@ebowwa/coder 0.2.0 → 0.7.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +75 -44
  2. package/dist/index.js +52191 -1
  3. package/dist/interfaces/ui/terminal/cli/index.js +52776 -0
  4. package/native/README.md +5 -5
  5. package/native/index.d.ts +0 -150
  6. package/native/index.darwin-arm64.node +0 -0
  7. package/native/index.node +0 -0
  8. package/native/package.json +5 -5
  9. package/package.json +31 -16
  10. package/dist/cli.js +0 -148
  11. package/dist/index-0pkak453.js +0 -136
  12. package/dist/index-0qd0x8b4.js +0 -110
  13. package/dist/index-0x3kprq6.js +0 -240
  14. package/dist/index-1eawy937.js +0 -308
  15. package/dist/index-24m2aygy.js +0 -240
  16. package/dist/index-29xcjnne.js +0 -280
  17. package/dist/index-2avyytn5.js +0 -349
  18. package/dist/index-4ms367ey.js +0 -136
  19. package/dist/index-4w2t3b0m.js +0 -240
  20. package/dist/index-4xfgd8nz.js +0 -261
  21. package/dist/index-5acjp9gc.js +0 -157
  22. package/dist/index-5s15hr56.js +0 -136
  23. package/dist/index-6e4wf341.js +0 -349
  24. package/dist/index-6fvnkedw.js +0 -240
  25. package/dist/index-6rqpmd4g.js +0 -128
  26. package/dist/index-77ckwnbm.js +0 -280
  27. package/dist/index-9knxy49k.js +0 -128
  28. package/dist/index-9zrnw4zx.js +0 -128
  29. package/dist/index-bk21w99v.js +0 -280
  30. package/dist/index-c41n76fv.js +0 -240
  31. package/dist/index-cb4ppjdt.js +0 -255
  32. package/dist/index-cfb2edt6.js +0 -240
  33. package/dist/index-cmfa38hh.js +0 -308
  34. package/dist/index-datjz8q1.js +0 -257
  35. package/dist/index-eadf4wvn.js +0 -240
  36. package/dist/index-em5k0m3z.js +0 -345
  37. package/dist/index-gh8r333a.js +0 -110
  38. package/dist/index-gkx6k2tr.js +0 -261
  39. package/dist/index-h5cabfks.js +0 -155
  40. package/dist/index-hcrpwyy3.js +0 -261
  41. package/dist/index-hk7fwwa8.js +0 -257
  42. package/dist/index-jb8cw7f8.js +0 -136
  43. package/dist/index-kbyw4th1.js +0 -347
  44. package/dist/index-kgj5gqnm.js +0 -345
  45. package/dist/index-mdf6xp1z.js +0 -255
  46. package/dist/index-mrhv8kvc.js +0 -280
  47. package/dist/index-mt4743dd.js +0 -161
  48. package/dist/index-qnwsg97q.js +0 -240
  49. package/dist/index-qwdy6x44.js +0 -261
  50. package/dist/index-rmj77261.js +0 -157
  51. package/dist/index-sbbw1a61.js +0 -349
  52. package/dist/index-svy5bcpn.js +0 -345
  53. package/dist/index-tvmy7tm9.js +0 -261
  54. package/dist/index-tzz4vzkj.js +0 -312
  55. package/dist/index-vz80zmhe.js +0 -110
  56. package/dist/index-wed2fk67.js +0 -240
  57. package/dist/index-wksgzz8e.js +0 -280
  58. package/dist/index-wn2m4wma.js +0 -240
  59. package/dist/index-xha05vjc.js +0 -257
  60. package/dist/index-yc6eh8p8.js +0 -136
  61. package/dist/index-ycjxx9ft.js +0 -240
  62. package/dist/index-z0gzd0fc.js +0 -110
  63. package/dist/index-z8cwtf8j.js +0 -240
  64. package/dist/index-zy5mtt00.js +0 -128
