@easbot/ollama-sdk 0.2.48 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,16 +1,13 @@
1
- 'use strict';var ri=require('path'),Mn=require('fs/promises'),Yo=require('fs'),Ia=require('zod'),url=require('url'),events=require('events'),tn=require('stream'),string_decoder=require('string_decoder'),utils=require('@easbot/utils');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 ri__default=/*#__PURE__*/_interopDefault(ri);var Mn__default=/*#__PURE__*/_interopDefault(Mn);var Yo__namespace=/*#__PURE__*/_interopNamespace(Yo);var Ia__default=/*#__PURE__*/_interopDefault(Ia);var tn__default=/*#__PURE__*/_interopDefault(tn);var Fn=Object.defineProperty;var Bi=s=>{throw TypeError(s)};var In=(s,t,e)=>t in s?Fn(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e;var c=(s,t,e)=>In(s,typeof t!="symbol"?t+"":t,e),ci=(s,t,e)=>t.has(s)||Bi("Cannot "+e);var r=(s,t,e)=>(ci(s,t,"read from private field"),e?e.call(s):t.get(s)),y=(s,t,e)=>t.has(s)?Bi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),p=(s,t,e,i)=>(ci(s,t,"write to private field"),t.set(s,e),e),g=(s,t,e)=>(ci(s,t,"access private method"),e);var Ps=(s,t,e,i)=>({set _(n){p(s,t,n);},get _(){return r(s,t,i)}});var Fs=class{constructor(t="http://localhost:11434"){c(this,"baseURL",t);}async*streamChat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:true})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);if(!e.body)throw new Error("Response body is null");let i=e.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 d of h){let f=d.trim();if(f)try{yield JSON.parse(f);}catch{}}}}finally{i.releaseLock();}}async chat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);return e.json()}};var Te={numCtx:262144,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},Dn=["numCtx","repeatPenalty","numPredict"];var te=class extends Error{constructor(e,i){super(e);c(this,"cause",i);this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},ui=class extends te{constructor(e,i,n){super(e,n);c(this,"url",i);this.name="ConnectionError";}},di=class extends te{constructor(e,i){super(`Model not found: ${e}`,i);c(this,"modelId",e);this.name="ModelNotFoundError";}},pi=class extends te{constructor(e,i,n,o){super(e,o);c(this,"field",i);c(this,"value",n);this.name="ValidationError";}},fi=class extends te{constructor(e,i,n){super(e,n);c(this,"timeoutMs",i);this.name="TimeoutError";}},He=class extends te{constructor(e,i,n){super(`Invalid tool definition for "${e}": missing ${i}`,n);c(this,"toolName",e);c(this,"missingField",i);this.name="InvalidToolDefinitionError";}};var Dr=(s,t,e)=>{let i=s instanceof RegExp?Gi(s,e):s,n=t instanceof RegExp?Gi(t,e):t,o=i!==null&&n!=null&&Nn(i,n,e);return o&&{start:o[0],end:o[1],pre:e.slice(0,o[0]),body:e.slice(o[0]+i.length,o[1]),post:e.slice(o[1]+n.length)}},Gi=(s,t)=>{let e=t.match(s);return e?e[0]:null},Nn=(s,t,e)=>{let i,n,o,a,l,h=e.indexOf(s),d=e.indexOf(t,h+1),f=h;if(h>=0&&d>0){if(s===t)return [h,d];for(i=[],o=e.length;f>=0&&!l;){if(f===h)i.push(f),h=e.indexOf(s,f+1);else if(i.length===1){let u=i.pop();u!==void 0&&(l=[u,d]);}else n=i.pop(),n!==void 0&&n<o&&(o=n,a=d),d=e.indexOf(t,f+1);f=h<d&&h>=0?h:d;}i.length&&a!==void 0&&(l=[o,a]);}return l},Nr="\0SLASH"+Math.random()+"\0",jr="\0OPEN"+Math.random()+"\0",Ni="\0CLOSE"+Math.random()+"\0",Wr="\0COMMA"+Math.random()+"\0",$r="\0PERIOD"+Math.random()+"\0",jn=new RegExp(Nr,"g"),Wn=new RegExp(jr,"g"),$n=new RegExp(Ni,"g"),zn=new RegExp(Wr,"g"),Un=new RegExp($r,"g"),Bn=/\\\\/g,Gn=/\\{/g,Vn=/\\}/g,qn=/\\,/g,Jn=/\\./g,Hn=1e5;function gi(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function Zn(s){return s.replace(Bn,Nr).replace(Gn,jr).replace(Vn,Ni).replace(qn,Wr).replace(Jn,$r)}function Kn(s){return s.replace(jn,"\\").replace(Wn,"{").replace($n,"}").replace(zn,",").replace(Un,".")}function zr(s){if(!s)return [""];let t=[],e=Dr("{","}",s);if(!e)return s.split(",");let{pre:i,body:n,post:o}=e,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 Yn(s,t={}){if(!s)return [];let{max:e=Hn}=t;return s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),es(Zn(s),e,true).map(Kn)}function Qn(s){return "{"+s+"}"}function Xn(s){return /^-?0\d/.test(s)}function to(s,t){return s<=t}function eo(s,t){return s>=t}function es(s,t,e){let i=[],n=Dr("{","}",s);if(!n)return [s];let o=n.pre,a=n.post.length?es(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(/,(?!,).*\}/)?(s=n.pre+"{"+n.body+Ni+n.post,es(s,t,true)):[s];let u;if(d)u=n.body.split(/\.\./);else if(u=zr(n.body),u.length===1&&u[0]!==void 0&&(u=es(u[0],t,false).map(Qn),u.length===1))return a.map(w=>n.pre+u[0]+w);let m;if(d&&u[0]!==void 0&&u[1]!==void 0){let w=gi(u[0]),v=gi(u[1]),S=Math.max(u[0].length,u[1].length),k=u.length===3&&u[2]!==void 0?Math.abs(gi(u[2])):1,b=to;v<w&&(k*=-1,b=eo);let R=u.some(Xn);m=[];for(let M=w;b(M,v);M+=k){let E;if(h)E=String.fromCharCode(M),E==="\\"&&(E="");else if(E=String(M),R){let F=S-E.length;if(F>0){let I=new Array(F+1).join("0");M<0?E="-"+I+E.slice(1):E=I+E;}}m.push(E);}}else {m=[];for(let w=0;w<u.length;w++)m.push.apply(m,es(u[w],t,false));}for(let w=0;w<m.length;w++)for(let v=0;v<a.length&&i.length<t;v++){let S=o+m[w]+a[v];(!e||d||S)&&i.push(S);}}return i}var Ys=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>65536)throw new TypeError("pattern is too long")},so={"[: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]},Ze=s=>s.replace(/[[\]\\-]/g,"\\$&"),io=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Vi=s=>s.join(""),ro=(s,t)=>{let e=t;if(s.charAt(e)!=="[")throw new Error("not in a brace expression");let i=[],n=[],o=e+1,a=false,l=false,h=false,d=false,f=e,u="";t:for(;o<s.length;){let v=s.charAt(o);if((v==="!"||v==="^")&&o===e+1){d=true,o++;continue}if(v==="]"&&a&&!h){f=o+1;break}if(a=true,v==="\\"&&!h){h=true,o++;continue}if(v==="["&&!h){for(let[S,[k,b,R]]of Object.entries(so))if(s.startsWith(S,o)){if(u)return ["$.",false,s.length-e,true];o+=S.length,R?n.push(k):i.push(k),l=l||b;continue t}}if(h=false,u){v>u?i.push(Ze(u)+"-"+Ze(v)):v===u&&i.push(Ze(v)),u="",o++;continue}if(s.startsWith("-]",o+1)){i.push(Ze(v+"-")),o+=2;continue}if(s.startsWith("-",o+1)){u=v,o+=2;continue}i.push(Ze(v)),o++;}if(f<o)return ["",false,0,false];if(!i.length&&!n.length)return ["$.",false,s.length-e,true];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!d){let v=i[0].length===2?i[0].slice(-1):i[0];return [io(v),false,f-e,false]}let m="["+(d?"^":"")+Vi(i)+"]",w="["+(d?"":"^")+Vi(n)+"]";return [i.length&&n.length?"("+m+"|"+w+")":i.length?m:w,l,f-e,true]},Fe=(s,{windowsPathsNoEscape:t=false,magicalBraces:e=true}={})=>e?t?s.replace(/\[([^\/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?s.replace(/\[([^\/\\{}])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),no=new Set(["!","?","+","*","@"]),qi=s=>no.has(s),oo="(?!(?:^|/)\\.\\.?(?:$|/))",Is="(?!\\.)",ao=new Set(["[","."]),lo=new Set(["..","."]),ho=new Set("().*{}+?[]^$\\!"),co=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ji="[^/]",Ji=ji+"*?",Hi=ji+"+?",G,Y,Vt,W,U,oe,we,ae,Wt,be,ls,Me,Br,pe,tt,Bs,ki,Gr,Ur=(tt=class{constructor(t,e,i={}){y(this,Me);c(this,"type");y(this,G);y(this,Y);y(this,Vt,false);y(this,W,[]);y(this,U);y(this,oe);y(this,we);y(this,ae,false);y(this,Wt);y(this,be);y(this,ls,false);this.type=t,t&&p(this,Y,true),p(this,U,e),p(this,G,r(this,U)?r(r(this,U),G):this),p(this,Wt,r(this,G)===this?i:r(r(this,G),Wt)),p(this,we,r(this,G)===this?[]:r(r(this,G),we)),t==="!"&&!r(r(this,G),ae)&&r(this,we).push(this),p(this,oe,r(this,U)?r(r(this,U),W).length:0);}get hasMagic(){if(r(this,Y)!==void 0)return r(this,Y);for(let t of r(this,W))if(typeof t!="string"&&(t.type||t.hasMagic))return p(this,Y,true);return r(this,Y)}toString(){return r(this,be)!==void 0?r(this,be):this.type?p(this,be,this.type+"("+r(this,W).map(t=>String(t)).join("|")+")"):p(this,be,r(this,W).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof tt&&r(e,U)===this))throw new Error("invalid part: "+e);r(this,W).push(e);}}toJSON(){let t=this.type===null?r(this,W).slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...r(this,W).map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,G)||r(r(this,G),ae)&&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,oe)===0)return true;let t=r(this,U);for(let e=0;e<r(this,oe);e++){let i=r(t,W)[e];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),W).length:0;return r(this,oe)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this));}clone(t){let e=new tt(this.type,t);for(let i of r(this,W))e.copyIn(i);return e}static fromGlob(t,e={}){var n;let i=new tt(null,void 0,e);return g(n=tt,pe,Bs).call(n,t,i,0,e),i}toMMPattern(){if(this!==r(this,G))return r(this,G).toMMPattern();let t=this.toString(),[e,i,n,o]=this.toRegExpSource();if(!(n||r(this,Y)||r(this,Wt).nocase&&!r(this,Wt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,Wt).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return r(this,Wt)}toRegExpSource(t){let e=t??!!r(this,Wt).dot;if(r(this,G)===this&&g(this,Me,Br).call(this),!this.type){let h=this.isStart()&&this.isEnd()&&!r(this,W).some(m=>typeof m!="string"),d=r(this,W).map(m=>{var b;let[w,v,S,k]=typeof m=="string"?g(b=tt,pe,Gr).call(b,m,r(this,Y),h):m.toRegExpSource(t);return p(this,Y,r(this,Y)||S),p(this,Vt,r(this,Vt)||k),w}).join(""),f="";if(this.isStart()&&typeof r(this,W)[0]=="string"&&!(r(this,W).length===1&&lo.has(r(this,W)[0]))){let m=ao,w=e&&m.has(d.charAt(0))||d.startsWith("\\.")&&m.has(d.charAt(2))||d.startsWith("\\.\\.")&&m.has(d.charAt(4)),v=!e&&!t&&m.has(d.charAt(0));f=w?oo:v?Is:"";}let u="";return this.isEnd()&&r(r(this,G),ae)&&r(this,U)?.type==="!"&&(u="(?:$|\\/)"),[f+d+u,Fe(d),p(this,Y,!!r(this,Y)),r(this,Vt)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,Me,ki).call(this,e);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let h=this.toString();return p(this,W,[h]),this.type=null,p(this,Y,void 0),[h,Fe(this.toString()),false,false]}let a=!i||t||e||!Is?"":g(this,Me,ki).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let l="";if(this.type==="!"&&r(this,ls))l=(this.isStart()&&!e?Is:"")+Hi;else {let h=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Is:"")+Ji+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=n+o+h;}return [l,Fe(o),p(this,Y,!!r(this,Y)),r(this,Vt)]}},G=new WeakMap,Y=new WeakMap,Vt=new WeakMap,W=new WeakMap,U=new WeakMap,oe=new WeakMap,we=new WeakMap,ae=new WeakMap,Wt=new WeakMap,be=new WeakMap,ls=new WeakMap,Me=new WeakSet,Br=function(){if(this!==r(this,G))throw new Error("should only call on root");if(r(this,ae))return this;this.toString(),p(this,ae,true);let t;for(;t=r(this,we).pop();){if(t.type!=="!")continue;let e=t,i=r(e,U);for(;i;){for(let n=r(e,oe)+1;!i.type&&n<r(i,W).length;n++)for(let o of r(t,W)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r(i,W)[n]);}e=i,i=r(e,U);}}return this},pe=new WeakSet,Bs=function(t,e,i,n){var w,v;let o=false,a=false,l=-1,h=false;if(e.type===null){let S=i,k="";for(;S<t.length;){let b=t.charAt(S++);if(o||b==="\\"){o=!o,k+=b;continue}if(a){S===l+1?(b==="^"||b==="!")&&(h=true):b==="]"&&!(S===l+2&&h)&&(a=false),k+=b;continue}else if(b==="["){a=true,l=S,h=false,k+=b;continue}if(!n.noext&&qi(b)&&t.charAt(S)==="("){e.push(k),k="";let R=new tt(b,e);S=g(w=tt,pe,Bs).call(w,t,R,S,n),e.push(R);continue}k+=b;}return e.push(k),S}let d=i+1,f=new tt(null,e),u=[],m="";for(;d<t.length;){let S=t.charAt(d++);if(o||S==="\\"){o=!o,m+=S;continue}if(a){d===l+1?(S==="^"||S==="!")&&(h=true):S==="]"&&!(d===l+2&&h)&&(a=false),m+=S;continue}else if(S==="["){a=true,l=d,h=false,m+=S;continue}if(qi(S)&&t.charAt(d)==="("){f.push(m),m="";let k=new tt(S,f);f.push(k),d=g(v=tt,pe,Bs).call(v,t,k,d,n);continue}if(S==="|"){f.push(m),m="",u.push(f),f=new tt(null,e);continue}if(S===")")return m===""&&r(e,W).length===0&&p(e,ls,true),f.push(m),m="",e.push(...u,f),d;m+=S;}return e.type=null,p(e,Y,void 0),p(e,W,[t.substring(i-1)]),d},ki=function(t){return r(this,W).map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[i,n,o,a]=e.toRegExpSource(t);return p(this,Vt,r(this,Vt)||a),i}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},Gr=function(t,e,i=false){let n=false,o="",a=false,l=false;for(let h=0;h<t.length;h++){let d=t.charAt(h);if(n){n=false,o+=(ho.has(d)?"\\":"")+d;continue}if(d==="*"){if(l)continue;l=true,o+=i&&/^[*]+$/.test(t)?Hi:Ji,e=true;continue}else l=false;if(d==="\\"){h===t.length-1?o+="\\\\":n=true;continue}if(d==="["){let[f,u,m,w]=ro(t,h);if(m){o+=f,a=a||u,h+=m-1,e=e||w;continue}}if(d==="?"){o+=ji,e=true;continue}o+=co(d);}return [o,Fe(t),!!e,a]},y(tt,pe),tt),Vr=(s,{windowsPathsNoEscape:t=false,magicalBraces:e=false}={})=>e?t?s.replace(/[?*()[\]{}]/g,"[$&]"):s.replace(/[?*()[\]\\{}]/g,"\\$&"):t?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&"),lt=(s,t,e={})=>(Ys(t),!e.nocomment&&t.charAt(0)==="#"?false:new fe(t,e).match(s)),uo=/^\*+([^+@!?\*\[\(]*)$/,po=s=>t=>!t.startsWith(".")&&t.endsWith(s),fo=s=>t=>t.endsWith(s),go=s=>(s=s.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(s)),mo=s=>(s=s.toLowerCase(),t=>t.toLowerCase().endsWith(s)),yo=/^\*+\.\*+$/,wo=s=>!s.startsWith(".")&&s.includes("."),bo=s=>s!=="."&&s!==".."&&s.includes("."),vo=/^\.\*+$/,So=s=>s!=="."&&s!==".."&&s.startsWith("."),xo=/^\*+$/,ko=s=>s.length!==0&&!s.startsWith("."),Eo=s=>s.length!==0&&s!=="."&&s!=="..",Oo=/^\?+([^+@!?\*\[\(]*)?$/,Co=([s,t=""])=>{let e=qr([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Ro=([s,t=""])=>{let e=Jr([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Mo=([s,t=""])=>{let e=Jr([s]);return t?i=>e(i)&&i.endsWith(t):e},Lo=([s,t=""])=>{let e=qr([s]);return t?i=>e(i)&&i.endsWith(t):e},qr=([s])=>{let t=s.length;return e=>e.length===t&&!e.startsWith(".")},Jr=([s])=>{let t=s.length;return e=>e.length===t&&e!=="."&&e!==".."},Hr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Zi={win32:{sep:"\\"},posix:{sep:"/"}},Ao=Hr==="win32"?Zi.win32.sep:Zi.posix.sep;lt.sep=Ao;var at=Symbol("globstar **");lt.GLOBSTAR=at;var To="[^/]",_o=To+"*?",Po="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Fo="(?:(?!(?:\\/|^)\\.).)*?",Io=(s,t={})=>e=>lt(e,s,t);lt.filter=Io;var wt=(s,t={})=>Object.assign({},s,t),Do=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return lt;let t=lt;return Object.assign((e,i,n={})=>t(e,i,wt(s,n)),{Minimatch:class extends t.Minimatch{constructor(e,i={}){super(e,wt(s,i));}static defaults(e){return t.defaults(wt(s,e)).Minimatch}},AST:class extends t.AST{constructor(e,i,n={}){super(e,i,wt(s,n));}static fromGlob(e,i={}){return t.AST.fromGlob(e,wt(s,i))}},unescape:(e,i={})=>t.unescape(e,wt(s,i)),escape:(e,i={})=>t.escape(e,wt(s,i)),filter:(e,i={})=>t.filter(e,wt(s,i)),defaults:e=>t.defaults(wt(s,e)),makeRe:(e,i={})=>t.makeRe(e,wt(s,i)),braceExpand:(e,i={})=>t.braceExpand(e,wt(s,i)),match:(e,i,n={})=>t.match(e,i,wt(s,n)),sep:t.sep,GLOBSTAR:at})};lt.defaults=Do;var Zr=(s,t={})=>(Ys(s),t.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:Yn(s,{max:t.braceExpandMax}));lt.braceExpand=Zr;var No=(s,t={})=>new fe(s,t).makeRe();lt.makeRe=No;var jo=(s,t,e={})=>{let i=new fe(t,e);return s=s.filter(n=>i.match(n)),i.options.nonull&&!s.length&&s.push(t),s};lt.match=jo;var Ki=/[?*]|[+@!]\(.*?\)|\[|\]/,Wo=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fe=class{constructor(s,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(s),t=t||{},this.options=t,this.pattern=s,this.platform=t.platform||Hr,this.isWindows=this.platform==="win32";let e="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[e]===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 s of this.set)for(let t of s)if(typeof t!="string")return true;return false}debug(...s){}make(){let s=this.pattern,t=this.options;if(!t.nocomment&&s.charAt(0)==="#"){this.comment=true;return}if(!s){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 e=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(e),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]==="?"||!Ki.test(n[2]))&&!Ki.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(s){if(this.options.noglobstar)for(let e=0;e<s.length;e++)for(let i=0;i<s[e].length;i++)s[e][i]==="**"&&(s[e][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(s=this.firstPhasePreProcess(s),s=this.secondPhasePreProcess(s)):t>=1?s=this.levelOneOptimize(s):s=this.adjascentGlobstarOptimize(s),s}adjascentGlobstarOptimize(s){return s.map(t=>{let e=-1;for(;(e=t.indexOf("**",e+1))!==-1;){let i=e;for(;t[i+1]==="**";)i++;i!==e&&t.splice(e,i-e);}return t})}levelOneOptimize(s){return s.map(t=>(t=t.reduce((e,i)=>{let n=e[e.length-1];return i==="**"&&n==="**"?e:i===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(e.pop(),e):(e.push(i),e)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(s){Array.isArray(s)||(s=this.slashSplit(s));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let i=1;i<s.length-1;i++){let n=s[i];i===1&&n===""&&s[0]===""||(n==="."||n==="")&&(t=true,s.splice(i,1),i--);}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=true,s.pop());}let e=0;for(;(e=s.indexOf("..",e+1))!==-1;){let i=s[e-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=true,s.splice(e-1,2),e-=2);}}while(t);return s.length===0?[""]:s}firstPhasePreProcess(s){let t=false;do{t=false;for(let e of s){let i=-1;for(;(i=e.indexOf("**",i+1))!==-1;){let o=i;for(;e[o+1]==="**";)o++;o>i&&e.splice(i+1,o-i);let a=e[i+1],l=e[i+2],h=e[i+3];if(a!==".."||!l||l==="."||l===".."||!h||h==="."||h==="..")continue;t=true,e.splice(i,1);let d=e.slice(0);d[i]="**",s.push(d),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<e.length-1;o++){let a=e[o];o===1&&a===""&&e[0]===""||(a==="."||a==="")&&(t=true,e.splice(o,1),o--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=true,e.pop());}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let o=e[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=true;let a=n===1&&e[n+1]==="**"?["."]:[];e.splice(n-1,2,...a),e.length===0&&e.push(""),n-=2;}}}}while(t);return s}secondPhasePreProcess(s){for(let t=0;t<s.length-1;t++)for(let e=t+1;e<s.length;e++){let i=this.partsMatch(s[t],s[e],!this.preserveMultipleSlashes);if(i){s[t]=[],s[e]=i;break}}return s.filter(t=>t.length)}partsMatch(s,t,e=false){let i=0,n=0,o=[],a="";for(;i<s.length&&n<t.length;)if(s[i]===t[n])o.push(a==="b"?t[n]:s[i]),i++,n++;else if(e&&s[i]==="**"&&t[n]===s[i+1])o.push(s[i]),i++;else if(e&&t[n]==="**"&&s[i]===t[n+1])o.push(t[n]),n++;else if(s[i]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="b")return false;a="a",o.push(s[i]),i++,n++;}else if(t[n]==="*"&&s[i]&&(this.options.dot||!s[i].startsWith("."))&&s[i]!=="**"){if(a==="a")return false;a="b",o.push(t[n]),i++,n++;}else return false;return s.length===t.length&&o}parseNegate(){if(this.nonegate)return;let s=this.pattern,t=false,e=0;for(let i=0;i<s.length&&s.charAt(i)==="!";i++)t=!t,e++;e&&(this.pattern=s.slice(e)),this.negate=t;}matchOne(s,t,e=false){let i=this.options;if(this.isWindows){let v=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),S=!v&&s[0]===""&&s[1]===""&&s[2]==="?"&&/^[a-z]:$/i.test(s[3]),k=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!k&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),R=S?3:v?0:void 0,M=b?3:k?0:void 0;if(typeof R=="number"&&typeof M=="number"){let[E,F]=[s[R],t[M]];E.toLowerCase()===F.toLowerCase()&&(t[M]=E,M>R?t=t.slice(M):R>M&&(s=s.slice(R)));}}let{optimizationLevel:n=1}=this.options;n>=2&&(s=this.levelTwoFileOptimize(s)),this.debug("matchOne",this,{file:s,pattern:t}),this.debug("matchOne",s.length,t.length);for(var o=0,a=0,l=s.length,h=t.length;o<l&&a<h;o++,a++){this.debug("matchOne loop");var d=t[a],f=s[o];if(this.debug(t,d,f),d===false)return false;if(d===at){this.debug("GLOBSTAR",[t,d,f]);var u=o,m=a+1;if(m===h){for(this.debug("** at the end");o<l;o++)if(s[o]==="."||s[o]===".."||!i.dot&&s[o].charAt(0)===".")return false;return true}for(;u<l;){var w=s[u];if(this.debug(`
3
- globstar while`,s,u,t,m,w),this.matchOne(s.slice(u),t.slice(m),e))return this.debug("globstar found match!",u,l,w),true;if(w==="."||w===".."||!i.dot&&w.charAt(0)==="."){this.debug("dot detected!",s,u,t,m);break}this.debug("globstar swallow a segment, and continue"),u++;}return !!(e&&(this.debug(`
4
- >>> no match, partial?`,s,u,t,m),u===l))}let v;if(typeof d=="string"?(v=f===d,this.debug("string match",d,f,v)):(v=d.test(f),this.debug("pattern match",d,f,v)),!v)return false}if(o===l&&a===h)return true;if(o===l)return e;if(a===h)return o===l-1&&s[o]==="";throw new Error("wtf?")}braceExpand(){return Zr(this.pattern,this.options)}parse(s){Ys(s);let t=this.options;if(s==="**")return at;if(s==="")return "";let e,i=null;(e=s.match(xo))?i=t.dot?Eo:ko:(e=s.match(uo))?i=(t.nocase?t.dot?mo:go:t.dot?fo:po)(e[1]):(e=s.match(Oo))?i=(t.nocase?t.dot?Ro:Co:t.dot?Mo:Lo)(e):(e=s.match(yo))?i=t.dot?bo:wo:(e=s.match(vo))&&(i=So);let n=Ur.fromGlob(s,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 s=this.set;if(!s.length)return this.regexp=false,this.regexp;let t=this.options,e=t.noglobstar?_o:t.dot?Po:Fo,i=new Set(t.nocase?["i"]:[]),n=s.map(l=>{let h=l.map(f=>{if(f instanceof RegExp)for(let u of f.flags.split(""))i.add(u);return typeof f=="string"?Wo(f):f===at?at:f._src});h.forEach((f,u)=>{let m=h[u+1],w=h[u-1];f!==at||w===at||(w===void 0?m!==void 0&&m!==at?h[u+1]="(?:\\/|"+e+"\\/)?"+m:h[u]=e:m===void 0?h[u-1]=w+"(?:\\/|\\/"+e+")?":m!==at&&(h[u-1]=w+"(?:\\/|\\/"+e+"\\/)"+m,h[u+1]=at));});let d=h.filter(f=>f!==at);if(this.partial&&d.length>=1){let f=[];for(let u=1;u<=d.length;u++)f.push(d.slice(0,u).join("/"));return "(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=s.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(s){return this.preserveMultipleSlashes?s.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(s)?["",...s.split(/\/+/)]:s.split(/\/+/)}match(s,t=this.partial){if(this.debug("match",s,this.pattern),this.comment)return false;if(this.empty)return s==="";if(s==="/"&&t)return true;let e=this.options;this.isWindows&&(s=s.split("\\").join("/"));let i=this.slashSplit(s);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(e.matchBase&&l.length===1&&(h=[o]),this.matchOne(h,l,t))return e.flipNegate?true:!this.negate}return e.flipNegate?false:this.negate}static defaults(s){return lt.defaults(s).Minimatch}};lt.AST=Ur;lt.Minimatch=fe;lt.escape=Vr;lt.unescape=Fe;var zo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Kr=new Set,Ei=typeof process=="object"&&process?process:{},Yr=(s,t,e,i)=>{typeof Ei.emitWarning=="function"?Ei.emitWarning(s,t,e,i):console.error(`[${e}] ${t}: ${s}`);},Qs=globalThis.AbortController,Yi=globalThis.AbortSignal;if(typeof Qs>"u"){Yi=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(e,i){this._onabort.push(i);}},Qs=class{constructor(){c(this,"signal",new Yi);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let i of this.signal._onabort)i(e);this.signal.onabort?.(e);}}};let s=Ei.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{s&&(s=false,Yr("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 Uo=s=>!Kr.has(s),se=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Qr=s=>se(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Gs:null:null,Gs=class extends Array{constructor(s){super(s),this.fill(0);}},Ut,Ie,Bo=(Ut=class{constructor(t,e){c(this,"heap");c(this,"length");if(!r(Ut,Ie))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Qr(t);if(!e)return [];p(Ut,Ie,true);let i=new Ut(t,e);return p(Ut,Ie,false),i}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},Ie=new WeakMap,y(Ut,Ie,false),Ut),dr,pr,vt,dt,Rt,ve,Mt,De,Ne,Lt,V,At,B,$,T,rt,pt,st,Q,Tt,X,_t,Pt,ft,gt,Ft,le,nt,je,x,Oi,Se,qt,hs,mt,Xr,xe,We,cs,ie,re,Ci,Vs,qs,j,Ri,ss,ne,Mi,$e,ei=($e=class{constructor(t){y(this,x);y(this,vt);y(this,dt);y(this,Rt);y(this,ve);y(this,Mt);y(this,De);y(this,Ne);y(this,Lt);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");y(this,V);y(this,At);y(this,B);y(this,$);y(this,T);y(this,rt);y(this,pt);y(this,st);y(this,Q);y(this,Tt);y(this,X);y(this,_t);y(this,Pt);y(this,ft);y(this,gt);y(this,Ft);y(this,le);y(this,nt);y(this,je);y(this,Se,()=>{});y(this,qt,()=>{});y(this,hs,()=>{});y(this,mt,()=>false);y(this,xe,t=>{});y(this,We,(t,e,i)=>{});y(this,cs,(t,e,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,dr,"LRUCache");let{max:e=0,ttl:i,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:d,onInsert:f,disposeAfter:u,noDisposeOnSet:m,noUpdateTTL:w,maxSize:v=0,maxEntrySize:S=0,sizeCalculation:k,fetchMethod:b,memoMethod:R,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:I,ignoreFetchAbort:O,perf:P}=t;if(P!==void 0&&typeof P?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,Lt,P??zo),e!==0&&!se(e))throw new TypeError("max option must be a nonnegative integer");let A=e?Qr(e):Array;if(!A)throw new Error("invalid max value: "+e);if(p(this,vt,e),p(this,dt,v),this.maxEntrySize=S||r(this,dt),this.sizeCalculation=k,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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(p(this,Ne,R),b!==void 0&&typeof b!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,De,b),p(this,le,!!b),p(this,B,new Map),p(this,$,new Array(e).fill(void 0)),p(this,T,new Array(e).fill(void 0)),p(this,rt,new A(e)),p(this,pt,new A(e)),p(this,st,0),p(this,Q,0),p(this,Tt,Bo.create(e)),p(this,V,0),p(this,At,0),typeof d=="function"&&p(this,Rt,d),typeof f=="function"&&p(this,ve,f),typeof u=="function"?(p(this,Mt,u),p(this,X,[])):(p(this,Mt,void 0),p(this,X,void 0)),p(this,Ft,!!r(this,Rt)),p(this,je,!!r(this,ve)),p(this,nt,!!r(this,Mt)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!I,this.ignoreFetchAbort=!!O,this.maxEntrySize!==0){if(r(this,dt)!==0&&!se(r(this,dt)))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,x,Xr).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=se(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,x,Oi).call(this);}if(r(this,vt)===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,vt)&&!r(this,dt)){let D="LRU_CACHE_UNBOUNDED";Uo(D)&&(Kr.add(D),Yr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",D,$e));}}get perf(){return r(this,Lt)}static unsafeExposeInternals(t){return {starts:r(t,Pt),ttls:r(t,ft),autopurgeTimers:r(t,gt),sizes:r(t,_t),keyMap:r(t,B),keyList:r(t,$),valList:r(t,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:e=>{var i;return g(i=t,x,j).call(i,e)},backgroundFetch:(e,i,n,o)=>{var a;return g(a=t,x,qs).call(a,e,i,n,o)},moveToTail:e=>{var i;return g(i=t,x,ss).call(i,e)},indexes:e=>{var i;return g(i=t,x,ie).call(i,e)},rindexes:e=>{var i;return g(i=t,x,re).call(i,e)},isStale:e=>{var i;return r(i=t,mt).call(i,e)}}}get max(){return r(this,vt)}get maxSize(){return r(this,dt)}get calculatedSize(){return r(this,At)}get size(){return r(this,V)}get fetchMethod(){return r(this,De)}get memoMethod(){return r(this,Ne)}get dispose(){return r(this,Rt)}get onInsert(){return r(this,ve)}get disposeAfter(){return r(this,Mt)}getRemainingTTL(t){return r(this,B).has(t)?1/0:0}*entries(){for(let t of g(this,x,ie).call(this))r(this,T)[t]!==void 0&&r(this,$)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield [r(this,$)[t],r(this,T)[t]]);}*rentries(){for(let t of g(this,x,re).call(this))r(this,T)[t]!==void 0&&r(this,$)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield [r(this,$)[t],r(this,T)[t]]);}*keys(){for(let t of g(this,x,ie).call(this)){let e=r(this,$)[t];e!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield e);}}*rkeys(){for(let t of g(this,x,re).call(this)){let e=r(this,$)[t];e!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield e);}}*values(){for(let t of g(this,x,ie).call(this))r(this,T)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield r(this,T)[t]);}*rvalues(){for(let t of g(this,x,re).call(this))r(this,T)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield r(this,T)[t]);}[(pr=Symbol.iterator,dr=Symbol.toStringTag,pr)](){return this.entries()}find(t,e={}){for(let i of g(this,x,ie).call(this)){let n=r(this,T)[i],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,r(this,$)[i],this))return this.get(r(this,$)[i],e)}}forEach(t,e=this){for(let i of g(this,x,ie).call(this)){let n=r(this,T)[i],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(e,o,r(this,$)[i],this);}}rforEach(t,e=this){for(let i of g(this,x,re).call(this)){let n=r(this,T)[i],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(e,o,r(this,$)[i],this);}}purgeStale(){let t=false;for(let e of g(this,x,re).call(this,{allowStale:true}))r(this,mt).call(this,e)&&(g(this,x,ne).call(this,r(this,$)[e],"expire"),t=true);return t}info(t){let e=r(this,B).get(t);if(e===void 0)return;let i=r(this,T)[e],n=g(this,x,j).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let o={value:n};if(r(this,ft)&&r(this,Pt)){let a=r(this,ft)[e],l=r(this,Pt)[e];if(a&&l){let h=a-(r(this,Lt).now()-l);o.ttl=h,o.start=Date.now();}}return r(this,_t)&&(o.size=r(this,_t)[e]),o}dump(){let t=[];for(let e of g(this,x,ie).call(this,{allowStale:true})){let i=r(this,$)[e],n=r(this,T)[e],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||i===void 0)continue;let a={value:o};if(r(this,ft)&&r(this,Pt)){a.ttl=r(this,ft)[e];let l=r(this,Lt).now()-r(this,Pt)[e];a.start=Math.floor(Date.now()-l);}r(this,_t)&&(a.size=r(this,_t)[e]),t.unshift([i,a]);}return t}load(t){this.clear();for(let[e,i]of t){if(i.start){let n=Date.now()-i.start;i.start=r(this,Lt).now()-n;}this.set(e,i.value,i);}}set(t,e,i={}){var m,w,v,S;if(e===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,cs).call(this,t,e,i.size||0,l);if(this.maxEntrySize&&f>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),g(this,x,ne).call(this,t,"set"),this;let u=r(this,V)===0?void 0:r(this,B).get(t);if(u===void 0)u=r(this,V)===0?r(this,Q):r(this,Tt).length!==0?r(this,Tt).pop():r(this,V)===r(this,vt)?g(this,x,Vs).call(this,false):r(this,V),r(this,$)[u]=t,r(this,T)[u]=e,r(this,B).set(t,u),r(this,rt)[r(this,Q)]=u,r(this,pt)[u]=r(this,Q),p(this,Q,u),Ps(this,V)._++,r(this,We).call(this,u,f,h),h&&(h.set="add"),d=false,r(this,je)&&((m=r(this,ve))==null||m.call(this,e,t,"add"));else {g(this,x,ss).call(this,u);let k=r(this,T)[u];if(e!==k){if(r(this,le)&&g(this,x,j).call(this,k)){k.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:b}=k;b!==void 0&&!a&&(r(this,Ft)&&((w=r(this,Rt))==null||w.call(this,b,t,"set")),r(this,nt)&&r(this,X)?.push([b,t,"set"]));}else a||(r(this,Ft)&&((v=r(this,Rt))==null||v.call(this,k,t,"set")),r(this,nt)&&r(this,X)?.push([k,t,"set"]));if(r(this,xe).call(this,u),r(this,We).call(this,u,f,h),r(this,T)[u]=e,h){h.set="replace";let b=k&&g(this,x,j).call(this,k)?k.__staleWhileFetching:k;b!==void 0&&(h.oldValue=b);}}else h&&(h.set="update");r(this,je)&&this.onInsert?.(e,t,e===k?"update":"replace");}if(n!==0&&!r(this,ft)&&g(this,x,Oi).call(this),r(this,ft)&&(d||r(this,hs).call(this,u,n,o),h&&r(this,qt).call(this,h,u)),!a&&r(this,nt)&&r(this,X)){let k=r(this,X),b;for(;b=k?.shift();)(S=r(this,Mt))==null||S.call(this,...b);}return this}pop(){var t;try{for(;r(this,V);){let e=r(this,T)[r(this,st)];if(g(this,x,Vs).call(this,!0),g(this,x,j).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(r(this,nt)&&r(this,X)){let e=r(this,X),i;for(;i=e?.shift();)(t=r(this,Mt))==null||t.call(this,...i);}}}has(t,e={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=e,o=r(this,B).get(t);if(o!==void 0){let a=r(this,T)[o];if(g(this,x,j).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,mt).call(this,o))n&&(n.has="stale",r(this,qt).call(this,n,o));else return i&&r(this,Se).call(this,o),n&&(n.has="hit",r(this,qt).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,e={}){let{allowStale:i=this.allowStale}=e,n=r(this,B).get(t);if(n===void 0||!i&&r(this,mt).call(this,n))return;let o=r(this,T)[n];return g(this,x,j).call(this,o)?o.__staleWhileFetching:o}async fetch(t,e={}){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:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:S,forceRefresh:k=false,status:b,signal:R}=e;if(!r(this,le))return b&&(b.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:b});let M={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:d,noUpdateTTL:f,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:v,ignoreFetchAbort:w,status:b,signal:R},E=r(this,B).get(t);if(E===void 0){b&&(b.fetch="miss");let F=g(this,x,qs).call(this,t,E,M,S);return F.__returned=F}else {let F=r(this,T)[E];if(g(this,x,j).call(this,F)){let A=i&&F.__staleWhileFetching!==void 0;return b&&(b.fetch="inflight",A&&(b.returnedStale=true)),A?F.__staleWhileFetching:F.__returned=F}let I=r(this,mt).call(this,E);if(!k&&!I)return b&&(b.fetch="hit"),g(this,x,ss).call(this,E),n&&r(this,Se).call(this,E),b&&r(this,qt).call(this,b,E),F;let O=g(this,x,qs).call(this,t,E,M,S),P=O.__staleWhileFetching!==void 0&&i;return b&&(b.fetch=I?"stale":"refresh",P&&I&&(b.returnedStale=true)),P?O.__staleWhileFetching:O.__returned=O}}async forceFetch(t,e={}){let i=await this.fetch(t,e);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,e={}){let i=r(this,Ne);if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=e,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,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=e,l=r(this,B).get(t);if(l!==void 0){let h=r(this,T)[l],d=g(this,x,j).call(this,h);return a&&r(this,qt).call(this,a,l),r(this,mt).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,ne).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?h:void 0)):(a&&(a.get="hit"),d?h.__staleWhileFetching:(g(this,x,ss).call(this,l),n&&r(this,Se).call(this,l),h))}else a&&(a.get="miss");}delete(t){return g(this,x,ne).call(this,t,"delete")}clear(){return g(this,x,Mi).call(this,"delete")}},vt=new WeakMap,dt=new WeakMap,Rt=new WeakMap,ve=new WeakMap,Mt=new WeakMap,De=new WeakMap,Ne=new WeakMap,Lt=new WeakMap,V=new WeakMap,At=new WeakMap,B=new WeakMap,$=new WeakMap,T=new WeakMap,rt=new WeakMap,pt=new WeakMap,st=new WeakMap,Q=new WeakMap,Tt=new WeakMap,X=new WeakMap,_t=new WeakMap,Pt=new WeakMap,ft=new WeakMap,gt=new WeakMap,Ft=new WeakMap,le=new WeakMap,nt=new WeakMap,je=new WeakMap,x=new WeakSet,Oi=function(){let t=new Gs(r(this,vt)),e=new Gs(r(this,vt));p(this,ft,t),p(this,Pt,e);let i=this.ttlAutopurge?new Array(r(this,vt)):void 0;p(this,gt,i),p(this,hs,(a,l,h=r(this,Lt).now())=>{if(e[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,mt).call(this,a)&&g(this,x,ne).call(this,r(this,$)[a],"expire");},l+1);d.unref&&d.unref(),i[a]=d;}}),p(this,Se,a=>{e[a]=t[a]!==0?r(this,Lt).now():0;}),p(this,qt,(a,l)=>{if(t[l]){let h=t[l],d=e[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,Lt).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=e[l];if(!h||!d)return 1/0;let f=(n||o())-d;return h-f},p(this,mt,a=>{let l=e[a],h=t[a];return !!h&&!!l&&(n||o())-l>h});},Se=new WeakMap,qt=new WeakMap,hs=new WeakMap,mt=new WeakMap,Xr=function(){let t=new Gs(r(this,vt));p(this,At,0),p(this,_t,t),p(this,xe,e=>{p(this,At,r(this,At)-t[e]),t[e]=0;}),p(this,cs,(e,i,n,o)=>{if(g(this,x,j).call(this,i))return 0;if(!se(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(i,e),!se(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}),p(this,We,(e,i,n)=>{if(t[e]=i,r(this,dt)){let o=r(this,dt)-t[e];for(;r(this,At)>o;)g(this,x,Vs).call(this,true);}p(this,At,r(this,At)+t[e]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,At));});},xe=new WeakMap,We=new WeakMap,cs=new WeakMap,ie=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let e=r(this,Q);!(!g(this,x,Ci).call(this,e)||((t||!r(this,mt).call(this,e))&&(yield e),e===r(this,st)));)e=r(this,pt)[e];},re=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let e=r(this,st);!(!g(this,x,Ci).call(this,e)||((t||!r(this,mt).call(this,e))&&(yield e),e===r(this,Q)));)e=r(this,rt)[e];},Ci=function(t){return t!==void 0&&r(this,B).get(r(this,$)[t])===t},Vs=function(t){var o;let e=r(this,st),i=r(this,$)[e],n=r(this,T)[e];return r(this,le)&&g(this,x,j).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,Ft)||r(this,nt))&&(r(this,Ft)&&((o=r(this,Rt))==null||o.call(this,n,i,"evict")),r(this,nt)&&r(this,X)?.push([n,i,"evict"])),r(this,xe).call(this,e),r(this,gt)?.[e]&&(clearTimeout(r(this,gt)[e]),r(this,gt)[e]=void 0),t&&(r(this,$)[e]=void 0,r(this,T)[e]=void 0,r(this,Tt).push(e)),r(this,V)===1?(p(this,st,p(this,Q,0)),r(this,Tt).length=0):p(this,st,r(this,rt)[e]),r(this,B).delete(i),Ps(this,V)._--,e},qs=function(t,e,i,n){let o=e===void 0?void 0:r(this,T)[e];if(g(this,x,j).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=(S,k=false)=>{let{aborted:b}=a.signal,R=i.ignoreFetchAbort&&S!==void 0,M=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&S!==void 0);if(i.status&&(b&&!k?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,R&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),b&&!R&&!k)return u(a.signal.reason,M);let E=w,F=r(this,T)[e];return (F===w||R&&k&&F===void 0)&&(S===void 0?E.__staleWhileFetching!==void 0?r(this,T)[e]=E.__staleWhileFetching:g(this,x,ne).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,S,h.options))),S},f=S=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=S),u(S,false)),u=(S,k)=>{let{aborted:b}=a.signal,R=b&&i.allowStaleOnFetchAbort,M=R||i.allowStaleOnFetchRejection,E=M||i.noDeleteOnFetchRejection,F=w;if(r(this,T)[e]===w&&(!E||!k&&F.__staleWhileFetching===void 0?g(this,x,ne).call(this,t,"fetch"):R||(r(this,T)[e]=F.__staleWhileFetching)),M)return i.status&&F.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),F.__staleWhileFetching;if(F.__returned===F)throw S},m=(S,k)=>{var R;let b=(R=r(this,De))==null?void 0:R.call(this,t,o,h);b&&b instanceof Promise&&b.then(M=>S(M===void 0?void 0:M),k),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(S(void 0),i.allowStaleOnFetchAbort&&(S=M=>d(M,true)));});};i.status&&(i.status.fetchDispatched=true);let w=new Promise(m).then(d,f),v=Object.assign(w,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return e===void 0?(this.set(t,v,{...h.options,status:void 0}),e=r(this,B).get(t)):r(this,T)[e]=v,v},j=function(t){if(!r(this,le))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Qs},Ri=function(t,e){r(this,pt)[e]=t,r(this,rt)[t]=e;},ss=function(t){t!==r(this,Q)&&(t===r(this,st)?p(this,st,r(this,rt)[t]):g(this,x,Ri).call(this,r(this,pt)[t],r(this,rt)[t]),g(this,x,Ri).call(this,r(this,Q),t),p(this,Q,t));},ne=function(t,e){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,Mi).call(this,e);else {r(this,xe).call(this,a);let l=r(this,T)[a];if(g(this,x,j).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,Ft)||r(this,nt))&&(r(this,Ft)&&((n=r(this,Rt))==null||n.call(this,l,t,e)),r(this,nt)&&r(this,X)?.push([l,t,e])),r(this,B).delete(t),r(this,$)[a]=void 0,r(this,T)[a]=void 0,a===r(this,Q))p(this,Q,r(this,pt)[a]);else if(a===r(this,st))p(this,st,r(this,rt)[a]);else {let h=r(this,pt)[a];r(this,rt)[h]=r(this,rt)[a];let d=r(this,rt)[a];r(this,pt)[d]=r(this,pt)[a];}Ps(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,Mt))==null||o.call(this,...l);}return i},Mi=function(t){var e,i;for(let n of g(this,x,re).call(this,{allowStale:true})){let o=r(this,T)[n];if(g(this,x,j).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=r(this,$)[n];r(this,Ft)&&((e=r(this,Rt))==null||e.call(this,o,a,t)),r(this,nt)&&r(this,X)?.push([o,a,t]);}}if(r(this,B).clear(),r(this,T).fill(void 0),r(this,$).fill(void 0),r(this,ft)&&r(this,Pt)){r(this,ft).fill(0),r(this,Pt).fill(0);for(let n of r(this,gt)??[])n!==void 0&&clearTimeout(n);r(this,gt)?.fill(void 0);}if(r(this,_t)&&r(this,_t).fill(0),p(this,st,0),p(this,Q,0),r(this,Tt).length=0,p(this,At,0),p(this,V,0),r(this,nt)&&r(this,X)){let n=r(this,X),o;for(;o=n?.shift();)(i=r(this,Mt))==null||i.call(this,...o);}},$e),Qi=typeof process=="object"&&process?process:{stdout:null,stderr:null},ia=s=>!!s&&typeof s=="object"&&(s instanceof Xs||s instanceof tn__default.default||ra(s)||na(s)),ra=s=>!!s&&typeof s=="object"&&s instanceof events.EventEmitter&&typeof s.pipe=="function"&&s.pipe!==tn__default.default.Writable.prototype.pipe,na=s=>!!s&&typeof s=="object"&&s instanceof events.EventEmitter&&typeof s.write=="function"&&typeof s.end=="function",Bt=Symbol("EOF"),Gt=Symbol("maybeEmitEnd"),ee=Symbol("emittedEnd"),Ds=Symbol("emittingEnd"),Ke=Symbol("emittedError"),Ns=Symbol("closed"),Xi=Symbol("read"),js=Symbol("flush"),tr=Symbol("flushChunk"),Ot=Symbol("encoding"),_e=Symbol("decoder"),H=Symbol("flowing"),Ye=Symbol("paused"),Pe=Symbol("resume"),Z=Symbol("buffer"),it=Symbol("pipes"),K=Symbol("bufferLength"),mi=Symbol("bufferPush"),Ws=Symbol("bufferShift"),et=Symbol("objectMode"),z=Symbol("destroyed"),yi=Symbol("error"),wi=Symbol("emitData"),er=Symbol("emitEnd"),bi=Symbol("emitEnd2"),Nt=Symbol("async"),vi=Symbol("abort"),$s=Symbol("aborted"),Qe=Symbol("signal"),ge=Symbol("dataListeners"),ut=Symbol("discarded"),Xe=s=>Promise.resolve().then(s),oa=s=>s(),aa=s=>s==="end"||s==="finish"||s==="prefinish",la=s=>s instanceof ArrayBuffer||!!s&&typeof s=="object"&&s.constructor&&s.constructor.name==="ArrayBuffer"&&s.byteLength>=0,ha=s=>!Buffer.isBuffer(s)&&ArrayBuffer.isView(s),en=class{constructor(s,t,e){c(this,"src");c(this,"dest");c(this,"opts");c(this,"ondrain");this.src=s,this.dest=t,this.opts=e,this.ondrain=()=>s[Pe](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(s){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},ca=class extends en{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(s,t,e){super(s,t,e),this.proxyErrors=i=>this.dest.emit("error",i),s.on("error",this.proxyErrors);}},ua=s=>!!s.objectMode,da=s=>!s.objectMode&&!!s.encoding&&s.encoding!=="buffer",fr,gr,mr,yr,wr,br,vr,Sr,xr,kr,Er,Or,Cr,Rr,Mr,Lr,Ar,Tr,_r,Xs=class extends events.EventEmitter{constructor(...t){let e=t[0]||{};super();c(this,_r,false);c(this,Tr,false);c(this,Ar,[]);c(this,Lr,[]);c(this,Mr);c(this,Rr);c(this,Cr);c(this,Or);c(this,Er,false);c(this,kr,false);c(this,xr,false);c(this,Sr,false);c(this,vr,null);c(this,br,0);c(this,wr,false);c(this,yr);c(this,mr,false);c(this,gr,0);c(this,fr,false);c(this,"writable",true);c(this,"readable",true);if(e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");ua(e)?(this[et]=true,this[Ot]=null):da(e)?(this[Ot]=e.encoding,this[et]=false):(this[et]=false,this[Ot]=null),this[Nt]=!!e.async,this[_e]=this[Ot]?new string_decoder.StringDecoder(this[Ot]):null,e&&e.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[Z]}),e&&e.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[it]});let{signal:i}=e;i&&(this[Qe]=i,i.aborted?this[vi]():i.addEventListener("abort",()=>this[vi]()));}get bufferLength(){return this[K]}get encoding(){return this[Ot]}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[Nt]}set async(t){this[Nt]=this[Nt]||!!t;}[(_r=H,Tr=Ye,Ar=it,Lr=Z,Mr=et,Rr=Ot,Cr=Nt,Or=_e,Er=Bt,kr=ee,xr=Ds,Sr=Ns,vr=Ke,br=K,wr=z,yr=Qe,mr=$s,gr=ge,fr=ut,vi)](){this[$s]=true,this.emit("abort",this[Qe]?.reason),this.destroy(this[Qe]?.reason);}get aborted(){return this[$s]}set aborted(t){}write(t,e,i){if(this[$s])return false;if(this[Bt])throw new Error("write after end");if(this[z])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof e=="function"&&(i=e,e="utf8"),e||(e="utf8");let n=this[Nt]?Xe:oa;if(!this[et]&&!Buffer.isBuffer(t)){if(ha(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(la(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[mi](t),this[K]!==0&&this.emit("readable"),i&&n(i),this[H]):t.length?(typeof t=="string"&&!(e===this[Ot]&&!this[_e]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[Ot]&&(t=this[_e].write(t)),this[H]&&this[K]!==0&&this[js](true),this[H]?this.emit("data",t):this[mi](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[z])return null;if(this[ut]=false,this[K]===0||t===0||t&&t>this[K])return this[Gt](),null;this[et]&&(t=null),this[Z].length>1&&!this[et]&&(this[Z]=[this[Ot]?this[Z].join(""):Buffer.concat(this[Z],this[K])]);let e=this[Xi](t||null,this[Z][0]);return this[Gt](),e}[Xi](t,e){if(this[et])this[Ws]();else {let i=e;t===i.length||t===null?this[Ws]():typeof i=="string"?(this[Z][0]=i.slice(t),e=i.slice(0,t),this[K]-=t):(this[Z][0]=i.subarray(t),e=i.subarray(0,t),this[K]-=t);}return this.emit("data",e),!this[Z].length&&!this[Bt]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[Bt]=true,this.writable=false,(this[H]||!this[Ye])&&this[Gt](),this}[Pe](){this[z]||(!this[ge]&&!this[it].length&&(this[ut]=true),this[Ye]=false,this[H]=true,this.emit("resume"),this[Z].length?this[js]():this[Bt]?this[Gt]():this.emit("drain"));}resume(){return this[Pe]()}pause(){this[H]=false,this[Ye]=true,this[ut]=false;}get destroyed(){return this[z]}get flowing(){return this[H]}get paused(){return this[Ye]}[mi](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[tr](this[Ws]())&&this[Z].length);!t&&!this[Z].length&&!this[Bt]&&this.emit("drain");}[tr](t){return this.emit("data",t),this[H]}pipe(t,e){if(this[z])return t;this[ut]=false;let i=this[ee];return e=e||{},t===Qi.stdout||t===Qi.stderr?e.end=false:e.end=e.end!==false,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[it].push(e.proxyErrors?new ca(this,t,e):new en(this,t,e)),this[Nt]?Xe(()=>this[Pe]()):this[Pe]()),t}unpipe(t){let e=this[it].find(i=>i.dest===t);e&&(this[it].length===1?(this[H]&&this[ge]===0&&(this[H]=false),this[it]=[]):this[it].splice(this[it].indexOf(e),1),e.unpipe());}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[ut]=false,this[ge]++,!this[it].length&&!this[H]&&this[Pe]();else if(t==="readable"&&this[K]!==0)super.emit("readable");else if(aa(t)&&this[ee])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ke]){let n=e;this[Nt]?Xe(()=>n.call(this,this[Ke])):n.call(this,this[Ke]);}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[ge]=this.listeners("data").length,this[ge]===0&&!this[ut]&&!this[it].length&&(this[H]=false)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[ge]=0,!this[ut]&&!this[it].length&&(this[H]=false)),e}get emittedEnd(){return this[ee]}[Gt](){!this[Ds]&&!this[ee]&&!this[z]&&this[Z].length===0&&this[Bt]&&(this[Ds]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ns]&&this.emit("close"),this[Ds]=false);}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==z&&this[z])return false;if(t==="data")return !this[et]&&!i?false:this[Nt]?(Xe(()=>this[wi](i)),true):this[wi](i);if(t==="end")return this[er]();if(t==="close"){if(this[Ns]=true,!this[ee]&&!this[z])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ke]=i,super.emit(yi,i);let o=!this[Qe]||this.listeners("error").length?super.emit("error",i):false;return this[Gt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Gt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let n=super.emit(t,...e);return this[Gt](),n}[wi](t){for(let i of this[it])i.dest.write(t)===false&&this.pause();let e=this[ut]?false:super.emit("data",t);return this[Gt](),e}[er](){return this[ee]?false:(this[ee]=true,this.readable=false,this[Nt]?(Xe(()=>this[bi]()),true):this[bi]())}[bi](){if(this[_e]){let e=this[_e].end();if(e){for(let i of this[it])i.dest.write(e);this[ut]||super.emit("data",e);}}for(let e of this[it])e.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 e=this.promise();return this.on("data",i=>{t.push(i),this[et]||(t.dataLength+=i.length);}),await e,t}async concat(){if(this[et])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Ot]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(z,()=>e(new Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[ut]=false;let t=false,e=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:false,value:i});if(this[Bt])return e();let n,o,a=f=>{this.off("data",l),this.off("end",h),this.off(z,d),e(),o(f);},l=f=>{this.off("error",a),this.off("end",h),this.off(z,d),this.pause(),n({value:f,done:!!this[Bt]});},h=()=>{this.off("error",a),this.off("data",l),this.off(z,d),e(),n({done:true,value:void 0});},d=()=>a(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,n=f,this.once(z,d),this.once("error",a),this.once("end",h),this.once("data",l);})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ut]=false;let t=false,e=()=>(this.pause(),this.off(yi,e),this.off(z,e),this.off("end",e),t=true,{done:true,value:void 0}),i=()=>{if(t)return e();let n=this.read();return n===null?e():{done:false,value:n}};return this.once("end",e),this.once(yi,e),this.once(z,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[z])return t?this.emit("error",t):this.emit(z),this;this[z]=true,this[ut]=true,this[Z].length=0,this[K]=0;let e=this;return typeof e.close=="function"&&!this[Ns]&&e.close(),t?this.emit("error",t):this.emit(z),this}static get isStream(){return ia}},pa=Yo.realpathSync.native,is={lstatSync:Yo.lstatSync,readdir:Yo.readdir,readdirSync:Yo.readdirSync,readlinkSync:Yo.readlinkSync,realpathSync:pa,promises:{lstat:Mn.lstat,readdir:Mn.readdir,readlink:Mn.readlink,realpath:Mn.realpath}},sn=s=>!s||s===is||s===Yo__namespace?is:{...is,...s,promises:{...is.promises,...s.promises||{}}},rn=/^\\\\\?\\([a-z]:)\\?$/i,fa=s=>s.replace(/\//g,"\\").replace(rn,"$1\\"),ga=/[\\\/]/,St=0,nn=1,on=2,jt=4,an=6,ln=8,me=10,hn=12,bt=15,ts=~bt,Si=16,sr=32,rs=64,Ct=128,zs=256,Js=512,ir=rs|Ct|Js,ma=1023,xi=s=>s.isFile()?ln:s.isDirectory()?jt:s.isSymbolicLink()?me:s.isCharacterDevice()?on:s.isBlockDevice()?an:s.isSocket()?hn:s.isFIFO()?nn:St,rr=new ei({max:2**12}),ns=s=>{let t=rr.get(s);if(t)return t;let e=s.normalize("NFKD");return rr.set(s,e),e},nr=new ei({max:2**12}),Us=s=>{let t=nr.get(s);if(t)return t;let e=ns(s.toLowerCase());return nr.set(s,e),e},or=class extends ei{constructor(){super({max:256});}},ya=class extends ei{constructor(s=16*1024){super({maxSize:s,sizeCalculation:t=>t.length+1});}},cn=Symbol("PathScurry setAsCwd"),ot,us,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,ks,Es,Os,Cs,Rs,Ms,he,ke,$t,Jt,Ht,Zt,L,Ee,Kt,zt,C,Ai,Hs,os,Ti,_i,as,Zs,Pi,Fi,Ks,un,dn,pn,Ii,ze,Ue,fn,Oe,Pr,ht=(Pr=class{constructor(s,t=St,e,i,n,o,a){y(this,C);c(this,"name");c(this,"root");c(this,"roots");c(this,"parent");c(this,"nocase");c(this,"isCWD",false);y(this,ot);y(this,us);y(this,ds);y(this,ps);y(this,fs);y(this,gs);y(this,ms);y(this,ys);y(this,ws);y(this,bs);y(this,vs);y(this,Ss);y(this,xs);y(this,ks);y(this,Es);y(this,Os);y(this,Cs);y(this,Rs);y(this,Ms);y(this,he);y(this,ke);y(this,$t);y(this,Jt);y(this,Ht);y(this,Zt);y(this,L);y(this,Ee);y(this,Kt);y(this,zt);y(this,ze,[]);y(this,Ue,false);y(this,Oe);this.name=s,p(this,he,n?Us(s):ns(s)),p(this,L,t&ma),this.nocase=n,this.roots=i,this.root=e||this,p(this,Ee,o),p(this,$t,a.fullpath),p(this,Ht,a.relative),p(this,Zt,a.relativePosix),this.parent=a.parent,this.parent?p(this,ot,r(this.parent,ot)):p(this,ot,sn(a.fs));}get dev(){return r(this,us)}get mode(){return r(this,ds)}get nlink(){return r(this,ps)}get uid(){return r(this,fs)}get gid(){return r(this,gs)}get rdev(){return r(this,ms)}get blksize(){return r(this,ys)}get ino(){return r(this,ws)}get size(){return r(this,bs)}get blocks(){return r(this,vs)}get atimeMs(){return r(this,Ss)}get mtimeMs(){return r(this,xs)}get ctimeMs(){return r(this,ks)}get birthtimeMs(){return r(this,Es)}get atime(){return r(this,Os)}get mtime(){return r(this,Cs)}get ctime(){return r(this,Rs)}get birthtime(){return r(this,Ms)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,ke)!==void 0?r(this,ke):this.parent?p(this,ke,this.parent.depth()+1):p(this,ke,0)}childrenCache(){return r(this,Ee)}resolve(s){var i;if(!s)return this;let t=this.getRootString(s),e=s.substring(t.length).split(this.splitSep);return t?g(i=this.getRoot(t),C,Ai).call(i,e):g(this,C,Ai).call(this,e)}children(){let s=r(this,Ee).get(this);if(s)return s;let t=Object.assign([],{provisional:0});return r(this,Ee).set(this,t),p(this,L,r(this,L)&~Si),t}child(s,t){if(s===""||s===".")return this;if(s==="..")return this.parent||this;let e=this.children(),i=this.nocase?Us(s):ns(s);for(let l of e)if(r(l,he)===i)return l;let n=this.parent?this.sep:"",o=r(this,$t)?r(this,$t)+n+s:void 0,a=this.newChild(s,St,{...t,parent:this,fullpath:o});return this.canReaddir()||p(a,L,r(a,L)|Ct),e.push(a),a}relative(){if(this.isCWD)return "";if(r(this,Ht)!==void 0)return r(this,Ht);let s=this.name,t=this.parent;if(!t)return p(this,Ht,this.name);let e=t.relative();return e+(!e||!t.parent?"":this.sep)+s}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(r(this,Zt)!==void 0)return r(this,Zt);let s=this.name,t=this.parent;if(!t)return p(this,Zt,this.fullpathPosix());let e=t.relativePosix();return e+(!e||!t.parent?"":"/")+s}fullpath(){if(r(this,$t)!==void 0)return r(this,$t);let s=this.name,t=this.parent;if(!t)return p(this,$t,this.name);let e=t.fullpath()+(t.parent?this.sep:"")+s;return p(this,$t,e)}fullpathPosix(){if(r(this,Jt)!==void 0)return r(this,Jt);if(this.sep==="/")return p(this,Jt,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?p(this,Jt,`//?/${i}`):p(this,Jt,i)}let s=this.parent,t=s.fullpathPosix(),e=t+(!t||!s.parent?"":"/")+this.name;return p(this,Jt,e)}isUnknown(){return (r(this,L)&bt)===St}isType(s){return this[`is${s}`]()}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)&bt)===ln}isDirectory(){return (r(this,L)&bt)===jt}isCharacterDevice(){return (r(this,L)&bt)===on}isBlockDevice(){return (r(this,L)&bt)===an}isFIFO(){return (r(this,L)&bt)===nn}isSocket(){return (r(this,L)&bt)===hn}isSymbolicLink(){return (r(this,L)&me)===me}lstatCached(){return r(this,L)&sr?this:void 0}readlinkCached(){return r(this,Kt)}realpathCached(){return r(this,zt)}readdirCached(){let s=this.children();return s.slice(0,s.provisional)}canReadlink(){if(r(this,Kt))return true;if(!this.parent)return false;let s=r(this,L)&bt;return !(s!==St&&s!==me||r(this,L)&zs||r(this,L)&Ct)}calledReaddir(){return !!(r(this,L)&Si)}isENOENT(){return !!(r(this,L)&Ct)}isNamed(s){return this.nocase?r(this,he)===Us(s):r(this,he)===ns(s)}async readlink(){let s=r(this,Kt);if(s)return s;if(this.canReadlink()&&this.parent)try{let t=await r(this,ot).promises.readlink(this.fullpath()),e=(await this.parent.realpath())?.resolve(t);if(e)return p(this,Kt,e)}catch(t){g(this,C,Fi).call(this,t.code);return}}readlinkSync(){let s=r(this,Kt);if(s)return s;if(this.canReadlink()&&this.parent)try{let t=r(this,ot).readlinkSync(this.fullpath()),e=this.parent.realpathSync()?.resolve(t);if(e)return p(this,Kt,e)}catch(t){g(this,C,Fi).call(this,t.code);return}}async lstat(){if((r(this,L)&Ct)===0)try{return g(this,C,Ii).call(this,await r(this,ot).promises.lstat(this.fullpath())),this}catch(s){g(this,C,Pi).call(this,s.code);}}lstatSync(){if((r(this,L)&Ct)===0)try{return g(this,C,Ii).call(this,r(this,ot).lstatSync(this.fullpath())),this}catch(s){g(this,C,Pi).call(this,s.code);}}readdirCB(s,t=false){if(!this.canReaddir()){t?s(null,[]):queueMicrotask(()=>s(null,[]));return}let e=this.children();if(this.calledReaddir()){let n=e.slice(0,e.provisional);t?s(null,n):queueMicrotask(()=>s(null,n));return}if(r(this,ze).push(s),r(this,Ue))return;p(this,Ue,true);let i=this.fullpath();r(this,ot).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,C,Zs).call(this,n.code),e.provisional=0;else {for(let a of o)g(this,C,Ks).call(this,a,e);g(this,C,Hs).call(this,e);}g(this,C,fn).call(this,e.slice(0,e.provisional));});}async readdir(){if(!this.canReaddir())return [];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let t=this.fullpath();if(r(this,Oe))await r(this,Oe);else {let e=()=>{};p(this,Oe,new Promise(i=>e=i));try{for(let i of await r(this,ot).promises.readdir(t,{withFileTypes:!0}))g(this,C,Ks).call(this,i,s);g(this,C,Hs).call(this,s);}catch(i){g(this,C,Zs).call(this,i.code),s.provisional=0;}p(this,Oe,void 0),e();}return s.slice(0,s.provisional)}readdirSync(){if(!this.canReaddir())return [];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let t=this.fullpath();try{for(let e of r(this,ot).readdirSync(t,{withFileTypes:!0}))g(this,C,Ks).call(this,e,s);g(this,C,Hs).call(this,s);}catch(e){g(this,C,Zs).call(this,e.code),s.provisional=0;}return s.slice(0,s.provisional)}canReaddir(){if(r(this,L)&ir)return false;let s=bt&r(this,L);return s===St||s===jt||s===me}shouldWalk(s,t){return (r(this,L)&jt)===jt&&!(r(this,L)&ir)&&!s.has(this)&&(!t||t(this))}async realpath(){if(r(this,zt))return r(this,zt);if(!((Js|zs|Ct)&r(this,L)))try{let s=await r(this,ot).promises.realpath(this.fullpath());return p(this,zt,this.resolve(s))}catch{g(this,C,_i).call(this);}}realpathSync(){if(r(this,zt))return r(this,zt);if(!((Js|zs|Ct)&r(this,L)))try{let s=r(this,ot).realpathSync(this.fullpath());return p(this,zt,this.resolve(s))}catch{g(this,C,_i).call(this);}}[cn](s){if(s===this)return;s.isCWD=false,this.isCWD=true;let t=new Set([]),e=[],i=this;for(;i&&i.parent;)t.add(i),p(i,Ht,e.join(this.sep)),p(i,Zt,e.join("/")),i=i.parent,e.push("..");for(i=s;i&&i.parent&&!t.has(i);)p(i,Ht,void 0),p(i,Zt,void 0),i=i.parent;}},ot=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,ks=new WeakMap,Es=new WeakMap,Os=new WeakMap,Cs=new WeakMap,Rs=new WeakMap,Ms=new WeakMap,he=new WeakMap,ke=new WeakMap,$t=new WeakMap,Jt=new WeakMap,Ht=new WeakMap,Zt=new WeakMap,L=new WeakMap,Ee=new WeakMap,Kt=new WeakMap,zt=new WeakMap,C=new WeakSet,Ai=function(s){let t=this;for(let e of s)t=t.child(e);return t},Hs=function(s){var t;p(this,L,r(this,L)|Si);for(let e=s.provisional;e<s.length;e++){let i=s[e];i&&g(t=i,C,os).call(t);}},os=function(){r(this,L)&Ct||(p(this,L,(r(this,L)|Ct)&ts),g(this,C,Ti).call(this));},Ti=function(){var t;let s=this.children();s.provisional=0;for(let e of s)g(t=e,C,os).call(t);},_i=function(){p(this,L,r(this,L)|Js),g(this,C,as).call(this);},as=function(){if(r(this,L)&rs)return;let s=r(this,L);(s&bt)===jt&&(s&=ts),p(this,L,s|rs),g(this,C,Ti).call(this);},Zs=function(s=""){s==="ENOTDIR"||s==="EPERM"?g(this,C,as).call(this):s==="ENOENT"?g(this,C,os).call(this):this.children().provisional=0;},Pi=function(s=""){var t;s==="ENOTDIR"?g(t=this.parent,C,as).call(t):s==="ENOENT"&&g(this,C,os).call(this);},Fi=function(s=""){var e;let t=r(this,L);t|=zs,s==="ENOENT"&&(t|=Ct),(s==="EINVAL"||s==="UNKNOWN")&&(t&=ts),p(this,L,t),s==="ENOTDIR"&&this.parent&&g(e=this.parent,C,as).call(e);},Ks=function(s,t){return g(this,C,dn).call(this,s,t)||g(this,C,un).call(this,s,t)},un=function(s,t){let e=xi(s),i=this.newChild(s.name,e,{parent:this}),n=r(i,L)&bt;return n!==jt&&n!==me&&n!==St&&p(i,L,r(i,L)|rs),t.unshift(i),t.provisional++,i},dn=function(s,t){for(let e=t.provisional;e<t.length;e++){let i=t[e];if((this.nocase?Us(s.name):ns(s.name))===r(i,he))return g(this,C,pn).call(this,s,i,e,t)}},pn=function(s,t,e,i){let n=t.name;return p(t,L,r(t,L)&ts|xi(s)),n!==s.name&&(t.name=s.name),e!==i.provisional&&(e===i.length-1?i.pop():i.splice(e,1),i.unshift(t)),i.provisional++,t},Ii=function(s){let{atime:t,atimeMs:e,birthtime:i,birthtimeMs:n,blksize:o,blocks:a,ctime:l,ctimeMs:h,dev:d,gid:f,ino:u,mode:m,mtime:w,mtimeMs:v,nlink:S,rdev:k,size:b,uid:R}=s;p(this,Os,t),p(this,Ss,e),p(this,Ms,i),p(this,Es,n),p(this,ys,o),p(this,vs,a),p(this,Rs,l),p(this,ks,h),p(this,us,d),p(this,gs,f),p(this,ws,u),p(this,ds,m),p(this,Cs,w),p(this,xs,v),p(this,ps,S),p(this,ms,k),p(this,bs,b),p(this,fs,R);let M=xi(s);p(this,L,r(this,L)&ts|M|sr),M!==St&&M!==jt&&M!==me&&p(this,L,r(this,L)|rs);},ze=new WeakMap,Ue=new WeakMap,fn=function(s){p(this,Ue,false);let t=r(this,ze).slice();r(this,ze).length=0,t.forEach(e=>e(null,s));},Oe=new WeakMap,Pr),gn=class mn extends ht{constructor(e,i=St,n,o,a,l,h){super(e,i,n,o,a,l,h);c(this,"sep","\\");c(this,"splitSep",ga);}newChild(e,i=St,n={}){return new mn(e,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return ri.win32.parse(e).root}getRoot(e){if(e=fa(e.toUpperCase()),e===this.root.name)return this.root;for(let[i,n]of Object.entries(this.roots))if(this.sameRoot(e,i))return this.roots[e]=n;return this.roots[e]=new $i(e,this).root}sameRoot(e,i=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(rn,"$1\\"),e===i}},yn=class wn extends ht{constructor(e,i=St,n,o,a,l,h){super(e,i,n,o,a,l,h);c(this,"splitSep","/");c(this,"sep","/");}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,i=St,n={}){return new wn(e,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Be,Ge,Ls,As,Fr,bn=(Fr=class{constructor(s=process.cwd(),t,e,{nocase:i,childrenCacheSize:n=16*1024,fs:o=is}={}){c(this,"root");c(this,"rootPath");c(this,"roots");c(this,"cwd");y(this,Be);y(this,Ge);y(this,Ls);c(this,"nocase");y(this,As);p(this,As,sn(o)),(s instanceof URL||s.startsWith("file://"))&&(s=url.fileURLToPath(s));let a=t.resolve(s);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),p(this,Be,new or),p(this,Ge,new or),p(this,Ls,new ya(n));let l=a.substring(this.rootPath.length).split(e);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,As)),this.roots[this.rootPath]=this.root;let h=this.root,d=l.length-1,f=t.sep,u=this.rootPath,m=false;for(let w of l){let v=d--;h=h.child(w,{relative:new Array(v).fill("..").join(f),relativePosix:new Array(v).fill("..").join("/"),fullpath:u+=(m?"":f)+w}),m=true;}this.cwd=h;}depth(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.depth()}childrenCache(){return r(this,Ls)}resolve(...s){let t="";for(let n=s.length-1;n>=0;n--){let o=s[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let e=r(this,Be).get(t);if(e!==void 0)return e;let i=this.cwd.resolve(t).fullpath();return r(this,Be).set(t,i),i}resolvePosix(...s){let t="";for(let n=s.length-1;n>=0;n--){let o=s[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let e=r(this,Ge).get(t);if(e!==void 0)return e;let i=this.cwd.resolve(t).fullpathPosix();return r(this,Ge).set(t,i),i}relative(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relative()}relativePosix(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relativePosix()}basename(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.name}dirname(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),(s.parent||s).fullpath()}async readdir(s=this.cwd,t={withFileTypes:true}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e}=t;if(s.canReaddir()){let i=await s.readdir();return e?i:i.map(n=>n.name)}else return []}readdirSync(s=this.cwd,t={withFileTypes:true}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true}=t;return s.canReaddir()?e?s.readdirSync():s.readdirSync().map(i=>i.name):[]}async lstat(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstat()}lstatSync(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstatSync()}async readlink(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=await s.readlink();return t?e:e?.fullpath()}readlinkSync(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=s.readlinkSync();return t?e:e?.fullpath()}async realpath(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=await s.realpath();return t?e:e?.fullpath()}realpathSync(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=s.realpathSync();return t?e:e?.fullpath()}async walk(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(s))&&a.push(e?s:s.fullpath());let l=new Set,h=(f,u)=>{l.add(f),f.readdirCB((m,w)=>{if(m)return u(m);let v=w.length;if(!v)return u();let S=()=>{--v===0&&u();};for(let k of w)(!n||n(k))&&a.push(e?k:k.fullpath()),i&&k.isSymbolicLink()?k.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(l,o)?h(b,S):S()):k.shouldWalk(l,o)?h(k,S):S();},true);},d=s;return new Promise((f,u)=>{h(d,m=>{if(m)return u(m);f(a);});})}walkSync(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(s))&&a.push(e?s:s.fullpath());let l=new Set([s]);for(let h of l){let d=h.readdirSync();for(let f of d){(!n||n(f))&&a.push(e?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(i&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync();}u.shouldWalk(l,o)&&l.add(u);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(s=this.cwd,t={}){return typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd),this.stream(s,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t;(!n||n(s))&&(yield e?s:s.fullpath());let a=new Set([s]);for(let l of a){let h=l.readdirSync();for(let d of h){(!n||n(d))&&(yield e?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(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Xs({objectMode:true});(!n||n(s))&&a.write(e?s:s.fullpath());let l=new Set,h=[s],d=0,f=()=>{let u=false;for(;!u;){let m=h.shift();if(!m){d===0&&a.end();return}d++,l.add(m);let w=(S,k,b=false)=>{if(S)return a.emit("error",S);if(i&&!b){let R=[];for(let M of k)M.isSymbolicLink()&&R.push(M.realpath().then(E=>E?.isUnknown()?E.lstat():E));if(R.length){Promise.all(R).then(()=>w(null,k,true));return}}for(let R of k)R&&(!n||n(R))&&(a.write(e?R:R.fullpath())||(u=true));d--;for(let R of k){let M=R.realpathCached()||R;M.shouldWalk(l,o)&&h.push(M);}u&&!a.flowing?a.once("drain",f):v||f();},v=true;m.readdirCB(w,true),v=false;}};return f(),a}streamSync(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=new Xs({objectMode:true}),l=new Set;(!n||n(s))&&a.write(e?s:s.fullpath());let h=[s],d=0,f=()=>{let u=false;for(;!u;){let m=h.shift();if(!m){d===0&&a.end();return}d++,l.add(m);let w=m.readdirSync();for(let v of w)(!n||n(v))&&(a.write(e?v:v.fullpath())||(u=true));d--;for(let v of w){let S=v;if(v.isSymbolicLink()){if(!(i&&(S=v.realpathSync())))continue;S.isUnknown()&&S.lstatSync();}S.shouldWalk(l,o)&&h.push(S);}}u&&!a.flowing&&a.once("drain",f);};return f(),a}chdir(s=this.cwd){let t=this.cwd;this.cwd=typeof s=="string"?this.cwd.resolve(s):s,this.cwd[cn](t);}},Be=new WeakMap,Ge=new WeakMap,Ls=new WeakMap,As=new WeakMap,Fr),$i=class extends bn{constructor(t=process.cwd(),e={}){let{nocase:i=true}=e;super(t,ri.win32,"\\",{...e,nocase:i});c(this,"sep","\\");this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase;}parseRootPath(t){return ri.win32.parse(t).root.toUpperCase()}newRoot(t){return new gn(this.rootPath,jt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},zi=class extends bn{constructor(t=process.cwd(),e={}){let{nocase:i=false}=e;super(t,ri.posix,"/",{...e,nocase:i});c(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new yn(this.rootPath,jt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},vn=class extends zi{constructor(s=process.cwd(),t={}){let{nocase:e=true}=t;super(s,{...t,nocase:e});}};process.platform==="win32"?gn:yn;var wa=process.platform==="win32"?$i:process.platform==="darwin"?vn:zi,ba=s=>s.length>=1,va=s=>s.length>=1,Sa=Symbol.for("nodejs.util.inspect.custom"),q,ct,J,Ce,It,Ts,ce,ue,de,Ve,qe,Sn=(qe=class{constructor(t,e,i,n){y(this,q);y(this,ct);y(this,J);c(this,"length");y(this,Ce);y(this,It);y(this,Ts);y(this,ce);y(this,ue);y(this,de);y(this,Ve,true);if(!ba(t))throw new TypeError("empty pattern list");if(!va(e))throw new TypeError("empty glob list");if(e.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(p(this,q,t),p(this,ct,e),p(this,J,i),p(this,Ce,n),r(this,J)===0){if(this.isUNC()){let[o,a,l,h,...d]=r(this,q),[f,u,m,w,...v]=r(this,ct);d[0]===""&&(d.shift(),v.shift());let S=[o,a,l,h,""].join("/"),k=[f,u,m,w,""].join("/");p(this,q,[S,...d]),p(this,ct,[k,...v]),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 d=o+"/",f=l+"/";p(this,q,[d,...a]),p(this,ct,[f,...h]),this.length=r(this,q).length;}}}[Sa](){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 p(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,It)!==void 0?r(this,It):this.hasMore()?(p(this,It,new qe(r(this,q),r(this,ct),r(this,J)+1,r(this,Ce))),p(r(this,It),de,r(this,de)),p(r(this,It),ue,r(this,ue)),p(r(this,It),ce,r(this,ce)),r(this,It)):p(this,It,null)}isUNC(){let t=r(this,q);return r(this,ue)!==void 0?r(this,ue):p(this,ue,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,ce)!==void 0?r(this,ce):p(this,ce,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,de)!==void 0?r(this,de):p(this,de,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,Ve))}markFollowGlobstar(){return r(this,J)===0||!this.isGlobstar()||!r(this,Ve)?false:(p(this,Ve,false),true)}},q=new WeakMap,ct=new WeakMap,J=new WeakMap,Ce=new WeakMap,It=new WeakMap,Ts=new WeakMap,ce=new WeakMap,ue=new WeakMap,de=new WeakMap,Ve=new WeakMap,qe),xa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ar=class{constructor(s,{nobrace:t,nocase:e,noext:i,noglobstar:n,platform:o=xa}){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:e,noext:i,noglobstar:n,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of s)this.add(a);}add(s){let t=new fe(s,this.mmopts);for(let e=0;e<t.set.length;e++){let i=t.set[e],n=t.globParts[e];if(!i||!n)throw new Error("invalid pattern object");for(;i[0]==="."&&n[0]===".";)i.shift(),n.shift();let o=new Sn(i,n,0,this.platform),a=new fe(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(s){let t=s.fullpath(),e=`${t}/`,i=s.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(e))return true;return false}childrenIgnored(s){let t=s.fullpath()+"/",e=(s.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(e))return true;for(let i of this.absoluteChildren)if(i.match(t))return true;return false}},ka=class xn{constructor(t=new Map){c(this,"store");this.store=t;}copy(){return new xn(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let i=t.fullpath(),n=this.store.get(i);n?n.add(e.globString()):this.store.set(i,new Set([e.globString()]));}},Ea=class{constructor(){c(this,"store",new Map);}add(s,t,e){let i=(t?2:0)|(e?1:0),n=this.store.get(s);this.store.set(s,n===void 0?i:i&n);}entries(){return [...this.store.entries()].map(([s,t])=>[s,!!(t&2),!!(t&1)])}},Oa=class{constructor(){c(this,"store",new Map);}add(s,t){if(!s.canReaddir())return;let e=this.store.get(s);e?e.find(i=>i.globString()===t.globString())||e.push(t):this.store.set(s,[t]);}get(s){let t=this.store.get(s);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(s=>[s,this.store.get(s)])}keys(){return [...this.store.keys()].filter(s=>s.canReaddir())}},lr=class kn{constructor(t,e){c(this,"hasWalkedCache");c(this,"matches",new Ea);c(this,"subwalks",new Oa);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=e?e.copy():new ka;}processPatterns(t,e){this.patterns=e;let i=e.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 u=o.rest();if(u)o=u;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 u=h===".."||h===""||h===".";this.matches.add(n.resolve(h),l,u);continue}else if(h===at){(!n.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(n,o);let u=d?.pattern(),m=d?.rest();if(!d||(u===""||u===".")&&!m)this.matches.add(n,l,u===""||u===".");else if(u===".."){let w=n.parent||n;m?this.hasWalkedCache.hasWalked(w,m)||this.subwalks.add(w,m):this.matches.add(w,l,true);}}else h instanceof RegExp&&this.subwalks.add(n,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new kn(this.opts,this.hasWalkedCache)}filterEntries(t,e){let i=this.subwalks.get(t),n=this.child();for(let o of e)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,e,i,n){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,n,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(i&&e.checkFollowGlobstar()?this.subwalks.add(t,i):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),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,e,i,n){e.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}testString(t,e,i,n){t.isNamed(e)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}},Ca=(s,t)=>typeof s=="string"?new ar([s],t):Array.isArray(s)?new ar(s,t):s,Je,Yt,Re,xt,ye,Di,Ir,En=(Ir=class{constructor(s,t,e){y(this,xt);c(this,"path");c(this,"patterns");c(this,"opts");c(this,"seen",new Set);c(this,"paused",false);c(this,"aborted",false);y(this,Je,[]);y(this,Yt);y(this,Re);c(this,"signal");c(this,"maxDepth");c(this,"includeChildMatches");if(this.patterns=s,this.path=t,this.opts=e,p(this,Re,!e.posix&&e.platform==="win32"?"\\":"/"),this.includeChildMatches=e.includeChildMatches!==false,(e.ignore||!this.includeChildMatches)&&(p(this,Yt,Ca(e.ignore??[],e)),!this.includeChildMatches&&typeof r(this,Yt).add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=e.maxDepth||1/0,e.signal&&(this.signal=e.signal,this.signal.addEventListener("abort",()=>{r(this,Je).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let s;for(;!this.paused&&(s=r(this,Je).shift());)s();}onResume(s){this.signal?.aborted||(this.paused?r(this,Je).push(s):s());}async matchCheck(s,t){if(t&&this.opts.nodir)return;let e;if(this.opts.realpath){if(e=s.realpathCached()||await s.realpath(),!e)return;s=e;}let i=s.isUnknown()||this.opts.stat?await s.lstat():s;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(s,t){return s&&(this.maxDepth===1/0||s.depth()<=this.maxDepth)&&(!t||s.canReaddir())&&(!this.opts.nodir||!s.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!s.isSymbolicLink()||!s.realpathCached()?.isDirectory())&&!g(this,xt,ye).call(this,s)?s:void 0}matchCheckSync(s,t){if(t&&this.opts.nodir)return;let e;if(this.opts.realpath){if(e=s.realpathCached()||s.realpathSync(),!e)return;s=e;}let i=s.isUnknown()||this.opts.stat?s.lstatSync():s;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(s,t){if(g(this,xt,ye).call(this,s))return;if(!this.includeChildMatches&&r(this,Yt)?.add){let n=`${s.relativePosix()}/**`;r(this,Yt).add(n);}let e=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(s);let i=this.opts.mark&&s.isDirectory()?r(this,Re):"";if(this.opts.withFileTypes)this.matchEmit(s);else if(e){let n=this.opts.posix?s.fullpathPosix():s.fullpath();this.matchEmit(n+i);}else {let n=this.opts.posix?s.relativePosix():s.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+r(this,Re))?"."+r(this,Re):"";this.matchEmit(n?o+n+i:"."+i);}}async match(s,t,e){let i=await this.matchCheck(s,e);i&&this.matchFinish(i,t);}matchSync(s,t,e){let i=this.matchCheckSync(s,e);i&&this.matchFinish(i,t);}walkCB(s,t,e){this.signal?.aborted&&e(),this.walkCB2(s,t,new lr(this.opts),e);}walkCB2(s,t,e,i){if(g(this,xt,Di).call(this,s))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(s,t,e,i));return}e.processPatterns(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,xt,ye).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let a of e.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,e,o):a.readdirCB((h,d)=>this.walkCB3(a,d,e,o),true);}o();}walkCB3(s,t,e,i){e=e.filterEntries(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,xt,ye).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let[a,l]of e.subwalks.entries())n++,this.walkCB2(a,l,e.child(),o);o();}walkCBSync(s,t,e){this.signal?.aborted&&e(),this.walkCB2Sync(s,t,new lr(this.opts),e);}walkCB2Sync(s,t,e,i){if(g(this,xt,Di).call(this,s))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(s,t,e,i));return}e.processPatterns(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,xt,ye).call(this,a)||this.matchSync(a,l,h);for(let a of e.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirSync();this.walkCB3Sync(a,l,e,o);}o();}walkCB3Sync(s,t,e,i){e=e.filterEntries(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,xt,ye).call(this,a)||this.matchSync(a,l,h);for(let[a,l]of e.subwalks.entries())n++,this.walkCB2Sync(a,l,e.child(),o);o();}},Je=new WeakMap,Yt=new WeakMap,Re=new WeakMap,xt=new WeakSet,ye=function(s){return this.seen.has(s)||!!r(this,Yt)?.ignored?.(s)},Di=function(s){return !!r(this,Yt)?.childrenIgnored?.(s)},Ir),hr=class extends En{constructor(t,e,i){super(t,e,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,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(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}},cr=class extends En{constructor(t,e,i){super(t,e,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}},Ra=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Le=class{constructor(s,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 s=="string"&&(s=[s]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(s=s.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");s=s.map(l=>l.includes("/")?l:`./**/${l}`);}if(this.pattern=s,this.platform=t.platform||Ra,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"?$i:t.platform==="darwin"?vn:t.platform?zi:wa;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let e=this.platform==="darwin"||this.platform==="win32",i={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:e,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 fe(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 Sn(l,d,0,this.platform)});}async walk(){return [...await 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}).walk()]}walkSync(){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}).walkSync()]}stream(){return new cr(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 cr(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()}},Ma=(s,t={})=>{Array.isArray(s)||(s=[s]);for(let e of s)if(new fe(e,t).hasMagic())return true;return false};function si(s,t={}){return new Le(s,t).streamSync()}function On(s,t={}){return new Le(s,t).stream()}function Cn(s,t={}){return new Le(s,t).walkSync()}async function ur(s,t={}){return new Le(s,t).walk()}function ii(s,t={}){return new Le(s,t).iterateSync()}function Rn(s,t={}){return new Le(s,t).iterate()}var La=si,Aa=Object.assign(On,{sync:si}),Ta=ii,_a=Object.assign(Rn,{sync:ii}),Pa=Object.assign(Cn,{stream:si,iterate:ii}),ti=Object.assign(ur,{glob:ur,globSync:Cn,sync:Pa,globStream:On,stream:Aa,globStreamSync:si,streamSync:La,globIterate:Rn,iterate:_a,globIterateSync:ii,iterateSync:Ta,Glob:Le,hasMagic:Ma,escape:Vr,unescape:Fe});ti.glob=ti;var Dt;(I=>{I.Level=Ia__default.default.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let t={DEBUG:0,INFO:1,WARN:2,ERROR:3},e="INFO";function i(O){return t[O]>=t[e]}function n(){return e}I.getLevel=n;let o=new Map;I.Default=F({service:"default"});let l="";function h(){return l}I.file=h;let d,f,u=false,m=false,w=O=>{try{m&&process.stderr.write(O);}catch{}},v=false,S=false;async function k(O){if(u)return;if(O.level&&(e=O.level),O.print&&(m=O.print??false),O.print){u=true;return}let P=O.logDir||ri__default.default.join(process.env.EASBOT_LOG_PATH??process.cwd(),"logs");O.logFile?l=ri__default.default.join(P,O.logFile??"ollama-sdk.log"):l=ri__default.default.join(P,"ollama-sdk.log");try{await Mn__default.default.mkdir(P,{recursive:!0}),d=await Mn__default.default.open(l,"a"),f=Yo.createWriteStream("",{fd:d.fd,autoClose:!1}),w=A=>{if(!(v||S||!f||f.destroyed))try{if(!f.writable)return;f.write(A,D=>{if(D&&!v){let _=D;if(_.code==="EPIPE"||_.code==="EIO"){S=!0,f?.destroy();return}v=!0,setTimeout(()=>{v=!1;},1e3);}});}catch(D){let _=D;if(_.code==="EPIPE"||_.code==="EIO"){S=!0,f?.destroy();return}v||(v=!0,setTimeout(()=>{v=!1;},1e3));}},u=!0;}catch{w=A=>{try{process.stderr.write(A);}catch{}},u=true;}}I.init=k;async function b(){u&&(f&&!f.destroyed&&(await new Promise((O,P)=>{f.end(A=>{A?P(A):O();});}).catch(()=>{}),f=void 0),d&&(await d.close().catch(()=>{}),d=void 0),w=O=>{try{process.stderr.write(O);}catch{}},u=false);}I.close=b;function M(O,P=0){let A=O.message;return O.cause instanceof Error&&P<10?A+" Caused by: "+M(O.cause,P+1):A}let E=Date.now();function F(O){O=O||{};let P=O.service;if(P&&typeof P=="string"){let _=o.get(P);if(_)return _}function A(_,N){let Ae=Object.entries({...O,...N}).filter(([Ui,Xt])=>Xt!=null).map(([Ui,Xt])=>{let hi=`${Ui}=`;return Xt instanceof Error?hi+M(Xt):typeof Xt=="object"?hi+JSON.stringify(Xt):hi+Xt}).join(" "),Et=new Date,Pn=Et.getTime()-E;return E=Et.getTime(),[utils.formatLogTime(Et),"+"+Pn+"ms",Ae,_].filter(Boolean).join(" ")+`
5
- `}let D={debug(_,N){i("DEBUG")&&w("DEBUG "+A(_,N));},info(_,N){i("INFO")&&w("INFO "+A(_,N));},error(_,N){i("ERROR")&&w("ERROR "+A(_,N));},warn(_,N){i("WARN")&&w("WARN "+A(_,N));},tag(_,N){return O&&(O[_]=N),D},clone(){return I.create({...O})},time(_,N){let Ae=Date.now();D.info(_,{status:"started",...N});function Et(){D.info(_,{status:"completed",duration:Date.now()-Ae,...N});}return {stop:Et,[Symbol.dispose](){Et();}}}};return P&&typeof P=="string"&&o.set(P,D),D}I.create=F;})(Dt||(Dt={}));function Ln(s,t,e){let i;return t?i="tool-calls":s?i="stop":i="other",{unified:i,raw:e}}var kt=Dt.create({service:"ollama-sdk",module:"native-language-model"});function ni(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function oi(s){if(!s||s.trim().length===0)return false;try{return JSON.parse(s),!0}catch{return false}}function An(s){return typeof s=="string"?s:JSON.stringify(s)}function Tn(s){return !s.tools||s.tools.length===0?{}:{tools:s.tools.map(t=>{if(!t.name)throw new He(t.name||"unknown","name");let e=t.inputSchema||t.parameters;if(!e)throw new He(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:e}}})}}function _n(s){let t=[];for(let e of s)try{switch(e.role){case "system":t.push({role:"system",content:e.content});break;case "user":{let i=e.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 e.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 e.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){kt.warn("Failed to convert message",{messageRole:e.role,error:i instanceof Error?i.message:String(i)});}return t}var ai=class{constructor(t,e={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"client");this.modelId=t,this.client=new Fs(e.baseURL);}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}async doStream(t){let e=ni();kt.debug("Stream request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=_n(t.prompt),n=Tn({tools:t.tools}),o=JSON.stringify({model:this.modelId,messages:i,options:Te,...n}),a=null,l=null,h=w=>{a&&a.enqueue(w),l&&l.enqueue(w);},d=async()=>{try{let w=!0,v=!1,S=!1,k="",b="",R=!1,M=[],E=[],F=()=>{if(E.length>0){for(let O of E)h(O);E.length=0;}},I=null;for await(let O of this.client.streamChat({model:this.modelId,messages:i,options:Te,...n})){if(I&&I.chunkCount++,w){w=!1;let P={type:"response-metadata",id:ni(),modelId:this.modelId,timestamp:new Date(O.created_at)};h(P),I&&I.eventCount++;}if(O.message?.tool_calls){S&&(E.push({type:"reasoning-end",id:"reasoning-0"}),S=!1),v&&(E.push({type:"text-end",id:"txt-0"}),v=!1);for(let P of O.message.tool_calls){if(!P.id||!P.function?.name){let Et=P.id?"function.name":"id";kt.error("Invalid tool call: missing field",{traceId:e,missingField:Et,toolCall:void 0}),E.push({type:"error",error:`Invalid tool call: missing ${Et}`});continue}let A=P.id,D=P.function.name,_=An(P.function.arguments),N=M.find(Et=>Et.id===A);N?(N.function.arguments+=_,kt.debug("Tool call arguments accumulated",{traceId:e,toolCallId:A,toolName:D,deltaLength:_.length,totalLength:N.function.arguments.length,isComplete:oi(N.function.arguments)}),_&&E.push({type:"tool-input-delta",id:A,delta:_})):(N={id:A,type:"function",function:{name:D,arguments:_},hasFinished:!1},M.push(N),I&&I.toolCallCount++,kt.debug("Tool call received",{traceId:e,toolCallId:A,toolName:D,argumentsLength:_.length,isComplete:oi(_)}),E.push({type:"tool-input-start",id:A,toolName:D}),_&&E.push({type:"tool-input-delta",id:A,delta:_}));let Ae=oi(N.function.arguments);!N.hasFinished&&Ae&&(kt.debug("Tool call arguments complete",{traceId:e,toolCallId:A,toolName:D,isComplete:Ae,argumentsLength:N.function.arguments.length}),E.push({type:"tool-input-end",id:A}),E.push({type:"tool-call",toolCallId:A,toolName:D,input:N.function.arguments}),N.hasFinished=!0);}F(),I&&(I.eventCount+=E.length);}if(O.message?.content){let P=O.message.content;for(b+=P;b.length>0;)if(R){let A=b.indexOf("</think>");if(A===-1){b.length>0&&E.push({type:"reasoning-delta",id:"reasoning-0",delta:b}),b="";break}else {if(A>0){let D=b.substring(0,A);E.push({type:"reasoning-delta",id:"reasoning-0",delta:D});}E.push({type:"reasoning-end",id:"reasoning-0"}),S=!1,R=!1,b=b.substring(A+8);}}else {let A=b.indexOf("<think>");if(A===-1){b.length>0&&(v||(v=!0,E.push({type:"text-start",id:"txt-0"})),E.push({type:"text-delta",id:"txt-0",delta:b}),k+=b),b="";break}else {if(A>0){let D=b.substring(0,A);v||(v=!0,E.push({type:"text-start",id:"txt-0"})),E.push({type:"text-delta",id:"txt-0",delta:D}),k+=D,E.push({type:"text-end",id:"txt-0"}),v=!1;}R=!0,b=b.substring(A+7),S||(S=!0,E.push({type:"reasoning-start",id:"reasoning-0"}));}}}if(F(),I&&(I.eventCount+=E.length),O.done){let P=M.filter(_=>!_.hasFinished);for(let _ of P)E.push({type:"tool-input-end",id:_.id}),E.push({type:"tool-call",toolCallId:_.id,toolName:_.function.name,input:_.function.arguments});b.length>0&&(R?(E.push({type:"reasoning-delta",id:"reasoning-0",delta:b}),E.push({type:"reasoning-end",id:"reasoning-0"})):(v||(v=!0,E.push({type:"text-start",id:"txt-0"})),E.push({type:"text-delta",id:"txt-0",delta:b}),k+=b)),v&&E.push({type:"text-end",id:"txt-0"});let D=M.length>0?"tool-calls":"stop";if(E.push({type:"finish",finishReason:D,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}}}),F(),I&&(I.eventCount+=E.length),I);M.length=0;}}}catch(w){kt.error("Stream processing error",{traceId:e,error:w instanceof Error?w.message:String(w),stack:void 0}),h({type:"error",error:w instanceof Error?w.message:String(w)}),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(w){a=w;}}),u=new ReadableStream({start(w){l=w;}});d();async function*m(w){let v=w.getReader();try{for(;;){let{done:S,value:k}=await v.read();if(S)break;yield k;}}finally{v.releaseLock();}}return {stream:f,fullStream:m(u),request:{body:o},response:{}}}async doGenerate(t){let e=ni();kt.debug("Generate request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=_n(t.prompt),n=Tn({tools:t.tools}),o=await this.client.chat({model:this.modelId,messages:i,options:Te,...n}),a=[];if(o.message?.content&&a.push({type:"text",text:o.message.content}),o.message?.tool_calls){kt.debug("Tool calls received in generate",{traceId:e,toolCallCount:o.message.tool_calls.length});for(let d of o.message.tool_calls){let f=d.id||ni(),u=d.function.name,m=An(d.function.arguments);kt.debug("Processing tool call in generate",{traceId:e,toolCallId:f,toolName:u,argumentsLength:m.length,isComplete:oi(m)}),a.push({type:"tool-call",toolCallId:f,toolName:u,input:m});}}let l=!!(o.message?.tool_calls&&o.message.tool_calls.length>0),h=Ln(o.done??false,l,"stop");return kt.debug("Generate request completed",{traceId:e,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:Te,...n})},response:{}}}};var Qt=class{constructor(t,e={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"nativeModel");this.modelId=t,this.nativeModel=new ai(t,{baseURL:e.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 _s=class{constructor(t,e={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"maxEmbeddingsPerCall");c(this,"supportsParallelCalls",true);c(this,"baseURL");this.modelId=t,this.baseURL=e.baseURL||"http://localhost:11434";}async doEmbed(t){let{values:e,abortSignal:i}=t,n=Dt.create({service:"ollama-embedding"});if(!e||e.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:e.length,baseURL:this.baseURL});try{let o=await Promise.all(e.map(l=>this.generateSingleEmbedding(l,i))),a=e.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,e){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:e});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 e=t.match(/[a-zA-Z]/g)?.length||0,i=t.match(/[\u4e00-\u9fa5]/g)?.length||0,n=t.length-e-i;return Math.ceil(e/4)+i+Math.ceil(n*.5)}};var li=class{constructor(t,e,i={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"languageModel");c(this,"options");c(this,"log",Dt.create({service:"ollama-sdk",module:"reranking-model"}));this.modelId=t,this.languageModel=new Qt(t,e),this.options={totalScore:i.totalScore??1,useEnhancedPrompt:i.useEnhancedPrompt??true,promptLanguage:i.promptLanguage??"en"},this.log.debug("OllamaRerankingModel created",{modelId:t,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(t){let{query:e,documents:i,topN:n}=t,o;Array.isArray(i)?o=i:i.type==="text"?o=i.values.map((h,d)=>({content:h,id:`doc_${d+1}`})):o=i.values;let a=n??o.length;if(o.length===0)return {ranking:[],warnings:[]};try{let h=this.buildRerankPrompt(e,o),f=(await this.languageModel.doGenerate({prompt:[{role:"user",content:[{type:"text",text:h}]}],maxOutputTokens:500,temperature:.1})).content.find(m=>m.type==="text")?.text||"",u=this.parseRerankResult(f,o,a);return {ranking:u.results.map(m=>({index:m.index,relevanceScore:m.score,document:m.document})),warnings:u.warnings.map(m=>({type:"other",message:m}))}}catch(h){return this.log.error("Reranking failed",{error:h.message}),{ranking:o.map((f,u)=>({index:u,relevanceScore:this.options.totalScore*(1-u/o.length),document:f})),warnings:[{type:"other",message:`Reranking failed, using original order: ${h.message}`}]}}}buildRerankPrompt(t,e){let i=e.map((n,o)=>{let a=n.id||`doc_${o+1}`,l=n.content.slice(0,300);return `${o+1}. [ID: ${a}] ${l}`}).join(`
1
+ 'use strict';var utils=require('@easbot/utils');require('path');var H=Object.defineProperty;var X=(s,t,e)=>t in s?H(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e;var r=(s,t,e)=>X(s,typeof t!="symbol"?t+"":t,e);var D=class{constructor(t="http://localhost:11434"){r(this,"baseURL",t);}async*streamChat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:true})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);if(!e.body)throw new Error("Response body is null");let o=e.body.getReader(),a=new TextDecoder,n="";try{for(;;){let{done:l,value:c}=await o.read();if(l){if(n.trim())try{yield JSON.parse(n);}catch{}break}n+=a.decode(c,{stream:!0});let u=n.split(`
2
+ `);n=u.pop()||"";for(let b of u){let O=b.trim();if(O)try{yield JSON.parse(O);}catch{}}}}finally{o.releaseLock();}}async chat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);return e.json()}};var w={numCtx:262144,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},ee=["numCtx","repeatPenalty","numPredict"];var _=class extends Error{constructor(e,o){super(e);r(this,"cause",o);this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},J=class extends _{constructor(e,o,a){super(e,a);r(this,"url",o);this.name="ConnectionError";}},G=class extends _{constructor(e,o){super(`Model not found: ${e}`,o);r(this,"modelId",e);this.name="ModelNotFoundError";}},z=class extends _{constructor(e,o,a,n){super(e,n);r(this,"field",o);r(this,"value",a);this.name="ValidationError";}},B=class extends _{constructor(e,o,a){super(e,a);r(this,"timeoutMs",o);this.name="TimeoutError";}},T=class extends _{constructor(e,o,a){super(`Invalid tool definition for "${e}": missing ${o}`,a);r(this,"toolName",e);r(this,"missingField",o);this.name="InvalidToolDefinitionError";}};function Q(s,t,e){let o;return t?o="tool-calls":s?o="stop":o="other",{unified:o,raw:e}}var x=utils.Log.create({service:"ollama-sdk",module:"native-language-model"});function V(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function U(s){if(!s||s.trim().length===0)return false;try{return JSON.parse(s),!0}catch{return false}}function K(s){return typeof s=="string"?s:JSON.stringify(s)}function Y(s){return !s.tools||s.tools.length===0?{}:{tools:s.tools.map(t=>{if(!t.name)throw new T(t.name||"unknown","name");let e=t.inputSchema||t.parameters;if(!e)throw new T(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:e}}})}}function Z(s){let t=[];for(let e of s)try{switch(e.role){case "system":t.push({role:"system",content:e.content});break;case "user":{let o=e.content.filter(a=>a.type==="text").map(a=>a.text).join(`
3
+ `);o&&t.push({role:"user",content:o});break}case "assistant":{let o="",a=[];for(let n of e.content)if(n.type==="text")o+=n.text;else if(n.type==="tool-call"){let l=n;a.push({id:l.toolCallId,type:"function",function:{name:l.toolName,arguments:JSON.stringify(l.input)}});}t.push({role:"assistant",content:o||null,tool_calls:a.length>0?a:void 0});break}case "tool":for(let o of e.content){let a=o.output,n;switch(a.type){case "text":case "error-text":n=a.value;break;case "content":case "json":case "error-json":n=JSON.stringify(a.value);break;default:n=String(a.value);break}t.push({role:"tool",tool_call_id:o.toolCallId,content:n});}break}}catch(o){x.warn("Failed to convert message",{messageRole:e.role,error:o instanceof Error?o.message:String(o)});}return t}var F=class{constructor(t,e={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"defaultObjectGenerationMode","json");r(this,"supportedUrls",{});r(this,"client");this.modelId=t,this.client=new D(e.baseURL);}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}async doStream(t){let e=V();x.debug("Stream request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let o=Z(t.prompt),a=Y({tools:t.tools}),n=JSON.stringify({model:this.modelId,messages:o,options:w,...a}),l=null,c=null,u=m=>{l&&l.enqueue(m),c&&c.enqueue(m);},b=async()=>{try{let m=!0,M=!1,L=!1,E="",p="",N=!1,P=[],d=[],j=()=>{if(d.length>0){for(let v of d)u(v);d.length=0;}},y=null;for await(let v of this.client.streamChat({model:this.modelId,messages:o,options:w,...a})){if(y&&y.chunkCount++,m){m=!1;let k={type:"response-metadata",id:V(),modelId:this.modelId,timestamp:new Date(v.created_at)};u(k),y&&y.eventCount++;}if(v.message?.tool_calls){L&&(d.push({type:"reasoning-end",id:"reasoning-0"}),L=!1),M&&(d.push({type:"text-end",id:"txt-0"}),M=!1);for(let k of v.message.tool_calls){if(!k.id||!k.function?.name){let $=k.id?"function.name":"id";x.error("Invalid tool call: missing field",{traceId:e,missingField:$,toolCall:void 0}),d.push({type:"error",error:`Invalid tool call: missing ${$}`});continue}let f=k.id,C=k.function.name,h=K(k.function.arguments),S=P.find($=>$.id===f);S?(S.function.arguments+=h,x.debug("Tool call arguments accumulated",{traceId:e,toolCallId:f,toolName:C,deltaLength:h.length,totalLength:S.function.arguments.length,isComplete:U(S.function.arguments)}),h&&d.push({type:"tool-input-delta",id:f,delta:h})):(S={id:f,type:"function",function:{name:C,arguments:h},hasFinished:!1},P.push(S),y&&y.toolCallCount++,x.debug("Tool call received",{traceId:e,toolCallId:f,toolName:C,argumentsLength:h.length,isComplete:U(h)}),d.push({type:"tool-input-start",id:f,toolName:C}),h&&d.push({type:"tool-input-delta",id:f,delta:h}));let W=U(S.function.arguments);!S.hasFinished&&W&&(x.debug("Tool call arguments complete",{traceId:e,toolCallId:f,toolName:C,isComplete:W,argumentsLength:S.function.arguments.length}),d.push({type:"tool-input-end",id:f}),d.push({type:"tool-call",toolCallId:f,toolName:C,input:S.function.arguments}),S.hasFinished=!0);}j(),y&&(y.eventCount+=d.length);}if(v.message?.content){let k=v.message.content;for(p+=k;p.length>0;)if(N){let f=p.indexOf("</think>");if(f===-1){p.length>0&&d.push({type:"reasoning-delta",id:"reasoning-0",delta:p}),p="";break}else {if(f>0){let C=p.substring(0,f);d.push({type:"reasoning-delta",id:"reasoning-0",delta:C});}d.push({type:"reasoning-end",id:"reasoning-0"}),L=!1,N=!1,p=p.substring(f+8);}}else {let f=p.indexOf("<think>");if(f===-1){p.length>0&&(M||(M=!0,d.push({type:"text-start",id:"txt-0"})),d.push({type:"text-delta",id:"txt-0",delta:p}),E+=p),p="";break}else {if(f>0){let C=p.substring(0,f);M||(M=!0,d.push({type:"text-start",id:"txt-0"})),d.push({type:"text-delta",id:"txt-0",delta:C}),E+=C,d.push({type:"text-end",id:"txt-0"}),M=!1;}N=!0,p=p.substring(f+7),L||(L=!0,d.push({type:"reasoning-start",id:"reasoning-0"}));}}}if(j(),y&&(y.eventCount+=d.length),v.done){let k=P.filter(h=>!h.hasFinished);for(let h of k)d.push({type:"tool-input-end",id:h.id}),d.push({type:"tool-call",toolCallId:h.id,toolName:h.function.name,input:h.function.arguments});p.length>0&&(N?(d.push({type:"reasoning-delta",id:"reasoning-0",delta:p}),d.push({type:"reasoning-end",id:"reasoning-0"})):(M||(M=!0,d.push({type:"text-start",id:"txt-0"})),d.push({type:"text-delta",id:"txt-0",delta:p}),E+=p)),M&&d.push({type:"text-end",id:"txt-0"});let C=P.length>0?"tool-calls":"stop";if(d.push({type:"finish",finishReason:C,usage:{inputTokens:{total:v.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:v.eval_count||0,text:void 0,reasoning:void 0}},providerMetadata:{ollama:{totalDuration:v.total_duration||0,loadDuration:v.load_duration||0,promptEvalDuration:v.prompt_eval_duration||0,evalDuration:v.eval_duration||0}}}),j(),y&&(y.eventCount+=d.length),y);P.length=0;}}}catch(m){x.error("Stream processing error",{traceId:e,error:m instanceof Error?m.message:String(m),stack:void 0}),u({type:"error",error:m instanceof Error?m.message:String(m)}),u({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{l&&l.close(),c&&c.close();}},O=new ReadableStream({start(m){l=m;}}),i=new ReadableStream({start(m){c=m;}});b();async function*g(m){let M=m.getReader();try{for(;;){let{done:L,value:E}=await M.read();if(L)break;yield E;}}finally{M.releaseLock();}}return {stream:O,fullStream:g(i),request:{body:n},response:{}}}async doGenerate(t){let e=V();x.debug("Generate request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let o=Z(t.prompt),a=Y({tools:t.tools}),n=await this.client.chat({model:this.modelId,messages:o,options:w,...a}),l=[];if(n.message?.content&&l.push({type:"text",text:n.message.content}),n.message?.tool_calls){x.debug("Tool calls received in generate",{traceId:e,toolCallCount:n.message.tool_calls.length});for(let b of n.message.tool_calls){let O=b.id||V(),i=b.function.name,g=K(b.function.arguments);x.debug("Processing tool call in generate",{traceId:e,toolCallId:O,toolName:i,argumentsLength:g.length,isComplete:U(g)}),l.push({type:"tool-call",toolCallId:O,toolName:i,input:g});}}let c=!!(n.message?.tool_calls&&n.message.tool_calls.length>0),u=Q(n.done??false,c,"stop");return x.debug("Generate request completed",{traceId:e,finishReason:u,contentParts:l.length,hasToolCalls:c,inputTokens:n.prompt_eval_count||0,outputTokens:n.eval_count||0}),{content:l,finishReason:u,usage:{inputTokens:{total:n.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:n.eval_count||0,text:void 0,reasoning:void 0}},providerMetadata:{ollama:{totalDuration:n.total_duration||0,loadDuration:n.load_duration||0,promptEvalDuration:n.prompt_eval_duration||0,evalDuration:n.eval_duration||0}},request:{body:JSON.stringify({model:this.modelId,messages:o,options:w,...a})},response:{}}}};var I=class{constructor(t,e={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"defaultObjectGenerationMode","json");r(this,"supportedUrls",{});r(this,"nativeModel");this.modelId=t,this.nativeModel=new F(t,{baseURL:e.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 A=class{constructor(t,e={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"maxEmbeddingsPerCall");r(this,"supportsParallelCalls",true);r(this,"baseURL");this.modelId=t,this.baseURL=e.baseURL||"http://localhost:11434";}async doEmbed(t){let{values:e,abortSignal:o}=t,a=utils.Log.create({service:"ollama-embedding"});if(!e||e.length===0)return a.warn("Empty values array provided",{modelId:this.modelId}),{embeddings:[],usage:{tokens:0},warnings:[]};a.debug("Generating text embeddings",{modelId:this.modelId,valuesCount:e.length,baseURL:this.baseURL});try{let n=await Promise.all(e.map(c=>this.generateSingleEmbedding(c,o))),l=e.reduce((c,u)=>c+this.estimateTokens(u),0);return a.debug("Text embeddings generated successfully",{modelId:this.modelId,embeddingsCount:n.length,totalTokens:l}),{embeddings:n,usage:{tokens:l},warnings:[]}}catch(n){throw a.error("Text embedding generation failed",{modelId:this.modelId,error:n instanceof Error?n.message:String(n),stack:void 0}),n}}async generateSingleEmbedding(t,e){let o=`${this.baseURL}/api/embeddings`;try{let a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:this.modelId,prompt:t}),signal:e});if(!a.ok){let l=await a.text();throw new Error(`Ollama embedding API error (${a.status}): ${l}`)}let n=await a.json();if(!n.embedding||!Array.isArray(n.embedding))throw new Error("Invalid response format from Ollama embedding API");return n.embedding}catch(a){throw a instanceof TypeError&&a.message.includes("fetch")?new Error(`Failed to connect to Ollama server at ${this.baseURL}: ${a.message}`):a}}estimateTokens(t){let e=t.match(/[a-zA-Z]/g)?.length||0,o=t.match(/[\u4e00-\u9fa5]/g)?.length||0,a=t.length-e-o;return Math.ceil(e/4)+o+Math.ceil(a*.5)}};var q=class{constructor(t,e,o={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"languageModel");r(this,"options");r(this,"log",utils.Log.create({service:"ollama-sdk",module:"reranking-model"}));this.modelId=t,this.languageModel=new I(t,e),this.options={totalScore:o.totalScore??1,useEnhancedPrompt:o.useEnhancedPrompt??true,promptLanguage:o.promptLanguage??"en"},this.log.debug("OllamaRerankingModel created",{modelId:t,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(t){let{query:e,documents:o,topN:a}=t,n;Array.isArray(o)?n=o:o.type==="text"?n=o.values.map((u,b)=>({content:u,id:`doc_${b+1}`})):n=o.values;let l=a??n.length;if(n.length===0)return {ranking:[],warnings:[]};try{let u=this.buildRerankPrompt(e,n),O=(await this.languageModel.doGenerate({prompt:[{role:"user",content:[{type:"text",text:u}]}],maxOutputTokens:500,temperature:.1})).content.find(g=>g.type==="text")?.text||"",i=this.parseRerankResult(O,n,l);return {ranking:i.results.map(g=>({index:g.index,relevanceScore:g.score,document:g.document})),warnings:i.warnings.map(g=>({type:"other",message:g}))}}catch(u){return this.log.error("Reranking failed",{error:u.message}),{ranking:n.map((O,i)=>({index:i,relevanceScore:this.options.totalScore*(1-i/n.length),document:O})),warnings:[{type:"other",message:`Reranking failed, using original order: ${u.message}`}]}}}buildRerankPrompt(t,e){let o=e.map((a,n)=>{let l=a.id||`doc_${n+1}`,c=a.content.slice(0,300);return `${n+1}. [ID: ${l}] ${c}`}).join(`
7
4
 
8
5
  `);if(this.options.promptLanguage==="en")return `You are a professional information retrieval reranking expert. Please rank the following documents according to the query.
9
6
 
10
7
  User query: ${t}
11
8
 
12
9
  Documents to rank:
13
- ${i}
10
+ ${o}
14
11
 
15
12
  Please rank the documents according to the following requirements:
16
13
  1. Carefully analyze the user's query intent and key information needs
@@ -27,12 +24,12 @@ The actual score for each position should be calculated dynamically. For example
27
24
 
28
25
  Example output format: 2,5,1,4,3
29
26
 
30
- Please only output the ranked document numbers separated by commas, do not include the actual scores.`;{let n=this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u4FE1\u606F\u68C0\u7D22\u91CD\u6392\u5E8F\u4E13\u5BB6\u3002\u8BF7\u6839\u636E\u7528\u6237\u67E5\u8BE2\u5BF9\u6587\u6863\u8FDB\u884C\u76F8\u5173\u6027\u6392\u5E8F\u3002
27
+ Please only output the ranked document numbers separated by commas, do not include the actual scores.`;{let a=this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u4FE1\u606F\u68C0\u7D22\u91CD\u6392\u5E8F\u4E13\u5BB6\u3002\u8BF7\u6839\u636E\u7528\u6237\u67E5\u8BE2\u5BF9\u6587\u6863\u8FDB\u884C\u76F8\u5173\u6027\u6392\u5E8F\u3002
31
28
 
32
29
  \u7528\u6237\u67E5\u8BE2\uFF1A${t}
33
30
 
34
31
  \u5F85\u6392\u5E8F\u6587\u6863\uFF1A
35
- ${i}
32
+ ${o}
36
33
 
37
34
  \u8BF7\u6309\u7167\u4EE5\u4E0B\u8981\u6C42\u8FDB\u884C\u6392\u5E8F\uFF1A
38
35
  1. \u4ED4\u7EC6\u5206\u6790\u7528\u6237\u67E5\u8BE2\u7684\u610F\u56FE\u548C\u5173\u952E\u4FE1\u606F\u9700\u6C42
@@ -40,9 +37,8 @@ ${i}
40
37
  3. \u8003\u8651\u6587\u6863\u7684\u5B8C\u6574\u6027\u3001\u51C6\u786E\u6027\u548C\u5B9E\u7528\u6027
41
38
  4. \u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u6587\u6863\u7F16\u53F7\uFF0C\u7528\u9017\u53F7\u5206\u9694
42
39
  5. \u6700\u76F8\u5173\u7684\u6587\u6863\u6392\u5728\u6700\u524D\u9762
43
- 6. \u8BF7\u4F7F\u7528 ${n} \u5206\u503C\u8FDB\u884C\u8BC4\u5206
40
+ 6. \u8BF7\u4F7F\u7528 ${a} \u5206\u503C\u8FDB\u884C\u8BC4\u5206
44
41
 
45
42
  \u793A\u4F8B\u8F93\u51FA\u683C\u5F0F\uFF1A2,5,1,4,3
46
43
 
47
- \u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}}parseRerankResult(t,e,i){let n=[];try{let o=t.match(/\d+/g)?.map(u=>parseInt(u,10)-1).filter(u=>u>=0&&u<e.length)||[],a=[],l=new Set;for(let u of o)l.has(u)||(l.add(u),a.push(u));let h=[];for(let u=0;u<a.length;u++){let m=a[u];if(m!==void 0&&m>=0&&m<e.length){let w=e[m];w&&h.push({index:m,score:this.options.totalScore*(1-u/a.length),document:w});}}let d=new Set(a);for(let u=0;u<e.length;u++)if(!d.has(u)){let m=this.options.totalScore*.1*(1-u/e.length);h.push({index:u,score:m,document:e[u]});}let f=i?h.slice(0,i):h;return this.log.debug("Parsed rerank results",{extractedNumbers:o,uniqueIndices:a,resultCount:f.length,topK:i}),{results:f,warnings:n}}catch(o){return this.log.error("Failed to parse rerank result",{error:o.message,text:t}),{results:e.map((l,h)=>({index:h,score:this.options.totalScore*(1-h/e.length),document:l})),warnings:[`Failed to parse rerank result: ${o.message}`]}}}};function ja(s={}){if(s.logDir){let e=s.logLevel??"INFO",i=ri__default.default.join(s.logDir,"ollama-sdk.log");Dt.init({print:process.argv.includes("--print-logs"),logDir:s.logDir,level:e,logFile:"ollama-sdk.log"}).then(()=>{Dt.create({service:"ollama-sdk",module:"provider"}).debug("Ollama provider created",{baseURL:s.baseURL||"http://localhost:11434",logFile:i,logLevel:e});});}return Object.assign(e=>new Qt(e,s),{languageModel:e=>new Qt(e,s),chat:e=>new Qt(e,s),embeddingModel:e=>new _s(e,s),rerankingModel:(e,i)=>new li(e,s,i)})}var Wa="0.1.0";
48
- exports.ConnectionError=ui;exports.ModelNotFoundError=di;exports.OLLAMA_DEFAULT_OPTIONS=Te;exports.OLLAMA_SPECIFIC_PARAMS=Dn;exports.OllamaEmbeddingModel=_s;exports.OllamaError=te;exports.OllamaLanguageModel=Qt;exports.TimeoutError=fi;exports.VERSION=Wa;exports.ValidationError=pi;exports.createOllama=ja;
44
+ \u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}}parseRerankResult(t,e,o){let a=[];try{let n=t.match(/\d+/g)?.map(i=>parseInt(i,10)-1).filter(i=>i>=0&&i<e.length)||[],l=[],c=new Set;for(let i of n)c.has(i)||(c.add(i),l.push(i));let u=[];for(let i=0;i<l.length;i++){let g=l[i];if(g!==void 0&&g>=0&&g<e.length){let m=e[g];m&&u.push({index:g,score:this.options.totalScore*(1-i/l.length),document:m});}}let b=new Set(l);for(let i=0;i<e.length;i++)if(!b.has(i)){let g=this.options.totalScore*.1*(1-i/e.length);u.push({index:i,score:g,document:e[i]});}let O=o?u.slice(0,o):u;return this.log.debug("Parsed rerank results",{extractedNumbers:n,uniqueIndices:l,resultCount:O.length,topK:o}),{results:O,warnings:a}}catch(n){return this.log.error("Failed to parse rerank result",{error:n.message,text:t}),{results:e.map((c,u)=>({index:u,score:this.options.totalScore*(1-u/e.length),document:c})),warnings:[`Failed to parse rerank result: ${n.message}`]}}}};function ae(s={}){return Object.assign(e=>new I(e,s),{languageModel:e=>new I(e,s),chat:e=>new I(e,s),embeddingModel:e=>new A(e,s),rerankingModel:(e,o)=>new q(e,s,o)})}var re="0.1.0";exports.ConnectionError=J;exports.ModelNotFoundError=G;exports.OLLAMA_DEFAULT_OPTIONS=w;exports.OLLAMA_SPECIFIC_PARAMS=ee;exports.OllamaEmbeddingModel=A;exports.OllamaError=_;exports.OllamaLanguageModel=I;exports.TimeoutError=B;exports.VERSION=re;exports.ValidationError=z;exports.createOllama=ae;
package/dist/index.mjs CHANGED
@@ -1,16 +1,13 @@
1
- import ni,{win32,posix}from'path';import Ln,{realpath,readlink,readdir,lstat}from'fs/promises';import*as Qo from'fs';import {realpathSync,createWriteStream,readlinkSync,readdirSync,readdir as readdir$1,lstatSync}from'fs';import Da from'zod';import {fileURLToPath}from'url';import {EventEmitter}from'events';import en from'stream';import {StringDecoder}from'string_decoder';import {formatLogTime}from'@easbot/utils';var In=Object.defineProperty;var Gi=s=>{throw TypeError(s)};var Dn=(s,t,e)=>t in s?In(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e;var c=(s,t,e)=>Dn(s,typeof t!="symbol"?t+"":t,e),ui=(s,t,e)=>t.has(s)||Gi("Cannot "+e);var r=(s,t,e)=>(ui(s,t,"read from private field"),e?e.call(s):t.get(s)),y=(s,t,e)=>t.has(s)?Gi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),p=(s,t,e,i)=>(ui(s,t,"write to private field"),t.set(s,e),e),g=(s,t,e)=>(ui(s,t,"access private method"),e);var Fs=(s,t,e,i)=>({set _(n){p(s,t,n);},get _(){return r(s,t,i)}});var Is=class{constructor(t="http://localhost:11434"){c(this,"baseURL",t);}async*streamChat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:true})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);if(!e.body)throw new Error("Response body is null");let i=e.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 d of h){let f=d.trim();if(f)try{yield JSON.parse(f);}catch{}}}}finally{i.releaseLock();}}async chat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);return e.json()}};var _e={numCtx:262144,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},Nn=["numCtx","repeatPenalty","numPredict"];var ee=class extends Error{constructor(e,i){super(e);c(this,"cause",i);this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},di=class extends ee{constructor(e,i,n){super(e,n);c(this,"url",i);this.name="ConnectionError";}},pi=class extends ee{constructor(e,i){super(`Model not found: ${e}`,i);c(this,"modelId",e);this.name="ModelNotFoundError";}},fi=class extends ee{constructor(e,i,n,o){super(e,o);c(this,"field",i);c(this,"value",n);this.name="ValidationError";}},gi=class extends ee{constructor(e,i,n){super(e,n);c(this,"timeoutMs",i);this.name="TimeoutError";}},Ze=class extends ee{constructor(e,i,n){super(`Invalid tool definition for "${e}": missing ${i}`,n);c(this,"toolName",e);c(this,"missingField",i);this.name="InvalidToolDefinitionError";}};var Nr=(s,t,e)=>{let i=s instanceof RegExp?Vi(s,e):s,n=t instanceof RegExp?Vi(t,e):t,o=i!==null&&n!=null&&jn(i,n,e);return o&&{start:o[0],end:o[1],pre:e.slice(0,o[0]),body:e.slice(o[0]+i.length,o[1]),post:e.slice(o[1]+n.length)}},Vi=(s,t)=>{let e=t.match(s);return e?e[0]:null},jn=(s,t,e)=>{let i,n,o,a,l,h=e.indexOf(s),d=e.indexOf(t,h+1),f=h;if(h>=0&&d>0){if(s===t)return [h,d];for(i=[],o=e.length;f>=0&&!l;){if(f===h)i.push(f),h=e.indexOf(s,f+1);else if(i.length===1){let u=i.pop();u!==void 0&&(l=[u,d]);}else n=i.pop(),n!==void 0&&n<o&&(o=n,a=d),d=e.indexOf(t,f+1);f=h<d&&h>=0?h:d;}i.length&&a!==void 0&&(l=[o,a]);}return l},jr="\0SLASH"+Math.random()+"\0",Wr="\0OPEN"+Math.random()+"\0",ji="\0CLOSE"+Math.random()+"\0",$r="\0COMMA"+Math.random()+"\0",zr="\0PERIOD"+Math.random()+"\0",Wn=new RegExp(jr,"g"),$n=new RegExp(Wr,"g"),zn=new RegExp(ji,"g"),Un=new RegExp($r,"g"),Bn=new RegExp(zr,"g"),Gn=/\\\\/g,Vn=/\\{/g,qn=/\\}/g,Jn=/\\,/g,Hn=/\\./g,Zn=1e5;function mi(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function Kn(s){return s.replace(Gn,jr).replace(Vn,Wr).replace(qn,ji).replace(Jn,$r).replace(Hn,zr)}function Yn(s){return s.replace(Wn,"\\").replace($n,"{").replace(zn,"}").replace(Un,",").replace(Bn,".")}function Ur(s){if(!s)return [""];let t=[],e=Nr("{","}",s);if(!e)return s.split(",");let{pre:i,body:n,post:o}=e,a=i.split(",");a[a.length-1]+="{"+n+"}";let l=Ur(o);return o.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),t.push.apply(t,a),t}function Qn(s,t={}){if(!s)return [];let{max:e=Zn}=t;return s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),ss(Kn(s),e,true).map(Yn)}function Xn(s){return "{"+s+"}"}function to(s){return /^-?0\d/.test(s)}function eo(s,t){return s<=t}function so(s,t){return s>=t}function ss(s,t,e){let i=[],n=Nr("{","}",s);if(!n)return [s];let o=n.pre,a=n.post.length?ss(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(/,(?!,).*\}/)?(s=n.pre+"{"+n.body+ji+n.post,ss(s,t,true)):[s];let u;if(d)u=n.body.split(/\.\./);else if(u=Ur(n.body),u.length===1&&u[0]!==void 0&&(u=ss(u[0],t,false).map(Xn),u.length===1))return a.map(w=>n.pre+u[0]+w);let m;if(d&&u[0]!==void 0&&u[1]!==void 0){let w=mi(u[0]),v=mi(u[1]),S=Math.max(u[0].length,u[1].length),k=u.length===3&&u[2]!==void 0?Math.abs(mi(u[2])):1,b=eo;v<w&&(k*=-1,b=so);let R=u.some(to);m=[];for(let M=w;b(M,v);M+=k){let E;if(h)E=String.fromCharCode(M),E==="\\"&&(E="");else if(E=String(M),R){let F=S-E.length;if(F>0){let I=new Array(F+1).join("0");M<0?E="-"+I+E.slice(1):E=I+E;}}m.push(E);}}else {m=[];for(let w=0;w<u.length;w++)m.push.apply(m,ss(u[w],t,false));}for(let w=0;w<m.length;w++)for(let v=0;v<a.length&&i.length<t;v++){let S=o+m[w]+a[v];(!e||d||S)&&i.push(S);}}return i}var Qs=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>65536)throw new TypeError("pattern is too long")},io={"[: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]},Ke=s=>s.replace(/[[\]\\-]/g,"\\$&"),ro=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),qi=s=>s.join(""),no=(s,t)=>{let e=t;if(s.charAt(e)!=="[")throw new Error("not in a brace expression");let i=[],n=[],o=e+1,a=false,l=false,h=false,d=false,f=e,u="";t:for(;o<s.length;){let v=s.charAt(o);if((v==="!"||v==="^")&&o===e+1){d=true,o++;continue}if(v==="]"&&a&&!h){f=o+1;break}if(a=true,v==="\\"&&!h){h=true,o++;continue}if(v==="["&&!h){for(let[S,[k,b,R]]of Object.entries(io))if(s.startsWith(S,o)){if(u)return ["$.",false,s.length-e,true];o+=S.length,R?n.push(k):i.push(k),l=l||b;continue t}}if(h=false,u){v>u?i.push(Ke(u)+"-"+Ke(v)):v===u&&i.push(Ke(v)),u="",o++;continue}if(s.startsWith("-]",o+1)){i.push(Ke(v+"-")),o+=2;continue}if(s.startsWith("-",o+1)){u=v,o+=2;continue}i.push(Ke(v)),o++;}if(f<o)return ["",false,0,false];if(!i.length&&!n.length)return ["$.",false,s.length-e,true];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!d){let v=i[0].length===2?i[0].slice(-1):i[0];return [ro(v),false,f-e,false]}let m="["+(d?"^":"")+qi(i)+"]",w="["+(d?"":"^")+qi(n)+"]";return [i.length&&n.length?"("+m+"|"+w+")":i.length?m:w,l,f-e,true]},Ie=(s,{windowsPathsNoEscape:t=false,magicalBraces:e=true}={})=>e?t?s.replace(/\[([^\/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?s.replace(/\[([^\/\\{}])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),oo=new Set(["!","?","+","*","@"]),Ji=s=>oo.has(s),ao="(?!(?:^|/)\\.\\.?(?:$|/))",Ds="(?!\\.)",lo=new Set(["[","."]),ho=new Set(["..","."]),co=new Set("().*{}+?[]^$\\!"),uo=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Wi="[^/]",Hi=Wi+"*?",Zi=Wi+"+?",G,Y,qt,W,U,ae,be,le,$t,ve,hs,Le,Gr,fe,tt,Gs,Ei,Vr,Br=(tt=class{constructor(t,e,i={}){y(this,Le);c(this,"type");y(this,G);y(this,Y);y(this,qt,false);y(this,W,[]);y(this,U);y(this,ae);y(this,be);y(this,le,false);y(this,$t);y(this,ve);y(this,hs,false);this.type=t,t&&p(this,Y,true),p(this,U,e),p(this,G,r(this,U)?r(r(this,U),G):this),p(this,$t,r(this,G)===this?i:r(r(this,G),$t)),p(this,be,r(this,G)===this?[]:r(r(this,G),be)),t==="!"&&!r(r(this,G),le)&&r(this,be).push(this),p(this,ae,r(this,U)?r(r(this,U),W).length:0);}get hasMagic(){if(r(this,Y)!==void 0)return r(this,Y);for(let t of r(this,W))if(typeof t!="string"&&(t.type||t.hasMagic))return p(this,Y,true);return r(this,Y)}toString(){return r(this,ve)!==void 0?r(this,ve):this.type?p(this,ve,this.type+"("+r(this,W).map(t=>String(t)).join("|")+")"):p(this,ve,r(this,W).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof tt&&r(e,U)===this))throw new Error("invalid part: "+e);r(this,W).push(e);}}toJSON(){let t=this.type===null?r(this,W).slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...r(this,W).map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,G)||r(r(this,G),le)&&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,ae)===0)return true;let t=r(this,U);for(let e=0;e<r(this,ae);e++){let i=r(t,W)[e];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),W).length:0;return r(this,ae)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this));}clone(t){let e=new tt(this.type,t);for(let i of r(this,W))e.copyIn(i);return e}static fromGlob(t,e={}){var n;let i=new tt(null,void 0,e);return g(n=tt,fe,Gs).call(n,t,i,0,e),i}toMMPattern(){if(this!==r(this,G))return r(this,G).toMMPattern();let t=this.toString(),[e,i,n,o]=this.toRegExpSource();if(!(n||r(this,Y)||r(this,$t).nocase&&!r(this,$t).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(r(this,$t).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return r(this,$t)}toRegExpSource(t){let e=t??!!r(this,$t).dot;if(r(this,G)===this&&g(this,Le,Gr).call(this),!this.type){let h=this.isStart()&&this.isEnd()&&!r(this,W).some(m=>typeof m!="string"),d=r(this,W).map(m=>{var b;let[w,v,S,k]=typeof m=="string"?g(b=tt,fe,Vr).call(b,m,r(this,Y),h):m.toRegExpSource(t);return p(this,Y,r(this,Y)||S),p(this,qt,r(this,qt)||k),w}).join(""),f="";if(this.isStart()&&typeof r(this,W)[0]=="string"&&!(r(this,W).length===1&&ho.has(r(this,W)[0]))){let m=lo,w=e&&m.has(d.charAt(0))||d.startsWith("\\.")&&m.has(d.charAt(2))||d.startsWith("\\.\\.")&&m.has(d.charAt(4)),v=!e&&!t&&m.has(d.charAt(0));f=w?ao:v?Ds:"";}let u="";return this.isEnd()&&r(r(this,G),le)&&r(this,U)?.type==="!"&&(u="(?:$|\\/)"),[f+d+u,Ie(d),p(this,Y,!!r(this,Y)),r(this,qt)]}let i=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=g(this,Le,Ei).call(this,e);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let h=this.toString();return p(this,W,[h]),this.type=null,p(this,Y,void 0),[h,Ie(this.toString()),false,false]}let a=!i||t||e||!Ds?"":g(this,Le,Ei).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let l="";if(this.type==="!"&&r(this,hs))l=(this.isStart()&&!e?Ds:"")+Zi;else {let h=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Ds:"")+Hi+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;l=n+o+h;}return [l,Ie(o),p(this,Y,!!r(this,Y)),r(this,qt)]}},G=new WeakMap,Y=new WeakMap,qt=new WeakMap,W=new WeakMap,U=new WeakMap,ae=new WeakMap,be=new WeakMap,le=new WeakMap,$t=new WeakMap,ve=new WeakMap,hs=new WeakMap,Le=new WeakSet,Gr=function(){if(this!==r(this,G))throw new Error("should only call on root");if(r(this,le))return this;this.toString(),p(this,le,true);let t;for(;t=r(this,be).pop();){if(t.type!=="!")continue;let e=t,i=r(e,U);for(;i;){for(let n=r(e,ae)+1;!i.type&&n<r(i,W).length;n++)for(let o of r(t,W)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r(i,W)[n]);}e=i,i=r(e,U);}}return this},fe=new WeakSet,Gs=function(t,e,i,n){var w,v;let o=false,a=false,l=-1,h=false;if(e.type===null){let S=i,k="";for(;S<t.length;){let b=t.charAt(S++);if(o||b==="\\"){o=!o,k+=b;continue}if(a){S===l+1?(b==="^"||b==="!")&&(h=true):b==="]"&&!(S===l+2&&h)&&(a=false),k+=b;continue}else if(b==="["){a=true,l=S,h=false,k+=b;continue}if(!n.noext&&Ji(b)&&t.charAt(S)==="("){e.push(k),k="";let R=new tt(b,e);S=g(w=tt,fe,Gs).call(w,t,R,S,n),e.push(R);continue}k+=b;}return e.push(k),S}let d=i+1,f=new tt(null,e),u=[],m="";for(;d<t.length;){let S=t.charAt(d++);if(o||S==="\\"){o=!o,m+=S;continue}if(a){d===l+1?(S==="^"||S==="!")&&(h=true):S==="]"&&!(d===l+2&&h)&&(a=false),m+=S;continue}else if(S==="["){a=true,l=d,h=false,m+=S;continue}if(Ji(S)&&t.charAt(d)==="("){f.push(m),m="";let k=new tt(S,f);f.push(k),d=g(v=tt,fe,Gs).call(v,t,k,d,n);continue}if(S==="|"){f.push(m),m="",u.push(f),f=new tt(null,e);continue}if(S===")")return m===""&&r(e,W).length===0&&p(e,hs,true),f.push(m),m="",e.push(...u,f),d;m+=S;}return e.type=null,p(e,Y,void 0),p(e,W,[t.substring(i-1)]),d},Ei=function(t){return r(this,W).map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[i,n,o,a]=e.toRegExpSource(t);return p(this,qt,r(this,qt)||a),i}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},Vr=function(t,e,i=false){let n=false,o="",a=false,l=false;for(let h=0;h<t.length;h++){let d=t.charAt(h);if(n){n=false,o+=(co.has(d)?"\\":"")+d;continue}if(d==="*"){if(l)continue;l=true,o+=i&&/^[*]+$/.test(t)?Zi:Hi,e=true;continue}else l=false;if(d==="\\"){h===t.length-1?o+="\\\\":n=true;continue}if(d==="["){let[f,u,m,w]=no(t,h);if(m){o+=f,a=a||u,h+=m-1,e=e||w;continue}}if(d==="?"){o+=Wi,e=true;continue}o+=uo(d);}return [o,Ie(t),!!e,a]},y(tt,fe),tt),qr=(s,{windowsPathsNoEscape:t=false,magicalBraces:e=false}={})=>e?t?s.replace(/[?*()[\]{}]/g,"[$&]"):s.replace(/[?*()[\]\\{}]/g,"\\$&"):t?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&"),lt=(s,t,e={})=>(Qs(t),!e.nocomment&&t.charAt(0)==="#"?false:new ge(t,e).match(s)),po=/^\*+([^+@!?\*\[\(]*)$/,fo=s=>t=>!t.startsWith(".")&&t.endsWith(s),go=s=>t=>t.endsWith(s),mo=s=>(s=s.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(s)),yo=s=>(s=s.toLowerCase(),t=>t.toLowerCase().endsWith(s)),wo=/^\*+\.\*+$/,bo=s=>!s.startsWith(".")&&s.includes("."),vo=s=>s!=="."&&s!==".."&&s.includes("."),So=/^\.\*+$/,xo=s=>s!=="."&&s!==".."&&s.startsWith("."),ko=/^\*+$/,Eo=s=>s.length!==0&&!s.startsWith("."),Oo=s=>s.length!==0&&s!=="."&&s!=="..",Co=/^\?+([^+@!?\*\[\(]*)?$/,Ro=([s,t=""])=>{let e=Jr([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Mo=([s,t=""])=>{let e=Hr([s]);return t?(t=t.toLowerCase(),i=>e(i)&&i.toLowerCase().endsWith(t)):e},Lo=([s,t=""])=>{let e=Hr([s]);return t?i=>e(i)&&i.endsWith(t):e},Ao=([s,t=""])=>{let e=Jr([s]);return t?i=>e(i)&&i.endsWith(t):e},Jr=([s])=>{let t=s.length;return e=>e.length===t&&!e.startsWith(".")},Hr=([s])=>{let t=s.length;return e=>e.length===t&&e!=="."&&e!==".."},Zr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ki={win32:{sep:"\\"},posix:{sep:"/"}},To=Zr==="win32"?Ki.win32.sep:Ki.posix.sep;lt.sep=To;var at=Symbol("globstar **");lt.GLOBSTAR=at;var _o="[^/]",Po=_o+"*?",Fo="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Io="(?:(?!(?:\\/|^)\\.).)*?",Do=(s,t={})=>e=>lt(e,s,t);lt.filter=Do;var bt=(s,t={})=>Object.assign({},s,t),No=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return lt;let t=lt;return Object.assign((e,i,n={})=>t(e,i,bt(s,n)),{Minimatch:class extends t.Minimatch{constructor(e,i={}){super(e,bt(s,i));}static defaults(e){return t.defaults(bt(s,e)).Minimatch}},AST:class extends t.AST{constructor(e,i,n={}){super(e,i,bt(s,n));}static fromGlob(e,i={}){return t.AST.fromGlob(e,bt(s,i))}},unescape:(e,i={})=>t.unescape(e,bt(s,i)),escape:(e,i={})=>t.escape(e,bt(s,i)),filter:(e,i={})=>t.filter(e,bt(s,i)),defaults:e=>t.defaults(bt(s,e)),makeRe:(e,i={})=>t.makeRe(e,bt(s,i)),braceExpand:(e,i={})=>t.braceExpand(e,bt(s,i)),match:(e,i,n={})=>t.match(e,i,bt(s,n)),sep:t.sep,GLOBSTAR:at})};lt.defaults=No;var Kr=(s,t={})=>(Qs(s),t.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:Qn(s,{max:t.braceExpandMax}));lt.braceExpand=Kr;var jo=(s,t={})=>new ge(s,t).makeRe();lt.makeRe=jo;var Wo=(s,t,e={})=>{let i=new ge(t,e);return s=s.filter(n=>i.match(n)),i.options.nonull&&!s.length&&s.push(t),s};lt.match=Wo;var Yi=/[?*]|[+@!]\(.*?\)|\[|\]/,$o=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ge=class{constructor(s,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");Qs(s),t=t||{},this.options=t,this.pattern=s,this.platform=t.platform||Zr,this.isWindows=this.platform==="win32";let e="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[e]===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 s of this.set)for(let t of s)if(typeof t!="string")return true;return false}debug(...s){}make(){let s=this.pattern,t=this.options;if(!t.nocomment&&s.charAt(0)==="#"){this.comment=true;return}if(!s){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 e=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(e),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]==="?"||!Yi.test(n[2]))&&!Yi.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(s){if(this.options.noglobstar)for(let e=0;e<s.length;e++)for(let i=0;i<s[e].length;i++)s[e][i]==="**"&&(s[e][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(s=this.firstPhasePreProcess(s),s=this.secondPhasePreProcess(s)):t>=1?s=this.levelOneOptimize(s):s=this.adjascentGlobstarOptimize(s),s}adjascentGlobstarOptimize(s){return s.map(t=>{let e=-1;for(;(e=t.indexOf("**",e+1))!==-1;){let i=e;for(;t[i+1]==="**";)i++;i!==e&&t.splice(e,i-e);}return t})}levelOneOptimize(s){return s.map(t=>(t=t.reduce((e,i)=>{let n=e[e.length-1];return i==="**"&&n==="**"?e:i===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(e.pop(),e):(e.push(i),e)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(s){Array.isArray(s)||(s=this.slashSplit(s));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let i=1;i<s.length-1;i++){let n=s[i];i===1&&n===""&&s[0]===""||(n==="."||n==="")&&(t=true,s.splice(i,1),i--);}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=true,s.pop());}let e=0;for(;(e=s.indexOf("..",e+1))!==-1;){let i=s[e-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=true,s.splice(e-1,2),e-=2);}}while(t);return s.length===0?[""]:s}firstPhasePreProcess(s){let t=false;do{t=false;for(let e of s){let i=-1;for(;(i=e.indexOf("**",i+1))!==-1;){let o=i;for(;e[o+1]==="**";)o++;o>i&&e.splice(i+1,o-i);let a=e[i+1],l=e[i+2],h=e[i+3];if(a!==".."||!l||l==="."||l===".."||!h||h==="."||h==="..")continue;t=true,e.splice(i,1);let d=e.slice(0);d[i]="**",s.push(d),i--;}if(!this.preserveMultipleSlashes){for(let o=1;o<e.length-1;o++){let a=e[o];o===1&&a===""&&e[0]===""||(a==="."||a==="")&&(t=true,e.splice(o,1),o--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=true,e.pop());}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let o=e[n-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=true;let a=n===1&&e[n+1]==="**"?["."]:[];e.splice(n-1,2,...a),e.length===0&&e.push(""),n-=2;}}}}while(t);return s}secondPhasePreProcess(s){for(let t=0;t<s.length-1;t++)for(let e=t+1;e<s.length;e++){let i=this.partsMatch(s[t],s[e],!this.preserveMultipleSlashes);if(i){s[t]=[],s[e]=i;break}}return s.filter(t=>t.length)}partsMatch(s,t,e=false){let i=0,n=0,o=[],a="";for(;i<s.length&&n<t.length;)if(s[i]===t[n])o.push(a==="b"?t[n]:s[i]),i++,n++;else if(e&&s[i]==="**"&&t[n]===s[i+1])o.push(s[i]),i++;else if(e&&t[n]==="**"&&s[i]===t[n+1])o.push(t[n]),n++;else if(s[i]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="b")return false;a="a",o.push(s[i]),i++,n++;}else if(t[n]==="*"&&s[i]&&(this.options.dot||!s[i].startsWith("."))&&s[i]!=="**"){if(a==="a")return false;a="b",o.push(t[n]),i++,n++;}else return false;return s.length===t.length&&o}parseNegate(){if(this.nonegate)return;let s=this.pattern,t=false,e=0;for(let i=0;i<s.length&&s.charAt(i)==="!";i++)t=!t,e++;e&&(this.pattern=s.slice(e)),this.negate=t;}matchOne(s,t,e=false){let i=this.options;if(this.isWindows){let v=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),S=!v&&s[0]===""&&s[1]===""&&s[2]==="?"&&/^[a-z]:$/i.test(s[3]),k=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!k&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),R=S?3:v?0:void 0,M=b?3:k?0:void 0;if(typeof R=="number"&&typeof M=="number"){let[E,F]=[s[R],t[M]];E.toLowerCase()===F.toLowerCase()&&(t[M]=E,M>R?t=t.slice(M):R>M&&(s=s.slice(R)));}}let{optimizationLevel:n=1}=this.options;n>=2&&(s=this.levelTwoFileOptimize(s)),this.debug("matchOne",this,{file:s,pattern:t}),this.debug("matchOne",s.length,t.length);for(var o=0,a=0,l=s.length,h=t.length;o<l&&a<h;o++,a++){this.debug("matchOne loop");var d=t[a],f=s[o];if(this.debug(t,d,f),d===false)return false;if(d===at){this.debug("GLOBSTAR",[t,d,f]);var u=o,m=a+1;if(m===h){for(this.debug("** at the end");o<l;o++)if(s[o]==="."||s[o]===".."||!i.dot&&s[o].charAt(0)===".")return false;return true}for(;u<l;){var w=s[u];if(this.debug(`
3
- globstar while`,s,u,t,m,w),this.matchOne(s.slice(u),t.slice(m),e))return this.debug("globstar found match!",u,l,w),true;if(w==="."||w===".."||!i.dot&&w.charAt(0)==="."){this.debug("dot detected!",s,u,t,m);break}this.debug("globstar swallow a segment, and continue"),u++;}return !!(e&&(this.debug(`
4
- >>> no match, partial?`,s,u,t,m),u===l))}let v;if(typeof d=="string"?(v=f===d,this.debug("string match",d,f,v)):(v=d.test(f),this.debug("pattern match",d,f,v)),!v)return false}if(o===l&&a===h)return true;if(o===l)return e;if(a===h)return o===l-1&&s[o]==="";throw new Error("wtf?")}braceExpand(){return Kr(this.pattern,this.options)}parse(s){Qs(s);let t=this.options;if(s==="**")return at;if(s==="")return "";let e,i=null;(e=s.match(ko))?i=t.dot?Oo:Eo:(e=s.match(po))?i=(t.nocase?t.dot?yo:mo:t.dot?go:fo)(e[1]):(e=s.match(Co))?i=(t.nocase?t.dot?Mo:Ro:t.dot?Lo:Ao)(e):(e=s.match(wo))?i=t.dot?vo:bo:(e=s.match(So))&&(i=xo);let n=Br.fromGlob(s,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 s=this.set;if(!s.length)return this.regexp=false,this.regexp;let t=this.options,e=t.noglobstar?Po:t.dot?Fo:Io,i=new Set(t.nocase?["i"]:[]),n=s.map(l=>{let h=l.map(f=>{if(f instanceof RegExp)for(let u of f.flags.split(""))i.add(u);return typeof f=="string"?$o(f):f===at?at:f._src});h.forEach((f,u)=>{let m=h[u+1],w=h[u-1];f!==at||w===at||(w===void 0?m!==void 0&&m!==at?h[u+1]="(?:\\/|"+e+"\\/)?"+m:h[u]=e:m===void 0?h[u-1]=w+"(?:\\/|\\/"+e+")?":m!==at&&(h[u-1]=w+"(?:\\/|\\/"+e+"\\/)"+m,h[u+1]=at));});let d=h.filter(f=>f!==at);if(this.partial&&d.length>=1){let f=[];for(let u=1;u<=d.length;u++)f.push(d.slice(0,u).join("/"));return "(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=s.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(s){return this.preserveMultipleSlashes?s.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(s)?["",...s.split(/\/+/)]:s.split(/\/+/)}match(s,t=this.partial){if(this.debug("match",s,this.pattern),this.comment)return false;if(this.empty)return s==="";if(s==="/"&&t)return true;let e=this.options;this.isWindows&&(s=s.split("\\").join("/"));let i=this.slashSplit(s);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(e.matchBase&&l.length===1&&(h=[o]),this.matchOne(h,l,t))return e.flipNegate?true:!this.negate}return e.flipNegate?false:this.negate}static defaults(s){return lt.defaults(s).Minimatch}};lt.AST=Br;lt.Minimatch=ge;lt.escape=qr;lt.unescape=Ie;var Uo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Yr=new Set,Oi=typeof process=="object"&&process?process:{},Qr=(s,t,e,i)=>{typeof Oi.emitWarning=="function"?Oi.emitWarning(s,t,e,i):console.error(`[${e}] ${t}: ${s}`);},Xs=globalThis.AbortController,Qi=globalThis.AbortSignal;if(typeof Xs>"u"){Qi=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(e,i){this._onabort.push(i);}},Xs=class{constructor(){c(this,"signal",new Qi);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let i of this.signal._onabort)i(e);this.signal.onabort?.(e);}}};let s=Oi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{s&&(s=false,Qr("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 Bo=s=>!Yr.has(s),ie=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Xr=s=>ie(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Vs:null:null,Vs=class extends Array{constructor(s){super(s),this.fill(0);}},Bt,De,Go=(Bt=class{constructor(t,e){c(this,"heap");c(this,"length");if(!r(Bt,De))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Xr(t);if(!e)return [];p(Bt,De,true);let i=new Bt(t,e);return p(Bt,De,false),i}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},De=new WeakMap,y(Bt,De,false),Bt),pr,fr,St,dt,Mt,Se,Lt,Ne,je,At,V,Tt,B,$,T,rt,pt,st,Q,_t,X,Pt,Ft,ft,gt,It,he,nt,We,x,Ci,xe,Jt,cs,mt,tn,ke,$e,us,re,ne,Ri,qs,Js,j,Mi,is,oe,Li,ze,si=(ze=class{constructor(t){y(this,x);y(this,St);y(this,dt);y(this,Mt);y(this,Se);y(this,Lt);y(this,Ne);y(this,je);y(this,At);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");y(this,V);y(this,Tt);y(this,B);y(this,$);y(this,T);y(this,rt);y(this,pt);y(this,st);y(this,Q);y(this,_t);y(this,X);y(this,Pt);y(this,Ft);y(this,ft);y(this,gt);y(this,It);y(this,he);y(this,nt);y(this,We);y(this,xe,()=>{});y(this,Jt,()=>{});y(this,cs,()=>{});y(this,mt,()=>false);y(this,ke,t=>{});y(this,$e,(t,e,i)=>{});y(this,us,(t,e,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,pr,"LRUCache");let{max:e=0,ttl:i,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:d,onInsert:f,disposeAfter:u,noDisposeOnSet:m,noUpdateTTL:w,maxSize:v=0,maxEntrySize:S=0,sizeCalculation:k,fetchMethod:b,memoMethod:R,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:I,ignoreFetchAbort:O,perf:P}=t;if(P!==void 0&&typeof P?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,At,P??Uo),e!==0&&!ie(e))throw new TypeError("max option must be a nonnegative integer");let A=e?Xr(e):Array;if(!A)throw new Error("invalid max value: "+e);if(p(this,St,e),p(this,dt,v),this.maxEntrySize=S||r(this,dt),this.sizeCalculation=k,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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(p(this,je,R),b!==void 0&&typeof b!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,Ne,b),p(this,he,!!b),p(this,B,new Map),p(this,$,new Array(e).fill(void 0)),p(this,T,new Array(e).fill(void 0)),p(this,rt,new A(e)),p(this,pt,new A(e)),p(this,st,0),p(this,Q,0),p(this,_t,Go.create(e)),p(this,V,0),p(this,Tt,0),typeof d=="function"&&p(this,Mt,d),typeof f=="function"&&p(this,Se,f),typeof u=="function"?(p(this,Lt,u),p(this,X,[])):(p(this,Lt,void 0),p(this,X,void 0)),p(this,It,!!r(this,Mt)),p(this,We,!!r(this,Se)),p(this,nt,!!r(this,Lt)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!I,this.ignoreFetchAbort=!!O,this.maxEntrySize!==0){if(r(this,dt)!==0&&!ie(r(this,dt)))throw new TypeError("maxSize must be a positive integer if specified");if(!ie(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,x,tn).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=ie(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!ie(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,x,Ci).call(this);}if(r(this,St)===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,St)&&!r(this,dt)){let D="LRU_CACHE_UNBOUNDED";Bo(D)&&(Yr.add(D),Qr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",D,ze));}}get perf(){return r(this,At)}static unsafeExposeInternals(t){return {starts:r(t,Ft),ttls:r(t,ft),autopurgeTimers:r(t,gt),sizes:r(t,Pt),keyMap:r(t,B),keyList:r(t,$),valList:r(t,T),next:r(t,rt),prev:r(t,pt),get head(){return r(t,st)},get tail(){return r(t,Q)},free:r(t,_t),isBackgroundFetch:e=>{var i;return g(i=t,x,j).call(i,e)},backgroundFetch:(e,i,n,o)=>{var a;return g(a=t,x,Js).call(a,e,i,n,o)},moveToTail:e=>{var i;return g(i=t,x,is).call(i,e)},indexes:e=>{var i;return g(i=t,x,re).call(i,e)},rindexes:e=>{var i;return g(i=t,x,ne).call(i,e)},isStale:e=>{var i;return r(i=t,mt).call(i,e)}}}get max(){return r(this,St)}get maxSize(){return r(this,dt)}get calculatedSize(){return r(this,Tt)}get size(){return r(this,V)}get fetchMethod(){return r(this,Ne)}get memoMethod(){return r(this,je)}get dispose(){return r(this,Mt)}get onInsert(){return r(this,Se)}get disposeAfter(){return r(this,Lt)}getRemainingTTL(t){return r(this,B).has(t)?1/0:0}*entries(){for(let t of g(this,x,re).call(this))r(this,T)[t]!==void 0&&r(this,$)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield [r(this,$)[t],r(this,T)[t]]);}*rentries(){for(let t of g(this,x,ne).call(this))r(this,T)[t]!==void 0&&r(this,$)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield [r(this,$)[t],r(this,T)[t]]);}*keys(){for(let t of g(this,x,re).call(this)){let e=r(this,$)[t];e!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield e);}}*rkeys(){for(let t of g(this,x,ne).call(this)){let e=r(this,$)[t];e!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield e);}}*values(){for(let t of g(this,x,re).call(this))r(this,T)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield r(this,T)[t]);}*rvalues(){for(let t of g(this,x,ne).call(this))r(this,T)[t]!==void 0&&!g(this,x,j).call(this,r(this,T)[t])&&(yield r(this,T)[t]);}[(fr=Symbol.iterator,pr=Symbol.toStringTag,fr)](){return this.entries()}find(t,e={}){for(let i of g(this,x,re).call(this)){let n=r(this,T)[i],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,r(this,$)[i],this))return this.get(r(this,$)[i],e)}}forEach(t,e=this){for(let i of g(this,x,re).call(this)){let n=r(this,T)[i],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(e,o,r(this,$)[i],this);}}rforEach(t,e=this){for(let i of g(this,x,ne).call(this)){let n=r(this,T)[i],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(e,o,r(this,$)[i],this);}}purgeStale(){let t=false;for(let e of g(this,x,ne).call(this,{allowStale:true}))r(this,mt).call(this,e)&&(g(this,x,oe).call(this,r(this,$)[e],"expire"),t=true);return t}info(t){let e=r(this,B).get(t);if(e===void 0)return;let i=r(this,T)[e],n=g(this,x,j).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let o={value:n};if(r(this,ft)&&r(this,Ft)){let a=r(this,ft)[e],l=r(this,Ft)[e];if(a&&l){let h=a-(r(this,At).now()-l);o.ttl=h,o.start=Date.now();}}return r(this,Pt)&&(o.size=r(this,Pt)[e]),o}dump(){let t=[];for(let e of g(this,x,re).call(this,{allowStale:true})){let i=r(this,$)[e],n=r(this,T)[e],o=g(this,x,j).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||i===void 0)continue;let a={value:o};if(r(this,ft)&&r(this,Ft)){a.ttl=r(this,ft)[e];let l=r(this,At).now()-r(this,Ft)[e];a.start=Math.floor(Date.now()-l);}r(this,Pt)&&(a.size=r(this,Pt)[e]),t.unshift([i,a]);}return t}load(t){this.clear();for(let[e,i]of t){if(i.start){let n=Date.now()-i.start;i.start=r(this,At).now()-n;}this.set(e,i.value,i);}}set(t,e,i={}){var m,w,v,S;if(e===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,us).call(this,t,e,i.size||0,l);if(this.maxEntrySize&&f>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),g(this,x,oe).call(this,t,"set"),this;let u=r(this,V)===0?void 0:r(this,B).get(t);if(u===void 0)u=r(this,V)===0?r(this,Q):r(this,_t).length!==0?r(this,_t).pop():r(this,V)===r(this,St)?g(this,x,qs).call(this,false):r(this,V),r(this,$)[u]=t,r(this,T)[u]=e,r(this,B).set(t,u),r(this,rt)[r(this,Q)]=u,r(this,pt)[u]=r(this,Q),p(this,Q,u),Fs(this,V)._++,r(this,$e).call(this,u,f,h),h&&(h.set="add"),d=false,r(this,We)&&((m=r(this,Se))==null||m.call(this,e,t,"add"));else {g(this,x,is).call(this,u);let k=r(this,T)[u];if(e!==k){if(r(this,he)&&g(this,x,j).call(this,k)){k.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:b}=k;b!==void 0&&!a&&(r(this,It)&&((w=r(this,Mt))==null||w.call(this,b,t,"set")),r(this,nt)&&r(this,X)?.push([b,t,"set"]));}else a||(r(this,It)&&((v=r(this,Mt))==null||v.call(this,k,t,"set")),r(this,nt)&&r(this,X)?.push([k,t,"set"]));if(r(this,ke).call(this,u),r(this,$e).call(this,u,f,h),r(this,T)[u]=e,h){h.set="replace";let b=k&&g(this,x,j).call(this,k)?k.__staleWhileFetching:k;b!==void 0&&(h.oldValue=b);}}else h&&(h.set="update");r(this,We)&&this.onInsert?.(e,t,e===k?"update":"replace");}if(n!==0&&!r(this,ft)&&g(this,x,Ci).call(this),r(this,ft)&&(d||r(this,cs).call(this,u,n,o),h&&r(this,Jt).call(this,h,u)),!a&&r(this,nt)&&r(this,X)){let k=r(this,X),b;for(;b=k?.shift();)(S=r(this,Lt))==null||S.call(this,...b);}return this}pop(){var t;try{for(;r(this,V);){let e=r(this,T)[r(this,st)];if(g(this,x,qs).call(this,!0),g(this,x,j).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(r(this,nt)&&r(this,X)){let e=r(this,X),i;for(;i=e?.shift();)(t=r(this,Lt))==null||t.call(this,...i);}}}has(t,e={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=e,o=r(this,B).get(t);if(o!==void 0){let a=r(this,T)[o];if(g(this,x,j).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,mt).call(this,o))n&&(n.has="stale",r(this,Jt).call(this,n,o));else return i&&r(this,xe).call(this,o),n&&(n.has="hit",r(this,Jt).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,e={}){let{allowStale:i=this.allowStale}=e,n=r(this,B).get(t);if(n===void 0||!i&&r(this,mt).call(this,n))return;let o=r(this,T)[n];return g(this,x,j).call(this,o)?o.__staleWhileFetching:o}async fetch(t,e={}){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:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:S,forceRefresh:k=false,status:b,signal:R}=e;if(!r(this,he))return b&&(b.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:b});let M={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:d,noUpdateTTL:f,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:v,ignoreFetchAbort:w,status:b,signal:R},E=r(this,B).get(t);if(E===void 0){b&&(b.fetch="miss");let F=g(this,x,Js).call(this,t,E,M,S);return F.__returned=F}else {let F=r(this,T)[E];if(g(this,x,j).call(this,F)){let A=i&&F.__staleWhileFetching!==void 0;return b&&(b.fetch="inflight",A&&(b.returnedStale=true)),A?F.__staleWhileFetching:F.__returned=F}let I=r(this,mt).call(this,E);if(!k&&!I)return b&&(b.fetch="hit"),g(this,x,is).call(this,E),n&&r(this,xe).call(this,E),b&&r(this,Jt).call(this,b,E),F;let O=g(this,x,Js).call(this,t,E,M,S),P=O.__staleWhileFetching!==void 0&&i;return b&&(b.fetch=I?"stale":"refresh",P&&I&&(b.returnedStale=true)),P?O.__staleWhileFetching:O.__returned=O}}async forceFetch(t,e={}){let i=await this.fetch(t,e);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,e={}){let i=r(this,je);if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=e,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,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=e,l=r(this,B).get(t);if(l!==void 0){let h=r(this,T)[l],d=g(this,x,j).call(this,h);return a&&r(this,Jt).call(this,a,l),r(this,mt).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,oe).call(this,t,"expire"),a&&i&&(a.returnedStale=true),i?h:void 0)):(a&&(a.get="hit"),d?h.__staleWhileFetching:(g(this,x,is).call(this,l),n&&r(this,xe).call(this,l),h))}else a&&(a.get="miss");}delete(t){return g(this,x,oe).call(this,t,"delete")}clear(){return g(this,x,Li).call(this,"delete")}},St=new WeakMap,dt=new WeakMap,Mt=new WeakMap,Se=new WeakMap,Lt=new WeakMap,Ne=new WeakMap,je=new WeakMap,At=new WeakMap,V=new WeakMap,Tt=new WeakMap,B=new WeakMap,$=new WeakMap,T=new WeakMap,rt=new WeakMap,pt=new WeakMap,st=new WeakMap,Q=new WeakMap,_t=new WeakMap,X=new WeakMap,Pt=new WeakMap,Ft=new WeakMap,ft=new WeakMap,gt=new WeakMap,It=new WeakMap,he=new WeakMap,nt=new WeakMap,We=new WeakMap,x=new WeakSet,Ci=function(){let t=new Vs(r(this,St)),e=new Vs(r(this,St));p(this,ft,t),p(this,Ft,e);let i=this.ttlAutopurge?new Array(r(this,St)):void 0;p(this,gt,i),p(this,cs,(a,l,h=r(this,At).now())=>{if(e[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,mt).call(this,a)&&g(this,x,oe).call(this,r(this,$)[a],"expire");},l+1);d.unref&&d.unref(),i[a]=d;}}),p(this,xe,a=>{e[a]=t[a]!==0?r(this,At).now():0;}),p(this,Jt,(a,l)=>{if(t[l]){let h=t[l],d=e[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,At).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=e[l];if(!h||!d)return 1/0;let f=(n||o())-d;return h-f},p(this,mt,a=>{let l=e[a],h=t[a];return !!h&&!!l&&(n||o())-l>h});},xe=new WeakMap,Jt=new WeakMap,cs=new WeakMap,mt=new WeakMap,tn=function(){let t=new Vs(r(this,St));p(this,Tt,0),p(this,Pt,t),p(this,ke,e=>{p(this,Tt,r(this,Tt)-t[e]),t[e]=0;}),p(this,us,(e,i,n,o)=>{if(g(this,x,j).call(this,i))return 0;if(!ie(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(i,e),!ie(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}),p(this,$e,(e,i,n)=>{if(t[e]=i,r(this,dt)){let o=r(this,dt)-t[e];for(;r(this,Tt)>o;)g(this,x,qs).call(this,true);}p(this,Tt,r(this,Tt)+t[e]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,Tt));});},ke=new WeakMap,$e=new WeakMap,us=new WeakMap,re=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let e=r(this,Q);!(!g(this,x,Ri).call(this,e)||((t||!r(this,mt).call(this,e))&&(yield e),e===r(this,st)));)e=r(this,pt)[e];},ne=function*({allowStale:t=this.allowStale}={}){if(r(this,V))for(let e=r(this,st);!(!g(this,x,Ri).call(this,e)||((t||!r(this,mt).call(this,e))&&(yield e),e===r(this,Q)));)e=r(this,rt)[e];},Ri=function(t){return t!==void 0&&r(this,B).get(r(this,$)[t])===t},qs=function(t){var o;let e=r(this,st),i=r(this,$)[e],n=r(this,T)[e];return r(this,he)&&g(this,x,j).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,It)||r(this,nt))&&(r(this,It)&&((o=r(this,Mt))==null||o.call(this,n,i,"evict")),r(this,nt)&&r(this,X)?.push([n,i,"evict"])),r(this,ke).call(this,e),r(this,gt)?.[e]&&(clearTimeout(r(this,gt)[e]),r(this,gt)[e]=void 0),t&&(r(this,$)[e]=void 0,r(this,T)[e]=void 0,r(this,_t).push(e)),r(this,V)===1?(p(this,st,p(this,Q,0)),r(this,_t).length=0):p(this,st,r(this,rt)[e]),r(this,B).delete(i),Fs(this,V)._--,e},Js=function(t,e,i,n){let o=e===void 0?void 0:r(this,T)[e];if(g(this,x,j).call(this,o))return o;let a=new Xs,{signal:l}=i;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let h={signal:a.signal,options:i,context:n},d=(S,k=false)=>{let{aborted:b}=a.signal,R=i.ignoreFetchAbort&&S!==void 0,M=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&S!==void 0);if(i.status&&(b&&!k?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,R&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),b&&!R&&!k)return u(a.signal.reason,M);let E=w,F=r(this,T)[e];return (F===w||R&&k&&F===void 0)&&(S===void 0?E.__staleWhileFetching!==void 0?r(this,T)[e]=E.__staleWhileFetching:g(this,x,oe).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,S,h.options))),S},f=S=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=S),u(S,false)),u=(S,k)=>{let{aborted:b}=a.signal,R=b&&i.allowStaleOnFetchAbort,M=R||i.allowStaleOnFetchRejection,E=M||i.noDeleteOnFetchRejection,F=w;if(r(this,T)[e]===w&&(!E||!k&&F.__staleWhileFetching===void 0?g(this,x,oe).call(this,t,"fetch"):R||(r(this,T)[e]=F.__staleWhileFetching)),M)return i.status&&F.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),F.__staleWhileFetching;if(F.__returned===F)throw S},m=(S,k)=>{var R;let b=(R=r(this,Ne))==null?void 0:R.call(this,t,o,h);b&&b instanceof Promise&&b.then(M=>S(M===void 0?void 0:M),k),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(S(void 0),i.allowStaleOnFetchAbort&&(S=M=>d(M,true)));});};i.status&&(i.status.fetchDispatched=true);let w=new Promise(m).then(d,f),v=Object.assign(w,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return e===void 0?(this.set(t,v,{...h.options,status:void 0}),e=r(this,B).get(t)):r(this,T)[e]=v,v},j=function(t){if(!r(this,he))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Xs},Mi=function(t,e){r(this,pt)[e]=t,r(this,rt)[t]=e;},is=function(t){t!==r(this,Q)&&(t===r(this,st)?p(this,st,r(this,rt)[t]):g(this,x,Mi).call(this,r(this,pt)[t],r(this,rt)[t]),g(this,x,Mi).call(this,r(this,Q),t),p(this,Q,t));},oe=function(t,e){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,Li).call(this,e);else {r(this,ke).call(this,a);let l=r(this,T)[a];if(g(this,x,j).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,It)||r(this,nt))&&(r(this,It)&&((n=r(this,Mt))==null||n.call(this,l,t,e)),r(this,nt)&&r(this,X)?.push([l,t,e])),r(this,B).delete(t),r(this,$)[a]=void 0,r(this,T)[a]=void 0,a===r(this,Q))p(this,Q,r(this,pt)[a]);else if(a===r(this,st))p(this,st,r(this,rt)[a]);else {let h=r(this,pt)[a];r(this,rt)[h]=r(this,rt)[a];let d=r(this,rt)[a];r(this,pt)[d]=r(this,pt)[a];}Fs(this,V)._--,r(this,_t).push(a);}}if(r(this,nt)&&r(this,X)?.length){let a=r(this,X),l;for(;l=a?.shift();)(o=r(this,Lt))==null||o.call(this,...l);}return i},Li=function(t){var e,i;for(let n of g(this,x,ne).call(this,{allowStale:true})){let o=r(this,T)[n];if(g(this,x,j).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=r(this,$)[n];r(this,It)&&((e=r(this,Mt))==null||e.call(this,o,a,t)),r(this,nt)&&r(this,X)?.push([o,a,t]);}}if(r(this,B).clear(),r(this,T).fill(void 0),r(this,$).fill(void 0),r(this,ft)&&r(this,Ft)){r(this,ft).fill(0),r(this,Ft).fill(0);for(let n of r(this,gt)??[])n!==void 0&&clearTimeout(n);r(this,gt)?.fill(void 0);}if(r(this,Pt)&&r(this,Pt).fill(0),p(this,st,0),p(this,Q,0),r(this,_t).length=0,p(this,Tt,0),p(this,V,0),r(this,nt)&&r(this,X)){let n=r(this,X),o;for(;o=n?.shift();)(i=r(this,Lt))==null||i.call(this,...o);}},ze),Xi=typeof process=="object"&&process?process:{stdout:null,stderr:null},ra=s=>!!s&&typeof s=="object"&&(s instanceof ti||s instanceof en||na(s)||oa(s)),na=s=>!!s&&typeof s=="object"&&s instanceof EventEmitter&&typeof s.pipe=="function"&&s.pipe!==en.Writable.prototype.pipe,oa=s=>!!s&&typeof s=="object"&&s instanceof EventEmitter&&typeof s.write=="function"&&typeof s.end=="function",Gt=Symbol("EOF"),Vt=Symbol("maybeEmitEnd"),se=Symbol("emittedEnd"),Ns=Symbol("emittingEnd"),Ye=Symbol("emittedError"),js=Symbol("closed"),tr=Symbol("read"),Ws=Symbol("flush"),er=Symbol("flushChunk"),Ct=Symbol("encoding"),Pe=Symbol("decoder"),H=Symbol("flowing"),Qe=Symbol("paused"),Fe=Symbol("resume"),Z=Symbol("buffer"),it=Symbol("pipes"),K=Symbol("bufferLength"),yi=Symbol("bufferPush"),$s=Symbol("bufferShift"),et=Symbol("objectMode"),z=Symbol("destroyed"),wi=Symbol("error"),bi=Symbol("emitData"),sr=Symbol("emitEnd"),vi=Symbol("emitEnd2"),jt=Symbol("async"),Si=Symbol("abort"),zs=Symbol("aborted"),Xe=Symbol("signal"),me=Symbol("dataListeners"),ut=Symbol("discarded"),ts=s=>Promise.resolve().then(s),aa=s=>s(),la=s=>s==="end"||s==="finish"||s==="prefinish",ha=s=>s instanceof ArrayBuffer||!!s&&typeof s=="object"&&s.constructor&&s.constructor.name==="ArrayBuffer"&&s.byteLength>=0,ca=s=>!Buffer.isBuffer(s)&&ArrayBuffer.isView(s),sn=class{constructor(s,t,e){c(this,"src");c(this,"dest");c(this,"opts");c(this,"ondrain");this.src=s,this.dest=t,this.opts=e,this.ondrain=()=>s[Fe](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(s){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},ua=class extends sn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(s,t,e){super(s,t,e),this.proxyErrors=i=>this.dest.emit("error",i),s.on("error",this.proxyErrors);}},da=s=>!!s.objectMode,pa=s=>!s.objectMode&&!!s.encoding&&s.encoding!=="buffer",gr,mr,yr,wr,br,vr,Sr,xr,kr,Er,Or,Cr,Rr,Mr,Lr,Ar,Tr,_r,Pr,ti=class extends EventEmitter{constructor(...t){let e=t[0]||{};super();c(this,Pr,false);c(this,_r,false);c(this,Tr,[]);c(this,Ar,[]);c(this,Lr);c(this,Mr);c(this,Rr);c(this,Cr);c(this,Or,false);c(this,Er,false);c(this,kr,false);c(this,xr,false);c(this,Sr,null);c(this,vr,0);c(this,br,false);c(this,wr);c(this,yr,false);c(this,mr,0);c(this,gr,false);c(this,"writable",true);c(this,"readable",true);if(e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");da(e)?(this[et]=true,this[Ct]=null):pa(e)?(this[Ct]=e.encoding,this[et]=false):(this[et]=false,this[Ct]=null),this[jt]=!!e.async,this[Pe]=this[Ct]?new StringDecoder(this[Ct]):null,e&&e.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[Z]}),e&&e.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[it]});let{signal:i}=e;i&&(this[Xe]=i,i.aborted?this[Si]():i.addEventListener("abort",()=>this[Si]()));}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[jt]}set async(t){this[jt]=this[jt]||!!t;}[(Pr=H,_r=Qe,Tr=it,Ar=Z,Lr=et,Mr=Ct,Rr=jt,Cr=Pe,Or=Gt,Er=se,kr=Ns,xr=js,Sr=Ye,vr=K,br=z,wr=Xe,yr=zs,mr=me,gr=ut,Si)](){this[zs]=true,this.emit("abort",this[Xe]?.reason),this.destroy(this[Xe]?.reason);}get aborted(){return this[zs]}set aborted(t){}write(t,e,i){if(this[zs])return false;if(this[Gt])throw new Error("write after end");if(this[z])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof e=="function"&&(i=e,e="utf8"),e||(e="utf8");let n=this[jt]?ts:aa;if(!this[et]&&!Buffer.isBuffer(t)){if(ca(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(ha(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[Ws](true),this[H]?this.emit("data",t):this[yi](t),this[K]!==0&&this.emit("readable"),i&&n(i),this[H]):t.length?(typeof t=="string"&&!(e===this[Ct]&&!this[Pe]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[Ct]&&(t=this[Pe].write(t)),this[H]&&this[K]!==0&&this[Ws](true),this[H]?this.emit("data",t):this[yi](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[z])return null;if(this[ut]=false,this[K]===0||t===0||t&&t>this[K])return this[Vt](),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 e=this[tr](t||null,this[Z][0]);return this[Vt](),e}[tr](t,e){if(this[et])this[$s]();else {let i=e;t===i.length||t===null?this[$s]():typeof i=="string"?(this[Z][0]=i.slice(t),e=i.slice(0,t),this[K]-=t):(this[Z][0]=i.subarray(t),e=i.subarray(0,t),this[K]-=t);}return this.emit("data",e),!this[Z].length&&!this[Gt]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[Gt]=true,this.writable=false,(this[H]||!this[Qe])&&this[Vt](),this}[Fe](){this[z]||(!this[me]&&!this[it].length&&(this[ut]=true),this[Qe]=false,this[H]=true,this.emit("resume"),this[Z].length?this[Ws]():this[Gt]?this[Vt]():this.emit("drain"));}resume(){return this[Fe]()}pause(){this[H]=false,this[Qe]=true,this[ut]=false;}get destroyed(){return this[z]}get flowing(){return this[H]}get paused(){return this[Qe]}[yi](t){this[et]?this[K]+=1:this[K]+=t.length,this[Z].push(t);}[$s](){return this[et]?this[K]-=1:this[K]-=this[Z][0].length,this[Z].shift()}[Ws](t=false){do;while(this[er](this[$s]())&&this[Z].length);!t&&!this[Z].length&&!this[Gt]&&this.emit("drain");}[er](t){return this.emit("data",t),this[H]}pipe(t,e){if(this[z])return t;this[ut]=false;let i=this[se];return e=e||{},t===Xi.stdout||t===Xi.stderr?e.end=false:e.end=e.end!==false,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[it].push(e.proxyErrors?new ua(this,t,e):new sn(this,t,e)),this[jt]?ts(()=>this[Fe]()):this[Fe]()),t}unpipe(t){let e=this[it].find(i=>i.dest===t);e&&(this[it].length===1?(this[H]&&this[me]===0&&(this[H]=false),this[it]=[]):this[it].splice(this[it].indexOf(e),1),e.unpipe());}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[ut]=false,this[me]++,!this[it].length&&!this[H]&&this[Fe]();else if(t==="readable"&&this[K]!==0)super.emit("readable");else if(la(t)&&this[se])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ye]){let n=e;this[jt]?ts(()=>n.call(this,this[Ye])):n.call(this,this[Ye]);}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[me]=this.listeners("data").length,this[me]===0&&!this[ut]&&!this[it].length&&(this[H]=false)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[me]=0,!this[ut]&&!this[it].length&&(this[H]=false)),e}get emittedEnd(){return this[se]}[Vt](){!this[Ns]&&!this[se]&&!this[z]&&this[Z].length===0&&this[Gt]&&(this[Ns]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[js]&&this.emit("close"),this[Ns]=false);}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==z&&this[z])return false;if(t==="data")return !this[et]&&!i?false:this[jt]?(ts(()=>this[bi](i)),true):this[bi](i);if(t==="end")return this[sr]();if(t==="close"){if(this[js]=true,!this[se]&&!this[z])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ye]=i,super.emit(wi,i);let o=!this[Xe]||this.listeners("error").length?super.emit("error",i):false;return this[Vt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Vt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let n=super.emit(t,...e);return this[Vt](),n}[bi](t){for(let i of this[it])i.dest.write(t)===false&&this.pause();let e=this[ut]?false:super.emit("data",t);return this[Vt](),e}[sr](){return this[se]?false:(this[se]=true,this.readable=false,this[jt]?(ts(()=>this[vi]()),true):this[vi]())}[vi](){if(this[Pe]){let e=this[Pe].end();if(e){for(let i of this[it])i.dest.write(e);this[ut]||super.emit("data",e);}}for(let e of this[it])e.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 e=this.promise();return this.on("data",i=>{t.push(i),this[et]||(t.dataLength+=i.length);}),await e,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,e)=>{this.on(z,()=>e(new Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[ut]=false;let t=false,e=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:false,value:i});if(this[Gt])return e();let n,o,a=f=>{this.off("data",l),this.off("end",h),this.off(z,d),e(),o(f);},l=f=>{this.off("error",a),this.off("end",h),this.off(z,d),this.pause(),n({value:f,done:!!this[Gt]});},h=()=>{this.off("error",a),this.off("data",l),this.off(z,d),e(),n({done:true,value:void 0});},d=()=>a(new Error("stream destroyed"));return new Promise((f,u)=>{o=u,n=f,this.once(z,d),this.once("error",a),this.once("end",h),this.once("data",l);})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ut]=false;let t=false,e=()=>(this.pause(),this.off(wi,e),this.off(z,e),this.off("end",e),t=true,{done:true,value:void 0}),i=()=>{if(t)return e();let n=this.read();return n===null?e():{done:false,value:n}};return this.once("end",e),this.once(wi,e),this.once(z,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[z])return t?this.emit("error",t):this.emit(z),this;this[z]=true,this[ut]=true,this[Z].length=0,this[K]=0;let e=this;return typeof e.close=="function"&&!this[js]&&e.close(),t?this.emit("error",t):this.emit(z),this}static get isStream(){return ra}},fa=realpathSync.native,rs={lstatSync:lstatSync,readdir:readdir$1,readdirSync:readdirSync,readlinkSync:readlinkSync,realpathSync:fa,promises:{lstat:lstat,readdir:readdir,readlink:readlink,realpath:realpath}},rn=s=>!s||s===rs||s===Qo?rs:{...rs,...s,promises:{...rs.promises,...s.promises||{}}},nn=/^\\\\\?\\([a-z]:)\\?$/i,ga=s=>s.replace(/\//g,"\\").replace(nn,"$1\\"),ma=/[\\\/]/,xt=0,on=1,an=2,Wt=4,ln=6,hn=8,ye=10,cn=12,vt=15,es=~vt,xi=16,ir=32,ns=64,Rt=128,Us=256,Hs=512,rr=ns|Rt|Hs,ya=1023,ki=s=>s.isFile()?hn:s.isDirectory()?Wt:s.isSymbolicLink()?ye:s.isCharacterDevice()?an:s.isBlockDevice()?ln:s.isSocket()?cn:s.isFIFO()?on:xt,nr=new si({max:2**12}),os=s=>{let t=nr.get(s);if(t)return t;let e=s.normalize("NFKD");return nr.set(s,e),e},or=new si({max:2**12}),Bs=s=>{let t=or.get(s);if(t)return t;let e=os(s.toLowerCase());return or.set(s,e),e},ar=class extends si{constructor(){super({max:256});}},wa=class extends si{constructor(s=16*1024){super({maxSize:s,sizeCalculation:t=>t.length+1});}},un=Symbol("PathScurry setAsCwd"),ot,ds,ps,fs,gs,ms,ys,ws,bs,vs,Ss,xs,ks,Es,Os,Cs,Rs,Ms,Ls,ce,Ee,zt,Ht,Zt,Kt,L,Oe,Yt,Ut,C,Ti,Zs,as,_i,Pi,ls,Ks,Fi,Ii,Ys,dn,pn,fn,Di,Ue,Be,gn,Ce,Fr,ht=(Fr=class{constructor(s,t=xt,e,i,n,o,a){y(this,C);c(this,"name");c(this,"root");c(this,"roots");c(this,"parent");c(this,"nocase");c(this,"isCWD",false);y(this,ot);y(this,ds);y(this,ps);y(this,fs);y(this,gs);y(this,ms);y(this,ys);y(this,ws);y(this,bs);y(this,vs);y(this,Ss);y(this,xs);y(this,ks);y(this,Es);y(this,Os);y(this,Cs);y(this,Rs);y(this,Ms);y(this,Ls);y(this,ce);y(this,Ee);y(this,zt);y(this,Ht);y(this,Zt);y(this,Kt);y(this,L);y(this,Oe);y(this,Yt);y(this,Ut);y(this,Ue,[]);y(this,Be,false);y(this,Ce);this.name=s,p(this,ce,n?Bs(s):os(s)),p(this,L,t&ya),this.nocase=n,this.roots=i,this.root=e||this,p(this,Oe,o),p(this,zt,a.fullpath),p(this,Zt,a.relative),p(this,Kt,a.relativePosix),this.parent=a.parent,this.parent?p(this,ot,r(this.parent,ot)):p(this,ot,rn(a.fs));}get dev(){return r(this,ds)}get mode(){return r(this,ps)}get nlink(){return r(this,fs)}get uid(){return r(this,gs)}get gid(){return r(this,ms)}get rdev(){return r(this,ys)}get blksize(){return r(this,ws)}get ino(){return r(this,bs)}get size(){return r(this,vs)}get blocks(){return r(this,Ss)}get atimeMs(){return r(this,xs)}get mtimeMs(){return r(this,ks)}get ctimeMs(){return r(this,Es)}get birthtimeMs(){return r(this,Os)}get atime(){return r(this,Cs)}get mtime(){return r(this,Rs)}get ctime(){return r(this,Ms)}get birthtime(){return r(this,Ls)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,Ee)!==void 0?r(this,Ee):this.parent?p(this,Ee,this.parent.depth()+1):p(this,Ee,0)}childrenCache(){return r(this,Oe)}resolve(s){var i;if(!s)return this;let t=this.getRootString(s),e=s.substring(t.length).split(this.splitSep);return t?g(i=this.getRoot(t),C,Ti).call(i,e):g(this,C,Ti).call(this,e)}children(){let s=r(this,Oe).get(this);if(s)return s;let t=Object.assign([],{provisional:0});return r(this,Oe).set(this,t),p(this,L,r(this,L)&~xi),t}child(s,t){if(s===""||s===".")return this;if(s==="..")return this.parent||this;let e=this.children(),i=this.nocase?Bs(s):os(s);for(let l of e)if(r(l,ce)===i)return l;let n=this.parent?this.sep:"",o=r(this,zt)?r(this,zt)+n+s:void 0,a=this.newChild(s,xt,{...t,parent:this,fullpath:o});return this.canReaddir()||p(a,L,r(a,L)|Rt),e.push(a),a}relative(){if(this.isCWD)return "";if(r(this,Zt)!==void 0)return r(this,Zt);let s=this.name,t=this.parent;if(!t)return p(this,Zt,this.name);let e=t.relative();return e+(!e||!t.parent?"":this.sep)+s}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(r(this,Kt)!==void 0)return r(this,Kt);let s=this.name,t=this.parent;if(!t)return p(this,Kt,this.fullpathPosix());let e=t.relativePosix();return e+(!e||!t.parent?"":"/")+s}fullpath(){if(r(this,zt)!==void 0)return r(this,zt);let s=this.name,t=this.parent;if(!t)return p(this,zt,this.name);let e=t.fullpath()+(t.parent?this.sep:"")+s;return p(this,zt,e)}fullpathPosix(){if(r(this,Ht)!==void 0)return r(this,Ht);if(this.sep==="/")return p(this,Ht,this.fullpath());if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(i)?p(this,Ht,`//?/${i}`):p(this,Ht,i)}let s=this.parent,t=s.fullpathPosix(),e=t+(!t||!s.parent?"":"/")+this.name;return p(this,Ht,e)}isUnknown(){return (r(this,L)&vt)===xt}isType(s){return this[`is${s}`]()}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)&vt)===hn}isDirectory(){return (r(this,L)&vt)===Wt}isCharacterDevice(){return (r(this,L)&vt)===an}isBlockDevice(){return (r(this,L)&vt)===ln}isFIFO(){return (r(this,L)&vt)===on}isSocket(){return (r(this,L)&vt)===cn}isSymbolicLink(){return (r(this,L)&ye)===ye}lstatCached(){return r(this,L)&ir?this:void 0}readlinkCached(){return r(this,Yt)}realpathCached(){return r(this,Ut)}readdirCached(){let s=this.children();return s.slice(0,s.provisional)}canReadlink(){if(r(this,Yt))return true;if(!this.parent)return false;let s=r(this,L)&vt;return !(s!==xt&&s!==ye||r(this,L)&Us||r(this,L)&Rt)}calledReaddir(){return !!(r(this,L)&xi)}isENOENT(){return !!(r(this,L)&Rt)}isNamed(s){return this.nocase?r(this,ce)===Bs(s):r(this,ce)===os(s)}async readlink(){let s=r(this,Yt);if(s)return s;if(this.canReadlink()&&this.parent)try{let t=await r(this,ot).promises.readlink(this.fullpath()),e=(await this.parent.realpath())?.resolve(t);if(e)return p(this,Yt,e)}catch(t){g(this,C,Ii).call(this,t.code);return}}readlinkSync(){let s=r(this,Yt);if(s)return s;if(this.canReadlink()&&this.parent)try{let t=r(this,ot).readlinkSync(this.fullpath()),e=this.parent.realpathSync()?.resolve(t);if(e)return p(this,Yt,e)}catch(t){g(this,C,Ii).call(this,t.code);return}}async lstat(){if((r(this,L)&Rt)===0)try{return g(this,C,Di).call(this,await r(this,ot).promises.lstat(this.fullpath())),this}catch(s){g(this,C,Fi).call(this,s.code);}}lstatSync(){if((r(this,L)&Rt)===0)try{return g(this,C,Di).call(this,r(this,ot).lstatSync(this.fullpath())),this}catch(s){g(this,C,Fi).call(this,s.code);}}readdirCB(s,t=false){if(!this.canReaddir()){t?s(null,[]):queueMicrotask(()=>s(null,[]));return}let e=this.children();if(this.calledReaddir()){let n=e.slice(0,e.provisional);t?s(null,n):queueMicrotask(()=>s(null,n));return}if(r(this,Ue).push(s),r(this,Be))return;p(this,Be,true);let i=this.fullpath();r(this,ot).readdir(i,{withFileTypes:true},(n,o)=>{if(n)g(this,C,Ks).call(this,n.code),e.provisional=0;else {for(let a of o)g(this,C,Ys).call(this,a,e);g(this,C,Zs).call(this,e);}g(this,C,gn).call(this,e.slice(0,e.provisional));});}async readdir(){if(!this.canReaddir())return [];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let t=this.fullpath();if(r(this,Ce))await r(this,Ce);else {let e=()=>{};p(this,Ce,new Promise(i=>e=i));try{for(let i of await r(this,ot).promises.readdir(t,{withFileTypes:!0}))g(this,C,Ys).call(this,i,s);g(this,C,Zs).call(this,s);}catch(i){g(this,C,Ks).call(this,i.code),s.provisional=0;}p(this,Ce,void 0),e();}return s.slice(0,s.provisional)}readdirSync(){if(!this.canReaddir())return [];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let t=this.fullpath();try{for(let e of r(this,ot).readdirSync(t,{withFileTypes:!0}))g(this,C,Ys).call(this,e,s);g(this,C,Zs).call(this,s);}catch(e){g(this,C,Ks).call(this,e.code),s.provisional=0;}return s.slice(0,s.provisional)}canReaddir(){if(r(this,L)&rr)return false;let s=vt&r(this,L);return s===xt||s===Wt||s===ye}shouldWalk(s,t){return (r(this,L)&Wt)===Wt&&!(r(this,L)&rr)&&!s.has(this)&&(!t||t(this))}async realpath(){if(r(this,Ut))return r(this,Ut);if(!((Hs|Us|Rt)&r(this,L)))try{let s=await r(this,ot).promises.realpath(this.fullpath());return p(this,Ut,this.resolve(s))}catch{g(this,C,Pi).call(this);}}realpathSync(){if(r(this,Ut))return r(this,Ut);if(!((Hs|Us|Rt)&r(this,L)))try{let s=r(this,ot).realpathSync(this.fullpath());return p(this,Ut,this.resolve(s))}catch{g(this,C,Pi).call(this);}}[un](s){if(s===this)return;s.isCWD=false,this.isCWD=true;let t=new Set([]),e=[],i=this;for(;i&&i.parent;)t.add(i),p(i,Zt,e.join(this.sep)),p(i,Kt,e.join("/")),i=i.parent,e.push("..");for(i=s;i&&i.parent&&!t.has(i);)p(i,Zt,void 0),p(i,Kt,void 0),i=i.parent;}},ot=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,ks=new WeakMap,Es=new WeakMap,Os=new WeakMap,Cs=new WeakMap,Rs=new WeakMap,Ms=new WeakMap,Ls=new WeakMap,ce=new WeakMap,Ee=new WeakMap,zt=new WeakMap,Ht=new WeakMap,Zt=new WeakMap,Kt=new WeakMap,L=new WeakMap,Oe=new WeakMap,Yt=new WeakMap,Ut=new WeakMap,C=new WeakSet,Ti=function(s){let t=this;for(let e of s)t=t.child(e);return t},Zs=function(s){var t;p(this,L,r(this,L)|xi);for(let e=s.provisional;e<s.length;e++){let i=s[e];i&&g(t=i,C,as).call(t);}},as=function(){r(this,L)&Rt||(p(this,L,(r(this,L)|Rt)&es),g(this,C,_i).call(this));},_i=function(){var t;let s=this.children();s.provisional=0;for(let e of s)g(t=e,C,as).call(t);},Pi=function(){p(this,L,r(this,L)|Hs),g(this,C,ls).call(this);},ls=function(){if(r(this,L)&ns)return;let s=r(this,L);(s&vt)===Wt&&(s&=es),p(this,L,s|ns),g(this,C,_i).call(this);},Ks=function(s=""){s==="ENOTDIR"||s==="EPERM"?g(this,C,ls).call(this):s==="ENOENT"?g(this,C,as).call(this):this.children().provisional=0;},Fi=function(s=""){var t;s==="ENOTDIR"?g(t=this.parent,C,ls).call(t):s==="ENOENT"&&g(this,C,as).call(this);},Ii=function(s=""){var e;let t=r(this,L);t|=Us,s==="ENOENT"&&(t|=Rt),(s==="EINVAL"||s==="UNKNOWN")&&(t&=es),p(this,L,t),s==="ENOTDIR"&&this.parent&&g(e=this.parent,C,ls).call(e);},Ys=function(s,t){return g(this,C,pn).call(this,s,t)||g(this,C,dn).call(this,s,t)},dn=function(s,t){let e=ki(s),i=this.newChild(s.name,e,{parent:this}),n=r(i,L)&vt;return n!==Wt&&n!==ye&&n!==xt&&p(i,L,r(i,L)|ns),t.unshift(i),t.provisional++,i},pn=function(s,t){for(let e=t.provisional;e<t.length;e++){let i=t[e];if((this.nocase?Bs(s.name):os(s.name))===r(i,ce))return g(this,C,fn).call(this,s,i,e,t)}},fn=function(s,t,e,i){let n=t.name;return p(t,L,r(t,L)&es|ki(s)),n!==s.name&&(t.name=s.name),e!==i.provisional&&(e===i.length-1?i.pop():i.splice(e,1),i.unshift(t)),i.provisional++,t},Di=function(s){let{atime:t,atimeMs:e,birthtime:i,birthtimeMs:n,blksize:o,blocks:a,ctime:l,ctimeMs:h,dev:d,gid:f,ino:u,mode:m,mtime:w,mtimeMs:v,nlink:S,rdev:k,size:b,uid:R}=s;p(this,Cs,t),p(this,xs,e),p(this,Ls,i),p(this,Os,n),p(this,ws,o),p(this,Ss,a),p(this,Ms,l),p(this,Es,h),p(this,ds,d),p(this,ms,f),p(this,bs,u),p(this,ps,m),p(this,Rs,w),p(this,ks,v),p(this,fs,S),p(this,ys,k),p(this,vs,b),p(this,gs,R);let M=ki(s);p(this,L,r(this,L)&es|M|ir),M!==xt&&M!==Wt&&M!==ye&&p(this,L,r(this,L)|ns);},Ue=new WeakMap,Be=new WeakMap,gn=function(s){p(this,Be,false);let t=r(this,Ue).slice();r(this,Ue).length=0,t.forEach(e=>e(null,s));},Ce=new WeakMap,Fr),mn=class yn extends ht{constructor(e,i=xt,n,o,a,l,h){super(e,i,n,o,a,l,h);c(this,"sep","\\");c(this,"splitSep",ma);}newChild(e,i=xt,n={}){return new yn(e,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return win32.parse(e).root}getRoot(e){if(e=ga(e.toUpperCase()),e===this.root.name)return this.root;for(let[i,n]of Object.entries(this.roots))if(this.sameRoot(e,i))return this.roots[e]=n;return this.roots[e]=new zi(e,this).root}sameRoot(e,i=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(nn,"$1\\"),e===i}},wn=class bn extends ht{constructor(e,i=xt,n,o,a,l,h){super(e,i,n,o,a,l,h);c(this,"splitSep","/");c(this,"sep","/");}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,i=xt,n={}){return new bn(e,i,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Ge,Ve,As,Ts,Ir,vn=(Ir=class{constructor(s=process.cwd(),t,e,{nocase:i,childrenCacheSize:n=16*1024,fs:o=rs}={}){c(this,"root");c(this,"rootPath");c(this,"roots");c(this,"cwd");y(this,Ge);y(this,Ve);y(this,As);c(this,"nocase");y(this,Ts);p(this,Ts,rn(o)),(s instanceof URL||s.startsWith("file://"))&&(s=fileURLToPath(s));let a=t.resolve(s);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),p(this,Ge,new ar),p(this,Ve,new ar),p(this,As,new wa(n));let l=a.substring(this.rootPath.length).split(e);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,Ts)),this.roots[this.rootPath]=this.root;let h=this.root,d=l.length-1,f=t.sep,u=this.rootPath,m=false;for(let w of l){let v=d--;h=h.child(w,{relative:new Array(v).fill("..").join(f),relativePosix:new Array(v).fill("..").join("/"),fullpath:u+=(m?"":f)+w}),m=true;}this.cwd=h;}depth(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.depth()}childrenCache(){return r(this,As)}resolve(...s){let t="";for(let n=s.length-1;n>=0;n--){let o=s[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let e=r(this,Ge).get(t);if(e!==void 0)return e;let i=this.cwd.resolve(t).fullpath();return r(this,Ge).set(t,i),i}resolvePosix(...s){let t="";for(let n=s.length-1;n>=0;n--){let o=s[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let e=r(this,Ve).get(t);if(e!==void 0)return e;let i=this.cwd.resolve(t).fullpathPosix();return r(this,Ve).set(t,i),i}relative(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relative()}relativePosix(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relativePosix()}basename(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.name}dirname(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),(s.parent||s).fullpath()}async readdir(s=this.cwd,t={withFileTypes:true}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e}=t;if(s.canReaddir()){let i=await s.readdir();return e?i:i.map(n=>n.name)}else return []}readdirSync(s=this.cwd,t={withFileTypes:true}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true}=t;return s.canReaddir()?e?s.readdirSync():s.readdirSync().map(i=>i.name):[]}async lstat(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstat()}lstatSync(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstatSync()}async readlink(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=await s.readlink();return t?e:e?.fullpath()}readlinkSync(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=s.readlinkSync();return t?e:e?.fullpath()}async realpath(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=await s.realpath();return t?e:e?.fullpath()}realpathSync(s=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s.withFileTypes,s=this.cwd);let e=s.realpathSync();return t?e:e?.fullpath()}async walk(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(s))&&a.push(e?s:s.fullpath());let l=new Set,h=(f,u)=>{l.add(f),f.readdirCB((m,w)=>{if(m)return u(m);let v=w.length;if(!v)return u();let S=()=>{--v===0&&u();};for(let k of w)(!n||n(k))&&a.push(e?k:k.fullpath()),i&&k.isSymbolicLink()?k.realpath().then(b=>b?.isUnknown()?b.lstat():b).then(b=>b?.shouldWalk(l,o)?h(b,S):S()):k.shouldWalk(l,o)?h(k,S):S();},true);},d=s;return new Promise((f,u)=>{h(d,m=>{if(m)return u(m);f(a);});})}walkSync(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=[];(!n||n(s))&&a.push(e?s:s.fullpath());let l=new Set([s]);for(let h of l){let d=h.readdirSync();for(let f of d){(!n||n(f))&&a.push(e?f:f.fullpath());let u=f;if(f.isSymbolicLink()){if(!(i&&(u=f.realpathSync())))continue;u.isUnknown()&&u.lstatSync();}u.shouldWalk(l,o)&&l.add(u);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(s=this.cwd,t={}){return typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd),this.stream(s,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t;(!n||n(s))&&(yield e?s:s.fullpath());let a=new Set([s]);for(let l of a){let h=l.readdirSync();for(let d of h){(!n||n(d))&&(yield e?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(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=new ti({objectMode:true});(!n||n(s))&&a.write(e?s:s.fullpath());let l=new Set,h=[s],d=0,f=()=>{let u=false;for(;!u;){let m=h.shift();if(!m){d===0&&a.end();return}d++,l.add(m);let w=(S,k,b=false)=>{if(S)return a.emit("error",S);if(i&&!b){let R=[];for(let M of k)M.isSymbolicLink()&&R.push(M.realpath().then(E=>E?.isUnknown()?E.lstat():E));if(R.length){Promise.all(R).then(()=>w(null,k,true));return}}for(let R of k)R&&(!n||n(R))&&(a.write(e?R:R.fullpath())||(u=true));d--;for(let R of k){let M=R.realpathCached()||R;M.shouldWalk(l,o)&&h.push(M);}u&&!a.flowing?a.once("drain",f):v||f();},v=true;m.readdirCB(w,true),v=false;}};return f(),a}streamSync(s=this.cwd,t={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof ht||(t=s,s=this.cwd);let{withFileTypes:e=true,follow:i=false,filter:n,walkFilter:o}=t,a=new ti({objectMode:true}),l=new Set;(!n||n(s))&&a.write(e?s:s.fullpath());let h=[s],d=0,f=()=>{let u=false;for(;!u;){let m=h.shift();if(!m){d===0&&a.end();return}d++,l.add(m);let w=m.readdirSync();for(let v of w)(!n||n(v))&&(a.write(e?v:v.fullpath())||(u=true));d--;for(let v of w){let S=v;if(v.isSymbolicLink()){if(!(i&&(S=v.realpathSync())))continue;S.isUnknown()&&S.lstatSync();}S.shouldWalk(l,o)&&h.push(S);}}u&&!a.flowing&&a.once("drain",f);};return f(),a}chdir(s=this.cwd){let t=this.cwd;this.cwd=typeof s=="string"?this.cwd.resolve(s):s,this.cwd[un](t);}},Ge=new WeakMap,Ve=new WeakMap,As=new WeakMap,Ts=new WeakMap,Ir),zi=class extends vn{constructor(t=process.cwd(),e={}){let{nocase:i=true}=e;super(t,win32,"\\",{...e,nocase:i});c(this,"sep","\\");this.nocase=i;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase;}parseRootPath(t){return win32.parse(t).root.toUpperCase()}newRoot(t){return new mn(this.rootPath,Wt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Ui=class extends vn{constructor(t=process.cwd(),e={}){let{nocase:i=false}=e;super(t,posix,"/",{...e,nocase:i});c(this,"sep","/");this.nocase=i;}parseRootPath(t){return "/"}newRoot(t){return new wn(this.rootPath,Wt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Sn=class extends Ui{constructor(s=process.cwd(),t={}){let{nocase:e=true}=t;super(s,{...t,nocase:e});}};process.platform==="win32"?mn:wn;var ba=process.platform==="win32"?zi:process.platform==="darwin"?Sn:Ui,va=s=>s.length>=1,Sa=s=>s.length>=1,xa=Symbol.for("nodejs.util.inspect.custom"),q,ct,J,Re,Dt,_s,ue,de,pe,qe,Je,xn=(Je=class{constructor(t,e,i,n){y(this,q);y(this,ct);y(this,J);c(this,"length");y(this,Re);y(this,Dt);y(this,_s);y(this,ue);y(this,de);y(this,pe);y(this,qe,true);if(!va(t))throw new TypeError("empty pattern list");if(!Sa(e))throw new TypeError("empty glob list");if(e.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(p(this,q,t),p(this,ct,e),p(this,J,i),p(this,Re,n),r(this,J)===0){if(this.isUNC()){let[o,a,l,h,...d]=r(this,q),[f,u,m,w,...v]=r(this,ct);d[0]===""&&(d.shift(),v.shift());let S=[o,a,l,h,""].join("/"),k=[f,u,m,w,""].join("/");p(this,q,[S,...d]),p(this,ct,[k,...v]),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 d=o+"/",f=l+"/";p(this,q,[d,...a]),p(this,ct,[f,...h]),this.length=r(this,q).length;}}}[xa](){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 p(this,_s,r(this,_s)||(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,Dt)!==void 0?r(this,Dt):this.hasMore()?(p(this,Dt,new Je(r(this,q),r(this,ct),r(this,J)+1,r(this,Re))),p(r(this,Dt),pe,r(this,pe)),p(r(this,Dt),de,r(this,de)),p(r(this,Dt),ue,r(this,ue)),r(this,Dt)):p(this,Dt,null)}isUNC(){let t=r(this,q);return r(this,de)!==void 0?r(this,de):p(this,de,r(this,Re)==="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,ue)!==void 0?r(this,ue):p(this,ue,r(this,Re)==="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,pe)!==void 0?r(this,pe):p(this,pe,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,qe))}markFollowGlobstar(){return r(this,J)===0||!this.isGlobstar()||!r(this,qe)?false:(p(this,qe,false),true)}},q=new WeakMap,ct=new WeakMap,J=new WeakMap,Re=new WeakMap,Dt=new WeakMap,_s=new WeakMap,ue=new WeakMap,de=new WeakMap,pe=new WeakMap,qe=new WeakMap,Je),ka=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",lr=class{constructor(s,{nobrace:t,nocase:e,noext:i,noglobstar:n,platform:o=ka}){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:e,noext:i,noglobstar:n,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of s)this.add(a);}add(s){let t=new ge(s,this.mmopts);for(let e=0;e<t.set.length;e++){let i=t.set[e],n=t.globParts[e];if(!i||!n)throw new Error("invalid pattern object");for(;i[0]==="."&&n[0]===".";)i.shift(),n.shift();let o=new xn(i,n,0,this.platform),a=new ge(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(s){let t=s.fullpath(),e=`${t}/`,i=s.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(e))return true;return false}childrenIgnored(s){let t=s.fullpath()+"/",e=(s.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(e))return true;for(let i of this.absoluteChildren)if(i.match(t))return true;return false}},Ea=class kn{constructor(t=new Map){c(this,"store");this.store=t;}copy(){return new kn(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let i=t.fullpath(),n=this.store.get(i);n?n.add(e.globString()):this.store.set(i,new Set([e.globString()]));}},Oa=class{constructor(){c(this,"store",new Map);}add(s,t,e){let i=(t?2:0)|(e?1:0),n=this.store.get(s);this.store.set(s,n===void 0?i:i&n);}entries(){return [...this.store.entries()].map(([s,t])=>[s,!!(t&2),!!(t&1)])}},Ca=class{constructor(){c(this,"store",new Map);}add(s,t){if(!s.canReaddir())return;let e=this.store.get(s);e?e.find(i=>i.globString()===t.globString())||e.push(t):this.store.set(s,[t]);}get(s){let t=this.store.get(s);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(s=>[s,this.store.get(s)])}keys(){return [...this.store.keys()].filter(s=>s.canReaddir())}},hr=class En{constructor(t,e){c(this,"hasWalkedCache");c(this,"matches",new Oa);c(this,"subwalks",new Ca);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=e?e.copy():new Ea;}processPatterns(t,e){this.patterns=e;let i=e.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 u=o.rest();if(u)o=u;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 u=h===".."||h===""||h===".";this.matches.add(n.resolve(h),l,u);continue}else if(h===at){(!n.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(n,o);let u=d?.pattern(),m=d?.rest();if(!d||(u===""||u===".")&&!m)this.matches.add(n,l,u===""||u===".");else if(u===".."){let w=n.parent||n;m?this.hasWalkedCache.hasWalked(w,m)||this.subwalks.add(w,m):this.matches.add(w,l,true);}}else h instanceof RegExp&&this.subwalks.add(n,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new En(this.opts,this.hasWalkedCache)}filterEntries(t,e){let i=this.subwalks.get(t),n=this.child();for(let o of e)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,e,i,n){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,n,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(i&&e.checkFollowGlobstar()?this.subwalks.add(t,i):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),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,e,i,n){e.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}testString(t,e,i,n){t.isNamed(e)&&(i?this.subwalks.add(t,i):this.matches.add(t,n,false));}},Ra=(s,t)=>typeof s=="string"?new lr([s],t):Array.isArray(s)?new lr(s,t):s,He,Qt,Me,kt,we,Ni,Dr,On=(Dr=class{constructor(s,t,e){y(this,kt);c(this,"path");c(this,"patterns");c(this,"opts");c(this,"seen",new Set);c(this,"paused",false);c(this,"aborted",false);y(this,He,[]);y(this,Qt);y(this,Me);c(this,"signal");c(this,"maxDepth");c(this,"includeChildMatches");if(this.patterns=s,this.path=t,this.opts=e,p(this,Me,!e.posix&&e.platform==="win32"?"\\":"/"),this.includeChildMatches=e.includeChildMatches!==false,(e.ignore||!this.includeChildMatches)&&(p(this,Qt,Ra(e.ignore??[],e)),!this.includeChildMatches&&typeof r(this,Qt).add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=e.maxDepth||1/0,e.signal&&(this.signal=e.signal,this.signal.addEventListener("abort",()=>{r(this,He).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let s;for(;!this.paused&&(s=r(this,He).shift());)s();}onResume(s){this.signal?.aborted||(this.paused?r(this,He).push(s):s());}async matchCheck(s,t){if(t&&this.opts.nodir)return;let e;if(this.opts.realpath){if(e=s.realpathCached()||await s.realpath(),!e)return;s=e;}let i=s.isUnknown()||this.opts.stat?await s.lstat():s;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(s,t){return s&&(this.maxDepth===1/0||s.depth()<=this.maxDepth)&&(!t||s.canReaddir())&&(!this.opts.nodir||!s.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!s.isSymbolicLink()||!s.realpathCached()?.isDirectory())&&!g(this,kt,we).call(this,s)?s:void 0}matchCheckSync(s,t){if(t&&this.opts.nodir)return;let e;if(this.opts.realpath){if(e=s.realpathCached()||s.realpathSync(),!e)return;s=e;}let i=s.isUnknown()||this.opts.stat?s.lstatSync():s;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(s,t){if(g(this,kt,we).call(this,s))return;if(!this.includeChildMatches&&r(this,Qt)?.add){let n=`${s.relativePosix()}/**`;r(this,Qt).add(n);}let e=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(s);let i=this.opts.mark&&s.isDirectory()?r(this,Me):"";if(this.opts.withFileTypes)this.matchEmit(s);else if(e){let n=this.opts.posix?s.fullpathPosix():s.fullpath();this.matchEmit(n+i);}else {let n=this.opts.posix?s.relativePosix():s.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+r(this,Me))?"."+r(this,Me):"";this.matchEmit(n?o+n+i:"."+i);}}async match(s,t,e){let i=await this.matchCheck(s,e);i&&this.matchFinish(i,t);}matchSync(s,t,e){let i=this.matchCheckSync(s,e);i&&this.matchFinish(i,t);}walkCB(s,t,e){this.signal?.aborted&&e(),this.walkCB2(s,t,new hr(this.opts),e);}walkCB2(s,t,e,i){if(g(this,kt,Ni).call(this,s))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(s,t,e,i));return}e.processPatterns(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,kt,we).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let a of e.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,e,o):a.readdirCB((h,d)=>this.walkCB3(a,d,e,o),true);}o();}walkCB3(s,t,e,i){e=e.filterEntries(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,kt,we).call(this,a)||(n++,this.match(a,l,h).then(()=>o()));for(let[a,l]of e.subwalks.entries())n++,this.walkCB2(a,l,e.child(),o);o();}walkCBSync(s,t,e){this.signal?.aborted&&e(),this.walkCB2Sync(s,t,new hr(this.opts),e);}walkCB2Sync(s,t,e,i){if(g(this,kt,Ni).call(this,s))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(s,t,e,i));return}e.processPatterns(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,kt,we).call(this,a)||this.matchSync(a,l,h);for(let a of e.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let l=a.readdirSync();this.walkCB3Sync(a,l,e,o);}o();}walkCB3Sync(s,t,e,i){e=e.filterEntries(s,t);let n=1,o=()=>{--n===0&&i();};for(let[a,l,h]of e.matches.entries())g(this,kt,we).call(this,a)||this.matchSync(a,l,h);for(let[a,l]of e.subwalks.entries())n++,this.walkCB2Sync(a,l,e.child(),o);o();}},He=new WeakMap,Qt=new WeakMap,Me=new WeakMap,kt=new WeakSet,we=function(s){return this.seen.has(s)||!!r(this,Qt)?.ignored?.(s)},Ni=function(s){return !!r(this,Qt)?.childrenIgnored?.(s)},Dr),cr=class extends On{constructor(t,e,i){super(t,e,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,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(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}},ur=class extends On{constructor(t,e,i){super(t,e,i);c(this,"results");this.results=new ti({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}},Ma=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ae=class{constructor(s,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=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 s=="string"&&(s=[s]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(s=s.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");s=s.map(l=>l.includes("/")?l:`./**/${l}`);}if(this.pattern=s,this.platform=t.platform||Ma,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"?zi:t.platform==="darwin"?Sn:t.platform?Ui:ba;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let e=this.platform==="darwin"||this.platform==="win32",i={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:e,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 ge(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 xn(l,d,0,this.platform)});}async walk(){return [...await new cr(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 cr(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 ur(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 ur(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()}},La=(s,t={})=>{Array.isArray(s)||(s=[s]);for(let e of s)if(new ge(e,t).hasMagic())return true;return false};function ii(s,t={}){return new Ae(s,t).streamSync()}function Cn(s,t={}){return new Ae(s,t).stream()}function Rn(s,t={}){return new Ae(s,t).walkSync()}async function dr(s,t={}){return new Ae(s,t).walk()}function ri(s,t={}){return new Ae(s,t).iterateSync()}function Mn(s,t={}){return new Ae(s,t).iterate()}var Aa=ii,Ta=Object.assign(Cn,{sync:ii}),_a=ri,Pa=Object.assign(Mn,{sync:ri}),Fa=Object.assign(Rn,{stream:ii,iterate:ri}),ei=Object.assign(dr,{glob:dr,globSync:Rn,sync:Fa,globStream:Cn,stream:Ta,globStreamSync:ii,streamSync:Aa,globIterate:Mn,iterate:Pa,globIterateSync:ri,iterateSync:_a,Glob:Ae,hasMagic:La,escape:qr,unescape:Ie});ei.glob=ei;var Nt;(I=>{I.Level=Da.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let t={DEBUG:0,INFO:1,WARN:2,ERROR:3},e="INFO";function i(O){return t[O]>=t[e]}function n(){return e}I.getLevel=n;let o=new Map;I.Default=F({service:"default"});let l="";function h(){return l}I.file=h;let d,f,u=false,m=false,w=O=>{try{m&&process.stderr.write(O);}catch{}},v=false,S=false;async function k(O){if(u)return;if(O.level&&(e=O.level),O.print&&(m=O.print??false),O.print){u=true;return}let P=O.logDir||ni.join(process.env.EASBOT_LOG_PATH??process.cwd(),"logs");O.logFile?l=ni.join(P,O.logFile??"ollama-sdk.log"):l=ni.join(P,"ollama-sdk.log");try{await Ln.mkdir(P,{recursive:!0}),d=await Ln.open(l,"a"),f=createWriteStream("",{fd:d.fd,autoClose:!1}),w=A=>{if(!(v||S||!f||f.destroyed))try{if(!f.writable)return;f.write(A,D=>{if(D&&!v){let _=D;if(_.code==="EPIPE"||_.code==="EIO"){S=!0,f?.destroy();return}v=!0,setTimeout(()=>{v=!1;},1e3);}});}catch(D){let _=D;if(_.code==="EPIPE"||_.code==="EIO"){S=!0,f?.destroy();return}v||(v=!0,setTimeout(()=>{v=!1;},1e3));}},u=!0;}catch{w=A=>{try{process.stderr.write(A);}catch{}},u=true;}}I.init=k;async function b(){u&&(f&&!f.destroyed&&(await new Promise((O,P)=>{f.end(A=>{A?P(A):O();});}).catch(()=>{}),f=void 0),d&&(await d.close().catch(()=>{}),d=void 0),w=O=>{try{process.stderr.write(O);}catch{}},u=false);}I.close=b;function M(O,P=0){let A=O.message;return O.cause instanceof Error&&P<10?A+" Caused by: "+M(O.cause,P+1):A}let E=Date.now();function F(O){O=O||{};let P=O.service;if(P&&typeof P=="string"){let _=o.get(P);if(_)return _}function A(_,N){let Te=Object.entries({...O,...N}).filter(([Bi,te])=>te!=null).map(([Bi,te])=>{let ci=`${Bi}=`;return te instanceof Error?ci+M(te):typeof te=="object"?ci+JSON.stringify(te):ci+te}).join(" "),Ot=new Date,Fn=Ot.getTime()-E;return E=Ot.getTime(),[formatLogTime(Ot),"+"+Fn+"ms",Te,_].filter(Boolean).join(" ")+`
5
- `}let D={debug(_,N){i("DEBUG")&&w("DEBUG "+A(_,N));},info(_,N){i("INFO")&&w("INFO "+A(_,N));},error(_,N){i("ERROR")&&w("ERROR "+A(_,N));},warn(_,N){i("WARN")&&w("WARN "+A(_,N));},tag(_,N){return O&&(O[_]=N),D},clone(){return I.create({...O})},time(_,N){let Te=Date.now();D.info(_,{status:"started",...N});function Ot(){D.info(_,{status:"completed",duration:Date.now()-Te,...N});}return {stop:Ot,[Symbol.dispose](){Ot();}}}};return P&&typeof P=="string"&&o.set(P,D),D}I.create=F;})(Nt||(Nt={}));function An(s,t,e){let i;return t?i="tool-calls":s?i="stop":i="other",{unified:i,raw:e}}var Et=Nt.create({service:"ollama-sdk",module:"native-language-model"});function oi(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ai(s){if(!s||s.trim().length===0)return false;try{return JSON.parse(s),!0}catch{return false}}function Tn(s){return typeof s=="string"?s:JSON.stringify(s)}function _n(s){return !s.tools||s.tools.length===0?{}:{tools:s.tools.map(t=>{if(!t.name)throw new Ze(t.name||"unknown","name");let e=t.inputSchema||t.parameters;if(!e)throw new Ze(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:e}}})}}function Pn(s){let t=[];for(let e of s)try{switch(e.role){case "system":t.push({role:"system",content:e.content});break;case "user":{let i=e.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 e.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 e.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){Et.warn("Failed to convert message",{messageRole:e.role,error:i instanceof Error?i.message:String(i)});}return t}var li=class{constructor(t,e={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"client");this.modelId=t,this.client=new Is(e.baseURL);}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}async doStream(t){let e=oi();Et.debug("Stream request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=Pn(t.prompt),n=_n({tools:t.tools}),o=JSON.stringify({model:this.modelId,messages:i,options:_e,...n}),a=null,l=null,h=w=>{a&&a.enqueue(w),l&&l.enqueue(w);},d=async()=>{try{let w=!0,v=!1,S=!1,k="",b="",R=!1,M=[],E=[],F=()=>{if(E.length>0){for(let O of E)h(O);E.length=0;}},I=null;for await(let O of this.client.streamChat({model:this.modelId,messages:i,options:_e,...n})){if(I&&I.chunkCount++,w){w=!1;let P={type:"response-metadata",id:oi(),modelId:this.modelId,timestamp:new Date(O.created_at)};h(P),I&&I.eventCount++;}if(O.message?.tool_calls){S&&(E.push({type:"reasoning-end",id:"reasoning-0"}),S=!1),v&&(E.push({type:"text-end",id:"txt-0"}),v=!1);for(let P of O.message.tool_calls){if(!P.id||!P.function?.name){let Ot=P.id?"function.name":"id";Et.error("Invalid tool call: missing field",{traceId:e,missingField:Ot,toolCall:void 0}),E.push({type:"error",error:`Invalid tool call: missing ${Ot}`});continue}let A=P.id,D=P.function.name,_=Tn(P.function.arguments),N=M.find(Ot=>Ot.id===A);N?(N.function.arguments+=_,Et.debug("Tool call arguments accumulated",{traceId:e,toolCallId:A,toolName:D,deltaLength:_.length,totalLength:N.function.arguments.length,isComplete:ai(N.function.arguments)}),_&&E.push({type:"tool-input-delta",id:A,delta:_})):(N={id:A,type:"function",function:{name:D,arguments:_},hasFinished:!1},M.push(N),I&&I.toolCallCount++,Et.debug("Tool call received",{traceId:e,toolCallId:A,toolName:D,argumentsLength:_.length,isComplete:ai(_)}),E.push({type:"tool-input-start",id:A,toolName:D}),_&&E.push({type:"tool-input-delta",id:A,delta:_}));let Te=ai(N.function.arguments);!N.hasFinished&&Te&&(Et.debug("Tool call arguments complete",{traceId:e,toolCallId:A,toolName:D,isComplete:Te,argumentsLength:N.function.arguments.length}),E.push({type:"tool-input-end",id:A}),E.push({type:"tool-call",toolCallId:A,toolName:D,input:N.function.arguments}),N.hasFinished=!0);}F(),I&&(I.eventCount+=E.length);}if(O.message?.content){let P=O.message.content;for(b+=P;b.length>0;)if(R){let A=b.indexOf("</think>");if(A===-1){b.length>0&&E.push({type:"reasoning-delta",id:"reasoning-0",delta:b}),b="";break}else {if(A>0){let D=b.substring(0,A);E.push({type:"reasoning-delta",id:"reasoning-0",delta:D});}E.push({type:"reasoning-end",id:"reasoning-0"}),S=!1,R=!1,b=b.substring(A+8);}}else {let A=b.indexOf("<think>");if(A===-1){b.length>0&&(v||(v=!0,E.push({type:"text-start",id:"txt-0"})),E.push({type:"text-delta",id:"txt-0",delta:b}),k+=b),b="";break}else {if(A>0){let D=b.substring(0,A);v||(v=!0,E.push({type:"text-start",id:"txt-0"})),E.push({type:"text-delta",id:"txt-0",delta:D}),k+=D,E.push({type:"text-end",id:"txt-0"}),v=!1;}R=!0,b=b.substring(A+7),S||(S=!0,E.push({type:"reasoning-start",id:"reasoning-0"}));}}}if(F(),I&&(I.eventCount+=E.length),O.done){let P=M.filter(_=>!_.hasFinished);for(let _ of P)E.push({type:"tool-input-end",id:_.id}),E.push({type:"tool-call",toolCallId:_.id,toolName:_.function.name,input:_.function.arguments});b.length>0&&(R?(E.push({type:"reasoning-delta",id:"reasoning-0",delta:b}),E.push({type:"reasoning-end",id:"reasoning-0"})):(v||(v=!0,E.push({type:"text-start",id:"txt-0"})),E.push({type:"text-delta",id:"txt-0",delta:b}),k+=b)),v&&E.push({type:"text-end",id:"txt-0"});let D=M.length>0?"tool-calls":"stop";if(E.push({type:"finish",finishReason:D,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}}}),F(),I&&(I.eventCount+=E.length),I);M.length=0;}}}catch(w){Et.error("Stream processing error",{traceId:e,error:w instanceof Error?w.message:String(w),stack:void 0}),h({type:"error",error:w instanceof Error?w.message:String(w)}),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(w){a=w;}}),u=new ReadableStream({start(w){l=w;}});d();async function*m(w){let v=w.getReader();try{for(;;){let{done:S,value:k}=await v.read();if(S)break;yield k;}}finally{v.releaseLock();}}return {stream:f,fullStream:m(u),request:{body:o},response:{}}}async doGenerate(t){let e=oi();Et.debug("Generate request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let i=Pn(t.prompt),n=_n({tools:t.tools}),o=await this.client.chat({model:this.modelId,messages:i,options:_e,...n}),a=[];if(o.message?.content&&a.push({type:"text",text:o.message.content}),o.message?.tool_calls){Et.debug("Tool calls received in generate",{traceId:e,toolCallCount:o.message.tool_calls.length});for(let d of o.message.tool_calls){let f=d.id||oi(),u=d.function.name,m=Tn(d.function.arguments);Et.debug("Processing tool call in generate",{traceId:e,toolCallId:f,toolName:u,argumentsLength:m.length,isComplete:ai(m)}),a.push({type:"tool-call",toolCallId:f,toolName:u,input:m});}}let l=!!(o.message?.tool_calls&&o.message.tool_calls.length>0),h=An(o.done??false,l,"stop");return Et.debug("Generate request completed",{traceId:e,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:_e,...n})},response:{}}}};var Xt=class{constructor(t,e={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"nativeModel");this.modelId=t,this.nativeModel=new li(t,{baseURL:e.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 Ps=class{constructor(t,e={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"maxEmbeddingsPerCall");c(this,"supportsParallelCalls",true);c(this,"baseURL");this.modelId=t,this.baseURL=e.baseURL||"http://localhost:11434";}async doEmbed(t){let{values:e,abortSignal:i}=t,n=Nt.create({service:"ollama-embedding"});if(!e||e.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:e.length,baseURL:this.baseURL});try{let o=await Promise.all(e.map(l=>this.generateSingleEmbedding(l,i))),a=e.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,e){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:e});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 e=t.match(/[a-zA-Z]/g)?.length||0,i=t.match(/[\u4e00-\u9fa5]/g)?.length||0,n=t.length-e-i;return Math.ceil(e/4)+i+Math.ceil(n*.5)}};var hi=class{constructor(t,e,i={}){c(this,"specificationVersion","v3");c(this,"provider","ollama");c(this,"modelId");c(this,"languageModel");c(this,"options");c(this,"log",Nt.create({service:"ollama-sdk",module:"reranking-model"}));this.modelId=t,this.languageModel=new Xt(t,e),this.options={totalScore:i.totalScore??1,useEnhancedPrompt:i.useEnhancedPrompt??true,promptLanguage:i.promptLanguage??"en"},this.log.debug("OllamaRerankingModel created",{modelId:t,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(t){let{query:e,documents:i,topN:n}=t,o;Array.isArray(i)?o=i:i.type==="text"?o=i.values.map((h,d)=>({content:h,id:`doc_${d+1}`})):o=i.values;let a=n??o.length;if(o.length===0)return {ranking:[],warnings:[]};try{let h=this.buildRerankPrompt(e,o),f=(await this.languageModel.doGenerate({prompt:[{role:"user",content:[{type:"text",text:h}]}],maxOutputTokens:500,temperature:.1})).content.find(m=>m.type==="text")?.text||"",u=this.parseRerankResult(f,o,a);return {ranking:u.results.map(m=>({index:m.index,relevanceScore:m.score,document:m.document})),warnings:u.warnings.map(m=>({type:"other",message:m}))}}catch(h){return this.log.error("Reranking failed",{error:h.message}),{ranking:o.map((f,u)=>({index:u,relevanceScore:this.options.totalScore*(1-u/o.length),document:f})),warnings:[{type:"other",message:`Reranking failed, using original order: ${h.message}`}]}}}buildRerankPrompt(t,e){let i=e.map((n,o)=>{let a=n.id||`doc_${o+1}`,l=n.content.slice(0,300);return `${o+1}. [ID: ${a}] ${l}`}).join(`
1
+ import {Log}from'@easbot/utils';import'path';var X=Object.defineProperty;var ee=(s,t,e)=>t in s?X(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e;var r=(s,t,e)=>ee(s,typeof t!="symbol"?t+"":t,e);var V=class{constructor(t="http://localhost:11434"){r(this,"baseURL",t);}async*streamChat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:true})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);if(!e.body)throw new Error("Response body is null");let o=e.body.getReader(),a=new TextDecoder,n="";try{for(;;){let{done:l,value:c}=await o.read();if(l){if(n.trim())try{yield JSON.parse(n);}catch{}break}n+=a.decode(c,{stream:!0});let u=n.split(`
2
+ `);n=u.pop()||"";for(let b of u){let O=b.trim();if(O)try{yield JSON.parse(O);}catch{}}}}finally{o.releaseLock();}}async chat(t){let e=await fetch(`${this.baseURL}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,stream:false})});if(!e.ok)throw new Error(`Ollama API error: ${e.status} ${e.statusText}`);return e.json()}};var E={numCtx:262144,temperature:.7,topK:40,topP:.9,repeatPenalty:1.1,numPredict:32e3},te=["numCtx","repeatPenalty","numPredict"];var L=class extends Error{constructor(e,o){super(e);r(this,"cause",o);this.name="OllamaError",Object.setPrototypeOf(this,new.target.prototype);}},G=class extends L{constructor(e,o,a){super(e,a);r(this,"url",o);this.name="ConnectionError";}},z=class extends L{constructor(e,o){super(`Model not found: ${e}`,o);r(this,"modelId",e);this.name="ModelNotFoundError";}},B=class extends L{constructor(e,o,a,n){super(e,n);r(this,"field",o);r(this,"value",a);this.name="ValidationError";}},W=class extends L{constructor(e,o,a){super(e,a);r(this,"timeoutMs",o);this.name="TimeoutError";}},A=class extends L{constructor(e,o,a){super(`Invalid tool definition for "${e}": missing ${o}`,a);r(this,"toolName",e);r(this,"missingField",o);this.name="InvalidToolDefinitionError";}};function K(s,t,e){let o;return t?o="tool-calls":s?o="stop":o="other",{unified:o,raw:e}}var x=Log.create({service:"ollama-sdk",module:"native-language-model"});function U(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function F(s){if(!s||s.trim().length===0)return false;try{return JSON.parse(s),!0}catch{return false}}function Y(s){return typeof s=="string"?s:JSON.stringify(s)}function Z(s){return !s.tools||s.tools.length===0?{}:{tools:s.tools.map(t=>{if(!t.name)throw new A(t.name||"unknown","name");let e=t.inputSchema||t.parameters;if(!e)throw new A(t.name,"inputSchema");return {type:"function",function:{name:t.name,description:t.description,parameters:e}}})}}function H(s){let t=[];for(let e of s)try{switch(e.role){case "system":t.push({role:"system",content:e.content});break;case "user":{let o=e.content.filter(a=>a.type==="text").map(a=>a.text).join(`
3
+ `);o&&t.push({role:"user",content:o});break}case "assistant":{let o="",a=[];for(let n of e.content)if(n.type==="text")o+=n.text;else if(n.type==="tool-call"){let l=n;a.push({id:l.toolCallId,type:"function",function:{name:l.toolName,arguments:JSON.stringify(l.input)}});}t.push({role:"assistant",content:o||null,tool_calls:a.length>0?a:void 0});break}case "tool":for(let o of e.content){let a=o.output,n;switch(a.type){case "text":case "error-text":n=a.value;break;case "content":case "json":case "error-json":n=JSON.stringify(a.value);break;default:n=String(a.value);break}t.push({role:"tool",tool_call_id:o.toolCallId,content:n});}break}}catch(o){x.warn("Failed to convert message",{messageRole:e.role,error:o instanceof Error?o.message:String(o)});}return t}var q=class{constructor(t,e={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"defaultObjectGenerationMode","json");r(this,"supportedUrls",{});r(this,"client");this.modelId=t,this.client=new V(e.baseURL);}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}async doStream(t){let e=U();x.debug("Stream request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let o=H(t.prompt),a=Z({tools:t.tools}),n=JSON.stringify({model:this.modelId,messages:o,options:E,...a}),l=null,c=null,u=m=>{l&&l.enqueue(m),c&&c.enqueue(m);},b=async()=>{try{let m=!0,M=!1,w=!1,P="",p="",$=!1,T=[],d=[],J=()=>{if(d.length>0){for(let v of d)u(v);d.length=0;}},y=null;for await(let v of this.client.streamChat({model:this.modelId,messages:o,options:E,...a})){if(y&&y.chunkCount++,m){m=!1;let k={type:"response-metadata",id:U(),modelId:this.modelId,timestamp:new Date(v.created_at)};u(k),y&&y.eventCount++;}if(v.message?.tool_calls){w&&(d.push({type:"reasoning-end",id:"reasoning-0"}),w=!1),M&&(d.push({type:"text-end",id:"txt-0"}),M=!1);for(let k of v.message.tool_calls){if(!k.id||!k.function?.name){let D=k.id?"function.name":"id";x.error("Invalid tool call: missing field",{traceId:e,missingField:D,toolCall:void 0}),d.push({type:"error",error:`Invalid tool call: missing ${D}`});continue}let f=k.id,C=k.function.name,h=Y(k.function.arguments),S=T.find(D=>D.id===f);S?(S.function.arguments+=h,x.debug("Tool call arguments accumulated",{traceId:e,toolCallId:f,toolName:C,deltaLength:h.length,totalLength:S.function.arguments.length,isComplete:F(S.function.arguments)}),h&&d.push({type:"tool-input-delta",id:f,delta:h})):(S={id:f,type:"function",function:{name:C,arguments:h},hasFinished:!1},T.push(S),y&&y.toolCallCount++,x.debug("Tool call received",{traceId:e,toolCallId:f,toolName:C,argumentsLength:h.length,isComplete:F(h)}),d.push({type:"tool-input-start",id:f,toolName:C}),h&&d.push({type:"tool-input-delta",id:f,delta:h}));let Q=F(S.function.arguments);!S.hasFinished&&Q&&(x.debug("Tool call arguments complete",{traceId:e,toolCallId:f,toolName:C,isComplete:Q,argumentsLength:S.function.arguments.length}),d.push({type:"tool-input-end",id:f}),d.push({type:"tool-call",toolCallId:f,toolName:C,input:S.function.arguments}),S.hasFinished=!0);}J(),y&&(y.eventCount+=d.length);}if(v.message?.content){let k=v.message.content;for(p+=k;p.length>0;)if($){let f=p.indexOf("</think>");if(f===-1){p.length>0&&d.push({type:"reasoning-delta",id:"reasoning-0",delta:p}),p="";break}else {if(f>0){let C=p.substring(0,f);d.push({type:"reasoning-delta",id:"reasoning-0",delta:C});}d.push({type:"reasoning-end",id:"reasoning-0"}),w=!1,$=!1,p=p.substring(f+8);}}else {let f=p.indexOf("<think>");if(f===-1){p.length>0&&(M||(M=!0,d.push({type:"text-start",id:"txt-0"})),d.push({type:"text-delta",id:"txt-0",delta:p}),P+=p),p="";break}else {if(f>0){let C=p.substring(0,f);M||(M=!0,d.push({type:"text-start",id:"txt-0"})),d.push({type:"text-delta",id:"txt-0",delta:C}),P+=C,d.push({type:"text-end",id:"txt-0"}),M=!1;}$=!0,p=p.substring(f+7),w||(w=!0,d.push({type:"reasoning-start",id:"reasoning-0"}));}}}if(J(),y&&(y.eventCount+=d.length),v.done){let k=T.filter(h=>!h.hasFinished);for(let h of k)d.push({type:"tool-input-end",id:h.id}),d.push({type:"tool-call",toolCallId:h.id,toolName:h.function.name,input:h.function.arguments});p.length>0&&($?(d.push({type:"reasoning-delta",id:"reasoning-0",delta:p}),d.push({type:"reasoning-end",id:"reasoning-0"})):(M||(M=!0,d.push({type:"text-start",id:"txt-0"})),d.push({type:"text-delta",id:"txt-0",delta:p}),P+=p)),M&&d.push({type:"text-end",id:"txt-0"});let C=T.length>0?"tool-calls":"stop";if(d.push({type:"finish",finishReason:C,usage:{inputTokens:{total:v.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:v.eval_count||0,text:void 0,reasoning:void 0}},providerMetadata:{ollama:{totalDuration:v.total_duration||0,loadDuration:v.load_duration||0,promptEvalDuration:v.prompt_eval_duration||0,evalDuration:v.eval_duration||0}}}),J(),y&&(y.eventCount+=d.length),y);T.length=0;}}}catch(m){x.error("Stream processing error",{traceId:e,error:m instanceof Error?m.message:String(m),stack:void 0}),u({type:"error",error:m instanceof Error?m.message:String(m)}),u({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{l&&l.close(),c&&c.close();}},O=new ReadableStream({start(m){l=m;}}),i=new ReadableStream({start(m){c=m;}});b();async function*g(m){let M=m.getReader();try{for(;;){let{done:w,value:P}=await M.read();if(w)break;yield P;}}finally{M.releaseLock();}}return {stream:O,fullStream:g(i),request:{body:n},response:{}}}async doGenerate(t){let e=U();x.debug("Generate request started",{traceId:e,modelId:this.modelId,hasTools:!!t.tools&&t.tools.length>0,toolCount:t.tools?.length||0,messageCount:t.prompt.length});let o=H(t.prompt),a=Z({tools:t.tools}),n=await this.client.chat({model:this.modelId,messages:o,options:E,...a}),l=[];if(n.message?.content&&l.push({type:"text",text:n.message.content}),n.message?.tool_calls){x.debug("Tool calls received in generate",{traceId:e,toolCallCount:n.message.tool_calls.length});for(let b of n.message.tool_calls){let O=b.id||U(),i=b.function.name,g=Y(b.function.arguments);x.debug("Processing tool call in generate",{traceId:e,toolCallId:O,toolName:i,argumentsLength:g.length,isComplete:F(g)}),l.push({type:"tool-call",toolCallId:O,toolName:i,input:g});}}let c=!!(n.message?.tool_calls&&n.message.tool_calls.length>0),u=K(n.done??false,c,"stop");return x.debug("Generate request completed",{traceId:e,finishReason:u,contentParts:l.length,hasToolCalls:c,inputTokens:n.prompt_eval_count||0,outputTokens:n.eval_count||0}),{content:l,finishReason:u,usage:{inputTokens:{total:n.prompt_eval_count||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:n.eval_count||0,text:void 0,reasoning:void 0}},providerMetadata:{ollama:{totalDuration:n.total_duration||0,loadDuration:n.load_duration||0,promptEvalDuration:n.prompt_eval_duration||0,evalDuration:n.eval_duration||0}},request:{body:JSON.stringify({model:this.modelId,messages:o,options:E,...a})},response:{}}}};var _=class{constructor(t,e={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"defaultObjectGenerationMode","json");r(this,"supportedUrls",{});r(this,"nativeModel");this.modelId=t,this.nativeModel=new q(t,{baseURL:e.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 N=class{constructor(t,e={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"maxEmbeddingsPerCall");r(this,"supportsParallelCalls",true);r(this,"baseURL");this.modelId=t,this.baseURL=e.baseURL||"http://localhost:11434";}async doEmbed(t){let{values:e,abortSignal:o}=t,a=Log.create({service:"ollama-embedding"});if(!e||e.length===0)return a.warn("Empty values array provided",{modelId:this.modelId}),{embeddings:[],usage:{tokens:0},warnings:[]};a.debug("Generating text embeddings",{modelId:this.modelId,valuesCount:e.length,baseURL:this.baseURL});try{let n=await Promise.all(e.map(c=>this.generateSingleEmbedding(c,o))),l=e.reduce((c,u)=>c+this.estimateTokens(u),0);return a.debug("Text embeddings generated successfully",{modelId:this.modelId,embeddingsCount:n.length,totalTokens:l}),{embeddings:n,usage:{tokens:l},warnings:[]}}catch(n){throw a.error("Text embedding generation failed",{modelId:this.modelId,error:n instanceof Error?n.message:String(n),stack:void 0}),n}}async generateSingleEmbedding(t,e){let o=`${this.baseURL}/api/embeddings`;try{let a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:this.modelId,prompt:t}),signal:e});if(!a.ok){let l=await a.text();throw new Error(`Ollama embedding API error (${a.status}): ${l}`)}let n=await a.json();if(!n.embedding||!Array.isArray(n.embedding))throw new Error("Invalid response format from Ollama embedding API");return n.embedding}catch(a){throw a instanceof TypeError&&a.message.includes("fetch")?new Error(`Failed to connect to Ollama server at ${this.baseURL}: ${a.message}`):a}}estimateTokens(t){let e=t.match(/[a-zA-Z]/g)?.length||0,o=t.match(/[\u4e00-\u9fa5]/g)?.length||0,a=t.length-e-o;return Math.ceil(e/4)+o+Math.ceil(a*.5)}};var j=class{constructor(t,e,o={}){r(this,"specificationVersion","v3");r(this,"provider","ollama");r(this,"modelId");r(this,"languageModel");r(this,"options");r(this,"log",Log.create({service:"ollama-sdk",module:"reranking-model"}));this.modelId=t,this.languageModel=new _(t,e),this.options={totalScore:o.totalScore??1,useEnhancedPrompt:o.useEnhancedPrompt??true,promptLanguage:o.promptLanguage??"en"},this.log.debug("OllamaRerankingModel created",{modelId:t,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(t){let{query:e,documents:o,topN:a}=t,n;Array.isArray(o)?n=o:o.type==="text"?n=o.values.map((u,b)=>({content:u,id:`doc_${b+1}`})):n=o.values;let l=a??n.length;if(n.length===0)return {ranking:[],warnings:[]};try{let u=this.buildRerankPrompt(e,n),O=(await this.languageModel.doGenerate({prompt:[{role:"user",content:[{type:"text",text:u}]}],maxOutputTokens:500,temperature:.1})).content.find(g=>g.type==="text")?.text||"",i=this.parseRerankResult(O,n,l);return {ranking:i.results.map(g=>({index:g.index,relevanceScore:g.score,document:g.document})),warnings:i.warnings.map(g=>({type:"other",message:g}))}}catch(u){return this.log.error("Reranking failed",{error:u.message}),{ranking:n.map((O,i)=>({index:i,relevanceScore:this.options.totalScore*(1-i/n.length),document:O})),warnings:[{type:"other",message:`Reranking failed, using original order: ${u.message}`}]}}}buildRerankPrompt(t,e){let o=e.map((a,n)=>{let l=a.id||`doc_${n+1}`,c=a.content.slice(0,300);return `${n+1}. [ID: ${l}] ${c}`}).join(`
7
4
 
8
5
  `);if(this.options.promptLanguage==="en")return `You are a professional information retrieval reranking expert. Please rank the following documents according to the query.
9
6
 
10
7
  User query: ${t}
11
8
 
12
9
  Documents to rank:
13
- ${i}
10
+ ${o}
14
11
 
15
12
  Please rank the documents according to the following requirements:
16
13
  1. Carefully analyze the user's query intent and key information needs
@@ -27,12 +24,12 @@ The actual score for each position should be calculated dynamically. For example
27
24
 
28
25
  Example output format: 2,5,1,4,3
29
26
 
30
- Please only output the ranked document numbers separated by commas, do not include the actual scores.`;{let n=this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u4FE1\u606F\u68C0\u7D22\u91CD\u6392\u5E8F\u4E13\u5BB6\u3002\u8BF7\u6839\u636E\u7528\u6237\u67E5\u8BE2\u5BF9\u6587\u6863\u8FDB\u884C\u76F8\u5173\u6027\u6392\u5E8F\u3002
27
+ Please only output the ranked document numbers separated by commas, do not include the actual scores.`;{let a=this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u4FE1\u606F\u68C0\u7D22\u91CD\u6392\u5E8F\u4E13\u5BB6\u3002\u8BF7\u6839\u636E\u7528\u6237\u67E5\u8BE2\u5BF9\u6587\u6863\u8FDB\u884C\u76F8\u5173\u6027\u6392\u5E8F\u3002
31
28
 
32
29
  \u7528\u6237\u67E5\u8BE2\uFF1A${t}
33
30
 
34
31
  \u5F85\u6392\u5E8F\u6587\u6863\uFF1A
35
- ${i}
32
+ ${o}
36
33
 
37
34
  \u8BF7\u6309\u7167\u4EE5\u4E0B\u8981\u6C42\u8FDB\u884C\u6392\u5E8F\uFF1A
38
35
  1. \u4ED4\u7EC6\u5206\u6790\u7528\u6237\u67E5\u8BE2\u7684\u610F\u56FE\u548C\u5173\u952E\u4FE1\u606F\u9700\u6C42
@@ -40,9 +37,8 @@ ${i}
40
37
  3. \u8003\u8651\u6587\u6863\u7684\u5B8C\u6574\u6027\u3001\u51C6\u786E\u6027\u548C\u5B9E\u7528\u6027
41
38
  4. \u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u6587\u6863\u7F16\u53F7\uFF0C\u7528\u9017\u53F7\u5206\u9694
42
39
  5. \u6700\u76F8\u5173\u7684\u6587\u6863\u6392\u5728\u6700\u524D\u9762
43
- 6. \u8BF7\u4F7F\u7528 ${n} \u5206\u503C\u8FDB\u884C\u8BC4\u5206
40
+ 6. \u8BF7\u4F7F\u7528 ${a} \u5206\u503C\u8FDB\u884C\u8BC4\u5206
44
41
 
45
42
  \u793A\u4F8B\u8F93\u51FA\u683C\u5F0F\uFF1A2,5,1,4,3
46
43
 
47
- \u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}}parseRerankResult(t,e,i){let n=[];try{let o=t.match(/\d+/g)?.map(u=>parseInt(u,10)-1).filter(u=>u>=0&&u<e.length)||[],a=[],l=new Set;for(let u of o)l.has(u)||(l.add(u),a.push(u));let h=[];for(let u=0;u<a.length;u++){let m=a[u];if(m!==void 0&&m>=0&&m<e.length){let w=e[m];w&&h.push({index:m,score:this.options.totalScore*(1-u/a.length),document:w});}}let d=new Set(a);for(let u=0;u<e.length;u++)if(!d.has(u)){let m=this.options.totalScore*.1*(1-u/e.length);h.push({index:u,score:m,document:e[u]});}let f=i?h.slice(0,i):h;return this.log.debug("Parsed rerank results",{extractedNumbers:o,uniqueIndices:a,resultCount:f.length,topK:i}),{results:f,warnings:n}}catch(o){return this.log.error("Failed to parse rerank result",{error:o.message,text:t}),{results:e.map((l,h)=>({index:h,score:this.options.totalScore*(1-h/e.length),document:l})),warnings:[`Failed to parse rerank result: ${o.message}`]}}}};function Wa(s={}){if(s.logDir){let e=s.logLevel??"INFO",i=ni.join(s.logDir,"ollama-sdk.log");Nt.init({print:process.argv.includes("--print-logs"),logDir:s.logDir,level:e,logFile:"ollama-sdk.log"}).then(()=>{Nt.create({service:"ollama-sdk",module:"provider"}).debug("Ollama provider created",{baseURL:s.baseURL||"http://localhost:11434",logFile:i,logLevel:e});});}return Object.assign(e=>new Xt(e,s),{languageModel:e=>new Xt(e,s),chat:e=>new Xt(e,s),embeddingModel:e=>new Ps(e,s),rerankingModel:(e,i)=>new hi(e,s,i)})}var $a="0.1.0";
48
- export{di as ConnectionError,pi as ModelNotFoundError,_e as OLLAMA_DEFAULT_OPTIONS,Nn as OLLAMA_SPECIFIC_PARAMS,Ps as OllamaEmbeddingModel,ee as OllamaError,Xt as OllamaLanguageModel,gi as TimeoutError,$a as VERSION,fi as ValidationError,Wa as createOllama};
44
+ \u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}}parseRerankResult(t,e,o){let a=[];try{let n=t.match(/\d+/g)?.map(i=>parseInt(i,10)-1).filter(i=>i>=0&&i<e.length)||[],l=[],c=new Set;for(let i of n)c.has(i)||(c.add(i),l.push(i));let u=[];for(let i=0;i<l.length;i++){let g=l[i];if(g!==void 0&&g>=0&&g<e.length){let m=e[g];m&&u.push({index:g,score:this.options.totalScore*(1-i/l.length),document:m});}}let b=new Set(l);for(let i=0;i<e.length;i++)if(!b.has(i)){let g=this.options.totalScore*.1*(1-i/e.length);u.push({index:i,score:g,document:e[i]});}let O=o?u.slice(0,o):u;return this.log.debug("Parsed rerank results",{extractedNumbers:n,uniqueIndices:l,resultCount:O.length,topK:o}),{results:O,warnings:a}}catch(n){return this.log.error("Failed to parse rerank result",{error:n.message,text:t}),{results:e.map((c,u)=>({index:u,score:this.options.totalScore*(1-u/e.length),document:c})),warnings:[`Failed to parse rerank result: ${n.message}`]}}}};function re(s={}){return Object.assign(e=>new _(e,s),{languageModel:e=>new _(e,s),chat:e=>new _(e,s),embeddingModel:e=>new N(e,s),rerankingModel:(e,o)=>new j(e,s,o)})}var se="0.1.0";export{G as ConnectionError,z as ModelNotFoundError,E as OLLAMA_DEFAULT_OPTIONS,te as OLLAMA_SPECIFIC_PARAMS,N as OllamaEmbeddingModel,L as OllamaError,_ as OllamaLanguageModel,W as TimeoutError,se as VERSION,B as ValidationError,re as createOllama};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easbot/ollama-sdk",
3
- "version": "0.2.48",
3
+ "version": "0.3.0",
4
4
  "description": "Ollama provider for Vercel AI SDK - Run local LLMs with Ollama in your AI applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -44,8 +44,8 @@
44
44
  "ai": "^6.0.176",
45
45
  "axios": "^1.16.1",
46
46
  "zod": "^4.4.3",
47
- "@easbot/types": "0.2.48",
48
- "@easbot/utils": "0.2.48"
47
+ "@easbot/types": "0.3.0",
48
+ "@easbot/utils": "0.3.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@biomejs/biome": "^2.4.14",