@easbot/local-model-sdk 0.1.7 → 0.1.11

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,24 +1,24 @@
1
- 'use strict';var transformers=require('@huggingface/transformers'),Zs=require('os'),ti=require('path'),z=require('fs'),_n=require('fs/promises'),qa=require('zod'),url=require('url'),events=require('events'),hn=require('stream'),string_decoder=require('string_decoder');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Zs__namespace=/*#__PURE__*/_interopNamespace(Zs);var ti__namespace=/*#__PURE__*/_interopNamespace(ti);var z__namespace=/*#__PURE__*/_interopNamespace(z);var _n__default=/*#__PURE__*/_interopDefault(_n);var qa__default=/*#__PURE__*/_interopDefault(qa);var hn__default=/*#__PURE__*/_interopDefault(hn);var Gn=Object.defineProperty;var Ys=i=>{throw TypeError(i)};var qn=(i,t,e)=>t in i?Gn(i,t,{enumerable:true,configurable:true,writable:true,value:e}):i[t]=e;var c=(i,t,e)=>qn(i,typeof t!="symbol"?t+"":t,e),bs=(i,t,e)=>t.has(i)||Ys("Cannot "+e);var r=(i,t,e)=>(bs(i,t,"read from private field"),e?e.call(i):t.get(i)),w=(i,t,e)=>t.has(i)?Ys("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),u=(i,t,e,s)=>(bs(i,t,"write to private field"),t.set(i,e),e),m=(i,t,e)=>(bs(i,t,"access private method"),e);var Wi=(i,t,e,s)=>({set _(n){u(i,t,n);},get _(){return r(i,t,s)}});var gt=(g=>(g.MODEL_NOT_FOUND="MODEL_NOT_FOUND",g.MODEL_LOAD_ERROR="MODEL_LOAD_ERROR",g.MODEL_NOT_INITIALIZED="MODEL_NOT_INITIALIZED",g.GENERATION_ERROR="GENERATION_ERROR",g.EMBEDDING_ERROR="EMBEDDING_ERROR",g.INVALID_INPUT="INVALID_INPUT",g.UNSUPPORTED_FEATURE="UNSUPPORTED_FEATURE",g.CACHE_ERROR="CACHE_ERROR",g.PROCESSING_ERROR="PROCESSING_ERROR",g.ABORTED="ABORTED",g.OUT_OF_MEMORY="OUT_OF_MEMORY",g.UNKNOWN_ERROR="UNKNOWN_ERROR",g))(gt||{});function ji(i,t,e){let s;return t?s="error":i?s="stop":s="other",{unified:s,raw:e}}var kt={"qwen3-0.6b":{modelId:"qwen3-0.6b",huggingFaceId:"onnx-community/Qwen3-0.6B-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}},"gemma-3-1b-it":{modelId:"gemma-3-1b-it",huggingFaceId:"onnx-community/gemma-3-1b-it-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}}},be={"bge-small-zh-v1.5":{modelId:"bge-small-zh-v1.5",huggingFaceId:"Xenova/bge-small-zh-v1.5",dimensions:512,maxEmbeddingsPerCall:32},"bge-base-zh-v1.5":{modelId:"bge-base-zh-v1.5",huggingFaceId:"Xenova/bge-base-zh-v1.5",dimensions:768,maxEmbeddingsPerCall:32},"bge-large-zh-v1.5":{modelId:"bge-large-zh-v1.5",huggingFaceId:"Xenova/bge-large-zh-v1.5",dimensions:1024,maxEmbeddingsPerCall:32},"all-MiniLM-L6-v2":{modelId:"all-MiniLM-L6-v2",huggingFaceId:"sentence-transformers/all-MiniLM-L6-v2",dimensions:384,maxEmbeddingsPerCall:32}};var x=class i extends Error{constructor(e,s,n){super(e);this.code=s;this.cause=n;this.name="LocalModelError",Error.captureStackTrace&&Error.captureStackTrace(this,i);}},nt=class{static modelLoadError(t){return new x(`\u6A21\u578B\u52A0\u8F7D\u5931\u8D25: ${t.message}`,"MODEL_LOAD_ERROR",t)}static generationError(t){return new x(`\u751F\u6210\u5931\u8D25: ${t.message}`,"GENERATION_ERROR",t)}static embeddingError(t){return new x(`\u5D4C\u5165\u5931\u8D25: ${t.message}`,"EMBEDDING_ERROR",t)}static validationError(t){return new x(t,"INVALID_INPUT")}static abortError(){return new x("\u64CD\u4F5C\u5DF2\u4E2D\u6B62","ABORTED")}static unsupportedFeature(t){return new x(`\u4E0D\u652F\u6301\u7684\u529F\u80FD: ${t}`,"UNSUPPORTED_FEATURE")}};var Vn=ti__namespace.join(Zs__namespace.homedir(),".cache","easbot","models"),Fe=class{constructor(t){c(this,"cacheDir");this.cacheDir=t.cacheDir||Vn;}getCachePath(t){return ti__namespace.join(this.cacheDir,t)}isCached(t){try{let e=this.getCachePath(t);return z__namespace.existsSync(e)&&z__namespace.statSync(e).isDirectory()}catch{return false}}async clear(t){try{if(t){let e=this.getCachePath(t);z__namespace.existsSync(e)&&await this.removeDirectory(e);}else z__namespace.existsSync(this.cacheDir)&&await this.removeDirectory(this.cacheDir);}catch(e){throw new x(`\u6E05\u7406\u7F13\u5B58\u5931\u8D25: ${e instanceof Error?e.message:String(e)}`,"CACHE_ERROR",e instanceof Error?e:void 0)}}async getCacheSize(t){try{let e=t?this.getCachePath(t):this.cacheDir;return z__namespace.existsSync(e)?await this.getDirectorySize(e):0}catch(e){throw new x(`\u83B7\u53D6\u7F13\u5B58\u5927\u5C0F\u5931\u8D25: ${e instanceof Error?e.message:String(e)}`,"CACHE_ERROR",e instanceof Error?e:void 0)}}async getDirectorySize(t){let e=0,s=z__namespace.readdirSync(t);for(let n of s){let o=ti__namespace.join(t,n),a=z__namespace.statSync(o);a.isDirectory()?e+=await this.getDirectorySize(o):e+=a.size;}return e}async removeDirectory(t){if(!z__namespace.existsSync(t))return;let e=z__namespace.readdirSync(t);for(let s of e){let n=ti__namespace.join(t,s);z__namespace.statSync(n).isDirectory()?await this.removeDirectory(n):z__namespace.unlinkSync(n);}z__namespace.rmdirSync(t);}ensureCacheDir(){try{z__namespace.existsSync(this.cacheDir)||z__namespace.mkdirSync(this.cacheDir,{recursive:!0});}catch(t){throw new x(`\u521B\u5EFA\u7F13\u5B58\u76EE\u5F55\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`,"CACHE_ERROR",t instanceof Error?t:void 0)}}};var Gr=(i,t,e)=>{let s=i instanceof RegExp?Xs(i,e):i,n=t instanceof RegExp?Xs(t,e):t,o=s!==null&&n!=null&&Kn(s,n,e);return o&&{start:o[0],end:o[1],pre:e.slice(0,o[0]),body:e.slice(o[0]+s.length,o[1]),post:e.slice(o[1]+n.length)}},Xs=(i,t)=>{let e=t.match(i);return e?e[0]:null},Kn=(i,t,e)=>{let s,n,o,a,h,l=e.indexOf(i),d=e.indexOf(t,l+1),p=l;if(l>=0&&d>0){if(i===t)return [l,d];for(s=[],o=e.length;p>=0&&!h;){if(p===l)s.push(p),l=e.indexOf(i,p+1);else if(s.length===1){let f=s.pop();f!==void 0&&(h=[f,d]);}else n=s.pop(),n!==void 0&&n<o&&(o=n,a=d),d=e.indexOf(t,p+1);p=l<d&&l>=0?l:d;}s.length&&a!==void 0&&(h=[o,a]);}return h},qr="\0SLASH"+Math.random()+"\0",Vr="\0OPEN"+Math.random()+"\0",Ws="\0CLOSE"+Math.random()+"\0",Kr="\0COMMA"+Math.random()+"\0",Hr="\0PERIOD"+Math.random()+"\0",Hn=new RegExp(qr,"g"),Jn=new RegExp(Vr,"g"),Yn=new RegExp(Ws,"g"),Zn=new RegExp(Kr,"g"),Xn=new RegExp(Hr,"g"),Qn=/\\\\/g,to=/\\{/g,eo=/\\}/g,io=/\\,/g,so=/\\./g,ro=1e5;function Ss(i){return isNaN(i)?i.charCodeAt(0):parseInt(i,10)}function no(i){return i.replace(Qn,qr).replace(to,Vr).replace(eo,Ws).replace(io,Kr).replace(so,Hr)}function oo(i){return i.replace(Hn,"\\").replace(Jn,"{").replace(Yn,"}").replace(Zn,",").replace(Xn,".")}function Jr(i){if(!i)return [""];let t=[],e=Gr("{","}",i);if(!e)return i.split(",");let{pre:s,body:n,post:o}=e,a=s.split(",");a[a.length-1]+="{"+n+"}";let h=Jr(o);return o.length&&(a[a.length-1]+=h.shift(),a.push.apply(a,h)),t.push.apply(t,a),t}function ao(i,t={}){if(!i)return [];let{max:e=ro}=t;return i.slice(0,2)==="{}"&&(i="\\{\\}"+i.slice(2)),ai(no(i),e,true).map(oo)}function lo(i){return "{"+i+"}"}function ho(i){return /^-?0\d/.test(i)}function co(i,t){return i<=t}function uo(i,t){return i>=t}function ai(i,t,e){let s=[],n=Gr("{","}",i);if(!n)return [i];let o=n.pre,a=n.post.length?ai(n.post,t,false):[""];if(/\$$/.test(n.pre))for(let h=0;h<a.length&&h<t;h++){let l=o+"{"+n.body+"}"+a[h];s.push(l);}else {let h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),d=h||l,p=n.body.indexOf(",")>=0;if(!d&&!p)return n.post.match(/,(?!,).*\}/)?(i=n.pre+"{"+n.body+Ws+n.post,ai(i,t,true)):[i];let f;if(d)f=n.body.split(/\.\./);else if(f=Jr(n.body),f.length===1&&f[0]!==void 0&&(f=ai(f[0],t,false).map(lo),f.length===1))return a.map(y=>n.pre+f[0]+y);let g;if(d&&f[0]!==void 0&&f[1]!==void 0){let y=Ss(f[0]),S=Ss(f[1]),b=Math.max(f[0].length,f[1].length),T=f.length===3&&f[2]!==void 0?Math.abs(Ss(f[2])):1,E=co;S<y&&(T*=-1,E=uo);let C=f.some(ho);g=[];for(let O=y;E(O,S);O+=T){let P;if(l)P=String.fromCharCode(O),P==="\\"&&(P="");else if(P=String(O),C){let M=b-P.length;if(M>0){let D=new Array(M+1).join("0");O<0?P="-"+D+P.slice(1):P=D+P;}}g.push(P);}}else {g=[];for(let y=0;y<f.length;y++)g.push.apply(g,ai(f[y],t,false));}for(let y=0;y<g.length;y++)for(let S=0;S<a.length&&s.length<t;S++){let b=o+g[y]+a[S];(!e||d||b)&&s.push(b);}}return s}var os=i=>{if(typeof i!="string")throw new TypeError("invalid pattern");if(i.length>65536)throw new TypeError("pattern is too long")},fo={"[: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]},ei=i=>i.replace(/[[\]\\-]/g,"\\$&"),po=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Qs=i=>i.join(""),go=(i,t)=>{let e=t;if(i.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],n=[],o=e+1,a=false,h=false,l=false,d=false,p=e,f="";t:for(;o<i.length;){let S=i.charAt(o);if((S==="!"||S==="^")&&o===e+1){d=true,o++;continue}if(S==="]"&&a&&!l){p=o+1;break}if(a=true,S==="\\"&&!l){l=true,o++;continue}if(S==="["&&!l){for(let[b,[T,E,C]]of Object.entries(fo))if(i.startsWith(b,o)){if(f)return ["$.",false,i.length-e,true];o+=b.length,C?n.push(T):s.push(T),h=h||E;continue t}}if(l=false,f){S>f?s.push(ei(f)+"-"+ei(S)):S===f&&s.push(ei(S)),f="",o++;continue}if(i.startsWith("-]",o+1)){s.push(ei(S+"-")),o+=2;continue}if(i.startsWith("-",o+1)){f=S,o+=2;continue}s.push(ei(S)),o++;}if(p<o)return ["",false,0,false];if(!s.length&&!n.length)return ["$.",false,i.length-e,true];if(n.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!d){let S=s[0].length===2?s[0].slice(-1):s[0];return [po(S),false,p-e,false]}let g="["+(d?"^":"")+Qs(s)+"]",y="["+(d?"":"^")+Qs(n)+"]";return [s.length&&n.length?"("+g+"|"+y+")":s.length?g:y,h,p-e,true]},ze=(i,{windowsPathsNoEscape:t=false,magicalBraces:e=true}={})=>e?t?i.replace(/\[([^\/\\])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?i.replace(/\[([^\/\\{}])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),mo=new Set(["!","?","+","*","@"]),tr=i=>mo.has(i),yo="(?!(?:^|/)\\.\\.?(?:$|/))",Gi="(?!\\.)",wo=new Set(["[","."]),bo=new Set(["..","."]),So=new Set("().*{}+?[]^$\\!"),Eo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),js="[^/]",er=js+"*?",ir=js+"+?",j,Z,Jt,I,$,le,Te,he,jt,xe,pi,Ae,Zr,ge,tt,Xi,ks,Xr,Yr=(tt=class{constructor(t,e,s={}){w(this,Ae);c(this,"type");w(this,j);w(this,Z);w(this,Jt,false);w(this,I,[]);w(this,$);w(this,le);w(this,Te);w(this,he,false);w(this,jt);w(this,xe);w(this,pi,false);this.type=t,t&&u(this,Z,true),u(this,$,e),u(this,j,r(this,$)?r(r(this,$),j):this),u(this,jt,r(this,j)===this?s:r(r(this,j),jt)),u(this,Te,r(this,j)===this?[]:r(r(this,j),Te)),t==="!"&&!r(r(this,j),he)&&r(this,Te).push(this),u(this,le,r(this,$)?r(r(this,$),I).length:0);}get hasMagic(){if(r(this,Z)!==void 0)return r(this,Z);for(let t of r(this,I))if(typeof t!="string"&&(t.type||t.hasMagic))return u(this,Z,true);return r(this,Z)}toString(){return r(this,xe)!==void 0?r(this,xe):this.type?u(this,xe,this.type+"("+r(this,I).map(t=>String(t)).join("|")+")"):u(this,xe,r(this,I).map(t=>String(t)).join(""))}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof tt&&r(e,$)===this))throw new Error("invalid part: "+e);r(this,I).push(e);}}toJSON(){let t=this.type===null?r(this,I).slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...r(this,I).map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===r(this,j)||r(r(this,j),he)&&r(this,$)?.type==="!")&&t.push({}),t}isStart(){if(r(this,j)===this)return true;if(!r(this,$)?.isStart())return false;if(r(this,le)===0)return true;let t=r(this,$);for(let e=0;e<r(this,le);e++){let s=r(t,I)[e];if(!(s instanceof tt&&s.type==="!"))return false}return true}isEnd(){if(r(this,j)===this||r(this,$)?.type==="!")return true;if(!r(this,$)?.isEnd())return false;if(!this.type)return r(this,$)?.isEnd();let t=r(this,$)?r(r(this,$),I).length:0;return r(this,le)===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 s of r(this,I))e.copyIn(s);return e}static fromGlob(t,e={}){var n;let s=new tt(null,void 0,e);return m(n=tt,ge,Xi).call(n,t,s,0,e),s}toMMPattern(){if(this!==r(this,j))return r(this,j).toMMPattern();let t=this.toString(),[e,s,n,o]=this.toRegExpSource();if(!(n||r(this,Z)||r(this,jt).nocase&&!r(this,jt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let a=(r(this,jt).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return r(this,jt)}toRegExpSource(t){let e=t??!!r(this,jt).dot;if(r(this,j)===this&&m(this,Ae,Zr).call(this),!this.type){let l=this.isStart()&&this.isEnd()&&!r(this,I).some(g=>typeof g!="string"),d=r(this,I).map(g=>{var E;let[y,S,b,T]=typeof g=="string"?m(E=tt,ge,Xr).call(E,g,r(this,Z),l):g.toRegExpSource(t);return u(this,Z,r(this,Z)||b),u(this,Jt,r(this,Jt)||T),y}).join(""),p="";if(this.isStart()&&typeof r(this,I)[0]=="string"&&!(r(this,I).length===1&&bo.has(r(this,I)[0]))){let g=wo,y=e&&g.has(d.charAt(0))||d.startsWith("\\.")&&g.has(d.charAt(2))||d.startsWith("\\.\\.")&&g.has(d.charAt(4)),S=!e&&!t&&g.has(d.charAt(0));p=y?yo:S?Gi:"";}let f="";return this.isEnd()&&r(r(this,j),he)&&r(this,$)?.type==="!"&&(f="(?:$|\\/)"),[p+d+f,ze(d),u(this,Z,!!r(this,Z)),r(this,Jt)]}let s=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",o=m(this,Ae,ks).call(this,e);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return u(this,I,[l]),this.type=null,u(this,Z,void 0),[l,ze(this.toString()),false,false]}let a=!s||t||e||!Gi?"":m(this,Ae,ks).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let h="";if(this.type==="!"&&r(this,pi))h=(this.isStart()&&!e?Gi:"")+ir;else {let l=this.type==="!"?"))"+(this.isStart()&&!e&&!t?Gi:"")+er+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;h=n+o+l;}return [h,ze(o),u(this,Z,!!r(this,Z)),r(this,Jt)]}},j=new WeakMap,Z=new WeakMap,Jt=new WeakMap,I=new WeakMap,$=new WeakMap,le=new WeakMap,Te=new WeakMap,he=new WeakMap,jt=new WeakMap,xe=new WeakMap,pi=new WeakMap,Ae=new WeakSet,Zr=function(){if(this!==r(this,j))throw new Error("should only call on root");if(r(this,he))return this;this.toString(),u(this,he,true);let t;for(;t=r(this,Te).pop();){if(t.type!=="!")continue;let e=t,s=r(e,$);for(;s;){for(let n=r(e,le)+1;!s.type&&n<r(s,I).length;n++)for(let o of r(t,I)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(r(s,I)[n]);}e=s,s=r(e,$);}}return this},ge=new WeakSet,Xi=function(t,e,s,n){var y,S;let o=false,a=false,h=-1,l=false;if(e.type===null){let b=s,T="";for(;b<t.length;){let E=t.charAt(b++);if(o||E==="\\"){o=!o,T+=E;continue}if(a){b===h+1?(E==="^"||E==="!")&&(l=true):E==="]"&&!(b===h+2&&l)&&(a=false),T+=E;continue}else if(E==="["){a=true,h=b,l=false,T+=E;continue}if(!n.noext&&tr(E)&&t.charAt(b)==="("){e.push(T),T="";let C=new tt(E,e);b=m(y=tt,ge,Xi).call(y,t,C,b,n),e.push(C);continue}T+=E;}return e.push(T),b}let d=s+1,p=new tt(null,e),f=[],g="";for(;d<t.length;){let b=t.charAt(d++);if(o||b==="\\"){o=!o,g+=b;continue}if(a){d===h+1?(b==="^"||b==="!")&&(l=true):b==="]"&&!(d===h+2&&l)&&(a=false),g+=b;continue}else if(b==="["){a=true,h=d,l=false,g+=b;continue}if(tr(b)&&t.charAt(d)==="("){p.push(g),g="";let T=new tt(b,p);p.push(T),d=m(S=tt,ge,Xi).call(S,t,T,d,n);continue}if(b==="|"){p.push(g),g="",f.push(p),p=new tt(null,e);continue}if(b===")")return g===""&&r(e,I).length===0&&u(e,pi,true),p.push(g),g="",e.push(...f,p),d;g+=b;}return e.type=null,u(e,Z,void 0),u(e,I,[t.substring(s-1)]),d},ks=function(t){return r(this,I).map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,n,o,a]=e.toRegExpSource(t);return u(this,Jt,r(this,Jt)||a),s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")},Xr=function(t,e,s=false){let n=false,o="",a=false,h=false;for(let l=0;l<t.length;l++){let d=t.charAt(l);if(n){n=false,o+=(So.has(d)?"\\":"")+d;continue}if(d==="*"){if(h)continue;h=true,o+=s&&/^[*]+$/.test(t)?ir:er,e=true;continue}else h=false;if(d==="\\"){l===t.length-1?o+="\\\\":n=true;continue}if(d==="["){let[p,f,g,y]=go(t,l);if(g){o+=p,a=a||f,l+=g-1,e=e||y;continue}}if(d==="?"){o+=js,e=true;continue}o+=Eo(d);}return [o,ze(t),!!e,a]},w(tt,ge),tt),Qr=(i,{windowsPathsNoEscape:t=false,magicalBraces:e=false}={})=>e?t?i.replace(/[?*()[\]{}]/g,"[$&]"):i.replace(/[?*()[\]\\{}]/g,"\\$&"):t?i.replace(/[?*()[\]]/g,"[$&]"):i.replace(/[?*()[\]\\]/g,"\\$&"),dt=(i,t,e={})=>(os(t),!e.nocomment&&t.charAt(0)==="#"?false:new me(t,e).match(i)),vo=/^\*+([^+@!?\*\[\(]*)$/,To=i=>t=>!t.startsWith(".")&&t.endsWith(i),xo=i=>t=>t.endsWith(i),Mo=i=>(i=i.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(i)),Co=i=>(i=i.toLowerCase(),t=>t.toLowerCase().endsWith(i)),Ro=/^\*+\.\*+$/,ko=i=>!i.startsWith(".")&&i.includes("."),Lo=i=>i!=="."&&i!==".."&&i.includes("."),Oo=/^\.\*+$/,Po=i=>i!=="."&&i!==".."&&i.startsWith("."),Do=/^\*+$/,Ao=i=>i.length!==0&&!i.startsWith("."),Io=i=>i.length!==0&&i!=="."&&i!=="..",No=/^\?+([^+@!?\*\[\(]*)?$/,_o=([i,t=""])=>{let e=tn([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Fo=([i,t=""])=>{let e=en([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Uo=([i,t=""])=>{let e=en([i]);return t?s=>e(s)&&s.endsWith(t):e},Bo=([i,t=""])=>{let e=tn([i]);return t?s=>e(s)&&s.endsWith(t):e},tn=([i])=>{let t=i.length;return e=>e.length===t&&!e.startsWith(".")},en=([i])=>{let t=i.length;return e=>e.length===t&&e!=="."&&e!==".."},sn=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",sr={win32:{sep:"\\"},posix:{sep:"/"}},zo=sn==="win32"?sr.win32.sep:sr.posix.sep;dt.sep=zo;var ct=Symbol("globstar **");dt.GLOBSTAR=ct;var $o="[^/]",Wo=$o+"*?",jo="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Go="(?:(?!(?:\\/|^)\\.).)*?",qo=(i,t={})=>e=>dt(e,i,t);dt.filter=qo;var vt=(i,t={})=>Object.assign({},i,t),Vo=i=>{if(!i||typeof i!="object"||!Object.keys(i).length)return dt;let t=dt;return Object.assign((e,s,n={})=>t(e,s,vt(i,n)),{Minimatch:class extends t.Minimatch{constructor(e,s={}){super(e,vt(i,s));}static defaults(e){return t.defaults(vt(i,e)).Minimatch}},AST:class extends t.AST{constructor(e,s,n={}){super(e,s,vt(i,n));}static fromGlob(e,s={}){return t.AST.fromGlob(e,vt(i,s))}},unescape:(e,s={})=>t.unescape(e,vt(i,s)),escape:(e,s={})=>t.escape(e,vt(i,s)),filter:(e,s={})=>t.filter(e,vt(i,s)),defaults:e=>t.defaults(vt(i,e)),makeRe:(e,s={})=>t.makeRe(e,vt(i,s)),braceExpand:(e,s={})=>t.braceExpand(e,vt(i,s)),match:(e,s,n={})=>t.match(e,s,vt(i,n)),sep:t.sep,GLOBSTAR:ct})};dt.defaults=Vo;var rn=(i,t={})=>(os(i),t.nobrace||!/\{(?:(?!\{).)*\}/.test(i)?[i]:ao(i,{max:t.braceExpandMax}));dt.braceExpand=rn;var Ko=(i,t={})=>new me(i,t).makeRe();dt.makeRe=Ko;var Ho=(i,t,e={})=>{let s=new me(t,e);return i=i.filter(n=>s.match(n)),s.options.nonull&&!i.length&&i.push(t),i};dt.match=Ho;var rr=/[?*]|[+@!]\(.*?\)|\[|\]/,Jo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),me=class{constructor(i,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");os(i),t=t||{},this.options=t,this.pattern=i,this.platform=t.platform||sn,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 i of this.set)for(let t of i)if(typeof t!="string")return true;return false}debug(...i){}make(){let i=this.pattern,t=this.options;if(!t.nocomment&&i.charAt(0)==="#"){this.comment=true;return}if(!i){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 s=this.globParts.map((n,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=n[0]===""&&n[1]===""&&(n[2]==="?"||!rr.test(n[2]))&&!rr.test(n[3]),l=/^[a-z]:/i.test(n[0]);if(h)return [...n.slice(0,4),...n.slice(4).map(d=>this.parse(d))];if(l)return [n[0],...n.slice(1).map(d=>this.parse(d))]}return n.map(h=>this.parse(h))});if(this.debug(this.pattern,s),this.set=s.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(i){if(this.options.noglobstar)for(let e=0;e<i.length;e++)for(let s=0;s<i[e].length;s++)i[e][s]==="**"&&(i[e][s]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(i=this.firstPhasePreProcess(i),i=this.secondPhasePreProcess(i)):t>=1?i=this.levelOneOptimize(i):i=this.adjascentGlobstarOptimize(i),i}adjascentGlobstarOptimize(i){return i.map(t=>{let e=-1;for(;(e=t.indexOf("**",e+1))!==-1;){let s=e;for(;t[s+1]==="**";)s++;s!==e&&t.splice(e,s-e);}return t})}levelOneOptimize(i){return i.map(t=>(t=t.reduce((e,s)=>{let n=e[e.length-1];return s==="**"&&n==="**"?e:s===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(e.pop(),e):(e.push(s),e)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(i){Array.isArray(i)||(i=this.slashSplit(i));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let s=1;s<i.length-1;s++){let n=i[s];s===1&&n===""&&i[0]===""||(n==="."||n==="")&&(t=true,i.splice(s,1),s--);}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(t=true,i.pop());}let e=0;for(;(e=i.indexOf("..",e+1))!==-1;){let s=i[e-1];s&&s!=="."&&s!==".."&&s!=="**"&&(t=true,i.splice(e-1,2),e-=2);}}while(t);return i.length===0?[""]:i}firstPhasePreProcess(i){let t=false;do{t=false;for(let e of i){let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let o=s;for(;e[o+1]==="**";)o++;o>s&&e.splice(s+1,o-s);let a=e[s+1],h=e[s+2],l=e[s+3];if(a!==".."||!h||h==="."||h===".."||!l||l==="."||l==="..")continue;t=true,e.splice(s,1);let d=e.slice(0);d[s]="**",i.push(d),s--;}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 i}secondPhasePreProcess(i){for(let t=0;t<i.length-1;t++)for(let e=t+1;e<i.length;e++){let s=this.partsMatch(i[t],i[e],!this.preserveMultipleSlashes);if(s){i[t]=[],i[e]=s;break}}return i.filter(t=>t.length)}partsMatch(i,t,e=false){let s=0,n=0,o=[],a="";for(;s<i.length&&n<t.length;)if(i[s]===t[n])o.push(a==="b"?t[n]:i[s]),s++,n++;else if(e&&i[s]==="**"&&t[n]===i[s+1])o.push(i[s]),s++;else if(e&&t[n]==="**"&&i[s]===t[n+1])o.push(t[n]),n++;else if(i[s]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="b")return false;a="a",o.push(i[s]),s++,n++;}else if(t[n]==="*"&&i[s]&&(this.options.dot||!i[s].startsWith("."))&&i[s]!=="**"){if(a==="a")return false;a="b",o.push(t[n]),s++,n++;}else return false;return i.length===t.length&&o}parseNegate(){if(this.nonegate)return;let i=this.pattern,t=false,e=0;for(let s=0;s<i.length&&i.charAt(s)==="!";s++)t=!t,e++;e&&(this.pattern=i.slice(e)),this.negate=t;}matchOne(i,t,e=false){let s=this.options;if(this.isWindows){let S=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),b=!S&&i[0]===""&&i[1]===""&&i[2]==="?"&&/^[a-z]:$/i.test(i[3]),T=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),E=!T&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),C=b?3:S?0:void 0,O=E?3:T?0:void 0;if(typeof C=="number"&&typeof O=="number"){let[P,M]=[i[C],t[O]];P.toLowerCase()===M.toLowerCase()&&(t[O]=P,O>C?t=t.slice(O):C>O&&(i=i.slice(C)));}}let{optimizationLevel:n=1}=this.options;n>=2&&(i=this.levelTwoFileOptimize(i)),this.debug("matchOne",this,{file:i,pattern:t}),this.debug("matchOne",i.length,t.length);for(var o=0,a=0,h=i.length,l=t.length;o<h&&a<l;o++,a++){this.debug("matchOne loop");var d=t[a],p=i[o];if(this.debug(t,d,p),d===false)return false;if(d===ct){this.debug("GLOBSTAR",[t,d,p]);var f=o,g=a+1;if(g===l){for(this.debug("** at the end");o<h;o++)if(i[o]==="."||i[o]===".."||!s.dot&&i[o].charAt(0)===".")return false;return true}for(;f<h;){var y=i[f];if(this.debug(`
2
- globstar while`,i,f,t,g,y),this.matchOne(i.slice(f),t.slice(g),e))return this.debug("globstar found match!",f,h,y),true;if(y==="."||y===".."||!s.dot&&y.charAt(0)==="."){this.debug("dot detected!",i,f,t,g);break}this.debug("globstar swallow a segment, and continue"),f++;}return !!(e&&(this.debug(`
3
- >>> no match, partial?`,i,f,t,g),f===h))}let S;if(typeof d=="string"?(S=p===d,this.debug("string match",d,p,S)):(S=d.test(p),this.debug("pattern match",d,p,S)),!S)return false}if(o===h&&a===l)return true;if(o===h)return e;if(a===l)return o===h-1&&i[o]==="";throw new Error("wtf?")}braceExpand(){return rn(this.pattern,this.options)}parse(i){os(i);let t=this.options;if(i==="**")return ct;if(i==="")return "";let e,s=null;(e=i.match(Do))?s=t.dot?Io:Ao:(e=i.match(vo))?s=(t.nocase?t.dot?Co:Mo:t.dot?xo:To)(e[1]):(e=i.match(No))?s=(t.nocase?t.dot?Fo:_o:t.dot?Uo:Bo)(e):(e=i.match(Ro))?s=t.dot?Lo:ko:(e=i.match(Oo))&&(s=Po);let n=Yr.fromGlob(i,this.options).toMMPattern();return s&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:s}),n}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let i=this.set;if(!i.length)return this.regexp=false,this.regexp;let t=this.options,e=t.noglobstar?Wo:t.dot?jo:Go,s=new Set(t.nocase?["i"]:[]),n=i.map(h=>{let l=h.map(p=>{if(p instanceof RegExp)for(let f of p.flags.split(""))s.add(f);return typeof p=="string"?Jo(p):p===ct?ct:p._src});l.forEach((p,f)=>{let g=l[f+1],y=l[f-1];p!==ct||y===ct||(y===void 0?g!==void 0&&g!==ct?l[f+1]="(?:\\/|"+e+"\\/)?"+g:l[f]=e:g===void 0?l[f-1]=y+"(?:\\/|\\/"+e+")?":g!==ct&&(l[f-1]=y+"(?:\\/|\\/"+e+"\\/)"+g,l[f+1]=ct));});let d=l.filter(p=>p!==ct);if(this.partial&&d.length>=1){let p=[];for(let f=1;f<=d.length;f++)p.push(d.slice(0,f).join("/"));return "(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[o,a]=i.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,[...s].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(i){return this.preserveMultipleSlashes?i.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(i)?["",...i.split(/\/+/)]:i.split(/\/+/)}match(i,t=this.partial){if(this.debug("match",i,this.pattern),this.comment)return false;if(this.empty)return i==="";if(i==="/"&&t)return true;let e=this.options;this.isWindows&&(i=i.split("\\").join("/"));let s=this.slashSplit(i);this.debug(this.pattern,"split",s);let n=this.set;this.debug(this.pattern,"set",n);let o=s[s.length-1];if(!o)for(let a=s.length-2;!o&&a>=0;a--)o=s[a];for(let a=0;a<n.length;a++){let h=n[a],l=s;if(e.matchBase&&h.length===1&&(l=[o]),this.matchOne(l,h,t))return e.flipNegate?true:!this.negate}return e.flipNegate?false:this.negate}static defaults(i){return dt.defaults(i).Minimatch}};dt.AST=Yr;dt.Minimatch=me;dt.escape=Qr;dt.unescape=ze;var Zo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nn=new Set,Ls=typeof process=="object"&&process?process:{},on=(i,t,e,s)=>{typeof Ls.emitWarning=="function"?Ls.emitWarning(i,t,e,s):console.error(`[${e}] ${t}: ${i}`);},as=globalThis.AbortController,nr=globalThis.AbortSignal;if(typeof as>"u"){nr=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(e,s){this._onabort.push(s);}},as=class{constructor(){c(this,"signal",new nr);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let s of this.signal._onabort)s(e);this.signal.onabort?.(e);}}};let i=Ls.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{i&&(i=false,on("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 Xo=i=>!nn.has(i),re=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),an=i=>re(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?Qi:null:null,Qi=class extends Array{constructor(i){super(i),this.fill(0);}},Vt,$e,Qo=(Vt=class{constructor(t,e){c(this,"heap");c(this,"length");if(!r(Vt,$e))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=an(t);if(!e)return [];u(Vt,$e,true);let s=new Vt(t,e);return u(Vt,$e,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},$e=new WeakMap,w(Vt,$e,false),Vt),Sr,Er,xt,yt,Pt,Me,Dt,We,je,At,G,It,W,N,L,at,wt,rt,X,Nt,Q,_t,Ft,bt,St,Ut,ce,lt,Ge,v,Os,Ce,Yt,gi,Et,ln,Re,qe,mi,ne,oe,Ps,ts,es,A,Ds,li,ae,As,Ve,cs=(Ve=class{constructor(t){w(this,v);w(this,xt);w(this,yt);w(this,Pt);w(this,Me);w(this,Dt);w(this,We);w(this,je);w(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");w(this,G);w(this,It);w(this,W);w(this,N);w(this,L);w(this,at);w(this,wt);w(this,rt);w(this,X);w(this,Nt);w(this,Q);w(this,_t);w(this,Ft);w(this,bt);w(this,St);w(this,Ut);w(this,ce);w(this,lt);w(this,Ge);w(this,Ce,()=>{});w(this,Yt,()=>{});w(this,gi,()=>{});w(this,Et,()=>false);w(this,Re,t=>{});w(this,qe,(t,e,s)=>{});w(this,mi,(t,e,s,n)=>{if(s||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,Sr,"LRUCache");let{max:e=0,ttl:s,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:l,dispose:d,onInsert:p,disposeAfter:f,noDisposeOnSet:g,noUpdateTTL:y,maxSize:S=0,maxEntrySize:b=0,sizeCalculation:T,fetchMethod:E,memoMethod:C,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:P,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:D,ignoreFetchAbort:F,perf:it}=t;if(it!==void 0&&typeof it?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,At,it??Zo),e!==0&&!re(e))throw new TypeError("max option must be a nonnegative integer");let _=e?an(e):Array;if(!_)throw new Error("invalid max value: "+e);if(u(this,xt,e),u(this,yt,S),this.maxEntrySize=b||r(this,yt),this.sizeCalculation=T,this.sizeCalculation){if(!r(this,yt)&&!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(C!==void 0&&typeof C!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,je,C),E!==void 0&&typeof E!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,We,E),u(this,ce,!!E),u(this,W,new Map),u(this,N,new Array(e).fill(void 0)),u(this,L,new Array(e).fill(void 0)),u(this,at,new _(e)),u(this,wt,new _(e)),u(this,rt,0),u(this,X,0),u(this,Nt,Qo.create(e)),u(this,G,0),u(this,It,0),typeof d=="function"&&u(this,Pt,d),typeof p=="function"&&u(this,Me,p),typeof f=="function"?(u(this,Dt,f),u(this,Q,[])):(u(this,Dt,void 0),u(this,Q,void 0)),u(this,Ut,!!r(this,Pt)),u(this,Ge,!!r(this,Me)),u(this,lt,!!r(this,Dt)),this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(r(this,yt)!==0&&!re(r(this,yt)))throw new TypeError("maxSize must be a positive integer if specified");if(!re(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");m(this,v,ln).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!P,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=re(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!re(this.ttl))throw new TypeError("ttl must be a positive integer if specified");m(this,v,Os).call(this);}if(r(this,xt)===0&&this.ttl===0&&r(this,yt)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,xt)&&!r(this,yt)){let K="LRU_CACHE_UNBOUNDED";Xo(K)&&(nn.add(K),on("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",K,Ve));}}get perf(){return r(this,At)}static unsafeExposeInternals(t){return {starts:r(t,Ft),ttls:r(t,bt),autopurgeTimers:r(t,St),sizes:r(t,_t),keyMap:r(t,W),keyList:r(t,N),valList:r(t,L),next:r(t,at),prev:r(t,wt),get head(){return r(t,rt)},get tail(){return r(t,X)},free:r(t,Nt),isBackgroundFetch:e=>{var s;return m(s=t,v,A).call(s,e)},backgroundFetch:(e,s,n,o)=>{var a;return m(a=t,v,es).call(a,e,s,n,o)},moveToTail:e=>{var s;return m(s=t,v,li).call(s,e)},indexes:e=>{var s;return m(s=t,v,ne).call(s,e)},rindexes:e=>{var s;return m(s=t,v,oe).call(s,e)},isStale:e=>{var s;return r(s=t,Et).call(s,e)}}}get max(){return r(this,xt)}get maxSize(){return r(this,yt)}get calculatedSize(){return r(this,It)}get size(){return r(this,G)}get fetchMethod(){return r(this,We)}get memoMethod(){return r(this,je)}get dispose(){return r(this,Pt)}get onInsert(){return r(this,Me)}get disposeAfter(){return r(this,Dt)}getRemainingTTL(t){return r(this,W).has(t)?1/0:0}*entries(){for(let t of m(this,v,ne).call(this))r(this,L)[t]!==void 0&&r(this,N)[t]!==void 0&&!m(this,v,A).call(this,r(this,L)[t])&&(yield [r(this,N)[t],r(this,L)[t]]);}*rentries(){for(let t of m(this,v,oe).call(this))r(this,L)[t]!==void 0&&r(this,N)[t]!==void 0&&!m(this,v,A).call(this,r(this,L)[t])&&(yield [r(this,N)[t],r(this,L)[t]]);}*keys(){for(let t of m(this,v,ne).call(this)){let e=r(this,N)[t];e!==void 0&&!m(this,v,A).call(this,r(this,L)[t])&&(yield e);}}*rkeys(){for(let t of m(this,v,oe).call(this)){let e=r(this,N)[t];e!==void 0&&!m(this,v,A).call(this,r(this,L)[t])&&(yield e);}}*values(){for(let t of m(this,v,ne).call(this))r(this,L)[t]!==void 0&&!m(this,v,A).call(this,r(this,L)[t])&&(yield r(this,L)[t]);}*rvalues(){for(let t of m(this,v,oe).call(this))r(this,L)[t]!==void 0&&!m(this,v,A).call(this,r(this,L)[t])&&(yield r(this,L)[t]);}[(Er=Symbol.iterator,Sr=Symbol.toStringTag,Er)](){return this.entries()}find(t,e={}){for(let s of m(this,v,ne).call(this)){let n=r(this,L)[s],o=m(this,v,A).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,r(this,N)[s],this))return this.get(r(this,N)[s],e)}}forEach(t,e=this){for(let s of m(this,v,ne).call(this)){let n=r(this,L)[s],o=m(this,v,A).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(e,o,r(this,N)[s],this);}}rforEach(t,e=this){for(let s of m(this,v,oe).call(this)){let n=r(this,L)[s],o=m(this,v,A).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(e,o,r(this,N)[s],this);}}purgeStale(){let t=false;for(let e of m(this,v,oe).call(this,{allowStale:true}))r(this,Et).call(this,e)&&(m(this,v,ae).call(this,r(this,N)[e],"expire"),t=true);return t}info(t){let e=r(this,W).get(t);if(e===void 0)return;let s=r(this,L)[e],n=m(this,v,A).call(this,s)?s.__staleWhileFetching:s;if(n===void 0)return;let o={value:n};if(r(this,bt)&&r(this,Ft)){let a=r(this,bt)[e],h=r(this,Ft)[e];if(a&&h){let l=a-(r(this,At).now()-h);o.ttl=l,o.start=Date.now();}}return r(this,_t)&&(o.size=r(this,_t)[e]),o}dump(){let t=[];for(let e of m(this,v,ne).call(this,{allowStale:true})){let s=r(this,N)[e],n=r(this,L)[e],o=m(this,v,A).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||s===void 0)continue;let a={value:o};if(r(this,bt)&&r(this,Ft)){a.ttl=r(this,bt)[e];let h=r(this,At).now()-r(this,Ft)[e];a.start=Math.floor(Date.now()-h);}r(this,_t)&&(a.size=r(this,_t)[e]),t.unshift([s,a]);}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let n=Date.now()-s.start;s.start=r(this,At).now()-n;}this.set(e,s.value,s);}}set(t,e,s={}){var g,y,S,b;if(e===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:l}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,p=r(this,mi).call(this,t,e,s.size||0,h);if(this.maxEntrySize&&p>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=true),m(this,v,ae).call(this,t,"set"),this;let f=r(this,G)===0?void 0:r(this,W).get(t);if(f===void 0)f=r(this,G)===0?r(this,X):r(this,Nt).length!==0?r(this,Nt).pop():r(this,G)===r(this,xt)?m(this,v,ts).call(this,false):r(this,G),r(this,N)[f]=t,r(this,L)[f]=e,r(this,W).set(t,f),r(this,at)[r(this,X)]=f,r(this,wt)[f]=r(this,X),u(this,X,f),Wi(this,G)._++,r(this,qe).call(this,f,p,l),l&&(l.set="add"),d=false,r(this,Ge)&&((g=r(this,Me))==null||g.call(this,e,t,"add"));else {m(this,v,li).call(this,f);let T=r(this,L)[f];if(e!==T){if(r(this,ce)&&m(this,v,A).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:E}=T;E!==void 0&&!a&&(r(this,Ut)&&((y=r(this,Pt))==null||y.call(this,E,t,"set")),r(this,lt)&&r(this,Q)?.push([E,t,"set"]));}else a||(r(this,Ut)&&((S=r(this,Pt))==null||S.call(this,T,t,"set")),r(this,lt)&&r(this,Q)?.push([T,t,"set"]));if(r(this,Re).call(this,f),r(this,qe).call(this,f,p,l),r(this,L)[f]=e,l){l.set="replace";let E=T&&m(this,v,A).call(this,T)?T.__staleWhileFetching:T;E!==void 0&&(l.oldValue=E);}}else l&&(l.set="update");r(this,Ge)&&this.onInsert?.(e,t,e===T?"update":"replace");}if(n!==0&&!r(this,bt)&&m(this,v,Os).call(this),r(this,bt)&&(d||r(this,gi).call(this,f,n,o),l&&r(this,Yt).call(this,l,f)),!a&&r(this,lt)&&r(this,Q)){let T=r(this,Q),E;for(;E=T?.shift();)(b=r(this,Dt))==null||b.call(this,...E);}return this}pop(){var t;try{for(;r(this,G);){let e=r(this,L)[r(this,rt)];if(m(this,v,ts).call(this,!0),m(this,v,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(r(this,lt)&&r(this,Q)){let e=r(this,Q),s;for(;s=e?.shift();)(t=r(this,Dt))==null||t.call(this,...s);}}}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:n}=e,o=r(this,W).get(t);if(o!==void 0){let a=r(this,L)[o];if(m(this,v,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,Et).call(this,o))n&&(n.has="stale",r(this,Yt).call(this,n,o));else return s&&r(this,Ce).call(this,o),n&&(n.has="hit",r(this,Yt).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,e={}){let{allowStale:s=this.allowStale}=e,n=r(this,W).get(t);if(n===void 0||!s&&r(this,Et).call(this,n))return;let o=r(this,L)[n];return m(this,v,A).call(this,o)?o.__staleWhileFetching:o}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:l=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:g=this.allowStaleOnFetchRejection,ignoreFetchAbort:y=this.ignoreFetchAbort,allowStaleOnFetchAbort:S=this.allowStaleOnFetchAbort,context:b,forceRefresh:T=false,status:E,signal:C}=e;if(!r(this,ce))return E&&(E.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:E});let O={allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:l,sizeCalculation:d,noUpdateTTL:p,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:g,allowStaleOnFetchAbort:S,ignoreFetchAbort:y,status:E,signal:C},P=r(this,W).get(t);if(P===void 0){E&&(E.fetch="miss");let M=m(this,v,es).call(this,t,P,O,b);return M.__returned=M}else {let M=r(this,L)[P];if(m(this,v,A).call(this,M)){let _=s&&M.__staleWhileFetching!==void 0;return E&&(E.fetch="inflight",_&&(E.returnedStale=true)),_?M.__staleWhileFetching:M.__returned=M}let D=r(this,Et).call(this,P);if(!T&&!D)return E&&(E.fetch="hit"),m(this,v,li).call(this,P),n&&r(this,Ce).call(this,P),E&&r(this,Yt).call(this,E,P),M;let F=m(this,v,es).call(this,t,P,O,b),it=F.__staleWhileFetching!==void 0&&s;return E&&(E.fetch=D?"stale":"refresh",it&&D&&(E.returnedStale=true)),it?F.__staleWhileFetching:F.__returned=F}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=r(this,je);if(!s)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=e,h=this.get(t,a);if(!o&&h!==void 0)return h;let l=s(t,h,{options:a,context:n});return this.set(t,l,a),l}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=e,h=r(this,W).get(t);if(h!==void 0){let l=r(this,L)[h],d=m(this,v,A).call(this,l);return a&&r(this,Yt).call(this,a,h),r(this,Et).call(this,h)?(a&&(a.get="stale"),d?(a&&s&&l.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?l.__staleWhileFetching:void 0):(o||m(this,v,ae).call(this,t,"expire"),a&&s&&(a.returnedStale=true),s?l:void 0)):(a&&(a.get="hit"),d?l.__staleWhileFetching:(m(this,v,li).call(this,h),n&&r(this,Ce).call(this,h),l))}else a&&(a.get="miss");}delete(t){return m(this,v,ae).call(this,t,"delete")}clear(){return m(this,v,As).call(this,"delete")}},xt=new WeakMap,yt=new WeakMap,Pt=new WeakMap,Me=new WeakMap,Dt=new WeakMap,We=new WeakMap,je=new WeakMap,At=new WeakMap,G=new WeakMap,It=new WeakMap,W=new WeakMap,N=new WeakMap,L=new WeakMap,at=new WeakMap,wt=new WeakMap,rt=new WeakMap,X=new WeakMap,Nt=new WeakMap,Q=new WeakMap,_t=new WeakMap,Ft=new WeakMap,bt=new WeakMap,St=new WeakMap,Ut=new WeakMap,ce=new WeakMap,lt=new WeakMap,Ge=new WeakMap,v=new WeakSet,Os=function(){let t=new Qi(r(this,xt)),e=new Qi(r(this,xt));u(this,bt,t),u(this,Ft,e);let s=this.ttlAutopurge?new Array(r(this,xt)):void 0;u(this,St,s),u(this,gi,(a,h,l=r(this,At).now())=>{if(e[a]=h!==0?l:0,t[a]=h,s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h!==0&&s){let d=setTimeout(()=>{r(this,Et).call(this,a)&&m(this,v,ae).call(this,r(this,N)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}),u(this,Ce,a=>{e[a]=t[a]!==0?r(this,At).now():0;}),u(this,Yt,(a,h)=>{if(t[h]){let l=t[h],d=e[h];if(!l||!d)return;a.ttl=l,a.start=d,a.now=n||o();let p=a.now-d;a.remainingTTL=l-p;}});let n=0,o=()=>{let a=r(this,At).now();if(this.ttlResolution>0){n=a;let h=setTimeout(()=>n=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=r(this,W).get(a);if(h===void 0)return 0;let l=t[h],d=e[h];if(!l||!d)return 1/0;let p=(n||o())-d;return l-p},u(this,Et,a=>{let h=e[a],l=t[a];return !!l&&!!h&&(n||o())-h>l});},Ce=new WeakMap,Yt=new WeakMap,gi=new WeakMap,Et=new WeakMap,ln=function(){let t=new Qi(r(this,xt));u(this,It,0),u(this,_t,t),u(this,Re,e=>{u(this,It,r(this,It)-t[e]),t[e]=0;}),u(this,mi,(e,s,n,o)=>{if(m(this,v,A).call(this,s))return 0;if(!re(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(s,e),!re(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n}),u(this,qe,(e,s,n)=>{if(t[e]=s,r(this,yt)){let o=r(this,yt)-t[e];for(;r(this,It)>o;)m(this,v,ts).call(this,true);}u(this,It,r(this,It)+t[e]),n&&(n.entrySize=s,n.totalCalculatedSize=r(this,It));});},Re=new WeakMap,qe=new WeakMap,mi=new WeakMap,ne=function*({allowStale:t=this.allowStale}={}){if(r(this,G))for(let e=r(this,X);!(!m(this,v,Ps).call(this,e)||((t||!r(this,Et).call(this,e))&&(yield e),e===r(this,rt)));)e=r(this,wt)[e];},oe=function*({allowStale:t=this.allowStale}={}){if(r(this,G))for(let e=r(this,rt);!(!m(this,v,Ps).call(this,e)||((t||!r(this,Et).call(this,e))&&(yield e),e===r(this,X)));)e=r(this,at)[e];},Ps=function(t){return t!==void 0&&r(this,W).get(r(this,N)[t])===t},ts=function(t){var o;let e=r(this,rt),s=r(this,N)[e],n=r(this,L)[e];return r(this,ce)&&m(this,v,A).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,Ut)||r(this,lt))&&(r(this,Ut)&&((o=r(this,Pt))==null||o.call(this,n,s,"evict")),r(this,lt)&&r(this,Q)?.push([n,s,"evict"])),r(this,Re).call(this,e),r(this,St)?.[e]&&(clearTimeout(r(this,St)[e]),r(this,St)[e]=void 0),t&&(r(this,N)[e]=void 0,r(this,L)[e]=void 0,r(this,Nt).push(e)),r(this,G)===1?(u(this,rt,u(this,X,0)),r(this,Nt).length=0):u(this,rt,r(this,at)[e]),r(this,W).delete(s),Wi(this,G)._--,e},es=function(t,e,s,n){let o=e===void 0?void 0:r(this,L)[e];if(m(this,v,A).call(this,o))return o;let a=new as,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let l={signal:a.signal,options:s,context:n},d=(b,T=false)=>{let{aborted:E}=a.signal,C=s.ignoreFetchAbort&&b!==void 0,O=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&b!==void 0);if(s.status&&(E&&!T?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,C&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),E&&!C&&!T)return f(a.signal.reason,O);let P=y,M=r(this,L)[e];return (M===y||C&&T&&M===void 0)&&(b===void 0?P.__staleWhileFetching!==void 0?r(this,L)[e]=P.__staleWhileFetching:m(this,v,ae).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,b,l.options))),b},p=b=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=b),f(b,false)),f=(b,T)=>{let{aborted:E}=a.signal,C=E&&s.allowStaleOnFetchAbort,O=C||s.allowStaleOnFetchRejection,P=O||s.noDeleteOnFetchRejection,M=y;if(r(this,L)[e]===y&&(!P||!T&&M.__staleWhileFetching===void 0?m(this,v,ae).call(this,t,"fetch"):C||(r(this,L)[e]=M.__staleWhileFetching)),O)return s.status&&M.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),M.__staleWhileFetching;if(M.__returned===M)throw b},g=(b,T)=>{var C;let E=(C=r(this,We))==null?void 0:C.call(this,t,o,l);E&&E instanceof Promise&&E.then(O=>b(O===void 0?void 0:O),T),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(b(void 0),s.allowStaleOnFetchAbort&&(b=O=>d(O,true)));});};s.status&&(s.status.fetchDispatched=true);let y=new Promise(g).then(d,p),S=Object.assign(y,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return e===void 0?(this.set(t,S,{...l.options,status:void 0}),e=r(this,W).get(t)):r(this,L)[e]=S,S},A=function(t){if(!r(this,ce))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof as},Ds=function(t,e){r(this,wt)[e]=t,r(this,at)[t]=e;},li=function(t){t!==r(this,X)&&(t===r(this,rt)?u(this,rt,r(this,at)[t]):m(this,v,Ds).call(this,r(this,wt)[t],r(this,at)[t]),m(this,v,Ds).call(this,r(this,X),t),u(this,X,t));},ae=function(t,e){var n,o;let s=false;if(r(this,G)!==0){let a=r(this,W).get(t);if(a!==void 0)if(r(this,St)?.[a]&&(clearTimeout(r(this,St)?.[a]),r(this,St)[a]=void 0),s=true,r(this,G)===1)m(this,v,As).call(this,e);else {r(this,Re).call(this,a);let h=r(this,L)[a];if(m(this,v,A).call(this,h)?h.__abortController.abort(new Error("deleted")):(r(this,Ut)||r(this,lt))&&(r(this,Ut)&&((n=r(this,Pt))==null||n.call(this,h,t,e)),r(this,lt)&&r(this,Q)?.push([h,t,e])),r(this,W).delete(t),r(this,N)[a]=void 0,r(this,L)[a]=void 0,a===r(this,X))u(this,X,r(this,wt)[a]);else if(a===r(this,rt))u(this,rt,r(this,at)[a]);else {let l=r(this,wt)[a];r(this,at)[l]=r(this,at)[a];let d=r(this,at)[a];r(this,wt)[d]=r(this,wt)[a];}Wi(this,G)._--,r(this,Nt).push(a);}}if(r(this,lt)&&r(this,Q)?.length){let a=r(this,Q),h;for(;h=a?.shift();)(o=r(this,Dt))==null||o.call(this,...h);}return s},As=function(t){var e,s;for(let n of m(this,v,oe).call(this,{allowStale:true})){let o=r(this,L)[n];if(m(this,v,A).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=r(this,N)[n];r(this,Ut)&&((e=r(this,Pt))==null||e.call(this,o,a,t)),r(this,lt)&&r(this,Q)?.push([o,a,t]);}}if(r(this,W).clear(),r(this,L).fill(void 0),r(this,N).fill(void 0),r(this,bt)&&r(this,Ft)){r(this,bt).fill(0),r(this,Ft).fill(0);for(let n of r(this,St)??[])n!==void 0&&clearTimeout(n);r(this,St)?.fill(void 0);}if(r(this,_t)&&r(this,_t).fill(0),u(this,rt,0),u(this,X,0),r(this,Nt).length=0,u(this,It,0),u(this,G,0),r(this,lt)&&r(this,Q)){let n=r(this,Q),o;for(;o=n?.shift();)(s=r(this,Dt))==null||s.call(this,...o);}},Ve),or=typeof process=="object"&&process?process:{stdout:null,stderr:null},fa=i=>!!i&&typeof i=="object"&&(i instanceof ls||i instanceof hn__default.default||pa(i)||ga(i)),pa=i=>!!i&&typeof i=="object"&&i instanceof events.EventEmitter&&typeof i.pipe=="function"&&i.pipe!==hn__default.default.Writable.prototype.pipe,ga=i=>!!i&&typeof i=="object"&&i instanceof events.EventEmitter&&typeof i.write=="function"&&typeof i.end=="function",Kt=Symbol("EOF"),Ht=Symbol("maybeEmitEnd"),se=Symbol("emittedEnd"),qi=Symbol("emittingEnd"),ii=Symbol("emittedError"),Vi=Symbol("closed"),ar=Symbol("read"),Ki=Symbol("flush"),lr=Symbol("flushChunk"),Lt=Symbol("encoding"),Ue=Symbol("decoder"),H=Symbol("flowing"),si=Symbol("paused"),Be=Symbol("resume"),J=Symbol("buffer"),ot=Symbol("pipes"),Y=Symbol("bufferLength"),Es=Symbol("bufferPush"),Hi=Symbol("bufferShift"),st=Symbol("objectMode"),B=Symbol("destroyed"),vs=Symbol("error"),Ts=Symbol("emitData"),hr=Symbol("emitEnd"),xs=Symbol("emitEnd2"),$t=Symbol("async"),Ms=Symbol("abort"),Ji=Symbol("aborted"),ri=Symbol("signal"),Se=Symbol("dataListeners"),mt=Symbol("discarded"),ni=i=>Promise.resolve().then(i),ma=i=>i(),ya=i=>i==="end"||i==="finish"||i==="prefinish",wa=i=>i instanceof ArrayBuffer||!!i&&typeof i=="object"&&i.constructor&&i.constructor.name==="ArrayBuffer"&&i.byteLength>=0,ba=i=>!Buffer.isBuffer(i)&&ArrayBuffer.isView(i),cn=class{constructor(i,t,e){c(this,"src");c(this,"dest");c(this,"opts");c(this,"ondrain");this.src=i,this.dest=t,this.opts=e,this.ondrain=()=>i[Be](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(i){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},Sa=class extends cn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(i,t,e){super(i,t,e),this.proxyErrors=s=>this.dest.emit("error",s),i.on("error",this.proxyErrors);}},Ea=i=>!!i.objectMode,va=i=>!i.objectMode&&!!i.encoding&&i.encoding!=="buffer",vr,Tr,xr,Mr,Cr,Rr,kr,Lr,Or,Pr,Dr,Ar,Ir,Nr,_r,Fr,Ur,Br,zr,ls=class extends events.EventEmitter{constructor(...t){let e=t[0]||{};super();c(this,zr,false);c(this,Br,false);c(this,Ur,[]);c(this,Fr,[]);c(this,_r);c(this,Nr);c(this,Ir);c(this,Ar);c(this,Dr,false);c(this,Pr,false);c(this,Or,false);c(this,Lr,false);c(this,kr,null);c(this,Rr,0);c(this,Cr,false);c(this,Mr);c(this,xr,false);c(this,Tr,0);c(this,vr,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");Ea(e)?(this[st]=true,this[Lt]=null):va(e)?(this[Lt]=e.encoding,this[st]=false):(this[st]=false,this[Lt]=null),this[$t]=!!e.async,this[Ue]=this[Lt]?new string_decoder.StringDecoder(this[Lt]):null,e&&e.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[J]}),e&&e.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[ot]});let{signal:s}=e;s&&(this[ri]=s,s.aborted?this[Ms]():s.addEventListener("abort",()=>this[Ms]()));}get bufferLength(){return this[Y]}get encoding(){return this[Lt]}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[st]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[$t]}set async(t){this[$t]=this[$t]||!!t;}[(zr=H,Br=si,Ur=ot,Fr=J,_r=st,Nr=Lt,Ir=$t,Ar=Ue,Dr=Kt,Pr=se,Or=qi,Lr=Vi,kr=ii,Rr=Y,Cr=B,Mr=ri,xr=Ji,Tr=Se,vr=mt,Ms)](){this[Ji]=true,this.emit("abort",this[ri]?.reason),this.destroy(this[ri]?.reason);}get aborted(){return this[Ji]}set aborted(t){}write(t,e,s){if(this[Ji])return false;if(this[Kt])throw new Error("write after end");if(this[B])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let n=this[$t]?ni:ma;if(!this[st]&&!Buffer.isBuffer(t)){if(ba(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(wa(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[st]?(this[H]&&this[Y]!==0&&this[Ki](true),this[H]?this.emit("data",t):this[Es](t),this[Y]!==0&&this.emit("readable"),s&&n(s),this[H]):t.length?(typeof t=="string"&&!(e===this[Lt]&&!this[Ue]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[Lt]&&(t=this[Ue].write(t)),this[H]&&this[Y]!==0&&this[Ki](true),this[H]?this.emit("data",t):this[Es](t),this[Y]!==0&&this.emit("readable"),s&&n(s),this[H]):(this[Y]!==0&&this.emit("readable"),s&&n(s),this[H])}read(t){if(this[B])return null;if(this[mt]=false,this[Y]===0||t===0||t&&t>this[Y])return this[Ht](),null;this[st]&&(t=null),this[J].length>1&&!this[st]&&(this[J]=[this[Lt]?this[J].join(""):Buffer.concat(this[J],this[Y])]);let e=this[ar](t||null,this[J][0]);return this[Ht](),e}[ar](t,e){if(this[st])this[Hi]();else {let s=e;t===s.length||t===null?this[Hi]():typeof s=="string"?(this[J][0]=s.slice(t),e=s.slice(0,t),this[Y]-=t):(this[J][0]=s.subarray(t),e=s.subarray(0,t),this[Y]-=t);}return this.emit("data",e),!this[J].length&&!this[Kt]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[Kt]=true,this.writable=false,(this[H]||!this[si])&&this[Ht](),this}[Be](){this[B]||(!this[Se]&&!this[ot].length&&(this[mt]=true),this[si]=false,this[H]=true,this.emit("resume"),this[J].length?this[Ki]():this[Kt]?this[Ht]():this.emit("drain"));}resume(){return this[Be]()}pause(){this[H]=false,this[si]=true,this[mt]=false;}get destroyed(){return this[B]}get flowing(){return this[H]}get paused(){return this[si]}[Es](t){this[st]?this[Y]+=1:this[Y]+=t.length,this[J].push(t);}[Hi](){return this[st]?this[Y]-=1:this[Y]-=this[J][0].length,this[J].shift()}[Ki](t=false){do;while(this[lr](this[Hi]())&&this[J].length);!t&&!this[J].length&&!this[Kt]&&this.emit("drain");}[lr](t){return this.emit("data",t),this[H]}pipe(t,e){if(this[B])return t;this[mt]=false;let s=this[se];return e=e||{},t===or.stdout||t===or.stderr?e.end=false:e.end=e.end!==false,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[ot].push(e.proxyErrors?new Sa(this,t,e):new cn(this,t,e)),this[$t]?ni(()=>this[Be]()):this[Be]()),t}unpipe(t){let e=this[ot].find(s=>s.dest===t);e&&(this[ot].length===1?(this[H]&&this[Se]===0&&(this[H]=false),this[ot]=[]):this[ot].splice(this[ot].indexOf(e),1),e.unpipe());}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[mt]=false,this[Se]++,!this[ot].length&&!this[H]&&this[Be]();else if(t==="readable"&&this[Y]!==0)super.emit("readable");else if(ya(t)&&this[se])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ii]){let n=e;this[$t]?ni(()=>n.call(this,this[ii])):n.call(this,this[ii]);}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[Se]=this.listeners("data").length,this[Se]===0&&!this[mt]&&!this[ot].length&&(this[H]=false)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[Se]=0,!this[mt]&&!this[ot].length&&(this[H]=false)),e}get emittedEnd(){return this[se]}[Ht](){!this[qi]&&!this[se]&&!this[B]&&this[J].length===0&&this[Kt]&&(this[qi]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Vi]&&this.emit("close"),this[qi]=false);}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==B&&this[B])return false;if(t==="data")return !this[st]&&!s?false:this[$t]?(ni(()=>this[Ts](s)),true):this[Ts](s);if(t==="end")return this[hr]();if(t==="close"){if(this[Vi]=true,!this[se]&&!this[B])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ii]=s,super.emit(vs,s);let o=!this[ri]||this.listeners("error").length?super.emit("error",s):false;return this[Ht](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ht](),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[Ht](),n}[Ts](t){for(let s of this[ot])s.dest.write(t)===false&&this.pause();let e=this[mt]?false:super.emit("data",t);return this[Ht](),e}[hr](){return this[se]?false:(this[se]=true,this.readable=false,this[$t]?(ni(()=>this[xs]()),true):this[xs]())}[xs](){if(this[Ue]){let e=this[Ue].end();if(e){for(let s of this[ot])s.dest.write(e);this[mt]||super.emit("data",e);}}for(let e of this[ot])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[st]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[st]||(t.dataLength+=s.length);}),await e,t}async concat(){if(this[st])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Lt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(B,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[mt]=false;let t=false,e=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return e();let s=this.read();if(s!==null)return Promise.resolve({done:false,value:s});if(this[Kt])return e();let n,o,a=p=>{this.off("data",h),this.off("end",l),this.off(B,d),e(),o(p);},h=p=>{this.off("error",a),this.off("end",l),this.off(B,d),this.pause(),n({value:p,done:!!this[Kt]});},l=()=>{this.off("error",a),this.off("data",h),this.off(B,d),e(),n({done:true,value:void 0});},d=()=>a(new Error("stream destroyed"));return new Promise((p,f)=>{o=f,n=p,this.once(B,d),this.once("error",a),this.once("end",l),this.once("data",h);})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[mt]=false;let t=false,e=()=>(this.pause(),this.off(vs,e),this.off(B,e),this.off("end",e),t=true,{done:true,value:void 0}),s=()=>{if(t)return e();let n=this.read();return n===null?e():{done:false,value:n}};return this.once("end",e),this.once(vs,e),this.once(B,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[B])return t?this.emit("error",t):this.emit(B),this;this[B]=true,this[mt]=true,this[J].length=0,this[Y]=0;let e=this;return typeof e.close=="function"&&!this[Vi]&&e.close(),t?this.emit("error",t):this.emit(B),this}static get isStream(){return fa}},Ta=z.realpathSync.native,hi={lstatSync:z.lstatSync,readdir:z.readdir,readdirSync:z.readdirSync,readlinkSync:z.readlinkSync,realpathSync:Ta,promises:{lstat:_n.lstat,readdir:_n.readdir,readlink:_n.readlink,realpath:_n.realpath}},dn=i=>!i||i===hi||i===z__namespace?hi:{...hi,...i,promises:{...hi.promises,...i.promises||{}}},un=/^\\\\\?\\([a-z]:)\\?$/i,xa=i=>i.replace(/\//g,"\\").replace(un,"$1\\"),Ma=/[\\\/]/,Mt=0,fn=1,pn=2,Wt=4,gn=6,mn=8,Ee=10,yn=12,Tt=15,oi=~Tt,Cs=16,cr=32,ci=64,Ot=128,Yi=256,is=512,dr=ci|Ot|is,Ca=1023,Rs=i=>i.isFile()?mn:i.isDirectory()?Wt:i.isSymbolicLink()?Ee:i.isCharacterDevice()?pn:i.isBlockDevice()?gn:i.isSocket()?yn:i.isFIFO()?fn:Mt,ur=new cs({max:2**12}),di=i=>{let t=ur.get(i);if(t)return t;let e=i.normalize("NFKD");return ur.set(i,e),e},fr=new cs({max:2**12}),Zi=i=>{let t=fr.get(i);if(t)return t;let e=di(i.toLowerCase());return fr.set(i,e),e},pr=class extends cs{constructor(){super({max:256});}},Ra=class extends cs{constructor(i=16*1024){super({maxSize:i,sizeCalculation:t=>t.length+1});}},wn=Symbol("PathScurry setAsCwd"),ht,yi,wi,bi,Si,Ei,vi,Ti,xi,Mi,Ci,Ri,ki,Li,Oi,Pi,Di,Ai,Ii,de,ke,Gt,Zt,Xt,Qt,k,Le,te,qt,R,Ns,ss,ui,_s,Fs,fi,rs,Us,Bs,ns,bn,Sn,En,zs,Ke,He,vn,Oe,$r,ut=($r=class{constructor(i,t=Mt,e,s,n,o,a){w(this,R);c(this,"name");c(this,"root");c(this,"roots");c(this,"parent");c(this,"nocase");c(this,"isCWD",false);w(this,ht);w(this,yi);w(this,wi);w(this,bi);w(this,Si);w(this,Ei);w(this,vi);w(this,Ti);w(this,xi);w(this,Mi);w(this,Ci);w(this,Ri);w(this,ki);w(this,Li);w(this,Oi);w(this,Pi);w(this,Di);w(this,Ai);w(this,Ii);w(this,de);w(this,ke);w(this,Gt);w(this,Zt);w(this,Xt);w(this,Qt);w(this,k);w(this,Le);w(this,te);w(this,qt);w(this,Ke,[]);w(this,He,false);w(this,Oe);this.name=i,u(this,de,n?Zi(i):di(i)),u(this,k,t&Ca),this.nocase=n,this.roots=s,this.root=e||this,u(this,Le,o),u(this,Gt,a.fullpath),u(this,Xt,a.relative),u(this,Qt,a.relativePosix),this.parent=a.parent,this.parent?u(this,ht,r(this.parent,ht)):u(this,ht,dn(a.fs));}get dev(){return r(this,yi)}get mode(){return r(this,wi)}get nlink(){return r(this,bi)}get uid(){return r(this,Si)}get gid(){return r(this,Ei)}get rdev(){return r(this,vi)}get blksize(){return r(this,Ti)}get ino(){return r(this,xi)}get size(){return r(this,Mi)}get blocks(){return r(this,Ci)}get atimeMs(){return r(this,Ri)}get mtimeMs(){return r(this,ki)}get ctimeMs(){return r(this,Li)}get birthtimeMs(){return r(this,Oi)}get atime(){return r(this,Pi)}get mtime(){return r(this,Di)}get ctime(){return r(this,Ai)}get birthtime(){return r(this,Ii)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return r(this,ke)!==void 0?r(this,ke):this.parent?u(this,ke,this.parent.depth()+1):u(this,ke,0)}childrenCache(){return r(this,Le)}resolve(i){var s;if(!i)return this;let t=this.getRootString(i),e=i.substring(t.length).split(this.splitSep);return t?m(s=this.getRoot(t),R,Ns).call(s,e):m(this,R,Ns).call(this,e)}children(){let i=r(this,Le).get(this);if(i)return i;let t=Object.assign([],{provisional:0});return r(this,Le).set(this,t),u(this,k,r(this,k)&~Cs),t}child(i,t){if(i===""||i===".")return this;if(i==="..")return this.parent||this;let e=this.children(),s=this.nocase?Zi(i):di(i);for(let h of e)if(r(h,de)===s)return h;let n=this.parent?this.sep:"",o=r(this,Gt)?r(this,Gt)+n+i:void 0,a=this.newChild(i,Mt,{...t,parent:this,fullpath:o});return this.canReaddir()||u(a,k,r(a,k)|Ot),e.push(a),a}relative(){if(this.isCWD)return "";if(r(this,Xt)!==void 0)return r(this,Xt);let i=this.name,t=this.parent;if(!t)return u(this,Xt,this.name);let e=t.relative();return e+(!e||!t.parent?"":this.sep)+i}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(r(this,Qt)!==void 0)return r(this,Qt);let i=this.name,t=this.parent;if(!t)return u(this,Qt,this.fullpathPosix());let e=t.relativePosix();return e+(!e||!t.parent?"":"/")+i}fullpath(){if(r(this,Gt)!==void 0)return r(this,Gt);let i=this.name,t=this.parent;if(!t)return u(this,Gt,this.name);let e=t.fullpath()+(t.parent?this.sep:"")+i;return u(this,Gt,e)}fullpathPosix(){if(r(this,Zt)!==void 0)return r(this,Zt);if(this.sep==="/")return u(this,Zt,this.fullpath());if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(s)?u(this,Zt,`//?/${s}`):u(this,Zt,s)}let i=this.parent,t=i.fullpathPosix(),e=t+(!t||!i.parent?"":"/")+this.name;return u(this,Zt,e)}isUnknown(){return (r(this,k)&Tt)===Mt}isType(i){return this[`is${i}`]()}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,k)&Tt)===mn}isDirectory(){return (r(this,k)&Tt)===Wt}isCharacterDevice(){return (r(this,k)&Tt)===pn}isBlockDevice(){return (r(this,k)&Tt)===gn}isFIFO(){return (r(this,k)&Tt)===fn}isSocket(){return (r(this,k)&Tt)===yn}isSymbolicLink(){return (r(this,k)&Ee)===Ee}lstatCached(){return r(this,k)&cr?this:void 0}readlinkCached(){return r(this,te)}realpathCached(){return r(this,qt)}readdirCached(){let i=this.children();return i.slice(0,i.provisional)}canReadlink(){if(r(this,te))return true;if(!this.parent)return false;let i=r(this,k)&Tt;return !(i!==Mt&&i!==Ee||r(this,k)&Yi||r(this,k)&Ot)}calledReaddir(){return !!(r(this,k)&Cs)}isENOENT(){return !!(r(this,k)&Ot)}isNamed(i){return this.nocase?r(this,de)===Zi(i):r(this,de)===di(i)}async readlink(){let i=r(this,te);if(i)return i;if(this.canReadlink()&&this.parent)try{let t=await r(this,ht).promises.readlink(this.fullpath()),e=(await this.parent.realpath())?.resolve(t);if(e)return u(this,te,e)}catch(t){m(this,R,Bs).call(this,t.code);return}}readlinkSync(){let i=r(this,te);if(i)return i;if(this.canReadlink()&&this.parent)try{let t=r(this,ht).readlinkSync(this.fullpath()),e=this.parent.realpathSync()?.resolve(t);if(e)return u(this,te,e)}catch(t){m(this,R,Bs).call(this,t.code);return}}async lstat(){if((r(this,k)&Ot)===0)try{return m(this,R,zs).call(this,await r(this,ht).promises.lstat(this.fullpath())),this}catch(i){m(this,R,Us).call(this,i.code);}}lstatSync(){if((r(this,k)&Ot)===0)try{return m(this,R,zs).call(this,r(this,ht).lstatSync(this.fullpath())),this}catch(i){m(this,R,Us).call(this,i.code);}}readdirCB(i,t=false){if(!this.canReaddir()){t?i(null,[]):queueMicrotask(()=>i(null,[]));return}let e=this.children();if(this.calledReaddir()){let n=e.slice(0,e.provisional);t?i(null,n):queueMicrotask(()=>i(null,n));return}if(r(this,Ke).push(i),r(this,He))return;u(this,He,true);let s=this.fullpath();r(this,ht).readdir(s,{withFileTypes:true},(n,o)=>{if(n)m(this,R,rs).call(this,n.code),e.provisional=0;else {for(let a of o)m(this,R,ns).call(this,a,e);m(this,R,ss).call(this,e);}m(this,R,vn).call(this,e.slice(0,e.provisional));});}async readdir(){if(!this.canReaddir())return [];let i=this.children();if(this.calledReaddir())return i.slice(0,i.provisional);let t=this.fullpath();if(r(this,Oe))await r(this,Oe);else {let e=()=>{};u(this,Oe,new Promise(s=>e=s));try{for(let s of await r(this,ht).promises.readdir(t,{withFileTypes:!0}))m(this,R,ns).call(this,s,i);m(this,R,ss).call(this,i);}catch(s){m(this,R,rs).call(this,s.code),i.provisional=0;}u(this,Oe,void 0),e();}return i.slice(0,i.provisional)}readdirSync(){if(!this.canReaddir())return [];let i=this.children();if(this.calledReaddir())return i.slice(0,i.provisional);let t=this.fullpath();try{for(let e of r(this,ht).readdirSync(t,{withFileTypes:!0}))m(this,R,ns).call(this,e,i);m(this,R,ss).call(this,i);}catch(e){m(this,R,rs).call(this,e.code),i.provisional=0;}return i.slice(0,i.provisional)}canReaddir(){if(r(this,k)&dr)return false;let i=Tt&r(this,k);return i===Mt||i===Wt||i===Ee}shouldWalk(i,t){return (r(this,k)&Wt)===Wt&&!(r(this,k)&dr)&&!i.has(this)&&(!t||t(this))}async realpath(){if(r(this,qt))return r(this,qt);if(!((is|Yi|Ot)&r(this,k)))try{let i=await r(this,ht).promises.realpath(this.fullpath());return u(this,qt,this.resolve(i))}catch{m(this,R,Fs).call(this);}}realpathSync(){if(r(this,qt))return r(this,qt);if(!((is|Yi|Ot)&r(this,k)))try{let i=r(this,ht).realpathSync(this.fullpath());return u(this,qt,this.resolve(i))}catch{m(this,R,Fs).call(this);}}[wn](i){if(i===this)return;i.isCWD=false,this.isCWD=true;let t=new Set([]),e=[],s=this;for(;s&&s.parent;)t.add(s),u(s,Xt,e.join(this.sep)),u(s,Qt,e.join("/")),s=s.parent,e.push("..");for(s=i;s&&s.parent&&!t.has(s);)u(s,Xt,void 0),u(s,Qt,void 0),s=s.parent;}},ht=new WeakMap,yi=new WeakMap,wi=new WeakMap,bi=new WeakMap,Si=new WeakMap,Ei=new WeakMap,vi=new WeakMap,Ti=new WeakMap,xi=new WeakMap,Mi=new WeakMap,Ci=new WeakMap,Ri=new WeakMap,ki=new WeakMap,Li=new WeakMap,Oi=new WeakMap,Pi=new WeakMap,Di=new WeakMap,Ai=new WeakMap,Ii=new WeakMap,de=new WeakMap,ke=new WeakMap,Gt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,Qt=new WeakMap,k=new WeakMap,Le=new WeakMap,te=new WeakMap,qt=new WeakMap,R=new WeakSet,Ns=function(i){let t=this;for(let e of i)t=t.child(e);return t},ss=function(i){var t;u(this,k,r(this,k)|Cs);for(let e=i.provisional;e<i.length;e++){let s=i[e];s&&m(t=s,R,ui).call(t);}},ui=function(){r(this,k)&Ot||(u(this,k,(r(this,k)|Ot)&oi),m(this,R,_s).call(this));},_s=function(){var t;let i=this.children();i.provisional=0;for(let e of i)m(t=e,R,ui).call(t);},Fs=function(){u(this,k,r(this,k)|is),m(this,R,fi).call(this);},fi=function(){if(r(this,k)&ci)return;let i=r(this,k);(i&Tt)===Wt&&(i&=oi),u(this,k,i|ci),m(this,R,_s).call(this);},rs=function(i=""){i==="ENOTDIR"||i==="EPERM"?m(this,R,fi).call(this):i==="ENOENT"?m(this,R,ui).call(this):this.children().provisional=0;},Us=function(i=""){var t;i==="ENOTDIR"?m(t=this.parent,R,fi).call(t):i==="ENOENT"&&m(this,R,ui).call(this);},Bs=function(i=""){var e;let t=r(this,k);t|=Yi,i==="ENOENT"&&(t|=Ot),(i==="EINVAL"||i==="UNKNOWN")&&(t&=oi),u(this,k,t),i==="ENOTDIR"&&this.parent&&m(e=this.parent,R,fi).call(e);},ns=function(i,t){return m(this,R,Sn).call(this,i,t)||m(this,R,bn).call(this,i,t)},bn=function(i,t){let e=Rs(i),s=this.newChild(i.name,e,{parent:this}),n=r(s,k)&Tt;return n!==Wt&&n!==Ee&&n!==Mt&&u(s,k,r(s,k)|ci),t.unshift(s),t.provisional++,s},Sn=function(i,t){for(let e=t.provisional;e<t.length;e++){let s=t[e];if((this.nocase?Zi(i.name):di(i.name))===r(s,de))return m(this,R,En).call(this,i,s,e,t)}},En=function(i,t,e,s){let n=t.name;return u(t,k,r(t,k)&oi|Rs(i)),n!==i.name&&(t.name=i.name),e!==s.provisional&&(e===s.length-1?s.pop():s.splice(e,1),s.unshift(t)),s.provisional++,t},zs=function(i){let{atime:t,atimeMs:e,birthtime:s,birthtimeMs:n,blksize:o,blocks:a,ctime:h,ctimeMs:l,dev:d,gid:p,ino:f,mode:g,mtime:y,mtimeMs:S,nlink:b,rdev:T,size:E,uid:C}=i;u(this,Pi,t),u(this,Ri,e),u(this,Ii,s),u(this,Oi,n),u(this,Ti,o),u(this,Ci,a),u(this,Ai,h),u(this,Li,l),u(this,yi,d),u(this,Ei,p),u(this,xi,f),u(this,wi,g),u(this,Di,y),u(this,ki,S),u(this,bi,b),u(this,vi,T),u(this,Mi,E),u(this,Si,C);let O=Rs(i);u(this,k,r(this,k)&oi|O|cr),O!==Mt&&O!==Wt&&O!==Ee&&u(this,k,r(this,k)|ci);},Ke=new WeakMap,He=new WeakMap,vn=function(i){u(this,He,false);let t=r(this,Ke).slice();r(this,Ke).length=0,t.forEach(e=>e(null,i));},Oe=new WeakMap,$r),Tn=class xn extends ut{constructor(e,s=Mt,n,o,a,h,l){super(e,s,n,o,a,h,l);c(this,"sep","\\");c(this,"splitSep",Ma);}newChild(e,s=Mt,n={}){return new xn(e,s,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return ti.win32.parse(e).root}getRoot(e){if(e=xa(e.toUpperCase()),e===this.root.name)return this.root;for(let[s,n]of Object.entries(this.roots))if(this.sameRoot(e,s))return this.roots[e]=n;return this.roots[e]=new qs(e,this).root}sameRoot(e,s=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(un,"$1\\"),e===s}},Mn=class Cn extends ut{constructor(e,s=Mt,n,o,a,h,l){super(e,s,n,o,a,h,l);c(this,"splitSep","/");c(this,"sep","/");}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,s=Mt,n={}){return new Cn(e,s,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Je,Ye,Ni,_i,Wr,Rn=(Wr=class{constructor(i=process.cwd(),t,e,{nocase:s,childrenCacheSize:n=16*1024,fs:o=hi}={}){c(this,"root");c(this,"rootPath");c(this,"roots");c(this,"cwd");w(this,Je);w(this,Ye);w(this,Ni);c(this,"nocase");w(this,_i);u(this,_i,dn(o)),(i instanceof URL||i.startsWith("file://"))&&(i=url.fileURLToPath(i));let a=t.resolve(i);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),u(this,Je,new pr),u(this,Ye,new pr),u(this,Ni,new Ra(n));let h=a.substring(this.rootPath.length).split(e);if(h.length===1&&!h[0]&&h.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(r(this,_i)),this.roots[this.rootPath]=this.root;let l=this.root,d=h.length-1,p=t.sep,f=this.rootPath,g=false;for(let y of h){let S=d--;l=l.child(y,{relative:new Array(S).fill("..").join(p),relativePosix:new Array(S).fill("..").join("/"),fullpath:f+=(g?"":p)+y}),g=true;}this.cwd=l;}depth(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.depth()}childrenCache(){return r(this,Ni)}resolve(...i){let t="";for(let n=i.length-1;n>=0;n--){let o=i[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let e=r(this,Je).get(t);if(e!==void 0)return e;let s=this.cwd.resolve(t).fullpath();return r(this,Je).set(t,s),s}resolvePosix(...i){let t="";for(let n=i.length-1;n>=0;n--){let o=i[n];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let e=r(this,Ye).get(t);if(e!==void 0)return e;let s=this.cwd.resolve(t).fullpathPosix();return r(this,Ye).set(t,s),s}relative(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.relative()}relativePosix(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.relativePosix()}basename(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.name}dirname(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),(i.parent||i).fullpath()}async readdir(i=this.cwd,t={withFileTypes:true}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd);let{withFileTypes:e}=t;if(i.canReaddir()){let s=await i.readdir();return e?s:s.map(n=>n.name)}else return []}readdirSync(i=this.cwd,t={withFileTypes:true}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd);let{withFileTypes:e=true}=t;return i.canReaddir()?e?i.readdirSync():i.readdirSync().map(s=>s.name):[]}async lstat(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.lstat()}lstatSync(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.lstatSync()}async readlink(i=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i.withFileTypes,i=this.cwd);let e=await i.readlink();return t?e:e?.fullpath()}readlinkSync(i=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i.withFileTypes,i=this.cwd);let e=i.readlinkSync();return t?e:e?.fullpath()}async realpath(i=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i.withFileTypes,i=this.cwd);let e=await i.realpath();return t?e:e?.fullpath()}realpathSync(i=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i.withFileTypes,i=this.cwd);let e=i.realpathSync();return t?e:e?.fullpath()}async walk(i=this.cwd,t={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd);let{withFileTypes:e=true,follow:s=false,filter:n,walkFilter:o}=t,a=[];(!n||n(i))&&a.push(e?i:i.fullpath());let h=new Set,l=(p,f)=>{h.add(p),p.readdirCB((g,y)=>{if(g)return f(g);let S=y.length;if(!S)return f();let b=()=>{--S===0&&f();};for(let T of y)(!n||n(T))&&a.push(e?T:T.fullpath()),s&&T.isSymbolicLink()?T.realpath().then(E=>E?.isUnknown()?E.lstat():E).then(E=>E?.shouldWalk(h,o)?l(E,b):b()):T.shouldWalk(h,o)?l(T,b):b();},true);},d=i;return new Promise((p,f)=>{l(d,g=>{if(g)return f(g);p(a);});})}walkSync(i=this.cwd,t={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd);let{withFileTypes:e=true,follow:s=false,filter:n,walkFilter:o}=t,a=[];(!n||n(i))&&a.push(e?i:i.fullpath());let h=new Set([i]);for(let l of h){let d=l.readdirSync();for(let p of d){(!n||n(p))&&a.push(e?p:p.fullpath());let f=p;if(p.isSymbolicLink()){if(!(s&&(f=p.realpathSync())))continue;f.isUnknown()&&f.lstatSync();}f.shouldWalk(h,o)&&h.add(f);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(i=this.cwd,t={}){return typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd),this.stream(i,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(i=this.cwd,t={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd);let{withFileTypes:e=true,follow:s=false,filter:n,walkFilter:o}=t;(!n||n(i))&&(yield e?i:i.fullpath());let a=new Set([i]);for(let h of a){let l=h.readdirSync();for(let d of l){(!n||n(d))&&(yield e?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(s&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync();}p.shouldWalk(a,o)&&a.add(p);}}}stream(i=this.cwd,t={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd);let{withFileTypes:e=true,follow:s=false,filter:n,walkFilter:o}=t,a=new ls({objectMode:true});(!n||n(i))&&a.write(e?i:i.fullpath());let h=new Set,l=[i],d=0,p=()=>{let f=false;for(;!f;){let g=l.shift();if(!g){d===0&&a.end();return}d++,h.add(g);let y=(b,T,E=false)=>{if(b)return a.emit("error",b);if(s&&!E){let C=[];for(let O of T)O.isSymbolicLink()&&C.push(O.realpath().then(P=>P?.isUnknown()?P.lstat():P));if(C.length){Promise.all(C).then(()=>y(null,T,true));return}}for(let C of T)C&&(!n||n(C))&&(a.write(e?C:C.fullpath())||(f=true));d--;for(let C of T){let O=C.realpathCached()||C;O.shouldWalk(h,o)&&l.push(O);}f&&!a.flowing?a.once("drain",p):S||p();},S=true;g.readdirCB(y,true),S=false;}};return p(),a}streamSync(i=this.cwd,t={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ut||(t=i,i=this.cwd);let{withFileTypes:e=true,follow:s=false,filter:n,walkFilter:o}=t,a=new ls({objectMode:true}),h=new Set;(!n||n(i))&&a.write(e?i:i.fullpath());let l=[i],d=0,p=()=>{let f=false;for(;!f;){let g=l.shift();if(!g){d===0&&a.end();return}d++,h.add(g);let y=g.readdirSync();for(let S of y)(!n||n(S))&&(a.write(e?S:S.fullpath())||(f=true));d--;for(let S of y){let b=S;if(S.isSymbolicLink()){if(!(s&&(b=S.realpathSync())))continue;b.isUnknown()&&b.lstatSync();}b.shouldWalk(h,o)&&l.push(b);}}f&&!a.flowing&&a.once("drain",p);};return p(),a}chdir(i=this.cwd){let t=this.cwd;this.cwd=typeof i=="string"?this.cwd.resolve(i):i,this.cwd[wn](t);}},Je=new WeakMap,Ye=new WeakMap,Ni=new WeakMap,_i=new WeakMap,Wr),qs=class extends Rn{constructor(t=process.cwd(),e={}){let{nocase:s=true}=e;super(t,ti.win32,"\\",{...e,nocase:s});c(this,"sep","\\");this.nocase=s;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase;}parseRootPath(t){return ti.win32.parse(t).root.toUpperCase()}newRoot(t){return new Tn(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)}},Vs=class extends Rn{constructor(t=process.cwd(),e={}){let{nocase:s=false}=e;super(t,ti.posix,"/",{...e,nocase:s});c(this,"sep","/");this.nocase=s;}parseRootPath(t){return "/"}newRoot(t){return new Mn(this.rootPath,Wt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},kn=class extends Vs{constructor(i=process.cwd(),t={}){let{nocase:e=true}=t;super(i,{...t,nocase:e});}};process.platform==="win32"?Tn:Mn;var ka=process.platform==="win32"?qs:process.platform==="darwin"?kn:Vs,La=i=>i.length>=1,Oa=i=>i.length>=1,Pa=Symbol.for("nodejs.util.inspect.custom"),q,ft,V,Pe,Bt,Fi,ue,fe,pe,Ze,Xe,Ln=(Xe=class{constructor(t,e,s,n){w(this,q);w(this,ft);w(this,V);c(this,"length");w(this,Pe);w(this,Bt);w(this,Fi);w(this,ue);w(this,fe);w(this,pe);w(this,Ze,true);if(!La(t))throw new TypeError("empty pattern list");if(!Oa(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,s<0||s>=this.length)throw new TypeError("index out of range");if(u(this,q,t),u(this,ft,e),u(this,V,s),u(this,Pe,n),r(this,V)===0){if(this.isUNC()){let[o,a,h,l,...d]=r(this,q),[p,f,g,y,...S]=r(this,ft);d[0]===""&&(d.shift(),S.shift());let b=[o,a,h,l,""].join("/"),T=[p,f,g,y,""].join("/");u(this,q,[b,...d]),u(this,ft,[T,...S]),this.length=r(this,q).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=r(this,q),[h,...l]=r(this,ft);a[0]===""&&(a.shift(),l.shift());let d=o+"/",p=h+"/";u(this,q,[d,...a]),u(this,ft,[p,...l]),this.length=r(this,q).length;}}}[Pa](){return "Pattern <"+r(this,ft).slice(r(this,V)).join("/")+">"}pattern(){return r(this,q)[r(this,V)]}isString(){return typeof r(this,q)[r(this,V)]=="string"}isGlobstar(){return r(this,q)[r(this,V)]===ct}isRegExp(){return r(this,q)[r(this,V)]instanceof RegExp}globString(){return u(this,Fi,r(this,Fi)||(r(this,V)===0?this.isAbsolute()?r(this,ft)[0]+r(this,ft).slice(1).join("/"):r(this,ft).join("/"):r(this,ft).slice(r(this,V)).join("/")))}hasMore(){return this.length>r(this,V)+1}rest(){return r(this,Bt)!==void 0?r(this,Bt):this.hasMore()?(u(this,Bt,new Xe(r(this,q),r(this,ft),r(this,V)+1,r(this,Pe))),u(r(this,Bt),pe,r(this,pe)),u(r(this,Bt),fe,r(this,fe)),u(r(this,Bt),ue,r(this,ue)),r(this,Bt)):u(this,Bt,null)}isUNC(){let t=r(this,q);return r(this,fe)!==void 0?r(this,fe):u(this,fe,r(this,Pe)==="win32"&&r(this,V)===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):u(this,ue,r(this,Pe)==="win32"&&r(this,V)===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):u(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,V)===0?t:""}checkFollowGlobstar(){return !(r(this,V)===0||!this.isGlobstar()||!r(this,Ze))}markFollowGlobstar(){return r(this,V)===0||!this.isGlobstar()||!r(this,Ze)?false:(u(this,Ze,false),true)}},q=new WeakMap,ft=new WeakMap,V=new WeakMap,Pe=new WeakMap,Bt=new WeakMap,Fi=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,Ze=new WeakMap,Xe),Da=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",gr=class{constructor(i,{nobrace:t,nocase:e,noext:s,noglobstar:n,platform:o=Da}){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:s,noglobstar:n,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of i)this.add(a);}add(i){let t=new me(i,this.mmopts);for(let e=0;e<t.set.length;e++){let s=t.set[e],n=t.globParts[e];if(!s||!n)throw new Error("invalid pattern object");for(;s[0]==="."&&n[0]===".";)s.shift(),n.shift();let o=new Ln(s,n,0,this.platform),a=new me(o.globString(),this.mmopts),h=n[n.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(a):this.relative.push(a),h&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a));}}ignored(i){let t=i.fullpath(),e=`${t}/`,s=i.relative()||".",n=`${s}/`;for(let o of this.relative)if(o.match(s)||o.match(n))return true;for(let o of this.absolute)if(o.match(t)||o.match(e))return true;return false}childrenIgnored(i){let t=i.fullpath()+"/",e=(i.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(e))return true;for(let s of this.absoluteChildren)if(s.match(t))return true;return false}},Aa=class On{constructor(t=new Map){c(this,"store");this.store=t;}copy(){return new On(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),n=this.store.get(s);n?n.add(e.globString()):this.store.set(s,new Set([e.globString()]));}},Ia=class{constructor(){c(this,"store",new Map);}add(i,t,e){let s=(t?2:0)|(e?1:0),n=this.store.get(i);this.store.set(i,n===void 0?s:s&n);}entries(){return [...this.store.entries()].map(([i,t])=>[i,!!(t&2),!!(t&1)])}},Na=class{constructor(){c(this,"store",new Map);}add(i,t){if(!i.canReaddir())return;let e=this.store.get(i);e?e.find(s=>s.globString()===t.globString())||e.push(t):this.store.set(i,[t]);}get(i){let t=this.store.get(i);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(i=>[i,this.store.get(i)])}keys(){return [...this.store.keys()].filter(i=>i.canReaddir())}},mr=class Pn{constructor(t,e){c(this,"hasWalkedCache");c(this,"matches",new Ia);c(this,"subwalks",new Na);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 Aa;}processPatterns(t,e){this.patterns=e;let s=e.map(n=>[t,n]);for(let[n,o]of s){this.hasWalkedCache.storeWalked(n,o);let a=o.root(),h=o.isAbsolute()&&this.opts.absolute!==false;if(a){n=n.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let f=o.rest();if(f)o=f;else {this.matches.add(n,true,false);continue}}if(n.isENOENT())continue;let l,d,p=false;for(;typeof(l=o.pattern())=="string"&&(d=o.rest());)n=n.resolve(l),o=d,p=true;if(l=o.pattern(),d=o.rest(),p){if(this.hasWalkedCache.hasWalked(n,o))continue;this.hasWalkedCache.storeWalked(n,o);}if(typeof l=="string"){let f=l===".."||l===""||l===".";this.matches.add(n.resolve(l),h,f);continue}else if(l===ct){(!n.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(n,o);let f=d?.pattern(),g=d?.rest();if(!d||(f===""||f===".")&&!g)this.matches.add(n,h,f===""||f===".");else if(f===".."){let y=n.parent||n;g?this.hasWalkedCache.hasWalked(y,g)||this.subwalks.add(y,g):this.matches.add(y,h,true);}}else l instanceof RegExp&&this.subwalks.add(n,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Pn(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),n=this.child();for(let o of e)for(let a of s){let h=a.isAbsolute(),l=a.pattern(),d=a.rest();l===ct?n.testGlobstar(o,a,d,h):l instanceof RegExp?n.testRegExp(o,l,d,h):n.testString(o,l,d,h);}return n}testGlobstar(t,e,s,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()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let o=s.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,s.rest(),n);else if(o===".."){let a=t.parent||t;this.subwalks.add(a,s);}else o instanceof RegExp&&this.testRegExp(t,o,s.rest(),n);}}testRegExp(t,e,s,n){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,n,false));}testString(t,e,s,n){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,n,false));}},_a=(i,t)=>typeof i=="string"?new gr([i],t):Array.isArray(i)?new gr(i,t):i,Qe,ee,De,Ct,ve,$s,jr,Dn=(jr=class{constructor(i,t,e){w(this,Ct);c(this,"path");c(this,"patterns");c(this,"opts");c(this,"seen",new Set);c(this,"paused",false);c(this,"aborted",false);w(this,Qe,[]);w(this,ee);w(this,De);c(this,"signal");c(this,"maxDepth");c(this,"includeChildMatches");if(this.patterns=i,this.path=t,this.opts=e,u(this,De,!e.posix&&e.platform==="win32"?"\\":"/"),this.includeChildMatches=e.includeChildMatches!==false,(e.ignore||!this.includeChildMatches)&&(u(this,ee,_a(e.ignore??[],e)),!this.includeChildMatches&&typeof r(this,ee).add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=e.maxDepth||1/0,e.signal&&(this.signal=e.signal,this.signal.addEventListener("abort",()=>{r(this,Qe).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let i;for(;!this.paused&&(i=r(this,Qe).shift());)i();}onResume(i){this.signal?.aborted||(this.paused?r(this,Qe).push(i):i());}async matchCheck(i,t){if(t&&this.opts.nodir)return;let e;if(this.opts.realpath){if(e=i.realpathCached()||await i.realpath(),!e)return;i=e;}let s=i.isUnknown()||this.opts.stat?await i.lstat():i;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let n=await s.realpath();n&&(n.isUnknown()||this.opts.stat)&&await n.lstat();}return this.matchCheckTest(s,t)}matchCheckTest(i,t){return i&&(this.maxDepth===1/0||i.depth()<=this.maxDepth)&&(!t||i.canReaddir())&&(!this.opts.nodir||!i.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!i.isSymbolicLink()||!i.realpathCached()?.isDirectory())&&!m(this,Ct,ve).call(this,i)?i:void 0}matchCheckSync(i,t){if(t&&this.opts.nodir)return;let e;if(this.opts.realpath){if(e=i.realpathCached()||i.realpathSync(),!e)return;i=e;}let s=i.isUnknown()||this.opts.stat?i.lstatSync():i;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let n=s.realpathSync();n&&(n?.isUnknown()||this.opts.stat)&&n.lstatSync();}return this.matchCheckTest(s,t)}matchFinish(i,t){if(m(this,Ct,ve).call(this,i))return;if(!this.includeChildMatches&&r(this,ee)?.add){let n=`${i.relativePosix()}/**`;r(this,ee).add(n);}let e=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(i);let s=this.opts.mark&&i.isDirectory()?r(this,De):"";if(this.opts.withFileTypes)this.matchEmit(i);else if(e){let n=this.opts.posix?i.fullpathPosix():i.fullpath();this.matchEmit(n+s);}else {let n=this.opts.posix?i.relativePosix():i.relative(),o=this.opts.dotRelative&&!n.startsWith(".."+r(this,De))?"."+r(this,De):"";this.matchEmit(n?o+n+s:"."+s);}}async match(i,t,e){let s=await this.matchCheck(i,e);s&&this.matchFinish(s,t);}matchSync(i,t,e){let s=this.matchCheckSync(i,e);s&&this.matchFinish(s,t);}walkCB(i,t,e){this.signal?.aborted&&e(),this.walkCB2(i,t,new mr(this.opts),e);}walkCB2(i,t,e,s){if(m(this,Ct,$s).call(this,i))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(i,t,e,s));return}e.processPatterns(i,t);let n=1,o=()=>{--n===0&&s();};for(let[a,h,l]of e.matches.entries())m(this,Ct,ve).call(this,a)||(n++,this.match(a,h,l).then(()=>o()));for(let a of e.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let h=a.readdirCached();a.calledReaddir()?this.walkCB3(a,h,e,o):a.readdirCB((l,d)=>this.walkCB3(a,d,e,o),true);}o();}walkCB3(i,t,e,s){e=e.filterEntries(i,t);let n=1,o=()=>{--n===0&&s();};for(let[a,h,l]of e.matches.entries())m(this,Ct,ve).call(this,a)||(n++,this.match(a,h,l).then(()=>o()));for(let[a,h]of e.subwalks.entries())n++,this.walkCB2(a,h,e.child(),o);o();}walkCBSync(i,t,e){this.signal?.aborted&&e(),this.walkCB2Sync(i,t,new mr(this.opts),e);}walkCB2Sync(i,t,e,s){if(m(this,Ct,$s).call(this,i))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(i,t,e,s));return}e.processPatterns(i,t);let n=1,o=()=>{--n===0&&s();};for(let[a,h,l]of e.matches.entries())m(this,Ct,ve).call(this,a)||this.matchSync(a,h,l);for(let a of e.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;n++;let h=a.readdirSync();this.walkCB3Sync(a,h,e,o);}o();}walkCB3Sync(i,t,e,s){e=e.filterEntries(i,t);let n=1,o=()=>{--n===0&&s();};for(let[a,h,l]of e.matches.entries())m(this,Ct,ve).call(this,a)||this.matchSync(a,h,l);for(let[a,h]of e.subwalks.entries())n++,this.walkCB2Sync(a,h,e.child(),o);o();}},Qe=new WeakMap,ee=new WeakMap,De=new WeakMap,Ct=new WeakSet,ve=function(i){return this.seen.has(i)||!!r(this,ee)?.ignored?.(i)},$s=function(i){return !!r(this,ee)?.childrenIgnored?.(i)},jr),yr=class extends Dn{constructor(t,e,s){super(t,e,s);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}},wr=class extends Dn{constructor(t,e,s){super(t,e,s);c(this,"results");this.results=new ls({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}},Fa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ie=class{constructor(i,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 i=="string"&&(i=[i]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(i=i.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");i=i.map(h=>h.includes("/")?h:`./**/${h}`);}if(this.pattern=i,this.platform=t.platform||Fa,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 h=t.platform==="win32"?qs:t.platform==="darwin"?kn:t.platform?Vs:ka;this.scurry=new h(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let e=this.platform==="darwin"||this.platform==="win32",s={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(h=>new me(h,s)),[o,a]=n.reduce((h,l)=>(h[0].push(...l.set),h[1].push(...l.globParts),h),[[],[]]);this.patterns=o.map((h,l)=>{let d=a[l];if(!d)throw new Error("invalid pattern object");return new Ln(h,d,0,this.platform)});}async walk(){return [...await new yr(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 yr(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 wr(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 wr(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()}},Ua=(i,t={})=>{Array.isArray(i)||(i=[i]);for(let e of i)if(new me(e,t).hasMagic())return true;return false};function ds(i,t={}){return new Ie(i,t).streamSync()}function An(i,t={}){return new Ie(i,t).stream()}function In(i,t={}){return new Ie(i,t).walkSync()}async function br(i,t={}){return new Ie(i,t).walk()}function us(i,t={}){return new Ie(i,t).iterateSync()}function Nn(i,t={}){return new Ie(i,t).iterate()}var Ba=ds,za=Object.assign(An,{sync:ds}),$a=us,Wa=Object.assign(Nn,{sync:us}),ja=Object.assign(In,{stream:ds,iterate:us}),hs=Object.assign(br,{glob:br,globSync:In,sync:ja,globStream:An,stream:za,globStreamSync:ds,streamSync:Ba,globIterate:Nn,iterate:Wa,globIterateSync:us,iterateSync:$a,Glob:Ie,hasMagic:Ua,escape:Qr,unescape:ze});hs.glob=hs;var ye;(P=>{P.Level=qa__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 s(M){return t[M]>=t[e]}function n(){return e}P.getLevel=n;let o=new Map;P.Default=O({service:"default"});let h="";function l(){return h}P.file=l;let d,p,f=false,g=()=>{},y=false;async function S(M){if(f)return;if(M.print){f=true;return}M.level&&(e=M.level);let D=M.logDir||ti__namespace.default.join(process.cwd(),"logs");M.logFile?h=ti__namespace.default.join(D,M.logFile??"local-model-sdk.log"):h=ti__namespace.default.join(D,"local-model-sdk.log");try{d=await _n__default.default.open(h,"a"),p=z.createWriteStream("",{fd:d.fd,autoClose:!1}),g=F=>{if(!(y||!p||p.destroyed))try{if(!p.writable)return;p.write(F,it=>{it&&!y&&(y=!0,setTimeout(()=>{y=!1;},1e3));});}catch{y||(y=!0,setTimeout(()=>{y=!1;},1e3));}},f=!0;}catch{g=F=>{try{process.stderr.write(F);}catch{}},f=true;}}P.init=S;async function b(){f&&(p&&!p.destroyed&&(await new Promise((M,D)=>{p.end(F=>{F?D(F):M();});}).catch(()=>{}),p=void 0),d&&(await d.close().catch(()=>{}),d=void 0),g=M=>{try{process.stderr.write(M);}catch{}},f=false);}P.close=b;function E(M,D=0){let F=M.message;return M.cause instanceof Error&&D<10?F+" Caused by: "+E(M.cause,D+1):F}let C=Date.now();function O(M){M=M||{};let D=M.service;if(D&&typeof D=="string"){let _=o.get(D);if(_)return _}function F(_,K){let ys=Object.entries({...M,...K}).filter(([Js,ie])=>ie!=null).map(([Js,ie])=>{let ws=`${Js}=`;return ie instanceof Error?ws+E(ie):typeof ie=="object"?ws+JSON.stringify(ie):ws+ie}).join(" "),Rt=new Date,jn=Rt.getTime()-C;return C=Rt.getTime(),[Rt.getFullYear()+"-"+String(Rt.getMonth()+1).padStart(2,"0")+"-"+String(Rt.getDate()).padStart(2,"0")+"T"+String(Rt.getHours()).padStart(2,"0")+":"+String(Rt.getMinutes()).padStart(2,"0")+":"+String(Rt.getSeconds()).padStart(2,"0"),"+"+jn+"ms",ys,_].filter(Boolean).join(" ")+`
4
- `}let it={debug(_,K){s("DEBUG")&&g("DEBUG "+F(_,K));},info(_,K){s("INFO")&&g("INFO "+F(_,K));},error(_,K){s("ERROR")&&g("ERROR "+F(_,K));},warn(_,K){s("WARN")&&g("WARN "+F(_,K));},tag(_,K){return M&&(M[_]=K),it},clone(){return P.create({...M})},time(_,K){let ys=Date.now();it.info(_,{status:"started",...K});function Rt(){it.info(_,{status:"completed",duration:Date.now()-ys,...K});}return {stop:Rt,[Symbol.dispose](){Rt();}}}};return D&&typeof D=="string"&&o.set(D,it),it}P.create=O;})(ye||(ye={}));var U=ye.create({service:"transformers-engine"});var Va=ti__namespace.join(Zs__namespace.homedir(),".cache","easbot","models");process.env.HF_HOME||(process.env.HF_HOME=Va);transformers.env.allowLocalModels=true;transformers.env.allowRemoteModels=true;transformers.env.useBrowserCache=false;transformers.env.useFSCache=true;var fs=class{constructor(t){c(this,"pipeline",null);c(this,"tokenizer",null);c(this,"isInitialized",false);c(this,"config");c(this,"modelCache");this.config=t,this.modelCache=new Fe({cacheDir:t.cacheDir}),this.configureEnvironment();}configureEnvironment(){this.modelCache.ensureCacheDir(),process.env.HF_HOME||(process.env.HF_HOME=this.config.cacheDir),transformers.env.cacheDir=this.config.cacheDir,transformers.env.allowLocalModels=true,transformers.env.allowRemoteModels=true,transformers.env.useBrowserCache=false,transformers.env.useFSCache=true,transformers.env.backends?.onnx&&(transformers.env.backends.onnx.logLevel="error"),this.config.verbose&&U.debug("\u73AF\u5883\u914D\u7F6E\u5B8C\u6210",{cacheDir:this.config.cacheDir,hfHome:process.env.HF_HOME,modelId:this.config.modelId,modelType:this.config.modelType});}async initialize(){if(this.isInitialized){this.config.verbose&&U.debug("\u6A21\u578B\u5DF2\u521D\u59CB\u5316\uFF0C\u8DF3\u8FC7\u91CD\u590D\u52A0\u8F7D");return}try{this.config.verbose&&U.debug("\u5F00\u59CB\u521D\u59CB\u5316\u6A21\u578B");let t,e;if(this.config.modelType==="language"){let o=kt[this.config.modelId];if(!o)throw new x(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");t=o.huggingFaceId,e=o.dtype;}else {let o=be[this.config.modelId];if(!o)throw new x(`\u4E0D\u652F\u6301\u7684 Embedding Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");t=o.huggingFaceId,e=o.dtype;}this.config.verbose&&(U.debug("\u52A0\u8F7D\u6A21\u578B",{huggingFaceId:t,dtype:e||"auto"}),this.modelCache.isCached(t)?U.debug("\u4F7F\u7528\u7F13\u5B58\u7684\u6A21\u578B"):U.debug("\u9996\u6B21\u4E0B\u8F7D\u6A21\u578B\uFF0C\u53EF\u80FD\u9700\u8981\u4E00\u4E9B\u65F6\u95F4"));let s={cache_dir:this.config.cacheDir,local_files_only:!0};if(e&&(s.dtype=e),this.modelCache.isCached(t))this.config.verbose&&U.debug("\u4F7F\u7528\u672C\u5730\u7F13\u5B58\u6A21\u578B");else throw this.config.verbose&&U.warn("\u672C\u5730\u7F13\u5B58\u4E0D\u5B58\u5728",{huggingFaceId:t,cacheDir:this.config.cacheDir}),new x(`\u6A21\u578B ${t} \u672A\u627E\u5230\u672C\u5730\u7F13\u5B58\u3002\u8BF7\u5148\u4E0B\u8F7D\u6A21\u578B\u5230: ${this.config.cacheDir}`,"MODEL_NOT_FOUND");this.config.modelType==="language"?this.pipeline=await transformers.pipeline("text-generation",t,s):this.pipeline=await transformers.pipeline("feature-extraction",t,s),this.tokenizer=this.pipeline.tokenizer,this.isInitialized=!0,this.config.verbose&&U.debug("\u6A21\u578B\u521D\u59CB\u5316\u6210\u529F",{modelId:this.config.modelId});}catch(t){throw this.config.verbose&&U.error("\u6A21\u578B\u521D\u59CB\u5316\u5931\u8D25",{error:t}),nt.modelLoadError(t instanceof Error?t:new Error(String(t)))}}extractAssistantResponse(t,e){let s=`<|im_start|>assistant
5
- `,n=t.lastIndexOf(s);if(n!==-1){let p=t.slice(n+s.length);return p=p.replace(/<\|im_end\|>$/g,""),p.trim()}let o=`
1
+ 'use strict';var transformers=require('@huggingface/transformers'),er=require('os'),ti=require('path'),B=require('fs'),Ys=require('fs/promises'),Ha=require('zod'),url=require('url'),events=require('events'),un=require('stream'),string_decoder=require('string_decoder');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var er__namespace=/*#__PURE__*/_interopNamespace(er);var ti__namespace=/*#__PURE__*/_interopNamespace(ti);var B__namespace=/*#__PURE__*/_interopNamespace(B);var Ys__default=/*#__PURE__*/_interopDefault(Ys);var Ha__default=/*#__PURE__*/_interopDefault(Ha);var un__default=/*#__PURE__*/_interopDefault(un);var Vn=Object.defineProperty;var Qs=i=>{throw TypeError(i)};var Hn=(i,e,t)=>e in i?Vn(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var c=(i,e,t)=>Hn(i,typeof e!="symbol"?e+"":e,t),vs=(i,e,t)=>e.has(i)||Qs("Cannot "+t);var n=(i,e,t)=>(vs(i,e,"read from private field"),t?t.call(i):e.get(i)),w=(i,e,t)=>e.has(i)?Qs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),f=(i,e,t,s)=>(vs(i,e,"write to private field"),e.set(i,t),t),y=(i,e,t)=>(vs(i,e,"access private method"),t);var Gi=(i,e,t,s)=>({set _(r){f(i,e,r);},get _(){return n(i,e,s)}});var ge=(u=>(u.MODEL_NOT_FOUND="MODEL_NOT_FOUND",u.MODEL_LOAD_ERROR="MODEL_LOAD_ERROR",u.MODEL_NOT_INITIALIZED="MODEL_NOT_INITIALIZED",u.GENERATION_ERROR="GENERATION_ERROR",u.EMBEDDING_ERROR="EMBEDDING_ERROR",u.INVALID_INPUT="INVALID_INPUT",u.UNSUPPORTED_FEATURE="UNSUPPORTED_FEATURE",u.CACHE_ERROR="CACHE_ERROR",u.PROCESSING_ERROR="PROCESSING_ERROR",u.ABORTED="ABORTED",u.OUT_OF_MEMORY="OUT_OF_MEMORY",u.UNKNOWN_ERROR="UNKNOWN_ERROR",u))(ge||{});function qi(i,e,t){let s;return e?s="error":i?s="stop":s="other",{unified:s,raw:t}}var Ee={"qwen3-0.6b":{modelId:"qwen3-0.6b",huggingFaceId:"onnx-community/Qwen3-0.6B-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}},"gemma-3-1b-it":{modelId:"gemma-3-1b-it",huggingFaceId:"onnx-community/gemma-3-1b-it-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}}},bt={"bge-small-zh-v1.5":{modelId:"bge-small-zh-v1.5",huggingFaceId:"Xenova/bge-small-zh-v1.5",dimensions:512,maxEmbeddingsPerCall:32},"bge-base-zh-v1.5":{modelId:"bge-base-zh-v1.5",huggingFaceId:"Xenova/bge-base-zh-v1.5",dimensions:768,maxEmbeddingsPerCall:32},"bge-large-zh-v1.5":{modelId:"bge-large-zh-v1.5",huggingFaceId:"Xenova/bge-large-zh-v1.5",dimensions:1024,maxEmbeddingsPerCall:32},"all-MiniLM-L6-v2":{modelId:"all-MiniLM-L6-v2",huggingFaceId:"sentence-transformers/all-MiniLM-L6-v2",dimensions:384,maxEmbeddingsPerCall:32}};var x=class i extends Error{constructor(t,s,r){super(t);this.code=s;this.cause=r;this.name="LocalModelError",Error.captureStackTrace&&Error.captureStackTrace(this,i);}},ne=class{static modelLoadError(e){return new x(`\u6A21\u578B\u52A0\u8F7D\u5931\u8D25: ${e.message}`,"MODEL_LOAD_ERROR",e)}static generationError(e){return new x(`\u751F\u6210\u5931\u8D25: ${e.message}`,"GENERATION_ERROR",e)}static embeddingError(e){return new x(`\u5D4C\u5165\u5931\u8D25: ${e.message}`,"EMBEDDING_ERROR",e)}static validationError(e){return new x(e,"INVALID_INPUT")}static abortError(){return new x("\u64CD\u4F5C\u5DF2\u4E2D\u6B62","ABORTED")}static unsupportedFeature(e){return new x(`\u4E0D\u652F\u6301\u7684\u529F\u80FD: ${e}`,"UNSUPPORTED_FEATURE")}};var Kn=ti__namespace.join(er__namespace.homedir(),".cache","easbot","models"),Ut=class{constructor(e){c(this,"cacheDir");this.cacheDir=e.cacheDir||Kn;}getCachePath(e){return ti__namespace.join(this.cacheDir,e)}isCached(e){try{let t=this.getCachePath(e);return B__namespace.existsSync(t)&&B__namespace.statSync(t).isDirectory()}catch{return false}}async clear(e){try{if(e){let t=this.getCachePath(e);B__namespace.existsSync(t)&&await this.removeDirectory(t);}else B__namespace.existsSync(this.cacheDir)&&await this.removeDirectory(this.cacheDir);}catch(t){throw new x(`\u6E05\u7406\u7F13\u5B58\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`,"CACHE_ERROR",t instanceof Error?t:void 0)}}async getCacheSize(e){try{let t=e?this.getCachePath(e):this.cacheDir;return B__namespace.existsSync(t)?await this.getDirectorySize(t):0}catch(t){throw new x(`\u83B7\u53D6\u7F13\u5B58\u5927\u5C0F\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`,"CACHE_ERROR",t instanceof Error?t:void 0)}}async getDirectorySize(e){let t=0,s=B__namespace.readdirSync(e);for(let r of s){let o=ti__namespace.join(e,r),a=B__namespace.statSync(o);a.isDirectory()?t+=await this.getDirectorySize(o):t+=a.size;}return t}async removeDirectory(e){if(!B__namespace.existsSync(e))return;let t=B__namespace.readdirSync(e);for(let s of t){let r=ti__namespace.join(e,s);B__namespace.statSync(r).isDirectory()?await this.removeDirectory(r):B__namespace.unlinkSync(r);}B__namespace.rmdirSync(e);}ensureCacheDir(){try{B__namespace.existsSync(this.cacheDir)||B__namespace.mkdirSync(this.cacheDir,{recursive:!0});}catch(e){throw new x(`\u521B\u5EFA\u7F13\u5B58\u76EE\u5F55\u5931\u8D25: ${e instanceof Error?e.message:String(e)}`,"CACHE_ERROR",e instanceof Error?e:void 0)}}};var Hr=(i,e,t)=>{let s=i instanceof RegExp?tr(i,t):i,r=e instanceof RegExp?tr(e,t):e,o=s!==null&&r!=null&&Jn(s,r,t);return o&&{start:o[0],end:o[1],pre:t.slice(0,o[0]),body:t.slice(o[0]+s.length,o[1]),post:t.slice(o[1]+r.length)}},tr=(i,e)=>{let t=e.match(i);return t?t[0]:null},Jn=(i,e,t)=>{let s,r,o,a,h,l=t.indexOf(i),d=t.indexOf(e,l+1),g=l;if(l>=0&&d>0){if(i===e)return [l,d];for(s=[],o=t.length;g>=0&&!h;){if(g===l)s.push(g),l=t.indexOf(i,g+1);else if(s.length===1){let p=s.pop();p!==void 0&&(h=[p,d]);}else r=s.pop(),r!==void 0&&r<o&&(o=r,a=d),d=t.indexOf(e,g+1);g=l<d&&l>=0?l:d;}s.length&&a!==void 0&&(h=[o,a]);}return h},Kr="\0SLASH"+Math.random()+"\0",Jr="\0OPEN"+Math.random()+"\0",Gs="\0CLOSE"+Math.random()+"\0",Yr="\0COMMA"+Math.random()+"\0",Zr="\0PERIOD"+Math.random()+"\0",Yn=new RegExp(Kr,"g"),Zn=new RegExp(Jr,"g"),Xn=new RegExp(Gs,"g"),Qn=new RegExp(Yr,"g"),eo=new RegExp(Zr,"g"),to=/\\\\/g,io=/\\{/g,so=/\\}/g,ro=/\\,/g,no=/\\./g,oo=1e5;function Es(i){return isNaN(i)?i.charCodeAt(0):parseInt(i,10)}function ao(i){return i.replace(to,Kr).replace(io,Jr).replace(so,Gs).replace(ro,Yr).replace(no,Zr)}function lo(i){return i.replace(Yn,"\\").replace(Zn,"{").replace(Xn,"}").replace(Qn,",").replace(eo,".")}function Xr(i){if(!i)return [""];let e=[],t=Hr("{","}",i);if(!t)return i.split(",");let{pre:s,body:r,post:o}=t,a=s.split(",");a[a.length-1]+="{"+r+"}";let h=Xr(o);return o.length&&(a[a.length-1]+=h.shift(),a.push.apply(a,h)),e.push.apply(e,a),e}function ho(i,e={}){if(!i)return [];let{max:t=oo}=e;return i.slice(0,2)==="{}"&&(i="\\{\\}"+i.slice(2)),li(ao(i),t,true).map(lo)}function co(i){return "{"+i+"}"}function uo(i){return /^-?0\d/.test(i)}function po(i,e){return i<=e}function fo(i,e){return i>=e}function li(i,e,t){let s=[],r=Hr("{","}",i);if(!r)return [i];let o=r.pre,a=r.post.length?li(r.post,e,false):[""];if(/\$$/.test(r.pre))for(let h=0;h<a.length&&h<e;h++){let l=o+"{"+r.body+"}"+a[h];s.push(l);}else {let h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),d=h||l,g=r.body.indexOf(",")>=0;if(!d&&!g)return r.post.match(/,(?!,).*\}/)?(i=r.pre+"{"+r.body+Gs+r.post,li(i,e,true)):[i];let p;if(d)p=r.body.split(/\.\./);else if(p=Xr(r.body),p.length===1&&p[0]!==void 0&&(p=li(p[0],e,false).map(co),p.length===1))return a.map(m=>r.pre+p[0]+m);let u;if(d&&p[0]!==void 0&&p[1]!==void 0){let m=Es(p[0]),b=Es(p[1]),S=Math.max(p[0].length,p[1].length),T=p.length===3&&p[2]!==void 0?Math.abs(Es(p[2])):1,v=po;b<m&&(T*=-1,v=fo);let M=p.some(uo);u=[];for(let O=m;v(O,b);O+=T){let P;if(l)P=String.fromCharCode(O),P==="\\"&&(P="");else if(P=String(O),M){let k=S-P.length;if(k>0){let D=new Array(k+1).join("0");O<0?P="-"+D+P.slice(1):P=D+P;}}u.push(P);}}else {u=[];for(let m=0;m<p.length;m++)u.push.apply(u,li(p[m],e,false));}for(let m=0;m<u.length;m++)for(let b=0;b<a.length&&s.length<e;b++){let S=o+u[m]+a[b];(!t||d||S)&&s.push(S);}}return s}var ls=i=>{if(typeof i!="string")throw new TypeError("invalid pattern");if(i.length>65536)throw new TypeError("pattern is too long")},go={"[: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]},ii=i=>i.replace(/[[\]\\-]/g,"\\$&"),mo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ir=i=>i.join(""),yo=(i,e)=>{let t=e;if(i.charAt(t)!=="[")throw new Error("not in a brace expression");let s=[],r=[],o=t+1,a=false,h=false,l=false,d=false,g=t,p="";e:for(;o<i.length;){let b=i.charAt(o);if((b==="!"||b==="^")&&o===t+1){d=true,o++;continue}if(b==="]"&&a&&!l){g=o+1;break}if(a=true,b==="\\"&&!l){l=true,o++;continue}if(b==="["&&!l){for(let[S,[T,v,M]]of Object.entries(go))if(i.startsWith(S,o)){if(p)return ["$.",false,i.length-t,true];o+=S.length,M?r.push(T):s.push(T),h=h||v;continue e}}if(l=false,p){b>p?s.push(ii(p)+"-"+ii(b)):b===p&&s.push(ii(b)),p="",o++;continue}if(i.startsWith("-]",o+1)){s.push(ii(b+"-")),o+=2;continue}if(i.startsWith("-",o+1)){p=b,o+=2;continue}s.push(ii(b)),o++;}if(g<o)return ["",false,0,false];if(!s.length&&!r.length)return ["$.",false,i.length-t,true];if(r.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!d){let b=s[0].length===2?s[0].slice(-1):s[0];return [mo(b),false,g-t,false]}let u="["+(d?"^":"")+ir(s)+"]",m="["+(d?"":"^")+ir(r)+"]";return [s.length&&r.length?"("+u+"|"+m+")":s.length?u:m,h,g-t,true]},zt=(i,{windowsPathsNoEscape:e=false,magicalBraces:t=true}={})=>t?e?i.replace(/\[([^\/\\])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?i.replace(/\[([^\/\\{}])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),wo=new Set(["!","?","+","*","@"]),sr=i=>wo.has(i),bo="(?!(?:^|/)\\.\\.?(?:$|/))",Vi="(?!\\.)",So=new Set(["[","."]),vo=new Set(["..","."]),Eo=new Set("().*{}+?[]^$\\!"),xo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),qs="[^/]",rr=qs+"*?",nr=qs+"+?",G,X,Ye,I,z,ct,xt,dt,Ge,Tt,gi,At,en,yt,te,es,Os,tn,Qr=(te=class{constructor(e,t,s={}){w(this,At);c(this,"type");w(this,G);w(this,X);w(this,Ye,false);w(this,I,[]);w(this,z);w(this,ct);w(this,xt);w(this,dt,false);w(this,Ge);w(this,Tt);w(this,gi,false);this.type=e,e&&f(this,X,true),f(this,z,t),f(this,G,n(this,z)?n(n(this,z),G):this),f(this,Ge,n(this,G)===this?s:n(n(this,G),Ge)),f(this,xt,n(this,G)===this?[]:n(n(this,G),xt)),e==="!"&&!n(n(this,G),dt)&&n(this,xt).push(this),f(this,ct,n(this,z)?n(n(this,z),I).length:0);}get hasMagic(){if(n(this,X)!==void 0)return n(this,X);for(let e of n(this,I))if(typeof e!="string"&&(e.type||e.hasMagic))return f(this,X,true);return n(this,X)}toString(){return n(this,Tt)!==void 0?n(this,Tt):this.type?f(this,Tt,this.type+"("+n(this,I).map(e=>String(e)).join("|")+")"):f(this,Tt,n(this,I).map(e=>String(e)).join(""))}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof te&&n(t,z)===this))throw new Error("invalid part: "+t);n(this,I).push(t);}}toJSON(){let e=this.type===null?n(this,I).slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...n(this,I).map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===n(this,G)||n(n(this,G),dt)&&n(this,z)?.type==="!")&&e.push({}),e}isStart(){if(n(this,G)===this)return true;if(!n(this,z)?.isStart())return false;if(n(this,ct)===0)return true;let e=n(this,z);for(let t=0;t<n(this,ct);t++){let s=n(e,I)[t];if(!(s instanceof te&&s.type==="!"))return false}return true}isEnd(){if(n(this,G)===this||n(this,z)?.type==="!")return true;if(!n(this,z)?.isEnd())return false;if(!this.type)return n(this,z)?.isEnd();let e=n(this,z)?n(n(this,z),I).length:0;return n(this,ct)===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this));}clone(e){let t=new te(this.type,e);for(let s of n(this,I))t.copyIn(s);return t}static fromGlob(e,t={}){var r;let s=new te(null,void 0,t);return y(r=te,yt,es).call(r,e,s,0,t),s}toMMPattern(){if(this!==n(this,G))return n(this,G).toMMPattern();let e=this.toString(),[t,s,r,o]=this.toRegExpSource();if(!(r||n(this,X)||n(this,Ge).nocase&&!n(this,Ge).nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return s;let a=(n(this,Ge).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return n(this,Ge)}toRegExpSource(e){let t=e??!!n(this,Ge).dot;if(n(this,G)===this&&y(this,At,en).call(this),!this.type){let l=this.isStart()&&this.isEnd()&&!n(this,I).some(u=>typeof u!="string"),d=n(this,I).map(u=>{var v;let[m,b,S,T]=typeof u=="string"?y(v=te,yt,tn).call(v,u,n(this,X),l):u.toRegExpSource(e);return f(this,X,n(this,X)||S),f(this,Ye,n(this,Ye)||T),m}).join(""),g="";if(this.isStart()&&typeof n(this,I)[0]=="string"&&!(n(this,I).length===1&&vo.has(n(this,I)[0]))){let u=So,m=t&&u.has(d.charAt(0))||d.startsWith("\\.")&&u.has(d.charAt(2))||d.startsWith("\\.\\.")&&u.has(d.charAt(4)),b=!t&&!e&&u.has(d.charAt(0));g=m?bo:b?Vi:"";}let p="";return this.isEnd()&&n(n(this,G),dt)&&n(this,z)?.type==="!"&&(p="(?:$|\\/)"),[g+d+p,zt(d),f(this,X,!!n(this,X)),n(this,Ye)]}let s=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",o=y(this,At,Os).call(this,t);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return f(this,I,[l]),this.type=null,f(this,X,void 0),[l,zt(this.toString()),false,false]}let a=!s||e||t||!Vi?"":y(this,At,Os).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let h="";if(this.type==="!"&&n(this,gi))h=(this.isStart()&&!t?Vi:"")+nr;else {let l=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Vi:"")+rr+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;h=r+o+l;}return [h,zt(o),f(this,X,!!n(this,X)),n(this,Ye)]}},G=new WeakMap,X=new WeakMap,Ye=new WeakMap,I=new WeakMap,z=new WeakMap,ct=new WeakMap,xt=new WeakMap,dt=new WeakMap,Ge=new WeakMap,Tt=new WeakMap,gi=new WeakMap,At=new WeakSet,en=function(){if(this!==n(this,G))throw new Error("should only call on root");if(n(this,dt))return this;this.toString(),f(this,dt,true);let e;for(;e=n(this,xt).pop();){if(e.type!=="!")continue;let t=e,s=n(t,z);for(;s;){for(let r=n(t,ct)+1;!s.type&&r<n(s,I).length;r++)for(let o of n(e,I)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n(s,I)[r]);}t=s,s=n(t,z);}}return this},yt=new WeakSet,es=function(e,t,s,r){var m,b;let o=false,a=false,h=-1,l=false;if(t.type===null){let S=s,T="";for(;S<e.length;){let v=e.charAt(S++);if(o||v==="\\"){o=!o,T+=v;continue}if(a){S===h+1?(v==="^"||v==="!")&&(l=true):v==="]"&&!(S===h+2&&l)&&(a=false),T+=v;continue}else if(v==="["){a=true,h=S,l=false,T+=v;continue}if(!r.noext&&sr(v)&&e.charAt(S)==="("){t.push(T),T="";let M=new te(v,t);S=y(m=te,yt,es).call(m,e,M,S,r),t.push(M);continue}T+=v;}return t.push(T),S}let d=s+1,g=new te(null,t),p=[],u="";for(;d<e.length;){let S=e.charAt(d++);if(o||S==="\\"){o=!o,u+=S;continue}if(a){d===h+1?(S==="^"||S==="!")&&(l=true):S==="]"&&!(d===h+2&&l)&&(a=false),u+=S;continue}else if(S==="["){a=true,h=d,l=false,u+=S;continue}if(sr(S)&&e.charAt(d)==="("){g.push(u),u="";let T=new te(S,g);g.push(T),d=y(b=te,yt,es).call(b,e,T,d,r);continue}if(S==="|"){g.push(u),u="",p.push(g),g=new te(null,t);continue}if(S===")")return u===""&&n(t,I).length===0&&f(t,gi,true),g.push(u),u="",t.push(...p,g),d;u+=S;}return t.type=null,f(t,X,void 0),f(t,I,[e.substring(s-1)]),d},Os=function(e){return n(this,I).map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[s,r,o,a]=t.toRegExpSource(e);return f(this,Ye,n(this,Ye)||a),s}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")},tn=function(e,t,s=false){let r=false,o="",a=false,h=false;for(let l=0;l<e.length;l++){let d=e.charAt(l);if(r){r=false,o+=(Eo.has(d)?"\\":"")+d;continue}if(d==="*"){if(h)continue;h=true,o+=s&&/^[*]+$/.test(e)?nr:rr,t=true;continue}else h=false;if(d==="\\"){l===e.length-1?o+="\\\\":r=true;continue}if(d==="["){let[g,p,u,m]=yo(e,l);if(u){o+=g,a=a||p,l+=u-1,t=t||m;continue}}if(d==="?"){o+=qs,t=true;continue}o+=xo(d);}return [o,zt(e),!!t,a]},w(te,yt),te),sn=(i,{windowsPathsNoEscape:e=false,magicalBraces:t=false}={})=>t?e?i.replace(/[?*()[\]{}]/g,"[$&]"):i.replace(/[?*()[\]\\{}]/g,"\\$&"):e?i.replace(/[?*()[\]]/g,"[$&]"):i.replace(/[?*()[\]\\]/g,"\\$&"),de=(i,e,t={})=>(ls(e),!t.nocomment&&e.charAt(0)==="#"?false:new wt(e,t).match(i)),To=/^\*+([^+@!?\*\[\(]*)$/,ko=i=>e=>!e.startsWith(".")&&e.endsWith(i),Mo=i=>e=>e.endsWith(i),Ro=i=>(i=i.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(i)),Lo=i=>(i=i.toLowerCase(),e=>e.toLowerCase().endsWith(i)),Co=/^\*+\.\*+$/,Oo=i=>!i.startsWith(".")&&i.includes("."),Po=i=>i!=="."&&i!==".."&&i.includes("."),Do=/^\.\*+$/,Ao=i=>i!=="."&&i!==".."&&i.startsWith("."),Io=/^\*+$/,No=i=>i.length!==0&&!i.startsWith("."),_o=i=>i.length!==0&&i!=="."&&i!=="..",Fo=/^\?+([^+@!?\*\[\(]*)?$/,Uo=([i,e=""])=>{let t=rn([i]);return e?(e=e.toLowerCase(),s=>t(s)&&s.toLowerCase().endsWith(e)):t},$o=([i,e=""])=>{let t=nn([i]);return e?(e=e.toLowerCase(),s=>t(s)&&s.toLowerCase().endsWith(e)):t},Bo=([i,e=""])=>{let t=nn([i]);return e?s=>t(s)&&s.endsWith(e):t},zo=([i,e=""])=>{let t=rn([i]);return e?s=>t(s)&&s.endsWith(e):t},rn=([i])=>{let e=i.length;return t=>t.length===e&&!t.startsWith(".")},nn=([i])=>{let e=i.length;return t=>t.length===e&&t!=="."&&t!==".."},on=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",or={win32:{sep:"\\"},posix:{sep:"/"}},jo=on==="win32"?or.win32.sep:or.posix.sep;de.sep=jo;var ce=Symbol("globstar **");de.GLOBSTAR=ce;var Wo="[^/]",Go=Wo+"*?",qo="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Vo="(?:(?!(?:\\/|^)\\.).)*?",Ho=(i,e={})=>t=>de(t,i,e);de.filter=Ho;var xe=(i,e={})=>Object.assign({},i,e),Ko=i=>{if(!i||typeof i!="object"||!Object.keys(i).length)return de;let e=de;return Object.assign((t,s,r={})=>e(t,s,xe(i,r)),{Minimatch:class extends e.Minimatch{constructor(t,s={}){super(t,xe(i,s));}static defaults(t){return e.defaults(xe(i,t)).Minimatch}},AST:class extends e.AST{constructor(t,s,r={}){super(t,s,xe(i,r));}static fromGlob(t,s={}){return e.AST.fromGlob(t,xe(i,s))}},unescape:(t,s={})=>e.unescape(t,xe(i,s)),escape:(t,s={})=>e.escape(t,xe(i,s)),filter:(t,s={})=>e.filter(t,xe(i,s)),defaults:t=>e.defaults(xe(i,t)),makeRe:(t,s={})=>e.makeRe(t,xe(i,s)),braceExpand:(t,s={})=>e.braceExpand(t,xe(i,s)),match:(t,s,r={})=>e.match(t,s,xe(i,r)),sep:e.sep,GLOBSTAR:ce})};de.defaults=Ko;var an=(i,e={})=>(ls(i),e.nobrace||!/\{(?:(?!\{).)*\}/.test(i)?[i]:ho(i,{max:e.braceExpandMax}));de.braceExpand=an;var Jo=(i,e={})=>new wt(i,e).makeRe();de.makeRe=Jo;var Yo=(i,e,t={})=>{let s=new wt(e,t);return i=i.filter(r=>s.match(r)),s.options.nonull&&!i.length&&i.push(e),i};de.match=Yo;var ar=/[?*]|[+@!]\(.*?\)|\[|\]/,Zo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),wt=class{constructor(i,e={}){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");ls(i),e=e||{},this.options=e,this.pattern=i,this.platform=e.platform||on,this.isWindows=this.platform==="win32";let t="allowWindowsEscape";this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e[t]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!e.nonegate,this.comment=false,this.empty=false,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.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 i of this.set)for(let e of i)if(typeof e!="string")return true;return false}debug(...i){}make(){let i=this.pattern,e=this.options;if(!e.nocomment&&i.charAt(0)==="#"){this.comment=true;return}if(!i){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let t=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(t),this.debug(this.pattern,this.globParts);let s=this.globParts.map((r,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=r[0]===""&&r[1]===""&&(r[2]==="?"||!ar.test(r[2]))&&!ar.test(r[3]),l=/^[a-z]:/i.test(r[0]);if(h)return [...r.slice(0,4),...r.slice(4).map(d=>this.parse(d))];if(l)return [r[0],...r.slice(1).map(d=>this.parse(d))]}return r.map(h=>this.parse(h))});if(this.debug(this.pattern,s),this.set=s.filter(r=>r.indexOf(false)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(i){if(this.options.noglobstar)for(let t=0;t<i.length;t++)for(let s=0;s<i[t].length;s++)i[t][s]==="**"&&(i[t][s]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(i=this.firstPhasePreProcess(i),i=this.secondPhasePreProcess(i)):e>=1?i=this.levelOneOptimize(i):i=this.adjascentGlobstarOptimize(i),i}adjascentGlobstarOptimize(i){return i.map(e=>{let t=-1;for(;(t=e.indexOf("**",t+1))!==-1;){let s=t;for(;e[s+1]==="**";)s++;s!==t&&e.splice(t,s-t);}return e})}levelOneOptimize(i){return i.map(e=>(e=e.reduce((t,s)=>{let r=t[t.length-1];return s==="**"&&r==="**"?t:s===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(t.pop(),t):(t.push(s),t)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(i){Array.isArray(i)||(i=this.slashSplit(i));let e=false;do{if(e=false,!this.preserveMultipleSlashes){for(let s=1;s<i.length-1;s++){let r=i[s];s===1&&r===""&&i[0]===""||(r==="."||r==="")&&(e=true,i.splice(s,1),s--);}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(e=true,i.pop());}let t=0;for(;(t=i.indexOf("..",t+1))!==-1;){let s=i[t-1];s&&s!=="."&&s!==".."&&s!=="**"&&(e=true,i.splice(t-1,2),t-=2);}}while(e);return i.length===0?[""]:i}firstPhasePreProcess(i){let e=false;do{e=false;for(let t of i){let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let o=s;for(;t[o+1]==="**";)o++;o>s&&t.splice(s+1,o-s);let a=t[s+1],h=t[s+2],l=t[s+3];if(a!==".."||!h||h==="."||h===".."||!l||l==="."||l==="..")continue;e=true,t.splice(s,1);let d=t.slice(0);d[s]="**",i.push(d),s--;}if(!this.preserveMultipleSlashes){for(let o=1;o<t.length-1;o++){let a=t[o];o===1&&a===""&&t[0]===""||(a==="."||a==="")&&(e=true,t.splice(o,1),o--);}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=true,t.pop());}let r=0;for(;(r=t.indexOf("..",r+1))!==-1;){let o=t[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=true;let a=r===1&&t[r+1]==="**"?["."]:[];t.splice(r-1,2,...a),t.length===0&&t.push(""),r-=2;}}}}while(e);return i}secondPhasePreProcess(i){for(let e=0;e<i.length-1;e++)for(let t=e+1;t<i.length;t++){let s=this.partsMatch(i[e],i[t],!this.preserveMultipleSlashes);if(s){i[e]=[],i[t]=s;break}}return i.filter(e=>e.length)}partsMatch(i,e,t=false){let s=0,r=0,o=[],a="";for(;s<i.length&&r<e.length;)if(i[s]===e[r])o.push(a==="b"?e[r]:i[s]),s++,r++;else if(t&&i[s]==="**"&&e[r]===i[s+1])o.push(i[s]),s++;else if(t&&e[r]==="**"&&i[s]===e[r+1])o.push(e[r]),r++;else if(i[s]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(a==="b")return false;a="a",o.push(i[s]),s++,r++;}else if(e[r]==="*"&&i[s]&&(this.options.dot||!i[s].startsWith("."))&&i[s]!=="**"){if(a==="a")return false;a="b",o.push(e[r]),s++,r++;}else return false;return i.length===e.length&&o}parseNegate(){if(this.nonegate)return;let i=this.pattern,e=false,t=0;for(let s=0;s<i.length&&i.charAt(s)==="!";s++)e=!e,t++;t&&(this.pattern=i.slice(t)),this.negate=e;}matchOne(i,e,t=false){let s=this.options;if(this.isWindows){let b=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),S=!b&&i[0]===""&&i[1]===""&&i[2]==="?"&&/^[a-z]:$/i.test(i[3]),T=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!T&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),M=S?3:b?0:void 0,O=v?3:T?0:void 0;if(typeof M=="number"&&typeof O=="number"){let[P,k]=[i[M],e[O]];P.toLowerCase()===k.toLowerCase()&&(e[O]=P,O>M?e=e.slice(O):M>O&&(i=i.slice(M)));}}let{optimizationLevel:r=1}=this.options;r>=2&&(i=this.levelTwoFileOptimize(i)),this.debug("matchOne",this,{file:i,pattern:e}),this.debug("matchOne",i.length,e.length);for(var o=0,a=0,h=i.length,l=e.length;o<h&&a<l;o++,a++){this.debug("matchOne loop");var d=e[a],g=i[o];if(this.debug(e,d,g),d===false)return false;if(d===ce){this.debug("GLOBSTAR",[e,d,g]);var p=o,u=a+1;if(u===l){for(this.debug("** at the end");o<h;o++)if(i[o]==="."||i[o]===".."||!s.dot&&i[o].charAt(0)===".")return false;return true}for(;p<h;){var m=i[p];if(this.debug(`
2
+ globstar while`,i,p,e,u,m),this.matchOne(i.slice(p),e.slice(u),t))return this.debug("globstar found match!",p,h,m),true;if(m==="."||m===".."||!s.dot&&m.charAt(0)==="."){this.debug("dot detected!",i,p,e,u);break}this.debug("globstar swallow a segment, and continue"),p++;}return !!(t&&(this.debug(`
3
+ >>> no match, partial?`,i,p,e,u),p===h))}let b;if(typeof d=="string"?(b=g===d,this.debug("string match",d,g,b)):(b=d.test(g),this.debug("pattern match",d,g,b)),!b)return false}if(o===h&&a===l)return true;if(o===h)return t;if(a===l)return o===h-1&&i[o]==="";throw new Error("wtf?")}braceExpand(){return an(this.pattern,this.options)}parse(i){ls(i);let e=this.options;if(i==="**")return ce;if(i==="")return "";let t,s=null;(t=i.match(Io))?s=e.dot?_o:No:(t=i.match(To))?s=(e.nocase?e.dot?Lo:Ro:e.dot?Mo:ko)(t[1]):(t=i.match(Fo))?s=(e.nocase?e.dot?$o:Uo:e.dot?Bo:zo)(t):(t=i.match(Co))?s=e.dot?Po:Oo:(t=i.match(Do))&&(s=Ao);let r=Qr.fromGlob(i,this.options).toMMPattern();return s&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:s}),r}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let i=this.set;if(!i.length)return this.regexp=false,this.regexp;let e=this.options,t=e.noglobstar?Go:e.dot?qo:Vo,s=new Set(e.nocase?["i"]:[]),r=i.map(h=>{let l=h.map(g=>{if(g instanceof RegExp)for(let p of g.flags.split(""))s.add(p);return typeof g=="string"?Zo(g):g===ce?ce:g._src});l.forEach((g,p)=>{let u=l[p+1],m=l[p-1];g!==ce||m===ce||(m===void 0?u!==void 0&&u!==ce?l[p+1]="(?:\\/|"+t+"\\/)?"+u:l[p]=t:u===void 0?l[p-1]=m+"(?:\\/|\\/"+t+")?":u!==ce&&(l[p-1]=m+"(?:\\/|\\/"+t+"\\/)"+u,l[p+1]=ce));});let d=l.filter(g=>g!==ce);if(this.partial&&d.length>=1){let g=[];for(let p=1;p<=d.length;p++)g.push(d.slice(0,p).join("/"));return "(?:"+g.join("|")+")"}return d.join("/")}).join("|"),[o,a]=i.length>1?["(?:",")"]:["",""];r="^"+o+r+a+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+a+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...s].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(i){return this.preserveMultipleSlashes?i.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(i)?["",...i.split(/\/+/)]:i.split(/\/+/)}match(i,e=this.partial){if(this.debug("match",i,this.pattern),this.comment)return false;if(this.empty)return i==="";if(i==="/"&&e)return true;let t=this.options;this.isWindows&&(i=i.split("\\").join("/"));let s=this.slashSplit(i);this.debug(this.pattern,"split",s);let r=this.set;this.debug(this.pattern,"set",r);let o=s[s.length-1];if(!o)for(let a=s.length-2;!o&&a>=0;a--)o=s[a];for(let a=0;a<r.length;a++){let h=r[a],l=s;if(t.matchBase&&h.length===1&&(l=[o]),this.matchOne(l,h,e))return t.flipNegate?true:!this.negate}return t.flipNegate?false:this.negate}static defaults(i){return de.defaults(i).Minimatch}};de.AST=Qr;de.Minimatch=wt;de.escape=sn;de.unescape=zt;var Qo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ln=new Set,Ps=typeof process=="object"&&process?process:{},hn=(i,e,t,s)=>{typeof Ps.emitWarning=="function"?Ps.emitWarning(i,e,t,s):console.error(`[${t}] ${e}: ${i}`);},hs=globalThis.AbortController,lr=globalThis.AbortSignal;if(typeof hs>"u"){lr=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(t,s){this._onabort.push(s);}},hs=class{constructor(){c(this,"signal",new lr);e();}abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let s of this.signal._onabort)s(t);this.signal.onabort?.(t);}}};let i=Ps.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{i&&(i=false,hn("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",e));};}var ea=i=>!ln.has(i),ot=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),cn=i=>ot(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?ts:null:null,ts=class extends Array{constructor(i){super(i),this.fill(0);}},He,jt,ta=(He=class{constructor(e,t){c(this,"heap");c(this,"length");if(!n(He,jt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=cn(e);if(!t)return [];f(He,jt,true);let s=new He(e,t);return f(He,jt,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},jt=new WeakMap,w(He,jt,false),He),xr,Tr,ke,ye,De,kt,Ae,Wt,Gt,Ie,q,Ne,j,N,C,ae,we,re,Q,_e,ee,Fe,Ue,be,Se,$e,ut,le,qt,E,Ds,Mt,Ze,mi,ve,dn,Rt,Vt,yi,at,lt,As,is,ss,A,Is,hi,ht,Ns,Ht,us=(Ht=class{constructor(e){w(this,E);w(this,ke);w(this,ye);w(this,De);w(this,kt);w(this,Ae);w(this,Wt);w(this,Gt);w(this,Ie);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");w(this,q);w(this,Ne);w(this,j);w(this,N);w(this,C);w(this,ae);w(this,we);w(this,re);w(this,Q);w(this,_e);w(this,ee);w(this,Fe);w(this,Ue);w(this,be);w(this,Se);w(this,$e);w(this,ut);w(this,le);w(this,qt);w(this,Mt,()=>{});w(this,Ze,()=>{});w(this,mi,()=>{});w(this,ve,()=>false);w(this,Rt,e=>{});w(this,Vt,(e,t,s)=>{});w(this,yi,(e,t,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,xr,"LRUCache");let{max:t=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:l,dispose:d,onInsert:g,disposeAfter:p,noDisposeOnSet:u,noUpdateTTL:m,maxSize:b=0,maxEntrySize:S=0,sizeCalculation:T,fetchMethod:v,memoMethod:M,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:P,allowStaleOnFetchRejection:k,allowStaleOnFetchAbort:D,ignoreFetchAbort:F,perf:ie}=e;if(ie!==void 0&&typeof ie?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,Ie,ie??Qo),t!==0&&!ot(t))throw new TypeError("max option must be a nonnegative integer");let _=t?cn(t):Array;if(!_)throw new Error("invalid max value: "+t);if(f(this,ke,t),f(this,ye,b),this.maxEntrySize=S||n(this,ye),this.sizeCalculation=T,this.sizeCalculation){if(!n(this,ye)&&!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(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,Gt,M),v!==void 0&&typeof v!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Wt,v),f(this,ut,!!v),f(this,j,new Map),f(this,N,new Array(t).fill(void 0)),f(this,C,new Array(t).fill(void 0)),f(this,ae,new _(t)),f(this,we,new _(t)),f(this,re,0),f(this,Q,0),f(this,_e,ta.create(t)),f(this,q,0),f(this,Ne,0),typeof d=="function"&&f(this,De,d),typeof g=="function"&&f(this,kt,g),typeof p=="function"?(f(this,Ae,p),f(this,ee,[])):(f(this,Ae,void 0),f(this,ee,void 0)),f(this,$e,!!n(this,De)),f(this,qt,!!n(this,kt)),f(this,le,!!n(this,Ae)),this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!k,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(n(this,ye)!==0&&!ot(n(this,ye)))throw new TypeError("maxSize must be a positive integer if specified");if(!ot(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");y(this,E,dn).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!P,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=ot(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ot(this.ttl))throw new TypeError("ttl must be a positive integer if specified");y(this,E,Ds).call(this);}if(n(this,ke)===0&&this.ttl===0&&n(this,ye)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!n(this,ke)&&!n(this,ye)){let K="LRU_CACHE_UNBOUNDED";ea(K)&&(ln.add(K),hn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",K,Ht));}}get perf(){return n(this,Ie)}static unsafeExposeInternals(e){return {starts:n(e,Ue),ttls:n(e,be),autopurgeTimers:n(e,Se),sizes:n(e,Fe),keyMap:n(e,j),keyList:n(e,N),valList:n(e,C),next:n(e,ae),prev:n(e,we),get head(){return n(e,re)},get tail(){return n(e,Q)},free:n(e,_e),isBackgroundFetch:t=>{var s;return y(s=e,E,A).call(s,t)},backgroundFetch:(t,s,r,o)=>{var a;return y(a=e,E,ss).call(a,t,s,r,o)},moveToTail:t=>{var s;return y(s=e,E,hi).call(s,t)},indexes:t=>{var s;return y(s=e,E,at).call(s,t)},rindexes:t=>{var s;return y(s=e,E,lt).call(s,t)},isStale:t=>{var s;return n(s=e,ve).call(s,t)}}}get max(){return n(this,ke)}get maxSize(){return n(this,ye)}get calculatedSize(){return n(this,Ne)}get size(){return n(this,q)}get fetchMethod(){return n(this,Wt)}get memoMethod(){return n(this,Gt)}get dispose(){return n(this,De)}get onInsert(){return n(this,kt)}get disposeAfter(){return n(this,Ae)}getRemainingTTL(e){return n(this,j).has(e)?1/0:0}*entries(){for(let e of y(this,E,at).call(this))n(this,C)[e]!==void 0&&n(this,N)[e]!==void 0&&!y(this,E,A).call(this,n(this,C)[e])&&(yield [n(this,N)[e],n(this,C)[e]]);}*rentries(){for(let e of y(this,E,lt).call(this))n(this,C)[e]!==void 0&&n(this,N)[e]!==void 0&&!y(this,E,A).call(this,n(this,C)[e])&&(yield [n(this,N)[e],n(this,C)[e]]);}*keys(){for(let e of y(this,E,at).call(this)){let t=n(this,N)[e];t!==void 0&&!y(this,E,A).call(this,n(this,C)[e])&&(yield t);}}*rkeys(){for(let e of y(this,E,lt).call(this)){let t=n(this,N)[e];t!==void 0&&!y(this,E,A).call(this,n(this,C)[e])&&(yield t);}}*values(){for(let e of y(this,E,at).call(this))n(this,C)[e]!==void 0&&!y(this,E,A).call(this,n(this,C)[e])&&(yield n(this,C)[e]);}*rvalues(){for(let e of y(this,E,lt).call(this))n(this,C)[e]!==void 0&&!y(this,E,A).call(this,n(this,C)[e])&&(yield n(this,C)[e]);}[(Tr=Symbol.iterator,xr=Symbol.toStringTag,Tr)](){return this.entries()}find(e,t={}){for(let s of y(this,E,at).call(this)){let r=n(this,C)[s],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,n(this,N)[s],this))return this.get(n(this,N)[s],t)}}forEach(e,t=this){for(let s of y(this,E,at).call(this)){let r=n(this,C)[s],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,n(this,N)[s],this);}}rforEach(e,t=this){for(let s of y(this,E,lt).call(this)){let r=n(this,C)[s],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,n(this,N)[s],this);}}purgeStale(){let e=false;for(let t of y(this,E,lt).call(this,{allowStale:true}))n(this,ve).call(this,t)&&(y(this,E,ht).call(this,n(this,N)[t],"expire"),e=true);return e}info(e){let t=n(this,j).get(e);if(t===void 0)return;let s=n(this,C)[t],r=y(this,E,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(n(this,be)&&n(this,Ue)){let a=n(this,be)[t],h=n(this,Ue)[t];if(a&&h){let l=a-(n(this,Ie).now()-h);o.ttl=l,o.start=Date.now();}}return n(this,Fe)&&(o.size=n(this,Fe)[t]),o}dump(){let e=[];for(let t of y(this,E,at).call(this,{allowStale:true})){let s=n(this,N)[t],r=n(this,C)[t],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(n(this,be)&&n(this,Ue)){a.ttl=n(this,be)[t];let h=n(this,Ie).now()-n(this,Ue)[t];a.start=Math.floor(Date.now()-h);}n(this,Fe)&&(a.size=n(this,Fe)[t]),e.unshift([s,a]);}return e}load(e){this.clear();for(let[t,s]of e){if(s.start){let r=Date.now()-s.start;s.start=n(this,Ie).now()-r;}this.set(t,s.value,s);}}set(e,t,s={}){var u,m,b,S;if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:l}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,g=n(this,yi).call(this,e,t,s.size||0,h);if(this.maxEntrySize&&g>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=true),y(this,E,ht).call(this,e,"set"),this;let p=n(this,q)===0?void 0:n(this,j).get(e);if(p===void 0)p=n(this,q)===0?n(this,Q):n(this,_e).length!==0?n(this,_e).pop():n(this,q)===n(this,ke)?y(this,E,is).call(this,false):n(this,q),n(this,N)[p]=e,n(this,C)[p]=t,n(this,j).set(e,p),n(this,ae)[n(this,Q)]=p,n(this,we)[p]=n(this,Q),f(this,Q,p),Gi(this,q)._++,n(this,Vt).call(this,p,g,l),l&&(l.set="add"),d=false,n(this,qt)&&((u=n(this,kt))==null||u.call(this,t,e,"add"));else {y(this,E,hi).call(this,p);let T=n(this,C)[p];if(t!==T){if(n(this,ut)&&y(this,E,A).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:v}=T;v!==void 0&&!a&&(n(this,$e)&&((m=n(this,De))==null||m.call(this,v,e,"set")),n(this,le)&&n(this,ee)?.push([v,e,"set"]));}else a||(n(this,$e)&&((b=n(this,De))==null||b.call(this,T,e,"set")),n(this,le)&&n(this,ee)?.push([T,e,"set"]));if(n(this,Rt).call(this,p),n(this,Vt).call(this,p,g,l),n(this,C)[p]=t,l){l.set="replace";let v=T&&y(this,E,A).call(this,T)?T.__staleWhileFetching:T;v!==void 0&&(l.oldValue=v);}}else l&&(l.set="update");n(this,qt)&&this.onInsert?.(t,e,t===T?"update":"replace");}if(r!==0&&!n(this,be)&&y(this,E,Ds).call(this),n(this,be)&&(d||n(this,mi).call(this,p,r,o),l&&n(this,Ze).call(this,l,p)),!a&&n(this,le)&&n(this,ee)){let T=n(this,ee),v;for(;v=T?.shift();)(S=n(this,Ae))==null||S.call(this,...v);}return this}pop(){var e;try{for(;n(this,q);){let t=n(this,C)[n(this,re)];if(y(this,E,is).call(this,!0),y(this,E,A).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(n(this,le)&&n(this,ee)){let t=n(this,ee),s;for(;s=t?.shift();)(e=n(this,Ae))==null||e.call(this,...s);}}}has(e,t={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=t,o=n(this,j).get(e);if(o!==void 0){let a=n(this,C)[o];if(y(this,E,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(n(this,ve).call(this,o))r&&(r.has="stale",n(this,Ze).call(this,r,o));else return s&&n(this,Mt).call(this,o),r&&(r.has="hit",n(this,Ze).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,t={}){let{allowStale:s=this.allowStale}=t,r=n(this,j).get(e);if(r===void 0||!s&&n(this,ve).call(this,r))return;let o=n(this,C)[r];return y(this,E,A).call(this,o)?o.__staleWhileFetching:o}async fetch(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:l=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:g=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:b=this.allowStaleOnFetchAbort,context:S,forceRefresh:T=false,status:v,signal:M}=t;if(!n(this,ut))return v&&(v.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:v});let O={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:l,sizeCalculation:d,noUpdateTTL:g,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:b,ignoreFetchAbort:m,status:v,signal:M},P=n(this,j).get(e);if(P===void 0){v&&(v.fetch="miss");let k=y(this,E,ss).call(this,e,P,O,S);return k.__returned=k}else {let k=n(this,C)[P];if(y(this,E,A).call(this,k)){let _=s&&k.__staleWhileFetching!==void 0;return v&&(v.fetch="inflight",_&&(v.returnedStale=true)),_?k.__staleWhileFetching:k.__returned=k}let D=n(this,ve).call(this,P);if(!T&&!D)return v&&(v.fetch="hit"),y(this,E,hi).call(this,P),r&&n(this,Mt).call(this,P),v&&n(this,Ze).call(this,v,P),k;let F=y(this,E,ss).call(this,e,P,O,S),ie=F.__staleWhileFetching!==void 0&&s;return v&&(v.fetch=D?"stale":"refresh",ie&&D&&(v.returnedStale=true)),ie?F.__staleWhileFetching:F.__returned=F}}async forceFetch(e,t={}){let s=await this.fetch(e,t);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,t={}){let s=n(this,Gt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=t,h=this.get(e,a);if(!o&&h!==void 0)return h;let l=s(e,h,{options:a,context:r});return this.set(e,l,a),l}get(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=t,h=n(this,j).get(e);if(h!==void 0){let l=n(this,C)[h],d=y(this,E,A).call(this,l);return a&&n(this,Ze).call(this,a,h),n(this,ve).call(this,h)?(a&&(a.get="stale"),d?(a&&s&&l.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?l.__staleWhileFetching:void 0):(o||y(this,E,ht).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?l:void 0)):(a&&(a.get="hit"),d?l.__staleWhileFetching:(y(this,E,hi).call(this,h),r&&n(this,Mt).call(this,h),l))}else a&&(a.get="miss");}delete(e){return y(this,E,ht).call(this,e,"delete")}clear(){return y(this,E,Ns).call(this,"delete")}},ke=new WeakMap,ye=new WeakMap,De=new WeakMap,kt=new WeakMap,Ae=new WeakMap,Wt=new WeakMap,Gt=new WeakMap,Ie=new WeakMap,q=new WeakMap,Ne=new WeakMap,j=new WeakMap,N=new WeakMap,C=new WeakMap,ae=new WeakMap,we=new WeakMap,re=new WeakMap,Q=new WeakMap,_e=new WeakMap,ee=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,be=new WeakMap,Se=new WeakMap,$e=new WeakMap,ut=new WeakMap,le=new WeakMap,qt=new WeakMap,E=new WeakSet,Ds=function(){let e=new ts(n(this,ke)),t=new ts(n(this,ke));f(this,be,e),f(this,Ue,t);let s=this.ttlAutopurge?new Array(n(this,ke)):void 0;f(this,Se,s),f(this,mi,(a,h,l=n(this,Ie).now())=>{if(t[a]=h!==0?l:0,e[a]=h,s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h!==0&&s){let d=setTimeout(()=>{n(this,ve).call(this,a)&&y(this,E,ht).call(this,n(this,N)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}),f(this,Mt,a=>{t[a]=e[a]!==0?n(this,Ie).now():0;}),f(this,Ze,(a,h)=>{if(e[h]){let l=e[h],d=t[h];if(!l||!d)return;a.ttl=l,a.start=d,a.now=r||o();let g=a.now-d;a.remainingTTL=l-g;}});let r=0,o=()=>{let a=n(this,Ie).now();if(this.ttlResolution>0){r=a;let h=setTimeout(()=>r=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=n(this,j).get(a);if(h===void 0)return 0;let l=e[h],d=t[h];if(!l||!d)return 1/0;let g=(r||o())-d;return l-g},f(this,ve,a=>{let h=t[a],l=e[a];return !!l&&!!h&&(r||o())-h>l});},Mt=new WeakMap,Ze=new WeakMap,mi=new WeakMap,ve=new WeakMap,dn=function(){let e=new ts(n(this,ke));f(this,Ne,0),f(this,Fe,e),f(this,Rt,t=>{f(this,Ne,n(this,Ne)-e[t]),e[t]=0;}),f(this,yi,(t,s,r,o)=>{if(y(this,E,A).call(this,s))return 0;if(!ot(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,t),!ot(r))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 r}),f(this,Vt,(t,s,r)=>{if(e[t]=s,n(this,ye)){let o=n(this,ye)-e[t];for(;n(this,Ne)>o;)y(this,E,is).call(this,true);}f(this,Ne,n(this,Ne)+e[t]),r&&(r.entrySize=s,r.totalCalculatedSize=n(this,Ne));});},Rt=new WeakMap,Vt=new WeakMap,yi=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(n(this,q))for(let t=n(this,Q);!(!y(this,E,As).call(this,t)||((e||!n(this,ve).call(this,t))&&(yield t),t===n(this,re)));)t=n(this,we)[t];},lt=function*({allowStale:e=this.allowStale}={}){if(n(this,q))for(let t=n(this,re);!(!y(this,E,As).call(this,t)||((e||!n(this,ve).call(this,t))&&(yield t),t===n(this,Q)));)t=n(this,ae)[t];},As=function(e){return e!==void 0&&n(this,j).get(n(this,N)[e])===e},is=function(e){var o;let t=n(this,re),s=n(this,N)[t],r=n(this,C)[t];return n(this,ut)&&y(this,E,A).call(this,r)?r.__abortController.abort(new Error("evicted")):(n(this,$e)||n(this,le))&&(n(this,$e)&&((o=n(this,De))==null||o.call(this,r,s,"evict")),n(this,le)&&n(this,ee)?.push([r,s,"evict"])),n(this,Rt).call(this,t),n(this,Se)?.[t]&&(clearTimeout(n(this,Se)[t]),n(this,Se)[t]=void 0),e&&(n(this,N)[t]=void 0,n(this,C)[t]=void 0,n(this,_e).push(t)),n(this,q)===1?(f(this,re,f(this,Q,0)),n(this,_e).length=0):f(this,re,n(this,ae)[t]),n(this,j).delete(s),Gi(this,q)._--,t},ss=function(e,t,s,r){let o=t===void 0?void 0:n(this,C)[t];if(y(this,E,A).call(this,o))return o;let a=new hs,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let l={signal:a.signal,options:s,context:r},d=(S,T=false)=>{let{aborted:v}=a.signal,M=s.ignoreFetchAbort&&S!==void 0,O=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&S!==void 0);if(s.status&&(v&&!T?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),v&&!M&&!T)return p(a.signal.reason,O);let P=m,k=n(this,C)[t];return (k===m||M&&T&&k===void 0)&&(S===void 0?P.__staleWhileFetching!==void 0?n(this,C)[t]=P.__staleWhileFetching:y(this,E,ht).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,S,l.options))),S},g=S=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=S),p(S,false)),p=(S,T)=>{let{aborted:v}=a.signal,M=v&&s.allowStaleOnFetchAbort,O=M||s.allowStaleOnFetchRejection,P=O||s.noDeleteOnFetchRejection,k=m;if(n(this,C)[t]===m&&(!P||!T&&k.__staleWhileFetching===void 0?y(this,E,ht).call(this,e,"fetch"):M||(n(this,C)[t]=k.__staleWhileFetching)),O)return s.status&&k.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),k.__staleWhileFetching;if(k.__returned===k)throw S},u=(S,T)=>{var M;let v=(M=n(this,Wt))==null?void 0:M.call(this,e,o,l);v&&v instanceof Promise&&v.then(O=>S(O===void 0?void 0:O),T),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(S(void 0),s.allowStaleOnFetchAbort&&(S=O=>d(O,true)));});};s.status&&(s.status.fetchDispatched=true);let m=new Promise(u).then(d,g),b=Object.assign(m,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,b,{...l.options,status:void 0}),t=n(this,j).get(e)):n(this,C)[t]=b,b},A=function(e){if(!n(this,ut))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof hs},Is=function(e,t){n(this,we)[t]=e,n(this,ae)[e]=t;},hi=function(e){e!==n(this,Q)&&(e===n(this,re)?f(this,re,n(this,ae)[e]):y(this,E,Is).call(this,n(this,we)[e],n(this,ae)[e]),y(this,E,Is).call(this,n(this,Q),e),f(this,Q,e));},ht=function(e,t){var r,o;let s=false;if(n(this,q)!==0){let a=n(this,j).get(e);if(a!==void 0)if(n(this,Se)?.[a]&&(clearTimeout(n(this,Se)?.[a]),n(this,Se)[a]=void 0),s=true,n(this,q)===1)y(this,E,Ns).call(this,t);else {n(this,Rt).call(this,a);let h=n(this,C)[a];if(y(this,E,A).call(this,h)?h.__abortController.abort(new Error("deleted")):(n(this,$e)||n(this,le))&&(n(this,$e)&&((r=n(this,De))==null||r.call(this,h,e,t)),n(this,le)&&n(this,ee)?.push([h,e,t])),n(this,j).delete(e),n(this,N)[a]=void 0,n(this,C)[a]=void 0,a===n(this,Q))f(this,Q,n(this,we)[a]);else if(a===n(this,re))f(this,re,n(this,ae)[a]);else {let l=n(this,we)[a];n(this,ae)[l]=n(this,ae)[a];let d=n(this,ae)[a];n(this,we)[d]=n(this,we)[a];}Gi(this,q)._--,n(this,_e).push(a);}}if(n(this,le)&&n(this,ee)?.length){let a=n(this,ee),h;for(;h=a?.shift();)(o=n(this,Ae))==null||o.call(this,...h);}return s},Ns=function(e){var t,s;for(let r of y(this,E,lt).call(this,{allowStale:true})){let o=n(this,C)[r];if(y(this,E,A).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=n(this,N)[r];n(this,$e)&&((t=n(this,De))==null||t.call(this,o,a,e)),n(this,le)&&n(this,ee)?.push([o,a,e]);}}if(n(this,j).clear(),n(this,C).fill(void 0),n(this,N).fill(void 0),n(this,be)&&n(this,Ue)){n(this,be).fill(0),n(this,Ue).fill(0);for(let r of n(this,Se)??[])r!==void 0&&clearTimeout(r);n(this,Se)?.fill(void 0);}if(n(this,Fe)&&n(this,Fe).fill(0),f(this,re,0),f(this,Q,0),n(this,_e).length=0,f(this,Ne,0),f(this,q,0),n(this,le)&&n(this,ee)){let r=n(this,ee),o;for(;o=r?.shift();)(s=n(this,Ae))==null||s.call(this,...o);}},Ht),hr=typeof process=="object"&&process?process:{stdout:null,stderr:null},ga=i=>!!i&&typeof i=="object"&&(i instanceof cs||i instanceof un__default.default||ma(i)||ya(i)),ma=i=>!!i&&typeof i=="object"&&i instanceof events.EventEmitter&&typeof i.pipe=="function"&&i.pipe!==un__default.default.Writable.prototype.pipe,ya=i=>!!i&&typeof i=="object"&&i instanceof events.EventEmitter&&typeof i.write=="function"&&typeof i.end=="function",Ke=Symbol("EOF"),Je=Symbol("maybeEmitEnd"),nt=Symbol("emittedEnd"),Hi=Symbol("emittingEnd"),si=Symbol("emittedError"),Ki=Symbol("closed"),cr=Symbol("read"),Ji=Symbol("flush"),dr=Symbol("flushChunk"),Oe=Symbol("encoding"),$t=Symbol("decoder"),J=Symbol("flowing"),ri=Symbol("paused"),Bt=Symbol("resume"),Y=Symbol("buffer"),oe=Symbol("pipes"),Z=Symbol("bufferLength"),xs=Symbol("bufferPush"),Yi=Symbol("bufferShift"),se=Symbol("objectMode"),$=Symbol("destroyed"),Ts=Symbol("error"),ks=Symbol("emitData"),ur=Symbol("emitEnd"),Ms=Symbol("emitEnd2"),je=Symbol("async"),Rs=Symbol("abort"),Zi=Symbol("aborted"),ni=Symbol("signal"),St=Symbol("dataListeners"),me=Symbol("discarded"),oi=i=>Promise.resolve().then(i),wa=i=>i(),ba=i=>i==="end"||i==="finish"||i==="prefinish",Sa=i=>i instanceof ArrayBuffer||!!i&&typeof i=="object"&&i.constructor&&i.constructor.name==="ArrayBuffer"&&i.byteLength>=0,va=i=>!Buffer.isBuffer(i)&&ArrayBuffer.isView(i),pn=class{constructor(i,e,t){c(this,"src");c(this,"dest");c(this,"opts");c(this,"ondrain");this.src=i,this.dest=e,this.opts=t,this.ondrain=()=>i[Bt](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(i){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},Ea=class extends pn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(i,e,t){super(i,e,t),this.proxyErrors=s=>this.dest.emit("error",s),i.on("error",this.proxyErrors);}},xa=i=>!!i.objectMode,Ta=i=>!i.objectMode&&!!i.encoding&&i.encoding!=="buffer",kr,Mr,Rr,Lr,Cr,Or,Pr,Dr,Ar,Ir,Nr,_r,Fr,Ur,$r,Br,zr,jr,Wr,cs=class extends events.EventEmitter{constructor(...e){let t=e[0]||{};super();c(this,Wr,false);c(this,jr,false);c(this,zr,[]);c(this,Br,[]);c(this,$r);c(this,Ur);c(this,Fr);c(this,_r);c(this,Nr,false);c(this,Ir,false);c(this,Ar,false);c(this,Dr,false);c(this,Pr,null);c(this,Or,0);c(this,Cr,false);c(this,Lr);c(this,Rr,false);c(this,Mr,0);c(this,kr,false);c(this,"writable",true);c(this,"readable",true);if(t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");xa(t)?(this[se]=true,this[Oe]=null):Ta(t)?(this[Oe]=t.encoding,this[se]=false):(this[se]=false,this[Oe]=null),this[je]=!!t.async,this[$t]=this[Oe]?new string_decoder.StringDecoder(this[Oe]):null,t&&t.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[Y]}),t&&t.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[oe]});let{signal:s}=t;s&&(this[ni]=s,s.aborted?this[Rs]():s.addEventListener("abort",()=>this[Rs]()));}get bufferLength(){return this[Z]}get encoding(){return this[Oe]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[se]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[je]}set async(e){this[je]=this[je]||!!e;}[(Wr=J,jr=ri,zr=oe,Br=Y,$r=se,Ur=Oe,Fr=je,_r=$t,Nr=Ke,Ir=nt,Ar=Hi,Dr=Ki,Pr=si,Or=Z,Cr=$,Lr=ni,Rr=Zi,Mr=St,kr=me,Rs)](){this[Zi]=true,this.emit("abort",this[ni]?.reason),this.destroy(this[ni]?.reason);}get aborted(){return this[Zi]}set aborted(e){}write(e,t,s){if(this[Zi])return false;if(this[Ke])throw new Error("write after end");if(this[$])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let r=this[je]?oi:wa;if(!this[se]&&!Buffer.isBuffer(e)){if(va(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Sa(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[se]?(this[J]&&this[Z]!==0&&this[Ji](true),this[J]?this.emit("data",e):this[xs](e),this[Z]!==0&&this.emit("readable"),s&&r(s),this[J]):e.length?(typeof e=="string"&&!(t===this[Oe]&&!this[$t]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Oe]&&(e=this[$t].write(e)),this[J]&&this[Z]!==0&&this[Ji](true),this[J]?this.emit("data",e):this[xs](e),this[Z]!==0&&this.emit("readable"),s&&r(s),this[J]):(this[Z]!==0&&this.emit("readable"),s&&r(s),this[J])}read(e){if(this[$])return null;if(this[me]=false,this[Z]===0||e===0||e&&e>this[Z])return this[Je](),null;this[se]&&(e=null),this[Y].length>1&&!this[se]&&(this[Y]=[this[Oe]?this[Y].join(""):Buffer.concat(this[Y],this[Z])]);let t=this[cr](e||null,this[Y][0]);return this[Je](),t}[cr](e,t){if(this[se])this[Yi]();else {let s=t;e===s.length||e===null?this[Yi]():typeof s=="string"?(this[Y][0]=s.slice(e),t=s.slice(0,e),this[Z]-=e):(this[Y][0]=s.subarray(e),t=s.subarray(0,e),this[Z]-=e);}return this.emit("data",t),!this[Y].length&&!this[Ke]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[Ke]=true,this.writable=false,(this[J]||!this[ri])&&this[Je](),this}[Bt](){this[$]||(!this[St]&&!this[oe].length&&(this[me]=true),this[ri]=false,this[J]=true,this.emit("resume"),this[Y].length?this[Ji]():this[Ke]?this[Je]():this.emit("drain"));}resume(){return this[Bt]()}pause(){this[J]=false,this[ri]=true,this[me]=false;}get destroyed(){return this[$]}get flowing(){return this[J]}get paused(){return this[ri]}[xs](e){this[se]?this[Z]+=1:this[Z]+=e.length,this[Y].push(e);}[Yi](){return this[se]?this[Z]-=1:this[Z]-=this[Y][0].length,this[Y].shift()}[Ji](e=false){do;while(this[dr](this[Yi]())&&this[Y].length);!e&&!this[Y].length&&!this[Ke]&&this.emit("drain");}[dr](e){return this.emit("data",e),this[J]}pipe(e,t){if(this[$])return e;this[me]=false;let s=this[nt];return t=t||{},e===hr.stdout||e===hr.stderr?t.end=false:t.end=t.end!==false,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[oe].push(t.proxyErrors?new Ea(this,e,t):new pn(this,e,t)),this[je]?oi(()=>this[Bt]()):this[Bt]()),e}unpipe(e){let t=this[oe].find(s=>s.dest===e);t&&(this[oe].length===1?(this[J]&&this[St]===0&&(this[J]=false),this[oe]=[]):this[oe].splice(this[oe].indexOf(t),1),t.unpipe());}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[me]=false,this[St]++,!this[oe].length&&!this[J]&&this[Bt]();else if(e==="readable"&&this[Z]!==0)super.emit("readable");else if(ba(e)&&this[nt])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[si]){let r=t;this[je]?oi(()=>r.call(this,this[si])):r.call(this,this[si]);}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[St]=this.listeners("data").length,this[St]===0&&!this[me]&&!this[oe].length&&(this[J]=false)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return (e==="data"||e===void 0)&&(this[St]=0,!this[me]&&!this[oe].length&&(this[J]=false)),t}get emittedEnd(){return this[nt]}[Je](){!this[Hi]&&!this[nt]&&!this[$]&&this[Y].length===0&&this[Ke]&&(this[Hi]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ki]&&this.emit("close"),this[Hi]=false);}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==$&&this[$])return false;if(e==="data")return !this[se]&&!s?false:this[je]?(oi(()=>this[ks](s)),true):this[ks](s);if(e==="end")return this[ur]();if(e==="close"){if(this[Ki]=true,!this[nt]&&!this[$])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(e==="error"){this[si]=s,super.emit(Ts,s);let o=!this[ni]||this.listeners("error").length?super.emit("error",s):false;return this[Je](),o}else if(e==="resume"){let o=super.emit("resume");return this[Je](),o}else if(e==="finish"||e==="prefinish"){let o=super.emit(e);return this.removeAllListeners(e),o}let r=super.emit(e,...t);return this[Je](),r}[ks](e){for(let s of this[oe])s.dest.write(e)===false&&this.pause();let t=this[me]?false:super.emit("data",e);return this[Je](),t}[ur](){return this[nt]?false:(this[nt]=true,this.readable=false,this[je]?(oi(()=>this[Ms]()),true):this[Ms]())}[Ms](){if(this[$t]){let t=this[$t].end();if(t){for(let s of this[oe])s.dest.write(t);this[me]||super.emit("data",t);}}for(let t of this[oe])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[se]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[se]||(e.dataLength+=s.length);}),await t,e}async concat(){if(this[se])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Oe]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on($,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e());})}[Symbol.asyncIterator](){this[me]=false;let e=false,t=async()=>(this.pause(),e=true,{value:void 0,done:true});return {next:()=>{if(e)return t();let s=this.read();if(s!==null)return Promise.resolve({done:false,value:s});if(this[Ke])return t();let r,o,a=g=>{this.off("data",h),this.off("end",l),this.off($,d),t(),o(g);},h=g=>{this.off("error",a),this.off("end",l),this.off($,d),this.pause(),r({value:g,done:!!this[Ke]});},l=()=>{this.off("error",a),this.off("data",h),this.off($,d),t(),r({done:true,value:void 0});},d=()=>a(new Error("stream destroyed"));return new Promise((g,p)=>{o=p,r=g,this.once($,d),this.once("error",a),this.once("end",l),this.once("data",h);})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[me]=false;let e=false,t=()=>(this.pause(),this.off(Ts,t),this.off($,t),this.off("end",t),e=true,{done:true,value:void 0}),s=()=>{if(e)return t();let r=this.read();return r===null?t():{done:false,value:r}};return this.once("end",t),this.once(Ts,t),this.once($,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[$])return e?this.emit("error",e):this.emit($),this;this[$]=true,this[me]=true,this[Y].length=0,this[Z]=0;let t=this;return typeof t.close=="function"&&!this[Ki]&&t.close(),e?this.emit("error",e):this.emit($),this}static get isStream(){return ga}},ka=B.realpathSync.native,ci={lstatSync:B.lstatSync,readdir:B.readdir,readdirSync:B.readdirSync,readlinkSync:B.readlinkSync,realpathSync:ka,promises:{lstat:Ys.lstat,readdir:Ys.readdir,readlink:Ys.readlink,realpath:Ys.realpath}},fn=i=>!i||i===ci||i===B__namespace?ci:{...ci,...i,promises:{...ci.promises,...i.promises||{}}},gn=/^\\\\\?\\([a-z]:)\\?$/i,Ma=i=>i.replace(/\//g,"\\").replace(gn,"$1\\"),Ra=/[\\\/]/,Me=0,mn=1,yn=2,We=4,wn=6,bn=8,vt=10,Sn=12,Te=15,ai=~Te,Ls=16,pr=32,di=64,Pe=128,Xi=256,rs=512,fr=di|Pe|rs,La=1023,Cs=i=>i.isFile()?bn:i.isDirectory()?We:i.isSymbolicLink()?vt:i.isCharacterDevice()?yn:i.isBlockDevice()?wn:i.isSocket()?Sn:i.isFIFO()?mn:Me,gr=new us({max:2**12}),ui=i=>{let e=gr.get(i);if(e)return e;let t=i.normalize("NFKD");return gr.set(i,t),t},mr=new us({max:2**12}),Qi=i=>{let e=mr.get(i);if(e)return e;let t=ui(i.toLowerCase());return mr.set(i,t),t},yr=class extends us{constructor(){super({max:256});}},Ca=class extends us{constructor(i=16*1024){super({maxSize:i,sizeCalculation:e=>e.length+1});}},vn=Symbol("PathScurry setAsCwd"),he,wi,bi,Si,vi,Ei,xi,Ti,ki,Mi,Ri,Li,Ci,Oi,Pi,Di,Ai,Ii,Ni,pt,Lt,qe,Xe,Qe,et,L,Ct,tt,Ve,R,Fs,ns,pi,Us,$s,fi,os,Bs,zs,as,En,xn,Tn,js,Kt,Jt,kn,Ot,Gr,ue=(Gr=class{constructor(i,e=Me,t,s,r,o,a){w(this,R);c(this,"name");c(this,"root");c(this,"roots");c(this,"parent");c(this,"nocase");c(this,"isCWD",false);w(this,he);w(this,wi);w(this,bi);w(this,Si);w(this,vi);w(this,Ei);w(this,xi);w(this,Ti);w(this,ki);w(this,Mi);w(this,Ri);w(this,Li);w(this,Ci);w(this,Oi);w(this,Pi);w(this,Di);w(this,Ai);w(this,Ii);w(this,Ni);w(this,pt);w(this,Lt);w(this,qe);w(this,Xe);w(this,Qe);w(this,et);w(this,L);w(this,Ct);w(this,tt);w(this,Ve);w(this,Kt,[]);w(this,Jt,false);w(this,Ot);this.name=i,f(this,pt,r?Qi(i):ui(i)),f(this,L,e&La),this.nocase=r,this.roots=s,this.root=t||this,f(this,Ct,o),f(this,qe,a.fullpath),f(this,Qe,a.relative),f(this,et,a.relativePosix),this.parent=a.parent,this.parent?f(this,he,n(this.parent,he)):f(this,he,fn(a.fs));}get dev(){return n(this,wi)}get mode(){return n(this,bi)}get nlink(){return n(this,Si)}get uid(){return n(this,vi)}get gid(){return n(this,Ei)}get rdev(){return n(this,xi)}get blksize(){return n(this,Ti)}get ino(){return n(this,ki)}get size(){return n(this,Mi)}get blocks(){return n(this,Ri)}get atimeMs(){return n(this,Li)}get mtimeMs(){return n(this,Ci)}get ctimeMs(){return n(this,Oi)}get birthtimeMs(){return n(this,Pi)}get atime(){return n(this,Di)}get mtime(){return n(this,Ai)}get ctime(){return n(this,Ii)}get birthtime(){return n(this,Ni)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return n(this,Lt)!==void 0?n(this,Lt):this.parent?f(this,Lt,this.parent.depth()+1):f(this,Lt,0)}childrenCache(){return n(this,Ct)}resolve(i){var s;if(!i)return this;let e=this.getRootString(i),t=i.substring(e.length).split(this.splitSep);return e?y(s=this.getRoot(e),R,Fs).call(s,t):y(this,R,Fs).call(this,t)}children(){let i=n(this,Ct).get(this);if(i)return i;let e=Object.assign([],{provisional:0});return n(this,Ct).set(this,e),f(this,L,n(this,L)&~Ls),e}child(i,e){if(i===""||i===".")return this;if(i==="..")return this.parent||this;let t=this.children(),s=this.nocase?Qi(i):ui(i);for(let h of t)if(n(h,pt)===s)return h;let r=this.parent?this.sep:"",o=n(this,qe)?n(this,qe)+r+i:void 0,a=this.newChild(i,Me,{...e,parent:this,fullpath:o});return this.canReaddir()||f(a,L,n(a,L)|Pe),t.push(a),a}relative(){if(this.isCWD)return "";if(n(this,Qe)!==void 0)return n(this,Qe);let i=this.name,e=this.parent;if(!e)return f(this,Qe,this.name);let t=e.relative();return t+(!t||!e.parent?"":this.sep)+i}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(n(this,et)!==void 0)return n(this,et);let i=this.name,e=this.parent;if(!e)return f(this,et,this.fullpathPosix());let t=e.relativePosix();return t+(!t||!e.parent?"":"/")+i}fullpath(){if(n(this,qe)!==void 0)return n(this,qe);let i=this.name,e=this.parent;if(!e)return f(this,qe,this.name);let t=e.fullpath()+(e.parent?this.sep:"")+i;return f(this,qe,t)}fullpathPosix(){if(n(this,Xe)!==void 0)return n(this,Xe);if(this.sep==="/")return f(this,Xe,this.fullpath());if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(s)?f(this,Xe,`//?/${s}`):f(this,Xe,s)}let i=this.parent,e=i.fullpathPosix(),t=e+(!e||!i.parent?"":"/")+this.name;return f(this,Xe,t)}isUnknown(){return (n(this,L)&Te)===Me}isType(i){return this[`is${i}`]()}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 (n(this,L)&Te)===bn}isDirectory(){return (n(this,L)&Te)===We}isCharacterDevice(){return (n(this,L)&Te)===yn}isBlockDevice(){return (n(this,L)&Te)===wn}isFIFO(){return (n(this,L)&Te)===mn}isSocket(){return (n(this,L)&Te)===Sn}isSymbolicLink(){return (n(this,L)&vt)===vt}lstatCached(){return n(this,L)&pr?this:void 0}readlinkCached(){return n(this,tt)}realpathCached(){return n(this,Ve)}readdirCached(){let i=this.children();return i.slice(0,i.provisional)}canReadlink(){if(n(this,tt))return true;if(!this.parent)return false;let i=n(this,L)&Te;return !(i!==Me&&i!==vt||n(this,L)&Xi||n(this,L)&Pe)}calledReaddir(){return !!(n(this,L)&Ls)}isENOENT(){return !!(n(this,L)&Pe)}isNamed(i){return this.nocase?n(this,pt)===Qi(i):n(this,pt)===ui(i)}async readlink(){let i=n(this,tt);if(i)return i;if(this.canReadlink()&&this.parent)try{let e=await n(this,he).promises.readlink(this.fullpath()),t=(await this.parent.realpath())?.resolve(e);if(t)return f(this,tt,t)}catch(e){y(this,R,zs).call(this,e.code);return}}readlinkSync(){let i=n(this,tt);if(i)return i;if(this.canReadlink()&&this.parent)try{let e=n(this,he).readlinkSync(this.fullpath()),t=this.parent.realpathSync()?.resolve(e);if(t)return f(this,tt,t)}catch(e){y(this,R,zs).call(this,e.code);return}}async lstat(){if((n(this,L)&Pe)===0)try{return y(this,R,js).call(this,await n(this,he).promises.lstat(this.fullpath())),this}catch(i){y(this,R,Bs).call(this,i.code);}}lstatSync(){if((n(this,L)&Pe)===0)try{return y(this,R,js).call(this,n(this,he).lstatSync(this.fullpath())),this}catch(i){y(this,R,Bs).call(this,i.code);}}readdirCB(i,e=false){if(!this.canReaddir()){e?i(null,[]):queueMicrotask(()=>i(null,[]));return}let t=this.children();if(this.calledReaddir()){let r=t.slice(0,t.provisional);e?i(null,r):queueMicrotask(()=>i(null,r));return}if(n(this,Kt).push(i),n(this,Jt))return;f(this,Jt,true);let s=this.fullpath();n(this,he).readdir(s,{withFileTypes:true},(r,o)=>{if(r)y(this,R,os).call(this,r.code),t.provisional=0;else {for(let a of o)y(this,R,as).call(this,a,t);y(this,R,ns).call(this,t);}y(this,R,kn).call(this,t.slice(0,t.provisional));});}async readdir(){if(!this.canReaddir())return [];let i=this.children();if(this.calledReaddir())return i.slice(0,i.provisional);let e=this.fullpath();if(n(this,Ot))await n(this,Ot);else {let t=()=>{};f(this,Ot,new Promise(s=>t=s));try{for(let s of await n(this,he).promises.readdir(e,{withFileTypes:!0}))y(this,R,as).call(this,s,i);y(this,R,ns).call(this,i);}catch(s){y(this,R,os).call(this,s.code),i.provisional=0;}f(this,Ot,void 0),t();}return i.slice(0,i.provisional)}readdirSync(){if(!this.canReaddir())return [];let i=this.children();if(this.calledReaddir())return i.slice(0,i.provisional);let e=this.fullpath();try{for(let t of n(this,he).readdirSync(e,{withFileTypes:!0}))y(this,R,as).call(this,t,i);y(this,R,ns).call(this,i);}catch(t){y(this,R,os).call(this,t.code),i.provisional=0;}return i.slice(0,i.provisional)}canReaddir(){if(n(this,L)&fr)return false;let i=Te&n(this,L);return i===Me||i===We||i===vt}shouldWalk(i,e){return (n(this,L)&We)===We&&!(n(this,L)&fr)&&!i.has(this)&&(!e||e(this))}async realpath(){if(n(this,Ve))return n(this,Ve);if(!((rs|Xi|Pe)&n(this,L)))try{let i=await n(this,he).promises.realpath(this.fullpath());return f(this,Ve,this.resolve(i))}catch{y(this,R,$s).call(this);}}realpathSync(){if(n(this,Ve))return n(this,Ve);if(!((rs|Xi|Pe)&n(this,L)))try{let i=n(this,he).realpathSync(this.fullpath());return f(this,Ve,this.resolve(i))}catch{y(this,R,$s).call(this);}}[vn](i){if(i===this)return;i.isCWD=false,this.isCWD=true;let e=new Set([]),t=[],s=this;for(;s&&s.parent;)e.add(s),f(s,Qe,t.join(this.sep)),f(s,et,t.join("/")),s=s.parent,t.push("..");for(s=i;s&&s.parent&&!e.has(s);)f(s,Qe,void 0),f(s,et,void 0),s=s.parent;}},he=new WeakMap,wi=new WeakMap,bi=new WeakMap,Si=new WeakMap,vi=new WeakMap,Ei=new WeakMap,xi=new WeakMap,Ti=new WeakMap,ki=new WeakMap,Mi=new WeakMap,Ri=new WeakMap,Li=new WeakMap,Ci=new WeakMap,Oi=new WeakMap,Pi=new WeakMap,Di=new WeakMap,Ai=new WeakMap,Ii=new WeakMap,Ni=new WeakMap,pt=new WeakMap,Lt=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Qe=new WeakMap,et=new WeakMap,L=new WeakMap,Ct=new WeakMap,tt=new WeakMap,Ve=new WeakMap,R=new WeakSet,Fs=function(i){let e=this;for(let t of i)e=e.child(t);return e},ns=function(i){var e;f(this,L,n(this,L)|Ls);for(let t=i.provisional;t<i.length;t++){let s=i[t];s&&y(e=s,R,pi).call(e);}},pi=function(){n(this,L)&Pe||(f(this,L,(n(this,L)|Pe)&ai),y(this,R,Us).call(this));},Us=function(){var e;let i=this.children();i.provisional=0;for(let t of i)y(e=t,R,pi).call(e);},$s=function(){f(this,L,n(this,L)|rs),y(this,R,fi).call(this);},fi=function(){if(n(this,L)&di)return;let i=n(this,L);(i&Te)===We&&(i&=ai),f(this,L,i|di),y(this,R,Us).call(this);},os=function(i=""){i==="ENOTDIR"||i==="EPERM"?y(this,R,fi).call(this):i==="ENOENT"?y(this,R,pi).call(this):this.children().provisional=0;},Bs=function(i=""){var e;i==="ENOTDIR"?y(e=this.parent,R,fi).call(e):i==="ENOENT"&&y(this,R,pi).call(this);},zs=function(i=""){var t;let e=n(this,L);e|=Xi,i==="ENOENT"&&(e|=Pe),(i==="EINVAL"||i==="UNKNOWN")&&(e&=ai),f(this,L,e),i==="ENOTDIR"&&this.parent&&y(t=this.parent,R,fi).call(t);},as=function(i,e){return y(this,R,xn).call(this,i,e)||y(this,R,En).call(this,i,e)},En=function(i,e){let t=Cs(i),s=this.newChild(i.name,t,{parent:this}),r=n(s,L)&Te;return r!==We&&r!==vt&&r!==Me&&f(s,L,n(s,L)|di),e.unshift(s),e.provisional++,s},xn=function(i,e){for(let t=e.provisional;t<e.length;t++){let s=e[t];if((this.nocase?Qi(i.name):ui(i.name))===n(s,pt))return y(this,R,Tn).call(this,i,s,t,e)}},Tn=function(i,e,t,s){let r=e.name;return f(e,L,n(e,L)&ai|Cs(i)),r!==i.name&&(e.name=i.name),t!==s.provisional&&(t===s.length-1?s.pop():s.splice(t,1),s.unshift(e)),s.provisional++,e},js=function(i){let{atime:e,atimeMs:t,birthtime:s,birthtimeMs:r,blksize:o,blocks:a,ctime:h,ctimeMs:l,dev:d,gid:g,ino:p,mode:u,mtime:m,mtimeMs:b,nlink:S,rdev:T,size:v,uid:M}=i;f(this,Di,e),f(this,Li,t),f(this,Ni,s),f(this,Pi,r),f(this,Ti,o),f(this,Ri,a),f(this,Ii,h),f(this,Oi,l),f(this,wi,d),f(this,Ei,g),f(this,ki,p),f(this,bi,u),f(this,Ai,m),f(this,Ci,b),f(this,Si,S),f(this,xi,T),f(this,Mi,v),f(this,vi,M);let O=Cs(i);f(this,L,n(this,L)&ai|O|pr),O!==Me&&O!==We&&O!==vt&&f(this,L,n(this,L)|di);},Kt=new WeakMap,Jt=new WeakMap,kn=function(i){f(this,Jt,false);let e=n(this,Kt).slice();n(this,Kt).length=0,e.forEach(t=>t(null,i));},Ot=new WeakMap,Gr),Mn=class Rn extends ue{constructor(t,s=Me,r,o,a,h,l){super(t,s,r,o,a,h,l);c(this,"sep","\\");c(this,"splitSep",Ra);}newChild(t,s=Me,r={}){return new Rn(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(t){return ti.win32.parse(t).root}getRoot(t){if(t=Ma(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,r]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=r;return this.roots[t]=new Hs(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(gn,"$1\\"),t===s}},Ln=class Cn extends ue{constructor(t,s=Me,r,o,a,h,l){super(t,s,r,o,a,h,l);c(this,"splitSep","/");c(this,"sep","/");}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=Me,r={}){return new Cn(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Yt,Zt,_i,Fi,qr,On=(qr=class{constructor(i=process.cwd(),e,t,{nocase:s,childrenCacheSize:r=16*1024,fs:o=ci}={}){c(this,"root");c(this,"rootPath");c(this,"roots");c(this,"cwd");w(this,Yt);w(this,Zt);w(this,_i);c(this,"nocase");w(this,Fi);f(this,Fi,fn(o)),(i instanceof URL||i.startsWith("file://"))&&(i=url.fileURLToPath(i));let a=e.resolve(i);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),f(this,Yt,new yr),f(this,Zt,new yr),f(this,_i,new Ca(r));let h=a.substring(this.rootPath.length).split(t);if(h.length===1&&!h[0]&&h.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(n(this,Fi)),this.roots[this.rootPath]=this.root;let l=this.root,d=h.length-1,g=e.sep,p=this.rootPath,u=false;for(let m of h){let b=d--;l=l.child(m,{relative:new Array(b).fill("..").join(g),relativePosix:new Array(b).fill("..").join("/"),fullpath:p+=(u?"":g)+m}),u=true;}this.cwd=l;}depth(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.depth()}childrenCache(){return n(this,_i)}resolve(...i){let e="";for(let r=i.length-1;r>=0;r--){let o=i[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let t=n(this,Yt).get(e);if(t!==void 0)return t;let s=this.cwd.resolve(e).fullpath();return n(this,Yt).set(e,s),s}resolvePosix(...i){let e="";for(let r=i.length-1;r>=0;r--){let o=i[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let t=n(this,Zt).get(e);if(t!==void 0)return t;let s=this.cwd.resolve(e).fullpathPosix();return n(this,Zt).set(e,s),s}relative(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.relative()}relativePosix(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.relativePosix()}basename(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.name}dirname(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),(i.parent||i).fullpath()}async readdir(i=this.cwd,e={withFileTypes:true}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd);let{withFileTypes:t}=e;if(i.canReaddir()){let s=await i.readdir();return t?s:s.map(r=>r.name)}else return []}readdirSync(i=this.cwd,e={withFileTypes:true}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd);let{withFileTypes:t=true}=e;return i.canReaddir()?t?i.readdirSync():i.readdirSync().map(s=>s.name):[]}async lstat(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.lstat()}lstatSync(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.lstatSync()}async readlink(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i.withFileTypes,i=this.cwd);let t=await i.readlink();return e?t:t?.fullpath()}readlinkSync(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i.withFileTypes,i=this.cwd);let t=i.readlinkSync();return e?t:t?.fullpath()}async realpath(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i.withFileTypes,i=this.cwd);let t=await i.realpath();return e?t:t?.fullpath()}realpathSync(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i.withFileTypes,i=this.cwd);let t=i.realpathSync();return e?t:t?.fullpath()}async walk(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=[];(!r||r(i))&&a.push(t?i:i.fullpath());let h=new Set,l=(g,p)=>{h.add(g),g.readdirCB((u,m)=>{if(u)return p(u);let b=m.length;if(!b)return p();let S=()=>{--b===0&&p();};for(let T of m)(!r||r(T))&&a.push(t?T:T.fullpath()),s&&T.isSymbolicLink()?T.realpath().then(v=>v?.isUnknown()?v.lstat():v).then(v=>v?.shouldWalk(h,o)?l(v,S):S()):T.shouldWalk(h,o)?l(T,S):S();},true);},d=i;return new Promise((g,p)=>{l(d,u=>{if(u)return p(u);g(a);});})}walkSync(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=[];(!r||r(i))&&a.push(t?i:i.fullpath());let h=new Set([i]);for(let l of h){let d=l.readdirSync();for(let g of d){(!r||r(g))&&a.push(t?g:g.fullpath());let p=g;if(g.isSymbolicLink()){if(!(s&&(p=g.realpathSync())))continue;p.isUnknown()&&p.lstatSync();}p.shouldWalk(h,o)&&h.add(p);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(i=this.cwd,e={}){return typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd),this.stream(i,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e;(!r||r(i))&&(yield t?i:i.fullpath());let a=new Set([i]);for(let h of a){let l=h.readdirSync();for(let d of l){(!r||r(d))&&(yield t?d:d.fullpath());let g=d;if(d.isSymbolicLink()){if(!(s&&(g=d.realpathSync())))continue;g.isUnknown()&&g.lstatSync();}g.shouldWalk(a,o)&&a.add(g);}}}stream(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=new cs({objectMode:true});(!r||r(i))&&a.write(t?i:i.fullpath());let h=new Set,l=[i],d=0,g=()=>{let p=false;for(;!p;){let u=l.shift();if(!u){d===0&&a.end();return}d++,h.add(u);let m=(S,T,v=false)=>{if(S)return a.emit("error",S);if(s&&!v){let M=[];for(let O of T)O.isSymbolicLink()&&M.push(O.realpath().then(P=>P?.isUnknown()?P.lstat():P));if(M.length){Promise.all(M).then(()=>m(null,T,true));return}}for(let M of T)M&&(!r||r(M))&&(a.write(t?M:M.fullpath())||(p=true));d--;for(let M of T){let O=M.realpathCached()||M;O.shouldWalk(h,o)&&l.push(O);}p&&!a.flowing?a.once("drain",g):b||g();},b=true;u.readdirCB(m,true),b=false;}};return g(),a}streamSync(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof ue||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=new cs({objectMode:true}),h=new Set;(!r||r(i))&&a.write(t?i:i.fullpath());let l=[i],d=0,g=()=>{let p=false;for(;!p;){let u=l.shift();if(!u){d===0&&a.end();return}d++,h.add(u);let m=u.readdirSync();for(let b of m)(!r||r(b))&&(a.write(t?b:b.fullpath())||(p=true));d--;for(let b of m){let S=b;if(b.isSymbolicLink()){if(!(s&&(S=b.realpathSync())))continue;S.isUnknown()&&S.lstatSync();}S.shouldWalk(h,o)&&l.push(S);}}p&&!a.flowing&&a.once("drain",g);};return g(),a}chdir(i=this.cwd){let e=this.cwd;this.cwd=typeof i=="string"?this.cwd.resolve(i):i,this.cwd[vn](e);}},Yt=new WeakMap,Zt=new WeakMap,_i=new WeakMap,Fi=new WeakMap,qr),Hs=class extends On{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,ti.win32,"\\",{...t,nocase:s});c(this,"sep","\\");this.nocase=s;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase;}parseRootPath(e){return ti.win32.parse(e).root.toUpperCase()}newRoot(e){return new Mn(this.rootPath,We,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Ks=class extends On{constructor(e=process.cwd(),t={}){let{nocase:s=false}=t;super(e,ti.posix,"/",{...t,nocase:s});c(this,"sep","/");this.nocase=s;}parseRootPath(e){return "/"}newRoot(e){return new Ln(this.rootPath,We,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},Pn=class extends Ks{constructor(i=process.cwd(),e={}){let{nocase:t=true}=e;super(i,{...e,nocase:t});}};process.platform==="win32"?Mn:Ln;var Oa=process.platform==="win32"?Hs:process.platform==="darwin"?Pn:Ks,Pa=i=>i.length>=1,Da=i=>i.length>=1,Aa=Symbol.for("nodejs.util.inspect.custom"),V,pe,H,Pt,Be,Ui,ft,gt,mt,Xt,Qt,Dn=(Qt=class{constructor(e,t,s,r){w(this,V);w(this,pe);w(this,H);c(this,"length");w(this,Pt);w(this,Be);w(this,Ui);w(this,ft);w(this,gt);w(this,mt);w(this,Xt,true);if(!Pa(e))throw new TypeError("empty pattern list");if(!Da(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,s<0||s>=this.length)throw new TypeError("index out of range");if(f(this,V,e),f(this,pe,t),f(this,H,s),f(this,Pt,r),n(this,H)===0){if(this.isUNC()){let[o,a,h,l,...d]=n(this,V),[g,p,u,m,...b]=n(this,pe);d[0]===""&&(d.shift(),b.shift());let S=[o,a,h,l,""].join("/"),T=[g,p,u,m,""].join("/");f(this,V,[S,...d]),f(this,pe,[T,...b]),this.length=n(this,V).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=n(this,V),[h,...l]=n(this,pe);a[0]===""&&(a.shift(),l.shift());let d=o+"/",g=h+"/";f(this,V,[d,...a]),f(this,pe,[g,...l]),this.length=n(this,V).length;}}}[Aa](){return "Pattern <"+n(this,pe).slice(n(this,H)).join("/")+">"}pattern(){return n(this,V)[n(this,H)]}isString(){return typeof n(this,V)[n(this,H)]=="string"}isGlobstar(){return n(this,V)[n(this,H)]===ce}isRegExp(){return n(this,V)[n(this,H)]instanceof RegExp}globString(){return f(this,Ui,n(this,Ui)||(n(this,H)===0?this.isAbsolute()?n(this,pe)[0]+n(this,pe).slice(1).join("/"):n(this,pe).join("/"):n(this,pe).slice(n(this,H)).join("/")))}hasMore(){return this.length>n(this,H)+1}rest(){return n(this,Be)!==void 0?n(this,Be):this.hasMore()?(f(this,Be,new Qt(n(this,V),n(this,pe),n(this,H)+1,n(this,Pt))),f(n(this,Be),mt,n(this,mt)),f(n(this,Be),gt,n(this,gt)),f(n(this,Be),ft,n(this,ft)),n(this,Be)):f(this,Be,null)}isUNC(){let e=n(this,V);return n(this,gt)!==void 0?n(this,gt):f(this,gt,n(this,Pt)==="win32"&&n(this,H)===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3])}isDrive(){let e=n(this,V);return n(this,ft)!==void 0?n(this,ft):f(this,ft,n(this,Pt)==="win32"&&n(this,H)===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]))}isAbsolute(){let e=n(this,V);return n(this,mt)!==void 0?n(this,mt):f(this,mt,e[0]===""&&e.length>1||this.isDrive()||this.isUNC())}root(){let e=n(this,V)[0];return typeof e=="string"&&this.isAbsolute()&&n(this,H)===0?e:""}checkFollowGlobstar(){return !(n(this,H)===0||!this.isGlobstar()||!n(this,Xt))}markFollowGlobstar(){return n(this,H)===0||!this.isGlobstar()||!n(this,Xt)?false:(f(this,Xt,false),true)}},V=new WeakMap,pe=new WeakMap,H=new WeakMap,Pt=new WeakMap,Be=new WeakMap,Ui=new WeakMap,ft=new WeakMap,gt=new WeakMap,mt=new WeakMap,Xt=new WeakMap,Qt),Ia=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",wr=class{constructor(i,{nobrace:e,nocase:t,noext:s,noglobstar:r,platform:o=Ia}){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:e,nocase:t,noext:s,noglobstar:r,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of i)this.add(a);}add(i){let e=new wt(i,this.mmopts);for(let t=0;t<e.set.length;t++){let s=e.set[t],r=e.globParts[t];if(!s||!r)throw new Error("invalid pattern object");for(;s[0]==="."&&r[0]===".";)s.shift(),r.shift();let o=new Dn(s,r,0,this.platform),a=new wt(o.globString(),this.mmopts),h=r[r.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(a):this.relative.push(a),h&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a));}}ignored(i){let e=i.fullpath(),t=`${e}/`,s=i.relative()||".",r=`${s}/`;for(let o of this.relative)if(o.match(s)||o.match(r))return true;for(let o of this.absolute)if(o.match(e)||o.match(t))return true;return false}childrenIgnored(i){let e=i.fullpath()+"/",t=(i.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(t))return true;for(let s of this.absoluteChildren)if(s.match(e))return true;return false}},Na=class An{constructor(e=new Map){c(this,"store");this.store=e;}copy(){return new An(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let s=e.fullpath(),r=this.store.get(s);r?r.add(t.globString()):this.store.set(s,new Set([t.globString()]));}},_a=class{constructor(){c(this,"store",new Map);}add(i,e,t){let s=(e?2:0)|(t?1:0),r=this.store.get(i);this.store.set(i,r===void 0?s:s&r);}entries(){return [...this.store.entries()].map(([i,e])=>[i,!!(e&2),!!(e&1)])}},Fa=class{constructor(){c(this,"store",new Map);}add(i,e){if(!i.canReaddir())return;let t=this.store.get(i);t?t.find(s=>s.globString()===e.globString())||t.push(e):this.store.set(i,[e]);}get(i){let e=this.store.get(i);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(i=>[i,this.store.get(i)])}keys(){return [...this.store.keys()].filter(i=>i.canReaddir())}},br=class In{constructor(e,t){c(this,"hasWalkedCache");c(this,"matches",new _a);c(this,"subwalks",new Fa);c(this,"patterns");c(this,"follow");c(this,"dot");c(this,"opts");this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Na;}processPatterns(e,t){this.patterns=t;let s=t.map(r=>[e,r]);for(let[r,o]of s){this.hasWalkedCache.storeWalked(r,o);let a=o.root(),h=o.isAbsolute()&&this.opts.absolute!==false;if(a){r=r.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let p=o.rest();if(p)o=p;else {this.matches.add(r,true,false);continue}}if(r.isENOENT())continue;let l,d,g=false;for(;typeof(l=o.pattern())=="string"&&(d=o.rest());)r=r.resolve(l),o=d,g=true;if(l=o.pattern(),d=o.rest(),g){if(this.hasWalkedCache.hasWalked(r,o))continue;this.hasWalkedCache.storeWalked(r,o);}if(typeof l=="string"){let p=l===".."||l===""||l===".";this.matches.add(r.resolve(l),h,p);continue}else if(l===ce){(!r.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(r,o);let p=d?.pattern(),u=d?.rest();if(!d||(p===""||p===".")&&!u)this.matches.add(r,h,p===""||p===".");else if(p===".."){let m=r.parent||r;u?this.hasWalkedCache.hasWalked(m,u)||this.subwalks.add(m,u):this.matches.add(m,h,true);}}else l instanceof RegExp&&this.subwalks.add(r,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new In(this.opts,this.hasWalkedCache)}filterEntries(e,t){let s=this.subwalks.get(e),r=this.child();for(let o of t)for(let a of s){let h=a.isAbsolute(),l=a.pattern(),d=a.rest();l===ce?r.testGlobstar(o,a,d,h):l instanceof RegExp?r.testRegExp(o,l,d,h):r.testString(o,l,d,h);}return r}testGlobstar(e,t,s,r){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,r,false),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(s&&t.checkFollowGlobstar()?this.subwalks.add(e,s):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),s){let o=s.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(e,o,s.rest(),r);else if(o===".."){let a=e.parent||e;this.subwalks.add(a,s);}else o instanceof RegExp&&this.testRegExp(e,o,s.rest(),r);}}testRegExp(e,t,s,r){t.test(e.name)&&(s?this.subwalks.add(e,s):this.matches.add(e,r,false));}testString(e,t,s,r){e.isNamed(t)&&(s?this.subwalks.add(e,s):this.matches.add(e,r,false));}},Ua=(i,e)=>typeof i=="string"?new wr([i],e):Array.isArray(i)?new wr(i,e):i,ei,it,Dt,Re,Et,Ws,Vr,Nn=(Vr=class{constructor(i,e,t){w(this,Re);c(this,"path");c(this,"patterns");c(this,"opts");c(this,"seen",new Set);c(this,"paused",false);c(this,"aborted",false);w(this,ei,[]);w(this,it);w(this,Dt);c(this,"signal");c(this,"maxDepth");c(this,"includeChildMatches");if(this.patterns=i,this.path=e,this.opts=t,f(this,Dt,!t.posix&&t.platform==="win32"?"\\":"/"),this.includeChildMatches=t.includeChildMatches!==false,(t.ignore||!this.includeChildMatches)&&(f(this,it,Ua(t.ignore??[],t)),!this.includeChildMatches&&typeof n(this,it).add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=t.maxDepth||1/0,t.signal&&(this.signal=t.signal,this.signal.addEventListener("abort",()=>{n(this,ei).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let i;for(;!this.paused&&(i=n(this,ei).shift());)i();}onResume(i){this.signal?.aborted||(this.paused?n(this,ei).push(i):i());}async matchCheck(i,e){if(e&&this.opts.nodir)return;let t;if(this.opts.realpath){if(t=i.realpathCached()||await i.realpath(),!t)return;i=t;}let s=i.isUnknown()||this.opts.stat?await i.lstat():i;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let r=await s.realpath();r&&(r.isUnknown()||this.opts.stat)&&await r.lstat();}return this.matchCheckTest(s,e)}matchCheckTest(i,e){return i&&(this.maxDepth===1/0||i.depth()<=this.maxDepth)&&(!e||i.canReaddir())&&(!this.opts.nodir||!i.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!i.isSymbolicLink()||!i.realpathCached()?.isDirectory())&&!y(this,Re,Et).call(this,i)?i:void 0}matchCheckSync(i,e){if(e&&this.opts.nodir)return;let t;if(this.opts.realpath){if(t=i.realpathCached()||i.realpathSync(),!t)return;i=t;}let s=i.isUnknown()||this.opts.stat?i.lstatSync():i;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let r=s.realpathSync();r&&(r?.isUnknown()||this.opts.stat)&&r.lstatSync();}return this.matchCheckTest(s,e)}matchFinish(i,e){if(y(this,Re,Et).call(this,i))return;if(!this.includeChildMatches&&n(this,it)?.add){let r=`${i.relativePosix()}/**`;n(this,it).add(r);}let t=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(i);let s=this.opts.mark&&i.isDirectory()?n(this,Dt):"";if(this.opts.withFileTypes)this.matchEmit(i);else if(t){let r=this.opts.posix?i.fullpathPosix():i.fullpath();this.matchEmit(r+s);}else {let r=this.opts.posix?i.relativePosix():i.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+n(this,Dt))?"."+n(this,Dt):"";this.matchEmit(r?o+r+s:"."+s);}}async match(i,e,t){let s=await this.matchCheck(i,t);s&&this.matchFinish(s,e);}matchSync(i,e,t){let s=this.matchCheckSync(i,t);s&&this.matchFinish(s,e);}walkCB(i,e,t){this.signal?.aborted&&t(),this.walkCB2(i,e,new br(this.opts),t);}walkCB2(i,e,t,s){if(y(this,Re,Ws).call(this,i))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(i,e,t,s));return}t.processPatterns(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Re,Et).call(this,a)||(r++,this.match(a,h,l).then(()=>o()));for(let a of t.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let h=a.readdirCached();a.calledReaddir()?this.walkCB3(a,h,t,o):a.readdirCB((l,d)=>this.walkCB3(a,d,t,o),true);}o();}walkCB3(i,e,t,s){t=t.filterEntries(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Re,Et).call(this,a)||(r++,this.match(a,h,l).then(()=>o()));for(let[a,h]of t.subwalks.entries())r++,this.walkCB2(a,h,t.child(),o);o();}walkCBSync(i,e,t){this.signal?.aborted&&t(),this.walkCB2Sync(i,e,new br(this.opts),t);}walkCB2Sync(i,e,t,s){if(y(this,Re,Ws).call(this,i))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(i,e,t,s));return}t.processPatterns(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Re,Et).call(this,a)||this.matchSync(a,h,l);for(let a of t.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let h=a.readdirSync();this.walkCB3Sync(a,h,t,o);}o();}walkCB3Sync(i,e,t,s){t=t.filterEntries(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Re,Et).call(this,a)||this.matchSync(a,h,l);for(let[a,h]of t.subwalks.entries())r++,this.walkCB2Sync(a,h,t.child(),o);o();}},ei=new WeakMap,it=new WeakMap,Dt=new WeakMap,Re=new WeakSet,Et=function(i){return this.seen.has(i)||!!n(this,it)?.ignored?.(i)},Ws=function(i){return !!n(this,it)?.childrenIgnored?.(i)},Vr),Sr=class extends Nn{constructor(e,t,s){super(e,t,s);c(this,"matches",new Set);}matchEmit(e){this.matches.add(e);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(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}},vr=class extends Nn{constructor(e,t,s){super(e,t,s);c(this,"results");this.results=new cs({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(e){this.results.write(e),this.results.flowing||this.pause();}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end());}):this.walkCB(e,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}},$a=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",It=class{constructor(i,e){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(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=url.fileURLToPath(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==false,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof i=="string"&&(i=[i]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===false,this.windowsPathsNoEscape&&(i=i.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");i=i.map(h=>h.includes("/")?h:`./**/${h}`);}if(this.pattern=i,this.platform=e.platform||$a,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let h=e.platform==="win32"?Hs:e.platform==="darwin"?Pn:e.platform?Ks:Oa;this.scurry=new h(this.cwd,{nocase:e.nocase,fs:e.fs});}this.nocase=this.scurry.nocase;let t=this.platform==="darwin"||this.platform==="win32",s={braceExpandMax:1e4,...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:t,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(h=>new wt(h,s)),[o,a]=r.reduce((h,l)=>(h[0].push(...l.set),h[1].push(...l.globParts),h),[[],[]]);this.patterns=o.map((h,l)=>{let d=a[l];if(!d)throw new Error("invalid pattern object");return new Dn(h,d,0,this.platform)});}async walk(){return [...await new Sr(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 Sr(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 vr(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 vr(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()}},Ba=(i,e={})=>{Array.isArray(i)||(i=[i]);for(let t of i)if(new wt(t,e).hasMagic())return true;return false};function ps(i,e={}){return new It(i,e).streamSync()}function _n(i,e={}){return new It(i,e).stream()}function Fn(i,e={}){return new It(i,e).walkSync()}async function Er(i,e={}){return new It(i,e).walk()}function fs(i,e={}){return new It(i,e).iterateSync()}function Un(i,e={}){return new It(i,e).iterate()}var za=ps,ja=Object.assign(_n,{sync:ps}),Wa=fs,Ga=Object.assign(Un,{sync:fs}),qa=Object.assign(Fn,{stream:ps,iterate:fs}),ds=Object.assign(Er,{glob:Er,globSync:Fn,sync:qa,globStream:_n,stream:ja,globStreamSync:ps,streamSync:za,globIterate:Un,iterate:Ga,globIterateSync:fs,iterateSync:Wa,Glob:It,hasMagic:Ba,escape:sn,unescape:zt});ds.glob=ds;var Le;(P=>{P.Level=Ha__default.default.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let e={DEBUG:0,INFO:1,WARN:2,ERROR:3},t="INFO";function s(k){return e[k]>=e[t]}function r(){return t}P.getLevel=r;let o=new Map;P.Default=O({service:"default"});let h="";function l(){return h}P.file=l;let d,g,p=false,u=()=>{},m=false;async function b(k){if(p)return;if(k.print){p=true;return}k.level&&(t=k.level);let D=k.logDir||ti__namespace.default.join(process.env.EASBOT_LOG_PATH??process.cwd(),"logs");k.logFile?h=ti__namespace.default.join(D,k.logFile??"local-model-sdk.log"):h=ti__namespace.default.join(D,"local-model-sdk.log");try{await Ys__default.default.mkdir(D,{recursive:!0}),d=await Ys__default.default.open(h,"a"),g=B.createWriteStream("",{fd:d.fd,autoClose:!1}),u=F=>{if(!(m||!g||g.destroyed))try{if(!g.writable)return;g.write(F,ie=>{ie&&!m&&(m=!0,setTimeout(()=>{m=!1;},1e3));});}catch{m||(m=!0,setTimeout(()=>{m=!1;},1e3));}},p=!0;}catch{u=F=>{try{process.stderr.write(F);}catch{}},p=true;}}P.init=b;async function S(){p&&(g&&!g.destroyed&&(await new Promise((k,D)=>{g.end(F=>{F?D(F):k();});}).catch(()=>{}),g=void 0),d&&(await d.close().catch(()=>{}),d=void 0),u=k=>{try{process.stderr.write(k);}catch{}},p=false);}P.close=S;function v(k,D=0){let F=k.message;return k.cause instanceof Error&&D<10?F+" Caused by: "+v(k.cause,D+1):F}let M=Date.now();function O(k){k=k||{};let D=k.service;if(D&&typeof D=="string"){let _=o.get(D);if(_)return _}function F(_,K){let bs=Object.entries({...k,...K}).filter(([Xs,rt])=>rt!=null).map(([Xs,rt])=>{let Ss=`${Xs}=`;return rt instanceof Error?Ss+v(rt):typeof rt=="object"?Ss+JSON.stringify(rt):Ss+rt}).join(" "),Ce=new Date,qn=Ce.getTime()-M;return M=Ce.getTime(),[Ce.getFullYear()+"-"+String(Ce.getMonth()+1).padStart(2,"0")+"-"+String(Ce.getDate()).padStart(2,"0")+"T"+String(Ce.getHours()).padStart(2,"0")+":"+String(Ce.getMinutes()).padStart(2,"0")+":"+String(Ce.getSeconds()).padStart(2,"0"),"+"+qn+"ms",bs,_].filter(Boolean).join(" ")+`
4
+ `}let ie={debug(_,K){s("DEBUG")&&u("DEBUG "+F(_,K));},info(_,K){s("INFO")&&u("INFO "+F(_,K));},error(_,K){s("ERROR")&&u("ERROR "+F(_,K));},warn(_,K){s("WARN")&&u("WARN "+F(_,K));},tag(_,K){return k&&(k[_]=K),ie},clone(){return P.create({...k})},time(_,K){let bs=Date.now();ie.info(_,{status:"started",...K});function Ce(){ie.info(_,{status:"completed",duration:Date.now()-bs,...K});}return {stop:Ce,[Symbol.dispose](){Ce();}}}};return D&&typeof D=="string"&&o.set(D,ie),ie}P.create=O;})(Le||(Le={}));var U=Le.create({service:"transformers-engine"});var Ka=ti__namespace.join(er__namespace.homedir(),".cache","easbot","models");process.env.HF_HOME||(process.env.HF_HOME=Ka);transformers.env.allowLocalModels=true;transformers.env.allowRemoteModels=true;transformers.env.useBrowserCache=false;transformers.env.useFSCache=true;var gs=class{constructor(e){c(this,"pipeline",null);c(this,"tokenizer",null);c(this,"isInitialized",false);c(this,"config");c(this,"modelCache");this.config=e,this.modelCache=new Ut({cacheDir:e.cacheDir}),this.configureEnvironment();}configureEnvironment(){this.modelCache.ensureCacheDir(),process.env.HF_HOME||(process.env.HF_HOME=this.config.cacheDir),transformers.env.cacheDir=this.config.cacheDir,transformers.env.allowLocalModels=true,transformers.env.allowRemoteModels=true,transformers.env.useBrowserCache=false,transformers.env.useFSCache=true,transformers.env.backends?.onnx&&(transformers.env.backends.onnx.logLevel="error"),this.config.verbose&&U.debug("\u73AF\u5883\u914D\u7F6E\u5B8C\u6210",{cacheDir:this.config.cacheDir,hfHome:process.env.HF_HOME,modelId:this.config.modelId,modelType:this.config.modelType});}async initialize(){if(this.isInitialized){this.config.verbose&&U.debug("\u6A21\u578B\u5DF2\u521D\u59CB\u5316\uFF0C\u8DF3\u8FC7\u91CD\u590D\u52A0\u8F7D");return}try{this.config.verbose&&U.debug("\u5F00\u59CB\u521D\u59CB\u5316\u6A21\u578B");let e,t;if(this.config.modelType==="language"){let o=Ee[this.config.modelId];if(!o)throw new x(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");e=o.huggingFaceId,t=o.dtype;}else {let o=bt[this.config.modelId];if(!o)throw new x(`\u4E0D\u652F\u6301\u7684 Embedding Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");e=o.huggingFaceId,t=o.dtype;}this.config.verbose&&(U.debug("\u52A0\u8F7D\u6A21\u578B",{huggingFaceId:e,dtype:t||"auto"}),this.modelCache.isCached(e)?U.debug("\u4F7F\u7528\u7F13\u5B58\u7684\u6A21\u578B"):U.debug("\u9996\u6B21\u4E0B\u8F7D\u6A21\u578B\uFF0C\u53EF\u80FD\u9700\u8981\u4E00\u4E9B\u65F6\u95F4"));let s={cache_dir:this.config.cacheDir,local_files_only:!0};if(t&&(s.dtype=t),this.modelCache.isCached(e))this.config.verbose&&U.debug("\u4F7F\u7528\u672C\u5730\u7F13\u5B58\u6A21\u578B");else throw this.config.verbose&&U.warn("\u672C\u5730\u7F13\u5B58\u4E0D\u5B58\u5728",{huggingFaceId:e,cacheDir:this.config.cacheDir}),new x(`\u6A21\u578B ${e} \u672A\u627E\u5230\u672C\u5730\u7F13\u5B58\u3002\u8BF7\u5148\u4E0B\u8F7D\u6A21\u578B\u5230: ${this.config.cacheDir}`,"MODEL_NOT_FOUND");this.config.modelType==="language"?this.pipeline=await transformers.pipeline("text-generation",e,s):this.pipeline=await transformers.pipeline("feature-extraction",e,s),this.tokenizer=this.pipeline.tokenizer,this.isInitialized=!0,this.config.verbose&&U.debug("\u6A21\u578B\u521D\u59CB\u5316\u6210\u529F",{modelId:this.config.modelId});}catch(e){throw this.config.verbose&&U.error("\u6A21\u578B\u521D\u59CB\u5316\u5931\u8D25",{error:e}),ne.modelLoadError(e instanceof Error?e:new Error(String(e)))}}extractAssistantResponse(e,t){let s=`<|im_start|>assistant
5
+ `,r=e.lastIndexOf(s);if(r!==-1){let g=e.slice(r+s.length);return g=g.replace(/<\|im_end\|>$/g,""),g.trim()}let o=`
6
6
  assistant
7
- `,a=t.lastIndexOf(o);if(a!==-1)return t.slice(a+o.length).trim();let h=`assistant
8
- `,l=t.lastIndexOf(h);return l!==-1?t.slice(l+h.length).trim():(t.startsWith(e)?t.slice(e.length):t).trim()}async generate(t,e){let n=kt[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]},o={temperature:e.temperature??n.temperature,topP:e.topP??n.topP,topK:e.topK??n.topK,maxTokens:e.maxTokens??n.maxTokens,repetitionPenalty:e.repetitionPenalty??n.repetitionPenalty,stopSequences:e.stopSequences??n.stopSequences,abortSignal:e.abortSignal};if(this.config.modelType!=="language")throw new x("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(e.abortSignal?.aborted)throw nt.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u751F\u6210\u6587\u672C");let a=await this.countTokens([t]),h=await this.pipeline(t,{max_new_tokens:o.maxTokens,temperature:o.temperature,top_p:o.topP,top_k:o.topK,repetition_penalty:o.repetitionPenalty,do_sample:o.temperature>0});if(e.abortSignal?.aborted)throw nt.abortError();let l=h[0]?.generated_text||"",d=this.extractAssistantResponse(l,t),p=await this.countTokens([d]);return this.config.verbose&&U.debug("\u751F\u6210\u5B8C\u6210",{completionTokens:p}),{content:d,finishReason:ji(!0,!1),usage:{promptTokens:a,completionTokens:p,totalTokens:a+p}}}catch(a){throw this.config.verbose&&U.error("\u751F\u6210\u5931\u8D25",{error:a}),a instanceof x&&a.code==="ABORTED"?a:nt.generationError(a instanceof Error?a:new Error(String(a)))}}async generateStream(t,e,s){let o=kt[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]};if(!this.isInitialized)throw new x("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="language")throw new x("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(e.abortSignal?.aborted)throw nt.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u6D41\u5F0F\u751F\u6210\u6587\u672C\uFF08\u6A21\u62DF\u6D41\u5F0F\u8F93\u51FA\uFF09");let a=await this.pipeline(t,{max_new_tokens:e.maxTokens??o.maxTokens,temperature:e.temperature??o.temperature,top_p:e.topP??o.topP,top_k:e.topK??o.topK,repetition_penalty:e.repetitionPenalty??o.repetitionPenalty,do_sample:(e.temperature??o.temperature)>0});if(e.abortSignal?.aborted)throw nt.abortError();let h=a[0]?.generated_text||"",l=this.extractAssistantResponse(h,t),d=l.split(/(\s+)/);for(let g of d){if(e.abortSignal?.aborted)throw nt.abortError();g.length>0&&s({type:"text-delta",delta:g});}s({type:"text-end"});let p=await this.countTokens([t]),f=await this.countTokens([l]);s({type:"finish",finishReason:ji(!0,!1),usage:{promptTokens:p,completionTokens:f,totalTokens:p+f}}),this.config.verbose&&U.debug("\u6D41\u5F0F\u751F\u6210\u5B8C\u6210",{promptTokens:p,completionTokens:f,totalTokens:p+f});}catch(a){throw this.config.verbose&&U.error("\u6D41\u5F0F\u751F\u6210\u5931\u8D25",{error:a}),a instanceof x&&a.code==="ABORTED"?a:(s({type:"finish",finishReason:ji(false,true,"generation_error"),usage:{promptTokens:0,completionTokens:0,totalTokens:0}}),nt.generationError(a instanceof Error?a:new Error(String(a))))}}async embed(t,e){if(!this.isInitialized)throw new x("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="embedding")throw new x("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u5D4C\u5165\u63A8\u7406","UNSUPPORTED_FEATURE");if(e?.aborted)throw nt.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u63A8\u7406",{textCount:t.length});let s=await this.pipeline(t,{pooling:"mean",normalize:!0});if(e?.aborted)throw nt.abortError();let n=[];if(s.dims&&s.dims.length===2){let[o,a]=s.dims,h=Array.from(s.data);for(let l=0;l<o;l++){let d=l*a,p=d+a;n.push(h.slice(d,p));}}else n.push(Array.from(s.data));return this.config.verbose&&U.debug("\u63A8\u7406\u5B8C\u6210",{embeddingCount:n.length}),n}catch(s){throw this.config.verbose&&U.error("\u63A8\u7406\u5931\u8D25",{error:s}),s instanceof x&&s.code==="ABORTED"?s:nt.embeddingError(s instanceof Error?s:new Error(String(s)))}}async countTokens(t){if(!this.isInitialized)throw new x("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");try{let e=0;for(let s of t){let n=await this.tokenizer(s);e+=n.input_ids.data.length;}return e}catch(e){return this.config.verbose&&U.error("\u8BA1\u7B97 token \u5931\u8D25",{error:e}),t.reduce((s,n)=>s+Math.ceil(n.length/4),0)}}async dispose(){this.config.verbose&&U.debug("\u5378\u8F7D\u6A21\u578B"),this.pipeline=null,this.tokenizer=null,this.isInitialized=false,this.config.verbose&&U.debug("\u6A21\u578B\u5DF2\u5378\u8F7D");}isReady(){return this.isInitialized}};var pt=class{static validateTexts(t){if(!Array.isArray(t))throw new x("\u8F93\u5165\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4","INVALID_INPUT");if(t.length===0)throw new x("\u8F93\u5165\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let e=0;e<t.length;e++){let s=t[e];if(typeof s!="string")throw new x(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${e} \u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`,"INVALID_INPUT");if(s.trim().length===0)throw new x(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${e} \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}static validateMessages(t){if(!Array.isArray(t))throw new x("\u6D88\u606F\u5FC5\u987B\u662F\u6570\u7EC4","INVALID_INPUT");if(t.length===0)throw new x("\u6D88\u606F\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let e=0;e<t.length;e++){let s=t[e];if(!s||typeof s!="object")throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!s.role)throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7F3A\u5C11 role \u5B57\u6BB5`,"INVALID_INPUT");if(!["system","user","assistant"].includes(s.role))throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 role "${s.role}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 system\u3001user\u3001assistant`,"UNSUPPORTED_FEATURE");if(!s.content)throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7F3A\u5C11 content \u5B57\u6BB5`,"INVALID_INPUT");if(typeof s.content=="string"){if(s.content.trim().length===0)throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}else if(Array.isArray(s.content)){if(s.content.length===0)throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content \u6570\u7EC4\u4E3A\u7A7A`,"INVALID_INPUT");for(let n=0;n<s.content.length;n++){let o=s.content[n];if(!o||typeof o!="object")throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content part ${n} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!o.type)throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content part ${n} \u7F3A\u5C11 type \u5B57\u6BB5`,"INVALID_INPUT");if(o.type!=="text"&&o.type!=="reasoning")throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content part ${n} \u7C7B\u578B "${o.type}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 text \u548C reasoning`,"UNSUPPORTED_FEATURE");if(!("text"in o)||typeof o.text!="string")throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content part ${n} \u7F3A\u5C11\u6709\u6548\u7684 text \u5B57\u6BB5`,"INVALID_INPUT");if(o.text.trim().length===0)throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content part ${n} \u7684 text \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}else throw new x(`\u6D88\u606F\u7D22\u5F15 ${e} \u7684 content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216\u6570\u7EC4`,"INVALID_INPUT")}}static validateGenerateOptions(t){if(t.temperature!==void 0&&(typeof t.temperature!="number"||t.temperature<0||t.temperature>2))throw new x("temperature \u5FC5\u987B\u662F 0 \u5230 2 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(t.topP!==void 0&&(typeof t.topP!="number"||t.topP<0||t.topP>1))throw new x("topP \u5FC5\u987B\u662F 0 \u5230 1 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(t.topK!==void 0&&(typeof t.topK!="number"||t.topK<1||!Number.isInteger(t.topK)))throw new x("topK \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(t.maxTokens!==void 0&&(typeof t.maxTokens!="number"||t.maxTokens<1||!Number.isInteger(t.maxTokens)))throw new x("maxTokens \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(t.repetitionPenalty!==void 0&&(typeof t.repetitionPenalty!="number"||t.repetitionPenalty<0))throw new x("repetitionPenalty \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6570\u5B57","INVALID_INPUT")}};var ps=class{static createReadableStream(t,e){return new ReadableStream({async start(s){if(e?.aborted){s.error(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));return}let n=false,o=()=>{n=true,s.error(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));};e?.addEventListener("abort",o);try{if(await t(a=>{if(!n)try{s.enqueue(a),a.isFinished&&(s.close(),e?.removeEventListener("abort",o));}catch(h){s.error(h),e?.removeEventListener("abort",o);}}),!n)try{s.enqueue({textDelta:"",isFinished:!0,finishReason:"stop"}),s.close();}catch{}}catch(a){n||s.error(a instanceof x?a:new x(`\u751F\u6210\u5931\u8D25: ${a instanceof Error?a.message:String(a)}`,"GENERATION_ERROR",a instanceof Error?a:void 0));}finally{e?.removeEventListener("abort",o);}},cancel(){}})}static async*streamToAsyncIterator(t){let e=t.getReader();try{for(;;){let{done:s,value:n}=await e.read();if(s)break;yield n;}}finally{e.releaseLock();}}};function Ka(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var Ui=class{constructor(t,e,s){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"engine");c(this,"modelConfig");if(this.provider=t,this.modelId=e,this.engine=s,this.modelConfig=kt[e],!this.modelConfig)throw new x(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${e}`,"MODEL_NOT_FOUND")}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}convertToQwenFormat(t){let e=[];for(let s of t){let n="";switch(typeof s.content=="string"?n=s.content:Array.isArray(s.content)&&(n=s.content.filter(o=>o.type==="text").map(o=>"text"in o?o.text:"").join(`
9
- `)),s.role){case "system":e.push(`<|im_start|>system
10
- ${n}<|im_end|>`);break;case "user":e.push(`<|im_start|>user
11
- ${n}<|im_end|>`);break;case "assistant":e.push(`<|im_start|>assistant
12
- ${n}<|im_end|>`);break;default:throw new x(`\u4E0D\u652F\u6301\u7684\u6D88\u606F\u89D2\u8272: ${s.role}`,"UNSUPPORTED_FEATURE")}}return e.push(`<|im_start|>assistant
13
- `),e.join(`
14
- `)}async doGenerate(t){pt.validateMessages(t.prompt);let e=this.convertToQwenFormat(t.prompt),s={temperature:t.temperature??this.modelConfig.defaultSettings.temperature,topP:t.topP??this.modelConfig.defaultSettings.topP,topK:t.topK??this.modelConfig.defaultSettings.topK,maxTokens:t.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:t.abortSignal};pt.validateGenerateOptions(s),this.engine.isReady()||await this.engine.initialize();let n=await this.engine.generate(e,s);return {content:[{type:"text",text:n.content||""}],finishReason:n.finishReason,usage:{inputTokens:n.usage.promptTokens,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:n.usage.completionTokens,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:(n.usage.promptTokens||0)+(n.usage.completionTokens||0)},warnings:[],rawCall:{rawPrompt:e,rawSettings:s}}}async doStream(t){pt.validateMessages(t.prompt);let e=this.convertToQwenFormat(t.prompt),s={temperature:t.temperature??this.modelConfig.defaultSettings.temperature,topP:t.topP??this.modelConfig.defaultSettings.topP,topK:t.topK??this.modelConfig.defaultSettings.topK,maxTokens:t.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:t.abortSignal};pt.validateGenerateOptions(s),this.engine.isReady()||await this.engine.initialize();let n=ps.createReadableStream(async h=>{await this.engine.generateStream(e,s,l=>{if(l.type==="text-delta"){let d=l.delta||"";h({textDelta:d,isFinished:false});}else l.type==="finish"&&h({textDelta:"",isFinished:true,finishReason:l.finishReason});});},t.abortSignal),o=null;return {stream:n.pipeThrough(new TransformStream({transform(h,l){h.isFinished?(o&&(l.enqueue({type:"text-end",id:o}),o=null),l.enqueue({type:"finish",finishReason:h.finishReason||"stop",usage:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}})):h.textDelta&&(o||(o=Ka(),l.enqueue({type:"text-start",id:o})),l.enqueue({type:"text-delta",id:o,delta:h.textDelta}));}})),rawCall:{rawPrompt:e,rawSettings:s}}}};var Bi=class i{static buildEnhancedPrompt(t,e){let s=[];s.push(i.buildSystemPrompt(e));for(let n of t){let o=i.formatMessage(n);o&&s.push(o);}return s.push(`<|im_start|>assistant
7
+ `,a=e.lastIndexOf(o);if(a!==-1)return e.slice(a+o.length).trim();let h=`assistant
8
+ `,l=e.lastIndexOf(h);return l!==-1?e.slice(l+h.length).trim():(e.startsWith(t)?e.slice(t.length):e).trim()}async generate(e,t){let r=Ee[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]},o={temperature:t.temperature??r.temperature,topP:t.topP??r.topP,topK:t.topK??r.topK,maxTokens:t.maxTokens??r.maxTokens,repetitionPenalty:t.repetitionPenalty??r.repetitionPenalty,stopSequences:t.stopSequences??r.stopSequences,abortSignal:t.abortSignal};if(this.config.modelType!=="language")throw new x("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(t.abortSignal?.aborted)throw ne.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u751F\u6210\u6587\u672C");let a=await this.countTokens([e]),h=await this.pipeline(e,{max_new_tokens:o.maxTokens,temperature:o.temperature,top_p:o.topP,top_k:o.topK,repetition_penalty:o.repetitionPenalty,do_sample:o.temperature>0});if(t.abortSignal?.aborted)throw ne.abortError();let l=h[0]?.generated_text||"",d=this.extractAssistantResponse(l,e),g=await this.countTokens([d]);return this.config.verbose&&U.debug("\u751F\u6210\u5B8C\u6210",{completionTokens:g}),{content:d,finishReason:qi(!0,!1),usage:{promptTokens:a,completionTokens:g,totalTokens:a+g}}}catch(a){throw this.config.verbose&&U.error("\u751F\u6210\u5931\u8D25",{error:a}),a instanceof x&&a.code==="ABORTED"?a:ne.generationError(a instanceof Error?a:new Error(String(a)))}}async generateStream(e,t,s){let o=Ee[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]};if(!this.isInitialized)throw new x("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="language")throw new x("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(t.abortSignal?.aborted)throw ne.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u6D41\u5F0F\u751F\u6210\u6587\u672C\uFF08\u6A21\u62DF\u6D41\u5F0F\u8F93\u51FA\uFF09");let a=await this.pipeline(e,{max_new_tokens:t.maxTokens??o.maxTokens,temperature:t.temperature??o.temperature,top_p:t.topP??o.topP,top_k:t.topK??o.topK,repetition_penalty:t.repetitionPenalty??o.repetitionPenalty,do_sample:(t.temperature??o.temperature)>0});if(t.abortSignal?.aborted)throw ne.abortError();let h=a[0]?.generated_text||"",l=this.extractAssistantResponse(h,e),d=l.split(/(\s+)/);for(let u of d){if(t.abortSignal?.aborted)throw ne.abortError();u.length>0&&s({type:"text-delta",delta:u});}s({type:"text-end"});let g=await this.countTokens([e]),p=await this.countTokens([l]);s({type:"finish",finishReason:qi(!0,!1),usage:{promptTokens:g,completionTokens:p,totalTokens:g+p}}),this.config.verbose&&U.debug("\u6D41\u5F0F\u751F\u6210\u5B8C\u6210",{promptTokens:g,completionTokens:p,totalTokens:g+p});}catch(a){throw this.config.verbose&&U.error("\u6D41\u5F0F\u751F\u6210\u5931\u8D25",{error:a}),a instanceof x&&a.code==="ABORTED"?a:(s({type:"finish",finishReason:qi(false,true,"generation_error"),usage:{promptTokens:0,completionTokens:0,totalTokens:0}}),ne.generationError(a instanceof Error?a:new Error(String(a))))}}async embed(e,t){if(!this.isInitialized)throw new x("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="embedding")throw new x("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u5D4C\u5165\u63A8\u7406","UNSUPPORTED_FEATURE");if(t?.aborted)throw ne.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u63A8\u7406",{textCount:e.length});let s=await this.pipeline(e,{pooling:"mean",normalize:!0});if(t?.aborted)throw ne.abortError();let r=[];if(s.dims&&s.dims.length===2){let[o,a]=s.dims,h=Array.from(s.data);for(let l=0;l<o;l++){let d=l*a,g=d+a;r.push(h.slice(d,g));}}else r.push(Array.from(s.data));return this.config.verbose&&U.debug("\u63A8\u7406\u5B8C\u6210",{embeddingCount:r.length}),r}catch(s){throw this.config.verbose&&U.error("\u63A8\u7406\u5931\u8D25",{error:s}),s instanceof x&&s.code==="ABORTED"?s:ne.embeddingError(s instanceof Error?s:new Error(String(s)))}}async countTokens(e){if(!this.isInitialized)throw new x("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");try{let t=0;for(let s of e){let r=await this.tokenizer(s);t+=r.input_ids.data.length;}return t}catch(t){return this.config.verbose&&U.error("\u8BA1\u7B97 token \u5931\u8D25",{error:t}),e.reduce((s,r)=>s+Math.ceil(r.length/4),0)}}async dispose(){this.config.verbose&&U.debug("\u5378\u8F7D\u6A21\u578B"),this.pipeline=null,this.tokenizer=null,this.isInitialized=false,this.config.verbose&&U.debug("\u6A21\u578B\u5DF2\u5378\u8F7D");}isReady(){return this.isInitialized}};var fe=class{static validateTexts(e){if(!Array.isArray(e))throw new x("\u8F93\u5165\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4","INVALID_INPUT");if(e.length===0)throw new x("\u8F93\u5165\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let t=0;t<e.length;t++){let s=e[t];if(typeof s!="string")throw new x(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${t} \u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`,"INVALID_INPUT");if(s.trim().length===0)throw new x(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${t} \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}static validateMessages(e){if(!Array.isArray(e))throw new x("\u6D88\u606F\u5FC5\u987B\u662F\u6570\u7EC4","INVALID_INPUT");if(e.length===0)throw new x("\u6D88\u606F\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let t=0;t<e.length;t++){let s=e[t];if(!s||typeof s!="object")throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!s.role)throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7F3A\u5C11 role \u5B57\u6BB5`,"INVALID_INPUT");if(!["system","user","assistant"].includes(s.role))throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 role "${s.role}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 system\u3001user\u3001assistant`,"UNSUPPORTED_FEATURE");if(!s.content)throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7F3A\u5C11 content \u5B57\u6BB5`,"INVALID_INPUT");if(typeof s.content=="string"){if(s.content.trim().length===0)throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}else if(Array.isArray(s.content)){if(s.content.length===0)throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u6570\u7EC4\u4E3A\u7A7A`,"INVALID_INPUT");for(let r=0;r<s.content.length;r++){let o=s.content[r];if(!o||typeof o!="object")throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!o.type)throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7F3A\u5C11 type \u5B57\u6BB5`,"INVALID_INPUT");if(o.type!=="text"&&o.type!=="reasoning")throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7C7B\u578B "${o.type}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 text \u548C reasoning`,"UNSUPPORTED_FEATURE");if(!("text"in o)||typeof o.text!="string")throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7F3A\u5C11\u6709\u6548\u7684 text \u5B57\u6BB5`,"INVALID_INPUT");if(o.text.trim().length===0)throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7684 text \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}else throw new x(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216\u6570\u7EC4`,"INVALID_INPUT")}}static validateGenerateOptions(e){if(e.temperature!==void 0&&(typeof e.temperature!="number"||e.temperature<0||e.temperature>2))throw new x("temperature \u5FC5\u987B\u662F 0 \u5230 2 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(e.topP!==void 0&&(typeof e.topP!="number"||e.topP<0||e.topP>1))throw new x("topP \u5FC5\u987B\u662F 0 \u5230 1 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(e.topK!==void 0&&(typeof e.topK!="number"||e.topK<1||!Number.isInteger(e.topK)))throw new x("topK \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(e.maxTokens!==void 0&&(typeof e.maxTokens!="number"||e.maxTokens<1||!Number.isInteger(e.maxTokens)))throw new x("maxTokens \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(e.repetitionPenalty!==void 0&&(typeof e.repetitionPenalty!="number"||e.repetitionPenalty<0))throw new x("repetitionPenalty \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6570\u5B57","INVALID_INPUT")}};var ms=class{static createReadableStream(e,t){return new ReadableStream({async start(s){if(t?.aborted){s.error(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));return}let r=false,o=()=>{r=true,s.error(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));};t?.addEventListener("abort",o);try{if(await e(a=>{if(!r)try{s.enqueue(a),a.isFinished&&(s.close(),t?.removeEventListener("abort",o));}catch(h){s.error(h),t?.removeEventListener("abort",o);}}),!r)try{s.enqueue({textDelta:"",isFinished:!0,finishReason:"stop"}),s.close();}catch{}}catch(a){r||s.error(a instanceof x?a:new x(`\u751F\u6210\u5931\u8D25: ${a instanceof Error?a.message:String(a)}`,"GENERATION_ERROR",a instanceof Error?a:void 0));}finally{t?.removeEventListener("abort",o);}},cancel(){}})}static async*streamToAsyncIterator(e){let t=e.getReader();try{for(;;){let{done:s,value:r}=await t.read();if(s)break;yield r;}}finally{t.releaseLock();}}};function Ja(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var Nt=class{constructor(e,t,s){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"engine");c(this,"modelConfig");if(this.provider=e,this.modelId=t,this.engine=s,this.modelConfig=Ee[t],!this.modelConfig)throw new x(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${t}`,"MODEL_NOT_FOUND")}async generate(e){return this.doGenerate(e)}async stream(e){return this.doStream(e)}convertToQwenFormat(e){let t=[];for(let s of e){let r="";switch(typeof s.content=="string"?r=s.content:Array.isArray(s.content)&&(r=s.content.filter(o=>o.type==="text").map(o=>"text"in o?o.text:"").join(`
9
+ `)),s.role){case "system":t.push(`<|im_start|>system
10
+ ${r}<|im_end|>`);break;case "user":t.push(`<|im_start|>user
11
+ ${r}<|im_end|>`);break;case "assistant":t.push(`<|im_start|>assistant
12
+ ${r}<|im_end|>`);break;default:throw new x(`\u4E0D\u652F\u6301\u7684\u6D88\u606F\u89D2\u8272: ${s.role}`,"UNSUPPORTED_FEATURE")}}return t.push(`<|im_start|>assistant
13
+ `),t.join(`
14
+ `)}async doGenerate(e){fe.validateMessages(e.prompt);let t=this.convertToQwenFormat(e.prompt),s={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};fe.validateGenerateOptions(s),this.engine.isReady()||await this.engine.initialize();let r=await this.engine.generate(t,s);return {content:[{type:"text",text:r.content||""}],finishReason:r.finishReason,usage:{inputTokens:r.usage.promptTokens,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:r.usage.completionTokens,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:(r.usage.promptTokens||0)+(r.usage.completionTokens||0)},warnings:[],rawCall:{rawPrompt:t,rawSettings:s}}}async doStream(e){fe.validateMessages(e.prompt);let t=this.convertToQwenFormat(e.prompt),s={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};fe.validateGenerateOptions(s),this.engine.isReady()||await this.engine.initialize();let r=ms.createReadableStream(async h=>{await this.engine.generateStream(t,s,l=>{if(l.type==="text-delta"){let d=l.delta||"";h({textDelta:d,isFinished:false});}else l.type==="finish"&&h({textDelta:"",isFinished:true,finishReason:l.finishReason});});},e.abortSignal),o=null;return {stream:r.pipeThrough(new TransformStream({transform(h,l){h.isFinished?(o&&(l.enqueue({type:"text-end",id:o}),o=null),l.enqueue({type:"finish",finishReason:h.finishReason||"stop",usage:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}})):h.textDelta&&(o||(o=Ja(),l.enqueue({type:"text-start",id:o})),l.enqueue({type:"text-delta",id:o,delta:h.textDelta}));}})),rawCall:{rawPrompt:t,rawSettings:s}}}};var $i=class i{static buildEnhancedPrompt(e,t){let s=[];s.push(i.buildSystemPrompt(t));for(let r of e){let o=i.formatMessage(r);o&&s.push(o);}return s.push(`<|im_start|>assistant
15
15
  `),s.join(`
16
- `)}static buildSystemPrompt(t){return t&&t.length>0?`<|im_start|>system
16
+ `)}static buildSystemPrompt(e){return e&&e.length>0?`<|im_start|>system
17
17
  Environment: ipython
18
18
 
19
19
  You have access to the following functions:
20
20
 
21
- ${i.formatToolsDefinition(t)}
21
+ ${i.formatToolsDefinition(e)}
22
22
 
23
23
  FUNCTION CALLING INSTRUCTIONS:
24
24
 
@@ -104,16 +104,106 @@ CRITICAL OUTPUT RULES:
104
104
  2. If you use <think> tags, ALWAYS use them as a COMPLETE PAIR: <think>content</think>
105
105
  3. Your response must be clean, natural text without any formatting markers
106
106
  4. Do NOT include any part of the conversation format in your output
107
- <|im_end|>`}static formatToolsDefinition(t){return t.map(e=>{let s=e.inputSchema;return JSON.stringify({name:e.name,description:e.description||"No description",parameters:s},null,2)}).join(`
108
-
109
- `)}static formatMessage(t){let e="";if(typeof t.content=="string")e=t.content;else if(Array.isArray(t.content)){let s=[];for(let n of t.content)if(n.type==="text")s.push("text"in n?n.text:"");else if(n.type==="tool-call"){let o={name:n.toolName,parameters:n.args||{}};s.push(JSON.stringify(o));}else if(n.type==="tool-result"){let o=n.result;s.push(typeof o=="string"?o:JSON.stringify(o));}e=s.join(`
110
- `);}switch(t.role){case "system":return null;case "user":return `<|im_start|>user
111
- ${e}<|im_end|>`;case "assistant":return `<|im_start|>assistant
112
- ${e}<|im_end|>`;case "tool":return `<|im_start|>tool
113
- ${e}<|im_end|>`;default:{let s=t.role;throw new x(`\u4E0D\u652F\u6301\u7684\u6D88\u606F\u89D2\u8272: ${s}`,"UNSUPPORTED_FEATURE")}}}};var Ne=class{static processThinkTags(t,e){let s={...t};for(;s.contentBuffer.length>0;)if(s.isInThinkTag){let n=s.contentBuffer.indexOf("</think>");if(n===-1){s.contentBuffer.length>0&&e.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:s.contentBuffer}),s.contentBuffer="";break}if(n>0){let o=s.contentBuffer.substring(0,n);o.length>0&&e.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:o});}e.enqueue({type:"reasoning-end",id:"reasoning-0"}),s.reasoningStarted=false,s.isInThinkTag=false,s.contentBuffer=s.contentBuffer.substring(n+8);}else {let n=s.contentBuffer.indexOf("<think>");if(n===-1){s.contentBuffer.length>0&&(s.textStarted||(s.textStarted=true,e.enqueue({type:"text-start",id:"txt-0"})),e.enqueue({type:"text-delta",id:"txt-0",delta:s.contentBuffer})),s.contentBuffer="";break}if(n>0){let o=s.contentBuffer.substring(0,n);s.textStarted||(s.textStarted=true,e.enqueue({type:"text-start",id:"txt-0"})),o.length>0&&e.enqueue({type:"text-delta",id:"txt-0",delta:o}),e.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false;}s.isInThinkTag=true,s.contentBuffer=s.contentBuffer.substring(n+7),s.reasoningStarted||(s.reasoningStarted=true,e.enqueue({type:"reasoning-start",id:"reasoning-0"}));}return s}static finishThinkParsing(t,e){let s={...t};return s.contentBuffer.length>0?s.isInThinkTag?(s.contentBuffer.length>0&&e.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:s.contentBuffer}),s.reasoningStarted&&(e.enqueue({type:"reasoning-end",id:"reasoning-0"}),s.reasoningStarted=false)):(s.textStarted||(e.enqueue({type:"text-start",id:"txt-0"}),s.textStarted=true),s.contentBuffer.length>0&&e.enqueue({type:"text-delta",id:"txt-0",delta:s.contentBuffer}),e.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false):(s.textStarted&&(e.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false),s.reasoningStarted&&!s.isInThinkTag&&(e.enqueue({type:"reasoning-end",id:"reasoning-0"}),s.reasoningStarted=false)),s}static removeThinkTags(t){return t.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}};function Ha(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var _e=class i{static extractToolCalls(t){let e=[],s=t,n=t.split(`
114
- `),o=[];for(let a of n){let h=a.trim();if(!h){o.push(a);continue}try{let l=JSON.parse(h);if(l.name&&typeof l.name=="string"&&l.parameters&&typeof l.parameters=="object"){e.push({name:l.name,parameters:JSON.stringify(l.parameters)});continue}}catch{}o.push(a);}return s=o.join(`
115
- `).trim(),{toolCalls:e,remainingText:s}}static processToolCalls(t,e,s){let n={...t},o=n.contentBuffer.split(`
116
- `),a=[];for(let h=0;h<o.length;h++){let l=o[h];if(!l)continue;let d=l.trim();if(!d){a.push(l);continue}let p=false;try{let f=JSON.parse(d);if(f.name&&typeof f.name=="string"&&f.parameters&&typeof f.parameters=="object"){if(s&&s.length>0&&!s.some(b=>b.name===f.name)){a.push(l);continue}if(p=!0,a.length>0){let S=a.join(`
117
- `);S.trim()&&(n.textStarted||(e.enqueue({type:"text-start",id:"txt-0"}),n.textStarted=!0),e.enqueue({type:"text-delta",id:"txt-0",delta:S+`
118
- `})),a.length=0;}n.textStarted&&(e.enqueue({type:"text-end",id:"txt-0"}),n.textStarted=!1);let g=Ha(),y=JSON.stringify(f.parameters);e.enqueue({type:"tool-input-start",id:g,toolName:f.name}),e.enqueue({type:"tool-input-delta",id:g,delta:y}),e.enqueue({type:"tool-input-end",id:g}),e.enqueue({type:"tool-call",toolCallId:g,toolName:f.name,input:y}),n.completedToolCalls.push({id:g,name:f.name,parameters:y});}}catch{}p||a.push(l);}return n.contentBuffer=a.join(`
119
- `),n}static finishToolParsing(t,e){let s={...t};return s.contentBuffer.trim().length>0?(s.textStarted||(e.enqueue({type:"text-start",id:"txt-0"}),s.textStarted=true),e.enqueue({type:"text-delta",id:"txt-0",delta:s.contentBuffer}),e.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false):s.textStarted&&(e.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false),s}static removeToolCalls(t){let{remainingText:e}=i.extractToolCalls(t);return e}};function zn(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var zi=class{constructor(t,e,s){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"supportsToolCalling","experimental");c(this,"supportsThinking","experimental");c(this,"engine");c(this,"modelConfig");if(this.provider=t,this.modelId=e,this.engine=s,this.modelConfig=kt[e],!this.modelConfig)throw new x(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${e}`,"MODEL_NOT_FOUND")}async generate(t){return this.doGenerate(t)}async stream(t){return this.doStream(t)}async doGenerate(t){pt.validateMessages(t.prompt);let e=t.tools?.filter(g=>"inputSchema"in g),s=Bi.buildEnhancedPrompt(t.prompt,e),n={temperature:t.temperature??this.modelConfig.defaultSettings.temperature,topP:t.topP??this.modelConfig.defaultSettings.topP,topK:t.topK??this.modelConfig.defaultSettings.topK,maxTokens:t.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:t.abortSignal};pt.validateGenerateOptions(n),this.engine.isReady()||await this.engine.initialize();let o=await this.engine.generate(s,n),a=Ne.removeThinkTags(o.content||""),{toolCalls:h,remainingText:l}=_e.extractToolCalls(a),d=[];l.trim().length>0&&d.push({type:"text",text:l});for(let g of h)d.push({type:"tool-call",toolCallId:zn(),toolName:g.name,input:g.parameters});let p=h.length>0?"tool-calls":o.finishReason,f=[];return {content:d,finishReason:p,usage:{inputTokens:{total:o.usage.promptTokens,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:o.usage.completionTokens,text:void 0,reasoning:void 0}},warnings:f,rawCall:{rawPrompt:s,rawSettings:n}}}async doStream(t){let e=zn();pt.validateMessages(t.prompt);let s=t.tools?.filter(y=>"inputSchema"in y),n=Bi.buildEnhancedPrompt(t.prompt,s),o={temperature:t.temperature??this.modelConfig.defaultSettings.temperature,topP:t.topP??this.modelConfig.defaultSettings.topP,topK:t.topK??this.modelConfig.defaultSettings.topK,maxTokens:t.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:t.abortSignal};pt.validateGenerateOptions(o),this.engine.isReady()||await this.engine.initialize();let a=null,h=null,l=y=>{a&&a.enqueue(y),h&&h.enqueue(y);},d=async()=>{try{let y={isInThinkTag:!1,reasoningStarted:!1,textStarted:!1,contentBuffer:""},S={contentBuffer:"",textStarted:!1,completedToolCalls:[]};l({type:"response-metadata",id:e,modelId:this.modelId,timestamp:new Date}),await this.engine.generateStream(n,o,b=>{if(b.type==="text-delta"){let T=b.delta||"";if(T.length===0)return;y.contentBuffer+=T;let E=Ne.processThinkTags(y,{enqueue:l});y.isInThinkTag=E.isInThinkTag,y.reasoningStarted=E.reasoningStarted,y.textStarted=E.textStarted,S.contentBuffer+=E.contentBuffer,y.contentBuffer="";let C=_e.processToolCalls(S,{enqueue:l},s);S.contentBuffer=C.contentBuffer,S.textStarted=C.textStarted,S.completedToolCalls=C.completedToolCalls;}else if(b.type==="text-end"){let T=Ne.finishThinkParsing(y,{enqueue:l});y.textStarted=T.textStarted,y.reasoningStarted=T.reasoningStarted;let E=_e.finishToolParsing(S,{enqueue:l});S.textStarted=E.textStarted;}else if(b.type==="finish"){let T=Ne.finishThinkParsing(y,{enqueue:l});y.textStarted=T.textStarted,y.reasoningStarted=T.reasoningStarted;let E=_e.finishToolParsing(S,{enqueue:l});S.textStarted=E.textStarted;let C=S.completedToolCalls.length>0;l({type:"finish",finishReason:C?"tool-calls":b.finishReason,usage:b.usage?{inputTokens:{total:b.usage.promptTokens||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:b.usage.completionTokens||0,text:void 0,reasoning:void 0}}:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}});}});}catch(y){l({type:"error",error:y instanceof Error?y.message:String(y)}),l({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(),h&&h.close();}},p=new ReadableStream({start(y){a=y;}}),f=new ReadableStream({start(y){h=y;}});d();async function*g(y){let S=y.getReader();try{for(;;){let{done:b,value:T}=await S.read();if(b)break;yield T;}}finally{S.releaseLock();}}return {stream:p,fullStream:g(f),request:{body:n},response:{headers:{}}}}};var gs=class{constructor(t){c(this,"config");this.config=t;}createBatches(t){let e=[],s=this.config.batchSize;for(let n=0;n<t.length;n+=s)e.push(t.slice(n,n+s));return e}async processBatches(t,e,s){if(s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");let n=this.createBatches(t),o=[];for(let a=0;a<n.length;a++){if(s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");let h=n[a];if(h){try{let l=await e(h);o.push(...l);}catch(l){throw l instanceof x&&l.code==="ABORTED"?l:new x(`\u6279\u6B21 ${a+1}/${n.length} \u5904\u7406\u5931\u8D25: ${l instanceof Error?l.message:String(l)}`,"PROCESSING_ERROR",l instanceof Error?l:void 0)}a<n.length-1&&this.config.delayBetweenBatches&&this.config.delayBetweenBatches>0&&await this.delay(this.config.delayBetweenBatches,s);}}return o}async delay(t,e){return new Promise((s,n)=>{if(e?.aborted){n(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));return}let o=setTimeout(()=>{e?.removeEventListener("abort",a),s();},t),a=()=>{clearTimeout(o),n(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));};e?.addEventListener("abort",a);})}};var $i=class{constructor(t,e,s){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"maxEmbeddingsPerCall");c(this,"supportsParallelCalls",false);c(this,"engine");c(this,"modelConfig");if(this.provider=t,this.modelId=e,this.engine=s,this.modelConfig=be[e],!this.modelConfig)throw new x(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${e}`,"MODEL_NOT_FOUND");this.maxEmbeddingsPerCall=this.modelConfig.maxEmbeddingsPerCall;}async doEmbed(t){let{values:e,abortSignal:s}=t;if(pt.validateTexts(e),s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");this.engine.isReady()||await this.engine.initialize();let o=await new gs({batchSize:this.maxEmbeddingsPerCall,delayBetweenBatches:0}).processBatches(e,async h=>{if(s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");return await this.engine.embed(h,s)},s),a=await this.engine.countTokens(e);return {embeddings:o,usage:{tokens:a},warnings:[]}}};var we=ye.create({service:"local-model-provider"}),Hs={cacheDir:ti__namespace.default.join(Zs__namespace.homedir(),".cache","easbot","models"),verbose:false,autoUnloadTimeout:300*1e3,maxCachedModels:3,memoryWarningThreshold:1.5*1024*1024*1024,useEnhancedModel:true,logDir:"",logLevel:"INFO"},ms=class{constructor(t){c(this,"config");c(this,"modelCache");c(this,"engines",new Map);c(this,"modelInfo",new Map);this.config={...Hs,...t},this.modelCache=new Fe({cacheDir:this.config.cacheDir});}languageModel(t,e){if(!kt[t])throw new x(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${t}`,"MODEL_NOT_FOUND");let s=this.getOrCreateEngine(t,"language");return e?.useEnhancedModel??this.config.useEnhancedModel?(this.config.verbose&&we.debug("\u521B\u5EFA\u589E\u5F3A\u8BED\u8A00\u6A21\u578B",{modelId:t}),new zi("local",t,s)):(this.config.verbose&&we.debug("\u521B\u5EFA\u57FA\u7840\u8BED\u8A00\u6A21\u578B",{modelId:t}),new Ui("local",t,s))}textEmbeddingModel(t){if(!be[t])throw new x(`\u4E0D\u652F\u6301\u7684 Embedding Model ID: ${t}`,"MODEL_NOT_FOUND");let e=this.getOrCreateEngine(t,"embedding");return new $i("local",t,e)}chat(t,e){return this.languageModel(t,e)}getOrCreateEngine(t,e){let s=`${e}:${t}`;if(this.engines.has(s)){let o=this.modelInfo.get(s);return o&&(o.lastUsed=Date.now(),o.useCount++),this.config.verbose&&we.debug("\u590D\u7528\u5DF2\u52A0\u8F7D\u7684\u6A21\u578B",{engineKey:s}),this.engines.get(s)}this.engines.size>=this.config.maxCachedModels&&this.evictLeastRecentlyUsed(),this.config.verbose&&we.debug("\u521B\u5EFA\u65B0\u5F15\u64CE",{engineKey:s});let n=new fs({modelId:t,modelType:e,cacheDir:this.config.cacheDir,verbose:this.config.verbose});return this.engines.set(s,n),this.modelInfo.set(s,{modelId:t,modelType:e,isLoaded:false,lastUsed:Date.now(),useCount:1}),n}evictLeastRecentlyUsed(){let t=null,e=Number.POSITIVE_INFINITY;for(let[s,n]of this.modelInfo.entries())n.lastUsed<e&&(e=n.lastUsed,t=s);if(t){this.config.verbose&&we.debug("\u6DD8\u6C70\u6A21\u578B",{engineKey:t});let s=this.engines.get(t);s&&s.dispose().catch(n=>{we.error("\u5378\u8F7D\u6A21\u578B\u5931\u8D25",{error:n});}),this.engines.delete(t),this.modelInfo.delete(t);}}getLoadedModels(){return Array.from(this.modelInfo.values())}async dispose(){this.config.verbose&&we.debug("\u5378\u8F7D\u6240\u6709\u6A21\u578B");let t=Array.from(this.engines.values()).map(e=>e.dispose());await Promise.all(t),this.engines.clear(),this.modelInfo.clear(),this.config.verbose&&we.debug("\u6240\u6709\u6A21\u578B\u5DF2\u5378\u8F7D");}};function Ja(i){let t=new ms(i);if(i?.logDir){let s=i.logLevel??"INFO",n=ti__namespace.default.join(i.logDir,"local-model-sdk.log");ye.init({print:process.argv.includes("--print-logs"),logDir:i.logDir,level:s,logFile:"local-model-sdk.log"}).then(()=>{ye.create({service:"local-model-sdk",module:"provider"}).debug("Local model provider created",{cacheDir:i?.cacheDir||Hs.cacheDir,useEnhancedModel:i?.useEnhancedModel??Hs.useEnhancedModel,logFile:n,logLevel:s});});}return Object.assign((s,n)=>t.languageModel(s,n),{languageModel:(s,n)=>t.languageModel(s,n),chat:(s,n)=>t.chat(s,n),textEmbeddingModel:s=>t.textEmbeddingModel(s)})}var Ya="0.1.0",Za="@easbot/local-model-sdk",Xa="Complete local model SDK for EASBot - Transformers.js + ONNX implementation";exports.ErrorCode=gt;exports.ErrorHandler=nt;exports.LocalEmbeddingModel=$i;exports.LocalEnhancedLanguageModel=zi;exports.LocalLanguageModel=Ui;exports.LocalModelError=x;exports.LocalModelProvider=ms;exports.SDK_DESCRIPTION=Xa;exports.SDK_NAME=Za;exports.SUPPORTED_EMBEDDING_MODELS=be;exports.SUPPORTED_LANGUAGE_MODELS=kt;exports.VERSION=Ya;exports.createLocal=Ja;
107
+ <|im_end|>`}static formatToolsDefinition(e){return e.map(t=>{let s=t.inputSchema;return JSON.stringify({name:t.name,description:t.description||"No description",parameters:s},null,2)}).join(`
108
+
109
+ `)}static formatMessage(e){let t="";if(typeof e.content=="string")t=e.content;else if(Array.isArray(e.content)){let s=[];for(let r of e.content)if(r.type==="text")s.push("text"in r?r.text:"");else if(r.type==="tool-call"){let o={name:r.toolName,parameters:r.args||{}};s.push(JSON.stringify(o));}else if(r.type==="tool-result"){let o=r.result;s.push(typeof o=="string"?o:JSON.stringify(o));}t=s.join(`
110
+ `);}switch(e.role){case "system":return null;case "user":return `<|im_start|>user
111
+ ${t}<|im_end|>`;case "assistant":return `<|im_start|>assistant
112
+ ${t}<|im_end|>`;case "tool":return `<|im_start|>tool
113
+ ${t}<|im_end|>`;default:{let s=e.role;throw new x(`\u4E0D\u652F\u6301\u7684\u6D88\u606F\u89D2\u8272: ${s}`,"UNSUPPORTED_FEATURE")}}}};var _t=class{static processThinkTags(e,t){let s={...e};for(;s.contentBuffer.length>0;)if(s.isInThinkTag){let r=s.contentBuffer.indexOf("</think>");if(r===-1){s.contentBuffer.length>0&&t.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:s.contentBuffer}),s.contentBuffer="";break}if(r>0){let o=s.contentBuffer.substring(0,r);o.length>0&&t.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:o});}t.enqueue({type:"reasoning-end",id:"reasoning-0"}),s.reasoningStarted=false,s.isInThinkTag=false,s.contentBuffer=s.contentBuffer.substring(r+8);}else {let r=s.contentBuffer.indexOf("<think>");if(r===-1){s.contentBuffer.length>0&&(s.textStarted||(s.textStarted=true,t.enqueue({type:"text-start",id:"txt-0"})),t.enqueue({type:"text-delta",id:"txt-0",delta:s.contentBuffer})),s.contentBuffer="";break}if(r>0){let o=s.contentBuffer.substring(0,r);s.textStarted||(s.textStarted=true,t.enqueue({type:"text-start",id:"txt-0"})),o.length>0&&t.enqueue({type:"text-delta",id:"txt-0",delta:o}),t.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false;}s.isInThinkTag=true,s.contentBuffer=s.contentBuffer.substring(r+7),s.reasoningStarted||(s.reasoningStarted=true,t.enqueue({type:"reasoning-start",id:"reasoning-0"}));}return s}static finishThinkParsing(e,t){let s={...e};return s.contentBuffer.length>0?s.isInThinkTag?(s.contentBuffer.length>0&&t.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:s.contentBuffer}),s.reasoningStarted&&(t.enqueue({type:"reasoning-end",id:"reasoning-0"}),s.reasoningStarted=false)):(s.textStarted||(t.enqueue({type:"text-start",id:"txt-0"}),s.textStarted=true),s.contentBuffer.length>0&&t.enqueue({type:"text-delta",id:"txt-0",delta:s.contentBuffer}),t.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false):(s.textStarted&&(t.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false),s.reasoningStarted&&!s.isInThinkTag&&(t.enqueue({type:"reasoning-end",id:"reasoning-0"}),s.reasoningStarted=false)),s}static removeThinkTags(e){return e.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}};function Ya(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var Ft=class i{static extractToolCalls(e){let t=[],s=e,r=e.split(`
114
+ `),o=[];for(let a of r){let h=a.trim();if(!h){o.push(a);continue}try{let l=JSON.parse(h);if(l.name&&typeof l.name=="string"&&l.parameters&&typeof l.parameters=="object"){t.push({name:l.name,parameters:JSON.stringify(l.parameters)});continue}}catch{}o.push(a);}return s=o.join(`
115
+ `).trim(),{toolCalls:t,remainingText:s}}static processToolCalls(e,t,s){let r={...e},o=r.contentBuffer.split(`
116
+ `),a=[];for(let h=0;h<o.length;h++){let l=o[h];if(!l)continue;let d=l.trim();if(!d){a.push(l);continue}let g=false;try{let p=JSON.parse(d);if(p.name&&typeof p.name=="string"&&p.parameters&&typeof p.parameters=="object"){if(s&&s.length>0&&!s.some(S=>S.name===p.name)){a.push(l);continue}if(g=!0,a.length>0){let b=a.join(`
117
+ `);b.trim()&&(r.textStarted||(t.enqueue({type:"text-start",id:"txt-0"}),r.textStarted=!0),t.enqueue({type:"text-delta",id:"txt-0",delta:b+`
118
+ `})),a.length=0;}r.textStarted&&(t.enqueue({type:"text-end",id:"txt-0"}),r.textStarted=!1);let u=Ya(),m=JSON.stringify(p.parameters);t.enqueue({type:"tool-input-start",id:u,toolName:p.name}),t.enqueue({type:"tool-input-delta",id:u,delta:m}),t.enqueue({type:"tool-input-end",id:u}),t.enqueue({type:"tool-call",toolCallId:u,toolName:p.name,input:m}),r.completedToolCalls.push({id:u,name:p.name,parameters:m});}}catch{}g||a.push(l);}return r.contentBuffer=a.join(`
119
+ `),r}static finishToolParsing(e,t){let s={...e};return s.contentBuffer.trim().length>0?(s.textStarted||(t.enqueue({type:"text-start",id:"txt-0"}),s.textStarted=true),t.enqueue({type:"text-delta",id:"txt-0",delta:s.contentBuffer}),t.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false):s.textStarted&&(t.enqueue({type:"text-end",id:"txt-0"}),s.textStarted=false),s}static removeToolCalls(e){let{remainingText:t}=i.extractToolCalls(e);return t}};function jn(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var Bi=class{constructor(e,t,s){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"supportsToolCalling","experimental");c(this,"supportsThinking","experimental");c(this,"engine");c(this,"modelConfig");if(this.provider=e,this.modelId=t,this.engine=s,this.modelConfig=Ee[t],!this.modelConfig)throw new x(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${t}`,"MODEL_NOT_FOUND")}async generate(e){return this.doGenerate(e)}async stream(e){return this.doStream(e)}async doGenerate(e){fe.validateMessages(e.prompt);let t=e.tools?.filter(u=>"inputSchema"in u),s=$i.buildEnhancedPrompt(e.prompt,t),r={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};fe.validateGenerateOptions(r),this.engine.isReady()||await this.engine.initialize();let o=await this.engine.generate(s,r),a=_t.removeThinkTags(o.content||""),{toolCalls:h,remainingText:l}=Ft.extractToolCalls(a),d=[];l.trim().length>0&&d.push({type:"text",text:l});for(let u of h)d.push({type:"tool-call",toolCallId:jn(),toolName:u.name,input:u.parameters});let g=h.length>0?"tool-calls":o.finishReason,p=[];return {content:d,finishReason:g,usage:{inputTokens:{total:o.usage.promptTokens,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:o.usage.completionTokens,text:void 0,reasoning:void 0}},warnings:p,rawCall:{rawPrompt:s,rawSettings:r}}}async doStream(e){let t=jn();fe.validateMessages(e.prompt);let s=e.tools?.filter(m=>"inputSchema"in m),r=$i.buildEnhancedPrompt(e.prompt,s),o={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};fe.validateGenerateOptions(o),this.engine.isReady()||await this.engine.initialize();let a=null,h=null,l=m=>{a&&a.enqueue(m),h&&h.enqueue(m);},d=async()=>{try{let m={isInThinkTag:!1,reasoningStarted:!1,textStarted:!1,contentBuffer:""},b={contentBuffer:"",textStarted:!1,completedToolCalls:[]};l({type:"response-metadata",id:t,modelId:this.modelId,timestamp:new Date}),await this.engine.generateStream(r,o,S=>{if(S.type==="text-delta"){let T=S.delta||"";if(T.length===0)return;m.contentBuffer+=T;let v=_t.processThinkTags(m,{enqueue:l});m.isInThinkTag=v.isInThinkTag,m.reasoningStarted=v.reasoningStarted,m.textStarted=v.textStarted,b.contentBuffer+=v.contentBuffer,m.contentBuffer="";let M=Ft.processToolCalls(b,{enqueue:l},s);b.contentBuffer=M.contentBuffer,b.textStarted=M.textStarted,b.completedToolCalls=M.completedToolCalls;}else if(S.type==="text-end"){let T=_t.finishThinkParsing(m,{enqueue:l});m.textStarted=T.textStarted,m.reasoningStarted=T.reasoningStarted;let v=Ft.finishToolParsing(b,{enqueue:l});b.textStarted=v.textStarted;}else if(S.type==="finish"){let T=_t.finishThinkParsing(m,{enqueue:l});m.textStarted=T.textStarted,m.reasoningStarted=T.reasoningStarted;let v=Ft.finishToolParsing(b,{enqueue:l});b.textStarted=v.textStarted;let M=b.completedToolCalls.length>0;l({type:"finish",finishReason:M?"tool-calls":S.finishReason,usage:S.usage?{inputTokens:{total:S.usage.promptTokens||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:S.usage.completionTokens||0,text:void 0,reasoning:void 0}}:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}});}});}catch(m){l({type:"error",error:m instanceof Error?m.message:String(m)}),l({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(),h&&h.close();}},g=new ReadableStream({start(m){a=m;}}),p=new ReadableStream({start(m){h=m;}});d();async function*u(m){let b=m.getReader();try{for(;;){let{done:S,value:T}=await b.read();if(S)break;yield T;}}finally{b.releaseLock();}}return {stream:g,fullStream:u(p),request:{body:r},response:{headers:{}}}}};var ys=class{constructor(e){c(this,"config");this.config=e;}createBatches(e){let t=[],s=this.config.batchSize;for(let r=0;r<e.length;r+=s)t.push(e.slice(r,r+s));return t}async processBatches(e,t,s){if(s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");let r=this.createBatches(e),o=[];for(let a=0;a<r.length;a++){if(s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");let h=r[a];if(h){try{let l=await t(h);o.push(...l);}catch(l){throw l instanceof x&&l.code==="ABORTED"?l:new x(`\u6279\u6B21 ${a+1}/${r.length} \u5904\u7406\u5931\u8D25: ${l instanceof Error?l.message:String(l)}`,"PROCESSING_ERROR",l instanceof Error?l:void 0)}a<r.length-1&&this.config.delayBetweenBatches&&this.config.delayBetweenBatches>0&&await this.delay(this.config.delayBetweenBatches,s);}}return o}async delay(e,t){return new Promise((s,r)=>{if(t?.aborted){r(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));return}let o=setTimeout(()=>{t?.removeEventListener("abort",a),s();},e),a=()=>{clearTimeout(o),r(new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));};t?.addEventListener("abort",a);})}};var zi=class{constructor(e,t,s){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"maxEmbeddingsPerCall");c(this,"supportsParallelCalls",false);c(this,"engine");c(this,"modelConfig");if(this.provider=e,this.modelId=t,this.engine=s,this.modelConfig=bt[t],!this.modelConfig)throw new x(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${t}`,"MODEL_NOT_FOUND");this.maxEmbeddingsPerCall=this.modelConfig.maxEmbeddingsPerCall;}async doEmbed(e){let{values:t,abortSignal:s}=e;if(fe.validateTexts(t),s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");this.engine.isReady()||await this.engine.initialize();let o=await new ys({batchSize:this.maxEmbeddingsPerCall,delayBetweenBatches:0}).processBatches(t,async h=>{if(s?.aborted)throw new x("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");return await this.engine.embed(h,s)},s),a=await this.engine.countTokens(t);return {embeddings:o,usage:{tokens:a},warnings:[]}}};var ji=class{constructor(e,t,s,r={}){c(this,"specificationVersion","v3");c(this,"provider","local");c(this,"modelId");c(this,"languageModel");c(this,"options");c(this,"log",Le.create({service:"local-model-sdk",module:"reranking-model"}));this.modelId=e,this.languageModel=new Nt("local",e,s),this.options={llm:this.languageModel,totalScore:r.totalScore??1,useEnhancedPrompt:r.useEnhancedPrompt??false,promptLanguage:r.promptLanguage??"en"},this.log.debug("LocalRerankingModel created",{modelId:e,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(e){let{query:t,documents:s,topN:r}=e,o;Array.isArray(s)?o=s:s.type==="text"?o=s.values.map((l,d)=>({content:l,id:`doc_${d+1}`})):o=s.values;let a=r??o.length;if(o.length===0)return {ranking:[],warnings:[]};try{let l=this.buildRerankPrompt(t,o),g=(await this.languageModel.doGenerate({prompt:[{role:"user",content:[{type:"text",text:l}]}],maxOutputTokens:500,temperature:.1})).content.find(u=>u.type==="text")?.text||"",p=this.parseRerankResult(g,o,a);return {ranking:p.results.map(u=>({index:u.index,relevanceScore:u.score,document:u.document})),warnings:p.warnings.map(u=>({type:"other",message:u})),response:{timestamp:new Date,modelId:this.modelId}}}catch(l){return this.log.error("Reranking failed",{error:l.message}),{ranking:o.map((g,p)=>({index:p,relevanceScore:this.options.totalScore*(1-p/o.length),document:g})),warnings:[{type:"other",message:`Reranking failed, using original order: ${l.message}`}],response:{timestamp:new Date,modelId:this.modelId}}}}buildRerankPrompt(e,t){let s=t.map((r,o)=>{let a=r.id||`doc_${o+1}`,h=r.content.slice(0,300);return `${o+1}. [ID: ${a}] ${h}`}).join(`
120
+
121
+ `);if(this.options.useEnhancedPrompt)if(this.options.promptLanguage==="en"){this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `You are a professional information retrieval reranking expert. Please rank the following documents according to the query.
122
+
123
+ User query: ${e}
124
+
125
+ Documents to rank:
126
+ ${s}
127
+
128
+ Please rank the documents according to the following requirements:
129
+ 1. Carefully analyze the user's query intent and key information needs
130
+ 2. Evaluate each document's relevance to the query
131
+ 3. Consider the document's completeness, accuracy, and usefulness
132
+ 4. Return to ranked document numbers separated by commas
133
+ 5. Most relevant documents should be at the front
134
+
135
+ Use a scoring scale from ${this.options.totalScore*.1} to ${this.options.totalScore} where ${this.options.totalScore*.1} is most relevant and ${this.options.totalScore} is least relevant.
136
+ The actual score for each position should be calculated dynamically. For example:
137
+ - If totalScore is 10: scores might be: 9, 7, 10, 4, 2
138
+ - If totalScore is 1: scores might be: 0.2, 0.5, 1.0, 0.06, 0.04
139
+ - If totalScore is 5: scores might be: 0.1, 0.25, 0.5, 0.03, 0.02
140
+
141
+ Example output format: 2,5,1,4,3
142
+
143
+ Please only output the ranked document numbers separated by commas, do not include the actual scores.`}else {let r=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
144
+
145
+ \u7528\u6237\u67E5\u8BE2\uFF1A${e}
146
+
147
+ \u5F85\u6392\u5E8F\u6587\u6863\uFF1A
148
+ ${s}
149
+
150
+ \u8BF7\u6309\u7167\u4EE5\u4E0B\u8981\u6C42\u8FDB\u884C\u6392\u5E8F\uFF1A
151
+ 1. \u4ED4\u7EC6\u5206\u6790\u7528\u6237\u67E5\u8BE2\u7684\u610F\u56FE\u548C\u5173\u952E\u4FE1\u606F\u9700\u6C42
152
+ 2. \u8BC4\u4F30\u6BCF\u4E2A\u6587\u6863\u4E0E\u67E5\u8BE2\u7684\u76F8\u5173\u6027
153
+ 3. \u8003\u8651\u6587\u6863\u7684\u5B8C\u6574\u6027\u3001\u51C6\u786E\u6027\u548C\u5B9E\u7528\u6027
154
+ 4. \u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u6587\u6863\u7F16\u53F7\uFF0C\u7528\u9017\u53F7\u5206\u9694
155
+ 5. \u6700\u76F8\u5173\u7684\u6587\u6863\u6392\u5728\u6700\u524D\u9762
156
+ 6. \u8BF7\u4F7F\u7528 ${r} \u5206\u503C\u8FDB\u884C\u8BC4\u5206
157
+
158
+ \u793A\u4F8B\u8F93\u51FA\u683C\u5F0F\uFF1A2,5,1,4,3
159
+
160
+ \u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}else return `\u6839\u636E\u67E5\u8BE2 "${e}" \u5BF9\u4EE5\u4E0B\u7ED3\u679C\u76F8\u5173\u6027\u8FDB\u884C\u6392\u5E8F\uFF0C\u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF08\u7528\u9017\u53F7\u5206\u9694\uFF09\uFF1A
161
+
162
+ ${s}
163
+
164
+ \u8F93\u51FA\u683C\u5F0F\uFF1A1,2,3,4,5\uFF08\u6700\u76F8\u5173\u7684\u6392\u5728\u524D\u9762\uFF09`}parseRerankResult(e,t,s){let r=[];try{let o=e.match(/\d+/g)?.map(u=>parseInt(u,10)-1).filter(u=>u>=0&&u<t.length)||[],a=[],h=new Set;for(let u of o)h.has(u)||(h.add(u),a.push(u));let l=[],d=new Set;for(let u of a)if(u!==void 0&&u>=0&&u<t.length&&!d.has(u)){d.add(u);let m=t[u];m&&l.push({index:u,score:this.options.totalScore*(1-l.length/a.length),document:m});}let g=new Set(a);for(let u=0;u<t.length;u++)if(!g.has(u)){let m=this.options.totalScore*.1*(1-u/t.length);l.push({index:u,score:m,document:t[u]});}let p=s?l.slice(0,s):l;return this.log.debug("Parsed rerank results",{extractedNumbers:o,uniqueIndices:a,resultCount:p.length,topK:s}),{results:p,warnings:r}}catch(o){return this.log.error("Failed to parse rerank result",{error:o.message,text:e}),{results:t.map((h,l)=>({index:l,score:this.options.totalScore*(1-l/t.length),document:h})),warnings:[`Failed to parse rerank result: ${o.message}`]}}}};var Wi=class{constructor(e,t,s={}){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"languageModel");c(this,"options");c(this,"log",Le.create({service:"local-model-sdk",module:"llm-reranking-model"}));this.modelId=e,this.languageModel=t,this.provider=t.provider||"external",this.options={llm:t,totalScore:s.totalScore??1,useEnhancedPrompt:s.useEnhancedPrompt??false,promptLanguage:s.promptLanguage??"en",modelOptions:s.modelOptions??{temperature:.1,maxTokens:3e4}},this.log.debug("LLMRerankingModel created",{modelId:e,provider:this.provider,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(e){let{query:t,documents:s,topN:r,abortSignal:o}=e,a;Array.isArray(s)?a=s:s.type==="text"?a=s.values.map((d,g)=>({content:d,id:`doc_${g+1}`})):a=s.values;let h=r??a.length;if(a.length===0)return {ranking:[],warnings:[]};try{let g={prompt:[{role:"user",content:[{type:"text",text:this.buildRerankPrompt(t,a)}]}],maxOutputTokens:this.options.modelOptions.maxTokens,temperature:this.options.modelOptions.temperature,abortSignal:o},p=await this.languageModel.doGenerate(g),u=this.extractTextContent(p),m=this.parseRerankResult(u,a,h);return {ranking:m.results.map(b=>({index:b.index,relevanceScore:b.score})),warnings:m.warnings.map(b=>({type:"other",message:b})),response:{timestamp:new Date,modelId:this.modelId}}}catch(d){return this.log.error("Reranking failed",{error:d.message}),{ranking:a.map((p,u)=>({index:u,relevanceScore:this.options.totalScore*(1-u/a.length)})),warnings:[{type:"other",message:`Reranking failed, using original order: ${d.message}`}],response:{timestamp:new Date,modelId:this.modelId}}}}extractTextContent(e){if(typeof e=="string")return e;if(e.content&&Array.isArray(e.content)){let t=e.content.find(s=>s.type==="text");if(t?.text)return t.text}return String(e)}buildRerankPrompt(e,t){let s=t.map((r,o)=>{let a=r.id||`doc_${o+1}`,h=r.content.slice(0,300);return `${o+1}. [ID: ${a}] ${h}`}).join(`
165
+
166
+ `);if(this.options.useEnhancedPrompt)if(this.options.promptLanguage==="en"){this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `You are a professional information retrieval reranking expert. Please rank the following documents according to the query.
167
+
168
+ User query: ${e}
169
+
170
+ Documents to rank:
171
+ ${s}
172
+
173
+ Please rank the documents according to the following requirements:
174
+ 1. Carefully analyze the user's query intent and key information needs
175
+ 2. Evaluate each document's relevance to the query
176
+ 3. Consider the document's completeness, accuracy, and usefulness
177
+ 4. Return to ranked document numbers separated by commas
178
+ 5. Most relevant documents should be at the front
179
+
180
+ Use a scoring scale from ${this.options.totalScore*.1} to ${this.options.totalScore} where ${this.options.totalScore*.1} is most relevant and ${this.options.totalScore} is least relevant.
181
+ The actual score for each position should be calculated dynamically. For example:
182
+ - If totalScore is 10: scores might be: 9, 7, 10, 4, 2
183
+ - If totalScore is 1: scores might be: 0.2, 0.5, 1.0, 0.06, 0.04
184
+ - If totalScore is 5: scores might be: 0.1, 0.25, 0.5, 0.03, 0.02
185
+
186
+ Example output format: 2,5,1,4,3
187
+
188
+ Please only output the ranked document numbers separated by commas, do not include the actual scores.`}else {let r=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
189
+
190
+ \u7528\u6237\u67E5\u8BE2\uFF1A${e}
191
+
192
+ \u5F85\u6392\u5E8F\u6587\u6863\uFF1A
193
+ ${s}
194
+
195
+ \u8BF7\u6309\u7167\u4EE5\u4E0B\u8981\u6C42\u8FDB\u884C\u6392\u5E8F\uFF1A
196
+ 1. \u4ED4\u7EC6\u5206\u6790\u7528\u6237\u67E5\u8BE2\u7684\u610F\u56FE\u548C\u5173\u952E\u4FE1\u606F\u9700\u6C42
197
+ 2. \u8BC4\u4F30\u6BCF\u4E2A\u6587\u6863\u4E0E\u67E5\u8BE2\u7684\u76F8\u5173\u6027
198
+ 3. \u8003\u8651\u6587\u6863\u7684\u5B8C\u6574\u6027\u3001\u51C6\u786E\u6027\u548C\u5B9E\u7528\u6027
199
+ 4. \u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u6587\u6863\u7F16\u53F7\uFF0C\u7528\u9017\u53F7\u5206\u9694
200
+ 5. \u6700\u76F8\u5173\u7684\u6587\u6863\u6392\u5728\u6700\u524D\u9762
201
+ 6. \u8BF7\u4F7F\u7528 ${r} \u5206\u503C\u8FDB\u884C\u8BC4\u5206
202
+
203
+ \u793A\u4F8B\u8F93\u51FA\u683C\u5F0F\uFF1A2,5,1,4,3
204
+
205
+ \u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}else return `\u6839\u636E\u67E5\u8BE2 "${e}" \u5BF9\u4EE5\u4E0B\u7ED3\u679C\u76F8\u5173\u6027\u8FDB\u884C\u6392\u5E8F\uFF0C\u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF08\u7528\u9017\u53F7\u5206\u9694\uFF09\uFF1A
206
+
207
+ ${s}
208
+
209
+ \u8F93\u51FA\u683C\u5F0F\uFF1A1,2,3,4,5\uFF08\u6700\u76F8\u5173\u7684\u6392\u5728\u524D\u9762\uFF09`}parseRerankResult(e,t,s){let r=[];try{let o=e.match(/\d+/g)?.map(u=>parseInt(u,10)-1).filter(u=>u>=0&&u<t.length)||[],a=[],h=new Set;for(let u of o)h.has(u)||(h.add(u),a.push(u));let l=[],d=new Set;for(let u of a)u!==void 0&&u>=0&&u<t.length&&!d.has(u)&&(d.add(u),l.push({index:u,score:this.options.totalScore*(1-l.length/a.length)}));let g=new Set(a);for(let u=0;u<t.length;u++)if(!g.has(u)){let m=this.options.totalScore*.1*(1-u/t.length);l.push({index:u,score:m});}let p=s?l.slice(0,s):l;return this.log.debug("Parsed rerank results",{extractedNumbers:o,uniqueIndices:a,resultCount:p.length,topK:s}),{results:p,warnings:r}}catch(o){return this.log.error("Failed to parse rerank result",{error:o.message,text:e}),{results:t.map((h,l)=>({index:l,score:this.options.totalScore*(1-l/t.length)})),warnings:[`Failed to parse rerank result: ${o.message}`]}}}};var st=Le.create({service:"local-model-provider"}),Zs={cacheDir:ti__namespace.default.join(er__namespace.homedir(),".cache","easbot","models"),verbose:false,autoUnloadTimeout:300*1e3,maxCachedModels:3,memoryWarningThreshold:1.5*1024*1024*1024,useEnhancedModel:true,logDir:"",logLevel:"INFO"},ws=class{constructor(e){c(this,"config");c(this,"modelCache");c(this,"engines",new Map);c(this,"modelInfo",new Map);this.config={...Zs,...e},this.modelCache=new Ut({cacheDir:this.config.cacheDir});}languageModel(e,t){if(!Ee[e])throw new x(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${e}`,"MODEL_NOT_FOUND");let s=this.getOrCreateEngine(e,"language");return t?.useEnhancedModel??this.config.useEnhancedModel?(this.config.verbose&&st.debug("\u521B\u5EFA\u589E\u5F3A\u8BED\u8A00\u6A21\u578B",{modelId:e}),new Bi("local",e,s)):(this.config.verbose&&st.debug("\u521B\u5EFA\u57FA\u7840\u8BED\u8A00\u6A21\u578B",{modelId:e}),new Nt("local",e,s))}embeddingModel(e){if(!bt[e])throw new x(`\u4E0D\u652F\u6301\u7684 Embedding Model ID: ${e}`,"MODEL_NOT_FOUND");let t=this.getOrCreateEngine(e,"embedding");return new zi("local",e,t)}chat(e,t){return this.languageModel(e,t)}rerankingModel(e,t){if(this.config.verbose&&st.debug("\u521B\u5EFA\u91CD\u6392\u5E8F\u6A21\u578B",{modelId:e,hasExternalLlm:!!t?.llm}),t?.llm)return new Wi(e,t.llm,t);if(!Ee[e])throw new x(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${e}`,"MODEL_NOT_FOUND");let s=this.getOrCreateEngine(e,"language");return new ji(e,this.config,s,t)}getOrCreateEngine(e,t){let s=`${t}:${e}`;if(this.engines.has(s)){let o=this.modelInfo.get(s);return o&&(o.lastUsed=Date.now(),o.useCount++),this.config.verbose&&st.debug("\u590D\u7528\u5DF2\u52A0\u8F7D\u7684\u6A21\u578B",{engineKey:s}),this.engines.get(s)}this.engines.size>=this.config.maxCachedModels&&this.evictLeastRecentlyUsed(),this.config.verbose&&st.debug("\u521B\u5EFA\u65B0\u5F15\u64CE",{engineKey:s});let r=new gs({modelId:e,modelType:t,cacheDir:this.config.cacheDir,verbose:this.config.verbose});return this.engines.set(s,r),this.modelInfo.set(s,{modelId:e,modelType:t,isLoaded:false,lastUsed:Date.now(),useCount:1}),r}evictLeastRecentlyUsed(){let e=null,t=Number.POSITIVE_INFINITY;for(let[s,r]of this.modelInfo.entries())r.lastUsed<t&&(t=r.lastUsed,e=s);if(e){this.config.verbose&&st.debug("\u6DD8\u6C70\u6A21\u578B",{engineKey:e});let s=this.engines.get(e);s&&s.dispose().catch(r=>{st.error("\u5378\u8F7D\u6A21\u578B\u5931\u8D25",{error:r});}),this.engines.delete(e),this.modelInfo.delete(e);}}getLoadedModels(){return Array.from(this.modelInfo.values())}async dispose(){this.config.verbose&&st.debug("\u5378\u8F7D\u6240\u6709\u6A21\u578B");let e=Array.from(this.engines.values()).map(t=>t.dispose());await Promise.all(e),this.engines.clear(),this.modelInfo.clear(),this.config.verbose&&st.debug("\u6240\u6709\u6A21\u578B\u5DF2\u5378\u8F7D");}};function Za(i){let e=new ws(i);if(i?.logDir){let s=i.logLevel??"INFO",r=ti__namespace.default.join(i.logDir,"local-model-sdk.log");Le.init({print:process.argv.includes("--print-logs"),logDir:i.logDir,level:s,logFile:"local-model-sdk.log"}).then(()=>{Le.create({service:"local-model-sdk",module:"provider"}).debug("Local model provider created",{cacheDir:i?.cacheDir||Zs.cacheDir,useEnhancedModel:i?.useEnhancedModel??Zs.useEnhancedModel,logFile:r,logLevel:s});});}return Object.assign((s,r)=>e.languageModel(s,r),{languageModel:(s,r)=>e.languageModel(s,r),chat:(s,r)=>e.chat(s,r),embeddingModel:s=>e.embeddingModel(s),rerankingModel:(s,r)=>e.rerankingModel(s,r)})}var Xa="0.1.0",Qa="@easbot/local-model-sdk",el="Complete local model SDK for EASBot - Transformers.js + ONNX implementation";exports.ErrorCode=ge;exports.ErrorHandler=ne;exports.LLMRerankingModel=Wi;exports.LocalEmbeddingModel=zi;exports.LocalEnhancedLanguageModel=Bi;exports.LocalLanguageModel=Nt;exports.LocalModelError=x;exports.LocalModelProvider=ws;exports.LocalRerankingModel=ji;exports.SDK_DESCRIPTION=el;exports.SDK_NAME=Qa;exports.SUPPORTED_EMBEDDING_MODELS=bt;exports.SUPPORTED_LANGUAGE_MODELS=Ee;exports.VERSION=Xa;exports.createLocal=Za;