@@ -1,349 +0,0 @@
1
- // @bun
2
- var a9=Object.create;var{getPrototypeOf:r9,defineProperty:Q5,getOwnPropertyNames:n9}=Object;var i9=Object.prototype.hasOwnProperty;var X5=($,Z,J)=>{J=$!=null?a9(r9($)):{};let Q=Z||!$||!$.__esModule?Q5(J,"default",{value:$,enumerable:!0}):J;for(let X of n9($))if(!i9.call(Q,X))Q5(Q,X,{get:()=>$[X],enumerable:!0});return Q};var T=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var v=import.meta.require;var E0=T((OY,L1)=>{/*!
3
- Copyright 2013 Lovell Fuller and others.
4
- SPDX-License-Identifier: Apache-2.0
5
- */var B1=($)=>typeof $<"u"&&$!==null,wZ=($)=>typeof $==="object",RZ=($)=>Object.prototype.toString.call($)==="[object Object]",CZ=($)=>typeof $==="function",NZ=($)=>typeof $==="boolean",PZ=($)=>$ instanceof Buffer,DZ=($)=>{if(B1($))switch($.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},FZ=($)=>$ instanceof ArrayBuffer,MZ=($)=>typeof $==="string"&&$.length>0,IZ=($)=>typeof $==="number"&&!Number.isNaN($),EZ=($)=>Number.isInteger($),SZ=($,Z,J)=>$>=Z&&$<=J,TZ=($,Z)=>Z.includes($),xZ=($,Z,J)=>Error(`Expected ${Z} for ${$} but received ${J} of type ${typeof J}`),kZ=($,Z)=>{return Z.message=$.message,Z};L1.exports={defined:B1,object:wZ,plainObject:RZ,fn:CZ,bool:NZ,buffer:PZ,typedArray:DZ,arrayBuffer:FZ,string:MZ,number:IZ,integer:EZ,inRange:SZ,inArray:TZ,invalidParameterError:xZ,nativeError:kZ}});var R1=T((yY,w1)=>{var _1=()=>process.platform==="linux",k6=null,vZ=()=>{if(!k6)if(_1()&&process.report){let $=process.report.excludeNetwork;process.report.excludeNetwork=!0,k6=process.report.getReport(),process.report.excludeNetwork=$}else k6={};return k6};w1.exports={isLinux:_1,getReport:vZ}});var N1=T((bY,C1)=>{var C4=v("fs"),OZ=($)=>{let Z=C4.openSync($,"r"),J=Buffer.alloc(2048),Q=C4.readSync(Z,J,0,2048,0);return C4.close(Z,()=>{}),J.subarray(0,Q)},yZ=($)=>new Promise((Z,J)=>{C4.open($,"r",(Q,X)=>{if(Q)J(Q);else{let V=Buffer.alloc(2048);C4.read(X,V,0,2048,0,(K,Y)=>{Z(V.subarray(0,Y)),C4.close(X,()=>{})})}})});C1.exports={LDD_PATH:"/usr/bin/ldd",SELF_PATH:"/proc/self/exe",readFileSync:OZ,readFile:yZ}});var D1=T((fY,P1)=>{var bZ=($)=>{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),J=$.readUInt16LE(54),Q=$.readUInt16LE(56);for(let X=0;X<Q;X++){let V=Z+X*J;if($.readUInt32LE(V)===3){let Y=$.readUInt32LE(V+8),W=$.readUInt32LE(V+32);return $.subarray(Y,Y+W).toString().replace(/\0.*$/g,"")}}return null};P1.exports={interpreterPath:bZ}});var O6=T((hY,d1)=>{var M1=v("child_process"),{isLinux:N4,getReport:I1}=R1(),{LDD_PATH:v6,SELF_PATH:E1,readFile:E2,readFileSync:S2}=N1(),{interpreterPath:S1}=D1(),S0,T0,x0,e0="",T1=()=>{if(!e0)return new Promise(($)=>{M1.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(Z,J)=>{e0=Z?" ":J,$(e0)})});return e0},x1=()=>{if(!e0)try{e0=M1.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch($){e0=" "}return e0},m0="glibc",k1=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,H4="musl",fZ=($)=>$.includes("libc.musl-")||$.includes("ld-musl-"),v1=()=>{let $=I1();if($.header&&$.header.glibcVersionRuntime)return m0;if(Array.isArray($.sharedObjects)){if($.sharedObjects.some(fZ))return H4}return null},O1=($)=>{let[Z,J]=$.split(/[\r\n]+/);if(Z&&Z.includes(m0))return m0;if(J&&J.includes(H4))return H4;return null},y1=($)=>{if($){if($.includes("/ld-musl-"))return H4;else if($.includes("/ld-linux-"))return m0}return null},b1=($)=>{if($=$.toString(),$.includes("musl"))return H4;if($.includes("GNU C Library"))return m0;return null},hZ=async()=>{if(T0!==void 0)return T0;T0=null;try{let $=await E2(v6);T0=b1($)}catch($){}return T0},gZ=()=>{if(T0!==void 0)return T0;T0=null;try{let $=S2(v6);T0=b1($)}catch($){}return T0},uZ=async()=>{if(S0!==void 0)return S0;S0=null;try{let $=await E2(E1),Z=S1($);S0=y1(Z)}catch($){}return S0},dZ=()=>{if(S0!==void 0)return S0;S0=null;try{let $=S2(E1),Z=S1($);S0=y1(Z)}catch($){}return S0},f1=async()=>{let $=null;if(N4()){if($=await uZ(),!$){if($=await hZ(),!$)$=v1();if(!$){let Z=await T1();$=O1(Z)}}}return $},h1=()=>{let $=null;if(N4()){if($=dZ(),!$){if($=gZ(),!$)$=v1();if(!$){let Z=x1();$=O1(Z)}}}return $},mZ=async()=>N4()&&await f1()!==m0,cZ=()=>N4()&&h1()!==m0,lZ=async()=>{if(x0!==void 0)return x0;x0=null;try{let Z=(await E2(v6)).match(k1);if(Z)x0=Z[1]}catch($){}return x0},pZ=()=>{if(x0!==void 0)return x0;x0=null;try{let Z=S2(v6).match(k1);if(Z)x0=Z[1]}catch($){}return x0},g1=()=>{let $=I1();if($.header&&$.header.glibcVersionRuntime)return $.header.glibcVersionRuntime;return null},F1=($)=>$.trim().split(/\s+/)[1],u1=($)=>{let[Z,J,Q]=$.split(/[\r\n]+/);if(Z&&Z.includes(m0))return F1(Z);if(J&&Q&&J.includes(H4))return F1(Q);return null},aZ=async()=>{let $=null;if(N4()){if($=await lZ(),!$)$=g1();if(!$){let Z=await T1();$=u1(Z)}}return $},rZ=()=>{let $=null;if(N4()){if($=pZ(),!$)$=g1();if(!$){let Z=x1();$=u1(Z)}}return $};d1.exports={GLIBC:m0,MUSL:H4,family:f1,familySync:h1,isNonGlibcLinux:mZ,isNonGlibcLinuxSync:cZ,version:aZ,versionSync:rZ}});var Z6=T((gY,m1)=>{var nZ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};m1.exports=nZ});var y6=T((uY,c1)=>{var iZ=Number.MAX_SAFE_INTEGER||9007199254740991,oZ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];c1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:iZ,RELEASE_TYPES:oZ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var J6=T((k0,l1)=>{var{MAX_SAFE_COMPONENT_LENGTH:T2,MAX_SAFE_BUILD_LENGTH:sZ,MAX_LENGTH:eZ}=y6(),tZ=Z6();k0=l1.exports={};var $J=k0.re=[],ZJ=k0.safeRe=[],N=k0.src=[],JJ=k0.safeSrc=[],P=k0.t={},QJ=0,x2="[a-zA-Z0-9-]",XJ=[["\\s",1],["\\d",eZ],[x2,sZ]],VJ=($)=>{for(let[Z,J]of XJ)$=$.split(`${Z}*`).join(`${Z}{0,${J}}`).split(`${Z}+`).join(`${Z}{1,${J}}`);return $},E=($,Z,J)=>{let Q=VJ(Z),X=QJ++;tZ($,X,Z),P[$]=X,N[X]=Z,JJ[X]=Q,$J[X]=new RegExp(Z,J?"g":void 0),ZJ[X]=new RegExp(Q,J?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${x2}*`);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",`${x2}+`);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,${T2}})(?:\\.(\\d{1,${T2}}))?(?:\\.(\\d{1,${T2}}))?`);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);k0.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);k0.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);k0.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 b6=T((dY,p1)=>{var KJ=Object.freeze({loose:!0}),YJ=Object.freeze({}),WJ=($)=>{if(!$)return YJ;if(typeof $!=="object")return KJ;return $};p1.exports=WJ});var i1=T((mY,n1)=>{var a1=/^[0-9]+$/,r1=($,Z)=>{if(typeof $==="number"&&typeof Z==="number")return $===Z?0:$<Z?-1:1;let J=a1.test($),Q=a1.test(Z);if(J&&Q)$=+$,Z=+Z;return $===Z?0:J&&!Q?-1:Q&&!J?1:$<Z?-1:1},HJ=($,Z)=>r1(Z,$);n1.exports={compareIdentifiers:r1,rcompareIdentifiers:HJ}});var P4=T((cY,s1)=>{var f6=Z6(),{MAX_LENGTH:o1,MAX_SAFE_INTEGER:h6}=y6(),{safeRe:g6,t:u6}=J6(),qJ=b6(),{compareIdentifiers:k2}=i1();class C0{constructor($,Z){if(Z=qJ(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>o1)throw TypeError(`version is longer than ${o1} characters`);f6("SemVer",$,Z),this.options=Z,this.loose=!!Z.loose,this.includePrerelease=!!Z.includePrerelease;let J=$.trim().match(Z.loose?g6[u6.LOOSE]:g6[u6.FULL]);if(!J)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+J[1],this.minor=+J[2],this.patch=+J[3],this.major>h6||this.major<0)throw TypeError("Invalid major version");if(this.minor>h6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>h6||this.patch<0)throw TypeError("Invalid patch version");if(!J[4])this.prerelease=[];else this.prerelease=J[4].split(".").map((Q)=>{if(/^[0-9]+$/.test(Q)){let X=+Q;if(X>=0&&X<h6)return X}return Q});this.build=J[5]?J[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(f6("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 J=this.prerelease[Z],Q=$.prerelease[Z];if(f6("prerelease compare",Z,J,Q),J===void 0&&Q===void 0)return 0;else if(Q===void 0)return 1;else if(J===void 0)return-1;else if(J===Q)continue;else return k2(J,Q)}while(++Z)}compareBuild($){if(!($ instanceof C0))$=new C0($,this.options);let Z=0;do{let J=this.build[Z],Q=$.build[Z];if(f6("build compare",Z,J,Q),J===void 0&&Q===void 0)return 0;else if(Q===void 0)return 1;else if(J===void 0)return-1;else if(J===Q)continue;else return k2(J,Q)}while(++Z)}inc($,Z,J){if($.startsWith("pre")){if(!Z&&J===!1)throw Error("invalid increment argument: identifier is empty");if(Z){let Q=`-${Z}`.match(this.options.loose?g6[u6.PRERELEASELOOSE]:g6[u6.PRERELEASE]);if(!Q||Q[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,J);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",Z,J);break;case"prepatch":this.prerelease.length=0,this.inc("patch",Z,J),this.inc("pre",Z,J);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",Z,J);this.inc("pre",Z,J);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 Q=Number(J)?1:0;if(this.prerelease.length===0)this.prerelease=[Q];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(".")&&J===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(Q)}}if(Z){let X=[Z,Q];if(J===!1)X=[Z];if(k2(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}}s1.exports=C0});var $$=T((lY,t1)=>{var e1=P4(),zJ=($,Z,J=!1)=>{if($ instanceof e1)return $;try{return new e1($,Z)}catch(Q){if(!J)return null;throw Q}};t1.exports=zJ});var J$=T((pY,Z$)=>{var GJ=P4(),jJ=$$(),{safeRe:d6,t:m6}=J6(),UJ=($,Z)=>{if($ instanceof GJ)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;Z=Z||{};let J=null;if(!Z.rtl)J=$.match(Z.includePrerelease?d6[m6.COERCEFULL]:d6[m6.COERCE]);else{let W=Z.includePrerelease?d6[m6.COERCERTLFULL]:d6[m6.COERCERTL],H;while((H=W.exec($))&&(!J||J.index+J[0].length!==$.length)){if(!J||H.index+H[0].length!==J.index+J[0].length)J=H;W.lastIndex=H.index+H[1].length+H[2].length}W.lastIndex=-1}if(J===null)return null;let Q=J[2],X=J[3]||"0",V=J[4]||"0",K=Z.includePrerelease&&J[5]?`-${J[5]}`:"",Y=Z.includePrerelease&&J[6]?`+${J[6]}`:"";return jJ(`${Q}.${X}.${V}${K}${Y}`,Z)};Z$.exports=UJ});var q4=T((aY,X$)=>{var Q$=P4(),AJ=($,Z,J)=>new Q$($,J).compare(new Q$(Z,J));X$.exports=AJ});var v2=T((rY,V$)=>{var BJ=q4(),LJ=($,Z,J)=>BJ($,Z,J)>=0;V$.exports=LJ});var W$=T((nY,Y$)=>{class K${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 Q=this.map.keys().next().value;this.delete(Q)}this.map.set($,Z)}return this}}Y$.exports=K$});var q$=T((iY,H$)=>{var _J=q4(),wJ=($,Z,J)=>_J($,Z,J)===0;H$.exports=wJ});var G$=T((oY,z$)=>{var RJ=q4(),CJ=($,Z,J)=>RJ($,Z,J)!==0;z$.exports=CJ});var U$=T((sY,j$)=>{var NJ=q4(),PJ=($,Z,J)=>NJ($,Z,J)>0;j$.exports=PJ});var B$=T((eY,A$)=>{var DJ=q4(),FJ=($,Z,J)=>DJ($,Z,J)<0;A$.exports=FJ});var _$=T((tY,L$)=>{var MJ=q4(),IJ=($,Z,J)=>MJ($,Z,J)<=0;L$.exports=IJ});var R$=T(($W,w$)=>{var EJ=q$(),SJ=G$(),TJ=U$(),xJ=v2(),kJ=B$(),vJ=_$(),OJ=($,Z,J,Q)=>{switch(Z){case"===":if(typeof $==="object")$=$.version;if(typeof J==="object")J=J.version;return $===J;case"!==":if(typeof $==="object")$=$.version;if(typeof J==="object")J=J.version;return $!==J;case"":case"=":case"==":return EJ($,J,Q);case"!=":return SJ($,J,Q);case">":return TJ($,J,Q);case">=":return xJ($,J,Q);case"<":return kJ($,J,Q);case"<=":return vJ($,J,Q);default:throw TypeError(`Invalid operator: ${Z}`)}};w$.exports=OJ});var I$=T((ZW,M$)=>{var Q6=Symbol("SemVer ANY");class c6{static get ANY(){return Q6}constructor($,Z){if(Z=C$(Z),$ instanceof c6)if($.loose===!!Z.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),y2("comparator",$,Z),this.options=Z,this.loose=!!Z.loose,this.parse($),this.semver===Q6)this.value="";else this.value=this.operator+this.semver.version;y2("comp",this)}parse($){let Z=this.options.loose?N$[P$.COMPARATORLOOSE]:N$[P$.COMPARATOR],J=$.match(Z);if(!J)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=J[1]!==void 0?J[1]:"",this.operator==="=")this.operator="";if(!J[2])this.semver=Q6;else this.semver=new D$(J[2],this.options.loose)}toString(){return this.value}test($){if(y2("Comparator.test",$,this.options.loose),this.semver===Q6||$===Q6)return!0;if(typeof $==="string")try{$=new D$($,this.options)}catch(Z){return!1}return O2($,this.operator,this.semver,this.options)}intersects($,Z){if(!($ instanceof c6))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new F$($.value,Z).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new F$(this.value,Z).test($.semver)}if(Z=C$(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(O2(this.semver,"<",$.semver,Z)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(O2(this.semver,">",$.semver,Z)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}M$.exports=c6;var C$=b6(),{safeRe:N$,t:P$}=J6(),O2=R$(),y2=Z6(),D$=P4(),F$=b2()});var b2=T((JW,x$)=>{var yJ=/\s+/g;class X6{constructor($,Z){if(Z=fJ(Z),$ instanceof X6)if($.loose===!!Z.loose&&$.includePrerelease===!!Z.includePrerelease)return $;else return new X6($.raw,Z);if($ instanceof f2)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(yJ," "),this.set=this.raw.split("||").map((J)=>this.parseRange(J.trim())).filter((J)=>J.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let J=this.set[0];if(this.set=this.set.filter((Q)=>!S$(Q[0])),this.set.length===0)this.set=[J];else if(this.set.length>1){for(let Q of this.set)if(Q.length===1&&lJ(Q[0])){this.set=[Q];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 J=0;J<Z.length;J++){if(J>0)this.formatted+=" ";this.formatted+=Z[J].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let J=((this.options.includePrerelease&&mJ)|(this.options.loose&&cJ))+":"+$,Q=E$.get(J);if(Q)return Q;let X=this.options.loose,V=X?J0[s.HYPHENRANGELOOSE]:J0[s.HYPHENRANGE];$=$.replace(V,$3(this.options.includePrerelease)),h("hyphen replace",$),$=$.replace(J0[s.COMPARATORTRIM],gJ),h("comparator trim",$),$=$.replace(J0[s.TILDETRIM],uJ),h("tilde trim",$),$=$.replace(J0[s.CARETTRIM],dJ),h("caret trim",$);let K=$.split(" ").map((z)=>pJ(z,this.options)).join(" ").split(/\s+/).map((z)=>tJ(z,this.options));if(X)K=K.filter((z)=>{return h("loose invalid filter",z,this.options),!!z.match(J0[s.COMPARATORLOOSE])});h("range list",K);let Y=new Map,W=K.map((z)=>new f2(z,this.options));for(let z of W){if(S$(z))return[z];Y.set(z.value,z)}if(Y.size>1&&Y.has(""))Y.delete("");let H=[...Y.values()];return E$.set(J,H),H}intersects($,Z){if(!($ instanceof X6))throw TypeError("a Range is required");return this.set.some((J)=>{return T$(J,Z)&&$.set.some((Q)=>{return T$(Q,Z)&&J.every((X)=>{return Q.every((V)=>{return X.intersects(V,Z)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new hJ($,this.options)}catch(Z){return!1}for(let Z=0;Z<this.set.length;Z++)if(Z3(this.set[Z],$,this.options))return!0;return!1}}x$.exports=X6;var bJ=W$(),E$=new bJ,fJ=b6(),f2=I$(),h=Z6(),hJ=P4(),{safeRe:J0,t:s,comparatorTrimReplace:gJ,tildeTrimReplace:uJ,caretTrimReplace:dJ}=J6(),{FLAG_INCLUDE_PRERELEASE:mJ,FLAG_LOOSE:cJ}=y6(),S$=($)=>$.value==="<0.0.0-0",lJ=($)=>$.value==="",T$=($,Z)=>{let J=!0,Q=$.slice(),X=Q.pop();while(J&&Q.length)J=Q.every((V)=>{return X.intersects(V,Z)}),X=Q.pop();return J},pJ=($,Z)=>{return $=$.replace(J0[s.BUILD],""),h("comp",$,Z),$=nJ($,Z),h("caret",$),$=aJ($,Z),h("tildes",$),$=oJ($,Z),h("xrange",$),$=eJ($,Z),h("stars",$),$},Q0=($)=>!$||$.toLowerCase()==="x"||$==="*",aJ=($,Z)=>{return $.trim().split(/\s+/).map((J)=>rJ(J,Z)).join(" ")},rJ=($,Z)=>{let J=Z.loose?J0[s.TILDELOOSE]:J0[s.TILDE];return $.replace(J,(Q,X,V,K,Y)=>{h("tilde",$,Q,X,V,K,Y);let W;if(Q0(X))W="";else if(Q0(V))W=`>=${X}.0.0 <${+X+1}.0.0-0`;else if(Q0(K))W=`>=${X}.${V}.0 <${X}.${+V+1}.0-0`;else if(Y)h("replaceTilde pr",Y),W=`>=${X}.${V}.${K}-${Y} <${X}.${+V+1}.0-0`;else W=`>=${X}.${V}.${K} <${X}.${+V+1}.0-0`;return h("tilde return",W),W})},nJ=($,Z)=>{return $.trim().split(/\s+/).map((J)=>iJ(J,Z)).join(" ")},iJ=($,Z)=>{h("caret",$,Z);let J=Z.loose?J0[s.CARETLOOSE]:J0[s.CARET],Q=Z.includePrerelease?"-0":"";return $.replace(J,(X,V,K,Y,W)=>{h("caret",$,X,V,K,Y,W);let H;if(Q0(V))H="";else if(Q0(K))H=`>=${V}.0.0${Q} <${+V+1}.0.0-0`;else if(Q0(Y))if(V==="0")H=`>=${V}.${K}.0${Q} <${V}.${+K+1}.0-0`;else H=`>=${V}.${K}.0${Q} <${+V+1}.0.0-0`;else if(W)if(h("replaceCaret pr",W),V==="0")if(K==="0")H=`>=${V}.${K}.${Y}-${W} <${V}.${K}.${+Y+1}-0`;else H=`>=${V}.${K}.${Y}-${W} <${V}.${+K+1}.0-0`;else H=`>=${V}.${K}.${Y}-${W} <${+V+1}.0.0-0`;else if(h("no pr"),V==="0")if(K==="0")H=`>=${V}.${K}.${Y}${Q} <${V}.${K}.${+Y+1}-0`;else H=`>=${V}.${K}.${Y}${Q} <${V}.${+K+1}.0-0`;else H=`>=${V}.${K}.${Y} <${+V+1}.0.0-0`;return h("caret return",H),H})},oJ=($,Z)=>{return h("replaceXRanges",$,Z),$.split(/\s+/).map((J)=>sJ(J,Z)).join(" ")},sJ=($,Z)=>{$=$.trim();let J=Z.loose?J0[s.XRANGELOOSE]:J0[s.XRANGE];return $.replace(J,(Q,X,V,K,Y,W)=>{h("xRange",$,Q,X,V,K,Y,W);let H=Q0(V),z=H||Q0(K),G=z||Q0(Y),A=G;if(X==="="&&A)X="";if(W=Z.includePrerelease?"-0":"",H)if(X===">"||X==="<")Q="<0.0.0-0";else Q="*";else if(X&&A){if(z)K=0;if(Y=0,X===">")if(X=">=",z)V=+V+1,K=0,Y=0;else K=+K+1,Y=0;else if(X==="<=")if(X="<",z)V=+V+1;else K=+K+1;if(X==="<")W="-0";Q=`${X+V}.${K}.${Y}${W}`}else if(z)Q=`>=${V}.0.0${W} <${+V+1}.0.0-0`;else if(G)Q=`>=${V}.${K}.0${W} <${V}.${+K+1}.0-0`;return h("xRange return",Q),Q})},eJ=($,Z)=>{return h("replaceStars",$,Z),$.trim().replace(J0[s.STAR],"")},tJ=($,Z)=>{return h("replaceGTE0",$,Z),$.trim().replace(J0[Z.includePrerelease?s.GTE0PRE:s.GTE0],"")},$3=($)=>(Z,J,Q,X,V,K,Y,W,H,z,G,A)=>{if(Q0(Q))J="";else if(Q0(X))J=`>=${Q}.0.0${$?"-0":""}`;else if(Q0(V))J=`>=${Q}.${X}.0${$?"-0":""}`;else if(K)J=`>=${J}`;else J=`>=${J}${$?"-0":""}`;if(Q0(H))W="";else if(Q0(z))W=`<${+H+1}.0.0-0`;else if(Q0(G))W=`<${H}.${+z+1}.0-0`;else if(A)W=`<=${H}.${z}.${G}-${A}`;else if($)W=`<${H}.${z}.${+G+1}-0`;else W=`<=${W}`;return`${J} ${W}`.trim()},Z3=($,Z,J)=>{for(let Q=0;Q<$.length;Q++)if(!$[Q].test(Z))return!1;if(Z.prerelease.length&&!J.includePrerelease){for(let Q=0;Q<$.length;Q++){if(h($[Q].semver),$[Q].semver===f2.ANY)continue;if($[Q].semver.prerelease.length>0){let X=$[Q].semver;if(X.major===Z.major&&X.minor===Z.minor&&X.patch===Z.patch)return!0}}return!1}return!0}});var v$=T((QW,k$)=>{var J3=b2(),Q3=($,Z,J)=>{try{Z=new J3(Z,J)}catch(Q){return!1}return Z.test($)};k$.exports=Q3});var h2=T((XW,X3)=>{X3.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 u2=T((VW,c$)=>{/*!
6
- Copyright 2013 Lovell Fuller and others.
7
- SPDX-License-Identifier: Apache-2.0
8
- */var{spawnSync:l6}=v("child_process"),{createHash:V3}=v("crypto"),f$=J$(),K3=v2(),Y3=v$(),O$=O6(),{config:W3,engines:y$,optionalDependencies:H3}=h2(),q3=process.env.npm_package_config_libvips||W3.libvips,h$=f$(q3).version,z3=["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"],p6={encoding:"utf8",shell:!0},G3=($)=>{if($ instanceof Error)console.error(`sharp: Installation error: ${$.message}`);else console.log(`sharp: ${$}`)},g$=()=>O$.isNonGlibcLinuxSync()?O$.familySync():"",j3=()=>`${process.platform}${g$()}-${process.arch}`,D4=()=>{if(u$())return"wasm32";let{npm_config_arch:$,npm_config_platform:Z,npm_config_libc:J}=process.env,Q=typeof J==="string"?J:g$();return`${Z||process.platform}${Q}-${$||process.arch}`},U3=()=>{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""},A3=()=>{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/cplusplus");})()}catch{}return""},B3=()=>{try{return v(`@img/sharp-libvips-dev-${D4()}/lib`)}catch{try{return v(`@img/sharp-libvips-${D4()}/lib`)}catch{}}return""},L3=()=>{if(process.release?.name==="node"&&process.versions){if(!Y3(process.versions.node,y$.node))return{found:process.versions.node,expected:y$.node}}},u$=()=>{let{CC:$}=process.env;return Boolean($?.endsWith("/emcc"))},_3=()=>{if(process.platform==="darwin"&&process.arch==="x64")return(l6("sysctl sysctl.proc_translated",p6).stdout||"").trim()==="sysctl.proc_translated: 1";return!1},b$=($)=>V3("sha512").update($).digest("hex"),w3=()=>{try{let $=b$(`imgsharp-libvips-${D4()}`),Z=f$(H3[`@img/sharp-libvips-${D4()}`],{includePrerelease:!0}).version;return b$(`${$}npm:${Z}`).slice(0,10)}catch{}return""},R3=()=>l6(`node-gyp rebuild --directory=src ${u$()?"--nodedir=emscripten":""}`,{...p6,stdio:"inherit"}).status,d$=()=>{if(process.platform!=="win32")return(l6("pkg-config --modversion vips-cpp",{...p6,env:{...process.env,PKG_CONFIG_PATH:m$()}}).stdout||"").trim();else return""},m$=()=>{if(process.platform!=="win32")return[(l6('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',p6).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""},g2=($,Z,J)=>{if(J)J(`Detected ${Z}, skipping search for globally-installed libvips`);return $},C3=($)=>{if(Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)===!0)return g2(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",$);if(Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)===!0)return g2(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",$);if(_3())return g2(!1,"Rosetta",$);let Z=d$();return!!Z&&K3(Z,h$)};c$.exports={minimumLibvipsVersion:h$,prebuiltPlatforms:z3,buildPlatformArch:D4,buildSharpLibvipsIncludeDir:U3,buildSharpLibvipsCPlusPlusDir:A3,buildSharpLibvipsLibDir:B3,isUnsupportedNodeRuntime:L3,runtimePlatformArch:j3,log:G3,yarnLocator:w3,spawnRebuild:R3,globalLibvipsVersion:d$,pkgConfigPath:m$,useGlobalLibvips:C3}});var K6=T((YW,p$)=>{/*!
9
- Copyright 2013 Lovell Fuller and others.
10
- SPDX-License-Identifier: Apache-2.0
11
- */var{familySync:N3,versionSync:P3}=O6(),{runtimePlatformArch:D3,isUnsupportedNodeRuntime:l$,prebuiltPlatforms:F3,minimumLibvipsVersion:M3}=u2(),z4=D3(),I3=[`../src/build/Release/sharp-${z4}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${z4}/sharp.node`,"@img/sharp-wasm32/sharp.node"],d2,F4,V6=[];for(d2 of I3)try{F4=v(d2);break}catch($){V6.push($)}if(F4&&d2.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)p$.exports=F4;else{let[$,Z,J]=["linux","darwin","win32"].map((V)=>z4.startsWith(V)),Q=[`Could not load the "sharp" module using the ${z4} runtime`];V6.forEach((V)=>{if(V.code!=="MODULE_NOT_FOUND")Q.push(`${V.code}: ${V.message}`)});let X=V6.map((V)=>V.message).join(" ");if(Q.push("Possible solutions:"),l$()){let{found:V,expected:K}=l$();Q.push("- Please upgrade Node.js:",` Found ${V}`,` Requires ${K}`)}else if(F3.includes(z4)){let[V,K]=z4.split("-"),Y=V.endsWith("musl")?" --libc=musl":"";Q.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","")}${Y} --cpu=${K} sharp`)}else Q.push(`- Manually install libvips >= ${M3}`,"- 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=`${N3()} ${P3()}`,Y=`${V.musl?"musl":"glibc"} ${V.musl||V.glibc}`;Q.push("- Update your OS:",` Found ${K}`,` Requires ${Y}`)}catch(V){}if($&&/\/snap\/core[0-9]{2}/.test(X))Q.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node");if(Z&&/Incompatible library version/.test(X))Q.push("- Update Homebrew:"," brew update && brew upgrade vips");if(V6.some((V)=>V.code==="ERR_DLOPEN_DISABLED"))Q.push("- Run Node.js without using the --no-addons flag");if(J&&/The specified procedure could not be found/.test(X))Q.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 Q.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),Error(Q.join(`
12
- `))}});var r$=T((HW,a$)=>{/*!
13
- Copyright 2013 Lovell Fuller and others.
14
- SPDX-License-Identifier: Apache-2.0
15
- */var E3=v("util"),m2=v("stream"),S3=E0();K6();var T3=E3.debuglog("sharp"),x3=($)=>{G4.queue.emit("change",$)},G4=function($,Z){if(arguments.length===1&&!S3.defined($))throw Error("Invalid input");if(!(this instanceof G4))return new G4($,Z);return m2.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:(J)=>{this.emit("warning",J),T3(J)},queueListener:x3},this.options.input=this._createInputDescriptor($,Z,{allowStream:!0}),this};Object.setPrototypeOf(G4.prototype,m2.Duplex.prototype);Object.setPrototypeOf(G4,m2.Duplex);function k3(){let $=this.constructor.call(),{debuglog:Z,queueListener:J,...Q}=this.options;if($.options=structuredClone(Q),$.options.debuglog=Z,$.options.queueListener=J,this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),$.options.input.buffer=this.options.input.buffer,$.emit("finish")});return $}Object.assign(G4.prototype,{clone:k3});a$.exports=G4});var o$=T((qW,i$)=>{/*!
16
- Copyright 2013 Lovell Fuller and others.
17
- SPDX-License-Identifier: Apache-2.0
18
- */var j=E0(),t0=K6(),v3={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},O3=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function n$($){let Z=O3.filter((J)=>j.defined($[J])).map((J)=>[J,$[J]]);return Z.length?Object.fromEntries(Z):void 0}function y3($,Z,J){let Q={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(j.string($))Q.file=$;else if(j.buffer($)){if($.length===0)throw Error("Input Buffer is empty");Q.buffer=$}else if(j.arrayBuffer($)){if($.byteLength===0)throw Error("Input bit Array is empty");Q.buffer=Buffer.from($,0,$.byteLength)}else if(j.typedArray($)){if($.length===0)throw Error("Input Bit Array is empty");Q.buffer=Buffer.from($.buffer,$.byteOffset,$.byteLength)}else if(j.plainObject($)&&!j.defined(Z)){if(Z=$,n$(Z))Q.buffer=[]}else if(!j.defined($)&&!j.defined(Z)&&j.object(J)&&J.allowStream)Q.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))Q.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"]))Q.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))Q.autoOrient=Z.autoOrient;else throw j.invalidParameterError("autoOrient","boolean",Z.autoOrient);if(j.defined(Z.density))if(j.inRange(Z.density,1,1e5))Q.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))Q.ignoreIcc=Z.ignoreIcc;else throw j.invalidParameterError("ignoreIcc","boolean",Z.ignoreIcc);if(j.defined(Z.limitInputPixels))if(j.bool(Z.limitInputPixels))Q.limitInputPixels=Z.limitInputPixels?268402689:0;else if(j.integer(Z.limitInputPixels)&&j.inRange(Z.limitInputPixels,0,Number.MAX_SAFE_INTEGER))Q.limitInputPixels=Z.limitInputPixels;else throw j.invalidParameterError("limitInputPixels","positive integer",Z.limitInputPixels);if(j.defined(Z.unlimited))if(j.bool(Z.unlimited))Q.unlimited=Z.unlimited;else throw j.invalidParameterError("unlimited","boolean",Z.unlimited);if(j.defined(Z.sequentialRead))if(j.bool(Z.sequentialRead))Q.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(Q.rawWidth=Z.raw.width,Q.rawHeight=Z.raw.height,Q.rawChannels=Z.raw.channels,$.constructor){case Uint8Array:case Uint8ClampedArray:Q.rawDepth="uchar";break;case Int8Array:Q.rawDepth="char";break;case Uint16Array:Q.rawDepth="ushort";break;case Int16Array:Q.rawDepth="short";break;case Uint32Array:Q.rawDepth="uint";break;case Int32Array:Q.rawDepth="int";break;case Float32Array:Q.rawDepth="float";break;case Float64Array:Q.rawDepth="double";break;default:Q.rawDepth="uchar";break}else throw Error("Expected width, height and channels for raw pixel input");if(Q.rawPremultiplied=!1,j.defined(Z.raw.premultiplied))if(j.bool(Z.raw.premultiplied))Q.rawPremultiplied=Z.raw.premultiplied;else throw j.invalidParameterError("raw.premultiplied","boolean",Z.raw.premultiplied);if(Q.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}`);Q.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))Q.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))Q.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))Q.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))Q.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))Q.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))Q.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))Q.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))Q.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))Q.svgHighBitdepth=Z.svg.highBitdepth;else throw j.invalidParameterError("svg.highBitdepth","boolean",Z.svg.highBitdepth)}if(j.object(Z.pdf)&&j.defined(Z.pdf.background))Q.pdfBackground=this._getBackgroundColourOption(Z.pdf.background);else if(j.defined(Z.pdfBackground))Q.pdfBackground=this._getBackgroundColourOption(Z.pdfBackground);if(j.object(Z.jp2)&&j.defined(Z.jp2.oneshot))if(j.bool(Z.jp2.oneshot))Q.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(Q.createWidth=Z.create.width,Q.createHeight=Z.create.height,Q.createChannels=Z.create.channels,Q.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}`);Q.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(Q.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(Q.createNoiseMean=128,j.defined(Z.create.noise.mean))if(j.number(Z.create.noise.mean)&&j.inRange(Z.create.noise.mean,0,1e4))Q.createNoiseMean=Z.create.noise.mean;else throw j.invalidParameterError("create.noise.mean","number between 0 and 10000",Z.create.noise.mean);if(Q.createNoiseSigma=30,j.defined(Z.create.noise.sigma))if(j.number(Z.create.noise.sigma)&&j.inRange(Z.create.noise.sigma,0,1e4))Q.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);Q.createBackground=this._getBackgroundColourOption(Z.create.background)}else throw Error("Expected valid noise or background to create a new input image");delete Q.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(Q.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))Q.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))Q.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)Q.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)Q.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]))Q.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))Q.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))Q.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))Q.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))Q.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"]))Q.textWrap=Z.text.wrap;else throw j.invalidParameterError("text.wrap","one of: word, char, word-char, none",Z.text.wrap);delete Q.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))Q.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))Q.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))Q.joinShim=Z.join.shim;else throw j.invalidParameterError("join.shim","integer between 0 and 100000",Z.join.shim);if(j.defined(Z.join.background))Q.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]))Q.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]))Q.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 Q}function b3($,Z,J){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($),J()}else J(Error("Non-Buffer data on Writable Stream"));else J(Error("Unexpected data on Writable Stream"))}function f3(){if(this._isStreamInput())this.options.input.buffer=Buffer.concat(this.options.input.buffer)}function h3(){return Array.isArray(this.options.input.buffer)}function g3($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t0.metadata(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)})});else t0.metadata(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)});return this}else if(this._isStreamInput())return new Promise((J,Q)=>{let X=()=>{this._flattenBufferIn(),t0.metadata(this.options,(V,K)=>{if(V)Q(j.nativeError(V,Z));else J(K)})};if(this.writableFinished)X();else this.once("finish",X)});else return new Promise((J,Q)=>{t0.metadata(this.options,(X,V)=>{if(X)Q(j.nativeError(X,Z));else J(V)})})}function u3($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t0.stats(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)})});else t0.stats(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)});return this}else if(this._isStreamInput())return new Promise((J,Q)=>{this.on("finish",function(){this._flattenBufferIn(),t0.stats(this.options,(X,V)=>{if(X)Q(j.nativeError(X,Z));else J(V)})})});else return new Promise((J,Q)=>{t0.stats(this.options,(X,V)=>{if(X)Q(j.nativeError(X,Z));else J(V)})})}i$.exports=($)=>{Object.assign($.prototype,{_inputOptionsFromObject:n$,_createInputDescriptor:y3,_write:b3,_flattenBufferIn:f3,_isStreamInput:h3,metadata:g3,stats:u3}),$.align=v3}});var J9=T((zW,Z9)=>{/*!
19
- Copyright 2013 Lovell Fuller and others.
20
- SPDX-License-Identifier: Apache-2.0
21
- */var F=E0(),e$={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},t$={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},s$={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},$9={entropy:16,attention:17},c2={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},d3={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},m3={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function l2($){return $.angle%360!==0||$.rotationAngle!==0}function a6($){return $.width!==-1||$.height!==-1}function c3($,Z,J){if(a6(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(J))J=$;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(J)){if(F.defined(J.width))if(F.integer(J.width)&&J.width>0)this.options.width=J.width;else throw F.invalidParameterError("width","positive integer",J.width);if(F.defined(J.height))if(F.integer(J.height)&&J.height>0)this.options.height=J.height;else throw F.invalidParameterError("height","positive integer",J.height);if(F.defined(J.fit)){let Q=m3[J.fit];if(F.string(Q))this.options.canvas=Q;else throw F.invalidParameterError("fit","valid fit",J.fit)}if(F.defined(J.position)){let Q=F.integer(J.position)?J.position:$9[J.position]||t$[J.position]||e$[J.position];if(F.integer(Q)&&(F.inRange(Q,0,8)||F.inRange(Q,16,17)))this.options.position=Q;else throw F.invalidParameterError("position","valid position/gravity/strategy",J.position)}if(this._setBackgroundColourOption("resizeBackground",J.background),F.defined(J.kernel))if(F.string(c2[J.kernel]))this.options.kernel=c2[J.kernel];else throw F.invalidParameterError("kernel","valid kernel name",J.kernel);if(F.defined(J.withoutEnlargement))this._setBooleanOption("withoutEnlargement",J.withoutEnlargement);if(F.defined(J.withoutReduction))this._setBooleanOption("withoutReduction",J.withoutReduction);if(F.defined(J.fastShrinkOnLoad))this._setBooleanOption("fastShrinkOnLoad",J.fastShrinkOnLoad)}if(l2(this.options)&&a6(this.options))this.options.rotateBefore=!0;return this}function l3($){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(s$[$.extendWith]))this.options.extendWith=s$[$.extendWith];else throw F.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",$.extendWith)}else throw F.invalidParameterError("extend","integer or object",$);return this}function p3($){let Z=a6(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(J){let Q=$[J];if(F.integer(Q)&&Q>=0)this.options[J+(J==="left"||J==="top"?"Offset":"")+Z]=Q;else throw F.invalidParameterError(J,"integer",Q)},this),l2(this.options)&&!a6(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 a3($){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(l2(this.options))this.options.rotateBefore=!0;return this}Z9.exports=($)=>{Object.assign($.prototype,{resize:c3,extend:l3,extract:p3,trim:a3}),$.gravity=e$,$.strategy=$9,$.kernel=c2,$.fit=d3,$.position=t$}});var X9=T((GW,Q9)=>{/*!
22
- Copyright 2013 Lovell Fuller and others.
23
- SPDX-License-Identifier: Apache-2.0
24
- */var b=E0(),p2={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 r3($){if(!Array.isArray($))throw b.invalidParameterError("images to composite","array",$);return this.options.composite=$.map((Z)=>{if(!b.object(Z))throw b.invalidParameterError("image to composite","object",Z);let J=this._inputOptionsFromObject(Z),Q={input:this._createInputDescriptor(Z.input,J,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(b.defined(Z.blend))if(b.string(p2[Z.blend]))Q.blend=p2[Z.blend];else throw b.invalidParameterError("blend","valid blend name",Z.blend);if(b.defined(Z.tile))if(b.bool(Z.tile))Q.tile=Z.tile;else throw b.invalidParameterError("tile","boolean",Z.tile);if(b.defined(Z.left))if(b.integer(Z.left))Q.left=Z.left;else throw b.invalidParameterError("left","integer",Z.left);if(b.defined(Z.top))if(b.integer(Z.top))Q.top=Z.top;else throw b.invalidParameterError("top","integer",Z.top);if(b.defined(Z.top)!==b.defined(Z.left))throw Error("Expected both left and top to be set");else Q.hasOffset=b.integer(Z.top)&&b.integer(Z.left);if(b.defined(Z.gravity))if(b.integer(Z.gravity)&&b.inRange(Z.gravity,0,8))Q.gravity=Z.gravity;else if(b.string(Z.gravity)&&b.integer(this.constructor.gravity[Z.gravity]))Q.gravity=this.constructor.gravity[Z.gravity];else throw b.invalidParameterError("gravity","valid gravity",Z.gravity);if(b.defined(Z.premultiplied))if(b.bool(Z.premultiplied))Q.premultiplied=Z.premultiplied;else throw b.invalidParameterError("premultiplied","boolean",Z.premultiplied);return Q}),this}Q9.exports=($)=>{$.prototype.composite=r3,$.blend=p2}});var H9=T((jW,W9)=>{/*!
25
- Copyright 2013 Lovell Fuller and others.
26
- SPDX-License-Identifier: Apache-2.0
27
- */var U=E0(),V9={integer:"integer",float:"float",approximate:"approximate"};function n3($,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 i3(){return this.options.input.autoOrient=!0,this}function o3($){return this.options.flip=U.bool($)?$:!0,this}function s3($){return this.options.flop=U.bool($)?$:!0,this}function e3($,Z){let J=[].concat(...$);if(J.length===4&&J.every(U.number))this.options.affineMatrix=J;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 t3($,Z,J){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(J))if(U.number(J)&&U.inRange(J,0,1e4))this.options.sharpenM2=J;else throw U.invalidParameterError("jagged","number between 0 and 10000",J)}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 $Q($){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 ZQ($){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(V9[$.precision]))this.options.precision=V9[$.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 K9($){if(!U.defined($))this.options.dilateWidth=1;else if(U.integer($)&&$>0)this.options.dilateWidth=$;else throw U.invalidParameterError("dilate","positive integer",K9);return this}function Y9($){if(!U.defined($))this.options.erodeWidth=1;else if(U.integer($)&&$>0)this.options.erodeWidth=$;else throw U.invalidParameterError("erode","positive integer",Y9);return this}function JQ($){if(this.options.flatten=U.bool($)?$:!0,U.object($))this._setBackgroundColourOption("flattenBackground",$.background);return this}function QQ(){return this.options.unflatten=!0,this}function XQ($,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 VQ($){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 KQ($){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 YQ($){return this.normalise($)}function WQ($){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 HQ($){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,J)=>Z+J,0);if($.scale<1)$.scale=1;if(!U.integer($.offset))$.offset=0;return this.options.convKernel=$,this}function qQ($,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 zQ($,Z,J){if(this.options.boolean=this._createInputDescriptor($,J),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 GQ($,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 jQ($){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 UQ($){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}W9.exports=($)=>{Object.assign($.prototype,{autoOrient:i3,rotate:n3,flip:o3,flop:s3,affine:e3,sharpen:t3,erode:Y9,dilate:K9,median:$Q,blur:ZQ,flatten:JQ,unflatten:QQ,gamma:XQ,negate:VQ,normalise:KQ,normalize:YQ,clahe:WQ,convolve:HQ,threshold:qQ,boolean:zQ,linear:GQ,recomb:jQ,modulate:UQ})}});var A9=T((UW,U9)=>{var{defineProperty:i2,getOwnPropertyDescriptor:AQ,getOwnPropertyNames:BQ}=Object,LQ=Object.prototype.hasOwnProperty,_Q=($,Z)=>{for(var J in Z)i2($,J,{get:Z[J],enumerable:!0})},wQ=($,Z,J,Q)=>{if(Z&&typeof Z==="object"||typeof Z==="function"){for(let X of BQ(Z))if(!LQ.call($,X)&&X!==J)i2($,X,{get:()=>Z[X],enumerable:!(Q=AQ(Z,X))||Q.enumerable})}return $},RQ=($)=>wQ(i2({},"__esModule",{value:!0}),$),q9={};_Q(q9,{default:()=>OQ});U9.exports=RQ(q9);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]},z9=Object.create(null);for(let $ in v0)if(Object.hasOwn(v0,$))z9[v0[$]]=$;var W0={to:{},get:{}};W0.get=function($){let Z=$.slice(0,3).toLowerCase(),J,Q;switch(Z){case"hsl":{J=W0.get.hsl($),Q="hsl";break}case"hwb":{J=W0.get.hwb($),Q="hwb";break}default:{J=W0.get.rgb($),Q="rgb";break}}if(!J)return null;return{model:Q,value:J}};W0.get.rgb=function($){if(!$)return null;let Z=/^#([a-f\d]{3,4})$/i,J=/^#([a-f\d]{6})([a-f\d]{2})?$/i,Q=/^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],Y,W,H;if(Y=$.match(J)){H=Y[2],Y=Y[1];for(W=0;W<3;W++){let z=W*2;K[W]=Number.parseInt(Y.slice(z,z+2),16)}if(H)K[3]=Number.parseInt(H,16)/255}else if(Y=$.match(Z)){Y=Y[1],H=Y[3];for(W=0;W<3;W++)K[W]=Number.parseInt(Y[W]+Y[W],16);if(H)K[3]=Number.parseInt(H+H,16)/255}else if(Y=$.match(Q)){for(W=0;W<3;W++)K[W]=Number.parseInt(Y[W+1],10);if(Y[4])K[3]=Y[5]?Number.parseFloat(Y[4])*0.01:Number.parseFloat(Y[4])}else if(Y=$.match(X)){for(W=0;W<3;W++)K[W]=Math.round(Number.parseFloat(Y[W+1])*2.55);if(Y[4])K[3]=Y[5]?Number.parseFloat(Y[4])*0.01:Number.parseFloat(Y[4])}else if(Y=$.match(V)){if(Y[1]==="transparent")return[0,0,0,0];if(!Object.hasOwn(v0,Y[1]))return null;return K=v0[Y[1]],K[3]=1,K}else return null;for(W=0;W<3;W++)K[W]=$4(K[W],0,255);return K[3]=$4(K[3],0,1),K};W0.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*)?\)$/,J=$.match(Z);if(J){let Q=Number.parseFloat(J[4]),X=(Number.parseFloat(J[1])%360+360)%360,V=$4(Number.parseFloat(J[2]),0,100),K=$4(Number.parseFloat(J[3]),0,100),Y=$4(Number.isNaN(Q)?1:Q,0,1);return[X,V,K,Y]}return null};W0.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*)?\)$/,J=$.match(Z);if(J){let Q=Number.parseFloat(J[4]),X=(Number.parseFloat(J[1])%360+360)%360,V=$4(Number.parseFloat(J[2]),0,100),K=$4(Number.parseFloat(J[3]),0,100),Y=$4(Number.isNaN(Q)?1:Q,0,1);return[X,V,K,Y]}return null};W0.to.hex=function(...$){return"#"+r6($[0])+r6($[1])+r6($[2])+($[3]<1?r6(Math.round($[3]*255)):"")};W0.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]+")"};W0.to.rgb.percent=function(...$){let Z=Math.round($[0]/255*100),J=Math.round($[1]/255*100),Q=Math.round($[2]/255*100);return $.length<4||$[3]===1?"rgb("+Z+"%, "+J+"%, "+Q+"%)":"rgba("+Z+"%, "+J+"%, "+Q+"%, "+$[3]+")"};W0.to.hsl=function(...$){return $.length<4||$[3]===1?"hsl("+$[0]+", "+$[1]+"%, "+$[2]+"%)":"hsla("+$[0]+", "+$[1]+"%, "+$[2]+"%, "+$[3]+")"};W0.to.hwb=function(...$){let Z="";if($.length>=4&&$[3]!==1)Z=", "+$[3];return"hwb("+$[0]+", "+$[1]+"%, "+$[2]+"%"+Z+")"};W0.to.keyword=function(...$){return z9[$.slice(0,3)]};function $4($,Z,J){return Math.min(Math.max(Z,$),J)}function r6($){let Z=Math.round($).toString(16).toUpperCase();return Z.length<2?"0"+Z:Z}var M4=W0,G9={};for(let $ of Object.keys(v0))G9[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:J}=C[$];delete C[$].channels,delete C[$].labels,Object.defineProperty(C[$],"channels",{value:Z}),Object.defineProperty(C[$],"labels",{value:J})}C.rgb.hsl=function($){let Z=$[0]/255,J=$[1]/255,Q=$[2]/255,X=Math.min(Z,J,Q),V=Math.max(Z,J,Q),K=V-X,Y,W;switch(V){case X:{Y=0;break}case Z:{Y=(J-Q)/K;break}case J:{Y=2+(Q-Z)/K;break}case Q:{Y=4+(Z-J)/K;break}}if(Y=Math.min(Y*60,360),Y<0)Y+=360;let H=(X+V)/2;if(V===X)W=0;else if(H<=0.5)W=K/(V+X);else W=K/(2-V-X);return[Y,W*100,H*100]};C.rgb.hsv=function($){let Z,J,Q,X,V,K=$[0]/255,Y=$[1]/255,W=$[2]/255,H=Math.max(K,Y,W),z=H-Math.min(K,Y,W),G=function(A){return(H-A)/6/z+0.5};if(z===0)X=0,V=0;else{switch(V=z/H,Z=G(K),J=G(Y),Q=G(W),H){case K:{X=Q-J;break}case Y:{X=0.3333333333333333+Z-Q;break}case W:{X=0.6666666666666666+J-Z;break}}if(X<0)X+=1;else if(X>1)X-=1}return[X*360,V*100,H*100]};C.rgb.hwb=function($){let Z=$[0],J=$[1],Q=$[2],X=C.rgb.hsl($)[0],V=0.00392156862745098*Math.min(Z,Math.min(J,Q));return Q=1-0.00392156862745098*Math.max(Z,Math.max(J,Q)),[X,V*100,Q*100]};C.rgb.oklab=function($){let Z=S4($[0]/255),J=S4($[1]/255),Q=S4($[2]/255),X=Math.cbrt(0.4122214708*Z+0.5363325363*J+0.0514459929*Q),V=Math.cbrt(0.2119034982*Z+0.6806995451*J+0.1073969566*Q),K=Math.cbrt(0.0883024619*Z+0.2817188376*J+0.6299787005*Q),Y=0.2104542553*X+0.793617785*V-0.0040720468*K,W=1.9779984951*X-2.428592205*V+0.4505937099*K,H=0.0259040371*X+0.7827717662*V-0.808675766*K;return[Y*100,W*100,H*100]};C.rgb.cmyk=function($){let Z=$[0]/255,J=$[1]/255,Q=$[2]/255,X=Math.min(1-Z,1-J,1-Q),V=(1-Z-X)/(1-X)||0,K=(1-J-X)/(1-X)||0,Y=(1-Q-X)/(1-X)||0;return[V*100,K*100,Y*100,X*100]};function CQ($,Z){return($[0]-Z[0])**2+($[1]-Z[1])**2+($[2]-Z[2])**2}C.rgb.keyword=function($){let Z=G9[$];if(Z)return Z;let J=Number.POSITIVE_INFINITY,Q;for(let X of Object.keys(v0)){let V=v0[X],K=CQ($,V);if(K<J)J=K,Q=X}return Q};C.keyword.rgb=function($){return v0[$]};C.rgb.xyz=function($){let Z=S4($[0]/255),J=S4($[1]/255),Q=S4($[2]/255),X=Z*0.4124564+J*0.3575761+Q*0.1804375,V=Z*0.2126729+J*0.7151522+Q*0.072175,K=Z*0.0193339+J*0.119192+Q*0.9503041;return[X*100,V*100,K*100]};C.rgb.lab=function($){let Z=C.rgb.xyz($),J=Z[0],Q=Z[1],X=Z[2];J/=95.047,Q/=100,X/=108.883,J=J>c0?J**0.3333333333333333:7.787*J+0.13793103448275862,Q=Q>c0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,X=X>c0?X**0.3333333333333333:7.787*X+0.13793103448275862;let V=116*Q-16,K=500*(J-Q),Y=200*(Q-X);return[V,K,Y]};C.hsl.rgb=function($){let Z=$[0]/360,J=$[1]/100,Q=$[2]/100,X,V;if(J===0)return V=Q*255,[V,V,V];let K=Q<0.5?Q*(1+J):Q+J-Q*J,Y=2*Q-K,W=[0,0,0];for(let H=0;H<3;H++){if(X=Z+0.3333333333333333*-(H-1),X<0)X++;if(X>1)X--;if(6*X<1)V=Y+(K-Y)*6*X;else if(2*X<1)V=K;else if(3*X<2)V=Y+(K-Y)*(0.6666666666666666-X)*6;else V=Y;W[H]=V*255}return W};C.hsl.hsv=function($){let Z=$[0],J=$[1]/100,Q=$[2]/100,X=J,V=Math.max(Q,0.01);Q*=2,J*=Q<=1?Q:2-Q,X*=V<=1?V:2-V;let K=(Q+J)/2,Y=Q===0?2*X/(V+X):2*J/(Q+J);return[Z,Y*100,K*100]};C.hsv.rgb=function($){let Z=$[0]/60,J=$[1]/100,Q=$[2]/100,X=Math.floor(Z)%6,V=Z-Math.floor(Z),K=255*Q*(1-J),Y=255*Q*(1-J*V),W=255*Q*(1-J*(1-V));switch(Q*=255,X){case 0:return[Q,W,K];case 1:return[Y,Q,K];case 2:return[K,Q,W];case 3:return[K,Y,Q];case 4:return[W,K,Q];case 5:return[Q,K,Y]}};C.hsv.hsl=function($){let Z=$[0],J=$[1]/100,Q=$[2]/100,X=Math.max(Q,0.01),V,K;K=(2-J)*Q;let Y=(2-J)*X;return V=J*X,V/=Y<=1?Y:2-Y,V=V||0,K/=2,[Z,V*100,K*100]};C.hwb.rgb=function($){let Z=$[0]/360,J=$[1]/100,Q=$[2]/100,X=J+Q,V;if(X>1)J/=X,Q/=X;let K=Math.floor(6*Z),Y=1-Q;if(V=6*Z-K,(K&1)!==0)V=1-V;let W=J+V*(Y-J),H,z,G;switch(K){default:case 6:case 0:{H=Y,z=W,G=J;break}case 1:{H=W,z=Y,G=J;break}case 2:{H=J,z=Y,G=W;break}case 3:{H=J,z=W,G=Y;break}case 4:{H=W,z=J,G=Y;break}case 5:{H=Y,z=J,G=W;break}}return[H*255,z*255,G*255]};C.cmyk.rgb=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=$[3]/100,V=1-Math.min(1,Z*(1-X)+X),K=1-Math.min(1,J*(1-X)+X),Y=1-Math.min(1,Q*(1-X)+X);return[V*255,K*255,Y*255]};C.xyz.rgb=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X,V,K;return X=Z*3.2404542+J*-1.5371385+Q*-0.4985314,V=Z*-0.969266+J*1.8760108+Q*0.041556,K=Z*0.0556434+J*-0.2040259+Q*1.0572252,X=E4(X),V=E4(V),K=E4(K),[X*255,V*255,K*255]};C.xyz.lab=function($){let Z=$[0],J=$[1],Q=$[2];Z/=95.047,J/=100,Q/=108.883,Z=Z>c0?Z**0.3333333333333333:7.787*Z+0.13793103448275862,J=J>c0?J**0.3333333333333333:7.787*J+0.13793103448275862,Q=Q>c0?Q**0.3333333333333333:7.787*Q+0.13793103448275862;let X=116*J-16,V=500*(Z-J),K=200*(J-Q);return[X,V,K]};C.xyz.oklab=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=Math.cbrt(0.8189330101*Z+0.3618667424*J-0.1288597137*Q),V=Math.cbrt(0.0329845436*Z+0.9293118715*J+0.0361456387*Q),K=Math.cbrt(0.0482003018*Z+0.2643662691*J+0.633851707*Q),Y=0.2104542553*X+0.793617785*V-0.0040720468*K,W=1.9779984951*X-2.428592205*V+0.4505937099*K,H=0.0259040371*X+0.7827717662*V-0.808675766*K;return[Y*100,W*100,H*100]};C.oklab.oklch=function($){return C.lab.lch($)};C.oklab.xyz=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=(0.999999998*Z+0.396337792*J+0.215803758*Q)**3,V=(1.000000008*Z-0.105561342*J-0.063854175*Q)**3,K=(1.000000055*Z-0.089484182*J-1.291485538*Q)**3,Y=1.227013851*X-0.55779998*V+0.281256149*K,W=-0.040580178*X+1.11225687*V-0.071676679*K,H=-0.076381285*X-0.421481978*V+1.58616322*K;return[Y*100,W*100,H*100]};C.oklab.rgb=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=(Z+0.3963377774*J+0.2158037573*Q)**3,V=(Z-0.1055613458*J-0.0638541728*Q)**3,K=(Z-0.0894841775*J-1.291485548*Q)**3,Y=E4(4.0767416621*X-3.3077115913*V+0.2309699292*K),W=E4(-1.2684380046*X+2.6097574011*V-0.3413193965*K),H=E4(-0.0041960863*X-0.7034186147*V+1.707614701*K);return[Y*255,W*255,H*255]};C.oklch.oklab=function($){return C.lch.lab($)};C.lab.xyz=function($){let Z=$[0],J=$[1],Q=$[2],X,V,K;V=(Z+16)/116,X=J/500+V,K=V-Q/200;let Y=V**3,W=X**3,H=K**3;return V=Y>c0?Y:(V-0.13793103448275862)/7.787,X=W>c0?W:(X-0.13793103448275862)/7.787,K=H>c0?H:(K-0.13793103448275862)/7.787,X*=95.047,V*=100,K*=108.883,[X,V,K]};C.lab.lch=function($){let Z=$[0],J=$[1],Q=$[2],X;if(X=Math.atan2(Q,J)*360/2/Math.PI,X<0)X+=360;let K=Math.sqrt(J*J+Q*Q);return[Z,K,X]};C.lch.lab=function($){let Z=$[0],J=$[1],X=$[2]/360*2*Math.PI,V=J*Math.cos(X),K=J*Math.sin(X);return[Z,V,K]};C.rgb.ansi16=function($,Z=null){let[J,Q,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(Q/255)<<1|Math.round(J/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],J=$[1],Q=$[2];if(Z>>4===J>>4&&J>>4===Q>>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(J/255*5)+Math.round(Q/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 J=(Math.trunc($>50)+1)*0.5,Q=(Z&1)*J*255,X=(Z>>1&1)*J*255,V=(Z>>2&1)*J*255;return[Q,X,V]};C.ansi256.rgb=function($){if($=$[0],$>=232){let V=($-232)*10+8;return[V,V,V]}$-=16;let Z,J=Math.floor($/36)/5*255,Q=Math.floor((Z=$%36)/6)/5*255,X=Z%6/5*255;return[J,Q,X]};C.rgb.hex=function($){let J=(((Math.round($[0])&255)<<16)+((Math.round($[1])&255)<<8)+(Math.round($[2])&255)).toString(16).toUpperCase();return"000000".slice(J.length)+J};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 J=Z[0];if(Z[0].length===3)J=[...J].map((Y)=>Y+Y).join("");let Q=Number.parseInt(J,16),X=Q>>16&255,V=Q>>8&255,K=Q&255;return[X,V,K]};C.rgb.hcg=function($){let Z=$[0]/255,J=$[1]/255,Q=$[2]/255,X=Math.max(Math.max(Z,J),Q),V=Math.min(Math.min(Z,J),Q),K=X-V,Y,W=K<1?V/(1-K):0;if(K<=0)Y=0;else if(X===Z)Y=(J-Q)/K%6;else if(X===J)Y=2+(Q-Z)/K;else Y=4+(Z-J)/K;return Y/=6,Y%=1,[Y*360,K*100,W*100]};C.hsl.hcg=function($){let Z=$[1]/100,J=$[2]/100,Q=J<0.5?2*Z*J:2*Z*(1-J),X=0;if(Q<1)X=(J-0.5*Q)/(1-Q);return[$[0],Q*100,X*100]};C.hsv.hcg=function($){let Z=$[1]/100,J=$[2]/100,Q=Z*J,X=0;if(Q<1)X=(J-Q)/(1-Q);return[$[0],Q*100,X*100]};C.hcg.rgb=function($){let Z=$[0]/360,J=$[1]/100,Q=$[2]/100;if(J===0)return[Q*255,Q*255,Q*255];let X=[0,0,0],V=Z%1*6,K=V%1,Y=1-K,W=0;switch(Math.floor(V)){case 0:{X[0]=1,X[1]=K,X[2]=0;break}case 1:{X[0]=Y,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]=Y,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]=Y}return W=(1-J)*Q,[(J*X[0]+W)*255,(J*X[1]+W)*255,(J*X[2]+W)*255]};C.hcg.hsv=function($){let Z=$[1]/100,J=$[2]/100,Q=Z+J*(1-Z),X=0;if(Q>0)X=Z/Q;return[$[0],X*100,Q*100]};C.hcg.hsl=function($){let Z=$[1]/100,Q=$[2]/100*(1-Z)+0.5*Z,X=0;if(Q>0&&Q<0.5)X=Z/(2*Q);else if(Q>=0.5&&Q<1)X=Z/(2*(1-Q));return[$[0],X*100,Q*100]};C.hcg.hwb=function($){let Z=$[1]/100,J=$[2]/100,Q=Z+J*(1-Z);return[$[0],(Q-Z)*100,(1-Q)*100]};C.hwb.hcg=function($){let Z=$[1]/100,Q=1-$[2]/100,X=Q-Z,V=0;if(X<1)V=(Q-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,Q=((Z<<16)+(Z<<8)+Z).toString(16).toUpperCase();return"000000".slice(Q.length)+Q};C.rgb.gray=function($){return[($[0]+$[1]+$[2])/3/255*100]};function NQ(){let $={},Z=Object.keys(j4);for(let{length:J}=Z,Q=0;Q<J;Q++)$[Z[Q]]={distance:-1,parent:null};return $}function PQ($){let Z=NQ(),J=[$];Z[$].distance=0;while(J.length>0){let Q=J.pop(),X=Object.keys(j4[Q]);for(let{length:V}=X,K=0;K<V;K++){let Y=X[K],W=Z[Y];if(W.distance===-1)W.distance=Z[Q].distance+1,W.parent=Q,J.unshift(Y)}}return Z}function DQ($,Z){return function(J){return Z($(J))}}function FQ($,Z){let J=[Z[$].parent,$],Q=j4[Z[$].parent][$],X=Z[$].parent;while(Z[X].parent)J.unshift(Z[X].parent),Q=DQ(j4[Z[X].parent][X],Q),X=Z[X].parent;return Q.conversion=J,Q}function MQ($){let Z=PQ($),J={},Q=Object.keys(Z);for(let{length:X}=Q,V=0;V<X;V++){let K=Q[V];if(Z[K].parent===null)continue;J[K]=FQ(K,Z)}return J}var IQ=MQ,I4={},EQ=Object.keys(j4);function SQ($){let Z=function(...J){let Q=J[0];if(Q===void 0||Q===null)return Q;if(Q.length>1)J=Q;return $(J)};if("conversion"in $)Z.conversion=$.conversion;return Z}function TQ($){let Z=function(...J){let Q=J[0];if(Q===void 0||Q===null)return Q;if(Q.length>1)J=Q;let X=$(J);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 EQ){I4[$]={},Object.defineProperty(I4[$],"channels",{value:j4[$].channels}),Object.defineProperty(I4[$],"labels",{value:j4[$].labels});let Z=IQ($),J=Object.keys(Z);for(let Q of J){let X=Z[Q];I4[$][Q]=TQ(X),I4[$][Q].raw=SQ(X)}}var z0=I4,j9=["keyword","gray","hex"],a2={};for(let $ of Object.keys(z0))a2[[...z0[$].labels].sort().join("")]=$;var r2={};function n($,Z){if(!(this instanceof n))return new n($,Z);if(Z&&Z in j9)Z=null;if(Z&&!(Z in z0))throw Error("Unknown model: "+Z);let J,Q;if($==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if($ instanceof n)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,Q=z0[this.model].channels,this.color=X.value.slice(0,Q),this.valpha=typeof X.value[Q]==="number"?X.value[Q]:1}else if($.length>0){this.model=Z||"rgb",Q=z0[this.model].channels;let X=Array.prototype.slice.call($,0,Q);this.color=n2(X,Q),this.valpha=typeof $[Q]==="number"?$[Q]: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 a2))throw Error("Unable to parse color from object: "+JSON.stringify($));this.model=a2[V];let{labels:K}=z0[this.model],Y=[];for(J=0;J<K.length;J++)Y.push($[K[J]]);this.color=n2(Y)}if(r2[this.model]){Q=z0[this.model].channels;for(J=0;J<Q;J++){let X=r2[this.model][J];if(X)this.color[J]=X(this.color[J])}}if(this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze)Object.freeze(this)}n.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 J=Z.valpha===1?Z.color:[...Z.color,this.valpha];return M4.to[Z.model](...J)},percentString($){let Z=this.rgb().round(typeof $==="number"?$:1),J=Z.valpha===1?Z.color:[...Z.color,this.valpha];return M4.to.rgb.percent(...J)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let $={},{channels:Z}=z0[this.model],{labels:J}=z0[this.model];for(let Q=0;Q<Z;Q++)$[J[Q]]=this.color[Q];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 n([...this.color.map(kQ($)),this.valpha],this.model)},alpha($){if($!==void 0)return new n([...this.color,Math.max(0,Math.min(1,$))],this.model);return this.valpha},red:u("rgb",0,l(255)),green:u("rgb",1,l(255)),blue:u("rgb",2,l(255)),hue:u(["hsl","hsv","hsl","hwb","hcg"],0,($)=>($%360+360)%360),saturationl:u("hsl",1,l(100)),lightness:u("hsl",2,l(100)),saturationv:u("hsv",1,l(100)),value:u("hsv",2,l(100)),chroma:u("hcg",1,l(100)),gray:u("hcg",2,l(100)),white:u("hwb",1,l(100)),wblack:u("hwb",2,l(100)),cyan:u("cmyk",0,l(100)),magenta:u("cmyk",1,l(100)),yellow:u("cmyk",2,l(100)),black:u("cmyk",3,l(100)),x:u("xyz",0,l(95.047)),y:u("xyz",1,l(100)),z:u("xyz",2,l(108.833)),l:u("lab",0,l(100)),a:u("lab",1),b:u("lab",2),keyword($){if($!==void 0)return new n($);return z0[this.model].keyword(this.color)},hex($){if($!==void 0)return new n($);return M4.to.hex(...this.rgb().round().color)},hexa($){if($!==void 0)return new n($);let Z=this.rgb().round().color,J=Math.round(this.valpha*255).toString(16).toUpperCase();if(J.length===1)J="0"+J;return M4.to.hex(...Z)+J},rgbNumber(){let $=this.rgb().color;return($[0]&255)<<16|($[1]&255)<<8|$[2]&255},luminosity(){let $=this.rgb().color,Z=[];for(let[J,Q]of $.entries()){let X=Q/255;Z[J]=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(),J=$.luminosity();if(Z>J)return(Z+0.05)/(J+0.05);return(J+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 n.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(),J=Z.color[0];return J=(J+$)%360,J=J<0?360+J:J,Z.color[0]=J,Z},mix($,Z){if(!$||!$.rgb)throw Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof $);let J=$.rgb(),Q=this.rgb(),X=Z===void 0?0.5:Z,V=2*X-1,K=J.alpha()-Q.alpha(),Y=((V*K===-1?V:(V+K)/(1+V*K))+1)/2,W=1-Y;return n.rgb(Y*J.red()+W*Q.red(),Y*J.green()+W*Q.green(),Y*J.blue()+W*Q.blue(),J.alpha()*X+Q.alpha()*(1-X))}};for(let $ of Object.keys(z0)){if(j9.includes($))continue;let{channels:Z}=z0[$];n.prototype[$]=function(...J){if(this.model===$)return new n(this);if(J.length>0)return new n(J,$);return new n([...vQ(z0[this.model][$].raw(this.color)),this.valpha],$)},n[$]=function(...J){let Q=J[0];if(typeof Q==="number")Q=n2(J,Z);return new n(Q,$)}}function xQ($,Z){return Number($.toFixed(Z))}function kQ($){return function(Z){return xQ(Z,$)}}function u($,Z,J){$=Array.isArray($)?$:[$];for(let Q of $)(r2[Q]||=[])[Z]=J;return $=$[0],function(Q){let X;if(Q!==void 0){if(J)Q=J(Q);return X=this[$](),X.color[Z]=Q,X}if(X=this[$]().color[Z],J)X=J(X);return X}}function l($){return function(Z){return Math.max(0,Math.min($,Z))}}function vQ($){return Array.isArray($)?$:[$]}function n2($,Z){for(let J=0;J<Z;J++)if(typeof $[J]!=="number")$[J]=0;return $}var OQ=n});var L9=T((AW,B9)=>{B9.exports=A9().default});var C9=T((BW,R9)=>{/*!
28
- Copyright 2013 Lovell Fuller and others.
29
- SPDX-License-Identifier: Apache-2.0
30
- */var yQ=L9(),l0=E0(),_9={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function bQ($){return this._setBackgroundColourOption("tint",$),this}function fQ($){return this.options.greyscale=l0.bool($)?$:!0,this}function hQ($){return this.greyscale($)}function gQ($){if(!l0.string($))throw l0.invalidParameterError("colourspace","string",$);return this.options.colourspacePipeline=$,this}function uQ($){return this.pipelineColourspace($)}function dQ($){if(!l0.string($))throw l0.invalidParameterError("colourspace","string",$);return this.options.colourspace=$,this}function mQ($){return this.toColourspace($)}function w9($){if(l0.object($)||l0.string($)&&$.length>=3&&$.length<=200){let Z=yQ($);return[Z.red(),Z.green(),Z.blue(),Math.round(Z.alpha()*255)]}else throw l0.invalidParameterError("background","object or string",$)}function cQ($,Z){if(l0.defined(Z))this.options[$]=w9(Z)}R9.exports=($)=>{Object.assign($.prototype,{tint:bQ,greyscale:fQ,grayscale:hQ,pipelineColourspace:gQ,pipelineColorspace:uQ,toColourspace:dQ,toColorspace:mQ,_getBackgroundColourOption:w9,_setBackgroundColourOption:cQ}),$.colourspace=_9,$.colorspace=_9}});var P9=T((LW,N9)=>{/*!
31
- Copyright 2013 Lovell Fuller and others.
32
- SPDX-License-Identifier: Apache-2.0
33
- */var O0=E0(),lQ={and:"and",or:"or",eor:"eor"};function pQ(){return this.options.removeAlpha=!0,this}function aQ($){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 rQ($){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 nQ($,Z){if(Array.isArray($))$.forEach(function(J){this.options.joinChannelIn.push(this._createInputDescriptor(J,Z))},this);else this.options.joinChannelIn.push(this._createInputDescriptor($,Z));return this}function iQ($){if(O0.string($)&&O0.inArray($,["and","or","eor"]))this.options.bandBoolOp=$;else throw O0.invalidParameterError("boolOp","one of: and, or, eor",$);return this}N9.exports=($)=>{Object.assign($.prototype,{removeAlpha:pQ,ensureAlpha:aQ,extractChannel:rQ,joinChannel:nQ,bandbool:iQ}),$.bool=lQ}});var E9=T((_W,I9)=>{/*!
34
- Copyright 2013 Lovell Fuller and others.
35
- SPDX-License-Identifier: Apache-2.0
36
- */var o2=v("path"),q=E0(),T4=K6(),D9=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"]]),oQ=/\.(jp[2x]|j2[kc])$/i,F9=()=>Error("JP2 output requires libvips with support for OpenJPEG"),M9=($)=>1<<31-Math.clz32(Math.ceil(Math.log2($)));function sQ($,Z){let J;if(!q.string($))J=Error("Missing output file path");else if(q.string(this.options.input.file)&&o2.resolve(this.options.input.file)===o2.resolve($))J=Error("Cannot use same file for input and output");else if(oQ.test(o2.extname($))&&!this.constructor.format.jp2k.output.file)J=F9();if(J)if(q.fn(Z))Z(J);else return Promise.reject(J);else{this.options.fileOut=$;let Q=Error();return this._pipeline(Z,Q)}return this}function eQ($,Z){if(q.object($))this._setBooleanOption("resolveWithObject",$.resolveWithObject);else if(this.options.resolveWithObject)this.options.resolveWithObject=!1;this.options.fileOut="";let J=Error();return this._pipeline(q.fn($)?$:Z,J)}function tQ(){return this.options.keepMetadata|=1,this}function $X($){if(q.object($))for(let[Z,J]of Object.entries($))if(q.object(J))for(let[Q,X]of Object.entries(J))if(q.string(X))this.options.withExif[`exif-${Z.toLowerCase()}-${Q}`]=X;else throw q.invalidParameterError(`${Z}.${Q}`,"string",X);else throw q.invalidParameterError(Z,"object",J);else throw q.invalidParameterError("exif","object",$);return this.options.withExifMerge=!1,this.keepExif()}function ZX($){return this.withExif($),this.options.withExifMerge=!0,this}function JX(){return this.options.keepMetadata|=8,this}function QX($,Z){if(q.string($))this.options.withIccProfile=$;else throw q.invalidParameterError("icc","string",$);if(this.keepIccProfile(),q.object(Z)){if(q.defined(Z.attach))if(q.bool(Z.attach)){if(!Z.attach)this.options.keepMetadata&=-9}else throw q.invalidParameterError("attach","boolean",Z.attach)}return this}function XX(){return this.options.keepMetadata|=2,this}function VX($){if(q.string($)&&$.length>0)this.options.withXmp=$,this.options.keepMetadata|=2;else throw q.invalidParameterError("xmp","non-empty string",$);return this}function KX(){return this.options.keepMetadata=31,this}function YX($){if(this.keepMetadata(),this.withIccProfile("srgb"),q.object($)){if(q.defined($.orientation))if(q.integer($.orientation)&&q.inRange($.orientation,1,8))this.options.withMetadataOrientation=$.orientation;else throw q.invalidParameterError("orientation","integer between 1 and 8",$.orientation);if(q.defined($.density))if(q.number($.density)&&$.density>0)this.options.withMetadataDensity=$.density;else throw q.invalidParameterError("density","positive number",$.density);if(q.defined($.icc))this.withIccProfile($.icc);if(q.defined($.exif))this.withExifMerge($.exif)}return this}function WX($,Z){let J=D9.get((q.object($)&&q.string($.id)?$.id:$).toLowerCase());if(!J)throw q.invalidParameterError("format",`one of: ${[...D9.keys()].join(", ")}`,$);return this[J](Z)}function HX($){if(q.object($)){if(q.defined($.quality))if(q.integer($.quality)&&q.inRange($.quality,1,100))this.options.jpegQuality=$.quality;else throw q.invalidParameterError("quality","integer between 1 and 100",$.quality);if(q.defined($.progressive))this._setBooleanOption("jpegProgressive",$.progressive);if(q.defined($.chromaSubsampling))if(q.string($.chromaSubsampling)&&q.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=$.chromaSubsampling;else throw q.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);let Z=q.bool($.optimizeCoding)?$.optimizeCoding:$.optimiseCoding;if(q.defined(Z))this._setBooleanOption("jpegOptimiseCoding",Z);if(q.defined($.mozjpeg))if(q.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 q.invalidParameterError("mozjpeg","boolean",$.mozjpeg);let J=q.bool($.trellisQuantization)?$.trellisQuantization:$.trellisQuantisation;if(q.defined(J))this._setBooleanOption("jpegTrellisQuantisation",J);if(q.defined($.overshootDeringing))this._setBooleanOption("jpegOvershootDeringing",$.overshootDeringing);let Q=q.bool($.optimizeScans)?$.optimizeScans:$.optimiseScans;if(q.defined(Q)){if(this._setBooleanOption("jpegOptimiseScans",Q),Q)this.options.jpegProgressive=!0}let X=q.number($.quantizationTable)?$.quantizationTable:$.quantisationTable;if(q.defined(X))if(q.integer(X)&&q.inRange(X,0,8))this.options.jpegQuantisationTable=X;else throw q.invalidParameterError("quantisationTable","integer between 0 and 8",X)}return this._updateFormatOut("jpeg",$)}function qX($){if(q.object($)){if(q.defined($.progressive))this._setBooleanOption("pngProgressive",$.progressive);if(q.defined($.compressionLevel))if(q.integer($.compressionLevel)&&q.inRange($.compressionLevel,0,9))this.options.pngCompressionLevel=$.compressionLevel;else throw q.invalidParameterError("compressionLevel","integer between 0 and 9",$.compressionLevel);if(q.defined($.adaptiveFiltering))this._setBooleanOption("pngAdaptiveFiltering",$.adaptiveFiltering);let Z=$.colours||$.colors;if(q.defined(Z))if(q.integer(Z)&&q.inRange(Z,2,256))this.options.pngBitdepth=M9(Z);else throw q.invalidParameterError("colours","integer between 2 and 256",Z);if(q.defined($.palette))this._setBooleanOption("pngPalette",$.palette);else if([$.quality,$.effort,$.colours,$.colors,$.dither].some(q.defined))this._setBooleanOption("pngPalette",!0);if(this.options.pngPalette){if(q.defined($.quality))if(q.integer($.quality)&&q.inRange($.quality,0,100))this.options.pngQuality=$.quality;else throw q.invalidParameterError("quality","integer between 0 and 100",$.quality);if(q.defined($.effort))if(q.integer($.effort)&&q.inRange($.effort,1,10))this.options.pngEffort=$.effort;else throw q.invalidParameterError("effort","integer between 1 and 10",$.effort);if(q.defined($.dither))if(q.number($.dither)&&q.inRange($.dither,0,1))this.options.pngDither=$.dither;else throw q.invalidParameterError("dither","number between 0.0 and 1.0",$.dither)}}return this._updateFormatOut("png",$)}function zX($){if(q.object($)){if(q.defined($.quality))if(q.integer($.quality)&&q.inRange($.quality,1,100))this.options.webpQuality=$.quality;else throw q.invalidParameterError("quality","integer between 1 and 100",$.quality);if(q.defined($.alphaQuality))if(q.integer($.alphaQuality)&&q.inRange($.alphaQuality,0,100))this.options.webpAlphaQuality=$.alphaQuality;else throw q.invalidParameterError("alphaQuality","integer between 0 and 100",$.alphaQuality);if(q.defined($.lossless))this._setBooleanOption("webpLossless",$.lossless);if(q.defined($.nearLossless))this._setBooleanOption("webpNearLossless",$.nearLossless);if(q.defined($.smartSubsample))this._setBooleanOption("webpSmartSubsample",$.smartSubsample);if(q.defined($.smartDeblock))this._setBooleanOption("webpSmartDeblock",$.smartDeblock);if(q.defined($.preset))if(q.string($.preset)&&q.inArray($.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=$.preset;else throw q.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",$.preset);if(q.defined($.effort))if(q.integer($.effort)&&q.inRange($.effort,0,6))this.options.webpEffort=$.effort;else throw q.invalidParameterError("effort","integer between 0 and 6",$.effort);if(q.defined($.minSize))this._setBooleanOption("webpMinSize",$.minSize);if(q.defined($.mixed))this._setBooleanOption("webpMixed",$.mixed)}return s2($,this.options),this._updateFormatOut("webp",$)}function GX($){if(q.object($)){if(q.defined($.reuse))this._setBooleanOption("gifReuse",$.reuse);if(q.defined($.progressive))this._setBooleanOption("gifProgressive",$.progressive);let Z=$.colours||$.colors;if(q.defined(Z))if(q.integer(Z)&&q.inRange(Z,2,256))this.options.gifBitdepth=M9(Z);else throw q.invalidParameterError("colours","integer between 2 and 256",Z);if(q.defined($.effort))if(q.number($.effort)&&q.inRange($.effort,1,10))this.options.gifEffort=$.effort;else throw q.invalidParameterError("effort","integer between 1 and 10",$.effort);if(q.defined($.dither))if(q.number($.dither)&&q.inRange($.dither,0,1))this.options.gifDither=$.dither;else throw q.invalidParameterError("dither","number between 0.0 and 1.0",$.dither);if(q.defined($.interFrameMaxError))if(q.number($.interFrameMaxError)&&q.inRange($.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=$.interFrameMaxError;else throw q.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",$.interFrameMaxError);if(q.defined($.interPaletteMaxError))if(q.number($.interPaletteMaxError)&&q.inRange($.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=$.interPaletteMaxError;else throw q.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",$.interPaletteMaxError);if(q.defined($.keepDuplicateFrames))if(q.bool($.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",$.keepDuplicateFrames);else throw q.invalidParameterError("keepDuplicateFrames","boolean",$.keepDuplicateFrames)}return s2($,this.options),this._updateFormatOut("gif",$)}function jX($){if(!this.constructor.format.jp2k.output.buffer)throw F9();if(q.object($)){if(q.defined($.quality))if(q.integer($.quality)&&q.inRange($.quality,1,100))this.options.jp2Quality=$.quality;else throw q.invalidParameterError("quality","integer between 1 and 100",$.quality);if(q.defined($.lossless))if(q.bool($.lossless))this.options.jp2Lossless=$.lossless;else throw q.invalidParameterError("lossless","boolean",$.lossless);if(q.defined($.tileWidth))if(q.integer($.tileWidth)&&q.inRange($.tileWidth,1,32768))this.options.jp2TileWidth=$.tileWidth;else throw q.invalidParameterError("tileWidth","integer between 1 and 32768",$.tileWidth);if(q.defined($.tileHeight))if(q.integer($.tileHeight)&&q.inRange($.tileHeight,1,32768))this.options.jp2TileHeight=$.tileHeight;else throw q.invalidParameterError("tileHeight","integer between 1 and 32768",$.tileHeight);if(q.defined($.chromaSubsampling))if(q.string($.chromaSubsampling)&&q.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=$.chromaSubsampling;else throw q.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling)}return this._updateFormatOut("jp2",$)}function s2($,Z){if(q.object($)&&q.defined($.loop))if(q.integer($.loop)&&q.inRange($.loop,0,65535))Z.loop=$.loop;else throw q.invalidParameterError("loop","integer between 0 and 65535",$.loop);if(q.object($)&&q.defined($.delay))if(q.integer($.delay)&&q.inRange($.delay,0,65535))Z.delay=[$.delay];else if(Array.isArray($.delay)&&$.delay.every(q.integer)&&$.delay.every((J)=>q.inRange(J,0,65535)))Z.delay=$.delay;else throw q.invalidParameterError("delay","integer or an array of integers between 0 and 65535",$.delay)}function UX($){if(q.object($)){if(q.defined($.quality))if(q.integer($.quality)&&q.inRange($.quality,1,100))this.options.tiffQuality=$.quality;else throw q.invalidParameterError("quality","integer between 1 and 100",$.quality);if(q.defined($.bitdepth))if(q.integer($.bitdepth)&&q.inArray($.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=$.bitdepth;else throw q.invalidParameterError("bitdepth","1, 2, 4 or 8",$.bitdepth);if(q.defined($.tile))this._setBooleanOption("tiffTile",$.tile);if(q.defined($.tileWidth))if(q.integer($.tileWidth)&&$.tileWidth>0)this.options.tiffTileWidth=$.tileWidth;else throw q.invalidParameterError("tileWidth","integer greater than zero",$.tileWidth);if(q.defined($.tileHeight))if(q.integer($.tileHeight)&&$.tileHeight>0)this.options.tiffTileHeight=$.tileHeight;else throw q.invalidParameterError("tileHeight","integer greater than zero",$.tileHeight);if(q.defined($.miniswhite))this._setBooleanOption("tiffMiniswhite",$.miniswhite);if(q.defined($.pyramid))this._setBooleanOption("tiffPyramid",$.pyramid);if(q.defined($.xres))if(q.number($.xres)&&$.xres>0)this.options.tiffXres=$.xres;else throw q.invalidParameterError("xres","number greater than zero",$.xres);if(q.defined($.yres))if(q.number($.yres)&&$.yres>0)this.options.tiffYres=$.yres;else throw q.invalidParameterError("yres","number greater than zero",$.yres);if(q.defined($.compression))if(q.string($.compression)&&q.inArray($.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=$.compression;else throw q.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",$.compression);if(q.defined($.bigtiff))this._setBooleanOption("tiffBigtiff",$.bigtiff);if(q.defined($.predictor))if(q.string($.predictor)&&q.inArray($.predictor,["none","horizontal","float"]))this.options.tiffPredictor=$.predictor;else throw q.invalidParameterError("predictor","one of: none, horizontal, float",$.predictor);if(q.defined($.resolutionUnit))if(q.string($.resolutionUnit)&&q.inArray($.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=$.resolutionUnit;else throw q.invalidParameterError("resolutionUnit","one of: inch, cm",$.resolutionUnit)}return this._updateFormatOut("tiff",$)}function AX($){return this.heif({...$,compression:"av1"})}function BX($){if(q.object($)){if(q.string($.compression)&&q.inArray($.compression,["av1","hevc"]))this.options.heifCompression=$.compression;else throw q.invalidParameterError("compression","one of: av1, hevc",$.compression);if(q.defined($.quality))if(q.integer($.quality)&&q.inRange($.quality,1,100))this.options.heifQuality=$.quality;else throw q.invalidParameterError("quality","integer between 1 and 100",$.quality);if(q.defined($.lossless))if(q.bool($.lossless))this.options.heifLossless=$.lossless;else throw q.invalidParameterError("lossless","boolean",$.lossless);if(q.defined($.effort))if(q.integer($.effort)&&q.inRange($.effort,0,9))this.options.heifEffort=$.effort;else throw q.invalidParameterError("effort","integer between 0 and 9",$.effort);if(q.defined($.chromaSubsampling))if(q.string($.chromaSubsampling)&&q.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=$.chromaSubsampling;else throw q.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);if(q.defined($.bitdepth))if(q.integer($.bitdepth)&&q.inArray($.bitdepth,[8,10,12])){if($.bitdepth!==8&&this.constructor.versions.heif)throw q.invalidParameterError("bitdepth when using prebuilt binaries",8,$.bitdepth);this.options.heifBitdepth=$.bitdepth}else throw q.invalidParameterError("bitdepth","8, 10 or 12",$.bitdepth)}else throw q.invalidParameterError("options","Object",$);return this._updateFormatOut("heif",$)}function LX($){if(q.object($)){if(q.defined($.quality))if(q.integer($.quality)&&q.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 q.invalidParameterError("quality","integer between 1 and 100",$.quality);else if(q.defined($.distance))if(q.number($.distance)&&q.inRange($.distance,0,15))this.options.jxlDistance=$.distance;else throw q.invalidParameterError("distance","number between 0.0 and 15.0",$.distance);if(q.defined($.decodingTier))if(q.integer($.decodingTier)&&q.inRange($.decodingTier,0,4))this.options.jxlDecodingTier=$.decodingTier;else throw q.invalidParameterError("decodingTier","integer between 0 and 4",$.decodingTier);if(q.defined($.lossless))if(q.bool($.lossless))this.options.jxlLossless=$.lossless;else throw q.invalidParameterError("lossless","boolean",$.lossless);if(q.defined($.effort))if(q.integer($.effort)&&q.inRange($.effort,1,9))this.options.jxlEffort=$.effort;else throw q.invalidParameterError("effort","integer between 1 and 9",$.effort)}return s2($,this.options),this._updateFormatOut("jxl",$)}function _X($){if(q.object($)){if(q.defined($.depth))if(q.string($.depth)&&q.inArray($.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=$.depth;else throw q.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",$.depth)}return this._updateFormatOut("raw")}function wX($){if(q.object($)){if(q.defined($.size))if(q.integer($.size)&&q.inRange($.size,1,8192))this.options.tileSize=$.size;else throw q.invalidParameterError("size","integer between 1 and 8192",$.size);if(q.defined($.overlap))if(q.integer($.overlap)&&q.inRange($.overlap,0,8192)){if($.overlap>this.options.tileSize)throw q.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,$.overlap);this.options.tileOverlap=$.overlap}else throw q.invalidParameterError("overlap","integer between 0 and 8192",$.overlap);if(q.defined($.container))if(q.string($.container)&&q.inArray($.container,["fs","zip"]))this.options.tileContainer=$.container;else throw q.invalidParameterError("container","one of: fs, zip",$.container);if(q.defined($.layout))if(q.string($.layout)&&q.inArray($.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=$.layout;else throw q.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",$.layout);if(q.defined($.angle))if(q.integer($.angle)&&!($.angle%90))this.options.tileAngle=$.angle;else throw q.invalidParameterError("angle","positive/negative multiple of 90",$.angle);if(this._setBackgroundColourOption("tileBackground",$.background),q.defined($.depth))if(q.string($.depth)&&q.inArray($.depth,["onepixel","onetile","one"]))this.options.tileDepth=$.depth;else throw q.invalidParameterError("depth","one of: onepixel, onetile, one",$.depth);if(q.defined($.skipBlanks))if(q.integer($.skipBlanks)&&q.inRange($.skipBlanks,-1,65535))this.options.tileSkipBlanks=$.skipBlanks;else throw q.invalidParameterError("skipBlanks","integer between -1 and 255/65535",$.skipBlanks);else if(q.defined($.layout)&&$.layout==="google")this.options.tileSkipBlanks=5;let Z=q.bool($.center)?$.center:$.centre;if(q.defined(Z))this._setBooleanOption("tileCentre",Z);if(q.defined($.id))if(q.string($.id))this.options.tileId=$.id;else throw q.invalidParameterError("id","string",$.id);if(q.defined($.basename))if(q.string($.basename))this.options.tileBasename=$.basename;else throw q.invalidParameterError("basename","string",$.basename)}if(q.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw q.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function RX($){if(!q.plainObject($))throw q.invalidParameterError("options","object",$);if(q.integer($.seconds)&&q.inRange($.seconds,0,3600))this.options.timeoutSeconds=$.seconds;else throw q.invalidParameterError("seconds","integer between 0 and 3600",$.seconds);return this}function CX($,Z){if(!(q.object(Z)&&Z.force===!1))this.options.formatOut=$;return this}function NX($,Z){if(q.bool(Z))this.options[$]=Z;else throw q.invalidParameterError($,"boolean",Z)}function PX(){if(!this.options.streamOut){this.options.streamOut=!0;let $=Error();this._pipeline(void 0,$)}}function DX($,Z){if(typeof $==="function"){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(J,Q,X)=>{if(J)$(q.nativeError(J,Z));else $(null,Q,X)})});else T4.pipeline(this.options,(J,Q,X)=>{if(J)$(q.nativeError(J,Z));else $(null,Q,X)});return this}else if(this.options.streamOut){if(this._isStreamInput()){if(this.once("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(J,Q,X)=>{if(J)this.emit("error",q.nativeError(J,Z));else this.emit("info",X),this.push(Q);this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished)this.emit("finish")}else T4.pipeline(this.options,(J,Q,X)=>{if(J)this.emit("error",q.nativeError(J,Z));else this.emit("info",X),this.push(Q);this.push(null),this.on("end",()=>this.emit("close"))});return this}else if(this._isStreamInput())return new Promise((J,Q)=>{this.once("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(X,V,K)=>{if(X)Q(q.nativeError(X,Z));else if(this.options.resolveWithObject)J({data:V,info:K});else J(V)})})});else return new Promise((J,Q)=>{T4.pipeline(this.options,(X,V,K)=>{if(X)Q(q.nativeError(X,Z));else if(this.options.resolveWithObject)J({data:V,info:K});else J(V)})})}I9.exports=($)=>{Object.assign($.prototype,{toFile:sQ,toBuffer:eQ,keepExif:tQ,withExif:$X,withExifMerge:ZX,keepIccProfile:JX,withIccProfile:QX,keepXmp:XX,withXmp:VX,keepMetadata:KX,withMetadata:YX,toFormat:WX,jpeg:HX,jp2:jX,png:qX,webp:zX,tiff:UX,avif:AX,heif:BX,jxl:LX,gif:GX,raw:_X,tile:wX,timeout:RX,_updateFormatOut:CX,_setBooleanOption:NX,_read:PX,_pipeline:DX})}});var k9=T((wW,x9)=>{/*!
37
- Copyright 2013 Lovell Fuller and others.
38
- SPDX-License-Identifier: Apache-2.0
39
- */var FX=v("events"),n6=O6(),B0=E0(),{runtimePlatformArch:MX}=u2(),X0=K6(),S9=MX(),e2=X0.libvipsVersion(),Z4=X0.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 IX={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},x4={vips:e2.semver};if(!e2.isGlobal)if(!e2.isWasm)try{x4=v(`@img/sharp-${S9}/versions`)}catch($){try{x4=v(`@img/sharp-libvips-${S9}/versions`)}catch(Z){}}else try{x4=(()=>{throw new Error("Cannot require module "+"@img/sharp-wasm32/versions");})()}catch($){}x4.sharp=h2().version;if(x4.heif&&Z4.heif)Z4.heif.input.fileSuffix=[".avif"],Z4.heif.output.alias=["avif"];function T9($){if(B0.bool($))if($)return X0.cache(50,20,100);else return X0.cache(0,0,0);else if(B0.object($))return X0.cache($.memory,$.files,$.items);else return X0.cache()}T9(!0);function EX($){return X0.concurrency(B0.integer($)?$:null)}if(n6.familySync()===n6.GLIBC&&!X0._isUsingJemalloc())X0.concurrency(1);else if(n6.familySync()===n6.MUSL&&X0.concurrency()===1024)X0.concurrency(v("os").availableParallelism());var SX=new FX.EventEmitter;function TX(){return X0.counters()}function xX($){return X0.simd(B0.bool($)?$:null)}function kX($){if(B0.object($))if(Array.isArray($.operation)&&$.operation.every(B0.string))X0.block($.operation,!0);else throw B0.invalidParameterError("operation","Array<string>",$.operation);else throw B0.invalidParameterError("options","object",$)}function vX($){if(B0.object($))if(Array.isArray($.operation)&&$.operation.every(B0.string))X0.block($.operation,!1);else throw B0.invalidParameterError("operation","Array<string>",$.operation);else throw B0.invalidParameterError("options","object",$)}x9.exports=($)=>{$.cache=T9,$.concurrency=EX,$.counters=TX,$.simd=xX,$.format=Z4,$.interpolators=IX,$.versions=x4,$.queue=SX,$.block=kX,$.unblock=vX}});var O9=T((CW,v9)=>{/*!
40
- Copyright 2013 Lovell Fuller and others.
41
- SPDX-License-Identifier: Apache-2.0
42
- */var p0=r$();o$()(p0);J9()(p0);X9()(p0);H9()(p0);C9()(p0);P9()(p0);E9()(p0);k9()(p0);v9.exports=p0});var q6={enabled:!0,ttl:"1h",cacheSystemPrompt:!0,cacheTools:!0,minTokensForCache:1024},o9={low:1024,medium:4096,high:16384,max:1e5},NV={enabled:!1,effort:"medium",interleaved:!0};function V5($,Z){if($.budgetTokens)return $.budgetTokens;let J=$.effort||"medium",Q=o9[J],X=$.modelMultiplier??(Z.includes("opus")?2:1);return Math.min(Q*X,1e5)}function K5($){return $.includes("claude-opus-4")||$.includes("claude-sonnet-4")||$.includes("claude-haiku-4")||$.includes("claude-4")}var PV={"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 e9($,Z,J,Q){let X=Z*Math.pow(2,$),V=X*Q*(Math.random()*2-1);return Math.min(X+V,J)}function t9($,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 J of Z)if($.message.includes(String(J)))return!0;return!1}function $7($){return new Promise((Z)=>setTimeout(Z,$))}async function Y5($,Z={}){let J={...s9,...Z},Q=null;for(let X=0;X<=J.maxRetries;X++)try{return await $()}catch(V){if(Q=V instanceof Error?V:Error(String(V)),X<J.maxRetries&&t9(Q,J.retryableStatusCodes)){let K=e9(X,J.baseDelayMs,J.maxDelayMs,J.jitterFactor);if(J.onRetry)J.onRetry(X+1,Q,K);else console.warn(`\x1B[33mRetry ${X+1}/${J.maxRetries} after ${K}ms: ${Q.message}\x1B[0m`);await $7(K)}else throw Q}throw Q||Error("Max retries exceeded")}var W5={"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 Z7($,Z){let J=W5[$]??W5["claude-sonnet-4-6"],Q=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,Y=Q/1e6*J.input,W=X/1e6*J.cache_read,H=V/1e6*J.cache_write,z=K/1e6*J.output,G=Y+W+H+z,L=(X+V)/1e6*(J.input-J.cache_read);return{costUSD:G,estimatedSavingsUSD:L}}function J7($,Z){if(!$||!Z.enabled||!Z.cacheSystemPrompt)return typeof $==="string"?$:void 0;if(Array.isArray($)){let J=[...$];if(J.length>0){let Q=J[J.length-1];if(Q&&Q.type==="text")J[J.length-1]={type:"text",text:Q.text,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return J}return[{type:"text",text:$,cache_control:{type:"ephemeral",ttl:Z.ttl}}]}function Q7($,Z){if(!Z.enabled)return $;let J=[];for(let Q=0;Q<$.length;Q++){let X=$[Q],V=[];for(let K=0;K<X.content.length;K++){let Y=X.content[K],W=K===X.content.length-1,H=Q===$.length-1;if(Y.type==="text"&&Y.text.length>=Z.minTokensForCache*4&&!Y.cache_control&&(W||H))V.push({...Y,cache_control:{type:"ephemeral",ttl:Z.ttl}});else V.push(Y)}J.push({...X,content:V})}if(J.length>0&&Z.enabled){let Q=J[J.length-1],X=Q.content[Q.content.length-1];if(X&&!("cache_control"in X))Q.content[Q.content.length-1]={...X,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return J}function X7($){let Z=$.cache_read_input_tokens??0,J=$.cache_creation_input_tokens??0,Q=Z+J,X=Z>0?1:0,V=J>0?1:0,K=X+V;return{cacheHits:X,cacheMisses:V,totalCacheReadTokens:Z,totalCacheWriteTokens:J,cacheHitRate:K>0?X/K:0,estimatedSavingsUSD:0}}async function H5($,Z){let{apiKey:J,model:Q="claude-sonnet-4-6",maxTokens:X=4096,tools:V,systemPrompt:K,cacheConfig:Y=q6,thinking:W,extendedThinking:H,onToken:z,onThinking:G,onRedactedThinking:A,onToolUse:L,signal:B}=Z,_=Date.now(),R=0,w=!0,D=0,I=Q7($,Y),S=J7(K,Y),M={model:Q,max_tokens:X,messages:I.map((f)=>({role:f.role,content:f.content})),stream:!0};if(S)M.system=S;if(V&&V.length>0)M.tools=V;let x=`${process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com"}/v1/messages`,c={"Content-Type":"application/json","x-api-key":J,"anthropic-version":"2023-06-01"};if(((H?.enabled??!1)||W&&W.type!=="disabled")&&K5(Q)){let f;if(H?.budgetTokens)f=H.budgetTokens;else if(W?.type==="enabled")f=W.budget_tokens;else{let n0=H?.effort||"medium";f=V5({enabled:!0,effort:n0,modelMultiplier:Q.includes("opus")?2:1},Q)}f=Math.max(1024,Math.min(f,1e5)),M.thinking={type:"enabled",budget_tokens:f};let D0=["extended-thinking-2025-01-24"];if(H?.interleaved!==!1)D0.push("interleaved-thinking-2025-01-24");c["anthropic-beta"]=D0.join(",")}else c["anthropic-beta"]="max-tokens-3-5-sonnet-2024-07-15";let e={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,retryableStatusCodes:[429,500,502,503,504,529],onRetry:(f,D0,n0)=>{console.log(`\x1B[33mAPI retry ${f}/3 after ${n0}ms: ${D0.message}\x1B[0m`)}},a0=await Y5(async()=>{let f=await fetch(x,{method:"POST",headers:c,body:JSON.stringify(M),signal:B});if(!f.ok&&e.retryableStatusCodes?.includes(f.status)){let D0=await f.text();throw Error(`API error: ${f.status} - ${D0}`)}return f},e);if(!a0.ok){let f=await a0.text();throw Error(`API error: ${a0.status} - ${f}`)}if(!a0.body)throw Error("No response body");let k4=a0.body.getReader(),W6=new TextDecoder,N0=null,y0=[],i={input_tokens:0,output_tokens:0},r0=null,L0=null,b0=null,K0=null,U4="",J5="";try{let f="";while(!0){let{done:D0,value:n0}=await k4.read();if(D0)break;f+=W6.decode(n0,{stream:!0});let y4=f.split(`
43
- `);f=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,i=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")K0={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 k=y.text;if(r0.text+=k,z?.(k),w)R=Date.now()-_,w=!1}else if(y.type==="thinking_delta"&&L0){let k=y.thinking;L0.thinking+=k,G?.(k),D+=Math.ceil(k.length/4)}else if(y.type==="redacted_thinking_delta"&&b0){let k=y.data;b0.data+=k,A?.(k),D+=Math.ceil(k.length/4)}else if(y.type==="input_json_delta"&&K0)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(K0!==null){try{K0.input=JSON.parse(U4)}catch{K0.input={}}y0.push(K0),L?.({id:K0.id,name:K0.name,input:K0.input}),K0=null,U4=""}break}case"message_delta":{let y=O;if(y.usage)i.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{k4.releaseLock()}if(!N0)throw Error("No message received from API");N0.content=y0;let{costUSD:f0,estimatedSavingsUSD:v4}=Z7(Q,i),P0=X7(i);P0.estimatedSavingsUSD=v4;let O4=Date.now()-_;return{message:N0,usage:i,cacheMetrics:P0,costUSD:f0,durationMs:O4,ttftMs:R||O4,thinkingTokens:D}}import*as q5 from"readline";var V7={Read:"low",Glob:"low",Grep:"low",Task:"low",Write:"medium",Edit:"medium",NotebookEdit:"medium",Bash:"high"},K7=[/\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 Y7($,Z){let J=V7[$]??"medium";if($==="Bash"){let Q=String(Z.command??"");for(let X of K7)if(X.test(Q))return"critical";if(/\bsudo\b/.test(Q)||/\bchmod\b/.test(Q))J="high"}if($==="Write"||$==="Edit"){let Q=String(Z.file_path??Z.path??"");if(/\.(env|pem|key|secret|credentials)/.test(Q))J="high";if(/\/\.ssh\//.test(Q)||/\/\.gnupg\//.test(Q))J="critical"}return J}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 s6{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 J=this.getCacheKey($,Z),Q=this.cache[J];if(Q&&Date.now()-Q.timestamp<this.cacheTimeout){if(Q.decision==="allowAlways")return{decision:"allow",reason:"Previously approved (always)"};if(Q.decision==="denyAlways")return{decision:"deny",reason:"Previously denied (always)"}}let X=Y7($,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 Y=await this.promptCallback(K);if(Y.decision==="allowAlways"||Y.decision==="denyAlways")this.cache[J]={decision:Y.decision,timestamp:Date.now()};return Y}return{decision:"allow"}}getCacheKey($,Z){if(["Read","Write","Edit"].includes($))return`${$}:${Z.file_path??Z.path??"unknown"}`;if($==="Bash"){let J=String(Z.command??"").slice(0,100);return`${$}:${J}`}return $}async defaultPrompt($){return new Promise((Z)=>{let J=q5.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";J.question(`Allow? ${K}: `,(Y)=>{switch(J.close(),Y.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 e6={readOnly:["Read","Glob","Grep","Task"],fileEdit:["Write","Edit","NotebookEdit"],system:["Bash"],network:[]};function xV($){return e6.readOnly.includes($)}function kV($){return e6.fileEdit.includes($)}function vV($){return e6.system.includes($)}var $2={tokenWarningThreshold:0.8,costUpdateInterval:5,toolSummaryInterval:3,envInfoOnStart:!0},t6={WARNING:0.8,CRITICAL:0.9,EMERGENCY:0.95};function H7($){let{current:Z,max:J,threshold:Q=t6.WARNING}=$;if(J<=0)return"";let X=Z/J;if(X<Q)return"";let V=J-Z,K=Math.round(X*100),Y,W;if(X>=t6.EMERGENCY)Y="emergency",W="\uD83D\uDEA8";else if(X>=t6.CRITICAL)Y="critical",W="\u26A0\uFE0F";else Y="warning",W="\u26A1";let H=[`${W} Token Usage ${Y.toUpperCase()}`,"",`Current: ${Z.toLocaleString()} / ${J.toLocaleString()} tokens (${K}%)`,`Remaining: ${V.toLocaleString()} tokens`];if(Y==="emergency")H.push(""),H.push("Consider summarizing or compacting the conversation to continue.");else if(Y==="critical")H.push(""),H.push("Approaching token limit. Consider wrapping up soon.");return H.join(`
44
- `)}function q7($){let{cost:Z,previousCost:J=0,currency:Q="USD"}=$,X=z7(Q),V=z5(Z,X),K=Z-J,Y=z5(Math.abs(K),X),W=["\uD83D\uDCB0 Cost Update","",`Total: ${V} ${Q}`];if(K!==0){let H=K>0?"+":"-";W.push(`This turn: ${H}${Y} ${Q}`)}return W.join(`
45
- `)}function z5($,Z){if($<0.01)return`${Z}${$.toFixed(4)}`;else if($<1)return`${Z}${$.toFixed(3)}`;return`${Z}${$.toFixed(2)}`}function z7($){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5"}[$]||$}function G7($){let{tools:Z,maxDisplay:J=10}=$;if(Z.length===0)return"No tools used this session.";let Q=new Map;for(let Y of Z){let W=Q.get(Y.name)||0;Q.set(Y.name,W+1)}let X=[...Q.entries()].sort((Y,W)=>W[1]-Y[1]),V=[`\uD83D\uDD27 Tool Usage Summary (${Z.length} total calls)`,""],K=X.slice(0,J);for(let[Y,W]of K)V.push(` \u2022 ${Y}: ${W} call${W===1?"":"s"}`);if(X.length>J){let Y=X.length-J;V.push(` ... and ${Y} more tool${Y===1?"":"s"}`)}return V.join(`
46
- `)}function j7($){let{workingDirectory:Z,gitStatus:J,platform:Q=process.platform,shell:X=process.env.SHELL||"unknown"}=$,V=["\uD83D\uDCCD Environment Information","",`Working Directory: ${Z}`,`Platform: ${Q}`,`Shell: ${X}`];if(J){if(V.push(""),V.push("Git Status:"),V.push(` Branch: ${J.branch}`),J.ahead>0||J.behind>0)V.push(` Ahead: ${J.ahead}, Behind: ${J.behind}`);let K=J.staged.length+J.unstaged.length+J.untracked.length+J.conflicted.length;if(K>0){if(V.push(` Changes: ${K} file${K===1?"":"s"}`),J.staged.length>0)V.push(` Staged: ${J.staged.length}`);if(J.unstaged.length>0)V.push(` Unstaged: ${J.unstaged.length}`);if(J.untracked.length>0)V.push(` Untracked: ${J.untracked.length}`);if(J.conflicted.length>0)V.push(` Conflicted: ${J.conflicted.length}`)}else V.push(" Working tree clean")}return V.join(`
47
- `)}function G5($){let{usage:Z,maxTokens:J,totalCost:Q,previousCost:X,toolsUsed:V,workingDirectory:K,gitStatus:Y,turnNumber:W,config:H}=$,z={...$2,...H},G=[],A=Z.input_tokens+Z.output_tokens,L=H7({current:A,max:J,threshold:z.tokenWarningThreshold});if(L)G.push(L);if(W%z.costUpdateInterval===0){let B=q7({cost:Q,previousCost:X});G.push(B)}if(W%z.toolSummaryInterval===0&&V.length>0){let B=G7({tools:V});G.push(B)}if(W===1&&z.envInfoOnStart){let B=j7({workingDirectory:K,gitStatus:Y});G.push(B)}if(G.length===0)return"";return["---","System Reminders:","",...G,"---"].join(`
48
- `)}function f4($){if(!$||$.length===0)return 0;return Math.ceil($.length/4)}function j5($){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((J,Q)=>J+j5(Q),0)+10;case"thinking":return f4($.thinking);default:return 0}}function U7($){return 4+$.content.reduce((Q,X)=>Q+j5(X),0)}function Z2($){if(!$||$.length===0)return 0;return $.reduce((Z,J)=>Z+U7(J),0)}function A7($){let Z=[];for(let J of $.content)switch(J.type){case"text":Z.push(J.text);break;case"tool_use":Z.push(`[Tool: ${J.name}(${JSON.stringify(J.input)})]`);break;case"tool_result":let Q=typeof J.content==="string"?J.content:J.content.map((X)=>X.type==="text"?X.text:"[content]").join("");Z.push(`[Result: ${Q.slice(0,500)}${Q.length>500?"...":""}]`);break;case"thinking":Z.push(`[Thinking: ${J.thinking.slice(0,200)}...]`);break}return Z.join(`
49
- `)}function B7($){let Z=new Map;for(let J of $)for(let Q of J.content)if(Q.type==="tool_use")Z.set(Q.id,{use:Q});for(let J of $)for(let Q of J.content)if(Q.type==="tool_result"){let X=Z.get(Q.tool_use_id);if(X)X.result=Q}return Z}async function L7($){if(!$||$.length===0)return"";let Z=[];Z.push(`[Context Summary: ${$.length} messages compacted]
50
- `);let J=[];for(let X=0;X<$.length;X++){let V=$[X];if(!V)continue;let K=V.role.toUpperCase(),Y=A7(V);for(let H of V.content)if(H.type==="tool_use")J.push(`${H.name}`);let W=Y.length>300?`${Y.slice(0,300)}...`:Y;Z.push(`${K}: ${W}
51
- `)}if(J.length>0){let X=J.reduce((K,Y)=>{return K[Y]=(K[Y]||0)+1,K},{}),V=Object.entries(X).map(([K,Y])=>`${K}(${Y})`).join(", ");Z.push(`
52
- Tools used: ${V}
53
- `)}let Q=Z.join("");if(Q.length>8000)Q=Q.slice(0,8000)+`
54
- ...[truncated]`;return Q}async function J2($,Z,J={}){let{keepFirst:Q=1,keepLast:X=5,preserveToolPairs:V=!0}=J,K=Z2($);if(K<=Z)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};if($.length<=Q+X)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};let Y=$.slice(0,Q),W=$.slice(Q,-X),H=$.slice(-X),G={role:"user",content:[{type:"text",text:`[Previous context has been compacted for continuity]
55
-
56
- ${await L7(W)}`}]},A=[];if(V&&W.length>0){let R=B7(W),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 L=[...Y,G];if(A.length>0)L.push({role:"assistant",content:A.filter((R)=>R.type==="tool_use")}),L.push({role:"user",content:A.filter((R)=>R.type==="tool_result")});L.push(...H);let B=Z2(L),_=$.length-L.length;return console.log(`Context compaction: ${$.length} -> ${L.length} messages, ${K} -> ${B} tokens`),{messages:L,messagesRemoved:_,tokensBefore:K,tokensAfter:B,didCompact:!0}}function U5($,Z,J=0.9){if($.length<8)return!1;let Q=Z2($),X=Math.floor(Z*J);return Q>=X}function Q2($){if(!$.didCompact)return{reductionPercent:0,tokensSaved:0};let Z=$.tokensBefore-$.tokensAfter,J=Z/$.tokensBefore*100;return{reductionPercent:Math.round(J*100)/100,tokensSaved:Z}}async function aV($,Z){let{apiKey:J,model:Q="claude-sonnet-4-6",maxTokens:X=4096,systemPrompt:V,tools:K,permissionMode:Y,workingDirectory:W,gitStatus:H=null,reminderConfig:z,cacheConfig:G=q6,thinking:A,extendedThinking:L,onText:B,onThinking:_,onToolUse:R,onToolResult:w,onMetrics:D,onReminder:I,onPermissionRequest:S,signal:M}=Z,g=new s6(Y,S),x=[...$],c=[],V0=[],e=0,a0=0,k4=0,W6=0,N0=0,y0=0,i={cacheHits:0,cacheMisses:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,cacheHitRate:0,estimatedSavingsUSD:0},r0={...$2,...z},L0=!0;while(L0){if(M?.aborted)break;k4++;let b0=c[c.length-1],K0=G5({usage:b0?.usage??{input_tokens:0,output_tokens:0},maxTokens:X,totalCost:e,previousCost:W6,toolsUsed:V0,workingDirectory:W,gitStatus:H,turnNumber:k4,config:r0});if(K0)I?.(K0);if(U5(x,X)){let O=await J2(x,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){x.length=0,x.push(...O.messages),N0++;let y=O.tokensBefore-O.tokensAfter;y0+=y;let k=Q2(O);console.log(`Context compacted: ${k.reductionPercent}% reduction, ${k.tokensSaved} tokens saved`)}}let U4=_7(x,V,K0),J5=await H5(U4,{apiKey:J,model:Q,maxTokens:X,systemPrompt:V,cacheConfig:G,thinking:A,extendedThinking:L,tools:K.map((O)=>({name:O.name,description:O.description,input_schema:O.input_schema})),onToken:B,onThinking:_,onToolUse:R,signal:M}),{message:f0,usage:v4,cacheMetrics:P0,costUSD:O4,durationMs:f,ttftMs:D0}=J5,n0={model:Q,messageCount:x.length,messageTokens:v4.input_tokens+v4.output_tokens,usage:v4,cacheMetrics:P0,durationMs:f,ttftMs:D0,costUSD:O4,stopReason:f0.stop_reason,requestId:f0.id};if(c.push(n0),W6=e,e+=O4,a0+=f,P0)i.cacheHits+=P0.cacheHits,i.cacheMisses+=P0.cacheMisses,i.totalCacheReadTokens+=P0.totalCacheReadTokens,i.totalCacheWriteTokens+=P0.totalCacheWriteTokens,i.estimatedSavingsUSD+=P0.estimatedSavingsUSD;let y4=i.cacheHits+i.cacheMisses;if(i.cacheHitRate=y4>0?i.cacheHits/y4:0,D?.(n0),x.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 J2(x,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){x.length=0,x.push(...O.messages),N0++;let y=O.tokensBefore-O.tokensAfter;y0+=y;let k=Q2(O);console.log(`Context compacted: ${k.reductionPercent}% reduction, ${k.tokensSaved} tokens saved`);continue}else{L0=!1;break}}let A4=f0.content.filter((O)=>O.type==="tool_use");if(V0.push(...A4),A4.length===0){L0=!1;break}let b4=[];if(M?.aborted);else{let O=A4.map(async(k)=>{let o6=K.find((h0)=>h0.name===k.name);if(!o6)return{toolUseId:k.id,result:{type:"tool_result",tool_use_id:k.id,content:`Error: Unknown tool "${k.name}"`,is_error:!0},toolResult:null};let H6=await g.checkPermission(o6.name,k.input);if(H6.decision==="deny"||H6.decision==="denyAlways")return{toolUseId:k.id,result:{type:"tool_result",tool_use_id:k.id,content:`Permission denied for tool "${k.name}"${H6.reason?`: ${H6.reason}`:""}`,is_error:!0},toolResult:null};try{let h0=await o6.handler(k.input,{workingDirectory:W,permissionMode:Y,abortSignal:M});return{toolUseId:k.id,result:{type:"tool_result",tool_use_id:k.id,content:h0.content,is_error:h0.is_error},toolResult:{id:k.id,result:h0}}}catch(h0){let p9=h0 instanceof Error?h0.message:String(h0);return{toolUseId:k.id,result:{type:"tool_result",tool_use_id:k.id,content:`Error: ${p9}`,is_error:!0},toolResult:null}}}),y=await Promise.all(O);for(let k of y)if(b4.push(k.result),k.toolResult)w?.(k.toolResult)}x.push({role:"user",content:b4})}return{messages:x,metrics:c,totalCost:e,totalDuration:a0,totalCacheMetrics:i,compactionCount:N0,totalTokensCompacted:y0}}function _7($,Z,J){if(J&&$.length>0){let Q=[...$];for(let X=Q.length-1;X>=0;X--){let V=Q[X];if(V&&V.role==="user"){let K={role:"user",content:Array.isArray(V.content)?w7(V.content,J):[{type:"text",text:`${String(V.content)}
57
-
58
- ${J}`}]};Q[X]=K;break}}return Q}return $}function w7($,Z){if($.length>0){let Q=$[$.length-1];if(Q&&Q.type==="text"){let X={type:"text",text:`${Q.text}
59
-
60
- ${Z}`};return[...$.slice(0,-1),X]}}let J={type:"text",text:`
61
-
62
- ${Z}`};return[...$,J]}function X2($){if($<0.01)return`$${$.toFixed(4)}`;return`$${$.toFixed(2)}`}function rV($){let Z=X2($.costUSD),J=`${$.usage.input_tokens.toLocaleString()} input, ${$.usage.output_tokens.toLocaleString()} output`;if($.usage.cache_read_input_tokens||$.usage.cache_creation_input_tokens){let Q=$.usage.cache_read_input_tokens?.toLocaleString()??"0",X=$.usage.cache_creation_input_tokens?.toLocaleString()??"0";return`Cost: ${Z} | Tokens: ${J} | Cache: ${Q} read, ${X} write`}return`Cost: ${Z} | Tokens: ${J}`}function nV($){let Z=X2($.costUSD),J=$.usage.input_tokens+$.usage.output_tokens;return`Cost: ${Z} | Tokens: ${J.toLocaleString()}`}function iV($){let Z=X2($.estimatedSavingsUSD);return`Cache: ${($.cacheHitRate*100).toFixed(1)}% hit rate | ${$.totalCacheReadTokens.toLocaleString()} read | ${$.totalCacheWriteTokens.toLocaleString()} written | Saved: ${Z}`}import{homedir as R7}from"os";import{join as g0}from"path";class C7{sessionsDir;currentSessionId=null;currentSessionFile=null;writeQueue=Promise.resolve();constructor($){this.sessionsDir=$??g0(R7(),".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 J={id:Z,created:Date.now(),updated:Date.now(),model:$.model,workingDirectory:$.workingDirectory,agentName:$.agentName,agentColor:$.agentColor,teamName:$.teamName};await this.appendEntry(J);let Q={type:"context",timestamp:Date.now(),workingDirectory:$.workingDirectory};return await this.appendEntry(Q),Z}async resumeSession($){let Z=g0(this.sessionsDir,`${$}.jsonl`);try{let J=await Bun.file(Z).text();if(!J)return null;let Q=J.trim().split(`
63
- `),X=[];for(let V of Q)try{X.push(JSON.parse(V))}catch{}return this.parseSessionEntries(X)}catch{return null}}parseSessionEntries($){let Z=null,J=[],Q=[],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 Y=K;switch(Y.type){case"message":J.push(Y.data);break;case"tool_use":Q.push(Y);break;case"metrics":X.push(Y.data);break;case"context":V=Y;break}}}if(!Z)Z={id:"unknown",created:Date.now(),updated:Date.now(),model:"claude-sonnet-4-6",workingDirectory:process.cwd()};return{metadata:Z,messages:J,tools:Q,metrics:X,context:V}}async appendEntry($){if(!this.currentSessionFile)return;this.writeQueue=this.writeQueue.then(async()=>{let Z=JSON.stringify($)+`
64
- `,J=Bun.file(this.currentSessionFile),Q=await J.exists()?await J.text():"";await Bun.write(this.currentSessionFile,Q+Z)}),await this.writeQueue}async saveMessage($){let Z={type:"message",timestamp:Date.now(),data:$};await this.appendEntry(Z),await this.updateTimestamp()}async saveToolUse($,Z,J,Q,X){let V={type:"tool_use",timestamp:Date.now(),toolId:$,toolName:Z,input:J,result:Q,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),J=[];try{let X=[...new Bun.Glob("*.jsonl").scanSync(this.sessionsDir)],V=await Promise.all(X.map(async(K)=>{let Y=g0(this.sessionsDir,K),W=await Bun.file(Y).stat();return{file:K,fullPath:Y,mtime:W?.mtime??new Date(0)}}));V.sort((K,Y)=>Y.mtime.getTime()-K.mtime.getTime());for(let{file:K,fullPath:Y}of V.slice(0,$)){let W=K.replace(".jsonl",""),H=await this.getSessionSummary(W,Y);if(H)J.push(H)}}catch{}return J}async getSessionSummary($,Z){let J=Z??g0(this.sessionsDir,`${$}.jsonl`);try{let Q=await Bun.file(J).text();if(!Q)return null;let X=Q.trim().split(`
65
- `),V=null,K=0,Y=0,W=0,H=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 L=A.data;if(!z&&L.role==="user"){let B=L.content.find((_)=>_.type==="text");if(B&&"text"in B){if(z=B.text.slice(0,100),B.text.length>100)z+="..."}}}else if(A.type==="metrics")Y+=A.data.costUSD,W+=A.data.usage.input_tokens,H+=A.data.usage.output_tokens}catch{}if(!V)return null;return{id:$,created:V.created,updated:V.updated,model:V.model,messageCount:K,totalCost:Y,totalTokens:{input:W,output:H},firstMessage:z,workingDirectory:V.workingDirectory}}catch{return null}}getCurrentSessionId(){return this.currentSessionId}async exportSession($,Z,J){let Q=await this.resumeSession($);if(!Q)throw Error(`Session not found: ${$}`);let X,V;switch(Z){case"jsonl":{let Y=g0(this.sessionsDir,`${$}.jsonl`);X=await Bun.file(Y).text(),V="jsonl";break}case"json":{X=JSON.stringify(Q,null,2),V="json";break}case"markdown":{X=this.sessionToMarkdown(Q),V="md";break}default:throw Error(`Unsupported format: ${Z}`)}let K=J??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 J of $.messages){let Q=J.role==="user"?"**User**":"**Claude**";Z.push(`### ${Q}`),Z.push("");for(let X of J.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 J=$.metrics.reduce((V,K)=>V+K.costUSD,0),Q=$.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:** $${J.toFixed(4)}`),Z.push(`- **Total Input Tokens:** ${Q.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:Q}=await import("fs/promises");return await Q(Z),!0}return!1}catch{return!1}}}function N7($){let Z=new Date($.created),J=new Date($.updated),Q=P7(J),X=[];X.push(`\x1B[1m${$.id}\x1B[0m (${Q})`),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 P7($){let J=new Date().getTime()-$.getTime(),Q=Math.floor(J/60000),X=Math.floor(J/3600000),V=Math.floor(J/86400000);if(Q<1)return"just now";if(Q<60)return`${Q}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return $.toLocaleDateString()}function tV($){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(N7(Z)),console.log("");console.log("To resume a session:"),console.log(" claude-remake --resume <session-id>")}import{dlopen as D7,suffix as F7}from"bun:ffi";import{join as X4,dirname as A5}from"path";import{fileURLToPath as B5}from"url";var Q4=null;function L5(){if(Q4)return Q4;let $=A5(B5(import.meta.url)),Z=[X4($,"..","..","native"),X4($,"..","native")],J=["index.darwin-arm64.node","index.darwin-x64.node","index.node"];for(let X of Z)for(let V of J){let K=X4(X,V);try{let Y=v(K);if(Y&&(Y.highlightCode||Y.highlight_code))return Q4={highlight_code:Y.highlightCode||Y.highlight_code,highlight_markdown:Y.highlightMarkdown||Y.highlight_markdown,highlight_diff:Y.highlightDiff||Y.highlight_diff,search_files:Y.searchFiles||Y.search_files,count_tokens:Y.countTokens||Y.count_tokens,calculate_diff:Y.calculateDiff||Y.calculate_diff,compact_content:Y.compactContent||Y.compact_content,count_tool_use:Y.countToolUse||Y.count_tool_use,find_tool_pairs:Y.findToolPairs||Y.find_tool_pairs,find_common_patterns:Y.findCommonPatterns||Y.find_common_patterns,validate_multi_edits:Y.validateMultiEdits||Y.validate_multi_edits,preview_multi_edits:Y.previewMultiEdits||Y.preview_multi_edits,apply_multi_edits:Y.applyMultiEdits||Y.apply_multi_edits},Q4}catch{continue}}let Q=Z.map((X)=>X4(X,`claude_code_native.${F7}`));for(let X of Q)try{return Q4=D7(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,Q4}catch{continue}return console.warn("Native module not available, using JS fallback"),_5()}function XK(){try{return L5(),Q4!==null}catch{return!1}}function _5(){return{highlight_code:($,Z)=>{let J=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"]),Q=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((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("#"))return`${X.comment}${Y}${X.reset}`;let W=Y.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*?\1/g,(H)=>{return`${X.string}${H}${X.default}`});return W=W.replace(/\b(\d+\.?\d*)\b/g,`${X.number}$1${X.default}`),W=W.replace(/\b([a-z]+)\b/gi,(H)=>{if(J.has(H))return`${X.keyword}${H}${X.default}`;if(Q.has(H))return`${X.type}${H}${X.default}`;return H}),W=W.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/g,(H,z)=>{return`${X.function}${z}${X.default}(`}),W}).join(`
71
- `)+X.reset,theme:"fallback"}},highlight_markdown:($)=>{return{html:$+"\x1B[0m",theme:"fallback"}},highlight_diff:($,Z,J)=>{let W=$.split(`
72
- `),H=Z.split(`
73
- `),z="",G=0,A=0,L=0;if(J?.file_path)z+=`\x1B[38;2;143;161;179m${J.file_path}\x1B[0m
74
- `;let B=[],_=Array.from({length:W.length+1},()=>Array.from({length:H.length+1},()=>0));for(let g=0;g<=W.length;g++)for(let x=0;x<=H.length;x++)if(g===0||x===0)_[g][x]=0;else if(W[g-1]===H[x-1])_[g][x]=_[g-1][x-1]+1;else _[g][x]=Math.max(_[g-1][x],_[g][x-1]);let R=W.length,w=H.length,D=new Set;while(R>0&&w>0)if(W[R-1]===H[w-1])D.add(`${R-1}:${w-1}`),B.unshift(W[R-1]),R--,w--;else if(_[R-1][w]>_[R][w-1])R--;else w--;let I=0,S=0,M=0;while(I<W.length||S<H.length){while(M<B.length&&I<W.length&&S<H.length&&W[I]===B[M]&&H[S]===B[M])I++,S++,M++;let g=I+1,x=S+1,c=0,V0=0,e=[];while(I<W.length&&(M>=B.length||W[I]!==B[M]))e.push(`\x1B[38;2;191;97;106m-${W[I]}\x1B[0m`),I++,c++,A++;while(S<H.length&&(M>=B.length||H[S]!==B[M]))e.push(`\x1B[38;2;163;190;140m+${H[S]}\x1B[0m`),S++,V0++,G++;if(c>0||V0>0)L++,z+=`\x1B[38;2;108;153;139m@@ -${g},${c} +${x},${V0} @@\x1B[0m
75
- `,z+=e.join(`
76
- `)+`
77
- `}return{output:z,additions:G,deletions:A,hunks:L}},search_files:($,Z,J)=>{return{matches:[],total_count:0,files_searched:0}},count_tokens:($)=>{return Math.ceil($.length/4)},calculate_diff:($,Z)=>{let J=$.split(`
78
- `),Q=Z.split(`
79
- `),X=[];if($!==Z)X.push({oldStart:1,oldLines:J.length,newStart:1,newLines:Q.length,content:`- ${J.join(`
80
- - `)}
81
- + ${Q.join(`
82
- + `)}`});return X},compact_content:($,Z,J="truncate")=>{let X=Z*4;if($.length<=X)return $;switch(J){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((W)=>W.trim().startsWith("#")||W.trim().startsWith("function")||W.trim().startsWith("const")||W.trim().startsWith("class")||W.trim().startsWith("export")||W.trim().startsWith("import")).slice(0,X/50).join(`
92
- `);default:return $.slice(0,X)}},validate_multi_edits:($)=>{let Z=[],J=new Map,Q=v("fs");for(let X of $)try{if(!Q.existsSync(X.filePath)){Z.push(`File not found: ${X.filePath}`);continue}if(!J.has(X.filePath)){let K=Q.readFileSync(X.filePath,"utf-8");J.set(X.filePath,K)}let V=J.get(X.filePath);if(!V.includes(X.oldString)){Z.push(`String not found in ${X.filePath}: "${M7(X.oldString,50)}"`);continue}if(!X.replaceAll){let K=(V.match(new RegExp(V2(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=[],J=new Map,Q=v("fs");for(let X of $)try{if(!Q.existsSync(X.filePath))continue;let V=Q.readFileSync(X.filePath,"utf-8"),K=X.replaceAll?(V.match(new RegExp(V2(X.oldString),"g"))||[]).length:1;J.set(X.filePath,(J.get(X.filePath)||0)+K)}catch{}for(let[X,V]of J)Z.push({filePath:X,replacementCount:V});return Z},apply_multi_edits:($)=>{let Z=_5().validate_multi_edits($);if(Z.length>0)return{success:!1,filesModified:[],totalReplacements:0,error:Z.join(`
93
- `),rolledBack:!1};let J=new Map,Q=new Set($.map((W)=>W.filePath)),X=v("fs");for(let W of Q)try{J.set(W,X.readFileSync(W,"utf-8"))}catch(H){return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to backup ${W}: ${H}`,rolledBack:!1}}let V=new Map;for(let[W,H]of J)V.set(W,H);let K=0;for(let W of $){let H=V.get(W.filePath);if(!H)continue;if(W.replaceAll){let z=(H.match(new RegExp(V2(W.oldString),"g"))||[]).length;V.set(W.filePath,H.split(W.oldString).join(W.newString)),K+=z}else V.set(W.filePath,H.replace(W.oldString,W.newString)),K+=1}let Y=[];for(let[W,H]of V){let z=J.get(W);if(H!==z)try{Bun.write(W,H),Y.push(W)}catch(G){for(let[A,L]of J)try{Bun.write(A,L)}catch{}return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to write ${W}: ${G}. All changes rolled back.`,rolledBack:!0}}}return{success:!0,filesModified:Y,totalReplacements:K,error:void 0,rolledBack:!1}},count_tool_use:($)=>{let Z={};for(let J of $)if(J.tool_use)for(let Q of J.tool_use)Z[Q.name]=(Z[Q.name]||0)+1;return Z},find_tool_pairs:($,Z)=>{let J={};for(let Q of $)if(Q.tool_use&&Q.tool_use.length>=2)for(let X=0;X<Q.tool_use.length-1;X++){let V=Q.tool_use[X]?.name,K=Q.tool_use[X+1]?.name;if(V&&K){if(!J[V])J[V]={};J[V][K]=(J[V][K]||0)+1}}return J},find_common_patterns:($)=>{let Z=[],J=new Map,Q=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,Y=X.tool_use[V+1]?.name;if(K&&Y){let W=`${K}|${Y}`;J.set(W,(J.get(W)||0)+1),Q++}}for(let[X,V]of J){let[K,Y]=X.split("|");Z.push({tools:[K,Y],count:V,percentage:Q>0?V/Q*100:0})}return Z.sort((X,V)=>V.count-X.count).slice(0,10)}}}var V4=L5();function VK($,Z){return V4.highlight_code($,Z)}function KK($){return V4.highlight_markdown($)}function YK($,Z,J){return V4.highlight_diff($,Z,J)}function WK($,Z){return V4.calculate_diff($,Z)}function K2($){return V4.validate_multi_edits($)}function w5($){return V4.preview_multi_edits($)}function R5($){return V4.apply_multi_edits($)}function M7($,Z){if($.length<=Z)return $;return $.slice(0,Z)+"..."}function V2($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var z6=null;function I7(){if(z6)return z6;let $=A5(B5(import.meta.url)),Z=process.platform==="darwin"?"libquant_rust.dylib":process.platform==="linux"?"libquant_rust.so":"quant_rust.dll",J=[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 Q of J)try{let{existsSync:X}=v("fs");if(!X(Q))continue;let{dlopen:V,FFIType:K,ptr:Y}=v("bun:ffi");return z6=V(Q,{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 G6=I7();function i0($){if(!$)throw Error(G6?.quant_last_error()||"Unknown quant error");return JSON.parse($)}function h4($){let{ptr:Z}=v("bun:ffi"),J=new Float64Array($);return{buffer:J,ptr:Z(J)}}function H0(){if(!G6)throw Error("Quant module not available - ensure @ebowwa/quant-rust is installed");return G6}function HK(){return H0().quant_version()}function qK(){return G6!==null}function zK($,Z,J,Q,X,V){let Y=H0().quant_ohlcv_new(BigInt($),Z,J,Q,X,V);return i0(Y)}function GK($,Z,J){let X=H0().quant_amm_new($,Z,J);return i0(X)}function jK($,Z,J,Q){let X=H0(),V=typeof J==="string"?J==="yes":J,K=X.quant_amm_calculate_cost($,Z,V,Q),Y=i0(K);return Math.abs(Y.cost)}function UK($,Z,J,Q){let X=H0(),V=typeof J==="string"?J==="yes":J,K=X.quant_amm_price_impact($,Z,V,Q);return i0(K)}function AK($,Z,J){let X=H0().quant_lmsr_price($,Z,J);return i0(X)}function BK($,Z,J,Q,X){let V=H0(),K=typeof Q==="string"?Q==="yes":Q,Y=V.quant_lmsr_cost($,Z,J,K,X);return i0(Y)}function LK($,Z){let Q=H0().quant_detect_arbitrage($,Z);return i0(Q)}var E7={probability:0,decimal:1,american:2};function _K($,Z){let Q=H0().quant_convert_odds($,E7[Z]??0);return i0(Q)}function wK($){if($.length===0)return NaN;let Z=H0(),{ptr:J}=h4($);return Z.quant_mean(J,$.length)}function RK($){if($.length===0)return NaN;let Z=H0(),{ptr:J}=h4($);return Z.quant_std_dev(J,$.length)}function CK($){if($.length===0)return NaN;let Z=H0(),{ptr:J}=h4($);return Z.quant_variance(J,$.length)}function NK($,Z){if($.length===0||Z.length===0||$.length!==Z.length)return NaN;let J=H0(),{ptr:Q}=h4($),{ptr:X}=h4(Z);return J.quant_correlation(Q,X,$.length)}var Y2=($,Z,J)=>{let Q=$ instanceof RegExp?C5($,J):$,X=Z instanceof RegExp?C5(Z,J):Z,V=Q!==null&&X!=null&&S7(Q,X,J);return V&&{start:V[0],end:V[1],pre:J.slice(0,V[0]),body:J.slice(V[0]+Q.length,V[1]),post:J.slice(V[1]+X.length)}},C5=($,Z)=>{let J=Z.match($);return J?J[0]:null},S7=($,Z,J)=>{let Q,X,V,K=void 0,Y,W=J.indexOf($),H=J.indexOf(Z,W+1),z=W;if(W>=0&&H>0){if($===Z)return[W,H];Q=[],V=J.length;while(z>=0&&!Y){if(z===W)Q.push(z),W=J.indexOf($,z+1);else if(Q.length===1){let G=Q.pop();if(G!==void 0)Y=[G,H]}else{if(X=Q.pop(),X!==void 0&&X<V)V=X,K=H;H=J.indexOf(Z,z+1)}z=W<H&&W>=0?W:H}if(Q.length&&K!==void 0)Y=[V,K]}return Y};var N5="\x00SLASH"+Math.random()+"\x00",P5="\x00OPEN"+Math.random()+"\x00",H2="\x00CLOSE"+Math.random()+"\x00",D5="\x00COMMA"+Math.random()+"\x00",F5="\x00PERIOD"+Math.random()+"\x00",T7=new RegExp(N5,"g"),x7=new RegExp(P5,"g"),k7=new RegExp(H2,"g"),v7=new RegExp(D5,"g"),O7=new RegExp(F5,"g"),y7=/\\\\/g,b7=/\\{/g,f7=/\\}/g,h7=/\\,/g,g7=/\\./g,u7=1e5;function W2($){return!isNaN($)?parseInt($,10):$.charCodeAt(0)}function d7($){return $.replace(y7,N5).replace(b7,P5).replace(f7,H2).replace(h7,D5).replace(g7,F5)}function m7($){return $.replace(T7,"\\").replace(x7,"{").replace(k7,"}").replace(v7,",").replace(O7,".")}function M5($){if(!$)return[""];let Z=[],J=Y2("{","}",$);if(!J)return $.split(",");let{pre:Q,body:X,post:V}=J,K=Q.split(",");K[K.length-1]+="{"+X+"}";let Y=M5(V);if(V.length)K[K.length-1]+=Y.shift(),K.push.apply(K,Y);return Z.push.apply(Z,K),Z}function I5($,Z={}){if(!$)return[];let{max:J=u7}=Z;if($.slice(0,2)==="{}")$="\\{\\}"+$.slice(2);return g4(d7($),J,!0).map(m7)}function c7($){return"{"+$+"}"}function l7($){return/^-?0\d/.test($)}function p7($,Z){return $<=Z}function a7($,Z){return $>=Z}function g4($,Z,J){let Q=[],X=Y2("{","}",$);if(!X)return[$];let V=X.pre,K=X.post.length?g4(X.post,Z,!1):[""];if(/\$$/.test(X.pre))for(let Y=0;Y<K.length&&Y<Z;Y++){let W=V+"{"+X.body+"}"+K[Y];Q.push(W)}else{let Y=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(X.body),W=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(X.body),H=Y||W,z=X.body.indexOf(",")>=0;if(!H&&!z){if(X.post.match(/,(?!,).*\}/))return $=X.pre+"{"+X.body+H2+X.post,g4($,Z,!0);return[$]}let G;if(H)G=X.body.split(/\.\./);else if(G=M5(X.body),G.length===1&&G[0]!==void 0){if(G=g4(G[0],Z,!1).map(c7),G.length===1)return K.map((L)=>X.pre+G[0]+L)}let A;if(H&&G[0]!==void 0&&G[1]!==void 0){let L=W2(G[0]),B=W2(G[1]),_=Math.max(G[0].length,G[1].length),R=G.length===3&&G[2]!==void 0?Math.abs(W2(G[2])):1,w=p7;if(B<L)R*=-1,w=a7;let I=G.some(l7);A=[];for(let S=L;w(S,B);S+=R){let M;if(W){if(M=String.fromCharCode(S),M==="\\")M=""}else if(M=String(S),I){let g=_-M.length;if(g>0){let x=Array(g+1).join("0");if(S<0)M="-"+x+M.slice(1);else M=x+M}}A.push(M)}}else{A=[];for(let L=0;L<G.length;L++)A.push.apply(A,g4(G[L],Z,!1))}for(let L=0;L<A.length;L++)for(let B=0;B<K.length&&Q.length<Z;B++){let _=V+A[L]+K[B];if(!J||H||_)Q.push(_)}}return Q}var u4=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var r7={"[: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]},d4=($)=>$.replace(/[[\]\\-]/g,"\\$&"),n7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),E5=($)=>$.join(""),S5=($,Z)=>{let J=Z;if($.charAt(J)!=="[")throw Error("not in a brace expression");let Q=[],X=[],V=J+1,K=!1,Y=!1,W=!1,H=!1,z=J,G="";$:while(V<$.length){let _=$.charAt(V);if((_==="!"||_==="^")&&V===J+1){H=!0,V++;continue}if(_==="]"&&K&&!W){z=V+1;break}if(K=!0,_==="\\"){if(!W){W=!0,V++;continue}}if(_==="["&&!W){for(let[R,[w,D,I]]of Object.entries(r7))if($.startsWith(R,V)){if(G)return["$.",!1,$.length-J,!0];if(V+=R.length,I)X.push(w);else Q.push(w);Y=Y||D;continue $}}if(W=!1,G){if(_>G)Q.push(d4(G)+"-"+d4(_));else if(_===G)Q.push(d4(_));G="",V++;continue}if($.startsWith("-]",V+1)){Q.push(d4(_+"-")),V+=2;continue}if($.startsWith("-",V+1)){G=_,V+=2;continue}Q.push(d4(_)),V++}if(z<V)return["",!1,0,!1];if(!Q.length&&!X.length)return["$.",!1,$.length-J,!0];if(X.length===0&&Q.length===1&&/^\\?.$/.test(Q[0])&&!H){let _=Q[0].length===2?Q[0].slice(-1):Q[0];return[n7(_),!1,z-J,!1]}let A="["+(H?"^":"")+E5(Q)+"]",L="["+(H?"":"^")+E5(X)+"]";return[Q.length&&X.length?"("+A+"|"+L+")":Q.length?A:L,Y,z-J,!0]};var _0=($,{windowsPathsNoEscape:Z=!1,magicalBraces:J=!0}={})=>{if(J)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 Y0,i7=new Set(["!","?","+","*","@"]),q2=($)=>i7.has($),T5=($)=>q2($.type),o7=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),s7=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),e7=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),x5=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),t7="(?!(?:^|/)\\.\\.?(?:$|/))",j6="(?!\\.)",$8=new Set(["[","."]),Z8=new Set(["..","."]),J8=new Set("().*{}+?[]^$\\!"),Q8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z2="[^/]",k5=z2+"*?",v5=z2+"+?",X8=0;class B4{type;#$;#Q;#X=!1;#Z=[];#K;#P;#_;#z=!1;#Y;#G;#q=!1;id=++X8;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,J={}){if(this.type=$,$)this.#Q=!0;if(this.#K=Z,this.#$=this.#K?this.#K.#$:this,this.#Y=this.#$===this?J:this.#$.#Y,this.#_=this.#$===this?[]:this.#$.#_,$==="!"&&!this.#$.#z)this.#_.push(this);this.#P=this.#K?this.#K.#Z.length:0}get hasMagic(){if(this.#Q!==void 0)return this.#Q;for(let $ of this.#Z){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#Q=!0}return this.#Q}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("|")+")"}#W(){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=$,J=Z.#K;while(J){for(let Q=Z.#P+1;!J.type&&Q<J.#Z.length;Q++)for(let X of $.#Z){if(typeof X==="string")throw Error("string part in extglob AST??");X.copyIn(J.#Z[Q])}Z=J,J=Z.#K}}return this}push(...$){for(let Z of $){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof Y0&&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 J=$.#Z[Z];if(!(J instanceof Y0&&J.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 Y0(this.type,$);for(let J of this.#Z)Z.copyIn(J);return Z}static#V($,Z,J,Q,X){let V=Q.maxExtglobRecursion??2,K=!1,Y=!1,W=-1,H=!1;if(Z.type===null){let B=J,_="";while(B<$.length){let R=$.charAt(B++);if(K||R==="\\"){K=!K,_+=R;continue}if(Y){if(B===W+1){if(R==="^"||R==="!")H=!0}else if(R==="]"&&!(B===W+2&&H))Y=!1;_+=R;continue}else if(R==="["){Y=!0,W=B,H=!1,_+=R;continue}if(!Q.noext&&q2(R)&&$.charAt(B)==="("&&X<=V){Z.push(_),_="";let D=new Y0(R,Z);B=Y0.#V($,D,B,Q,X+1),Z.push(D);continue}_+=R}return Z.push(_),B}let z=J+1,G=new Y0(null,Z),A=[],L="";while(z<$.length){let B=$.charAt(z++);if(K||B==="\\"){K=!K,L+=B;continue}if(Y){if(z===W+1){if(B==="^"||B==="!")H=!0}else if(B==="]"&&!(z===W+2&&H))Y=!1;L+=B;continue}else if(B==="["){Y=!0,W=z,H=!1,L+=B;continue}if(!Q.noext&&q2(B)&&$.charAt(z)==="("&&(X<=V||Z&&Z.#U(B))){let R=Z&&Z.#U(B)?0:1;G.push(L),L="";let w=new Y0(B,G);G.push(w),z=Y0.#V($,w,z,Q,X+R);continue}if(B==="|"){G.push(L),L="",A.push(G),G=new Y0(null,Z);continue}if(B===")"){if(L===""&&Z.#Z.length===0)Z.#q=!0;return G.push(L),L="",Z.push(...A,G),z}L+=B}return Z.type=null,Z.#Q=void 0,Z.#Z=[$.substring(J-1)],z}#w($){return this.#C($,s7)}#C($,Z=o7){if(!$||typeof $!=="object"||$.type!==null||$.#Z.length!==1||this.type===null)return!1;let J=$.#Z[0];if(!J||typeof J!=="object"||J.type===null)return!1;return this.#U(J.type,Z)}#U($,Z=e7){return!!Z.get(this.type)?.includes($)}#A($,Z){let J=$.#Z[0],Q=new Y0(null,J,this.options);Q.#Z.push(""),J.push(Q),this.#M($,Z)}#M($,Z){let J=$.#Z[0];this.#Z.splice(Z,1,...J.#Z);for(let Q of J.#Z)if(typeof Q==="object")Q.#K=this;this.#G=void 0}#B($){return!!x5.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=x5.get(this.type),J=$.#Z[0],Q=Z?.get(J.type);if(!Q)return!1;this.#Z=J.#Z;for(let X of this.#Z)if(typeof X==="object")X.#K=this;this.type=Q,this.#G=void 0,this.#q=!1}static fromGlob($,Z={}){let J=new Y0(null,void 0,Z);return Y0.#V($,J,0,Z,0),J}toMMPattern(){if(this!==this.#$)return this.#$.toMMPattern();let $=this.toString(),[Z,J,Q,X]=this.toRegExpSource();if(!(Q||this.#Q||this.#Y.nocase&&!this.#Y.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return J;let K=(this.#Y.nocase?"i":"")+(X?"u":"");return Object.assign(new RegExp(`^${Z}$`,K),{_src:Z,_glob:$})}get options(){return this.#Y}toRegExpSource($){let Z=$??!!this.#Y.dot;if(this.#$===this)this.#j(),this.#W();if(!T5(this)){let Y=this.isStart()&&this.isEnd()&&!this.#Z.some((A)=>typeof A!=="string"),W=this.#Z.map((A)=>{let[L,B,_,R]=typeof A==="string"?Y0.#R(A,this.#Q,Y):A.toRegExpSource($);return this.#Q=this.#Q||_,this.#X=this.#X||R,L}).join(""),H="";if(this.isStart()){if(typeof this.#Z[0]==="string"){if(!(this.#Z.length===1&&Z8.has(this.#Z[0]))){let L=$8,B=Z&&L.has(W.charAt(0))||W.startsWith("\\.")&&L.has(W.charAt(2))||W.startsWith("\\.\\.")&&L.has(W.charAt(4)),_=!Z&&!$&&L.has(W.charAt(0));H=B?t7:_?j6:""}}}let z="";if(this.isEnd()&&this.#$.#z&&this.#K?.type==="!")z="(?:$|\\/)";return[H+W+z,_0(W),this.#Q=!!this.#Q,this.#X]}let J=this.type==="*"||this.type==="+",Q=this.type==="!"?"(?:(?!(?:":"(?:",X=this.#L(Z);if(this.isStart()&&this.isEnd()&&!X&&this.type!=="!"){let Y=this.toString(),W=this;return W.#Z=[Y],W.type=null,W.#Q=void 0,[Y,_0(this.toString()),!1,!1]}let V=!J||$||Z||!j6?"":this.#L(!0);if(V===X)V="";if(V)X=`(?:${X})(?:${V})*?`;let K="";if(this.type==="!"&&this.#q)K=(this.isStart()&&!Z?j6:"")+v5;else{let Y=this.type==="!"?"))"+(this.isStart()&&!Z&&!$?j6:"")+k5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&V?")":this.type==="*"&&V?")?":`)${this.type}`;K=Q+X+Y}return[K,_0(X),this.#Q=!!this.#Q,this.#X]}#j(){if(!T5(this)){for(let $ of this.#Z)if(typeof $==="object")$.#j()}else{let $=0,Z=!1;do{Z=!0;for(let J=0;J<this.#Z.length;J++){let Q=this.#Z[J];if(typeof Q==="object"){if(Q.#j(),this.#C(Q))Z=!1,this.#M(Q,J);else if(this.#w(Q))Z=!1,this.#A(Q,J);else if(this.#N(Q))Z=!1,this.#D(Q)}}}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[J,Q,X,V]=Z.toRegExpSource($);return this.#X=this.#X||V,J}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#R($,Z,J=!1){let Q=!1,X="",V=!1,K=!1;for(let Y=0;Y<$.length;Y++){let W=$.charAt(Y);if(Q){Q=!1,X+=(J8.has(W)?"\\":"")+W;continue}if(W==="*"){if(K)continue;K=!0,X+=J&&/^[*]+$/.test($)?v5:k5,Z=!0;continue}else K=!1;if(W==="\\"){if(Y===$.length-1)X+="\\\\";else Q=!0;continue}if(W==="["){let[H,z,G,A]=S5($,Y);if(G){X+=H,V=V||z,Y+=G-1,Z=Z||A;continue}}if(W==="?"){X+=z2,Z=!0;continue}X+=Q8(W)}return[X,_0($),!!Z,V]}}Y0=B4;var L4=($,{windowsPathsNoEscape:Z=!1,magicalBraces:J=!1}={})=>{if(J)return Z?$.replace(/[?*()[\]{}]/g,"[$&]"):$.replace(/[?*()[\]\\{}]/g,"\\$&");return Z?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var t=($,Z,J={})=>{if(u4(Z),!J.nocomment&&Z.charAt(0)==="#")return!1;return new j0(Z,J).match($)},V8=/^\*+([^+@!?\*\[\(]*)$/,K8=($)=>(Z)=>!Z.startsWith(".")&&Z.endsWith($),Y8=($)=>(Z)=>Z.endsWith($),W8=($)=>{return $=$.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith($)},H8=($)=>{return $=$.toLowerCase(),(Z)=>Z.toLowerCase().endsWith($)},q8=/^\*+\.\*+$/,z8=($)=>!$.startsWith(".")&&$.includes("."),G8=($)=>$!=="."&&$!==".."&&$.includes("."),j8=/^\.\*+$/,U8=($)=>$!=="."&&$!==".."&&$.startsWith("."),A8=/^\*+$/,B8=($)=>$.length!==0&&!$.startsWith("."),L8=($)=>$.length!==0&&$!=="."&&$!=="..",_8=/^\?+([^+@!?\*\[\(]*)?$/,w8=([$,Z=""])=>{let J=b5([$]);if(!Z)return J;return Z=Z.toLowerCase(),(Q)=>J(Q)&&Q.toLowerCase().endsWith(Z)},R8=([$,Z=""])=>{let J=f5([$]);if(!Z)return J;return Z=Z.toLowerCase(),(Q)=>J(Q)&&Q.toLowerCase().endsWith(Z)},C8=([$,Z=""])=>{let J=f5([$]);return!Z?J:(Q)=>J(Q)&&Q.endsWith(Z)},N8=([$,Z=""])=>{let J=b5([$]);return!Z?J:(Q)=>J(Q)&&Q.endsWith(Z)},b5=([$])=>{let Z=$.length;return(J)=>J.length===Z&&!J.startsWith(".")},f5=([$])=>{let Z=$.length;return(J)=>J.length===Z&&J!=="."&&J!==".."},h5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",O5={win32:{sep:"\\"},posix:{sep:"/"}},P8=h5==="win32"?O5.win32.sep:O5.posix.sep;t.sep=P8;var d=Symbol("globstar **");t.GLOBSTAR=d;var D8="[^/]",F8=D8+"*?",M8="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",I8="(?:(?!(?:\\/|^)\\.).)*?",E8=($,Z={})=>(J)=>t(J,$,Z);t.filter=E8;var G0=($,Z={})=>Object.assign({},$,Z),S8=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return t;let Z=t;return Object.assign((Q,X,V={})=>Z(Q,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:(Q,X={})=>Z.unescape(Q,G0($,X)),escape:(Q,X={})=>Z.escape(Q,G0($,X)),filter:(Q,X={})=>Z.filter(Q,G0($,X)),defaults:(Q)=>Z.defaults(G0($,Q)),makeRe:(Q,X={})=>Z.makeRe(Q,G0($,X)),braceExpand:(Q,X={})=>Z.braceExpand(Q,G0($,X)),match:(Q,X,V={})=>Z.match(Q,X,G0($,V)),sep:Z.sep,GLOBSTAR:d})};t.defaults=S8;var g5=($,Z={})=>{if(u4($),Z.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return I5($,{max:Z.braceExpandMax})};t.braceExpand=g5;var T8=($,Z={})=>new j0($,Z).makeRe();t.makeRe=T8;var x8=($,Z,J={})=>{let Q=new j0(Z,J);if($=$.filter((X)=>Q.match(X)),Q.options.nonull&&!$.length)$.push(Z);return $};t.match=x8;var y5=/[?*]|[+@!]\(.*?\)|\[|\]/,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={}){u4($),Z=Z||{},this.options=Z,this.maxGlobstarRecursion=Z.maxGlobstarRecursion??200,this.pattern=$,this.platform=Z.platform||h5,this.isWindows=this.platform==="win32";let J="allowWindowsEscape";if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z[J]===!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 J=this.globSet.map((X)=>this.slashSplit(X));this.globParts=this.preprocess(J),this.debug(this.pattern,this.globParts);let Q=this.globParts.map((X,V,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let Y=X[0]===""&&X[1]===""&&(X[2]==="?"||!y5.test(X[2]))&&!y5.test(X[3]),W=/^[a-z]:/i.test(X[0]);if(Y)return[...X.slice(0,4),...X.slice(4).map((H)=>this.parse(H))];else if(W)return[X[0],...X.slice(1).map((H)=>this.parse(H))]}return X.map((Y)=>this.parse(Y))});if(this.debug(this.pattern,Q),this.set=Q.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 J=0;J<$.length;J++)for(let Q=0;Q<$[J].length;Q++)if($[J][Q]==="**")$[J][Q]="*"}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 J=-1;while((J=Z.indexOf("**",J+1))!==-1){let Q=J;while(Z[Q+1]==="**")Q++;if(Q!==J)Z.splice(J,Q-J)}return Z})}levelOneOptimize($){return $.map((Z)=>{return Z=Z.reduce((J,Q)=>{let X=J[J.length-1];if(Q==="**"&&X==="**")return J;if(Q===".."){if(X&&X!==".."&&X!=="."&&X!=="**")return J.pop(),J}return J.push(Q),J},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let Q=1;Q<$.length-1;Q++){let X=$[Q];if(Q===1&&X===""&&$[0]==="")continue;if(X==="."||X==="")Z=!0,$.splice(Q,1),Q--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Z=!0,$.pop()}let J=0;while((J=$.indexOf("..",J+1))!==-1){let Q=$[J-1];if(Q&&Q!=="."&&Q!==".."&&Q!=="**")Z=!0,$.splice(J-1,2),J-=2}}while(Z);return $.length===0?[""]:$}firstPhasePreProcess($){let Z=!1;do{Z=!1;for(let J of $){let Q=-1;while((Q=J.indexOf("**",Q+1))!==-1){let V=Q;while(J[V+1]==="**")V++;if(V>Q)J.splice(Q+1,V-Q);let K=J[Q+1],Y=J[Q+2],W=J[Q+3];if(K!=="..")continue;if(!Y||Y==="."||Y===".."||!W||W==="."||W==="..")continue;Z=!0,J.splice(Q,1);let H=J.slice(0);H[Q]="**",$.push(H),Q--}if(!this.preserveMultipleSlashes){for(let V=1;V<J.length-1;V++){let K=J[V];if(V===1&&K===""&&J[0]==="")continue;if(K==="."||K==="")Z=!0,J.splice(V,1),V--}if(J[0]==="."&&J.length===2&&(J[1]==="."||J[1]===""))Z=!0,J.pop()}let X=0;while((X=J.indexOf("..",X+1))!==-1){let V=J[X-1];if(V&&V!=="."&&V!==".."&&V!=="**"){Z=!0;let Y=X===1&&J[X+1]==="**"?["."]:[];if(J.splice(X-1,2,...Y),J.length===0)J.push("");X-=2}}}}while(Z);return $}secondPhasePreProcess($){for(let Z=0;Z<$.length-1;Z++)for(let J=Z+1;J<$.length;J++){let Q=this.partsMatch($[Z],$[J],!this.preserveMultipleSlashes);if(Q){$[Z]=[],$[J]=Q;break}}return $.filter((Z)=>Z.length)}partsMatch($,Z,J=!1){let Q=0,X=0,V=[],K="";while(Q<$.length&&X<Z.length)if($[Q]===Z[X])V.push(K==="b"?Z[X]:$[Q]),Q++,X++;else if(J&&$[Q]==="**"&&Z[X]===$[Q+1])V.push($[Q]),Q++;else if(J&&Z[X]==="**"&&$[Q]===Z[X+1])V.push(Z[X]),X++;else if($[Q]==="*"&&Z[X]&&(this.options.dot||!Z[X].startsWith("."))&&Z[X]!=="**"){if(K==="b")return!1;K="a",V.push($[Q]),Q++,X++}else if(Z[X]==="*"&&$[Q]&&(this.options.dot||!$[Q].startsWith("."))&&$[Q]!=="**"){if(K==="a")return!1;K="b",V.push(Z[X]),Q++,X++}else return!1;return $.length===Z.length&&V}parseNegate(){if(this.nonegate)return;let $=this.pattern,Z=!1,J=0;for(let Q=0;Q<$.length&&$.charAt(Q)==="!";Q++)Z=!Z,J++;if(J)this.pattern=$.slice(J);this.negate=Z}matchOne($,Z,J=!1){let Q=0,X=0;if(this.isWindows){let K=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),Y=!K&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),W=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),H=!W&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),z=Y?3:K?0:void 0,G=H?3:W?0:void 0;if(typeof z==="number"&&typeof G==="number"){let[A,L]=[$[z],Z[G]];if(A.toLowerCase()===L.toLowerCase())Z[G]=A,X=G,Q=z}}let{optimizationLevel:V=1}=this.options;if(V>=2)$=this.levelTwoFileOptimize($);if(Z.includes(d))return this.#$($,Z,J,Q,X);return this.#X($,Z,J,Q,X)}#$($,Z,J,Q,X){let V=Z.indexOf(d,X),K=Z.lastIndexOf(d),[Y,W,H]=J?[Z.slice(X,V),Z.slice(V+1),[]]:[Z.slice(X,V),Z.slice(V+1,K),Z.slice(K+1)];if(Y.length){let w=$.slice(Q,Q+Y.length);if(!this.#X(w,Y,J,0,0))return!1;Q+=Y.length,X+=Y.length}let z=0;if(H.length){if(H.length+Q>$.length)return!1;let w=$.length-H.length;if(this.#X($,H,J,w,0))z=H.length;else{if($[$.length-1]!==""||Q+H.length===$.length)return!1;if(w--,!this.#X($,H,J,w,0))return!1;z=H.length+1}}if(!W.length){let w=!!z;for(let D=Q;D<$.length-z;D++){let I=String($[D]);if(w=!0,I==="."||I===".."||!this.options.dot&&I.startsWith("."))return!1}return J||w}let G=[[[],0]],A=G[0],L=0,B=[0];for(let w of W)if(w===d)B.push(L),A=[[],0],G.push(A);else A[0].push(w),L++;let _=G.length-1,R=$.length-z;for(let w of G)w[1]=R-(B[_--]+w[0].length);return!!this.#Q($,G,Q,0,J,0,!!z)}#Q($,Z,J,Q,X,V,K){let Y=Z[Q];if(!Y){for(let z=J;z<$.length;z++){K=!0;let G=$[z];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1}return K}let[W,H]=Y;while(J<=H){if(this.#X($.slice(0,J+W.length),W,X,J,0)&&V<this.maxGlobstarRecursion){let A=this.#Q($,Z,J+W.length,Q+1,X,V+1,K);if(A!==!1)return A}let G=$[J];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1;J++}return X||null}#X($,Z,J,Q,X){let V,K,Y,W;for(V=Q,K=X,W=$.length,Y=Z.length;V<W&&K<Y;V++,K++){this.debug("matchOne loop");let H=Z[K],z=$[V];if(this.debug(Z,H,z),H===!1||H===d)return!1;let G;if(typeof H==="string")G=z===H,this.debug("string match",H,z,G);else G=H.test(z),this.debug("pattern match",H,z,G);if(!G)return!1}if(V===W&&K===Y)return!0;else if(V===W)return J;else if(K===Y)return V===W-1&&$[V]==="";else throw Error("wtf?")}braceExpand(){return g5(this.pattern,this.options)}parse($){u4($);let Z=this.options;if($==="**")return d;if($==="")return"";let J,Q=null;if(J=$.match(A8))Q=Z.dot?L8:B8;else if(J=$.match(V8))Q=(Z.nocase?Z.dot?H8:W8:Z.dot?Y8:K8)(J[1]);else if(J=$.match(_8))Q=(Z.nocase?Z.dot?R8:w8:Z.dot?C8:N8)(J);else if(J=$.match(q8))Q=Z.dot?G8:z8;else if(J=$.match(j8))Q=U8;let X=B4.fromGlob($,this.options).toMMPattern();if(Q&&typeof X==="object")Reflect.defineProperty(X,"test",{value:Q});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,J=Z.noglobstar?F8:Z.dot?M8:I8,Q=new Set(Z.nocase?["i"]:[]),X=$.map((Y)=>{let W=Y.map((z)=>{if(z instanceof RegExp)for(let G of z.flags.split(""))Q.add(G);return typeof z==="string"?k8(z):z===d?d:z._src});W.forEach((z,G)=>{let A=W[G+1],L=W[G-1];if(z!==d||L===d)return;if(L===void 0)if(A!==void 0&&A!==d)W[G+1]="(?:\\/|"+J+"\\/)?"+A;else W[G]=J;else if(A===void 0)W[G-1]=L+"(?:\\/|\\/"+J+")?";else if(A!==d)W[G-1]=L+"(?:\\/|\\/"+J+"\\/)"+A,W[G+1]=d});let H=W.filter((z)=>z!==d);if(this.partial&&H.length>=1){let z=[];for(let G=1;G<=H.length;G++)z.push(H.slice(0,G).join("/"));return"(?:"+z.join("|")+")"}return H.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,[...Q].join(""))}catch(Y){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 J=this.options;if(this.isWindows)$=$.split("\\").join("/");let Q=this.slashSplit($);this.debug(this.pattern,"split",Q);let X=this.set;this.debug(this.pattern,"set",X);let V=Q[Q.length-1];if(!V)for(let K=Q.length-2;!V&&K>=0;K--)V=Q[K];for(let K=0;K<X.length;K++){let Y=X[K],W=Q;if(J.matchBase&&Y.length===1)W=[V];if(this.matchOne(W,Y,Z)){if(J.flipNegate)return!0;return!this.negate}}if(J.flipNegate)return!1;return this.negate}static defaults($){return t.defaults($).Minimatch}}t.AST=B4;t.Minimatch=j0;t.escape=L4;t.unescape=_0;import{fileURLToPath as GZ}from"url";var v8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,d5=new Set,G2=typeof process=="object"&&process?process:{},m5=($,Z,J,Q)=>{typeof G2.emitWarning=="function"?G2.emitWarning($,Z,J,Q):console.error(`[${J}] ${Z}: ${$}`)},A6=globalThis.AbortController,u5=globalThis.AbortSignal;if(typeof A6>"u"){u5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(J,Q){this._onabort.push(Q)}},A6=class{constructor(){Z()}signal=new u5;abort(J){if(!this.signal.aborted){this.signal.reason=J,this.signal.aborted=!0;for(let Q of this.signal._onabort)Q(J);this.signal.onabort?.(J)}}};let $=G2.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{$&&($=!1,m5("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 O8=($)=>!d5.has($),lK=Symbol("type"),o0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),c5=($)=>o0($)?$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?U6:null:null,U6=class extends Array{constructor($){super($),this.fill(0)}},y8=class ${heap;length;static#$=!1;static create(Z){let J=c5(Z);if(!J)return[];$.#$=!0;let Q=new $(Z,J);return $.#$=!1,Q}constructor(Z,J){if(!$.#$)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}},m4=class ${#$;#Q;#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;#Y;#G;#q;#W;#V;#w;#C;#U;#A;#M;#B;#N;#D;#j;#L;#R;#I;#J;#O;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#j,autopurgeTimers:Z.#L,sizes:Z.#N,keyMap:Z.#q,keyList:Z.#W,valList:Z.#V,next:Z.#w,prev:Z.#C,get head(){return Z.#U},get tail(){return Z.#A},free:Z.#M,isBackgroundFetch:(J)=>Z.#H(J),backgroundFetch:(J,Q,X,V)=>Z.#m(J,Q,X,V),moveToTail:(J)=>Z.#b(J),indexes:(J)=>Z.#T(J),rindexes:(J)=>Z.#x(J),isStale:(J)=>Z.#F(J)}}get max(){return this.#$}get maxSize(){return this.#Q}get calculatedSize(){return this.#G}get size(){return this.#Y}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:J=0,ttl:Q,ttlResolution:X=1,ttlAutopurge:V,updateAgeOnGet:K,updateAgeOnHas:Y,allowStale:W,dispose:H,onInsert:z,disposeAfter:G,noDisposeOnSet:A,noUpdateTTL:L,maxSize:B=0,maxEntrySize:_=0,sizeCalculation:R,fetchMethod:w,memoMethod:D,noDeleteOnFetchRejection:I,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:g,ignoreFetchAbort:x,perf:c}=Z;if(c!==void 0&&typeof c?.now!="function")throw TypeError("perf option must have a now() method if specified");if(this.#z=c??v8,J!==0&&!o0(J))throw TypeError("max option must be a nonnegative integer");let V0=J?c5(J):Array;if(!V0)throw Error("invalid max value: "+J);if(this.#$=J,this.#Q=B,this.maxEntrySize=_||this.#Q,this.sizeCalculation=R,this.sizeCalculation){if(!this.#Q&&!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.#q=new Map,this.#W=Array(J).fill(void 0),this.#V=Array(J).fill(void 0),this.#w=new V0(J),this.#C=new V0(J),this.#U=0,this.#A=0,this.#M=y8.create(J),this.#Y=0,this.#G=0,typeof H=="function"&&(this.#X=H),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.#J=!!this.#K,this.noDisposeOnSet=!!A,this.noUpdateTTL=!!L,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!g,this.ignoreFetchAbort=!!x,this.maxEntrySize!==0){if(this.#Q!==0&&!o0(this.#Q))throw TypeError("maxSize must be a positive integer if specified");if(!o0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#l()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!K,this.updateAgeOnHas=!!Y,this.ttlResolution=o0(X)||X===0?X:1,this.ttlAutopurge=!!V,this.ttl=Q||0,this.ttl){if(!o0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#$===0&&this.ttl===0&&this.#Q===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#$&&!this.#Q){let e="LRU_CACHE_UNBOUNDED";O8(e)&&(d5.add(e),m5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,$))}}getRemainingTTL(Z){return this.#q.has(Z)?1/0:0}#k(){let Z=new U6(this.#$),J=new U6(this.#$);this.#j=Z,this.#D=J;let Q=this.ttlAutopurge?Array(this.#$):void 0;this.#L=Q,this.#h=(K,Y,W=this.#z.now())=>{if(J[K]=Y!==0?W:0,Z[K]=Y,Q?.[K]&&(clearTimeout(Q[K]),Q[K]=void 0),Y!==0&&Q){let H=setTimeout(()=>{this.#F(K)&&this.#S(this.#W[K],"expire")},Y+1);H.unref&&H.unref(),Q[K]=H}},this.#E=(K)=>{J[K]=Z[K]!==0?this.#z.now():0},this.#v=(K,Y)=>{if(Z[Y]){let W=Z[Y],H=J[Y];if(!W||!H)return;K.ttl=W,K.start=H,K.now=X||V();let z=K.now-H;K.remainingTTL=W-z}};let X=0,V=()=>{let K=this.#z.now();if(this.ttlResolution>0){X=K;let Y=setTimeout(()=>X=0,this.ttlResolution);Y.unref&&Y.unref()}return K};this.getRemainingTTL=(K)=>{let Y=this.#q.get(K);if(Y===void 0)return 0;let W=Z[Y],H=J[Y];if(!W||!H)return 1/0;let z=(X||V())-H;return W-z},this.#F=(K)=>{let Y=J[K],W=Z[K];return!!W&&!!Y&&(X||V())-Y>W}}#E=()=>{};#v=()=>{};#h=()=>{};#F=()=>!1;#l(){let Z=new U6(this.#$);this.#G=0,this.#N=Z,this.#f=(J)=>{this.#G-=Z[J],Z[J]=0},this.#g=(J,Q,X,V)=>{if(this.#H(Q))return 0;if(!o0(X))if(V){if(typeof V!="function")throw TypeError("sizeCalculation must be a function");if(X=V(Q,J),!o0(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=(J,Q,X)=>{if(Z[J]=Q,this.#Q){let V=this.#Q-Z[J];for(;this.#G>V;)this.#d(!0)}this.#G+=Z[J],X&&(X.entrySize=Q,X.totalCalculatedSize=this.#G)}}#f=(Z)=>{};#y=(Z,J,Q)=>{};#g=(Z,J,Q,X)=>{if(Q||X)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#Y)for(let J=this.#A;!(!this.#u(J)||((Z||!this.#F(J))&&(yield J),J===this.#U));)J=this.#C[J]}*#x({allowStale:Z=this.allowStale}={}){if(this.#Y)for(let J=this.#U;!(!this.#u(J)||((Z||!this.#F(J))&&(yield J),J===this.#A));)J=this.#w[J]}#u(Z){return Z!==void 0&&this.#q.get(this.#W[Z])===Z}*entries(){for(let Z of this.#T())this.#V[Z]!==void 0&&this.#W[Z]!==void 0&&!this.#H(this.#V[Z])&&(yield[this.#W[Z],this.#V[Z]])}*rentries(){for(let Z of this.#x())this.#V[Z]!==void 0&&this.#W[Z]!==void 0&&!this.#H(this.#V[Z])&&(yield[this.#W[Z],this.#V[Z]])}*keys(){for(let Z of this.#T()){let J=this.#W[Z];J!==void 0&&!this.#H(this.#V[Z])&&(yield J)}}*rkeys(){for(let Z of this.#x()){let J=this.#W[Z];J!==void 0&&!this.#H(this.#V[Z])&&(yield J)}}*values(){for(let Z of this.#T())this.#V[Z]!==void 0&&!this.#H(this.#V[Z])&&(yield this.#V[Z])}*rvalues(){for(let Z of this.#x())this.#V[Z]!==void 0&&!this.#H(this.#V[Z])&&(yield this.#V[Z])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let Q of this.#T()){let X=this.#V[Q],V=this.#H(X)?X.__staleWhileFetching:X;if(V!==void 0&&Z(V,this.#W[Q],this))return this.get(this.#W[Q],J)}}forEach(Z,J=this){for(let Q of this.#T()){let X=this.#V[Q],V=this.#H(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(J,V,this.#W[Q],this)}}rforEach(Z,J=this){for(let Q of this.#x()){let X=this.#V[Q],V=this.#H(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(J,V,this.#W[Q],this)}}purgeStale(){let Z=!1;for(let J of this.#x({allowStale:!0}))this.#F(J)&&(this.#S(this.#W[J],"expire"),Z=!0);return Z}info(Z){let J=this.#q.get(Z);if(J===void 0)return;let Q=this.#V[J],X=this.#H(Q)?Q.__staleWhileFetching:Q;if(X===void 0)return;let V={value:X};if(this.#j&&this.#D){let K=this.#j[J],Y=this.#D[J];if(K&&Y){let W=K-(this.#z.now()-Y);V.ttl=W,V.start=Date.now()}}return this.#N&&(V.size=this.#N[J]),V}dump(){let Z=[];for(let J of this.#T({allowStale:!0})){let Q=this.#W[J],X=this.#V[J],V=this.#H(X)?X.__staleWhileFetching:X;if(V===void 0||Q===void 0)continue;let K={value:V};if(this.#j&&this.#D){K.ttl=this.#j[J];let Y=this.#z.now()-this.#D[J];K.start=Math.floor(Date.now()-Y)}this.#N&&(K.size=this.#N[J]),Z.unshift([Q,K])}return Z}load(Z){this.clear();for(let[J,Q]of Z){if(Q.start){let X=Date.now()-Q.start;Q.start=this.#z.now()-X}this.set(J,Q.value,Q)}}set(Z,J,Q={}){if(J===void 0)return this.delete(Z),this;let{ttl:X=this.ttl,start:V,noDisposeOnSet:K=this.noDisposeOnSet,sizeCalculation:Y=this.sizeCalculation,status:W}=Q,{noUpdateTTL:H=this.noUpdateTTL}=Q,z=this.#g(Z,J,Q.size||0,Y);if(this.maxEntrySize&&z>this.maxEntrySize)return W&&(W.set="miss",W.maxEntrySizeExceeded=!0),this.#S(Z,"set"),this;let G=this.#Y===0?void 0:this.#q.get(Z);if(G===void 0)G=this.#Y===0?this.#A:this.#M.length!==0?this.#M.pop():this.#Y===this.#$?this.#d(!1):this.#Y,this.#W[G]=Z,this.#V[G]=J,this.#q.set(Z,G),this.#w[this.#A]=G,this.#C[G]=this.#A,this.#A=G,this.#Y++,this.#y(G,z,W),W&&(W.set="add"),H=!1,this.#O&&this.#Z?.(J,Z,"add");else{this.#b(G);let A=this.#V[G];if(J!==A){if(this.#I&&this.#H(A)){A.__abortController.abort(Error("replaced"));let{__staleWhileFetching:L}=A;L!==void 0&&!K&&(this.#R&&this.#X?.(L,Z,"set"),this.#J&&this.#B?.push([L,Z,"set"]))}else K||(this.#R&&this.#X?.(A,Z,"set"),this.#J&&this.#B?.push([A,Z,"set"]));if(this.#f(G),this.#y(G,z,W),this.#V[G]=J,W){W.set="replace";let L=A&&this.#H(A)?A.__staleWhileFetching:A;L!==void 0&&(W.oldValue=L)}}else W&&(W.set="update");this.#O&&this.onInsert?.(J,Z,J===A?"update":"replace")}if(X!==0&&!this.#j&&this.#k(),this.#j&&(H||this.#h(G,X,V),W&&this.#v(W,G)),!K&&this.#J&&this.#B){let A=this.#B,L;for(;L=A?.shift();)this.#K?.(...L)}return this}pop(){try{for(;this.#Y;){let Z=this.#V[this.#U];if(this.#d(!0),this.#H(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#J&&this.#B){let Z=this.#B,J;for(;J=Z?.shift();)this.#K?.(...J)}}}#d(Z){let J=this.#U,Q=this.#W[J],X=this.#V[J];return this.#I&&this.#H(X)?X.__abortController.abort(Error("evicted")):(this.#R||this.#J)&&(this.#R&&this.#X?.(X,Q,"evict"),this.#J&&this.#B?.push([X,Q,"evict"])),this.#f(J),this.#L?.[J]&&(clearTimeout(this.#L[J]),this.#L[J]=void 0),Z&&(this.#W[J]=void 0,this.#V[J]=void 0,this.#M.push(J)),this.#Y===1?(this.#U=this.#A=0,this.#M.length=0):this.#U=this.#w[J],this.#q.delete(Q),this.#Y--,J}has(Z,J={}){let{updateAgeOnHas:Q=this.updateAgeOnHas,status:X}=J,V=this.#q.get(Z);if(V!==void 0){let K=this.#V[V];if(this.#H(K)&&K.__staleWhileFetching===void 0)return!1;if(this.#F(V))X&&(X.has="stale",this.#v(X,V));else return Q&&this.#E(V),X&&(X.has="hit",this.#v(X,V)),!0}else X&&(X.has="miss");return!1}peek(Z,J={}){let{allowStale:Q=this.allowStale}=J,X=this.#q.get(Z);if(X===void 0||!Q&&this.#F(X))return;let V=this.#V[X];return this.#H(V)?V.__staleWhileFetching:V}#m(Z,J,Q,X){let V=J===void 0?void 0:this.#V[J];if(this.#H(V))return V;let K=new A6,{signal:Y}=Q;Y?.addEventListener("abort",()=>K.abort(Y.reason),{signal:K.signal});let W={signal:K.signal,options:Q,context:X},H=(_,R=!1)=>{let{aborted:w}=K.signal,D=Q.ignoreFetchAbort&&_!==void 0,I=Q.ignoreFetchAbort||!!(Q.allowStaleOnFetchAbort&&_!==void 0);if(Q.status&&(w&&!R?(Q.status.fetchAborted=!0,Q.status.fetchError=K.signal.reason,D&&(Q.status.fetchAbortIgnored=!0)):Q.status.fetchResolved=!0),w&&!D&&!R)return G(K.signal.reason,I);let S=L,M=this.#V[J];return(M===L||D&&R&&M===void 0)&&(_===void 0?S.__staleWhileFetching!==void 0?this.#V[J]=S.__staleWhileFetching:this.#S(Z,"fetch"):(Q.status&&(Q.status.fetchUpdated=!0),this.set(Z,_,W.options))),_},z=(_)=>(Q.status&&(Q.status.fetchRejected=!0,Q.status.fetchError=_),G(_,!1)),G=(_,R)=>{let{aborted:w}=K.signal,D=w&&Q.allowStaleOnFetchAbort,I=D||Q.allowStaleOnFetchRejection,S=I||Q.noDeleteOnFetchRejection,M=L;if(this.#V[J]===L&&(!S||!R&&M.__staleWhileFetching===void 0?this.#S(Z,"fetch"):D||(this.#V[J]=M.__staleWhileFetching)),I)return Q.status&&M.__staleWhileFetching!==void 0&&(Q.status.returnedStale=!0),M.__staleWhileFetching;if(M.__returned===M)throw _},A=(_,R)=>{let w=this.#P?.(Z,V,W);w&&w instanceof Promise&&w.then((D)=>_(D===void 0?void 0:D),R),K.signal.addEventListener("abort",()=>{(!Q.ignoreFetchAbort||Q.allowStaleOnFetchAbort)&&(_(void 0),Q.allowStaleOnFetchAbort&&(_=(D)=>H(D,!0)))})};Q.status&&(Q.status.fetchDispatched=!0);let L=new Promise(A).then(H,z),B=Object.assign(L,{__abortController:K,__staleWhileFetching:V,__returned:void 0});return J===void 0?(this.set(Z,B,{...W.options,status:void 0}),J=this.#q.get(Z)):this.#V[J]=B,B}#H(Z){if(!this.#I)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof A6}async fetch(Z,J={}){let{allowStale:Q=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,ttl:K=this.ttl,noDisposeOnSet:Y=this.noDisposeOnSet,size:W=0,sizeCalculation:H=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:G=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:A=this.allowStaleOnFetchRejection,ignoreFetchAbort:L=this.ignoreFetchAbort,allowStaleOnFetchAbort:B=this.allowStaleOnFetchAbort,context:_,forceRefresh:R=!1,status:w,signal:D}=J;if(!this.#I)return w&&(w.fetch="get"),this.get(Z,{allowStale:Q,updateAgeOnGet:X,noDeleteOnStaleGet:V,status:w});let I={allowStale:Q,updateAgeOnGet:X,noDeleteOnStaleGet:V,ttl:K,noDisposeOnSet:Y,size:W,sizeCalculation:H,noUpdateTTL:z,noDeleteOnFetchRejection:G,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:B,ignoreFetchAbort:L,status:w,signal:D},S=this.#q.get(Z);if(S===void 0){w&&(w.fetch="miss");let M=this.#m(Z,S,I,_);return M.__returned=M}else{let M=this.#V[S];if(this.#H(M)){let V0=Q&&M.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",V0&&(w.returnedStale=!0)),V0?M.__staleWhileFetching:M.__returned=M}let g=this.#F(S);if(!R&&!g)return w&&(w.fetch="hit"),this.#b(S),X&&this.#E(S),w&&this.#v(w,S),M;let x=this.#m(Z,S,I,_),c=x.__staleWhileFetching!==void 0&&Q;return w&&(w.fetch=g?"stale":"refresh",c&&g&&(w.returnedStale=!0)),c?x.__staleWhileFetching:x.__returned=x}}async forceFetch(Z,J={}){let Q=await this.fetch(Z,J);if(Q===void 0)throw Error("fetch() returned undefined");return Q}memo(Z,J={}){let Q=this.#_;if(!Q)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:V,...K}=J,Y=this.get(Z,K);if(!V&&Y!==void 0)return Y;let W=Q(Z,Y,{options:K,context:X});return this.set(Z,W,K),W}get(Z,J={}){let{allowStale:Q=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,status:K}=J,Y=this.#q.get(Z);if(Y!==void 0){let W=this.#V[Y],H=this.#H(W);return K&&this.#v(K,Y),this.#F(Y)?(K&&(K.get="stale"),H?(K&&Q&&W.__staleWhileFetching!==void 0&&(K.returnedStale=!0),Q?W.__staleWhileFetching:void 0):(V||this.#S(Z,"expire"),K&&Q&&(K.returnedStale=!0),Q?W:void 0)):(K&&(K.get="hit"),H?W.__staleWhileFetching:(this.#b(Y),X&&this.#E(Y),W))}else K&&(K.get="miss")}#c(Z,J){this.#C[J]=Z,this.#w[Z]=J}#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,J){let Q=!1;if(this.#Y!==0){let X=this.#q.get(Z);if(X!==void 0)if(this.#L?.[X]&&(clearTimeout(this.#L?.[X]),this.#L[X]=void 0),Q=!0,this.#Y===1)this.#p(J);else{this.#f(X);let V=this.#V[X];if(this.#H(V)?V.__abortController.abort(Error("deleted")):(this.#R||this.#J)&&(this.#R&&this.#X?.(V,Z,J),this.#J&&this.#B?.push([V,Z,J])),this.#q.delete(Z),this.#W[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 Y=this.#w[X];this.#C[Y]=this.#C[X]}this.#Y--,this.#M.push(X)}}if(this.#J&&this.#B?.length){let X=this.#B,V;for(;V=X?.shift();)this.#K?.(...V)}return Q}clear(){return this.#p("delete")}#p(Z){for(let J of this.#x({allowStale:!0})){let Q=this.#V[J];if(this.#H(Q))Q.__abortController.abort(Error("deleted"));else{let X=this.#W[J];this.#R&&this.#X?.(Q,X,Z),this.#J&&this.#B?.push([Q,X,Z])}}if(this.#q.clear(),this.#V.fill(void 0),this.#W.fill(void 0),this.#j&&this.#D){this.#j.fill(0),this.#D.fill(0);for(let J of this.#L??[])J!==void 0&&clearTimeout(J);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.#Y=0,this.#J&&this.#B){let J=this.#B,Q;for(;Q=J?.shift();)this.#K?.(...Q)}}};import{posix as a8,win32 as N2}from"path";import{fileURLToPath as r8}from"url";import{lstatSync as n8,readdir as i8,readdirSync as o8,readlinkSync as s8,realpathSync as e8}from"fs";import*as t8 from"fs";import{lstat as ZZ,readdir as JZ,readlink as QZ,realpath as XZ}from"fs/promises";import{EventEmitter as _2}from"events";import n5 from"stream";import{StringDecoder as b8}from"string_decoder";var l5=typeof process==="object"&&process?process:{stdout:null,stderr:null},f8=($)=>!!$&&typeof $==="object"&&($ instanceof Y4||$ instanceof n5||h8($)||g8($)),h8=($)=>!!$&&typeof $==="object"&&$ instanceof _2&&typeof $.pipe==="function"&&$.pipe!==n5.Writable.prototype.pipe,g8=($)=>!!$&&typeof $==="object"&&$ instanceof _2&&typeof $.write==="function"&&typeof $.end==="function",u0=Symbol("EOF"),d0=Symbol("maybeEmitEnd"),s0=Symbol("emittedEnd"),B6=Symbol("emittingEnd"),c4=Symbol("emittedError"),L6=Symbol("closed"),p5=Symbol("read"),_6=Symbol("flush"),a5=Symbol("flushChunk"),w0=Symbol("encoding"),_4=Symbol("decoder"),p=Symbol("flowing"),l4=Symbol("paused"),w4=Symbol("resume"),a=Symbol("buffer"),$0=Symbol("pipes"),r=Symbol("bufferLength"),j2=Symbol("bufferPush"),w6=Symbol("bufferShift"),o=Symbol("objectMode"),m=Symbol("destroyed"),U2=Symbol("error"),A2=Symbol("emitData"),r5=Symbol("emitEnd"),B2=Symbol("emitEnd2"),F0=Symbol("async"),L2=Symbol("abort"),R6=Symbol("aborted"),p4=Symbol("signal"),K4=Symbol("dataListeners"),q0=Symbol("discarded"),a4=($)=>Promise.resolve().then($),u8=($)=>$(),d8=($)=>$==="end"||$==="finish"||$==="prefinish",m8=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,c8=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class w2{src;dest;opts;ondrain;constructor($,Z,J){this.src=$,this.dest=Z,this.opts=J,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 i5 extends w2{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Z,J){super($,Z,J);this.proxyErrors=(Q)=>this.dest.emit("error",Q),$.on("error",this.proxyErrors)}}var l8=($)=>!!$.objectMode,p8=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class Y4 extends _2{[p]=!1;[l4]=!1;[$0]=[];[a]=[];[o];[w0];[F0];[_4];[u0]=!1;[s0]=!1;[B6]=!1;[L6]=!1;[c4]=null;[r]=0;[m]=!1;[p4];[R6]=!1;[K4]=0;[q0]=!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(l8(Z))this[o]=!0,this[w0]=null;else if(p8(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 b8(this[w0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[a]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[$0]});let{signal:J}=Z;if(J)if(this[p4]=J,J.aborted)this[L2]();else J.addEventListener("abort",()=>this[L2]())}get bufferLength(){return this[r]}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]||!!$}[L2](){this[R6]=!0,this.emit("abort",this[p4]?.reason),this.destroy(this[p4]?.reason)}get aborted(){return this[R6]}set aborted($){}write($,Z,J){if(this[R6])return!1;if(this[u0])throw Error("write after end");if(this[m])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")J=Z,Z="utf8";if(!Z)Z="utf8";let Q=this[F0]?a4:u8;if(!this[o]&&!Buffer.isBuffer($)){if(c8($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(m8($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[o]){if(this[p]&&this[r]!==0)this[_6](!0);if(this[p])this.emit("data",$);else this[j2]($);if(this[r]!==0)this.emit("readable");if(J)Q(J);return this[p]}if(!$.length){if(this[r]!==0)this.emit("readable");if(J)Q(J);return this[p]}if(typeof $==="string"&&!(Z===this[w0]&&!this[_4]?.lastNeed))$=Buffer.from($,Z);if(Buffer.isBuffer($)&&this[w0])$=this[_4].write($);if(this[p]&&this[r]!==0)this[_6](!0);if(this[p])this.emit("data",$);else this[j2]($);if(this[r]!==0)this.emit("readable");if(J)Q(J);return this[p]}read($){if(this[m])return null;if(this[q0]=!1,this[r]===0||$===0||$&&$>this[r])return this[d0](),null;if(this[o])$=null;if(this[a].length>1&&!this[o])this[a]=[this[w0]?this[a].join(""):Buffer.concat(this[a],this[r])];let Z=this[p5]($||null,this[a][0]);return this[d0](),Z}[p5]($,Z){if(this[o])this[w6]();else{let J=Z;if($===J.length||$===null)this[w6]();else if(typeof J==="string")this[a][0]=J.slice($),Z=J.slice(0,$),this[r]-=$;else this[a][0]=J.subarray($),Z=J.subarray(0,$),this[r]-=$}if(this.emit("data",Z),!this[a].length&&!this[u0])this.emit("drain");return Z}end($,Z,J){if(typeof $==="function")J=$,$=void 0;if(typeof Z==="function")J=Z,Z="utf8";if($!==void 0)this.write($,Z);if(J)this.once("end",J);if(this[u0]=!0,this.writable=!1,this[p]||!this[l4])this[d0]();return this}[w4](){if(this[m])return;if(!this[K4]&&!this[$0].length)this[q0]=!0;if(this[l4]=!1,this[p]=!0,this.emit("resume"),this[a].length)this[_6]();else if(this[u0])this[d0]();else this.emit("drain")}resume(){return this[w4]()}pause(){this[p]=!1,this[l4]=!0,this[q0]=!1}get destroyed(){return this[m]}get flowing(){return this[p]}get paused(){return this[l4]}[j2]($){if(this[o])this[r]+=1;else this[r]+=$.length;this[a].push($)}[w6](){if(this[o])this[r]-=1;else this[r]-=this[a][0].length;return this[a].shift()}[_6]($=!1){do;while(this[a5](this[w6]())&&this[a].length);if(!$&&!this[a].length&&!this[u0])this.emit("drain")}[a5]($){return this.emit("data",$),this[p]}pipe($,Z){if(this[m])return $;this[q0]=!1;let J=this[s0];if(Z=Z||{},$===l5.stdout||$===l5.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,J){if(Z.end)$.end()}else if(this[$0].push(!Z.proxyErrors?new w2(this,$,Z):new i5(this,$,Z)),this[F0])a4(()=>this[w4]());else this[w4]();return $}unpipe($){let Z=this[$0].find((J)=>J.dest===$);if(Z){if(this[$0].length===1){if(this[p]&&this[K4]===0)this[p]=!1;this[$0]=[]}else this[$0].splice(this[$0].indexOf(Z),1);Z.unpipe()}}addListener($,Z){return this.on($,Z)}on($,Z){let J=super.on($,Z);if($==="data"){if(this[q0]=!1,this[K4]++,!this[$0].length&&!this[p])this[w4]()}else if($==="readable"&&this[r]!==0)super.emit("readable");else if(d8($)&&this[s0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[c4]){let Q=Z;if(this[F0])a4(()=>Q.call(this,this[c4]));else Q.call(this,this[c4])}return J}removeListener($,Z){return this.off($,Z)}off($,Z){let J=super.off($,Z);if($==="data"){if(this[K4]=this.listeners("data").length,this[K4]===0&&!this[q0]&&!this[$0].length)this[p]=!1}return J}removeAllListeners($){let Z=super.removeAllListeners($);if($==="data"||$===void 0){if(this[K4]=0,!this[q0]&&!this[$0].length)this[p]=!1}return Z}get emittedEnd(){return this[s0]}[d0](){if(!this[B6]&&!this[s0]&&!this[m]&&this[a].length===0&&this[u0]){if(this[B6]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[L6])this.emit("close");this[B6]=!1}}emit($,...Z){let J=Z[0];if($!=="error"&&$!=="close"&&$!==m&&this[m])return!1;else if($==="data")return!this[o]&&!J?!1:this[F0]?(a4(()=>this[A2](J)),!0):this[A2](J);else if($==="end")return this[r5]();else if($==="close"){if(this[L6]=!0,!this[s0]&&!this[m])return!1;let X=super.emit("close");return this.removeAllListeners("close"),X}else if($==="error"){this[c4]=J,super.emit(U2,J);let X=!this[p4]||this.listeners("error").length?super.emit("error",J):!1;return this[d0](),X}else if($==="resume"){let X=super.emit("resume");return this[d0](),X}else if($==="finish"||$==="prefinish"){let X=super.emit($);return this.removeAllListeners($),X}let Q=super.emit($,...Z);return this[d0](),Q}[A2]($){for(let J of this[$0])if(J.dest.write($)===!1)this.pause();let Z=this[q0]?!1:super.emit("data",$);return this[d0](),Z}[r5](){if(this[s0])return!1;return this[s0]=!0,this.readable=!1,this[F0]?(a4(()=>this[B2]()),!0):this[B2]()}[B2](){if(this[_4]){let Z=this[_4].end();if(Z){for(let J of this[$0])J.dest.write(Z);if(!this[q0])super.emit("data",Z)}}for(let Z of this[$0])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",(J)=>{if($.push(J),!this[o])$.dataLength+=J.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(m,()=>Z(Error("stream destroyed"))),this.on("error",(J)=>Z(J)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[q0]=!1;let $=!1,Z=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Z();let Q=this.read();if(Q!==null)return Promise.resolve({done:!1,value:Q});if(this[u0])return Z();let X,V,K=(z)=>{this.off("data",Y),this.off("end",W),this.off(m,H),Z(),V(z)},Y=(z)=>{this.off("error",K),this.off("end",W),this.off(m,H),this.pause(),X({value:z,done:!!this[u0]})},W=()=>{this.off("error",K),this.off("data",Y),this.off(m,H),Z(),X({done:!0,value:void 0})},H=()=>K(Error("stream destroyed"));return new Promise((z,G)=>{V=G,X=z,this.once(m,H),this.once("error",K),this.once("end",W),this.once("data",Y)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[q0]=!1;let $=!1,Z=()=>{return this.pause(),this.off(U2,Z),this.off(m,Z),this.off("end",Z),$=!0,{done:!0,value:void 0}},J=()=>{if($)return Z();let Q=this.read();return Q===null?Z():{done:!1,value:Q}};return this.once("end",Z),this.once(U2,Z),this.once(m,Z),{next:J,throw:Z,return:Z,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy($){if(this[m]){if($)this.emit("error",$);else this.emit(m);return this}this[m]=!0,this[q0]=!0,this[a].length=0,this[r]=0;let Z=this;if(typeof Z.close==="function"&&!this[L6])Z.close();if($)this.emit("error",$);else this.emit(m);return this}static get isStream(){return f8}}var $Z=e8.native,n4={lstatSync:n8,readdir:i8,readdirSync:o8,readlinkSync:s8,realpathSync:$Z,promises:{lstat:ZZ,readdir:JZ,readlink:QZ,realpath:XZ}},$1=($)=>!$||$===n4||$===t8?n4:{...n4,...$,promises:{...n4.promises,...$.promises||{}}},Z1=/^\\\\\?\\([a-z]:)\\?$/i,VZ=($)=>$.replace(/\//g,"\\").replace(Z1,"$1\\"),KZ=/[\\\/]/,A0=0,J1=1,Q1=2,M0=4,X1=6,V1=8,W4=10,K1=12,U0=15,r4=~U0,R2=16,o5=32,i4=64,R0=128,C6=256,P6=512,s5=i4|R0|P6,YZ=1023,C2=($)=>$.isFile()?V1:$.isDirectory()?M0:$.isSymbolicLink()?W4:$.isCharacterDevice()?Q1:$.isBlockDevice()?X1:$.isSocket()?K1:$.isFIFO()?J1:A0,e5=new m4({max:4096}),o4=($)=>{let Z=e5.get($);if(Z)return Z;let J=$.normalize("NFKD");return e5.set($,J),J},t5=new m4({max:4096}),N6=($)=>{let Z=t5.get($);if(Z)return Z;let J=o4($.toLowerCase());return t5.set($,J),J};class P2 extends m4{constructor(){super({max:256})}}class Y1 extends m4{constructor($=16384){super({maxSize:$,sizeCalculation:(Z)=>Z.length+1})}}var W1=Symbol("PathScurry setAsCwd");class Z0{name;root;roots;parent;nocase;isCWD=!1;#$;#Q;get dev(){return this.#Q}#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}#Y;get ino(){return this.#Y}#G;get size(){return this.#G}#q;get blocks(){return this.#q}#W;get atimeMs(){return this.#W}#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;#J;#O;#k;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Z=A0,J,Q,X,V,K){if(this.name=$,this.#N=X?N6($):o4($),this.#J=Z&YZ,this.nocase=X,this.roots=Q,this.root=J||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.#$=$1(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($),Q=$.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#v(Q):this.#v(Q)}#v($){let Z=this;for(let J of $)Z=Z.child(J);return Z}children(){let $=this.#O.get(this);if($)return $;let Z=Object.assign([],{provisional:0});return this.#O.set(this,Z),this.#J&=~R2,Z}child($,Z){if($===""||$===".")return this;if($==="..")return this.parent||this;let J=this.children(),Q=this.nocase?N6($):o4($);for(let Y of J)if(Y.#N===Q)return Y;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.#J|=R0;return J.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 J=Z.relative();return J+(!J||!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 J=Z.relativePosix();return J+(!J||!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 Q=Z.fullpath()+(!Z.parent?"":this.sep)+$;return this.#j=Q}fullpathPosix(){if(this.#L!==void 0)return this.#L;if(this.sep==="/")return this.#L=this.fullpath();if(!this.parent){let Q=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Q))return this.#L=`//?/${Q}`;else return this.#L=Q}let $=this.parent,Z=$.fullpathPosix(),J=Z+(!Z||!$.parent?"":"/")+this.name;return this.#L=J}isUnknown(){return(this.#J&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.#J&U0)===V1}isDirectory(){return(this.#J&U0)===M0}isCharacterDevice(){return(this.#J&U0)===Q1}isBlockDevice(){return(this.#J&U0)===X1}isFIFO(){return(this.#J&U0)===J1}isSocket(){return(this.#J&U0)===K1}isSymbolicLink(){return(this.#J&W4)===W4}lstatCached(){return this.#J&o5?this:void 0}readlinkCached(){return this.#k}realpathCached(){return this.#E}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#k)return!0;if(!this.parent)return!1;let $=this.#J&U0;return!($!==A0&&$!==W4||this.#J&C6||this.#J&R0)}calledReaddir(){return!!(this.#J&R2)}isENOENT(){return!!(this.#J&R0)}isNamed($){return!this.nocase?this.#N===o4($):this.#N===N6($)}async readlink(){let $=this.#k;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#$.promises.readlink(this.fullpath()),J=(await this.parent.realpath())?.resolve(Z);if(J)return this.#k=J}catch(Z){this.#x(Z.code);return}}readlinkSync(){let $=this.#k;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#$.readlinkSync(this.fullpath()),J=this.parent.realpathSync()?.resolve(Z);if(J)return this.#k=J}catch(Z){this.#x(Z.code);return}}#h($){this.#J|=R2;for(let Z=$.provisional;Z<$.length;Z++){let J=$[Z];if(J)J.#F()}}#F(){if(this.#J&R0)return;this.#J=(this.#J|R0)&r4,this.#l()}#l(){let $=this.children();$.provisional=0;for(let Z of $)Z.#F()}#f(){this.#J|=P6,this.#y()}#y(){if(this.#J&i4)return;let $=this.#J;if(($&U0)===M0)$&=r4;this.#J=$|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()}#x($=""){let Z=this.#J;if(Z|=C6,$==="ENOENT")Z|=R0;if($==="EINVAL"||$==="UNKNOWN")Z&=r4;if(this.#J=Z,$==="ENOTDIR"&&this.parent)this.parent.#y()}#u($,Z){return this.#m($,Z)||this.#d($,Z)}#d($,Z){let J=C2($),Q=this.newChild($.name,J,{parent:this}),X=Q.#J&U0;if(X!==M0&&X!==W4&&X!==A0)Q.#J|=i4;return Z.unshift(Q),Z.provisional++,Q}#m($,Z){for(let J=Z.provisional;J<Z.length;J++){let Q=Z[J];if((this.nocase?N6($.name):o4($.name))!==Q.#N)continue;return this.#H($,Q,J,Z)}}#H($,Z,J,Q){let X=Z.name;if(Z.#J=Z.#J&r4|C2($),X!==$.name)Z.name=$.name;if(J!==Q.provisional){if(J===Q.length-1)Q.pop();else Q.splice(J,1);Q.unshift(Z)}return Q.provisional++,Z}async lstat(){if((this.#J&R0)===0)try{return this.#c(await this.#$.promises.lstat(this.fullpath())),this}catch($){this.#T($.code)}}lstatSync(){if((this.#J&R0)===0)try{return this.#c(this.#$.lstatSync(this.fullpath())),this}catch($){this.#T($.code)}}#c($){let{atime:Z,atimeMs:J,birthtime:Q,birthtimeMs:X,blksize:V,blocks:K,ctime:Y,ctimeMs:W,dev:H,gid:z,ino:G,mode:A,mtime:L,mtimeMs:B,nlink:_,rdev:R,size:w,uid:D}=$;this.#U=Z,this.#W=J,this.#B=Q,this.#C=X,this.#z=V,this.#q=K,this.#M=Y,this.#w=W,this.#Q=H,this.#P=z,this.#Y=G,this.#X=A,this.#A=L,this.#V=B,this.#Z=_,this.#_=R,this.#G=w,this.#K=D;let I=C2($);if(this.#J=this.#J&r4|I|o5,I!==A0&&I!==M0&&I!==W4)this.#J|=i4}#b=[];#S=!1;#p($){this.#S=!1;let Z=this.#b.slice();this.#b.length=0,Z.forEach((J)=>J(null,$))}readdirCB($,Z=!1){if(!this.canReaddir()){if(Z)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let J=this.children();if(this.calledReaddir()){let X=J.slice(0,J.provisional);if(Z)$(null,X);else queueMicrotask(()=>$(null,X));return}if(this.#b.push($),this.#S)return;this.#S=!0;let Q=this.fullpath();this.#$.readdir(Q,{withFileTypes:!0},(X,V)=>{if(X)this.#g(X.code),J.provisional=0;else{for(let K of V)this.#u(K,J);this.#h(J)}this.#p(J.slice(0,J.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 J=()=>{};this.#a=new Promise((Q)=>J=Q);try{for(let Q of await this.#$.promises.readdir(Z,{withFileTypes:!0}))this.#u(Q,$);this.#h($)}catch(Q){this.#g(Q.code),$.provisional=0}this.#a=void 0,J()}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 J of this.#$.readdirSync(Z,{withFileTypes:!0}))this.#u(J,$);this.#h($)}catch(J){this.#g(J.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#J&s5)return!1;let $=U0&this.#J;if(!($===A0||$===M0||$===W4))return!1;return!0}shouldWalk($,Z){return(this.#J&M0)===M0&&!(this.#J&s5)&&!$.has(this)&&(!Z||Z(this))}async realpath(){if(this.#E)return this.#E;if((P6|C6|R0)&this.#J)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((P6|C6|R0)&this.#J)return;try{let $=this.#$.realpathSync(this.fullpath());return this.#E=this.resolve($)}catch($){this.#f()}}[W1]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Z=new Set([]),J=[],Q=this;while(Q&&Q.parent)Z.add(Q),Q.#R=J.join(this.sep),Q.#I=J.join("/"),Q=Q.parent,J.push("..");Q=$;while(Q&&Q.parent&&!Z.has(Q))Q.#R=void 0,Q.#I=void 0,Q=Q.parent}}class D6 extends Z0{sep="\\";splitSep=KZ;constructor($,Z=A0,J,Q,X,V,K){super($,Z,J,Q,X,V,K)}newChild($,Z=A0,J={}){return new D6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),J)}getRootString($){return N2.parse($).root}getRoot($){if($=VZ($.toUpperCase()),$===this.root.name)return this.root;for(let[Z,J]of Object.entries(this.roots))if(this.sameRoot($,Z))return this.roots[$]=J;return this.roots[$]=new s4($,this).root}sameRoot($,Z=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(Z1,"$1\\"),$===Z}}class F6 extends Z0{splitSep="/";sep="/";constructor($,Z=A0,J,Q,X,V,K){super($,Z,J,Q,X,V,K)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Z=A0,J={}){return new F6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),J)}}class D2{root;rootPath;roots;cwd;#$;#Q;#X;nocase;#Z;constructor($=process.cwd(),Z,J,{nocase:Q,childrenCacheSize:X=16384,fs:V=n4}={}){if(this.#Z=$1(V),$ instanceof URL||$.startsWith("file://"))$=r8($);let K=Z.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#$=new P2,this.#Q=new P2,this.#X=new Y1(X);let Y=K.substring(this.rootPath.length).split(J);if(Y.length===1&&!Y[0])Y.pop();if(Q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Q,this.root=this.newRoot(this.#Z),this.roots[this.rootPath]=this.root;let W=this.root,H=Y.length-1,z=Z.sep,G=this.rootPath,A=!1;for(let L of Y){let B=H--;W=W.child(L,{relative:Array(B).fill("..").join(z),relativePosix:Array(B).fill("..").join("/"),fullpath:G+=(A?"":z)+L}),A=!0}this.cwd=W}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 J=this.#$.get(Z);if(J!==void 0)return J;let Q=this.cwd.resolve(Z).fullpath();return this.#$.set(Z,Q),Q}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 J=this.#Q.get(Z);if(J!==void 0)return J;let Q=this.cwd.resolve(Z).fullpathPosix();return this.#Q.set(Z,Q),Q}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 Z0))Z=$,$=this.cwd;let{withFileTypes:J}=Z;if(!$.canReaddir())return[];else{let Q=await $.readdir();return J?Q:Q.map((X)=>X.name)}}readdirSync($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:J=!0}=Z;if(!$.canReaddir())return[];else if(J)return $.readdirSync();else return $.readdirSync().map((Q)=>Q.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 Z0))Z=$.withFileTypes,$=this.cwd;let J=await $.readlink();return Z?J:J?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$.withFileTypes,$=this.cwd;let J=$.readlinkSync();return Z?J:J?.fullpath()}async realpath($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$.withFileTypes,$=this.cwd;let J=await $.realpath();return Z?J:J?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$.withFileTypes,$=this.cwd;let J=$.realpathSync();return Z?J:J?.fullpath()}async walk($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(J?$:$.fullpath());let Y=new Set,W=(z,G)=>{Y.add(z),z.readdirCB((A,L)=>{if(A)return G(A);let B=L.length;if(!B)return G();let _=()=>{if(--B===0)G()};for(let R of L){if(!X||X(R))K.push(J?R:R.fullpath());if(Q&&R.isSymbolicLink())R.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(Y,V)?W(w,_):_());else if(R.shouldWalk(Y,V))W(R,_);else _()}},!0)},H=$;return new Promise((z,G)=>{W(H,(A)=>{if(A)return G(A);z(K)})})}walkSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(J?$:$.fullpath());let Y=new Set([$]);for(let W of Y){let H=W.readdirSync();for(let z of H){if(!X||X(z))K.push(J?z:z.fullpath());let G=z;if(z.isSymbolicLink()){if(!(Q&&(G=z.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(Y,V))Y.add(G)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))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 Z0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z;if(!X||X($))yield J?$:$.fullpath();let K=new Set([$]);for(let Y of K){let W=Y.readdirSync();for(let H of W){if(!X||X(H))yield J?H:H.fullpath();let z=H;if(H.isSymbolicLink()){if(!(Q&&(z=H.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 Z0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=new Y4({objectMode:!0});if(!X||X($))K.write(J?$:$.fullpath());let Y=new Set,W=[$],H=0,z=()=>{let G=!1;while(!G){let A=W.shift();if(!A){if(H===0)K.end();return}H++,Y.add(A);let L=(_,R,w=!1)=>{if(_)return K.emit("error",_);if(Q&&!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(()=>L(null,R,!0));return}}for(let D of R)if(D&&(!X||X(D))){if(!K.write(J?D:D.fullpath()))G=!0}H--;for(let D of R){let I=D.realpathCached()||D;if(I.shouldWalk(Y,V))W.push(I)}if(G&&!K.flowing)K.once("drain",z);else if(!B)z()},B=!0;A.readdirCB(L,!0),B=!1}};return z(),K}streamSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=new Y4({objectMode:!0}),Y=new Set;if(!X||X($))K.write(J?$:$.fullpath());let W=[$],H=0,z=()=>{let G=!1;while(!G){let A=W.shift();if(!A){if(H===0)K.end();return}H++,Y.add(A);let L=A.readdirSync();for(let B of L)if(!X||X(B)){if(!K.write(J?B:B.fullpath()))G=!0}H--;for(let B of L){let _=B;if(B.isSymbolicLink()){if(!(Q&&(_=B.realpathSync())))continue;if(_.isUnknown())_.lstatSync()}if(_.shouldWalk(Y,V))W.push(_)}}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[W1](Z)}}class s4 extends D2{sep="\\";constructor($=process.cwd(),Z={}){let{nocase:J=!0}=Z;super($,N2,"\\",{...Z,nocase:J});this.nocase=J;for(let Q=this.cwd;Q;Q=Q.parent)Q.nocase=this.nocase}parseRootPath($){return N2.parse($).root.toUpperCase()}newRoot($){return new D6(this.rootPath,M0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class e4 extends D2{sep="/";constructor($=process.cwd(),Z={}){let{nocase:J=!1}=Z;super($,a8,"/",{...Z,nocase:J});this.nocase=J}parseRootPath($){return"/"}newRoot($){return new F6(this.rootPath,M0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class M6 extends e4{constructor($=process.cwd(),Z={}){let{nocase:J=!0}=Z;super($,{...Z,nocase:J})}}var VY=process.platform==="win32"?D6:F6,H1=process.platform==="win32"?s4:process.platform==="darwin"?M6:e4;var WZ=($)=>$.length>=1,HZ=($)=>$.length>=1;class R4{#$;#Q;#X;length;#Z;#K;#P;#_;#z;#Y;#G=!0;constructor($,Z,J,Q){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,J<0||J>=this.length)throw TypeError("index out of range");if(this.#$=$,this.#Q=Z,this.#X=J,this.#Z=Q,this.#X===0){if(this.isUNC()){let[X,V,K,Y,...W]=this.#$,[H,z,G,A,...L]=this.#Q;if(W[0]==="")W.shift(),L.shift();let B=[X,V,K,Y,""].join("/"),_=[H,z,G,A,""].join("/");this.#$=[B,...W],this.#Q=[_,...L],this.length=this.#$.length}else if(this.isDrive()||this.isAbsolute()){let[X,...V]=this.#$,[K,...Y]=this.#Q;if(V[0]==="")V.shift(),Y.shift();let W=X+"/",H=K+"/";this.#$=[W,...V],this.#Q=[H,...Y],this.length=this.#$.length}}}pattern(){return this.#$[this.#X]}isString(){return typeof this.#$[this.#X]==="string"}isGlobstar(){return this.#$[this.#X]===d}isRegExp(){return this.#$[this.#X]instanceof RegExp}globString(){return this.#P=this.#P||(this.#X===0?this.isAbsolute()?this.#Q[0]+this.#Q.slice(1).join("/"):this.#Q.join("/"):this.#Q.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.#Q,this.#X+1,this.#Z),this.#K.#Y=this.#Y,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.#Y!==void 0?this.#Y:this.#Y=$[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:J,noext:Q,noglobstar:X,platform:V=qZ}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=V,this.mmopts={dot:!0,nobrace:Z,nocase:J,noext:Q,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 J=0;J<Z.set.length;J++){let Q=Z.set[J],X=Z.globParts[J];if(!Q||!X)throw Error("invalid pattern object");while(Q[0]==="."&&X[0]===".")Q.shift(),X.shift();let V=new R4(Q,X,0,this.platform),K=new j0(V.globString(),this.mmopts),Y=X[X.length-1]==="**",W=V.isAbsolute();if(W)this.absolute.push(K);else this.relative.push(K);if(Y)if(W)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored($){let Z=$.fullpath(),J=`${Z}/`,Q=$.relative()||".",X=`${Q}/`;for(let V of this.relative)if(V.match(Q)||V.match(X))return!0;for(let V of this.absolute)if(V.match(Z)||V.match(J))return!0;return!1}childrenIgnored($){let Z=$.fullpath()+"/",J=($.relative()||".")+"/";for(let Q of this.relativeChildren)if(Q.match(J))return!0;for(let Q of this.absoluteChildren)if(Q.match(Z))return!0;return!1}}class F2{store;constructor($=new Map){this.store=$}copy(){return new F2(new Map(this.store))}hasWalked($,Z){return this.store.get($.fullpath())?.has(Z.globString())}storeWalked($,Z){let J=$.fullpath(),Q=this.store.get(J);if(Q)Q.add(Z.globString());else this.store.set(J,new Set([Z.globString()]))}}class q1{store=new Map;add($,Z,J){let Q=(Z?2:0)|(J?1:0),X=this.store.get($);this.store.set($,X===void 0?Q:Q&X)}entries(){return[...this.store.entries()].map(([$,Z])=>[$,!!(Z&2),!!(Z&1)])}}class z1{store=new Map;add($,Z){if(!$.canReaddir())return;let J=this.store.get($);if(J){if(!J.find((Q)=>Q.globString()===Z.globString()))J.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 q1;subwalks=new z1;patterns;follow;dot;opts;constructor($,Z){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Z?Z.copy():new F2}processPatterns($,Z){this.patterns=Z;let J=Z.map((Q)=>[$,Q]);for(let[Q,X]of J){this.hasWalkedCache.storeWalked(Q,X);let V=X.root(),K=X.isAbsolute()&&this.opts.absolute!==!1;if(V){Q=Q.resolve(V==="/"&&this.opts.root!==void 0?this.opts.root:V);let z=X.rest();if(!z){this.matches.add(Q,!0,!1);continue}else X=z}if(Q.isENOENT())continue;let Y,W,H=!1;while(typeof(Y=X.pattern())==="string"&&(W=X.rest()))Q=Q.resolve(Y),X=W,H=!0;if(Y=X.pattern(),W=X.rest(),H){if(this.hasWalkedCache.hasWalked(Q,X))continue;this.hasWalkedCache.storeWalked(Q,X)}if(typeof Y==="string"){let z=Y===".."||Y===""||Y===".";this.matches.add(Q.resolve(Y),K,z);continue}else if(Y===d){if(!Q.isSymbolicLink()||this.follow||X.checkFollowGlobstar())this.subwalks.add(Q,X);let z=W?.pattern(),G=W?.rest();if(!W||(z===""||z===".")&&!G)this.matches.add(Q,K,z===""||z===".");else if(z===".."){let A=Q.parent||Q;if(!G)this.matches.add(A,K,!0);else if(!this.hasWalkedCache.hasWalked(A,G))this.subwalks.add(A,G)}}else if(Y instanceof RegExp)this.subwalks.add(Q,X)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new $6(this.opts,this.hasWalkedCache)}filterEntries($,Z){let J=this.subwalks.get($),Q=this.child();for(let X of Z)for(let V of J){let K=V.isAbsolute(),Y=V.pattern(),W=V.rest();if(Y===d)Q.testGlobstar(X,V,W,K);else if(Y instanceof RegExp)Q.testRegExp(X,Y,W,K);else Q.testString(X,Y,W,K)}return Q}testGlobstar($,Z,J,Q){if(this.dot||!$.name.startsWith(".")){if(!Z.hasMore())this.matches.add($,Q,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Z);else if($.isSymbolicLink()){if(J&&Z.checkFollowGlobstar())this.subwalks.add($,J);else if(Z.markFollowGlobstar())this.subwalks.add($,Z)}}}if(J){let X=J.pattern();if(typeof X==="string"&&X!==".."&&X!==""&&X!==".")this.testString($,X,J.rest(),Q);else if(X===".."){let V=$.parent||$;this.subwalks.add(V,J)}else if(X instanceof RegExp)this.testRegExp($,X,J.rest(),Q)}}testRegExp($,Z,J,Q){if(!Z.test($.name))return;if(!J)this.matches.add($,Q,!1);else this.subwalks.add($,J)}testString($,Z,J,Q){if(!$.isNamed(Z))return;if(!J)this.matches.add($,Q,!1);else this.subwalks.add($,J)}}var zZ=($,Z)=>typeof $==="string"?new t4([$],Z):Array.isArray($)?new t4($,Z):$;class M2{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#$=[];#Q;#X;signal;maxDepth;includeChildMatches;constructor($,Z,J){if(this.patterns=$,this.path=Z,this.opts=J,this.#X=!J.posix&&J.platform==="win32"?"\\":"/",this.includeChildMatches=J.includeChildMatches!==!1,J.ignore||!this.includeChildMatches){if(this.#Q=zZ(J.ignore??[],J),!this.includeChildMatches&&typeof this.#Q.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=J.maxDepth||1/0,J.signal)this.signal=J.signal,this.signal.addEventListener("abort",()=>{this.#$.length=0})}#Z($){return this.seen.has($)||!!this.#Q?.ignored?.($)}#K($){return!!this.#Q?.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 J;if(this.opts.realpath){if(J=$.realpathCached()||await $.realpath(),!J)return;$=J}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 J;if(this.opts.realpath){if(J=$.realpathCached()||$.realpathSync(),!J)return;$=J}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.#Q?.add){let X=`${$.relativePosix()}/**`;this.#Q.add(X)}let J=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add($);let Q=this.opts.mark&&$.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit($);else if(J){let X=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(X+Q)}else{let X=this.opts.posix?$.relativePosix():$.relative(),V=this.opts.dotRelative&&!X.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!X?"."+Q:V+X+Q)}}async match($,Z,J){let Q=await this.matchCheck($,J);if(Q)this.matchFinish(Q,Z)}matchSync($,Z,J){let Q=this.matchCheckSync($,J);if(Q)this.matchFinish(Q,Z)}walkCB($,Z,J){if(this.signal?.aborted)J();this.walkCB2($,Z,new $6(this.opts),J)}walkCB2($,Z,J,Q){if(this.#K($))return Q();if(this.signal?.aborted)Q();if(this.paused){this.onResume(()=>this.walkCB2($,Z,J,Q));return}J.processPatterns($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,Y,W]of J.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,Y,W).then(()=>V())}for(let K of J.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let Y=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,Y,J,V);else K.readdirCB((W,H)=>this.walkCB3(K,H,J,V),!0)}V()}walkCB3($,Z,J,Q){J=J.filterEntries($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,Y,W]of J.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,Y,W).then(()=>V())}for(let[K,Y]of J.subwalks.entries())X++,this.walkCB2(K,Y,J.child(),V);V()}walkCBSync($,Z,J){if(this.signal?.aborted)J();this.walkCB2Sync($,Z,new $6(this.opts),J)}walkCB2Sync($,Z,J,Q){if(this.#K($))return Q();if(this.signal?.aborted)Q();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Z,J,Q));return}J.processPatterns($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,Y,W]of J.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,Y,W)}for(let K of J.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let Y=K.readdirSync();this.walkCB3Sync(K,Y,J,V)}V()}walkCB3Sync($,Z,J,Q){J=J.filterEntries($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,Y,W]of J.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,Y,W)}for(let[K,Y]of J.subwalks.entries())X++,this.walkCB2Sync(K,Y,J.child(),V);V()}}class I6 extends M2{matches=new Set;constructor($,Z,J){super($,Z,J)}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 E6 extends M2{results;constructor($,Z,J){super($,Z,J);this.results=new Y4({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 jZ=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=GZ(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((Y)=>Y.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");$=$.map((Y)=>Y.includes("/")?Y:`./**/${Y}`)}if(this.pattern=$,this.platform=Z.platform||jZ,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 Y=Z.platform==="win32"?s4:Z.platform==="darwin"?M6:Z.platform?e4:H1;this.scurry=new Y(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let J=this.platform==="darwin"||this.platform==="win32",Q={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:J,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},X=this.pattern.map((Y)=>new j0(Y,Q)),[V,K]=X.reduce((Y,W)=>{return Y[0].push(...W.set),Y[1].push(...W.globParts),Y},[[],[]]);this.patterns=V.map((Y,W)=>{let H=K[W];if(!H)throw Error("invalid pattern object");return new R4(Y,H,0,this.platform)})}async walk(){return[...await 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}).walk()]}walkSync(){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}).walkSync()]}stream(){return new E6(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 E6(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 I2=($,Z={})=>{if(!Array.isArray($))$=[$];for(let J of $)if(new j0(J,Z).hasMagic())return!0;return!1};function T6($,Z={}){return new I0($,Z).streamSync()}function j1($,Z={}){return new I0($,Z).stream()}function U1($,Z={}){return new I0($,Z).walkSync()}async function G1($,Z={}){return new I0($,Z).walk()}function x6($,Z={}){return new I0($,Z).iterateSync()}function A1($,Z={}){return new I0($,Z).iterate()}var UZ=T6,AZ=Object.assign(j1,{sync:T6}),BZ=x6,LZ=Object.assign(A1,{sync:x6}),_Z=Object.assign(U1,{stream:T6,iterate:x6}),S6=Object.assign(G1,{glob:G1,globSync:U1,sync:_Z,globStream:j1,stream:AZ,globStreamSync:T6,streamSync:UZ,globIterate:A1,iterate:LZ,globIterateSync:x6,iterateSync:BZ,Glob:I0,hasMagic:I2,escape:L4,unescape:_0});S6.glob=S6;var J4=X5(O9(),1),OX=new Set(["png","jpg","jpeg","gif","webp"]),yX=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"]),bX=25000,fX=5242880,y9=3932160,b9=400,hX=20,gX=[{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 uX($){if($.length<4)return null;for(let{signature:Z,mimeType:J}of gX){let Q=!0;for(let X=0;X<Z.length;X++)if($[X]!==Z[X]){Q=!1;break}if(Q){if(J==="image/webp"){if($.length>=12&&$[8]===87&&$[9]===69&&$[10]===66&&$[11]===80)return"image/webp";continue}return J}}return null}async function f9($,Z=bX,J){let Q=Bun.file($),X=Buffer.from(await Q.arrayBuffer());if(X.length===0)throw Error(`Image file is empty: ${$}`);if(X.length>fX)throw Error(`Image file too large: ${$} (${(X.length/1024/1024).toFixed(2)}MB > 5MB limit)`);if(!uX(X))throw Error(`Unsupported image format: ${$}`);let K=J4.default(X),Y=await K.metadata(),W={originalWidth:Y.width,originalHeight:Y.height},H=(Y.width||0)*(Y.height||0);if(H>y9){let _=Math.sqrt(y9/H),R=Math.round((Y.width||1)*_),w=Math.round((Y.height||1)*_);K=J4.default(X).resize(R,w,{fit:"inside",withoutEnlargement:!0})}let z=Y.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 _=await dX(X,Z),R=_.toString("base64"),w=await J4.default(_).metadata();return{type:"image",base64:R,mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:Y.width,originalHeight:Y.height,displayWidth:w.width,displayHeight:w.height}}}catch(_){let R=await J4.default(X).resize(b9,b9,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:hX}).toBuffer(),w=await J4.default(R).metadata();return{type:"image",base64:R.toString("base64"),mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:Y.width,originalHeight:Y.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:Y.width,originalHeight:Y.height,displayWidth:Y.width,displayHeight:Y.height}}}async function dX($,Z){let J=Math.floor(Z*0.8/0.125),Q=Math.floor(J*0.75),V=await J4.default($).metadata(),K=$.length;if(K<=Q)return $;let Y=Math.sqrt(Q/K),W=Math.round((V.width||1)*Y),H=Math.round((V.height||1)*Y);return J4.default($).resize(W,H,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:70}).toBuffer()}function h9($){let Z=$.toLowerCase().replace(/^\./,"");return OX.has(Z)}function g9($){let Z=$.toLowerCase().replace(/^\./,"");return yX.has(Z)}function u9($){return{type:"image",source:{type:"base64",data:$.base64,media_type:$.mediaType}}}function d9($){let Z=$.dimensions,J=Z?.originalWidth&&Z?.originalHeight?` (${Z.originalWidth}x${Z.originalHeight}${Z.displayWidth!==Z.originalWidth?` \u2192 ${Z.displayWidth}x${Z.displayHeight}`:""})`:"";return`[Image: ${$.mediaType}${J}, ${($.originalSize/1024).toFixed(1)}KB original]`}import*as i6 from"path";var mX={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 J=$.file_path,Q=$.offset||1,X=$.limit||2000;try{let V=i6.extname(J).toLowerCase().slice(1);if(h9(V))return await cX(J,Z.abortSignal);if(g9(V))return{content:`Binary file detected: ${J}
116
- This file type (${V}) is not supported for text reading.`,is_error:!0};let K=Bun.file(J);if(!await K.exists())return{content:`Error: File not found: ${J}`,is_error:!0};let W=(await K.text()).split(`
117
- `),H=Math.max(0,Q-1),z=Math.min(W.length,H+X),G=W.slice(H,z),A=z<W.length,B=G.map((_,R)=>`${H+R+1} ${_}`).join(`
118
- `);if(A)B+=`
119
-
120
- > WARNING: ${J} is ${W.length} lines (limit: ${X}). Only the first ${X} lines were loaded.`;return{content:B}}catch(V){return{content:`Error reading file: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}};async function cX($,Z){try{let J=await f9($,25000,Z),Q=u9(J);return{content:`${d9(J)}
121
-
122
- Note: Image content was read but cannot be displayed through this API proxy. When using native Anthropic API, the image would be included for visual analysis.`}}catch(J){return{content:`Error reading image: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}var lX={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:J,content:Q}=$;try{return await Bun.write(J,Q),{content:`Successfully wrote to ${J}`}}catch(X){return{content:`Error writing file: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},pX={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:J,old_string:Q,new_string:X}=$,V=$.replace_all||!1;try{let Y=await Bun.file(J).text();if(V){let W=Y;Y=Y.split(Q).join(X);let H=(W.match(new RegExp(aX(Q),"g"))||[]).length;if(H===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write(J,Y),{content:`Successfully replaced ${H} occurrences`}}else{let W=Y.indexOf(Q);if(W===-1)return{content:"Error: String not found in file",is_error:!0};if(Y.indexOf(Q,W+1)!==-1)return{content:"Error: String appears multiple times in file. Use replace_all or provide more context.",is_error:!0};return Y=Y.replace(Q,X),await Bun.write(J,Y),{content:`Successfully edited ${J}`}}}catch(K){return{content:`Error editing file: ${K instanceof Error?K.message:String(K)}`,is_error:!0}}}};function aX($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var rX={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 J=$.command,Q=$.timeout||120000;try{let X=Bun.spawnSync(["sh","-c",J],{cwd:Z.workingDirectory,timeout:Q,maxBuffer:31457280}),V=X.stdout?.toString()||"",K=X.stderr?.toString()||"";if(X.exitCode!==0)return{content:`Exit code: ${X.exitCode}
123
- ${V}
124
- ${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}}}},nX={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 J=$.pattern,Q=$.path||Z.workingDirectory;try{let X=await S6(J,{cwd:Q,absolute:!0,nodir:!0});if(X.length===0)return{content:"No files found matching pattern"};return{content:X.sort().join(`
125
- `)}}catch(X){return{content:`Error searching files: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},iX={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 J=$.pattern,Q=$.path||Z.workingDirectory,X=$.glob,V=$.output_mode||"content",K=$["-i:"],Y=$["-C:"],W=$.head_limit;try{let H=["--json"];if(K)H.push("-i");if(Y)H.push("-C",String(Y));if(X)H.push("--glob",X);if(V==="files_with_matches")H.push("--files-with-matches");if(V==="count")H.push("--count");H.push(J,Q);let G=Bun.spawnSync(["rg",...H],{cwd:Z.workingDirectory,maxBuffer:10485760}).stdout?.toString()||"";if(!G.trim())return{content:"No matches found"};if(V==="content"){let A=G.trim().split(`
126
- `),L=[];for(let B of A.slice(0,W||100))try{let _=JSON.parse(B);if(_.type==="match"){let R=_.data?.path?.text||"",w=_.data?.line_number||0,D=_.data?.lines?.text||"";L.push(`${R}:${w}:${D.trim()}`)}}catch{L.push(B)}return{content:L.join(`
127
- `)||"No matches found"}}return{content:G.trim()}}catch(H){return{content:`Error searching: ${H instanceof Error?H.message:String(H)}`,is_error:!0}}}},oX={name:"Task",description:`Launch a new agent to handle complex, multi-step tasks autonomously.
128
-
129
- The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
130
-
131
- Available agent types and their tools:
132
- - Bash: Command execution specialist for running bash commands. Use for git operations, command execution, and other terminal tasks.
133
- - general-purpose: General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks.
134
- - Explore: Fast agent specialized for exploring codebases. Use to quickly find files by patterns, search code for keywords, or answer questions about the codebase.
135
- - Plan: Software architect agent for designing implementation plans. Returns step-by-step plans, identifies critical files and considers architectural trade-offs.
136
-
137
- When using the Task tool, you must specify a subagent_type parameter to select the agent type.
138
-
139
- Usage notes:
140
- - Always include a short description (3-5 words) summarizing what the agent will do
141
- - Launch multiple agents concurrently whenever possible to maximize performance
142
- - 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:J,prompt:Q,description:X}=$,V=$.model||"haiku",K=$.resume,Y=$.run_in_background,W=K||`${J.toLowerCase()}-${Date.now().toString(36)}`;try{let H=process.env.ANTHROPIC_API_KEY||process.env.CLAUDE_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN||process.env.Z_AI_API_KEY||"";if(!H)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"],L=null;for(let D of A)try{if(await Bun.file(D).exists()){L=D;break}}catch{}if(!L)return{content:`Error: Could not find CLI. Tried:
143
- ${A.join(`
144
- `)}`,is_error:!0};let B=["run",L,"-m",G,"-p",Z.permissionMode,"-q",Q];if(Y)return Bun.spawn(["bun",...B],{cwd:Z.workingDirectory,detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,ANTHROPIC_API_KEY:H}}).unref(),{content:JSON.stringify({agentId:W,status:"running",message:`Agent started in background. Use TaskOutput tool with task_id: "${W}" to check results.`,description:X||"Background task"})};let _=Bun.spawnSync(["bun",...B],{cwd:Z.workingDirectory,timeout:300000,maxBuffer:10485760,env:{...process.env,ANTHROPIC_API_KEY:H}}),R=_.stdout?.toString()||"",w=_.stderr?.toString()||"";if(_.exitCode!==0)return{content:`Agent failed with exit code ${_.exitCode}
145
- ${w}
146
- ${R}`.trim(),is_error:!0};return{content:JSON.stringify({agentId:W,status:"completed",output:R,description:X||"Task completed"})}}catch(H){return{content:`Error running subagent: ${H instanceof Error?H.message:String(H)}`,is_error:!0}}}},sX={name:"TaskOutput",description:`Retrieves output from a running or completed task (background shell, agent, or remote session).
147
-
148
- Takes a task_id parameter identifying the task.
149
- Returns the task output along with status information.
150
- Use block=true (default) to wait for task completion.
151
- Use block=false for non-blocking check of current status.
152
-
153
- Task IDs can be found using the /tasks command
154
- 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 J=$.task_id,Q=$.block??!0,X=$.timeout??30000;try{let V=`${Z.workingDirectory}/.claude/tasks/${J}.json`,K=Bun.file(V);if(!await K.exists())return{content:`Task not found: ${J}. Use /tasks to list available tasks.`,is_error:!0};let Y=await K.json();if(Q&&Y.status==="running"){let W=Date.now();while(Date.now()-W<X){await new Promise((z)=>setTimeout(z,1000));let H=Bun.file(V);if(await H.exists()){let z=await H.json();if(z.status!=="running")return{content:JSON.stringify({task_id:J,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:J,status:"timeout",message:`Task still running after ${X}ms`},null,2)}}return{content:JSON.stringify({task_id:J,status:Y.status,output:Y.output,error:Y.error,duration:Y.endTime?Y.endTime-Y.startTime:null},null,2)}}catch(V){return{content:`Error getting task output: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},eX={name:"AskUserQuestion",description:`Use this tool when you need to ask the user questions during execution.
155
-
156
- This allows you to:
157
- 1. Gather user preferences or requirements
158
- 2. Clarify ambiguous instructions
159
- 3. Get decisions on implementation choices
160
- 4. Offer choices to the user about what direction to take
161
-
162
- 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.
163
-
164
- The options array should have 2-4 options. Each option should be a distinct, mutually exclusive choice.
165
- The preview feature allows showing markdown content in a side-by-side layout.
166
-
167
- 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 J=$.questions;try{let Q=J.map((X,V)=>{let K=X.options.map((Y,W)=>{let H=` ${W+1}. ${Y.label}`;if(Y.description)H+=` - ${Y.description}`;return H}).join(`
168
- `);return`## Question ${V+1}: [${X.header}]
169
- ${X.question}
170
-
171
- Options:
172
- ${K}${X.multiSelect?`
173
- (multi-select enabled)`:""}`}).join(`
174
-
175
- ---
176
-
177
- `);return{content:JSON.stringify({type:"user_question",questions:J,formatted:Q,message:"Questions prepared for user response"},null,2)}}catch(Q){return{content:`Error preparing questions: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},tX={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.
178
-
179
- How This Tool Works:
180
- - You should have already written your plan to the plan file specified in the plan mode system message
181
- - This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote
182
- - This tool simply signals that you're done planning and ready for the user to review and approve
183
-
184
- When to Use This Tool:
185
- 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.
186
-
187
- 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.
188
-
189
- Examples:
190
- - "Search for and understand the implementation of vim mode" - Do NOT use this tool
191
- - "Help me implement yank mode for vim" - Use EnterPlanMode
192
-
193
- Important notes:
194
- - NEVER run additional commands to read or explore code, besides git bash commands
195
- - NEVER use the TodoWrite or Task tools
196
- - DO NOT commit files that likely contain secrets (.env, credentials.json, etc.)
197
- - 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 J=$.allowedPrompts;try{let Q=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(Q);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:Q,planLength:V.length,allowedPrompts:J||[],message:"Plan is ready for user review. ExitPlanMode will request user approval."},null,2)}}catch(Q){return{content:`Error entering plan mode: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},$V={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.
198
-
199
- This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote.
200
- This tool simply signals that you're done planning and ready for the user to review and approve.
201
-
202
- IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code.
203
- 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 J=$.allowedPrompts;try{let Q=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(Q);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:Q,planPreview:V.slice(0,500)+(V.length>500?"...":""),allowedPrompts:J||[],message:"Plan submitted for user approval."},null,2)}}catch(Q){return{content:`Error exiting plan mode: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},ZV={name:"Skill",description:`Execute a skill within the main conversation.
204
-
205
- When users ask you to perform tasks, check if any of the available skills match. Skills provide specialized capabilities and domain knowledge.
206
-
207
- 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.
208
-
209
- How to invoke:
210
- - Use this tool with the skill name and optional arguments
211
- - Examples:
212
- - skill: "commit" - invoke the commit skill
213
- - skill: "review-pr", args: "123" - invoke with arguments
214
- - Use fully qualified name for namespaced skills: skill: "ms-office-suite:pdf"
215
-
216
- Available skills are listed in system-reminder messages in the conversation.
217
- 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.
218
-
219
- Important:
220
- - NEVER mention a skill without actually calling this tool
221
- - Do not invoke a skill that is already running
222
- - 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:J,args:Q}=$;try{let X=`${Z.workingDirectory}/.claude/skills`,V=`${process.env.HOME||""}/.claude/skills`,K=[`${X}/${J}.md`,`${X}/${J}/skill.md`,`${V}/${J}.md`,`${V}/${J}/skill.md`],Y=null;for(let z of K)if(await Bun.file(z).exists()){Y=z;break}if(!Y)return{content:`Skill not found: ${J}. Available skills can be listed with /help.`,is_error:!0};let H=await Bun.file(Y).text();return{content:JSON.stringify({type:"skill_invocation",skill:J,args:Q,skillFile:Y,content:H,message:`Skill "${J}" 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}}}},JV={name:"TaskStop",description:`Stops a running background task by its ID.
223
- Takes a task_id parameter identifying the task to stop.
224
- Returns a success or failure status.
225
- 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 J=$.task_id;try{let Q=`${Z.workingDirectory}/.claude/tasks/${J}.json`,X=Bun.file(Q);if(!await X.exists())return{content:`Task not found: ${J}`,is_error:!0};let V=await X.json();if(V.status!=="running")return{content:JSON.stringify({task_id:J,status:V.status,message:`Task is already ${V.status}`},null,2)};return V.status="stopped",await Bun.write(Q,JSON.stringify(V,null,2)),{content:JSON.stringify({task_id:J,status:"stopped",message:"Task stopped successfully"},null,2)}}catch(Q){return{content:`Error stopping task: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},QV={name:"MultiEdit",description:`Performs atomic multi-file editing with rollback on failure.
226
-
227
- This tool allows you to edit multiple files simultaneously in a single atomic operation.
228
- If any edit fails, all changes are automatically rolled back to maintain consistency.
229
-
230
- Key features:
231
- - Validates all edits before applying (files exist, strings found)
232
- - Creates automatic backups before editing
233
- - Applies all edits atomically (all-or-nothing)
234
- - Rolls back on any failure
235
-
236
- Use this when you need to make coordinated changes across multiple files and want
237
- to ensure either all changes succeed or none are applied.
238
-
239
- 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 J=$.edits,Q=$.dry_run||!1;try{if(!Array.isArray(J)||J.length===0)return{content:"Error: edits must be a non-empty array",is_error:!0};let X=[];for(let Y=0;Y<J.length;Y++){let W=J[Y];if(!W||!W.file_path||!W.old_string||W.new_string===void 0)return{content:`Error: Edit at index ${Y} is missing required fields (file_path, old_string, new_string)`,is_error:!0};X.push({filePath:W.file_path,oldString:W.old_string,newString:W.new_string,replaceAll:W.replace_all||!1})}if(Q){let Y=w5(X),W=K2(X);if(W.length>0)return{content:JSON.stringify({valid:!1,errors:W,preview:Y},null,2),is_error:!0};return{content:JSON.stringify({valid:!0,preview:Y,total_files:Y.length,total_replacements:Y.reduce((H,z)=>H+z.replacementCount,0),message:"Dry run successful - no changes applied"},null,2)}}let V=K2(X);if(V.length>0)return{content:`Validation failed:
240
- ${V.join(`
241
- `)}`,is_error:!0};let K=R5(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}}}},XV={name:"NotebookEdit",description:`Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source.
242
-
243
- 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:J,cell_id:Q,cell_number:X,new_source:V}=$,K=$.cell_type||"code",Y=$.edit_mode||"replace";try{let W=Bun.file(J);if(!await W.exists())return{content:`Error: Notebook not found: ${J}`,is_error:!0};let H=await W.json();if(!H.cells||!Array.isArray(H.cells))return{content:"Error: Invalid notebook format - no cells array",is_error:!0};let z;if(Q){if(z=H.cells.findIndex((G)=>G.id===Q),z===-1)return{content:`Error: Cell with ID "${Q}" not found`,is_error:!0}}else if(X!==void 0){if(z=X,z<0||z>=H.cells.length)if(Y==="insert")z=H.cells.length;else return{content:`Error: Cell number ${z} out of range (0-${H.cells.length-1})`,is_error:!0}}else if(Y!=="insert")return{content:"Error: Must specify either cell_id or cell_number",is_error:!0};else z=H.cells.length;switch(Y){case"delete":{H.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}:{}};H.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=H.cells[z];if(!G)return{content:`Error: Cell at index ${z} not found`,is_error:!0};H.cells[z]={...G,source:V,cell_type:K,...K==="code"?{execution_count:null}:{}};break}}return await Bun.write(J,JSON.stringify(H,null,1)),{content:JSON.stringify({success:!0,message:`Successfully ${Y}d cell in ${J}`,cellCount:H.cells.length})}}catch(W){return{content:`Error editing notebook: ${W instanceof Error?W.message:String(W)}`,is_error:!0}}}},VV={name:"tempglmvision",description:"Analyze images using GLM-4.6V vision model. Use this tool when you need to analyze, describe, or extract information from images. Supports PNG, JPG, JPEG, GIF, and WEBP formats. Accepts both local file paths and remote URLs.",input_schema:{type:"object",properties:{imageSource:{type:"string",description:"Local file path or remote URL to the image (supports PNG, JPG, JPEG, GIF, WEBP)"},prompt:{type:"string",description:"Detailed text prompt describing what to analyze, extract, or understand from the image."}},required:["imageSource","prompt"]},handler:async($,Z)=>{let{imageSource:J,prompt:Q}=$;try{let X=process.env.ANTHROPIC_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN;if(!X)return{content:"Error: No API key found. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.",is_error:!0};let V=process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com",K,Y;if(J.startsWith("http://")||J.startsWith("https://")){let A=await fetch(J);if(!A.ok)return{content:`Error fetching image: ${A.status} ${A.statusText}`,is_error:!0};K=Buffer.from(await A.arrayBuffer()).toString("base64");let B=A.headers.get("content-type");if(B?.includes("image/png"))Y="image/png";else if(B?.includes("image/gif"))Y="image/gif";else if(B?.includes("image/webp"))Y="image/webp";else Y="image/jpeg"}else{let A=Bun.file(J);if(!await A.exists())return{content:`Error: Image file not found: ${J}`,is_error:!0};K=Buffer.from(await A.arrayBuffer()).toString("base64");let B=i6.extname(J).toLowerCase();if(B===".png")Y="image/png";else if(B===".gif")Y="image/gif";else if(B===".webp")Y="image/webp";else Y="image/jpeg"}let W={model:"glm-5",max_tokens:4096,messages:[{role:"user",content:[{type:"image",source:{type:"base64",media_type:Y,data:K}},{type:"text",text:Q}]}]},H=await fetch(`${V}/v1/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":X,"anthropic-version":"2023-06-01"},body:JSON.stringify(W),signal:Z.abortSignal});if(!H.ok){let A=await H.text();return{content:`Vision API error: ${H.status} - ${A}`,is_error:!0}}let z=await H.json();if(z.error)return{content:`Vision API error: ${z.error.message}`,is_error:!0};return{content:z.content?.filter((A)=>A.type==="text").map((A)=>A.text).join(`
244
- `)||"No text content in vision response"}}catch(X){return{content:`Error analyzing image: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},KV={name:"mcp__4_5v_mcp__analyze_image",description:"Analyze an image using advanced AI vision models with comprehensive understanding capabilities. Supports PNG, JPG, JPEG, GIF, and WEBP formats. Accepts both local file paths and remote URLs.",input_schema:{type:"object",properties:{imageSource:{type:"string",description:"Local file path or remote URL to the image (supports PNG, JPG, JPEG, GIF, WEBP)"},prompt:{type:"string",description:"Detailed text prompt describing what to analyze, extract, or understand from the image. For front-end code replication, describe layout structure, color style, main components, and interactive elements."}},required:["imageSource","prompt"]},handler:async($,Z)=>{let{imageSource:J,prompt:Q}=$;try{let X=process.env.ANTHROPIC_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN;if(!X)return{content:"Error: No API key found. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.",is_error:!0};let V=process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com",K,Y;if(J.startsWith("http://")||J.startsWith("https://")){let A=await fetch(J);if(!A.ok)return{content:`Error fetching image: ${A.status} ${A.statusText}`,is_error:!0};K=Buffer.from(await A.arrayBuffer()).toString("base64");let B=A.headers.get("content-type");if(B?.includes("image/png"))Y="image/png";else if(B?.includes("image/gif"))Y="image/gif";else if(B?.includes("image/webp"))Y="image/webp";else Y="image/jpeg"}else{let A=Bun.file(J);if(!await A.exists())return{content:`Error: Image file not found: ${J}`,is_error:!0};K=Buffer.from(await A.arrayBuffer()).toString("base64");let B=i6.extname(J).toLowerCase();if(B===".png")Y="image/png";else if(B===".gif")Y="image/gif";else if(B===".webp")Y="image/webp";else Y="image/jpeg"}let W={model:"glm-5",max_tokens:4096,messages:[{role:"user",content:[{type:"image",source:{type:"base64",media_type:Y,data:K}},{type:"text",text:Q}]}]},H=await fetch(`${V}/v1/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":X,"anthropic-version":"2023-06-01"},body:JSON.stringify(W),signal:Z.abortSignal});if(!H.ok){let A=await H.text();return{content:`Vision API error: ${H.status} - ${A}`,is_error:!0}}let z=await H.json();if(z.error)return{content:`Vision API error: ${z.error.message}`,is_error:!0};return{content:z.content?.filter((A)=>A.type==="text").map((A)=>A.text).join(`
245
- `)||"No text content in vision response"}}catch(X){return{content:`Error analyzing image: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},YV=[mX,lX,pX,QV,rX,nX,iX,oX,sX,JV,eX,tX,$V,ZV,XV,KV,VV];function MW($){return YV.find((Z)=>Z.name===$)}import{spawn as WV}from"child_process";import t2 from"ws";class $5{static MCPClient=$5;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=WV(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,J)=>{let Q={...this.config.headers},X=new t2($,{headers:Q,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}`),J(V)})}),X.on("message",(V,K)=>{let Y=K?V.toString():V.toString();this.handleData(Y)}),X.on("error",(V)=>{if(this.log(`WebSocket error: ${V.message}`),!this.connected)J(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[Y,W]of this.pendingRequests)this.pendingRequests.delete(Y),W.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(`
246
- `)}}async request($,Z){let J=++this.requestId,Q={jsonrpc:"2.0",id:J,method:$,params:Z};return new Promise((X,V)=>{this.pendingRequests.set(J,{resolve:X,reject:V});let K=JSON.stringify(Q);if(this.websocket&&this.websocket.readyState===t2.OPEN)this.websocket.send(K);else if(this.process?.stdin?.writable)this.process.stdin.write(K+`
247
- `);else{this.pendingRequests.delete(J),V(Error("No active connection to send request"));return}setTimeout(()=>{if(this.pendingRequests.has(J))this.pendingRequests.delete(J),V(Error(`Request timeout for ${$}`))},this.config.timeout||120000)})}notify($,Z){let Q=JSON.stringify({jsonrpc:"2.0",method:$,params:Z});if(this.websocket&&this.websocket.readyState===t2.OPEN)this.websocket.send(Q);else if(this.process?.stdin?.writable)this.process.stdin.write(Q+`
248
- `)}handleData($){this.buffer+=$;let Z=this.buffer.split(`
249
- `);this.buffer=Z.pop()||"";for(let J of Z){if(!J.trim())continue;try{let Q=JSON.parse(J);if(Q.id!==void 0){let X=this.pendingRequests.get(Q.id);if(X)if(this.pendingRequests.delete(Q.id),Q.error)X.reject(Error(Q.error.message));else X.resolve(Q.result)}}catch(Q){this.log(`Parse error: ${Q}`)}}}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 TW($,Z){let J=new Map;for(let[Q,X]of Object.entries($)){if(X.disabled)continue;let V=new $5({name:Q,config:X,onLog:Z});try{await V.connect(),J.set(Q,V)}catch(K){let Y=K instanceof Error?K.message:String(K);Z?.(`[MCP:${Q}] Failed to connect: ${Y}`)}}return J}import{spawn as HV}from"child_process";class qV{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,J]of Object.entries($))for(let Q of J)this.register(Z,Q)}async execute($,Z){let J=this.hooks.get($);if(!J||J.length===0)return{decision:"allow"};let Q={...Z,event:$,timestamp:Date.now()};for(let X of J){if(X.enabled===!1)continue;let V=await this.executeHook(X,Q);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 J=$.timeout||this.timeout;try{return await new Promise((X,V)=>{let K=HV($.command,[],{shell:!0,stdio:["pipe","pipe","pipe"]}),Y="",W="";K.stdout?.on("data",(H)=>{Y+=H.toString()}),K.stderr?.on("data",(H)=>{W+=H.toString()}),K.on("close",(H)=>{if(H===0)try{let z=JSON.parse(Y);X(z)}catch{X({decision:"allow"})}else if(H===1)X({decision:"deny",reason:W||"Hook denied execution"});else if(H===2)X({decision:"block",reason:W||"Hook blocked execution"});else X({decision:"allow"})}),K.on("error",(H)=>{X({decision:"allow",reason:`Hook error: ${H.message}`})}),K.stdin?.write(JSON.stringify(Z)),K.stdin?.end(),setTimeout(()=>{K.kill(),X({decision:"allow",reason:"Hook timeout"})},J)})}catch(Q){return{decision:"allow",reason:`Hook execution failed: ${Q instanceof Error?Q.message:String(Q)}`}}}getHooks($){return this.hooks.get($)||[]}clear($){if($)this.hooks.delete($);else this.hooks.clear()}}var vW={validateWrite:{event:"PreToolUse",command:`node -e '
250
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
251
- if (input.tool_name === "Write") {
252
- const path = input.tool_input.file_path;
253
- if (path.includes("..") || path.startsWith("/etc/")) {
254
- console.log(JSON.stringify({ decision: "deny", reason: "Unsafe path" }));
255
- process.exit(1);
256
- }
257
- }
258
- console.log(JSON.stringify({ decision: "allow" }));
259
- '`,timeout:5000,enabled:!1},logToolUse:{event:"PostToolUse",command:`node -e '
260
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
261
- console.error(\`[LOG] Tool: \${input.tool_name}\`);
262
- console.log(JSON.stringify({ decision: "allow" }));
263
- '`,timeout:5000,enabled:!1}},OW={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."},yW={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as zV,existsSync as m9,readdirSync as GV}from"fs";import{join as jV}from"path";function UV($,Z="project"){if(!m9($))return null;let J=zV($,"utf-8"),Q=$.split("/").pop()?.replace(/\.md$/i,"")||"unknown",X=J.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!X)return{path:$,name:Q,description:"",prompt:J.trim(),source:Z};let V=X[1]??"",K=X[2]??"",Y=AV(V);return{path:$,name:Y.name||Q,description:Y.description||"",prompt:K.trim(),tools:Y.tools,model:Y.model,color:Y.color,source:Z}}function AV($){let Z={},J=$.split(`
264
- `);for(let Q of J){let X=Q.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 BV{skills=new Map;loadFromDirectory($,Z="project"){if(!m9($))return 0;let J=0,Q=GV($);for(let X of Q)if(X.endsWith(".md")){let V=UV(jV($,X),Z);if(V)this.skills.set(V.name,V),J++}return J}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 uW($){return`
265
- <skill-loading>
266
- You are operating with the "${$.name}" skill loaded.
267
-
268
- ${$.description?`Description: ${$.description}
269
- `:""}
270
- ${$.prompt}
271
- </skill-loading>
272
- `.trim()}var dW=[{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.
273
-
274
- Steps:
275
- 1. Run \`git diff --staged\` to see staged changes
276
- 2. Run \`git log --oneline -5\` to understand commit message style
277
- 3. Create a commit message following conventional commits format
278
- 4. Include "Co-Authored-By: Claude <noreply@anthropic.com>" if applicable
279
- 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.
280
-
281
- Steps:
282
- 1. Use \`gh pr view\` to get PR details
283
- 2. Use \`gh pr diff\` to see the changes
284
- 3. Analyze the code for:
285
- - Bugs and potential issues
286
- - Code quality and style
287
- - Test coverage
288
- - Documentation
289
- 4. Provide constructive feedback
290
- 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.
291
-
292
- MCP servers enable LLMs to interact with external services through well-designed tools.
293
-
294
- Key concepts:
295
- 1. Use FastMCP (Python) or MCP SDK (TypeScript)
296
- 2. Define tools with clear input schemas
297
- 3. Return structured content
298
- 4. Handle errors gracefully
299
-
300
- Transport types:
301
- - stdio: Local process communication
302
- - HTTP: REST API with JSON-RPC
303
- - SSE: Server-Sent Events for streaming
304
- - 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.
305
-
306
- Hooks are user-defined shell commands that execute at specific points during Claude Code's lifecycle.
307
-
308
- Available events:
309
- - PreToolUse: Before a tool executes
310
- - PostToolUse: After a tool succeeds
311
- - PostToolUseFailure: After a tool fails
312
- - Stop: When agent stops
313
- - UserPromptSubmit: When user submits prompt
314
- - SessionStart/SessionEnd: Session lifecycle
315
-
316
- Exit codes:
317
- - 0: Allow execution
318
- - 1: Deny and show stderr
319
- - 2: Block silently`,tools:["Read","Write","Edit"],model:"sonnet",source:"built-in"}];function mW($){return $.match(/^\/(\w+)(?:\s+(.*))?$/)?.[1]??null}function cW($){return $.match(/^\/\w+\s+(.*)$/)?.[1]??""}import{spawn as Z5}from"child_process";import{mkdirSync as c9,rmSync as LV,existsSync as l9,readFileSync as _V}from"fs";import{join as Y6}from"path";class wV{teams=new Map;teammates=new Map;messageQueue=new Map;storagePath;constructor($="~/.claude/teams"){if(this.storagePath=$.replace("~",process.env.HOME||""),!l9(this.storagePath))c9(this.storagePath,{recursive:!0});this.loadTeams()}createTeam($){let Z={...$,status:"active"};this.teams.set($.name,Z);for(let J of $.teammates)this.teammates.set(J.teammateId,J);return this.persistTeam(Z).catch((J)=>{console.error(`Failed to persist team ${$.name}:`,J)}),Z}getTeam($){return this.teams.get($)}listTeams(){return Array.from(this.teams.values())}deleteTeam($){let Z=this.teams.get($);if(Z){for(let Q of Z.teammates)this.teammates.delete(Q.teammateId),this.messageQueue.delete(Q.teammateId);this.teams.delete($);let J=Y6(this.storagePath,$);try{LV(J,{recursive:!0,force:!0})}catch(Q){console.error(`Failed to delete team directory ${J}:`,Q)}}}getTeammate($){return this.teammates.get($)}updateTeammateStatus($,Z){let J=this.teammates.get($);if(J)J.status=Z}async spawnTeammate($,Z={}){let{session:J,workingDir:Q=process.cwd()}=Z;if(!process.env.TMUX)await this.spawnInTerminal($,{session:J,workingDir:Q});else await this.spawnInTmux($,{session:J,workingDir:Q});this.updateTeammateStatus($.teammateId,"in_progress")}async spawnInTerminal($,Z){let J=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName,"--agent-color",$.color];if($.planModeRequired)J.push("--permission-mode","plan");if(process.platform==="darwin"){let Q=`
320
- tell application "Terminal"
321
- do script "cd ${Z.workingDir} && ${J.join(" ")}"
322
- activate
323
- end tell
324
- `;Z5("osascript",["-e",Q])}else Z5("xterm",["-e",J.join(" ")])}async spawnInTmux($,Z){let J=Z.session||process.env.TMUX?.split(",")[0]?.split(":")[0]||"claude";await this.tmuxCommand(["split-window","-t",J,"-c",Z.workingDir]);let Q=await this.tmuxCommand(["display-message","-p","#{pane_id}"]);if(Q)$.paneId=Q.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 J=Z5("tmux",$),Q="";J.stdout?.on("data",(X)=>{Q+=X.toString()}),J.on("close",()=>{Z(Q)})})}broadcast($,Z,J){let Q=this.teams.get($);if(!Q)return;let X={type:"broadcast",from:J||"system",content:Z,timestamp:Date.now()};for(let V of Q.teammates){if(J&&V.teammateId===J)continue;let K=this.messageQueue.get(V.teammateId)||[];K.push(X),this.messageQueue.set(V.teammateId,K)}}sendDirect($,Z,J){let Q={type:"direct",from:Z,to:$,content:J,timestamp:Date.now()},X=this.messageQueue.get($)||[];X.push(Q),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=Y6(this.storagePath,$.name),J=Y6(Z,"config.json");if(!l9(Z))c9(Z,{recursive:!0});await Bun.write(Y6(Z,".gitkeep"),"");let Q={name:$.name,description:$.description,teammates:$.teammates,taskListId:$.taskListId,status:$.status,coordination:$.coordination,updatedAt:Date.now()};await Bun.write(J,JSON.stringify(Q,null,2))}loadTeams(){let $=new Bun.Glob("**/config.json");try{let Z=Array.from($.scanSync(this.storagePath));for(let J of Z)try{let Q=Y6(this.storagePath,J);if(Bun.file(Q).size===0)continue;let K=_V(Q,"utf-8"),Y=JSON.parse(K);if(!Y.name||!Y.teammates||!Array.isArray(Y.teammates))continue;let W={name:Y.name,description:Y.description||"",teammates:Y.teammates,taskListId:Y.taskListId||"",status:Y.status||"active",coordination:Y.coordination||{dependencyOrder:[],communicationProtocol:"broadcast",taskAssignmentStrategy:"manual"}};this.teams.set(W.name,W);for(let H of W.teammates)this.teammates.set(H.teammateId,H)}catch(Q){}}catch(Z){if(Z.code!=="ENOENT");}}async persistAllTeams(){let $=Array.from(this.teams.values()).map((Z)=>this.persistTeam(Z));await Promise.all($)}}var nW={architect:($)=>({name:"architect",teamName:$,color:"blue",prompt:`You are an architect on the ${$} team.
325
- Your role is to design and plan the technical architecture.
326
- Focus on:
327
- - System design and component relationships
328
- - API contracts and interfaces
329
- - Data models and schemas
330
- - Trade-offs and design decisions`,planModeRequired:!0,status:"pending"}),implementer:($)=>({name:"implementer",teamName:$,color:"green",prompt:`You are an implementer on the ${$} team.
331
- Your role is to write clean, working code based on the architecture.
332
- Focus on:
333
- - Implementing the designed architecture
334
- - Writing tests
335
- - Following coding standards
336
- - Handling edge cases`,planModeRequired:!1,status:"pending"}),reviewer:($)=>({name:"reviewer",teamName:$,color:"yellow",prompt:`You are a code reviewer on the ${$} team.
337
- Your role is to review code changes and provide feedback.
338
- Focus on:
339
- - Code quality and readability
340
- - Potential bugs and issues
341
- - Performance considerations
342
- - Test coverage`,planModeRequired:!1,status:"pending"}),tester:($)=>({name:"tester",teamName:$,color:"orange",prompt:`You are a tester on the ${$} team.
343
- Your role is to ensure features work correctly.
344
- Focus on:
345
- - Writing comprehensive tests
346
- - Finding edge cases
347
- - Verifying requirements
348
- - Reporting bugs`,planModeRequired:!1,status:"pending"})};function RV(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function iW($){return{...$,teammateId:RV(),status:"pending"}}
349
- export{v as a,q6 as b,o9 as c,NV as d,V5 as e,K5 as f,PV as g,Z7 as h,J7 as i,Q7 as j,X7 as k,H5 as l,Y7 as m,W7 as n,s6 as o,e6 as p,xV as q,kV as r,vV as s,aV as t,X2 as u,rV as v,nV as w,iV as x,C7 as y,N7 as z,tV as A,L5 as B,XK as C,V4 as D,VK as E,KK as F,YK as G,WK as H,K2 as I,w5 as J,R5 as K,G6 as L,HK as M,qK as N,zK as O,GK as P,jK as Q,UK as R,AK as S,BK as T,LK as U,_K as V,wK as W,RK as X,CK as Y,NK as Z,mX as _,lX as $,pX as aa,rX as ba,nX as ca,iX as da,oX as ea,sX as fa,eX as ga,tX as ha,$V as ia,ZV as ja,JV as ka,QV as la,XV as ma,VV as na,KV as oa,YV as pa,MW as qa,$5 as ra,TW as sa,qV as ta,vW as ua,OW as va,yW as wa,UV as xa,BV as ya,uW as za,dW as Aa,mW as Ba,cW as Ca,wV as Da,nW as Ea,RV as Fa,iW as Ga};