@linxiraos/zeta 1.1.2 → 1.1.3
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var kPo=Object.create;var{getPrototypeOf:wPo,defineProperty:ZKe,getOwnPropertyNames:xPo}=Object;var vPo=Object.prototype.hasOwnProperty;function EPo(e){return this[e]}var APo,MPo,zs=(e,t,s)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?APo??=new WeakMap:MPo??=new WeakMap,i=o.get(e);if(i)return i}s=e!=null?kPo(wPo(e)):{};let r=t||!e||!e.__esModule?ZKe(s,"default",{value:e,enumerable:!0}):s;if(e&&typeof e==="object"||typeof e==="function"){for(let a of xPo(e))if(!vPo.call(r,a))ZKe(r,a,{get:EPo.bind(e,a),enumerable:!0})}if(n)o.set(e,r);return r};var we=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var IPo=(e)=>e;function PPo(e,t){this[e]=IPo.bind(null,t)}var nt=(e,t)=>{for(var s in t)ZKe(e,s,{get:t[s],enumerable:!0,configurable:!0,set:PPo.bind(t,s)})};var E=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ks=import.meta.require;var O8t="1.1.
|
|
3
|
+
var kPo=Object.create;var{getPrototypeOf:wPo,defineProperty:ZKe,getOwnPropertyNames:xPo}=Object;var vPo=Object.prototype.hasOwnProperty;function EPo(e){return this[e]}var APo,MPo,zs=(e,t,s)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?APo??=new WeakMap:MPo??=new WeakMap,i=o.get(e);if(i)return i}s=e!=null?kPo(wPo(e)):{};let r=t||!e||!e.__esModule?ZKe(s,"default",{value:e,enumerable:!0}):s;if(e&&typeof e==="object"||typeof e==="function"){for(let a of xPo(e))if(!vPo.call(r,a))ZKe(r,a,{get:EPo.bind(e,a),enumerable:!0})}if(n)o.set(e,r);return r};var we=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var IPo=(e)=>e;function PPo(e,t){this[e]=IPo.bind(null,t)}var nt=(e,t)=>{for(var s in t)ZKe(e,s,{get:t[s],enumerable:!0,configurable:!0,set:PPo.bind(t,s)})};var E=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ks=import.meta.require;var O8t="1.1.3",_8t;var P8t=E(()=>{_8t={bun:">=1.3.14"}});import*as Wr from"fs";import*as wee from"os";import*as Ns from"path";function wU(e){let t=e?.trim();if(!t||t==="default")return;if(t==="."||t===".."||t.endsWith(".")||!F8t.test(t)||_Po.test(t))throw Error(`Invalid OMP profile "${e}". Profile names must match ${F8t.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 nYe(e,t){return wU(e!==void 0?e:t)}function FPo(){return nYe(process.env.OMP_PROFILE,process.env.PI_PROFILE)}function LPo(){try{return FPo()}catch{return}}function oYe(){return Ns.join(wee.homedir(),Nx())}function rYe(e){let t=oYe();return e?Ns.join(t,"profiles",e):t}function iYe(){try{return wU(process.env.PI_PROFILE)}catch{return}}function NPo(e){return Ns.join(rYe(e),"agent")}function DPo(e,t){return e!==void 0&&t===NPo(e)}function N8t(e){if(process.platform!=="darwin"||!e.startsWith("/private/"))return e;let t=e.slice(8);try{if(Wr.realpathSync(e)===Wr.realpathSync(t))return t}catch{}return e}function vee(e){let t=Ns.resolve(e);try{return Wr.realpathSync(t)}catch{return t}}function sg(e){let t=vee(e);return process.platform==="win32"?t.toLowerCase():t}function MS(e,t){let s=sg(e),n=sg(t),o=Ns.relative(s,n);return o===""||!o.startsWith("..")&&!Ns.isAbsolute(o)}function a5(e,t){if(!MS(e,t))return null;let s=sg(e),n=sg(t);return Ns.relative(s,n)||null}function Ye(){return eYe}function Dx(e){eYe=N8t(Ns.resolve(e)),process.chdir(eYe)}async function qx(e){try{return(await Wr.promises.stat(e)).isDirectory()}catch{return!1}}function Nx(){if(process.env.PI_CONFIG_DIR)return process.env.PI_CONFIG_DIR;return".zeta"}function D8t(){let e=IS();return e?Ns.join(Nx(),"profiles",e,"agent"):`${Nx()}/agent`}class xee{configRoot;agentDir;#e;#t;#s=new Map;#n=new Map;constructor(e={}){let t=wU(e.profile);this.configRoot=rYe(t);let s=Ns.join(this.configRoot,"agent"),n=t?void 0:e.agentDirOverride;this.agentDir=n?Ns.resolve(n):s;let o=this.agentDir===s,i,r,a;if((process.platform==="linux"||process.platform==="darwin")&&o){let l=(u)=>{let p=process.env[u];if(!p)return;try{let c=Ns.join(p,Ct);if(t){let d=Ns.join(c,"profiles",t);if(Wr.existsSync(d))return d;return}if(Wr.existsSync(c))return c}catch{}return};i=l("XDG_DATA_HOME"),r=l("XDG_STATE_HOME"),a=l("XDG_CACHE_HOME")}this.#e={data:i??this.configRoot,state:r??this.configRoot,cache:a??this.configRoot},this.#t={data:i??this.agentDir,state:r??this.agentDir,cache:a??this.agentDir}}rootSubdir(e,t){let s=this.#s.get(e);if(s)return s;let n=t?this.#e[t]:this.configRoot,o=Ns.join(n,e);return this.#s.set(e,o),o}agentSubdir(e,t,s){if(!e||e===this.agentDir){let n=this.#n.get(t);if(n)return n;let o=s?this.#t[s]:this.agentDir,i=Ns.join(o,t);return this.#n.set(t,i),i}return Ns.join(e,t)}}function aYe(e,t,s=e){return DPo(e??s,t)?void 0:t}function q8t(){return eC?void 0:aYe(void 0,process.env.PI_CODING_AGENT_DIR,iYe())}function gRe(){Nn=new xee({agentDirOverride:q8t(),profile:eC})}function tC(){return Nn.configRoot}function lYe(e){let t=wU(e);if(t&&!eC)mRe=aYe(void 0,process.env.PI_CODING_AGENT_DIR,iYe());if(eC=t,eC)Nn=new xee({profile:eC}),process.env.OMP_PROFILE=eC,process.env.PI_PROFILE=eC,process.env.PI_CODING_AGENT_DIR=Nn.agentDir;else{for(let s of OPo)delete process.env[s];if(mRe===void 0)delete process.env.PI_CODING_AGENT_DIR;else process.env.PI_CODING_AGENT_DIR=mRe;Nn=new xee({agentDirOverride:mRe})}}function IS(){return eC}function U8t(e){return rYe(wU(e))}function Dt(){return Nn.agentDir}function Eee(e=Ye()){return Ns.join(e,".zeta")}function H8t(){return Nn.rootSubdir("reports","state")}function v_(){return Nn.rootSubdir("logs","state")}function l5(e=new Date,t=process.pid){return Ns.join(v_(),`${Ct}.${e.toISOString().slice(0,10)}.${t}.log`)}function rl(e){if(e!==void 0&&e!==qPo)return Ns.join(e,xa,"plugins");return Nn.rootSubdir("plugins","data")}function PS(e){return Ns.join(rl(e),"node_modules")}function xU(e){return Ns.join(rl(e),"package.json")}function hRe(e){return Ns.join(rl(e),"zeta-plugins.lock.json")}function TRe(){return Nn.rootSubdir("remote","data")}function B8t(e){let t=e?.trim();if(!t)return;let s=t;if(s==="~")s=wee.homedir();else if(s.startsWith("~/")||s.startsWith("~\\"))s=wee.homedir()+s.slice(1);return Ns.isAbsolute(s)?Ns.normalize(s):void 0}function uYe(e){return tYe=B8t(e),tYe}function yRe(){return B8t(process.env.OMP_WORKTREE_DIR)??tYe??Nn.rootSubdir("wt","data")}function W8t(){return Nn.rootSubdir("ssh-control","state")}function G8t(){return Nn.rootSubdir("remote-host","data")}function RRe(){return Nn.rootSubdir("python-env","data")}function u5(){return Nn.rootSubdir("puppeteer","cache")}function $8t(){return Nn.rootSubdir("browser-relay","data")}function z8t(){return Nn.rootSubdir("webcache","cache")}function j8t(){return Nn.rootSubdir("autoqa.db","data")}function V8t(e){return Bun.hash(Ns.resolve(e)).toString(16).padStart(16,"0").slice(-7)}function CRe(e){return Ns.join(yRe(),e)}function pYe(){return Nn.rootSubdir("gpu_cache.json","cache")}function cYe(){let e=process.env.OMP_GITHUB_CACHE_DB;if(e)return e;return Nn.rootSubdir(Ns.join("cache","github-cache.db"),"cache")}function K8t(){return Nn.rootSubdir(Ns.join("cache","legacy-pi-extension-cache.db"),"cache")}function Y8t(){let e=process.env.OMP_AUTH_BROKER_SNAPSHOT_CACHE;if(e)return e;return Nn.rootSubdir(Ns.join("cache","auth-broker-snapshot.enc"),"cache")}function X8t(){return Nn.rootSubdir(Ns.join("cache","avatars"),"cache")}function Aee(){return Nn.rootSubdir(Ns.join("cache","fastembed"),"cache")}function J8t(){return Nn.rootSubdir(Ns.join("cache","fastembed-runtime"),"cache")}function Ux(){return Nn.rootSubdir("stats.db","data")}function Q8t(){return Nn.rootSubdir("autoresearch","state")}function Z8t(e){return Ns.join(Q8t(),e)}function e9t(e){return Ns.join(Q8t(),`${e}.db`)}function UPo(){return Nn.rootSubdir("security","state")}function t9t(e){return Ns.join(UPo(),e)}function Go(e){return Nn.agentSubdir(e,"agent.db","data")}function Mee(e){return Nn.agentSubdir(e,"last-changelog-version","state")}function vU(e){return Nn.agentSubdir(e,"history.db","data")}function p5(e){return Nn.agentSubdir(e,"models.db","data")}function om(e){return Nn.agentSubdir(e,Ns.join("cache","tiny-models"),"cache")}function dYe(e){return Nn.agentSubdir(e,Ns.join("cache","document-conversions"),"cache")}function ng(e){return Nn.agentSubdir(e,"sessions","data")}function JT(e){return Nn.agentSubdir(e,"blobs","data")}function E_(e){return Nn.agentSubdir(e,"themes")}function s9t(e){return Nn.agentSubdir(e,"tools")}function n9t(e){return Nn.agentSubdir(e,"prompts")}function bRe(e){return Nn.agentSubdir(e,"memories","state")}function fYe(e){return Nn.agentSubdir(e,"terminal-sessions","state")}function o9t(e){return Nn.agentSubdir(e,`${Ct}-debug.log`,"state")}function r9t(e,t){if(t===e)return;try{if(Wr.existsSync(t)||!Wr.existsSync(e))return;Wr.mkdirSync(Ns.dirname(t),{recursive:!0}),Wr.copyFileSync(e,t,Wr.constants.COPYFILE_EXCL)}catch{}}function SRe(){let e=Nn.agentSubdir(void 0,"secret-placeholder.key","state");return r9t(Ns.join(Nn.agentDir,"secret-placeholder.key"),e),e}function kRe(){return Nn.rootSubdir(Ns.join("run","daemons"),"state")}function og(e){let t=Bun.hash.wyhash(Ns.resolve(e)).toString(16).padStart(16,"0");return Ns.join(kRe(),t)}function wRe(){return Ns.join(oYe(),"run","daemons","global")}function xRe(e){if(!/^[a-z0-9][a-z0-9._-]*$/i.test(e))throw Error(`Invalid global daemon service name: ${JSON.stringify(e)}`);return Ns.join(wRe(),e)}function i9t(){return Nn.rootSubdir(Ns.join("run","provider-inflight"),"state")}function QT(){let e=Nn.rootSubdir("marketplaces.json","data");return r9t(Ns.join(Nn.configRoot,"marketplaces.json"),e),e}function a9t(e=Ye()){return Ns.join(Eee(e),"prompts")}function l9t(e=Ye()){return Ns.join(Eee(e),"plugin-overrides.json")}function cr(e,t=Ye()){if(e==="user")return Ns.join(Dt(),"mcp.json");return Ns.join(Eee(t),"mcp.json")}function gd(e,t=Ye()){if(e==="user")return Ns.join(Dt(),"ssh.json");return Ns.join(Eee(t),"ssh.json")}function vRe(e=Ye()){return Ns.join(Eee(e),"tracking")}function u9t(e){return Ns.join(e??Dt(),"tracking-index.json")}function Hx(){if(kee)return kee;let e=Ns.join(oYe(),HPo),t=!1;try{let n=Wr.readFileSync(e,"utf8").trim();if(L8t.test(n))return kee=n,n;t=n.length>0}catch{}let s=crypto.randomUUID();try{if(Wr.mkdirSync(Ns.dirname(e),{recursive:!0}),t)try{Wr.unlinkSync(e)}catch{}let n=Wr.openSync(e,Wr.constants.O_WRONLY|Wr.constants.O_CREAT|Wr.constants.O_EXCL,384);try{Wr.writeSync(n,`${s}
|
|
4
4
|
`)}finally{Wr.closeSync(n)}}catch(n){if(n.code==="EEXIST")try{let o=Wr.readFileSync(e,"utf8").trim();if(L8t.test(o))return kee=o,o}catch{}}return kee=s,s}var Ct="zeta",xa=".zeta",UM,pr,go,sYe,F8t,OPo,_Po,eYe,eC,Nn,mRe,qPo,tYe,kee=null,HPo="install-id",L8t;var lu=E(()=>{P8t();UM=["config.yml","config.yaml"],pr=O8t,go=`zeta/${pr}`,sYe=_8t.bun.replace(/[^0-9.]/g,""),F8t=/^[a-z0-9][a-z0-9._-]{0,63}$/,OPo=["OMP_PROFILE","PI_PROFILE"],_Po=/^(?:CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(?:\..*)?$/i;eYe=N8t(process.cwd());eC=LPo();Nn=new xee({agentDirOverride:q8t(),profile:eC}),mRe=aYe(eC,process.env.PI_CODING_AGENT_DIR,eC??iYe()),qPo=wee.homedir();L8t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});import*as p9t from"crypto";import*as xh from"fs";import*as c9t from"os";import*as d9t from"path";function BPo(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 mYe{#e;#t;#s;#n;#o;#r;#a;#i;#l=0;#u;#p=0;#c=!1;constructor(e){this.#e=e.directory,this.#t=e.filenamePrefix,this.#s=e.filenameSuffix,this.#n=e.auditFile,this.#o=e.maxBytes,this.#r=e.maxFiles,this.#a=this.#h();let t=new Date;this.#f(this.#d(t));let s=this.#u;if(s)this.#g(s,t.getTime()),xh.closeSync(xh.openSync(s,"a"))}write(e){if(this.#c)return;let t=new Date;this.#f(this.#d(t));let s=this.#u;if(!s)return;this.#g(s,t.getTime());let n=`${e}${c9t.EOL}`;xh.appendFileSync(s,n,"utf8"),this.#p+=Buffer.byteLength(n)}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 s=t===0?"":`.${t}`;this.#u=d9t.join(this.#e,`${this.#t}.${e}.${this.#s}.log${s}`);try{this.#p=xh.statSync(this.#u).size}catch{this.#p=0}}#g(e,t){if(this.#a.some((n)=>n.name===e))return;let s=p9t.createHash("sha256").update(`${e}LOG_FILE${t}`).digest("hex");this.#a.push({date:t,name:e,hash:s});while(this.#a.length>this.#r){let n=this.#a.shift();if(!n)break;try{xh.rmSync(n.name,{force:!0})}catch{}}this.#T()}#h(){try{let e=JSON.parse(xh.readFileSync(this.#n,"utf8"));return Array.isArray(e.files)?e.files.filter(BPo):[]}catch{return[]}}#T(){let e={keep:{days:!1,amount:this.#r},auditLog:this.#n,files:this.#a,hashType:"sha256"};xh.writeFileSync(this.#n,JSON.stringify(e,void 0,4),"utf8")}}var f9t=()=>{};function g9t(){let e=globalThis,t=e[m9t];if(!t||t.length===0)return[];return e[m9t]=[],t}var m9t;var h9t=E(()=>{m9t=Symbol.for("omp.moduleLoadBuffer")});var P={};nt(P,{debug:()=>sf,endTiming:()=>pOo,error:()=>AU,info:()=>oOo,openSpanPath:()=>cOo,printTimings:()=>iOo,recordModuleLoadSpan:()=>S9t,registerLogSink:()=>$Po,setTransports:()=>RYe,shouldExitAfterTimings:()=>rOo,startTiming:()=>aOo,startupMarker:()=>ERe,time:()=>hOo,timingModeIncludes:()=>IRe,warn:()=>ia});import{AsyncLocalStorage as WPo}from"async_hooks";import*as rg from"fs";import*as R9t from"os";import*as yYe from"path";import{isPromise as GPo}from"util/types";function $Po(e){return MRe.add(e),()=>{MRe.delete(e)}}function PRe(e,t,s){if(MRe.size===0)return;let n={level:e,message:t,context:s,timestamp:new Date};for(let o of MRe)try{o(n)}catch{}}function YPo(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&(t.code==="ESRCH"||t.code==="EINVAL"))}}function XPo(e){let t;try{t=rg.readdirSync(e,{withFileTypes:!0})}catch{return}let s=new Date,n=`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-`+String(s.getDate()).padStart(2,"0"),o=new Date(s);o.setDate(o.getDate()-(KPo-1));let i=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-`+String(o.getDate()).padStart(2,"0"),r=new Map;for(let a of t){if(!a.isFile())continue;let l=zPo.exec(a.name),u=jPo.exec(a.name),p=l?.[2]??u?.[1];if(!p||YPo(Number(p)))continue;let c=yYe.join(e,a.name);if(u){if(VPo===0)try{rg.rmSync(c,{force:!0})}catch{}continue}if(!l?.[1])continue;if(l[1]<i||l[1]>n){try{rg.rmSync(c,{force:!0})}catch{}continue}let d=`${p}:${l[1]}`,f=r.get(d)??[];f.push({path:c,rollover:Number(l[3]??0)}),r.set(d,f)}for(let a of r.values()){if(a.length<=T9t)continue;let l=[];for(let u of a)try{l.push({...u,mtimeMs:rg.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(T9t))try{rg.rmSync(u.path,{force:!0})}catch{}}}function JPo(e){if(!rg.existsSync(e))rg.mkdirSync(e,{recursive:!0});return e}function QPo(e,t){if(t instanceof Error){let s={name:t.name,message:t.message,stack:t.stack},n=t;for(let o in n)s[o]=n[o];if(t.cause!==void 0)s.cause=t.cause;return s}return t}function HM(e,t=2){return String(e).padStart(t,"0")}function ZPo(e){let t=-e.getTimezoneOffset(),s=Math.abs(t),n=t>=0?"+":"-";return`${HM(e.getFullYear(),4)}-${HM(e.getMonth()+1)}-${HM(e.getDate())}T${HM(e.getHours())}:${HM(e.getMinutes())}:${HM(e.getSeconds())}.${HM(e.getMilliseconds(),3)}${n}${HM(Math.floor(s/60))}:${HM(s%60)}`}function tOo(e,t,s){let n=!eOo.test(t)&&s!==null&&typeof s==="object"?s:void 0,o=Object.assign({},n,{level:e,message:t});if(n?.message)o.message=`${t} ${n.message}`;if(n?.stack)o.stack=n.stack;if(n?.cause)o.cause=n.cause;return o}function y9t(e){let t=ZPo(new Date);e.timestamp=t;let s={timestamp:t,level:e.level,pid:process.pid,message:e.message};for(let[n,o]of Object.entries(e))if(n!=="level"&&n!=="timestamp"&&n!=="message")s[n]=o;return JSON.stringify(s,QPo)}function sOo(e){let t=JPo(e??v_());return XPo(t),new mYe({directory:t,filenamePrefix:"zeta",filenameSuffix:String(process.pid),maxBytes:10485760,maxFiles:5,auditFile:yYe.join(t,`.zeta.${process.pid}-audit.json`)})}function b9t(e){return{file:e.file?sOo(typeof e.file==="string"?e.file:void 0):void 0,console:e.console===!0}}function nOo(){return c5??=b9t(C9t),c5}function ORe(e,t,s){let n=nOo(),o=tOo(e,t,s);if(!n.file&&!n.console)return;let i=y9t(o);if(n.file)n.file.write(i);if(n.console)rg.writeSync(1,`${y9t(o)}${R9t.EOL}`)}function RYe(e){if(C9t=e,!c5)return;let t=c5;c5={file:void 0,console:!1},t.file?.close(),c5=b9t(e)}function AU(e,t){try{ORe("error",e,t)}catch{}PRe("error",e,t)}function ia(e,t){try{ORe("warn",e,t)}catch{}PRe("warn",e,t)}function oOo(e,t){try{ORe("info",e,t)}catch{}PRe("info",e,t)}function sf(e,t){try{ORe("debug",e,t)}catch{}PRe("debug",e,t)}function ERe(e){if(!process.env.PI_DEBUG_STARTUP)return;try{rg.writeSync(2,`[startup] ${e}
|
|
5
5
|
`)}catch{}}function IRe(e){let t=process.env.PI_TIMING;if(!t)return!1;if(t===e)return!0;let s=0;for(let n=0;n<=t.length;n++){let o=n===t.length?44:t.charCodeAt(n);if(!(o===44||o===58||o===59||o===43||o<=32))continue;if(n>s&&t.slice(s,n)===e)return!0;s=n+1}return!1}function rOo(){return IRe("x")||IRe("full")}function iOo(){if(!d5||!pp){console.error(`
|
|
6
6
|
--- Startup Timings ---
|
|
@@ -995,7 +995,7 @@ ${e.content}
|
|
|
995
995
|
selectableModels { name ref }
|
|
996
996
|
pinnedModel { name ref }
|
|
997
997
|
}
|
|
998
|
-
}`,jZo,Mnt="zeta_agent",Int="zeta_inline_prompt",VZo,KZo,Lnt=(e,t,s)=>{let n=new bn,o=zer(e);n.push({type:"start",partial:o});let i={stream:n,output:o,started:!0};return ver(e,t,s,i).catch((r)=>{let a=$F(r);if(!n.done)o.stopReason="error",o.errorMessage=i.goalOverflowMessage??a,n.push({type:"error",reason:"error",error:o})}),n},Yus,eps,ntr="<|im_start|>",otr="<|im_end|>",Str;var Dnt=E(()=>{Ywe();St();bi();Ba();SF();zus();$h();qZo=Lxe.resolve(import.meta.dir,"../../../../.tmp/gitlab-duo-workflow-trace.log");jZo=["incremental_streaming","read_file_chunked","shell_command","command_timeout","tool_call_approval"],VZo=["on_agent_reasoning","on_agent_final_answer","on_tool_execution_success","on_tool_execution_failed"],KZo=["runMCPTool","run_mcp_tool"];Yus=new Map;eps=jus.trim();Str=["Chat Agent","context_builder"]});import{Buffer as gps}from"buffer";import*as Rps from"os";import*as Cps from"path";function Mtr(){return _Ce("GOOGLE_VERTEX_REFRESH_SKEW_MS",60000)}function Itr(){return Cps.join(Rps.homedir(),".config","gcloud","application_default_credentials.json")}async function hps(e){try{return await Bun.file(e).json()}catch(t){if(ye(t))return;throw t}}async function Ptr(){let e=Bun.env.GOOGLE_APPLICATION_CREDENTIALS;if(e){let n=await hps(e);if(!n)throw new ms(`GOOGLE_APPLICATION_CREDENTIALS points to a missing file: ${e}`);return{source:`gac:${e}`,creds:n}}let t=Itr(),s=await hps(t);if(s)return{source:`user:${t}`,creds:s};return}function Hnt(e){let t=typeof e==="string"?gps.from(e,"utf8"):e;return gps.from(t.buffer,t.byteOffset,t.byteLength).toString("base64url")}function Otr(e){let t=e.replace(/-----BEGIN [^-]+-----/g,"").replace(/-----END [^-]+-----/g,"").replace(/\s+/g,"");if(!t)throw new ms("Invalid PEM: empty body");return Uint8Array.fromBase64(t)}async function _tr(e,t,s){let n={alg:"RS256",typ:"JWT"};if(s)n.kid=s;let o=`${Hnt(JSON.stringify(n))}.${Hnt(JSON.stringify(e))}`,i=await globalThis.crypto.subtle.importKey("pkcs8",Otr(t),{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["sign"]),r=new Uint8Array(await globalThis.crypto.subtle.sign("RSASSA-PKCS1-v1_5",i,new TextEncoder().encode(o)));return`${o}.${Hnt(r)}`}async function Tps(e,t,s){let n=Math.floor(Date.now()/1000),o=await _tr({iss:e.client_email,scope:bps,aud:Bnt,exp:n+3600,iat:n},e.private_key,e.private_key_id),i=new URLSearchParams({grant_type:Atr,assertion:o});return Sps(Bnt,i,t,s)}async function yps(e,t,s){let n=new URLSearchParams({client_id:e.client_id,client_secret:e.client_secret,refresh_token:e.refresh_token,grant_type:"refresh_token"});return Sps(Bnt,n,t,s)}async function Ftr(e,t){let s=AbortSignal.timeout(2000),n=e?AbortSignal.any([e,s]):s;try{let o=await t(Etr,{method:"GET",headers:{"Metadata-Flavor":"Google"},signal:n});if(!o.ok)return;return await o.json()}catch{return}}async function Sps(e,t,s,n){let o=await n(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t.toString(),signal:s});if(!o.ok){let i=await o.text().catch(()=>"");throw new et(`Google OAuth token exchange failed (${o.status}): ${i}`,{kind:"token-exchange",provider:"google-vertex",status:o.status})}return await o.json()}async function Ltr(e,t){let s=await Ptr();if(s){let o=s.creds,i;if(o.type==="impersonated_service_account"){let a=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(o.service_account_impersonation_url)?.groups?.target;if(!a)throw RangeError(`Cannot extract target principal from ${o.service_account_impersonation_url}`);let l=o.source_credentials.type==="service_account"?await Tps(o.source_credentials,e,t):await yps(o.source_credentials,e,t),u=await t(`https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${a}:generateAccessToken`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({delegates:o.delegates??[],scope:[bps],lifetime:"3600s"}),signal:e});if(!u.ok){let d=await u.text().catch(()=>"");throw new et(`Google Impersonation token exchange failed (${u.status}): ${d}`,{kind:"token-exchange",provider:"google-vertex",status:u.status})}let p=await u.json(),c=Math.max(0,Math.floor((new Date(p.expireTime).getTime()-Date.now())/1000));i={access_token:p.accessToken,expires_in:c,token_type:"Bearer"}}else i=o.type==="service_account"?await Tps(o,e,t):await yps(o,e,t);return{source:s.source,token:i}}let n=await Ftr(e,t);if(n)return{source:"metadata",token:n};throw new Kr(void 0,"Vertex AI requires Application Default Credentials. Set GOOGLE_APPLICATION_CREDENTIALS, run `gcloud auth application-default login`, or run on a GCE/Cloud Run instance with a service account.")}async function Nxe(e){let t=Bun.env.GOOGLE_CLOUD_ACCESS_TOKEN||Bun.env.CLOUDSDK_AUTH_ACCESS_TOKEN;if(t)return t;let s=e?.fetch??globalThis.fetch.bind(globalThis),n=Mtr(),o=Date.now();for(let[l,u]of qnt){if(u.expiresAtMs-n>o)return u.token;qnt.delete(l)}let i="vertex-adc",r=Unt.get(i);if(r)return ly(r,e?.signal);let a=(async()=>{try{let{source:l,token:u}=await Ltr(AbortSignal.timeout(Ntr),s),p=Date.now()+Math.max(0,u.expires_in*1000);return qnt.set(l,{token:u.access_token,expiresAtMs:p}),P.debug("vertex.adc acquired access token",{source:l,expiresInSec:u.expires_in}),u.access_token}finally{Unt.delete(i)}})();return Unt.set(i,a),ly(a,e?.signal)}var Bnt="https://oauth2.googleapis.com/token",Etr="http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token",bps="https://www.googleapis.com/auth/cloud-platform",Atr="urn:ietf:params:oauth:grant-type:jwt-bearer",qnt,Unt,Ntr=30000;var Wnt=E(()=>{X();St();$S();qnt=new Map,Unt=new Map});var Gnt;var kps=E(()=>{Gnt={type:"module",name:"@linxiraos/pi-ai",version:"1.1.2",description:"Unified LLM API with automatic model discovery and provider configuration",homepage:"https://linxira-os.github.io/zeta/",author:"Can Boluk",contributors:["Mario Zechner"],license:"MIT",repository:{type:"git",url:"git+https://github.com/Linxira-OS/linxira-zeta.git",directory:"packages/ai"},bugs:{url:"https://github.com/Linxira-OS/linxira-zeta/issues"},keywords:["ai","llm","openai","anthropic","gemini","unified","api"],main:"./src/index.ts",types:"./dist/types/index.d.ts",scripts:{check:"biome check . && bun run check:types","check:types":"tsgo -p tsconfig.json --noEmit",lint:"biome lint .",test:"bun test --parallel",fix:"biome check --write --unsafe .",fmt:"biome format --write ."},dependencies:{"@linxiraos/pi-omptype":"1.1.2","@linxiraos/pi-catalog":"1.1.2","@linxiraos/pi-utils":"1.1.2","@linxiraos/pi-wire":"1.1.2"},devDependencies:{"@types/bun":"^1.3.14"},engines:{bun:">=1.3.14"},files:["src","README.md","CHANGELOG.md","LICENSE","THIRD-PARTY-NOTICES.txt","dist/types"],exports:{".":{types:"./dist/types/index.d.ts",import:"./src/index.ts"},"./error":{types:"./dist/types/error/index.d.ts",import:"./src/error/index.ts"},"./*":{types:"./dist/types/*.d.ts",import:"./src/*.ts"},"./auth-broker":{types:"./dist/types/auth-broker/index.d.ts",import:"./src/auth-broker/index.ts"},"./auth-broker/*":{types:"./dist/types/auth-broker/*.d.ts",import:"./src/auth-broker/*.ts"},"./auth-gateway":{types:"./dist/types/auth-gateway/index.d.ts",import:"./src/auth-gateway/index.ts"},"./auth-gateway/*":{types:"./dist/types/auth-gateway/*.d.ts",import:"./src/auth-gateway/*.ts"},"./providers/*":{types:"./dist/types/providers/*.d.ts",import:"./src/providers/*.ts"},"./providers/openai-codex/*":{types:"./dist/types/providers/openai-codex/*.d.ts",import:"./src/providers/openai-codex/*.ts"},"./usage/*":{types:"./dist/types/usage/*.d.ts",import:"./src/usage/*.ts"},"./utils/harmony-leak":{types:"./dist/types/utils/harmony-leak.d.ts",import:"./src/utils/harmony-leak.ts"},"./dialect":{types:"./dist/types/dialect/index.d.ts",import:"./src/dialect/index.ts"},"./utils/*":{types:"./dist/types/utils/*.d.ts",import:"./src/utils/*.ts"},"./oauth":{types:"./dist/types/registry/oauth/index.d.ts",import:"./src/registry/oauth/index.ts"},"./oauth/*":{types:"./dist/types/registry/oauth/*.d.ts",import:"./src/registry/oauth/*.ts"},"./registry":{types:"./dist/types/registry/index.d.ts",import:"./src/registry/index.ts"},"./registry/oauth":{types:"./dist/types/registry/oauth/index.d.ts",import:"./src/registry/oauth/index.ts"},"./utils/schema":{types:"./dist/types/utils/schema/index.d.ts",import:"./src/utils/schema/index.ts"},"./utils/schema/*":{types:"./dist/types/utils/schema/*.d.ts",import:"./src/utils/schema/*.ts"},"./*.js":"./src/*.ts"}}});var Knt={};nt(Knt,{getKimiCommonHeaders:()=>sk,loginKimi:()=>jtr,refreshKimiToken:()=>Vtr});import*as xps from"crypto";import*as w4 from"fs";import*as wv from"os";import*as qxe from"path";import{scheduler as wps}from"timers/promises";function Vnt(){return be.KIMI_CODE_OAUTH_HOST||be.KIMI_OAUTH_HOST||qtr}function $nt(e,t,s){return[e,t,s].filter(Boolean).join(" ").trim()}function Gtr(){let e=wv.platform(),t=wv.release(),s=wv.arch();if(e==="darwin")return $nt("macOS",t,s);if(e==="win32")return $nt("Windows",t,s);return $nt(e==="linux"?"Linux":e,t,s)}function Dxe(e,t=""){return e.replace(/[^\x20-\x7E]/g,"").trim()||t}async function $tr(){let e=await fetch(`${Vnt()}/api/oauth/device_authorization`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...sk()},body:new URLSearchParams({client_id:jnt})});if(!e.ok){let l=await e.text();throw new et(`Kimi device authorization failed: ${e.status} ${l}`,{kind:"device-auth",provider:"kimi",status:e.status})}let t=await e.json(),s=t.user_code,n=t.device_code,o=t.verification_uri,i=t.verification_uri_complete;if(!s||!n||!o)throw new et("Kimi device authorization response missing required fields",{kind:"validation",provider:"kimi"});let r=typeof t.expires_in==="number"?t.expires_in*1000:Btr,a=typeof t.interval==="number"&&t.interval>0?t.interval*1000:Htr;return{userCode:s,deviceCode:n,verificationUri:o,verificationUriComplete:i||o,expiresInMs:r,intervalMs:a}}function vps(e,t){if(!e.access_token||typeof e.expires_in!=="number")throw new et("Kimi token response missing required fields",{kind:"validation",provider:"kimi"});let s=e.refresh_token??t;if(!s)throw new et("Kimi token response missing refresh token",{kind:"validation",provider:"kimi"});let n,o=e.access_token.split("."),i=o.length===3?o[1]:void 0;if(i)try{let r=JSON.parse(new TextDecoder("utf-8").decode(Uint8Array.fromBase64(i,{alphabet:"base64url"})));if(ce(r)){let a=typeof r.user_id==="string"?r.user_id.trim():"",l=typeof r.sub==="string"?r.sub.trim():"";n=a||l||void 0}}catch{}return{access:e.access_token,refresh:s,expires:Date.now()+e.expires_in*1000-Wtr,accountId:n}}async function ztr(e,t,s,n){let o=Date.now()+s,i=Math.max(1000,t);while(Date.now()<o){if(n?.aborted)throw new rn;let r=await fetch(`${Vnt()}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...sk()},body:new URLSearchParams({client_id:jnt,device_code:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}),a=await r.json();if(r.ok&&a.access_token)return vps(a);let l=a.error;if(l==="authorization_pending"){await wps.wait(i,{signal:n});continue}if(l==="slow_down"){i+=5000;let p=typeof a.interval==="number"?a.interval*1000:void 0;if(p&&p>i)i=p;await wps.wait(i,{signal:n});continue}if(l==="expired_token")throw new et("Kimi device authorization expired",{kind:"validation",provider:"kimi"});if(l==="access_denied")throw new et("Kimi device authorization denied",{kind:"validation",provider:"kimi"});let u=a.error_description?`: ${a.error_description}`:"";throw new et(`Kimi device flow failed: ${l??r.status}${u}`,{kind:"polling",provider:"kimi"})}throw new et("Kimi device flow timed out",{kind:"timeout",provider:"kimi"})}async function jtr(e){let t=await $tr();return e.onAuth?.({url:t.verificationUriComplete,instructions:`Enter code: ${t.userCode}`}),ztr(t.deviceCode,t.intervalMs,t.expiresInMs,e.signal)}async function Vtr(e){let t=await fetch(`${Vnt()}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...sk()},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:jnt})});if(!t.ok){let n=await t.json().catch(()=>{return}),o=n?.error_description?`: ${n.error_description}`:"";throw new et(`Kimi token refresh failed: ${t.status}${o}`,{kind:"token-refresh",provider:"kimi",status:t.status})}let s=await t.json();return vps(s,e)}var jnt="17e5f671-d194-4dfb-9706-5516cb48c098",qtr="https://auth.kimi.com",Utr="kimi-device-id",Htr=5000,Btr=900000,Wtr=300000,znt=()=>{let e=qxe.join(Dt(),Utr);try{let s=w4.readFileSync(e,"utf-8").trim();if(s)return znt=()=>s,s}catch{}let t=xps.randomUUID().replace(/-/g,"");try{w4.mkdirSync(qxe.dirname(e),{recursive:!0}),w4.writeFileSync(e,`${t}
|
|
998
|
+
}`,jZo,Mnt="zeta_agent",Int="zeta_inline_prompt",VZo,KZo,Lnt=(e,t,s)=>{let n=new bn,o=zer(e);n.push({type:"start",partial:o});let i={stream:n,output:o,started:!0};return ver(e,t,s,i).catch((r)=>{let a=$F(r);if(!n.done)o.stopReason="error",o.errorMessage=i.goalOverflowMessage??a,n.push({type:"error",reason:"error",error:o})}),n},Yus,eps,ntr="<|im_start|>",otr="<|im_end|>",Str;var Dnt=E(()=>{Ywe();St();bi();Ba();SF();zus();$h();qZo=Lxe.resolve(import.meta.dir,"../../../../.tmp/gitlab-duo-workflow-trace.log");jZo=["incremental_streaming","read_file_chunked","shell_command","command_timeout","tool_call_approval"],VZo=["on_agent_reasoning","on_agent_final_answer","on_tool_execution_success","on_tool_execution_failed"],KZo=["runMCPTool","run_mcp_tool"];Yus=new Map;eps=jus.trim();Str=["Chat Agent","context_builder"]});import{Buffer as gps}from"buffer";import*as Rps from"os";import*as Cps from"path";function Mtr(){return _Ce("GOOGLE_VERTEX_REFRESH_SKEW_MS",60000)}function Itr(){return Cps.join(Rps.homedir(),".config","gcloud","application_default_credentials.json")}async function hps(e){try{return await Bun.file(e).json()}catch(t){if(ye(t))return;throw t}}async function Ptr(){let e=Bun.env.GOOGLE_APPLICATION_CREDENTIALS;if(e){let n=await hps(e);if(!n)throw new ms(`GOOGLE_APPLICATION_CREDENTIALS points to a missing file: ${e}`);return{source:`gac:${e}`,creds:n}}let t=Itr(),s=await hps(t);if(s)return{source:`user:${t}`,creds:s};return}function Hnt(e){let t=typeof e==="string"?gps.from(e,"utf8"):e;return gps.from(t.buffer,t.byteOffset,t.byteLength).toString("base64url")}function Otr(e){let t=e.replace(/-----BEGIN [^-]+-----/g,"").replace(/-----END [^-]+-----/g,"").replace(/\s+/g,"");if(!t)throw new ms("Invalid PEM: empty body");return Uint8Array.fromBase64(t)}async function _tr(e,t,s){let n={alg:"RS256",typ:"JWT"};if(s)n.kid=s;let o=`${Hnt(JSON.stringify(n))}.${Hnt(JSON.stringify(e))}`,i=await globalThis.crypto.subtle.importKey("pkcs8",Otr(t),{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["sign"]),r=new Uint8Array(await globalThis.crypto.subtle.sign("RSASSA-PKCS1-v1_5",i,new TextEncoder().encode(o)));return`${o}.${Hnt(r)}`}async function Tps(e,t,s){let n=Math.floor(Date.now()/1000),o=await _tr({iss:e.client_email,scope:bps,aud:Bnt,exp:n+3600,iat:n},e.private_key,e.private_key_id),i=new URLSearchParams({grant_type:Atr,assertion:o});return Sps(Bnt,i,t,s)}async function yps(e,t,s){let n=new URLSearchParams({client_id:e.client_id,client_secret:e.client_secret,refresh_token:e.refresh_token,grant_type:"refresh_token"});return Sps(Bnt,n,t,s)}async function Ftr(e,t){let s=AbortSignal.timeout(2000),n=e?AbortSignal.any([e,s]):s;try{let o=await t(Etr,{method:"GET",headers:{"Metadata-Flavor":"Google"},signal:n});if(!o.ok)return;return await o.json()}catch{return}}async function Sps(e,t,s,n){let o=await n(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t.toString(),signal:s});if(!o.ok){let i=await o.text().catch(()=>"");throw new et(`Google OAuth token exchange failed (${o.status}): ${i}`,{kind:"token-exchange",provider:"google-vertex",status:o.status})}return await o.json()}async function Ltr(e,t){let s=await Ptr();if(s){let o=s.creds,i;if(o.type==="impersonated_service_account"){let a=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(o.service_account_impersonation_url)?.groups?.target;if(!a)throw RangeError(`Cannot extract target principal from ${o.service_account_impersonation_url}`);let l=o.source_credentials.type==="service_account"?await Tps(o.source_credentials,e,t):await yps(o.source_credentials,e,t),u=await t(`https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${a}:generateAccessToken`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l.access_token}`},body:JSON.stringify({delegates:o.delegates??[],scope:[bps],lifetime:"3600s"}),signal:e});if(!u.ok){let d=await u.text().catch(()=>"");throw new et(`Google Impersonation token exchange failed (${u.status}): ${d}`,{kind:"token-exchange",provider:"google-vertex",status:u.status})}let p=await u.json(),c=Math.max(0,Math.floor((new Date(p.expireTime).getTime()-Date.now())/1000));i={access_token:p.accessToken,expires_in:c,token_type:"Bearer"}}else i=o.type==="service_account"?await Tps(o,e,t):await yps(o,e,t);return{source:s.source,token:i}}let n=await Ftr(e,t);if(n)return{source:"metadata",token:n};throw new Kr(void 0,"Vertex AI requires Application Default Credentials. Set GOOGLE_APPLICATION_CREDENTIALS, run `gcloud auth application-default login`, or run on a GCE/Cloud Run instance with a service account.")}async function Nxe(e){let t=Bun.env.GOOGLE_CLOUD_ACCESS_TOKEN||Bun.env.CLOUDSDK_AUTH_ACCESS_TOKEN;if(t)return t;let s=e?.fetch??globalThis.fetch.bind(globalThis),n=Mtr(),o=Date.now();for(let[l,u]of qnt){if(u.expiresAtMs-n>o)return u.token;qnt.delete(l)}let i="vertex-adc",r=Unt.get(i);if(r)return ly(r,e?.signal);let a=(async()=>{try{let{source:l,token:u}=await Ltr(AbortSignal.timeout(Ntr),s),p=Date.now()+Math.max(0,u.expires_in*1000);return qnt.set(l,{token:u.access_token,expiresAtMs:p}),P.debug("vertex.adc acquired access token",{source:l,expiresInSec:u.expires_in}),u.access_token}finally{Unt.delete(i)}})();return Unt.set(i,a),ly(a,e?.signal)}var Bnt="https://oauth2.googleapis.com/token",Etr="http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token",bps="https://www.googleapis.com/auth/cloud-platform",Atr="urn:ietf:params:oauth:grant-type:jwt-bearer",qnt,Unt,Ntr=30000;var Wnt=E(()=>{X();St();$S();qnt=new Map,Unt=new Map});var Gnt;var kps=E(()=>{Gnt={type:"module",name:"@linxiraos/pi-ai",version:"1.1.3",description:"Unified LLM API with automatic model discovery and provider configuration",homepage:"https://linxira-os.github.io/zeta/",author:"Can Boluk",contributors:["Mario Zechner"],license:"MIT",repository:{type:"git",url:"git+https://github.com/Linxira-OS/linxira-zeta.git",directory:"packages/ai"},bugs:{url:"https://github.com/Linxira-OS/linxira-zeta/issues"},keywords:["ai","llm","openai","anthropic","gemini","unified","api"],main:"./src/index.ts",types:"./dist/types/index.d.ts",scripts:{check:"biome check . && bun run check:types","check:types":"tsgo -p tsconfig.json --noEmit",lint:"biome lint .",test:"bun test --parallel",fix:"biome check --write --unsafe .",fmt:"biome format --write ."},dependencies:{"@linxiraos/pi-omptype":"1.1.3","@linxiraos/pi-catalog":"1.1.3","@linxiraos/pi-utils":"1.1.3","@linxiraos/pi-wire":"1.1.3"},devDependencies:{"@types/bun":"^1.3.14"},engines:{bun:">=1.3.14"},files:["src","README.md","CHANGELOG.md","LICENSE","THIRD-PARTY-NOTICES.txt","dist/types"],exports:{".":{types:"./dist/types/index.d.ts",import:"./src/index.ts"},"./error":{types:"./dist/types/error/index.d.ts",import:"./src/error/index.ts"},"./*":{types:"./dist/types/*.d.ts",import:"./src/*.ts"},"./auth-broker":{types:"./dist/types/auth-broker/index.d.ts",import:"./src/auth-broker/index.ts"},"./auth-broker/*":{types:"./dist/types/auth-broker/*.d.ts",import:"./src/auth-broker/*.ts"},"./auth-gateway":{types:"./dist/types/auth-gateway/index.d.ts",import:"./src/auth-gateway/index.ts"},"./auth-gateway/*":{types:"./dist/types/auth-gateway/*.d.ts",import:"./src/auth-gateway/*.ts"},"./providers/*":{types:"./dist/types/providers/*.d.ts",import:"./src/providers/*.ts"},"./providers/openai-codex/*":{types:"./dist/types/providers/openai-codex/*.d.ts",import:"./src/providers/openai-codex/*.ts"},"./usage/*":{types:"./dist/types/usage/*.d.ts",import:"./src/usage/*.ts"},"./utils/harmony-leak":{types:"./dist/types/utils/harmony-leak.d.ts",import:"./src/utils/harmony-leak.ts"},"./dialect":{types:"./dist/types/dialect/index.d.ts",import:"./src/dialect/index.ts"},"./utils/*":{types:"./dist/types/utils/*.d.ts",import:"./src/utils/*.ts"},"./oauth":{types:"./dist/types/registry/oauth/index.d.ts",import:"./src/registry/oauth/index.ts"},"./oauth/*":{types:"./dist/types/registry/oauth/*.d.ts",import:"./src/registry/oauth/*.ts"},"./registry":{types:"./dist/types/registry/index.d.ts",import:"./src/registry/index.ts"},"./registry/oauth":{types:"./dist/types/registry/oauth/index.d.ts",import:"./src/registry/oauth/index.ts"},"./utils/schema":{types:"./dist/types/utils/schema/index.d.ts",import:"./src/utils/schema/index.ts"},"./utils/schema/*":{types:"./dist/types/utils/schema/*.d.ts",import:"./src/utils/schema/*.ts"},"./*.js":"./src/*.ts"}}});var Knt={};nt(Knt,{getKimiCommonHeaders:()=>sk,loginKimi:()=>jtr,refreshKimiToken:()=>Vtr});import*as xps from"crypto";import*as w4 from"fs";import*as wv from"os";import*as qxe from"path";import{scheduler as wps}from"timers/promises";function Vnt(){return be.KIMI_CODE_OAUTH_HOST||be.KIMI_OAUTH_HOST||qtr}function $nt(e,t,s){return[e,t,s].filter(Boolean).join(" ").trim()}function Gtr(){let e=wv.platform(),t=wv.release(),s=wv.arch();if(e==="darwin")return $nt("macOS",t,s);if(e==="win32")return $nt("Windows",t,s);return $nt(e==="linux"?"Linux":e,t,s)}function Dxe(e,t=""){return e.replace(/[^\x20-\x7E]/g,"").trim()||t}async function $tr(){let e=await fetch(`${Vnt()}/api/oauth/device_authorization`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...sk()},body:new URLSearchParams({client_id:jnt})});if(!e.ok){let l=await e.text();throw new et(`Kimi device authorization failed: ${e.status} ${l}`,{kind:"device-auth",provider:"kimi",status:e.status})}let t=await e.json(),s=t.user_code,n=t.device_code,o=t.verification_uri,i=t.verification_uri_complete;if(!s||!n||!o)throw new et("Kimi device authorization response missing required fields",{kind:"validation",provider:"kimi"});let r=typeof t.expires_in==="number"?t.expires_in*1000:Btr,a=typeof t.interval==="number"&&t.interval>0?t.interval*1000:Htr;return{userCode:s,deviceCode:n,verificationUri:o,verificationUriComplete:i||o,expiresInMs:r,intervalMs:a}}function vps(e,t){if(!e.access_token||typeof e.expires_in!=="number")throw new et("Kimi token response missing required fields",{kind:"validation",provider:"kimi"});let s=e.refresh_token??t;if(!s)throw new et("Kimi token response missing refresh token",{kind:"validation",provider:"kimi"});let n,o=e.access_token.split("."),i=o.length===3?o[1]:void 0;if(i)try{let r=JSON.parse(new TextDecoder("utf-8").decode(Uint8Array.fromBase64(i,{alphabet:"base64url"})));if(ce(r)){let a=typeof r.user_id==="string"?r.user_id.trim():"",l=typeof r.sub==="string"?r.sub.trim():"";n=a||l||void 0}}catch{}return{access:e.access_token,refresh:s,expires:Date.now()+e.expires_in*1000-Wtr,accountId:n}}async function ztr(e,t,s,n){let o=Date.now()+s,i=Math.max(1000,t);while(Date.now()<o){if(n?.aborted)throw new rn;let r=await fetch(`${Vnt()}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...sk()},body:new URLSearchParams({client_id:jnt,device_code:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}),a=await r.json();if(r.ok&&a.access_token)return vps(a);let l=a.error;if(l==="authorization_pending"){await wps.wait(i,{signal:n});continue}if(l==="slow_down"){i+=5000;let p=typeof a.interval==="number"?a.interval*1000:void 0;if(p&&p>i)i=p;await wps.wait(i,{signal:n});continue}if(l==="expired_token")throw new et("Kimi device authorization expired",{kind:"validation",provider:"kimi"});if(l==="access_denied")throw new et("Kimi device authorization denied",{kind:"validation",provider:"kimi"});let u=a.error_description?`: ${a.error_description}`:"";throw new et(`Kimi device flow failed: ${l??r.status}${u}`,{kind:"polling",provider:"kimi"})}throw new et("Kimi device flow timed out",{kind:"timeout",provider:"kimi"})}async function jtr(e){let t=await $tr();return e.onAuth?.({url:t.verificationUriComplete,instructions:`Enter code: ${t.userCode}`}),ztr(t.deviceCode,t.intervalMs,t.expiresInMs,e.signal)}async function Vtr(e){let t=await fetch(`${Vnt()}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...sk()},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:jnt})});if(!t.ok){let n=await t.json().catch(()=>{return}),o=n?.error_description?`: ${n.error_description}`:"";throw new et(`Kimi token refresh failed: ${t.status}${o}`,{kind:"token-refresh",provider:"kimi",status:t.status})}let s=await t.json();return vps(s,e)}var jnt="17e5f671-d194-4dfb-9706-5516cb48c098",qtr="https://auth.kimi.com",Utr="kimi-device-id",Htr=5000,Btr=900000,Wtr=300000,znt=()=>{let e=qxe.join(Dt(),Utr);try{let s=w4.readFileSync(e,"utf-8").trim();if(s)return znt=()=>s,s}catch{}let t=xps.randomUUID().replace(/-/g,"");try{w4.mkdirSync(qxe.dirname(e),{recursive:!0}),w4.writeFileSync(e,`${t}
|
|
999
999
|
`,{mode:384})}catch{}return znt=()=>t,t},sk=()=>{let e=Object.freeze({"User-Agent":`KimiCLI/${Gnt.version}`,"X-Msh-Platform":"kimi_cli","X-Msh-Version":Gnt.version,"X-Msh-Device-Name":Dxe(wv.hostname(),"unknown"),"X-Msh-Device-Model":Dxe(Gtr(),"unknown"),"X-Msh-Os-Version":Dxe(wv.version(),"unknown"),"X-Msh-Device-Id":Dxe(znt(),"unknown")});return sk=()=>e,e};var x4=E(()=>{X();kps();St();bi()});function Uxe(e,t){let s=t instanceof Error?t.message:String(t);return{role:"assistant",content:[],errorMessage:s,api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",timestamp:Date.now()}}function gne(e,t){if(e===void 0)return t;let s=Number(e);if(!Number.isFinite(s))return t;if(s<=0)return;return Math.trunc(s)}function v4(e=Aps){return gne(be.PI_STREAM_IDLE_TIMEOUT_MS??be.PI_OPENAI_STREAM_IDLE_TIMEOUT_MS,e)}function bC(e=Aps){return gne(be.PI_OPENAI_STREAM_IDLE_TIMEOUT_MS??be.PI_STREAM_IDLE_TIMEOUT_MS,e)}function xv(e,t=Mps){let s=e===void 0?t:Math.max(t,e);return gne(be.PI_STREAM_FIRST_EVENT_TIMEOUT_MS,s)}function SC(e,t=Mps){let s=be.PI_OPENAI_STREAM_FIRST_EVENT_TIMEOUT_MS;if(s!==void 0)return gne(s,t)??0;let n=gne(be.PI_STREAM_FIRST_EVENT_TIMEOUT_MS,t);if(n===void 0||n<=0)return 0;if(e===void 0||e<=0)return n;return Math.max(n,e)}function jF(e,t){if(t===void 0||t<=0)return{signal:e,clear:()=>{}};let s=new AbortController,n=setTimeout(()=>{s.abort(new DOMException("The operation timed out.","TimeoutError"))},t);return n.unref?.(),{signal:e?AbortSignal.any([e,s.signal]):s.signal,clear:()=>clearTimeout(n)}}async function*bm(e,t){let s=t.firstItemTimeoutMs??t.idleTimeoutMs,n=s!==void 0&&s>0?Date.now()+s:void 0,o=t.abortSignal,i=e[Symbol.asyncIterator](),r=!1,a=()=>{if(r)return;r=!0;let L=i.return?.();if(L)L.catch(()=>{})};if(o?.aborted)throw a(),Eps(o);let l=(L)=>L.then((D)=>({kind:"next",result:D}),(D)=>({kind:"error",error:D})),u=!0,p=()=>{u=!1},c=(L)=>{if(!t.isProgressItem)return!0;try{return t.isProgressItem(L)}catch{return!0}},d=Date.now(),f=()=>{if(!t.hasPendingLocalWork)return!1;try{return t.hasPendingLocalWork()}catch{return!1}},m=()=>{if(u){if(n!==void 0&&s!==void 0)n=Date.now()+s}else d=Date.now()},g=(s===void 0||s<=0)&&(t.idleTimeoutMs===void 0||t.idleTimeoutMs<=0),h,T,R;if(o){let{promise:L,resolve:D}=Promise.withResolvers();R=D,T=()=>R?.({kind:"abort"}),o.addEventListener("abort",T,{once:!0}),h=L}let C,w,x=!1,A,I=1/0,M=()=>{if(u)return n;if(t.idleTimeoutMs!==void 0&&t.idleTimeoutMs>0)return d+t.idleTimeoutMs;return},O=()=>{A=void 0,I=1/0;let L=M();if(L===void 0)return;let D=L-Date.now();if(D>0){I=L,A=setTimeout(O,D);return}x=!0,w?.({kind:"timeout"})},_=(L)=>{if(C===void 0||x){let{promise:D,resolve:N}=Promise.withResolvers();C=D,w=N,x=!1}if(A!==void 0){if(I<=L)return;clearTimeout(A)}I=L,A=setTimeout(O,Math.max(0,L-Date.now()))},F;try{let L=0;while(!0){if(++L%Ktr===0){if(h!==void 0&&!o.aborted){let{promise:H,resolve:W}=Promise.withResolvers();R=W,h=H}if(C!==void 0&&!x){let{promise:H,resolve:W}=Promise.withResolvers();w=W,C=H}}let D;if(u){if(n!==void 0){if(D=n-Date.now(),D<=0){if(!f())throw t.onFirstItemTimeout?.(),a(),new Pl(t.firstItemErrorMessage??t.errorMessage);m(),D=n-Date.now()}}}else if(t.idleTimeoutMs!==void 0&&t.idleTimeoutMs>0){if(D=t.idleTimeoutMs-(Date.now()-d),D<=0){if(!f())throw t.onIdle?.(),a(),new Pl(t.errorMessage);m(),D=t.idleTimeoutMs}}F??=l(i.next());let N=[F];if(!g&&D!==void 0&&D>0)_(Date.now()+D),N.push(C);if(h)N.push(h);let B=!1;try{let H=await Promise.race(N);if(H.kind==="next"||H.kind==="error")F=void 0;if(H.kind==="abort")throw a(),Eps(o);if(H.kind==="timeout"){if(f()){m(),B=!0;continue}if(!u)t.onIdle?.();else t.onFirstItemTimeout?.();throw a(),new Pl(!u?t.errorMessage:t.firstItemErrorMessage??t.errorMessage)}if(H.kind==="error")throw H.error;if(H.result.done){p();return}let W=H.result.value;if(c(W))p(),d=Date.now();yield W,B=!0}finally{if(!B)a()}}}finally{if(A!==void 0)clearTimeout(A);if(w?.({kind:"timeout"}),T&&o)o.removeEventListener("abort",T);R?.({kind:"abort"})}}async function*Ips(e,t){let s=e[Symbol.asyncIterator]();try{while(!0){let n=t.finishedAtMs();if(n===void 0){let l=await s.next();if(l.done)return;yield l.value;continue}let o=n+t.graceMs-Date.now();if(o<=0){t.onGraceEnd?.();return}let i=s.next(),r,a=new Promise((l)=>{r=setTimeout(()=>l("timeout"),o)});try{let l=await Promise.race([i,a]);if(l==="timeout"){i.catch(()=>{}),t.onGraceEnd?.();return}if(l.done)return;yield l.value}finally{if(r!==void 0)clearTimeout(r)}}}finally{let n=s.return?.();if(n)Promise.resolve(n).catch(()=>{})}}function Eps(e){let t=e.reason;if(t instanceof Error)return t;if(typeof t==="string")return new Ds(t);return new Ds}var Aps=300000,Mps=300000,Ktr=1024;var nk=E(()=>{X();St()});function Ytr(e,t,s){let n={};e.headers.forEach((i,r)=>{n[r.toLowerCase()]=i});let o={status:e.status,headers:n};if(t!==void 0)o.requestId=t;if(s!==void 0)o.metadata=s;return o}async function BI(e,t,s,n,o){if(!e?.onResponse)return;await e.onResponse(Ytr(t,n,o),s)}function Xtr(e){if(e===void 0)return;if(!Number.isFinite(e))return;if(e<=0)return;return Math.trunc(e)}function Ynt(e,t){let s=Xtr(t);if(s===void 0)return{signal:e};return{signal:e,timeout:s,maxRetries:0}}function GH(e,t){if(!e)return;try{e(t)}catch{}}import{scheduler as Jtr}from"timers/promises";function Xnt(){return new Ds("Request was aborted.")}function ssr(e){let t=e.headers.get("x-should-retry");if(t==="true")return!0;if(t==="false")return!1;let s=e.status;return iy(s)||s===409}function Pps(e){if(!e)return;let t=e.get("retry-after-ms");if(t){let n=Number.parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}let s=e.get("retry-after");if(s){let n=Number.parseFloat(s);if(Number.isFinite(n)&&n>=0)return n*1000;let o=Date.parse(s)-Date.now();if(Number.isFinite(o)&&o>=0)return o}return}function Qnt(e){let t=Math.min(esr*2**e,tsr),s=1-Math.random()*0.25;return t*s*1000}function Ops(e,t){for(let s in e)if(s.toLowerCase()===t)return!0;return!1}class _ps{#e;#t;constructor(e){this.#e=e}asResponse(){return this.#t??=this.#e(),this.#t}}class Jnt{#e;#t;constructor(e,t){this.#e=e,this.#t=t}create(e,t){return this.#e.request(this.#t,e,t)}}class Znt{messages;beta;#e;constructor(e){this.#e=e,this.messages=new Jnt(this,"/v1/messages"),this.beta={messages:new Jnt(this,"/v1/messages?beta=true")}}request(e,t,s){return new _ps(()=>this.#s(e,t,s))}#t(e){let t=this.#e,s=t.defaultHeaders??{},n={};if(t.apiKey!=null&&!Ops(s,"x-api-key"))n["X-Api-Key"]=t.apiKey;if(t.authToken!=null&&!Ops(s,"authorization"))n.Authorization=`Bearer ${t.authToken}`;return Object.assign(n,s),Object.assign(n,e),n}async#s(e,t,s){let n=this.#e,o=n.fetch??fetch,i=s?.signal,r=s?.timeout??n.timeout??Qtr,a=Math.max(0,s?.maxRetries??n.maxRetries??Ztr),l=s?.maxRetryDelayMs??n.maxRetryDelayMs??60000,u=`${n.baseURL??"https://api.anthropic.com"}${e}`,p=this.#t(s?.headers),c=JSON.stringify(t);for(let d=0;;d++){if(i?.aborted)throw Xnt();let f;try{f=await this.#n(o,u,p,c,r,i)}catch(m){if(i?.aborted)throw Xnt();if(d<a){await this.#o(d,void 0,i);continue}if(m instanceof iI)throw m;throw new Z5(m)}if(f.ok)return f;if(d<a&&ssr(f)){let m=Pps(f.headers);if(m!==void 0&&l>0&&m>l)throw await eH.fromResponse(f,i);await f.body?.cancel().catch(()=>{}),await this.#o(d,f.headers,i);continue}throw await eH.fromResponse(f,i)}}async#n(e,t,s,n,o,i){let r=new AbortController,a=!1,l=setTimeout(()=>{a=!0,r.abort()},o),u=()=>r.abort();i?.addEventListener("abort",u,{once:!0});try{return await e(t,{...this.#e.fetchOptions??{},method:"POST",headers:s,body:n,signal:r.signal})}catch(p){if(a&&!i?.aborted)throw new iI;throw p}finally{clearTimeout(l),i?.removeEventListener("abort",u)}}async#o(e,t,s){let n=Pps(t)??Qnt(e);try{await Jtr.wait(n,{signal:s})}catch{throw Xnt()}}}var Qtr=600000,Ztr=2,esr=0.5,tsr=8;var eot=E(()=>{St();St()});function VF(e){if(e.type==="server_tool_use")return(e.name==="web_search"||e.name==="tool_search_tool_regex"||e.name==="tool_search_tool_bm25")&&typeof e.id==="string"&&e.id.length>0;if(e.type==="web_search_tool_result"||e.type==="tool_search_tool_result")return typeof e.tool_use_id==="string"&&e.tool_use_id.length>0&&Object.hasOwn(e,"content");return!1}var hcs={};nt(hcs,{CLAUDE_CODE_MAX_OUTPUT_TOKENS:()=>TSe,applyAnthropicUsageExtras:()=>$xe,applyClaudeToolPrefix:()=>ncs,buildAnthropicClientOptions:()=>dcs,buildAnthropicHeaders:()=>Xxe,buildAnthropicSystemBlocks:()=>ove,buildBetaHeader:()=>Yxe,claudeCodeSystemInstruction:()=>uJe,claudeCodeVersion:()=>uF,claudeToolPrefix:()=>pF,clearAnthropicFastModeFallback:()=>Jxe,convertAnthropicMessages:()=>mcs,coworkHeaders:()=>Qxe,coworkUserAgent:()=>lJe,deriveClaudeDeviceId:()=>eve,generateClaudeCloakingUserId:()=>vsr,isAnthropicFastModeFallbackDisabled:()=>lot,isClaudeCloakingUserId:()=>dot,isInvalidThinkingSignatureError:()=>got,isProviderRetryableError:()=>pcs,mapStainlessArch:()=>tcs,maybeAddReplayUnsignedThinkingHint:()=>ccs,normalizeAnthropicBaseUrl:()=>YF,normalizeAnthropicToolSchema:()=>gcs,normalizeExtraBetas:()=>hot,resolveAnthropicCustomHeadersForBaseUrl:()=>nve,resolveAnthropicMetadataUserId:()=>tve,streamAnthropic:()=>dnr,stripClaudeToolPrefix:()=>sve,wrapFetchForCch:()=>Zxe});import*as vv from"crypto";import*as Vxe from"fs";import{scheduler as nsr}from"timers/promises";import*as Kxe from"tls";function YF(e){let t=e?.trim();if(!t)return;let s=t.replace(/\/+$/,"");return s.endsWith("/v1")?s.slice(0,-3):s}function Yxe(e,t){let s=new Set,n=[];for(let o of[...e,...t]){let i=o.trim();if(i&&!s.has(i))s.add(i),n.push(i)}return n.join(",")}function osr(e,t){for(let s in e)if(s.toLowerCase()==="anthropic-beta")return{[s]:Yxe(hot(e[s]),[t])};return{"anthropic-beta":t}}function Jps(e,t,s=!1){if(!e&&!s)return Fps;let n=[];for(let o of e?isr:Fps){if(s&&o===Yps)continue;n.push(o)}if(!e)return n;if(t)n.push(E4);return n.push(rsr),n}function Tne(e,t){if(!e)return;let s=t.toLowerCase();for(let[n,o]of Object.entries(e))if(n.toLowerCase()===s)return o;return}function usr(e){if(!e)return!1;return e.toLowerCase().startsWith("claude-cli")}function Xxe(e){let t=e.isOAuth??gF(e.apiKey),s=e.extraBetas??[],n=e.stream??!1,o=Tne(e.modelHeaders,"User-Agent"),i=Tne(e.modelHeaders,"Authorization"),r=Tne(e.modelHeaders,"X-Api-Key"),a=Yxe(e.coworkBetas??(t?Jps(!0,!0):[]),s),l=t?"application/json":n?"text/event-stream":"application/json",u=e.isCloudflareAiGateway??!1,p=!t&&!u,c=t&&e.allowAnthropicHeaderOverrides===!0&&!u&&!fy(e.baseUrl),d=!u,f={},m={},g=[],h=e.modelHeaders;if(h)for(let T in h){let R=h[T],C=T.toLowerCase();if(hsr.has(C)){if(c&&Tsr.has(C)){m[T]=R;continue}if(C==="user-agent")continue;if(C==="authorization"&&p)continue;if(C==="x-api-key"&&d)continue;g.push(T);continue}f[T]=R}if(g.length>0)P.debug("anthropic: ignoring caller-supplied enforced headers",{headers:g});if(u)return{...f,Accept:l,...tot,...o?{"User-Agent":o}:{},...a?{"anthropic-beta":a}:{},"cf-aig-authorization":`Bearer ${e.apiKey}`};if(t){let T=usr(o)?o:lJe,R={...f,Accept:l,"Content-Type":"application/json","User-Agent":T,...e.claudeCodeSessionId?{"X-Claude-Code-Session-Id":e.claudeCodeSessionId}:{},...Qxe,...a?{"anthropic-beta":a}:{},"anthropic-dangerous-direct-browser-access":"true","anthropic-version":"2023-06-01",Authorization:`Bearer ${e.apiKey}`,"x-app":"cli","x-client-request-id":vv.randomUUID(),Connection:"keep-alive","Accept-Encoding":"gzip, deflate, br, zstd",...r?{"X-Api-Key":r}:{}};return c?yne(R,m):R}else if(!fy(e.baseUrl))return{...f,Accept:l,Authorization:i??`Bearer ${e.apiKey}`,...tot,...o?{"User-Agent":o}:{},...a?{"anthropic-beta":a}:{},...r?{"X-Api-Key":r}:{}};else return{...f,Accept:l,...tot,...o?{"User-Agent":o}:{},...a?{"anthropic-beta":a}:{},...i?{Authorization:i}:{},"X-Api-Key":r??e.apiKey}}function psr(e){let t=e.trim().toLowerCase();if(t==="image/jpg")return"image/jpeg";if(t==="image/jpeg"||t==="image/png"||t==="image/gif"||t==="image/webp")return t;return}function Qps(e){return{...e}}function csr(){let e={strictToolsDisabled:!1,fastModeDisabled:!1,replayUnsignedThinkingDisabled:!1,close:()=>{e.strictToolsDisabled=!1,e.fastModeDisabled=!1,e.replayUnsignedThinkingDisabled=!1}};return e}function Zps(e,t){return`${iot}:${e}\x00${t}`}function dsr(e,t,s){if(!e)return;let n=Zps(t,s),o=e.get(n);if(o)return o;let i=csr();return e.set(n,i),i}function Jxe(e){if(!e)return;let t=`${iot}:`;for(let[s,n]of e){if(s!==iot&&!s.startsWith(t))continue;n.fastModeDisabled=!1}}function lot(e,t){if(!e||t.provider!=="anthropic"||t.api!=="anthropic-messages")return!1;let s=mot(t)??"https://api.anthropic.com",n=Zps(s,t.id);return e.get(n)?.fastModeDisabled??!1}function fsr(e){return e.tools?.some((t)=>t.strict===!0)??!1}function msr(e){delete e.speed}function gsr(e){if(!e.tools)return;for(let t of e.tools)delete t.strict}function ecs(e,t){let s=Jp(t,"short");if(s==="none")return{retention:s};let n=s==="long"&&e.compat.supportsLongCacheRetention?"1h":void 0;return{retention:s,cacheControl:{type:"ephemeral",...n&&{ttl:n}}}}function tcs(e){switch(e.toLowerCase()){case"amd64":case"x64":return"x64";case"arm64":case"aarch64":return"arm64";case"386":case"x86":case"ia32":return"x86";default:return`other::${e.toLowerCase()}`}}function ysr(e){let t=[4,7,20].map((n)=>e[n]??"0").join(""),s=vv.createHash("sha256").update(`59cf53e54c78${t}${uF}`).digest("hex").slice(0,3);return`${uot} cc_version=${uF}.${s}; cc_entrypoint=claude-desktop; ${pot};`}function Ssr(e){let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength),s=t.indexOf(qps);if(s===-1)return"no-billing-header";let n=s+qps.length,o=t.indexOf(Csr,n);if(o===-1||o-n>bsr)return"unanchored";let r=(Bun.hash.xxHash64(e,Rsr)&0xfffffn).toString(16).padStart(5,"0");for(let a=0;a<5;a++)e[o+4+a]=r.charCodeAt(a);return"patched"}function Zxe(e){return(t,s)=>{if(s?.body&&typeof s.body==="string"&&s.body.includes(pot)){let n=cot.encode(s.body);if(Ssr(n)==="unanchored")P.warn("anthropic: cch billing placeholder present but not patched; sending unattested request");return e(t,{...s,body:n})}return e(t,s)}}function dot(e){return ksr.test(e)}function wsr(e){if(e.length===0||e[0]!=="{")return!1;let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=="object"||Array.isArray(t))return!1;let s=t;return typeof s.session_id==="string"&&s.session_id.length>0}function xsr(e){if(typeof e!=="string")return;if(dot(e))return e.slice(e.lastIndexOf("_session_")+9);if(e.length===0||e[0]!=="{")return;let t;try{t=JSON.parse(e)}catch{return}if(!t||typeof t!=="object"||Array.isArray(t))return;let s=t.session_id;return typeof s==="string"&&s.length>0?s:void 0}function vsr(){let e=vv.randomBytes(32).toString("hex"),t=vv.randomUUID().toLowerCase(),s=vv.randomUUID().toLowerCase();return`user_${e}_account_${t}_session_${s}`}function eve(e,t){let s=vv.createHash("sha256");if(t&&t.length>0)return s.update(Asr).update("\x00").update(e).update("\x00").update(t).digest("hex");return s.update(Esr).update(e).digest("hex")}function Gxe(e,t){let s=e?.[t];return typeof s==="string"&&s.length>0?s:void 0}function Msr(e){return Gxe(e,"account_uuid")??Gxe(e,"accountId")??Gxe(e,"account_id")}function Isr(e){return eve(Hx(),e)}function Psr(e,t){let s={device_id:Isr(t),session_id:e??vv.randomUUID().toLowerCase()};if(t&&t.length>0)s.account_uuid=t;return JSON.stringify(s)}function tve(e,t,s,n){if(typeof e==="string"){if(!t||dot(e)||wsr(e))return e}if(!t)return;return Psr(s,n)}function Ups(e){let t=e?.trim().toLowerCase();return t==="native"||t==="exa"?t:void 0}function Fsr(e){let t=Tne(e,scs);if(t!==void 0)return Ups(t);return Ups(be.UMANS_WEBSEARCH_PROVIDER)}function Lsr(e){return e.provider==="umans"||e.baseUrl.toLowerCase().includes("api.code.umans.ai")}function ocs(e,t){if(!Lsr(e))return;let s=Fsr(t);return s?{[scs]:s}:void 0}function Nsr(e,t){return t&&e.toLowerCase()===_sr}function fot(e,t,s,n=!1){if(Nsr(e,n))return e;if(s)return`${pF}${e}`;return t?ncs(e):e}function Dsr(e,t,s){if(t||s)return sve(e);return e}function Usr(e){let t=0;for(let s of e){if(s.role!=="user"&&s.role!=="developer"&&s.role!=="toolResult")continue;if(!Array.isArray(s.content))continue;for(let n of s.content)if(n.type==="image")t++}return t}function Bsr(e){let t=0,s=[];return async(n)=>{if(t>=e){let{promise:o,resolve:i}=Promise.withResolvers();s.push(i),await o}else t++;try{return await n()}finally{let o=s.shift();if(o)o();else t--}}}async function Wsr(e){try{let t=Buffer.from(e.data,"base64"),{width:s,height:n}=await new Bun.Image(t).metadata();if(!s||!n)return e;if(s<=$H&&n<=$H)return e;let o=Math.min($H/s,$H/n),i=Math.max(1,Math.min($H,Math.round(s*o))),r=Math.max(1,Math.min($H,Math.round(n*o))),[a,l]=await Promise.all([new Bun.Image(t).resize(i,r).png().bytes(),new Bun.Image(t).resize(i,r).jpeg({quality:85}).bytes()]),u=a.length<=l.length?{buffer:a,mimeType:"image/png"}:{buffer:l,mimeType:"image/jpeg"};return{type:"image",data:Buffer.from(u.buffer).toString("base64"),mimeType:u.mimeType}}catch(t){return P.warn("anthropic: failed to resize oversized image for many-image request",{mimeType:e.mimeType,error:t instanceof Error?t.message:String(t)}),e}}async function Bps(e,t,s){let n=!1,o=await Promise.all(e.map(async(i)=>{if(i.type!=="image"||i.url||i.providerFile?.provider==="anthropic"&&i.providerFile.id)return i;let r=Hps.get(i);if(r===void 0)r=await s(()=>Wsr(i)),Hps.set(i,r);if(r!==i)n=!0,t.resized++;return r}));return n?o:e}async function Gsr(e,t,s){if(e.role==="user"||e.role==="developer"){if(!Array.isArray(e.content))return e;let n=await Bps(e.content,t,s);return n===e.content?e:{...e,content:n}}if(e.role==="toolResult"){let n=await Bps(e.content,t,s);return n===e.content?e:{...e,content:n}}return e}async function $sr(e,t){if(!t)return e;let s=Usr(e.messages);if(s<=qsr)return e;let n=!1,o={resized:0},i=Bsr(Hsr),r=await Promise.all(e.messages.map(async(a)=>{let l=await Gsr(a,o,i);if(l!==a)n=!0;return l}));if(!n)return e;return P.debug("anthropic: resized oversized images for many-image request",{imageCount:s,resized:o.resized,maxDimension:$H}),{...e,messages:r}}function rcs(e,t=!0){let s=[],n=!1,o=!1;for(let i of e){if(i.type==="text"){let a=i.text.toWellFormed();if(a.trim().length===0)continue;n=!0,s.push({type:"text",text:a});continue}if(!t){s.push({type:"text",text:Tv});continue}let r;if(i.providerFile?.provider==="anthropic"&&i.providerFile.id)r={type:"file",file_id:i.providerFile.id};else if(i.url)r={type:"url",url:i.url};else{let a=psr(i.mimeType);if(!a){s.push({type:"text",text:`[unsupported image: ${i.mimeType}]`});continue}r={type:"base64",media_type:a,data:i.data}}o=!0,s.push({type:"image",source:r})}if(!t)return s.filter((i)=>i.type==="text").map((i)=>i.text).join(`
|
|
1000
1000
|
`).toWellFormed();if(o&&!n)s.unshift({type:"text",text:"(see attached image)"});return s}function not(e){if(!e)return null;let t=e.trim();if(t&&!t.includes("-----BEGIN")&&acs(t))try{return`${t}@${Vxe.statSync(t).mtimeMs}`}catch{return t}return e}function zsr(){return JSON.stringify([not(be.NODE_EXTRA_CA_CERTS),not(be.CLAUDE_CODE_CLIENT_CERT),not(be.CLAUDE_CODE_CLIENT_KEY)])}function mot(e,t){if(e.provider==="github-copilot")return YF(Xke(e.baseUrl,t)??e.baseUrl);if(e.provider==="anthropic"&&ov()){let s=YF(be.FOUNDRY_BASE_URL);if(s)return s}if(e.provider==="anthropic"){let s=YF(e.baseUrl);if(s&&!fy(s))return s;return YF(be.ANTHROPIC_BASE_URL)??s??"https://api.anthropic.com"}return YF(e.baseUrl)}function ics(e,t){if(!e.compat.supportsEagerToolInputStreaming)return!1;if(fy(t))return!0;return!e.compat.officialEndpoint}function jsr(e){let t=e?.trim();if(!t)return;let s={};for(let n of t.split(/\r?\n|,/)){let o=n.trim();if(!o)continue;let i=o.indexOf(":");if(i<=0)continue;let r=o.slice(0,i).trim(),a=o.slice(i+1).trim();if(!r||!a)continue;s[r]=a}return Object.keys(s).length>0?s:void 0}function nve(e){if(!ov()&&fy(e))return;return jsr(be.ANTHROPIC_CUSTOM_HEADERS)}function Vsr(e,t){if(e.provider!=="anthropic")return;return nve(t)}function acs(e){return e.includes("/")||e.includes("\\")||/\.(pem|crt|cer|key)$/i.test(e)}function oot(e,t){let s=e?.trim();if(!s)return;let n=s.replace(/\\n/g,`
|
|
1001
1001
|
`);if(n.includes("-----BEGIN"))return n;if(acs(s))try{return Vxe.readFileSync(s,"utf8")}catch(o){if(ye(o))throw new yn(`${t} path does not exist: ${s}`);throw o}return n}function Ksr(e){if(e.provider!=="anthropic")return;if(!ov())return;let t=zsr();if(sot.has(t))return sot.get(t);let s=oot(be.NODE_EXTRA_CA_CERTS,"NODE_EXTRA_CA_CERTS"),n=oot(be.CLAUDE_CODE_CLIENT_CERT,"CLAUDE_CODE_CLIENT_CERT"),o=oot(be.CLAUDE_CODE_CLIENT_KEY,"CLAUDE_CODE_CLIENT_KEY");if(n&&!o||!n&&o)throw new ms("Both CLAUDE_CODE_CLIENT_CERT and CLAUDE_CODE_CLIENT_KEY must be set for mTLS.");let i={};if(s)i.ca=[...Kxe.rootCertificates,s];if(n)i.cert=n;if(o)i.key=o;let r=Object.keys(i).length>0?i:void 0;return sot.set(t,r),r}function Ysr(e,t){if(e.provider!=="anthropic")return;if(!t)return;let s;try{s=new URL(t).hostname}catch{return}if(!s)return;let n=Ksr(e);return{tls:{rejectUnauthorized:!0,serverName:s,...Wps?{ciphers:Wps}:{},...n??{}}}}function yne(...e){let t={},s=new Map;for(let n of e){if(!n)continue;for(let[o,i]of Object.entries(n)){let r=o.toLowerCase(),a=s.get(r);if(a!==void 0&&a!==o)delete t[a];s.set(r,o),t[o]=i}}return t}function Jsr(e){try{let t=JSON.parse(e),s=typeof t?.error?.type==="string"?t.error.type:void 0,n=typeof t?.error?.message==="string"?t.error.message:void 0;if(n)return new Ms(s?`Anthropic stream error (${s}): ${n}`:`Anthropic stream error: ${n}`,{provider:"anthropic",kind:"output"})}catch{}return new Ms(e,{provider:"anthropic",kind:"output"})}async function*Qsr(e,t,s){if(!e.body)throw new sv("Attempted to iterate over an Anthropic response with no body");let n=!1,o=!1;for await(let i of ev(e.body,t)){if(GH(s,i),i.event==="error")throw Jsr(i.data);if(i.event==="ping"){yield Xsr;continue}if(!lcs.has(i.event??""))continue;try{let r=JSON.parse(i.data);if(r.type!==i.event)Ma(`event type ${r.type} does not match SSE event ${i.event}`);if(r.type==="message_start")n=!0;else if(r.type==="message_stop")o=!0;yield r}catch(r){let a=r instanceof Error?r.message:String(r);Ma(`could not parse SSE event ${i.event}: ${a}; skipping frame; data=${i.data}`)}}if(n&&!o&&!t?.aborted)Ma("stream ended before message_stop")}function ucs(e){return ce(e)&&typeof e.asResponse==="function"}function Zsr(e){return ce(e)&&typeof e.withResponse==="function"}async function enr(e,t,s){if(ucs(e)){let n=await e.asResponse();return{events:Qsr(n,t,s),response:n,requestId:n.headers.get("request-id"),recordsRawSseEvents:!0}}if(Zsr(e)){let{data:n,response:o,request_id:i}=await e.withResponse();return{events:n,response:o,requestId:i,recordsRawSseEvents:!1}}throw new sv("Anthropic SDK request did not expose a stream response")}async function*tnr(e,t){for await(let s of e){let n=JSON.stringify(s);GH(t,{event:s.type,data:n,raw:[`event: ${s.type}`,`data: ${n}`]}),yield s}}function Ma(e){P.warn(`anthropic: ignoring malformed stream envelope: ${e}`)}function rnr(e){if(typeof e!=="string")return!1;if(e==="ping")return!0;return!lcs.has(e)}function pcs(e,t){return PQt(e,{provider:t,isProviderTransient:t==="github-copilot"?(s)=>nH(s):void 0})}function inr(e){let t=e.trim(),s=!1;while(t.startsWith(Gps)&&t.endsWith($ps))t=t.slice(Gps.length,t.length-$ps.length).trim(),s=!0;return s?t:void 0}function A4(e){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,...e===void 0?{}:{premiumRequests:e},cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function $xe(e,t){let s=t.cache_creation;if(s!=null){let o=s.ephemeral_5m_input_tokens??0,i=s.ephemeral_1h_input_tokens??0;if(o>0||i>0)e.cttl={...o>0?{ephemeral5m:o}:{},...i>0?{ephemeral1h:i}:{}};else delete e.cttl}let n=t.server_tool_use;if(n!=null){let o=n.web_search_requests??0,i=n.web_fetch_requests??0;if(o>0||i>0)e.server={...o>0?{webSearch:o}:{},...i>0?{webFetch:i}:{}};else delete e.server}}function anr(e){if(!ce(e))return;let t=ce(e.cache_creation)?{...typeof e.cache_creation.ephemeral_5m_input_tokens==="number"?{ephemeral_5m_input_tokens:e.cache_creation.ephemeral_5m_input_tokens}:{},...typeof e.cache_creation.ephemeral_1h_input_tokens==="number"?{ephemeral_1h_input_tokens:e.cache_creation.ephemeral_1h_input_tokens}:{}}:void 0;return{...typeof e.input_tokens==="number"?{input_tokens:e.input_tokens}:{},...typeof e.output_tokens==="number"?{output_tokens:e.output_tokens}:{},...typeof e.cache_read_input_tokens==="number"?{cache_read_input_tokens:e.cache_read_input_tokens}:{},...typeof e.cache_creation_input_tokens==="number"?{cache_creation_input_tokens:e.cache_creation_input_tokens}:{},...t===void 0?{}:{cache_creation:t}}}function lnr(e){if(!ce(e)||e.type!=="fallback")return;let t=ce(e.from)&&typeof e.from.model==="string"?e.from.model:void 0,s=ce(e.to)&&typeof e.to.model==="string"?e.to.model:void 0;if(!t?.trim()||!s?.trim())return;return{type:"fallback",from:{model:t},to:{model:s}}}function zps(e){let t=e.iterations??[];for(let s=t.length-1;s>=0;s-=1){let n=t[s];if(n?.type==="fallback_message"&&n.model?.trim())return n.model}return}function unr(e,t){let s=t?.trim();if(!s||s===e.id)return e;if(e.provider==="anthropic"){let n=fj("anthropic",s);if(n?.api==="anthropic-messages")return n}return e}function jps(e,t,s){let n=s.iterations??[];if(n.length===0)return!1;let o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},i=n.some((a)=>a.type==="fallback_message"),r=!1;for(let a of n){let l=a.input_tokens??0,u=a.output_tokens??0,p=a.cache_read_input_tokens??0,c=a.cache_creation_input_tokens??0,d=a.type==="fallback_message";if(i&&!d&&u===0&&c===0)continue;let f=A4();if(d)f.input=0,f.cacheRead=p+l;else f.input=l,f.cacheRead=p;f.output=u,f.cacheWrite=c,f.totalTokens=f.input+f.output+f.cacheRead+f.cacheWrite,_l(unr(e,a.model),f),o.input+=f.cost.input,o.output+=f.cost.output,o.cacheRead+=f.cost.cacheRead,o.cacheWrite+=f.cost.cacheWrite,o.total+=f.cost.total,r=!0}if(!r)return!1;return t.cost=o,!0}function got(e){return pnr.test(e)}function ccs(e,t){if(!got(t))return t;if(e.compat.officialEndpoint)return t;if(e.compatConfig?.replayUnsignedThinking!==void 0)return t;return`${`Provider "${e.provider}" looks like an Anthropic-compatible signing proxy: it rejected a replayed unsigned thinking block. Set \`compat.replayUnsignedThinking: false\` under \`providers.${e.provider}\` in your models.yml and retry. See https://github.com/can1357/oh-my-pi/issues/4297.`}
|
|
@@ -3528,7 +3528,7 @@ Return JSON in this exact format:
|
|
|
3528
3528
|
|
|
3529
3529
|
User message: {text}
|
|
3530
3530
|
|
|
3531
|
-
Extraction:`;c_e=["fact","text","content","value","statement"],b4r=["instruction","rule",...c_e],S4r=["preference",...c_e],k4r=["description","event","timeline","date",...c_e]});function I4r(e){return Object.hasOwn(M4r,e)}function Yzs(e,t="veracity"){if(e===null||e===void 0)return"unknown";let s=String(e).trim().toLowerCase();if(s==="")return"unknown";if(I4r(s))return s;let n=String(e),o=n.length>Kzs?`${n.slice(0,Kzs)}...[truncated]`:n;return console.warn(`${t} received unknown veracity ${JSON.stringify(o)}; clamping to 'unknown'`),"unknown"}var bQl,M4r,Kzs=80,SQl;var Xzs=E(()=>{Zk();bQl=Object.freeze({stated:1,inferred:0.7,tool:0.5,imported:0.6,unknown:0.8}),M4r=Object.freeze({stated:!0,inferred:!0,tool:!0,imported:!0,unknown:!0}),SQl=Symbol("mnemopi.veracity.txDepth")});var Jzs=()=>{};import*as OTt from"path";async function Qzs(e,t="local_cache"){let s=O4r[e];if(s===void 0)return!1;let n=OTt.join(t,e);for(let o of P4r){let i=OTt.join(n,o);if(await Bun.file(i).exists())continue;let r=await fetch(`https://huggingface.co/${s}/resolve/main/${o}`);if(!r.ok)throw Error(`Failed to download ${e} ${o} from ${s}: ${r.status} ${r.statusText}`);await Bun.write(i,await r.arrayBuffer())}return!0}var P4r,O4r;var Zzs=E(()=>{P4r=["config.json","tokenizer.json","tokenizer_config.json","special_tokens_map.json"],O4r={"fast-all-MiniLM-L6-v2":"sentence-transformers/all-MiniLM-L6-v2","fast-bge-base-en":"BAAI/bge-base-en","fast-bge-base-en-v1.5":"BAAI/bge-base-en-v1.5","fast-bge-small-en":"BAAI/bge-small-en","fast-bge-small-en-v1.5":"BAAI/bge-small-en-v1.5","fast-bge-small-zh-v1.5":"BAAI/bge-small-zh-v1.5","fast-multilingual-e5-large":"intfloat/multilingual-e5-large"}});var t3s;var e3s=E(()=>{t3s={type:"module",name:"@linxiraos/pi-mnemopi",version:"1.1.2",description:"Local SQLite memory engine for Zeta agents",homepage:"https://linxira-os.github.io/zeta/",author:"Can Boluk",contributors:["Abdias J"],license:"MIT",repository:{type:"git",url:"git+https://github.com/Linxira-OS/linxira-zeta.git",directory:"packages/mnemopi"},bugs:{url:"https://github.com/Linxira-OS/linxira-zeta/issues"},keywords:["memory","sqlite","agent","embeddings","mcp"],main:"./src/index.ts",module:"./src/index.ts",types:"./dist/types/index.d.ts",bin:{mnemopi:"src/cli.ts"},scripts:{check:"biome check . && bun run check:types","check:types":"tsgo -p tsconfig.json --noEmit",lint:"biome lint .",test:"bun test --parallel",fix:"biome check --write --unsafe .",fmt:"biome format --write ."},dependencies:{"@linxiraos/pi-ai":"1.1.2","@linxiraos/pi-catalog":"1.1.2","@linxiraos/pi-natives":"1.1.2","@linxiraos/pi-utils":"1.1.2"},peerDependencies:{fastembed:"2.1.0","onnxruntime-node":"1.21.0"},peerDependenciesMeta:{fastembed:{optional:!0},"onnxruntime-node":{optional:!0}},devDependencies:{"@types/bun":"^1.3.14",fastembed:"2.1.0","onnxruntime-node":"1.26.0"},engines:{bun:">=1.3.14"},files:["src","README.md","CHANGELOG.md","LICENSE","THIRD-PARTY-NOTICES.txt","dist/types"],exports:{".":{types:"./dist/types/index.d.ts",import:"./src/index.ts"},"./core":{types:"./dist/types/core/index.d.ts",import:"./src/core/index.ts"},"./core/beam":{types:"./dist/types/core/beam/index.d.ts",import:"./src/core/beam/index.ts"},"./beam":{types:"./dist/types/core/beam/index.d.ts",import:"./src/core/beam/index.ts"},"./diagnose":{types:"./dist/types/diagnose.d.ts",import:"./src/diagnose.ts"},"./mcp":{types:"./dist/types/mcp-tools.d.ts",import:"./src/mcp-tools.ts"},"./cli":{types:"./dist/types/cli.d.ts",import:"./src/cli.ts"},"./*":{types:"./dist/types/*.d.ts",import:"./src/*.ts"},"./*.js":"./src/*.ts"}}});import{createRequire as s3s}from"module";import*as _m from"path";function F4r(){return{versionKey:`fastembed-${f_e}_transitive-ort`.replace(/[^A-Za-z0-9._-]/g,"_"),install:{dependencies:{fastembed:f_e},trustedDependencies:["onnxruntime-node"]}}}async function L4r({fastembedEntry:e,fastembedPackageDir:t,arch:s=process.arch,env:n=process.env}){let o=_m.join(t,"node_modules"),i=_m.dirname(t),r=Mc(o,"onnxruntime-node"),a=r??Mc(i,"onnxruntime-node"),l=_m.join(r?o:i,"onnxruntime-node");if(!a)throw Error(`Cannot find module onnxruntime-node beside ${e}`);let u=new Bun.Glob(`bin/napi-*/win32/${s}/onnxruntime.dll`),p;for await(let m of u.scan({cwd:l,absolute:!0,onlyFiles:!0})){p=_m.dirname(m);break}if(!p)throw Error(`Cannot find module onnxruntime-node Windows DLL for ${s} beside ${a}`);let c=n.PATH,d=_m.resolve(p).toLowerCase();if(!c?.split(_m.delimiter).some((m)=>_m.resolve(m).toLowerCase()===d))n.PATH=c?`${p}${_m.delimiter}${c}`:p;return{ortEntry:a,ortPackageDir:l,dllDir:p}}function n3s(){return _Tt??=N4r().catch((e)=>{throw _Tt=null,e}),_Tt}async function N4r(){try{let e=s3s(import.meta.url),t=e.resolve("fastembed/package.json"),s=e(t);if(s.version!==f_e)throw Error(`Cannot find package fastembed@${f_e}; resolved ${String(s.version)}`);return await o3s(e.resolve("fastembed"),_m.dirname(t))}catch(e){if(!q4r(e))throw e;return P.debug("mnemopi: fastembed not loadable, using on-demand runtime install",{error:String(e)}),D4r()}}async function o3s(e,t){let s=s3s(e);if(process.platform==="win32"){let{ortEntry:o}=await L4r({fastembedEntry:e,fastembedPackageDir:t});s(o)}return s(e)}async function D4r(){let e=F4r(),t=await j_({runtimeDir:_m.join(J8t(),e.versionKey),install:e.install,probePackage:"fastembed"}),s=_m.join(t,"node_modules");pbe({runtimeNodeModules:s});let n=Mc(s,"fastembed");if(!n)throw Error(`fastembed runtime install at ${t} has no loadable entry`);return o3s(n,_m.join(s,"fastembed"))}function q4r(e){if(typeof e!=="object"||e===null)return!1;let{name:t,code:s,message:n}=e;if(t==="ResolveMessage")return!0;if(s==="ERR_MODULE_NOT_FOUND"||s==="MODULE_NOT_FOUND"||s==="ERR_DLOPEN_FAILED")return!0;return typeof n==="string"&&/cannot find (module|package)/i.test(n)}var f_e,_Tt=null;var r3s=E(()=>{X();e3s();f_e=t3s.peerDependencies.fastembed});function t9(e,t){let s=e.length>t.length?e.length:t.length;if(s===0)return 0;let n=0,o=0,i=0;for(let r=0;r<s;r+=1){let a=e[r]??0,l=t[r]??0,u=Number.isFinite(a)?a:0,p=Number.isFinite(l)?l:0;n+=u*p,o+=u*u,i+=p*p}if(o===0||i===0)return 0;return n/(Math.sqrt(o)*Math.sqrt(i))}import{mkdirSync as U4r}from"fs";import*as ole from"fs/promises";import*as NE from"path";async function l3s(e,t){let s=/Load model from (.+?\.onnx) failed:.*Protobuf parsing failed/i.exec(e);if(!s)return!1;let n=NE.resolve(s[1]),o=NE.resolve(t??Aee());if(!n.startsWith(o+NE.sep))return!1;try{await ole.rename(n,`${n}.corrupt-${Date.now()}`),P.warn("mnemopi: quarantined corrupt local embedding model; retrying init",{modelFile:n})}catch{}return!0}async function u3s(e,t){let s=/Model file not found at (.+?\.onnx)\b/i.exec(e);if(!s)return!1;let n=NE.resolve(s[1]),o=NE.dirname(n),i=NE.resolve(t??Aee());if(NE.dirname(o)!==i)return!1;try{await ole.rm(o,{recursive:!0,force:!0}),await ole.rm(`${o}.tar.gz`,{force:!0}),P.warn("mnemopi: cleared incomplete local embedding model cache; re-downloading",{modelDir:o})}catch{}return!0}async function YN(e){let t=e.cacheDir??Aee(),s=e.cacheDir===void 0?{...e,cacheDir:t}:e,{FlagEmbedding:n}=await n3s(),o=async()=>{try{return await n.init(s)}catch(i){let r=i instanceof Error?i.message:"";if(!W4r.test(r))throw i;if(!await Qzs(e.model,t))throw i;return n.init(s)}};try{return await o()}catch(i){let r=i instanceof Error?i.message:"";if(/Protobuf parsing failed/i.test(r)&&await l3s(r,t))return o();if(await u3s(r,t))return o();throw i}}function nP(){return LE()?.embeddings}function NTt(e){let t=nP(),s=t?.provider,n=0;if(s!==void 0){let r=i3s.get(s);if(r===void 0)n=B4r++,i3s.set(s,n);else n=r}let o=sP(),i=t?.apiUrl??"";return`${n}::${o}::${i}::${e}`}function p3s(){return be.NODE_ENV==="test"||be.BUN_ENV==="test"}function h2(){let e=nP();if(e?.disabled!==void 0)return e.disabled;return Kn("MNEMOPI_NO_EMBEDDINGS")}function G4r(){let e=nP()?.maxInputChars;if(e!==void 0)return Math.max(0,Math.trunc(e));let t=Number.parseInt(be.MNEMOPI_EMBEDDING_MAX_INPUT_CHARS??"",10);if(Number.isFinite(t)&&t>=0)return t;return 8192}function $4r(e,t){if(e.length<=t)return e;if(t<=FTt.length+16)return e.slice(e.length-t);let s=t-FTt.length,n=s>>>1,o=s-n;return e.slice(0,n)+FTt+e.slice(e.length-o)}function z4r(e){let t=G4r();if(t===0)return e;let s=null,n=0,o=0;for(let i=0;i<e.length;i++){let r=e[i]??"";if(r.length<=t)continue;if(s===null)s=e.slice();if(s[i]=$4r(r,t),n++,r.length>o)o=r.length}if(s===null)return e;return P[Q8()?"warn":"debug"]("mnemopi: embedding input truncated",{inputCount:e.length,trimmedCount:n,maxOriginalLen:o,maxInputChars:t}),s}function c3s(){let e=nP();if(e?.apiKey!==void 0)return e.apiKey;return be.MNEMOPI_EMBEDDING_API_KEY||be.OPENROUTER_API_KEY||be.OPENAI_API_KEY||""}function UTt(e=c3s()){return typeof e==="function"||e!==""}function j4r(){let e=nP();if(e?.apiUrl!==void 0)return e.apiUrl;return be.MNEMOPI_EMBEDDING_API_URL||be.OPENROUTER_BASE_URL||"https://openrouter.ai/api/v1"}function sP(){let e=nP();if(e?.model!==void 0)return e.model;return be.MNEMOPI_EMBEDDING_MODEL||"BAAI/bge-small-en-v1.5"}function rle(){return sP()}function m_e(e){if(e.startsWith("openai/")||e.includes("text-embedding")||e.startsWith("text-embedding"))return!0;let s=nP()?.apiUrl??(be.MNEMOPI_EMBEDDING_API_URL||be.OPENROUTER_BASE_URL);if(s!==void 0&&s!==""&&!Yr(s,"openrouter"))return!0;return Kn("MNEMOPI_EMBEDDINGS_VIA_API")}function d3s(e){let t=Number.parseInt(be.MNEMOPI_EMBEDDING_DIM??"",10);if(Number.isFinite(t))return t;return V4r[e]??384}async function LTt(e){let t=[];for await(let s of e)for(let n of s)t.push(new Float32Array(n));return t}function f3s(e){let t=K4r[e];return t===void 0?null:t}async function Y4r(){if(m_e(sP())||h2()||p3s())return null;if(m2!==null)return m2;let e=f3s(sP());if(e===null)return null;let t=Aee();U4r(t,{recursive:!0});let s=DTt({model:e,cacheDir:t,showDownloadProgress:!1});m2=s;try{return await s}catch(n){if(P[Q8()?"warn":"debug"]("mnemopi: local embedding model failed to load",{model:e,error:String(n)}),m2===s)m2=null;return null}}async function X4r(e){let t=j4r(),s=!Yr(t,"openrouter"),n=c3s();if(!s&&!UTt(n))return null;let o=JSON.stringify({model:sP(),input:e});try{let i=await Rn(n,async(a)=>{let l={"Content-Type":"application/json",...Kj()};if(a!=="")l.Authorization=`Bearer ${a}`;let u=await Ec(`${t.replace(/\/+$/,"")}/embeddings`,{method:"POST",headers:l,body:o,signal:AbortSignal.timeout(30000),maxAttempts:3,defaultDelayMs:(p)=>2**p*1000});if(u.status===401)throw new Fs("mnemopi embedding request unauthorized (401)",401,{headers:u.headers});return u});if(!i.ok)return null;let{data:r}=await i.json();if(r===void 0)return null;return qTt+=1,r.map((a)=>new Float32Array(a.embedding))}catch(i){return P.debug("mnemopi embedding request failed",{status:$p(i)}),null}}async function a3s(e){if(e.available===void 0)return!0;try{return await e.available()}catch{return!1}}function m3s(e){s9=e??null,g2.clear()}function g3s(e){DTt=e??YN,m2=null,g2.clear()}function h3s(){s9=null,m2=null,DTt=YN,qTt=0,g2.clear()}async function Z4r(){if(h2())return!1;let e=nP(),t=ele(e?.provider);if(t!==void 0)return a3s(t);if(s9!==null)return a3s(s9);if(m_e(sP())){let s=e?.apiUrl??(be.MNEMOPI_EMBEDDING_API_URL||be.OPENROUTER_BASE_URL);if(s!==void 0&&s!==""&&!Yr(s,"openrouter"))return!0;return UTt()}if(p3s())return!1;return f3s(sP())!==null}function eVr(){return UTt()}async function BTt(e){if(e===""||h2())return null;let t=NTt(e),s=g2.get(t);if(s!==void 0)return s;let o=(await g_e([e]))?.[0]??null;if(o!==null)g2.set(t,o);return o}async function g_e(e){if(e.length===0||h2())return null;e=z4r(e);let t=ele(nP()?.provider);if(t!==void 0)try{return await LTt(await t.embed(e))}catch{return null}if(s9!==null)try{return await LTt(await s9.embed(e))}catch{return null}if(m_e(sP()))return X4r(e);if(e.length===1){let n=NTt(e[0]??""),o=g2.get(n);if(o!==void 0)return[o]}let s=await Y4r();if(s===null)return null;try{let n=await LTt(s.embed([...e]));if(n.length===1){let o=n[0];if(o!==void 0)g2.set(NTt(e[0]??""),o)}return n}catch(n){return P[Q8()?"warn":"debug"]("mnemopi: local embedding failed",{textCount:e.length,error:String(n)}),null}}function tVr(){return qTt}var H4r=512,s9=null,m2=null,DTt,qTt=0,g2,i3s,B4r=1,W4r,FTt=`
|
|
3531
|
+
Extraction:`;c_e=["fact","text","content","value","statement"],b4r=["instruction","rule",...c_e],S4r=["preference",...c_e],k4r=["description","event","timeline","date",...c_e]});function I4r(e){return Object.hasOwn(M4r,e)}function Yzs(e,t="veracity"){if(e===null||e===void 0)return"unknown";let s=String(e).trim().toLowerCase();if(s==="")return"unknown";if(I4r(s))return s;let n=String(e),o=n.length>Kzs?`${n.slice(0,Kzs)}...[truncated]`:n;return console.warn(`${t} received unknown veracity ${JSON.stringify(o)}; clamping to 'unknown'`),"unknown"}var bQl,M4r,Kzs=80,SQl;var Xzs=E(()=>{Zk();bQl=Object.freeze({stated:1,inferred:0.7,tool:0.5,imported:0.6,unknown:0.8}),M4r=Object.freeze({stated:!0,inferred:!0,tool:!0,imported:!0,unknown:!0}),SQl=Symbol("mnemopi.veracity.txDepth")});var Jzs=()=>{};import*as OTt from"path";async function Qzs(e,t="local_cache"){let s=O4r[e];if(s===void 0)return!1;let n=OTt.join(t,e);for(let o of P4r){let i=OTt.join(n,o);if(await Bun.file(i).exists())continue;let r=await fetch(`https://huggingface.co/${s}/resolve/main/${o}`);if(!r.ok)throw Error(`Failed to download ${e} ${o} from ${s}: ${r.status} ${r.statusText}`);await Bun.write(i,await r.arrayBuffer())}return!0}var P4r,O4r;var Zzs=E(()=>{P4r=["config.json","tokenizer.json","tokenizer_config.json","special_tokens_map.json"],O4r={"fast-all-MiniLM-L6-v2":"sentence-transformers/all-MiniLM-L6-v2","fast-bge-base-en":"BAAI/bge-base-en","fast-bge-base-en-v1.5":"BAAI/bge-base-en-v1.5","fast-bge-small-en":"BAAI/bge-small-en","fast-bge-small-en-v1.5":"BAAI/bge-small-en-v1.5","fast-bge-small-zh-v1.5":"BAAI/bge-small-zh-v1.5","fast-multilingual-e5-large":"intfloat/multilingual-e5-large"}});var t3s;var e3s=E(()=>{t3s={type:"module",name:"@linxiraos/pi-mnemopi",version:"1.1.3",description:"Local SQLite memory engine for Zeta agents",homepage:"https://linxira-os.github.io/zeta/",author:"Can Boluk",contributors:["Abdias J"],license:"MIT",repository:{type:"git",url:"git+https://github.com/Linxira-OS/linxira-zeta.git",directory:"packages/mnemopi"},bugs:{url:"https://github.com/Linxira-OS/linxira-zeta/issues"},keywords:["memory","sqlite","agent","embeddings","mcp"],main:"./src/index.ts",module:"./src/index.ts",types:"./dist/types/index.d.ts",bin:{mnemopi:"src/cli.ts"},scripts:{check:"biome check . && bun run check:types","check:types":"tsgo -p tsconfig.json --noEmit",lint:"biome lint .",test:"bun test --parallel",fix:"biome check --write --unsafe .",fmt:"biome format --write ."},dependencies:{"@linxiraos/pi-ai":"1.1.3","@linxiraos/pi-catalog":"1.1.3","@linxiraos/pi-natives":"1.1.3","@linxiraos/pi-utils":"1.1.3"},peerDependencies:{fastembed:"2.1.0","onnxruntime-node":"1.21.0"},peerDependenciesMeta:{fastembed:{optional:!0},"onnxruntime-node":{optional:!0}},devDependencies:{"@types/bun":"^1.3.14",fastembed:"2.1.0","onnxruntime-node":"1.26.0"},engines:{bun:">=1.3.14"},files:["src","README.md","CHANGELOG.md","LICENSE","THIRD-PARTY-NOTICES.txt","dist/types"],exports:{".":{types:"./dist/types/index.d.ts",import:"./src/index.ts"},"./core":{types:"./dist/types/core/index.d.ts",import:"./src/core/index.ts"},"./core/beam":{types:"./dist/types/core/beam/index.d.ts",import:"./src/core/beam/index.ts"},"./beam":{types:"./dist/types/core/beam/index.d.ts",import:"./src/core/beam/index.ts"},"./diagnose":{types:"./dist/types/diagnose.d.ts",import:"./src/diagnose.ts"},"./mcp":{types:"./dist/types/mcp-tools.d.ts",import:"./src/mcp-tools.ts"},"./cli":{types:"./dist/types/cli.d.ts",import:"./src/cli.ts"},"./*":{types:"./dist/types/*.d.ts",import:"./src/*.ts"},"./*.js":"./src/*.ts"}}});import{createRequire as s3s}from"module";import*as _m from"path";function F4r(){return{versionKey:`fastembed-${f_e}_transitive-ort`.replace(/[^A-Za-z0-9._-]/g,"_"),install:{dependencies:{fastembed:f_e},trustedDependencies:["onnxruntime-node"]}}}async function L4r({fastembedEntry:e,fastembedPackageDir:t,arch:s=process.arch,env:n=process.env}){let o=_m.join(t,"node_modules"),i=_m.dirname(t),r=Mc(o,"onnxruntime-node"),a=r??Mc(i,"onnxruntime-node"),l=_m.join(r?o:i,"onnxruntime-node");if(!a)throw Error(`Cannot find module onnxruntime-node beside ${e}`);let u=new Bun.Glob(`bin/napi-*/win32/${s}/onnxruntime.dll`),p;for await(let m of u.scan({cwd:l,absolute:!0,onlyFiles:!0})){p=_m.dirname(m);break}if(!p)throw Error(`Cannot find module onnxruntime-node Windows DLL for ${s} beside ${a}`);let c=n.PATH,d=_m.resolve(p).toLowerCase();if(!c?.split(_m.delimiter).some((m)=>_m.resolve(m).toLowerCase()===d))n.PATH=c?`${p}${_m.delimiter}${c}`:p;return{ortEntry:a,ortPackageDir:l,dllDir:p}}function n3s(){return _Tt??=N4r().catch((e)=>{throw _Tt=null,e}),_Tt}async function N4r(){try{let e=s3s(import.meta.url),t=e.resolve("fastembed/package.json"),s=e(t);if(s.version!==f_e)throw Error(`Cannot find package fastembed@${f_e}; resolved ${String(s.version)}`);return await o3s(e.resolve("fastembed"),_m.dirname(t))}catch(e){if(!q4r(e))throw e;return P.debug("mnemopi: fastembed not loadable, using on-demand runtime install",{error:String(e)}),D4r()}}async function o3s(e,t){let s=s3s(e);if(process.platform==="win32"){let{ortEntry:o}=await L4r({fastembedEntry:e,fastembedPackageDir:t});s(o)}return s(e)}async function D4r(){let e=F4r(),t=await j_({runtimeDir:_m.join(J8t(),e.versionKey),install:e.install,probePackage:"fastembed"}),s=_m.join(t,"node_modules");pbe({runtimeNodeModules:s});let n=Mc(s,"fastembed");if(!n)throw Error(`fastembed runtime install at ${t} has no loadable entry`);return o3s(n,_m.join(s,"fastembed"))}function q4r(e){if(typeof e!=="object"||e===null)return!1;let{name:t,code:s,message:n}=e;if(t==="ResolveMessage")return!0;if(s==="ERR_MODULE_NOT_FOUND"||s==="MODULE_NOT_FOUND"||s==="ERR_DLOPEN_FAILED")return!0;return typeof n==="string"&&/cannot find (module|package)/i.test(n)}var f_e,_Tt=null;var r3s=E(()=>{X();e3s();f_e=t3s.peerDependencies.fastembed});function t9(e,t){let s=e.length>t.length?e.length:t.length;if(s===0)return 0;let n=0,o=0,i=0;for(let r=0;r<s;r+=1){let a=e[r]??0,l=t[r]??0,u=Number.isFinite(a)?a:0,p=Number.isFinite(l)?l:0;n+=u*p,o+=u*u,i+=p*p}if(o===0||i===0)return 0;return n/(Math.sqrt(o)*Math.sqrt(i))}import{mkdirSync as U4r}from"fs";import*as ole from"fs/promises";import*as NE from"path";async function l3s(e,t){let s=/Load model from (.+?\.onnx) failed:.*Protobuf parsing failed/i.exec(e);if(!s)return!1;let n=NE.resolve(s[1]),o=NE.resolve(t??Aee());if(!n.startsWith(o+NE.sep))return!1;try{await ole.rename(n,`${n}.corrupt-${Date.now()}`),P.warn("mnemopi: quarantined corrupt local embedding model; retrying init",{modelFile:n})}catch{}return!0}async function u3s(e,t){let s=/Model file not found at (.+?\.onnx)\b/i.exec(e);if(!s)return!1;let n=NE.resolve(s[1]),o=NE.dirname(n),i=NE.resolve(t??Aee());if(NE.dirname(o)!==i)return!1;try{await ole.rm(o,{recursive:!0,force:!0}),await ole.rm(`${o}.tar.gz`,{force:!0}),P.warn("mnemopi: cleared incomplete local embedding model cache; re-downloading",{modelDir:o})}catch{}return!0}async function YN(e){let t=e.cacheDir??Aee(),s=e.cacheDir===void 0?{...e,cacheDir:t}:e,{FlagEmbedding:n}=await n3s(),o=async()=>{try{return await n.init(s)}catch(i){let r=i instanceof Error?i.message:"";if(!W4r.test(r))throw i;if(!await Qzs(e.model,t))throw i;return n.init(s)}};try{return await o()}catch(i){let r=i instanceof Error?i.message:"";if(/Protobuf parsing failed/i.test(r)&&await l3s(r,t))return o();if(await u3s(r,t))return o();throw i}}function nP(){return LE()?.embeddings}function NTt(e){let t=nP(),s=t?.provider,n=0;if(s!==void 0){let r=i3s.get(s);if(r===void 0)n=B4r++,i3s.set(s,n);else n=r}let o=sP(),i=t?.apiUrl??"";return`${n}::${o}::${i}::${e}`}function p3s(){return be.NODE_ENV==="test"||be.BUN_ENV==="test"}function h2(){let e=nP();if(e?.disabled!==void 0)return e.disabled;return Kn("MNEMOPI_NO_EMBEDDINGS")}function G4r(){let e=nP()?.maxInputChars;if(e!==void 0)return Math.max(0,Math.trunc(e));let t=Number.parseInt(be.MNEMOPI_EMBEDDING_MAX_INPUT_CHARS??"",10);if(Number.isFinite(t)&&t>=0)return t;return 8192}function $4r(e,t){if(e.length<=t)return e;if(t<=FTt.length+16)return e.slice(e.length-t);let s=t-FTt.length,n=s>>>1,o=s-n;return e.slice(0,n)+FTt+e.slice(e.length-o)}function z4r(e){let t=G4r();if(t===0)return e;let s=null,n=0,o=0;for(let i=0;i<e.length;i++){let r=e[i]??"";if(r.length<=t)continue;if(s===null)s=e.slice();if(s[i]=$4r(r,t),n++,r.length>o)o=r.length}if(s===null)return e;return P[Q8()?"warn":"debug"]("mnemopi: embedding input truncated",{inputCount:e.length,trimmedCount:n,maxOriginalLen:o,maxInputChars:t}),s}function c3s(){let e=nP();if(e?.apiKey!==void 0)return e.apiKey;return be.MNEMOPI_EMBEDDING_API_KEY||be.OPENROUTER_API_KEY||be.OPENAI_API_KEY||""}function UTt(e=c3s()){return typeof e==="function"||e!==""}function j4r(){let e=nP();if(e?.apiUrl!==void 0)return e.apiUrl;return be.MNEMOPI_EMBEDDING_API_URL||be.OPENROUTER_BASE_URL||"https://openrouter.ai/api/v1"}function sP(){let e=nP();if(e?.model!==void 0)return e.model;return be.MNEMOPI_EMBEDDING_MODEL||"BAAI/bge-small-en-v1.5"}function rle(){return sP()}function m_e(e){if(e.startsWith("openai/")||e.includes("text-embedding")||e.startsWith("text-embedding"))return!0;let s=nP()?.apiUrl??(be.MNEMOPI_EMBEDDING_API_URL||be.OPENROUTER_BASE_URL);if(s!==void 0&&s!==""&&!Yr(s,"openrouter"))return!0;return Kn("MNEMOPI_EMBEDDINGS_VIA_API")}function d3s(e){let t=Number.parseInt(be.MNEMOPI_EMBEDDING_DIM??"",10);if(Number.isFinite(t))return t;return V4r[e]??384}async function LTt(e){let t=[];for await(let s of e)for(let n of s)t.push(new Float32Array(n));return t}function f3s(e){let t=K4r[e];return t===void 0?null:t}async function Y4r(){if(m_e(sP())||h2()||p3s())return null;if(m2!==null)return m2;let e=f3s(sP());if(e===null)return null;let t=Aee();U4r(t,{recursive:!0});let s=DTt({model:e,cacheDir:t,showDownloadProgress:!1});m2=s;try{return await s}catch(n){if(P[Q8()?"warn":"debug"]("mnemopi: local embedding model failed to load",{model:e,error:String(n)}),m2===s)m2=null;return null}}async function X4r(e){let t=j4r(),s=!Yr(t,"openrouter"),n=c3s();if(!s&&!UTt(n))return null;let o=JSON.stringify({model:sP(),input:e});try{let i=await Rn(n,async(a)=>{let l={"Content-Type":"application/json",...Kj()};if(a!=="")l.Authorization=`Bearer ${a}`;let u=await Ec(`${t.replace(/\/+$/,"")}/embeddings`,{method:"POST",headers:l,body:o,signal:AbortSignal.timeout(30000),maxAttempts:3,defaultDelayMs:(p)=>2**p*1000});if(u.status===401)throw new Fs("mnemopi embedding request unauthorized (401)",401,{headers:u.headers});return u});if(!i.ok)return null;let{data:r}=await i.json();if(r===void 0)return null;return qTt+=1,r.map((a)=>new Float32Array(a.embedding))}catch(i){return P.debug("mnemopi embedding request failed",{status:$p(i)}),null}}async function a3s(e){if(e.available===void 0)return!0;try{return await e.available()}catch{return!1}}function m3s(e){s9=e??null,g2.clear()}function g3s(e){DTt=e??YN,m2=null,g2.clear()}function h3s(){s9=null,m2=null,DTt=YN,qTt=0,g2.clear()}async function Z4r(){if(h2())return!1;let e=nP(),t=ele(e?.provider);if(t!==void 0)return a3s(t);if(s9!==null)return a3s(s9);if(m_e(sP())){let s=e?.apiUrl??(be.MNEMOPI_EMBEDDING_API_URL||be.OPENROUTER_BASE_URL);if(s!==void 0&&s!==""&&!Yr(s,"openrouter"))return!0;return UTt()}if(p3s())return!1;return f3s(sP())!==null}function eVr(){return UTt()}async function BTt(e){if(e===""||h2())return null;let t=NTt(e),s=g2.get(t);if(s!==void 0)return s;let o=(await g_e([e]))?.[0]??null;if(o!==null)g2.set(t,o);return o}async function g_e(e){if(e.length===0||h2())return null;e=z4r(e);let t=ele(nP()?.provider);if(t!==void 0)try{return await LTt(await t.embed(e))}catch{return null}if(s9!==null)try{return await LTt(await s9.embed(e))}catch{return null}if(m_e(sP()))return X4r(e);if(e.length===1){let n=NTt(e[0]??""),o=g2.get(n);if(o!==void 0)return[o]}let s=await Y4r();if(s===null)return null;try{let n=await LTt(s.embed([...e]));if(n.length===1){let o=n[0];if(o!==void 0)g2.set(NTt(e[0]??""),o)}return n}catch(n){return P[Q8()?"warn":"debug"]("mnemopi: local embedding failed",{textCount:e.length,error:String(n)}),null}}function tVr(){return qTt}var H4r=512,s9=null,m2=null,DTt,qTt=0,g2,i3s,B4r=1,W4r,FTt=`
|
|
3532
3532
|
|
|
3533
3533
|
[...]
|
|
3534
3534
|
|
|
@@ -4031,7 +4031,7 @@ ${r.length} entr${r.length===1?"y":"ies"}:
|
|
|
4031
4031
|
|
|
4032
4032
|
${u}
|
|
4033
4033
|
`;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:s,targetPath:n}=await this.#l(e,t),o=dc.dirname(n);try{let l=await vp.promises.realpath(o);lb(l,s)}catch(l){if(!ye(l))throw l}let i;try{i=await vp.promises.realpath(n)}catch(l){if(ye(l))throw Error(`Vault file not found: ${e.url}`);throw l}lb(i,s);let r=await vp.promises.stat(i);if(r.isDirectory())return this.#u(e,t);if(!r.isFile())throw Error(`vault:// URL must resolve to a file or directory: ${e.url}`);let a=await Bun.file(i).text();return{url:e.url,content:a,contentType:r9r(i),size:Buffer.byteLength(a,"utf-8"),sourcePath:i}}async#c(e,t,s){let{root:n,targetPath:o}=await this.#l(e,s);try{let i=await vp.promises.realpath(o);if(lb(i,n),(await vp.promises.stat(i)).isDirectory())throw Error(`vault:// URL must resolve to a file: ${e.url}`)}catch(i){if(!ye(i))throw i;let r=dc.dirname(o),a=await b9r(r,n);lb(a,n),await vp.promises.mkdir(r,{recursive:!0});let l=await vp.promises.realpath(r);lb(l,n)}await Bun.write(o,t)}async#d(e,t){let s=w9r(e),n=[...this.#r(e.ref),...s.args],o=await this.#s(n,t);return SFe(s.opLabel,o),{url:e.url,content:o.stdout,contentType:s.contentType,size:Buffer.byteLength(o.stdout,"utf-8"),immutable:!0}}}var Zyt="/Applications/Obsidian.app/Contents/MacOS/obsidian",a4s=30000,n9r,o9r,jE,kFe,zE,h9,Qyt,m9r="vault:// is disabled. Enable it by setting `vault.enabled = true` (Settings \u2192 Tools \u2192 Obsidian Vault).",xFe;var EFe=E(()=>{X();Qt();Dg();JL();wE();XW();n9r={outline:!0,backlinks:!0,links:!0,tags:!0,properties:!0,tasks:!0,wordcount:!0,history:!0,base:!0},o9r={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},Qyt=new Map;xFe=class xFe extends Error{constructor(){super(m9r);this.name="VaultDisabledError"}}});function nw(e){let t=e.trim();if(!t.toLowerCase().startsWith("xd://"))return null;let s=t.slice(5);if(s.length===0)return{name:null};if(/[/?#]/.test(s))return null;return{name:s}}function m4s(e){if(e.length<=5)return"xd://".startsWith(e.toLowerCase());return e.toLowerCase().startsWith("xd://")}class sRt{scheme="xd";immutable=!0;async resolve(e,t){let s=nw(e.href);if(!s)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 n=await t.xd.read(s.name);return{url:e.href,content:n,contentType:"text/plain",size:Buffer.byteLength(n)}}async write(e,t,s){let n=nw(e.href);if(!n)throw Error(`Invalid xd:// URL: ${e.href}. Use xd://<tool>.`);if(!s?.xd)throw Error("xd:// is not mounted in this session.");await s.xd.write(n.name,t)}}var vu="xd://";class sa{static#e;#t=new Map;constructor(){this.register(new Oyt),this.register(new dpt),this.register(new hpt),this.register(new Iyt),this.register(new $y),this.register(new tRt),this.register(new Ggt),this.register(new Fyt),this.register(new kle),this.register(new ght),this.register(new Dgt),this.register(new qgt),this.register(new Xmt),this.register(new Xyt),this.register(new sRt)}static instance(){return sa.#e??=new sa,sa.#e}static resetForTests(){sa.#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=_Pe(e);if(!t)return!1;if(this.#t.has(t))return this.canHandle(e);return this.#s(t)}completionSchemes(){let e=[];for(let[t,s]of this.#t)if(s.complete)e.push(t);return e}async complete(e,t,s){let n=this.#t.get(e.toLowerCase());if(!n?.complete)return null;return n.complete(t,s)}#s(e){return!["file","http","https"].includes(e)&&this.#t.has("mcp")}#n(e,t=!1){let s=xf(e),n=s.protocol.replace(/:$/,"").toLowerCase(),o=this.#t.get(n)??(t&&this.#s(n)?this.#t.get("mcp"):void 0);if(!o){let i=Array.from(this.#t.keys()).map((r)=>`${r}://`).join(", ");throw Error(`Unknown protocol: ${n}://
|
|
4034
|
-
Supported: ${i||"none"}`)}return{parsed:s,handler:o}}async resolve(e,t){let{parsed:s,handler:n}=this.#n(e,!0),o=await n.resolve(s,t);return{...o,immutable:o.immutable??n.immutable}}async write(e,t,s){let{parsed:n,handler:o}=this.#n(e);if(!o.write){let i=n.protocol.replace(/:$/,"").toLowerCase();throw Error(`${i}:// URLs are read-only for write; use the protocol-specific tool for mutations.`)}await o.write(n,t,s)}}var Ile=E(()=>{fpt();BAe();Jmt();Ugt();DPe();hht();Z_e();_yt();wE();Lyt();cFe();XW();Jyt();EFe()});var ku=E(()=>{fpt();BAe();Jmt();Ugt();DPe();hht();Z_e();_yt();wE();Ile();Lyt();cFe();XW();Jyt();EFe()});import*as Pf from"fs";import*as w4s from"os";import*as Sn from"path";import*as x4s from"url";import{glob as x9r}from"@linxiraos/pi-natives";function M2(e){return Sn.posix.isAbsolute(e)||Sn.win32.isAbsolute(e)}function O9r(e){return e.replace(v9r," ")}function _9r(e){return e.replace(/ (AM|PM)\./g,`${P9r}$1.`)}function F9r(e){return e.normalize("NFD")}function y4s(e){return e.replace(/'/g,"\u2019")}function L9r(e){if(!e.includes("\\")||!e.includes("/"))return e;return e.replace(/\\([ \t"'(){}[\]])/g,"$1")}function Ple(e){try{return Pf.accessSync(e,Pf.constants.F_OK),!0}catch{return!1}}function N9r(e){if(!e.startsWith("@"))return e;let t=e.slice(1);if(t.startsWith("/")||t==="~"||t.startsWith("~/")||Sn.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 D9r(e){if(!e.toLowerCase().startsWith("file://"))return e;try{return x4s.fileURLToPath(e)}catch{return e}}function Cp(e,t){let s=t??w4s.homedir();if(e==="~")return s;if(e.startsWith("~/")||e.startsWith("~\\"))return s+e.slice(1);if(e.startsWith("~"))return Sn.join(s,e.slice(1));return e}function ub(e){let t=/^:(?=[/\\~]|\.\.?[/\\]|[A-Za-z]:)/.test(e)?e.slice(1):e,s=OS(D9r(O9r(N9r(t))));return Cp(s)}function R4s(e){if(e.length!==1)return!1;let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function q9r(e){if(!e.startsWith("/"))return;let t=e.split("/");if(t[0]!=="")return;let s,n=2;if(t.length>=2&&R4s(t[1]??""))s=t[1].toUpperCase();else if(t.length>=3&&(t[1]??"").toLowerCase()==="mnt"&&R4s(t[2]??""))s=t[2].toUpperCase(),n=3;if(!s)return;let o=t.slice(n).filter(Boolean).join("\\");return o?`${s}:\\${o}`:`${s}:\\`}function U9r(e,t=process.platform){if(t!=="win32")return e;return q9r(e)??e}function B9r(e){let t=H9r.exec(e);if(!t)return null;let s=Number.parseInt(t[1],10);if(s<1)throw new oe("Line selector 0 is invalid; lines are 1-indexed. Use :1.");let n=t[2]===".."?"-":t[2],o=t[3]?Number.parseInt(t[3],10):void 0,i;if(n==="+"){if(o===void 0||o<1)throw new oe(`Invalid range ${s}+${o??0}: count must be >= 1.`);i=s+o-1}else if(n==="-"){if(o!==void 0){if(o<s)throw new oe(`Invalid range ${s}-${o}: end must be >= start.`);i=o}}return{startLine:s,endLine:i}}function hT(e){let t=e.split(","),s=[];for(let o of t){let i=B9r(o);if(!i)return null;s.push(i)}if(s.length===0)return null;s.sort((o,i)=>o.startLine-i.startLine);let n=[s[0]];for(let o=1;o<s.length;o++){let i=s[o],r=n[n.length-1];if(r.endLine===void 0)continue;if(i.startLine<=r.endLine+1){if(i.endLine===void 0||i.endLine>r.endLine)n[n.length-1]={startLine:r.startLine,endLine:i.endLine};continue}n.push(i)}return n}function IFe(e){if(!e)return;for(let t of e.split(":")){let s=t.toLowerCase();if(s==="raw"||s==="conflicts")continue;let n=hT(t);if(n)return n}return}function _le(e,t){for(let s of t){if(e<s.startLine)continue;if(s.endLine===void 0||e<=s.endLine)return!0}return!1}function Ju(e){let t=e.lastIndexOf(":");if(t<=0)return{path:e};let s=e.slice(t+1);if(!E9r.test(s))return{path:e};let n=e.slice(0,t),o=s,i=n.lastIndexOf(":");if(i>0){let r=n.slice(i+1),a=T4s.test(r),l=T4s.test(s),u=h4s.test(r),p=h4s.test(s);if(a&&p||u&&l)o=`${r}:${s}`,n=n.slice(0,i)}return{path:n,sel:o}}async function oD(e,t){let s=lc(e,t);try{return await Pf.promises.lstat(s),"exists"}catch(n){if(ye(n)||OU(n)||va(n,"ENAMETOOLONG"))return"missing";return"unknown"}}async function PFe(e,t){let s=Ju(e);if(s.sel===void 0)return s;return await oD(e,t)==="missing"?s:{path:e}}function I2(e){let t=e.match(v4s);if(!t)return{path:e};let s=t[1].toLowerCase();if(I9r.has(s))return{path:e};if(!M9r[s])return{path:e};let n=t[0].length;if(s==="ssh"&&e.indexOf("/",n)===-1)return{path:e};let o=e,i=[];while(!0){let r=o.lastIndexOf(":");if(r<n)break;let a=o.slice(r+1);if(!A9r.test(a))break;i.unshift(a),o=o.slice(0,r)}if(i.length===0)return{path:e};return{path:o,sel:i.join(":")}}function E4s(e){let{path:t,sel:s}=I2(e);if(s===void 0)return e;if(/^(?:raw|conflicts)$/i.test(s))return t;throw new oe(`write does not accept the trailing selector ":${s}" \u2014 it writes a whole file. `+`Remove ":${s}", or if the filename truly ends with it, percent-encode the ":" as %3A.`)}function W9r(e,t){for(let s of aRt)if(e.startsWith(s))throw Error(`Path "${t}" uses internal scheme "${s}" and must be resolved through the proper protocol handler, not as a filesystem path.`)}function ci(e){return e.replace(/^(local:)\/(?!\/)/,"$1//")}function Of(e){let t=ci(e),s=ci(ub(t));for(let n of aRt)if(s.startsWith(n))return!0;return!1}function OFe(e){let t=ci(ub(ci(e)));if(!aRt.some((o)=>t.startsWith(o)))return"write";let s=v4s.exec(t)?.[1]?.toLowerCase();return(s?sa.instance().getHandler(s):void 0)?.write?"write":"read"}function y9(e){return/ssh:\/\//i.test(e)}function lRt(e){return/^ssh:\/\//i.test(e.trim())}function P2(e){return/^https?:\/\/?/i.test(e)||/^www\./i.test(e)}function ks(e,t){let s=ci(e),n=U9r(ub(s)),o=ci(n);if(W9r(o,s),/^\/+$/.test(n))return t;if(Sn.isAbsolute(n))return n;return Sn.resolve(t,n)}function A4s(e,t){if(!e||Sn.isAbsolute(e))return null;if(e.startsWith("~")||Of(e))return null;let s=Sn.resolve(t),n=Sn.resolve(s,e);if(!AFe(n,s))return null;let o=nRt(s);if(!o)return null;let i=nRt(n);if(i)return AFe(i,o)?n:null;if(G9r(n))return null;let r=Sn.dirname(n),a=[Sn.basename(n)];for(;;){let l=nRt(r);if(l)return AFe(Sn.join(l,...a.reverse()),o)?n:null;let u=Sn.dirname(r);if(u===r||!AFe(r,s))return null;a.push(Sn.basename(r)),r=u}}function AFe(e,t){let s=Sn.relative(t,e);return!!s&&!s.startsWith("..")&&!Sn.isAbsolute(s)}function nRt(e){try{return Pf.realpathSync.native(e)}catch{return null}}function G9r(e){try{return Pf.lstatSync(e).isSymbolicLink()}catch{return!1}}async function uRt(e,t){let s=Sn.resolve(e);if(t){let i=await C4s(s);if(i!==null)return i;if(!await b4s(s))return null}let n=[Sn.basename(s)],o=Sn.dirname(s);for(;;){let i=await C4s(o);if(i!==null)return Sn.join(i,...n.reverse());if(!await b4s(o))return null;let r=Sn.dirname(o);if(r===o)return null;n.push(Sn.basename(o)),o=r}}async function C4s(e){try{return await Pf.promises.realpath(e)}catch{return null}}async function b4s(e){try{return!(await Pf.promises.lstat(e)).isSymbolicLink()}catch(t){return ye(t)}}function tn(e,t,s={}){let n=Sn.resolve(t),o=ci(e);if(Of(o))return o;let i=ub(o),r=Sn.isAbsolute(i)?Sn.resolve(i):Sn.resolve(t,i),a=Sn.relative(n,r),l=a===""||!a.startsWith("..")&&!Sn.isAbsolute(a),u=T9(l?a||".":r);if(s.trailingSlash&&u!=="."&&!u.endsWith("/"))u+="/";return u}function pRt(e){return e.startsWith('"')&&e.endsWith('"')&&e.length>1?e.slice(1,-1):e}function cRt(e){if(Of(e))return e;if(!e.includes("\\"))return e;return e.replace(/\\/g,"/")}function rD(e){return pRt(e.trim())}function $9r(e){let t=e.trim();if(!t.startsWith("[")||!t.endsWith("]"))return null;let s;try{s=JSON.parse(t)}catch{return null}if(!Array.isArray(s)||s.some((n)=>typeof n!=="string"))return null;return s}function Zy(e){if(typeof e==="string")return $9r(e)??[e];return e??[]}function ow(e){return z9r.some((t)=>e.includes(t))}function j9r(e,t){if(t==="comma")return e===",";if(t==="semicolon")return e===";";if(t==="whitespace")return rRt.test(e);return e===","||e===";"||rRt.test(e)}function V9r(e){let t=0;for(let s=0;s<e.length;s++){let n=e[s];if(n==="\\"&&s+1<e.length){s++;continue}if(n==="{"){t++;continue}if(n==="}"){if(t>0)t--;continue}if(t===0&&(n===","||n===";"||rRt.test(n)))return!0}return!1}function K9r(e,t){let s=[],n=0,o=0;for(let i=0;i<e.length;i++){let r=e[i];if(r==="\\"&&i+1<e.length){i++;continue}if(r==="{"){n++;continue}if(r==="}"){if(n>0)n--;continue}if(n!==0||!j9r(r,t))continue;s.push(e.slice(o,i)),o=i+1}return s.push(e.slice(o)),s}async function M4s(e,t,s){if(Of(e))return!0;let n=Ju(e).path,{basePath:o}=s(n),i=ks(o,t);try{return await Pf.promises.stat(i),!0}catch(r){if(ye(r)||va(r,"ENAMETOOLONG"))return!1;throw r}}async function Ole(e,t,s,n,o){let i=K9r(e,n);if(i.length<2)return null;let r=i.map(rD).filter((a)=>a.length>0);if(r.length===0)return null;if(r.length<2&&i.length===r.length)return null;if(o!=="none"){let a=await Promise.all(r.map((u)=>M4s(u,t,s)));if(!(o==="all"?a.every(Boolean):a.some(Boolean)))return null}return r}async function dRt(e,t,s={}){let n=rD(e);if(!V9r(n))return null;let o=s.splitter??MFe;if(s.routedUrlPredicate?.(n)){let r=await Ole(n,t,o,"semicolon","none");return r?.every(s.routedUrlPredicate)?r:null}if(Of(n))return null;if(await oD(n,t)!=="missing")return null;let i=Ju(n).path;if(!ow(i)&&await M4s(n,t,o))return null;return await Ole(n,t,o,"semicolon","none")??await Ole(n,t,o,"comma","some")??await Ole(n,t,o,"whitespace","all")??await Ole(n,t,o,"mixed","all")}async function Fle(e,t,s={}){let n=[];for(let o of e){let i=rD(o),r=await dRt(i,t,s);if(r)n.push(...r);else n.push(i)}return n}function MFe(e){let t=cRt(e),s=t.split("/"),n=-1;for(let o=0;o<s.length;o++)if(ow(s[o])){n=o;break}if(n===-1)return{basePath:t};if(n<=0)return{basePath:".",glob:t};return{basePath:s.slice(0,n).join("/"),glob:s.slice(n).join("/")}}async function I4s(e,t){if(!ow(e)||Of(e))return MFe(e);try{return await Pf.promises.stat(ks(e,t)),{basePath:cRt(e)}}catch{return MFe(e)}}function Lle(e){let t=cRt(e),s=t.split("/"),n=-1;for(let o=0;o<s.length;o++)if(ow(s[o])){n=o;break}if(n===-1)return{basePath:t,globPattern:"**/*",hasGlob:!1};if(n===0)return{basePath:".",globPattern:!t.startsWith("**/")?`**/${t}`:t,hasGlob:!0};return{basePath:s.slice(0,n).join("/"),globPattern:s.slice(n).join("/"),hasGlob:!0}}function oRt(e,t){if(!e)return t;if(!t)return e;let s=e.replace(/\/+$/,""),n=t.replace(/^\/+/,"");return`${s}/${n}`}function T9(e){return e.replace(/\\/g,"/")}function S4s(e,t){if(!e||e===".")return T9(t).replace(/^\/+/,"");let s=T9(e).replace(/\/+$/,""),n=T9(t).replace(/^\/+/,"");return`${s}/${n}`}function Y9r(e){let t=[...new Set(e.map((s)=>T9(s).trim()).filter(Boolean))];if(t.length===0)return;if(t.length===1)return t[0];return`{${t.join(",")}}`}function X9r(e){if(e.length===0)return".";let t=Sn.resolve(e[0]).split(Sn.sep);for(let n of e.slice(1)){let o=Sn.resolve(n).split(Sn.sep),i=0,r=Math.min(t.length,o.length);while(i<r&&t[i]===o[i])i+=1;t=t.slice(0,i)}if(t.length===0)return Sn.parse(Sn.resolve(e[0])).root;return t.join(Sn.sep)||Sn.parse(Sn.resolve(e[0])).root}function P4s(e,t){return e.map((s)=>tn(s,t,{trailingSlash:s.endsWith("/")||s.endsWith("\\")})).join(", ")}async function J9r(e,t,s,n=!1){if(e.length<1)return;let o=await Promise.all(e.map(async(c)=>{let d=await I4s(c,t),f=ks(d.basePath,t),m=await Pf.promises.stat(f);return{raw:c,parsedPath:d,absoluteBasePath:f,stat:m}})),i=!s&&o.every((c)=>!c.parsedPath.glob&&c.stat.isFile()),r=X9r(o.map((c)=>c.absoluteBasePath)),a=o.map((c)=>{let d=T9(Sn.relative(r,c.absoluteBasePath))||".";if(c.parsedPath.glob){let f=S4s(d,c.parsedPath.glob);return oRt(f,s)??f}if(s)return oRt(d==="."?void 0:d,s)??s;if(c.stat.isDirectory())return S4s(d,"**/*");return d==="."?Sn.basename(c.absoluteBasePath):d}),l=o.some((c)=>c.absoluteBasePath===r),u=n&&!i&&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?oRt(c.parsedPath.glob,s):s})):void 0;return{basePath:r,glob:Y9r(a),scopePath:P4s(e,t),exactFilePaths:i?o.map((c)=>c.absoluteBasePath):void 0,targets:p}}async function Q9r(e,t,s,n=!1){return J9r([...new Set(e)],t,s,n)}async function Z9r(e,t){if(e.length<=1)return;return{targets:e.map((n)=>{let o=Lle(n);return{basePath:ks(o.basePath,t),globPattern:o.globPattern,hasGlob:o.hasGlob}}),scopePath:P4s(e,t)}}async function O4s(e,t){return Z9r([...new Set(e)],t)}async function fRt(e,t,s){let n=await Promise.all(e.map(async(r)=>{let{basePath:a}=s(r),l=ks(a,t);try{return await Pf.promises.stat(l),{item:r,exists:!0}}catch(u){if(ye(u))return{item:r,exists:!1};throw u}})),o=[],i=[];for(let r of n)if(r.exists)o.push(r.item);else i.push(r.item);return{valid:o,missing:i}}function lc(e,t){let s=ks(e,t),n=L9r(s),o=n!==s?[s,n]:[s];for(let i of o)if(Ple(i))return i;for(let i of o){let r=_9r(i);if(r!==i&&Ple(r))return r;let a=F9r(i);if(a!==i&&Ple(a))return a;let l=y4s(i);if(l!==i&&Ple(l))return l;let u=y4s(a);if(u!==i&&Ple(u))return u}return s}function eKr(e){return e.replace(/[*?[{]/g,"[$&]")}async function tKr(e,t,s,n){let o=e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"");if(!o)return null;let i=AbortSignal.timeout(k4s),r=s?AbortSignal.any([s,i]):i,a;try{let l=await n({pattern:`**/${eKr(o)}`,path:t,hidden:!0,signal:r,timeoutMs:k4s});if(s?.aborted)throw new rt;a=l.matches.map((u)=>u.path)}catch{if(s?.aborted)throw new rt;return null}if(a.length!==1)return null;return{absolutePath:Sn.resolve(t,a[0]),displayPath:a[0]}}async function _Fe(e,t,s){return tKr(e,t,s,x9r)}async function R9(e){let{rawPaths:t,cwd:s,internalUrlAction:n}=e,o=t.map(rD);if(o.some((R)=>R.length===0))throw new oe("Search scope entries must be non-empty paths or globs");let i=await Fle(o,s);if(i.some((R)=>R.length===0))throw new oe("Search scope entries must be non-empty paths or globs");let r=/^(?:https?|ftp|ws|wss):\/\//i,a=sa.instance(),l=[],u=new Set;for(let R of i){let C=r.test(R);if(!C&&P2(R)&&!ow(R))try{await Pf.promises.stat(ks(R,s))}catch(x){C=ye(x)||OU(x)}if(C){let x=e.resolveExternalUrl?await e.resolveExternalUrl(R):void 0;if(x){if(l.push(x.sourcePath),e.trackImmutableSources&&x.immutable)u.add(Sn.resolve(x.sourcePath));continue}throw new oe(`Cannot ${n} external URL: ${R}. Use \`read\` to fetch web content, then search the returned text.`)}if(!a.canHandle(R)){l.push(R);continue}if(lRt(R))throw new oe(`Cannot ${n} a remote ssh:// path (no local file): ${R}. Use \`read ${R}\` to view it, or use \`grep\` on a specific remote file.`);if(ow(R))throw new oe(`Glob patterns are not supported for internal URLs: ${R}`);let w=await a.resolve(R,{cwd:s,settings:e.settings,signal:e.signal,localProtocolOptions:e.localProtocolOptions,skills:e.skills,pathOnly:!0});if(!w.sourcePath)throw new oe(`Cannot ${n} internal URL without a backing file: ${R}`);if(e.trackImmutableSources&&w.immutable)u.add(Sn.resolve(w.sourcePath));l.push(w.sourcePath)}let p=[],c=l;if(l.length>1){let R=await fRt(l,s,MFe);if(R.valid.length===0)throw new oe(`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 I4s(c[0]??".",s);d=ks(R.basePath,s),m=R.glob,f=tn(d,s)}else{let R=await Q9r(c,s,void 0,e.fanOutFileTargets===!0);if(!R)throw new oe("`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&&i.length>1?e.multipathStatHint:"";throw new oe(`Path not found: ${f}${R}`)}return{searchPath:d,scopePath:f,globFilter:m,isDirectory:T,multiTargets:g,exactFilePaths:h,missingPaths:p,immutableSourcePaths:u}}var v9r,g4s,iRt,E9r,h4s,T4s,A9r,M9r,I9r,v4s,P9r="\u202F",aRt,H9r,z9r,rRt,k4s=5000;var Ss=E(()=>{X();ku();Ut();v9r=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;g4s=String.raw`L?\d+(?:(?:[-+]|\.\.)L?\d+|-|\.\.)?`,iRt=`${g4s}(?:,${g4s})*`,E9r=new RegExp(`^(?:${iRt}|raw|conflicts)$`,"i"),h4s=new RegExp(`^${iRt}$`,"i"),T4s=/^raw$/i,A9r=new RegExp(String.raw`^(?:raw|conflicts|${iRt}|-\d+(?:[-+]\d+)?)$`,"i"),M9r={agent:!0,artifact:!0,issue:!0,history:!0,local:!0,memory:!0,omp:!0,pr:!0,rule:!0,security:!0,skill:!0,ssh:!0,vault:!0},I9r=new Set(["mcp"]),v4s=/^([a-z][a-z0-9+.-]*):\/\//i,aRt=["agent://","artifact://","skill://","rule://","security://","local://","mcp://","ssh://","vault://"];H9r=/^L?(\d+)(?:(\.\.|[-+])L?(\d+)?)?$/i;z9r=["*","?","[","{"];rRt=/\s/});var C9;var FFe=E(()=>{C9={type:"module",name:"@linxiraos/zeta",version:"1.1.2",description:"Coding agent CLI with read, bash, edit, write tools and session management",homepage:"https://linxira-os.github.io/zeta/",author:"Stencil Labs, Inc.",contributors:["Mario Zechner"],license:"MIT",repository:{type:"git",url:"git+https://github.com/Linxira-OS/linxira-zeta.git",directory:"packages/coding-agent"},bugs:{url:"https://github.com/Linxira-OS/linxira-zeta/issues"},keywords:["coding-agent","ai","llm","cli","tui","agent"],main:"./src/index.ts",types:"./dist/types/index.d.ts",bin:{zeta:"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":"^7.29.7","@linxiraos/pi-hashline":"1.1.2","@linxiraos/pi-stats":"1.1.2","@linxiraos/pi-omptype":"1.1.2","@linxiraos/pi-agent-core":"1.1.2","@linxiraos/pi-ai":"1.1.2","@linxiraos/pi-catalog":"1.1.2","@linxiraos/pi-mnemopi":"1.1.2","@linxiraos/pi-natives":"1.1.2","@linxiraos/pi-tui":"1.1.2","@linxiraos/pi-utils":"1.1.2","@linxiraos/pi-wire":"1.1.2","@linxiraos/pi-snapcompact":"1.1.2","@opentelemetry/api":"^1.9.1","@opentelemetry/api-logs":"^0.220.0","@opentelemetry/context-async-hooks":"^2.9.0","@opentelemetry/exporter-logs-otlp-proto":"^0.220.0","@opentelemetry/exporter-metrics-otlp-proto":"^0.220.0","@opentelemetry/exporter-trace-otlp-proto":"^0.220.0","@opentelemetry/resources":"^2.9.0","@opentelemetry/sdk-logs":"^0.220.0","@opentelemetry/sdk-metrics":"^2.9.0","@opentelemetry/sdk-trace-base":"^2.9.0","@opentelemetry/sdk-trace-node":"^2.9.0","puppeteer-core":"25.3.0"},optionalDependencies:{"@huggingface/transformers":"^4.2.0","sherpa-onnx-node":"1.13.2"},devDependencies:{"@types/bun":"^1.3.14"},engines:{bun:">=1.3.14"},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","LICENSE","THIRD-PARTY-NOTICES.txt","dist/types"],exports:{".":{types:"./dist/types/index.d.ts",import:"./src/index.ts"},"./*":{types:"./dist/types/*.d.ts",import:"./src/*.ts"},"./async":{types:"./dist/types/async/index.d.ts",import:"./src/async/index.ts"},"./async/*":{types:"./dist/types/async/*.d.ts",import:"./src/async/*.ts"},"./autoresearch":{types:"./dist/types/autoresearch/index.d.ts",import:"./src/autoresearch/index.ts"},"./autoresearch/*":{types:"./dist/types/autoresearch/*.d.ts",import:"./src/autoresearch/*.ts"},"./autoresearch/tools/*":{types:"./dist/types/autoresearch/tools/*.d.ts",import:"./src/autoresearch/tools/*.ts"},"./capability":{types:"./dist/types/capability/index.d.ts",import:"./src/capability/index.ts"},"./capability/*":{types:"./dist/types/capability/*.d.ts",import:"./src/capability/*.ts"},"./cli/*":{types:"./dist/types/cli/*.d.ts",import:"./src/cli/*.ts"},"./cli/gallery-fixtures":{types:"./dist/types/cli/gallery-fixtures/index.d.ts",import:"./src/cli/gallery-fixtures/index.ts"},"./cli/gallery-fixtures/*":{types:"./dist/types/cli/gallery-fixtures/*.d.ts",import:"./src/cli/gallery-fixtures/*.ts"},"./cli/commands/*":{types:"./dist/types/cli/commands/*.d.ts",import:"./src/cli/commands/*.ts"},"./commands/*":{types:"./dist/types/commands/*.d.ts",import:"./src/commands/*.ts"},"./commit":{types:"./dist/types/commit/index.d.ts",import:"./src/commit/index.ts"},"./commit/*":{types:"./dist/types/commit/*.d.ts",import:"./src/commit/*.ts"},"./commit/agentic":{types:"./dist/types/commit/agentic/index.d.ts",import:"./src/commit/agentic/index.ts"},"./commit/agentic/*":{types:"./dist/types/commit/agentic/*.d.ts",import:"./src/commit/agentic/*.ts"},"./commit/agentic/tools":{types:"./dist/types/commit/agentic/tools/index.d.ts",import:"./src/commit/agentic/tools/index.ts"},"./commit/agentic/tools/*":{types:"./dist/types/commit/agentic/tools/*.d.ts",import:"./src/commit/agentic/tools/*.ts"},"./commit/analysis":{types:"./dist/types/commit/analysis/index.d.ts",import:"./src/commit/analysis/index.ts"},"./commit/analysis/*":{types:"./dist/types/commit/analysis/*.d.ts",import:"./src/commit/analysis/*.ts"},"./commit/changelog":{types:"./dist/types/commit/changelog/index.d.ts",import:"./src/commit/changelog/index.ts"},"./commit/changelog/*":{types:"./dist/types/commit/changelog/*.d.ts",import:"./src/commit/changelog/*.ts"},"./commit/git/*":{types:"./dist/types/commit/git/*.d.ts",import:"./src/commit/git/*.ts"},"./commit/map-reduce":{types:"./dist/types/commit/map-reduce/index.d.ts",import:"./src/commit/map-reduce/index.ts"},"./commit/map-reduce/*":{types:"./dist/types/commit/map-reduce/*.d.ts",import:"./src/commit/map-reduce/*.ts"},"./commit/utils/*":{types:"./dist/types/commit/utils/*.d.ts",import:"./src/commit/utils/*.ts"},"./config/*":{types:"./dist/types/config/*.d.ts",import:"./src/config/*.ts"},"./dap":{types:"./dist/types/dap/index.d.ts",import:"./src/dap/index.ts"},"./dap/*":{types:"./dist/types/dap/*.d.ts",import:"./src/dap/*.ts"},"./debug":{types:"./dist/types/debug/index.d.ts",import:"./src/debug/index.ts"},"./debug/*":{types:"./dist/types/debug/*.d.ts",import:"./src/debug/*.ts"},"./discovery":{types:"./dist/types/discovery/index.d.ts",import:"./src/discovery/index.ts"},"./discovery/*":{types:"./dist/types/discovery/*.d.ts",import:"./src/discovery/*.ts"},"./edit":{types:"./dist/types/edit/index.d.ts",import:"./src/edit/index.ts"},"./edit/*":{types:"./dist/types/edit/*.d.ts",import:"./src/edit/*.ts"},"./edit/modes/*":{types:"./dist/types/edit/modes/*.d.ts",import:"./src/edit/modes/*.ts"},"./exa":{types:"./dist/types/exa/index.d.ts",import:"./src/exa/index.ts"},"./exa/*":{types:"./dist/types/exa/*.d.ts",import:"./src/exa/*.ts"},"./exec/*":{types:"./dist/types/exec/*.d.ts",import:"./src/exec/*.ts"},"./export/*":{types:"./dist/types/export/*.d.ts",import:"./src/export/*.ts"},"./export/html":{types:"./dist/types/export/html/index.d.ts",import:"./src/export/html/index.ts"},"./export/html/*":{types:"./dist/types/export/html/*.d.ts",import:"./src/export/html/*.ts"},"./extensibility/*":{types:"./dist/types/extensibility/*.d.ts",import:"./src/extensibility/*.ts"},"./extensibility/custom-commands":{types:"./dist/types/extensibility/custom-commands/index.d.ts",import:"./src/extensibility/custom-commands/index.ts"},"./extensibility/custom-commands/*":{types:"./dist/types/extensibility/custom-commands/*.d.ts",import:"./src/extensibility/custom-commands/*.ts"},"./extensibility/custom-commands/bundled/ci-green":{types:"./dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts",import:"./src/extensibility/custom-commands/bundled/ci-green/index.ts"},"./extensibility/custom-commands/bundled/review":{types:"./dist/types/extensibility/custom-commands/bundled/review/index.d.ts",import:"./src/extensibility/custom-commands/bundled/review/index.ts"},"./extensibility/custom-tools":{types:"./dist/types/extensibility/custom-tools/index.d.ts",import:"./src/extensibility/custom-tools/index.ts"},"./extensibility/custom-tools/*":{types:"./dist/types/extensibility/custom-tools/*.d.ts",import:"./src/extensibility/custom-tools/*.ts"},"./extensibility/extensions":{types:"./dist/types/extensibility/extensions/index.d.ts",import:"./src/extensibility/extensions/index.ts"},"./extensibility/extensions/*":{types:"./dist/types/extensibility/extensions/*.d.ts",import:"./src/extensibility/extensions/*.ts"},"./extensibility/hooks":{types:"./dist/types/extensibility/hooks/index.d.ts",import:"./src/extensibility/hooks/index.ts"},"./extensibility/hooks/*":{types:"./dist/types/extensibility/hooks/*.d.ts",import:"./src/extensibility/hooks/*.ts"},"./extensibility/plugins":{types:"./dist/types/extensibility/plugins/index.d.ts",import:"./src/extensibility/plugins/index.ts"},"./extensibility/plugins/*":{types:"./dist/types/extensibility/plugins/*.d.ts",import:"./src/extensibility/plugins/*.ts"},"./extensibility/plugins/marketplace":{types:"./dist/types/extensibility/plugins/marketplace/index.d.ts",import:"./src/extensibility/plugins/marketplace/index.ts"},"./extensibility/plugins/marketplace/*":{types:"./dist/types/extensibility/plugins/marketplace/*.d.ts",import:"./src/extensibility/plugins/marketplace/*.ts"},"./internal-urls":{types:"./dist/types/internal-urls/index.d.ts",import:"./src/internal-urls/index.ts"},"./internal-urls/*":{types:"./dist/types/internal-urls/*.d.ts",import:"./src/internal-urls/*.ts"},"./eval":{types:"./dist/types/eval/index.d.ts",import:"./src/eval/index.ts"},"./eval/js/*":{types:"./dist/types/eval/js/*.d.ts",import:"./src/eval/js/*.ts"},"./eval/py/*":{types:"./dist/types/eval/py/*.d.ts",import:"./src/eval/py/*.ts"},"./lsp":{types:"./dist/types/lsp/index.d.ts",import:"./src/lsp/index.ts"},"./lsp/*":{types:"./dist/types/lsp/*.d.ts",import:"./src/lsp/*.ts"},"./lsp/clients":{types:"./dist/types/lsp/clients/index.d.ts",import:"./src/lsp/clients/index.ts"},"./lsp/clients/*":{types:"./dist/types/lsp/clients/*.d.ts",import:"./src/lsp/clients/*.ts"},"./markit":{types:"./dist/types/markit/index.d.ts",import:"./src/markit/index.ts"},"./markit/*":{types:"./dist/types/markit/*.d.ts",import:"./src/markit/*.ts"},"./mcp":{types:"./dist/types/mcp/index.d.ts",import:"./src/mcp/index.ts"},"./mcp/*":{types:"./dist/types/mcp/*.d.ts",import:"./src/mcp/*.ts"},"./mcp/transports":{types:"./dist/types/mcp/transports/index.d.ts",import:"./src/mcp/transports/index.ts"},"./mcp/transports/*":{types:"./dist/types/mcp/transports/*.d.ts",import:"./src/mcp/transports/*.ts"},"./memories":{types:"./dist/types/memories/index.d.ts",import:"./src/memories/index.ts"},"./memories/*":{types:"./dist/types/memories/*.d.ts",import:"./src/memories/*.ts"},"./memory-backend":{types:"./dist/types/memory-backend/index.d.ts",import:"./src/memory-backend/index.ts"},"./memory-backend/*":{types:"./dist/types/memory-backend/*.d.ts",import:"./src/memory-backend/*.ts"},"./hindsight":{types:"./dist/types/hindsight/index.d.ts",import:"./src/hindsight/index.ts"},"./hindsight/*":{types:"./dist/types/hindsight/*.d.ts",import:"./src/hindsight/*.ts"},"./modes":{types:"./dist/types/modes/index.d.ts",import:"./src/modes/index.ts"},"./modes/*":{types:"./dist/types/modes/*.d.ts",import:"./src/modes/*.ts"},"./modes/acp":{types:"./dist/types/modes/acp/index.d.ts",import:"./src/modes/acp/index.ts"},"./modes/acp/*":{types:"./dist/types/modes/acp/*.d.ts",import:"./src/modes/acp/*.ts"},"./modes/components":{types:"./dist/types/modes/components/index.d.ts",import:"./src/modes/components/index.ts"},"./modes/components/*":{types:"./dist/types/modes/components/*.d.ts",import:"./src/modes/components/*.ts"},"./modes/components/extensions":{types:"./dist/types/modes/components/extensions/index.d.ts",import:"./src/modes/components/extensions/index.ts"},"./modes/components/extensions/*":{types:"./dist/types/modes/components/extensions/*.d.ts",import:"./src/modes/components/extensions/*.ts"},"./modes/components/status-line":{types:"./dist/types/modes/components/status-line/index.d.ts",import:"./src/modes/components/status-line/index.ts"},"./modes/components/status-line/*":{types:"./dist/types/modes/components/status-line/*.d.ts",import:"./src/modes/components/status-line/*.ts"},"./modes/controllers/*":{types:"./dist/types/modes/controllers/*.d.ts",import:"./src/modes/controllers/*.ts"},"./modes/setup-wizard":{types:"./dist/types/modes/setup-wizard/index.d.ts",import:"./src/modes/setup-wizard/index.ts"},"./modes/setup-wizard/*":{types:"./dist/types/modes/setup-wizard/*.d.ts",import:"./src/modes/setup-wizard/*.ts"},"./modes/rpc/*":{types:"./dist/types/modes/rpc/*.d.ts",import:"./src/modes/rpc/*.ts"},"./modes/theme/*":{types:"./dist/types/modes/theme/*.d.ts",import:"./src/modes/theme/*.ts"},"./modes/theme/defaults":{types:"./dist/types/modes/theme/defaults/index.d.ts",import:"./src/modes/theme/defaults/index.ts"},"./modes/utils/*":{types:"./dist/types/modes/utils/*.d.ts",import:"./src/modes/utils/*.ts"},"./plan-mode/*":{types:"./dist/types/plan-mode/*.d.ts",import:"./src/plan-mode/*.ts"},"./prompts/*":"./src/prompts/*.md","./secrets":{types:"./dist/types/secrets/index.d.ts",import:"./src/secrets/index.ts"},"./secrets/*":{types:"./dist/types/secrets/*.d.ts",import:"./src/secrets/*.ts"},"./session/*":{types:"./dist/types/session/*.d.ts",import:"./src/session/*.ts"},"./slash-commands/*":{types:"./dist/types/slash-commands/*.d.ts",import:"./src/slash-commands/*.ts"},"./ssh/*":{types:"./dist/types/ssh/*.d.ts",import:"./src/ssh/*.ts"},"./stt":{types:"./dist/types/stt/index.d.ts",import:"./src/stt/index.ts"},"./stt/*":{types:"./dist/types/stt/*.d.ts",import:"./src/stt/*.ts"},"./task":{types:"./dist/types/task/index.d.ts",import:"./src/task/index.ts"},"./task/*":{types:"./dist/types/task/*.d.ts",import:"./src/task/*.ts"},"./tools":{types:"./dist/types/tools/index.d.ts",import:"./src/tools/index.ts"},"./tools/hub":{types:"./dist/types/tools/hub/index.d.ts",import:"./src/tools/hub/index.ts"},"./tools/hub/*":{types:"./dist/types/tools/hub/*.d.ts",import:"./src/tools/hub/*.ts"},"./tools/*":{types:"./dist/types/tools/*.d.ts",import:"./src/tools/*.ts"},"./tui":{types:"./dist/types/tui/index.d.ts",import:"./src/tui/index.ts"},"./tui/*":{types:"./dist/types/tui/*.d.ts",import:"./src/tui/*.ts"},"./utils/*":{types:"./dist/types/utils/*.d.ts",import:"./src/utils/*.ts"},"./web/*":{types:"./dist/types/web/*.d.ts",import:"./src/web/*.ts"},"./web/scrapers":{types:"./dist/types/web/scrapers/index.d.ts",import:"./src/web/scrapers/index.ts"},"./web/scrapers/*":{types:"./dist/types/web/scrapers/*.d.ts",import:"./src/web/scrapers/*.ts"},"./web/search":{types:"./dist/types/web/search/index.d.ts",import:"./src/web/search/index.ts"},"./web/search/*":{types:"./dist/types/web/search/*.d.ts",import:"./src/web/search/*.ts"},"./web/search/providers/*":{types:"./dist/types/web/search/providers/*.d.ts",import:"./src/web/search/providers/*.ts"},"./*.js":"./src/*.ts"}}});import*as eR from"fs/promises";import*as Nle from"path";function F4s(e,t){let n=(t.trim().toLowerCase().replace(/^\.+/,"")||"bin").replace(/[^a-z0-9]+/g,"_")||"bin",o=C9.version.replace(/[^a-z0-9]+/gi,"_"),i=new Bun.CryptoHasher("sha256").update(e).digest("hex");return`v${LFe}-${o}-${n}-${i}`}function oKr(e){return Nle.join(dYe(),`${e}.json`)}function O2(e){return e instanceof Error?e.message:String(e)}function rKr(e){let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;if(!("version"in t)||t.version!==LFe)return null;if(!("content"in t)||typeof t.content!=="string"||t.content.length===0)return null;return{version:LFe,content:t.content}}async function L4s(e){let t=oKr(e),s;try{s=await Bun.file(t).text()}catch(o){if(!ye(o))P.debug("document conversion cache read failed",{error:O2(o)});return{status:"miss"}}let n;try{n=rKr(s)}catch(o){P.debug("document conversion cache read failed",{error:O2(o)}),n=null}if(!n)return await eR.rm(t,{force:!0}).catch(()=>{return}),{status:"miss"};return{status:"hit",content:n.content}}async function iKr(e){let t;try{t=await eR.readdir(e)}catch(i){if(!ye(i))P.debug("document conversion cache prune failed",{error:O2(i)});return}let s=Date.now(),n=[],o=0;for(let i of t){let r=Nle.join(e,i),a;try{a=await eR.stat(r)}catch(l){if(!ye(l))P.debug("document conversion cache prune failed",{error:O2(l)});continue}if(!a.isFile())continue;if(i.endsWith(".tmp")){if(s-a.mtimeMs>nKr)await eR.rm(r,{force:!0}).catch(()=>{return});continue}if(!i.endsWith(".json"))continue;n.push({path:r,size:a.size,mtimeMs:a.mtimeMs}),o+=a.size}if(o<=_4s)return;n.sort((i,r)=>i.mtimeMs-r.mtimeMs);for(let i of n){if(o<=_4s)break;try{await eR.rm(i.path,{force:!0}),o-=i.size}catch(r){if(!ye(r))P.debug("document conversion cache prune failed",{error:O2(r)})}}}async function N4s(e,t){let s=dYe(),n=Nle.join(s,`${e}.json`),o=Nle.join(s,`${e}.${process.pid}.${Date.now()}.${crypto.randomUUID()}.tmp`),i=JSON.stringify({version:LFe,content:t});try{await eR.mkdir(s,{recursive:!0}),await Bun.write(o,i),await eR.rename(o,n)}catch(r){await eR.rm(o,{force:!0}).catch(()=>{return}),P.debug("document conversion cache write failed",{error:O2(r)});return}iKr(s).catch((r)=>{P.debug("document conversion cache prune failed",{error:O2(r)})})}var LFe=1,_4s=268435456,nKr=300000;var D4s=E(()=>{X();FFe()});var Q;var fi=E(()=>{Q=class Q extends Error{constructor(e){super(e);this.name="ArchiveError"}}});function Pn(e,t){return e[t]|e[t+1]<<8}function Ps(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function VE(e,t){let s=Ps(e,t)+Ps(e,t+4)*4294967296;if(!Number.isSafeInteger(s))throw new Q("Archive uses offsets or sizes too large to read safely");return s}function Dle(e,t){return e[t]<<8|e[t+1]}function TT(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Ud(e,t,s){e[t]=s&255,e[t+1]=s>>>8&255}function zl(e,t,s){e[t]=s&255,e[t+1]=s>>>8&255,e[t+2]=s>>>16&255,e[t+3]=s>>>24&255}function _2(e,t,s){zl(e,t,s>>>0),zl(e,t+4,Math.floor(s/4294967296))}function fc(e,t,s){if(e.byteLength<t+s.length)return!1;for(let n=0;n<s.length;n++)if(e[t+n]!==s.charCodeAt(n))return!1;return!0}var b9;var yT=E(()=>{fi();b9=new TextDecoder});function _f(e){if(!e)return"";let t=e.replace(/\\/g,"/").split("/"),s=[];for(let n of t){if(!n||n===".")continue;if(n==="..")return;s.push(n)}return s.join("/")}function Qr(e){let t=e.replace(/\\/g,"/").split("/"),s=[];for(let n of t){if(!n||n===".")continue;if(n==="..")return;s.push(n)}if(s.length===0)return;return s.join("/")}function U4s(e){return e.endsWith("/")||e.endsWith("\\")}function Dr(e){if(Buffer.byteLength(e,"utf-8")<=q4s)return e;let t=0,s=0;for(let n of e){let o=Buffer.byteLength(n,"utf-8");if(s+o>q4s-3)break;t+=n.length,s+=o}return`${e.slice(0,t)}...`}function No(e,t,s){if(e>s)throw new Q(`Archive ${t} exceeds ${s} bytes`)}function Ff(e,t,s){No(Buffer.byteLength(e,"utf-8"),t,s)}var q4s=256;var Lf=E(()=>{fi()});function Di(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Q("Archive is too large to read safely");if(e>t.maxInMemorySize)throw new Q(`Archive is too large to read in memory (${kt(e)} > ${kt(t.maxInMemorySize)} limit)`)}function Vn(e,t,s){if(!Number.isSafeInteger(e)||e<0)throw new Q(`Invalid archive: ${s} has an invalid size`);if(e>t.maxIndexSize)throw new Q(`Archive ${s} is too large (${kt(e)} > ${kt(t.maxIndexSize)} limit)`)}function Oa(e,t,s){if(!Number.isSafeInteger(e)||e<0)throw new Q(`Archive member '${Dr(t)}' has an invalid size`);if(e>s.maxMemberSize)throw new Q(`Archive member '${Dr(t)}' is too large to extract in memory (${kt(e)} > ${kt(s.maxMemberSize)} limit)`)}function xr(e,t){if(e>t.maxEntries)throw new Q(`Archive has too many entries (> ${t.maxEntries} limit)`)}var qle;var mc=E(()=>{fi();Lf();qle={maxEntries:1e6,maxInMemorySize:268435456,maxIndexSize:67108864,maxMemberSize:67108864,maxPathBytes:4096,maxLinkDepth:40}});function Xc(e,t){let s=e.get(t.path);if(!s)return e.set(t.path,t),t;if(s.isDirectory&&!t.isDirectory)return e.set(t.path,t),t;if(!s.isDirectory&&t.isDirectory)return;let n={...t,mtimeMs:t.mtimeMs??s.mtimeMs,mode:t.mode??s.mode,storage:t.storage??s.storage};return e.set(t.path,n),n}function iD(e,t){xr(e.size,t);for(let s of[...e.values()]){let n=s.path.split("/"),o=n.length-1;for(let i=1;i<=o;i++){let r=n.slice(0,i).join("/");if(!r||e.has(r))continue;e.set(r,{path:r,isDirectory:!0,size:0}),xr(e.size,t)}}}function F2(e,t,s){let n=t,o=new Set;for(let i=0;!o.has(n);){o.add(n);let r;for(let a=n.length;a>0;a=n.lastIndexOf("/",a-1)){let l=e.get(n.slice(0,a));if(l?.storage?.type!=="link"||!l.isDirectory&&!l.storage.resolveTarget)continue;let u=n.slice(a+1);r=u?l.storage.targetPath?`${l.storage.targetPath}/${u}`:u:l.storage.targetPath;break}if(r===void 0)return n;if(++i>s)break;n=r}throw new Q(`Archive path '${t}' crosses a cyclic symlink`)}var aD=E(()=>{fi();mc()});function aKr(e,t){throw new Q(`Archive symlink '${Dr(t)}' cannot be materialized from target '${Dr(e)}'`)}class mRt{format;limits;#e=new Map;constructor(e,t,s=qle){this.format=e,this.limits=s;for(let n of t)Xc(this.#e,n);iD(this.#e,s)}indexEntries(){return this.#e.values()}getNode(e){let t=_f(e);if(t===void 0)return;if(t==="")return{path:"",isDirectory:!0,size:0};let s=F2(this.#e,t,this.limits.maxLinkDepth);if(s==="")return{path:t,isDirectory:!0,size:0};let n=this.#e.get(s);if(!n)return;return{path:t,isDirectory:n.isDirectory,size:n.size,mtimeMs:n.mtimeMs,mode:n.mode}}listDirectory(e){let t=_f(e);if(t===void 0)throw new Q("Archive path cannot contain '..'");let s=t?F2(this.#e,t,this.limits.maxLinkDepth):"";if(t&&s!==""){let i=this.#e.get(s);if(!i)throw new Q(`Archive path '${t}' not found`);if(!i.isDirectory)throw new Q(`Archive path '${t}' is not a directory`)}let n=s?`${s}/`:"",o=new Map;for(let i of this.#e.values()){if(s){if(!i.path.startsWith(n)||i.path===s)continue}let r=s?i.path.slice(n.length):i.path,a=r.split("/")[0];if(!a)continue;let l=t?`${t}/${a}`:a;if(o.has(l))continue;let u=s?`${s}/${a}`:a,p=F2(this.#e,u,this.limits.maxLinkDepth),c=p?this.#e.get(p):void 0,d=p===""||c?.isDirectory===!0||r.includes("/");o.set(l,{name:a,path:l,isDirectory:d,size:d?0:c?.size??i.size,mtimeMs:c?.mtimeMs??i.mtimeMs,mode:c?.mode??i.mode})}return[...o.values()].sort((i,r)=>i.name.toLowerCase().localeCompare(r.name.toLowerCase()))}async readFile(e){let t=_f(e);if(!t)throw new Q("Archive file path is required");let s=F2(this.#e,t,this.limits.maxLinkDepth);if(s==="")throw new Q(`Archive path '${t}' is a directory`);let n=this.#e.get(s);if(!n)throw new Q(`Archive file '${t}' not found`);if(n.isDirectory)throw new Q(`Archive path '${t}' is a directory`);if(!n.storage)throw new Q(`Archive file '${t}' has no readable storage`);if(Oa(n.size,t,this.limits),n.storage.type==="link")aKr(n.storage.targetPath,t);let o=await n.storage.source.read(n.size,t);return{path:t,isDirectory:!1,size:n.size,mtimeMs:n.mtimeMs,mode:n.mode,bytes:o}}}var gRt=E(()=>{aD();fi();mc();Lf()});function Ca(e,t=0){return Bun.hash.crc32(e,t)>>>0}function W4s(e,t=0n){let s=t^0xffffffffffffffffn,n=Number(s&0xffffffffn)>>>0,o=Number(s>>32n&0xffffffffn)>>>0;for(let i=0;i<e.length;i++){let r=(n^e[i])&255;n=((n>>>8|(o&255)<<24)>>>0^H4s[r])>>>0,o=(o>>>8^B4s[r])>>>0}return(BigInt(o)<<32n|BigInt(n))^0xffffffffffffffffn}function S9(e,t=0){let s=t;for(let n=0;n<e.length;n++)s=(s>>>8^G4s[(s^e[n])&255])&65535;return s}var H4s,B4s,G4s;var uP=E(()=>{H4s=new Uint32Array(256),B4s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e,s=0;for(let n=0;n<8;n++){let o=(t&1)!==0;if(t=(t>>>1|(s&1)<<31)>>>0,s>>>=1,o)t=(t^3615952706)>>>0,s=(s^3379320725)>>>0}H4s[e]=t,B4s[e]=s}G4s=new Uint16Array(256);for(let e=0;e<256;e++){let t=e;for(let s=0;s<8;s++)t=(t&1)!==0?t>>>1^40961:t>>>1;G4s[e]=t}});function $4s(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<e)throw new Q("Invalid archive range")}function z4s(e,t,s){if($4s(t,s),s>e.byteLength)throw new Q("Invalid archive: truncated data");return e.subarray(t,s)}function NFe(e){return{size:e.byteLength,async read(t,s){return z4s(e,t,s)}}}function hRt(e){let t=Bun.file(e),s=t.size;if(!Number.isSafeInteger(s))throw new Q("Archive is too large to read safely");return{size:s,async read(n,o){$4s(n,o);let i=await t.slice(n,o).bytes();if(i.byteLength!==o-n)throw new Q("Invalid archive: truncated data");return i}}}async function KE(e){return e.read(0,e.size)}var YE=E(()=>{fi()});class yRt{#e;#t;#s=0;constructor(e,t){this.#e=e,this.#t=t}read(e){if(!Number.isInteger(e)||e<0||e>24||this.#s+e>this.#e.byteLength*8)throw new Q(`Invalid ${this.#t} compressed data: truncated bitstream`);let t=0;for(let s=0;s<e;s++){let n=this.#s++;t=t*2+(this.#e[n>>>3]>>>7-(n&7)&1)}return t}assertZeroPadding(){while(this.#s<this.#e.byteLength*8)if(this.read(1)!==0)throw new Q(`Invalid ${this.#t} compressed data: non-zero trailing bits`)}}class cP{#e=[-1];#t=[-1];#s=[-1];#n;constructor(e){this.#n=e}static single(e,t,s){if(!Number.isInteger(e)||e<0||e>=t)throw new Q(`Invalid ${s} Huffman table: symbol is out of range`);let n=new cP(s);return n.#s[0]=e,n}static build(e,t,s){let n=new Uint32Array(17),o=0;for(let l=0;l<t;l++){let u=e[l];if(u>16)throw new Q(`Invalid ${s} Huffman table: code is too long`);if(u!==0)n[u]++,o=Math.max(o,u)}if(o===0)throw new Q(`Invalid ${s} Huffman table: no symbols`);let i=new Uint32Array(17),r=0;for(let l=1;l<=16;l++){if(r=(r+n[l-1])*2,r+n[l]>2**l)throw new Q(`Invalid ${s} Huffman table: oversubscribed codes`);i[l]=r}if(i[o]+n[o]!==2**o)throw new Q(`Invalid ${s} Huffman table: incomplete codes`);let a=new cP(s);for(let l=0;l<t;l++){let u=e[l];if(u===0)continue;let p=i[u];i[u]=p+1;let c=0;for(let d=u-1;d>=0;d--){if(a.#s[c]>=0)throw new Q(`Invalid ${s} Huffman table: prefix collision`);let f=p>>>d&1,m=f===0?a.#e[c]:a.#t[c];if(m<0)if(m=a.#s.length,a.#e.push(-1),a.#t.push(-1),a.#s.push(-1),f===0)a.#e[c]=m;else a.#t[c]=m;c=m}if(a.#s[c]>=0||a.#e[c]>=0||a.#t[c]>=0)throw new Q(`Invalid ${s} Huffman table: duplicate code`);a.#s[c]=l}return a}decode(e){let t=0;for(let s=0;s<=16;s++){let n=this.#s[t];if(n>=0)return n;if(t=e.read(1)===0?this.#e[t]:this.#t[t],t<0)throw new Q(`Invalid ${this.#n} Huffman code`)}throw new Q(`Invalid ${this.#n} Huffman code: excessive depth`)}}function X4s(e,t){let s=e.read(3);if(s===7){while(e.read(1)!==0)if(s++,s>16)throw new Q(`Invalid ${t} Huffman table: code is too long`)}return s}function pKr(e,t){let n=e.read(5);if(n===0)return cP.single(e.read(5),19,t);if(n>19)throw new Q(`Invalid ${t} temporary Huffman table size`);let o=new Uint8Array(19),i=0;while(i<n)if(o[i++]=X4s(e,t),i===3){let r=e.read(2);if(i+r>n)throw new Q(`Invalid ${t} temporary Huffman table`);i+=r}return cP.build(o,19,t)}function cKr(e,t,s){let o=e.read(9);if(o===0)return cP.single(e.read(9),510,s);if(o>510)throw new Q(`Invalid ${s} command Huffman table size`);let i=new Uint8Array(510),r=0;while(r<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(r+l>o)throw new Q(`Invalid ${s} command Huffman table`);r+=l}else i[r++]=a-2}return cP.build(i,510,s)}function dKr(e,t,s,n){let o=e.read(t);if(o===0)return cP.single(e.read(t),s,n);if(o>s)throw new Q(`Invalid ${n} position Huffman table size`);let i=new Uint8Array(s);for(let r=0;r<o;r++)i[r]=X4s(e,n);return cP.build(i,s,n)}function k9(e,t,s,n,o,i){let r=new yRt(e,i),a=new Uint8Array(t),l=0,u=0,p,c;while(l<t){if(u===0){if(u=r.read(16),u===0)throw new Q(`Invalid ${i} compressed data: empty block`);let T=pKr(r,i);p=cKr(r,T,i),c=dKr(r,n,o,i)}u--;let d=p.decode(r);if(d<256){a[l++]=d;continue}let f=d-256+3;if(f>t-l)throw new Q(`Invalid ${i} compressed data: match exceeds declared size`);let m=c.decode(r),g=m;if(m>1){let T=m-1;g=2**T+r.read(T)}if(g>=s||g>=l)throw new Q(`Invalid ${i} 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 Q(`Invalid ${i} compressed data: block exceeds declared size`);return r.assertZeroPadding(),a}function fKr(e,t){let s=new yRt(e,"LZH -lzs-"),n=new Uint8Array(t),o=new Uint8Array(2048);o.fill(32);let i=2031,r=0,a=(l)=>{if(r>=t)throw new Q("Invalid LZH -lzs- data: output exceeds declared size");n[r++]=l,o[i]=l,i=i+1&2047};while(r<t)if(s.read(1)!==0)a(s.read(8));else{let l=s.read(11),u=s.read(4)+2;if(u>t-r)throw new Q("Invalid LZH -lzs- data: match exceeds declared size");for(let p=0;p<u;p++)a(o[l+p&2047])}return s.assertZeroPadding(),n}function gKr(e,t,s){if(t<0)return S9(e);let n=S9(e.subarray(0,t));return n=S9(mKr.subarray(0,s-t),n),S9(e.subarray(s),n)}function pP(e,t){return e[t]|e[t+1]<<8}function XE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function j4s(e,t){let s=XE(e,t)+XE(e,t+4)*4294967296;if(!Number.isSafeInteger(s))throw new Q("LZH uses sizes too large to read safely");return s}function Ule(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.byteLength)throw new Q(`Invalid LZH archive: truncated ${n}`)}function TRt(e){let t=e.indexOf(0);if(t<0)t=e.byteLength;return lKr.decode(e.subarray(0,t))}function V4s(e){if((e.byteLength&1)!==0)throw new Q("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 uKr.decode(e.subarray(0,t))}function hKr(e){if(e===0)return;let t=1980+(e>>>25&127),s=e>>>21&15,n=e>>>16&31,o=e>>>11&31,i=e>>>5&63,r=(e&31)*2;if(s<1||s>12||n<1||n>31||o>23||i>59||r>59)return;return Date.UTC(t,s-1,n,o,i,r)}function K4s(e,t,s,n){switch(e){case 0:if(t.byteLength<2)throw new Q("Invalid LZH common extended header");n.commonCrc=pP(t,0),n.commonCrcOffset=s;break;case 1:n.filename=TRt(t);break;case 2:n.directory=TRt(t).replaceAll("\xFF","/");break;case 57:throw new Q("Multi-volume LZH archives are unsupported");case 65:if(t.byteLength>=16){let o=XE(t,8),i=XE(t,12),r=o+i*4294967296;if(Number.isSafeInteger(r))n.mtimeMs=r/1e4-11644473600000}break;case 66:if(t.byteLength<16)throw new Q("Invalid LZH 64-bit size extended header");n.packedSize=j4s(t,0),n.size=j4s(t,8);break;case 68:n.unicodeFilename=V4s(t);break;case 69:n.unicodeDirectory=V4s(t).replaceAll("\xFF","/");break;case 80:if(t.byteLength<2)throw new Q("Invalid LZH Unix permissions extended header");n.mode=pP(t,0);break;case 84:if(t.byteLength<4)throw new Q("Invalid LZH Unix timestamp extended header");n.mtimeMs=XE(t,0)*1000;break}}class J4s{#e;#t;#s;#n;#o;constructor(e,t,s,n,o){this.#e=e,this.#t=t,this.#s=s,this.#n=n,this.#o=o}async read(e,t){let s=this.#e.subarray(this.#t,this.#t+this.#s),n;switch(this.#n){case"-lh0-":case"-lz4-":if(s.byteLength!==e)throw new Q(`LZH member '${t}' has inconsistent stored size`);n=s.slice();break;case"-lh4-":n=k9(s,e,4096,4,13,"LZH -lh4-");break;case"-lh5-":n=k9(s,e,8192,4,14,"LZH -lh5-");break;case"-lh6-":n=k9(s,e,32768,5,16,"LZH -lh6-");break;case"-lh7-":n=k9(s,e,65536,5,17,"LZH -lh7-");break;case"-lzs-":n=fKr(s,e);break;case"-lh1-":throw new Q(`LZH member '${t}' uses unsupported dynamic-Huffman method -lh1-`);default:throw new Q(`LZH member '${t}' uses unsupported compression method ${this.#n}`)}if(n.byteLength!==e)throw new Q(`LZH member '${t}' extracted to an unexpected size`);if(S9(n)!==this.#o)throw new Q(`LZH member '${t}' failed CRC-16 verification`);return n}}function TKr(e,t,s){Ule(e,t,t+22,"header");let n=e[t+20];if(n>2)throw new Q(`Unsupported LZH header level ${n}`);let o=String.fromCharCode(...e.subarray(t+2,t+7));if(!Y4s.test(o))throw new Q(`Invalid LZH compression method '${o}'`);let i=XE(e,t+7),r=XE(e,t+11),a=0,l,u,p=0,c,d={};if(n<2){let T=e[t];if(T<(n===0?22:25))throw new Q(`Invalid LZH level-${n} header size`);let C=t+T+2;Ule(e,t,C,"header");let w=0;for(let A=t+2;A<C;A++)w=w+e[A]&255;if(w!==e[t+1])throw new Q("Invalid LZH header checksum");let x=e[t+21];if(22+x+2>T+2)throw new Q("Invalid LZH filename length");if(No(x,"member path",s.limits.maxPathBytes),l=TRt(e.subarray(t+22,t+22+x)),a=pP(e,t+22+x),u=hKr(XE(e,t+15)),n===0){let A=t+24+x;if(C-A>=12){let I=e.subarray(A,C);if((I[0]===85||I[0]===75)&&I[1]===0)p=I[0],d.mtimeMs=XE(I,2)*1000,d.mode=pP(I,I.byteLength-6)}c=C}else{p=e[t+24+x];let A=pP(e,C-2),I=C,M=0,O=0;while(A!==0){if(A<3)throw new Q("Invalid LZH extended header size");if(Ule(e,I,I+A,"extended header"),M+=A,Vn(T+2+M,s.limits,"header metadata"),++O>65535)throw new Q("Invalid LZH archive: too many extended headers");let _=e[I],F=I+A-2,L=e.subarray(I+1,F);if(_===1||_===2||_===68||_===69)No(L.byteLength,"member path",s.limits.maxPathBytes);K4s(_,L,I+1,d);let D=A;A=pP(e,F),I+=D}if(c=C+M,i=d.packedSize??i-M,i<0)throw new Q("Invalid LZH level-1 packed size")}}else{let T=pP(e,t);if(T<26)throw new Q("Invalid LZH level-2 header size");let R=t+T;Ule(e,t,R,"header"),a=pP(e,t+21),p=e[t+23],u=XE(e,t+15)*1000;let C=t+24,w=0;while(C+2<=R){let x=pP(e,C);if(x===0){C+=2;break}if(x<3||C+x>R)throw new Q("Invalid LZH extended header size");if(++w>65535)throw new Q("Invalid LZH archive: too many extended headers");let A=e[C+2],I=e.subarray(C+3,C+x);if(A===1||A===2||A===68||A===69)No(I.byteLength,"member path",s.limits.maxPathBytes);K4s(A,I,C+3,d),C+=x}if(C!==R)throw new Q("Invalid LZH level-2 extended header chain");c=R,i=d.packedSize??i}if(n===1&&p===32&&o==="-lh7-")throw new Q("LZH uses the incompatible LHARK -lh7- variant");r=d.size??r,u=d.mtimeMs??u;let f=d.mode;if(d.commonCrc!==void 0){let T=d.commonCrcOffset-t;if(gKr(e.subarray(t,c),T,T+2)!==d.commonCrc)throw new Q("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 Ff(h,"member path",s.limits.maxPathBytes),Oa(r,h||"<unnamed>",s.limits),Ule(e,c,c+i,"member data"),{method:o,packedSize:i,size:r,dataStart:c,nextOffset:c+i,crc:a,path:Qr(h),mtimeMs:u,mode:f}}function RRt(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 Y4s.test(t)&&e[20]<=2}var lKr,uKr,Y4s,mKr,Q4s=async(e,t)=>{Di(e.size,t.limits);let s;try{s=await KE(e)}catch(a){if(a instanceof Q)throw a;throw new Q(`Unable to read LZH archive: ${a instanceof Error?a.message:String(a)}`)}if(s.byteLength!==e.size)throw new Q("Invalid LZH archive: truncated data");if(!RRt(s))throw new Q("Invalid LZH archive header");let n=[],o=0,i=0,r=0;while(o<s.byteLength&&s[o]!==0){let a=TKr(s,o,t);if(r+=a.dataStart-o,Vn(r,t.limits,"index"),xr(++i,t.limits),a.nextOffset<=o)throw new Q("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 Q(`Invalid LZH symbolic link '${a.path}'`);let p=Qr(a.path.slice(0,u)),c=Qr(a.path.slice(u+1));if(!p||!c)continue;n.push({path:p,isDirectory:!1,size:0,mtimeMs:a.mtimeMs,mode:a.mode,storage:{type:"link",targetPath:c,resolveTarget:!1}});continue}n.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 J4s(s,a.dataStart,a.packedSize,a.method,a.crc)}})}if(n.length===0&&i===0)throw new Q("Invalid LZH archive: no members");return n};var CRt=E(()=>{uP();fi();mc();Lf();YE();lKr=new TextDecoder("windows-1252"),uKr=new TextDecoder("utf-16"),Y4s=/^-(?:lh[0-7d]|lz[45s])-$/;mKr=new Uint8Array(2)});function DFe(e,t){return e[t]|e[t+1]<<8}function L2(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Hle(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.byteLength)throw new Q(`Invalid ARJ archive: truncated ${n}`)}function RKr(e){if(e===0)return;let t=1980+(e>>>25&127),s=e>>>21&15,n=e>>>16&31,o=e>>>11&31,i=e>>>5&63,r=(e&31)*2;if(s<1||s>12||n<1||n>31||o>23||i>59||r>59)return;return Date.UTC(t,s-1,n,o,i,r)}function Z4s(e,t,s,n){let o=t;while(o<s&&e[o]!==0)o++;if(o===s)throw new Q(`Invalid ARJ ${n}: missing terminator`);return{value:yKr.decode(e.subarray(t,o)),next:o+1}}function eVs(e,t,s){if(Hle(e,t,t+4,"header signature"),e[t]!==tVs||e[t+1]!==sVs)throw new Q("Invalid ARJ header signature");let n=DFe(e,t+2);if(n===0)return{bodyStart:t+4,bodySize:0,nextOffset:t+4,metadataSize:4,isEnd:!0};if(n<30||n>nVs)throw new Q("Invalid ARJ basic header size");let o=t+4,i=o+n;if(Hle(e,o,i+4,"basic header"),Ca(e.subarray(o,i))!==L2(e,i))throw new Q("Invalid ARJ basic header CRC32");let r=i+4,a=0;for(;;){Hle(e,r,r+2,"extended header size");let l=DFe(e,r);if(r+=2,l===0)break;if(++a>65535)throw new Q("Invalid ARJ archive: too many extended headers");if(Hle(e,r,r+l+4,"extended header"),Ca(e.subarray(r,r+l))!==L2(e,r+l))throw new Q("Invalid ARJ extended header CRC32");r+=l+4,Vn(r-t,s.limits,"header metadata")}return{bodyStart:o,bodySize:n,nextOffset:r,metadataSize:r-t,isEnd:!1}}class oVs{#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 Q("Invalid ARJ method-4 compressed data: truncated bitstream");let t=0;for(let s=0;s<e;s++){let n=this.#t++;t=t*2+(this.#e[n>>>3]>>>7-(n&7)&1)}return t}assertZeroPadding(){while(this.#t<this.#e.byteLength*8)if(this.read(1)!==0)throw new Q("Invalid ARJ method-4 compressed data: non-zero trailing bits")}}function CKr(e,t){let s=new oVs(e),n=new Uint8Array(t),o=0;while(o<t){let i=0,r=0;for(;r<7;r++){if(s.read(1)===0)break;i+=2**r}if(r!==0)i+=s.read(r);if(i===0){n[o++]=s.read(8);continue}let a=i+2;if(a>t-o)throw new Q("Invalid ARJ method-4 compressed data: match exceeds declared size");let l=0,u=9;for(;u<13;u++){if(s.read(1)===0)break;l+=2**u}if(l+=s.read(u),l>=26624||l>=o)throw new Q("Invalid ARJ method-4 compressed data: history distance is out of range");let p=o-l-1;for(let c=0;c<a;c++)n[o++]=n[p++]}return s.assertZeroPadding(),n}class rVs{#e;#t;#s;#n;#o;constructor(e,t,s,n,o){this.#e=e,this.#t=t,this.#s=s,this.#n=n,this.#o=o}async read(e,t){let s=this.#e.subarray(this.#t,this.#t+this.#s),n;switch(this.#n){case 0:if(s.byteLength!==e)throw new Q(`ARJ member '${t}' has inconsistent stored size`);n=s.slice();break;case 1:case 2:case 3:n=k9(s,e,26624,5,17,`ARJ method ${this.#n}`);break;case 4:n=CKr(s,e);break;case 8:case 9:if(e!==0||s.byteLength!==0)throw new Q(`ARJ member '${t}' has invalid no-data method sizes`);n=new Uint8Array(0);break;default:throw new Q(`ARJ member '${t}' uses unsupported compression method ${this.#n}`)}if(n.byteLength!==e)throw new Q(`ARJ member '${t}' extracted to an unexpected size`);if(this.#n!==8&&Ca(n)!==this.#o)throw new Q(`ARJ member '${t}' failed CRC32 verification`);return n}}function bKr(e,t){let s=e.replaceAll("\\","/");if(t===1)s=s.replaceAll(">","/");else if(t===4)s=s.replaceAll(":","/");return s}function bRt(e){if(e.byteLength<34||e[0]!==tVs||e[1]!==sVs)return!1;let t=DFe(e,2);if(t<30||t>nVs||e.byteLength<t+8)return!1;let s=e.subarray(4,4+t);return s[0]>=30&&s[0]<=t&&s[6]===2&&Ca(s)===L2(e,4+t)}var tVs=96,sVs=234,nVs=2600,yKr,iVs=async(e,t)=>{Di(e.size,t.limits);let s;try{s=await KE(e)}catch(p){if(p instanceof Q)throw p;throw new Q(`Unable to read ARJ archive: ${p instanceof Error?p.message:String(p)}`)}if(s.byteLength!==e.size)throw new Q("Invalid ARJ archive: truncated data");if(!bRt(s))throw new Q("Invalid ARJ archive header");let n=eVs(s,0,t);if(n.isEnd)throw new Q("Invalid ARJ archive: missing main header");let o=s[n.bodyStart];if(o<30||o>n.bodySize||s[n.bodyStart+6]!==2)throw new Q("Invalid ARJ main header");let i=s[n.bodyStart+4];if((i&1)!==0)throw new Q("Encrypted ARJ archives are unsupported");if((i&4)!==0)throw new Q("Multi-volume ARJ archives are unsupported");let r=[],a=n.nextOffset,l=n.metadataSize,u=0;for(;;){let p=eVs(s,a,t);if(l+=p.metadataSize,Vn(l,t.limits,"index"),p.isEnd)break;xr(++u,t.limits);let c=s[p.bodyStart];if(c<30||c>p.bodySize)throw new Q("Invalid ARJ local header");let d=s[p.bodyStart+3],f=s[p.bodyStart+4],m=s[p.bodyStart+5],g=s[p.bodyStart+6];if((f&1)!==0)throw new Q("Encrypted ARJ members are unsupported");if((f&12)!==0)throw new Q("Multi-volume ARJ members are unsupported");let h=L2(s,p.bodyStart+12),T=L2(s,p.bodyStart+16),R=L2(s,p.bodyStart+20),C=DFe(s,p.bodyStart+26),w=Z4s(s,p.bodyStart+c,p.bodyStart+p.bodySize,"filename");Z4s(s,w.next,p.bodyStart+p.bodySize,"comment"),No(w.next-(p.bodyStart+c)-1,"member path",t.limits.maxPathBytes);let x=bKr(w.value,d);Ff(x,"member path",t.limits.maxPathBytes),Oa(T,x||"<unnamed>",t.limits);let A=p.nextOffset;Hle(s,A,A+h,"member data"),a=A+h;let I=Qr(x);if(!I)continue;let M=g===3,O;if((d===2||d===8)&&C!==0)O=(M?16384:32768)|C&4095;let _=L2(s,p.bodyStart+8),F=d===2||d===8?_===0?void 0:_*1000:RKr(_);r.push({path:I,isDirectory:M,size:M?0:T,mtimeMs:F,mode:O,storage:M?void 0:{type:"member",source:new rVs(s,A,h,m,R)}})}if(u===0)throw new Q("Invalid ARJ archive: no members");return r};var aVs=E(()=>{uP();fi();mc();CRt();Lf();YE();yKr=new TextDecoder("windows-1252")});import*as uVs from"path";function na(e){return new Q(`Invalid ASAR archive: ${e}`)}function UFe(e){return e instanceof Error&&e.message?e.message:String(e)}function SRt(e){return e+(4-e%4)%4}function Ble(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function xKr(e,t,s){if(e===void 0)return;let n=Dr(t);if(!Ble(e))throw na(`file '${n}' has an invalid integrity record`);if(e.algorithm!=="SHA256")throw na(`file '${n}' uses unsupported integrity algorithm '${String(e.algorithm)}'`);if(typeof e.hash!=="string"||!lVs.test(e.hash))throw na(`file '${n}' has an invalid integrity hash`);if(typeof e.blockSize!=="number"||!Number.isSafeInteger(e.blockSize)||e.blockSize<=0)throw na(`file '${n}' has an invalid integrity block size`);if(!Array.isArray(e.blocks))throw na(`file '${n}' has invalid integrity blocks`);let o=Math.max(1,Math.ceil(s/e.blockSize));if(e.blocks.length!==o)throw na(`file '${n}' has an inconsistent integrity block count`);for(let i of e.blocks)if(typeof i!=="string"||!lVs.test(i))throw na(`file '${n}' has an invalid integrity block hash`);return{algorithm:"SHA256",hash:e.hash.toLowerCase()}}function pVs(e,t,s){if(!t)return;if(new Bun.CryptoHasher("sha256").update(e).digest("hex")!==t.hash)throw new Q(`ASAR member '${Dr(s)}' failed SHA256 integrity verification`)}class cVs{#e;#t;#s;#n;constructor(e,t,s,n){this.#e=e,this.#t=t,this.#s=s,this.#n=n}async read(e,t){if(e!==this.#s)throw new Q(`ASAR member '${Dr(t)}' has an inconsistent size`);let s;try{s=await this.#e.read(this.#t,this.#t+this.#s)}catch(n){if(n instanceof Q)throw n;throw new Q(`Failed to read ASAR member '${Dr(t)}': ${UFe(n)}`)}if(s.byteLength!==this.#s)throw new Q(`ASAR member '${Dr(t)}' is truncated`);return pVs(s,this.#n,t),s}}class dVs{#e;#t;#s;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}async read(e,t){let s=Dr(t);if(e!==this.#t)throw new Q(`ASAR member '${s}' has an inconsistent size`);if(!this.#e)throw new Q(`Archive file '${s}' is unpacked and requires a filesystem-backed ASAR archive`);let n=Bun.file(this.#e),o=await n.stat().catch(()=>{throw new Q(`Unpacked ASAR file '${s}' was not found`)});if(o.isDirectory())throw new Q(`Unpacked ASAR file '${s}' is a directory`);if(o.size!==this.#t)throw new Q(`Unpacked ASAR file '${s}' size differs from its archive header (${o.size} != ${this.#t} bytes)`);let i;try{i=await n.bytes()}catch(r){throw new Q(`Failed to read unpacked ASAR file '${s}': ${UFe(r)}`)}if(i.byteLength!==this.#t)throw new Q(`Unpacked ASAR file '${s}' changed while being read`);return pVs(i,this.#s,t),i}}async function vKr(e,t){if(!Number.isSafeInteger(e.size)||e.size<qFe)throw na("truncated header");let s=await e.read(0,w9);if(s.byteLength!==w9)throw na("truncated size pickle");if(Ps(s,0)!==4)throw na("invalid size pickle");let n=Ps(s,4);if(n<Wle)throw na("header is too small");Vn(n,t.limits,"ASAR header");let o=w9+n;if(!Number.isSafeInteger(o)||o>e.size)throw na("header extends beyond archive boundary");let i=await e.read(w9,o);if(i.byteLength!==n)throw na("truncated header pickle");let r=Ps(i,0),a=Ps(i,4);if(r+4!==n||r!==4+SRt(a))throw na("inconsistent pickle lengths");let l=Wle+a;for(let g=l;g<i.byteLength;g++)if(i[g]!==0)throw na("non-zero pickle string padding");let u;try{u=SKr.decode(i.subarray(Wle,l))}catch{throw na("header is not valid UTF-8")}let p;try{p=JSON.parse(u)}catch{throw na("header is not valid JSON")}if(!Ble(p)||!Ble(p.files))throw na("root must contain a files object");let c=[],d=[],f=0,m=(g,h,T)=>{for(let R in g)xr(++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(No(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 na(`invalid entry name '${Dr(g.name)}'`);if(!Ble(g.node))throw na(`entry '${Dr(g.name)}' must be an object`);let T=g.parentPathBytes+(g.parentPath?1:0)+h;No(T,"member path",t.limits.maxPathBytes);let R=g.parentPath?`${g.parentPath}/${g.name}`:g.name;if(Qr(R)!==R)throw na(`invalid entry path '${Dr(R)}'`);let w=Dr(R);if(g.node.unpacked!==void 0&&typeof g.node.unpacked!=="boolean")throw na(`entry '${w}' has a non-boolean unpacked flag`);if("link"in g.node){if(typeof g.node.link!=="string"||g.node.link.length===0)throw na(`entry '${w}' has an invalid link target`);Ff(g.node.link,"link target",t.limits.maxPathBytes);let F=g.node.link.replace(/\\/g,"/"),L=F.startsWith("/")||/^[A-Za-z]:\//.test(F)?void 0:_f(F);if(L===void 0)throw na(`entry '${w}' links outside the archive`);c.push({path:R,isDirectory:!1,size:0,storage:{type:"link",targetPath:L,resolveTarget:!0}});continue}if("files"in g.node){if(!Ble(g.node.files))throw na(`directory '${w}' must contain a files object`);c.push({path:R,isDirectory:!0,size:0}),m(g.node.files,R,T);continue}let x=g.node.size;if(typeof x!=="number"||!Number.isSafeInteger(x)||x<0)throw na(`file '${w}' has an invalid size`);if(Oa(x,R,t.limits),g.node.executable!==void 0&&typeof g.node.executable!=="boolean")throw na(`file '${w}' has a non-boolean executable flag`);let A=typeof g.node.executable==="boolean"?wKr|(g.node.executable?493:420):void 0,I=xKr(g.node.integrity,R,x);if(g.node.unpacked===!0){let F=t.archivePath?uVs.join(`${t.archivePath}.unpacked`,...R.split("/")):void 0;c.push({path:R,isDirectory:!1,size:x,mode:A,storage:{type:"member",source:new dVs(F,x,I)}});continue}if(typeof g.node.offset!=="string"||!/^\d+$/.test(g.node.offset))throw na(`file '${w}' has an invalid offset`);let M=Number(g.node.offset),O=o+M,_=O+x;if(!Number.isSafeInteger(M)||!Number.isSafeInteger(O)||!Number.isSafeInteger(_)||_>e.size)throw na(`file '${w}' extends beyond archive boundary`);c.push({path:R,isDirectory:!1,size:x,mode:A,storage:{type:"member",source:new cVs(e,O,x,I)}})}return c}function mVs(e){if(e.byteLength<qFe+1)return!1;let t=Ps(e,0),s=Ps(e,4),n=Ps(e,8),o=Ps(e,12);return t===4&&s>=Wle&&s===n+4&&n===4+SRt(o)&&o>0&&e[qFe]===123}function EKr(e){let t=e.replace(/\\/g,"/"),s=Qr(t);if(s===void 0||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.includes("\x00")||t.split("/").some((n)=>!n||n==="."||n===".."))throw new Q(`Invalid ASAR member path '${Dr(e)}'`);return s}async function gVs(e){try{let t={files:Object.create(null)},s=[],n=0;for(let d of e){if(!Array.isArray(d)||d.length!==2||typeof d[0]!=="string"||!(d[1]instanceof Uint8Array))throw new Q("ASAR members must be [path, Uint8Array] pairs");let f=EKr(d[0]),m=f.split("/"),g=t;for(let T=0;T<m.length-1;T++){let R=m[T],C=g.files[R];if(C&&!("files"in C))throw new Q(`ASAR member path '${f}' crosses file '${m.slice(0,T+1).join("/")}'`);if(!C)g.files[R]={files:Object.create(null)};g=g.files[R]}let h=m.at(-1);if(g.files[h])throw new Q(`Duplicate or conflicting ASAR member path '${f}'`);if(!Number.isSafeInteger(d[1].byteLength)||!Number.isSafeInteger(n+d[1].byteLength))throw new Q("ASAR payload is too large to encode safely");g.files[h]={size:d[1].byteLength,offset:String(n)},s.push(d[1]),n+=d[1].byteLength}let o=kKr.encode(JSON.stringify(t)),r=4+SRt(o.byteLength),a=4+r;if(o.byteLength>4294967295||a>4294967295)throw new Q("ASAR header is too large to encode");let l=w9+a,u=l+n;if(!Number.isSafeInteger(u))throw new Q("ASAR archive is too large to encode safely");let p;try{p=new Uint8Array(u)}catch{throw new Q("ASAR archive is too large to encode in memory")}zl(p,0,4),zl(p,4,a),zl(p,8,r),zl(p,12,o.byteLength),p.set(o,qFe);let c=l;for(let d of s)p.set(d,c),c+=d.byteLength;return p}catch(t){if(t instanceof Q)throw t;throw new Q(`Failed to encode ASAR archive: ${UFe(t)}`)}}var SKr,kKr,w9=8,Wle=8,qFe,wKr=32768,lVs,fVs=async(e,t)=>{try{return await vKr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(`Failed to read ASAR archive: ${UFe(s)}`)}};var kRt=E(()=>{yT();fi();mc();Lf();SKr=new TextDecoder("utf-8",{fatal:!0}),kKr=new TextEncoder,qFe=w9+Wle,lVs=/^[0-9a-f]{64}$/i});class yVs{#e;#t=0;#s=0;#n=0;constructor(e){this.#e=e}readBits(e){let t=0,s=e;while(s>0){if(this.#n===0){if(this.#t+2>this.#e.byteLength)throw new Q("Invalid CAB archive: truncated LZX bitstream");this.#s=this.#e[this.#t]|this.#e[this.#t+1]<<8,this.#t+=2,this.#n=16}let n=Math.min(s,this.#n);t=t*2**n+(this.#s>>>this.#n-n&2**n-1),this.#n-=n,s-=n}return t}alignWord(){this.#n=0}readByte(){if(this.#n!==0)throw new Q("Invalid CAB archive: misaligned LZX byte stream");if(this.#t>=this.#e.byteLength)throw new Q("Invalid CAB archive: truncated LZX data");return this.#e[this.#t++]}readUInt32LE(){let e=this.readByte(),t=this.readByte(),s=this.readByte(),n=this.readByte();return(e|t<<8|s<<16|n<<24)>>>0}}class Gle{#e=new Uint32Array(17);#t=new Uint32Array(17);#s=new Uint32Array(17);#n;empty;constructor(e,t=!1){let s=0;for(let r of e){if(r>16)throw new Q("Invalid CAB archive: invalid LZX Huffman code length");if(r!==0)this.#e[r]++,s++}if(this.empty=s===0,this.empty&&!t)throw new Q("Invalid CAB archive: empty LZX Huffman tree");let n=0,o=0;for(let r=1;r<=16;r++){if(n=(n+this.#e[r-1])*2,n+this.#e[r]>2**r)throw new Q("Invalid CAB archive: oversubscribed LZX Huffman tree");this.#t[r]=n,this.#s[r]=o,o+=this.#e[r]}this.#n=new Uint16Array(s);let i=this.#s.slice();for(let r=0;r<e.byteLength;r++){let a=e[r];if(a!==0)this.#n[i[a]]=r;i[a]++}}decode(e){if(this.empty)throw new Q("Invalid CAB archive: LZX stream uses an empty Huffman tree");let t=0;for(let s=1;s<=16;s++){t=t*2+e.readBits(1);let n=t-this.#t[s];if(n>=0&&n<this.#e[s])return this.#n[this.#s[s]+n]}throw new Q("Invalid CAB archive: invalid LZX Huffman symbol")}}function wRt(e,t,s,n){let o=new Uint8Array(20);for(let a=0;a<o.byteLength;a++)o[a]=e.readBits(4);let i=new Gle(o),r=s;while(r<n){let a=i.decode(e);if(a===17||a===18){let l=e.readBits(a===17?4:5)+(a===17?4:20);if(r+l>n)throw new Q("Invalid CAB archive: LZX code-length run exceeds its tree");t.fill(0,r,r+l),r+=l;continue}if(a===19){let l=e.readBits(1)+4;if(r+l>n)throw new Q("Invalid CAB archive: LZX code-length run exceeds its tree");let u=i.decode(e),p=(t[r]-u+17)%17;t.fill(p,r,r+l),r+=l;continue}t[r]=(t[r]-a+17)%17,r++}}function TVs(e){return e>2147483647?e-4294967296:e}class xRt{#e;#t;#s;#n;#o=new Uint8Array(IKr);#r;#a;#i;#l=0;#u=0;#p=0;#c=1;#d=1;#f=1;#m=!1;#g=0;#h=!1;#T=0;#y=0;#C=0;#R=!1;constructor(e){if(!Number.isInteger(e)||e<15||e>21)throw new Q(`Unsupported CAB LZX window size: ${e} bits (expected 15-21)`);this.#e=new Uint8Array(2**e);let t=PKr[e-15];this.#n=new Uint8Array(256+t*8),this.#s=new Uint8Array(t),this.#t=new Uint32Array(t);for(let s=0;s<t;s++)if(this.#s[s]=s<4?0:Math.min(17,Math.floor(s/2)-1),s>0)this.#t[s]=this.#t[s-1]+2**this.#s[s-1]}decompressFrame(e,t){if(!Number.isInteger(t)||t<0||t>AKr)throw new Q(`Invalid CAB archive: LZX frame size ${t} exceeds 32768 bytes`);if(t===0)return new Uint8Array(0);let s=new yVs(e);if(!this.#m){if(s.readBits(1)!==0){let r=s.readBits(16),a=s.readBits(16);this.#g=TVs(r*65536+a>>>0)}this.#m=!0}let n=new Uint8Array(t),o=0;while(o<t){if(this.#C===0)this.#S(s);let r=Math.min(this.#C,t-o),a=this.#k(s,n,o,r);if(a!==r)throw new Q("Invalid CAB archive: LZX block produced the wrong byte count");o+=a,this.#C-=a}if(this.#C===0&&this.#T===3&&this.#R)s.readByte(),this.#R=!1;s.alignWord();let i=this.#x(n);return this.#p++,i}#S(e){if(this.#T===3&&this.#R)e.readByte();if(this.#R=!1,this.#T=e.readBits(3),this.#y=e.readBits(16)*256+e.readBits(8),this.#y===0)throw new Q("Invalid CAB archive: zero-length LZX block");if(this.#C=this.#y,this.#T===1||this.#T===2){if(this.#T===2){let t=new Uint8Array(8);for(let s=0;s<t.byteLength;s++)t[s]=e.readBits(3);this.#i=new Gle(t)}if(wRt(e,this.#n,0,256),wRt(e,this.#n,256,this.#n.byteLength),this.#r=new Gle(this.#n),this.#n[232]!==0)this.#h=!0;wRt(e,this.#o,0,this.#o.byteLength),this.#a=new Gle(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 Q("Invalid CAB archive: invalid LZX repeated offset");this.#R=(this.#y&1)!==0;return}throw new Q(`Invalid CAB archive: unsupported LZX block type ${this.#T}`)}#k(e,t,s,n){if(this.#T===3){for(let i=0;i<n;i++)this.#b(e.readByte(),t,s+i);return n}if(!this.#r||!this.#a)throw new Q("Invalid CAB archive: missing LZX decode trees");let o=0;while(o<n){let i=this.#r.decode(e);if(i<256){this.#b(i,t,s+o),o++;continue}let r=i-256,a=r&hVs;if(a===hVs)a+=this.#a.decode(e);if(a+=MKr,a>n-o||a>this.#C-o)throw new Q("Invalid CAB archive: LZX match crosses a frame or block boundary");let l=r>>>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 Q("Invalid CAB archive: LZX position slot is out of range");let p=this.#s[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 Q("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 Q("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.#b(this.#e[c],t,s+o+p)}o+=a}return o}#b(e,t,s){t[s]=e,this.#e[this.#l]=e,this.#l=(this.#l+1)%this.#e.byteLength,this.#u++}#x(e){if(!this.#h||this.#g===0||this.#p>=32768||e.byteLength<=10)return e;let t=e.slice(),s=0,n=this.#u-e.byteLength,o=t.byteLength-10;while(s<o){if(t[s++]!==232){n++;continue}let i=TVs((t[s]|t[s+1]<<8|t[s+2]<<16|t[s+3]<<24)>>>0);if(i>=-n&&i<this.#g){let r=i>=0?i-n:i+this.#g;t[s]=r&255,t[s+1]=r>>>8&255,t[s+2]=r>>>16&255,t[s+3]=r>>>24&255}s+=4,n+=5}return t}}var AKr=32768,MKr=2,hVs=7,IKr=249,PKr;var RVs=E(()=>{fi();PKr=[30,32,34,36,38,42,50]});import*as SVs from"zlib";async function $le(e,t,s,n=e.size){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>n)throw new Q("Invalid CAB archive: metadata range is out of bounds");let o;try{o=await e.read(t,s)}catch(i){if(i instanceof Q)throw i;throw new Q(`Unable to read CAB archive: ${i instanceof Error?i.message:String(i)}`)}if(o.byteLength!==s-t)throw new Q("Invalid CAB archive: truncated data");return o}function kVs(e){return e.byteLength>=4&&e[0]===77&&e[1]===83&&e[2]===67&&e[3]===70}function bVs(e,t=0){let s=t>>>0,n=0;while(n+4<=e.byteLength)s^=Ps(e,n),n+=4;let o=e.byteLength-n,i=0;if(o===3)i=e[n]<<16|e[n+1]<<8|e[n+2];else if(o===2)i=e[n]<<8|e[n+1];else if(o===1)i=e[n];return(s^i)>>>0}function UKr(e,t){try{return t?DKr.decode(e):qKr.decode(e)}catch{throw new Q("Invalid CAB archive: file name is not valid UTF-8")}}function HKr(e,t){if(e===0&&t===0)return;let s=1980+(e>>>9),n=e>>>5&15,o=e&31,i=t>>>11,r=t>>>5&63,a=(t&31)*2;if(n<1||n>12||o<1||o>31||i>23||r>59||a>59)throw new Q("Invalid CAB archive: file has an invalid DOS timestamp");return new Date(s,n-1,o,i,r,a).getTime()}function BKr(e,t){if(t)return 16877;let s=e&_Kr?292:420;if(e&LKr)s|=73;return 32768|s}class wVs{#e;#t;#s;#n;#o;constructor(e,t,s,n){this.#e=e,this.#t=t,this.#s=s,this.#n=n}readAll(){return this.#o??=this.#r(),this.#o}async#r(){let e=this.#t;if(e.method===2)throw new Q(`Unsupported CAB compression method: Quantum (level ${e.parameter})`);if(e.method>3)throw new Q(`Unsupported CAB compression method: ${e.method}`);if(e.method===3&&(e.parameter<15||e.parameter>21))throw new Q(`Unsupported CAB LZX window size: ${e.parameter} bits (expected 15-21)`);let t=e.dataEnd-e.dataStart;Di(t,this.#n);let s=await $le(this.#e,e.dataStart,e.dataEnd),n=0,o=0;for(let l=0;l<e.blockCount;l++){if(n+vRt+this.#s>s.byteLength)throw new Q("Invalid CAB archive: truncated CFDATA header");let u=Pn(s,n+4),p=Pn(s,n+6);if(p===0)throw new Q("Unsupported multi-volume CAB archive: split CFDATA block");if(p>CVs)throw new Q(`Invalid CAB archive: CFDATA expands to ${p} bytes (maximum 32768)`);let c=n+vRt+this.#s,d=c+u;if(d>s.byteLength)throw new Q("Invalid CAB archive: truncated CFDATA payload");let f=Ps(s,n);if(f!==0){let m=bVs(s.subarray(c,d));if(bVs(s.subarray(n+4,c),m)!==f)throw new Q(`Invalid CAB archive: CFDATA block ${l} checksum mismatch`)}o+=p,Di(o,this.#n),n=d}if(o<e.requiredSize)throw new Q("Invalid CAB archive: folder data is shorter than its file table declares");let i=new Uint8Array(o),r=e.method===3?new xRt(e.parameter):void 0;n=0;let a=0;for(let l=0;l<e.blockCount;l++){let u=Pn(s,n+4),p=Pn(s,n+6),c=n+vRt+this.#s,d=c+u,f=s.subarray(c,d),m;if(e.method===0){if(u!==p)throw new Q("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 Q("Invalid CAB archive: MSZIP block is missing its CK signature");try{let g=i.subarray(Math.max(0,a-CVs),a);m=new Uint8Array(SVs.inflateRawSync(f.subarray(2),{dictionary:g,maxOutputLength:p}))}catch(g){throw new Q(`Invalid CAB archive: MSZIP decompression failed${g instanceof Error?`: ${g.message}`:""}`)}}else m=r.decompressFrame(f,p);if(m.byteLength!==p)throw new Q(`Invalid CAB archive: CFDATA block ${l} produced ${m.byteLength} bytes, expected ${p}`);i.set(m,a),a+=m.byteLength,n=d}return i}}class xVs{#e;#t;#s;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}async read(e,t){if(e!==this.#s)throw new Q(`Invalid CAB archive: size changed while extracting '${t}'`);let s=await this.#e.readAll(),n=this.#t+e;if(!Number.isSafeInteger(n)||this.#t<0||n>s.byteLength)throw new Q(`Invalid CAB archive: member '${t}' is outside its folder data`);return s.slice(this.#t,n)}}async function WKr(e,t){if(e.size<N2)throw new Q("Invalid CAB archive: truncated CFHEADER");let s=await $le(e,0,N2);if(!kVs(s))throw new Q(`Invalid CAB archive: expected ${OKr} signature`);if(Ps(s,4)!==0||Ps(s,12)!==0||Ps(s,20)!==0)throw new Q("Invalid CAB archive: reserved CFHEADER fields must be zero");let n=Ps(s,8);if(n<N2||n>e.size)throw new Q("Invalid CAB archive: declared cabinet size is out of bounds");let o=Ps(s,16);if(o<N2||o>n)throw new Q("Invalid CAB archive: CFFILE table offset is out of bounds");if(s[24]!==3||s[25]!==1)throw new Q(`Unsupported CAB format version ${s[25]}.${s[24]} (expected 1.3)`);let i=Pn(s,26),r=Pn(s,28),a=Pn(s,30);if(a&3)throw new Q("Unsupported multi-volume CAB archive (previous/next cabinet link)");if(xr(i+r,t.limits),i===0&&r!==0)throw new Q("Invalid CAB archive: files exist without a folder");let l=0,u=0,p=0,c=N2;if(a&4){let x=await $le(e,N2,N2+4,n);if(l=Pn(x,0),u=x[2],p=x[3],l>60000)throw new Q("Invalid CAB archive: CFHEADER reserve area exceeds 60000 bytes");c+=4+l}let d=8+u,f=c+i*d;if(!Number.isSafeInteger(f)||f>n||f>o)throw new Q("Invalid CAB archive: CFFOLDER table is out of bounds");Vn(f,t.limits,"CAB header");let m=await $le(e,0,f,n),g=[];for(let x=0;x<i;x++){let A=c+x*d,I=Pn(m,A+6);g.push({dataStart:Ps(m,A),dataEnd:n,blockCount:Pn(m,A+4),method:I&15,parameter:I>>>8,requiredSize:0})}for(let x of g){if(x.dataStart<f||x.dataStart>n)throw new Q("Invalid CAB archive: CFFOLDER data offset is out of bounds");for(let A of g)if(A.dataStart>x.dataStart&&A.dataStart<x.dataEnd)x.dataEnd=A.dataStart}let h=g.reduce((x,A)=>Math.min(x,A.dataStart),n);if(o>h)throw new Q("Invalid CAB archive: CFFILE table overlaps folder data");Vn(f+(h-o),t.limits,"CAB index");let T=await $le(e,o,h,n),R=g.map((x)=>new wVs(e,x,p,t.limits)),C=[],w=0;for(let x=0;x<r;x++){if(w+16>T.byteLength)throw new Q("Invalid CAB archive: truncated CFFILE entry");let A=Ps(T,w),I=Ps(T,w+4),M=Pn(T,w+8),O=Pn(T,w+10),_=Pn(T,w+12),F=Pn(T,w+14);w+=16;let L=T.indexOf(0,w);if(L<0)throw new Q("Invalid CAB archive: unterminated CFFILE name");let D=T.subarray(w,L);if(D.byteLength>256)throw new Q("Invalid CAB archive: CFFILE name exceeds 256 bytes");if(No(D.byteLength,"member path",t.limits.maxPathBytes),w=L+1,M>=65533)throw new Q("Unsupported multi-volume CAB archive: continued file");if(M>=R.length)throw new Q("Invalid CAB archive: CFFILE references a missing folder");let N=UKr(D,(F&NKr)!==0);Oa(A,N,t.limits);let U=I+A;if(!Number.isSafeInteger(U))throw new Q("Invalid CAB archive: CFFILE range is too large");if(U>g[M].requiredSize)g[M].requiredSize=U;let B=Qr(N);if(!B)continue;let H=(F&FKr)!==0;C.push({path:B,isDirectory:H,size:A,mtimeMs:HKr(O,_),mode:BKr(F,H),storage:H?void 0:{type:"member",source:new xVs(R[M],I,A)}})}for(let x of g)Di(x.requiredSize,t.limits);return C}function vVs(e){return kVs(e)}var OKr="MSCF",N2=36,vRt=8,CVs=32768,_Kr=1,FKr=16,LKr=64,NKr=128,DKr,qKr,EVs=async(e,t)=>{try{return await WKr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(`Invalid CAB archive: ${s instanceof Error?s.message:String(s)}`)}};var AVs=E(()=>{yT();RVs();fi();mc();Lf();DKr=new TextDecoder("utf-8",{fatal:!0}),qKr=new TextDecoder("windows-1252")});function YKr(){let e=new Uint32Array(256);for(let t=0;t<e.length;t++){let s=t<<24;for(let n=0;n<8;n++)s=(s&2147483648)!==0?s<<1^79764919:s<<1;e[t]=s>>>0}return e}function MVs(e,t){return(KKr[(e>>>24^t)&255]^e<<8)>>>0}class PVs{#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 Q("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 s=0;s<e;s++)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 Q("Invalid non-zero bzip2 stream padding")}}class OVs{#e;#t;#s=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.#n(1),this.#t[this.#s++]=e}pushRepeated(e,t){this.#n(t),this.#t.fill(e,this.#s,this.#s+t),this.#s+=t}finish(){return this.#t.slice(0,this.#s)}#n(e){let t=this.#s+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new Q(`Bzip2 output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let s=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(s>this.#e)s=this.#e;let n=new Uint8Array(s);n.set(this.#t.subarray(0,this.#s)),this.#t=n}}class _Vs{#e=new Uint16Array(D2+1);#t=new Uint32Array(D2+1);#s=new Uint16Array(D2+1);#n;constructor(e){for(let o of e){if(o<1||o>D2)throw new Q("Invalid bzip2 Huffman code length");this.#e[o]++}let t=0,s=0;for(let o=1;o<=D2;o++){if(t=(t+this.#e[o-1])*2,t+this.#e[o]>2**o)throw new Q("Oversubscribed bzip2 Huffman table");this.#t[o]=t,this.#s[o]=s,s+=this.#e[o]}this.#n=new Uint16Array(e.length);let n=new Uint16Array(this.#s);for(let o=0;o<e.length;o++){let i=e[o];this.#n[n[i]]=o,n[i]++}}decode(e){let t=0;for(let s=1;s<=D2;s++){t=t*2+e.readBit();let n=t-this.#t[s];if(n>=0&&n<this.#e[s])return this.#n[this.#s[s]+n]}throw new Q("Invalid bzip2 Huffman code")}}function IVs(e,t){return e.every((s,n)=>s===t[n])}function XKr(e){if(e.readBits(8)!==66||e.readBits(8)!==90||e.readBits(8)!==104)throw new Q("Invalid bzip2 stream header");let t=e.readBits(8)-48;if(t<1||t>9)throw new Q("Invalid bzip2 block-size level");return t*1e5}function JKr(e,t){let s=e.readBits(3);if(s<2||s>6)throw new Q("Invalid bzip2 Huffman group count");let n=e.readBits(15);if(n<1||n>zKr)throw new Q("Invalid bzip2 selector count");let o=new Uint8Array(n),i=new Uint8Array(s);for(let l=0;l<s;l++)i[l]=l;for(let l=0;l<n;l++){let u=0;while(e.readBit()!==0)if(u++,u>=s)throw new Q("Invalid bzip2 selector MTF value");let p=i[u];o[l]=p,i.copyWithin(1,0,u),i[0]=p}let r=t.length+2,a=[];for(let l=0;l<s;l++){let u=new Uint8Array(r),p=e.readBits(5);for(let c=0;c<r;c++){while(e.readBit()!==0)if(p+=e.readBit()===0?1:-1,p<1||p>D2)throw new Q("Invalid bzip2 Huffman code length");u[c]=p}a.push(new _Vs(u))}return{selectors:o,tables:a}}function QKr(e,t,s,n,o){let i=new Uint8Array(s),r=new Uint8Array(t),a=0,l=0,u=0,p,c=()=>{if(u===0){if(l>=n.length)throw new Q("Bzip2 block exhausted its Huffman selectors");p=o[n[l++]],u=jKr}return u--,p.decode(e)},d=(g,h)=>{if(h<0||a+h>t)throw new Q("Bzip2 block exceeds its declared block-size level");r.fill(g,a,a+h),a+=h},f=s.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 Q("Invalid bzip2 RLE run length");R*=2,m=c()}while(m===0||m===1);if(d(i[0],T),m===f)break}let g=m-1;if(g<0||g>=i.length)throw new Q("Invalid bzip2 MTF symbol");let h=i[g];i.copyWithin(1,0,g),i[0]=h,d(h,1),m=c()}return r.slice(0,a)}function ZKr(e,t){if(e.length===0||t<0||t>=e.length)throw new Q("Invalid bzip2 BWT origin pointer");let s=new Uint32Array(257);for(let a of e)s[a+1]++;for(let a=1;a<s.length;a++)s[a]+=s[a-1];let n=new Uint32Array(s.subarray(0,256)),o=new Uint32Array(e.length);for(let a=0;a<e.length;a++){let l=e[a];o[n[l]]=a,n[l]++}let i=new Uint8Array(e.length),r=o[t];for(let a=0;a<i.length;a++)i[a]=e[r],r=o[r];return i}function eYr(e,t,s){let n=4294967295,o=-1,i=0,r=0,a=0,l=(p)=>{s.push(p),n=MVs(n,p)},u=(p,c)=>{s.pushRepeated(p,c);for(let d=0;d<c;d++)n=MVs(n,p)};for(let p of e){if(t){if(a===0)a=VKr[r],r=r+1&511;if(a--,a===1)p^=1}if(i===4){u(o,p),i=0;continue}if(l(p),p===o)i++;else o=p,i=1}if(i===4)throw new Q("Truncated bzip2 RLE run");return(n^4294967295)>>>0}function tYr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid bzip2 output limit");let s=new PVs(e),n=new OVs(t,e.byteLength);for(;;){let o=XKr(s),i=0;for(;;){let r=s.readMarker();if(IVs(r,$Kr)){let C=s.readUint32();if(i!==C)throw new Q("Bzip2 stream CRC mismatch");s.alignToByte();break}if(!IVs(r,GKr))throw new Q("Invalid bzip2 block marker");let a=s.readUint32(),l=s.readBit()!==0,u=s.readBits(24),p=s.readBits(16),c=new Uint8Array(256),d=0;for(let C=0;C<16;C++){if((p&32768>>>C)===0)continue;for(let w=0;w<16;w++)if(s.readBit()!==0)c[d++]=C*16+w}if(d===0)throw new Q("Bzip2 block has an empty symbol map");let f=c.slice(0,d),{selectors:m,tables:g}=JKr(s,f),h=QKr(s,o,f,m,g),T=ZKr(h,u),R=eYr(T,l,n);if(R!==a)throw new Q("Bzip2 block CRC mismatch");i=((i<<1|i>>>31)^R)>>>0}if(s.done)return n.finish()}}function HFe(e){return e.byteLength>=4&&e[0]===66&&e[1]===90&&e[2]===104&&e[3]>=49&&e[3]<=57}async function dP(e,t){try{return tYr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}}var GKr,$Kr,D2=20,zKr=18002,jKr=50,VKr,KKr;var zle=E(()=>{fi();GKr=[49,65,89,38,83,89],$Kr=[23,114,69,56,80,144],VKr=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]),KKr=YKr()});import{promisify as FVs}from"util";import*as BFe from"zlib";function WFe(e){return e.byteLength>=2&&e[0]===31&&e[1]===139}async function q2(e,t){try{return await nYr(e,{maxOutputLength:Math.max(t,1)})}catch(s){throw new Q(s instanceof Error?s.message:String(s))}}function LVs(e){return sYr(e)}var sYr,nYr;var jle=E(()=>{fi();sYr=FVs(BFe.gzip),nYr=FVs(BFe.gunzip)});class qVs{bytes;pos=0;range=4294967295;code=0;constructor(e){if(this.bytes=e,e.byteLength<5||e[0]!==0)throw new Q("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<oYr){if(this.pos>=this.bytes.byteLength)throw new Q("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 s=e[t],n=Math.imul(this.range>>>11,s)>>>0;if(this.code<n)return this.range=n,e[t]=s+(Nm-s>>>NVs),0;return this.range=this.range-n>>>0,this.code=this.code-n>>>0,e[t]=s-(s>>>NVs),1}decodeDirectBits(e){let t=0;for(let s=0;s<e;s++){this.#e(),this.range>>>=1;let n=0;if(this.code>=this.range)this.code=this.code-this.range>>>0,n=1;t=(t<<1|n)>>>0}return t}}function Xg(e){let t=new Uint16Array(e);return t.fill(Nm>>>1),t}class MRt{choice=Xg(2);low=Xg($Fe<<3);mid=Xg($Fe<<3);high=Xg(256);reset(){this.choice.fill(Nm>>>1),this.low.fill(Nm>>>1),this.mid.fill(Nm>>>1),this.high.fill(Nm>>>1)}decode(e,t){if(e.decodeBit(this.choice,0)===0)return GFe(e,this.low,t<<3,3);if(e.decodeBit(this.choice,1)===0)return 8+GFe(e,this.mid,t<<3,3);return 16+GFe(e,this.high,0,8)}}function GFe(e,t,s,n){let o=1;for(let i=0;i<n;i++)o=o<<1|e.decodeBit(t,s+o);return o-(1<<n)}function DVs(e,t,s,n){let o=1,i=0;for(let r=0;r<n;r++){let a=e.decodeBit(t,s+o);o=o<<1|a,i|=a<<r}return i>>>0}function UVs(e){if(e.byteLength!==5)throw new Q("Invalid LZMA properties: expected 5 bytes");let t=e[0];if(t>=225)throw new Q("Invalid LZMA properties");let s=t%9;t=Math.floor(t/9);let n=t%5,o=Math.floor(t/5),i=(e[1]|e[2]<<8|e[3]<<16|e[4]<<24)>>>0;return{lc:s,lp:n,pb:o,dictionarySize:Math.max(i,4096)}}class zFe{#e;#t;#s=0;#n=0;#o=0;#r=0;#a=0;#i=0;#l=0;#u=1;#p=1;#c=1;#d=1;#f=Xg(ERt);#m=Xg(x9*$Fe);#g=Xg(x9);#h=Xg(x9);#T=Xg(x9);#y=Xg(x9);#C=Xg(x9*$Fe);#R=Xg(256);#S=Xg(115);#k=Xg(16);#b=new MRt;#x=new MRt;constructor(e,t){this.#e=e,this.#t=t.dictionarySize,this.setProperties(t.lc,t.lp,t.pb),this.resetDictionary()}get outputPos(){return this.#s}setProperties(e,t,s){if(e>8||t>4||s>4||e+t>12)throw new Q("Invalid LZMA properties");this.#r=e,this.#a=t,this.#i=s;let n=ERt*2**(e+t);if(this.#f.length!==n)this.#f=Xg(n)}resetDictionary(){this.#n=this.#s,this.#o=0,this.resetState()}resetState(){this.#l=0,this.#u=this.#p=this.#c=this.#d=1,this.#f.fill(Nm>>>1),this.#m.fill(Nm>>>1),this.#g.fill(Nm>>>1),this.#h.fill(Nm>>>1),this.#T.fill(Nm>>>1),this.#y.fill(Nm>>>1),this.#C.fill(Nm>>>1),this.#R.fill(Nm>>>1),this.#S.fill(Nm>>>1),this.#k.fill(Nm>>>1),this.#b.reset(),this.#x.reset()}appendUncompressed(e,t){if(t)this.resetDictionary();if(e.byteLength>this.#e.byteLength-this.#s)throw new Q("LZMA2 output exceeds its limit");this.#e.set(e,this.#s),this.#s+=e.byteLength,this.#o+=e.byteLength}decodeChunk(e,t,s=!1){if(!Number.isSafeInteger(t)||t<0||t>this.#e.byteLength-this.#s)throw new Q("LZMA output exceeds its declared size");let n=this.#s+t,o=new qVs(e),i=(1<<this.#i)-1,r=(1<<this.#a)-1;while(this.#s<n||s){let a=this.#o&i;if(o.decodeBit(this.#m,(this.#l<<4)+a)===0){let u=this.#s===this.#n?0:this.#e[this.#s-1],p=(((this.#o&r)<<this.#r)+(u>>>8-this.#r))*ERt,c=1;if(this.#l>=7){this.#A(this.#u);let d=this.#e[this.#s-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.#s>=n)throw new Q("LZMA output exceeds its size limit before the end marker");this.#e[this.#s++]=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.#w(this.#u,1,n);continue}}else{let u;if(o.decodeBit(this.#T,this.#l)===0)u=this.#p;else{if(o.decodeBit(this.#y,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.#x.decode(o,a)+ARt,this.#l=this.#l<7?8:11}else{this.#d=this.#c,this.#c=this.#p,this.#p=this.#u,l=this.#b.decode(o,a)+ARt,this.#l=this.#l<7?7:10;let u=Math.min(l-ARt,3),p=GFe(o,this.#R,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+DVs(o,this.#S,c-p,d)>>>0;else if(c=c+(o.decodeDirectBits(d-4)<<4)>>>0,c=c+DVs(o,this.#k,0,4)>>>0,c===4294967295){if(s)return!0;throw new Q("LZMA stream ended before its declared output size")}}this.#u=c+1>>>0}this.#w(this.#u,l,n)}return!1}#A(e){let t=this.#s-this.#n;if(e<1||e>t||e>this.#t)throw new Q(`Invalid LZMA match distance ${e} with ${t} bytes available`)}#w(e,t,s){if(this.#A(e),t>s-this.#s)throw new Q("LZMA match exceeds its declared output size");for(let n=0;n<t;n++)this.#e[this.#s]=this.#e[this.#s-e],this.#s++;this.#o+=t}}async function Vle(e,t,s){if(!Number.isSafeInteger(s)||s<0)throw new Q("Invalid LZMA output size");try{let n=new Uint8Array(s),o=new zFe(n,UVs(e));if(o.decodeChunk(t,s),o.outputPos!==s)throw new Q("LZMA output size mismatch");return n}catch(n){if(n instanceof Q)throw n;throw new Q(`Invalid LZMA stream: ${n instanceof Error?n.message:String(n)}`)}}async function v9(e,t){if(e.byteLength<13)throw new Q("Invalid LZMA-alone stream: truncated header");if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid LZMA output limit");let s=e.subarray(0,5),n=!0,o=0;for(let i=0;i<8;i++){let r=e[5+i];if(r!==255)n=!1;o+=r*2**(i*8)}if(!n){if(!Number.isSafeInteger(o)||o>t)throw new Q("LZMA-alone output exceeds its size limit");return Vle(s,e.subarray(13),o)}try{let i=new Uint8Array(t),r=new zFe(i,UVs(s));if(!r.decodeChunk(e.subarray(13),t,!0))throw new Q("LZMA-alone output exceeds its size limit before the end marker");return i.subarray(0,r.outputPos)}catch(i){if(i instanceof Q)throw i;throw new Q(`Invalid LZMA-alone stream: ${i instanceof Error?i.message:String(i)}`)}}async function jFe(e,t,s){if(!Number.isInteger(e)||e<0||e>40)throw new Q("Unsupported LZMA2 dictionary property");if(!Number.isSafeInteger(s)||s<0)throw new Q("Invalid LZMA2 output limit");let n=e===40?4294967295:(2|e&1)*2**(Math.floor(e/2)+11),o=new Uint8Array(s),i=new zFe(o,{lc:3,lp:0,pb:2,dictionarySize:n}),r=0,a=!0,l=!1,u=()=>{if(r>=t.byteLength)throw new Q("Invalid LZMA2 stream: truncated chunk header");return t[r++]};try{for(;;){let p=u();if(p===0)break;if(p<128){if(p!==1&&p!==2)throw new Q(`Invalid LZMA2 control byte 0x${p.toString(16)}`);if(p===2&&a)throw new Q("Invalid LZMA2 stream: dictionary was not initialized");let h=(u()<<8)+u()+1;if(h>s-i.outputPos||h>t.byteLength-r)throw new Q("Invalid LZMA2 uncompressed chunk size");if(i.appendUncompressed(t.subarray(r,r+h),p===1),r+=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 Q("Invalid LZMA2 stream: dictionary was not initialized");if(!l&&!g)throw new Q("Invalid LZMA2 stream: properties were not initialized");if(g){let h=u();if(h>=225)throw new Q("Invalid LZMA2 properties");let T=h%9;h=Math.floor(h/9);let R=h%5,C=Math.floor(h/5);if(T+R>4)throw new Q("Invalid LZMA2 literal properties");i.setProperties(T,R,C),l=!0}if(d>t.byteLength-r||c>s-i.outputPos)throw new Q("Invalid LZMA2 chunk size");if(f)i.resetDictionary();else if(m)i.resetState();i.decodeChunk(t.subarray(r,r+d),c),r+=d,a=!1}if(r!==t.byteLength)throw new Q("Invalid LZMA2 stream: trailing data");return o.subarray(0,i.outputPos)}catch(p){if(p instanceof Q)throw p;throw new Q(`Invalid LZMA2 stream: ${p instanceof Error?p.message:String(p)}`)}}var oYr=16777216,Nm=2048,NVs=5,ERt=768,x9=12,$Fe=16,ARt=2;var U2=E(()=>{fi()});class BVs{#e;#t=0;#s=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 s=0;s<e;s++){let n=this.#t+s;t+=(this.#e[n>>>3]>>>(n&7)&1)*2**s}return this.#t+=e,t}alignCodeGroup(e){let t=e*8,s=this.#s+Math.ceil((this.#t-this.#s)/t)*t;if(s>this.#e.byteLength*8)throw new Q("Truncated compress (.Z) code group");this.#t=s,this.#s=s}assertFinalPadding(){this.#n(this.#e.byteLength*8)}#n(e){for(let t=this.#t;t<e;t++)if((this.#e[t>>>3]>>>(t&7)&1)!==0)throw new Q("Invalid non-zero compress (.Z) padding")}}class WVs{#e;#t;#s=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.#n(t);for(let s=t-1;s>=0;s--)this.#t[this.#s++]=e[s]}finish(){return this.#t.slice(0,this.#s)}#n(e){let t=this.#s+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new Q(`Compress (.Z) output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let s=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(s>this.#e)s=this.#e;let n=new Uint8Array(s);n.set(this.#t.subarray(0,this.#s)),this.#t=n}}function aYr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid compress (.Z) output limit");if(e.byteLength<3)throw new Q("Truncated compress (.Z) header");if(e[0]!==31||e[1]!==157)throw new Q("Invalid compress (.Z) header");let s=e[2];if((s&96)!==0)throw new Q("Unsupported compress (.Z) header flags");let n=s&31;if(n<IRt||n>iYr)throw new Q(`Invalid compress (.Z) maximum code width ${n}`);let o=(s&128)!==0,i=2**n,r=new Uint16Array(i),a=new Uint8Array(i),l=new Uint8Array(i),u=new BVs(e.subarray(3)),p=new WVs(t,e.byteLength),c=IRt,d=o?HVs:256,f=!1;for(;;){let m=u.read(c);if(m===void 0)return u.assertFinalPadding(),p.finish();if(m>=d)throw new Q(`Corrupt compress (.Z) dictionary code ${m}`);if(o&&m===rYr){u.alignCodeGroup(c),c=IRt,d=HVs,f=!1;continue}let g=m,h=0;while(g>=256){if(g>=d||h>=l.length-1)throw new Q("Corrupt compress (.Z) dictionary chain");l[h++]=a[g],g=r[g]}if(l[h++]=g,f){if(a[d-1]=g,m===d-1)l[0]=g}if(p.appendReversed(l,h),d<i){if(f=!0,r[d++]=m,d>2**c&&c<n)u.alignCodeGroup(c),c++}else f=!1}}function GVs(e){return e.byteLength>=2&&e[0]===31&&e[1]===157}async function PRt(e,t){try{return aYr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}}var rYr=256,HVs=257,IRt=9,iYr=16;var $Vs=E(()=>{fi()});function rw(e,t){if(t<0||t+4>e.byteLength)throw new Q("Invalid XZ stream: truncated integer");return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function KFe(e,t,s){e[t]=s&255,e[t+1]=s>>>8&255,e[t+2]=s>>>16&255,e[t+3]=s>>>24}function zVs(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function lYr(e,t,s){e[t]=s>>>24,e[t+1]=s>>>16&255,e[t+2]=s>>>8&255,e[t+3]=s&255}function ORt(e,t){if(e.byteLength!==t.byteLength)return!1;for(let s=0;s<e.byteLength;s++)if(e[s]!==t[s])return!1;return!0}function H2(e){let t=0;for(let s=0;s<9;s++){if(e.pos>=e.limit)throw new Q("Invalid XZ stream: truncated variable-length integer");let n=e.bytes[e.pos++];if(s>0&&n===0)throw new Q("Invalid XZ stream: non-canonical variable-length integer");if(t+=(n&127)*2**(s*7),!Number.isSafeInteger(t))throw new Q("XZ stream uses sizes too large to read safely");if((n&128)===0)return t}throw new Q("Invalid XZ stream: variable-length integer is too long")}function jVs(e){switch(e){case 0:return 0;case 1:return 4;case 4:return 8;case 10:return 32;default:throw new Q(`Unsupported XZ integrity check ID 0x${e.toString(16)}`)}}function uYr(e,t,s){if(s<8||t<0||t+s>e.byteLength)throw new Q("Invalid XZ stream: index range is invalid");let n=t+s;if(e[t]!==0)throw new Q("Invalid XZ stream: missing index indicator");if(Ca(e.subarray(t,n-4))!==rw(e,n-4))throw new Q("Invalid XZ stream: index CRC32 mismatch");let o={bytes:e,pos:t+1,limit:n-4},i=H2(o);if(i>Math.floor(s/2))throw new Q("Invalid XZ stream: impossible index record count");let r=[];for(let a=0;a<i;a++){let l=H2(o),u=H2(o);if(l===0)throw new Q("Invalid XZ stream: zero unpadded block size");r.push({unpaddedSize:l,uncompressedSize:u})}while(o.pos<o.limit)if(e[o.pos++]!==0)throw new Q("Invalid XZ stream: non-zero index padding");return r}function pYr(e){if(e.byteLength===0||(e.byteLength&3)!==0)throw new Q("Invalid XZ stream: size is not a multiple of four bytes");let t=[],s=e.byteLength;while(s>0){let n=0;while(s>=4&&e[s-1]===0&&e[s-2]===0&&e[s-3]===0&&e[s-4]===0)s-=4,n+=4;if(s===0)throw new Q("Invalid XZ stream: padding without a stream");if(s<24)throw new Q("Invalid XZ stream: truncated stream framing");let o=s-12;if(e[o+10]!==89||e[o+11]!==90)throw new Q("Invalid XZ stream: footer magic mismatch");if(Ca(e.subarray(o+4,o+10))!==rw(e,o))throw new Q("Invalid XZ stream: footer CRC32 mismatch");let i=e[o+8],r=e[o+9];if(i!==0||(r&240)!==0)throw new Q("Unsupported XZ stream flags");let a=r&15;jVs(a);let l=(rw(e,o+4)+1)*4;if(!Number.isSafeInteger(l)||l>o)throw new Q("Invalid XZ stream: backward index size is invalid");let u=o-l,p=uYr(e,u,l),c=0;for(let f of p)if(c+=Math.ceil(f.unpaddedSize/4)*4,!Number.isSafeInteger(c))throw new Q("XZ stream uses sizes too large to read safely");let d=u-c-12;if(d<0||d+12>e.byteLength||!ORt(e.subarray(d,d+6),VFe))throw new Q("Invalid XZ stream: header position or magic is invalid");if(e[d+6]!==i||e[d+7]!==r)throw new Q("Invalid XZ stream: header and footer flags differ");if(Ca(e.subarray(d+6,d+8))!==rw(e,d+8))throw new Q("Invalid XZ stream: header CRC32 mismatch");t.unshift({start:d,indexStart:u,footerStart:o,checkId:a,records:p}),s=d}return t}function cYr(e,t){let s=new Uint8Array(256),n=0;for(let o=0;o<e.byteLength;o++){let i=e[o]+s[t+n&255]&255;s[n]=i,e[o]=i,n=n-1&255}}function dYr(e,t){let s=[0,1,2,2,3],n=0,o=4294967291;if(e.byteLength<5)return;let i=0,r=e.byteLength-5;while(i<=r){let a=e[i];if(a!==232&&a!==233){i++;continue}let l=t+i>>>0,u=l-o>>>0;if(o=l,u>5)n=0;else for(let p=0;p<u;p++)n=(n&119)<<1>>>0;if(a=e[i+4],(a===0||a===255)&&n>>>1<=4&&n>>>1!==3){let p=rw(e,i+1),c=0;for(;;){if(c=p-l-5>>>0,n===0)break;let d=s[n>>>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[i+4]=~((c>>>24&1)-1)&255,e[i+3]=c>>>16,e[i+2]=c>>>8,e[i+1]=c,i+=5,n=0}else if(i++,n|=1,a===0||a===255)n|=16}}function fYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){if(e[s]>>>2!==18||(e[s+3]&3)!==1)continue;let o=(((e[s]&3)<<24|e[s+1]<<16|e[s+2]<<8|e[s+3]&252)>>>0)-t-s>>>0;e[s]=72|o>>>24&3,e[s+1]=o>>>16,e[s+2]=o>>>8,e[s+3]=e[s+3]&3|o&252}}function mYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){if(e[s+3]!==235)continue;let o=((e[s+2]<<18|e[s+1]<<10|e[s]<<2)>>>0)-t-s-8>>>2;e[s]=o,e[s+1]=o>>>8,e[s+2]=o>>>16}}function gYr(e,t){for(let s=0;s+4<=e.byteLength;s+=2){if((e[s+1]&248)!==240||(e[s+3]&248)!==248)continue;let o=(((e[s+1]&7)<<19|e[s]<<11|(e[s+3]&7)<<8|e[s+2])<<1>>>0)-t-s-4>>>1;e[s+1]=240|o>>>19&7,e[s]=o>>>11,e[s+3]=248|o>>>8&7,e[s+2]=o,s+=2}}function hYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){if(!(e[s]===64&&(e[s+1]&192)===0||e[s]===127&&(e[s+1]&192)===192))continue;let o=(zVs(e,s)<<2>>>0)-t-s>>>2;o=0-(o>>>22&1)<<22&1073741823|o&4194303|1073741824,lYr(e,s,o>>>0)}}function TYr(e,t){let s=[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 n=0;n+16<=e.byteLength;n+=16){let o=s[e[n]&31],i=5;for(let r=0;r<3;r++,i+=41){if((o>>>r&1)===0)continue;let a=i>>>3,l=i&7,u=0n;for(let f=0;f<6;f++)u|=BigInt(e[n+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-n>>>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[n+a+f]=Number(u>>BigInt(f*8))&255}}}function yYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){let n=t+s>>>0,o=rw(e,s);if(o>>>26===37)o=(2483027968|o-(n>>>2)&67108863)>>>0,KFe(e,s,o);else if((o&2667577344)===2415919104){let i=o>>>29&3|o>>>3&2097148;if((i+131072&1835008)!==0)continue;let r=i-(n>>>12)>>>0;o&=2415919135,o|=(r&3)<<29,o|=(r&262140)<<3,o|=0-(r&131072)&14680064,KFe(e,s,o>>>0)}}}function RYr(e,t){if(e.byteLength<8)return;for(let s=0;s<=e.byteLength-8;s+=2){let n=e[s];if(n===239){let i=e[s+1];if((i&13)!==0)continue;let r=((i&240)<<13|e[s+2]<<9|e[s+3]<<1)-t-s>>>0;e[s+1]=i&15|r>>>8&240,e[s+2]=r>>>16&15|r>>>7&16|r<<4&224,e[s+3]=r>>>4&127|r>>>13&128,s+=2;continue}if((n&127)!==23)continue;n=rw(e,s);let o;if((n&3712)!==0){if(o=rw(e,s+4),(n<<8^o-3&1015811)!==0){s+=4;continue}let i=(n&4294963200)+(o>>>20);n=(279|o<<12)>>>0,o=i>>>0}else{let i=n>>>27;if(n-12567<<18>>>0>=(i&29)){s+=2;continue}let r=zVs(e,s+4)-t-s>>>0;o=(n>>>12|r<<20)>>>0,n=(23|i<<7|r+2048&4294963200)>>>0}KFe(e,s,n),KFe(e,s+4,o),s+=6}}function CYr(e,t){if(t.id===3){if(t.properties.byteLength!==1)throw new Q("Invalid XZ Delta filter properties");cYr(e,t.properties[0]+1);return}if(t.properties.byteLength!==0&&t.properties.byteLength!==4)throw new Q(`Invalid XZ BCJ filter 0x${t.id.toString(16)} properties`);let s=t.properties.byteLength===4?rw(t.properties,0):0,n=t.id===6?16:t.id===8||t.id===11?2:t.id===4?1:4;if((s&n-1)!==0)throw new Q(`Invalid XZ BCJ filter 0x${t.id.toString(16)} start offset`);switch(t.id){case 4:dYr(e,s);break;case 5:fYr(e,s);break;case 6:TYr(e,s);break;case 7:mYr(e,s);break;case 8:gYr(e,s);break;case 9:hYr(e,s);break;case 10:yYr(e,s);break;case 11:RYr(e,s);break;default:throw new Q(`Unsupported XZ filter ID 0x${t.id.toString(16)}`)}}function bYr(e,t,s){if(e===0)return;if(e===1){if(rw(s,0)!==Ca(t))throw new Q("Invalid XZ stream: block CRC32 mismatch");return}if(e===4){let o=W4s(t),i=0n;for(let r=0;r<8;r++)i|=BigInt(s[r])<<BigInt(r*8);if(o!==i)throw new Q("Invalid XZ stream: block CRC64 mismatch");return}let n=new Uint8Array(new Bun.CryptoHasher("sha256").update(t).digest());if(!ORt(n,s))throw new Q("Invalid XZ stream: block SHA-256 mismatch")}async function SYr(e,t,s,n){if(t>=e.byteLength||e[t]===0)throw new Q("Invalid XZ stream: missing block header");let o=(e[t]+1)*4;if(t+o>e.byteLength||o<8)throw new Q("Invalid XZ stream: truncated block header");if(Ca(e.subarray(t,t+o-4))!==rw(e,t+o-4))throw new Q("Invalid XZ stream: block header CRC32 mismatch");let i={bytes:e,pos:t+1,limit:t+o-4},r=e[i.pos++];if((r&60)!==0)throw new Q("Unsupported XZ block flags");let a=(r&3)+1,l=(r&64)!==0?H2(i):void 0,u=(r&128)!==0?H2(i):void 0,p=[];for(let w=0;w<a;w++){let x=H2(i),A=H2(i);if(A>i.limit-i.pos)throw new Q("Invalid XZ stream: truncated filter properties");p.push({id:x,properties:e.slice(i.pos,i.pos+A)}),i.pos+=A}while(i.pos<i.limit)if(e[i.pos++]!==0)throw new Q("Invalid XZ stream: non-zero block header padding");let c=jVs(n),d=s.unpaddedSize-o-c;if(!Number.isSafeInteger(d)||d<=0)throw new Q("Invalid XZ stream: compressed block size is invalid");if(l!==void 0&&l!==d)throw new Q("Invalid XZ stream: block compressed size mismatch");if(u!==void 0&&u!==s.uncompressedSize)throw new Q("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 Q("Invalid XZ stream: truncated block data");let T=p[p.length-1];if(T.id!==33||T.properties.byteLength!==1)throw new Q(`Unsupported XZ terminal filter ID 0x${T.id.toString(16)} (LZMA2 required)`);let R=await jFe(T.properties[0],e.subarray(f,m),s.uncompressedSize);if(R.byteLength!==s.uncompressedSize)throw new Q("Invalid XZ stream: decoded block size mismatch");R=R.slice();for(let w=p.length-2;w>=0;w--)CYr(R,p[w]);for(let w=m;w<h;w++)if(e[w]!==0)throw new Q("Invalid XZ stream: non-zero block padding");bYr(n,R,e.subarray(h,h+c));let C=t+Math.ceil(s.unpaddedSize/4)*4;if(h+c!==C)throw new Q("Invalid XZ stream: block size does not match its index record");return R}function YFe(e){return e.byteLength>=VFe.byteLength&&ORt(e.subarray(0,VFe.byteLength),VFe)}async function fP(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid XZ output limit");try{let s=pYr(e),n=0;for(let r of s)for(let a of r.records)if(n+=a.uncompressedSize,!Number.isSafeInteger(n)||n>t)throw new Q("XZ output exceeds its size limit");let o=new Uint8Array(n),i=0;for(let r of s){let a=r.start+12;for(let l of r.records){let u=await SYr(e,a,l,r.checkId);o.set(u,i),i+=u.byteLength,a+=Math.ceil(l.unpaddedSize/4)*4}if(a!==r.indexStart)throw new Q("Invalid XZ stream: blocks do not align with index")}return o}catch(s){if(s instanceof Q)throw s;throw new Q(`Invalid XZ stream: ${s instanceof Error?s.message:String(s)}`)}}var VFe;var Kle=E(()=>{uP();fi();U2();VFe=Uint8Array.of(253,55,122,88,90,0)});import{promisify as VVs}from"util";import*as XFe from"zlib";function JFe(e){return e.byteLength>=4&&e[0]===40&&e[1]===181&&e[2]===47&&e[3]===253}async function mP(e,t){try{return await wYr(e,{maxOutputLength:Math.max(t,1)})}catch(s){throw new Q(s instanceof Error?s.message:String(s))}}function KVs(e){return kYr(e)}var kYr,wYr;var E9=E(()=>{fi();kYr=VVs(XFe.zstdCompress),wYr=VVs(XFe.zstdDecompress)});import*as ZFe from"path";class LRt{#e;#t;#s;#n;constructor(e,t,s,n){this.#e=e,this.#t=t,this.#s=s,this.#n=n}async read(e,t){if(e!==this.#s)throw new Q(`CPIO member '${t}' has an inconsistent declared size`);let s=this.#t+this.#s;if(s>this.#e.byteLength)throw new Q(`CPIO member '${t}' is truncated`);let n=this.#e.subarray(this.#t,s);if(this.#n!==void 0&&t6s(n)!==this.#n)throw new Q(`CPIO member '${t}' has an invalid CRC checksum`);return n}}function t6s(e){let t=0;for(let s of e)t=t+s>>>0;return t}function e6s(e,t){let s=e%t;return s===0?e:e+t-s}function gP(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.byteLength)throw new Q(`Invalid CPIO archive: truncated ${n}`)}function QFe(e,t,s,n,o){gP(e,t,t+s,`${o} field`);let i=0;for(let r=t;r<t+s;r++){let a=e[r],l;if(a>=48&&a<=57)l=a-48;else if(n===16&&a>=65&&a<=70)l=a-65+10;else if(n===16&&a>=97&&a<=102)l=a-97+10;else throw new Q(`Invalid CPIO archive: ${o} is not a valid base-${n} number`);if(l>=n)throw new Q(`Invalid CPIO archive: ${o} is not a valid base-${n} number`);i=i*n+l}if(!Number.isSafeInteger(i))throw new Q(`Invalid CPIO archive: ${o} is too large`);return i}function s6s(e,t){gP(e,t,t+2,"header");let s=e[t],n=e[t+1];if(s===199&&n===113||s===113&&n===199){gP(e,t,t+JVs,"old binary header");let r=s===199?Pn:Dle,a=(l)=>r(e,t+l)*65536+r(e,t+l+2);return{headerSize:JVs,alignment:2,devMajor:0,devMinor:r(e,t+2),inode:r(e,t+4),mode:r(e,t+6),nlink:r(e,t+12),mtime:a(16),nameSize:r(e,t+20),fileSize:a(22)}}gP(e,t,t+6,"magic");let o=String.fromCharCode(...e.subarray(t,t+6));if(o==="070701"||o==="070702"){gP(e,t,t+YVs,"new ASCII header");let i=(a,l)=>QFe(e,t+6+a*8,8,16,l),r=i(12,"checksum");if(o==="070701"&&r!==0)throw new Q("Invalid CPIO archive: newc checksum field must be zero");return{headerSize:YVs,alignment:4,inode:i(0,"inode"),mode:i(1,"mode"),nlink:i(4,"link count"),mtime:i(5,"modification time"),fileSize:i(6,"file size"),devMajor:i(7,"device major"),devMinor:i(8,"device minor"),nameSize:i(11,"name size"),checksum:o==="070702"?r:void 0}}if(o==="070707"){gP(e,t,t+XVs,"portable ASCII header");let i=(r,a)=>QFe(e,t+r,6,8,a);return{headerSize:XVs,alignment:1,devMajor:0,devMinor:i(6,"device"),inode:i(12,"inode"),mode:i(18,"mode"),nlink:i(36,"link count"),mtime:QFe(e,t+48,11,8,"modification time"),nameSize:i(59,"name size"),fileSize:QFe(e,t+65,11,8,"file size")}}throw new Q(`Invalid CPIO archive: unsupported or corrupt magic at offset ${t}`)}function n6s(e){try{return EYr.decode(e)}catch{return}}function FRt(e,t,s,n){for(let o=t;o<s;o++)if(e[o]!==0)throw new Q(`Invalid CPIO archive: non-zero ${n} padding`)}function AYr(e,t,s){No(t.byteLength,"link target",s);let n=n6s(t);if(n===void 0||n.includes("\x00"))throw new Q(`Invalid CPIO archive: symlink '${e}' has an invalid UTF-8 target`);let o=n.replace(/\\/g,"/");if(ZFe.posix.isAbsolute(o))return{path:o,resolveTarget:!1};let i=_f(ZFe.posix.join(ZFe.posix.dirname(e),o));return i===void 0?{path:o,resolveTarget:!1}:{path:i,resolveTarget:!0}}function NRt(e,t){Di(e.byteLength,t.limits);let s=[],n=0,o=0,i=!1;while(n<e.byteLength){let u=s6s(e,n);if(u.mode>65535)throw new Q("Invalid CPIO archive: mode exceeds 16 bits");if(u.nameSize<1)throw new Q("Invalid CPIO archive: name size must include a NUL terminator");No(u.nameSize-1,"member path",t.limits.maxPathBytes),Oa(u.fileSize,"(CPIO entry)",t.limits);let p=n+u.headerSize,c=p+u.nameSize,d=e6s(c,u.alignment),f=d+u.fileSize,m=e6s(f,u.alignment);if(gP(e,p,c,"member name"),gP(e,d,f,"member data"),gP(e,f,m,"member padding"),e[c-1]!==0)throw new Q("Invalid CPIO archive: member name is not NUL-terminated");for(let R=p;R<c-1;R++)if(e[R]===0)throw new Q("Invalid CPIO archive: member name contains an embedded NUL");FRt(e,c,d,"name"),FRt(e,f,m,"data"),o+=d-n,Vn(o,t.limits,"CPIO index");let g=n6s(e.subarray(p,c-1));if(g===xYr){if(u.fileSize!==0)throw new Q("Invalid CPIO archive: TRAILER!!! has non-empty data");i=!0,n=m;break}let h=u.mode&_Rt;if((h===ZVs||h===4096)&&u.fileSize!==0)throw new Q("Invalid CPIO archive: directory or FIFO has non-empty data");xr(s.length+1,t.limits);let T=g===void 0?void 0:Qr(g);s.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}),n=m}if(!i)throw new Q("Invalid CPIO archive: missing TRAILER!!! terminator");FRt(e,n,e.byteLength,"trailing");let r=new Map,a=new Set,l=new Map;for(let u of s){if((u.mode&_Rt)!==QVs||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 LRt(e,c.dataOffset,c.fileSize,c.checksum)}:{type:"link",targetPath:d.path,resolveTarget:!1}};Xc(r,m)}}for(let u of s){if(a.has(u)||u.path===void 0)continue;let p=u.mode&_Rt;if(p===ZVs){Xc(r,{path:u.path,isDirectory:!0,size:0,mtimeMs:u.mtimeMs,mode:u.mode});continue}if(p===vYr){let c=e.subarray(u.dataOffset,u.dataOffset+u.fileSize);if(u.checksum!==void 0&&t6s(c)!==u.checksum)throw new Q(`CPIO symlink '${u.path}' has an invalid CRC checksum`);let d=AYr(u.path,c,t.limits.maxPathBytes);Xc(r,{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!==QVs)continue;Xc(r,{path:u.path,isDirectory:!1,size:u.fileSize,mtimeMs:u.mtimeMs,mode:u.mode,storage:{type:"member",source:new LRt(e,u.dataOffset,u.fileSize,u.checksum)}})}return iD(r,t.limits),[...r.values()]}function Yle(e){try{let t=s6s(e,0);if(t.mode>65535||t.nameSize<1)return!1;let s=t.headerSize+t.nameSize;return s<=e.byteLength&&e[s-1]===0}catch{return!1}}var YVs=110,XVs=76,JVs=26,xYr="TRAILER!!!",_Rt=61440,QVs=32768,ZVs=16384,vYr=40960,EYr,o6s=async(e,t)=>{try{return Di(e.size,t.limits),NRt(await KE(e),t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}};var DRt=E(()=>{yT();aD();fi();mc();Lf();YE();EYr=new TextDecoder("utf-8",{fatal:!0})});import*as Jle from"path";class k6s{#e;#t;#s;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}async read(e,t){if(this.#s)throw new Q(`Archive member '${Dr(t)}' is a sparse file and cannot be read`);if(e>this.#e.byteLength-this.#t)throw new Q(`Archive member '${Dr(t)}' is truncated`);let s=this.#e.subarray(this.#t,this.#t+e);if(s.byteLength!==e)throw new Q(`Archive member '${Dr(t)}' has an invalid size`);return s}}function tLe(e,t,s){let n=Math.min(t+s,e.byteLength),o=t;while(o<n&&e[o]!==0)o++;return Zle.decode(e.subarray(t,o))}function B2(e,t){return e.byteLength===t.length&&fc(e,0,t)}function FYr(e,t){return fc(e,t+C6s,HRt)&&fc(e,t+b6s,BRt)}function sLe(e,t,s){let n=e.indexOf(0),o=e.subarray(0,n===-1?e.byteLength:n);return No(o.byteLength,t,s.maxPathBytes),Zle.decode(o)}function a6s(e,t,s){return No(e.byteLength,t,s.maxPathBytes),Zle.decode(e)}function nLe(e,t,s){if(t<0||s<=0||t+s>e.byteLength)throw new Q("Invalid tar numeric field");let n=e[t],o=0n;if((n&128)!==0){o=BigInt(n&127);for(let i=1;i<s;i++)o=o<<8n|BigInt(e[t+i]);if((n&64)!==0)o-=1n<<BigInt(s*8-1)}else for(let i=0;i<s;i++){let r=e[t+i];if(r>=48&&r<=55)o=o*8n+BigInt(r-48)}return Number(o)}function w6s(e,t){let s=nLe(e,t,h6s);if(!Number.isSafeInteger(s)||s<0)throw new Q("Invalid tar member size");return s}function oLe(e){let t=e%iw,s=e+(t===0?0:iw-t);if(!Number.isSafeInteger(s))throw new Q("Invalid tar member size");return s}function l6s(e,t){if(!/^\d+$/.test(e))throw new Q(`Invalid tar ${t}`);let s=Number(e);if(!Number.isSafeInteger(s)||s<0)throw new Q(`Invalid tar ${t}`);return s}function x6s(e,t){for(let s=0;s<iw;s++)if(e[t+s]!==0)return!1;return!0}function v6s(e,t){let s=nLe(e,t+lD,URt),n=0,o=0;for(let i=0;i<iw;i++){let a=i>=lD&&i<lD+URt?32:e[t+i]??0;n+=a,o+=a<<24>>24}return s===n||s===o}function u6s(e,t){Vn(e.byteLength,t,"tar PAX metadata");let s=new Map,n=0;while(n<e.byteLength){let o=n;while(o<e.byteLength&&e[o]!==32)o++;if(o===n||o>=e.byteLength||o-n>16)throw new Q("Invalid tar PAX record");let i=0;for(let l=n;l<o;l++){let u=e[l];if(u<48||u>57)throw new Q("Invalid tar PAX record");if(i=i*10+(u-48),i>e.byteLength-n)throw new Q("Invalid tar PAX record")}if(i<=0||n+i>e.byteLength||e[n+i-1]!==10)throw new Q("Invalid tar PAX record");let r=e.subarray(o+1,n+i-1),a=r.indexOf(61);if(a>=0){let l=r.subarray(0,a),u=r.subarray(a+1);if(fc(l,0,WRt)){if(s.set(WRt,u.byteLength===0?"":"1"),B2(l,"GNU.sparse.name"))s.set("GNU.sparse.name",a6s(u,"PAX sparse path",t));else if(B2(l,"GNU.sparse.realsize")||B2(l,"GNU.sparse.size")){if(u.byteLength>r6s)throw new Q("Invalid tar sparse real size");s.set("GNU.sparse.realsize",Zle.decode(u))}}else if(B2(l,"path")||B2(l,"linkpath")){let p=B2(l,"path")?"PAX path":"PAX link target";s.set(p==="PAX path"?"path":"linkpath",a6s(u,p,t))}else if(B2(l,"size")){if(u.byteLength>r6s)throw new Q("Invalid tar member size");s.set("size",Zle.decode(u))}}n+=i}return s}function LYr(e,t){for(let[s,n]of t)if(n==="")e.delete(s);else e.set(s,n)}function A9(e,t,s){if(t?.has(s))return t.get(s);return e.get(s)}function NYr(e,t){return A9(e,t,WRt)==="1"}function DYr(e,t,s){for(let n=s;n<=e.byteLength-t.length;n++)if(fc(e,n,t))return n;return-1}function p6s(e,t,s){let n=e.replace(/\\/g,"/");if(Jle.posix.isAbsolute(n))throw new Q(`Invalid old-GNU ${t}`);let o=Qr(n);if(!o)throw new Q(`Invalid old-GNU ${t}`);return Ff(o,t,s.maxPathBytes),o}function qYr(e,t,s,n,o){let i=[...e.entries()].filter(([r])=>r===s||r.startsWith(`${s}/`));if(i.length===0)return;for(let[r]of i)e.delete(r);for(let[r,a]of i){let l=r.slice(s.length),u=`${n}${l}`;Ff(u,"member path",o.maxPathBytes),a.path=u;let p=e.get(u);if(p)t.delete(p);e.set(u,a)}for(let r of t.values())if(r.kind==="hard link"&&(r.targetPath===s||r.targetPath.startsWith(`${s}/`)))r.targetPath=`${n}${r.targetPath.slice(s.length)}`}function UYr(e,t,s,n){Vn(e.byteLength,n,"old-GNU name metadata");let o=e.indexOf(0),i=o===-1?e.byteLength:o,r=0;while(r<i){let a=e.indexOf(10,r),l=a===-1||a>i?i:a,u=e.subarray(r,l);if(fc(u,0,"Rename ")){let p=DYr(u," to ",7);if(p===-1)throw new Q("Invalid old-GNU name record");let c=sLe(u.subarray(7,p),"old-GNU source path",n),d=u[u.byteLength-1]===47?u.byteLength-1:u.byteLength,f=sLe(u.subarray(p+4,d),"old-GNU target path",n);qYr(t,s,p6s(c,"source path",n),p6s(f,"target path",n),n)}r=l+1}}function HYr(e,t,s){if(t.size===0)return;let n=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(n.has(p))break;n.add(p)}let o=new Set(t.keys()),i=new Map,r=(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=r(u.targetPath),c=u.targetPath;if(p===null){try{c=F2(e,c,s.maxLinkDepth)}catch(g){if(!(g instanceof Q))throw new Q("Invalid archive link")}if(c!==u.targetPath)p=r(c)}if(p!==null&&p!==l){let g=i.get(p);if(g)g.push(l);else i.set(p,[l]);continue}o.delete(l);let d=i.get(l);if(d)i.delete(l),a.push(...d);if(p===l){if(u.kind==="hard link")throw new Q(`Archive hard link '${Dr(l.path)}' has a cyclic target '${Dr(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||n.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 Q(`Archive hard link '${Dr(l.path)}' targets ${g} '${Dr(u.targetPath)}'`)}if(u.kind==="hard link")throw new Q(`Archive hard link '${Dr(l.path)}' targets directory '${Dr(u.targetPath)}'`);l.isDirectory=!0,l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1}}if(o.size>0)throw new Q("Archive contains cyclic or unsupported links")}function eue(e,t){let{limits:s}=t;Di(e.byteLength,s);let n=new Map,o=new Map,i=(d,f)=>{let m=n.get(d.path),g=Xc(n,d);if(!g)return;if(m)o.delete(m);if(f)o.set(g,f);xr(n.size,s)},r=0,a,l,u,p=new Map,c=!1;while(r+iw<=e.byteLength){if(x6s(e,r)){c=!0;break}if(!v6s(e,r))throw new Q("Invalid or corrupt tar archive header");let d=r,f=String.fromCharCode(e[d+R6s]||48),m=w6s(e,d+$Rt),g=tLe(e,d+GRt,Qle);if(FYr(e,d)){let z=tLe(e,d+S6s,zRt);if(z)g=`${z}/${g}`}let h=tLe(e,d+MYr,IYr),T=nLe(e,d+T6s,y6s),R=nLe(e,d+m6s,g6s),C=Number.isSafeInteger(R)&&R>=0?R:void 0;r+=iw;let w=oLe(m);if(w>e.byteLength-r)throw new Q("Archive member data is truncated");let x=e.subarray(r,r+m);if(f==="L"){Vn(x.byteLength,s,"GNU long-name metadata"),a=sLe(x,"GNU long path",s),r+=w;continue}if(f==="K"){Vn(x.byteLength,s,"GNU long-link metadata"),l=sLe(x,"GNU long link target",s),r+=w;continue}if(f==="N"){UYr(x,n,o,s),r+=w;continue}if(f==="x"||f==="X"){u=u6s(x,s),r+=w;continue}if(f==="g"){LYr(p,u6s(x,s)),r+=w;continue}if(f==="M")throw new Q("GNU multi-volume tar members are not supported");if(a!==void 0)g=a;if(l!==void 0)h=l;let A=A9(p,u,"path");if(A!==void 0)g=A;let I=A9(p,u,"linkpath");if(I!==void 0)h=I;let M=A9(p,u,"size");if(M!==void 0)m=l6s(M,"member size");let O=A9(p,u,"GNU.sparse.name");if(O!==void 0)g=O;let _=m,F=A9(p,u,"GNU.sparse.realsize");if(F!==void 0)_=l6s(F,"sparse real size");let L=f==="S"||NYr(p,u);if(f==="S"&&e[d+PYr]===1){let z=!0;while(z){if(r+iw>e.byteLength)throw new Q("Archive sparse metadata is truncated");z=e[r+OYr]===1,r+=iw}}let D=r,N=oLe(m);if(N>e.byteLength-D)throw new Q(`Archive member '${Dr(g)}' is truncated`);r+=N,a=void 0,l=void 0,u=void 0;let U=f==="5"||g.endsWith("/"),B=Qr(g);if(!B)continue;Ff(B,"member path",s.maxPathBytes);let H=T*1000,W=T!==0&&Number.isSafeInteger(H)?H:void 0;if(U){i({path:B,isDirectory:!0,size:0,mtimeMs:W,mode:C});continue}if(f==="1"||f==="2"){let z=f==="1"?"hard link":"symlink",K=h.replace(/\\/g,"/");Ff(K,"link target",s.maxPathBytes);let J=f==="1"?Qr(K):Jle.posix.isAbsolute(K)?void 0:_f(Jle.posix.join(Jle.posix.dirname(B),K)),se={path:B,isDirectory:!1,size:0,mtimeMs:W,mode:C};if(J===void 0||Buffer.byteLength(J,"utf-8")>s.maxPathBytes){if(z==="hard link")throw new Q(`Archive hard link '${Dr(B)}' has an invalid target`);se.storage={type:"link",targetPath:K,resolveTarget:!1},i(se);continue}i(se,{kind:z,targetPath:J});continue}if(f!=="0"&&f!=="\x00"&&f!=="7"&&f!=="S")continue;Oa(_,B,s),i({path:B,isDirectory:!1,size:_,mtimeMs:W,mode:C,storage:{type:"member",source:new k6s(e,D,L)}})}if(!c)throw new Q("Not a valid tar archive: missing terminating zero block");return HYr(n,o,s),[...n.values()]}function jRt(e){if(e.byteLength<iw)return!1;if(x6s(e,0))return!0;try{if(tLe(e,GRt,Qle).length===0)return!1;let t=w6s(e,$Rt);return Number.isSafeInteger(oLe(t))&&v6s(e,0)}catch{return!1}}function eLe(e,t,s,n){if(n.byteLength>s)throw new Q("Tar header field is too long");e.set(n,t)}function Xle(e,t,s,n){if(!Number.isSafeInteger(n)||n<0)throw new Q("Invalid tar numeric value");let o=n.toString(8);if(o.length>s-1)throw new Q("Tar numeric value does not fit its header field");for(let i=t;i<t+s-1-o.length;i++)e[i]=48;for(let i=0;i<o.length;i++)e[t+s-1-o.length+i]=o.charCodeAt(i);e[t+s-1]=0}function BYr(e){if(e.byteLength<=Qle)return[e,new Uint8Array(0)];for(let t=e.byteLength-1;t>0;t--){if(e[t]!==47)continue;let s=e.subarray(0,t),n=e.subarray(t+1);if(s.byteLength<=zRt&&n.byteLength>0&&n.byteLength<=Qle)return[n,s]}return}function qRt(e,t){let s=uD.encode(`${e}=${t}
|
|
4034
|
+
Supported: ${i||"none"}`)}return{parsed:s,handler:o}}async resolve(e,t){let{parsed:s,handler:n}=this.#n(e,!0),o=await n.resolve(s,t);return{...o,immutable:o.immutable??n.immutable}}async write(e,t,s){let{parsed:n,handler:o}=this.#n(e);if(!o.write){let i=n.protocol.replace(/:$/,"").toLowerCase();throw Error(`${i}:// URLs are read-only for write; use the protocol-specific tool for mutations.`)}await o.write(n,t,s)}}var Ile=E(()=>{fpt();BAe();Jmt();Ugt();DPe();hht();Z_e();_yt();wE();Lyt();cFe();XW();Jyt();EFe()});var ku=E(()=>{fpt();BAe();Jmt();Ugt();DPe();hht();Z_e();_yt();wE();Ile();Lyt();cFe();XW();Jyt();EFe()});import*as Pf from"fs";import*as w4s from"os";import*as Sn from"path";import*as x4s from"url";import{glob as x9r}from"@linxiraos/pi-natives";function M2(e){return Sn.posix.isAbsolute(e)||Sn.win32.isAbsolute(e)}function O9r(e){return e.replace(v9r," ")}function _9r(e){return e.replace(/ (AM|PM)\./g,`${P9r}$1.`)}function F9r(e){return e.normalize("NFD")}function y4s(e){return e.replace(/'/g,"\u2019")}function L9r(e){if(!e.includes("\\")||!e.includes("/"))return e;return e.replace(/\\([ \t"'(){}[\]])/g,"$1")}function Ple(e){try{return Pf.accessSync(e,Pf.constants.F_OK),!0}catch{return!1}}function N9r(e){if(!e.startsWith("@"))return e;let t=e.slice(1);if(t.startsWith("/")||t==="~"||t.startsWith("~/")||Sn.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 D9r(e){if(!e.toLowerCase().startsWith("file://"))return e;try{return x4s.fileURLToPath(e)}catch{return e}}function Cp(e,t){let s=t??w4s.homedir();if(e==="~")return s;if(e.startsWith("~/")||e.startsWith("~\\"))return s+e.slice(1);if(e.startsWith("~"))return Sn.join(s,e.slice(1));return e}function ub(e){let t=/^:(?=[/\\~]|\.\.?[/\\]|[A-Za-z]:)/.test(e)?e.slice(1):e,s=OS(D9r(O9r(N9r(t))));return Cp(s)}function R4s(e){if(e.length!==1)return!1;let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function q9r(e){if(!e.startsWith("/"))return;let t=e.split("/");if(t[0]!=="")return;let s,n=2;if(t.length>=2&&R4s(t[1]??""))s=t[1].toUpperCase();else if(t.length>=3&&(t[1]??"").toLowerCase()==="mnt"&&R4s(t[2]??""))s=t[2].toUpperCase(),n=3;if(!s)return;let o=t.slice(n).filter(Boolean).join("\\");return o?`${s}:\\${o}`:`${s}:\\`}function U9r(e,t=process.platform){if(t!=="win32")return e;return q9r(e)??e}function B9r(e){let t=H9r.exec(e);if(!t)return null;let s=Number.parseInt(t[1],10);if(s<1)throw new oe("Line selector 0 is invalid; lines are 1-indexed. Use :1.");let n=t[2]===".."?"-":t[2],o=t[3]?Number.parseInt(t[3],10):void 0,i;if(n==="+"){if(o===void 0||o<1)throw new oe(`Invalid range ${s}+${o??0}: count must be >= 1.`);i=s+o-1}else if(n==="-"){if(o!==void 0){if(o<s)throw new oe(`Invalid range ${s}-${o}: end must be >= start.`);i=o}}return{startLine:s,endLine:i}}function hT(e){let t=e.split(","),s=[];for(let o of t){let i=B9r(o);if(!i)return null;s.push(i)}if(s.length===0)return null;s.sort((o,i)=>o.startLine-i.startLine);let n=[s[0]];for(let o=1;o<s.length;o++){let i=s[o],r=n[n.length-1];if(r.endLine===void 0)continue;if(i.startLine<=r.endLine+1){if(i.endLine===void 0||i.endLine>r.endLine)n[n.length-1]={startLine:r.startLine,endLine:i.endLine};continue}n.push(i)}return n}function IFe(e){if(!e)return;for(let t of e.split(":")){let s=t.toLowerCase();if(s==="raw"||s==="conflicts")continue;let n=hT(t);if(n)return n}return}function _le(e,t){for(let s of t){if(e<s.startLine)continue;if(s.endLine===void 0||e<=s.endLine)return!0}return!1}function Ju(e){let t=e.lastIndexOf(":");if(t<=0)return{path:e};let s=e.slice(t+1);if(!E9r.test(s))return{path:e};let n=e.slice(0,t),o=s,i=n.lastIndexOf(":");if(i>0){let r=n.slice(i+1),a=T4s.test(r),l=T4s.test(s),u=h4s.test(r),p=h4s.test(s);if(a&&p||u&&l)o=`${r}:${s}`,n=n.slice(0,i)}return{path:n,sel:o}}async function oD(e,t){let s=lc(e,t);try{return await Pf.promises.lstat(s),"exists"}catch(n){if(ye(n)||OU(n)||va(n,"ENAMETOOLONG"))return"missing";return"unknown"}}async function PFe(e,t){let s=Ju(e);if(s.sel===void 0)return s;return await oD(e,t)==="missing"?s:{path:e}}function I2(e){let t=e.match(v4s);if(!t)return{path:e};let s=t[1].toLowerCase();if(I9r.has(s))return{path:e};if(!M9r[s])return{path:e};let n=t[0].length;if(s==="ssh"&&e.indexOf("/",n)===-1)return{path:e};let o=e,i=[];while(!0){let r=o.lastIndexOf(":");if(r<n)break;let a=o.slice(r+1);if(!A9r.test(a))break;i.unshift(a),o=o.slice(0,r)}if(i.length===0)return{path:e};return{path:o,sel:i.join(":")}}function E4s(e){let{path:t,sel:s}=I2(e);if(s===void 0)return e;if(/^(?:raw|conflicts)$/i.test(s))return t;throw new oe(`write does not accept the trailing selector ":${s}" \u2014 it writes a whole file. `+`Remove ":${s}", or if the filename truly ends with it, percent-encode the ":" as %3A.`)}function W9r(e,t){for(let s of aRt)if(e.startsWith(s))throw Error(`Path "${t}" uses internal scheme "${s}" and must be resolved through the proper protocol handler, not as a filesystem path.`)}function ci(e){return e.replace(/^(local:)\/(?!\/)/,"$1//")}function Of(e){let t=ci(e),s=ci(ub(t));for(let n of aRt)if(s.startsWith(n))return!0;return!1}function OFe(e){let t=ci(ub(ci(e)));if(!aRt.some((o)=>t.startsWith(o)))return"write";let s=v4s.exec(t)?.[1]?.toLowerCase();return(s?sa.instance().getHandler(s):void 0)?.write?"write":"read"}function y9(e){return/ssh:\/\//i.test(e)}function lRt(e){return/^ssh:\/\//i.test(e.trim())}function P2(e){return/^https?:\/\/?/i.test(e)||/^www\./i.test(e)}function ks(e,t){let s=ci(e),n=U9r(ub(s)),o=ci(n);if(W9r(o,s),/^\/+$/.test(n))return t;if(Sn.isAbsolute(n))return n;return Sn.resolve(t,n)}function A4s(e,t){if(!e||Sn.isAbsolute(e))return null;if(e.startsWith("~")||Of(e))return null;let s=Sn.resolve(t),n=Sn.resolve(s,e);if(!AFe(n,s))return null;let o=nRt(s);if(!o)return null;let i=nRt(n);if(i)return AFe(i,o)?n:null;if(G9r(n))return null;let r=Sn.dirname(n),a=[Sn.basename(n)];for(;;){let l=nRt(r);if(l)return AFe(Sn.join(l,...a.reverse()),o)?n:null;let u=Sn.dirname(r);if(u===r||!AFe(r,s))return null;a.push(Sn.basename(r)),r=u}}function AFe(e,t){let s=Sn.relative(t,e);return!!s&&!s.startsWith("..")&&!Sn.isAbsolute(s)}function nRt(e){try{return Pf.realpathSync.native(e)}catch{return null}}function G9r(e){try{return Pf.lstatSync(e).isSymbolicLink()}catch{return!1}}async function uRt(e,t){let s=Sn.resolve(e);if(t){let i=await C4s(s);if(i!==null)return i;if(!await b4s(s))return null}let n=[Sn.basename(s)],o=Sn.dirname(s);for(;;){let i=await C4s(o);if(i!==null)return Sn.join(i,...n.reverse());if(!await b4s(o))return null;let r=Sn.dirname(o);if(r===o)return null;n.push(Sn.basename(o)),o=r}}async function C4s(e){try{return await Pf.promises.realpath(e)}catch{return null}}async function b4s(e){try{return!(await Pf.promises.lstat(e)).isSymbolicLink()}catch(t){return ye(t)}}function tn(e,t,s={}){let n=Sn.resolve(t),o=ci(e);if(Of(o))return o;let i=ub(o),r=Sn.isAbsolute(i)?Sn.resolve(i):Sn.resolve(t,i),a=Sn.relative(n,r),l=a===""||!a.startsWith("..")&&!Sn.isAbsolute(a),u=T9(l?a||".":r);if(s.trailingSlash&&u!=="."&&!u.endsWith("/"))u+="/";return u}function pRt(e){return e.startsWith('"')&&e.endsWith('"')&&e.length>1?e.slice(1,-1):e}function cRt(e){if(Of(e))return e;if(!e.includes("\\"))return e;return e.replace(/\\/g,"/")}function rD(e){return pRt(e.trim())}function $9r(e){let t=e.trim();if(!t.startsWith("[")||!t.endsWith("]"))return null;let s;try{s=JSON.parse(t)}catch{return null}if(!Array.isArray(s)||s.some((n)=>typeof n!=="string"))return null;return s}function Zy(e){if(typeof e==="string")return $9r(e)??[e];return e??[]}function ow(e){return z9r.some((t)=>e.includes(t))}function j9r(e,t){if(t==="comma")return e===",";if(t==="semicolon")return e===";";if(t==="whitespace")return rRt.test(e);return e===","||e===";"||rRt.test(e)}function V9r(e){let t=0;for(let s=0;s<e.length;s++){let n=e[s];if(n==="\\"&&s+1<e.length){s++;continue}if(n==="{"){t++;continue}if(n==="}"){if(t>0)t--;continue}if(t===0&&(n===","||n===";"||rRt.test(n)))return!0}return!1}function K9r(e,t){let s=[],n=0,o=0;for(let i=0;i<e.length;i++){let r=e[i];if(r==="\\"&&i+1<e.length){i++;continue}if(r==="{"){n++;continue}if(r==="}"){if(n>0)n--;continue}if(n!==0||!j9r(r,t))continue;s.push(e.slice(o,i)),o=i+1}return s.push(e.slice(o)),s}async function M4s(e,t,s){if(Of(e))return!0;let n=Ju(e).path,{basePath:o}=s(n),i=ks(o,t);try{return await Pf.promises.stat(i),!0}catch(r){if(ye(r)||va(r,"ENAMETOOLONG"))return!1;throw r}}async function Ole(e,t,s,n,o){let i=K9r(e,n);if(i.length<2)return null;let r=i.map(rD).filter((a)=>a.length>0);if(r.length===0)return null;if(r.length<2&&i.length===r.length)return null;if(o!=="none"){let a=await Promise.all(r.map((u)=>M4s(u,t,s)));if(!(o==="all"?a.every(Boolean):a.some(Boolean)))return null}return r}async function dRt(e,t,s={}){let n=rD(e);if(!V9r(n))return null;let o=s.splitter??MFe;if(s.routedUrlPredicate?.(n)){let r=await Ole(n,t,o,"semicolon","none");return r?.every(s.routedUrlPredicate)?r:null}if(Of(n))return null;if(await oD(n,t)!=="missing")return null;let i=Ju(n).path;if(!ow(i)&&await M4s(n,t,o))return null;return await Ole(n,t,o,"semicolon","none")??await Ole(n,t,o,"comma","some")??await Ole(n,t,o,"whitespace","all")??await Ole(n,t,o,"mixed","all")}async function Fle(e,t,s={}){let n=[];for(let o of e){let i=rD(o),r=await dRt(i,t,s);if(r)n.push(...r);else n.push(i)}return n}function MFe(e){let t=cRt(e),s=t.split("/"),n=-1;for(let o=0;o<s.length;o++)if(ow(s[o])){n=o;break}if(n===-1)return{basePath:t};if(n<=0)return{basePath:".",glob:t};return{basePath:s.slice(0,n).join("/"),glob:s.slice(n).join("/")}}async function I4s(e,t){if(!ow(e)||Of(e))return MFe(e);try{return await Pf.promises.stat(ks(e,t)),{basePath:cRt(e)}}catch{return MFe(e)}}function Lle(e){let t=cRt(e),s=t.split("/"),n=-1;for(let o=0;o<s.length;o++)if(ow(s[o])){n=o;break}if(n===-1)return{basePath:t,globPattern:"**/*",hasGlob:!1};if(n===0)return{basePath:".",globPattern:!t.startsWith("**/")?`**/${t}`:t,hasGlob:!0};return{basePath:s.slice(0,n).join("/"),globPattern:s.slice(n).join("/"),hasGlob:!0}}function oRt(e,t){if(!e)return t;if(!t)return e;let s=e.replace(/\/+$/,""),n=t.replace(/^\/+/,"");return`${s}/${n}`}function T9(e){return e.replace(/\\/g,"/")}function S4s(e,t){if(!e||e===".")return T9(t).replace(/^\/+/,"");let s=T9(e).replace(/\/+$/,""),n=T9(t).replace(/^\/+/,"");return`${s}/${n}`}function Y9r(e){let t=[...new Set(e.map((s)=>T9(s).trim()).filter(Boolean))];if(t.length===0)return;if(t.length===1)return t[0];return`{${t.join(",")}}`}function X9r(e){if(e.length===0)return".";let t=Sn.resolve(e[0]).split(Sn.sep);for(let n of e.slice(1)){let o=Sn.resolve(n).split(Sn.sep),i=0,r=Math.min(t.length,o.length);while(i<r&&t[i]===o[i])i+=1;t=t.slice(0,i)}if(t.length===0)return Sn.parse(Sn.resolve(e[0])).root;return t.join(Sn.sep)||Sn.parse(Sn.resolve(e[0])).root}function P4s(e,t){return e.map((s)=>tn(s,t,{trailingSlash:s.endsWith("/")||s.endsWith("\\")})).join(", ")}async function J9r(e,t,s,n=!1){if(e.length<1)return;let o=await Promise.all(e.map(async(c)=>{let d=await I4s(c,t),f=ks(d.basePath,t),m=await Pf.promises.stat(f);return{raw:c,parsedPath:d,absoluteBasePath:f,stat:m}})),i=!s&&o.every((c)=>!c.parsedPath.glob&&c.stat.isFile()),r=X9r(o.map((c)=>c.absoluteBasePath)),a=o.map((c)=>{let d=T9(Sn.relative(r,c.absoluteBasePath))||".";if(c.parsedPath.glob){let f=S4s(d,c.parsedPath.glob);return oRt(f,s)??f}if(s)return oRt(d==="."?void 0:d,s)??s;if(c.stat.isDirectory())return S4s(d,"**/*");return d==="."?Sn.basename(c.absoluteBasePath):d}),l=o.some((c)=>c.absoluteBasePath===r),u=n&&!i&&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?oRt(c.parsedPath.glob,s):s})):void 0;return{basePath:r,glob:Y9r(a),scopePath:P4s(e,t),exactFilePaths:i?o.map((c)=>c.absoluteBasePath):void 0,targets:p}}async function Q9r(e,t,s,n=!1){return J9r([...new Set(e)],t,s,n)}async function Z9r(e,t){if(e.length<=1)return;return{targets:e.map((n)=>{let o=Lle(n);return{basePath:ks(o.basePath,t),globPattern:o.globPattern,hasGlob:o.hasGlob}}),scopePath:P4s(e,t)}}async function O4s(e,t){return Z9r([...new Set(e)],t)}async function fRt(e,t,s){let n=await Promise.all(e.map(async(r)=>{let{basePath:a}=s(r),l=ks(a,t);try{return await Pf.promises.stat(l),{item:r,exists:!0}}catch(u){if(ye(u))return{item:r,exists:!1};throw u}})),o=[],i=[];for(let r of n)if(r.exists)o.push(r.item);else i.push(r.item);return{valid:o,missing:i}}function lc(e,t){let s=ks(e,t),n=L9r(s),o=n!==s?[s,n]:[s];for(let i of o)if(Ple(i))return i;for(let i of o){let r=_9r(i);if(r!==i&&Ple(r))return r;let a=F9r(i);if(a!==i&&Ple(a))return a;let l=y4s(i);if(l!==i&&Ple(l))return l;let u=y4s(a);if(u!==i&&Ple(u))return u}return s}function eKr(e){return e.replace(/[*?[{]/g,"[$&]")}async function tKr(e,t,s,n){let o=e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"");if(!o)return null;let i=AbortSignal.timeout(k4s),r=s?AbortSignal.any([s,i]):i,a;try{let l=await n({pattern:`**/${eKr(o)}`,path:t,hidden:!0,signal:r,timeoutMs:k4s});if(s?.aborted)throw new rt;a=l.matches.map((u)=>u.path)}catch{if(s?.aborted)throw new rt;return null}if(a.length!==1)return null;return{absolutePath:Sn.resolve(t,a[0]),displayPath:a[0]}}async function _Fe(e,t,s){return tKr(e,t,s,x9r)}async function R9(e){let{rawPaths:t,cwd:s,internalUrlAction:n}=e,o=t.map(rD);if(o.some((R)=>R.length===0))throw new oe("Search scope entries must be non-empty paths or globs");let i=await Fle(o,s);if(i.some((R)=>R.length===0))throw new oe("Search scope entries must be non-empty paths or globs");let r=/^(?:https?|ftp|ws|wss):\/\//i,a=sa.instance(),l=[],u=new Set;for(let R of i){let C=r.test(R);if(!C&&P2(R)&&!ow(R))try{await Pf.promises.stat(ks(R,s))}catch(x){C=ye(x)||OU(x)}if(C){let x=e.resolveExternalUrl?await e.resolveExternalUrl(R):void 0;if(x){if(l.push(x.sourcePath),e.trackImmutableSources&&x.immutable)u.add(Sn.resolve(x.sourcePath));continue}throw new oe(`Cannot ${n} external URL: ${R}. Use \`read\` to fetch web content, then search the returned text.`)}if(!a.canHandle(R)){l.push(R);continue}if(lRt(R))throw new oe(`Cannot ${n} a remote ssh:// path (no local file): ${R}. Use \`read ${R}\` to view it, or use \`grep\` on a specific remote file.`);if(ow(R))throw new oe(`Glob patterns are not supported for internal URLs: ${R}`);let w=await a.resolve(R,{cwd:s,settings:e.settings,signal:e.signal,localProtocolOptions:e.localProtocolOptions,skills:e.skills,pathOnly:!0});if(!w.sourcePath)throw new oe(`Cannot ${n} internal URL without a backing file: ${R}`);if(e.trackImmutableSources&&w.immutable)u.add(Sn.resolve(w.sourcePath));l.push(w.sourcePath)}let p=[],c=l;if(l.length>1){let R=await fRt(l,s,MFe);if(R.valid.length===0)throw new oe(`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 I4s(c[0]??".",s);d=ks(R.basePath,s),m=R.glob,f=tn(d,s)}else{let R=await Q9r(c,s,void 0,e.fanOutFileTargets===!0);if(!R)throw new oe("`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&&i.length>1?e.multipathStatHint:"";throw new oe(`Path not found: ${f}${R}`)}return{searchPath:d,scopePath:f,globFilter:m,isDirectory:T,multiTargets:g,exactFilePaths:h,missingPaths:p,immutableSourcePaths:u}}var v9r,g4s,iRt,E9r,h4s,T4s,A9r,M9r,I9r,v4s,P9r="\u202F",aRt,H9r,z9r,rRt,k4s=5000;var Ss=E(()=>{X();ku();Ut();v9r=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;g4s=String.raw`L?\d+(?:(?:[-+]|\.\.)L?\d+|-|\.\.)?`,iRt=`${g4s}(?:,${g4s})*`,E9r=new RegExp(`^(?:${iRt}|raw|conflicts)$`,"i"),h4s=new RegExp(`^${iRt}$`,"i"),T4s=/^raw$/i,A9r=new RegExp(String.raw`^(?:raw|conflicts|${iRt}|-\d+(?:[-+]\d+)?)$`,"i"),M9r={agent:!0,artifact:!0,issue:!0,history:!0,local:!0,memory:!0,omp:!0,pr:!0,rule:!0,security:!0,skill:!0,ssh:!0,vault:!0},I9r=new Set(["mcp"]),v4s=/^([a-z][a-z0-9+.-]*):\/\//i,aRt=["agent://","artifact://","skill://","rule://","security://","local://","mcp://","ssh://","vault://"];H9r=/^L?(\d+)(?:(\.\.|[-+])L?(\d+)?)?$/i;z9r=["*","?","[","{"];rRt=/\s/});var C9;var FFe=E(()=>{C9={type:"module",name:"@linxiraos/zeta",version:"1.1.3",description:"Coding agent CLI with read, bash, edit, write tools and session management",homepage:"https://linxira-os.github.io/zeta/",author:"Stencil Labs, Inc.",contributors:["Mario Zechner"],license:"MIT",repository:{type:"git",url:"git+https://github.com/Linxira-OS/linxira-zeta.git",directory:"packages/coding-agent"},bugs:{url:"https://github.com/Linxira-OS/linxira-zeta/issues"},keywords:["coding-agent","ai","llm","cli","tui","agent"],main:"./src/index.ts",types:"./dist/types/index.d.ts",bin:{zeta:"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":"^7.29.7","@linxiraos/pi-hashline":"1.1.3","@linxiraos/pi-stats":"1.1.3","@linxiraos/pi-omptype":"1.1.3","@linxiraos/pi-agent-core":"1.1.3","@linxiraos/pi-ai":"1.1.3","@linxiraos/pi-catalog":"1.1.3","@linxiraos/pi-mnemopi":"1.1.3","@linxiraos/pi-natives":"1.1.3","@linxiraos/pi-tui":"1.1.3","@linxiraos/pi-utils":"1.1.3","@linxiraos/pi-wire":"1.1.3","@linxiraos/pi-snapcompact":"1.1.3","@opentelemetry/api":"^1.9.1","@opentelemetry/api-logs":"^0.220.0","@opentelemetry/context-async-hooks":"^2.9.0","@opentelemetry/exporter-logs-otlp-proto":"^0.220.0","@opentelemetry/exporter-metrics-otlp-proto":"^0.220.0","@opentelemetry/exporter-trace-otlp-proto":"^0.220.0","@opentelemetry/resources":"^2.9.0","@opentelemetry/sdk-logs":"^0.220.0","@opentelemetry/sdk-metrics":"^2.9.0","@opentelemetry/sdk-trace-base":"^2.9.0","@opentelemetry/sdk-trace-node":"^2.9.0","puppeteer-core":"25.3.0"},optionalDependencies:{"@huggingface/transformers":"^4.2.0","sherpa-onnx-node":"1.13.2"},devDependencies:{"@types/bun":"^1.3.14"},engines:{bun:">=1.3.14"},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","LICENSE","THIRD-PARTY-NOTICES.txt","dist/types"],exports:{".":{types:"./dist/types/index.d.ts",import:"./src/index.ts"},"./*":{types:"./dist/types/*.d.ts",import:"./src/*.ts"},"./async":{types:"./dist/types/async/index.d.ts",import:"./src/async/index.ts"},"./async/*":{types:"./dist/types/async/*.d.ts",import:"./src/async/*.ts"},"./autoresearch":{types:"./dist/types/autoresearch/index.d.ts",import:"./src/autoresearch/index.ts"},"./autoresearch/*":{types:"./dist/types/autoresearch/*.d.ts",import:"./src/autoresearch/*.ts"},"./autoresearch/tools/*":{types:"./dist/types/autoresearch/tools/*.d.ts",import:"./src/autoresearch/tools/*.ts"},"./capability":{types:"./dist/types/capability/index.d.ts",import:"./src/capability/index.ts"},"./capability/*":{types:"./dist/types/capability/*.d.ts",import:"./src/capability/*.ts"},"./cli/*":{types:"./dist/types/cli/*.d.ts",import:"./src/cli/*.ts"},"./cli/gallery-fixtures":{types:"./dist/types/cli/gallery-fixtures/index.d.ts",import:"./src/cli/gallery-fixtures/index.ts"},"./cli/gallery-fixtures/*":{types:"./dist/types/cli/gallery-fixtures/*.d.ts",import:"./src/cli/gallery-fixtures/*.ts"},"./cli/commands/*":{types:"./dist/types/cli/commands/*.d.ts",import:"./src/cli/commands/*.ts"},"./commands/*":{types:"./dist/types/commands/*.d.ts",import:"./src/commands/*.ts"},"./commit":{types:"./dist/types/commit/index.d.ts",import:"./src/commit/index.ts"},"./commit/*":{types:"./dist/types/commit/*.d.ts",import:"./src/commit/*.ts"},"./commit/agentic":{types:"./dist/types/commit/agentic/index.d.ts",import:"./src/commit/agentic/index.ts"},"./commit/agentic/*":{types:"./dist/types/commit/agentic/*.d.ts",import:"./src/commit/agentic/*.ts"},"./commit/agentic/tools":{types:"./dist/types/commit/agentic/tools/index.d.ts",import:"./src/commit/agentic/tools/index.ts"},"./commit/agentic/tools/*":{types:"./dist/types/commit/agentic/tools/*.d.ts",import:"./src/commit/agentic/tools/*.ts"},"./commit/analysis":{types:"./dist/types/commit/analysis/index.d.ts",import:"./src/commit/analysis/index.ts"},"./commit/analysis/*":{types:"./dist/types/commit/analysis/*.d.ts",import:"./src/commit/analysis/*.ts"},"./commit/changelog":{types:"./dist/types/commit/changelog/index.d.ts",import:"./src/commit/changelog/index.ts"},"./commit/changelog/*":{types:"./dist/types/commit/changelog/*.d.ts",import:"./src/commit/changelog/*.ts"},"./commit/git/*":{types:"./dist/types/commit/git/*.d.ts",import:"./src/commit/git/*.ts"},"./commit/map-reduce":{types:"./dist/types/commit/map-reduce/index.d.ts",import:"./src/commit/map-reduce/index.ts"},"./commit/map-reduce/*":{types:"./dist/types/commit/map-reduce/*.d.ts",import:"./src/commit/map-reduce/*.ts"},"./commit/utils/*":{types:"./dist/types/commit/utils/*.d.ts",import:"./src/commit/utils/*.ts"},"./config/*":{types:"./dist/types/config/*.d.ts",import:"./src/config/*.ts"},"./dap":{types:"./dist/types/dap/index.d.ts",import:"./src/dap/index.ts"},"./dap/*":{types:"./dist/types/dap/*.d.ts",import:"./src/dap/*.ts"},"./debug":{types:"./dist/types/debug/index.d.ts",import:"./src/debug/index.ts"},"./debug/*":{types:"./dist/types/debug/*.d.ts",import:"./src/debug/*.ts"},"./discovery":{types:"./dist/types/discovery/index.d.ts",import:"./src/discovery/index.ts"},"./discovery/*":{types:"./dist/types/discovery/*.d.ts",import:"./src/discovery/*.ts"},"./edit":{types:"./dist/types/edit/index.d.ts",import:"./src/edit/index.ts"},"./edit/*":{types:"./dist/types/edit/*.d.ts",import:"./src/edit/*.ts"},"./edit/modes/*":{types:"./dist/types/edit/modes/*.d.ts",import:"./src/edit/modes/*.ts"},"./exa":{types:"./dist/types/exa/index.d.ts",import:"./src/exa/index.ts"},"./exa/*":{types:"./dist/types/exa/*.d.ts",import:"./src/exa/*.ts"},"./exec/*":{types:"./dist/types/exec/*.d.ts",import:"./src/exec/*.ts"},"./export/*":{types:"./dist/types/export/*.d.ts",import:"./src/export/*.ts"},"./export/html":{types:"./dist/types/export/html/index.d.ts",import:"./src/export/html/index.ts"},"./export/html/*":{types:"./dist/types/export/html/*.d.ts",import:"./src/export/html/*.ts"},"./extensibility/*":{types:"./dist/types/extensibility/*.d.ts",import:"./src/extensibility/*.ts"},"./extensibility/custom-commands":{types:"./dist/types/extensibility/custom-commands/index.d.ts",import:"./src/extensibility/custom-commands/index.ts"},"./extensibility/custom-commands/*":{types:"./dist/types/extensibility/custom-commands/*.d.ts",import:"./src/extensibility/custom-commands/*.ts"},"./extensibility/custom-commands/bundled/ci-green":{types:"./dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts",import:"./src/extensibility/custom-commands/bundled/ci-green/index.ts"},"./extensibility/custom-commands/bundled/review":{types:"./dist/types/extensibility/custom-commands/bundled/review/index.d.ts",import:"./src/extensibility/custom-commands/bundled/review/index.ts"},"./extensibility/custom-tools":{types:"./dist/types/extensibility/custom-tools/index.d.ts",import:"./src/extensibility/custom-tools/index.ts"},"./extensibility/custom-tools/*":{types:"./dist/types/extensibility/custom-tools/*.d.ts",import:"./src/extensibility/custom-tools/*.ts"},"./extensibility/extensions":{types:"./dist/types/extensibility/extensions/index.d.ts",import:"./src/extensibility/extensions/index.ts"},"./extensibility/extensions/*":{types:"./dist/types/extensibility/extensions/*.d.ts",import:"./src/extensibility/extensions/*.ts"},"./extensibility/hooks":{types:"./dist/types/extensibility/hooks/index.d.ts",import:"./src/extensibility/hooks/index.ts"},"./extensibility/hooks/*":{types:"./dist/types/extensibility/hooks/*.d.ts",import:"./src/extensibility/hooks/*.ts"},"./extensibility/plugins":{types:"./dist/types/extensibility/plugins/index.d.ts",import:"./src/extensibility/plugins/index.ts"},"./extensibility/plugins/*":{types:"./dist/types/extensibility/plugins/*.d.ts",import:"./src/extensibility/plugins/*.ts"},"./extensibility/plugins/marketplace":{types:"./dist/types/extensibility/plugins/marketplace/index.d.ts",import:"./src/extensibility/plugins/marketplace/index.ts"},"./extensibility/plugins/marketplace/*":{types:"./dist/types/extensibility/plugins/marketplace/*.d.ts",import:"./src/extensibility/plugins/marketplace/*.ts"},"./internal-urls":{types:"./dist/types/internal-urls/index.d.ts",import:"./src/internal-urls/index.ts"},"./internal-urls/*":{types:"./dist/types/internal-urls/*.d.ts",import:"./src/internal-urls/*.ts"},"./eval":{types:"./dist/types/eval/index.d.ts",import:"./src/eval/index.ts"},"./eval/js/*":{types:"./dist/types/eval/js/*.d.ts",import:"./src/eval/js/*.ts"},"./eval/py/*":{types:"./dist/types/eval/py/*.d.ts",import:"./src/eval/py/*.ts"},"./lsp":{types:"./dist/types/lsp/index.d.ts",import:"./src/lsp/index.ts"},"./lsp/*":{types:"./dist/types/lsp/*.d.ts",import:"./src/lsp/*.ts"},"./lsp/clients":{types:"./dist/types/lsp/clients/index.d.ts",import:"./src/lsp/clients/index.ts"},"./lsp/clients/*":{types:"./dist/types/lsp/clients/*.d.ts",import:"./src/lsp/clients/*.ts"},"./markit":{types:"./dist/types/markit/index.d.ts",import:"./src/markit/index.ts"},"./markit/*":{types:"./dist/types/markit/*.d.ts",import:"./src/markit/*.ts"},"./mcp":{types:"./dist/types/mcp/index.d.ts",import:"./src/mcp/index.ts"},"./mcp/*":{types:"./dist/types/mcp/*.d.ts",import:"./src/mcp/*.ts"},"./mcp/transports":{types:"./dist/types/mcp/transports/index.d.ts",import:"./src/mcp/transports/index.ts"},"./mcp/transports/*":{types:"./dist/types/mcp/transports/*.d.ts",import:"./src/mcp/transports/*.ts"},"./memories":{types:"./dist/types/memories/index.d.ts",import:"./src/memories/index.ts"},"./memories/*":{types:"./dist/types/memories/*.d.ts",import:"./src/memories/*.ts"},"./memory-backend":{types:"./dist/types/memory-backend/index.d.ts",import:"./src/memory-backend/index.ts"},"./memory-backend/*":{types:"./dist/types/memory-backend/*.d.ts",import:"./src/memory-backend/*.ts"},"./hindsight":{types:"./dist/types/hindsight/index.d.ts",import:"./src/hindsight/index.ts"},"./hindsight/*":{types:"./dist/types/hindsight/*.d.ts",import:"./src/hindsight/*.ts"},"./modes":{types:"./dist/types/modes/index.d.ts",import:"./src/modes/index.ts"},"./modes/*":{types:"./dist/types/modes/*.d.ts",import:"./src/modes/*.ts"},"./modes/acp":{types:"./dist/types/modes/acp/index.d.ts",import:"./src/modes/acp/index.ts"},"./modes/acp/*":{types:"./dist/types/modes/acp/*.d.ts",import:"./src/modes/acp/*.ts"},"./modes/components":{types:"./dist/types/modes/components/index.d.ts",import:"./src/modes/components/index.ts"},"./modes/components/*":{types:"./dist/types/modes/components/*.d.ts",import:"./src/modes/components/*.ts"},"./modes/components/extensions":{types:"./dist/types/modes/components/extensions/index.d.ts",import:"./src/modes/components/extensions/index.ts"},"./modes/components/extensions/*":{types:"./dist/types/modes/components/extensions/*.d.ts",import:"./src/modes/components/extensions/*.ts"},"./modes/components/status-line":{types:"./dist/types/modes/components/status-line/index.d.ts",import:"./src/modes/components/status-line/index.ts"},"./modes/components/status-line/*":{types:"./dist/types/modes/components/status-line/*.d.ts",import:"./src/modes/components/status-line/*.ts"},"./modes/controllers/*":{types:"./dist/types/modes/controllers/*.d.ts",import:"./src/modes/controllers/*.ts"},"./modes/setup-wizard":{types:"./dist/types/modes/setup-wizard/index.d.ts",import:"./src/modes/setup-wizard/index.ts"},"./modes/setup-wizard/*":{types:"./dist/types/modes/setup-wizard/*.d.ts",import:"./src/modes/setup-wizard/*.ts"},"./modes/rpc/*":{types:"./dist/types/modes/rpc/*.d.ts",import:"./src/modes/rpc/*.ts"},"./modes/theme/*":{types:"./dist/types/modes/theme/*.d.ts",import:"./src/modes/theme/*.ts"},"./modes/theme/defaults":{types:"./dist/types/modes/theme/defaults/index.d.ts",import:"./src/modes/theme/defaults/index.ts"},"./modes/utils/*":{types:"./dist/types/modes/utils/*.d.ts",import:"./src/modes/utils/*.ts"},"./plan-mode/*":{types:"./dist/types/plan-mode/*.d.ts",import:"./src/plan-mode/*.ts"},"./prompts/*":"./src/prompts/*.md","./secrets":{types:"./dist/types/secrets/index.d.ts",import:"./src/secrets/index.ts"},"./secrets/*":{types:"./dist/types/secrets/*.d.ts",import:"./src/secrets/*.ts"},"./session/*":{types:"./dist/types/session/*.d.ts",import:"./src/session/*.ts"},"./slash-commands/*":{types:"./dist/types/slash-commands/*.d.ts",import:"./src/slash-commands/*.ts"},"./ssh/*":{types:"./dist/types/ssh/*.d.ts",import:"./src/ssh/*.ts"},"./stt":{types:"./dist/types/stt/index.d.ts",import:"./src/stt/index.ts"},"./stt/*":{types:"./dist/types/stt/*.d.ts",import:"./src/stt/*.ts"},"./task":{types:"./dist/types/task/index.d.ts",import:"./src/task/index.ts"},"./task/*":{types:"./dist/types/task/*.d.ts",import:"./src/task/*.ts"},"./tools":{types:"./dist/types/tools/index.d.ts",import:"./src/tools/index.ts"},"./tools/hub":{types:"./dist/types/tools/hub/index.d.ts",import:"./src/tools/hub/index.ts"},"./tools/hub/*":{types:"./dist/types/tools/hub/*.d.ts",import:"./src/tools/hub/*.ts"},"./tools/*":{types:"./dist/types/tools/*.d.ts",import:"./src/tools/*.ts"},"./tui":{types:"./dist/types/tui/index.d.ts",import:"./src/tui/index.ts"},"./tui/*":{types:"./dist/types/tui/*.d.ts",import:"./src/tui/*.ts"},"./utils/*":{types:"./dist/types/utils/*.d.ts",import:"./src/utils/*.ts"},"./web/*":{types:"./dist/types/web/*.d.ts",import:"./src/web/*.ts"},"./web/scrapers":{types:"./dist/types/web/scrapers/index.d.ts",import:"./src/web/scrapers/index.ts"},"./web/scrapers/*":{types:"./dist/types/web/scrapers/*.d.ts",import:"./src/web/scrapers/*.ts"},"./web/search":{types:"./dist/types/web/search/index.d.ts",import:"./src/web/search/index.ts"},"./web/search/*":{types:"./dist/types/web/search/*.d.ts",import:"./src/web/search/*.ts"},"./web/search/providers/*":{types:"./dist/types/web/search/providers/*.d.ts",import:"./src/web/search/providers/*.ts"},"./*.js":"./src/*.ts"}}});import*as eR from"fs/promises";import*as Nle from"path";function F4s(e,t){let n=(t.trim().toLowerCase().replace(/^\.+/,"")||"bin").replace(/[^a-z0-9]+/g,"_")||"bin",o=C9.version.replace(/[^a-z0-9]+/gi,"_"),i=new Bun.CryptoHasher("sha256").update(e).digest("hex");return`v${LFe}-${o}-${n}-${i}`}function oKr(e){return Nle.join(dYe(),`${e}.json`)}function O2(e){return e instanceof Error?e.message:String(e)}function rKr(e){let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;if(!("version"in t)||t.version!==LFe)return null;if(!("content"in t)||typeof t.content!=="string"||t.content.length===0)return null;return{version:LFe,content:t.content}}async function L4s(e){let t=oKr(e),s;try{s=await Bun.file(t).text()}catch(o){if(!ye(o))P.debug("document conversion cache read failed",{error:O2(o)});return{status:"miss"}}let n;try{n=rKr(s)}catch(o){P.debug("document conversion cache read failed",{error:O2(o)}),n=null}if(!n)return await eR.rm(t,{force:!0}).catch(()=>{return}),{status:"miss"};return{status:"hit",content:n.content}}async function iKr(e){let t;try{t=await eR.readdir(e)}catch(i){if(!ye(i))P.debug("document conversion cache prune failed",{error:O2(i)});return}let s=Date.now(),n=[],o=0;for(let i of t){let r=Nle.join(e,i),a;try{a=await eR.stat(r)}catch(l){if(!ye(l))P.debug("document conversion cache prune failed",{error:O2(l)});continue}if(!a.isFile())continue;if(i.endsWith(".tmp")){if(s-a.mtimeMs>nKr)await eR.rm(r,{force:!0}).catch(()=>{return});continue}if(!i.endsWith(".json"))continue;n.push({path:r,size:a.size,mtimeMs:a.mtimeMs}),o+=a.size}if(o<=_4s)return;n.sort((i,r)=>i.mtimeMs-r.mtimeMs);for(let i of n){if(o<=_4s)break;try{await eR.rm(i.path,{force:!0}),o-=i.size}catch(r){if(!ye(r))P.debug("document conversion cache prune failed",{error:O2(r)})}}}async function N4s(e,t){let s=dYe(),n=Nle.join(s,`${e}.json`),o=Nle.join(s,`${e}.${process.pid}.${Date.now()}.${crypto.randomUUID()}.tmp`),i=JSON.stringify({version:LFe,content:t});try{await eR.mkdir(s,{recursive:!0}),await Bun.write(o,i),await eR.rename(o,n)}catch(r){await eR.rm(o,{force:!0}).catch(()=>{return}),P.debug("document conversion cache write failed",{error:O2(r)});return}iKr(s).catch((r)=>{P.debug("document conversion cache prune failed",{error:O2(r)})})}var LFe=1,_4s=268435456,nKr=300000;var D4s=E(()=>{X();FFe()});var Q;var fi=E(()=>{Q=class Q extends Error{constructor(e){super(e);this.name="ArchiveError"}}});function Pn(e,t){return e[t]|e[t+1]<<8}function Ps(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function VE(e,t){let s=Ps(e,t)+Ps(e,t+4)*4294967296;if(!Number.isSafeInteger(s))throw new Q("Archive uses offsets or sizes too large to read safely");return s}function Dle(e,t){return e[t]<<8|e[t+1]}function TT(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Ud(e,t,s){e[t]=s&255,e[t+1]=s>>>8&255}function zl(e,t,s){e[t]=s&255,e[t+1]=s>>>8&255,e[t+2]=s>>>16&255,e[t+3]=s>>>24&255}function _2(e,t,s){zl(e,t,s>>>0),zl(e,t+4,Math.floor(s/4294967296))}function fc(e,t,s){if(e.byteLength<t+s.length)return!1;for(let n=0;n<s.length;n++)if(e[t+n]!==s.charCodeAt(n))return!1;return!0}var b9;var yT=E(()=>{fi();b9=new TextDecoder});function _f(e){if(!e)return"";let t=e.replace(/\\/g,"/").split("/"),s=[];for(let n of t){if(!n||n===".")continue;if(n==="..")return;s.push(n)}return s.join("/")}function Qr(e){let t=e.replace(/\\/g,"/").split("/"),s=[];for(let n of t){if(!n||n===".")continue;if(n==="..")return;s.push(n)}if(s.length===0)return;return s.join("/")}function U4s(e){return e.endsWith("/")||e.endsWith("\\")}function Dr(e){if(Buffer.byteLength(e,"utf-8")<=q4s)return e;let t=0,s=0;for(let n of e){let o=Buffer.byteLength(n,"utf-8");if(s+o>q4s-3)break;t+=n.length,s+=o}return`${e.slice(0,t)}...`}function No(e,t,s){if(e>s)throw new Q(`Archive ${t} exceeds ${s} bytes`)}function Ff(e,t,s){No(Buffer.byteLength(e,"utf-8"),t,s)}var q4s=256;var Lf=E(()=>{fi()});function Di(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Q("Archive is too large to read safely");if(e>t.maxInMemorySize)throw new Q(`Archive is too large to read in memory (${kt(e)} > ${kt(t.maxInMemorySize)} limit)`)}function Vn(e,t,s){if(!Number.isSafeInteger(e)||e<0)throw new Q(`Invalid archive: ${s} has an invalid size`);if(e>t.maxIndexSize)throw new Q(`Archive ${s} is too large (${kt(e)} > ${kt(t.maxIndexSize)} limit)`)}function Oa(e,t,s){if(!Number.isSafeInteger(e)||e<0)throw new Q(`Archive member '${Dr(t)}' has an invalid size`);if(e>s.maxMemberSize)throw new Q(`Archive member '${Dr(t)}' is too large to extract in memory (${kt(e)} > ${kt(s.maxMemberSize)} limit)`)}function xr(e,t){if(e>t.maxEntries)throw new Q(`Archive has too many entries (> ${t.maxEntries} limit)`)}var qle;var mc=E(()=>{fi();Lf();qle={maxEntries:1e6,maxInMemorySize:268435456,maxIndexSize:67108864,maxMemberSize:67108864,maxPathBytes:4096,maxLinkDepth:40}});function Xc(e,t){let s=e.get(t.path);if(!s)return e.set(t.path,t),t;if(s.isDirectory&&!t.isDirectory)return e.set(t.path,t),t;if(!s.isDirectory&&t.isDirectory)return;let n={...t,mtimeMs:t.mtimeMs??s.mtimeMs,mode:t.mode??s.mode,storage:t.storage??s.storage};return e.set(t.path,n),n}function iD(e,t){xr(e.size,t);for(let s of[...e.values()]){let n=s.path.split("/"),o=n.length-1;for(let i=1;i<=o;i++){let r=n.slice(0,i).join("/");if(!r||e.has(r))continue;e.set(r,{path:r,isDirectory:!0,size:0}),xr(e.size,t)}}}function F2(e,t,s){let n=t,o=new Set;for(let i=0;!o.has(n);){o.add(n);let r;for(let a=n.length;a>0;a=n.lastIndexOf("/",a-1)){let l=e.get(n.slice(0,a));if(l?.storage?.type!=="link"||!l.isDirectory&&!l.storage.resolveTarget)continue;let u=n.slice(a+1);r=u?l.storage.targetPath?`${l.storage.targetPath}/${u}`:u:l.storage.targetPath;break}if(r===void 0)return n;if(++i>s)break;n=r}throw new Q(`Archive path '${t}' crosses a cyclic symlink`)}var aD=E(()=>{fi();mc()});function aKr(e,t){throw new Q(`Archive symlink '${Dr(t)}' cannot be materialized from target '${Dr(e)}'`)}class mRt{format;limits;#e=new Map;constructor(e,t,s=qle){this.format=e,this.limits=s;for(let n of t)Xc(this.#e,n);iD(this.#e,s)}indexEntries(){return this.#e.values()}getNode(e){let t=_f(e);if(t===void 0)return;if(t==="")return{path:"",isDirectory:!0,size:0};let s=F2(this.#e,t,this.limits.maxLinkDepth);if(s==="")return{path:t,isDirectory:!0,size:0};let n=this.#e.get(s);if(!n)return;return{path:t,isDirectory:n.isDirectory,size:n.size,mtimeMs:n.mtimeMs,mode:n.mode}}listDirectory(e){let t=_f(e);if(t===void 0)throw new Q("Archive path cannot contain '..'");let s=t?F2(this.#e,t,this.limits.maxLinkDepth):"";if(t&&s!==""){let i=this.#e.get(s);if(!i)throw new Q(`Archive path '${t}' not found`);if(!i.isDirectory)throw new Q(`Archive path '${t}' is not a directory`)}let n=s?`${s}/`:"",o=new Map;for(let i of this.#e.values()){if(s){if(!i.path.startsWith(n)||i.path===s)continue}let r=s?i.path.slice(n.length):i.path,a=r.split("/")[0];if(!a)continue;let l=t?`${t}/${a}`:a;if(o.has(l))continue;let u=s?`${s}/${a}`:a,p=F2(this.#e,u,this.limits.maxLinkDepth),c=p?this.#e.get(p):void 0,d=p===""||c?.isDirectory===!0||r.includes("/");o.set(l,{name:a,path:l,isDirectory:d,size:d?0:c?.size??i.size,mtimeMs:c?.mtimeMs??i.mtimeMs,mode:c?.mode??i.mode})}return[...o.values()].sort((i,r)=>i.name.toLowerCase().localeCompare(r.name.toLowerCase()))}async readFile(e){let t=_f(e);if(!t)throw new Q("Archive file path is required");let s=F2(this.#e,t,this.limits.maxLinkDepth);if(s==="")throw new Q(`Archive path '${t}' is a directory`);let n=this.#e.get(s);if(!n)throw new Q(`Archive file '${t}' not found`);if(n.isDirectory)throw new Q(`Archive path '${t}' is a directory`);if(!n.storage)throw new Q(`Archive file '${t}' has no readable storage`);if(Oa(n.size,t,this.limits),n.storage.type==="link")aKr(n.storage.targetPath,t);let o=await n.storage.source.read(n.size,t);return{path:t,isDirectory:!1,size:n.size,mtimeMs:n.mtimeMs,mode:n.mode,bytes:o}}}var gRt=E(()=>{aD();fi();mc();Lf()});function Ca(e,t=0){return Bun.hash.crc32(e,t)>>>0}function W4s(e,t=0n){let s=t^0xffffffffffffffffn,n=Number(s&0xffffffffn)>>>0,o=Number(s>>32n&0xffffffffn)>>>0;for(let i=0;i<e.length;i++){let r=(n^e[i])&255;n=((n>>>8|(o&255)<<24)>>>0^H4s[r])>>>0,o=(o>>>8^B4s[r])>>>0}return(BigInt(o)<<32n|BigInt(n))^0xffffffffffffffffn}function S9(e,t=0){let s=t;for(let n=0;n<e.length;n++)s=(s>>>8^G4s[(s^e[n])&255])&65535;return s}var H4s,B4s,G4s;var uP=E(()=>{H4s=new Uint32Array(256),B4s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e,s=0;for(let n=0;n<8;n++){let o=(t&1)!==0;if(t=(t>>>1|(s&1)<<31)>>>0,s>>>=1,o)t=(t^3615952706)>>>0,s=(s^3379320725)>>>0}H4s[e]=t,B4s[e]=s}G4s=new Uint16Array(256);for(let e=0;e<256;e++){let t=e;for(let s=0;s<8;s++)t=(t&1)!==0?t>>>1^40961:t>>>1;G4s[e]=t}});function $4s(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<e)throw new Q("Invalid archive range")}function z4s(e,t,s){if($4s(t,s),s>e.byteLength)throw new Q("Invalid archive: truncated data");return e.subarray(t,s)}function NFe(e){return{size:e.byteLength,async read(t,s){return z4s(e,t,s)}}}function hRt(e){let t=Bun.file(e),s=t.size;if(!Number.isSafeInteger(s))throw new Q("Archive is too large to read safely");return{size:s,async read(n,o){$4s(n,o);let i=await t.slice(n,o).bytes();if(i.byteLength!==o-n)throw new Q("Invalid archive: truncated data");return i}}}async function KE(e){return e.read(0,e.size)}var YE=E(()=>{fi()});class yRt{#e;#t;#s=0;constructor(e,t){this.#e=e,this.#t=t}read(e){if(!Number.isInteger(e)||e<0||e>24||this.#s+e>this.#e.byteLength*8)throw new Q(`Invalid ${this.#t} compressed data: truncated bitstream`);let t=0;for(let s=0;s<e;s++){let n=this.#s++;t=t*2+(this.#e[n>>>3]>>>7-(n&7)&1)}return t}assertZeroPadding(){while(this.#s<this.#e.byteLength*8)if(this.read(1)!==0)throw new Q(`Invalid ${this.#t} compressed data: non-zero trailing bits`)}}class cP{#e=[-1];#t=[-1];#s=[-1];#n;constructor(e){this.#n=e}static single(e,t,s){if(!Number.isInteger(e)||e<0||e>=t)throw new Q(`Invalid ${s} Huffman table: symbol is out of range`);let n=new cP(s);return n.#s[0]=e,n}static build(e,t,s){let n=new Uint32Array(17),o=0;for(let l=0;l<t;l++){let u=e[l];if(u>16)throw new Q(`Invalid ${s} Huffman table: code is too long`);if(u!==0)n[u]++,o=Math.max(o,u)}if(o===0)throw new Q(`Invalid ${s} Huffman table: no symbols`);let i=new Uint32Array(17),r=0;for(let l=1;l<=16;l++){if(r=(r+n[l-1])*2,r+n[l]>2**l)throw new Q(`Invalid ${s} Huffman table: oversubscribed codes`);i[l]=r}if(i[o]+n[o]!==2**o)throw new Q(`Invalid ${s} Huffman table: incomplete codes`);let a=new cP(s);for(let l=0;l<t;l++){let u=e[l];if(u===0)continue;let p=i[u];i[u]=p+1;let c=0;for(let d=u-1;d>=0;d--){if(a.#s[c]>=0)throw new Q(`Invalid ${s} Huffman table: prefix collision`);let f=p>>>d&1,m=f===0?a.#e[c]:a.#t[c];if(m<0)if(m=a.#s.length,a.#e.push(-1),a.#t.push(-1),a.#s.push(-1),f===0)a.#e[c]=m;else a.#t[c]=m;c=m}if(a.#s[c]>=0||a.#e[c]>=0||a.#t[c]>=0)throw new Q(`Invalid ${s} Huffman table: duplicate code`);a.#s[c]=l}return a}decode(e){let t=0;for(let s=0;s<=16;s++){let n=this.#s[t];if(n>=0)return n;if(t=e.read(1)===0?this.#e[t]:this.#t[t],t<0)throw new Q(`Invalid ${this.#n} Huffman code`)}throw new Q(`Invalid ${this.#n} Huffman code: excessive depth`)}}function X4s(e,t){let s=e.read(3);if(s===7){while(e.read(1)!==0)if(s++,s>16)throw new Q(`Invalid ${t} Huffman table: code is too long`)}return s}function pKr(e,t){let n=e.read(5);if(n===0)return cP.single(e.read(5),19,t);if(n>19)throw new Q(`Invalid ${t} temporary Huffman table size`);let o=new Uint8Array(19),i=0;while(i<n)if(o[i++]=X4s(e,t),i===3){let r=e.read(2);if(i+r>n)throw new Q(`Invalid ${t} temporary Huffman table`);i+=r}return cP.build(o,19,t)}function cKr(e,t,s){let o=e.read(9);if(o===0)return cP.single(e.read(9),510,s);if(o>510)throw new Q(`Invalid ${s} command Huffman table size`);let i=new Uint8Array(510),r=0;while(r<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(r+l>o)throw new Q(`Invalid ${s} command Huffman table`);r+=l}else i[r++]=a-2}return cP.build(i,510,s)}function dKr(e,t,s,n){let o=e.read(t);if(o===0)return cP.single(e.read(t),s,n);if(o>s)throw new Q(`Invalid ${n} position Huffman table size`);let i=new Uint8Array(s);for(let r=0;r<o;r++)i[r]=X4s(e,n);return cP.build(i,s,n)}function k9(e,t,s,n,o,i){let r=new yRt(e,i),a=new Uint8Array(t),l=0,u=0,p,c;while(l<t){if(u===0){if(u=r.read(16),u===0)throw new Q(`Invalid ${i} compressed data: empty block`);let T=pKr(r,i);p=cKr(r,T,i),c=dKr(r,n,o,i)}u--;let d=p.decode(r);if(d<256){a[l++]=d;continue}let f=d-256+3;if(f>t-l)throw new Q(`Invalid ${i} compressed data: match exceeds declared size`);let m=c.decode(r),g=m;if(m>1){let T=m-1;g=2**T+r.read(T)}if(g>=s||g>=l)throw new Q(`Invalid ${i} 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 Q(`Invalid ${i} compressed data: block exceeds declared size`);return r.assertZeroPadding(),a}function fKr(e,t){let s=new yRt(e,"LZH -lzs-"),n=new Uint8Array(t),o=new Uint8Array(2048);o.fill(32);let i=2031,r=0,a=(l)=>{if(r>=t)throw new Q("Invalid LZH -lzs- data: output exceeds declared size");n[r++]=l,o[i]=l,i=i+1&2047};while(r<t)if(s.read(1)!==0)a(s.read(8));else{let l=s.read(11),u=s.read(4)+2;if(u>t-r)throw new Q("Invalid LZH -lzs- data: match exceeds declared size");for(let p=0;p<u;p++)a(o[l+p&2047])}return s.assertZeroPadding(),n}function gKr(e,t,s){if(t<0)return S9(e);let n=S9(e.subarray(0,t));return n=S9(mKr.subarray(0,s-t),n),S9(e.subarray(s),n)}function pP(e,t){return e[t]|e[t+1]<<8}function XE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function j4s(e,t){let s=XE(e,t)+XE(e,t+4)*4294967296;if(!Number.isSafeInteger(s))throw new Q("LZH uses sizes too large to read safely");return s}function Ule(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.byteLength)throw new Q(`Invalid LZH archive: truncated ${n}`)}function TRt(e){let t=e.indexOf(0);if(t<0)t=e.byteLength;return lKr.decode(e.subarray(0,t))}function V4s(e){if((e.byteLength&1)!==0)throw new Q("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 uKr.decode(e.subarray(0,t))}function hKr(e){if(e===0)return;let t=1980+(e>>>25&127),s=e>>>21&15,n=e>>>16&31,o=e>>>11&31,i=e>>>5&63,r=(e&31)*2;if(s<1||s>12||n<1||n>31||o>23||i>59||r>59)return;return Date.UTC(t,s-1,n,o,i,r)}function K4s(e,t,s,n){switch(e){case 0:if(t.byteLength<2)throw new Q("Invalid LZH common extended header");n.commonCrc=pP(t,0),n.commonCrcOffset=s;break;case 1:n.filename=TRt(t);break;case 2:n.directory=TRt(t).replaceAll("\xFF","/");break;case 57:throw new Q("Multi-volume LZH archives are unsupported");case 65:if(t.byteLength>=16){let o=XE(t,8),i=XE(t,12),r=o+i*4294967296;if(Number.isSafeInteger(r))n.mtimeMs=r/1e4-11644473600000}break;case 66:if(t.byteLength<16)throw new Q("Invalid LZH 64-bit size extended header");n.packedSize=j4s(t,0),n.size=j4s(t,8);break;case 68:n.unicodeFilename=V4s(t);break;case 69:n.unicodeDirectory=V4s(t).replaceAll("\xFF","/");break;case 80:if(t.byteLength<2)throw new Q("Invalid LZH Unix permissions extended header");n.mode=pP(t,0);break;case 84:if(t.byteLength<4)throw new Q("Invalid LZH Unix timestamp extended header");n.mtimeMs=XE(t,0)*1000;break}}class J4s{#e;#t;#s;#n;#o;constructor(e,t,s,n,o){this.#e=e,this.#t=t,this.#s=s,this.#n=n,this.#o=o}async read(e,t){let s=this.#e.subarray(this.#t,this.#t+this.#s),n;switch(this.#n){case"-lh0-":case"-lz4-":if(s.byteLength!==e)throw new Q(`LZH member '${t}' has inconsistent stored size`);n=s.slice();break;case"-lh4-":n=k9(s,e,4096,4,13,"LZH -lh4-");break;case"-lh5-":n=k9(s,e,8192,4,14,"LZH -lh5-");break;case"-lh6-":n=k9(s,e,32768,5,16,"LZH -lh6-");break;case"-lh7-":n=k9(s,e,65536,5,17,"LZH -lh7-");break;case"-lzs-":n=fKr(s,e);break;case"-lh1-":throw new Q(`LZH member '${t}' uses unsupported dynamic-Huffman method -lh1-`);default:throw new Q(`LZH member '${t}' uses unsupported compression method ${this.#n}`)}if(n.byteLength!==e)throw new Q(`LZH member '${t}' extracted to an unexpected size`);if(S9(n)!==this.#o)throw new Q(`LZH member '${t}' failed CRC-16 verification`);return n}}function TKr(e,t,s){Ule(e,t,t+22,"header");let n=e[t+20];if(n>2)throw new Q(`Unsupported LZH header level ${n}`);let o=String.fromCharCode(...e.subarray(t+2,t+7));if(!Y4s.test(o))throw new Q(`Invalid LZH compression method '${o}'`);let i=XE(e,t+7),r=XE(e,t+11),a=0,l,u,p=0,c,d={};if(n<2){let T=e[t];if(T<(n===0?22:25))throw new Q(`Invalid LZH level-${n} header size`);let C=t+T+2;Ule(e,t,C,"header");let w=0;for(let A=t+2;A<C;A++)w=w+e[A]&255;if(w!==e[t+1])throw new Q("Invalid LZH header checksum");let x=e[t+21];if(22+x+2>T+2)throw new Q("Invalid LZH filename length");if(No(x,"member path",s.limits.maxPathBytes),l=TRt(e.subarray(t+22,t+22+x)),a=pP(e,t+22+x),u=hKr(XE(e,t+15)),n===0){let A=t+24+x;if(C-A>=12){let I=e.subarray(A,C);if((I[0]===85||I[0]===75)&&I[1]===0)p=I[0],d.mtimeMs=XE(I,2)*1000,d.mode=pP(I,I.byteLength-6)}c=C}else{p=e[t+24+x];let A=pP(e,C-2),I=C,M=0,O=0;while(A!==0){if(A<3)throw new Q("Invalid LZH extended header size");if(Ule(e,I,I+A,"extended header"),M+=A,Vn(T+2+M,s.limits,"header metadata"),++O>65535)throw new Q("Invalid LZH archive: too many extended headers");let _=e[I],F=I+A-2,L=e.subarray(I+1,F);if(_===1||_===2||_===68||_===69)No(L.byteLength,"member path",s.limits.maxPathBytes);K4s(_,L,I+1,d);let D=A;A=pP(e,F),I+=D}if(c=C+M,i=d.packedSize??i-M,i<0)throw new Q("Invalid LZH level-1 packed size")}}else{let T=pP(e,t);if(T<26)throw new Q("Invalid LZH level-2 header size");let R=t+T;Ule(e,t,R,"header"),a=pP(e,t+21),p=e[t+23],u=XE(e,t+15)*1000;let C=t+24,w=0;while(C+2<=R){let x=pP(e,C);if(x===0){C+=2;break}if(x<3||C+x>R)throw new Q("Invalid LZH extended header size");if(++w>65535)throw new Q("Invalid LZH archive: too many extended headers");let A=e[C+2],I=e.subarray(C+3,C+x);if(A===1||A===2||A===68||A===69)No(I.byteLength,"member path",s.limits.maxPathBytes);K4s(A,I,C+3,d),C+=x}if(C!==R)throw new Q("Invalid LZH level-2 extended header chain");c=R,i=d.packedSize??i}if(n===1&&p===32&&o==="-lh7-")throw new Q("LZH uses the incompatible LHARK -lh7- variant");r=d.size??r,u=d.mtimeMs??u;let f=d.mode;if(d.commonCrc!==void 0){let T=d.commonCrcOffset-t;if(gKr(e.subarray(t,c),T,T+2)!==d.commonCrc)throw new Q("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 Ff(h,"member path",s.limits.maxPathBytes),Oa(r,h||"<unnamed>",s.limits),Ule(e,c,c+i,"member data"),{method:o,packedSize:i,size:r,dataStart:c,nextOffset:c+i,crc:a,path:Qr(h),mtimeMs:u,mode:f}}function RRt(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 Y4s.test(t)&&e[20]<=2}var lKr,uKr,Y4s,mKr,Q4s=async(e,t)=>{Di(e.size,t.limits);let s;try{s=await KE(e)}catch(a){if(a instanceof Q)throw a;throw new Q(`Unable to read LZH archive: ${a instanceof Error?a.message:String(a)}`)}if(s.byteLength!==e.size)throw new Q("Invalid LZH archive: truncated data");if(!RRt(s))throw new Q("Invalid LZH archive header");let n=[],o=0,i=0,r=0;while(o<s.byteLength&&s[o]!==0){let a=TKr(s,o,t);if(r+=a.dataStart-o,Vn(r,t.limits,"index"),xr(++i,t.limits),a.nextOffset<=o)throw new Q("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 Q(`Invalid LZH symbolic link '${a.path}'`);let p=Qr(a.path.slice(0,u)),c=Qr(a.path.slice(u+1));if(!p||!c)continue;n.push({path:p,isDirectory:!1,size:0,mtimeMs:a.mtimeMs,mode:a.mode,storage:{type:"link",targetPath:c,resolveTarget:!1}});continue}n.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 J4s(s,a.dataStart,a.packedSize,a.method,a.crc)}})}if(n.length===0&&i===0)throw new Q("Invalid LZH archive: no members");return n};var CRt=E(()=>{uP();fi();mc();Lf();YE();lKr=new TextDecoder("windows-1252"),uKr=new TextDecoder("utf-16"),Y4s=/^-(?:lh[0-7d]|lz[45s])-$/;mKr=new Uint8Array(2)});function DFe(e,t){return e[t]|e[t+1]<<8}function L2(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Hle(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.byteLength)throw new Q(`Invalid ARJ archive: truncated ${n}`)}function RKr(e){if(e===0)return;let t=1980+(e>>>25&127),s=e>>>21&15,n=e>>>16&31,o=e>>>11&31,i=e>>>5&63,r=(e&31)*2;if(s<1||s>12||n<1||n>31||o>23||i>59||r>59)return;return Date.UTC(t,s-1,n,o,i,r)}function Z4s(e,t,s,n){let o=t;while(o<s&&e[o]!==0)o++;if(o===s)throw new Q(`Invalid ARJ ${n}: missing terminator`);return{value:yKr.decode(e.subarray(t,o)),next:o+1}}function eVs(e,t,s){if(Hle(e,t,t+4,"header signature"),e[t]!==tVs||e[t+1]!==sVs)throw new Q("Invalid ARJ header signature");let n=DFe(e,t+2);if(n===0)return{bodyStart:t+4,bodySize:0,nextOffset:t+4,metadataSize:4,isEnd:!0};if(n<30||n>nVs)throw new Q("Invalid ARJ basic header size");let o=t+4,i=o+n;if(Hle(e,o,i+4,"basic header"),Ca(e.subarray(o,i))!==L2(e,i))throw new Q("Invalid ARJ basic header CRC32");let r=i+4,a=0;for(;;){Hle(e,r,r+2,"extended header size");let l=DFe(e,r);if(r+=2,l===0)break;if(++a>65535)throw new Q("Invalid ARJ archive: too many extended headers");if(Hle(e,r,r+l+4,"extended header"),Ca(e.subarray(r,r+l))!==L2(e,r+l))throw new Q("Invalid ARJ extended header CRC32");r+=l+4,Vn(r-t,s.limits,"header metadata")}return{bodyStart:o,bodySize:n,nextOffset:r,metadataSize:r-t,isEnd:!1}}class oVs{#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 Q("Invalid ARJ method-4 compressed data: truncated bitstream");let t=0;for(let s=0;s<e;s++){let n=this.#t++;t=t*2+(this.#e[n>>>3]>>>7-(n&7)&1)}return t}assertZeroPadding(){while(this.#t<this.#e.byteLength*8)if(this.read(1)!==0)throw new Q("Invalid ARJ method-4 compressed data: non-zero trailing bits")}}function CKr(e,t){let s=new oVs(e),n=new Uint8Array(t),o=0;while(o<t){let i=0,r=0;for(;r<7;r++){if(s.read(1)===0)break;i+=2**r}if(r!==0)i+=s.read(r);if(i===0){n[o++]=s.read(8);continue}let a=i+2;if(a>t-o)throw new Q("Invalid ARJ method-4 compressed data: match exceeds declared size");let l=0,u=9;for(;u<13;u++){if(s.read(1)===0)break;l+=2**u}if(l+=s.read(u),l>=26624||l>=o)throw new Q("Invalid ARJ method-4 compressed data: history distance is out of range");let p=o-l-1;for(let c=0;c<a;c++)n[o++]=n[p++]}return s.assertZeroPadding(),n}class rVs{#e;#t;#s;#n;#o;constructor(e,t,s,n,o){this.#e=e,this.#t=t,this.#s=s,this.#n=n,this.#o=o}async read(e,t){let s=this.#e.subarray(this.#t,this.#t+this.#s),n;switch(this.#n){case 0:if(s.byteLength!==e)throw new Q(`ARJ member '${t}' has inconsistent stored size`);n=s.slice();break;case 1:case 2:case 3:n=k9(s,e,26624,5,17,`ARJ method ${this.#n}`);break;case 4:n=CKr(s,e);break;case 8:case 9:if(e!==0||s.byteLength!==0)throw new Q(`ARJ member '${t}' has invalid no-data method sizes`);n=new Uint8Array(0);break;default:throw new Q(`ARJ member '${t}' uses unsupported compression method ${this.#n}`)}if(n.byteLength!==e)throw new Q(`ARJ member '${t}' extracted to an unexpected size`);if(this.#n!==8&&Ca(n)!==this.#o)throw new Q(`ARJ member '${t}' failed CRC32 verification`);return n}}function bKr(e,t){let s=e.replaceAll("\\","/");if(t===1)s=s.replaceAll(">","/");else if(t===4)s=s.replaceAll(":","/");return s}function bRt(e){if(e.byteLength<34||e[0]!==tVs||e[1]!==sVs)return!1;let t=DFe(e,2);if(t<30||t>nVs||e.byteLength<t+8)return!1;let s=e.subarray(4,4+t);return s[0]>=30&&s[0]<=t&&s[6]===2&&Ca(s)===L2(e,4+t)}var tVs=96,sVs=234,nVs=2600,yKr,iVs=async(e,t)=>{Di(e.size,t.limits);let s;try{s=await KE(e)}catch(p){if(p instanceof Q)throw p;throw new Q(`Unable to read ARJ archive: ${p instanceof Error?p.message:String(p)}`)}if(s.byteLength!==e.size)throw new Q("Invalid ARJ archive: truncated data");if(!bRt(s))throw new Q("Invalid ARJ archive header");let n=eVs(s,0,t);if(n.isEnd)throw new Q("Invalid ARJ archive: missing main header");let o=s[n.bodyStart];if(o<30||o>n.bodySize||s[n.bodyStart+6]!==2)throw new Q("Invalid ARJ main header");let i=s[n.bodyStart+4];if((i&1)!==0)throw new Q("Encrypted ARJ archives are unsupported");if((i&4)!==0)throw new Q("Multi-volume ARJ archives are unsupported");let r=[],a=n.nextOffset,l=n.metadataSize,u=0;for(;;){let p=eVs(s,a,t);if(l+=p.metadataSize,Vn(l,t.limits,"index"),p.isEnd)break;xr(++u,t.limits);let c=s[p.bodyStart];if(c<30||c>p.bodySize)throw new Q("Invalid ARJ local header");let d=s[p.bodyStart+3],f=s[p.bodyStart+4],m=s[p.bodyStart+5],g=s[p.bodyStart+6];if((f&1)!==0)throw new Q("Encrypted ARJ members are unsupported");if((f&12)!==0)throw new Q("Multi-volume ARJ members are unsupported");let h=L2(s,p.bodyStart+12),T=L2(s,p.bodyStart+16),R=L2(s,p.bodyStart+20),C=DFe(s,p.bodyStart+26),w=Z4s(s,p.bodyStart+c,p.bodyStart+p.bodySize,"filename");Z4s(s,w.next,p.bodyStart+p.bodySize,"comment"),No(w.next-(p.bodyStart+c)-1,"member path",t.limits.maxPathBytes);let x=bKr(w.value,d);Ff(x,"member path",t.limits.maxPathBytes),Oa(T,x||"<unnamed>",t.limits);let A=p.nextOffset;Hle(s,A,A+h,"member data"),a=A+h;let I=Qr(x);if(!I)continue;let M=g===3,O;if((d===2||d===8)&&C!==0)O=(M?16384:32768)|C&4095;let _=L2(s,p.bodyStart+8),F=d===2||d===8?_===0?void 0:_*1000:RKr(_);r.push({path:I,isDirectory:M,size:M?0:T,mtimeMs:F,mode:O,storage:M?void 0:{type:"member",source:new rVs(s,A,h,m,R)}})}if(u===0)throw new Q("Invalid ARJ archive: no members");return r};var aVs=E(()=>{uP();fi();mc();CRt();Lf();YE();yKr=new TextDecoder("windows-1252")});import*as uVs from"path";function na(e){return new Q(`Invalid ASAR archive: ${e}`)}function UFe(e){return e instanceof Error&&e.message?e.message:String(e)}function SRt(e){return e+(4-e%4)%4}function Ble(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function xKr(e,t,s){if(e===void 0)return;let n=Dr(t);if(!Ble(e))throw na(`file '${n}' has an invalid integrity record`);if(e.algorithm!=="SHA256")throw na(`file '${n}' uses unsupported integrity algorithm '${String(e.algorithm)}'`);if(typeof e.hash!=="string"||!lVs.test(e.hash))throw na(`file '${n}' has an invalid integrity hash`);if(typeof e.blockSize!=="number"||!Number.isSafeInteger(e.blockSize)||e.blockSize<=0)throw na(`file '${n}' has an invalid integrity block size`);if(!Array.isArray(e.blocks))throw na(`file '${n}' has invalid integrity blocks`);let o=Math.max(1,Math.ceil(s/e.blockSize));if(e.blocks.length!==o)throw na(`file '${n}' has an inconsistent integrity block count`);for(let i of e.blocks)if(typeof i!=="string"||!lVs.test(i))throw na(`file '${n}' has an invalid integrity block hash`);return{algorithm:"SHA256",hash:e.hash.toLowerCase()}}function pVs(e,t,s){if(!t)return;if(new Bun.CryptoHasher("sha256").update(e).digest("hex")!==t.hash)throw new Q(`ASAR member '${Dr(s)}' failed SHA256 integrity verification`)}class cVs{#e;#t;#s;#n;constructor(e,t,s,n){this.#e=e,this.#t=t,this.#s=s,this.#n=n}async read(e,t){if(e!==this.#s)throw new Q(`ASAR member '${Dr(t)}' has an inconsistent size`);let s;try{s=await this.#e.read(this.#t,this.#t+this.#s)}catch(n){if(n instanceof Q)throw n;throw new Q(`Failed to read ASAR member '${Dr(t)}': ${UFe(n)}`)}if(s.byteLength!==this.#s)throw new Q(`ASAR member '${Dr(t)}' is truncated`);return pVs(s,this.#n,t),s}}class dVs{#e;#t;#s;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}async read(e,t){let s=Dr(t);if(e!==this.#t)throw new Q(`ASAR member '${s}' has an inconsistent size`);if(!this.#e)throw new Q(`Archive file '${s}' is unpacked and requires a filesystem-backed ASAR archive`);let n=Bun.file(this.#e),o=await n.stat().catch(()=>{throw new Q(`Unpacked ASAR file '${s}' was not found`)});if(o.isDirectory())throw new Q(`Unpacked ASAR file '${s}' is a directory`);if(o.size!==this.#t)throw new Q(`Unpacked ASAR file '${s}' size differs from its archive header (${o.size} != ${this.#t} bytes)`);let i;try{i=await n.bytes()}catch(r){throw new Q(`Failed to read unpacked ASAR file '${s}': ${UFe(r)}`)}if(i.byteLength!==this.#t)throw new Q(`Unpacked ASAR file '${s}' changed while being read`);return pVs(i,this.#s,t),i}}async function vKr(e,t){if(!Number.isSafeInteger(e.size)||e.size<qFe)throw na("truncated header");let s=await e.read(0,w9);if(s.byteLength!==w9)throw na("truncated size pickle");if(Ps(s,0)!==4)throw na("invalid size pickle");let n=Ps(s,4);if(n<Wle)throw na("header is too small");Vn(n,t.limits,"ASAR header");let o=w9+n;if(!Number.isSafeInteger(o)||o>e.size)throw na("header extends beyond archive boundary");let i=await e.read(w9,o);if(i.byteLength!==n)throw na("truncated header pickle");let r=Ps(i,0),a=Ps(i,4);if(r+4!==n||r!==4+SRt(a))throw na("inconsistent pickle lengths");let l=Wle+a;for(let g=l;g<i.byteLength;g++)if(i[g]!==0)throw na("non-zero pickle string padding");let u;try{u=SKr.decode(i.subarray(Wle,l))}catch{throw na("header is not valid UTF-8")}let p;try{p=JSON.parse(u)}catch{throw na("header is not valid JSON")}if(!Ble(p)||!Ble(p.files))throw na("root must contain a files object");let c=[],d=[],f=0,m=(g,h,T)=>{for(let R in g)xr(++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(No(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 na(`invalid entry name '${Dr(g.name)}'`);if(!Ble(g.node))throw na(`entry '${Dr(g.name)}' must be an object`);let T=g.parentPathBytes+(g.parentPath?1:0)+h;No(T,"member path",t.limits.maxPathBytes);let R=g.parentPath?`${g.parentPath}/${g.name}`:g.name;if(Qr(R)!==R)throw na(`invalid entry path '${Dr(R)}'`);let w=Dr(R);if(g.node.unpacked!==void 0&&typeof g.node.unpacked!=="boolean")throw na(`entry '${w}' has a non-boolean unpacked flag`);if("link"in g.node){if(typeof g.node.link!=="string"||g.node.link.length===0)throw na(`entry '${w}' has an invalid link target`);Ff(g.node.link,"link target",t.limits.maxPathBytes);let F=g.node.link.replace(/\\/g,"/"),L=F.startsWith("/")||/^[A-Za-z]:\//.test(F)?void 0:_f(F);if(L===void 0)throw na(`entry '${w}' links outside the archive`);c.push({path:R,isDirectory:!1,size:0,storage:{type:"link",targetPath:L,resolveTarget:!0}});continue}if("files"in g.node){if(!Ble(g.node.files))throw na(`directory '${w}' must contain a files object`);c.push({path:R,isDirectory:!0,size:0}),m(g.node.files,R,T);continue}let x=g.node.size;if(typeof x!=="number"||!Number.isSafeInteger(x)||x<0)throw na(`file '${w}' has an invalid size`);if(Oa(x,R,t.limits),g.node.executable!==void 0&&typeof g.node.executable!=="boolean")throw na(`file '${w}' has a non-boolean executable flag`);let A=typeof g.node.executable==="boolean"?wKr|(g.node.executable?493:420):void 0,I=xKr(g.node.integrity,R,x);if(g.node.unpacked===!0){let F=t.archivePath?uVs.join(`${t.archivePath}.unpacked`,...R.split("/")):void 0;c.push({path:R,isDirectory:!1,size:x,mode:A,storage:{type:"member",source:new dVs(F,x,I)}});continue}if(typeof g.node.offset!=="string"||!/^\d+$/.test(g.node.offset))throw na(`file '${w}' has an invalid offset`);let M=Number(g.node.offset),O=o+M,_=O+x;if(!Number.isSafeInteger(M)||!Number.isSafeInteger(O)||!Number.isSafeInteger(_)||_>e.size)throw na(`file '${w}' extends beyond archive boundary`);c.push({path:R,isDirectory:!1,size:x,mode:A,storage:{type:"member",source:new cVs(e,O,x,I)}})}return c}function mVs(e){if(e.byteLength<qFe+1)return!1;let t=Ps(e,0),s=Ps(e,4),n=Ps(e,8),o=Ps(e,12);return t===4&&s>=Wle&&s===n+4&&n===4+SRt(o)&&o>0&&e[qFe]===123}function EKr(e){let t=e.replace(/\\/g,"/"),s=Qr(t);if(s===void 0||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.includes("\x00")||t.split("/").some((n)=>!n||n==="."||n===".."))throw new Q(`Invalid ASAR member path '${Dr(e)}'`);return s}async function gVs(e){try{let t={files:Object.create(null)},s=[],n=0;for(let d of e){if(!Array.isArray(d)||d.length!==2||typeof d[0]!=="string"||!(d[1]instanceof Uint8Array))throw new Q("ASAR members must be [path, Uint8Array] pairs");let f=EKr(d[0]),m=f.split("/"),g=t;for(let T=0;T<m.length-1;T++){let R=m[T],C=g.files[R];if(C&&!("files"in C))throw new Q(`ASAR member path '${f}' crosses file '${m.slice(0,T+1).join("/")}'`);if(!C)g.files[R]={files:Object.create(null)};g=g.files[R]}let h=m.at(-1);if(g.files[h])throw new Q(`Duplicate or conflicting ASAR member path '${f}'`);if(!Number.isSafeInteger(d[1].byteLength)||!Number.isSafeInteger(n+d[1].byteLength))throw new Q("ASAR payload is too large to encode safely");g.files[h]={size:d[1].byteLength,offset:String(n)},s.push(d[1]),n+=d[1].byteLength}let o=kKr.encode(JSON.stringify(t)),r=4+SRt(o.byteLength),a=4+r;if(o.byteLength>4294967295||a>4294967295)throw new Q("ASAR header is too large to encode");let l=w9+a,u=l+n;if(!Number.isSafeInteger(u))throw new Q("ASAR archive is too large to encode safely");let p;try{p=new Uint8Array(u)}catch{throw new Q("ASAR archive is too large to encode in memory")}zl(p,0,4),zl(p,4,a),zl(p,8,r),zl(p,12,o.byteLength),p.set(o,qFe);let c=l;for(let d of s)p.set(d,c),c+=d.byteLength;return p}catch(t){if(t instanceof Q)throw t;throw new Q(`Failed to encode ASAR archive: ${UFe(t)}`)}}var SKr,kKr,w9=8,Wle=8,qFe,wKr=32768,lVs,fVs=async(e,t)=>{try{return await vKr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(`Failed to read ASAR archive: ${UFe(s)}`)}};var kRt=E(()=>{yT();fi();mc();Lf();SKr=new TextDecoder("utf-8",{fatal:!0}),kKr=new TextEncoder,qFe=w9+Wle,lVs=/^[0-9a-f]{64}$/i});class yVs{#e;#t=0;#s=0;#n=0;constructor(e){this.#e=e}readBits(e){let t=0,s=e;while(s>0){if(this.#n===0){if(this.#t+2>this.#e.byteLength)throw new Q("Invalid CAB archive: truncated LZX bitstream");this.#s=this.#e[this.#t]|this.#e[this.#t+1]<<8,this.#t+=2,this.#n=16}let n=Math.min(s,this.#n);t=t*2**n+(this.#s>>>this.#n-n&2**n-1),this.#n-=n,s-=n}return t}alignWord(){this.#n=0}readByte(){if(this.#n!==0)throw new Q("Invalid CAB archive: misaligned LZX byte stream");if(this.#t>=this.#e.byteLength)throw new Q("Invalid CAB archive: truncated LZX data");return this.#e[this.#t++]}readUInt32LE(){let e=this.readByte(),t=this.readByte(),s=this.readByte(),n=this.readByte();return(e|t<<8|s<<16|n<<24)>>>0}}class Gle{#e=new Uint32Array(17);#t=new Uint32Array(17);#s=new Uint32Array(17);#n;empty;constructor(e,t=!1){let s=0;for(let r of e){if(r>16)throw new Q("Invalid CAB archive: invalid LZX Huffman code length");if(r!==0)this.#e[r]++,s++}if(this.empty=s===0,this.empty&&!t)throw new Q("Invalid CAB archive: empty LZX Huffman tree");let n=0,o=0;for(let r=1;r<=16;r++){if(n=(n+this.#e[r-1])*2,n+this.#e[r]>2**r)throw new Q("Invalid CAB archive: oversubscribed LZX Huffman tree");this.#t[r]=n,this.#s[r]=o,o+=this.#e[r]}this.#n=new Uint16Array(s);let i=this.#s.slice();for(let r=0;r<e.byteLength;r++){let a=e[r];if(a!==0)this.#n[i[a]]=r;i[a]++}}decode(e){if(this.empty)throw new Q("Invalid CAB archive: LZX stream uses an empty Huffman tree");let t=0;for(let s=1;s<=16;s++){t=t*2+e.readBits(1);let n=t-this.#t[s];if(n>=0&&n<this.#e[s])return this.#n[this.#s[s]+n]}throw new Q("Invalid CAB archive: invalid LZX Huffman symbol")}}function wRt(e,t,s,n){let o=new Uint8Array(20);for(let a=0;a<o.byteLength;a++)o[a]=e.readBits(4);let i=new Gle(o),r=s;while(r<n){let a=i.decode(e);if(a===17||a===18){let l=e.readBits(a===17?4:5)+(a===17?4:20);if(r+l>n)throw new Q("Invalid CAB archive: LZX code-length run exceeds its tree");t.fill(0,r,r+l),r+=l;continue}if(a===19){let l=e.readBits(1)+4;if(r+l>n)throw new Q("Invalid CAB archive: LZX code-length run exceeds its tree");let u=i.decode(e),p=(t[r]-u+17)%17;t.fill(p,r,r+l),r+=l;continue}t[r]=(t[r]-a+17)%17,r++}}function TVs(e){return e>2147483647?e-4294967296:e}class xRt{#e;#t;#s;#n;#o=new Uint8Array(IKr);#r;#a;#i;#l=0;#u=0;#p=0;#c=1;#d=1;#f=1;#m=!1;#g=0;#h=!1;#T=0;#y=0;#C=0;#R=!1;constructor(e){if(!Number.isInteger(e)||e<15||e>21)throw new Q(`Unsupported CAB LZX window size: ${e} bits (expected 15-21)`);this.#e=new Uint8Array(2**e);let t=PKr[e-15];this.#n=new Uint8Array(256+t*8),this.#s=new Uint8Array(t),this.#t=new Uint32Array(t);for(let s=0;s<t;s++)if(this.#s[s]=s<4?0:Math.min(17,Math.floor(s/2)-1),s>0)this.#t[s]=this.#t[s-1]+2**this.#s[s-1]}decompressFrame(e,t){if(!Number.isInteger(t)||t<0||t>AKr)throw new Q(`Invalid CAB archive: LZX frame size ${t} exceeds 32768 bytes`);if(t===0)return new Uint8Array(0);let s=new yVs(e);if(!this.#m){if(s.readBits(1)!==0){let r=s.readBits(16),a=s.readBits(16);this.#g=TVs(r*65536+a>>>0)}this.#m=!0}let n=new Uint8Array(t),o=0;while(o<t){if(this.#C===0)this.#S(s);let r=Math.min(this.#C,t-o),a=this.#k(s,n,o,r);if(a!==r)throw new Q("Invalid CAB archive: LZX block produced the wrong byte count");o+=a,this.#C-=a}if(this.#C===0&&this.#T===3&&this.#R)s.readByte(),this.#R=!1;s.alignWord();let i=this.#x(n);return this.#p++,i}#S(e){if(this.#T===3&&this.#R)e.readByte();if(this.#R=!1,this.#T=e.readBits(3),this.#y=e.readBits(16)*256+e.readBits(8),this.#y===0)throw new Q("Invalid CAB archive: zero-length LZX block");if(this.#C=this.#y,this.#T===1||this.#T===2){if(this.#T===2){let t=new Uint8Array(8);for(let s=0;s<t.byteLength;s++)t[s]=e.readBits(3);this.#i=new Gle(t)}if(wRt(e,this.#n,0,256),wRt(e,this.#n,256,this.#n.byteLength),this.#r=new Gle(this.#n),this.#n[232]!==0)this.#h=!0;wRt(e,this.#o,0,this.#o.byteLength),this.#a=new Gle(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 Q("Invalid CAB archive: invalid LZX repeated offset");this.#R=(this.#y&1)!==0;return}throw new Q(`Invalid CAB archive: unsupported LZX block type ${this.#T}`)}#k(e,t,s,n){if(this.#T===3){for(let i=0;i<n;i++)this.#b(e.readByte(),t,s+i);return n}if(!this.#r||!this.#a)throw new Q("Invalid CAB archive: missing LZX decode trees");let o=0;while(o<n){let i=this.#r.decode(e);if(i<256){this.#b(i,t,s+o),o++;continue}let r=i-256,a=r&hVs;if(a===hVs)a+=this.#a.decode(e);if(a+=MKr,a>n-o||a>this.#C-o)throw new Q("Invalid CAB archive: LZX match crosses a frame or block boundary");let l=r>>>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 Q("Invalid CAB archive: LZX position slot is out of range");let p=this.#s[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 Q("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 Q("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.#b(this.#e[c],t,s+o+p)}o+=a}return o}#b(e,t,s){t[s]=e,this.#e[this.#l]=e,this.#l=(this.#l+1)%this.#e.byteLength,this.#u++}#x(e){if(!this.#h||this.#g===0||this.#p>=32768||e.byteLength<=10)return e;let t=e.slice(),s=0,n=this.#u-e.byteLength,o=t.byteLength-10;while(s<o){if(t[s++]!==232){n++;continue}let i=TVs((t[s]|t[s+1]<<8|t[s+2]<<16|t[s+3]<<24)>>>0);if(i>=-n&&i<this.#g){let r=i>=0?i-n:i+this.#g;t[s]=r&255,t[s+1]=r>>>8&255,t[s+2]=r>>>16&255,t[s+3]=r>>>24&255}s+=4,n+=5}return t}}var AKr=32768,MKr=2,hVs=7,IKr=249,PKr;var RVs=E(()=>{fi();PKr=[30,32,34,36,38,42,50]});import*as SVs from"zlib";async function $le(e,t,s,n=e.size){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>n)throw new Q("Invalid CAB archive: metadata range is out of bounds");let o;try{o=await e.read(t,s)}catch(i){if(i instanceof Q)throw i;throw new Q(`Unable to read CAB archive: ${i instanceof Error?i.message:String(i)}`)}if(o.byteLength!==s-t)throw new Q("Invalid CAB archive: truncated data");return o}function kVs(e){return e.byteLength>=4&&e[0]===77&&e[1]===83&&e[2]===67&&e[3]===70}function bVs(e,t=0){let s=t>>>0,n=0;while(n+4<=e.byteLength)s^=Ps(e,n),n+=4;let o=e.byteLength-n,i=0;if(o===3)i=e[n]<<16|e[n+1]<<8|e[n+2];else if(o===2)i=e[n]<<8|e[n+1];else if(o===1)i=e[n];return(s^i)>>>0}function UKr(e,t){try{return t?DKr.decode(e):qKr.decode(e)}catch{throw new Q("Invalid CAB archive: file name is not valid UTF-8")}}function HKr(e,t){if(e===0&&t===0)return;let s=1980+(e>>>9),n=e>>>5&15,o=e&31,i=t>>>11,r=t>>>5&63,a=(t&31)*2;if(n<1||n>12||o<1||o>31||i>23||r>59||a>59)throw new Q("Invalid CAB archive: file has an invalid DOS timestamp");return new Date(s,n-1,o,i,r,a).getTime()}function BKr(e,t){if(t)return 16877;let s=e&_Kr?292:420;if(e&LKr)s|=73;return 32768|s}class wVs{#e;#t;#s;#n;#o;constructor(e,t,s,n){this.#e=e,this.#t=t,this.#s=s,this.#n=n}readAll(){return this.#o??=this.#r(),this.#o}async#r(){let e=this.#t;if(e.method===2)throw new Q(`Unsupported CAB compression method: Quantum (level ${e.parameter})`);if(e.method>3)throw new Q(`Unsupported CAB compression method: ${e.method}`);if(e.method===3&&(e.parameter<15||e.parameter>21))throw new Q(`Unsupported CAB LZX window size: ${e.parameter} bits (expected 15-21)`);let t=e.dataEnd-e.dataStart;Di(t,this.#n);let s=await $le(this.#e,e.dataStart,e.dataEnd),n=0,o=0;for(let l=0;l<e.blockCount;l++){if(n+vRt+this.#s>s.byteLength)throw new Q("Invalid CAB archive: truncated CFDATA header");let u=Pn(s,n+4),p=Pn(s,n+6);if(p===0)throw new Q("Unsupported multi-volume CAB archive: split CFDATA block");if(p>CVs)throw new Q(`Invalid CAB archive: CFDATA expands to ${p} bytes (maximum 32768)`);let c=n+vRt+this.#s,d=c+u;if(d>s.byteLength)throw new Q("Invalid CAB archive: truncated CFDATA payload");let f=Ps(s,n);if(f!==0){let m=bVs(s.subarray(c,d));if(bVs(s.subarray(n+4,c),m)!==f)throw new Q(`Invalid CAB archive: CFDATA block ${l} checksum mismatch`)}o+=p,Di(o,this.#n),n=d}if(o<e.requiredSize)throw new Q("Invalid CAB archive: folder data is shorter than its file table declares");let i=new Uint8Array(o),r=e.method===3?new xRt(e.parameter):void 0;n=0;let a=0;for(let l=0;l<e.blockCount;l++){let u=Pn(s,n+4),p=Pn(s,n+6),c=n+vRt+this.#s,d=c+u,f=s.subarray(c,d),m;if(e.method===0){if(u!==p)throw new Q("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 Q("Invalid CAB archive: MSZIP block is missing its CK signature");try{let g=i.subarray(Math.max(0,a-CVs),a);m=new Uint8Array(SVs.inflateRawSync(f.subarray(2),{dictionary:g,maxOutputLength:p}))}catch(g){throw new Q(`Invalid CAB archive: MSZIP decompression failed${g instanceof Error?`: ${g.message}`:""}`)}}else m=r.decompressFrame(f,p);if(m.byteLength!==p)throw new Q(`Invalid CAB archive: CFDATA block ${l} produced ${m.byteLength} bytes, expected ${p}`);i.set(m,a),a+=m.byteLength,n=d}return i}}class xVs{#e;#t;#s;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}async read(e,t){if(e!==this.#s)throw new Q(`Invalid CAB archive: size changed while extracting '${t}'`);let s=await this.#e.readAll(),n=this.#t+e;if(!Number.isSafeInteger(n)||this.#t<0||n>s.byteLength)throw new Q(`Invalid CAB archive: member '${t}' is outside its folder data`);return s.slice(this.#t,n)}}async function WKr(e,t){if(e.size<N2)throw new Q("Invalid CAB archive: truncated CFHEADER");let s=await $le(e,0,N2);if(!kVs(s))throw new Q(`Invalid CAB archive: expected ${OKr} signature`);if(Ps(s,4)!==0||Ps(s,12)!==0||Ps(s,20)!==0)throw new Q("Invalid CAB archive: reserved CFHEADER fields must be zero");let n=Ps(s,8);if(n<N2||n>e.size)throw new Q("Invalid CAB archive: declared cabinet size is out of bounds");let o=Ps(s,16);if(o<N2||o>n)throw new Q("Invalid CAB archive: CFFILE table offset is out of bounds");if(s[24]!==3||s[25]!==1)throw new Q(`Unsupported CAB format version ${s[25]}.${s[24]} (expected 1.3)`);let i=Pn(s,26),r=Pn(s,28),a=Pn(s,30);if(a&3)throw new Q("Unsupported multi-volume CAB archive (previous/next cabinet link)");if(xr(i+r,t.limits),i===0&&r!==0)throw new Q("Invalid CAB archive: files exist without a folder");let l=0,u=0,p=0,c=N2;if(a&4){let x=await $le(e,N2,N2+4,n);if(l=Pn(x,0),u=x[2],p=x[3],l>60000)throw new Q("Invalid CAB archive: CFHEADER reserve area exceeds 60000 bytes");c+=4+l}let d=8+u,f=c+i*d;if(!Number.isSafeInteger(f)||f>n||f>o)throw new Q("Invalid CAB archive: CFFOLDER table is out of bounds");Vn(f,t.limits,"CAB header");let m=await $le(e,0,f,n),g=[];for(let x=0;x<i;x++){let A=c+x*d,I=Pn(m,A+6);g.push({dataStart:Ps(m,A),dataEnd:n,blockCount:Pn(m,A+4),method:I&15,parameter:I>>>8,requiredSize:0})}for(let x of g){if(x.dataStart<f||x.dataStart>n)throw new Q("Invalid CAB archive: CFFOLDER data offset is out of bounds");for(let A of g)if(A.dataStart>x.dataStart&&A.dataStart<x.dataEnd)x.dataEnd=A.dataStart}let h=g.reduce((x,A)=>Math.min(x,A.dataStart),n);if(o>h)throw new Q("Invalid CAB archive: CFFILE table overlaps folder data");Vn(f+(h-o),t.limits,"CAB index");let T=await $le(e,o,h,n),R=g.map((x)=>new wVs(e,x,p,t.limits)),C=[],w=0;for(let x=0;x<r;x++){if(w+16>T.byteLength)throw new Q("Invalid CAB archive: truncated CFFILE entry");let A=Ps(T,w),I=Ps(T,w+4),M=Pn(T,w+8),O=Pn(T,w+10),_=Pn(T,w+12),F=Pn(T,w+14);w+=16;let L=T.indexOf(0,w);if(L<0)throw new Q("Invalid CAB archive: unterminated CFFILE name");let D=T.subarray(w,L);if(D.byteLength>256)throw new Q("Invalid CAB archive: CFFILE name exceeds 256 bytes");if(No(D.byteLength,"member path",t.limits.maxPathBytes),w=L+1,M>=65533)throw new Q("Unsupported multi-volume CAB archive: continued file");if(M>=R.length)throw new Q("Invalid CAB archive: CFFILE references a missing folder");let N=UKr(D,(F&NKr)!==0);Oa(A,N,t.limits);let U=I+A;if(!Number.isSafeInteger(U))throw new Q("Invalid CAB archive: CFFILE range is too large");if(U>g[M].requiredSize)g[M].requiredSize=U;let B=Qr(N);if(!B)continue;let H=(F&FKr)!==0;C.push({path:B,isDirectory:H,size:A,mtimeMs:HKr(O,_),mode:BKr(F,H),storage:H?void 0:{type:"member",source:new xVs(R[M],I,A)}})}for(let x of g)Di(x.requiredSize,t.limits);return C}function vVs(e){return kVs(e)}var OKr="MSCF",N2=36,vRt=8,CVs=32768,_Kr=1,FKr=16,LKr=64,NKr=128,DKr,qKr,EVs=async(e,t)=>{try{return await WKr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(`Invalid CAB archive: ${s instanceof Error?s.message:String(s)}`)}};var AVs=E(()=>{yT();RVs();fi();mc();Lf();DKr=new TextDecoder("utf-8",{fatal:!0}),qKr=new TextDecoder("windows-1252")});function YKr(){let e=new Uint32Array(256);for(let t=0;t<e.length;t++){let s=t<<24;for(let n=0;n<8;n++)s=(s&2147483648)!==0?s<<1^79764919:s<<1;e[t]=s>>>0}return e}function MVs(e,t){return(KKr[(e>>>24^t)&255]^e<<8)>>>0}class PVs{#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 Q("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 s=0;s<e;s++)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 Q("Invalid non-zero bzip2 stream padding")}}class OVs{#e;#t;#s=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.#n(1),this.#t[this.#s++]=e}pushRepeated(e,t){this.#n(t),this.#t.fill(e,this.#s,this.#s+t),this.#s+=t}finish(){return this.#t.slice(0,this.#s)}#n(e){let t=this.#s+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new Q(`Bzip2 output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let s=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(s>this.#e)s=this.#e;let n=new Uint8Array(s);n.set(this.#t.subarray(0,this.#s)),this.#t=n}}class _Vs{#e=new Uint16Array(D2+1);#t=new Uint32Array(D2+1);#s=new Uint16Array(D2+1);#n;constructor(e){for(let o of e){if(o<1||o>D2)throw new Q("Invalid bzip2 Huffman code length");this.#e[o]++}let t=0,s=0;for(let o=1;o<=D2;o++){if(t=(t+this.#e[o-1])*2,t+this.#e[o]>2**o)throw new Q("Oversubscribed bzip2 Huffman table");this.#t[o]=t,this.#s[o]=s,s+=this.#e[o]}this.#n=new Uint16Array(e.length);let n=new Uint16Array(this.#s);for(let o=0;o<e.length;o++){let i=e[o];this.#n[n[i]]=o,n[i]++}}decode(e){let t=0;for(let s=1;s<=D2;s++){t=t*2+e.readBit();let n=t-this.#t[s];if(n>=0&&n<this.#e[s])return this.#n[this.#s[s]+n]}throw new Q("Invalid bzip2 Huffman code")}}function IVs(e,t){return e.every((s,n)=>s===t[n])}function XKr(e){if(e.readBits(8)!==66||e.readBits(8)!==90||e.readBits(8)!==104)throw new Q("Invalid bzip2 stream header");let t=e.readBits(8)-48;if(t<1||t>9)throw new Q("Invalid bzip2 block-size level");return t*1e5}function JKr(e,t){let s=e.readBits(3);if(s<2||s>6)throw new Q("Invalid bzip2 Huffman group count");let n=e.readBits(15);if(n<1||n>zKr)throw new Q("Invalid bzip2 selector count");let o=new Uint8Array(n),i=new Uint8Array(s);for(let l=0;l<s;l++)i[l]=l;for(let l=0;l<n;l++){let u=0;while(e.readBit()!==0)if(u++,u>=s)throw new Q("Invalid bzip2 selector MTF value");let p=i[u];o[l]=p,i.copyWithin(1,0,u),i[0]=p}let r=t.length+2,a=[];for(let l=0;l<s;l++){let u=new Uint8Array(r),p=e.readBits(5);for(let c=0;c<r;c++){while(e.readBit()!==0)if(p+=e.readBit()===0?1:-1,p<1||p>D2)throw new Q("Invalid bzip2 Huffman code length");u[c]=p}a.push(new _Vs(u))}return{selectors:o,tables:a}}function QKr(e,t,s,n,o){let i=new Uint8Array(s),r=new Uint8Array(t),a=0,l=0,u=0,p,c=()=>{if(u===0){if(l>=n.length)throw new Q("Bzip2 block exhausted its Huffman selectors");p=o[n[l++]],u=jKr}return u--,p.decode(e)},d=(g,h)=>{if(h<0||a+h>t)throw new Q("Bzip2 block exceeds its declared block-size level");r.fill(g,a,a+h),a+=h},f=s.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 Q("Invalid bzip2 RLE run length");R*=2,m=c()}while(m===0||m===1);if(d(i[0],T),m===f)break}let g=m-1;if(g<0||g>=i.length)throw new Q("Invalid bzip2 MTF symbol");let h=i[g];i.copyWithin(1,0,g),i[0]=h,d(h,1),m=c()}return r.slice(0,a)}function ZKr(e,t){if(e.length===0||t<0||t>=e.length)throw new Q("Invalid bzip2 BWT origin pointer");let s=new Uint32Array(257);for(let a of e)s[a+1]++;for(let a=1;a<s.length;a++)s[a]+=s[a-1];let n=new Uint32Array(s.subarray(0,256)),o=new Uint32Array(e.length);for(let a=0;a<e.length;a++){let l=e[a];o[n[l]]=a,n[l]++}let i=new Uint8Array(e.length),r=o[t];for(let a=0;a<i.length;a++)i[a]=e[r],r=o[r];return i}function eYr(e,t,s){let n=4294967295,o=-1,i=0,r=0,a=0,l=(p)=>{s.push(p),n=MVs(n,p)},u=(p,c)=>{s.pushRepeated(p,c);for(let d=0;d<c;d++)n=MVs(n,p)};for(let p of e){if(t){if(a===0)a=VKr[r],r=r+1&511;if(a--,a===1)p^=1}if(i===4){u(o,p),i=0;continue}if(l(p),p===o)i++;else o=p,i=1}if(i===4)throw new Q("Truncated bzip2 RLE run");return(n^4294967295)>>>0}function tYr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid bzip2 output limit");let s=new PVs(e),n=new OVs(t,e.byteLength);for(;;){let o=XKr(s),i=0;for(;;){let r=s.readMarker();if(IVs(r,$Kr)){let C=s.readUint32();if(i!==C)throw new Q("Bzip2 stream CRC mismatch");s.alignToByte();break}if(!IVs(r,GKr))throw new Q("Invalid bzip2 block marker");let a=s.readUint32(),l=s.readBit()!==0,u=s.readBits(24),p=s.readBits(16),c=new Uint8Array(256),d=0;for(let C=0;C<16;C++){if((p&32768>>>C)===0)continue;for(let w=0;w<16;w++)if(s.readBit()!==0)c[d++]=C*16+w}if(d===0)throw new Q("Bzip2 block has an empty symbol map");let f=c.slice(0,d),{selectors:m,tables:g}=JKr(s,f),h=QKr(s,o,f,m,g),T=ZKr(h,u),R=eYr(T,l,n);if(R!==a)throw new Q("Bzip2 block CRC mismatch");i=((i<<1|i>>>31)^R)>>>0}if(s.done)return n.finish()}}function HFe(e){return e.byteLength>=4&&e[0]===66&&e[1]===90&&e[2]===104&&e[3]>=49&&e[3]<=57}async function dP(e,t){try{return tYr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}}var GKr,$Kr,D2=20,zKr=18002,jKr=50,VKr,KKr;var zle=E(()=>{fi();GKr=[49,65,89,38,83,89],$Kr=[23,114,69,56,80,144],VKr=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]),KKr=YKr()});import{promisify as FVs}from"util";import*as BFe from"zlib";function WFe(e){return e.byteLength>=2&&e[0]===31&&e[1]===139}async function q2(e,t){try{return await nYr(e,{maxOutputLength:Math.max(t,1)})}catch(s){throw new Q(s instanceof Error?s.message:String(s))}}function LVs(e){return sYr(e)}var sYr,nYr;var jle=E(()=>{fi();sYr=FVs(BFe.gzip),nYr=FVs(BFe.gunzip)});class qVs{bytes;pos=0;range=4294967295;code=0;constructor(e){if(this.bytes=e,e.byteLength<5||e[0]!==0)throw new Q("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<oYr){if(this.pos>=this.bytes.byteLength)throw new Q("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 s=e[t],n=Math.imul(this.range>>>11,s)>>>0;if(this.code<n)return this.range=n,e[t]=s+(Nm-s>>>NVs),0;return this.range=this.range-n>>>0,this.code=this.code-n>>>0,e[t]=s-(s>>>NVs),1}decodeDirectBits(e){let t=0;for(let s=0;s<e;s++){this.#e(),this.range>>>=1;let n=0;if(this.code>=this.range)this.code=this.code-this.range>>>0,n=1;t=(t<<1|n)>>>0}return t}}function Xg(e){let t=new Uint16Array(e);return t.fill(Nm>>>1),t}class MRt{choice=Xg(2);low=Xg($Fe<<3);mid=Xg($Fe<<3);high=Xg(256);reset(){this.choice.fill(Nm>>>1),this.low.fill(Nm>>>1),this.mid.fill(Nm>>>1),this.high.fill(Nm>>>1)}decode(e,t){if(e.decodeBit(this.choice,0)===0)return GFe(e,this.low,t<<3,3);if(e.decodeBit(this.choice,1)===0)return 8+GFe(e,this.mid,t<<3,3);return 16+GFe(e,this.high,0,8)}}function GFe(e,t,s,n){let o=1;for(let i=0;i<n;i++)o=o<<1|e.decodeBit(t,s+o);return o-(1<<n)}function DVs(e,t,s,n){let o=1,i=0;for(let r=0;r<n;r++){let a=e.decodeBit(t,s+o);o=o<<1|a,i|=a<<r}return i>>>0}function UVs(e){if(e.byteLength!==5)throw new Q("Invalid LZMA properties: expected 5 bytes");let t=e[0];if(t>=225)throw new Q("Invalid LZMA properties");let s=t%9;t=Math.floor(t/9);let n=t%5,o=Math.floor(t/5),i=(e[1]|e[2]<<8|e[3]<<16|e[4]<<24)>>>0;return{lc:s,lp:n,pb:o,dictionarySize:Math.max(i,4096)}}class zFe{#e;#t;#s=0;#n=0;#o=0;#r=0;#a=0;#i=0;#l=0;#u=1;#p=1;#c=1;#d=1;#f=Xg(ERt);#m=Xg(x9*$Fe);#g=Xg(x9);#h=Xg(x9);#T=Xg(x9);#y=Xg(x9);#C=Xg(x9*$Fe);#R=Xg(256);#S=Xg(115);#k=Xg(16);#b=new MRt;#x=new MRt;constructor(e,t){this.#e=e,this.#t=t.dictionarySize,this.setProperties(t.lc,t.lp,t.pb),this.resetDictionary()}get outputPos(){return this.#s}setProperties(e,t,s){if(e>8||t>4||s>4||e+t>12)throw new Q("Invalid LZMA properties");this.#r=e,this.#a=t,this.#i=s;let n=ERt*2**(e+t);if(this.#f.length!==n)this.#f=Xg(n)}resetDictionary(){this.#n=this.#s,this.#o=0,this.resetState()}resetState(){this.#l=0,this.#u=this.#p=this.#c=this.#d=1,this.#f.fill(Nm>>>1),this.#m.fill(Nm>>>1),this.#g.fill(Nm>>>1),this.#h.fill(Nm>>>1),this.#T.fill(Nm>>>1),this.#y.fill(Nm>>>1),this.#C.fill(Nm>>>1),this.#R.fill(Nm>>>1),this.#S.fill(Nm>>>1),this.#k.fill(Nm>>>1),this.#b.reset(),this.#x.reset()}appendUncompressed(e,t){if(t)this.resetDictionary();if(e.byteLength>this.#e.byteLength-this.#s)throw new Q("LZMA2 output exceeds its limit");this.#e.set(e,this.#s),this.#s+=e.byteLength,this.#o+=e.byteLength}decodeChunk(e,t,s=!1){if(!Number.isSafeInteger(t)||t<0||t>this.#e.byteLength-this.#s)throw new Q("LZMA output exceeds its declared size");let n=this.#s+t,o=new qVs(e),i=(1<<this.#i)-1,r=(1<<this.#a)-1;while(this.#s<n||s){let a=this.#o&i;if(o.decodeBit(this.#m,(this.#l<<4)+a)===0){let u=this.#s===this.#n?0:this.#e[this.#s-1],p=(((this.#o&r)<<this.#r)+(u>>>8-this.#r))*ERt,c=1;if(this.#l>=7){this.#A(this.#u);let d=this.#e[this.#s-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.#s>=n)throw new Q("LZMA output exceeds its size limit before the end marker");this.#e[this.#s++]=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.#w(this.#u,1,n);continue}}else{let u;if(o.decodeBit(this.#T,this.#l)===0)u=this.#p;else{if(o.decodeBit(this.#y,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.#x.decode(o,a)+ARt,this.#l=this.#l<7?8:11}else{this.#d=this.#c,this.#c=this.#p,this.#p=this.#u,l=this.#b.decode(o,a)+ARt,this.#l=this.#l<7?7:10;let u=Math.min(l-ARt,3),p=GFe(o,this.#R,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+DVs(o,this.#S,c-p,d)>>>0;else if(c=c+(o.decodeDirectBits(d-4)<<4)>>>0,c=c+DVs(o,this.#k,0,4)>>>0,c===4294967295){if(s)return!0;throw new Q("LZMA stream ended before its declared output size")}}this.#u=c+1>>>0}this.#w(this.#u,l,n)}return!1}#A(e){let t=this.#s-this.#n;if(e<1||e>t||e>this.#t)throw new Q(`Invalid LZMA match distance ${e} with ${t} bytes available`)}#w(e,t,s){if(this.#A(e),t>s-this.#s)throw new Q("LZMA match exceeds its declared output size");for(let n=0;n<t;n++)this.#e[this.#s]=this.#e[this.#s-e],this.#s++;this.#o+=t}}async function Vle(e,t,s){if(!Number.isSafeInteger(s)||s<0)throw new Q("Invalid LZMA output size");try{let n=new Uint8Array(s),o=new zFe(n,UVs(e));if(o.decodeChunk(t,s),o.outputPos!==s)throw new Q("LZMA output size mismatch");return n}catch(n){if(n instanceof Q)throw n;throw new Q(`Invalid LZMA stream: ${n instanceof Error?n.message:String(n)}`)}}async function v9(e,t){if(e.byteLength<13)throw new Q("Invalid LZMA-alone stream: truncated header");if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid LZMA output limit");let s=e.subarray(0,5),n=!0,o=0;for(let i=0;i<8;i++){let r=e[5+i];if(r!==255)n=!1;o+=r*2**(i*8)}if(!n){if(!Number.isSafeInteger(o)||o>t)throw new Q("LZMA-alone output exceeds its size limit");return Vle(s,e.subarray(13),o)}try{let i=new Uint8Array(t),r=new zFe(i,UVs(s));if(!r.decodeChunk(e.subarray(13),t,!0))throw new Q("LZMA-alone output exceeds its size limit before the end marker");return i.subarray(0,r.outputPos)}catch(i){if(i instanceof Q)throw i;throw new Q(`Invalid LZMA-alone stream: ${i instanceof Error?i.message:String(i)}`)}}async function jFe(e,t,s){if(!Number.isInteger(e)||e<0||e>40)throw new Q("Unsupported LZMA2 dictionary property");if(!Number.isSafeInteger(s)||s<0)throw new Q("Invalid LZMA2 output limit");let n=e===40?4294967295:(2|e&1)*2**(Math.floor(e/2)+11),o=new Uint8Array(s),i=new zFe(o,{lc:3,lp:0,pb:2,dictionarySize:n}),r=0,a=!0,l=!1,u=()=>{if(r>=t.byteLength)throw new Q("Invalid LZMA2 stream: truncated chunk header");return t[r++]};try{for(;;){let p=u();if(p===0)break;if(p<128){if(p!==1&&p!==2)throw new Q(`Invalid LZMA2 control byte 0x${p.toString(16)}`);if(p===2&&a)throw new Q("Invalid LZMA2 stream: dictionary was not initialized");let h=(u()<<8)+u()+1;if(h>s-i.outputPos||h>t.byteLength-r)throw new Q("Invalid LZMA2 uncompressed chunk size");if(i.appendUncompressed(t.subarray(r,r+h),p===1),r+=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 Q("Invalid LZMA2 stream: dictionary was not initialized");if(!l&&!g)throw new Q("Invalid LZMA2 stream: properties were not initialized");if(g){let h=u();if(h>=225)throw new Q("Invalid LZMA2 properties");let T=h%9;h=Math.floor(h/9);let R=h%5,C=Math.floor(h/5);if(T+R>4)throw new Q("Invalid LZMA2 literal properties");i.setProperties(T,R,C),l=!0}if(d>t.byteLength-r||c>s-i.outputPos)throw new Q("Invalid LZMA2 chunk size");if(f)i.resetDictionary();else if(m)i.resetState();i.decodeChunk(t.subarray(r,r+d),c),r+=d,a=!1}if(r!==t.byteLength)throw new Q("Invalid LZMA2 stream: trailing data");return o.subarray(0,i.outputPos)}catch(p){if(p instanceof Q)throw p;throw new Q(`Invalid LZMA2 stream: ${p instanceof Error?p.message:String(p)}`)}}var oYr=16777216,Nm=2048,NVs=5,ERt=768,x9=12,$Fe=16,ARt=2;var U2=E(()=>{fi()});class BVs{#e;#t=0;#s=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 s=0;s<e;s++){let n=this.#t+s;t+=(this.#e[n>>>3]>>>(n&7)&1)*2**s}return this.#t+=e,t}alignCodeGroup(e){let t=e*8,s=this.#s+Math.ceil((this.#t-this.#s)/t)*t;if(s>this.#e.byteLength*8)throw new Q("Truncated compress (.Z) code group");this.#t=s,this.#s=s}assertFinalPadding(){this.#n(this.#e.byteLength*8)}#n(e){for(let t=this.#t;t<e;t++)if((this.#e[t>>>3]>>>(t&7)&1)!==0)throw new Q("Invalid non-zero compress (.Z) padding")}}class WVs{#e;#t;#s=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.#n(t);for(let s=t-1;s>=0;s--)this.#t[this.#s++]=e[s]}finish(){return this.#t.slice(0,this.#s)}#n(e){let t=this.#s+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new Q(`Compress (.Z) output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let s=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(s>this.#e)s=this.#e;let n=new Uint8Array(s);n.set(this.#t.subarray(0,this.#s)),this.#t=n}}function aYr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid compress (.Z) output limit");if(e.byteLength<3)throw new Q("Truncated compress (.Z) header");if(e[0]!==31||e[1]!==157)throw new Q("Invalid compress (.Z) header");let s=e[2];if((s&96)!==0)throw new Q("Unsupported compress (.Z) header flags");let n=s&31;if(n<IRt||n>iYr)throw new Q(`Invalid compress (.Z) maximum code width ${n}`);let o=(s&128)!==0,i=2**n,r=new Uint16Array(i),a=new Uint8Array(i),l=new Uint8Array(i),u=new BVs(e.subarray(3)),p=new WVs(t,e.byteLength),c=IRt,d=o?HVs:256,f=!1;for(;;){let m=u.read(c);if(m===void 0)return u.assertFinalPadding(),p.finish();if(m>=d)throw new Q(`Corrupt compress (.Z) dictionary code ${m}`);if(o&&m===rYr){u.alignCodeGroup(c),c=IRt,d=HVs,f=!1;continue}let g=m,h=0;while(g>=256){if(g>=d||h>=l.length-1)throw new Q("Corrupt compress (.Z) dictionary chain");l[h++]=a[g],g=r[g]}if(l[h++]=g,f){if(a[d-1]=g,m===d-1)l[0]=g}if(p.appendReversed(l,h),d<i){if(f=!0,r[d++]=m,d>2**c&&c<n)u.alignCodeGroup(c),c++}else f=!1}}function GVs(e){return e.byteLength>=2&&e[0]===31&&e[1]===157}async function PRt(e,t){try{return aYr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}}var rYr=256,HVs=257,IRt=9,iYr=16;var $Vs=E(()=>{fi()});function rw(e,t){if(t<0||t+4>e.byteLength)throw new Q("Invalid XZ stream: truncated integer");return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function KFe(e,t,s){e[t]=s&255,e[t+1]=s>>>8&255,e[t+2]=s>>>16&255,e[t+3]=s>>>24}function zVs(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function lYr(e,t,s){e[t]=s>>>24,e[t+1]=s>>>16&255,e[t+2]=s>>>8&255,e[t+3]=s&255}function ORt(e,t){if(e.byteLength!==t.byteLength)return!1;for(let s=0;s<e.byteLength;s++)if(e[s]!==t[s])return!1;return!0}function H2(e){let t=0;for(let s=0;s<9;s++){if(e.pos>=e.limit)throw new Q("Invalid XZ stream: truncated variable-length integer");let n=e.bytes[e.pos++];if(s>0&&n===0)throw new Q("Invalid XZ stream: non-canonical variable-length integer");if(t+=(n&127)*2**(s*7),!Number.isSafeInteger(t))throw new Q("XZ stream uses sizes too large to read safely");if((n&128)===0)return t}throw new Q("Invalid XZ stream: variable-length integer is too long")}function jVs(e){switch(e){case 0:return 0;case 1:return 4;case 4:return 8;case 10:return 32;default:throw new Q(`Unsupported XZ integrity check ID 0x${e.toString(16)}`)}}function uYr(e,t,s){if(s<8||t<0||t+s>e.byteLength)throw new Q("Invalid XZ stream: index range is invalid");let n=t+s;if(e[t]!==0)throw new Q("Invalid XZ stream: missing index indicator");if(Ca(e.subarray(t,n-4))!==rw(e,n-4))throw new Q("Invalid XZ stream: index CRC32 mismatch");let o={bytes:e,pos:t+1,limit:n-4},i=H2(o);if(i>Math.floor(s/2))throw new Q("Invalid XZ stream: impossible index record count");let r=[];for(let a=0;a<i;a++){let l=H2(o),u=H2(o);if(l===0)throw new Q("Invalid XZ stream: zero unpadded block size");r.push({unpaddedSize:l,uncompressedSize:u})}while(o.pos<o.limit)if(e[o.pos++]!==0)throw new Q("Invalid XZ stream: non-zero index padding");return r}function pYr(e){if(e.byteLength===0||(e.byteLength&3)!==0)throw new Q("Invalid XZ stream: size is not a multiple of four bytes");let t=[],s=e.byteLength;while(s>0){let n=0;while(s>=4&&e[s-1]===0&&e[s-2]===0&&e[s-3]===0&&e[s-4]===0)s-=4,n+=4;if(s===0)throw new Q("Invalid XZ stream: padding without a stream");if(s<24)throw new Q("Invalid XZ stream: truncated stream framing");let o=s-12;if(e[o+10]!==89||e[o+11]!==90)throw new Q("Invalid XZ stream: footer magic mismatch");if(Ca(e.subarray(o+4,o+10))!==rw(e,o))throw new Q("Invalid XZ stream: footer CRC32 mismatch");let i=e[o+8],r=e[o+9];if(i!==0||(r&240)!==0)throw new Q("Unsupported XZ stream flags");let a=r&15;jVs(a);let l=(rw(e,o+4)+1)*4;if(!Number.isSafeInteger(l)||l>o)throw new Q("Invalid XZ stream: backward index size is invalid");let u=o-l,p=uYr(e,u,l),c=0;for(let f of p)if(c+=Math.ceil(f.unpaddedSize/4)*4,!Number.isSafeInteger(c))throw new Q("XZ stream uses sizes too large to read safely");let d=u-c-12;if(d<0||d+12>e.byteLength||!ORt(e.subarray(d,d+6),VFe))throw new Q("Invalid XZ stream: header position or magic is invalid");if(e[d+6]!==i||e[d+7]!==r)throw new Q("Invalid XZ stream: header and footer flags differ");if(Ca(e.subarray(d+6,d+8))!==rw(e,d+8))throw new Q("Invalid XZ stream: header CRC32 mismatch");t.unshift({start:d,indexStart:u,footerStart:o,checkId:a,records:p}),s=d}return t}function cYr(e,t){let s=new Uint8Array(256),n=0;for(let o=0;o<e.byteLength;o++){let i=e[o]+s[t+n&255]&255;s[n]=i,e[o]=i,n=n-1&255}}function dYr(e,t){let s=[0,1,2,2,3],n=0,o=4294967291;if(e.byteLength<5)return;let i=0,r=e.byteLength-5;while(i<=r){let a=e[i];if(a!==232&&a!==233){i++;continue}let l=t+i>>>0,u=l-o>>>0;if(o=l,u>5)n=0;else for(let p=0;p<u;p++)n=(n&119)<<1>>>0;if(a=e[i+4],(a===0||a===255)&&n>>>1<=4&&n>>>1!==3){let p=rw(e,i+1),c=0;for(;;){if(c=p-l-5>>>0,n===0)break;let d=s[n>>>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[i+4]=~((c>>>24&1)-1)&255,e[i+3]=c>>>16,e[i+2]=c>>>8,e[i+1]=c,i+=5,n=0}else if(i++,n|=1,a===0||a===255)n|=16}}function fYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){if(e[s]>>>2!==18||(e[s+3]&3)!==1)continue;let o=(((e[s]&3)<<24|e[s+1]<<16|e[s+2]<<8|e[s+3]&252)>>>0)-t-s>>>0;e[s]=72|o>>>24&3,e[s+1]=o>>>16,e[s+2]=o>>>8,e[s+3]=e[s+3]&3|o&252}}function mYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){if(e[s+3]!==235)continue;let o=((e[s+2]<<18|e[s+1]<<10|e[s]<<2)>>>0)-t-s-8>>>2;e[s]=o,e[s+1]=o>>>8,e[s+2]=o>>>16}}function gYr(e,t){for(let s=0;s+4<=e.byteLength;s+=2){if((e[s+1]&248)!==240||(e[s+3]&248)!==248)continue;let o=(((e[s+1]&7)<<19|e[s]<<11|(e[s+3]&7)<<8|e[s+2])<<1>>>0)-t-s-4>>>1;e[s+1]=240|o>>>19&7,e[s]=o>>>11,e[s+3]=248|o>>>8&7,e[s+2]=o,s+=2}}function hYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){if(!(e[s]===64&&(e[s+1]&192)===0||e[s]===127&&(e[s+1]&192)===192))continue;let o=(zVs(e,s)<<2>>>0)-t-s>>>2;o=0-(o>>>22&1)<<22&1073741823|o&4194303|1073741824,lYr(e,s,o>>>0)}}function TYr(e,t){let s=[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 n=0;n+16<=e.byteLength;n+=16){let o=s[e[n]&31],i=5;for(let r=0;r<3;r++,i+=41){if((o>>>r&1)===0)continue;let a=i>>>3,l=i&7,u=0n;for(let f=0;f<6;f++)u|=BigInt(e[n+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-n>>>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[n+a+f]=Number(u>>BigInt(f*8))&255}}}function yYr(e,t){for(let s=0;s+4<=e.byteLength;s+=4){let n=t+s>>>0,o=rw(e,s);if(o>>>26===37)o=(2483027968|o-(n>>>2)&67108863)>>>0,KFe(e,s,o);else if((o&2667577344)===2415919104){let i=o>>>29&3|o>>>3&2097148;if((i+131072&1835008)!==0)continue;let r=i-(n>>>12)>>>0;o&=2415919135,o|=(r&3)<<29,o|=(r&262140)<<3,o|=0-(r&131072)&14680064,KFe(e,s,o>>>0)}}}function RYr(e,t){if(e.byteLength<8)return;for(let s=0;s<=e.byteLength-8;s+=2){let n=e[s];if(n===239){let i=e[s+1];if((i&13)!==0)continue;let r=((i&240)<<13|e[s+2]<<9|e[s+3]<<1)-t-s>>>0;e[s+1]=i&15|r>>>8&240,e[s+2]=r>>>16&15|r>>>7&16|r<<4&224,e[s+3]=r>>>4&127|r>>>13&128,s+=2;continue}if((n&127)!==23)continue;n=rw(e,s);let o;if((n&3712)!==0){if(o=rw(e,s+4),(n<<8^o-3&1015811)!==0){s+=4;continue}let i=(n&4294963200)+(o>>>20);n=(279|o<<12)>>>0,o=i>>>0}else{let i=n>>>27;if(n-12567<<18>>>0>=(i&29)){s+=2;continue}let r=zVs(e,s+4)-t-s>>>0;o=(n>>>12|r<<20)>>>0,n=(23|i<<7|r+2048&4294963200)>>>0}KFe(e,s,n),KFe(e,s+4,o),s+=6}}function CYr(e,t){if(t.id===3){if(t.properties.byteLength!==1)throw new Q("Invalid XZ Delta filter properties");cYr(e,t.properties[0]+1);return}if(t.properties.byteLength!==0&&t.properties.byteLength!==4)throw new Q(`Invalid XZ BCJ filter 0x${t.id.toString(16)} properties`);let s=t.properties.byteLength===4?rw(t.properties,0):0,n=t.id===6?16:t.id===8||t.id===11?2:t.id===4?1:4;if((s&n-1)!==0)throw new Q(`Invalid XZ BCJ filter 0x${t.id.toString(16)} start offset`);switch(t.id){case 4:dYr(e,s);break;case 5:fYr(e,s);break;case 6:TYr(e,s);break;case 7:mYr(e,s);break;case 8:gYr(e,s);break;case 9:hYr(e,s);break;case 10:yYr(e,s);break;case 11:RYr(e,s);break;default:throw new Q(`Unsupported XZ filter ID 0x${t.id.toString(16)}`)}}function bYr(e,t,s){if(e===0)return;if(e===1){if(rw(s,0)!==Ca(t))throw new Q("Invalid XZ stream: block CRC32 mismatch");return}if(e===4){let o=W4s(t),i=0n;for(let r=0;r<8;r++)i|=BigInt(s[r])<<BigInt(r*8);if(o!==i)throw new Q("Invalid XZ stream: block CRC64 mismatch");return}let n=new Uint8Array(new Bun.CryptoHasher("sha256").update(t).digest());if(!ORt(n,s))throw new Q("Invalid XZ stream: block SHA-256 mismatch")}async function SYr(e,t,s,n){if(t>=e.byteLength||e[t]===0)throw new Q("Invalid XZ stream: missing block header");let o=(e[t]+1)*4;if(t+o>e.byteLength||o<8)throw new Q("Invalid XZ stream: truncated block header");if(Ca(e.subarray(t,t+o-4))!==rw(e,t+o-4))throw new Q("Invalid XZ stream: block header CRC32 mismatch");let i={bytes:e,pos:t+1,limit:t+o-4},r=e[i.pos++];if((r&60)!==0)throw new Q("Unsupported XZ block flags");let a=(r&3)+1,l=(r&64)!==0?H2(i):void 0,u=(r&128)!==0?H2(i):void 0,p=[];for(let w=0;w<a;w++){let x=H2(i),A=H2(i);if(A>i.limit-i.pos)throw new Q("Invalid XZ stream: truncated filter properties");p.push({id:x,properties:e.slice(i.pos,i.pos+A)}),i.pos+=A}while(i.pos<i.limit)if(e[i.pos++]!==0)throw new Q("Invalid XZ stream: non-zero block header padding");let c=jVs(n),d=s.unpaddedSize-o-c;if(!Number.isSafeInteger(d)||d<=0)throw new Q("Invalid XZ stream: compressed block size is invalid");if(l!==void 0&&l!==d)throw new Q("Invalid XZ stream: block compressed size mismatch");if(u!==void 0&&u!==s.uncompressedSize)throw new Q("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 Q("Invalid XZ stream: truncated block data");let T=p[p.length-1];if(T.id!==33||T.properties.byteLength!==1)throw new Q(`Unsupported XZ terminal filter ID 0x${T.id.toString(16)} (LZMA2 required)`);let R=await jFe(T.properties[0],e.subarray(f,m),s.uncompressedSize);if(R.byteLength!==s.uncompressedSize)throw new Q("Invalid XZ stream: decoded block size mismatch");R=R.slice();for(let w=p.length-2;w>=0;w--)CYr(R,p[w]);for(let w=m;w<h;w++)if(e[w]!==0)throw new Q("Invalid XZ stream: non-zero block padding");bYr(n,R,e.subarray(h,h+c));let C=t+Math.ceil(s.unpaddedSize/4)*4;if(h+c!==C)throw new Q("Invalid XZ stream: block size does not match its index record");return R}function YFe(e){return e.byteLength>=VFe.byteLength&&ORt(e.subarray(0,VFe.byteLength),VFe)}async function fP(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Q("Invalid XZ output limit");try{let s=pYr(e),n=0;for(let r of s)for(let a of r.records)if(n+=a.uncompressedSize,!Number.isSafeInteger(n)||n>t)throw new Q("XZ output exceeds its size limit");let o=new Uint8Array(n),i=0;for(let r of s){let a=r.start+12;for(let l of r.records){let u=await SYr(e,a,l,r.checkId);o.set(u,i),i+=u.byteLength,a+=Math.ceil(l.unpaddedSize/4)*4}if(a!==r.indexStart)throw new Q("Invalid XZ stream: blocks do not align with index")}return o}catch(s){if(s instanceof Q)throw s;throw new Q(`Invalid XZ stream: ${s instanceof Error?s.message:String(s)}`)}}var VFe;var Kle=E(()=>{uP();fi();U2();VFe=Uint8Array.of(253,55,122,88,90,0)});import{promisify as VVs}from"util";import*as XFe from"zlib";function JFe(e){return e.byteLength>=4&&e[0]===40&&e[1]===181&&e[2]===47&&e[3]===253}async function mP(e,t){try{return await wYr(e,{maxOutputLength:Math.max(t,1)})}catch(s){throw new Q(s instanceof Error?s.message:String(s))}}function KVs(e){return kYr(e)}var kYr,wYr;var E9=E(()=>{fi();kYr=VVs(XFe.zstdCompress),wYr=VVs(XFe.zstdDecompress)});import*as ZFe from"path";class LRt{#e;#t;#s;#n;constructor(e,t,s,n){this.#e=e,this.#t=t,this.#s=s,this.#n=n}async read(e,t){if(e!==this.#s)throw new Q(`CPIO member '${t}' has an inconsistent declared size`);let s=this.#t+this.#s;if(s>this.#e.byteLength)throw new Q(`CPIO member '${t}' is truncated`);let n=this.#e.subarray(this.#t,s);if(this.#n!==void 0&&t6s(n)!==this.#n)throw new Q(`CPIO member '${t}' has an invalid CRC checksum`);return n}}function t6s(e){let t=0;for(let s of e)t=t+s>>>0;return t}function e6s(e,t){let s=e%t;return s===0?e:e+t-s}function gP(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.byteLength)throw new Q(`Invalid CPIO archive: truncated ${n}`)}function QFe(e,t,s,n,o){gP(e,t,t+s,`${o} field`);let i=0;for(let r=t;r<t+s;r++){let a=e[r],l;if(a>=48&&a<=57)l=a-48;else if(n===16&&a>=65&&a<=70)l=a-65+10;else if(n===16&&a>=97&&a<=102)l=a-97+10;else throw new Q(`Invalid CPIO archive: ${o} is not a valid base-${n} number`);if(l>=n)throw new Q(`Invalid CPIO archive: ${o} is not a valid base-${n} number`);i=i*n+l}if(!Number.isSafeInteger(i))throw new Q(`Invalid CPIO archive: ${o} is too large`);return i}function s6s(e,t){gP(e,t,t+2,"header");let s=e[t],n=e[t+1];if(s===199&&n===113||s===113&&n===199){gP(e,t,t+JVs,"old binary header");let r=s===199?Pn:Dle,a=(l)=>r(e,t+l)*65536+r(e,t+l+2);return{headerSize:JVs,alignment:2,devMajor:0,devMinor:r(e,t+2),inode:r(e,t+4),mode:r(e,t+6),nlink:r(e,t+12),mtime:a(16),nameSize:r(e,t+20),fileSize:a(22)}}gP(e,t,t+6,"magic");let o=String.fromCharCode(...e.subarray(t,t+6));if(o==="070701"||o==="070702"){gP(e,t,t+YVs,"new ASCII header");let i=(a,l)=>QFe(e,t+6+a*8,8,16,l),r=i(12,"checksum");if(o==="070701"&&r!==0)throw new Q("Invalid CPIO archive: newc checksum field must be zero");return{headerSize:YVs,alignment:4,inode:i(0,"inode"),mode:i(1,"mode"),nlink:i(4,"link count"),mtime:i(5,"modification time"),fileSize:i(6,"file size"),devMajor:i(7,"device major"),devMinor:i(8,"device minor"),nameSize:i(11,"name size"),checksum:o==="070702"?r:void 0}}if(o==="070707"){gP(e,t,t+XVs,"portable ASCII header");let i=(r,a)=>QFe(e,t+r,6,8,a);return{headerSize:XVs,alignment:1,devMajor:0,devMinor:i(6,"device"),inode:i(12,"inode"),mode:i(18,"mode"),nlink:i(36,"link count"),mtime:QFe(e,t+48,11,8,"modification time"),nameSize:i(59,"name size"),fileSize:QFe(e,t+65,11,8,"file size")}}throw new Q(`Invalid CPIO archive: unsupported or corrupt magic at offset ${t}`)}function n6s(e){try{return EYr.decode(e)}catch{return}}function FRt(e,t,s,n){for(let o=t;o<s;o++)if(e[o]!==0)throw new Q(`Invalid CPIO archive: non-zero ${n} padding`)}function AYr(e,t,s){No(t.byteLength,"link target",s);let n=n6s(t);if(n===void 0||n.includes("\x00"))throw new Q(`Invalid CPIO archive: symlink '${e}' has an invalid UTF-8 target`);let o=n.replace(/\\/g,"/");if(ZFe.posix.isAbsolute(o))return{path:o,resolveTarget:!1};let i=_f(ZFe.posix.join(ZFe.posix.dirname(e),o));return i===void 0?{path:o,resolveTarget:!1}:{path:i,resolveTarget:!0}}function NRt(e,t){Di(e.byteLength,t.limits);let s=[],n=0,o=0,i=!1;while(n<e.byteLength){let u=s6s(e,n);if(u.mode>65535)throw new Q("Invalid CPIO archive: mode exceeds 16 bits");if(u.nameSize<1)throw new Q("Invalid CPIO archive: name size must include a NUL terminator");No(u.nameSize-1,"member path",t.limits.maxPathBytes),Oa(u.fileSize,"(CPIO entry)",t.limits);let p=n+u.headerSize,c=p+u.nameSize,d=e6s(c,u.alignment),f=d+u.fileSize,m=e6s(f,u.alignment);if(gP(e,p,c,"member name"),gP(e,d,f,"member data"),gP(e,f,m,"member padding"),e[c-1]!==0)throw new Q("Invalid CPIO archive: member name is not NUL-terminated");for(let R=p;R<c-1;R++)if(e[R]===0)throw new Q("Invalid CPIO archive: member name contains an embedded NUL");FRt(e,c,d,"name"),FRt(e,f,m,"data"),o+=d-n,Vn(o,t.limits,"CPIO index");let g=n6s(e.subarray(p,c-1));if(g===xYr){if(u.fileSize!==0)throw new Q("Invalid CPIO archive: TRAILER!!! has non-empty data");i=!0,n=m;break}let h=u.mode&_Rt;if((h===ZVs||h===4096)&&u.fileSize!==0)throw new Q("Invalid CPIO archive: directory or FIFO has non-empty data");xr(s.length+1,t.limits);let T=g===void 0?void 0:Qr(g);s.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}),n=m}if(!i)throw new Q("Invalid CPIO archive: missing TRAILER!!! terminator");FRt(e,n,e.byteLength,"trailing");let r=new Map,a=new Set,l=new Map;for(let u of s){if((u.mode&_Rt)!==QVs||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 LRt(e,c.dataOffset,c.fileSize,c.checksum)}:{type:"link",targetPath:d.path,resolveTarget:!1}};Xc(r,m)}}for(let u of s){if(a.has(u)||u.path===void 0)continue;let p=u.mode&_Rt;if(p===ZVs){Xc(r,{path:u.path,isDirectory:!0,size:0,mtimeMs:u.mtimeMs,mode:u.mode});continue}if(p===vYr){let c=e.subarray(u.dataOffset,u.dataOffset+u.fileSize);if(u.checksum!==void 0&&t6s(c)!==u.checksum)throw new Q(`CPIO symlink '${u.path}' has an invalid CRC checksum`);let d=AYr(u.path,c,t.limits.maxPathBytes);Xc(r,{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!==QVs)continue;Xc(r,{path:u.path,isDirectory:!1,size:u.fileSize,mtimeMs:u.mtimeMs,mode:u.mode,storage:{type:"member",source:new LRt(e,u.dataOffset,u.fileSize,u.checksum)}})}return iD(r,t.limits),[...r.values()]}function Yle(e){try{let t=s6s(e,0);if(t.mode>65535||t.nameSize<1)return!1;let s=t.headerSize+t.nameSize;return s<=e.byteLength&&e[s-1]===0}catch{return!1}}var YVs=110,XVs=76,JVs=26,xYr="TRAILER!!!",_Rt=61440,QVs=32768,ZVs=16384,vYr=40960,EYr,o6s=async(e,t)=>{try{return Di(e.size,t.limits),NRt(await KE(e),t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}};var DRt=E(()=>{yT();aD();fi();mc();Lf();YE();EYr=new TextDecoder("utf-8",{fatal:!0})});import*as Jle from"path";class k6s{#e;#t;#s;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}async read(e,t){if(this.#s)throw new Q(`Archive member '${Dr(t)}' is a sparse file and cannot be read`);if(e>this.#e.byteLength-this.#t)throw new Q(`Archive member '${Dr(t)}' is truncated`);let s=this.#e.subarray(this.#t,this.#t+e);if(s.byteLength!==e)throw new Q(`Archive member '${Dr(t)}' has an invalid size`);return s}}function tLe(e,t,s){let n=Math.min(t+s,e.byteLength),o=t;while(o<n&&e[o]!==0)o++;return Zle.decode(e.subarray(t,o))}function B2(e,t){return e.byteLength===t.length&&fc(e,0,t)}function FYr(e,t){return fc(e,t+C6s,HRt)&&fc(e,t+b6s,BRt)}function sLe(e,t,s){let n=e.indexOf(0),o=e.subarray(0,n===-1?e.byteLength:n);return No(o.byteLength,t,s.maxPathBytes),Zle.decode(o)}function a6s(e,t,s){return No(e.byteLength,t,s.maxPathBytes),Zle.decode(e)}function nLe(e,t,s){if(t<0||s<=0||t+s>e.byteLength)throw new Q("Invalid tar numeric field");let n=e[t],o=0n;if((n&128)!==0){o=BigInt(n&127);for(let i=1;i<s;i++)o=o<<8n|BigInt(e[t+i]);if((n&64)!==0)o-=1n<<BigInt(s*8-1)}else for(let i=0;i<s;i++){let r=e[t+i];if(r>=48&&r<=55)o=o*8n+BigInt(r-48)}return Number(o)}function w6s(e,t){let s=nLe(e,t,h6s);if(!Number.isSafeInteger(s)||s<0)throw new Q("Invalid tar member size");return s}function oLe(e){let t=e%iw,s=e+(t===0?0:iw-t);if(!Number.isSafeInteger(s))throw new Q("Invalid tar member size");return s}function l6s(e,t){if(!/^\d+$/.test(e))throw new Q(`Invalid tar ${t}`);let s=Number(e);if(!Number.isSafeInteger(s)||s<0)throw new Q(`Invalid tar ${t}`);return s}function x6s(e,t){for(let s=0;s<iw;s++)if(e[t+s]!==0)return!1;return!0}function v6s(e,t){let s=nLe(e,t+lD,URt),n=0,o=0;for(let i=0;i<iw;i++){let a=i>=lD&&i<lD+URt?32:e[t+i]??0;n+=a,o+=a<<24>>24}return s===n||s===o}function u6s(e,t){Vn(e.byteLength,t,"tar PAX metadata");let s=new Map,n=0;while(n<e.byteLength){let o=n;while(o<e.byteLength&&e[o]!==32)o++;if(o===n||o>=e.byteLength||o-n>16)throw new Q("Invalid tar PAX record");let i=0;for(let l=n;l<o;l++){let u=e[l];if(u<48||u>57)throw new Q("Invalid tar PAX record");if(i=i*10+(u-48),i>e.byteLength-n)throw new Q("Invalid tar PAX record")}if(i<=0||n+i>e.byteLength||e[n+i-1]!==10)throw new Q("Invalid tar PAX record");let r=e.subarray(o+1,n+i-1),a=r.indexOf(61);if(a>=0){let l=r.subarray(0,a),u=r.subarray(a+1);if(fc(l,0,WRt)){if(s.set(WRt,u.byteLength===0?"":"1"),B2(l,"GNU.sparse.name"))s.set("GNU.sparse.name",a6s(u,"PAX sparse path",t));else if(B2(l,"GNU.sparse.realsize")||B2(l,"GNU.sparse.size")){if(u.byteLength>r6s)throw new Q("Invalid tar sparse real size");s.set("GNU.sparse.realsize",Zle.decode(u))}}else if(B2(l,"path")||B2(l,"linkpath")){let p=B2(l,"path")?"PAX path":"PAX link target";s.set(p==="PAX path"?"path":"linkpath",a6s(u,p,t))}else if(B2(l,"size")){if(u.byteLength>r6s)throw new Q("Invalid tar member size");s.set("size",Zle.decode(u))}}n+=i}return s}function LYr(e,t){for(let[s,n]of t)if(n==="")e.delete(s);else e.set(s,n)}function A9(e,t,s){if(t?.has(s))return t.get(s);return e.get(s)}function NYr(e,t){return A9(e,t,WRt)==="1"}function DYr(e,t,s){for(let n=s;n<=e.byteLength-t.length;n++)if(fc(e,n,t))return n;return-1}function p6s(e,t,s){let n=e.replace(/\\/g,"/");if(Jle.posix.isAbsolute(n))throw new Q(`Invalid old-GNU ${t}`);let o=Qr(n);if(!o)throw new Q(`Invalid old-GNU ${t}`);return Ff(o,t,s.maxPathBytes),o}function qYr(e,t,s,n,o){let i=[...e.entries()].filter(([r])=>r===s||r.startsWith(`${s}/`));if(i.length===0)return;for(let[r]of i)e.delete(r);for(let[r,a]of i){let l=r.slice(s.length),u=`${n}${l}`;Ff(u,"member path",o.maxPathBytes),a.path=u;let p=e.get(u);if(p)t.delete(p);e.set(u,a)}for(let r of t.values())if(r.kind==="hard link"&&(r.targetPath===s||r.targetPath.startsWith(`${s}/`)))r.targetPath=`${n}${r.targetPath.slice(s.length)}`}function UYr(e,t,s,n){Vn(e.byteLength,n,"old-GNU name metadata");let o=e.indexOf(0),i=o===-1?e.byteLength:o,r=0;while(r<i){let a=e.indexOf(10,r),l=a===-1||a>i?i:a,u=e.subarray(r,l);if(fc(u,0,"Rename ")){let p=DYr(u," to ",7);if(p===-1)throw new Q("Invalid old-GNU name record");let c=sLe(u.subarray(7,p),"old-GNU source path",n),d=u[u.byteLength-1]===47?u.byteLength-1:u.byteLength,f=sLe(u.subarray(p+4,d),"old-GNU target path",n);qYr(t,s,p6s(c,"source path",n),p6s(f,"target path",n),n)}r=l+1}}function HYr(e,t,s){if(t.size===0)return;let n=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(n.has(p))break;n.add(p)}let o=new Set(t.keys()),i=new Map,r=(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=r(u.targetPath),c=u.targetPath;if(p===null){try{c=F2(e,c,s.maxLinkDepth)}catch(g){if(!(g instanceof Q))throw new Q("Invalid archive link")}if(c!==u.targetPath)p=r(c)}if(p!==null&&p!==l){let g=i.get(p);if(g)g.push(l);else i.set(p,[l]);continue}o.delete(l);let d=i.get(l);if(d)i.delete(l),a.push(...d);if(p===l){if(u.kind==="hard link")throw new Q(`Archive hard link '${Dr(l.path)}' has a cyclic target '${Dr(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||n.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 Q(`Archive hard link '${Dr(l.path)}' targets ${g} '${Dr(u.targetPath)}'`)}if(u.kind==="hard link")throw new Q(`Archive hard link '${Dr(l.path)}' targets directory '${Dr(u.targetPath)}'`);l.isDirectory=!0,l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1}}if(o.size>0)throw new Q("Archive contains cyclic or unsupported links")}function eue(e,t){let{limits:s}=t;Di(e.byteLength,s);let n=new Map,o=new Map,i=(d,f)=>{let m=n.get(d.path),g=Xc(n,d);if(!g)return;if(m)o.delete(m);if(f)o.set(g,f);xr(n.size,s)},r=0,a,l,u,p=new Map,c=!1;while(r+iw<=e.byteLength){if(x6s(e,r)){c=!0;break}if(!v6s(e,r))throw new Q("Invalid or corrupt tar archive header");let d=r,f=String.fromCharCode(e[d+R6s]||48),m=w6s(e,d+$Rt),g=tLe(e,d+GRt,Qle);if(FYr(e,d)){let z=tLe(e,d+S6s,zRt);if(z)g=`${z}/${g}`}let h=tLe(e,d+MYr,IYr),T=nLe(e,d+T6s,y6s),R=nLe(e,d+m6s,g6s),C=Number.isSafeInteger(R)&&R>=0?R:void 0;r+=iw;let w=oLe(m);if(w>e.byteLength-r)throw new Q("Archive member data is truncated");let x=e.subarray(r,r+m);if(f==="L"){Vn(x.byteLength,s,"GNU long-name metadata"),a=sLe(x,"GNU long path",s),r+=w;continue}if(f==="K"){Vn(x.byteLength,s,"GNU long-link metadata"),l=sLe(x,"GNU long link target",s),r+=w;continue}if(f==="N"){UYr(x,n,o,s),r+=w;continue}if(f==="x"||f==="X"){u=u6s(x,s),r+=w;continue}if(f==="g"){LYr(p,u6s(x,s)),r+=w;continue}if(f==="M")throw new Q("GNU multi-volume tar members are not supported");if(a!==void 0)g=a;if(l!==void 0)h=l;let A=A9(p,u,"path");if(A!==void 0)g=A;let I=A9(p,u,"linkpath");if(I!==void 0)h=I;let M=A9(p,u,"size");if(M!==void 0)m=l6s(M,"member size");let O=A9(p,u,"GNU.sparse.name");if(O!==void 0)g=O;let _=m,F=A9(p,u,"GNU.sparse.realsize");if(F!==void 0)_=l6s(F,"sparse real size");let L=f==="S"||NYr(p,u);if(f==="S"&&e[d+PYr]===1){let z=!0;while(z){if(r+iw>e.byteLength)throw new Q("Archive sparse metadata is truncated");z=e[r+OYr]===1,r+=iw}}let D=r,N=oLe(m);if(N>e.byteLength-D)throw new Q(`Archive member '${Dr(g)}' is truncated`);r+=N,a=void 0,l=void 0,u=void 0;let U=f==="5"||g.endsWith("/"),B=Qr(g);if(!B)continue;Ff(B,"member path",s.maxPathBytes);let H=T*1000,W=T!==0&&Number.isSafeInteger(H)?H:void 0;if(U){i({path:B,isDirectory:!0,size:0,mtimeMs:W,mode:C});continue}if(f==="1"||f==="2"){let z=f==="1"?"hard link":"symlink",K=h.replace(/\\/g,"/");Ff(K,"link target",s.maxPathBytes);let J=f==="1"?Qr(K):Jle.posix.isAbsolute(K)?void 0:_f(Jle.posix.join(Jle.posix.dirname(B),K)),se={path:B,isDirectory:!1,size:0,mtimeMs:W,mode:C};if(J===void 0||Buffer.byteLength(J,"utf-8")>s.maxPathBytes){if(z==="hard link")throw new Q(`Archive hard link '${Dr(B)}' has an invalid target`);se.storage={type:"link",targetPath:K,resolveTarget:!1},i(se);continue}i(se,{kind:z,targetPath:J});continue}if(f!=="0"&&f!=="\x00"&&f!=="7"&&f!=="S")continue;Oa(_,B,s),i({path:B,isDirectory:!1,size:_,mtimeMs:W,mode:C,storage:{type:"member",source:new k6s(e,D,L)}})}if(!c)throw new Q("Not a valid tar archive: missing terminating zero block");return HYr(n,o,s),[...n.values()]}function jRt(e){if(e.byteLength<iw)return!1;if(x6s(e,0))return!0;try{if(tLe(e,GRt,Qle).length===0)return!1;let t=w6s(e,$Rt);return Number.isSafeInteger(oLe(t))&&v6s(e,0)}catch{return!1}}function eLe(e,t,s,n){if(n.byteLength>s)throw new Q("Tar header field is too long");e.set(n,t)}function Xle(e,t,s,n){if(!Number.isSafeInteger(n)||n<0)throw new Q("Invalid tar numeric value");let o=n.toString(8);if(o.length>s-1)throw new Q("Tar numeric value does not fit its header field");for(let i=t;i<t+s-1-o.length;i++)e[i]=48;for(let i=0;i<o.length;i++)e[t+s-1-o.length+i]=o.charCodeAt(i);e[t+s-1]=0}function BYr(e){if(e.byteLength<=Qle)return[e,new Uint8Array(0)];for(let t=e.byteLength-1;t>0;t--){if(e[t]!==47)continue;let s=e.subarray(0,t),n=e.subarray(t+1);if(s.byteLength<=zRt&&n.byteLength>0&&n.byteLength<=Qle)return[n,s]}return}function qRt(e,t){let s=uD.encode(`${e}=${t}
|
|
4035
4035
|
`),n=s.byteLength+2;for(;;){let a=String(n).length+1+s.byteLength;if(a===n)break;n=a}let o=uD.encode(`${n} `),i=new Uint8Array(n);return i.set(o),i.set(s,o.byteLength),i}function A6s(e){let t=0;for(let o of e)if(t+=o.byteLength,!Number.isSafeInteger(t))throw new Q("Tar archive is too large to encode safely");let s=new Uint8Array(t),n=0;for(let o of e)s.set(o,n),n+=o.byteLength;return s}function c6s(e,t,s,n,o,i){let r=new Uint8Array(iw);eLe(r,GRt,Qle,e),Xle(r,m6s,g6s,o),Xle(r,108,8,0),Xle(r,116,8,0),Xle(r,$Rt,h6s,s),Xle(r,T6s,y6s,n),r.fill(32,lD,lD+URt),r[R6s]=i,eLe(r,C6s,HRt.length,uD.encode(HRt)),eLe(r,b6s,BRt.length,uD.encode(BRt)),eLe(r,S6s,zRt,t);let a=0;for(let u of r)a+=u;let l=a.toString(8).padStart(6,"0");for(let u=0;u<6;u++)r[lD+u]=l.charCodeAt(u);return r[lD+6]=0,r[lD+7]=32,r}function d6s(e,t){e.push(t);let s=oLe(t.byteLength)-t.byteLength;if(s>0)e.push(new Uint8Array(s))}function f6s(e,t,s,n,o){let i=uD.encode(n?`${t}/`:t),r=BYr(i),a=n?0:s.byteLength,l=0,u=[];if(!r)u.push(qRt("path",n?`${t}/`:t));if(a>i6s)u.push(qRt("size",String(a)));if(0>_Yr)u.push(qRt("mtime",String(0)));if(u.length>0){let c=A6s(u),d=uD.encode(`PaxHeaders/${String(o).padStart(8,"0")}`);e.push(c6s(d,new Uint8Array(0),c.byteLength,0,420,120)),d6s(e,c)}let p=r??[uD.encode(`PaxFile/${String(o).padStart(8,"0")}`),new Uint8Array(0)];if(e.push(c6s(p[0],p[1],a<=i6s?a:0,0,n?493:420,n?53:48)),!n)d6s(e,s)}async function rLe(e){let t=[],s=new Map,n=0;for(let[o,i]of e){let r=o.endsWith("/")||o.endsWith("\\"),a=Qr(o);if(!a)throw new Q(`Invalid tar member path '${Dr(o)}'`);if(uD.encode(a).byteLength===0)throw new Q("Invalid empty tar member path");if(r&&i.byteLength!==0)throw new Q(`Tar directory '${Dr(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=s.get(d);if(f==="file")throw new Q(`Tar member '${Dr(d)}' is not a directory`);if(f==="directory")continue;s.set(d,"directory"),f6s(t,d,new Uint8Array(0),!0,n++)}let p=s.get(a);if(p){if(r&&p==="directory")continue;throw new Q(`Duplicate tar member path '${Dr(a)}'`)}s.set(a,r?"directory":"file"),f6s(t,a,i,r,n++)}return t.push(new Uint8Array(iw*2)),A6s(t)}var iw=512,GRt=0,Qle=100,m6s=100,g6s=8,$Rt=124,h6s=12,T6s=136,y6s=12,lD=148,URt=8,R6s=156,MYr=157,IYr=100,C6s=257,HRt="ustar\x00",b6s=263,BRt="00",S6s=345,zRt=155,PYr=482,OYr=504,r6s=32,WRt="GNU.sparse.",Zle,uD,i6s=8589934591,_Yr=8589934591,E6s=async(e,t)=>{Di(e.size,t.limits);let s;try{s=await KE(e)}catch(n){if(n instanceof Q)throw n;throw new Q(n instanceof Error?n.message:"Failed to read tar archive")}if(s.byteLength!==e.size)throw new Q("Invalid archive: truncated data");return eue(s,t)};var iLe=E(()=>{yT();aD();fi();mc();Lf();YE();Zle=new TextDecoder,uD=new TextEncoder});class I6s{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async read(e,t){try{let s=await this.#e.read(this.#t,this.#t+e);if(s.byteLength!==e)throw new Q(`Archive member '${t}' is truncated`);return s}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}}}function M9(e,t,s){let n=t+s;while(n>t&&e[n-1]===32)n--;let o="";for(let i=t;i<n;i++){let r=e[i];if(r<32||r>126)throw new Q("Invalid ar archive header field");o+=String.fromCharCode(r)}return o}function tue(e,t,s){if(e===""||e==="-1")return;if(!(t===8?/^[0-7]+$/:/^\d+$/).test(e))throw new Q(`Invalid ar archive ${s}`);let o=Number.parseInt(e,t);if(!Number.isSafeInteger(o))throw new Q(`Invalid ar archive ${s}`);return o}function zYr(e){let t=tue(e,10,"member size");if(t===void 0)throw new Q("Invalid ar archive member size");return t}function jYr(e){if(e.byteLength!==uLe||e[M6s]!==96||e[M6s+1]!==10)throw new Q("Invalid ar archive member header");let t=M9(e,0,WYr),s=tue(M9(e,16,12),10,"modification time");tue(M9(e,28,6),10,"user id"),tue(M9(e,34,6),10,"group id");let n=tue(M9(e,40,8),8,"mode"),o=zYr(M9(e,48,10)),i;if(t.startsWith("#1/")){let r=t.slice(3);if(!/^\d+$/.test(r))throw new Q("Invalid ar archive BSD extended name length");if(i=Number.parseInt(r,10),!Number.isSafeInteger(i)||i<=0||i>o)throw new Q("Invalid ar archive BSD extended name length")}return{rawName:t,physicalSize:o,mtimeSeconds:s,mode:n,bsdNameLength:i}}function P6s(e,t){return No(e.byteLength,"member path",t.maxPathBytes),b9.decode(e)}function VYr(e,t){let s=e.indexOf(0),n=s>=0?e.subarray(0,s):e;if(n.byteLength===0)throw new Q("Invalid ar archive empty BSD extended name");return{name:P6s(n,t),byteLength:n.byteLength}}function KYr(e){if(e==="/"||e==="//"||e==="/SYM64/")return e;return e.endsWith("/")?e.slice(0,-1):e}function YYr(e,t,s){let n=e.slice(1);if(!/^\d+$/.test(n))throw new Q(`Invalid ar archive member name '${e}'`);let o=Number.parseInt(n,10);if(!Number.isSafeInteger(o)||o<0||o>=t.byteLength)throw new Q(`Invalid ar archive long-name offset '${e}'`);let i=o;while(i<t.byteLength&&t[i]!==0&&t[i]!==10)i++;if(i===t.byteLength)throw new Q(`Unterminated ar archive long name at offset ${o}`);let r=i;if(t[i]===10&&r>o&&t[r-1]===47)r--;if(r===o)throw new Q(`Empty ar archive long name at offset ${o}`);let a=t.subarray(o,r);return{name:P6s(a,s),byteLength:a.byteLength}}function XYr(e){return e==="/"||e==="//"||e==="/SYM64/"||e==="__.SYMDEF"||e==="__.SYMDEF SORTED"}function JYr(e,t,s,n){let o=new Map;for(let i of e){let{name:r,nameByteLength:a}=i;if(/^\/\d+$/.test(r)){if(!t)throw new Q(`Ar archive member '${r}' references a missing long-name table`);let c=YYr(r,t,n.limits);r=c.name,a=c.byteLength}else r=KYr(r);if(XYr(r))continue;No(a,"member path",n.limits.maxPathBytes),Oa(i.size,r,n.limits);let l=Qr(r);if(!l)continue;let u=i.mode!==void 0&&(i.mode&GYr)===$Yr,p={path:l,isDirectory:u,size:u?0:i.size,...i.mtimeSeconds!==void 0?{mtimeMs:i.mtimeSeconds*1000}:{},...i.mode!==void 0?{mode:i.mode}:{},...!u?{storage:{type:"member",source:new I6s(s,i.dataOffset)}}:{}};Xc(o,p),xr(o.size,n.limits)}return iD(o,n.limits),[...o.values()]}function QYr(e){if(!VRt(e))throw new Q("Invalid ar archive signature")}async function aLe(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.size)throw new Q(`Invalid ar archive: truncated ${n}`);try{let o=await e.read(t,s);if(o.byteLength!==s-t)throw new Q(`Invalid ar archive: truncated ${n}`);return o}catch(o){if(o instanceof Q)throw o;throw new Q(o instanceof Error?o.message:String(o))}}async function ZYr(e,t){if(!Number.isSafeInteger(e.size)||e.size<lLe.length)throw new Q("Invalid ar archive signature");QYr(await aLe(e,0,lLe.length,"signature"));let s=[],n,o=0;for(let i=lLe.length;i<e.size;){let r=await aLe(e,i,i+uLe,"member header"),a=jYr(r);o+=uLe,Vn(o,t.limits,"index");let l=i+uLe,u=l+a.physicalSize;if(!Number.isSafeInteger(u)||u>e.size)throw new Q("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,Vn(o,t.limits,"index");let m=await aLe(e,l,l+a.bsdNameLength,"BSD member name"),g=VYr(m,t.limits);p=g.name,c=g.byteLength,d+=a.bsdNameLength,f-=a.bsdNameLength}else if(a.rawName==="//")o+=a.physicalSize,Vn(o,t.limits,"index"),n=await aLe(e,l,u,"long-name table");if(s.push({name:p,nameByteLength:c,dataOffset:d,size:f,mtimeSeconds:a.mtimeSeconds,mode:a.mode}),xr(s.length,t.limits),i=u+(a.physicalSize&1),i>e.size)throw new Q("Invalid ar archive: missing alignment byte")}return JYr(s,n,e,t)}function VRt(e){return fc(e,0,lLe)}var lLe=`!<arch>
|
|
4036
4036
|
`,uLe=60,WYr=16,M6s=58,GYr=61440,$Yr=16384,pLe=async(e,t)=>{try{return await ZYr(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}};var KRt=E(()=>{yT();aD();fi();mc();Lf();YE()});function t7r(e){if(!fc(e,0,cLe)||e.byteLength<cLe.length+YRt)return;let t=cLe.length;if(e[t+58]!==96||e[t+59]!==10)return;let s=t+e7r;while(s>t&&e[s-1]===32)s--;let n="";for(let o=t;o<s;o++){let i=e[o];if(i<32||i>126)return;n+=String.fromCharCode(i)}if(n.startsWith("#1/")){let o=n.slice(3);if(!/^\d+$/.test(o))return;let i=Number.parseInt(o,10),r=t+YRt;if(!Number.isSafeInteger(i)||i<=0||r+i>e.byteLength)return;let a=e.subarray(r,r+i),l=a.indexOf(0);return b9.decode(l>=0?a.subarray(0,l):a)}return n.endsWith("/")?n.slice(0,-1):n}function s7r(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 n7r(e,t,s){let n=s.limits.maxInMemorySize,o;switch(t){case"none":o=e;break;case"gz":o=await q2(e,n);break;case"xz":o=await fP(e,n);break;case"zst":o=await mP(e,n);break;case"bz2":o=await dP(e,n);break;case"lzma":o=await v9(e,n);break}return Di(o.byteLength,s.limits),o}function o7r(e){let t=`control/${e.path}`;if(e.storage?.type!=="link")return{...e,path:t};let s=e.storage.targetPath;if(s!==""&&Qr(s)!==s)return{...e,path:t};return{...e,path:t,storage:{...e.storage,targetPath:s?`control/${s}`:"control"}}}async function r7r(e){if(e.isDirectory||e.storage?.type!=="member")throw new Q(`Invalid deb archive member '${e.path}'`);return e.storage.source.read(e.size,e.path)}async function i7r(e,t){let s=Math.min(e.size,cLe.length+YRt+t.limits.maxPathBytes),n;try{n=await e.read(0,s)}catch(r){throw new Q(r instanceof Error?r.message:String(r))}if(!XRt(n))throw new Q("Invalid deb archive: first member is not debian-binary");let o=await pLe(e,t);if(o[0]?.path!==O6s)throw new Q("Invalid deb archive: first member is not debian-binary");let i=new Map;for(let r of o){let a=s7r(r.path);if(!a){if(r.path.startsWith("control.tar.")||r.path.startsWith("data.tar."))throw new Q(`Unsupported deb tar compression in '${r.path}'`);Xc(i,r);continue}let l=await r7r(r),u=await n7r(l,a.compression,t),p=eue(u,t);for(let c of p)Xc(i,a.kind==="control"?o7r(c):c)}return iD(i,t.limits),[...i.values()]}function XRt(e){return t7r(e)===O6s}var cLe=`!<arch>
|
|
4037
4037
|
`,YRt=60,e7r=16,O6s="debian-binary",_6s=async(e,t)=>{try{return await i7r(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}};var F6s=E(()=>{yT();zle();jle();U2();Kle();E9();aD();fi();mc();Lf();iLe();KRt()});import*as W2 from"path";class D6s{#e=0;#t;constructor(e){this.#t=e}async read(e,t,s,n){ZRt(e,t,s,n),this.#e+=s-t,Vn(this.#e,this.#t,"ISO metadata");let o=await e.read(t,s);if(o.byteLength!==s-t)throw Po(`truncated ${n}`);return o}}class q6s{#e;#t;#s;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}async read(e,t){try{let s=new Uint8Array(e),n=0;for(let o of this.#s){if(n+o.size>e)throw Po(`invalid multi-extent size for '${t}'`);let i=o.fileUnitSize*this.#t,r=o.interleaveGapSize*this.#t;if(i===0){let u=await L6s(this.#e,o.start,o.size,t);s.set(u,n),n+=u.byteLength;continue}let{size:a,start:l}=o;while(a>0){let u=Math.min(i,a),p=await L6s(this.#e,l,u,t);s.set(p,n),n+=u,a-=u,l=hP(l,i+r,"interleaved file offset")}}if(n!==e)throw Po(`member '${t}' produced ${n} bytes, expected ${e}`);return s}catch(s){if(s instanceof Q)throw s;throw Po(`could not extract member '${t}'`)}}}function Po(e){return new Q(`Invalid ISO 9660 archive: ${e}`)}function mLe(e,t,s){let n=e*t;if(!Number.isSafeInteger(n)||n<0)throw Po(`${s} is too large`);return n}function hP(e,t,s){let n=e+t;if(!Number.isSafeInteger(n)||n<0)throw Po(`${s} is too large`);return n}function ZRt(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.size)throw Po(`truncated or invalid ${n}`)}async function L6s(e,t,s,n){let o=hP(t,s,"member extent");ZRt(e,t,o,`extent for '${n}'`);let i=await e.read(t,o);if(i.byteLength!==s)throw Po(`truncated extent for '${n}'`);return i}function dLe(e,t,s){let n=Pn(e,t);if(n!==Dle(e,t+2))throw Po(`${s} has mismatched byte orders`);return n}function pD(e,t,s){let n=Ps(e,t);if(n!==TT(e,t+4))throw Po(`${s} has mismatched byte orders`);return n}function l7r(e,t){let s=e[t]+1900,n=e[t+1],o=e[t+2],i=e[t+3],r=e[t+4],a=e[t+5],l=e[t+6],u=l>=128?l-256:l;if(n<1||n>12||o<1||o>31||i>23||r>59||a>60||u<-48||u>52)return;let p=Date.UTC(s,n-1,o,i,r,Math.min(a,59));if(!Number.isFinite(p))return;return p-u*15*60000}function U6s(e,t,s,n){if(s<34)throw Po(`${n} directory record is too short`);let o=e[t];if(o<34||o>s)throw Po(`${n} directory record has an invalid length`);let i=e[t+32],r=i%2===0?1:0,a=33+i+r;if(i===0||a>o)throw Po(`${n} directory record has an invalid identifier`);let l=pD(e,t+2,`${n} extent location`),u=pD(e,t+10,`${n} data length`);dLe(e,t+28,`${n} volume sequence number`);let p=e[t+26],c=e[t+27];if(p===0!==(c===0))throw Po(`${n} has an invalid interleave configuration`);return{extent:l,size:u,extendedAttributeBlocks:e[t+1],mtimeMs:l7r(e,t+18),flags:e[t+25],fileUnitSize:p,interleaveGapSize:c,identifier:e.subarray(t+33,t+33+i),systemUse:e.subarray(t+a,t+o)}}function N6s(e,t){pD(e,80,"volume space size"),dLe(e,120,"volume set size"),dLe(e,124,"volume sequence number");let s=dLe(e,128,"logical block size");if(pD(e,132,"path table size"),s!==pb)throw new Q(`Unsupported ISO 9660 logical block size ${s} (expected 2048)`);let n=U6s(e,156,e.byteLength-156,"root");if((n.flags&2)===0||n.size===0||n.identifier.byteLength!==1||n.identifier[0]!==0)throw Po("invalid root directory record");return{blockSize:s,root:n,joliet:t}}async function u7r(e,t,s){if(e.size<JRt+pb)throw Po("truncated volume descriptor set");let n=JRt,o=16,i=new Uint8Array(0),r=0,a,l,u=!1,p=!1,c=!1,d=0;while(!c&&n<e.size){let f=mLe(o,pb,"volume descriptor scan"),m=s.maxIndexSize-d;if(m<pb)throw Po("volume descriptor set exceeds metadata limit");let g=Math.floor(Math.min(f,m,e.size-n)/pb);if(g<1)throw Po("truncated volume descriptor");let h=g*pb;i=await t.read(e,n,n+h,"volume descriptor set"),r=0;while(r+pb<=i.byteLength){let T=i.subarray(r,r+pb),R=T[0];if(fc(T,1,"CDROM")||fc(T,9,"CDROM"))p=!0;if(fc(T,1,"BEA01")||fc(T,1,"NSR02")||fc(T,1,"NSR03")||fc(T,1,"TEA01"))u=!0;if(fc(T,1,"CD001")){if(T[6]!==1&&T[6]!==2)throw Po("unsupported volume descriptor version");if(R===1)a=N6s(T,!1);if(R===2&&T[88]===37&&T[89]===47&&[64,67,69].includes(T[90]))l=N6s(T,!0);if(R===255){c=!0;break}}r+=pb,d+=pb}n+=i.byteLength,o=Math.min(o*2,Math.ceil(s.maxIndexSize/pb))}if(!a&&!l){if(p)throw new Q("Unsupported High Sierra CD-ROM filesystem (not ISO 9660)");if(u)throw new Q("Unsupported UDF-only image (no ISO 9660 volume descriptor)");throw Po("primary volume descriptor not found")}if(!c)throw Po("volume descriptor terminator not found");if(l)return{...l,rockRidgeRoot:a?.root};return a}function H6s(e,t){let s;if(t){if(e.byteLength%2!==0)throw Po("Joliet identifier has an odd byte length");let n=new Uint16Array(e.byteLength/2);for(let i=0;i<n.length;i++)n[i]=Dle(e,i*2);let o=[];for(let i=0;i<n.length;i+=4096)o.push(String.fromCharCode(...n.subarray(i,i+4096)));s=o.join("")}else s=QRt.decode(e);return s.endsWith(";1")?s.slice(0,-2):s}function B6s(e){let t=e.systemUse;for(let s=0;s+7<=t.byteLength;){let n=t[s+2];if(n<4||s+n>t.byteLength)return;if(t[s]===83&&t[s+1]===80&&n===7&&t[s+4]===190&&t[s+5]===239)return t[s+6];s+=n}return}async function W6s(e,t,s,n,o,i){if(t===void 0||t>e.systemUse.byteLength)return{};let r=[e.systemUse.subarray(t)],a=new Set,l=[],u=[],p=!1,c,d;for(let g=0;g<r.length;g++){let h=r[g];for(let T=0;T+4<=h.byteLength;){let R=String.fromCharCode(h[T],h[T+1]),C=h[T+2],w=h[T+3];if(C<4||T+C>h.byteLength)throw Po("malformed SUSP record");if(w!==1&&(R==="CE"||R==="NM"||R==="PX"||R==="RE"||R==="CL"||R==="PL"||R==="SL"||R==="ST"))throw Po(`unsupported SUSP ${R} version ${w}`);let x=h.subarray(T+4,T+C);if(R==="ST")break;if(R==="CE"){if(x.byteLength<24)throw Po("short SUSP CE record");let A=pD(x,0,"SUSP continuation block"),I=pD(x,8,"SUSP continuation offset"),M=pD(x,16,"SUSP continuation length");Vn(M,i,"ISO SUSP continuation");let O=hP(mLe(A,n,"SUSP continuation location"),I,"SUSP continuation location"),_=hP(O,M,"SUSP continuation range"),F=`${O}:${_}`;if(a.has(F))throw Po("cyclic SUSP continuation");if(a.size>=a7r)throw Po("too many SUSP continuations");a.add(F),r.push(await o.read(s,O,_,"SUSP continuation"))}if(R==="NM"&&x.byteLength>=1){let A=x[0];if((A&6)===0)l.push(QRt.decode(x.subarray(1)));else if(A&2)l.push(".");else if(A&4)l.push("..")}if(R==="PX"&&x.byteLength>=8)c=pD(x,0,"Rock Ridge PX mode");if(R==="RE"||R==="CL"||R==="PL")d=R;if(R==="SL"&&x.byteLength>=1){let A=1;while(A<x.byteLength){if(A+2>x.byteLength)throw Po("malformed Rock Ridge SL component");let I=x[A],M=x[A+1];if(A+=2,A+M>x.byteLength)throw Po("malformed Rock Ridge SL component");let O;if(I&8)O="";else if(I&4)O="..";else if(I&2)O=".";else O=QRt.decode(x.subarray(A,A+M));if(p&&u.length>0)u[u.length-1]+=O;else u.push(O);p=(I&1)!==0,A+=M}}T+=C}}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 G6s(e,t){for(let s=e;s;s=s.parent)if(s.key===t)return!0;return!1}function p7r(e,t){let s=hP(e.extent,e.extendedAttributeBlocks,"file extent block");return{start:mLe(s,t,"file extent offset"),size:e.size,fileUnitSize:e.fileUnitSize,interleaveGapSize:e.interleaveGapSize}}async function $6s(e,t,s,n,o){let i=mLe(hP(t.extent,t.extendedAttributeBlocks,"directory extent block"),s,"directory extent offset"),r=hP(i,t.size,"directory extent range"),a=await n.read(e,i,r,"directory extent"),l=[];for(let u=0;u<a.byteLength;){let p=s-u%s,c=a[u];if(c===0){u+=p;continue}if(c>p||c>a.byteLength-u)throw Po("directory record crosses a logical block");l.push(U6s(a,u,c,"member")),xr(l.length,o),u+=c}return l}async function c7r(e,t,s,n,o,i){let r=`${t.extent}:${t.size}`,a=[{record:t,parentPath:"",depth:0,ancestor:{key:r}}],l;while(a.length>0){let u=a.pop();if(u.depth>fLe)throw Po(`directory hierarchy exceeds ${fLe} levels`);let p=await $6s(e,u.record,s,n,o);if(u.depth===0&&p.length>0&&p[0].identifier.byteLength===1&&p[0].identifier[0]===0)l=B6s(p[0]);for(let c of p){if(c.identifier.byteLength===1&&(c.identifier[0]===0||c.identifier[0]===1))continue;let d=await W6s(c,l,e,s,n,o);if(d.relocation)throw new Q(`Unsupported Rock Ridge relocated directory (${d.relocation})`);let f=d.name??H6s(c.identifier,!1);No(Buffer.byteLength(f,"utf-8"),"member name",o.maxPathBytes);let m=u.parentPath?`${u.parentPath}/${f}`:f,g=Qr(m);if(!g)continue;if(No(Buffer.byteLength(g,"utf-8"),"member path",o.maxPathBytes),d.symlink!==void 0){No(Buffer.byteLength(d.symlink,"utf-8"),"link target",o.maxPathBytes);let R=W2.posix.isAbsolute(d.symlink)?void 0:_f(W2.posix.join(W2.posix.dirname(g),d.symlink));Xc(i,{path:g,isDirectory:!1,size:0,mtimeMs:c.mtimeMs,mode:d.mode,storage:{type:"link",targetPath:R??d.symlink,resolveTarget:R!==void 0}}),xr(i.size,o);continue}let h=i.get(g);if(h&&d.mode!==void 0)i.set(g,{...h,mode:d.mode});if((c.flags&2)===0)continue;let T=`${c.extent}:${c.size}`;if(G6s(u.ancestor,T))throw Po(`cyclic directory at '${g}'`);a.push({record:c,parentPath:g,depth:u.depth+1,ancestor:{key:T,parent:u.ancestor}})}}}async function d7r(e,t){if(!Number.isSafeInteger(e.size)||e.size<0)throw Po("invalid source size");let s=new D6s(t.limits),n=await u7r(e,s,t.limits),i={key:`${n.root.extent}:${n.root.size}`},r=[{record:n.root,parentPath:"",depth:0,ancestor:i}],a=new Map,l;while(r.length>0){let u=r.pop();if(u.depth>fLe)throw Po(`directory hierarchy exceeds ${fLe} levels`);let p=await $6s(e,u.record,n.blockSize,s,t.limits);if(u.depth===0&&p.length>0&&p[0].identifier.byteLength===1&&p[0].identifier[0]===0)l=B6s(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 Po("multi-extent directory is unsupported");while((f[f.length-1].flags&128)!==0){let x=p[++c];if(!x||x.identifier.byteLength!==d.identifier.byteLength)throw Po("unterminated multi-extent file");for(let A=0;A<d.identifier.byteLength;A++)if(x.identifier[A]!==d.identifier[A])throw Po("non-contiguous multi-extent file");if((x.flags&-129)!==(d.flags&-129))throw Po("inconsistent multi-extent file flags");f.push(x)}}c++;let m=await W6s(d,l,e,n.blockSize,s,t.limits);if(m.relocation)throw new Q(`Unsupported Rock Ridge relocated directory (${m.relocation})`);let g=m.name??H6s(d.identifier,n.joliet);No(Buffer.byteLength(g,"utf-8"),"member name",t.limits.maxPathBytes);let h=u.parentPath?`${u.parentPath}/${g}`:g,T=Qr(h);if(!T)continue;No(Buffer.byteLength(T,"utf-8"),"member path",t.limits.maxPathBytes);let R=(d.flags&2)!==0;if(m.symlink!==void 0){No(Buffer.byteLength(m.symlink,"utf-8"),"link target",t.limits.maxPathBytes);let x=W2.posix.isAbsolute(m.symlink)?void 0:_f(W2.posix.join(W2.posix.dirname(T),m.symlink));Xc(a,{path:T,isDirectory:!1,size:0,mtimeMs:d.mtimeMs,mode:m.mode,storage:{type:"link",targetPath:x??m.symlink,resolveTarget:x!==void 0}}),xr(a.size,t.limits);continue}if(R){Xc(a,{path:T,isDirectory:!0,size:0,mtimeMs:d.mtimeMs,mode:m.mode}),xr(a.size,t.limits);let x=`${d.extent}:${d.size}`;if(G6s(u.ancestor,x))throw Po(`cyclic directory at '${T}'`);r.push({record:d,parentPath:T,depth:u.depth+1,ancestor:{key:x,parent:u.ancestor}});continue}let C=0;for(let x of f)C=hP(C,x.size,"multi-extent member size");Oa(C,T,t.limits);let w=C===0?[]:f.map((x)=>p7r(x,n.blockSize));for(let x of w)ZRt(e,x.start,hP(x.start,x.size,"file extent range"),`extent for '${T}'`);Xc(a,{path:T,isDirectory:!1,size:C,mtimeMs:d.mtimeMs,mode:m.mode,storage:{type:"member",source:new q6s(e,n.blockSize,w)}}),xr(a.size,t.limits)}}if(n.rockRidgeRoot)await c7r(e,n.rockRidgeRoot,n.blockSize,s,t.limits,a);return[...a.values()]}function z6s(e){return fc(e,JRt+1,"CD001")}var pb=2048,JRt,fLe=256,a7r=32,QRt,j6s=async(e,t)=>{try{return await d7r(e,t)}catch(s){if(s instanceof Q)throw s;throw Po("could not parse image")}};var V6s=E(()=>{yT();aD();fi();mc();Lf();JRt=16*pb,QRt=new TextDecoder});class e8s{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 s=e;s>0;){if(this.pos>=this.bytes.byteLength-4)cD("truncated compressed data");let n=Math.min(s,8-this.bit);if(t=t*2**n+(this.bytes[this.pos]>>>8-this.bit-n&2**n-1),this.bit+=n,s-=n,this.bit===8)this.bit=0,this.pos++}return t}align(){if(this.bit!==0)this.pos++,this.bit=0}}class I9{#e=new Int32Array(16);#t=new Int32Array(16);#s=new Int32Array(16);#n;#o=!1;constructor(e){this.#n=new Int32Array(e)}build(e,t,s){this.#e.fill(0);for(let r=0;r<s;r++){let a=e[t+r]&15;if(a!==0)this.#e[a]++}let n=0,o=0;for(let r=1;r<=15;r++)n=n+this.#e[r-1]<<1,this.#t[r]=n,this.#s[r]=o,o+=this.#e[r];let i=this.#s.slice();for(let r=0;r<s;r++){let a=e[t+r]&15;if(a!==0)this.#n[i[a]++]=r}this.#o=o!==0}decode(e){if(!this.#o)cD("empty Huffman table");let t=0;for(let s=1;s<=15;s++){t=t<<1|e.read(1);let n=t-this.#t[s];if(n>=0&&n<this.#e[s])return this.#n[this.#s[s]+n]}cD("invalid Huffman symbol")}}class tCt{#e=new Uint8Array(0);#t=[0,0,0,0];#s=0;#n=0;#o=0;#r=0;#a=new Uint8Array(K6s);#i=[];#l=[];#u=0;reset(){this.#e=new Uint8Array(0),this.#t=[0,0,0,0],this.#s=0,this.#n=0,this.#o=0,this.#r=0,this.#a.fill(0),this.#i=[],this.#l=[],this.#u=0}decode(e,t,s,n,o){if(o<29)throw new Q(`Unsupported RAR4 compression algorithm version ${o}`);if(!n)this.reset();let i=this.#e.byteLength>s?this.#e.subarray(this.#e.byteLength-s):this.#e,r=new Uint8Array(i.byteLength+t+260);r.set(i);let a=i.byteLength,l=a+t,u=a,p=new e8s(e),c=new I9(gLe),d=new I9(P9),f=new I9(hLe),m=new I9(eCt),g=[],h=()=>{if(p.align(),p.read(1)!==0)throw new Q("Unsupported RAR4 PPMd compressed block");let x=p.read(1)!==0;if(this.#o=0,this.#r=0,!x)this.#a.fill(0);let A=y7r(p,this.#a,K6s),I=0;c.build(A,I,gLe),I+=gLe,d.build(A,I,P9),I+=P9,f.build(A,I,hLe),I+=hLe,m.build(A,I,eCt),this.#a.set(A)},T=(x,A)=>{if(x<=0||x>s||x>u)cD("invalid LZ distance");A=Math.min(A,l-u);for(let I=0;I<A;I++)r[u+I]=r[u+I-x];u+=A},R=(x)=>{this.#t[3]=this.#t[2],this.#t[2]=this.#t[1],this.#t[1]=this.#t[0],this.#t[0]=x},C=()=>{let x=p.read(8),A=(x&7)+1;if(A===7)A=p.read(8)+7;else if(A===8)A=p.read(16);let I=new Uint8Array(A);for(let U=0;U<A;U++)I[U]=p.read(8);let M=new t8s(I),O;if((x&128)!==0)if(O=M.readData(),O===0)this.#i=[],this.#l=[];else O--;else O=this.#u;if(O<0||O>this.#i.length)cD("invalid RarVM filter index");this.#u=O;let _=O===this.#i.length,F=M.readData();if((x&64)!==0)F+=258;F+=u-a;let L=(x&32)!==0?M.readData():this.#l[O]??0,D=new Int32Array(7);if(D[3]=245760,D[4]=L,(x&16)!==0){let U=M.read(7);for(let B=0;B<7;B++)if((U&1<<B)!==0)D[B]=M.readData()}let N;if(_){let U=M.readData(),B=new Uint8Array(U);for(let H=0;H<U;H++)B[H]=M.read(8);N=g7r(B),this.#i.push(N),this.#l.push(L)}else N=this.#i[O],this.#l[O]=L;if(N!==1&&N!==2&&N!==6)throw new Q(`Unsupported RAR4 RarVM filter type ${N||"unknown"}`);if(F<0||L<0||F+L>t)cD("invalid RarVM filter range");g.push({type:N,start:F,size:L,channels:D[0],fileOffset:D[6]})};h();while(u<l){let x=c.decode(p);if(x<256)r[u++]=x;else if(x>=271){let A=x-271,I=Y6s[A]+3+p.read(X6s[A]),M=d.decode(p),O=Q6s[M]+1,_=Z6s[M];if(_!==0)if(M>9){if(_>4)O+=p.read(_-4)*16;if(this.#r>0)this.#r--,O+=this.#o;else{let F=f.decode(p);if(F===16)this.#r=15,O+=this.#o;else O+=F,this.#o=F}}else O+=p.read(_);if(O>=8192)I++;if(O>=262144)I++;R(O),this.#s=O,this.#n=I,T(O,I)}else if(x===256)if(p.read(1)!==0)h();else{if(p.read(1)!==0)h();break}else if(x===257)C();else if(x===258){if(this.#n!==0)T(this.#s,this.#n)}else if(x<263){let A=x-259,I=this.#t[A];for(let _=A;_>0;_--)this.#t[_]=this.#t[_-1];this.#t[0]=I;let M=m.decode(p),O=Y6s[M]+2+p.read(X6s[M]);this.#s=I,this.#n=O,T(I,O)}else{let A=x-263,I=f7r[A]+1+p.read(m7r[A]);R(I),this.#s=I,this.#n=2,T(I,2)}}if(u!==l)cD(`decompressed size mismatch (${u-a} != ${t})`);let w=r.slice(a,l);return h7r(w,g),this.#e=r.slice(Math.max(0,l-s),l),w}}class t8s{#e;#t=0;constructor(e){this.#e=e}read(e){let t=0;for(let s=e;s>0;){let n=this.#t>>>3;if(n>=this.#e.byteLength)cD("truncated RarVM code");let o=this.#t&7,i=Math.min(s,8-o);t=t*2**i+(this.#e[n]>>>8-o-i&2**i-1),this.#t+=i,s-=i}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 g7r(e){let t=Ca(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 h7r(e,t){for(let s of t){let n=e.subarray(s.start,s.start+s.size);if(s.type===6){let i=n.slice(),r=0;for(let a=0;a<s.channels;a++){let l=0;for(let u=a;u<n.byteLength;u+=s.channels)l=l-i[r++]&255,n[u]=l}continue}let o=s.type===2?233:232;for(let i=0;i+4<n.byteLength;){let r=n[i++];if(r!==232&&r!==o)continue;let a=i+(s.fileOffset>>>0),l=T7r(n,i);if(l<0){if(l+a>=0)J6s(n,i,l+16777216)}else if(l-16777216<0)J6s(n,i,l-a);i+=4}}}function T7r(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function J6s(e,t,s){e[t]=s,e[t+1]=s>>>8,e[t+2]=s>>>16,e[t+3]=s>>>24}function y7r(e,t,s){let n=new Uint8Array(20);for(let r=0;r<20;r++){let a=e.read(4);if(a===15){let l=e.read(4);if(l!==0){l+=2;while(l-- >0&&r<20)n[r++]=0;r--;continue}}n[r]=a}let o=new I9(20);o.build(n,0,20);let i=new Uint8Array(s);for(let r=0;r<s;){let a=o.decode(e);if(a<16)i[r]=a+t[r]&15,r++;else if(a===16||a===17){let l=e.read(a===16?3:7)+(a===16?3:11),u=r===0?0:i[r-1];while(l-- >0&&r<s)i[r++]=u}else{let l=e.read(a===18?3:7)+(a===18?3:11);while(l-- >0&&r<s)i[r++]=0}}return i}function cD(e){throw new Q(`Invalid RAR4 archive: ${e}`)}var gLe=299,P9=60,hLe=17,eCt=28,K6s,Y6s,X6s,f7r,m7r,Q6s,Z6s;var s8s=E(()=>{uP();fi();K6s=gLe+P9+hLe+eCt,Y6s=[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],X6s=[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],f7r=[0,4,8,16,32,64,128,192],m7r=[2,2,3,4,5,6,6,6],Q6s=new Int32Array(P9),Z6s=new Uint8Array(P9);{let e=[4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,14,0,12],t=0,s=0;for(let n=0;n<e.length;n++)for(let o=0;o<e[n];o++)Q6s[s]=t,Z6s[s]=n,t+=2**n,s++}});class i8s{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)Hd("invalid bit count");let t=0;for(let s=e;s>0;){if(this.pos>=this.bytes.byteLength-16)Hd("truncated compressed data");let n=Math.min(s,8-this.bit);if(t=t*2**n+(this.bytes[this.pos]>>>8-this.bit-n&2**n-1),this.bit+=n,s-=n,this.bit===8)this.bit=0,this.pos++}return t}peek15(){let e=this.pos,t=this.bit,s=this.read(15);return this.pos=e,this.bit=t,s}align(){if(this.bit!==0)this.pos++,this.bit=0}byte(){if(this.bit!==0)Hd("unaligned compressed data");if(this.pos>=this.bytes.byteLength-16)Hd("truncated compressed data");return this.bytes[this.pos++]}atBlockEnd(){return this.pos>this.blockEnd||this.pos===this.blockEnd&&this.bit>=this.blockEndBit}}class QE{#e;#t;#s;#n;#o;#r;#a=!1;constructor(e,t=15){this.#t=e,this.#e=t,this.#s=new Int32Array(t+1),this.#n=new Int32Array(t+1),this.#o=new Int32Array(t+1),this.#r=new Int32Array(e)}build(e,t=0){this.#s.fill(0);for(let i=0;i<this.#t;i++){let r=e[t+i];if(r>this.#e)Hd("invalid Huffman code length");if(r!==0)this.#s[r]++}let s=0,n=0;for(let i=1;i<=this.#e;i++)s=s+this.#s[i-1]<<1,this.#n[i]=s,this.#o[i]=n,n+=this.#s[i];if(n!==0&&s+this.#s[this.#e]!==1<<this.#e)Hd("incomplete Huffman table");let o=this.#o.slice();for(let i=0;i<this.#t;i++){let r=e[t+i];if(r!==0)this.#r[o[r]++]=i}this.#a=n!==0}decode(e){if(!this.#a)Hd("empty Huffman table");let t=0;for(let s=1;s<=this.#e;s++){t=t<<1|e.read(1);let n=t-this.#n[s];if(n>=0&&n<this.#s[s])return this.#r[this.#o[s]+n]}Hd("invalid Huffman symbol")}}class oCt{#e=new Uint8Array(0);#t=[4294967295,4294967295,4294967295,4294967295];#s=0;#n=new QE(JE);#o=new QE(G2);#r=new QE(sue);#a=new QE(nCt);#i=!1;reset(){this.#e=new Uint8Array(0),this.#t=[4294967295,4294967295,4294967295,4294967295],this.#s=0,this.#n=new QE(JE),this.#o=new QE(G2),this.#r=new QE(sue),this.#a=new QE(nCt),this.#i=!1}decode(e,t,s,n,o){if(o!==0&&o!==1)throw new Q(`Unsupported RAR5 compression algorithm version ${o}`);if(!n)this.reset();if(!Number.isSafeInteger(s)||s<131072)Hd("invalid dictionary size");let i=this.#e.byteLength>s?this.#e.subarray(this.#e.byteLength-s):this.#e,r=new Uint8Array(i.byteLength+t+C7r);r.set(i);let a=i.byteLength,l=a,u=l+t,p=[],c=new i8s(e),d=this.#n,f=this.#o,m=this.#r,g=this.#a,h=!1,T=()=>{c.align();let w=c.byte(),x=w^c.byte(),A=w>>>3&3;if(A===3)Hd("invalid compressed block header");let I=c.byte();x^=I;for(let N=0;N<A;N++){let U=c.byte();x^=U,I+=U*2**(8*(N+1))}if(x!==90)Hd("compressed block checksum mismatch");let M=(w&7)+1;if(I+=M>>>3,I===0)Hd("empty compressed block");if(I--,M&=7,c.blockEnd=c.pos+I,c.blockEndBit=M,h=(w&64)!==0,(w&128)===0)return;let O=new Uint8Array(20);for(let N=0;N<20;){let U=c.read(4);if(U===15){let B=c.read(4);if(B!==0){N=Math.min(20,N+B+2);continue}}O[N++]=U}let _=new QE(20);_.build(O);let F=o===1?sCt:sCt-16,L=new Uint8Array(F);for(let N=0;N<F;){let U=_.decode(c);if(U<16){L[N++]=U;continue}let B=(U-16&1)*4;B+=B+3+c.read(B+3);let H=U<18?N===0?Hd("invalid Huffman repeat"):L[N-1]:0,W=Math.min(F,N+B);L.fill(H,N,W),N=W}let D=new Uint8Array(sCt);if(o===0)D.set(L.subarray(0,JE+64)),D.set(L.subarray(JE+64),JE+G2);else D.set(L);d.build(D),f.build(D,JE),m.build(D,JE+G2),g.build(D,JE+G2+sue),this.#i=!1;for(let N=0;N<sue;N++)if(D[JE+G2+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)Hd("compressed block overread");if(c.align(),h)break;T();continue}let w=d.decode(c);if(w<256){r[a++]=w;continue}if(w===256){let I=(c.read(2)+1)*8,M=0;for(let D=0;D<I;D+=8)M+=c.read(8)*2**D;let O=(c.read(2)+1)*8,_=0;for(let D=0;D<O;D+=8)_+=c.read(8)*2**D;let F=c.read(3),L=F===0?c.read(5)+1:0;if(F>3)throw new Q(`Unsupported RAR5 filter type ${F}`);if(_>b7r||a-l+M+_>t)Hd("invalid filter range");p.push({type:F,channels:L,start:a-l+M,size:_});continue}let x,A=this.#t[0];if(w<262){if(w>=258){let I=w-258;A=this.#t[I];for(let O=I;O>0;O--)this.#t[O]=this.#t[O-1];this.#t[0]=A;let M=g.decode(c);x=M>=8?n8s(c,M):M,x+=2,this.#s=x}else if(x=this.#s,x===0)continue}else{this.#t[3]=this.#t[2],this.#t[2]=this.#t[1],this.#t[1]=this.#t[0];let I=w-262;x=I>=8?n8s(c,I):I,x+=2;let M=f.decode(c);if(M>=4){let O=M-2>>>1;if(M=(2|M&1)*2**O,O<4)M+=c.read(O);else if(x+=R7r[O]??3,this.#i)M+=c.read(O-4)*16+m.decode(c);else M+=c.read(O)}A=M+1,this.#t[0]=A,this.#s=x}if(A<=0||A>s||A>a)Hd("invalid LZ distance");if(a+x>r.byteLength)Hd("invalid LZ match length");for(let I=0;I<x;I++)r[a+I]=r[a+I-A];a+=x}if(a!==u)Hd(`decompressed size mismatch (${a-l} != ${t})`);let R=r.slice(l,u);S7r(R,p);let C=Math.max(0,u-s);return this.#e=r.slice(C,u),R}}function n8s(e,t){let s=(t>>>2)-1;return((4|t&3)<<s)+e.read(s)}function S7r(e,t){for(let s of t){let n=e.subarray(s.start,s.start+s.size);if(s.type===0){let o=n.slice(),i=0;for(let r=0;r<s.channels;r++){let a=0;for(let l=r;l<n.byteLength;l+=s.channels)a=a-o[i++]&255,n[l]=a}}else if(s.type===1||s.type===2)for(let i=0;i+4<n.byteLength;){let r=n[i++];if(r!==232&&(s.type===1||r!==233))continue;let a=s.start+i&16777215,l=o8s(n,i);if(l>>>0<16777216)l-=a;else if(l>>>0>=-a>>>0)l+=16777216;else{i+=4;continue}r8s(n,i,l),i+=4}else for(let o=0;o+3<n.byteLength;o+=4){if(n[o+3]!==235)continue;let i=o8s(n,o),r=(i&4278190080|i-(s.start+o>>2)&16777215)>>>0;r8s(n,o,r)}}}function o8s(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function r8s(e,t,s){e[t]=s,e[t+1]=s>>>8,e[t+2]=s>>>16,e[t+3]=s>>>24}function Hd(e){throw new Q(`Invalid RAR5 archive: ${e}`)}var JE=306,G2=80,sue=16,nCt=44,sCt,R7r,C7r=4100,b7r=4194304;var a8s=E(()=>{fi();sCt=JE+G2+sue+nCt,R7r=[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 c8s{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async read(e,t){return this.#e.read(this.#t,e,t)}}class d8s{#e;#t;#s;#n=new Map;#o=Promise.resolve();constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s.limits}member(e){return new c8s(this,e)}async read(e,t,s){let n=this.#o.then(async()=>{if(!this.#n.has(e))await this.#r(e)});this.#o=n.catch(()=>{return}),await n;let o=this.#n.get(e);if(!o)throw new Q(`Failed to extract RAR member '${s}'`);if(o.byteLength!==t)throw new Q(`RAR member '${s}' size mismatch (${o.byteLength} != ${t})`);return o.slice()}async#r(e){let t=this.#t[e];if(!t)throw new Q("Invalid RAR member index");let s=e;if(t.solid)while(s>0&&this.#t[s].solid&&this.#t[s-1].format===t.format)s--;let n=new tCt,o=new oCt;for(let i=s;i<=e;i++){let r=this.#t[i];if(r.isDirectory)continue;if(Oa(r.unpackedSize,r.path,this.#s),r.method===0&&r.packedSize!==r.unpackedSize)Qu("stored member size mismatch");if(r.method>5)throw new Q(r.format===4?`Unsupported RAR4 compression method 0x${(r.method+48).toString(16)} for '${r.path}'`:`Unsupported RAR5 compression method ${r.method} for '${r.path}'`);if(r.method!==0)Di(r.packedSize+2*r.unpackedSize+2*r.dictionarySize+8192,this.#s);let a=cb(r.dataStart,r.packedSize,this.#e.size,"member data"),l=await this.#e.read(r.dataStart,a),u;if(r.method===0){if(u=l,r.solid)if(r.format===4)n.reset();else o.reset()}else if(r.format===5)u=o.decode(l,r.unpackedSize,r.dictionarySize,r.solid,r.version);else u=n.decode(l,r.unpackedSize,r.dictionarySize,r.solid,r.version);if(u.byteLength!==r.unpackedSize)Qu(`member '${r.path}' size mismatch`);if(r.crc!==void 0&&Ca(u)!==r.crc)throw new Q(`RAR member '${r.path}' CRC32 mismatch`);this.#n.set(i,u.slice())}}}function f8s(e){return rCt(e)!==void 0}async function k7r(e,t){let s=Math.min(e.size,$2.byteLength),n=await e.read(0,s),o=rCt(n);while(!o&&s<Math.min(e.size,1048576+$2.byteLength)){let l=Math.min(e.size,1048576+$2.byteLength,Math.max(65536,s*2));Vn(l,t.limits,"RAR signature scan");let u=await e.read(s,l),p=new Uint8Array(l);p.set(n),p.set(u,s),n=p,s=l,o=rCt(n)}if(!o)throw new Q("Invalid RAR archive: signature not found");let i=[{start:0,bytes:n}],r=n.byteLength;Vn(r,t.limits,"RAR metadata");let a=o.offset+(o.version===5?$2.byteLength:iCt.byteLength);while(a<e.size)if(o.version===5){if(a+5>e.size)Qu("truncated RAR5 header");let l=await e.read(a,Math.min(e.size,a+16)),u={offset:4},p=yl(l,u,l.byteLength,"header size");if(p>2097152)Qu("RAR5 header exceeds format limit");let c=cb(a,u.offset+p,e.size,"RAR5 header");Vn(r+c-a,t.limits,"RAR metadata");let d=await e.read(a,c);i.push({start:a,bytes:d}),r+=d.byteLength,Vn(r,t.limits,"RAR metadata");let f={offset:u.offset},m=yl(d,f,d.byteLength,"header type"),g=yl(d,f,d.byteLength,"header flags");if((g&1)!==0)yl(d,f,d.byteLength,"extra area size");let h=(g&2)!==0?yl(d,f,d.byteLength,"data size"):0;if(a=cb(c,h,e.size,"RAR5 data area"),m===4||m===5)break}else{if(a+7>e.size)Qu("truncated RAR4 base header");let l=await e.read(a,Math.min(e.size,a+11)),u=l[2],p=Pn(l,3),c=Pn(l,5);if(c<7)Qu("invalid RAR4 header size");let d=cb(a,c,e.size,"RAR4 header");Vn(r+d-a,t.limits,"RAR metadata");let f=await e.read(a,d);i.push({start:a,bytes:f}),r+=f.byteLength,Vn(r,t.limits,"RAR metadata");let m=(p&32768)!==0?Ps(f,7):0,g=cb(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=Ps(f,h+17);if(T===3&&(R&61440)===40960)Vn(r+m,t.limits,"RAR metadata"),i.push({start:d,bytes:await e.read(d,g)}),r+=m,Vn(r,t.limits,"RAR metadata")}}if(a=g,u===123||u===115&&(p&128)!==0)break}return i.sort((l,u)=>l.start-u.start||u.bytes.byteLength-l.bytes.byteLength),{marker:o,segments:i}}function w7r(e,t){let s=(i,r)=>{let a=0,l=t.length;while(a<l){let u=a+l>>>1;if(t[u].start<=i)a=u+1;else l=u}for(let u=a-1;u>=0;u--){let p=t[u];if(i>=p.start&&r<=p.start+p.bytes.byteLength)return p}Qu("RAR parser accessed member payload while indexing")},n=Object.create(null);return new Proxy(n,{get(i,r){if(r==="byteLength"||r==="length")return e;if(r==="subarray")return(a,l=e)=>{let u=s(a,l);return u.bytes.subarray(a-u.start,l-u.start)};if(typeof r==="string"){let a=Number(r);if(Number.isSafeInteger(a)&&a>=0){let l=s(a,a+1);return l.bytes[a-l.start]}}return}})}function x7r(e,t,s){let n=[],o=t+$2.byteLength,i=!1;while(o<e.byteLength){if(o+5>e.byteLength)Qu("truncated RAR5 header");let r=Ps(e,o),a=o+4,l={offset:a},u=yl(e,l,e.byteLength,"header size");if(u>2097152)Qu("RAR5 header exceeds format limit");Vn(u,s.limits,"RAR5 header");let p=l.offset,c=cb(p,u,e.byteLength,"RAR5 header");if(Ca(e.subarray(a,c))!==r)Qu("RAR5 header CRC32 mismatch");let d={offset:p},f=yl(e,d,c,"header type"),m=yl(e,d,c,"header flags"),g=(m&1)!==0?yl(e,d,c,"extra area size"):0,h=(m&2)!==0?yl(e,d,c,"data size"):0;if((m&24)!==0)throw new Q("Unsupported multi-volume RAR5 archive");let T=c,R=cb(T,h,e.byteLength,"RAR5 data area");if(g>c-d.offset)Qu("invalid RAR5 extra area size");let C=c-g;if(f===4)throw new Q("Encrypted RAR5 headers are not supported");if(f===1){let w=yl(e,d,C,"archive flags");if((w&1)!==0)throw new Q("Unsupported multi-volume RAR5 archive");if((w&8)!==0)throw new Q("Unsupported RAR5 recovery record");if((w&2)!==0)yl(e,d,C,"volume number");i=!0}else if(f===2||f===3){let w=yl(e,d,C,"file flags"),x=yl(e,d,C,"unpacked size");if((w&8)!==0)throw new Q("RAR5 member with unknown unpacked size is not supported");let A=yl(e,d,C,"file attributes"),I;if((w&2)!==0)Jg(d.offset,4,C,"RAR5 modification time"),I=Ps(e,d.offset)*1000,d.offset+=4;let M;if((w&4)!==0)Jg(d.offset,4,C,"RAR5 data CRC32"),M=Ps(e,d.offset),d.offset+=4;let O=yl(e,d,C,"compression information"),_=O&63;if(_===1&&(O&1048576)!==0)_=0;let F=(O&64)!==0,L=O>>>7&7,N=131072*2**(O>>>10&31);if((O&63)===1)N+=N*(O>>>15&31)/32;if(!Number.isSafeInteger(N)||N>s.limits.maxInMemorySize)throw new Q(`RAR5 dictionary is too large (${N} bytes)`);let U=yl(e,d,C,"host OS"),B=yl(e,d,C,"file name size");No(B,"member path",s.limits.maxPathBytes),Jg(d.offset,B,C,"RAR5 file name");let H;try{H=l8s.decode(e.subarray(d.offset,d.offset+B))}catch{throw new Q("Invalid RAR5 UTF-8 member name")}d.offset+=B;let W;for(let z of E7r(e,C,c)){let K={offset:z.start};if(z.type===1)throw new Q(`Encrypted RAR5 member '${H}' is not supported`);if(z.type===3){let J=yl(e,K,z.end,"time flags");if((J&2)!==0)if((J&1)!==0)Jg(K.offset,4,z.end,"Unix modification time"),I=Ps(e,K.offset)*1000;else Jg(K.offset,8,z.end,"Windows modification time"),I=I7r(e,K.offset)}else if(z.type===5){let J=yl(e,K,z.end,"redirection type");yl(e,K,z.end,"redirection flags");let se=yl(e,K,z.end,"link target size");if(No(se,"link target",s.limits.maxPathBytes),Jg(K.offset,se,z.end,"link target"),J<1||J>5)throw new Q(`Unsupported RAR5 redirection type ${J}`);try{W=l8s.decode(e.subarray(K.offset,K.offset+se))}catch{throw new Q("Invalid RAR5 UTF-8 link target")}}}if(f===2){Oa(x,H,s.limits);let z=Qr(H);if(z){let K;if(W!==void 0){let se=g8s(z,W);W=se.target,K=se.resolveTarget}let J=(w&1)!==0;n.push({format:5,path:z,dataStart:T,packedSize:h,unpackedSize:x,method:L,version:_,dictionarySize:N,solid:F,crc:M,isDirectory:J,mtimeMs:I,mode:U===1?A:void 0,linkTarget:W,linkResolveTarget:K}),xr(n.length,s.limits)}}else if(H==="RR")throw new Q("Unsupported RAR5 recovery record")}else if(f===5){if((yl(e,d,C,"end flags")&1)!==0)throw new Q("Unsupported multi-volume RAR5 archive");break}else if((m&4)===0)throw new Q(`Unsupported RAR5 header type ${f}`);o=R}if(!i)Qu("RAR5 main header is missing");return n}function v7r(e,t,s){let n=[],o=t+iCt.byteLength,i=!1;while(o<e.byteLength){Jg(o,7,e.byteLength,"RAR4 base header");let r=Pn(e,o),a=e[o+2],l=Pn(e,o+3),u=Pn(e,o+5);if(u<7)Qu("invalid RAR4 header size");Vn(u,s.limits,"RAR4 header");let p=cb(o,u,e.byteLength,"RAR4 header");if((Ca(e.subarray(o+2,p))&65535)!==r)Qu("RAR4 header CRC mismatch");let c=0,d=o+7;if((l&32768)!==0)Jg(d,4,p,"RAR4 additional size"),c=Ps(e,d),d+=4;let f=p,m=cb(f,c,e.byteLength,"RAR4 data area");if(a===115){if((l&1)!==0)throw new Q("Unsupported multi-volume RAR4 archive");if((l&64)!==0)throw new Q("Unsupported RAR4 recovery record");if((l&128)!==0)throw new Q("Encrypted RAR4 headers are not supported");i=!0}else if(a===116){Jg(d,21,p,"RAR4 file header");let g=Ps(e,d);d+=4;let h=e[d++],T=Ps(e,d);d+=4;let R=Ps(e,d);d+=4;let C=e[d++],w=e[d++],x=Pn(e,d);d+=2;let A=Ps(e,d);d+=4;let I=c,M=g;if((l&256)!==0)Jg(d,8,p,"RAR4 high sizes"),I+=Ps(e,d)*4294967296,d+=4,M+=Ps(e,d)*4294967296,d+=4,m=cb(f,I,e.byteLength,"RAR4 file data");if((l&3)!==0)throw new Q("Unsupported multi-volume RAR4 member");if((l&4)!==0)throw new Q("Encrypted RAR4 file data is not supported");if(w<48||w>53)throw new Q(`Unsupported RAR4 compression method 0x${w.toString(16)}`);No(x,"member path",s.limits.maxPathBytes),Jg(d,x,p,"RAR4 file name");let O=e.subarray(d,d+x),_=(l&512)!==0?A7r(O):TLe.decode(O);if(d+=x,(l&1024)!==0)Jg(d,8,p,"RAR4 salt"),d+=8;let F=p8s(R);if((l&4096)!==0){Jg(d,2,p,"RAR4 extended time flags");let D=Pn(e,d);d+=2;for(let N=0;N<4;N++){let U=D>>>(3-N)*4&15;if((U&8)===0)continue;let B=R;if(N!==0)Jg(d,4,p,"RAR4 extended time"),B=Ps(e,d),d+=4;let H=p8s(B)+((U&4)!==0?1000:0),W=0,z=U&3;Jg(d,z,p,"RAR4 extended time precision");for(let K=0;K<z;K++)W|=e[d++]<<(K+3-z)*8;if(H+=W/1e4,N===0)F=H}}Oa(M,_,s.limits);let L=Qr(_);if(L){let D=(l>>>5&7)===7,N=h===3?A:void 0,U,B;if(N!==void 0&&(N&61440)===40960){if(w!==48||I!==M)throw new Q(`Unsupported compressed RAR4 symlink '${L}'`);No(I,"link target",s.limits.maxPathBytes);let H=g8s(L,TLe.decode(e.subarray(f,m)));U=H.target,B=H.resolveTarget}n.push({format:4,path:L,dataStart:f,packedSize:I,unpackedSize:M,method:w-48,version:C,dictionarySize:M7r(l),solid:(l&16)!==0,crc:T,isDirectory:D,mtimeMs:F,mode:N,linkTarget:U,linkResolveTarget:B}),xr(n.length,s.limits)}}else if(a===120)throw new Q("Unsupported RAR4 recovery record");else if(a===123){if((l&1)!==0)throw new Q("Unsupported multi-volume RAR4 archive");break}o=m}if(!i)Qu("RAR4 main header is missing");return n}function E7r(e,t,s){let n=[],o={offset:t};while(o.offset<s){let i=yl(e,o,s,"extra record size"),r=o.offset,a=cb(r,i,s,"extra record"),l=yl(e,o,a,"extra record type");n.push({type:l,start:o.offset,end:a}),o.offset=a}return n}function yl(e,t,s,n){let o=0,i=1;for(let r=0;r<10;r++){if(t.offset>=s)Qu(`truncated ${n}`);let a=e[t.offset++];if(o+=(a&127)*i,!Number.isSafeInteger(o))Qu(`${n} is too large`);if((a&128)===0)return o;i*=128}Qu(`${n} vint is too long`)}function rCt(e){let t=Math.min(e.byteLength,1048576+$2.byteLength);for(let s=0;s<t;s++){if(u8s(e,s,$2))return{version:5,offset:s};if(u8s(e,s,iCt))return{version:4,offset:s}}return}function u8s(e,t,s){if(t+s.byteLength>e.byteLength)return!1;for(let n=0;n<s.byteLength;n++)if(e[t+n]!==s[n])return!1;return!0}function A7r(e){let t=e.indexOf(0);if(t<0)return TLe.decode(e);if(++t>=e.byteLength)return TLe.decode(e.subarray(0,t-1));let s=e[t++],n=0,o=0,i=0,r="";while(t<e.byteLength){if(i===0){if(o=e[t++],i=8,t>=e.byteLength)break}let a=o>>>6;if(a===0)r+=String.fromCharCode(e[t++]),n++;else if(a===1)r+=String.fromCharCode(e[t++]+(s<<8)),n++;else if(a===2){if(t+1>=e.byteLength)Qu("truncated RAR4 Unicode name");r+=String.fromCharCode(e[t]|e[t+1]<<8),t+=2,n++}else{let l=e[t++];if((l&128)!==0){if(t>=e.byteLength)Qu("truncated RAR4 Unicode name correction");let u=e[t++];l=(l&127)+2;for(;l>0&&n<e.byteLength;l--,n++)r+=String.fromCharCode(s<<8|e[n]+u&255)}else{l+=2;for(;l>0&&n<e.byteLength;l--,n++)r+=String.fromCharCode(e[n])}}o=o<<2&255,i-=2}return r}function g8s(e,t){let s=t.replace(/\\/g,"/");if(s.startsWith("/"))return{target:s,resolveTarget:!1};let n=e.split("/");n.pop();for(let o of s.split("/")){if(!o||o===".")continue;if(o===".."){if(n.length===0)return{target:s,resolveTarget:!1};n.pop()}else n.push(o)}return{target:n.join("/"),resolveTarget:!0}}function M7r(e){let t=e>>>5&7;return t===7?4194304:65536*2**t}function p8s(e){let t=(e&31)*2,s=e>>>5&63,n=e>>>11&31,o=e>>>16&31,i=e>>>21&15,r=(e>>>25&127)+1980;return new Date(r,i-1,o,n,s,t).getTime()}function I7r(e,t){return(Ps(e,t)+Ps(e,t+4)*4294967296)/1e4-11644473600000}function cb(e,t,s,n){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||t<0)Qu(`invalid ${n} range`);let o=e+t;if(!Number.isSafeInteger(o)||o<e||o>s)Qu(`truncated ${n}`);return o}function Jg(e,t,s,n){cb(e,t,s,n)}function Qu(e){throw new Q(`Invalid RAR archive: ${e}`)}var iCt,$2,l8s,TLe,m8s=async(e,t)=>{if(!Number.isSafeInteger(e.size)||e.size<0)throw new Q("Archive is too large to read safely");let s=await k7r(e,t),n=w7r(e.size,s.segments),o=s.marker,i=o.version===5?x7r(n,o.offset,t):v7r(n,o.offset,t),r=new d8s(e,i,t),a=[];for(let l=0;l<i.length;l++){let u=i[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:r.member(l)};a.push(p)}return a};var h8s=E(()=>{yT();uP();fi();mc();Lf();s8s();a8s();iCt=Uint8Array.of(82,97,114,33,26,7,0),$2=Uint8Array.of(82,97,114,33,26,7,1,0),l8s=new TextDecoder("utf-8",{fatal:!0}),TLe=new TextDecoder("windows-1252")});function F7r(e,t){let s=e%t;return s===0?e:e+t-s}async function nue(e,t,s,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<t||s>e.size)throw new Q(`Invalid RPM package: truncated ${n}`);let o=await e.read(t,s);if(o.byteLength!==s-t)throw new Q(`Invalid RPM package: truncated ${n}`);return o}function S8s(e,t,s){if(e.byteLength!==z2||TT(e,0)!==P7r)throw new Q(`Invalid RPM package: corrupt ${s} header magic`);for(let a=4;a<8;a++)if(e[a]!==0)throw new Q(`Invalid RPM package: corrupt ${s} header reserved bytes`);let n=TT(e,8),o=TT(e,12);xr(n,t.limits);let r=n*oue+o;if(!Number.isSafeInteger(r))throw new Q(`Invalid RPM package: ${s} header is too large`);return Vn(z2+r,t.limits,`RPM ${s} header`),{indexCount:n,dataSize:o,bodySize:r,totalSize:z2+r}}function w8s(e,t,s){let n=t.indexCount*oue;if(e.byteLength!==t.bodySize)throw new Q(`Invalid RPM package: truncated ${s} header`);for(let o=0;o<t.indexCount;o++){let i=o*oue,r=TT(e,i),a=TT(e,i+4),l=TT(e,i+8),u=TT(e,i+12);if(l>t.dataSize)throw new Q(`Invalid RPM package: tag ${r} 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 Q(`Invalid RPM package: null tag ${r} has values`);continue}else if(a===RLe||a===8||a===9){let d=a===RLe?1:u;if(a===RLe&&u!==1)throw new Q(`Invalid RPM package: string tag ${r} has an invalid count`);if(d>p)throw new Q(`Invalid RPM package: string tag ${r} exceeds header data`);let f=n+l,m=n+t.dataSize;for(let g=0;g<d;g++){while(f<m&&e[f]!==0)f++;if(f===m)throw new Q(`Invalid RPM package: string tag ${r} is not NUL-terminated`);f++}continue}else throw new Q(`Invalid RPM package: tag ${r} uses unknown data type ${a}`);if(l%c!==0)throw new Q(`Invalid RPM package: tag ${r} data is misaligned`);if(u*c>p)throw new Q(`Invalid RPM package: tag ${r} exceeds header data`)}}function L7r(e,t,s,n,o,i,r){if(i!==RLe||o!==1)throw new Q(`Invalid RPM package: tag ${r} must contain one string`);let a=t+n,l=t+s,u=a;while(u<l&&e[u]!==0)u++;if(u===l)throw new Q(`Invalid RPM package: tag ${r} string is not NUL-terminated`);if(u-a>4096)throw new Q(`Invalid RPM package: tag ${r} string is too large`);try{return _7r.decode(e.subarray(a,u))}catch{throw new Q(`Invalid RPM package: tag ${r} is not valid UTF-8`)}}function N7r(e,t){w8s(e,t,"main");let s=t.indexCount*oue;if(e.byteLength!==t.bodySize)throw new Q("Invalid RPM package: truncated main header");let n={};for(let o=0;o<t.indexCount;o++){let i=o*oue,r=TT(e,i),a=TT(e,i+4),l=TT(e,i+8),u=TT(e,i+12);if(l>t.dataSize)throw new Q(`Invalid RPM package: tag ${r} points outside header data`);if(r!==T8s&&r!==y8s&&r!==R8s&&r!==C8s&&r!==b8s)continue;let p=L7r(e,s,t.dataSize,l,u,a,r);switch(r){case T8s:n.name=p;break;case y8s:n.version=p;break;case R8s:n.payloadFormat=p;break;case C8s:n.payloadCompressor=p;break;case b8s:n.payloadFlags=p;break}}return n}function D7r(e,t){if(e.name&&e.version)return`${e.name}-${e.version}`;return e.name??t}function k8s(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 s=2**Math.ceil(Math.log2(t));return t===s||t===s-s/4}async function q7r(e,t,s,n){let i=t.payloadCompressor?.trim().toLowerCase();if(!i||!["gzip","gz","bzip2","bzip","xz","lzma","zstd","zstdio","none"].includes(i))if(WFe(e))i="gzip";else if(HFe(e))i="bzip2";else if(YFe(e))i="xz";else if(JFe(e))i="zstd";else if(k8s(e))i="lzma";else if(Yle(e))i="none";else throw new Q(`RPM package '${s}' uses unsupported payload compressor '${t.payloadCompressor??"unknown"}'`);switch(i){case"gzip":case"gz":return q2(e,n);case"bzip2":case"bzip":return dP(e,n);case"xz":return fP(e,n);case"zstd":case"zstdio":return mP(e,n);case"lzma":if(!k8s(e))throw new Q(`RPM package '${s}' has a malformed LZMA payload`);return v9(e,n);case"none":if(!Yle(e))throw new Q(`RPM package '${s}' has an invalid uncompressed CPIO payload`);return e;default:throw new Q(`RPM package '${s}' uses unsupported payload compressor '${i}'`)}}async function U7r(e,t){let s=await nue(e,0,yLe+z2,"lead and signature header");if(!aCt(s))throw new Q("Invalid RPM package: bad lead magic");let n=s[4],o=s[6]<<8|s[7];if(n<3||o>1)throw new Q("Unsupported RPM package lead version or type");let i=s[78]<<8|s[79];if(i!==O7r)throw new Q(`Unsupported RPM signature type ${i}; only header signatures are supported`);let r=s.subarray(10,76).indexOf(0),a=s.subarray(10,r<0?76:10+r),l="unknown package";try{let I=new TextDecoder("utf-8",{fatal:!0}).decode(a);if(I)l=I}catch{}let u=S8s(s.subarray(yLe),t,"signature"),p=yLe+u.totalSize,c=F7r(p,8),d=await nue(e,yLe+z2,c,"signature header");if(d.byteLength<u.bodySize)throw new Q("Invalid RPM package: truncated signature header");w8s(d.subarray(0,u.bodySize),u,"signature");for(let I=u.bodySize;I<d.byteLength;I++)if(d[I]!==0)throw new Q("Invalid RPM package: non-zero signature alignment padding");let f=await nue(e,c,c+z2,"main header intro"),m=S8s(f,t,"main");Vn(u.totalSize+m.totalSize,t.limits,"RPM headers");let g=c+z2,h=await nue(e,g,g+m.bodySize,"main header"),T=N7r(h,m),R=D7r(T,l);if(T.payloadFormat&&T.payloadFormat.toLowerCase()!=="cpio")throw new Q(`RPM package '${R}' uses unsupported payload format '${T.payloadFormat}'`);let C=c+m.totalSize,w=e.size-C;Di(w,t.limits);let x=await nue(e,C,e.size,"payload"),A=await q7r(x,T,R,t.limits.maxInMemorySize);return Di(A.byteLength,t.limits),NRt(A,t)}function aCt(e){return e.byteLength>=4&&e[0]===237&&e[1]===171&&e[2]===238&&e[3]===219}var yLe=96,z2=16,oue=16,P7r=2393761793,O7r=5,T8s=1000,y8s=1001,R8s=1124,C8s=1125,b8s=1126,RLe=6,_7r,x8s=async(e,t)=>{try{return await U7r(e,t)}catch(s){if(s instanceof Q)throw s;throw new Q(s instanceof Error?s.message:String(s))}};var v8s=E(()=>{yT();zle();jle();U2();Kle();E9();DRt();fi();mc();_7r=new TextDecoder("utf-8",{fatal:!0})});function E8s(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 A8s(e,t){if(t+4>e.byteLength)throw new Q("Invalid 7z BCJ properties");return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function H7r(e,t){let s=new Uint8Array(256),n=0;for(let o=0;o<e.byteLength;o++){let i=e[o]+s[t+n&255]&255;s[n]=i,e[o]=i,n=n-1&255}}function B7r(e,t){let s=[0,1,2,2,3],n=0,o=4294967291;if(e.byteLength<5)return;let i=0,r=e.byteLength-5;while(i<=r){let a=e[i];if(a!==232&&a!==233){i++;continue}let l=t+i>>>0,u=l-o>>>0;if(o=l,u>5)n=0;else for(let p=0;p<u;p++)n=(n&119)<<1>>>0;if(a=e[i+4],(a===0||a===255)&&n>>>1<=4&&n>>>1!==3){let p=A8s(e,i+1),c=0;for(;;){if(c=p-l-5>>>0,n===0)break;let d=s[n>>>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[i+4]=~((c>>>24&1)-1)&255,e[i+3]=c>>>16,e[i+2]=c>>>8,e[i+1]=c,i+=5,n=0}else if(i++,n|=1,a===0||a===255)n|=16}}class CLe{#e;#t;#s;#n;constructor(e,t,s){this.#e=e,this.#t=t,this.#s=s}read(){return this.#n??=this.#o(),this.#n}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 Q("Unsupported 7z coder BCJ2 (multi-input folder)");throw new Q("Unsupported 7z folder graph with multiple packed input streams")}let t=e.packOffsets[0],s=e.packSizes[0];if(!Number.isSafeInteger(t)||!Number.isSafeInteger(s)||t<0||s<0||t+s>this.#e.size)throw new Q("Invalid 7z packed-stream range");let n=await this.#e.read(t,t+s);if(e.packCrcs[0]!==void 0&&Ca(n)!==e.packCrcs[0])throw new Q("Invalid 7z packed-stream CRC32 mismatch");let o=e.packedIndices[0],i=new Set;for(;;){let r=e.coders.findIndex((p)=>o>=p.inputStart&&o<p.inputStart+p.numInputs);if(r<0||i.has(r))throw new Q("Invalid 7z folder binding graph");i.add(r);let a=e.coders[r];if(a.numInputs!==1||a.numOutputs!==1)throw new Q(`Unsupported 7z coder ${E8s(a.id)} stream topology`);let l=e.unpackSizes[a.outputStart];if(l===void 0)throw new Q("Invalid 7z coder unpack size");switch(Di(l,this.#s),a.id){case 0n:if(a.properties.byteLength!==0||n.byteLength!==l)throw new Q("Invalid 7z Copy coder size or properties");break;case 0x30101n:n=await Vle(a.properties,n,l);break;case 0x21n:if(a.properties.byteLength!==1)throw new Q("Invalid 7z LZMA2 coder properties");if(n=await jFe(a.properties[0],n,l),n.byteLength!==l)throw new Q("7z LZMA2 coder output size mismatch");break;case 3n:if(a.properties.byteLength!==1||n.byteLength!==l)throw new Q("Invalid 7z Delta coder properties or size");n=n.slice(),H7r(n,a.properties[0]+1);break;case 0x3030103n:{if(a.properties.byteLength!==0&&a.properties.byteLength!==4)throw new Q("Invalid 7z BCJ x86 coder properties");if(n.byteLength!==l)throw new Q("7z BCJ x86 coder output size mismatch");let p=a.properties.byteLength===4?A8s(a.properties,0):0;n=n.slice(),B7r(n,p);break}case 0x30401n:throw new Q("Unsupported 7z coder PPMd");case 0x6f10701n:throw new Q("Encrypted 7z archives use unsupported coder 7zAES");default:throw new Q(`Unsupported 7z coder ${E8s(a.id)}`)}let u=e.bindPairs.find((p)=>p.output===a.outputStart);if(!u)break;o=u.input}if(i.size!==e.coders.length)throw new Q("Unsupported 7z folder graph with disconnected coders");if(e.crc!==void 0&&Ca(n)!==e.crc)throw new Q("Invalid 7z folder CRC32 mismatch");return n}}var M8s=E(()=>{uP();U2();fi();mc()});class TP{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 Q("Invalid 7z header: truncated data");return this.bytes[this.pos++]}readBytes(e){if(!Number.isSafeInteger(e)||e<0||e>this.remaining)throw new Q("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 s=0;s<8;s++)t|=BigInt(e[s])<<BigInt(s*8);return t}readNumberBigInt(){let e=this.readByte(),t=0n,s=128;for(let n=0;n<8;n++){if((e&s)===0)return t|BigInt(e&s-1)<<BigInt(n*8);t|=BigInt(this.readByte())<<BigInt(n*8),s>>>=1}return t}readNumber(e="number"){let t=this.readNumberBigInt();if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Q(`7z ${e} is too large to read safely`);return Number(t)}skipSizedProperty(){this.readBytes(this.readNumber("property size"))}}function bLe(e,t){let s=Array(t),n=0,o=0;for(let i=0;i<t;i++){if(o===0)n=e.readByte(),o=128;s[i]=(n&o)!==0,o>>>=1}return s}function dCt(e,t){if(e.readByte()!==0)return Array(t).fill(!0);return bLe(e,t)}function fCt(e,t){let s=dCt(e,t),n=Array(t);for(let o=0;o<t;o++)if(s[o])n[o]=e.readUInt32();return{defined:s,values:n}}function uCt(e,t,s){let n=e.readNumber("property ID");if(n!==t)throw new Q(`Invalid 7z header: expected ${s} ID 0x${t.toString(16)}, got 0x${n.toString(16)}`)}function z7r(e,t){let s=e.readNumber("folder coder count");if(s===0||s>t.limits.maxEntries)throw new Q("Invalid 7z folder coder count");let n=[],o=0,i=0;for(let d=0;d<s;d++){let f=e.readByte();if((f&192)!==0)throw new Q("Unsupported 7z coder alternatives or reserved flags");let m=f&15;if(m===0||m>8)throw new Q("Invalid 7z coder method ID size");let g=0n;for(let x of e.readBytes(m))g=g<<8n|BigInt(x);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||i+R>t.limits.maxEntries)throw new Q("Invalid or excessive 7z coder stream count");let C=(f&32)!==0?e.readNumber("coder properties size"):0;Vn(C,t.limits,"coder properties");let w=e.readBytes(C).slice();n.push({id:g,properties:w,inputStart:o,outputStart:i,numInputs:T,numOutputs:R}),o+=T,i+=R}let r=i-1;if(r<0||r>o)throw new Q("Invalid 7z folder bind-pair count");let a=[],l=new Set,u=new Set;for(let d=0;d<r;d++){let f=e.readNumber("bind input index"),m=e.readNumber("bind output index");if(f>=o||m>=i||l.has(f)||u.has(m))throw new Q("Invalid 7z folder bind pair");l.add(f),u.add(m),a.push({input:f,output:m})}let p=o-r,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 Q("Invalid 7z packed stream index");l.add(f),c.push(f)}if(c.length!==p)throw new Q("Invalid 7z folder packed-stream map");return{coders:n,bindPairs:a,packedIndices:c,unpackSizes:[],packOffsets:[],packSizes:[],packCrcs:[]}}function mCt(e){let t=new Set(e.bindPairs.map((o)=>o.output)),n=e.coders.flatMap((o)=>Array.from({length:o.numOutputs},(i,r)=>o.outputStart+r)).filter((o)=>!t.has(o));if(n.length!==1)throw new Q("Unsupported 7z folder with multiple final output streams");return n[0]}function j7r(e,t,s){t.packPosition=e.readNumber("pack position");let n=e.readNumber("pack stream count");if(n>s.limits.maxEntries)throw new Q("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 Q("Invalid duplicate 7z pack sizes");for(let i=0;i<n;i++)t.packSizes.push(e.readNumber("packed stream size"))}else if(o===10){if(t.packCrcs.length!==0)throw new Q("Invalid duplicate 7z pack CRCs");t.packCrcs=fCt(e,n).values}else e.skipSizedProperty()}if(t.packSizes.length!==n)throw new Q("Invalid 7z PackInfo without complete sizes");if(t.packCrcs.length===0)t.packCrcs=Array(n).fill(void 0)}function V7r(e,t,s){uCt(e,11,"Folder");let n=e.readNumber("folder count");if(n>s.limits.maxEntries)throw new Q("7z has too many folders");if(e.readByte()!==0)throw new Q("Unsupported 7z external folder definitions");for(let o=0;o<n;o++)t.folders.push(z7r(e,s));uCt(e,12,"CodersUnpackSize");for(let o of t.folders){let i=o.coders.reduce((r,a)=>r+a.numOutputs,0);for(let r=0;r<i;r++)o.unpackSizes.push(e.readNumber("coder unpack size"))}for(;;){let o=e.readNumber("UnpackInfo property ID");if(o===0)break;if(o===10){let i=fCt(e,n);for(let r=0;r<n;r++)t.folders[r].crc=i.values[r]}else e.skipSizedProperty()}}function K7r(e,t){let s=Array(t.folders.length).fill(1),n,o;for(;;){let a=e.readNumber("SubStreamsInfo property ID");if(a===0)break;if(a===13)for(let l=0;l<s.length;l++)s[l]=e.readNumber("folder substream count");else if(a===9){n=[];for(let l=0;l<t.folders.length;l++)for(let u=1;u<s[l];u++)n.push(e.readNumber("substream size"))}else if(a===10){let l=0;for(let u=0;u<s.length;u++)if(s[u]!==1||t.folders[u].crc===void 0)l+=s[u];o=fCt(e,l)}else e.skipSizedProperty()}let i=0,r=0;for(let a=0;a<t.folders.length;a++){let l=t.folders[a],u=s[a],p=0,c=l.unpackSizes[mCt(l)];for(let d=0;d<u;d++){let f=d+1===u?c-p:n?.[i++]??(()=>{throw new Q("Invalid 7z SubStreamsInfo without sizes")})();if(f<0||p+f>c)throw new Q("Invalid 7z substream size total");let m;if(u===1&&l.crc!==void 0)m=l.crc;else m=o?.values[r++];t.substreams.push({folderIndex:a,offset:p,size:f,crc:m}),p+=f}if(p!==c)throw new Q("Invalid 7z substream sizes")}}function Y7r(e,t){let s=32+e.packPosition,n=[];for(let i of e.packSizes){if(!Number.isSafeInteger(s)||s<0||i<0||s+i>t)throw new Q("Invalid 7z packed-stream range");n.push(s),s+=i}let o=0;for(let i of e.folders)for(let r=0;r<i.packedIndices.length;r++){if(o>=e.packSizes.length)throw new Q("Invalid 7z folder-to-pack-stream mapping");i.packOffsets.push(n[o]),i.packSizes.push(e.packSizes[o]),i.packCrcs.push(e.packCrcs[o]),o++}if(o!==e.packSizes.length)throw new Q("Invalid unused 7z packed streams")}function pCt(e,t,s){let n={packPosition:0,packSizes:[],packCrcs:[],folders:[],substreams:[]};for(;;){let o=e.readNumber("StreamsInfo property ID");if(o===0)break;if(o===6)j7r(e,n,s);else if(o===7)V7r(e,n,s);else if(o===8)K7r(e,n);else throw new Q(`Unsupported 7z StreamsInfo property ID 0x${o.toString(16)}`)}if(n.folders.length>0&&n.substreams.length===0)for(let o=0;o<n.folders.length;o++){let i=n.folders[o];n.substreams.push({folderIndex:o,offset:0,size:i.unpackSizes[mCt(i)],crc:i.crc})}return Y7r(n,t),n}async function I8s(e,t,s){let n=[];for(let o of t.folders){let i=o.unpackSizes[mCt(o)];Vn(i,s.limits,"decoded header"),Di(i,s.limits),n.push(await new CLe(e,o,s.limits).read())}return n}function gCt(e,t){let s=e.readByte();if(s===0)return e;if(s!==1)throw new Q("Invalid 7z external-property flag");let n=e.readNumber("external property stream index"),o=t[n];if(!o)throw new Q("Invalid 7z external property stream index");return new TP(o)}function X7r(e,t,s,n){let o=gCt(e,s),i=[];for(let r=0;r<t;r++){let a=o.pos;while(o.remaining>=2&&(o.bytes[o.pos]!==0||o.bytes[o.pos+1]!==0))o.pos+=2;if(No(o.pos-a,"encoded member path",n*2),o.remaining<2)throw new Q("Invalid 7z UTF-16 file-name table");let l;try{l=W7r.decode(o.bytes.subarray(a,o.pos))}catch{throw new Q("Invalid 7z UTF-16 file name")}o.pos+=2,Ff(l,"member path",n),i.push(l)}return i}function J7r(e,t,s){let n=dCt(e,t),o=gCt(e,s),i=Array(t);for(let r=0;r<t;r++)if(n[r]){let a=o.readUInt64BigInt(),l=Number(a/10000n)-$7r;if(Number.isFinite(l))i[r]=l}return i}function Q7r(e,t,s){let n=dCt(e,t),o=gCt(e,s),i=Array(t);for(let r=0;r<t;r++)if(n[r])i[r]=o.readUInt32();return i}function Z7r(e,t,s){let n=e.readNumber("file count");xr(n,s.limits);let o={names:Array(n).fill(""),emptyStreams:Array(n).fill(!1),emptyFiles:[],antiFiles:[],mtimes:Array(n),attributes:Array(n)};for(;;){let i=e.readNumber("FilesInfo property ID");if(i===0)break;let r=e.readNumber("FilesInfo property size");Vn(r,s.limits,"file property");let a=new TP(e.readBytes(r));if(i===14)o.emptyStreams=bLe(a,n);else if(i===15)o.emptyFiles=bLe(a,o.emptyStreams.filter(Boolean).length);else if(i===16)o.antiFiles=bLe(a,o.emptyStreams.filter(Boolean).length);else if(i===17)o.names=X7r(a,n,t,s.limits.maxPathBytes);else if(i===20)o.mtimes=J7r(a,n,t);else if(i===21)o.attributes=Q7r(a,n,t);else if(i===25)while(a.remaining>0)if(a.readByte()!==0)throw new Q("Invalid non-zero 7z dummy property");else a.pos=a.bytes.byteLength;if(a.remaining!==0)throw new Q(`Invalid 7z file property 0x${i.toString(16)} length`)}return o}async function eXr(e,t,s){let n=new TP(t);uCt(n,1,"Header");let o=[],i,r;for(;;){let a=n.readNumber("Header property ID");if(a===0)break;if(a===2)for(;;){if(n.readNumber("archive property ID")===0)break;n.skipSizedProperty()}else if(a===3)o=await I8s(e,pCt(n,e.size,s),s);else if(a===4)i=pCt(n,e.size,s);else if(a===5)r=Z7r(n,o,s);else throw new Q(`Unsupported 7z header property ID 0x${a.toString(16)}`)}if(n.remaining!==0)throw new Q("Invalid 7z trailing header data");if(!i)i={packPosition:0,packSizes:[],packCrcs:[],folders:[],substreams:[]};if(!r)r={names:[],emptyStreams:[],emptyFiles:[],antiFiles:[],mtimes:[],attributes:[]};return{streams:i,files:r}}class cCt{#e;#t;#s;#n;constructor(e,t){this.#e=e,this.#t=t.offset,this.#s=t.size,this.#n=t.crc}async read(e,t){if(e!==this.#s)throw new Q(`7z member '${t}' declared size changed during extraction`);let s=await this.#e.read();if(this.#t<0||this.#t+e>s.byteLength)throw new Q(`Invalid 7z member '${t}' folder range`);let n=s.subarray(this.#t,this.#t+e);if(this.#n!==void 0&&Ca(n)!==this.#n)throw new Q(`Invalid 7z member '${t}' CRC32 mismatch`);return n.slice()}}class P8s{async read(e,t){if(e!==0)throw new Q(`Invalid empty 7z member '${t}' size`);return new Uint8Array(0)}}function sXr(e,t){let s=t.replace(/\\/g,"/");if(s.startsWith("/"))return{targetPath:s,resolveTarget:!1};let n=e.split("/");n.pop();for(let o of s.split("/")){if(!o||o===".")continue;if(o===".."){if(n.length===0)return{targetPath:s,resolveTarget:!1};n.pop()}else n.push(o)}return{targetPath:n.join("/"),resolveTarget:!0}}async function nXr(e,t,s,n){let o=t.folders.map((l)=>new CLe(e,l,n.limits)),i=[],r=0,a=0;for(let l=0;l<s.names.length;l++){let u=s.names[l],p=Qr(u),c=s.emptyStreams[l]??!1,d=c?s.emptyFiles[r]??!1:!1,f=c?s.antiFiles[r]??!1:!1;if(c)r++;let m=c?void 0:t.substreams[a++];if(!c&&!m)throw new Q("Invalid 7z file-to-substream mapping");if(!p||f)continue;let g=s.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,C=m?.size??0;Oa(C,p,n.limits);let w={path:p,isDirectory:R,size:C,mtimeMs:s.mtimes[l],mode:h};if(T&&m){No(C,"link target",n.limits.maxPathBytes);let x=new cCt(o[m.folderIndex],m),A;try{A=G7r.decode(await x.read(C,p))}catch(M){if(M instanceof Q)throw M;throw new Q(`Invalid UTF-8 symlink target in 7z member '${p}'`)}Ff(A,"link target",n.limits.maxPathBytes);let I=sXr(p,A);w.storage={type:"link",targetPath:I.targetPath,resolveTarget:I.resolveTarget}}else if(!R)w.storage=m?{type:"member",source:new cCt(o[m.folderIndex],m)}:{type:"member",source:tXr};i.push(w),xr(i.length,n.limits)}if(a!==t.substreams.length)throw new Q("Invalid unused 7z substreams");return i}function hCt(e){if(e.byteLength<lCt.byteLength)return!1;for(let t=0;t<lCt.byteLength;t++)if(e[t]!==lCt[t])return!1;return!0}var lCt,W7r,G7r,$7r=11644473600000,tXr,O8s=async(e,t)=>{try{if(e.size<32)throw new Q("Invalid 7z archive: truncated signature header");let s=await e.read(0,32);if(!hCt(s))throw new Q("Invalid 7z archive signature");if(s[6]!==0)throw new Q(`Unsupported 7z major version ${s[6]}`);if(Ca(s.subarray(12,32))!==new TP(s.subarray(8,12)).readUInt32())throw new Q("Invalid 7z start-header CRC32 mismatch");let n=new TP(s.subarray(12)),o=n.readUInt64BigInt(),i=n.readUInt64BigInt(),r=n.readUInt32();if(o>BigInt(Number.MAX_SAFE_INTEGER)||i>BigInt(Number.MAX_SAFE_INTEGER))throw new Q("7z header offsets or sizes are too large to read safely");let a=32+Number(o),l=Number(i);if(Vn(l,t.limits,"next header"),!Number.isSafeInteger(a)||a<32||a+l>e.size)throw new Q("Invalid 7z next-header range");let u=await e.read(a,a+l);if(Ca(u)!==r)throw new Q("Invalid 7z next-header CRC32 mismatch");let p=new TP(u).readNumber("next-header ID");if(p===23){let d=new TP(u);d.readNumber();let f=pCt(d,e.size,t);if(d.remaining!==0)throw new Q("Invalid 7z encoded-header trailing data");let m=await I8s(e,f,t);if(m.length!==1)throw new Q("Invalid 7z encoded header folder count");if(u=m[0],new TP(u).readNumber("decoded-header ID")!==1)throw new Q("Invalid decoded 7z header marker")}else if(p!==1)throw new Q(`Unsupported 7z next-header ID 0x${p.toString(16)}`);let c=await eXr(e,u,t);return await nXr(e,c.streams,c.files,t)}catch(s){if(s instanceof Q)throw s;throw new Q(`Invalid 7z archive: ${s instanceof Error?s.message:String(s)}`)}};var _8s=E(()=>{uP();fi();mc();Lf();M8s();lCt=Uint8Array.of(55,122,188,175,39,28),W7r=new TextDecoder("utf-16",{fatal:!0}),G7r=new TextDecoder("utf-8",{fatal:!0});tXr=new P8s});import*as j2 from"path";import*as kLe from"zlib";function wLe(e,t){if(e instanceof Q)return e;return new Q(`${t}: ${e instanceof Error?e.message:String(e)}`)}function SLe(e,t,s,n){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<0)throw new Q(`Invalid ZIP archive: ${n} has an invalid range`);let o=e+t;if(!Number.isSafeInteger(o)||o>s)throw new Q(`Invalid ZIP archive: ${n} exceeds archive size`);return o}function gXr(e){for(let t=e.byteLength-iue;t>=0;t--){if(Ps(e,t)!==SCt)continue;if(t+iue+Pn(e,t+20)===e.byteLength)return t}throw new Q("Invalid ZIP archive: missing end of central directory")}async function hXr(e,t,s,n){let o=n-rue;if(o<0)return;let i=o>=s?t.subarray(o-s,o-s+rue):await e.read(o,n);if(i.byteLength!==rue||Ps(i,0)!==L8s)return;if(Ps(i,4)!==0||Ps(i,16)!==1)throw new Q("Multi-volume ZIP archives are not supported");let r=VE(i,8),a=[r],l=o-O9;if(l>=0&&l!==r)a.push(l);for(let u of a){if(u<0||u+O9>e.size)continue;let p=await e.read(u,u+O9);if(p.byteLength!==O9||Ps(p,0)!==F8s)continue;let c=VE(p,4);if(c<44||u+12+c!==o)continue;if(Ps(p,16)!==0||Ps(p,20)!==0)throw new Q("Multi-volume ZIP archives are not supported");let d=VE(p,24),f=VE(p,32);if(d!==f)throw new Q("Multi-volume ZIP archives are not supported");return{entries:f,size:VE(p,40),offset:VE(p,48),physicalEnd:u,archiveOffset:0}}throw new Q("Invalid ZIP archive: missing ZIP64 end of central directory")}async function TXr(e,t){if(t.entries===0)return t.offset;let s=[t.offset],n=t.physicalEnd-t.size;if(n!==t.offset)s.push(n);for(let o of s){if(o<0||o+4>e.size||o+t.size>e.size)continue;let i=await e.read(o,o+4);if(i.byteLength===4&&Ps(i,0)===bCt)return o}throw new Q("Invalid ZIP archive: central directory is out of bounds or malformed")}async function yXr(e,t){if(e.size<iue)throw new Q("Invalid ZIP archive: missing end of central directory");let s=Math.min(e.size,iue+rXr),n=e.size-s,o=await e.read(n,e.size);if(o.byteLength!==s)throw new Q("Invalid ZIP archive: truncated end of central directory");let i=gXr(o),r=n+i,a=Pn(o,i+4),l=Pn(o,i+6),u=Pn(o,i+8),p=Pn(o,i+10),c=Ps(o,i+12),d=Ps(o,i+16);if(a!==0||l!==0||u!==yP&&p!==yP&&u!==p)throw new Q("Multi-volume ZIP archives are not supported");let f=u===yP||p===yP||c===aw||d===aw,m=await hXr(e,o,n,r),g=r;if(m)({entries:p,size:c,offset:d,physicalEnd:g}=m);else if(f)throw new Q("Invalid ZIP archive: missing ZIP64 central-directory metadata");if(xr(p,t),Vn(c,t,"ZIP central directory"),p>Math.floor(c/46))throw new Q("Invalid ZIP archive: truncated central directory");let h=d,T={entries:p,size:c,offset:d,physicalEnd:g,archiveOffset:0};return T.offset=await TXr(e,T),T.archiveOffset=T.offset-h,SLe(T.offset,T.size,e.size,"central directory"),T}function RXr(e,t){let s=0n;for(let i=7;i>=0;i--)s=s<<8n|BigInt(e[t+i]);let n=s/10000n-pXr,o=Number(n);return Number.isSafeInteger(o)?o:void 0}function CXr(e){if(e.byteLength<4)return;let t=4;while(t+4<=e.byteLength){let s=Pn(e,t),n=Pn(e,t+2),o=t+4+n;if(o>e.byteLength)throw new Q("Invalid ZIP archive: malformed NTFS extra field");if(s===1&&n>=8)return RXr(e,t+4);t=o}return}function bXr(e,t){if(t===0)return;let s=1980+(t>>>9&127),n=(t>>>5&15)-1,o=t&31,i=e>>>11&31,r=e>>>5&63,a=(e&31)*2;if(n<0||n>11||o<1||o>31||i>23||r>59||a>59)return;let l=new Date(s,n,o,i,r,a).getTime();return Number.isFinite(l)?l:void 0}function SXr(e,t){let s={},n=0;while(n<e.byteLength){if(n+4>e.byteLength)throw new Q("Invalid ZIP archive: truncated extra-field header");let o=Pn(e,n),i=Pn(e,n+2),r=n+4,a=r+i;if(a>e.byteLength)throw new Q("Invalid ZIP archive: malformed extra field");let l=e.subarray(r,a);if(o===1)s.zip64=l;else if(o===28789){if(l.byteLength<5)throw new Q("Invalid ZIP archive: Unicode path extra field is too small");if(l[0]===1&&Ps(l,1)===Ca(t))try{s.unicodePath=dXr.decode(l.subarray(5))}catch{}}else if(o===21589){if(l.byteLength<1)throw new Q("Invalid ZIP archive: extended timestamp extra field is too small");if((l[0]&1)!==0){if(l.byteLength<5)throw new Q("Invalid ZIP archive: extended timestamp extra field is too small");s.mtimeMs=(Ps(l,1)|0)*1000}}else if(o===10&&s.mtimeMs===void 0)s.mtimeMs=CXr(l);n=a}return s}function kXr(e,t,s){if(!(s.uncompressedSize||s.compressedSize||s.localHeaderOffset||s.diskStart))return t;if(!e)throw new Q("Invalid ZIP archive: missing ZIP64 extra field");let o=0,i={...t};if(s.uncompressedSize){if(o+8>e.byteLength)throw new Q("Invalid ZIP archive: malformed ZIP64 extra field");i.uncompressedSize=VE(e,o),o+=8}if(s.compressedSize){if(o+8>e.byteLength)throw new Q("Invalid ZIP archive: malformed ZIP64 extra field");i.compressedSize=VE(e,o),o+=8}if(s.localHeaderOffset){if(o+8>e.byteLength)throw new Q("Invalid ZIP archive: malformed ZIP64 extra field");i.localHeaderOffset=VE(e,o),o+=8}if(s.diskStart){if(o+4>e.byteLength)throw new Q("Invalid ZIP archive: malformed ZIP64 extra field");i.diskStart=Ps(e,o)}return i}async function wXr(e,t,s,n){try{switch(t){case 0:return e;case 8:return kLe.inflateRawSync(e,{maxOutputLength:Math.max(s,1)});case 12:return await dP(e,s);case 14:{if(e.byteLength<9||e[2]!==5||e[3]!==0)throw new Q(`Invalid ZIP archive: malformed LZMA properties for '${n}'`);return await Vle(e.subarray(4,9),e.subarray(9),s)}case 20:case 93:return await mP(e,s);case 95:return await fP(e,s);default:throw new Q(`Unsupported ZIP compression method ${t} for '${n}'`)}}catch(o){throw wLe(o,`Failed to decompress ZIP member '${n}'`)}}class q8s{#e;#t;#s;#n;#o;#r;#a;constructor(e,t,s,n,o,i,r){this.#e=e,this.#t=t,this.#s=s,this.#n=n,this.#o=o,this.#r=i,this.#a=r}async read(e,t){try{if(Oa(Math.max(e,this.#t),t,this.#a),(this.#n&(yCt|RCt))!==0||this.#s===99)throw new Q(`Encrypted ZIP member '${t}' is not supported`);if(cXr[this.#s]!==!0)throw new Q(`Unsupported ZIP compression method ${this.#s} for '${t}'`);let s=SLe(this.#r,30,this.#e.size,`local header for '${t}'`),n=await this.#e.read(this.#r,s);if(n.byteLength!==30||Ps(n,0)!==CCt)throw new Q(`Invalid ZIP archive: malformed local header for '${t}'`);if((Pn(n,6)&(yCt|RCt))!==0)throw new Q(`Encrypted ZIP member '${t}' is not supported`);if(Pn(n,8)!==this.#s)throw new Q(`Invalid ZIP archive: local and central compression methods disagree for '${t}'`);let i=this.#r+30+Pn(n,26)+Pn(n,28),r=SLe(i,this.#t,this.#e.size,`data for '${t}'`);if(this.#s===0&&this.#t!==e)throw new Q(`Invalid ZIP archive: size mismatch for '${t}' (expected ${e}, got ${this.#t})`);let a=await this.#e.read(i,r);if(a.byteLength!==this.#t)throw new Q(`Invalid ZIP archive: truncated data for '${t}'`);let l=await wXr(a,this.#s,e,t);if(l.byteLength!==e)throw new Q(`Invalid ZIP archive: size mismatch for '${t}' (expected ${e}, got ${l.byteLength})`);if(Ca(l)!==this.#o)throw new Q(`Invalid ZIP archive: CRC mismatch for '${t}'`);return l}catch(s){throw wLe(s,`Failed to read ZIP member '${t}'`)}}}function xXr(e,t,s,n){let o=[],i=0;for(let r=0;r<s.entries;r++){if(i+46>t.byteLength)throw new Q("Invalid ZIP archive: truncated central directory");if(Ps(t,i)!==bCt)throw new Q("Invalid ZIP archive: malformed central directory");let a=Pn(t,i+4),l=Pn(t,i+8),u=Pn(t,i+10),p=Pn(t,i+12),c=Pn(t,i+14),d=Ps(t,i+16),f=Ps(t,i+20),m=Ps(t,i+24),g=Pn(t,i+28),h=Pn(t,i+30),T=Pn(t,i+32),R=Pn(t,i+34),C=Ps(t,i+38),w=Ps(t,i+42),x=i+46,A=x+g,I=A+h,M=I+T;if(!Number.isSafeInteger(M)||M>t.byteLength)throw new Q("Invalid ZIP archive: truncated central-directory entry");No(g,"member path",n.limits.maxPathBytes);let O=t.subarray(x,A),_=SXr(t.subarray(A,I),O),F=kXr(_.zip64,{compressedSize:f,uncompressedSize:m,localHeaderOffset:w,diskStart:R},{compressedSize:f===aw,uncompressedSize:m===aw,localHeaderOffset:w===aw,diskStart:R===yP});if(F.diskStart!==0)throw new Q("Multi-volume ZIP archives are not supported");let L=_.unicodePath??((l&TCt)!==0?D8s:fXr).decode(O);if(Ff(L,"member path",n.limits.maxPathBytes),(l&(yCt|RCt))!==0||u===99)throw new Q(`Encrypted ZIP member '${L}' is not supported`);let D=Qr(L);if(D){Oa(Math.max(F.uncompressedSize,F.compressedSize),D,n.limits);let N=a>>>8,U=N===N8s||N===iXr?C>>>16:void 0,B=U===void 0?0:U&aXr,H=U4s(L)||B===lXr||(C&16)!==0,W=B===uXr&&!H,z=F.localHeaderOffset+s.archiveOffset;SLe(z,30,e.size,`local header for '${D}'`);let K=new q8s(e,F.compressedSize,u,l,d,z,n.limits),J={path:D,isDirectory:H,size:H?0:F.uncompressedSize,mtimeMs:_.mtimeMs??bXr(p,c),mode:U||void 0,storage:H?void 0:{type:"member",source:K}};o.push({entry:J,isSymlink:W}),xr(o.length,n.limits)}i=M}return o}async function vXr(e,t){let s=await yXr(e,t.limits);if(s.size===0)return[];let n=await e.read(s.offset,s.offset+s.size);if(n.byteLength!==s.size)throw new Q("Invalid ZIP archive: truncated central directory");let o=xXr(e,n,s,t);for(let i of o){if(!i.isSymlink)continue;if(No(i.entry.size,"symlink target",t.limits.maxPathBytes),i.entry.storage?.type!=="member")throw new Q("Invalid ZIP archive: symlink has no payload");let r=await i.entry.storage.source.read(i.entry.size,i.entry.path),a=D8s.decode(r);Ff(a,"symlink target",t.limits.maxPathBytes);let l=a.replace(/\\/g,"/"),p=j2.posix.isAbsolute(l)||/^[A-Za-z]:/.test(l)||l.includes("\x00")?void 0:_f(j2.posix.join(j2.posix.dirname(i.entry.path),l));i.entry.size=0,i.entry.storage={type:"link",targetPath:p===void 0?l:p,resolveTarget:p!==void 0}}return o.map((i)=>i.entry)}function H8s(e){if(e.byteLength<4)return!1;let t=Ps(e,0);return t===CCt||t===SCt||t===oXr}async function B8s(e){try{let t=[],s=[],n=0,o=0,i=0;for(let[c,d]of e){let f=c.replace(/\\/g,"/"),m=Qr(f);if(!m||m!==f.replace(/^\.\//,"")||f.startsWith("/")||/^[A-Za-z]:/.test(f)||f.includes("\x00"))throw new Q(`Cannot write unsafe ZIP member path '${c}'`);let g=m,h=mXr.encode(g);if(h.byteLength>yP)throw new Q(`ZIP member path '${g}' is too long to write`);if(d.byteLength>=aw)throw new Q(`ZIP member '${g}' is too large to write`);let T=d.byteLength===0?void 0:kLe.deflateRawSync(d),R=T&&T.byteLength<d.byteLength?T:d,C=R===d?0:8;if(R.byteLength>=aw||n>=aw)throw new Q("ZIP archive is too large to write member offsets safely");let w=Ca(d),x=new Uint8Array(30+h.byteLength);zl(x,0,CCt),Ud(x,4,20),Ud(x,6,TCt),Ud(x,8,C),Ud(x,10,0),Ud(x,12,33),zl(x,14,w),zl(x,18,R.byteLength),zl(x,22,d.byteLength),Ud(x,26,h.byteLength),x.set(h,30),t.push(x,R);let A=new Uint8Array(46+h.byteLength);if(zl(A,0,bCt),Ud(A,4,N8s<<8|20),Ud(A,6,20),Ud(A,8,TCt),Ud(A,10,C),Ud(A,12,0),Ud(A,14,33),zl(A,16,w),zl(A,20,R.byteLength),zl(A,24,d.byteLength),Ud(A,28,h.byteLength),zl(A,38,2175008768),zl(A,42,n),A.set(h,46),s.push(A),n+=x.byteLength+R.byteLength,o+=A.byteLength,i++,!Number.isSafeInteger(n+o)||i>aw)throw new Q("ZIP archive is too large to write")}if(n>=aw||o>=aw)throw new Q("ZIP archive is too large to write member offsets safely");let r=i>=yP,a=iue+(r?O9+rue:0),l=n+o+a;if(!Number.isSafeInteger(l))throw new Q("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 s)u.set(c,p),p+=c.byteLength;if(r){let c=p;zl(u,p,F8s),_2(u,p+4,44),Ud(u,p+12,45),Ud(u,p+14,45),_2(u,p+24,i),_2(u,p+32,i),_2(u,p+40,o),_2(u,p+48,n),p+=O9,zl(u,p,L8s),_2(u,p+8,c),zl(u,p+16,1),p+=rue}return zl(u,p,SCt),Ud(u,p+8,r?yP:i),Ud(u,p+10,r?yP:i),zl(u,p+12,o),zl(u,p+16,n),u}catch(t){throw wLe(t,"Failed to encode ZIP archive")}}var CCt=67324752,bCt=33639248,F8s=101075792,L8s=117853008,SCt=101010256,oXr=134695760,iue=22,O9=56,rue=20,rXr=65535,yP=65535,aw=4294967295,TCt=2048,yCt=1,RCt=64,N8s=3,iXr=19,aXr=61440,lXr=16384,uXr=40960,pXr=11644473600000n,cXr,D8s,dXr,fXr,mXr,U8s=async(e,t)=>{try{return await vXr(e,t)}catch(s){throw wLe(s,"Failed to read ZIP archive")}};var kCt=E(()=>{yT();uP();zle();U2();Kle();E9();fi();mc();Lf();YE();cXr={0:!0,8:!0,12:!0,14:!0,20:!0,93:!0,95:!0},D8s=new TextDecoder("utf-8"),dXr=new TextDecoder("utf-8",{fatal:!0}),fXr=new TextDecoder("windows-1252"),mXr=new TextEncoder});import*as G8s from"path";function xLe(e){let t=e.toLowerCase();for(let[s,n]of wCt)if(t.endsWith(`.${s}`))return n;return}function AXr(e){if(!e)return"data";let t=G8s.basename(e.replace(/\\/g,"/")),s=t.toLowerCase();for(let[n]of wCt)if(s.length>n.length+1&&s.endsWith(`.${n}`))return t.slice(0,t.length-n.length-1);return t||"data"}class z8s{#e;constructor(e){this.#e=e}async read(){return this.#e}}function lw(e){return async(t,s)=>{Di(t.size,s.limits);let n=await e(await KE(t),s.limits.maxInMemorySize);if(Di(n.byteLength,s.limits),jRt(n))return eue(n,s);return[{path:AXr(s.archivePath),isDirectory:!1,size:n.byteLength,storage:{type:"member",source:new z8s(n)}}]}}function j8s(e){return MXr[e]}function V8s(e){for(let[n,o]of IXr)if(o(e))return n;let t=e.byteLength-W8s,s=Math.max(0,e.byteLength-W8s-OXr);for(let n=t;n>=s;n--)if(Ps(e,n)===PXr)return"zip";return}var EXr,wCt,$8s,MXr,IXr,PXr=101010256,W8s=22,OXr=65535;var xCt=E(()=>{aVs();kRt();yT();AVs();zle();jle();U2();$Vs();Kle();E9();DRt();F6s();V6s();mc();CRt();h8s();v8s();_8s();YE();iLe();KRt();kCt();EXr={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"]},wCt=Object.entries(EXr).flatMap(([e,t])=>t.map((s)=>[s,e])).sort((e,t)=>t[0].length-e[0].length),$8s=wCt.map(([e])=>e.replace(/\./g,"\\.")).join("|");MXr={zip:U8s,tar:E6s,"tar.gz":lw(q2),"tar.bz2":lw(dP),"tar.xz":lw(fP),"tar.zst":lw(mP),"tar.Z":lw(PRt),asar:fVs,rar:m8s,"7z":O8s,iso:j6s,cab:EVs,cpio:o6s,rpm:x8s,ar:pLe,deb:_6s,lzh:Q4s,arj:iVs,gz:lw(q2),bz2:lw(dP),xz:lw(fP),zst:lw(mP),Z:lw(PRt),lzma:lw(v9)};IXr=[["zip",H8s],["rar",f8s],["7z",hCt],["cab",vVs],["rpm",aCt],["arj",bRt],["lzh",RRt],["cpio",Yle],["deb",XRt],["ar",VRt],["asar",mVs],["tar.gz",WFe],["tar.bz2",HFe],["tar.xz",YFe],["tar.zst",JFe],["tar.Z",GVs],["iso",z6s],["tar",jRt]]});import*as dD from"fs/promises";import*as RT from"path";function FXr(e){if(typeof e!=="string"){if("bytes"in e)return{source:NFe(e.bytes),format:e.format};if("source"in e)return{source:e.source,format:e.format,archivePath:e.path};let s=e.format;return{source:hRt(e.path),format:s,archivePath:e.path}}let t=xLe(e);if(!t)throw new Q(`Unsupported archive format: ${e}`);return{source:hRt(e),format:t,archivePath:e}}async function V2(e,t={}){let{source:s,format:n,archivePath:o}=FXr(e),i={...qle,...t.limits},r={limits:i,archivePath:o},a=await j8s(n)(s,r);return new mRt(n,a,i)}function _9(e){let t=e.replace(/\\/g,"/"),s=new RegExp(`\\.(?:${$8s})(?=(?::|$))`,"gi"),n=new Set,o=[],i;while(!0){if(i=s.exec(t),i===null)break;let r=i.index+i[0].length,a=e.slice(0,r),l=t.slice(r).replace(/^:+/,""),u=`${a}\x00${l}`;if(n.has(u))continue;n.add(u),o.push({archivePath:a,subPath:l})}return o.sort((r,a)=>a.archivePath.length-r.archivePath.length)}function vCt(e){return e.map((t)=>{if(t.isDirectory)return`${t.name}/`;let s=t.size>0?` (${kt(t.size)})`:"";return`${t.name}${s}`})}async function K8s(e,t,s={}){let o=(await V2({bytes:e,format:t})).listDirectory(""),i=s.limit!==void 0&&s.limit>0?o.slice(0,s.limit):o,r=vCt(i);return r.length>0?r.join(`
|
|
@@ -4455,7 +4455,7 @@ ${o}`,bJs))}if(this.#t==="running")this.#i.addChild(this.#n);else{let o=XNe({sta
|
|
|
4455
4455
|
`),w=C.length>0?n.countTokens(C):0;r.push({id:T.toolCallId,textTokens:w,frames:w>=jSt?kB(C,{shape:s}):0,hasImage:R}),a.set(T.toolCallId,{index:h,message:T,text:C})}let u,p;if(this.options.renderSystemPrompt!=="none"){if(u=WJs(e.systemPrompt,this.options.renderSystemPrompt),u)p={textTokens:n.countTokens(u.text),frames:kB(u.text,{shape:s})}}let c=i.findIndex((h)=>h.role==="user"),d=GJs({options:this.options,shape:s,budget:o,toolResults:r,systemPrompt:p,hasUserMessage:c>=0}),f=!1,m=[];for(let h of d.toolResults){let T=a.get(h.id);if(!T)continue;let R=await this.#s(this.#e,h.id,T.text,s);i[T.index]={...T.message,content:[{type:"text",text:HJs},...R]},f=!0,m.push({toolCallId:h.id,savedTokens:Math.max(0,h.textTokens-h.frames*s.frameTokenEstimate)})}if(m.length>0)this.onToolResultSavings?.(m,t);if(this.options.renderToolResults){for(let h of this.#e.keys())if(!l.has(h))this.#e.delete(h)}let g=e.systemPrompt;if(d.systemPrompt&&c>=0&&u){let h=Bun.hash(u.text),T=this.#t;if(!T||T.hash!==h)T={hash:h,frames:await this.frameSink?.framesFor(u.text,s,sDe)??await SB(u.text,{shape:s,maxFrames:sDe})},this.#t=T;let R=T.frames,C=i[c],w=typeof C.content==="string"?[{type:"text",text:C.content}]:C.content;i[c]={...C,content:[{type:"text",text:u.userNote},...R,...w]},g=u.replacement,f=!0}if(!f)return e;return{...e,systemPrompt:g,messages:i}}async#s(e,t,s,n){let o=Bun.hash(s),i=e.get(t);if(i&&i.hash===o)return i.frames;let r=await this.frameSink?.framesFor(s,n)??await SB(s,{shape:n});return e.set(t,{hash:o,frames:r}),r}}var sDe=6,jSt=3000,bni=0.9,wni;var KSt=E(()=>{ki();fk();PJs();_Js();LJs();DJs();UJs();wni=[/<repo-rules>\n[\s\S]*?\n<\/repo-rules>/g,/## Context\n<instructions>\n[\s\S]*?\n<\/instructions>/g]});function $ue(e){return Math.min(32000,Math.max(8192,Math.floor(e*0.125)))}var YSt=8192;function VJs(e,t,s){if(!(t>0))return null;let n=e.getGroup("compaction"),o=n;if(!n.enabled||o.strategy==="off")return null;let i=mk(t,o);if(!(i>0)||i>t)return null;let r=n.asyncEnabled!==!1&&aie(s,n)!==void 0,a=$ue(i);return{thresholdPercent:i/t*100,speculationPercent:r?Math.max(0,i-a)/t*100:null}}function Ani(e,t){if(!t.some((s)=>s.name==="read"))return ZSt;return e.filter((s)=>s.hide!==!0)}function Mni(e,t){let s=[];for(let n of e)s.push(n.name,n.description??"");return t.countTokens(s)}function aDe(e,t){let s=[];for(let n of e){if(typeof n.name==="string")s.push(n.name);if(typeof n.description==="string")s.push(n.description);try{let o={name:n.name,description:n.description,parameters:n.parameters},i=JSON.stringify(ao(o)??{});if(typeof i==="string")s.push(i)}catch{}}return t.countTokens(s)}function KJs(e,t){let s=e,n=e.systemPrompt??JSt,o=e.agent?.state?.tools??QSt,i=e.skills??ZSt,r=s[zJs];if(r&&r.systemPromptRef===n&&r.toolsRef===o&&r.skillsRef===i&&r.tokenizerRef===t)return r;return r={systemPromptRef:n,toolsRef:o,skillsRef:i,tokenizerRef:t,tokens:void 0,breakdown:void 0},s[zJs]=r,r}function Zg(e,t){let s=KJs(e,t);if(s.tokens!==void 0)return s.tokens;let n=e.systemPrompt??JSt,o=e.agent?.state?.tools??QSt,i=t.countTokens(Array.from(n,(r)=>r??""))+aDe(o,t);return s.tokens=i,i}function ekt(e,t){let s=KJs(e,t);if(s.breakdown)return s.breakdown;let n=e.agent?.state?.tools??QSt,o=Mni(Ani(e.skills??ZSt,n),t),i=aDe(n,t),r=e.systemPrompt??JSt,a=t.countTokens(Array.from(r.slice(1),(p)=>p??"")),l=Math.max(0,t.countTokens(r[0]??"")-o),u={skillsTokens:o,toolsTokens:i,systemContextTokens:a,systemPromptTokens:l};return s.breakdown=u,u}function lDe(e,t){let s=e.model,n=e.agent.tokenizer,o=s?.contextWindow??0,i=typeof e.getContextBreakdown==="function"?e.getContextBreakdown():void 0,r=0,a=0,l=0,u=0,p=0,c=0;if(i)r=i.messagesTokens,a=i.skillsTokens,l=i.systemToolsTokens,u=i.systemContextTokens,p=i.systemPromptTokens,c=i.usedTokens;else{r=n.countMessages(e.messages??[]);let h=ekt(e,n);a=h.skillsTokens,l=h.toolsTokens,u=h.systemContextTokens,p=h.systemPromptTokens,c=a+l+u+p+r}let d=[{id:"systemPrompt",label:"System prompt",tokens:p,color:"accent",glyph:nDe},{id:"systemTools",label:"System tools",tokens:l,color:"warning",glyph:nDe},{id:"systemContext",label:"System context",tokens:u,color:"customMessageLabel",glyph:nDe},{id:"skills",label:"Skills",tokens:a,color:"success",glyph:nDe},{id:"messages",label:"Messages",tokens:r,color:"userMessageText",glyph:Eni}],f=0;if(o>0){let h=e.settings.getGroup("compaction");if(h.enabled&&h.strategy!=="off"){let T=mk(o,h);f=Math.max(0,o-T)}else f=0;if(f===0&&h.enabled)f=MB(o,h)}f=Math.min(f,Math.max(0,o-c));let m=Math.max(0,o-c-f),g;if(t?.snapcompactSavings){let h=e.settings.get("snapcompact.systemPrompt"),T=e.settings.get("snapcompact.toolResults");if(h!=="none"||T)g=$Js({options:{renderSystemPrompt:h,renderToolResults:T,shape:e.settings.get("snapcompact.shape")},model:s,systemPrompt:e.systemPrompt??[],messages:e.messages??[]})}return{model:s,contextWindow:o,categories:d,usedTokens:c,autoCompactBufferTokens:f,freeTokens:m,snapcompact:g}}function Ini(e){let t=[],s=e.contextWindow;if(s<=0){for(let p=0;p<AD;p++)t.push({glyph:iDe,color:"dim"});return t}let n=s/AD,o=(p)=>{if(p<=0)return 0;return Math.max(1,Math.round(p/n))},i=e.categories.map((p)=>({category:p,count:o(p.tokens)})),r=o(e.autoCompactBufferTokens),a=i.reduce((p,c)=>p+c.count,0),l=AD-r;if(a>l){let p=a-l,c=[...i].sort((d,f)=>f.count-d.count);for(let d of c)while(p>0&&d.count>1)d.count-=1,p-=1;if(a=i.reduce((d,f)=>d+f.count,0),a+r>AD)r=Math.max(0,AD-a)}for(let{category:p,count:c}of i)for(let d=0;d<c;d++)t.push({glyph:p.glyph,color:p.color});let u=Math.max(0,AD-t.length-r);for(let p=0;p<u;p++)t.push({glyph:iDe,color:"dim"});for(let p=0;p<r;p++)t.push({glyph:jJs,color:"warning"});while(t.length<AD)t.push({glyph:iDe,color:"dim"});return t.slice(0,AD)}function oDe(e,t,s=1){if(t<=0)return"0%";let n=e/t*100;if(n>0&&n<0.05)return"<0.1%";return`${n.toFixed(s)}%`}function Pni(e,t){let s=[],{model:n,contextWindow:o,categories:i,usedTokens:r,autoCompactBufferTokens:a,freeTokens:l}=e,u=n?.name??n?.id??"no model",p=n?.id??"unknown",c=He(o).toLowerCase();s.push(t.bold(`${u}`)+t.fg("dim",` (${c} context)`)),s.push(t.fg("muted",`${p}[${c}]`)),s.push(`${t.bold(He(r))}${t.fg("dim",`/${c} tokens`)}`+t.fg("muted",` (${oDe(r,o)})`)),s.push(""),s.push(t.fg("muted","Estimated usage by category"));for(let m of i){let g=t.fg(m.color,m.glyph),h=m.label,T=He(m.tokens),R=oDe(m.tokens,o);s.push(`${g} ${h}: ${t.bold(T)} ${t.fg("dim",`tokens (${R})`)}`)}let d=t.fg("dim",iDe);if(s.push(`${d} Free space: ${t.bold(He(l))} ${t.fg("dim",`(${oDe(l,o)})`)}`),a>0){let m=t.fg("warning",jJs);s.push(`${m} Autocompact buffer: ${t.bold(He(a))} ${t.fg("dim",`tokens (${oDe(a,o)})`)}`)}let f=e.snapcompact;if(f)if(s.push(""),!f.visionCapable)s.push(t.fg("muted","Snapcompact: inactive (model has no image input)"));else{if(s.push(t.fg("muted","Snapcompact (estimated wire savings)")),f.systemPrompt){let m=f.systemPrompt;if(m.applied)s.push(` System prompt (${m.scope==="agents-md"?"AGENTS.md":"all"}): saves ${t.bold(`~${He(m.savedTokens)}`)} `+t.fg("dim",`(${He(m.textTokens)} text \u2192 ${m.frames} frame${m.frames===1?"":"s"} \u2248 ${He(m.imageTokens)})`));else{let g=m.reason==="budget"?"image budget exhausted":m.reason==="empty"?"nothing to image":"frames would not save tokens";s.push(` System prompt (${m.scope==="agents-md"?"AGENTS.md":"all"}): ${t.fg("dim",`stays text (${g})`)}`)}}if(f.toolResults){let m=f.toolResults;if(m.swapped>0)s.push(` Tool results: saves ${t.bold(`~${He(m.savedTokens)}`)} `+t.fg("dim",`(${m.swapped}/${m.total} imaged, ${He(m.textTokens)} text \u2192 ${m.frames} frames \u2248 ${He(m.imageTokens)})`));else s.push(` Tool results: ${t.fg("dim",`none imaged (${m.total} in history)`)}`)}if(f.savedTokens>0)s.push(` Next request: ${t.bold(`~${He(Math.max(0,r-f.savedTokens))}`)} ${t.fg("dim","tokens on the wire")}`)}return s}function YJs(e,t){if(e.contextWindow<=0)return t.fg("muted","Context usage is unavailable: no model is selected for this session.");let s=Ini(e),n=Pni(e,t),o=Math.max(XSt,n.length),i=[];for(let r=0;r<o;r++){let a="";if(r<XSt){let p=[];for(let c=0;c<rDe;c++){let d=s[r*rDe+c];p.push(t.fg(d.color,d.glyph))}a=p.join(" ")}else a=" ".repeat(rDe*2-1);let l=n[r]??"",u=l.length>0?`${a}${vni}${l}`:a;i.push(u)}return i.join(`
|
|
4456
4456
|
`)}var rDe=20,XSt=10,AD,vni=" ",nDe="\u26C1",Eni="\u26C3",iDe="\u26F6",jJs="\u26DD",JSt,QSt,ZSt,zJs;var MD=E(()=>{yy();du();X();P6();KSt();AD=rDe*XSt;JSt=[],QSt=[],ZSt=[];zJs=Symbol("non-message-token-cache")});function Au(e,t){return e.keybindings.getDisplayString(t)||"Disabled"}function XJs(e){let t=Eie(),s=t==="darwin",n=Aie("alt",t),o=Aie("super",t);return["**Navigation**","| Key | Action |","|-----|--------|","| `Arrow keys` | Move cursor / browse history (Up when empty) |",`| \`${n}+Left/Right\` | Move by word |`,s?`| \`Ctrl+A\` / \`Home\` / \`${o}+Left\` | Start of line |`:"| `Ctrl+A` / `Home` | Start of line |",s?`| \`Ctrl+E\` / \`End\` / \`${o}+Right\` | End of line |`:"| `Ctrl+E` / `End` | End of line |","","**Editing**","| Key | Action |","|-----|--------|","| `Enter` | Send message |",`| \`Shift+Enter\` / \`${n}+Enter\` | New line |`,`| \`Ctrl+W\` / \`${n}+Backspace\` | Delete word backwards |`,"| `Ctrl+U` | Delete to start of line |","| `Ctrl+K` | Delete to end of line |",`| \`${Au(e,"app.clipboard.copyLine")}\` | Copy current line |`,`| \`${Au(e,"app.clipboard.copyPrompt")}\` | Copy whole prompt |`,"","**Other**","| Key | Action |","|-----|--------|","| `Tab` | Path completion / accept autocomplete |",`| \`${Au(e,"app.interrupt")}\` | Cancel autocomplete / interrupt active work |`,`| \`${Au(e,"app.clear")}\` | Clear editor (first) / exit (second) |`,`| \`${Au(e,"app.exit")}\` | Exit (saves current prompt as draft) |`,`| \`${Au(e,"app.suspend")}\` | Suspend to background |`,`| \`${Au(e,"app.display.reset")}\` | Reset terminal display |`,`| \`${Au(e,"app.thinking.cycle")}\` | Cycle thinking level |`,`| \`${Au(e,"app.model.cycleForward")}\` | Cycle role models (slow/default/smol) |`,`| \`${Au(e,"app.model.cycleBackward")}\` | Cycle role models (backward) |`,`| \`${Au(e,"app.model.selectTemporary")}\` | Select model (temporary) |`,`| \`${Au(e,"app.model.select")}\` | Select model (set roles) |`,`| \`${Au(e,"app.plan.toggle")}\` | Toggle plan mode |`,`| \`${Au(e,"app.history.search")}\` | Search prompt history |`,`| \`${Au(e,"app.tools.expand")}\` | Toggle tool output expansion |`,`| \`${Au(e,"app.tools.toggleVisibility")}\` | Toggle tool activity visibility |`,`| \`${Au(e,"app.thinking.toggle")}\` | Toggle thinking block visibility |`,`| \`${Au(e,"app.editor.external")}\` | Edit message in external editor |`,`| \`${Au(e,"app.retry")}\` | Retry last failed assistant turn |`,`| \`${Au(e,"app.clipboard.pasteImage")}\` | Paste image or text from clipboard |`,"| Hold `Space` | Speech-to-text (push-to-talk): hold to record, release to transcribe |",`| \`${Au(e,"app.live.toggle")}\` | Start/stop live voice mode (/live) |`,`| \`${Au(e,"app.agents.hub")}\` / \`${Au(e,"app.session.observe")}\` / double-tap \`\u2190\` (empty editor) | Open the agent hub |`,"| `#<number>` | GitHub issue/PR reference (e.g. `#3164` \u2192 `pr://`/`issue://`) |","| `#` / `#<text>` | Prompt actions (copy / undo / move cursor) |","| `/` | Slash commands |","| `!` | Run bash command |","| `!!` | Run bash command (excluded from context) |","| `$` | Run Python in shared kernel |","| `$$` | Run Python (excluded from context) |"].join(`
|
|
4457
4457
|
`)}var JJs=E(()=>{P0()});function QJs(e){return e.replace(/\|/g,"\\|").replace(/\r?\n+/g," ").trim()}function ZJs(e){if(e.tools.length===0&&!e.xdevTools?.length)return"No tools are currently visible to the agent.";let t=[];for(let s of e.tools){let n=QJs(s.description)||"No description provided.";t.push(`| \`${s.name}\` | ${n} |`)}for(let s of e.xdevTools??[])t.push(`| \`xd://${s.name}\` | ${QJs(s.summary)||"No description provided."} |`);return["| Tool | Description |","|------|-------------|",...t].join(`
|
|
4458
|
-
`)}function uDe(e){if(e.mode==="images"){let s=e.imagesDropped??0;return s===0?"No images found in this session.":`Dropped ${s} image${s===1?"":"s"} from this session.`}if(e.mode==="thinking"){let s=e.thinkingBlocksDropped??0;return s===0?"No thinking blocks found in this session.":`Dropped ${s} thinking block${s===1?"":"s"} from this session.`}let t=[];if(e.toolResultsDropped>0)t.push(`${e.toolResultsDropped} tool result${e.toolResultsDropped===1?"":"s"}`);if(e.blocksDropped>0)t.push(`${e.blocksDropped} block${e.blocksDropped===1?"":"s"}`);if(t.length===0)return"Nothing to shake.";return`Shook ${t.join(" + ")} (~${e.tokensFreed} tokens freed).`}function Cw(e){return typeof e==="string"&&e.trim()?e.trim().toLowerCase():void 0}function pDe(e){if(!e)return;let t=e.email||e.accountId||e.projectId;if(!t)return;let s=e.orgName||e.orgId;return s&&s!==t?`${t} (${s})`:t}function yK(e,t,s){if(!s)return!1;let n=e.metadata??{},o=Cw(s.accountId),i=Cw(s.email),r=Cw(s.projectId),a=Cw(s.orgId),l=Cw(n.orgId);if(a||l){if(a!==l)return!1;if(!o&&!i&&!r)return!0}if(o){if((Cw(n.accountId)??Cw(n.account_id))===o)return!0;if(Cw(t.scope.accountId)===o)return!0}if(i&&Cw(n.email)===i)return!0;if(r){if(Cw(n.projectId)===r)return!0;if(Cw(t.scope.projectId)===r)return!0}return!1}function cDe(e,t){if(!t)return!1;return e.limits.some((s)=>yK(e,s,t))}var tkt="./CHANGELOG-
|
|
4458
|
+
`)}function uDe(e){if(e.mode==="images"){let s=e.imagesDropped??0;return s===0?"No images found in this session.":`Dropped ${s} image${s===1?"":"s"} from this session.`}if(e.mode==="thinking"){let s=e.thinkingBlocksDropped??0;return s===0?"No thinking blocks found in this session.":`Dropped ${s} thinking block${s===1?"":"s"} from this session.`}let t=[];if(e.toolResultsDropped>0)t.push(`${e.toolResultsDropped} tool result${e.toolResultsDropped===1?"":"s"}`);if(e.blocksDropped>0)t.push(`${e.blocksDropped} block${e.blocksDropped===1?"":"s"}`);if(t.length===0)return"Nothing to shake.";return`Shook ${t.join(" + ")} (~${e.tokensFreed} tokens freed).`}function Cw(e){return typeof e==="string"&&e.trim()?e.trim().toLowerCase():void 0}function pDe(e){if(!e)return;let t=e.email||e.accountId||e.projectId;if(!t)return;let s=e.orgName||e.orgId;return s&&s!==t?`${t} (${s})`:t}function yK(e,t,s){if(!s)return!1;let n=e.metadata??{},o=Cw(s.accountId),i=Cw(s.email),r=Cw(s.projectId),a=Cw(s.orgId),l=Cw(n.orgId);if(a||l){if(a!==l)return!1;if(!o&&!i&&!r)return!0}if(o){if((Cw(n.accountId)??Cw(n.account_id))===o)return!0;if(Cw(t.scope.accountId)===o)return!0}if(i&&Cw(n.email)===i)return!0;if(r){if(Cw(n.projectId)===r)return!0;if(Cw(t.scope.projectId)===r)return!0}return!1}function cDe(e,t){if(!t)return!1;return e.limits.some((s)=>yK(e,s,t))}var tkt="./CHANGELOG-4ke2dm3h.md";var eQs=()=>{};import*as dDe from"path";function Fni(e){return{markdown:void 0,persistCurrentVersion:e,truncated:!1,selectedEntries:0,totalUnseenEntries:0,latestVersion:void 0,changeCount:0,categoryCounts:{}}}function Lni(e){let t={},s=0;for(let n of e){let o;for(let i of n.content.split(`
|
|
4459
4459
|
`)){let r=i.match(/^###\s+(.+?)\s*$/);if(r){o=r[1];continue}if(!o||!/^-\s+\S/.test(i))continue;t[o]=(t[o]??0)+1,s++}}return{changeCount:s,categoryCounts:t}}function Nni(e,t){if(e==="Breaking Changes")return t===1?"breaking change":"breaking changes";return e.toLowerCase()}function rQs(e){let t=e.latestVersion;if(!t||e.selectedEntries===0)return"Updated omp. Use /changelog for recent changes.";let{selectedEntries:s,changeCount:n}=e,o=s===1?"release":"releases",i=n===1?"change":"changes",r=s===1?`Updated to v${t} \xB7 ${n} ${i} in 1 release`:`Updated to v${t} \xB7 ${n} ${i} across ${s} ${o}`,l=[...tQs.filter((c)=>e.categoryCounts[c]),...Object.keys(e.categoryCounts).filter((c)=>!tQs.includes(c)).sort()].map((c)=>`${e.categoryCounts[c]} ${Nni(c,e.categoryCounts[c])}`).join(" \xB7 "),u=e.totalUnseenEntries-e.selectedEntries,p=u>0?`+${u} earlier ${u===1?"release":"releases"} \xB7 Use /changelog full for history.`:"Use /changelog for details.";return l?`${r}
|
|
4460
4460
|
${l} \xB7 ${p}`:`${r}
|
|
4461
4461
|
${p}`}function iQs(e,t){if(dDe.isAbsolute(e)||dDe.win32.isAbsolute(e))return e;return new URL(e,t)}async function fDe(e){let t;if(e)try{t=await Bun.file(e).text()}catch(s){if(!ye(s))P.error(`Warning: Could not parse changelog: ${s}`)}return t??=await Bun.file(iQs(tkt,import.meta.url)).text(),Dni(t)}function Dni(e){let t=e.split(`
|