yinzerflow 0.5.3 → 0.5.4
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/index.js +19 -177
- package/index.js.map +3 -55
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,190 +1,32 @@
|
|
|
1
|
-
import{createRequire as nw}from"node:module";var iw=Object.create;var{getPrototypeOf:aw,defineProperty:S$,getOwnPropertyNames:sw}=Object;var rw=Object.prototype.hasOwnProperty;var U0=(S,$,w)=>{w=S!=null?iw(aw(S)):{};let Z=$||!S||!S.__esModule?S$(w,"default",{value:S,enumerable:!0}):w;for(let Y of sw(S))if(!rw.call(Z,Y))S$(Z,Y,{get:()=>S[Y],enumerable:!0});return Z};var F=(S,$)=>()=>($||S(($={exports:{}}).exports,$),$.exports);var j=nw(import.meta.url);var M0=F((g0,u0)=>{(function(S,$){typeof g0=="object"&&typeof u0<"u"?u0.exports=$():typeof define=="function"&&define.amd?define($):(S=typeof globalThis<"u"?globalThis:S||self).dayjs=$()})(g0,function(){var S=1000,$=60000,w=3600000,Z="millisecond",Y="second",y="minute",W="hour",J="day",X="week",U="month",Q="quarter",M="year",G="date",O="Invalid Date",W1=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,u={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(H){var k=["th","st","nd","rd"],q=H%100;return"["+H+(k[(q-20)%10]||k[q]||k[0])+"]"}},n=function(H,k,q){var z=String(H);return!z||z.length>=k?H:""+Array(k+1-z.length).join(q)+H},T1={s:n,z:function(H){var k=-H.utcOffset(),q=Math.abs(k),z=Math.floor(q/60),V=q%60;return(k<=0?"+":"-")+n(z,2,"0")+":"+n(V,2,"0")},m:function H(k,q){if(k.date()<q.date())return-H(q,k);var z=12*(q.year()-k.year())+(q.month()-k.month()),V=k.clone().add(z,U),E=q-V<0,K=k.clone().add(z+(E?-1:1),U);return+(-(z+(q-V)/(E?V-K:K-V))||0)},a:function(H){return H<0?Math.ceil(H)||0:Math.floor(H)},p:function(H){return{M:U,y:M,w:X,d:J,D:G,h:W,m:y,s:Y,ms:Z,Q}[H]||String(H||"").toLowerCase().replace(/s$/,"")},u:function(H){return H===void 0}},z1="en",t={};t[z1]=u;var p0="$isDayjsObject",B1=function(H){return H instanceof X0||!(!H||!H[p0])},P1=function H(k,q,z){var V;if(!k)return z1;if(typeof k=="string"){var E=k.toLowerCase();t[E]&&(V=E),q&&(t[E]=q,V=E);var K=k.split("-");if(!V&&K.length>1)return H(K[0])}else{var I=k.name;t[I]=k,V=I}return!z&&V&&(z1=V),V||!z&&z1},P=function(H,k){if(B1(H))return H.clone();var q=typeof k=="object"?k:{};return q.date=H,q.args=arguments,new X0(q)},L=T1;L.l=P1,L.i=B1,L.w=function(H,k){return P(H,{locale:k.$L,utc:k.$u,x:k.$x,$offset:k.$offset})};var X0=function(){function H(q){this.$L=P1(q.locale,null,!0),this.parse(q),this.$x=this.$x||q.x||{},this[p0]=!0}var k=H.prototype;return k.parse=function(q){this.$d=function(z){var{date:V,utc:E}=z;if(V===null)return new Date(NaN);if(L.u(V))return new Date;if(V instanceof Date)return new Date(V);if(typeof V=="string"&&!/Z$/i.test(V)){var K=V.match(W1);if(K){var I=K[2]-1||0,R=(K[7]||"0").substring(0,3);return E?new Date(Date.UTC(K[1],I,K[3]||1,K[4]||0,K[5]||0,K[6]||0,R)):new Date(K[1],I,K[3]||1,K[4]||0,K[5]||0,K[6]||0,R)}}return new Date(V)}(q),this.init()},k.init=function(){var q=this.$d;this.$y=q.getFullYear(),this.$M=q.getMonth(),this.$D=q.getDate(),this.$W=q.getDay(),this.$H=q.getHours(),this.$m=q.getMinutes(),this.$s=q.getSeconds(),this.$ms=q.getMilliseconds()},k.$utils=function(){return L},k.isValid=function(){return this.$d.toString()!==O},k.isSame=function(q,z){var V=P(q);return this.startOf(z)<=V&&V<=this.endOf(z)},k.isAfter=function(q,z){return P(q)<this.startOf(z)},k.isBefore=function(q,z){return this.endOf(z)<P(q)},k.$g=function(q,z,V){return L.u(q)?this[z]:this.set(V,q)},k.unix=function(){return Math.floor(this.valueOf()/1000)},k.valueOf=function(){return this.$d.getTime()},k.startOf=function(q,z){var V=this,E=!!L.u(z)||z,K=L.p(q),I=function(E1,m){var J1=L.w(V.$u?Date.UTC(V.$y,m,E1):new Date(V.$y,m,E1),V);return E?J1:J1.endOf(J)},R=function(E1,m){return L.w(V.toDate()[E1].apply(V.toDate("s"),(E?[0,0,0,0]:[23,59,59,999]).slice(m)),V)},_=this.$W,h=this.$M,i=this.$D,R1="set"+(this.$u?"UTC":"");switch(K){case M:return E?I(1,0):I(31,11);case U:return E?I(1,h):I(0,h+1);case X:var H1=this.$locale().weekStart||0,g1=(_<H1?_+7:_)-H1;return I(E?i-g1:i+(6-g1),h);case J:case G:return R(R1+"Hours",0);case W:return R(R1+"Minutes",1);case y:return R(R1+"Seconds",2);case Y:return R(R1+"Milliseconds",3);default:return this.clone()}},k.endOf=function(q){return this.startOf(q,!1)},k.$set=function(q,z){var V,E=L.p(q),K="set"+(this.$u?"UTC":""),I=(V={},V[J]=K+"Date",V[G]=K+"Date",V[U]=K+"Month",V[M]=K+"FullYear",V[W]=K+"Hours",V[y]=K+"Minutes",V[Y]=K+"Seconds",V[Z]=K+"Milliseconds",V)[E],R=E===J?this.$D+(z-this.$W):z;if(E===U||E===M){var _=this.clone().set(G,1);_.$d[I](R),_.init(),this.$d=_.set(G,Math.min(this.$D,_.daysInMonth())).$d}else I&&this.$d[I](R);return this.init(),this},k.set=function(q,z){return this.clone().$set(q,z)},k.get=function(q){return this[L.p(q)]()},k.add=function(q,z){var V,E=this;q=Number(q);var K=L.p(z),I=function(h){var i=P(E);return L.w(i.date(i.date()+Math.round(h*q)),E)};if(K===U)return this.set(U,this.$M+q);if(K===M)return this.set(M,this.$y+q);if(K===J)return I(1);if(K===X)return I(7);var R=(V={},V[y]=$,V[W]=w,V[Y]=S,V)[K]||1,_=this.$d.getTime()+q*R;return L.w(_,this)},k.subtract=function(q,z){return this.add(-1*q,z)},k.format=function(q){var z=this,V=this.$locale();if(!this.isValid())return V.invalidDate||O;var E=q||"YYYY-MM-DDTHH:mm:ssZ",K=L.z(this),I=this.$H,R=this.$m,_=this.$M,h=V.weekdays,i=V.months,R1=V.meridiem,H1=function(m,J1,u1,Q0){return m&&(m[J1]||m(z,E))||u1[J1].slice(0,Q0)},g1=function(m){return L.s(I%12||12,m,"0")},E1=R1||function(m,J1,u1){var Q0=m<12?"AM":"PM";return u1?Q0.toLowerCase():Q0};return E.replace(b,function(m,J1){return J1||function(u1){switch(u1){case"YY":return String(z.$y).slice(-2);case"YYYY":return L.s(z.$y,4,"0");case"M":return _+1;case"MM":return L.s(_+1,2,"0");case"MMM":return H1(V.monthsShort,_,i,3);case"MMMM":return H1(i,_);case"D":return z.$D;case"DD":return L.s(z.$D,2,"0");case"d":return String(z.$W);case"dd":return H1(V.weekdaysMin,z.$W,h,2);case"ddd":return H1(V.weekdaysShort,z.$W,h,3);case"dddd":return h[z.$W];case"H":return String(I);case"HH":return L.s(I,2,"0");case"h":return g1(1);case"hh":return g1(2);case"a":return E1(I,R,!0);case"A":return E1(I,R,!1);case"m":return String(R);case"mm":return L.s(R,2,"0");case"s":return String(z.$s);case"ss":return L.s(z.$s,2,"0");case"SSS":return L.s(z.$ms,3,"0");case"Z":return K}return null}(m)||K.replace(":","")})},k.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},k.diff=function(q,z,V){var E,K=this,I=L.p(z),R=P(q),_=(R.utcOffset()-this.utcOffset())*$,h=this-R,i=function(){return L.m(K,R)};switch(I){case M:E=i()/12;break;case U:E=i();break;case Q:E=i()/3;break;case X:E=(h-_)/604800000;break;case J:E=(h-_)/86400000;break;case W:E=h/w;break;case y:E=h/$;break;case Y:E=h/S;break;default:E=h}return V?E:L.a(E)},k.daysInMonth=function(){return this.endOf(U).$D},k.$locale=function(){return t[this.$L]},k.locale=function(q,z){if(!q)return this.$L;var V=this.clone(),E=P1(q,z,!0);return E&&(V.$L=E),V},k.clone=function(){return L.w(this.$d,this)},k.toDate=function(){return new Date(this.valueOf())},k.toJSON=function(){return this.isValid()?this.toISOString():null},k.toISOString=function(){return this.$d.toISOString()},k.toString=function(){return this.$d.toUTCString()},H}(),eS=X0.prototype;return P.prototype=eS,[["$ms",Z],["$s",Y],["$m",y],["$H",W],["$W",J],["$M",U],["$y",M],["$D",G]].forEach(function(H){eS[H[1]]=function(k){return this.$g(k,H[0],H[1])}}),P.extend=function(H,k){return H.$i||(H(k,X0,P),H.$i=!0),P},P.locale=P1,P.isDayjs=B1,P.unix=function(H){return P(1000*H)},P.en=t[z1],P.Ls=t,P.p={},P})});var _$=F((q9,X6)=>{X6.exports={acl:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},append:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},asking:{arity:1,flags:["fast"],keyStart:0,keyStop:0,step:0},auth:{arity:-2,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},bgrewriteaof:{arity:1,flags:["admin","noscript","no_async_loading"],keyStart:0,keyStop:0,step:0},bgsave:{arity:-1,flags:["admin","noscript","no_async_loading"],keyStart:0,keyStop:0,step:0},bitcount:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},bitfield:{arity:-2,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},bitfield_ro:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},bitop:{arity:-4,flags:["write","denyoom"],keyStart:2,keyStop:-1,step:1},bitpos:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},blmove:{arity:6,flags:["write","denyoom","noscript","blocking"],keyStart:1,keyStop:2,step:1},blmpop:{arity:-5,flags:["write","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},blpop:{arity:-3,flags:["write","noscript","blocking"],keyStart:1,keyStop:-2,step:1},brpop:{arity:-3,flags:["write","noscript","blocking"],keyStart:1,keyStop:-2,step:1},brpoplpush:{arity:4,flags:["write","denyoom","noscript","blocking"],keyStart:1,keyStop:2,step:1},bzmpop:{arity:-5,flags:["write","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},bzpopmax:{arity:-3,flags:["write","noscript","blocking","fast"],keyStart:1,keyStop:-2,step:1},bzpopmin:{arity:-3,flags:["write","noscript","blocking","fast"],keyStart:1,keyStop:-2,step:1},client:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},cluster:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},command:{arity:-1,flags:["loading","stale"],keyStart:0,keyStop:0,step:0},config:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},copy:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},dbsize:{arity:1,flags:["readonly","fast"],keyStart:0,keyStop:0,step:0},debug:{arity:-2,flags:["admin","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},decr:{arity:2,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},decrby:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},del:{arity:-2,flags:["write"],keyStart:1,keyStop:-1,step:1},discard:{arity:1,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:0,keyStop:0,step:0},dump:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},echo:{arity:2,flags:["fast"],keyStart:0,keyStop:0,step:0},eval:{arity:-3,flags:["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},eval_ro:{arity:-3,flags:["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},evalsha:{arity:-3,flags:["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},evalsha_ro:{arity:-3,flags:["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},exec:{arity:1,flags:["noscript","loading","stale","skip_slowlog"],keyStart:0,keyStop:0,step:0},exists:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:-1,step:1},expire:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},expireat:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},expiretime:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},failover:{arity:-1,flags:["admin","noscript","stale"],keyStart:0,keyStop:0,step:0},fcall:{arity:-3,flags:["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},fcall_ro:{arity:-3,flags:["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},flushall:{arity:-1,flags:["write"],keyStart:0,keyStop:0,step:0},flushdb:{arity:-1,flags:["write"],keyStart:0,keyStop:0,step:0},function:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},geoadd:{arity:-5,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},geodist:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},geohash:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},geopos:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},georadius:{arity:-6,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},georadius_ro:{arity:-6,flags:["readonly"],keyStart:1,keyStop:1,step:1},georadiusbymember:{arity:-5,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},georadiusbymember_ro:{arity:-5,flags:["readonly"],keyStart:1,keyStop:1,step:1},geosearch:{arity:-7,flags:["readonly"],keyStart:1,keyStop:1,step:1},geosearchstore:{arity:-8,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},get:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},getbit:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},getdel:{arity:2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},getex:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},getrange:{arity:4,flags:["readonly"],keyStart:1,keyStop:1,step:1},getset:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hdel:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hello:{arity:-1,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},hexists:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hexpire:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpire:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hget:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hgetall:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},hincrby:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hincrbyfloat:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hkeys:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},hlen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hmget:{arity:-3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hmset:{arity:-4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hrandfield:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},hscan:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},hset:{arity:-4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hsetnx:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hstrlen:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hvals:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},incr:{arity:2,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},incrby:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},incrbyfloat:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},info:{arity:-1,flags:["loading","stale"],keyStart:0,keyStop:0,step:0},keys:{arity:2,flags:["readonly"],keyStart:0,keyStop:0,step:0},lastsave:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},latency:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},lcs:{arity:-3,flags:["readonly"],keyStart:1,keyStop:2,step:1},lindex:{arity:3,flags:["readonly"],keyStart:1,keyStop:1,step:1},linsert:{arity:5,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},llen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},lmove:{arity:5,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},lmpop:{arity:-4,flags:["write","movablekeys"],keyStart:0,keyStop:0,step:0},lolwut:{arity:-1,flags:["readonly","fast"],keyStart:0,keyStop:0,step:0},lpop:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},lpos:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},lpush:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},lpushx:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},lrange:{arity:4,flags:["readonly"],keyStart:1,keyStop:1,step:1},lrem:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},lset:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},ltrim:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},memory:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},mget:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:-1,step:1},migrate:{arity:-6,flags:["write","movablekeys"],keyStart:3,keyStop:3,step:1},module:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},monitor:{arity:1,flags:["admin","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},move:{arity:3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},mset:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:2},msetnx:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:2},multi:{arity:1,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:0,keyStop:0,step:0},object:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},persist:{arity:2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},pexpire:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},pexpireat:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},pexpiretime:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},pfadd:{arity:-2,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},pfcount:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},pfdebug:{arity:3,flags:["write","denyoom","admin"],keyStart:2,keyStop:2,step:1},pfmerge:{arity:-2,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},pfselftest:{arity:1,flags:["admin"],keyStart:0,keyStop:0,step:0},ping:{arity:-1,flags:["fast"],keyStart:0,keyStop:0,step:0},psetex:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},psubscribe:{arity:-2,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},psync:{arity:-3,flags:["admin","noscript","no_async_loading","no_multi"],keyStart:0,keyStop:0,step:0},pttl:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},publish:{arity:3,flags:["pubsub","loading","stale","fast"],keyStart:0,keyStop:0,step:0},pubsub:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},punsubscribe:{arity:-1,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},quit:{arity:-1,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},randomkey:{arity:1,flags:["readonly"],keyStart:0,keyStop:0,step:0},readonly:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},readwrite:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},rename:{arity:3,flags:["write"],keyStart:1,keyStop:2,step:1},renamenx:{arity:3,flags:["write","fast"],keyStart:1,keyStop:2,step:1},replconf:{arity:-1,flags:["admin","noscript","loading","stale","allow_busy"],keyStart:0,keyStop:0,step:0},replicaof:{arity:3,flags:["admin","noscript","stale","no_async_loading"],keyStart:0,keyStop:0,step:0},reset:{arity:1,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},restore:{arity:-4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},"restore-asking":{arity:-4,flags:["write","denyoom","asking"],keyStart:1,keyStop:1,step:1},role:{arity:1,flags:["noscript","loading","stale","fast"],keyStart:0,keyStop:0,step:0},rpop:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},rpoplpush:{arity:3,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},rpush:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},rpushx:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},sadd:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},save:{arity:1,flags:["admin","noscript","no_async_loading","no_multi"],keyStart:0,keyStop:0,step:0},scan:{arity:-2,flags:["readonly"],keyStart:0,keyStop:0,step:0},scard:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},script:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},sdiff:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},sdiffstore:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},select:{arity:2,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},set:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},setbit:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},setex:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},setnx:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},setrange:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},shutdown:{arity:-1,flags:["admin","noscript","loading","stale","no_multi","allow_busy"],keyStart:0,keyStop:0,step:0},sinter:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},sintercard:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},sinterstore:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},sismember:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},slaveof:{arity:3,flags:["admin","noscript","stale","no_async_loading"],keyStart:0,keyStop:0,step:0},slowlog:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},smembers:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},smismember:{arity:-3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},smove:{arity:4,flags:["write","fast"],keyStart:1,keyStop:2,step:1},sort:{arity:-2,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},sort_ro:{arity:-2,flags:["readonly","movablekeys"],keyStart:1,keyStop:1,step:1},spop:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},spublish:{arity:3,flags:["pubsub","loading","stale","fast"],keyStart:1,keyStop:1,step:1},srandmember:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},srem:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},sscan:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},ssubscribe:{arity:-2,flags:["pubsub","noscript","loading","stale"],keyStart:1,keyStop:-1,step:1},strlen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},subscribe:{arity:-2,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},substr:{arity:4,flags:["readonly"],keyStart:1,keyStop:1,step:1},sunion:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},sunionstore:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},sunsubscribe:{arity:-1,flags:["pubsub","noscript","loading","stale"],keyStart:1,keyStop:-1,step:1},swapdb:{arity:3,flags:["write","fast"],keyStart:0,keyStop:0,step:0},sync:{arity:1,flags:["admin","noscript","no_async_loading","no_multi"],keyStart:0,keyStop:0,step:0},time:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},touch:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:-1,step:1},ttl:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},type:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},unlink:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:-1,step:1},unsubscribe:{arity:-1,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},unwatch:{arity:1,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:0,keyStop:0,step:0},wait:{arity:3,flags:["noscript"],keyStart:0,keyStop:0,step:0},watch:{arity:-2,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:1,keyStop:-1,step:1},xack:{arity:-4,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xadd:{arity:-5,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},xautoclaim:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xclaim:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xdel:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xdelex:{arity:-5,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xgroup:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},xinfo:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},xlen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},xpending:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},xrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},xread:{arity:-4,flags:["readonly","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},xreadgroup:{arity:-7,flags:["write","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},xrevrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},xsetid:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},xtrim:{arity:-4,flags:["write"],keyStart:1,keyStop:1,step:1},zadd:{arity:-4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},zcard:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zcount:{arity:4,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zdiff:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zdiffstore:{arity:-4,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},zincrby:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},zinter:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zintercard:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zinterstore:{arity:-4,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},zlexcount:{arity:4,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zmpop:{arity:-4,flags:["write","movablekeys"],keyStart:0,keyStop:0,step:0},zmscore:{arity:-3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zpopmax:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},zpopmin:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},zrandmember:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrangebylex:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrangebyscore:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrangestore:{arity:-5,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},zrank:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zrem:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},zremrangebylex:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},zremrangebyrank:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},zremrangebyscore:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},zrevrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrevrangebylex:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrevrangebyscore:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrevrank:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zscan:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},zscore:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zunion:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zunionstore:{arity:-4,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1}}});var N1=F((d)=>{var Q6=d&&d.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(d,"__esModule",{value:!0});d.getKeyIndexes=d.hasFlag=d.exists=d.list=void 0;var H0=Q6(_$());d.list=Object.keys(H0.default);var JS={};d.list.forEach((S)=>{JS[S]=H0.default[S].flags.reduce(function($,w){return $[w]=!0,$},{})});function U6(S){return Boolean(H0.default[S])}d.exists=U6;function M6(S,$){if(!JS[S])throw Error("Unknown command "+S);return Boolean(JS[S][$])}d.hasFlag=M6;function G6(S,$,w){let Z=H0.default[S];if(!Z)throw Error("Unknown command "+S);if(!Array.isArray($))throw Error("Expect args to be an array");let Y=[],y=Boolean(w&&w.parseExternalKey),W=(X,U)=>{let Q=[],M=Number(X[U]);for(let G=0;G<M;G++)Q.push(G+U+1);return Q},J=(X,U,Q)=>{for(let M=U;M<X.length-1;M+=1)if(String(X[M]).toLowerCase()===Q.toLowerCase())return M+1;return null};switch(S){case"zunionstore":case"zinterstore":case"zdiffstore":Y.push(0,...W($,1));break;case"eval":case"evalsha":case"eval_ro":case"evalsha_ro":case"fcall":case"fcall_ro":case"blmpop":case"bzmpop":Y.push(...W($,1));break;case"sintercard":case"lmpop":case"zunion":case"zinter":case"zmpop":case"zintercard":case"zdiff":{Y.push(...W($,0));break}case"georadius":{Y.push(0);let X=J($,5,"STORE");if(X)Y.push(X);let U=J($,5,"STOREDIST");if(U)Y.push(U);break}case"georadiusbymember":{Y.push(0);let X=J($,4,"STORE");if(X)Y.push(X);let U=J($,4,"STOREDIST");if(U)Y.push(U);break}case"sort":case"sort_ro":Y.push(0);for(let X=1;X<$.length-1;X++){let U=$[X];if(typeof U!=="string")continue;let Q=U.toUpperCase();if(Q==="GET"){if(X+=1,U=$[X],U!=="#")if(y)Y.push([X,x$(U)]);else Y.push(X)}else if(Q==="BY")if(X+=1,y)Y.push([X,x$($[X])]);else Y.push(X);else if(Q==="STORE")X+=1,Y.push(X)}break;case"migrate":if($[2]==="")for(let X=5;X<$.length-1;X++){let U=$[X];if(typeof U==="string"&&U.toUpperCase()==="KEYS"){for(let Q=X+1;Q<$.length;Q++)Y.push(Q);break}}else Y.push(2);break;case"xreadgroup":case"xread":for(let X=S==="xread"?0:3;X<$.length-1;X++)if(String($[X]).toUpperCase()==="STREAMS"){for(let U=X+1;U<=X+($.length-1-X)/2;U++)Y.push(U);break}break;default:if(Z.step>0){let X=Z.keyStart-1,U=Z.keyStop>0?Z.keyStop:$.length+Z.keyStop+1;for(let Q=X;Q<U;Q+=Z.step)Y.push(Q)}break}return Y}d.getKeyIndexes=G6;function x$(S){if(typeof S!=="string")S=String(S);let $=S.indexOf("->");return $===-1?S.length:$}});var b$=F((C$)=>{Object.defineProperty(C$,"__esModule",{value:!0});C$.tryCatch=C$.errorObj=void 0;C$.errorObj={e:{}};var XS;function q6(S,$){try{let w=XS;return XS=null,w.apply(this,arguments)}catch(w){return C$.errorObj.e=w,C$.errorObj}}function V6(S){return XS=S,q6}C$.tryCatch=V6});var X1=F((f$)=>{Object.defineProperty(f$,"__esModule",{value:!0});var _1=b$();function h$(S){setTimeout(function(){throw S},0)}function k6(S,$,w){if(typeof $==="function")S.then((Z)=>{let Y;if(w!==void 0&&Object(w).spread&&Array.isArray(Z))Y=_1.tryCatch($).apply(void 0,[null].concat(Z));else Y=Z===void 0?_1.tryCatch($)(null):_1.tryCatch($)(null,Z);if(Y===_1.errorObj)h$(Y.e)},(Z)=>{if(!Z){let y=Error(Z+"");Object.assign(y,{cause:Z}),Z=y}let Y=_1.tryCatch($)(Z);if(Y===_1.errorObj)h$(Y.e)});return S}f$.default=k6});var u$=F((z9,g$)=>{var p$=j("assert"),t1=j("util");function x1(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}t1.inherits(x1,Error);Object.defineProperty(x1.prototype,"name",{value:"RedisError",configurable:!0,writable:!0});function US(S,$,w){p$($),p$.strictEqual(typeof w,"number"),Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0});let Z=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=Z,this.offset=w,this.buffer=$}t1.inherits(US,x1);Object.defineProperty(US.prototype,"name",{value:"ParserError",configurable:!0,writable:!0});function MS(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0});let $=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=$}t1.inherits(MS,x1);Object.defineProperty(MS.prototype,"name",{value:"ReplyError",configurable:!0,writable:!0});function E0(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}t1.inherits(E0,x1);Object.defineProperty(E0.prototype,"name",{value:"AbortError",configurable:!0,writable:!0});function GS(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}t1.inherits(GS,E0);Object.defineProperty(GS.prototype,"name",{value:"InterruptError",configurable:!0,writable:!0});g$.exports={RedisError:x1,ParserError:US,ReplyError:MS,AbortError:E0,InterruptError:GS}});var i$=F((B9,t$)=>{var m$=j("assert");class i1 extends Error{get name(){return this.constructor.name}}class d$ extends i1{constructor(S,$,w){m$($),m$.strictEqual(typeof w,"number");let Z=Error.stackTraceLimit;Error.stackTraceLimit=2;super(S);Error.stackTraceLimit=Z,this.offset=w,this.buffer=$}get name(){return this.constructor.name}}class l$ extends i1{constructor(S){let $=Error.stackTraceLimit;Error.stackTraceLimit=2;super(S);Error.stackTraceLimit=$}get name(){return this.constructor.name}}class qS extends i1{get name(){return this.constructor.name}}class c$ extends qS{get name(){return this.constructor.name}}t$.exports={RedisError:i1,ParserError:d$,ReplyError:l$,AbortError:qS,InterruptError:c$}});var O1=F((H9,a$)=>{var z6=process.version.charCodeAt(1)<55&&process.version.charCodeAt(2)===46?u$():i$();a$.exports=z6});var a1=F((E9,VS)=>{var s$=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920],B6=function($){var w,Z=0,Y=0,y=[],W=$.length;for(;Z<W;Z++)if(w=$.charCodeAt(Z),w<128)y[Y++]=w;else if(w<2048)y[Y++]=w>>6|192,y[Y++]=w&63|128;else if((w&64512)===55296&&Z+1<$.length&&($.charCodeAt(Z+1)&64512)===56320)w=65536+((w&1023)<<10)+($.charCodeAt(++Z)&1023),y[Y++]=w>>18|240,y[Y++]=w>>12&63|128,y[Y++]=w>>6&63|128,y[Y++]=w&63|128;else y[Y++]=w>>12|224,y[Y++]=w>>6&63|128,y[Y++]=w&63|128;return y},r$=VS.exports=function($){var w,Z=0,Y=-1,y=0,W=0,J=typeof $==="string"?B6($):$,X=J.length;while(Z<X){if(w=J[Z++],Y===-1){if(w===123)Y=Z}else if(w!==125)W=s$[(w^W>>8)&255]^W<<8;else if(Z-1!==Y)return W&16383;y=s$[(w^y>>8)&255]^y<<8}return y&16383};VS.exports.generateMulti=function($){var w=1,Z=$.length,Y=r$($[0]);while(w<Z)if(r$($[w++])!==Y)return-1;return Y}});var Y3=F((K9,Z3)=>{var o$=9007199254740991,H6="[object Arguments]",E6="[object Function]",K6="[object GeneratorFunction]",O6=/^(?:0|[1-9]\d*)$/;function e$(S,$,w){switch(w.length){case 0:return S.call($);case 1:return S.call($,w[0]);case 2:return S.call($,w[0],w[1]);case 3:return S.call($,w[0],w[1],w[2])}return S.apply($,w)}function D6(S,$){var w=-1,Z=Array(S);while(++w<S)Z[w]=$(w);return Z}var s1=Object.prototype,r1=s1.hasOwnProperty,S3=s1.toString,L6=s1.propertyIsEnumerable,n$=Math.max;function I6(S,$){var w=v6(S)||C6(S)?D6(S.length,String):[],Z=w.length,Y=!!Z;for(var y in S)if(($||r1.call(S,y))&&!(Y&&(y=="length"||w3(y,Z))))w.push(y);return w}function j6(S,$,w,Z){if(S===void 0||kS(S,s1[w])&&!r1.call(Z,w))return $;return S}function A6(S,$,w){var Z=S[$];if(!(r1.call(S,$)&&kS(Z,w))||w===void 0&&!($ in S))S[$]=w}function T6(S){if(!zS(S))return x6(S);var $=_6(S),w=[];for(var Z in S)if(!(Z=="constructor"&&($||!r1.call(S,Z))))w.push(Z);return w}function $3(S,$){return $=n$($===void 0?S.length-1:$,0),function(){var w=arguments,Z=-1,Y=n$(w.length-$,0),y=Array(Y);while(++Z<Y)y[Z]=w[$+Z];Z=-1;var W=Array($+1);while(++Z<$)W[Z]=w[Z];return W[$]=y,e$(S,this,W)}}function P6(S,$,w,Z){w||(w={});var Y=-1,y=$.length;while(++Y<y){var W=$[Y],J=Z?Z(w[W],S[W],W,w,S):void 0;A6(w,W,J===void 0?S[W]:J)}return w}function R6(S){return $3(function($,w){var Z=-1,Y=w.length,y=Y>1?w[Y-1]:void 0,W=Y>2?w[2]:void 0;if(y=S.length>3&&typeof y=="function"?(Y--,y):void 0,W&&N6(w[0],w[1],W))y=Y<3?void 0:y,Y=1;$=Object($);while(++Z<Y){var J=w[Z];if(J)S($,J,Z,y)}return $})}function w3(S,$){return $=$==null?o$:$,!!$&&(typeof S=="number"||O6.test(S))&&(S>-1&&S%1==0&&S<$)}function N6(S,$,w){if(!zS(w))return!1;var Z=typeof $;if(Z=="number"?FS(w)&&w3($,w.length):Z=="string"&&($ in w))return kS(w[$],S);return!1}function _6(S){var $=S&&S.constructor,w=typeof $=="function"&&$.prototype||s1;return S===w}function x6(S){var $=[];if(S!=null)for(var w in Object(S))$.push(w);return $}function kS(S,$){return S===$||S!==S&&$!==$}function C6(S){return b6(S)&&r1.call(S,"callee")&&(!L6.call(S,"callee")||S3.call(S)==H6)}var v6=Array.isArray;function FS(S){return S!=null&&f6(S.length)&&!h6(S)}function b6(S){return p6(S)&&FS(S)}function h6(S){var $=zS(S)?S3.call(S):"";return $==E6||$==K6}function f6(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=o$}function zS(S){var $=typeof S;return!!S&&($=="object"||$=="function")}function p6(S){return!!S&&typeof S=="object"}var g6=R6(function(S,$,w,Z){P6($,m6($),S,Z)}),u6=$3(function(S){return S.push(void 0,j6),e$(g6,void 0,S)});function m6(S){return FS(S)?I6(S,!0):T6(S)}Z3.exports=u6});var J3=F((O9,W3)=>{var d6=9007199254740991,l6="[object Arguments]",c6="[object Function]",t6="[object GeneratorFunction]",BS=Object.prototype,i6=BS.hasOwnProperty,y3=BS.toString,a6=BS.propertyIsEnumerable;function s6(S){return n6(S)&&i6.call(S,"callee")&&(!a6.call(S,"callee")||y3.call(S)==l6)}function r6(S){return S!=null&&e6(S.length)&&!o6(S)}function n6(S){return $7(S)&&r6(S)}function o6(S){var $=S7(S)?y3.call(S):"";return $==c6||$==t6}function e6(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=d6}function S7(S){var $=typeof S;return!!S&&($=="object"||$=="function")}function $7(S){return!!S&&typeof S=="object"}W3.exports=s6});var K0=F((X3)=>{Object.defineProperty(X3,"__esModule",{value:!0});X3.isArguments=X3.defaults=X3.noop=void 0;var w7=Y3();X3.defaults=w7;var Z7=J3();X3.isArguments=Z7;function Y7(){}X3.noop=Y7});var M3=F((L9,U3)=>{var C1=1000,v1=C1*60,b1=v1*60,D1=b1*24,J7=D1*7,X7=D1*365.25;U3.exports=function(S,$){$=$||{};var w=typeof S;if(w==="string"&&S.length>0)return Q7(S);else if(w==="number"&&isFinite(S))return $.long?M7(S):U7(S);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(S))};function Q7(S){if(S=String(S),S.length>100)return;var $=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(S);if(!$)return;var w=parseFloat($[1]),Z=($[2]||"ms").toLowerCase();switch(Z){case"years":case"year":case"yrs":case"yr":case"y":return w*X7;case"weeks":case"week":case"w":return w*J7;case"days":case"day":case"d":return w*D1;case"hours":case"hour":case"hrs":case"hr":case"h":return w*b1;case"minutes":case"minute":case"mins":case"min":case"m":return w*v1;case"seconds":case"second":case"secs":case"sec":case"s":return w*C1;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return w;default:return}}function U7(S){var $=Math.abs(S);if($>=D1)return Math.round(S/D1)+"d";if($>=b1)return Math.round(S/b1)+"h";if($>=v1)return Math.round(S/v1)+"m";if($>=C1)return Math.round(S/C1)+"s";return S+"ms"}function M7(S){var $=Math.abs(S);if($>=D1)return O0(S,$,D1,"day");if($>=b1)return O0(S,$,b1,"hour");if($>=v1)return O0(S,$,v1,"minute");if($>=C1)return O0(S,$,C1,"second");return S+" ms"}function O0(S,$,w,Z){var Y=$>=w*1.5;return Math.round(S/w)+" "+Z+(Y?"s":"")}});var HS=F((I9,G3)=>{function G7(S){w.debug=w,w.default=w,w.coerce=X,w.disable=W,w.enable=Y,w.enabled=J,w.humanize=M3(),w.destroy=U,Object.keys(S).forEach((Q)=>{w[Q]=S[Q]}),w.names=[],w.skips=[],w.formatters={};function $(Q){let M=0;for(let G=0;G<Q.length;G++)M=(M<<5)-M+Q.charCodeAt(G),M|=0;return w.colors[Math.abs(M)%w.colors.length]}w.selectColor=$;function w(Q){let M,G=null,O,W1;function b(...u){if(!b.enabled)return;let n=b,T1=Number(new Date),z1=T1-(M||T1);if(n.diff=z1,n.prev=M,n.curr=T1,M=T1,u[0]=w.coerce(u[0]),typeof u[0]!=="string")u.unshift("%O");let t=0;u[0]=u[0].replace(/%([a-zA-Z%])/g,(B1,P1)=>{if(B1==="%%")return"%";t++;let P=w.formatters[P1];if(typeof P==="function"){let L=u[t];B1=P.call(n,L),u.splice(t,1),t--}return B1}),w.formatArgs.call(n,u),(n.log||w.log).apply(n,u)}if(b.namespace=Q,b.useColors=w.useColors(),b.color=w.selectColor(Q),b.extend=Z,b.destroy=w.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(G!==null)return G;if(O!==w.namespaces)O=w.namespaces,W1=w.enabled(Q);return W1},set:(u)=>{G=u}}),typeof w.init==="function")w.init(b);return b}function Z(Q,M){let G=w(this.namespace+(typeof M>"u"?":":M)+Q);return G.log=this.log,G}function Y(Q){w.save(Q),w.namespaces=Q,w.names=[],w.skips=[];let M=(typeof Q==="string"?Q:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let G of M)if(G[0]==="-")w.skips.push(G.slice(1));else w.names.push(G)}function y(Q,M){let G=0,O=0,W1=-1,b=0;while(G<Q.length)if(O<M.length&&(M[O]===Q[G]||M[O]==="*"))if(M[O]==="*")W1=O,b=G,O++;else G++,O++;else if(W1!==-1)O=W1+1,b++,G=b;else return!1;while(O<M.length&&M[O]==="*")O++;return O===M.length}function W(){let Q=[...w.names,...w.skips.map((M)=>"-"+M)].join(",");return w.enable(""),Q}function J(Q){for(let M of w.skips)if(y(Q,M))return!1;for(let M of w.names)if(y(Q,M))return!0;return!1}function X(Q){if(Q instanceof Error)return Q.stack||Q.message;return Q}function U(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return w.enable(w.load()),w}G3.exports=G7});var V3=F((q3,D0)=>{q3.formatArgs=V7;q3.save=k7;q3.load=F7;q3.useColors=q7;q3.storage=z7();q3.destroy=(()=>{let S=!1;return()=>{if(!S)S=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();q3.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function q7(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let S;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(S=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(S[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function V7(S){if(S[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+S[0]+(this.useColors?"%c ":" ")+"+"+D0.exports.humanize(this.diff),!this.useColors)return;let $="color: "+this.color;S.splice(1,0,$,"color: inherit");let w=0,Z=0;S[0].replace(/%[a-zA-Z%]/g,(Y)=>{if(Y==="%%")return;if(w++,Y==="%c")Z=w}),S.splice(Z,0,$)}q3.log=console.debug||console.log||(()=>{});function k7(S){try{if(S)q3.storage.setItem("debug",S);else q3.storage.removeItem("debug")}catch($){}}function F7(){let S;try{S=q3.storage.getItem("debug")||q3.storage.getItem("DEBUG")}catch($){}if(!S&&typeof process<"u"&&"env"in process)S=process.env.DEBUG;return S}function z7(){try{return localStorage}catch(S){}}D0.exports=HS()(q3);var{formatters:B7}=D0.exports;B7.j=function(S){try{return JSON.stringify(S)}catch($){return"[UnexpectedJSONParseError]: "+$.message}}});var F3=F((A9,k3)=>{k3.exports=(S,$=process.argv)=>{let w=S.startsWith("-")?"":S.length===1?"-":"--",Z=$.indexOf(w+S),Y=$.indexOf("--");return Z!==-1&&(Y===-1||Z<Y)}});var H3=F((T9,B3)=>{var j7=j("os"),z3=j("tty"),r=F3(),{env:x}=process,Q1;if(r("no-color")||r("no-colors")||r("color=false")||r("color=never"))Q1=0;else if(r("color")||r("colors")||r("color=true")||r("color=always"))Q1=1;if("FORCE_COLOR"in x)if(x.FORCE_COLOR==="true")Q1=1;else if(x.FORCE_COLOR==="false")Q1=0;else Q1=x.FORCE_COLOR.length===0?1:Math.min(parseInt(x.FORCE_COLOR,10),3);function ES(S){if(S===0)return!1;return{level:S,hasBasic:!0,has256:S>=2,has16m:S>=3}}function KS(S,$){if(Q1===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(S&&!$&&Q1===void 0)return 0;let w=Q1||0;if(x.TERM==="dumb")return w;if(process.platform==="win32"){let Z=j7.release().split(".");if(Number(Z[0])>=10&&Number(Z[2])>=10586)return Number(Z[2])>=14931?3:2;return 1}if("CI"in x){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((Z)=>(Z in x))||x.CI_NAME==="codeship")return 1;return w}if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(x.TEAMCITY_VERSION)?1:0;if(x.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in x){let Z=parseInt((x.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(x.TERM_PROGRAM){case"iTerm.app":return Z>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(x.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(x.TERM))return 1;if("COLORTERM"in x)return 1;return w}function A7(S){let $=KS(S,S&&S.isTTY);return ES($)}B3.exports={supportsColor:A7,stdout:ES(KS(!0,z3.isatty(1))),stderr:ES(KS(!0,z3.isatty(2)))}});var D3=F((K3,I0)=>{var T7=j("tty"),L0=j("util");K3.init=v7;K3.log=_7;K3.formatArgs=R7;K3.save=x7;K3.load=C7;K3.useColors=P7;K3.destroy=L0.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");K3.colors=[6,2,3,4,5,1];try{let S=H3();if(S&&(S.stderr||S).level>=2)K3.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(S){}K3.inspectOpts=Object.keys(process.env).filter((S)=>{return/^debug_/i.test(S)}).reduce((S,$)=>{let w=$.substring(6).toLowerCase().replace(/_([a-z])/g,(Y,y)=>{return y.toUpperCase()}),Z=process.env[$];if(/^(yes|on|true|enabled)$/i.test(Z))Z=!0;else if(/^(no|off|false|disabled)$/i.test(Z))Z=!1;else if(Z==="null")Z=null;else Z=Number(Z);return S[w]=Z,S},{});function P7(){return"colors"in K3.inspectOpts?Boolean(K3.inspectOpts.colors):T7.isatty(process.stderr.fd)}function R7(S){let{namespace:$,useColors:w}=this;if(w){let Z=this.color,Y="\x1B[3"+(Z<8?Z:"8;5;"+Z),y=` ${Y};1m${$} \x1B[0m`;S[0]=y+S[0].split(`
|
|
2
|
-
`).join(`
|
|
3
|
-
`+y),S.push(Y+"m+"+I0.exports.humanize(this.diff)+"\x1B[0m")}else S[0]=N7()+$+" "+S[0]}function N7(){if(K3.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function _7(...S){return process.stderr.write(L0.formatWithOptions(K3.inspectOpts,...S)+`
|
|
4
|
-
`)}function x7(S){if(S)process.env.DEBUG=S;else delete process.env.DEBUG}function C7(){return process.env.DEBUG}function v7(S){S.inspectOpts={};let $=Object.keys(K3.inspectOpts);for(let w=0;w<$.length;w++)S.inspectOpts[$[w]]=K3.inspectOpts[$[w]]}I0.exports=HS()(K3);var{formatters:E3}=I0.exports;E3.o=function(S){return this.inspectOpts.colors=this.useColors,L0.inspect(S,this.inspectOpts).split(`
|
|
5
|
-
`).map(($)=>$.trim()).join(" ")};E3.O=function(S){return this.inspectOpts.colors=this.useColors,L0.inspect(S,this.inspectOpts)}});var L3=F((R9,OS)=>{if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)OS.exports=V3();else OS.exports=D3()});var P3=F((A3)=>{Object.defineProperty(A3,"__esModule",{value:!0});A3.genRedactedString=A3.getStringValue=A3.MAX_ARGUMENT_LENGTH=void 0;var d7=L3(),DS=200;A3.MAX_ARGUMENT_LENGTH=DS;var l7="ioredis";function I3(S){if(S===null)return;switch(typeof S){case"boolean":return;case"number":return;case"object":if(Buffer.isBuffer(S))return S.toString("hex");if(Array.isArray(S))return S.join(",");try{return JSON.stringify(S)}catch($){return}case"string":return S}}A3.getStringValue=I3;function j3(S,$){let{length:w}=S;return w<=$?S:S.slice(0,$)+' ... <REDACTED full-length="'+w+'">'}A3.genRedactedString=j3;function c7(S){let $=(0,d7.default)(`${l7}:${S}`);function w(...Z){if(!$.enabled)return;for(let Y=1;Y<Z.length;Y++){let y=I3(Z[Y]);if(typeof y==="string"&&y.length>DS)Z[Y]=j3(y,DS)}return $.apply(null,Z)}return Object.defineProperties(w,{namespace:{get(){return $.namespace}},enabled:{get(){return $.enabled}},destroy:{get(){return $.destroy}},log:{get(){return $.log},set(Z){$.log=Z}}}),w}A3.default=c7});var _3=F((N3)=>{Object.defineProperty(N3,"__esModule",{value:!0});var R3=`-----BEGIN CERTIFICATE-----
|
|
6
|
-
MIIDTzCCAjegAwIBAgIJAKSVpiDswLcwMA0GCSqGSIb3DQEBBQUAMD4xFjAUBgNV
|
|
7
|
-
BAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1
|
|
8
|
-
dGhvcml0eTAeFw0xMzEwMDExMjE0NTVaFw0yMzA5MjkxMjE0NTVaMD4xFjAUBgNV
|
|
9
|
-
BAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1
|
|
10
|
-
dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALZqkh/DczWP
|
|
11
|
-
JnxnHLQ7QL0T4B4CDKWBKCcisriGbA6ZePWVNo4hfKQC6JrzfR+081NeD6VcWUiz
|
|
12
|
-
rmd+jtPhIY4c+WVQYm5PKaN6DT1imYdxQw7aqO5j2KUCEh/cznpLxeSHoTxlR34E
|
|
13
|
-
QwF28Wl3eg2vc5ct8LjU3eozWVk3gb7alx9mSA2SgmuX5lEQawl++rSjsBStemY2
|
|
14
|
-
BDwOpAMXIrdEyP/cVn8mkvi/BDs5M5G+09j0gfhyCzRWMQ7Hn71u1eolRxwVxgi3
|
|
15
|
-
TMn+/vTaFSqxKjgck6zuAYjBRPaHe7qLxHNr1So/Mc9nPy+3wHebFwbIcnUojwbp
|
|
16
|
-
4nctkWbjb2cCAwEAAaNQME4wHQYDVR0OBBYEFP1whtcrydmW3ZJeuSoKZIKjze3w
|
|
17
|
-
MB8GA1UdIwQYMBaAFP1whtcrydmW3ZJeuSoKZIKjze3wMAwGA1UdEwQFMAMBAf8w
|
|
18
|
-
DQYJKoZIhvcNAQEFBQADggEBAG2erXhwRAa7+ZOBs0B6X57Hwyd1R4kfmXcs0rta
|
|
19
|
-
lbPpvgULSiB+TCbf3EbhJnHGyvdCY1tvlffLjdA7HJ0PCOn+YYLBA0pTU/dyvrN6
|
|
20
|
-
Su8NuS5yubnt9mb13nDGYo1rnt0YRfxN+8DM3fXIVr038A30UlPX2Ou1ExFJT0MZ
|
|
21
|
-
uFKY6ZvLdI6/1cbgmguMlAhM+DhKyV6Sr5699LM3zqeI816pZmlREETYkGr91q7k
|
|
22
|
-
BpXJu/dtHaGxg1ZGu6w/PCsYGUcECWENYD4VQPd8N32JjOfu6vEgoEAwfPP+3oGp
|
|
23
|
-
Z4m3ewACcWOAenqflb+cQYC4PsF7qbXDmRaWrbKntOlZ3n0=
|
|
24
|
-
-----END CERTIFICATE-----
|
|
25
|
-
-----BEGIN CERTIFICATE-----
|
|
26
|
-
MIIGMTCCBBmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwajELMAkGA1UEBhMCVVMx
|
|
27
|
-
CzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJzMS0w
|
|
28
|
-
KwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN
|
|
29
|
-
MTgwMjI1MTUzNzM3WhcNMjgwMjIzMTUzNzM3WjBfMQswCQYDVQQGEwJVUzELMAkG
|
|
30
|
-
A1UECAwCQ0ExEjAQBgNVBAoMCVJlZGlzTGFiczEvMC0GA1UEAwwmUkNQIEludGVy
|
|
31
|
-
bWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA
|
|
32
|
-
A4ICDwAwggIKAoICAQDf9dqbxc8Bq7Ctq9rWcxrGNKKHivqLAFpPq02yLPx6fsOv
|
|
33
|
-
Tq7GsDChAYBBc4v7Y2Ap9RD5Vs3dIhEANcnolf27QwrG9RMnnvzk8pCvp1o6zSU4
|
|
34
|
-
VuOE1W66/O1/7e2rVxyrnTcP7UgK43zNIXu7+tiAqWsO92uSnuMoGPGpeaUm1jym
|
|
35
|
-
hjWKtkAwDFSqvHY+XL5qDVBEjeUe+WHkYUg40cAXjusAqgm2hZt29c2wnVrxW25W
|
|
36
|
-
P0meNlzHGFdA2AC5z54iRiqj57dTfBTkHoBczQxcyw6hhzxZQ4e5I5zOKjXXEhZN
|
|
37
|
-
r0tA3YC14CTabKRus/JmZieyZzRgEy2oti64tmLYTqSlAD78pRL40VNoaSYetXLw
|
|
38
|
-
hhNsXCHgWaY6d5bLOc/aIQMAV5oLvZQKvuXAF1IDmhPA+bZbpWipp0zagf1P1H3s
|
|
39
|
-
UzsMdn2KM0ejzgotbtNlj5TcrVwpmvE3ktvUAuA+hi3FkVx1US+2Gsp5x4YOzJ7u
|
|
40
|
-
P1WPk6ShF0JgnJH2ILdj6kttTWwFzH17keSFICWDfH/+kM+k7Y1v3EXMQXE7y0T9
|
|
41
|
-
MjvJskz6d/nv+sQhY04xt64xFMGTnZjlJMzfQNi7zWFLTZnDD0lPowq7l3YiPoTT
|
|
42
|
-
t5Xky83lu0KZsZBo0WlWaDG00gLVdtRgVbcuSWxpi5BdLb1kRab66JptWjxwXQID
|
|
43
|
-
AQABo4HrMIHoMDoGA1UdHwQzMDEwL6AtoCuGKWh0dHBzOi8vcmwtY2Etc2VydmVy
|
|
44
|
-
LnJlZGlzbGFicy5jb20vdjEvY3JsMEYGCCsGAQUFBwEBBDowODA2BggrBgEFBQcw
|
|
45
|
-
AYYqaHR0cHM6Ly9ybC1jYS1zZXJ2ZXIucmVkaXNsYWJzLmNvbS92MS9vY3NwMB0G
|
|
46
|
-
A1UdDgQWBBQHar5OKvQUpP2qWt6mckzToeCOHDAfBgNVHSMEGDAWgBQi42wH6hM4
|
|
47
|
-
L2sujEvLM0/u8lRXTzASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIB
|
|
48
|
-
hjANBgkqhkiG9w0BAQsFAAOCAgEAirEn/iTsAKyhd+pu2W3Z5NjCko4NPU0EYUbr
|
|
49
|
-
AP7+POK2rzjIrJO3nFYQ/LLuC7KCXG+2qwan2SAOGmqWst13Y+WHp44Kae0kaChW
|
|
50
|
-
vcYLXXSoGQGC8QuFSNUdaeg3RbMDYFT04dOkqufeWVccoHVxyTSg9eD8LZuHn5jw
|
|
51
|
-
7QDLiEECBmIJHk5Eeo2TAZrx4Yx6ufSUX5HeVjlAzqwtAqdt99uCJ/EL8bgpWbe+
|
|
52
|
-
XoSpvUv0SEC1I1dCAhCKAvRlIOA6VBcmzg5Am12KzkqTul12/VEFIgzqu0Zy2Jbc
|
|
53
|
-
AUPrYVu/+tOGXQaijy7YgwH8P8n3s7ZeUa1VABJHcxrxYduDDJBLZi+MjheUDaZ1
|
|
54
|
-
jQRHYevI2tlqeSBqdPKG4zBY5lS0GiAlmuze5oENt0P3XboHoZPHiqcK3VECgTVh
|
|
55
|
-
/BkJcuudETSJcZDmQ8YfoKfBzRQNg2sv/hwvUv73Ss51Sco8GEt2lD8uEdib1Q6z
|
|
56
|
-
zDT5lXJowSzOD5ZA9OGDjnSRL+2riNtKWKEqvtEG3VBJoBzu9GoxbAc7wIZLxmli
|
|
57
|
-
iF5a/Zf5X+UXD3s4TMmy6C4QZJpAA2egsSQCnraWO2ULhh7iXMysSkF/nzVfZn43
|
|
58
|
-
iqpaB8++9a37hWq14ZmOv0TJIDz//b2+KC4VFXWQ5W5QC6whsjT+OlG4p5ZYG0jo
|
|
59
|
-
616pxqo=
|
|
60
|
-
-----END CERTIFICATE-----
|
|
61
|
-
-----BEGIN CERTIFICATE-----
|
|
62
|
-
MIIFujCCA6KgAwIBAgIJAJ1aTT1lu2ScMA0GCSqGSIb3DQEBCwUAMGoxCzAJBgNV
|
|
63
|
-
BAYTAlVTMQswCQYDVQQIDAJDQTELMAkGA1UEBwwCQ0ExEjAQBgNVBAoMCVJlZGlz
|
|
64
|
-
TGFiczEtMCsGA1UEAwwkUmVkaXNMYWJzIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9y
|
|
65
|
-
aXR5MB4XDTE4MDIyNTE1MjA0MloXDTM4MDIyMDE1MjA0MlowajELMAkGA1UEBhMC
|
|
66
|
-
VVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJz
|
|
67
|
-
MS0wKwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw
|
|
68
|
-
ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDLEjXy7YrbN5Waau5cd6g1
|
|
69
|
-
G5C2tMmeTpZ0duFAPxNU4oE3RHS5gGiok346fUXuUxbZ6QkuzeN2/2Z+RmRcJhQY
|
|
70
|
-
Dm0ZgdG4x59An1TJfnzKKoWj8ISmoHS/TGNBdFzXV7FYNLBuqZouqePI6ReC6Qhl
|
|
71
|
-
pp45huV32Q3a6IDrrvx7Wo5ZczEQeFNbCeCOQYNDdTmCyEkHqc2AGo8eoIlSTutT
|
|
72
|
-
ULOC7R5gzJVTS0e1hesQ7jmqHjbO+VQS1NAL4/5K6cuTEqUl+XhVhPdLWBXJQ5ag
|
|
73
|
-
54qhX4v+ojLzeU1R/Vc6NjMvVtptWY6JihpgplprN0Yh2556ewcXMeturcKgXfGJ
|
|
74
|
-
xeYzsjzXerEjrVocX5V8BNrg64NlifzTMKNOOv4fVZszq1SIHR8F9ROrqiOdh8iC
|
|
75
|
-
JpUbLpXH9hWCSEO6VRMB2xJoKu3cgl63kF30s77x7wLFMEHiwsQRKxooE1UhgS9K
|
|
76
|
-
2sO4TlQ1eWUvFvHSTVDQDlGQ6zu4qjbOpb3Q8bQwoK+ai2alkXVR4Ltxe9QlgYK3
|
|
77
|
-
StsnPhruzZGA0wbXdpw0bnM+YdlEm5ffSTpNIfgHeaa7Dtb801FtA71ZlH7A6TaI
|
|
78
|
-
SIQuUST9EKmv7xrJyx0W1pGoPOLw5T029aTjnICSLdtV9bLwysrLhIYG5bnPq78B
|
|
79
|
-
cS+jZHFGzD7PUVGQD01nOQIDAQABo2MwYTAdBgNVHQ4EFgQUIuNsB+oTOC9rLoxL
|
|
80
|
-
yzNP7vJUV08wHwYDVR0jBBgwFoAUIuNsB+oTOC9rLoxLyzNP7vJUV08wDwYDVR0T
|
|
81
|
-
AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAHfg
|
|
82
|
-
z5pMNUAKdMzK1aS1EDdK9yKz4qicILz5czSLj1mC7HKDRy8cVADUxEICis++CsCu
|
|
83
|
-
rYOvyCVergHQLREcxPq4rc5Nq1uj6J6649NEeh4WazOOjL4ZfQ1jVznMbGy+fJm3
|
|
84
|
-
3Hoelv6jWRG9iqeJZja7/1s6YC6bWymI/OY1e4wUKeNHAo+Vger7MlHV+RuabaX+
|
|
85
|
-
hSJ8bJAM59NCM7AgMTQpJCncrcdLeceYniGy5Q/qt2b5mJkQVkIdy4TPGGB+AXDJ
|
|
86
|
-
D0q3I/JDRkDUFNFdeW0js7fHdsvCR7O3tJy5zIgEV/o/BCkmJVtuwPYOrw/yOlKj
|
|
87
|
-
TY/U7ATAx9VFF6/vYEOMYSmrZlFX+98L6nJtwDqfLB5VTltqZ4H/KBxGE3IRSt9l
|
|
88
|
-
FXy40U+LnXzhhW+7VBAvyYX8GEXhHkKU8Gqk1xitrqfBXY74xKgyUSTolFSfFVgj
|
|
89
|
-
mcM/X4K45bka+qpkj7Kfv/8D4j6aZekwhN2ly6hhC1SmQ8qjMjpG/mrWOSSHZFmf
|
|
90
|
-
ybu9iD2AYHeIOkshIl6xYIa++Q/00/vs46IzAbQyriOi0XxlSMMVtPx0Q3isp+ji
|
|
91
|
-
n8Mq9eOuxYOEQ4of8twUkUDd528iwGtEdwf0Q01UyT84S62N8AySl1ZBKXJz6W4F
|
|
92
|
-
UhWfa/HQYOAPDdEjNgnVwLI23b8t0TozyCWw7q8h
|
|
93
|
-
-----END CERTIFICATE-----
|
|
1
|
+
var k1=Object.create;var{getPrototypeOf:T1,defineProperty:f$,getOwnPropertyNames:v1}=Object;var P1=Object.prototype.hasOwnProperty;var G$=($,W,Y)=>{Y=$!=null?k1(T1($)):{};let Z=W||!$||!$.__esModule?f$(Y,"default",{value:$,enumerable:!0}):Y;for(let Q of v1($))if(!P1.call(Z,Q))f$(Z,Q,{get:()=>$[Q],enumerable:!0});return Z};var R1=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var W$=R1((F$,q$)=>{(function($,W){typeof F$=="object"&&typeof q$<"u"?q$.exports=W():typeof define=="function"&&define.amd?define(W):($=typeof globalThis<"u"?globalThis:$||self).dayjs=W()})(F$,function(){var $=1000,W=60000,Y=3600000,Z="millisecond",Q="second",X="minute",J="hour",M="day",V="week",B="month",S="quarter",E="year",T="date",h$="Invalid Date",_1=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,I1=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,S1={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(F){var j=["th","st","nd","rd"],D=F%100;return"["+F+(j[(D-20)%10]||j[D]||j[0])+"]"}},j$=function(F,j,D){var U=String(F);return!U||U.length>=j?F:""+Array(j+1-U.length).join(D)+F},L1={s:j$,z:function(F){var j=-F.utcOffset(),D=Math.abs(j),U=Math.floor(D/60),K=D%60;return(j<=0?"+":"-")+j$(U,2,"0")+":"+j$(K,2,"0")},m:function F(j,D){if(j.date()<D.date())return-F(D,j);var U=12*(D.year()-j.year())+(D.month()-j.month()),K=j.clone().add(U,B),q=D-K<0,w=j.clone().add(U+(q?-1:1),B);return+(-(U+(D-K)/(q?K-w:w-K))||0)},a:function(F){return F<0?Math.ceil(F)||0:Math.floor(F)},p:function(F){return{M:B,y:E,w:V,d:M,D:T,h:J,m:X,s:Q,ms:Z,Q:S}[F]||String(F||"").toLowerCase().replace(/s$/,"")},u:function(F){return F===void 0}},g="en",h={};h[g]=S1;var m$="$isDayjsObject",U$=function(F){return F instanceof e||!(!F||!F[m$])},o=function F(j,D,U){var K;if(!j)return g;if(typeof j=="string"){var q=j.toLowerCase();h[q]&&(K=q),D&&(h[q]=D,K=q);var w=j.split("-");if(!K&&w.length>1)return F(w[0])}else{var H=j.name;h[H]=j,K=H}return!U&&K&&(g=K),K||!U&&g},_=function(F,j){if(U$(F))return F.clone();var D=typeof j=="object"?j:{};return D.date=F,D.args=arguments,new e(D)},N=L1;N.l=o,N.i=U$,N.w=function(F,j){return _(F,{locale:j.$L,utc:j.$u,x:j.$x,$offset:j.$offset})};var e=function(){function F(D){this.$L=o(D.locale,null,!0),this.parse(D),this.$x=this.$x||D.x||{},this[m$]=!0}var j=F.prototype;return j.parse=function(D){this.$d=function(U){var{date:K,utc:q}=U;if(K===null)return new Date(NaN);if(N.u(K))return new Date;if(K instanceof Date)return new Date(K);if(typeof K=="string"&&!/Z$/i.test(K)){var w=K.match(_1);if(w){var H=w[2]-1||0,A=(w[7]||"0").substring(0,3);return q?new Date(Date.UTC(w[1],H,w[3]||1,w[4]||0,w[5]||0,w[6]||0,A)):new Date(w[1],H,w[3]||1,w[4]||0,w[5]||0,w[6]||0,A)}}return new Date(K)}(D),this.init()},j.init=function(){var D=this.$d;this.$y=D.getFullYear(),this.$M=D.getMonth(),this.$D=D.getDate(),this.$W=D.getDay(),this.$H=D.getHours(),this.$m=D.getMinutes(),this.$s=D.getSeconds(),this.$ms=D.getMilliseconds()},j.$utils=function(){return N},j.isValid=function(){return this.$d.toString()!==h$},j.isSame=function(D,U){var K=_(D);return this.startOf(U)<=K&&K<=this.endOf(U)},j.isAfter=function(D,U){return _(D)<this.startOf(U)},j.isBefore=function(D,U){return this.endOf(U)<_(D)},j.$g=function(D,U,K){return N.u(D)?this[U]:this.set(K,D)},j.unix=function(){return Math.floor(this.valueOf()/1000)},j.valueOf=function(){return this.$d.getTime()},j.startOf=function(D,U){var K=this,q=!!N.u(U)||U,w=N.p(D),H=function(p,v){var y=N.w(K.$u?Date.UTC(K.$y,v,p):new Date(K.$y,v,p),K);return q?y:y.endOf(M)},A=function(p,v){return N.w(K.toDate()[p].apply(K.toDate("s"),(q?[0,0,0,0]:[23,59,59,999]).slice(v)),K)},I=this.$W,L=this.$M,P=this.$D,l="set"+(this.$u?"UTC":"");switch(w){case E:return q?H(1,0):H(31,11);case B:return q?H(1,L):H(0,L+1);case V:var m=this.$locale().weekStart||0,s=(I<m?I+7:I)-m;return H(q?P-s:P+(6-s),L);case M:case T:return A(l+"Hours",0);case J:return A(l+"Minutes",1);case X:return A(l+"Seconds",2);case Q:return A(l+"Milliseconds",3);default:return this.clone()}},j.endOf=function(D){return this.startOf(D,!1)},j.$set=function(D,U){var K,q=N.p(D),w="set"+(this.$u?"UTC":""),H=(K={},K[M]=w+"Date",K[T]=w+"Date",K[B]=w+"Month",K[E]=w+"FullYear",K[J]=w+"Hours",K[X]=w+"Minutes",K[Q]=w+"Seconds",K[Z]=w+"Milliseconds",K)[q],A=q===M?this.$D+(U-this.$W):U;if(q===B||q===E){var I=this.clone().set(T,1);I.$d[H](A),I.init(),this.$d=I.set(T,Math.min(this.$D,I.daysInMonth())).$d}else H&&this.$d[H](A);return this.init(),this},j.set=function(D,U){return this.clone().$set(D,U)},j.get=function(D){return this[N.p(D)]()},j.add=function(D,U){var K,q=this;D=Number(D);var w=N.p(U),H=function(L){var P=_(q);return N.w(P.date(P.date()+Math.round(L*D)),q)};if(w===B)return this.set(B,this.$M+D);if(w===E)return this.set(E,this.$y+D);if(w===M)return H(1);if(w===V)return H(7);var A=(K={},K[X]=W,K[J]=Y,K[Q]=$,K)[w]||1,I=this.$d.getTime()+D*A;return N.w(I,this)},j.subtract=function(D,U){return this.add(-1*D,U)},j.format=function(D){var U=this,K=this.$locale();if(!this.isValid())return K.invalidDate||h$;var q=D||"YYYY-MM-DDTHH:mm:ssZ",w=N.z(this),H=this.$H,A=this.$m,I=this.$M,L=K.weekdays,P=K.months,l=K.meridiem,m=function(v,y,d,$$){return v&&(v[y]||v(U,q))||d[y].slice(0,$$)},s=function(v){return N.s(H%12||12,v,"0")},p=l||function(v,y,d){var $$=v<12?"AM":"PM";return d?$$.toLowerCase():$$};return q.replace(I1,function(v,y){return y||function(d){switch(d){case"YY":return String(U.$y).slice(-2);case"YYYY":return N.s(U.$y,4,"0");case"M":return I+1;case"MM":return N.s(I+1,2,"0");case"MMM":return m(K.monthsShort,I,P,3);case"MMMM":return m(P,I);case"D":return U.$D;case"DD":return N.s(U.$D,2,"0");case"d":return String(U.$W);case"dd":return m(K.weekdaysMin,U.$W,L,2);case"ddd":return m(K.weekdaysShort,U.$W,L,3);case"dddd":return L[U.$W];case"H":return String(H);case"HH":return N.s(H,2,"0");case"h":return s(1);case"hh":return s(2);case"a":return p(H,A,!0);case"A":return p(H,A,!1);case"m":return String(A);case"mm":return N.s(A,2,"0");case"s":return String(U.$s);case"ss":return N.s(U.$s,2,"0");case"SSS":return N.s(U.$ms,3,"0");case"Z":return w}return null}(v)||w.replace(":","")})},j.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},j.diff=function(D,U,K){var q,w=this,H=N.p(U),A=_(D),I=(A.utcOffset()-this.utcOffset())*W,L=this-A,P=function(){return N.m(w,A)};switch(H){case E:q=P()/12;break;case B:q=P();break;case S:q=P()/3;break;case V:q=(L-I)/604800000;break;case M:q=(L-I)/86400000;break;case J:q=L/Y;break;case X:q=L/W;break;case Q:q=L/$;break;default:q=L}return K?q:N.a(q)},j.daysInMonth=function(){return this.endOf(B).$D},j.$locale=function(){return h[this.$L]},j.locale=function(D,U){if(!D)return this.$L;var K=this.clone(),q=o(D,U,!0);return q&&(K.$L=q),K},j.clone=function(){return N.w(this.$d,this)},j.toDate=function(){return new Date(this.valueOf())},j.toJSON=function(){return this.isValid()?this.toISOString():null},j.toISOString=function(){return this.$d.toISOString()},j.toString=function(){return this.$d.toUTCString()},F}(),p$=e.prototype;return _.prototype=p$,[["$ms",Z],["$s",Q],["$m",X],["$H",J],["$W",M],["$M",B],["$y",E],["$D",T]].forEach(function(F){p$[F[1]]=function(j){return this.$g(j,F[0],F[1])}}),_.extend=function(F,j){return F.$i||(F(j,e,_),F.$i=!0),_},_.locale=o,_.isDayjs=U$,_.unix=function(F){return _(1000*F)},_.en=h[g],_.Ls=h,_.p={},_})});import{createServer as J2}from"net";var V$=G$(W$(),1);var r={ok:"OK",created:"Created",accepted:"Accepted",noContent:"No Content",movedPermanently:"Moved Permanently",found:"Found",notModified:"Not Modified",badRequest:"Bad Request",unauthorized:"Unauthorized",forbidden:"Forbidden",notFound:"Not Found",methodNotAllowed:"Method Not Allowed",conflict:"Conflict",unsupportedMediaType:"Unsupported Media Type",tooManyRequests:"Too Many Requests",internalServerError:"Internal Server Error"},R={ok:200,created:201,accepted:202,noContent:204,movedPermanently:301,found:302,notModified:304,badRequest:400,unauthorized:401,forbidden:403,notFound:404,methodNotAllowed:405,conflict:409,unsupportedMediaType:415,tooManyRequests:429,internalServerError:500},z={delete:"DELETE",get:"GET",head:"HEAD",post:"POST",put:"PUT",patch:"PATCH",options:"OPTIONS"},b={json:"application/json",html:"text/html",form:"application/x-www-form-urlencoded",multipart:"multipart/form-data",xml:"application/xml",text:"text/plain",csv:"text/csv",yamlApplication:"application/yaml",yamlText:"text/yaml",urlEncodedJson:"application/x-www-form-urlencoded+json"},x={authorization:"Authorization",proxyAuthorization:"Proxy-Authorization",wwwAuthenticate:"WWW-Authenticate",cacheControl:"Cache-Control",etag:"ETag",expires:"Expires",lastModified:"Last-Modified",ifMatch:"If-Match",ifNoneMatch:"If-None-Match",ifModifiedSince:"If-Modified-Since",ifUnmodifiedSince:"If-Unmodified-Since",ifRange:"If-Range",age:"Age",vary:"Vary",contentType:"Content-Type",contentLength:"Content-Length",contentEncoding:"Content-Encoding",contentLanguage:"Content-Language",contentDisposition:"Content-Disposition",contentLocation:"Content-Location",contentRange:"Content-Range",accessControlAllowCredentials:"Access-Control-Allow-Credentials",accessControlAllowHeaders:"Access-Control-Allow-Headers",accessControlAllowMethods:"Access-Control-Allow-Methods",accessControlAllowOrigin:"Access-Control-Allow-Origin",accessControlExposeHeaders:"Access-Control-Expose-Headers",accessControlMaxAge:"Access-Control-Max-Age",accessControlRequestHeaders:"Access-Control-Request-Headers",accessControlRequestMethod:"Access-Control-Request-Method",accept:"Accept",acceptEncoding:"Accept-Encoding",acceptLanguage:"Accept-Language",acceptRanges:"Accept-Ranges",host:"Host",userAgent:"User-Agent",referer:"Referer",origin:"Origin",from:"From",expect:"Expect",location:"Location",server:"Server",date:"Date",allow:"Allow",retryAfter:"Retry-After",range:"Range",contentSecurityPolicy:"Content-Security-Policy",contentSecurityPolicyReportOnly:"Content-Security-Policy-Report-Only",strictTransportSecurity:"Strict-Transport-Security",xContentTypeOptions:"X-Content-Type-Options",xFrameOptions:"X-Frame-Options",xXSSProtection:"X-XSS-Protection",referrerPolicy:"Referrer-Policy",permissionsPolicy:"Permissions-Policy",crossOriginEmbedderPolicy:"Cross-Origin-Embedder-Policy",crossOriginOpenerPolicy:"Cross-Origin-Opener-Policy",crossOriginResourcePolicy:"Cross-Origin-Resource-Policy",cookie:"Cookie",setCookie:"Set-Cookie",connection:"Connection",keepAlive:"Keep-Alive",upgrade:"Upgrade",upgradeInsecureRequests:"Upgrade-Insecure-Requests",transferEncoding:"Transfer-Encoding",te:"TE",trailer:"Trailer",forwarded:"Forwarded",xForwardedFor:"X-Forwarded-For",via:"Via",maxForwards:"Max-Forwards",altSvc:"Alt-Svc",altUsed:"Alt-Used",timingAllowOrigin:"Timing-Allow-Origin",serverTiming:"Server-Timing",refresh:"Refresh",link:"Link",xPoweredBy:"X-Powered-By",xPermittedCrossDomainPolicies:"X-Permitted-Cross-Domain-Policies",reportTo:"Report-To",serviceWorkerAllowed:"Service-Worker-Allowed",sourceMap:"SourceMap",priority:"Priority",secGPC:"Sec-GPC",clearSiteData:"Clear-Site-Data",noVarySearch:"No-Vary-Search"},l$={base64:"base64",binary:"binary",utf8:"utf8"};var Y$=($,W)=>{if(!W.enabled)return!1;if($.request.method==="OPTIONS"){if(!s$($,W))return $.response.setStatusCode(403),$._response._setBody({error:"CORS: Origin not allowed",origin:$.request.headers.origin}),!0;$.response.setStatusCode(W.optionsSuccessStatus);let Q=g$($,W);if($._response._setHeadersIfNotSet({[x.accessControlAllowOrigin]:Q,[x.accessControlAllowMethods]:W.methods.join(", "),[x.accessControlAllowHeaders]:typeof W.allowedHeaders==="string"?W.allowedHeaders:W.allowedHeaders.join(", "),[x.accessControlAllowCredentials]:W.credentials?"true":"false",[x.accessControlExposeHeaders]:W.exposedHeaders.join(", "),[x.accessControlMaxAge]:W.maxAge.toString()}),W.preflightContinue)return!1;return $._response._setBody(""),!0}if(s$($,W)){let Z=g$($,W);$._response._setHeadersIfNotSet({[x.accessControlAllowOrigin]:Z,[x.accessControlAllowCredentials]:W.credentials?"true":"false"})}return!1},g$=($,W)=>{if(W.origin==="*"){if(W.credentials)throw Error('CORS Security Error: origin: "*" with credentials: true is forbidden by CORS spec and creates security vulnerabilities. Use specific origins instead.');return"*"}let Y=$.request.headers.origin;if(Y)return Y;if(typeof W.origin==="string")return W.origin;if(Array.isArray(W.origin)&&W.origin.length>0){let[Z]=W.origin;return Z??"null"}return"null"},s$=($,W)=>{if(W.origin==="*")return!0;let Y=$.request.headers.origin?.toLowerCase()??"";if(typeof W.origin==="function")return Boolean(W.origin(Y,$.request));if(typeof W.origin==="string")return Y===W.origin.toLowerCase();if(Array.isArray(W.origin))return W.origin.some((Z)=>Y===Z.toLowerCase());if(W.origin instanceof RegExp)return W.origin.test(Y);return!1};var d$=G$(W$(),1);var O={reset:"\x1B[0m",cyan:"\x1B[96m",yellow:"\x1B[93m",red:"\x1B[91m",green:"\x1B[92m",magenta:"\x1B[95m",gray:"\x1B[90m"};var c={off:"off",error:"error",warn:"warn",info:"info"};var f={off:0,error:1,warn:2,info:3},b1={positive:["n'at!","yinz are good!","that's the way!","right on!","lookin' good!","way to go!","keep it up!"],neutral:["n'at","yinz know","just sayin'","that's how it is","what can ya do","it happens"],negative:["aw jeez","that ain't right","what a jagoff move","that's terrible n'at","somebody messed up","this is bad news","yinz better fix this"]},Z$=($)=>{let W=b1[$];return W[Math.floor(Math.random()*W.length)]??""},r$=()=>d$.default().format("YYYY-MM-DD HH:mm:ss.SSS"),w$=($,W,...Y)=>{let Z=r$(),Q=O.reset;if(W==="NETWORK")Q=O.gray;if($==="error"){let J=`${O.red}[${W}] ❌ [${Z}] [ERROR]${O.reset}`;console.error(`${J}`,`${Q}`,...Y,`${O.reset} - ${Z$("negative")}`);return}if($==="warn"){let J=`${O.yellow}[${W}] ⚠️ [${Z}] [WARN]${O.reset}`;console.warn(`${J}`,`${Q}`,...Y,`${O.reset} - ${Z$("neutral")}`);return}if($==="off")return;let X=`${O.cyan}[${W}] ✅ [${Z}] [INFO]${O.reset}`;console.info(`${X}`,`${Q}`,...Y,`${O.reset} - ${Z$("positive")}`)},C1=($,W,...Y)=>{let Z=r$(),Q=`${O.magenta}[${$}] \uD83D\uDCCA [${Z}] [TABLE]${O.reset}`;if(console.log(`${Q} - ${Z$("positive")}`),console.table(W),Y.length>0)console.log(`${O.gray}Additional context:${O.reset}`,...Y)},a=($)=>{let W={logLevel:$?.logLevel??c.info,prefix:$?.prefix??"YINZER",logger:$?.logger??null},Y=(M)=>f[M]??f.info;return{info:(...M)=>{if(Y(W.logLevel)<f.info)return;if(W.logger){W.logger.info(...M);return}w$("info",W.prefix,...M)},warn:(...M)=>{if(Y(W.logLevel)<f.warn)return;if(W.logger){W.logger.warn(...M);return}w$("warn",W.prefix,...M)},error:(...M)=>{if(Y(W.logLevel)<f.error)return;if(W.logger){W.logger.error(...M);return}w$("error",W.prefix,...M)},table:(M,...V)=>{if(Y(W.logLevel)<f.info)return;if(W.logger){W.logger.info("TABLE:",M,...V);return}C1(W.prefix,M,...V)},levels:f}},G=a();class B${setup;constructor($){this.setup=$}async handle($){try{if(this._handleCors($))return;let W=await this._matchRoute($);if(!W)return;Object.assign($.request.params,W.params);let{handler:Y,options:Z}=W,{beforeHooks:Q=[],afterHooks:X=[]}=Z;if(await this._handleBeforeAllHooks($))return;if(await this._handleBeforeHooks($,Q))return;let J=null;try{J=await Y($)}catch(V){throw V}for(let V of X)await V($);let M=this.setup._hooks._afterAll;for(let V of M){if(!this._shouldRunHook(V.options,$.request.path))continue;await V.handler($)}if($._response._setBody(J),$.request.method==="HEAD")$._response._setBody(null);$._response._parseResponseIntoString();return}catch(W){await this.handleError($,W)}}async handleError($,W){try{let Y=this.setup._hooks._onError,Z=await Y($,W);$._response._setBody(Z),Y$($,this.setup._configuration.cors),$._response._parseResponseIntoString(),$._response._setHeadersIfNotSet({Date:V$.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":$._response._stringBody.split(`
|
|
94
2
|
|
|
95
|
-
|
|
96
|
-
MIIEjzCCA3egAwIBAgIQe55B/ALCKJDZtdNT8kD6hTANBgkqhkiG9w0BAQsFADBM
|
|
97
|
-
MSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xv
|
|
98
|
-
YmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjAeFw0yMjAxMjYxMjAwMDBaFw0y
|
|
99
|
-
NTAxMjYwMDAwMDBaMFgxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWdu
|
|
100
|
-
IG52LXNhMS4wLAYDVQQDEyVHbG9iYWxTaWduIEF0bGFzIFIzIE9WIFRMUyBDQSAy
|
|
101
|
-
MDIyIFEyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmGmg1LW9b7Lf
|
|
102
|
-
8zDD83yBDTEkt+FOxKJZqF4veWc5KZsQj9HfnUS2e5nj/E+JImlGPsQuoiosLuXD
|
|
103
|
-
BVBNAMcUFa11buFMGMeEMwiTmCXoXRrXQmH0qjpOfKgYc5gHG3BsRGaRrf7VR4eg
|
|
104
|
-
ofNMG9wUBw4/g/TT7+bQJdA4NfE7Y4d5gEryZiBGB/swaX6Jp/8MF4TgUmOWmalK
|
|
105
|
-
dZCKyb4sPGQFRTtElk67F7vU+wdGcrcOx1tDcIB0ncjLPMnaFicagl+daWGsKqTh
|
|
106
|
-
counQb6QJtYHa91KvCfKWocMxQ7OIbB5UARLPmC4CJ1/f8YFm35ebfzAeULYdGXu
|
|
107
|
-
jE9CLor0OwIDAQABo4IBXzCCAVswDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQG
|
|
108
|
-
CCsGAQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQW
|
|
109
|
-
BBSH5Zq7a7B/t95GfJWkDBpA8HHqdjAfBgNVHSMEGDAWgBSP8Et/qC5FJK5NUPpj
|
|
110
|
-
move4t0bvDB7BggrBgEFBQcBAQRvMG0wLgYIKwYBBQUHMAGGImh0dHA6Ly9vY3Nw
|
|
111
|
-
Mi5nbG9iYWxzaWduLmNvbS9yb290cjMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9zZWN1
|
|
112
|
-
cmUuZ2xvYmFsc2lnbi5jb20vY2FjZXJ0L3Jvb3QtcjMuY3J0MDYGA1UdHwQvMC0w
|
|
113
|
-
K6ApoCeGJWh0dHA6Ly9jcmwuZ2xvYmFsc2lnbi5jb20vcm9vdC1yMy5jcmwwIQYD
|
|
114
|
-
VR0gBBowGDAIBgZngQwBAgIwDAYKKwYBBAGgMgoBAjANBgkqhkiG9w0BAQsFAAOC
|
|
115
|
-
AQEAKRic9/f+nmhQU/wz04APZLjgG5OgsuUOyUEZjKVhNGDwxGTvKhyXGGAMW2B/
|
|
116
|
-
3bRi+aElpXwoxu3pL6fkElbX3B0BeS5LoDtxkyiVEBMZ8m+sXbocwlPyxrPbX6mY
|
|
117
|
-
0rVIvnuUeBH8X0L5IwfpNVvKnBIilTbcebfHyXkPezGwz7E1yhUULjJFm2bt0SdX
|
|
118
|
-
y+4X/WeiiYIv+fTVgZZgl+/2MKIsu/qdBJc3f3TvJ8nz+Eax1zgZmww+RSQWeOj3
|
|
119
|
-
15Iw6Z5FX+NwzY/Ab+9PosR5UosSeq+9HhtaxZttXG1nVh+avYPGYddWmiMT90J5
|
|
120
|
-
ZgKnO/Fx2hBgTxhOTMYaD312kg==
|
|
121
|
-
-----END CERTIFICATE-----
|
|
3
|
+
`)[1]?.length.toString()??"0"})}catch(Y){G.error("Error handler failed, this might be an internal error in the YinzerFlow framework: ",Y),$.response.setStatusCode(500),$._response._setBody({success:!1,message:"Internal Server Error"}),Y$($,this.setup._configuration.cors),$._response._parseResponseIntoString(),$._response._setHeadersIfNotSet({Date:V$.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":$._response._stringBody.split(`
|
|
122
4
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp
|
|
126
|
-
Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4
|
|
127
|
-
MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG
|
|
128
|
-
A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI
|
|
129
|
-
hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8
|
|
130
|
-
RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT
|
|
131
|
-
gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm
|
|
132
|
-
KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd
|
|
133
|
-
QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ
|
|
134
|
-
XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw
|
|
135
|
-
DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o
|
|
136
|
-
LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU
|
|
137
|
-
RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp
|
|
138
|
-
jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK
|
|
139
|
-
6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX
|
|
140
|
-
mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs
|
|
141
|
-
Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH
|
|
142
|
-
WD9f
|
|
143
|
-
-----END CERTIFICATE-----`,s7={RedisCloudFixed:{ca:R3},RedisCloudFlexible:{ca:R3}};N3.default=s7});var C=F((j0)=>{var __dirname="/home/patrick/development/npm/yinzerflow/node_modules/ioredis/built/utils";Object.defineProperty(j0,"__esModule",{value:!0});j0.noop=j0.defaults=j0.Debug=j0.getPackageMeta=j0.zipMap=j0.CONNECTION_CLOSED_ERROR_MSG=j0.shuffle=j0.sample=j0.resolveTLSProfile=j0.parseURL=j0.optimizeErrorStack=j0.toArg=j0.convertMapToArray=j0.convertObjectToArray=j0.timeout=j0.packObject=j0.isInt=j0.wrapMultiResult=j0.convertBufferToString=void 0;var n7=j("fs"),o7=j("path"),x3=j("url"),LS=K0();Object.defineProperty(j0,"defaults",{enumerable:!0,get:function(){return LS.defaults}});Object.defineProperty(j0,"noop",{enumerable:!0,get:function(){return LS.noop}});var e7=P3();j0.Debug=e7.default;var SZ=_3();function C3(S,$){if(S instanceof Buffer)return S.toString($);if(Array.isArray(S)){let w=S.length,Z=Array(w);for(let Y=0;Y<w;++Y)Z[Y]=S[Y]instanceof Buffer&&$==="utf8"?S[Y].toString():C3(S[Y],$);return Z}return S}j0.convertBufferToString=C3;function $Z(S){if(!S)return null;let $=[],w=S.length;for(let Z=0;Z<w;++Z){let Y=S[Z];if(Y instanceof Error)$.push([Y]);else $.push([null,Y])}return $}j0.wrapMultiResult=$Z;function v3(S){let $=parseFloat(S);return!isNaN(S)&&($|0)===$}j0.isInt=v3;function wZ(S){let $={},w=S.length;for(let Z=1;Z<w;Z+=2)$[S[Z-1]]=S[Z];return $}j0.packObject=wZ;function ZZ(S,$){let w=null,Z=function(){if(w)clearTimeout(w),w=null,S.apply(this,arguments)};return w=setTimeout(Z,$,Error("timeout")),Z}j0.timeout=ZZ;function YZ(S){let $=[],w=Object.keys(S);for(let Z=0,Y=w.length;Z<Y;Z++)$.push(w[Z],S[w[Z]]);return $}j0.convertObjectToArray=YZ;function yZ(S){let $=[],w=0;return S.forEach(function(Z,Y){$[w]=Y,$[w+1]=Z,w+=2}),$}j0.convertMapToArray=yZ;function WZ(S){if(S===null||typeof S>"u")return"";return String(S)}j0.toArg=WZ;function JZ(S,$,w){let Z=$.split(`
|
|
144
|
-
`),Y="",y;for(y=1;y<Z.length;++y)if(Z[y].indexOf(w)===-1)break;for(let W=y;W<Z.length;++W)Y+=`
|
|
145
|
-
`+Z[W];if(S.stack){let W=S.stack.indexOf(`
|
|
146
|
-
`);S.stack=S.stack.slice(0,W)+Y}return S}j0.optimizeErrorStack=JZ;function XZ(S){if(v3(S))return{port:S};let $=(0,x3.parse)(S,!0,!0);if(!$.slashes&&S[0]!=="/")S="//"+S,$=(0,x3.parse)(S,!0,!0);let w=$.query||{},Z={};if($.auth){let Y=$.auth.indexOf(":");Z.username=Y===-1?$.auth:$.auth.slice(0,Y),Z.password=Y===-1?"":$.auth.slice(Y+1)}if($.pathname)if($.protocol==="redis:"||$.protocol==="rediss:"){if($.pathname.length>1)Z.db=$.pathname.slice(1)}else Z.path=$.pathname;if($.host)Z.host=$.hostname;if($.port)Z.port=$.port;if(typeof w.family==="string"){let Y=Number.parseInt(w.family,10);if(!Number.isNaN(Y))Z.family=Y}return(0,LS.defaults)(Z,w),Z}j0.parseURL=XZ;function QZ(S){let $=S===null||S===void 0?void 0:S.tls;if(typeof $==="string")$={profile:$};let w=SZ.default[$===null||$===void 0?void 0:$.profile];if(w)$=Object.assign({},w,$),delete $.profile,S=Object.assign({},S,{tls:$});return S}j0.resolveTLSProfile=QZ;function UZ(S,$=0){let w=S.length;if($>=w)return null;return S[$+Math.floor(Math.random()*(w-$))]}j0.sample=UZ;function MZ(S){let $=S.length;while($>0){let w=Math.floor(Math.random()*$);$--,[S[$],S[w]]=[S[w],S[$]]}return S}j0.shuffle=MZ;j0.CONNECTION_CLOSED_ERROR_MSG="Connection is closed.";function GZ(S,$){let w=new Map;return S.forEach((Z,Y)=>{w.set(Z,$[Y])}),w}j0.zipMap=GZ;var h1=null;async function qZ(){if(h1)return h1;try{let S=(0,o7.resolve)(__dirname,"..","..","package.json"),$=await n7.promises.readFile(S,"utf8");return h1={version:JSON.parse($).version},h1}catch(S){return h1={version:"error-fetching-version"},h1}}j0.getPackageMeta=qZ});var Y1=F((g3)=>{var __dirname="/home/patrick/development/npm/yinzerflow/node_modules/ioredis/built";Object.defineProperty(g3,"__esModule",{value:!0});var b3=N1(),_Z=a1(),xZ=X1(),I1=C();class l{constructor(S,$=[],w={},Z){if(this.name=S,this.inTransaction=!1,this.isResolved=!1,this.transformed=!1,this.replyEncoding=w.replyEncoding,this.errorStack=w.errorStack,this.args=$.flat(),this.callback=Z,this.initPromise(),w.keyPrefix){let Y=w.keyPrefix instanceof Buffer,y=Y?w.keyPrefix:null;this._iterateKeys((W)=>{if(W instanceof Buffer){if(y===null)y=Buffer.from(w.keyPrefix);return Buffer.concat([y,W])}else if(Y)return Buffer.concat([w.keyPrefix,Buffer.from(String(W))]);return w.keyPrefix+W})}if(w.readOnly)this.isReadOnly=!0}static checkFlag(S,$){return!!this.getFlagMap()[S][$]}static setArgumentTransformer(S,$){this._transformer.argument[S]=$}static setReplyTransformer(S,$){this._transformer.reply[S]=$}static getFlagMap(){if(!this.flagMap)this.flagMap=Object.keys(l.FLAGS).reduce((S,$)=>{return S[$]={},l.FLAGS[$].forEach((w)=>{S[$][w]=!0}),S},{});return this.flagMap}getSlot(){if(typeof this.slot>"u"){let S=this.getKeys()[0];this.slot=S==null?null:_Z(S)}return this.slot}getKeys(){return this._iterateKeys()}toWritable(S){let $,w="*"+(this.args.length+1)+`\r
|
|
147
|
-
$`+Buffer.byteLength(this.name)+`\r
|
|
148
|
-
`+this.name+`\r
|
|
149
|
-
`;if(this.bufferMode){let Z=new p3;Z.push(w);for(let Y=0;Y<this.args.length;++Y){let y=this.args[Y];if(y instanceof Buffer)if(y.length===0)Z.push(`$0\r
|
|
5
|
+
`)[1]?.length.toString()??"0"})}}_handleCors($){if(Y$($,this.setup._configuration.cors))return $._response._parseResponseIntoString(),!0;return!1}async _matchRoute($){let W=this.setup._routeRegistry._findRoute($.request.method,$.request.path);if(!W){let Y=await this.setup._hooks._onNotFound($);return $._response._setBody(Y),$._response._parseResponseIntoString(),null}return W}async _handleBeforeAllHooks($){let W=this.setup._hooks._beforeAll;for(let Y of W){if(!this._shouldRunHook(Y.options,$.request.path))continue;let Z=await Y.handler($);if(Z!==void 0)return $._response._setBody(Z),$._response._parseResponseIntoString(),!0}return!1}async _handleBeforeHooks($,W){for(let Y of W){let Z=await Y($);if(Z!==void 0)return $._response._setBody(Z),$._response._parseResponseIntoString(),!0}return!1}_shouldRunHook($,W){if(!$)return!0;let{routesToInclude:Y,routesToExclude:Z}=$;if(Z.some((Q)=>this._matchesPattern(W,Q)))return!1;if(Y.length===0)return!0;return Y.some((Q)=>this._matchesPattern(W,Q))}_matchesPattern($,W){if(W===$)return!0;if(W.endsWith("/*")){let Y=W.slice(0,-2);return $.startsWith(Y)}return!1}}var c$=["__proto__","constructor","prototype"],a$=($,W)=>{if(!$||!$.trim()||$.trim()==="\x00")return;let Y=Buffer.byteLength($,"utf8");if(Y>W.maxSize)throw G.warn("[SECURITY] JSON request body too large",{size:Y,limit:W.maxSize,sizeMB:Math.round(Y/1024/1024)}),Error(`Request body too large: ${Y} bytes exceeds limit of ${W.maxSize} bytes`);let Z=null;try{Z=JSON.parse($)}catch(Q){let X=Q instanceof Error?Q.message:String(Q);throw Error(`Invalid JSON syntax: ${X}`)}try{O$(Z,W,1)}catch(Q){let X=Q instanceof Error?Q.message:String(Q);throw Error(`JSON security validation failed: ${X}`)}return Z},x1=($,W)=>{if(typeof $==="string"&&$.length>W.maxStringLength)throw Error(`String too long: ${$.length} characters exceeds limit of ${W.maxStringLength}`)},u1=($,W,Y)=>{if($.length>W.maxArrayLength)throw Error(`Array too large: ${$.length} elements exceeds limit of ${W.maxArrayLength}`);for(let Z of $)O$(Z,W,Y+1)},y1=($,W)=>{if($.length>W.maxKeys)throw Error(`Object has too many keys: ${$.length} exceeds limit of ${W.maxKeys}`);if(!W.allowPrototypeProperties){for(let Y of $)if(c$.includes(Y))throw G.warn("[SECURITY] Prototype pollution attempt detected",{property:Y,dangerousProperties:c$}),Error(`Prototype pollution attempt detected: property '${Y}' is not allowed`)}},h1=($,W,Y)=>{let Z=Object.keys($);for(let Q of Z){if(Q.length>W.maxStringLength)throw Error(`Object key too long: '${Q.substring(0,50)}...' exceeds limit of ${W.maxStringLength}`);let X=$[Q];if(typeof X==="string"&&X.length>W.maxStringLength)throw Error(`String value too long: property '${Q}' has ${X.length} characters, exceeds limit of ${W.maxStringLength}`);O$(X,W,Y+1)}},O$=($,W,Y)=>{if(Y>W.maxDepth)throw G.warn("[SECURITY] JSON nesting too deep - potential stack overflow attack",{currentDepth:Y,maxDepth:W.maxDepth}),Error(`JSON nesting too deep: current depth ${Y} exceeds maximum depth of ${W.maxDepth}`);if($===null||typeof $!=="object"){x1($,W);return}if(Array.isArray($)){u1($,W,Y);return}let Z=Object.keys($);y1(Z,W),h1($,W,Y)};var m1=($)=>{let W=$.startsWith(`\r
|
|
6
|
+
`)?$.slice(2):$,Y=W.indexOf(`\r
|
|
150
7
|
\r
|
|
151
|
-
`);
|
|
152
|
-
`),Z.
|
|
153
|
-
`);
|
|
154
|
-
|
|
155
|
-
`)}$=Z.toBuffer()}else{$=w;for(let Z=0;Z<this.args.length;++Z){let Y=this.args[Z];$+="$"+Buffer.byteLength(Y)+`\r
|
|
156
|
-
`+Y+`\r
|
|
157
|
-
`}}return $}stringifyArguments(){for(let S=0;S<this.args.length;++S){let $=this.args[S];if(typeof $==="string");else if($ instanceof Buffer)this.bufferMode=!0;else this.args[S]=(0,I1.toArg)($)}}transformReply(S){if(this.replyEncoding)S=(0,I1.convertBufferToString)(S,this.replyEncoding);let $=l._transformer.reply[this.name];if($)S=$(S);return S}setTimeout(S){if(!this._commandTimeoutTimer)this._commandTimeoutTimer=setTimeout(()=>{if(!this.isResolved)this.reject(Error("Command timed out"))},S)}initPromise(){let S=new Promise(($,w)=>{if(!this.transformed){this.transformed=!0;let Z=l._transformer.argument[this.name];if(Z)this.args=Z(this.args);this.stringifyArguments()}if(this.resolve=this._convertValue($),this.errorStack)this.reject=(Z)=>{w((0,I1.optimizeErrorStack)(Z,this.errorStack.stack,__dirname))};else this.reject=w});this.promise=(0,xZ.default)(S,this.callback)}_iterateKeys(S=($)=>$){if(typeof this.keys>"u"){if(this.keys=[],(0,b3.exists)(this.name)){let $=(0,b3.getKeyIndexes)(this.name,this.args);for(let w of $)this.args[w]=S(this.args[w]),this.keys.push(this.args[w])}}return this.keys}_convertValue(S){return($)=>{try{let w=this._commandTimeoutTimer;if(w)clearTimeout(w),delete this._commandTimeoutTimer;S(this.transformReply($)),this.isResolved=!0}catch(w){this.reject(w)}return this.promise}}}g3.default=l;l.FLAGS={VALID_IN_SUBSCRIBER_MODE:["subscribe","psubscribe","unsubscribe","punsubscribe","ssubscribe","sunsubscribe","ping","quit"],VALID_IN_MONITOR_MODE:["monitor","auth"],ENTER_SUBSCRIBER_MODE:["subscribe","psubscribe","ssubscribe"],EXIT_SUBSCRIBER_MODE:["unsubscribe","punsubscribe","sunsubscribe"],WILL_DISCONNECT:["quit"],HANDSHAKE_COMMANDS:["auth","select","client","readonly","info"],IGNORE_RECONNECT_ON_ERROR:["client"]};l._transformer={argument:{},reply:{}};var h3=function(S){if(S.length===1){if(S[0]instanceof Map)return(0,I1.convertMapToArray)(S[0]);if(typeof S[0]==="object"&&S[0]!==null)return(0,I1.convertObjectToArray)(S[0])}return S},f3=function(S){if(S.length===2){if(S[1]instanceof Map)return[S[0]].concat((0,I1.convertMapToArray)(S[1]));if(typeof S[1]==="object"&&S[1]!==null)return[S[0]].concat((0,I1.convertObjectToArray)(S[1]))}return S};l.setArgumentTransformer("mset",h3);l.setArgumentTransformer("msetnx",h3);l.setArgumentTransformer("hset",f3);l.setArgumentTransformer("hmset",f3);l.setReplyTransformer("hgetall",function(S){if(Array.isArray(S)){let $={};for(let w=0;w<S.length;w+=2){let Z=S[w],Y=S[w+1];if(Z in $)Object.defineProperty($,Z,{value:Y,configurable:!0,enumerable:!0,writable:!0});else $[Z]=Y}return $}return S});class p3{constructor(){this.length=0,this.items=[]}push(S){this.length+=Buffer.byteLength(S),this.items.push(S)}toBuffer(){let S=Buffer.allocUnsafe(this.length),$=0;for(let w of this.items){let Z=Buffer.byteLength(w);Buffer.isBuffer(w)?w.copy(S,$):S.write(w,$,Z),$+=Z}return S}}});var m3=F((u3)=>{Object.defineProperty(u3,"__esModule",{value:!0});var vZ=O1();class IS extends vZ.RedisError{constructor(S,$){super(S);this.lastNodeError=$,Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}u3.default=IS;IS.defaultMessage="Failed to refresh slots cache."});var A0=F((l3)=>{Object.defineProperty(l3,"__esModule",{value:!0});var hZ=j("stream");class d3 extends hZ.Readable{constructor(S){super(S);this.opt=S,this._redisCursor="0",this._redisDrained=!1}_read(){if(this._redisDrained){this.push(null);return}let S=[this._redisCursor];if(this.opt.key)S.unshift(this.opt.key);if(this.opt.match)S.push("MATCH",this.opt.match);if(this.opt.type)S.push("TYPE",this.opt.type);if(this.opt.count)S.push("COUNT",String(this.opt.count));if(this.opt.noValues)S.push("NOVALUES");this.opt.redis[this.opt.command](S,($,w)=>{if($){this.emit("error",$);return}if(this._redisCursor=w[0]instanceof Buffer?w[0].toString():w[0],this._redisCursor==="0")this._redisDrained=!0;this.push(w[1])})}close(){this._redisDrained=!0}}l3.default=d3});var e3=F((r3)=>{Object.defineProperty(r3,"__esModule",{value:!0});r3.executeWithAutoPipelining=r3.getFirstValueInFlattenedArray=r3.shouldUseAutoPipelining=r3.notAllowedAutoPipelineCommands=r3.kCallbacks=r3.kExec=void 0;var t3=K0(),pZ=a1(),c3=X1();r3.kExec=Symbol("exec");r3.kCallbacks=Symbol("callbacks");r3.notAllowedAutoPipelineCommands=["auth","info","script","quit","cluster","pipeline","multi","subscribe","psubscribe","unsubscribe","unpsubscribe","select","client"];function i3(S,$){if(S._runningAutoPipelines.has($))return;if(!S._autoPipelines.has($))return;S._runningAutoPipelines.add($);let w=S._autoPipelines.get($);S._autoPipelines.delete($);let Z=w[r3.kCallbacks];w[r3.kCallbacks]=null,w.exec(function(Y,y){if(S._runningAutoPipelines.delete($),Y)for(let W=0;W<Z.length;W++)process.nextTick(Z[W],Y);else for(let W=0;W<Z.length;W++)process.nextTick(Z[W],...y[W]);if(S._autoPipelines.has($))i3(S,$)})}function gZ(S,$,w){return $&&S.options.enableAutoPipelining&&!S.isPipeline&&!r3.notAllowedAutoPipelineCommands.includes(w)&&!S.options.autoPipeliningIgnoredCommands.includes(w)}r3.shouldUseAutoPipelining=gZ;function a3(S){for(let $=0;$<S.length;$++){let w=S[$];if(typeof w==="string")return w;else if(Array.isArray(w)||(0,t3.isArguments)(w)){if(w.length===0)continue;return w[0]}let Z=[w].flat();if(Z.length>0)return Z[0]}return}r3.getFirstValueInFlattenedArray=a3;function s3(S,$,w,Z,Y){if(S.isCluster&&!S.slots.length){if(S.status==="wait")S.connect().catch(t3.noop);return(0,c3.default)(new Promise(function(U,Q){S.delayUntilReady((M)=>{if(M){Q(M);return}s3(S,$,w,Z,null).then(U,Q)})}),Y)}let y=S.options.keyPrefix||"",W=S.isCluster?S.slots[pZ(`${y}${a3(Z)}`)].join(","):"main";if(!S._autoPipelines.has(W)){let U=S.pipeline();U[r3.kExec]=!1,U[r3.kCallbacks]=[],S._autoPipelines.set(W,U)}let J=S._autoPipelines.get(W);if(!J[r3.kExec])J[r3.kExec]=!0,setImmediate(i3,S,W);let X=new Promise(function(U,Q){if(J[r3.kCallbacks].push(function(M,G){if(M){Q(M);return}U(G)}),$==="call")Z.unshift(w);J[$](...Z)});return(0,c3.default)(X,Y)}r3.executeWithAutoPipelining=s3});var w4=F(($4)=>{Object.defineProperty($4,"__esModule",{value:!0});var dZ=j("crypto"),lZ=Y1(),cZ=X1();class S4{constructor(S,$=null,w="",Z=!1){this.lua=S,this.numberOfKeys=$,this.keyPrefix=w,this.readOnly=Z,this.sha=(0,dZ.createHash)("sha1").update(S).digest("hex");let Y=this.sha,y=new WeakSet;this.Command=class extends lZ.default{toWritable(J){let X=this.reject;if(this.reject=(U)=>{if(U.message.indexOf("NOSCRIPT")!==-1)y.delete(J);X.call(this,U)},!y.has(J))y.add(J),this.name="eval",this.args[0]=S;else if(this.name==="eval")this.name="evalsha",this.args[0]=Y;return super.toWritable(J)}}}execute(S,$,w,Z){if(typeof this.numberOfKeys==="number")$.unshift(this.numberOfKeys);if(this.keyPrefix)w.keyPrefix=this.keyPrefix;if(this.readOnly)w.readOnly=!0;let Y=new this.Command("evalsha",[this.sha,...$],w);return Y.promise=Y.promise.catch((y)=>{if(y.message.indexOf("NOSCRIPT")===-1)throw y;let W=new this.Command("evalsha",[this.sha,...$],w);return(S.isPipeline?S.redis:S).sendCommand(W)}),(0,cZ.default)(Y.promise,Z),S.sendCommand(Y)}}$4.default=S4});var R0=F((Y4)=>{Object.defineProperty(Y4,"__esModule",{value:!0});var iZ=N1(),P0=e3(),aZ=Y1(),sZ=w4();class M1{constructor(){this.options={},this.scriptsSet={},this.addedBuiltinSet=new Set}getBuiltinCommands(){return jS.slice(0)}createBuiltinCommand(S){return{string:U1(null,S,"utf8"),buffer:U1(null,S,null)}}addBuiltinCommand(S){this.addedBuiltinSet.add(S),this[S]=U1(S,S,"utf8"),this[S+"Buffer"]=U1(S+"Buffer",S,null)}defineCommand(S,$){let w=new sZ.default($.lua,$.numberOfKeys,this.options.keyPrefix,$.readOnly);this.scriptsSet[S]=w,this[S]=Z4(S,S,w,"utf8"),this[S+"Buffer"]=Z4(S+"Buffer",S,w,null)}sendCommand(S,$,w){throw Error('"sendCommand" is not implemented')}}var jS=iZ.list.filter((S)=>S!=="monitor");jS.push("sentinel");jS.forEach(function(S){M1.prototype[S]=U1(S,S,"utf8"),M1.prototype[S+"Buffer"]=U1(S+"Buffer",S,null)});M1.prototype.call=U1("call","utf8");M1.prototype.callBuffer=U1("callBuffer",null);M1.prototype.send_command=M1.prototype.call;function U1(S,$,w){if(typeof w>"u")w=$,$=null;return function(...Z){let Y=$||Z.shift(),y=Z[Z.length-1];if(typeof y==="function")Z.pop();else y=void 0;let W={errorStack:this.options.showFriendlyErrorStack?Error():void 0,keyPrefix:this.options.keyPrefix,replyEncoding:w};if(!(0,P0.shouldUseAutoPipelining)(this,S,Y))return this.sendCommand(new aZ.default(Y,Z,W,y));return(0,P0.executeWithAutoPipelining)(this,S,Y,Z,y)}}function Z4(S,$,w,Z){return function(...Y){let y=typeof Y[Y.length-1]==="function"?Y.pop():void 0,W={replyEncoding:Z};if(this.options.showFriendlyErrorStack)W.errorStack=Error();if(!(0,P0.shouldUseAutoPipelining)(this,S,$))return w.execute(this,Y,W,y);return(0,P0.executeWithAutoPipelining)(this,S,$,Y,y)}}Y4.default=M1});var TS=F((X4)=>{Object.defineProperty(X4,"__esModule",{value:!0});var AS=a1(),y4=N1(),W4=X1(),nZ=j("util"),oZ=Y1(),eZ=C(),SY=R0();function $Y(S,$){let w=AS($[0]),Z=S._groupsBySlot[w];for(let Y=1;Y<$.length;Y++)if(S._groupsBySlot[AS($[Y])]!==Z)return-1;return w}class j1 extends SY.default{constructor(S){super();this.redis=S,this.isPipeline=!0,this.replyPending=0,this._queue=[],this._result=[],this._transactions=0,this._shaToScript={},this.isCluster=this.redis.constructor.name==="Cluster"||this.redis.isCluster,this.options=S.options,Object.keys(S.scriptsSet).forEach((w)=>{let Z=S.scriptsSet[w];this._shaToScript[Z.sha]=Z,this[w]=S[w],this[w+"Buffer"]=S[w+"Buffer"]}),S.addedBuiltinSet.forEach((w)=>{this[w]=S[w],this[w+"Buffer"]=S[w+"Buffer"]}),this.promise=new Promise((w,Z)=>{this.resolve=w,this.reject=Z});let $=this;Object.defineProperty(this,"length",{get:function(){return $._queue.length}})}fillResult(S,$){if(this._queue[$].name==="exec"&&Array.isArray(S[1])){let Z=S[1].length;for(let Y=0;Y<Z;Y++){if(S[1][Y]instanceof Error)continue;let y=this._queue[$-(Z-Y)];try{S[1][Y]=y.transformReply(S[1][Y])}catch(W){S[1][Y]=W}}}if(this._result[$]=S,--this.replyPending)return;if(this.isCluster){let Z=!0,Y;for(let y=0;y<this._result.length;++y){let W=this._result[y][0],J=this._queue[y];if(W){if(J.name==="exec"&&W.message==="EXECABORT Transaction discarded because of previous errors.")continue;if(!Y)Y={name:W.name,message:W.message};else if(Y.name!==W.name||Y.message!==W.message){Z=!1;break}}else if(!J.inTransaction){if(!((0,y4.exists)(J.name)&&(0,y4.hasFlag)(J.name,"readonly"))){Z=!1;break}}}if(Y&&Z){let y=this,W=Y.message.split(" "),J=this._queue,X=!1;this._queue=[];for(let G=0;G<J.length;++G){if(W[0]==="ASK"&&!X&&J[G].name!=="asking"&&(!J[G-1]||J[G-1].name!=="asking")){let O=new oZ.default("asking");O.ignore=!0,this.sendCommand(O)}J[G].initPromise(),this.sendCommand(J[G]),X=J[G].inTransaction}let U=!0;if(typeof this.leftRedirections>"u")this.leftRedirections={};let Q=function(){y.exec()},M=this.redis;if(M.handleError(Y,this.leftRedirections,{moved:function(G,O){y.preferKey=O,M.slots[W[1]]=[O],M._groupsBySlot[W[1]]=M._groupsIds[M.slots[W[1]].join(";")],M.refreshSlotsCache(),y.exec()},ask:function(G,O){y.preferKey=O,y.exec()},tryagain:Q,clusterDown:Q,connectionClosed:Q,maxRedirections:()=>{U=!1},defaults:()=>{U=!1}}),U)return}}let w=0;for(let Z=0;Z<this._queue.length-w;++Z){if(this._queue[Z+w].ignore)w+=1;this._result[Z]=this._result[Z+w]}this.resolve(this._result.slice(0,this._result.length-w))}sendCommand(S){if(this._transactions>0)S.inTransaction=!0;let $=this._queue.length;return S.pipelineIndex=$,S.promise.then((w)=>{this.fillResult([null,w],$)}).catch((w)=>{this.fillResult([w],$)}),this._queue.push(S),this}addBatch(S){let $,w,Z;for(let Y=0;Y<S.length;++Y)$=S[Y],w=$[0],Z=$.slice(1),this[w].apply(this,Z);return this}}X4.default=j1;var wY=j1.prototype.multi;j1.prototype.multi=function(){return this._transactions+=1,wY.apply(this,arguments)};var J4=j1.prototype.execBuffer;j1.prototype.execBuffer=(0,nZ.deprecate)(function(){if(this._transactions>0)this._transactions-=1;return J4.apply(this,arguments)},"Pipeline#execBuffer: Use Pipeline#exec instead");j1.prototype.exec=function(S){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(eZ.noop);if(S&&!this.nodeifiedPromise)this.nodeifiedPromise=!0,(0,W4.default)(this.promise,S);return this.redis.delayUntilReady((Y)=>{if(Y){this.reject(Y);return}this.exec(S)}),this.promise}if(this._transactions>0)return this._transactions-=1,J4.apply(this,arguments);if(!this.nodeifiedPromise)this.nodeifiedPromise=!0,(0,W4.default)(this.promise,S);if(!this._queue.length)this.resolve([]);let $;if(this.isCluster){let Y=[];for(let y=0;y<this._queue.length;y++){let W=this._queue[y].getKeys();if(W.length)Y.push(W[0]);if(W.length&&AS.generateMulti(W)<0)return this.reject(Error("All the keys in a pipeline command should belong to the same slot")),this.promise}if(Y.length){if($=$Y(this.redis,Y),$<0)return this.reject(Error("All keys in the pipeline should belong to the same slots allocation group")),this.promise}else $=Math.random()*16384|0}let w=this;return Z(),this.promise;function Z(){let Y=w.replyPending=w._queue.length,y;if(w.isCluster)y={slot:$,redis:w.redis.connectionPool.nodes.all[w.preferKey]};let W="",J,X={isPipeline:!0,destination:w.isCluster?y:{redis:w.redis},write(U){if(typeof U!=="string"){if(!J)J=[];if(W)J.push(Buffer.from(W,"utf8")),W="";J.push(U)}else W+=U;if(!--Y){if(J){if(W)J.push(Buffer.from(W,"utf8"));X.destination.redis.stream.write(Buffer.concat(J))}else X.destination.redis.stream.write(W);Y=w._queue.length,W="",J=void 0}}};for(let U=0;U<w._queue.length;++U)w.redis.sendCommand(w._queue[U],X,y);return w.promise}}});var NS=F((U4)=>{Object.defineProperty(U4,"__esModule",{value:!0});U4.addTransactionSupport=void 0;var PS=C(),RS=X1(),Q4=TS();function YY(S){S.pipeline=function(Z){let Y=new Q4.default(this);if(Array.isArray(Z))Y.addBatch(Z);return Y};let{multi:$}=S;S.multi=function(Z,Y){if(typeof Y>"u"&&!Array.isArray(Z))Y=Z,Z=null;if(Y&&Y.pipeline===!1)return $.call(this);let y=new Q4.default(this);if(y.multi(),Array.isArray(Z))y.addBatch(Z);let W=y.exec;y.exec=function(X){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(PS.noop);return(0,RS.default)(new Promise((Q,M)=>{this.redis.delayUntilReady((G)=>{if(G){M(G);return}this.exec(y).then(Q,M)})}),X)}if(this._transactions>0)W.call(y);if(this.nodeifiedPromise)return W.call(y);let U=W.call(y);return(0,RS.default)(U.then(function(Q){let M=Q[Q.length-1];if(typeof M>"u")throw Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.");if(M[0]){M[0].previousErrors=[];for(let G=0;G<Q.length-1;++G)if(Q[G][0])M[0].previousErrors.push(Q[G][0]);throw M[0]}return(0,PS.wrapMultiResult)(M[1])}),X)};let{execBuffer:J}=y;return y.execBuffer=function(X){if(this._transactions>0)J.call(y);return y.exec(X)},y};let{exec:w}=S;S.exec=function(Z){return(0,RS.default)(w.call(this).then(function(Y){if(Array.isArray(Y))Y=(0,PS.wrapMultiResult)(Y);return Y}),Z)}}U4.addTransactionSupport=YY});var _S=F((G4)=>{Object.defineProperty(G4,"__esModule",{value:!0});function yY(S,$){Object.getOwnPropertyNames($.prototype).forEach((w)=>{Object.defineProperty(S.prototype,w,Object.getOwnPropertyDescriptor($.prototype,w))})}G4.default=yY});var F4=F((V4)=>{Object.defineProperty(V4,"__esModule",{value:!0});V4.DEFAULT_CLUSTER_OPTIONS=void 0;var q4=j("dns");V4.DEFAULT_CLUSTER_OPTIONS={clusterRetryStrategy:(S)=>Math.min(100+S*2,2000),enableOfflineQueue:!0,enableReadyCheck:!0,scaleReads:"master",maxRedirections:16,retryDelayOnMoved:0,retryDelayOnFailover:100,retryDelayOnClusterDown:100,retryDelayOnTryAgain:100,slotsRefreshTimeout:1000,useSRVRecords:!1,resolveSrv:q4.resolveSrv,dnsLookup:q4.lookup,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],shardedSubscribers:!1}});var e1=F((B4)=>{Object.defineProperty(B4,"__esModule",{value:!0});B4.getConnectionName=B4.weightSrvRecords=B4.groupSrvRecords=B4.getUniqueHostnamesFromOptions=B4.normalizeNodeOptions=B4.nodeKeyToRedisOptions=B4.getNodeKey=void 0;var z4=C(),JY=j("net");function XY(S){return S.port=S.port||6379,S.host=S.host||"127.0.0.1",S.host+":"+S.port}B4.getNodeKey=XY;function QY(S){let $=S.lastIndexOf(":");if($===-1)throw Error(`Invalid node key ${S}`);return{host:S.slice(0,$),port:Number(S.slice($+1))}}B4.nodeKeyToRedisOptions=QY;function UY(S){return S.map(($)=>{let w={};if(typeof $==="object")Object.assign(w,$);else if(typeof $==="string")Object.assign(w,(0,z4.parseURL)($));else if(typeof $==="number")w.port=$;else throw Error("Invalid argument "+$);if(typeof w.port==="string")w.port=parseInt(w.port,10);if(delete w.db,!w.port)w.port=6379;if(!w.host)w.host="127.0.0.1";return(0,z4.resolveTLSProfile)(w)})}B4.normalizeNodeOptions=UY;function MY(S){let $={};return S.forEach((w)=>{$[w.host]=!0}),Object.keys($).filter((w)=>!(0,JY.isIP)(w))}B4.getUniqueHostnamesFromOptions=MY;function GY(S){let $={};for(let w of S)if(!$.hasOwnProperty(w.priority))$[w.priority]={totalWeight:w.weight,records:[w]};else $[w.priority].totalWeight+=w.weight,$[w.priority].records.push(w);return $}B4.groupSrvRecords=GY;function qY(S){if(S.records.length===1)return S.totalWeight=0,S.records.shift();let $=Math.floor(Math.random()*(S.totalWeight+S.records.length)),w=0;for(let[Z,Y]of S.records.entries())if(w+=1+Y.weight,w>$)return S.totalWeight-=Y.weight,S.records.splice(Z,1),Y}B4.weightSrvRecords=qY;function VY(S,$){let w=`ioredis-cluster(${S})`;return $?`${w}:${$}`:w}B4.getConnectionName=VY});var CS=F((O4)=>{Object.defineProperty(O4,"__esModule",{value:!0});var E4=e1(),xS=C(),KY=G1(),S1=(0,xS.Debug)("cluster:subscriber");class K4{constructor(S,$,w=!1){this.connectionPool=S,this.emitter=$,this.isSharded=w,this.started=!1,this.subscriber=null,this.slotRange=[],this.onSubscriberEnd=()=>{if(!this.started){S1("subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.");return}S1("subscriber has disconnected, selecting a new one..."),this.selectSubscriber()},this.connectionPool.on("-node",(Z,Y)=>{if(!this.started||!this.subscriber)return;if((0,E4.getNodeKey)(this.subscriber.options)===Y)S1("subscriber has left, selecting a new one..."),this.selectSubscriber()}),this.connectionPool.on("+node",()=>{if(!this.started||this.subscriber)return;S1("a new node is discovered and there is no subscriber, selecting a new one..."),this.selectSubscriber()})}getInstance(){return this.subscriber}associateSlotRange(S){if(this.isSharded)this.slotRange=S;return this.slotRange}start(){this.started=!0,this.selectSubscriber(),S1("started")}stop(){if(this.started=!1,this.subscriber)this.subscriber.disconnect(),this.subscriber=null}isStarted(){return this.started}selectSubscriber(){let S=this.lastActiveSubscriber;if(S)S.off("end",this.onSubscriberEnd),S.disconnect();if(this.subscriber)this.subscriber.off("end",this.onSubscriberEnd),this.subscriber.disconnect();let $=(0,xS.sample)(this.connectionPool.getNodes());if(!$){S1("selecting subscriber failed since there is no node discovered in the cluster yet"),this.subscriber=null;return}let{options:w}=$;S1("selected a subscriber %s:%s",w.host,w.port);let Z="subscriber";if(this.isSharded)Z="ssubscriber";this.subscriber=new KY.default({port:w.port,host:w.host,username:w.username,password:w.password,enableReadyCheck:!0,connectionName:(0,E4.getConnectionName)(Z,w.connectionName),lazyConnect:!0,tls:w.tls,retryStrategy:null}),this.subscriber.on("error",xS.noop),this.subscriber.on("moved",()=>{this.emitter.emit("forceRefresh")}),this.subscriber.once("end",this.onSubscriberEnd);let Y={subscribe:[],psubscribe:[],ssubscribe:[]};if(S){let y=S.condition||S.prevCondition;if(y&&y.subscriber)Y.subscribe=y.subscriber.channels("subscribe"),Y.psubscribe=y.subscriber.channels("psubscribe"),Y.ssubscribe=y.subscriber.channels("ssubscribe")}if(Y.subscribe.length||Y.psubscribe.length||Y.ssubscribe.length){let y=0;for(let W of["subscribe","psubscribe","ssubscribe"]){let J=Y[W];if(J.length==0)continue;if(S1("%s %d channels",W,J.length),W==="ssubscribe")for(let X of J)y+=1,this.subscriber[W](X).then(()=>{if(!--y)this.lastActiveSubscriber=this.subscriber}).catch(()=>{S1("failed to ssubscribe to channel: %s",X)});else y+=1,this.subscriber[W](J).then(()=>{if(!--y)this.lastActiveSubscriber=this.subscriber}).catch(()=>{S1("failed to %s %d channels",W,J.length)})}}else this.lastActiveSubscriber=this.subscriber;for(let y of["message","messageBuffer"])this.subscriber.on(y,(W,J)=>{this.emitter.emit(y,W,J)});for(let y of["pmessage","pmessageBuffer"])this.subscriber.on(y,(W,J,X)=>{this.emitter.emit(y,W,J,X)});if(this.isSharded==!0)for(let y of["smessage","smessageBuffer"])this.subscriber.on(y,(W,J)=>{this.emitter.emit(y,W,J)})}}O4.default=K4});var bS=F((L4)=>{Object.defineProperty(L4,"__esModule",{value:!0});var DY=j("events"),N0=C(),vS=e1(),LY=G1(),S0=(0,N0.Debug)("cluster:connectionPool");class D4 extends DY.EventEmitter{constructor(S){super();this.redisOptions=S,this.nodes={all:{},master:{},slave:{}},this.specifiedOptions={}}getNodes(S="all"){let $=this.nodes[S];return Object.keys($).map((w)=>$[w])}getInstanceByKey(S){return this.nodes.all[S]}getSampleInstance(S){let $=Object.keys(this.nodes[S]),w=(0,N0.sample)($);return this.nodes[S][w]}addMasterNode(S){let $=(0,vS.getNodeKey)(S.options),w=this.createRedisFromOptions(S,S.options.readOnly);if(!S.options.readOnly)return this.nodes.all[$]=w,this.nodes.master[$]=w,!0;return!1}createRedisFromOptions(S,$){return new LY.default((0,N0.defaults)({retryStrategy:null,enableOfflineQueue:!0,readOnly:$},S,this.redisOptions,{lazyConnect:!0}))}findOrCreate(S,$=!1){let w=(0,vS.getNodeKey)(S);if($=Boolean($),this.specifiedOptions[w])Object.assign(S,this.specifiedOptions[w]);else this.specifiedOptions[w]=S;let Z;if(this.nodes.all[w]){if(Z=this.nodes.all[w],Z.options.readOnly!==$)if(Z.options.readOnly=$,S0("Change role of %s to %s",w,$?"slave":"master"),Z[$?"readonly":"readwrite"]().catch(N0.noop),$)delete this.nodes.master[w],this.nodes.slave[w]=Z;else delete this.nodes.slave[w],this.nodes.master[w]=Z}else S0("Connecting to %s as %s",w,$?"slave":"master"),Z=this.createRedisFromOptions(S,$),this.nodes.all[w]=Z,this.nodes[$?"slave":"master"][w]=Z,Z.once("end",()=>{if(this.removeNode(w),this.emit("-node",Z,w),!Object.keys(this.nodes.all).length)this.emit("drain")}),this.emit("+node",Z,w),Z.on("error",function(Y){this.emit("nodeError",Y,w)});return Z}reset(S){S0("Reset with %O",S);let $={};S.forEach((w)=>{let Z=(0,vS.getNodeKey)(w);if(!(w.readOnly&&$[Z]))$[Z]=w}),Object.keys(this.nodes.all).forEach((w)=>{if(!$[w])S0("Disconnect %s because the node does not hold any slot",w),this.nodes.all[w].disconnect(),this.removeNode(w)}),Object.keys($).forEach((w)=>{let Z=$[w];this.findOrCreate(Z,Z.readOnly)})}removeNode(S){let{nodes:$}=this;if($.all[S])S0("Remove %s from the pool",S),delete $.all[S];delete $.master[S],delete $.slave[S]}}L4.default=D4});var _0=F((a9,I4)=>{function A(S,w){var w=w||{};if(this._capacity=w.capacity,this._head=0,this._tail=0,Array.isArray(S))this._fromArray(S);else this._capacityMask=3,this._list=[,,,,]}A.prototype.peekAt=function($){var w=$;if(w!==(w|0))return;var Z=this.size();if(w>=Z||w<-Z)return;if(w<0)w+=Z;return w=this._head+w&this._capacityMask,this._list[w]};A.prototype.get=function($){return this.peekAt($)};A.prototype.peek=function(){if(this._head===this._tail)return;return this._list[this._head]};A.prototype.peekFront=function(){return this.peek()};A.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(A.prototype,"length",{get:function(){return this.size()}});A.prototype.size=function(){if(this._head===this._tail)return 0;if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};A.prototype.unshift=function($){if(arguments.length===0)return this.size();var w=this._list.length;if(this._head=this._head-1+w&this._capacityMask,this._list[this._head]=$,this._tail===this._head)this._growArray();if(this._capacity&&this.size()>this._capacity)this.pop();if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};A.prototype.shift=function(){var $=this._head;if($===this._tail)return;var w=this._list[$];if(this._list[$]=void 0,this._head=$+1&this._capacityMask,$<2&&this._tail>1e4&&this._tail<=this._list.length>>>2)this._shrinkArray();return w};A.prototype.push=function($){if(arguments.length===0)return this.size();var w=this._tail;if(this._list[w]=$,this._tail=w+1&this._capacityMask,this._tail===this._head)this._growArray();if(this._capacity&&this.size()>this._capacity)this.shift();if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};A.prototype.pop=function(){var $=this._tail;if($===this._head)return;var w=this._list.length;this._tail=$-1+w&this._capacityMask;var Z=this._list[this._tail];if(this._list[this._tail]=void 0,this._head<2&&$>1e4&&$<=w>>>2)this._shrinkArray();return Z};A.prototype.removeOne=function($){var w=$;if(w!==(w|0))return;if(this._head===this._tail)return;var Z=this.size(),Y=this._list.length;if(w>=Z||w<-Z)return;if(w<0)w+=Z;w=this._head+w&this._capacityMask;var y=this._list[w],W;if($<Z/2){for(W=$;W>0;W--)this._list[w]=this._list[w=w-1+Y&this._capacityMask];this._list[w]=void 0,this._head=this._head+1+Y&this._capacityMask}else{for(W=Z-1-$;W>0;W--)this._list[w]=this._list[w=w+1+Y&this._capacityMask];this._list[w]=void 0,this._tail=this._tail-1+Y&this._capacityMask}return y};A.prototype.remove=function($,w){var Z=$,Y,y=w;if(Z!==(Z|0))return;if(this._head===this._tail)return;var W=this.size(),J=this._list.length;if(Z>=W||Z<-W||w<1)return;if(Z<0)Z+=W;if(w===1||!w)return Y=[,],Y[0]=this.removeOne(Z),Y;if(Z===0&&Z+w>=W)return Y=this.toArray(),this.clear(),Y;if(Z+w>W)w=W-Z;var X;Y=Array(w);for(X=0;X<w;X++)Y[X]=this._list[this._head+Z+X&this._capacityMask];if(Z=this._head+Z&this._capacityMask,$+w===W){this._tail=this._tail-w+J&this._capacityMask;for(X=w;X>0;X--)this._list[Z=Z+1+J&this._capacityMask]=void 0;return Y}if($===0){this._head=this._head+w+J&this._capacityMask;for(X=w-1;X>0;X--)this._list[Z=Z+1+J&this._capacityMask]=void 0;return Y}if(Z<W/2){this._head=this._head+$+w+J&this._capacityMask;for(X=$;X>0;X--)this.unshift(this._list[Z=Z-1+J&this._capacityMask]);Z=this._head-1+J&this._capacityMask;while(y>0)this._list[Z=Z-1+J&this._capacityMask]=void 0,y--;if($<0)this._tail=Z}else{this._tail=Z,Z=Z+w+J&this._capacityMask;for(X=W-(w+$);X>0;X--)this.push(this._list[Z++]);Z=this._tail;while(y>0)this._list[Z=Z+1+J&this._capacityMask]=void 0,y--}if(this._head<2&&this._tail>1e4&&this._tail<=J>>>2)this._shrinkArray();return Y};A.prototype.splice=function($,w){var Z=$;if(Z!==(Z|0))return;var Y=this.size();if(Z<0)Z+=Y;if(Z>Y)return;if(arguments.length>2){var y,W,J,X=arguments.length,U=this._list.length,Q=2;if(!Y||Z<Y/2){W=Array(Z);for(y=0;y<Z;y++)W[y]=this._list[this._head+y&this._capacityMask];if(w===0){if(J=[],Z>0)this._head=this._head+Z+U&this._capacityMask}else J=this.remove(Z,w),this._head=this._head+Z+U&this._capacityMask;while(X>Q)this.unshift(arguments[--X]);for(y=Z;y>0;y--)this.unshift(W[y-1])}else{W=Array(Y-(Z+w));var M=W.length;for(y=0;y<M;y++)W[y]=this._list[this._head+Z+w+y&this._capacityMask];if(w===0){if(J=[],Z!=Y)this._tail=this._head+Z+U&this._capacityMask}else J=this.remove(Z,w),this._tail=this._tail-M+U&this._capacityMask;while(Q<X)this.push(arguments[Q++]);for(y=0;y<M;y++)this.push(W[y])}return J}else return this.remove(Z,w)};A.prototype.clear=function(){this._list=Array(this._list.length),this._head=0,this._tail=0};A.prototype.isEmpty=function(){return this._head===this._tail};A.prototype.toArray=function(){return this._copyArray(!1)};A.prototype._fromArray=function($){var w=$.length,Z=this._nextPowerOf2(w);this._list=Array(Z),this._capacityMask=Z-1,this._tail=w;for(var Y=0;Y<w;Y++)this._list[Y]=$[Y]};A.prototype._copyArray=function($,w){var Z=this._list,Y=Z.length,y=this.length;if(w=w|y,w==y&&this._head<this._tail)return this._list.slice(this._head,this._tail);var W=Array(w),J=0,X;if($||this._head>this._tail){for(X=this._head;X<Y;X++)W[J++]=Z[X];for(X=0;X<this._tail;X++)W[J++]=Z[X]}else for(X=this._head;X<this._tail;X++)W[J++]=Z[X];return W};A.prototype._growArray=function(){if(this._head!=0){var $=this._copyArray(!0,this._list.length<<1);this._tail=this._list.length,this._head=0,this._list=$}else this._tail=this._list.length,this._list.length<<=1;this._capacityMask=this._capacityMask<<1|1};A.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};A.prototype._nextPowerOf2=function($){var w=Math.log($)/Math.log(2),Z=1<<w+1;return Math.max(Z,4)};I4.exports=A});var T4=F((A4)=>{Object.defineProperty(A4,"__esModule",{value:!0});var jY=C(),AY=_0(),TY=(0,jY.Debug)("delayqueue");class j4{constructor(){this.queues={},this.timeouts={}}push(S,$,w){let Z=w.callback||process.nextTick;if(!this.queues[S])this.queues[S]=new AY;if(this.queues[S].push($),!this.timeouts[S])this.timeouts[S]=setTimeout(()=>{Z(()=>{this.timeouts[S]=null,this.execute(S)})},w.timeout)}execute(S){let $=this.queues[S];if(!$)return;let{length:w}=$;if(!w)return;TY("send %d commands in %s queue",w,S),this.queues[S]=null;while($.length>0)$.shift()()}}A4.default=j4});var x4=F((_4)=>{Object.defineProperty(_4,"__esModule",{value:!0});var RY=C(),NY=CS(),_Y=bS(),P4=e1(),x0=a1(),R4=(0,RY.Debug)("cluster:subscriberGroup");class N4{constructor(S,$){this.cluster=S,this.shardedSubscribers=new Map,this.clusterSlots=[],this.subscriberToSlotsIndex=new Map,this.channels=new Map,S.on("+node",(w)=>{this._addSubscriber(w)}),S.on("-node",(w)=>{this._removeSubscriber(w)}),S.on("refresh",()=>{this._refreshSlots(S)}),S.on("forceRefresh",()=>{$()})}getResponsibleSubscriber(S){let $=this.clusterSlots[S][0];return this.shardedSubscribers.get($)}addChannels(S){let $=x0(S[0]);S.forEach((Z)=>{if(x0(Z)!=$)return-1});let w=this.channels.get($);if(!w)this.channels.set($,S);else this.channels.set($,w.concat(S));return[...this.channels.values()].flatMap((Z)=>Z).length}removeChannels(S){let $=x0(S[0]);S.forEach((Z)=>{if(x0(Z)!=$)return-1});let w=this.channels.get($);if(w){let Z=w.filter((Y)=>!S.includes(Y));this.channels.set($,Z)}return[...this.channels.values()].flatMap((Z)=>Z).length}stop(){for(let S of this.shardedSubscribers.values())S.stop()}start(){for(let S of this.shardedSubscribers.values())if(!S.isStarted())S.start()}_addSubscriber(S){let $=new _Y.default(S.options);if($.addMasterNode(S)){let w=new NY.default($,this.cluster,!0),Z=(0,P4.getNodeKey)(S.options);return this.shardedSubscribers.set(Z,w),w.start(),this._resubscribe(),this.cluster.emit("+subscriber"),w}return null}_removeSubscriber(S){let $=(0,P4.getNodeKey)(S.options),w=this.shardedSubscribers.get($);if(w)w.stop(),this.shardedSubscribers.delete($),this._resubscribe(),this.cluster.emit("-subscriber");return this.shardedSubscribers}_refreshSlots(S){if(this._slotsAreEqual(S.slots))R4("Nothing to refresh because the new cluster map is equal to the previous one.");else{R4("Refreshing the slots of the subscriber group."),this.subscriberToSlotsIndex=new Map;for(let $=0;$<S.slots.length;$++){let w=S.slots[$][0];if(!this.subscriberToSlotsIndex.has(w))this.subscriberToSlotsIndex.set(w,[]);this.subscriberToSlotsIndex.get(w).push(Number($))}return this._resubscribe(),this.clusterSlots=JSON.parse(JSON.stringify(S.slots)),this.cluster.emit("subscribersReady"),!0}return!1}_resubscribe(){if(this.shardedSubscribers)this.shardedSubscribers.forEach((S,$)=>{let w=this.subscriberToSlotsIndex.get($);if(w)S.associateSlotRange(w),w.forEach((Z)=>{let Y=S.getInstance(),y=this.channels.get(Z);if(y&&y.length>0){if(Y)Y.ssubscribe(y),Y.on("ready",()=>{Y.ssubscribe(y)})}})})}_slotsAreEqual(S){if(this.clusterSlots===void 0)return!1;else return JSON.stringify(this.clusterSlots)===JSON.stringify(S)}}_4.default=N4});var fS=F((g4)=>{Object.defineProperty(g4,"__esModule",{value:!0});var C4=N1(),p4=j("events"),$0=O1(),v4=X1(),b4=Y1(),hS=m3(),CY=G1(),vY=A0(),bY=NS(),c=C(),hY=_S(),fY=R0(),pY=F4(),gY=CS(),uY=bS(),mY=T4(),f1=e1(),h4=_0(),dY=x4(),T=(0,c.Debug)("cluster"),f4=new WeakSet;class w0 extends fY.default{constructor(S,$={}){super();if(this.slots=[],this._groupsIds={},this._groupsBySlot=Array(16384),this.isCluster=!0,this.retryAttempts=0,this.delayQueue=new mY.default,this.offlineQueue=new h4,this.isRefreshing=!1,this._refreshSlotsCacheCallbacks=[],this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this._readyDelayedCallbacks=[],this.connectionEpoch=0,p4.EventEmitter.call(this),this.startupNodes=S,this.options=(0,c.defaults)({},$,pY.DEFAULT_CLUSTER_OPTIONS,this.options),this.options.shardedSubscribers==!0)this.shardedSubscribers=new dY.default(this,this.refreshSlotsCache.bind(this));if(this.options.redisOptions&&this.options.redisOptions.keyPrefix&&!this.options.keyPrefix)this.options.keyPrefix=this.options.redisOptions.keyPrefix;if(typeof this.options.scaleReads!=="function"&&["all","master","slave"].indexOf(this.options.scaleReads)===-1)throw Error('Invalid option scaleReads "'+this.options.scaleReads+'". Expected "all", "master", "slave" or a custom function');if(this.connectionPool=new uY.default(this.options.redisOptions),this.connectionPool.on("-node",(w,Z)=>{this.emit("-node",w)}),this.connectionPool.on("+node",(w)=>{this.emit("+node",w)}),this.connectionPool.on("drain",()=>{this.setStatus("close")}),this.connectionPool.on("nodeError",(w,Z)=>{this.emit("node error",w,Z)}),this.subscriber=new gY.default(this.connectionPool,this),this.options.scripts)Object.entries(this.options.scripts).forEach(([w,Z])=>{this.defineCommand(w,Z)});if(this.options.lazyConnect)this.setStatus("wait");else this.connect().catch((w)=>{T("connecting failed: %s",w)})}connect(){return new Promise((S,$)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){$(Error("Redis is already connecting/connected"));return}let w=++this.connectionEpoch;this.setStatus("connecting"),this.resolveStartupNodeHostnames().then((Z)=>{if(this.connectionEpoch!==w){T("discard connecting after resolving startup nodes because epoch not match: %d != %d",w,this.connectionEpoch),$(new $0.RedisError("Connection is discarded because a new connection is made"));return}if(this.status!=="connecting"){T("discard connecting after resolving startup nodes because the status changed to %s",this.status),$(new $0.RedisError("Connection is aborted"));return}this.connectionPool.reset(Z);let Y=()=>{this.setStatus("ready"),this.retryAttempts=0,this.executeOfflineCommands(),this.resetNodesRefreshInterval(),S()},y=void 0,W=()=>{if(this.invokeReadyDelayedCallbacks(void 0),this.removeListener("close",y),this.manuallyClosing=!1,this.setStatus("connect"),this.options.enableReadyCheck)this.readyCheck((J,X)=>{if(J||X){if(T("Ready check failed (%s). Reconnecting...",J||X),this.status==="connect")this.disconnect(!0)}else Y()});else Y()};if(y=()=>{let J=Error("None of startup nodes is available");this.removeListener("refresh",W),this.invokeReadyDelayedCallbacks(J),$(J)},this.once("refresh",W),this.once("close",y),this.once("close",this.handleCloseEvent.bind(this)),this.refreshSlotsCache((J)=>{if(J&&J.message===hS.default.defaultMessage)CY.default.prototype.silentEmit.call(this,"error",J),this.connectionPool.reset([])}),this.subscriber.start(),this.options.shardedSubscribers)this.shardedSubscribers.start()}).catch((Z)=>{this.setStatus("close"),this.handleCloseEvent(Z),this.invokeReadyDelayedCallbacks(Z),$(Z)})})}disconnect(S=!1){let $=this.status;if(this.setStatus("disconnecting"),!S)this.manuallyClosing=!0;if(this.reconnectTimeout&&!S)clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null,T("Canceled reconnecting attempts");if(this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers)this.shardedSubscribers.stop();if($==="wait")this.setStatus("close"),this.handleCloseEvent();else this.connectionPool.reset([])}quit(S){let $=this.status;if(this.setStatus("disconnecting"),this.manuallyClosing=!0,this.reconnectTimeout)clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null;if(this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers)this.shardedSubscribers.stop();if($==="wait"){let w=(0,v4.default)(Promise.resolve("OK"),S);return setImmediate(function(){this.setStatus("close"),this.handleCloseEvent()}.bind(this)),w}return(0,v4.default)(Promise.all(this.nodes().map((w)=>w.quit().catch((Z)=>{if(Z.message===c.CONNECTION_CLOSED_ERROR_MSG)return"OK";throw Z}))).then(()=>"OK"),S)}duplicate(S=[],$={}){let w=S.length>0?S:this.startupNodes.slice(0),Z=Object.assign({},this.options,$);return new w0(w,Z)}nodes(S="all"){if(S!=="all"&&S!=="master"&&S!=="slave")throw Error('Invalid role "'+S+'". Expected "all", "master" or "slave"');return this.connectionPool.getNodes(S)}delayUntilReady(S){this._readyDelayedCallbacks.push(S)}get autoPipelineQueueSize(){let S=0;for(let $ of this._autoPipelines.values())S+=$.length;return S}refreshSlotsCache(S){if(S)this._refreshSlotsCacheCallbacks.push(S);if(this.isRefreshing)return;this.isRefreshing=!0;let $=this,w=(W)=>{this.isRefreshing=!1;for(let J of this._refreshSlotsCacheCallbacks)J(W);this._refreshSlotsCacheCallbacks=[]},Z=(0,c.shuffle)(this.connectionPool.getNodes()),Y=null;function y(W){if(W===Z.length){let U=new hS.default(hS.default.defaultMessage,Y);return w(U)}let J=Z[W],X=`${J.options.host}:${J.options.port}`;T("getting slot cache from %s",X),$.getInfoFromNode(J,function(U){switch($.status){case"close":case"end":return w(Error("Cluster is disconnected."));case"disconnecting":return w(Error("Cluster is disconnecting."))}if(U)$.emit("node error",U,X),Y=U,y(W+1);else $.emit("refresh"),w()})}y(0)}sendCommand(S,$,w){if(this.status==="wait")this.connect().catch(c.noop);if(this.status==="end")return S.reject(Error(c.CONNECTION_CLOSED_ERROR_MSG)),S.promise;let Z=this.options.scaleReads;if(Z!=="master"){if(!(S.isReadOnly||(0,C4.exists)(S.name)&&(0,C4.hasFlag)(S.name,"readonly")))Z="master"}let Y=w?w.slot:S.getSlot(),y={},W=this;if(!w&&!f4.has(S)){f4.add(S);let X=S.reject;S.reject=function(U){let Q=J.bind(null,!0);W.handleError(U,y,{moved:function(M,G){if(T("command %s is moved to %s",S.name,G),Y=Number(M),W.slots[M])W.slots[M][0]=G;else W.slots[M]=[G];W._groupsBySlot[M]=W._groupsIds[W.slots[M].join(";")],W.connectionPool.findOrCreate(W.natMapper(G)),J(),T("refreshing slot caches... (triggered by MOVED error)"),W.refreshSlotsCache()},ask:function(M,G){T("command %s is required to ask %s:%s",S.name,G);let O=W.natMapper(G);W.connectionPool.findOrCreate(O),J(!1,`${O.host}:${O.port}`)},tryagain:Q,clusterDown:Q,connectionClosed:Q,maxRedirections:function(M){X.call(S,M)},defaults:function(){X.call(S,U)}})}}J();function J(X,U){if(W.status==="end"){S.reject(new $0.AbortError("Cluster is ended."));return}let Q;if(W.status==="ready"||S.name==="cluster"){if(w&&w.redis)Q=w.redis;else if(b4.default.checkFlag("ENTER_SUBSCRIBER_MODE",S.name)||b4.default.checkFlag("EXIT_SUBSCRIBER_MODE",S.name)){if(W.options.shardedSubscribers==!0&&(S.name=="ssubscribe"||S.name=="sunsubscribe")){let M=W.shardedSubscribers.getResponsibleSubscriber(Y),G=-1;if(S.name=="ssubscribe")G=W.shardedSubscribers.addChannels(S.getKeys());if(S.name=="sunsubscribe")G=W.shardedSubscribers.removeChannels(S.getKeys());if(G!==-1)Q=M.getInstance();else S.reject(new $0.AbortError("Can't add or remove the given channels. Are they in the same slot?"))}else Q=W.subscriber.getInstance();if(!Q){S.reject(new $0.AbortError("No subscriber for the cluster"));return}}else{if(!X){if(typeof Y==="number"&&W.slots[Y]){let M=W.slots[Y];if(typeof Z==="function"){let G=M.map(function(O){return W.connectionPool.getInstanceByKey(O)});if(Q=Z(G,S),Array.isArray(Q))Q=(0,c.sample)(Q);if(!Q)Q=G[0]}else{let G;if(Z==="all")G=(0,c.sample)(M);else if(Z==="slave"&&M.length>1)G=(0,c.sample)(M,1);else G=M[0];Q=W.connectionPool.getInstanceByKey(G)}}if(U)Q=W.connectionPool.getInstanceByKey(U),Q.asking()}if(!Q)Q=(typeof Z==="function"?null:W.connectionPool.getSampleInstance(Z))||W.connectionPool.getSampleInstance("all")}if(w&&!w.redis)w.redis=Q}if(Q)Q.sendCommand(S,$);else if(W.options.enableOfflineQueue)W.offlineQueue.push({command:S,stream:$,node:w});else S.reject(Error("Cluster isn't ready and enableOfflineQueue options is false"))}return S.promise}sscanStream(S,$){return this.createScanStream("sscan",{key:S,options:$})}sscanBufferStream(S,$){return this.createScanStream("sscanBuffer",{key:S,options:$})}hscanStream(S,$){return this.createScanStream("hscan",{key:S,options:$})}hscanBufferStream(S,$){return this.createScanStream("hscanBuffer",{key:S,options:$})}zscanStream(S,$){return this.createScanStream("zscan",{key:S,options:$})}zscanBufferStream(S,$){return this.createScanStream("zscanBuffer",{key:S,options:$})}handleError(S,$,w){if(typeof $.value>"u")$.value=this.options.maxRedirections;else $.value-=1;if($.value<=0){w.maxRedirections(Error("Too many Cluster redirections. Last error: "+S));return}let Z=S.message.split(" ");if(Z[0]==="MOVED"){let Y=this.options.retryDelayOnMoved;if(Y&&typeof Y==="number")this.delayQueue.push("moved",w.moved.bind(null,Z[1],Z[2]),{timeout:Y});else w.moved(Z[1],Z[2])}else if(Z[0]==="ASK")w.ask(Z[1],Z[2]);else if(Z[0]==="TRYAGAIN")this.delayQueue.push("tryagain",w.tryagain,{timeout:this.options.retryDelayOnTryAgain});else if(Z[0]==="CLUSTERDOWN"&&this.options.retryDelayOnClusterDown>0)this.delayQueue.push("clusterdown",w.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)});else if(S.message===c.CONNECTION_CLOSED_ERROR_MSG&&this.options.retryDelayOnFailover>0&&this.status==="ready")this.delayQueue.push("failover",w.connectionClosed,{timeout:this.options.retryDelayOnFailover,callback:this.refreshSlotsCache.bind(this)});else w.defaults()}resetOfflineQueue(){this.offlineQueue=new h4}clearNodesRefreshInterval(){if(this.slotsTimer)clearTimeout(this.slotsTimer),this.slotsTimer=null}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval)return;let S=()=>{this.slotsTimer=setTimeout(()=>{T('refreshing slot caches... (triggered by "slotsRefreshInterval" option)'),this.refreshSlotsCache(()=>{S()})},this.options.slotsRefreshInterval)};S()}setStatus(S){T("status: %s -> %s",this.status||"[empty]",S),this.status=S,process.nextTick(()=>{this.emit(S)})}handleCloseEvent(S){if(S)T("closed because %s",S);let $;if(!this.manuallyClosing&&typeof this.options.clusterRetryStrategy==="function")$=this.options.clusterRetryStrategy.call(this,++this.retryAttempts,S);if(typeof $==="number")this.setStatus("reconnecting"),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,T("Cluster is disconnected. Retrying after %dms",$),this.connect().catch(function(w){T("Got error %s when reconnecting. Ignoring...",w)})},$);else this.setStatus("end"),this.flushQueue(Error("None of startup nodes is available"))}flushQueue(S){let $;while($=this.offlineQueue.shift())$.command.reject(S)}executeOfflineCommands(){if(this.offlineQueue.length){T("send %d commands in offline queue",this.offlineQueue.length);let S=this.offlineQueue;this.resetOfflineQueue();let $;while($=S.shift())this.sendCommand($.command,$.stream,$.node)}}natMapper(S){let $=typeof S==="string"?S:`${S.host}:${S.port}`,w=null;if(this.options.natMap&&typeof this.options.natMap==="function")w=this.options.natMap($);else if(this.options.natMap&&typeof this.options.natMap==="object")w=this.options.natMap[$];if(w)return T("NAT mapping %s -> %O",$,w),Object.assign({},w);return typeof S==="string"?(0,f1.nodeKeyToRedisOptions)(S):S}getInfoFromNode(S,$){if(!S)return $(Error("Node is disconnected"));let w=S.duplicate({enableOfflineQueue:!0,enableReadyCheck:!1,retryStrategy:null,connectionName:(0,f1.getConnectionName)("refresher",this.options.redisOptions&&this.options.redisOptions.connectionName)});w.on("error",c.noop),w.cluster("SLOTS",(0,c.timeout)((Z,Y)=>{if(w.disconnect(),Z)return T("error encountered running CLUSTER.SLOTS: %s",Z),$(Z);if(this.status==="disconnecting"||this.status==="close"||this.status==="end"){T("ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s",Y.length,this.status),$();return}let y=[];T("cluster slots result count: %d",Y.length);for(let J=0;J<Y.length;++J){let X=Y[J],U=X[0],Q=X[1],M=[];for(let G=2;G<X.length;G++){if(!X[G][0])continue;let O=this.natMapper({host:X[G][0],port:X[G][1]});O.readOnly=G!==2,y.push(O),M.push(O.host+":"+O.port)}T("cluster slots result [%d]: slots %d~%d served by %s",J,U,Q,M);for(let G=U;G<=Q;G++)this.slots[G]=M}this._groupsIds=Object.create(null);let W=0;for(let J=0;J<16384;J++){let X=(this.slots[J]||[]).join(";");if(!X.length){this._groupsBySlot[J]=void 0;continue}if(!this._groupsIds[X])this._groupsIds[X]=++W;this._groupsBySlot[J]=this._groupsIds[X]}this.connectionPool.reset(y),$()},this.options.slotsRefreshTimeout))}invokeReadyDelayedCallbacks(S){for(let $ of this._readyDelayedCallbacks)process.nextTick($,S);this._readyDelayedCallbacks=[]}readyCheck(S){this.cluster("INFO",($,w)=>{if($)return S($);if(typeof w!=="string")return S();let Z,Y=w.split(`\r
|
|
158
|
-
`);for(let y=0;y<Y.length;++y){let W=Y[y].split(":");if(W[0]==="cluster_state"){Z=W[1];break}}if(Z==="fail")T("cluster state not ok (%s)",Z),S(null,Z);else S()})}resolveSrv(S){return new Promise(($,w)=>{this.options.resolveSrv(S,(Z,Y)=>{if(Z)return w(Z);let y=this,W=(0,f1.groupSrvRecords)(Y),J=Object.keys(W).sort((U,Q)=>parseInt(U)-parseInt(Q));function X(U){if(!J.length)return w(U);let Q=J[0],M=W[Q],G=(0,f1.weightSrvRecords)(M);if(!M.records.length)J.shift();y.dnsLookup(G.name).then((O)=>$({host:O,port:G.port}),X)}X()})})}dnsLookup(S){return new Promise(($,w)=>{this.options.dnsLookup(S,(Z,Y)=>{if(Z)T("failed to resolve hostname %s to IP: %s",S,Z.message),w(Z);else T("resolved hostname %s to IP %s",S,Y),$(Y)})})}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0)throw Error("`startupNodes` should contain at least one node.");let S=(0,f1.normalizeNodeOptions)(this.startupNodes),$=(0,f1.getUniqueHostnamesFromOptions)(S);if($.length===0)return S;let w=await Promise.all($.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this))),Z=(0,c.zipMap)($,w);return S.map((Y)=>{let y=Z.get(Y.host);if(!y)return Y;if(this.options.useSRVRecords)return Object.assign({},Y,y);return Object.assign({},Y,{host:y})})}createScanStream(S,{key:$,options:w={}}){return new vY.default({objectMode:!0,key:$,redis:this,command:S,...w})}}(0,hY.default)(w0,p4.EventEmitter);(0,bY.addTransactionSupport)(w0.prototype);g4.default=w0});var C0=F((m4)=>{Object.defineProperty(m4,"__esModule",{value:!0});var cY=C(),tY=(0,cY.Debug)("AbstractConnector");class u4{constructor(S){this.connecting=!1,this.disconnectTimeout=S}check(S){return!0}disconnect(){if(this.connecting=!1,this.stream){let S=this.stream,$=setTimeout(()=>{tY("stream %s:%s still open, destroying it",S.remoteAddress,S.remotePort),S.destroy()},this.disconnectTimeout);S.on("close",()=>clearTimeout($)),S.end()}}}m4.default=u4});var c4=F((l4)=>{Object.defineProperty(l4,"__esModule",{value:!0});var aY=j("net"),sY=j("tls"),rY=C(),nY=C0();class d4 extends nY.default{constructor(S){super(S.disconnectTimeout);this.options=S}connect(S){let{options:$}=this;this.connecting=!0;let w;if("path"in $&&$.path)w={path:$.path};else{if(w={},"port"in $&&$.port!=null)w.port=$.port;if("host"in $&&$.host!=null)w.host=$.host;if("family"in $&&$.family!=null)w.family=$.family}if($.tls)Object.assign(w,$.tls);return new Promise((Z,Y)=>{process.nextTick(()=>{if(!this.connecting){Y(Error(rY.CONNECTION_CLOSED_ERROR_MSG));return}try{if($.tls)this.stream=(0,sY.connect)(w);else this.stream=(0,aY.createConnection)(w)}catch(y){Y(y);return}this.stream.once("error",(y)=>{this.firstError=y}),Z(this.stream)})})}}l4.default=d4});var a4=F((i4)=>{Object.defineProperty(i4,"__esModule",{value:!0});function eY(S,$){return(S.host||"127.0.0.1")===($.host||"127.0.0.1")&&(S.port||26379)===($.port||26379)}class t4{constructor(S){this.cursor=0,this.sentinels=S.slice(0)}next(){let S=this.cursor>=this.sentinels.length;return{done:S,value:S?void 0:this.sentinels[this.cursor++]}}reset(S){if(S&&this.sentinels.length>1&&this.cursor!==1)this.sentinels.unshift(...this.sentinels.splice(this.cursor-1));this.cursor=0}add(S){for(let $=0;$<this.sentinels.length;$++)if(eY(S,this.sentinels[$]))return!1;return this.sentinels.push(S),!0}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}}i4.default=t4});var e4=F((n4)=>{Object.defineProperty(n4,"__esModule",{value:!0});n4.FailoverDetector=void 0;var $8=C(),pS=(0,$8.Debug)("FailoverDetector"),s4="+switch-master";class r4{constructor(S,$){this.isDisconnected=!1,this.connector=S,this.sentinels=$}cleanup(){this.isDisconnected=!0;for(let S of this.sentinels)S.client.disconnect()}async subscribe(){pS("Starting FailoverDetector");let S=[];for(let $ of this.sentinels){let w=$.client.subscribe(s4).catch((Z)=>{pS("Failed to subscribe to failover messages on sentinel %s:%s (%s)",$.address.host||"127.0.0.1",$.address.port||26739,Z.message)});S.push(w),$.client.on("message",(Z)=>{if(!this.isDisconnected&&Z===s4)this.disconnect()})}await Promise.all(S)}disconnect(){this.isDisconnected=!0,pS("Failover detected, disconnecting"),this.connector.disconnect()}}n4.FailoverDetector=r4});var v0=F((Zw)=>{Object.defineProperty(Zw,"__esModule",{value:!0});Zw.SentinelIterator=void 0;var w8=j("net"),Z0=C(),Z8=j("tls"),Sw=a4();Zw.SentinelIterator=Sw.default;var Y8=C0(),y8=G1(),W8=e4(),p1=(0,Z0.Debug)("SentinelConnector");class $w extends Y8.default{constructor(S){super(S.disconnectTimeout);if(this.options=S,this.emitter=null,this.failoverDetector=null,!this.options.sentinels.length)throw Error("Requires at least one sentinel to connect to.");if(!this.options.name)throw Error("Requires the name of master.");this.sentinelIterator=new Sw.default(this.options.sentinels)}check(S){let $=!S.role||this.options.role===S.role;if(!$)p1("role invalid, expected %s, but got %s",this.options.role,S.role),this.sentinelIterator.next(),this.sentinelIterator.next(),this.sentinelIterator.reset(!0);return $}disconnect(){if(super.disconnect(),this.failoverDetector)this.failoverDetector.cleanup()}connect(S){this.connecting=!0,this.retryAttempts=0;let $,w=async()=>{let Z=this.sentinelIterator.next();if(Z.done){this.sentinelIterator.reset(!1);let J=typeof this.options.sentinelRetryStrategy==="function"?this.options.sentinelRetryStrategy(++this.retryAttempts):null,X=typeof J!=="number"?"All sentinels are unreachable and retry is disabled.":`All sentinels are unreachable. Retrying from scratch after ${J}ms.`;if($)X+=` Last error: ${$.message}`;p1(X);let U=Error(X);if(typeof J==="number")return S("error",U),await new Promise((Q)=>setTimeout(Q,J)),w();else throw U}let Y=null,y=null;try{Y=await this.resolve(Z.value)}catch(J){y=J}if(!this.connecting)throw Error(Z0.CONNECTION_CLOSED_ERROR_MSG);let W=Z.value.host+":"+Z.value.port;if(Y){if(p1("resolved: %s:%s from sentinel %s",Y.host,Y.port,W),this.options.enableTLSForSentinelMode&&this.options.tls)Object.assign(Y,this.options.tls),this.stream=(0,Z8.connect)(Y),this.stream.once("secureConnect",this.initFailoverDetector.bind(this));else this.stream=(0,w8.createConnection)(Y),this.stream.once("connect",this.initFailoverDetector.bind(this));return this.stream.once("error",(J)=>{this.firstError=J}),this.stream}else{let J=y?"failed to connect to sentinel "+W+" because "+y.message:"connected to sentinel "+W+" successfully, but got an invalid reply: "+Y;if(p1(J),S("sentinelError",Error(J)),y)$=y;return w()}};return w()}async updateSentinels(S){if(!this.options.updateSentinels)return;let $=await S.sentinel("sentinels",this.options.name);if(!Array.isArray($))return;$.map(Z0.packObject).forEach((w)=>{if((w.flags?w.flags.split(","):[]).indexOf("disconnected")===-1&&w.ip&&w.port){let Y=this.sentinelNatResolve(ww(w));if(this.sentinelIterator.add(Y))p1("adding sentinel %s:%s",Y.host,Y.port)}}),p1("Updated internal sentinels: %s",this.sentinelIterator)}async resolveMaster(S){let $=await S.sentinel("get-master-addr-by-name",this.options.name);return await this.updateSentinels(S),this.sentinelNatResolve(Array.isArray($)?{host:$[0],port:Number($[1])}:null)}async resolveSlave(S){let $=await S.sentinel("slaves",this.options.name);if(!Array.isArray($))return null;let w=$.map(Z0.packObject).filter((Z)=>Z.flags&&!Z.flags.match(/(disconnected|s_down|o_down)/));return this.sentinelNatResolve(J8(w,this.options.preferredSlaves))}sentinelNatResolve(S){if(!S||!this.options.natMap)return S;let $=`${S.host}:${S.port}`,w=S;if(typeof this.options.natMap==="function")w=this.options.natMap($)||S;else if(typeof this.options.natMap==="object")w=this.options.natMap[$]||S;return w}connectToSentinel(S,$){return new y8.default({port:S.port||26379,host:S.host,username:this.options.sentinelUsername||null,password:this.options.sentinelPassword||null,family:S.family||("path"in this.options&&this.options.path?void 0:this.options.family),tls:this.options.sentinelTLS,retryStrategy:null,enableReadyCheck:!1,connectTimeout:this.options.connectTimeout,commandTimeout:this.options.sentinelCommandTimeout,...$})}async resolve(S){let $=this.connectToSentinel(S);$.on("error",X8);try{if(this.options.role==="slave")return await this.resolveSlave($);else return await this.resolveMaster($)}finally{$.disconnect()}}async initFailoverDetector(){var S;if(!this.options.failoverDetector)return;this.sentinelIterator.reset(!0);let $=[];while($.length<this.options.sentinelMaxConnections){let{done:w,value:Z}=this.sentinelIterator.next();if(w)break;let Y=this.connectToSentinel(Z,{lazyConnect:!0,retryStrategy:this.options.sentinelReconnectStrategy});Y.on("reconnecting",()=>{var y;(y=this.emitter)===null||y===void 0||y.emit("sentinelReconnecting")}),$.push({address:Z,client:Y})}if(this.sentinelIterator.reset(!1),this.failoverDetector)this.failoverDetector.cleanup();this.failoverDetector=new W8.FailoverDetector(this,$),await this.failoverDetector.subscribe(),(S=this.emitter)===null||S===void 0||S.emit("failoverSubscribed")}}Zw.default=$w;function J8(S,$){if(S.length===0)return null;let w;if(typeof $==="function")w=$(S);else if($!==null&&typeof $==="object"){let Z=Array.isArray($)?$:[$];Z.sort((Y,y)=>{if(!Y.prio)Y.prio=1;if(!y.prio)y.prio=1;if(Y.prio<y.prio)return-1;if(Y.prio>y.prio)return 1;return 0});for(let Y=0;Y<Z.length;Y++){for(let y=0;y<S.length;y++){let W=S[y];if(W.ip===Z[Y].ip){if(W.port===Z[Y].port){w=W;break}}}if(w)break}}if(!w)w=(0,Z0.sample)(S);return ww(w)}function ww(S){return{host:S.ip,port:Number(S.port)}}function X8(){}});var Jw=F((yw)=>{Object.defineProperty(yw,"__esModule",{value:!0});yw.SentinelConnector=yw.StandaloneConnector=void 0;var U8=c4();yw.StandaloneConnector=U8.default;var M8=v0();yw.SentinelConnector=M8.default});var Uw=F((Qw)=>{Object.defineProperty(Qw,"__esModule",{value:!0});var q8=O1();class Xw extends q8.AbortError{constructor(S){let $=`Reached the max retries per request limit (which is ${S}). Refer to "maxRetriesPerRequest" option for details.`;super($);Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}Qw.default=Xw});var qw=F((Mw)=>{Object.defineProperty(Mw,"__esModule",{value:!0});Mw.MaxRetriesPerRequestError=void 0;var k8=Uw();Mw.MaxRetriesPerRequestError=k8.default});var Kw=F((WJ,Ew)=>{var lS=j("buffer").Buffer,F8=j("string_decoder").StringDecoder,gS=new F8,Vw=O1(),z8=Vw.ReplyError,B8=Vw.ParserError,o=lS.allocUnsafe(32768),p=0,b0=null,Y0=0,uS=0;function H8(S){let $=S.buffer.length-1;var w=S.offset,Z=0,Y=1;if(S.buffer[w]===45)Y=-1,w++;while(w<$){let y=S.buffer[w++];if(y===13)return S.offset=w+1,Y*Z;Z=Z*10+(y-48)}}function E8(S){let $=S.buffer.length-1;var w=S.offset,Z=0,Y="";if(S.buffer[w]===45)Y+="-",w++;while(w<$){var y=S.buffer[w++];if(y===13){if(S.offset=w+1,Z!==0)Y+=Z;return Y}else if(Z>429496728)Y+=Z*10+(y-48),Z=0;else if(y===48&&Z===0)Y+=0;else Z=Z*10+(y-48)}}function kw(S){let{offset:$,buffer:w}=S,Z=w.length-1;var Y=$;while(Y<Z)if(w[Y++]===13){if(S.offset=Y+1,S.optionReturnBuffers===!0)return S.buffer.slice($,Y-1);return S.buffer.toString("utf8",$,Y-1)}}function Fw(S){let $=S.buffer.length-1;var w=S.offset,Z=0;while(w<$){let Y=S.buffer[w++];if(Y===13)return S.offset=w+1,Z;Z=Z*10+(Y-48)}}function K8(S){if(S.optionStringNumbers===!0)return E8(S);return H8(S)}function O8(S){let $=Fw(S);if($===void 0)return;if($<0)return null;let w=S.offset+$;if(w+2>S.buffer.length){S.bigStrSize=w+2,S.totalChunkSize=S.buffer.length,S.bufferCache.push(S.buffer);return}let Z=S.offset;if(S.offset=w+2,S.optionReturnBuffers===!0)return S.buffer.slice(Z,w);return S.buffer.toString("utf8",Z,w)}function D8(S){var $=kw(S);if($!==void 0){if(S.optionReturnBuffers===!0)$=$.toString();return new z8($)}}function L8(S,$){let w=new B8("Protocol error, got "+JSON.stringify(String.fromCharCode($))+" as reply type byte",JSON.stringify(S.buffer),S.offset);S.buffer=null,S.returnFatalError(w)}function I8(S){let $=Fw(S);if($===void 0)return;if($<0)return null;let w=Array($);return zw(S,w,0)}function mS(S,$,w){S.arrayCache.push($),S.arrayPos.push(w)}function dS(S){let $=S.arrayCache.pop();var w=S.arrayPos.pop();if(S.arrayCache.length){let Z=dS(S);if(Z===void 0){mS(S,$,w);return}$[w++]=Z}return zw(S,$,w)}function zw(S,$,w){let Z=S.buffer.length;while(w<$.length){let Y=S.offset;if(S.offset>=Z){mS(S,$,w);return}let y=Bw(S,S.buffer[S.offset++]);if(y===void 0){if(!(S.arrayCache.length||S.bufferCache.length))S.offset=Y;mS(S,$,w);return}$[w]=y,w++}return $}function Bw(S,$){switch($){case 36:return O8(S);case 43:return kw(S);case 42:return I8(S);case 58:return K8(S);case 45:return D8(S);default:return L8(S,$)}}function j8(){if(o.length>51200)if(Y0===1||uS>Y0*2){let S=Math.floor(o.length/10),$=S<p?p:S;p=0,o=o.slice($,o.length)}else uS++,Y0--;else clearInterval(b0),Y0=0,uS=0,b0=null}function A8(S){if(o.length<S+p){let $=S>78643200?2:3;if(p>116391936)p=52428800;if(o=lS.allocUnsafe(S*$+p),p=0,Y0++,b0===null)b0=setInterval(j8,50)}}function T8(S){let{bufferCache:$,offset:w}=S;var Z=$.length,Y=S.bigStrSize-S.totalChunkSize;if(S.offset=Y,Y<=2){if(Z===2)return $[0].toString("utf8",w,$[0].length+Y-2);Z--,Y=$[$.length-2].length+Y}var y=gS.write($[0].slice(w));for(var W=1;W<Z-1;W++)y+=gS.write($[W]);return y+=gS.end($[W].slice(0,Y-2)),y}function P8(S){let{bufferCache:$,offset:w}=S,Z=S.bigStrSize-w-2;var Y=$.length,y=S.bigStrSize-S.totalChunkSize;if(S.offset=y,y<=2){if(Y===2)return $[0].slice(w,$[0].length+y-2);Y--,y=$[$.length-2].length+y}A8(Z);let W=p;$[0].copy(o,W,w,$[0].length),p+=$[0].length-w;for(var J=1;J<Y-1;J++)$[J].copy(o,p),p+=$[J].length;return $[J].copy(o,p,0,y-2),p+=y-2,o.slice(W,p)}class Hw{constructor(S){if(!S)throw TypeError("Options are mandatory.");if(typeof S.returnError!=="function"||typeof S.returnReply!=="function")throw TypeError("The returnReply and returnError options have to be functions.");this.setReturnBuffers(!!S.returnBuffers),this.setStringNumbers(!!S.stringNumbers),this.returnError=S.returnError,this.returnFatalError=S.returnFatalError||S.returnError,this.returnReply=S.returnReply,this.reset()}reset(){this.offset=0,this.buffer=null,this.bigStrSize=0,this.totalChunkSize=0,this.bufferCache=[],this.arrayCache=[],this.arrayPos=[]}setReturnBuffers(S){if(typeof S!=="boolean")throw TypeError("The returnBuffers argument has to be a boolean");this.optionReturnBuffers=S}setStringNumbers(S){if(typeof S!=="boolean")throw TypeError("The stringNumbers argument has to be a boolean");this.optionStringNumbers=S}execute(S){if(this.buffer===null)this.buffer=S,this.offset=0;else if(this.bigStrSize===0){let w=this.buffer.length,Z=w-this.offset,Y=lS.allocUnsafe(Z+S.length);if(this.buffer.copy(Y,0,this.offset,w),S.copy(Y,Z,0,S.length),this.buffer=Y,this.offset=0,this.arrayCache.length){let y=dS(this);if(y===void 0)return;this.returnReply(y)}}else if(this.totalChunkSize+S.length>=this.bigStrSize){this.bufferCache.push(S);var $=this.optionReturnBuffers?P8(this):T8(this);if(this.bigStrSize=0,this.bufferCache=[],this.buffer=S,this.arrayCache.length){if(this.arrayCache[0][this.arrayPos[0]++]=$,$=dS(this),$===void 0)return}this.returnReply($)}else{this.bufferCache.push(S),this.totalChunkSize+=S.length;return}while(this.offset<this.buffer.length){let w=this.offset,Z=this.buffer[this.offset++],Y=Bw(this,Z);if(Y===void 0){if(!(this.arrayCache.length||this.bufferCache.length))this.offset=w;return}if(Z===45)this.returnError(Y);else this.returnReply(Y)}this.buffer=null}}Ew.exports=Hw});var Lw=F((Dw)=>{Object.defineProperty(Dw,"__esModule",{value:!0});class Ow{constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(S,$){this.set[cS(S)][$]=!0}del(S,$){delete this.set[cS(S)][$]}channels(S){return Object.keys(this.set[cS(S)])}isEmpty(){return this.channels("subscribe").length===0&&this.channels("psubscribe").length===0&&this.channels("ssubscribe").length===0}}Dw.default=Ow;function cS(S){if(S==="unsubscribe")return"subscribe";if(S==="punsubscribe")return"psubscribe";if(S==="sunsubscribe")return"ssubscribe";return S}});var Rw=F((Pw)=>{Object.defineProperty(Pw,"__esModule",{value:!0});var Iw=Y1(),N8=C(),_8=Kw(),x8=Lw(),C8=(0,N8.Debug)("dataHandler");class Tw{constructor(S,$){this.redis=S;let w=new _8({stringNumbers:$.stringNumbers,returnBuffers:!0,returnError:(Z)=>{this.returnError(Z)},returnFatalError:(Z)=>{this.returnFatalError(Z)},returnReply:(Z)=>{this.returnReply(Z)}});S.stream.prependListener("data",(Z)=>{w.execute(Z)}),S.stream.resume()}returnFatalError(S){S.message+=". Please report this.",this.redis.recoverFromFatalError(S,S,{offlineQueue:!1})}returnError(S){let $=this.shiftCommand(S);if(!$)return;if(S.command={name:$.command.name,args:$.command.args},$.command.name=="ssubscribe"&&S.message.includes("MOVED")){this.redis.emit("moved");return}this.redis.handleReconnection(S,$)}returnReply(S){if(this.handleMonitorReply(S))return;if(this.handleSubscriberReply(S))return;let $=this.shiftCommand(S);if(!$)return;if(Iw.default.checkFlag("ENTER_SUBSCRIBER_MODE",$.command.name)){if(this.redis.condition.subscriber=new x8.default,this.redis.condition.subscriber.add($.command.name,S[1].toString()),!jw($.command,S[2]))this.redis.commandQueue.unshift($)}else if(Iw.default.checkFlag("EXIT_SUBSCRIBER_MODE",$.command.name)){if(!Aw($.command,S[2]))this.redis.commandQueue.unshift($)}else $.command.resolve(S)}handleSubscriberReply(S){if(!this.redis.condition.subscriber)return!1;let $=Array.isArray(S)?S[0].toString():null;switch(C8('receive reply "%s" in subscriber mode',$),$){case"message":if(this.redis.listeners("message").length>0)this.redis.emit("message",S[1].toString(),S[2]?S[2].toString():"");this.redis.emit("messageBuffer",S[1],S[2]);break;case"pmessage":{let w=S[1].toString();if(this.redis.listeners("pmessage").length>0)this.redis.emit("pmessage",w,S[2].toString(),S[3].toString());this.redis.emit("pmessageBuffer",w,S[2],S[3]);break}case"smessage":{if(this.redis.listeners("smessage").length>0)this.redis.emit("smessage",S[1].toString(),S[2]?S[2].toString():"");this.redis.emit("smessageBuffer",S[1],S[2]);break}case"ssubscribe":case"subscribe":case"psubscribe":{let w=S[1].toString();this.redis.condition.subscriber.add($,w);let Z=this.shiftCommand(S);if(!Z)return;if(!jw(Z.command,S[2]))this.redis.commandQueue.unshift(Z);break}case"sunsubscribe":case"unsubscribe":case"punsubscribe":{let w=S[1]?S[1].toString():null;if(w)this.redis.condition.subscriber.del($,w);let Z=S[2];if(Number(Z)===0)this.redis.condition.subscriber=!1;let Y=this.shiftCommand(S);if(!Y)return;if(!Aw(Y.command,Z))this.redis.commandQueue.unshift(Y);break}default:{let w=this.shiftCommand(S);if(!w)return;w.command.resolve(S)}}return!0}handleMonitorReply(S){if(this.redis.status!=="monitoring")return!1;let $=S.toString();if($==="OK")return!1;let w=$.indexOf(" "),Z=$.slice(0,w),Y=$.indexOf('"'),y=$.slice(Y+1,-1).split('" "').map((J)=>J.replace(/\\"/g,'"')),W=$.slice(w+2,Y-2).split(" ");return this.redis.emit("monitor",Z,y,W[1],W[0]),!0}shiftCommand(S){let $=this.redis.commandQueue.shift();if(!$){let Z=Error("Command queue state error. If you can reproduce this, please report it."+(S instanceof Error?` Last error: ${S.message}`:` Last reply: ${S.toString()}`));return this.redis.emit("error",Z),null}return $}}Pw.default=Tw;var q1=new WeakMap;function jw(S,$){let w=q1.has(S)?q1.get(S):S.args.length;if(w-=1,w<=0)return S.resolve($),q1.delete(S),!0;return q1.set(S,w),!1}function Aw(S,$){let w=q1.has(S)?q1.get(S):S.args.length;if(w===0){if(Number($)===0)return q1.delete(S),S.resolve($),!0;return!1}if(w-=1,w<=0)return S.resolve($),!0;return q1.set(S,w),!1}});var _w=F((Nw)=>{Object.defineProperty(Nw,"__esModule",{value:!0});Nw.readyHandler=Nw.errorHandler=Nw.closeHandler=Nw.connectHandler=void 0;var b8=O1(),h8=Y1(),f8=qw(),$1=C(),p8=Rw(),v=(0,$1.Debug)("connection");function g8(S){return function(){var $;S.setStatus("connect"),S.resetCommandQueue();let w=!1,{connectionEpoch:Z}=S;if(S.condition.auth)S.auth(S.condition.auth,function(y){if(Z!==S.connectionEpoch)return;if(y)if(y.message.indexOf("no password is set")!==-1)console.warn("[WARN] Redis server does not require a password, but a password was supplied.");else if(y.message.indexOf("without any password configured for the default user")!==-1)console.warn("[WARN] This Redis server's `default` user does not require a password, but a password was supplied");else if(y.message.indexOf("wrong number of arguments for 'auth' command")!==-1)console.warn(`[ERROR] The server returned "wrong number of arguments for 'auth' command". You are probably passing both username and password to Redis version 5 or below. You should only pass the 'password' option for Redis version 5 and under.`);else w=!0,S.recoverFromFatalError(y,y)});if(S.condition.select)S.select(S.condition.select).catch((y)=>{S.silentEmit("error",y)});new p8.default(S,{stringNumbers:S.options.stringNumbers});let Y=[];if(S.options.connectionName)v("set the connection name [%s]",S.options.connectionName),Y.push(S.client("setname",S.options.connectionName).catch($1.noop));if(!S.options.disableClientInfo)v("set the client info"),Y.push((0,$1.getPackageMeta)().then((y)=>{return S.client("SETINFO","LIB-VER",y.version).catch($1.noop)}).catch($1.noop)),Y.push(S.client("SETINFO","LIB-NAME",(($=S.options)===null||$===void 0?void 0:$.clientInfoTag)?`ioredis(${S.options.clientInfoTag})`:"ioredis").catch($1.noop));Promise.all(Y).catch($1.noop).finally(()=>{if(!S.options.enableReadyCheck)Nw.readyHandler(S)();if(S.options.enableReadyCheck)S._readyCheck(function(y,W){if(Z!==S.connectionEpoch)return;if(y){if(!w)S.recoverFromFatalError(Error("Ready check failed: "+y.message),y)}else if(S.connector.check(W))Nw.readyHandler(S)();else S.disconnect(!0)})})}}Nw.connectHandler=g8;function tS(S){let $=new b8.AbortError("Command aborted due to connection close");return $.command={name:S.name,args:S.args},$}function u8(S){var $;let w=0;for(let Z=0;Z<S.length;){let Y=($=S.peekAt(Z))===null||$===void 0?void 0:$.command,y=Y.pipelineIndex;if(y===void 0||y===0)w=0;if(y!==void 0&&y!==w++){S.remove(Z,1),Y.reject(tS(Y));continue}Z++}}function m8(S){var $;for(let w=0;w<S.length;){let Z=($=S.peekAt(w))===null||$===void 0?void 0:$.command;if(Z.name==="multi")break;if(Z.name==="exec"){S.remove(w,1),Z.reject(tS(Z));break}if(Z.inTransaction)S.remove(w,1),Z.reject(tS(Z));else w++}}function d8(S){return function(){let w=S.status;if(S.setStatus("close"),S.commandQueue.length)u8(S.commandQueue);if(S.offlineQueue.length)m8(S.offlineQueue);if(w==="ready"){if(!S.prevCondition)S.prevCondition=S.condition;if(S.commandQueue.length)S.prevCommandQueue=S.commandQueue}if(S.manuallyClosing)return S.manuallyClosing=!1,v("skip reconnecting since the connection is manually closed."),$();if(typeof S.options.retryStrategy!=="function")return v("skip reconnecting because `retryStrategy` is not a function"),$();let Z=S.options.retryStrategy(++S.retryAttempts);if(typeof Z!=="number")return v("skip reconnecting because `retryStrategy` doesn't return a number"),$();v("reconnect in %sms",Z),S.setStatus("reconnecting",Z),S.reconnectTimeout=setTimeout(function(){S.reconnectTimeout=null,S.connect().catch($1.noop)},Z);let{maxRetriesPerRequest:Y}=S.options;if(typeof Y==="number"){if(Y<0)v("maxRetriesPerRequest is negative, ignoring...");else if(S.retryAttempts%(Y+1)===0)v("reach maxRetriesPerRequest limitation, flushing command queue..."),S.flushQueue(new f8.MaxRetriesPerRequestError(Y))}};function $(){S.setStatus("end"),S.flushQueue(Error($1.CONNECTION_CLOSED_ERROR_MSG))}}Nw.closeHandler=d8;function l8(S){return function($){v("error: %s",$),S.silentEmit("error",$)}}Nw.errorHandler=l8;function c8(S){return function(){if(S.setStatus("ready"),S.retryAttempts=0,S.options.monitor){S.call("monitor").then(()=>S.setStatus("monitoring"),(Z)=>S.emit("error",Z));let{sendCommand:w}=S;S.sendCommand=function(Z){if(h8.default.checkFlag("VALID_IN_MONITOR_MODE",Z.name))return w.call(S,Z);return Z.reject(Error("Connection is in monitoring mode, can't process commands.")),Z.promise},S.once("close",function(){delete S.sendCommand});return}let $=S.prevCondition?S.prevCondition.select:S.condition.select;if(S.options.readOnly)v("set the connection to readonly mode"),S.readonly().catch($1.noop);if(S.prevCondition){let w=S.prevCondition;if(S.prevCondition=null,w.subscriber&&S.options.autoResubscribe){if(S.condition.select!==$)v("connect to db [%d]",$),S.select($);let Z=w.subscriber.channels("subscribe");if(Z.length)v("subscribe %d channels",Z.length),S.subscribe(Z);let Y=w.subscriber.channels("psubscribe");if(Y.length)v("psubscribe %d channels",Y.length),S.psubscribe(Y);let y=w.subscriber.channels("ssubscribe");if(y.length){v("ssubscribe %s",y.length);for(let W of y)S.ssubscribe(W)}}}if(S.prevCommandQueue)if(S.options.autoResendUnfulfilledCommands){v("resend %d unfulfilled commands",S.prevCommandQueue.length);while(S.prevCommandQueue.length>0){let w=S.prevCommandQueue.shift();if(w.select!==S.condition.select&&w.command.name!=="select")S.select(w.select);S.sendCommand(w.command,w.stream)}}else S.prevCommandQueue=null;if(S.offlineQueue.length){v("send %d commands in offline queue",S.offlineQueue.length);let w=S.offlineQueue;S.resetOfflineQueue();while(w.length>0){let Z=w.shift();if(Z.select!==S.condition.select&&Z.command.name!=="select")S.select(Z.select);S.sendCommand(Z.command,Z.stream)}}if(S.condition.select!==$)v("connect to db [%d]",$),S.select($)}}Nw.readyHandler=c8});var vw=F((xw)=>{Object.defineProperty(xw,"__esModule",{value:!0});xw.DEFAULT_REDIS_OPTIONS=void 0;xw.DEFAULT_REDIS_OPTIONS={port:6379,host:"localhost",family:0,connectTimeout:1e4,disconnectTimeout:2000,retryStrategy:function(S){return Math.min(S*50,2000)},keepAlive:0,noDelay:!0,connectionName:null,disableClientInfo:!1,clientInfoTag:void 0,sentinels:null,name:null,role:"master",sentinelRetryStrategy:function(S){return Math.min(S*10,1000)},sentinelReconnectStrategy:function(){return 60000},natMap:null,enableTLSForSentinelMode:!1,updateSentinels:!0,failoverDetector:!1,username:null,password:null,db:0,enableOfflineQueue:!0,enableReadyCheck:!0,autoResubscribe:!0,autoResendUnfulfilledCommands:!0,lazyConnect:!1,keyPrefix:"",reconnectOnError:null,readOnly:!1,stringNumbers:!1,maxRetriesPerRequest:20,maxLoadingRetryTime:1e4,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],sentinelMaxConnections:10}});var G1=F((pw)=>{Object.defineProperty(pw,"__esModule",{value:!0});var bw=N1(),fw=j("events"),iS=X1(),s8=fS(),y0=Y1(),r8=Jw(),n8=v0(),V1=_w(),o8=vw(),e8=A0(),Sy=NS(),A1=C(),$y=_S(),wy=R0(),k1=K0(),hw=_0(),F1=(0,A1.Debug)("redis");class w1 extends wy.default{constructor(S,$,w){super();if(this.status="wait",this.isCluster=!1,this.reconnectTimeout=null,this.connectionEpoch=0,this.retryAttempts=0,this.manuallyClosing=!1,this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this.parseOptions(S,$,w),fw.EventEmitter.call(this),this.resetCommandQueue(),this.resetOfflineQueue(),this.options.Connector)this.connector=new this.options.Connector(this.options);else if(this.options.sentinels){let Z=new n8.default(this.options);Z.emitter=this,this.connector=Z}else this.connector=new r8.StandaloneConnector(this.options);if(this.options.scripts)Object.entries(this.options.scripts).forEach(([Z,Y])=>{this.defineCommand(Z,Y)});if(this.options.lazyConnect)this.setStatus("wait");else this.connect().catch(k1.noop)}static createClient(...S){return new w1(...S)}get autoPipelineQueueSize(){let S=0;for(let $ of this._autoPipelines.values())S+=$.length;return S}connect(S){let $=new Promise((w,Z)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){Z(Error("Redis is already connecting/connected"));return}this.connectionEpoch+=1,this.setStatus("connecting");let{options:Y}=this;this.condition={select:Y.db,auth:Y.username?[Y.username,Y.password]:Y.password,subscriber:!1};let y=this;(0,iS.default)(this.connector.connect(function(W,J){y.silentEmit(W,J)}),function(W,J){if(W){y.flushQueue(W),y.silentEmit("error",W),Z(W),y.setStatus("end");return}let X=Y.tls?"secureConnect":"connect";if("sentinels"in Y&&Y.sentinels&&!Y.enableTLSForSentinelMode)X="connect";if(y.stream=J,Y.noDelay)J.setNoDelay(!0);if(typeof Y.keepAlive==="number")if(J.connecting)J.once(X,()=>{J.setKeepAlive(!0,Y.keepAlive)});else J.setKeepAlive(!0,Y.keepAlive);if(J.connecting){if(J.once(X,V1.connectHandler(y)),Y.connectTimeout){let M=!1;J.setTimeout(Y.connectTimeout,function(){if(M)return;J.setTimeout(0),J.destroy();let G=Error("connect ETIMEDOUT");G.errorno="ETIMEDOUT",G.code="ETIMEDOUT",G.syscall="connect",V1.errorHandler(y)(G)}),J.once(X,function(){M=!0,J.setTimeout(0)})}}else if(J.destroyed){let M=y.connector.firstError;if(M)process.nextTick(()=>{V1.errorHandler(y)(M)});process.nextTick(V1.closeHandler(y))}else process.nextTick(V1.connectHandler(y));if(!J.destroyed)J.once("error",V1.errorHandler(y)),J.once("close",V1.closeHandler(y));let U=function(){y.removeListener("close",Q),w()};var Q=function(){y.removeListener("ready",U),Z(Error(A1.CONNECTION_CLOSED_ERROR_MSG))};y.once("ready",U),y.once("close",Q)})});return(0,iS.default)($,S)}disconnect(S=!1){if(!S)this.manuallyClosing=!0;if(this.reconnectTimeout&&!S)clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null;if(this.status==="wait")V1.closeHandler(this)();else this.connector.disconnect()}end(){this.disconnect()}duplicate(S){return new w1({...this.options,...S})}get mode(){var S;return this.options.monitor?"monitor":((S=this.condition)===null||S===void 0?void 0:S.subscriber)?"subscriber":"normal"}monitor(S){let $=this.duplicate({monitor:!0,lazyConnect:!1});return(0,iS.default)(new Promise(function(w,Z){$.once("error",Z),$.once("monitoring",function(){w($)})}),S)}sendCommand(S,$){var w,Z;if(this.status==="wait")this.connect().catch(k1.noop);if(this.status==="end")return S.reject(Error(A1.CONNECTION_CLOSED_ERROR_MSG)),S.promise;if(((w=this.condition)===null||w===void 0?void 0:w.subscriber)&&!y0.default.checkFlag("VALID_IN_SUBSCRIBER_MODE",S.name))return S.reject(Error("Connection in subscriber mode, only subscriber commands may be used")),S.promise;if(typeof this.options.commandTimeout==="number")S.setTimeout(this.options.commandTimeout);let Y=this.status==="ready"||!$&&this.status==="connect"&&(0,bw.exists)(S.name)&&((0,bw.hasFlag)(S.name,"loading")||y0.default.checkFlag("HANDSHAKE_COMMANDS",S.name));if(!this.stream)Y=!1;else if(!this.stream.writable)Y=!1;else if(this.stream._writableState&&this.stream._writableState.ended)Y=!1;if(!Y){if(!this.options.enableOfflineQueue)return S.reject(Error("Stream isn't writeable and enableOfflineQueue options is false")),S.promise;if(S.name==="quit"&&this.offlineQueue.length===0)return this.disconnect(),S.resolve(Buffer.from("OK")),S.promise;if(F1.enabled)F1("queue command[%s]: %d -> %s(%o)",this._getDescription(),this.condition.select,S.name,S.args);this.offlineQueue.push({command:S,stream:$,select:this.condition.select})}else{if(F1.enabled)F1("write command[%s]: %d -> %s(%o)",this._getDescription(),(Z=this.condition)===null||Z===void 0?void 0:Z.select,S.name,S.args);if($)if("isPipeline"in $&&$.isPipeline)$.write(S.toWritable($.destination.redis.stream));else $.write(S.toWritable($));else this.stream.write(S.toWritable(this.stream));if(this.commandQueue.push({command:S,stream:$,select:this.condition.select}),y0.default.checkFlag("WILL_DISCONNECT",S.name))this.manuallyClosing=!0;if(this.options.socketTimeout!==void 0&&this.socketTimeoutTimer===void 0)this.setSocketTimeout()}if(S.name==="select"&&(0,A1.isInt)(S.args[0])){let y=parseInt(S.args[0],10);if(this.condition.select!==y)this.condition.select=y,this.emit("select",y),F1("switch to db [%d]",this.condition.select)}return S.promise}setSocketTimeout(){this.socketTimeoutTimer=setTimeout(()=>{this.stream.destroy(Error(`Socket timeout. Expecting data, but didn't receive any in ${this.options.socketTimeout}ms.`)),this.socketTimeoutTimer=void 0},this.options.socketTimeout),this.stream.once("data",()=>{if(clearTimeout(this.socketTimeoutTimer),this.socketTimeoutTimer=void 0,this.commandQueue.length===0)return;this.setSocketTimeout()})}scanStream(S){return this.createScanStream("scan",{options:S})}scanBufferStream(S){return this.createScanStream("scanBuffer",{options:S})}sscanStream(S,$){return this.createScanStream("sscan",{key:S,options:$})}sscanBufferStream(S,$){return this.createScanStream("sscanBuffer",{key:S,options:$})}hscanStream(S,$){return this.createScanStream("hscan",{key:S,options:$})}hscanBufferStream(S,$){return this.createScanStream("hscanBuffer",{key:S,options:$})}zscanStream(S,$){return this.createScanStream("zscan",{key:S,options:$})}zscanBufferStream(S,$){return this.createScanStream("zscanBuffer",{key:S,options:$})}silentEmit(S,$){let w;if(S==="error"){if(w=$,this.status==="end")return;if(this.manuallyClosing){if(w instanceof Error&&(w.message===A1.CONNECTION_CLOSED_ERROR_MSG||w.syscall==="connect"||w.syscall==="read"))return}}if(this.listeners(S).length>0)return this.emit.apply(this,arguments);if(w&&w instanceof Error)console.error("[ioredis] Unhandled error event:",w.stack);return!1}recoverFromFatalError(S,$,w){this.flushQueue($,w),this.silentEmit("error",$),this.disconnect(!0)}handleReconnection(S,$){var w;let Z=!1;if(this.options.reconnectOnError&&!y0.default.checkFlag("IGNORE_RECONNECT_ON_ERROR",$.command.name))Z=this.options.reconnectOnError(S);switch(Z){case 1:case!0:if(this.status!=="reconnecting")this.disconnect(!0);$.command.reject(S);break;case 2:if(this.status!=="reconnecting")this.disconnect(!0);if(((w=this.condition)===null||w===void 0?void 0:w.select)!==$.select&&$.command.name!=="select")this.select($.select);this.sendCommand($.command);break;default:$.command.reject(S)}}_getDescription(){let S;if("path"in this.options&&this.options.path)S=this.options.path;else if(this.stream&&this.stream.remoteAddress&&this.stream.remotePort)S=this.stream.remoteAddress+":"+this.stream.remotePort;else if("host"in this.options&&this.options.host)S=this.options.host+":"+this.options.port;else S="";if(this.options.connectionName)S+=` (${this.options.connectionName})`;return S}resetCommandQueue(){this.commandQueue=new hw}resetOfflineQueue(){this.offlineQueue=new hw}parseOptions(...S){let $={},w=!1;for(let Z=0;Z<S.length;++Z){let Y=S[Z];if(Y===null||typeof Y>"u")continue;if(typeof Y==="object")(0,k1.defaults)($,Y);else if(typeof Y==="string"){if((0,k1.defaults)($,(0,A1.parseURL)(Y)),Y.startsWith("rediss://"))w=!0}else if(typeof Y==="number")$.port=Y;else throw Error("Invalid argument "+Y)}if(w)(0,k1.defaults)($,{tls:!0});if((0,k1.defaults)($,w1.defaultOptions),typeof $.port==="string")$.port=parseInt($.port,10);if(typeof $.db==="string")$.db=parseInt($.db,10);this.options=(0,A1.resolveTLSProfile)($)}setStatus(S,$){if(F1.enabled)F1("status[%s]: %s -> %s",this._getDescription(),this.status||"[empty]",S);this.status=S,process.nextTick(this.emit.bind(this,S,$))}createScanStream(S,{key:$,options:w={}}){return new e8.default({objectMode:!0,key:$,redis:this,command:S,...w})}flushQueue(S,$){$=(0,k1.defaults)({},$,{offlineQueue:!0,commandQueue:!0});let w;if($.offlineQueue)while(w=this.offlineQueue.shift())w.command.reject(S);if($.commandQueue){if(this.commandQueue.length>0){if(this.stream)this.stream.removeAllListeners("data");while(w=this.commandQueue.shift())w.command.reject(S)}}}_readyCheck(S){let $=this;this.info(function(w,Z){if(w){if(w.message&&w.message.includes("NOPERM"))return console.warn(`Skipping the ready check because INFO command fails: "${w.message}". You can disable ready check with "enableReadyCheck". More: https://github.com/luin/ioredis/wiki/Disable-ready-check.`),S(null,{});return S(w)}if(typeof Z!=="string")return S(null,Z);let Y={},y=Z.split(`\r
|
|
159
|
-
`);for(let W=0;W<y.length;++W){let[J,...X]=y[W].split(":"),U=X.join(":");if(U)Y[J]=U}if(!Y.loading||Y.loading==="0")S(null,Y);else{let W=(Y.loading_eta_seconds||1)*1000,J=$.options.maxLoadingRetryTime&&$.options.maxLoadingRetryTime<W?$.options.maxLoadingRetryTime:W;F1("Redis server still loading, trying again in "+J+"ms"),setTimeout(function(){$._readyCheck(S)},J)}}).catch(k1.noop)}}w1.Cluster=s8.default;w1.Command=y0.default;w1.defaultOptions=o8.DEFAULT_REDIS_OPTIONS;(0,$y.default)(w1,fw.EventEmitter);(0,Sy.addTransactionSupport)(w1.prototype);pw.default=w1});var mw=F((g,uw)=>{Object.defineProperty(g,"__esModule",{value:!0});g.print=g.ReplyError=g.SentinelIterator=g.SentinelConnector=g.AbstractConnector=g.Pipeline=g.ScanStream=g.Command=g.Cluster=g.Redis=g.default=void 0;g=uw.exports=G1().default;var Yy=G1();Object.defineProperty(g,"default",{enumerable:!0,get:function(){return Yy.default}});var yy=G1();Object.defineProperty(g,"Redis",{enumerable:!0,get:function(){return yy.default}});var Wy=fS();Object.defineProperty(g,"Cluster",{enumerable:!0,get:function(){return Wy.default}});var Jy=Y1();Object.defineProperty(g,"Command",{enumerable:!0,get:function(){return Jy.default}});var Xy=A0();Object.defineProperty(g,"ScanStream",{enumerable:!0,get:function(){return Xy.default}});var Qy=TS();Object.defineProperty(g,"Pipeline",{enumerable:!0,get:function(){return Qy.default}});var Uy=C0();Object.defineProperty(g,"AbstractConnector",{enumerable:!0,get:function(){return Uy.default}});var gw=v0();Object.defineProperty(g,"SentinelConnector",{enumerable:!0,get:function(){return gw.default}});Object.defineProperty(g,"SentinelIterator",{enumerable:!0,get:function(){return gw.SentinelIterator}});g.ReplyError=O1().ReplyError;Object.defineProperty(g,"Promise",{get(){return console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used."),Promise},set(S){console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.")}});function My(S,$){if(S)console.log("Error: "+S);else console.log("Reply: "+$)}g.print=My});import{createServer as Ry}from"net";var d0=U0(M0(),1);var m1={ok:"OK",created:"Created",accepted:"Accepted",noContent:"No Content",movedPermanently:"Moved Permanently",found:"Found",notModified:"Not Modified",badRequest:"Bad Request",unauthorized:"Unauthorized",forbidden:"Forbidden",notFound:"Not Found",methodNotAllowed:"Method Not Allowed",conflict:"Conflict",unsupportedMediaType:"Unsupported Media Type",tooManyRequests:"Too Many Requests",internalServerError:"Internal Server Error"},a={ok:200,created:201,accepted:202,noContent:204,movedPermanently:301,found:302,notModified:304,badRequest:400,unauthorized:401,forbidden:403,notFound:404,methodNotAllowed:405,conflict:409,unsupportedMediaType:415,tooManyRequests:429,internalServerError:500},N={delete:"DELETE",get:"GET",head:"HEAD",post:"POST",put:"PUT",patch:"PATCH",options:"OPTIONS"},s={json:"application/json",html:"text/html",form:"application/x-www-form-urlencoded",multipart:"multipart/form-data",xml:"application/xml",text:"text/plain",csv:"text/csv",yamlApplication:"application/yaml",yamlText:"text/yaml",urlEncodedJson:"application/x-www-form-urlencoded+json"},Z1={authorization:"Authorization",proxyAuthorization:"Proxy-Authorization",wwwAuthenticate:"WWW-Authenticate",cacheControl:"Cache-Control",etag:"ETag",expires:"Expires",lastModified:"Last-Modified",ifMatch:"If-Match",ifNoneMatch:"If-None-Match",ifModifiedSince:"If-Modified-Since",ifUnmodifiedSince:"If-Unmodified-Since",ifRange:"If-Range",age:"Age",vary:"Vary",contentType:"Content-Type",contentLength:"Content-Length",contentEncoding:"Content-Encoding",contentLanguage:"Content-Language",contentDisposition:"Content-Disposition",contentLocation:"Content-Location",contentRange:"Content-Range",accessControlAllowCredentials:"Access-Control-Allow-Credentials",accessControlAllowHeaders:"Access-Control-Allow-Headers",accessControlAllowMethods:"Access-Control-Allow-Methods",accessControlAllowOrigin:"Access-Control-Allow-Origin",accessControlExposeHeaders:"Access-Control-Expose-Headers",accessControlMaxAge:"Access-Control-Max-Age",accessControlRequestHeaders:"Access-Control-Request-Headers",accessControlRequestMethod:"Access-Control-Request-Method",accept:"Accept",acceptEncoding:"Accept-Encoding",acceptLanguage:"Accept-Language",acceptRanges:"Accept-Ranges",host:"Host",userAgent:"User-Agent",referer:"Referer",origin:"Origin",from:"From",expect:"Expect",location:"Location",server:"Server",date:"Date",allow:"Allow",retryAfter:"Retry-After",range:"Range",contentSecurityPolicy:"Content-Security-Policy",contentSecurityPolicyReportOnly:"Content-Security-Policy-Report-Only",strictTransportSecurity:"Strict-Transport-Security",xContentTypeOptions:"X-Content-Type-Options",xFrameOptions:"X-Frame-Options",xXSSProtection:"X-XSS-Protection",referrerPolicy:"Referrer-Policy",permissionsPolicy:"Permissions-Policy",crossOriginEmbedderPolicy:"Cross-Origin-Embedder-Policy",crossOriginOpenerPolicy:"Cross-Origin-Opener-Policy",crossOriginResourcePolicy:"Cross-Origin-Resource-Policy",cookie:"Cookie",setCookie:"Set-Cookie",connection:"Connection",keepAlive:"Keep-Alive",upgrade:"Upgrade",upgradeInsecureRequests:"Upgrade-Insecure-Requests",transferEncoding:"Transfer-Encoding",te:"TE",trailer:"Trailer",forwarded:"Forwarded",xForwardedFor:"X-Forwarded-For",via:"Via",maxForwards:"Max-Forwards",altSvc:"Alt-Svc",altUsed:"Alt-Used",timingAllowOrigin:"Timing-Allow-Origin",serverTiming:"Server-Timing",refresh:"Refresh",link:"Link",xPoweredBy:"X-Powered-By",xPermittedCrossDomainPolicies:"X-Permitted-Cross-Domain-Policies",reportTo:"Report-To",serviceWorkerAllowed:"Service-Worker-Allowed",sourceMap:"SourceMap",priority:"Priority",secGPC:"Sec-GPC",clearSiteData:"Clear-Site-Data",noVarySearch:"No-Vary-Search"},$$={base64:"base64",binary:"binary",utf8:"utf8"};var G0=(S,$)=>{if(!$.enabled)return!1;if(S.request.method==="OPTIONS"){if(!Z$(S,$))return S.response.setStatusCode(403),S._response._setBody({error:"CORS: Origin not allowed",origin:S.request.headers.origin}),!0;S.response.setStatusCode($.optionsSuccessStatus);let Y=w$(S,$);if(S._response._setHeadersIfNotSet({[Z1.accessControlAllowOrigin]:Y,[Z1.accessControlAllowMethods]:$.methods.join(", "),[Z1.accessControlAllowHeaders]:typeof $.allowedHeaders==="string"?$.allowedHeaders:$.allowedHeaders.join(", "),[Z1.accessControlAllowCredentials]:$.credentials?"true":"false",[Z1.accessControlExposeHeaders]:$.exposedHeaders.join(", "),[Z1.accessControlMaxAge]:$.maxAge.toString()}),$.preflightContinue)return!1;return S._response._setBody(""),!0}if(Z$(S,$)){let Z=w$(S,$);S._response._setHeadersIfNotSet({[Z1.accessControlAllowOrigin]:Z,[Z1.accessControlAllowCredentials]:$.credentials?"true":"false"})}return!1},w$=(S,$)=>{if($.origin==="*"){if($.credentials)throw Error('CORS Security Error: origin: "*" with credentials: true is forbidden by CORS spec and creates security vulnerabilities. Use specific origins instead.');return"*"}let w=S.request.headers.origin;if(w)return w;if(typeof $.origin==="string")return $.origin;if(Array.isArray($.origin)&&$.origin.length>0){let[Z]=$.origin;return Z??"null"}return"null"},Z$=(S,$)=>{if($.origin==="*")return!0;let w=S.request.headers.origin?.toLowerCase()??"";if(typeof $.origin==="function")return Boolean($.origin(w,S.request));if(typeof $.origin==="string")return w===$.origin.toLowerCase();if(Array.isArray($.origin))return $.origin.some((Z)=>w===Z.toLowerCase());if($.origin instanceof RegExp)return $.origin.test(w);return!1};var Y$=U0(M0(),1);var D={reset:"\x1B[0m",cyan:"\x1B[96m",yellow:"\x1B[93m",red:"\x1B[91m",green:"\x1B[92m",magenta:"\x1B[95m",gray:"\x1B[90m"};var d1={off:"off",error:"error",warn:"warn",info:"info"};var K1={off:0,error:1,warn:2,info:3},ow={positive:["n'at!","yinz are good!","that's the way!","right on!","lookin' good!","way to go!","keep it up!"],neutral:["n'at","yinz know","just sayin'","that's how it is","what can ya do","it happens"],negative:["aw jeez","that ain't right","what a jagoff move","that's terrible n'at","somebody messed up","this is bad news","yinz better fix this"]},q0=(S)=>{let $=ow[S];return $[Math.floor(Math.random()*$.length)]??""},y$=()=>Y$.default().format("YYYY-MM-DD HH:mm:ss.SSS"),m0=(S,$,...w)=>{let Z=y$(),Y=D.reset;if($==="NETWORK")Y=D.gray;if(S==="error"){let W=`${D.red}[${$}] ❌ [${Z}] [ERROR]${D.reset}`;console.error(`${W}`,`${Y}`,...w,`${D.reset} - ${q0("negative")}`);return}if(S==="warn"){let W=`${D.yellow}[${$}] ⚠️ [${Z}] [WARN]${D.reset}`;console.warn(`${W}`,`${Y}`,...w,`${D.reset} - ${q0("neutral")}`);return}if(S==="off")return;let y=`${D.cyan}[${$}] ✅ [${Z}] [INFO]${D.reset}`;console.info(`${y}`,`${Y}`,...w,`${D.reset} - ${q0("positive")}`)},ew=(S,$,...w)=>{let Z=y$(),Y=`${D.magenta}[${S}] \uD83D\uDCCA [${Z}] [TABLE]${D.reset}`;if(console.log(`${Y} - ${q0("positive")}`),console.table($),w.length>0)console.log(`${D.gray}Additional context:${D.reset}`,...w)},l1=(S)=>{let $={logLevel:S?.logLevel??d1.info,prefix:S?.prefix??"YINZER",logger:S?.logger??null},w=(J)=>K1[J]??K1.info;return{info:(...J)=>{if(w($.logLevel)<K1.info)return;if($.logger){$.logger.info(...J);return}m0("info",$.prefix,...J)},warn:(...J)=>{if(w($.logLevel)<K1.warn)return;if($.logger){$.logger.warn(...J);return}m0("warn",$.prefix,...J)},error:(...J)=>{if(w($.logLevel)<K1.error)return;if($.logger){$.logger.error(...J);return}m0("error",$.prefix,...J)},table:(J,...X)=>{if(w($.logLevel)<K1.info)return;if($.logger){$.logger.info("TABLE:",J,...X);return}ew($.prefix,J,...X)},levels:K1}},B=l1();class l0{setup;constructor(S){this.setup=S}async handle(S){try{if(this._handleCors(S))return;let $=await this._matchRoute(S);if(!$)return;Object.assign(S.request.params,$.params);let{handler:w,options:Z}=$,{beforeHooks:Y=[],afterHooks:y=[]}=Z;if(await this._handleBeforeAllHooks(S))return;if(await this._handleBeforeHooks(S,Y))return;let W=null;try{W=await w(S)}catch(X){throw X}for(let X of y)await X(S);let J=this.setup._hooks._afterAll;for(let X of J){if(!this._shouldRunHook(X.options,S.request.path))continue;await X.handler(S)}if(S._response._setBody(W),S.request.method==="HEAD")S._response._setBody(null);S._response._parseResponseIntoString();return}catch($){await this.handleError(S,$)}}async handleError(S,$){try{let w=this.setup._hooks._onError,Z=await w(S,$);S._response._setBody(Z),G0(S,this.setup._configuration.cors),S._response._parseResponseIntoString(),S._response._setHeadersIfNotSet({Date:d0.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":S._response._stringBody.split(`
|
|
160
|
-
|
|
161
|
-
`)[1]?.length.toString()??"0"})}catch(w){B.error("Error handler failed, this might be an internal error in the YinzerFlow framework: ",w),S.response.setStatusCode(500),S._response._setBody({success:!1,message:"Internal Server Error"}),G0(S,this.setup._configuration.cors),S._response._parseResponseIntoString(),S._response._setHeadersIfNotSet({Date:d0.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":S._response._stringBody.split(`
|
|
162
|
-
|
|
163
|
-
`)[1]?.length.toString()??"0"})}}_handleCors(S){if(G0(S,this.setup._configuration.cors))return S._response._parseResponseIntoString(),!0;return!1}async _matchRoute(S){let $=this.setup._routeRegistry._findRoute(S.request.method,S.request.path);if(!$){let w=await this.setup._hooks._onNotFound(S);return S._response._setBody(w),S._response._parseResponseIntoString(),null}return $}async _handleBeforeAllHooks(S){let $=this.setup._hooks._beforeAll;for(let w of $){if(!this._shouldRunHook(w.options,S.request.path))continue;let Z=await w.handler(S);if(Z!==void 0)return S._response._setBody(Z),S._response._parseResponseIntoString(),!0}return!1}async _handleBeforeHooks(S,$){for(let w of $){let Z=await w(S);if(Z!==void 0)return S._response._setBody(Z),S._response._parseResponseIntoString(),!0}return!1}_shouldRunHook(S,$){if(!S)return!0;let{routesToInclude:w,routesToExclude:Z}=S;if(Z.some((Y)=>this._matchesPattern($,Y)))return!1;if(w.length===0)return!0;return w.some((Y)=>this._matchesPattern($,Y))}_matchesPattern(S,$){if($===S)return!0;if($.endsWith("/*")){let w=$.slice(0,-2);return S.startsWith(w)}return!1}}var W$=["__proto__","constructor","prototype"],J$=(S,$)=>{if(!S||!S.trim()||S.trim()==="\x00")return;let w=Buffer.byteLength(S,"utf8");if(w>$.maxSize)throw B.warn("[SECURITY] JSON request body too large",{size:w,limit:$.maxSize,sizeMB:Math.round(w/1024/1024)}),Error(`Request body too large: ${w} bytes exceeds limit of ${$.maxSize} bytes`);let Z=null;try{Z=JSON.parse(S)}catch(Y){let y=Y instanceof Error?Y.message:String(Y);throw Error(`Invalid JSON syntax: ${y}`)}try{c0(Z,$,1)}catch(Y){let y=Y instanceof Error?Y.message:String(Y);throw Error(`JSON security validation failed: ${y}`)}return Z},S5=(S,$)=>{if(typeof S==="string"&&S.length>$.maxStringLength)throw Error(`String too long: ${S.length} characters exceeds limit of ${$.maxStringLength}`)},$5=(S,$,w)=>{if(S.length>$.maxArrayLength)throw Error(`Array too large: ${S.length} elements exceeds limit of ${$.maxArrayLength}`);for(let Z of S)c0(Z,$,w+1)},w5=(S,$)=>{if(S.length>$.maxKeys)throw Error(`Object has too many keys: ${S.length} exceeds limit of ${$.maxKeys}`);if(!$.allowPrototypeProperties){for(let w of S)if(W$.includes(w))throw B.warn("[SECURITY] Prototype pollution attempt detected",{property:w,dangerousProperties:W$}),Error(`Prototype pollution attempt detected: property '${w}' is not allowed`)}},Z5=(S,$,w)=>{let Z=Object.keys(S);for(let Y of Z){if(Y.length>$.maxStringLength)throw Error(`Object key too long: '${Y.substring(0,50)}...' exceeds limit of ${$.maxStringLength}`);let y=S[Y];if(typeof y==="string"&&y.length>$.maxStringLength)throw Error(`String value too long: property '${Y}' has ${y.length} characters, exceeds limit of ${$.maxStringLength}`);c0(y,$,w+1)}},c0=(S,$,w)=>{if(w>$.maxDepth)throw B.warn("[SECURITY] JSON nesting too deep - potential stack overflow attack",{currentDepth:w,maxDepth:$.maxDepth}),Error(`JSON nesting too deep: current depth ${w} exceeds maximum depth of ${$.maxDepth}`);if(S===null||typeof S!=="object"){S5(S,$);return}if(Array.isArray(S)){$5(S,$,w);return}let Z=Object.keys(S);w5(Z,$),Z5(S,$,w)};var Y5=(S)=>{let $=S.startsWith(`\r
|
|
164
|
-
`)?S.slice(2):S,w=$.indexOf(`\r
|
|
165
|
-
\r
|
|
166
|
-
`);if(w===-1)return["",""];let Z=$.slice(0,w),Y=$.slice(w+4);return[Z,Y]},y5=(S)=>{let $={name:""},w=/name=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec(S),Z=/filename=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec(S);if(w)$.name=w[1]??w[2]??"";if(Z){let Y=Z[1]??Z[2];if(Y)$.filename=Y}return $},W5=(S)=>{let w=S.split(/\r?\n/).find((Z)=>Z.toLowerCase().startsWith("content-type:"));if(!w)return"application/octet-stream";return w.slice(w.indexOf(":")+1).trim().split(";")[0]?.trim()??"application/octet-stream"},J5=(S)=>{return["image/","audio/","video/","application/octet-stream","application/pdf","application/zip","application/x-"].some((w)=>S.toLowerCase().startsWith(w))},X5=(S)=>Buffer.isBuffer(S)?S.length:Buffer.byteLength(S,"utf8"),Q5=(S,$)=>{if(!$)return;if(S.size>$.maxFileSize)throw B.warn("[SECURITY] File upload too large",{filename:S.filename,size:S.size,limit:$.maxFileSize,sizeMB:Math.round(S.size/1024/1024)}),Error(`File too large: ${S.filename} is ${S.size} bytes, exceeds limit of ${$.maxFileSize} bytes`);if(S.filename&&S.filename.length>$.maxFilenameLength)throw Error(`Filename too long: ${S.filename.length} characters exceeds limit of ${$.maxFilenameLength}`);if(S.filename){let w=S.filename.toLowerCase().substring(S.filename.lastIndexOf("."));if($.blockedExtensions.includes(w))throw B.warn("[SECURITY] Blocked file type upload attempt",{filename:S.filename,extension:w,blockedExtensions:$.blockedExtensions}),Error(`File type not allowed: ${w} files are blocked for security reasons`);if($.allowedExtensions.length>0&&!$.allowedExtensions.includes(w))throw Error(`File type not allowed: ${w} is not in the allowed extensions list`)}},U5=({contentDisposition:S,contentSection:$,headersSection:w,config:Z})=>{let Y=W5(w),y=$.endsWith(`\r
|
|
167
|
-
`)?$.slice(0,-2):$,W=J5(Y)?Buffer.from(y,"binary"):y,J={filename:S.filename??"",contentType:Y,size:X5(W),content:W};return Q5(J,Z),J},X$=(S,$,w)=>{let Z={fields:{},files:[]},Y=S.split(`--${$}`).slice(1),y=0;for(let W of Y){if(!W||W.trim()===""||W.trim()==="--")continue;let[J,X]=Y5(W);if(!J)continue;let Q=J.split(/\r?\n/).find((G)=>G.toLowerCase().startsWith("content-disposition:"));if(!Q)continue;let M=y5(Q);if(!M.name)continue;if(M.filename!==void 0){if(w&&Z.files.length>=w.maxFiles)throw B.warn("[SECURITY] Too many files in upload request",{fileCount:Z.files.length,maxFiles:w.maxFiles}),Error(`Too many files: maximum of ${w.maxFiles} files allowed per request`);let G=U5({contentDisposition:M,contentSection:X,headersSection:J,config:w});if(y+=G.size,w&&y>w.maxTotalSize)throw B.warn("[SECURITY] Total upload size too large",{totalSize:y,limit:w.maxTotalSize,totalSizeMB:Math.round(y/1024/1024)}),Error(`Total file size too large: ${y} bytes exceeds limit of ${w.maxTotalSize} bytes`);Z.files.push(G)}if(M.filename===void 0){let G=X.endsWith(`\r
|
|
168
|
-
`)?X.slice(0,-2):X;Z.fields[M.name]=G}}return Z};var M5=(S,$)=>{if(S.length>$.maxFields)throw Error(`Too many form fields: ${S.length} exceeds limit of ${$.maxFields}`)},G5=(S,$,w)=>{if(S.length>w.maxFieldNameLength)throw Error(`Form field name too long: ${S.length} characters exceeds limit of ${w.maxFieldNameLength}`);if($&&$.length>w.maxFieldLength)throw Error(`Form field value too long: field '${S}' has ${$.length} characters, exceeds limit of ${w.maxFieldLength}`)},q5=(S,$,w)=>{if(S.length>w.maxFieldNameLength)throw Error(`Decoded form field name too long: ${S.length} characters exceeds limit of ${w.maxFieldNameLength}`);if($.length>w.maxFieldLength)throw Error(`Decoded form field value too long: field '${S}' has ${$.length} characters, exceeds limit of ${w.maxFieldLength}`)},V5=(S,$,w)=>{let[Z,Y]=S.split("=");if(!Z)return;if(w)G5(Z,Y,w);try{let y=decodeURIComponent(Z),W=Y?decodeURIComponent(Y):"";if(w)q5(y,W,w);$[y]=W}catch(y){if(y instanceof Error&&y.message.includes("exceeds limit"))throw y;$[Z]=Y??""}},Q$=(S,$)=>{let w={},Z=S.split("&");if($)M5(Z,$);for(let Y of Z)V5(Y,w,$);return w};var V0={JPEG:[255,216,255],PNG:[137,80,78,71],GIF87A:[71,73,70,56,55,97],GIF89A:[71,73,70,56,57,97],BMP:[66,77],TIFF_LE:[73,73,42,0],TIFF_BE:[77,77,0,42],WEBP:[82,73,70,70],ICO:[0,0,1,0],MP3_ID3:[73,68,51],MP3_FRAME:[255,251],WAV:[82,73,70,70],FLAC:[102,76,97,67],OGG:[79,103,103,83],MP4_FTYP:[0,0,0,24,102,116,121,112],MP4_FTYP_ALT:[0,0,0,28,102,116,121,112],AVI:[82,73,70,70],WEBM:[26,69,223,163],PDF:[37,80,68,70],ZIP:[80,75,3,4],ZIP_EMPTY:[80,75,5,6],ZIP_SPANNED:[80,75,7,8],RAR:[82,97,114,33,26,7,0],RAR5:[82,97,114,33,26,7,1,0],SEVENZ:[55,122,188,175,39,28],GZIP:[31,139],EXE:[77,90],ELF:[127,69,76,70],OFFICE_OLD:[208,207,17,224,161,177,26,225]},k0=(S,$)=>{if(S.length<$.length)return!1;return $.every((w,Z)=>S[Z]===w)},k5=(S)=>{if(k0(S,V0.WEBP)&&S.length>=12)return S.subarray(8,12).toString("ascii")==="WEBP";if(k0(S,V0.WAV)&&S.length>=12)return S.subarray(8,12).toString("ascii")==="WAVE";if(k0(S,V0.AVI)&&S.length>=12)return S.subarray(8,12).toString("ascii")==="AVI ";return!1},F0=(S,$)=>{if(!S)return F5($);let w=S.toLowerCase();if(w.startsWith("image/")||w.startsWith("video/")||w.startsWith("audio/")||w==="application/pdf"||w==="application/octet-stream"||w.startsWith("application/zip")||w.startsWith("application/x-"))return"base64";if(w.startsWith("text/")||w.startsWith("application/json")||w.startsWith("application/xml")||w.startsWith("application/javascript"))return"utf8";return"binary"},F5=(S)=>{if(Buffer.isBuffer(S))return z5(S)?"base64":"utf8";if(typeof S==="object"&&S!==null)return"utf8";if(typeof S==="string")return"utf8";return"utf8"},z5=(S)=>{if(S.length===0)return!1;let $=Object.values(V0);for(let Y of $)if(k0(S,Y))return!0;if(k5(S))return!0;let w=S.filter((Y)=>Y===0).length,Z=S.filter((Y)=>Y<32&&Y!==9&&Y!==10&&Y!==13).length;return w/S.length>0.1||Z/S.length>0.3};var B5=(S)=>{if(!(S.startsWith("{")&&S.endsWith("}")||S.startsWith("[")&&S.endsWith("]")))return!1;try{return JSON.parse(S),!0}catch{return!1}},H5=(S)=>S.includes("=")&&S.includes("&"),E5=(S)=>S.includes("boundary="),K5=(S)=>typeof S==="object"&&S!==null&&!Buffer.isBuffer(S)&&!(S instanceof Uint8Array)&&!(S instanceof ArrayBuffer)&&!(S instanceof Date),O5=(S)=>S instanceof Date,D5=(S)=>{if(Buffer.isBuffer(S))return S;return Buffer.from(S)},L5=(S)=>{return F0(void 0,S)==="base64"?"application/octet-stream":"text/plain"},t0=(S)=>{let $=S.trim();if(B5($))return s.json;if(H5($))return s.form;if(E5($))return s.multipart;return"text/plain"},U$=(S)=>{if(S===null||S===void 0)return"text/plain";if(O5(S))return"text/plain";if(K5(S))return s.json;if(typeof S==="string")return t0(S);if(Buffer.isBuffer(S)||S instanceof Uint8Array||S instanceof ArrayBuffer){let $=D5(S);return L5($)}return"text/plain"};var I5=(S,$,w)=>{let Z=Buffer.byteLength(S,"utf8");if($===s.json){if(Z>w.json.maxSize)throw Error(`JSON body too large: ${Z} bytes exceeds limit of ${w.json.maxSize} bytes`)}else if($===s.form){if(Z>w.urlEncoded.maxSize)throw Error(`URL-encoded body too large: ${Z} bytes exceeds limit of ${w.urlEncoded.maxSize} bytes`)}else if($===s.multipart){if(Z>w.fileUploads.maxTotalSize)throw Error(`Multipart body too large: ${Z} bytes exceeds limit of ${w.fileUploads.maxTotalSize} bytes`)}},M$=(S,$={})=>{let{headerContentType:w,boundary:Z,config:Y}=$;if(!S||!S.trim())return;let y=w??t0(S);if(Y)I5(S,y,Y);if(y===s.json){if(!Y)throw Error("Body parser configuration is required for JSON parsing");return J$(S,Y.json)}if(y===s.multipart){if(!Z)throw Error("Invalid multipart form data: missing boundary");return X$(S,Z,Y?.fileUploads)}if(y===s.form)return Q$(S,Y?.urlEncoded);return S};var i0=(S,$)=>{let w=S.indexOf($);if(w===-1)return[S,""];let Z=S.slice(0,w),Y=S.slice(w+$.length);return[Z,Y]};var G$=(S)=>{if(!S||!S.trim())return{method:"GET",path:"/",protocol:"HTTP/1.1",headersRaw:"",rawBody:""};let[$,w]=i0(S,`\r
|
|
169
|
-
`),[Z,Y,y]=$.split(" ",3),[W,J]=i0(w,`\r
|
|
8
|
+
`);if(Y===-1)return["",""];let Z=W.slice(0,Y),Q=W.slice(Y+4);return[Z,Q]},p1=($)=>{let W={name:""},Y=/name=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec($),Z=/filename=(?:"(?<temp2>[^"]*)"|(?<temp1>[^;,\s]+))/i.exec($);if(Y)W.name=Y[1]??Y[2]??"";if(Z){let Q=Z[1]??Z[2];if(Q)W.filename=Q}return W},f1=($)=>{let Y=$.split(/\r?\n/).find((Z)=>Z.toLowerCase().startsWith("content-type:"));if(!Y)return"application/octet-stream";return Y.slice(Y.indexOf(":")+1).trim().split(";")[0]?.trim()??"application/octet-stream"},l1=($)=>{return["image/","audio/","video/","application/octet-stream","application/pdf","application/zip","application/x-"].some((Y)=>$.toLowerCase().startsWith(Y))},g1=($)=>Buffer.isBuffer($)?$.length:Buffer.byteLength($,"utf8"),s1=($,W)=>{if(!W)return;if($.size>W.maxFileSize)throw G.warn("[SECURITY] File upload too large",{filename:$.filename,size:$.size,limit:W.maxFileSize,sizeMB:Math.round($.size/1024/1024)}),Error(`File too large: ${$.filename} is ${$.size} bytes, exceeds limit of ${W.maxFileSize} bytes`);if($.filename&&$.filename.length>W.maxFilenameLength)throw Error(`Filename too long: ${$.filename.length} characters exceeds limit of ${W.maxFilenameLength}`);if($.filename){let Y=$.filename.toLowerCase().substring($.filename.lastIndexOf("."));if(W.blockedExtensions.includes(Y))throw G.warn("[SECURITY] Blocked file type upload attempt",{filename:$.filename,extension:Y,blockedExtensions:W.blockedExtensions}),Error(`File type not allowed: ${Y} files are blocked for security reasons`);if(W.allowedExtensions.length>0&&!W.allowedExtensions.includes(Y))throw Error(`File type not allowed: ${Y} is not in the allowed extensions list`)}},d1=({contentDisposition:$,contentSection:W,headersSection:Y,config:Z})=>{let Q=f1(Y),X=W.endsWith(`\r
|
|
9
|
+
`)?W.slice(0,-2):W,J=l1(Q)?Buffer.from(X,"binary"):X,M={filename:$.filename??"",contentType:Q,size:g1(J),content:J};return s1(M,Z),M},i$=($,W,Y)=>{let Z={fields:{},files:[]},Q=$.split(`--${W}`).slice(1),X=0;for(let J of Q){if(!J||J.trim()===""||J.trim()==="--")continue;let[M,V]=m1(J);if(!M)continue;let S=M.split(/\r?\n/).find((T)=>T.toLowerCase().startsWith("content-disposition:"));if(!S)continue;let E=p1(S);if(!E.name)continue;if(E.filename!==void 0){if(Y&&Z.files.length>=Y.maxFiles)throw G.warn("[SECURITY] Too many files in upload request",{fileCount:Z.files.length,maxFiles:Y.maxFiles}),Error(`Too many files: maximum of ${Y.maxFiles} files allowed per request`);let T=d1({contentDisposition:E,contentSection:V,headersSection:M,config:Y});if(X+=T.size,Y&&X>Y.maxTotalSize)throw G.warn("[SECURITY] Total upload size too large",{totalSize:X,limit:Y.maxTotalSize,totalSizeMB:Math.round(X/1024/1024)}),Error(`Total file size too large: ${X} bytes exceeds limit of ${Y.maxTotalSize} bytes`);Z.files.push(T)}if(E.filename===void 0){let T=V.endsWith(`\r
|
|
10
|
+
`)?V.slice(0,-2):V;Z.fields[E.name]=T}}return Z};var r1=($,W)=>{if($.length>W.maxFields)throw Error(`Too many form fields: ${$.length} exceeds limit of ${W.maxFields}`)},c1=($,W,Y)=>{if($.length>Y.maxFieldNameLength)throw Error(`Form field name too long: ${$.length} characters exceeds limit of ${Y.maxFieldNameLength}`);if(W&&W.length>Y.maxFieldLength)throw Error(`Form field value too long: field '${$}' has ${W.length} characters, exceeds limit of ${Y.maxFieldLength}`)},a1=($,W,Y)=>{if($.length>Y.maxFieldNameLength)throw Error(`Decoded form field name too long: ${$.length} characters exceeds limit of ${Y.maxFieldNameLength}`);if(W.length>Y.maxFieldLength)throw Error(`Decoded form field value too long: field '${$}' has ${W.length} characters, exceeds limit of ${Y.maxFieldLength}`)},i1=($,W,Y)=>{let[Z,Q]=$.split("=");if(!Z)return;if(Y)c1(Z,Q,Y);try{let X=decodeURIComponent(Z),J=Q?decodeURIComponent(Q):"";if(Y)a1(X,J,Y);W[X]=J}catch(X){if(X instanceof Error&&X.message.includes("exceeds limit"))throw X;W[Z]=Q??""}},n$=($,W)=>{let Y={},Z=$.split("&");if(W)r1(Z,W);for(let Q of Z)i1(Q,Y,W);return Y};var Q$={JPEG:[255,216,255],PNG:[137,80,78,71],GIF87A:[71,73,70,56,55,97],GIF89A:[71,73,70,56,57,97],BMP:[66,77],TIFF_LE:[73,73,42,0],TIFF_BE:[77,77,0,42],WEBP:[82,73,70,70],ICO:[0,0,1,0],MP3_ID3:[73,68,51],MP3_FRAME:[255,251],WAV:[82,73,70,70],FLAC:[102,76,97,67],OGG:[79,103,103,83],MP4_FTYP:[0,0,0,24,102,116,121,112],MP4_FTYP_ALT:[0,0,0,28,102,116,121,112],AVI:[82,73,70,70],WEBM:[26,69,223,163],PDF:[37,80,68,70],ZIP:[80,75,3,4],ZIP_EMPTY:[80,75,5,6],ZIP_SPANNED:[80,75,7,8],RAR:[82,97,114,33,26,7,0],RAR5:[82,97,114,33,26,7,1,0],SEVENZ:[55,122,188,175,39,28],GZIP:[31,139],EXE:[77,90],ELF:[127,69,76,70],OFFICE_OLD:[208,207,17,224,161,177,26,225]},X$=($,W)=>{if($.length<W.length)return!1;return W.every((Y,Z)=>$[Z]===Y)},n1=($)=>{if(X$($,Q$.WEBP)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="WEBP";if(X$($,Q$.WAV)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="WAVE";if(X$($,Q$.AVI)&&$.length>=12)return $.subarray(8,12).toString("ascii")==="AVI ";return!1},J$=($,W)=>{if(!$)return t1(W);let Y=$.toLowerCase();if(Y.startsWith("image/")||Y.startsWith("video/")||Y.startsWith("audio/")||Y==="application/pdf"||Y==="application/octet-stream"||Y.startsWith("application/zip")||Y.startsWith("application/x-"))return"base64";if(Y.startsWith("text/")||Y.startsWith("application/json")||Y.startsWith("application/xml")||Y.startsWith("application/javascript"))return"utf8";return"binary"},t1=($)=>{if(Buffer.isBuffer($))return o1($)?"base64":"utf8";if(typeof $==="object"&&$!==null)return"utf8";if(typeof $==="string")return"utf8";return"utf8"},o1=($)=>{if($.length===0)return!1;let W=Object.values(Q$);for(let Q of W)if(X$($,Q))return!0;if(n1($))return!0;let Y=$.filter((Q)=>Q===0).length,Z=$.filter((Q)=>Q<32&&Q!==9&&Q!==10&&Q!==13).length;return Y/$.length>0.1||Z/$.length>0.3};var e1=($)=>{if(!($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")))return!1;try{return JSON.parse($),!0}catch{return!1}},$0=($)=>$.includes("=")&&$.includes("&"),W0=($)=>$.includes("boundary="),Y0=($)=>typeof $==="object"&&$!==null&&!Buffer.isBuffer($)&&!($ instanceof Uint8Array)&&!($ instanceof ArrayBuffer)&&!($ instanceof Date),Z0=($)=>$ instanceof Date,Q0=($)=>{if(Buffer.isBuffer($))return $;return Buffer.from($)},X0=($)=>{return J$(void 0,$)==="base64"?"application/octet-stream":"text/plain"},N$=($)=>{let W=$.trim();if(e1(W))return b.json;if($0(W))return b.form;if(W0(W))return b.multipart;return"text/plain"},t$=($)=>{if($===null||$===void 0)return"text/plain";if(Z0($))return"text/plain";if(Y0($))return b.json;if(typeof $==="string")return N$($);if(Buffer.isBuffer($)||$ instanceof Uint8Array||$ instanceof ArrayBuffer){let W=Q0($);return X0(W)}return"text/plain"};var J0=($,W,Y)=>{let Z=Buffer.byteLength($,"utf8");if(W===b.json){if(Z>Y.json.maxSize)throw Error(`JSON body too large: ${Z} bytes exceeds limit of ${Y.json.maxSize} bytes`)}else if(W===b.form){if(Z>Y.urlEncoded.maxSize)throw Error(`URL-encoded body too large: ${Z} bytes exceeds limit of ${Y.urlEncoded.maxSize} bytes`)}else if(W===b.multipart){if(Z>Y.fileUploads.maxTotalSize)throw Error(`Multipart body too large: ${Z} bytes exceeds limit of ${Y.fileUploads.maxTotalSize} bytes`)}},o$=($,W={})=>{let{headerContentType:Y,boundary:Z,config:Q}=W;if(!$||!$.trim())return;let X=Y??N$($);if(Q)J0($,X,Q);if(X===b.json){if(!Q)throw Error("Body parser configuration is required for JSON parsing");return a$($,Q.json)}if(X===b.multipart){if(!Z)throw Error("Invalid multipart form data: missing boundary");return i$($,Z,Q?.fileUploads)}if(X===b.form)return n$($,Q?.urlEncoded);return $};var H$=($,W)=>{let Y=$.indexOf(W);if(Y===-1)return[$,""];let Z=$.slice(0,Y),Q=$.slice(Y+W.length);return[Z,Q]};var e$=($)=>{if(!$||!$.trim())return{method:"GET",path:"/",protocol:"HTTP/1.1",headersRaw:"",rawBody:""};let[W,Y]=H$($,`\r
|
|
11
|
+
`),[Z,Q,X]=W.split(" ",3),[J,M]=H$(Y,`\r
|
|
170
12
|
\r
|
|
171
|
-
`);if(!Z||!Object.values(
|
|
13
|
+
`);if(!Z||!Object.values(z).includes(Z))return{method:"GET",path:Q??"/",protocol:X??"HTTP/1.1",headersRaw:J,rawBody:M};return{method:Z,path:Q??"/",protocol:X??"HTTP/1.1",headersRaw:J,rawBody:M}};var $1=($)=>{if(!$)return{};if(!$.includes("?"))return{};let[,W]=$.split("?");if(!W)return{};let Y={},Z=W.split("&");for(let Q of Z){let[X,J]=Q.split("=");if(X)try{let M=decodeURIComponent(X),V=J?decodeURIComponent(J):"";Y[M]=V}catch{Y[X]=J??""}}return Y};var M0=[/^(?<classA>10)\./,/^(?<classB>172)\.(?<classBRange>1[6-9]|2[0-9]|3[0-1])\./,/^(?<classC>192)\.(?<classCRange>168)\./,/^(?<linkLocal>169)\.(?<linkLocalRange>254)\./,/^(?<loopback>127)\./,/^(?<ipv6Loopback>::1)$/,/^(?<ipv6LinkLocal>fe80):/i,/^(?<ipv6UniqueLocalFC>fc00):/i,/^(?<ipv6UniqueLocalFD>fd00):/i],W1=($)=>{if(!$||typeof $!=="string")return!1;let W=$.replace(/^\[|\]$/g,"");if(/^(?<octet>(?<highByte>25[0-5]|(?<midByte>2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/.test(W)){let Q=W.split(".");return Q.length===4&&Q.every((X)=>{let J=parseInt(X,10);return J>=0&&J<=255})}if(W.includes("::")&&(W.match(/::/g)??[]).length>1)return!1;return/^(?<ipv6Address>(?<fullAddress>(?<hexQuad>[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4})|(?<compressedAddress>(?<leadingPart>[0-9a-fA-F]{1,4}:){1,7}:)|(?<mixedCompression>(?<frontPart>[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4})|(?<doubleColonOnly>::)|(?<linkLocal>fe80:(?<linkSuffix>:[0-9a-fA-F]{0,4}){0,4}(?<zoneId>%[0-9a-zA-Z]+)?)|(?<ipv4MappedFull>::ffff:(?<mappedIpv4>(?<mappedOctet>[0-9]{1,3}\.){3}[0-9]{1,3}))|(?<generalPattern>(?<segmentGroup>[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}))$/.test(W)},Y1=($)=>{if(!$)return!1;let W=$.replace(/^\[|\]$/g,"");return M0.some((Y)=>Y.test(W))},Z1=($,W)=>{if(!$||!W.length)return!1;if(W.includes("*"))return!0;return W.includes($)},D0=($,W)=>{if(!W.detectSpoofing||$.length<=1)return!1;if($.length>W.maxChainLength)return!0;if(new Set($).size!==$.length)return!0;let Z=$.filter(W1).length;if(Z>0&&Z<$.length)return!0;return!1},K0=($,W)=>{if($.length<=1)return!0;let Y=$[$.length-1];return Boolean(Y&&Z1(Y,W.trustedProxies))},j0=($,W)=>{if(W==="x-forwarded-for")return $[0];return $[$.length-1]},U0=($)=>{let{clientIp:W,headerName:Y,ipChain:Z,config:Q}=$,X=Y1(W),J=Y==="x-forwarded-for"?Z1(Z[Z.length-1]??"",Q.trustedProxies):!0;return{ip:W,isValid:!0,isPrivate:X,source:Y,trusted:J}},G0=()=>({ip:"",isValid:!1,isPrivate:!1,source:"socket",trusted:!1}),F0=($,W)=>{for(let Y of W.headerPreference){let Z=$[Y];if(!Z)continue;let Q=Z.split(",").map((M)=>M.trim()).filter(Boolean);if(Q.length===0)continue;if(D0(Q,W))continue;if(Y==="x-forwarded-for"&&!K0(Q,W))continue;let X=j0(Q,Y);if(!X||!W1(X))continue;if(Y1(X)&&!W.allowPrivateIps)continue;return U0({clientIp:X,headerName:Y,ipChain:Q,config:W})}return G0()},q0=($,W,Y={})=>{let Q={...$._configuration.ipSecurity,...Y},X=F0(W,Q);if(X.isValid)return X;return{ip:"",isValid:!1,isPrivate:!1,source:"socket",trusted:!1}},Q1=($,W)=>{return q0($,W).ip};var X1=($)=>{if(!$)return;return/boundary\s*=\s*(?<temp1>[^;,\s]*)/i.exec($)?.[1]};var J1=($)=>{if(!$)return{};w0($);let W=V0($),Y=B0(W);return O0(Y)},w0=($)=>{if($.split(/\r\n|\r|\n/).length>100)throw Error("Too many headers: maximum 100 allowed")},V0=($)=>{let W={},Z=$.replace(/\r\n|\r|\n/g,`
|
|
172
14
|
`).split(`
|
|
173
|
-
`);for(let
|
|
174
|
-
`))throw Error(`Header value contains invalid line break characters: ${
|
|
15
|
+
`);for(let Q of Z){if(!Q.trim())continue;let X=Q.indexOf(":");if(X===-1)continue;let J=Q.slice(0,X).trim(),M=Q.slice(X+1).trim();if(!J)continue;if(!N0(J))throw Error(`Invalid header name: ${J}`);if(J.length>200)throw Error("Header name too long: maximum 200 characters allowed");if(M.length>8192)throw Error("Header value too long: maximum 8192 characters allowed");W[J.toLowerCase()]=M}return W},B0=($)=>{let W={};for(let[Y,Z]of Object.entries($))W[Y]=H0(Z);return W},O0=($)=>$,N0=($)=>{return/^[a-zA-Z0-9!#$%&'*+\-.^_`|~]+$/.test($)},H0=($)=>{return $.replace(/[\x00-\x08\x0A-\x1F\x7F]/g,"")};class E${_rawRequest;_setup;method;path;protocol;headers;body;query;params;ipAddress;rawBody;constructor($,W,Y){this._rawRequest=$,this._setup=W,this.ipAddress=Y??"";let{method:Z,path:Q,protocol:X,headers:J,body:M,query:V,params:B,rawBody:S}=this._parseRequestIntoObject();this.method=Z,this.path=Q,this.protocol=X,this.headers=J,this.body=M,this.query=V??{},this.params=B??{},this.rawBody=S;let E=Q1(this._setup,J);if(E)this.ipAddress=E}_parseRequestIntoObject(){let $=this._rawRequest.toString(),{method:W,path:Y,protocol:Z,headersRaw:Q,rawBody:X}=e$($),J=J1(Q),M=J["content-type"],V=M?.split(";")[0]?.trim().toLowerCase(),B=X1(M);return{method:W,path:Y,protocol:Z,headers:J,body:o$(X,{headerContentType:V,boundary:B,config:this._setup._configuration.bodyParser}),query:$1(Y),params:{},rawBody:X}}}var j1=G$(W$(),1);var M1=($,W)=>{let Y=W?.encoding??"utf8";if($===null||$===void 0)return"";if(Buffer.isBuffer($))return A$($,Y);if($ instanceof Uint8Array)return E0($,Y);if($ instanceof ArrayBuffer)return A0($,Y);if(typeof $==="string")return $;if(typeof $==="object")return z0($);return String($)},A$=($,W)=>{if(W==="base64")return $.toString("base64");if(W==="binary")return $.toString("binary");return $.toString("utf8")},E0=($,W)=>{let Y=Buffer.from($);return A$(Y,W)},A0=($,W)=>{let Y=Buffer.from($);return A$(Y,W)},z0=($)=>{try{return JSON.stringify($)}catch(W){return String($)}};var D1=new Map;for(let[$,W]of Object.entries(R)){let Z=r[$];D1.set(W,Z)}var K1=($)=>{let W=D1.get($);if(!W)throw Error(`Unknown status code: ${$}`);return W};var _0=($,W)=>{if(typeof W!=="string")throw Error(`Header value must be a string, got ${typeof W}`);if(W.includes("\r")||W.includes(`
|
|
16
|
+
`))throw Error(`Header value contains invalid line break characters: ${$}`);let Y=[/[\r\n](?:set-cookie|location|authorization|www-authenticate):/i,/\r\n\r\n|\n\n/,/[\r\n]http\/\d\.\d\s+\d+/i];for(let Z of Y)if(Z.test(W))throw Error(`Header value contains suspicious injection pattern: ${$}`)},I0=($)=>{for(let[W,Y]of Object.entries($))_0(W,Y)},z$=($)=>{let W={};for(let[Y,Z]of Object.entries($))if(Z!==void 0)W[Y]=Z;return I0(W),W};var i=($)=>{if(S0($))return $.length;if(typeof $==="string")return Buffer.byteLength($,"utf8");if(L0($))try{let W=JSON.stringify($);return Buffer.byteLength(W,"utf8")}catch{return 0}return 0},S0=($)=>typeof Buffer<"u"&&Buffer.isBuffer($),L0=($)=>typeof $==="object"&&$!==null;class _${_request;_statusCode=R.ok;_status=r.ok;_headers={};_body="";_stringBody="";_encoding=l$.utf8;constructor($){this._request=$,this._setSecurityHeaders()}_parseResponseIntoString(){let $=`${this._request.protocol} ${this._statusCode} ${this._status}`,W=Object.entries(this._headers).map(([J,M])=>`${J}: ${M}`),Y=J$(this._headers["content-type"],this._body),Z=M1(this._body,{encoding:Y});this._encoding=Y;let Q=W.length>0?`${W.join(`
|
|
175
17
|
`)}
|
|
176
|
-
`:"";this._stringBody=`${
|
|
177
|
-
${
|
|
178
|
-
${Z}`;let
|
|
18
|
+
`:"";this._stringBody=`${$}
|
|
19
|
+
${Q}
|
|
20
|
+
${Z}`;let X=i(this._stringBody);this._setHeadersIfNotSet({Date:j1.default().format("ddd, DD MMM YYYY HH:mm:ss [GMT]"),"Content-Length":String(X)})}_setHeadersIfNotSet($){let W={};for(let[Z,Q]of Object.entries($))if(Q!==void 0&&!(Z in this._headers))W[Z]=Q;let Y=z$(W);Object.assign(this._headers,Y)}_setBody($){if(this._body=$,!this._headers["content-type"]){let W=t$($);this._setHeadersIfNotSet({"Content-Type":W})}}setStatusCode($){this._statusCode=$,this._status=K1($)}addHeaders($){let W=z$($);this._headers={...this._headers,...W}}removeHeaders($){for(let W of $)delete this._headers[W]}_setSecurityHeaders(){this._setHeadersIfNotSet({"X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"})}}class I${_request;_response;request;response;state={};constructor($,W,Y){this._request=new E$($,W,Y),this._response=new _$(this._request),this.request=this._request,this.response=this._response}}var k0={enabled:!0,origin:"*",methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:"*",exposedHeaders:[],credentials:!1,maxAge:86400,preflightContinue:!1,optionsSuccessStatus:R.noContent},M$={json:{maxSize:262144,maxDepth:10,allowPrototypeProperties:!1,maxKeys:1000,maxStringLength:1048576,maxArrayLength:1e4},fileUploads:{maxFileSize:10485760,maxTotalSize:52428800,maxFiles:10,allowedExtensions:[],blockedExtensions:[".exe",".bat",".cmd",".scr",".pif",".com"],maxFilenameLength:255},urlEncoded:{maxSize:1048576,maxFields:1000,maxFieldNameLength:100,maxFieldLength:1048576}},U1={trustedProxies:["127.0.0.1","::1"],allowPrivateIps:!0,headerPreference:["x-forwarded-for","x-real-ip","cf-connecting-ip","x-client-ip","true-client-ip"],maxChainLength:10,detectSpoofing:!0},T0={port:5000,host:"0.0.0.0",networkLogs:!1,gracefulShutdownTimeout:"15m",cors:{enabled:!1},bodyParser:M$,ipSecurity:U1},v0=($)=>{if($.maxSize<1)throw Error("bodyParser.json.maxSize must be at least 1 byte");if($.maxDepth<1)throw Error("bodyParser.json.maxDepth must be at least 1");if($.maxKeys<1)throw Error("bodyParser.json.maxKeys must be at least 1");if($.maxStringLength<1)throw Error("bodyParser.json.maxStringLength must be at least 1 byte");if($.maxArrayLength<1)throw Error("bodyParser.json.maxArrayLength must be at least 1")},P0=($)=>{if($.maxFileSize<1)throw Error("bodyParser.fileUploads.maxFileSize must be at least 1 byte");if($.maxTotalSize<1)throw Error("bodyParser.fileUploads.maxTotalSize must be at least 1 byte");if($.maxFiles<1)throw Error("bodyParser.fileUploads.maxFiles must be at least 1");if($.maxFilenameLength<1)throw Error("bodyParser.fileUploads.maxFilenameLength must be at least 1 character")},R0=($)=>{if($.maxSize<1)throw Error("bodyParser.urlEncoded.maxSize must be at least 1 byte");if($.maxFields<1)throw Error("bodyParser.urlEncoded.maxFields must be at least 1");if($.maxFieldNameLength<1)throw Error("bodyParser.urlEncoded.maxFieldNameLength must be at least 1 character");if($.maxFieldLength<1)throw Error("bodyParser.urlEncoded.maxFieldLength must be at least 1 byte")},b0=($)=>{if(!Array.isArray($.trustedProxies))throw Error("ipSecurity.trustedProxies must be an array");if(!Array.isArray($.headerPreference))throw Error("ipSecurity.headerPreference must be an array");if($.headerPreference.length===0)throw Error("ipSecurity.headerPreference must contain at least one header");if($.maxChainLength<1)throw Error("ipSecurity.maxChainLength must be at least 1");if($.maxChainLength>50)throw Error("ipSecurity.maxChainLength must not exceed 50 to prevent DoS attacks")},C0=($)=>{if($.allowPrototypeProperties)G.warn("[SECURITY WARNING] bodyParser.json.allowPrototypeProperties is enabled. This allows prototype pollution attacks. Only enable this if you absolutely need it and have other protections in place.");if($.maxSize>10485760)G.warn(`[SECURITY WARNING] bodyParser.json.maxSize is set to ${$.maxSize} bytes (${Math.round($.maxSize/1024/1024)}MB). Large JSON payloads can cause memory exhaustion and DoS attacks. Consider if this size is necessary.`);if($.maxDepth>50)G.warn(`[SECURITY WARNING] bodyParser.json.maxDepth is set to ${$.maxDepth}. Very deep JSON nesting can cause stack overflow attacks. Consider if this depth is necessary.`)},x0=($)=>{if($.maxFileSize>104857600)G.warn(`[SECURITY WARNING] bodyParser.fileUploads.maxFileSize is set to ${$.maxFileSize} bytes (${Math.round($.maxFileSize/1024/1024)}MB). Large file uploads can consume significant server resources.`);if($.maxTotalSize>1073741824)G.warn(`[SECURITY WARNING] bodyParser.fileUploads.maxTotalSize is set to ${$.maxTotalSize} bytes (${Math.round($.maxTotalSize/1024/1024/1024)}GB). Very large total upload sizes can cause memory and disk space exhaustion.`);let W=[".exe",".bat",".cmd",".scr",".pif",".com",".vbs",".jar",".app"],Y=$.allowedExtensions.filter((Z)=>W.includes(Z.toLowerCase()));if(Y.length>0)G.warn(`[SECURITY WARNING] bodyParser.fileUploads.allowedExtensions includes dangerous file types: ${Y.join(", ")}. This could allow execution of malicious files. Only allow these if absolutely necessary.`);if($.blockedExtensions.length===0&&$.allowedExtensions.length===0)G.warn("[SECURITY WARNING] File uploads have no extension restrictions (no blockedExtensions and no allowedExtensions). Consider adding blockedExtensions or allowedExtensions to improve security.")},u0=($)=>{if($.trustedProxies.length===0)G.warn("[SECURITY WARNING] ipSecurity.trustedProxies is empty. No proxy headers will be trusted, which may prevent proper client IP detection.");if($.maxChainLength>20)G.warn(`[SECURITY WARNING] ipSecurity.maxChainLength is set to ${$.maxChainLength}. Very long proxy chains can consume significant resources and may indicate amplification attacks.`);if(!$.detectSpoofing)G.warn("[SECURITY WARNING] ipSecurity.detectSpoofing is disabled. This reduces protection against IP spoofing attacks. Only disable if you have other protective measures.")},y0=($,W)=>{if(W?.cors?.enabled)$.cors={...k0,...W.cors,enabled:!0}},h0=($,W)=>{if(W?.bodyParser)$.bodyParser={json:{...M$.json,...W.bodyParser.json},fileUploads:{...M$.fileUploads,...W.bodyParser.fileUploads},urlEncoded:{...M$.urlEncoded,...W.bodyParser.urlEncoded}},f0($.bodyParser)},m0=($,W)=>{if(W?.ipSecurity)$.ipSecurity={...U1,...W.ipSecurity},b0($.ipSecurity),u0($.ipSecurity)},p0=($,W)=>{if(W?.port!==void 0){let Y=Number(W.port);if(isNaN(Y)||Y<1||Y>65535)throw Error("Invalid port number");$.port=Y}},f0=($)=>{v0($.json),P0($.fileUploads),R0($.urlEncoded),C0($.json),x0($.fileUploads)},G1=($)=>{let W={...T0};return Object.assign(W,$),y0(W,$),h0(W,$),m0(W,$),p0(W,$),W};class S${_beforeAll;_afterAll;_onError;_onNotFound;constructor(){this._beforeAll=new Set,this._afterAll=new Set,this._onError=($,W)=>{return G.error("Error while handeling your request: ",W),$.response.setStatusCode(R.internalServerError),{success:!1,message:"Internal Server Error"}},this._onNotFound=($)=>{return $.response.setStatusCode(R.notFound),{success:!1,message:"404 Not Found"}}}_addBeforeHooks($,W){this._validateHandlersArray($,"beforeAll");for(let Y of $)this._beforeAll.add({handler:Y,options:W??{routesToExclude:[],routesToInclude:[]}})}_addAfterHooks($,W){this._validateHandlersArray($,"afterAll");for(let Y of $)this._afterAll.add({handler:Y,options:W??{routesToExclude:[],routesToInclude:[]}})}_validateHandlersArray($,W){if(!Array.isArray($)){let Y=typeof $;throw Error(`YinzerFlow: ${W}() expects an array of handler functions, but received ${Y}.${Y==="function"?`
|
|
179
21
|
|
|
180
|
-
❌ Incorrect: app.${
|
|
181
|
-
✅ Correct: app.${
|
|
22
|
+
❌ Incorrect: app.${W}${O.red}(${O.reset}(ctx) => { ... }${O.red})${O.reset}
|
|
23
|
+
✅ Correct: app.${W}${O.green}([${O.reset}(ctx) => { ... }${O.green}])${O.reset}
|
|
182
24
|
|
|
183
|
-
Note: Wrap your handler function in ${
|
|
25
|
+
Note: Wrap your handler function in ${O.magenta}square brackets${O.reset} to make it an array.
|
|
184
26
|
|
|
185
27
|
`:`
|
|
186
28
|
|
|
187
29
|
Expected: Array<HandlerCallback>
|
|
188
|
-
Received: ${w}`}`)}if(S.length===0){B.warn(`${$}() called with empty array. No hooks will be registered.`);return}for(let w=0;w<S.length;w++){let Z=S[w];if(typeof Z!=="function")throw Error(`YinzerFlow: ${$}() array contains non-function at index ${w}. Expected: function, received: ${typeof Z}`)}}_addOnError(S){this._onError=S}_addOnNotFound(S){this._onNotFound=S}}var j$=(S)=>{let $=[],w=S.path.replace(/:\w+/g,(Z)=>{let Y=Z.slice(1);return $.push(Y),"([^/]+)"}).replace(/\//g,"\\/");return{...S,pattern:new RegExp(`^${w}$`),paramNames:$,isParameterized:!0}};var SS=(S)=>{let[$]=S.split("?");if(!$)return"";if([$]=$.split("#"),!$)return"";try{$=decodeURIComponent($)}catch(w){B.warn("Failed to decode URL path",{path:$})}if($=$.startsWith("/")?$:`/${$}`,$=$.replace(/\/\/+/g,"/"),$=J6($),$.length>1&&$.endsWith("/"))$=$.slice(0,-1);return $},J6=(S)=>{let $=S.split("/"),w=[];for(let Y of $){if(Y==="."||Y===""){if(Y===""&&w.length===0)w.push(Y);continue}if(Y===".."){if(w.length>1)w.pop()}else w.push(Y)}return w.join("/")||"/"},$S=(S)=>S.replace(/:\w+/g,":param");var A$=(S)=>{let $=S.match(/:\w+/g);if(!$)return;let w=$.map((Y)=>Y.slice(1)),Z=new Set(w);if(w.length!==Z.size){let Y=w.filter((y,W)=>w.indexOf(y)!==W);throw Error(`Route ${S} has duplicate parameter names: ${Y.join(", ")}. Parameter names must be unique within a route for clarity and to prevent conflicts.`)}};class wS{_exactRoutes=new Map;_parameterizedRoutes=new Map;_register({method:S,path:$,handler:w,options:Z}){let Y=SS($),y=Y.includes(":");if(y)A$(Y);if(this._hasExactRoutePattern(S,Y))throw Error(`Route ${Y} already exists for method ${S}`);let W={method:S,path:Y,handler:w,options:Z,params:{}};if(y)this._storeParameterizedRoute(S,W);else this._storeExactRoute(S,Y,W)}_findRoute(S,$){let w=SS($),Z=this._exactRoutes.get(S)?.get(w);if(Z)return Z;let Y=this._findParameterizedRoute(S,w);if(Y)return Y;return}_hasExactRoutePattern(S,$){if(this._exactRoutes.get(S)?.has($))return!0;if($.includes(":")){let w=$S($),Z=this._parameterizedRoutes.get(S);if(Z)return Z.some((Y)=>$S(Y.path)===w)}else{let w=this._parameterizedRoutes.get(S);if(w)return w.some((Z)=>Z.path===$)}return!1}_storeExactRoute(S,$,w){if(!this._exactRoutes.has(S))this._exactRoutes.set(S,new Map);this._exactRoutes.get(S)?.set($,w)}_storeParameterizedRoute(S,$){if(!this._parameterizedRoutes.has(S))this._parameterizedRoutes.set(S,[]);let w=j$($);this._parameterizedRoutes.get(S)?.push(w)}_findParameterizedRoute(S,$){let w=this._parameterizedRoutes.get(S);if(!w)return;for(let Z of w){let Y=$.match(Z.pattern);if(Y){let y={};for(let W=0;W<Z.paramNames.length;W++){let J=Y[W+1],X=Z.paramNames[W];if(J!==void 0&&X!==void 0)y[X]=J}return{...Z,params:y}}}return}}var e=(S)=>({beforeHooks:S?.beforeHooks??[],afterHooks:S?.afterHooks??[]}),ZS=(S,$)=>({beforeHooks:[...S.beforeHooks??[],...$?.beforeHooks??[]],afterHooks:[...$?.afterHooks??[],...S.afterHooks??[]]}),YS=(S,$)=>{let w=S.endsWith("/")?S.slice(0,-1):S,Z=$.startsWith("/")?$:`/${$}`;return`${w}${Z}`};class B0{_setup;_prefix;_options;constructor(S,$,w){this._setup=S,this._prefix=$,this._options=e(w)}_createRouteHandler(S){return($,w,Z)=>{let Y=YS(this._prefix,$),y=ZS(this._options,Z);if(this._setup._routeRegistry._register({method:S,handler:w,path:Y,options:y,params:{}}),S===N.get)this._setup._routeRegistry._register({method:N.head,handler:w,path:Y,options:y,params:{}})}}get=this._createRouteHandler(N.get);head=this._createRouteHandler(N.head);post=this._createRouteHandler(N.post);put=this._createRouteHandler(N.put);delete=this._createRouteHandler(N.delete);patch=this._createRouteHandler(N.patch);options=this._createRouteHandler(N.options);group(S,$,w){let Z=YS(this._prefix,S),Y=ZS(this._options,w),y=new B0(this._setup,Z,Y);return $(y),y}}class yS{_configuration;_routeRegistry=new wS;_hooks=new e0;constructor(S){this._configuration=I$(S)}get(S,$,w){let Z=e(w);this._routeRegistry._register({method:N.get,handler:$,path:S,options:Z,params:{}}),this._routeRegistry._register({method:N.head,handler:$,path:S,options:Z,params:{}})}head(S,$,w){this._routeRegistry._register({method:N.head,handler:$,path:S,options:e(w),params:{}})}post(S,$,w){this._routeRegistry._register({method:N.post,handler:$,path:S,options:e(w),params:{}})}put(S,$,w){this._routeRegistry._register({method:N.put,handler:$,path:S,options:e(w),params:{}})}patch(S,$,w){this._routeRegistry._register({method:N.patch,handler:$,path:S,options:e(w),params:{}})}delete(S,$,w){this._routeRegistry._register({method:N.delete,handler:$,path:S,options:e(w),params:{}})}options(S,$,w){this._routeRegistry._register({method:N.options,handler:$,path:S,options:e(w),params:{}})}group(S,$,w){let Z=new B0(this,S,w);return $(Z),Z}beforeAll(S,$){this._hooks._addBeforeHooks(S,$)}afterAll(S,$){this._hooks._addAfterHooks(S,$)}onError(S){this._hooks._addOnError(S)}onNotFound(S){this._hooks._addOnNotFound(S)}}var T$={prefix:"NETWORK",logLevel:"off",logger:void 0},f={log:l1(T$),enable:(S)=>{f.log=l1({...T$,logLevel:d1.info,logger:S})}},P$=(S)=>{if(S>=200&&S<300)return"✅";if(S>=300&&S<400)return"\uD83D\uDD04";if(S>=400&&S<500)return"❌";if(S>=500)return"\uD83D\uDCA5";return"❓"},WS=[{maxTime:50,emoji:"⚡",phrase:"faster than a Stillers touchdown!"},{maxTime:100,emoji:"\uD83D\uDD25",phrase:"smooth as butter n'at!"},{maxTime:200,emoji:"✅",phrase:"not bad yinz!"},{maxTime:500,emoji:"⚠️",phrase:"slowin' down a bit there"},{maxTime:1000,emoji:"\uD83D\uDC0C",phrase:"that's draggin' n'at"},{maxTime:1/0,emoji:"\uD83D\uDCA5",phrase:"what a jagoff response time!"}],R$=(S)=>{let $=WS.find((w)=>S<w.maxTime)??WS[WS.length-1];if(!$)throw Error("No threshold found for performance details");f.log.warn(`${D.magenta} ${$.emoji} Response time: ${S}ms - ${$.phrase}${D.reset}`)};var N$=()=>{let S=new Map;return{get:async($)=>Promise.resolve(S.get($)),set:async($,w)=>{return S.set($,w),Promise.resolve()},delete:async($)=>{return S.delete($),Promise.resolve()},destroy:async()=>{return S.clear(),Promise.resolve()}}};var aS=U0(mw(),1);var y1=(S)=>{if(typeof S==="number")return S;if(typeof S!=="string")throw Error("Invalid time format. Expected format: 1ms, 1s, 1m, 1h, 1d");if(S.length<2)throw Error("Invalid time format. Expected format: 1ms, 1s, 1m, 1h, 1d");if(S.length>3)throw Error("Invalid time format. Expected format: 1ms, 1s, 1m, 1h, 1d");let $=S.includes("ms")?S.slice(-2):S.slice(-1),w=S.includes("ms")?S.slice(0,-2):S.slice(0,-1);if(!["ms","s","m","h","d"].includes($))throw Error(`Invalid time unit: "${$}". Expected: s (seconds), m (minutes), h (hours), or d (days)`);let Z=Number(w);if(isNaN(Z)||Z<=0)throw Error(`Invalid time value: "${w}". Must be a positive number`);switch($){case"ms":return Z;case"s":return Z*1000;case"m":return Z*60*1000;case"h":return Z*60*60*1000;case"d":return Z*24*60*60*1000;default:throw Error(`Unsupported time unit: "${$}"`)}};var dw=async(S)=>{let{store:$}=S;if($.type!=="redis")throw Error(`Expected Redis store configuration but got: ${JSON.stringify($)}`);let{client:w,keyPrefix:Z="rate_limit:",maxRetries:Y=3,retryDelay:y=1000}=$,W=y1(y),J=!1;return await(async()=>{for(let U=1;U<=Y;U++)try{await w.ping(),J=!0,B.info(`[RedisStore] Successfully connected to Redis (attempt ${U})`);return}catch(Q){if(B.warn(`[RedisStore] Redis connection attempt ${U}/${Y} failed:`,Q),U<Y)B.info(`[RedisStore] Retrying connection in ${y}...`),await new Promise((M)=>{setTimeout(M,W)});else B.error("[RedisStore] All Redis connection attempts failed. Store will operate in degraded mode."),J=!1}})(),{get:async(U)=>zy({client:w,key:U,keyPrefix:Z,connectionHealthy:J}),set:async(U,Q)=>By({client:w,config:S,key:U,value:Q,keyPrefix:Z,connectionHealthy:J}),delete:async(U)=>Hy({client:w,key:U,keyPrefix:Z,connectionHealthy:J}),destroy:async()=>Ey({client:w,keyPrefix:Z,connectionHealthy:J})}},sS=(S,$)=>`${$}${S}`,qy=(S)=>{try{return JSON.stringify(S)}catch($){throw B.error("[RedisStore] Failed to serialize value:",$),Error("Failed to serialize rate limit data")}},Vy=(S)=>{try{return JSON.parse(S)}catch($){throw B.error("[RedisStore] Failed to deserialize value:",$),Error("Failed to deserialize rate limit data")}},f0=(S,$,w)=>{if(w)B.warn(`[RedisStore] Redis ${S} failed (connection was healthy):`,$);else B.error(`[RedisStore] Redis ${S} failed (connection unhealthy):`,$)},ky=async({client:S,key:$,value:w,ttlSeconds:Z})=>{try{if(S instanceof aS.Redis)await S.set($,w,"EX",Z);else await S.set($,w,{EX:Z})}catch(Y){if(Y instanceof Error)throw Error(`Unsupported Redis client or Redis operation failed: ${Y.message}`);throw Y}},Fy=async({client:S,key:$,value:w})=>{try{if(S instanceof aS.Redis)await S.set($,w,"KEEPTTL");else await S.set($,w,{KEEPTTL:!0})}catch(Z){if(Z instanceof Error)throw Error(`Unsupported Redis client or Redis operation failed: ${Z.message}`);throw Z}},zy=async({client:S,key:$,keyPrefix:w,connectionHealthy:Z})=>{try{let Y=sS($,w),y=await S.get(Y);if(y===null)return;return Vy(y)}catch(Y){f0("GET",Y,Z);return}},By=async({client:S,config:$,key:w,value:Z,keyPrefix:Y,connectionHealthy:y})=>{try{let W=sS(w,Y),J=qy(Z);if(await S.exists(W))await Fy({client:S,key:W,value:J});else await ky({client:S,key:W,value:J,ttlSeconds:Math.floor($.window/1000)})}catch(W){f0("SET",W,y)}},Hy=async({client:S,key:$,keyPrefix:w,connectionHealthy:Z})=>{try{let Y=sS($,w);await S.del(Y)}catch(Y){f0("DELETE",Y,Z)}},Ey=async({client:S,keyPrefix:$,connectionHealthy:w})=>{try{let Z=`${$}*`,Y=await S.keys(Z);if(Y.length>0)await Promise.all(Y.map(async(y)=>S.del(y))),B.info(`[RedisStore] Destroyed ${Y.length} rate limit keys`)}catch(Z){f0("DESTROY",Z,w)}};var Ky=()=>({memory:()=>N$(),redis:async(S)=>dw(S)}),lw=async(S)=>{let w=Ky()[S.store.type];if(!w)throw Error(`Unsupported store type: ${S.store.type}`);return w(S)};class rS{_config;_store=null;constructor(S){this._config=S}async _getStore(){return this._store??=await lw(this._config),this._store}async check(S){let $=await this._getStore(),w=this._config.keyGenerator(S),Z=Date.now(),Y=await $.get(w)??{currentWindowCount:0,previousWindowCount:0,windowStart:Z};if(Z-Y.windowStart>=this._config.window)Y.previousWindowCount=0,Y.currentWindowCount=0,Y.windowStart=Z;let J=(Z-Y.windowStart)/this._config.window,X=Y.previousWindowCount*(1-J),U=Y.currentWindowCount+X,Q=U<this._config.max;if(Q)Y.currentWindowCount++;await $.set(w,Y);let M=Math.max(0,Math.floor(this._config.max-U-(Q?1:0))),G=Y.windowStart+this._config.window;return{allowed:Q,remaining:M,resetTime:G,totalHits:Math.ceil(U+(Q?1:0)),limit:this._config.max}}async destroy(){await(await this._getStore()).destroy()}}var Oy=(S)=>Math.ceil((S-Date.now())/1000),Dy=(S)=>new rS(S);class W0{_config;_strategy;constructor(S){this._config=S,this._strategy=Dy(S)}async check(S){return this._strategy.check(S)}async destroy(){await this._strategy.destroy()}get config(){return this._config}}var nS=(S,$)=>{if(S.response.addHeaders({"RateLimit-Limit":String($.limit),"RateLimit-Remaining":String($.remaining),"RateLimit-Reset":String(Math.ceil($.resetTime/1000))}),!$.allowed){let w=Oy($.resetTime);S.response.addHeaders({"Retry-After":String(w)})}};var oS={slidingWindowCounter:"sliding-window-counter"},Ly={memory:"memory",redis:"redis"};class J0{algorithm;store;window;max;standardHeaders;skipSuccessfulRequests;skipFailedRequests;keyGenerator;handler;constructor(S){this._validateConfig(S),this.algorithm=S?.algorithm??oS.slidingWindowCounter,this.store=S?.store??{type:"memory"},this.window=y1(S?.window??"15m"),this.max=S?.max??100,this.standardHeaders=S?.standardHeaders??!0,this.skipSuccessfulRequests=S?.skipSuccessfulRequests??!1,this.skipFailedRequests=S?.skipFailedRequests??!1,this.keyGenerator=S?.keyGenerator??Ty,this.handler=S?.handler??Ay}_validateConfig(S){if(!S)return;Iy(S),jy(S)}get config(){return{algorithm:this.algorithm,window:this.window,max:this.max,standardHeaders:this.standardHeaders,skipSuccessfulRequests:this.skipSuccessfulRequests,skipFailedRequests:this.skipFailedRequests,keyGenerator:this.keyGenerator,handler:this.handler}}}var Iy=(S)=>{if(S.max!==void 0){if(typeof S.max!=="number"||isNaN(S.max))throw Error("rateLimit.max must be a number");if(S.max<1)throw Error("rateLimit.max must be at least 1 request per window");if(!Number.isInteger(S.max))throw Error("rateLimit.max must be an integer (no decimals)")}if(S.window!==void 0)if(typeof S.window==="string"){if(!/^(?<value>\d+)(?<unit>s|m|h|d)$/.test(S.window))throw Error(`rateLimit.window must be a valid time string (e.g., '30s', '15m', '2h', '1d') or milliseconds as a number. Received: "${S.window}"`);let w=y1(S.window);if(w<1000)throw Error(`rateLimit.window must be at least 1000ms (1 second). Received: ${S.window} (${w}ms). Very short time windows can cause performance issues and inaccurate rate limiting.`)}else if(typeof S.window==="number"){if(isNaN(S.window))throw Error("rateLimit.window must be a valid number when using milliseconds");if(S.window<1000)throw Error(`rateLimit.window must be at least 1000ms (1 second). Received: ${S.window}ms. Very short time windows can cause performance issues and inaccurate rate limiting.`);if(!Number.isInteger(S.window))throw Error("rateLimit.window must be an integer when using milliseconds (no decimals)")}else throw Error('rateLimit.window must be a time string (e.g., "15m") or milliseconds as a number')},jy=(S)=>{if(S.enabled===!1)B.warn("[SECURITY WARNING] Rate limiting is disabled. This removes DoS protection from your API. Only disable for development or if you have external rate limiting (e.g., API gateway, CDN).");if(S.max!==void 0&&S.max>1e4)B.warn(`[SECURITY WARNING] rateLimit.max is set to ${S.max} requests. Very high rate limits may not provide adequate DoS protection. Consider if this limit is necessary for your use case.`);if(S.window!==void 0){let $=typeof S.window==="string"?y1(S.window):S.window,w=3600000;if($>3600000){let Z=Math.round($/3600000);B.warn(`[SECURITY WARNING] rateLimit.window is set to ${typeof S.window==="string"?S.window:`${$}ms`} (${Z}h). Very long time windows may allow burst attacks before limits are enforced. Consider shorter windows for better protection.`)}}if(S.window!==void 0){let $=typeof S.window==="string"?y1(S.window):S.window;if($<1e4&&S.max!==void 0&&S.max>100)B.warn(`[PERFORMANCE WARNING] rateLimit.window is set to ${typeof S.window==="string"?S.window:`${$}ms`} with max ${S.max} requests. Very short time windows with high request counts can cause performance overhead. Consider increasing the window or decreasing max.`)}},Ay=(S)=>{return S.response.setStatusCode(a.tooManyRequests),{success:!1,message:"Yinz are sending too many requests. Slow down, jagoff!"}},Ty=(S)=>S.request.ipAddress;var Py=(S)=>async($)=>{let w=new J0(S),Z=new W0(w),Y=await Z.check($);if(Z.config.standardHeaders)nS($,Y);if(!Y.allowed)return Z.config.handler($);return},cw=(S)=>async($)=>{let w=await S.check($);if(S.config.standardHeaders)nS($,w);if(!w.allowed)return S.config.handler($);return};class tw extends yS{_isListening=!1;_server;_globalRateLimiter;constructor(S){super(S);if(this._configuration.logger)Object.assign(B,this._configuration.logger);if(this._configuration.networkLogs)f.enable(this._configuration.networkLogger);let $=new J0(S?.rateLimit);if(S?.rateLimit?.enabled){this._globalRateLimiter=new W0($);let w=cw(this._globalRateLimiter);this.beforeAll([w])}if(this._configuration.gracefulShutdownTimeout){let w=y1(this._configuration.gracefulShutdownTimeout);if(w>0)this._setupGracefulShutdown(w)}}_setupServer(S,$,w){if(!this._server)return;this._server.on("error",(Z)=>{f.log.error(`YinzerFlow server error at ${this._configuration.host}:${this._configuration.port} - ${Z.message}`),$(Z)}),this._server.on("listening",()=>{this._isListening=!0,f.log.info(`YinzerFlow server at ${this._configuration.host}:${this._configuration.port} is up and running`),S()}),this._server.on("connection",(Z)=>{this._handleConnection(Z,w)})}async _processRequest({data:S,socket:$,requestHandler:w,clientAddress:Z}){let Y=Date.now();f.log.info("Incoming request",`${Z} ${c1(S)}bytes`);let y=new o0(S,this,Z);await w.handle(y),$.write(y._response._stringBody),$.end();let J=Date.now()-Y;f.log.info(`${P$(y._response._statusCode)} ${Z} "${y.request.method} ${y.request.path} ${y.request.protocol}" ${y._response._statusCode} ${c1(y._response._body)}bytes "${y.request.headers.referer??"-"}" "${y.request.headers["user-agent"]??"-"}" ${J}ms`),R$(J)}_handleConnection(S,$){let w=S.remoteAddress??"unknown",Z=Date.now(),Y=!1,y=null;f.log.info(`New visitor from ${w}`),S.on("data",(W)=>{if(!Y){Y=!0,y=Date.now();let J=y-Z;if(J>100)f.log.warn(`Delayed data from ${w} (${J}ms connection delay)`)}this._processRequest({data:W,socket:S,requestHandler:$,clientAddress:w}).catch((J)=>{let X=J instanceof Error?J.message:"Unknown error";f.log.error(`Visitor from ${w} experienced an error during request processing: ${X}`,J),S.destroy()})}),S.on("error",(W)=>{f.log.error(`Visitor from ${w} experienced an error during socket connection: ${W.message}`,W)}),S.on("close",()=>{let W=Date.now()-Z;if(Y){f.log.info(`Visitor from ${w} headed out (${W}ms total)`);return}if(W<10)f.log.info(`${w} quick connectivity check (${W}ms) - health probe`);else f.log.warn(`${w} disconnected without sending data (${W}ms) - potential probe`)})}async listen(){if(this._isListening)throw Error("Server is already listening");return new Promise((S,$)=>{let w=new l0(this);this._server=Ry(),this._setupServer(S,$,w),this._server.listen(this._configuration.port,this._configuration.host)})}async close(){if(!this._isListening||!this._server)return;if(this._globalRateLimiter)await this._globalRateLimiter.destroy(),this._globalRateLimiter=void 0;return new Promise((S)=>{if(!this._server){this._isListening=!1,S();return}this._server.close(()=>{this._isListening=!1,f.log.warn(`YinzerFlow server at ${this._configuration.host}:${this._configuration.port} is shutting down - See yinz later`),S()})})}status(){return{isListening:this._isListening,port:this._configuration.port,host:this._configuration.host}}_setupGracefulShutdown(S){if(S<=0)return;if(process.listenerCount("SIGTERM")===0&&process.listenerCount("SIGINT")===0){let $=(w)=>{B.info(`\uD83D\uDED1 Received ${w}, shutting down gracefully in ${this._configuration.gracefulShutdownTimeout}...`),setTimeout(()=>{this.close().then(()=>{B.info("✅ Server shut down gracefully"),process.exit(0)}).catch((Z)=>{B.error("❌ Error during graceful shutdown:",Z),process.exit(1)})},S)};process.on("SIGTERM",()=>$("SIGTERM")),process.on("SIGINT",()=>$("SIGINT"))}}}export{Ly as rateLimitStoreType,Py as rateLimitHook,oS as rateLimitAlgorithm,d1 as logLevels,B as log,a as httpStatusCode,m1 as httpStatus,l1 as createLogger,D as colors,tw as YinzerFlow};
|
|
30
|
+
Received: ${Y}`}`)}if($.length===0){G.warn(`${W}() called with empty array. No hooks will be registered.`);return}for(let Y=0;Y<$.length;Y++){let Z=$[Y];if(typeof Z!=="function")throw Error(`YinzerFlow: ${W}() array contains non-function at index ${Y}. Expected: function, received: ${typeof Z}`)}}_addOnError($){this._onError=$}_addOnNotFound($){this._onNotFound=$}}var F1=($)=>{let W=[],Y=$.path.replace(/:\w+/g,(Z)=>{let Q=Z.slice(1);return W.push(Q),"([^/]+)"}).replace(/\//g,"\\/");return{...$,pattern:new RegExp(`^${Y}$`),paramNames:W,isParameterized:!0}};var L$=($)=>{let[W]=$.split("?");if(!W)return"";if([W]=W.split("#"),!W)return"";try{W=decodeURIComponent(W)}catch(Y){G.warn("Failed to decode URL path",{path:W})}if(W=W.startsWith("/")?W:`/${W}`,W=W.replace(/\/\/+/g,"/"),W=l0(W),W.length>1&&W.endsWith("/"))W=W.slice(0,-1);return W},l0=($)=>{let W=$.split("/"),Y=[];for(let Q of W){if(Q==="."||Q===""){if(Q===""&&Y.length===0)Y.push(Q);continue}if(Q===".."){if(Y.length>1)Y.pop()}else Y.push(Q)}return Y.join("/")||"/"},k$=($)=>$.replace(/:\w+/g,":param");var q1=($)=>{let W=$.match(/:\w+/g);if(!W)return;let Y=W.map((Q)=>Q.slice(1)),Z=new Set(Y);if(Y.length!==Z.size){let Q=Y.filter((X,J)=>Y.indexOf(X)!==J);throw Error(`Route ${$} has duplicate parameter names: ${Q.join(", ")}. Parameter names must be unique within a route for clarity and to prevent conflicts.`)}};class T${_exactRoutes=new Map;_parameterizedRoutes=new Map;_register({method:$,path:W,handler:Y,options:Z}){let Q=L$(W),X=Q.includes(":");if(X)q1(Q);if(this._hasExactRoutePattern($,Q))throw Error(`Route ${Q} already exists for method ${$}`);let J={method:$,path:Q,handler:Y,options:Z,params:{}};if(X)this._storeParameterizedRoute($,J);else this._storeExactRoute($,Q,J)}_findRoute($,W){let Y=L$(W),Z=this._exactRoutes.get($)?.get(Y);if(Z)return Z;let Q=this._findParameterizedRoute($,Y);if(Q)return Q;return}_hasExactRoutePattern($,W){if(this._exactRoutes.get($)?.has(W))return!0;if(W.includes(":")){let Y=k$(W),Z=this._parameterizedRoutes.get($);if(Z)return Z.some((Q)=>k$(Q.path)===Y)}else{let Y=this._parameterizedRoutes.get($);if(Y)return Y.some((Z)=>Z.path===W)}return!1}_storeExactRoute($,W,Y){if(!this._exactRoutes.has($))this._exactRoutes.set($,new Map);this._exactRoutes.get($)?.set(W,Y)}_storeParameterizedRoute($,W){if(!this._parameterizedRoutes.has($))this._parameterizedRoutes.set($,[]);let Y=F1(W);this._parameterizedRoutes.get($)?.push(Y)}_findParameterizedRoute($,W){let Y=this._parameterizedRoutes.get($);if(!Y)return;for(let Z of Y){let Q=W.match(Z.pattern);if(Q){let X={};for(let J=0;J<Z.paramNames.length;J++){let M=Q[J+1],V=Z.paramNames[J];if(M!==void 0&&V!==void 0)X[V]=M}return{...Z,params:X}}}return}}var C=($)=>({beforeHooks:$?.beforeHooks??[],afterHooks:$?.afterHooks??[]}),v$=($,W)=>({beforeHooks:[...$.beforeHooks??[],...W?.beforeHooks??[]],afterHooks:[...W?.afterHooks??[],...$.afterHooks??[]]}),P$=($,W)=>{let Y=$.endsWith("/")?$.slice(0,-1):$,Z=W.startsWith("/")?W:`/${W}`;return`${Y}${Z}`};class D${_setup;_prefix;_options;constructor($,W,Y){this._setup=$,this._prefix=W,this._options=C(Y)}_createRouteHandler($){return(W,Y,Z)=>{let Q=P$(this._prefix,W),X=v$(this._options,Z);if(this._setup._routeRegistry._register({method:$,handler:Y,path:Q,options:X,params:{}}),$===z.get)this._setup._routeRegistry._register({method:z.head,handler:Y,path:Q,options:X,params:{}})}}get=this._createRouteHandler(z.get);head=this._createRouteHandler(z.head);post=this._createRouteHandler(z.post);put=this._createRouteHandler(z.put);delete=this._createRouteHandler(z.delete);patch=this._createRouteHandler(z.patch);options=this._createRouteHandler(z.options);group($,W,Y){let Z=P$(this._prefix,$),Q=v$(this._options,Y),X=new D$(this._setup,Z,Q);return W(X),X}}class R${_configuration;_routeRegistry=new T$;_hooks=new S$;constructor($){this._configuration=G1($)}get($,W,Y){let Z=C(Y);this._routeRegistry._register({method:z.get,handler:W,path:$,options:Z,params:{}}),this._routeRegistry._register({method:z.head,handler:W,path:$,options:Z,params:{}})}head($,W,Y){this._routeRegistry._register({method:z.head,handler:W,path:$,options:C(Y),params:{}})}post($,W,Y){this._routeRegistry._register({method:z.post,handler:W,path:$,options:C(Y),params:{}})}put($,W,Y){this._routeRegistry._register({method:z.put,handler:W,path:$,options:C(Y),params:{}})}patch($,W,Y){this._routeRegistry._register({method:z.patch,handler:W,path:$,options:C(Y),params:{}})}delete($,W,Y){this._routeRegistry._register({method:z.delete,handler:W,path:$,options:C(Y),params:{}})}options($,W,Y){this._routeRegistry._register({method:z.options,handler:W,path:$,options:C(Y),params:{}})}group($,W,Y){let Z=new D$(this,$,Y);return W(Z),Z}beforeAll($,W){this._hooks._addBeforeHooks($,W)}afterAll($,W){this._hooks._addAfterHooks($,W)}onError($){this._hooks._addOnError($)}onNotFound($){this._hooks._addOnNotFound($)}}var w1={prefix:"NETWORK",logLevel:"off",logger:void 0},k={log:a(w1),enable:($)=>{k.log=a({...w1,logLevel:c.info,logger:$})}},V1=($)=>{if($>=200&&$<300)return"✅";if($>=300&&$<400)return"\uD83D\uDD04";if($>=400&&$<500)return"❌";if($>=500)return"\uD83D\uDCA5";return"❓"},b$=[{maxTime:50,emoji:"⚡",phrase:"faster than a Stillers touchdown!"},{maxTime:100,emoji:"\uD83D\uDD25",phrase:"smooth as butter n'at!"},{maxTime:200,emoji:"✅",phrase:"not bad yinz!"},{maxTime:500,emoji:"⚠️",phrase:"slowin' down a bit there"},{maxTime:1000,emoji:"\uD83D\uDC0C",phrase:"that's draggin' n'at"},{maxTime:1/0,emoji:"\uD83D\uDCA5",phrase:"what a jagoff response time!"}],B1=($)=>{let W=b$.find((Y)=>$<Y.maxTime)??b$[b$.length-1];if(!W)throw Error("No threshold found for performance details");k.log.warn(`${O.magenta} ${W.emoji} Response time: ${$}ms - ${W.phrase}${O.reset}`)};var O1=()=>{let $=new Map;return{get:async(W)=>Promise.resolve($.get(W)),set:async(W,Y)=>{return $.set(W,Y),Promise.resolve()},delete:async(W)=>{return $.delete(W),Promise.resolve()},destroy:async()=>{return $.clear(),Promise.resolve()}}};import{Redis as N1}from"ioredis";var u=($)=>{if(typeof $==="number")return $;if(typeof $!=="string")throw Error("Invalid time format. Expected format: 1ms, 1s, 1m, 1h, 1d");if($.length<2)throw Error("Invalid time format. Expected format: 1ms, 1s, 1m, 1h, 1d");if($.length>3)throw Error("Invalid time format. Expected format: 1ms, 1s, 1m, 1h, 1d");let W=$.includes("ms")?$.slice(-2):$.slice(-1),Y=$.includes("ms")?$.slice(0,-2):$.slice(0,-1);if(!["ms","s","m","h","d"].includes(W))throw Error(`Invalid time unit: "${W}". Expected: s (seconds), m (minutes), h (hours), or d (days)`);let Z=Number(Y);if(isNaN(Z)||Z<=0)throw Error(`Invalid time value: "${Y}". Must be a positive number`);switch(W){case"ms":return Z;case"s":return Z*1000;case"m":return Z*60*1000;case"h":return Z*60*60*1000;case"d":return Z*24*60*60*1000;default:throw Error(`Unsupported time unit: "${W}"`)}};var H1=async($)=>{let{store:W}=$;if(W.type!=="redis")throw Error(`Expected Redis store configuration but got: ${JSON.stringify(W)}`);let{client:Y,keyPrefix:Z="rate_limit:",maxRetries:Q=3,retryDelay:X=1000}=W,J=u(X),M=!1;return await(async()=>{for(let B=1;B<=Q;B++)try{await Y.ping(),M=!0,G.info(`[RedisStore] Successfully connected to Redis (attempt ${B})`);return}catch(S){if(G.warn(`[RedisStore] Redis connection attempt ${B}/${Q} failed:`,S),B<Q)G.info(`[RedisStore] Retrying connection in ${X}...`),await new Promise((E)=>{setTimeout(E,J)});else G.error("[RedisStore] All Redis connection attempts failed. Store will operate in degraded mode."),M=!1}})(),{get:async(B)=>c0({client:Y,key:B,keyPrefix:Z,connectionHealthy:M}),set:async(B,S)=>a0({client:Y,config:$,key:B,value:S,keyPrefix:Z,connectionHealthy:M}),delete:async(B)=>i0({client:Y,key:B,keyPrefix:Z,connectionHealthy:M}),destroy:async()=>n0({client:Y,keyPrefix:Z,connectionHealthy:M})}},C$=($,W)=>`${W}${$}`,g0=($)=>{try{return JSON.stringify($)}catch(W){throw G.error("[RedisStore] Failed to serialize value:",W),Error("Failed to serialize rate limit data")}},s0=($)=>{try{return JSON.parse($)}catch(W){throw G.error("[RedisStore] Failed to deserialize value:",W),Error("Failed to deserialize rate limit data")}},K$=($,W,Y)=>{if(Y)G.warn(`[RedisStore] Redis ${$} failed (connection was healthy):`,W);else G.error(`[RedisStore] Redis ${$} failed (connection unhealthy):`,W)},d0=async({client:$,key:W,value:Y,ttlSeconds:Z})=>{try{if($ instanceof N1)await $.set(W,Y,"EX",Z);else await $.set(W,Y,{EX:Z})}catch(Q){if(Q instanceof Error)throw Error(`Unsupported Redis client or Redis operation failed: ${Q.message}`);throw Q}},r0=async({client:$,key:W,value:Y})=>{try{if($ instanceof N1)await $.set(W,Y,"KEEPTTL");else await $.set(W,Y,{KEEPTTL:!0})}catch(Z){if(Z instanceof Error)throw Error(`Unsupported Redis client or Redis operation failed: ${Z.message}`);throw Z}},c0=async({client:$,key:W,keyPrefix:Y,connectionHealthy:Z})=>{try{let Q=C$(W,Y),X=await $.get(Q);if(X===null)return;return s0(X)}catch(Q){K$("GET",Q,Z);return}},a0=async({client:$,config:W,key:Y,value:Z,keyPrefix:Q,connectionHealthy:X})=>{try{let J=C$(Y,Q),M=g0(Z);if(await $.exists(J))await r0({client:$,key:J,value:M});else await d0({client:$,key:J,value:M,ttlSeconds:Math.floor(W.window/1000)})}catch(J){K$("SET",J,X)}},i0=async({client:$,key:W,keyPrefix:Y,connectionHealthy:Z})=>{try{let Q=C$(W,Y);await $.del(Q)}catch(Q){K$("DELETE",Q,Z)}},n0=async({client:$,keyPrefix:W,connectionHealthy:Y})=>{try{let Z=`${W}*`,Q=await $.keys(Z);if(Q.length>0)await Promise.all(Q.map(async(X)=>$.del(X))),G.info(`[RedisStore] Destroyed ${Q.length} rate limit keys`)}catch(Z){K$("DESTROY",Z,Y)}};var t0=()=>({memory:()=>O1(),redis:async($)=>H1($)}),E1=async($)=>{let Y=t0()[$.store.type];if(!Y)throw Error(`Unsupported store type: ${$.store.type}`);return Y($)};class x${_config;_store=null;constructor($){this._config=$}async _getStore(){return this._store??=await E1(this._config),this._store}async check($){let W=await this._getStore(),Y=this._config.keyGenerator($),Z=Date.now(),Q=await W.get(Y)??{currentWindowCount:0,previousWindowCount:0,windowStart:Z};if(Z-Q.windowStart>=this._config.window)Q.previousWindowCount=0,Q.currentWindowCount=0,Q.windowStart=Z;let M=(Z-Q.windowStart)/this._config.window,V=Q.previousWindowCount*(1-M),B=Q.currentWindowCount+V,S=B<this._config.max;if(S)Q.currentWindowCount++;await W.set(Y,Q);let E=Math.max(0,Math.floor(this._config.max-B-(S?1:0))),T=Q.windowStart+this._config.window;return{allowed:S,remaining:E,resetTime:T,totalHits:Math.ceil(B+(S?1:0)),limit:this._config.max}}async destroy(){await(await this._getStore()).destroy()}}var o0=($)=>Math.ceil(($-Date.now())/1000),e0=($)=>new x$($);class n{_config;_strategy;constructor($){this._config=$,this._strategy=e0($)}async check($){return this._strategy.check($)}async destroy(){await this._strategy.destroy()}get config(){return this._config}}var u$=($,W)=>{if($.response.addHeaders({"RateLimit-Limit":String(W.limit),"RateLimit-Remaining":String(W.remaining),"RateLimit-Reset":String(Math.ceil(W.resetTime/1000))}),!W.allowed){let Y=o0(W.resetTime);$.response.addHeaders({"Retry-After":String(Y)})}};var y$={slidingWindowCounter:"sliding-window-counter"},$2={memory:"memory",redis:"redis"};class t{algorithm;store;window;max;standardHeaders;skipSuccessfulRequests;skipFailedRequests;keyGenerator;handler;constructor($){this._validateConfig($),this.algorithm=$?.algorithm??y$.slidingWindowCounter,this.store=$?.store??{type:"memory"},this.window=u($?.window??"15m"),this.max=$?.max??100,this.standardHeaders=$?.standardHeaders??!0,this.skipSuccessfulRequests=$?.skipSuccessfulRequests??!1,this.skipFailedRequests=$?.skipFailedRequests??!1,this.keyGenerator=$?.keyGenerator??Q2,this.handler=$?.handler??Z2}_validateConfig($){if(!$)return;W2($),Y2($)}get config(){return{algorithm:this.algorithm,window:this.window,max:this.max,standardHeaders:this.standardHeaders,skipSuccessfulRequests:this.skipSuccessfulRequests,skipFailedRequests:this.skipFailedRequests,keyGenerator:this.keyGenerator,handler:this.handler}}}var W2=($)=>{if($.max!==void 0){if(typeof $.max!=="number"||isNaN($.max))throw Error("rateLimit.max must be a number");if($.max<1)throw Error("rateLimit.max must be at least 1 request per window");if(!Number.isInteger($.max))throw Error("rateLimit.max must be an integer (no decimals)")}if($.window!==void 0)if(typeof $.window==="string"){if(!/^(?<value>\d+)(?<unit>s|m|h|d)$/.test($.window))throw Error(`rateLimit.window must be a valid time string (e.g., '30s', '15m', '2h', '1d') or milliseconds as a number. Received: "${$.window}"`);let Y=u($.window);if(Y<1000)throw Error(`rateLimit.window must be at least 1000ms (1 second). Received: ${$.window} (${Y}ms). Very short time windows can cause performance issues and inaccurate rate limiting.`)}else if(typeof $.window==="number"){if(isNaN($.window))throw Error("rateLimit.window must be a valid number when using milliseconds");if($.window<1000)throw Error(`rateLimit.window must be at least 1000ms (1 second). Received: ${$.window}ms. Very short time windows can cause performance issues and inaccurate rate limiting.`);if(!Number.isInteger($.window))throw Error("rateLimit.window must be an integer when using milliseconds (no decimals)")}else throw Error('rateLimit.window must be a time string (e.g., "15m") or milliseconds as a number')},Y2=($)=>{if($.enabled===!1)G.warn("[SECURITY WARNING] Rate limiting is disabled. This removes DoS protection from your API. Only disable for development or if you have external rate limiting (e.g., API gateway, CDN).");if($.max!==void 0&&$.max>1e4)G.warn(`[SECURITY WARNING] rateLimit.max is set to ${$.max} requests. Very high rate limits may not provide adequate DoS protection. Consider if this limit is necessary for your use case.`);if($.window!==void 0){let W=typeof $.window==="string"?u($.window):$.window,Y=3600000;if(W>3600000){let Z=Math.round(W/3600000);G.warn(`[SECURITY WARNING] rateLimit.window is set to ${typeof $.window==="string"?$.window:`${W}ms`} (${Z}h). Very long time windows may allow burst attacks before limits are enforced. Consider shorter windows for better protection.`)}}if($.window!==void 0){let W=typeof $.window==="string"?u($.window):$.window;if(W<1e4&&$.max!==void 0&&$.max>100)G.warn(`[PERFORMANCE WARNING] rateLimit.window is set to ${typeof $.window==="string"?$.window:`${W}ms`} with max ${$.max} requests. Very short time windows with high request counts can cause performance overhead. Consider increasing the window or decreasing max.`)}},Z2=($)=>{return $.response.setStatusCode(R.tooManyRequests),{success:!1,message:"Yinz are sending too many requests. Slow down, jagoff!"}},Q2=($)=>$.request.ipAddress;var X2=($)=>async(W)=>{let Y=new t($),Z=new n(Y),Q=await Z.check(W);if(Z.config.standardHeaders)u$(W,Q);if(!Q.allowed)return Z.config.handler(W);return},A1=($)=>async(W)=>{let Y=await $.check(W);if($.config.standardHeaders)u$(W,Y);if(!Y.allowed)return $.config.handler(W);return};class z1 extends R${_isListening=!1;_server;_globalRateLimiter;constructor($){super($);if(this._configuration.logger)Object.assign(G,this._configuration.logger);if(this._configuration.networkLogs)k.enable(this._configuration.networkLogger);let W=new t($?.rateLimit);if($?.rateLimit?.enabled){this._globalRateLimiter=new n(W);let Y=A1(this._globalRateLimiter);this.beforeAll([Y])}if(this._configuration.gracefulShutdownTimeout){let Y=u(this._configuration.gracefulShutdownTimeout);if(Y>0)this._setupGracefulShutdown(Y)}}_setupServer($,W,Y){if(!this._server)return;this._server.on("error",(Z)=>{k.log.error(`YinzerFlow server error at ${this._configuration.host}:${this._configuration.port} - ${Z.message}`),W(Z)}),this._server.on("listening",()=>{this._isListening=!0,k.log.info(`YinzerFlow server at ${this._configuration.host}:${this._configuration.port} is up and running`),$()}),this._server.on("connection",(Z)=>{this._handleConnection(Z,Y)})}async _processRequest({data:$,socket:W,requestHandler:Y,clientAddress:Z}){let Q=Date.now();k.log.info("Incoming request",`${Z} ${i($)}bytes`);let X=new I$($,this,Z);await Y.handle(X),W.write(X._response._stringBody),W.end();let M=Date.now()-Q;k.log.info(`${V1(X._response._statusCode)} ${Z} "${X.request.method} ${X.request.path} ${X.request.protocol}" ${X._response._statusCode} ${i(X._response._body)}bytes "${X.request.headers.referer??"-"}" "${X.request.headers["user-agent"]??"-"}" ${M}ms`),B1(M)}_handleConnection($,W){let Y=$.remoteAddress??"unknown",Z=Date.now(),Q=!1,X=null;k.log.info(`New visitor from ${Y}`),$.on("data",(J)=>{if(!Q){Q=!0,X=Date.now();let M=X-Z;if(M>100)k.log.warn(`Delayed data from ${Y} (${M}ms connection delay)`)}this._processRequest({data:J,socket:$,requestHandler:W,clientAddress:Y}).catch((M)=>{let V=M instanceof Error?M.message:"Unknown error";k.log.error(`Visitor from ${Y} experienced an error during request processing: ${V}`,M),$.destroy()})}),$.on("error",(J)=>{k.log.error(`Visitor from ${Y} experienced an error during socket connection: ${J.message}`,J)}),$.on("close",()=>{let J=Date.now()-Z;if(Q){k.log.info(`Visitor from ${Y} headed out (${J}ms total)`);return}if(J<10)k.log.info(`${Y} quick connectivity check (${J}ms) - health probe`);else k.log.warn(`${Y} disconnected without sending data (${J}ms) - potential probe`)})}async listen(){if(this._isListening)throw Error("Server is already listening");return new Promise(($,W)=>{let Y=new B$(this);this._server=J2(),this._setupServer($,W,Y),this._server.listen(this._configuration.port,this._configuration.host)})}async close(){if(!this._isListening||!this._server)return;if(this._globalRateLimiter)await this._globalRateLimiter.destroy(),this._globalRateLimiter=void 0;return new Promise(($)=>{if(!this._server){this._isListening=!1,$();return}this._server.close(()=>{this._isListening=!1,k.log.warn(`YinzerFlow server at ${this._configuration.host}:${this._configuration.port} is shutting down - See yinz later`),$()})})}status(){return{isListening:this._isListening,port:this._configuration.port,host:this._configuration.host}}_setupGracefulShutdown($){if($<=0)return;if(process.listenerCount("SIGTERM")===0&&process.listenerCount("SIGINT")===0){let W=(Y)=>{G.info(`\uD83D\uDED1 Received ${Y}, shutting down gracefully in ${this._configuration.gracefulShutdownTimeout}...`),setTimeout(()=>{this.close().then(()=>{G.info("✅ Server shut down gracefully"),process.exit(0)}).catch((Z)=>{G.error("❌ Error during graceful shutdown:",Z),process.exit(1)})},$)};process.on("SIGTERM",()=>W("SIGTERM")),process.on("SIGINT",()=>W("SIGINT"))}}}export{$2 as rateLimitStoreType,X2 as rateLimitHook,y$ as rateLimitAlgorithm,c as logLevels,G as log,R as httpStatusCode,r as httpStatus,a as createLogger,O as colors,z1 as YinzerFlow};
|
|
189
31
|
|
|
190
|
-
//# debugId=
|
|
32
|
+
//# debugId=D1B70EF71A50CAB664756E2164756E21
|