Skip to content
Browse files

Merge pull request #183 from misoproject/release-0.3

Release 0.3
  • Loading branch information...
2 parents c6f6be2 + e0f2f61 commit a3d87beeedf363b93c340c85646cb9a5240c9419 @iros iros committed Oct 29, 2012
View
2 LICENSE-MIT
@@ -1,4 +1,4 @@
-Copyright (c) 2012 The Guardian, Bocoup
+Copyright (c) 2012 Irene Ros, Alex Graul;
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
View
25 README.md
@@ -7,28 +7,39 @@ Read more about Dataset [here](http://misoproject.com/dataset)
## Download
+All downloads are located in the [/dist](https://github.com/misoproject/dataset/tree/master/dist) directory. Here are some of them:
+
### Including Dependencies
-[miso.ds.dev.zip](https://github.com/downloads/misoproject/dataset/miso.ds.dev.0.2.2.zip) - Download Development With Dependencies - 0.2.2
+[miso.ds.dev.0.3.0.zip](https://github.com/downloads/misoproject/dataset/miso.ds.dev.0.3.0.zip) - Download Development With Dependencies - 0.3.0
+
+[miso.ds.deps.min.0.3.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.min.0.3.0.js) - Download Production With Dependencies - 0.3.0
+
+[miso.ds.deps.ie.0.3.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.ie.0.3.0.js) - Download Development With Dependencies for IE - 0.3.0
-[miso.ds.deps.min.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.min.0.2.2.js) - Download Production With Dependencies - 0.2.2
+[miso.ds.deps.ie.min.0.3.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.deps.ie.0.3.0.js) - Download Production With Dependencies for IE - 0.3.0
### Without Dependencies
The following builds do not have any of the dependencies built in. It is your own responsibility to include them as appropriate script elements in your page.
-[miso.ds.js](https://github.com/downloads/misoproject/dataset/miso.ds.min.0.2.2.js) - Download Production No Dependencies - 0.2.2
+[miso.ds.0.3.0.js](https://github.com/downloads/misoproject/dataset/miso.ds.min.0.3.0.js) - Download Development No Dependencies - 0.3.0
+
+[miso.ds.min.0.3.0.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.min.0.3.0.js) - Download Production No Dependencies - 0.3.0
+
+[miso.ds.0.3.0.m.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.0.3.0.m.js) - Download AMD Compatibile Build No Dependencies- 0.3.0
+
+[miso.ds.min.0.3.0.m.js](https://github.com/misoproject/dataset/tree/master/dist/miso.ds.min.0.3.0.m.js) - Download AMD Compatibile Build Production No Dependencies- 0.3.0
-[miso.ds.min.js](https://github.com/misoproject/dataset/tree/master/dist/) - Download Development No Dependencies - 0.2.2
### Dependencies
Dataset has the following dependencies:
-* [Lodash.js 0.6.1](http://lodash.com/)
+* [Lodash.js 0.9.0](http://lodash.com/)
* [Underscore.math.js (version unknown)](https://github.com/syntagmatic/underscore.math)
-* [Underscore.deferred.js 0.1.2](https://github.com/wookiehangover/underscore.Deferred)
-* [moment.js 1.7.0](http://momentjs.com/) (for date and time parsing)
+* [Underscore.deferred.js 0.2.0](https://github.com/wookiehangover/underscore.Deferred)
+* [moment.js 1.7.2](http://momentjs.com/) (for date and time parsing)
If you are planning on supporting IE, include the following json2.js library as well:
* [json2.js 2011-10-19](https://github.com/douglascrockford/JSON-js)
View
12 component.json
@@ -1,12 +0,0 @@
-{
- "name": "miso.dataset",
- "version": "0.2.2",
- "main": "./dist/miso.ds.0.2.2.js",
- "dependencies" : {
- "json2" : "*",
- "lodash" : "0.6.1",
- "moment" : "1.7.0",
- "underscore.deferred" : "*",
- "underscore.math" : "git://github.com/syntagmatic/underscore.math.git"
- }
-}
View
2 dist/LASTBUILD
@@ -1 +1 @@
-2012/09/03 05:58
+2012/10/27 04:34
View
3,160 dist/miso.ds.0.2.2.js → dist/miso.ds.0.3.0.js
1,571 additions, 1,589 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
3,406 dist/miso.ds.0.3.0.m.js
3,406 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
7,062 dist/miso.ds.deps.0.2.2.js → dist/miso.ds.deps.0.3.0.js
3,482 additions, 3,580 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
7,078 dist/miso.ds.deps.ie.0.2.2.js → dist/miso.ds.deps.ie.0.3.0.js
3,490 additions, 3,588 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
9 dist/miso.ds.deps.ie.min.0.2.2.js
@@ -1,9 +0,0 @@
-/**
-* Miso.Dataset - v0.2.2 - 9/3/2012
-* http://github.com/misoproject/dataset
-* Copyright (c) 2012 Alex Graul, Irene Ros;
-* Dual Licensed: MIT, GPL
-* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
-* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
-*/
-(function(a,b){function F(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,a._a=null,this._lang=c||!1}function G(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=H(j/1e3),b.seconds=i%60,h+=H(i/60),b.minutes=h%60,g+=H(h/60),b.hours=g%24,f+=H(g/24),f+=e*7,b.days=f%30,d+=H(f/30),b.months=d%12,c+=H(d/12),b.years=c,this._lang=!1}function H(a){return a<0?Math.ceil(a):Math.floor(a)}function I(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function J(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(1).month(a.month()+f*c).date(Math.min(g,a.daysInMonth())))}function K(a){return Object.prototype.toString.call(a)==="[object Array]"}function L(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function M(b,c){var d,e;for(d=1;d<7;d++)b[d]=b[d]==null?d===2?1:0:b[d];return b[7]=c,e=new a(0),c?(e.setUTCFullYear(b[0],b[1],b[2]),e.setUTCHours(b[3],b[4],b[5],b[6])):(e.setFullYear(b[0],b[1],b[2]),e.setHours(b[3],b[4],b[5],b[6])),e._a=b,e}function N(a,b){var c,d,e=[];!b&&h&&(b=require("./lang/"+a));for(c=0;c<i.length;c++)b[i[c]]=b[i[c]]||f.en[i[c]];for(c=0;c<12;c++)d=moment([2e3,c]),e[c]=new RegExp("^"+(b.months[c]||b.months(d,""))+"|^"+(b.monthsShort[c]||b.monthsShort(d,"")).replace(".",""),"i");return b.monthsParse=b.monthsParse||e,f[a]=b,b}function O(a){var b=typeof a=="string"&&a||a&&a._lang||null;return b?f[b]||N(b):moment}function P(a){return C[a]?"'+("+C[a]+")+'":a.replace(m,"").replace(/\\?'/g,"\\'")}function Q(a){return O().longDateFormat[a]||a}function R(a){var b="var a,b;return '"+a.replace(k,P)+"';",c=Function;return new c("t","v","o","p","m",b)}function S(a){return B[a]||(B[a]=R(a)),B[a]}function T(a,b){function d(d,e){return c[d].call?c[d](a,b):c[d][e]}var c=O(a);while(l.test(b))b=b.replace(l,Q);return B[b]||(B[b]=R(b)),B[b](a,d,c.ordinal,I,c.meridiem)}function U(a){switch(a){case"DDDD":return q;case"YYYY":return r;case"S":case"SS":case"SSS":case"DDD":return p;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return s;case"Z":case"ZZ":return t;case"T":return u;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return o;default:return new RegExp(a.replace("\\",""))}}function V(a,b,c,d){var e;switch(a){case"M":case"MM":c[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(e=0;e<12;e++)if(O().monthsParse[e].test(b)){c[1]=e;break}break;case"D":case"DD":case"DDD":case"DDDD":b!=null&&(c[2]=~~b);break;case"YY":b=~~b,c[0]=b+(b>70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(y),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}}function W(a,b){var c=[0,0,1,0,0,0,0],d={tzh:0,tzm:0},e=b.match(k),f,g;for(f=0;f<e.length;f++)g=(U(e[f]).exec(a)||[])[0],a=a.replace(U(e[f]),""),V(e[f],g,c,d);return d.isPm&&c[3]<12&&(c[3]+=12),d.isPm===!1&&c[3]===12&&(c[3]=0),c[3]+=d.tzh,c[4]+=d.tzm,M(c,d.isUTC)}function X(a,b){var c,d=a.match(n)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=W(a,b[g]),e=T(new F(h),b[g]).match(n)||[],i=L(d,e),i<f&&(f=i,c=h);return c}function Y(b){var c="YYYY-MM-DDT",d;if(v.exec(b)){for(d=0;d<4;d++)if(x[d][1].exec(b)){c+=x[d][0];break}return t.exec(b)?W(b,c+" Z"):W(b,c)}return new a(b)}function Z(a,b,c,d,e){var f=e.relativeTime[a];return typeof f=="function"?f(b||1,!!c,a,d):f.replace(/%d/i,b||1)}function $(a,b,c){var e=d(Math.abs(a)/1e3),f=d(e/60),g=d(f/60),h=d(g/24),i=d(h/365),j=e<45&&["s",e]||f===1&&["m"]||f<45&&["mm",f]||g===1&&["h"]||g<22&&["hh",g]||h===1&&["d"]||h<=25&&["dd",h]||h<=45&&["M"]||h<345&&["MM",d(h/30)]||i===1&&["y"]||["yy",i];return j[2]=b,j[3]=a>0,j[4]=c,Z.apply({},j)}function _(a,b){moment.fn[a]=function(a){var c=this._isUTC?"UTC":"";return a!=null?(this._d["set"+c+b](a),this):this._d["get"+c+b]()}}function ba(a){moment.duration.fn[a]=function(){return this._data[a]}}function bb(a,b){moment.duration.fn["as"+a]=function(){return+this/b}}var moment,c="1.7.0",d=Math.round,e,f={},g="en",h=typeof module!="undefined"&&module.exports,i="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),j=/^\/?Date\((\-?\d+)/i,k=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?)/g,l=/(LT|LL?L?L?)/g,m=/(^\[)|(\\)|\]$/g,n=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,o=/\d\d?/,p=/\d{1,3}/,q=/\d{3}/,r=/\d{1,4}/,s=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,t=/Z|[\+\-]\d\d:?\d\d/i,u=/T/i,v=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,w="YYYY-MM-DDTHH:mm:ssZ",x=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],y=/([\+\-]|\d\d)/gi,z="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),A={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},B={},C={M:"(a=t.month()+1)",MMM:'v("monthsShort",t.month())',MMMM:'v("months",t.month())',D:"(a=t.date())",DDD:"(a=new Date(t.year(),t.month(),t.date()),b=new Date(t.year(),0,1),a=~~(((a-b)/864e5)+1.5))",d:"(a=t.day())",dd:'v("weekdaysMin",t.day())',ddd:'v("weekdaysShort",t.day())',dddd:'v("weekdays",t.day())',w:"(a=new Date(t.year(),t.month(),t.date()-t.day()+5),b=new Date(a.getFullYear(),0,4),a=~~((a-b)/864e5/7+1.5))",YY:"p(t.year()%100,2)",YYYY:"p(t.year(),4)",a:"m(t.hours(),t.minutes(),!0)",A:"m(t.hours(),t.minutes(),!1)",H:"t.hours()",h:"t.hours()%12||12",m:"t.minutes()",s:"t.seconds()",S:"~~(t.milliseconds()/100)",SS:"p(~~(t.milliseconds()/10),2)",SSS:"p(t.milliseconds(),3)",Z:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(a/60),2)+":"+p(~~a%60,2)',ZZ:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(10*a/6),4)'},D="DDD w M D d".split(" "),E="M D H h m s w".split(" ");while(D.length)e=D.pop(),C[e+"o"]=C[e]+"+o(a)";while(E.length)e=E.pop(),C[e+e]="p("+C[e]+",2)";C.DDDD="p("+C.DDD+",3)",moment=function(c,d){if(c===null||c==="")return null;var e,f;return moment.isMoment(c)?new F(new a(+c._d),c._isUTC,c._lang):(d?K(d)?e=X(c,d):e=W(c,d):(f=j.exec(c),e=c===b?new a:f?new a(+f[1]):c instanceof a?c:K(c)?M(c):typeof c=="string"?Y(c):new a(c)),new F(e))},moment.utc=function(a,b){return K(a)?new F(M(a,!0),!0):(typeof a=="string"&&!t.exec(a)&&(a+=" +0000",b&&(b+=" Z")),moment(a,b).utc())},moment.unix=function(a){return moment(a*1e3)},moment.duration=function(a,b){var c=moment.isDuration(a),d=typeof a=="number",e=c?a._data:d?{}:a,f;return d&&(b?e[b]=a:e.milliseconds=a),f=new G(e),c&&(f._lang=a._lang),f},moment.humanizeDuration=function(a,b,c){return moment.duration(a,b===!0?null:b).humanize(b===!0?!0:c)},moment.version=c,moment.defaultFormat=w,moment.lang=function(a,b){var c;if(!a)return g;(b||!f[a])&&N(a,b);if(f[a]){for(c=0;c<i.length;c++)moment[i[c]]=f[a][i[c]];moment.monthsParse=f[a].monthsParse,g=a}},moment.langData=O,moment.isMoment=function(a){return a instanceof F},moment.isDuration=function(a){return a instanceof G},moment.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),moment.fn=F.prototype={clone:function(){return moment(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?!L(this._a,(this._a[7]?moment.utc(this):this).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return T(this,a?a:moment.defaultFormat)},add:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return J(this,c,1),this},subtract:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return J(this,c,-1),this},diff:function(a,b,c){var e=this._isUTC?moment(a).utc():moment(a).local(),f=(this.zone()-e.zone())*6e4,g=this._d-e._d-f,h=this.year()-e.year(),i=this.month()-e.month(),j=this.date()-e.date(),k;return b==="months"?k=h*12+i+j/30:b==="years"?k=h+(i+j/30)/12:k=b==="seconds"?g/1e3:b==="minutes"?g/6e4:b==="hours"?g/36e5:b==="days"?g/864e5:b==="weeks"?g/6048e5:g,c?k:d(k)},from:function(a,b){return moment.duration(this.diff(a)).lang(this._lang).humanize(!b)},fromNow:function(a){return this.from(moment(),a)},calendar:function(){var a=this.diff(moment().sod(),"days",!0),b=this.lang().calendar,c=b.sameElse,d=a<-6?c:a<-1?b.lastWeek:a<0?b.lastDay:a<1?b.sameDay:a<2?b.nextDay:a<7?b.nextWeek:c;return this.format(typeof d=="function"?d.apply(this):d)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<moment([this.year()]).zone()||this.zone()<moment([this.year(),5]).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return a==null?b:this.add({d:a-b})},startOf:function(a){switch(a.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return this},endOf:function(a){return this.startOf(a).add(a.replace(/s?$/,"s"),1).subtract("ms",1)},sod:function(){return this.clone().startOf("day")},eod:function(){return this.clone().endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return moment.utc([this.year(),this.month()+1,0]).date()},lang:function(a){return a===b?O(this):(this._lang=a,this)}};for(e=0;e<z.length;e++)_(z[e].toLowerCase(),z[e]);_("year","FullYear"),moment.duration.fn=G.prototype={weeks:function(){return H(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,c=this.lang().relativeTime,d=$(b,!a,this.lang());return a&&(d=(b<=0?c.past:c.future).replace(/%s/i,d)),d},lang:moment.fn.lang};for(e in A)A.hasOwnProperty(e)&&(bb(e,A[e]),ba(e.toLowerCase()));bb("Weeks",6048e5),h&&(module.exports=moment),typeof ender=="undefined"&&(this.moment=moment),typeof define=="function"&&define.amd&&define("moment",[],function(){return moment})}).call(this,Date),function(a,b){function bq(a){return new br(a)}function br(a){if(a&&a._wrapped)return a;this._wrapped=a}function bC(a,b,c){b||(b=0);var d=a.length,e=d-b>=(c||n),f=e?{}:a;if(e){var g,h=b-1;while(++h<d)g=a[h]+"",(F.call(f,g)?f[g]:f[g]=[]).push(a[h])}return function(a){if(e){var c=a+"";return F.call(f,c)&&cM(f[c],a)>-1}return cM(f,a,b)>-1}}function bD(){var a,b,c,d=-1,e=arguments.length,f={bottom:"",exit:"",init:"",top:"",arrayBranch:{beforeLoop:""},objectBranch:{beforeLoop:""}};while(++d<e){a=arguments[d];for(b in a)c=(c=a[b])==null?"":c,/beforeLoop|inLoop/.test(b)?(typeof c=="string"&&(c={array:c,object:c}),f.arrayBranch[b]=c.array||"",f.objectBranch[b]=c.object||""):f[b]=c}var g=f.args,i=/^[^,]+/.exec(g)[0],j=f.useStrict;f.firstArg=i,f.hasDontEnumBug=Z,f.isKeysFast=bh,f.noArgsEnum=ba,f.shadowed=A,f.useHas=f.useHas!==!1,f.useStrict=j==null?bi:j,f.noCharByIndex==null&&(f.noCharByIndex=bd),f.exit||(f.exit="if (!"+i+") return result");if(i!="collection"||!f.arrayBranch.inLoop)f.arrayBranch=null;var k=Function("arrayLikeClasses, ArrayProto, bind, compareAscending, concat, forIn, hasOwnProperty, identity, indexOf, isArguments, isArray, isFunction, isPlainObject, iteratorBind, objectClass, objectTypes, nativeKeys, propertyIsEnumerable, slice, stringClass, toString","var callee = function("+g+") {\n"+bs(f)+"\n};\n"+"return callee");return k(bk,h,db,bE,E,bX,F,dn,cM,bO,bP,bQ,bR,bI,U,bo,N,H,I,W,J)}function bE(a,c){var d=a.index,e=c.index;return a=a.criteria,c=c.criteria,a===b?1:c===b?-1:a<c?-1:a>c?1:d<e?-1:1}function bF(a,b){return D[b]}function bG(a){return"\\"+bp[a]}function bH(a){return bm[a]}function bI(a,b){return function(c,d,e){return a.call(b,c,d,e)}}function bJ(){}function bK(a,b){if(a&&p.test(b))return"<e%-"+b+"%>";var c=D.length;return D[c]="' +\n__e("+b+") +\n'",C+c}function bL(a,b,c,d){if(d){var e=D.length;return D[e]="';\n"+d+";\n__p += '",C+e}return b?bK(null,b):bM(null,c)}function bM(a,b){if(a&&p.test(b))return"<e%="+b+"%>";var c=D.length;return D[c]="' +\n((__t = ("+b+")) == null ? '' : __t) +\n'",C+c}function bN(a){return bn[a]}function bO(a){return J.call(a)==O}function bQ(a){return typeof a=="function"}function bR(a,b){return a?a==j||a.__proto__==j&&(b||!bO(a)):!1}function bT(a,b,c,d,e){if(a==null)return a;c&&(b=!1),e||(e={value:null}),e.value==null&&(e.value=!!(i.clone||k.clone||l.clone));var f=bo[typeof a];if((f||e.value)&&a.clone&&bQ(a.clone))return e.value=null,a.clone(b);if(f){var g=J.call(a);if(!bl[g]||bb&&bO(a))return a;var h=g==P;f=h||(g==U?bR(a,!0):f)}if(!f||!b)return f?h?I.call(a):bW({},a):a;var j=a.constructor;switch(g){case Q:return new j(a==!0);case R:return new j(+a);case T:case W:return new j(a);case V:return j(a.source,u.exec(a))}d||(d=[]);var m=d.length;while(m--)if(d[m].source==a)return d[m].value;m=a.length;var n=h?j(m):{};d.push({value:n,source:a});if(h){var o=-1;while(++o<m)n[o]=bT(a[o],b,null,d,e)}else bY(a,function(a,c){n[c]=bT(a,b,null,d,e)});return n}function b$(a,b){return a?F.call(a,b):!1}function b_(a){return a===!0||a===!1||J.call(a)==Q}function ca(a){return J.call(a)==R}function cb(a){return a?a.nodeType===1:!1}function cd(a,b,c,d){if(a==null||b==null)return a===b;d||(d={value:null}),d.value==null&&(d.value=!!(i.isEqual||k.isEqual||l.isEqual));if(bo[typeof a]||bo[typeof b]||d.value){a._chain&&(a=a._wrapped),b._chain&&(b=b._wrapped);if(a.isEqual&&bQ(a.isEqual))return d.value=null,a.isEqual(b);if(b.isEqual&&bQ(b.isEqual))return d.value=null,b.isEqual(a)}if(a===b)return a!==0||1/a==1/b;var e=J.call(a);if(e!=J.call(b))return!1;switch(e){case Q:case R:return+a==+b;case T:return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case V:case W:return a==b+""}var f=bk[e];if(bb&&!f&&(f=bO(a))&&!bO(b))return!1;if(!f&&(e!=U||be&&(typeof a.toString!="function"&&typeof (a+"")=="string"||typeof b.toString!="function"&&typeof (b+"")=="string")))return!1;c||(c=[]);var g=c.length;while(g--)if(c[g]==a)return!0;var h=-1,j=!0,m=0;c.push(a);if(f){m=a.length,j=m==b.length;if(j)while(m--)if(!(j=cd(a[m],b[m],c,d)))break;return j}var n=a.constructor,o=b.constructor;if(n!=o&&!(bQ(n)&&n instanceof n&&bQ(o)&&o instanceof o))return!1;for(var p in a)if(F.call(a,p)){m++;if(!F.call(b,p)||!cd(a[p],b[p],c,d))return!1}for(p in b)if(F.call(b,p)&&!(m--))return!1;if(Z)while(++h<7){p=A[h];if(F.call(a,p)&&(!F.call(b,p)||!cd(a[p],b[p],c,d)))return!1}return!0}function ce(a){return M(a)&&J.call(a)==T}function cf(a){return a?bo[typeof a]:!1}function cg(a){return J.call(a)==T&&a!=+a}function ch(a){return a===null}function ci(a){return J.call(a)==T}function cj(a){return J.call(a)==V}function ck(a){return J.call(a)==W}function cl(a){return a===b}function cp(a){if(!a)return 0;var b=J.call(a),c=a.length;return bk[b]||bb&&bO(a)||b==U&&c>-1&&c===c>>>0&&bQ(a.splice)?c:cm(a).length}function cC(a,b,c,d){if(!a)return c;var e=a.length,f=arguments.length<3;d&&(b=bI(b,d));if(e>-1&&e===e>>>0){var g=bd&&J.call(a)==W?a.split(""):a;e&&f&&(c=g[--e]);while(e--)c=b(c,g[e],e,a);return c}var h,i=cm(a);e=i.length,e&&f&&(c=a[i[--e]]);while(e--)h=i[e],c=b(c,a[h],h,a);return c}function cG(a){if(!a)return[];if(a.toArray&&bQ(a.toArray))return a.toArray();var b=a.length;return b>-1&&b===b>>>0?(bc?J.call(a)==W:typeof a=="string")?a.split(""):I.call(a):cq(a)}function cI(a){var b=[];if(!a)return b;var c=-1,d=a.length;while(++c<d)a[c]&&b.push(a[c]);return b}function cJ(a){var b=[];if(!a)return b;var c=-1,d=a.length,e=E.apply(b,arguments),f=bC(e,d);while(++c<d)f(a[c])||b.push(a[c]);return b}function cK(a,b,c){if(a)return b==null||c?a[0]:I.call(a,0,b)}function cL(a,b){var c=[];if(!a)return c;var d,e=-1,f=a.length;while(++e<f)d=a[e],bP(d)?G.apply(c,b?d:cL(d)):c.push(d);return c}function cM(a,b,c){if(!a)return-1;var d=-1,e=a.length;if(c)if(typeof c=="number")d=(c<0?Math.max(0,e+c):c)-1;else return d=cW(a,b),a[d]===b?d:-1;while(++d<e)if(a[d]===b)return d;return-1}function cN(a,b,c){return a?I.call(a,0,-(b==null||c?1:b)):[]}function cO(a){var b=[];if(!a)return b;var c,d=arguments.length,e=[],f=-1,g=a.length;a:while(++f<g){c=a[f];if(cM(b,c)<0){for(var h=1;h<d;h++)if(!(e[h]||(e[h]=bC(arguments[h])))(c))continue a;b.push(c)}}return b}function cP(a,b,c){if(a){var d=a.length;return b==null||c?a[d-1]:I.call(a,-b||d)}}function cQ(a,b,c){if(!a)return-1;var d=a.length;c&&typeof c=="number"&&(d=(c<0?Math.max(0,d+c):Math.min(c,d-1))+1);while(d--)if(a[d]===b)return d;return-1}function cR(a,b,c){var d=-Infinity,e=d;if(!a)return e;var f,g=-1,h=a.length;if(!b){while(++g<h)a[g]>e&&(e=a[g]);return e}c&&(b=bI(b,c));while(++g<h)f=b(a[g],g,a),f>d&&(d=f,e=a[g]);return e}function cS(a,b,c){var d=Infinity,e=d;if(!a)return e;var f,g=-1,h=a.length;if(!b){while(++g<h)a[g]<e&&(e=a[g]);return e}c&&(b=bI(b,c));while(++g<h)f=b(a[g],g,a),f<d&&(d=f,e=a[g]);return e}function cT(a,b,c){a=+a||0,c=+c||1,b==null&&(b=a,a=0);var d=-1,e=Math.max(0,Math.ceil((b-a)/c)),f=Array(e);while(++d<e)f[d]=a,a+=c;return f}function cU(a,b,c){return a?I.call(a,b==null||c?1:b):[]}function cV(a){if(!a)return[];var b,c=-1,d=a.length,e=Array(d);while(++c<d)b=Math.floor(Math.random()*(c+1)),e[c]=e[b],e[b]=a[c];return e}function cW(a,b,c,d){if(!a)return 0;var e,f=0,g=a.length;if(c){d&&(c=db(c,d)),b=c(b);while(f<g)e=f+g>>>1,c(a[e])<b?f=e+1:g=e}else while(f<g)e=f+g>>>1,a[e]<b?f=e+1:g=e;return f}function cX(){var a=-1,b=[],c=E.apply(b,arguments),d=c.length;while(++a<d)cM(b,c[a])<0&&b.push(c[a]);return b}function cY(a,b,c,d){var e=[];if(!a)return e;var f,g=-1,h=a.length,i=[];typeof b=="function"&&(d=c,c=b,b=!1),c?d&&(c=bI(c,d)):c=dn;while(++g<h){f=c(a[g],g,a);if(b?!g||i[i.length-1]!==f:cM(i,f)<0)i.push(f),e.push(a[g])}return e}function cZ(a){var b=[];if(!a)return b;var c=-1,d=a.length,e=bC(arguments,1,20);while(++c<d)e(a[c])||b.push(a[c]);return b}function c$(a){if(!a)return[];var b=-1,c=cR(cA(arguments,"length")),d=Array(c);while(++b<c)d[b]=cA(arguments,b);return d}function c_(a,b){if(!a)return{};var c=-1,d=a.length,e={};b||(b=[]);while(++c<d)e[a[c]]=b[c];return e}function da(a,b){return a<1?b():function(){if(--a<1)return b.apply(this,arguments)}}function db(a,b){function f(){var g=arguments,h=b;d||(a=b[c]),e.length&&(g=g.length?e.concat(I.call(g)):e);if(this instanceof f){bJ.prototype=a.prototype,h=new bJ;var i=a.apply(h,g);return i&&bo[typeof i]?i:h}return a.apply(h,g)}var c,d=bQ(a);if(!d)c=b,b=a;else if(bg||K&&arguments.length>2)return K.call.apply(K,arguments);var e=I.call(arguments,2);return f}function dd(){var a=arguments;return function(){var b=arguments,c=a.length;while(c--)b=[a[c].apply(this,b)];return b[0]}}function de(a,b,c){function h(){g=null,c||a.apply(f,d)}var d,e,f,g;return function(){var i=c&&!g;return d=arguments,f=this,X(g),g=Y(h,b),i&&(e=a.apply(f,d)),e}}function df(a,c){var d=I.call(arguments,2);return Y(function(){return a.apply(b,d)},c)}function dg(a){var c=I.call(arguments,1);return Y(function(){return a.apply(b,c)},1)}function dh(a,b){var c={};return function(){var d=b?b.apply(this,arguments):arguments[0];return F.call(c,d)?c[d]:c[d]=a.apply(this,arguments)}}function di(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}}function dj(a){var b=I.call(arguments,1),c=b.length;return function(){var d,e=arguments;return e.length&&(b.length=c,G.apply(b,e)),d=b.length==1?a.call(this,b[0]):a.apply(this,b),b.length=c,d}}function dk(a,b){function h(){g=new Date,f=null,a.apply(e,c)}var c,d,e,f,g=0;return function(){var i=new Date,j=b-(i-g);return c=arguments,e=this,j<=0?(g=i,d=a.apply(e,c)):f||(f=Y(h,j)),d}}function dl(a,b){return function(){var c=[a];return arguments.length&&G.apply(c,arguments),b.apply(this,c)}}function dm(a){return a==null?"":(a+"").replace(y,bH)}function dn(a){return a}function dp(a){cw(bZ(a),function(b){var c=bq[b]=a[b];br.prototype[b]=function(){var a=[this._wrapped];arguments.length&&G.apply(a,arguments);var b=c.apply(bq,a);return this._chain&&(b=new br(b),b._chain=!0),b}})}function dq(){return a._=o,this}function dr(a,b){if(!a)return null;var c=a[b];return bQ(c)?a[b]():c}function ds(a,b,g){g||(g={}),a+="";var h,i,j=g.escape,k=g.evaluate,l=g.interpolate,m=bq.templateSettings,n=g.variable||m.variable,o=n;j==null&&(j=m.escape),k==null&&(k=m.evaluate||!1),l==null&&(l=m.interpolate),j&&(a=a.replace(j,bK)),l&&(a=a.replace(l,bM)),k!=c&&(c=k,f=RegExp("<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>"+(k?"|"+k.source:""),"g")),h=D.length,a=a.replace(f,bL),h=h!=D.length,a="__p += '"+a.replace(z,bG).replace(x,bF)+"';\n",D.length=0,o||(n=d||"obj",h?a="with ("+n+") {\n"+a+"\n}\n":(n!=d&&(d=n,e=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),a=a.replace(v,"$&"+n+".").replace(e,"$1__d"))),a=(h?a.replace(r,""):a).replace(s,"$1").replace(t,"$1;"),a="function("+n+") {\n"+(o?"":n+" || ("+n+" = {});\n")+"var __t, __p = '', __e = _.escape"+(h?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":(o?"":", __d = "+n+"."+n+" || "+n)+";\n")+a+"return __p\n}",bj&&(a+="\n//@ sourceURL=/lodash/template/source["+B++ +"]");try{i=Function("_","return "+a)(bq)}catch(p){i=function(){throw p}}return b?i(b):(i.source=a,i)}function dt(a,b,c){var d=-1;if(c)while(++d<a)b.call(c,d);else while(++d<a)b(d)}function du(a){return a==null?"":(a+"").replace(q,bN)}function dv(a){var b=m++;return a?a+b:b}function dw(a){return a=new br(a),a._chain=!0,a}function dx(a,b){return b(a),a}function dy(){return this._chain=!0,this}function dz(){return this._wrapped}"use strict";var c,d,e,f,g=typeof exports=="object"&&exports&&(typeof global=="object"&&global&&global==global.global&&(a=global),exports),h=Array.prototype,i=Boolean.prototype,j=Object.prototype,k=Number.prototype,l=String.prototype,m=0,n=30,o=a._,p=/[-+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,q=/&(?:amp|lt|gt|quot|#x27);/g,r=/\b__p \+= '';/g,s=/\b(__p \+=) '' \+/g,t=/(__e\(.*?\)|\b__t\)) \+\n'';/g,u=/\w*$/,v=/(?:__e|__t = )\(\s*(?![\d\s"']|this\.)/g,w=RegExp("^"+(j.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),x=/__token__(\d+)/g,y=/[&<>"']/g,z=/['\n\r\t\u2028\u2029\\]/g,A=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],B=0,C="__token__",D=[],E=h.concat,F=j.hasOwnProperty,G=h.push,H=j.propertyIsEnumerable,I=h.slice,J=j.toString,K=w.test(K=I.bind)&&K,L=w.test(L=Array.isArray)&&L,M=a.isFinite,N=w.test(N=Object.keys)&&N,O="[object Arguments]",P="[object Array]",Q="[object Boolean]",R="[object Date]",S="[object Function]",T="[object Number]",U="[object Object]",V="[object RegExp]",W="[object String]",X=a.clearTimeout,Y=a.setTimeout,Z,$,_,ba=!0;(function(){function c(){this.x=1}var a={0:1,length:1},b=[];c.prototype={valueOf:1,y:1};for(var d in new c)b.push(d);for(d in arguments)ba=!d;Z=(b+"").length<4,_=b[0]!="x",$=(b.splice.call(a,0,1),a[0])})(1);var bb=!bO(arguments),bc=I.call("x")[0]!="x",bd="x"[0]+Object("x")[0]!="xx";try{var be=({toString:0}+"",J.call(a.document||0)==U)}catch(bf){}var bg=K&&/\n|Opera/.test(K+J.call(a.opera)),bh=N&&/^.+$|true/.test(N+!!a.attachEvent),bi=!bg;try{var bj=(Function("//@")(),!a.attachEvent)}catch(bf){}var bk={};bk[Q]=bk[R]=bk[S]=bk[T]=bk[U]=bk[V]=!1,bk[O]=bk[P]=bk[W]=!0;var bl={};bl[O]=bl[S]=!1,bl[P]=bl[Q]=bl[R]=bl[T]=bl[U]=bl[V]=bl[W]=!0;var bm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},bn={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'"},bo={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1,unknown:!0},bp={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"};bq.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var bs=ds("<% if (useStrict) { %>'use strict';\n<% } %>var index, value, iteratee = <%= firstArg %>, result<% if (init) { %> = <%= init %><% } %>;\n<%= exit %>;\n<%= top %>;\n<% if (arrayBranch) { %>var length = iteratee.length; index = -1; <% if (objectBranch) { %>\nif (length > -1 && length === length >>> 0) {<% } %> <% if (noCharByIndex) { %>\n if (toString.call(iteratee) == stringClass) {\n iteratee = iteratee.split('')\n } <% } %>\n <%= arrayBranch.beforeLoop %>;\n while (++index < length) {\n value = iteratee[index];\n <%= arrayBranch.inLoop %>\n } <% if (objectBranch) { %>\n}<% } %><% } %><% if (objectBranch) { %> <% if (arrayBranch) { %>\nelse { <% } else if (noArgsEnum) { %>\n var length = iteratee.length; index = -1;\n if (length && isArguments(iteratee)) {\n while (++index < length) {\n value = iteratee[index += ''];\n <%= objectBranch.inLoop %>\n }\n } else { <% } %> <% if (!hasDontEnumBug) { %>\n var skipProto = typeof iteratee == 'function' && \n propertyIsEnumerable.call(iteratee, 'prototype');\n <% } %> <% if (isKeysFast && useHas) { %>\n var ownIndex = -1,\n ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n length = ownProps.length;\n\n <%= objectBranch.beforeLoop %>;\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n <% if (!hasDontEnumBug) { %>if (!(skipProto && index == 'prototype')) {\n <% } %> value = iteratee[index];\n <%= objectBranch.inLoop %>\n <% if (!hasDontEnumBug) { %>}\n<% } %> } <% } else { %>\n <%= objectBranch.beforeLoop %>;\n for (index in iteratee) { <% if (!hasDontEnumBug || useHas) { %>\n if (<% if (!hasDontEnumBug) { %>!(skipProto && index == 'prototype')<% } if (!hasDontEnumBug && useHas) { %> && <% } if (useHas) { %>hasOwnProperty.call(iteratee, index)<% } %>) { <% } %>\n value = iteratee[index];\n <%= objectBranch.inLoop %>;\n <% if (!hasDontEnumBug || useHas) { %>}\n<% } %> } <% } %> <% if (hasDontEnumBug) { %>\n\n var ctor = iteratee.constructor;\n <% for (var k = 0; k < 7; k++) { %>\n index = '<%= shadowed[k] %>';\n if (<% if (shadowed[k] == 'constructor') { %>!(ctor && ctor.prototype === iteratee) && <% } %>hasOwnProperty.call(iteratee, index)) {\n value = iteratee[index];\n <%= objectBranch.inLoop %>\n } <% } %> <% } %> <% if (arrayBranch || noArgsEnum) { %>\n}<% } %><% } %>\n<%= bottom %>;\nreturn result"),bt={args:"collection, callback, thisArg",init:"collection",top:"if (!callback) {\n callback = identity\n}\nelse if (thisArg) {\n callback = iteratorBind(callback, thisArg)\n}",inLoop:"if (callback(value, index, collection) === false) return result"},bu={init:"{}",top:"var prop;\nif (typeof callback != 'function') {\n var valueProp = callback;\n callback = function(value) { return value[valueProp] }\n}\nelse if (thisArg) {\n callback = iteratorBind(callback, thisArg)\n}",inLoop:"prop = callback(value, index, collection);\n(hasOwnProperty.call(result, prop) ? result[prop]++ : result[prop] = 1)"},bv={useHas:!1,args:"object, callback, thisArg",init:"{}",top:"var isFunc = typeof callback == 'function';\nif (!isFunc) {\n var props = concat.apply(ArrayProto, arguments)\n} else if (thisArg) {\n callback = iteratorBind(callback, thisArg)\n}",inLoop:"if (isFunc\n ? !callback(value, index, object)\n : indexOf(props, index) < 0\n) result[index] = value"},bw={init:"true",inLoop:"if (!callback(value, index, collection)) return !result"},bx={useHas:!1,useStrict:!1,args:"object",init:"object",top:"for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",inLoop:"result[index] = value",bottom:" }\n}"},by={init:"[]",inLoop:"callback(value, index, collection) && result.push(value)"},bz={top:"if (thisArg) callback = iteratorBind(callback, thisArg)"},bA={inLoop:{object:bt.inLoop}},bB={init:"",exit:"if (!collection) return []",beforeLoop:{array:"result = Array(length)",object:"result = "+(bh?"Array(length)":"[]")},inLoop:{array:"result[index] = callback(value, index, collection)",object:"result"+(bh?"[ownIndex] = ":".push")+"(callback(value, index, collection))"}};bb&&(bO=function(a){return!!a&&!!F.call(a,"callee")});var bP=L||function(a){return J.call(a)==P};bQ(/x/)&&(bQ=function(a){return J.call(a)==S}),bR(bo)||(bR=function(a,b){var c=!1;if(!a||typeof a!="object"||!b&&bO(a))return c;var d=a.constructor;return(!be||typeof a.toString=="function"||typeof (a+"")!="string")&&(!bQ(d)||d instanceof d)?_?(bX(a,function(b,d){return c=!F.call(a,d),!1}),c===!1):(bX(a,function(a,b){c=b}),c===!1||F.call(a,c)):c});var bS=bD({args:"object",init:"[]",inLoop:"result.push(index)"}),bU=bD(bx,{inLoop:"if (result[index] == null) "+bx.inLoop}),bV=bD(bv),bW=bD(bx),bX=bD(bt,bz,bA,{useHas:!1}),bY=bD(bt,bz,bA),bZ=bD({useHas:!1,args:"object",init:"[]",inLoop:"if (isFunction(value)) result.push(index)",bottom:"result.sort()"}),cc=bD({args:"value",init:"true",top:"var className = toString.call(value),\n length = value.length;\nif (arrayLikeClasses[className]"+(bb?" || isArguments(value)":"")+" ||\n"+" (className == objectClass && length > -1 && length === length >>> 0 &&\n"+" isFunction(value.splice))"+") return !length",inLoop:{object:"return false"}}),cm=N?function(a){var b=typeof a;return b=="function"&&H.call(a,"prototype")?bS(a):a&&bo[b]?N(a):[]}:bS,cn=bD(bx,{args:"object, source, indicator, stack",top:"var destValue, found, isArr, stackLength, recursive = indicator == isPlainObject;\nif (!recursive) stack = [];\nfor (var argsIndex = 1, argsLength = recursive ? 2 : arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",inLoop:"if (value && ((isArr = isArray(value)) || isPlainObject(value))) {\n found = false; stackLength = stack.length;\n while (stackLength--) {\n if (found = stack[stackLength].source == value) break\n }\n if (found) {\n result[index] = stack[stackLength].value\n } else {\n destValue = (destValue = result[index]) && isArr\n ? (isArray(destValue) ? destValue : [])\n : (isPlainObject(destValue) ? destValue : {});\n stack.push({ value: destValue, source: value });\n result[index] = callee(destValue, value, isPlainObject, stack)\n }\n} else if (value != null) {\n result[index] = value\n}"}),co=bD(bv,{top:"if (typeof callback != 'function') {\n var prop,\n props = concat.apply(ArrayProto, arguments),\n length = props.length;\n for (index = 1; index < length; index++) {\n prop = props[index];\n if (prop in object) result[prop] = object[prop]\n }\n} else {\n if (thisArg) callback = iteratorBind(callback, thisArg)",inLoop:"if (callback(value, index, object)) result[index] = value",bottom:"}"}),cq=bD({args:"object",init:"[]",inLoop:"result.push(value)"}),cr=bD({args:"collection, target",init:"false",noCharByIndex:!1,beforeLoop:{array:"if (toString.call(collection) == stringClass) return collection.indexOf(target) > -1"},inLoop:"if (value === target) return true"}),cs=bD(bt,bu),ct=bD(bt,bw),cu=bD(bt,by),cv=bD(bt,bz,{init:"",inLoop:"if (callback(value, index, collection)) return value"}),cw=bD(bt,bz),cx=bD(bt,bu,{inLoop:"prop = callback(value, index, collection);\n(hasOwnProperty.call(result, prop) ? result[prop] : result[prop] = []).push(value)"}),cy=bD(bB,{args:"collection, methodName",top:"var args = slice.call(arguments, 2),\n isFunc = typeof methodName == 'function'",inLoop:{array:"result[index] = (isFunc ? methodName : value[methodName]).apply(value, args)",object:"result"+(bh?"[ownIndex] = ":".push")+"((isFunc ? methodName : value[methodName]).apply(value, args))"}}),cz=bD(bt,bB),cA=bD(bB,{args:"collection, property",inLoop:{array:"result[index] = value[property]",object:"result"+(bh?"[ownIndex] = ":".push")+"(value[property])"}}),cB=bD({args:"collection, callback, accumulator, thisArg",init:"accumulator",top:"var noaccum = arguments.length < 3;\nif (thisArg) callback = iteratorBind(callback, thisArg)",beforeLoop:{array:"if (noaccum) result = iteratee[++index]"},inLoop:{array:"result = callback(result, value, index, collection)",object:"result = noaccum\n ? (noaccum = false, value)\n : callback(result, value, index, collection)"}}),cD=bD(bt,by,{inLoop:"!"+by.inLoop}),cE=bD(bt,bw,{init:"false",inLoop:bw.inLoop.replace("!","")}),cF=bD(bt,bu,bB,{inLoop:{array:"result[index] = {\n criteria: callback(value, index, collection),\n index: index,\n value: value\n}",object:"result"+(bh?"[ownIndex] = ":".push")+"({\n"+" criteria: callback(value, index, collection),\n"+" index: index,\n"+" value: value\n"+"})"},bottom:"result.sort(compareAscending);\nlength = result.length;\nwhile (length--) {\n result[length] = result[length].value\n}"}),cH=bD(by,{args:"collection, properties",top:"var props = [];\nforIn(properties, function(value, prop) { props.push(prop) });\nvar propsLength = props.length",inLoop:"for (var prop, pass = true, propIndex = 0; propIndex < propsLength; propIndex++) {\n prop = props[propIndex];\n if (!(pass = value[prop] === properties[prop])) break\n}\npass && result.push(value)"}),dc=bD({useHas:!1,useStrict:!1,args:"object",init:"object",top:"var funcs = arguments,\n length = funcs.length;\nif (length > 1) {\n for (var index = 1; index < length; index++) {\n result[funcs[index]] = bind(result[funcs[index]], result)\n }\n return result\n}",inLoop:"if (isFunction(result[index])) {\n result[index] = bind(result[index], result)\n}"});bq.VERSION="0.6.1",bq.after=da,bq.bind=db,bq.bindAll=dc,bq.chain=dw,bq.clone=bT,bq.compact=cI,bq.compose=dd,bq.contains=cr,bq.countBy=cs,bq.debounce=de,bq.defaults=bU,bq.defer=dg,bq.delay=df,bq.difference=cJ,bq.drop=bV,bq.escape=dm,bq.every=ct,bq.extend=bW,bq.filter=cu,bq.find=cv,bq.first=cK,bq.flatten=cL,bq.forEach=cw,bq.forIn=bX,bq.forOwn=bY,bq.functions=bZ,bq.groupBy=cx,bq.has=b$,bq.identity=dn,bq.indexOf=cM,bq.initial=cN,bq.intersection=cO,bq.invoke=cy,bq.isArguments=bO,bq.isArray=bP,bq.isBoolean=b_,bq.isDate=ca,bq.isElement=cb,bq.isEmpty=cc,bq.isEqual=cd,bq.isFinite=ce,bq.isFunction=bQ,bq.isNaN=cg,bq.isNull=ch,bq.isNumber=ci,bq.isObject=cf,bq.isRegExp=cj,bq.isString=ck,bq.isUndefined=cl,bq.keys=cm,bq.last=cP,bq.lastIndexOf=cQ,bq.map=cz,bq.max=cR,bq.memoize=dh,bq.merge=cn,bq.min=cS,bq.mixin=dp,bq.noConflict=dq,bq.once=di,bq.partial=dj,bq.pick=co,bq.pluck=cA,bq.range=cT,bq.reduce=cB,bq.reduceRight=cC,bq.reject=cD,bq.rest=cU,bq.result=dr,bq.shuffle=cV,bq.size=cp,bq.some=cE,bq.sortBy=cF,bq.sortedIndex=cW,bq.tap=dx,bq.template=ds,bq.throttle=dk,bq.times=dt,bq.toArray=cG,bq.unescape=du,bq.union=cX,bq.uniq=cY,bq.uniqueId=dv,bq.values=cq,bq.where=cH,bq.without=cZ,bq.wrap=dl,bq.zip=c$,bq.zipObject=c_,bq.all=ct,bq.any=cE,bq.collect=cz,bq.detect=cv,bq.each=cw,bq.foldl=cB,bq.foldr=cC,bq.head=cK,bq.include=cr,bq.inject=cB,bq.methods=bZ,bq.omit=bV,bq.select=cu,bq.tail=cU,bq.take=cK,bq.unique=cY,bq._iteratorTemplate=bs,bq._shimKeys=bS,br.prototype=bq.prototype,dp(bq),br.prototype.chain=dy,br.prototype.value=dz,cw(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=h[a];br.prototype[a]=function(){var a=this._wrapped;return b.apply(a,arguments),$&&a.length===0&&delete a[0],this._chain&&(a=new br(a),a._chain=!0),a}}),cw(["concat","join","slice"],function(a){var b=h[a];br.prototype[a]=function(){var a=this._wrapped,c=b.apply(a,arguments);return this._chain&&(c=new br(c),c._chain=!0),c}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(a._=bq,define(function(){return bq})):g?typeof module=="object"&&module&&module.exports==g?(module.exports=bq)._=bq:g._=bq:a._=bq}(this);var JSON;JSON||(JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));return e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),function(){var a=this.math={};a.mean=a.ave=a.average=function(b,c){return a.sum(b,c)/_(b).size()},a.median=function(b){var c=(b.length+1)/2,d=a.sort(b);return d.length%2?d[c-1]:(d[c-1.5]+d[c-.5])/2},a.pow=function(a,b){if(_.isNumber(a))return Math.pow(a,b);if(_.isArray(a))return _.map(a,function(a){return _.pow(a,b)})},a.scale=function(a,b){var b=b||1,c=_.max(a);return _.map(a,function(a){return a*(b/c)})},a.slope=function(a,b){return(b[1]-a[1])/(b[0]-a[0])},a.sort=function(a){return a.sort(function(a,b){return a-b})},a.stdDeviation=a.sigma=function(a){return Math.sqrt(_(a).variance())},a.sum=function(a,b){if(_.isArray(a)&&typeof a[0]=="number")var c=a;else var b=b||"value",c=_(a).pluck(b);var d=0;for(var e=0,f=c.length;e<f;e++)d+=c[e];return d},a.transpose=function(a){var b=[];return _(a).each(function(a,c){_(a).each(function(a,d){b[d]||(b[d]=[]),b[d][c]=a})}),b},a.variance=function(a){var b=_(a).mean();return _(a).chain().map(function(a){return _(a-b).pow(2)}).mean().value()},_.mixin(a)}(),function(a){function p(a){var b=o[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var b={},c=Array.prototype,d=Object.prototype,e=d.hasOwnProperty,f=d.toString,g=c.forEach,h=c.slice,i=function(a,c,d){var f,h,i;if(!a)return;if(g&&a.forEach===g)a.forEach(c,d);else if(a.length===+a.length){for(h=0,i=a.length;h<i;h++)if(h in a&&c.call(d,a[h],h,a)===b)return}else for(f in a)if(e.call(a,f)&&c.call(d,a[f],f,a)===b)return},j=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},k=function(a){return i(h.call(arguments,1),function(b){var c;for(c in b)b[c]!==void 0&&(a[c]=b[c])}),a},l={"[object Array]":"array","[object Function]":"function"},m=function(a){return a?l[f.call(a)]||"object":String(a)},n={},o={};n.Callbacks=function(a){a=a?o[a]||p(a):{};var b=[],c=[],d,e,f,g,h,i,j=function(c){var d,e,f,g,h;for(d=0,e=c.length;d<e;d++)f=c[d],g=m(f),g==="array"?j(f):g==="function"&&(!a.unique||!l.has(f))&&b.push(f)},k=function(j,k){k=k||[],d=!a.memory||[j,k],e=!0,f=!0,i=g||0,g=0,h=b.length;for(;b&&i<h;i++)if(b[i].apply(j,k)===!1&&a.stopOnFalse){d=!0;break}f=!1,b&&(a.once?d===!0?l.disable():b=[]:c&&c.length&&(d=c.shift(),l.fireWith(d[0],d[1])))},l={add:function(){if(b){var a=b.length;j(arguments),f?h=b.length:d&&d!==!0&&(g=a,k(d[0],d[1]))}return this},remove:function(){if(b){var c=arguments,d=0,e=c.length;for(;d<e;d++)for(var g=0;g<b.length;g++)if(c[d]===b[g]){f&&g<=h&&(h--,g<=i&&i--),b.splice(g--,1);if(a.unique)break}}return this},has:function(a){if(b){var c=0,d=b.length;for(;c<d;c++)if(a===b[c])return!0}return!1},empty:function(){return b=[],this},disable:function(){return b=c=d=undefined,this},disabled:function(){return!b},lock:function(){return c=undefined,(!d||d===!0)&&l.disable(),this},locked:function(){return!c},fireWith:function(b,e){return c&&(f?a.once||c.push([b,e]):(!a.once||!d)&&k(b,e)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!e}};return l},n.Deferred=function(a){var b=n.Callbacks("once memory"),c=n.Callbacks("once memory"),d=n.Callbacks("memory"),e="pending",f={resolve:b,reject:c,notify:d},g={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){return h.done(a).fail(b).progress(c),this},always:function(){return h.done.apply(h,arguments).fail.apply(h,arguments),this},pipe:function(a,b,c){return n.Deferred(function(d){i({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=a[0],e=a[1],f;j(c)?h[b](function(){f=c.apply(this,arguments),f&&j(f.promise)?f.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===h?d:this,[f])}):h[b](d[e])})}).promise()},promise:function(a){if(!a)a=g;else for(var b in g)a[b]=g[b];return a}},h=g.promise({}),k;for(k in f)h[k]=f[k].fire,h[k+"With"]=f[k].fireWith;return h.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(h,h),h},n.when=function(a){function l(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--f||i.resolveWith(i,b)}}function m(a){return function(b){e[a]=arguments.length>1?h.call(arguments,0):b,i.notifyWith(k,e)}}var b=h.call(arguments,0),c=0,d=b.length,e=new Array(d),f=d,g=d,i=d<=1&&a&&j(a.promise)?a:n.Deferred(),k=i.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&j(b[c].promise)?b[c].promise().then(l(c),i.reject,m(c)):--f;f||i.resolveWith(i,b)}else i!==a&&i.resolveWith(i,d?[a]:[]);return k},typeof module!="undefined"&&module.exports?module.exports=n:typeof a._!="undefined"?a._.mixin(n):a._=n}(this),function(a,_){var b=a.Miso||(a.Miso={});b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return _.isNull(a)||typeof a=="undefined"||_.isNaN(a)?null:a},test:function(a){return!0},compare:function(a,b){if(_.isEqual(a,b))return 0;if(a<b)return-1;if(a>b)return 1},numeric:function(a){return a===null||_.isNaN(+a)?null:+a}},string:{name:"string",coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)||a===null?null:_.isNumber(+a)?+a:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a===null||_.isNaN(a)?null:a?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(a){var b=+a;return _.isNull(a)||typeof a=="undefined"||_.isNaN(b)?null:b},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return _.isNaN(a)||a===null?null:a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isNull(a)||typeof a=="undefined"||_.isNaN(a))return null;if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(a)||a===null?null:a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Event=function(a){_.isArray(a)||(a=[a]),this.deltas=a},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a==="_id"}).value()}),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a){return new b.Event(a)}}(this,_),function(a,_){var b=a.Miso||{};b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName._id].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},compute:function(a,b){if(this.func){var c=this.func(a);return typeof b!="undefined"?this.data[b]=c:this.data.push(c),c}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.filter={columns:this._columnFilter(a.filter.columns||undefined),rows:this._rowFilter(a.filter.rows||undefined)},this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c._id];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={_id:c._id,old:this.rowByPosition(f),changed:{}};a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.filter=c.filter||{},_.isFunction(a)?c.filter.rows=a:c.filter=a,c.parent=this,new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push("_id"),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=function(b){return _.indexOf(a,b._id)===-1?!1:!0},b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a==="_id"||a==="_oids"})},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(e.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column '"+e.name+"' with type "+e.type}},this),this._computedColumns&&_.each(this._computedColumns,function(b){var c=b.compute(a);a[b.name]=c});if(_.isUndefined(this.comparator))_.each(this._columns,function(b){b.isComputed()||b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={}),this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=this._rowIdByPosition.length;else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f._id)||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=b})}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={};_.isFunction(a)?b.comparator=a:b=a||b,b.comparator&&(this.comparator=b.comparator);if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var c=this.length,d;if(c===1)return;var e=_.bind(function(a,b){var c=this.rowByPosition(b);_.each(c,function(c,d){var e=this._columnPositionByName[d],f=this._columns[e].data[a];this._columns[e].data.splice(a,1,c),this._columns[e].data.splice(b,1,f)},this)},this),f=_.bind(function(a,b){var c=a,d;while(c*2<=b){d=c*2;var f=this.rowByPosition(c);d+1<b&&this.comparator(this.rowByPosition(d),this.rowByPosition(d+1))<0&&d++;if(this.comparator(f,this.rowByPosition(d))<0)e(c,d),c=d;else return}},this),g=function(a){var b=Math.round((a-2)/2);while(b>=0)f(b,a-1),b--};if(c>2){g(c),d=c-1;while(d>1)e(d,0),d--,f(0,d)}else this.comparator(this.rowByPosition(0),this.rowByPosition(1))>0&&e(0,1);return this.comparator(this.rowByPosition(this.length-2),this.rowByPosition(this.length-1))>0&&e(this.length-1,this.length-2),this.syncable&&b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_){var b=a.Miso;b.Product=b.Product||function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),b.Product.define=function(a){return function(c,d){d=d||{};var e=this._findColumns(c),f=this;d.type=d.type||e[0].type,d.typeOptions=d.typeOptions||e[0].typeOptions;var g=function(){var c=a.call(f,e,d);return b.types[d.type].coerce(c,d.typeOptions)};if(this.syncable){var h=new b.Product({columns:e,func:function(a){a=a||{};var b=this._buildDelta(this.value,g.call(f));this.value=b.changed;if(f.syncable){var c=this._buildEvent(b);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",c)}}});return this.bind("change",h._sync,h),h}return g.call(f)}},_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:b.Product.define(function(a,c){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}),max:b.Product.define(function(a,b){return _.max(_.map(a,function(a){return a._max()}))}),min:b.Product.define(function(a,b){return _.min(_.map(a,function(a){return a._min()}))}),mean:b.Product.define(function(a,c){var d=[];_.each(a,function(a){d.push(a.data)}),d=_.flatten(d);var e=a[0].type;return d=_.map(d,function(a){return b.types[e].numeric(a)}),_.mean(d)})})}(this,_),function(a,_,moment){var b=a.Miso;b.Dataset=function(a){this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],typeof a!="undefined"&&(a=a||{},this._initialize(a))},b.Dataset.prototype=new b.DataView,_.extend(b.Dataset.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var c=[],d=_.keys(a),e,f=this.uniqueAgainst,g=this.column(f),h=[],i=[],j=[];_.each(a[f],function(c,d){var e=g.data.indexOf(b.types[g.type].coerce(c)),f={};_.each(a,function(a,b){f[b]=a[d]});if(e===-1)h.push(f);else{i.push(f);var j=this.rowById(this.column("_id").data[e])._id;this.update(j,f)}},this),h.length>0&&this.add(h)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addComputedColumn:function(a,c,d){if(!_.isUndefined(this.column(a)))throw"There is already a column by this name.";if(typeof b.types[c]=="undefined")throw"The type "+c+" doesn't exist";var e=new b.Column({name:a,type:c,func:_.bind(d,this)});return this._columns.push(e),this._computedColumns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,this.length>0&&this.each(function(a,b){e.compute(a,b)},this),e},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column("_id")))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())}),this.addColumn({name:"_id",type:"number",data:b});if(this._columnPositionByName._id!==0){var c=this._columns[this._columnPositionByName._id],d=this._columnPositionByName._id;this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName._id=0,_.each(this._columnPositionByName,function(a,b){b!=="_id"&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a._id||(a._id=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b._id),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c);this.trigger("remove",e),this.trigger("change",e)}},update:function(a,c,d){var e,f=[],g=_.bind(function(a,d){var g,h;_.isFunction(c)?h=c.apply(this,[a]):h=c,e=_.keys(h),_.each(e,function(a){g=this.column(a);if(g.isComputed())throw"You're trying to update a computed column. Those get computed!";var c=b.types[g.type];if(c)if(c.test(h[g.name],g))_.isUndefined(g.before)||(h[g.name]=g.before(h[g.name])),h[g.name]=c.coerce(h[g.name],g);else throw"incorrect value '"+h[g.name]+"' of type "+b.typeOf(h[g.name],g)+" passed to column '"+g.name+"' with type "+g.type;g.data[d]=h[g.name]},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(b){var c=_.extend({},a,h),e=c[b.name],f=b.compute(c,d);e!==f&&(h[b.name]=f)}),f.push({_id:a._id,old:a,changed:h})},this);_.isString(a)&&(a=[a]);if(_.isArray(a)){var h,i;_.each(a,function(a){h=this.rowById(a),i=this._rowPositionById[a],g(h,i)})}else a=this._rowFilter(a),this.each(function(b,c){a(b)&&g(b,c)},this);if(this.syncable&&(!d||!d.silent)){var j=this._buildEvent(f);this.trigger("update",j),this.trigger("change",j)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso||(a.Miso={});b.Derived=function(a){a=a||{},b.Dataset.call(this),this.parent=a.parent,this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b.Dataset,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column("_id").data=this.parent.column("_id").data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column("_id").data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d._column(a).data,g=d._column("count").data,h=d._column("_oids").data,i=d._column("_id").data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b._id])):(g[c]+=1,h[c].push(b._id))}),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){b.Builder.clearRowCache(this);var d={},e=0,f=this._columnPositionByName[a],g=this.parent.column(a);for(var h=0;h<this.parent.length;h++){var i=null;this.preprocess?i=this.preprocess(g.data[h]):i=g.data[h],_.isUndefined(d[i])&&(d[i]=e,_.each(c,function(a){var b=this.column(a),c=this.column("_id");b.data[e]=[],c.data[e]=_.uniqueId()},this),this.column(a).data[e]=i,e++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[h],e=d[i];b.data[e].push(this.parent.rowByPosition(h))},this)}var j=this._columns[this._columnPositionByName._oids];return j.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,d){_.isArray(c)&&(j.data[d]=j.data[d]||[],j.data[d].push(_.map(c,function(a){return a._id})),j.data[d]=_.flatten(j.data[d]),b.data[d]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return a.ActiveXObject?new a.ActiveXObject("Microsoft.XMLHTTP"):new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null;return a.ajax.onreadystatechange=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},b}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d.charAt(o))&&n++,o++;d=d.slice(o,p)}function q(a){var d=a[1];if(d.length&&d!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var g=null;a[2]?g=a[2].replace(new RegExp('""',"g"),'"'):g=a[3];if(k){g===""&&(g=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(g)}else{var i=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(g)||g==="")g="X";b.indexOf(g)!==-1&&(g=i(g)),b.push(g),c[g]=[]}}(new RegExp("^"+f)).test(d)&&q(["","",undefined,""]);while(i=a.exec(d))q(i)}catch(r){throw new Error("Error while parsing delimited data on row "+m+". Message: "+r.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_)
View
9 dist/miso.ds.deps.ie.min.0.3.0.js
@@ -0,0 +1,9 @@
+/**
+* Miso.Dataset - v0.3.0 - 10/27/2012
+* http://github.com/misoproject/dataset
+* Copyright (c) 2012 Alex Graul, Irene Ros;
+* Dual Licensed: MIT, GPL
+* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
+* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
+*/
+(function(a){function D(a,b,c,d){var e=c.lang();return e[a].call?e[a](c,d):e[a][b]}function E(a,b){return function(c){return J(a.call(this,c),b)}}function F(a){return function(b){var c=a.call(this,b);return c+this.lang().ordinal(c)}}function G(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,this._lang=c||!1}function H(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=I(j/1e3),b.seconds=i%60,h+=I(i/60),b.minutes=h%60,g+=I(h/60),b.hours=g%24,f+=I(g/24),f+=e*7,b.days=f%30,d+=I(f/30),b.months=d%12,c+=I(d/12),b.years=c,this._lang=!1}function I(a){return a<0?Math.ceil(a):Math.floor(a)}function J(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function K(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(1).month(a.month()+f*c).date(Math.min(g,a.daysInMonth())))}function L(a){return Object.prototype.toString.call(a)==="[object Array]"}function M(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function N(a,b,c,d){var e,f,g=[];for(e=0;e<7;e++)g[e]=a[e]=a[e]==null?e===2?1:0:a[e];return a[7]=g[7]=b,a[8]!=null&&(g[8]=a[8]),a[3]+=c||0,a[4]+=d||0,f=new Date(0),b?(f.setUTCFullYear(a[0],a[1],a[2]),f.setUTCHours(a[3],a[4],a[5],a[6])):(f.setFullYear(a[0],a[1],a[2]),f.setHours(a[3],a[4],a[5],a[6])),f._a=g,f}function O(a,b){var c,d,f=[];!b&&g&&(b=require("./lang/"+a));for(c=0;c<h.length;c++)b[h[c]]=b[h[c]]||e.en[h[c]];for(c=0;c<12;c++)d=moment([2e3,c]),f[c]=new RegExp("^"+(b.months[c]||b.months(d,""))+"|^"+(b.monthsShort[c]||b.monthsShort(d,"")).replace(".",""),"i");return b.monthsParse=b.monthsParse||f,e[a]=b,b}function P(a){var b=typeof a=="string"&&a||a&&a._lang||null;return b?e[b]||O(b):moment}function Q(a){return a.match(/\[.*\]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function R(a){var b=a.match(j),c,d;for(c=0,d=b.length;c<d;c++)C[b[c]]?b[c]=C[b[c]]:b[c]=Q(b[c]);return function(e){var f="";for(c=0;c<d;c++)f+=typeof b[c].call=="function"?b[c].call(e,a):b[c];return f}}function S(a,b){function d(b){return a.lang().longDateFormat[b]||b}var c=5;while(c--&&k.test(b))b=b.replace(k,d);return z[b]||(z[b]=R(b)),z[b](a)}function T(a){switch(a){case"DDDD":return o;case"YYYY":return p;case"S":case"SS":case"SSS":case"DDD":return n;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return q;case"Z":case"ZZ":return r;case"T":return s;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return m;default:return new RegExp(a.replace("\\",""))}}function U(a,b,c,d){var e,f;switch(a){case"M":case"MM":c[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(e=0;e<12;e++)if(P().monthsParse[e].test(b)){c[1]=e,f=!0;break}f||(c[8]=!1);break;case"D":case"DD":case"DDD":case"DDDD":b!=null&&(c[2]=~~b);break;case"YY":c[0]=~~b+(~~b>70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(w),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}b==null&&(c[8]=!1)}function V(a,b){var c=[0,0,1,0,0,0,0],d={tzh:0,tzm:0},e=b.match(j),f,g;for(f=0;f<e.length;f++)g=(T(e[f]).exec(a)||[])[0],g&&(a=a.slice(a.indexOf(g)+g.length)),C[e[f]]&&U(e[f],g,c,d);return d.isPm&&c[3]<12&&(c[3]+=12),d.isPm===!1&&c[3]===12&&(c[3]=0),N(c,d.isUTC,d.tzh,d.tzm)}function W(a,b){var c,d=a.match(l)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=V(a,b[g]),e=S(new G(h),b[g]).match(l)||[],i=M(d,e),i<f&&(f=i,c=h);return c}function X(a){var b="YYYY-MM-DDT",c;if(t.exec(a)){for(c=0;c<4;c++)if(v[c][1].exec(a)){b+=v[c][0];break}return r.exec(a)?V(a,b+" Z"):V(a,b)}return new Date(a)}function Y(a,b,c,d,e){var f=e.relativeTime[a];return typeof f=="function"?f(b||1,!!c,a,d):f.replace(/%d/i,b||1)}function Z(a,b,d){var e=c(Math.abs(a)/1e3),f=c(e/60),g=c(f/60),h=c(g/24),i=c(h/365),j=e<45&&["s",e]||f===1&&["m"]||f<45&&["mm",f]||g===1&&["h"]||g<22&&["hh",g]||h===1&&["d"]||h<=25&&["dd",h]||h<=45&&["M"]||h<345&&["MM",c(h/30)]||i===1&&["y"]||["yy",i];return j[2]=b,j[3]=a>0,j[4]=d,Y.apply({},j)}function $(a,b){moment.fn[a]=function(a){var c=this._isUTC?"UTC":"";return a!=null?(this._d["set"+c+b](a),this):this._d["get"+c+b]()}}function _(a){moment.duration.fn[a]=function(){return this._data[a]}}function ba(a,b){moment.duration.fn["as"+a]=function(){return+this/b}}var moment,b="1.7.2",c=Math.round,d,e={},f="en",g=typeof module!="undefined"&&module.exports,h="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),i=/^\/?Date\((\-?\d+)/i,j=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g,k=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?)/g,l=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,m=/\d\d?/,n=/\d{1,3}/,o=/\d{3}/,p=/\d{1,4}/,q=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,r=/Z|[\+\-]\d\d:?\d\d/i,s=/T/i,t=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,u="YYYY-MM-DDTHH:mm:ssZ",v=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],w=/([\+\-]|\d\d)/gi,x="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),y={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},z={},A="DDD w M D d".split(" "),B="M D H h m s w".split(" "),C={M:function(){return this.month()+1},MMM:function(a){return D("monthsShort",this.month(),this,a)},MMMM:function(a){return D("months",this.month(),this,a)},D:function(){return this.date()},DDD:function(){var a=new Date(this.year(),this.month(),this.date()),b=new Date(this.year(),0,1);return~~((a-b)/864e5+1.5)},d:function(){return this.day()},dd:function(a){return D("weekdaysMin",this.day(),this,a)},ddd:function(a){return D("weekdaysShort",this.day(),this,a)},dddd:function(a){return D("weekdays",this.day(),this,a)},w:function(){var a=new Date(this.year(),this.month(),this.date()-this.day()+5),b=new Date(a.getFullYear(),0,4);return~~((a-b)/864e5/7+1.5)},YY:function(){return J(this.year()%100,2)},YYYY:function(){return J(this.year(),4)},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return~~(this.milliseconds()/100)},SS:function(){return J(~~(this.milliseconds()/10),2)},SSS:function(){return J(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+J(~~(a/60),2)+":"+J(~~a%60,2)},ZZ:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+J(~~(10*a/6),4)}};while(A.length)d=A.pop(),C[d+"o"]=F(C[d]);while(B.length)d=B.pop(),C[d+d]=E(C[d],2);C.DDDD=E(C.DDD,3),moment=function(b,c){if(b===null||b==="")return null;var d,e;return moment.isMoment(b)?new G(new Date(+b._d),b._isUTC,b._lang):(c?L(c)?d=W(b,c):d=V(b,c):(e=i.exec(b),d=b===a?new Date:e?new Date(+e[1]):b instanceof Date?b:L(b)?N(b):typeof b=="string"?X(b):new Date(b)),new G(d))},moment.utc=function(a,b){return L(a)?new G(N(a,!0),!0):(typeof a=="string"&&!r.exec(a)&&(a+=" +0000",b&&(b+=" Z")),moment(a,b).utc())},moment.unix=function(a){return moment(a*1e3)},moment.duration=function(a,b){var c=moment.isDuration(a),d=typeof a=="number",e=c?a._data:d?{}:a,f;return d&&(b?e[b]=a:e.milliseconds=a),f=new H(e),c&&(f._lang=a._lang),f},moment.humanizeDuration=function(a,b,c){return moment.duration(a,b===!0?null:b).humanize(b===!0?!0:c)},moment.version=b,moment.defaultFormat=u,moment.lang=function(a,b){var c;if(!a)return f;(b||!e[a])&&O(a,b);if(e[a]){for(c=0;c<h.length;c++)moment[h[c]]=e[a][h[c]];moment.monthsParse=e[a].monthsParse,f=a}},moment.langData=P,moment.isMoment=function(a){return a instanceof G},moment.isDuration=function(a){return a instanceof H},moment.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),moment.fn=G.prototype={clone:function(){return moment(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?this._a[8]!=null?!!this._a[8]:!M(this._a,(this._a[7]?moment.utc(this._a):moment(this._a)).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return S(this,a?a:moment.defaultFormat)},add:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return K(this,c,1),this},subtract:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return K(this,c,-1),this},diff:function(a,b,d){var e=this._isUTC?moment(a).utc():moment(a).local(),f=(this.zone()-e.zone())*6e4,g=this._d-e._d-f,h=this.year()-e.year(),i=this.month()-e.month(),j=this.date()-e.date(),k;return b==="months"?k=h*12+i+j/30:b==="years"?k=h+(i+j/30)/12:k=b==="seconds"?g/1e3:b==="minutes"?g/6e4:b==="hours"?g/36e5:b==="days"?g/864e5:b==="weeks"?g/6048e5:g,d?k:c(k)},from:function(a,b){return moment.duration(this.diff(a)).lang(this._lang).humanize(!b)},fromNow:function(a){return this.from(moment(),a)},calendar:function(){var a=this.diff(moment().sod(),"days",!0),b=this.lang().calendar,c=b.sameElse,d=a<-6?c:a<-1?b.lastWeek:a<0?b.lastDay:a<1?b.sameDay:a<2?b.nextDay:a<7?b.nextWeek:c;return this.format(typeof d=="function"?d.apply(this):d)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<moment([this.year()]).zone()||this.zone()<moment([this.year(),5]).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return a==null?b:this.add({d:a-b})},startOf:function(a){switch(a.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return this},endOf:function(a){return this.startOf(a).add(a.replace(/s?$/,"s"),1).subtract("ms",1)},sod:function(){return this.clone().startOf("day")},eod:function(){return this.clone().endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return moment.utc([this.year(),this.month()+1,0]).date()},lang:function(b){return b===a?P(this):(this._lang=b,this)}};for(d=0;d<x.length;d++)$(x[d].toLowerCase(),x[d]);$("year","FullYear"),moment.duration.fn=H.prototype={weeks:function(){return I(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,c=this.lang().relativeTime,d=Z(b,!a,this.lang()),e=b<=0?c.past:c.future;return a&&(typeof e=="function"?d=e(d):d=e.replace(/%s/i,d)),d},lang:moment.fn.lang};for(d in y)y.hasOwnProperty(d)&&(ba(d,y[d]),_(d.toLowerCase()));ba("Weeks",6048e5),g&&(module.exports=moment),typeof ender=="undefined"&&(this.moment=moment),typeof define=="function"&&define.amd&&define("moment",[],function(){return moment})}).call(this),function(a,b){function bj(a){if(a&&a.__wrapped__)return a;if(this instanceof bj)this.__wrapped__=a;else return new bj(a)}function bo(a,b,c){b||(b=0);var d=a.length,e=d-b>=(c||i),f=e?{}:a;if(e){var g=b-1;while(++g<d){var h=a[g]+"";(B.call(f,h)?f[h]:f[h]=[]).push(a[g])}}return function(a){if(e){var c=a+"";return B.call(f,c)&&cD(f[c],a)>-1}return cD(f,a,b)>-1}}function bp(a,c){var d=a.index,e=c.index;a=a.criteria,c=c.criteria;if(a!==c){if(a>c||a===b)return 1;if(a<c||c===b)return-1}return d<e?-1:1}function bq(a,b,c){function g(){var h=arguments,i=e?this:b;d||(a=b[f]),c.length&&(h=h.length?c.concat(E.call(h)):c);if(this instanceof g){bv.prototype=a.prototype,i=new bv;var j=a.apply(i,h);return j&&bh[typeof j]?j:i}return a.apply(i,h)}var d=bR(a),e=!c,f=a;return e&&(c=b),g}function br(a,c){return a?typeof a!="function"?function(b){return b[a]}:c!==b?function(b,d,e){return a.call(c,b,d,e)}:a:dc}function bs(){var a={arrayLoop:"",bottom:"",hasDontEnumBug:W,isKeysFast:be,objectLoop:"",noArgsEnum:Z,noCharByIndex:ba,shadowed:v,top:"",useHas:!0};for(var b,c=0;b=arguments[c];c++)for(var d in b)a[d]=b[d];var e=a.args;a.firstArg=/^[^,]+/.exec(e)[0];var f=Function("createCallback, hasOwnProperty, isArguments, objectTypes, nativeKeys, propertyIsEnumerable, stringClass, toString","return function("+e+") {\n"+bk(a)+"\n}");return f(br,B,bx,bh,J,D,V,F)}function bt(a){return"\\"+bi[a]}function bu(a){return bC[a]}function bv(){}function bw(a){return bD[a]}function bx(a){return F.call(a)==N}function bA(a){var b=!1;if(!a||typeof a!="object"||bx(a))return b;var c=a.constructor;return(!bb||typeof a.toString=="function"||typeof (a+"")!="string")&&(!bR(c)||c instanceof c)?X?(by(a,function(a,c,d){return b=!B.call(d,c),!1}),b===!1):(by(a,function(a,c){b=c}),b===!1||B.call(a,b)):b}function bB(a){var b=[];return bz(a,function(a,c){b.push(c)}),b}function bE(a,b,c,d,e){if(a==null)return a;c&&(b=!1);var f=bh[typeof a];if(f){var g=F.call(a);if(!bg[g]||$&&bx(a))return a;var h=g==O;f=h||(g==T?bW(a):f)}if(!f||!b)return f?h?E.call(a):bG({},a):a;var i=a.constructor;switch(g){case P:case Q:return new i(+a);case S:case V:return new i(a);case U:return i(a.source,p.exec(a))}d||(d=[]),e||(e=[]);var j=d.length;while(j--)if(d[j]==a)return e[j];var k=h?i(a.length):{};return d.push(a),e.push(k),(h?cj:bz)(a,function(a,c){k[c]=bE(a,b,null,d,e)}),k}function bH(a){var b=[];return by(a,function(a,c){bR(a)&&b.push(c)}),b.sort()}function bI(a,b){return a?B.call(a,b):!1}function bJ(a){var b={};return bz(a,function(a,c){b[a]=c}),b}function bL(a){return a===!0||a===!1||F.call(a)==P}function bM(a){return F.call(a)==Q}function bN(a){return a?a.nodeType===1:!1}function bO(a){var b=!0;if(!a)return b;var c=F.call(a),d=a.length;return c==O||c==V||c==N||$&&bx(a)||c==T&&typeof d=="number"&&bR(a.splice)?!d:(bz(a,function(){return b=!1}),b)}function bP(a,b,c,d){if(a===b)return a!==0||1/a==1/b;if(a==null||b==null)return a===b;var e=F.call(a);if(e!=F.call(b))return!1;switch(e){case P:case Q:return+a==+b;case S:return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case U:case V:return a==b+""}var f=e==O||e==N;if($&&!f&&(f=bx(a))&&!bx(b))return!1;if(!f){if(a.__wrapped__||b.__wrapped__)return bP(a.__wrapped__||a,b.__wrapped__||b);if(e!=T||bb&&(typeof a.toString!="function"&&typeof (a+"")=="string"||typeof b.toString!="function"&&typeof (b+"")=="string"))return!1;var g=a.constructor,h=b.constructor;if(g!=h&&!(bR(g)&&g instanceof g&&bR(h)&&h instanceof h))return!1}c||(c=[]),d||(d=[]);var i=c.length;while(i--)if(c[i]==a)return d[i]==b;var j=-1,k=!0,l=0;c.push(a),d.push(b);if(f){l=a.length,k=l==b.length;if(k)while(l--)if(!(k=bP(a[l],b[l],c,d)))break;return k}for(var m in a)if(B.call(a,m)){l++;if(!B.call(b,m)||!bP(a[m],b[m],c,d))return!1}for(m in b)if(B.call(b,m)&&!(l--))return!1;if(W)while(++j<7){m=v[j];if(B.call(a,m)&&(!B.call(b,m)||!bP(a[m],b[m],c,d)))return!1}return!0}function bQ(a){return I(a?+a:parseFloat(a))}function bR(a){return typeof a=="function"}function bS(a){return a?bh[typeof a]:!1}function bT(a){return F.call(a)==S&&a!=+a}function bU(a){return a===null}function bV(a){return F.call(a)==S}function bX(a){return F.call(a)==U}function bY(a){return F.call(a)==V}function bZ(a){return a===b}function b_(a,b,c){var d=arguments,e=0,f=2,g=d[3],i=d[4];c!==h&&(g=[],i=[],f=d.length);while(++e<f)bz(d[e],function(b,c){var d,e,f;if(b&&((e=bK(b))||bW(b))){var j=g.length;while(j--){d=g[j]==b;if(d)break}d?a[c]=i[j]:(g.push(b),i.push(f=(f=a[c],e)?bK(f)?f:[]:bW(f)?f:{}),a[c]=b_(f,b,h,g,i))}else b!=null&&(a[c]=b)});return a}function ca(a,b,c){var d=typeof b=="function",f={};if(d)b=br(b,c);else var g=y.apply(e,arguments);return by(a,function(a,c,e){if(d?!b(a,c,e):cD(g,c,1)<0)f[c]=a}),f}function cb(a){var b=[];return bz(a,function(a,c){b.push([c,a])}),b}function cc(a,b,c){var d={};if(typeof b!="function"){var f=0,g=y.apply(e,arguments),h=g.length;while(++f<h){var i=g[f];i in a&&(d[i]=a[i])}}else b=br(b,c),by(a,function(a,c,e){b(a,c,e)&&(d[c]=a)});return d}function cd(a){var b=[];return bz(a,function(a){b.push(a)}),b}function ce(a,b){var c=a?a.length:0;return typeof c=="number"?(F.call(a)==V?a.indexOf(b):cD(a,b))>-1:cv(a,function(a){return a===b})}function cf(a,b,c){var d={};return b=br(b,c),cj(a,function(a,c,e){c=b(a,c,e),B.call(d,c)?d[c]++:d[c]=1}),d}function cg(a,b,c){var d=!0;return b=br(b,c),cj(a,function(a,c,e){return d=b(a,c,e)}),!!d}function ch(a,b,c){var d=[];return b=br(b,c),cj(a,function(a,c,e){b(a,c,e)&&d.push(a)}),d}function ci(a,b,c){var d;return b=br(b,c),cv(a,function(a,c,e){return b(a,c,e)&&(d=a,!0)}),d}function ck(a,b,c){var d={};return b=br(b,c),cj(a,function(a,c,e){c=b(a,c,e),(B.call(d,c)?d[c]:d[c]=[]).push(a)}),d}function cl(a,b){var c=E.call(arguments,2),d=typeof b=="function",e=[];return cj(a,function(a){e.push((d?b:a[b]).apply(a,c))}),e}function cm(a,b,c){var d=-1,e=a?a.length:0,f=Array(typeof e=="number"?e:0);b=br(b,c);if(bK(a))while(++d<e)f[d]=b(a[d],d,a);else cj(a,function(a,c,e){f[++d]=b(a,c,e)});return f}function cn(a,b,c){var d=-Infinity,e=-1,f=a?a.length:0,g=d;if(b||typeof f!="number")b=br(b,c),cj(a,function(a,c,e){var f=b(a,c,e);f>d&&(d=f,g=a)});else while(++e<f)a[e]>g&&(g=a[e]);return g}function co(a,b,c){var d=Infinity,e=-1,f=a?a.length:0,g=d;if(b||typeof f!="number")b=br(b,c),cj(a,function(a,c,e){var f=b(a,c,e);f<d&&(d=f,g=a)});else while(++e<f)a[e]<g&&(g=a[e]);return g}function cp(a,b){var c=[];return cj(a,function(a){c.push(a[b])}),c}function cq(a,b,c,d){var e=arguments.length<3;return b=br(b,d),cj(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)}),c}function cr(a,b,c,d){var e=a,f=a?a.length:0,g=arguments.length<3;if(typeof f!="number"){var h=b$(a);f=h.length}else ba&&F.call(a)==V&&(e=a.split(""));return cj(a,function(a,i,j){i=h?h[--f]:--f,c=g?(g=!1,e[i]):b.call(d,c,e[i],i,j)}),c}function cs(a,b,c){return b=br(b,c),ch(a,function(a,c,d){return!b(a,c,d)})}function ct(a){var b=-1,c=Array(a?a.length:0);return cj(a,function(a){var d=z(M()*(++b+1));c[b]=c[d],c[d]=a}),c}function cu(a){var b=a?a.length:0;return typeof b=="number"?b:b$(a).length}function cv(a,b,c){var d;return b=br(b,c),cj(a,function(a,c,e){return!(d=b(a,c,e))}),!!d}function cw(a,b,c){var d=[];b=br(b,c),cj(a,function(a,c,e){d.push({criteria:b(a,c,e),index:c,value:a})});var e=d.length;d.sort(bp);while(e--)d[e]=d[e].value;return d}function cx(a){return a&&typeof a.length=="number"?(_?F.call(a)==V:typeof a=="string")?a.split(""):E.call(a):cd(a)}function cy(a,b){var c=[];return by(b,function(a,b){c.push(b)}),ch(a,function(a){var d=c.length;while(d--){var e=a[c[d]]===b[c[d]];if(!e)break}return!!e})}function cz(a){var b=-1,c=a?a.length:0,d=[];while(++b<c){var e=a[b];e&&d.push(e)}return d}function cA(a){var b=-1,c=a?a.length:0,d=y.apply(e,arguments),f=bo(d,c),g=[];while(++b<c){var h=a[b];f(h)||g.push(h)}return g}function cB(a,b,c){if(a)return b==null||c?a[0]:E.call(a,0,b)}function cC(a,b){var c=-1,d=a?a.length:0,e=[];while(++c<d){var f=a[c];bK(f)?C.apply(e,b?f:cC(f)):e.push(f)}return e}function cD(a,b,c){var d=-1,e=a?a.length:0;if(typeof c=="number")d=(c<0?K(0,e+c):c||0)-1;else if(c)return d=cL(a,b),a[d]===b?d:-1;while(++d<e)if(a[d]===b)return d;return-1}function cE(a,b,c){return a?E.call(a,0,-(b==null||c?1:b)):[]}function cF(a){var b=arguments,c=b.length,d={},e=[];return cj(a,function(a){if(cD(e,a)<0){var f=c;while(--f)if(!(d[f]||(d[f]=bo(b[f])))(a))return;e.push(a)}}),e}function cG(a,b,c){if(a){var d=a.length;return b==null||c?a[d-1]:E.call(a,-b||d)}}function cH(a,b,c){var d=a?a.length:0;typeof c=="number"&&(d=(c<0?K(0,d+c):L(c,d-1))+1);while(d--)if(a[d]===b)return d;return-1}function cI(a,b){var c=-1,d=a?a.length:0,e={};while(++c<d){var f=a[c];b?e[f]=b[c]:e[f[0]]=f[1]}return e}function cJ(a,b,c){a=+a||0,c=+c||1,b==null&&(b=a,a=0);var d=-1,e=K(0,x((b-a)/c)),f=Array(e);while(++d<e)f[d]=a,a+=c;return f}function cK(a,b,c){return a?E.call(a,b==null||c?1:b):[]}function cL(a,b,c,d){var e=0,f=a?a.length:e;c=c?br(c,d):dc,b=c(b);while(e<f){var g=e+f>>>1;c(a[g])<b?e=g+1:f=g}return e}function cM(){var a=-1,b=y.apply(e,arguments),c=b.length,d=[];while(++a<c){var f=b[a];cD(d,f)<0&&d.push(f)}return d}function cN(a,b,c,d){var e=-1,f=a?a.length:0,g=[],h=[];typeof b=="function"&&(d=c,c=b,b=!1),c=br(c,d);while(++e<f){var i=c(a[e],e,a);if(b?!e||h[h.length-1]!==i:cD(h,i)<0)h.push(i),g.push(a[e])}return g}function cO(a){var b=-1,c=a?a.length:0,d=bo(arguments,1,20),e=[];while(++b<c){var f=a[b];d(f)||e.push(f)}return e}function cP(a){var b=-1,c=a?cn(cp(arguments,"length")):0,d=Array(c);while(++b<c)d[b]=cp(arguments,b);return d}function cQ(a,b){return a<1?b():function(){if(--a<1)return b.apply(this,arguments)}}function cR(a,b){return bd||G&&arguments.length>2?G.call.apply(G,arguments):bq(a,b,E.call(arguments,2))}function cS(a){var b=arguments,c=b.length>1?0:(b=bH(a),-1),d=b.length;while(++c<d){var e=b[c];a[e]=cR(a[e],a)}return a}function cT(){var a=arguments;return function(){var b=arguments,c=a.length;while(c--)b=[a[c].apply(this,b)];return b[0]}}function cU(a,b,c){function h(){g=null,c||(e=a.apply(f,d))}var d,e,f,g;return function(){var i=c&&!g;return d=arguments,f=this,clearTimeout(g),g=setTimeout(h,b),i&&(e=a.apply(f,d)),e}}function cV(a,c){var d=E.call(arguments,2);return setTimeout(function(){a.apply(b,d)},c)}function cW(a){var c=E.call(arguments,1);return setTimeout(function(){a.apply(b,c)},1)}function cX(a,b){return bq(b,a,E.call(arguments,2))}function cY(a,b){var c={};return function(){var d=b?b.apply(this,arguments):arguments[0];return B.call(c,d)?c[d]:c[d]=a.apply(this,arguments)}}function cZ(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}}function c$(a){return bq(a,E.call(arguments,1))}function c_(a,b){function h(){g=new Date,f=null,d=a.apply(e,c)}var c,d,e,f,g=0;return function(){var i=new Date,j=b-(i-g);return c=arguments,e=this,j<=0?(clearTimeout(f),g=i,d=a.apply(e,c)):f||(f=setTimeout(h,j)),d}}function da(a,b){return function(){var c=[a];return C.apply(c,arguments),b.apply(this,c)}}function db(a){return a==null?"":(a+"").replace(t,bu)}function dc(a){return a}function dd(a){cj(bH(a),function(b){var c=bj[b]=a[b];bj.prototype[b]=function(){var a=[this.__wrapped__];C.apply(a,arguments);var b=c.apply(bj,a);return this.__chain__&&(b=new bj(b),b.__chain__=!0),b}})}function de(){return a._=j,this}function df(a,b){return a==null&&b==null&&(b=1),a=+a||0,b==null&&(b=a,a=0),a+z(M()*((+b||0)-a+1))}function dg(a,b){var c=a?a[b]:null;return bR(c)?a[b]():c}function dh(a,b,c){a||(a=""),c||(c={});var d,e,f=0,g=bj.templateSettings,h="__p += '",i=c.variable||g.variable,j=i,l=RegExp((c.escape||g.escape||s).source+"|"+(c.interpolate||g.interpolate||s).source+"|"+(c.evaluate||g.evaluate||s).source+"|$","g");a.replace(l,function(b,c,e,g,i){h+=a.slice(f,i).replace(u,bt),h+=c?"' +\n__e("+c+") +\n'":g?"';\n"+g+";\n__p += '":e?"' +\n((__t = ("+e+")) == null ? '' : __t) +\n'":"",d||(d=g||k.test(c||e)),f=i+b.length}),h+="';\n";if(!j){i="obj";if(d)h="with ("+i+") {\n"+h+"\n}\n";else{var p=RegExp("(\\(\\s*)"+i+"\\."+i+"\\b","g");h=h.replace(q,"$&"+i+".").replace(p,"$1__d")}}h=(d?h.replace(m,""):h).replace(n,"$1").replace(o,"$1;"),h="function("+i+") {\n"+(j?"":i+" || ("+i+" = {});\n")+"var __t, __p = '', __e = _.escape"+(d?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":(j?"":", __d = "+i+"."+i+" || "+i)+";\n")+h+"return __p\n}";var r=bf?"\n//@ sourceURL="+(c.sourceURL||"/lodash/template/source["+w++ +"]"):"";try{e=Function("_","return "+h+r)(bj)}catch(t){throw t.source=h,t}return b?e(b):(e.source=h,e)}function di(a,b,c){a=+a||0;var d=-1,e=Array(a);while(++d<a)e[d]=b.call(c,d);return e}function dj(a){return a==null?"":(a+"").replace(l,bw)}function dk(a){var b=g++;return a?a+b:b}function dl(a){return a=new bj(a),a.__chain__=!0,a}function dm(a,b){return b(a),a}function dn(){return this.__chain__=!0,this}function dp(){return this.__wrapped__}var c=typeof exports=="object"&&exports,d=typeof global=="object"&&global;d.global===d&&(a=d);var e=[],f={},g=0,h={},i=30,j=a._,k=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,l=/&(?:amp|lt|gt|quot|#x27);/g,m=/\b__p \+= '';/g,n=/\b(__p \+=) '' \+/g,o=/(__e\(.*?\)|\b__t\)) \+\n'';/g,p=/\w*$/,q=/(?:__e|__t = )\(\s*(?![\d\s"']|this\.)/g,r=RegExp("^"+(f.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),s=/($^)/,t=/[&<>"']/g,u=/['\n\r\t\u2028\u2029\\]/g,v=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],w=0,x=Math.ceil,y=e.concat,z=Math.floor,A=r.test(A=Object.getPrototypeOf)&&A,B=f.hasOwnProperty,C=e.push,D=f.propertyIsEnumerable,E=e.slice,F=f.toString,G=r.test(G=E.bind)&&G,H=r.test(H=Array.isArray)&&H,I=a.isFinite,J=r.test(J=Object.keys)&&J,K=Math.max,L=Math.min,M=Math.random,N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Function]",S="[object Number]",T="[object Object]",U="[object RegExp]",V="[object String]",W,X,Y=(Y={0:1,length:1},e.splice.call(Y,0,1),Y[0]),Z=!0;(function(){function b(){this.x=1}var a=[];b.prototype={valueOf:1,y:1};for(var c in new b)a.push(c);for(c in arguments)Z=!c;W=!/valueOf/.test(a),X=a[0]!="x"})(1);var $=!bx(arguments),_=E.call("x")[0]!="x",ba="x"[0]+Object("x")[0]!="xx";try{var bb=({toString:0}+"",F.call(a.document||0)==T)}catch(bc){}var bd=G&&/\n|Opera/.test(G+F.call(a.opera)),be=J&&/^.+$|true/.test(J+!!a.attachEvent);try{var bf=(Function("//@")(),!a.attachEvent)}catch(bc){}var bg={};bg[N]=bg[R]=!1,bg[O]=bg[P]=bg[Q]=bg[S]=bg[T]=bg[U]=bg[V]=!0;var bh={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},bi={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"};bj.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var bk=dh("<% if (obj.useStrict) { %>'use strict';\n<% } %>var index, value, iteratee = <%= firstArg %>, result = <%= firstArg %>;\nif (!<%= firstArg %>) return result;\n<%= top %>;\n<% if (arrayLoop) { %>var length = iteratee.length; index = -1;\nif (typeof length == 'number') { <% if (noCharByIndex) { %>\n if (toString.call(iteratee) == stringClass) {\n iteratee = iteratee.split('')\n } <% } %>\n while (++index < length) {\n value = iteratee[index];\n <%= arrayLoop %>\n }\n}\nelse { <% } else if (noArgsEnum) { %>\n var length = iteratee.length; index = -1;\n if (length && isArguments(iteratee)) {\n while (++index < length) {\n value = iteratee[index += ''];\n <%= objectLoop %>\n }\n } else { <% } %> <% if (!hasDontEnumBug) { %>\n var skipProto = typeof iteratee == 'function' && \n propertyIsEnumerable.call(iteratee, 'prototype');\n <% } %> <% if (isKeysFast && useHas) { %>\n var ownIndex = -1,\n ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n <% if (!hasDontEnumBug) { %>if (!(skipProto && index == 'prototype')) {\n <% } %> value = iteratee[index];\n <%= objectLoop %>\n <% if (!hasDontEnumBug) { %>}\n<% } %> } <% } else { %>\n for (index in iteratee) {<% if (!hasDontEnumBug || useHas) { %>\n if (<% if (!hasDontEnumBug) { %>!(skipProto && index == 'prototype')<% } if (!hasDontEnumBug && useHas) { %> && <% } if (useHas) { %>hasOwnProperty.call(iteratee, index)<% } %>) { <% } %>\n value = iteratee[index];\n <%= objectLoop %>; <% if (!hasDontEnumBug || useHas) { %>\n }<% } %>\n } <% } %> <% if (hasDontEnumBug) { %>\n\n var ctor = iteratee.constructor;\n <% for (var k = 0; k < 7; k++) { %>\n index = '<%= shadowed[k] %>';\n if (<% if (shadowed[k] == 'constructor') { %>!(ctor && ctor.prototype === iteratee) && <% } %>hasOwnProperty.call(iteratee, index)) {\n value = iteratee[index];\n <%= objectLoop %>\n } <% } %> <% } %> <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n<%= bottom %>;\nreturn result"),bl={args:"collection, callback, thisArg",top:"callback = createCallback(callback, thisArg)",arrayLoop:"if (callback(value, index, collection) === false) return result",objectLoop:"if (callback(value, index, collection) === false) return result"},bm={useHas:!1,args:"object",top:"for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",objectLoop:"result[index] = value",bottom:" }\n}"},bn={arrayLoop:null};$&&(bx=function(a){return a?B.call(a,"callee"):!1});var by=bs(bl,bn,{useHas:!1}),bz=bs(bl,bn),bC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},bD=bJ(bC),bF=bs(bm,{objectLoop:"if (result[index] == null) "+bm.objectLoop}),bG=bs(bm),bK=H||function(a){return F.call(a)==O};bR(/x/)&&(bR=function(a){return F.call(a)==R});var bW=A?function(a){if(!a||typeof a!="object")return!1;var b=a.valueOf,c=typeof b=="function"&&(c=A(b))&&A(c);return c?a==c||A(a)==c&&!bx(a):bA(a)}:bA,b$=J?function(a){var b=typeof a;return b=="function"&&D.call(a,"prototype")?bB(a):a&&bh[b]?J(a):[]}:bB,cj=bs(bl);bj.VERSION="0.9.0",bj.after=cQ,bj.bind=cR,bj.bindAll=cS,bj.chain=dl,bj.clone=bE,bj.compact=cz,bj.compose=cT,bj.contains=ce,bj.countBy=cf,bj.debounce=cU,bj.defaults=bF,bj.defer=cW,bj.delay=cV,bj.difference=cA,bj.escape=db,bj.every=cg,bj.extend=bG,bj.filter=ch,bj.find=ci,bj.first=cB,bj.flatten=cC,bj.forEach=cj,bj.forIn=by,bj.forOwn=bz,bj.functions=bH,bj.groupBy=ck,bj.has=bI,bj.identity=dc,bj.indexOf=cD,bj.initial=cE,bj.intersection=cF,bj.invert=bJ,bj.invoke=cl,bj.isArguments=bx,bj.isArray=bK,bj.isBoolean=bL,bj.isDate=bM,bj.isElement=bN,bj.isEmpty=bO,bj.isEqual=bP,bj.isFinite=bQ,bj.isFunction=bR,bj.isNaN=bT,bj.isNull=bU,bj.isNumber=bV,bj.isObject=bS,bj.isPlainObject=bW,bj.isRegExp=bX,bj.isString=bY,bj.isUndefined=bZ,bj.keys=b$,bj.last=cG,bj.lastIndexOf=cH,bj.lateBind=cX,bj.map=cm,bj.max=cn,bj.memoize=cY,bj.merge=b_,bj.min=co,bj.mixin=dd,bj.noConflict=de,bj.object=cI,bj.omit=ca,bj.once=cZ,bj.pairs=cb,bj.partial=c$,bj.pick=cc,bj.pluck=cp,bj.random=df,bj.range=cJ,bj.reduce=cq,bj.reduceRight=cr,bj.reject=cs,bj.rest=cK,bj.result=dg,bj.shuffle=ct,bj.size=cu,bj.some=cv,bj.sortBy=cw,bj.sortedIndex=cL,bj.tap=dm,bj.template=dh,bj.throttle=c_,bj.times=di,bj.toArray=cx,bj.unescape=dj,bj.union=cM,bj.uniq=cN,bj.uniqueId=dk,bj.values=cd,bj.where=cy,bj.without=cO,bj.wrap=da,bj.zip=cP,bj.all=cg,bj.any=cv,bj.collect=cm,bj.detect=ci,bj.drop=cK,bj.each=cj,bj.foldl=cq,bj.foldr=cr,bj.head=cB,bj.include=ce,bj.inject=cq,bj.methods=bH,bj.select=ch,bj.tail=cK,bj.take=cB,bj.unique=cN,bj._iteratorTemplate=bk,dd(bj),bj.prototype.chain=dn,bj.prototype.value=dp,cj(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=e[a];bj.prototype[a]=function(){var a=this.__wrapped__;return b.apply(a,arguments),Y&&a.length===0&&delete a[0],this.__chain__&&(a=new bj(a),a.__chain__=!0),a}}),cj(["concat","join","slice"],function(a){var b=e[a];bj.prototype[a]=function(){var a=this.__wrapped__,c=b.apply(a,arguments);return this.__chain__&&(c=new bj(c),c.__chain__=!0),c}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(a._=bj,define(function(){return bj})):c?typeof module=="object"&&module&&module.exports==c?(module.exports=bj)._=bj:c._=bj:a._=bj}(this);var JSON;JSON||(JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));return e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),function(){var a=this.math={};a.mean=a.ave=a.average=function(b,c){return a.sum(b,c)/_(b).size()},a.median=function(b){var c=(b.length+1)/2,d=a.sort(b);return d.length%2?d[c-1]:(d[c-1.5]+d[c-.5])/2},a.pow=function(a,b){if(_.isNumber(a))return Math.pow(a,b);if(_.isArray(a))return _.map(a,function(a){return _.pow(a,b)})},a.scale=function(a,b){var b=b||1,c=_.max(a);return _.map(a,function(a){return a*(b/c)})},a.slope=function(a,b){return(b[1]-a[1])/(b[0]-a[0])},a.sort=function(a){return a.sort(function(a,b){return a-b})},a.stdDeviation=a.sigma=function(a){return Math.sqrt(_(a).variance())},a.sum=function(a,b){if(_.isArray(a)&&typeof a[0]=="number")var c=a;else var b=b||"value",c=_(a).pluck(b);var d=0;for(var e=0,f=c.length;e<f;e++)d+=c[e];return d},a.transpose=function(a){var b=[];return _(a).each(function(a,c){_(a).each(function(a,d){b[d]||(b[d]=[]),b[d][c]=a})}),b},a.variance=function(a){var b=_(a).mean();return _(a).chain().map(function(a){return _(a-b).pow(2)}).mean().value()},_.mixin(a)}(),function(a){function r(a){var b=q[a]={};return j(a.split(/\s+/),function(a){b[a]=!0}),b}var b={},c=Array.prototype,d=Object.prototype,e=d.hasOwnProperty,f=d.toString,g=c.forEach,h=c.indexOf,i=c.slice,j=function(a,c,d){var f,h,i;if(!a)return;if(g&&a.forEach===g)a.forEach(c,d);else if(a.length===+a.length){for(h=0,i=a.length;h<i;h++)if(h in a&&c.call(d,a[h],h,a)===b)return}else for(f in a)if(e.call(a,f)&&c.call(d,a[f],f,a)===b)return},k=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},l=function(a){return j(i.call(arguments,1),function(b){var c;for(c in b)b[c]!==void 0&&(a[c]=b[c])}),a},m=function(a,b,c){var d;if(b){if(h)return h.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},n={};j("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){n["[object "+a+"]"]=a.toLowerCase()});var o=function(a){return a==null?String(a):n[f.call(a)]||"object"},p={},q={};p.Callbacks=function(a){a=typeof a=="string"?q[a]||r(a):l({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],k=function(j){b=a.memory&&j,c=!0,g=e||0,e=0,f=h.length,d=!0;for(;h&&g<f;g++)if(h[g].apply(j[0],j[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&k(i.shift()):b?h=[]:n.disable())},n={add:function(){if(h){var c=h.length;(function g(b){j(b,function(b){var c=o(b);c==="function"&&(!a.unique||!n.has(b))?h.push(b):b&&b.length&&c!=="string"&&g(b)})})(arguments),d?f=h.length:b&&(e=c,k(b))}return this},remove:function(){return h&&j(arguments,function(a){var b;while((b=m(a,h,b))>-1)h.splice(b,1),d&&(b<=f&&f--,b<=g&&g--)}),this},has:function(a){return m(a,h)>-1},empty:function(){return h=[],this},disable:function(){return h=i=b=undefined,this},disabled:function(){return!h},lock:function(){return i=undefined,b||n.disable(),this},locked:function(){return!i},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],h&&(!c||i)&&(d?i.push(b):k(b)),this},fire:function(){return n.fireWith(this,arguments),this},fired:function(){return!!c}};return n},p.Deferred=function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){j(b,function(b,d){var f=b[0],g=a[d];e[b[1]](k(g)?function(){var a=g.apply(this,arguments);a&&k(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return typeof a=="object"?l(a,d):d}},e={};return d.pipe=d.then,j(b,function(a,f){var g=a[2],h=a[3];d[a[1]]=g.add,h&&g.add(function(){c=h},b[f^1][2].disable,b[2][2].lock),e[a[0]]=g.fire,e[a[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},p.when=function(a){var b=0,c=i.call(arguments),d=c.length,e=d!==1||a&&k(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?i.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,j,l;if(d>1){h=new Array(d),j=new Array(d),l=new Array(d);for(;b<d;b++)c[b]&&k(c[b].promise)?c[b].promise().done(g(b,l,c)).fail(f.reject).progress(g(b,j,h)):--e}return e||f.resolveWith(l,c),f.promise()},typeof module!="undefined"&&module.exports?module.exports=p:typeof a._!="undefined"?a._.mixin(p):a._=p}(this),function(a){a.Miso=a.Miso||{},a.Miso.Dataset=function(a){a=a||{},this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],this._initialize(a)}}(this),function(a,_){var b=a.Miso.Dataset;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},compute:function(a,b){if(this.func){var c=this.func(a);return typeof b!="undefined"?this.data[b]=c:this.data.push(c),c}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=this.parent.idAttribute,this.filter={},this.filter.columns=_.bind(this._columnFilter(a.filter.columns||undefined),this),this.filter.rows=_.bind(this._rowFilter(a.filter.rows||undefined),this),this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c[this.idAttribute]];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={old:this.rowByPosition(f),changed:{}};h[this.idAttribute]=c[this.idAttribute],a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.filter=c.filter||{},_.isFunction(a)?c.filter.rows=a:c.filter=a,c.parent=this,new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push(this.idAttribute),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=_.bind(function(b){return _.indexOf(a,b[this.idAttribute])===-1?!1:!0},this),b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a===this.idAttribute||a==="_oids"},this)},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(e.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column '"+e.name+"' with type "+e.type}},this),this._computedColumns&&_.each(this._computedColumns,function(b){var c=b.compute(a);a[b.name]=c});if(_.isUndefined(this.comparator)){_.each(this._columns,function(b){b.isComputed()||b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={});if(typeof this._rowPositionById[a[this.idAttribute]]!="undefined")throw"The id "+a[this.idAttribute]+" is not unique. The "+this.idAttribute+" column must be unique";this._rowPositionById[a[this.idAttribute]]=this._rowIdByPosition.length,this._rowIdByPosition.push(a[this.idAttribute])}else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f[this.idAttribute])||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a[this.idAttribute]),this._rowPositionById[a[this.idAttribute]]=b},this)}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={},c=[];_.isFunction(a)?b.comparator=a:b=a||{};if(b.comparator)this.comparator=b.comparator;else if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var d,e,f;for(d=0;d<this.length;d++)c[d]=this._row(d);c.sort(this.comparator),d=c.length;while(d--){f=c[d],this._rowIdByPosition[d]=f[this.idAttribute],this._rowPositionById[f[this.idAttribute]]=d,e=this._columns.length;while(e--){var g=this._columns[e];g.data[d]=f[g.name]}}return this.syncable&&!b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_,moment){var b=a.Miso.Dataset;b.prototype=new b.DataView,_.extend(b.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=a.idAttribute||"_id",this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var c=[],d=_.keys(a),e,f=this.uniqueAgainst,g=this.column(f),h=[],i=[],j=[];_.each(a[f],function(c,d){var e=g.data.indexOf(b.types[g.type].coerce(c)),f={};_.each(a,function(a,b){f[b]=a[d]}),e===-1?h.push(f):(i.push(f),f[this.idAttribute]=this.rowById(this.column(this.idAttribute).data[e])[this.idAttribute],this.update(f))},this),h.length>0&&this.add(h)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addComputedColumn:function(a,c,d){if(!_.isUndefined(this.column(a)))throw"There is already a column by this name.";if(typeof b.types[c]=="undefined")throw"The type "+c+" doesn't exist";var e=new b.Column({name:a,type:c,func:_.bind(d,this)});return this._columns.push(e),this._computedColumns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,this.length>0&&this.each(function(a,b){e.compute(a,b)},this),e},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column(this.idAttribute)))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())});var c=this.addColumn({name:this.idAttribute,data:b});this.idAttribute==="_id"&&(c.type="number");if(this._columnPositionByName[this.idAttribute]!==0){var d=this._columnPositionByName[this.idAttribute];this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName[this.idAttribute]=0,_.each(this._columnPositionByName,function(a,b){b!==this.idAttribute&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a[this.idAttribute]||(a[this.idAttribute]=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c,this);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b[this.idAttribute]),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("remove",e),this.trigger("change",e)}},_arrayUpdate:function(a){var c=[];return _.each(a,function(a){var d={old:{},changed:{}};d[this.idAttribute]=a[this.idAttribute];var e=this._rowPositionById[a[this.idAttribute]];_.each(a,function(a,c){var f=this._columns[this._columnPositionByName[c]],g=b.types[f.type];if(f.name===this.idAttribute&&f.data[e]!==a)throw"You can't update the id column";if(typeof f=="undefined")throw"column "+c+" not found!";if(!g.test(a,f))throw"Value is incorrect type";if(this._computedColumns[f.name])return;a=g.coerce(a,f),_.isUndefined(f.before)||(a=f.before(a)),f.data[e]!==a&&(d.old[c]=f.data[e],f.data[e]=a,d.changed[c]=a)},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(a){var b=_.extend({},this._row(e)),c=b[a.name],f=a.compute(b,e);c!==f&&(d.old[a.name]=c,a.data[e]=f,d.changed[a.name]=f)},this),_.keys(d.changed).length>0&&c.push(d)},this),c},_functionUpdate:function(a){var b=[];for(var c=0;c<this.length;c++){var d=a(this.rowByPosition(c));d!==!1&&b.push(d)}return this._arrayUpdate(b)},update:function(a,b){var c;if(_.isFunction(a))c=this._functionUpdate(a);else{var d=_.isArray(a)?a:[a];c=this._arrayUpdate(d)}if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("update",e),this.trigger("change",e)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso.Dataset;b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return _.isNull(a)||typeof a=="undefined"||_.isNaN(a)?null:a},test:function(a){return!0},compare:function(a,b){if(_.isEqual(a,b))return 0;if(a<b)return-1;if(a>b)return 1},numeric:function(a){return a===null||_.isNaN(+a)?null:+a}},string:{name:"string",coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)||a===null?null:_.isNumber(+a)?+a:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a===null||_.isNaN(a)?null:a?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(a){var b=+a;return _.isNull(a)||typeof a=="undefined"||_.isNaN(b)?null:b},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return _.isNaN(a)||a===null?null:a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isNull(a)||typeof a=="undefined"||_.isNaN(a))return null;if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(a)||a===null?null:a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Event=function(a,b){_.isArray(a)||(a=[a]),this.deltas=a,this.dataset=b||null},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a===this.dataset.idAttribute},this).value()},this),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a,c){return new b.Event(a,c)}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName[a.idAttribute]].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Product=function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),b.Product.define=function(a){return function(c,d){d=d||{};var e=this._findColumns(c),f=this;d.type=d.type||e[0].type,d.typeOptions=d.typeOptions||e[0].typeOptions;var g=function(){var c=a.call(f,e,d);return b.types[d.type].coerce(c,d.typeOptions)};if(this.syncable){var h=new b.Product({columns:e,func:function(a){a=a||{};var b=this._buildDelta(this.value,g.call(f));this.value=b.changed;if(f.syncable){var c=this._buildEvent(b,this);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",c)}}});return this.bind("change",h._sync,h),h}return g.call(f)}},_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:b.Product.define(function(a,c){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}),max:b.Product.define(function(a,b){return _.max(_.map(a,function(a){return a._max()}))}),min:b.Product.define(function(a,b){return _.min(_.map(a,function(a){return a._min()}))}),mean:b.Product.define(function(a,c){var d=[];_.each(a,function(a){d.push(a.data)}),d=_.flatten(d);var e=a[0].type;return d=_.map(d,function(a){return b.types[e].numeric(a)}),_.mean(d)})})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return a.ActiveXObject?new a.ActiveXObject("Microsoft.XMLHTTP"):new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null,d;return d=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},a.ajax.readyState===4?d():a.ajax.onreadystatechange=d,b}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d.charAt(o))&&n++,o++;d=d.slice(o,p)}function q(a){var d=a[1];if(d.length&&d!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var g=null;a[2]?g=a[2].replace(new RegExp('""',"g"),'"'):g=a[3];if(k){g===""&&(g=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(g)}else{var i=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(g)||g==="")g="X";b.indexOf(g)!==-1&&(g=i(g)),b.push(g),c[g]=[]}}(new RegExp("^"+f)).test(d)&&q(["","",undefined,""]);while(i=a.exec(d))q(i)}catch(r){throw new Error("Error while parsing delimited data on row "+m+". Message: "+r.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Derived=function(a){a=a||{},b.call(this),this.parent=a.parent,this.idAttribute="_id",this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){if(a===this.idAttribute)throw"You can't compute a moving average on the id column";e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column(this.idAttribute).data=this.parent.column(this.parent.idAttribute).data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column(this.parent.idAttribute).data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d.column(a).data,g=d.column("count").data,h=d.column("_oids").data,i=d.column(d.idAttribute).data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b[this.parent.idAttribute]])):(g[c]+=1,h[c].push(b[this.parent.idAttribute]))},d),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){var d=this;b.Builder.clearRowCache(this);var e={},f=0,g=this._columnPositionByName[a],h=this.parent.column(a);for(var i=0;i<this.parent.length;i++){var j=null;this.preprocess?j=this.preprocess(h.data[i]):j=h.data[i],_.isUndefined(e[j])&&(e[j]=f,_.each(c,function(a){var b=this.column(a),c=this.column(this.idAttribute);b.data[f]=[],c.data[f]=_.uniqueId()},this),this.column(a).data[f]=j,f++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[i],d=e[j];b.data[d].push(this.parent.rowByPosition(i))},this)}var k=this._columns[this._columnPositionByName._oids];return k.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,e){_.isArray(c)&&(k.data[e]=k.data[e]||[],k.data[e].push(_.map(c,function(a){return a[d.parent.idAttribute]})),k.data[e]=_.flatten(k.data[e]),b.data[e]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_)
View
9 dist/miso.ds.deps.min.0.2.2.js
@@ -1,9 +0,0 @@
-/**
-* Miso.Dataset - v0.2.2 - 9/3/2012
-* http://github.com/misoproject/dataset
-* Copyright (c) 2012 Alex Graul, Irene Ros;
-* Dual Licensed: MIT, GPL
-* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
-* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
-*/
-(function(a,b){function F(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,a._a=null,this._lang=c||!1}function G(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=H(j/1e3),b.seconds=i%60,h+=H(i/60),b.minutes=h%60,g+=H(h/60),b.hours=g%24,f+=H(g/24),f+=e*7,b.days=f%30,d+=H(f/30),b.months=d%12,c+=H(d/12),b.years=c,this._lang=!1}function H(a){return a<0?Math.ceil(a):Math.floor(a)}function I(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function J(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(1).month(a.month()+f*c).date(Math.min(g,a.daysInMonth())))}function K(a){return Object.prototype.toString.call(a)==="[object Array]"}function L(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function M(b,c){var d,e;for(d=1;d<7;d++)b[d]=b[d]==null?d===2?1:0:b[d];return b[7]=c,e=new a(0),c?(e.setUTCFullYear(b[0],b[1],b[2]),e.setUTCHours(b[3],b[4],b[5],b[6])):(e.setFullYear(b[0],b[1],b[2]),e.setHours(b[3],b[4],b[5],b[6])),e._a=b,e}function N(a,b){var c,d,e=[];!b&&h&&(b=require("./lang/"+a));for(c=0;c<i.length;c++)b[i[c]]=b[i[c]]||f.en[i[c]];for(c=0;c<12;c++)d=moment([2e3,c]),e[c]=new RegExp("^"+(b.months[c]||b.months(d,""))+"|^"+(b.monthsShort[c]||b.monthsShort(d,"")).replace(".",""),"i");return b.monthsParse=b.monthsParse||e,f[a]=b,b}function O(a){var b=typeof a=="string"&&a||a&&a._lang||null;return b?f[b]||N(b):moment}function P(a){return C[a]?"'+("+C[a]+")+'":a.replace(m,"").replace(/\\?'/g,"\\'")}function Q(a){return O().longDateFormat[a]||a}function R(a){var b="var a,b;return '"+a.replace(k,P)+"';",c=Function;return new c("t","v","o","p","m",b)}function S(a){return B[a]||(B[a]=R(a)),B[a]}function T(a,b){function d(d,e){return c[d].call?c[d](a,b):c[d][e]}var c=O(a);while(l.test(b))b=b.replace(l,Q);return B[b]||(B[b]=R(b)),B[b](a,d,c.ordinal,I,c.meridiem)}function U(a){switch(a){case"DDDD":return q;case"YYYY":return r;case"S":case"SS":case"SSS":case"DDD":return p;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return s;case"Z":case"ZZ":return t;case"T":return u;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return o;default:return new RegExp(a.replace("\\",""))}}function V(a,b,c,d){var e;switch(a){case"M":case"MM":c[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(e=0;e<12;e++)if(O().monthsParse[e].test(b)){c[1]=e;break}break;case"D":case"DD":case"DDD":case"DDDD":b!=null&&(c[2]=~~b);break;case"YY":b=~~b,c[0]=b+(b>70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(y),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}}function W(a,b){var c=[0,0,1,0,0,0,0],d={tzh:0,tzm:0},e=b.match(k),f,g;for(f=0;f<e.length;f++)g=(U(e[f]).exec(a)||[])[0],a=a.replace(U(e[f]),""),V(e[f],g,c,d);return d.isPm&&c[3]<12&&(c[3]+=12),d.isPm===!1&&c[3]===12&&(c[3]=0),c[3]+=d.tzh,c[4]+=d.tzm,M(c,d.isUTC)}function X(a,b){var c,d=a.match(n)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=W(a,b[g]),e=T(new F(h),b[g]).match(n)||[],i=L(d,e),i<f&&(f=i,c=h);return c}function Y(b){var c="YYYY-MM-DDT",d;if(v.exec(b)){for(d=0;d<4;d++)if(x[d][1].exec(b)){c+=x[d][0];break}return t.exec(b)?W(b,c+" Z"):W(b,c)}return new a(b)}function Z(a,b,c,d,e){var f=e.relativeTime[a];return typeof f=="function"?f(b||1,!!c,a,d):f.replace(/%d/i,b||1)}function $(a,b,c){var e=d(Math.abs(a)/1e3),f=d(e/60),g=d(f/60),h=d(g/24),i=d(h/365),j=e<45&&["s",e]||f===1&&["m"]||f<45&&["mm",f]||g===1&&["h"]||g<22&&["hh",g]||h===1&&["d"]||h<=25&&["dd",h]||h<=45&&["M"]||h<345&&["MM",d(h/30)]||i===1&&["y"]||["yy",i];return j[2]=b,j[3]=a>0,j[4]=c,Z.apply({},j)}function _(a,b){moment.fn[a]=function(a){var c=this._isUTC?"UTC":"";return a!=null?(this._d["set"+c+b](a),this):this._d["get"+c+b]()}}function ba(a){moment.duration.fn[a]=function(){return this._data[a]}}function bb(a,b){moment.duration.fn["as"+a]=function(){return+this/b}}var moment,c="1.7.0",d=Math.round,e,f={},g="en",h=typeof module!="undefined"&&module.exports,i="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),j=/^\/?Date\((\-?\d+)/i,k=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?)/g,l=/(LT|LL?L?L?)/g,m=/(^\[)|(\\)|\]$/g,n=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,o=/\d\d?/,p=/\d{1,3}/,q=/\d{3}/,r=/\d{1,4}/,s=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,t=/Z|[\+\-]\d\d:?\d\d/i,u=/T/i,v=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,w="YYYY-MM-DDTHH:mm:ssZ",x=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],y=/([\+\-]|\d\d)/gi,z="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),A={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},B={},C={M:"(a=t.month()+1)",MMM:'v("monthsShort",t.month())',MMMM:'v("months",t.month())',D:"(a=t.date())",DDD:"(a=new Date(t.year(),t.month(),t.date()),b=new Date(t.year(),0,1),a=~~(((a-b)/864e5)+1.5))",d:"(a=t.day())",dd:'v("weekdaysMin",t.day())',ddd:'v("weekdaysShort",t.day())',dddd:'v("weekdays",t.day())',w:"(a=new Date(t.year(),t.month(),t.date()-t.day()+5),b=new Date(a.getFullYear(),0,4),a=~~((a-b)/864e5/7+1.5))",YY:"p(t.year()%100,2)",YYYY:"p(t.year(),4)",a:"m(t.hours(),t.minutes(),!0)",A:"m(t.hours(),t.minutes(),!1)",H:"t.hours()",h:"t.hours()%12||12",m:"t.minutes()",s:"t.seconds()",S:"~~(t.milliseconds()/100)",SS:"p(~~(t.milliseconds()/10),2)",SSS:"p(t.milliseconds(),3)",Z:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(a/60),2)+":"+p(~~a%60,2)',ZZ:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(10*a/6),4)'},D="DDD w M D d".split(" "),E="M D H h m s w".split(" ");while(D.length)e=D.pop(),C[e+"o"]=C[e]+"+o(a)";while(E.length)e=E.pop(),C[e+e]="p("+C[e]+",2)";C.DDDD="p("+C.DDD+",3)",moment=function(c,d){if(c===null||c==="")return null;var e,f;return moment.isMoment(c)?new F(new a(+c._d),c._isUTC,c._lang):(d?K(d)?e=X(c,d):e=W(c,d):(f=j.exec(c),e=c===b?new a:f?new a(+f[1]):c instanceof a?c:K(c)?M(c):typeof c=="string"?Y(c):new a(c)),new F(e))},moment.utc=function(a,b){return K(a)?new F(M(a,!0),!0):(typeof a=="string"&&!t.exec(a)&&(a+=" +0000",b&&(b+=" Z")),moment(a,b).utc())},moment.unix=function(a){return moment(a*1e3)},moment.duration=function(a,b){var c=moment.isDuration(a),d=typeof a=="number",e=c?a._data:d?{}:a,f;return d&&(b?e[b]=a:e.milliseconds=a),f=new G(e),c&&(f._lang=a._lang),f},moment.humanizeDuration=function(a,b,c){return moment.duration(a,b===!0?null:b).humanize(b===!0?!0:c)},moment.version=c,moment.defaultFormat=w,moment.lang=function(a,b){var c;if(!a)return g;(b||!f[a])&&N(a,b);if(f[a]){for(c=0;c<i.length;c++)moment[i[c]]=f[a][i[c]];moment.monthsParse=f[a].monthsParse,g=a}},moment.langData=O,moment.isMoment=function(a){return a instanceof F},moment.isDuration=function(a){return a instanceof G},moment.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),moment.fn=F.prototype={clone:function(){return moment(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?!L(this._a,(this._a[7]?moment.utc(this):this).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return T(this,a?a:moment.defaultFormat)},add:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return J(this,c,1),this},subtract:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return J(this,c,-1),this},diff:function(a,b,c){var e=this._isUTC?moment(a).utc():moment(a).local(),f=(this.zone()-e.zone())*6e4,g=this._d-e._d-f,h=this.year()-e.year(),i=this.month()-e.month(),j=this.date()-e.date(),k;return b==="months"?k=h*12+i+j/30:b==="years"?k=h+(i+j/30)/12:k=b==="seconds"?g/1e3:b==="minutes"?g/6e4:b==="hours"?g/36e5:b==="days"?g/864e5:b==="weeks"?g/6048e5:g,c?k:d(k)},from:function(a,b){return moment.duration(this.diff(a)).lang(this._lang).humanize(!b)},fromNow:function(a){return this.from(moment(),a)},calendar:function(){var a=this.diff(moment().sod(),"days",!0),b=this.lang().calendar,c=b.sameElse,d=a<-6?c:a<-1?b.lastWeek:a<0?b.lastDay:a<1?b.sameDay:a<2?b.nextDay:a<7?b.nextWeek:c;return this.format(typeof d=="function"?d.apply(this):d)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<moment([this.year()]).zone()||this.zone()<moment([this.year(),5]).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return a==null?b:this.add({d:a-b})},startOf:function(a){switch(a.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return this},endOf:function(a){return this.startOf(a).add(a.replace(/s?$/,"s"),1).subtract("ms",1)},sod:function(){return this.clone().startOf("day")},eod:function(){return this.clone().endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return moment.utc([this.year(),this.month()+1,0]).date()},lang:function(a){return a===b?O(this):(this._lang=a,this)}};for(e=0;e<z.length;e++)_(z[e].toLowerCase(),z[e]);_("year","FullYear"),moment.duration.fn=G.prototype={weeks:function(){return H(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,c=this.lang().relativeTime,d=$(b,!a,this.lang());return a&&(d=(b<=0?c.past:c.future).replace(/%s/i,d)),d},lang:moment.fn.lang};for(e in A)A.hasOwnProperty(e)&&(bb(e,A[e]),ba(e.toLowerCase()));bb("Weeks",6048e5),h&&(module.exports=moment),typeof ender=="undefined"&&(this.moment=moment),typeof define=="function"&&define.amd&&define("moment",[],function(){return moment})}).call(this,Date),function(a,b){function bq(a){return new br(a)}function br(a){if(a&&a._wrapped)return a;this._wrapped=a}function bC(a,b,c){b||(b=0);var d=a.length,e=d-b>=(c||n),f=e?{}:a;if(e){var g,h=b-1;while(++h<d)g=a[h]+"",(F.call(f,g)?f[g]:f[g]=[]).push(a[h])}return function(a){if(e){var c=a+"";return F.call(f,c)&&cM(f[c],a)>-1}return cM(f,a,b)>-1}}function bD(){var a,b,c,d=-1,e=arguments.length,f={bottom:"",exit:"",init:"",top:"",arrayBranch:{beforeLoop:""},objectBranch:{beforeLoop:""}};while(++d<e){a=arguments[d];for(b in a)c=(c=a[b])==null?"":c,/beforeLoop|inLoop/.test(b)?(typeof c=="string"&&(c={array:c,object:c}),f.arrayBranch[b]=c.array||"",f.objectBranch[b]=c.object||""):f[b]=c}var g=f.args,i=/^[^,]+/.exec(g)[0],j=f.useStrict;f.firstArg=i,f.hasDontEnumBug=Z,f.isKeysFast=bh,f.noArgsEnum=ba,f.shadowed=A,f.useHas=f.useHas!==!1,f.useStrict=j==null?bi:j,f.noCharByIndex==null&&(f.noCharByIndex=bd),f.exit||(f.exit="if (!"+i+") return result");if(i!="collection"||!f.arrayBranch.inLoop)f.arrayBranch=null;var k=Function("arrayLikeClasses, ArrayProto, bind, compareAscending, concat, forIn, hasOwnProperty, identity, indexOf, isArguments, isArray, isFunction, isPlainObject, iteratorBind, objectClass, objectTypes, nativeKeys, propertyIsEnumerable, slice, stringClass, toString","var callee = function("+g+") {\n"+bs(f)+"\n};\n"+"return callee");return k(bk,h,db,bE,E,bX,F,dn,cM,bO,bP,bQ,bR,bI,U,bo,N,H,I,W,J)}function bE(a,c){var d=a.index,e=c.index;return a=a.criteria,c=c.criteria,a===b?1:c===b?-1:a<c?-1:a>c?1:d<e?-1:1}function bF(a,b){return D[b]}function bG(a){return"\\"+bp[a]}function bH(a){return bm[a]}function bI(a,b){return function(c,d,e){return a.call(b,c,d,e)}}function bJ(){}function bK(a,b){if(a&&p.test(b))return"<e%-"+b+"%>";var c=D.length;return D[c]="' +\n__e("+b+") +\n'",C+c}function bL(a,b,c,d){if(d){var e=D.length;return D[e]="';\n"+d+";\n__p += '",C+e}return b?bK(null,b):bM(null,c)}function bM(a,b){if(a&&p.test(b))return"<e%="+b+"%>";var c=D.length;return D[c]="' +\n((__t = ("+b+")) == null ? '' : __t) +\n'",C+c}function bN(a){return bn[a]}function bO(a){return J.call(a)==O}function bQ(a){return typeof a=="function"}function bR(a,b){return a?a==j||a.__proto__==j&&(b||!bO(a)):!1}function bT(a,b,c,d,e){if(a==null)return a;c&&(b=!1),e||(e={value:null}),e.value==null&&(e.value=!!(i.clone||k.clone||l.clone));var f=bo[typeof a];if((f||e.value)&&a.clone&&bQ(a.clone))return e.value=null,a.clone(b);if(f){var g=J.call(a);if(!bl[g]||bb&&bO(a))return a;var h=g==P;f=h||(g==U?bR(a,!0):f)}if(!f||!b)return f?h?I.call(a):bW({},a):a;var j=a.constructor;switch(g){case Q:return new j(a==!0);case R:return new j(+a);case T:case W:return new j(a);case V:return j(a.source,u.exec(a))}d||(d=[]);var m=d.length;while(m--)if(d[m].source==a)return d[m].value;m=a.length;var n=h?j(m):{};d.push({value:n,source:a});if(h){var o=-1;while(++o<m)n[o]=bT(a[o],b,null,d,e)}else bY(a,function(a,c){n[c]=bT(a,b,null,d,e)});return n}function b$(a,b){return a?F.call(a,b):!1}function b_(a){return a===!0||a===!1||J.call(a)==Q}function ca(a){return J.call(a)==R}function cb(a){return a?a.nodeType===1:!1}function cd(a,b,c,d){if(a==null||b==null)return a===b;d||(d={value:null}),d.value==null&&(d.value=!!(i.isEqual||k.isEqual||l.isEqual));if(bo[typeof a]||bo[typeof b]||d.value){a._chain&&(a=a._wrapped),b._chain&&(b=b._wrapped);if(a.isEqual&&bQ(a.isEqual))return d.value=null,a.isEqual(b);if(b.isEqual&&bQ(b.isEqual))return d.value=null,b.isEqual(a)}if(a===b)return a!==0||1/a==1/b;var e=J.call(a);if(e!=J.call(b))return!1;switch(e){case Q:case R:return+a==+b;case T:return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case V:case W:return a==b+""}var f=bk[e];if(bb&&!f&&(f=bO(a))&&!bO(b))return!1;if(!f&&(e!=U||be&&(typeof a.toString!="function"&&typeof (a+"")=="string"||typeof b.toString!="function"&&typeof (b+"")=="string")))return!1;c||(c=[]);var g=c.length;while(g--)if(c[g]==a)return!0;var h=-1,j=!0,m=0;c.push(a);if(f){m=a.length,j=m==b.length;if(j)while(m--)if(!(j=cd(a[m],b[m],c,d)))break;return j}var n=a.constructor,o=b.constructor;if(n!=o&&!(bQ(n)&&n instanceof n&&bQ(o)&&o instanceof o))return!1;for(var p in a)if(F.call(a,p)){m++;if(!F.call(b,p)||!cd(a[p],b[p],c,d))return!1}for(p in b)if(F.call(b,p)&&!(m--))return!1;if(Z)while(++h<7){p=A[h];if(F.call(a,p)&&(!F.call(b,p)||!cd(a[p],b[p],c,d)))return!1}return!0}function ce(a){return M(a)&&J.call(a)==T}function cf(a){return a?bo[typeof a]:!1}function cg(a){return J.call(a)==T&&a!=+a}function ch(a){return a===null}function ci(a){return J.call(a)==T}function cj(a){return J.call(a)==V}function ck(a){return J.call(a)==W}function cl(a){return a===b}function cp(a){if(!a)return 0;var b=J.call(a),c=a.length;return bk[b]||bb&&bO(a)||b==U&&c>-1&&c===c>>>0&&bQ(a.splice)?c:cm(a).length}function cC(a,b,c,d){if(!a)return c;var e=a.length,f=arguments.length<3;d&&(b=bI(b,d));if(e>-1&&e===e>>>0){var g=bd&&J.call(a)==W?a.split(""):a;e&&f&&(c=g[--e]);while(e--)c=b(c,g[e],e,a);return c}var h,i=cm(a);e=i.length,e&&f&&(c=a[i[--e]]);while(e--)h=i[e],c=b(c,a[h],h,a);return c}function cG(a){if(!a)return[];if(a.toArray&&bQ(a.toArray))return a.toArray();var b=a.length;return b>-1&&b===b>>>0?(bc?J.call(a)==W:typeof a=="string")?a.split(""):I.call(a):cq(a)}function cI(a){var b=[];if(!a)return b;var c=-1,d=a.length;while(++c<d)a[c]&&b.push(a[c]);return b}function cJ(a){var b=[];if(!a)return b;var c=-1,d=a.length,e=E.apply(b,arguments),f=bC(e,d);while(++c<d)f(a[c])||b.push(a[c]);return b}function cK(a,b,c){if(a)return b==null||c?a[0]:I.call(a,0,b)}function cL(a,b){var c=[];if(!a)return c;var d,e=-1,f=a.length;while(++e<f)d=a[e],bP(d)?G.apply(c,b?d:cL(d)):c.push(d);return c}function cM(a,b,c){if(!a)return-1;var d=-1,e=a.length;if(c)if(typeof c=="number")d=(c<0?Math.max(0,e+c):c)-1;else return d=cW(a,b),a[d]===b?d:-1;while(++d<e)if(a[d]===b)return d;return-1}function cN(a,b,c){return a?I.call(a,0,-(b==null||c?1:b)):[]}function cO(a){var b=[];if(!a)return b;var c,d=arguments.length,e=[],f=-1,g=a.length;a:while(++f<g){c=a[f];if(cM(b,c)<0){for(var h=1;h<d;h++)if(!(e[h]||(e[h]=bC(arguments[h])))(c))continue a;b.push(c)}}return b}function cP(a,b,c){if(a){var d=a.length;return b==null||c?a[d-1]:I.call(a,-b||d)}}function cQ(a,b,c){if(!a)return-1;var d=a.length;c&&typeof c=="number"&&(d=(c<0?Math.max(0,d+c):Math.min(c,d-1))+1);while(d--)if(a[d]===b)return d;return-1}function cR(a,b,c){var d=-Infinity,e=d;if(!a)return e;var f,g=-1,h=a.length;if(!b){while(++g<h)a[g]>e&&(e=a[g]);return e}c&&(b=bI(b,c));while(++g<h)f=b(a[g],g,a),f>d&&(d=f,e=a[g]);return e}function cS(a,b,c){var d=Infinity,e=d;if(!a)return e;var f,g=-1,h=a.length;if(!b){while(++g<h)a[g]<e&&(e=a[g]);return e}c&&(b=bI(b,c));while(++g<h)f=b(a[g],g,a),f<d&&(d=f,e=a[g]);return e}function cT(a,b,c){a=+a||0,c=+c||1,b==null&&(b=a,a=0);var d=-1,e=Math.max(0,Math.ceil((b-a)/c)),f=Array(e);while(++d<e)f[d]=a,a+=c;return f}function cU(a,b,c){return a?I.call(a,b==null||c?1:b):[]}function cV(a){if(!a)return[];var b,c=-1,d=a.length,e=Array(d);while(++c<d)b=Math.floor(Math.random()*(c+1)),e[c]=e[b],e[b]=a[c];return e}function cW(a,b,c,d){if(!a)return 0;var e,f=0,g=a.length;if(c){d&&(c=db(c,d)),b=c(b);while(f<g)e=f+g>>>1,c(a[e])<b?f=e+1:g=e}else while(f<g)e=f+g>>>1,a[e]<b?f=e+1:g=e;return f}function cX(){var a=-1,b=[],c=E.apply(b,arguments),d=c.length;while(++a<d)cM(b,c[a])<0&&b.push(c[a]);return b}function cY(a,b,c,d){var e=[];if(!a)return e;var f,g=-1,h=a.length,i=[];typeof b=="function"&&(d=c,c=b,b=!1),c?d&&(c=bI(c,d)):c=dn;while(++g<h){f=c(a[g],g,a);if(b?!g||i[i.length-1]!==f:cM(i,f)<0)i.push(f),e.push(a[g])}return e}function cZ(a){var b=[];if(!a)return b;var c=-1,d=a.length,e=bC(arguments,1,20);while(++c<d)e(a[c])||b.push(a[c]);return b}function c$(a){if(!a)return[];var b=-1,c=cR(cA(arguments,"length")),d=Array(c);while(++b<c)d[b]=cA(arguments,b);return d}function c_(a,b){if(!a)return{};var c=-1,d=a.length,e={};b||(b=[]);while(++c<d)e[a[c]]=b[c];return e}function da(a,b){return a<1?b():function(){if(--a<1)return b.apply(this,arguments)}}function db(a,b){function f(){var g=arguments,h=b;d||(a=b[c]),e.length&&(g=g.length?e.concat(I.call(g)):e);if(this instanceof f){bJ.prototype=a.prototype,h=new bJ;var i=a.apply(h,g);return i&&bo[typeof i]?i:h}return a.apply(h,g)}var c,d=bQ(a);if(!d)c=b,b=a;else if(bg||K&&arguments.length>2)return K.call.apply(K,arguments);var e=I.call(arguments,2);return f}function dd(){var a=arguments;return function(){var b=arguments,c=a.length;while(c--)b=[a[c].apply(this,b)];return b[0]}}function de(a,b,c){function h(){g=null,c||a.apply(f,d)}var d,e,f,g;return function(){var i=c&&!g;return d=arguments,f=this,X(g),g=Y(h,b),i&&(e=a.apply(f,d)),e}}function df(a,c){var d=I.call(arguments,2);return Y(function(){return a.apply(b,d)},c)}function dg(a){var c=I.call(arguments,1);return Y(function(){return a.apply(b,c)},1)}function dh(a,b){var c={};return function(){var d=b?b.apply(this,arguments):arguments[0];return F.call(c,d)?c[d]:c[d]=a.apply(this,arguments)}}function di(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}}function dj(a){var b=I.call(arguments,1),c=b.length;return function(){var d,e=arguments;return e.length&&(b.length=c,G.apply(b,e)),d=b.length==1?a.call(this,b[0]):a.apply(this,b),b.length=c,d}}function dk(a,b){function h(){g=new Date,f=null,a.apply(e,c)}var c,d,e,f,g=0;return function(){var i=new Date,j=b-(i-g);return c=arguments,e=this,j<=0?(g=i,d=a.apply(e,c)):f||(f=Y(h,j)),d}}function dl(a,b){return function(){var c=[a];return arguments.length&&G.apply(c,arguments),b.apply(this,c)}}function dm(a){return a==null?"":(a+"").replace(y,bH)}function dn(a){return a}function dp(a){cw(bZ(a),function(b){var c=bq[b]=a[b];br.prototype[b]=function(){var a=[this._wrapped];arguments.length&&G.apply(a,arguments);var b=c.apply(bq,a);return this._chain&&(b=new br(b),b._chain=!0),b}})}function dq(){return a._=o,this}function dr(a,b){if(!a)return null;var c=a[b];return bQ(c)?a[b]():c}function ds(a,b,g){g||(g={}),a+="";var h,i,j=g.escape,k=g.evaluate,l=g.interpolate,m=bq.templateSettings,n=g.variable||m.variable,o=n;j==null&&(j=m.escape),k==null&&(k=m.evaluate||!1),l==null&&(l=m.interpolate),j&&(a=a.replace(j,bK)),l&&(a=a.replace(l,bM)),k!=c&&(c=k,f=RegExp("<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>"+(k?"|"+k.source:""),"g")),h=D.length,a=a.replace(f,bL),h=h!=D.length,a="__p += '"+a.replace(z,bG).replace(x,bF)+"';\n",D.length=0,o||(n=d||"obj",h?a="with ("+n+") {\n"+a+"\n}\n":(n!=d&&(d=n,e=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),a=a.replace(v,"$&"+n+".").replace(e,"$1__d"))),a=(h?a.replace(r,""):a).replace(s,"$1").replace(t,"$1;"),a="function("+n+") {\n"+(o?"":n+" || ("+n+" = {});\n")+"var __t, __p = '', __e = _.escape"+(h?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":(o?"":", __d = "+n+"."+n+" || "+n)+";\n")+a+"return __p\n}",bj&&(a+="\n//@ sourceURL=/lodash/template/source["+B++ +"]");try{i=Function("_","return "+a)(bq)}catch(p){i=function(){throw p}}return b?i(b):(i.source=a,i)}function dt(a,b,c){var d=-1;if(c)while(++d<a)b.call(c,d);else while(++d<a)b(d)}function du(a){return a==null?"":(a+"").replace(q,bN)}function dv(a){var b=m++;return a?a+b:b}function dw(a){return a=new br(a),a._chain=!0,a}function dx(a,b){return b(a),a}function dy(){return this._chain=!0,this}function dz(){return this._wrapped}"use strict";var c,d,e,f,g=typeof exports=="object"&&exports&&(typeof global=="object"&&global&&global==global.global&&(a=global),exports),h=Array.prototype,i=Boolean.prototype,j=Object.prototype,k=Number.prototype,l=String.prototype,m=0,n=30,o=a._,p=/[-+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,q=/&(?:amp|lt|gt|quot|#x27);/g,r=/\b__p \+= '';/g,s=/\b(__p \+=) '' \+/g,t=/(__e\(.*?\)|\b__t\)) \+\n'';/g,u=/\w*$/,v=/(?:__e|__t = )\(\s*(?![\d\s"']|this\.)/g,w=RegExp("^"+(j.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),x=/__token__(\d+)/g,y=/[&<>"']/g,z=/['\n\r\t\u2028\u2029\\]/g,A=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],B=0,C="__token__",D=[],E=h.concat,F=j.hasOwnProperty,G=h.push,H=j.propertyIsEnumerable,I=h.slice,J=j.toString,K=w.test(K=I.bind)&&K,L=w.test(L=Array.isArray)&&L,M=a.isFinite,N=w.test(N=Object.keys)&&N,O="[object Arguments]",P="[object Array]",Q="[object Boolean]",R="[object Date]",S="[object Function]",T="[object Number]",U="[object Object]",V="[object RegExp]",W="[object String]",X=a.clearTimeout,Y=a.setTimeout,Z,$,_,ba=!0;(function(){function c(){this.x=1}var a={0:1,length:1},b=[];c.prototype={valueOf:1,y:1};for(var d in new c)b.push(d);for(d in arguments)ba=!d;Z=(b+"").length<4,_=b[0]!="x",$=(b.splice.call(a,0,1),a[0])})(1);var bb=!bO(arguments),bc=I.call("x")[0]!="x",bd="x"[0]+Object("x")[0]!="xx";try{var be=({toString:0}+"",J.call(a.document||0)==U)}catch(bf){}var bg=K&&/\n|Opera/.test(K+J.call(a.opera)),bh=N&&/^.+$|true/.test(N+!!a.attachEvent),bi=!bg;try{var bj=(Function("//@")(),!a.attachEvent)}catch(bf){}var bk={};bk[Q]=bk[R]=bk[S]=bk[T]=bk[U]=bk[V]=!1,bk[O]=bk[P]=bk[W]=!0;var bl={};bl[O]=bl[S]=!1,bl[P]=bl[Q]=bl[R]=bl[T]=bl[U]=bl[V]=bl[W]=!0;var bm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},bn={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'"},bo={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1,unknown:!0},bp={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"};bq.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var bs=ds("<% if (useStrict) { %>'use strict';\n<% } %>var index, value, iteratee = <%= firstArg %>, result<% if (init) { %> = <%= init %><% } %>;\n<%= exit %>;\n<%= top %>;\n<% if (arrayBranch) { %>var length = iteratee.length; index = -1; <% if (objectBranch) { %>\nif (length > -1 && length === length >>> 0) {<% } %> <% if (noCharByIndex) { %>\n if (toString.call(iteratee) == stringClass) {\n iteratee = iteratee.split('')\n } <% } %>\n <%= arrayBranch.beforeLoop %>;\n while (++index < length) {\n value = iteratee[index];\n <%= arrayBranch.inLoop %>\n } <% if (objectBranch) { %>\n}<% } %><% } %><% if (objectBranch) { %> <% if (arrayBranch) { %>\nelse { <% } else if (noArgsEnum) { %>\n var length = iteratee.length; index = -1;\n if (length && isArguments(iteratee)) {\n while (++index < length) {\n value = iteratee[index += ''];\n <%= objectBranch.inLoop %>\n }\n } else { <% } %> <% if (!hasDontEnumBug) { %>\n var skipProto = typeof iteratee == 'function' && \n propertyIsEnumerable.call(iteratee, 'prototype');\n <% } %> <% if (isKeysFast && useHas) { %>\n var ownIndex = -1,\n ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n length = ownProps.length;\n\n <%= objectBranch.beforeLoop %>;\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n <% if (!hasDontEnumBug) { %>if (!(skipProto && index == 'prototype')) {\n <% } %> value = iteratee[index];\n <%= objectBranch.inLoop %>\n <% if (!hasDontEnumBug) { %>}\n<% } %> } <% } else { %>\n <%= objectBranch.beforeLoop %>;\n for (index in iteratee) { <% if (!hasDontEnumBug || useHas) { %>\n if (<% if (!hasDontEnumBug) { %>!(skipProto && index == 'prototype')<% } if (!hasDontEnumBug && useHas) { %> && <% } if (useHas) { %>hasOwnProperty.call(iteratee, index)<% } %>) { <% } %>\n value = iteratee[index];\n <%= objectBranch.inLoop %>;\n <% if (!hasDontEnumBug || useHas) { %>}\n<% } %> } <% } %> <% if (hasDontEnumBug) { %>\n\n var ctor = iteratee.constructor;\n <% for (var k = 0; k < 7; k++) { %>\n index = '<%= shadowed[k] %>';\n if (<% if (shadowed[k] == 'constructor') { %>!(ctor && ctor.prototype === iteratee) && <% } %>hasOwnProperty.call(iteratee, index)) {\n value = iteratee[index];\n <%= objectBranch.inLoop %>\n } <% } %> <% } %> <% if (arrayBranch || noArgsEnum) { %>\n}<% } %><% } %>\n<%= bottom %>;\nreturn result"),bt={args:"collection, callback, thisArg",init:"collection",top:"if (!callback) {\n callback = identity\n}\nelse if (thisArg) {\n callback = iteratorBind(callback, thisArg)\n}",inLoop:"if (callback(value, index, collection) === false) return result"},bu={init:"{}",top:"var prop;\nif (typeof callback != 'function') {\n var valueProp = callback;\n callback = function(value) { return value[valueProp] }\n}\nelse if (thisArg) {\n callback = iteratorBind(callback, thisArg)\n}",inLoop:"prop = callback(value, index, collection);\n(hasOwnProperty.call(result, prop) ? result[prop]++ : result[prop] = 1)"},bv={useHas:!1,args:"object, callback, thisArg",init:"{}",top:"var isFunc = typeof callback == 'function';\nif (!isFunc) {\n var props = concat.apply(ArrayProto, arguments)\n} else if (thisArg) {\n callback = iteratorBind(callback, thisArg)\n}",inLoop:"if (isFunc\n ? !callback(value, index, object)\n : indexOf(props, index) < 0\n) result[index] = value"},bw={init:"true",inLoop:"if (!callback(value, index, collection)) return !result"},bx={useHas:!1,useStrict:!1,args:"object",init:"object",top:"for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",inLoop:"result[index] = value",bottom:" }\n}"},by={init:"[]",inLoop:"callback(value, index, collection) && result.push(value)"},bz={top:"if (thisArg) callback = iteratorBind(callback, thisArg)"},bA={inLoop:{object:bt.inLoop}},bB={init:"",exit:"if (!collection) return []",beforeLoop:{array:"result = Array(length)",object:"result = "+(bh?"Array(length)":"[]")},inLoop:{array:"result[index] = callback(value, index, collection)",object:"result"+(bh?"[ownIndex] = ":".push")+"(callback(value, index, collection))"}};bb&&(bO=function(a){return!!a&&!!F.call(a,"callee")});var bP=L||function(a){return J.call(a)==P};bQ(/x/)&&(bQ=function(a){return J.call(a)==S}),bR(bo)||(bR=function(a,b){var c=!1;if(!a||typeof a!="object"||!b&&bO(a))return c;var d=a.constructor;return(!be||typeof a.toString=="function"||typeof (a+"")!="string")&&(!bQ(d)||d instanceof d)?_?(bX(a,function(b,d){return c=!F.call(a,d),!1}),c===!1):(bX(a,function(a,b){c=b}),c===!1||F.call(a,c)):c});var bS=bD({args:"object",init:"[]",inLoop:"result.push(index)"}),bU=bD(bx,{inLoop:"if (result[index] == null) "+bx.inLoop}),bV=bD(bv),bW=bD(bx),bX=bD(bt,bz,bA,{useHas:!1}),bY=bD(bt,bz,bA),bZ=bD({useHas:!1,args:"object",init:"[]",inLoop:"if (isFunction(value)) result.push(index)",bottom:"result.sort()"}),cc=bD({args:"value",init:"true",top:"var className = toString.call(value),\n length = value.length;\nif (arrayLikeClasses[className]"+(bb?" || isArguments(value)":"")+" ||\n"+" (className == objectClass && length > -1 && length === length >>> 0 &&\n"+" isFunction(value.splice))"+") return !length",inLoop:{object:"return false"}}),cm=N?function(a){var b=typeof a;return b=="function"&&H.call(a,"prototype")?bS(a):a&&bo[b]?N(a):[]}:bS,cn=bD(bx,{args:"object, source, indicator, stack",top:"var destValue, found, isArr, stackLength, recursive = indicator == isPlainObject;\nif (!recursive) stack = [];\nfor (var argsIndex = 1, argsLength = recursive ? 2 : arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",inLoop:"if (value && ((isArr = isArray(value)) || isPlainObject(value))) {\n found = false; stackLength = stack.length;\n while (stackLength--) {\n if (found = stack[stackLength].source == value) break\n }\n if (found) {\n result[index] = stack[stackLength].value\n } else {\n destValue = (destValue = result[index]) && isArr\n ? (isArray(destValue) ? destValue : [])\n : (isPlainObject(destValue) ? destValue : {});\n stack.push({ value: destValue, source: value });\n result[index] = callee(destValue, value, isPlainObject, stack)\n }\n} else if (value != null) {\n result[index] = value\n}"}),co=bD(bv,{top:"if (typeof callback != 'function') {\n var prop,\n props = concat.apply(ArrayProto, arguments),\n length = props.length;\n for (index = 1; index < length; index++) {\n prop = props[index];\n if (prop in object) result[prop] = object[prop]\n }\n} else {\n if (thisArg) callback = iteratorBind(callback, thisArg)",inLoop:"if (callback(value, index, object)) result[index] = value",bottom:"}"}),cq=bD({args:"object",init:"[]",inLoop:"result.push(value)"}),cr=bD({args:"collection, target",init:"false",noCharByIndex:!1,beforeLoop:{array:"if (toString.call(collection) == stringClass) return collection.indexOf(target) > -1"},inLoop:"if (value === target) return true"}),cs=bD(bt,bu),ct=bD(bt,bw),cu=bD(bt,by),cv=bD(bt,bz,{init:"",inLoop:"if (callback(value, index, collection)) return value"}),cw=bD(bt,bz),cx=bD(bt,bu,{inLoop:"prop = callback(value, index, collection);\n(hasOwnProperty.call(result, prop) ? result[prop] : result[prop] = []).push(value)"}),cy=bD(bB,{args:"collection, methodName",top:"var args = slice.call(arguments, 2),\n isFunc = typeof methodName == 'function'",inLoop:{array:"result[index] = (isFunc ? methodName : value[methodName]).apply(value, args)",object:"result"+(bh?"[ownIndex] = ":".push")+"((isFunc ? methodName : value[methodName]).apply(value, args))"}}),cz=bD(bt,bB),cA=bD(bB,{args:"collection, property",inLoop:{array:"result[index] = value[property]",object:"result"+(bh?"[ownIndex] = ":".push")+"(value[property])"}}),cB=bD({args:"collection, callback, accumulator, thisArg",init:"accumulator",top:"var noaccum = arguments.length < 3;\nif (thisArg) callback = iteratorBind(callback, thisArg)",beforeLoop:{array:"if (noaccum) result = iteratee[++index]"},inLoop:{array:"result = callback(result, value, index, collection)",object:"result = noaccum\n ? (noaccum = false, value)\n : callback(result, value, index, collection)"}}),cD=bD(bt,by,{inLoop:"!"+by.inLoop}),cE=bD(bt,bw,{init:"false",inLoop:bw.inLoop.replace("!","")}),cF=bD(bt,bu,bB,{inLoop:{array:"result[index] = {\n criteria: callback(value, index, collection),\n index: index,\n value: value\n}",object:"result"+(bh?"[ownIndex] = ":".push")+"({\n"+" criteria: callback(value, index, collection),\n"+" index: index,\n"+" value: value\n"+"})"},bottom:"result.sort(compareAscending);\nlength = result.length;\nwhile (length--) {\n result[length] = result[length].value\n}"}),cH=bD(by,{args:"collection, properties",top:"var props = [];\nforIn(properties, function(value, prop) { props.push(prop) });\nvar propsLength = props.length",inLoop:"for (var prop, pass = true, propIndex = 0; propIndex < propsLength; propIndex++) {\n prop = props[propIndex];\n if (!(pass = value[prop] === properties[prop])) break\n}\npass && result.push(value)"}),dc=bD({useHas:!1,useStrict:!1,args:"object",init:"object",top:"var funcs = arguments,\n length = funcs.length;\nif (length > 1) {\n for (var index = 1; index < length; index++) {\n result[funcs[index]] = bind(result[funcs[index]], result)\n }\n return result\n}",inLoop:"if (isFunction(result[index])) {\n result[index] = bind(result[index], result)\n}"});bq.VERSION="0.6.1",bq.after=da,bq.bind=db,bq.bindAll=dc,bq.chain=dw,bq.clone=bT,bq.compact=cI,bq.compose=dd,bq.contains=cr,bq.countBy=cs,bq.debounce=de,bq.defaults=bU,bq.defer=dg,bq.delay=df,bq.difference=cJ,bq.drop=bV,bq.escape=dm,bq.every=ct,bq.extend=bW,bq.filter=cu,bq.find=cv,bq.first=cK,bq.flatten=cL,bq.forEach=cw,bq.forIn=bX,bq.forOwn=bY,bq.functions=bZ,bq.groupBy=cx,bq.has=b$,bq.identity=dn,bq.indexOf=cM,bq.initial=cN,bq.intersection=cO,bq.invoke=cy,bq.isArguments=bO,bq.isArray=bP,bq.isBoolean=b_,bq.isDate=ca,bq.isElement=cb,bq.isEmpty=cc,bq.isEqual=cd,bq.isFinite=ce,bq.isFunction=bQ,bq.isNaN=cg,bq.isNull=ch,bq.isNumber=ci,bq.isObject=cf,bq.isRegExp=cj,bq.isString=ck,bq.isUndefined=cl,bq.keys=cm,bq.last=cP,bq.lastIndexOf=cQ,bq.map=cz,bq.max=cR,bq.memoize=dh,bq.merge=cn,bq.min=cS,bq.mixin=dp,bq.noConflict=dq,bq.once=di,bq.partial=dj,bq.pick=co,bq.pluck=cA,bq.range=cT,bq.reduce=cB,bq.reduceRight=cC,bq.reject=cD,bq.rest=cU,bq.result=dr,bq.shuffle=cV,bq.size=cp,bq.some=cE,bq.sortBy=cF,bq.sortedIndex=cW,bq.tap=dx,bq.template=ds,bq.throttle=dk,bq.times=dt,bq.toArray=cG,bq.unescape=du,bq.union=cX,bq.uniq=cY,bq.uniqueId=dv,bq.values=cq,bq.where=cH,bq.without=cZ,bq.wrap=dl,bq.zip=c$,bq.zipObject=c_,bq.all=ct,bq.any=cE,bq.collect=cz,bq.detect=cv,bq.each=cw,bq.foldl=cB,bq.foldr=cC,bq.head=cK,bq.include=cr,bq.inject=cB,bq.methods=bZ,bq.omit=bV,bq.select=cu,bq.tail=cU,bq.take=cK,bq.unique=cY,bq._iteratorTemplate=bs,bq._shimKeys=bS,br.prototype=bq.prototype,dp(bq),br.prototype.chain=dy,br.prototype.value=dz,cw(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=h[a];br.prototype[a]=function(){var a=this._wrapped;return b.apply(a,arguments),$&&a.length===0&&delete a[0],this._chain&&(a=new br(a),a._chain=!0),a}}),cw(["concat","join","slice"],function(a){var b=h[a];br.prototype[a]=function(){var a=this._wrapped,c=b.apply(a,arguments);return this._chain&&(c=new br(c),c._chain=!0),c}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(a._=bq,define(function(){return bq})):g?typeof module=="object"&&module&&module.exports==g?(module.exports=bq)._=bq:g._=bq:a._=bq}(this),function(){var a=this.math={};a.mean=a.ave=a.average=function(b,c){return a.sum(b,c)/_(b).size()},a.median=function(b){var c=(b.length+1)/2,d=a.sort(b);return d.length%2?d[c-1]:(d[c-1.5]+d[c-.5])/2},a.pow=function(a,b){if(_.isNumber(a))return Math.pow(a,b);if(_.isArray(a))return _.map(a,function(a){return _.pow(a,b)})},a.scale=function(a,b){var b=b||1,c=_.max(a);return _.map(a,function(a){return a*(b/c)})},a.slope=function(a,b){return(b[1]-a[1])/(b[0]-a[0])},a.sort=function(a){return a.sort(function(a,b){return a-b})},a.stdDeviation=a.sigma=function(a){return Math.sqrt(_(a).variance())},a.sum=function(a,b){if(_.isArray(a)&&typeof a[0]=="number")var c=a;else var b=b||"value",c=_(a).pluck(b);var d=0;for(var e=0,f=c.length;e<f;e++)d+=c[e];return d},a.transpose=function(a){var b=[];return _(a).each(function(a,c){_(a).each(function(a,d){b[d]||(b[d]=[]),b[d][c]=a})}),b},a.variance=function(a){var b=_(a).mean();return _(a).chain().map(function(a){return _(a-b).pow(2)}).mean().value()},_.mixin(a)}(),function(a){function p(a){var b=o[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var b={},c=Array.prototype,d=Object.prototype,e=d.hasOwnProperty,f=d.toString,g=c.forEach,h=c.slice,i=function(a,c,d){var f,h,i;if(!a)return;if(g&&a.forEach===g)a.forEach(c,d);else if(a.length===+a.length){for(h=0,i=a.length;h<i;h++)if(h in a&&c.call(d,a[h],h,a)===b)return}else for(f in a)if(e.call(a,f)&&c.call(d,a[f],f,a)===b)return},j=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},k=function(a){return i(h.call(arguments,1),function(b){var c;for(c in b)b[c]!==void 0&&(a[c]=b[c])}),a},l={"[object Array]":"array","[object Function]":"function"},m=function(a){return a?l[f.call(a)]||"object":String(a)},n={},o={};n.Callbacks=function(a){a=a?o[a]||p(a):{};var b=[],c=[],d,e,f,g,h,i,j=function(c){var d,e,f,g,h;for(d=0,e=c.length;d<e;d++)f=c[d],g=m(f),g==="array"?j(f):g==="function"&&(!a.unique||!l.has(f))&&b.push(f)},k=function(j,k){k=k||[],d=!a.memory||[j,k],e=!0,f=!0,i=g||0,g=0,h=b.length;for(;b&&i<h;i++)if(b[i].apply(j,k)===!1&&a.stopOnFalse){d=!0;break}f=!1,b&&(a.once?d===!0?l.disable():b=[]:c&&c.length&&(d=c.shift(),l.fireWith(d[0],d[1])))},l={add:function(){if(b){var a=b.length;j(arguments),f?h=b.length:d&&d!==!0&&(g=a,k(d[0],d[1]))}return this},remove:function(){if(b){var c=arguments,d=0,e=c.length;for(;d<e;d++)for(var g=0;g<b.length;g++)if(c[d]===b[g]){f&&g<=h&&(h--,g<=i&&i--),b.splice(g--,1);if(a.unique)break}}return this},has:function(a){if(b){var c=0,d=b.length;for(;c<d;c++)if(a===b[c])return!0}return!1},empty:function(){return b=[],this},disable:function(){return b=c=d=undefined,this},disabled:function(){return!b},lock:function(){return c=undefined,(!d||d===!0)&&l.disable(),this},locked:function(){return!c},fireWith:function(b,e){return c&&(f?a.once||c.push([b,e]):(!a.once||!d)&&k(b,e)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!e}};return l},n.Deferred=function(a){var b=n.Callbacks("once memory"),c=n.Callbacks("once memory"),d=n.Callbacks("memory"),e="pending",f={resolve:b,reject:c,notify:d},g={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){return h.done(a).fail(b).progress(c),this},always:function(){return h.done.apply(h,arguments).fail.apply(h,arguments),this},pipe:function(a,b,c){return n.Deferred(function(d){i({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=a[0],e=a[1],f;j(c)?h[b](function(){f=c.apply(this,arguments),f&&j(f.promise)?f.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===h?d:this,[f])}):h[b](d[e])})}).promise()},promise:function(a){if(!a)a=g;else for(var b in g)a[b]=g[b];return a}},h=g.promise({}),k;for(k in f)h[k]=f[k].fire,h[k+"With"]=f[k].fireWith;return h.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(h,h),h},n.when=function(a){function l(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--f||i.resolveWith(i,b)}}function m(a){return function(b){e[a]=arguments.length>1?h.call(arguments,0):b,i.notifyWith(k,e)}}var b=h.call(arguments,0),c=0,d=b.length,e=new Array(d),f=d,g=d,i=d<=1&&a&&j(a.promise)?a:n.Deferred(),k=i.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&j(b[c].promise)?b[c].promise().then(l(c),i.reject,m(c)):--f;f||i.resolveWith(i,b)}else i!==a&&i.resolveWith(i,d?[a]:[]);return k},typeof module!="undefined"&&module.exports?module.exports=n:typeof a._!="undefined"?a._.mixin(n):a._=n}(this),function(a,_){var b=a.Miso||(a.Miso={});b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return _.isNull(a)||typeof a=="undefined"||_.isNaN(a)?null:a},test:function(a){return!0},compare:function(a,b){if(_.isEqual(a,b))return 0;if(a<b)return-1;if(a>b)return 1},numeric:function(a){return a===null||_.isNaN(+a)?null:+a}},string:{name:"string",coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)||a===null?null:_.isNumber(+a)?+a:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a===null||_.isNaN(a)?null:a?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(a){var b=+a;return _.isNull(a)||typeof a=="undefined"||_.isNaN(b)?null:b},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return _.isNaN(a)||a===null?null:a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isNull(a)||typeof a=="undefined"||_.isNaN(a))return null;if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(a)||a===null?null:a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Event=function(a){_.isArray(a)||(a=[a]),this.deltas=a},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a==="_id"}).value()}),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a){return new b.Event(a)}}(this,_),function(a,_){var b=a.Miso||{};b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName._id].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},compute:function(a,b){if(this.func){var c=this.func(a);return typeof b!="undefined"?this.data[b]=c:this.data.push(c),c}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.filter={columns:this._columnFilter(a.filter.columns||undefined),rows:this._rowFilter(a.filter.rows||undefined)},this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c._id];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={_id:c._id,old:this.rowByPosition(f),changed:{}};a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.filter=c.filter||{},_.isFunction(a)?c.filter.rows=a:c.filter=a,c.parent=this,new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push("_id"),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=function(b){return _.indexOf(a,b._id)===-1?!1:!0},b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a==="_id"||a==="_oids"})},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(e.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column '"+e.name+"' with type "+e.type}},this),this._computedColumns&&_.each(this._computedColumns,function(b){var c=b.compute(a);a[b.name]=c});if(_.isUndefined(this.comparator))_.each(this._columns,function(b){b.isComputed()||b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={}),this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=this._rowIdByPosition.length;else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f._id)||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=b})}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={};_.isFunction(a)?b.comparator=a:b=a||b,b.comparator&&(this.comparator=b.comparator);if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var c=this.length,d;if(c===1)return;var e=_.bind(function(a,b){var c=this.rowByPosition(b);_.each(c,function(c,d){var e=this._columnPositionByName[d],f=this._columns[e].data[a];this._columns[e].data.splice(a,1,c),this._columns[e].data.splice(b,1,f)},this)},this),f=_.bind(function(a,b){var c=a,d;while(c*2<=b){d=c*2;var f=this.rowByPosition(c);d+1<b&&this.comparator(this.rowByPosition(d),this.rowByPosition(d+1))<0&&d++;if(this.comparator(f,this.rowByPosition(d))<0)e(c,d),c=d;else return}},this),g=function(a){var b=Math.round((a-2)/2);while(b>=0)f(b,a-1),b--};if(c>2){g(c),d=c-1;while(d>1)e(d,0),d--,f(0,d)}else this.comparator(this.rowByPosition(0),this.rowByPosition(1))>0&&e(0,1);return this.comparator(this.rowByPosition(this.length-2),this.rowByPosition(this.length-1))>0&&e(this.length-1,this.length-2),this.syncable&&b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_){var b=a.Miso;b.Product=b.Product||function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),b.Product.define=function(a){return function(c,d){d=d||{};var e=this._findColumns(c),f=this;d.type=d.type||e[0].type,d.typeOptions=d.typeOptions||e[0].typeOptions;var g=function(){var c=a.call(f,e,d);return b.types[d.type].coerce(c,d.typeOptions)};if(this.syncable){var h=new b.Product({columns:e,func:function(a){a=a||{};var b=this._buildDelta(this.value,g.call(f));this.value=b.changed;if(f.syncable){var c=this._buildEvent(b);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",c)}}});return this.bind("change",h._sync,h),h}return g.call(f)}},_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:b.Product.define(function(a,c){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}),max:b.Product.define(function(a,b){return _.max(_.map(a,function(a){return a._max()}))}),min:b.Product.define(function(a,b){return _.min(_.map(a,function(a){return a._min()}))}),mean:b.Product.define(function(a,c){var d=[];_.each(a,function(a){d.push(a.data)}),d=_.flatten(d);var e=a[0].type;return d=_.map(d,function(a){return b.types[e].numeric(a)}),_.mean(d)})})}(this,_),function(a,_,moment){var b=a.Miso;b.Dataset=function(a){this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],typeof a!="undefined"&&(a=a||{},this._initialize(a))},b.Dataset.prototype=new b.DataView,_.extend(b.Dataset.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var c=[],d=_.keys(a),e,f=this.uniqueAgainst,g=this.column(f),h=[],i=[],j=[];_.each(a[f],function(c,d){var e=g.data.indexOf(b.types[g.type].coerce(c)),f={};_.each(a,function(a,b){f[b]=a[d]});if(e===-1)h.push(f);else{i.push(f);var j=this.rowById(this.column("_id").data[e])._id;this.update(j,f)}},this),h.length>0&&this.add(h)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addComputedColumn:function(a,c,d){if(!_.isUndefined(this.column(a)))throw"There is already a column by this name.";if(typeof b.types[c]=="undefined")throw"The type "+c+" doesn't exist";var e=new b.Column({name:a,type:c,func:_.bind(d,this)});return this._columns.push(e),this._computedColumns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,this.length>0&&this.each(function(a,b){e.compute(a,b)},this),e},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column("_id")))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())}),this.addColumn({name:"_id",type:"number",data:b});if(this._columnPositionByName._id!==0){var c=this._columns[this._columnPositionByName._id],d=this._columnPositionByName._id;this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName._id=0,_.each(this._columnPositionByName,function(a,b){b!=="_id"&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a._id||(a._id=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b._id),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c);this.trigger("remove",e),this.trigger("change",e)}},update:function(a,c,d){var e,f=[],g=_.bind(function(a,d){var g,h;_.isFunction(c)?h=c.apply(this,[a]):h=c,e=_.keys(h),_.each(e,function(a){g=this.column(a);if(g.isComputed())throw"You're trying to update a computed column. Those get computed!";var c=b.types[g.type];if(c)if(c.test(h[g.name],g))_.isUndefined(g.before)||(h[g.name]=g.before(h[g.name])),h[g.name]=c.coerce(h[g.name],g);else throw"incorrect value '"+h[g.name]+"' of type "+b.typeOf(h[g.name],g)+" passed to column '"+g.name+"' with type "+g.type;g.data[d]=h[g.name]},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(b){var c=_.extend({},a,h),e=c[b.name],f=b.compute(c,d);e!==f&&(h[b.name]=f)}),f.push({_id:a._id,old:a,changed:h})},this);_.isString(a)&&(a=[a]);if(_.isArray(a)){var h,i;_.each(a,function(a){h=this.rowById(a),i=this._rowPositionById[a],g(h,i)})}else a=this._rowFilter(a),this.each(function(b,c){a(b)&&g(b,c)},this);if(this.syncable&&(!d||!d.silent)){var j=this._buildEvent(f);this.trigger("update",j),this.trigger("change",j)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso||(a.Miso={});b.Derived=function(a){a=a||{},b.Dataset.call(this),this.parent=a.parent,this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b.Dataset,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column("_id").data=this.parent.column("_id").data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column("_id").data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d._column(a).data,g=d._column("count").data,h=d._column("_oids").data,i=d._column("_id").data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b._id])):(g[c]+=1,h[c].push(b._id))}),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){b.Builder.clearRowCache(this);var d={},e=0,f=this._columnPositionByName[a],g=this.parent.column(a);for(var h=0;h<this.parent.length;h++){var i=null;this.preprocess?i=this.preprocess(g.data[h]):i=g.data[h],_.isUndefined(d[i])&&(d[i]=e,_.each(c,function(a){var b=this.column(a),c=this.column("_id");b.data[e]=[],c.data[e]=_.uniqueId()},this),this.column(a).data[e]=i,e++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[h],e=d[i];b.data[e].push(this.parent.rowByPosition(h))},this)}var j=this._columns[this._columnPositionByName._oids];return j.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,d){_.isArray(c)&&(j.data[d]=j.data[d]||[],j.data[d].push(_.map(c,function(a){return a._id})),j.data[d]=_.flatten(j.data[d]),b.data[d]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return a.ActiveXObject?new a.ActiveXObject("Microsoft.XMLHTTP"):new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null;return a.ajax.onreadystatechange=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},b}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d.charAt(o))&&n++,o++;d=d.slice(o,p)}function q(a){var d=a[1];if(d.length&&d!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var g=null;a[2]?g=a[2].replace(new RegExp('""',"g"),'"'):g=a[3];if(k){g===""&&(g=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(g)}else{var i=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(g)||g==="")g="X";b.indexOf(g)!==-1&&(g=i(g)),b.push(g),c[g]=[]}}(new RegExp("^"+f)).test(d)&&q(["","",undefined,""]);while(i=a.exec(d))q(i)}catch(r){throw new Error("Error while parsing delimited data on row "+m+". Message: "+r.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_)
View
9 dist/miso.ds.deps.min.0.3.0.js
@@ -0,0 +1,9 @@
+/**
+* Miso.Dataset - v0.3.0 - 10/27/2012
+* http://github.com/misoproject/dataset
+* Copyright (c) 2012 Alex Graul, Irene Ros;
+* Dual Licensed: MIT, GPL
+* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
+* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
+*/
+(function(a){function D(a,b,c,d){var e=c.lang();return e[a].call?e[a](c,d):e[a][b]}function E(a,b){return function(c){return J(a.call(this,c),b)}}function F(a){return function(b){var c=a.call(this,b);return c+this.lang().ordinal(c)}}function G(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,this._lang=c||!1}function H(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=I(j/1e3),b.seconds=i%60,h+=I(i/60),b.minutes=h%60,g+=I(h/60),b.hours=g%24,f+=I(g/24),f+=e*7,b.days=f%30,d+=I(f/30),b.months=d%12,c+=I(d/12),b.years=c,this._lang=!1}function I(a){return a<0?Math.ceil(a):Math.floor(a)}function J(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function K(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(1).month(a.month()+f*c).date(Math.min(g,a.daysInMonth())))}function L(a){return Object.prototype.toString.call(a)==="[object Array]"}function M(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function N(a,b,c,d){var e,f,g=[];for(e=0;e<7;e++)g[e]=a[e]=a[e]==null?e===2?1:0:a[e];return a[7]=g[7]=b,a[8]!=null&&(g[8]=a[8]),a[3]+=c||0,a[4]+=d||0,f=new Date(0),b?(f.setUTCFullYear(a[0],a[1],a[2]),f.setUTCHours(a[3],a[4],a[5],a[6])):(f.setFullYear(a[0],a[1],a[2]),f.setHours(a[3],a[4],a[5],a[6])),f._a=g,f}function O(a,b){var c,d,f=[];!b&&g&&(b=require("./lang/"+a));for(c=0;c<h.length;c++)b[h[c]]=b[h[c]]||e.en[h[c]];for(c=0;c<12;c++)d=moment([2e3,c]),f[c]=new RegExp("^"+(b.months[c]||b.months(d,""))+"|^"+(b.monthsShort[c]||b.monthsShort(d,"")).replace(".",""),"i");return b.monthsParse=b.monthsParse||f,e[a]=b,b}function P(a){var b=typeof a=="string"&&a||a&&a._lang||null;return b?e[b]||O(b):moment}function Q(a){return a.match(/\[.*\]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function R(a){var b=a.match(j),c,d;for(c=0,d=b.length;c<d;c++)C[b[c]]?b[c]=C[b[c]]:b[c]=Q(b[c]);return function(e){var f="";for(c=0;c<d;c++)f+=typeof b[c].call=="function"?b[c].call(e,a):b[c];return f}}function S(a,b){function d(b){return a.lang().longDateFormat[b]||b}var c=5;while(c--&&k.test(b))b=b.replace(k,d);return z[b]||(z[b]=R(b)),z[b](a)}function T(a){switch(a){case"DDDD":return o;case"YYYY":return p;case"S":case"SS":case"SSS":case"DDD":return n;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return q;case"Z":case"ZZ":return r;case"T":return s;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return m;default:return new RegExp(a.replace("\\",""))}}function U(a,b,c,d){var e,f;switch(a){case"M":case"MM":c[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(e=0;e<12;e++)if(P().monthsParse[e].test(b)){c[1]=e,f=!0;break}f||(c[8]=!1);break;case"D":case"DD":case"DDD":case"DDDD":b!=null&&(c[2]=~~b);break;case"YY":c[0]=~~b+(~~b>70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(w),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}b==null&&(c[8]=!1)}function V(a,b){var c=[0,0,1,0,0,0,0],d={tzh:0,tzm:0},e=b.match(j),f,g;for(f=0;f<e.length;f++)g=(T(e[f]).exec(a)||[])[0],g&&(a=a.slice(a.indexOf(g)+g.length)),C[e[f]]&&U(e[f],g,c,d);return d.isPm&&c[3]<12&&(c[3]+=12),d.isPm===!1&&c[3]===12&&(c[3]=0),N(c,d.isUTC,d.tzh,d.tzm)}function W(a,b){var c,d=a.match(l)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=V(a,b[g]),e=S(new G(h),b[g]).match(l)||[],i=M(d,e),i<f&&(f=i,c=h);return c}function X(a){var b="YYYY-MM-DDT",c;if(t.exec(a)){for(c=0;c<4;c++)if(v[c][1].exec(a)){b+=v[c][0];break}return r.exec(a)?V(a,b+" Z"):V(a,b)}return new Date(a)}function Y(a,b,c,d,e){var f=e.relativeTime[a];return typeof f=="function"?f(b||1,!!c,a,d):f.replace(/%d/i,b||1)}function Z(a,b,d){var e=c(Math.abs(a)/1e3),f=c(e/60),g=c(f/60),h=c(g/24),i=c(h/365),j=e<45&&["s",e]||f===1&&["m"]||f<45&&["mm",f]||g===1&&["h"]||g<22&&["hh",g]||h===1&&["d"]||h<=25&&["dd",h]||h<=45&&["M"]||h<345&&["MM",c(h/30)]||i===1&&["y"]||["yy",i];return j[2]=b,j[3]=a>0,j[4]=d,Y.apply({},j)}function $(a,b){moment.fn[a]=function(a){var c=this._isUTC?"UTC":"";return a!=null?(this._d["set"+c+b](a),this):this._d["get"+c+b]()}}function _(a){moment.duration.fn[a]=function(){return this._data[a]}}function ba(a,b){moment.duration.fn["as"+a]=function(){return+this/b}}var moment,b="1.7.2",c=Math.round,d,e={},f="en",g=typeof module!="undefined"&&module.exports,h="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),i=/^\/?Date\((\-?\d+)/i,j=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g,k=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?)/g,l=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,m=/\d\d?/,n=/\d{1,3}/,o=/\d{3}/,p=/\d{1,4}/,q=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,r=/Z|[\+\-]\d\d:?\d\d/i,s=/T/i,t=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,u="YYYY-MM-DDTHH:mm:ssZ",v=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],w=/([\+\-]|\d\d)/gi,x="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),y={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},z={},A="DDD w M D d".split(" "),B="M D H h m s w".split(" "),C={M:function(){return this.month()+1},MMM:function(a){return D("monthsShort",this.month(),this,a)},MMMM:function(a){return D("months",this.month(),this,a)},D:function(){return this.date()},DDD:function(){var a=new Date(this.year(),this.month(),this.date()),b=new Date(this.year(),0,1);return~~((a-b)/864e5+1.5)},d:function(){return this.day()},dd:function(a){return D("weekdaysMin",this.day(),this,a)},ddd:function(a){return D("weekdaysShort",this.day(),this,a)},dddd:function(a){return D("weekdays",this.day(),this,a)},w:function(){var a=new Date(this.year(),this.month(),this.date()-this.day()+5),b=new Date(a.getFullYear(),0,4);return~~((a-b)/864e5/7+1.5)},YY:function(){return J(this.year()%100,2)},YYYY:function(){return J(this.year(),4)},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return~~(this.milliseconds()/100)},SS:function(){return J(~~(this.milliseconds()/10),2)},SSS:function(){return J(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+J(~~(a/60),2)+":"+J(~~a%60,2)},ZZ:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+J(~~(10*a/6),4)}};while(A.length)d=A.pop(),C[d+"o"]=F(C[d]);while(B.length)d=B.pop(),C[d+d]=E(C[d],2);C.DDDD=E(C.DDD,3),moment=function(b,c){if(b===null||b==="")return null;var d,e;return moment.isMoment(b)?new G(new Date(+b._d),b._isUTC,b._lang):(c?L(c)?d=W(b,c):d=V(b,c):(e=i.exec(b),d=b===a?new Date:e?new Date(+e[1]):b instanceof Date?b:L(b)?N(b):typeof b=="string"?X(b):new Date(b)),new G(d))},moment.utc=function(a,b){return L(a)?new G(N(a,!0),!0):(typeof a=="string"&&!r.exec(a)&&(a+=" +0000",b&&(b+=" Z")),moment(a,b).utc())},moment.unix=function(a){return moment(a*1e3)},moment.duration=function(a,b){var c=moment.isDuration(a),d=typeof a=="number",e=c?a._data:d?{}:a,f;return d&&(b?e[b]=a:e.milliseconds=a),f=new H(e),c&&(f._lang=a._lang),f},moment.humanizeDuration=function(a,b,c){return moment.duration(a,b===!0?null:b).humanize(b===!0?!0:c)},moment.version=b,moment.defaultFormat=u,moment.lang=function(a,b){var c;if(!a)return f;(b||!e[a])&&O(a,b);if(e[a]){for(c=0;c<h.length;c++)moment[h[c]]=e[a][h[c]];moment.monthsParse=e[a].monthsParse,f=a}},moment.langData=P,moment.isMoment=function(a){return a instanceof G},moment.isDuration=function(a){return a instanceof H},moment.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),moment.fn=G.prototype={clone:function(){return moment(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?this._a[8]!=null?!!this._a[8]:!M(this._a,(this._a[7]?moment.utc(this._a):moment(this._a)).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return S(this,a?a:moment.defaultFormat)},add:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return K(this,c,1),this},subtract:function(a,b){var c=b?moment.duration(+b,a):moment.duration(a);return K(this,c,-1),this},diff:function(a,b,d){var e=this._isUTC?moment(a).utc():moment(a).local(),f=(this.zone()-e.zone())*6e4,g=this._d-e._d-f,h=this.year()-e.year(),i=this.month()-e.month(),j=this.date()-e.date(),k;return b==="months"?k=h*12+i+j/30:b==="years"?k=h+(i+j/30)/12:k=b==="seconds"?g/1e3:b==="minutes"?g/6e4:b==="hours"?g/36e5:b==="days"?g/864e5:b==="weeks"?g/6048e5:g,d?k:c(k)},from:function(a,b){return moment.duration(this.diff(a)).lang(this._lang).humanize(!b)},fromNow:function(a){return this.from(moment(),a)},calendar:function(){var a=this.diff(moment().sod(),"days",!0),b=this.lang().calendar,c=b.sameElse,d=a<-6?c:a<-1?b.lastWeek:a<0?b.lastDay:a<1?b.sameDay:a<2?b.nextDay:a<7?b.nextWeek:c;return this.format(typeof d=="function"?d.apply(this):d)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<moment([this.year()]).zone()||this.zone()<moment([this.year(),5]).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return a==null?b:this.add({d:a-b})},startOf:function(a){switch(a.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return this},endOf:function(a){return this.startOf(a).add(a.replace(/s?$/,"s"),1).subtract("ms",1)},sod:function(){return this.clone().startOf("day")},eod:function(){return this.clone().endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return moment.utc([this.year(),this.month()+1,0]).date()},lang:function(b){return b===a?P(this):(this._lang=b,this)}};for(d=0;d<x.length;d++)$(x[d].toLowerCase(),x[d]);$("year","FullYear"),moment.duration.fn=H.prototype={weeks:function(){return I(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,c=this.lang().relativeTime,d=Z(b,!a,this.lang()),e=b<=0?c.past:c.future;return a&&(typeof e=="function"?d=e(d):d=e.replace(/%s/i,d)),d},lang:moment.fn.lang};for(d in y)y.hasOwnProperty(d)&&(ba(d,y[d]),_(d.toLowerCase()));ba("Weeks",6048e5),g&&(module.exports=moment),typeof ender=="undefined"&&(this.moment=moment),typeof define=="function"&&define.amd&&define("moment",[],function(){return moment})}).call(this),function(a,b){function bj(a){if(a&&a.__wrapped__)return a;if(this instanceof bj)this.__wrapped__=a;else return new bj(a)}function bo(a,b,c){b||(b=0);var d=a.length,e=d-b>=(c||i),f=e?{}:a;if(e){var g=b-1;while(++g<d){var h=a[g]+"";(B.call(f,h)?f[h]:f[h]=[]).push(a[g])}}return function(a){if(e){var c=a+"";return B.call(f,c)&&cD(f[c],a)>-1}return cD(f,a,b)>-1}}function bp(a,c){var d=a.index,e=c.index;a=a.criteria,c=c.criteria;if(a!==c){if(a>c||a===b)return 1;if(a<c||c===b)return-1}return d<e?-1:1}function bq(a,b,c){function g(){var h=arguments,i=e?this:b;d||(a=b[f]),c.length&&(h=h.length?c.concat(E.call(h)):c);if(this instanceof g){bv.prototype=a.prototype,i=new bv;var j=a.apply(i,h);return j&&bh[typeof j]?j:i}return a.apply(i,h)}var d=bR(a),e=!c,f=a;return e&&(c=b),g}function br(a,c){return a?typeof a!="function"?function(b){return b[a]}:c!==b?function(b,d,e){return a.call(c,b,d,e)}:a:dc}function bs(){var a={arrayLoop:"",bottom:"",hasDontEnumBug:W,isKeysFast:be,objectLoop:"",noArgsEnum:Z,noCharByIndex:ba,shadowed:v,top:"",useHas:!0};for(var b,c=0;b=arguments[c];c++)for(var d in b)a[d]=b[d];var e=a.args;a.firstArg=/^[^,]+/.exec(e)[0];var f=Function("createCallback, hasOwnProperty, isArguments, objectTypes, nativeKeys, propertyIsEnumerable, stringClass, toString","return function("+e+") {\n"+bk(a)+"\n}");return f(br,B,bx,bh,J,D,V,F)}function bt(a){return"\\"+bi[a]}function bu(a){return bC[a]}function bv(){}function bw(a){return bD[a]}function bx(a){return F.call(a)==N}function bA(a){var b=!1;if(!a||typeof a!="object"||bx(a))return b;var c=a.constructor;return(!bb||typeof a.toString=="function"||typeof (a+"")!="string")&&(!bR(c)||c instanceof c)?X?(by(a,function(a,c,d){return b=!B.call(d,c),!1}),b===!1):(by(a,function(a,c){b=c}),b===!1||B.call(a,b)):b}function bB(a){var b=[];return bz(a,function(a,c){b.push(c)}),b}function bE(a,b,c,d,e){if(a==null)return a;c&&(b=!1);var f=bh[typeof a];if(f){var g=F.call(a);if(!bg[g]||$&&bx(a))return a;var h=g==O;f=h||(g==T?bW(a):f)}if(!f||!b)return f?h?E.call(a):bG({},a):a;var i=a.constructor;switch(g){case P:case Q:return new i(+a);case S:case V:return new i(a);case U:return i(a.source,p.exec(a))}d||(d=[]),e||(e=[]);var j=d.length;while(j--)if(d[j]==a)return e[j];var k=h?i(a.length):{};return d.push(a),e.push(k),(h?cj:bz)(a,function(a,c){k[c]=bE(a,b,null,d,e)}),k}function bH(a){var b=[];return by(a,function(a,c){bR(a)&&b.push(c)}),b.sort()}function bI(a,b){return a?B.call(a,b):!1}function bJ(a){var b={};return bz(a,function(a,c){b[a]=c}),b}function bL(a){return a===!0||a===!1||F.call(a)==P}function bM(a){return F.call(a)==Q}function bN(a){return a?a.nodeType===1:!1}function bO(a){var b=!0;if(!a)return b;var c=F.call(a),d=a.length;return c==O||c==V||c==N||$&&bx(a)||c==T&&typeof d=="number"&&bR(a.splice)?!d:(bz(a,function(){return b=!1}),b)}function bP(a,b,c,d){if(a===b)return a!==0||1/a==1/b;if(a==null||b==null)return a===b;var e=F.call(a);if(e!=F.call(b))return!1;switch(e){case P:case Q:return+a==+b;case S:return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case U:case V:return a==b+""}var f=e==O||e==N;if($&&!f&&(f=bx(a))&&!bx(b))return!1;if(!f){if(a.__wrapped__||b.__wrapped__)return bP(a.__wrapped__||a,b.__wrapped__||b);if(e!=T||bb&&(typeof a.toString!="function"&&typeof (a+"")=="string"||typeof b.toString!="function"&&typeof (b+"")=="string"))return!1;var g=a.constructor,h=b.constructor;if(g!=h&&!(bR(g)&&g instanceof g&&bR(h)&&h instanceof h))return!1}c||(c=[]),d||(d=[]);var i=c.length;while(i--)if(c[i]==a)return d[i]==b;var j=-1,k=!0,l=0;c.push(a),d.push(b);if(f){l=a.length,k=l==b.length;if(k)while(l--)if(!(k=bP(a[l],b[l],c,d)))break;return k}for(var m in a)if(B.call(a,m)){l++;if(!B.call(b,m)||!bP(a[m],b[m],c,d))return!1}for(m in b)if(B.call(b,m)&&!(l--))return!1;if(W)while(++j<7){m=v[j];if(B.call(a,m)&&(!B.call(b,m)||!bP(a[m],b[m],c,d)))return!1}return!0}function bQ(a){return I(a?+a:parseFloat(a))}function bR(a){return typeof a=="function"}function bS(a){return a?bh[typeof a]:!1}function bT(a){return F.call(a)==S&&a!=+a}function bU(a){return a===null}function bV(a){return F.call(a)==S}function bX(a){return F.call(a)==U}function bY(a){return F.call(a)==V}function bZ(a){return a===b}function b_(a,b,c){var d=arguments,e=0,f=2,g=d[3],i=d[4];c!==h&&(g=[],i=[],f=d.length);while(++e<f)bz(d[e],function(b,c){var d,e,f;if(b&&((e=bK(b))||bW(b))){var j=g.length;while(j--){d=g[j]==b;if(d)break}d?a[c]=i[j]:(g.push(b),i.push(f=(f=a[c],e)?bK(f)?f:[]:bW(f)?f:{}),a[c]=b_(f,b,h,g,i))}else b!=null&&(a[c]=b)});return a}function ca(a,b,c){var d=typeof b=="function",f={};if(d)b=br(b,c);else var g=y.apply(e,arguments);return by(a,function(a,c,e){if(d?!b(a,c,e):cD(g,c,1)<0)f[c]=a}),f}function cb(a){var b=[];return bz(a,function(a,c){b.push([c,a])}),b}function cc(a,b,c){var d={};if(typeof b!="function"){var f=0,g=y.apply(e,arguments),h=g.length;while(++f<h){var i=g[f];i in a&&(d[i]=a[i])}}else b=br(b,c),by(a,function(a,c,e){b(a,c,e)&&(d[c]=a)});return d}function cd(a){var b=[];return bz(a,function(a){b.push(a)}),b}function ce(a,b){var c=a?a.length:0;return typeof c=="number"?(F.call(a)==V?a.indexOf(b):cD(a,b))>-1:cv(a,function(a){return a===b})}function cf(a,b,c){var d={};return b=br(b,c),cj(a,function(a,c,e){c=b(a,c,e),B.call(d,c)?d[c]++:d[c]=1}),d}function cg(a,b,c){var d=!0;return b=br(b,c),cj(a,function(a,c,e){return d=b(a,c,e)}),!!d}function ch(a,b,c){var d=[];return b=br(b,c),cj(a,function(a,c,e){b(a,c,e)&&d.push(a)}),d}function ci(a,b,c){var d;return b=br(b,c),cv(a,function(a,c,e){return b(a,c,e)&&(d=a,!0)}),d}function ck(a,b,c){var d={};return b=br(b,c),cj(a,function(a,c,e){c=b(a,c,e),(B.call(d,c)?d[c]:d[c]=[]).push(a)}),d}function cl(a,b){var c=E.call(arguments,2),d=typeof b=="function",e=[];return cj(a,function(a){e.push((d?b:a[b]).apply(a,c))}),e}function cm(a,b,c){var d=-1,e=a?a.length:0,f=Array(typeof e=="number"?e:0);b=br(b,c);if(bK(a))while(++d<e)f[d]=b(a[d],d,a);else cj(a,function(a,c,e){f[++d]=b(a,c,e)});return f}function cn(a,b,c){var d=-Infinity,e=-1,f=a?a.length:0,g=d;if(b||typeof f!="number")b=br(b,c),cj(a,function(a,c,e){var f=b(a,c,e);f>d&&(d=f,g=a)});else while(++e<f)a[e]>g&&(g=a[e]);return g}function co(a,b,c){var d=Infinity,e=-1,f=a?a.length:0,g=d;if(b||typeof f!="number")b=br(b,c),cj(a,function(a,c,e){var f=b(a,c,e);f<d&&(d=f,g=a)});else while(++e<f)a[e]<g&&(g=a[e]);return g}function cp(a,b){var c=[];return cj(a,function(a){c.push(a[b])}),c}function cq(a,b,c,d){var e=arguments.length<3;return b=br(b,d),cj(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)}),c}function cr(a,b,c,d){var e=a,f=a?a.length:0,g=arguments.length<3;if(typeof f!="number"){var h=b$(a);f=h.length}else ba&&F.call(a)==V&&(e=a.split(""));return cj(a,function(a,i,j){i=h?h[--f]:--f,c=g?(g=!1,e[i]):b.call(d,c,e[i],i,j)}),c}function cs(a,b,c){return b=br(b,c),ch(a,function(a,c,d){return!b(a,c,d)})}function ct(a){var b=-1,c=Array(a?a.length:0);return cj(a,function(a){var d=z(M()*(++b+1));c[b]=c[d],c[d]=a}),c}function cu(a){var b=a?a.length:0;return typeof b=="number"?b:b$(a).length}function cv(a,b,c){var d;return b=br(b,c),cj(a,function(a,c,e){return!(d=b(a,c,e))}),!!d}function cw(a,b,c){var d=[];b=br(b,c),cj(a,function(a,c,e){d.push({criteria:b(a,c,e),index:c,value:a})});var e=d.length;d.sort(bp);while(e--)d[e]=d[e].value;return d}function cx(a){return a&&typeof a.length=="number"?(_?F.call(a)==V:typeof a=="string")?a.split(""):E.call(a):cd(a)}function cy(a,b){var c=[];return by(b,function(a,b){c.push(b)}),ch(a,function(a){var d=c.length;while(d--){var e=a[c[d]]===b[c[d]];if(!e)break}return!!e})}function cz(a){var b=-1,c=a?a.length:0,d=[];while(++b<c){var e=a[b];e&&d.push(e)}return d}function cA(a){var b=-1,c=a?a.length:0,d=y.apply(e,arguments),f=bo(d,c),g=[];while(++b<c){var h=a[b];f(h)||g.push(h)}return g}function cB(a,b,c){if(a)return b==null||c?a[0]:E.call(a,0,b)}function cC(a,b){var c=-1,d=a?a.length:0,e=[];while(++c<d){var f=a[c];bK(f)?C.apply(e,b?f:cC(f)):e.push(f)}return e}function cD(a,b,c){var d=-1,e=a?a.length:0;if(typeof c=="number")d=(c<0?K(0,e+c):c||0)-1;else if(c)return d=cL(a,b),a[d]===b?d:-1;while(++d<e)if(a[d]===b)return d;return-1}function cE(a,b,c){return a?E.call(a,0,-(b==null||c?1:b)):[]}function cF(a){var b=arguments,c=b.length,d={},e=[];return cj(a,function(a){if(cD(e,a)<0){var f=c;while(--f)if(!(d[f]||(d[f]=bo(b[f])))(a))return;e.push(a)}}),e}function cG(a,b,c){if(a){var d=a.length;return b==null||c?a[d-1]:E.call(a,-b||d)}}function cH(a,b,c){var d=a?a.length:0;typeof c=="number"&&(d=(c<0?K(0,d+c):L(c,d-1))+1);while(d--)if(a[d]===b)return d;return-1}function cI(a,b){var c=-1,d=a?a.length:0,e={};while(++c<d){var f=a[c];b?e[f]=b[c]:e[f[0]]=f[1]}return e}function cJ(a,b,c){a=+a||0,c=+c||1,b==null&&(b=a,a=0);var d=-1,e=K(0,x((b-a)/c)),f=Array(e);while(++d<e)f[d]=a,a+=c;return f}function cK(a,b,c){return a?E.call(a,b==null||c?1:b):[]}function cL(a,b,c,d){var e=0,f=a?a.length:e;c=c?br(c,d):dc,b=c(b);while(e<f){var g=e+f>>>1;c(a[g])<b?e=g+1:f=g}return e}function cM(){var a=-1,b=y.apply(e,arguments),c=b.length,d=[];while(++a<c){var f=b[a];cD(d,f)<0&&d.push(f)}return d}function cN(a,b,c,d){var e=-1,f=a?a.length:0,g=[],h=[];typeof b=="function"&&(d=c,c=b,b=!1),c=br(c,d);while(++e<f){var i=c(a[e],e,a);if(b?!e||h[h.length-1]!==i:cD(h,i)<0)h.push(i),g.push(a[e])}return g}function cO(a){var b=-1,c=a?a.length:0,d=bo(arguments,1,20),e=[];while(++b<c){var f=a[b];d(f)||e.push(f)}return e}function cP(a){var b=-1,c=a?cn(cp(arguments,"length")):0,d=Array(c);while(++b<c)d[b]=cp(arguments,b);return d}function cQ(a,b){return a<1?b():function(){if(--a<1)return b.apply(this,arguments)}}function cR(a,b){return bd||G&&arguments.length>2?G.call.apply(G,arguments):bq(a,b,E.call(arguments,2))}function cS(a){var b=arguments,c=b.length>1?0:(b=bH(a),-1),d=b.length;while(++c<d){var e=b[c];a[e]=cR(a[e],a)}return a}function cT(){var a=arguments;return function(){var b=arguments,c=a.length;while(c--)b=[a[c].apply(this,b)];return b[0]}}function cU(a,b,c){function h(){g=null,c||(e=a.apply(f,d))}var d,e,f,g;return function(){var i=c&&!g;return d=arguments,f=this,clearTimeout(g),g=setTimeout(h,b),i&&(e=a.apply(f,d)),e}}function cV(a,c){var d=E.call(arguments,2);return setTimeout(function(){a.apply(b,d)},c)}function cW(a){var c=E.call(arguments,1);return setTimeout(function(){a.apply(b,c)},1)}function cX(a,b){return bq(b,a,E.call(arguments,2))}function cY(a,b){var c={};return function(){var d=b?b.apply(this,arguments):arguments[0];return B.call(c,d)?c[d]:c[d]=a.apply(this,arguments)}}function cZ(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}}function c$(a){return bq(a,E.call(arguments,1))}function c_(a,b){function h(){g=new Date,f=null,d=a.apply(e,c)}var c,d,e,f,g=0;return function(){var i=new Date,j=b-(i-g);return c=arguments,e=this,j<=0?(clearTimeout(f),g=i,d=a.apply(e,c)):f||(f=setTimeout(h,j)),d}}function da(a,b){return function(){var c=[a];return C.apply(c,arguments),b.apply(this,c)}}function db(a){return a==null?"":(a+"").replace(t,bu)}function dc(a){return a}function dd(a){cj(bH(a),function(b){var c=bj[b]=a[b];bj.prototype[b]=function(){var a=[this.__wrapped__];C.apply(a,arguments);var b=c.apply(bj,a);return this.__chain__&&(b=new bj(b),b.__chain__=!0),b}})}function de(){return a._=j,this}function df(a,b){return a==null&&b==null&&(b=1),a=+a||0,b==null&&(b=a,a=0),a+z(M()*((+b||0)-a+1))}function dg(a,b){var c=a?a[b]:null;return bR(c)?a[b]():c}function dh(a,b,c){a||(a=""),c||(c={});var d,e,f=0,g=bj.templateSettings,h="__p += '",i=c.variable||g.variable,j=i,l=RegExp((c.escape||g.escape||s).source+"|"+(c.interpolate||g.interpolate||s).source+"|"+(c.evaluate||g.evaluate||s).source+"|$","g");a.replace(l,function(b,c,e,g,i){h+=a.slice(f,i).replace(u,bt),h+=c?"' +\n__e("+c+") +\n'":g?"';\n"+g+";\n__p += '":e?"' +\n((__t = ("+e+")) == null ? '' : __t) +\n'":"",d||(d=g||k.test(c||e)),f=i+b.length}),h+="';\n";if(!j){i="obj";if(d)h="with ("+i+") {\n"+h+"\n}\n";else{var p=RegExp("(\\(\\s*)"+i+"\\."+i+"\\b","g");h=h.replace(q,"$&"+i+".").replace(p,"$1__d")}}h=(d?h.replace(m,""):h).replace(n,"$1").replace(o,"$1;"),h="function("+i+") {\n"+(j?"":i+" || ("+i+" = {});\n")+"var __t, __p = '', __e = _.escape"+(d?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":(j?"":", __d = "+i+"."+i+" || "+i)+";\n")+h+"return __p\n}";var r=bf?"\n//@ sourceURL="+(c.sourceURL||"/lodash/template/source["+w++ +"]"):"";try{e=Function("_","return "+h+r)(bj)}catch(t){throw t.source=h,t}return b?e(b):(e.source=h,e)}function di(a,b,c){a=+a||0;var d=-1,e=Array(a);while(++d<a)e[d]=b.call(c,d);return e}function dj(a){return a==null?"":(a+"").replace(l,bw)}function dk(a){var b=g++;return a?a+b:b}function dl(a){return a=new bj(a),a.__chain__=!0,a}function dm(a,b){return b(a),a}function dn(){return this.__chain__=!0,this}function dp(){return this.__wrapped__}var c=typeof exports=="object"&&exports,d=typeof global=="object"&&global;d.global===d&&(a=d);var e=[],f={},g=0,h={},i=30,j=a._,k=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,l=/&(?:amp|lt|gt|quot|#x27);/g,m=/\b__p \+= '';/g,n=/\b(__p \+=) '' \+/g,o=/(__e\(.*?\)|\b__t\)) \+\n'';/g,p=/\w*$/,q=/(?:__e|__t = )\(\s*(?![\d\s"']|this\.)/g,r=RegExp("^"+(f.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),s=/($^)/,t=/[&<>"']/g,u=/['\n\r\t\u2028\u2029\\]/g,v=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],w=0,x=Math.ceil,y=e.concat,z=Math.floor,A=r.test(A=Object.getPrototypeOf)&&A,B=f.hasOwnProperty,C=e.push,D=f.propertyIsEnumerable,E=e.slice,F=f.toString,G=r.test(G=E.bind)&&G,H=r.test(H=Array.isArray)&&H,I=a.isFinite,J=r.test(J=Object.keys)&&J,K=Math.max,L=Math.min,M=Math.random,N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Function]",S="[object Number]",T="[object Object]",U="[object RegExp]",V="[object String]",W,X,Y=(Y={0:1,length:1},e.splice.call(Y,0,1),Y[0]),Z=!0;(function(){function b(){this.x=1}var a=[];b.prototype={valueOf:1,y:1};for(var c in new b)a.push(c);for(c in arguments)Z=!c;W=!/valueOf/.test(a),X=a[0]!="x"})(1);var $=!bx(arguments),_=E.call("x")[0]!="x",ba="x"[0]+Object("x")[0]!="xx";try{var bb=({toString:0}+"",F.call(a.document||0)==T)}catch(bc){}var bd=G&&/\n|Opera/.test(G+F.call(a.opera)),be=J&&/^.+$|true/.test(J+!!a.attachEvent);try{var bf=(Function("//@")(),!a.attachEvent)}catch(bc){}var bg={};bg[N]=bg[R]=!1,bg[O]=bg[P]=bg[Q]=bg[S]=bg[T]=bg[U]=bg[V]=!0;var bh={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},bi={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"};bj.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var bk=dh("<% if (obj.useStrict) { %>'use strict';\n<% } %>var index, value, iteratee = <%= firstArg %>, result = <%= firstArg %>;\nif (!<%= firstArg %>) return result;\n<%= top %>;\n<% if (arrayLoop) { %>var length = iteratee.length; index = -1;\nif (typeof length == 'number') { <% if (noCharByIndex) { %>\n if (toString.call(iteratee) == stringClass) {\n iteratee = iteratee.split('')\n } <% } %>\n while (++index < length) {\n value = iteratee[index];\n <%= arrayLoop %>\n }\n}\nelse { <% } else if (noArgsEnum) { %>\n var length = iteratee.length; index = -1;\n if (length && isArguments(iteratee)) {\n while (++index < length) {\n value = iteratee[index += ''];\n <%= objectLoop %>\n }\n } else { <% } %> <% if (!hasDontEnumBug) { %>\n var skipProto = typeof iteratee == 'function' && \n propertyIsEnumerable.call(iteratee, 'prototype');\n <% } %> <% if (isKeysFast && useHas) { %>\n var ownIndex = -1,\n ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n <% if (!hasDontEnumBug) { %>if (!(skipProto && index == 'prototype')) {\n <% } %> value = iteratee[index];\n <%= objectLoop %>\n <% if (!hasDontEnumBug) { %>}\n<% } %> } <% } else { %>\n for (index in iteratee) {<% if (!hasDontEnumBug || useHas) { %>\n if (<% if (!hasDontEnumBug) { %>!(skipProto && index == 'prototype')<% } if (!hasDontEnumBug && useHas) { %> && <% } if (useHas) { %>hasOwnProperty.call(iteratee, index)<% } %>) { <% } %>\n value = iteratee[index];\n <%= objectLoop %>; <% if (!hasDontEnumBug || useHas) { %>\n }<% } %>\n } <% } %> <% if (hasDontEnumBug) { %>\n\n var ctor = iteratee.constructor;\n <% for (var k = 0; k < 7; k++) { %>\n index = '<%= shadowed[k] %>';\n if (<% if (shadowed[k] == 'constructor') { %>!(ctor && ctor.prototype === iteratee) && <% } %>hasOwnProperty.call(iteratee, index)) {\n value = iteratee[index];\n <%= objectLoop %>\n } <% } %> <% } %> <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n<%= bottom %>;\nreturn result"),bl={args:"collection, callback, thisArg",top:"callback = createCallback(callback, thisArg)",arrayLoop:"if (callback(value, index, collection) === false) return result",objectLoop:"if (callback(value, index, collection) === false) return result"},bm={useHas:!1,args:"object",top:"for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n if (iteratee = arguments[argsIndex]) {",objectLoop:"result[index] = value",bottom:" }\n}"},bn={arrayLoop:null};$&&(bx=function(a){return a?B.call(a,"callee"):!1});var by=bs(bl,bn,{useHas:!1}),bz=bs(bl,bn),bC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},bD=bJ(bC),bF=bs(bm,{objectLoop:"if (result[index] == null) "+bm.objectLoop}),bG=bs(bm),bK=H||function(a){return F.call(a)==O};bR(/x/)&&(bR=function(a){return F.call(a)==R});var bW=A?function(a){if(!a||typeof a!="object")return!1;var b=a.valueOf,c=typeof b=="function"&&(c=A(b))&&A(c);return c?a==c||A(a)==c&&!bx(a):bA(a)}:bA,b$=J?function(a){var b=typeof a;return b=="function"&&D.call(a,"prototype")?bB(a):a&&bh[b]?J(a):[]}:bB,cj=bs(bl);bj.VERSION="0.9.0",bj.after=cQ,bj.bind=cR,bj.bindAll=cS,bj.chain=dl,bj.clone=bE,bj.compact=cz,bj.compose=cT,bj.contains=ce,bj.countBy=cf,bj.debounce=cU,bj.defaults=bF,bj.defer=cW,bj.delay=cV,bj.difference=cA,bj.escape=db,bj.every=cg,bj.extend=bG,bj.filter=ch,bj.find=ci,bj.first=cB,bj.flatten=cC,bj.forEach=cj,bj.forIn=by,bj.forOwn=bz,bj.functions=bH,bj.groupBy=ck,bj.has=bI,bj.identity=dc,bj.indexOf=cD,bj.initial=cE,bj.intersection=cF,bj.invert=bJ,bj.invoke=cl,bj.isArguments=bx,bj.isArray=bK,bj.isBoolean=bL,bj.isDate=bM,bj.isElement=bN,bj.isEmpty=bO,bj.isEqual=bP,bj.isFinite=bQ,bj.isFunction=bR,bj.isNaN=bT,bj.isNull=bU,bj.isNumber=bV,bj.isObject=bS,bj.isPlainObject=bW,bj.isRegExp=bX,bj.isString=bY,bj.isUndefined=bZ,bj.keys=b$,bj.last=cG,bj.lastIndexOf=cH,bj.lateBind=cX,bj.map=cm,bj.max=cn,bj.memoize=cY,bj.merge=b_,bj.min=co,bj.mixin=dd,bj.noConflict=de,bj.object=cI,bj.omit=ca,bj.once=cZ,bj.pairs=cb,bj.partial=c$,bj.pick=cc,bj.pluck=cp,bj.random=df,bj.range=cJ,bj.reduce=cq,bj.reduceRight=cr,bj.reject=cs,bj.rest=cK,bj.result=dg,bj.shuffle=ct,bj.size=cu,bj.some=cv,bj.sortBy=cw,bj.sortedIndex=cL,bj.tap=dm,bj.template=dh,bj.throttle=c_,bj.times=di,bj.toArray=cx,bj.unescape=dj,bj.union=cM,bj.uniq=cN,bj.uniqueId=dk,bj.values=cd,bj.where=cy,bj.without=cO,bj.wrap=da,bj.zip=cP,bj.all=cg,bj.any=cv,bj.collect=cm,bj.detect=ci,bj.drop=cK,bj.each=cj,bj.foldl=cq,bj.foldr=cr,bj.head=cB,bj.include=ce,bj.inject=cq,bj.methods=bH,bj.select=ch,bj.tail=cK,bj.take=cB,bj.unique=cN,bj._iteratorTemplate=bk,dd(bj),bj.prototype.chain=dn,bj.prototype.value=dp,cj(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=e[a];bj.prototype[a]=function(){var a=this.__wrapped__;return b.apply(a,arguments),Y&&a.length===0&&delete a[0],this.__chain__&&(a=new bj(a),a.__chain__=!0),a}}),cj(["concat","join","slice"],function(a){var b=e[a];bj.prototype[a]=function(){var a=this.__wrapped__,c=b.apply(a,arguments);return this.__chain__&&(c=new bj(c),c.__chain__=!0),c}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(a._=bj,define(function(){return bj})):c?typeof module=="object"&&module&&module.exports==c?(module.exports=bj)._=bj:c._=bj:a._=bj}(this),function(){var a=this.math={};a.mean=a.ave=a.average=function(b,c){return a.sum(b,c)/_(b).size()},a.median=function(b){var c=(b.length+1)/2,d=a.sort(b);return d.length%2?d[c-1]:(d[c-1.5]+d[c-.5])/2},a.pow=function(a,b){if(_.isNumber(a))return Math.pow(a,b);if(_.isArray(a))return _.map(a,function(a){return _.pow(a,b)})},a.scale=function(a,b){var b=b||1,c=_.max(a);return _.map(a,function(a){return a*(b/c)})},a.slope=function(a,b){return(b[1]-a[1])/(b[0]-a[0])},a.sort=function(a){return a.sort(function(a,b){return a-b})},a.stdDeviation=a.sigma=function(a){return Math.sqrt(_(a).variance())},a.sum=function(a,b){if(_.isArray(a)&&typeof a[0]=="number")var c=a;else var b=b||"value",c=_(a).pluck(b);var d=0;for(var e=0,f=c.length;e<f;e++)d+=c[e];return d},a.transpose=function(a){var b=[];return _(a).each(function(a,c){_(a).each(function(a,d){b[d]||(b[d]=[]),b[d][c]=a})}),b},a.variance=function(a){var b=_(a).mean();return _(a).chain().map(function(a){return _(a-b).pow(2)}).mean().value()},_.mixin(a)}(),function(a){function r(a){var b=q[a]={};return j(a.split(/\s+/),function(a){b[a]=!0}),b}var b={},c=Array.prototype,d=Object.prototype,e=d.hasOwnProperty,f=d.toString,g=c.forEach,h=c.indexOf,i=c.slice,j=function(a,c,d){var f,h,i;if(!a)return;if(g&&a.forEach===g)a.forEach(c,d);else if(a.length===+a.length){for(h=0,i=a.length;h<i;h++)if(h in a&&c.call(d,a[h],h,a)===b)return}else for(f in a)if(e.call(a,f)&&c.call(d,a[f],f,a)===b)return},k=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},l=function(a){return j(i.call(arguments,1),function(b){var c;for(c in b)b[c]!==void 0&&(a[c]=b[c])}),a},m=function(a,b,c){var d;if(b){if(h)return h.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},n={};j("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){n["[object "+a+"]"]=a.toLowerCase()});var o=function(a){return a==null?String(a):n[f.call(a)]||"object"},p={},q={};p.Callbacks=function(a){a=typeof a=="string"?q[a]||r(a):l({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],k=function(j){b=a.memory&&j,c=!0,g=e||0,e=0,f=h.length,d=!0;for(;h&&g<f;g++)if(h[g].apply(j[0],j[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&k(i.shift()):b?h=[]:n.disable())},n={add:function(){if(h){var c=h.length;(function g(b){j(b,function(b){var c=o(b);c==="function"&&(!a.unique||!n.has(b))?h.push(b):b&&b.length&&c!=="string"&&g(b)})})(arguments),d?f=h.length:b&&(e=c,k(b))}return this},remove:function(){return h&&j(arguments,function(a){var b;while((b=m(a,h,b))>-1)h.splice(b,1),d&&(b<=f&&f--,b<=g&&g--)}),this},has:function(a){return m(a,h)>-1},empty:function(){return h=[],this},disable:function(){return h=i=b=undefined,this},disabled:function(){return!h},lock:function(){return i=undefined,b||n.disable(),this},locked:function(){return!i},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],h&&(!c||i)&&(d?i.push(b):k(b)),this},fire:function(){return n.fireWith(this,arguments),this},fired:function(){return!!c}};return n},p.Deferred=function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){j(b,function(b,d){var f=b[0],g=a[d];e[b[1]](k(g)?function(){var a=g.apply(this,arguments);a&&k(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return typeof a=="object"?l(a,d):d}},e={};return d.pipe=d.then,j(b,function(a,f){var g=a[2],h=a[3];d[a[1]]=g.add,h&&g.add(function(){c=h},b[f^1][2].disable,b[2][2].lock),e[a[0]]=g.fire,e[a[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},p.when=function(a){var b=0,c=i.call(arguments),d=c.length,e=d!==1||a&&k(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?i.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,j,l;if(d>1){h=new Array(d),j=new Array(d),l=new Array(d);for(;b<d;b++)c[b]&&k(c[b].promise)?c[b].promise().done(g(b,l,c)).fail(f.reject).progress(g(b,j,h)):--e}return e||f.resolveWith(l,c),f.promise()},typeof module!="undefined"&&module.exports?module.exports=p:typeof a._!="undefined"?a._.mixin(p):a._=p}(this),function(a){a.Miso=a.Miso||{},a.Miso.Dataset=function(a){a=a||{},this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],this._initialize(a)}}(this),function(a,_){var b=a.Miso.Dataset;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},compute:function(a,b){if(this.func){var c=this.func(a);return typeof b!="undefined"?this.data[b]=c:this.data.push(c),c}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=this.parent.idAttribute,this.filter={},this.filter.columns=_.bind(this._columnFilter(a.filter.columns||undefined),this),this.filter.rows=_.bind(this._rowFilter(a.filter.rows||undefined),this),this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c[this.idAttribute]];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={old:this.rowByPosition(f),changed:{}};h[this.idAttribute]=c[this.idAttribute],a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.filter=c.filter||{},_.isFunction(a)?c.filter.rows=a:c.filter=a,c.parent=this,new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push(this.idAttribute),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=_.bind(function(b){return _.indexOf(a,b[this.idAttribute])===-1?!1:!0},this),b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a===this.idAttribute||a==="_oids"},this)},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(e.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column '"+e.name+"' with type "+e.type}},this),this._computedColumns&&_.each(this._computedColumns,function(b){var c=b.compute(a);a[b.name]=c});if(_.isUndefined(this.comparator)){_.each(this._columns,function(b){b.isComputed()||b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={});if(typeof this._rowPositionById[a[this.idAttribute]]!="undefined")throw"The id "+a[this.idAttribute]+" is not unique. The "+this.idAttribute+" column must be unique";this._rowPositionById[a[this.idAttribute]]=this._rowIdByPosition.length,this._rowIdByPosition.push(a[this.idAttribute])}else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f[this.idAttribute])||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a[this.idAttribute]),this._rowPositionById[a[this.idAttribute]]=b},this)}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={},c=[];_.isFunction(a)?b.comparator=a:b=a||{};if(b.comparator)this.comparator=b.comparator;else if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var d,e,f;for(d=0;d<this.length;d++)c[d]=this._row(d);c.sort(this.comparator),d=c.length;while(d--){f=c[d],this._rowIdByPosition[d]=f[this.idAttribute],this._rowPositionById[f[this.idAttribute]]=d,e=this._columns.length;while(e--){var g=this._columns[e];g.data[d]=f[g.name]}}return this.syncable&&!b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_,moment){var b=a.Miso.Dataset;b.prototype=new b.DataView,_.extend(b.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=a.idAttribute||"_id",this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var c=[],d=_.keys(a),e,f=this.uniqueAgainst,g=this.column(f),h=[],i=[],j=[];_.each(a[f],function(c,d){var e=g.data.indexOf(b.types[g.type].coerce(c)),f={};_.each(a,function(a,b){f[b]=a[d]}),e===-1?h.push(f):(i.push(f),f[this.idAttribute]=this.rowById(this.column(this.idAttribute).data[e])[this.idAttribute],this.update(f))},this),h.length>0&&this.add(h)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addComputedColumn:function(a,c,d){if(!_.isUndefined(this.column(a)))throw"There is already a column by this name.";if(typeof b.types[c]=="undefined")throw"The type "+c+" doesn't exist";var e=new b.Column({name:a,type:c,func:_.bind(d,this)});return this._columns.push(e),this._computedColumns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,this.length>0&&this.each(function(a,b){e.compute(a,b)},this),e},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column(this.idAttribute)))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())});var c=this.addColumn({name:this.idAttribute,data:b});this.idAttribute==="_id"&&(c.type="number");if(this._columnPositionByName[this.idAttribute]!==0){var d=this._columnPositionByName[this.idAttribute];this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName[this.idAttribute]=0,_.each(this._columnPositionByName,function(a,b){b!==this.idAttribute&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a[this.idAttribute]||(a[this.idAttribute]=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c,this);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b[this.idAttribute]),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("remove",e),this.trigger("change",e)}},_arrayUpdate:function(a){var c=[];return _.each(a,function(a){var d={old:{},changed:{}};d[this.idAttribute]=a[this.idAttribute];var e=this._rowPositionById[a[this.idAttribute]];_.each(a,function(a,c){var f=this._columns[this._columnPositionByName[c]],g=b.types[f.type];if(f.name===this.idAttribute&&f.data[e]!==a)throw"You can't update the id column";if(typeof f=="undefined")throw"column "+c+" not found!";if(!g.test(a,f))throw"Value is incorrect type";if(this._computedColumns[f.name])return;a=g.coerce(a,f),_.isUndefined(f.before)||(a=f.before(a)),f.data[e]!==a&&(d.old[c]=f.data[e],f.data[e]=a,d.changed[c]=a)},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(a){var b=_.extend({},this._row(e)),c=b[a.name],f=a.compute(b,e);c!==f&&(d.old[a.name]=c,a.data[e]=f,d.changed[a.name]=f)},this),_.keys(d.changed).length>0&&c.push(d)},this),c},_functionUpdate:function(a){var b=[];for(var c=0;c<this.length;c++){var d=a(this.rowByPosition(c));d!==!1&&b.push(d)}return this._arrayUpdate(b)},update:function(a,b){var c;if(_.isFunction(a))c=this._functionUpdate(a);else{var d=_.isArray(a)?a:[a];c=this._arrayUpdate(d)}if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("update",e),this.trigger("change",e)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso.Dataset;b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return _.isNull(a)||typeof a=="undefined"||_.isNaN(a)?null:a},test:function(a){return!0},compare:function(a,b){if(_.isEqual(a,b))return 0;if(a<b)return-1;if(a>b)return 1},numeric:function(a){return a===null||_.isNaN(+a)?null:+a}},string:{name:"string",coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)||a===null?null:_.isNumber(+a)?+a:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a===null||_.isNaN(a)?null:a?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(a){var b=+a;return _.isNull(a)||typeof a=="undefined"||_.isNaN(b)?null:b},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return _.isNaN(a)||a===null?null:a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isNull(a)||typeof a=="undefined"||_.isNaN(a))return null;if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(a)||a===null?null:a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Event=function(a,b){_.isArray(a)||(a=[a]),this.deltas=a,this.dataset=b||null},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a===this.dataset.idAttribute},this).value()},this),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a,c){return new b.Event(a,c)}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName[a.idAttribute]].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Product=function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),b.Product.define=function(a){return function(c,d){d=d||{};var e=this._findColumns(c),f=this;d.type=d.type||e[0].type,d.typeOptions=d.typeOptions||e[0].typeOptions;var g=function(){var c=a.call(f,e,d);return b.types[d.type].coerce(c,d.typeOptions)};if(this.syncable){var h=new b.Product({columns:e,func:function(a){a=a||{};var b=this._buildDelta(this.value,g.call(f));this.value=b.changed;if(f.syncable){var c=this._buildEvent(b,this);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",c)}}});return this.bind("change",h._sync,h),h}return g.call(f)}},_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:b.Product.define(function(a,c){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}),max:b.Product.define(function(a,b){return _.max(_.map(a,function(a){return a._max()}))}),min:b.Product.define(function(a,b){return _.min(_.map(a,function(a){return a._min()}))}),mean:b.Product.define(function(a,c){var d=[];_.each(a,function(a){d.push(a.data)}),d=_.flatten(d);var e=a[0].type;return d=_.map(d,function(a){return b.types[e].numeric(a)}),_.mean(d)})})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return a.ActiveXObject?new a.ActiveXObject("Microsoft.XMLHTTP"):new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null,d;return d=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},a.ajax.readyState===4?d():a.ajax.onreadystatechange=d,b}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d.charAt(o))&&n++,o++;d=d.slice(o,p)}function q(a){var d=a[1];if(d.length&&d!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var g=null;a[2]?g=a[2].replace(new RegExp('""',"g"),'"'):g=a[3];if(k){g===""&&(g=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(g)}else{var i=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(g)||g==="")g="X";b.indexOf(g)!==-1&&(g=i(g)),b.push(g),c[g]=[]}}(new RegExp("^"+f)).test(d)&&q(["","",undefined,""]);while(i=a.exec(d))q(i)}catch(r){throw new Error("Error while parsing delimited data on row "+m+". Message: "+r.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Derived=function(a){a=a||{},b.call(this),this.parent=a.parent,this.idAttribute="_id",this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){if(a===this.idAttribute)throw"You can't compute a moving average on the id column";e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column(this.idAttribute).data=this.parent.column(this.parent.idAttribute).data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column(this.parent.idAttribute).data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d.column(a).data,g=d.column("count").data,h=d.column("_oids").data,i=d.column(d.idAttribute).data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b[this.parent.idAttribute]])):(g[c]+=1,h[c].push(b[this.parent.idAttribute]))},d),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){var d=this;b.Builder.clearRowCache(this);var e={},f=0,g=this._columnPositionByName[a],h=this.parent.column(a);for(var i=0;i<this.parent.length;i++){var j=null;this.preprocess?j=this.preprocess(h.data[i]):j=h.data[i],_.isUndefined(e[j])&&(e[j]=f,_.each(c,function(a){var b=this.column(a),c=this.column(this.idAttribute);b.data[f]=[],c.data[f]=_.uniqueId()},this),this.column(a).data[f]=j,f++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[i],d=e[j];b.data[d].push(this.parent.rowByPosition(i))},this)}var k=this._columns[this._columnPositionByName._oids];return k.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,e){_.isArray(c)&&(k.data[e]=k.data[e]||[],k.data[e].push(_.map(c,function(a){return a[d.parent.idAttribute]})),k.data[e]=_.flatten(k.data[e]),b.data[e]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_)
View
BIN dist/miso.ds.dev.0.2.2.zip
Binary file not shown.
View
BIN dist/miso.ds.dev.0.3.0.zip
Binary file not shown.
View
9 dist/miso.ds.min.0.2.2.js
@@ -1,9 +0,0 @@
-/**
-* Miso.Dataset - v0.2.2 - 9/3/2012
-* http://github.com/misoproject/dataset
-* Copyright (c) 2012 Alex Graul, Irene Ros;
-* Dual Licensed: MIT, GPL
-* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
-* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
-*/
-(function(a,_){var b=a.Miso||(a.Miso={});b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return _.isNull(a)||typeof a=="undefined"||_.isNaN(a)?null:a},test:function(a){return!0},compare:function(a,b){if(_.isEqual(a,b))return 0;if(a<b)return-1;if(a>b)return 1},numeric:function(a){return a===null||_.isNaN(+a)?null:+a}},string:{name:"string",coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)||a===null?null:_.isNumber(+a)?+a:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a===null||_.isNaN(a)?null:a?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(a){var b=+a;return _.isNull(a)||typeof a=="undefined"||_.isNaN(b)?null:b},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return _.isNaN(a)||a===null?null:a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isNull(a)||typeof a=="undefined"||_.isNaN(a))return null;if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(a)||a===null?null:a.valueOf()}}}})(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Event=function(a){_.isArray(a)||(a=[a]),this.deltas=a},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a==="_id"}).value()}),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a){return new b.Event(a)}}(this,_),function(a,_){var b=a.Miso||{};b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName._id].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},compute:function(a,b){if(this.func){var c=this.func(a);return typeof b!="undefined"?this.data[b]=c:this.data.push(c),c}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.filter={columns:this._columnFilter(a.filter.columns||undefined),rows:this._rowFilter(a.filter.rows||undefined)},this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c._id];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={_id:c._id,old:this.rowByPosition(f),changed:{}};a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.filter=c.filter||{},_.isFunction(a)?c.filter.rows=a:c.filter=a,c.parent=this,new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push("_id"),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=function(b){return _.indexOf(a,b._id)===-1?!1:!0},b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a==="_id"||a==="_oids"})},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(e.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column '"+e.name+"' with type "+e.type}},this),this._computedColumns&&_.each(this._computedColumns,function(b){var c=b.compute(a);a[b.name]=c});if(_.isUndefined(this.comparator))_.each(this._columns,function(b){b.isComputed()||b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={}),this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=this._rowIdByPosition.length;else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f._id)||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=b})}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={};_.isFunction(a)?b.comparator=a:b=a||b,b.comparator&&(this.comparator=b.comparator);if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var c=this.length,d;if(c===1)return;var e=_.bind(function(a,b){var c=this.rowByPosition(b);_.each(c,function(c,d){var e=this._columnPositionByName[d],f=this._columns[e].data[a];this._columns[e].data.splice(a,1,c),this._columns[e].data.splice(b,1,f)},this)},this),f=_.bind(function(a,b){var c=a,d;while(c*2<=b){d=c*2;var f=this.rowByPosition(c);d+1<b&&this.comparator(this.rowByPosition(d),this.rowByPosition(d+1))<0&&d++;if(this.comparator(f,this.rowByPosition(d))<0)e(c,d),c=d;else return}},this),g=function(a){var b=Math.round((a-2)/2);while(b>=0)f(b,a-1),b--};if(c>2){g(c),d=c-1;while(d>1)e(d,0),d--,f(0,d)}else this.comparator(this.rowByPosition(0),this.rowByPosition(1))>0&&e(0,1);return this.comparator(this.rowByPosition(this.length-2),this.rowByPosition(this.length-1))>0&&e(this.length-1,this.length-2),this.syncable&&b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_){var b=a.Miso;b.Product=b.Product||function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),b.Product.define=function(a){return function(c,d){d=d||{};var e=this._findColumns(c),f=this;d.type=d.type||e[0].type,d.typeOptions=d.typeOptions||e[0].typeOptions;var g=function(){var c=a.call(f,e,d);return b.types[d.type].coerce(c,d.typeOptions)};if(this.syncable){var h=new b.Product({columns:e,func:function(a){a=a||{};var b=this._buildDelta(this.value,g.call(f));this.value=b.changed;if(f.syncable){var c=this._buildEvent(b);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",c)}}});return this.bind("change",h._sync,h),h}return g.call(f)}},_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:b.Product.define(function(a,c){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}),max:b.Product.define(function(a,b){return _.max(_.map(a,function(a){return a._max()}))}),min:b.Product.define(function(a,b){return _.min(_.map(a,function(a){return a._min()}))}),mean:b.Product.define(function(a,c){var d=[];_.each(a,function(a){d.push(a.data)}),d=_.flatten(d);var e=a[0].type;return d=_.map(d,function(a){return b.types[e].numeric(a)}),_.mean(d)})})}(this,_),function(a,_,moment){var b=a.Miso;b.Dataset=function(a){this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],typeof a!="undefined"&&(a=a||{},this._initialize(a))},b.Dataset.prototype=new b.DataView,_.extend(b.Dataset.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var c=[],d=_.keys(a),e,f=this.uniqueAgainst,g=this.column(f),h=[],i=[],j=[];_.each(a[f],function(c,d){var e=g.data.indexOf(b.types[g.type].coerce(c)),f={};_.each(a,function(a,b){f[b]=a[d]});if(e===-1)h.push(f);else{i.push(f);var j=this.rowById(this.column("_id").data[e])._id;this.update(j,f)}},this),h.length>0&&this.add(h)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addComputedColumn:function(a,c,d){if(!_.isUndefined(this.column(a)))throw"There is already a column by this name.";if(typeof b.types[c]=="undefined")throw"The type "+c+" doesn't exist";var e=new b.Column({name:a,type:c,func:_.bind(d,this)});return this._columns.push(e),this._computedColumns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,this.length>0&&this.each(function(a,b){e.compute(a,b)},this),e},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column("_id")))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())}),this.addColumn({name:"_id",type:"number",data:b});if(this._columnPositionByName._id!==0){var c=this._columns[this._columnPositionByName._id],d=this._columnPositionByName._id;this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName._id=0,_.each(this._columnPositionByName,function(a,b){b!=="_id"&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a._id||(a._id=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b._id),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c);this.trigger("remove",e),this.trigger("change",e)}},update:function(a,c,d){var e,f=[],g=_.bind(function(a,d){var g,h;_.isFunction(c)?h=c.apply(this,[a]):h=c,e=_.keys(h),_.each(e,function(a){g=this.column(a);if(g.isComputed())throw"You're trying to update a computed column. Those get computed!";var c=b.types[g.type];if(c)if(c.test(h[g.name],g))_.isUndefined(g.before)||(h[g.name]=g.before(h[g.name])),h[g.name]=c.coerce(h[g.name],g);else throw"incorrect value '"+h[g.name]+"' of type "+b.typeOf(h[g.name],g)+" passed to column '"+g.name+"' with type "+g.type;g.data[d]=h[g.name]},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(b){var c=_.extend({},a,h),e=c[b.name],f=b.compute(c,d);e!==f&&(h[b.name]=f)}),f.push({_id:a._id,old:a,changed:h})},this);_.isString(a)&&(a=[a]);if(_.isArray(a)){var h,i;_.each(a,function(a){h=this.rowById(a),i=this._rowPositionById[a],g(h,i)})}else a=this._rowFilter(a),this.each(function(b,c){a(b)&&g(b,c)},this);if(this.syncable&&(!d||!d.silent)){var j=this._buildEvent(f);this.trigger("update",j),this.trigger("change",j)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso||(a.Miso={});b.Derived=function(a){a=a||{},b.Dataset.call(this),this.parent=a.parent,this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b.Dataset,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column("_id").data=this.parent.column("_id").data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column("_id").data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d._column(a).data,g=d._column("count").data,h=d._column("_oids").data,i=d._column("_id").data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b._id])):(g[c]+=1,h[c].push(b._id))}),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){b.Builder.clearRowCache(this);var d={},e=0,f=this._columnPositionByName[a],g=this.parent.column(a);for(var h=0;h<this.parent.length;h++){var i=null;this.preprocess?i=this.preprocess(g.data[h]):i=g.data[h],_.isUndefined(d[i])&&(d[i]=e,_.each(c,function(a){var b=this.column(a),c=this.column("_id");b.data[e]=[],c.data[e]=_.uniqueId()},this),this.column(a).data[e]=i,e++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[h],e=d[i];b.data[e].push(this.parent.rowByPosition(h))},this)}var j=this._columns[this._columnPositionByName._oids];return j.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,d){_.isArray(c)&&(j.data[d]=j.data[d]||[],j.data[d].push(_.map(c,function(a){return a._id})),j.data[d]=_.flatten(j.data[d]),b.data[d]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return a.ActiveXObject?new a.ActiveXObject("Microsoft.XMLHTTP"):new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null;return a.ajax.onreadystatechange=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},b}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d.charAt(o))&&n++,o++;d=d.slice(o,p)}function q(a){var d=a[1];if(d.length&&d!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var g=null;a[2]?g=a[2].replace(new RegExp('""',"g"),'"'):g=a[3];if(k){g===""&&(g=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(g)}else{var i=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(g)||g==="")g="X";b.indexOf(g)!==-1&&(g=i(g)),b.push(g),c[g]=[]}}(new RegExp("^"+f)).test(d)&&q(["","",undefined,""]);while(i=a.exec(d))q(i)}catch(r){throw new Error("Error while parsing delimited data on row "+m+". Message: "+r.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_)
View
9 dist/miso.ds.min.0.3.0.js
@@ -0,0 +1,9 @@
+/**
+* Miso.Dataset - v0.3.0 - 10/27/2012
+* http://github.com/misoproject/dataset
+* Copyright (c) 2012 Alex Graul, Irene Ros;
+* Dual Licensed: MIT, GPL
+* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
+* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
+*/
+(function(a){a.Miso=a.Miso||{},a.Miso.Dataset=function(a){a=a||{},this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],this._initialize(a)}})(this),function(a,_){var b=a.Miso.Dataset;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},compute:function(a,b){if(this.func){var c=this.func(a);return typeof b!="undefined"?this.data[b]=c:this.data.push(c),c}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=this.parent.idAttribute,this.filter={},this.filter.columns=_.bind(this._columnFilter(a.filter.columns||undefined),this),this.filter.rows=_.bind(this._rowFilter(a.filter.rows||undefined),this),this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c[this.idAttribute]];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={old:this.rowByPosition(f),changed:{}};h[this.idAttribute]=c[this.idAttribute],a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.filter=c.filter||{},_.isFunction(a)?c.filter.rows=a:c.filter=a,c.parent=this,new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push(this.idAttribute),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=_.bind(function(b){return _.indexOf(a,b[this.idAttribute])===-1?!1:!0},this),b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a===this.idAttribute||a==="_oids"},this)},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(e.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column '"+e.name+"' with type "+e.type}},this),this._computedColumns&&_.each(this._computedColumns,function(b){var c=b.compute(a);a[b.name]=c});if(_.isUndefined(this.comparator)){_.each(this._columns,function(b){b.isComputed()||b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={});if(typeof this._rowPositionById[a[this.idAttribute]]!="undefined")throw"The id "+a[this.idAttribute]+" is not unique. The "+this.idAttribute+" column must be unique";this._rowPositionById[a[this.idAttribute]]=this._rowIdByPosition.length,this._rowIdByPosition.push(a[this.idAttribute])}else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f[this.idAttribute])||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a[this.idAttribute]),this._rowPositionById[a[this.idAttribute]]=b},this)}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={},c=[];_.isFunction(a)?b.comparator=a:b=a||{};if(b.comparator)this.comparator=b.comparator;else if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var d,e,f;for(d=0;d<this.length;d++)c[d]=this._row(d);c.sort(this.comparator),d=c.length;while(d--){f=c[d],this._rowIdByPosition[d]=f[this.idAttribute],this._rowPositionById[f[this.idAttribute]]=d,e=this._columns.length;while(e--){var g=this._columns[e];g.data[d]=f[g.name]}}return this.syncable&&!b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_,moment){var b=a.Miso.Dataset;b.prototype=new b.DataView,_.extend(b.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=a.idAttribute||"_id",this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var c=[],d=_.keys(a),e,f=this.uniqueAgainst,g=this.column(f),h=[],i=[],j=[];_.each(a[f],function(c,d){var e=g.data.indexOf(b.types[g.type].coerce(c)),f={};_.each(a,function(a,b){f[b]=a[d]}),e===-1?h.push(f):(i.push(f),f[this.idAttribute]=this.rowById(this.column(this.idAttribute).data[e])[this.idAttribute],this.update(f))},this),h.length>0&&this.add(h)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addComputedColumn:function(a,c,d){if(!_.isUndefined(this.column(a)))throw"There is already a column by this name.";if(typeof b.types[c]=="undefined")throw"The type "+c+" doesn't exist";var e=new b.Column({name:a,type:c,func:_.bind(d,this)});return this._columns.push(e),this._computedColumns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,this.length>0&&this.each(function(a,b){e.compute(a,b)},this),e},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column(this.idAttribute)))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())});var c=this.addColumn({name:this.idAttribute,data:b});this.idAttribute==="_id"&&(c.type="number");if(this._columnPositionByName[this.idAttribute]!==0){var d=this._columnPositionByName[this.idAttribute];this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName[this.idAttribute]=0,_.each(this._columnPositionByName,function(a,b){b!==this.idAttribute&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a[this.idAttribute]||(a[this.idAttribute]=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c,this);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b[this.idAttribute]),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("remove",e),this.trigger("change",e)}},_arrayUpdate:function(a){var c=[];return _.each(a,function(a){var d={old:{},changed:{}};d[this.idAttribute]=a[this.idAttribute];var e=this._rowPositionById[a[this.idAttribute]];_.each(a,function(a,c){var f=this._columns[this._columnPositionByName[c]],g=b.types[f.type];if(f.name===this.idAttribute&&f.data[e]!==a)throw"You can't update the id column";if(typeof f=="undefined")throw"column "+c+" not found!";if(!g.test(a,f))throw"Value is incorrect type";if(this._computedColumns[f.name])return;a=g.coerce(a,f),_.isUndefined(f.before)||(a=f.before(a)),f.data[e]!==a&&(d.old[c]=f.data[e],f.data[e]=a,d.changed[c]=a)},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(a){var b=_.extend({},this._row(e)),c=b[a.name],f=a.compute(b,e);c!==f&&(d.old[a.name]=c,a.data[e]=f,d.changed[a.name]=f)},this),_.keys(d.changed).length>0&&c.push(d)},this),c},_functionUpdate:function(a){var b=[];for(var c=0;c<this.length;c++){var d=a(this.rowByPosition(c));d!==!1&&b.push(d)}return this._arrayUpdate(b)},update:function(a,b){var c;if(_.isFunction(a))c=this._functionUpdate(a);else{var d=_.isArray(a)?a:[a];c=this._arrayUpdate(d)}if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("update",e),this.trigger("change",e)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso.Dataset;b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return _.isNull(a)||typeof a=="undefined"||_.isNaN(a)?null:a},test:function(a){return!0},compare:function(a,b){if(_.isEqual(a,b))return 0;if(a<b)return-1;if(a>b)return 1},numeric:function(a){return a===null||_.isNaN(+a)?null:+a}},string:{name:"string",coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)||a===null?null:_.isNumber(+a)?+a:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a===null||_.isNaN(a)?null:a?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(a){var b=+a;return _.isNull(a)||typeof a=="undefined"||_.isNaN(b)?null:b},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return _.isNaN(a)||a===null?null:a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isNull(a)||typeof a=="undefined"||_.isNaN(a))return null;if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(a)||a===null?null:a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Event=function(a,b){_.isArray(a)||(a=[a]),this.deltas=a,this.dataset=b||null},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a===this.dataset.idAttribute},this).value()},this),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a,c){return new b.Event(a,c)}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName[a.idAttribute]].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Product=function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),b.Product.define=function(a){return function(c,d){d=d||{};var e=this._findColumns(c),f=this;d.type=d.type||e[0].type,d.typeOptions=d.typeOptions||e[0].typeOptions;var g=function(){var c=a.call(f,e,d);return b.types[d.type].coerce(c,d.typeOptions)};if(this.syncable){var h=new b.Product({columns:e,func:function(a){a=a||{};var b=this._buildDelta(this.value,g.call(f));this.value=b.changed;if(f.syncable){var c=this._buildEvent(b,this);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",c)}}});return this.bind("change",h._sync,h),h}return g.call(f)}},_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:b.Product.define(function(a,c){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}),max:b.Product.define(function(a,b){return _.max(_.map(a,function(a){return a._max()}))}),min:b.Product.define(function(a,b){return _.min(_.map(a,function(a){return a._min()}))}),mean:b.Product.define(function(a,c){var d=[];_.each(a,function(a){d.push(a.data)}),d=_.flatten(d);var e=a[0].type;return d=_.map(d,function(a){return b.types[e].numeric(a)}),_.mean(d)})})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return a.ActiveXObject?new a.ActiveXObject("Microsoft.XMLHTTP"):new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null,d;return d=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},a.ajax.readyState===4?d():a.ajax.onreadystatechange=d,b}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d.charAt(o))&&n++,o++;d=d.slice(o,p)}function q(a){var d=a[1];if(d.length&&d!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var g=null;a[2]?g=a[2].replace(new RegExp('""',"g"),'"'):g=a[3];if(k){g===""&&(g=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(g)}else{var i=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(g)||g==="")g="X";b.indexOf(g)!==-1&&(g=i(g)),b.push(g),c[g]=[]}}(new RegExp("^"+f)).test(d)&&q(["","",undefined,""]);while(i=a.exec(d))q(i)}catch(r){throw new Error("Error while parsing delimited data on row "+m+". Message: "+r.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Derived=function(a){a=a||{},b.call(this),this.parent=a.parent,this.idAttribute="_id",this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){if(a===this.idAttribute)throw"You can't compute a moving average on the id column";e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column(this.idAttribute).data=this.parent.column(this.parent.idAttribute).data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column(this.parent.idAttribute).data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d.column(a).data,g=d.column("count").data,h=d.column("_oids").data,i=d.column(d.idAttribute).data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b[this.parent.idAttribute]])):(g[c]+=1,h[c].push(b[this.parent.idAttribute]))},d),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){var d=this;b.Builder.clearRowCache(this);var e={},f=0,g=this._columnPositionByName[a],h=this.parent.column(a);for(var i=0;i<this.parent.length;i++){var j=null;this.preprocess?j=this.preprocess(h.data[i]):j=h.data[i],_.isUndefined(e[j])&&(e[j]=f,_.each(c,function(a){var b=this.column(a),c=this.column(this.idAttribute);b.data[f]=[],c.data[f]=_.uniqueId()},this),this.column(a).data[f]=j,f++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[i],d=e[j];b.data[d].push(this.parent.rowByPosition(i))},this)}var k=this._columns[this._columnPositionByName._oids];return k.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,e){_.isArray(c)&&(k.data[e]=k.data[e]||[],k.data[e].push(_.map(c,function(a){return a[d.parent.idAttribute]})),k.data[e]=_.flatten(k.data[e]),b.data[e]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_)
View
9 dist/miso.ds.min.0.3.0.m.js
@@ -0,0 +1,9 @@
+/**
+* Miso.Dataset - v0.3.0 - 10/27/2012
+* http://github.com/misoproject/dataset
+* Copyright (c) 2012 Alex Graul, Irene Ros;
+* Dual Licensed: MIT, GPL
+* https://github.com/misoproject/dataset/blob/master/LICENSE-MIT
+* https://github.com/misoproject/dataset/blob/master/LICENSE-GPL
+*/
+(function(a){a.Miso=a.Miso||{},a.Miso.Dataset=function(a){a=a||{},this.length=0,this._columns=[],this._columnPositionByName={},this._computedColumns=[],this._initialize(a)}})(this),function(a,_){var b=a.Miso.Dataset;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a){return b.types[this.type].numeric(a)},numericAt:function(a){return this.toNumeric(this.data[a])},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},compute:function(a,b){if(this.func){var c=this.func(a);return typeof b!="undefined"?this.data[b]=c:this.data.push(c),c}},isComputed:function(){return!_.isUndefined(this.func)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)this.data[c]!==null&&b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){if(typeof a!="undefined"){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");this.parent=a.parent,this._initialize(a)}},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=this.parent.idAttribute,this.filter={},this.filter.columns=_.bind(this._columnFilter(a.filter.columns||undefined),this),this.filter.rows=_.bind(this._rowFilter(a.filter.rows||undefined),this),this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c[this.idAttribute]];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={old:this.rowByPosition(f),changed:{}};h[this.idAttribute]=c[this.idAttribute],a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.filter=c.filter||{},_.isFunction(a)?c.filter.rows=a:c.filter=a,c.parent=this,new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(_.isString(a)&&(a=[a]),a.push(this.idAttribute),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=_.bind(function(b){return _.indexOf(a,b[this.idAttribute])===-1?!1:!0},this),b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a===this.idAttribute||a==="_oids"},this)},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},reverseEach:function(a,b){for(var c=this.length-1;c>=0;c--)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(e.isComputed())throw"You're trying to update a computed column. Those get computed!";if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))_.isUndefined(e.before)||(a[e.name]=e.before(a[e.name])),a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column '"+e.name+"' with type "+e.type}},this),this._computedColumns&&_.each(this._computedColumns,function(b){var c=b.compute(a);a[b.name]=c});if(_.isUndefined(this.comparator)){_.each(this._columns,function(b){b.isComputed()||b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={});if(typeof this._rowPositionById[a[this.idAttribute]]!="undefined")throw"The id "+a[this.idAttribute]+" is not unique. The "+this.idAttribute+" column must be unique";this._rowPositionById[a[this.idAttribute]]=this._rowIdByPosition.length,this._rowIdByPosition.push(a[this.idAttribute])}else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f[this.idAttribute])||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a[this.idAttribute]),this._rowPositionById[a[this.idAttribute]]=b},this)}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){var b={},c=[];_.isFunction(a)?b.comparator=a:b=a||{};if(b.comparator)this.comparator=b.comparator;else if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var d,e,f;for(d=0;d<this.length;d++)c[d]=this._row(d);c.sort(this.comparator),d=c.length;while(d--){f=c[d],this._rowIdByPosition[d]=f[this.idAttribute],this._rowPositionById[f[this.idAttribute]]=d,e=this._columns.length;while(e--){var g=this._columns[e];g.data[d]=f[g.name]}}return this.syncable&&!b.silent&&this.trigger("sort"),this},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_,moment){var b=a.Miso.Dataset;b.prototype=new b.DataView,_.extend(b.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.idAttribute=a.idAttribute||"_id",this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.parser instanceof b.Parsers.Delimited&&(a.dataType="text"),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred?this.deferred=a.deferred:this.deferred=new _.Deferred,a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){try{this._apply(c)}catch(d){if(a.error)a.error.call(this,d);else throw d}this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this,c),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var c=[],d=_.keys(a),e,f=this.uniqueAgainst,g=this.column(f),h=[],i=[],j=[];_.each(a[f],function(c,d){var e=g.data.indexOf(b.types[g.type].coerce(c)),f={};_.each(a,function(a,b){f[b]=a[d]}),e===-1?h.push(f):(i.push(f),f[this.idAttribute]=this.rowById(this.column(this.idAttribute).data[e])[this.idAttribute],this.update(f))},this),h.length>0&&this.add(h)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},_apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addComputedColumn:function(a,c,d){if(!_.isUndefined(this.column(a)))throw"There is already a column by this name.";if(typeof b.types[c]=="undefined")throw"The type "+c+" doesn't exist";var e=new b.Column({name:a,type:c,func:_.bind(d,this)});return this._columns.push(e),this._computedColumns.push(e),this._columnPositionByName[e.name]=this._columns.length-1,this.length>0&&this.each(function(a,b){e.compute(a,b)},this),e},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column(this.idAttribute)))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())});var c=this.addColumn({name:this.idAttribute,data:b});this.idAttribute==="_id"&&(c.type="number");if(this._columnPositionByName[this.idAttribute]!==0){var d=this._columnPositionByName[this.idAttribute];this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName[this.idAttribute]=0,_.each(this._columnPositionByName,function(a,b){b!==this.idAttribute&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a[this.idAttribute]||(a[this.idAttribute]=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c,this);this.trigger("add",d),this.trigger("change",d)}return this},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b[this.idAttribute]),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("remove",e),this.trigger("change",e)}},_arrayUpdate:function(a){var c=[];return _.each(a,function(a){var d={old:{},changed:{}};d[this.idAttribute]=a[this.idAttribute];var e=this._rowPositionById[a[this.idAttribute]];_.each(a,function(a,c){var f=this._columns[this._columnPositionByName[c]],g=b.types[f.type];if(f.name===this.idAttribute&&f.data[e]!==a)throw"You can't update the id column";if(typeof f=="undefined")throw"column "+c+" not found!";if(!g.test(a,f))throw"Value is incorrect type";if(this._computedColumns[f.name])return;a=g.coerce(a,f),_.isUndefined(f.before)||(a=f.before(a)),f.data[e]!==a&&(d.old[c]=f.data[e],f.data[e]=a,d.changed[c]=a)},this),typeof this._computedColumns!="undefined"&&_.each(this._computedColumns,function(a){var b=_.extend({},this._row(e)),c=b[a.name],f=a.compute(b,e);c!==f&&(d.old[a.name]=c,a.data[e]=f,d.changed[a.name]=f)},this),_.keys(d.changed).length>0&&c.push(d)},this),c},_functionUpdate:function(a){var b=[];for(var c=0;c<this.length;c++){var d=a(this.rowByPosition(c));d!==!1&&b.push(d)}return this._arrayUpdate(b)},update:function(a,b){var c;if(_.isFunction(a))c=this._functionUpdate(a);else{var d=_.isArray(a)?a:[a];c=this._arrayUpdate(d)}if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c,this);this.trigger("update",e),this.trigger("change",e)}return this},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso.Dataset;b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return _.isNull(a)||typeof a=="undefined"||_.isNaN(a)?null:a},test:function(a){return!0},compare:function(a,b){if(_.isEqual(a,b))return 0;if(a<b)return-1;if(a>b)return 1},numeric:function(a){return a===null||_.isNaN(+a)?null:+a}},string:{name:"string",coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(+a)||a===null?null:_.isNumber(+a)?+a:null}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return _.isNaN(a)||a===null||typeof a=="undefined"?null:a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return a===null||_.isNaN(a)?null:a?1:0}},number:{name:"number",regexp:/^\s*[\-\.]?[0-9]+([\.][0-9]+)?\s*$/,coerce:function(a){var b=+a;return _.isNull(a)||typeof a=="undefined"||_.isNaN(b)?null:b},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a==null&&b!=null?-1:a!=null&&b==null?1:a==null&&b==null?0:a===b?0:a<b?-1:1},numeric:function(a){return _.isNaN(a)||a===null?null:a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isNull(a)||typeof a=="undefined"||_.isNaN(a))return null;if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(a)||a===null?null:a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Event=function(a,b){_.isArray(a)||(a=[a]),this.deltas=a,this.dataset=b||null},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){b.old=b.old||[],b.changed=b.changed||[],a=_.chain(a).union(_.keys(b.old),_.keys(b.changed)).reject(function(a){return a===this.dataset.idAttribute},this).value()},this),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a,c){return new b.Event(a,c)}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName[a.idAttribute]].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Product=function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),b.Product.define=function(a){return function(c,d){d=d||{};var e=this._findColumns(c),f=this;d.type=d.type||e[0].type,d.typeOptions=d.typeOptions||e[0].typeOptions;var g=function(){var c=a.call(f,e,d);return b.types[d.type].coerce(c,d.typeOptions)};if(this.syncable){var h=new b.Product({columns:e,func:function(a){a=a||{};var b=this._buildDelta(this.value,g.call(f));this.value=b.changed;if(f.syncable){var c=this._buildEvent(b,this);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",c)}}});return this.bind("change",h._sync,h),h}return g.call(f)}},_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:b.Product.define(function(a,c){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}),max:b.Product.define(function(a,b){return _.max(_.map(a,function(a){return a._max()}))}),min:b.Product.define(function(a,b){return _.min(_.map(a,function(a){return a._min()}))}),mean:b.Product.define(function(a,c){var d=[];_.each(a,function(a){d.push(a.data)}),d=_.flatten(d);var e=a[0].type;return d=_.map(d,function(a){return b.types[e].numeric(a)}),_.mean(d)})})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json",callback:a.callback}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);this.callback&&(window[this.callback]=c),b.Xhr(_.extend(this.params,{success:this.callback?this.callback:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return a.ActiveXObject?new a.ActiveXObject("Microsoft.XMLHTTP"):new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error,a.callback);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d,e){if(c){var f=document.querySelectorAll('script[src="'+a+'"]');if(f.length){b&&b(!0);return}}var g=document.head||document.getElementsByTagName("head")[0]||document.documentElement,h=document.createElement("script"),i=a.split("?")[1],j=!1,k=[],l;i&&!c&&(k=i.split("&")),k.length&&(l=k[k.length-1].split("="));if(!e){var m=_.uniqueId("callback");e=k.length?l[1]?l[1]:m:m}!i&&!c&&(a+="?");if(!i||!/callback/.test(i))i&&(a+="&"),a+="callback="+e;e&&!c&&(!window[e]||(e=e+ +(new Date)+_.uniqueId()),window[e]=function(a){b&&b(a),j=!0},l&&(a=a.replace(l.join("="),l[0]+"="+e))),h.onload=h.onreadystatechange=function(){if(!h.readyState||/loaded|complete/.test(h.readyState)){c&&b&&b();if(j){try{delete window[e]}catch(a){window[e]=void 0}g.removeChild(h)}}},h.onerror=function(a){d&&d.call(null,a)},h.src=a,g.insertBefore(h,g.firstChild);return},b.Xhr.httpData=function(a){var b,c=null,d;return d=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},a.ajax.readyState===4?d():a.ajax.onreadystatechange=d,b}}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);a._timeout=setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject(),typeof this._timeout!="undefined"&&clearTimeout(this._timeout)},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.fast?(a.url="https://spreadsheets.google.com/tq?key="+a.key,typeof a.sheetName=="undefined"&&(a.sheetName="Sheet1"),a.url+="&sheet="+a.sheetName,this.callback="misodsgs"+(new Date).getTime(),a.url+="&tqx=version:0.6;responseHandler:"+this.callback,a.url+=";reqId:0;out:json&tq&_=1335871249558#",delete a.sheetName):a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key}return this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){if(c.indexOf(a.name)!==-1)throw new Error('You have more than one column named "'+a.name+'"');c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.GoogleSpreadsheet=function(a){this.fast=a.fast||!1},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d={},e;if(typeof a.status!="undefined"&&a.status==="error")throw new Error("You can't use the fast importer for this url. Disable the fast flag");if(this.fast){b=_.pluck(a.table.cols,"label");if(_.unique(b).length<b.length){var f="";throw _.inject(b,function(a,b){return a[b]=a[b]+1||1,a[b]>1&&(f=b),a},{}),new Error('You have more than one column named "'+f+'"')}_.each(a.table.rows,function(a){a=a.c;for(e=0;e<a.length;e++)c[e]=c[e]||[],a[e].v===""?c[e].push(null):c[e].push(a[e].v)}),_.each(b,function(a,b){d[a]=c[b]})}else{var g=/([A-Z]+)(\d+)/,h={};_.each(a.feed.entry,function(a,d){var e=g.exec(a.title.$t),f=e[1],i=parseInt(e[2],10);if(i===1){if(b.indexOf(a.content.$t)!==-1)throw new Error('You have more than one column named "'+a.content.$t+'"');h[f]=c.length,b[h[f]]=a.content.$t,c[h[f]]=[]}else{var j=h[f];c[j][i-1]=a.content.$t}},this),_.each(c,function(a,e){a.length=_.max(_.pluck(c,"length")),a.splice(0,1);for(var f=0;f<a.length;f++)if(_.isUndefined(a[f])||a[f]==="")a[f]=null;d[b[e]]=a})}return{columns:b,data:d}}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.skipRows=a.skipRows||0,this.emptyValue=a.emptyValue||null,this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},typeof String.prototype.trim!="function"&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d={},e=function(a){d[a]||(d[a]=0);var b=a+d[a];return d[a]+=1,b},f=function(a,d,f,g,h){f=f||",";var i=null,j=0,k=!1,l=-1,m=0;try{d=d.replace(/\s+$/,"").replace(/^[\r|\n|\s]+[\r|\n]/,"\n");if(g>0){var n=0,o=0,p=d.length;while(n<g&&o<p)/\n|\r|\r\n/.test(d.charAt(o))&&n++,o++;d=d.slice(o,p)}function q(a){var d=a[1];if(d.length&&d!==f){m++;if(l<j-1)throw m--,new Error("Not enough items in row");k=!0,l=0}else k||j++,l++;var g=null;a[2]?g=a[2].replace(new RegExp('""',"g"),'"'):g=a[3];if(k){g===""&&(g=h);if(typeof c[b[l]]=="undefined")throw new Error("Too many items in row");c[b[l]].push(g)}else{var i=function(a){var c=e(a);while(b.indexOf(c)!==-1)c=e(a);return c};if(_.isUndefined(g)||g==="")g="X";b.indexOf(g)!==-1&&(g=i(g)),b.push(g),c[g]=[]}}(new RegExp("^"+f)).test(d)&&q(["","",undefined,""]);while(i=a.exec(d))q(i)}catch(r){throw new Error("Error while parsing delimited data on row "+m+". Message: "+r.message)}return{columns:b,data:c}};return f(this.__delimiterPatterns,a,this.delimiter,this.skipRows,this.emptyValue)}})}(this,_),function(a,_){var b=a.Miso.Dataset;b.Derived=function(a){a=a||{},b.call(this),this.parent=a.parent,this.idAttribute="_id",this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this))},b.Derived.prototype=new b,_.extend(b.Derived.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.DataView.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){if(a===this.idAttribute)throw"You can't compute a moving average on the id column";e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column(this.idAttribute).data=this.parent.column(this.parent.idAttribute).data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column(this.parent.idAttribute).data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},countBy:function(a,c){function j(a,c,d){var e;for(e=0;e<a.length;e++)if(b.types[d].compare(a[e],c)===0)return e;return-1}c=c||{};var d=new b.Derived({parent:this,method:_.sum,args:arguments}),e=this.column(a);d.addColumn({name:a,type:e.type}),d.addColumn({name:"count",type:"number"}),d.addColumn({name:"_oids",type:"mixed"}),b.Builder.cacheColumns(d);var f=d.column(a).data,g=d.column("count").data,h=d.column("_oids").data,i=d.column(d.idAttribute).data;return this.each(function(b){var c=j(f,b[a],e.type);c===-1?(f.push(b[a]),i.push(_.uniqueId()),g.push(1),h.push([b[this.parent.idAttribute]])):(g[c]+=1,h[c].push(b[this.parent.idAttribute]))},d),b.Builder.cacheRows(d),d},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type})},e),b.Builder.cacheColumns(e);var g=function(){var d=this;b.Builder.clearRowCache(this);var e={},f=0,g=this._columnPositionByName[a],h=this.parent.column(a);for(var i=0;i<this.parent.length;i++){var j=null;this.preprocess?j=this.preprocess(h.data[i]):j=h.data[i],_.isUndefined(e[j])&&(e[j]=f,_.each(c,function(a){var b=this.column(a),c=this.column(this.idAttribute);b.data[f]=[],c.data[f]=_.uniqueId()},this),this.column(a).data[f]=j,f++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[i],d=e[j];b.data[d].push(this.parent.rowByPosition(i))},this)}var k=this._columns[this._columnPositionByName._oids];return k.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,e){_.isArray(c)&&(k.data[e]=k.data[e]||[],k.data[e].push(_.map(c,function(a){return a[d.parent.idAttribute]})),k.data[e]=_.flatten(k.data[e]),b.data[e]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_),function(a){var b=a.Miso||{};delete window.Miso,typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(module.exports=b),exports.miso=b):typeof define=="function"&&define.amd&&define("miso",[],function(){return b})}(this)
View
3,160 dist/node/miso.ds.deps.0.2.2.js → dist/node/miso.ds.deps.0.3.0.js
1,571 additions, 1,589 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2,641 lib/lodash.js
1,180 additions, 1,461 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
299 lib/moment.js
@@ -1,17 +1,17 @@
// moment.js
-// version : 1.7.0
+// version : 1.7.2
// author : Tim Wood
// license : MIT
// momentjs.com
-(function (Date, undefined) {
+(function (undefined) {
/************************************
Constants
************************************/
var moment,
- VERSION = "1.7.0",
+ VERSION = "1.7.2",
round = Math.round, i,
// internal storage for language config files
languages = {},
@@ -30,9 +30,8 @@
aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
// format tokens
- formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?)/g,
- localFormattingTokens = /(LT|LL?L?L?)/g,
- formattingRemoveEscapes = /(^\[)|(\\)|\]$/g,
+ formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g,
+ localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?)/g,
// parsing tokens
parseMultipleFormatChunker = /([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,
@@ -46,7 +45,7 @@
parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i, // +00:00 -00:00 +0000 -0000 or Z
parseTokenT = /T/i, // T (ISO seperator)
- // preliminary iso regex
+ // preliminary iso regex
// 0000-00-00 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000
isoRegex = /^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,
isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',
@@ -77,58 +76,138 @@
// format function strings
formatFunctions = {},
+ // tokens to ordinalize and pad
+ ordinalizeTokens = 'DDD w M D d'.split(' '),
+ paddedTokens = 'M D H h m s w'.split(' '),
+
/*
* moment.fn.format uses new Function() to create an inlined formatting function.
* Results are a 3x speed boost
* http://jsperf.com/momentjs-cached-format-functions
*
* These strings are appended into a function using replaceFormatTokens and makeFormatFunction
*/
- formatFunctionStrings = {
+ formatTokenFunctions = {
// a = placeholder
// b = placeholder
// t = the current moment being formatted
// v = getValueAtKey function
// o = language.ordinal function
// p = leftZeroFill function
// m = language.meridiem value or function
- M : '(a=t.month()+1)',
- MMM : 'v("monthsShort",t.month())',
- MMMM : 'v("months",t.month())',
- D : '(a=t.date())',
- DDD : '(a=new Date(t.year(),t.month(),t.date()),b=new Date(t.year(),0,1),a=~~(((a-b)/864e5)+1.5))',
- d : '(a=t.day())',
- dd : 'v("weekdaysMin",t.day())',
- ddd : 'v("weekdaysShort",t.day())',
- dddd : 'v("weekdays",t.day())',
- w : '(a=new Date(t.year(),t.month(),t.date()-t.day()+5),b=new Date(a.getFullYear(),0,4),a=~~((a-b)/864e5/7+1.5))',
- YY : 'p(t.year()%100,2)',
- YYYY : 'p(t.year(),4)',
- a : 'm(t.hours(),t.minutes(),!0)',
- A : 'm(t.hours(),t.minutes(),!1)',
- H : 't.hours()',
- h : 't.hours()%12||12',
- m : 't.minutes()',
- s : 't.seconds()',
- S : '~~(t.milliseconds()/100)',
- SS : 'p(~~(t.milliseconds()/10),2)',
- SSS : 'p(t.milliseconds(),3)',
- Z : '((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(a/60),2)+":"+p(~~a%60,2)',
- ZZ : '((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(10*a/6),4)'
- },
+ M : function () {
+ return this.month() + 1;
+ },
+ MMM : function (format) {
+ return getValueFromArray("monthsShort", this.month(), this, format);
+ },
+ MMMM : function (format) {
+ return getValueFromArray("months", this.month(), this, format);
+ },
+ D : function () {
+ return this.date();
+ },
+ DDD : function () {
+ var a = new Date(this.year(), this.month(), this.date()),
+ b = new Date(this.year(), 0, 1);
+ return ~~(((a - b) / 864e5) + 1.5);
+ },
+ d : function () {
+ return this.day();
+ },
+ dd : function (format) {
+ return getValueFromArray("weekdaysMin", this.day(), this, format);
+ },
+ ddd : function (format) {
+ return getValueFromArray("weekdaysShort", this.day(), this, format);
+ },
+ dddd : function (format) {
+ return getValueFromArray("weekdays", this.day(), this, format);
+ },
+ w : function () {
+ var a = new Date(this.year(), this.month(), this.date() - this.day() + 5),
+ b = new Date(a.getFullYear(), 0, 4);
+ return ~~((a - b) / 864e5 / 7 + 1.5);
+ },
+ YY : function () {
+ return leftZeroFill(this.year() % 100, 2);
+ },
+ YYYY : function () {
+ return leftZeroFill(this.year(), 4);
+ },
+ a : function () {
+ return this.lang().meridiem(this.hours(), this.minutes(), true);
+ },
+ A : function () {
+ return this.lang().meridiem(this.hours(), this.minutes(), false);
+ },
+ H : function () {
+ return this.hours();
+ },
+ h : function () {
+ return this.hours() % 12 || 12;
+ },
+ m : function () {
+ return this.minutes();
+ },
+ s : function () {
+ return this.seconds();
+ },
+ S : function () {
+ return ~~(this.milliseconds() / 100);
+ },
+ SS : function () {
+ return leftZeroFill(~~(this.milliseconds() / 10), 2);
+ },
+ SSS : function () {
+ return leftZeroFill(this.milliseconds(), 3);
+ },
+ Z : function () {
+ var a = -this.zone(),
+ b = "+";
+ if (a < 0) {
+ a = -a;
+ b = "-";
+ }
+ return b + leftZeroFill(~~(a / 60), 2) + ":" + leftZeroFill(~~a % 60, 2);
+ },
+ ZZ : function () {
+ var a = -this.zone(),
+ b = "+";
+ if (a < 0) {
+ a = -a;
+ b = "-";
+ }
+ return b + leftZeroFill(~~(10 * a / 6), 4);
+ }
+ };
- ordinalizeTokens = 'DDD w M D d'.split(' '),
- paddedTokens = 'M D H h m s w'.split(' ');
+ function getValueFromArray(key, index, m, format) {
+ var lang = m.lang();
+ return lang[key].call ? lang[key](m, format) : lang[key][index];
+ }
+
+ function padToken(func, count) {
+ return function (a) {
+ return leftZeroFill(func.call(this, a), count);
+ };
+ }
+ function ordinalizeToken(func) {
+ return function (a) {
+ var b = func.call(this, a);
+ return b + this.lang().ordinal(b);
+ };
+ }
while (ordinalizeTokens.length) {
i = ordinalizeTokens.pop();
- formatFunctionStrings[i + 'o'] = formatFunctionStrings[i] + '+o(a)';
+ formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i]);
}
while (paddedTokens.length) {
i = paddedTokens.pop();
- formatFunctionStrings[i + i] = 'p(' + formatFunctionStrings[i] + ',2)';
+ formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2);
}
- formatFunctionStrings.DDDD = 'p(' + formatFunctionStrings.DDD + ',3)';
+ formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
/************************************
@@ -141,15 +220,14 @@
this._d = date;
this._isUTC = !!isUTC;
this._a = date._a || null;
- date._a = null;
this._lang = lang || false;
}
// Duration Constructor
function Duration(duration) {
var data = this._data = {},
years = duration.years || duration.y || 0,
- months = duration.months || duration.M || 0,
+ months = duration.months || duration.M || 0,
weeks = duration.weeks || duration.w || 0,
days = duration.days || duration.d || 0,
hours = duration.hours || duration.h || 0,
@@ -171,7 +249,7 @@
// it separately.
this._months = months +
years * 12;
-
+
// The following code bubbles up values, see the tests for
// examples of what that means.
data.milliseconds = milliseconds % 1000;
@@ -188,7 +266,7 @@
days += weeks * 7;
data.days = days % 30;
-
+
months += absRound(days / 30);
data.months = months % 12;
@@ -267,13 +345,21 @@
// the array should mirror the parameters below
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
- function dateFromArray(input, asUTC) {
- var i, date;
- for (i = 1; i < 7; i++) {
- input[i] = (input[i] == null) ? (i === 2 ? 1 : 0) : input[i];
+ function dateFromArray(input, asUTC, hoursOffset, minutesOffset) {
+ var i, date, forValid = [];
+ for (i = 0; i < 7; i++) {
+ forValid[i] = input[i] = (input[i] == null) ? (i === 2 ? 1 : 0) : input[i];
}
// we store whether we used utc or not in the input array
- input[7] = asUTC;
+ input[7] = forValid[7] = asUTC;
+ // if the parser flagged the input as invalid, we pass the value along
+ if (input[8] != null) {
+ forValid[8] = input[8];
+ }
+ // add the offsets to the time to be parsed so that we can have a clean array
+ // for checking isValid
+ input[3] += hoursOffset || 0;
+ input[4] += minutesOffset || 0;
date = new Date(0);
if (asUTC) {
date.setUTCFullYear(input[0], input[1], input[2]);
@@ -282,7 +368,7 @@
date.setFullYear(input[0], input[1], input[2]);
date.setHours(input[3], input[4], input[5], input[6]);
}
- date._a = input;
+ date._a = forValid;
return date;
}
@@ -297,7 +383,7 @@
if (!values && hasModule) {
values = require('./lang/' + key);
}
-
+
for (i = 0; i < langConfigProperties.length; i++) {
// If a language definition does not provide a value, inherit
// from English
@@ -307,13 +393,13 @@
for (i = 0; i < 12; i++) {
m = moment([2000, i]);
- parse[i] = new RegExp('^' + (values.months[i] || values.months(m, '')) +
+ parse[i] = new RegExp('^' + (values.months[i] || values.months(m, '')) +
'|^' + (values.monthsShort[i] || values.monthsShort(m, '')).replace('.', ''), 'i');
}
values.monthsParse = values.monthsParse || parse;
languages[key] = values;
-
+
return values;
}
@@ -339,54 +425,50 @@
************************************/
- // helper for building inline formatting functions
- function replaceFormatTokens(token) {
- return formatFunctionStrings[token] ?
- ("'+(" + formatFunctionStrings[token] + ")+'") :
- token.replace(formattingRemoveEscapes, "").replace(/\\?'/g, "\\'");
- }
-
- // helper for recursing long date formatting tokens
- function replaceLongDateFormatTokens(input) {
- return getLangDefinition().longDateFormat[input] || input;
+ function removeFormattingTokens(input) {
+ if (input.match(/\[.*\]/)) {
+ return input.replace(/^\[|\]$/g, "");
+ }
+ return input.replace(/\\/g, "");
}
function makeFormatFunction(format) {
- var output = "var a,b;return '" +
- format.replace(formattingTokens, replaceFormatTokens) + "';",
- Fn = Function; // get around jshint
- // t = the current moment being formatted
- // v = getValueAtKey function
- // o = language.ordinal function
- // p = leftZeroFill function
- // m = language.meridiem value or function
- return new Fn('t', 'v', 'o', 'p', 'm', output);
- }
+ var array = format.match(formattingTokens), i, length;
- function makeOrGetFormatFunction(format) {
- if (!formatFunctions[format]) {
- formatFunctions[format] = makeFormatFunction(format);
+ for (i = 0, length = array.length; i < length; i++) {
+ if (formatTokenFunctions[array[i]]) {
+ array[i] = formatTokenFunctions[array[i]];
+ } else {
+ array[i] = removeFormattingTokens(array[i]);
+ }
}
- return formatFunctions[format];
+
+ return function (mom) {
+ var output = "";
+ for (i = 0; i < length; i++) {
+ output += typeof array[i].call === 'function' ? array[i].call(mom, format) : array[i];
+ }
+ return output;
+ };
}
// format date using native date object
function formatMoment(m, format) {
- var lang = getLangDefinition(m);
+ var i = 5;
- function getValueFromArray(key, index) {
- return lang[key].call ? lang[key](m, format) : lang[key][index];
+ function replaceLongDateFormatTokens(input) {
+ return m.lang().longDateFormat[input] || input;
}
- while (localFormattingTokens.test(format)) {
+ while (i-- && localFormattingTokens.test(format)) {
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
}
if (!formatFunctions[format]) {
formatFunctions[format] = makeFormatFunction(format);
}
- return formatFunctions[format](m, getValueFromArray, lang.ordinal, leftZeroFill, lang.meridiem);
+ return formatFunctions[format](m);
}
@@ -442,8 +524,8 @@
// function to convert string input to date
function addTimeToArrayFromToken(token, input, datePartArray, config) {
- var a;
- //console.log('addTime', format, input);
+ var a, b;
+
switch (token) {
// MONTH
case 'M' : // fall through to MM
@@ -455,9 +537,14 @@
for (a = 0; a < 12; a++) {
if (getLangDefinition().monthsParse[a].test(input)) {
datePartArray[1] = a;
+ b = true;
break;
}
}
+ // if we didn't find a month name, mark the date as invalid.
+ if (!b) {
+ datePartArray[8] = false;
+ }
break;
// DAY OF MONTH
case 'D' : // fall through to DDDD
@@ -470,8 +557,7 @@
break;
// YEAR
case 'YY' :
- input = ~~input;
- datePartArray[0] = input + (input > 70 ? 1900 : 2000);
+ datePartArray[0] = ~~input + (~~input > 70 ? 1900 : 2000);
break;
case 'YYYY' :
datePartArray[0] = ~~Math.abs(input);
@@ -522,10 +608,19 @@
}
break;
}
+
+ // if the input is null, the date is not valid
+ if (input == null) {
+ datePartArray[8] = false;
+ }
}
// date from string and format string
function makeDateFromStringAndFormat(string, format) {
+ // This array is used to make a Date, either with `new Date` or `Date.UTC`
+ // We store some additional data on the array for validation
+ // datePartArray[7] is true if the Date was created with `Date.UTC` and false if created with `new Date`
+ // datePartArray[8] is false if the Date is invalid, and undefined if the validity is unknown.
var datePartArray = [0, 0, 1, 0, 0, 0, 0],
config = {
tzh : 0, // timezone hour offset
@@ -536,8 +631,13 @@
for (i = 0; i < tokens.length; i++) {
parsedInput = (getParseRegexForToken(tokens[i]).exec(string) || [])[0];
- string = string.replace(getParseRegexForToken(tokens[i]), '');
- addTimeToArrayFromToken(tokens[i], parsedInput, datePartArray, config);
+ if (parsedInput) {
+ string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
+ }
+ // don't parse if its not a known token
+ if (formatTokenFunctions[tokens[i]]) {
+ addTimeToArrayFromToken(tokens[i], parsedInput, datePartArray, config);
+ }
}
// handle am pm
if (config.isPm && datePartArray[3] < 12) {
@@ -547,11 +647,8 @@
if (config.isPm === false && datePartArray[3] === 12) {
datePartArray[3] = 0;
}
- // handle timezone
- datePartArray[3] += config.tzh;
- datePartArray[4] += config.tzm;
// return
- return dateFromArray(datePartArray, config.isUTC);
+ return dateFromArray(datePartArray, config.isUTC, config.tzh, config.tzm);
}
// date from string and array of format strings
@@ -586,7 +683,7 @@
break;
}
}
- return parseTokenTimezone.exec(string) ?
+ return parseTokenTimezone.exec(string) ?
makeDateFromStringAndFormat(string, format + ' Z') :
makeDateFromStringAndFormat(string, format);
}
@@ -855,7 +952,12 @@
isValid : function () {
if (this._a) {
- return !compareArrays(this._a, (this._a[7] ? moment.utc(this) : this).toArray());
+ // if the parser finds that the input is invalid, it sets
+ // the eighth item in the input array to false.
+ if (this._a[8] != null) {
+ return !!this._a[8];
+ }
+ return !compareArrays(this._a, (this._a[7] ? moment.utc(this._a) : moment(this._a)).toArray());
}
return !isNaN(this._d.getTime());
},
@@ -936,7 +1038,7 @@
},
isDST : function () {
- return (this.zone() < moment([this.year()]).zone() ||
+ return (this.zone() < moment([this.year()]).zone() ||
this.zone() < moment([this.year(), 5]).zone());
},
@@ -975,7 +1077,7 @@
endOf: function (val) {
return this.startOf(val).add(val.replace(/s?$/, 's'), 1).subtract('ms', 1);
},
-
+
sod: function () {
return this.clone().startOf('day');
},
@@ -1047,10 +1149,15 @@
humanize : function (withSuffix) {
var difference = +this,
rel = this.lang().relativeTime,
- output = relativeTime(difference, !withSuffix, this.lang());
+ output = relativeTime(difference, !withSuffix, this.lang()),
+ fromNow = difference <= 0 ? rel.past : rel.future;
if (withSuffix) {
- output = (difference <= 0 ? rel.past : rel.future).replace(/%s/i, output);
+ if (typeof fromNow === 'function') {
+ output = fromNow(output);
+ } else {
+ output = fromNow.replace(/%s/i, output);
+ }
}
return output;
@@ -1103,4 +1210,4 @@
return moment;
});
}
-}).call(this, Date);
+}).call(this);
View
10 package.json
@@ -2,7 +2,7 @@
"name" : "miso.dataset",
"title" : "Miso.Dataset",
"description" : "Dataset is a javascript library makes managing the data behind client-side visualisations easy, including realtime data. It takes care of loading, parsing, sorting, filtering and querying of datasets as well as the creation of derivative datasets. Dataset is part of the Miso Toolkit",
- "version" : "0.2.2",
+ "version" : "0.3.0",
"homepage" : "http://github.com/misoproject/dataset",
"authors" : "Alex Graul, Irene Ros",
@@ -21,7 +21,7 @@
}
],
- "main": "dist/node/miso.ds.deps.0.2.2",
+ "main": "dist/node/miso.ds.deps.0.3.0",
"repository": {
"type": "git",
@@ -35,9 +35,9 @@
},
"dependencies": {
- "lodash": "0.7.0",
- "moment": "1.7.0",
- "underscore.deferred": "0.1.4",
+ "lodash": "0.9.0",
+ "moment": "1.7.2",
+ "underscore.deferred": "0.2.0",
"request": "2.9.153"
}
}
View
10 test/index.build.deps.html
@@ -5,8 +5,16 @@
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
<!-- Dataset source files -->
- <script src="../dist/miso.ds.deps.min.0.1.0.js"></script>
+ <script src="../dist/miso.ds.deps.min.0.3.0.js"></script>
+ <script type='text/javascript'>
+ window.Miso = window.Miso || (window.Miso = {});
+ window.Miso.Tester = {
+ foo : function() {
+ return 44;
+ },
+ };
+ </script>
<!-- Vendor deps, non-lib -->
<script src="vendor/jquery.js"></script>
<script src="vendor/qunit.js"></script>
View
10 test/index.build.deps.min.html
@@ -10,8 +10,16 @@
<script src="../lib/underscore.math.js"></script>
<script src="../lib/underscore.deferred.js"></script>
- <script src="../dist/miso.ds.0.1.0.js"></script>
+ <script src="../dist/miso.ds.deps.0.3.0.js"></script>
+ <script type='text/javascript'>
+ window.Miso = window.Miso || (window.Miso = {});
+ window.Miso.Tester = {
+ foo : function() {
+ return 44;
+ },
+ };
+ </script>
<!-- Load data sets -->
<script src="data/short_obj.js"></script>
<script src="data/alphabet_obj.js"></script>
View
2 test/index.build.html
@@ -13,7 +13,7 @@
},
};
</script>
- <script src="../dist/miso.ds.deps.0.2.1.js"></script>
+ <script src="../dist/miso.ds.deps.0.3.0.js"></script>
<!-- Vendor deps, non-lib -->
<script src="vendor/jquery.js"></script>
View
3 test/index.min.html
@@ -13,7 +13,7 @@
<script src="../lib/underscore.js"></script>
<script src="../lib/underscore.math.js"></script>
<script src="../lib/underscore.deferred.js"></script>
- <script src="../dist/miso.ds.min.0.1.0.js"></script>
+ <script src="../dist/miso.ds.min.0.3.0.js"></script>
<!-- Load data sets -->
<script src="data/short_obj.js"></script>
@@ -36,7 +36,6 @@
<script src="unit/events.js"></script>
<script src="unit/derived.js"></script>
<script src="unit/importers.js"></script>
-
</head>
<body>
View
34 test/unit/bugs.js
@@ -374,40 +374,6 @@
});
});
- // test("Not even sure yet", function() {
- // var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fwww.tfl.gov.uk/tfl/syndication/feeds/cycle-hire/livecyclehireupdates.xml'&format=json&diagnostics=true&callback=";
- // var ds = new Miso.Dataset({
- // url: url,
- // jsonp: true,
- // interval: 5000,
- // extract: function ( data ) {
- // snapshot = data.query.results.stations.station;
- // return snapshot;
- // },
- // resetOnFetch: false,
- // columns: [ // need to specify these so Dataset doesn't trip over null values etc
- // { name: 'lat', type: 'number' },
- // { name: 'long', type: 'number' },
- // { name: 'installDate', type: 'number' },
- // { name: 'distance', type: 'number' },
- // { name: 'nbBikes', type: 'number' },
- // { name: 'nbEmptyDocks', type: 'number' }
- // ],
- // sync: true,
- // uniqueAgainst: 'id',
- // idAttribute: 'id'
- // })
- // ds.fetch();
- // ds.sort( function ( stationA, stationB ) {
- // if (stationA.distance > stationB.distance) {
- // return 1;
- // } else {
- // return -1;
- // }
- // });
-
- // });
- //
test("Non -1/0/1 comparators cause a mess", 1, function() {
//we use this to check we've managed to update twice
//without an error about updating the ID column

0 comments on commit a3d87be

Please sign in to comment.
Something went wrong with that request. Please try again.