@ebowwa/coder 0.1.12 → 0.2.1

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.
@@ -0,0 +1,345 @@
1
+ // @bun
2
+ var p9=Object.create;var{getPrototypeOf:a9,defineProperty:Z5,getOwnPropertyNames:r9}=Object;var n9=Object.prototype.hasOwnProperty;var Q5=($,Z,Q)=>{Q=$!=null?p9(a9($)):{};let J=Z||!$||!$.__esModule?Z5(Q,"default",{value:$,enumerable:!0}):Q;for(let X of r9($))if(!n9.call(J,X))Z5(J,X,{get:()=>$[X],enumerable:!0});return J};var T=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var v=import.meta.require;var E0=T((kW,A1)=>{/*!
3
+ Copyright 2013 Lovell Fuller and others.
4
+ SPDX-License-Identifier: Apache-2.0
5
+ */var U1=($)=>typeof $<"u"&&$!==null,_Z=($)=>typeof $==="object",wZ=($)=>Object.prototype.toString.call($)==="[object Object]",RZ=($)=>typeof $==="function",CZ=($)=>typeof $==="boolean",NZ=($)=>$ instanceof Buffer,PZ=($)=>{if(U1($))switch($.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},DZ=($)=>$ instanceof ArrayBuffer,FZ=($)=>typeof $==="string"&&$.length>0,MZ=($)=>typeof $==="number"&&!Number.isNaN($),IZ=($)=>Number.isInteger($),EZ=($,Z,Q)=>$>=Z&&$<=Q,SZ=($,Z)=>Z.includes($),TZ=($,Z,Q)=>Error(`Expected ${Z} for ${$} but received ${Q} of type ${typeof Q}`),kZ=($,Z)=>{return Z.message=$.message,Z};A1.exports={defined:U1,object:_Z,plainObject:wZ,fn:RZ,bool:CZ,buffer:NZ,typedArray:PZ,arrayBuffer:DZ,string:FZ,number:MZ,integer:IZ,inRange:EZ,inArray:SZ,invalidParameterError:TZ,nativeError:kZ}});var _1=T((xW,L1)=>{var B1=()=>process.platform==="linux",k6=null,xZ=()=>{if(!k6)if(B1()&&process.report){let $=process.report.excludeNetwork;process.report.excludeNetwork=!0,k6=process.report.getReport(),process.report.excludeNetwork=$}else k6={};return k6};L1.exports={isLinux:B1,getReport:xZ}});var R1=T((vW,w1)=>{var C4=v("fs"),vZ=($)=>{let Z=C4.openSync($,"r"),Q=Buffer.alloc(2048),J=C4.readSync(Z,Q,0,2048,0);return C4.close(Z,()=>{}),Q.subarray(0,J)},OZ=($)=>new Promise((Z,Q)=>{C4.open($,"r",(J,X)=>{if(J)Q(J);else{let V=Buffer.alloc(2048);C4.read(X,V,0,2048,0,(K,W)=>{Z(V.subarray(0,W)),C4.close(X,()=>{})})}})});w1.exports={LDD_PATH:"/usr/bin/ldd",SELF_PATH:"/proc/self/exe",readFileSync:vZ,readFile:OZ}});var N1=T((OW,C1)=>{var yZ=($)=>{if($.length<64)return null;if($.readUInt32BE(0)!==2135247942)return null;if($.readUInt8(4)!==2)return null;if($.readUInt8(5)!==1)return null;let Z=$.readUInt32LE(32),Q=$.readUInt16LE(54),J=$.readUInt16LE(56);for(let X=0;X<J;X++){let V=Z+X*Q;if($.readUInt32LE(V)===3){let W=$.readUInt32LE(V+8),H=$.readUInt32LE(V+32);return $.subarray(W,W+H).toString().replace(/\0.*$/g,"")}}return null};C1.exports={interpreterPath:yZ}});var v6=T((yW,g1)=>{var D1=v("child_process"),{isLinux:N4,getReport:F1}=_1(),{LDD_PATH:x6,SELF_PATH:M1,readFile:M2,readFileSync:I2}=R1(),{interpreterPath:I1}=N1(),S0,T0,k0,e0="",E1=()=>{if(!e0)return new Promise(($)=>{D1.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(Z,Q)=>{e0=Z?" ":Q,$(e0)})});return e0},S1=()=>{if(!e0)try{e0=D1.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch($){e0=" "}return e0},m0="glibc",T1=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,q4="musl",bZ=($)=>$.includes("libc.musl-")||$.includes("ld-musl-"),k1=()=>{let $=F1();if($.header&&$.header.glibcVersionRuntime)return m0;if(Array.isArray($.sharedObjects)){if($.sharedObjects.some(bZ))return q4}return null},x1=($)=>{let[Z,Q]=$.split(/[\r\n]+/);if(Z&&Z.includes(m0))return m0;if(Q&&Q.includes(q4))return q4;return null},v1=($)=>{if($){if($.includes("/ld-musl-"))return q4;else if($.includes("/ld-linux-"))return m0}return null},O1=($)=>{if($=$.toString(),$.includes("musl"))return q4;if($.includes("GNU C Library"))return m0;return null},fZ=async()=>{if(T0!==void 0)return T0;T0=null;try{let $=await M2(x6);T0=O1($)}catch($){}return T0},hZ=()=>{if(T0!==void 0)return T0;T0=null;try{let $=I2(x6);T0=O1($)}catch($){}return T0},gZ=async()=>{if(S0!==void 0)return S0;S0=null;try{let $=await M2(M1),Z=I1($);S0=v1(Z)}catch($){}return S0},dZ=()=>{if(S0!==void 0)return S0;S0=null;try{let $=I2(M1),Z=I1($);S0=v1(Z)}catch($){}return S0},y1=async()=>{let $=null;if(N4()){if($=await gZ(),!$){if($=await fZ(),!$)$=k1();if(!$){let Z=await E1();$=x1(Z)}}}return $},b1=()=>{let $=null;if(N4()){if($=dZ(),!$){if($=hZ(),!$)$=k1();if(!$){let Z=S1();$=x1(Z)}}}return $},uZ=async()=>N4()&&await y1()!==m0,mZ=()=>N4()&&b1()!==m0,cZ=async()=>{if(k0!==void 0)return k0;k0=null;try{let Z=(await M2(x6)).match(T1);if(Z)k0=Z[1]}catch($){}return k0},lZ=()=>{if(k0!==void 0)return k0;k0=null;try{let Z=I2(x6).match(T1);if(Z)k0=Z[1]}catch($){}return k0},f1=()=>{let $=F1();if($.header&&$.header.glibcVersionRuntime)return $.header.glibcVersionRuntime;return null},P1=($)=>$.trim().split(/\s+/)[1],h1=($)=>{let[Z,Q,J]=$.split(/[\r\n]+/);if(Z&&Z.includes(m0))return P1(Z);if(Q&&J&&Q.includes(q4))return P1(J);return null},pZ=async()=>{let $=null;if(N4()){if($=await cZ(),!$)$=f1();if(!$){let Z=await E1();$=h1(Z)}}return $},aZ=()=>{let $=null;if(N4()){if($=lZ(),!$)$=f1();if(!$){let Z=S1();$=h1(Z)}}return $};g1.exports={GLIBC:m0,MUSL:q4,family:y1,familySync:b1,isNonGlibcLinux:uZ,isNonGlibcLinuxSync:mZ,version:pZ,versionSync:aZ}});var Z6=T((bW,d1)=>{var rZ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};d1.exports=rZ});var O6=T((fW,u1)=>{var nZ=Number.MAX_SAFE_INTEGER||9007199254740991,iZ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];u1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:nZ,RELEASE_TYPES:iZ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Q6=T((x0,m1)=>{var{MAX_SAFE_COMPONENT_LENGTH:E2,MAX_SAFE_BUILD_LENGTH:sZ,MAX_LENGTH:oZ}=O6(),eZ=Z6();x0=m1.exports={};var tZ=x0.re=[],$Q=x0.safeRe=[],N=x0.src=[],ZQ=x0.safeSrc=[],P=x0.t={},QQ=0,S2="[a-zA-Z0-9-]",JQ=[["\\s",1],["\\d",oZ],[S2,sZ]],XQ=($)=>{for(let[Z,Q]of JQ)$=$.split(`${Z}*`).join(`${Z}{0,${Q}}`).split(`${Z}+`).join(`${Z}{1,${Q}}`);return $},E=($,Z,Q)=>{let J=XQ(Z),X=QQ++;eZ($,X,Z),P[$]=X,N[X]=Z,ZQ[X]=J,tZ[X]=new RegExp(Z,Q?"g":void 0),$Q[X]=new RegExp(J,Q?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${S2}*`);E("MAINVERSION",`(${N[P.NUMERICIDENTIFIER]})\\.(${N[P.NUMERICIDENTIFIER]})\\.(${N[P.NUMERICIDENTIFIER]})`);E("MAINVERSIONLOOSE",`(${N[P.NUMERICIDENTIFIERLOOSE]})\\.(${N[P.NUMERICIDENTIFIERLOOSE]})\\.(${N[P.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASEIDENTIFIER",`(?:${N[P.NONNUMERICIDENTIFIER]}|${N[P.NUMERICIDENTIFIER]})`);E("PRERELEASEIDENTIFIERLOOSE",`(?:${N[P.NONNUMERICIDENTIFIER]}|${N[P.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASE",`(?:-(${N[P.PRERELEASEIDENTIFIER]}(?:\\.${N[P.PRERELEASEIDENTIFIER]})*))`);E("PRERELEASELOOSE",`(?:-?(${N[P.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${N[P.PRERELEASEIDENTIFIERLOOSE]})*))`);E("BUILDIDENTIFIER",`${S2}+`);E("BUILD",`(?:\\+(${N[P.BUILDIDENTIFIER]}(?:\\.${N[P.BUILDIDENTIFIER]})*))`);E("FULLPLAIN",`v?${N[P.MAINVERSION]}${N[P.PRERELEASE]}?${N[P.BUILD]}?`);E("FULL",`^${N[P.FULLPLAIN]}$`);E("LOOSEPLAIN",`[v=\\s]*${N[P.MAINVERSIONLOOSE]}${N[P.PRERELEASELOOSE]}?${N[P.BUILD]}?`);E("LOOSE",`^${N[P.LOOSEPLAIN]}$`);E("GTLT","((?:<|>)?=?)");E("XRANGEIDENTIFIERLOOSE",`${N[P.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);E("XRANGEIDENTIFIER",`${N[P.NUMERICIDENTIFIER]}|x|X|\\*`);E("XRANGEPLAIN",`[v=\\s]*(${N[P.XRANGEIDENTIFIER]})(?:\\.(${N[P.XRANGEIDENTIFIER]})(?:\\.(${N[P.XRANGEIDENTIFIER]})(?:${N[P.PRERELEASE]})?${N[P.BUILD]}?)?)?`);E("XRANGEPLAINLOOSE",`[v=\\s]*(${N[P.XRANGEIDENTIFIERLOOSE]})(?:\\.(${N[P.XRANGEIDENTIFIERLOOSE]})(?:\\.(${N[P.XRANGEIDENTIFIERLOOSE]})(?:${N[P.PRERELEASELOOSE]})?${N[P.BUILD]}?)?)?`);E("XRANGE",`^${N[P.GTLT]}\\s*${N[P.XRANGEPLAIN]}$`);E("XRANGELOOSE",`^${N[P.GTLT]}\\s*${N[P.XRANGEPLAINLOOSE]}$`);E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${E2}})(?:\\.(\\d{1,${E2}}))?(?:\\.(\\d{1,${E2}}))?`);E("COERCE",`${N[P.COERCEPLAIN]}(?:$|[^\\d])`);E("COERCEFULL",N[P.COERCEPLAIN]+`(?:${N[P.PRERELEASE]})?(?:${N[P.BUILD]})?(?:$|[^\\d])`);E("COERCERTL",N[P.COERCE],!0);E("COERCERTLFULL",N[P.COERCEFULL],!0);E("LONETILDE","(?:~>?)");E("TILDETRIM",`(\\s*)${N[P.LONETILDE]}\\s+`,!0);x0.tildeTrimReplace="$1~";E("TILDE",`^${N[P.LONETILDE]}${N[P.XRANGEPLAIN]}$`);E("TILDELOOSE",`^${N[P.LONETILDE]}${N[P.XRANGEPLAINLOOSE]}$`);E("LONECARET","(?:\\^)");E("CARETTRIM",`(\\s*)${N[P.LONECARET]}\\s+`,!0);x0.caretTrimReplace="$1^";E("CARET",`^${N[P.LONECARET]}${N[P.XRANGEPLAIN]}$`);E("CARETLOOSE",`^${N[P.LONECARET]}${N[P.XRANGEPLAINLOOSE]}$`);E("COMPARATORLOOSE",`^${N[P.GTLT]}\\s*(${N[P.LOOSEPLAIN]})$|^$`);E("COMPARATOR",`^${N[P.GTLT]}\\s*(${N[P.FULLPLAIN]})$|^$`);E("COMPARATORTRIM",`(\\s*)${N[P.GTLT]}\\s*(${N[P.LOOSEPLAIN]}|${N[P.XRANGEPLAIN]})`,!0);x0.comparatorTrimReplace="$1$2$3";E("HYPHENRANGE",`^\\s*(${N[P.XRANGEPLAIN]})\\s+-\\s+(${N[P.XRANGEPLAIN]})\\s*$`);E("HYPHENRANGELOOSE",`^\\s*(${N[P.XRANGEPLAINLOOSE]})\\s+-\\s+(${N[P.XRANGEPLAINLOOSE]})\\s*$`);E("STAR","(<|>)?=?\\s*\\*");E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var y6=T((hW,c1)=>{var VQ=Object.freeze({loose:!0}),KQ=Object.freeze({}),WQ=($)=>{if(!$)return KQ;if(typeof $!=="object")return VQ;return $};c1.exports=WQ});var r1=T((gW,a1)=>{var l1=/^[0-9]+$/,p1=($,Z)=>{if(typeof $==="number"&&typeof Z==="number")return $===Z?0:$<Z?-1:1;let Q=l1.test($),J=l1.test(Z);if(Q&&J)$=+$,Z=+Z;return $===Z?0:Q&&!J?-1:J&&!Q?1:$<Z?-1:1},HQ=($,Z)=>p1(Z,$);a1.exports={compareIdentifiers:p1,rcompareIdentifiers:HQ}});var P4=T((dW,i1)=>{var b6=Z6(),{MAX_LENGTH:n1,MAX_SAFE_INTEGER:f6}=O6(),{safeRe:h6,t:g6}=Q6(),qQ=y6(),{compareIdentifiers:T2}=r1();class C0{constructor($,Z){if(Z=qQ(Z),$ instanceof C0)if($.loose===!!Z.loose&&$.includePrerelease===!!Z.includePrerelease)return $;else $=$.version;else if(typeof $!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof $}".`);if($.length>n1)throw TypeError(`version is longer than ${n1} characters`);b6("SemVer",$,Z),this.options=Z,this.loose=!!Z.loose,this.includePrerelease=!!Z.includePrerelease;let Q=$.trim().match(Z.loose?h6[g6.LOOSE]:h6[g6.FULL]);if(!Q)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+Q[1],this.minor=+Q[2],this.patch=+Q[3],this.major>f6||this.major<0)throw TypeError("Invalid major version");if(this.minor>f6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>f6||this.patch<0)throw TypeError("Invalid patch version");if(!Q[4])this.prerelease=[];else this.prerelease=Q[4].split(".").map((J)=>{if(/^[0-9]+$/.test(J)){let X=+J;if(X>=0&&X<f6)return X}return J});this.build=Q[5]?Q[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare($){if(b6("SemVer.compare",this.version,this.options,$),!($ instanceof C0)){if(typeof $==="string"&&$===this.version)return 0;$=new C0($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof C0))$=new C0($,this.options);if(this.major<$.major)return-1;if(this.major>$.major)return 1;if(this.minor<$.minor)return-1;if(this.minor>$.minor)return 1;if(this.patch<$.patch)return-1;if(this.patch>$.patch)return 1;return 0}comparePre($){if(!($ instanceof C0))$=new C0($,this.options);if(this.prerelease.length&&!$.prerelease.length)return-1;else if(!this.prerelease.length&&$.prerelease.length)return 1;else if(!this.prerelease.length&&!$.prerelease.length)return 0;let Z=0;do{let Q=this.prerelease[Z],J=$.prerelease[Z];if(b6("prerelease compare",Z,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return T2(Q,J)}while(++Z)}compareBuild($){if(!($ instanceof C0))$=new C0($,this.options);let Z=0;do{let Q=this.build[Z],J=$.build[Z];if(b6("build compare",Z,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return T2(Q,J)}while(++Z)}inc($,Z,Q){if($.startsWith("pre")){if(!Z&&Q===!1)throw Error("invalid increment argument: identifier is empty");if(Z){let J=`-${Z}`.match(this.options.loose?h6[g6.PRERELEASELOOSE]:h6[g6.PRERELEASE]);if(!J||J[1]!==Z)throw Error(`invalid identifier: ${Z}`)}}switch($){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",Z,Q);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",Z,Q);break;case"prepatch":this.prerelease.length=0,this.inc("patch",Z,Q),this.inc("pre",Z,Q);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",Z,Q);this.inc("pre",Z,Q);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let J=Number(Q)?1:0;if(this.prerelease.length===0)this.prerelease=[J];else{let X=this.prerelease.length;while(--X>=0)if(typeof this.prerelease[X]==="number")this.prerelease[X]++,X=-2;if(X===-1){if(Z===this.prerelease.join(".")&&Q===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(J)}}if(Z){let X=[Z,J];if(Q===!1)X=[Z];if(T2(this.prerelease[0],Z)===0){if(isNaN(this.prerelease[1]))this.prerelease=X}else this.prerelease=X}break}default:throw Error(`invalid increment argument: ${$}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}i1.exports=C0});var e1=T((uW,o1)=>{var s1=P4(),YQ=($,Z,Q=!1)=>{if($ instanceof s1)return $;try{return new s1($,Z)}catch(J){if(!Q)return null;throw J}};o1.exports=YQ});var $$=T((mW,t1)=>{var zQ=P4(),GQ=e1(),{safeRe:d6,t:u6}=Q6(),jQ=($,Z)=>{if($ instanceof zQ)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;Z=Z||{};let Q=null;if(!Z.rtl)Q=$.match(Z.includePrerelease?d6[u6.COERCEFULL]:d6[u6.COERCE]);else{let H=Z.includePrerelease?d6[u6.COERCERTLFULL]:d6[u6.COERCERTL],q;while((q=H.exec($))&&(!Q||Q.index+Q[0].length!==$.length)){if(!Q||q.index+q[0].length!==Q.index+Q[0].length)Q=q;H.lastIndex=q.index+q[1].length+q[2].length}H.lastIndex=-1}if(Q===null)return null;let J=Q[2],X=Q[3]||"0",V=Q[4]||"0",K=Z.includePrerelease&&Q[5]?`-${Q[5]}`:"",W=Z.includePrerelease&&Q[6]?`+${Q[6]}`:"";return GQ(`${J}.${X}.${V}${K}${W}`,Z)};t1.exports=jQ});var Y4=T((cW,Q$)=>{var Z$=P4(),UQ=($,Z,Q)=>new Z$($,Q).compare(new Z$(Z,Q));Q$.exports=UQ});var k2=T((lW,J$)=>{var AQ=Y4(),BQ=($,Z,Q)=>AQ($,Z,Q)>=0;J$.exports=BQ});var K$=T((pW,V$)=>{class X${constructor(){this.max=1000,this.map=new Map}get($){let Z=this.map.get($);if(Z===void 0)return;else return this.map.delete($),this.map.set($,Z),Z}delete($){return this.map.delete($)}set($,Z){if(!this.delete($)&&Z!==void 0){if(this.map.size>=this.max){let J=this.map.keys().next().value;this.delete(J)}this.map.set($,Z)}return this}}V$.exports=X$});var H$=T((aW,W$)=>{var LQ=Y4(),_Q=($,Z,Q)=>LQ($,Z,Q)===0;W$.exports=_Q});var Y$=T((rW,q$)=>{var wQ=Y4(),RQ=($,Z,Q)=>wQ($,Z,Q)!==0;q$.exports=RQ});var G$=T((nW,z$)=>{var CQ=Y4(),NQ=($,Z,Q)=>CQ($,Z,Q)>0;z$.exports=NQ});var U$=T((iW,j$)=>{var PQ=Y4(),DQ=($,Z,Q)=>PQ($,Z,Q)<0;j$.exports=DQ});var B$=T((sW,A$)=>{var FQ=Y4(),MQ=($,Z,Q)=>FQ($,Z,Q)<=0;A$.exports=MQ});var _$=T((oW,L$)=>{var IQ=H$(),EQ=Y$(),SQ=G$(),TQ=k2(),kQ=U$(),xQ=B$(),vQ=($,Z,Q,J)=>{switch(Z){case"===":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $===Q;case"!==":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $!==Q;case"":case"=":case"==":return IQ($,Q,J);case"!=":return EQ($,Q,J);case">":return SQ($,Q,J);case">=":return TQ($,Q,J);case"<":return kQ($,Q,J);case"<=":return xQ($,Q,J);default:throw TypeError(`Invalid operator: ${Z}`)}};L$.exports=vQ});var F$=T((eW,D$)=>{var J6=Symbol("SemVer ANY");class m6{static get ANY(){return J6}constructor($,Z){if(Z=w$(Z),$ instanceof m6)if($.loose===!!Z.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),v2("comparator",$,Z),this.options=Z,this.loose=!!Z.loose,this.parse($),this.semver===J6)this.value="";else this.value=this.operator+this.semver.version;v2("comp",this)}parse($){let Z=this.options.loose?R$[C$.COMPARATORLOOSE]:R$[C$.COMPARATOR],Q=$.match(Z);if(!Q)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=Q[1]!==void 0?Q[1]:"",this.operator==="=")this.operator="";if(!Q[2])this.semver=J6;else this.semver=new N$(Q[2],this.options.loose)}toString(){return this.value}test($){if(v2("Comparator.test",$,this.options.loose),this.semver===J6||$===J6)return!0;if(typeof $==="string")try{$=new N$($,this.options)}catch(Z){return!1}return x2($,this.operator,this.semver,this.options)}intersects($,Z){if(!($ instanceof m6))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new P$($.value,Z).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new P$(this.value,Z).test($.semver)}if(Z=w$(Z),Z.includePrerelease&&(this.value==="<0.0.0-0"||$.value==="<0.0.0-0"))return!1;if(!Z.includePrerelease&&(this.value.startsWith("<0.0.0")||$.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&$.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&$.operator.startsWith("<"))return!0;if(this.semver.version===$.semver.version&&this.operator.includes("=")&&$.operator.includes("="))return!0;if(x2(this.semver,"<",$.semver,Z)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(x2(this.semver,">",$.semver,Z)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}D$.exports=m6;var w$=y6(),{safeRe:R$,t:C$}=Q6(),x2=_$(),v2=Z6(),N$=P4(),P$=O2()});var O2=T((tW,S$)=>{var OQ=/\s+/g;class X6{constructor($,Z){if(Z=bQ(Z),$ instanceof X6)if($.loose===!!Z.loose&&$.includePrerelease===!!Z.includePrerelease)return $;else return new X6($.raw,Z);if($ instanceof y2)return this.raw=$.value,this.set=[[$]],this.formatted=void 0,this;if(this.options=Z,this.loose=!!Z.loose,this.includePrerelease=!!Z.includePrerelease,this.raw=$.trim().replace(OQ," "),this.set=this.raw.split("||").map((Q)=>this.parseRange(Q.trim())).filter((Q)=>Q.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Q=this.set[0];if(this.set=this.set.filter((J)=>!I$(J[0])),this.set.length===0)this.set=[Q];else if(this.set.length>1){for(let J of this.set)if(J.length===1&&cQ(J[0])){this.set=[J];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let $=0;$<this.set.length;$++){if($>0)this.formatted+="||";let Z=this.set[$];for(let Q=0;Q<Z.length;Q++){if(Q>0)this.formatted+=" ";this.formatted+=Z[Q].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let Q=((this.options.includePrerelease&&uQ)|(this.options.loose&&mQ))+":"+$,J=M$.get(Q);if(J)return J;let X=this.options.loose,V=X?J0[e.HYPHENRANGELOOSE]:J0[e.HYPHENRANGE];$=$.replace(V,tQ(this.options.includePrerelease)),g("hyphen replace",$),$=$.replace(J0[e.COMPARATORTRIM],hQ),g("comparator trim",$),$=$.replace(J0[e.TILDETRIM],gQ),g("tilde trim",$),$=$.replace(J0[e.CARETTRIM],dQ),g("caret trim",$);let K=$.split(" ").map((z)=>lQ(z,this.options)).join(" ").split(/\s+/).map((z)=>eQ(z,this.options));if(X)K=K.filter((z)=>{return g("loose invalid filter",z,this.options),!!z.match(J0[e.COMPARATORLOOSE])});g("range list",K);let W=new Map,H=K.map((z)=>new y2(z,this.options));for(let z of H){if(I$(z))return[z];W.set(z.value,z)}if(W.size>1&&W.has(""))W.delete("");let q=[...W.values()];return M$.set(Q,q),q}intersects($,Z){if(!($ instanceof X6))throw TypeError("a Range is required");return this.set.some((Q)=>{return E$(Q,Z)&&$.set.some((J)=>{return E$(J,Z)&&Q.every((X)=>{return J.every((V)=>{return X.intersects(V,Z)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new fQ($,this.options)}catch(Z){return!1}for(let Z=0;Z<this.set.length;Z++)if($J(this.set[Z],$,this.options))return!0;return!1}}S$.exports=X6;var yQ=K$(),M$=new yQ,bQ=y6(),y2=F$(),g=Z6(),fQ=P4(),{safeRe:J0,t:e,comparatorTrimReplace:hQ,tildeTrimReplace:gQ,caretTrimReplace:dQ}=Q6(),{FLAG_INCLUDE_PRERELEASE:uQ,FLAG_LOOSE:mQ}=O6(),I$=($)=>$.value==="<0.0.0-0",cQ=($)=>$.value==="",E$=($,Z)=>{let Q=!0,J=$.slice(),X=J.pop();while(Q&&J.length)Q=J.every((V)=>{return X.intersects(V,Z)}),X=J.pop();return Q},lQ=($,Z)=>{return $=$.replace(J0[e.BUILD],""),g("comp",$,Z),$=rQ($,Z),g("caret",$),$=pQ($,Z),g("tildes",$),$=iQ($,Z),g("xrange",$),$=oQ($,Z),g("stars",$),$},X0=($)=>!$||$.toLowerCase()==="x"||$==="*",pQ=($,Z)=>{return $.trim().split(/\s+/).map((Q)=>aQ(Q,Z)).join(" ")},aQ=($,Z)=>{let Q=Z.loose?J0[e.TILDELOOSE]:J0[e.TILDE];return $.replace(Q,(J,X,V,K,W)=>{g("tilde",$,J,X,V,K,W);let H;if(X0(X))H="";else if(X0(V))H=`>=${X}.0.0 <${+X+1}.0.0-0`;else if(X0(K))H=`>=${X}.${V}.0 <${X}.${+V+1}.0-0`;else if(W)g("replaceTilde pr",W),H=`>=${X}.${V}.${K}-${W} <${X}.${+V+1}.0-0`;else H=`>=${X}.${V}.${K} <${X}.${+V+1}.0-0`;return g("tilde return",H),H})},rQ=($,Z)=>{return $.trim().split(/\s+/).map((Q)=>nQ(Q,Z)).join(" ")},nQ=($,Z)=>{g("caret",$,Z);let Q=Z.loose?J0[e.CARETLOOSE]:J0[e.CARET],J=Z.includePrerelease?"-0":"";return $.replace(Q,(X,V,K,W,H)=>{g("caret",$,X,V,K,W,H);let q;if(X0(V))q="";else if(X0(K))q=`>=${V}.0.0${J} <${+V+1}.0.0-0`;else if(X0(W))if(V==="0")q=`>=${V}.${K}.0${J} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.0${J} <${+V+1}.0.0-0`;else if(H)if(g("replaceCaret pr",H),V==="0")if(K==="0")q=`>=${V}.${K}.${W}-${H} <${V}.${K}.${+W+1}-0`;else q=`>=${V}.${K}.${W}-${H} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.${W}-${H} <${+V+1}.0.0-0`;else if(g("no pr"),V==="0")if(K==="0")q=`>=${V}.${K}.${W}${J} <${V}.${K}.${+W+1}-0`;else q=`>=${V}.${K}.${W}${J} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.${W} <${+V+1}.0.0-0`;return g("caret return",q),q})},iQ=($,Z)=>{return g("replaceXRanges",$,Z),$.split(/\s+/).map((Q)=>sQ(Q,Z)).join(" ")},sQ=($,Z)=>{$=$.trim();let Q=Z.loose?J0[e.XRANGELOOSE]:J0[e.XRANGE];return $.replace(Q,(J,X,V,K,W,H)=>{g("xRange",$,J,X,V,K,W,H);let q=X0(V),z=q||X0(K),G=z||X0(W),A=G;if(X==="="&&A)X="";if(H=Z.includePrerelease?"-0":"",q)if(X===">"||X==="<")J="<0.0.0-0";else J="*";else if(X&&A){if(z)K=0;if(W=0,X===">")if(X=">=",z)V=+V+1,K=0,W=0;else K=+K+1,W=0;else if(X==="<=")if(X="<",z)V=+V+1;else K=+K+1;if(X==="<")H="-0";J=`${X+V}.${K}.${W}${H}`}else if(z)J=`>=${V}.0.0${H} <${+V+1}.0.0-0`;else if(G)J=`>=${V}.${K}.0${H} <${V}.${+K+1}.0-0`;return g("xRange return",J),J})},oQ=($,Z)=>{return g("replaceStars",$,Z),$.trim().replace(J0[e.STAR],"")},eQ=($,Z)=>{return g("replaceGTE0",$,Z),$.trim().replace(J0[Z.includePrerelease?e.GTE0PRE:e.GTE0],"")},tQ=($)=>(Z,Q,J,X,V,K,W,H,q,z,G,A)=>{if(X0(J))Q="";else if(X0(X))Q=`>=${J}.0.0${$?"-0":""}`;else if(X0(V))Q=`>=${J}.${X}.0${$?"-0":""}`;else if(K)Q=`>=${Q}`;else Q=`>=${Q}${$?"-0":""}`;if(X0(q))H="";else if(X0(z))H=`<${+q+1}.0.0-0`;else if(X0(G))H=`<${q}.${+z+1}.0-0`;else if(A)H=`<=${q}.${z}.${G}-${A}`;else if($)H=`<${q}.${z}.${+G+1}-0`;else H=`<=${H}`;return`${Q} ${H}`.trim()},$J=($,Z,Q)=>{for(let J=0;J<$.length;J++)if(!$[J].test(Z))return!1;if(Z.prerelease.length&&!Q.includePrerelease){for(let J=0;J<$.length;J++){if(g($[J].semver),$[J].semver===y2.ANY)continue;if($[J].semver.prerelease.length>0){let X=$[J].semver;if(X.major===Z.major&&X.minor===Z.minor&&X.patch===Z.patch)return!0}}return!1}return!0}});var k$=T(($H,T$)=>{var ZJ=O2(),QJ=($,Z,Q)=>{try{Z=new ZJ(Z,Q)}catch(J){return!1}return Z.test($)};T$.exports=QJ});var b2=T((ZH,JJ)=>{JJ.exports={name:"sharp",description:"High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",version:"0.34.5",author:"Lovell Fuller <npm@lovell.info>",homepage:"https://sharp.pixelplumbing.com",contributors:["Pierre Inglebert <pierre.inglebert@gmail.com>","Jonathan Ong <jonathanrichardong@gmail.com>","Chanon Sajjamanochai <chanon.s@gmail.com>","Juliano Julio <julianojulio@gmail.com>","Daniel Gasienica <daniel@gasienica.ch>","Julian Walker <julian@fiftythree.com>","Amit Pitaru <pitaru.amit@gmail.com>","Brandon Aaron <hello.brandon@aaron.sh>","Andreas Lind <andreas@one.com>","Maurus Cuelenaere <mcuelenaere@gmail.com>","Linus Unneb\xE4ck <linus@folkdatorn.se>","Victor Mateevitsi <mvictoras@gmail.com>","Alaric Holloway <alaric.holloway@gmail.com>","Bernhard K. Weisshuhn <bkw@codingforce.com>","Chris Riley <criley@primedia.com>","David Carley <dacarley@gmail.com>","John Tobin <john@limelightmobileinc.com>","Kenton Gray <kentongray@gmail.com>","Felix B\xFCnemann <Felix.Buenemann@gmail.com>","Samy Al Zahrani <samyalzahrany@gmail.com>","Chintan Thakkar <lemnisk8@gmail.com>","F. Orlando Galashan <frulo@gmx.de>","Kleis Auke Wolthuizen <info@kleisauke.nl>","Matt Hirsch <mhirsch@media.mit.edu>","Matthias Thoemmes <thoemmes@gmail.com>","Patrick Paskaris <patrick@paskaris.gr>","J\xE9r\xE9my Lal <kapouer@melix.org>","Rahul Nanwani <r.nanwani@gmail.com>","Alice Monday <alice0meta@gmail.com>","Kristo Jorgenson <kristo.jorgenson@gmail.com>","YvesBos <yves_bos@outlook.com>","Guy Maliar <guy@tailorbrands.com>","Nicolas Coden <nicolas@ncoden.fr>","Matt Parrish <matt.r.parrish@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Matthew McEachen <matthew+github@mceachen.org>","Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>","Kenric D'Souza <kenric.dsouza@gmail.com>","Oleh Aleinyk <oleg.aleynik@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Andrea Bianco <andrea.bianco@unibas.ch>","Rik Heywood <rik@rik.org>","Thomas Parisot <hi@oncletom.io>","Nathan Graves <nathanrgraves+github@gmail.com>","Tom Lokhorst <tom@lokhorst.eu>","Espen Hovlandsdal <espen@hovlandsdal.com>","Sylvain Dumont <sylvain.dumont35@gmail.com>","Alun Davies <alun.owain.davies@googlemail.com>","Aidan Hoolachan <ajhoolachan21@gmail.com>","Axel Eirola <axel.eirola@iki.fi>","Freezy <freezy@xbmc.org>","Daiz <taneli.vatanen@gmail.com>","Julian Aubourg <j@ubourg.net>","Keith Belovay <keith@picthrive.com>","Michael B. Klein <mbklein@gmail.com>","Jordan Prudhomme <jordan@raboland.fr>","Ilya Ovdin <iovdin@gmail.com>","Andargor <andargor@yahoo.com>","Paul Neave <paul.neave@gmail.com>","Brendan Kennedy <brenwken@gmail.com>","Brychan Bennett-Odlum <git@brychan.io>","Edward Silverton <e.silverton@gmail.com>","Roman Malieiev <aromaleev@gmail.com>","Tomas Szabo <tomas.szabo@deftomat.com>","Robert O'Rourke <robert@o-rourke.org>","Guillermo Alfonso Varela Chouci\xF1o <guillevch@gmail.com>","Christian Flintrup <chr@gigahost.dk>","Manan Jadhav <manan@motionden.com>","Leon Radley <leon@radley.se>","alza54 <alza54@thiocod.in>","Jacob Smith <jacob@frende.me>","Michael Nutt <michael@nutt.im>","Brad Parham <baparham@gmail.com>","Taneli Vatanen <taneli.vatanen@gmail.com>","Joris Dugu\xE9 <zaruike10@gmail.com>","Chris Banks <christopher.bradley.banks@gmail.com>","Ompal Singh <ompal.hitm09@gmail.com>","Brodan <christopher.hranj@gmail.com>","Ankur Parihar <ankur.github@gmail.com>","Brahim Ait elhaj <brahima@gmail.com>","Mart Jansink <m.jansink@gmail.com>","Lachlan Newman <lachnewman007@gmail.com>","Dennis Beatty <dennis@dcbeatty.com>","Ingvar Stepanyan <me@rreverser.com>","Don Denton <don@happycollision.com>"],scripts:{build:"node install/build.js",install:"node install/check.js || npm run build",clean:"rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",test:"npm run lint && npm run test-unit",lint:"npm run lint-cpp && npm run lint-js && npm run lint-types","lint-cpp":"cpplint --quiet src/*.h src/*.cc","lint-js":"biome lint","lint-types":"tsd --files ./test/types/sharp.test-d.ts","test-leak":"./test/leak/leak.sh","test-unit":"node --experimental-test-coverage test/unit.mjs","package-from-local-build":"node npm/from-local-build.js","package-release-notes":"node npm/release-notes.js","docs-build":"node docs/build.mjs","docs-serve":"cd docs && npm start","docs-publish":"cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"},type:"commonjs",main:"lib/index.js",types:"lib/index.d.ts",files:["install","lib","src/*.{cc,h,gyp}"],repository:{type:"git",url:"git://github.com/lovell/sharp.git"},keywords:["jpeg","png","webp","avif","tiff","gif","svg","jp2","dzi","image","resize","thumbnail","crop","embed","libvips","vips"],dependencies:{"@img/colour":"^1.0.0","detect-libc":"^2.1.2",semver:"^7.7.3"},optionalDependencies:{"@img/sharp-darwin-arm64":"0.34.5","@img/sharp-darwin-x64":"0.34.5","@img/sharp-libvips-darwin-arm64":"1.2.4","@img/sharp-libvips-darwin-x64":"1.2.4","@img/sharp-libvips-linux-arm":"1.2.4","@img/sharp-libvips-linux-arm64":"1.2.4","@img/sharp-libvips-linux-ppc64":"1.2.4","@img/sharp-libvips-linux-riscv64":"1.2.4","@img/sharp-libvips-linux-s390x":"1.2.4","@img/sharp-libvips-linux-x64":"1.2.4","@img/sharp-libvips-linuxmusl-arm64":"1.2.4","@img/sharp-libvips-linuxmusl-x64":"1.2.4","@img/sharp-linux-arm":"0.34.5","@img/sharp-linux-arm64":"0.34.5","@img/sharp-linux-ppc64":"0.34.5","@img/sharp-linux-riscv64":"0.34.5","@img/sharp-linux-s390x":"0.34.5","@img/sharp-linux-x64":"0.34.5","@img/sharp-linuxmusl-arm64":"0.34.5","@img/sharp-linuxmusl-x64":"0.34.5","@img/sharp-wasm32":"0.34.5","@img/sharp-win32-arm64":"0.34.5","@img/sharp-win32-ia32":"0.34.5","@img/sharp-win32-x64":"0.34.5"},devDependencies:{"@biomejs/biome":"^2.3.4","@cpplint/cli":"^0.1.0","@emnapi/runtime":"^1.7.0","@img/sharp-libvips-dev":"1.2.4","@img/sharp-libvips-dev-wasm32":"1.2.4","@img/sharp-libvips-win32-arm64":"1.2.4","@img/sharp-libvips-win32-ia32":"1.2.4","@img/sharp-libvips-win32-x64":"1.2.4","@types/node":"*",emnapi:"^1.7.0","exif-reader":"^2.0.2","extract-zip":"^2.0.1",icc:"^3.0.0","jsdoc-to-markdown":"^9.1.3","node-addon-api":"^8.5.0","node-gyp":"^11.5.0","tar-fs":"^3.1.1",tsd:"^0.33.0"},license:"Apache-2.0",engines:{node:"^18.17.0 || ^20.3.0 || >=21.0.0"},config:{libvips:">=8.17.3"},funding:{url:"https://opencollective.com/libvips"}}});var h2=T((QH,u$)=>{/*!
6
+ Copyright 2013 Lovell Fuller and others.
7
+ SPDX-License-Identifier: Apache-2.0
8
+ */var{spawnSync:c6}=v("child_process"),{createHash:XJ}=v("crypto"),y$=$$(),VJ=k2(),KJ=k$(),x$=v6(),{config:WJ,engines:v$,optionalDependencies:HJ}=b2(),qJ=process.env.npm_package_config_libvips||WJ.libvips,b$=y$(qJ).version,YJ=["darwin-arm64","darwin-x64","linux-arm","linux-arm64","linux-ppc64","linux-riscv64","linux-s390x","linux-x64","linuxmusl-arm64","linuxmusl-x64","win32-arm64","win32-ia32","win32-x64"],l6={encoding:"utf8",shell:!0},zJ=($)=>{if($ instanceof Error)console.error(`sharp: Installation error: ${$.message}`);else console.log(`sharp: ${$}`)},f$=()=>x$.isNonGlibcLinuxSync()?x$.familySync():"",GJ=()=>`${process.platform}${f$()}-${process.arch}`,D4=()=>{if(h$())return"wasm32";let{npm_config_arch:$,npm_config_platform:Z,npm_config_libc:Q}=process.env,J=typeof Q==="string"?Q:f$();return`${Z||process.platform}${J}-${$||process.arch}`},jJ=()=>{try{return v(`@img/sharp-libvips-dev-${D4()}/include`)}catch{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/include");})()}catch{}}return""},UJ=()=>{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/cplusplus");})()}catch{}return""},AJ=()=>{try{return v(`@img/sharp-libvips-dev-${D4()}/lib`)}catch{try{return v(`@img/sharp-libvips-${D4()}/lib`)}catch{}}return""},BJ=()=>{if(process.release?.name==="node"&&process.versions){if(!KJ(process.versions.node,v$.node))return{found:process.versions.node,expected:v$.node}}},h$=()=>{let{CC:$}=process.env;return Boolean($?.endsWith("/emcc"))},LJ=()=>{if(process.platform==="darwin"&&process.arch==="x64")return(c6("sysctl sysctl.proc_translated",l6).stdout||"").trim()==="sysctl.proc_translated: 1";return!1},O$=($)=>XJ("sha512").update($).digest("hex"),_J=()=>{try{let $=O$(`imgsharp-libvips-${D4()}`),Z=y$(HJ[`@img/sharp-libvips-${D4()}`],{includePrerelease:!0}).version;return O$(`${$}npm:${Z}`).slice(0,10)}catch{}return""},wJ=()=>c6(`node-gyp rebuild --directory=src ${h$()?"--nodedir=emscripten":""}`,{...l6,stdio:"inherit"}).status,g$=()=>{if(process.platform!=="win32")return(c6("pkg-config --modversion vips-cpp",{...l6,env:{...process.env,PKG_CONFIG_PATH:d$()}}).stdout||"").trim();else return""},d$=()=>{if(process.platform!=="win32")return[(c6('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',l6).stdout||"").trim(),process.env.PKG_CONFIG_PATH,"/usr/local/lib/pkgconfig","/usr/lib/pkgconfig","/usr/local/libdata/pkgconfig","/usr/libdata/pkgconfig"].filter(Boolean).join(":");else return""},f2=($,Z,Q)=>{if(Q)Q(`Detected ${Z}, skipping search for globally-installed libvips`);return $},RJ=($)=>{if(Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)===!0)return f2(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",$);if(Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)===!0)return f2(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",$);if(LJ())return f2(!1,"Rosetta",$);let Z=g$();return!!Z&&VJ(Z,b$)};u$.exports={minimumLibvipsVersion:b$,prebuiltPlatforms:YJ,buildPlatformArch:D4,buildSharpLibvipsIncludeDir:jJ,buildSharpLibvipsCPlusPlusDir:UJ,buildSharpLibvipsLibDir:AJ,isUnsupportedNodeRuntime:BJ,runtimePlatformArch:GJ,log:zJ,yarnLocator:_J,spawnRebuild:wJ,globalLibvipsVersion:g$,pkgConfigPath:d$,useGlobalLibvips:RJ}});var K6=T((XH,c$)=>{/*!
9
+ Copyright 2013 Lovell Fuller and others.
10
+ SPDX-License-Identifier: Apache-2.0
11
+ */var{familySync:CJ,versionSync:NJ}=v6(),{runtimePlatformArch:PJ,isUnsupportedNodeRuntime:m$,prebuiltPlatforms:DJ,minimumLibvipsVersion:FJ}=h2(),z4=PJ(),MJ=[`../src/build/Release/sharp-${z4}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${z4}/sharp.node`,"@img/sharp-wasm32/sharp.node"],g2,F4,V6=[];for(g2 of MJ)try{F4=v(g2);break}catch($){V6.push($)}if(F4&&g2.startsWith("@img/sharp-linux-x64")&&!F4._isUsingX64V2()){let $=Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");$.code="Unsupported CPU",V6.push($),F4=null}if(F4)c$.exports=F4;else{let[$,Z,Q]=["linux","darwin","win32"].map((V)=>z4.startsWith(V)),J=[`Could not load the "sharp" module using the ${z4} runtime`];V6.forEach((V)=>{if(V.code!=="MODULE_NOT_FOUND")J.push(`${V.code}: ${V.message}`)});let X=V6.map((V)=>V.message).join(" ");if(J.push("Possible solutions:"),m$()){let{found:V,expected:K}=m$();J.push("- Please upgrade Node.js:",` Found ${V}`,` Requires ${K}`)}else if(DJ.includes(z4)){let[V,K]=z4.split("-"),W=V.endsWith("musl")?" --libc=musl":"";J.push("- Ensure optional dependencies can be installed:"," npm install --include=optional sharp","- Ensure your package manager supports multi-platform installation:"," See https://sharp.pixelplumbing.com/install#cross-platform","- Add platform-specific dependencies:",` npm install --os=${V.replace("musl","")}${W} --cpu=${K} sharp`)}else J.push(`- Manually install libvips >= ${FJ}`,"- Add experimental WebAssembly-based dependencies:"," npm install --cpu=wasm32 sharp"," npm install @img/sharp-wasm32");if($&&/(symbol not found|CXXABI_)/i.test(X))try{let{config:V}=v(`@img/sharp-libvips-${z4}/package`),K=`${CJ()} ${NJ()}`,W=`${V.musl?"musl":"glibc"} ${V.musl||V.glibc}`;J.push("- Update your OS:",` Found ${K}`,` Requires ${W}`)}catch(V){}if($&&/\/snap\/core[0-9]{2}/.test(X))J.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node");if(Z&&/Incompatible library version/.test(X))J.push("- Update Homebrew:"," brew update && brew upgrade vips");if(V6.some((V)=>V.code==="ERR_DLOPEN_DISABLED"))J.push("- Run Node.js without using the --no-addons flag");if(Q&&/The specified procedure could not be found/.test(X))J.push("- Using the canvas package on Windows?"," See https://sharp.pixelplumbing.com/install#canvas-and-windows","- Check for outdated versions of sharp in the dependency tree:"," npm ls sharp");throw J.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),Error(J.join(`
12
+ `))}});var p$=T((KH,l$)=>{/*!
13
+ Copyright 2013 Lovell Fuller and others.
14
+ SPDX-License-Identifier: Apache-2.0
15
+ */var IJ=v("util"),d2=v("stream"),EJ=E0();K6();var SJ=IJ.debuglog("sharp"),TJ=($)=>{G4.queue.emit("change",$)},G4=function($,Z){if(arguments.length===1&&!EJ.defined($))throw Error("Invalid input");if(!(this instanceof G4))return new G4($,Z);return d2.Duplex.call(this),this.options={topOffsetPre:-1,leftOffsetPre:-1,widthPre:-1,heightPre:-1,topOffsetPost:-1,leftOffsetPost:-1,widthPost:-1,heightPost:-1,width:-1,height:-1,canvas:"crop",position:0,resizeBackground:[0,0,0,255],angle:0,rotationAngle:0,rotationBackground:[0,0,0,255],rotateBefore:!1,orientBefore:!1,flip:!1,flop:!1,extendTop:0,extendBottom:0,extendLeft:0,extendRight:0,extendBackground:[0,0,0,255],extendWith:"background",withoutEnlargement:!1,withoutReduction:!1,affineMatrix:[],affineBackground:[0,0,0,255],affineIdx:0,affineIdy:0,affineOdx:0,affineOdy:0,affineInterpolator:this.constructor.interpolators.bilinear,kernel:"lanczos3",fastShrinkOnLoad:!0,tint:[-1,0,0,0],flatten:!1,flattenBackground:[0,0,0],unflatten:!1,negate:!1,negateAlpha:!0,medianSize:0,blurSigma:0,precision:"integer",minAmpl:0.2,sharpenSigma:0,sharpenM1:1,sharpenM2:2,sharpenX1:2,sharpenY2:10,sharpenY3:20,threshold:0,thresholdGrayscale:!0,trimBackground:[],trimThreshold:-1,trimLineArt:!1,dilateWidth:0,erodeWidth:0,gamma:0,gammaOut:0,greyscale:!1,normalise:!1,normaliseLower:1,normaliseUpper:99,claheWidth:0,claheHeight:0,claheMaxSlope:3,brightness:1,saturation:1,hue:0,lightness:0,booleanBufferIn:null,booleanFileIn:"",joinChannelIn:[],extractChannel:-1,removeAlpha:!1,ensureAlpha:-1,colourspace:"srgb",colourspacePipeline:"last",composite:[],fileOut:"",formatOut:"input",streamOut:!1,keepMetadata:0,withMetadataOrientation:-1,withMetadataDensity:0,withIccProfile:"",withExif:{},withExifMerge:!0,withXmp:"",resolveWithObject:!1,loop:-1,delay:[],jpegQuality:80,jpegProgressive:!1,jpegChromaSubsampling:"4:2:0",jpegTrellisQuantisation:!1,jpegOvershootDeringing:!1,jpegOptimiseScans:!1,jpegOptimiseCoding:!0,jpegQuantisationTable:0,pngProgressive:!1,pngCompressionLevel:6,pngAdaptiveFiltering:!1,pngPalette:!1,pngQuality:100,pngEffort:7,pngBitdepth:8,pngDither:1,jp2Quality:80,jp2TileHeight:512,jp2TileWidth:512,jp2Lossless:!1,jp2ChromaSubsampling:"4:4:4",webpQuality:80,webpAlphaQuality:100,webpLossless:!1,webpNearLossless:!1,webpSmartSubsample:!1,webpSmartDeblock:!1,webpPreset:"default",webpEffort:4,webpMinSize:!1,webpMixed:!1,gifBitdepth:8,gifEffort:7,gifDither:1,gifInterFrameMaxError:0,gifInterPaletteMaxError:3,gifKeepDuplicateFrames:!1,gifReuse:!0,gifProgressive:!1,tiffQuality:80,tiffCompression:"jpeg",tiffBigtiff:!1,tiffPredictor:"horizontal",tiffPyramid:!1,tiffMiniswhite:!1,tiffBitdepth:8,tiffTile:!1,tiffTileHeight:256,tiffTileWidth:256,tiffXres:1,tiffYres:1,tiffResolutionUnit:"inch",heifQuality:50,heifLossless:!1,heifCompression:"av1",heifEffort:4,heifChromaSubsampling:"4:4:4",heifBitdepth:8,jxlDistance:1,jxlDecodingTier:0,jxlEffort:7,jxlLossless:!1,rawDepth:"uchar",tileSize:256,tileOverlap:0,tileContainer:"fs",tileLayout:"dz",tileFormat:"last",tileDepth:"last",tileAngle:0,tileSkipBlanks:-1,tileBackground:[255,255,255,255],tileCentre:!1,tileId:"https://example.com/iiif",tileBasename:"",timeoutSeconds:0,linearA:[],linearB:[],pdfBackground:[255,255,255,255],debuglog:(Q)=>{this.emit("warning",Q),SJ(Q)},queueListener:TJ},this.options.input=this._createInputDescriptor($,Z,{allowStream:!0}),this};Object.setPrototypeOf(G4.prototype,d2.Duplex.prototype);Object.setPrototypeOf(G4,d2.Duplex);function kJ(){let $=this.constructor.call(),{debuglog:Z,queueListener:Q,...J}=this.options;if($.options=structuredClone(J),$.options.debuglog=Z,$.options.queueListener=Q,this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),$.options.input.buffer=this.options.input.buffer,$.emit("finish")});return $}Object.assign(G4.prototype,{clone:kJ});l$.exports=G4});var n$=T((WH,r$)=>{/*!
16
+ Copyright 2013 Lovell Fuller and others.
17
+ SPDX-License-Identifier: Apache-2.0
18
+ */var j=E0(),t0=K6(),xJ={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},vJ=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function a$($){let Z=vJ.filter((Q)=>j.defined($[Q])).map((Q)=>[Q,$[Q]]);return Z.length?Object.fromEntries(Z):void 0}function OJ($,Z,Q){let J={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(j.string($))J.file=$;else if(j.buffer($)){if($.length===0)throw Error("Input Buffer is empty");J.buffer=$}else if(j.arrayBuffer($)){if($.byteLength===0)throw Error("Input bit Array is empty");J.buffer=Buffer.from($,0,$.byteLength)}else if(j.typedArray($)){if($.length===0)throw Error("Input Bit Array is empty");J.buffer=Buffer.from($.buffer,$.byteOffset,$.byteLength)}else if(j.plainObject($)&&!j.defined(Z)){if(Z=$,a$(Z))J.buffer=[]}else if(!j.defined($)&&!j.defined(Z)&&j.object(Q)&&Q.allowStream)J.buffer=[];else if(Array.isArray($))if($.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=$.map((X)=>this._createInputDescriptor(X));else throw Error("Recursive join is unsupported");else throw Error("Expected at least two images to join");else throw Error(`Unsupported input '${$}' of type ${typeof $}${j.defined(Z)?` when also providing options of type ${typeof Z}`:""}`);if(j.object(Z)){if(j.defined(Z.failOnError))if(j.bool(Z.failOnError))J.failOn=Z.failOnError?"warning":"none";else throw j.invalidParameterError("failOnError","boolean",Z.failOnError);if(j.defined(Z.failOn))if(j.string(Z.failOn)&&j.inArray(Z.failOn,["none","truncated","error","warning"]))J.failOn=Z.failOn;else throw j.invalidParameterError("failOn","one of: none, truncated, error, warning",Z.failOn);if(j.defined(Z.autoOrient))if(j.bool(Z.autoOrient))J.autoOrient=Z.autoOrient;else throw j.invalidParameterError("autoOrient","boolean",Z.autoOrient);if(j.defined(Z.density))if(j.inRange(Z.density,1,1e5))J.density=Z.density;else throw j.invalidParameterError("density","number between 1 and 100000",Z.density);if(j.defined(Z.ignoreIcc))if(j.bool(Z.ignoreIcc))J.ignoreIcc=Z.ignoreIcc;else throw j.invalidParameterError("ignoreIcc","boolean",Z.ignoreIcc);if(j.defined(Z.limitInputPixels))if(j.bool(Z.limitInputPixels))J.limitInputPixels=Z.limitInputPixels?268402689:0;else if(j.integer(Z.limitInputPixels)&&j.inRange(Z.limitInputPixels,0,Number.MAX_SAFE_INTEGER))J.limitInputPixels=Z.limitInputPixels;else throw j.invalidParameterError("limitInputPixels","positive integer",Z.limitInputPixels);if(j.defined(Z.unlimited))if(j.bool(Z.unlimited))J.unlimited=Z.unlimited;else throw j.invalidParameterError("unlimited","boolean",Z.unlimited);if(j.defined(Z.sequentialRead))if(j.bool(Z.sequentialRead))J.sequentialRead=Z.sequentialRead;else throw j.invalidParameterError("sequentialRead","boolean",Z.sequentialRead);if(j.defined(Z.raw)){if(j.object(Z.raw)&&j.integer(Z.raw.width)&&Z.raw.width>0&&j.integer(Z.raw.height)&&Z.raw.height>0&&j.integer(Z.raw.channels)&&j.inRange(Z.raw.channels,1,4))switch(J.rawWidth=Z.raw.width,J.rawHeight=Z.raw.height,J.rawChannels=Z.raw.channels,$.constructor){case Uint8Array:case Uint8ClampedArray:J.rawDepth="uchar";break;case Int8Array:J.rawDepth="char";break;case Uint16Array:J.rawDepth="ushort";break;case Int16Array:J.rawDepth="short";break;case Uint32Array:J.rawDepth="uint";break;case Int32Array:J.rawDepth="int";break;case Float32Array:J.rawDepth="float";break;case Float64Array:J.rawDepth="double";break;default:J.rawDepth="uchar";break}else throw Error("Expected width, height and channels for raw pixel input");if(J.rawPremultiplied=!1,j.defined(Z.raw.premultiplied))if(j.bool(Z.raw.premultiplied))J.rawPremultiplied=Z.raw.premultiplied;else throw j.invalidParameterError("raw.premultiplied","boolean",Z.raw.premultiplied);if(J.rawPageHeight=0,j.defined(Z.raw.pageHeight))if(j.integer(Z.raw.pageHeight)&&Z.raw.pageHeight>0&&Z.raw.pageHeight<=Z.raw.height){if(Z.raw.height%Z.raw.pageHeight!==0)throw Error(`Expected raw.height ${Z.raw.height} to be a multiple of raw.pageHeight ${Z.raw.pageHeight}`);J.rawPageHeight=Z.raw.pageHeight}else throw j.invalidParameterError("raw.pageHeight","positive integer",Z.raw.pageHeight)}if(j.defined(Z.animated))if(j.bool(Z.animated))J.pages=Z.animated?-1:1;else throw j.invalidParameterError("animated","boolean",Z.animated);if(j.defined(Z.pages))if(j.integer(Z.pages)&&j.inRange(Z.pages,-1,1e5))J.pages=Z.pages;else throw j.invalidParameterError("pages","integer between -1 and 100000",Z.pages);if(j.defined(Z.page))if(j.integer(Z.page)&&j.inRange(Z.page,0,1e5))J.page=Z.page;else throw j.invalidParameterError("page","integer between 0 and 100000",Z.page);if(j.object(Z.openSlide)&&j.defined(Z.openSlide.level))if(j.integer(Z.openSlide.level)&&j.inRange(Z.openSlide.level,0,256))J.openSlideLevel=Z.openSlide.level;else throw j.invalidParameterError("openSlide.level","integer between 0 and 256",Z.openSlide.level);else if(j.defined(Z.level))if(j.integer(Z.level)&&j.inRange(Z.level,0,256))J.openSlideLevel=Z.level;else throw j.invalidParameterError("level","integer between 0 and 256",Z.level);if(j.object(Z.tiff)&&j.defined(Z.tiff.subifd))if(j.integer(Z.tiff.subifd)&&j.inRange(Z.tiff.subifd,-1,1e5))J.tiffSubifd=Z.tiff.subifd;else throw j.invalidParameterError("tiff.subifd","integer between -1 and 100000",Z.tiff.subifd);else if(j.defined(Z.subifd))if(j.integer(Z.subifd)&&j.inRange(Z.subifd,-1,1e5))J.tiffSubifd=Z.subifd;else throw j.invalidParameterError("subifd","integer between -1 and 100000",Z.subifd);if(j.object(Z.svg)){if(j.defined(Z.svg.stylesheet))if(j.string(Z.svg.stylesheet))J.svgStylesheet=Z.svg.stylesheet;else throw j.invalidParameterError("svg.stylesheet","string",Z.svg.stylesheet);if(j.defined(Z.svg.highBitdepth))if(j.bool(Z.svg.highBitdepth))J.svgHighBitdepth=Z.svg.highBitdepth;else throw j.invalidParameterError("svg.highBitdepth","boolean",Z.svg.highBitdepth)}if(j.object(Z.pdf)&&j.defined(Z.pdf.background))J.pdfBackground=this._getBackgroundColourOption(Z.pdf.background);else if(j.defined(Z.pdfBackground))J.pdfBackground=this._getBackgroundColourOption(Z.pdfBackground);if(j.object(Z.jp2)&&j.defined(Z.jp2.oneshot))if(j.bool(Z.jp2.oneshot))J.jp2Oneshot=Z.jp2.oneshot;else throw j.invalidParameterError("jp2.oneshot","boolean",Z.jp2.oneshot);if(j.defined(Z.create))if(j.object(Z.create)&&j.integer(Z.create.width)&&Z.create.width>0&&j.integer(Z.create.height)&&Z.create.height>0&&j.integer(Z.create.channels)){if(J.createWidth=Z.create.width,J.createHeight=Z.create.height,J.createChannels=Z.create.channels,J.createPageHeight=0,j.defined(Z.create.pageHeight))if(j.integer(Z.create.pageHeight)&&Z.create.pageHeight>0&&Z.create.pageHeight<=Z.create.height){if(Z.create.height%Z.create.pageHeight!==0)throw Error(`Expected create.height ${Z.create.height} to be a multiple of create.pageHeight ${Z.create.pageHeight}`);J.createPageHeight=Z.create.pageHeight}else throw j.invalidParameterError("create.pageHeight","positive integer",Z.create.pageHeight);if(j.defined(Z.create.noise)){if(!j.object(Z.create.noise))throw Error("Expected noise to be an object");if(Z.create.noise.type!=="gaussian")throw Error("Only gaussian noise is supported at the moment");if(J.createNoiseType=Z.create.noise.type,!j.inRange(Z.create.channels,1,4))throw j.invalidParameterError("create.channels","number between 1 and 4",Z.create.channels);if(J.createNoiseMean=128,j.defined(Z.create.noise.mean))if(j.number(Z.create.noise.mean)&&j.inRange(Z.create.noise.mean,0,1e4))J.createNoiseMean=Z.create.noise.mean;else throw j.invalidParameterError("create.noise.mean","number between 0 and 10000",Z.create.noise.mean);if(J.createNoiseSigma=30,j.defined(Z.create.noise.sigma))if(j.number(Z.create.noise.sigma)&&j.inRange(Z.create.noise.sigma,0,1e4))J.createNoiseSigma=Z.create.noise.sigma;else throw j.invalidParameterError("create.noise.sigma","number between 0 and 10000",Z.create.noise.sigma)}else if(j.defined(Z.create.background)){if(!j.inRange(Z.create.channels,3,4))throw j.invalidParameterError("create.channels","number between 3 and 4",Z.create.channels);J.createBackground=this._getBackgroundColourOption(Z.create.background)}else throw Error("Expected valid noise or background to create a new input image");delete J.buffer}else throw Error("Expected valid width, height and channels to create a new input image");if(j.defined(Z.text))if(j.object(Z.text)&&j.string(Z.text.text)){if(J.textValue=Z.text.text,j.defined(Z.text.height)&&j.defined(Z.text.dpi))throw Error("Expected only one of dpi or height");if(j.defined(Z.text.font))if(j.string(Z.text.font))J.textFont=Z.text.font;else throw j.invalidParameterError("text.font","string",Z.text.font);if(j.defined(Z.text.fontfile))if(j.string(Z.text.fontfile))J.textFontfile=Z.text.fontfile;else throw j.invalidParameterError("text.fontfile","string",Z.text.fontfile);if(j.defined(Z.text.width))if(j.integer(Z.text.width)&&Z.text.width>0)J.textWidth=Z.text.width;else throw j.invalidParameterError("text.width","positive integer",Z.text.width);if(j.defined(Z.text.height))if(j.integer(Z.text.height)&&Z.text.height>0)J.textHeight=Z.text.height;else throw j.invalidParameterError("text.height","positive integer",Z.text.height);if(j.defined(Z.text.align))if(j.string(Z.text.align)&&j.string(this.constructor.align[Z.text.align]))J.textAlign=this.constructor.align[Z.text.align];else throw j.invalidParameterError("text.align","valid alignment",Z.text.align);if(j.defined(Z.text.justify))if(j.bool(Z.text.justify))J.textJustify=Z.text.justify;else throw j.invalidParameterError("text.justify","boolean",Z.text.justify);if(j.defined(Z.text.dpi))if(j.integer(Z.text.dpi)&&j.inRange(Z.text.dpi,1,1e6))J.textDpi=Z.text.dpi;else throw j.invalidParameterError("text.dpi","integer between 1 and 1000000",Z.text.dpi);if(j.defined(Z.text.rgba))if(j.bool(Z.text.rgba))J.textRgba=Z.text.rgba;else throw j.invalidParameterError("text.rgba","bool",Z.text.rgba);if(j.defined(Z.text.spacing))if(j.integer(Z.text.spacing)&&j.inRange(Z.text.spacing,-1e6,1e6))J.textSpacing=Z.text.spacing;else throw j.invalidParameterError("text.spacing","integer between -1000000 and 1000000",Z.text.spacing);if(j.defined(Z.text.wrap))if(j.string(Z.text.wrap)&&j.inArray(Z.text.wrap,["word","char","word-char","none"]))J.textWrap=Z.text.wrap;else throw j.invalidParameterError("text.wrap","one of: word, char, word-char, none",Z.text.wrap);delete J.buffer}else throw Error("Expected a valid string to create an image with text.");if(j.defined(Z.join))if(j.defined(this.options.join)){if(j.defined(Z.join.animated))if(j.bool(Z.join.animated))J.joinAnimated=Z.join.animated;else throw j.invalidParameterError("join.animated","boolean",Z.join.animated);if(j.defined(Z.join.across))if(j.integer(Z.join.across)&&j.inRange(Z.join.across,1,1e6))J.joinAcross=Z.join.across;else throw j.invalidParameterError("join.across","integer between 1 and 100000",Z.join.across);if(j.defined(Z.join.shim))if(j.integer(Z.join.shim)&&j.inRange(Z.join.shim,0,1e6))J.joinShim=Z.join.shim;else throw j.invalidParameterError("join.shim","integer between 0 and 100000",Z.join.shim);if(j.defined(Z.join.background))J.joinBackground=this._getBackgroundColourOption(Z.join.background);if(j.defined(Z.join.halign))if(j.string(Z.join.halign)&&j.string(this.constructor.align[Z.join.halign]))J.joinHalign=this.constructor.align[Z.join.halign];else throw j.invalidParameterError("join.halign","valid alignment",Z.join.halign);if(j.defined(Z.join.valign))if(j.string(Z.join.valign)&&j.string(this.constructor.align[Z.join.valign]))J.joinValign=this.constructor.align[Z.join.valign];else throw j.invalidParameterError("join.valign","valid alignment",Z.join.valign)}else throw Error("Expected input to be an array of images to join")}else if(j.defined(Z))throw Error(`Invalid input options ${Z}`);return J}function yJ($,Z,Q){if(Array.isArray(this.options.input.buffer))if(j.buffer($)){if(this.options.input.buffer.length===0)this.on("finish",()=>{this.streamInFinished=!0});this.options.input.buffer.push($),Q()}else Q(Error("Non-Buffer data on Writable Stream"));else Q(Error("Unexpected data on Writable Stream"))}function bJ(){if(this._isStreamInput())this.options.input.buffer=Buffer.concat(this.options.input.buffer)}function fJ(){return Array.isArray(this.options.input.buffer)}function hJ($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t0.metadata(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)})});else t0.metadata(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{let X=()=>{this._flattenBufferIn(),t0.metadata(this.options,(V,K)=>{if(V)J(j.nativeError(V,Z));else Q(K)})};if(this.writableFinished)X();else this.once("finish",X)});else return new Promise((Q,J)=>{t0.metadata(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})}function gJ($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t0.stats(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)})});else t0.stats(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{this.on("finish",function(){this._flattenBufferIn(),t0.stats(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})});else return new Promise((Q,J)=>{t0.stats(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})}r$.exports=($)=>{Object.assign($.prototype,{_inputOptionsFromObject:a$,_createInputDescriptor:OJ,_write:yJ,_flattenBufferIn:bJ,_isStreamInput:fJ,metadata:hJ,stats:gJ}),$.align=xJ}});var $9=T((HH,t$)=>{/*!
19
+ Copyright 2013 Lovell Fuller and others.
20
+ SPDX-License-Identifier: Apache-2.0
21
+ */var F=E0(),s$={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},o$={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},i$={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},e$={entropy:16,attention:17},u2={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},dJ={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},uJ={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function m2($){return $.angle%360!==0||$.rotationAngle!==0}function p6($){return $.width!==-1||$.height!==-1}function mJ($,Z,Q){if(p6(this.options))this.options.debuglog("ignoring previous resize options");if(this.options.widthPost!==-1)this.options.debuglog("operation order will be: extract, resize, extract");if(F.defined($))if(F.object($)&&!F.defined(Q))Q=$;else if(F.integer($)&&$>0)this.options.width=$;else throw F.invalidParameterError("width","positive integer",$);else this.options.width=-1;if(F.defined(Z))if(F.integer(Z)&&Z>0)this.options.height=Z;else throw F.invalidParameterError("height","positive integer",Z);else this.options.height=-1;if(F.object(Q)){if(F.defined(Q.width))if(F.integer(Q.width)&&Q.width>0)this.options.width=Q.width;else throw F.invalidParameterError("width","positive integer",Q.width);if(F.defined(Q.height))if(F.integer(Q.height)&&Q.height>0)this.options.height=Q.height;else throw F.invalidParameterError("height","positive integer",Q.height);if(F.defined(Q.fit)){let J=uJ[Q.fit];if(F.string(J))this.options.canvas=J;else throw F.invalidParameterError("fit","valid fit",Q.fit)}if(F.defined(Q.position)){let J=F.integer(Q.position)?Q.position:e$[Q.position]||o$[Q.position]||s$[Q.position];if(F.integer(J)&&(F.inRange(J,0,8)||F.inRange(J,16,17)))this.options.position=J;else throw F.invalidParameterError("position","valid position/gravity/strategy",Q.position)}if(this._setBackgroundColourOption("resizeBackground",Q.background),F.defined(Q.kernel))if(F.string(u2[Q.kernel]))this.options.kernel=u2[Q.kernel];else throw F.invalidParameterError("kernel","valid kernel name",Q.kernel);if(F.defined(Q.withoutEnlargement))this._setBooleanOption("withoutEnlargement",Q.withoutEnlargement);if(F.defined(Q.withoutReduction))this._setBooleanOption("withoutReduction",Q.withoutReduction);if(F.defined(Q.fastShrinkOnLoad))this._setBooleanOption("fastShrinkOnLoad",Q.fastShrinkOnLoad)}if(m2(this.options)&&p6(this.options))this.options.rotateBefore=!0;return this}function cJ($){if(F.integer($)&&$>0)this.options.extendTop=$,this.options.extendBottom=$,this.options.extendLeft=$,this.options.extendRight=$;else if(F.object($)){if(F.defined($.top))if(F.integer($.top)&&$.top>=0)this.options.extendTop=$.top;else throw F.invalidParameterError("top","positive integer",$.top);if(F.defined($.bottom))if(F.integer($.bottom)&&$.bottom>=0)this.options.extendBottom=$.bottom;else throw F.invalidParameterError("bottom","positive integer",$.bottom);if(F.defined($.left))if(F.integer($.left)&&$.left>=0)this.options.extendLeft=$.left;else throw F.invalidParameterError("left","positive integer",$.left);if(F.defined($.right))if(F.integer($.right)&&$.right>=0)this.options.extendRight=$.right;else throw F.invalidParameterError("right","positive integer",$.right);if(this._setBackgroundColourOption("extendBackground",$.background),F.defined($.extendWith))if(F.string(i$[$.extendWith]))this.options.extendWith=i$[$.extendWith];else throw F.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",$.extendWith)}else throw F.invalidParameterError("extend","integer or object",$);return this}function lJ($){let Z=p6(this.options)||this.options.widthPre!==-1?"Post":"Pre";if(this.options[`width${Z}`]!==-1)this.options.debuglog("ignoring previous extract options");if(["left","top","width","height"].forEach(function(Q){let J=$[Q];if(F.integer(J)&&J>=0)this.options[Q+(Q==="left"||Q==="top"?"Offset":"")+Z]=J;else throw F.invalidParameterError(Q,"integer",J)},this),m2(this.options)&&!p6(this.options)){if(this.options.widthPre===-1||this.options.widthPost===-1)this.options.rotateBefore=!0}if(this.options.input.autoOrient)this.options.orientBefore=!0;return this}function pJ($){if(this.options.trimThreshold=10,F.defined($))if(F.object($)){if(F.defined($.background))this._setBackgroundColourOption("trimBackground",$.background);if(F.defined($.threshold))if(F.number($.threshold)&&$.threshold>=0)this.options.trimThreshold=$.threshold;else throw F.invalidParameterError("threshold","positive number",$.threshold);if(F.defined($.lineArt))this._setBooleanOption("trimLineArt",$.lineArt)}else throw F.invalidParameterError("trim","object",$);if(m2(this.options))this.options.rotateBefore=!0;return this}t$.exports=($)=>{Object.assign($.prototype,{resize:mJ,extend:cJ,extract:lJ,trim:pJ}),$.gravity=s$,$.strategy=e$,$.kernel=u2,$.fit=dJ,$.position=o$}});var Q9=T((qH,Z9)=>{/*!
22
+ Copyright 2013 Lovell Fuller and others.
23
+ SPDX-License-Identifier: Apache-2.0
24
+ */var f=E0(),c2={clear:"clear",source:"source",over:"over",in:"in",out:"out",atop:"atop",dest:"dest","dest-over":"dest-over","dest-in":"dest-in","dest-out":"dest-out","dest-atop":"dest-atop",xor:"xor",add:"add",saturate:"saturate",multiply:"multiply",screen:"screen",overlay:"overlay",darken:"darken",lighten:"lighten","colour-dodge":"colour-dodge","color-dodge":"colour-dodge","colour-burn":"colour-burn","color-burn":"colour-burn","hard-light":"hard-light","soft-light":"soft-light",difference:"difference",exclusion:"exclusion"};function aJ($){if(!Array.isArray($))throw f.invalidParameterError("images to composite","array",$);return this.options.composite=$.map((Z)=>{if(!f.object(Z))throw f.invalidParameterError("image to composite","object",Z);let Q=this._inputOptionsFromObject(Z),J={input:this._createInputDescriptor(Z.input,Q,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(f.defined(Z.blend))if(f.string(c2[Z.blend]))J.blend=c2[Z.blend];else throw f.invalidParameterError("blend","valid blend name",Z.blend);if(f.defined(Z.tile))if(f.bool(Z.tile))J.tile=Z.tile;else throw f.invalidParameterError("tile","boolean",Z.tile);if(f.defined(Z.left))if(f.integer(Z.left))J.left=Z.left;else throw f.invalidParameterError("left","integer",Z.left);if(f.defined(Z.top))if(f.integer(Z.top))J.top=Z.top;else throw f.invalidParameterError("top","integer",Z.top);if(f.defined(Z.top)!==f.defined(Z.left))throw Error("Expected both left and top to be set");else J.hasOffset=f.integer(Z.top)&&f.integer(Z.left);if(f.defined(Z.gravity))if(f.integer(Z.gravity)&&f.inRange(Z.gravity,0,8))J.gravity=Z.gravity;else if(f.string(Z.gravity)&&f.integer(this.constructor.gravity[Z.gravity]))J.gravity=this.constructor.gravity[Z.gravity];else throw f.invalidParameterError("gravity","valid gravity",Z.gravity);if(f.defined(Z.premultiplied))if(f.bool(Z.premultiplied))J.premultiplied=Z.premultiplied;else throw f.invalidParameterError("premultiplied","boolean",Z.premultiplied);return J}),this}Z9.exports=($)=>{$.prototype.composite=aJ,$.blend=c2}});var W9=T((YH,K9)=>{/*!
25
+ Copyright 2013 Lovell Fuller and others.
26
+ SPDX-License-Identifier: Apache-2.0
27
+ */var U=E0(),J9={integer:"integer",float:"float",approximate:"approximate"};function rJ($,Z){if(!U.defined($))return this.autoOrient();if(this.options.angle||this.options.rotationAngle)this.options.debuglog("ignoring previous rotate options"),this.options.angle=0,this.options.rotationAngle=0;if(U.integer($)&&!($%90))this.options.angle=$;else if(U.number($)){if(this.options.rotationAngle=$,U.object(Z)&&Z.background)this._setBackgroundColourOption("rotationBackground",Z.background)}else throw U.invalidParameterError("angle","numeric",$);return this}function nJ(){return this.options.input.autoOrient=!0,this}function iJ($){return this.options.flip=U.bool($)?$:!0,this}function sJ($){return this.options.flop=U.bool($)?$:!0,this}function oJ($,Z){let Q=[].concat(...$);if(Q.length===4&&Q.every(U.number))this.options.affineMatrix=Q;else throw U.invalidParameterError("matrix","1x4 or 2x2 array",$);if(U.defined(Z))if(U.object(Z)){if(this._setBackgroundColourOption("affineBackground",Z.background),U.defined(Z.idx))if(U.number(Z.idx))this.options.affineIdx=Z.idx;else throw U.invalidParameterError("options.idx","number",Z.idx);if(U.defined(Z.idy))if(U.number(Z.idy))this.options.affineIdy=Z.idy;else throw U.invalidParameterError("options.idy","number",Z.idy);if(U.defined(Z.odx))if(U.number(Z.odx))this.options.affineOdx=Z.odx;else throw U.invalidParameterError("options.odx","number",Z.odx);if(U.defined(Z.ody))if(U.number(Z.ody))this.options.affineOdy=Z.ody;else throw U.invalidParameterError("options.ody","number",Z.ody);if(U.defined(Z.interpolator))if(U.inArray(Z.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=Z.interpolator;else throw U.invalidParameterError("options.interpolator","valid interpolator name",Z.interpolator)}else throw U.invalidParameterError("options","object",Z);return this}function eJ($,Z,Q){if(!U.defined($))this.options.sharpenSigma=-1;else if(U.bool($))this.options.sharpenSigma=$?-1:0;else if(U.number($)&&U.inRange($,0.01,1e4)){if(this.options.sharpenSigma=$,U.defined(Z))if(U.number(Z)&&U.inRange(Z,0,1e4))this.options.sharpenM1=Z;else throw U.invalidParameterError("flat","number between 0 and 10000",Z);if(U.defined(Q))if(U.number(Q)&&U.inRange(Q,0,1e4))this.options.sharpenM2=Q;else throw U.invalidParameterError("jagged","number between 0 and 10000",Q)}else if(U.plainObject($)){if(U.number($.sigma)&&U.inRange($.sigma,0.000001,10))this.options.sharpenSigma=$.sigma;else throw U.invalidParameterError("options.sigma","number between 0.000001 and 10",$.sigma);if(U.defined($.m1))if(U.number($.m1)&&U.inRange($.m1,0,1e6))this.options.sharpenM1=$.m1;else throw U.invalidParameterError("options.m1","number between 0 and 1000000",$.m1);if(U.defined($.m2))if(U.number($.m2)&&U.inRange($.m2,0,1e6))this.options.sharpenM2=$.m2;else throw U.invalidParameterError("options.m2","number between 0 and 1000000",$.m2);if(U.defined($.x1))if(U.number($.x1)&&U.inRange($.x1,0,1e6))this.options.sharpenX1=$.x1;else throw U.invalidParameterError("options.x1","number between 0 and 1000000",$.x1);if(U.defined($.y2))if(U.number($.y2)&&U.inRange($.y2,0,1e6))this.options.sharpenY2=$.y2;else throw U.invalidParameterError("options.y2","number between 0 and 1000000",$.y2);if(U.defined($.y3))if(U.number($.y3)&&U.inRange($.y3,0,1e6))this.options.sharpenY3=$.y3;else throw U.invalidParameterError("options.y3","number between 0 and 1000000",$.y3)}else throw U.invalidParameterError("sigma","number between 0.01 and 10000",$);return this}function tJ($){if(!U.defined($))this.options.medianSize=3;else if(U.integer($)&&U.inRange($,1,1000))this.options.medianSize=$;else throw U.invalidParameterError("size","integer between 1 and 1000",$);return this}function $3($){let Z;if(U.number($))Z=$;else if(U.plainObject($)){if(!U.number($.sigma))throw U.invalidParameterError("options.sigma","number between 0.3 and 1000",Z);if(Z=$.sigma,"precision"in $)if(U.string(J9[$.precision]))this.options.precision=J9[$.precision];else throw U.invalidParameterError("precision","one of: integer, float, approximate",$.precision);if("minAmplitude"in $)if(U.number($.minAmplitude)&&U.inRange($.minAmplitude,0.001,1))this.options.minAmpl=$.minAmplitude;else throw U.invalidParameterError("minAmplitude","number between 0.001 and 1",$.minAmplitude)}if(!U.defined($))this.options.blurSigma=-1;else if(U.bool($))this.options.blurSigma=$?-1:0;else if(U.number(Z)&&U.inRange(Z,0.3,1000))this.options.blurSigma=Z;else throw U.invalidParameterError("sigma","number between 0.3 and 1000",Z);return this}function X9($){if(!U.defined($))this.options.dilateWidth=1;else if(U.integer($)&&$>0)this.options.dilateWidth=$;else throw U.invalidParameterError("dilate","positive integer",X9);return this}function V9($){if(!U.defined($))this.options.erodeWidth=1;else if(U.integer($)&&$>0)this.options.erodeWidth=$;else throw U.invalidParameterError("erode","positive integer",V9);return this}function Z3($){if(this.options.flatten=U.bool($)?$:!0,U.object($))this._setBackgroundColourOption("flattenBackground",$.background);return this}function Q3(){return this.options.unflatten=!0,this}function J3($,Z){if(!U.defined($))this.options.gamma=2.2;else if(U.number($)&&U.inRange($,1,3))this.options.gamma=$;else throw U.invalidParameterError("gamma","number between 1.0 and 3.0",$);if(!U.defined(Z))this.options.gammaOut=this.options.gamma;else if(U.number(Z)&&U.inRange(Z,1,3))this.options.gammaOut=Z;else throw U.invalidParameterError("gammaOut","number between 1.0 and 3.0",Z);return this}function X3($){if(this.options.negate=U.bool($)?$:!0,U.plainObject($)&&"alpha"in $)if(!U.bool($.alpha))throw U.invalidParameterError("alpha","should be boolean value",$.alpha);else this.options.negateAlpha=$.alpha;return this}function V3($){if(U.plainObject($)){if(U.defined($.lower))if(U.number($.lower)&&U.inRange($.lower,0,99))this.options.normaliseLower=$.lower;else throw U.invalidParameterError("lower","number between 0 and 99",$.lower);if(U.defined($.upper))if(U.number($.upper)&&U.inRange($.upper,1,100))this.options.normaliseUpper=$.upper;else throw U.invalidParameterError("upper","number between 1 and 100",$.upper)}if(this.options.normaliseLower>=this.options.normaliseUpper)throw U.invalidParameterError("range","lower to be less than upper",`${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);return this.options.normalise=!0,this}function K3($){return this.normalise($)}function W3($){if(U.plainObject($)){if(U.integer($.width)&&$.width>0)this.options.claheWidth=$.width;else throw U.invalidParameterError("width","integer greater than zero",$.width);if(U.integer($.height)&&$.height>0)this.options.claheHeight=$.height;else throw U.invalidParameterError("height","integer greater than zero",$.height);if(U.defined($.maxSlope))if(U.integer($.maxSlope)&&U.inRange($.maxSlope,0,100))this.options.claheMaxSlope=$.maxSlope;else throw U.invalidParameterError("maxSlope","integer between 0 and 100",$.maxSlope)}else throw U.invalidParameterError("options","plain object",$);return this}function H3($){if(!U.object($)||!Array.isArray($.kernel)||!U.integer($.width)||!U.integer($.height)||!U.inRange($.width,3,1001)||!U.inRange($.height,3,1001)||$.height*$.width!==$.kernel.length)throw Error("Invalid convolution kernel");if(!U.integer($.scale))$.scale=$.kernel.reduce((Z,Q)=>Z+Q,0);if($.scale<1)$.scale=1;if(!U.integer($.offset))$.offset=0;return this.options.convKernel=$,this}function q3($,Z){if(!U.defined($))this.options.threshold=128;else if(U.bool($))this.options.threshold=$?128:0;else if(U.integer($)&&U.inRange($,0,255))this.options.threshold=$;else throw U.invalidParameterError("threshold","integer between 0 and 255",$);if(!U.object(Z)||Z.greyscale===!0||Z.grayscale===!0)this.options.thresholdGrayscale=!0;else this.options.thresholdGrayscale=!1;return this}function Y3($,Z,Q){if(this.options.boolean=this._createInputDescriptor($,Q),U.string(Z)&&U.inArray(Z,["and","or","eor"]))this.options.booleanOp=Z;else throw U.invalidParameterError("operator","one of: and, or, eor",Z);return this}function z3($,Z){if(!U.defined($)&&U.number(Z))$=1;else if(U.number($)&&!U.defined(Z))Z=0;if(!U.defined($))this.options.linearA=[];else if(U.number($))this.options.linearA=[$];else if(Array.isArray($)&&$.length&&$.every(U.number))this.options.linearA=$;else throw U.invalidParameterError("a","number or array of numbers",$);if(!U.defined(Z))this.options.linearB=[];else if(U.number(Z))this.options.linearB=[Z];else if(Array.isArray(Z)&&Z.length&&Z.every(U.number))this.options.linearB=Z;else throw U.invalidParameterError("b","number or array of numbers",Z);if(this.options.linearA.length!==this.options.linearB.length)throw Error("Expected a and b to be arrays of the same length");return this}function G3($){if(!Array.isArray($))throw U.invalidParameterError("inputMatrix","array",$);if($.length!==3&&$.length!==4)throw U.invalidParameterError("inputMatrix","3x3 or 4x4 array",$.length);let Z=$.flat().map(Number);if(Z.length!==9&&Z.length!==16)throw U.invalidParameterError("inputMatrix","cardinality of 9 or 16",Z.length);return this.options.recombMatrix=Z,this}function j3($){if(!U.plainObject($))throw U.invalidParameterError("options","plain object",$);if("brightness"in $)if(U.number($.brightness)&&$.brightness>=0)this.options.brightness=$.brightness;else throw U.invalidParameterError("brightness","number above zero",$.brightness);if("saturation"in $)if(U.number($.saturation)&&$.saturation>=0)this.options.saturation=$.saturation;else throw U.invalidParameterError("saturation","number above zero",$.saturation);if("hue"in $)if(U.integer($.hue))this.options.hue=$.hue%360;else throw U.invalidParameterError("hue","number",$.hue);if("lightness"in $)if(U.number($.lightness))this.options.lightness=$.lightness;else throw U.invalidParameterError("lightness","number",$.lightness);return this}K9.exports=($)=>{Object.assign($.prototype,{autoOrient:nJ,rotate:rJ,flip:iJ,flop:sJ,affine:oJ,sharpen:eJ,erode:V9,dilate:X9,median:tJ,blur:$3,flatten:Z3,unflatten:Q3,gamma:J3,negate:X3,normalise:V3,normalize:K3,clahe:W3,convolve:H3,threshold:q3,boolean:Y3,linear:z3,recomb:G3,modulate:j3})}});var j9=T((zH,G9)=>{var{defineProperty:r2,getOwnPropertyDescriptor:U3,getOwnPropertyNames:A3}=Object,B3=Object.prototype.hasOwnProperty,L3=($,Z)=>{for(var Q in Z)r2($,Q,{get:Z[Q],enumerable:!0})},_3=($,Z,Q,J)=>{if(Z&&typeof Z==="object"||typeof Z==="function"){for(let X of A3(Z))if(!B3.call($,X)&&X!==Q)r2($,X,{get:()=>Z[X],enumerable:!(J=U3(Z,X))||J.enumerable})}return $},w3=($)=>_3(r2({},"__esModule",{value:!0}),$),H9={};L3(H9,{default:()=>v3});G9.exports=w3(H9);var v0={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},q9=Object.create(null);for(let $ in v0)if(Object.hasOwn(v0,$))q9[v0[$]]=$;var q0={to:{},get:{}};q0.get=function($){let Z=$.slice(0,3).toLowerCase(),Q,J;switch(Z){case"hsl":{Q=q0.get.hsl($),J="hsl";break}case"hwb":{Q=q0.get.hwb($),J="hwb";break}default:{Q=q0.get.rgb($),J="rgb";break}}if(!Q)return null;return{model:J,value:Q}};q0.get.rgb=function($){if(!$)return null;let Z=/^#([a-f\d]{3,4})$/i,Q=/^#([a-f\d]{6})([a-f\d]{2})?$/i,J=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,X=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,V=/^(\w+)$/,K=[0,0,0,1],W,H,q;if(W=$.match(Q)){q=W[2],W=W[1];for(H=0;H<3;H++){let z=H*2;K[H]=Number.parseInt(W.slice(z,z+2),16)}if(q)K[3]=Number.parseInt(q,16)/255}else if(W=$.match(Z)){W=W[1],q=W[3];for(H=0;H<3;H++)K[H]=Number.parseInt(W[H]+W[H],16);if(q)K[3]=Number.parseInt(q+q,16)/255}else if(W=$.match(J)){for(H=0;H<3;H++)K[H]=Number.parseInt(W[H+1],10);if(W[4])K[3]=W[5]?Number.parseFloat(W[4])*0.01:Number.parseFloat(W[4])}else if(W=$.match(X)){for(H=0;H<3;H++)K[H]=Math.round(Number.parseFloat(W[H+1])*2.55);if(W[4])K[3]=W[5]?Number.parseFloat(W[4])*0.01:Number.parseFloat(W[4])}else if(W=$.match(V)){if(W[1]==="transparent")return[0,0,0,0];if(!Object.hasOwn(v0,W[1]))return null;return K=v0[W[1]],K[3]=1,K}else return null;for(H=0;H<3;H++)K[H]=$4(K[H],0,255);return K[3]=$4(K[3],0,1),K};q0.get.hsl=function($){if(!$)return null;let Z=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,Q=$.match(Z);if(Q){let J=Number.parseFloat(Q[4]),X=(Number.parseFloat(Q[1])%360+360)%360,V=$4(Number.parseFloat(Q[2]),0,100),K=$4(Number.parseFloat(Q[3]),0,100),W=$4(Number.isNaN(J)?1:J,0,1);return[X,V,K,W]}return null};q0.get.hwb=function($){if(!$)return null;let Z=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,Q=$.match(Z);if(Q){let J=Number.parseFloat(Q[4]),X=(Number.parseFloat(Q[1])%360+360)%360,V=$4(Number.parseFloat(Q[2]),0,100),K=$4(Number.parseFloat(Q[3]),0,100),W=$4(Number.isNaN(J)?1:J,0,1);return[X,V,K,W]}return null};q0.to.hex=function(...$){return"#"+a6($[0])+a6($[1])+a6($[2])+($[3]<1?a6(Math.round($[3]*255)):"")};q0.to.rgb=function(...$){return $.length<4||$[3]===1?"rgb("+Math.round($[0])+", "+Math.round($[1])+", "+Math.round($[2])+")":"rgba("+Math.round($[0])+", "+Math.round($[1])+", "+Math.round($[2])+", "+$[3]+")"};q0.to.rgb.percent=function(...$){let Z=Math.round($[0]/255*100),Q=Math.round($[1]/255*100),J=Math.round($[2]/255*100);return $.length<4||$[3]===1?"rgb("+Z+"%, "+Q+"%, "+J+"%)":"rgba("+Z+"%, "+Q+"%, "+J+"%, "+$[3]+")"};q0.to.hsl=function(...$){return $.length<4||$[3]===1?"hsl("+$[0]+", "+$[1]+"%, "+$[2]+"%)":"hsla("+$[0]+", "+$[1]+"%, "+$[2]+"%, "+$[3]+")"};q0.to.hwb=function(...$){let Z="";if($.length>=4&&$[3]!==1)Z=", "+$[3];return"hwb("+$[0]+", "+$[1]+"%, "+$[2]+"%"+Z+")"};q0.to.keyword=function(...$){return q9[$.slice(0,3)]};function $4($,Z,Q){return Math.min(Math.max(Z,$),Q)}function a6($){let Z=Math.round($).toString(16).toUpperCase();return Z.length<2?"0"+Z:Z}var M4=q0,Y9={};for(let $ of Object.keys(v0))Y9[v0[$]]=$;var C={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},j4=C,c0=0.008856451679035631;function E4($){let Z=$>0.0031308?1.055*$**0.4166666666666667-0.055:$*12.92;return Math.min(Math.max(0,Z),1)}function S4($){return $>0.04045?(($+0.055)/1.055)**2.4:$/12.92}for(let $ of Object.keys(C)){if(!("channels"in C[$]))throw Error("missing channels property: "+$);if(!("labels"in C[$]))throw Error("missing channel labels property: "+$);if(C[$].labels.length!==C[$].channels)throw Error("channel and label counts mismatch: "+$);let{channels:Z,labels:Q}=C[$];delete C[$].channels,delete C[$].labels,Object.defineProperty(C[$],"channels",{value:Z}),Object.defineProperty(C[$],"labels",{value:Q})}C.rgb.hsl=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.min(Z,Q,J),V=Math.max(Z,Q,J),K=V-X,W,H;switch(V){case X:{W=0;break}case Z:{W=(Q-J)/K;break}case Q:{W=2+(J-Z)/K;break}case J:{W=4+(Z-Q)/K;break}}if(W=Math.min(W*60,360),W<0)W+=360;let q=(X+V)/2;if(V===X)H=0;else if(q<=0.5)H=K/(V+X);else H=K/(2-V-X);return[W,H*100,q*100]};C.rgb.hsv=function($){let Z,Q,J,X,V,K=$[0]/255,W=$[1]/255,H=$[2]/255,q=Math.max(K,W,H),z=q-Math.min(K,W,H),G=function(A){return(q-A)/6/z+0.5};if(z===0)X=0,V=0;else{switch(V=z/q,Z=G(K),Q=G(W),J=G(H),q){case K:{X=J-Q;break}case W:{X=0.3333333333333333+Z-J;break}case H:{X=0.6666666666666666+Q-Z;break}}if(X<0)X+=1;else if(X>1)X-=1}return[X*360,V*100,q*100]};C.rgb.hwb=function($){let Z=$[0],Q=$[1],J=$[2],X=C.rgb.hsl($)[0],V=0.00392156862745098*Math.min(Z,Math.min(Q,J));return J=1-0.00392156862745098*Math.max(Z,Math.max(Q,J)),[X,V*100,J*100]};C.rgb.oklab=function($){let Z=S4($[0]/255),Q=S4($[1]/255),J=S4($[2]/255),X=Math.cbrt(0.4122214708*Z+0.5363325363*Q+0.0514459929*J),V=Math.cbrt(0.2119034982*Z+0.6806995451*Q+0.1073969566*J),K=Math.cbrt(0.0883024619*Z+0.2817188376*Q+0.6299787005*J),W=0.2104542553*X+0.793617785*V-0.0040720468*K,H=1.9779984951*X-2.428592205*V+0.4505937099*K,q=0.0259040371*X+0.7827717662*V-0.808675766*K;return[W*100,H*100,q*100]};C.rgb.cmyk=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.min(1-Z,1-Q,1-J),V=(1-Z-X)/(1-X)||0,K=(1-Q-X)/(1-X)||0,W=(1-J-X)/(1-X)||0;return[V*100,K*100,W*100,X*100]};function R3($,Z){return($[0]-Z[0])**2+($[1]-Z[1])**2+($[2]-Z[2])**2}C.rgb.keyword=function($){let Z=Y9[$];if(Z)return Z;let Q=Number.POSITIVE_INFINITY,J;for(let X of Object.keys(v0)){let V=v0[X],K=R3($,V);if(K<Q)Q=K,J=X}return J};C.keyword.rgb=function($){return v0[$]};C.rgb.xyz=function($){let Z=S4($[0]/255),Q=S4($[1]/255),J=S4($[2]/255),X=Z*0.4124564+Q*0.3575761+J*0.1804375,V=Z*0.2126729+Q*0.7151522+J*0.072175,K=Z*0.0193339+Q*0.119192+J*0.9503041;return[X*100,V*100,K*100]};C.rgb.lab=function($){let Z=C.rgb.xyz($),Q=Z[0],J=Z[1],X=Z[2];Q/=95.047,J/=100,X/=108.883,Q=Q>c0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,J=J>c0?J**0.3333333333333333:7.787*J+0.13793103448275862,X=X>c0?X**0.3333333333333333:7.787*X+0.13793103448275862;let V=116*J-16,K=500*(Q-J),W=200*(J-X);return[V,K,W]};C.hsl.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100,X,V;if(Q===0)return V=J*255,[V,V,V];let K=J<0.5?J*(1+Q):J+Q-J*Q,W=2*J-K,H=[0,0,0];for(let q=0;q<3;q++){if(X=Z+0.3333333333333333*-(q-1),X<0)X++;if(X>1)X--;if(6*X<1)V=W+(K-W)*6*X;else if(2*X<1)V=K;else if(3*X<2)V=W+(K-W)*(0.6666666666666666-X)*6;else V=W;H[q]=V*255}return H};C.hsl.hsv=function($){let Z=$[0],Q=$[1]/100,J=$[2]/100,X=Q,V=Math.max(J,0.01);J*=2,Q*=J<=1?J:2-J,X*=V<=1?V:2-V;let K=(J+Q)/2,W=J===0?2*X/(V+X):2*Q/(J+Q);return[Z,W*100,K*100]};C.hsv.rgb=function($){let Z=$[0]/60,Q=$[1]/100,J=$[2]/100,X=Math.floor(Z)%6,V=Z-Math.floor(Z),K=255*J*(1-Q),W=255*J*(1-Q*V),H=255*J*(1-Q*(1-V));switch(J*=255,X){case 0:return[J,H,K];case 1:return[W,J,K];case 2:return[K,J,H];case 3:return[K,W,J];case 4:return[H,K,J];case 5:return[J,K,W]}};C.hsv.hsl=function($){let Z=$[0],Q=$[1]/100,J=$[2]/100,X=Math.max(J,0.01),V,K;K=(2-Q)*J;let W=(2-Q)*X;return V=Q*X,V/=W<=1?W:2-W,V=V||0,K/=2,[Z,V*100,K*100]};C.hwb.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100,X=Q+J,V;if(X>1)Q/=X,J/=X;let K=Math.floor(6*Z),W=1-J;if(V=6*Z-K,(K&1)!==0)V=1-V;let H=Q+V*(W-Q),q,z,G;switch(K){default:case 6:case 0:{q=W,z=H,G=Q;break}case 1:{q=H,z=W,G=Q;break}case 2:{q=Q,z=W,G=H;break}case 3:{q=Q,z=H,G=W;break}case 4:{q=H,z=Q,G=W;break}case 5:{q=W,z=Q,G=H;break}}return[q*255,z*255,G*255]};C.cmyk.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=$[3]/100,V=1-Math.min(1,Z*(1-X)+X),K=1-Math.min(1,Q*(1-X)+X),W=1-Math.min(1,J*(1-X)+X);return[V*255,K*255,W*255]};C.xyz.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X,V,K;return X=Z*3.2404542+Q*-1.5371385+J*-0.4985314,V=Z*-0.969266+Q*1.8760108+J*0.041556,K=Z*0.0556434+Q*-0.2040259+J*1.0572252,X=E4(X),V=E4(V),K=E4(K),[X*255,V*255,K*255]};C.xyz.lab=function($){let Z=$[0],Q=$[1],J=$[2];Z/=95.047,Q/=100,J/=108.883,Z=Z>c0?Z**0.3333333333333333:7.787*Z+0.13793103448275862,Q=Q>c0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,J=J>c0?J**0.3333333333333333:7.787*J+0.13793103448275862;let X=116*Q-16,V=500*(Z-Q),K=200*(Q-J);return[X,V,K]};C.xyz.oklab=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=Math.cbrt(0.8189330101*Z+0.3618667424*Q-0.1288597137*J),V=Math.cbrt(0.0329845436*Z+0.9293118715*Q+0.0361456387*J),K=Math.cbrt(0.0482003018*Z+0.2643662691*Q+0.633851707*J),W=0.2104542553*X+0.793617785*V-0.0040720468*K,H=1.9779984951*X-2.428592205*V+0.4505937099*K,q=0.0259040371*X+0.7827717662*V-0.808675766*K;return[W*100,H*100,q*100]};C.oklab.oklch=function($){return C.lab.lch($)};C.oklab.xyz=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=(0.999999998*Z+0.396337792*Q+0.215803758*J)**3,V=(1.000000008*Z-0.105561342*Q-0.063854175*J)**3,K=(1.000000055*Z-0.089484182*Q-1.291485538*J)**3,W=1.227013851*X-0.55779998*V+0.281256149*K,H=-0.040580178*X+1.11225687*V-0.071676679*K,q=-0.076381285*X-0.421481978*V+1.58616322*K;return[W*100,H*100,q*100]};C.oklab.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=(Z+0.3963377774*Q+0.2158037573*J)**3,V=(Z-0.1055613458*Q-0.0638541728*J)**3,K=(Z-0.0894841775*Q-1.291485548*J)**3,W=E4(4.0767416621*X-3.3077115913*V+0.2309699292*K),H=E4(-1.2684380046*X+2.6097574011*V-0.3413193965*K),q=E4(-0.0041960863*X-0.7034186147*V+1.707614701*K);return[W*255,H*255,q*255]};C.oklch.oklab=function($){return C.lch.lab($)};C.lab.xyz=function($){let Z=$[0],Q=$[1],J=$[2],X,V,K;V=(Z+16)/116,X=Q/500+V,K=V-J/200;let W=V**3,H=X**3,q=K**3;return V=W>c0?W:(V-0.13793103448275862)/7.787,X=H>c0?H:(X-0.13793103448275862)/7.787,K=q>c0?q:(K-0.13793103448275862)/7.787,X*=95.047,V*=100,K*=108.883,[X,V,K]};C.lab.lch=function($){let Z=$[0],Q=$[1],J=$[2],X;if(X=Math.atan2(J,Q)*360/2/Math.PI,X<0)X+=360;let K=Math.sqrt(Q*Q+J*J);return[Z,K,X]};C.lch.lab=function($){let Z=$[0],Q=$[1],X=$[2]/360*2*Math.PI,V=Q*Math.cos(X),K=Q*Math.sin(X);return[Z,V,K]};C.rgb.ansi16=function($,Z=null){let[Q,J,X]=$,V=Z===null?C.rgb.hsv($)[2]:Z;if(V=Math.round(V/50),V===0)return 30;let K=30+(Math.round(X/255)<<2|Math.round(J/255)<<1|Math.round(Q/255));if(V===2)K+=60;return K};C.hsv.ansi16=function($){return C.rgb.ansi16(C.hsv.rgb($),$[2])};C.rgb.ansi256=function($){let Z=$[0],Q=$[1],J=$[2];if(Z>>4===Q>>4&&Q>>4===J>>4){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}return 16+36*Math.round(Z/255*5)+6*Math.round(Q/255*5)+Math.round(J/255*5)};C.ansi16.rgb=function($){$=$[0];let Z=$%10;if(Z===0||Z===7){if($>50)Z+=3.5;return Z=Z/10.5*255,[Z,Z,Z]}let Q=(Math.trunc($>50)+1)*0.5,J=(Z&1)*Q*255,X=(Z>>1&1)*Q*255,V=(Z>>2&1)*Q*255;return[J,X,V]};C.ansi256.rgb=function($){if($=$[0],$>=232){let V=($-232)*10+8;return[V,V,V]}$-=16;let Z,Q=Math.floor($/36)/5*255,J=Math.floor((Z=$%36)/6)/5*255,X=Z%6/5*255;return[Q,J,X]};C.rgb.hex=function($){let Q=(((Math.round($[0])&255)<<16)+((Math.round($[1])&255)<<8)+(Math.round($[2])&255)).toString(16).toUpperCase();return"000000".slice(Q.length)+Q};C.hex.rgb=function($){let Z=$.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!Z)return[0,0,0];let Q=Z[0];if(Z[0].length===3)Q=[...Q].map((W)=>W+W).join("");let J=Number.parseInt(Q,16),X=J>>16&255,V=J>>8&255,K=J&255;return[X,V,K]};C.rgb.hcg=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.max(Math.max(Z,Q),J),V=Math.min(Math.min(Z,Q),J),K=X-V,W,H=K<1?V/(1-K):0;if(K<=0)W=0;else if(X===Z)W=(Q-J)/K%6;else if(X===Q)W=2+(J-Z)/K;else W=4+(Z-Q)/K;return W/=6,W%=1,[W*360,K*100,H*100]};C.hsl.hcg=function($){let Z=$[1]/100,Q=$[2]/100,J=Q<0.5?2*Z*Q:2*Z*(1-Q),X=0;if(J<1)X=(Q-0.5*J)/(1-J);return[$[0],J*100,X*100]};C.hsv.hcg=function($){let Z=$[1]/100,Q=$[2]/100,J=Z*Q,X=0;if(J<1)X=(Q-J)/(1-J);return[$[0],J*100,X*100]};C.hcg.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100;if(Q===0)return[J*255,J*255,J*255];let X=[0,0,0],V=Z%1*6,K=V%1,W=1-K,H=0;switch(Math.floor(V)){case 0:{X[0]=1,X[1]=K,X[2]=0;break}case 1:{X[0]=W,X[1]=1,X[2]=0;break}case 2:{X[0]=0,X[1]=1,X[2]=K;break}case 3:{X[0]=0,X[1]=W,X[2]=1;break}case 4:{X[0]=K,X[1]=0,X[2]=1;break}default:X[0]=1,X[1]=0,X[2]=W}return H=(1-Q)*J,[(Q*X[0]+H)*255,(Q*X[1]+H)*255,(Q*X[2]+H)*255]};C.hcg.hsv=function($){let Z=$[1]/100,Q=$[2]/100,J=Z+Q*(1-Z),X=0;if(J>0)X=Z/J;return[$[0],X*100,J*100]};C.hcg.hsl=function($){let Z=$[1]/100,J=$[2]/100*(1-Z)+0.5*Z,X=0;if(J>0&&J<0.5)X=Z/(2*J);else if(J>=0.5&&J<1)X=Z/(2*(1-J));return[$[0],X*100,J*100]};C.hcg.hwb=function($){let Z=$[1]/100,Q=$[2]/100,J=Z+Q*(1-Z);return[$[0],(J-Z)*100,(1-J)*100]};C.hwb.hcg=function($){let Z=$[1]/100,J=1-$[2]/100,X=J-Z,V=0;if(X<1)V=(J-X)/(1-X);return[$[0],X*100,V*100]};C.apple.rgb=function($){return[$[0]/65535*255,$[1]/65535*255,$[2]/65535*255]};C.rgb.apple=function($){return[$[0]/255*65535,$[1]/255*65535,$[2]/255*65535]};C.gray.rgb=function($){return[$[0]/100*255,$[0]/100*255,$[0]/100*255]};C.gray.hsl=function($){return[0,0,$[0]]};C.gray.hsv=C.gray.hsl;C.gray.hwb=function($){return[0,100,$[0]]};C.gray.cmyk=function($){return[0,0,0,$[0]]};C.gray.lab=function($){return[$[0],0,0]};C.gray.hex=function($){let Z=Math.round($[0]/100*255)&255,J=((Z<<16)+(Z<<8)+Z).toString(16).toUpperCase();return"000000".slice(J.length)+J};C.rgb.gray=function($){return[($[0]+$[1]+$[2])/3/255*100]};function C3(){let $={},Z=Object.keys(j4);for(let{length:Q}=Z,J=0;J<Q;J++)$[Z[J]]={distance:-1,parent:null};return $}function N3($){let Z=C3(),Q=[$];Z[$].distance=0;while(Q.length>0){let J=Q.pop(),X=Object.keys(j4[J]);for(let{length:V}=X,K=0;K<V;K++){let W=X[K],H=Z[W];if(H.distance===-1)H.distance=Z[J].distance+1,H.parent=J,Q.unshift(W)}}return Z}function P3($,Z){return function(Q){return Z($(Q))}}function D3($,Z){let Q=[Z[$].parent,$],J=j4[Z[$].parent][$],X=Z[$].parent;while(Z[X].parent)Q.unshift(Z[X].parent),J=P3(j4[Z[X].parent][X],J),X=Z[X].parent;return J.conversion=Q,J}function F3($){let Z=N3($),Q={},J=Object.keys(Z);for(let{length:X}=J,V=0;V<X;V++){let K=J[V];if(Z[K].parent===null)continue;Q[K]=D3(K,Z)}return Q}var M3=F3,I4={},I3=Object.keys(j4);function E3($){let Z=function(...Q){let J=Q[0];if(J===void 0||J===null)return J;if(J.length>1)Q=J;return $(Q)};if("conversion"in $)Z.conversion=$.conversion;return Z}function S3($){let Z=function(...Q){let J=Q[0];if(J===void 0||J===null)return J;if(J.length>1)Q=J;let X=$(Q);if(typeof X==="object")for(let{length:V}=X,K=0;K<V;K++)X[K]=Math.round(X[K]);return X};if("conversion"in $)Z.conversion=$.conversion;return Z}for(let $ of I3){I4[$]={},Object.defineProperty(I4[$],"channels",{value:j4[$].channels}),Object.defineProperty(I4[$],"labels",{value:j4[$].labels});let Z=M3($),Q=Object.keys(Z);for(let J of Q){let X=Z[J];I4[$][J]=S3(X),I4[$][J].raw=E3(X)}}var z0=I4,z9=["keyword","gray","hex"],l2={};for(let $ of Object.keys(z0))l2[[...z0[$].labels].sort().join("")]=$;var p2={};function i($,Z){if(!(this instanceof i))return new i($,Z);if(Z&&Z in z9)Z=null;if(Z&&!(Z in z0))throw Error("Unknown model: "+Z);let Q,J;if($==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if($ instanceof i)this.model=$.model,this.color=[...$.color],this.valpha=$.valpha;else if(typeof $==="string"){let X=M4.get($);if(X===null)throw Error("Unable to parse color from string: "+$);this.model=X.model,J=z0[this.model].channels,this.color=X.value.slice(0,J),this.valpha=typeof X.value[J]==="number"?X.value[J]:1}else if($.length>0){this.model=Z||"rgb",J=z0[this.model].channels;let X=Array.prototype.slice.call($,0,J);this.color=a2(X,J),this.valpha=typeof $[J]==="number"?$[J]:1}else if(typeof $==="number")this.model="rgb",this.color=[$>>16&255,$>>8&255,$&255],this.valpha=1;else{this.valpha=1;let X=Object.keys($);if("alpha"in $)X.splice(X.indexOf("alpha"),1),this.valpha=typeof $.alpha==="number"?$.alpha:0;let V=X.sort().join("");if(!(V in l2))throw Error("Unable to parse color from object: "+JSON.stringify($));this.model=l2[V];let{labels:K}=z0[this.model],W=[];for(Q=0;Q<K.length;Q++)W.push($[K[Q]]);this.color=a2(W)}if(p2[this.model]){J=z0[this.model].channels;for(Q=0;Q<J;Q++){let X=p2[this.model][Q];if(X)this.color[Q]=X(this.color[Q])}}if(this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze)Object.freeze(this)}i.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string($){let Z=this.model in M4.to?this:this.rgb();Z=Z.round(typeof $==="number"?$:1);let Q=Z.valpha===1?Z.color:[...Z.color,this.valpha];return M4.to[Z.model](...Q)},percentString($){let Z=this.rgb().round(typeof $==="number"?$:1),Q=Z.valpha===1?Z.color:[...Z.color,this.valpha];return M4.to.rgb.percent(...Q)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let $={},{channels:Z}=z0[this.model],{labels:Q}=z0[this.model];for(let J=0;J<Z;J++)$[Q[J]]=this.color[J];if(this.valpha!==1)$.alpha=this.valpha;return $},unitArray(){let $=this.rgb().color;if($[0]/=255,$[1]/=255,$[2]/=255,this.valpha!==1)$.push(this.valpha);return $},unitObject(){let $=this.rgb().object();if($.r/=255,$.g/=255,$.b/=255,this.valpha!==1)$.alpha=this.valpha;return $},round($){return $=Math.max($||0,0),new i([...this.color.map(k3($)),this.valpha],this.model)},alpha($){if($!==void 0)return new i([...this.color,Math.max(0,Math.min(1,$))],this.model);return this.valpha},red:u("rgb",0,p(255)),green:u("rgb",1,p(255)),blue:u("rgb",2,p(255)),hue:u(["hsl","hsv","hsl","hwb","hcg"],0,($)=>($%360+360)%360),saturationl:u("hsl",1,p(100)),lightness:u("hsl",2,p(100)),saturationv:u("hsv",1,p(100)),value:u("hsv",2,p(100)),chroma:u("hcg",1,p(100)),gray:u("hcg",2,p(100)),white:u("hwb",1,p(100)),wblack:u("hwb",2,p(100)),cyan:u("cmyk",0,p(100)),magenta:u("cmyk",1,p(100)),yellow:u("cmyk",2,p(100)),black:u("cmyk",3,p(100)),x:u("xyz",0,p(95.047)),y:u("xyz",1,p(100)),z:u("xyz",2,p(108.833)),l:u("lab",0,p(100)),a:u("lab",1),b:u("lab",2),keyword($){if($!==void 0)return new i($);return z0[this.model].keyword(this.color)},hex($){if($!==void 0)return new i($);return M4.to.hex(...this.rgb().round().color)},hexa($){if($!==void 0)return new i($);let Z=this.rgb().round().color,Q=Math.round(this.valpha*255).toString(16).toUpperCase();if(Q.length===1)Q="0"+Q;return M4.to.hex(...Z)+Q},rgbNumber(){let $=this.rgb().color;return($[0]&255)<<16|($[1]&255)<<8|$[2]&255},luminosity(){let $=this.rgb().color,Z=[];for(let[Q,J]of $.entries()){let X=J/255;Z[Q]=X<=0.04045?X/12.92:((X+0.055)/1.055)**2.4}return 0.2126*Z[0]+0.7152*Z[1]+0.0722*Z[2]},contrast($){let Z=this.luminosity(),Q=$.luminosity();if(Z>Q)return(Z+0.05)/(Q+0.05);return(Q+0.05)/(Z+0.05)},level($){let Z=this.contrast($);if(Z>=7)return"AAA";return Z>=4.5?"AA":""},isDark(){let $=this.rgb().color;return($[0]*2126+$[1]*7152+$[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let $=this.rgb();for(let Z=0;Z<3;Z++)$.color[Z]=255-$.color[Z];return $},lighten($){let Z=this.hsl();return Z.color[2]+=Z.color[2]*$,Z},darken($){let Z=this.hsl();return Z.color[2]-=Z.color[2]*$,Z},saturate($){let Z=this.hsl();return Z.color[1]+=Z.color[1]*$,Z},desaturate($){let Z=this.hsl();return Z.color[1]-=Z.color[1]*$,Z},whiten($){let Z=this.hwb();return Z.color[1]+=Z.color[1]*$,Z},blacken($){let Z=this.hwb();return Z.color[2]+=Z.color[2]*$,Z},grayscale(){let $=this.rgb().color,Z=$[0]*0.3+$[1]*0.59+$[2]*0.11;return i.rgb(Z,Z,Z)},fade($){return this.alpha(this.valpha-this.valpha*$)},opaquer($){return this.alpha(this.valpha+this.valpha*$)},rotate($){let Z=this.hsl(),Q=Z.color[0];return Q=(Q+$)%360,Q=Q<0?360+Q:Q,Z.color[0]=Q,Z},mix($,Z){if(!$||!$.rgb)throw Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof $);let Q=$.rgb(),J=this.rgb(),X=Z===void 0?0.5:Z,V=2*X-1,K=Q.alpha()-J.alpha(),W=((V*K===-1?V:(V+K)/(1+V*K))+1)/2,H=1-W;return i.rgb(W*Q.red()+H*J.red(),W*Q.green()+H*J.green(),W*Q.blue()+H*J.blue(),Q.alpha()*X+J.alpha()*(1-X))}};for(let $ of Object.keys(z0)){if(z9.includes($))continue;let{channels:Z}=z0[$];i.prototype[$]=function(...Q){if(this.model===$)return new i(this);if(Q.length>0)return new i(Q,$);return new i([...x3(z0[this.model][$].raw(this.color)),this.valpha],$)},i[$]=function(...Q){let J=Q[0];if(typeof J==="number")J=a2(Q,Z);return new i(J,$)}}function T3($,Z){return Number($.toFixed(Z))}function k3($){return function(Z){return T3(Z,$)}}function u($,Z,Q){$=Array.isArray($)?$:[$];for(let J of $)(p2[J]||=[])[Z]=Q;return $=$[0],function(J){let X;if(J!==void 0){if(Q)J=Q(J);return X=this[$](),X.color[Z]=J,X}if(X=this[$]().color[Z],Q)X=Q(X);return X}}function p($){return function(Z){return Math.max(0,Math.min($,Z))}}function x3($){return Array.isArray($)?$:[$]}function a2($,Z){for(let Q=0;Q<Z;Q++)if(typeof $[Q]!=="number")$[Q]=0;return $}var v3=i});var A9=T((GH,U9)=>{U9.exports=j9().default});var w9=T((jH,_9)=>{/*!
28
+ Copyright 2013 Lovell Fuller and others.
29
+ SPDX-License-Identifier: Apache-2.0
30
+ */var O3=A9(),l0=E0(),B9={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function y3($){return this._setBackgroundColourOption("tint",$),this}function b3($){return this.options.greyscale=l0.bool($)?$:!0,this}function f3($){return this.greyscale($)}function h3($){if(!l0.string($))throw l0.invalidParameterError("colourspace","string",$);return this.options.colourspacePipeline=$,this}function g3($){return this.pipelineColourspace($)}function d3($){if(!l0.string($))throw l0.invalidParameterError("colourspace","string",$);return this.options.colourspace=$,this}function u3($){return this.toColourspace($)}function L9($){if(l0.object($)||l0.string($)&&$.length>=3&&$.length<=200){let Z=O3($);return[Z.red(),Z.green(),Z.blue(),Math.round(Z.alpha()*255)]}else throw l0.invalidParameterError("background","object or string",$)}function m3($,Z){if(l0.defined(Z))this.options[$]=L9(Z)}_9.exports=($)=>{Object.assign($.prototype,{tint:y3,greyscale:b3,grayscale:f3,pipelineColourspace:h3,pipelineColorspace:g3,toColourspace:d3,toColorspace:u3,_getBackgroundColourOption:L9,_setBackgroundColourOption:m3}),$.colourspace=B9,$.colorspace=B9}});var C9=T((UH,R9)=>{/*!
31
+ Copyright 2013 Lovell Fuller and others.
32
+ SPDX-License-Identifier: Apache-2.0
33
+ */var O0=E0(),c3={and:"and",or:"or",eor:"eor"};function l3(){return this.options.removeAlpha=!0,this}function p3($){if(O0.defined($))if(O0.number($)&&O0.inRange($,0,1))this.options.ensureAlpha=$;else throw O0.invalidParameterError("alpha","number between 0 and 1",$);else this.options.ensureAlpha=1;return this}function a3($){let Z={red:0,green:1,blue:2,alpha:3};if(Object.keys(Z).includes($))$=Z[$];if(O0.integer($)&&O0.inRange($,0,4))this.options.extractChannel=$;else throw O0.invalidParameterError("channel","integer or one of: red, green, blue, alpha",$);return this}function r3($,Z){if(Array.isArray($))$.forEach(function(Q){this.options.joinChannelIn.push(this._createInputDescriptor(Q,Z))},this);else this.options.joinChannelIn.push(this._createInputDescriptor($,Z));return this}function n3($){if(O0.string($)&&O0.inArray($,["and","or","eor"]))this.options.bandBoolOp=$;else throw O0.invalidParameterError("boolOp","one of: and, or, eor",$);return this}R9.exports=($)=>{Object.assign($.prototype,{removeAlpha:l3,ensureAlpha:p3,extractChannel:a3,joinChannel:r3,bandbool:n3}),$.bool=c3}});var M9=T((AH,F9)=>{/*!
34
+ Copyright 2013 Lovell Fuller and others.
35
+ SPDX-License-Identifier: Apache-2.0
36
+ */var n2=v("path"),Y=E0(),T4=K6(),N9=new Map([["heic","heif"],["heif","heif"],["avif","avif"],["jpeg","jpeg"],["jpg","jpeg"],["jpe","jpeg"],["tile","tile"],["dz","tile"],["png","png"],["raw","raw"],["tiff","tiff"],["tif","tiff"],["webp","webp"],["gif","gif"],["jp2","jp2"],["jpx","jp2"],["j2k","jp2"],["j2c","jp2"],["jxl","jxl"]]),i3=/\.(jp[2x]|j2[kc])$/i,P9=()=>Error("JP2 output requires libvips with support for OpenJPEG"),D9=($)=>1<<31-Math.clz32(Math.ceil(Math.log2($)));function s3($,Z){let Q;if(!Y.string($))Q=Error("Missing output file path");else if(Y.string(this.options.input.file)&&n2.resolve(this.options.input.file)===n2.resolve($))Q=Error("Cannot use same file for input and output");else if(i3.test(n2.extname($))&&!this.constructor.format.jp2k.output.file)Q=P9();if(Q)if(Y.fn(Z))Z(Q);else return Promise.reject(Q);else{this.options.fileOut=$;let J=Error();return this._pipeline(Z,J)}return this}function o3($,Z){if(Y.object($))this._setBooleanOption("resolveWithObject",$.resolveWithObject);else if(this.options.resolveWithObject)this.options.resolveWithObject=!1;this.options.fileOut="";let Q=Error();return this._pipeline(Y.fn($)?$:Z,Q)}function e3(){return this.options.keepMetadata|=1,this}function t3($){if(Y.object($))for(let[Z,Q]of Object.entries($))if(Y.object(Q))for(let[J,X]of Object.entries(Q))if(Y.string(X))this.options.withExif[`exif-${Z.toLowerCase()}-${J}`]=X;else throw Y.invalidParameterError(`${Z}.${J}`,"string",X);else throw Y.invalidParameterError(Z,"object",Q);else throw Y.invalidParameterError("exif","object",$);return this.options.withExifMerge=!1,this.keepExif()}function $X($){return this.withExif($),this.options.withExifMerge=!0,this}function ZX(){return this.options.keepMetadata|=8,this}function QX($,Z){if(Y.string($))this.options.withIccProfile=$;else throw Y.invalidParameterError("icc","string",$);if(this.keepIccProfile(),Y.object(Z)){if(Y.defined(Z.attach))if(Y.bool(Z.attach)){if(!Z.attach)this.options.keepMetadata&=-9}else throw Y.invalidParameterError("attach","boolean",Z.attach)}return this}function JX(){return this.options.keepMetadata|=2,this}function XX($){if(Y.string($)&&$.length>0)this.options.withXmp=$,this.options.keepMetadata|=2;else throw Y.invalidParameterError("xmp","non-empty string",$);return this}function VX(){return this.options.keepMetadata=31,this}function KX($){if(this.keepMetadata(),this.withIccProfile("srgb"),Y.object($)){if(Y.defined($.orientation))if(Y.integer($.orientation)&&Y.inRange($.orientation,1,8))this.options.withMetadataOrientation=$.orientation;else throw Y.invalidParameterError("orientation","integer between 1 and 8",$.orientation);if(Y.defined($.density))if(Y.number($.density)&&$.density>0)this.options.withMetadataDensity=$.density;else throw Y.invalidParameterError("density","positive number",$.density);if(Y.defined($.icc))this.withIccProfile($.icc);if(Y.defined($.exif))this.withExifMerge($.exif)}return this}function WX($,Z){let Q=N9.get((Y.object($)&&Y.string($.id)?$.id:$).toLowerCase());if(!Q)throw Y.invalidParameterError("format",`one of: ${[...N9.keys()].join(", ")}`,$);return this[Q](Z)}function HX($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.jpegQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.progressive))this._setBooleanOption("jpegProgressive",$.progressive);if(Y.defined($.chromaSubsampling))if(Y.string($.chromaSubsampling)&&Y.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=$.chromaSubsampling;else throw Y.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);let Z=Y.bool($.optimizeCoding)?$.optimizeCoding:$.optimiseCoding;if(Y.defined(Z))this._setBooleanOption("jpegOptimiseCoding",Z);if(Y.defined($.mozjpeg))if(Y.bool($.mozjpeg)){if($.mozjpeg)this.options.jpegTrellisQuantisation=!0,this.options.jpegOvershootDeringing=!0,this.options.jpegOptimiseScans=!0,this.options.jpegProgressive=!0,this.options.jpegQuantisationTable=3}else throw Y.invalidParameterError("mozjpeg","boolean",$.mozjpeg);let Q=Y.bool($.trellisQuantization)?$.trellisQuantization:$.trellisQuantisation;if(Y.defined(Q))this._setBooleanOption("jpegTrellisQuantisation",Q);if(Y.defined($.overshootDeringing))this._setBooleanOption("jpegOvershootDeringing",$.overshootDeringing);let J=Y.bool($.optimizeScans)?$.optimizeScans:$.optimiseScans;if(Y.defined(J)){if(this._setBooleanOption("jpegOptimiseScans",J),J)this.options.jpegProgressive=!0}let X=Y.number($.quantizationTable)?$.quantizationTable:$.quantisationTable;if(Y.defined(X))if(Y.integer(X)&&Y.inRange(X,0,8))this.options.jpegQuantisationTable=X;else throw Y.invalidParameterError("quantisationTable","integer between 0 and 8",X)}return this._updateFormatOut("jpeg",$)}function qX($){if(Y.object($)){if(Y.defined($.progressive))this._setBooleanOption("pngProgressive",$.progressive);if(Y.defined($.compressionLevel))if(Y.integer($.compressionLevel)&&Y.inRange($.compressionLevel,0,9))this.options.pngCompressionLevel=$.compressionLevel;else throw Y.invalidParameterError("compressionLevel","integer between 0 and 9",$.compressionLevel);if(Y.defined($.adaptiveFiltering))this._setBooleanOption("pngAdaptiveFiltering",$.adaptiveFiltering);let Z=$.colours||$.colors;if(Y.defined(Z))if(Y.integer(Z)&&Y.inRange(Z,2,256))this.options.pngBitdepth=D9(Z);else throw Y.invalidParameterError("colours","integer between 2 and 256",Z);if(Y.defined($.palette))this._setBooleanOption("pngPalette",$.palette);else if([$.quality,$.effort,$.colours,$.colors,$.dither].some(Y.defined))this._setBooleanOption("pngPalette",!0);if(this.options.pngPalette){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,0,100))this.options.pngQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 0 and 100",$.quality);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,1,10))this.options.pngEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 1 and 10",$.effort);if(Y.defined($.dither))if(Y.number($.dither)&&Y.inRange($.dither,0,1))this.options.pngDither=$.dither;else throw Y.invalidParameterError("dither","number between 0.0 and 1.0",$.dither)}}return this._updateFormatOut("png",$)}function YX($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.webpQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.alphaQuality))if(Y.integer($.alphaQuality)&&Y.inRange($.alphaQuality,0,100))this.options.webpAlphaQuality=$.alphaQuality;else throw Y.invalidParameterError("alphaQuality","integer between 0 and 100",$.alphaQuality);if(Y.defined($.lossless))this._setBooleanOption("webpLossless",$.lossless);if(Y.defined($.nearLossless))this._setBooleanOption("webpNearLossless",$.nearLossless);if(Y.defined($.smartSubsample))this._setBooleanOption("webpSmartSubsample",$.smartSubsample);if(Y.defined($.smartDeblock))this._setBooleanOption("webpSmartDeblock",$.smartDeblock);if(Y.defined($.preset))if(Y.string($.preset)&&Y.inArray($.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=$.preset;else throw Y.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",$.preset);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,0,6))this.options.webpEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 0 and 6",$.effort);if(Y.defined($.minSize))this._setBooleanOption("webpMinSize",$.minSize);if(Y.defined($.mixed))this._setBooleanOption("webpMixed",$.mixed)}return i2($,this.options),this._updateFormatOut("webp",$)}function zX($){if(Y.object($)){if(Y.defined($.reuse))this._setBooleanOption("gifReuse",$.reuse);if(Y.defined($.progressive))this._setBooleanOption("gifProgressive",$.progressive);let Z=$.colours||$.colors;if(Y.defined(Z))if(Y.integer(Z)&&Y.inRange(Z,2,256))this.options.gifBitdepth=D9(Z);else throw Y.invalidParameterError("colours","integer between 2 and 256",Z);if(Y.defined($.effort))if(Y.number($.effort)&&Y.inRange($.effort,1,10))this.options.gifEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 1 and 10",$.effort);if(Y.defined($.dither))if(Y.number($.dither)&&Y.inRange($.dither,0,1))this.options.gifDither=$.dither;else throw Y.invalidParameterError("dither","number between 0.0 and 1.0",$.dither);if(Y.defined($.interFrameMaxError))if(Y.number($.interFrameMaxError)&&Y.inRange($.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=$.interFrameMaxError;else throw Y.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",$.interFrameMaxError);if(Y.defined($.interPaletteMaxError))if(Y.number($.interPaletteMaxError)&&Y.inRange($.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=$.interPaletteMaxError;else throw Y.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",$.interPaletteMaxError);if(Y.defined($.keepDuplicateFrames))if(Y.bool($.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",$.keepDuplicateFrames);else throw Y.invalidParameterError("keepDuplicateFrames","boolean",$.keepDuplicateFrames)}return i2($,this.options),this._updateFormatOut("gif",$)}function GX($){if(!this.constructor.format.jp2k.output.buffer)throw P9();if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.jp2Quality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.lossless))if(Y.bool($.lossless))this.options.jp2Lossless=$.lossless;else throw Y.invalidParameterError("lossless","boolean",$.lossless);if(Y.defined($.tileWidth))if(Y.integer($.tileWidth)&&Y.inRange($.tileWidth,1,32768))this.options.jp2TileWidth=$.tileWidth;else throw Y.invalidParameterError("tileWidth","integer between 1 and 32768",$.tileWidth);if(Y.defined($.tileHeight))if(Y.integer($.tileHeight)&&Y.inRange($.tileHeight,1,32768))this.options.jp2TileHeight=$.tileHeight;else throw Y.invalidParameterError("tileHeight","integer between 1 and 32768",$.tileHeight);if(Y.defined($.chromaSubsampling))if(Y.string($.chromaSubsampling)&&Y.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=$.chromaSubsampling;else throw Y.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling)}return this._updateFormatOut("jp2",$)}function i2($,Z){if(Y.object($)&&Y.defined($.loop))if(Y.integer($.loop)&&Y.inRange($.loop,0,65535))Z.loop=$.loop;else throw Y.invalidParameterError("loop","integer between 0 and 65535",$.loop);if(Y.object($)&&Y.defined($.delay))if(Y.integer($.delay)&&Y.inRange($.delay,0,65535))Z.delay=[$.delay];else if(Array.isArray($.delay)&&$.delay.every(Y.integer)&&$.delay.every((Q)=>Y.inRange(Q,0,65535)))Z.delay=$.delay;else throw Y.invalidParameterError("delay","integer or an array of integers between 0 and 65535",$.delay)}function jX($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.tiffQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.bitdepth))if(Y.integer($.bitdepth)&&Y.inArray($.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=$.bitdepth;else throw Y.invalidParameterError("bitdepth","1, 2, 4 or 8",$.bitdepth);if(Y.defined($.tile))this._setBooleanOption("tiffTile",$.tile);if(Y.defined($.tileWidth))if(Y.integer($.tileWidth)&&$.tileWidth>0)this.options.tiffTileWidth=$.tileWidth;else throw Y.invalidParameterError("tileWidth","integer greater than zero",$.tileWidth);if(Y.defined($.tileHeight))if(Y.integer($.tileHeight)&&$.tileHeight>0)this.options.tiffTileHeight=$.tileHeight;else throw Y.invalidParameterError("tileHeight","integer greater than zero",$.tileHeight);if(Y.defined($.miniswhite))this._setBooleanOption("tiffMiniswhite",$.miniswhite);if(Y.defined($.pyramid))this._setBooleanOption("tiffPyramid",$.pyramid);if(Y.defined($.xres))if(Y.number($.xres)&&$.xres>0)this.options.tiffXres=$.xres;else throw Y.invalidParameterError("xres","number greater than zero",$.xres);if(Y.defined($.yres))if(Y.number($.yres)&&$.yres>0)this.options.tiffYres=$.yres;else throw Y.invalidParameterError("yres","number greater than zero",$.yres);if(Y.defined($.compression))if(Y.string($.compression)&&Y.inArray($.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=$.compression;else throw Y.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",$.compression);if(Y.defined($.bigtiff))this._setBooleanOption("tiffBigtiff",$.bigtiff);if(Y.defined($.predictor))if(Y.string($.predictor)&&Y.inArray($.predictor,["none","horizontal","float"]))this.options.tiffPredictor=$.predictor;else throw Y.invalidParameterError("predictor","one of: none, horizontal, float",$.predictor);if(Y.defined($.resolutionUnit))if(Y.string($.resolutionUnit)&&Y.inArray($.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=$.resolutionUnit;else throw Y.invalidParameterError("resolutionUnit","one of: inch, cm",$.resolutionUnit)}return this._updateFormatOut("tiff",$)}function UX($){return this.heif({...$,compression:"av1"})}function AX($){if(Y.object($)){if(Y.string($.compression)&&Y.inArray($.compression,["av1","hevc"]))this.options.heifCompression=$.compression;else throw Y.invalidParameterError("compression","one of: av1, hevc",$.compression);if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.heifQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.lossless))if(Y.bool($.lossless))this.options.heifLossless=$.lossless;else throw Y.invalidParameterError("lossless","boolean",$.lossless);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,0,9))this.options.heifEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 0 and 9",$.effort);if(Y.defined($.chromaSubsampling))if(Y.string($.chromaSubsampling)&&Y.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=$.chromaSubsampling;else throw Y.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);if(Y.defined($.bitdepth))if(Y.integer($.bitdepth)&&Y.inArray($.bitdepth,[8,10,12])){if($.bitdepth!==8&&this.constructor.versions.heif)throw Y.invalidParameterError("bitdepth when using prebuilt binaries",8,$.bitdepth);this.options.heifBitdepth=$.bitdepth}else throw Y.invalidParameterError("bitdepth","8, 10 or 12",$.bitdepth)}else throw Y.invalidParameterError("options","Object",$);return this._updateFormatOut("heif",$)}function BX($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.jxlDistance=$.quality>=30?0.1+(100-$.quality)*0.09:0.017666666666666667*$.quality*$.quality-1.15*$.quality+25;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);else if(Y.defined($.distance))if(Y.number($.distance)&&Y.inRange($.distance,0,15))this.options.jxlDistance=$.distance;else throw Y.invalidParameterError("distance","number between 0.0 and 15.0",$.distance);if(Y.defined($.decodingTier))if(Y.integer($.decodingTier)&&Y.inRange($.decodingTier,0,4))this.options.jxlDecodingTier=$.decodingTier;else throw Y.invalidParameterError("decodingTier","integer between 0 and 4",$.decodingTier);if(Y.defined($.lossless))if(Y.bool($.lossless))this.options.jxlLossless=$.lossless;else throw Y.invalidParameterError("lossless","boolean",$.lossless);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,1,9))this.options.jxlEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 1 and 9",$.effort)}return i2($,this.options),this._updateFormatOut("jxl",$)}function LX($){if(Y.object($)){if(Y.defined($.depth))if(Y.string($.depth)&&Y.inArray($.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=$.depth;else throw Y.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",$.depth)}return this._updateFormatOut("raw")}function _X($){if(Y.object($)){if(Y.defined($.size))if(Y.integer($.size)&&Y.inRange($.size,1,8192))this.options.tileSize=$.size;else throw Y.invalidParameterError("size","integer between 1 and 8192",$.size);if(Y.defined($.overlap))if(Y.integer($.overlap)&&Y.inRange($.overlap,0,8192)){if($.overlap>this.options.tileSize)throw Y.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,$.overlap);this.options.tileOverlap=$.overlap}else throw Y.invalidParameterError("overlap","integer between 0 and 8192",$.overlap);if(Y.defined($.container))if(Y.string($.container)&&Y.inArray($.container,["fs","zip"]))this.options.tileContainer=$.container;else throw Y.invalidParameterError("container","one of: fs, zip",$.container);if(Y.defined($.layout))if(Y.string($.layout)&&Y.inArray($.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=$.layout;else throw Y.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",$.layout);if(Y.defined($.angle))if(Y.integer($.angle)&&!($.angle%90))this.options.tileAngle=$.angle;else throw Y.invalidParameterError("angle","positive/negative multiple of 90",$.angle);if(this._setBackgroundColourOption("tileBackground",$.background),Y.defined($.depth))if(Y.string($.depth)&&Y.inArray($.depth,["onepixel","onetile","one"]))this.options.tileDepth=$.depth;else throw Y.invalidParameterError("depth","one of: onepixel, onetile, one",$.depth);if(Y.defined($.skipBlanks))if(Y.integer($.skipBlanks)&&Y.inRange($.skipBlanks,-1,65535))this.options.tileSkipBlanks=$.skipBlanks;else throw Y.invalidParameterError("skipBlanks","integer between -1 and 255/65535",$.skipBlanks);else if(Y.defined($.layout)&&$.layout==="google")this.options.tileSkipBlanks=5;let Z=Y.bool($.center)?$.center:$.centre;if(Y.defined(Z))this._setBooleanOption("tileCentre",Z);if(Y.defined($.id))if(Y.string($.id))this.options.tileId=$.id;else throw Y.invalidParameterError("id","string",$.id);if(Y.defined($.basename))if(Y.string($.basename))this.options.tileBasename=$.basename;else throw Y.invalidParameterError("basename","string",$.basename)}if(Y.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw Y.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function wX($){if(!Y.plainObject($))throw Y.invalidParameterError("options","object",$);if(Y.integer($.seconds)&&Y.inRange($.seconds,0,3600))this.options.timeoutSeconds=$.seconds;else throw Y.invalidParameterError("seconds","integer between 0 and 3600",$.seconds);return this}function RX($,Z){if(!(Y.object(Z)&&Z.force===!1))this.options.formatOut=$;return this}function CX($,Z){if(Y.bool(Z))this.options[$]=Z;else throw Y.invalidParameterError($,"boolean",Z)}function NX(){if(!this.options.streamOut){this.options.streamOut=!0;let $=Error();this._pipeline(void 0,$)}}function PX($,Z){if(typeof $==="function"){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(Q,J,X)=>{if(Q)$(Y.nativeError(Q,Z));else $(null,J,X)})});else T4.pipeline(this.options,(Q,J,X)=>{if(Q)$(Y.nativeError(Q,Z));else $(null,J,X)});return this}else if(this.options.streamOut){if(this._isStreamInput()){if(this.once("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(Q,J,X)=>{if(Q)this.emit("error",Y.nativeError(Q,Z));else this.emit("info",X),this.push(J);this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished)this.emit("finish")}else T4.pipeline(this.options,(Q,J,X)=>{if(Q)this.emit("error",Y.nativeError(Q,Z));else this.emit("info",X),this.push(J);this.push(null),this.on("end",()=>this.emit("close"))});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{this.once("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(X,V,K)=>{if(X)J(Y.nativeError(X,Z));else if(this.options.resolveWithObject)Q({data:V,info:K});else Q(V)})})});else return new Promise((Q,J)=>{T4.pipeline(this.options,(X,V,K)=>{if(X)J(Y.nativeError(X,Z));else if(this.options.resolveWithObject)Q({data:V,info:K});else Q(V)})})}F9.exports=($)=>{Object.assign($.prototype,{toFile:s3,toBuffer:o3,keepExif:e3,withExif:t3,withExifMerge:$X,keepIccProfile:ZX,withIccProfile:QX,keepXmp:JX,withXmp:XX,keepMetadata:VX,withMetadata:KX,toFormat:WX,jpeg:HX,jp2:GX,png:qX,webp:YX,tiff:jX,avif:UX,heif:AX,jxl:BX,gif:zX,raw:LX,tile:_X,timeout:wX,_updateFormatOut:RX,_setBooleanOption:CX,_read:NX,_pipeline:PX})}});var T9=T((BH,S9)=>{/*!
37
+ Copyright 2013 Lovell Fuller and others.
38
+ SPDX-License-Identifier: Apache-2.0
39
+ */var DX=v("events"),r6=v6(),B0=E0(),{runtimePlatformArch:FX}=h2(),V0=K6(),I9=FX(),s2=V0.libvipsVersion(),Z4=V0.format();Z4.heif.output.alias=["avif","heic"];Z4.jpeg.output.alias=["jpe","jpg"];Z4.tiff.output.alias=["tif"];Z4.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var MX={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},k4={vips:s2.semver};if(!s2.isGlobal)if(!s2.isWasm)try{k4=v(`@img/sharp-${I9}/versions`)}catch($){try{k4=v(`@img/sharp-libvips-${I9}/versions`)}catch(Z){}}else try{k4=(()=>{throw new Error("Cannot require module "+"@img/sharp-wasm32/versions");})()}catch($){}k4.sharp=b2().version;if(k4.heif&&Z4.heif)Z4.heif.input.fileSuffix=[".avif"],Z4.heif.output.alias=["avif"];function E9($){if(B0.bool($))if($)return V0.cache(50,20,100);else return V0.cache(0,0,0);else if(B0.object($))return V0.cache($.memory,$.files,$.items);else return V0.cache()}E9(!0);function IX($){return V0.concurrency(B0.integer($)?$:null)}if(r6.familySync()===r6.GLIBC&&!V0._isUsingJemalloc())V0.concurrency(1);else if(r6.familySync()===r6.MUSL&&V0.concurrency()===1024)V0.concurrency(v("os").availableParallelism());var EX=new DX.EventEmitter;function SX(){return V0.counters()}function TX($){return V0.simd(B0.bool($)?$:null)}function kX($){if(B0.object($))if(Array.isArray($.operation)&&$.operation.every(B0.string))V0.block($.operation,!0);else throw B0.invalidParameterError("operation","Array<string>",$.operation);else throw B0.invalidParameterError("options","object",$)}function xX($){if(B0.object($))if(Array.isArray($.operation)&&$.operation.every(B0.string))V0.block($.operation,!1);else throw B0.invalidParameterError("operation","Array<string>",$.operation);else throw B0.invalidParameterError("options","object",$)}S9.exports=($)=>{$.cache=E9,$.concurrency=IX,$.counters=SX,$.simd=TX,$.format=Z4,$.interpolators=MX,$.versions=k4,$.queue=EX,$.block=kX,$.unblock=xX}});var x9=T((_H,k9)=>{/*!
40
+ Copyright 2013 Lovell Fuller and others.
41
+ SPDX-License-Identifier: Apache-2.0
42
+ */var p0=p$();n$()(p0);$9()(p0);Q9()(p0);W9()(p0);w9()(p0);C9()(p0);M9()(p0);T9()(p0);k9.exports=p0});var Y6={enabled:!0,ttl:"1h",cacheSystemPrompt:!0,cacheTools:!0,minTokensForCache:1024},i9={low:1024,medium:4096,high:16384,max:1e5},wV={enabled:!1,effort:"medium",interleaved:!0};function J5($,Z){if($.budgetTokens)return $.budgetTokens;let Q=$.effort||"medium",J=i9[Q],X=$.modelMultiplier??(Z.includes("opus")?2:1);return Math.min(J*X,1e5)}function X5($){return $.includes("claude-opus-4")||$.includes("claude-sonnet-4")||$.includes("claude-haiku-4")||$.includes("claude-4")}var RV={"claude-opus-4-6":{input:15,output:75,cache_write:18.75,cache_read:1.5},"claude-sonnet-4-6":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-haiku-4-5":{input:0.8,output:4,cache_write:1,cache_read:0.08}};var s9={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,jitterFactor:0.2,retryableStatusCodes:[429,500,502,503,504,529],onRetry:void 0};function o9($,Z,Q,J){let X=Z*Math.pow(2,$),V=X*J*(Math.random()*2-1);return Math.min(X+V,Q)}function e9($,Z){if($.message.includes("429")||$.message.includes("rate limit"))return!0;if($.message.includes("500")||$.message.includes("502")||$.message.includes("503")||$.message.includes("504"))return!0;if($.message.includes("ECONNREFUSED")||$.message.includes("ENOTFOUND")||$.message.includes("ETIMEDOUT")||$.message.includes("network")||$.message.includes("fetch failed"))return!0;for(let Q of Z)if($.message.includes(String(Q)))return!0;return!1}function t9($){return new Promise((Z)=>setTimeout(Z,$))}async function V5($,Z={}){let Q={...s9,...Z},J=null;for(let X=0;X<=Q.maxRetries;X++)try{return await $()}catch(V){if(J=V instanceof Error?V:Error(String(V)),X<Q.maxRetries&&e9(J,Q.retryableStatusCodes)){let K=o9(X,Q.baseDelayMs,Q.maxDelayMs,Q.jitterFactor);if(Q.onRetry)Q.onRetry(X+1,J,K);else console.warn(`\x1B[33mRetry ${X+1}/${Q.maxRetries} after ${K}ms: ${J.message}\x1B[0m`);await t9(K)}else throw J}throw J||Error("Max retries exceeded")}var K5={"claude-opus-4-6":{input:15,output:75,cache_write:18.75,cache_read:1.5},"claude-sonnet-4-6":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-haiku-4-5":{input:0.8,output:4,cache_write:1,cache_read:0.08},"claude-3-5-sonnet":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-3-5-haiku":{input:0.8,output:4,cache_write:1,cache_read:0.08},"claude-3-opus":{input:15,output:75,cache_write:18.75,cache_read:1.5}};function $7($,Z){let Q=K5[$]??K5["claude-sonnet-4-6"],J=Z.input_tokens-(Z.cache_read_input_tokens??0),X=Z.cache_read_input_tokens??0,V=Z.cache_creation_input_tokens??0,K=Z.output_tokens,W=J/1e6*Q.input,H=X/1e6*Q.cache_read,q=V/1e6*Q.cache_write,z=K/1e6*Q.output,G=W+H+q+z,B=(X+V)/1e6*(Q.input-Q.cache_read);return{costUSD:G,estimatedSavingsUSD:B}}function Z7($,Z){if(!$||!Z.enabled||!Z.cacheSystemPrompt)return typeof $==="string"?$:void 0;if(Array.isArray($)){let Q=[...$];if(Q.length>0){let J=Q[Q.length-1];if(J&&J.type==="text")Q[Q.length-1]={type:"text",text:J.text,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return Q}return[{type:"text",text:$,cache_control:{type:"ephemeral",ttl:Z.ttl}}]}function Q7($,Z){if(!Z.enabled)return $;let Q=[];for(let J=0;J<$.length;J++){let X=$[J],V=[];for(let K=0;K<X.content.length;K++){let W=X.content[K],H=K===X.content.length-1,q=J===$.length-1;if(W.type==="text"&&W.text.length>=Z.minTokensForCache*4&&!W.cache_control&&(H||q))V.push({...W,cache_control:{type:"ephemeral",ttl:Z.ttl}});else V.push(W)}Q.push({...X,content:V})}if(Q.length>0&&Z.enabled){let J=Q[Q.length-1],X=J.content[J.content.length-1];if(X&&!("cache_control"in X))J.content[J.content.length-1]={...X,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return Q}function J7($){let Z=$.cache_read_input_tokens??0,Q=$.cache_creation_input_tokens??0,J=Z+Q,X=Z>0?1:0,V=Q>0?1:0,K=X+V;return{cacheHits:X,cacheMisses:V,totalCacheReadTokens:Z,totalCacheWriteTokens:Q,cacheHitRate:K>0?X/K:0,estimatedSavingsUSD:0}}async function W5($,Z){let{apiKey:Q,model:J="claude-sonnet-4-6",maxTokens:X=4096,tools:V,systemPrompt:K,cacheConfig:W=Y6,thinking:H,extendedThinking:q,onToken:z,onThinking:G,onRedactedThinking:A,onToolUse:B,signal:_}=Z,L=Date.now(),R=0,w=!0,D=0,I=Q7($,W),S=Z7(K,W),M={model:J,max_tokens:X,messages:I.map((h)=>({role:h.role,content:h.content})),stream:!0};if(S)M.system=S;if(V&&V.length>0)M.tools=V;let k=`${process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com"}/v1/messages`,l={"Content-Type":"application/json","x-api-key":Q,"anthropic-version":"2023-06-01"};if(((q?.enabled??!1)||H&&H.type!=="disabled")&&X5(J)){let h;if(q?.budgetTokens)h=q.budgetTokens;else if(H?.type==="enabled")h=H.budget_tokens;else{let n0=q?.effort||"medium";h=J5({enabled:!0,effort:n0,modelMultiplier:J.includes("opus")?2:1},J)}h=Math.max(1024,Math.min(h,1e5)),M.thinking={type:"enabled",budget_tokens:h};let D0=["extended-thinking-2025-01-24"];if(q?.interleaved!==!1)D0.push("interleaved-thinking-2025-01-24");l["anthropic-beta"]=D0.join(",")}else l["anthropic-beta"]="max-tokens-3-5-sonnet-2024-07-15";let t={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,retryableStatusCodes:[429,500,502,503,504,529],onRetry:(h,D0,n0)=>{console.log(`\x1B[33mAPI retry ${h}/3 after ${n0}ms: ${D0.message}\x1B[0m`)}},a0=await V5(async()=>{let h=await fetch(k,{method:"POST",headers:l,body:JSON.stringify(M),signal:_});if(!h.ok&&t.retryableStatusCodes?.includes(h.status)){let D0=await h.text();throw Error(`API error: ${h.status} - ${D0}`)}return h},t);if(!a0.ok){let h=await a0.text();throw Error(`API error: ${a0.status} - ${h}`)}if(!a0.body)throw Error("No response body");let x4=a0.body.getReader(),H6=new TextDecoder,N0=null,y0=[],s={input_tokens:0,output_tokens:0},r0=null,L0=null,b0=null,W0=null,U4="",$5="";try{let h="";while(!0){let{done:D0,value:n0}=await x4.read();if(D0)break;h+=H6.decode(n0,{stream:!0});let y4=h.split(`
43
+ `);h=y4.pop()||"";for(let A4 of y4){if(!A4.startsWith("data: "))continue;let b4=A4.slice(6);if(!b4)continue;try{let O=JSON.parse(b4);switch(O.type){case"message_start":{let y=O.message;N0=y,s=y.usage;break}case"content_block_start":{let y=O.content_block;if(y.type==="text")r0={type:"text",text:""};else if(y.type==="thinking")L0={type:"thinking",thinking:""};else if(y.type==="redacted_thinking")b0={type:"redacted_thinking",data:""};else if(y.type==="tool_use")W0={type:"tool_use",id:y.id,name:y.name,input:{}},U4="";break}case"content_block_delta":{let y=O.delta;if(y.type==="text_delta"&&r0){let x=y.text;if(r0.text+=x,z?.(x),w)R=Date.now()-L,w=!1}else if(y.type==="thinking_delta"&&L0){let x=y.thinking;L0.thinking+=x,G?.(x),D+=Math.ceil(x.length/4)}else if(y.type==="redacted_thinking_delta"&&b0){let x=y.data;b0.data+=x,A?.(x),D+=Math.ceil(x.length/4)}else if(y.type==="input_json_delta"&&W0)U4+=y.partial_json;break}case"content_block_stop":{if(r0!==null)y0.push(r0),r0=null;else if(L0!==null)y0.push(L0),L0=null;else if(b0!==null)y0.push(b0),A?.(b0.data),b0=null;else if(W0!==null){try{W0.input=JSON.parse(U4)}catch{W0.input={}}y0.push(W0),B?.({id:W0.id,name:W0.name,input:W0.input}),W0=null,U4=""}break}case"message_delta":{let y=O;if(y.usage)s.output_tokens=y.usage.output_tokens;if(N0&&y.delta?.stop_reason)N0.stop_reason=y.delta.stop_reason;break}case"message_stop":break}}catch{}}}}finally{x4.releaseLock()}if(!N0)throw Error("No message received from API");N0.content=y0;let{costUSD:f0,estimatedSavingsUSD:v4}=$7(J,s),P0=J7(s);P0.estimatedSavingsUSD=v4;let O4=Date.now()-L;return{message:N0,usage:s,cacheMetrics:P0,costUSD:f0,durationMs:O4,ttftMs:R||O4,thinkingTokens:D}}import*as H5 from"readline";var X7={Read:"low",Glob:"low",Grep:"low",Task:"low",Write:"medium",Edit:"medium",NotebookEdit:"medium",Bash:"high"},V7=[/\brm\s+-rf\b/,/\brm\s+-r\b/,/\brm\s+[^-]/,/\bgit\s+push\s+--force\b/,/\bgit\s+reset\s+--hard\b/,/\bgit\s+clean\s+-fd\b/,/\bdrop\b/i,/\bdelete\b/i,/\btruncate\b/i,/\bformat\b/i,/\bdd\s+if=/,/\bshred\b/,/\b:\(\)\{\s*:\|:\s*&\s*\};\s*:\b/];function K7($,Z){let Q=X7[$]??"medium";if($==="Bash"){let J=String(Z.command??"");for(let X of V7)if(X.test(J))return"critical";if(/\bsudo\b/.test(J)||/\bchmod\b/.test(J))Q="high"}if($==="Write"||$==="Edit"){let J=String(Z.file_path??Z.path??"");if(/\.(env|pem|key|secret|credentials)/.test(J))Q="high";if(/\/\.ssh\//.test(J)||/\/\.gnupg\//.test(J))Q="critical"}return Q}function W7($,Z){switch($){case"Read":return`Read file: ${Z.file_path??"unknown"}`;case"Write":return`Write file: ${Z.file_path??"unknown"} (${String(Z.content??"").length} chars)`;case"Edit":return`Edit file: ${Z.file_path??"unknown"}`;case"Bash":return`Execute: ${String(Z.command??"").slice(0,100)}${String(Z.command??"").length>100?"...":""}`;case"Glob":return`Find files: ${Z.pattern??"*"}`;case"Grep":return`Search: "${Z.pattern??""}" in ${Z.path??"."}`;case"Task":return`Spawn agent: ${Z.subagent_type??"unknown"}`;default:return`Use tool: ${$}`}}class i6{cache={};cacheTimeout=300000;promptCallback;mode;constructor($="default",Z){this.mode=$,this.promptCallback=Z??this.defaultPrompt.bind(this)}async checkPermission($,Z){if(this.mode==="bypassPermissions")return{decision:"allow"};if(this.mode==="dontAsk")return{decision:"deny",reason:"Permission mode is dontAsk"};if(this.mode==="acceptEdits"){if(["Read","Write","Edit","Glob","Grep"].includes($))return{decision:"allow"}}if(this.mode==="plan"){if(["Read","Glob","Grep","Task"].includes($))return{decision:"allow"};return{decision:"deny",reason:"Plan mode - write operations disabled"}}let Q=this.getCacheKey($,Z),J=this.cache[Q];if(J&&Date.now()-J.timestamp<this.cacheTimeout){if(J.decision==="allowAlways")return{decision:"allow",reason:"Previously approved (always)"};if(J.decision==="denyAlways")return{decision:"deny",reason:"Previously denied (always)"}}let X=K7($,Z),V=W7($,Z),K={toolName:$,toolInput:Z,riskLevel:X,description:V,file:Z.file_path??Z.path,command:$==="Bash"?Z.command:void 0};if(this.mode==="interactive"||this.mode==="default"){let W=await this.promptCallback(K);if(W.decision==="allowAlways"||W.decision==="denyAlways")this.cache[Q]={decision:W.decision,timestamp:Date.now()};return W}return{decision:"allow"}}getCacheKey($,Z){if(["Read","Write","Edit"].includes($))return`${$}:${Z.file_path??Z.path??"unknown"}`;if($==="Bash"){let Q=String(Z.command??"").slice(0,100);return`${$}:${Q}`}return $}async defaultPrompt($){return new Promise((Z)=>{let Q=H5.createInterface({input:process.stdin,output:process.stdout}),X={low:"\x1B[32m",medium:"\x1B[33m",high:"\x1B[31m",critical:"\x1B[35m"}[$.riskLevel]??"\x1B[0m",V="\x1B[0m";if(console.log(""),console.log("\x1B[36m\u2501\u2501\u2501 Permission Required \u2501\u2501\u2501\x1B[0m"),console.log(`Tool: \x1B[1m${$.toolName}\x1B[0m`),console.log(`Risk: ${X}${$.riskLevel.toUpperCase()}\x1B[0m`),console.log(`Action: ${$.description}`),$.file)console.log(`File: ${$.file}`);if($.command)console.log(`Command: ${$.command.slice(0,200)}${$.command.length>200?"...":""}`);console.log("");let K="[y]es / [n]o / [a]lways / [d]eny always";Q.question(`Allow? ${K}: `,(W)=>{switch(Q.close(),W.trim().toLowerCase()){case"y":case"yes":Z({decision:"allow"});break;case"a":case"always":Z({decision:"allowAlways"});break;case"d":case"deny":case"deny always":Z({decision:"denyAlways"});break;case"n":case"no":default:Z({decision:"deny"});break}})})}clearCache(){this.cache={}}setMode($){this.mode=$,this.clearCache()}}var s6={readOnly:["Read","Glob","Grep","Task"],fileEdit:["Write","Edit","NotebookEdit"],system:["Bash"],network:[]};function EV($){return s6.readOnly.includes($)}function SV($){return s6.fileEdit.includes($)}function TV($){return s6.system.includes($)}var e6={tokenWarningThreshold:0.8,costUpdateInterval:5,toolSummaryInterval:3,envInfoOnStart:!0},o6={WARNING:0.8,CRITICAL:0.9,EMERGENCY:0.95};function H7($){let{current:Z,max:Q,threshold:J=o6.WARNING}=$;if(Q<=0)return"";let X=Z/Q;if(X<J)return"";let V=Q-Z,K=Math.round(X*100),W,H;if(X>=o6.EMERGENCY)W="emergency",H="\uD83D\uDEA8";else if(X>=o6.CRITICAL)W="critical",H="\u26A0\uFE0F";else W="warning",H="\u26A1";let q=[`${H} Token Usage ${W.toUpperCase()}`,"",`Current: ${Z.toLocaleString()} / ${Q.toLocaleString()} tokens (${K}%)`,`Remaining: ${V.toLocaleString()} tokens`];if(W==="emergency")q.push(""),q.push("Consider summarizing or compacting the conversation to continue.");else if(W==="critical")q.push(""),q.push("Approaching token limit. Consider wrapping up soon.");return q.join(`
44
+ `)}function q7($){let{cost:Z,previousCost:Q=0,currency:J="USD"}=$,X=Y7(J),V=q5(Z,X),K=Z-Q,W=q5(Math.abs(K),X),H=["\uD83D\uDCB0 Cost Update","",`Total: ${V} ${J}`];if(K!==0){let q=K>0?"+":"-";H.push(`This turn: ${q}${W} ${J}`)}return H.join(`
45
+ `)}function q5($,Z){if($<0.01)return`${Z}${$.toFixed(4)}`;else if($<1)return`${Z}${$.toFixed(3)}`;return`${Z}${$.toFixed(2)}`}function Y7($){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5"}[$]||$}function z7($){let{tools:Z,maxDisplay:Q=10}=$;if(Z.length===0)return"No tools used this session.";let J=new Map;for(let W of Z){let H=J.get(W.name)||0;J.set(W.name,H+1)}let X=[...J.entries()].sort((W,H)=>H[1]-W[1]),V=[`\uD83D\uDD27 Tool Usage Summary (${Z.length} total calls)`,""],K=X.slice(0,Q);for(let[W,H]of K)V.push(` \u2022 ${W}: ${H} call${H===1?"":"s"}`);if(X.length>Q){let W=X.length-Q;V.push(` ... and ${W} more tool${W===1?"":"s"}`)}return V.join(`
46
+ `)}function G7($){let{workingDirectory:Z,gitStatus:Q,platform:J=process.platform,shell:X=process.env.SHELL||"unknown"}=$,V=["\uD83D\uDCCD Environment Information","",`Working Directory: ${Z}`,`Platform: ${J}`,`Shell: ${X}`];if(Q){if(V.push(""),V.push("Git Status:"),V.push(` Branch: ${Q.branch}`),Q.ahead>0||Q.behind>0)V.push(` Ahead: ${Q.ahead}, Behind: ${Q.behind}`);let K=Q.staged.length+Q.unstaged.length+Q.untracked.length+Q.conflicted.length;if(K>0){if(V.push(` Changes: ${K} file${K===1?"":"s"}`),Q.staged.length>0)V.push(` Staged: ${Q.staged.length}`);if(Q.unstaged.length>0)V.push(` Unstaged: ${Q.unstaged.length}`);if(Q.untracked.length>0)V.push(` Untracked: ${Q.untracked.length}`);if(Q.conflicted.length>0)V.push(` Conflicted: ${Q.conflicted.length}`)}else V.push(" Working tree clean")}return V.join(`
47
+ `)}function Y5($){let{usage:Z,maxTokens:Q,totalCost:J,previousCost:X,toolsUsed:V,workingDirectory:K,gitStatus:W,turnNumber:H,config:q}=$,z={...e6,...q},G=[],A=Z.input_tokens+Z.output_tokens,B=H7({current:A,max:Q,threshold:z.tokenWarningThreshold});if(B)G.push(B);if(H%z.costUpdateInterval===0){let _=q7({cost:J,previousCost:X});G.push(_)}if(H%z.toolSummaryInterval===0&&V.length>0){let _=z7({tools:V});G.push(_)}if(H===1&&z.envInfoOnStart){let _=G7({workingDirectory:K,gitStatus:W});G.push(_)}if(G.length===0)return"";return["---","System Reminders:","",...G,"---"].join(`
48
+ `)}function f4($){if(!$||$.length===0)return 0;return Math.ceil($.length/4)}function z5($){switch($.type){case"text":return f4($.text);case"image":return 100;case"tool_use":let Z=JSON.stringify($.input);return f4($.name)+f4(Z)+10;case"tool_result":if(typeof $.content==="string")return f4($.content)+10;return $.content.reduce((Q,J)=>Q+z5(J),0)+10;case"thinking":return f4($.thinking);default:return 0}}function j7($){return 4+$.content.reduce((J,X)=>J+z5(X),0)}function t6($){if(!$||$.length===0)return 0;return $.reduce((Z,Q)=>Z+j7(Q),0)}function U7($){let Z=[];for(let Q of $.content)switch(Q.type){case"text":Z.push(Q.text);break;case"tool_use":Z.push(`[Tool: ${Q.name}(${JSON.stringify(Q.input)})]`);break;case"tool_result":let J=typeof Q.content==="string"?Q.content:Q.content.map((X)=>X.type==="text"?X.text:"[content]").join("");Z.push(`[Result: ${J.slice(0,500)}${J.length>500?"...":""}]`);break;case"thinking":Z.push(`[Thinking: ${Q.thinking.slice(0,200)}...]`);break}return Z.join(`
49
+ `)}function A7($){let Z=new Map;for(let Q of $)for(let J of Q.content)if(J.type==="tool_use")Z.set(J.id,{use:J});for(let Q of $)for(let J of Q.content)if(J.type==="tool_result"){let X=Z.get(J.tool_use_id);if(X)X.result=J}return Z}async function B7($){if(!$||$.length===0)return"";let Z=[];Z.push(`[Context Summary: ${$.length} messages compacted]
50
+ `);let Q=[];for(let X=0;X<$.length;X++){let V=$[X];if(!V)continue;let K=V.role.toUpperCase(),W=U7(V);for(let q of V.content)if(q.type==="tool_use")Q.push(`${q.name}`);let H=W.length>300?`${W.slice(0,300)}...`:W;Z.push(`${K}: ${H}
51
+ `)}if(Q.length>0){let X=Q.reduce((K,W)=>{return K[W]=(K[W]||0)+1,K},{}),V=Object.entries(X).map(([K,W])=>`${K}(${W})`).join(", ");Z.push(`
52
+ Tools used: ${V}
53
+ `)}let J=Z.join("");if(J.length>8000)J=J.slice(0,8000)+`
54
+ ...[truncated]`;return J}async function $2($,Z,Q={}){let{keepFirst:J=1,keepLast:X=5,preserveToolPairs:V=!0}=Q,K=t6($);if(K<=Z)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};if($.length<=J+X)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};let W=$.slice(0,J),H=$.slice(J,-X),q=$.slice(-X),G={role:"user",content:[{type:"text",text:`[Previous context has been compacted for continuity]
55
+
56
+ ${await B7(H)}`}]},A=[];if(V&&H.length>0){let R=A7(H),w=Array.from(R.values()).slice(-3).filter((D)=>D.result&&!D.result.is_error);for(let D of w)if(A.push(D.use),D.result)A.push(D.result)}let B=[...W,G];if(A.length>0)B.push({role:"assistant",content:A.filter((R)=>R.type==="tool_use")}),B.push({role:"user",content:A.filter((R)=>R.type==="tool_result")});B.push(...q);let _=t6(B),L=$.length-B.length;return console.log(`Context compaction: ${$.length} -> ${B.length} messages, ${K} -> ${_} tokens`),{messages:B,messagesRemoved:L,tokensBefore:K,tokensAfter:_,didCompact:!0}}function G5($,Z,Q=0.9){if($.length<8)return!1;let J=t6($),X=Math.floor(Z*Q);return J>=X}function Z2($){if(!$.didCompact)return{reductionPercent:0,tokensSaved:0};let Z=$.tokensBefore-$.tokensAfter,Q=Z/$.tokensBefore*100;return{reductionPercent:Math.round(Q*100)/100,tokensSaved:Z}}async function cV($,Z){let{apiKey:Q,model:J="claude-sonnet-4-6",maxTokens:X=4096,systemPrompt:V,tools:K,permissionMode:W,workingDirectory:H,gitStatus:q=null,reminderConfig:z,cacheConfig:G=Y6,thinking:A,extendedThinking:B,onText:_,onThinking:L,onToolUse:R,onToolResult:w,onMetrics:D,onReminder:I,onPermissionRequest:S,signal:M}=Z,d=new i6(W,S),k=[...$],l=[],K0=[],t=0,a0=0,x4=0,H6=0,N0=0,y0=0,s={cacheHits:0,cacheMisses:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,cacheHitRate:0,estimatedSavingsUSD:0},r0={...e6,...z},L0=!0;while(L0){if(M?.aborted)break;x4++;let b0=l[l.length-1],W0=Y5({usage:b0?.usage??{input_tokens:0,output_tokens:0},maxTokens:X,totalCost:t,previousCost:H6,toolsUsed:K0,workingDirectory:H,gitStatus:q,turnNumber:x4,config:r0});if(W0)I?.(W0);if(G5(k,X)){let O=await $2(k,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){k.length=0,k.push(...O.messages),N0++;let y=O.tokensBefore-O.tokensAfter;y0+=y;let x=Z2(O);console.log(`Context compacted: ${x.reductionPercent}% reduction, ${x.tokensSaved} tokens saved`)}}let U4=L7(k,V,W0),$5=await W5(U4,{apiKey:Q,model:J,maxTokens:X,systemPrompt:V,cacheConfig:G,thinking:A,extendedThinking:B,tools:K.map((O)=>({name:O.name,description:O.description,input_schema:O.input_schema})),onToken:_,onThinking:L,onToolUse:R,signal:M}),{message:f0,usage:v4,cacheMetrics:P0,costUSD:O4,durationMs:h,ttftMs:D0}=$5,n0={model:J,messageCount:k.length,messageTokens:v4.input_tokens+v4.output_tokens,usage:v4,cacheMetrics:P0,durationMs:h,ttftMs:D0,costUSD:O4,stopReason:f0.stop_reason,requestId:f0.id};if(l.push(n0),H6=t,t+=O4,a0+=h,P0)s.cacheHits+=P0.cacheHits,s.cacheMisses+=P0.cacheMisses,s.totalCacheReadTokens+=P0.totalCacheReadTokens,s.totalCacheWriteTokens+=P0.totalCacheWriteTokens,s.estimatedSavingsUSD+=P0.estimatedSavingsUSD;let y4=s.cacheHits+s.cacheMisses;if(s.cacheHitRate=y4>0?s.cacheHits/y4:0,D?.(n0),k.push({role:"assistant",content:f0.content}),f0.stop_reason==="end_turn"||f0.stop_reason==="stop_sequence"){L0=!1;break}if(f0.stop_reason==="max_tokens"){let O=await $2(k,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){k.length=0,k.push(...O.messages),N0++;let y=O.tokensBefore-O.tokensAfter;y0+=y;let x=Z2(O);console.log(`Context compacted: ${x.reductionPercent}% reduction, ${x.tokensSaved} tokens saved`);continue}else{L0=!1;break}}let A4=f0.content.filter((O)=>O.type==="tool_use");if(K0.push(...A4),A4.length===0){L0=!1;break}let b4=[];if(M?.aborted);else{let O=A4.map(async(x)=>{let n6=K.find((h0)=>h0.name===x.name);if(!n6)return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Error: Unknown tool "${x.name}"`,is_error:!0},toolResult:null};let q6=await d.checkPermission(n6.name,x.input);if(q6.decision==="deny"||q6.decision==="denyAlways")return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Permission denied for tool "${x.name}"${q6.reason?`: ${q6.reason}`:""}`,is_error:!0},toolResult:null};try{let h0=await n6.handler(x.input,{workingDirectory:H,permissionMode:W,abortSignal:M});return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:h0.content,is_error:h0.is_error},toolResult:{id:x.id,result:h0}}}catch(h0){let l9=h0 instanceof Error?h0.message:String(h0);return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Error: ${l9}`,is_error:!0},toolResult:null}}}),y=await Promise.all(O);for(let x of y)if(b4.push(x.result),x.toolResult)w?.(x.toolResult)}k.push({role:"user",content:b4})}return{messages:k,metrics:l,totalCost:t,totalDuration:a0,totalCacheMetrics:s,compactionCount:N0,totalTokensCompacted:y0}}function L7($,Z,Q){if(Q&&$.length>0){let J=[...$];for(let X=J.length-1;X>=0;X--){let V=J[X];if(V&&V.role==="user"){let K={role:"user",content:Array.isArray(V.content)?_7(V.content,Q):[{type:"text",text:`${String(V.content)}
57
+
58
+ ${Q}`}]};J[X]=K;break}}return J}return $}function _7($,Z){if($.length>0){let J=$[$.length-1];if(J&&J.type==="text"){let X={type:"text",text:`${J.text}
59
+
60
+ ${Z}`};return[...$.slice(0,-1),X]}}let Q={type:"text",text:`
61
+
62
+ ${Z}`};return[...$,Q]}function Q2($){if($<0.01)return`$${$.toFixed(4)}`;return`$${$.toFixed(2)}`}function lV($){let Z=Q2($.costUSD),Q=`${$.usage.input_tokens.toLocaleString()} input, ${$.usage.output_tokens.toLocaleString()} output`;if($.usage.cache_read_input_tokens||$.usage.cache_creation_input_tokens){let J=$.usage.cache_read_input_tokens?.toLocaleString()??"0",X=$.usage.cache_creation_input_tokens?.toLocaleString()??"0";return`Cost: ${Z} | Tokens: ${Q} | Cache: ${J} read, ${X} write`}return`Cost: ${Z} | Tokens: ${Q}`}function pV($){let Z=Q2($.costUSD),Q=$.usage.input_tokens+$.usage.output_tokens;return`Cost: ${Z} | Tokens: ${Q.toLocaleString()}`}function aV($){let Z=Q2($.estimatedSavingsUSD);return`Cache: ${($.cacheHitRate*100).toFixed(1)}% hit rate | ${$.totalCacheReadTokens.toLocaleString()} read | ${$.totalCacheWriteTokens.toLocaleString()} written | Saved: ${Z}`}import{homedir as w7}from"os";import{join as g0}from"path";class R7{sessionsDir;currentSessionId=null;currentSessionFile=null;writeQueue=Promise.resolve();constructor($){this.sessionsDir=$??g0(w7(),".claude","sessions")}async init(){try{await Bun.write(g0(this.sessionsDir,".gitkeep"),"")}catch{}}generateSessionId(){let $=Date.now().toString(36),Z=Math.random().toString(36).slice(2,8);return`${$}-${Z}`}async createSession($){await this.init();let Z=this.generateSessionId();this.currentSessionId=Z,this.currentSessionFile=g0(this.sessionsDir,`${Z}.jsonl`);let Q={id:Z,created:Date.now(),updated:Date.now(),model:$.model,workingDirectory:$.workingDirectory,agentName:$.agentName,agentColor:$.agentColor,teamName:$.teamName};await this.appendEntry(Q);let J={type:"context",timestamp:Date.now(),workingDirectory:$.workingDirectory};return await this.appendEntry(J),Z}async resumeSession($){let Z=g0(this.sessionsDir,`${$}.jsonl`);try{let Q=await Bun.file(Z).text();if(!Q)return null;let J=Q.trim().split(`
63
+ `),X=[];for(let V of J)try{X.push(JSON.parse(V))}catch{}return this.parseSessionEntries(X)}catch{return null}}parseSessionEntries($){let Z=null,Q=[],J=[],X=[],V=null;for(let K of $){if(!("type"in K)&&"id"in K&&"created"in K){Z=K;continue}if("type"in K){let W=K;switch(W.type){case"message":Q.push(W.data);break;case"tool_use":J.push(W);break;case"metrics":X.push(W.data);break;case"context":V=W;break}}}if(!Z)Z={id:"unknown",created:Date.now(),updated:Date.now(),model:"claude-sonnet-4-6",workingDirectory:process.cwd()};return{metadata:Z,messages:Q,tools:J,metrics:X,context:V}}async appendEntry($){if(!this.currentSessionFile)return;this.writeQueue=this.writeQueue.then(async()=>{let Z=JSON.stringify($)+`
64
+ `,Q=Bun.file(this.currentSessionFile),J=await Q.exists()?await Q.text():"";await Bun.write(this.currentSessionFile,J+Z)}),await this.writeQueue}async saveMessage($){let Z={type:"message",timestamp:Date.now(),data:$};await this.appendEntry(Z),await this.updateTimestamp()}async saveToolUse($,Z,Q,J,X){let V={type:"tool_use",timestamp:Date.now(),toolId:$,toolName:Z,input:Q,result:J,isError:X};await this.appendEntry(V)}async saveMetrics($){let Z={type:"metrics",timestamp:Date.now(),data:$};await this.appendEntry(Z)}async updateTimestamp(){if(!this.currentSessionFile||!this.currentSessionId)return}async listSessions($=20){await this.init();let Z=Bun.file(this.sessionsDir),Q=[];try{let X=[...new Bun.Glob("*.jsonl").scanSync(this.sessionsDir)],V=await Promise.all(X.map(async(K)=>{let W=g0(this.sessionsDir,K),H=await Bun.file(W).stat();return{file:K,fullPath:W,mtime:H?.mtime??new Date(0)}}));V.sort((K,W)=>W.mtime.getTime()-K.mtime.getTime());for(let{file:K,fullPath:W}of V.slice(0,$)){let H=K.replace(".jsonl",""),q=await this.getSessionSummary(H,W);if(q)Q.push(q)}}catch{}return Q}async getSessionSummary($,Z){let Q=Z??g0(this.sessionsDir,`${$}.jsonl`);try{let J=await Bun.file(Q).text();if(!J)return null;let X=J.trim().split(`
65
+ `),V=null,K=0,W=0,H=0,q=0,z;for(let G of X)try{let A=JSON.parse(G);if(A.id&&A.created)V=A;else if(A.type==="message"){K++;let B=A.data;if(!z&&B.role==="user"){let _=B.content.find((L)=>L.type==="text");if(_&&"text"in _){if(z=_.text.slice(0,100),_.text.length>100)z+="..."}}}else if(A.type==="metrics")W+=A.data.costUSD,H+=A.data.usage.input_tokens,q+=A.data.usage.output_tokens}catch{}if(!V)return null;return{id:$,created:V.created,updated:V.updated,model:V.model,messageCount:K,totalCost:W,totalTokens:{input:H,output:q},firstMessage:z,workingDirectory:V.workingDirectory}}catch{return null}}getCurrentSessionId(){return this.currentSessionId}async exportSession($,Z,Q){let J=await this.resumeSession($);if(!J)throw Error(`Session not found: ${$}`);let X,V;switch(Z){case"jsonl":{let W=g0(this.sessionsDir,`${$}.jsonl`);X=await Bun.file(W).text(),V="jsonl";break}case"json":{X=JSON.stringify(J,null,2),V="json";break}case"markdown":{X=this.sessionToMarkdown(J),V="md";break}default:throw Error(`Unsupported format: ${Z}`)}let K=Q??g0(process.cwd(),`session-${$}.${V}`);return await Bun.write(K,X),K}sessionToMarkdown($){let Z=[];Z.push(`# Session: ${$.metadata.id}`),Z.push(""),Z.push(`**Created:** ${new Date($.metadata.created).toISOString()}`),Z.push(`**Model:** ${$.metadata.model}`),Z.push(`**Working Directory:** ${$.metadata.workingDirectory}`),Z.push(""),Z.push("## Conversation"),Z.push("");for(let Q of $.messages){let J=Q.role==="user"?"**User**":"**Claude**";Z.push(`### ${J}`),Z.push("");for(let X of Q.content)if(X.type==="text")Z.push(X.text),Z.push("");else if(X.type==="tool_use"){let V=X;Z.push(`\`\`\`tool:${V.name}`),Z.push(JSON.stringify(V.input,null,2)),Z.push("```"),Z.push("")}else if(X.type==="tool_result"){let V=X;Z.push(`**Result**${V.is_error?" (error)":""}:`),Z.push("```"),Z.push(typeof V.content==="string"?V.content:JSON.stringify(V.content,null,2)),Z.push("```"),Z.push("")}}if($.metrics.length>0){Z.push("## Metrics"),Z.push("");let Q=$.metrics.reduce((V,K)=>V+K.costUSD,0),J=$.metrics.reduce((V,K)=>V+K.usage.input_tokens,0),X=$.metrics.reduce((V,K)=>V+K.usage.output_tokens,0);Z.push(`- **Total Cost:** $${Q.toFixed(4)}`),Z.push(`- **Total Input Tokens:** ${J.toLocaleString()}`),Z.push(`- **Total Output Tokens:** ${X.toLocaleString()}`),Z.push(`- **API Calls:** ${$.metrics.length}`)}return Z.join(`
66
+ `)}async deleteSession($){let Z=g0(this.sessionsDir,`${$}.jsonl`);try{if(await Bun.file(Z).exists()){let{unlink:J}=await import("fs/promises");return await J(Z),!0}return!1}catch{return!1}}}function C7($){let Z=new Date($.created),Q=new Date($.updated),J=N7(Q),X=[];X.push(`\x1B[1m${$.id}\x1B[0m (${J})`),X.push(` Model: ${$.model} | Messages: ${$.messageCount}`);let V=$.totalCost<0.01?`$${$.totalCost.toFixed(4)}`:`$${$.totalCost.toFixed(2)}`;if(X.push(` Cost: ${V} | Tokens: ${$.totalTokens.input.toLocaleString()} in, ${$.totalTokens.output.toLocaleString()} out`),$.firstMessage)X.push(` Preview: ${$.firstMessage}`);return X.push(` Directory: ${$.workingDirectory}`),X.join(`
67
+ `)}function N7($){let Q=new Date().getTime()-$.getTime(),J=Math.floor(Q/60000),X=Math.floor(Q/3600000),V=Math.floor(Q/86400000);if(J<1)return"just now";if(J<60)return`${J}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return $.toLocaleDateString()}function sV($){if($.length===0){console.log("No sessions found."),console.log(`
68
+ Start a new conversation to create a session.`);return}console.log(`\x1B[1mRecent Sessions (${$.length})\x1B[0m
69
+ `);for(let Z of $)console.log(C7(Z)),console.log("");console.log("To resume a session:"),console.log(" claude-remake --resume <session-id>")}import{dlopen as P7,suffix as D7}from"bun:ffi";import{join as X4,dirname as j5}from"path";import{fileURLToPath as U5}from"url";var J4=null;function A5(){if(J4)return J4;let $=j5(U5(import.meta.url)),Z=[X4($,"..","..","native"),X4($,"..","native")],Q=["index.darwin-arm64.node","index.darwin-x64.node","index.node"];for(let X of Z)for(let V of Q){let K=X4(X,V);try{let W=v(K);if(W&&(W.highlightCode||W.highlight_code))return J4={highlight_code:W.highlightCode||W.highlight_code,highlight_markdown:W.highlightMarkdown||W.highlight_markdown,highlight_diff:W.highlightDiff||W.highlight_diff,search_files:W.searchFiles||W.search_files,count_tokens:W.countTokens||W.count_tokens,calculate_diff:W.calculateDiff||W.calculate_diff,compact_content:W.compactContent||W.compact_content,count_tool_use:W.countToolUse||W.count_tool_use,find_tool_pairs:W.findToolPairs||W.find_tool_pairs,find_common_patterns:W.findCommonPatterns||W.find_common_patterns,validate_multi_edits:W.validateMultiEdits||W.validate_multi_edits,preview_multi_edits:W.previewMultiEdits||W.preview_multi_edits,apply_multi_edits:W.applyMultiEdits||W.apply_multi_edits},J4}catch{continue}}let J=Z.map((X)=>X4(X,`claude_code_native.${D7}`));for(let X of J)try{return J4=P7(X,{highlight_code:{args:["cstring","cstring"],returns:"pointer"},highlight_markdown:{args:["cstring"],returns:"pointer"},highlight_diff:{args:["cstring","cstring","pointer"],returns:"pointer"},search_files:{args:["cstring","cstring","pointer"],returns:"pointer"},count_tokens:{args:["cstring"],returns:"u32"},calculate_diff:{args:["cstring","cstring"],returns:"pointer"},compact_content:{args:["cstring","u32","cstring"],returns:"pointer"}}).symbols,J4}catch{continue}return console.warn("Native module not available, using JS fallback"),B5()}function ZK(){try{return A5(),J4!==null}catch{return!1}}function B5(){return{highlight_code:($,Z)=>{let Q=new Set(["function","const","let","var","return","if","else","for","while","class","interface","type","import","export","from","async","await","try","catch","throw","new","this","extends","implements","static","public","private","protected","readonly","abstract","enum","namespace"]),J=new Set(["string","number","boolean","void","null","undefined","any","never","object","symbol","bigint","true","false"]),X={reset:"\x1B[0m",keyword:"\x1B[38;2;180;142;173m",string:"\x1B[38;2;163;190;140m",number:"\x1B[38;2;208;135;112m",type:"\x1B[38;2;191;97;106m",function:"\x1B[38;2;143;161;179m",comment:"\x1B[38;2;108;153;139m",default:"\x1B[38;2;192;197;206m"};return{html:$.split(`
70
+ `).map((W)=>{if(W.trim().startsWith("//")||W.trim().startsWith("#"))return`${X.comment}${W}${X.reset}`;let H=W.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*?\1/g,(q)=>{return`${X.string}${q}${X.default}`});return H=H.replace(/\b(\d+\.?\d*)\b/g,`${X.number}$1${X.default}`),H=H.replace(/\b([a-z]+)\b/gi,(q)=>{if(Q.has(q))return`${X.keyword}${q}${X.default}`;if(J.has(q))return`${X.type}${q}${X.default}`;return q}),H=H.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/g,(q,z)=>{return`${X.function}${z}${X.default}(`}),H}).join(`
71
+ `)+X.reset,theme:"fallback"}},highlight_markdown:($)=>{return{html:$+"\x1B[0m",theme:"fallback"}},highlight_diff:($,Z,Q)=>{let H=$.split(`
72
+ `),q=Z.split(`
73
+ `),z="",G=0,A=0,B=0;if(Q?.file_path)z+=`\x1B[38;2;143;161;179m${Q.file_path}\x1B[0m
74
+ `;let _=[],L=Array.from({length:H.length+1},()=>Array.from({length:q.length+1},()=>0));for(let d=0;d<=H.length;d++)for(let k=0;k<=q.length;k++)if(d===0||k===0)L[d][k]=0;else if(H[d-1]===q[k-1])L[d][k]=L[d-1][k-1]+1;else L[d][k]=Math.max(L[d-1][k],L[d][k-1]);let R=H.length,w=q.length,D=new Set;while(R>0&&w>0)if(H[R-1]===q[w-1])D.add(`${R-1}:${w-1}`),_.unshift(H[R-1]),R--,w--;else if(L[R-1][w]>L[R][w-1])R--;else w--;let I=0,S=0,M=0;while(I<H.length||S<q.length){while(M<_.length&&I<H.length&&S<q.length&&H[I]===_[M]&&q[S]===_[M])I++,S++,M++;let d=I+1,k=S+1,l=0,K0=0,t=[];while(I<H.length&&(M>=_.length||H[I]!==_[M]))t.push(`\x1B[38;2;191;97;106m-${H[I]}\x1B[0m`),I++,l++,A++;while(S<q.length&&(M>=_.length||q[S]!==_[M]))t.push(`\x1B[38;2;163;190;140m+${q[S]}\x1B[0m`),S++,K0++,G++;if(l>0||K0>0)B++,z+=`\x1B[38;2;108;153;139m@@ -${d},${l} +${k},${K0} @@\x1B[0m
75
+ `,z+=t.join(`
76
+ `)+`
77
+ `}return{output:z,additions:G,deletions:A,hunks:B}},search_files:($,Z,Q)=>{return{matches:[],total_count:0,files_searched:0}},count_tokens:($)=>{return Math.ceil($.length/4)},calculate_diff:($,Z)=>{let Q=$.split(`
78
+ `),J=Z.split(`
79
+ `),X=[];if($!==Z)X.push({oldStart:1,oldLines:Q.length,newStart:1,newLines:J.length,content:`- ${Q.join(`
80
+ - `)}
81
+ + ${J.join(`
82
+ + `)}`});return X},compact_content:($,Z,Q="truncate")=>{let X=Z*4;if($.length<=X)return $;switch(Q){case"truncate":return $.slice(0,X/2)+`
83
+
84
+ ... [truncated] ...
85
+
86
+ `+$.slice(-X/2);case"summarize":let V=Math.floor(X/4);return`=== BEGINNING ===
87
+ `+$.slice(0,V)+`
88
+
89
+ === END ===
90
+ `+$.slice(-V);case"extract":return $.split(`
91
+ `).filter((H)=>H.trim().startsWith("#")||H.trim().startsWith("function")||H.trim().startsWith("const")||H.trim().startsWith("class")||H.trim().startsWith("export")||H.trim().startsWith("import")).slice(0,X/50).join(`
92
+ `);default:return $.slice(0,X)}},validate_multi_edits:($)=>{let Z=[],Q=new Map,J=v("fs");for(let X of $)try{if(!J.existsSync(X.filePath)){Z.push(`File not found: ${X.filePath}`);continue}if(!Q.has(X.filePath)){let K=J.readFileSync(X.filePath,"utf-8");Q.set(X.filePath,K)}let V=Q.get(X.filePath);if(!V.includes(X.oldString)){Z.push(`String not found in ${X.filePath}: "${F7(X.oldString,50)}"`);continue}if(!X.replaceAll){let K=(V.match(new RegExp(J2(X.oldString),"g"))||[]).length;if(K>1)Z.push(`String appears ${K} times in ${X.filePath}. Use replaceAll or provide more context.`)}}catch(V){Z.push(`Error reading ${X.filePath}: ${V}`)}return Z},preview_multi_edits:($)=>{let Z=[],Q=new Map,J=v("fs");for(let X of $)try{if(!J.existsSync(X.filePath))continue;let V=J.readFileSync(X.filePath,"utf-8"),K=X.replaceAll?(V.match(new RegExp(J2(X.oldString),"g"))||[]).length:1;Q.set(X.filePath,(Q.get(X.filePath)||0)+K)}catch{}for(let[X,V]of Q)Z.push({filePath:X,replacementCount:V});return Z},apply_multi_edits:($)=>{let Z=B5().validate_multi_edits($);if(Z.length>0)return{success:!1,filesModified:[],totalReplacements:0,error:Z.join(`
93
+ `),rolledBack:!1};let Q=new Map,J=new Set($.map((H)=>H.filePath)),X=v("fs");for(let H of J)try{Q.set(H,X.readFileSync(H,"utf-8"))}catch(q){return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to backup ${H}: ${q}`,rolledBack:!1}}let V=new Map;for(let[H,q]of Q)V.set(H,q);let K=0;for(let H of $){let q=V.get(H.filePath);if(!q)continue;if(H.replaceAll){let z=(q.match(new RegExp(J2(H.oldString),"g"))||[]).length;V.set(H.filePath,q.split(H.oldString).join(H.newString)),K+=z}else V.set(H.filePath,q.replace(H.oldString,H.newString)),K+=1}let W=[];for(let[H,q]of V){let z=Q.get(H);if(q!==z)try{Bun.write(H,q),W.push(H)}catch(G){for(let[A,B]of Q)try{Bun.write(A,B)}catch{}return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to write ${H}: ${G}. All changes rolled back.`,rolledBack:!0}}}return{success:!0,filesModified:W,totalReplacements:K,error:void 0,rolledBack:!1}},count_tool_use:($)=>{let Z={};for(let Q of $)if(Q.tool_use)for(let J of Q.tool_use)Z[J.name]=(Z[J.name]||0)+1;return Z},find_tool_pairs:($,Z)=>{let Q={};for(let J of $)if(J.tool_use&&J.tool_use.length>=2)for(let X=0;X<J.tool_use.length-1;X++){let V=J.tool_use[X]?.name,K=J.tool_use[X+1]?.name;if(V&&K){if(!Q[V])Q[V]={};Q[V][K]=(Q[V][K]||0)+1}}return Q},find_common_patterns:($)=>{let Z=[],Q=new Map,J=0;for(let X of $)if(X.tool_use&&X.tool_use.length>=2)for(let V=0;V<X.tool_use.length-1;V++){let K=X.tool_use[V]?.name,W=X.tool_use[V+1]?.name;if(K&&W){let H=`${K}|${W}`;Q.set(H,(Q.get(H)||0)+1),J++}}for(let[X,V]of Q){let[K,W]=X.split("|");Z.push({tools:[K,W],count:V,percentage:J>0?V/J*100:0})}return Z.sort((X,V)=>V.count-X.count).slice(0,10)}}}var V4=A5();function QK($,Z){return V4.highlight_code($,Z)}function JK($){return V4.highlight_markdown($)}function XK($,Z,Q){return V4.highlight_diff($,Z,Q)}function VK($,Z){return V4.calculate_diff($,Z)}function X2($){return V4.validate_multi_edits($)}function L5($){return V4.preview_multi_edits($)}function _5($){return V4.apply_multi_edits($)}function F7($,Z){if($.length<=Z)return $;return $.slice(0,Z)+"..."}function J2($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var z6=null;function M7(){if(z6)return z6;let $=j5(U5(import.meta.url)),Z=process.platform==="darwin"?"libquant_rust.dylib":process.platform==="linux"?"libquant_rust.so":"quant_rust.dll",Q=[X4($,"..","..","node_modules","@ebowwa","quant-rust","native",`${process.platform}-${process.arch}`,Z),X4($,"..","..","..","@ebowwa","quant-rust","native",`${process.platform}-${process.arch}`,Z),X4($,"..","..","node_modules","@ebowwa","quant-rust","target","release",Z)];for(let J of Q)try{let{existsSync:X}=v("fs");if(!X(J))continue;let{dlopen:V,FFIType:K,ptr:W}=v("bun:ffi");return z6=V(J,{quant_version:{returns:K.cstring,args:[]},quant_last_error:{returns:K.cstring,args:[]},quant_clear_error:{returns:K.void,args:[]},quant_ohlcv_new:{returns:K.cstring,args:[K.u64,K.f64,K.f64,K.f64,K.f64,K.f64]},quant_amm_new:{returns:K.cstring,args:[K.f64,K.f64,K.f64]},quant_amm_calculate_cost:{returns:K.cstring,args:[K.f64,K.f64,K.bool,K.f64]},quant_amm_price_impact:{returns:K.cstring,args:[K.f64,K.f64,K.bool,K.f64]},quant_lmsr_price:{returns:K.cstring,args:[K.f64,K.f64,K.f64]},quant_lmsr_cost:{returns:K.cstring,args:[K.f64,K.f64,K.f64,K.bool,K.f64]},quant_detect_arbitrage:{returns:K.cstring,args:[K.f64,K.f64]},quant_convert_odds:{returns:K.cstring,args:[K.f64,K.i32]},quant_mean:{returns:K.f64,args:[K.ptr,K.usize]},quant_std_dev:{returns:K.f64,args:[K.ptr,K.usize]},quant_variance:{returns:K.f64,args:[K.ptr,K.usize]},quant_correlation:{returns:K.f64,args:[K.ptr,K.ptr,K.usize]},quant_free_string:{returns:K.void,args:[K.ptr]}}).symbols,z6}catch{continue}return null}var b=M7();function i0($){if(!$)throw Error(b?.quant_last_error()||"Unknown quant error");return JSON.parse($)}function h4($){let{ptr:Z}=v("bun:ffi"),Q=new Float64Array($);return{buffer:Q,ptr:Z(Q)}}function KK(){if(!b)return"not available";return b.quant_version()}function WK(){return b!==null}function HK($,Z,Q,J,X,V){if(!b)return{timestamp:$,open:Z,high:Q,low:J,close:X,volume:V};let K=b.quant_ohlcv_new(BigInt($),Z,Q,J,X,V);return i0(K)}function qK($,Z,Q){if(!b){let X=$*Z;return{pool_yes:$,pool_no:Z,k:X,fee:Q,price_yes:Z/X,price_no:$/X}}let J=b.quant_amm_new($,Z,Q);return i0(J)}function YK($,Z,Q,J){if(!b){let W=typeof Q==="string"?Q==="yes":Q,H=$*Z;if(W){let q=H/($+J);return Math.abs(q-Z)}else{let q=H/(Z+J);return Math.abs(q-$)}}let X=typeof Q==="string"?Q==="yes":Q,V=b.quant_amm_calculate_cost($,Z,X,J),K=i0(V);return Math.abs(K.cost)}function zK($,Z,Q,J){if(!b){let K=typeof Q==="string"?Q==="yes":Q,W=$*Z,H=K?Z/W:$/W,q=K?$+J:$,z=K?Z:Z+J,G=K?z/W:q/W;return{price_before:H,price_after:G,price_impact:Math.abs(G-H)/H,slippage:Math.abs(G-H)}}let X=typeof Q==="string"?Q==="yes":Q,V=b.quant_amm_price_impact($,Z,X,J);return i0(V)}function GK($,Z,Q){if(!b){let X=Math.exp($/Q),V=Math.exp(Z/Q),K=X+V,W=X/K,H=V/K;return{yes_price:W,no_price:H,spread:Math.abs(W-H)}}let J=b.quant_lmsr_price($,Z,Q);return i0(J)}function jK($,Z,Q,J,X){if(!b){let W=typeof J==="string"?J==="yes":J,H=Q*Math.log(Math.exp($/Q)+Math.exp(Z/Q)),q=W?$+X:$,z=W?Z:Z+X,G=Q*Math.log(Math.exp(q/Q)+Math.exp(z/Q));return{cost:G-H,avg_price:(G-H)/X}}let V=typeof J==="string"?J==="yes":J,K=b.quant_lmsr_cost($,Z,Q,V,X);return i0(K)}function UK($,Z){if(!b){let J=$+Z,X=J<1;return{has_arbitrage:X,yes_price:$,no_price:Z,total:J,profit_per_share:X?1-J:0}}let Q=b.quant_detect_arbitrage($,Z);return i0(Q)}var I7={probability:0,decimal:1,american:2};function AK($,Z){if(!b){let J;switch(Z){case"probability":J=$;break;case"decimal":J=1/$;break;case"american":J=$>0?100/($+100):-$/(-$+100);break}let X=1/J,V=J>=0.5?-100/(J-1):(1-J)/J*100;return{probability:J,decimal_odds:X,american_odds:Math.round(V)}}let Q=b.quant_convert_odds($,I7[Z]??0);return i0(Q)}function BK($){if($.length===0)return NaN;if(!b)return $.reduce((Q,J)=>Q+J,0)/$.length;let{ptr:Z}=h4($);return b.quant_mean(Z,$.length)}function LK($){if($.length===0)return NaN;if(!b){let Q=$.reduce((X,V)=>X+V,0)/$.length,J=$.map((X)=>Math.pow(X-Q,2));return Math.sqrt(J.reduce((X,V)=>X+V,0)/$.length)}let{ptr:Z}=h4($);return b.quant_std_dev(Z,$.length)}function _K($){if($.length===0)return NaN;if(!b){let Q=$.reduce((X,V)=>X+V,0)/$.length;return $.map((X)=>Math.pow(X-Q,2)).reduce((X,V)=>X+V,0)/$.length}let{ptr:Z}=h4($);return b.quant_variance(Z,$.length)}function wK($,Z){if($.length===0||Z.length===0||$.length!==Z.length)return NaN;if(!b){let X=$.length,V=$.reduce((z,G)=>z+G,0)/X,K=Z.reduce((z,G)=>z+G,0)/X,W=$.reduce((z,G,A)=>z+(G-V)*(Z[A]-K),0)/X,H=$.reduce((z,G)=>z+Math.pow(G-V,2),0)/X,q=Z.reduce((z,G)=>z+Math.pow(G-K,2),0)/X;return W/Math.sqrt(H*q)}let{ptr:Q}=h4($),{ptr:J}=h4(Z);return b.quant_correlation(Q,J,$.length)}var V2=($,Z,Q)=>{let J=$ instanceof RegExp?w5($,Q):$,X=Z instanceof RegExp?w5(Z,Q):Z,V=J!==null&&X!=null&&E7(J,X,Q);return V&&{start:V[0],end:V[1],pre:Q.slice(0,V[0]),body:Q.slice(V[0]+J.length,V[1]),post:Q.slice(V[1]+X.length)}},w5=($,Z)=>{let Q=Z.match($);return Q?Q[0]:null},E7=($,Z,Q)=>{let J,X,V,K=void 0,W,H=Q.indexOf($),q=Q.indexOf(Z,H+1),z=H;if(H>=0&&q>0){if($===Z)return[H,q];J=[],V=Q.length;while(z>=0&&!W){if(z===H)J.push(z),H=Q.indexOf($,z+1);else if(J.length===1){let G=J.pop();if(G!==void 0)W=[G,q]}else{if(X=J.pop(),X!==void 0&&X<V)V=X,K=q;q=Q.indexOf(Z,z+1)}z=H<q&&H>=0?H:q}if(J.length&&K!==void 0)W=[V,K]}return W};var R5="\x00SLASH"+Math.random()+"\x00",C5="\x00OPEN"+Math.random()+"\x00",W2="\x00CLOSE"+Math.random()+"\x00",N5="\x00COMMA"+Math.random()+"\x00",P5="\x00PERIOD"+Math.random()+"\x00",S7=new RegExp(R5,"g"),T7=new RegExp(C5,"g"),k7=new RegExp(W2,"g"),x7=new RegExp(N5,"g"),v7=new RegExp(P5,"g"),O7=/\\\\/g,y7=/\\{/g,b7=/\\}/g,f7=/\\,/g,h7=/\\./g,g7=1e5;function K2($){return!isNaN($)?parseInt($,10):$.charCodeAt(0)}function d7($){return $.replace(O7,R5).replace(y7,C5).replace(b7,W2).replace(f7,N5).replace(h7,P5)}function u7($){return $.replace(S7,"\\").replace(T7,"{").replace(k7,"}").replace(x7,",").replace(v7,".")}function D5($){if(!$)return[""];let Z=[],Q=V2("{","}",$);if(!Q)return $.split(",");let{pre:J,body:X,post:V}=Q,K=J.split(",");K[K.length-1]+="{"+X+"}";let W=D5(V);if(V.length)K[K.length-1]+=W.shift(),K.push.apply(K,W);return Z.push.apply(Z,K),Z}function F5($,Z={}){if(!$)return[];let{max:Q=g7}=Z;if($.slice(0,2)==="{}")$="\\{\\}"+$.slice(2);return g4(d7($),Q,!0).map(u7)}function m7($){return"{"+$+"}"}function c7($){return/^-?0\d/.test($)}function l7($,Z){return $<=Z}function p7($,Z){return $>=Z}function g4($,Z,Q){let J=[],X=V2("{","}",$);if(!X)return[$];let V=X.pre,K=X.post.length?g4(X.post,Z,!1):[""];if(/\$$/.test(X.pre))for(let W=0;W<K.length&&W<Z;W++){let H=V+"{"+X.body+"}"+K[W];J.push(H)}else{let W=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(X.body),H=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(X.body),q=W||H,z=X.body.indexOf(",")>=0;if(!q&&!z){if(X.post.match(/,(?!,).*\}/))return $=X.pre+"{"+X.body+W2+X.post,g4($,Z,!0);return[$]}let G;if(q)G=X.body.split(/\.\./);else if(G=D5(X.body),G.length===1&&G[0]!==void 0){if(G=g4(G[0],Z,!1).map(m7),G.length===1)return K.map((B)=>X.pre+G[0]+B)}let A;if(q&&G[0]!==void 0&&G[1]!==void 0){let B=K2(G[0]),_=K2(G[1]),L=Math.max(G[0].length,G[1].length),R=G.length===3&&G[2]!==void 0?Math.abs(K2(G[2])):1,w=l7;if(_<B)R*=-1,w=p7;let I=G.some(c7);A=[];for(let S=B;w(S,_);S+=R){let M;if(H){if(M=String.fromCharCode(S),M==="\\")M=""}else if(M=String(S),I){let d=L-M.length;if(d>0){let k=Array(d+1).join("0");if(S<0)M="-"+k+M.slice(1);else M=k+M}}A.push(M)}}else{A=[];for(let B=0;B<G.length;B++)A.push.apply(A,g4(G[B],Z,!1))}for(let B=0;B<A.length;B++)for(let _=0;_<K.length&&J.length<Z;_++){let L=V+A[B]+K[_];if(!Q||q||L)J.push(L)}}return J}var d4=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var a7={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},u4=($)=>$.replace(/[[\]\\-]/g,"\\$&"),r7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),M5=($)=>$.join(""),I5=($,Z)=>{let Q=Z;if($.charAt(Q)!=="[")throw Error("not in a brace expression");let J=[],X=[],V=Q+1,K=!1,W=!1,H=!1,q=!1,z=Q,G="";$:while(V<$.length){let L=$.charAt(V);if((L==="!"||L==="^")&&V===Q+1){q=!0,V++;continue}if(L==="]"&&K&&!H){z=V+1;break}if(K=!0,L==="\\"){if(!H){H=!0,V++;continue}}if(L==="["&&!H){for(let[R,[w,D,I]]of Object.entries(a7))if($.startsWith(R,V)){if(G)return["$.",!1,$.length-Q,!0];if(V+=R.length,I)X.push(w);else J.push(w);W=W||D;continue $}}if(H=!1,G){if(L>G)J.push(u4(G)+"-"+u4(L));else if(L===G)J.push(u4(L));G="",V++;continue}if($.startsWith("-]",V+1)){J.push(u4(L+"-")),V+=2;continue}if($.startsWith("-",V+1)){G=L,V+=2;continue}J.push(u4(L)),V++}if(z<V)return["",!1,0,!1];if(!J.length&&!X.length)return["$.",!1,$.length-Q,!0];if(X.length===0&&J.length===1&&/^\\?.$/.test(J[0])&&!q){let L=J[0].length===2?J[0].slice(-1):J[0];return[r7(L),!1,z-Q,!1]}let A="["+(q?"^":"")+M5(J)+"]",B="["+(q?"":"^")+M5(X)+"]";return[J.length&&X.length?"("+A+"|"+B+")":J.length?A:B,W,z-Q,!0]};var _0=($,{windowsPathsNoEscape:Z=!1,magicalBraces:Q=!0}={})=>{if(Q)return Z?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");return Z?$.replace(/\[([^\/\\{}])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")};var H0,n7=new Set(["!","?","+","*","@"]),H2=($)=>n7.has($),E5=($)=>H2($.type),i7=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),s7=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),o7=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),S5=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),e7="(?!(?:^|/)\\.\\.?(?:$|/))",G6="(?!\\.)",t7=new Set(["[","."]),$8=new Set(["..","."]),Z8=new Set("().*{}+?[]^$\\!"),Q8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),q2="[^/]",T5=q2+"*?",k5=q2+"+?",J8=0;class B4{type;#$;#J;#X=!1;#Z=[];#K;#P;#_;#z=!1;#W;#G;#Y=!1;id=++J8;get depth(){return(this.#K?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#$.id,parent:this.#K?.id,depth:this.depth,partsLength:this.#Z.length,parts:this.#Z}}constructor($,Z,Q={}){if(this.type=$,$)this.#J=!0;if(this.#K=Z,this.#$=this.#K?this.#K.#$:this,this.#W=this.#$===this?Q:this.#$.#W,this.#_=this.#$===this?[]:this.#$.#_,$==="!"&&!this.#$.#z)this.#_.push(this);this.#P=this.#K?this.#K.#Z.length:0}get hasMagic(){if(this.#J!==void 0)return this.#J;for(let $ of this.#Z){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#J=!0}return this.#J}toString(){if(this.#G!==void 0)return this.#G;if(!this.type)return this.#G=this.#Z.map(($)=>String($)).join("");else return this.#G=this.type+"("+this.#Z.map(($)=>String($)).join("|")+")"}#H(){if(this!==this.#$)throw Error("should only call on root");if(this.#z)return this;this.toString(),this.#z=!0;let $;while($=this.#_.pop()){if($.type!=="!")continue;let Z=$,Q=Z.#K;while(Q){for(let J=Z.#P+1;!Q.type&&J<Q.#Z.length;J++)for(let X of $.#Z){if(typeof X==="string")throw Error("string part in extglob AST??");X.copyIn(Q.#Z[J])}Z=Q,Q=Z.#K}}return this}push(...$){for(let Z of $){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof H0&&Z.#K===this))throw Error("invalid part: "+Z);this.#Z.push(Z)}}toJSON(){let $=this.type===null?this.#Z.slice().map((Z)=>typeof Z==="string"?Z:Z.toJSON()):[this.type,...this.#Z.map((Z)=>Z.toJSON())];if(this.isStart()&&!this.type)$.unshift([]);if(this.isEnd()&&(this===this.#$||this.#$.#z&&this.#K?.type==="!"))$.push({});return $}isStart(){if(this.#$===this)return!0;if(!this.#K?.isStart())return!1;if(this.#P===0)return!0;let $=this.#K;for(let Z=0;Z<this.#P;Z++){let Q=$.#Z[Z];if(!(Q instanceof H0&&Q.type==="!"))return!1}return!0}isEnd(){if(this.#$===this)return!0;if(this.#K?.type==="!")return!0;if(!this.#K?.isEnd())return!1;if(!this.type)return this.#K?.isEnd();let $=this.#K?this.#K.#Z.length:0;return this.#P===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Z=new H0(this.type,$);for(let Q of this.#Z)Z.copyIn(Q);return Z}static#V($,Z,Q,J,X){let V=J.maxExtglobRecursion??2,K=!1,W=!1,H=-1,q=!1;if(Z.type===null){let _=Q,L="";while(_<$.length){let R=$.charAt(_++);if(K||R==="\\"){K=!K,L+=R;continue}if(W){if(_===H+1){if(R==="^"||R==="!")q=!0}else if(R==="]"&&!(_===H+2&&q))W=!1;L+=R;continue}else if(R==="["){W=!0,H=_,q=!1,L+=R;continue}if(!J.noext&&H2(R)&&$.charAt(_)==="("&&X<=V){Z.push(L),L="";let D=new H0(R,Z);_=H0.#V($,D,_,J,X+1),Z.push(D);continue}L+=R}return Z.push(L),_}let z=Q+1,G=new H0(null,Z),A=[],B="";while(z<$.length){let _=$.charAt(z++);if(K||_==="\\"){K=!K,B+=_;continue}if(W){if(z===H+1){if(_==="^"||_==="!")q=!0}else if(_==="]"&&!(z===H+2&&q))W=!1;B+=_;continue}else if(_==="["){W=!0,H=z,q=!1,B+=_;continue}if(!J.noext&&H2(_)&&$.charAt(z)==="("&&(X<=V||Z&&Z.#U(_))){let R=Z&&Z.#U(_)?0:1;G.push(B),B="";let w=new H0(_,G);G.push(w),z=H0.#V($,w,z,J,X+R);continue}if(_==="|"){G.push(B),B="",A.push(G),G=new H0(null,Z);continue}if(_===")"){if(B===""&&Z.#Z.length===0)Z.#Y=!0;return G.push(B),B="",Z.push(...A,G),z}B+=_}return Z.type=null,Z.#J=void 0,Z.#Z=[$.substring(Q-1)],z}#w($){return this.#C($,s7)}#C($,Z=i7){if(!$||typeof $!=="object"||$.type!==null||$.#Z.length!==1||this.type===null)return!1;let Q=$.#Z[0];if(!Q||typeof Q!=="object"||Q.type===null)return!1;return this.#U(Q.type,Z)}#U($,Z=o7){return!!Z.get(this.type)?.includes($)}#A($,Z){let Q=$.#Z[0],J=new H0(null,Q,this.options);J.#Z.push(""),Q.push(J),this.#M($,Z)}#M($,Z){let Q=$.#Z[0];this.#Z.splice(Z,1,...Q.#Z);for(let J of Q.#Z)if(typeof J==="object")J.#K=this;this.#G=void 0}#B($){return!!S5.get(this.type)?.has($)}#N($){if(!$||typeof $!=="object"||$.type!==null||$.#Z.length!==1||this.type===null||this.#Z.length!==1)return!1;let Z=$.#Z[0];if(!Z||typeof Z!=="object"||Z.type===null)return!1;return this.#B(Z.type)}#D($){let Z=S5.get(this.type),Q=$.#Z[0],J=Z?.get(Q.type);if(!J)return!1;this.#Z=Q.#Z;for(let X of this.#Z)if(typeof X==="object")X.#K=this;this.type=J,this.#G=void 0,this.#Y=!1}static fromGlob($,Z={}){let Q=new H0(null,void 0,Z);return H0.#V($,Q,0,Z,0),Q}toMMPattern(){if(this!==this.#$)return this.#$.toMMPattern();let $=this.toString(),[Z,Q,J,X]=this.toRegExpSource();if(!(J||this.#J||this.#W.nocase&&!this.#W.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return Q;let K=(this.#W.nocase?"i":"")+(X?"u":"");return Object.assign(new RegExp(`^${Z}$`,K),{_src:Z,_glob:$})}get options(){return this.#W}toRegExpSource($){let Z=$??!!this.#W.dot;if(this.#$===this)this.#j(),this.#H();if(!E5(this)){let W=this.isStart()&&this.isEnd()&&!this.#Z.some((A)=>typeof A!=="string"),H=this.#Z.map((A)=>{let[B,_,L,R]=typeof A==="string"?H0.#R(A,this.#J,W):A.toRegExpSource($);return this.#J=this.#J||L,this.#X=this.#X||R,B}).join(""),q="";if(this.isStart()){if(typeof this.#Z[0]==="string"){if(!(this.#Z.length===1&&$8.has(this.#Z[0]))){let B=t7,_=Z&&B.has(H.charAt(0))||H.startsWith("\\.")&&B.has(H.charAt(2))||H.startsWith("\\.\\.")&&B.has(H.charAt(4)),L=!Z&&!$&&B.has(H.charAt(0));q=_?e7:L?G6:""}}}let z="";if(this.isEnd()&&this.#$.#z&&this.#K?.type==="!")z="(?:$|\\/)";return[q+H+z,_0(H),this.#J=!!this.#J,this.#X]}let Q=this.type==="*"||this.type==="+",J=this.type==="!"?"(?:(?!(?:":"(?:",X=this.#L(Z);if(this.isStart()&&this.isEnd()&&!X&&this.type!=="!"){let W=this.toString(),H=this;return H.#Z=[W],H.type=null,H.#J=void 0,[W,_0(this.toString()),!1,!1]}let V=!Q||$||Z||!G6?"":this.#L(!0);if(V===X)V="";if(V)X=`(?:${X})(?:${V})*?`;let K="";if(this.type==="!"&&this.#Y)K=(this.isStart()&&!Z?G6:"")+k5;else{let W=this.type==="!"?"))"+(this.isStart()&&!Z&&!$?G6:"")+T5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&V?")":this.type==="*"&&V?")?":`)${this.type}`;K=J+X+W}return[K,_0(X),this.#J=!!this.#J,this.#X]}#j(){if(!E5(this)){for(let $ of this.#Z)if(typeof $==="object")$.#j()}else{let $=0,Z=!1;do{Z=!0;for(let Q=0;Q<this.#Z.length;Q++){let J=this.#Z[Q];if(typeof J==="object"){if(J.#j(),this.#C(J))Z=!1,this.#M(J,Q);else if(this.#w(J))Z=!1,this.#A(J,Q);else if(this.#N(J))Z=!1,this.#D(J)}}}while(!Z&&++$<10)}this.#G=void 0}#L($){return this.#Z.map((Z)=>{if(typeof Z==="string")throw Error("string type in extglob ast??");let[Q,J,X,V]=Z.toRegExpSource($);return this.#X=this.#X||V,Q}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#R($,Z,Q=!1){let J=!1,X="",V=!1,K=!1;for(let W=0;W<$.length;W++){let H=$.charAt(W);if(J){J=!1,X+=(Z8.has(H)?"\\":"")+H;continue}if(H==="*"){if(K)continue;K=!0,X+=Q&&/^[*]+$/.test($)?k5:T5,Z=!0;continue}else K=!1;if(H==="\\"){if(W===$.length-1)X+="\\\\";else J=!0;continue}if(H==="["){let[q,z,G,A]=I5($,W);if(G){X+=q,V=V||z,W+=G-1,Z=Z||A;continue}}if(H==="?"){X+=q2,Z=!0;continue}X+=Q8(H)}return[X,_0($),!!Z,V]}}H0=B4;var L4=($,{windowsPathsNoEscape:Z=!1,magicalBraces:Q=!1}={})=>{if(Q)return Z?$.replace(/[?*()[\]{}]/g,"[$&]"):$.replace(/[?*()[\]\\{}]/g,"\\$&");return Z?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var $0=($,Z,Q={})=>{if(d4(Z),!Q.nocomment&&Z.charAt(0)==="#")return!1;return new j0(Z,Q).match($)},X8=/^\*+([^+@!?\*\[\(]*)$/,V8=($)=>(Z)=>!Z.startsWith(".")&&Z.endsWith($),K8=($)=>(Z)=>Z.endsWith($),W8=($)=>{return $=$.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith($)},H8=($)=>{return $=$.toLowerCase(),(Z)=>Z.toLowerCase().endsWith($)},q8=/^\*+\.\*+$/,Y8=($)=>!$.startsWith(".")&&$.includes("."),z8=($)=>$!=="."&&$!==".."&&$.includes("."),G8=/^\.\*+$/,j8=($)=>$!=="."&&$!==".."&&$.startsWith("."),U8=/^\*+$/,A8=($)=>$.length!==0&&!$.startsWith("."),B8=($)=>$.length!==0&&$!=="."&&$!=="..",L8=/^\?+([^+@!?\*\[\(]*)?$/,_8=([$,Z=""])=>{let Q=O5([$]);if(!Z)return Q;return Z=Z.toLowerCase(),(J)=>Q(J)&&J.toLowerCase().endsWith(Z)},w8=([$,Z=""])=>{let Q=y5([$]);if(!Z)return Q;return Z=Z.toLowerCase(),(J)=>Q(J)&&J.toLowerCase().endsWith(Z)},R8=([$,Z=""])=>{let Q=y5([$]);return!Z?Q:(J)=>Q(J)&&J.endsWith(Z)},C8=([$,Z=""])=>{let Q=O5([$]);return!Z?Q:(J)=>Q(J)&&J.endsWith(Z)},O5=([$])=>{let Z=$.length;return(Q)=>Q.length===Z&&!Q.startsWith(".")},y5=([$])=>{let Z=$.length;return(Q)=>Q.length===Z&&Q!=="."&&Q!==".."},b5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",x5={win32:{sep:"\\"},posix:{sep:"/"}},N8=b5==="win32"?x5.win32.sep:x5.posix.sep;$0.sep=N8;var m=Symbol("globstar **");$0.GLOBSTAR=m;var P8="[^/]",D8=P8+"*?",F8="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",M8="(?:(?!(?:\\/|^)\\.).)*?",I8=($,Z={})=>(Q)=>$0(Q,$,Z);$0.filter=I8;var G0=($,Z={})=>Object.assign({},$,Z),E8=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return $0;let Z=$0;return Object.assign((J,X,V={})=>Z(J,X,G0($,V)),{Minimatch:class extends Z.Minimatch{constructor(X,V={}){super(X,G0($,V))}static defaults(X){return Z.defaults(G0($,X)).Minimatch}},AST:class extends Z.AST{constructor(X,V,K={}){super(X,V,G0($,K))}static fromGlob(X,V={}){return Z.AST.fromGlob(X,G0($,V))}},unescape:(J,X={})=>Z.unescape(J,G0($,X)),escape:(J,X={})=>Z.escape(J,G0($,X)),filter:(J,X={})=>Z.filter(J,G0($,X)),defaults:(J)=>Z.defaults(G0($,J)),makeRe:(J,X={})=>Z.makeRe(J,G0($,X)),braceExpand:(J,X={})=>Z.braceExpand(J,G0($,X)),match:(J,X,V={})=>Z.match(J,X,G0($,V)),sep:Z.sep,GLOBSTAR:m})};$0.defaults=E8;var f5=($,Z={})=>{if(d4($),Z.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return F5($,{max:Z.braceExpandMax})};$0.braceExpand=f5;var S8=($,Z={})=>new j0($,Z).makeRe();$0.makeRe=S8;var T8=($,Z,Q={})=>{let J=new j0(Z,Q);if($=$.filter((X)=>J.match(X)),J.options.nonull&&!$.length)$.push(Z);return $};$0.match=T8;var v5=/[?*]|[+@!]\(.*?\)|\[|\]/,k8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class j0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor($,Z={}){d4($),Z=Z||{},this.options=Z,this.maxGlobstarRecursion=Z.maxGlobstarRecursion??200,this.pattern=$,this.platform=Z.platform||b5,this.isWindows=this.platform==="win32";let Q="allowWindowsEscape";if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z[Q]===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let $ of this.set)for(let Z of $)if(typeof Z!=="string")return!0;return!1}debug(...$){}make(){let $=this.pattern,Z=this.options;if(!Z.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...X)=>console.error(...X);this.debug(this.pattern,this.globSet);let Q=this.globSet.map((X)=>this.slashSplit(X));this.globParts=this.preprocess(Q),this.debug(this.pattern,this.globParts);let J=this.globParts.map((X,V,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=X[0]===""&&X[1]===""&&(X[2]==="?"||!v5.test(X[2]))&&!v5.test(X[3]),H=/^[a-z]:/i.test(X[0]);if(W)return[...X.slice(0,4),...X.slice(4).map((q)=>this.parse(q))];else if(H)return[X[0],...X.slice(1).map((q)=>this.parse(q))]}return X.map((W)=>this.parse(W))});if(this.debug(this.pattern,J),this.set=J.filter((X)=>X.indexOf(!1)===-1),this.isWindows)for(let X=0;X<this.set.length;X++){let V=this.set[X];if(V[0]===""&&V[1]===""&&this.globParts[X][2]==="?"&&typeof V[3]==="string"&&/^[a-z]:$/i.test(V[3]))V[2]="?"}this.debug(this.pattern,this.set)}preprocess($){if(this.options.noglobstar){for(let Q=0;Q<$.length;Q++)for(let J=0;J<$[Q].length;J++)if($[Q][J]==="**")$[Q][J]="*"}let{optimizationLevel:Z=1}=this.options;if(Z>=2)$=this.firstPhasePreProcess($),$=this.secondPhasePreProcess($);else if(Z>=1)$=this.levelOneOptimize($);else $=this.adjascentGlobstarOptimize($);return $}adjascentGlobstarOptimize($){return $.map((Z)=>{let Q=-1;while((Q=Z.indexOf("**",Q+1))!==-1){let J=Q;while(Z[J+1]==="**")J++;if(J!==Q)Z.splice(Q,J-Q)}return Z})}levelOneOptimize($){return $.map((Z)=>{return Z=Z.reduce((Q,J)=>{let X=Q[Q.length-1];if(J==="**"&&X==="**")return Q;if(J===".."){if(X&&X!==".."&&X!=="."&&X!=="**")return Q.pop(),Q}return Q.push(J),Q},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let J=1;J<$.length-1;J++){let X=$[J];if(J===1&&X===""&&$[0]==="")continue;if(X==="."||X==="")Z=!0,$.splice(J,1),J--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Z=!0,$.pop()}let Q=0;while((Q=$.indexOf("..",Q+1))!==-1){let J=$[Q-1];if(J&&J!=="."&&J!==".."&&J!=="**")Z=!0,$.splice(Q-1,2),Q-=2}}while(Z);return $.length===0?[""]:$}firstPhasePreProcess($){let Z=!1;do{Z=!1;for(let Q of $){let J=-1;while((J=Q.indexOf("**",J+1))!==-1){let V=J;while(Q[V+1]==="**")V++;if(V>J)Q.splice(J+1,V-J);let K=Q[J+1],W=Q[J+2],H=Q[J+3];if(K!=="..")continue;if(!W||W==="."||W===".."||!H||H==="."||H==="..")continue;Z=!0,Q.splice(J,1);let q=Q.slice(0);q[J]="**",$.push(q),J--}if(!this.preserveMultipleSlashes){for(let V=1;V<Q.length-1;V++){let K=Q[V];if(V===1&&K===""&&Q[0]==="")continue;if(K==="."||K==="")Z=!0,Q.splice(V,1),V--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))Z=!0,Q.pop()}let X=0;while((X=Q.indexOf("..",X+1))!==-1){let V=Q[X-1];if(V&&V!=="."&&V!==".."&&V!=="**"){Z=!0;let W=X===1&&Q[X+1]==="**"?["."]:[];if(Q.splice(X-1,2,...W),Q.length===0)Q.push("");X-=2}}}}while(Z);return $}secondPhasePreProcess($){for(let Z=0;Z<$.length-1;Z++)for(let Q=Z+1;Q<$.length;Q++){let J=this.partsMatch($[Z],$[Q],!this.preserveMultipleSlashes);if(J){$[Z]=[],$[Q]=J;break}}return $.filter((Z)=>Z.length)}partsMatch($,Z,Q=!1){let J=0,X=0,V=[],K="";while(J<$.length&&X<Z.length)if($[J]===Z[X])V.push(K==="b"?Z[X]:$[J]),J++,X++;else if(Q&&$[J]==="**"&&Z[X]===$[J+1])V.push($[J]),J++;else if(Q&&Z[X]==="**"&&$[J]===Z[X+1])V.push(Z[X]),X++;else if($[J]==="*"&&Z[X]&&(this.options.dot||!Z[X].startsWith("."))&&Z[X]!=="**"){if(K==="b")return!1;K="a",V.push($[J]),J++,X++}else if(Z[X]==="*"&&$[J]&&(this.options.dot||!$[J].startsWith("."))&&$[J]!=="**"){if(K==="a")return!1;K="b",V.push(Z[X]),J++,X++}else return!1;return $.length===Z.length&&V}parseNegate(){if(this.nonegate)return;let $=this.pattern,Z=!1,Q=0;for(let J=0;J<$.length&&$.charAt(J)==="!";J++)Z=!Z,Q++;if(Q)this.pattern=$.slice(Q);this.negate=Z}matchOne($,Z,Q=!1){let J=0,X=0;if(this.isWindows){let K=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),W=!K&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),H=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),q=!H&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),z=W?3:K?0:void 0,G=q?3:H?0:void 0;if(typeof z==="number"&&typeof G==="number"){let[A,B]=[$[z],Z[G]];if(A.toLowerCase()===B.toLowerCase())Z[G]=A,X=G,J=z}}let{optimizationLevel:V=1}=this.options;if(V>=2)$=this.levelTwoFileOptimize($);if(Z.includes(m))return this.#$($,Z,Q,J,X);return this.#X($,Z,Q,J,X)}#$($,Z,Q,J,X){let V=Z.indexOf(m,X),K=Z.lastIndexOf(m),[W,H,q]=Q?[Z.slice(X,V),Z.slice(V+1),[]]:[Z.slice(X,V),Z.slice(V+1,K),Z.slice(K+1)];if(W.length){let w=$.slice(J,J+W.length);if(!this.#X(w,W,Q,0,0))return!1;J+=W.length,X+=W.length}let z=0;if(q.length){if(q.length+J>$.length)return!1;let w=$.length-q.length;if(this.#X($,q,Q,w,0))z=q.length;else{if($[$.length-1]!==""||J+q.length===$.length)return!1;if(w--,!this.#X($,q,Q,w,0))return!1;z=q.length+1}}if(!H.length){let w=!!z;for(let D=J;D<$.length-z;D++){let I=String($[D]);if(w=!0,I==="."||I===".."||!this.options.dot&&I.startsWith("."))return!1}return Q||w}let G=[[[],0]],A=G[0],B=0,_=[0];for(let w of H)if(w===m)_.push(B),A=[[],0],G.push(A);else A[0].push(w),B++;let L=G.length-1,R=$.length-z;for(let w of G)w[1]=R-(_[L--]+w[0].length);return!!this.#J($,G,J,0,Q,0,!!z)}#J($,Z,Q,J,X,V,K){let W=Z[J];if(!W){for(let z=Q;z<$.length;z++){K=!0;let G=$[z];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1}return K}let[H,q]=W;while(Q<=q){if(this.#X($.slice(0,Q+H.length),H,X,Q,0)&&V<this.maxGlobstarRecursion){let A=this.#J($,Z,Q+H.length,J+1,X,V+1,K);if(A!==!1)return A}let G=$[Q];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1;Q++}return X||null}#X($,Z,Q,J,X){let V,K,W,H;for(V=J,K=X,H=$.length,W=Z.length;V<H&&K<W;V++,K++){this.debug("matchOne loop");let q=Z[K],z=$[V];if(this.debug(Z,q,z),q===!1||q===m)return!1;let G;if(typeof q==="string")G=z===q,this.debug("string match",q,z,G);else G=q.test(z),this.debug("pattern match",q,z,G);if(!G)return!1}if(V===H&&K===W)return!0;else if(V===H)return Q;else if(K===W)return V===H-1&&$[V]==="";else throw Error("wtf?")}braceExpand(){return f5(this.pattern,this.options)}parse($){d4($);let Z=this.options;if($==="**")return m;if($==="")return"";let Q,J=null;if(Q=$.match(U8))J=Z.dot?B8:A8;else if(Q=$.match(X8))J=(Z.nocase?Z.dot?H8:W8:Z.dot?K8:V8)(Q[1]);else if(Q=$.match(L8))J=(Z.nocase?Z.dot?w8:_8:Z.dot?R8:C8)(Q);else if(Q=$.match(q8))J=Z.dot?z8:Y8;else if(Q=$.match(G8))J=j8;let X=B4.fromGlob($,this.options).toMMPattern();if(J&&typeof X==="object")Reflect.defineProperty(X,"test",{value:J});return X}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Z=this.options,Q=Z.noglobstar?D8:Z.dot?F8:M8,J=new Set(Z.nocase?["i"]:[]),X=$.map((W)=>{let H=W.map((z)=>{if(z instanceof RegExp)for(let G of z.flags.split(""))J.add(G);return typeof z==="string"?k8(z):z===m?m:z._src});H.forEach((z,G)=>{let A=H[G+1],B=H[G-1];if(z!==m||B===m)return;if(B===void 0)if(A!==void 0&&A!==m)H[G+1]="(?:\\/|"+Q+"\\/)?"+A;else H[G]=Q;else if(A===void 0)H[G-1]=B+"(?:\\/|\\/"+Q+")?";else if(A!==m)H[G-1]=B+"(?:\\/|\\/"+Q+"\\/)"+A,H[G+1]=m});let q=H.filter((z)=>z!==m);if(this.partial&&q.length>=1){let z=[];for(let G=1;G<=q.length;G++)z.push(q.slice(0,G).join("/"));return"(?:"+z.join("|")+")"}return q.join("/")}).join("|"),[V,K]=$.length>1?["(?:",")"]:["",""];if(X="^"+V+X+K+"$",this.partial)X="^(?:\\/|"+V+X.slice(1,-1)+K+")$";if(this.negate)X="^(?!"+X+").+$";try{this.regexp=new RegExp(X,[...J].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit($){if(this.preserveMultipleSlashes)return $.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test($))return["",...$.split(/\/+/)];else return $.split(/\/+/)}match($,Z=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Z)return!0;let Q=this.options;if(this.isWindows)$=$.split("\\").join("/");let J=this.slashSplit($);this.debug(this.pattern,"split",J);let X=this.set;this.debug(this.pattern,"set",X);let V=J[J.length-1];if(!V)for(let K=J.length-2;!V&&K>=0;K--)V=J[K];for(let K=0;K<X.length;K++){let W=X[K],H=J;if(Q.matchBase&&W.length===1)H=[V];if(this.matchOne(H,W,Z)){if(Q.flipNegate)return!0;return!this.negate}}if(Q.flipNegate)return!1;return this.negate}static defaults($){return $0.defaults($).Minimatch}}$0.AST=B4;$0.Minimatch=j0;$0.escape=L4;$0.unescape=_0;import{fileURLToPath as zZ}from"url";var x8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,g5=new Set,Y2=typeof process=="object"&&process?process:{},d5=($,Z,Q,J)=>{typeof Y2.emitWarning=="function"?Y2.emitWarning($,Z,Q,J):console.error(`[${Q}] ${Z}: ${$}`)},U6=globalThis.AbortController,h5=globalThis.AbortSignal;if(typeof U6>"u"){h5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Q,J){this._onabort.push(J)}},U6=class{constructor(){Z()}signal=new h5;abort(Q){if(!this.signal.aborted){this.signal.reason=Q,this.signal.aborted=!0;for(let J of this.signal._onabort)J(Q);this.signal.onabort?.(Q)}}};let $=Y2.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{$&&($=!1,d5("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Z))}}var v8=($)=>!g5.has($),uK=Symbol("type"),s0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),u5=($)=>s0($)?$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?j6:null:null,j6=class extends Array{constructor($){super($),this.fill(0)}},O8=class ${heap;length;static#$=!1;static create(Z){let Q=u5(Z);if(!Q)return[];$.#$=!0;let J=new $(Z,Q);return $.#$=!1,J}constructor(Z,Q){if(!$.#$)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Q(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}},m4=class ${#$;#J;#X;#Z;#K;#P;#_;#z;get perf(){return this.#z}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#Y;#H;#V;#w;#C;#U;#A;#M;#B;#N;#D;#j;#L;#R;#I;#Q;#O;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#j,autopurgeTimers:Z.#L,sizes:Z.#N,keyMap:Z.#Y,keyList:Z.#H,valList:Z.#V,next:Z.#w,prev:Z.#C,get head(){return Z.#U},get tail(){return Z.#A},free:Z.#M,isBackgroundFetch:(Q)=>Z.#q(Q),backgroundFetch:(Q,J,X,V)=>Z.#m(Q,J,X,V),moveToTail:(Q)=>Z.#b(Q),indexes:(Q)=>Z.#T(Q),rindexes:(Q)=>Z.#k(Q),isStale:(Q)=>Z.#F(Q)}}get max(){return this.#$}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#P}get memoMethod(){return this.#_}get dispose(){return this.#X}get onInsert(){return this.#Z}get disposeAfter(){return this.#K}constructor(Z){let{max:Q=0,ttl:J,ttlResolution:X=1,ttlAutopurge:V,updateAgeOnGet:K,updateAgeOnHas:W,allowStale:H,dispose:q,onInsert:z,disposeAfter:G,noDisposeOnSet:A,noUpdateTTL:B,maxSize:_=0,maxEntrySize:L=0,sizeCalculation:R,fetchMethod:w,memoMethod:D,noDeleteOnFetchRejection:I,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:d,ignoreFetchAbort:k,perf:l}=Z;if(l!==void 0&&typeof l?.now!="function")throw TypeError("perf option must have a now() method if specified");if(this.#z=l??x8,Q!==0&&!s0(Q))throw TypeError("max option must be a nonnegative integer");let K0=Q?u5(Q):Array;if(!K0)throw Error("invalid max value: "+Q);if(this.#$=Q,this.#J=_,this.maxEntrySize=L||this.#J,this.sizeCalculation=R,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw TypeError("sizeCalculation set to non-function")}if(D!==void 0&&typeof D!="function")throw TypeError("memoMethod must be a function if defined");if(this.#_=D,w!==void 0&&typeof w!="function")throw TypeError("fetchMethod must be a function if specified");if(this.#P=w,this.#I=!!w,this.#Y=new Map,this.#H=Array(Q).fill(void 0),this.#V=Array(Q).fill(void 0),this.#w=new K0(Q),this.#C=new K0(Q),this.#U=0,this.#A=0,this.#M=O8.create(Q),this.#W=0,this.#G=0,typeof q=="function"&&(this.#X=q),typeof z=="function"&&(this.#Z=z),typeof G=="function"?(this.#K=G,this.#B=[]):(this.#K=void 0,this.#B=void 0),this.#R=!!this.#X,this.#O=!!this.#Z,this.#Q=!!this.#K,this.noDisposeOnSet=!!A,this.noUpdateTTL=!!B,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!d,this.ignoreFetchAbort=!!k,this.maxEntrySize!==0){if(this.#J!==0&&!s0(this.#J))throw TypeError("maxSize must be a positive integer if specified");if(!s0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#l()}if(this.allowStale=!!H,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!K,this.updateAgeOnHas=!!W,this.ttlResolution=s0(X)||X===0?X:1,this.ttlAutopurge=!!V,this.ttl=J||0,this.ttl){if(!s0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#x()}if(this.#$===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#$&&!this.#J){let t="LRU_CACHE_UNBOUNDED";v8(t)&&(g5.add(t),d5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,$))}}getRemainingTTL(Z){return this.#Y.has(Z)?1/0:0}#x(){let Z=new j6(this.#$),Q=new j6(this.#$);this.#j=Z,this.#D=Q;let J=this.ttlAutopurge?Array(this.#$):void 0;this.#L=J,this.#h=(K,W,H=this.#z.now())=>{if(Q[K]=W!==0?H:0,Z[K]=W,J?.[K]&&(clearTimeout(J[K]),J[K]=void 0),W!==0&&J){let q=setTimeout(()=>{this.#F(K)&&this.#S(this.#H[K],"expire")},W+1);q.unref&&q.unref(),J[K]=q}},this.#E=(K)=>{Q[K]=Z[K]!==0?this.#z.now():0},this.#v=(K,W)=>{if(Z[W]){let H=Z[W],q=Q[W];if(!H||!q)return;K.ttl=H,K.start=q,K.now=X||V();let z=K.now-q;K.remainingTTL=H-z}};let X=0,V=()=>{let K=this.#z.now();if(this.ttlResolution>0){X=K;let W=setTimeout(()=>X=0,this.ttlResolution);W.unref&&W.unref()}return K};this.getRemainingTTL=(K)=>{let W=this.#Y.get(K);if(W===void 0)return 0;let H=Z[W],q=Q[W];if(!H||!q)return 1/0;let z=(X||V())-q;return H-z},this.#F=(K)=>{let W=Q[K],H=Z[K];return!!H&&!!W&&(X||V())-W>H}}#E=()=>{};#v=()=>{};#h=()=>{};#F=()=>!1;#l(){let Z=new j6(this.#$);this.#G=0,this.#N=Z,this.#f=(Q)=>{this.#G-=Z[Q],Z[Q]=0},this.#g=(Q,J,X,V)=>{if(this.#q(J))return 0;if(!s0(X))if(V){if(typeof V!="function")throw TypeError("sizeCalculation must be a function");if(X=V(J,Q),!s0(X))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return X},this.#y=(Q,J,X)=>{if(Z[Q]=J,this.#J){let V=this.#J-Z[Q];for(;this.#G>V;)this.#u(!0)}this.#G+=Z[Q],X&&(X.entrySize=J,X.totalCalculatedSize=this.#G)}}#f=(Z)=>{};#y=(Z,Q,J)=>{};#g=(Z,Q,J,X)=>{if(J||X)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#W)for(let Q=this.#A;!(!this.#d(Q)||((Z||!this.#F(Q))&&(yield Q),Q===this.#U));)Q=this.#C[Q]}*#k({allowStale:Z=this.allowStale}={}){if(this.#W)for(let Q=this.#U;!(!this.#d(Q)||((Z||!this.#F(Q))&&(yield Q),Q===this.#A));)Q=this.#w[Q]}#d(Z){return Z!==void 0&&this.#Y.get(this.#H[Z])===Z}*entries(){for(let Z of this.#T())this.#V[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield[this.#H[Z],this.#V[Z]])}*rentries(){for(let Z of this.#k())this.#V[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield[this.#H[Z],this.#V[Z]])}*keys(){for(let Z of this.#T()){let Q=this.#H[Z];Q!==void 0&&!this.#q(this.#V[Z])&&(yield Q)}}*rkeys(){for(let Z of this.#k()){let Q=this.#H[Z];Q!==void 0&&!this.#q(this.#V[Z])&&(yield Q)}}*values(){for(let Z of this.#T())this.#V[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield this.#V[Z])}*rvalues(){for(let Z of this.#k())this.#V[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield this.#V[Z])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,Q={}){for(let J of this.#T()){let X=this.#V[J],V=this.#q(X)?X.__staleWhileFetching:X;if(V!==void 0&&Z(V,this.#H[J],this))return this.get(this.#H[J],Q)}}forEach(Z,Q=this){for(let J of this.#T()){let X=this.#V[J],V=this.#q(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(Q,V,this.#H[J],this)}}rforEach(Z,Q=this){for(let J of this.#k()){let X=this.#V[J],V=this.#q(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(Q,V,this.#H[J],this)}}purgeStale(){let Z=!1;for(let Q of this.#k({allowStale:!0}))this.#F(Q)&&(this.#S(this.#H[Q],"expire"),Z=!0);return Z}info(Z){let Q=this.#Y.get(Z);if(Q===void 0)return;let J=this.#V[Q],X=this.#q(J)?J.__staleWhileFetching:J;if(X===void 0)return;let V={value:X};if(this.#j&&this.#D){let K=this.#j[Q],W=this.#D[Q];if(K&&W){let H=K-(this.#z.now()-W);V.ttl=H,V.start=Date.now()}}return this.#N&&(V.size=this.#N[Q]),V}dump(){let Z=[];for(let Q of this.#T({allowStale:!0})){let J=this.#H[Q],X=this.#V[Q],V=this.#q(X)?X.__staleWhileFetching:X;if(V===void 0||J===void 0)continue;let K={value:V};if(this.#j&&this.#D){K.ttl=this.#j[Q];let W=this.#z.now()-this.#D[Q];K.start=Math.floor(Date.now()-W)}this.#N&&(K.size=this.#N[Q]),Z.unshift([J,K])}return Z}load(Z){this.clear();for(let[Q,J]of Z){if(J.start){let X=Date.now()-J.start;J.start=this.#z.now()-X}this.set(Q,J.value,J)}}set(Z,Q,J={}){if(Q===void 0)return this.delete(Z),this;let{ttl:X=this.ttl,start:V,noDisposeOnSet:K=this.noDisposeOnSet,sizeCalculation:W=this.sizeCalculation,status:H}=J,{noUpdateTTL:q=this.noUpdateTTL}=J,z=this.#g(Z,Q,J.size||0,W);if(this.maxEntrySize&&z>this.maxEntrySize)return H&&(H.set="miss",H.maxEntrySizeExceeded=!0),this.#S(Z,"set"),this;let G=this.#W===0?void 0:this.#Y.get(Z);if(G===void 0)G=this.#W===0?this.#A:this.#M.length!==0?this.#M.pop():this.#W===this.#$?this.#u(!1):this.#W,this.#H[G]=Z,this.#V[G]=Q,this.#Y.set(Z,G),this.#w[this.#A]=G,this.#C[G]=this.#A,this.#A=G,this.#W++,this.#y(G,z,H),H&&(H.set="add"),q=!1,this.#O&&this.#Z?.(Q,Z,"add");else{this.#b(G);let A=this.#V[G];if(Q!==A){if(this.#I&&this.#q(A)){A.__abortController.abort(Error("replaced"));let{__staleWhileFetching:B}=A;B!==void 0&&!K&&(this.#R&&this.#X?.(B,Z,"set"),this.#Q&&this.#B?.push([B,Z,"set"]))}else K||(this.#R&&this.#X?.(A,Z,"set"),this.#Q&&this.#B?.push([A,Z,"set"]));if(this.#f(G),this.#y(G,z,H),this.#V[G]=Q,H){H.set="replace";let B=A&&this.#q(A)?A.__staleWhileFetching:A;B!==void 0&&(H.oldValue=B)}}else H&&(H.set="update");this.#O&&this.onInsert?.(Q,Z,Q===A?"update":"replace")}if(X!==0&&!this.#j&&this.#x(),this.#j&&(q||this.#h(G,X,V),H&&this.#v(H,G)),!K&&this.#Q&&this.#B){let A=this.#B,B;for(;B=A?.shift();)this.#K?.(...B)}return this}pop(){try{for(;this.#W;){let Z=this.#V[this.#U];if(this.#u(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#Q&&this.#B){let Z=this.#B,Q;for(;Q=Z?.shift();)this.#K?.(...Q)}}}#u(Z){let Q=this.#U,J=this.#H[Q],X=this.#V[Q];return this.#I&&this.#q(X)?X.__abortController.abort(Error("evicted")):(this.#R||this.#Q)&&(this.#R&&this.#X?.(X,J,"evict"),this.#Q&&this.#B?.push([X,J,"evict"])),this.#f(Q),this.#L?.[Q]&&(clearTimeout(this.#L[Q]),this.#L[Q]=void 0),Z&&(this.#H[Q]=void 0,this.#V[Q]=void 0,this.#M.push(Q)),this.#W===1?(this.#U=this.#A=0,this.#M.length=0):this.#U=this.#w[Q],this.#Y.delete(J),this.#W--,Q}has(Z,Q={}){let{updateAgeOnHas:J=this.updateAgeOnHas,status:X}=Q,V=this.#Y.get(Z);if(V!==void 0){let K=this.#V[V];if(this.#q(K)&&K.__staleWhileFetching===void 0)return!1;if(this.#F(V))X&&(X.has="stale",this.#v(X,V));else return J&&this.#E(V),X&&(X.has="hit",this.#v(X,V)),!0}else X&&(X.has="miss");return!1}peek(Z,Q={}){let{allowStale:J=this.allowStale}=Q,X=this.#Y.get(Z);if(X===void 0||!J&&this.#F(X))return;let V=this.#V[X];return this.#q(V)?V.__staleWhileFetching:V}#m(Z,Q,J,X){let V=Q===void 0?void 0:this.#V[Q];if(this.#q(V))return V;let K=new U6,{signal:W}=J;W?.addEventListener("abort",()=>K.abort(W.reason),{signal:K.signal});let H={signal:K.signal,options:J,context:X},q=(L,R=!1)=>{let{aborted:w}=K.signal,D=J.ignoreFetchAbort&&L!==void 0,I=J.ignoreFetchAbort||!!(J.allowStaleOnFetchAbort&&L!==void 0);if(J.status&&(w&&!R?(J.status.fetchAborted=!0,J.status.fetchError=K.signal.reason,D&&(J.status.fetchAbortIgnored=!0)):J.status.fetchResolved=!0),w&&!D&&!R)return G(K.signal.reason,I);let S=B,M=this.#V[Q];return(M===B||D&&R&&M===void 0)&&(L===void 0?S.__staleWhileFetching!==void 0?this.#V[Q]=S.__staleWhileFetching:this.#S(Z,"fetch"):(J.status&&(J.status.fetchUpdated=!0),this.set(Z,L,H.options))),L},z=(L)=>(J.status&&(J.status.fetchRejected=!0,J.status.fetchError=L),G(L,!1)),G=(L,R)=>{let{aborted:w}=K.signal,D=w&&J.allowStaleOnFetchAbort,I=D||J.allowStaleOnFetchRejection,S=I||J.noDeleteOnFetchRejection,M=B;if(this.#V[Q]===B&&(!S||!R&&M.__staleWhileFetching===void 0?this.#S(Z,"fetch"):D||(this.#V[Q]=M.__staleWhileFetching)),I)return J.status&&M.__staleWhileFetching!==void 0&&(J.status.returnedStale=!0),M.__staleWhileFetching;if(M.__returned===M)throw L},A=(L,R)=>{let w=this.#P?.(Z,V,H);w&&w instanceof Promise&&w.then((D)=>L(D===void 0?void 0:D),R),K.signal.addEventListener("abort",()=>{(!J.ignoreFetchAbort||J.allowStaleOnFetchAbort)&&(L(void 0),J.allowStaleOnFetchAbort&&(L=(D)=>q(D,!0)))})};J.status&&(J.status.fetchDispatched=!0);let B=new Promise(A).then(q,z),_=Object.assign(B,{__abortController:K,__staleWhileFetching:V,__returned:void 0});return Q===void 0?(this.set(Z,_,{...H.options,status:void 0}),Q=this.#Y.get(Z)):this.#V[Q]=_,_}#q(Z){if(!this.#I)return!1;let Q=Z;return!!Q&&Q instanceof Promise&&Q.hasOwnProperty("__staleWhileFetching")&&Q.__abortController instanceof U6}async fetch(Z,Q={}){let{allowStale:J=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,ttl:K=this.ttl,noDisposeOnSet:W=this.noDisposeOnSet,size:H=0,sizeCalculation:q=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:G=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:A=this.allowStaleOnFetchRejection,ignoreFetchAbort:B=this.ignoreFetchAbort,allowStaleOnFetchAbort:_=this.allowStaleOnFetchAbort,context:L,forceRefresh:R=!1,status:w,signal:D}=Q;if(!this.#I)return w&&(w.fetch="get"),this.get(Z,{allowStale:J,updateAgeOnGet:X,noDeleteOnStaleGet:V,status:w});let I={allowStale:J,updateAgeOnGet:X,noDeleteOnStaleGet:V,ttl:K,noDisposeOnSet:W,size:H,sizeCalculation:q,noUpdateTTL:z,noDeleteOnFetchRejection:G,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:_,ignoreFetchAbort:B,status:w,signal:D},S=this.#Y.get(Z);if(S===void 0){w&&(w.fetch="miss");let M=this.#m(Z,S,I,L);return M.__returned=M}else{let M=this.#V[S];if(this.#q(M)){let K0=J&&M.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",K0&&(w.returnedStale=!0)),K0?M.__staleWhileFetching:M.__returned=M}let d=this.#F(S);if(!R&&!d)return w&&(w.fetch="hit"),this.#b(S),X&&this.#E(S),w&&this.#v(w,S),M;let k=this.#m(Z,S,I,L),l=k.__staleWhileFetching!==void 0&&J;return w&&(w.fetch=d?"stale":"refresh",l&&d&&(w.returnedStale=!0)),l?k.__staleWhileFetching:k.__returned=k}}async forceFetch(Z,Q={}){let J=await this.fetch(Z,Q);if(J===void 0)throw Error("fetch() returned undefined");return J}memo(Z,Q={}){let J=this.#_;if(!J)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:V,...K}=Q,W=this.get(Z,K);if(!V&&W!==void 0)return W;let H=J(Z,W,{options:K,context:X});return this.set(Z,H,K),H}get(Z,Q={}){let{allowStale:J=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,status:K}=Q,W=this.#Y.get(Z);if(W!==void 0){let H=this.#V[W],q=this.#q(H);return K&&this.#v(K,W),this.#F(W)?(K&&(K.get="stale"),q?(K&&J&&H.__staleWhileFetching!==void 0&&(K.returnedStale=!0),J?H.__staleWhileFetching:void 0):(V||this.#S(Z,"expire"),K&&J&&(K.returnedStale=!0),J?H:void 0)):(K&&(K.get="hit"),q?H.__staleWhileFetching:(this.#b(W),X&&this.#E(W),H))}else K&&(K.get="miss")}#c(Z,Q){this.#C[Q]=Z,this.#w[Z]=Q}#b(Z){Z!==this.#A&&(Z===this.#U?this.#U=this.#w[Z]:this.#c(this.#C[Z],this.#w[Z]),this.#c(this.#A,Z),this.#A=Z)}delete(Z){return this.#S(Z,"delete")}#S(Z,Q){let J=!1;if(this.#W!==0){let X=this.#Y.get(Z);if(X!==void 0)if(this.#L?.[X]&&(clearTimeout(this.#L?.[X]),this.#L[X]=void 0),J=!0,this.#W===1)this.#p(Q);else{this.#f(X);let V=this.#V[X];if(this.#q(V)?V.__abortController.abort(Error("deleted")):(this.#R||this.#Q)&&(this.#R&&this.#X?.(V,Z,Q),this.#Q&&this.#B?.push([V,Z,Q])),this.#Y.delete(Z),this.#H[X]=void 0,this.#V[X]=void 0,X===this.#A)this.#A=this.#C[X];else if(X===this.#U)this.#U=this.#w[X];else{let K=this.#C[X];this.#w[K]=this.#w[X];let W=this.#w[X];this.#C[W]=this.#C[X]}this.#W--,this.#M.push(X)}}if(this.#Q&&this.#B?.length){let X=this.#B,V;for(;V=X?.shift();)this.#K?.(...V)}return J}clear(){return this.#p("delete")}#p(Z){for(let Q of this.#k({allowStale:!0})){let J=this.#V[Q];if(this.#q(J))J.__abortController.abort(Error("deleted"));else{let X=this.#H[Q];this.#R&&this.#X?.(J,X,Z),this.#Q&&this.#B?.push([J,X,Z])}}if(this.#Y.clear(),this.#V.fill(void 0),this.#H.fill(void 0),this.#j&&this.#D){this.#j.fill(0),this.#D.fill(0);for(let Q of this.#L??[])Q!==void 0&&clearTimeout(Q);this.#L?.fill(void 0)}if(this.#N&&this.#N.fill(0),this.#U=0,this.#A=0,this.#M.length=0,this.#G=0,this.#W=0,this.#Q&&this.#B){let Q=this.#B,J;for(;J=Q?.shift();)this.#K?.(...J)}}};import{posix as p8,win32 as R2}from"path";import{fileURLToPath as a8}from"url";import{lstatSync as r8,readdir as n8,readdirSync as i8,readlinkSync as s8,realpathSync as o8}from"fs";import*as e8 from"fs";import{lstat as $Z,readdir as ZZ,readlink as QZ,realpath as JZ}from"fs/promises";import{EventEmitter as B2}from"events";import a5 from"stream";import{StringDecoder as y8}from"string_decoder";var m5=typeof process==="object"&&process?process:{stdout:null,stderr:null},b8=($)=>!!$&&typeof $==="object"&&($ instanceof W4||$ instanceof a5||f8($)||h8($)),f8=($)=>!!$&&typeof $==="object"&&$ instanceof B2&&typeof $.pipe==="function"&&$.pipe!==a5.Writable.prototype.pipe,h8=($)=>!!$&&typeof $==="object"&&$ instanceof B2&&typeof $.write==="function"&&typeof $.end==="function",d0=Symbol("EOF"),u0=Symbol("maybeEmitEnd"),o0=Symbol("emittedEnd"),A6=Symbol("emittingEnd"),c4=Symbol("emittedError"),B6=Symbol("closed"),c5=Symbol("read"),L6=Symbol("flush"),l5=Symbol("flushChunk"),w0=Symbol("encoding"),_4=Symbol("decoder"),a=Symbol("flowing"),l4=Symbol("paused"),w4=Symbol("resume"),r=Symbol("buffer"),Z0=Symbol("pipes"),n=Symbol("bufferLength"),z2=Symbol("bufferPush"),_6=Symbol("bufferShift"),o=Symbol("objectMode"),c=Symbol("destroyed"),G2=Symbol("error"),j2=Symbol("emitData"),p5=Symbol("emitEnd"),U2=Symbol("emitEnd2"),F0=Symbol("async"),A2=Symbol("abort"),w6=Symbol("aborted"),p4=Symbol("signal"),K4=Symbol("dataListeners"),Y0=Symbol("discarded"),a4=($)=>Promise.resolve().then($),g8=($)=>$(),d8=($)=>$==="end"||$==="finish"||$==="prefinish",u8=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,m8=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class L2{src;dest;opts;ondrain;constructor($,Z,Q){this.src=$,this.dest=Z,this.opts=Q,this.ondrain=()=>$[w4](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class r5 extends L2{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Z,Q){super($,Z,Q);this.proxyErrors=(J)=>this.dest.emit("error",J),$.on("error",this.proxyErrors)}}var c8=($)=>!!$.objectMode,l8=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class W4 extends B2{[a]=!1;[l4]=!1;[Z0]=[];[r]=[];[o];[w0];[F0];[_4];[d0]=!1;[o0]=!1;[A6]=!1;[B6]=!1;[c4]=null;[n]=0;[c]=!1;[p4];[w6]=!1;[K4]=0;[Y0]=!1;writable=!0;readable=!0;constructor(...$){let Z=$[0]||{};super();if(Z.objectMode&&typeof Z.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(c8(Z))this[o]=!0,this[w0]=null;else if(l8(Z))this[w0]=Z.encoding,this[o]=!1;else this[o]=!1,this[w0]=null;if(this[F0]=!!Z.async,this[_4]=this[w0]?new y8(this[w0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[r]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[Z0]});let{signal:Q}=Z;if(Q)if(this[p4]=Q,Q.aborted)this[A2]();else Q.addEventListener("abort",()=>this[A2]())}get bufferLength(){return this[n]}get encoding(){return this[w0]}set encoding($){throw Error("Encoding must be set at instantiation time")}setEncoding($){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[o]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[F0]}set["async"]($){this[F0]=this[F0]||!!$}[A2](){this[w6]=!0,this.emit("abort",this[p4]?.reason),this.destroy(this[p4]?.reason)}get aborted(){return this[w6]}set aborted($){}write($,Z,Q){if(this[w6])return!1;if(this[d0])throw Error("write after end");if(this[c])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")Q=Z,Z="utf8";if(!Z)Z="utf8";let J=this[F0]?a4:g8;if(!this[o]&&!Buffer.isBuffer($)){if(m8($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(u8($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[o]){if(this[a]&&this[n]!==0)this[L6](!0);if(this[a])this.emit("data",$);else this[z2]($);if(this[n]!==0)this.emit("readable");if(Q)J(Q);return this[a]}if(!$.length){if(this[n]!==0)this.emit("readable");if(Q)J(Q);return this[a]}if(typeof $==="string"&&!(Z===this[w0]&&!this[_4]?.lastNeed))$=Buffer.from($,Z);if(Buffer.isBuffer($)&&this[w0])$=this[_4].write($);if(this[a]&&this[n]!==0)this[L6](!0);if(this[a])this.emit("data",$);else this[z2]($);if(this[n]!==0)this.emit("readable");if(Q)J(Q);return this[a]}read($){if(this[c])return null;if(this[Y0]=!1,this[n]===0||$===0||$&&$>this[n])return this[u0](),null;if(this[o])$=null;if(this[r].length>1&&!this[o])this[r]=[this[w0]?this[r].join(""):Buffer.concat(this[r],this[n])];let Z=this[c5]($||null,this[r][0]);return this[u0](),Z}[c5]($,Z){if(this[o])this[_6]();else{let Q=Z;if($===Q.length||$===null)this[_6]();else if(typeof Q==="string")this[r][0]=Q.slice($),Z=Q.slice(0,$),this[n]-=$;else this[r][0]=Q.subarray($),Z=Q.subarray(0,$),this[n]-=$}if(this.emit("data",Z),!this[r].length&&!this[d0])this.emit("drain");return Z}end($,Z,Q){if(typeof $==="function")Q=$,$=void 0;if(typeof Z==="function")Q=Z,Z="utf8";if($!==void 0)this.write($,Z);if(Q)this.once("end",Q);if(this[d0]=!0,this.writable=!1,this[a]||!this[l4])this[u0]();return this}[w4](){if(this[c])return;if(!this[K4]&&!this[Z0].length)this[Y0]=!0;if(this[l4]=!1,this[a]=!0,this.emit("resume"),this[r].length)this[L6]();else if(this[d0])this[u0]();else this.emit("drain")}resume(){return this[w4]()}pause(){this[a]=!1,this[l4]=!0,this[Y0]=!1}get destroyed(){return this[c]}get flowing(){return this[a]}get paused(){return this[l4]}[z2]($){if(this[o])this[n]+=1;else this[n]+=$.length;this[r].push($)}[_6](){if(this[o])this[n]-=1;else this[n]-=this[r][0].length;return this[r].shift()}[L6]($=!1){do;while(this[l5](this[_6]())&&this[r].length);if(!$&&!this[r].length&&!this[d0])this.emit("drain")}[l5]($){return this.emit("data",$),this[a]}pipe($,Z){if(this[c])return $;this[Y0]=!1;let Q=this[o0];if(Z=Z||{},$===m5.stdout||$===m5.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,Q){if(Z.end)$.end()}else if(this[Z0].push(!Z.proxyErrors?new L2(this,$,Z):new r5(this,$,Z)),this[F0])a4(()=>this[w4]());else this[w4]();return $}unpipe($){let Z=this[Z0].find((Q)=>Q.dest===$);if(Z){if(this[Z0].length===1){if(this[a]&&this[K4]===0)this[a]=!1;this[Z0]=[]}else this[Z0].splice(this[Z0].indexOf(Z),1);Z.unpipe()}}addListener($,Z){return this.on($,Z)}on($,Z){let Q=super.on($,Z);if($==="data"){if(this[Y0]=!1,this[K4]++,!this[Z0].length&&!this[a])this[w4]()}else if($==="readable"&&this[n]!==0)super.emit("readable");else if(d8($)&&this[o0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[c4]){let J=Z;if(this[F0])a4(()=>J.call(this,this[c4]));else J.call(this,this[c4])}return Q}removeListener($,Z){return this.off($,Z)}off($,Z){let Q=super.off($,Z);if($==="data"){if(this[K4]=this.listeners("data").length,this[K4]===0&&!this[Y0]&&!this[Z0].length)this[a]=!1}return Q}removeAllListeners($){let Z=super.removeAllListeners($);if($==="data"||$===void 0){if(this[K4]=0,!this[Y0]&&!this[Z0].length)this[a]=!1}return Z}get emittedEnd(){return this[o0]}[u0](){if(!this[A6]&&!this[o0]&&!this[c]&&this[r].length===0&&this[d0]){if(this[A6]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[B6])this.emit("close");this[A6]=!1}}emit($,...Z){let Q=Z[0];if($!=="error"&&$!=="close"&&$!==c&&this[c])return!1;else if($==="data")return!this[o]&&!Q?!1:this[F0]?(a4(()=>this[j2](Q)),!0):this[j2](Q);else if($==="end")return this[p5]();else if($==="close"){if(this[B6]=!0,!this[o0]&&!this[c])return!1;let X=super.emit("close");return this.removeAllListeners("close"),X}else if($==="error"){this[c4]=Q,super.emit(G2,Q);let X=!this[p4]||this.listeners("error").length?super.emit("error",Q):!1;return this[u0](),X}else if($==="resume"){let X=super.emit("resume");return this[u0](),X}else if($==="finish"||$==="prefinish"){let X=super.emit($);return this.removeAllListeners($),X}let J=super.emit($,...Z);return this[u0](),J}[j2]($){for(let Q of this[Z0])if(Q.dest.write($)===!1)this.pause();let Z=this[Y0]?!1:super.emit("data",$);return this[u0](),Z}[p5](){if(this[o0])return!1;return this[o0]=!0,this.readable=!1,this[F0]?(a4(()=>this[U2]()),!0):this[U2]()}[U2](){if(this[_4]){let Z=this[_4].end();if(Z){for(let Q of this[Z0])Q.dest.write(Z);if(!this[Y0])super.emit("data",Z)}}for(let Z of this[Z0])Z.end();let $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){let $=Object.assign([],{dataLength:0});if(!this[o])$.dataLength=0;let Z=this.promise();return this.on("data",(Q)=>{if($.push(Q),!this[o])$.dataLength+=Q.length}),await Z,$}async concat(){if(this[o])throw Error("cannot concat in objectMode");let $=await this.collect();return this[w0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Z)=>{this.on(c,()=>Z(Error("stream destroyed"))),this.on("error",(Q)=>Z(Q)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[Y0]=!1;let $=!1,Z=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Z();let J=this.read();if(J!==null)return Promise.resolve({done:!1,value:J});if(this[d0])return Z();let X,V,K=(z)=>{this.off("data",W),this.off("end",H),this.off(c,q),Z(),V(z)},W=(z)=>{this.off("error",K),this.off("end",H),this.off(c,q),this.pause(),X({value:z,done:!!this[d0]})},H=()=>{this.off("error",K),this.off("data",W),this.off(c,q),Z(),X({done:!0,value:void 0})},q=()=>K(Error("stream destroyed"));return new Promise((z,G)=>{V=G,X=z,this.once(c,q),this.once("error",K),this.once("end",H),this.once("data",W)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Y0]=!1;let $=!1,Z=()=>{return this.pause(),this.off(G2,Z),this.off(c,Z),this.off("end",Z),$=!0,{done:!0,value:void 0}},Q=()=>{if($)return Z();let J=this.read();return J===null?Z():{done:!1,value:J}};return this.once("end",Z),this.once(G2,Z),this.once(c,Z),{next:Q,throw:Z,return:Z,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy($){if(this[c]){if($)this.emit("error",$);else this.emit(c);return this}this[c]=!0,this[Y0]=!0,this[r].length=0,this[n]=0;let Z=this;if(typeof Z.close==="function"&&!this[B6])Z.close();if($)this.emit("error",$);else this.emit(c);return this}static get isStream(){return b8}}var t8=o8.native,n4={lstatSync:r8,readdir:n8,readdirSync:i8,readlinkSync:s8,realpathSync:t8,promises:{lstat:$Z,readdir:ZZ,readlink:QZ,realpath:JZ}},e5=($)=>!$||$===n4||$===e8?n4:{...n4,...$,promises:{...n4.promises,...$.promises||{}}},t5=/^\\\\\?\\([a-z]:)\\?$/i,XZ=($)=>$.replace(/\//g,"\\").replace(t5,"$1\\"),VZ=/[\\\/]/,A0=0,$1=1,Z1=2,M0=4,Q1=6,J1=8,H4=10,X1=12,U0=15,r4=~U0,_2=16,n5=32,i4=64,R0=128,R6=256,N6=512,i5=i4|R0|N6,KZ=1023,w2=($)=>$.isFile()?J1:$.isDirectory()?M0:$.isSymbolicLink()?H4:$.isCharacterDevice()?Z1:$.isBlockDevice()?Q1:$.isSocket()?X1:$.isFIFO()?$1:A0,s5=new m4({max:4096}),s4=($)=>{let Z=s5.get($);if(Z)return Z;let Q=$.normalize("NFKD");return s5.set($,Q),Q},o5=new m4({max:4096}),C6=($)=>{let Z=o5.get($);if(Z)return Z;let Q=s4($.toLowerCase());return o5.set($,Q),Q};class C2 extends m4{constructor(){super({max:256})}}class V1 extends m4{constructor($=16384){super({maxSize:$,sizeCalculation:(Z)=>Z.length+1})}}var K1=Symbol("PathScurry setAsCwd");class Q0{name;root;roots;parent;nocase;isCWD=!1;#$;#J;get dev(){return this.#J}#X;get mode(){return this.#X}#Z;get nlink(){return this.#Z}#K;get uid(){return this.#K}#P;get gid(){return this.#P}#_;get rdev(){return this.#_}#z;get blksize(){return this.#z}#W;get ino(){return this.#W}#G;get size(){return this.#G}#Y;get blocks(){return this.#Y}#H;get atimeMs(){return this.#H}#V;get mtimeMs(){return this.#V}#w;get ctimeMs(){return this.#w}#C;get birthtimeMs(){return this.#C}#U;get atime(){return this.#U}#A;get mtime(){return this.#A}#M;get ctime(){return this.#M}#B;get birthtime(){return this.#B}#N;#D;#j;#L;#R;#I;#Q;#O;#x;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Z=A0,Q,J,X,V,K){if(this.name=$,this.#N=X?C6($):s4($),this.#Q=Z&KZ,this.nocase=X,this.roots=J,this.root=Q||this,this.#O=V,this.#j=K.fullpath,this.#R=K.relative,this.#I=K.relativePosix,this.parent=K.parent,this.parent)this.#$=this.parent.#$;else this.#$=e5(K.fs)}depth(){if(this.#D!==void 0)return this.#D;if(!this.parent)return this.#D=0;return this.#D=this.parent.depth()+1}childrenCache(){return this.#O}resolve($){if(!$)return this;let Z=this.getRootString($),J=$.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#v(J):this.#v(J)}#v($){let Z=this;for(let Q of $)Z=Z.child(Q);return Z}children(){let $=this.#O.get(this);if($)return $;let Z=Object.assign([],{provisional:0});return this.#O.set(this,Z),this.#Q&=~_2,Z}child($,Z){if($===""||$===".")return this;if($==="..")return this.parent||this;let Q=this.children(),J=this.nocase?C6($):s4($);for(let W of Q)if(W.#N===J)return W;let X=this.parent?this.sep:"",V=this.#j?this.#j+X+$:void 0,K=this.newChild($,A0,{...Z,parent:this,fullpath:V});if(!this.canReaddir())K.#Q|=R0;return Q.push(K),K}relative(){if(this.isCWD)return"";if(this.#R!==void 0)return this.#R;let $=this.name,Z=this.parent;if(!Z)return this.#R=this.name;let Q=Z.relative();return Q+(!Q||!Z.parent?"":this.sep)+$}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let $=this.name,Z=this.parent;if(!Z)return this.#I=this.fullpathPosix();let Q=Z.relativePosix();return Q+(!Q||!Z.parent?"":"/")+$}fullpath(){if(this.#j!==void 0)return this.#j;let $=this.name,Z=this.parent;if(!Z)return this.#j=this.name;let J=Z.fullpath()+(!Z.parent?"":this.sep)+$;return this.#j=J}fullpathPosix(){if(this.#L!==void 0)return this.#L;if(this.sep==="/")return this.#L=this.fullpath();if(!this.parent){let J=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(J))return this.#L=`//?/${J}`;else return this.#L=J}let $=this.parent,Z=$.fullpathPosix(),Q=Z+(!Z||!$.parent?"":"/")+this.name;return this.#L=Q}isUnknown(){return(this.#Q&U0)===A0}isType($){return this[`is${$}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#Q&U0)===J1}isDirectory(){return(this.#Q&U0)===M0}isCharacterDevice(){return(this.#Q&U0)===Z1}isBlockDevice(){return(this.#Q&U0)===Q1}isFIFO(){return(this.#Q&U0)===$1}isSocket(){return(this.#Q&U0)===X1}isSymbolicLink(){return(this.#Q&H4)===H4}lstatCached(){return this.#Q&n5?this:void 0}readlinkCached(){return this.#x}realpathCached(){return this.#E}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#x)return!0;if(!this.parent)return!1;let $=this.#Q&U0;return!($!==A0&&$!==H4||this.#Q&R6||this.#Q&R0)}calledReaddir(){return!!(this.#Q&_2)}isENOENT(){return!!(this.#Q&R0)}isNamed($){return!this.nocase?this.#N===s4($):this.#N===C6($)}async readlink(){let $=this.#x;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#$.promises.readlink(this.fullpath()),Q=(await this.parent.realpath())?.resolve(Z);if(Q)return this.#x=Q}catch(Z){this.#k(Z.code);return}}readlinkSync(){let $=this.#x;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#$.readlinkSync(this.fullpath()),Q=this.parent.realpathSync()?.resolve(Z);if(Q)return this.#x=Q}catch(Z){this.#k(Z.code);return}}#h($){this.#Q|=_2;for(let Z=$.provisional;Z<$.length;Z++){let Q=$[Z];if(Q)Q.#F()}}#F(){if(this.#Q&R0)return;this.#Q=(this.#Q|R0)&r4,this.#l()}#l(){let $=this.children();$.provisional=0;for(let Z of $)Z.#F()}#f(){this.#Q|=N6,this.#y()}#y(){if(this.#Q&i4)return;let $=this.#Q;if(($&U0)===M0)$&=r4;this.#Q=$|i4,this.#l()}#g($=""){if($==="ENOTDIR"||$==="EPERM")this.#y();else if($==="ENOENT")this.#F();else this.children().provisional=0}#T($=""){if($==="ENOTDIR")this.parent.#y();else if($==="ENOENT")this.#F()}#k($=""){let Z=this.#Q;if(Z|=R6,$==="ENOENT")Z|=R0;if($==="EINVAL"||$==="UNKNOWN")Z&=r4;if(this.#Q=Z,$==="ENOTDIR"&&this.parent)this.parent.#y()}#d($,Z){return this.#m($,Z)||this.#u($,Z)}#u($,Z){let Q=w2($),J=this.newChild($.name,Q,{parent:this}),X=J.#Q&U0;if(X!==M0&&X!==H4&&X!==A0)J.#Q|=i4;return Z.unshift(J),Z.provisional++,J}#m($,Z){for(let Q=Z.provisional;Q<Z.length;Q++){let J=Z[Q];if((this.nocase?C6($.name):s4($.name))!==J.#N)continue;return this.#q($,J,Q,Z)}}#q($,Z,Q,J){let X=Z.name;if(Z.#Q=Z.#Q&r4|w2($),X!==$.name)Z.name=$.name;if(Q!==J.provisional){if(Q===J.length-1)J.pop();else J.splice(Q,1);J.unshift(Z)}return J.provisional++,Z}async lstat(){if((this.#Q&R0)===0)try{return this.#c(await this.#$.promises.lstat(this.fullpath())),this}catch($){this.#T($.code)}}lstatSync(){if((this.#Q&R0)===0)try{return this.#c(this.#$.lstatSync(this.fullpath())),this}catch($){this.#T($.code)}}#c($){let{atime:Z,atimeMs:Q,birthtime:J,birthtimeMs:X,blksize:V,blocks:K,ctime:W,ctimeMs:H,dev:q,gid:z,ino:G,mode:A,mtime:B,mtimeMs:_,nlink:L,rdev:R,size:w,uid:D}=$;this.#U=Z,this.#H=Q,this.#B=J,this.#C=X,this.#z=V,this.#Y=K,this.#M=W,this.#w=H,this.#J=q,this.#P=z,this.#W=G,this.#X=A,this.#A=B,this.#V=_,this.#Z=L,this.#_=R,this.#G=w,this.#K=D;let I=w2($);if(this.#Q=this.#Q&r4|I|n5,I!==A0&&I!==M0&&I!==H4)this.#Q|=i4}#b=[];#S=!1;#p($){this.#S=!1;let Z=this.#b.slice();this.#b.length=0,Z.forEach((Q)=>Q(null,$))}readdirCB($,Z=!1){if(!this.canReaddir()){if(Z)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let Q=this.children();if(this.calledReaddir()){let X=Q.slice(0,Q.provisional);if(Z)$(null,X);else queueMicrotask(()=>$(null,X));return}if(this.#b.push($),this.#S)return;this.#S=!0;let J=this.fullpath();this.#$.readdir(J,{withFileTypes:!0},(X,V)=>{if(X)this.#g(X.code),Q.provisional=0;else{for(let K of V)this.#d(K,Q);this.#h(Q)}this.#p(Q.slice(0,Q.provisional));return})}#a;async readdir(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Z=this.fullpath();if(this.#a)await this.#a;else{let Q=()=>{};this.#a=new Promise((J)=>Q=J);try{for(let J of await this.#$.promises.readdir(Z,{withFileTypes:!0}))this.#d(J,$);this.#h($)}catch(J){this.#g(J.code),$.provisional=0}this.#a=void 0,Q()}return $.slice(0,$.provisional)}readdirSync(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Z=this.fullpath();try{for(let Q of this.#$.readdirSync(Z,{withFileTypes:!0}))this.#d(Q,$);this.#h($)}catch(Q){this.#g(Q.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#Q&i5)return!1;let $=U0&this.#Q;if(!($===A0||$===M0||$===H4))return!1;return!0}shouldWalk($,Z){return(this.#Q&M0)===M0&&!(this.#Q&i5)&&!$.has(this)&&(!Z||Z(this))}async realpath(){if(this.#E)return this.#E;if((N6|R6|R0)&this.#Q)return;try{let $=await this.#$.promises.realpath(this.fullpath());return this.#E=this.resolve($)}catch($){this.#f()}}realpathSync(){if(this.#E)return this.#E;if((N6|R6|R0)&this.#Q)return;try{let $=this.#$.realpathSync(this.fullpath());return this.#E=this.resolve($)}catch($){this.#f()}}[K1]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Z=new Set([]),Q=[],J=this;while(J&&J.parent)Z.add(J),J.#R=Q.join(this.sep),J.#I=Q.join("/"),J=J.parent,Q.push("..");J=$;while(J&&J.parent&&!Z.has(J))J.#R=void 0,J.#I=void 0,J=J.parent}}class P6 extends Q0{sep="\\";splitSep=VZ;constructor($,Z=A0,Q,J,X,V,K){super($,Z,Q,J,X,V,K)}newChild($,Z=A0,Q={}){return new P6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),Q)}getRootString($){return R2.parse($).root}getRoot($){if($=XZ($.toUpperCase()),$===this.root.name)return this.root;for(let[Z,Q]of Object.entries(this.roots))if(this.sameRoot($,Z))return this.roots[$]=Q;return this.roots[$]=new o4($,this).root}sameRoot($,Z=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(t5,"$1\\"),$===Z}}class D6 extends Q0{splitSep="/";sep="/";constructor($,Z=A0,Q,J,X,V,K){super($,Z,Q,J,X,V,K)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Z=A0,Q={}){return new D6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),Q)}}class N2{root;rootPath;roots;cwd;#$;#J;#X;nocase;#Z;constructor($=process.cwd(),Z,Q,{nocase:J,childrenCacheSize:X=16384,fs:V=n4}={}){if(this.#Z=e5(V),$ instanceof URL||$.startsWith("file://"))$=a8($);let K=Z.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#$=new C2,this.#J=new C2,this.#X=new V1(X);let W=K.substring(this.rootPath.length).split(Q);if(W.length===1&&!W[0])W.pop();if(J===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=J,this.root=this.newRoot(this.#Z),this.roots[this.rootPath]=this.root;let H=this.root,q=W.length-1,z=Z.sep,G=this.rootPath,A=!1;for(let B of W){let _=q--;H=H.child(B,{relative:Array(_).fill("..").join(z),relativePosix:Array(_).fill("..").join("/"),fullpath:G+=(A?"":z)+B}),A=!0}this.cwd=H}depth($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.depth()}childrenCache(){return this.#X}resolve(...$){let Z="";for(let X=$.length-1;X>=0;X--){let V=$[X];if(!V||V===".")continue;if(Z=Z?`${V}/${Z}`:V,this.isAbsolute(V))break}let Q=this.#$.get(Z);if(Q!==void 0)return Q;let J=this.cwd.resolve(Z).fullpath();return this.#$.set(Z,J),J}resolvePosix(...$){let Z="";for(let X=$.length-1;X>=0;X--){let V=$[X];if(!V||V===".")continue;if(Z=Z?`${V}/${Z}`:V,this.isAbsolute(V))break}let Q=this.#J.get(Z);if(Q!==void 0)return Q;let J=this.cwd.resolve(Z).fullpathPosix();return this.#J.set(Z,J),J}relative($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relative()}relativePosix($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relativePosix()}basename($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.name}dirname($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return($.parent||$).fullpath()}async readdir($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q}=Z;if(!$.canReaddir())return[];else{let J=await $.readdir();return Q?J:J.map((X)=>X.name)}}readdirSync($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0}=Z;if(!$.canReaddir())return[];else if(Q)return $.readdirSync();else return $.readdirSync().map((J)=>J.name)}async lstat($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstat()}lstatSync($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstatSync()}async readlink($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$.withFileTypes,$=this.cwd;let Q=await $.readlink();return Z?Q:Q?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$.withFileTypes,$=this.cwd;let Q=$.readlinkSync();return Z?Q:Q?.fullpath()}async realpath($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$.withFileTypes,$=this.cwd;let Q=await $.realpath();return Z?Q:Q?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$.withFileTypes,$=this.cwd;let Q=$.realpathSync();return Z?Q:Q?.fullpath()}async walk($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(Q?$:$.fullpath());let W=new Set,H=(z,G)=>{W.add(z),z.readdirCB((A,B)=>{if(A)return G(A);let _=B.length;if(!_)return G();let L=()=>{if(--_===0)G()};for(let R of B){if(!X||X(R))K.push(Q?R:R.fullpath());if(J&&R.isSymbolicLink())R.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,V)?H(w,L):L());else if(R.shouldWalk(W,V))H(R,L);else L()}},!0)},q=$;return new Promise((z,G)=>{H(q,(A)=>{if(A)return G(A);z(K)})})}walkSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(Q?$:$.fullpath());let W=new Set([$]);for(let H of W){let q=H.readdirSync();for(let z of q){if(!X||X(z))K.push(Q?z:z.fullpath());let G=z;if(z.isSymbolicLink()){if(!(J&&(G=z.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(W,V))W.add(G)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;return this.stream($,Z)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z;if(!X||X($))yield Q?$:$.fullpath();let K=new Set([$]);for(let W of K){let H=W.readdirSync();for(let q of H){if(!X||X(q))yield Q?q:q.fullpath();let z=q;if(q.isSymbolicLink()){if(!(J&&(z=q.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(K,V))K.add(z)}}}stream($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=new W4({objectMode:!0});if(!X||X($))K.write(Q?$:$.fullpath());let W=new Set,H=[$],q=0,z=()=>{let G=!1;while(!G){let A=H.shift();if(!A){if(q===0)K.end();return}q++,W.add(A);let B=(L,R,w=!1)=>{if(L)return K.emit("error",L);if(J&&!w){let D=[];for(let I of R)if(I.isSymbolicLink())D.push(I.realpath().then((S)=>S?.isUnknown()?S.lstat():S));if(D.length){Promise.all(D).then(()=>B(null,R,!0));return}}for(let D of R)if(D&&(!X||X(D))){if(!K.write(Q?D:D.fullpath()))G=!0}q--;for(let D of R){let I=D.realpathCached()||D;if(I.shouldWalk(W,V))H.push(I)}if(G&&!K.flowing)K.once("drain",z);else if(!_)z()},_=!0;A.readdirCB(B,!0),_=!1}};return z(),K}streamSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=new W4({objectMode:!0}),W=new Set;if(!X||X($))K.write(Q?$:$.fullpath());let H=[$],q=0,z=()=>{let G=!1;while(!G){let A=H.shift();if(!A){if(q===0)K.end();return}q++,W.add(A);let B=A.readdirSync();for(let _ of B)if(!X||X(_)){if(!K.write(Q?_:_.fullpath()))G=!0}q--;for(let _ of B){let L=_;if(_.isSymbolicLink()){if(!(J&&(L=_.realpathSync())))continue;if(L.isUnknown())L.lstatSync()}if(L.shouldWalk(W,V))H.push(L)}}if(G&&!K.flowing)K.once("drain",z)};return z(),K}chdir($=this.cwd){let Z=this.cwd;this.cwd=typeof $==="string"?this.cwd.resolve($):$,this.cwd[K1](Z)}}class o4 extends N2{sep="\\";constructor($=process.cwd(),Z={}){let{nocase:Q=!0}=Z;super($,R2,"\\",{...Z,nocase:Q});this.nocase=Q;for(let J=this.cwd;J;J=J.parent)J.nocase=this.nocase}parseRootPath($){return R2.parse($).root.toUpperCase()}newRoot($){return new P6(this.rootPath,M0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class e4 extends N2{sep="/";constructor($=process.cwd(),Z={}){let{nocase:Q=!1}=Z;super($,p8,"/",{...Z,nocase:Q});this.nocase=Q}parseRootPath($){return"/"}newRoot($){return new D6(this.rootPath,M0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class F6 extends e4{constructor($=process.cwd(),Z={}){let{nocase:Q=!0}=Z;super($,{...Z,nocase:Q})}}var QW=process.platform==="win32"?P6:D6,W1=process.platform==="win32"?o4:process.platform==="darwin"?F6:e4;var WZ=($)=>$.length>=1,HZ=($)=>$.length>=1;class R4{#$;#J;#X;length;#Z;#K;#P;#_;#z;#W;#G=!0;constructor($,Z,Q,J){if(!WZ($))throw TypeError("empty pattern list");if(!HZ(Z))throw TypeError("empty glob list");if(Z.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,Q<0||Q>=this.length)throw TypeError("index out of range");if(this.#$=$,this.#J=Z,this.#X=Q,this.#Z=J,this.#X===0){if(this.isUNC()){let[X,V,K,W,...H]=this.#$,[q,z,G,A,...B]=this.#J;if(H[0]==="")H.shift(),B.shift();let _=[X,V,K,W,""].join("/"),L=[q,z,G,A,""].join("/");this.#$=[_,...H],this.#J=[L,...B],this.length=this.#$.length}else if(this.isDrive()||this.isAbsolute()){let[X,...V]=this.#$,[K,...W]=this.#J;if(V[0]==="")V.shift(),W.shift();let H=X+"/",q=K+"/";this.#$=[H,...V],this.#J=[q,...W],this.length=this.#$.length}}}pattern(){return this.#$[this.#X]}isString(){return typeof this.#$[this.#X]==="string"}isGlobstar(){return this.#$[this.#X]===m}isRegExp(){return this.#$[this.#X]instanceof RegExp}globString(){return this.#P=this.#P||(this.#X===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#X).join("/"))}hasMore(){return this.length>this.#X+1}rest(){if(this.#K!==void 0)return this.#K;if(!this.hasMore())return this.#K=null;return this.#K=new R4(this.#$,this.#J,this.#X+1,this.#Z),this.#K.#W=this.#W,this.#K.#z=this.#z,this.#K.#_=this.#_,this.#K}isUNC(){let $=this.#$;return this.#z!==void 0?this.#z:this.#z=this.#Z==="win32"&&this.#X===0&&$[0]===""&&$[1]===""&&typeof $[2]==="string"&&!!$[2]&&typeof $[3]==="string"&&!!$[3]}isDrive(){let $=this.#$;return this.#_!==void 0?this.#_:this.#_=this.#Z==="win32"&&this.#X===0&&this.length>1&&typeof $[0]==="string"&&/^[a-z]:$/i.test($[0])}isAbsolute(){let $=this.#$;return this.#W!==void 0?this.#W:this.#W=$[0]===""&&$.length>1||this.isDrive()||this.isUNC()}root(){let $=this.#$[0];return typeof $==="string"&&this.isAbsolute()&&this.#X===0?$:""}checkFollowGlobstar(){return!(this.#X===0||!this.isGlobstar()||!this.#G)}markFollowGlobstar(){if(this.#X===0||!this.isGlobstar()||!this.#G)return!1;return this.#G=!1,!0}}var qZ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class t4{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Z,nocase:Q,noext:J,noglobstar:X,platform:V=qZ}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=V,this.mmopts={dot:!0,nobrace:Z,nocase:Q,noext:J,noglobstar:X,optimizationLevel:2,platform:V,nocomment:!0,nonegate:!0};for(let K of $)this.add(K)}add($){let Z=new j0($,this.mmopts);for(let Q=0;Q<Z.set.length;Q++){let J=Z.set[Q],X=Z.globParts[Q];if(!J||!X)throw Error("invalid pattern object");while(J[0]==="."&&X[0]===".")J.shift(),X.shift();let V=new R4(J,X,0,this.platform),K=new j0(V.globString(),this.mmopts),W=X[X.length-1]==="**",H=V.isAbsolute();if(H)this.absolute.push(K);else this.relative.push(K);if(W)if(H)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored($){let Z=$.fullpath(),Q=`${Z}/`,J=$.relative()||".",X=`${J}/`;for(let V of this.relative)if(V.match(J)||V.match(X))return!0;for(let V of this.absolute)if(V.match(Z)||V.match(Q))return!0;return!1}childrenIgnored($){let Z=$.fullpath()+"/",Q=($.relative()||".")+"/";for(let J of this.relativeChildren)if(J.match(Q))return!0;for(let J of this.absoluteChildren)if(J.match(Z))return!0;return!1}}class P2{store;constructor($=new Map){this.store=$}copy(){return new P2(new Map(this.store))}hasWalked($,Z){return this.store.get($.fullpath())?.has(Z.globString())}storeWalked($,Z){let Q=$.fullpath(),J=this.store.get(Q);if(J)J.add(Z.globString());else this.store.set(Q,new Set([Z.globString()]))}}class H1{store=new Map;add($,Z,Q){let J=(Z?2:0)|(Q?1:0),X=this.store.get($);this.store.set($,X===void 0?J:J&X)}entries(){return[...this.store.entries()].map(([$,Z])=>[$,!!(Z&2),!!(Z&1)])}}class q1{store=new Map;add($,Z){if(!$.canReaddir())return;let Q=this.store.get($);if(Q){if(!Q.find((J)=>J.globString()===Z.globString()))Q.push(Z)}else this.store.set($,[Z])}get($){let Z=this.store.get($);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map(($)=>[$,this.store.get($)])}keys(){return[...this.store.keys()].filter(($)=>$.canReaddir())}}class $6{hasWalkedCache;matches=new H1;subwalks=new q1;patterns;follow;dot;opts;constructor($,Z){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Z?Z.copy():new P2}processPatterns($,Z){this.patterns=Z;let Q=Z.map((J)=>[$,J]);for(let[J,X]of Q){this.hasWalkedCache.storeWalked(J,X);let V=X.root(),K=X.isAbsolute()&&this.opts.absolute!==!1;if(V){J=J.resolve(V==="/"&&this.opts.root!==void 0?this.opts.root:V);let z=X.rest();if(!z){this.matches.add(J,!0,!1);continue}else X=z}if(J.isENOENT())continue;let W,H,q=!1;while(typeof(W=X.pattern())==="string"&&(H=X.rest()))J=J.resolve(W),X=H,q=!0;if(W=X.pattern(),H=X.rest(),q){if(this.hasWalkedCache.hasWalked(J,X))continue;this.hasWalkedCache.storeWalked(J,X)}if(typeof W==="string"){let z=W===".."||W===""||W===".";this.matches.add(J.resolve(W),K,z);continue}else if(W===m){if(!J.isSymbolicLink()||this.follow||X.checkFollowGlobstar())this.subwalks.add(J,X);let z=H?.pattern(),G=H?.rest();if(!H||(z===""||z===".")&&!G)this.matches.add(J,K,z===""||z===".");else if(z===".."){let A=J.parent||J;if(!G)this.matches.add(A,K,!0);else if(!this.hasWalkedCache.hasWalked(A,G))this.subwalks.add(A,G)}}else if(W instanceof RegExp)this.subwalks.add(J,X)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new $6(this.opts,this.hasWalkedCache)}filterEntries($,Z){let Q=this.subwalks.get($),J=this.child();for(let X of Z)for(let V of Q){let K=V.isAbsolute(),W=V.pattern(),H=V.rest();if(W===m)J.testGlobstar(X,V,H,K);else if(W instanceof RegExp)J.testRegExp(X,W,H,K);else J.testString(X,W,H,K)}return J}testGlobstar($,Z,Q,J){if(this.dot||!$.name.startsWith(".")){if(!Z.hasMore())this.matches.add($,J,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Z);else if($.isSymbolicLink()){if(Q&&Z.checkFollowGlobstar())this.subwalks.add($,Q);else if(Z.markFollowGlobstar())this.subwalks.add($,Z)}}}if(Q){let X=Q.pattern();if(typeof X==="string"&&X!==".."&&X!==""&&X!==".")this.testString($,X,Q.rest(),J);else if(X===".."){let V=$.parent||$;this.subwalks.add(V,Q)}else if(X instanceof RegExp)this.testRegExp($,X,Q.rest(),J)}}testRegExp($,Z,Q,J){if(!Z.test($.name))return;if(!Q)this.matches.add($,J,!1);else this.subwalks.add($,Q)}testString($,Z,Q,J){if(!$.isNamed(Z))return;if(!Q)this.matches.add($,J,!1);else this.subwalks.add($,Q)}}var YZ=($,Z)=>typeof $==="string"?new t4([$],Z):Array.isArray($)?new t4($,Z):$;class D2{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#$=[];#J;#X;signal;maxDepth;includeChildMatches;constructor($,Z,Q){if(this.patterns=$,this.path=Z,this.opts=Q,this.#X=!Q.posix&&Q.platform==="win32"?"\\":"/",this.includeChildMatches=Q.includeChildMatches!==!1,Q.ignore||!this.includeChildMatches){if(this.#J=YZ(Q.ignore??[],Q),!this.includeChildMatches&&typeof this.#J.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=Q.maxDepth||1/0,Q.signal)this.signal=Q.signal,this.signal.addEventListener("abort",()=>{this.#$.length=0})}#Z($){return this.seen.has($)||!!this.#J?.ignored?.($)}#K($){return!!this.#J?.childrenIgnored?.($)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let $=void 0;while(!this.paused&&($=this.#$.shift()))$()}onResume($){if(this.signal?.aborted)return;if(!this.paused)$();else this.#$.push($)}async matchCheck($,Z){if(Z&&this.opts.nodir)return;let Q;if(this.opts.realpath){if(Q=$.realpathCached()||await $.realpath(),!Q)return;$=Q}let X=$.isUnknown()||this.opts.stat?await $.lstat():$;if(this.opts.follow&&this.opts.nodir&&X?.isSymbolicLink()){let V=await X.realpath();if(V&&(V.isUnknown()||this.opts.stat))await V.lstat()}return this.matchCheckTest(X,Z)}matchCheckTest($,Z){return $&&(this.maxDepth===1/0||$.depth()<=this.maxDepth)&&(!Z||$.canReaddir())&&(!this.opts.nodir||!$.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!$.isSymbolicLink()||!$.realpathCached()?.isDirectory())&&!this.#Z($)?$:void 0}matchCheckSync($,Z){if(Z&&this.opts.nodir)return;let Q;if(this.opts.realpath){if(Q=$.realpathCached()||$.realpathSync(),!Q)return;$=Q}let X=$.isUnknown()||this.opts.stat?$.lstatSync():$;if(this.opts.follow&&this.opts.nodir&&X?.isSymbolicLink()){let V=X.realpathSync();if(V&&(V?.isUnknown()||this.opts.stat))V.lstatSync()}return this.matchCheckTest(X,Z)}matchFinish($,Z){if(this.#Z($))return;if(!this.includeChildMatches&&this.#J?.add){let X=`${$.relativePosix()}/**`;this.#J.add(X)}let Q=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add($);let J=this.opts.mark&&$.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit($);else if(Q){let X=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(X+J)}else{let X=this.opts.posix?$.relativePosix():$.relative(),V=this.opts.dotRelative&&!X.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!X?"."+J:V+X+J)}}async match($,Z,Q){let J=await this.matchCheck($,Q);if(J)this.matchFinish(J,Z)}matchSync($,Z,Q){let J=this.matchCheckSync($,Q);if(J)this.matchFinish(J,Z)}walkCB($,Z,Q){if(this.signal?.aborted)Q();this.walkCB2($,Z,new $6(this.opts),Q)}walkCB2($,Z,Q,J){if(this.#K($))return J();if(this.signal?.aborted)J();if(this.paused){this.onResume(()=>this.walkCB2($,Z,Q,J));return}Q.processPatterns($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,W,H).then(()=>V())}for(let K of Q.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,Q,V);else K.readdirCB((H,q)=>this.walkCB3(K,q,Q,V),!0)}V()}walkCB3($,Z,Q,J){Q=Q.filterEntries($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,W,H).then(()=>V())}for(let[K,W]of Q.subwalks.entries())X++,this.walkCB2(K,W,Q.child(),V);V()}walkCBSync($,Z,Q){if(this.signal?.aborted)Q();this.walkCB2Sync($,Z,new $6(this.opts),Q)}walkCB2Sync($,Z,Q,J){if(this.#K($))return J();if(this.signal?.aborted)J();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Z,Q,J));return}Q.processPatterns($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,W,H)}for(let K of Q.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let W=K.readdirSync();this.walkCB3Sync(K,W,Q,V)}V()}walkCB3Sync($,Z,Q,J){Q=Q.filterEntries($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,W,H)}for(let[K,W]of Q.subwalks.entries())X++,this.walkCB2Sync(K,W,Q.child(),V);V()}}class M6 extends D2{matches=new Set;constructor($,Z,Q){super($,Z,Q)}matchEmit($){this.matches.add($)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise(($,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else $(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class I6 extends D2{results;constructor($,Z,Q){super($,Z,Q);this.results=new W4({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit($){if(this.results.write($),!this.results.flowing)this.pause()}stream(){let $=this.path;if($.isUnknown())$.lstat().then(()=>{this.walkCB($,this.patterns,()=>this.results.end())});else this.walkCB($,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var GZ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class I0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor($,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=zZ(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof $==="string")$=[$];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)$=$.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");$=$.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=$,this.platform=Z.platform||GZ,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=Z.platform==="win32"?o4:Z.platform==="darwin"?F6:Z.platform?e4:W1;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let Q=this.platform==="darwin"||this.platform==="win32",J={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:Q,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},X=this.pattern.map((W)=>new j0(W,J)),[V,K]=X.reduce((W,H)=>{return W[0].push(...H.set),W[1].push(...H.globParts),W},[[],[]]);this.patterns=V.map((W,H)=>{let q=K[H];if(!q)throw Error("invalid pattern object");return new R4(W,q,0,this.platform)})}async walk(){return[...await new M6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new M6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new I6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new I6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var F2=($,Z={})=>{if(!Array.isArray($))$=[$];for(let Q of $)if(new j0(Q,Z).hasMagic())return!0;return!1};function S6($,Z={}){return new I0($,Z).streamSync()}function z1($,Z={}){return new I0($,Z).stream()}function G1($,Z={}){return new I0($,Z).walkSync()}async function Y1($,Z={}){return new I0($,Z).walk()}function T6($,Z={}){return new I0($,Z).iterateSync()}function j1($,Z={}){return new I0($,Z).iterate()}var jZ=S6,UZ=Object.assign(z1,{sync:S6}),AZ=T6,BZ=Object.assign(j1,{sync:T6}),LZ=Object.assign(G1,{stream:S6,iterate:T6}),E6=Object.assign(Y1,{glob:Y1,globSync:G1,sync:LZ,globStream:z1,stream:UZ,globStreamSync:S6,streamSync:jZ,globIterate:j1,iterate:BZ,globIterateSync:T6,iterateSync:AZ,Glob:I0,hasMagic:F2,escape:L4,unescape:_0});E6.glob=E6;var Q4=Q5(x9(),1),vX=new Set(["png","jpg","jpeg","gif","webp"]),OX=new Set(["mp3","wav","flac","ogg","aac","m4a","wma","aiff","opus","mp4","avi","mov","wmv","flv","mkv","webm","m4v","mpeg","mpg","zip","rar","tar","gz","bz2","7z","xz","z","tgz","iso","exe","dll","so","dylib","app","msi","deb","rpm","bin","dat","db","sqlite","sqlite3","mdb","idx","doc","docx","xls","xlsx","ppt","pptx","odt","ods","odp","ttf","otf","woff","woff2","eot","psd","ai","eps","sketch","fig","xd","blend","obj","3ds","max","class","jar","war","pyc","pyo","rlib","swf","fla"]),yX=25000,bX=5242880,v9=3932160,O9=400,fX=20,hX=[{signature:[137,80,78,71],mimeType:"image/png"},{signature:[255,216,255],mimeType:"image/jpeg"},{signature:[71,73,70,56],mimeType:"image/gif"},{signature:[82,73,70,70],mimeType:"image/webp"}];function gX($){if($.length<4)return null;for(let{signature:Z,mimeType:Q}of hX){let J=!0;for(let X=0;X<Z.length;X++)if($[X]!==Z[X]){J=!1;break}if(J){if(Q==="image/webp"){if($.length>=12&&$[8]===87&&$[9]===69&&$[10]===66&&$[11]===80)return"image/webp";continue}return Q}}return null}async function y9($,Z=yX,Q){let J=Bun.file($),X=Buffer.from(await J.arrayBuffer());if(X.length===0)throw Error(`Image file is empty: ${$}`);if(X.length>bX)throw Error(`Image file too large: ${$} (${(X.length/1024/1024).toFixed(2)}MB > 5MB limit)`);if(!gX(X))throw Error(`Unsupported image format: ${$}`);let K=Q4.default(X),W=await K.metadata(),H={originalWidth:W.width,originalHeight:W.height},q=(W.width||0)*(W.height||0);if(q>v9){let L=Math.sqrt(v9/q),R=Math.round((W.width||1)*L),w=Math.round((W.height||1)*L);K=Q4.default(X).resize(R,w,{fit:"inside",withoutEnlargement:!0})}let z=W.format||"jpeg",G;if(z==="png")G=await K.png().toBuffer();else if(z==="webp")G=await K.webp().toBuffer();else if(z==="gif")G=await K.gif().toBuffer();else G=await K.jpeg({quality:85}).toBuffer(),z="jpeg";let A=G.toString("base64");if(Math.ceil(A.length*0.125)>Z)try{let L=await dX(X,Z),R=L.toString("base64"),w=await Q4.default(L).metadata();return{type:"image",base64:R,mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:W.width,originalHeight:W.height,displayWidth:w.width,displayHeight:w.height}}}catch(L){let R=await Q4.default(X).resize(O9,O9,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:fX}).toBuffer(),w=await Q4.default(R).metadata();return{type:"image",base64:R.toString("base64"),mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:W.width,originalHeight:W.height,displayWidth:w.width,displayHeight:w.height}}}return{type:"image",base64:A,mediaType:z==="jpeg"?"image/jpeg":z==="png"?"image/png":z==="gif"?"image/gif":z==="webp"?"image/webp":"image/jpeg",originalSize:X.length,dimensions:{originalWidth:W.width,originalHeight:W.height,displayWidth:W.width,displayHeight:W.height}}}async function dX($,Z){let Q=Math.floor(Z*0.8/0.125),J=Math.floor(Q*0.75),V=await Q4.default($).metadata(),K=$.length;if(K<=J)return $;let W=Math.sqrt(J/K),H=Math.round((V.width||1)*W),q=Math.round((V.height||1)*W);return Q4.default($).resize(H,q,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:70}).toBuffer()}function b9($){let Z=$.toLowerCase().replace(/^\./,"");return vX.has(Z)}function f9($){let Z=$.toLowerCase().replace(/^\./,"");return OX.has(Z)}function h9($){return{type:"image",source:{type:"base64",data:$.base64,media_type:$.mediaType}}}function g9($){let Z=$.dimensions,Q=Z?.originalWidth&&Z?.originalHeight?` (${Z.originalWidth}x${Z.originalHeight}${Z.displayWidth!==Z.originalWidth?` \u2192 ${Z.displayWidth}x${Z.displayHeight}`:""})`:"";return`[Image: ${$.mediaType}${Q}, ${($.originalSize/1024).toFixed(1)}KB original]`}import*as d9 from"path";var uX={name:"Read",description:`Reads a file from the local filesystem. You can access any file directly by using this tool.
94
+
95
+ Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid.
96
+
97
+ This tool allows Claude Code to read images (PNG, JPG, JPEG, GIF, WEBP) and PDF files.
98
+
99
+ Usage:
100
+ - The file_path parameter must be an absolute path, not a relative path
101
+ - By default, reads up to 2000 lines starting from the beginning of the file
102
+ - You can optionally specify line offset and limit (especially handy for long files)
103
+ - Any lines longer than 2000 characters will be truncated
104
+ - Results are returned using cat -n format, with line numbers starting at 1
105
+
106
+ This tool can read images (PNG, JPG, JPEG, GIF, WEBP). When reading images, the tool displays them visually.
107
+
108
+ For PDF files:
109
+ - Get the pages parameter to read specific page ranges (e.g., pages: "1-5")
110
+ - Maximum 20 pages per request
111
+ - For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific page ranges.
112
+
113
+ Try to read the whole file by default, but for particularly large files, you should consider reading the file in chunks.
114
+
115
+ If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`,input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to read"},offset:{type:"number",description:"The line number to start reading from (1-based)"},limit:{type:"number",description:"The number of lines to read"},pages:{type:"string",description:'Page range for PDF files (e.g., "1-5")'}},required:["file_path"]},handler:async($,Z)=>{let Q=$.file_path,J=$.offset||1,X=$.limit||2000;try{let V=d9.extname(Q).toLowerCase().slice(1);if(b9(V))return await mX(Q,Z.abortSignal);if(f9(V))return{content:`Binary file detected: ${Q}
116
+ This file type (${V}) is not supported for text reading.`,is_error:!0};let K=Bun.file(Q);if(!await K.exists())return{content:`Error: File not found: ${Q}`,is_error:!0};let H=(await K.text()).split(`
117
+ `),q=Math.max(0,J-1),z=Math.min(H.length,q+X),G=H.slice(q,z),A=z<H.length,_=G.map((L,R)=>`${q+R+1} ${L}`).join(`
118
+ `);if(A)_+=`
119
+
120
+ > WARNING: ${Q} is ${H.length} lines (limit: ${X}). Only the first ${X} lines were loaded.`;return{content:_}}catch(V){return{content:`Error reading file: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}};async function mX($,Z){try{let Q=await y9($,25000,Z),J=h9(Q);return{content:[{type:"text",text:g9(Q)},J]}}catch(Q){return{content:`Error reading image: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}var cX={name:"Write",description:"Writes a file to the local filesystem. This tool will overwrite the existing file if there is one at the provided path.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to write"},content:{type:"string",description:"The content to write to the file"}},required:["file_path","content"]},handler:async($,Z)=>{let{file_path:Q,content:J}=$;try{return await Bun.write(Q,J),{content:`Successfully wrote to ${Q}`}}catch(X){return{content:`Error writing file: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},lX={name:"Edit",description:"Performs exact string replacements in files. Use this tool to modify existing files.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to modify"},old_string:{type:"string",description:"The text to replace"},new_string:{type:"string",description:"The text to replace it with"},replace_all:{type:"boolean",description:"Replace all occurrences (default false)"}},required:["file_path","old_string","new_string"]},handler:async($,Z)=>{let{file_path:Q,old_string:J,new_string:X}=$,V=$.replace_all||!1;try{let W=await Bun.file(Q).text();if(V){let H=W;W=W.split(J).join(X);let q=(H.match(new RegExp(pX(J),"g"))||[]).length;if(q===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write(Q,W),{content:`Successfully replaced ${q} occurrences`}}else{let H=W.indexOf(J);if(H===-1)return{content:"Error: String not found in file",is_error:!0};if(W.indexOf(J,H+1)!==-1)return{content:"Error: String appears multiple times in file. Use replace_all or provide more context.",is_error:!0};return W=W.replace(J,X),await Bun.write(Q,W),{content:`Successfully edited ${Q}`}}}catch(K){return{content:`Error editing file: ${K instanceof Error?K.message:String(K)}`,is_error:!0}}}};function pX($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var aX={name:"Bash",description:"Executes a given bash command with optional timeout. Working directory persists between commands.",input_schema:{type:"object",properties:{command:{type:"string",description:"The command to execute"},timeout:{type:"number",description:"Optional timeout in milliseconds (max 600000)"},description:{type:"string",description:"Clear, concise description of what this command does"}},required:["command"]},handler:async($,Z)=>{let Q=$.command,J=$.timeout||120000;try{let X=Bun.spawnSync(["sh","-c",Q],{cwd:Z.workingDirectory,timeout:J,maxBuffer:31457280}),V=X.stdout?.toString()||"",K=X.stderr?.toString()||"";if(X.exitCode!==0)return{content:`Exit code: ${X.exitCode}
121
+ ${V}
122
+ ${K}`.trim(),is_error:!0};return{content:V||"(no output)"}}catch(X){return{content:`Error executing command: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},rX={name:"Glob",description:"Fast file pattern matching tool that works with any codebase size. Supports glob patterns.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The glob pattern to match files"},path:{type:"string",description:"The directory to search (default: current directory)"}},required:["pattern"]},handler:async($,Z)=>{let Q=$.pattern,J=$.path||Z.workingDirectory;try{let X=await E6(Q,{cwd:J,absolute:!0,nodir:!0});if(X.length===0)return{content:"No files found matching pattern"};return{content:X.sort().join(`
123
+ `)}}catch(X){return{content:`Error searching files: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},nX={name:"Grep",description:"A powerful search tool built on ripgrep. Supports full regex syntax.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The regular expression pattern to search for"},path:{type:"string",description:"File or directory to search"},glob:{type:"string",description:"Glob pattern to filter files"},output_mode:{type:"string",enum:["content","files_with_matches","count"],description:"Output mode (default: content)"},"-i:":{type:"boolean",description:"Case insensitive search"},"-C:":{type:"number",description:"Context lines around match"},head_limit:{type:"number",description:"Maximum number of results"}},required:["pattern"]},handler:async($,Z)=>{let Q=$.pattern,J=$.path||Z.workingDirectory,X=$.glob,V=$.output_mode||"content",K=$["-i:"],W=$["-C:"],H=$.head_limit;try{let q=["--json"];if(K)q.push("-i");if(W)q.push("-C",String(W));if(X)q.push("--glob",X);if(V==="files_with_matches")q.push("--files-with-matches");if(V==="count")q.push("--count");q.push(Q,J);let G=Bun.spawnSync(["rg",...q],{cwd:Z.workingDirectory,maxBuffer:10485760}).stdout?.toString()||"";if(!G.trim())return{content:"No matches found"};if(V==="content"){let A=G.trim().split(`
124
+ `),B=[];for(let _ of A.slice(0,H||100))try{let L=JSON.parse(_);if(L.type==="match"){let R=L.data?.path?.text||"",w=L.data?.line_number||0,D=L.data?.lines?.text||"";B.push(`${R}:${w}:${D.trim()}`)}}catch{B.push(_)}return{content:B.join(`
125
+ `)||"No matches found"}}return{content:G.trim()}}catch(q){return{content:`Error searching: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},iX={name:"Task",description:`Launch a new agent to handle complex, multi-step tasks autonomously.
126
+
127
+ The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
128
+
129
+ Available agent types and their tools:
130
+ - Bash: Command execution specialist for running bash commands. Use for git operations, command execution, and other terminal tasks.
131
+ - general-purpose: General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks.
132
+ - Explore: Fast agent specialized for exploring codebases. Use to quickly find files by patterns, search code for keywords, or answer questions about the codebase.
133
+ - Plan: Software architect agent for designing implementation plans. Returns step-by-step plans, identifies critical files and considers architectural trade-offs.
134
+
135
+ When using the Task tool, you must specify a subagent_type parameter to select the agent type.
136
+
137
+ Usage notes:
138
+ - Always include a short description (3-5 words) summarizing what the agent will do
139
+ - Launch multiple agents concurrently whenever possible to maximize performance
140
+ - Agents can be resumed using the "resume" parameter by passing the agent ID from a previous invocation.`,input_schema:{type:"object",properties:{subagent_type:{type:"string",enum:["Bash","general-purpose","Explore","Plan"],description:"The agent type to launch"},description:{type:"string",description:"A short (3-5 word) description of what the agent will do"},prompt:{type:"string",description:"The task for the agent to perform"},resume:{type:"string",description:"Resume a previous agent by its ID"},model:{type:"string",enum:["sonnet","opus","haiku"],description:"Model for the subagent (default: haiku for quick tasks)"},run_in_background:{type:"boolean",description:"Run the agent in the background"}},required:["subagent_type","prompt"]},handler:async($,Z)=>{let{subagent_type:Q,prompt:J,description:X}=$,V=$.model||"haiku",K=$.resume,W=$.run_in_background,H=K||`${Q.toLowerCase()}-${Date.now().toString(36)}`;try{let q=process.env.ANTHROPIC_API_KEY||process.env.CLAUDE_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN||process.env.Z_AI_API_KEY||"";if(!q)return{content:"Error: No API key available for subagent. Set ANTHROPIC_API_KEY, CLAUDE_API_KEY, ANTHROPIC_AUTH_TOKEN, or Z_AI_API_KEY environment variable.",is_error:!0};let z={haiku:"claude-haiku-4-5",sonnet:"claude-sonnet-4-6",opus:"claude-opus-4-6"},G=z[V]||z.haiku,A=[import.meta.dir+"/../../dist/cli.js",import.meta.dir+"/../cli.ts",process.cwd()+"/dist/cli.js",process.cwd()+"/src/cli.ts"],B=null;for(let D of A)try{if(await Bun.file(D).exists()){B=D;break}}catch{}if(!B)return{content:`Error: Could not find CLI. Tried:
141
+ ${A.join(`
142
+ `)}`,is_error:!0};let _=["run",B,"-m",G,"-p",Z.permissionMode,"-q",J];if(W)return Bun.spawn(["bun",..._],{cwd:Z.workingDirectory,detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,ANTHROPIC_API_KEY:q}}).unref(),{content:JSON.stringify({agentId:H,status:"running",message:`Agent started in background. Use TaskOutput tool with task_id: "${H}" to check results.`,description:X||"Background task"})};let L=Bun.spawnSync(["bun",..._],{cwd:Z.workingDirectory,timeout:300000,maxBuffer:10485760,env:{...process.env,ANTHROPIC_API_KEY:q}}),R=L.stdout?.toString()||"",w=L.stderr?.toString()||"";if(L.exitCode!==0)return{content:`Agent failed with exit code ${L.exitCode}
143
+ ${w}
144
+ ${R}`.trim(),is_error:!0};return{content:JSON.stringify({agentId:H,status:"completed",output:R,description:X||"Task completed"})}}catch(q){return{content:`Error running subagent: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},sX={name:"TaskOutput",description:`Retrieves output from a running or completed task (background shell, agent, or remote session).
145
+
146
+ Takes a task_id parameter identifying the task.
147
+ Returns the task output along with status information.
148
+ Use block=true (default) to wait for task completion.
149
+ Use block=false for non-blocking check of current status.
150
+
151
+ Task IDs can be found using the /tasks command
152
+ Works with all task types: background shells, async agents, and remote sessions`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The task ID to get output from"},block:{type:"boolean",description:"Whether to wait for completion (default: true)",default:!0},timeout:{type:"number",description:"Max wait time in ms (default: 30000, max: 600000)",default:30000,minimum:0,maximum:600000}},required:["task_id"]},handler:async($,Z)=>{let Q=$.task_id,J=$.block??!0,X=$.timeout??30000;try{let V=`${Z.workingDirectory}/.claude/tasks/${Q}.json`,K=Bun.file(V);if(!await K.exists())return{content:`Task not found: ${Q}. Use /tasks to list available tasks.`,is_error:!0};let W=await K.json();if(J&&W.status==="running"){let H=Date.now();while(Date.now()-H<X){await new Promise((z)=>setTimeout(z,1000));let q=Bun.file(V);if(await q.exists()){let z=await q.json();if(z.status!=="running")return{content:JSON.stringify({task_id:Q,status:z.status,output:z.output,error:z.error,duration:z.endTime?z.endTime-z.startTime:null},null,2)}}}return{content:JSON.stringify({task_id:Q,status:"timeout",message:`Task still running after ${X}ms`},null,2)}}return{content:JSON.stringify({task_id:Q,status:W.status,output:W.output,error:W.error,duration:W.endTime?W.endTime-W.startTime:null},null,2)}}catch(V){return{content:`Error getting task output: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},oX={name:"AskUserQuestion",description:`Use this tool when you need to ask the user questions during execution.
153
+
154
+ This allows you to:
155
+ 1. Gather user preferences or requirements
156
+ 2. Clarify ambiguous instructions
157
+ 3. Get decisions on implementation choices
158
+ 4. Offer choices to the user about what direction to take
159
+
160
+ Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
161
+
162
+ The options array should have 2-4 options. Each option should be a distinct, mutually exclusive choice.
163
+ The preview feature allows showing markdown content in a side-by-side layout.
164
+
165
+ User can always select "Other" to provide custom text input.`,input_schema:{type:"object",properties:{questions:{type:"array",description:"Questions to ask the user (1-4 questions)",items:{type:"object",properties:{question:{type:"string",description:"The complete question to ask the user"},header:{type:"string",description:"Very short label displayed as a chip/tag (max 12 chars)"},options:{type:"array",description:"The available choices (2-4 options)",items:{type:"object",properties:{label:{type:"string",description:"The display text for this option (5 words max)"},description:{type:"string",description:"Explanation of what this option means"},markdown:{type:"string",description:"Optional preview content shown in a monospace box"}},required:["label","description"]},minItems:2,maxItems:4},multiSelect:{type:"boolean",description:"Allow selecting multiple options (default: false)",default:!1}},required:["question","header","options"]},minItems:1,maxItems:4}},required:["questions"]},handler:async($,Z)=>{let Q=$.questions;try{let J=Q.map((X,V)=>{let K=X.options.map((W,H)=>{let q=` ${H+1}. ${W.label}`;if(W.description)q+=` - ${W.description}`;return q}).join(`
166
+ `);return`## Question ${V+1}: [${X.header}]
167
+ ${X.question}
168
+
169
+ Options:
170
+ ${K}${X.multiSelect?`
171
+ (multi-select enabled)`:""}`}).join(`
172
+
173
+ ---
174
+
175
+ `);return{content:JSON.stringify({type:"user_question",questions:Q,formatted:J,message:"Questions prepared for user response"},null,2)}}catch(J){return{content:`Error preparing questions: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},eX={name:"EnterPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
176
+
177
+ How This Tool Works:
178
+ - You should have already written your plan to the plan file specified in the plan mode system message
179
+ - This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote
180
+ - This tool simply signals that you're done planning and ready for the user to review and approve
181
+
182
+ When to Use This Tool:
183
+ IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you're gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.
184
+
185
+ Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
186
+
187
+ Examples:
188
+ - "Search for and understand the implementation of vim mode" - Do NOT use this tool
189
+ - "Help me implement yank mode for vim" - Use EnterPlanMode
190
+
191
+ Important notes:
192
+ - NEVER run additional commands to read or explore code, besides git bash commands
193
+ - NEVER use the TodoWrite or Task tools
194
+ - DO NOT commit files that likely contain secrets (.env, credentials.json, etc.)
195
+ - If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to (e.g., 'Bash')"},prompt:{type:"string",description:"Semantic description of the action (e.g., 'run tests', 'install dependencies')"}},required:["tool","prompt"]}}},required:[]},handler:async($,Z)=>{let Q=$.allowedPrompts;try{let J=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(J);if(!await X.exists())return{content:"Error: No plan file found. Please write your plan to .claude/plan.md first.",is_error:!0};let V=await X.text();return{content:JSON.stringify({type:"plan_ready",planFile:J,planLength:V.length,allowedPrompts:Q||[],message:"Plan is ready for user review. ExitPlanMode will request user approval."},null,2)}}catch(J){return{content:`Error entering plan mode: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},tX={name:"ExitPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
196
+
197
+ This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote.
198
+ This tool simply signals that you're done planning and ready for the user to review and approve.
199
+
200
+ IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code.
201
+ ExitPlanMode inherently requests user approval of the plan.`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to"},prompt:{type:"string",description:"Semantic description of the action"}},required:["tool","prompt"]}}},required:[]},handler:async($,Z)=>{let Q=$.allowedPrompts;try{let J=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(J);if(!await X.exists())return{content:"Error: No plan file found at .claude/plan.md",is_error:!0};let V=await X.text();return{content:JSON.stringify({type:"exit_plan_mode",status:"awaiting_approval",planFile:J,planPreview:V.slice(0,500)+(V.length>500?"...":""),allowedPrompts:Q||[],message:"Plan submitted for user approval."},null,2)}}catch(J){return{content:`Error exiting plan mode: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},$V={name:"Skill",description:`Execute a skill within the main conversation.
202
+
203
+ When users ask you to perform tasks, check if any of the available skills match. Skills provide specialized capabilities and domain knowledge.
204
+
205
+ When users reference a "slash command" or "/<something>" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke it.
206
+
207
+ How to invoke:
208
+ - Use this tool with the skill name and optional arguments
209
+ - Examples:
210
+ - skill: "commit" - invoke the commit skill
211
+ - skill: "review-pr", args: "123" - invoke with arguments
212
+ - Use fully qualified name for namespaced skills: skill: "ms-office-suite:pdf"
213
+
214
+ Available skills are listed in system-reminder messages in the conversation.
215
+ When a skill matches the user's request, this is a BLOCKING REQUIREMENT: invoke the relevant Skill tool BEFORE generating any other response about the task.
216
+
217
+ Important:
218
+ - NEVER mention a skill without actually calling this tool
219
+ - Do not invoke a skill that is already running
220
+ - Do not use this tool for built-in CLI commands (like /help, /clear)`,input_schema:{type:"object",properties:{skill:{type:"string",description:"The skill name (e.g., 'commit', 'review-pr', or fully qualified 'namespace:skill')"},args:{type:"string",description:"Optional arguments for the skill"}},required:["skill"]},handler:async($,Z)=>{let{skill:Q,args:J}=$;try{let X=`${Z.workingDirectory}/.claude/skills`,V=`${process.env.HOME||""}/.claude/skills`,K=[`${X}/${Q}.md`,`${X}/${Q}/skill.md`,`${V}/${Q}.md`,`${V}/${Q}/skill.md`],W=null;for(let z of K)if(await Bun.file(z).exists()){W=z;break}if(!W)return{content:`Skill not found: ${Q}. Available skills can be listed with /help.`,is_error:!0};let q=await Bun.file(W).text();return{content:JSON.stringify({type:"skill_invocation",skill:Q,args:J,skillFile:W,content:q,message:`Skill "${Q}" loaded. Follow the instructions in the skill content.`},null,2)}}catch(X){return{content:`Error invoking skill: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},ZV={name:"TaskStop",description:`Stops a running background task by its ID.
221
+ Takes a task_id parameter identifying the task to stop.
222
+ Returns a success or failure status.
223
+ Use this tool to terminate a long-running task.`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The ID of the background task to stop"},shell_id:{type:"string",description:"Deprecated: use task_id instead"}},required:["task_id"]},handler:async($,Z)=>{let Q=$.task_id;try{let J=`${Z.workingDirectory}/.claude/tasks/${Q}.json`,X=Bun.file(J);if(!await X.exists())return{content:`Task not found: ${Q}`,is_error:!0};let V=await X.json();if(V.status!=="running")return{content:JSON.stringify({task_id:Q,status:V.status,message:`Task is already ${V.status}`},null,2)};return V.status="stopped",await Bun.write(J,JSON.stringify(V,null,2)),{content:JSON.stringify({task_id:Q,status:"stopped",message:"Task stopped successfully"},null,2)}}catch(J){return{content:`Error stopping task: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},QV={name:"MultiEdit",description:`Performs atomic multi-file editing with rollback on failure.
224
+
225
+ This tool allows you to edit multiple files simultaneously in a single atomic operation.
226
+ If any edit fails, all changes are automatically rolled back to maintain consistency.
227
+
228
+ Key features:
229
+ - Validates all edits before applying (files exist, strings found)
230
+ - Creates automatic backups before editing
231
+ - Applies all edits atomically (all-or-nothing)
232
+ - Rolls back on any failure
233
+
234
+ Use this when you need to make coordinated changes across multiple files and want
235
+ to ensure either all changes succeed or none are applied.
236
+
237
+ IMPORTANT: You MUST read the files first before using this tool. Only edit files you have already read.`,input_schema:{type:"object",properties:{edits:{type:"array",description:"Array of edit operations to apply atomically",items:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to edit"},old_string:{type:"string",description:"The text to find and replace"},new_string:{type:"string",description:"The text to replace it with"},replace_all:{type:"boolean",description:"Replace all occurrences (default: false)"}},required:["file_path","old_string","new_string"]}},dry_run:{type:"boolean",description:"Preview changes without applying them (default: false)"}},required:["edits"]},handler:async($,Z)=>{let Q=$.edits,J=$.dry_run||!1;try{if(!Array.isArray(Q)||Q.length===0)return{content:"Error: edits must be a non-empty array",is_error:!0};let X=[];for(let W=0;W<Q.length;W++){let H=Q[W];if(!H||!H.file_path||!H.old_string||H.new_string===void 0)return{content:`Error: Edit at index ${W} is missing required fields (file_path, old_string, new_string)`,is_error:!0};X.push({filePath:H.file_path,oldString:H.old_string,newString:H.new_string,replaceAll:H.replace_all||!1})}if(J){let W=L5(X),H=X2(X);if(H.length>0)return{content:JSON.stringify({valid:!1,errors:H,preview:W},null,2),is_error:!0};return{content:JSON.stringify({valid:!0,preview:W,total_files:W.length,total_replacements:W.reduce((q,z)=>q+z.replacementCount,0),message:"Dry run successful - no changes applied"},null,2)}}let V=X2(X);if(V.length>0)return{content:`Validation failed:
238
+ ${V.join(`
239
+ `)}`,is_error:!0};let K=_5(X);if(K.success)return{content:JSON.stringify({success:!0,files_modified:K.filesModified,total_replacements:K.totalReplacements,message:`Successfully applied ${K.totalReplacements} replacement(s) across ${K.filesModified.length} file(s)`},null,2)};else return{content:JSON.stringify({success:!1,error:K.error,rolled_back:K.rolledBack,files_modified:K.filesModified},null,2),is_error:!0}}catch(X){return{content:`Error applying multi-edit: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},JV={name:"NotebookEdit",description:`Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source.
240
+
241
+ Jupyter notebooks are interactive documents that combine code, text, and visualizations. The notebook_path parameter must be an absolute path, not a relative path. The cell_number is 0-indexed. Use edit_mode=insert to add a new cell at the index specified by cell_number. Use edit_mode=delete to delete the cell at the index specified by cell_number.`,input_schema:{type:"object",properties:{notebook_path:{type:"string",description:"The absolute path to the Jupyter notebook file to edit"},cell_id:{type:"string",description:"The ID of the cell to edit (optional, alternative to cell_number)"},cell_number:{type:"number",description:"The index of the cell to edit (0-indexed)"},new_source:{type:"string",description:"The new source for the cell"},cell_type:{type:"string",enum:["code","markdown"],description:"The type of the cell (code or markdown). Defaults to code."},edit_mode:{type:"string",enum:["replace","insert","delete"],description:"The type of edit to perform (replace, insert, delete)"}},required:["notebook_path"]},handler:async($,Z)=>{let{notebook_path:Q,cell_id:J,cell_number:X,new_source:V}=$,K=$.cell_type||"code",W=$.edit_mode||"replace";try{let H=Bun.file(Q);if(!await H.exists())return{content:`Error: Notebook not found: ${Q}`,is_error:!0};let q=await H.json();if(!q.cells||!Array.isArray(q.cells))return{content:"Error: Invalid notebook format - no cells array",is_error:!0};let z;if(J){if(z=q.cells.findIndex((G)=>G.id===J),z===-1)return{content:`Error: Cell with ID "${J}" not found`,is_error:!0}}else if(X!==void 0){if(z=X,z<0||z>=q.cells.length)if(W==="insert")z=q.cells.length;else return{content:`Error: Cell number ${z} out of range (0-${q.cells.length-1})`,is_error:!0}}else if(W!=="insert")return{content:"Error: Must specify either cell_id or cell_number",is_error:!0};else z=q.cells.length;switch(W){case"delete":{q.cells.splice(z,1);break}case"insert":{let G={id:`cell-${Date.now()}`,cell_type:K,source:V||"",metadata:{},...K==="code"?{outputs:[],execution_count:null}:{}};q.cells.splice(z,0,G);break}case"replace":default:{if(V===void 0)return{content:"Error: new_source is required for replace mode",is_error:!0};let G=q.cells[z];if(!G)return{content:`Error: Cell at index ${z} not found`,is_error:!0};q.cells[z]={...G,source:V,cell_type:K,...K==="code"?{execution_count:null}:{}};break}}return await Bun.write(Q,JSON.stringify(q,null,1)),{content:JSON.stringify({success:!0,message:`Successfully ${W}d cell in ${Q}`,cellCount:q.cells.length})}}catch(H){return{content:`Error editing notebook: ${H instanceof Error?H.message:String(H)}`,is_error:!0}}}},XV=[uX,cX,lX,QV,aX,rX,nX,iX,sX,ZV,oX,eX,tX,$V,JV];function PH($){return XV.find((Z)=>Z.name===$)}import{spawn as VV}from"child_process";import o2 from"ws";class e2{static MCPClient=e2;name;config;connected=!1;tools=[];process=null;websocket=null;requestId=0;pendingRequests=new Map;buffer="";onLog;constructor($){this.name=$.name,this.config=$.config,this.onLog=$.onLog}async connect(){if(this.config.type==="stdio")await this.connectStdio();else if(this.config.type==="http"||this.config.type==="sse")await this.connectHttp();else if(this.config.type==="ws")await this.connectWebSocket()}async connectStdio(){if(!this.config.command)throw Error("No command specified for stdio transport");this.log(`Starting stdio transport: ${this.config.command}`),this.process=VV(this.config.command,this.config.args||[],{env:{...process.env,...this.config.env},stdio:["pipe","pipe","pipe"]}),this.process.stdout?.on("data",($)=>{this.handleData($.toString())}),this.process.stderr?.on("data",($)=>{this.log(`stderr: ${$.toString()}`)}),this.process.on("error",($)=>{this.log(`Process error: ${$.message}`)}),this.process.on("close",($)=>{this.log(`Process closed with code ${$}`),this.connected=!1}),await new Promise(($)=>setTimeout($,100)),await this.initialize()}async connectHttp(){if(!this.config.url)throw Error("No URL specified for HTTP transport");this.log(`Starting HTTP transport: ${this.config.url}`);try{let $=await fetch(this.config.url,{method:"POST",headers:{"Content-Type":"application/json",...this.config.headers},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"claude-code-remake",version:"0.1.0"}}})});if(!$.ok)throw Error(`HTTP error: ${$.status}`);let Z=await $.json();this.connected=!0,await this.loadTools()}catch($){let Z=$ instanceof Error?$.message:String($);throw Error(`Failed to connect to HTTP server: ${Z}`)}}async connectWebSocket(){if(!this.config.url)throw Error("No URL specified for WebSocket transport");let $=this.config.url;return this.log(`Starting WebSocket transport: ${$}`),new Promise((Z,Q)=>{let J={...this.config.headers},X=new o2($,{headers:J,handshakeTimeout:this.config.timeout||30000});X.on("open",()=>{this.log("WebSocket connection established"),this.websocket=X,this.connected=!0,this.initialize().then(()=>Z()).catch((V)=>{let K=V instanceof Error?V.message:String(V);this.log(`Initialization failed: ${K}`),Q(V)})}),X.on("message",(V,K)=>{let W=K?V.toString():V.toString();this.handleData(W)}),X.on("error",(V)=>{if(this.log(`WebSocket error: ${V.message}`),!this.connected)Q(Error(`WebSocket connection failed: ${V.message}`))}),X.on("close",(V,K)=>{this.log(`WebSocket closed: code=${V}, reason=${K.toString()}`),this.connected=!1,this.websocket=null;for(let[W,H]of this.pendingRequests)this.pendingRequests.delete(W),H.reject(Error(`WebSocket closed: ${K.toString()}`))}),X.on("ping",()=>{X.pong()})})}async initialize(){let $=await this.request("initialize",{protocolVersion:"2024-11-05",capabilities:{tools:{},resources:{},prompts:{}},clientInfo:{name:"claude-code-remake",version:"0.1.0"}});this.log(`Initialized with: ${JSON.stringify($)}`),this.connected=!0,this.notify("notifications/initialized",{}),await this.loadTools()}async loadTools(){try{let $=await this.request("tools/list",{});this.tools=$.tools.map((Z)=>({name:Z.name,description:Z.description,inputSchema:Z.inputSchema})),this.log(`Loaded ${this.tools.length} tools`)}catch($){this.log(`Failed to load tools: ${$}`)}}async callTool($,Z){return{content:(await this.request("tools/call",{name:$,arguments:Z})).content.filter((X)=>X.type==="text").map((X)=>X.text||"").join(`
242
+ `)}}async request($,Z){let Q=++this.requestId,J={jsonrpc:"2.0",id:Q,method:$,params:Z};return new Promise((X,V)=>{this.pendingRequests.set(Q,{resolve:X,reject:V});let K=JSON.stringify(J);if(this.websocket&&this.websocket.readyState===o2.OPEN)this.websocket.send(K);else if(this.process?.stdin?.writable)this.process.stdin.write(K+`
243
+ `);else{this.pendingRequests.delete(Q),V(Error("No active connection to send request"));return}setTimeout(()=>{if(this.pendingRequests.has(Q))this.pendingRequests.delete(Q),V(Error(`Request timeout for ${$}`))},this.config.timeout||120000)})}notify($,Z){let J=JSON.stringify({jsonrpc:"2.0",method:$,params:Z});if(this.websocket&&this.websocket.readyState===o2.OPEN)this.websocket.send(J);else if(this.process?.stdin?.writable)this.process.stdin.write(J+`
244
+ `)}handleData($){this.buffer+=$;let Z=this.buffer.split(`
245
+ `);this.buffer=Z.pop()||"";for(let Q of Z){if(!Q.trim())continue;try{let J=JSON.parse(Q);if(J.id!==void 0){let X=this.pendingRequests.get(J.id);if(X)if(this.pendingRequests.delete(J.id),J.error)X.reject(Error(J.error.message));else X.resolve(J.result)}}catch(J){this.log(`Parse error: ${J}`)}}}async close(){if(this.websocket)this.websocket.close(),this.websocket=null;if(this.process)this.process.kill(),this.process=null;this.connected=!1}log($){this.onLog?.(`[MCP:${this.name}] ${$}`)}}async function IH($,Z){let Q=new Map;for(let[J,X]of Object.entries($)){if(X.disabled)continue;let V=new e2({name:J,config:X,onLog:Z});try{await V.connect(),Q.set(J,V)}catch(K){let W=K instanceof Error?K.message:String(K);Z?.(`[MCP:${J}] Failed to connect: ${W}`)}}return Q}import{spawn as KV}from"child_process";class WV{hooks=new Map;timeout;constructor($=60000){this.timeout=$}register($,Z){if(!this.hooks.has($))this.hooks.set($,[]);this.hooks.get($)?.push(Z)}registerAll($){for(let[Z,Q]of Object.entries($))for(let J of Q)this.register(Z,J)}async execute($,Z){let Q=this.hooks.get($);if(!Q||Q.length===0)return{decision:"allow"};let J={...Z,event:$,timestamp:Date.now()};for(let X of Q){if(X.enabled===!1)continue;let V=await this.executeHook(X,J);if(V.decision==="deny"||V.decision==="block")return V;if(V.modified_input)Object.assign(Z,V.modified_input)}return{decision:"allow"}}async executeHook($,Z){let Q=$.timeout||this.timeout;try{return await new Promise((X,V)=>{let K=KV($.command,[],{shell:!0,stdio:["pipe","pipe","pipe"]}),W="",H="";K.stdout?.on("data",(q)=>{W+=q.toString()}),K.stderr?.on("data",(q)=>{H+=q.toString()}),K.on("close",(q)=>{if(q===0)try{let z=JSON.parse(W);X(z)}catch{X({decision:"allow"})}else if(q===1)X({decision:"deny",reason:H||"Hook denied execution"});else if(q===2)X({decision:"block",reason:H||"Hook blocked execution"});else X({decision:"allow"})}),K.on("error",(q)=>{X({decision:"allow",reason:`Hook error: ${q.message}`})}),K.stdin?.write(JSON.stringify(Z)),K.stdin?.end(),setTimeout(()=>{K.kill(),X({decision:"allow",reason:"Hook timeout"})},Q)})}catch(J){return{decision:"allow",reason:`Hook execution failed: ${J instanceof Error?J.message:String(J)}`}}}getHooks($){return this.hooks.get($)||[]}clear($){if($)this.hooks.delete($);else this.hooks.clear()}}var TH={validateWrite:{event:"PreToolUse",command:`node -e '
246
+ const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
247
+ if (input.tool_name === "Write") {
248
+ const path = input.tool_input.file_path;
249
+ if (path.includes("..") || path.startsWith("/etc/")) {
250
+ console.log(JSON.stringify({ decision: "deny", reason: "Unsafe path" }));
251
+ process.exit(1);
252
+ }
253
+ }
254
+ console.log(JSON.stringify({ decision: "allow" }));
255
+ '`,timeout:5000,enabled:!1},logToolUse:{event:"PostToolUse",command:`node -e '
256
+ const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
257
+ console.error(\`[LOG] Tool: \${input.tool_name}\`);
258
+ console.log(JSON.stringify({ decision: "allow" }));
259
+ '`,timeout:5000,enabled:!1}},kH={PreToolUse:"Before a tool is executed. Can modify input or deny execution.",PostToolUse:"After a tool successfully executes. Can process result.",PostToolUseFailure:"After a tool fails. Can handle error or retry.",Stop:"When the agent stops (end_turn, max_tokens, error).",UserPromptSubmit:"When user submits a prompt. Can modify or reject.",SessionStart:"When a new session starts.",SessionEnd:"When a session ends.",Notification:"When a notification is sent.",ConfigChange:"When configuration changes.",WorktreeCreate:"When a git worktree is created."},xH={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as HV,existsSync as u9,readdirSync as qV}from"fs";import{join as YV}from"path";function zV($,Z="project"){if(!u9($))return null;let Q=HV($,"utf-8"),J=$.split("/").pop()?.replace(/\.md$/i,"")||"unknown",X=Q.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!X)return{path:$,name:J,description:"",prompt:Q.trim(),source:Z};let V=X[1]??"",K=X[2]??"",W=GV(V);return{path:$,name:W.name||J,description:W.description||"",prompt:K.trim(),tools:W.tools,model:W.model,color:W.color,source:Z}}function GV($){let Z={},Q=$.split(`
260
+ `);for(let J of Q){let X=J.match(/^(\w+):\s*(.*)$/);if(X){let V=X[1];if(!V)continue;let K=X[2]??"";if(K.startsWith("["))try{Z[V]=JSON.parse(K)}catch{Z[V]=K}else if(K==="true")Z[V]=!0;else if(K==="false")Z[V]=!1;else if(/^\d+$/.test(K))Z[V]=parseInt(K,10);else if(/^\d+\.\d+$/.test(K))Z[V]=parseFloat(K);else Z[V]=K}}return Z}class jV{skills=new Map;loadFromDirectory($,Z="project"){if(!u9($))return 0;let Q=0,J=qV($);for(let X of J)if(X.endsWith(".md")){let V=zV(YV($,X),Z);if(V)this.skills.set(V.name,V),Q++}return Q}get($){return this.skills.get($)}getAll(){return Array.from(this.skills.values())}has($){return this.skills.has($)}getNames(){return Array.from(this.skills.keys())}}function fH($){return`
261
+ <skill-loading>
262
+ You are operating with the "${$.name}" skill loaded.
263
+
264
+ ${$.description?`Description: ${$.description}
265
+ `:""}
266
+ ${$.prompt}
267
+ </skill-loading>
268
+ `.trim()}var hH=[{path:"built-in://commit",name:"commit",description:"Create a git commit with the staged changes",prompt:`Analyze the staged changes and create a git commit.
269
+
270
+ Steps:
271
+ 1. Run \`git diff --staged\` to see staged changes
272
+ 2. Run \`git log --oneline -5\` to understand commit message style
273
+ 3. Create a commit message following conventional commits format
274
+ 4. Include "Co-Authored-By: Claude <noreply@anthropic.com>" if applicable
275
+ 5. Run \`git commit\` with the message`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://review-pr",name:"review-pr",description:"Review a pull request",prompt:`Review the current pull request and provide feedback.
276
+
277
+ Steps:
278
+ 1. Use \`gh pr view\` to get PR details
279
+ 2. Use \`gh pr diff\` to see the changes
280
+ 3. Analyze the code for:
281
+ - Bugs and potential issues
282
+ - Code quality and style
283
+ - Test coverage
284
+ - Documentation
285
+ 4. Provide constructive feedback
286
+ 5. Approve or request changes as appropriate`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://mcp-builder",name:"mcp-builder",description:"Guide for creating MCP servers",prompt:`Help the user build MCP (Model Context Protocol) servers.
287
+
288
+ MCP servers enable LLMs to interact with external services through well-designed tools.
289
+
290
+ Key concepts:
291
+ 1. Use FastMCP (Python) or MCP SDK (TypeScript)
292
+ 2. Define tools with clear input schemas
293
+ 3. Return structured content
294
+ 4. Handle errors gracefully
295
+
296
+ Transport types:
297
+ - stdio: Local process communication
298
+ - HTTP: REST API with JSON-RPC
299
+ - SSE: Server-Sent Events for streaming
300
+ - WebSocket: Bidirectional communication`,tools:["Read","Write","Edit","Bash"],model:"sonnet",source:"built-in"},{path:"built-in://claude-hooks",name:"claude-hooks",description:"Guide for Claude Code hooks",prompt:`Help the user configure Claude Code hooks.
301
+
302
+ Hooks are user-defined shell commands that execute at specific points during Claude Code's lifecycle.
303
+
304
+ Available events:
305
+ - PreToolUse: Before a tool executes
306
+ - PostToolUse: After a tool succeeds
307
+ - PostToolUseFailure: After a tool fails
308
+ - Stop: When agent stops
309
+ - UserPromptSubmit: When user submits prompt
310
+ - SessionStart/SessionEnd: Session lifecycle
311
+
312
+ Exit codes:
313
+ - 0: Allow execution
314
+ - 1: Deny and show stderr
315
+ - 2: Block silently`,tools:["Read","Write","Edit"],model:"sonnet",source:"built-in"}];function gH($){return $.match(/^\/(\w+)(?:\s+(.*))?$/)?.[1]??null}function dH($){return $.match(/^\/\w+\s+(.*)$/)?.[1]??""}import{spawn as t2}from"child_process";import{mkdirSync as m9,rmSync as UV,existsSync as c9,readFileSync as AV}from"fs";import{join as W6}from"path";class BV{teams=new Map;teammates=new Map;messageQueue=new Map;storagePath;constructor($="~/.claude/teams"){if(this.storagePath=$.replace("~",process.env.HOME||""),!c9(this.storagePath))m9(this.storagePath,{recursive:!0});this.loadTeams()}createTeam($){let Z={...$,status:"active"};this.teams.set($.name,Z);for(let Q of $.teammates)this.teammates.set(Q.teammateId,Q);return this.persistTeam(Z).catch((Q)=>{console.error(`Failed to persist team ${$.name}:`,Q)}),Z}getTeam($){return this.teams.get($)}listTeams(){return Array.from(this.teams.values())}deleteTeam($){let Z=this.teams.get($);if(Z){for(let J of Z.teammates)this.teammates.delete(J.teammateId),this.messageQueue.delete(J.teammateId);this.teams.delete($);let Q=W6(this.storagePath,$);try{UV(Q,{recursive:!0,force:!0})}catch(J){console.error(`Failed to delete team directory ${Q}:`,J)}}}getTeammate($){return this.teammates.get($)}updateTeammateStatus($,Z){let Q=this.teammates.get($);if(Q)Q.status=Z}async spawnTeammate($,Z={}){let{session:Q,workingDir:J=process.cwd()}=Z;if(!process.env.TMUX)await this.spawnInTerminal($,{session:Q,workingDir:J});else await this.spawnInTmux($,{session:Q,workingDir:J});this.updateTeammateStatus($.teammateId,"in_progress")}async spawnInTerminal($,Z){let Q=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName,"--agent-color",$.color];if($.planModeRequired)Q.push("--permission-mode","plan");if(process.platform==="darwin"){let J=`
316
+ tell application "Terminal"
317
+ do script "cd ${Z.workingDir} && ${Q.join(" ")}"
318
+ activate
319
+ end tell
320
+ `;t2("osascript",["-e",J])}else t2("xterm",["-e",Q.join(" ")])}async spawnInTmux($,Z){let Q=Z.session||process.env.TMUX?.split(",")[0]?.split(":")[0]||"claude";await this.tmuxCommand(["split-window","-t",Q,"-c",Z.workingDir]);let J=await this.tmuxCommand(["display-message","-p","#{pane_id}"]);if(J)$.paneId=J.trim();let X=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName];await this.tmuxCommand(["send-keys","-t",$.paneId||"",X.join(" "),"Enter"])}async tmuxCommand($){return new Promise((Z)=>{let Q=t2("tmux",$),J="";Q.stdout?.on("data",(X)=>{J+=X.toString()}),Q.on("close",()=>{Z(J)})})}broadcast($,Z,Q){let J=this.teams.get($);if(!J)return;let X={type:"broadcast",from:Q||"system",content:Z,timestamp:Date.now()};for(let V of J.teammates){if(Q&&V.teammateId===Q)continue;let K=this.messageQueue.get(V.teammateId)||[];K.push(X),this.messageQueue.set(V.teammateId,K)}}sendDirect($,Z,Q){let J={type:"direct",from:Z,to:$,content:Q,timestamp:Date.now()},X=this.messageQueue.get($)||[];X.push(J),this.messageQueue.set($,X)}getMessages($){let Z=this.messageQueue.get($)||[];return this.messageQueue.delete($),Z}hasMessages($){let Z=this.messageQueue.get($);return Z!==void 0&&Z.length>0}peekMessages($){return this.messageQueue.get($)||[]}clearMessages($){this.messageQueue.delete($)}getMessageCount($){return this.messageQueue.get($)?.length||0}async persistTeam($){let Z=W6(this.storagePath,$.name),Q=W6(Z,"config.json");if(!c9(Z))m9(Z,{recursive:!0});await Bun.write(W6(Z,".gitkeep"),"");let J={name:$.name,description:$.description,teammates:$.teammates,taskListId:$.taskListId,status:$.status,coordination:$.coordination,updatedAt:Date.now()};await Bun.write(Q,JSON.stringify(J,null,2))}loadTeams(){let $=new Bun.Glob("**/config.json");try{let Z=Array.from($.scanSync(this.storagePath));for(let Q of Z)try{let J=W6(this.storagePath,Q);if(Bun.file(J).size===0)continue;let K=AV(J,"utf-8"),W=JSON.parse(K);if(!W.name||!W.teammates||!Array.isArray(W.teammates))continue;let H={name:W.name,description:W.description||"",teammates:W.teammates,taskListId:W.taskListId||"",status:W.status||"active",coordination:W.coordination||{dependencyOrder:[],communicationProtocol:"broadcast",taskAssignmentStrategy:"manual"}};this.teams.set(H.name,H);for(let q of H.teammates)this.teammates.set(q.teammateId,q)}catch(J){}}catch(Z){if(Z.code!=="ENOENT");}}async persistAllTeams(){let $=Array.from(this.teams.values()).map((Z)=>this.persistTeam(Z));await Promise.all($)}}var pH={architect:($)=>({name:"architect",teamName:$,color:"blue",prompt:`You are an architect on the ${$} team.
321
+ Your role is to design and plan the technical architecture.
322
+ Focus on:
323
+ - System design and component relationships
324
+ - API contracts and interfaces
325
+ - Data models and schemas
326
+ - Trade-offs and design decisions`,planModeRequired:!0,status:"pending"}),implementer:($)=>({name:"implementer",teamName:$,color:"green",prompt:`You are an implementer on the ${$} team.
327
+ Your role is to write clean, working code based on the architecture.
328
+ Focus on:
329
+ - Implementing the designed architecture
330
+ - Writing tests
331
+ - Following coding standards
332
+ - Handling edge cases`,planModeRequired:!1,status:"pending"}),reviewer:($)=>({name:"reviewer",teamName:$,color:"yellow",prompt:`You are a code reviewer on the ${$} team.
333
+ Your role is to review code changes and provide feedback.
334
+ Focus on:
335
+ - Code quality and readability
336
+ - Potential bugs and issues
337
+ - Performance considerations
338
+ - Test coverage`,planModeRequired:!1,status:"pending"}),tester:($)=>({name:"tester",teamName:$,color:"orange",prompt:`You are a tester on the ${$} team.
339
+ Your role is to ensure features work correctly.
340
+ Focus on:
341
+ - Writing comprehensive tests
342
+ - Finding edge cases
343
+ - Verifying requirements
344
+ - Reporting bugs`,planModeRequired:!1,status:"pending"})};function LV(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function aH($){return{...$,teammateId:LV(),status:"pending"}}
345
+ export{v as a,Y6 as b,i9 as c,wV as d,J5 as e,X5 as f,RV as g,$7 as h,Z7 as i,Q7 as j,J7 as k,W5 as l,K7 as m,W7 as n,i6 as o,s6 as p,EV as q,SV as r,TV as s,cV as t,Q2 as u,lV as v,pV as w,aV as x,R7 as y,C7 as z,sV as A,A5 as B,ZK as C,V4 as D,QK as E,JK as F,XK as G,VK as H,X2 as I,L5 as J,_5 as K,b as L,KK as M,WK as N,HK as O,qK as P,YK as Q,zK as R,GK as S,jK as T,UK as U,AK as V,BK as W,LK as X,_K as Y,wK as Z,uX as _,cX as $,lX as aa,aX as ba,rX as ca,nX as da,iX as ea,sX as fa,oX as ga,eX as ha,tX as ia,$V as ja,ZV as ka,QV as la,JV as ma,XV as na,PH as oa,e2 as pa,IH as qa,WV as ra,TH as sa,kH as ta,xH as ua,zV as va,jV as wa,fH as xa,hH as ya,gH as za,dH as Aa,BV as Ba,pH as Ca,LV as Da,aH as Ea};