var Functions={Identity:function(e){return e},True:function(){return!0},Blank:function(){}},Types={Boolean:typeof!0,Number:"number",String:"string",Object:typeof{},Undefined:"undefined",Function:"function"},funcCache={"":Functions.Identity},Utils={createLambda:function(n){if(null==n)return Functions.Identity;if(typeof n!==Types.String)return n;{let t=funcCache[n];if(null!=t)return t;if(-1===n.indexOf("=>")){const o=new RegExp("[$]+","g");let e=0;for(var r;null!=(r=o.exec(n));)r[0].length>e&&(e=r[0].length);const i=[];for(let n=1;n<=e;n++){let t="";for(let e=0;e(.*)/);return t=new Function(e[1],e[2].match(/\breturn\b/)?e[2]:"return "+e[2]),funcCache[n]=t,t}}},defineProperty:function(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!0,writable:!0,value:n})},compare:function(e,t){return e===t?0:t=t.length&&(e=0),this.yieldReturn(t[e++])},Functions.Blank)})},Enumerable.empty=function(){return new Enumerable(function(){return new IEnumerator(Functions.Blank,function(){return!1},Functions.Blank)})},Enumerable.from=function(r){if(null==r)return Enumerable.empty();if(r instanceof Enumerable)return r;if(typeof r==Types.Number||typeof r==Types.Boolean)return Enumerable.repeat(r,1);if(typeof r==Types.String)return new Enumerable(function(){var e=0;return new IEnumerator(Functions.Blank,function(){return e=t.length-1?0:n+1;const e=t[n];if(e.moveNext())return this.yieldReturn(e.current());e.dispose(),t.splice(n--,1)}return this.yieldBreak()},function(){Enumerable.from(t).forEach(Utils.dispose)})})},Enumerable.prototype.join=function(e,o,i,a,l){o=Utils.createLambda(o),i=Utils.createLambda(i),a=Utils.createLambda(a),l=Utils.createLambda(l);var c=this;return new Enumerable(function(){var t,n,r=null,u=0;return new IEnumerator(function(){t=c.getEnumerator(),n=Enumerable.from(e).toLookup(i,Functions.Identity,l)},function(){for(;;){if(null!=r){let e=r[u++];if(void 0!==e)return this.yieldReturn(a(t.current(),e));e=null,u=0}if(!t.moveNext())return!1;var e=o(t.current());r=n.get(e).toArray()}},function(){Utils.dispose(t)})})},Enumerable.prototype.leftJoin=function(e,o,i,a,l){o=Utils.createLambda(o),i=Utils.createLambda(i),a=Utils.createLambda(a),l=Utils.createLambda(l);var c=this;return new Enumerable(function(){var t,n,r=null,u=0;return new IEnumerator(function(){t=c.getEnumerator(),n=Enumerable.from(e).toLookup(i,Functions.Identity,l)},function(){for(;;){if(null!=r){let e=r[u++];if(void 0!==e)return this.yieldReturn(a(t.current(),e));e=null,u=0}if(!t.moveNext())return!1;var e=o(t.current());if(null==(r=n.get(e).toArray())||0==r.length)return this.yieldReturn(a(t.current(),null))}},function(){Utils.dispose(t)})})},Enumerable.prototype.groupJoin=function(e,r,u,o,i){r=Utils.createLambda(r),u=Utils.createLambda(u),o=Utils.createLambda(o),i=Utils.createLambda(i);var a=this;return new Enumerable(function(){var t=a.getEnumerator(),n=null;return new IEnumerator(function(){t=a.getEnumerator(),n=Enumerable.from(e).toLookup(u,Functions.Identity,i)},function(){if(t.moveNext()){var e=n.get(r(t.current()));return this.yieldReturn(o(t.current(),e))}return!1},function(){Utils.dispose(t)})})},Enumerable.prototype.all=function(t){t=Utils.createLambda(t);var n=!0;return this.forEach(function(e){if(!t(e))return n=!1}),n},Enumerable.prototype.any=function(e){e=Utils.createLambda(e);var t=this.getEnumerator();try{if(0==arguments.length)return t.moveNext();for(;t.moveNext();)if(e(t.current()))return!0;return!1}finally{Utils.dispose(t)}},Enumerable.prototype.isEmpty=function(){return!this.any()},Enumerable.prototype.concat=function(){var n=this;if(1==arguments.length){const r=arguments[0];return new Enumerable(function(){var e,t;return new IEnumerator(function(){e=n.getEnumerator()},function(){if(null==t){if(e.moveNext())return this.yieldReturn(e.current());t=Enumerable.from(r).getEnumerator()}return!!t.moveNext()&&this.yieldReturn(t.current())},function(){try{Utils.dispose(e)}finally{Utils.dispose(t)}})})}{const e=arguments;return new Enumerable(function(){var t;return new IEnumerator(function(){t=Enumerable.make(n).concat(Enumerable.from(e).select(Enumerable.from)).select(function(e){return e.getEnumerator()}).toArray()},function(){for(;0=n?t=r:e=r}return this.yieldReturn(u[t].value)}return this.yieldBreak()},Functions.Blank)})},Enumerable.prototype.groupBy=function(t,n,r,u){var o=this;return t=Utils.createLambda(t),n=Utils.createLambda(n),null!=r&&(r=Utils.createLambda(r)),u=Utils.createLambda(u),new Enumerable(function(){var e;return new IEnumerator(function(){e=o.toLookup(t,n,u).toEnumerable().getEnumerator()},function(){return!!e.moveNext()&&(null==r?this.yieldReturn(e.current()):this.yieldReturn(r(e.current().key(),e.current())))},function(){Utils.dispose(e)})})},Enumerable.prototype.partitionBy=function(i,a,l,c){var s,e=this;return i=Utils.createLambda(i),a=Utils.createLambda(a),c=Utils.createLambda(c),l=null==l?(s=!1,function(e,t){return new Grouping(e,t)}):(s=!0,Utils.createLambda(l)),new Enumerable(function(){var n,r,u,o=[];return new IEnumerator(function(){(n=e.getEnumerator()).moveNext()&&(r=i(n.current()),u=c(r),o.push(a(n.current())))},function(){for(var e;1==(e=n.moveNext())&&u===c(i(n.current()));)o.push(a(n.current()));if(0=r)return this.yieldReturn(e);return 0n(t)?e:t})},Enumerable.prototype.minBy=function(n){return n=Utils.createLambda(n),this.aggregate(function(e,t){return n(e)