UNPKG

data-forge

Version:

JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.

1 lines 221 kB
var dataForge=function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";var n,u=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},o=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,u,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(e){u={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return o},a=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(o(arguments[t]));return e},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=r(7),l=r(8),f=r(9),h=r(10),p=r(11),d=r(12),y=r(13),D=r(14),m=r(15),v=r(36),g=r(16),w=r(17),b=r(18),E=r(40),F=r(42),C=r(19),A=r(5),x=r(20),S=r(21),_=r(22),B=s(r(23)),I=r(1),O=s(r(3)),k=s(r(26));O.default.extend(k.default);var N,j=r(4),M=r(2),P=s(r(69));!function(e){e.Start="start",e.End="end"}(N=t.WhichIndex||(t.WhichIndex={}));var T=function(){function e(t){this.configFn=null,this.content=null,t?j.isFunction(t)?this.configFn=t:j.isArray(t)||j.isFunction(t[Symbol.iterator])?this.content=e.initFromArray(t):this.content=e.initFromConfig(t):this.content=e.initEmpty()}return e.initFromArray=function(t){return{index:e.defaultCountIterable,values:t,pairs:new f.MultiIterable([e.defaultCountIterable,t]),isBaked:!0}},e.initEmpty=function(){return{index:e.defaultEmptyIterable,values:e.defaultEmptyIterable,pairs:e.defaultEmptyIterable,isBaked:!0}},e.checkIterable=function(e,t){if(j.isArray(e));else if(!j.isFunction(e[Symbol.iterator]))throw new Error("Expected '"+t+"' field of Series config object to be an array of values or an iterable of values.")},e.initFromConfig=function(t){var r,n,u,i=!1;return t.pairs&&(e.checkIterable(t.pairs,"pairs"),u=t.pairs),t.index?(e.checkIterable(t.index,"index"),r=t.index):r=u?new x.ExtractElementIterable(u,0):e.defaultCountIterable,t.values?(e.checkIterable(t.values,"values"),n=t.values):n=u?new x.ExtractElementIterable(u,1):e.defaultEmptyIterable,u||(u=new f.MultiIterable([r,n])),void 0!==t.baked&&(i=t.baked),{index:r,values:n,pairs:u,isBaked:i}},e.prototype.lazyInit=function(){null===this.content&&null!==this.configFn&&(this.content=e.initFromConfig(this.configFn()))},e.prototype.getContent=function(){return this.lazyInit(),this.content},e.prototype[Symbol.iterator]=function(){return this.getContent().values[Symbol.iterator]()},e.prototype.cast=function(){return this},e.prototype.getIndex=function(){var e=this;return new A.Index(function(){return{values:e.getContent().index}})},e.prototype.withIndex=function(t){var r=this;return j.isFunction(t)?new e(function(){return{values:r.getContent().values,index:r.select(t)}}):(e.checkIterable(t,"newIndex"),new e(function(){return{values:r.getContent().values,index:t}}))},e.prototype.resetIndex=function(){var t=this;return new e(function(){return{values:t.getContent().values}})},e.merge=function(t){var r=new Map,n=Array.from(t).length,u=0;try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{for(var c=i(s.toPairs()),l=c.next();!l.done;l=c.next()){var f=l.value,h=f[0];r.has(h)||r.set(h,new Array(n)),r.get(h)[u]=f[1]}}catch(e){y={error:e}}finally{try{l&&!l.done&&(D=c.return)&&D.call(c)}finally{if(y)throw y.error}}++u}}catch(e){p={error:e}}finally{try{a&&!a.done&&(d=o.return)&&d.call(o)}finally{if(p)throw p.error}}var p,d,y,D,m=Array.from(r.keys()).map(function(e){return[e,r.get(e)]});return m.sort(function(e,t){return e[0]===t[0]?0:e[0]>t[0]?1:-1}),new e({pairs:m})},e.prototype.merge=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.merge([this].concat(t))},e.prototype.toArray=function(){var e,t,r=[];try{for(var n=i(this.getContent().values),u=n.next();!u.done;u=n.next()){var o=u.value;null!=o&&r.push(o)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toPairs=function(){var e,t,r=[];try{for(var n=i(this.getContent().pairs),u=n.next();!u.done;u=n.next()){var o=u.value;void 0!==o[1]&&null!==o[1]&&r.push(o)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(e,t){if(!j.isFunction(e))throw new Error("Expected 'keySelector' parameter to Series.toObject to be a function.");if(!j.isFunction(t))throw new Error("Expected 'valueSelector' parameter to Series.toObject to be a function.");return j.toMap(this,e,t)},e.prototype.select=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to 'Series.select' function to be a function.");return new e(function(){return{values:new h.SelectIterable(r.getContent().values,t),index:r.getContent().index}})},e.prototype.selectMany=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to 'Series.selectMany' to be a function.");return new e(function(){return{pairs:new p.SelectManyIterable(r.getContent().pairs,function(e,r){var n,u,o=[];try{for(var a=i(t(e[1],r)),s=a.next();!s.done;s=a.next()){var c=s.value;o.push([e[0],c])}}catch(e){n={error:e}}finally{try{s&&!s.done&&(u=a.return)&&u.call(a)}finally{if(n)throw n.error}}return o})}})},e.prototype.window=function(t,r){var n=this;if(!j.isNumber(t))throw new Error("Expected 'period' parameter to 'Series.window' to be a number.");return new e(function(){return{pairs:new v.SeriesWindowIterable(n.getContent().pairs,t,r||N.End)}})},e.prototype.rollingWindow=function(t,r){var n=this;if(!j.isNumber(t))throw new Error("Expected 'period' parameter to 'Series.rollingWindow' to be a number.");return new e(function(){return{pairs:new E.SeriesRollingWindowIterable(n.getContent().pairs,t,r||N.End)}})},e.prototype.variableWindow=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'comparer' parameter to 'Series.variableWindow' to be a function.");return new e(function(){return{values:new F.SeriesVariableWindowIterable(r.getContent().pairs,t)}})},e.prototype.sequentialDistinct=function(e){if(e){if(!j.isFunction(e))throw new Error("Expected 'selector' parameter to 'Series.sequentialDistinct' to be a selector function that determines the value to compare for duplicates.")}else e=function(e){return e};return this.variableWindow(function(t,r){return e(t)===e(r)}).select(function(e){return[e.getIndex().first(),e.first()]}).withIndex(function(e){return e[0]}).select(function(e){return e[1]})},e.prototype.aggregate=function(e,t){if(j.isFunction(e)&&!t)return this.skip(1).aggregate(this.first(),e);if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to aggregate to be a function.");var r,n,u=e;try{for(var o=i(this),a=o.next();!a.done;a=o.next()){u=t(u,a.value)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return u},e.prototype.amountRange=function(e,t){return this.rollingWindow(e,t).select(function(e){return e.max()-e.min()})},e.prototype.proportionRange=function(e,t){return this.rollingWindow(e,t).select(function(e){return(e.max()-e.min())/e.last()})},e.prototype.percentRange=function(e,t){return this.proportionRange(e,t).select(function(e){return 100*e})},e.prototype.amountChange=function(e,t){return this.rollingWindow(void 0===e?2:e,t).select(function(e){return e.last()-e.first()})},e.prototype.proportionChange=function(e,t){return this.rollingWindow(void 0===e?2:e,t).select(function(e){return(e.last()-e.first())/e.first()})},e.prototype.percentChange=function(e,t){return this.proportionChange(e,t).select(function(e){return 100*e})},e.prototype.proportionRank=function(e){if(void 0===e&&(e=2),!j.isNumber(e))throw new Error("Expected 'period' parameter to 'Series.proportionRank' to be a number that specifies the time period for the ranking.");return this.rollingWindow(e+1).select(function(t){var r=t.last();return t.head(-1).where(function(e){return e<r}).count()/e})},e.prototype.percentRank=function(e){if(void 0===e&&(e=2),!j.isNumber(e))throw new Error("Expected 'period' parameter to 'Series.percentRank' to be a number that specifies the time period for the ranking.");return this.proportionRank(e).select(function(e){return 100*e})},e.prototype.skip=function(t){var r=this;return new e(function(){return{values:new S.SkipIterable(r.getContent().values,t),index:new S.SkipIterable(r.getContent().index,t),pairs:new S.SkipIterable(r.getContent().pairs,t)}})},e.prototype.skipWhile=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'predicate' parameter to 'Series.skipWhile' function to be a predicate function that returns true/false.");return new e(function(){return{values:new _.SkipWhileIterable(r.getContent().values,t),pairs:new _.SkipWhileIterable(r.getContent().pairs,function(e){return t(e[1])})}})},e.prototype.skipUntil=function(e){if(!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.skipUntil' function to be a predicate function that returns true/false.");return this.skipWhile(function(t){return!e(t)})},e.prototype.take=function(t){var r=this;if(!j.isNumber(t))throw new Error("Expected 'numRows' parameter to 'Series.take' function to be a number.");return new e(function(){return{index:new d.TakeIterable(r.getContent().index,t),values:new d.TakeIterable(r.getContent().values,t),pairs:new d.TakeIterable(r.getContent().pairs,t)}})},e.prototype.takeWhile=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'predicate' parameter to 'Series.takeWhile' function to be a predicate function that returns true/false.");return new e(function(){return{values:new y.TakeWhileIterable(r.getContent().values,t),pairs:new y.TakeWhileIterable(r.getContent().pairs,function(e){return t(e[1])})}})},e.prototype.takeUntil=function(e){if(!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.takeUntil' function to be a predicate function that returns true/false.");return this.takeWhile(function(t){return!e(t)})},e.count=function(e){return e.count()},e.prototype.count=function(){var e,t,r=0;try{for(var n=i(this.getContent().values),u=n.next();!u.done;u=n.next()){u.value;++r}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.first=function(){try{for(var e=i(this),t=e.next();!t.done;t=e.next()){return t.value}}catch(e){r={error:e}}finally{try{t&&!t.done&&(n=e.return)&&n.call(e)}finally{if(r)throw r.error}}throw new Error("Series.first: No values in Series.");var r,n},e.prototype.last=function(){var e,t,r=null;try{for(var n=i(this),u=n.next();!u.done;u=n.next()){r=u.value}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}if(null===r)throw new Error("Series.last: No values in Series.");return r},e.prototype.at=function(e){var t,r;if(!this.none())try{for(var n=i(this.getContent().pairs),u=n.next();!u.done;u=n.next()){var o=u.value;if(o[0]===e)return o[1]}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},e.prototype.head=function(t){if(!j.isNumber(t))throw new Error("Expected 'numValues' parameter to 'Series.head' function to be a number.");if(0===t)return new e;var r=t<0?this.count()-Math.abs(t):t;return this.take(r)},e.prototype.tail=function(t){if(!j.isNumber(t))throw new Error("Expected 'numValues' parameter to 'Series.tail' function to be a number.");if(0===t)return new e;var r=t>0?this.count()-t:Math.abs(t);return this.skip(r)},e.prototype.where=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'predicate' parameter to 'Series.where' function to be a function.");return new e(function(){return{values:new D.WhereIterable(r.getContent().values,t),pairs:new D.WhereIterable(r.getContent().pairs,function(e){return t(e[1])})}})},e.prototype.forEach=function(e){if(!j.isFunction(e))throw new Error("Expected 'callback' parameter to 'Series.forEach' to be a function.");var t,r,n=0;try{for(var u=i(this),o=u.next();!o.done;o=u.next()){e(o.value,n++)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return this},e.prototype.all=function(e){if(!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.all' to be a function.");var t,r,n=0;try{for(var u=i(this),o=u.next();!o.done;o=u.next()){if(!e(o.value))return!1;++n}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return n>0},e.prototype.any=function(e){if(e&&!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.any' to be a function.");var t,r;if(!e)return!this[Symbol.iterator]().next().done;try{for(var n=i(this),u=n.next();!u.done;u=n.next()){if(e(u.value))return!0}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!1},e.prototype.none=function(e){if(e&&!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.none' to be a function.");var t,r;if(!e)return this[Symbol.iterator]().next().done;try{for(var n=i(this),u=n.next();!u.done;u=n.next()){if(e(u.value))return!1}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},e.prototype.startAt=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThan();return{index:new _.SkipWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new _.SkipWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.endAt=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThanOrEqualTo();return{index:new y.TakeWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new y.TakeWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.before=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThan();return{index:new y.TakeWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new y.TakeWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.after=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThanOrEqualTo();return{index:new _.SkipWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new _.SkipWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.between=function(e,t){return this.startAt(e).endAt(t)},e.prototype.toString=function(){for(var e=["__index__","__value__"],t=this.toPairs(),r=new B.default,n=0;n<t.length;++n){for(var u=t[n],i=0;i<u.length;++i){var o=u[i];r.cell(e[i],o)}r.newRow()}return r.toString()},e.parseInt=function(e,t){if(null!=e){if(!j.isString(e))throw new Error("Called Series.parseInts, expected all values in the series to be strings, instead found a '"+typeof e+"' at index "+t);if(0!==e.length)return parseInt(e)}},e.prototype.parseInts=function(){return this.select(e.parseInt)},e.parseFloat=function(e,t){if(null!=e){if(!j.isString(e))throw new Error("Called Series.parseFloats, expected all values in the series to be strings, instead found a '"+typeof e+"' at index "+t);if(0!==e.length)return parseFloat(e)}},e.prototype.parseFloats=function(){return this.select(e.parseFloat)},e.parseDate=function(e,t,r){if(null!=e){if(!j.isString(e))throw new Error("Called Series.parseDates, expected all values in the series to be strings, instead found a '"+typeof e+"' at index "+t);if(0!==e.length)return O.default(e,r).toDate()}},e.prototype.parseDates=function(t){if(t&&!j.isString(t))throw new Error("Expected optional 'formatString' parameter to Series.parseDates to be a string (if specified).");return this.select(function(r,n){return e.parseDate(r,n,t)})},e.toString=function(e,t){return void 0===e?void 0:null===e?null:t&&j.isDate(e)?O.default(e).format(t):t&&j.isNumber(e)?P.default(e).format(t):e.toString()},e.prototype.toStrings=function(t){if(t&&!j.isString(t))throw new Error("Expected optional 'formatString' parameter to Series.toStrings to be a string (if specified).");return this.select(function(r){return e.toString(r,t)})},e.prototype.bake=function(){return this.getContent().isBaked?this:new e({values:this.toArray(),pairs:this.toPairs(),baked:!0})},e.prototype.inflate=function(e){var t=this;if(e){if(!j.isFunction(e))throw new Error("Expected 'selector' parameter to Series.inflate to be a selector function.");return new I.DataFrame(function(){var r=t.getContent();return{values:new h.SelectIterable(r.values,e),index:r.index,pairs:new h.SelectIterable(r.pairs,function(t,r){return[t[0],e(t[1],r)]})}})}return new I.DataFrame(function(){var e=t.getContent();return{values:e.values,index:e.index,pairs:e.pairs}})},e.sum=function(e){return e.sum()},e.prototype.sum=function(){if(this.none())return 0;return this.aggregate(function(e,t){return e+t})},e.average=function(e){return e.average()},e.prototype.average=function(){var e=this.count();return e>0?this.sum()/e:0},e.median=function(e){return e.median()},e.prototype.median=function(){var e=this.count();if(0===e)return 0;var t=this.orderBy(function(e){return e}).toArray();return e%2==0?(t[e/2-1]+t[e/2])/2:t[Math.floor(e/2)]},e.std=function(e){return e.std()},e.prototype.std=function(){var e=this.bake(),t=e.count();if(0===t)return 0;var r=e.average(),n=e.select(function(e){var t=e-r;return t*t}).sum();return Math.sqrt(n/t)},e.min=function(e){return e.min()},e.prototype.min=function(){return this.aggregate(function(e,t){return Math.min(e,t)})},e.max=function(e){return e.max()},e.prototype.max=function(){return this.aggregate(function(e,t){return Math.max(e,t)})},e.prototype.invert=function(){return this.select(function(e){return-e})},e.prototype.counter=function(e){return this.groupSequentialBy(e).selectMany(function(t,r){return e(t.first())?M.range(1,t.count()).withIndex(t.getIndex()).toPairs():M.replicate(0,t.count()).withIndex(t.getIndex()).toPairs()}).withIndex(function(e){return e[0]}).select(function(e){return e[1]})},e.prototype.reverse=function(){var t=this;return new e(function(){return{values:new g.ReverseIterable(t.getContent().values),index:new g.ReverseIterable(t.getContent().index),pairs:new g.ReverseIterable(t.getContent().pairs)}})},e.prototype.distinct=function(t){var r=this;return new e(function(){return{values:new b.DistinctIterable(r.getContent().values,t),pairs:new b.DistinctIterable(r.getContent().pairs,function(e){return t&&t(e[1])||e[1]})}})},e.prototype.groupBy=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to 'Series.groupBy' to be a selector function that determines the value to group the series by.");return new e(function(){var n,u,o=[],a={},s=0;try{for(var c=i(r.getContent().pairs),l=c.next();!l.done;l=c.next()){var f=l.value,h=t(f[1],s);++s;var p=a[h];if(p)p.push(f);else{var d=[];d.push(f),o.push(d),a[h]=d}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(u=c.return)&&u.call(c)}finally{if(n)throw n.error}}return{values:o.map(function(t){return new e({pairs:t})})}})},e.prototype.groupSequentialBy=function(e){if(e){if(!j.isFunction(e))throw new Error("Expected 'selector' parameter to 'Series.groupSequentialBy' to be a selector function that determines the value to group the series by.")}else e=function(e){return e};return this.variableWindow(function(t,r){return e(t)===e(r)})},e.concat=function(t){if(!j.isArray(t))throw new Error("Expected 'series' parameter to 'Series.concat' to be an array of series.");return new e(function(){var e=t.map(function(e){return e.getContent()});return{values:new m.ConcatIterable(e.map(function(e){return e.values})),pairs:new m.ConcatIterable(e.map(function(e){return e.pairs}))}})},e.prototype.concat=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n,u,o,a,s=[this];try{for(var c=i(t),l=c.next();!l.done;l=c.next()){var f=l.value;if(j.isArray(f))try{for(var h=i(f),p=h.next();!p.done;p=h.next()){var d=p.value;s.push(d)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(o)throw o.error}}else s.push(f)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(u=c.return)&&u.call(c)}finally{if(n)throw n.error}}return e.concat(s)},e.zip=function(t,r){var n=Array.from(t);if(0===n.length)return new e;var u=n[0];return u.none()?new e:new e(function(){var e=n;return{index:u.getContent().index,values:new w.ZipIterable(e.map(function(e){return e.getContent().values}),r)}})},e.prototype.zip=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=t[t.length-1],u=[this].concat(t.slice(0,t.length-1));return e.zip(u,function(e){return n.apply(void 0,a(e))})},e.prototype.orderBy=function(e){var t=this.getContent();return new R({values:t.values,pairs:t.pairs,selector:e,direction:C.Direction.Ascending,parent:null})},e.prototype.orderByDescending=function(e){var t=this.getContent();return new R({values:t.values,pairs:t.pairs,selector:e,direction:C.Direction.Descending,parent:null})},e.prototype.union=function(e,t){if(t&&!j.isFunction(t))throw new Error("Expected optional 'selector' parameter to 'Series.union' to be a selector function.");return this.concat(e).distinct(t)},e.prototype.intersection=function(e,t,r){if(t){if(!j.isFunction(t))throw new Error("Expected optional 'outerSelector' parameter to 'Series.intersection' to be a function.")}else t=function(e){return e};if(r){if(!j.isFunction(r))throw new Error("Expected optional 'innerSelector' parameter to 'Series.intersection' to be a function.")}else r=function(e){return e};return this.where(function(n){var u=t(n);return e.where(function(e){return u===r(e)}).any()})},e.prototype.except=function(e,t,r){if(t){if(!j.isFunction(t))throw new Error("Expected optional 'outerSelector' parameter to 'Series.except' to be a function.")}else t=function(e){return e};if(r){if(!j.isFunction(r))throw new Error("Expected optional 'innerSelector' parameter to 'Series.except' to be a function.")}else r=function(e){return e};return this.where(function(n){var u=t(n);return e.where(function(e){return u===r(e)}).none()})},e.prototype.join=function(t,r,n,u){if(!j.isFunction(r))throw new Error("Expected 'outerKeySelector' parameter of 'Series.join' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'innerKeySelector' parameter of 'Series.join' to be a selector function.");if(!j.isFunction(u))throw new Error("Expected 'resultSelector' parameter of 'Series.join' to be a selector function.");var o=this;return new e(function(){var e,a,s,c,l=t.groupBy(n).toObject(function(e){return n(e.first())},function(e){return e}),f=(o.getContent(),[]);try{for(var h=i(o),p=h.next();!p.done;p=h.next()){var d=p.value,y=l[r(d)];if(y)try{for(var D=i(y),m=D.next();!m.done;m=D.next()){var v=m.value;f.push(u(d,v))}}catch(e){s={error:e}}finally{try{m&&!m.done&&(c=D.return)&&c.call(D)}finally{if(s)throw s.error}}}}catch(t){e={error:t}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(e)throw e.error}}return{values:f}})},e.prototype.joinOuter=function(e,t,r,n){if(!j.isFunction(t))throw new Error("Expected 'outerKeySelector' parameter of 'Series.joinOuter' to be a selector function.");if(!j.isFunction(r))throw new Error("Expected 'innerKeySelector' parameter of 'Series.joinOuter' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'resultSelector' parameter of 'Series.joinOuter' to be a selector function.");var u=this.except(e,t,r).select(function(e){return n(e,null)}).resetIndex(),i=e.except(this,r,t).select(function(e){return n(null,e)}).resetIndex(),o=this.join(e,t,r,n);return u.concat(o).concat(i).resetIndex()},e.prototype.joinOuterLeft=function(e,t,r,n){if(!j.isFunction(t))throw new Error("Expected 'outerKeySelector' parameter of 'Series.joinOuterLeft' to be a selector function.");if(!j.isFunction(r))throw new Error("Expected 'innerKeySelector' parameter of 'Series.joinOuterLeft' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'resultSelector' parameter of 'Series.joinOuterLeft' to be a selector function.");var u=this.except(e,t,r).select(function(e){return n(e,null)}).resetIndex(),i=this.join(e,t,r,n);return u.concat(i).resetIndex()},e.prototype.joinOuterRight=function(e,t,r,n){if(!j.isFunction(t))throw new Error("Expected 'outerKeySelector' parameter of 'Series.joinOuterRight' to be a selector function.");if(!j.isFunction(r))throw new Error("Expected 'innerKeySelector' parameter of 'Series.joinOuterRight' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'resultSelector' parameter of 'Series.joinOuterRight' to be a selector function.");var u=e.except(this,r,t).select(function(e){return n(null,e)}).resetIndex();return this.join(e,t,r,n).concat(u).resetIndex()},e.prototype.truncateStrings=function(e){if(!j.isNumber(e))throw new Error("Expected 'maxLength' parameter to 'Series.truncateStrings' to be a number.");return this.select(function(t){return j.isString(t)&&t.length>e?t.substring(0,e):t})},e.prototype.round=function(e){if(void 0!==e){if(!j.isNumber(e))throw new Error("Expected 'numDecimalPlaces' parameter to 'Series.round' to be a number.")}else e=2;return this.select(function(t){return j.isNumber(t)?parseFloat(t.toFixed(e)):t})},e.prototype.insertPair=function(t){if(!j.isArray(t))throw new Error("Expected 'pair' parameter to 'Series.insertPair' to be an array.");if(2!==t.length)throw new Error("Expected 'pair' parameter to 'Series.insertPair' to be an array with two elements. The first element is the index, the second is the value.");return new e({pairs:[t]}).concat(this)},e.prototype.appendPair=function(t){if(!j.isArray(t))throw new Error("Expected 'pair' parameter to 'Series.appendPair' to be an array.");if(2!==t.length)throw new Error("Expected 'pair' parameter to 'Series.appendPair' to be an array with two elements. The first element is the index, the second is the value.");return this.concat(new e({pairs:[t]}))},e.prototype.fillGaps=function(e,t){if(!j.isFunction(e))throw new Error("Expected 'comparer' parameter to 'Series.fillGaps' to be a comparer function that compares two values and returns a boolean.");if(!j.isFunction(t))throw new Error("Expected 'generator' parameter to 'Series.fillGaps' to be a generator function that takes two values and returns an array of generated pairs to span the gap.");return this.rollingWindow(2).selectMany(function(r){var n=r.toPairs(),u=n[0],i=n[1];if(!e(u,i))return[u];var o=t(u,i);if(!j.isArray(o))throw new Error("Expected return from 'generator' parameter to 'Series.fillGaps' to be an array of pairs, instead got a "+typeof o);return[u].concat(o)}).withIndex(function(e){return e[0]}).select(function(e){return e[1]}).concat(this.tail(1))},e.prototype.defaultIfEmpty=function(t){if(this.none()){if(t instanceof e)return t;if(j.isArray(t))return new e(t);throw new Error("Expected 'defaultSequence' parameter to 'Series.defaultIfEmpty' to be an array or a series.")}return this},e.prototype.detectTypes=function(){var e=this;return new I.DataFrame(function(){var t=e.count(),r=e.select(function(e){var t=typeof e;return"object"===t&&j.isDate(e)&&(t="date"),t}).aggregate({},function(e,t){var r=e[t];return r||(r={count:0},e[t]=r),++r.count,e});return{columnNames:["Type","Frequency"],rows:Object.keys(r).map(function(e){return[e,r[e].count/t*100]})}})},e.prototype.detectValues=function(){var e=this;return new I.DataFrame(function(){var t=e.count(),r=e.aggregate(new Map,function(e,t){var r=e.get(t);return r||(r={count:0,value:t},e.set(t,r)),++r.count,e});return{columnNames:["Value","Frequency"],rows:Array.from(r.keys()).map(function(e){var n=r.get(e);return[n.value,n.count/t*100]})}})},e.prototype.bucket=function(e){if(!j.isNumber(e))throw new Error("Expected 'numBuckets' parameter to 'Series.bucket' to be a number.");if(this.none())return new I.DataFrame;var t=this.min(),r=(this.max()-t)/(e-1);return this.select(function(e){var n=Math.floor((e-t)/r),u=n*r+t;return{Value:e,Bucket:n,Min:u,Mid:u+.5*r,Max:u+r}}).inflate()},e.prototype.getTypeCode=function(){return"series"},e.defaultCountIterable=new l.CountIterable,e.defaultEmptyIterable=new c.EmptyIterable,e}();t.Series=T;var R=function(e){function t(r){for(var n=this,u=[],i=[],o=0,a=r.parent;null!==a;){var s=a.config;u.push(t.makeSortSpec(o,s.selector,s.direction)),i.push(t.makeSortSpec(o,t.makePairsSelector(s.selector),s.direction)),++o,a=s.parent}return u.push(t.makeSortSpec(o,r.selector,r.direction)),i.push(t.makeSortSpec(o,t.makePairsSelector(r.selector),r.direction)),(n=e.call(this,{values:new C.OrderedIterable(r.values,u),pairs:new C.OrderedIterable(r.pairs,i)})||this).config=r,n}return u(t,e),t.makeSortSpec=function(e,t,r){return{sortLevel:e,selector:t,direction:r}},t.makePairsSelector=function(e){return function(t,r){return e(t[1],r)}},t.prototype.thenBy=function(e){return new t({values:this.config.values,pairs:this.config.pairs,selector:e,direction:C.Direction.Ascending,parent:this})},t.prototype.thenByDescending=function(e){return new t({values:this.config.values,pairs:this.config.pairs,selector:e,direction:C.Direction.Descending,parent:this})},t}(T)},function(e,t,r){"use strict";var n,u=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},o=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,u,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(e){u={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return o},a=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(o(arguments[t]));return e},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=r(7),l=r(8),f=r(9),h=r(10),p=r(11),d=r(12),y=r(13),D=r(14),m=r(15),v=r(56),g=r(16),w=r(17),b=r(58),E=r(18),F=r(60),C=r(62),A=r(19),x=r(5),S=r(20),_=r(21),B=r(22),I=s(r(23)),O=s(r(3)),k=r(0),N=r(64),j=r(4),M=s(r(24)),P=s(r(25)),T=function(){function e(t){this.configFn=null,this.content=null,t?j.isFunction(t)?this.configFn=t:j.isArray(t)||j.isFunction(t[Symbol.iterator])?this.content=e.initFromArray(t):this.content=e.initFromConfig(t):this.content=e.initEmpty()}return e.initFromArray=function(t){var r=t[Symbol.iterator]().next(),n=r.done?[]:Object.keys(r.value);return{index:e.defaultCountIterable,values:t,pairs:new f.MultiIterable([e.defaultCountIterable,t]),isBaked:!0,columnNames:n}},e.initEmpty=function(){return{index:e.defaultEmptyIterable,values:e.defaultEmptyIterable,pairs:e.defaultEmptyIterable,isBaked:!0,columnNames:[]}},e.initColumnNames=function(e){var t=[],r={};try{for(var n=i(e),u=n.next();!u.done;u=n.next()){void 0===r[d=(p=u.value).toLowerCase()]?r[d]=1:r[d]+=1}}catch(e){o={error:e}}finally{try{u&&!u.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}var o,a,s,c,l={};try{for(var f=i(e),h=f.next();!h.done;h=f.next()){var p,d;if(r[d=(p=h.value).toLowerCase()]>1){var y=1;void 0!==l[d]&&(y=l[d]),t.push(p+"."+y),l[d]=y+1}else t.push(p)}}catch(e){s={error:e}}finally{try{h&&!h.done&&(c=f.return)&&c.call(f)}finally{if(s)throw s.error}}return t},e.checkIterable=function(e,t){if(j.isArray(e));else if(!j.isFunction(e[Symbol.iterator]))throw new Error("Expected '"+t+"' field of DataFrame config object to be an array of values or an iterable of values.")},e.initFromConfig=function(t){var r,n,u,o,a,s,c=!1;if(t.pairs&&(e.checkIterable(t.pairs,"pairs"),u=t.pairs),t.columns){var p=t.columns;if(j.isArray(p)||j.isFunction(p[Symbol.iterator])){var d=p;o=Array.from(d).map(function(e){return e.name}),p=j.toMap(d,function(e){return e.name},function(e){return e.series})}else{if(!j.isObject(p))throw new Error("Expected 'columns' member of 'config' parameter to DataFrame constructor to be an object with fields that define columns.");o=Object.keys(p)}var y=[];try{for(var D=i(o),m=D.next();!m.done;m=D.next()){var v=m.value;e.checkIterable(p[v],v),y.push(p[v])}}catch(e){a={error:e}}finally{try{m&&!m.done&&(s=D.return)&&s.call(D)}finally{if(a)throw a.error}}n=new b.CsvRowsIterable(o,new f.MultiIterable(y))}else t.columnNames&&(o=this.initColumnNames(t.columnNames)),t.rows?(t.columnNames||(o=new h.SelectIterable(new l.CountIterable,function(e){return"Column."+e.toString()})),e.checkIterable(t.rows,"rows"),n=new b.CsvRowsIterable(o,t.rows)):t.values?(e.checkIterable(t.values,"values"),n=t.values,t.columnNames||(o=new N.ColumnNamesIterable(n,t.considerAllRows||!1))):u?(n=new S.ExtractElementIterable(u,1),t.columnNames||(o=new N.ColumnNamesIterable(n,t.considerAllRows||!1))):(n=e.defaultEmptyIterable,t.columnNames||(o=e.defaultEmptyIterable));return t.index?(e.checkIterable(t.index,"index"),r=t.index):r=u?new S.ExtractElementIterable(u,0):e.defaultCountIterable,u||(u=new f.MultiIterable([r,n])),void 0!==t.baked&&(c=t.baked),{index:r,values:n,pairs:u,isBaked:c,columnNames:o}},e.prototype.lazyInit=function(){null===this.content&&null!==this.configFn&&(this.content=e.initFromConfig(this.configFn()))},e.prototype.getContent=function(){return this.lazyInit(),this.content},e.prototype[Symbol.iterator]=function(){return this.getContent().values[Symbol.iterator]()},e.prototype.getColumnNames=function(){return Array.from(this.getContent().columnNames)},e.prototype.getColumns=function(){var e=this;return new k.Series(function(){return{values:e.getColumnNames().map(function(t){var r=e.getSeries(t).skipWhile(function(e){return null==e}),n=r.any()?r.first():void 0;return{name:t,type:j.determineType(n),series:r}})}})},e.prototype.cast=function(){return this},e.prototype.getIndex=function(){var e=this;return new x.Index(function(){return{values:e.getContent().index}})},e.prototype.setIndex=function(e){if(!j.isString(e))throw new Error("Expected 'columnName' parameter to 'DataFrame.setIndex' to be a string that specifies the name of the column to set as the index for the dataframe.");return this.withIndex(this.getSeries(e))},e.prototype.withIndex=function(t){var r=this;return j.isFunction(t)?new e(function(){var e=r.getContent();return{columnNames:e.columnNames,values:e.values,index:r.deflate(t)}}):(e.checkIterable(t,"newIndex"),new e(function(){var e=r.getContent();return{columnNames:e.columnNames,values:e.values,index:t}}))},e.prototype.resetIndex=function(){var t=this;return new e(function(){var e=t.getContent();return{columnNames:e.columnNames,values:e.values}})},e.prototype.getSeries=function(e){var t=this;if(!j.isString(e))throw new Error("Expected 'columnName' parameter to 'DataFrame.getSeries' function to be a string that specifies the name of the column to retreive.");return new k.Series(function(){return{values:new h.SelectIterable(t.getContent().values,function(t){return t[e]}),index:t.getContent().index}})},e.prototype.hasSeries=function(e){var t,r,n=e.toLowerCase();try{for(var u=i(this.getColumnNames()),o=u.next();!o.done;o=u.next()){if(o.value.toLowerCase()===n)return!0}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return!1},e.prototype.expectSeries=function(e){if(!this.hasSeries(e))throw new Error("Expected dataframe to contain series with column name: '"+e+"'.");return this.getSeries(e)},e.prototype.withSeries=function(t,r){var n=this;if(j.isObject(t)){if(!j.isUndefined(r))throw new Error("Expected 'series' parameter to 'DataFrame.withSeries' to not be set when 'columnNameOrSpec is an object.")}else{if(!j.isString(t))throw new Error("Expected 'columnNameOrSpec' parameter to 'DataFrame.withSeries' function to be a string that specifies the column to set or replace.");if(!j.isFunction(r)&&!j.isObject(r))throw new Error("Expected 'series' parameter to 'DataFrame.withSeries' to be a Series object or a function that takes a dataframe and produces a Series.")}if(j.isObject(t)){var u=t,o=Object.keys(u),a=this;try{for(var s=i(o),c=s.next();!c.done;c=s.next()){var l=c.value;a=a.withSeries(l,u[l])}}catch(e){f={error:e}}finally{try{c&&!c.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}}return a.cast()}var f,p,d=t;if(this.none()){return(j.isFunction(r)?r(this):r).inflate(function(e){var t={};return t[d]=e,t}).cast()}return new e(function(){var e;e=j.isFunction(r)?r(n):r;var t=j.toMap2(e.toPairs(),function(e){return e[0]},function(e){return e[1]});return{columnNames:j.makeDistinct(n.getColumnNames().concat([d])),index:n.getContent().index,pairs:new h.SelectIterable(n.getContent().pairs,function(e){var r=e[0],n=e[1],u=Object.assign({},n);return u[d]=t.get(r),[r,u]})}})},e.merge=function(t){var r=new Map;try{for(var n=i(t),u=n.next();!u.done;u=n.next()){var o=u.value;try{for(var a=i(o.toPairs()),s=a.next();!s.done;s=a.next()){var c=s.value,l=c[0];if(r.has(l))r.set(l,Object.assign(r.get(l),c[1]));else{var f=Object.assign({},c[1]);r.set(l,f)}}}catch(e){d={error:e}}finally{try{s&&!s.done&&(y=a.return)&&y.call(a)}finally{if(d)throw d.error}}}}catch(e){h={error:e}}finally{try{u&&!u.done&&(p=n.return)&&p.call(n)}finally{if(h)throw h.error}}var h,p,d,y,D=Array.from(t).map(function(e){return e.getColumnNames()}).reduce(function(e,t){return e.concat(t)},[]),m=j.makeDistinct(D),v=Array.from(r.keys()).map(function(e){return[e,r.get(e)]});return v.sort(function(e,t){return e[0]===t[0]?0:e[0]>t[0]?1:-1}),new e({columnNames:m,pairs:v})},e.prototype.merge=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.merge([this].concat(t))},e.prototype.ensureSeries=function(e,t){if(j.isObject(e)){if(!j.isUndefined(t))throw new Error("Expected 'series' parameter to 'DataFrame.ensureSeries' to not be set when 'columnNameOrSpec is an object.")}else{if(!j.isString(e))throw new Error("Expected 'columnNameOrSpec' parameter to 'DataFrame.ensureSeries' function to be a string that specifies the column to set or replace.");if(!j.isFunction(t)&&!j.isObject(t))throw new Error("Expected 'series' parameter to 'DataFrame.ensureSeries' to be a Series object or a function that takes a dataframe and produces a Series.")}if(j.isObject(e)){var r=e,n=Object.keys(e),u=this;try{for(var o=i(n),a=o.next();!a.done;a=o.next()){var s=a.value;u=u.ensureSeries(s,r[s])}}catch(e){c={error:e}}finally{try{a&&!a.done&&(l=o.return)&&l.call(o)}finally{if(c)throw c.error}}return u}var c,l,f=e;return this.hasSeries(f)?this:this.withSeries(f,t)},e.prototype.subset=function(t){var r=this;if(!j.isArray(t))throw new Error("Expected 'columnNames' parameter to 'DataFrame.subset' to be an array of column names to keep.");return new e(function(){var e=r.getContent();return{columnNames:t,index:e.index,values:new h.SelectIterable(e.values,function(e){var r,n,u={};try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;u[s]=e[s]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return u}),pairs:new h.SelectIterable(e.pairs,function(e){var r,n,u={},o=e[1];try{for(var a=i(t),s=a.next();!s.done;s=a.next()){var c=s.value;u[c]=o[c]}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[e[0],u]})}})},e.prototype.dropSeries=function(t){var r=this;if(!j.isArray(t)){if(!j.isString(t))throw new Error("'DataFrame.dropSeries' expected either a string or an array or strings.");t=[t]}return new e(function(){var e,n,u=r.getContent(),o=[];try{for(var a=i(u.columnNames),s=a.next();!s.done;s=a.next()){var c=s.value;-1===t.indexOf(c)&&o.push(c)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return{columnNames:o,index:u.index,values:new h.SelectIterable(u.values,function(e){var r,n,u=Object.assign({},e);try{for(var o=i(t),a=o.next();!a.done;a=o.next()){delete u[a.value]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return u}),pairs:new h.SelectIterable(u.pairs,function(e){var r,n,u=Object.assign({},e[1]);try{for(var o=i(t),a=o.next();!a.done;a=o.next()){delete u[a.value]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return[e[0],u]})}})},e.prototype.reorderSeries=function(t){var r,n,u=this;if(!j.isArray(t))throw new Error("Expected parameter 'columnNames' to 'DataFrame.reorderSeries' to be an array with column names.");try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(!j.isString(s))throw new Error("Expected parameter 'columnNames' to 'DataFrame.reorderSeries' to be an array with column names.")}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return new e(function(){var e=u.getContent();return{columnNames:t,index:e.index,values:new h.SelectIterable(e.values,function(e){var r,n,u={};try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;u[s]=e[s]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return u}),pairs:new h.SelectIterable(e.pairs,function(e){var r,n,u=e[1],o={};try{for(var a=i(t),s=a.next();!s.done;s=a.next()){var c=s.value;o[c]=u[c]}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[e[0],o]})}})},e.prototype.bringToFront=function(t){var r,n,u=this;if(j.isArray(t))try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(!j.isString(s))throw new Error("Expect 'columnOrColumns' parameter to 'DataFrame.bringToFront' function to specify a column or columns via a string or an array of strings.")}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}else{if(!j.isString(t))throw new Error("Expect 'columnOrColumns' parameter to 'DataFrame.bringToFront' function to specify a column or columns via a string or an array of strings.");t=[t]}return new e(function(){var e=u.getContent(),r=Array.from(e.columnNames),n=[];try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;-1!==r.indexOf(s)&&n.push(s)}}catch(e){c={error:e}}finally{try{a&&!a.done&&(l=o.return)&&l.call(o)}finally{if(c)throw c.error}}var c,l,f,h,p=[];try{for(var d=i(r),y=d.next();!y.done;y=d.next()){var D=y.value;-1===t.indexOf(D)&&p.push(D)}}catch(e){f={error:e}}finally{try{y&&!y.done&&(h=d.return)&&h.call(d)}finally{if(f)throw f.error}}return{columnNames:n.concat(p),index:e.index,values:e.values,pairs:e.pairs}})},e.prototype.bringToBack=function(t){var r,n,u=this;if(j.isArray(t))try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(!j.isString(s))throw new Error("Expect 'columnOrColumns' parameter to 'DataFrame.bringToBack' function to specify a column or columns via a string or an array of strings.")}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}else{if(!j.isString(t))throw new Error("Expect 'columnOrColumns' parameter to 'DataFrame.bringToBack' function to specify a column or columns via a string or an array of strings.");t=[t]}return new e(function(){var e=u.getContent(),r=Array.from(e.columnNames),n=[];try{for(var o=i(t),a=o.next();!a.done;a=o.next()){var s=a.value;-1!==r.indexOf(s)&&n.push(s)}}catch(e){c={error:e}}finally{try{a&&!a.done&&(l=o.return)&&l.call(o)}finally{if(c)throw c.error}}var c,l,f,h,p=[];try{for(var d=i(r),y=d.next();!y.done;y=d.next()){var D=y.value;-1===t.indexOf(D)&&p.push(D)}}catch(e){f={error:e}}finally{try{y&&!y.done&&(h=d.return)&&h.call(d)}finally{if(f)throw f.error}}return{columnNames:p.concat(n),index:e.index,values:e.values,pairs:e.pairs}})},e.prototype.renameSeries=function(t){var r=this;if(!j.isObject(t))throw new Error("Expected parameter 'newColumnNames' to 'DataFrame.renameSeries' to be an array with column names.");var n,u,o=Object.keys(t);try{for(var a=i(o),s=a.next();!s.done;s=a.next()){var c=s.value;if(!j.isString(c))throw new Error("Expected existing column name '"+c+"' of 'newColumnNames' parameter to 'DataFrame.renameSeries' to be a string.");if(!j.isString(t[c]))throw new Error("Expected new column name '"+t[c]+"' for existing column '"+c+"' of 'newColumnNames' parameter to 'DataFrame.renameSeries' to be a string.")}}catch(e){n={error:e}}finally{try{s&&!s.done&&(u=a.return)&&u.call(a)}finally{if(n)throw n.error}}return new e(function(){var e,n,u=r.getContent(),a=[];try{for(var s=i(u.columnNames),c=s.next();!c.done;c=s.next()){var l=c.value;-1===o.indexOf(l)?a.push(l):a.push(t[l])}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}function f(e){var r,n,u=Object.assign({},e);try{for(var a=i(o),s=a.next();!s.done;s=a.next()){var c=s.value;u[t[c]]=u[c],delete u[c]}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return u}return{columnNames:a,index:u.index,values:new h.SelectIterable(u.values,f),pairs:new h.SelectIterable(u.pairs,function(e){return[e[0],f(e[1])]})}})},e.prototype.toArray=function(){var e,t,r=[];try{for(var n=i(this.getContent().values),u=n.next();!u.done;u=n.next()){var o=u.value;null!=o&&r.push(o)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toPairs=function(){var e,t,r=[];try{for(var n=i(this.getContent().pairs),u=n.next();!u.done;u=n.next()){var o=u.value;null!=o[1]&&null!==o[1]&&r.push(o)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(e,t){if(!j.isFunction(e))throw new Error("Expected 'keySelector' parameter to DataFrame.toObject to be a function.");if(!j.isFunction(t))throw new Error("Expected 'valueSelector' parameter to DataFrame.toObject to be a function.");return j.toMap(this,e,t)},e.prototype.toRows=function(){var e,t,r=this.getColumnNames(),n=[];try{for(var u=i(this.getContent().values),o=u.next();!o.done;o=u.next()){for(var a=o.value,s=[],c=0;c<r.length;++c)s.push(a[r[c]]);n.push(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}return n},e.prototype.select=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to 'DataFrame.select' function to be a function.");return new e(function(){var e=r.getContent();return{values:new h.SelectIterable(e.values,t),index:e.index}})},e.prototype.selectMany=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to 'DataFrame.selectMany' to be a function.");return new e(function(){return{pairs:new p.SelectManyIterable(r.getContent().pairs,function(e,r){var n,u,o=[];try{for(var a=i(t(e[1],r)),s=a.next();!s.done;s=a.next()){var c=s.value;o.push([e[0],c])}}catch(e){n={error:e}}finally{try{s&&!s.done&&(u=a.return)&&u.call(a)}finally{if(n)throw n.error}}return o})}})},e.prototype.transformSeries=function(e){if(!j.isObject(e))throw new Error("Expected 'columnSelectors' parameter of 'DataFrame.transformSeries' function to be an object. Field names should specify columns to transform. Field values should be selector functions that specify the transformation for each column.");var t,r,n=this;try{for(var u=i(Object.keys(e)),o=u.next();!o.done;o=u.next()){var a=o.value;n.hasSeries(a)&&(n=n.withSeries(a,n.getSeries(a).select(e[a])))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return n},e.prototype.generateSeries=function(e){if(j.isObject(e)){var t=e;f=Object.keys(t),h=this;try{for(var r=i(f),n=r.next();!n.done;n=r.next()){y=n.value;h=h.withSeries(y,h.select(t[y]).deflate())}}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(a)throw a.error}}return h}if(!j.isFunction(e))throw new Error("Expected 'generator' parameter to 'DataFrame.generateSeries' function to be a function or an object.");var u,o,a,s,c=e,l=this.select(c).bake(),f=l.getColumnNames(),h=this;try{for(var p=i(f),d=p.next();!d.done;d=p.next()){var y=d.value;h=h.withSeries(y,l.getSeries(y))}}catch(e){u={error:e}}finally{try{d&&!d.done&&(o=p.return)&&o.call(p)}finally{if(u)throw u.error}}return h},e.prototype.deflate=function(e){var t=this;if(e&&!j.isFunction(e))throw new Error("Expected 'selector' parameter to 'DataFrame.deflate' function to be a selector function.");return new k.Series(function(){var r=t.getContent();return e?{index:r.index,values:new h.SelectIterable(r.values,e),pairs:new h.SelectIterable(r.pairs,function(t,r){return[t[0],e(t[1],r)]})}:{index:r.index,values:r.values,pairs:r.pairs}})},e.prototype.inflateSeries=function(e,t)