@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,345 +0,0 @@
1
- // @bun
2
- var g9=Object.create;var{getPrototypeOf:u9,defineProperty:s2,getOwnPropertyNames:d9}=Object;var m9=Object.prototype.hasOwnProperty;var e2=($,Z,Q)=>{Q=$!=null?g9(u9($)):{};let J=Z||!$||!$.__esModule?s2(Q,"default",{value:$,enumerable:!0}):Q;for(let X of d9($))if(!m9.call(J,X))s2(J,X,{get:()=>$[X],enumerable:!0});return J};var T=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var y=import.meta.require;var M0=T((zK,W1)=>{/*!
3
- Copyright 2013 Lovell Fuller and others.
4
- SPDX-License-Identifier: Apache-2.0
5
- */var q1=($)=>typeof $<"u"&&$!==null,GZ=($)=>typeof $==="object",jZ=($)=>Object.prototype.toString.call($)==="[object Object]",UZ=($)=>typeof $==="function",AZ=($)=>typeof $==="boolean",BZ=($)=>$ instanceof Buffer,LZ=($)=>{if(q1($))switch($.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},_Z=($)=>$ instanceof ArrayBuffer,wZ=($)=>typeof $==="string"&&$.length>0,FZ=($)=>typeof $==="number"&&!Number.isNaN($),RZ=($)=>Number.isInteger($),CZ=($,Z,Q)=>$>=Z&&$<=Q,NZ=($,Z)=>Z.includes($),PZ=($,Z,Q)=>Error(`Expected ${Z} for ${$} but received ${Q} of type ${typeof Q}`),DZ=($,Z)=>{return Z.message=$.message,Z};W1.exports={defined:q1,object:GZ,plainObject:jZ,fn:UZ,bool:AZ,buffer:BZ,typedArray:LZ,arrayBuffer:_Z,string:wZ,number:FZ,integer:RZ,inRange:CZ,inArray:NZ,invalidParameterError:PZ,nativeError:DZ}});var G1=T((GK,z1)=>{var H1=()=>process.platform==="linux",M6=null,IZ=()=>{if(!M6)if(H1()&&process.report){let $=process.report.excludeNetwork;process.report.excludeNetwork=!0,M6=process.report.getReport(),process.report.excludeNetwork=$}else M6={};return M6};z1.exports={isLinux:H1,getReport:IZ}});var U1=T((jK,j1)=>{var _4=y("fs"),MZ=($)=>{let Z=_4.openSync($,"r"),Q=Buffer.alloc(2048),J=_4.readSync(Z,Q,0,2048,0);return _4.close(Z,()=>{}),Q.subarray(0,J)},SZ=($)=>new Promise((Z,Q)=>{_4.open($,"r",(J,X)=>{if(J)Q(J);else{let V=Buffer.alloc(2048);_4.read(X,V,0,2048,0,(Y,K)=>{Z(V.subarray(0,K)),_4.close(X,()=>{})})}})});j1.exports={LDD_PATH:"/usr/bin/ldd",SELF_PATH:"/proc/self/exe",readFileSync:MZ,readFile:SZ}});var B1=T((UK,A1)=>{var EZ=($)=>{if($.length<64)return null;if($.readUInt32BE(0)!==2135247942)return null;if($.readUInt8(4)!==2)return null;if($.readUInt8(5)!==1)return null;let Z=$.readUInt32LE(32),Q=$.readUInt16LE(54),J=$.readUInt16LE(56);for(let X=0;X<J;X++){let V=Z+X*Q;if($.readUInt32LE(V)===3){let K=$.readUInt32LE(V+8),q=$.readUInt32LE(V+32);return $.subarray(K,K+q).toString().replace(/\0.*$/g,"")}}return null};A1.exports={interpreterPath:EZ}});var E6=T((AK,v1)=>{var _1=y("child_process"),{isLinux:w4,getReport:w1}=G1(),{LDD_PATH:S6,SELF_PATH:F1,readFile:C2,readFileSync:N2}=U1(),{interpreterPath:R1}=B1(),S0,E0,T0,o0="",C1=()=>{if(!o0)return new Promise(($)=>{_1.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(Z,Q)=>{o0=Z?" ":Q,$(o0)})});return o0},N1=()=>{if(!o0)try{o0=_1.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch($){o0=" "}return o0},d0="glibc",P1=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,Y4="musl",TZ=($)=>$.includes("libc.musl-")||$.includes("ld-musl-"),D1=()=>{let $=w1();if($.header&&$.header.glibcVersionRuntime)return d0;if(Array.isArray($.sharedObjects)){if($.sharedObjects.some(TZ))return Y4}return null},I1=($)=>{let[Z,Q]=$.split(/[\r\n]+/);if(Z&&Z.includes(d0))return d0;if(Q&&Q.includes(Y4))return Y4;return null},M1=($)=>{if($){if($.includes("/ld-musl-"))return Y4;else if($.includes("/ld-linux-"))return d0}return null},S1=($)=>{if($=$.toString(),$.includes("musl"))return Y4;if($.includes("GNU C Library"))return d0;return null},xZ=async()=>{if(E0!==void 0)return E0;E0=null;try{let $=await C2(S6);E0=S1($)}catch($){}return E0},kZ=()=>{if(E0!==void 0)return E0;E0=null;try{let $=N2(S6);E0=S1($)}catch($){}return E0},vZ=async()=>{if(S0!==void 0)return S0;S0=null;try{let $=await C2(F1),Z=R1($);S0=M1(Z)}catch($){}return S0},OZ=()=>{if(S0!==void 0)return S0;S0=null;try{let $=N2(F1),Z=R1($);S0=M1(Z)}catch($){}return S0},E1=async()=>{let $=null;if(w4()){if($=await vZ(),!$){if($=await xZ(),!$)$=D1();if(!$){let Z=await C1();$=I1(Z)}}}return $},T1=()=>{let $=null;if(w4()){if($=OZ(),!$){if($=kZ(),!$)$=D1();if(!$){let Z=N1();$=I1(Z)}}}return $},yZ=async()=>w4()&&await E1()!==d0,bZ=()=>w4()&&T1()!==d0,fZ=async()=>{if(T0!==void 0)return T0;T0=null;try{let Z=(await C2(S6)).match(P1);if(Z)T0=Z[1]}catch($){}return T0},hZ=()=>{if(T0!==void 0)return T0;T0=null;try{let Z=N2(S6).match(P1);if(Z)T0=Z[1]}catch($){}return T0},x1=()=>{let $=w1();if($.header&&$.header.glibcVersionRuntime)return $.header.glibcVersionRuntime;return null},L1=($)=>$.trim().split(/\s+/)[1],k1=($)=>{let[Z,Q,J]=$.split(/[\r\n]+/);if(Z&&Z.includes(d0))return L1(Z);if(Q&&J&&Q.includes(Y4))return L1(J);return null},gZ=async()=>{let $=null;if(w4()){if($=await fZ(),!$)$=x1();if(!$){let Z=await C1();$=k1(Z)}}return $},uZ=()=>{let $=null;if(w4()){if($=hZ(),!$)$=x1();if(!$){let Z=N1();$=k1(Z)}}return $};v1.exports={GLIBC:d0,MUSL:Y4,family:E1,familySync:T1,isNonGlibcLinux:yZ,isNonGlibcLinuxSync:bZ,version:gZ,versionSync:uZ}});var s4=T((BK,O1)=>{var dZ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};O1.exports=dZ});var T6=T((LK,y1)=>{var mZ=Number.MAX_SAFE_INTEGER||9007199254740991,cZ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];y1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:mZ,RELEASE_TYPES:cZ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var e4=T((x0,b1)=>{var{MAX_SAFE_COMPONENT_LENGTH:P2,MAX_SAFE_BUILD_LENGTH:lZ,MAX_LENGTH:pZ}=T6(),aZ=s4();x0=b1.exports={};var rZ=x0.re=[],nZ=x0.safeRe=[],C=x0.src=[],iZ=x0.safeSrc=[],N=x0.t={},oZ=0,D2="[a-zA-Z0-9-]",sZ=[["\\s",1],["\\d",pZ],[D2,lZ]],eZ=($)=>{for(let[Z,Q]of sZ)$=$.split(`${Z}*`).join(`${Z}{0,${Q}}`).split(`${Z}+`).join(`${Z}{1,${Q}}`);return $},S=($,Z,Q)=>{let J=eZ(Z),X=oZ++;aZ($,X,Z),N[$]=X,C[X]=Z,iZ[X]=J,rZ[X]=new RegExp(Z,Q?"g":void 0),nZ[X]=new RegExp(J,Q?"g":void 0)};S("NUMERICIDENTIFIER","0|[1-9]\\d*");S("NUMERICIDENTIFIERLOOSE","\\d+");S("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${D2}*`);S("MAINVERSION",`(${C[N.NUMERICIDENTIFIER]})\\.(${C[N.NUMERICIDENTIFIER]})\\.(${C[N.NUMERICIDENTIFIER]})`);S("MAINVERSIONLOOSE",`(${C[N.NUMERICIDENTIFIERLOOSE]})\\.(${C[N.NUMERICIDENTIFIERLOOSE]})\\.(${C[N.NUMERICIDENTIFIERLOOSE]})`);S("PRERELEASEIDENTIFIER",`(?:${C[N.NONNUMERICIDENTIFIER]}|${C[N.NUMERICIDENTIFIER]})`);S("PRERELEASEIDENTIFIERLOOSE",`(?:${C[N.NONNUMERICIDENTIFIER]}|${C[N.NUMERICIDENTIFIERLOOSE]})`);S("PRERELEASE",`(?:-(${C[N.PRERELEASEIDENTIFIER]}(?:\\.${C[N.PRERELEASEIDENTIFIER]})*))`);S("PRERELEASELOOSE",`(?:-?(${C[N.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${C[N.PRERELEASEIDENTIFIERLOOSE]})*))`);S("BUILDIDENTIFIER",`${D2}+`);S("BUILD",`(?:\\+(${C[N.BUILDIDENTIFIER]}(?:\\.${C[N.BUILDIDENTIFIER]})*))`);S("FULLPLAIN",`v?${C[N.MAINVERSION]}${C[N.PRERELEASE]}?${C[N.BUILD]}?`);S("FULL",`^${C[N.FULLPLAIN]}$`);S("LOOSEPLAIN",`[v=\\s]*${C[N.MAINVERSIONLOOSE]}${C[N.PRERELEASELOOSE]}?${C[N.BUILD]}?`);S("LOOSE",`^${C[N.LOOSEPLAIN]}$`);S("GTLT","((?:<|>)?=?)");S("XRANGEIDENTIFIERLOOSE",`${C[N.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);S("XRANGEIDENTIFIER",`${C[N.NUMERICIDENTIFIER]}|x|X|\\*`);S("XRANGEPLAIN",`[v=\\s]*(${C[N.XRANGEIDENTIFIER]})(?:\\.(${C[N.XRANGEIDENTIFIER]})(?:\\.(${C[N.XRANGEIDENTIFIER]})(?:${C[N.PRERELEASE]})?${C[N.BUILD]}?)?)?`);S("XRANGEPLAINLOOSE",`[v=\\s]*(${C[N.XRANGEIDENTIFIERLOOSE]})(?:\\.(${C[N.XRANGEIDENTIFIERLOOSE]})(?:\\.(${C[N.XRANGEIDENTIFIERLOOSE]})(?:${C[N.PRERELEASELOOSE]})?${C[N.BUILD]}?)?)?`);S("XRANGE",`^${C[N.GTLT]}\\s*${C[N.XRANGEPLAIN]}$`);S("XRANGELOOSE",`^${C[N.GTLT]}\\s*${C[N.XRANGEPLAINLOOSE]}$`);S("COERCEPLAIN",`(^|[^\\d])(\\d{1,${P2}})(?:\\.(\\d{1,${P2}}))?(?:\\.(\\d{1,${P2}}))?`);S("COERCE",`${C[N.COERCEPLAIN]}(?:$|[^\\d])`);S("COERCEFULL",C[N.COERCEPLAIN]+`(?:${C[N.PRERELEASE]})?(?:${C[N.BUILD]})?(?:$|[^\\d])`);S("COERCERTL",C[N.COERCE],!0);S("COERCERTLFULL",C[N.COERCEFULL],!0);S("LONETILDE","(?:~>?)");S("TILDETRIM",`(\\s*)${C[N.LONETILDE]}\\s+`,!0);x0.tildeTrimReplace="$1~";S("TILDE",`^${C[N.LONETILDE]}${C[N.XRANGEPLAIN]}$`);S("TILDELOOSE",`^${C[N.LONETILDE]}${C[N.XRANGEPLAINLOOSE]}$`);S("LONECARET","(?:\\^)");S("CARETTRIM",`(\\s*)${C[N.LONECARET]}\\s+`,!0);x0.caretTrimReplace="$1^";S("CARET",`^${C[N.LONECARET]}${C[N.XRANGEPLAIN]}$`);S("CARETLOOSE",`^${C[N.LONECARET]}${C[N.XRANGEPLAINLOOSE]}$`);S("COMPARATORLOOSE",`^${C[N.GTLT]}\\s*(${C[N.LOOSEPLAIN]})$|^$`);S("COMPARATOR",`^${C[N.GTLT]}\\s*(${C[N.FULLPLAIN]})$|^$`);S("COMPARATORTRIM",`(\\s*)${C[N.GTLT]}\\s*(${C[N.LOOSEPLAIN]}|${C[N.XRANGEPLAIN]})`,!0);x0.comparatorTrimReplace="$1$2$3";S("HYPHENRANGE",`^\\s*(${C[N.XRANGEPLAIN]})\\s+-\\s+(${C[N.XRANGEPLAIN]})\\s*$`);S("HYPHENRANGELOOSE",`^\\s*(${C[N.XRANGEPLAINLOOSE]})\\s+-\\s+(${C[N.XRANGEPLAINLOOSE]})\\s*$`);S("STAR","(<|>)?=?\\s*\\*");S("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");S("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var x6=T((_K,f1)=>{var tZ=Object.freeze({loose:!0}),$Q=Object.freeze({}),ZQ=($)=>{if(!$)return $Q;if(typeof $!=="object")return tZ;return $};f1.exports=ZQ});var d1=T((wK,u1)=>{var h1=/^[0-9]+$/,g1=($,Z)=>{if(typeof $==="number"&&typeof Z==="number")return $===Z?0:$<Z?-1:1;let Q=h1.test($),J=h1.test(Z);if(Q&&J)$=+$,Z=+Z;return $===Z?0:Q&&!J?-1:J&&!Q?1:$<Z?-1:1},QQ=($,Z)=>g1(Z,$);u1.exports={compareIdentifiers:g1,rcompareIdentifiers:QQ}});var F4=T((FK,c1)=>{var k6=s4(),{MAX_LENGTH:m1,MAX_SAFE_INTEGER:v6}=T6(),{safeRe:O6,t:y6}=e4(),JQ=x6(),{compareIdentifiers:I2}=d1();class F0{constructor($,Z){if(Z=JQ(Z),$ instanceof F0)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>m1)throw TypeError(`version is longer than ${m1} characters`);k6("SemVer",$,Z),this.options=Z,this.loose=!!Z.loose,this.includePrerelease=!!Z.includePrerelease;let Q=$.trim().match(Z.loose?O6[y6.LOOSE]:O6[y6.FULL]);if(!Q)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+Q[1],this.minor=+Q[2],this.patch=+Q[3],this.major>v6||this.major<0)throw TypeError("Invalid major version");if(this.minor>v6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>v6||this.patch<0)throw TypeError("Invalid patch version");if(!Q[4])this.prerelease=[];else this.prerelease=Q[4].split(".").map((J)=>{if(/^[0-9]+$/.test(J)){let X=+J;if(X>=0&&X<v6)return X}return J});this.build=Q[5]?Q[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare($){if(k6("SemVer.compare",this.version,this.options,$),!($ instanceof F0)){if(typeof $==="string"&&$===this.version)return 0;$=new F0($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof F0))$=new F0($,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 F0))$=new F0($,this.options);if(this.prerelease.length&&!$.prerelease.length)return-1;else if(!this.prerelease.length&&$.prerelease.length)return 1;else if(!this.prerelease.length&&!$.prerelease.length)return 0;let Z=0;do{let Q=this.prerelease[Z],J=$.prerelease[Z];if(k6("prerelease compare",Z,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return I2(Q,J)}while(++Z)}compareBuild($){if(!($ instanceof F0))$=new F0($,this.options);let Z=0;do{let Q=this.build[Z],J=$.build[Z];if(k6("build compare",Z,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return I2(Q,J)}while(++Z)}inc($,Z,Q){if($.startsWith("pre")){if(!Z&&Q===!1)throw Error("invalid increment argument: identifier is empty");if(Z){let J=`-${Z}`.match(this.options.loose?O6[y6.PRERELEASELOOSE]:O6[y6.PRERELEASE]);if(!J||J[1]!==Z)throw Error(`invalid identifier: ${Z}`)}}switch($){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",Z,Q);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",Z,Q);break;case"prepatch":this.prerelease.length=0,this.inc("patch",Z,Q),this.inc("pre",Z,Q);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",Z,Q);this.inc("pre",Z,Q);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let J=Number(Q)?1:0;if(this.prerelease.length===0)this.prerelease=[J];else{let X=this.prerelease.length;while(--X>=0)if(typeof this.prerelease[X]==="number")this.prerelease[X]++,X=-2;if(X===-1){if(Z===this.prerelease.join(".")&&Q===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(J)}}if(Z){let X=[Z,J];if(Q===!1)X=[Z];if(I2(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}}c1.exports=F0});var a1=T((RK,p1)=>{var l1=F4(),XQ=($,Z,Q=!1)=>{if($ instanceof l1)return $;try{return new l1($,Z)}catch(J){if(!Q)return null;throw J}};p1.exports=XQ});var n1=T((CK,r1)=>{var VQ=F4(),YQ=a1(),{safeRe:b6,t:f6}=e4(),KQ=($,Z)=>{if($ instanceof VQ)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;Z=Z||{};let Q=null;if(!Z.rtl)Q=$.match(Z.includePrerelease?b6[f6.COERCEFULL]:b6[f6.COERCE]);else{let q=Z.includePrerelease?b6[f6.COERCERTLFULL]:b6[f6.COERCERTL],W;while((W=q.exec($))&&(!Q||Q.index+Q[0].length!==$.length)){if(!Q||W.index+W[0].length!==Q.index+Q[0].length)Q=W;q.lastIndex=W.index+W[1].length+W[2].length}q.lastIndex=-1}if(Q===null)return null;let J=Q[2],X=Q[3]||"0",V=Q[4]||"0",Y=Z.includePrerelease&&Q[5]?`-${Q[5]}`:"",K=Z.includePrerelease&&Q[6]?`+${Q[6]}`:"";return YQ(`${J}.${X}.${V}${Y}${K}`,Z)};r1.exports=KQ});var K4=T((NK,o1)=>{var i1=F4(),qQ=($,Z,Q)=>new i1($,Q).compare(new i1(Z,Q));o1.exports=qQ});var M2=T((PK,s1)=>{var WQ=K4(),HQ=($,Z,Q)=>WQ($,Z,Q)>=0;s1.exports=HQ});var $$=T((DK,t1)=>{class e1{constructor(){this.max=1000,this.map=new Map}get($){let Z=this.map.get($);if(Z===void 0)return;else return this.map.delete($),this.map.set($,Z),Z}delete($){return this.map.delete($)}set($,Z){if(!this.delete($)&&Z!==void 0){if(this.map.size>=this.max){let J=this.map.keys().next().value;this.delete(J)}this.map.set($,Z)}return this}}t1.exports=e1});var Q$=T((IK,Z$)=>{var zQ=K4(),GQ=($,Z,Q)=>zQ($,Z,Q)===0;Z$.exports=GQ});var X$=T((MK,J$)=>{var jQ=K4(),UQ=($,Z,Q)=>jQ($,Z,Q)!==0;J$.exports=UQ});var Y$=T((SK,V$)=>{var AQ=K4(),BQ=($,Z,Q)=>AQ($,Z,Q)>0;V$.exports=BQ});var q$=T((EK,K$)=>{var LQ=K4(),_Q=($,Z,Q)=>LQ($,Z,Q)<0;K$.exports=_Q});var H$=T((TK,W$)=>{var wQ=K4(),FQ=($,Z,Q)=>wQ($,Z,Q)<=0;W$.exports=FQ});var G$=T((xK,z$)=>{var RQ=Q$(),CQ=X$(),NQ=Y$(),PQ=M2(),DQ=q$(),IQ=H$(),MQ=($,Z,Q,J)=>{switch(Z){case"===":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $===Q;case"!==":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $!==Q;case"":case"=":case"==":return RQ($,Q,J);case"!=":return CQ($,Q,J);case">":return NQ($,Q,J);case">=":return PQ($,Q,J);case"<":return DQ($,Q,J);case"<=":return IQ($,Q,J);default:throw TypeError(`Invalid operator: ${Z}`)}};z$.exports=MQ});var w$=T((kK,_$)=>{var t4=Symbol("SemVer ANY");class h6{static get ANY(){return t4}constructor($,Z){if(Z=j$(Z),$ instanceof h6)if($.loose===!!Z.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),E2("comparator",$,Z),this.options=Z,this.loose=!!Z.loose,this.parse($),this.semver===t4)this.value="";else this.value=this.operator+this.semver.version;E2("comp",this)}parse($){let Z=this.options.loose?U$[A$.COMPARATORLOOSE]:U$[A$.COMPARATOR],Q=$.match(Z);if(!Q)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=Q[1]!==void 0?Q[1]:"",this.operator==="=")this.operator="";if(!Q[2])this.semver=t4;else this.semver=new B$(Q[2],this.options.loose)}toString(){return this.value}test($){if(E2("Comparator.test",$,this.options.loose),this.semver===t4||$===t4)return!0;if(typeof $==="string")try{$=new B$($,this.options)}catch(Z){return!1}return S2($,this.operator,this.semver,this.options)}intersects($,Z){if(!($ instanceof h6))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new L$($.value,Z).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new L$(this.value,Z).test($.semver)}if(Z=j$(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(S2(this.semver,"<",$.semver,Z)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(S2(this.semver,">",$.semver,Z)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}_$.exports=h6;var j$=x6(),{safeRe:U$,t:A$}=e4(),S2=G$(),E2=s4(),B$=F4(),L$=T2()});var T2=T((vK,N$)=>{var SQ=/\s+/g;class $6{constructor($,Z){if(Z=TQ(Z),$ instanceof $6)if($.loose===!!Z.loose&&$.includePrerelease===!!Z.includePrerelease)return $;else return new $6($.raw,Z);if($ instanceof x2)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(SQ," "),this.set=this.raw.split("||").map((Q)=>this.parseRange(Q.trim())).filter((Q)=>Q.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Q=this.set[0];if(this.set=this.set.filter((J)=>!R$(J[0])),this.set.length===0)this.set=[Q];else if(this.set.length>1){for(let J of this.set)if(J.length===1&&fQ(J[0])){this.set=[J];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let $=0;$<this.set.length;$++){if($>0)this.formatted+="||";let Z=this.set[$];for(let Q=0;Q<Z.length;Q++){if(Q>0)this.formatted+=" ";this.formatted+=Z[Q].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let Q=((this.options.includePrerelease&&yQ)|(this.options.loose&&bQ))+":"+$,J=F$.get(Q);if(J)return J;let X=this.options.loose,V=X?Q0[s.HYPHENRANGELOOSE]:Q0[s.HYPHENRANGE];$=$.replace(V,rQ(this.options.includePrerelease)),h("hyphen replace",$),$=$.replace(Q0[s.COMPARATORTRIM],kQ),h("comparator trim",$),$=$.replace(Q0[s.TILDETRIM],vQ),h("tilde trim",$),$=$.replace(Q0[s.CARETTRIM],OQ),h("caret trim",$);let Y=$.split(" ").map((z)=>hQ(z,this.options)).join(" ").split(/\s+/).map((z)=>aQ(z,this.options));if(X)Y=Y.filter((z)=>{return h("loose invalid filter",z,this.options),!!z.match(Q0[s.COMPARATORLOOSE])});h("range list",Y);let K=new Map,q=Y.map((z)=>new x2(z,this.options));for(let z of q){if(R$(z))return[z];K.set(z.value,z)}if(K.size>1&&K.has(""))K.delete("");let W=[...K.values()];return F$.set(Q,W),W}intersects($,Z){if(!($ instanceof $6))throw TypeError("a Range is required");return this.set.some((Q)=>{return C$(Q,Z)&&$.set.some((J)=>{return C$(J,Z)&&Q.every((X)=>{return J.every((V)=>{return X.intersects(V,Z)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new xQ($,this.options)}catch(Z){return!1}for(let Z=0;Z<this.set.length;Z++)if(nQ(this.set[Z],$,this.options))return!0;return!1}}N$.exports=$6;var EQ=$$(),F$=new EQ,TQ=x6(),x2=w$(),h=s4(),xQ=F4(),{safeRe:Q0,t:s,comparatorTrimReplace:kQ,tildeTrimReplace:vQ,caretTrimReplace:OQ}=e4(),{FLAG_INCLUDE_PRERELEASE:yQ,FLAG_LOOSE:bQ}=T6(),R$=($)=>$.value==="<0.0.0-0",fQ=($)=>$.value==="",C$=($,Z)=>{let Q=!0,J=$.slice(),X=J.pop();while(Q&&J.length)Q=J.every((V)=>{return X.intersects(V,Z)}),X=J.pop();return Q},hQ=($,Z)=>{return $=$.replace(Q0[s.BUILD],""),h("comp",$,Z),$=dQ($,Z),h("caret",$),$=gQ($,Z),h("tildes",$),$=cQ($,Z),h("xrange",$),$=pQ($,Z),h("stars",$),$},J0=($)=>!$||$.toLowerCase()==="x"||$==="*",gQ=($,Z)=>{return $.trim().split(/\s+/).map((Q)=>uQ(Q,Z)).join(" ")},uQ=($,Z)=>{let Q=Z.loose?Q0[s.TILDELOOSE]:Q0[s.TILDE];return $.replace(Q,(J,X,V,Y,K)=>{h("tilde",$,J,X,V,Y,K);let q;if(J0(X))q="";else if(J0(V))q=`>=${X}.0.0 <${+X+1}.0.0-0`;else if(J0(Y))q=`>=${X}.${V}.0 <${X}.${+V+1}.0-0`;else if(K)h("replaceTilde pr",K),q=`>=${X}.${V}.${Y}-${K} <${X}.${+V+1}.0-0`;else q=`>=${X}.${V}.${Y} <${X}.${+V+1}.0-0`;return h("tilde return",q),q})},dQ=($,Z)=>{return $.trim().split(/\s+/).map((Q)=>mQ(Q,Z)).join(" ")},mQ=($,Z)=>{h("caret",$,Z);let Q=Z.loose?Q0[s.CARETLOOSE]:Q0[s.CARET],J=Z.includePrerelease?"-0":"";return $.replace(Q,(X,V,Y,K,q)=>{h("caret",$,X,V,Y,K,q);let W;if(J0(V))W="";else if(J0(Y))W=`>=${V}.0.0${J} <${+V+1}.0.0-0`;else if(J0(K))if(V==="0")W=`>=${V}.${Y}.0${J} <${V}.${+Y+1}.0-0`;else W=`>=${V}.${Y}.0${J} <${+V+1}.0.0-0`;else if(q)if(h("replaceCaret pr",q),V==="0")if(Y==="0")W=`>=${V}.${Y}.${K}-${q} <${V}.${Y}.${+K+1}-0`;else W=`>=${V}.${Y}.${K}-${q} <${V}.${+Y+1}.0-0`;else W=`>=${V}.${Y}.${K}-${q} <${+V+1}.0.0-0`;else if(h("no pr"),V==="0")if(Y==="0")W=`>=${V}.${Y}.${K}${J} <${V}.${Y}.${+K+1}-0`;else W=`>=${V}.${Y}.${K}${J} <${V}.${+Y+1}.0-0`;else W=`>=${V}.${Y}.${K} <${+V+1}.0.0-0`;return h("caret return",W),W})},cQ=($,Z)=>{return h("replaceXRanges",$,Z),$.split(/\s+/).map((Q)=>lQ(Q,Z)).join(" ")},lQ=($,Z)=>{$=$.trim();let Q=Z.loose?Q0[s.XRANGELOOSE]:Q0[s.XRANGE];return $.replace(Q,(J,X,V,Y,K,q)=>{h("xRange",$,J,X,V,Y,K,q);let W=J0(V),z=W||J0(Y),G=z||J0(K),A=G;if(X==="="&&A)X="";if(q=Z.includePrerelease?"-0":"",W)if(X===">"||X==="<")J="<0.0.0-0";else J="*";else if(X&&A){if(z)Y=0;if(K=0,X===">")if(X=">=",z)V=+V+1,Y=0,K=0;else Y=+Y+1,K=0;else if(X==="<=")if(X="<",z)V=+V+1;else Y=+Y+1;if(X==="<")q="-0";J=`${X+V}.${Y}.${K}${q}`}else if(z)J=`>=${V}.0.0${q} <${+V+1}.0.0-0`;else if(G)J=`>=${V}.${Y}.0${q} <${V}.${+Y+1}.0-0`;return h("xRange return",J),J})},pQ=($,Z)=>{return h("replaceStars",$,Z),$.trim().replace(Q0[s.STAR],"")},aQ=($,Z)=>{return h("replaceGTE0",$,Z),$.trim().replace(Q0[Z.includePrerelease?s.GTE0PRE:s.GTE0],"")},rQ=($)=>(Z,Q,J,X,V,Y,K,q,W,z,G,A)=>{if(J0(J))Q="";else if(J0(X))Q=`>=${J}.0.0${$?"-0":""}`;else if(J0(V))Q=`>=${J}.${X}.0${$?"-0":""}`;else if(Y)Q=`>=${Q}`;else Q=`>=${Q}${$?"-0":""}`;if(J0(W))q="";else if(J0(z))q=`<${+W+1}.0.0-0`;else if(J0(G))q=`<${W}.${+z+1}.0-0`;else if(A)q=`<=${W}.${z}.${G}-${A}`;else if($)q=`<${W}.${z}.${+G+1}-0`;else q=`<=${q}`;return`${Q} ${q}`.trim()},nQ=($,Z,Q)=>{for(let J=0;J<$.length;J++)if(!$[J].test(Z))return!1;if(Z.prerelease.length&&!Q.includePrerelease){for(let J=0;J<$.length;J++){if(h($[J].semver),$[J].semver===x2.ANY)continue;if($[J].semver.prerelease.length>0){let X=$[J].semver;if(X.major===Z.major&&X.minor===Z.minor&&X.patch===Z.patch)return!0}}return!1}return!0}});var D$=T((OK,P$)=>{var iQ=T2(),oQ=($,Z,Q)=>{try{Z=new iQ(Z,Q)}catch(J){return!1}return Z.test($)};P$.exports=oQ});var k2=T((yK,sQ)=>{sQ.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 O2=T((bK,y$)=>{/*!
6
- Copyright 2013 Lovell Fuller and others.
7
- SPDX-License-Identifier: Apache-2.0
8
- */var{spawnSync:g6}=y("child_process"),{createHash:eQ}=y("crypto"),E$=n1(),tQ=M2(),$J=D$(),I$=E6(),{config:ZJ,engines:M$,optionalDependencies:QJ}=k2(),JJ=process.env.npm_package_config_libvips||ZJ.libvips,T$=E$(JJ).version,XJ=["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"],u6={encoding:"utf8",shell:!0},VJ=($)=>{if($ instanceof Error)console.error(`sharp: Installation error: ${$.message}`);else console.log(`sharp: ${$}`)},x$=()=>I$.isNonGlibcLinuxSync()?I$.familySync():"",YJ=()=>`${process.platform}${x$()}-${process.arch}`,R4=()=>{if(k$())return"wasm32";let{npm_config_arch:$,npm_config_platform:Z,npm_config_libc:Q}=process.env,J=typeof Q==="string"?Q:x$();return`${Z||process.platform}${J}-${$||process.arch}`},KJ=()=>{try{return y(`@img/sharp-libvips-dev-${R4()}/include`)}catch{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/include");})()}catch{}}return""},qJ=()=>{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/cplusplus");})()}catch{}return""},WJ=()=>{try{return y(`@img/sharp-libvips-dev-${R4()}/lib`)}catch{try{return y(`@img/sharp-libvips-${R4()}/lib`)}catch{}}return""},HJ=()=>{if(process.release?.name==="node"&&process.versions){if(!$J(process.versions.node,M$.node))return{found:process.versions.node,expected:M$.node}}},k$=()=>{let{CC:$}=process.env;return Boolean($?.endsWith("/emcc"))},zJ=()=>{if(process.platform==="darwin"&&process.arch==="x64")return(g6("sysctl sysctl.proc_translated",u6).stdout||"").trim()==="sysctl.proc_translated: 1";return!1},S$=($)=>eQ("sha512").update($).digest("hex"),GJ=()=>{try{let $=S$(`imgsharp-libvips-${R4()}`),Z=E$(QJ[`@img/sharp-libvips-${R4()}`],{includePrerelease:!0}).version;return S$(`${$}npm:${Z}`).slice(0,10)}catch{}return""},jJ=()=>g6(`node-gyp rebuild --directory=src ${k$()?"--nodedir=emscripten":""}`,{...u6,stdio:"inherit"}).status,v$=()=>{if(process.platform!=="win32")return(g6("pkg-config --modversion vips-cpp",{...u6,env:{...process.env,PKG_CONFIG_PATH:O$()}}).stdout||"").trim();else return""},O$=()=>{if(process.platform!=="win32")return[(g6('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',u6).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""},v2=($,Z,Q)=>{if(Q)Q(`Detected ${Z}, skipping search for globally-installed libvips`);return $},UJ=($)=>{if(Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)===!0)return v2(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",$);if(Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)===!0)return v2(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",$);if(zJ())return v2(!1,"Rosetta",$);let Z=v$();return!!Z&&tQ(Z,T$)};y$.exports={minimumLibvipsVersion:T$,prebuiltPlatforms:XJ,buildPlatformArch:R4,buildSharpLibvipsIncludeDir:KJ,buildSharpLibvipsCPlusPlusDir:qJ,buildSharpLibvipsLibDir:WJ,isUnsupportedNodeRuntime:HJ,runtimePlatformArch:YJ,log:VJ,yarnLocator:GJ,spawnRebuild:jJ,globalLibvipsVersion:v$,pkgConfigPath:O$,useGlobalLibvips:UJ}});var Q6=T((hK,f$)=>{/*!
9
- Copyright 2013 Lovell Fuller and others.
10
- SPDX-License-Identifier: Apache-2.0
11
- */var{familySync:AJ,versionSync:BJ}=E6(),{runtimePlatformArch:LJ,isUnsupportedNodeRuntime:b$,prebuiltPlatforms:_J,minimumLibvipsVersion:wJ}=O2(),q4=LJ(),FJ=[`../src/build/Release/sharp-${q4}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${q4}/sharp.node`,"@img/sharp-wasm32/sharp.node"],y2,C4,Z6=[];for(y2 of FJ)try{C4=y(y2);break}catch($){Z6.push($)}if(C4&&y2.startsWith("@img/sharp-linux-x64")&&!C4._isUsingX64V2()){let $=Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");$.code="Unsupported CPU",Z6.push($),C4=null}if(C4)f$.exports=C4;else{let[$,Z,Q]=["linux","darwin","win32"].map((V)=>q4.startsWith(V)),J=[`Could not load the "sharp" module using the ${q4} runtime`];Z6.forEach((V)=>{if(V.code!=="MODULE_NOT_FOUND")J.push(`${V.code}: ${V.message}`)});let X=Z6.map((V)=>V.message).join(" ");if(J.push("Possible solutions:"),b$()){let{found:V,expected:Y}=b$();J.push("- Please upgrade Node.js:",` Found ${V}`,` Requires ${Y}`)}else if(_J.includes(q4)){let[V,Y]=q4.split("-"),K=V.endsWith("musl")?" --libc=musl":"";J.push("- Ensure optional dependencies can be installed:"," npm install --include=optional sharp","- Ensure your package manager supports multi-platform installation:"," See https://sharp.pixelplumbing.com/install#cross-platform","- Add platform-specific dependencies:",` npm install --os=${V.replace("musl","")}${K} --cpu=${Y} sharp`)}else J.push(`- Manually install libvips >= ${wJ}`,"- 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}=y(`@img/sharp-libvips-${q4}/package`),Y=`${AJ()} ${BJ()}`,K=`${V.musl?"musl":"glibc"} ${V.musl||V.glibc}`;J.push("- Update your OS:",` Found ${Y}`,` Requires ${K}`)}catch(V){}if($&&/\/snap\/core[0-9]{2}/.test(X))J.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node");if(Z&&/Incompatible library version/.test(X))J.push("- Update Homebrew:"," brew update && brew upgrade vips");if(Z6.some((V)=>V.code==="ERR_DLOPEN_DISABLED"))J.push("- Run Node.js without using the --no-addons flag");if(Q&&/The specified procedure could not be found/.test(X))J.push("- Using the canvas package on Windows?"," See https://sharp.pixelplumbing.com/install#canvas-and-windows","- Check for outdated versions of sharp in the dependency tree:"," npm ls sharp");throw J.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),Error(J.join(`
12
- `))}});var g$=T((uK,h$)=>{/*!
13
- Copyright 2013 Lovell Fuller and others.
14
- SPDX-License-Identifier: Apache-2.0
15
- */var RJ=y("util"),b2=y("stream"),CJ=M0();Q6();var NJ=RJ.debuglog("sharp"),PJ=($)=>{W4.queue.emit("change",$)},W4=function($,Z){if(arguments.length===1&&!CJ.defined($))throw Error("Invalid input");if(!(this instanceof W4))return new W4($,Z);return b2.Duplex.call(this),this.options={topOffsetPre:-1,leftOffsetPre:-1,widthPre:-1,heightPre:-1,topOffsetPost:-1,leftOffsetPost:-1,widthPost:-1,heightPost:-1,width:-1,height:-1,canvas:"crop",position:0,resizeBackground:[0,0,0,255],angle:0,rotationAngle:0,rotationBackground:[0,0,0,255],rotateBefore:!1,orientBefore:!1,flip:!1,flop:!1,extendTop:0,extendBottom:0,extendLeft:0,extendRight:0,extendBackground:[0,0,0,255],extendWith:"background",withoutEnlargement:!1,withoutReduction:!1,affineMatrix:[],affineBackground:[0,0,0,255],affineIdx:0,affineIdy:0,affineOdx:0,affineOdy:0,affineInterpolator:this.constructor.interpolators.bilinear,kernel:"lanczos3",fastShrinkOnLoad:!0,tint:[-1,0,0,0],flatten:!1,flattenBackground:[0,0,0],unflatten:!1,negate:!1,negateAlpha:!0,medianSize:0,blurSigma:0,precision:"integer",minAmpl:0.2,sharpenSigma:0,sharpenM1:1,sharpenM2:2,sharpenX1:2,sharpenY2:10,sharpenY3:20,threshold:0,thresholdGrayscale:!0,trimBackground:[],trimThreshold:-1,trimLineArt:!1,dilateWidth:0,erodeWidth:0,gamma:0,gammaOut:0,greyscale:!1,normalise:!1,normaliseLower:1,normaliseUpper:99,claheWidth:0,claheHeight:0,claheMaxSlope:3,brightness:1,saturation:1,hue:0,lightness:0,booleanBufferIn:null,booleanFileIn:"",joinChannelIn:[],extractChannel:-1,removeAlpha:!1,ensureAlpha:-1,colourspace:"srgb",colourspacePipeline:"last",composite:[],fileOut:"",formatOut:"input",streamOut:!1,keepMetadata:0,withMetadataOrientation:-1,withMetadataDensity:0,withIccProfile:"",withExif:{},withExifMerge:!0,withXmp:"",resolveWithObject:!1,loop:-1,delay:[],jpegQuality:80,jpegProgressive:!1,jpegChromaSubsampling:"4:2:0",jpegTrellisQuantisation:!1,jpegOvershootDeringing:!1,jpegOptimiseScans:!1,jpegOptimiseCoding:!0,jpegQuantisationTable:0,pngProgressive:!1,pngCompressionLevel:6,pngAdaptiveFiltering:!1,pngPalette:!1,pngQuality:100,pngEffort:7,pngBitdepth:8,pngDither:1,jp2Quality:80,jp2TileHeight:512,jp2TileWidth:512,jp2Lossless:!1,jp2ChromaSubsampling:"4:4:4",webpQuality:80,webpAlphaQuality:100,webpLossless:!1,webpNearLossless:!1,webpSmartSubsample:!1,webpSmartDeblock:!1,webpPreset:"default",webpEffort:4,webpMinSize:!1,webpMixed:!1,gifBitdepth:8,gifEffort:7,gifDither:1,gifInterFrameMaxError:0,gifInterPaletteMaxError:3,gifKeepDuplicateFrames:!1,gifReuse:!0,gifProgressive:!1,tiffQuality:80,tiffCompression:"jpeg",tiffBigtiff:!1,tiffPredictor:"horizontal",tiffPyramid:!1,tiffMiniswhite:!1,tiffBitdepth:8,tiffTile:!1,tiffTileHeight:256,tiffTileWidth:256,tiffXres:1,tiffYres:1,tiffResolutionUnit:"inch",heifQuality:50,heifLossless:!1,heifCompression:"av1",heifEffort:4,heifChromaSubsampling:"4:4:4",heifBitdepth:8,jxlDistance:1,jxlDecodingTier:0,jxlEffort:7,jxlLossless:!1,rawDepth:"uchar",tileSize:256,tileOverlap:0,tileContainer:"fs",tileLayout:"dz",tileFormat:"last",tileDepth:"last",tileAngle:0,tileSkipBlanks:-1,tileBackground:[255,255,255,255],tileCentre:!1,tileId:"https://example.com/iiif",tileBasename:"",timeoutSeconds:0,linearA:[],linearB:[],pdfBackground:[255,255,255,255],debuglog:(Q)=>{this.emit("warning",Q),NJ(Q)},queueListener:PJ},this.options.input=this._createInputDescriptor($,Z,{allowStream:!0}),this};Object.setPrototypeOf(W4.prototype,b2.Duplex.prototype);Object.setPrototypeOf(W4,b2.Duplex);function DJ(){let $=this.constructor.call(),{debuglog:Z,queueListener:Q,...J}=this.options;if($.options=structuredClone(J),$.options.debuglog=Z,$.options.queueListener=Q,this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),$.options.input.buffer=this.options.input.buffer,$.emit("finish")});return $}Object.assign(W4.prototype,{clone:DJ});h$.exports=W4});var m$=T((dK,d$)=>{/*!
16
- Copyright 2013 Lovell Fuller and others.
17
- SPDX-License-Identifier: Apache-2.0
18
- */var j=M0(),s0=Q6(),IJ={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},MJ=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function u$($){let Z=MJ.filter((Q)=>j.defined($[Q])).map((Q)=>[Q,$[Q]]);return Z.length?Object.fromEntries(Z):void 0}function SJ($,Z,Q){let J={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(j.string($))J.file=$;else if(j.buffer($)){if($.length===0)throw Error("Input Buffer is empty");J.buffer=$}else if(j.arrayBuffer($)){if($.byteLength===0)throw Error("Input bit Array is empty");J.buffer=Buffer.from($,0,$.byteLength)}else if(j.typedArray($)){if($.length===0)throw Error("Input Bit Array is empty");J.buffer=Buffer.from($.buffer,$.byteOffset,$.byteLength)}else if(j.plainObject($)&&!j.defined(Z)){if(Z=$,u$(Z))J.buffer=[]}else if(!j.defined($)&&!j.defined(Z)&&j.object(Q)&&Q.allowStream)J.buffer=[];else if(Array.isArray($))if($.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=$.map((X)=>this._createInputDescriptor(X));else throw Error("Recursive join is unsupported");else throw Error("Expected at least two images to join");else throw Error(`Unsupported input '${$}' of type ${typeof $}${j.defined(Z)?` when also providing options of type ${typeof Z}`:""}`);if(j.object(Z)){if(j.defined(Z.failOnError))if(j.bool(Z.failOnError))J.failOn=Z.failOnError?"warning":"none";else throw j.invalidParameterError("failOnError","boolean",Z.failOnError);if(j.defined(Z.failOn))if(j.string(Z.failOn)&&j.inArray(Z.failOn,["none","truncated","error","warning"]))J.failOn=Z.failOn;else throw j.invalidParameterError("failOn","one of: none, truncated, error, warning",Z.failOn);if(j.defined(Z.autoOrient))if(j.bool(Z.autoOrient))J.autoOrient=Z.autoOrient;else throw j.invalidParameterError("autoOrient","boolean",Z.autoOrient);if(j.defined(Z.density))if(j.inRange(Z.density,1,1e5))J.density=Z.density;else throw j.invalidParameterError("density","number between 1 and 100000",Z.density);if(j.defined(Z.ignoreIcc))if(j.bool(Z.ignoreIcc))J.ignoreIcc=Z.ignoreIcc;else throw j.invalidParameterError("ignoreIcc","boolean",Z.ignoreIcc);if(j.defined(Z.limitInputPixels))if(j.bool(Z.limitInputPixels))J.limitInputPixels=Z.limitInputPixels?268402689:0;else if(j.integer(Z.limitInputPixels)&&j.inRange(Z.limitInputPixels,0,Number.MAX_SAFE_INTEGER))J.limitInputPixels=Z.limitInputPixels;else throw j.invalidParameterError("limitInputPixels","positive integer",Z.limitInputPixels);if(j.defined(Z.unlimited))if(j.bool(Z.unlimited))J.unlimited=Z.unlimited;else throw j.invalidParameterError("unlimited","boolean",Z.unlimited);if(j.defined(Z.sequentialRead))if(j.bool(Z.sequentialRead))J.sequentialRead=Z.sequentialRead;else throw j.invalidParameterError("sequentialRead","boolean",Z.sequentialRead);if(j.defined(Z.raw)){if(j.object(Z.raw)&&j.integer(Z.raw.width)&&Z.raw.width>0&&j.integer(Z.raw.height)&&Z.raw.height>0&&j.integer(Z.raw.channels)&&j.inRange(Z.raw.channels,1,4))switch(J.rawWidth=Z.raw.width,J.rawHeight=Z.raw.height,J.rawChannels=Z.raw.channels,$.constructor){case Uint8Array:case Uint8ClampedArray:J.rawDepth="uchar";break;case Int8Array:J.rawDepth="char";break;case Uint16Array:J.rawDepth="ushort";break;case Int16Array:J.rawDepth="short";break;case Uint32Array:J.rawDepth="uint";break;case Int32Array:J.rawDepth="int";break;case Float32Array:J.rawDepth="float";break;case Float64Array:J.rawDepth="double";break;default:J.rawDepth="uchar";break}else throw Error("Expected width, height and channels for raw pixel input");if(J.rawPremultiplied=!1,j.defined(Z.raw.premultiplied))if(j.bool(Z.raw.premultiplied))J.rawPremultiplied=Z.raw.premultiplied;else throw j.invalidParameterError("raw.premultiplied","boolean",Z.raw.premultiplied);if(J.rawPageHeight=0,j.defined(Z.raw.pageHeight))if(j.integer(Z.raw.pageHeight)&&Z.raw.pageHeight>0&&Z.raw.pageHeight<=Z.raw.height){if(Z.raw.height%Z.raw.pageHeight!==0)throw Error(`Expected raw.height ${Z.raw.height} to be a multiple of raw.pageHeight ${Z.raw.pageHeight}`);J.rawPageHeight=Z.raw.pageHeight}else throw j.invalidParameterError("raw.pageHeight","positive integer",Z.raw.pageHeight)}if(j.defined(Z.animated))if(j.bool(Z.animated))J.pages=Z.animated?-1:1;else throw j.invalidParameterError("animated","boolean",Z.animated);if(j.defined(Z.pages))if(j.integer(Z.pages)&&j.inRange(Z.pages,-1,1e5))J.pages=Z.pages;else throw j.invalidParameterError("pages","integer between -1 and 100000",Z.pages);if(j.defined(Z.page))if(j.integer(Z.page)&&j.inRange(Z.page,0,1e5))J.page=Z.page;else throw j.invalidParameterError("page","integer between 0 and 100000",Z.page);if(j.object(Z.openSlide)&&j.defined(Z.openSlide.level))if(j.integer(Z.openSlide.level)&&j.inRange(Z.openSlide.level,0,256))J.openSlideLevel=Z.openSlide.level;else throw j.invalidParameterError("openSlide.level","integer between 0 and 256",Z.openSlide.level);else if(j.defined(Z.level))if(j.integer(Z.level)&&j.inRange(Z.level,0,256))J.openSlideLevel=Z.level;else throw j.invalidParameterError("level","integer between 0 and 256",Z.level);if(j.object(Z.tiff)&&j.defined(Z.tiff.subifd))if(j.integer(Z.tiff.subifd)&&j.inRange(Z.tiff.subifd,-1,1e5))J.tiffSubifd=Z.tiff.subifd;else throw j.invalidParameterError("tiff.subifd","integer between -1 and 100000",Z.tiff.subifd);else if(j.defined(Z.subifd))if(j.integer(Z.subifd)&&j.inRange(Z.subifd,-1,1e5))J.tiffSubifd=Z.subifd;else throw j.invalidParameterError("subifd","integer between -1 and 100000",Z.subifd);if(j.object(Z.svg)){if(j.defined(Z.svg.stylesheet))if(j.string(Z.svg.stylesheet))J.svgStylesheet=Z.svg.stylesheet;else throw j.invalidParameterError("svg.stylesheet","string",Z.svg.stylesheet);if(j.defined(Z.svg.highBitdepth))if(j.bool(Z.svg.highBitdepth))J.svgHighBitdepth=Z.svg.highBitdepth;else throw j.invalidParameterError("svg.highBitdepth","boolean",Z.svg.highBitdepth)}if(j.object(Z.pdf)&&j.defined(Z.pdf.background))J.pdfBackground=this._getBackgroundColourOption(Z.pdf.background);else if(j.defined(Z.pdfBackground))J.pdfBackground=this._getBackgroundColourOption(Z.pdfBackground);if(j.object(Z.jp2)&&j.defined(Z.jp2.oneshot))if(j.bool(Z.jp2.oneshot))J.jp2Oneshot=Z.jp2.oneshot;else throw j.invalidParameterError("jp2.oneshot","boolean",Z.jp2.oneshot);if(j.defined(Z.create))if(j.object(Z.create)&&j.integer(Z.create.width)&&Z.create.width>0&&j.integer(Z.create.height)&&Z.create.height>0&&j.integer(Z.create.channels)){if(J.createWidth=Z.create.width,J.createHeight=Z.create.height,J.createChannels=Z.create.channels,J.createPageHeight=0,j.defined(Z.create.pageHeight))if(j.integer(Z.create.pageHeight)&&Z.create.pageHeight>0&&Z.create.pageHeight<=Z.create.height){if(Z.create.height%Z.create.pageHeight!==0)throw Error(`Expected create.height ${Z.create.height} to be a multiple of create.pageHeight ${Z.create.pageHeight}`);J.createPageHeight=Z.create.pageHeight}else throw j.invalidParameterError("create.pageHeight","positive integer",Z.create.pageHeight);if(j.defined(Z.create.noise)){if(!j.object(Z.create.noise))throw Error("Expected noise to be an object");if(Z.create.noise.type!=="gaussian")throw Error("Only gaussian noise is supported at the moment");if(J.createNoiseType=Z.create.noise.type,!j.inRange(Z.create.channels,1,4))throw j.invalidParameterError("create.channels","number between 1 and 4",Z.create.channels);if(J.createNoiseMean=128,j.defined(Z.create.noise.mean))if(j.number(Z.create.noise.mean)&&j.inRange(Z.create.noise.mean,0,1e4))J.createNoiseMean=Z.create.noise.mean;else throw j.invalidParameterError("create.noise.mean","number between 0 and 10000",Z.create.noise.mean);if(J.createNoiseSigma=30,j.defined(Z.create.noise.sigma))if(j.number(Z.create.noise.sigma)&&j.inRange(Z.create.noise.sigma,0,1e4))J.createNoiseSigma=Z.create.noise.sigma;else throw j.invalidParameterError("create.noise.sigma","number between 0 and 10000",Z.create.noise.sigma)}else if(j.defined(Z.create.background)){if(!j.inRange(Z.create.channels,3,4))throw j.invalidParameterError("create.channels","number between 3 and 4",Z.create.channels);J.createBackground=this._getBackgroundColourOption(Z.create.background)}else throw Error("Expected valid noise or background to create a new input image");delete J.buffer}else throw Error("Expected valid width, height and channels to create a new input image");if(j.defined(Z.text))if(j.object(Z.text)&&j.string(Z.text.text)){if(J.textValue=Z.text.text,j.defined(Z.text.height)&&j.defined(Z.text.dpi))throw Error("Expected only one of dpi or height");if(j.defined(Z.text.font))if(j.string(Z.text.font))J.textFont=Z.text.font;else throw j.invalidParameterError("text.font","string",Z.text.font);if(j.defined(Z.text.fontfile))if(j.string(Z.text.fontfile))J.textFontfile=Z.text.fontfile;else throw j.invalidParameterError("text.fontfile","string",Z.text.fontfile);if(j.defined(Z.text.width))if(j.integer(Z.text.width)&&Z.text.width>0)J.textWidth=Z.text.width;else throw j.invalidParameterError("text.width","positive integer",Z.text.width);if(j.defined(Z.text.height))if(j.integer(Z.text.height)&&Z.text.height>0)J.textHeight=Z.text.height;else throw j.invalidParameterError("text.height","positive integer",Z.text.height);if(j.defined(Z.text.align))if(j.string(Z.text.align)&&j.string(this.constructor.align[Z.text.align]))J.textAlign=this.constructor.align[Z.text.align];else throw j.invalidParameterError("text.align","valid alignment",Z.text.align);if(j.defined(Z.text.justify))if(j.bool(Z.text.justify))J.textJustify=Z.text.justify;else throw j.invalidParameterError("text.justify","boolean",Z.text.justify);if(j.defined(Z.text.dpi))if(j.integer(Z.text.dpi)&&j.inRange(Z.text.dpi,1,1e6))J.textDpi=Z.text.dpi;else throw j.invalidParameterError("text.dpi","integer between 1 and 1000000",Z.text.dpi);if(j.defined(Z.text.rgba))if(j.bool(Z.text.rgba))J.textRgba=Z.text.rgba;else throw j.invalidParameterError("text.rgba","bool",Z.text.rgba);if(j.defined(Z.text.spacing))if(j.integer(Z.text.spacing)&&j.inRange(Z.text.spacing,-1e6,1e6))J.textSpacing=Z.text.spacing;else throw j.invalidParameterError("text.spacing","integer between -1000000 and 1000000",Z.text.spacing);if(j.defined(Z.text.wrap))if(j.string(Z.text.wrap)&&j.inArray(Z.text.wrap,["word","char","word-char","none"]))J.textWrap=Z.text.wrap;else throw j.invalidParameterError("text.wrap","one of: word, char, word-char, none",Z.text.wrap);delete J.buffer}else throw Error("Expected a valid string to create an image with text.");if(j.defined(Z.join))if(j.defined(this.options.join)){if(j.defined(Z.join.animated))if(j.bool(Z.join.animated))J.joinAnimated=Z.join.animated;else throw j.invalidParameterError("join.animated","boolean",Z.join.animated);if(j.defined(Z.join.across))if(j.integer(Z.join.across)&&j.inRange(Z.join.across,1,1e6))J.joinAcross=Z.join.across;else throw j.invalidParameterError("join.across","integer between 1 and 100000",Z.join.across);if(j.defined(Z.join.shim))if(j.integer(Z.join.shim)&&j.inRange(Z.join.shim,0,1e6))J.joinShim=Z.join.shim;else throw j.invalidParameterError("join.shim","integer between 0 and 100000",Z.join.shim);if(j.defined(Z.join.background))J.joinBackground=this._getBackgroundColourOption(Z.join.background);if(j.defined(Z.join.halign))if(j.string(Z.join.halign)&&j.string(this.constructor.align[Z.join.halign]))J.joinHalign=this.constructor.align[Z.join.halign];else throw j.invalidParameterError("join.halign","valid alignment",Z.join.halign);if(j.defined(Z.join.valign))if(j.string(Z.join.valign)&&j.string(this.constructor.align[Z.join.valign]))J.joinValign=this.constructor.align[Z.join.valign];else throw j.invalidParameterError("join.valign","valid alignment",Z.join.valign)}else throw Error("Expected input to be an array of images to join")}else if(j.defined(Z))throw Error(`Invalid input options ${Z}`);return J}function EJ($,Z,Q){if(Array.isArray(this.options.input.buffer))if(j.buffer($)){if(this.options.input.buffer.length===0)this.on("finish",()=>{this.streamInFinished=!0});this.options.input.buffer.push($),Q()}else Q(Error("Non-Buffer data on Writable Stream"));else Q(Error("Unexpected data on Writable Stream"))}function TJ(){if(this._isStreamInput())this.options.input.buffer=Buffer.concat(this.options.input.buffer)}function xJ(){return Array.isArray(this.options.input.buffer)}function kJ($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),s0.metadata(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)})});else s0.metadata(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{let X=()=>{this._flattenBufferIn(),s0.metadata(this.options,(V,Y)=>{if(V)J(j.nativeError(V,Z));else Q(Y)})};if(this.writableFinished)X();else this.once("finish",X)});else return new Promise((Q,J)=>{s0.metadata(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})}function vJ($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),s0.stats(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)})});else s0.stats(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{this.on("finish",function(){this._flattenBufferIn(),s0.stats(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})});else return new Promise((Q,J)=>{s0.stats(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})}d$.exports=($)=>{Object.assign($.prototype,{_inputOptionsFromObject:u$,_createInputDescriptor:SJ,_write:EJ,_flattenBufferIn:TJ,_isStreamInput:xJ,metadata:kJ,stats:vJ}),$.align=IJ}});var n$=T((mK,r$)=>{/*!
19
- Copyright 2013 Lovell Fuller and others.
20
- SPDX-License-Identifier: Apache-2.0
21
- */var D=M0(),l$={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},p$={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},c$={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},a$={entropy:16,attention:17},f2={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},OJ={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},yJ={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function h2($){return $.angle%360!==0||$.rotationAngle!==0}function d6($){return $.width!==-1||$.height!==-1}function bJ($,Z,Q){if(d6(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(D.defined($))if(D.object($)&&!D.defined(Q))Q=$;else if(D.integer($)&&$>0)this.options.width=$;else throw D.invalidParameterError("width","positive integer",$);else this.options.width=-1;if(D.defined(Z))if(D.integer(Z)&&Z>0)this.options.height=Z;else throw D.invalidParameterError("height","positive integer",Z);else this.options.height=-1;if(D.object(Q)){if(D.defined(Q.width))if(D.integer(Q.width)&&Q.width>0)this.options.width=Q.width;else throw D.invalidParameterError("width","positive integer",Q.width);if(D.defined(Q.height))if(D.integer(Q.height)&&Q.height>0)this.options.height=Q.height;else throw D.invalidParameterError("height","positive integer",Q.height);if(D.defined(Q.fit)){let J=yJ[Q.fit];if(D.string(J))this.options.canvas=J;else throw D.invalidParameterError("fit","valid fit",Q.fit)}if(D.defined(Q.position)){let J=D.integer(Q.position)?Q.position:a$[Q.position]||p$[Q.position]||l$[Q.position];if(D.integer(J)&&(D.inRange(J,0,8)||D.inRange(J,16,17)))this.options.position=J;else throw D.invalidParameterError("position","valid position/gravity/strategy",Q.position)}if(this._setBackgroundColourOption("resizeBackground",Q.background),D.defined(Q.kernel))if(D.string(f2[Q.kernel]))this.options.kernel=f2[Q.kernel];else throw D.invalidParameterError("kernel","valid kernel name",Q.kernel);if(D.defined(Q.withoutEnlargement))this._setBooleanOption("withoutEnlargement",Q.withoutEnlargement);if(D.defined(Q.withoutReduction))this._setBooleanOption("withoutReduction",Q.withoutReduction);if(D.defined(Q.fastShrinkOnLoad))this._setBooleanOption("fastShrinkOnLoad",Q.fastShrinkOnLoad)}if(h2(this.options)&&d6(this.options))this.options.rotateBefore=!0;return this}function fJ($){if(D.integer($)&&$>0)this.options.extendTop=$,this.options.extendBottom=$,this.options.extendLeft=$,this.options.extendRight=$;else if(D.object($)){if(D.defined($.top))if(D.integer($.top)&&$.top>=0)this.options.extendTop=$.top;else throw D.invalidParameterError("top","positive integer",$.top);if(D.defined($.bottom))if(D.integer($.bottom)&&$.bottom>=0)this.options.extendBottom=$.bottom;else throw D.invalidParameterError("bottom","positive integer",$.bottom);if(D.defined($.left))if(D.integer($.left)&&$.left>=0)this.options.extendLeft=$.left;else throw D.invalidParameterError("left","positive integer",$.left);if(D.defined($.right))if(D.integer($.right)&&$.right>=0)this.options.extendRight=$.right;else throw D.invalidParameterError("right","positive integer",$.right);if(this._setBackgroundColourOption("extendBackground",$.background),D.defined($.extendWith))if(D.string(c$[$.extendWith]))this.options.extendWith=c$[$.extendWith];else throw D.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",$.extendWith)}else throw D.invalidParameterError("extend","integer or object",$);return this}function hJ($){let Z=d6(this.options)||this.options.widthPre!==-1?"Post":"Pre";if(this.options[`width${Z}`]!==-1)this.options.debuglog("ignoring previous extract options");if(["left","top","width","height"].forEach(function(Q){let J=$[Q];if(D.integer(J)&&J>=0)this.options[Q+(Q==="left"||Q==="top"?"Offset":"")+Z]=J;else throw D.invalidParameterError(Q,"integer",J)},this),h2(this.options)&&!d6(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 gJ($){if(this.options.trimThreshold=10,D.defined($))if(D.object($)){if(D.defined($.background))this._setBackgroundColourOption("trimBackground",$.background);if(D.defined($.threshold))if(D.number($.threshold)&&$.threshold>=0)this.options.trimThreshold=$.threshold;else throw D.invalidParameterError("threshold","positive number",$.threshold);if(D.defined($.lineArt))this._setBooleanOption("trimLineArt",$.lineArt)}else throw D.invalidParameterError("trim","object",$);if(h2(this.options))this.options.rotateBefore=!0;return this}r$.exports=($)=>{Object.assign($.prototype,{resize:bJ,extend:fJ,extract:hJ,trim:gJ}),$.gravity=l$,$.strategy=a$,$.kernel=f2,$.fit=OJ,$.position=p$}});var o$=T((cK,i$)=>{/*!
22
- Copyright 2013 Lovell Fuller and others.
23
- SPDX-License-Identifier: Apache-2.0
24
- */var b=M0(),g2={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 uJ($){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 Q=this._inputOptionsFromObject(Z),J={input:this._createInputDescriptor(Z.input,Q,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(b.defined(Z.blend))if(b.string(g2[Z.blend]))J.blend=g2[Z.blend];else throw b.invalidParameterError("blend","valid blend name",Z.blend);if(b.defined(Z.tile))if(b.bool(Z.tile))J.tile=Z.tile;else throw b.invalidParameterError("tile","boolean",Z.tile);if(b.defined(Z.left))if(b.integer(Z.left))J.left=Z.left;else throw b.invalidParameterError("left","integer",Z.left);if(b.defined(Z.top))if(b.integer(Z.top))J.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 J.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))J.gravity=Z.gravity;else if(b.string(Z.gravity)&&b.integer(this.constructor.gravity[Z.gravity]))J.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))J.premultiplied=Z.premultiplied;else throw b.invalidParameterError("premultiplied","boolean",Z.premultiplied);return J}),this}i$.exports=($)=>{$.prototype.composite=uJ,$.blend=g2}});var Z9=T((lK,$9)=>{/*!
25
- Copyright 2013 Lovell Fuller and others.
26
- SPDX-License-Identifier: Apache-2.0
27
- */var U=M0(),s$={integer:"integer",float:"float",approximate:"approximate"};function dJ($,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 mJ(){return this.options.input.autoOrient=!0,this}function cJ($){return this.options.flip=U.bool($)?$:!0,this}function lJ($){return this.options.flop=U.bool($)?$:!0,this}function pJ($,Z){let Q=[].concat(...$);if(Q.length===4&&Q.every(U.number))this.options.affineMatrix=Q;else throw U.invalidParameterError("matrix","1x4 or 2x2 array",$);if(U.defined(Z))if(U.object(Z)){if(this._setBackgroundColourOption("affineBackground",Z.background),U.defined(Z.idx))if(U.number(Z.idx))this.options.affineIdx=Z.idx;else throw U.invalidParameterError("options.idx","number",Z.idx);if(U.defined(Z.idy))if(U.number(Z.idy))this.options.affineIdy=Z.idy;else throw U.invalidParameterError("options.idy","number",Z.idy);if(U.defined(Z.odx))if(U.number(Z.odx))this.options.affineOdx=Z.odx;else throw U.invalidParameterError("options.odx","number",Z.odx);if(U.defined(Z.ody))if(U.number(Z.ody))this.options.affineOdy=Z.ody;else throw U.invalidParameterError("options.ody","number",Z.ody);if(U.defined(Z.interpolator))if(U.inArray(Z.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=Z.interpolator;else throw U.invalidParameterError("options.interpolator","valid interpolator name",Z.interpolator)}else throw U.invalidParameterError("options","object",Z);return this}function aJ($,Z,Q){if(!U.defined($))this.options.sharpenSigma=-1;else if(U.bool($))this.options.sharpenSigma=$?-1:0;else if(U.number($)&&U.inRange($,0.01,1e4)){if(this.options.sharpenSigma=$,U.defined(Z))if(U.number(Z)&&U.inRange(Z,0,1e4))this.options.sharpenM1=Z;else throw U.invalidParameterError("flat","number between 0 and 10000",Z);if(U.defined(Q))if(U.number(Q)&&U.inRange(Q,0,1e4))this.options.sharpenM2=Q;else throw U.invalidParameterError("jagged","number between 0 and 10000",Q)}else if(U.plainObject($)){if(U.number($.sigma)&&U.inRange($.sigma,0.000001,10))this.options.sharpenSigma=$.sigma;else throw U.invalidParameterError("options.sigma","number between 0.000001 and 10",$.sigma);if(U.defined($.m1))if(U.number($.m1)&&U.inRange($.m1,0,1e6))this.options.sharpenM1=$.m1;else throw U.invalidParameterError("options.m1","number between 0 and 1000000",$.m1);if(U.defined($.m2))if(U.number($.m2)&&U.inRange($.m2,0,1e6))this.options.sharpenM2=$.m2;else throw U.invalidParameterError("options.m2","number between 0 and 1000000",$.m2);if(U.defined($.x1))if(U.number($.x1)&&U.inRange($.x1,0,1e6))this.options.sharpenX1=$.x1;else throw U.invalidParameterError("options.x1","number between 0 and 1000000",$.x1);if(U.defined($.y2))if(U.number($.y2)&&U.inRange($.y2,0,1e6))this.options.sharpenY2=$.y2;else throw U.invalidParameterError("options.y2","number between 0 and 1000000",$.y2);if(U.defined($.y3))if(U.number($.y3)&&U.inRange($.y3,0,1e6))this.options.sharpenY3=$.y3;else throw U.invalidParameterError("options.y3","number between 0 and 1000000",$.y3)}else throw U.invalidParameterError("sigma","number between 0.01 and 10000",$);return this}function rJ($){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 nJ($){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(s$[$.precision]))this.options.precision=s$[$.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 e$($){if(!U.defined($))this.options.dilateWidth=1;else if(U.integer($)&&$>0)this.options.dilateWidth=$;else throw U.invalidParameterError("dilate","positive integer",e$);return this}function t$($){if(!U.defined($))this.options.erodeWidth=1;else if(U.integer($)&&$>0)this.options.erodeWidth=$;else throw U.invalidParameterError("erode","positive integer",t$);return this}function iJ($){if(this.options.flatten=U.bool($)?$:!0,U.object($))this._setBackgroundColourOption("flattenBackground",$.background);return this}function oJ(){return this.options.unflatten=!0,this}function sJ($,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 eJ($){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 tJ($){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 $3($){return this.normalise($)}function Z3($){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 Q3($){if(!U.object($)||!Array.isArray($.kernel)||!U.integer($.width)||!U.integer($.height)||!U.inRange($.width,3,1001)||!U.inRange($.height,3,1001)||$.height*$.width!==$.kernel.length)throw Error("Invalid convolution kernel");if(!U.integer($.scale))$.scale=$.kernel.reduce((Z,Q)=>Z+Q,0);if($.scale<1)$.scale=1;if(!U.integer($.offset))$.offset=0;return this.options.convKernel=$,this}function J3($,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 X3($,Z,Q){if(this.options.boolean=this._createInputDescriptor($,Q),U.string(Z)&&U.inArray(Z,["and","or","eor"]))this.options.booleanOp=Z;else throw U.invalidParameterError("operator","one of: and, or, eor",Z);return this}function V3($,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 Y3($){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 K3($){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}$9.exports=($)=>{Object.assign($.prototype,{autoOrient:mJ,rotate:dJ,flip:cJ,flop:lJ,affine:pJ,sharpen:aJ,erode:t$,dilate:e$,median:rJ,blur:nJ,flatten:iJ,unflatten:oJ,gamma:sJ,negate:eJ,normalise:tJ,normalize:$3,clahe:Z3,convolve:Q3,threshold:J3,boolean:X3,linear:V3,recomb:Y3,modulate:K3})}});var K9=T((pK,Y9)=>{var{defineProperty:c2,getOwnPropertyDescriptor:q3,getOwnPropertyNames:W3}=Object,H3=Object.prototype.hasOwnProperty,z3=($,Z)=>{for(var Q in Z)c2($,Q,{get:Z[Q],enumerable:!0})},G3=($,Z,Q,J)=>{if(Z&&typeof Z==="object"||typeof Z==="function"){for(let X of W3(Z))if(!H3.call($,X)&&X!==Q)c2($,X,{get:()=>Z[X],enumerable:!(J=q3(Z,X))||J.enumerable})}return $},j3=($)=>G3(c2({},"__esModule",{value:!0}),$),Q9={};z3(Q9,{default:()=>M3});Y9.exports=j3(Q9);var k0={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]},J9=Object.create(null);for(let $ in k0)if(Object.hasOwn(k0,$))J9[k0[$]]=$;var q0={to:{},get:{}};q0.get=function($){let Z=$.slice(0,3).toLowerCase(),Q,J;switch(Z){case"hsl":{Q=q0.get.hsl($),J="hsl";break}case"hwb":{Q=q0.get.hwb($),J="hwb";break}default:{Q=q0.get.rgb($),J="rgb";break}}if(!Q)return null;return{model:J,value:Q}};q0.get.rgb=function($){if(!$)return null;let Z=/^#([a-f\d]{3,4})$/i,Q=/^#([a-f\d]{6})([a-f\d]{2})?$/i,J=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,X=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,V=/^(\w+)$/,Y=[0,0,0,1],K,q,W;if(K=$.match(Q)){W=K[2],K=K[1];for(q=0;q<3;q++){let z=q*2;Y[q]=Number.parseInt(K.slice(z,z+2),16)}if(W)Y[3]=Number.parseInt(W,16)/255}else if(K=$.match(Z)){K=K[1],W=K[3];for(q=0;q<3;q++)Y[q]=Number.parseInt(K[q]+K[q],16);if(W)Y[3]=Number.parseInt(W+W,16)/255}else if(K=$.match(J)){for(q=0;q<3;q++)Y[q]=Number.parseInt(K[q+1],10);if(K[4])Y[3]=K[5]?Number.parseFloat(K[4])*0.01:Number.parseFloat(K[4])}else if(K=$.match(X)){for(q=0;q<3;q++)Y[q]=Math.round(Number.parseFloat(K[q+1])*2.55);if(K[4])Y[3]=K[5]?Number.parseFloat(K[4])*0.01:Number.parseFloat(K[4])}else if(K=$.match(V)){if(K[1]==="transparent")return[0,0,0,0];if(!Object.hasOwn(k0,K[1]))return null;return Y=k0[K[1]],Y[3]=1,Y}else return null;for(q=0;q<3;q++)Y[q]=e0(Y[q],0,255);return Y[3]=e0(Y[3],0,1),Y};q0.get.hsl=function($){if(!$)return null;let Z=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,Q=$.match(Z);if(Q){let J=Number.parseFloat(Q[4]),X=(Number.parseFloat(Q[1])%360+360)%360,V=e0(Number.parseFloat(Q[2]),0,100),Y=e0(Number.parseFloat(Q[3]),0,100),K=e0(Number.isNaN(J)?1:J,0,1);return[X,V,Y,K]}return null};q0.get.hwb=function($){if(!$)return null;let Z=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,Q=$.match(Z);if(Q){let J=Number.parseFloat(Q[4]),X=(Number.parseFloat(Q[1])%360+360)%360,V=e0(Number.parseFloat(Q[2]),0,100),Y=e0(Number.parseFloat(Q[3]),0,100),K=e0(Number.isNaN(J)?1:J,0,1);return[X,V,Y,K]}return null};q0.to.hex=function(...$){return"#"+m6($[0])+m6($[1])+m6($[2])+($[3]<1?m6(Math.round($[3]*255)):"")};q0.to.rgb=function(...$){return $.length<4||$[3]===1?"rgb("+Math.round($[0])+", "+Math.round($[1])+", "+Math.round($[2])+")":"rgba("+Math.round($[0])+", "+Math.round($[1])+", "+Math.round($[2])+", "+$[3]+")"};q0.to.rgb.percent=function(...$){let Z=Math.round($[0]/255*100),Q=Math.round($[1]/255*100),J=Math.round($[2]/255*100);return $.length<4||$[3]===1?"rgb("+Z+"%, "+Q+"%, "+J+"%)":"rgba("+Z+"%, "+Q+"%, "+J+"%, "+$[3]+")"};q0.to.hsl=function(...$){return $.length<4||$[3]===1?"hsl("+$[0]+", "+$[1]+"%, "+$[2]+"%)":"hsla("+$[0]+", "+$[1]+"%, "+$[2]+"%, "+$[3]+")"};q0.to.hwb=function(...$){let Z="";if($.length>=4&&$[3]!==1)Z=", "+$[3];return"hwb("+$[0]+", "+$[1]+"%, "+$[2]+"%"+Z+")"};q0.to.keyword=function(...$){return J9[$.slice(0,3)]};function e0($,Z,Q){return Math.min(Math.max(Z,$),Q)}function m6($){let Z=Math.round($).toString(16).toUpperCase();return Z.length<2?"0"+Z:Z}var N4=q0,X9={};for(let $ of Object.keys(k0))X9[k0[$]]=$;var R={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"]}},H4=R,m0=0.008856451679035631;function D4($){let Z=$>0.0031308?1.055*$**0.4166666666666667-0.055:$*12.92;return Math.min(Math.max(0,Z),1)}function I4($){return $>0.04045?(($+0.055)/1.055)**2.4:$/12.92}for(let $ of Object.keys(R)){if(!("channels"in R[$]))throw Error("missing channels property: "+$);if(!("labels"in R[$]))throw Error("missing channel labels property: "+$);if(R[$].labels.length!==R[$].channels)throw Error("channel and label counts mismatch: "+$);let{channels:Z,labels:Q}=R[$];delete R[$].channels,delete R[$].labels,Object.defineProperty(R[$],"channels",{value:Z}),Object.defineProperty(R[$],"labels",{value:Q})}R.rgb.hsl=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.min(Z,Q,J),V=Math.max(Z,Q,J),Y=V-X,K,q;switch(V){case X:{K=0;break}case Z:{K=(Q-J)/Y;break}case Q:{K=2+(J-Z)/Y;break}case J:{K=4+(Z-Q)/Y;break}}if(K=Math.min(K*60,360),K<0)K+=360;let W=(X+V)/2;if(V===X)q=0;else if(W<=0.5)q=Y/(V+X);else q=Y/(2-V-X);return[K,q*100,W*100]};R.rgb.hsv=function($){let Z,Q,J,X,V,Y=$[0]/255,K=$[1]/255,q=$[2]/255,W=Math.max(Y,K,q),z=W-Math.min(Y,K,q),G=function(A){return(W-A)/6/z+0.5};if(z===0)X=0,V=0;else{switch(V=z/W,Z=G(Y),Q=G(K),J=G(q),W){case Y:{X=J-Q;break}case K:{X=0.3333333333333333+Z-J;break}case q:{X=0.6666666666666666+Q-Z;break}}if(X<0)X+=1;else if(X>1)X-=1}return[X*360,V*100,W*100]};R.rgb.hwb=function($){let Z=$[0],Q=$[1],J=$[2],X=R.rgb.hsl($)[0],V=0.00392156862745098*Math.min(Z,Math.min(Q,J));return J=1-0.00392156862745098*Math.max(Z,Math.max(Q,J)),[X,V*100,J*100]};R.rgb.oklab=function($){let Z=I4($[0]/255),Q=I4($[1]/255),J=I4($[2]/255),X=Math.cbrt(0.4122214708*Z+0.5363325363*Q+0.0514459929*J),V=Math.cbrt(0.2119034982*Z+0.6806995451*Q+0.1073969566*J),Y=Math.cbrt(0.0883024619*Z+0.2817188376*Q+0.6299787005*J),K=0.2104542553*X+0.793617785*V-0.0040720468*Y,q=1.9779984951*X-2.428592205*V+0.4505937099*Y,W=0.0259040371*X+0.7827717662*V-0.808675766*Y;return[K*100,q*100,W*100]};R.rgb.cmyk=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.min(1-Z,1-Q,1-J),V=(1-Z-X)/(1-X)||0,Y=(1-Q-X)/(1-X)||0,K=(1-J-X)/(1-X)||0;return[V*100,Y*100,K*100,X*100]};function U3($,Z){return($[0]-Z[0])**2+($[1]-Z[1])**2+($[2]-Z[2])**2}R.rgb.keyword=function($){let Z=X9[$];if(Z)return Z;let Q=Number.POSITIVE_INFINITY,J;for(let X of Object.keys(k0)){let V=k0[X],Y=U3($,V);if(Y<Q)Q=Y,J=X}return J};R.keyword.rgb=function($){return k0[$]};R.rgb.xyz=function($){let Z=I4($[0]/255),Q=I4($[1]/255),J=I4($[2]/255),X=Z*0.4124564+Q*0.3575761+J*0.1804375,V=Z*0.2126729+Q*0.7151522+J*0.072175,Y=Z*0.0193339+Q*0.119192+J*0.9503041;return[X*100,V*100,Y*100]};R.rgb.lab=function($){let Z=R.rgb.xyz($),Q=Z[0],J=Z[1],X=Z[2];Q/=95.047,J/=100,X/=108.883,Q=Q>m0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,J=J>m0?J**0.3333333333333333:7.787*J+0.13793103448275862,X=X>m0?X**0.3333333333333333:7.787*X+0.13793103448275862;let V=116*J-16,Y=500*(Q-J),K=200*(J-X);return[V,Y,K]};R.hsl.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100,X,V;if(Q===0)return V=J*255,[V,V,V];let Y=J<0.5?J*(1+Q):J+Q-J*Q,K=2*J-Y,q=[0,0,0];for(let W=0;W<3;W++){if(X=Z+0.3333333333333333*-(W-1),X<0)X++;if(X>1)X--;if(6*X<1)V=K+(Y-K)*6*X;else if(2*X<1)V=Y;else if(3*X<2)V=K+(Y-K)*(0.6666666666666666-X)*6;else V=K;q[W]=V*255}return q};R.hsl.hsv=function($){let Z=$[0],Q=$[1]/100,J=$[2]/100,X=Q,V=Math.max(J,0.01);J*=2,Q*=J<=1?J:2-J,X*=V<=1?V:2-V;let Y=(J+Q)/2,K=J===0?2*X/(V+X):2*Q/(J+Q);return[Z,K*100,Y*100]};R.hsv.rgb=function($){let Z=$[0]/60,Q=$[1]/100,J=$[2]/100,X=Math.floor(Z)%6,V=Z-Math.floor(Z),Y=255*J*(1-Q),K=255*J*(1-Q*V),q=255*J*(1-Q*(1-V));switch(J*=255,X){case 0:return[J,q,Y];case 1:return[K,J,Y];case 2:return[Y,J,q];case 3:return[Y,K,J];case 4:return[q,Y,J];case 5:return[J,Y,K]}};R.hsv.hsl=function($){let Z=$[0],Q=$[1]/100,J=$[2]/100,X=Math.max(J,0.01),V,Y;Y=(2-Q)*J;let K=(2-Q)*X;return V=Q*X,V/=K<=1?K:2-K,V=V||0,Y/=2,[Z,V*100,Y*100]};R.hwb.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100,X=Q+J,V;if(X>1)Q/=X,J/=X;let Y=Math.floor(6*Z),K=1-J;if(V=6*Z-Y,(Y&1)!==0)V=1-V;let q=Q+V*(K-Q),W,z,G;switch(Y){default:case 6:case 0:{W=K,z=q,G=Q;break}case 1:{W=q,z=K,G=Q;break}case 2:{W=Q,z=K,G=q;break}case 3:{W=Q,z=q,G=K;break}case 4:{W=q,z=Q,G=K;break}case 5:{W=K,z=Q,G=q;break}}return[W*255,z*255,G*255]};R.cmyk.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=$[3]/100,V=1-Math.min(1,Z*(1-X)+X),Y=1-Math.min(1,Q*(1-X)+X),K=1-Math.min(1,J*(1-X)+X);return[V*255,Y*255,K*255]};R.xyz.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X,V,Y;return X=Z*3.2404542+Q*-1.5371385+J*-0.4985314,V=Z*-0.969266+Q*1.8760108+J*0.041556,Y=Z*0.0556434+Q*-0.2040259+J*1.0572252,X=D4(X),V=D4(V),Y=D4(Y),[X*255,V*255,Y*255]};R.xyz.lab=function($){let Z=$[0],Q=$[1],J=$[2];Z/=95.047,Q/=100,J/=108.883,Z=Z>m0?Z**0.3333333333333333:7.787*Z+0.13793103448275862,Q=Q>m0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,J=J>m0?J**0.3333333333333333:7.787*J+0.13793103448275862;let X=116*Q-16,V=500*(Z-Q),Y=200*(Q-J);return[X,V,Y]};R.xyz.oklab=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=Math.cbrt(0.8189330101*Z+0.3618667424*Q-0.1288597137*J),V=Math.cbrt(0.0329845436*Z+0.9293118715*Q+0.0361456387*J),Y=Math.cbrt(0.0482003018*Z+0.2643662691*Q+0.633851707*J),K=0.2104542553*X+0.793617785*V-0.0040720468*Y,q=1.9779984951*X-2.428592205*V+0.4505937099*Y,W=0.0259040371*X+0.7827717662*V-0.808675766*Y;return[K*100,q*100,W*100]};R.oklab.oklch=function($){return R.lab.lch($)};R.oklab.xyz=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=(0.999999998*Z+0.396337792*Q+0.215803758*J)**3,V=(1.000000008*Z-0.105561342*Q-0.063854175*J)**3,Y=(1.000000055*Z-0.089484182*Q-1.291485538*J)**3,K=1.227013851*X-0.55779998*V+0.281256149*Y,q=-0.040580178*X+1.11225687*V-0.071676679*Y,W=-0.076381285*X-0.421481978*V+1.58616322*Y;return[K*100,q*100,W*100]};R.oklab.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=(Z+0.3963377774*Q+0.2158037573*J)**3,V=(Z-0.1055613458*Q-0.0638541728*J)**3,Y=(Z-0.0894841775*Q-1.291485548*J)**3,K=D4(4.0767416621*X-3.3077115913*V+0.2309699292*Y),q=D4(-1.2684380046*X+2.6097574011*V-0.3413193965*Y),W=D4(-0.0041960863*X-0.7034186147*V+1.707614701*Y);return[K*255,q*255,W*255]};R.oklch.oklab=function($){return R.lch.lab($)};R.lab.xyz=function($){let Z=$[0],Q=$[1],J=$[2],X,V,Y;V=(Z+16)/116,X=Q/500+V,Y=V-J/200;let K=V**3,q=X**3,W=Y**3;return V=K>m0?K:(V-0.13793103448275862)/7.787,X=q>m0?q:(X-0.13793103448275862)/7.787,Y=W>m0?W:(Y-0.13793103448275862)/7.787,X*=95.047,V*=100,Y*=108.883,[X,V,Y]};R.lab.lch=function($){let Z=$[0],Q=$[1],J=$[2],X;if(X=Math.atan2(J,Q)*360/2/Math.PI,X<0)X+=360;let Y=Math.sqrt(Q*Q+J*J);return[Z,Y,X]};R.lch.lab=function($){let Z=$[0],Q=$[1],X=$[2]/360*2*Math.PI,V=Q*Math.cos(X),Y=Q*Math.sin(X);return[Z,V,Y]};R.rgb.ansi16=function($,Z=null){let[Q,J,X]=$,V=Z===null?R.rgb.hsv($)[2]:Z;if(V=Math.round(V/50),V===0)return 30;let Y=30+(Math.round(X/255)<<2|Math.round(J/255)<<1|Math.round(Q/255));if(V===2)Y+=60;return Y};R.hsv.ansi16=function($){return R.rgb.ansi16(R.hsv.rgb($),$[2])};R.rgb.ansi256=function($){let Z=$[0],Q=$[1],J=$[2];if(Z>>4===Q>>4&&Q>>4===J>>4){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}return 16+36*Math.round(Z/255*5)+6*Math.round(Q/255*5)+Math.round(J/255*5)};R.ansi16.rgb=function($){$=$[0];let Z=$%10;if(Z===0||Z===7){if($>50)Z+=3.5;return Z=Z/10.5*255,[Z,Z,Z]}let Q=(Math.trunc($>50)+1)*0.5,J=(Z&1)*Q*255,X=(Z>>1&1)*Q*255,V=(Z>>2&1)*Q*255;return[J,X,V]};R.ansi256.rgb=function($){if($=$[0],$>=232){let V=($-232)*10+8;return[V,V,V]}$-=16;let Z,Q=Math.floor($/36)/5*255,J=Math.floor((Z=$%36)/6)/5*255,X=Z%6/5*255;return[Q,J,X]};R.rgb.hex=function($){let Q=(((Math.round($[0])&255)<<16)+((Math.round($[1])&255)<<8)+(Math.round($[2])&255)).toString(16).toUpperCase();return"000000".slice(Q.length)+Q};R.hex.rgb=function($){let Z=$.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!Z)return[0,0,0];let Q=Z[0];if(Z[0].length===3)Q=[...Q].map((K)=>K+K).join("");let J=Number.parseInt(Q,16),X=J>>16&255,V=J>>8&255,Y=J&255;return[X,V,Y]};R.rgb.hcg=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.max(Math.max(Z,Q),J),V=Math.min(Math.min(Z,Q),J),Y=X-V,K,q=Y<1?V/(1-Y):0;if(Y<=0)K=0;else if(X===Z)K=(Q-J)/Y%6;else if(X===Q)K=2+(J-Z)/Y;else K=4+(Z-Q)/Y;return K/=6,K%=1,[K*360,Y*100,q*100]};R.hsl.hcg=function($){let Z=$[1]/100,Q=$[2]/100,J=Q<0.5?2*Z*Q:2*Z*(1-Q),X=0;if(J<1)X=(Q-0.5*J)/(1-J);return[$[0],J*100,X*100]};R.hsv.hcg=function($){let Z=$[1]/100,Q=$[2]/100,J=Z*Q,X=0;if(J<1)X=(Q-J)/(1-J);return[$[0],J*100,X*100]};R.hcg.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100;if(Q===0)return[J*255,J*255,J*255];let X=[0,0,0],V=Z%1*6,Y=V%1,K=1-Y,q=0;switch(Math.floor(V)){case 0:{X[0]=1,X[1]=Y,X[2]=0;break}case 1:{X[0]=K,X[1]=1,X[2]=0;break}case 2:{X[0]=0,X[1]=1,X[2]=Y;break}case 3:{X[0]=0,X[1]=K,X[2]=1;break}case 4:{X[0]=Y,X[1]=0,X[2]=1;break}default:X[0]=1,X[1]=0,X[2]=K}return q=(1-Q)*J,[(Q*X[0]+q)*255,(Q*X[1]+q)*255,(Q*X[2]+q)*255]};R.hcg.hsv=function($){let Z=$[1]/100,Q=$[2]/100,J=Z+Q*(1-Z),X=0;if(J>0)X=Z/J;return[$[0],X*100,J*100]};R.hcg.hsl=function($){let Z=$[1]/100,J=$[2]/100*(1-Z)+0.5*Z,X=0;if(J>0&&J<0.5)X=Z/(2*J);else if(J>=0.5&&J<1)X=Z/(2*(1-J));return[$[0],X*100,J*100]};R.hcg.hwb=function($){let Z=$[1]/100,Q=$[2]/100,J=Z+Q*(1-Z);return[$[0],(J-Z)*100,(1-J)*100]};R.hwb.hcg=function($){let Z=$[1]/100,J=1-$[2]/100,X=J-Z,V=0;if(X<1)V=(J-X)/(1-X);return[$[0],X*100,V*100]};R.apple.rgb=function($){return[$[0]/65535*255,$[1]/65535*255,$[2]/65535*255]};R.rgb.apple=function($){return[$[0]/255*65535,$[1]/255*65535,$[2]/255*65535]};R.gray.rgb=function($){return[$[0]/100*255,$[0]/100*255,$[0]/100*255]};R.gray.hsl=function($){return[0,0,$[0]]};R.gray.hsv=R.gray.hsl;R.gray.hwb=function($){return[0,100,$[0]]};R.gray.cmyk=function($){return[0,0,0,$[0]]};R.gray.lab=function($){return[$[0],0,0]};R.gray.hex=function($){let Z=Math.round($[0]/100*255)&255,J=((Z<<16)+(Z<<8)+Z).toString(16).toUpperCase();return"000000".slice(J.length)+J};R.rgb.gray=function($){return[($[0]+$[1]+$[2])/3/255*100]};function A3(){let $={},Z=Object.keys(H4);for(let{length:Q}=Z,J=0;J<Q;J++)$[Z[J]]={distance:-1,parent:null};return $}function B3($){let Z=A3(),Q=[$];Z[$].distance=0;while(Q.length>0){let J=Q.pop(),X=Object.keys(H4[J]);for(let{length:V}=X,Y=0;Y<V;Y++){let K=X[Y],q=Z[K];if(q.distance===-1)q.distance=Z[J].distance+1,q.parent=J,Q.unshift(K)}}return Z}function L3($,Z){return function(Q){return Z($(Q))}}function _3($,Z){let Q=[Z[$].parent,$],J=H4[Z[$].parent][$],X=Z[$].parent;while(Z[X].parent)Q.unshift(Z[X].parent),J=L3(H4[Z[X].parent][X],J),X=Z[X].parent;return J.conversion=Q,J}function w3($){let Z=B3($),Q={},J=Object.keys(Z);for(let{length:X}=J,V=0;V<X;V++){let Y=J[V];if(Z[Y].parent===null)continue;Q[Y]=_3(Y,Z)}return Q}var F3=w3,P4={},R3=Object.keys(H4);function C3($){let Z=function(...Q){let J=Q[0];if(J===void 0||J===null)return J;if(J.length>1)Q=J;return $(Q)};if("conversion"in $)Z.conversion=$.conversion;return Z}function N3($){let Z=function(...Q){let J=Q[0];if(J===void 0||J===null)return J;if(J.length>1)Q=J;let X=$(Q);if(typeof X==="object")for(let{length:V}=X,Y=0;Y<V;Y++)X[Y]=Math.round(X[Y]);return X};if("conversion"in $)Z.conversion=$.conversion;return Z}for(let $ of R3){P4[$]={},Object.defineProperty(P4[$],"channels",{value:H4[$].channels}),Object.defineProperty(P4[$],"labels",{value:H4[$].labels});let Z=F3($),Q=Object.keys(Z);for(let J of Q){let X=Z[J];P4[$][J]=N3(X),P4[$][J].raw=C3(X)}}var H0=P4,V9=["keyword","gray","hex"],u2={};for(let $ of Object.keys(H0))u2[[...H0[$].labels].sort().join("")]=$;var d2={};function n($,Z){if(!(this instanceof n))return new n($,Z);if(Z&&Z in V9)Z=null;if(Z&&!(Z in H0))throw Error("Unknown model: "+Z);let Q,J;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=N4.get($);if(X===null)throw Error("Unable to parse color from string: "+$);this.model=X.model,J=H0[this.model].channels,this.color=X.value.slice(0,J),this.valpha=typeof X.value[J]==="number"?X.value[J]:1}else if($.length>0){this.model=Z||"rgb",J=H0[this.model].channels;let X=Array.prototype.slice.call($,0,J);this.color=m2(X,J),this.valpha=typeof $[J]==="number"?$[J]:1}else if(typeof $==="number")this.model="rgb",this.color=[$>>16&255,$>>8&255,$&255],this.valpha=1;else{this.valpha=1;let X=Object.keys($);if("alpha"in $)X.splice(X.indexOf("alpha"),1),this.valpha=typeof $.alpha==="number"?$.alpha:0;let V=X.sort().join("");if(!(V in u2))throw Error("Unable to parse color from object: "+JSON.stringify($));this.model=u2[V];let{labels:Y}=H0[this.model],K=[];for(Q=0;Q<Y.length;Q++)K.push($[Y[Q]]);this.color=m2(K)}if(d2[this.model]){J=H0[this.model].channels;for(Q=0;Q<J;Q++){let X=d2[this.model][Q];if(X)this.color[Q]=X(this.color[Q])}}if(this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze)Object.freeze(this)}n.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string($){let Z=this.model in N4.to?this:this.rgb();Z=Z.round(typeof $==="number"?$:1);let Q=Z.valpha===1?Z.color:[...Z.color,this.valpha];return N4.to[Z.model](...Q)},percentString($){let Z=this.rgb().round(typeof $==="number"?$:1),Q=Z.valpha===1?Z.color:[...Z.color,this.valpha];return N4.to.rgb.percent(...Q)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let $={},{channels:Z}=H0[this.model],{labels:Q}=H0[this.model];for(let J=0;J<Z;J++)$[Q[J]]=this.color[J];if(this.valpha!==1)$.alpha=this.valpha;return $},unitArray(){let $=this.rgb().color;if($[0]/=255,$[1]/=255,$[2]/=255,this.valpha!==1)$.push(this.valpha);return $},unitObject(){let $=this.rgb().object();if($.r/=255,$.g/=255,$.b/=255,this.valpha!==1)$.alpha=this.valpha;return $},round($){return $=Math.max($||0,0),new n([...this.color.map(D3($)),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 H0[this.model].keyword(this.color)},hex($){if($!==void 0)return new n($);return N4.to.hex(...this.rgb().round().color)},hexa($){if($!==void 0)return new n($);let Z=this.rgb().round().color,Q=Math.round(this.valpha*255).toString(16).toUpperCase();if(Q.length===1)Q="0"+Q;return N4.to.hex(...Z)+Q},rgbNumber(){let $=this.rgb().color;return($[0]&255)<<16|($[1]&255)<<8|$[2]&255},luminosity(){let $=this.rgb().color,Z=[];for(let[Q,J]of $.entries()){let X=J/255;Z[Q]=X<=0.04045?X/12.92:((X+0.055)/1.055)**2.4}return 0.2126*Z[0]+0.7152*Z[1]+0.0722*Z[2]},contrast($){let Z=this.luminosity(),Q=$.luminosity();if(Z>Q)return(Z+0.05)/(Q+0.05);return(Q+0.05)/(Z+0.05)},level($){let Z=this.contrast($);if(Z>=7)return"AAA";return Z>=4.5?"AA":""},isDark(){let $=this.rgb().color;return($[0]*2126+$[1]*7152+$[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let $=this.rgb();for(let Z=0;Z<3;Z++)$.color[Z]=255-$.color[Z];return $},lighten($){let Z=this.hsl();return Z.color[2]+=Z.color[2]*$,Z},darken($){let Z=this.hsl();return Z.color[2]-=Z.color[2]*$,Z},saturate($){let Z=this.hsl();return Z.color[1]+=Z.color[1]*$,Z},desaturate($){let Z=this.hsl();return Z.color[1]-=Z.color[1]*$,Z},whiten($){let Z=this.hwb();return Z.color[1]+=Z.color[1]*$,Z},blacken($){let Z=this.hwb();return Z.color[2]+=Z.color[2]*$,Z},grayscale(){let $=this.rgb().color,Z=$[0]*0.3+$[1]*0.59+$[2]*0.11;return 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(),Q=Z.color[0];return Q=(Q+$)%360,Q=Q<0?360+Q:Q,Z.color[0]=Q,Z},mix($,Z){if(!$||!$.rgb)throw Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof $);let Q=$.rgb(),J=this.rgb(),X=Z===void 0?0.5:Z,V=2*X-1,Y=Q.alpha()-J.alpha(),K=((V*Y===-1?V:(V+Y)/(1+V*Y))+1)/2,q=1-K;return n.rgb(K*Q.red()+q*J.red(),K*Q.green()+q*J.green(),K*Q.blue()+q*J.blue(),Q.alpha()*X+J.alpha()*(1-X))}};for(let $ of Object.keys(H0)){if(V9.includes($))continue;let{channels:Z}=H0[$];n.prototype[$]=function(...Q){if(this.model===$)return new n(this);if(Q.length>0)return new n(Q,$);return new n([...I3(H0[this.model][$].raw(this.color)),this.valpha],$)},n[$]=function(...Q){let J=Q[0];if(typeof J==="number")J=m2(Q,Z);return new n(J,$)}}function P3($,Z){return Number($.toFixed(Z))}function D3($){return function(Z){return P3(Z,$)}}function u($,Z,Q){$=Array.isArray($)?$:[$];for(let J of $)(d2[J]||=[])[Z]=Q;return $=$[0],function(J){let X;if(J!==void 0){if(Q)J=Q(J);return X=this[$](),X.color[Z]=J,X}if(X=this[$]().color[Z],Q)X=Q(X);return X}}function l($){return function(Z){return Math.max(0,Math.min($,Z))}}function I3($){return Array.isArray($)?$:[$]}function m2($,Z){for(let Q=0;Q<Z;Q++)if(typeof $[Q]!=="number")$[Q]=0;return $}var M3=n});var W9=T((aK,q9)=>{q9.exports=K9().default});var j9=T((rK,G9)=>{/*!
28
- Copyright 2013 Lovell Fuller and others.
29
- SPDX-License-Identifier: Apache-2.0
30
- */var S3=W9(),c0=M0(),H9={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function E3($){return this._setBackgroundColourOption("tint",$),this}function T3($){return this.options.greyscale=c0.bool($)?$:!0,this}function x3($){return this.greyscale($)}function k3($){if(!c0.string($))throw c0.invalidParameterError("colourspace","string",$);return this.options.colourspacePipeline=$,this}function v3($){return this.pipelineColourspace($)}function O3($){if(!c0.string($))throw c0.invalidParameterError("colourspace","string",$);return this.options.colourspace=$,this}function y3($){return this.toColourspace($)}function z9($){if(c0.object($)||c0.string($)&&$.length>=3&&$.length<=200){let Z=S3($);return[Z.red(),Z.green(),Z.blue(),Math.round(Z.alpha()*255)]}else throw c0.invalidParameterError("background","object or string",$)}function b3($,Z){if(c0.defined(Z))this.options[$]=z9(Z)}G9.exports=($)=>{Object.assign($.prototype,{tint:E3,greyscale:T3,grayscale:x3,pipelineColourspace:k3,pipelineColorspace:v3,toColourspace:O3,toColorspace:y3,_getBackgroundColourOption:z9,_setBackgroundColourOption:b3}),$.colourspace=H9,$.colorspace=H9}});var A9=T((nK,U9)=>{/*!
31
- Copyright 2013 Lovell Fuller and others.
32
- SPDX-License-Identifier: Apache-2.0
33
- */var v0=M0(),f3={and:"and",or:"or",eor:"eor"};function h3(){return this.options.removeAlpha=!0,this}function g3($){if(v0.defined($))if(v0.number($)&&v0.inRange($,0,1))this.options.ensureAlpha=$;else throw v0.invalidParameterError("alpha","number between 0 and 1",$);else this.options.ensureAlpha=1;return this}function u3($){let Z={red:0,green:1,blue:2,alpha:3};if(Object.keys(Z).includes($))$=Z[$];if(v0.integer($)&&v0.inRange($,0,4))this.options.extractChannel=$;else throw v0.invalidParameterError("channel","integer or one of: red, green, blue, alpha",$);return this}function d3($,Z){if(Array.isArray($))$.forEach(function(Q){this.options.joinChannelIn.push(this._createInputDescriptor(Q,Z))},this);else this.options.joinChannelIn.push(this._createInputDescriptor($,Z));return this}function m3($){if(v0.string($)&&v0.inArray($,["and","or","eor"]))this.options.bandBoolOp=$;else throw v0.invalidParameterError("boolOp","one of: and, or, eor",$);return this}U9.exports=($)=>{Object.assign($.prototype,{removeAlpha:h3,ensureAlpha:g3,extractChannel:u3,joinChannel:d3,bandbool:m3}),$.bool=f3}});var F9=T((iK,w9)=>{/*!
34
- Copyright 2013 Lovell Fuller and others.
35
- SPDX-License-Identifier: Apache-2.0
36
- */var l2=y("path"),H=M0(),M4=Q6(),B9=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"]]),c3=/\.(jp[2x]|j2[kc])$/i,L9=()=>Error("JP2 output requires libvips with support for OpenJPEG"),_9=($)=>1<<31-Math.clz32(Math.ceil(Math.log2($)));function l3($,Z){let Q;if(!H.string($))Q=Error("Missing output file path");else if(H.string(this.options.input.file)&&l2.resolve(this.options.input.file)===l2.resolve($))Q=Error("Cannot use same file for input and output");else if(c3.test(l2.extname($))&&!this.constructor.format.jp2k.output.file)Q=L9();if(Q)if(H.fn(Z))Z(Q);else return Promise.reject(Q);else{this.options.fileOut=$;let J=Error();return this._pipeline(Z,J)}return this}function p3($,Z){if(H.object($))this._setBooleanOption("resolveWithObject",$.resolveWithObject);else if(this.options.resolveWithObject)this.options.resolveWithObject=!1;this.options.fileOut="";let Q=Error();return this._pipeline(H.fn($)?$:Z,Q)}function a3(){return this.options.keepMetadata|=1,this}function r3($){if(H.object($))for(let[Z,Q]of Object.entries($))if(H.object(Q))for(let[J,X]of Object.entries(Q))if(H.string(X))this.options.withExif[`exif-${Z.toLowerCase()}-${J}`]=X;else throw H.invalidParameterError(`${Z}.${J}`,"string",X);else throw H.invalidParameterError(Z,"object",Q);else throw H.invalidParameterError("exif","object",$);return this.options.withExifMerge=!1,this.keepExif()}function n3($){return this.withExif($),this.options.withExifMerge=!0,this}function i3(){return this.options.keepMetadata|=8,this}function o3($,Z){if(H.string($))this.options.withIccProfile=$;else throw H.invalidParameterError("icc","string",$);if(this.keepIccProfile(),H.object(Z)){if(H.defined(Z.attach))if(H.bool(Z.attach)){if(!Z.attach)this.options.keepMetadata&=-9}else throw H.invalidParameterError("attach","boolean",Z.attach)}return this}function s3(){return this.options.keepMetadata|=2,this}function e3($){if(H.string($)&&$.length>0)this.options.withXmp=$,this.options.keepMetadata|=2;else throw H.invalidParameterError("xmp","non-empty string",$);return this}function t3(){return this.options.keepMetadata=31,this}function $X($){if(this.keepMetadata(),this.withIccProfile("srgb"),H.object($)){if(H.defined($.orientation))if(H.integer($.orientation)&&H.inRange($.orientation,1,8))this.options.withMetadataOrientation=$.orientation;else throw H.invalidParameterError("orientation","integer between 1 and 8",$.orientation);if(H.defined($.density))if(H.number($.density)&&$.density>0)this.options.withMetadataDensity=$.density;else throw H.invalidParameterError("density","positive number",$.density);if(H.defined($.icc))this.withIccProfile($.icc);if(H.defined($.exif))this.withExifMerge($.exif)}return this}function ZX($,Z){let Q=B9.get((H.object($)&&H.string($.id)?$.id:$).toLowerCase());if(!Q)throw H.invalidParameterError("format",`one of: ${[...B9.keys()].join(", ")}`,$);return this[Q](Z)}function QX($){if(H.object($)){if(H.defined($.quality))if(H.integer($.quality)&&H.inRange($.quality,1,100))this.options.jpegQuality=$.quality;else throw H.invalidParameterError("quality","integer between 1 and 100",$.quality);if(H.defined($.progressive))this._setBooleanOption("jpegProgressive",$.progressive);if(H.defined($.chromaSubsampling))if(H.string($.chromaSubsampling)&&H.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=$.chromaSubsampling;else throw H.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);let Z=H.bool($.optimizeCoding)?$.optimizeCoding:$.optimiseCoding;if(H.defined(Z))this._setBooleanOption("jpegOptimiseCoding",Z);if(H.defined($.mozjpeg))if(H.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 H.invalidParameterError("mozjpeg","boolean",$.mozjpeg);let Q=H.bool($.trellisQuantization)?$.trellisQuantization:$.trellisQuantisation;if(H.defined(Q))this._setBooleanOption("jpegTrellisQuantisation",Q);if(H.defined($.overshootDeringing))this._setBooleanOption("jpegOvershootDeringing",$.overshootDeringing);let J=H.bool($.optimizeScans)?$.optimizeScans:$.optimiseScans;if(H.defined(J)){if(this._setBooleanOption("jpegOptimiseScans",J),J)this.options.jpegProgressive=!0}let X=H.number($.quantizationTable)?$.quantizationTable:$.quantisationTable;if(H.defined(X))if(H.integer(X)&&H.inRange(X,0,8))this.options.jpegQuantisationTable=X;else throw H.invalidParameterError("quantisationTable","integer between 0 and 8",X)}return this._updateFormatOut("jpeg",$)}function JX($){if(H.object($)){if(H.defined($.progressive))this._setBooleanOption("pngProgressive",$.progressive);if(H.defined($.compressionLevel))if(H.integer($.compressionLevel)&&H.inRange($.compressionLevel,0,9))this.options.pngCompressionLevel=$.compressionLevel;else throw H.invalidParameterError("compressionLevel","integer between 0 and 9",$.compressionLevel);if(H.defined($.adaptiveFiltering))this._setBooleanOption("pngAdaptiveFiltering",$.adaptiveFiltering);let Z=$.colours||$.colors;if(H.defined(Z))if(H.integer(Z)&&H.inRange(Z,2,256))this.options.pngBitdepth=_9(Z);else throw H.invalidParameterError("colours","integer between 2 and 256",Z);if(H.defined($.palette))this._setBooleanOption("pngPalette",$.palette);else if([$.quality,$.effort,$.colours,$.colors,$.dither].some(H.defined))this._setBooleanOption("pngPalette",!0);if(this.options.pngPalette){if(H.defined($.quality))if(H.integer($.quality)&&H.inRange($.quality,0,100))this.options.pngQuality=$.quality;else throw H.invalidParameterError("quality","integer between 0 and 100",$.quality);if(H.defined($.effort))if(H.integer($.effort)&&H.inRange($.effort,1,10))this.options.pngEffort=$.effort;else throw H.invalidParameterError("effort","integer between 1 and 10",$.effort);if(H.defined($.dither))if(H.number($.dither)&&H.inRange($.dither,0,1))this.options.pngDither=$.dither;else throw H.invalidParameterError("dither","number between 0.0 and 1.0",$.dither)}}return this._updateFormatOut("png",$)}function XX($){if(H.object($)){if(H.defined($.quality))if(H.integer($.quality)&&H.inRange($.quality,1,100))this.options.webpQuality=$.quality;else throw H.invalidParameterError("quality","integer between 1 and 100",$.quality);if(H.defined($.alphaQuality))if(H.integer($.alphaQuality)&&H.inRange($.alphaQuality,0,100))this.options.webpAlphaQuality=$.alphaQuality;else throw H.invalidParameterError("alphaQuality","integer between 0 and 100",$.alphaQuality);if(H.defined($.lossless))this._setBooleanOption("webpLossless",$.lossless);if(H.defined($.nearLossless))this._setBooleanOption("webpNearLossless",$.nearLossless);if(H.defined($.smartSubsample))this._setBooleanOption("webpSmartSubsample",$.smartSubsample);if(H.defined($.smartDeblock))this._setBooleanOption("webpSmartDeblock",$.smartDeblock);if(H.defined($.preset))if(H.string($.preset)&&H.inArray($.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=$.preset;else throw H.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",$.preset);if(H.defined($.effort))if(H.integer($.effort)&&H.inRange($.effort,0,6))this.options.webpEffort=$.effort;else throw H.invalidParameterError("effort","integer between 0 and 6",$.effort);if(H.defined($.minSize))this._setBooleanOption("webpMinSize",$.minSize);if(H.defined($.mixed))this._setBooleanOption("webpMixed",$.mixed)}return p2($,this.options),this._updateFormatOut("webp",$)}function VX($){if(H.object($)){if(H.defined($.reuse))this._setBooleanOption("gifReuse",$.reuse);if(H.defined($.progressive))this._setBooleanOption("gifProgressive",$.progressive);let Z=$.colours||$.colors;if(H.defined(Z))if(H.integer(Z)&&H.inRange(Z,2,256))this.options.gifBitdepth=_9(Z);else throw H.invalidParameterError("colours","integer between 2 and 256",Z);if(H.defined($.effort))if(H.number($.effort)&&H.inRange($.effort,1,10))this.options.gifEffort=$.effort;else throw H.invalidParameterError("effort","integer between 1 and 10",$.effort);if(H.defined($.dither))if(H.number($.dither)&&H.inRange($.dither,0,1))this.options.gifDither=$.dither;else throw H.invalidParameterError("dither","number between 0.0 and 1.0",$.dither);if(H.defined($.interFrameMaxError))if(H.number($.interFrameMaxError)&&H.inRange($.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=$.interFrameMaxError;else throw H.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",$.interFrameMaxError);if(H.defined($.interPaletteMaxError))if(H.number($.interPaletteMaxError)&&H.inRange($.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=$.interPaletteMaxError;else throw H.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",$.interPaletteMaxError);if(H.defined($.keepDuplicateFrames))if(H.bool($.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",$.keepDuplicateFrames);else throw H.invalidParameterError("keepDuplicateFrames","boolean",$.keepDuplicateFrames)}return p2($,this.options),this._updateFormatOut("gif",$)}function YX($){if(!this.constructor.format.jp2k.output.buffer)throw L9();if(H.object($)){if(H.defined($.quality))if(H.integer($.quality)&&H.inRange($.quality,1,100))this.options.jp2Quality=$.quality;else throw H.invalidParameterError("quality","integer between 1 and 100",$.quality);if(H.defined($.lossless))if(H.bool($.lossless))this.options.jp2Lossless=$.lossless;else throw H.invalidParameterError("lossless","boolean",$.lossless);if(H.defined($.tileWidth))if(H.integer($.tileWidth)&&H.inRange($.tileWidth,1,32768))this.options.jp2TileWidth=$.tileWidth;else throw H.invalidParameterError("tileWidth","integer between 1 and 32768",$.tileWidth);if(H.defined($.tileHeight))if(H.integer($.tileHeight)&&H.inRange($.tileHeight,1,32768))this.options.jp2TileHeight=$.tileHeight;else throw H.invalidParameterError("tileHeight","integer between 1 and 32768",$.tileHeight);if(H.defined($.chromaSubsampling))if(H.string($.chromaSubsampling)&&H.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=$.chromaSubsampling;else throw H.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling)}return this._updateFormatOut("jp2",$)}function p2($,Z){if(H.object($)&&H.defined($.loop))if(H.integer($.loop)&&H.inRange($.loop,0,65535))Z.loop=$.loop;else throw H.invalidParameterError("loop","integer between 0 and 65535",$.loop);if(H.object($)&&H.defined($.delay))if(H.integer($.delay)&&H.inRange($.delay,0,65535))Z.delay=[$.delay];else if(Array.isArray($.delay)&&$.delay.every(H.integer)&&$.delay.every((Q)=>H.inRange(Q,0,65535)))Z.delay=$.delay;else throw H.invalidParameterError("delay","integer or an array of integers between 0 and 65535",$.delay)}function KX($){if(H.object($)){if(H.defined($.quality))if(H.integer($.quality)&&H.inRange($.quality,1,100))this.options.tiffQuality=$.quality;else throw H.invalidParameterError("quality","integer between 1 and 100",$.quality);if(H.defined($.bitdepth))if(H.integer($.bitdepth)&&H.inArray($.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=$.bitdepth;else throw H.invalidParameterError("bitdepth","1, 2, 4 or 8",$.bitdepth);if(H.defined($.tile))this._setBooleanOption("tiffTile",$.tile);if(H.defined($.tileWidth))if(H.integer($.tileWidth)&&$.tileWidth>0)this.options.tiffTileWidth=$.tileWidth;else throw H.invalidParameterError("tileWidth","integer greater than zero",$.tileWidth);if(H.defined($.tileHeight))if(H.integer($.tileHeight)&&$.tileHeight>0)this.options.tiffTileHeight=$.tileHeight;else throw H.invalidParameterError("tileHeight","integer greater than zero",$.tileHeight);if(H.defined($.miniswhite))this._setBooleanOption("tiffMiniswhite",$.miniswhite);if(H.defined($.pyramid))this._setBooleanOption("tiffPyramid",$.pyramid);if(H.defined($.xres))if(H.number($.xres)&&$.xres>0)this.options.tiffXres=$.xres;else throw H.invalidParameterError("xres","number greater than zero",$.xres);if(H.defined($.yres))if(H.number($.yres)&&$.yres>0)this.options.tiffYres=$.yres;else throw H.invalidParameterError("yres","number greater than zero",$.yres);if(H.defined($.compression))if(H.string($.compression)&&H.inArray($.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=$.compression;else throw H.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",$.compression);if(H.defined($.bigtiff))this._setBooleanOption("tiffBigtiff",$.bigtiff);if(H.defined($.predictor))if(H.string($.predictor)&&H.inArray($.predictor,["none","horizontal","float"]))this.options.tiffPredictor=$.predictor;else throw H.invalidParameterError("predictor","one of: none, horizontal, float",$.predictor);if(H.defined($.resolutionUnit))if(H.string($.resolutionUnit)&&H.inArray($.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=$.resolutionUnit;else throw H.invalidParameterError("resolutionUnit","one of: inch, cm",$.resolutionUnit)}return this._updateFormatOut("tiff",$)}function qX($){return this.heif({...$,compression:"av1"})}function WX($){if(H.object($)){if(H.string($.compression)&&H.inArray($.compression,["av1","hevc"]))this.options.heifCompression=$.compression;else throw H.invalidParameterError("compression","one of: av1, hevc",$.compression);if(H.defined($.quality))if(H.integer($.quality)&&H.inRange($.quality,1,100))this.options.heifQuality=$.quality;else throw H.invalidParameterError("quality","integer between 1 and 100",$.quality);if(H.defined($.lossless))if(H.bool($.lossless))this.options.heifLossless=$.lossless;else throw H.invalidParameterError("lossless","boolean",$.lossless);if(H.defined($.effort))if(H.integer($.effort)&&H.inRange($.effort,0,9))this.options.heifEffort=$.effort;else throw H.invalidParameterError("effort","integer between 0 and 9",$.effort);if(H.defined($.chromaSubsampling))if(H.string($.chromaSubsampling)&&H.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=$.chromaSubsampling;else throw H.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);if(H.defined($.bitdepth))if(H.integer($.bitdepth)&&H.inArray($.bitdepth,[8,10,12])){if($.bitdepth!==8&&this.constructor.versions.heif)throw H.invalidParameterError("bitdepth when using prebuilt binaries",8,$.bitdepth);this.options.heifBitdepth=$.bitdepth}else throw H.invalidParameterError("bitdepth","8, 10 or 12",$.bitdepth)}else throw H.invalidParameterError("options","Object",$);return this._updateFormatOut("heif",$)}function HX($){if(H.object($)){if(H.defined($.quality))if(H.integer($.quality)&&H.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 H.invalidParameterError("quality","integer between 1 and 100",$.quality);else if(H.defined($.distance))if(H.number($.distance)&&H.inRange($.distance,0,15))this.options.jxlDistance=$.distance;else throw H.invalidParameterError("distance","number between 0.0 and 15.0",$.distance);if(H.defined($.decodingTier))if(H.integer($.decodingTier)&&H.inRange($.decodingTier,0,4))this.options.jxlDecodingTier=$.decodingTier;else throw H.invalidParameterError("decodingTier","integer between 0 and 4",$.decodingTier);if(H.defined($.lossless))if(H.bool($.lossless))this.options.jxlLossless=$.lossless;else throw H.invalidParameterError("lossless","boolean",$.lossless);if(H.defined($.effort))if(H.integer($.effort)&&H.inRange($.effort,1,9))this.options.jxlEffort=$.effort;else throw H.invalidParameterError("effort","integer between 1 and 9",$.effort)}return p2($,this.options),this._updateFormatOut("jxl",$)}function zX($){if(H.object($)){if(H.defined($.depth))if(H.string($.depth)&&H.inArray($.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=$.depth;else throw H.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",$.depth)}return this._updateFormatOut("raw")}function GX($){if(H.object($)){if(H.defined($.size))if(H.integer($.size)&&H.inRange($.size,1,8192))this.options.tileSize=$.size;else throw H.invalidParameterError("size","integer between 1 and 8192",$.size);if(H.defined($.overlap))if(H.integer($.overlap)&&H.inRange($.overlap,0,8192)){if($.overlap>this.options.tileSize)throw H.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,$.overlap);this.options.tileOverlap=$.overlap}else throw H.invalidParameterError("overlap","integer between 0 and 8192",$.overlap);if(H.defined($.container))if(H.string($.container)&&H.inArray($.container,["fs","zip"]))this.options.tileContainer=$.container;else throw H.invalidParameterError("container","one of: fs, zip",$.container);if(H.defined($.layout))if(H.string($.layout)&&H.inArray($.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=$.layout;else throw H.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",$.layout);if(H.defined($.angle))if(H.integer($.angle)&&!($.angle%90))this.options.tileAngle=$.angle;else throw H.invalidParameterError("angle","positive/negative multiple of 90",$.angle);if(this._setBackgroundColourOption("tileBackground",$.background),H.defined($.depth))if(H.string($.depth)&&H.inArray($.depth,["onepixel","onetile","one"]))this.options.tileDepth=$.depth;else throw H.invalidParameterError("depth","one of: onepixel, onetile, one",$.depth);if(H.defined($.skipBlanks))if(H.integer($.skipBlanks)&&H.inRange($.skipBlanks,-1,65535))this.options.tileSkipBlanks=$.skipBlanks;else throw H.invalidParameterError("skipBlanks","integer between -1 and 255/65535",$.skipBlanks);else if(H.defined($.layout)&&$.layout==="google")this.options.tileSkipBlanks=5;let Z=H.bool($.center)?$.center:$.centre;if(H.defined(Z))this._setBooleanOption("tileCentre",Z);if(H.defined($.id))if(H.string($.id))this.options.tileId=$.id;else throw H.invalidParameterError("id","string",$.id);if(H.defined($.basename))if(H.string($.basename))this.options.tileBasename=$.basename;else throw H.invalidParameterError("basename","string",$.basename)}if(H.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw H.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function jX($){if(!H.plainObject($))throw H.invalidParameterError("options","object",$);if(H.integer($.seconds)&&H.inRange($.seconds,0,3600))this.options.timeoutSeconds=$.seconds;else throw H.invalidParameterError("seconds","integer between 0 and 3600",$.seconds);return this}function UX($,Z){if(!(H.object(Z)&&Z.force===!1))this.options.formatOut=$;return this}function AX($,Z){if(H.bool(Z))this.options[$]=Z;else throw H.invalidParameterError($,"boolean",Z)}function BX(){if(!this.options.streamOut){this.options.streamOut=!0;let $=Error();this._pipeline(void 0,$)}}function LX($,Z){if(typeof $==="function"){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),M4.pipeline(this.options,(Q,J,X)=>{if(Q)$(H.nativeError(Q,Z));else $(null,J,X)})});else M4.pipeline(this.options,(Q,J,X)=>{if(Q)$(H.nativeError(Q,Z));else $(null,J,X)});return this}else if(this.options.streamOut){if(this._isStreamInput()){if(this.once("finish",()=>{this._flattenBufferIn(),M4.pipeline(this.options,(Q,J,X)=>{if(Q)this.emit("error",H.nativeError(Q,Z));else this.emit("info",X),this.push(J);this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished)this.emit("finish")}else M4.pipeline(this.options,(Q,J,X)=>{if(Q)this.emit("error",H.nativeError(Q,Z));else this.emit("info",X),this.push(J);this.push(null),this.on("end",()=>this.emit("close"))});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{this.once("finish",()=>{this._flattenBufferIn(),M4.pipeline(this.options,(X,V,Y)=>{if(X)J(H.nativeError(X,Z));else if(this.options.resolveWithObject)Q({data:V,info:Y});else Q(V)})})});else return new Promise((Q,J)=>{M4.pipeline(this.options,(X,V,Y)=>{if(X)J(H.nativeError(X,Z));else if(this.options.resolveWithObject)Q({data:V,info:Y});else Q(V)})})}w9.exports=($)=>{Object.assign($.prototype,{toFile:l3,toBuffer:p3,keepExif:a3,withExif:r3,withExifMerge:n3,keepIccProfile:i3,withIccProfile:o3,keepXmp:s3,withXmp:e3,keepMetadata:t3,withMetadata:$X,toFormat:ZX,jpeg:QX,jp2:YX,png:JX,webp:XX,tiff:KX,avif:qX,heif:WX,jxl:HX,gif:VX,raw:zX,tile:GX,timeout:jX,_updateFormatOut:UX,_setBooleanOption:AX,_read:BX,_pipeline:LX})}});var P9=T((oK,N9)=>{/*!
37
- Copyright 2013 Lovell Fuller and others.
38
- SPDX-License-Identifier: Apache-2.0
39
- */var _X=y("events"),c6=E6(),A0=M0(),{runtimePlatformArch:wX}=O2(),X0=Q6(),R9=wX(),a2=X0.libvipsVersion(),t0=X0.format();t0.heif.output.alias=["avif","heic"];t0.jpeg.output.alias=["jpe","jpg"];t0.tiff.output.alias=["tif"];t0.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var FX={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},S4={vips:a2.semver};if(!a2.isGlobal)if(!a2.isWasm)try{S4=y(`@img/sharp-${R9}/versions`)}catch($){try{S4=y(`@img/sharp-libvips-${R9}/versions`)}catch(Z){}}else try{S4=(()=>{throw new Error("Cannot require module "+"@img/sharp-wasm32/versions");})()}catch($){}S4.sharp=k2().version;if(S4.heif&&t0.heif)t0.heif.input.fileSuffix=[".avif"],t0.heif.output.alias=["avif"];function C9($){if(A0.bool($))if($)return X0.cache(50,20,100);else return X0.cache(0,0,0);else if(A0.object($))return X0.cache($.memory,$.files,$.items);else return X0.cache()}C9(!0);function RX($){return X0.concurrency(A0.integer($)?$:null)}if(c6.familySync()===c6.GLIBC&&!X0._isUsingJemalloc())X0.concurrency(1);else if(c6.familySync()===c6.MUSL&&X0.concurrency()===1024)X0.concurrency(y("os").availableParallelism());var CX=new _X.EventEmitter;function NX(){return X0.counters()}function PX($){return X0.simd(A0.bool($)?$:null)}function DX($){if(A0.object($))if(Array.isArray($.operation)&&$.operation.every(A0.string))X0.block($.operation,!0);else throw A0.invalidParameterError("operation","Array<string>",$.operation);else throw A0.invalidParameterError("options","object",$)}function IX($){if(A0.object($))if(Array.isArray($.operation)&&$.operation.every(A0.string))X0.block($.operation,!1);else throw A0.invalidParameterError("operation","Array<string>",$.operation);else throw A0.invalidParameterError("options","object",$)}N9.exports=($)=>{$.cache=C9,$.concurrency=RX,$.counters=NX,$.simd=PX,$.format=t0,$.interpolators=FX,$.versions=S4,$.queue=CX,$.block=DX,$.unblock=IX}});var I9=T((eK,D9)=>{/*!
40
- Copyright 2013 Lovell Fuller and others.
41
- SPDX-License-Identifier: Apache-2.0
42
- */var l0=g$();m$()(l0);n$()(l0);o$()(l0);Z9()(l0);j9()(l0);A9()(l0);F9()(l0);P9()(l0);D9.exports=l0});var Y6={enabled:!0,ttl:"1h",cacheSystemPrompt:!0,cacheTools:!0,minTokensForCache:1024},c9={low:1024,medium:4096,high:16384,max:1e5},jV={enabled:!1,effort:"medium",interleaved:!0};function t2($,Z){if($.budgetTokens)return $.budgetTokens;let Q=$.effort||"medium",J=c9[Q],X=$.modelMultiplier??(Z.includes("opus")?2:1);return Math.min(J*X,1e5)}function $5($){return $.includes("claude-opus-4")||$.includes("claude-sonnet-4")||$.includes("claude-haiku-4")||$.includes("claude-4")}var UV={"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 l9={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,jitterFactor:0.2,retryableStatusCodes:[429,500,502,503,504,529],onRetry:void 0};function p9($,Z,Q,J){let X=Z*Math.pow(2,$),V=X*J*(Math.random()*2-1);return Math.min(X+V,Q)}function a9($,Z){if($.message.includes("429")||$.message.includes("rate limit"))return!0;if($.message.includes("500")||$.message.includes("502")||$.message.includes("503")||$.message.includes("504"))return!0;if($.message.includes("ECONNREFUSED")||$.message.includes("ENOTFOUND")||$.message.includes("ETIMEDOUT")||$.message.includes("network")||$.message.includes("fetch failed"))return!0;for(let Q of Z)if($.message.includes(String(Q)))return!0;return!1}function r9($){return new Promise((Z)=>setTimeout(Z,$))}async function Z5($,Z={}){let Q={...l9,...Z},J=null;for(let X=0;X<=Q.maxRetries;X++)try{return await $()}catch(V){if(J=V instanceof Error?V:Error(String(V)),X<Q.maxRetries&&a9(J,Q.retryableStatusCodes)){let Y=p9(X,Q.baseDelayMs,Q.maxDelayMs,Q.jitterFactor);if(Q.onRetry)Q.onRetry(X+1,J,Y);else console.warn(`\x1B[33mRetry ${X+1}/${Q.maxRetries} after ${Y}ms: ${J.message}\x1B[0m`);await r9(Y)}else throw J}throw J||Error("Max retries exceeded")}var Q5={"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 n9($,Z){let Q=Q5[$]??Q5["claude-sonnet-4-6"],J=Z.input_tokens-(Z.cache_read_input_tokens??0),X=Z.cache_read_input_tokens??0,V=Z.cache_creation_input_tokens??0,Y=Z.output_tokens,K=J/1e6*Q.input,q=X/1e6*Q.cache_read,W=V/1e6*Q.cache_write,z=Y/1e6*Q.output,G=K+q+W+z,B=(X+V)/1e6*(Q.input-Q.cache_read);return{costUSD:G,estimatedSavingsUSD:B}}function i9($,Z){if(!$||!Z.enabled||!Z.cacheSystemPrompt)return typeof $==="string"?$:void 0;if(Array.isArray($)){let Q=[...$];if(Q.length>0){let J=Q[Q.length-1];if(J&&J.type==="text")Q[Q.length-1]={type:"text",text:J.text,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return Q}return[{type:"text",text:$,cache_control:{type:"ephemeral",ttl:Z.ttl}}]}function o9($,Z){if(!Z.enabled)return $;let Q=[];for(let J=0;J<$.length;J++){let X=$[J],V=[];for(let Y=0;Y<X.content.length;Y++){let K=X.content[Y],q=Y===X.content.length-1,W=J===$.length-1;if(K.type==="text"&&K.text.length>=Z.minTokensForCache*4&&!K.cache_control&&(q||W))V.push({...K,cache_control:{type:"ephemeral",ttl:Z.ttl}});else V.push(K)}Q.push({...X,content:V})}if(Q.length>0&&Z.enabled){let J=Q[Q.length-1],X=J.content[J.content.length-1];if(X&&!("cache_control"in X))J.content[J.content.length-1]={...X,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return Q}function s9($){let Z=$.cache_read_input_tokens??0,Q=$.cache_creation_input_tokens??0,J=Z+Q,X=Z>0?1:0,V=Q>0?1:0,Y=X+V;return{cacheHits:X,cacheMisses:V,totalCacheReadTokens:Z,totalCacheWriteTokens:Q,cacheHitRate:Y>0?X/Y:0,estimatedSavingsUSD:0}}async function J5($,Z){let{apiKey:Q,model:J="claude-sonnet-4-6",maxTokens:X=4096,tools:V,systemPrompt:Y,cacheConfig:K=Y6,thinking:q,extendedThinking:W,onToken:z,onThinking:G,onRedactedThinking:A,onToolUse:B,signal:_}=Z,L=Date.now(),F=0,w=!0,P=0,M=o9($,K),E=i9(Y,K),I={model:J,max_tokens:X,messages:M.map((f)=>({role:f.role,content:f.content})),stream:!0};if(E)I.system=E;if(V&&V.length>0)I.tools=V;let x=`${process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com"}/v1/messages`,c={"Content-Type":"application/json","x-api-key":Q,"anthropic-version":"2023-06-01"};if(((W?.enabled??!1)||q&&q.type!=="disabled")&&$5(J)){let f;if(W?.budgetTokens)f=W.budgetTokens;else if(q?.type==="enabled")f=q.budget_tokens;else{let r0=W?.effort||"medium";f=t2({enabled:!0,effort:r0,modelMultiplier:J.includes("opus")?2:1},J)}f=Math.max(1024,Math.min(f,1e5)),I.thinking={type:"enabled",budget_tokens:f};let N0=["extended-thinking-2025-01-24"];if(W?.interleaved!==!1)N0.push("interleaved-thinking-2025-01-24");c["anthropic-beta"]=N0.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,N0,r0)=>{console.log(`\x1B[33mAPI retry ${f}/3 after ${r0}ms: ${N0.message}\x1B[0m`)}},p0=await Z5(async()=>{let f=await fetch(x,{method:"POST",headers:c,body:JSON.stringify(I),signal:_});if(!f.ok&&e.retryableStatusCodes?.includes(f.status)){let N0=await f.text();throw Error(`API error: ${f.status} - ${N0}`)}return f},e);if(!p0.ok){let f=await p0.text();throw Error(`API error: ${p0.status} - ${f}`)}if(!p0.body)throw Error("No response body");let E4=p0.body.getReader(),X6=new TextDecoder,R0=null,O0=[],i={input_tokens:0,output_tokens:0},a0=null,B0=null,y0=null,Y0=null,z4="",o2="";try{let f="";while(!0){let{done:N0,value:r0}=await E4.read();if(N0)break;f+=X6.decode(r0,{stream:!0});let k4=f.split(`
43
- `);f=k4.pop()||"";for(let G4 of k4){if(!G4.startsWith("data: "))continue;let v4=G4.slice(6);if(!v4)continue;try{let v=JSON.parse(v4);switch(v.type){case"message_start":{let O=v.message;R0=O,i=O.usage;break}case"content_block_start":{let O=v.content_block;if(O.type==="text")a0={type:"text",text:""};else if(O.type==="thinking")B0={type:"thinking",thinking:""};else if(O.type==="redacted_thinking")y0={type:"redacted_thinking",data:""};else if(O.type==="tool_use")Y0={type:"tool_use",id:O.id,name:O.name,input:{}},z4="";break}case"content_block_delta":{let O=v.delta;if(O.type==="text_delta"&&a0){let k=O.text;if(a0.text+=k,z?.(k),w)F=Date.now()-L,w=!1}else if(O.type==="thinking_delta"&&B0){let k=O.thinking;B0.thinking+=k,G?.(k),P+=Math.ceil(k.length/4)}else if(O.type==="redacted_thinking_delta"&&y0){let k=O.data;y0.data+=k,A?.(k),P+=Math.ceil(k.length/4)}else if(O.type==="input_json_delta"&&Y0)z4+=O.partial_json;break}case"content_block_stop":{if(a0!==null)O0.push(a0),a0=null;else if(B0!==null)O0.push(B0),B0=null;else if(y0!==null)O0.push(y0),A?.(y0.data),y0=null;else if(Y0!==null){try{Y0.input=JSON.parse(z4)}catch{Y0.input={}}O0.push(Y0),B?.({id:Y0.id,name:Y0.name,input:Y0.input}),Y0=null,z4=""}break}case"message_delta":{let O=v;if(O.usage)i.output_tokens=O.usage.output_tokens;if(R0&&O.delta?.stop_reason)R0.stop_reason=O.delta.stop_reason;break}case"message_stop":break}}catch{}}}}finally{E4.releaseLock()}if(!R0)throw Error("No message received from API");R0.content=O0;let{costUSD:b0,estimatedSavingsUSD:T4}=n9(J,i),C0=s9(i);C0.estimatedSavingsUSD=T4;let x4=Date.now()-L;return{message:R0,usage:i,cacheMetrics:C0,costUSD:b0,durationMs:x4,ttftMs:F||x4,thinkingTokens:P}}import*as X5 from"readline";var e9={Read:"low",Glob:"low",Grep:"low",Task:"low",Write:"medium",Edit:"medium",NotebookEdit:"medium",Bash:"high"},t9=[/\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 $7($,Z){let Q=e9[$]??"medium";if($==="Bash"){let J=String(Z.command??"");for(let X of t9)if(X.test(J))return"critical";if(/\bsudo\b/.test(J)||/\bchmod\b/.test(J))Q="high"}if($==="Write"||$==="Edit"){let J=String(Z.file_path??Z.path??"");if(/\.(env|pem|key|secret|credentials)/.test(J))Q="high";if(/\/\.ssh\//.test(J)||/\/\.gnupg\//.test(J))Q="critical"}return Q}function Z7($,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 p6{cache={};cacheTimeout=300000;promptCallback;mode;constructor($="default",Z){this.mode=$,this.promptCallback=Z??this.defaultPrompt.bind(this)}async checkPermission($,Z){if(this.mode==="bypassPermissions")return{decision:"allow"};if(this.mode==="dontAsk")return{decision:"deny",reason:"Permission mode is dontAsk"};if(this.mode==="acceptEdits"){if(["Read","Write","Edit","Glob","Grep"].includes($))return{decision:"allow"}}if(this.mode==="plan"){if(["Read","Glob","Grep","Task"].includes($))return{decision:"allow"};return{decision:"deny",reason:"Plan mode - write operations disabled"}}let Q=this.getCacheKey($,Z),J=this.cache[Q];if(J&&Date.now()-J.timestamp<this.cacheTimeout){if(J.decision==="allowAlways")return{decision:"allow",reason:"Previously approved (always)"};if(J.decision==="denyAlways")return{decision:"deny",reason:"Previously denied (always)"}}let X=$7($,Z),V=Z7($,Z),Y={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 K=await this.promptCallback(Y);if(K.decision==="allowAlways"||K.decision==="denyAlways")this.cache[Q]={decision:K.decision,timestamp:Date.now()};return K}return{decision:"allow"}}getCacheKey($,Z){if(["Read","Write","Edit"].includes($))return`${$}:${Z.file_path??Z.path??"unknown"}`;if($==="Bash"){let Q=String(Z.command??"").slice(0,100);return`${$}:${Q}`}return $}async defaultPrompt($){return new Promise((Z)=>{let Q=X5.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 Y="[y]es / [n]o / [a]lways / [d]eny always";Q.question(`Allow? ${Y}: `,(K)=>{switch(Q.close(),K.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 a6={readOnly:["Read","Glob","Grep","Task"],fileEdit:["Write","Edit","NotebookEdit"],system:["Bash"],network:[]};function CV($){return a6.readOnly.includes($)}function NV($){return a6.fileEdit.includes($)}function PV($){return a6.system.includes($)}var n6={tokenWarningThreshold:0.8,costUpdateInterval:5,toolSummaryInterval:3,envInfoOnStart:!0},r6={WARNING:0.8,CRITICAL:0.9,EMERGENCY:0.95};function Q7($){let{current:Z,max:Q,threshold:J=r6.WARNING}=$;if(Q<=0)return"";let X=Z/Q;if(X<J)return"";let V=Q-Z,Y=Math.round(X*100),K,q;if(X>=r6.EMERGENCY)K="emergency",q="\uD83D\uDEA8";else if(X>=r6.CRITICAL)K="critical",q="\u26A0\uFE0F";else K="warning",q="\u26A1";let W=[`${q} Token Usage ${K.toUpperCase()}`,"",`Current: ${Z.toLocaleString()} / ${Q.toLocaleString()} tokens (${Y}%)`,`Remaining: ${V.toLocaleString()} tokens`];if(K==="emergency")W.push(""),W.push("Consider summarizing or compacting the conversation to continue.");else if(K==="critical")W.push(""),W.push("Approaching token limit. Consider wrapping up soon.");return W.join(`
44
- `)}function J7($){let{cost:Z,previousCost:Q=0,currency:J="USD"}=$,X=X7(J),V=V5(Z,X),Y=Z-Q,K=V5(Math.abs(Y),X),q=["\uD83D\uDCB0 Cost Update","",`Total: ${V} ${J}`];if(Y!==0){let W=Y>0?"+":"-";q.push(`This turn: ${W}${K} ${J}`)}return q.join(`
45
- `)}function V5($,Z){if($<0.01)return`${Z}${$.toFixed(4)}`;else if($<1)return`${Z}${$.toFixed(3)}`;return`${Z}${$.toFixed(2)}`}function X7($){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5"}[$]||$}function V7($){let{tools:Z,maxDisplay:Q=10}=$;if(Z.length===0)return"No tools used this session.";let J=new Map;for(let K of Z){let q=J.get(K.name)||0;J.set(K.name,q+1)}let X=[...J.entries()].sort((K,q)=>q[1]-K[1]),V=[`\uD83D\uDD27 Tool Usage Summary (${Z.length} total calls)`,""],Y=X.slice(0,Q);for(let[K,q]of Y)V.push(` \u2022 ${K}: ${q} call${q===1?"":"s"}`);if(X.length>Q){let K=X.length-Q;V.push(` ... and ${K} more tool${K===1?"":"s"}`)}return V.join(`
46
- `)}function Y7($){let{workingDirectory:Z,gitStatus:Q,platform:J=process.platform,shell:X=process.env.SHELL||"unknown"}=$,V=["\uD83D\uDCCD Environment Information","",`Working Directory: ${Z}`,`Platform: ${J}`,`Shell: ${X}`];if(Q){if(V.push(""),V.push("Git Status:"),V.push(` Branch: ${Q.branch}`),Q.ahead>0||Q.behind>0)V.push(` Ahead: ${Q.ahead}, Behind: ${Q.behind}`);let Y=Q.staged.length+Q.unstaged.length+Q.untracked.length+Q.conflicted.length;if(Y>0){if(V.push(` Changes: ${Y} file${Y===1?"":"s"}`),Q.staged.length>0)V.push(` Staged: ${Q.staged.length}`);if(Q.unstaged.length>0)V.push(` Unstaged: ${Q.unstaged.length}`);if(Q.untracked.length>0)V.push(` Untracked: ${Q.untracked.length}`);if(Q.conflicted.length>0)V.push(` Conflicted: ${Q.conflicted.length}`)}else V.push(" Working tree clean")}return V.join(`
47
- `)}function Y5($){let{usage:Z,maxTokens:Q,totalCost:J,previousCost:X,toolsUsed:V,workingDirectory:Y,gitStatus:K,turnNumber:q,config:W}=$,z={...n6,...W},G=[],A=Z.input_tokens+Z.output_tokens,B=Q7({current:A,max:Q,threshold:z.tokenWarningThreshold});if(B)G.push(B);if(q%z.costUpdateInterval===0){let _=J7({cost:J,previousCost:X});G.push(_)}if(q%z.toolSummaryInterval===0&&V.length>0){let _=V7({tools:V});G.push(_)}if(q===1&&z.envInfoOnStart){let _=Y7({workingDirectory:Y,gitStatus:K});G.push(_)}if(G.length===0)return"";return["---","System Reminders:","",...G,"---"].join(`
48
- `)}function O4($){if(!$||$.length===0)return 0;return Math.ceil($.length/4)}function K5($){switch($.type){case"text":return O4($.text);case"image":return 100;case"tool_use":let Z=JSON.stringify($.input);return O4($.name)+O4(Z)+10;case"tool_result":if(typeof $.content==="string")return O4($.content)+10;return $.content.reduce((Q,J)=>Q+K5(J),0)+10;case"thinking":return O4($.thinking);default:return 0}}function K7($){return 4+$.content.reduce((J,X)=>J+K5(X),0)}function i6($){if(!$||$.length===0)return 0;return $.reduce((Z,Q)=>Z+K7(Q),0)}function q7($){let Z=[];for(let Q of $.content)switch(Q.type){case"text":Z.push(Q.text);break;case"tool_use":Z.push(`[Tool: ${Q.name}(${JSON.stringify(Q.input)})]`);break;case"tool_result":let J=typeof Q.content==="string"?Q.content:Q.content.map((X)=>X.type==="text"?X.text:"[content]").join("");Z.push(`[Result: ${J.slice(0,500)}${J.length>500?"...":""}]`);break;case"thinking":Z.push(`[Thinking: ${Q.thinking.slice(0,200)}...]`);break}return Z.join(`
49
- `)}function W7($){let Z=new Map;for(let Q of $)for(let J of Q.content)if(J.type==="tool_use")Z.set(J.id,{use:J});for(let Q of $)for(let J of Q.content)if(J.type==="tool_result"){let X=Z.get(J.tool_use_id);if(X)X.result=J}return Z}async function H7($){if(!$||$.length===0)return"";let Z=[];Z.push(`[Context Summary: ${$.length} messages compacted]
50
- `);let Q=[];for(let X=0;X<$.length;X++){let V=$[X];if(!V)continue;let Y=V.role.toUpperCase(),K=q7(V);for(let W of V.content)if(W.type==="tool_use")Q.push(`${W.name}`);let q=K.length>300?`${K.slice(0,300)}...`:K;Z.push(`${Y}: ${q}
51
- `)}if(Q.length>0){let X=Q.reduce((Y,K)=>{return Y[K]=(Y[K]||0)+1,Y},{}),V=Object.entries(X).map(([Y,K])=>`${Y}(${K})`).join(", ");Z.push(`
52
- Tools used: ${V}
53
- `)}let J=Z.join("");if(J.length>8000)J=J.slice(0,8000)+`
54
- ...[truncated]`;return J}async function o6($,Z,Q={}){let{keepFirst:J=1,keepLast:X=5,preserveToolPairs:V=!0}=Q,Y=i6($);if(Y<=Z)return{messages:$,messagesRemoved:0,tokensBefore:Y,tokensAfter:Y,didCompact:!1};if($.length<=J+X)return{messages:$,messagesRemoved:0,tokensBefore:Y,tokensAfter:Y,didCompact:!1};let K=$.slice(0,J),q=$.slice(J,-X),W=$.slice(-X),G={role:"user",content:[{type:"text",text:`[Previous context has been compacted for continuity]
55
-
56
- ${await H7(q)}`}]},A=[];if(V&&q.length>0){let F=W7(q),w=Array.from(F.values()).slice(-3).filter((P)=>P.result&&!P.result.is_error);for(let P of w)if(A.push(P.use),P.result)A.push(P.result)}let B=[...K,G];if(A.length>0)B.push({role:"assistant",content:A.filter((F)=>F.type==="tool_use")}),B.push({role:"user",content:A.filter((F)=>F.type==="tool_result")});B.push(...W);let _=i6(B),L=$.length-B.length;return console.log(`Context compaction: ${$.length} -> ${B.length} messages, ${Y} -> ${_} tokens`),{messages:B,messagesRemoved:L,tokensBefore:Y,tokensAfter:_,didCompact:!0}}function q5($,Z,Q=0.9){if($.length<8)return!1;let J=i6($),X=Math.floor(Z*Q);return J>=X}function s6($){if(!$.didCompact)return{reductionPercent:0,tokensSaved:0};let Z=$.tokensBefore-$.tokensAfter,Q=Z/$.tokensBefore*100;return{reductionPercent:Math.round(Q*100)/100,tokensSaved:Z}}async function fV($,Z){let{apiKey:Q,model:J="claude-sonnet-4-6",maxTokens:X=4096,systemPrompt:V,tools:Y,permissionMode:K,workingDirectory:q,gitStatus:W=null,reminderConfig:z,cacheConfig:G=Y6,thinking:A,extendedThinking:B,onText:_,onThinking:L,onToolUse:F,onToolResult:w,onMetrics:P,onReminder:M,onPermissionRequest:E,signal:I}=Z,g=new p6(K,E),x=[...$],c=[],V0=[],e=0,p0=0,E4=0,X6=0,R0=0,O0=0,i={cacheHits:0,cacheMisses:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,cacheHitRate:0,estimatedSavingsUSD:0},a0={...n6,...z},B0=!0;while(B0){if(I?.aborted)break;E4++;let y0=c[c.length-1],Y0=Y5({usage:y0?.usage??{input_tokens:0,output_tokens:0},maxTokens:X,totalCost:e,previousCost:X6,toolsUsed:V0,workingDirectory:q,gitStatus:W,turnNumber:E4,config:a0});if(Y0)M?.(Y0);if(q5(x,X)){let v=await o6(x,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(v.didCompact&&v.tokensAfter<v.tokensBefore){x.length=0,x.push(...v.messages),R0++;let O=v.tokensBefore-v.tokensAfter;O0+=O;let k=s6(v);console.log(`Context compacted: ${k.reductionPercent}% reduction, ${k.tokensSaved} tokens saved`)}}let z4=z7(x,V,Y0),o2=await J5(z4,{apiKey:Q,model:J,maxTokens:X,systemPrompt:V,cacheConfig:G,thinking:A,extendedThinking:B,tools:Y.map((v)=>({name:v.name,description:v.description,input_schema:v.input_schema})),onToken:_,onThinking:L,onToolUse:F,signal:I}),{message:b0,usage:T4,cacheMetrics:C0,costUSD:x4,durationMs:f,ttftMs:N0}=o2,r0={model:J,messageCount:x.length,messageTokens:T4.input_tokens+T4.output_tokens,usage:T4,cacheMetrics:C0,durationMs:f,ttftMs:N0,costUSD:x4,stopReason:b0.stop_reason,requestId:b0.id};if(c.push(r0),X6=e,e+=x4,p0+=f,C0)i.cacheHits+=C0.cacheHits,i.cacheMisses+=C0.cacheMisses,i.totalCacheReadTokens+=C0.totalCacheReadTokens,i.totalCacheWriteTokens+=C0.totalCacheWriteTokens,i.estimatedSavingsUSD+=C0.estimatedSavingsUSD;let k4=i.cacheHits+i.cacheMisses;if(i.cacheHitRate=k4>0?i.cacheHits/k4:0,P?.(r0),x.push({role:"assistant",content:b0.content}),b0.stop_reason==="end_turn"||b0.stop_reason==="stop_sequence"){B0=!1;break}if(b0.stop_reason==="max_tokens"){let v=await o6(x,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(v.didCompact&&v.tokensAfter<v.tokensBefore){x.length=0,x.push(...v.messages),R0++;let O=v.tokensBefore-v.tokensAfter;O0+=O;let k=s6(v);console.log(`Context compacted: ${k.reductionPercent}% reduction, ${k.tokensSaved} tokens saved`);continue}else{B0=!1;break}}let G4=b0.content.filter((v)=>v.type==="tool_use");if(V0.push(...G4),G4.length===0){B0=!1;break}let v4=[];if(I?.aborted);else{let v=G4.map(async(k)=>{let l6=Y.find((f0)=>f0.name===k.name);if(!l6)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 V6=await g.checkPermission(l6.name,k.input);if(V6.decision==="deny"||V6.decision==="denyAlways")return{toolUseId:k.id,result:{type:"tool_result",tool_use_id:k.id,content:`Permission denied for tool "${k.name}"${V6.reason?`: ${V6.reason}`:""}`,is_error:!0},toolResult:null};try{let f0=await l6.handler(k.input,{workingDirectory:q,permissionMode:K,abortSignal:I});return{toolUseId:k.id,result:{type:"tool_result",tool_use_id:k.id,content:f0.content,is_error:f0.is_error},toolResult:{id:k.id,result:f0}}}catch(f0){let h9=f0 instanceof Error?f0.message:String(f0);return{toolUseId:k.id,result:{type:"tool_result",tool_use_id:k.id,content:`Error: ${h9}`,is_error:!0},toolResult:null}}}),O=await Promise.all(v);for(let k of O)if(v4.push(k.result),k.toolResult)w?.(k.toolResult)}x.push({role:"user",content:v4})}return{messages:x,metrics:c,totalCost:e,totalDuration:p0,totalCacheMetrics:i,compactionCount:R0,totalTokensCompacted:O0}}function z7($,Z,Q){if(Q&&$.length>0){let J=[...$];for(let X=J.length-1;X>=0;X--){let V=J[X];if(V&&V.role==="user"){let Y={role:"user",content:Array.isArray(V.content)?G7(V.content,Q):[{type:"text",text:`${String(V.content)}
57
-
58
- ${Q}`}]};J[X]=Y;break}}return J}return $}function G7($,Z){if($.length>0){let J=$[$.length-1];if(J&&J.type==="text"){let X={type:"text",text:`${J.text}
59
-
60
- ${Z}`};return[...$.slice(0,-1),X]}}let Q={type:"text",text:`
61
-
62
- ${Z}`};return[...$,Q]}function e6($){if($<0.01)return`$${$.toFixed(4)}`;return`$${$.toFixed(2)}`}function hV($){let Z=e6($.costUSD),Q=`${$.usage.input_tokens.toLocaleString()} input, ${$.usage.output_tokens.toLocaleString()} output`;if($.usage.cache_read_input_tokens||$.usage.cache_creation_input_tokens){let J=$.usage.cache_read_input_tokens?.toLocaleString()??"0",X=$.usage.cache_creation_input_tokens?.toLocaleString()??"0";return`Cost: ${Z} | Tokens: ${Q} | Cache: ${J} read, ${X} write`}return`Cost: ${Z} | Tokens: ${Q}`}function gV($){let Z=e6($.costUSD),Q=$.usage.input_tokens+$.usage.output_tokens;return`Cost: ${Z} | Tokens: ${Q.toLocaleString()}`}function uV($){let Z=e6($.estimatedSavingsUSD);return`Cache: ${($.cacheHitRate*100).toFixed(1)}% hit rate | ${$.totalCacheReadTokens.toLocaleString()} read | ${$.totalCacheWriteTokens.toLocaleString()} written | Saved: ${Z}`}import{homedir as j7}from"os";import{join as h0}from"path";class U7{sessionsDir;currentSessionId=null;currentSessionFile=null;writeQueue=Promise.resolve();constructor($){this.sessionsDir=$??h0(j7(),".claude","sessions")}async init(){try{await Bun.write(h0(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=h0(this.sessionsDir,`${Z}.jsonl`);let Q={id:Z,created:Date.now(),updated:Date.now(),model:$.model,workingDirectory:$.workingDirectory,agentName:$.agentName,agentColor:$.agentColor,teamName:$.teamName};await this.appendEntry(Q);let J={type:"context",timestamp:Date.now(),workingDirectory:$.workingDirectory};return await this.appendEntry(J),Z}async resumeSession($){let Z=h0(this.sessionsDir,`${$}.jsonl`);try{let Q=await Bun.file(Z).text();if(!Q)return null;let J=Q.trim().split(`
63
- `),X=[];for(let V of J)try{X.push(JSON.parse(V))}catch{}return this.parseSessionEntries(X)}catch{return null}}parseSessionEntries($){let Z=null,Q=[],J=[],X=[],V=null;for(let Y of $){if(!("type"in Y)&&"id"in Y&&"created"in Y){Z=Y;continue}if("type"in Y){let K=Y;switch(K.type){case"message":Q.push(K.data);break;case"tool_use":J.push(K);break;case"metrics":X.push(K.data);break;case"context":V=K;break}}}if(!Z)Z={id:"unknown",created:Date.now(),updated:Date.now(),model:"claude-sonnet-4-6",workingDirectory:process.cwd()};return{metadata:Z,messages:Q,tools:J,metrics:X,context:V}}async appendEntry($){if(!this.currentSessionFile)return;this.writeQueue=this.writeQueue.then(async()=>{let Z=JSON.stringify($)+`
64
- `,Q=Bun.file(this.currentSessionFile),J=await Q.exists()?await Q.text():"";await Bun.write(this.currentSessionFile,J+Z)}),await this.writeQueue}async saveMessage($){let Z={type:"message",timestamp:Date.now(),data:$};await this.appendEntry(Z),await this.updateTimestamp()}async saveToolUse($,Z,Q,J,X){let V={type:"tool_use",timestamp:Date.now(),toolId:$,toolName:Z,input:Q,result:J,isError:X};await this.appendEntry(V)}async saveMetrics($){let Z={type:"metrics",timestamp:Date.now(),data:$};await this.appendEntry(Z)}async updateTimestamp(){if(!this.currentSessionFile||!this.currentSessionId)return}async listSessions($=20){await this.init();let Z=Bun.file(this.sessionsDir),Q=[];try{let X=[...new Bun.Glob("*.jsonl").scanSync(this.sessionsDir)],V=await Promise.all(X.map(async(Y)=>{let K=h0(this.sessionsDir,Y),q=await Bun.file(K).stat();return{file:Y,fullPath:K,mtime:q?.mtime??new Date(0)}}));V.sort((Y,K)=>K.mtime.getTime()-Y.mtime.getTime());for(let{file:Y,fullPath:K}of V.slice(0,$)){let q=Y.replace(".jsonl",""),W=await this.getSessionSummary(q,K);if(W)Q.push(W)}}catch{}return Q}async getSessionSummary($,Z){let Q=Z??h0(this.sessionsDir,`${$}.jsonl`);try{let J=await Bun.file(Q).text();if(!J)return null;let X=J.trim().split(`
65
- `),V=null,Y=0,K=0,q=0,W=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"){Y++;let B=A.data;if(!z&&B.role==="user"){let _=B.content.find((L)=>L.type==="text");if(_&&"text"in _){if(z=_.text.slice(0,100),_.text.length>100)z+="..."}}}else if(A.type==="metrics")K+=A.data.costUSD,q+=A.data.usage.input_tokens,W+=A.data.usage.output_tokens}catch{}if(!V)return null;return{id:$,created:V.created,updated:V.updated,model:V.model,messageCount:Y,totalCost:K,totalTokens:{input:q,output:W},firstMessage:z,workingDirectory:V.workingDirectory}}catch{return null}}getCurrentSessionId(){return this.currentSessionId}async exportSession($,Z,Q){let J=await this.resumeSession($);if(!J)throw Error(`Session not found: ${$}`);let X,V;switch(Z){case"jsonl":{let K=h0(this.sessionsDir,`${$}.jsonl`);X=await Bun.file(K).text(),V="jsonl";break}case"json":{X=JSON.stringify(J,null,2),V="json";break}case"markdown":{X=this.sessionToMarkdown(J),V="md";break}default:throw Error(`Unsupported format: ${Z}`)}let Y=Q??h0(process.cwd(),`session-${$}.${V}`);return await Bun.write(Y,X),Y}sessionToMarkdown($){let Z=[];Z.push(`# Session: ${$.metadata.id}`),Z.push(""),Z.push(`**Created:** ${new Date($.metadata.created).toISOString()}`),Z.push(`**Model:** ${$.metadata.model}`),Z.push(`**Working Directory:** ${$.metadata.workingDirectory}`),Z.push(""),Z.push("## Conversation"),Z.push("");for(let Q of $.messages){let J=Q.role==="user"?"**User**":"**Claude**";Z.push(`### ${J}`),Z.push("");for(let X of Q.content)if(X.type==="text")Z.push(X.text),Z.push("");else if(X.type==="tool_use"){let V=X;Z.push(`\`\`\`tool:${V.name}`),Z.push(JSON.stringify(V.input,null,2)),Z.push("```"),Z.push("")}else if(X.type==="tool_result"){let V=X;Z.push(`**Result**${V.is_error?" (error)":""}:`),Z.push("```"),Z.push(typeof V.content==="string"?V.content:JSON.stringify(V.content,null,2)),Z.push("```"),Z.push("")}}if($.metrics.length>0){Z.push("## Metrics"),Z.push("");let Q=$.metrics.reduce((V,Y)=>V+Y.costUSD,0),J=$.metrics.reduce((V,Y)=>V+Y.usage.input_tokens,0),X=$.metrics.reduce((V,Y)=>V+Y.usage.output_tokens,0);Z.push(`- **Total Cost:** $${Q.toFixed(4)}`),Z.push(`- **Total Input Tokens:** ${J.toLocaleString()}`),Z.push(`- **Total Output Tokens:** ${X.toLocaleString()}`),Z.push(`- **API Calls:** ${$.metrics.length}`)}return Z.join(`
66
- `)}async deleteSession($){let Z=h0(this.sessionsDir,`${$}.jsonl`);try{if(await Bun.file(Z).exists()){let{unlink:J}=await import("fs/promises");return await J(Z),!0}return!1}catch{return!1}}}function A7($){let Z=new Date($.created),Q=new Date($.updated),J=B7(Q),X=[];X.push(`\x1B[1m${$.id}\x1B[0m (${J})`),X.push(` Model: ${$.model} | Messages: ${$.messageCount}`);let V=$.totalCost<0.01?`$${$.totalCost.toFixed(4)}`:`$${$.totalCost.toFixed(2)}`;if(X.push(` Cost: ${V} | Tokens: ${$.totalTokens.input.toLocaleString()} in, ${$.totalTokens.output.toLocaleString()} out`),$.firstMessage)X.push(` Preview: ${$.firstMessage}`);return X.push(` Directory: ${$.workingDirectory}`),X.join(`
67
- `)}function B7($){let Q=new Date().getTime()-$.getTime(),J=Math.floor(Q/60000),X=Math.floor(Q/3600000),V=Math.floor(Q/86400000);if(J<1)return"just now";if(J<60)return`${J}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return $.toLocaleDateString()}function lV($){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(A7(Z)),console.log("");console.log("To resume a session:"),console.log(" claude-remake --resume <session-id>")}import{dlopen as L7,suffix as _7}from"bun:ffi";import{join as K6,dirname as w7}from"path";import{fileURLToPath as F7}from"url";var Z4=null;function W5(){if(Z4)return Z4;let $=w7(F7(import.meta.url)),Z=[K6($,"..","..","native"),K6($,"..","native")],Q=["index.darwin-arm64.node","index.darwin-x64.node","index.node"];for(let X of Z)for(let V of Q){let Y=K6(X,V);try{let K=y(Y);if(K&&(K.highlightCode||K.highlight_code))return Z4={highlight_code:K.highlightCode||K.highlight_code,highlight_markdown:K.highlightMarkdown||K.highlight_markdown,highlight_diff:K.highlightDiff||K.highlight_diff,search_files:K.searchFiles||K.search_files,count_tokens:K.countTokens||K.count_tokens,calculate_diff:K.calculateDiff||K.calculate_diff,compact_content:K.compactContent||K.compact_content,count_tool_use:K.countToolUse||K.count_tool_use,find_tool_pairs:K.findToolPairs||K.find_tool_pairs,find_common_patterns:K.findCommonPatterns||K.find_common_patterns,validate_multi_edits:K.validateMultiEdits||K.validate_multi_edits,preview_multi_edits:K.previewMultiEdits||K.preview_multi_edits,apply_multi_edits:K.applyMultiEdits||K.apply_multi_edits},Z4}catch{continue}}let J=Z.map((X)=>K6(X,`claude_code_native.${_7}`));for(let X of J)try{return Z4=L7(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,Z4}catch{continue}return console.warn("Native module not available, using JS fallback"),H5()}function iV(){try{return W5(),Z4!==null}catch{return!1}}function H5(){return{highlight_code:($,Z)=>{let Q=new Set(["function","const","let","var","return","if","else","for","while","class","interface","type","import","export","from","async","await","try","catch","throw","new","this","extends","implements","static","public","private","protected","readonly","abstract","enum","namespace"]),J=new Set(["string","number","boolean","void","null","undefined","any","never","object","symbol","bigint","true","false"]),X={reset:"\x1B[0m",keyword:"\x1B[38;2;180;142;173m",string:"\x1B[38;2;163;190;140m",number:"\x1B[38;2;208;135;112m",type:"\x1B[38;2;191;97;106m",function:"\x1B[38;2;143;161;179m",comment:"\x1B[38;2;108;153;139m",default:"\x1B[38;2;192;197;206m"};return{html:$.split(`
70
- `).map((K)=>{if(K.trim().startsWith("//")||K.trim().startsWith("#"))return`${X.comment}${K}${X.reset}`;let q=K.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*?\1/g,(W)=>{return`${X.string}${W}${X.default}`});return q=q.replace(/\b(\d+\.?\d*)\b/g,`${X.number}$1${X.default}`),q=q.replace(/\b([a-z]+)\b/gi,(W)=>{if(Q.has(W))return`${X.keyword}${W}${X.default}`;if(J.has(W))return`${X.type}${W}${X.default}`;return W}),q=q.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/g,(W,z)=>{return`${X.function}${z}${X.default}(`}),q}).join(`
71
- `)+X.reset,theme:"fallback"}},highlight_markdown:($)=>{return{html:$+"\x1B[0m",theme:"fallback"}},highlight_diff:($,Z,Q)=>{let q=$.split(`
72
- `),W=Z.split(`
73
- `),z="",G=0,A=0,B=0;if(Q?.file_path)z+=`\x1B[38;2;143;161;179m${Q.file_path}\x1B[0m
74
- `;let _=[],L=Array.from({length:q.length+1},()=>Array.from({length:W.length+1},()=>0));for(let g=0;g<=q.length;g++)for(let x=0;x<=W.length;x++)if(g===0||x===0)L[g][x]=0;else if(q[g-1]===W[x-1])L[g][x]=L[g-1][x-1]+1;else L[g][x]=Math.max(L[g-1][x],L[g][x-1]);let F=q.length,w=W.length,P=new Set;while(F>0&&w>0)if(q[F-1]===W[w-1])P.add(`${F-1}:${w-1}`),_.unshift(q[F-1]),F--,w--;else if(L[F-1][w]>L[F][w-1])F--;else w--;let M=0,E=0,I=0;while(M<q.length||E<W.length){while(I<_.length&&M<q.length&&E<W.length&&q[M]===_[I]&&W[E]===_[I])M++,E++,I++;let g=M+1,x=E+1,c=0,V0=0,e=[];while(M<q.length&&(I>=_.length||q[M]!==_[I]))e.push(`\x1B[38;2;191;97;106m-${q[M]}\x1B[0m`),M++,c++,A++;while(E<W.length&&(I>=_.length||W[E]!==_[I]))e.push(`\x1B[38;2;163;190;140m+${W[E]}\x1B[0m`),E++,V0++,G++;if(c>0||V0>0)B++,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:B}},search_files:($,Z,Q)=>{return{matches:[],total_count:0,files_searched:0}},count_tokens:($)=>{return Math.ceil($.length/4)},calculate_diff:($,Z)=>{let Q=$.split(`
78
- `),J=Z.split(`
79
- `),X=[];if($!==Z)X.push({oldStart:1,oldLines:Q.length,newStart:1,newLines:J.length,content:`- ${Q.join(`
80
- - `)}
81
- + ${J.join(`
82
- + `)}`});return X},compact_content:($,Z,Q="truncate")=>{let X=Z*4;if($.length<=X)return $;switch(Q){case"truncate":return $.slice(0,X/2)+`
83
-
84
- ... [truncated] ...
85
-
86
- `+$.slice(-X/2);case"summarize":let V=Math.floor(X/4);return`=== BEGINNING ===
87
- `+$.slice(0,V)+`
88
-
89
- === END ===
90
- `+$.slice(-V);case"extract":return $.split(`
91
- `).filter((q)=>q.trim().startsWith("#")||q.trim().startsWith("function")||q.trim().startsWith("const")||q.trim().startsWith("class")||q.trim().startsWith("export")||q.trim().startsWith("import")).slice(0,X/50).join(`
92
- `);default:return $.slice(0,X)}},validate_multi_edits:($)=>{let Z=[],Q=new Map,J=y("fs");for(let X of $)try{if(!J.existsSync(X.filePath)){Z.push(`File not found: ${X.filePath}`);continue}if(!Q.has(X.filePath)){let Y=J.readFileSync(X.filePath,"utf-8");Q.set(X.filePath,Y)}let V=Q.get(X.filePath);if(!V.includes(X.oldString)){Z.push(`String not found in ${X.filePath}: "${R7(X.oldString,50)}"`);continue}if(!X.replaceAll){let Y=(V.match(new RegExp(t6(X.oldString),"g"))||[]).length;if(Y>1)Z.push(`String appears ${Y} times in ${X.filePath}. Use replaceAll or provide more context.`)}}catch(V){Z.push(`Error reading ${X.filePath}: ${V}`)}return Z},preview_multi_edits:($)=>{let Z=[],Q=new Map,J=y("fs");for(let X of $)try{if(!J.existsSync(X.filePath))continue;let V=J.readFileSync(X.filePath,"utf-8"),Y=X.replaceAll?(V.match(new RegExp(t6(X.oldString),"g"))||[]).length:1;Q.set(X.filePath,(Q.get(X.filePath)||0)+Y)}catch{}for(let[X,V]of Q)Z.push({filePath:X,replacementCount:V});return Z},apply_multi_edits:($)=>{let Z=H5().validate_multi_edits($);if(Z.length>0)return{success:!1,filesModified:[],totalReplacements:0,error:Z.join(`
93
- `),rolledBack:!1};let Q=new Map,J=new Set($.map((q)=>q.filePath)),X=y("fs");for(let q of J)try{Q.set(q,X.readFileSync(q,"utf-8"))}catch(W){return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to backup ${q}: ${W}`,rolledBack:!1}}let V=new Map;for(let[q,W]of Q)V.set(q,W);let Y=0;for(let q of $){let W=V.get(q.filePath);if(!W)continue;if(q.replaceAll){let z=(W.match(new RegExp(t6(q.oldString),"g"))||[]).length;V.set(q.filePath,W.split(q.oldString).join(q.newString)),Y+=z}else V.set(q.filePath,W.replace(q.oldString,q.newString)),Y+=1}let K=[];for(let[q,W]of V){let z=Q.get(q);if(W!==z)try{Bun.write(q,W),K.push(q)}catch(G){for(let[A,B]of Q)try{Bun.write(A,B)}catch{}return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to write ${q}: ${G}. All changes rolled back.`,rolledBack:!0}}}return{success:!0,filesModified:K,totalReplacements:Y,error:void 0,rolledBack:!1}},count_tool_use:($)=>{let Z={};for(let Q of $)if(Q.tool_use)for(let J of Q.tool_use)Z[J.name]=(Z[J.name]||0)+1;return Z},find_tool_pairs:($,Z)=>{let Q={};for(let J of $)if(J.tool_use&&J.tool_use.length>=2)for(let X=0;X<J.tool_use.length-1;X++){let V=J.tool_use[X]?.name,Y=J.tool_use[X+1]?.name;if(V&&Y){if(!Q[V])Q[V]={};Q[V][Y]=(Q[V][Y]||0)+1}}return Q},find_common_patterns:($)=>{let Z=[],Q=new Map,J=0;for(let X of $)if(X.tool_use&&X.tool_use.length>=2)for(let V=0;V<X.tool_use.length-1;V++){let Y=X.tool_use[V]?.name,K=X.tool_use[V+1]?.name;if(Y&&K){let q=`${Y}|${K}`;Q.set(q,(Q.get(q)||0)+1),J++}}for(let[X,V]of Q){let[Y,K]=X.split("|");Z.push({tools:[Y,K],count:V,percentage:J>0?V/J*100:0})}return Z.sort((X,V)=>V.count-X.count).slice(0,10)}}}var Q4=W5();function oV($,Z){return Q4.highlight_code($,Z)}function sV($){return Q4.highlight_markdown($)}function eV($,Z,Q){return Q4.highlight_diff($,Z,Q)}function tV($,Z){return Q4.calculate_diff($,Z)}function $2($){return Q4.validate_multi_edits($)}function z5($){return Q4.preview_multi_edits($)}function G5($){return Q4.apply_multi_edits($)}function R7($,Z){if($.length<=Z)return $;return $.slice(0,Z)+"..."}function t6($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z2=($,Z,Q)=>{let J=$ instanceof RegExp?j5($,Q):$,X=Z instanceof RegExp?j5(Z,Q):Z,V=J!==null&&X!=null&&C7(J,X,Q);return V&&{start:V[0],end:V[1],pre:Q.slice(0,V[0]),body:Q.slice(V[0]+J.length,V[1]),post:Q.slice(V[1]+X.length)}},j5=($,Z)=>{let Q=Z.match($);return Q?Q[0]:null},C7=($,Z,Q)=>{let J,X,V,Y=void 0,K,q=Q.indexOf($),W=Q.indexOf(Z,q+1),z=q;if(q>=0&&W>0){if($===Z)return[q,W];J=[],V=Q.length;while(z>=0&&!K){if(z===q)J.push(z),q=Q.indexOf($,z+1);else if(J.length===1){let G=J.pop();if(G!==void 0)K=[G,W]}else{if(X=J.pop(),X!==void 0&&X<V)V=X,Y=W;W=Q.indexOf(Z,z+1)}z=q<W&&q>=0?q:W}if(J.length&&Y!==void 0)K=[V,Y]}return K};var U5="\x00SLASH"+Math.random()+"\x00",A5="\x00OPEN"+Math.random()+"\x00",J2="\x00CLOSE"+Math.random()+"\x00",B5="\x00COMMA"+Math.random()+"\x00",L5="\x00PERIOD"+Math.random()+"\x00",N7=new RegExp(U5,"g"),P7=new RegExp(A5,"g"),D7=new RegExp(J2,"g"),I7=new RegExp(B5,"g"),M7=new RegExp(L5,"g"),S7=/\\\\/g,E7=/\\{/g,T7=/\\}/g,x7=/\\,/g,k7=/\\./g,v7=1e5;function Q2($){return!isNaN($)?parseInt($,10):$.charCodeAt(0)}function O7($){return $.replace(S7,U5).replace(E7,A5).replace(T7,J2).replace(x7,B5).replace(k7,L5)}function y7($){return $.replace(N7,"\\").replace(P7,"{").replace(D7,"}").replace(I7,",").replace(M7,".")}function _5($){if(!$)return[""];let Z=[],Q=Z2("{","}",$);if(!Q)return $.split(",");let{pre:J,body:X,post:V}=Q,Y=J.split(",");Y[Y.length-1]+="{"+X+"}";let K=_5(V);if(V.length)Y[Y.length-1]+=K.shift(),Y.push.apply(Y,K);return Z.push.apply(Z,Y),Z}function w5($,Z={}){if(!$)return[];let{max:Q=v7}=Z;if($.slice(0,2)==="{}")$="\\{\\}"+$.slice(2);return y4(O7($),Q,!0).map(y7)}function b7($){return"{"+$+"}"}function f7($){return/^-?0\d/.test($)}function h7($,Z){return $<=Z}function g7($,Z){return $>=Z}function y4($,Z,Q){let J=[],X=Z2("{","}",$);if(!X)return[$];let V=X.pre,Y=X.post.length?y4(X.post,Z,!1):[""];if(/\$$/.test(X.pre))for(let K=0;K<Y.length&&K<Z;K++){let q=V+"{"+X.body+"}"+Y[K];J.push(q)}else{let K=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(X.body),q=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(X.body),W=K||q,z=X.body.indexOf(",")>=0;if(!W&&!z){if(X.post.match(/,(?!,).*\}/))return $=X.pre+"{"+X.body+J2+X.post,y4($,Z,!0);return[$]}let G;if(W)G=X.body.split(/\.\./);else if(G=_5(X.body),G.length===1&&G[0]!==void 0){if(G=y4(G[0],Z,!1).map(b7),G.length===1)return Y.map((B)=>X.pre+G[0]+B)}let A;if(W&&G[0]!==void 0&&G[1]!==void 0){let B=Q2(G[0]),_=Q2(G[1]),L=Math.max(G[0].length,G[1].length),F=G.length===3&&G[2]!==void 0?Math.abs(Q2(G[2])):1,w=h7;if(_<B)F*=-1,w=g7;let M=G.some(f7);A=[];for(let E=B;w(E,_);E+=F){let I;if(q){if(I=String.fromCharCode(E),I==="\\")I=""}else if(I=String(E),M){let g=L-I.length;if(g>0){let x=Array(g+1).join("0");if(E<0)I="-"+x+I.slice(1);else I=x+I}}A.push(I)}}else{A=[];for(let B=0;B<G.length;B++)A.push.apply(A,y4(G[B],Z,!1))}for(let B=0;B<A.length;B++)for(let _=0;_<Y.length&&J.length<Z;_++){let L=V+A[B]+Y[_];if(!Q||W||L)J.push(L)}}return J}var b4=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var u7={"[: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]},f4=($)=>$.replace(/[[\]\\-]/g,"\\$&"),d7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),F5=($)=>$.join(""),R5=($,Z)=>{let Q=Z;if($.charAt(Q)!=="[")throw Error("not in a brace expression");let J=[],X=[],V=Q+1,Y=!1,K=!1,q=!1,W=!1,z=Q,G="";$:while(V<$.length){let L=$.charAt(V);if((L==="!"||L==="^")&&V===Q+1){W=!0,V++;continue}if(L==="]"&&Y&&!q){z=V+1;break}if(Y=!0,L==="\\"){if(!q){q=!0,V++;continue}}if(L==="["&&!q){for(let[F,[w,P,M]]of Object.entries(u7))if($.startsWith(F,V)){if(G)return["$.",!1,$.length-Q,!0];if(V+=F.length,M)X.push(w);else J.push(w);K=K||P;continue $}}if(q=!1,G){if(L>G)J.push(f4(G)+"-"+f4(L));else if(L===G)J.push(f4(L));G="",V++;continue}if($.startsWith("-]",V+1)){J.push(f4(L+"-")),V+=2;continue}if($.startsWith("-",V+1)){G=L,V+=2;continue}J.push(f4(L)),V++}if(z<V)return["",!1,0,!1];if(!J.length&&!X.length)return["$.",!1,$.length-Q,!0];if(X.length===0&&J.length===1&&/^\\?.$/.test(J[0])&&!W){let L=J[0].length===2?J[0].slice(-1):J[0];return[d7(L),!1,z-Q,!1]}let A="["+(W?"^":"")+F5(J)+"]",B="["+(W?"":"^")+F5(X)+"]";return[J.length&&X.length?"("+A+"|"+B+")":J.length?A:B,K,z-Q,!0]};var L0=($,{windowsPathsNoEscape:Z=!1,magicalBraces:Q=!0}={})=>{if(Q)return Z?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");return Z?$.replace(/\[([^\/\\{}])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")};var K0,m7=new Set(["!","?","+","*","@"]),X2=($)=>m7.has($),C5=($)=>X2($.type),c7=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),l7=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),p7=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),N5=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),a7="(?!(?:^|/)\\.\\.?(?:$|/))",q6="(?!\\.)",r7=new Set(["[","."]),n7=new Set(["..","."]),i7=new Set("().*{}+?[]^$\\!"),o7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),V2="[^/]",P5=V2+"*?",D5=V2+"+?",s7=0;class j4{type;#$;#J;#X=!1;#Z=[];#Y;#N;#_;#z=!1;#K;#G;#H=!1;id=++s7;get depth(){return(this.#Y?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#$.id,parent:this.#Y?.id,depth:this.depth,partsLength:this.#Z.length,parts:this.#Z}}constructor($,Z,Q={}){if(this.type=$,$)this.#J=!0;if(this.#Y=Z,this.#$=this.#Y?this.#Y.#$:this,this.#K=this.#$===this?Q:this.#$.#K,this.#_=this.#$===this?[]:this.#$.#_,$==="!"&&!this.#$.#z)this.#_.push(this);this.#N=this.#Y?this.#Y.#Z.length:0}get hasMagic(){if(this.#J!==void 0)return this.#J;for(let $ of this.#Z){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#J=!0}return this.#J}toString(){if(this.#G!==void 0)return this.#G;if(!this.type)return this.#G=this.#Z.map(($)=>String($)).join("");else return this.#G=this.type+"("+this.#Z.map(($)=>String($)).join("|")+")"}#q(){if(this!==this.#$)throw Error("should only call on root");if(this.#z)return this;this.toString(),this.#z=!0;let $;while($=this.#_.pop()){if($.type!=="!")continue;let Z=$,Q=Z.#Y;while(Q){for(let J=Z.#N+1;!Q.type&&J<Q.#Z.length;J++)for(let X of $.#Z){if(typeof X==="string")throw Error("string part in extglob AST??");X.copyIn(Q.#Z[J])}Z=Q,Q=Z.#Y}}return this}push(...$){for(let Z of $){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof K0&&Z.#Y===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.#Y?.type==="!"))$.push({});return $}isStart(){if(this.#$===this)return!0;if(!this.#Y?.isStart())return!1;if(this.#N===0)return!0;let $=this.#Y;for(let Z=0;Z<this.#N;Z++){let Q=$.#Z[Z];if(!(Q instanceof K0&&Q.type==="!"))return!1}return!0}isEnd(){if(this.#$===this)return!0;if(this.#Y?.type==="!")return!0;if(!this.#Y?.isEnd())return!1;if(!this.type)return this.#Y?.isEnd();let $=this.#Y?this.#Y.#Z.length:0;return this.#N===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Z=new K0(this.type,$);for(let Q of this.#Z)Z.copyIn(Q);return Z}static#V($,Z,Q,J,X){let V=J.maxExtglobRecursion??2,Y=!1,K=!1,q=-1,W=!1;if(Z.type===null){let _=Q,L="";while(_<$.length){let F=$.charAt(_++);if(Y||F==="\\"){Y=!Y,L+=F;continue}if(K){if(_===q+1){if(F==="^"||F==="!")W=!0}else if(F==="]"&&!(_===q+2&&W))K=!1;L+=F;continue}else if(F==="["){K=!0,q=_,W=!1,L+=F;continue}if(!J.noext&&X2(F)&&$.charAt(_)==="("&&X<=V){Z.push(L),L="";let P=new K0(F,Z);_=K0.#V($,P,_,J,X+1),Z.push(P);continue}L+=F}return Z.push(L),_}let z=Q+1,G=new K0(null,Z),A=[],B="";while(z<$.length){let _=$.charAt(z++);if(Y||_==="\\"){Y=!Y,B+=_;continue}if(K){if(z===q+1){if(_==="^"||_==="!")W=!0}else if(_==="]"&&!(z===q+2&&W))K=!1;B+=_;continue}else if(_==="["){K=!0,q=z,W=!1,B+=_;continue}if(!J.noext&&X2(_)&&$.charAt(z)==="("&&(X<=V||Z&&Z.#U(_))){let F=Z&&Z.#U(_)?0:1;G.push(B),B="";let w=new K0(_,G);G.push(w),z=K0.#V($,w,z,J,X+F);continue}if(_==="|"){G.push(B),B="",A.push(G),G=new K0(null,Z);continue}if(_===")"){if(B===""&&Z.#Z.length===0)Z.#H=!0;return G.push(B),B="",Z.push(...A,G),z}B+=_}return Z.type=null,Z.#J=void 0,Z.#Z=[$.substring(Q-1)],z}#w($){return this.#R($,l7)}#R($,Z=c7){if(!$||typeof $!=="object"||$.type!==null||$.#Z.length!==1||this.type===null)return!1;let Q=$.#Z[0];if(!Q||typeof Q!=="object"||Q.type===null)return!1;return this.#U(Q.type,Z)}#U($,Z=p7){return!!Z.get(this.type)?.includes($)}#A($,Z){let Q=$.#Z[0],J=new K0(null,Q,this.options);J.#Z.push(""),Q.push(J),this.#I($,Z)}#I($,Z){let Q=$.#Z[0];this.#Z.splice(Z,1,...Q.#Z);for(let J of Q.#Z)if(typeof J==="object")J.#Y=this;this.#G=void 0}#B($){return!!N5.get(this.type)?.has($)}#C($){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)}#P($){let Z=N5.get(this.type),Q=$.#Z[0],J=Z?.get(Q.type);if(!J)return!1;this.#Z=Q.#Z;for(let X of this.#Z)if(typeof X==="object")X.#Y=this;this.type=J,this.#G=void 0,this.#H=!1}static fromGlob($,Z={}){let Q=new K0(null,void 0,Z);return K0.#V($,Q,0,Z,0),Q}toMMPattern(){if(this!==this.#$)return this.#$.toMMPattern();let $=this.toString(),[Z,Q,J,X]=this.toRegExpSource();if(!(J||this.#J||this.#K.nocase&&!this.#K.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return Q;let Y=(this.#K.nocase?"i":"")+(X?"u":"");return Object.assign(new RegExp(`^${Z}$`,Y),{_src:Z,_glob:$})}get options(){return this.#K}toRegExpSource($){let Z=$??!!this.#K.dot;if(this.#$===this)this.#j(),this.#q();if(!C5(this)){let K=this.isStart()&&this.isEnd()&&!this.#Z.some((A)=>typeof A!=="string"),q=this.#Z.map((A)=>{let[B,_,L,F]=typeof A==="string"?K0.#F(A,this.#J,K):A.toRegExpSource($);return this.#J=this.#J||L,this.#X=this.#X||F,B}).join(""),W="";if(this.isStart()){if(typeof this.#Z[0]==="string"){if(!(this.#Z.length===1&&n7.has(this.#Z[0]))){let B=r7,_=Z&&B.has(q.charAt(0))||q.startsWith("\\.")&&B.has(q.charAt(2))||q.startsWith("\\.\\.")&&B.has(q.charAt(4)),L=!Z&&!$&&B.has(q.charAt(0));W=_?a7:L?q6:""}}}let z="";if(this.isEnd()&&this.#$.#z&&this.#Y?.type==="!")z="(?:$|\\/)";return[W+q+z,L0(q),this.#J=!!this.#J,this.#X]}let Q=this.type==="*"||this.type==="+",J=this.type==="!"?"(?:(?!(?:":"(?:",X=this.#L(Z);if(this.isStart()&&this.isEnd()&&!X&&this.type!=="!"){let K=this.toString(),q=this;return q.#Z=[K],q.type=null,q.#J=void 0,[K,L0(this.toString()),!1,!1]}let V=!Q||$||Z||!q6?"":this.#L(!0);if(V===X)V="";if(V)X=`(?:${X})(?:${V})*?`;let Y="";if(this.type==="!"&&this.#H)Y=(this.isStart()&&!Z?q6:"")+D5;else{let K=this.type==="!"?"))"+(this.isStart()&&!Z&&!$?q6:"")+P5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&V?")":this.type==="*"&&V?")?":`)${this.type}`;Y=J+X+K}return[Y,L0(X),this.#J=!!this.#J,this.#X]}#j(){if(!C5(this)){for(let $ of this.#Z)if(typeof $==="object")$.#j()}else{let $=0,Z=!1;do{Z=!0;for(let Q=0;Q<this.#Z.length;Q++){let J=this.#Z[Q];if(typeof J==="object"){if(J.#j(),this.#R(J))Z=!1,this.#I(J,Q);else if(this.#w(J))Z=!1,this.#A(J,Q);else if(this.#C(J))Z=!1,this.#P(J)}}}while(!Z&&++$<10)}this.#G=void 0}#L($){return this.#Z.map((Z)=>{if(typeof Z==="string")throw Error("string type in extglob ast??");let[Q,J,X,V]=Z.toRegExpSource($);return this.#X=this.#X||V,Q}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#F($,Z,Q=!1){let J=!1,X="",V=!1,Y=!1;for(let K=0;K<$.length;K++){let q=$.charAt(K);if(J){J=!1,X+=(i7.has(q)?"\\":"")+q;continue}if(q==="*"){if(Y)continue;Y=!0,X+=Q&&/^[*]+$/.test($)?D5:P5,Z=!0;continue}else Y=!1;if(q==="\\"){if(K===$.length-1)X+="\\\\";else J=!0;continue}if(q==="["){let[W,z,G,A]=R5($,K);if(G){X+=W,V=V||z,K+=G-1,Z=Z||A;continue}}if(q==="?"){X+=V2,Z=!0;continue}X+=o7(q)}return[X,L0($),!!Z,V]}}K0=j4;var U4=($,{windowsPathsNoEscape:Z=!1,magicalBraces:Q=!1}={})=>{if(Q)return Z?$.replace(/[?*()[\]{}]/g,"[$&]"):$.replace(/[?*()[\]\\{}]/g,"\\$&");return Z?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var t=($,Z,Q={})=>{if(b4(Z),!Q.nocomment&&Z.charAt(0)==="#")return!1;return new G0(Z,Q).match($)},e7=/^\*+([^+@!?\*\[\(]*)$/,t7=($)=>(Z)=>!Z.startsWith(".")&&Z.endsWith($),$8=($)=>(Z)=>Z.endsWith($),Z8=($)=>{return $=$.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith($)},Q8=($)=>{return $=$.toLowerCase(),(Z)=>Z.toLowerCase().endsWith($)},J8=/^\*+\.\*+$/,X8=($)=>!$.startsWith(".")&&$.includes("."),V8=($)=>$!=="."&&$!==".."&&$.includes("."),Y8=/^\.\*+$/,K8=($)=>$!=="."&&$!==".."&&$.startsWith("."),q8=/^\*+$/,W8=($)=>$.length!==0&&!$.startsWith("."),H8=($)=>$.length!==0&&$!=="."&&$!=="..",z8=/^\?+([^+@!?\*\[\(]*)?$/,G8=([$,Z=""])=>{let Q=S5([$]);if(!Z)return Q;return Z=Z.toLowerCase(),(J)=>Q(J)&&J.toLowerCase().endsWith(Z)},j8=([$,Z=""])=>{let Q=E5([$]);if(!Z)return Q;return Z=Z.toLowerCase(),(J)=>Q(J)&&J.toLowerCase().endsWith(Z)},U8=([$,Z=""])=>{let Q=E5([$]);return!Z?Q:(J)=>Q(J)&&J.endsWith(Z)},A8=([$,Z=""])=>{let Q=S5([$]);return!Z?Q:(J)=>Q(J)&&J.endsWith(Z)},S5=([$])=>{let Z=$.length;return(Q)=>Q.length===Z&&!Q.startsWith(".")},E5=([$])=>{let Z=$.length;return(Q)=>Q.length===Z&&Q!=="."&&Q!==".."},T5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",I5={win32:{sep:"\\"},posix:{sep:"/"}},B8=T5==="win32"?I5.win32.sep:I5.posix.sep;t.sep=B8;var d=Symbol("globstar **");t.GLOBSTAR=d;var L8="[^/]",_8=L8+"*?",w8="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",F8="(?:(?!(?:\\/|^)\\.).)*?",R8=($,Z={})=>(Q)=>t(Q,$,Z);t.filter=R8;var z0=($,Z={})=>Object.assign({},$,Z),C8=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return t;let Z=t;return Object.assign((J,X,V={})=>Z(J,X,z0($,V)),{Minimatch:class extends Z.Minimatch{constructor(X,V={}){super(X,z0($,V))}static defaults(X){return Z.defaults(z0($,X)).Minimatch}},AST:class extends Z.AST{constructor(X,V,Y={}){super(X,V,z0($,Y))}static fromGlob(X,V={}){return Z.AST.fromGlob(X,z0($,V))}},unescape:(J,X={})=>Z.unescape(J,z0($,X)),escape:(J,X={})=>Z.escape(J,z0($,X)),filter:(J,X={})=>Z.filter(J,z0($,X)),defaults:(J)=>Z.defaults(z0($,J)),makeRe:(J,X={})=>Z.makeRe(J,z0($,X)),braceExpand:(J,X={})=>Z.braceExpand(J,z0($,X)),match:(J,X,V={})=>Z.match(J,X,z0($,V)),sep:Z.sep,GLOBSTAR:d})};t.defaults=C8;var x5=($,Z={})=>{if(b4($),Z.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return w5($,{max:Z.braceExpandMax})};t.braceExpand=x5;var N8=($,Z={})=>new G0($,Z).makeRe();t.makeRe=N8;var P8=($,Z,Q={})=>{let J=new G0(Z,Q);if($=$.filter((X)=>J.match(X)),J.options.nonull&&!$.length)$.push(Z);return $};t.match=P8;var M5=/[?*]|[+@!]\(.*?\)|\[|\]/,D8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class G0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor($,Z={}){b4($),Z=Z||{},this.options=Z,this.maxGlobstarRecursion=Z.maxGlobstarRecursion??200,this.pattern=$,this.platform=Z.platform||T5,this.isWindows=this.platform==="win32";let Q="allowWindowsEscape";if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z[Q]===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let $ of this.set)for(let Z of $)if(typeof Z!=="string")return!0;return!1}debug(...$){}make(){let $=this.pattern,Z=this.options;if(!Z.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...X)=>console.error(...X);this.debug(this.pattern,this.globSet);let Q=this.globSet.map((X)=>this.slashSplit(X));this.globParts=this.preprocess(Q),this.debug(this.pattern,this.globParts);let J=this.globParts.map((X,V,Y)=>{if(this.isWindows&&this.windowsNoMagicRoot){let K=X[0]===""&&X[1]===""&&(X[2]==="?"||!M5.test(X[2]))&&!M5.test(X[3]),q=/^[a-z]:/i.test(X[0]);if(K)return[...X.slice(0,4),...X.slice(4).map((W)=>this.parse(W))];else if(q)return[X[0],...X.slice(1).map((W)=>this.parse(W))]}return X.map((K)=>this.parse(K))});if(this.debug(this.pattern,J),this.set=J.filter((X)=>X.indexOf(!1)===-1),this.isWindows)for(let X=0;X<this.set.length;X++){let V=this.set[X];if(V[0]===""&&V[1]===""&&this.globParts[X][2]==="?"&&typeof V[3]==="string"&&/^[a-z]:$/i.test(V[3]))V[2]="?"}this.debug(this.pattern,this.set)}preprocess($){if(this.options.noglobstar){for(let Q=0;Q<$.length;Q++)for(let J=0;J<$[Q].length;J++)if($[Q][J]==="**")$[Q][J]="*"}let{optimizationLevel:Z=1}=this.options;if(Z>=2)$=this.firstPhasePreProcess($),$=this.secondPhasePreProcess($);else if(Z>=1)$=this.levelOneOptimize($);else $=this.adjascentGlobstarOptimize($);return $}adjascentGlobstarOptimize($){return $.map((Z)=>{let Q=-1;while((Q=Z.indexOf("**",Q+1))!==-1){let J=Q;while(Z[J+1]==="**")J++;if(J!==Q)Z.splice(Q,J-Q)}return Z})}levelOneOptimize($){return $.map((Z)=>{return Z=Z.reduce((Q,J)=>{let X=Q[Q.length-1];if(J==="**"&&X==="**")return Q;if(J===".."){if(X&&X!==".."&&X!=="."&&X!=="**")return Q.pop(),Q}return Q.push(J),Q},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let J=1;J<$.length-1;J++){let X=$[J];if(J===1&&X===""&&$[0]==="")continue;if(X==="."||X==="")Z=!0,$.splice(J,1),J--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Z=!0,$.pop()}let Q=0;while((Q=$.indexOf("..",Q+1))!==-1){let J=$[Q-1];if(J&&J!=="."&&J!==".."&&J!=="**")Z=!0,$.splice(Q-1,2),Q-=2}}while(Z);return $.length===0?[""]:$}firstPhasePreProcess($){let Z=!1;do{Z=!1;for(let Q of $){let J=-1;while((J=Q.indexOf("**",J+1))!==-1){let V=J;while(Q[V+1]==="**")V++;if(V>J)Q.splice(J+1,V-J);let Y=Q[J+1],K=Q[J+2],q=Q[J+3];if(Y!=="..")continue;if(!K||K==="."||K===".."||!q||q==="."||q==="..")continue;Z=!0,Q.splice(J,1);let W=Q.slice(0);W[J]="**",$.push(W),J--}if(!this.preserveMultipleSlashes){for(let V=1;V<Q.length-1;V++){let Y=Q[V];if(V===1&&Y===""&&Q[0]==="")continue;if(Y==="."||Y==="")Z=!0,Q.splice(V,1),V--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))Z=!0,Q.pop()}let X=0;while((X=Q.indexOf("..",X+1))!==-1){let V=Q[X-1];if(V&&V!=="."&&V!==".."&&V!=="**"){Z=!0;let K=X===1&&Q[X+1]==="**"?["."]:[];if(Q.splice(X-1,2,...K),Q.length===0)Q.push("");X-=2}}}}while(Z);return $}secondPhasePreProcess($){for(let Z=0;Z<$.length-1;Z++)for(let Q=Z+1;Q<$.length;Q++){let J=this.partsMatch($[Z],$[Q],!this.preserveMultipleSlashes);if(J){$[Z]=[],$[Q]=J;break}}return $.filter((Z)=>Z.length)}partsMatch($,Z,Q=!1){let J=0,X=0,V=[],Y="";while(J<$.length&&X<Z.length)if($[J]===Z[X])V.push(Y==="b"?Z[X]:$[J]),J++,X++;else if(Q&&$[J]==="**"&&Z[X]===$[J+1])V.push($[J]),J++;else if(Q&&Z[X]==="**"&&$[J]===Z[X+1])V.push(Z[X]),X++;else if($[J]==="*"&&Z[X]&&(this.options.dot||!Z[X].startsWith("."))&&Z[X]!=="**"){if(Y==="b")return!1;Y="a",V.push($[J]),J++,X++}else if(Z[X]==="*"&&$[J]&&(this.options.dot||!$[J].startsWith("."))&&$[J]!=="**"){if(Y==="a")return!1;Y="b",V.push(Z[X]),J++,X++}else return!1;return $.length===Z.length&&V}parseNegate(){if(this.nonegate)return;let $=this.pattern,Z=!1,Q=0;for(let J=0;J<$.length&&$.charAt(J)==="!";J++)Z=!Z,Q++;if(Q)this.pattern=$.slice(Q);this.negate=Z}matchOne($,Z,Q=!1){let J=0,X=0;if(this.isWindows){let Y=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),K=!Y&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),q=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),W=!q&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),z=K?3:Y?0:void 0,G=W?3:q?0:void 0;if(typeof z==="number"&&typeof G==="number"){let[A,B]=[$[z],Z[G]];if(A.toLowerCase()===B.toLowerCase())Z[G]=A,X=G,J=z}}let{optimizationLevel:V=1}=this.options;if(V>=2)$=this.levelTwoFileOptimize($);if(Z.includes(d))return this.#$($,Z,Q,J,X);return this.#X($,Z,Q,J,X)}#$($,Z,Q,J,X){let V=Z.indexOf(d,X),Y=Z.lastIndexOf(d),[K,q,W]=Q?[Z.slice(X,V),Z.slice(V+1),[]]:[Z.slice(X,V),Z.slice(V+1,Y),Z.slice(Y+1)];if(K.length){let w=$.slice(J,J+K.length);if(!this.#X(w,K,Q,0,0))return!1;J+=K.length,X+=K.length}let z=0;if(W.length){if(W.length+J>$.length)return!1;let w=$.length-W.length;if(this.#X($,W,Q,w,0))z=W.length;else{if($[$.length-1]!==""||J+W.length===$.length)return!1;if(w--,!this.#X($,W,Q,w,0))return!1;z=W.length+1}}if(!q.length){let w=!!z;for(let P=J;P<$.length-z;P++){let M=String($[P]);if(w=!0,M==="."||M===".."||!this.options.dot&&M.startsWith("."))return!1}return Q||w}let G=[[[],0]],A=G[0],B=0,_=[0];for(let w of q)if(w===d)_.push(B),A=[[],0],G.push(A);else A[0].push(w),B++;let L=G.length-1,F=$.length-z;for(let w of G)w[1]=F-(_[L--]+w[0].length);return!!this.#J($,G,J,0,Q,0,!!z)}#J($,Z,Q,J,X,V,Y){let K=Z[J];if(!K){for(let z=Q;z<$.length;z++){Y=!0;let G=$[z];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1}return Y}let[q,W]=K;while(Q<=W){if(this.#X($.slice(0,Q+q.length),q,X,Q,0)&&V<this.maxGlobstarRecursion){let A=this.#J($,Z,Q+q.length,J+1,X,V+1,Y);if(A!==!1)return A}let G=$[Q];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1;Q++}return X||null}#X($,Z,Q,J,X){let V,Y,K,q;for(V=J,Y=X,q=$.length,K=Z.length;V<q&&Y<K;V++,Y++){this.debug("matchOne loop");let W=Z[Y],z=$[V];if(this.debug(Z,W,z),W===!1||W===d)return!1;let G;if(typeof W==="string")G=z===W,this.debug("string match",W,z,G);else G=W.test(z),this.debug("pattern match",W,z,G);if(!G)return!1}if(V===q&&Y===K)return!0;else if(V===q)return Q;else if(Y===K)return V===q-1&&$[V]==="";else throw Error("wtf?")}braceExpand(){return x5(this.pattern,this.options)}parse($){b4($);let Z=this.options;if($==="**")return d;if($==="")return"";let Q,J=null;if(Q=$.match(q8))J=Z.dot?H8:W8;else if(Q=$.match(e7))J=(Z.nocase?Z.dot?Q8:Z8:Z.dot?$8:t7)(Q[1]);else if(Q=$.match(z8))J=(Z.nocase?Z.dot?j8:G8:Z.dot?U8:A8)(Q);else if(Q=$.match(J8))J=Z.dot?V8:X8;else if(Q=$.match(Y8))J=K8;let X=j4.fromGlob($,this.options).toMMPattern();if(J&&typeof X==="object")Reflect.defineProperty(X,"test",{value:J});return X}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Z=this.options,Q=Z.noglobstar?_8:Z.dot?w8:F8,J=new Set(Z.nocase?["i"]:[]),X=$.map((K)=>{let q=K.map((z)=>{if(z instanceof RegExp)for(let G of z.flags.split(""))J.add(G);return typeof z==="string"?D8(z):z===d?d:z._src});q.forEach((z,G)=>{let A=q[G+1],B=q[G-1];if(z!==d||B===d)return;if(B===void 0)if(A!==void 0&&A!==d)q[G+1]="(?:\\/|"+Q+"\\/)?"+A;else q[G]=Q;else if(A===void 0)q[G-1]=B+"(?:\\/|\\/"+Q+")?";else if(A!==d)q[G-1]=B+"(?:\\/|\\/"+Q+"\\/)"+A,q[G+1]=d});let W=q.filter((z)=>z!==d);if(this.partial&&W.length>=1){let z=[];for(let G=1;G<=W.length;G++)z.push(W.slice(0,G).join("/"));return"(?:"+z.join("|")+")"}return W.join("/")}).join("|"),[V,Y]=$.length>1?["(?:",")"]:["",""];if(X="^"+V+X+Y+"$",this.partial)X="^(?:\\/|"+V+X.slice(1,-1)+Y+")$";if(this.negate)X="^(?!"+X+").+$";try{this.regexp=new RegExp(X,[...J].join(""))}catch(K){this.regexp=!1}return this.regexp}slashSplit($){if(this.preserveMultipleSlashes)return $.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test($))return["",...$.split(/\/+/)];else return $.split(/\/+/)}match($,Z=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Z)return!0;let Q=this.options;if(this.isWindows)$=$.split("\\").join("/");let J=this.slashSplit($);this.debug(this.pattern,"split",J);let X=this.set;this.debug(this.pattern,"set",X);let V=J[J.length-1];if(!V)for(let Y=J.length-2;!V&&Y>=0;Y--)V=J[Y];for(let Y=0;Y<X.length;Y++){let K=X[Y],q=J;if(Q.matchBase&&K.length===1)q=[V];if(this.matchOne(q,K,Z)){if(Q.flipNegate)return!0;return!this.negate}}if(Q.flipNegate)return!1;return this.negate}static defaults($){return t.defaults($).Minimatch}}t.AST=j4;t.Minimatch=G0;t.escape=U4;t.unescape=L0;import{fileURLToPath as VZ}from"url";var I8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,v5=new Set,Y2=typeof process=="object"&&process?process:{},O5=($,Z,Q,J)=>{typeof Y2.emitWarning=="function"?Y2.emitWarning($,Z,Q,J):console.error(`[${Q}] ${Z}: ${$}`)},H6=globalThis.AbortController,k5=globalThis.AbortSignal;if(typeof H6>"u"){k5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Q,J){this._onabort.push(J)}},H6=class{constructor(){Z()}signal=new k5;abort(Q){if(!this.signal.aborted){this.signal.reason=Q,this.signal.aborted=!0;for(let J of this.signal._onabort)J(Q);this.signal.onabort?.(Q)}}};let $=Y2.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{$&&($=!1,O5("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 M8=($)=>!v5.has($),RY=Symbol("type"),n0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),y5=($)=>n0($)?$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?W6:null:null,W6=class extends Array{constructor($){super($),this.fill(0)}},S8=class ${heap;length;static#$=!1;static create(Z){let Q=y5(Z);if(!Q)return[];$.#$=!0;let J=new $(Z,Q);return $.#$=!1,J}constructor(Z,Q){if(!$.#$)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Q(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}},h4=class ${#$;#J;#X;#Z;#Y;#N;#_;#z;get perf(){return this.#z}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#K;#G;#H;#q;#V;#w;#R;#U;#A;#I;#B;#C;#P;#j;#L;#F;#M;#Q;#O;static unsafeExposeInternals(Z){return{starts:Z.#P,ttls:Z.#j,autopurgeTimers:Z.#L,sizes:Z.#C,keyMap:Z.#H,keyList:Z.#q,valList:Z.#V,next:Z.#w,prev:Z.#R,get head(){return Z.#U},get tail(){return Z.#A},free:Z.#I,isBackgroundFetch:(Q)=>Z.#W(Q),backgroundFetch:(Q,J,X,V)=>Z.#m(Q,J,X,V),moveToTail:(Q)=>Z.#b(Q),indexes:(Q)=>Z.#T(Q),rindexes:(Q)=>Z.#x(Q),isStale:(Q)=>Z.#D(Q)}}get max(){return this.#$}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#K}get fetchMethod(){return this.#N}get memoMethod(){return this.#_}get dispose(){return this.#X}get onInsert(){return this.#Z}get disposeAfter(){return this.#Y}constructor(Z){let{max:Q=0,ttl:J,ttlResolution:X=1,ttlAutopurge:V,updateAgeOnGet:Y,updateAgeOnHas:K,allowStale:q,dispose:W,onInsert:z,disposeAfter:G,noDisposeOnSet:A,noUpdateTTL:B,maxSize:_=0,maxEntrySize:L=0,sizeCalculation:F,fetchMethod:w,memoMethod:P,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:I,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??I8,Q!==0&&!n0(Q))throw TypeError("max option must be a nonnegative integer");let V0=Q?y5(Q):Array;if(!V0)throw Error("invalid max value: "+Q);if(this.#$=Q,this.#J=_,this.maxEntrySize=L||this.#J,this.sizeCalculation=F,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw TypeError("sizeCalculation set to non-function")}if(P!==void 0&&typeof P!="function")throw TypeError("memoMethod must be a function if defined");if(this.#_=P,w!==void 0&&typeof w!="function")throw TypeError("fetchMethod must be a function if specified");if(this.#N=w,this.#M=!!w,this.#H=new Map,this.#q=Array(Q).fill(void 0),this.#V=Array(Q).fill(void 0),this.#w=new V0(Q),this.#R=new V0(Q),this.#U=0,this.#A=0,this.#I=S8.create(Q),this.#K=0,this.#G=0,typeof W=="function"&&(this.#X=W),typeof z=="function"&&(this.#Z=z),typeof G=="function"?(this.#Y=G,this.#B=[]):(this.#Y=void 0,this.#B=void 0),this.#F=!!this.#X,this.#O=!!this.#Z,this.#Q=!!this.#Y,this.noDisposeOnSet=!!A,this.noUpdateTTL=!!B,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!I,this.allowStaleOnFetchAbort=!!g,this.ignoreFetchAbort=!!x,this.maxEntrySize!==0){if(this.#J!==0&&!n0(this.#J))throw TypeError("maxSize must be a positive integer if specified");if(!n0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#l()}if(this.allowStale=!!q,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!Y,this.updateAgeOnHas=!!K,this.ttlResolution=n0(X)||X===0?X:1,this.ttlAutopurge=!!V,this.ttl=J||0,this.ttl){if(!n0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#$===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#$&&!this.#J){let e="LRU_CACHE_UNBOUNDED";M8(e)&&(v5.add(e),O5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,$))}}getRemainingTTL(Z){return this.#H.has(Z)?1/0:0}#k(){let Z=new W6(this.#$),Q=new W6(this.#$);this.#j=Z,this.#P=Q;let J=this.ttlAutopurge?Array(this.#$):void 0;this.#L=J,this.#h=(Y,K,q=this.#z.now())=>{if(Q[Y]=K!==0?q:0,Z[Y]=K,J?.[Y]&&(clearTimeout(J[Y]),J[Y]=void 0),K!==0&&J){let W=setTimeout(()=>{this.#D(Y)&&this.#E(this.#q[Y],"expire")},K+1);W.unref&&W.unref(),J[Y]=W}},this.#S=(Y)=>{Q[Y]=Z[Y]!==0?this.#z.now():0},this.#v=(Y,K)=>{if(Z[K]){let q=Z[K],W=Q[K];if(!q||!W)return;Y.ttl=q,Y.start=W,Y.now=X||V();let z=Y.now-W;Y.remainingTTL=q-z}};let X=0,V=()=>{let Y=this.#z.now();if(this.ttlResolution>0){X=Y;let K=setTimeout(()=>X=0,this.ttlResolution);K.unref&&K.unref()}return Y};this.getRemainingTTL=(Y)=>{let K=this.#H.get(Y);if(K===void 0)return 0;let q=Z[K],W=Q[K];if(!q||!W)return 1/0;let z=(X||V())-W;return q-z},this.#D=(Y)=>{let K=Q[Y],q=Z[Y];return!!q&&!!K&&(X||V())-K>q}}#S=()=>{};#v=()=>{};#h=()=>{};#D=()=>!1;#l(){let Z=new W6(this.#$);this.#G=0,this.#C=Z,this.#f=(Q)=>{this.#G-=Z[Q],Z[Q]=0},this.#g=(Q,J,X,V)=>{if(this.#W(J))return 0;if(!n0(X))if(V){if(typeof V!="function")throw TypeError("sizeCalculation must be a function");if(X=V(J,Q),!n0(X))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return X},this.#y=(Q,J,X)=>{if(Z[Q]=J,this.#J){let V=this.#J-Z[Q];for(;this.#G>V;)this.#d(!0)}this.#G+=Z[Q],X&&(X.entrySize=J,X.totalCalculatedSize=this.#G)}}#f=(Z)=>{};#y=(Z,Q,J)=>{};#g=(Z,Q,J,X)=>{if(J||X)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#K)for(let Q=this.#A;!(!this.#u(Q)||((Z||!this.#D(Q))&&(yield Q),Q===this.#U));)Q=this.#R[Q]}*#x({allowStale:Z=this.allowStale}={}){if(this.#K)for(let Q=this.#U;!(!this.#u(Q)||((Z||!this.#D(Q))&&(yield Q),Q===this.#A));)Q=this.#w[Q]}#u(Z){return Z!==void 0&&this.#H.get(this.#q[Z])===Z}*entries(){for(let Z of this.#T())this.#V[Z]!==void 0&&this.#q[Z]!==void 0&&!this.#W(this.#V[Z])&&(yield[this.#q[Z],this.#V[Z]])}*rentries(){for(let Z of this.#x())this.#V[Z]!==void 0&&this.#q[Z]!==void 0&&!this.#W(this.#V[Z])&&(yield[this.#q[Z],this.#V[Z]])}*keys(){for(let Z of this.#T()){let Q=this.#q[Z];Q!==void 0&&!this.#W(this.#V[Z])&&(yield Q)}}*rkeys(){for(let Z of this.#x()){let Q=this.#q[Z];Q!==void 0&&!this.#W(this.#V[Z])&&(yield Q)}}*values(){for(let Z of this.#T())this.#V[Z]!==void 0&&!this.#W(this.#V[Z])&&(yield this.#V[Z])}*rvalues(){for(let Z of this.#x())this.#V[Z]!==void 0&&!this.#W(this.#V[Z])&&(yield this.#V[Z])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,Q={}){for(let J of this.#T()){let X=this.#V[J],V=this.#W(X)?X.__staleWhileFetching:X;if(V!==void 0&&Z(V,this.#q[J],this))return this.get(this.#q[J],Q)}}forEach(Z,Q=this){for(let J of this.#T()){let X=this.#V[J],V=this.#W(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(Q,V,this.#q[J],this)}}rforEach(Z,Q=this){for(let J of this.#x()){let X=this.#V[J],V=this.#W(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(Q,V,this.#q[J],this)}}purgeStale(){let Z=!1;for(let Q of this.#x({allowStale:!0}))this.#D(Q)&&(this.#E(this.#q[Q],"expire"),Z=!0);return Z}info(Z){let Q=this.#H.get(Z);if(Q===void 0)return;let J=this.#V[Q],X=this.#W(J)?J.__staleWhileFetching:J;if(X===void 0)return;let V={value:X};if(this.#j&&this.#P){let Y=this.#j[Q],K=this.#P[Q];if(Y&&K){let q=Y-(this.#z.now()-K);V.ttl=q,V.start=Date.now()}}return this.#C&&(V.size=this.#C[Q]),V}dump(){let Z=[];for(let Q of this.#T({allowStale:!0})){let J=this.#q[Q],X=this.#V[Q],V=this.#W(X)?X.__staleWhileFetching:X;if(V===void 0||J===void 0)continue;let Y={value:V};if(this.#j&&this.#P){Y.ttl=this.#j[Q];let K=this.#z.now()-this.#P[Q];Y.start=Math.floor(Date.now()-K)}this.#C&&(Y.size=this.#C[Q]),Z.unshift([J,Y])}return Z}load(Z){this.clear();for(let[Q,J]of Z){if(J.start){let X=Date.now()-J.start;J.start=this.#z.now()-X}this.set(Q,J.value,J)}}set(Z,Q,J={}){if(Q===void 0)return this.delete(Z),this;let{ttl:X=this.ttl,start:V,noDisposeOnSet:Y=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:q}=J,{noUpdateTTL:W=this.noUpdateTTL}=J,z=this.#g(Z,Q,J.size||0,K);if(this.maxEntrySize&&z>this.maxEntrySize)return q&&(q.set="miss",q.maxEntrySizeExceeded=!0),this.#E(Z,"set"),this;let G=this.#K===0?void 0:this.#H.get(Z);if(G===void 0)G=this.#K===0?this.#A:this.#I.length!==0?this.#I.pop():this.#K===this.#$?this.#d(!1):this.#K,this.#q[G]=Z,this.#V[G]=Q,this.#H.set(Z,G),this.#w[this.#A]=G,this.#R[G]=this.#A,this.#A=G,this.#K++,this.#y(G,z,q),q&&(q.set="add"),W=!1,this.#O&&this.#Z?.(Q,Z,"add");else{this.#b(G);let A=this.#V[G];if(Q!==A){if(this.#M&&this.#W(A)){A.__abortController.abort(Error("replaced"));let{__staleWhileFetching:B}=A;B!==void 0&&!Y&&(this.#F&&this.#X?.(B,Z,"set"),this.#Q&&this.#B?.push([B,Z,"set"]))}else Y||(this.#F&&this.#X?.(A,Z,"set"),this.#Q&&this.#B?.push([A,Z,"set"]));if(this.#f(G),this.#y(G,z,q),this.#V[G]=Q,q){q.set="replace";let B=A&&this.#W(A)?A.__staleWhileFetching:A;B!==void 0&&(q.oldValue=B)}}else q&&(q.set="update");this.#O&&this.onInsert?.(Q,Z,Q===A?"update":"replace")}if(X!==0&&!this.#j&&this.#k(),this.#j&&(W||this.#h(G,X,V),q&&this.#v(q,G)),!Y&&this.#Q&&this.#B){let A=this.#B,B;for(;B=A?.shift();)this.#Y?.(...B)}return this}pop(){try{for(;this.#K;){let Z=this.#V[this.#U];if(this.#d(!0),this.#W(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#Q&&this.#B){let Z=this.#B,Q;for(;Q=Z?.shift();)this.#Y?.(...Q)}}}#d(Z){let Q=this.#U,J=this.#q[Q],X=this.#V[Q];return this.#M&&this.#W(X)?X.__abortController.abort(Error("evicted")):(this.#F||this.#Q)&&(this.#F&&this.#X?.(X,J,"evict"),this.#Q&&this.#B?.push([X,J,"evict"])),this.#f(Q),this.#L?.[Q]&&(clearTimeout(this.#L[Q]),this.#L[Q]=void 0),Z&&(this.#q[Q]=void 0,this.#V[Q]=void 0,this.#I.push(Q)),this.#K===1?(this.#U=this.#A=0,this.#I.length=0):this.#U=this.#w[Q],this.#H.delete(J),this.#K--,Q}has(Z,Q={}){let{updateAgeOnHas:J=this.updateAgeOnHas,status:X}=Q,V=this.#H.get(Z);if(V!==void 0){let Y=this.#V[V];if(this.#W(Y)&&Y.__staleWhileFetching===void 0)return!1;if(this.#D(V))X&&(X.has="stale",this.#v(X,V));else return J&&this.#S(V),X&&(X.has="hit",this.#v(X,V)),!0}else X&&(X.has="miss");return!1}peek(Z,Q={}){let{allowStale:J=this.allowStale}=Q,X=this.#H.get(Z);if(X===void 0||!J&&this.#D(X))return;let V=this.#V[X];return this.#W(V)?V.__staleWhileFetching:V}#m(Z,Q,J,X){let V=Q===void 0?void 0:this.#V[Q];if(this.#W(V))return V;let Y=new H6,{signal:K}=J;K?.addEventListener("abort",()=>Y.abort(K.reason),{signal:Y.signal});let q={signal:Y.signal,options:J,context:X},W=(L,F=!1)=>{let{aborted:w}=Y.signal,P=J.ignoreFetchAbort&&L!==void 0,M=J.ignoreFetchAbort||!!(J.allowStaleOnFetchAbort&&L!==void 0);if(J.status&&(w&&!F?(J.status.fetchAborted=!0,J.status.fetchError=Y.signal.reason,P&&(J.status.fetchAbortIgnored=!0)):J.status.fetchResolved=!0),w&&!P&&!F)return G(Y.signal.reason,M);let E=B,I=this.#V[Q];return(I===B||P&&F&&I===void 0)&&(L===void 0?E.__staleWhileFetching!==void 0?this.#V[Q]=E.__staleWhileFetching:this.#E(Z,"fetch"):(J.status&&(J.status.fetchUpdated=!0),this.set(Z,L,q.options))),L},z=(L)=>(J.status&&(J.status.fetchRejected=!0,J.status.fetchError=L),G(L,!1)),G=(L,F)=>{let{aborted:w}=Y.signal,P=w&&J.allowStaleOnFetchAbort,M=P||J.allowStaleOnFetchRejection,E=M||J.noDeleteOnFetchRejection,I=B;if(this.#V[Q]===B&&(!E||!F&&I.__staleWhileFetching===void 0?this.#E(Z,"fetch"):P||(this.#V[Q]=I.__staleWhileFetching)),M)return J.status&&I.__staleWhileFetching!==void 0&&(J.status.returnedStale=!0),I.__staleWhileFetching;if(I.__returned===I)throw L},A=(L,F)=>{let w=this.#N?.(Z,V,q);w&&w instanceof Promise&&w.then((P)=>L(P===void 0?void 0:P),F),Y.signal.addEventListener("abort",()=>{(!J.ignoreFetchAbort||J.allowStaleOnFetchAbort)&&(L(void 0),J.allowStaleOnFetchAbort&&(L=(P)=>W(P,!0)))})};J.status&&(J.status.fetchDispatched=!0);let B=new Promise(A).then(W,z),_=Object.assign(B,{__abortController:Y,__staleWhileFetching:V,__returned:void 0});return Q===void 0?(this.set(Z,_,{...q.options,status:void 0}),Q=this.#H.get(Z)):this.#V[Q]=_,_}#W(Z){if(!this.#M)return!1;let Q=Z;return!!Q&&Q instanceof Promise&&Q.hasOwnProperty("__staleWhileFetching")&&Q.__abortController instanceof H6}async fetch(Z,Q={}){let{allowStale:J=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,ttl:Y=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:q=0,sizeCalculation:W=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:G=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:A=this.allowStaleOnFetchRejection,ignoreFetchAbort:B=this.ignoreFetchAbort,allowStaleOnFetchAbort:_=this.allowStaleOnFetchAbort,context:L,forceRefresh:F=!1,status:w,signal:P}=Q;if(!this.#M)return w&&(w.fetch="get"),this.get(Z,{allowStale:J,updateAgeOnGet:X,noDeleteOnStaleGet:V,status:w});let M={allowStale:J,updateAgeOnGet:X,noDeleteOnStaleGet:V,ttl:Y,noDisposeOnSet:K,size:q,sizeCalculation:W,noUpdateTTL:z,noDeleteOnFetchRejection:G,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:_,ignoreFetchAbort:B,status:w,signal:P},E=this.#H.get(Z);if(E===void 0){w&&(w.fetch="miss");let I=this.#m(Z,E,M,L);return I.__returned=I}else{let I=this.#V[E];if(this.#W(I)){let V0=J&&I.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",V0&&(w.returnedStale=!0)),V0?I.__staleWhileFetching:I.__returned=I}let g=this.#D(E);if(!F&&!g)return w&&(w.fetch="hit"),this.#b(E),X&&this.#S(E),w&&this.#v(w,E),I;let x=this.#m(Z,E,M,L),c=x.__staleWhileFetching!==void 0&&J;return w&&(w.fetch=g?"stale":"refresh",c&&g&&(w.returnedStale=!0)),c?x.__staleWhileFetching:x.__returned=x}}async forceFetch(Z,Q={}){let J=await this.fetch(Z,Q);if(J===void 0)throw Error("fetch() returned undefined");return J}memo(Z,Q={}){let J=this.#_;if(!J)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:V,...Y}=Q,K=this.get(Z,Y);if(!V&&K!==void 0)return K;let q=J(Z,K,{options:Y,context:X});return this.set(Z,q,Y),q}get(Z,Q={}){let{allowStale:J=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,status:Y}=Q,K=this.#H.get(Z);if(K!==void 0){let q=this.#V[K],W=this.#W(q);return Y&&this.#v(Y,K),this.#D(K)?(Y&&(Y.get="stale"),W?(Y&&J&&q.__staleWhileFetching!==void 0&&(Y.returnedStale=!0),J?q.__staleWhileFetching:void 0):(V||this.#E(Z,"expire"),Y&&J&&(Y.returnedStale=!0),J?q:void 0)):(Y&&(Y.get="hit"),W?q.__staleWhileFetching:(this.#b(K),X&&this.#S(K),q))}else Y&&(Y.get="miss")}#c(Z,Q){this.#R[Q]=Z,this.#w[Z]=Q}#b(Z){Z!==this.#A&&(Z===this.#U?this.#U=this.#w[Z]:this.#c(this.#R[Z],this.#w[Z]),this.#c(this.#A,Z),this.#A=Z)}delete(Z){return this.#E(Z,"delete")}#E(Z,Q){let J=!1;if(this.#K!==0){let X=this.#H.get(Z);if(X!==void 0)if(this.#L?.[X]&&(clearTimeout(this.#L?.[X]),this.#L[X]=void 0),J=!0,this.#K===1)this.#p(Q);else{this.#f(X);let V=this.#V[X];if(this.#W(V)?V.__abortController.abort(Error("deleted")):(this.#F||this.#Q)&&(this.#F&&this.#X?.(V,Z,Q),this.#Q&&this.#B?.push([V,Z,Q])),this.#H.delete(Z),this.#q[X]=void 0,this.#V[X]=void 0,X===this.#A)this.#A=this.#R[X];else if(X===this.#U)this.#U=this.#w[X];else{let Y=this.#R[X];this.#w[Y]=this.#w[X];let K=this.#w[X];this.#R[K]=this.#R[X]}this.#K--,this.#I.push(X)}}if(this.#Q&&this.#B?.length){let X=this.#B,V;for(;V=X?.shift();)this.#Y?.(...V)}return J}clear(){return this.#p("delete")}#p(Z){for(let Q of this.#x({allowStale:!0})){let J=this.#V[Q];if(this.#W(J))J.__abortController.abort(Error("deleted"));else{let X=this.#q[Q];this.#F&&this.#X?.(J,X,Z),this.#Q&&this.#B?.push([J,X,Z])}}if(this.#H.clear(),this.#V.fill(void 0),this.#q.fill(void 0),this.#j&&this.#P){this.#j.fill(0),this.#P.fill(0);for(let Q of this.#L??[])Q!==void 0&&clearTimeout(Q);this.#L?.fill(void 0)}if(this.#C&&this.#C.fill(0),this.#U=0,this.#A=0,this.#I.length=0,this.#G=0,this.#K=0,this.#Q&&this.#B){let Q=this.#B,J;for(;J=Q?.shift();)this.#Y?.(...J)}}};import{posix as g8,win32 as B2}from"path";import{fileURLToPath as u8}from"url";import{lstatSync as d8,readdir as m8,readdirSync as c8,readlinkSync as l8,realpathSync as p8}from"fs";import*as a8 from"fs";import{lstat as n8,readdir as i8,readlink as o8,realpath as s8}from"fs/promises";import{EventEmitter as G2}from"events";import u5 from"stream";import{StringDecoder as E8}from"string_decoder";var b5=typeof process==="object"&&process?process:{stdout:null,stderr:null},T8=($)=>!!$&&typeof $==="object"&&($ instanceof X4||$ instanceof u5||x8($)||k8($)),x8=($)=>!!$&&typeof $==="object"&&$ instanceof G2&&typeof $.pipe==="function"&&$.pipe!==u5.Writable.prototype.pipe,k8=($)=>!!$&&typeof $==="object"&&$ instanceof G2&&typeof $.write==="function"&&typeof $.end==="function",g0=Symbol("EOF"),u0=Symbol("maybeEmitEnd"),i0=Symbol("emittedEnd"),z6=Symbol("emittingEnd"),g4=Symbol("emittedError"),G6=Symbol("closed"),f5=Symbol("read"),j6=Symbol("flush"),h5=Symbol("flushChunk"),_0=Symbol("encoding"),A4=Symbol("decoder"),p=Symbol("flowing"),u4=Symbol("paused"),B4=Symbol("resume"),a=Symbol("buffer"),$0=Symbol("pipes"),r=Symbol("bufferLength"),K2=Symbol("bufferPush"),U6=Symbol("bufferShift"),o=Symbol("objectMode"),m=Symbol("destroyed"),q2=Symbol("error"),W2=Symbol("emitData"),g5=Symbol("emitEnd"),H2=Symbol("emitEnd2"),P0=Symbol("async"),z2=Symbol("abort"),A6=Symbol("aborted"),d4=Symbol("signal"),J4=Symbol("dataListeners"),W0=Symbol("discarded"),m4=($)=>Promise.resolve().then($),v8=($)=>$(),O8=($)=>$==="end"||$==="finish"||$==="prefinish",y8=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,b8=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class j2{src;dest;opts;ondrain;constructor($,Z,Q){this.src=$,this.dest=Z,this.opts=Q,this.ondrain=()=>$[B4](),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 d5 extends j2{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Z,Q){super($,Z,Q);this.proxyErrors=(J)=>this.dest.emit("error",J),$.on("error",this.proxyErrors)}}var f8=($)=>!!$.objectMode,h8=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class X4 extends G2{[p]=!1;[u4]=!1;[$0]=[];[a]=[];[o];[_0];[P0];[A4];[g0]=!1;[i0]=!1;[z6]=!1;[G6]=!1;[g4]=null;[r]=0;[m]=!1;[d4];[A6]=!1;[J4]=0;[W0]=!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(f8(Z))this[o]=!0,this[_0]=null;else if(h8(Z))this[_0]=Z.encoding,this[o]=!1;else this[o]=!1,this[_0]=null;if(this[P0]=!!Z.async,this[A4]=this[_0]?new E8(this[_0]):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:Q}=Z;if(Q)if(this[d4]=Q,Q.aborted)this[z2]();else Q.addEventListener("abort",()=>this[z2]())}get bufferLength(){return this[r]}get encoding(){return this[_0]}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[P0]}set["async"]($){this[P0]=this[P0]||!!$}[z2](){this[A6]=!0,this.emit("abort",this[d4]?.reason),this.destroy(this[d4]?.reason)}get aborted(){return this[A6]}set aborted($){}write($,Z,Q){if(this[A6])return!1;if(this[g0])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")Q=Z,Z="utf8";if(!Z)Z="utf8";let J=this[P0]?m4:v8;if(!this[o]&&!Buffer.isBuffer($)){if(b8($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(y8($))$=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[j6](!0);if(this[p])this.emit("data",$);else this[K2]($);if(this[r]!==0)this.emit("readable");if(Q)J(Q);return this[p]}if(!$.length){if(this[r]!==0)this.emit("readable");if(Q)J(Q);return this[p]}if(typeof $==="string"&&!(Z===this[_0]&&!this[A4]?.lastNeed))$=Buffer.from($,Z);if(Buffer.isBuffer($)&&this[_0])$=this[A4].write($);if(this[p]&&this[r]!==0)this[j6](!0);if(this[p])this.emit("data",$);else this[K2]($);if(this[r]!==0)this.emit("readable");if(Q)J(Q);return this[p]}read($){if(this[m])return null;if(this[W0]=!1,this[r]===0||$===0||$&&$>this[r])return this[u0](),null;if(this[o])$=null;if(this[a].length>1&&!this[o])this[a]=[this[_0]?this[a].join(""):Buffer.concat(this[a],this[r])];let Z=this[f5]($||null,this[a][0]);return this[u0](),Z}[f5]($,Z){if(this[o])this[U6]();else{let Q=Z;if($===Q.length||$===null)this[U6]();else if(typeof Q==="string")this[a][0]=Q.slice($),Z=Q.slice(0,$),this[r]-=$;else this[a][0]=Q.subarray($),Z=Q.subarray(0,$),this[r]-=$}if(this.emit("data",Z),!this[a].length&&!this[g0])this.emit("drain");return Z}end($,Z,Q){if(typeof $==="function")Q=$,$=void 0;if(typeof Z==="function")Q=Z,Z="utf8";if($!==void 0)this.write($,Z);if(Q)this.once("end",Q);if(this[g0]=!0,this.writable=!1,this[p]||!this[u4])this[u0]();return this}[B4](){if(this[m])return;if(!this[J4]&&!this[$0].length)this[W0]=!0;if(this[u4]=!1,this[p]=!0,this.emit("resume"),this[a].length)this[j6]();else if(this[g0])this[u0]();else this.emit("drain")}resume(){return this[B4]()}pause(){this[p]=!1,this[u4]=!0,this[W0]=!1}get destroyed(){return this[m]}get flowing(){return this[p]}get paused(){return this[u4]}[K2]($){if(this[o])this[r]+=1;else this[r]+=$.length;this[a].push($)}[U6](){if(this[o])this[r]-=1;else this[r]-=this[a][0].length;return this[a].shift()}[j6]($=!1){do;while(this[h5](this[U6]())&&this[a].length);if(!$&&!this[a].length&&!this[g0])this.emit("drain")}[h5]($){return this.emit("data",$),this[p]}pipe($,Z){if(this[m])return $;this[W0]=!1;let Q=this[i0];if(Z=Z||{},$===b5.stdout||$===b5.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,Q){if(Z.end)$.end()}else if(this[$0].push(!Z.proxyErrors?new j2(this,$,Z):new d5(this,$,Z)),this[P0])m4(()=>this[B4]());else this[B4]();return $}unpipe($){let Z=this[$0].find((Q)=>Q.dest===$);if(Z){if(this[$0].length===1){if(this[p]&&this[J4]===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 Q=super.on($,Z);if($==="data"){if(this[W0]=!1,this[J4]++,!this[$0].length&&!this[p])this[B4]()}else if($==="readable"&&this[r]!==0)super.emit("readable");else if(O8($)&&this[i0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[g4]){let J=Z;if(this[P0])m4(()=>J.call(this,this[g4]));else J.call(this,this[g4])}return Q}removeListener($,Z){return this.off($,Z)}off($,Z){let Q=super.off($,Z);if($==="data"){if(this[J4]=this.listeners("data").length,this[J4]===0&&!this[W0]&&!this[$0].length)this[p]=!1}return Q}removeAllListeners($){let Z=super.removeAllListeners($);if($==="data"||$===void 0){if(this[J4]=0,!this[W0]&&!this[$0].length)this[p]=!1}return Z}get emittedEnd(){return this[i0]}[u0](){if(!this[z6]&&!this[i0]&&!this[m]&&this[a].length===0&&this[g0]){if(this[z6]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[G6])this.emit("close");this[z6]=!1}}emit($,...Z){let Q=Z[0];if($!=="error"&&$!=="close"&&$!==m&&this[m])return!1;else if($==="data")return!this[o]&&!Q?!1:this[P0]?(m4(()=>this[W2](Q)),!0):this[W2](Q);else if($==="end")return this[g5]();else if($==="close"){if(this[G6]=!0,!this[i0]&&!this[m])return!1;let X=super.emit("close");return this.removeAllListeners("close"),X}else if($==="error"){this[g4]=Q,super.emit(q2,Q);let X=!this[d4]||this.listeners("error").length?super.emit("error",Q):!1;return this[u0](),X}else if($==="resume"){let X=super.emit("resume");return this[u0](),X}else if($==="finish"||$==="prefinish"){let X=super.emit($);return this.removeAllListeners($),X}let J=super.emit($,...Z);return this[u0](),J}[W2]($){for(let Q of this[$0])if(Q.dest.write($)===!1)this.pause();let Z=this[W0]?!1:super.emit("data",$);return this[u0](),Z}[g5](){if(this[i0])return!1;return this[i0]=!0,this.readable=!1,this[P0]?(m4(()=>this[H2]()),!0):this[H2]()}[H2](){if(this[A4]){let Z=this[A4].end();if(Z){for(let Q of this[$0])Q.dest.write(Z);if(!this[W0])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",(Q)=>{if($.push(Q),!this[o])$.dataLength+=Q.length}),await Z,$}async concat(){if(this[o])throw Error("cannot concat in objectMode");let $=await this.collect();return this[_0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Z)=>{this.on(m,()=>Z(Error("stream destroyed"))),this.on("error",(Q)=>Z(Q)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[W0]=!1;let $=!1,Z=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Z();let J=this.read();if(J!==null)return Promise.resolve({done:!1,value:J});if(this[g0])return Z();let X,V,Y=(z)=>{this.off("data",K),this.off("end",q),this.off(m,W),Z(),V(z)},K=(z)=>{this.off("error",Y),this.off("end",q),this.off(m,W),this.pause(),X({value:z,done:!!this[g0]})},q=()=>{this.off("error",Y),this.off("data",K),this.off(m,W),Z(),X({done:!0,value:void 0})},W=()=>Y(Error("stream destroyed"));return new Promise((z,G)=>{V=G,X=z,this.once(m,W),this.once("error",Y),this.once("end",q),this.once("data",K)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[W0]=!1;let $=!1,Z=()=>{return this.pause(),this.off(q2,Z),this.off(m,Z),this.off("end",Z),$=!0,{done:!0,value:void 0}},Q=()=>{if($)return Z();let J=this.read();return J===null?Z():{done:!1,value:J}};return this.once("end",Z),this.once(q2,Z),this.once(m,Z),{next:Q,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[W0]=!0,this[a].length=0,this[r]=0;let Z=this;if(typeof Z.close==="function"&&!this[G6])Z.close();if($)this.emit("error",$);else this.emit(m);return this}static get isStream(){return T8}}var r8=p8.native,l4={lstatSync:d8,readdir:m8,readdirSync:c8,readlinkSync:l8,realpathSync:r8,promises:{lstat:n8,readdir:i8,readlink:o8,realpath:s8}},a5=($)=>!$||$===l4||$===a8?l4:{...l4,...$,promises:{...l4.promises,...$.promises||{}}},r5=/^\\\\\?\\([a-z]:)\\?$/i,e8=($)=>$.replace(/\//g,"\\").replace(r5,"$1\\"),t8=/[\\\/]/,U0=0,n5=1,i5=2,D0=4,o5=6,s5=8,V4=10,e5=12,j0=15,c4=~j0,U2=16,m5=32,p4=64,w0=128,B6=256,_6=512,c5=p4|w0|_6,$Z=1023,A2=($)=>$.isFile()?s5:$.isDirectory()?D0:$.isSymbolicLink()?V4:$.isCharacterDevice()?i5:$.isBlockDevice()?o5:$.isSocket()?e5:$.isFIFO()?n5:U0,l5=new h4({max:4096}),a4=($)=>{let Z=l5.get($);if(Z)return Z;let Q=$.normalize("NFKD");return l5.set($,Q),Q},p5=new h4({max:4096}),L6=($)=>{let Z=p5.get($);if(Z)return Z;let Q=a4($.toLowerCase());return p5.set($,Q),Q};class L2 extends h4{constructor(){super({max:256})}}class t5 extends h4{constructor($=16384){super({maxSize:$,sizeCalculation:(Z)=>Z.length+1})}}var $1=Symbol("PathScurry setAsCwd");class Z0{name;root;roots;parent;nocase;isCWD=!1;#$;#J;get dev(){return this.#J}#X;get mode(){return this.#X}#Z;get nlink(){return this.#Z}#Y;get uid(){return this.#Y}#N;get gid(){return this.#N}#_;get rdev(){return this.#_}#z;get blksize(){return this.#z}#K;get ino(){return this.#K}#G;get size(){return this.#G}#H;get blocks(){return this.#H}#q;get atimeMs(){return this.#q}#V;get mtimeMs(){return this.#V}#w;get ctimeMs(){return this.#w}#R;get birthtimeMs(){return this.#R}#U;get atime(){return this.#U}#A;get mtime(){return this.#A}#I;get ctime(){return this.#I}#B;get birthtime(){return this.#B}#C;#P;#j;#L;#F;#M;#Q;#O;#k;#S;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Z=U0,Q,J,X,V,Y){if(this.name=$,this.#C=X?L6($):a4($),this.#Q=Z&$Z,this.nocase=X,this.roots=J,this.root=Q||this,this.#O=V,this.#j=Y.fullpath,this.#F=Y.relative,this.#M=Y.relativePosix,this.parent=Y.parent,this.parent)this.#$=this.parent.#$;else this.#$=a5(Y.fs)}depth(){if(this.#P!==void 0)return this.#P;if(!this.parent)return this.#P=0;return this.#P=this.parent.depth()+1}childrenCache(){return this.#O}resolve($){if(!$)return this;let Z=this.getRootString($),J=$.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#v(J):this.#v(J)}#v($){let Z=this;for(let Q of $)Z=Z.child(Q);return Z}children(){let $=this.#O.get(this);if($)return $;let Z=Object.assign([],{provisional:0});return this.#O.set(this,Z),this.#Q&=~U2,Z}child($,Z){if($===""||$===".")return this;if($==="..")return this.parent||this;let Q=this.children(),J=this.nocase?L6($):a4($);for(let K of Q)if(K.#C===J)return K;let X=this.parent?this.sep:"",V=this.#j?this.#j+X+$:void 0,Y=this.newChild($,U0,{...Z,parent:this,fullpath:V});if(!this.canReaddir())Y.#Q|=w0;return Q.push(Y),Y}relative(){if(this.isCWD)return"";if(this.#F!==void 0)return this.#F;let $=this.name,Z=this.parent;if(!Z)return this.#F=this.name;let Q=Z.relative();return Q+(!Q||!Z.parent?"":this.sep)+$}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#M!==void 0)return this.#M;let $=this.name,Z=this.parent;if(!Z)return this.#M=this.fullpathPosix();let Q=Z.relativePosix();return Q+(!Q||!Z.parent?"":"/")+$}fullpath(){if(this.#j!==void 0)return this.#j;let $=this.name,Z=this.parent;if(!Z)return this.#j=this.name;let J=Z.fullpath()+(!Z.parent?"":this.sep)+$;return this.#j=J}fullpathPosix(){if(this.#L!==void 0)return this.#L;if(this.sep==="/")return this.#L=this.fullpath();if(!this.parent){let J=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(J))return this.#L=`//?/${J}`;else return this.#L=J}let $=this.parent,Z=$.fullpathPosix(),Q=Z+(!Z||!$.parent?"":"/")+this.name;return this.#L=Q}isUnknown(){return(this.#Q&j0)===U0}isType($){return this[`is${$}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#Q&j0)===s5}isDirectory(){return(this.#Q&j0)===D0}isCharacterDevice(){return(this.#Q&j0)===i5}isBlockDevice(){return(this.#Q&j0)===o5}isFIFO(){return(this.#Q&j0)===n5}isSocket(){return(this.#Q&j0)===e5}isSymbolicLink(){return(this.#Q&V4)===V4}lstatCached(){return this.#Q&m5?this:void 0}readlinkCached(){return this.#k}realpathCached(){return this.#S}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#k)return!0;if(!this.parent)return!1;let $=this.#Q&j0;return!($!==U0&&$!==V4||this.#Q&B6||this.#Q&w0)}calledReaddir(){return!!(this.#Q&U2)}isENOENT(){return!!(this.#Q&w0)}isNamed($){return!this.nocase?this.#C===a4($):this.#C===L6($)}async readlink(){let $=this.#k;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#$.promises.readlink(this.fullpath()),Q=(await this.parent.realpath())?.resolve(Z);if(Q)return this.#k=Q}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()),Q=this.parent.realpathSync()?.resolve(Z);if(Q)return this.#k=Q}catch(Z){this.#x(Z.code);return}}#h($){this.#Q|=U2;for(let Z=$.provisional;Z<$.length;Z++){let Q=$[Z];if(Q)Q.#D()}}#D(){if(this.#Q&w0)return;this.#Q=(this.#Q|w0)&c4,this.#l()}#l(){let $=this.children();$.provisional=0;for(let Z of $)Z.#D()}#f(){this.#Q|=_6,this.#y()}#y(){if(this.#Q&p4)return;let $=this.#Q;if(($&j0)===D0)$&=c4;this.#Q=$|p4,this.#l()}#g($=""){if($==="ENOTDIR"||$==="EPERM")this.#y();else if($==="ENOENT")this.#D();else this.children().provisional=0}#T($=""){if($==="ENOTDIR")this.parent.#y();else if($==="ENOENT")this.#D()}#x($=""){let Z=this.#Q;if(Z|=B6,$==="ENOENT")Z|=w0;if($==="EINVAL"||$==="UNKNOWN")Z&=c4;if(this.#Q=Z,$==="ENOTDIR"&&this.parent)this.parent.#y()}#u($,Z){return this.#m($,Z)||this.#d($,Z)}#d($,Z){let Q=A2($),J=this.newChild($.name,Q,{parent:this}),X=J.#Q&j0;if(X!==D0&&X!==V4&&X!==U0)J.#Q|=p4;return Z.unshift(J),Z.provisional++,J}#m($,Z){for(let Q=Z.provisional;Q<Z.length;Q++){let J=Z[Q];if((this.nocase?L6($.name):a4($.name))!==J.#C)continue;return this.#W($,J,Q,Z)}}#W($,Z,Q,J){let X=Z.name;if(Z.#Q=Z.#Q&c4|A2($),X!==$.name)Z.name=$.name;if(Q!==J.provisional){if(Q===J.length-1)J.pop();else J.splice(Q,1);J.unshift(Z)}return J.provisional++,Z}async lstat(){if((this.#Q&w0)===0)try{return this.#c(await this.#$.promises.lstat(this.fullpath())),this}catch($){this.#T($.code)}}lstatSync(){if((this.#Q&w0)===0)try{return this.#c(this.#$.lstatSync(this.fullpath())),this}catch($){this.#T($.code)}}#c($){let{atime:Z,atimeMs:Q,birthtime:J,birthtimeMs:X,blksize:V,blocks:Y,ctime:K,ctimeMs:q,dev:W,gid:z,ino:G,mode:A,mtime:B,mtimeMs:_,nlink:L,rdev:F,size:w,uid:P}=$;this.#U=Z,this.#q=Q,this.#B=J,this.#R=X,this.#z=V,this.#H=Y,this.#I=K,this.#w=q,this.#J=W,this.#N=z,this.#K=G,this.#X=A,this.#A=B,this.#V=_,this.#Z=L,this.#_=F,this.#G=w,this.#Y=P;let M=A2($);if(this.#Q=this.#Q&c4|M|m5,M!==U0&&M!==D0&&M!==V4)this.#Q|=p4}#b=[];#E=!1;#p($){this.#E=!1;let Z=this.#b.slice();this.#b.length=0,Z.forEach((Q)=>Q(null,$))}readdirCB($,Z=!1){if(!this.canReaddir()){if(Z)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let Q=this.children();if(this.calledReaddir()){let X=Q.slice(0,Q.provisional);if(Z)$(null,X);else queueMicrotask(()=>$(null,X));return}if(this.#b.push($),this.#E)return;this.#E=!0;let J=this.fullpath();this.#$.readdir(J,{withFileTypes:!0},(X,V)=>{if(X)this.#g(X.code),Q.provisional=0;else{for(let Y of V)this.#u(Y,Q);this.#h(Q)}this.#p(Q.slice(0,Q.provisional));return})}#a;async readdir(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Z=this.fullpath();if(this.#a)await this.#a;else{let Q=()=>{};this.#a=new Promise((J)=>Q=J);try{for(let J of await this.#$.promises.readdir(Z,{withFileTypes:!0}))this.#u(J,$);this.#h($)}catch(J){this.#g(J.code),$.provisional=0}this.#a=void 0,Q()}return $.slice(0,$.provisional)}readdirSync(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Z=this.fullpath();try{for(let Q of this.#$.readdirSync(Z,{withFileTypes:!0}))this.#u(Q,$);this.#h($)}catch(Q){this.#g(Q.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#Q&c5)return!1;let $=j0&this.#Q;if(!($===U0||$===D0||$===V4))return!1;return!0}shouldWalk($,Z){return(this.#Q&D0)===D0&&!(this.#Q&c5)&&!$.has(this)&&(!Z||Z(this))}async realpath(){if(this.#S)return this.#S;if((_6|B6|w0)&this.#Q)return;try{let $=await this.#$.promises.realpath(this.fullpath());return this.#S=this.resolve($)}catch($){this.#f()}}realpathSync(){if(this.#S)return this.#S;if((_6|B6|w0)&this.#Q)return;try{let $=this.#$.realpathSync(this.fullpath());return this.#S=this.resolve($)}catch($){this.#f()}}[$1]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Z=new Set([]),Q=[],J=this;while(J&&J.parent)Z.add(J),J.#F=Q.join(this.sep),J.#M=Q.join("/"),J=J.parent,Q.push("..");J=$;while(J&&J.parent&&!Z.has(J))J.#F=void 0,J.#M=void 0,J=J.parent}}class w6 extends Z0{sep="\\";splitSep=t8;constructor($,Z=U0,Q,J,X,V,Y){super($,Z,Q,J,X,V,Y)}newChild($,Z=U0,Q={}){return new w6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),Q)}getRootString($){return B2.parse($).root}getRoot($){if($=e8($.toUpperCase()),$===this.root.name)return this.root;for(let[Z,Q]of Object.entries(this.roots))if(this.sameRoot($,Z))return this.roots[$]=Q;return this.roots[$]=new r4($,this).root}sameRoot($,Z=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(r5,"$1\\"),$===Z}}class F6 extends Z0{splitSep="/";sep="/";constructor($,Z=U0,Q,J,X,V,Y){super($,Z,Q,J,X,V,Y)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Z=U0,Q={}){return new F6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),Q)}}class _2{root;rootPath;roots;cwd;#$;#J;#X;nocase;#Z;constructor($=process.cwd(),Z,Q,{nocase:J,childrenCacheSize:X=16384,fs:V=l4}={}){if(this.#Z=a5(V),$ instanceof URL||$.startsWith("file://"))$=u8($);let Y=Z.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(Y),this.#$=new L2,this.#J=new L2,this.#X=new t5(X);let K=Y.substring(this.rootPath.length).split(Q);if(K.length===1&&!K[0])K.pop();if(J===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=J,this.root=this.newRoot(this.#Z),this.roots[this.rootPath]=this.root;let q=this.root,W=K.length-1,z=Z.sep,G=this.rootPath,A=!1;for(let B of K){let _=W--;q=q.child(B,{relative:Array(_).fill("..").join(z),relativePosix:Array(_).fill("..").join("/"),fullpath:G+=(A?"":z)+B}),A=!0}this.cwd=q}depth($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.depth()}childrenCache(){return this.#X}resolve(...$){let Z="";for(let X=$.length-1;X>=0;X--){let V=$[X];if(!V||V===".")continue;if(Z=Z?`${V}/${Z}`:V,this.isAbsolute(V))break}let Q=this.#$.get(Z);if(Q!==void 0)return Q;let J=this.cwd.resolve(Z).fullpath();return this.#$.set(Z,J),J}resolvePosix(...$){let Z="";for(let X=$.length-1;X>=0;X--){let V=$[X];if(!V||V===".")continue;if(Z=Z?`${V}/${Z}`:V,this.isAbsolute(V))break}let Q=this.#J.get(Z);if(Q!==void 0)return Q;let J=this.cwd.resolve(Z).fullpathPosix();return this.#J.set(Z,J),J}relative($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relative()}relativePosix($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relativePosix()}basename($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.name}dirname($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return($.parent||$).fullpath()}async readdir($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:Q}=Z;if(!$.canReaddir())return[];else{let J=await $.readdir();return Q?J:J.map((X)=>X.name)}}readdirSync($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:Q=!0}=Z;if(!$.canReaddir())return[];else if(Q)return $.readdirSync();else return $.readdirSync().map((J)=>J.name)}async lstat($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstat()}lstatSync($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstatSync()}async readlink($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$.withFileTypes,$=this.cwd;let Q=await $.readlink();return Z?Q:Q?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$.withFileTypes,$=this.cwd;let Q=$.readlinkSync();return Z?Q:Q?.fullpath()}async realpath($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$.withFileTypes,$=this.cwd;let Q=await $.realpath();return Z?Q:Q?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$.withFileTypes,$=this.cwd;let Q=$.realpathSync();return Z?Q:Q?.fullpath()}async walk($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,Y=[];if(!X||X($))Y.push(Q?$:$.fullpath());let K=new Set,q=(z,G)=>{K.add(z),z.readdirCB((A,B)=>{if(A)return G(A);let _=B.length;if(!_)return G();let L=()=>{if(--_===0)G()};for(let F of B){if(!X||X(F))Y.push(Q?F:F.fullpath());if(J&&F.isSymbolicLink())F.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(K,V)?q(w,L):L());else if(F.shouldWalk(K,V))q(F,L);else L()}},!0)},W=$;return new Promise((z,G)=>{q(W,(A)=>{if(A)return G(A);z(Y)})})}walkSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,Y=[];if(!X||X($))Y.push(Q?$:$.fullpath());let K=new Set([$]);for(let q of K){let W=q.readdirSync();for(let z of W){if(!X||X(z))Y.push(Q?z:z.fullpath());let G=z;if(z.isSymbolicLink()){if(!(J&&(G=z.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(K,V))K.add(G)}}return Y}[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:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z;if(!X||X($))yield Q?$:$.fullpath();let Y=new Set([$]);for(let K of Y){let q=K.readdirSync();for(let W of q){if(!X||X(W))yield Q?W:W.fullpath();let z=W;if(W.isSymbolicLink()){if(!(J&&(z=W.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(Y,V))Y.add(z)}}}stream($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,Y=new X4({objectMode:!0});if(!X||X($))Y.write(Q?$:$.fullpath());let K=new Set,q=[$],W=0,z=()=>{let G=!1;while(!G){let A=q.shift();if(!A){if(W===0)Y.end();return}W++,K.add(A);let B=(L,F,w=!1)=>{if(L)return Y.emit("error",L);if(J&&!w){let P=[];for(let M of F)if(M.isSymbolicLink())P.push(M.realpath().then((E)=>E?.isUnknown()?E.lstat():E));if(P.length){Promise.all(P).then(()=>B(null,F,!0));return}}for(let P of F)if(P&&(!X||X(P))){if(!Y.write(Q?P:P.fullpath()))G=!0}W--;for(let P of F){let M=P.realpathCached()||P;if(M.shouldWalk(K,V))q.push(M)}if(G&&!Y.flowing)Y.once("drain",z);else if(!_)z()},_=!0;A.readdirCB(B,!0),_=!1}};return z(),Y}streamSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Z0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,Y=new X4({objectMode:!0}),K=new Set;if(!X||X($))Y.write(Q?$:$.fullpath());let q=[$],W=0,z=()=>{let G=!1;while(!G){let A=q.shift();if(!A){if(W===0)Y.end();return}W++,K.add(A);let B=A.readdirSync();for(let _ of B)if(!X||X(_)){if(!Y.write(Q?_:_.fullpath()))G=!0}W--;for(let _ of B){let L=_;if(_.isSymbolicLink()){if(!(J&&(L=_.realpathSync())))continue;if(L.isUnknown())L.lstatSync()}if(L.shouldWalk(K,V))q.push(L)}}if(G&&!Y.flowing)Y.once("drain",z)};return z(),Y}chdir($=this.cwd){let Z=this.cwd;this.cwd=typeof $==="string"?this.cwd.resolve($):$,this.cwd[$1](Z)}}class r4 extends _2{sep="\\";constructor($=process.cwd(),Z={}){let{nocase:Q=!0}=Z;super($,B2,"\\",{...Z,nocase:Q});this.nocase=Q;for(let J=this.cwd;J;J=J.parent)J.nocase=this.nocase}parseRootPath($){return B2.parse($).root.toUpperCase()}newRoot($){return new w6(this.rootPath,D0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class n4 extends _2{sep="/";constructor($=process.cwd(),Z={}){let{nocase:Q=!1}=Z;super($,g8,"/",{...Z,nocase:Q});this.nocase=Q}parseRootPath($){return"/"}newRoot($){return new F6(this.rootPath,D0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class R6 extends n4{constructor($=process.cwd(),Z={}){let{nocase:Q=!0}=Z;super($,{...Z,nocase:Q})}}var bY=process.platform==="win32"?w6:F6,Z1=process.platform==="win32"?r4:process.platform==="darwin"?R6:n4;var ZZ=($)=>$.length>=1,QZ=($)=>$.length>=1;class L4{#$;#J;#X;length;#Z;#Y;#N;#_;#z;#K;#G=!0;constructor($,Z,Q,J){if(!ZZ($))throw TypeError("empty pattern list");if(!QZ(Z))throw TypeError("empty glob list");if(Z.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,Q<0||Q>=this.length)throw TypeError("index out of range");if(this.#$=$,this.#J=Z,this.#X=Q,this.#Z=J,this.#X===0){if(this.isUNC()){let[X,V,Y,K,...q]=this.#$,[W,z,G,A,...B]=this.#J;if(q[0]==="")q.shift(),B.shift();let _=[X,V,Y,K,""].join("/"),L=[W,z,G,A,""].join("/");this.#$=[_,...q],this.#J=[L,...B],this.length=this.#$.length}else if(this.isDrive()||this.isAbsolute()){let[X,...V]=this.#$,[Y,...K]=this.#J;if(V[0]==="")V.shift(),K.shift();let q=X+"/",W=Y+"/";this.#$=[q,...V],this.#J=[W,...K],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.#N=this.#N||(this.#X===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#X).join("/"))}hasMore(){return this.length>this.#X+1}rest(){if(this.#Y!==void 0)return this.#Y;if(!this.hasMore())return this.#Y=null;return this.#Y=new L4(this.#$,this.#J,this.#X+1,this.#Z),this.#Y.#K=this.#K,this.#Y.#z=this.#z,this.#Y.#_=this.#_,this.#Y}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.#K!==void 0?this.#K:this.#K=$[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 JZ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class i4{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Z,nocase:Q,noext:J,noglobstar:X,platform:V=JZ}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=V,this.mmopts={dot:!0,nobrace:Z,nocase:Q,noext:J,noglobstar:X,optimizationLevel:2,platform:V,nocomment:!0,nonegate:!0};for(let Y of $)this.add(Y)}add($){let Z=new G0($,this.mmopts);for(let Q=0;Q<Z.set.length;Q++){let J=Z.set[Q],X=Z.globParts[Q];if(!J||!X)throw Error("invalid pattern object");while(J[0]==="."&&X[0]===".")J.shift(),X.shift();let V=new L4(J,X,0,this.platform),Y=new G0(V.globString(),this.mmopts),K=X[X.length-1]==="**",q=V.isAbsolute();if(q)this.absolute.push(Y);else this.relative.push(Y);if(K)if(q)this.absoluteChildren.push(Y);else this.relativeChildren.push(Y)}}ignored($){let Z=$.fullpath(),Q=`${Z}/`,J=$.relative()||".",X=`${J}/`;for(let V of this.relative)if(V.match(J)||V.match(X))return!0;for(let V of this.absolute)if(V.match(Z)||V.match(Q))return!0;return!1}childrenIgnored($){let Z=$.fullpath()+"/",Q=($.relative()||".")+"/";for(let J of this.relativeChildren)if(J.match(Q))return!0;for(let J of this.absoluteChildren)if(J.match(Z))return!0;return!1}}class w2{store;constructor($=new Map){this.store=$}copy(){return new w2(new Map(this.store))}hasWalked($,Z){return this.store.get($.fullpath())?.has(Z.globString())}storeWalked($,Z){let Q=$.fullpath(),J=this.store.get(Q);if(J)J.add(Z.globString());else this.store.set(Q,new Set([Z.globString()]))}}class Q1{store=new Map;add($,Z,Q){let J=(Z?2:0)|(Q?1:0),X=this.store.get($);this.store.set($,X===void 0?J:J&X)}entries(){return[...this.store.entries()].map(([$,Z])=>[$,!!(Z&2),!!(Z&1)])}}class J1{store=new Map;add($,Z){if(!$.canReaddir())return;let Q=this.store.get($);if(Q){if(!Q.find((J)=>J.globString()===Z.globString()))Q.push(Z)}else this.store.set($,[Z])}get($){let Z=this.store.get($);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map(($)=>[$,this.store.get($)])}keys(){return[...this.store.keys()].filter(($)=>$.canReaddir())}}class o4{hasWalkedCache;matches=new Q1;subwalks=new J1;patterns;follow;dot;opts;constructor($,Z){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Z?Z.copy():new w2}processPatterns($,Z){this.patterns=Z;let Q=Z.map((J)=>[$,J]);for(let[J,X]of Q){this.hasWalkedCache.storeWalked(J,X);let V=X.root(),Y=X.isAbsolute()&&this.opts.absolute!==!1;if(V){J=J.resolve(V==="/"&&this.opts.root!==void 0?this.opts.root:V);let z=X.rest();if(!z){this.matches.add(J,!0,!1);continue}else X=z}if(J.isENOENT())continue;let K,q,W=!1;while(typeof(K=X.pattern())==="string"&&(q=X.rest()))J=J.resolve(K),X=q,W=!0;if(K=X.pattern(),q=X.rest(),W){if(this.hasWalkedCache.hasWalked(J,X))continue;this.hasWalkedCache.storeWalked(J,X)}if(typeof K==="string"){let z=K===".."||K===""||K===".";this.matches.add(J.resolve(K),Y,z);continue}else if(K===d){if(!J.isSymbolicLink()||this.follow||X.checkFollowGlobstar())this.subwalks.add(J,X);let z=q?.pattern(),G=q?.rest();if(!q||(z===""||z===".")&&!G)this.matches.add(J,Y,z===""||z===".");else if(z===".."){let A=J.parent||J;if(!G)this.matches.add(A,Y,!0);else if(!this.hasWalkedCache.hasWalked(A,G))this.subwalks.add(A,G)}}else if(K instanceof RegExp)this.subwalks.add(J,X)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new o4(this.opts,this.hasWalkedCache)}filterEntries($,Z){let Q=this.subwalks.get($),J=this.child();for(let X of Z)for(let V of Q){let Y=V.isAbsolute(),K=V.pattern(),q=V.rest();if(K===d)J.testGlobstar(X,V,q,Y);else if(K instanceof RegExp)J.testRegExp(X,K,q,Y);else J.testString(X,K,q,Y)}return J}testGlobstar($,Z,Q,J){if(this.dot||!$.name.startsWith(".")){if(!Z.hasMore())this.matches.add($,J,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Z);else if($.isSymbolicLink()){if(Q&&Z.checkFollowGlobstar())this.subwalks.add($,Q);else if(Z.markFollowGlobstar())this.subwalks.add($,Z)}}}if(Q){let X=Q.pattern();if(typeof X==="string"&&X!==".."&&X!==""&&X!==".")this.testString($,X,Q.rest(),J);else if(X===".."){let V=$.parent||$;this.subwalks.add(V,Q)}else if(X instanceof RegExp)this.testRegExp($,X,Q.rest(),J)}}testRegExp($,Z,Q,J){if(!Z.test($.name))return;if(!Q)this.matches.add($,J,!1);else this.subwalks.add($,Q)}testString($,Z,Q,J){if(!$.isNamed(Z))return;if(!Q)this.matches.add($,J,!1);else this.subwalks.add($,Q)}}var XZ=($,Z)=>typeof $==="string"?new i4([$],Z):Array.isArray($)?new i4($,Z):$;class F2{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#$=[];#J;#X;signal;maxDepth;includeChildMatches;constructor($,Z,Q){if(this.patterns=$,this.path=Z,this.opts=Q,this.#X=!Q.posix&&Q.platform==="win32"?"\\":"/",this.includeChildMatches=Q.includeChildMatches!==!1,Q.ignore||!this.includeChildMatches){if(this.#J=XZ(Q.ignore??[],Q),!this.includeChildMatches&&typeof this.#J.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=Q.maxDepth||1/0,Q.signal)this.signal=Q.signal,this.signal.addEventListener("abort",()=>{this.#$.length=0})}#Z($){return this.seen.has($)||!!this.#J?.ignored?.($)}#Y($){return!!this.#J?.childrenIgnored?.($)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let $=void 0;while(!this.paused&&($=this.#$.shift()))$()}onResume($){if(this.signal?.aborted)return;if(!this.paused)$();else this.#$.push($)}async matchCheck($,Z){if(Z&&this.opts.nodir)return;let Q;if(this.opts.realpath){if(Q=$.realpathCached()||await $.realpath(),!Q)return;$=Q}let X=$.isUnknown()||this.opts.stat?await $.lstat():$;if(this.opts.follow&&this.opts.nodir&&X?.isSymbolicLink()){let V=await X.realpath();if(V&&(V.isUnknown()||this.opts.stat))await V.lstat()}return this.matchCheckTest(X,Z)}matchCheckTest($,Z){return $&&(this.maxDepth===1/0||$.depth()<=this.maxDepth)&&(!Z||$.canReaddir())&&(!this.opts.nodir||!$.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!$.isSymbolicLink()||!$.realpathCached()?.isDirectory())&&!this.#Z($)?$:void 0}matchCheckSync($,Z){if(Z&&this.opts.nodir)return;let Q;if(this.opts.realpath){if(Q=$.realpathCached()||$.realpathSync(),!Q)return;$=Q}let X=$.isUnknown()||this.opts.stat?$.lstatSync():$;if(this.opts.follow&&this.opts.nodir&&X?.isSymbolicLink()){let V=X.realpathSync();if(V&&(V?.isUnknown()||this.opts.stat))V.lstatSync()}return this.matchCheckTest(X,Z)}matchFinish($,Z){if(this.#Z($))return;if(!this.includeChildMatches&&this.#J?.add){let X=`${$.relativePosix()}/**`;this.#J.add(X)}let Q=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add($);let J=this.opts.mark&&$.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit($);else if(Q){let X=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(X+J)}else{let X=this.opts.posix?$.relativePosix():$.relative(),V=this.opts.dotRelative&&!X.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!X?"."+J:V+X+J)}}async match($,Z,Q){let J=await this.matchCheck($,Q);if(J)this.matchFinish(J,Z)}matchSync($,Z,Q){let J=this.matchCheckSync($,Q);if(J)this.matchFinish(J,Z)}walkCB($,Z,Q){if(this.signal?.aborted)Q();this.walkCB2($,Z,new o4(this.opts),Q)}walkCB2($,Z,Q,J){if(this.#Y($))return J();if(this.signal?.aborted)J();if(this.paused){this.onResume(()=>this.walkCB2($,Z,Q,J));return}Q.processPatterns($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[Y,K,q]of Q.matches.entries()){if(this.#Z(Y))continue;X++,this.match(Y,K,q).then(()=>V())}for(let Y of Q.subwalkTargets()){if(this.maxDepth!==1/0&&Y.depth()>=this.maxDepth)continue;X++;let K=Y.readdirCached();if(Y.calledReaddir())this.walkCB3(Y,K,Q,V);else Y.readdirCB((q,W)=>this.walkCB3(Y,W,Q,V),!0)}V()}walkCB3($,Z,Q,J){Q=Q.filterEntries($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[Y,K,q]of Q.matches.entries()){if(this.#Z(Y))continue;X++,this.match(Y,K,q).then(()=>V())}for(let[Y,K]of Q.subwalks.entries())X++,this.walkCB2(Y,K,Q.child(),V);V()}walkCBSync($,Z,Q){if(this.signal?.aborted)Q();this.walkCB2Sync($,Z,new o4(this.opts),Q)}walkCB2Sync($,Z,Q,J){if(this.#Y($))return J();if(this.signal?.aborted)J();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Z,Q,J));return}Q.processPatterns($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[Y,K,q]of Q.matches.entries()){if(this.#Z(Y))continue;this.matchSync(Y,K,q)}for(let Y of Q.subwalkTargets()){if(this.maxDepth!==1/0&&Y.depth()>=this.maxDepth)continue;X++;let K=Y.readdirSync();this.walkCB3Sync(Y,K,Q,V)}V()}walkCB3Sync($,Z,Q,J){Q=Q.filterEntries($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[Y,K,q]of Q.matches.entries()){if(this.#Z(Y))continue;this.matchSync(Y,K,q)}for(let[Y,K]of Q.subwalks.entries())X++,this.walkCB2Sync(Y,K,Q.child(),V);V()}}class C6 extends F2{matches=new Set;constructor($,Z,Q){super($,Z,Q)}matchEmit($){this.matches.add($)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise(($,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else $(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class N6 extends F2{results;constructor($,Z,Q){super($,Z,Q);this.results=new X4({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 YZ=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=VZ(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((K)=>K.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");$=$.map((K)=>K.includes("/")?K:`./**/${K}`)}if(this.pattern=$,this.platform=Z.platform||YZ,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 K=Z.platform==="win32"?r4:Z.platform==="darwin"?R6:Z.platform?n4:Z1;this.scurry=new K(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let Q=this.platform==="darwin"||this.platform==="win32",J={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:Q,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},X=this.pattern.map((K)=>new G0(K,J)),[V,Y]=X.reduce((K,q)=>{return K[0].push(...q.set),K[1].push(...q.globParts),K},[[],[]]);this.patterns=V.map((K,q)=>{let W=Y[q];if(!W)throw Error("invalid pattern object");return new L4(K,W,0,this.platform)})}async walk(){return[...await new C6(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 C6(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 N6(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 N6(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 R2=($,Z={})=>{if(!Array.isArray($))$=[$];for(let Q of $)if(new G0(Q,Z).hasMagic())return!0;return!1};function D6($,Z={}){return new I0($,Z).streamSync()}function V1($,Z={}){return new I0($,Z).stream()}function Y1($,Z={}){return new I0($,Z).walkSync()}async function X1($,Z={}){return new I0($,Z).walk()}function I6($,Z={}){return new I0($,Z).iterateSync()}function K1($,Z={}){return new I0($,Z).iterate()}var KZ=D6,qZ=Object.assign(V1,{sync:D6}),WZ=I6,HZ=Object.assign(K1,{sync:I6}),zZ=Object.assign(Y1,{stream:D6,iterate:I6}),P6=Object.assign(X1,{glob:X1,globSync:Y1,sync:zZ,globStream:V1,stream:qZ,globStreamSync:D6,streamSync:KZ,globIterate:K1,iterate:HZ,globIterateSync:I6,iterateSync:WZ,Glob:I0,hasMagic:R2,escape:U4,unescape:L0});P6.glob=P6;var $4=e2(I9(),1),MX=new Set(["png","jpg","jpeg","gif","webp"]),SX=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"]),EX=25000,TX=5242880,M9=3932160,S9=400,xX=20,kX=[{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 vX($){if($.length<4)return null;for(let{signature:Z,mimeType:Q}of kX){let J=!0;for(let X=0;X<Z.length;X++)if($[X]!==Z[X]){J=!1;break}if(J){if(Q==="image/webp"){if($.length>=12&&$[8]===87&&$[9]===69&&$[10]===66&&$[11]===80)return"image/webp";continue}return Q}}return null}async function E9($,Z=EX,Q){let J=Bun.file($),X=Buffer.from(await J.arrayBuffer());if(X.length===0)throw Error(`Image file is empty: ${$}`);if(X.length>TX)throw Error(`Image file too large: ${$} (${(X.length/1024/1024).toFixed(2)}MB > 5MB limit)`);if(!vX(X))throw Error(`Unsupported image format: ${$}`);let Y=$4.default(X),K=await Y.metadata(),q={originalWidth:K.width,originalHeight:K.height},W=(K.width||0)*(K.height||0);if(W>M9){let L=Math.sqrt(M9/W),F=Math.round((K.width||1)*L),w=Math.round((K.height||1)*L);Y=$4.default(X).resize(F,w,{fit:"inside",withoutEnlargement:!0})}let z=K.format||"jpeg",G;if(z==="png")G=await Y.png().toBuffer();else if(z==="webp")G=await Y.webp().toBuffer();else if(z==="gif")G=await Y.gif().toBuffer();else G=await Y.jpeg({quality:85}).toBuffer(),z="jpeg";let A=G.toString("base64");if(Math.ceil(A.length*0.125)>Z)try{let L=await OX(X,Z),F=L.toString("base64"),w=await $4.default(L).metadata();return{type:"image",base64:F,mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:K.width,originalHeight:K.height,displayWidth:w.width,displayHeight:w.height}}}catch(L){let F=await $4.default(X).resize(S9,S9,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:xX}).toBuffer(),w=await $4.default(F).metadata();return{type:"image",base64:F.toString("base64"),mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:K.width,originalHeight:K.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:K.width,originalHeight:K.height,displayWidth:K.width,displayHeight:K.height}}}async function OX($,Z){let Q=Math.floor(Z*0.8/0.125),J=Math.floor(Q*0.75),V=await $4.default($).metadata(),Y=$.length;if(Y<=J)return $;let K=Math.sqrt(J/Y),q=Math.round((V.width||1)*K),W=Math.round((V.height||1)*K);return $4.default($).resize(q,W,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:70}).toBuffer()}function T9($){let Z=$.toLowerCase().replace(/^\./,"");return MX.has(Z)}function x9($){let Z=$.toLowerCase().replace(/^\./,"");return SX.has(Z)}function k9($){return{type:"image",source:{type:"base64",data:$.base64,media_type:$.mediaType}}}function v9($){let Z=$.dimensions,Q=Z?.originalWidth&&Z?.originalHeight?` (${Z.originalWidth}x${Z.originalHeight}${Z.displayWidth!==Z.originalWidth?` \u2192 ${Z.displayWidth}x${Z.displayHeight}`:""})`:"";return`[Image: ${$.mediaType}${Q}, ${($.originalSize/1024).toFixed(1)}KB original]`}import*as O9 from"path";var yX={name:"Read",description:`Reads a file from the local filesystem. You can access any file directly by using this tool.
94
-
95
- Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid.
96
-
97
- This tool allows Claude Code to read images (PNG, JPG, JPEG, GIF, WEBP) and PDF files.
98
-
99
- Usage:
100
- - The file_path parameter must be an absolute path, not a relative path
101
- - By default, reads up to 2000 lines starting from the beginning of the file
102
- - You can optionally specify line offset and limit (especially handy for long files)
103
- - Any lines longer than 2000 characters will be truncated
104
- - Results are returned using cat -n format, with line numbers starting at 1
105
-
106
- This tool can read images (PNG, JPG, JPEG, GIF, WEBP). When reading images, the tool displays them visually.
107
-
108
- For PDF files:
109
- - Get the pages parameter to read specific page ranges (e.g., pages: "1-5")
110
- - Maximum 20 pages per request
111
- - For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific page ranges.
112
-
113
- Try to read the whole file by default, but for particularly large files, you should consider reading the file in chunks.
114
-
115
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`,input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to read"},offset:{type:"number",description:"The line number to start reading from (1-based)"},limit:{type:"number",description:"The number of lines to read"},pages:{type:"string",description:'Page range for PDF files (e.g., "1-5")'}},required:["file_path"]},handler:async($,Z)=>{let Q=$.file_path,J=$.offset||1,X=$.limit||2000;try{let V=O9.extname(Q).toLowerCase().slice(1);if(T9(V))return await bX(Q,Z.abortSignal);if(x9(V))return{content:`Binary file detected: ${Q}
116
- This file type (${V}) is not supported for text reading.`,is_error:!0};let Y=Bun.file(Q);if(!await Y.exists())return{content:`Error: File not found: ${Q}`,is_error:!0};let q=(await Y.text()).split(`
117
- `),W=Math.max(0,J-1),z=Math.min(q.length,W+X),G=q.slice(W,z),A=z<q.length,_=G.map((L,F)=>`${W+F+1} ${L}`).join(`
118
- `);if(A)_+=`
119
-
120
- > WARNING: ${Q} is ${q.length} lines (limit: ${X}). Only the first ${X} lines were loaded.`;return{content:_}}catch(V){return{content:`Error reading file: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}};async function bX($,Z){try{let Q=await E9($,25000,Z),J=k9(Q);return{content:[{type:"text",text:v9(Q)},J]}}catch(Q){return{content:`Error reading image: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}var fX={name:"Write",description:"Writes a file to the local filesystem. This tool will overwrite the existing file if there is one at the provided path.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to write"},content:{type:"string",description:"The content to write to the file"}},required:["file_path","content"]},handler:async($,Z)=>{let{file_path:Q,content:J}=$;try{return await Bun.write(Q,J),{content:`Successfully wrote to ${Q}`}}catch(X){return{content:`Error writing file: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},hX={name:"Edit",description:"Performs exact string replacements in files. Use this tool to modify existing files.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to modify"},old_string:{type:"string",description:"The text to replace"},new_string:{type:"string",description:"The text to replace it with"},replace_all:{type:"boolean",description:"Replace all occurrences (default false)"}},required:["file_path","old_string","new_string"]},handler:async($,Z)=>{let{file_path:Q,old_string:J,new_string:X}=$,V=$.replace_all||!1;try{let K=await Bun.file(Q).text();if(V){let q=K;K=K.split(J).join(X);let W=(q.match(new RegExp(gX(J),"g"))||[]).length;if(W===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write(Q,K),{content:`Successfully replaced ${W} occurrences`}}else{let q=K.indexOf(J);if(q===-1)return{content:"Error: String not found in file",is_error:!0};if(K.indexOf(J,q+1)!==-1)return{content:"Error: String appears multiple times in file. Use replace_all or provide more context.",is_error:!0};return K=K.replace(J,X),await Bun.write(Q,K),{content:`Successfully edited ${Q}`}}}catch(Y){return{content:`Error editing file: ${Y instanceof Error?Y.message:String(Y)}`,is_error:!0}}}};function gX($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var uX={name:"Bash",description:"Executes a given bash command with optional timeout. Working directory persists between commands.",input_schema:{type:"object",properties:{command:{type:"string",description:"The command to execute"},timeout:{type:"number",description:"Optional timeout in milliseconds (max 600000)"},description:{type:"string",description:"Clear, concise description of what this command does"}},required:["command"]},handler:async($,Z)=>{let Q=$.command,J=$.timeout||120000;try{let X=Bun.spawnSync(["sh","-c",Q],{cwd:Z.workingDirectory,timeout:J,maxBuffer:31457280}),V=X.stdout?.toString()||"",Y=X.stderr?.toString()||"";if(X.exitCode!==0)return{content:`Exit code: ${X.exitCode}
121
- ${V}
122
- ${Y}`.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}}}},dX={name:"Glob",description:"Fast file pattern matching tool that works with any codebase size. Supports glob patterns.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The glob pattern to match files"},path:{type:"string",description:"The directory to search (default: current directory)"}},required:["pattern"]},handler:async($,Z)=>{let Q=$.pattern,J=$.path||Z.workingDirectory;try{let X=await P6(Q,{cwd:J,absolute:!0,nodir:!0});if(X.length===0)return{content:"No files found matching pattern"};return{content:X.sort().join(`
123
- `)}}catch(X){return{content:`Error searching files: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},mX={name:"Grep",description:"A powerful search tool built on ripgrep. Supports full regex syntax.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The regular expression pattern to search for"},path:{type:"string",description:"File or directory to search"},glob:{type:"string",description:"Glob pattern to filter files"},output_mode:{type:"string",enum:["content","files_with_matches","count"],description:"Output mode (default: content)"},"-i:":{type:"boolean",description:"Case insensitive search"},"-C:":{type:"number",description:"Context lines around match"},head_limit:{type:"number",description:"Maximum number of results"}},required:["pattern"]},handler:async($,Z)=>{let Q=$.pattern,J=$.path||Z.workingDirectory,X=$.glob,V=$.output_mode||"content",Y=$["-i:"],K=$["-C:"],q=$.head_limit;try{let W=["--json"];if(Y)W.push("-i");if(K)W.push("-C",String(K));if(X)W.push("--glob",X);if(V==="files_with_matches")W.push("--files-with-matches");if(V==="count")W.push("--count");W.push(Q,J);let G=Bun.spawnSync(["rg",...W],{cwd:Z.workingDirectory,maxBuffer:10485760}).stdout?.toString()||"";if(!G.trim())return{content:"No matches found"};if(V==="content"){let A=G.trim().split(`
124
- `),B=[];for(let _ of A.slice(0,q||100))try{let L=JSON.parse(_);if(L.type==="match"){let F=L.data?.path?.text||"",w=L.data?.line_number||0,P=L.data?.lines?.text||"";B.push(`${F}:${w}:${P.trim()}`)}}catch{B.push(_)}return{content:B.join(`
125
- `)||"No matches found"}}return{content:G.trim()}}catch(W){return{content:`Error searching: ${W instanceof Error?W.message:String(W)}`,is_error:!0}}}},cX={name:"Task",description:`Launch a new agent to handle complex, multi-step tasks autonomously.
126
-
127
- The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
128
-
129
- Available agent types and their tools:
130
- - Bash: Command execution specialist for running bash commands. Use for git operations, command execution, and other terminal tasks.
131
- - general-purpose: General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks.
132
- - Explore: Fast agent specialized for exploring codebases. Use to quickly find files by patterns, search code for keywords, or answer questions about the codebase.
133
- - Plan: Software architect agent for designing implementation plans. Returns step-by-step plans, identifies critical files and considers architectural trade-offs.
134
-
135
- When using the Task tool, you must specify a subagent_type parameter to select the agent type.
136
-
137
- Usage notes:
138
- - Always include a short description (3-5 words) summarizing what the agent will do
139
- - Launch multiple agents concurrently whenever possible to maximize performance
140
- - Agents can be resumed using the "resume" parameter by passing the agent ID from a previous invocation.`,input_schema:{type:"object",properties:{subagent_type:{type:"string",enum:["Bash","general-purpose","Explore","Plan"],description:"The agent type to launch"},description:{type:"string",description:"A short (3-5 word) description of what the agent will do"},prompt:{type:"string",description:"The task for the agent to perform"},resume:{type:"string",description:"Resume a previous agent by its ID"},model:{type:"string",enum:["sonnet","opus","haiku"],description:"Model for the subagent (default: haiku for quick tasks)"},run_in_background:{type:"boolean",description:"Run the agent in the background"}},required:["subagent_type","prompt"]},handler:async($,Z)=>{let{subagent_type:Q,prompt:J,description:X}=$,V=$.model||"haiku",Y=$.resume,K=$.run_in_background,q=Y||`${Q.toLowerCase()}-${Date.now().toString(36)}`;try{let W=process.env.ANTHROPIC_API_KEY||process.env.CLAUDE_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN||process.env.Z_AI_API_KEY||"";if(!W)return{content:"Error: No API key available for subagent. Set ANTHROPIC_API_KEY, CLAUDE_API_KEY, ANTHROPIC_AUTH_TOKEN, or Z_AI_API_KEY environment variable.",is_error:!0};let z={haiku:"claude-haiku-4-5",sonnet:"claude-sonnet-4-6",opus:"claude-opus-4-6"},G=z[V]||z.haiku,A=[import.meta.dir+"/../../dist/cli.js",import.meta.dir+"/../cli.ts",process.cwd()+"/dist/cli.js",process.cwd()+"/src/cli.ts"],B=null;for(let P of A)try{if(await Bun.file(P).exists()){B=P;break}}catch{}if(!B)return{content:`Error: Could not find CLI. Tried:
141
- ${A.join(`
142
- `)}`,is_error:!0};let _=["run",B,"-m",G,"-p",Z.permissionMode,"-q",J];if(K)return Bun.spawn(["bun",..._],{cwd:Z.workingDirectory,detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,ANTHROPIC_API_KEY:W}}).unref(),{content:JSON.stringify({agentId:q,status:"running",message:`Agent started in background. Use TaskOutput tool with task_id: "${q}" to check results.`,description:X||"Background task"})};let L=Bun.spawnSync(["bun",..._],{cwd:Z.workingDirectory,timeout:300000,maxBuffer:10485760,env:{...process.env,ANTHROPIC_API_KEY:W}}),F=L.stdout?.toString()||"",w=L.stderr?.toString()||"";if(L.exitCode!==0)return{content:`Agent failed with exit code ${L.exitCode}
143
- ${w}
144
- ${F}`.trim(),is_error:!0};return{content:JSON.stringify({agentId:q,status:"completed",output:F,description:X||"Task completed"})}}catch(W){return{content:`Error running subagent: ${W instanceof Error?W.message:String(W)}`,is_error:!0}}}},lX={name:"TaskOutput",description:`Retrieves output from a running or completed task (background shell, agent, or remote session).
145
-
146
- Takes a task_id parameter identifying the task.
147
- Returns the task output along with status information.
148
- Use block=true (default) to wait for task completion.
149
- Use block=false for non-blocking check of current status.
150
-
151
- Task IDs can be found using the /tasks command
152
- Works with all task types: background shells, async agents, and remote sessions`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The task ID to get output from"},block:{type:"boolean",description:"Whether to wait for completion (default: true)",default:!0},timeout:{type:"number",description:"Max wait time in ms (default: 30000, max: 600000)",default:30000,minimum:0,maximum:600000}},required:["task_id"]},handler:async($,Z)=>{let Q=$.task_id,J=$.block??!0,X=$.timeout??30000;try{let V=`${Z.workingDirectory}/.claude/tasks/${Q}.json`,Y=Bun.file(V);if(!await Y.exists())return{content:`Task not found: ${Q}. Use /tasks to list available tasks.`,is_error:!0};let K=await Y.json();if(J&&K.status==="running"){let q=Date.now();while(Date.now()-q<X){await new Promise((z)=>setTimeout(z,1000));let W=Bun.file(V);if(await W.exists()){let z=await W.json();if(z.status!=="running")return{content:JSON.stringify({task_id:Q,status:z.status,output:z.output,error:z.error,duration:z.endTime?z.endTime-z.startTime:null},null,2)}}}return{content:JSON.stringify({task_id:Q,status:"timeout",message:`Task still running after ${X}ms`},null,2)}}return{content:JSON.stringify({task_id:Q,status:K.status,output:K.output,error:K.error,duration:K.endTime?K.endTime-K.startTime:null},null,2)}}catch(V){return{content:`Error getting task output: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},pX={name:"AskUserQuestion",description:`Use this tool when you need to ask the user questions during execution.
153
-
154
- This allows you to:
155
- 1. Gather user preferences or requirements
156
- 2. Clarify ambiguous instructions
157
- 3. Get decisions on implementation choices
158
- 4. Offer choices to the user about what direction to take
159
-
160
- Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
161
-
162
- The options array should have 2-4 options. Each option should be a distinct, mutually exclusive choice.
163
- The preview feature allows showing markdown content in a side-by-side layout.
164
-
165
- User can always select "Other" to provide custom text input.`,input_schema:{type:"object",properties:{questions:{type:"array",description:"Questions to ask the user (1-4 questions)",items:{type:"object",properties:{question:{type:"string",description:"The complete question to ask the user"},header:{type:"string",description:"Very short label displayed as a chip/tag (max 12 chars)"},options:{type:"array",description:"The available choices (2-4 options)",items:{type:"object",properties:{label:{type:"string",description:"The display text for this option (5 words max)"},description:{type:"string",description:"Explanation of what this option means"},markdown:{type:"string",description:"Optional preview content shown in a monospace box"}},required:["label","description"]},minItems:2,maxItems:4},multiSelect:{type:"boolean",description:"Allow selecting multiple options (default: false)",default:!1}},required:["question","header","options"]},minItems:1,maxItems:4}},required:["questions"]},handler:async($,Z)=>{let Q=$.questions;try{let J=Q.map((X,V)=>{let Y=X.options.map((K,q)=>{let W=` ${q+1}. ${K.label}`;if(K.description)W+=` - ${K.description}`;return W}).join(`
166
- `);return`## Question ${V+1}: [${X.header}]
167
- ${X.question}
168
-
169
- Options:
170
- ${Y}${X.multiSelect?`
171
- (multi-select enabled)`:""}`}).join(`
172
-
173
- ---
174
-
175
- `);return{content:JSON.stringify({type:"user_question",questions:Q,formatted:J,message:"Questions prepared for user response"},null,2)}}catch(J){return{content:`Error preparing questions: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},aX={name:"EnterPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
176
-
177
- How This Tool Works:
178
- - You should have already written your plan to the plan file specified in the plan mode system message
179
- - This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote
180
- - This tool simply signals that you're done planning and ready for the user to review and approve
181
-
182
- When to Use This Tool:
183
- IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you're gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.
184
-
185
- Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
186
-
187
- Examples:
188
- - "Search for and understand the implementation of vim mode" - Do NOT use this tool
189
- - "Help me implement yank mode for vim" - Use EnterPlanMode
190
-
191
- Important notes:
192
- - NEVER run additional commands to read or explore code, besides git bash commands
193
- - NEVER use the TodoWrite or Task tools
194
- - DO NOT commit files that likely contain secrets (.env, credentials.json, etc.)
195
- - If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to (e.g., 'Bash')"},prompt:{type:"string",description:"Semantic description of the action (e.g., 'run tests', 'install dependencies')"}},required:["tool","prompt"]}}},required:[]},handler:async($,Z)=>{let Q=$.allowedPrompts;try{let J=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(J);if(!await X.exists())return{content:"Error: No plan file found. Please write your plan to .claude/plan.md first.",is_error:!0};let V=await X.text();return{content:JSON.stringify({type:"plan_ready",planFile:J,planLength:V.length,allowedPrompts:Q||[],message:"Plan is ready for user review. ExitPlanMode will request user approval."},null,2)}}catch(J){return{content:`Error entering plan mode: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},rX={name:"ExitPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
196
-
197
- This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote.
198
- This tool simply signals that you're done planning and ready for the user to review and approve.
199
-
200
- IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code.
201
- ExitPlanMode inherently requests user approval of the plan.`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to"},prompt:{type:"string",description:"Semantic description of the action"}},required:["tool","prompt"]}}},required:[]},handler:async($,Z)=>{let Q=$.allowedPrompts;try{let J=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(J);if(!await X.exists())return{content:"Error: No plan file found at .claude/plan.md",is_error:!0};let V=await X.text();return{content:JSON.stringify({type:"exit_plan_mode",status:"awaiting_approval",planFile:J,planPreview:V.slice(0,500)+(V.length>500?"...":""),allowedPrompts:Q||[],message:"Plan submitted for user approval."},null,2)}}catch(J){return{content:`Error exiting plan mode: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},nX={name:"Skill",description:`Execute a skill within the main conversation.
202
-
203
- When users ask you to perform tasks, check if any of the available skills match. Skills provide specialized capabilities and domain knowledge.
204
-
205
- When users reference a "slash command" or "/<something>" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke it.
206
-
207
- How to invoke:
208
- - Use this tool with the skill name and optional arguments
209
- - Examples:
210
- - skill: "commit" - invoke the commit skill
211
- - skill: "review-pr", args: "123" - invoke with arguments
212
- - Use fully qualified name for namespaced skills: skill: "ms-office-suite:pdf"
213
-
214
- Available skills are listed in system-reminder messages in the conversation.
215
- When a skill matches the user's request, this is a BLOCKING REQUIREMENT: invoke the relevant Skill tool BEFORE generating any other response about the task.
216
-
217
- Important:
218
- - NEVER mention a skill without actually calling this tool
219
- - Do not invoke a skill that is already running
220
- - Do not use this tool for built-in CLI commands (like /help, /clear)`,input_schema:{type:"object",properties:{skill:{type:"string",description:"The skill name (e.g., 'commit', 'review-pr', or fully qualified 'namespace:skill')"},args:{type:"string",description:"Optional arguments for the skill"}},required:["skill"]},handler:async($,Z)=>{let{skill:Q,args:J}=$;try{let X=`${Z.workingDirectory}/.claude/skills`,V=`${process.env.HOME||""}/.claude/skills`,Y=[`${X}/${Q}.md`,`${X}/${Q}/skill.md`,`${V}/${Q}.md`,`${V}/${Q}/skill.md`],K=null;for(let z of Y)if(await Bun.file(z).exists()){K=z;break}if(!K)return{content:`Skill not found: ${Q}. Available skills can be listed with /help.`,is_error:!0};let W=await Bun.file(K).text();return{content:JSON.stringify({type:"skill_invocation",skill:Q,args:J,skillFile:K,content:W,message:`Skill "${Q}" loaded. Follow the instructions in the skill content.`},null,2)}}catch(X){return{content:`Error invoking skill: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},iX={name:"TaskStop",description:`Stops a running background task by its ID.
221
- Takes a task_id parameter identifying the task to stop.
222
- Returns a success or failure status.
223
- Use this tool to terminate a long-running task.`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The ID of the background task to stop"},shell_id:{type:"string",description:"Deprecated: use task_id instead"}},required:["task_id"]},handler:async($,Z)=>{let Q=$.task_id;try{let J=`${Z.workingDirectory}/.claude/tasks/${Q}.json`,X=Bun.file(J);if(!await X.exists())return{content:`Task not found: ${Q}`,is_error:!0};let V=await X.json();if(V.status!=="running")return{content:JSON.stringify({task_id:Q,status:V.status,message:`Task is already ${V.status}`},null,2)};return V.status="stopped",await Bun.write(J,JSON.stringify(V,null,2)),{content:JSON.stringify({task_id:Q,status:"stopped",message:"Task stopped successfully"},null,2)}}catch(J){return{content:`Error stopping task: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},oX={name:"MultiEdit",description:`Performs atomic multi-file editing with rollback on failure.
224
-
225
- This tool allows you to edit multiple files simultaneously in a single atomic operation.
226
- If any edit fails, all changes are automatically rolled back to maintain consistency.
227
-
228
- Key features:
229
- - Validates all edits before applying (files exist, strings found)
230
- - Creates automatic backups before editing
231
- - Applies all edits atomically (all-or-nothing)
232
- - Rolls back on any failure
233
-
234
- Use this when you need to make coordinated changes across multiple files and want
235
- to ensure either all changes succeed or none are applied.
236
-
237
- IMPORTANT: You MUST read the files first before using this tool. Only edit files you have already read.`,input_schema:{type:"object",properties:{edits:{type:"array",description:"Array of edit operations to apply atomically",items:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to edit"},old_string:{type:"string",description:"The text to find and replace"},new_string:{type:"string",description:"The text to replace it with"},replace_all:{type:"boolean",description:"Replace all occurrences (default: false)"}},required:["file_path","old_string","new_string"]}},dry_run:{type:"boolean",description:"Preview changes without applying them (default: false)"}},required:["edits"]},handler:async($,Z)=>{let Q=$.edits,J=$.dry_run||!1;try{if(!Array.isArray(Q)||Q.length===0)return{content:"Error: edits must be a non-empty array",is_error:!0};let X=[];for(let K=0;K<Q.length;K++){let q=Q[K];if(!q||!q.file_path||!q.old_string||q.new_string===void 0)return{content:`Error: Edit at index ${K} is missing required fields (file_path, old_string, new_string)`,is_error:!0};X.push({filePath:q.file_path,oldString:q.old_string,newString:q.new_string,replaceAll:q.replace_all||!1})}if(J){let K=z5(X),q=$2(X);if(q.length>0)return{content:JSON.stringify({valid:!1,errors:q,preview:K},null,2),is_error:!0};return{content:JSON.stringify({valid:!0,preview:K,total_files:K.length,total_replacements:K.reduce((W,z)=>W+z.replacementCount,0),message:"Dry run successful - no changes applied"},null,2)}}let V=$2(X);if(V.length>0)return{content:`Validation failed:
238
- ${V.join(`
239
- `)}`,is_error:!0};let Y=G5(X);if(Y.success)return{content:JSON.stringify({success:!0,files_modified:Y.filesModified,total_replacements:Y.totalReplacements,message:`Successfully applied ${Y.totalReplacements} replacement(s) across ${Y.filesModified.length} file(s)`},null,2)};else return{content:JSON.stringify({success:!1,error:Y.error,rolled_back:Y.rolledBack,files_modified:Y.filesModified},null,2),is_error:!0}}catch(X){return{content:`Error applying multi-edit: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},sX={name:"NotebookEdit",description:`Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source.
240
-
241
- Jupyter notebooks are interactive documents that combine code, text, and visualizations. The notebook_path parameter must be an absolute path, not a relative path. The cell_number is 0-indexed. Use edit_mode=insert to add a new cell at the index specified by cell_number. Use edit_mode=delete to delete the cell at the index specified by cell_number.`,input_schema:{type:"object",properties:{notebook_path:{type:"string",description:"The absolute path to the Jupyter notebook file to edit"},cell_id:{type:"string",description:"The ID of the cell to edit (optional, alternative to cell_number)"},cell_number:{type:"number",description:"The index of the cell to edit (0-indexed)"},new_source:{type:"string",description:"The new source for the cell"},cell_type:{type:"string",enum:["code","markdown"],description:"The type of the cell (code or markdown). Defaults to code."},edit_mode:{type:"string",enum:["replace","insert","delete"],description:"The type of edit to perform (replace, insert, delete)"}},required:["notebook_path"]},handler:async($,Z)=>{let{notebook_path:Q,cell_id:J,cell_number:X,new_source:V}=$,Y=$.cell_type||"code",K=$.edit_mode||"replace";try{let q=Bun.file(Q);if(!await q.exists())return{content:`Error: Notebook not found: ${Q}`,is_error:!0};let W=await q.json();if(!W.cells||!Array.isArray(W.cells))return{content:"Error: Invalid notebook format - no cells array",is_error:!0};let z;if(J){if(z=W.cells.findIndex((G)=>G.id===J),z===-1)return{content:`Error: Cell with ID "${J}" not found`,is_error:!0}}else if(X!==void 0){if(z=X,z<0||z>=W.cells.length)if(K==="insert")z=W.cells.length;else return{content:`Error: Cell number ${z} out of range (0-${W.cells.length-1})`,is_error:!0}}else if(K!=="insert")return{content:"Error: Must specify either cell_id or cell_number",is_error:!0};else z=W.cells.length;switch(K){case"delete":{W.cells.splice(z,1);break}case"insert":{let G={id:`cell-${Date.now()}`,cell_type:Y,source:V||"",metadata:{},...Y==="code"?{outputs:[],execution_count:null}:{}};W.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=W.cells[z];if(!G)return{content:`Error: Cell at index ${z} not found`,is_error:!0};W.cells[z]={...G,source:V,cell_type:Y,...Y==="code"?{execution_count:null}:{}};break}}return await Bun.write(Q,JSON.stringify(W,null,1)),{content:JSON.stringify({success:!0,message:`Successfully ${K}d cell in ${Q}`,cellCount:W.cells.length})}}catch(q){return{content:`Error editing notebook: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},eX=[yX,fX,hX,oX,uX,dX,mX,cX,lX,iX,pX,aX,rX,nX,sX];function Jq($){return eX.find((Z)=>Z.name===$)}import{spawn as tX}from"child_process";import r2 from"ws";class n2{static MCPClient=n2;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=tX(this.config.command,this.config.args||[],{env:{...process.env,...this.config.env},stdio:["pipe","pipe","pipe"]}),this.process.stdout?.on("data",($)=>{this.handleData($.toString())}),this.process.stderr?.on("data",($)=>{this.log(`stderr: ${$.toString()}`)}),this.process.on("error",($)=>{this.log(`Process error: ${$.message}`)}),this.process.on("close",($)=>{this.log(`Process closed with code ${$}`),this.connected=!1}),await new Promise(($)=>setTimeout($,100)),await this.initialize()}async connectHttp(){if(!this.config.url)throw Error("No URL specified for HTTP transport");this.log(`Starting HTTP transport: ${this.config.url}`);try{let $=await fetch(this.config.url,{method:"POST",headers:{"Content-Type":"application/json",...this.config.headers},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"claude-code-remake",version:"0.1.0"}}})});if(!$.ok)throw Error(`HTTP error: ${$.status}`);let Z=await $.json();this.connected=!0,await this.loadTools()}catch($){let Z=$ instanceof Error?$.message:String($);throw Error(`Failed to connect to HTTP server: ${Z}`)}}async connectWebSocket(){if(!this.config.url)throw Error("No URL specified for WebSocket transport");let $=this.config.url;return this.log(`Starting WebSocket transport: ${$}`),new Promise((Z,Q)=>{let J={...this.config.headers},X=new r2($,{headers:J,handshakeTimeout:this.config.timeout||30000});X.on("open",()=>{this.log("WebSocket connection established"),this.websocket=X,this.connected=!0,this.initialize().then(()=>Z()).catch((V)=>{let Y=V instanceof Error?V.message:String(V);this.log(`Initialization failed: ${Y}`),Q(V)})}),X.on("message",(V,Y)=>{let K=Y?V.toString():V.toString();this.handleData(K)}),X.on("error",(V)=>{if(this.log(`WebSocket error: ${V.message}`),!this.connected)Q(Error(`WebSocket connection failed: ${V.message}`))}),X.on("close",(V,Y)=>{this.log(`WebSocket closed: code=${V}, reason=${Y.toString()}`),this.connected=!1,this.websocket=null;for(let[K,q]of this.pendingRequests)this.pendingRequests.delete(K),q.reject(Error(`WebSocket closed: ${Y.toString()}`))}),X.on("ping",()=>{X.pong()})})}async initialize(){let $=await this.request("initialize",{protocolVersion:"2024-11-05",capabilities:{tools:{},resources:{},prompts:{}},clientInfo:{name:"claude-code-remake",version:"0.1.0"}});this.log(`Initialized with: ${JSON.stringify($)}`),this.connected=!0,this.notify("notifications/initialized",{}),await this.loadTools()}async loadTools(){try{let $=await this.request("tools/list",{});this.tools=$.tools.map((Z)=>({name:Z.name,description:Z.description,inputSchema:Z.inputSchema})),this.log(`Loaded ${this.tools.length} tools`)}catch($){this.log(`Failed to load tools: ${$}`)}}async callTool($,Z){return{content:(await this.request("tools/call",{name:$,arguments:Z})).content.filter((X)=>X.type==="text").map((X)=>X.text||"").join(`
242
- `)}}async request($,Z){let Q=++this.requestId,J={jsonrpc:"2.0",id:Q,method:$,params:Z};return new Promise((X,V)=>{this.pendingRequests.set(Q,{resolve:X,reject:V});let Y=JSON.stringify(J);if(this.websocket&&this.websocket.readyState===r2.OPEN)this.websocket.send(Y);else if(this.process?.stdin?.writable)this.process.stdin.write(Y+`
243
- `);else{this.pendingRequests.delete(Q),V(Error("No active connection to send request"));return}setTimeout(()=>{if(this.pendingRequests.has(Q))this.pendingRequests.delete(Q),V(Error(`Request timeout for ${$}`))},this.config.timeout||120000)})}notify($,Z){let J=JSON.stringify({jsonrpc:"2.0",method:$,params:Z});if(this.websocket&&this.websocket.readyState===r2.OPEN)this.websocket.send(J);else if(this.process?.stdin?.writable)this.process.stdin.write(J+`
244
- `)}handleData($){this.buffer+=$;let Z=this.buffer.split(`
245
- `);this.buffer=Z.pop()||"";for(let Q of Z){if(!Q.trim())continue;try{let J=JSON.parse(Q);if(J.id!==void 0){let X=this.pendingRequests.get(J.id);if(X)if(this.pendingRequests.delete(J.id),J.error)X.reject(Error(J.error.message));else X.resolve(J.result)}}catch(J){this.log(`Parse error: ${J}`)}}}async close(){if(this.websocket)this.websocket.close(),this.websocket=null;if(this.process)this.process.kill(),this.process=null;this.connected=!1}log($){this.onLog?.(`[MCP:${this.name}] ${$}`)}}async function Kq($,Z){let Q=new Map;for(let[J,X]of Object.entries($)){if(X.disabled)continue;let V=new n2({name:J,config:X,onLog:Z});try{await V.connect(),Q.set(J,V)}catch(Y){let K=Y instanceof Error?Y.message:String(Y);Z?.(`[MCP:${J}] Failed to connect: ${K}`)}}return Q}import{spawn as $V}from"child_process";class ZV{hooks=new Map;timeout;constructor($=60000){this.timeout=$}register($,Z){if(!this.hooks.has($))this.hooks.set($,[]);this.hooks.get($)?.push(Z)}registerAll($){for(let[Z,Q]of Object.entries($))for(let J of Q)this.register(Z,J)}async execute($,Z){let Q=this.hooks.get($);if(!Q||Q.length===0)return{decision:"allow"};let J={...Z,event:$,timestamp:Date.now()};for(let X of Q){if(X.enabled===!1)continue;let V=await this.executeHook(X,J);if(V.decision==="deny"||V.decision==="block")return V;if(V.modified_input)Object.assign(Z,V.modified_input)}return{decision:"allow"}}async executeHook($,Z){let Q=$.timeout||this.timeout;try{return await new Promise((X,V)=>{let Y=$V($.command,[],{shell:!0,stdio:["pipe","pipe","pipe"]}),K="",q="";Y.stdout?.on("data",(W)=>{K+=W.toString()}),Y.stderr?.on("data",(W)=>{q+=W.toString()}),Y.on("close",(W)=>{if(W===0)try{let z=JSON.parse(K);X(z)}catch{X({decision:"allow"})}else if(W===1)X({decision:"deny",reason:q||"Hook denied execution"});else if(W===2)X({decision:"block",reason:q||"Hook blocked execution"});else X({decision:"allow"})}),Y.on("error",(W)=>{X({decision:"allow",reason:`Hook error: ${W.message}`})}),Y.stdin?.write(JSON.stringify(Z)),Y.stdin?.end(),setTimeout(()=>{Y.kill(),X({decision:"allow",reason:"Hook timeout"})},Q)})}catch(J){return{decision:"allow",reason:`Hook execution failed: ${J instanceof Error?J.message:String(J)}`}}}getHooks($){return this.hooks.get($)||[]}clear($){if($)this.hooks.delete($);else this.hooks.clear()}}var Hq={validateWrite:{event:"PreToolUse",command:`node -e '
246
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
247
- if (input.tool_name === "Write") {
248
- const path = input.tool_input.file_path;
249
- if (path.includes("..") || path.startsWith("/etc/")) {
250
- console.log(JSON.stringify({ decision: "deny", reason: "Unsafe path" }));
251
- process.exit(1);
252
- }
253
- }
254
- console.log(JSON.stringify({ decision: "allow" }));
255
- '`,timeout:5000,enabled:!1},logToolUse:{event:"PostToolUse",command:`node -e '
256
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
257
- console.error(\`[LOG] Tool: \${input.tool_name}\`);
258
- console.log(JSON.stringify({ decision: "allow" }));
259
- '`,timeout:5000,enabled:!1}},zq={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."},Gq={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as QV,existsSync as y9,readdirSync as JV}from"fs";import{join as XV}from"path";function VV($,Z="project"){if(!y9($))return null;let Q=QV($,"utf-8"),J=$.split("/").pop()?.replace(/\.md$/i,"")||"unknown",X=Q.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!X)return{path:$,name:J,description:"",prompt:Q.trim(),source:Z};let V=X[1]??"",Y=X[2]??"",K=YV(V);return{path:$,name:K.name||J,description:K.description||"",prompt:Y.trim(),tools:K.tools,model:K.model,color:K.color,source:Z}}function YV($){let Z={},Q=$.split(`
260
- `);for(let J of Q){let X=J.match(/^(\w+):\s*(.*)$/);if(X){let V=X[1];if(!V)continue;let Y=X[2]??"";if(Y.startsWith("["))try{Z[V]=JSON.parse(Y)}catch{Z[V]=Y}else if(Y==="true")Z[V]=!0;else if(Y==="false")Z[V]=!1;else if(/^\d+$/.test(Y))Z[V]=parseInt(Y,10);else if(/^\d+\.\d+$/.test(Y))Z[V]=parseFloat(Y);else Z[V]=Y}}return Z}class KV{skills=new Map;loadFromDirectory($,Z="project"){if(!y9($))return 0;let Q=0,J=JV($);for(let X of J)if(X.endsWith(".md")){let V=VV(XV($,X),Z);if(V)this.skills.set(V.name,V),Q++}return Q}get($){return this.skills.get($)}getAll(){return Array.from(this.skills.values())}has($){return this.skills.has($)}getNames(){return Array.from(this.skills.keys())}}function Lq($){return`
261
- <skill-loading>
262
- You are operating with the "${$.name}" skill loaded.
263
-
264
- ${$.description?`Description: ${$.description}
265
- `:""}
266
- ${$.prompt}
267
- </skill-loading>
268
- `.trim()}var _q=[{path:"built-in://commit",name:"commit",description:"Create a git commit with the staged changes",prompt:`Analyze the staged changes and create a git commit.
269
-
270
- Steps:
271
- 1. Run \`git diff --staged\` to see staged changes
272
- 2. Run \`git log --oneline -5\` to understand commit message style
273
- 3. Create a commit message following conventional commits format
274
- 4. Include "Co-Authored-By: Claude <noreply@anthropic.com>" if applicable
275
- 5. Run \`git commit\` with the message`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://review-pr",name:"review-pr",description:"Review a pull request",prompt:`Review the current pull request and provide feedback.
276
-
277
- Steps:
278
- 1. Use \`gh pr view\` to get PR details
279
- 2. Use \`gh pr diff\` to see the changes
280
- 3. Analyze the code for:
281
- - Bugs and potential issues
282
- - Code quality and style
283
- - Test coverage
284
- - Documentation
285
- 4. Provide constructive feedback
286
- 5. Approve or request changes as appropriate`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://mcp-builder",name:"mcp-builder",description:"Guide for creating MCP servers",prompt:`Help the user build MCP (Model Context Protocol) servers.
287
-
288
- MCP servers enable LLMs to interact with external services through well-designed tools.
289
-
290
- Key concepts:
291
- 1. Use FastMCP (Python) or MCP SDK (TypeScript)
292
- 2. Define tools with clear input schemas
293
- 3. Return structured content
294
- 4. Handle errors gracefully
295
-
296
- Transport types:
297
- - stdio: Local process communication
298
- - HTTP: REST API with JSON-RPC
299
- - SSE: Server-Sent Events for streaming
300
- - WebSocket: Bidirectional communication`,tools:["Read","Write","Edit","Bash"],model:"sonnet",source:"built-in"},{path:"built-in://claude-hooks",name:"claude-hooks",description:"Guide for Claude Code hooks",prompt:`Help the user configure Claude Code hooks.
301
-
302
- Hooks are user-defined shell commands that execute at specific points during Claude Code's lifecycle.
303
-
304
- Available events:
305
- - PreToolUse: Before a tool executes
306
- - PostToolUse: After a tool succeeds
307
- - PostToolUseFailure: After a tool fails
308
- - Stop: When agent stops
309
- - UserPromptSubmit: When user submits prompt
310
- - SessionStart/SessionEnd: Session lifecycle
311
-
312
- Exit codes:
313
- - 0: Allow execution
314
- - 1: Deny and show stderr
315
- - 2: Block silently`,tools:["Read","Write","Edit"],model:"sonnet",source:"built-in"}];function wq($){return $.match(/^\/(\w+)(?:\s+(.*))?$/)?.[1]??null}function Fq($){return $.match(/^\/\w+\s+(.*)$/)?.[1]??""}import{spawn as i2}from"child_process";import{mkdirSync as b9,rmSync as qV,existsSync as f9,readFileSync as WV}from"fs";import{join as J6}from"path";class HV{teams=new Map;teammates=new Map;messageQueue=new Map;storagePath;constructor($="~/.claude/teams"){if(this.storagePath=$.replace("~",process.env.HOME||""),!f9(this.storagePath))b9(this.storagePath,{recursive:!0});this.loadTeams()}createTeam($){let Z={...$,status:"active"};this.teams.set($.name,Z);for(let Q of $.teammates)this.teammates.set(Q.teammateId,Q);return this.persistTeam(Z).catch((Q)=>{console.error(`Failed to persist team ${$.name}:`,Q)}),Z}getTeam($){return this.teams.get($)}listTeams(){return Array.from(this.teams.values())}deleteTeam($){let Z=this.teams.get($);if(Z){for(let J of Z.teammates)this.teammates.delete(J.teammateId),this.messageQueue.delete(J.teammateId);this.teams.delete($);let Q=J6(this.storagePath,$);try{qV(Q,{recursive:!0,force:!0})}catch(J){console.error(`Failed to delete team directory ${Q}:`,J)}}}getTeammate($){return this.teammates.get($)}updateTeammateStatus($,Z){let Q=this.teammates.get($);if(Q)Q.status=Z}async spawnTeammate($,Z={}){let{session:Q,workingDir:J=process.cwd()}=Z;if(!process.env.TMUX)await this.spawnInTerminal($,{session:Q,workingDir:J});else await this.spawnInTmux($,{session:Q,workingDir:J});this.updateTeammateStatus($.teammateId,"in_progress")}async spawnInTerminal($,Z){let Q=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName,"--agent-color",$.color];if($.planModeRequired)Q.push("--permission-mode","plan");if(process.platform==="darwin"){let J=`
316
- tell application "Terminal"
317
- do script "cd ${Z.workingDir} && ${Q.join(" ")}"
318
- activate
319
- end tell
320
- `;i2("osascript",["-e",J])}else i2("xterm",["-e",Q.join(" ")])}async spawnInTmux($,Z){let Q=Z.session||process.env.TMUX?.split(",")[0]?.split(":")[0]||"claude";await this.tmuxCommand(["split-window","-t",Q,"-c",Z.workingDir]);let J=await this.tmuxCommand(["display-message","-p","#{pane_id}"]);if(J)$.paneId=J.trim();let X=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName];await this.tmuxCommand(["send-keys","-t",$.paneId||"",X.join(" "),"Enter"])}async tmuxCommand($){return new Promise((Z)=>{let Q=i2("tmux",$),J="";Q.stdout?.on("data",(X)=>{J+=X.toString()}),Q.on("close",()=>{Z(J)})})}broadcast($,Z,Q){let J=this.teams.get($);if(!J)return;let X={type:"broadcast",from:Q||"system",content:Z,timestamp:Date.now()};for(let V of J.teammates){if(Q&&V.teammateId===Q)continue;let Y=this.messageQueue.get(V.teammateId)||[];Y.push(X),this.messageQueue.set(V.teammateId,Y)}}sendDirect($,Z,Q){let J={type:"direct",from:Z,to:$,content:Q,timestamp:Date.now()},X=this.messageQueue.get($)||[];X.push(J),this.messageQueue.set($,X)}getMessages($){let Z=this.messageQueue.get($)||[];return this.messageQueue.delete($),Z}hasMessages($){let Z=this.messageQueue.get($);return Z!==void 0&&Z.length>0}peekMessages($){return this.messageQueue.get($)||[]}clearMessages($){this.messageQueue.delete($)}getMessageCount($){return this.messageQueue.get($)?.length||0}async persistTeam($){let Z=J6(this.storagePath,$.name),Q=J6(Z,"config.json");if(!f9(Z))b9(Z,{recursive:!0});await Bun.write(J6(Z,".gitkeep"),"");let J={name:$.name,description:$.description,teammates:$.teammates,taskListId:$.taskListId,status:$.status,coordination:$.coordination,updatedAt:Date.now()};await Bun.write(Q,JSON.stringify(J,null,2))}loadTeams(){let $=new Bun.Glob("**/config.json");try{let Z=Array.from($.scanSync(this.storagePath));for(let Q of Z)try{let J=J6(this.storagePath,Q);if(Bun.file(J).size===0)continue;let Y=WV(J,"utf-8"),K=JSON.parse(Y);if(!K.name||!K.teammates||!Array.isArray(K.teammates))continue;let q={name:K.name,description:K.description||"",teammates:K.teammates,taskListId:K.taskListId||"",status:K.status||"active",coordination:K.coordination||{dependencyOrder:[],communicationProtocol:"broadcast",taskAssignmentStrategy:"manual"}};this.teams.set(q.name,q);for(let W of q.teammates)this.teammates.set(W.teammateId,W)}catch(J){}}catch(Z){if(Z.code!=="ENOENT");}}async persistAllTeams(){let $=Array.from(this.teams.values()).map((Z)=>this.persistTeam(Z));await Promise.all($)}}var Dq={architect:($)=>({name:"architect",teamName:$,color:"blue",prompt:`You are an architect on the ${$} team.
321
- Your role is to design and plan the technical architecture.
322
- Focus on:
323
- - System design and component relationships
324
- - API contracts and interfaces
325
- - Data models and schemas
326
- - Trade-offs and design decisions`,planModeRequired:!0,status:"pending"}),implementer:($)=>({name:"implementer",teamName:$,color:"green",prompt:`You are an implementer on the ${$} team.
327
- Your role is to write clean, working code based on the architecture.
328
- Focus on:
329
- - Implementing the designed architecture
330
- - Writing tests
331
- - Following coding standards
332
- - Handling edge cases`,planModeRequired:!1,status:"pending"}),reviewer:($)=>({name:"reviewer",teamName:$,color:"yellow",prompt:`You are a code reviewer on the ${$} team.
333
- Your role is to review code changes and provide feedback.
334
- Focus on:
335
- - Code quality and readability
336
- - Potential bugs and issues
337
- - Performance considerations
338
- - Test coverage`,planModeRequired:!1,status:"pending"}),tester:($)=>({name:"tester",teamName:$,color:"orange",prompt:`You are a tester on the ${$} team.
339
- Your role is to ensure features work correctly.
340
- Focus on:
341
- - Writing comprehensive tests
342
- - Finding edge cases
343
- - Verifying requirements
344
- - Reporting bugs`,planModeRequired:!1,status:"pending"})};function zV(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Iq($){return{...$,teammateId:zV(),status:"pending"}}
345
- export{y as a,Y6 as b,c9 as c,jV as d,t2 as e,$5 as f,UV as g,n9 as h,i9 as i,o9 as j,s9 as k,J5 as l,$7 as m,Z7 as n,p6 as o,a6 as p,CV as q,NV as r,PV as s,fV as t,e6 as u,hV as v,gV as w,uV as x,U7 as y,A7 as z,lV as A,W5 as B,iV as C,Q4 as D,oV as E,sV as F,eV as G,tV as H,$2 as I,z5 as J,G5 as K,yX as L,fX as M,hX as N,uX as O,dX as P,mX as Q,cX as R,lX as S,pX as T,aX as U,rX as V,nX as W,iX as X,oX as Y,sX as Z,eX as _,Jq as $,n2 as aa,Kq as ba,ZV as ca,Hq as da,zq as ea,Gq as fa,VV as ga,KV as ha,Lq as ia,_q as ja,wq as ka,Fq as la,HV as ma,Dq as na,zV as oa,Iq as pa};