@easbot/ollama-sdk 0.1.3 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +15 -15
- package/README.md +13 -13
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +26 -23
- package/dist/index.d.ts +26 -23
- package/dist/index.mjs +6 -6
- package/package.json +29 -29
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
`);o=h.pop()||"";for(let d of h){let f=d.trim();if(f)try{yield JSON.parse(f);}catch{}}}}finally{i.releaseLock();}}async chat(t){let s=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!s.ok)throw new Error(`Ollama API error: ${s.status} ${s.statusText}`);return s.json()}};var Me={numCtx:262144,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},_n=["numCtx","repeatPenalty","numPredict"];var Qt=class extends Error{constructor(s,i){super(s);this.cause=i;this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},hi=class extends Qt{constructor(s,i,n){super(s,n);this.url=i;this.name="ConnectionError";}},ci=class extends Qt{constructor(s,i){super(`Model not found: ${s}`,i);this.modelId=s;this.name="ModelNotFoundError";}},ui=class extends Qt{constructor(s,i,n,o){super(s,o);this.field=i;this.value=n;this.name="ValidationError";}},di=class extends Qt{constructor(s,i,n){super(s,n);this.timeoutMs=i;this.name="TimeoutError";}},Je=class extends Qt{constructor(s,i,n){super(`Invalid tool definition for "${s}": missing ${i}`,n);this.toolName=s;this.missingField=i;this.name="InvalidToolDefinitionError";}};var Pr=(e,t,s)=>{let i=e instanceof RegExp?Ui(e,s):e,n=t instanceof RegExp?Ui(t,s):t,o=i!==null&&n!=null&&Fn(i,n,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+n.length)}},Ui=(e,t)=>{let s=t.match(e);return s?s[0]:null},Fn=(e,t,s)=>{let i,n,o,a,l,h=s.indexOf(e),d=s.indexOf(t,h+1),f=h;if(h>=0&&d>0){if(e===t)return [h,d];for(i=[],o=s.length;f>=0&&!l;){if(f===h)i.push(f),h=s.indexOf(e,f+1);else if(i.length===1){let p=i.pop();p!==void 0&&(l=[p,d]);}else n=i.pop(),n!==void 0&&n<o&&(o=n,a=d),d=s.indexOf(t,f+1);f=h<d&&h>=0?h:d;}i.length&&a!==void 0&&(l=[o,a]);}return l},Dr="\0SLASH"+Math.random()+"\0",Ir="\0OPEN"+Math.random()+"\0",Di="\0CLOSE"+Math.random()+"\0",Nr="\0COMMA"+Math.random()+"\0",jr="\0PERIOD"+Math.random()+"\0",Pn=new RegExp(Dr,"g"),Dn=new RegExp(Ir,"g"),In=new RegExp(Di,"g"),Nn=new RegExp(Nr,"g"),jn=new RegExp(jr,"g"),Wn=/\\\\/g,zn=/\\{/g,$n=/\\}/g,Un=/\\,/g,Bn=/\\./g,Gn=1e5;function pi(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Vn(e){return e.replace(Wn,Dr).replace(zn,Ir).replace($n,Di).replace(Un,Nr).replace(Bn,jr)}function qn(e){return e.replace(Pn,"\\").replace(Dn,"{").replace(In,"}").replace(Nn,",").replace(jn,".")}function Wr(e){if(!e)return [""];let t=[],s=Pr("{","}",e);if(!s)return e.split(",");let{pre:i,body:n,post:o}=s,a=i.split(",");a[a.length-1]+="{"+n+"}";let l=Wr(o);return o.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),t.push.apply(t,a),t}function Jn(e,t={}){if(!e)return [];let{max:s=Gn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ts(Vn(e),s,true).map(qn)}function Hn(e){return "{"+e+"}"}function Zn(e){return /^-?0\d/.test(e)}function Kn(e,t){return e<=t}function Yn(e,t){return e>=t}function ts(e,t,s){let i=[],n=Pr("{","}",e);if(!n)return [e];let o=n.pre,a=n.post.length?ts(n.post,t,false):[""];if(/\$$/.test(n.pre))for(let l=0;l<a.length&&l<t;l++){let h=o+"{"+n.body+"}"+a[l];i.push(h);}else {let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),h=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),d=l||h,f=n.body.indexOf(",")>=0;if(!d&&!f)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+Di+n.post,ts(e,t,true)):[e];let p;if(d)p=n.body.split(/\.\./);else if(p=Wr(n.body),p.length===1&&p[0]!==void 0&&(p=ts(p[0],t,false).map(Hn),p.length===1))return a.map(b=>n.pre+p[0]+b);let y;if(d&&p[0]!==void 0&&p[1]!==void 0){let b=pi(p[0]),S=pi(p[1]),v=Math.max(p[0].length,p[1].length),E=p.length===3&&p[2]!==void 0?Math.abs(pi(p[2])):1,w=Kn;S<b&&(E*=-1,w=Yn);let O=p.some(Zn);y=[];for(let T=b;w(T,S);T+=E){let C;if(h)C=String.fromCharCode(T),C==="\\"&&(C="");else if(C=String(T),O){let k=v-C.length;if(k>0){let M=new Array(k+1).join("0");T<0?C="-"+M+C.slice(1):C=M+C;}}y.push(C);}}else {y=[];for(let b=0;b<p.length;b++)y.push.apply(y,ts(p[b],t,false));}for(let b=0;b<y.length;b++)for(let S=0;S<a.length&&i.length<t;S++){let v=o+y[b]+a[S];(!s||d||v)&&i.push(v);}}return i}var Ys=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},Qn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",true],"[:alpha:]":["\\p{L}\\p{Nl}",true],"[:ascii:]":["\\x00-\\x7f",false],"[:blank:]":["\\p{Zs}\\t",true],"[:cntrl:]":["\\p{Cc}",true],"[:digit:]":["\\p{Nd}",true],"[:graph:]":["\\p{Z}\\p{C}",true,true],"[:lower:]":["\\p{Ll}",true],"[:print:]":["\\p{C}",true],"[:punct:]":["\\p{P}",true],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",true],"[:upper:]":["\\p{Lu}",true],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",true],"[:xdigit:]":["A-Fa-f0-9",false]},He=e=>e.replace(/[[\]\\-]/g,"\\$&"),Xn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Bi=e=>e.join(""),to=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],n=[],o=s+1,a=false,l=false,h=false,d=false,f=s,p="";t:for(;o<e.length;){let S=e.charAt(o);if((S==="!"||S==="^")&&o===s+1){d=true,o++;continue}if(S==="]"&&a&&!h){f=o+1;break}if(a=true,S==="\\"&&!h){h=true,o++;continue}if(S==="["&&!h){for(let[v,[E,w,O]]of Object.entries(Qn))if(e.startsWith(v,o)){if(p)return ["$.",false,e.length-s,true];o+=v.length,O?n.push(E):i.push(E),l=l||w;continue t}}if(h=false,p){S>p?i.push(He(p)+"-"+He(S)):S===p&&i.push(He(S)),p="",o++;continue}if(e.startsWith("-]",o+1)){i.push(He(S+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=S,o+=2;continue}i.push(He(S)),o++;}if(f<o)return ["",false,0,false];if(!i.length&&!n.length)return ["$.",false,e.length-s,true];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!d){let S=i[0].length===2?i[0].slice(-1):i[0];return [Xn(S),false,f-s,false]}let y="["+(d?"^":"")+Bi(i)+"]",b="["+(d?"":"^")+Bi(n)+"]";return [i.length&&n.length?"("+y+"|"+b+")":i.length?y:b,l,f-s,true]},_e=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=true}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),eo=new Set(["!","?","+","*","@"]),Gi=e=>eo.has(e),so="(?!(?:^|/)\\.\\.?(?:$|/))",Ds="(?!\\.)",io=new Set(["[","."]),ro=new Set(["..","."]),no=new Set("().*{}+?[]^$\\!"),oo=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ii="[^/]",Vi=Ii+"*?",qi=Ii+"+?",G,K,Bt,N,U,re,me,ne,Nt,ye,as,Oe,$r,ue,tt,Bs,Si,Ur,zr=(tt=class{constructor(t,s,i={}){m(this,Oe);c(this,"type");m(this,G);m(this,K);m(this,Bt,false);m(this,N,[]);m(this,U);m(this,re);m(this,me);m(this,ne,false);m(this,Nt);m(this,ye);m(this,as,false);this.type=t,t&&u(this,K,true),u(this,U,s),u(this,G,r(this,U)?r(r(this,U),G):this),u(this,Nt,r(this,G)===this?i:r(r(this,G),Nt)),u(this,me,r(this,G)===this?[]:r(r(this,G),me)),t==="!"&&!r(r(this,G),ne)&&r(this,me).push(this),u(this,re,r(this,U)?r(r(this,U),N).length:0);}get hasMagic(){if(r(this,K)!==void 0)return r(this,K);for(let t of r(this,N))if(typeof t!="string"&&(t.type||t.hasMagic))return u(this,K,true);return r(this,K)}toString(){return r(this,ye)!==void 0?r(this,ye):this.type?u(this,ye,this.type+"("+r(this,N).map(t=>String(t)).join("|")+")"):u(this,ye,r(this,N).map(t=>String(t)).join(""))}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof tt&&r(s,U)===this))throw new Error("invalid part: "+s);r(this,N).push(s);}}toJSON(){let t=this.type===null?r(this,N).slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...r(this,N).map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,G)||r(r(this,G),ne)&&r(this,U)?.type==="!")&&t.push({}),t}isStart(){if(r(this,G)===this)return true;if(!r(this,U)?.isStart())return false;if(r(this,re)===0)return true;let t=r(this,U);for(let s=0;s<r(this,re);s++){let i=r(t,N)[s];if(!(i instanceof tt&&i.type==="!"))return false}return true}isEnd(){if(r(this,G)===this||r(this,U)?.type==="!")return true;if(!r(this,U)?.isEnd())return false;if(!this.type)return r(this,U)?.isEnd();let t=r(this,U)?r(r(this,U),N).length:0;return r(this,re)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this));}clone(t){let s=new tt(this.type,t);for(let i of r(this,N))s.copyIn(i);return s}static fromGlob(t,s={}){var n;let i=new tt(null,void 0,s);return g(n=tt,ue,Bs).call(n,t,i,0,s),i}toMMPattern(){if(this!==r(this,G))return r(this,G).toMMPattern();let t=this.toString(),[s,i,n,o]=this.toRegExpSource();if(!(n||r(this,K)||r(this,Nt).nocase&&!r(this,Nt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,Nt).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return r(this,Nt)}toRegExpSource(t){let s=t??!!r(this,Nt).dot;if(r(this,G)===this&&g(this,Oe,$r).call(this),!this.type){let h=this.isStart()&&this.isEnd()&&!r(this,N).some(y=>typeof y!="string"),d=r(this,N).map(y=>{var w;let[b,S,v,E]=typeof y=="string"?g(w=tt,ue,Ur).call(w,y,r(this,K),h):y.toRegExpSource(t);return u(this,K,r(this,K)||v),u(this,Bt,r(this,Bt)||E),b}).join(""),f="";if(this.isStart()&&typeof r(this,N)[0]=="string"&&!(r(this,N).length===1&&ro.has(r(this,N)[0]))){let y=io,b=s&&y.has(d.charAt(0))||d.startsWith("\\.")&&y.has(d.charAt(2))||d.startsWith("\\.\\.")&&y.has(d.charAt(4)),S=!s&&!t&&y.has(d.charAt(0));f=b?so:S?Ds:"";}let p="";return this.isEnd()&&r(r(this,G),ne)&&r(this,U)?.type==="!"&&(p="(?:$|\\/)"),[f+d+p,_e(d),u(this,K,!!r(this,K)),r(this,Bt)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,Oe,Si).call(this,s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let h=this.toString();return u(this,N,[h]),this.type=null,u(this,K,void 0),[h,_e(this.toString()),false,false]}let a=!i||t||s||!Ds?"":g(this,Oe,Si).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let l="";if(this.type==="!"&&r(this,as))l=(this.isStart()&&!s?Ds:"")+qi;else {let h=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Ds:"")+Vi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=n+o+h;}return [l,_e(o),u(this,K,!!r(this,K)),r(this,Bt)]}},G=new WeakMap,K=new WeakMap,Bt=new WeakMap,N=new WeakMap,U=new WeakMap,re=new WeakMap,me=new WeakMap,ne=new WeakMap,Nt=new WeakMap,ye=new WeakMap,as=new WeakMap,Oe=new WeakSet,$r=function(){if(this!==r(this,G))throw new Error("should only call on root");if(r(this,ne))return this;this.toString(),u(this,ne,true);let t;for(;t=r(this,me).pop();){if(t.type!=="!")continue;let s=t,i=r(s,U);for(;i;){for(let n=r(s,re)+1;!i.type&&n<r(i,N).length;n++)for(let o of r(t,N)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r(i,N)[n]);}s=i,i=r(s,U);}}return this},ue=new WeakSet,Bs=function(t,s,i,n){var b,S;let o=false,a=false,l=-1,h=false;if(s.type===null){let v=i,E="";for(;v<t.length;){let w=t.charAt(v++);if(o||w==="\\"){o=!o,E+=w;continue}if(a){v===l+1?(w==="^"||w==="!")&&(h=true):w==="]"&&!(v===l+2&&h)&&(a=false),E+=w;continue}else if(w==="["){a=true,l=v,h=false,E+=w;continue}if(!n.noext&&Gi(w)&&t.charAt(v)==="("){s.push(E),E="";let O=new tt(w,s);v=g(b=tt,ue,Bs).call(b,t,O,v,n),s.push(O);continue}E+=w;}return s.push(E),v}let d=i+1,f=new tt(null,s),p=[],y="";for(;d<t.length;){let v=t.charAt(d++);if(o||v==="\\"){o=!o,y+=v;continue}if(a){d===l+1?(v==="^"||v==="!")&&(h=true):v==="]"&&!(d===l+2&&h)&&(a=false),y+=v;continue}else if(v==="["){a=true,l=d,h=false,y+=v;continue}if(Gi(v)&&t.charAt(d)==="("){f.push(y),y="";let E=new tt(v,f);f.push(E),d=g(S=tt,ue,Bs).call(S,t,E,d,n);continue}if(v==="|"){f.push(y),y="",p.push(f),f=new tt(null,s);continue}if(v===")")return y===""&&r(s,N).length===0&&u(s,as,true),f.push(y),y="",s.push(...p,f),d;y+=v;}return s.type=null,u(s,K,void 0),u(s,N,[t.substring(i-1)]),d},Si=function(t){return r(this,N).map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,n,o,a]=s.toRegExpSource(t);return u(this,Bt,r(this,Bt)||a),i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")},Ur=function(t,s,i=false){let n=false,o="",a=false;for(let l=0;l<t.length;l++){let h=t.charAt(l);if(n){n=false,o+=(no.has(h)?"\\":"")+h;continue}if(h==="\\"){l===t.length-1?o+="\\\\":n=true;continue}if(h==="["){let[d,f,p,y]=to(t,l);if(p){o+=d,a=a||f,l+=p-1,s=s||y;continue}}if(h==="*"){o+=i&&t==="*"?qi:Vi,s=true;continue}if(h==="?"){o+=Ii,s=true;continue}o+=oo(h);}return [o,_e(t),!!s,a]},m(tt,ue),tt),Br=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=false}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),lt=(e,t,s={})=>(Ys(t),!s.nocomment&&t.charAt(0)==="#"?false:new de(t,s).match(e)),ao=/^\*+([^+@!?\*\[\(]*)$/,lo=e=>t=>!t.startsWith(".")&&t.endsWith(e),ho=e=>t=>t.endsWith(e),co=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),uo=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),po=/^\*+\.\*+$/,fo=e=>!e.startsWith(".")&&e.includes("."),go=e=>e!=="."&&e!==".."&&e.includes("."),mo=/^\.\*+$/,yo=e=>e!=="."&&e!==".."&&e.startsWith("."),wo=/^\*+$/,bo=e=>e.length!==0&&!e.startsWith("."),vo=e=>e.length!==0&&e!=="."&&e!=="..",So=/^\?+([^+@!?\*\[\(]*)?$/,xo=([e,t=""])=>{let s=Gr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Eo=([e,t=""])=>{let s=Vr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Co=([e,t=""])=>{let s=Vr([e]);return t?i=>s(i)&&i.endsWith(t):s},ko=([e,t=""])=>{let s=Gr([e]);return t?i=>s(i)&&i.endsWith(t):s},Gr=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Vr=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},qr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ji={win32:{sep:"\\"},posix:{sep:"/"}},Oo=qr==="win32"?Ji.win32.sep:Ji.posix.sep;lt.sep=Oo;var at=Symbol("globstar **");lt.GLOBSTAR=at;var Ro="[^/]",To=Ro+"*?",Mo="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ao="(?:(?!(?:\\/|^)\\.).)*?",Lo=(e,t={})=>s=>lt(s,e,t);lt.filter=Lo;var yt=(e,t={})=>Object.assign({},e,t),_o=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return lt;let t=lt;return Object.assign((s,i,n={})=>t(s,i,yt(e,n)),{Minimatch:class extends t.Minimatch{constructor(s,i={}){super(s,yt(e,i));}static defaults(s){return t.defaults(yt(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,i,n={}){super(s,i,yt(e,n));}static fromGlob(s,i={}){return t.AST.fromGlob(s,yt(e,i))}},unescape:(s,i={})=>t.unescape(s,yt(e,i)),escape:(s,i={})=>t.escape(s,yt(e,i)),filter:(s,i={})=>t.filter(s,yt(e,i)),defaults:s=>t.defaults(yt(e,s)),makeRe:(s,i={})=>t.makeRe(s,yt(e,i)),braceExpand:(s,i={})=>t.braceExpand(s,yt(e,i)),match:(s,i,n={})=>t.match(s,i,yt(e,n)),sep:t.sep,GLOBSTAR:at})};lt.defaults=_o;var Jr=(e,t={})=>(Ys(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Jn(e,{max:t.braceExpandMax}));lt.braceExpand=Jr;var Fo=(e,t={})=>new de(e,t).makeRe();lt.makeRe=Fo;var Po=(e,t,s={})=>{let i=new de(t,s);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};lt.match=Po;var Hi=/[?*]|[+@!]\(.*?\)|\[|\]/,Do=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),de=class{constructor(e,t={}){c(this,"options");c(this,"set");c(this,"pattern");c(this,"windowsPathsNoEscape");c(this,"nonegate");c(this,"negate");c(this,"comment");c(this,"empty");c(this,"preserveMultipleSlashes");c(this,"partial");c(this,"globSet");c(this,"globParts");c(this,"nocase");c(this,"isWindows");c(this,"platform");c(this,"windowsNoMagicRoot");c(this,"regexp");Ys(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||qr,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!t.nonegate,this.comment=false,this.empty=false,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make();}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return true;for(let e of this.set)for(let t of e)if(typeof t!="string")return true;return false}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=n[0]===""&&n[1]===""&&(n[2]==="?"||!Hi.test(n[2]))&&!Hi.test(n[3]),h=/^[a-z]:/i.test(n[0]);if(l)return [...n.slice(0,4),...n.slice(4).map(d=>this.parse(d))];if(h)return [n[0],...n.slice(1).map(d=>this.parse(d))]}return n.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(n=>n.indexOf(false)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(e){if(this.options.noglobstar)for(let s=0;s<e.length;s++)for(let i=0;i<e[s].length;i++)e[s][i]==="**"&&(e[s][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let i=s;for(;t[i+1]==="**";)i++;i!==s&&t.splice(s,i-s);}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,i)=>{let n=s[s.length-1];return i==="**"&&n==="**"?s:i===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(s.pop(),s):(s.push(i),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let n=e[i];i===1&&n===""&&e[0]===""||(n==="."||n==="")&&(t=true,e.splice(i,1),i--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=true,e.pop());}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){let i=e[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=true,e.splice(s-1,2),s-=2);}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=false;do{t=false;for(let s of e){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let a=s[i+1],l=s[i+2],h=s[i+3];if(a!==".."||!l||l==="."||l===".."||!h||h==="."||h==="..")continue;t=true,s.splice(i,1);let d=s.slice(0);d[i]="**",e.push(d),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(t=true,s.splice(o,1),o--);}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=true,s.pop());}let n=0;for(;(n=s.indexOf("..",n+1))!==-1;){let o=s[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=true;let a=n===1&&s[n+1]==="**"?["."]:[];s.splice(n-1,2,...a),s.length===0&&s.push(""),n-=2;}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){let i=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(i){e[t]=[],e[s]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,s=false){let i=0,n=0,o=[],a="";for(;i<e.length&&n<t.length;)if(e[i]===t[n])o.push(a==="b"?t[n]:e[i]),i++,n++;else if(s&&e[i]==="**"&&t[n]===e[i+1])o.push(e[i]),i++;else if(s&&t[n]==="**"&&e[i]===t[n+1])o.push(t[n]),n++;else if(e[i]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="b")return false;a="a",o.push(e[i]),i++,n++;}else if(t[n]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return false;a="b",o.push(t[n]),i++,n++;}else return false;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=false,s=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t;}matchOne(e,t,s=false){let i=this.options;if(this.isWindows){let S=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!S&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),w=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),O=v?3:S?0:void 0,T=w?3:E?0:void 0;if(typeof O=="number"&&typeof T=="number"){let[C,k]=[e[O],t[T]];C.toLowerCase()===k.toLowerCase()&&(t[T]=C,T>O?t=t.slice(T):O>T&&(e=e.slice(O)));}}let{optimizationLevel:n=1}=this.options;n>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var o=0,a=0,l=e.length,h=t.length;o<l&&a<h;o++,a++){this.debug("matchOne loop");var d=t[a],f=e[o];if(this.debug(t,d,f),d===false)return false;if(d===at){this.debug("GLOBSTAR",[t,d,f]);var p=o,y=a+1;if(y===h){for(this.debug("** at the end");o<l;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return false;return true}for(;p<l;){var b=e[p];if(this.debug(`
|
|
1
|
+
'use strict';var zi=require('path'),Rn=require('fs/promises'),Zo=require('fs'),Fa=require('zod'),url=require('url'),events=require('events'),Xr=require('stream'),string_decoder=require('string_decoder');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var zi__default=/*#__PURE__*/_interopDefault(zi);var Rn__default=/*#__PURE__*/_interopDefault(Rn);var Zo__namespace=/*#__PURE__*/_interopNamespace(Zo);var Fa__default=/*#__PURE__*/_interopDefault(Fa);var Xr__default=/*#__PURE__*/_interopDefault(Xr);var _n=Object.defineProperty;var Ui=e=>{throw TypeError(e)};var Fn=(e,t,s)=>t in e?_n(e,t,{enumerable:true,configurable:true,writable:true,value:s}):e[t]=s;var u=(e,t,s)=>Fn(e,typeof t!="symbol"?t+"":t,s),li=(e,t,s)=>t.has(e)||Ui("Cannot "+s);var r=(e,t,s)=>(li(e,t,"read from private field"),s?s.call(e):t.get(e)),m=(e,t,s)=>t.has(e)?Ui("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),d=(e,t,s,i)=>(li(e,t,"write to private field"),t.set(e,s),s),g=(e,t,s)=>(li(e,t,"access private method"),s);var Fs=(e,t,s,i)=>({set _(n){d(e,t,n);},get _(){return r(e,t,i)}});var Ps=class{constructor(t="http://localhost:11434"){this.baseURL=t;}async*streamChat(t){let s=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:true})});if(!s.ok)throw new Error(`Ollama API error: ${s.status} ${s.statusText}`);if(!s.body)throw new Error("Response body is null");let i=s.body.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:a,value:l}=await i.read();if(a){if(o.trim())try{yield JSON.parse(o);}catch{}break}o+=n.decode(l,{stream:!0});let h=o.split(`
|
|
2
|
+
`);o=h.pop()||"";for(let c of h){let f=c.trim();if(f)try{yield JSON.parse(f);}catch{}}}}finally{i.releaseLock();}}async chat(t){let s=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!s.ok)throw new Error(`Ollama API error: ${s.status} ${s.statusText}`);return s.json()}};var Le={numCtx:262144,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},Pn=["numCtx","repeatPenalty","numPredict"];var Qt=class extends Error{constructor(s,i){super(s);this.cause=i;this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},hi=class extends Qt{constructor(s,i,n){super(s,n);this.url=i;this.name="ConnectionError";}},ci=class extends Qt{constructor(s,i){super(`Model not found: ${s}`,i);this.modelId=s;this.name="ModelNotFoundError";}},ui=class extends Qt{constructor(s,i,n,o){super(s,o);this.field=i;this.value=n;this.name="ValidationError";}},di=class extends Qt{constructor(s,i,n){super(s,n);this.timeoutMs=i;this.name="TimeoutError";}},Je=class extends Qt{constructor(s,i,n){super(`Invalid tool definition for "${s}": missing ${i}`,n);this.toolName=s;this.missingField=i;this.name="InvalidToolDefinitionError";}};var Dr=(e,t,s)=>{let i=e instanceof RegExp?Bi(e,s):e,n=t instanceof RegExp?Bi(t,s):t,o=i!==null&&n!=null&&Dn(i,n,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+n.length)}},Bi=(e,t)=>{let s=t.match(e);return s?s[0]:null},Dn=(e,t,s)=>{let i,n,o,a,l,h=s.indexOf(e),c=s.indexOf(t,h+1),f=h;if(h>=0&&c>0){if(e===t)return [h,c];for(i=[],o=s.length;f>=0&&!l;){if(f===h)i.push(f),h=s.indexOf(e,f+1);else if(i.length===1){let p=i.pop();p!==void 0&&(l=[p,c]);}else n=i.pop(),n!==void 0&&n<o&&(o=n,a=c),c=s.indexOf(t,f+1);f=h<c&&h>=0?h:c;}i.length&&a!==void 0&&(l=[o,a]);}return l},Ir="\0SLASH"+Math.random()+"\0",Nr="\0OPEN"+Math.random()+"\0",Di="\0CLOSE"+Math.random()+"\0",jr="\0COMMA"+Math.random()+"\0",Wr="\0PERIOD"+Math.random()+"\0",In=new RegExp(Ir,"g"),Nn=new RegExp(Nr,"g"),jn=new RegExp(Di,"g"),Wn=new RegExp(jr,"g"),zn=new RegExp(Wr,"g"),$n=/\\\\/g,Un=/\\{/g,Bn=/\\}/g,Gn=/\\,/g,Vn=/\\./g,qn=1e5;function pi(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Jn(e){return e.replace($n,Ir).replace(Un,Nr).replace(Bn,Di).replace(Gn,jr).replace(Vn,Wr)}function Hn(e){return e.replace(In,"\\").replace(Nn,"{").replace(jn,"}").replace(Wn,",").replace(zn,".")}function zr(e){if(!e)return [""];let t=[],s=Dr("{","}",e);if(!s)return e.split(",");let{pre:i,body:n,post:o}=s,a=i.split(",");a[a.length-1]+="{"+n+"}";let l=zr(o);return o.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),t.push.apply(t,a),t}function Zn(e,t={}){if(!e)return [];let{max:s=qn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ts(Jn(e),s,true).map(Hn)}function Kn(e){return "{"+e+"}"}function Yn(e){return /^-?0\d/.test(e)}function Qn(e,t){return e<=t}function Xn(e,t){return e>=t}function ts(e,t,s){let i=[],n=Dr("{","}",e);if(!n)return [e];let o=n.pre,a=n.post.length?ts(n.post,t,false):[""];if(/\$$/.test(n.pre))for(let l=0;l<a.length&&l<t;l++){let h=o+"{"+n.body+"}"+a[l];i.push(h);}else {let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),h=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=l||h,f=n.body.indexOf(",")>=0;if(!c&&!f)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+Di+n.post,ts(e,t,true)):[e];let p;if(c)p=n.body.split(/\.\./);else if(p=zr(n.body),p.length===1&&p[0]!==void 0&&(p=ts(p[0],t,false).map(Kn),p.length===1))return a.map(b=>n.pre+p[0]+b);let y;if(c&&p[0]!==void 0&&p[1]!==void 0){let b=pi(p[0]),S=pi(p[1]),v=Math.max(p[0].length,p[1].length),E=p.length===3&&p[2]!==void 0?Math.abs(pi(p[2])):1,w=Qn;S<b&&(E*=-1,w=Xn);let k=p.some(Yn);y=[];for(let M=b;w(M,S);M+=E){let C;if(h)C=String.fromCharCode(M),C==="\\"&&(C="");else if(C=String(M),k){let O=v-C.length;if(O>0){let T=new Array(O+1).join("0");M<0?C="-"+T+C.slice(1):C=T+C;}}y.push(C);}}else {y=[];for(let b=0;b<p.length;b++)y.push.apply(y,ts(p[b],t,false));}for(let b=0;b<y.length;b++)for(let S=0;S<a.length&&i.length<t;S++){let v=o+y[b]+a[S];(!s||c||v)&&i.push(v);}}return i}var Ys=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},to={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",true],"[:alpha:]":["\\p{L}\\p{Nl}",true],"[:ascii:]":["\\x00-\\x7f",false],"[:blank:]":["\\p{Zs}\\t",true],"[:cntrl:]":["\\p{Cc}",true],"[:digit:]":["\\p{Nd}",true],"[:graph:]":["\\p{Z}\\p{C}",true,true],"[:lower:]":["\\p{Ll}",true],"[:print:]":["\\p{C}",true],"[:punct:]":["\\p{P}",true],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",true],"[:upper:]":["\\p{Lu}",true],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",true],"[:xdigit:]":["A-Fa-f0-9",false]},He=e=>e.replace(/[[\]\\-]/g,"\\$&"),eo=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Gi=e=>e.join(""),so=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],n=[],o=s+1,a=false,l=false,h=false,c=false,f=s,p="";t:for(;o<e.length;){let S=e.charAt(o);if((S==="!"||S==="^")&&o===s+1){c=true,o++;continue}if(S==="]"&&a&&!h){f=o+1;break}if(a=true,S==="\\"&&!h){h=true,o++;continue}if(S==="["&&!h){for(let[v,[E,w,k]]of Object.entries(to))if(e.startsWith(v,o)){if(p)return ["$.",false,e.length-s,true];o+=v.length,k?n.push(E):i.push(E),l=l||w;continue t}}if(h=false,p){S>p?i.push(He(p)+"-"+He(S)):S===p&&i.push(He(S)),p="",o++;continue}if(e.startsWith("-]",o+1)){i.push(He(S+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=S,o+=2;continue}i.push(He(S)),o++;}if(f<o)return ["",false,0,false];if(!i.length&&!n.length)return ["$.",false,e.length-s,true];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!c){let S=i[0].length===2?i[0].slice(-1):i[0];return [eo(S),false,f-s,false]}let y="["+(c?"^":"")+Gi(i)+"]",b="["+(c?"":"^")+Gi(n)+"]";return [i.length&&n.length?"("+y+"|"+b+")":i.length?y:b,l,f-s,true]},_e=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=true}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),io=new Set(["!","?","+","*","@"]),Vi=e=>io.has(e),ro="(?!(?:^|/)\\.\\.?(?:$|/))",Ds="(?!\\.)",no=new Set(["[","."]),oo=new Set(["..","."]),ao=new Set("().*{}+?[]^$\\!"),lo=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ii="[^/]",qi=Ii+"*?",Ji=Ii+"+?",G,Y,Bt,N,U,re,me,ne,Nt,ye,as,ke,Ur,ue,tt,Bs,Si,Br,$r=(tt=class{constructor(t,s,i={}){m(this,ke);u(this,"type");m(this,G);m(this,Y);m(this,Bt,false);m(this,N,[]);m(this,U);m(this,re);m(this,me);m(this,ne,false);m(this,Nt);m(this,ye);m(this,as,false);this.type=t,t&&d(this,Y,true),d(this,U,s),d(this,G,r(this,U)?r(r(this,U),G):this),d(this,Nt,r(this,G)===this?i:r(r(this,G),Nt)),d(this,me,r(this,G)===this?[]:r(r(this,G),me)),t==="!"&&!r(r(this,G),ne)&&r(this,me).push(this),d(this,re,r(this,U)?r(r(this,U),N).length:0);}get hasMagic(){if(r(this,Y)!==void 0)return r(this,Y);for(let t of r(this,N))if(typeof t!="string"&&(t.type||t.hasMagic))return d(this,Y,true);return r(this,Y)}toString(){return r(this,ye)!==void 0?r(this,ye):this.type?d(this,ye,this.type+"("+r(this,N).map(t=>String(t)).join("|")+")"):d(this,ye,r(this,N).map(t=>String(t)).join(""))}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof tt&&r(s,U)===this))throw new Error("invalid part: "+s);r(this,N).push(s);}}toJSON(){let t=this.type===null?r(this,N).slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...r(this,N).map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,G)||r(r(this,G),ne)&&r(this,U)?.type==="!")&&t.push({}),t}isStart(){if(r(this,G)===this)return true;if(!r(this,U)?.isStart())return false;if(r(this,re)===0)return true;let t=r(this,U);for(let s=0;s<r(this,re);s++){let i=r(t,N)[s];if(!(i instanceof tt&&i.type==="!"))return false}return true}isEnd(){if(r(this,G)===this||r(this,U)?.type==="!")return true;if(!r(this,U)?.isEnd())return false;if(!this.type)return r(this,U)?.isEnd();let t=r(this,U)?r(r(this,U),N).length:0;return r(this,re)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this));}clone(t){let s=new tt(this.type,t);for(let i of r(this,N))s.copyIn(i);return s}static fromGlob(t,s={}){var n;let i=new tt(null,void 0,s);return g(n=tt,ue,Bs).call(n,t,i,0,s),i}toMMPattern(){if(this!==r(this,G))return r(this,G).toMMPattern();let t=this.toString(),[s,i,n,o]=this.toRegExpSource();if(!(n||r(this,Y)||r(this,Nt).nocase&&!r(this,Nt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,Nt).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return r(this,Nt)}toRegExpSource(t){let s=t??!!r(this,Nt).dot;if(r(this,G)===this&&g(this,ke,Ur).call(this),!this.type){let h=this.isStart()&&this.isEnd()&&!r(this,N).some(y=>typeof y!="string"),c=r(this,N).map(y=>{var w;let[b,S,v,E]=typeof y=="string"?g(w=tt,ue,Br).call(w,y,r(this,Y),h):y.toRegExpSource(t);return d(this,Y,r(this,Y)||v),d(this,Bt,r(this,Bt)||E),b}).join(""),f="";if(this.isStart()&&typeof r(this,N)[0]=="string"&&!(r(this,N).length===1&&oo.has(r(this,N)[0]))){let y=no,b=s&&y.has(c.charAt(0))||c.startsWith("\\.")&&y.has(c.charAt(2))||c.startsWith("\\.\\.")&&y.has(c.charAt(4)),S=!s&&!t&&y.has(c.charAt(0));f=b?ro:S?Ds:"";}let p="";return this.isEnd()&&r(r(this,G),ne)&&r(this,U)?.type==="!"&&(p="(?:$|\\/)"),[f+c+p,_e(c),d(this,Y,!!r(this,Y)),r(this,Bt)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,ke,Si).call(this,s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let h=this.toString();return d(this,N,[h]),this.type=null,d(this,Y,void 0),[h,_e(this.toString()),false,false]}let a=!i||t||s||!Ds?"":g(this,ke,Si).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let l="";if(this.type==="!"&&r(this,as))l=(this.isStart()&&!s?Ds:"")+Ji;else {let h=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Ds:"")+qi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=n+o+h;}return [l,_e(o),d(this,Y,!!r(this,Y)),r(this,Bt)]}},G=new WeakMap,Y=new WeakMap,Bt=new WeakMap,N=new WeakMap,U=new WeakMap,re=new WeakMap,me=new WeakMap,ne=new WeakMap,Nt=new WeakMap,ye=new WeakMap,as=new WeakMap,ke=new WeakSet,Ur=function(){if(this!==r(this,G))throw new Error("should only call on root");if(r(this,ne))return this;this.toString(),d(this,ne,true);let t;for(;t=r(this,me).pop();){if(t.type!=="!")continue;let s=t,i=r(s,U);for(;i;){for(let n=r(s,re)+1;!i.type&&n<r(i,N).length;n++)for(let o of r(t,N)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r(i,N)[n]);}s=i,i=r(s,U);}}return this},ue=new WeakSet,Bs=function(t,s,i,n){var b,S;let o=false,a=false,l=-1,h=false;if(s.type===null){let v=i,E="";for(;v<t.length;){let w=t.charAt(v++);if(o||w==="\\"){o=!o,E+=w;continue}if(a){v===l+1?(w==="^"||w==="!")&&(h=true):w==="]"&&!(v===l+2&&h)&&(a=false),E+=w;continue}else if(w==="["){a=true,l=v,h=false,E+=w;continue}if(!n.noext&&Vi(w)&&t.charAt(v)==="("){s.push(E),E="";let k=new tt(w,s);v=g(b=tt,ue,Bs).call(b,t,k,v,n),s.push(k);continue}E+=w;}return s.push(E),v}let c=i+1,f=new tt(null,s),p=[],y="";for(;c<t.length;){let v=t.charAt(c++);if(o||v==="\\"){o=!o,y+=v;continue}if(a){c===l+1?(v==="^"||v==="!")&&(h=true):v==="]"&&!(c===l+2&&h)&&(a=false),y+=v;continue}else if(v==="["){a=true,l=c,h=false,y+=v;continue}if(Vi(v)&&t.charAt(c)==="("){f.push(y),y="";let E=new tt(v,f);f.push(E),c=g(S=tt,ue,Bs).call(S,t,E,c,n);continue}if(v==="|"){f.push(y),y="",p.push(f),f=new tt(null,s);continue}if(v===")")return y===""&&r(s,N).length===0&&d(s,as,true),f.push(y),y="",s.push(...p,f),c;y+=v;}return s.type=null,d(s,Y,void 0),d(s,N,[t.substring(i-1)]),c},Si=function(t){return r(this,N).map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,n,o,a]=s.toRegExpSource(t);return d(this,Bt,r(this,Bt)||a),i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")},Br=function(t,s,i=false){let n=false,o="",a=false,l=false;for(let h=0;h<t.length;h++){let c=t.charAt(h);if(n){n=false,o+=(ao.has(c)?"\\":"")+c;continue}if(c==="*"){if(l)continue;l=true,o+=i&&/^[*]+$/.test(t)?Ji:qi,s=true;continue}else l=false;if(c==="\\"){h===t.length-1?o+="\\\\":n=true;continue}if(c==="["){let[f,p,y,b]=so(t,h);if(y){o+=f,a=a||p,h+=y-1,s=s||b;continue}}if(c==="?"){o+=Ii,s=true;continue}o+=lo(c);}return [o,_e(t),!!s,a]},m(tt,ue),tt),Gr=(e,{windowsPathsNoEscape:t=false,magicalBraces:s=false}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),lt=(e,t,s={})=>(Ys(t),!s.nocomment&&t.charAt(0)==="#"?false:new de(t,s).match(e)),ho=/^\*+([^+@!?\*\[\(]*)$/,co=e=>t=>!t.startsWith(".")&&t.endsWith(e),uo=e=>t=>t.endsWith(e),po=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),fo=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),go=/^\*+\.\*+$/,mo=e=>!e.startsWith(".")&&e.includes("."),yo=e=>e!=="."&&e!==".."&&e.includes("."),wo=/^\.\*+$/,bo=e=>e!=="."&&e!==".."&&e.startsWith("."),vo=/^\*+$/,So=e=>e.length!==0&&!e.startsWith("."),xo=e=>e.length!==0&&e!=="."&&e!=="..",Eo=/^\?+([^+@!?\*\[\(]*)?$/,Co=([e,t=""])=>{let s=Vr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Oo=([e,t=""])=>{let s=qr([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},ko=([e,t=""])=>{let s=qr([e]);return t?i=>s(i)&&i.endsWith(t):s},Ro=([e,t=""])=>{let s=Vr([e]);return t?i=>s(i)&&i.endsWith(t):s},Vr=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},qr=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Jr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Hi={win32:{sep:"\\"},posix:{sep:"/"}},Mo=Jr==="win32"?Hi.win32.sep:Hi.posix.sep;lt.sep=Mo;var at=Symbol("globstar **");lt.GLOBSTAR=at;var Lo="[^/]",To=Lo+"*?",Ao="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_o="(?:(?!(?:\\/|^)\\.).)*?",Fo=(e,t={})=>s=>lt(s,e,t);lt.filter=Fo;var yt=(e,t={})=>Object.assign({},e,t),Po=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return lt;let t=lt;return Object.assign((s,i,n={})=>t(s,i,yt(e,n)),{Minimatch:class extends t.Minimatch{constructor(s,i={}){super(s,yt(e,i));}static defaults(s){return t.defaults(yt(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,i,n={}){super(s,i,yt(e,n));}static fromGlob(s,i={}){return t.AST.fromGlob(s,yt(e,i))}},unescape:(s,i={})=>t.unescape(s,yt(e,i)),escape:(s,i={})=>t.escape(s,yt(e,i)),filter:(s,i={})=>t.filter(s,yt(e,i)),defaults:s=>t.defaults(yt(e,s)),makeRe:(s,i={})=>t.makeRe(s,yt(e,i)),braceExpand:(s,i={})=>t.braceExpand(s,yt(e,i)),match:(s,i,n={})=>t.match(s,i,yt(e,n)),sep:t.sep,GLOBSTAR:at})};lt.defaults=Po;var Hr=(e,t={})=>(Ys(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Zn(e,{max:t.braceExpandMax}));lt.braceExpand=Hr;var Do=(e,t={})=>new de(e,t).makeRe();lt.makeRe=Do;var Io=(e,t,s={})=>{let i=new de(t,s);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};lt.match=Io;var Zi=/[?*]|[+@!]\(.*?\)|\[|\]/,No=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),de=class{constructor(e,t={}){u(this,"options");u(this,"set");u(this,"pattern");u(this,"windowsPathsNoEscape");u(this,"nonegate");u(this,"negate");u(this,"comment");u(this,"empty");u(this,"preserveMultipleSlashes");u(this,"partial");u(this,"globSet");u(this,"globParts");u(this,"nocase");u(this,"isWindows");u(this,"platform");u(this,"windowsNoMagicRoot");u(this,"regexp");Ys(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||Jr,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!t.nonegate,this.comment=false,this.empty=false,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make();}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return true;for(let e of this.set)for(let t of e)if(typeof t!="string")return true;return false}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...n)=>console.error(...n)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=n[0]===""&&n[1]===""&&(n[2]==="?"||!Zi.test(n[2]))&&!Zi.test(n[3]),h=/^[a-z]:/i.test(n[0]);if(l)return [...n.slice(0,4),...n.slice(4).map(c=>this.parse(c))];if(h)return [n[0],...n.slice(1).map(c=>this.parse(c))]}return n.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(n=>n.indexOf(false)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){let o=this.set[n];o[0]===""&&o[1]===""&&this.globParts[n][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(e){if(this.options.noglobstar)for(let s=0;s<e.length;s++)for(let i=0;i<e[s].length;i++)e[s][i]==="**"&&(e[s][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let i=s;for(;t[i+1]==="**";)i++;i!==s&&t.splice(s,i-s);}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,i)=>{let n=s[s.length-1];return i==="**"&&n==="**"?s:i===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(s.pop(),s):(s.push(i),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let n=e[i];i===1&&n===""&&e[0]===""||(n==="."||n==="")&&(t=true,e.splice(i,1),i--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=true,e.pop());}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){let i=e[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=true,e.splice(s-1,2),s-=2);}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=false;do{t=false;for(let s of e){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let a=s[i+1],l=s[i+2],h=s[i+3];if(a!==".."||!l||l==="."||l===".."||!h||h==="."||h==="..")continue;t=true,s.splice(i,1);let c=s.slice(0);c[i]="**",e.push(c),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(t=true,s.splice(o,1),o--);}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=true,s.pop());}let n=0;for(;(n=s.indexOf("..",n+1))!==-1;){let o=s[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=true;let a=n===1&&s[n+1]==="**"?["."]:[];s.splice(n-1,2,...a),s.length===0&&s.push(""),n-=2;}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){let i=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(i){e[t]=[],e[s]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,s=false){let i=0,n=0,o=[],a="";for(;i<e.length&&n<t.length;)if(e[i]===t[n])o.push(a==="b"?t[n]:e[i]),i++,n++;else if(s&&e[i]==="**"&&t[n]===e[i+1])o.push(e[i]),i++;else if(s&&t[n]==="**"&&e[i]===t[n+1])o.push(t[n]),n++;else if(e[i]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="b")return false;a="a",o.push(e[i]),i++,n++;}else if(t[n]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return false;a="b",o.push(t[n]),i++,n++;}else return false;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=false,s=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t;}matchOne(e,t,s=false){let i=this.options;if(this.isWindows){let S=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!S&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),w=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),k=v?3:S?0:void 0,M=w?3:E?0:void 0;if(typeof k=="number"&&typeof M=="number"){let[C,O]=[e[k],t[M]];C.toLowerCase()===O.toLowerCase()&&(t[M]=C,M>k?t=t.slice(M):k>M&&(e=e.slice(k)));}}let{optimizationLevel:n=1}=this.options;n>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var o=0,a=0,l=e.length,h=t.length;o<l&&a<h;o++,a++){this.debug("matchOne loop");var c=t[a],f=e[o];if(this.debug(t,c,f),c===false)return false;if(c===at){this.debug("GLOBSTAR",[t,c,f]);var p=o,y=a+1;if(y===h){for(this.debug("** at the end");o<l;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return false;return true}for(;p<l;){var b=e[p];if(this.debug(`
|
|
3
3
|
globstar while`,e,p,t,y,b),this.matchOne(e.slice(p),t.slice(y),s))return this.debug("globstar found match!",p,l,b),true;if(b==="."||b===".."||!i.dot&&b.charAt(0)==="."){this.debug("dot detected!",e,p,t,y);break}this.debug("globstar swallow a segment, and continue"),p++;}return !!(s&&(this.debug(`
|
|
4
|
-
>>> no match, partial?`,e,p,t,y),p===l))}let S;if(typeof d=="string"?(S=f===d,this.debug("string match",d,f,S)):(S=d.test(f),this.debug("pattern match",d,f,S)),!S)return false}if(o===l&&a===h)return true;if(o===l)return s;if(a===h)return o===l-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Jr(this.pattern,this.options)}parse(e){Ys(e);let t=this.options;if(e==="**")return at;if(e==="")return "";let s,i=null;(s=e.match(wo))?i=t.dot?vo:bo:(s=e.match(ao))?i=(t.nocase?t.dot?uo:co:t.dot?ho:lo)(s[1]):(s=e.match(So))?i=(t.nocase?t.dot?Eo:xo:t.dot?Co:ko)(s):(s=e.match(po))?i=t.dot?go:fo:(s=e.match(mo))&&(i=yo);let n=zr.fromGlob(e,this.options).toMMPattern();return i&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:i}),n}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let e=this.set;if(!e.length)return this.regexp=false,this.regexp;let t=this.options,s=t.noglobstar?To:t.dot?Mo:Ao,i=new Set(t.nocase?["i"]:[]),n=e.map(l=>{let h=l.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?Do(f):f===at?at:f._src});h.forEach((f,p)=>{let y=h[p+1],b=h[p-1];f!==at||b===at||(b===void 0?y!==void 0&&y!==at?h[p+1]="(?:\\/|"+s+"\\/)?"+y:h[p]=s:y===void 0?h[p-1]=b+"(?:\\/|\\/"+s+")?":y!==at&&(h[p-1]=b+"(?:\\/|\\/"+s+"\\/)"+y,h[p+1]=at));});let d=h.filter(f=>f!==at);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return "(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];n="^"+o+n+a+"$",this.partial&&(n="^(?:\\/|"+o+n.slice(1,-1)+a+")$"),this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...i].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return false;if(this.empty)return e==="";if(e==="/"&&t)return true;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let n=this.set;this.debug(this.pattern,"set",n);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<n.length;a++){let l=n[a],h=i;if(s.matchBase&&l.length===1&&(h=[o]),this.matchOne(h,l,t))return s.flipNegate?true:!this.negate}return s.flipNegate?false:this.negate}static defaults(e){return lt.defaults(e).Minimatch}};lt.AST=zr;lt.Minimatch=de;lt.escape=Br;lt.unescape=_e;var No=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Hr=new Set,xi=typeof process=="object"&&process?process:{},Zr=(e,t,s,i)=>{typeof xi.emitWarning=="function"?xi.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`);},Qs=globalThis.AbortController,Zi=globalThis.AbortSignal;if(typeof Qs>"u"){Zi=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(s,i){this._onabort.push(i);}},Qs=class{constructor(){c(this,"signal",new Zi);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s);}}};let e=xi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=false,Zr("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",t));};}var jo=e=>!Hr.has(e),te=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Kr=e=>te(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Gs:null:null,Gs=class extends Array{constructor(e){super(e),this.fill(0);}},zt,Fe,Wo=(zt=class{constructor(t,s){c(this,"heap");c(this,"length");if(!r(zt,Fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0;}static create(t){let s=Kr(t);if(!s)return [];u(zt,Fe,true);let i=new zt(t,s);return u(zt,Fe,false),i}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},Fe=new WeakMap,m(zt,Fe,false),zt),cr,ur,bt,ut,kt,we,Ot,Pe,De,Rt,V,Tt,B,j,_,rt,dt,st,Y,Mt,Q,At,Lt,pt,ft,_t,oe,nt,Ie,x,Ei,be,Gt,ls,gt,Yr,ve,Ne,hs,ee,se,Ci,Vs,qs,I,ki,es,ie,Oi,je,ei=(je=class{constructor(t){m(this,x);m(this,bt);m(this,ut);m(this,kt);m(this,we);m(this,Ot);m(this,Pe);m(this,De);m(this,Rt);c(this,"ttl");c(this,"ttlResolution");c(this,"ttlAutopurge");c(this,"updateAgeOnGet");c(this,"updateAgeOnHas");c(this,"allowStale");c(this,"noDisposeOnSet");c(this,"noUpdateTTL");c(this,"maxEntrySize");c(this,"sizeCalculation");c(this,"noDeleteOnFetchRejection");c(this,"noDeleteOnStaleGet");c(this,"allowStaleOnFetchAbort");c(this,"allowStaleOnFetchRejection");c(this,"ignoreFetchAbort");m(this,V);m(this,Tt);m(this,B);m(this,j);m(this,_);m(this,rt);m(this,dt);m(this,st);m(this,Y);m(this,Mt);m(this,Q);m(this,At);m(this,Lt);m(this,pt);m(this,ft);m(this,_t);m(this,oe);m(this,nt);m(this,Ie);m(this,be,()=>{});m(this,Gt,()=>{});m(this,ls,()=>{});m(this,gt,()=>false);m(this,ve,t=>{});m(this,Ne,(t,s,i)=>{});m(this,hs,(t,s,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,cr,"LRUCache");let{max:s=0,ttl:i,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:d,onInsert:f,disposeAfter:p,noDisposeOnSet:y,noUpdateTTL:b,maxSize:S=0,maxEntrySize:v=0,sizeCalculation:E,fetchMethod:w,memoMethod:O,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:k,allowStaleOnFetchAbort:M,ignoreFetchAbort:F,perf:D}=t;if(D!==void 0&&typeof D?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,Rt,D??No),s!==0&&!te(s))throw new TypeError("max option must be a nonnegative integer");let A=s?Kr(s):Array;if(!A)throw new Error("invalid max value: "+s);if(u(this,bt,s),u(this,ut,S),this.maxEntrySize=v||r(this,ut),this.sizeCalculation=E,this.sizeCalculation){if(!r(this,ut)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(O!==void 0&&typeof O!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,De,O),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,Pe,w),u(this,oe,!!w),u(this,B,new Map),u(this,j,new Array(s).fill(void 0)),u(this,_,new Array(s).fill(void 0)),u(this,rt,new A(s)),u(this,dt,new A(s)),u(this,st,0),u(this,Y,0),u(this,Mt,Wo.create(s)),u(this,V,0),u(this,Tt,0),typeof d=="function"&&u(this,kt,d),typeof f=="function"&&u(this,we,f),typeof p=="function"?(u(this,Ot,p),u(this,Q,[])):(u(this,Ot,void 0),u(this,Q,void 0)),u(this,_t,!!r(this,kt)),u(this,Ie,!!r(this,we)),u(this,nt,!!r(this,Ot)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!k,this.allowStaleOnFetchAbort=!!M,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(r(this,ut)!==0&&!te(r(this,ut)))throw new TypeError("maxSize must be a positive integer if specified");if(!te(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,x,Yr).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=te(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!te(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,x,Ei).call(this);}if(r(this,bt)===0&&this.ttl===0&&r(this,ut)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,bt)&&!r(this,ut)){let P="LRU_CACHE_UNBOUNDED";jo(P)&&(Hr.add(P),Zr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",P,je));}}get perf(){return r(this,Rt)}static unsafeExposeInternals(t){return {starts:r(t,Lt),ttls:r(t,pt),autopurgeTimers:r(t,ft),sizes:r(t,At),keyMap:r(t,B),keyList:r(t,j),valList:r(t,_),next:r(t,rt),prev:r(t,dt),get head(){return r(t,st)},get tail(){return r(t,Y)},free:r(t,Mt),isBackgroundFetch:s=>{var i;return g(i=t,x,I).call(i,s)},backgroundFetch:(s,i,n,o)=>{var a;return g(a=t,x,qs).call(a,s,i,n,o)},moveToTail:s=>{var i;return g(i=t,x,es).call(i,s)},indexes:s=>{var i;return g(i=t,x,ee).call(i,s)},rindexes:s=>{var i;return g(i=t,x,se).call(i,s)},isStale:s=>{var i;return r(i=t,gt).call(i,s)}}}get max(){return r(this,bt)}get maxSize(){return r(this,ut)}get calculatedSize(){return r(this,Tt)}get size(){return r(this,V)}get fetchMethod(){return r(this,Pe)}get memoMethod(){return r(this,De)}get dispose(){return r(this,kt)}get onInsert(){return r(this,we)}get disposeAfter(){return r(this,Ot)}getRemainingTTL(t){return r(this,B).has(t)?1/0:0}*entries(){for(let t of g(this,x,ee).call(this))r(this,_)[t]!==void 0&&r(this,j)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield [r(this,j)[t],r(this,_)[t]]);}*rentries(){for(let t of g(this,x,se).call(this))r(this,_)[t]!==void 0&&r(this,j)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield [r(this,j)[t],r(this,_)[t]]);}*keys(){for(let t of g(this,x,ee).call(this)){let s=r(this,j)[t];s!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield s);}}*rkeys(){for(let t of g(this,x,se).call(this)){let s=r(this,j)[t];s!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield s);}}*values(){for(let t of g(this,x,ee).call(this))r(this,_)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield r(this,_)[t]);}*rvalues(){for(let t of g(this,x,se).call(this))r(this,_)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield r(this,_)[t]);}[(ur=Symbol.iterator,cr=Symbol.toStringTag,ur)](){return this.entries()}find(t,s={}){for(let i of g(this,x,ee).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,r(this,j)[i],this))return this.get(r(this,j)[i],s)}}forEach(t,s=this){for(let i of g(this,x,ee).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,j)[i],this);}}rforEach(t,s=this){for(let i of g(this,x,se).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,j)[i],this);}}purgeStale(){let t=false;for(let s of g(this,x,se).call(this,{allowStale:true}))r(this,gt).call(this,s)&&(g(this,x,ie).call(this,r(this,j)[s],"expire"),t=true);return t}info(t){let s=r(this,B).get(t);if(s===void 0)return;let i=r(this,_)[s],n=g(this,x,I).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let o={value:n};if(r(this,pt)&&r(this,Lt)){let a=r(this,pt)[s],l=r(this,Lt)[s];if(a&&l){let h=a-(r(this,Rt).now()-l);o.ttl=h,o.start=Date.now();}}return r(this,At)&&(o.size=r(this,At)[s]),o}dump(){let t=[];for(let s of g(this,x,ee).call(this,{allowStale:true})){let i=r(this,j)[s],n=r(this,_)[s],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||i===void 0)continue;let a={value:o};if(r(this,pt)&&r(this,Lt)){a.ttl=r(this,pt)[s];let l=r(this,Rt).now()-r(this,Lt)[s];a.start=Math.floor(Date.now()-l);}r(this,At)&&(a.size=r(this,At)[s]),t.unshift([i,a]);}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let n=Date.now()-i.start;i.start=r(this,Rt).now()-n;}this.set(s,i.value,i);}}set(t,s,i={}){var y,b,S,v;if(s===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:h}=i,{noUpdateTTL:d=this.noUpdateTTL}=i,f=r(this,hs).call(this,t,s,i.size||0,l);if(this.maxEntrySize&&f>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),g(this,x,ie).call(this,t,"set"),this;let p=r(this,V)===0?void 0:r(this,B).get(t);if(p===void 0)p=r(this,V)===0?r(this,Y):r(this,Mt).length!==0?r(this,Mt).pop():r(this,V)===r(this,bt)?g(this,x,Vs).call(this,false):r(this,V),r(this,j)[p]=t,r(this,_)[p]=s,r(this,B).set(t,p),r(this,rt)[r(this,Y)]=p,r(this,dt)[p]=r(this,Y),u(this,Y,p),Fs(this,V)._++,r(this,Ne).call(this,p,f,h),h&&(h.set="add"),d=false,r(this,Ie)&&((y=r(this,we))==null||y.call(this,s,t,"add"));else {g(this,x,es).call(this,p);let E=r(this,_)[p];if(s!==E){if(r(this,oe)&&g(this,x,I).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=E;w!==void 0&&!a&&(r(this,_t)&&((b=r(this,kt))==null||b.call(this,w,t,"set")),r(this,nt)&&r(this,Q)?.push([w,t,"set"]));}else a||(r(this,_t)&&((S=r(this,kt))==null||S.call(this,E,t,"set")),r(this,nt)&&r(this,Q)?.push([E,t,"set"]));if(r(this,ve).call(this,p),r(this,Ne).call(this,p,f,h),r(this,_)[p]=s,h){h.set="replace";let w=E&&g(this,x,I).call(this,E)?E.__staleWhileFetching:E;w!==void 0&&(h.oldValue=w);}}else h&&(h.set="update");r(this,Ie)&&this.onInsert?.(s,t,s===E?"update":"replace");}if(n!==0&&!r(this,pt)&&g(this,x,Ei).call(this),r(this,pt)&&(d||r(this,ls).call(this,p,n,o),h&&r(this,Gt).call(this,h,p)),!a&&r(this,nt)&&r(this,Q)){let E=r(this,Q),w;for(;w=E?.shift();)(v=r(this,Ot))==null||v.call(this,...w);}return this}pop(){var t;try{for(;r(this,V);){let s=r(this,_)[r(this,st)];if(g(this,x,Vs).call(this,!0),g(this,x,I).call(this,s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(r(this,nt)&&r(this,Q)){let s=r(this,Q),i;for(;i=s?.shift();)(t=r(this,Ot))==null||t.call(this,...i);}}}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=s,o=r(this,B).get(t);if(o!==void 0){let a=r(this,_)[o];if(g(this,x,I).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,gt).call(this,o))n&&(n.has="stale",r(this,Gt).call(this,n,o));else return i&&r(this,be).call(this,o),n&&(n.has="hit",r(this,Gt).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,s={}){let{allowStale:i=this.allowStale}=s,n=r(this,B).get(t);if(n===void 0||!i&&r(this,gt).call(this,n))return;let o=r(this,_)[n];return g(this,x,I).call(this,o)?o.__staleWhileFetching:o}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:h=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:S=this.allowStaleOnFetchAbort,context:v,forceRefresh:E=false,status:w,signal:O}=s;if(!r(this,oe))return w&&(w.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:w});let T={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:d,noUpdateTTL:f,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:S,ignoreFetchAbort:b,status:w,signal:O},C=r(this,B).get(t);if(C===void 0){w&&(w.fetch="miss");let k=g(this,x,qs).call(this,t,C,T,v);return k.__returned=k}else {let k=r(this,_)[C];if(g(this,x,I).call(this,k)){let A=i&&k.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",A&&(w.returnedStale=true)),A?k.__staleWhileFetching:k.__returned=k}let M=r(this,gt).call(this,C);if(!E&&!M)return w&&(w.fetch="hit"),g(this,x,es).call(this,C),n&&r(this,be).call(this,C),w&&r(this,Gt).call(this,w,C),k;let F=g(this,x,qs).call(this,t,C,T,v),D=F.__staleWhileFetching!==void 0&&i;return w&&(w.fetch=M?"stale":"refresh",D&&M&&(w.returnedStale=true)),D?F.__staleWhileFetching:F.__returned=F}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=r(this,De);if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=s,l=this.get(t,a);if(!o&&l!==void 0)return l;let h=i(t,l,{options:a,context:n});return this.set(t,h,a),h}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=s,l=r(this,B).get(t);if(l!==void 0){let h=r(this,_)[l],d=g(this,x,I).call(this,h);return a&&r(this,Gt).call(this,a,l),r(this,gt).call(this,l)?(a&&(a.get="stale"),d?(a&&i&&h.__staleWhileFetching!==void 0&&(a.returnedStale=true),i?h.__staleWhileFetching:void 0):(o||g(this,x,ie).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?h:void 0)):(a&&(a.get="hit"),d?h.__staleWhileFetching:(g(this,x,es).call(this,l),n&&r(this,be).call(this,l),h))}else a&&(a.get="miss");}delete(t){return g(this,x,ie).call(this,t,"delete")}clear(){return g(this,x,Oi).call(this,"delete")}},bt=new WeakMap,ut=new WeakMap,kt=new WeakMap,we=new WeakMap,Ot=new WeakMap,Pe=new WeakMap,De=new WeakMap,Rt=new WeakMap,V=new WeakMap,Tt=new WeakMap,B=new WeakMap,j=new WeakMap,_=new WeakMap,rt=new WeakMap,dt=new WeakMap,st=new WeakMap,Y=new WeakMap,Mt=new WeakMap,Q=new WeakMap,At=new WeakMap,Lt=new WeakMap,pt=new WeakMap,ft=new WeakMap,_t=new WeakMap,oe=new WeakMap,nt=new WeakMap,Ie=new WeakMap,x=new WeakSet,Ei=function(){let t=new Gs(r(this,bt)),s=new Gs(r(this,bt));u(this,pt,t),u(this,Lt,s);let i=this.ttlAutopurge?new Array(r(this,bt)):void 0;u(this,ft,i),u(this,ls,(a,l,h=r(this,Rt).now())=>{if(s[a]=l!==0?h:0,t[a]=l,i?.[a]&&(clearTimeout(i[a]),i[a]=void 0),l!==0&&i){let d=setTimeout(()=>{r(this,gt).call(this,a)&&g(this,x,ie).call(this,r(this,j)[a],"expire");},l+1);d.unref&&d.unref(),i[a]=d;}}),u(this,be,a=>{s[a]=t[a]!==0?r(this,Rt).now():0;}),u(this,Gt,(a,l)=>{if(t[l]){let h=t[l],d=s[l];if(!h||!d)return;a.ttl=h,a.start=d,a.now=n||o();let f=a.now-d;a.remainingTTL=h-f;}});let n=0,o=()=>{let a=r(this,Rt).now();if(this.ttlResolution>0){n=a;let l=setTimeout(()=>n=0,this.ttlResolution);l.unref&&l.unref();}return a};this.getRemainingTTL=a=>{let l=r(this,B).get(a);if(l===void 0)return 0;let h=t[l],d=s[l];if(!h||!d)return 1/0;let f=(n||o())-d;return h-f},u(this,gt,a=>{let l=s[a],h=t[a];return !!h&&!!l&&(n||o())-l>h});},be=new WeakMap,Gt=new WeakMap,ls=new WeakMap,gt=new WeakMap,Yr=function(){let t=new Gs(r(this,bt));u(this,Tt,0),u(this,At,t),u(this,ve,s=>{u(this,Tt,r(this,Tt)-t[s]),t[s]=0;}),u(this,hs,(s,i,n,o)=>{if(g(this,x,I).call(this,i))return 0;if(!te(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(i,s),!te(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n}),u(this,Ne,(s,i,n)=>{if(t[s]=i,r(this,ut)){let o=r(this,ut)-t[s];for(;r(this,Tt)>o;)g(this,x,Vs).call(this,true);}u(this,Tt,r(this,Tt)+t[s]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,Tt));});},ve=new WeakMap,Ne=new WeakMap,hs=new WeakMap,ee=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,Y);!(!g(this,x,Ci).call(this,s)||((t||!r(this,gt).call(this,s))&&(yield s),s===r(this,st)));)s=r(this,dt)[s];},se=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,st);!(!g(this,x,Ci).call(this,s)||((t||!r(this,gt).call(this,s))&&(yield s),s===r(this,Y)));)s=r(this,rt)[s];},Ci=function(t){return t!==void 0&&r(this,B).get(r(this,j)[t])===t},Vs=function(t){var o;let s=r(this,st),i=r(this,j)[s],n=r(this,_)[s];return r(this,oe)&&g(this,x,I).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,_t)||r(this,nt))&&(r(this,_t)&&((o=r(this,kt))==null||o.call(this,n,i,"evict")),r(this,nt)&&r(this,Q)?.push([n,i,"evict"])),r(this,ve).call(this,s),r(this,ft)?.[s]&&(clearTimeout(r(this,ft)[s]),r(this,ft)[s]=void 0),t&&(r(this,j)[s]=void 0,r(this,_)[s]=void 0,r(this,Mt).push(s)),r(this,V)===1?(u(this,st,u(this,Y,0)),r(this,Mt).length=0):u(this,st,r(this,rt)[s]),r(this,B).delete(i),Fs(this,V)._--,s},qs=function(t,s,i,n){let o=s===void 0?void 0:r(this,_)[s];if(g(this,x,I).call(this,o))return o;let a=new Qs,{signal:l}=i;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let h={signal:a.signal,options:i,context:n},d=(v,E=false)=>{let{aborted:w}=a.signal,O=i.ignoreFetchAbort&&v!==void 0,T=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&v!==void 0);if(i.status&&(w&&!E?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,O&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),w&&!O&&!E)return p(a.signal.reason,T);let C=b,k=r(this,_)[s];return (k===b||O&&E&&k===void 0)&&(v===void 0?C.__staleWhileFetching!==void 0?r(this,_)[s]=C.__staleWhileFetching:g(this,x,ie).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,v,h.options))),v},f=v=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=v),p(v,false)),p=(v,E)=>{let{aborted:w}=a.signal,O=w&&i.allowStaleOnFetchAbort,T=O||i.allowStaleOnFetchRejection,C=T||i.noDeleteOnFetchRejection,k=b;if(r(this,_)[s]===b&&(!C||!E&&k.__staleWhileFetching===void 0?g(this,x,ie).call(this,t,"fetch"):O||(r(this,_)[s]=k.__staleWhileFetching)),T)return i.status&&k.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),k.__staleWhileFetching;if(k.__returned===k)throw v},y=(v,E)=>{var O;let w=(O=r(this,Pe))==null?void 0:O.call(this,t,o,h);w&&w instanceof Promise&&w.then(T=>v(T===void 0?void 0:T),E),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(v(void 0),i.allowStaleOnFetchAbort&&(v=T=>d(T,true)));});};i.status&&(i.status.fetchDispatched=true);let b=new Promise(y).then(d,f),S=Object.assign(b,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,S,{...h.options,status:void 0}),s=r(this,B).get(t)):r(this,_)[s]=S,S},I=function(t){if(!r(this,oe))return false;let s=t;return !!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Qs},ki=function(t,s){r(this,dt)[s]=t,r(this,rt)[t]=s;},es=function(t){t!==r(this,Y)&&(t===r(this,st)?u(this,st,r(this,rt)[t]):g(this,x,ki).call(this,r(this,dt)[t],r(this,rt)[t]),g(this,x,ki).call(this,r(this,Y),t),u(this,Y,t));},ie=function(t,s){var n,o;let i=false;if(r(this,V)!==0){let a=r(this,B).get(t);if(a!==void 0)if(r(this,ft)?.[a]&&(clearTimeout(r(this,ft)?.[a]),r(this,ft)[a]=void 0),i=true,r(this,V)===1)g(this,x,Oi).call(this,s);else {r(this,ve).call(this,a);let l=r(this,_)[a];if(g(this,x,I).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,_t)||r(this,nt))&&(r(this,_t)&&((n=r(this,kt))==null||n.call(this,l,t,s)),r(this,nt)&&r(this,Q)?.push([l,t,s])),r(this,B).delete(t),r(this,j)[a]=void 0,r(this,_)[a]=void 0,a===r(this,Y))u(this,Y,r(this,dt)[a]);else if(a===r(this,st))u(this,st,r(this,rt)[a]);else {let h=r(this,dt)[a];r(this,rt)[h]=r(this,rt)[a];let d=r(this,rt)[a];r(this,dt)[d]=r(this,dt)[a];}Fs(this,V)._--,r(this,Mt).push(a);}}if(r(this,nt)&&r(this,Q)?.length){let a=r(this,Q),l;for(;l=a?.shift();)(o=r(this,Ot))==null||o.call(this,...l);}return i},Oi=function(t){var s,i;for(let n of g(this,x,se).call(this,{allowStale:true})){let o=r(this,_)[n];if(g(this,x,I).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=r(this,j)[n];r(this,_t)&&((s=r(this,kt))==null||s.call(this,o,a,t)),r(this,nt)&&r(this,Q)?.push([o,a,t]);}}if(r(this,B).clear(),r(this,_).fill(void 0),r(this,j).fill(void 0),r(this,pt)&&r(this,Lt)){r(this,pt).fill(0),r(this,Lt).fill(0);for(let n of r(this,ft)??[])n!==void 0&&clearTimeout(n);r(this,ft)?.fill(void 0);}if(r(this,At)&&r(this,At).fill(0),u(this,st,0),u(this,Y,0),r(this,Mt).length=0,u(this,Tt,0),u(this,V,0),r(this,nt)&&r(this,Q)){let n=r(this,Q),o;for(;o=n?.shift();)(i=r(this,Ot))==null||i.call(this,...o);}},je),Ki=typeof process=="object"&&process?process:{stdout:null,stderr:null},Xo=e=>!!e&&typeof e=="object"&&(e instanceof Xs||e instanceof Qr__default.default||ta(e)||ea(e)),ta=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Qr__default.default.Writable.prototype.pipe,ea=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",$t=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),Xt=Symbol("emittedEnd"),Is=Symbol("emittingEnd"),Ze=Symbol("emittedError"),Ns=Symbol("closed"),Yi=Symbol("read"),js=Symbol("flush"),Qi=Symbol("flushChunk"),Et=Symbol("encoding"),Ae=Symbol("decoder"),J=Symbol("flowing"),Ke=Symbol("paused"),Le=Symbol("resume"),H=Symbol("buffer"),it=Symbol("pipes"),Z=Symbol("bufferLength"),fi=Symbol("bufferPush"),Ws=Symbol("bufferShift"),et=Symbol("objectMode"),$=Symbol("destroyed"),gi=Symbol("error"),mi=Symbol("emitData"),Xi=Symbol("emitEnd"),yi=Symbol("emitEnd2"),Dt=Symbol("async"),wi=Symbol("abort"),zs=Symbol("aborted"),Ye=Symbol("signal"),pe=Symbol("dataListeners"),ct=Symbol("discarded"),Qe=e=>Promise.resolve().then(e),sa=e=>e(),ia=e=>e==="end"||e==="finish"||e==="prefinish",ra=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,na=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Xr=class{constructor(e,t,s){c(this,"src");c(this,"dest");c(this,"opts");c(this,"ondrain");this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Le](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},oa=class extends Xr{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors);}},aa=e=>!!e.objectMode,la=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",dr,pr,fr,gr,mr,yr,wr,br,vr,Sr,xr,Er,Cr,kr,Or,Rr,Tr,Mr,Ar,Xs=class extends events.EventEmitter{constructor(...t){let s=t[0]||{};super();c(this,Ar,false);c(this,Mr,false);c(this,Tr,[]);c(this,Rr,[]);c(this,Or);c(this,kr);c(this,Cr);c(this,Er);c(this,xr,false);c(this,Sr,false);c(this,vr,false);c(this,br,false);c(this,wr,null);c(this,yr,0);c(this,mr,false);c(this,gr);c(this,fr,false);c(this,pr,0);c(this,dr,false);c(this,"writable",true);c(this,"readable",true);if(s.objectMode&&typeof s.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");aa(s)?(this[et]=true,this[Et]=null):la(s)?(this[Et]=s.encoding,this[et]=false):(this[et]=false,this[Et]=null),this[Dt]=!!s.async,this[Ae]=this[Et]?new string_decoder.StringDecoder(this[Et]):null,s&&s.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[H]}),s&&s.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[it]});let{signal:i}=s;i&&(this[Ye]=i,i.aborted?this[wi]():i.addEventListener("abort",()=>this[wi]()));}get bufferLength(){return this[Z]}get encoding(){return this[Et]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[et]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Dt]}set async(t){this[Dt]=this[Dt]||!!t;}[(Ar=J,Mr=Ke,Tr=it,Rr=H,Or=et,kr=Et,Cr=Dt,Er=Ae,xr=$t,Sr=Xt,vr=Is,br=Ns,wr=Ze,yr=Z,mr=$,gr=Ye,fr=zs,pr=pe,dr=ct,wi)](){this[zs]=true,this.emit("abort",this[Ye]?.reason),this.destroy(this[Ye]?.reason);}get aborted(){return this[zs]}set aborted(t){}write(t,s,i){if(this[zs])return false;if(this[$t])throw new Error("write after end");if(this[$])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof s=="function"&&(i=s,s="utf8"),s||(s="utf8");let n=this[Dt]?Qe:sa;if(!this[et]&&!Buffer.isBuffer(t)){if(na(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(ra(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[et]?(this[J]&&this[Z]!==0&&this[js](true),this[J]?this.emit("data",t):this[fi](t),this[Z]!==0&&this.emit("readable"),i&&n(i),this[J]):t.length?(typeof t=="string"&&!(s===this[Et]&&!this[Ae]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[Et]&&(t=this[Ae].write(t)),this[J]&&this[Z]!==0&&this[js](true),this[J]?this.emit("data",t):this[fi](t),this[Z]!==0&&this.emit("readable"),i&&n(i),this[J]):(this[Z]!==0&&this.emit("readable"),i&&n(i),this[J])}read(t){if(this[$])return null;if(this[ct]=false,this[Z]===0||t===0||t&&t>this[Z])return this[Ut](),null;this[et]&&(t=null),this[H].length>1&&!this[et]&&(this[H]=[this[Et]?this[H].join(""):Buffer.concat(this[H],this[Z])]);let s=this[Yi](t||null,this[H][0]);return this[Ut](),s}[Yi](t,s){if(this[et])this[Ws]();else {let i=s;t===i.length||t===null?this[Ws]():typeof i=="string"?(this[H][0]=i.slice(t),s=i.slice(0,t),this[Z]-=t):(this[H][0]=i.subarray(t),s=i.subarray(0,t),this[Z]-=t);}return this.emit("data",s),!this[H].length&&!this[$t]&&this.emit("drain"),s}end(t,s,i){return typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s="utf8"),t!==void 0&&this.write(t,s),i&&this.once("end",i),this[$t]=true,this.writable=false,(this[J]||!this[Ke])&&this[Ut](),this}[Le](){this[$]||(!this[pe]&&!this[it].length&&(this[ct]=true),this[Ke]=false,this[J]=true,this.emit("resume"),this[H].length?this[js]():this[$t]?this[Ut]():this.emit("drain"));}resume(){return this[Le]()}pause(){this[J]=false,this[Ke]=true,this[ct]=false;}get destroyed(){return this[$]}get flowing(){return this[J]}get paused(){return this[Ke]}[fi](t){this[et]?this[Z]+=1:this[Z]+=t.length,this[H].push(t);}[Ws](){return this[et]?this[Z]-=1:this[Z]-=this[H][0].length,this[H].shift()}[js](t=false){do;while(this[Qi](this[Ws]())&&this[H].length);!t&&!this[H].length&&!this[$t]&&this.emit("drain");}[Qi](t){return this.emit("data",t),this[J]}pipe(t,s){if(this[$])return t;this[ct]=false;let i=this[Xt];return s=s||{},t===Ki.stdout||t===Ki.stderr?s.end=false:s.end=s.end!==false,s.proxyErrors=!!s.proxyErrors,i?s.end&&t.end():(this[it].push(s.proxyErrors?new oa(this,t,s):new Xr(this,t,s)),this[Dt]?Qe(()=>this[Le]()):this[Le]()),t}unpipe(t){let s=this[it].find(i=>i.dest===t);s&&(this[it].length===1?(this[J]&&this[pe]===0&&(this[J]=false),this[it]=[]):this[it].splice(this[it].indexOf(s),1),s.unpipe());}addListener(t,s){return this.on(t,s)}on(t,s){let i=super.on(t,s);if(t==="data")this[ct]=false,this[pe]++,!this[it].length&&!this[J]&&this[Le]();else if(t==="readable"&&this[Z]!==0)super.emit("readable");else if(ia(t)&&this[Xt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ze]){let n=s;this[Dt]?Qe(()=>n.call(this,this[Ze])):n.call(this,this[Ze]);}return i}removeListener(t,s){return this.off(t,s)}off(t,s){let i=super.off(t,s);return t==="data"&&(this[pe]=this.listeners("data").length,this[pe]===0&&!this[ct]&&!this[it].length&&(this[J]=false)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[pe]=0,!this[ct]&&!this[it].length&&(this[J]=false)),s}get emittedEnd(){return this[Xt]}[Ut](){!this[Is]&&!this[Xt]&&!this[$]&&this[H].length===0&&this[$t]&&(this[Is]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ns]&&this.emit("close"),this[Is]=false);}emit(t,...s){let i=s[0];if(t!=="error"&&t!=="close"&&t!==$&&this[$])return false;if(t==="data")return !this[et]&&!i?false:this[Dt]?(Qe(()=>this[mi](i)),true):this[mi](i);if(t==="end")return this[Xi]();if(t==="close"){if(this[Ns]=true,!this[Xt]&&!this[$])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ze]=i,super.emit(gi,i);let o=!this[Ye]||this.listeners("error").length?super.emit("error",i):false;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let n=super.emit(t,...s);return this[Ut](),n}[mi](t){for(let i of this[it])i.dest.write(t)===false&&this.pause();let s=this[ct]?false:super.emit("data",t);return this[Ut](),s}[Xi](){return this[Xt]?false:(this[Xt]=true,this.readable=false,this[Dt]?(Qe(()=>this[yi]()),true):this[yi]())}[yi](){if(this[Ae]){let s=this[Ae].end();if(s){for(let i of this[it])i.dest.write(s);this[ct]||super.emit("data",s);}}for(let s of this[it])s.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[et]||(t.dataLength=0);let s=this.promise();return this.on("data",i=>{t.push(i),this[et]||(t.dataLength+=i.length);}),await s,t}async concat(){if(this[et])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Et]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,s)=>{this.on($,()=>s(new Error("stream destroyed"))),this.on("error",i=>s(i)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[ct]=false;let t=false,s=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return s();let i=this.read();if(i!==null)return Promise.resolve({done:false,value:i});if(this[$t])return s();let n,o,a=f=>{this.off("data",l),this.off("end",h),this.off($,d),s(),o(f);},l=f=>{this.off("error",a),this.off("end",h),this.off($,d),this.pause(),n({value:f,done:!!this[$t]});},h=()=>{this.off("error",a),this.off("data",l),this.off($,d),s(),n({done:true,value:void 0});},d=()=>a(new Error("stream destroyed"));return new Promise((f,p)=>{o=p,n=f,this.once($,d),this.once("error",a),this.once("end",h),this.once("data",l);})},throw:s,return:s,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[ct]=false;let t=false,s=()=>(this.pause(),this.off(gi,s),this.off($,s),this.off("end",s),t=true,{done:true,value:void 0}),i=()=>{if(t)return s();let n=this.read();return n===null?s():{done:false,value:n}};return this.once("end",s),this.once(gi,s),this.once($,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this}}}destroy(t){if(this[$])return t?this.emit("error",t):this.emit($),this;this[$]=true,this[ct]=true,this[H].length=0,this[Z]=0;let s=this;return typeof s.close=="function"&&!this[Ns]&&s.close(),t?this.emit("error",t):this.emit($),this}static get isStream(){return Xo}},ha=Jo.realpathSync.native,ss={lstatSync:Jo.lstatSync,readdir:Jo.readdir,readdirSync:Jo.readdirSync,readlinkSync:Jo.readlinkSync,realpathSync:ha,promises:{lstat:On.lstat,readdir:On.readdir,readlink:On.readlink,realpath:On.realpath}},tn=e=>!e||e===ss||e===Jo__namespace?ss:{...ss,...e,promises:{...ss.promises,...e.promises||{}}},en=/^\\\\\?\\([a-z]:)\\?$/i,ca=e=>e.replace(/\//g,"\\").replace(en,"$1\\"),ua=/[\\\/]/,vt=0,sn=1,rn=2,It=4,nn=6,on=8,fe=10,an=12,wt=15,Xe=~wt,bi=16,tr=32,is=64,Ct=128,$s=256,Js=512,er=is|Ct|Js,da=1023,vi=e=>e.isFile()?on:e.isDirectory()?It:e.isSymbolicLink()?fe:e.isCharacterDevice()?rn:e.isBlockDevice()?nn:e.isSocket()?an:e.isFIFO()?sn:vt,sr=new ei({max:2**12}),rs=e=>{let t=sr.get(e);if(t)return t;let s=e.normalize("NFKD");return sr.set(e,s),s},ir=new ei({max:2**12}),Us=e=>{let t=ir.get(e);if(t)return t;let s=rs(e.toLowerCase());return ir.set(e,s),s},rr=class extends ei{constructor(){super({max:256});}},pa=class extends ei{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1});}},ln=Symbol("PathScurry setAsCwd"),ot,cs,us,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,Es,Cs,ks,Os,Rs,ae,Se,jt,Vt,qt,Jt,L,xe,Ht,Wt,R,Ti,Hs,ns,Mi,Ai,os,Zs,Li,_i,Ks,hn,cn,un,Fi,We,ze,dn,Ee,Lr,ht=(Lr=class{constructor(e,t=vt,s,i,n,o,a){m(this,R);c(this,"name");c(this,"root");c(this,"roots");c(this,"parent");c(this,"nocase");c(this,"isCWD",false);m(this,ot);m(this,cs);m(this,us);m(this,ds);m(this,ps);m(this,fs);m(this,gs);m(this,ms);m(this,ys);m(this,ws);m(this,bs);m(this,vs);m(this,Ss);m(this,xs);m(this,Es);m(this,Cs);m(this,ks);m(this,Os);m(this,Rs);m(this,ae);m(this,Se);m(this,jt);m(this,Vt);m(this,qt);m(this,Jt);m(this,L);m(this,xe);m(this,Ht);m(this,Wt);m(this,We,[]);m(this,ze,false);m(this,Ee);this.name=e,u(this,ae,n?Us(e):rs(e)),u(this,L,t&da),this.nocase=n,this.roots=i,this.root=s||this,u(this,xe,o),u(this,jt,a.fullpath),u(this,qt,a.relative),u(this,Jt,a.relativePosix),this.parent=a.parent,this.parent?u(this,ot,r(this.parent,ot)):u(this,ot,tn(a.fs));}get dev(){return r(this,cs)}get mode(){return r(this,us)}get nlink(){return r(this,ds)}get uid(){return r(this,ps)}get gid(){return r(this,fs)}get rdev(){return r(this,gs)}get blksize(){return r(this,ms)}get ino(){return r(this,ys)}get size(){return r(this,ws)}get blocks(){return r(this,bs)}get atimeMs(){return r(this,vs)}get mtimeMs(){return r(this,Ss)}get ctimeMs(){return r(this,xs)}get birthtimeMs(){return r(this,Es)}get atime(){return r(this,Cs)}get mtime(){return r(this,ks)}get ctime(){return r(this,Os)}get birthtime(){return r(this,Rs)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,Se)!==void 0?r(this,Se):this.parent?u(this,Se,this.parent.depth()+1):u(this,Se,0)}childrenCache(){return r(this,xe)}resolve(e){var i;if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?g(i=this.getRoot(t),R,Ti).call(i,s):g(this,R,Ti).call(this,s)}children(){let e=r(this,xe).get(this);if(e)return e;let t=Object.assign([],{provisional:0});return r(this,xe).set(this,t),u(this,L,r(this,L)&~bi),t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?Us(e):rs(e);for(let l of s)if(r(l,ae)===i)return l;let n=this.parent?this.sep:"",o=r(this,jt)?r(this,jt)+n+e:void 0,a=this.newChild(e,vt,{...t,parent:this,fullpath:o});return this.canReaddir()||u(a,L,r(a,L)|Ct),s.push(a),a}relative(){if(this.isCWD)return "";if(r(this,qt)!==void 0)return r(this,qt);let e=this.name,t=this.parent;if(!t)return u(this,qt,this.name);let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(r(this,Jt)!==void 0)return r(this,Jt);let e=this.name,t=this.parent;if(!t)return u(this,Jt,this.fullpathPosix());let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(r(this,jt)!==void 0)return r(this,jt);let e=this.name,t=this.parent;if(!t)return u(this,jt,this.name);let s=t.fullpath()+(t.parent?this.sep:"")+e;return u(this,jt,s)}fullpathPosix(){if(r(this,Vt)!==void 0)return r(this,Vt);if(this.sep==="/")return u(this,Vt,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?u(this,Vt,`//?/${i}`):u(this,Vt,i)}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return u(this,Vt,s)}isUnknown(){return (r(this,L)&wt)===vt}isType(e){return this[`is${e}`]()}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 (r(this,L)&wt)===on}isDirectory(){return (r(this,L)&wt)===It}isCharacterDevice(){return (r(this,L)&wt)===rn}isBlockDevice(){return (r(this,L)&wt)===nn}isFIFO(){return (r(this,L)&wt)===sn}isSocket(){return (r(this,L)&wt)===an}isSymbolicLink(){return (r(this,L)&fe)===fe}lstatCached(){return r(this,L)&tr?this:void 0}readlinkCached(){return r(this,Ht)}realpathCached(){return r(this,Wt)}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(r(this,Ht))return true;if(!this.parent)return false;let e=r(this,L)&wt;return !(e!==vt&&e!==fe||r(this,L)&$s||r(this,L)&Ct)}calledReaddir(){return !!(r(this,L)&bi)}isENOENT(){return !!(r(this,L)&Ct)}isNamed(e){return this.nocase?r(this,ae)===Us(e):r(this,ae)===rs(e)}async readlink(){let e=r(this,Ht);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await r(this,ot).promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return u(this,Ht,s)}catch(t){g(this,R,_i).call(this,t.code);return}}readlinkSync(){let e=r(this,Ht);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=r(this,ot).readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return u(this,Ht,s)}catch(t){g(this,R,_i).call(this,t.code);return}}async lstat(){if((r(this,L)&Ct)===0)try{return g(this,R,Fi).call(this,await r(this,ot).promises.lstat(this.fullpath())),this}catch(e){g(this,R,Li).call(this,e.code);}}lstatSync(){if((r(this,L)&Ct)===0)try{return g(this,R,Fi).call(this,r(this,ot).lstatSync(this.fullpath())),this}catch(e){g(this,R,Li).call(this,e.code);}}readdirCB(e,t=false){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let n=s.slice(0,s.provisional);t?e(null,n):queueMicrotask(()=>e(null,n));return}if(r(this,We).push(e),r(this,ze))return;u(this,ze,true);let i=this.fullpath();r(this,ot).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,R,Zs).call(this,n.code),s.provisional=0;else {for(let a of o)g(this,R,Ks).call(this,a,s);g(this,R,Hs).call(this,s);}g(this,R,dn).call(this,s.slice(0,s.provisional));});}async readdir(){if(!this.canReaddir())return [];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(r(this,Ee))await r(this,Ee);else {let s=()=>{};u(this,Ee,new Promise(i=>s=i));try{for(let i of await r(this,ot).promises.readdir(t,{withFileTypes:!0}))g(this,R,Ks).call(this,i,e);g(this,R,Hs).call(this,e);}catch(i){g(this,R,Zs).call(this,i.code),e.provisional=0;}u(this,Ee,void 0),s();}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return [];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of r(this,ot).readdirSync(t,{withFileTypes:!0}))g(this,R,Ks).call(this,s,e);g(this,R,Hs).call(this,e);}catch(s){g(this,R,Zs).call(this,s.code),e.provisional=0;}return e.slice(0,e.provisional)}canReaddir(){if(r(this,L)&er)return false;let e=wt&r(this,L);return e===vt||e===It||e===fe}shouldWalk(e,t){return (r(this,L)&It)===It&&!(r(this,L)&er)&&!e.has(this)&&(!t||t(this))}async realpath(){if(r(this,Wt))return r(this,Wt);if(!((Js|$s|Ct)&r(this,L)))try{let e=await r(this,ot).promises.realpath(this.fullpath());return u(this,Wt,this.resolve(e))}catch{g(this,R,Ai).call(this);}}realpathSync(){if(r(this,Wt))return r(this,Wt);if(!((Js|$s|Ct)&r(this,L)))try{let e=r(this,ot).realpathSync(this.fullpath());return u(this,Wt,this.resolve(e))}catch{g(this,R,Ai).call(this);}}[ln](e){if(e===this)return;e.isCWD=false,this.isCWD=true;let t=new Set([]),s=[],i=this;for(;i&&i.parent;)t.add(i),u(i,qt,s.join(this.sep)),u(i,Jt,s.join("/")),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)u(i,qt,void 0),u(i,Jt,void 0),i=i.parent;}},ot=new WeakMap,cs=new WeakMap,us=new WeakMap,ds=new WeakMap,ps=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ys=new WeakMap,ws=new WeakMap,bs=new WeakMap,vs=new WeakMap,Ss=new WeakMap,xs=new WeakMap,Es=new WeakMap,Cs=new WeakMap,ks=new WeakMap,Os=new WeakMap,Rs=new WeakMap,ae=new WeakMap,Se=new WeakMap,jt=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,L=new WeakMap,xe=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,R=new WeakSet,Ti=function(e){let t=this;for(let s of e)t=t.child(s);return t},Hs=function(e){var t;u(this,L,r(this,L)|bi);for(let s=e.provisional;s<e.length;s++){let i=e[s];i&&g(t=i,R,ns).call(t);}},ns=function(){r(this,L)&Ct||(u(this,L,(r(this,L)|Ct)&Xe),g(this,R,Mi).call(this));},Mi=function(){var t;let e=this.children();e.provisional=0;for(let s of e)g(t=s,R,ns).call(t);},Ai=function(){u(this,L,r(this,L)|Js),g(this,R,os).call(this);},os=function(){if(r(this,L)&is)return;let e=r(this,L);(e&wt)===It&&(e&=Xe),u(this,L,e|is),g(this,R,Mi).call(this);},Zs=function(e=""){e==="ENOTDIR"||e==="EPERM"?g(this,R,os).call(this):e==="ENOENT"?g(this,R,ns).call(this):this.children().provisional=0;},Li=function(e=""){var t;e==="ENOTDIR"?g(t=this.parent,R,os).call(t):e==="ENOENT"&&g(this,R,ns).call(this);},_i=function(e=""){var s;let t=r(this,L);t|=$s,e==="ENOENT"&&(t|=Ct),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Xe),u(this,L,t),e==="ENOTDIR"&&this.parent&&g(s=this.parent,R,os).call(s);},Ks=function(e,t){return g(this,R,cn).call(this,e,t)||g(this,R,hn).call(this,e,t)},hn=function(e,t){let s=vi(e),i=this.newChild(e.name,s,{parent:this}),n=r(i,L)&wt;return n!==It&&n!==fe&&n!==vt&&u(i,L,r(i,L)|is),t.unshift(i),t.provisional++,i},cn=function(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?Us(e.name):rs(e.name))===r(i,ae))return g(this,R,un).call(this,e,i,s,t)}},un=function(e,t,s,i){let n=t.name;return u(t,L,r(t,L)&Xe|vi(e)),n!==e.name&&(t.name=e.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(t)),i.provisional++,t},Fi=function(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:n,blksize:o,blocks:a,ctime:l,ctimeMs:h,dev:d,gid:f,ino:p,mode:y,mtime:b,mtimeMs:S,nlink:v,rdev:E,size:w,uid:O}=e;u(this,Cs,t),u(this,vs,s),u(this,Rs,i),u(this,Es,n),u(this,ms,o),u(this,bs,a),u(this,Os,l),u(this,xs,h),u(this,cs,d),u(this,fs,f),u(this,ys,p),u(this,us,y),u(this,ks,b),u(this,Ss,S),u(this,ds,v),u(this,gs,E),u(this,ws,w),u(this,ps,O);let T=vi(e);u(this,L,r(this,L)&Xe|T|tr),T!==vt&&T!==It&&T!==fe&&u(this,L,r(this,L)|is);},We=new WeakMap,ze=new WeakMap,dn=function(e){u(this,ze,false);let t=r(this,We).slice();r(this,We).length=0,t.forEach(s=>s(null,e));},Ee=new WeakMap,Lr),pn=class fn extends ht{constructor(s,i=vt,n,o,a,l,h){super(s,i,n,o,a,l,h);c(this,"sep","\\");c(this,"splitSep",ua);}newChild(s,i=vt,n={}){return new fn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(s){return La.win32.parse(s).root}getRoot(s){if(s=ca(s.toUpperCase()),s===this.root.name)return this.root;for(let[i,n]of Object.entries(this.roots))if(this.sameRoot(s,i))return this.roots[s]=n;return this.roots[s]=new ji(s,this).root}sameRoot(s,i=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(en,"$1\\"),s===i}},gn=class mn extends ht{constructor(s,i=vt,n,o,a,l,h){super(s,i,n,o,a,l,h);c(this,"splitSep","/");c(this,"sep","/");}getRootString(s){return s.startsWith("/")?"/":""}getRoot(s){return this.root}newChild(s,i=vt,n={}){return new mn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}},$e,Ue,Ts,Ms,_r,yn=(_r=class{constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:n=16*1024,fs:o=ss}={}){c(this,"root");c(this,"rootPath");c(this,"roots");c(this,"cwd");m(this,$e);m(this,Ue);m(this,Ts);c(this,"nocase");m(this,Ms);u(this,Ms,tn(o)),(e instanceof URL||e.startsWith("file://"))&&(e=url.fileURLToPath(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),u(this,$e,new rr),u(this,Ue,new rr),u(this,Ts,new pa(n));let l=a.substring(this.rootPath.length).split(s);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(r(this,Ms)),this.roots[this.rootPath]=this.root;let h=this.root,d=l.length-1,f=t.sep,p=this.rootPath,y=false;for(let b of l){let S=d--;h=h.child(b,{relative:new Array(S).fill("..").join(f),relativePosix:new Array(S).fill("..").join("/"),fullpath:p+=(y?"":f)+b}),y=true;}this.cwd=h;}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return r(this,Ts)}resolve(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,$e).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return r(this,$e).set(t,i),i}resolvePosix(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,Ue).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return r(this,Ue).set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let i=await e.readdir();return s?i:i.map(n=>n.name)}else return []}readdirSync(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let l=new Set,h=(f,p)=>{l.add(f),f.readdirCB((y,b)=>{if(y)return p(y);let S=b.length;if(!S)return p();let v=()=>{--S===0&&p();};for(let E of b)(!n||n(E))&&a.push(s?E:E.fullpath()),i&&E.isSymbolicLink()?E.realpath().then(w=>w?.isUnknown()?w.lstat():w).then(w=>w?.shouldWalk(l,o)?h(w,v):v()):E.shouldWalk(l,o)?h(E,v):v();},true);},d=e;return new Promise((f,p)=>{h(d,y=>{if(y)return p(y);f(a);});})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let l=new Set([e]);for(let h of l){let d=h.readdirSync();for(let f of d){(!n||n(f))&&a.push(s?f:f.fullpath());let p=f;if(f.isSymbolicLink()){if(!(i&&(p=f.realpathSync())))continue;p.isUnknown()&&p.lstatSync();}p.shouldWalk(l,o)&&l.add(p);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t;(!n||n(e))&&(yield s?e:e.fullpath());let a=new Set([e]);for(let l of a){let h=l.readdirSync();for(let d of h){(!n||n(d))&&(yield s?d:d.fullpath());let f=d;if(d.isSymbolicLink()){if(!(i&&(f=d.realpathSync())))continue;f.isUnknown()&&f.lstatSync();}f.shouldWalk(a,o)&&a.add(f);}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Xs({objectMode:true});(!n||n(e))&&a.write(s?e:e.fullpath());let l=new Set,h=[e],d=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){d===0&&a.end();return}d++,l.add(y);let b=(v,E,w=false)=>{if(v)return a.emit("error",v);if(i&&!w){let O=[];for(let T of E)T.isSymbolicLink()&&O.push(T.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(O.length){Promise.all(O).then(()=>b(null,E,true));return}}for(let O of E)O&&(!n||n(O))&&(a.write(s?O:O.fullpath())||(p=true));d--;for(let O of E){let T=O.realpathCached()||O;T.shouldWalk(l,o)&&h.push(T);}p&&!a.flowing?a.once("drain",f):S||f();},S=true;y.readdirCB(b,true),S=false;}};return f(),a}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Xs({objectMode:true}),l=new Set;(!n||n(e))&&a.write(s?e:e.fullpath());let h=[e],d=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){d===0&&a.end();return}d++,l.add(y);let b=y.readdirSync();for(let S of b)(!n||n(S))&&(a.write(s?S:S.fullpath())||(p=true));d--;for(let S of b){let v=S;if(S.isSymbolicLink()){if(!(i&&(v=S.realpathSync())))continue;v.isUnknown()&&v.lstatSync();}v.shouldWalk(l,o)&&h.push(v);}}p&&!a.flowing&&a.once("drain",f);};return f(),a}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[ln](t);}},$e=new WeakMap,Ue=new WeakMap,Ts=new WeakMap,Ms=new WeakMap,_r),ji=class extends yn{constructor(t=process.cwd(),s={}){let{nocase:i=true}=s;super(t,La.win32,"\\",{...s,nocase:i});c(this,"sep","\\");this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase;}parseRootPath(t){return La.win32.parse(t).root.toUpperCase()}newRoot(t){return new pn(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Wi=class extends yn{constructor(t=process.cwd(),s={}){let{nocase:i=false}=s;super(t,La.posix,"/",{...s,nocase:i});c(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new gn(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},wn=class extends Wi{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,{...t,nocase:s});}};process.platform==="win32"?pn:gn;var fa=process.platform==="win32"?ji:process.platform==="darwin"?wn:Wi,ga=e=>e.length>=1,ma=e=>e.length>=1,q,mt,X,Ce,Ft,As,le,he,ce,Be,Ge,bn=(Ge=class{constructor(t,s,i,n){m(this,q);m(this,mt);m(this,X);c(this,"length");m(this,Ce);m(this,Ft);m(this,As);m(this,le);m(this,he);m(this,ce);m(this,Be,true);if(!ga(t))throw new TypeError("empty pattern list");if(!ma(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(u(this,q,t),u(this,mt,s),u(this,X,i),u(this,Ce,n),r(this,X)===0){if(this.isUNC()){let[o,a,l,h,...d]=r(this,q),[f,p,y,b,...S]=r(this,mt);d[0]===""&&(d.shift(),S.shift());let v=[o,a,l,h,""].join("/"),E=[f,p,y,b,""].join("/");u(this,q,[v,...d]),u(this,mt,[E,...S]),this.length=r(this,q).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=r(this,q),[l,...h]=r(this,mt);a[0]===""&&(a.shift(),h.shift());let d=o+"/",f=l+"/";u(this,q,[d,...a]),u(this,mt,[f,...h]),this.length=r(this,q).length;}}}pattern(){return r(this,q)[r(this,X)]}isString(){return typeof r(this,q)[r(this,X)]=="string"}isGlobstar(){return r(this,q)[r(this,X)]===at}isRegExp(){return r(this,q)[r(this,X)]instanceof RegExp}globString(){return u(this,As,r(this,As)||(r(this,X)===0?this.isAbsolute()?r(this,mt)[0]+r(this,mt).slice(1).join("/"):r(this,mt).join("/"):r(this,mt).slice(r(this,X)).join("/")))}hasMore(){return this.length>r(this,X)+1}rest(){return r(this,Ft)!==void 0?r(this,Ft):this.hasMore()?(u(this,Ft,new Ge(r(this,q),r(this,mt),r(this,X)+1,r(this,Ce))),u(r(this,Ft),ce,r(this,ce)),u(r(this,Ft),he,r(this,he)),u(r(this,Ft),le,r(this,le)),r(this,Ft)):u(this,Ft,null)}isUNC(){let t=r(this,q);return r(this,he)!==void 0?r(this,he):u(this,he,r(this,Ce)==="win32"&&r(this,X)===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3])}isDrive(){let t=r(this,q);return r(this,le)!==void 0?r(this,le):u(this,le,r(this,Ce)==="win32"&&r(this,X)===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]))}isAbsolute(){let t=r(this,q);return r(this,ce)!==void 0?r(this,ce):u(this,ce,t[0]===""&&t.length>1||this.isDrive()||this.isUNC())}root(){let t=r(this,q)[0];return typeof t=="string"&&this.isAbsolute()&&r(this,X)===0?t:""}checkFollowGlobstar(){return !(r(this,X)===0||!this.isGlobstar()||!r(this,Be))}markFollowGlobstar(){return r(this,X)===0||!this.isGlobstar()||!r(this,Be)?false:(u(this,Be,false),true)}},q=new WeakMap,mt=new WeakMap,X=new WeakMap,Ce=new WeakMap,Ft=new WeakMap,As=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,Be=new WeakMap,Ge),ya=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",nr=class{constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:n,platform:o=ya}){c(this,"relative");c(this,"relativeChildren");c(this,"absolute");c(this,"absoluteChildren");c(this,"platform");c(this,"mmopts");this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:true,nobrace:t,nocase:s,noext:i,noglobstar:n,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of e)this.add(a);}add(e){let t=new de(e,this.mmopts);for(let s=0;s<t.set.length;s++){let i=t.set[s],n=t.globParts[s];if(!i||!n)throw new Error("invalid pattern object");for(;i[0]==="."&&n[0]===".";)i.shift(),n.shift();let o=new bn(i,n,0,this.platform),a=new de(o.globString(),this.mmopts),l=n[n.length-1]==="**",h=o.isAbsolute();h?this.absolute.push(a):this.relative.push(a),l&&(h?this.absoluteChildren.push(a):this.relativeChildren.push(a));}}ignored(e){let t=e.fullpath(),s=`${t}/`,i=e.relative()||".",n=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(n))return true;for(let o of this.absolute)if(o.match(t)||o.match(s))return true;return false}childrenIgnored(e){let t=e.fullpath()+"/",s=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return true;for(let i of this.absoluteChildren)if(i.match(t))return true;return false}},wa=class vn{constructor(t=new Map){c(this,"store");this.store=t;}copy(){return new vn(new Map(this.store))}hasWalked(t,s){return this.store.get(t.fullpath())?.has(s.globString())}storeWalked(t,s){let i=t.fullpath(),n=this.store.get(i);n?n.add(s.globString()):this.store.set(i,new Set([s.globString()]));}},ba=class{constructor(){c(this,"store",new Map);}add(e,t,s){let i=(t?2:0)|(s?1:0),n=this.store.get(e);this.store.set(e,n===void 0?i:i&n);}entries(){return [...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},va=class{constructor(){c(this,"store",new Map);}add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(i=>i.globString()===t.globString())||s.push(t):this.store.set(e,[t]);}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return [...this.store.keys()].filter(e=>e.canReaddir())}},or=class Sn{constructor(t,s){c(this,"hasWalkedCache");c(this,"matches",new ba);c(this,"subwalks",new va);c(this,"patterns");c(this,"follow");c(this,"dot");c(this,"opts");this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new wa;}processPatterns(t,s){this.patterns=s;let i=s.map(n=>[t,n]);for(let[n,o]of i){this.hasWalkedCache.storeWalked(n,o);let a=o.root(),l=o.isAbsolute()&&this.opts.absolute!==false;if(a){n=n.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let p=o.rest();if(p)o=p;else {this.matches.add(n,true,false);continue}}if(n.isENOENT())continue;let h,d,f=false;for(;typeof(h=o.pattern())=="string"&&(d=o.rest());)n=n.resolve(h),o=d,f=true;if(h=o.pattern(),d=o.rest(),f){if(this.hasWalkedCache.hasWalked(n,o))continue;this.hasWalkedCache.storeWalked(n,o);}if(typeof h=="string"){let p=h===".."||h===""||h===".";this.matches.add(n.resolve(h),l,p);continue}else if(h===at){(!n.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(n,o);let p=d?.pattern(),y=d?.rest();if(!d||(p===""||p===".")&&!y)this.matches.add(n,l,p===""||p===".");else if(p===".."){let b=n.parent||n;y?this.hasWalkedCache.hasWalked(b,y)||this.subwalks.add(b,y):this.matches.add(b,l,true);}}else h instanceof RegExp&&this.subwalks.add(n,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Sn(this.opts,this.hasWalkedCache)}filterEntries(t,s){let i=this.subwalks.get(t),n=this.child();for(let o of s)for(let a of i){let l=a.isAbsolute(),h=a.pattern(),d=a.rest();h===at?n.testGlobstar(o,a,d,l):h instanceof RegExp?n.testRegExp(o,h,d,l):n.testString(o,h,d,l);}return n}testGlobstar(t,s,i,n){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,n,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(i&&s.checkFollowGlobstar()?this.subwalks.add(t,i):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),i){let o=i.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,i.rest(),n);else if(o===".."){let a=t.parent||t;this.subwalks.add(a,i);}else o instanceof RegExp&&this.testRegExp(t,o,i.rest(),n);}}testRegExp(t,s,i,n){s.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}testString(t,s,i,n){t.isNamed(s)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}},Sa=(e,t)=>typeof e=="string"?new nr([e],t):Array.isArray(e)?new nr(e,t):e,Ve,Zt,ke,St,ge,Pi,Fr,xn=(Fr=class{constructor(e,t,s){m(this,St);c(this,"path");c(this,"patterns");c(this,"opts");c(this,"seen",new Set);c(this,"paused",false);c(this,"aborted",false);m(this,Ve,[]);m(this,Zt);m(this,ke);c(this,"signal");c(this,"maxDepth");c(this,"includeChildMatches");if(this.patterns=e,this.path=t,this.opts=s,u(this,ke,!s.posix&&s.platform==="win32"?"\\":"/"),this.includeChildMatches=s.includeChildMatches!==false,(s.ignore||!this.includeChildMatches)&&(u(this,Zt,Sa(s.ignore??[],s)),!this.includeChildMatches&&typeof r(this,Zt).add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{r(this,Ve).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let e;for(;!this.paused&&(e=r(this,Ve).shift());)e();}onResume(e){this.signal?.aborted||(this.paused?r(this,Ve).push(e):e());}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=await i.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat();}return this.matchCheckTest(i,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!g(this,St,ge).call(this,e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=i.realpathSync();n&&(n?.isUnknown()||this.opts.stat)&&n.lstatSync();}return this.matchCheckTest(i,t)}matchFinish(e,t){if(g(this,St,ge).call(this,e))return;if(!this.includeChildMatches&&r(this,Zt)?.add){let n=`${e.relativePosix()}/**`;r(this,Zt).add(n);}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?r(this,ke):"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let n=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(n+i);}else {let n=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+r(this,ke))?"."+r(this,ke):"";this.matchEmit(n?o+n+i:"."+i);}}async match(e,t,s){let i=await this.matchCheck(e,s);i&&this.matchFinish(i,t);}matchSync(e,t,s){let i=this.matchCheckSync(e,s);i&&this.matchFinish(i,t);}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new or(this.opts),s);}walkCB2(e,t,s,i){if(g(this,St,Pi).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,s,o):a.readdirCB((h,d)=>this.walkCB3(a,d,s,o),true);}o();}walkCB3(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let[a,l]of s.subwalks.entries())n++,this.walkCB2(a,l,s.child(),o);o();}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new or(this.opts),s);}walkCB2Sync(e,t,s,i){if(g(this,St,Pi).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||this.matchSync(a,l,h);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirSync();this.walkCB3Sync(a,l,s,o);}o();}walkCB3Sync(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||this.matchSync(a,l,h);for(let[a,l]of s.subwalks.entries())n++,this.walkCB2Sync(a,l,s.child(),o);o();}},Ve=new WeakMap,Zt=new WeakMap,ke=new WeakMap,St=new WeakSet,ge=function(e){return this.seen.has(e)||!!r(this,Zt)?.ignored?.(e)},Pi=function(e){return !!r(this,Zt)?.childrenIgnored?.(e)},Fr),ar=class extends xn{constructor(t,s,i){super(t,s,i);c(this,"matches",new Set);}matchEmit(t){this.matches.add(t);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,s)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?s(this.signal.reason):t(this.matches);});}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},lr=class extends xn{constructor(t,s,i){super(t,s,i);c(this,"results");this.results=new Xs({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(t){this.results.write(t),this.results.flowing||this.pause();}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end());}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},xa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Re=class{constructor(e,t){c(this,"absolute");c(this,"cwd");c(this,"root");c(this,"dot");c(this,"dotRelative");c(this,"follow");c(this,"ignore");c(this,"magicalBraces");c(this,"mark");c(this,"matchBase");c(this,"maxDepth");c(this,"nobrace");c(this,"nocase");c(this,"nodir");c(this,"noext");c(this,"noglobstar");c(this,"pattern");c(this,"platform");c(this,"realpath");c(this,"scurry");c(this,"stat");c(this,"signal");c(this,"windowsPathsNoEscape");c(this,"withFileTypes");c(this,"includeChildMatches");c(this,"opts");c(this,"patterns");if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=url.fileURLToPath(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==false,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(e=e.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(l=>l.includes("/")?l:`./**/${l}`);}if(this.pattern=e,this.platform=t.platform||xa,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let l=t.platform==="win32"?ji:t.platform==="darwin"?wn:t.platform?Wi:fa;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(l=>new de(l,i)),[o,a]=n.reduce((l,h)=>(l[0].push(...h.set),l[1].push(...h.globParts),l),[[],[]]);this.patterns=o.map((l,h)=>{let d=a[h];if(!d)throw new Error("invalid pattern object");return new bn(l,d,0,this.platform)});}async walk(){return [...await new ar(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 ar(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 lr(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 lr(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()}},Ea=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new de(s,t).hasMagic())return true;return false};function si(e,t={}){return new Re(e,t).streamSync()}function En(e,t={}){return new Re(e,t).stream()}function Cn(e,t={}){return new Re(e,t).walkSync()}async function hr(e,t={}){return new Re(e,t).walk()}function ii(e,t={}){return new Re(e,t).iterateSync()}function kn(e,t={}){return new Re(e,t).iterate()}var Ca=si,ka=Object.assign(En,{sync:si}),Oa=ii,Ra=Object.assign(kn,{sync:ii}),Ta=Object.assign(Cn,{stream:si,iterate:ii}),ti=Object.assign(hr,{glob:hr,globSync:Cn,sync:Ta,globStream:En,stream:ka,globStreamSync:si,streamSync:Ca,globIterate:kn,iterate:Ra,globIterateSync:ii,iterateSync:Oa,Glob:Re,hasMagic:Ea,escape:Br,unescape:_e});ti.glob=ti;var Kt;(C=>{C.Level=Aa__default.default.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let t={DEBUG:0,INFO:1,WARN:2,ERROR:3},s="INFO";function i(k){return t[k]>=t[s]}function n(){return s}C.getLevel=n;let o=new Map;C.Default=T({service:"default"});let l="";function h(){return l}C.file=h;let d,f,p=false,y=()=>{},b=false;async function S(k){if(k.level&&(s=k.level),k.print){p=true;return}if(k.logPath)l=k.logPath;else {y=()=>{},p=true;return}try{d=await On__default.default.open(l,"a"),f=Jo.createWriteStream("",{fd:d.fd,autoClose:!1}),y=M=>{if(!(b||!f||f.destroyed))try{if(!f.writable)return;f.write(M,F=>{F&&!b&&(b=!0,setTimeout(()=>{b=!1;},1e3));});}catch{b||(b=!0,setTimeout(()=>{b=!1;},1e3));}},p=!0;}catch{y=M=>{try{process.stderr.write(M);}catch{}},p=true;}}C.init=S;async function v(){p&&(f&&!f.destroyed&&(await new Promise((k,M)=>{f.end(F=>{F?M(F):k();});}).catch(()=>{}),f=void 0),d&&(await d.close().catch(()=>{}),d=void 0),y=k=>{try{process.stderr.write(k);}catch{}},p=false);}C.close=v;function w(k,M=0){let F=k.message;return k.cause instanceof Error&&M<10?F+" Caused by: "+w(k.cause,M+1):F}let O=Date.now();function T(k){k=k||{};let M=k.service;if(M&&typeof M=="string"){let A=o.get(M);if(A)return A}function F(A,P){let W=Object.entries({...k,...P}).filter(([zi,Yt])=>Yt!=null).map(([zi,Yt])=>{let ai=`${zi}=`;return Yt instanceof Error?ai+w(Yt):typeof Yt=="object"?ai+JSON.stringify(Yt):ai+Yt}).join(" "),z=new Date,_s=z.getTime()-O;return O=z.getTime(),[z.getFullYear()+"-"+String(z.getMonth()+1).padStart(2,"0")+"-"+String(z.getDate()).padStart(2,"0")+"T"+String(z.getHours()).padStart(2,"0")+":"+String(z.getMinutes()).padStart(2,"0")+":"+String(z.getSeconds()).padStart(2,"0"),"+"+_s+"ms",W,A].filter(Boolean).join(" ")+`
|
|
5
|
-
`}let D={debug(
|
|
6
|
-
`);i&&t.push({role:"user",content:i});break}case "assistant":{let i="",n=[];for(let o of s.content)if(o.type==="text")i+=o.text;else if(o.type==="tool-call"){let a=o;n.push({id:a.toolCallId,type:"function",function:{name:a.toolName,arguments:JSON.stringify(a.input)}});}t.push({role:"assistant",content:i||null,tool_calls:n.length>0?n:void 0});break}case "tool":for(let i of s.content){let n=i.output,o;switch(n.type){case "text":case "error-text":o=n.value;break;case "content":case "json":case "error-json":o=JSON.stringify(n.value);break;default:o=String(n.value);break}t.push({role:"tool",tool_call_id:i.toolCallId,content:o});}break}}catch(i){xt.warn("Failed to convert message",{messageRole:s.role,error:i instanceof Error?i.message:String(i)});}return t}var oi=class{constructor(t,s={}){
|
|
7
|
-
exports.ConnectionError=hi;exports.ModelNotFoundError=ci;exports.OLLAMA_DEFAULT_OPTIONS=
|
|
4
|
+
>>> no match, partial?`,e,p,t,y),p===l))}let S;if(typeof c=="string"?(S=f===c,this.debug("string match",c,f,S)):(S=c.test(f),this.debug("pattern match",c,f,S)),!S)return false}if(o===l&&a===h)return true;if(o===l)return s;if(a===h)return o===l-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Hr(this.pattern,this.options)}parse(e){Ys(e);let t=this.options;if(e==="**")return at;if(e==="")return "";let s,i=null;(s=e.match(vo))?i=t.dot?xo:So:(s=e.match(ho))?i=(t.nocase?t.dot?fo:po:t.dot?uo:co)(s[1]):(s=e.match(Eo))?i=(t.nocase?t.dot?Oo:Co:t.dot?ko:Ro)(s):(s=e.match(go))?i=t.dot?yo:mo:(s=e.match(wo))&&(i=bo);let n=$r.fromGlob(e,this.options).toMMPattern();return i&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:i}),n}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let e=this.set;if(!e.length)return this.regexp=false,this.regexp;let t=this.options,s=t.noglobstar?To:t.dot?Ao:_o,i=new Set(t.nocase?["i"]:[]),n=e.map(l=>{let h=l.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?No(f):f===at?at:f._src});h.forEach((f,p)=>{let y=h[p+1],b=h[p-1];f!==at||b===at||(b===void 0?y!==void 0&&y!==at?h[p+1]="(?:\\/|"+s+"\\/)?"+y:h[p]=s:y===void 0?h[p-1]=b+"(?:\\/|\\/"+s+")?":y!==at&&(h[p-1]=b+"(?:\\/|\\/"+s+"\\/)"+y,h[p+1]=at));});let c=h.filter(f=>f!==at);if(this.partial&&c.length>=1){let f=[];for(let p=1;p<=c.length;p++)f.push(c.slice(0,p).join("/"));return "(?:"+f.join("|")+")"}return c.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];n="^"+o+n+a+"$",this.partial&&(n="^(?:\\/|"+o+n.slice(1,-1)+a+")$"),this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...i].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return false;if(this.empty)return e==="";if(e==="/"&&t)return true;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let n=this.set;this.debug(this.pattern,"set",n);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<n.length;a++){let l=n[a],h=i;if(s.matchBase&&l.length===1&&(h=[o]),this.matchOne(h,l,t))return s.flipNegate?true:!this.negate}return s.flipNegate?false:this.negate}static defaults(e){return lt.defaults(e).Minimatch}};lt.AST=$r;lt.Minimatch=de;lt.escape=Gr;lt.unescape=_e;var Wo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zr=new Set,xi=typeof process=="object"&&process?process:{},Kr=(e,t,s,i)=>{typeof xi.emitWarning=="function"?xi.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`);},Qs=globalThis.AbortController,Ki=globalThis.AbortSignal;if(typeof Qs>"u"){Ki=class{constructor(){u(this,"onabort");u(this,"_onabort",[]);u(this,"reason");u(this,"aborted",false);}addEventListener(s,i){this._onabort.push(i);}},Qs=class{constructor(){u(this,"signal",new Ki);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s);}}};let e=xi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=false,Kr("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",t));};}var zo=e=>!Zr.has(e),te=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Yr=e=>te(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Gs:null:null,Gs=class extends Array{constructor(e){super(e),this.fill(0);}},zt,Fe,$o=(zt=class{constructor(t,s){u(this,"heap");u(this,"length");if(!r(zt,Fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0;}static create(t){let s=Yr(t);if(!s)return [];d(zt,Fe,true);let i=new zt(t,s);return d(zt,Fe,false),i}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},Fe=new WeakMap,m(zt,Fe,false),zt),ur,dr,bt,dt,kt,we,Rt,Pe,De,Mt,V,Lt,B,j,_,rt,pt,st,Q,Tt,X,At,_t,ft,gt,Ft,oe,nt,Ie,x,Ei,be,Gt,ls,mt,Qr,ve,Ne,hs,ee,se,Ci,Vs,qs,I,Oi,es,ie,ki,je,ei=(je=class{constructor(t){m(this,x);m(this,bt);m(this,dt);m(this,kt);m(this,we);m(this,Rt);m(this,Pe);m(this,De);m(this,Mt);u(this,"ttl");u(this,"ttlResolution");u(this,"ttlAutopurge");u(this,"updateAgeOnGet");u(this,"updateAgeOnHas");u(this,"allowStale");u(this,"noDisposeOnSet");u(this,"noUpdateTTL");u(this,"maxEntrySize");u(this,"sizeCalculation");u(this,"noDeleteOnFetchRejection");u(this,"noDeleteOnStaleGet");u(this,"allowStaleOnFetchAbort");u(this,"allowStaleOnFetchRejection");u(this,"ignoreFetchAbort");m(this,V);m(this,Lt);m(this,B);m(this,j);m(this,_);m(this,rt);m(this,pt);m(this,st);m(this,Q);m(this,Tt);m(this,X);m(this,At);m(this,_t);m(this,ft);m(this,gt);m(this,Ft);m(this,oe);m(this,nt);m(this,Ie);m(this,be,()=>{});m(this,Gt,()=>{});m(this,ls,()=>{});m(this,mt,()=>false);m(this,ve,t=>{});m(this,Ne,(t,s,i)=>{});m(this,hs,(t,s,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});u(this,ur,"LRUCache");let{max:s=0,ttl:i,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:c,onInsert:f,disposeAfter:p,noDisposeOnSet:y,noUpdateTTL:b,maxSize:S=0,maxEntrySize:v=0,sizeCalculation:E,fetchMethod:w,memoMethod:k,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:T,ignoreFetchAbort:F,perf:D}=t;if(D!==void 0&&typeof D?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(d(this,Mt,D??Wo),s!==0&&!te(s))throw new TypeError("max option must be a nonnegative integer");let L=s?Yr(s):Array;if(!L)throw new Error("invalid max value: "+s);if(d(this,bt,s),d(this,dt,S),this.maxEntrySize=v||r(this,dt),this.sizeCalculation=E,this.sizeCalculation){if(!r(this,dt)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(d(this,De,k),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(d(this,Pe,w),d(this,oe,!!w),d(this,B,new Map),d(this,j,new Array(s).fill(void 0)),d(this,_,new Array(s).fill(void 0)),d(this,rt,new L(s)),d(this,pt,new L(s)),d(this,st,0),d(this,Q,0),d(this,Tt,$o.create(s)),d(this,V,0),d(this,Lt,0),typeof c=="function"&&d(this,kt,c),typeof f=="function"&&d(this,we,f),typeof p=="function"?(d(this,Rt,p),d(this,X,[])):(d(this,Rt,void 0),d(this,X,void 0)),d(this,Ft,!!r(this,kt)),d(this,Ie,!!r(this,we)),d(this,nt,!!r(this,Rt)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(r(this,dt)!==0&&!te(r(this,dt)))throw new TypeError("maxSize must be a positive integer if specified");if(!te(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,x,Qr).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=te(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!te(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,x,Ei).call(this);}if(r(this,bt)===0&&this.ttl===0&&r(this,dt)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,bt)&&!r(this,dt)){let P="LRU_CACHE_UNBOUNDED";zo(P)&&(Zr.add(P),Kr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",P,je));}}get perf(){return r(this,Mt)}static unsafeExposeInternals(t){return {starts:r(t,_t),ttls:r(t,ft),autopurgeTimers:r(t,gt),sizes:r(t,At),keyMap:r(t,B),keyList:r(t,j),valList:r(t,_),next:r(t,rt),prev:r(t,pt),get head(){return r(t,st)},get tail(){return r(t,Q)},free:r(t,Tt),isBackgroundFetch:s=>{var i;return g(i=t,x,I).call(i,s)},backgroundFetch:(s,i,n,o)=>{var a;return g(a=t,x,qs).call(a,s,i,n,o)},moveToTail:s=>{var i;return g(i=t,x,es).call(i,s)},indexes:s=>{var i;return g(i=t,x,ee).call(i,s)},rindexes:s=>{var i;return g(i=t,x,se).call(i,s)},isStale:s=>{var i;return r(i=t,mt).call(i,s)}}}get max(){return r(this,bt)}get maxSize(){return r(this,dt)}get calculatedSize(){return r(this,Lt)}get size(){return r(this,V)}get fetchMethod(){return r(this,Pe)}get memoMethod(){return r(this,De)}get dispose(){return r(this,kt)}get onInsert(){return r(this,we)}get disposeAfter(){return r(this,Rt)}getRemainingTTL(t){return r(this,B).has(t)?1/0:0}*entries(){for(let t of g(this,x,ee).call(this))r(this,_)[t]!==void 0&&r(this,j)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield [r(this,j)[t],r(this,_)[t]]);}*rentries(){for(let t of g(this,x,se).call(this))r(this,_)[t]!==void 0&&r(this,j)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield [r(this,j)[t],r(this,_)[t]]);}*keys(){for(let t of g(this,x,ee).call(this)){let s=r(this,j)[t];s!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield s);}}*rkeys(){for(let t of g(this,x,se).call(this)){let s=r(this,j)[t];s!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield s);}}*values(){for(let t of g(this,x,ee).call(this))r(this,_)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield r(this,_)[t]);}*rvalues(){for(let t of g(this,x,se).call(this))r(this,_)[t]!==void 0&&!g(this,x,I).call(this,r(this,_)[t])&&(yield r(this,_)[t]);}[(dr=Symbol.iterator,ur=Symbol.toStringTag,dr)](){return this.entries()}find(t,s={}){for(let i of g(this,x,ee).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,r(this,j)[i],this))return this.get(r(this,j)[i],s)}}forEach(t,s=this){for(let i of g(this,x,ee).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,j)[i],this);}}rforEach(t,s=this){for(let i of g(this,x,se).call(this)){let n=r(this,_)[i],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(s,o,r(this,j)[i],this);}}purgeStale(){let t=false;for(let s of g(this,x,se).call(this,{allowStale:true}))r(this,mt).call(this,s)&&(g(this,x,ie).call(this,r(this,j)[s],"expire"),t=true);return t}info(t){let s=r(this,B).get(t);if(s===void 0)return;let i=r(this,_)[s],n=g(this,x,I).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let o={value:n};if(r(this,ft)&&r(this,_t)){let a=r(this,ft)[s],l=r(this,_t)[s];if(a&&l){let h=a-(r(this,Mt).now()-l);o.ttl=h,o.start=Date.now();}}return r(this,At)&&(o.size=r(this,At)[s]),o}dump(){let t=[];for(let s of g(this,x,ee).call(this,{allowStale:true})){let i=r(this,j)[s],n=r(this,_)[s],o=g(this,x,I).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||i===void 0)continue;let a={value:o};if(r(this,ft)&&r(this,_t)){a.ttl=r(this,ft)[s];let l=r(this,Mt).now()-r(this,_t)[s];a.start=Math.floor(Date.now()-l);}r(this,At)&&(a.size=r(this,At)[s]),t.unshift([i,a]);}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let n=Date.now()-i.start;i.start=r(this,Mt).now()-n;}this.set(s,i.value,i);}}set(t,s,i={}){var y,b,S,v;if(s===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:h}=i,{noUpdateTTL:c=this.noUpdateTTL}=i,f=r(this,hs).call(this,t,s,i.size||0,l);if(this.maxEntrySize&&f>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),g(this,x,ie).call(this,t,"set"),this;let p=r(this,V)===0?void 0:r(this,B).get(t);if(p===void 0)p=r(this,V)===0?r(this,Q):r(this,Tt).length!==0?r(this,Tt).pop():r(this,V)===r(this,bt)?g(this,x,Vs).call(this,false):r(this,V),r(this,j)[p]=t,r(this,_)[p]=s,r(this,B).set(t,p),r(this,rt)[r(this,Q)]=p,r(this,pt)[p]=r(this,Q),d(this,Q,p),Fs(this,V)._++,r(this,Ne).call(this,p,f,h),h&&(h.set="add"),c=false,r(this,Ie)&&((y=r(this,we))==null||y.call(this,s,t,"add"));else {g(this,x,es).call(this,p);let E=r(this,_)[p];if(s!==E){if(r(this,oe)&&g(this,x,I).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=E;w!==void 0&&!a&&(r(this,Ft)&&((b=r(this,kt))==null||b.call(this,w,t,"set")),r(this,nt)&&r(this,X)?.push([w,t,"set"]));}else a||(r(this,Ft)&&((S=r(this,kt))==null||S.call(this,E,t,"set")),r(this,nt)&&r(this,X)?.push([E,t,"set"]));if(r(this,ve).call(this,p),r(this,Ne).call(this,p,f,h),r(this,_)[p]=s,h){h.set="replace";let w=E&&g(this,x,I).call(this,E)?E.__staleWhileFetching:E;w!==void 0&&(h.oldValue=w);}}else h&&(h.set="update");r(this,Ie)&&this.onInsert?.(s,t,s===E?"update":"replace");}if(n!==0&&!r(this,ft)&&g(this,x,Ei).call(this),r(this,ft)&&(c||r(this,ls).call(this,p,n,o),h&&r(this,Gt).call(this,h,p)),!a&&r(this,nt)&&r(this,X)){let E=r(this,X),w;for(;w=E?.shift();)(v=r(this,Rt))==null||v.call(this,...w);}return this}pop(){var t;try{for(;r(this,V);){let s=r(this,_)[r(this,st)];if(g(this,x,Vs).call(this,!0),g(this,x,I).call(this,s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(r(this,nt)&&r(this,X)){let s=r(this,X),i;for(;i=s?.shift();)(t=r(this,Rt))==null||t.call(this,...i);}}}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=s,o=r(this,B).get(t);if(o!==void 0){let a=r(this,_)[o];if(g(this,x,I).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,mt).call(this,o))n&&(n.has="stale",r(this,Gt).call(this,n,o));else return i&&r(this,be).call(this,o),n&&(n.has="hit",r(this,Gt).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,s={}){let{allowStale:i=this.allowStale}=s,n=r(this,B).get(t);if(n===void 0||!i&&r(this,mt).call(this,n))return;let o=r(this,_)[n];return g(this,x,I).call(this,o)?o.__staleWhileFetching:o}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:h=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:S=this.allowStaleOnFetchAbort,context:v,forceRefresh:E=false,status:w,signal:k}=s;if(!r(this,oe))return w&&(w.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:w});let M={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:c,noUpdateTTL:f,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:S,ignoreFetchAbort:b,status:w,signal:k},C=r(this,B).get(t);if(C===void 0){w&&(w.fetch="miss");let O=g(this,x,qs).call(this,t,C,M,v);return O.__returned=O}else {let O=r(this,_)[C];if(g(this,x,I).call(this,O)){let L=i&&O.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",L&&(w.returnedStale=true)),L?O.__staleWhileFetching:O.__returned=O}let T=r(this,mt).call(this,C);if(!E&&!T)return w&&(w.fetch="hit"),g(this,x,es).call(this,C),n&&r(this,be).call(this,C),w&&r(this,Gt).call(this,w,C),O;let F=g(this,x,qs).call(this,t,C,M,v),D=F.__staleWhileFetching!==void 0&&i;return w&&(w.fetch=T?"stale":"refresh",D&&T&&(w.returnedStale=true)),D?F.__staleWhileFetching:F.__returned=F}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=r(this,De);if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=s,l=this.get(t,a);if(!o&&l!==void 0)return l;let h=i(t,l,{options:a,context:n});return this.set(t,h,a),h}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=s,l=r(this,B).get(t);if(l!==void 0){let h=r(this,_)[l],c=g(this,x,I).call(this,h);return a&&r(this,Gt).call(this,a,l),r(this,mt).call(this,l)?(a&&(a.get="stale"),c?(a&&i&&h.__staleWhileFetching!==void 0&&(a.returnedStale=true),i?h.__staleWhileFetching:void 0):(o||g(this,x,ie).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?h:void 0)):(a&&(a.get="hit"),c?h.__staleWhileFetching:(g(this,x,es).call(this,l),n&&r(this,be).call(this,l),h))}else a&&(a.get="miss");}delete(t){return g(this,x,ie).call(this,t,"delete")}clear(){return g(this,x,ki).call(this,"delete")}},bt=new WeakMap,dt=new WeakMap,kt=new WeakMap,we=new WeakMap,Rt=new WeakMap,Pe=new WeakMap,De=new WeakMap,Mt=new WeakMap,V=new WeakMap,Lt=new WeakMap,B=new WeakMap,j=new WeakMap,_=new WeakMap,rt=new WeakMap,pt=new WeakMap,st=new WeakMap,Q=new WeakMap,Tt=new WeakMap,X=new WeakMap,At=new WeakMap,_t=new WeakMap,ft=new WeakMap,gt=new WeakMap,Ft=new WeakMap,oe=new WeakMap,nt=new WeakMap,Ie=new WeakMap,x=new WeakSet,Ei=function(){let t=new Gs(r(this,bt)),s=new Gs(r(this,bt));d(this,ft,t),d(this,_t,s);let i=this.ttlAutopurge?new Array(r(this,bt)):void 0;d(this,gt,i),d(this,ls,(a,l,h=r(this,Mt).now())=>{if(s[a]=l!==0?h:0,t[a]=l,i?.[a]&&(clearTimeout(i[a]),i[a]=void 0),l!==0&&i){let c=setTimeout(()=>{r(this,mt).call(this,a)&&g(this,x,ie).call(this,r(this,j)[a],"expire");},l+1);c.unref&&c.unref(),i[a]=c;}}),d(this,be,a=>{s[a]=t[a]!==0?r(this,Mt).now():0;}),d(this,Gt,(a,l)=>{if(t[l]){let h=t[l],c=s[l];if(!h||!c)return;a.ttl=h,a.start=c,a.now=n||o();let f=a.now-c;a.remainingTTL=h-f;}});let n=0,o=()=>{let a=r(this,Mt).now();if(this.ttlResolution>0){n=a;let l=setTimeout(()=>n=0,this.ttlResolution);l.unref&&l.unref();}return a};this.getRemainingTTL=a=>{let l=r(this,B).get(a);if(l===void 0)return 0;let h=t[l],c=s[l];if(!h||!c)return 1/0;let f=(n||o())-c;return h-f},d(this,mt,a=>{let l=s[a],h=t[a];return !!h&&!!l&&(n||o())-l>h});},be=new WeakMap,Gt=new WeakMap,ls=new WeakMap,mt=new WeakMap,Qr=function(){let t=new Gs(r(this,bt));d(this,Lt,0),d(this,At,t),d(this,ve,s=>{d(this,Lt,r(this,Lt)-t[s]),t[s]=0;}),d(this,hs,(s,i,n,o)=>{if(g(this,x,I).call(this,i))return 0;if(!te(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(i,s),!te(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n}),d(this,Ne,(s,i,n)=>{if(t[s]=i,r(this,dt)){let o=r(this,dt)-t[s];for(;r(this,Lt)>o;)g(this,x,Vs).call(this,true);}d(this,Lt,r(this,Lt)+t[s]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,Lt));});},ve=new WeakMap,Ne=new WeakMap,hs=new WeakMap,ee=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,Q);!(!g(this,x,Ci).call(this,s)||((t||!r(this,mt).call(this,s))&&(yield s),s===r(this,st)));)s=r(this,pt)[s];},se=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let s=r(this,st);!(!g(this,x,Ci).call(this,s)||((t||!r(this,mt).call(this,s))&&(yield s),s===r(this,Q)));)s=r(this,rt)[s];},Ci=function(t){return t!==void 0&&r(this,B).get(r(this,j)[t])===t},Vs=function(t){var o;let s=r(this,st),i=r(this,j)[s],n=r(this,_)[s];return r(this,oe)&&g(this,x,I).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,Ft)||r(this,nt))&&(r(this,Ft)&&((o=r(this,kt))==null||o.call(this,n,i,"evict")),r(this,nt)&&r(this,X)?.push([n,i,"evict"])),r(this,ve).call(this,s),r(this,gt)?.[s]&&(clearTimeout(r(this,gt)[s]),r(this,gt)[s]=void 0),t&&(r(this,j)[s]=void 0,r(this,_)[s]=void 0,r(this,Tt).push(s)),r(this,V)===1?(d(this,st,d(this,Q,0)),r(this,Tt).length=0):d(this,st,r(this,rt)[s]),r(this,B).delete(i),Fs(this,V)._--,s},qs=function(t,s,i,n){let o=s===void 0?void 0:r(this,_)[s];if(g(this,x,I).call(this,o))return o;let a=new Qs,{signal:l}=i;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let h={signal:a.signal,options:i,context:n},c=(v,E=false)=>{let{aborted:w}=a.signal,k=i.ignoreFetchAbort&&v!==void 0,M=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&v!==void 0);if(i.status&&(w&&!E?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,k&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),w&&!k&&!E)return p(a.signal.reason,M);let C=b,O=r(this,_)[s];return (O===b||k&&E&&O===void 0)&&(v===void 0?C.__staleWhileFetching!==void 0?r(this,_)[s]=C.__staleWhileFetching:g(this,x,ie).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,v,h.options))),v},f=v=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=v),p(v,false)),p=(v,E)=>{let{aborted:w}=a.signal,k=w&&i.allowStaleOnFetchAbort,M=k||i.allowStaleOnFetchRejection,C=M||i.noDeleteOnFetchRejection,O=b;if(r(this,_)[s]===b&&(!C||!E&&O.__staleWhileFetching===void 0?g(this,x,ie).call(this,t,"fetch"):k||(r(this,_)[s]=O.__staleWhileFetching)),M)return i.status&&O.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw v},y=(v,E)=>{var k;let w=(k=r(this,Pe))==null?void 0:k.call(this,t,o,h);w&&w instanceof Promise&&w.then(M=>v(M===void 0?void 0:M),E),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(v(void 0),i.allowStaleOnFetchAbort&&(v=M=>c(M,true)));});};i.status&&(i.status.fetchDispatched=true);let b=new Promise(y).then(c,f),S=Object.assign(b,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,S,{...h.options,status:void 0}),s=r(this,B).get(t)):r(this,_)[s]=S,S},I=function(t){if(!r(this,oe))return false;let s=t;return !!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Qs},Oi=function(t,s){r(this,pt)[s]=t,r(this,rt)[t]=s;},es=function(t){t!==r(this,Q)&&(t===r(this,st)?d(this,st,r(this,rt)[t]):g(this,x,Oi).call(this,r(this,pt)[t],r(this,rt)[t]),g(this,x,Oi).call(this,r(this,Q),t),d(this,Q,t));},ie=function(t,s){var n,o;let i=false;if(r(this,V)!==0){let a=r(this,B).get(t);if(a!==void 0)if(r(this,gt)?.[a]&&(clearTimeout(r(this,gt)?.[a]),r(this,gt)[a]=void 0),i=true,r(this,V)===1)g(this,x,ki).call(this,s);else {r(this,ve).call(this,a);let l=r(this,_)[a];if(g(this,x,I).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,Ft)||r(this,nt))&&(r(this,Ft)&&((n=r(this,kt))==null||n.call(this,l,t,s)),r(this,nt)&&r(this,X)?.push([l,t,s])),r(this,B).delete(t),r(this,j)[a]=void 0,r(this,_)[a]=void 0,a===r(this,Q))d(this,Q,r(this,pt)[a]);else if(a===r(this,st))d(this,st,r(this,rt)[a]);else {let h=r(this,pt)[a];r(this,rt)[h]=r(this,rt)[a];let c=r(this,rt)[a];r(this,pt)[c]=r(this,pt)[a];}Fs(this,V)._--,r(this,Tt).push(a);}}if(r(this,nt)&&r(this,X)?.length){let a=r(this,X),l;for(;l=a?.shift();)(o=r(this,Rt))==null||o.call(this,...l);}return i},ki=function(t){var s,i;for(let n of g(this,x,se).call(this,{allowStale:true})){let o=r(this,_)[n];if(g(this,x,I).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=r(this,j)[n];r(this,Ft)&&((s=r(this,kt))==null||s.call(this,o,a,t)),r(this,nt)&&r(this,X)?.push([o,a,t]);}}if(r(this,B).clear(),r(this,_).fill(void 0),r(this,j).fill(void 0),r(this,ft)&&r(this,_t)){r(this,ft).fill(0),r(this,_t).fill(0);for(let n of r(this,gt)??[])n!==void 0&&clearTimeout(n);r(this,gt)?.fill(void 0);}if(r(this,At)&&r(this,At).fill(0),d(this,st,0),d(this,Q,0),r(this,Tt).length=0,d(this,Lt,0),d(this,V,0),r(this,nt)&&r(this,X)){let n=r(this,X),o;for(;o=n?.shift();)(i=r(this,Rt))==null||i.call(this,...o);}},je),Yi=typeof process=="object"&&process?process:{stdout:null,stderr:null},ea=e=>!!e&&typeof e=="object"&&(e instanceof Xs||e instanceof Xr__default.default||sa(e)||ia(e)),sa=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Xr__default.default.Writable.prototype.pipe,ia=e=>!!e&&typeof e=="object"&&e instanceof events.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",$t=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),Xt=Symbol("emittedEnd"),Is=Symbol("emittingEnd"),Ze=Symbol("emittedError"),Ns=Symbol("closed"),Qi=Symbol("read"),js=Symbol("flush"),Xi=Symbol("flushChunk"),Ct=Symbol("encoding"),Te=Symbol("decoder"),H=Symbol("flowing"),Ke=Symbol("paused"),Ae=Symbol("resume"),Z=Symbol("buffer"),it=Symbol("pipes"),K=Symbol("bufferLength"),fi=Symbol("bufferPush"),Ws=Symbol("bufferShift"),et=Symbol("objectMode"),$=Symbol("destroyed"),gi=Symbol("error"),mi=Symbol("emitData"),tr=Symbol("emitEnd"),yi=Symbol("emitEnd2"),Dt=Symbol("async"),wi=Symbol("abort"),zs=Symbol("aborted"),Ye=Symbol("signal"),pe=Symbol("dataListeners"),ut=Symbol("discarded"),Qe=e=>Promise.resolve().then(e),ra=e=>e(),na=e=>e==="end"||e==="finish"||e==="prefinish",oa=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,aa=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),tn=class{constructor(e,t,s){u(this,"src");u(this,"dest");u(this,"opts");u(this,"ondrain");this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Ae](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},la=class extends tn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>this.dest.emit("error",i),e.on("error",this.proxyErrors);}},ha=e=>!!e.objectMode,ca=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",pr,fr,gr,mr,yr,wr,br,vr,Sr,xr,Er,Cr,Or,kr,Rr,Mr,Lr,Tr,Ar,Xs=class extends events.EventEmitter{constructor(...t){let s=t[0]||{};super();u(this,Ar,false);u(this,Tr,false);u(this,Lr,[]);u(this,Mr,[]);u(this,Rr);u(this,kr);u(this,Or);u(this,Cr);u(this,Er,false);u(this,xr,false);u(this,Sr,false);u(this,vr,false);u(this,br,null);u(this,wr,0);u(this,yr,false);u(this,mr);u(this,gr,false);u(this,fr,0);u(this,pr,false);u(this,"writable",true);u(this,"readable",true);if(s.objectMode&&typeof s.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");ha(s)?(this[et]=true,this[Ct]=null):ca(s)?(this[Ct]=s.encoding,this[et]=false):(this[et]=false,this[Ct]=null),this[Dt]=!!s.async,this[Te]=this[Ct]?new string_decoder.StringDecoder(this[Ct]):null,s&&s.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[Z]}),s&&s.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[it]});let{signal:i}=s;i&&(this[Ye]=i,i.aborted?this[wi]():i.addEventListener("abort",()=>this[wi]()));}get bufferLength(){return this[K]}get encoding(){return this[Ct]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[et]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Dt]}set async(t){this[Dt]=this[Dt]||!!t;}[(Ar=H,Tr=Ke,Lr=it,Mr=Z,Rr=et,kr=Ct,Or=Dt,Cr=Te,Er=$t,xr=Xt,Sr=Is,vr=Ns,br=Ze,wr=K,yr=$,mr=Ye,gr=zs,fr=pe,pr=ut,wi)](){this[zs]=true,this.emit("abort",this[Ye]?.reason),this.destroy(this[Ye]?.reason);}get aborted(){return this[zs]}set aborted(t){}write(t,s,i){if(this[zs])return false;if(this[$t])throw new Error("write after end");if(this[$])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof s=="function"&&(i=s,s="utf8"),s||(s="utf8");let n=this[Dt]?Qe:ra;if(!this[et]&&!Buffer.isBuffer(t)){if(aa(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(oa(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[et]?(this[H]&&this[K]!==0&&this[js](true),this[H]?this.emit("data",t):this[fi](t),this[K]!==0&&this.emit("readable"),i&&n(i),this[H]):t.length?(typeof t=="string"&&!(s===this[Ct]&&!this[Te]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[Ct]&&(t=this[Te].write(t)),this[H]&&this[K]!==0&&this[js](true),this[H]?this.emit("data",t):this[fi](t),this[K]!==0&&this.emit("readable"),i&&n(i),this[H]):(this[K]!==0&&this.emit("readable"),i&&n(i),this[H])}read(t){if(this[$])return null;if(this[ut]=false,this[K]===0||t===0||t&&t>this[K])return this[Ut](),null;this[et]&&(t=null),this[Z].length>1&&!this[et]&&(this[Z]=[this[Ct]?this[Z].join(""):Buffer.concat(this[Z],this[K])]);let s=this[Qi](t||null,this[Z][0]);return this[Ut](),s}[Qi](t,s){if(this[et])this[Ws]();else {let i=s;t===i.length||t===null?this[Ws]():typeof i=="string"?(this[Z][0]=i.slice(t),s=i.slice(0,t),this[K]-=t):(this[Z][0]=i.subarray(t),s=i.subarray(0,t),this[K]-=t);}return this.emit("data",s),!this[Z].length&&!this[$t]&&this.emit("drain"),s}end(t,s,i){return typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s="utf8"),t!==void 0&&this.write(t,s),i&&this.once("end",i),this[$t]=true,this.writable=false,(this[H]||!this[Ke])&&this[Ut](),this}[Ae](){this[$]||(!this[pe]&&!this[it].length&&(this[ut]=true),this[Ke]=false,this[H]=true,this.emit("resume"),this[Z].length?this[js]():this[$t]?this[Ut]():this.emit("drain"));}resume(){return this[Ae]()}pause(){this[H]=false,this[Ke]=true,this[ut]=false;}get destroyed(){return this[$]}get flowing(){return this[H]}get paused(){return this[Ke]}[fi](t){this[et]?this[K]+=1:this[K]+=t.length,this[Z].push(t);}[Ws](){return this[et]?this[K]-=1:this[K]-=this[Z][0].length,this[Z].shift()}[js](t=false){do;while(this[Xi](this[Ws]())&&this[Z].length);!t&&!this[Z].length&&!this[$t]&&this.emit("drain");}[Xi](t){return this.emit("data",t),this[H]}pipe(t,s){if(this[$])return t;this[ut]=false;let i=this[Xt];return s=s||{},t===Yi.stdout||t===Yi.stderr?s.end=false:s.end=s.end!==false,s.proxyErrors=!!s.proxyErrors,i?s.end&&t.end():(this[it].push(s.proxyErrors?new la(this,t,s):new tn(this,t,s)),this[Dt]?Qe(()=>this[Ae]()):this[Ae]()),t}unpipe(t){let s=this[it].find(i=>i.dest===t);s&&(this[it].length===1?(this[H]&&this[pe]===0&&(this[H]=false),this[it]=[]):this[it].splice(this[it].indexOf(s),1),s.unpipe());}addListener(t,s){return this.on(t,s)}on(t,s){let i=super.on(t,s);if(t==="data")this[ut]=false,this[pe]++,!this[it].length&&!this[H]&&this[Ae]();else if(t==="readable"&&this[K]!==0)super.emit("readable");else if(na(t)&&this[Xt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ze]){let n=s;this[Dt]?Qe(()=>n.call(this,this[Ze])):n.call(this,this[Ze]);}return i}removeListener(t,s){return this.off(t,s)}off(t,s){let i=super.off(t,s);return t==="data"&&(this[pe]=this.listeners("data").length,this[pe]===0&&!this[ut]&&!this[it].length&&(this[H]=false)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[pe]=0,!this[ut]&&!this[it].length&&(this[H]=false)),s}get emittedEnd(){return this[Xt]}[Ut](){!this[Is]&&!this[Xt]&&!this[$]&&this[Z].length===0&&this[$t]&&(this[Is]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ns]&&this.emit("close"),this[Is]=false);}emit(t,...s){let i=s[0];if(t!=="error"&&t!=="close"&&t!==$&&this[$])return false;if(t==="data")return !this[et]&&!i?false:this[Dt]?(Qe(()=>this[mi](i)),true):this[mi](i);if(t==="end")return this[tr]();if(t==="close"){if(this[Ns]=true,!this[Xt]&&!this[$])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ze]=i,super.emit(gi,i);let o=!this[Ye]||this.listeners("error").length?super.emit("error",i):false;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let n=super.emit(t,...s);return this[Ut](),n}[mi](t){for(let i of this[it])i.dest.write(t)===false&&this.pause();let s=this[ut]?false:super.emit("data",t);return this[Ut](),s}[tr](){return this[Xt]?false:(this[Xt]=true,this.readable=false,this[Dt]?(Qe(()=>this[yi]()),true):this[yi]())}[yi](){if(this[Te]){let s=this[Te].end();if(s){for(let i of this[it])i.dest.write(s);this[ut]||super.emit("data",s);}}for(let s of this[it])s.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[et]||(t.dataLength=0);let s=this.promise();return this.on("data",i=>{t.push(i),this[et]||(t.dataLength+=i.length);}),await s,t}async concat(){if(this[et])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Ct]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,s)=>{this.on($,()=>s(new Error("stream destroyed"))),this.on("error",i=>s(i)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[ut]=false;let t=false,s=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return s();let i=this.read();if(i!==null)return Promise.resolve({done:false,value:i});if(this[$t])return s();let n,o,a=f=>{this.off("data",l),this.off("end",h),this.off($,c),s(),o(f);},l=f=>{this.off("error",a),this.off("end",h),this.off($,c),this.pause(),n({value:f,done:!!this[$t]});},h=()=>{this.off("error",a),this.off("data",l),this.off($,c),s(),n({done:true,value:void 0});},c=()=>a(new Error("stream destroyed"));return new Promise((f,p)=>{o=p,n=f,this.once($,c),this.once("error",a),this.once("end",h),this.once("data",l);})},throw:s,return:s,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ut]=false;let t=false,s=()=>(this.pause(),this.off(gi,s),this.off($,s),this.off("end",s),t=true,{done:true,value:void 0}),i=()=>{if(t)return s();let n=this.read();return n===null?s():{done:false,value:n}};return this.once("end",s),this.once(gi,s),this.once($,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[$])return t?this.emit("error",t):this.emit($),this;this[$]=true,this[ut]=true,this[Z].length=0,this[K]=0;let s=this;return typeof s.close=="function"&&!this[Ns]&&s.close(),t?this.emit("error",t):this.emit($),this}static get isStream(){return ea}},ua=Zo.realpathSync.native,ss={lstatSync:Zo.lstatSync,readdir:Zo.readdir,readdirSync:Zo.readdirSync,readlinkSync:Zo.readlinkSync,realpathSync:ua,promises:{lstat:Rn.lstat,readdir:Rn.readdir,readlink:Rn.readlink,realpath:Rn.realpath}},en=e=>!e||e===ss||e===Zo__namespace?ss:{...ss,...e,promises:{...ss.promises,...e.promises||{}}},sn=/^\\\\\?\\([a-z]:)\\?$/i,da=e=>e.replace(/\//g,"\\").replace(sn,"$1\\"),pa=/[\\\/]/,vt=0,rn=1,nn=2,It=4,on=6,an=8,fe=10,ln=12,wt=15,Xe=~wt,bi=16,er=32,is=64,Ot=128,$s=256,Js=512,sr=is|Ot|Js,fa=1023,vi=e=>e.isFile()?an:e.isDirectory()?It:e.isSymbolicLink()?fe:e.isCharacterDevice()?nn:e.isBlockDevice()?on:e.isSocket()?ln:e.isFIFO()?rn:vt,ir=new ei({max:2**12}),rs=e=>{let t=ir.get(e);if(t)return t;let s=e.normalize("NFKD");return ir.set(e,s),s},rr=new ei({max:2**12}),Us=e=>{let t=rr.get(e);if(t)return t;let s=rs(e.toLowerCase());return rr.set(e,s),s},nr=class extends ei{constructor(){super({max:256});}},ga=class extends ei{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1});}},hn=Symbol("PathScurry setAsCwd"),ot,cs,us,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,Es,Cs,Os,ks,Rs,ae,Se,jt,Vt,qt,Jt,A,xe,Ht,Wt,R,Mi,Hs,ns,Li,Ti,os,Zs,Ai,_i,Ks,cn,un,dn,Fi,We,ze,pn,Ee,_r,ht=(_r=class{constructor(e,t=vt,s,i,n,o,a){m(this,R);u(this,"name");u(this,"root");u(this,"roots");u(this,"parent");u(this,"nocase");u(this,"isCWD",false);m(this,ot);m(this,cs);m(this,us);m(this,ds);m(this,ps);m(this,fs);m(this,gs);m(this,ms);m(this,ys);m(this,ws);m(this,bs);m(this,vs);m(this,Ss);m(this,xs);m(this,Es);m(this,Cs);m(this,Os);m(this,ks);m(this,Rs);m(this,ae);m(this,Se);m(this,jt);m(this,Vt);m(this,qt);m(this,Jt);m(this,A);m(this,xe);m(this,Ht);m(this,Wt);m(this,We,[]);m(this,ze,false);m(this,Ee);this.name=e,d(this,ae,n?Us(e):rs(e)),d(this,A,t&fa),this.nocase=n,this.roots=i,this.root=s||this,d(this,xe,o),d(this,jt,a.fullpath),d(this,qt,a.relative),d(this,Jt,a.relativePosix),this.parent=a.parent,this.parent?d(this,ot,r(this.parent,ot)):d(this,ot,en(a.fs));}get dev(){return r(this,cs)}get mode(){return r(this,us)}get nlink(){return r(this,ds)}get uid(){return r(this,ps)}get gid(){return r(this,fs)}get rdev(){return r(this,gs)}get blksize(){return r(this,ms)}get ino(){return r(this,ys)}get size(){return r(this,ws)}get blocks(){return r(this,bs)}get atimeMs(){return r(this,vs)}get mtimeMs(){return r(this,Ss)}get ctimeMs(){return r(this,xs)}get birthtimeMs(){return r(this,Es)}get atime(){return r(this,Cs)}get mtime(){return r(this,Os)}get ctime(){return r(this,ks)}get birthtime(){return r(this,Rs)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,Se)!==void 0?r(this,Se):this.parent?d(this,Se,this.parent.depth()+1):d(this,Se,0)}childrenCache(){return r(this,xe)}resolve(e){var i;if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?g(i=this.getRoot(t),R,Mi).call(i,s):g(this,R,Mi).call(this,s)}children(){let e=r(this,xe).get(this);if(e)return e;let t=Object.assign([],{provisional:0});return r(this,xe).set(this,t),d(this,A,r(this,A)&~bi),t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?Us(e):rs(e);for(let l of s)if(r(l,ae)===i)return l;let n=this.parent?this.sep:"",o=r(this,jt)?r(this,jt)+n+e:void 0,a=this.newChild(e,vt,{...t,parent:this,fullpath:o});return this.canReaddir()||d(a,A,r(a,A)|Ot),s.push(a),a}relative(){if(this.isCWD)return "";if(r(this,qt)!==void 0)return r(this,qt);let e=this.name,t=this.parent;if(!t)return d(this,qt,this.name);let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(r(this,Jt)!==void 0)return r(this,Jt);let e=this.name,t=this.parent;if(!t)return d(this,Jt,this.fullpathPosix());let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(r(this,jt)!==void 0)return r(this,jt);let e=this.name,t=this.parent;if(!t)return d(this,jt,this.name);let s=t.fullpath()+(t.parent?this.sep:"")+e;return d(this,jt,s)}fullpathPosix(){if(r(this,Vt)!==void 0)return r(this,Vt);if(this.sep==="/")return d(this,Vt,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?d(this,Vt,`//?/${i}`):d(this,Vt,i)}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return d(this,Vt,s)}isUnknown(){return (r(this,A)&wt)===vt}isType(e){return this[`is${e}`]()}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 (r(this,A)&wt)===an}isDirectory(){return (r(this,A)&wt)===It}isCharacterDevice(){return (r(this,A)&wt)===nn}isBlockDevice(){return (r(this,A)&wt)===on}isFIFO(){return (r(this,A)&wt)===rn}isSocket(){return (r(this,A)&wt)===ln}isSymbolicLink(){return (r(this,A)&fe)===fe}lstatCached(){return r(this,A)&er?this:void 0}readlinkCached(){return r(this,Ht)}realpathCached(){return r(this,Wt)}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(r(this,Ht))return true;if(!this.parent)return false;let e=r(this,A)&wt;return !(e!==vt&&e!==fe||r(this,A)&$s||r(this,A)&Ot)}calledReaddir(){return !!(r(this,A)&bi)}isENOENT(){return !!(r(this,A)&Ot)}isNamed(e){return this.nocase?r(this,ae)===Us(e):r(this,ae)===rs(e)}async readlink(){let e=r(this,Ht);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await r(this,ot).promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return d(this,Ht,s)}catch(t){g(this,R,_i).call(this,t.code);return}}readlinkSync(){let e=r(this,Ht);if(e)return e;if(this.canReadlink()&&this.parent)try{let t=r(this,ot).readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return d(this,Ht,s)}catch(t){g(this,R,_i).call(this,t.code);return}}async lstat(){if((r(this,A)&Ot)===0)try{return g(this,R,Fi).call(this,await r(this,ot).promises.lstat(this.fullpath())),this}catch(e){g(this,R,Ai).call(this,e.code);}}lstatSync(){if((r(this,A)&Ot)===0)try{return g(this,R,Fi).call(this,r(this,ot).lstatSync(this.fullpath())),this}catch(e){g(this,R,Ai).call(this,e.code);}}readdirCB(e,t=false){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let n=s.slice(0,s.provisional);t?e(null,n):queueMicrotask(()=>e(null,n));return}if(r(this,We).push(e),r(this,ze))return;d(this,ze,true);let i=this.fullpath();r(this,ot).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,R,Zs).call(this,n.code),s.provisional=0;else {for(let a of o)g(this,R,Ks).call(this,a,s);g(this,R,Hs).call(this,s);}g(this,R,pn).call(this,s.slice(0,s.provisional));});}async readdir(){if(!this.canReaddir())return [];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(r(this,Ee))await r(this,Ee);else {let s=()=>{};d(this,Ee,new Promise(i=>s=i));try{for(let i of await r(this,ot).promises.readdir(t,{withFileTypes:!0}))g(this,R,Ks).call(this,i,e);g(this,R,Hs).call(this,e);}catch(i){g(this,R,Zs).call(this,i.code),e.provisional=0;}d(this,Ee,void 0),s();}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return [];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of r(this,ot).readdirSync(t,{withFileTypes:!0}))g(this,R,Ks).call(this,s,e);g(this,R,Hs).call(this,e);}catch(s){g(this,R,Zs).call(this,s.code),e.provisional=0;}return e.slice(0,e.provisional)}canReaddir(){if(r(this,A)&sr)return false;let e=wt&r(this,A);return e===vt||e===It||e===fe}shouldWalk(e,t){return (r(this,A)&It)===It&&!(r(this,A)&sr)&&!e.has(this)&&(!t||t(this))}async realpath(){if(r(this,Wt))return r(this,Wt);if(!((Js|$s|Ot)&r(this,A)))try{let e=await r(this,ot).promises.realpath(this.fullpath());return d(this,Wt,this.resolve(e))}catch{g(this,R,Ti).call(this);}}realpathSync(){if(r(this,Wt))return r(this,Wt);if(!((Js|$s|Ot)&r(this,A)))try{let e=r(this,ot).realpathSync(this.fullpath());return d(this,Wt,this.resolve(e))}catch{g(this,R,Ti).call(this);}}[hn](e){if(e===this)return;e.isCWD=false,this.isCWD=true;let t=new Set([]),s=[],i=this;for(;i&&i.parent;)t.add(i),d(i,qt,s.join(this.sep)),d(i,Jt,s.join("/")),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)d(i,qt,void 0),d(i,Jt,void 0),i=i.parent;}},ot=new WeakMap,cs=new WeakMap,us=new WeakMap,ds=new WeakMap,ps=new WeakMap,fs=new WeakMap,gs=new WeakMap,ms=new WeakMap,ys=new WeakMap,ws=new WeakMap,bs=new WeakMap,vs=new WeakMap,Ss=new WeakMap,xs=new WeakMap,Es=new WeakMap,Cs=new WeakMap,Os=new WeakMap,ks=new WeakMap,Rs=new WeakMap,ae=new WeakMap,Se=new WeakMap,jt=new WeakMap,Vt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,A=new WeakMap,xe=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,R=new WeakSet,Mi=function(e){let t=this;for(let s of e)t=t.child(s);return t},Hs=function(e){var t;d(this,A,r(this,A)|bi);for(let s=e.provisional;s<e.length;s++){let i=e[s];i&&g(t=i,R,ns).call(t);}},ns=function(){r(this,A)&Ot||(d(this,A,(r(this,A)|Ot)&Xe),g(this,R,Li).call(this));},Li=function(){var t;let e=this.children();e.provisional=0;for(let s of e)g(t=s,R,ns).call(t);},Ti=function(){d(this,A,r(this,A)|Js),g(this,R,os).call(this);},os=function(){if(r(this,A)&is)return;let e=r(this,A);(e&wt)===It&&(e&=Xe),d(this,A,e|is),g(this,R,Li).call(this);},Zs=function(e=""){e==="ENOTDIR"||e==="EPERM"?g(this,R,os).call(this):e==="ENOENT"?g(this,R,ns).call(this):this.children().provisional=0;},Ai=function(e=""){var t;e==="ENOTDIR"?g(t=this.parent,R,os).call(t):e==="ENOENT"&&g(this,R,ns).call(this);},_i=function(e=""){var s;let t=r(this,A);t|=$s,e==="ENOENT"&&(t|=Ot),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Xe),d(this,A,t),e==="ENOTDIR"&&this.parent&&g(s=this.parent,R,os).call(s);},Ks=function(e,t){return g(this,R,un).call(this,e,t)||g(this,R,cn).call(this,e,t)},cn=function(e,t){let s=vi(e),i=this.newChild(e.name,s,{parent:this}),n=r(i,A)&wt;return n!==It&&n!==fe&&n!==vt&&d(i,A,r(i,A)|is),t.unshift(i),t.provisional++,i},un=function(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?Us(e.name):rs(e.name))===r(i,ae))return g(this,R,dn).call(this,e,i,s,t)}},dn=function(e,t,s,i){let n=t.name;return d(t,A,r(t,A)&Xe|vi(e)),n!==e.name&&(t.name=e.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(t)),i.provisional++,t},Fi=function(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:n,blksize:o,blocks:a,ctime:l,ctimeMs:h,dev:c,gid:f,ino:p,mode:y,mtime:b,mtimeMs:S,nlink:v,rdev:E,size:w,uid:k}=e;d(this,Cs,t),d(this,vs,s),d(this,Rs,i),d(this,Es,n),d(this,ms,o),d(this,bs,a),d(this,ks,l),d(this,xs,h),d(this,cs,c),d(this,fs,f),d(this,ys,p),d(this,us,y),d(this,Os,b),d(this,Ss,S),d(this,ds,v),d(this,gs,E),d(this,ws,w),d(this,ps,k);let M=vi(e);d(this,A,r(this,A)&Xe|M|er),M!==vt&&M!==It&&M!==fe&&d(this,A,r(this,A)|is);},We=new WeakMap,ze=new WeakMap,pn=function(e){d(this,ze,false);let t=r(this,We).slice();r(this,We).length=0,t.forEach(s=>s(null,e));},Ee=new WeakMap,_r),fn=class gn extends ht{constructor(s,i=vt,n,o,a,l,h){super(s,i,n,o,a,l,h);u(this,"sep","\\");u(this,"splitSep",pa);}newChild(s,i=vt,n={}){return new gn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(s){return zi.win32.parse(s).root}getRoot(s){if(s=da(s.toUpperCase()),s===this.root.name)return this.root;for(let[i,n]of Object.entries(this.roots))if(this.sameRoot(s,i))return this.roots[s]=n;return this.roots[s]=new ji(s,this).root}sameRoot(s,i=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(sn,"$1\\"),s===i}},mn=class yn extends ht{constructor(s,i=vt,n,o,a,l,h){super(s,i,n,o,a,l,h);u(this,"splitSep","/");u(this,"sep","/");}getRootString(s){return s.startsWith("/")?"/":""}getRoot(s){return this.root}newChild(s,i=vt,n={}){return new yn(s,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}},$e,Ue,Ms,Ls,Fr,wn=(Fr=class{constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:n=16*1024,fs:o=ss}={}){u(this,"root");u(this,"rootPath");u(this,"roots");u(this,"cwd");m(this,$e);m(this,Ue);m(this,Ms);u(this,"nocase");m(this,Ls);d(this,Ls,en(o)),(e instanceof URL||e.startsWith("file://"))&&(e=url.fileURLToPath(e));let a=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),d(this,$e,new nr),d(this,Ue,new nr),d(this,Ms,new ga(n));let l=a.substring(this.rootPath.length).split(s);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(r(this,Ls)),this.roots[this.rootPath]=this.root;let h=this.root,c=l.length-1,f=t.sep,p=this.rootPath,y=false;for(let b of l){let S=c--;h=h.child(b,{relative:new Array(S).fill("..").join(f),relativePosix:new Array(S).fill("..").join("/"),fullpath:p+=(y?"":f)+b}),y=true;}this.cwd=h;}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return r(this,Ms)}resolve(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,$e).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return r(this,$e).set(t,i),i}resolvePosix(...e){let t="";for(let n=e.length-1;n>=0;n--){let o=e[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=r(this,Ue).get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return r(this,Ue).set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let i=await e.readdir();return s?i:i.map(n=>n.name)}else return []}readdirSync(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let l=new Set,h=(f,p)=>{l.add(f),f.readdirCB((y,b)=>{if(y)return p(y);let S=b.length;if(!S)return p();let v=()=>{--S===0&&p();};for(let E of b)(!n||n(E))&&a.push(s?E:E.fullpath()),i&&E.isSymbolicLink()?E.realpath().then(w=>w?.isUnknown()?w.lstat():w).then(w=>w?.shouldWalk(l,o)?h(w,v):v()):E.shouldWalk(l,o)?h(E,v):v();},true);},c=e;return new Promise((f,p)=>{h(c,y=>{if(y)return p(y);f(a);});})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(e))&&a.push(s?e:e.fullpath());let l=new Set([e]);for(let h of l){let c=h.readdirSync();for(let f of c){(!n||n(f))&&a.push(s?f:f.fullpath());let p=f;if(f.isSymbolicLink()){if(!(i&&(p=f.realpathSync())))continue;p.isUnknown()&&p.lstatSync();}p.shouldWalk(l,o)&&l.add(p);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t;(!n||n(e))&&(yield s?e:e.fullpath());let a=new Set([e]);for(let l of a){let h=l.readdirSync();for(let c of h){(!n||n(c))&&(yield s?c:c.fullpath());let f=c;if(c.isSymbolicLink()){if(!(i&&(f=c.realpathSync())))continue;f.isUnknown()&&f.lstatSync();}f.shouldWalk(a,o)&&a.add(f);}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Xs({objectMode:true});(!n||n(e))&&a.write(s?e:e.fullpath());let l=new Set,h=[e],c=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){c===0&&a.end();return}c++,l.add(y);let b=(v,E,w=false)=>{if(v)return a.emit("error",v);if(i&&!w){let k=[];for(let M of E)M.isSymbolicLink()&&k.push(M.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(k.length){Promise.all(k).then(()=>b(null,E,true));return}}for(let k of E)k&&(!n||n(k))&&(a.write(s?k:k.fullpath())||(p=true));c--;for(let k of E){let M=k.realpathCached()||k;M.shouldWalk(l,o)&&h.push(M);}p&&!a.flowing?a.once("drain",f):S||f();},S=true;y.readdirCB(b,true),S=false;}};return f(),a}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ht||(t=e,e=this.cwd);let{withFileTypes:s=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Xs({objectMode:true}),l=new Set;(!n||n(e))&&a.write(s?e:e.fullpath());let h=[e],c=0,f=()=>{let p=false;for(;!p;){let y=h.shift();if(!y){c===0&&a.end();return}c++,l.add(y);let b=y.readdirSync();for(let S of b)(!n||n(S))&&(a.write(s?S:S.fullpath())||(p=true));c--;for(let S of b){let v=S;if(S.isSymbolicLink()){if(!(i&&(v=S.realpathSync())))continue;v.isUnknown()&&v.lstatSync();}v.shouldWalk(l,o)&&h.push(v);}}p&&!a.flowing&&a.once("drain",f);};return f(),a}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[hn](t);}},$e=new WeakMap,Ue=new WeakMap,Ms=new WeakMap,Ls=new WeakMap,Fr),ji=class extends wn{constructor(t=process.cwd(),s={}){let{nocase:i=true}=s;super(t,zi.win32,"\\",{...s,nocase:i});u(this,"sep","\\");this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase;}parseRootPath(t){return zi.win32.parse(t).root.toUpperCase()}newRoot(t){return new fn(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Wi=class extends wn{constructor(t=process.cwd(),s={}){let{nocase:i=false}=s;super(t,zi.posix,"/",{...s,nocase:i});u(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new mn(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},bn=class extends Wi{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,{...t,nocase:s});}};process.platform==="win32"?fn:mn;var ma=process.platform==="win32"?ji:process.platform==="darwin"?bn:Wi,ya=e=>e.length>=1,wa=e=>e.length>=1,ba=Symbol.for("nodejs.util.inspect.custom"),q,ct,J,Ce,Pt,Ts,le,he,ce,Be,Ge,vn=(Ge=class{constructor(t,s,i,n){m(this,q);m(this,ct);m(this,J);u(this,"length");m(this,Ce);m(this,Pt);m(this,Ts);m(this,le);m(this,he);m(this,ce);m(this,Be,true);if(!ya(t))throw new TypeError("empty pattern list");if(!wa(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(d(this,q,t),d(this,ct,s),d(this,J,i),d(this,Ce,n),r(this,J)===0){if(this.isUNC()){let[o,a,l,h,...c]=r(this,q),[f,p,y,b,...S]=r(this,ct);c[0]===""&&(c.shift(),S.shift());let v=[o,a,l,h,""].join("/"),E=[f,p,y,b,""].join("/");d(this,q,[v,...c]),d(this,ct,[E,...S]),this.length=r(this,q).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=r(this,q),[l,...h]=r(this,ct);a[0]===""&&(a.shift(),h.shift());let c=o+"/",f=l+"/";d(this,q,[c,...a]),d(this,ct,[f,...h]),this.length=r(this,q).length;}}}[ba](){return "Pattern <"+r(this,ct).slice(r(this,J)).join("/")+">"}pattern(){return r(this,q)[r(this,J)]}isString(){return typeof r(this,q)[r(this,J)]=="string"}isGlobstar(){return r(this,q)[r(this,J)]===at}isRegExp(){return r(this,q)[r(this,J)]instanceof RegExp}globString(){return d(this,Ts,r(this,Ts)||(r(this,J)===0?this.isAbsolute()?r(this,ct)[0]+r(this,ct).slice(1).join("/"):r(this,ct).join("/"):r(this,ct).slice(r(this,J)).join("/")))}hasMore(){return this.length>r(this,J)+1}rest(){return r(this,Pt)!==void 0?r(this,Pt):this.hasMore()?(d(this,Pt,new Ge(r(this,q),r(this,ct),r(this,J)+1,r(this,Ce))),d(r(this,Pt),ce,r(this,ce)),d(r(this,Pt),he,r(this,he)),d(r(this,Pt),le,r(this,le)),r(this,Pt)):d(this,Pt,null)}isUNC(){let t=r(this,q);return r(this,he)!==void 0?r(this,he):d(this,he,r(this,Ce)==="win32"&&r(this,J)===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3])}isDrive(){let t=r(this,q);return r(this,le)!==void 0?r(this,le):d(this,le,r(this,Ce)==="win32"&&r(this,J)===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]))}isAbsolute(){let t=r(this,q);return r(this,ce)!==void 0?r(this,ce):d(this,ce,t[0]===""&&t.length>1||this.isDrive()||this.isUNC())}root(){let t=r(this,q)[0];return typeof t=="string"&&this.isAbsolute()&&r(this,J)===0?t:""}checkFollowGlobstar(){return !(r(this,J)===0||!this.isGlobstar()||!r(this,Be))}markFollowGlobstar(){return r(this,J)===0||!this.isGlobstar()||!r(this,Be)?false:(d(this,Be,false),true)}},q=new WeakMap,ct=new WeakMap,J=new WeakMap,Ce=new WeakMap,Pt=new WeakMap,Ts=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,Be=new WeakMap,Ge),va=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",or=class{constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:n,platform:o=va}){u(this,"relative");u(this,"relativeChildren");u(this,"absolute");u(this,"absoluteChildren");u(this,"platform");u(this,"mmopts");this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:true,nobrace:t,nocase:s,noext:i,noglobstar:n,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of e)this.add(a);}add(e){let t=new de(e,this.mmopts);for(let s=0;s<t.set.length;s++){let i=t.set[s],n=t.globParts[s];if(!i||!n)throw new Error("invalid pattern object");for(;i[0]==="."&&n[0]===".";)i.shift(),n.shift();let o=new vn(i,n,0,this.platform),a=new de(o.globString(),this.mmopts),l=n[n.length-1]==="**",h=o.isAbsolute();h?this.absolute.push(a):this.relative.push(a),l&&(h?this.absoluteChildren.push(a):this.relativeChildren.push(a));}}ignored(e){let t=e.fullpath(),s=`${t}/`,i=e.relative()||".",n=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(n))return true;for(let o of this.absolute)if(o.match(t)||o.match(s))return true;return false}childrenIgnored(e){let t=e.fullpath()+"/",s=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return true;for(let i of this.absoluteChildren)if(i.match(t))return true;return false}},Sa=class Sn{constructor(t=new Map){u(this,"store");this.store=t;}copy(){return new Sn(new Map(this.store))}hasWalked(t,s){return this.store.get(t.fullpath())?.has(s.globString())}storeWalked(t,s){let i=t.fullpath(),n=this.store.get(i);n?n.add(s.globString()):this.store.set(i,new Set([s.globString()]));}},xa=class{constructor(){u(this,"store",new Map);}add(e,t,s){let i=(t?2:0)|(s?1:0),n=this.store.get(e);this.store.set(e,n===void 0?i:i&n);}entries(){return [...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},Ea=class{constructor(){u(this,"store",new Map);}add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(i=>i.globString()===t.globString())||s.push(t):this.store.set(e,[t]);}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return [...this.store.keys()].filter(e=>e.canReaddir())}},ar=class xn{constructor(t,s){u(this,"hasWalkedCache");u(this,"matches",new xa);u(this,"subwalks",new Ea);u(this,"patterns");u(this,"follow");u(this,"dot");u(this,"opts");this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new Sa;}processPatterns(t,s){this.patterns=s;let i=s.map(n=>[t,n]);for(let[n,o]of i){this.hasWalkedCache.storeWalked(n,o);let a=o.root(),l=o.isAbsolute()&&this.opts.absolute!==false;if(a){n=n.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let p=o.rest();if(p)o=p;else {this.matches.add(n,true,false);continue}}if(n.isENOENT())continue;let h,c,f=false;for(;typeof(h=o.pattern())=="string"&&(c=o.rest());)n=n.resolve(h),o=c,f=true;if(h=o.pattern(),c=o.rest(),f){if(this.hasWalkedCache.hasWalked(n,o))continue;this.hasWalkedCache.storeWalked(n,o);}if(typeof h=="string"){let p=h===".."||h===""||h===".";this.matches.add(n.resolve(h),l,p);continue}else if(h===at){(!n.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(n,o);let p=c?.pattern(),y=c?.rest();if(!c||(p===""||p===".")&&!y)this.matches.add(n,l,p===""||p===".");else if(p===".."){let b=n.parent||n;y?this.hasWalkedCache.hasWalked(b,y)||this.subwalks.add(b,y):this.matches.add(b,l,true);}}else h instanceof RegExp&&this.subwalks.add(n,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new xn(this.opts,this.hasWalkedCache)}filterEntries(t,s){let i=this.subwalks.get(t),n=this.child();for(let o of s)for(let a of i){let l=a.isAbsolute(),h=a.pattern(),c=a.rest();h===at?n.testGlobstar(o,a,c,l):h instanceof RegExp?n.testRegExp(o,h,c,l):n.testString(o,h,c,l);}return n}testGlobstar(t,s,i,n){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,n,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(i&&s.checkFollowGlobstar()?this.subwalks.add(t,i):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),i){let o=i.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,i.rest(),n);else if(o===".."){let a=t.parent||t;this.subwalks.add(a,i);}else o instanceof RegExp&&this.testRegExp(t,o,i.rest(),n);}}testRegExp(t,s,i,n){s.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}testString(t,s,i,n){t.isNamed(s)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}},Ca=(e,t)=>typeof e=="string"?new or([e],t):Array.isArray(e)?new or(e,t):e,Ve,Zt,Oe,St,ge,Pi,Pr,En=(Pr=class{constructor(e,t,s){m(this,St);u(this,"path");u(this,"patterns");u(this,"opts");u(this,"seen",new Set);u(this,"paused",false);u(this,"aborted",false);m(this,Ve,[]);m(this,Zt);m(this,Oe);u(this,"signal");u(this,"maxDepth");u(this,"includeChildMatches");if(this.patterns=e,this.path=t,this.opts=s,d(this,Oe,!s.posix&&s.platform==="win32"?"\\":"/"),this.includeChildMatches=s.includeChildMatches!==false,(s.ignore||!this.includeChildMatches)&&(d(this,Zt,Ca(s.ignore??[],s)),!this.includeChildMatches&&typeof r(this,Zt).add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{r(this,Ve).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let e;for(;!this.paused&&(e=r(this,Ve).shift());)e();}onResume(e){this.signal?.aborted||(this.paused?r(this,Ve).push(e):e());}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=await i.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat();}return this.matchCheckTest(i,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!g(this,St,ge).call(this,e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s;}let i=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let n=i.realpathSync();n&&(n?.isUnknown()||this.opts.stat)&&n.lstatSync();}return this.matchCheckTest(i,t)}matchFinish(e,t){if(g(this,St,ge).call(this,e))return;if(!this.includeChildMatches&&r(this,Zt)?.add){let n=`${e.relativePosix()}/**`;r(this,Zt).add(n);}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?r(this,Oe):"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let n=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(n+i);}else {let n=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+r(this,Oe))?"."+r(this,Oe):"";this.matchEmit(n?o+n+i:"."+i);}}async match(e,t,s){let i=await this.matchCheck(e,s);i&&this.matchFinish(i,t);}matchSync(e,t,s){let i=this.matchCheckSync(e,s);i&&this.matchFinish(i,t);}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new ar(this.opts),s);}walkCB2(e,t,s,i){if(g(this,St,Pi).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,s,o):a.readdirCB((h,c)=>this.walkCB3(a,c,s,o),true);}o();}walkCB3(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let[a,l]of s.subwalks.entries())n++,this.walkCB2(a,l,s.child(),o);o();}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new ar(this.opts),s);}walkCB2Sync(e,t,s,i){if(g(this,St,Pi).call(this,e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,i));return}s.processPatterns(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||this.matchSync(a,l,h);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirSync();this.walkCB3Sync(a,l,s,o);}o();}walkCB3Sync(e,t,s,i){s=s.filterEntries(e,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of s.matches.entries())g(this,St,ge).call(this,a)||this.matchSync(a,l,h);for(let[a,l]of s.subwalks.entries())n++,this.walkCB2Sync(a,l,s.child(),o);o();}},Ve=new WeakMap,Zt=new WeakMap,Oe=new WeakMap,St=new WeakSet,ge=function(e){return this.seen.has(e)||!!r(this,Zt)?.ignored?.(e)},Pi=function(e){return !!r(this,Zt)?.childrenIgnored?.(e)},Pr),lr=class extends En{constructor(t,s,i){super(t,s,i);u(this,"matches",new Set);}matchEmit(t){this.matches.add(t);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,s)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?s(this.signal.reason):t(this.matches);});}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},hr=class extends En{constructor(t,s,i){super(t,s,i);u(this,"results");this.results=new Xs({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(t){this.results.write(t),this.results.flowing||this.pause();}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end());}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},Oa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Re=class{constructor(e,t){u(this,"absolute");u(this,"cwd");u(this,"root");u(this,"dot");u(this,"dotRelative");u(this,"follow");u(this,"ignore");u(this,"magicalBraces");u(this,"mark");u(this,"matchBase");u(this,"maxDepth");u(this,"nobrace");u(this,"nocase");u(this,"nodir");u(this,"noext");u(this,"noglobstar");u(this,"pattern");u(this,"platform");u(this,"realpath");u(this,"scurry");u(this,"stat");u(this,"signal");u(this,"windowsPathsNoEscape");u(this,"withFileTypes");u(this,"includeChildMatches");u(this,"opts");u(this,"patterns");if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=url.fileURLToPath(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==false,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(e=e.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(l=>l.includes("/")?l:`./**/${l}`);}if(this.pattern=e,this.platform=t.platform||Oa,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let l=t.platform==="win32"?ji:t.platform==="darwin"?bn:t.platform?Wi:ma;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},n=this.pattern.map(l=>new de(l,i)),[o,a]=n.reduce((l,h)=>(l[0].push(...h.set),l[1].push(...h.globParts),l),[[],[]]);this.patterns=o.map((l,h)=>{let c=a[h];if(!c)throw new Error("invalid pattern object");return new vn(l,c,0,this.platform)});}async walk(){return [...await new lr(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 lr(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 hr(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 hr(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()}},ka=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new de(s,t).hasMagic())return true;return false};function si(e,t={}){return new Re(e,t).streamSync()}function Cn(e,t={}){return new Re(e,t).stream()}function On(e,t={}){return new Re(e,t).walkSync()}async function cr(e,t={}){return new Re(e,t).walk()}function ii(e,t={}){return new Re(e,t).iterateSync()}function kn(e,t={}){return new Re(e,t).iterate()}var Ra=si,Ma=Object.assign(Cn,{sync:si}),La=ii,Ta=Object.assign(kn,{sync:ii}),Aa=Object.assign(On,{stream:si,iterate:ii}),ti=Object.assign(cr,{glob:cr,globSync:On,sync:Aa,globStream:Cn,stream:Ma,globStreamSync:si,streamSync:Ra,globIterate:kn,iterate:Ta,globIterateSync:ii,iterateSync:La,Glob:Re,hasMagic:ka,escape:Gr,unescape:_e});ti.glob=ti;var Kt;(C=>{C.Level=Fa__default.default.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let t={DEBUG:0,INFO:1,WARN:2,ERROR:3},s="INFO";function i(O){return t[O]>=t[s]}function n(){return s}C.getLevel=n;let o=new Map;C.Default=M({service:"default"});let l="";function h(){return l}C.file=h;let c,f,p=false,y=()=>{},b=false;async function S(O){if(p)return;if(O.print){p=true;return}O.level&&(s=O.level);let T=O.logDir||zi__default.default.join(process.cwd(),"logs");O.logFile?l=zi__default.default.join(T,O.logFile??"ollama-sdk.log"):l=zi__default.default.join(T,"ollama-sdk.log");try{c=await Rn__default.default.open(l,"a"),f=Zo.createWriteStream("",{fd:c.fd,autoClose:!1}),y=F=>{if(!(b||!f||f.destroyed))try{if(!f.writable)return;f.write(F,D=>{D&&!b&&(b=!0,setTimeout(()=>{b=!1;},1e3));});}catch{b||(b=!0,setTimeout(()=>{b=!1;},1e3));}},p=!0;}catch{y=F=>{try{process.stderr.write(F);}catch{}},p=true;}}C.init=S;async function v(){p&&(f&&!f.destroyed&&(await new Promise((O,T)=>{f.end(F=>{F?T(F):O();});}).catch(()=>{}),f=void 0),c&&(await c.close().catch(()=>{}),c=void 0),y=O=>{try{process.stderr.write(O);}catch{}},p=false);}C.close=v;function w(O,T=0){let F=O.message;return O.cause instanceof Error&&T<10?F+" Caused by: "+w(O.cause,T+1):F}let k=Date.now();function M(O){O=O||{};let T=O.service;if(T&&typeof T=="string"){let L=o.get(T);if(L)return L}function F(L,P){let W=Object.entries({...O,...P}).filter(([$i,Yt])=>Yt!=null).map(([$i,Yt])=>{let ai=`${$i}=`;return Yt instanceof Error?ai+w(Yt):typeof Yt=="object"?ai+JSON.stringify(Yt):ai+Yt}).join(" "),z=new Date,_s=z.getTime()-k;return k=z.getTime(),[z.getFullYear()+"-"+String(z.getMonth()+1).padStart(2,"0")+"-"+String(z.getDate()).padStart(2,"0")+"T"+String(z.getHours()).padStart(2,"0")+":"+String(z.getMinutes()).padStart(2,"0")+":"+String(z.getSeconds()).padStart(2,"0"),"+"+_s+"ms",W,L].filter(Boolean).join(" ")+`
|
|
5
|
+
`}let D={debug(L,P){i("DEBUG")&&y("DEBUG "+F(L,P));},info(L,P){i("INFO")&&y("INFO "+F(L,P));},error(L,P){i("ERROR")&&y("ERROR "+F(L,P));},warn(L,P){i("WARN")&&y("WARN "+F(L,P));},tag(L,P){return O&&(O[L]=P),D},clone(){return C.create({...O})},time(L,P){let W=Date.now();D.info(L,{status:"started",...P});function z(){D.info(L,{status:"completed",duration:Date.now()-W,...P});}return {stop:z,[Symbol.dispose](){z();}}}};return T&&typeof T=="string"&&o.set(T,D),D}C.create=M;})(Kt||(Kt={}));function Mn(e,t,s){let i;return t?i="tool-calls":e?i="stop":i="other",{unified:i,raw:s}}var xt=Kt.create({service:"ollama-sdk",module:"native-language-model"});function ri(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ni(e){if(!e||e.trim().length===0)return false;try{return JSON.parse(e),!0}catch{return false}}function Ln(e){return typeof e=="string"?e:JSON.stringify(e)}function Tn(e){return !e.tools||e.tools.length===0?{}:{tools:e.tools.map(t=>{if(!t.name)throw new Je(t.name||"unknown","name");let s=t.inputSchema||t.parameters;if(!s)throw new Je(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:s}}})}}function An(e){let t=[];for(let s of e)try{switch(s.role){case "system":t.push({role:"system",content:s.content});break;case "user":{let i=s.content.filter(n=>n.type==="text").map(n=>n.text).join(`
|
|
6
|
+
`);i&&t.push({role:"user",content:i});break}case "assistant":{let i="",n=[];for(let o of s.content)if(o.type==="text")i+=o.text;else if(o.type==="tool-call"){let a=o;n.push({id:a.toolCallId,type:"function",function:{name:a.toolName,arguments:JSON.stringify(a.input)}});}t.push({role:"assistant",content:i||null,tool_calls:n.length>0?n:void 0});break}case "tool":for(let i of s.content){let n=i.output,o;switch(n.type){case "text":case "error-text":o=n.value;break;case "content":case "json":case "error-json":o=JSON.stringify(n.value);break;default:o=String(n.value);break}t.push({role:"tool",tool_call_id:i.toolCallId,content:o});}break}}catch(i){xt.warn("Failed to convert message",{messageRole:s.role,error:i instanceof Error?i.message:String(i)});}return t}var oi=class{constructor(t,s={}){u(this,"specificationVersion","v3");u(this,"provider","ollama");u(this,"modelId");u(this,"defaultObjectGenerationMode","json");u(this,"supportedUrls",{});u(this,"client");this.modelId=t,this.client=new Ps(s.baseURL);}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}async doStream(t){let s=ri();xt.debug("Stream request started",{traceId:s,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=An(t.prompt),n=Tn({tools:t.tools}),o=JSON.stringify({model:this.modelId,messages:i,options:Le,...n}),a=null,l=null,h=b=>{a&&a.enqueue(b),l&&l.enqueue(b);},c=async()=>{try{let b=!0,S=!1,v=!1,E="",w="",k=!1,M=[],C=[],O=()=>{if(C.length>0){for(let F of C)h(F);C.length=0;}},T=null;for await(let F of this.client.streamChat({model:this.modelId,messages:i,options:Le,...n})){if(T&&T.chunkCount++,b){b=!1;let D={type:"response-metadata",id:ri(),modelId:this.modelId,timestamp:new Date(F.created_at)};h(D),T&&T.eventCount++;}if(F.message?.tool_calls){v&&(C.push({type:"reasoning-end",id:"reasoning-0"}),v=!1),S&&(C.push({type:"text-end",id:"txt-0"}),S=!1);for(let D of F.message.tool_calls){if(!D.id||!D.function?.name){let qe=D.id?"function.name":"id";xt.error("Invalid tool call: missing field",{traceId:s,missingField:qe,toolCall:void 0}),C.push({type:"error",error:`Invalid tool call: missing ${qe}`});continue}let L=D.id,P=D.function.name,W=Ln(D.function.arguments),z=M.find(qe=>qe.id===L);z?(z.function.arguments+=W,xt.debug("Tool call arguments accumulated",{traceId:s,toolCallId:L,toolName:P,deltaLength:W.length,totalLength:z.function.arguments.length,isComplete:ni(z.function.arguments)}),W&&C.push({type:"tool-input-delta",id:L,delta:W})):(z={id:L,type:"function",function:{name:P,arguments:W},hasFinished:!1},M.push(z),T&&T.toolCallCount++,xt.debug("Tool call received",{traceId:s,toolCallId:L,toolName:P,argumentsLength:W.length,isComplete:ni(W)}),C.push({type:"tool-input-start",id:L,toolName:P}),W&&C.push({type:"tool-input-delta",id:L,delta:W}));let _s=ni(z.function.arguments);!z.hasFinished&&_s&&(xt.debug("Tool call arguments complete",{traceId:s,toolCallId:L,toolName:P,isComplete:_s,argumentsLength:z.function.arguments.length}),C.push({type:"tool-input-end",id:L}),C.push({type:"tool-call",toolCallId:L,toolName:P,input:z.function.arguments}),z.hasFinished=!0);}O(),T&&(T.eventCount+=C.length);}if(F.message?.content){let D=F.message.content;for(w+=D;w.length>0;)if(k){let L=w.indexOf("</think>");if(L===-1){w.length>0&&C.push({type:"reasoning-delta",id:"reasoning-0",delta:w}),w="";break}else {if(L>0){let P=w.substring(0,L);C.push({type:"reasoning-delta",id:"reasoning-0",delta:P});}C.push({type:"reasoning-end",id:"reasoning-0"}),v=!1,k=!1,w=w.substring(L+8);}}else {let L=w.indexOf("<think>");if(L===-1){w.length>0&&(S||(S=!0,C.push({type:"text-start",id:"txt-0"})),C.push({type:"text-delta",id:"txt-0",delta:w}),E+=w),w="";break}else {if(L>0){let P=w.substring(0,L);S||(S=!0,C.push({type:"text-start",id:"txt-0"})),C.push({type:"text-delta",id:"txt-0",delta:P}),E+=P,C.push({type:"text-end",id:"txt-0"}),S=!1;}k=!0,w=w.substring(L+7),v||(v=!0,C.push({type:"reasoning-start",id:"reasoning-0"}));}}}if(O(),T&&(T.eventCount+=C.length),F.done){let D=M.filter(W=>!W.hasFinished);for(let W of D)C.push({type:"tool-input-end",id:W.id}),C.push({type:"tool-call",toolCallId:W.id,toolName:W.function.name,input:W.function.arguments});w.length>0&&(k?(C.push({type:"reasoning-delta",id:"reasoning-0",delta:w}),C.push({type:"reasoning-end",id:"reasoning-0"})):(S||(S=!0,C.push({type:"text-start",id:"txt-0"})),C.push({type:"text-delta",id:"txt-0",delta:w}),E+=w)),S&&C.push({type:"text-end",id:"txt-0"});let P=M.length>0?"tool-calls":"stop";if(C.push({type:"finish",finishReason:P,usage:{inputTokens:{total:F.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:F.eval_count||0,text:void 0,reasoning:void 0}},providerMetadata:{ollama:{totalDuration:F.total_duration||0,loadDuration:F.load_duration||0,promptEvalDuration:F.prompt_eval_duration||0,evalDuration:F.eval_duration||0}}}),O(),T&&(T.eventCount+=C.length),T);M.length=0;}}}catch(b){xt.error("Stream processing error",{traceId:s,error:b instanceof Error?b.message:String(b),stack:void 0}),h({type:"error",error:b instanceof Error?b.message:String(b)}),h({type:"finish",finishReason:"error",usage:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}});}finally{a&&a.close(),l&&l.close();}},f=new ReadableStream({start(b){a=b;}}),p=new ReadableStream({start(b){l=b;}});c();async function*y(b){let S=b.getReader();try{for(;;){let{done:v,value:E}=await S.read();if(v)break;yield E;}}finally{S.releaseLock();}}return {stream:f,fullStream:y(p),request:{body:o},response:{}}}async doGenerate(t){let s=ri();xt.debug("Generate request started",{traceId:s,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=An(t.prompt),n=Tn({tools:t.tools}),o=await this.client.chat({model:this.modelId,messages:i,options:Le,...n}),a=[];if(o.message?.content&&a.push({type:"text",text:o.message.content}),o.message?.tool_calls){xt.debug("Tool calls received in generate",{traceId:s,toolCallCount:o.message.tool_calls.length});for(let c of o.message.tool_calls){let f=c.id||ri(),p=c.function.name,y=Ln(c.function.arguments);xt.debug("Processing tool call in generate",{traceId:s,toolCallId:f,toolName:p,argumentsLength:y.length,isComplete:ni(y)}),a.push({type:"tool-call",toolCallId:f,toolName:p,input:y});}}let l=!!(o.message?.tool_calls&&o.message.tool_calls.length>0),h=Mn(o.done??false,l,"stop");return xt.debug("Generate request completed",{traceId:s,finishReason:h,contentParts:a.length,hasToolCalls:l,inputTokens:o.prompt_eval_count||0,outputTokens:o.eval_count||0}),{content:a,finishReason:h,usage:{inputTokens:{total:o.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:o.eval_count||0,text:void 0,reasoning:void 0}},providerMetadata:{ollama:{totalDuration:o.total_duration||0,loadDuration:o.load_duration||0,promptEvalDuration:o.prompt_eval_duration||0,evalDuration:o.eval_duration||0}},request:{body:JSON.stringify({model:this.modelId,messages:i,options:Le,...n})},response:{}}}};var Me=class{constructor(t,s={}){u(this,"specificationVersion","v3");u(this,"provider","ollama");u(this,"modelId");u(this,"defaultObjectGenerationMode","json");u(this,"supportedUrls",{});u(this,"nativeModel");this.modelId=t,this.nativeModel=new oi(t,{baseURL:s.baseURL||"http://localhost:11434"});}doGenerate(t){return this.nativeModel.doGenerate(t)}doStream(t){return this.nativeModel.doStream(t)}async generate(t){return this.nativeModel.generate(t)}async stream(t){return this.nativeModel.stream(t)}};var As=class{constructor(t,s={}){u(this,"specificationVersion","v3");u(this,"provider","ollama");u(this,"modelId");u(this,"maxEmbeddingsPerCall");u(this,"supportsParallelCalls",true);u(this,"baseURL");this.modelId=t,this.baseURL=s.baseURL||"http://localhost:11434";}async doEmbed(t){let{values:s,abortSignal:i}=t,n=Kt.create({service:"ollama-embedding"});if(!s||s.length===0)return n.warn("Empty values array provided",{modelId:this.modelId}),{embeddings:[],usage:{tokens:0},warnings:[]};n.debug("Generating text embeddings",{modelId:this.modelId,valuesCount:s.length,baseURL:this.baseURL});try{let o=await Promise.all(s.map(l=>this.generateSingleEmbedding(l,i))),a=s.reduce((l,h)=>l+this.estimateTokens(h),0);return n.debug("Text embeddings generated successfully",{modelId:this.modelId,embeddingsCount:o.length,totalTokens:a}),{embeddings:o,usage:{tokens:a},warnings:[]}}catch(o){throw n.error("Text embedding generation failed",{modelId:this.modelId,error:o instanceof Error?o.message:String(o),stack:void 0}),o}}async generateSingleEmbedding(t,s){let i=`${this.baseURL}/api/embeddings`;try{let n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:this.modelId,prompt:t}),signal:s});if(!n.ok){let a=await n.text();throw new Error(`Ollama embedding API error (${n.status}): ${a}`)}let o=await n.json();if(!o.embedding||!Array.isArray(o.embedding))throw new Error("Invalid response format from Ollama embedding API");return o.embedding}catch(n){throw n instanceof TypeError&&n.message.includes("fetch")?new Error(`Failed to connect to Ollama server at ${this.baseURL}: ${n.message}`):n}}estimateTokens(t){let s=t.match(/[a-zA-Z]/g)?.length||0,i=t.match(/[\u4e00-\u9fa5]/g)?.length||0,n=t.length-s-i;return Math.ceil(s/4)+i+Math.ceil(n*.5)}};function Da(e={}){if(e.logDir){let s=e.logLevel??"INFO",i=zi__default.default.join(e.logDir,"ollama-sdk.log");Kt.init({print:process.argv.includes("--print-logs"),logDir:e.logDir,level:s,logFile:"ollama-sdk.log"}).then(()=>{Kt.create({service:"ollama-sdk",module:"provider"}).debug("Ollama provider created",{baseURL:e.baseURL||"http://localhost:11434",logFile:i,logLevel:s});});}return Object.assign(s=>new Me(s,e),{languageModel:s=>new Me(s,e),chat:s=>new Me(s,e),textEmbeddingModel:s=>new As(s,e)})}var Ia="0.1.0";
|
|
7
|
+
exports.ConnectionError=hi;exports.ModelNotFoundError=ci;exports.OLLAMA_DEFAULT_OPTIONS=Le;exports.OLLAMA_SPECIFIC_PARAMS=Pn;exports.OllamaEmbeddingModel=As;exports.OllamaError=Qt;exports.OllamaLanguageModel=Me;exports.TimeoutError=di;exports.VERSION=Ia;exports.ValidationError=ui;exports.createOllama=Da;
|