Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moussaka-client

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moussaka-client - npm Package Compare versions

Comparing version 0.1.2 to 0.1.6

2

bower.json
{
"name": "moussaka-client",
"version": "0.1.2",
"version": "0.1.6",
"authors": [

@@ -5,0 +5,0 @@ "Sean Dawson <contact@seandawson.info>"

@@ -1,2 +0,2 @@

/*! moussaka-client - v0.1.2 - 2014-10-15 */!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.MoussakaClient=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){!function(a,b){"use strict";var c=a("./libs/logger.js"),d=a("./libs/moussakaClient.js");c.trace("MoussakaClient module loaded."),b.exports=d}(a,b)},{"./libs/logger.js":2,"./libs/moussakaClient.js":3}],2:[function(a,b){!function(a,b){"use strict";var c=a("sprintf-js").sprintf,d=function(a){this.logLevel=a||this.severity.warning.level};d.prototype.severity={trace:{label:"trace",level:0},info:{label:"info",level:1},warning:{label:"warning",level:2},error:{label:"error",level:3},exception:{label:"exception",level:4}},d.prototype.log=function(a,b){a||(a=this.severity.info),b||(b="No message provided in log statement."),a.level>=this.logLevel&&console.log(c("[%s] [%s]: %s",(new Date).toLocaleTimeString(),a.label,b))},d.prototype.trace=function(a){this.log(this.severity.trace,a)},d.prototype.info=function(a){this.log(this.severity.info,a)},d.prototype.warning=function(a){this.log(this.severity.warning,a)},d.prototype.error=function(a){this.log(this.severity.error,a)},d.prototype.exception=function(a){this.log(this.severity.exception,a)},b.exports=new d}(a,b)},{"sprintf-js":13}],3:[function(a,b){!function(a,b){"use strict";var c=a("./utils.js"),d=a("lodash"),e=a("superagent"),f=a("./logger.js"),g=a("./ref.js"),h=a("path"),i=a("events").EventEmitter,j=a("util").inherits,k=function(a){c.validateRequiredOptions(a,["deviceName","apiKey","projectId","projectVersion"]),this.serverUrl="http://localhost:3000/",this.pollInterval=1e3,d.assign(this,a),this.registedVars={},this.connected=!1,this.dataSchema={},this.polling=!1,this.intervalId=null,this.pollErrorCount=0,this.pollReady=!0,a.logLevel&&(f.logLevel=a.logLevel)};j(k,i),k.prototype.getBaseUrl=function(){if(!this.serverUrl)throw new Error("Server URL not defined.");var a=this.serverUrl;return"/"===a.substr(-1)?a.substr(0,a.length-1):a},k.prototype.registerVar=function(a,b,c){if(this.registedVars[a])throw new Error("Variable with that name already registered.");var d=new g(b);return this.registedVars[a]={ref:d,schema:c},this.updateSchema(),d},k.prototype.updateSchema=function(){if(this.connected)throw new Error("Cannot update schema after connect.");var a={};d.each(this.registedVars,function(b,c){if(!b.schema){var d=null,e=b.ref;switch(f.trace("Updating schema with: "+c),f.trace("Type: "+typeof e.value),f.trace("Complex: "+!!e.value.getType),typeof e.value){case"boolean":d="boolean";break;case"number":d="float";break;case"string":d="string"}if(e.value.getType&&(d=e.value.getType()),!d)throw new Error("Cannot deduce object type. Please pass in a schema object.");b.schema={type:d}}a[c]=b.schema},this),this.dataSchema=a},k.prototype.connect=function(){var a=this.getBaseUrl()+h.join("/projects/",this.projectId,"devices/");f.trace("Connecting device at: "+a),e.put(a).send({projectId:this.projectId,projectVersion:this.projectVersion,deviceName:this.deviceName}).end(function(a,b){return a?this.emit("error",a):void(b.ok?(this.connected=!0,this._id=b.body._id,f.trace("Connected!: _id: "+this._id),this.emit("connect",this._id),this.beginPolling()):this.emit("error",new Error("Server returned error: Status: "+b.status+" Detail:"+b.body.detail)))}.bind(this))},k.prototype.disconnect=function(){var a=this.getBaseUrl()+h.join("/projects/",this.projectId,"devices/",this._id,"/");f.trace("Disconnecting device at: "+a),this.stopPolling(),e.del(a).end(function(a,b){return a?this.emit("error",a):void(b.ok?(this.connected=!1,this.emit("disconnect")):this.emit("error",new Error("Server returned error: Status: "+b.status+" Detail:"+b.body.detail)))}.bind(this))},k.prototype.beginPolling=function(){if(!this.connected||this.polling)throw new Error("This method should only be called by the connect function.");f.trace("Starting polling"),this.intervalId=setInterval(this.pollFn.bind(this),this.pollInterval),this.polling=!0},k.prototype.pollFn=function(){var a=this.getBaseUrl()+h.join("/projects/",this.projectId,"sessions/",this._id,"/updates/");f.trace("Polling with URL: "+a),this.emit("poll"),this.pollReady||f.warn("pollFn called before last poll completed. Skipping poll. Make sure poll frequency is not to fast."),this.pollReady=!1,e.get(a).end(function(a,b){return this.pollReady=!0,a?(++this.pollErrorCount>5&&(f.error("5 poll errors encountered in a row. Disconnecting..."),this.disconnect()),this.emit("error",a)):b.ok?(this.pollErrorCount=0,void this.applyUpdates(b.body)):this.emit("error",new Error("Server returned error: Status: "+b.status+" Detail:"+b.body.detail))}.bind(this))},k.prototype.stopPolling=function(){if(f.trace("Stopping polling"),!this.intervalId&&this.polling)throw new Error("Polling started but no intervalId.");if(!this.intervalId||!this.polling)throw new Error("Polling has not been started.");clearInterval(this.intervalId),this.polling=!1},k.prototype.applyUpdates=function(a){return a?void d.each(a,function(a,b){var c=a.values,d=this.registedVars[b],e=d.schema.type,g=d.ref;switch(d.schema.type){case"float":case"double":case"decimal":g.value=c.n;break;case"string":g.value=c.s;break;case"boolean":g.value=c.b;break;default:g.value.setValues?g.value.setValues(c):f.warn("Unsupported variable type: "+e)}},this):void f.warn("Updates is null.")},b.exports=k}(a,b)},{"./logger.js":2,"./ref.js":4,"./utils.js":5,events:6,lodash:12,path:8,superagent:14,util:11}],4:[function(a,b){!function(a,b){"use strict";var c=a("./logger.js"),d=function(a){var b=this;this.internalValue=a,this.internalType=typeof a,Object.defineProperty(this,"value",{get:function(){return b.internalValue},set:function(a){b.internalType!==typeof a&&c.warn("Type of value: "+typeof a+" does not match type of reference: "+b.internalType),b.internalValue=a}})};b.exports=d}(a,b)},{"./logger.js":2}],5:[function(a,b){!function(a,b){"use strict";{var c=a("lodash");a("./logger.js")}b.exports={validateRequiredOptions:function(a,b){return!a&&b.length>0?!1:(c.each(b,function(b){if(!c.contains(Object.keys(a),b))throw new Error("Missing required option: "+b)}),!0)}}}(a,b)},{"./logger.js":2,lodash:12}],6:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function d(a){return"function"==typeof a}function e(a){return"number"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(a){return void 0===a}b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!e(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],7:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],8:[function(a,b,c){(function(a){function b(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function d(a,b){if(a.filter)return a.filter(b);for(var c=[],d=0;d<a.length;d++)b(a[d],d,a)&&c.push(a[d]);return c}var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,f=function(a){return e.exec(a).slice(1)};c.resolve=function(){for(var c="",e=!1,f=arguments.length-1;f>=-1&&!e;f--){var g=f>=0?arguments[f]:a.cwd();if("string"!=typeof g)throw new TypeError("Arguments to path.resolve must be strings");g&&(c=g+"/"+c,e="/"===g.charAt(0))}return c=b(d(c.split("/"),function(a){return!!a}),!e).join("/"),(e?"/":"")+c||"."},c.normalize=function(a){var e=c.isAbsolute(a),f="/"===g(a,-1);return a=b(d(a.split("/"),function(a){return!!a}),!e).join("/"),a||e||(a="."),a&&f&&(a+="/"),(e?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){if("string"!=typeof a)throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b<a.length&&""===a[b];b++);for(var c=a.length-1;c>=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i<e.length;i++)j.push("..");return j=j.concat(f.slice(h)),j.join("/")},c.sep="/",c.delimiter=":",c.dirname=function(a){var b=f(a),c=b[0],d=b[1];return c||d?(d&&(d=d.substr(0,d.length-1)),c+d):"."},c.basename=function(a,b){var c=f(a)[2];return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return f(a)[3]};var g="b"==="ab".substr(-1)?function(a,b,c){return a.substr(b,c)}:function(a,b,c){return 0>b&&(b=a.length+b),a.substr(b,c)}}).call(this,a("_process"))},{_process:9}],9:[function(a,b){function c(){}var d=b.exports={};d.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),d.title="browser",d.browser=!0,d.env={},d.argv=[],d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(){throw new Error("process.chdir is not supported")}},{}],10:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],11:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c<arguments.length;c++)b.push(e(arguments[c]));return b.join(" ")}for(var c=1,d=arguments,f=d.length,g=String(a).replace(G,function(a){if("%%"===a)return"%";if(c>=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":10,_process:9,inherits:7}],12:[function(b,c,d){(function(b){(function(){function e(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d<e;)if(a[d]===b)return d;return-1}function f(a,b){var c=typeof b;if(a=a.cache,"boolean"==c||null==b)return a[b]?0:-1;"number"!=c&&"string"!=c&&(c="object");var d="number"==c?b:v+b;return a=(a=a[c])&&a[d],"object"==c?a&&e(a,b)>-1?0:-1:a?0:-1}function g(a){var b=this.cache,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:v+a,e=b[c]||(b[c]={});"object"==c?(e[d]||(e[d]=[])).push(a):e[d]=!0}}function h(a){return a.charCodeAt(0)}function i(a,b){for(var c=a.criteria,d=b.criteria,e=-1,f=c.length;++e<f;){var g=c[e],h=d[e];if(g!==h){if(g>h||"undefined"==typeof g)return 1;if(h>g||"undefined"==typeof h)return-1}}return a.index-b.index}function j(a){var b=-1,c=a.length,d=a[0],e=a[c/2|0],f=a[c-1];if(d&&"object"==typeof d&&e&&"object"==typeof e&&f&&"object"==typeof f)return!1;var h=m();h["false"]=h["null"]=h["true"]=h.undefined=!1;var i=m();for(i.array=a,i.cache=h,i.push=g;++b<c;)i.push(a[b]);return i}function k(a){return"\\"+Z[a]}function l(){return s.pop()||[]}function m(){return t.pop()||{array:null,cache:null,criteria:null,"false":!1,index:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,value:null}}function n(a){a.length=0,s.length<x&&s.push(a)}function o(a){var b=a.cache;b&&o(b),a.array=a.cache=a.criteria=a.object=a.number=a.string=a.value=null,t.length<x&&t.push(a)}function p(a,b,c){b||(b=0),"undefined"==typeof c&&(c=a?a.length:0);for(var d=-1,e=c-b||0,f=Array(0>e?0:e);++d<e;)f[d]=a[b+d];return f}function q(a){function b(a){return a&&"object"==typeof a&&!Zd(a)&&Hd.call(a,"__wrapped__")?a:new c(a)}function c(a,b){this.__chain__=!!b,this.__wrapped__=a}function d(a){function b(){if(d){var a=p(d);Id.apply(a,arguments)}if(this instanceof b){var f=s(c.prototype),g=c.apply(f,a||arguments);return Eb(g)?g:f}return c.apply(e,a||arguments)}var c=a[0],d=a[2],e=a[4];return Yd(b,a),b}function g(a,b,c,d,e){if(c){var f=c(a);if("undefined"!=typeof f)return f}var h=Eb(a);if(!h)return a;var i=Ad.call(a);if(!V[i])return a;var j=Wd[i];switch(i){case O:case P:return new j(+a);case R:case U:return new j(a);case T:return f=j(a.source,D.exec(a)),f.lastIndex=a.lastIndex,f}var k=Zd(a);if(b){var m=!d;d||(d=l()),e||(e=l());for(var o=d.length;o--;)if(d[o]==a)return e[o];f=k?j(a.length):{}}else f=k?p(a):ee({},a);return k&&(Hd.call(a,"index")&&(f.index=a.index),Hd.call(a,"input")&&(f.input=a.input)),b?(d.push(a),e.push(f),(k?Yb:he)(a,function(a,h){f[h]=g(a,b,c,d,e)}),m&&(n(d),n(e)),f):f}function s(a){return Eb(a)?Nd(a):{}}function t(a,b,c){if("function"!=typeof a)return Zc;if("undefined"==typeof b||!("prototype"in a))return a;var d=a.__bindData__;if("undefined"==typeof d&&(Xd.funcNames&&(d=!a.name),d=d||!Xd.funcDecomp,!d)){var e=Fd.call(a);Xd.funcNames||(d=!E.test(e)),d||(d=I.test(e),Yd(a,d))}if(d===!1||d!==!0&&1&d[1])return a;switch(c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return Ic(a,b)}function x(a){function b(){var a=i?g:this;if(e){var n=p(e);Id.apply(n,arguments)}if((f||k)&&(n||(n=p(arguments)),f&&Id.apply(n,f),k&&n.length<h))return d|=16,x([c,l?d:-4&d,n,null,g,h]);if(n||(n=arguments),j&&(c=a[m]),this instanceof b){a=s(c.prototype);var o=c.apply(a,n);return Eb(o)?o:a}return c.apply(a,n)}var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=1&d,j=2&d,k=4&d,l=8&d,m=c;return Yd(b,a),b}function Z(a,b){var c=-1,d=ib(),g=a?a.length:0,h=g>=w&&d===e,i=[];if(h){var k=j(b);k?(d=f,b=k):h=!1}for(;++c<g;){var l=a[c];d(b,l)<0&&i.push(l)}return h&&o(b),i}function _(a,b,c,d){for(var e=(d||0)-1,f=a?a.length:0,g=[];++e<f;){var h=a[e];if(h&&"object"==typeof h&&"number"==typeof h.length&&(Zd(h)||mb(h))){b||(h=_(h,b,c));var i=-1,j=h.length,k=g.length;for(g.length+=j;++i<j;)g[k++]=h[i]}else c||g.push(h)}return g}function ab(a,b,c,d,e,f){if(c){var g=c(a,b);if("undefined"!=typeof g)return!!g}if(a===b)return 0!==a||1/a==1/b;var h=typeof a,i=typeof b;if(!(a!==a||a&&Y[h]||b&&Y[i]))return!1;if(null==a||null==b)return a===b;var j=Ad.call(a),k=Ad.call(b);if(j==M&&(j=S),k==M&&(k=S),j!=k)return!1;switch(j){case O:case P:return+a==+b;case R:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case T:case U:return a==vd(b)}var m=j==N;if(!m){var o=Hd.call(a,"__wrapped__"),p=Hd.call(b,"__wrapped__");if(o||p)return ab(o?a.__wrapped__:a,p?b.__wrapped__:b,c,d,e,f);if(j!=S)return!1;var q=a.constructor,r=b.constructor;if(q!=r&&!(Db(q)&&q instanceof q&&Db(r)&&r instanceof r)&&"constructor"in a&&"constructor"in b)return!1}var s=!e;e||(e=l()),f||(f=l());for(var t=e.length;t--;)if(e[t]==a)return f[t]==b;var u=0;if(g=!0,e.push(a),f.push(b),m){if(t=a.length,u=b.length,g=u==t,g||d)for(;u--;){var v=t,w=b[u];if(d)for(;v--&&!(g=ab(a[v],w,c,d,e,f)););else if(!(g=ab(a[u],w,c,d,e,f)))break}}else ge(b,function(b,h,i){return Hd.call(i,h)?(u++,g=Hd.call(a,h)&&ab(a[h],b,c,d,e,f)):void 0}),g&&!d&&ge(a,function(a,b,c){return Hd.call(c,b)?g=--u>-1:void 0});return e.pop(),f.pop(),s&&(n(e),n(f)),g}function bb(a,b,c,d,e){(Zd(b)?Yb:he)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Zd(b))||ie(b))){for(var k=d.length;k--;)if(g=d[k]==b){j=e[k];break}if(!g){var l;c&&(i=c(j,b),(l="undefined"!=typeof i)&&(j=i)),l||(j=h?Zd(j)?j:[]:ie(j)?j:{}),d.push(b),e.push(j),l||bb(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function cb(a,b){return a+Ed(Vd()*(b-a+1))}function eb(a,b,c){var d=-1,g=ib(),h=a?a.length:0,i=[],k=!b&&h>=w&&g===e,m=c||k?l():i;if(k){var p=j(m);g=f,m=p}for(;++d<h;){var q=a[d],r=c?c(q,d,a):q;(b?!d||m[m.length-1]!==r:g(m,r)<0)&&((c||k)&&m.push(r),i.push(q))}return k?(n(m.array),o(m)):c&&n(m),i}function fb(a){return function(c,d,e){var f={};d=b.createCallback(d,e,3);var g=-1,h=c?c.length:0;if("number"==typeof h)for(;++g<h;){var i=c[g];a(f,i,d(i,g,c),c)}else he(c,function(b,c,e){a(f,b,d(b,c,e),e)});return f}}function gb(a,b,c,e,f,g){var h=1&b,i=2&b,j=4&b,k=16&b,l=32&b;if(!i&&!Db(a))throw new wd;k&&!c.length&&(b&=-17,k=c=!1),l&&!e.length&&(b&=-33,l=e=!1);var m=a&&a.__bindData__;if(m&&m!==!0)return m=p(m),m[2]&&(m[2]=p(m[2])),m[3]&&(m[3]=p(m[3])),!h||1&m[1]||(m[4]=f),!h&&1&m[1]&&(b|=8),!j||4&m[1]||(m[5]=g),k&&Id.apply(m[2]||(m[2]=[]),c),l&&Ld.apply(m[3]||(m[3]=[]),e),m[1]|=b,gb.apply(null,m);var n=1==b||17===b?d:x;return n([a,b,c,e,f,g])}function hb(a){return ae[a]}function ib(){var a=(a=b.indexOf)===rc?e:a;return a}function jb(a){return"function"==typeof a&&Bd.test(a)}function kb(a){var b,c;return a&&Ad.call(a)==S&&(b=a.constructor,!Db(b)||b instanceof b)?(ge(a,function(a,b){c=b}),"undefined"==typeof c||Hd.call(a,c)):!1}function lb(a){return be[a]}function mb(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ad.call(a)==M||!1}function nb(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c=b,b=!1),g(a,b,"function"==typeof c&&t(c,d,1))}function ob(a,b,c){return g(a,!0,"function"==typeof b&&t(b,c,1))}function pb(a,b){var c=s(a);return b?ee(c,b):c}function qb(a,c,d){var e;return c=b.createCallback(c,d,3),he(a,function(a,b,d){return c(a,b,d)?(e=b,!1):void 0}),e}function rb(a,c,d){var e;return c=b.createCallback(c,d,3),tb(a,function(a,b,d){return c(a,b,d)?(e=b,!1):void 0}),e}function sb(a,b,c){var d=[];ge(a,function(a,b){d.push(b,a)});var e=d.length;for(b=t(b,c,3);e--&&b(d[e--],d[e],a)!==!1;);return a}function tb(a,b,c){var d=_d(a),e=d.length;for(b=t(b,c,3);e--;){var f=d[e];if(b(a[f],f,a)===!1)break}return a}function ub(a){var b=[];return ge(a,function(a,c){Db(a)&&b.push(c)}),b.sort()}function vb(a,b){return a?Hd.call(a,b):!1}function wb(a){for(var b=-1,c=_d(a),d=c.length,e={};++b<d;){var f=c[b];e[a[f]]=f}return e}function xb(a){return a===!0||a===!1||a&&"object"==typeof a&&Ad.call(a)==O||!1}function yb(a){return a&&"object"==typeof a&&Ad.call(a)==P||!1}function zb(a){return a&&1===a.nodeType||!1}function Ab(a){var b=!0;if(!a)return b;var c=Ad.call(a),d=a.length;return c==N||c==U||c==M||c==S&&"number"==typeof d&&Db(a.splice)?!d:(he(a,function(){return b=!1}),b)}function Bb(a,b,c,d){return ab(a,b,"function"==typeof c&&t(c,d,2))}function Cb(a){return Pd(a)&&!Qd(parseFloat(a))}function Db(a){return"function"==typeof a}function Eb(a){return!(!a||!Y[typeof a])}function Fb(a){return Hb(a)&&a!=+a}function Gb(a){return null===a}function Hb(a){return"number"==typeof a||a&&"object"==typeof a&&Ad.call(a)==R||!1}function Ib(a){return a&&"object"==typeof a&&Ad.call(a)==T||!1}function Jb(a){return"string"==typeof a||a&&"object"==typeof a&&Ad.call(a)==U||!1}function Kb(a){return"undefined"==typeof a}function Lb(a,c,d){var e={};return c=b.createCallback(c,d,3),he(a,function(a,b,d){e[b]=c(a,b,d)}),e}function Mb(a){var b=arguments,c=2;if(!Eb(a))return a;if("number"!=typeof b[2]&&(c=b.length),c>3&&"function"==typeof b[c-2])var d=t(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var e=p(arguments,1,c),f=-1,g=l(),h=l();++f<c;)bb(a,e[f],d,g,h);return n(g),n(h),a}function Nb(a,c,d){var e={};if("function"!=typeof c){var f=[];ge(a,function(a,b){f.push(b)}),f=Z(f,_(arguments,!0,!1,1));for(var g=-1,h=f.length;++g<h;){var i=f[g];e[i]=a[i]}}else c=b.createCallback(c,d,3),ge(a,function(a,b,d){c(a,b,d)||(e[b]=a)});return e}function Ob(a){for(var b=-1,c=_d(a),d=c.length,e=nd(d);++b<d;){var f=c[b];e[b]=[f,a[f]]}return e}function Pb(a,c,d){var e={};if("function"!=typeof c)for(var f=-1,g=_(arguments,!0,!1,1),h=Eb(a)?g.length:0;++f<h;){var i=g[f];i in a&&(e[i]=a[i])}else c=b.createCallback(c,d,3),ge(a,function(a,b,d){c(a,b,d)&&(e[b]=a)});return e}function Qb(a,c,d,e){var f=Zd(a);if(null==d)if(f)d=[];else{var g=a&&a.constructor,h=g&&g.prototype;d=s(h)}return c&&(c=b.createCallback(c,e,4),(f?Yb:he)(a,function(a,b,e){return c(d,a,b,e)})),d}function Rb(a){for(var b=-1,c=_d(a),d=c.length,e=nd(d);++b<d;)e[b]=a[c[b]];return e}function Sb(a){for(var b=arguments,c=-1,d=_(b,!0,!1,1),e=b[2]&&b[2][b[1]]===a?1:d.length,f=nd(e);++c<e;)f[c]=a[d[c]];return f}function Tb(a,b,c){var d=-1,e=ib(),f=a?a.length:0,g=!1;return c=(0>c?Sd(0,f+c):c)||0,Zd(a)?g=e(a,b,c)>-1:"number"==typeof f?g=(Jb(a)?a.indexOf(b,c):e(a,b,c))>-1:he(a,function(a){return++d>=c?!(g=a===b):void 0}),g}function Ub(a,c,d){var e=!0;c=b.createCallback(c,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&(e=!!c(a[f],f,a)););else he(a,function(a,b,d){return e=!!c(a,b,d)});return e}function Vb(a,c,d){var e=[];c=b.createCallback(c,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g;){var h=a[f];c(h,f,a)&&e.push(h)}else he(a,function(a,b,d){c(a,b,d)&&e.push(a)});return e}function Wb(a,c,d){c=b.createCallback(c,d,3);var e=-1,f=a?a.length:0;if("number"!=typeof f){var g;return he(a,function(a,b,d){return c(a,b,d)?(g=a,!1):void 0}),g}for(;++e<f;){var h=a[e];if(c(h,e,a))return h}}function Xb(a,c,d){var e;return c=b.createCallback(c,d,3),Zb(a,function(a,b,d){return c(a,b,d)?(e=a,!1):void 0}),e}function Yb(a,b,c){var d=-1,e=a?a.length:0;if(b=b&&"undefined"==typeof c?b:t(b,c,3),"number"==typeof e)for(;++d<e&&b(a[d],d,a)!==!1;);else he(a,b);return a}function Zb(a,b,c){var d=a?a.length:0;if(b=b&&"undefined"==typeof c?b:t(b,c,3),"number"==typeof d)for(;d--&&b(a[d],d,a)!==!1;);else{var e=_d(a);d=e.length,he(a,function(a,c,f){return c=e?e[--d]:--d,b(f[c],c,f)})}return a}function $b(a,b){var c=p(arguments,2),d=-1,e="function"==typeof b,f=a?a.length:0,g=nd("number"==typeof f?f:0);return Yb(a,function(a){g[++d]=(e?b:a[b]).apply(a,c)}),g}function _b(a,c,d){var e=-1,f=a?a.length:0;if(c=b.createCallback(c,d,3),"number"==typeof f)for(var g=nd(f);++e<f;)g[e]=c(a[e],e,a);else g=[],he(a,function(a,b,d){g[++e]=c(a,b,d)});return g}function ac(a,c,d){var e=-1/0,f=e;if("function"!=typeof c&&d&&d[c]===a&&(c=null),null==c&&Zd(a))for(var g=-1,i=a.length;++g<i;){var j=a[g];j>f&&(f=j)}else c=null==c&&Jb(a)?h:b.createCallback(c,d,3),Yb(a,function(a,b,d){var g=c(a,b,d);g>e&&(e=g,f=a)});return f}function bc(a,c,d){var e=1/0,f=e;if("function"!=typeof c&&d&&d[c]===a&&(c=null),null==c&&Zd(a))for(var g=-1,i=a.length;++g<i;){var j=a[g];
f>j&&(f=j)}else c=null==c&&Jb(a)?h:b.createCallback(c,d,3),Yb(a,function(a,b,d){var g=c(a,b,d);e>g&&(e=g,f=a)});return f}function cc(a,c,d,e){if(!a)return d;var f=arguments.length<3;c=b.createCallback(c,e,4);var g=-1,h=a.length;if("number"==typeof h)for(f&&(d=a[++g]);++g<h;)d=c(d,a[g],g,a);else he(a,function(a,b,e){d=f?(f=!1,a):c(d,a,b,e)});return d}function dc(a,c,d,e){var f=arguments.length<3;return c=b.createCallback(c,e,4),Zb(a,function(a,b,e){d=f?(f=!1,a):c(d,a,b,e)}),d}function ec(a,c,d){return c=b.createCallback(c,d,3),Vb(a,function(a,b,d){return!c(a,b,d)})}function fc(a,b,c){if(a&&"number"!=typeof a.length&&(a=Rb(a)),null==b||c)return a?a[cb(0,a.length-1)]:r;var d=gc(a);return d.length=Td(Sd(0,b),d.length),d}function gc(a){var b=-1,c=a?a.length:0,d=nd("number"==typeof c?c:0);return Yb(a,function(a){var c=cb(0,++b);d[b]=d[c],d[c]=a}),d}function hc(a){var b=a?a.length:0;return"number"==typeof b?b:_d(a).length}function ic(a,c,d){var e;c=b.createCallback(c,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&!(e=c(a[f],f,a)););else he(a,function(a,b,d){return!(e=c(a,b,d))});return!!e}function jc(a,c,d){var e=-1,f=Zd(c),g=a?a.length:0,h=nd("number"==typeof g?g:0);for(f||(c=b.createCallback(c,d,3)),Yb(a,function(a,b,d){var g=h[++e]=m();f?g.criteria=_b(c,function(b){return a[b]}):(g.criteria=l())[0]=c(a,b,d),g.index=e,g.value=a}),g=h.length,h.sort(i);g--;){var j=h[g];h[g]=j.value,f||n(j.criteria),o(j)}return h}function kc(a){return a&&"number"==typeof a.length?p(a):Rb(a)}function lc(a){for(var b=-1,c=a?a.length:0,d=[];++b<c;){var e=a[b];e&&d.push(e)}return d}function mc(a){return Z(a,_(arguments,!0,!0,1))}function nc(a,c,d){var e=-1,f=a?a.length:0;for(c=b.createCallback(c,d,3);++e<f;)if(c(a[e],e,a))return e;return-1}function oc(a,c,d){var e=a?a.length:0;for(c=b.createCallback(c,d,3);e--;)if(c(a[e],e,a))return e;return-1}function pc(a,c,d){var e=0,f=a?a.length:0;if("number"!=typeof c&&null!=c){var g=-1;for(c=b.createCallback(c,d,3);++g<f&&c(a[g],g,a);)e++}else if(e=c,null==e||d)return a?a[0]:r;return p(a,0,Td(Sd(0,e),f))}function qc(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c="function"!=typeof b&&d&&d[b]===a?null:b,b=!1),null!=c&&(a=_b(a,c,d)),_(a,b)}function rc(a,b,c){if("number"==typeof c){var d=a?a.length:0;c=0>c?Sd(0,d+c):c||0}else if(c){var f=Ac(a,b);return a[f]===b?f:-1}return e(a,b,c)}function sc(a,c,d){var e=0,f=a?a.length:0;if("number"!=typeof c&&null!=c){var g=f;for(c=b.createCallback(c,d,3);g--&&c(a[g],g,a);)e++}else e=null==c||d?1:c||e;return p(a,0,Td(Sd(0,f-e),f))}function tc(){for(var a=[],b=-1,c=arguments.length,d=l(),g=ib(),h=g===e,i=l();++b<c;){var k=arguments[b];(Zd(k)||mb(k))&&(a.push(k),d.push(h&&k.length>=w&&j(b?a[b]:i)))}var m=a[0],p=-1,q=m?m.length:0,r=[];a:for(;++p<q;){var s=d[0];if(k=m[p],(s?f(s,k):g(i,k))<0){for(b=c,(s||i).push(k);--b;)if(s=d[b],(s?f(s,k):g(a[b],k))<0)continue a;r.push(k)}}for(;c--;)s=d[c],s&&o(s);return n(d),n(i),r}function uc(a,c,d){var e=0,f=a?a.length:0;if("number"!=typeof c&&null!=c){var g=f;for(c=b.createCallback(c,d,3);g--&&c(a[g],g,a);)e++}else if(e=c,null==e||d)return a?a[f-1]:r;return p(a,Sd(0,f-e))}function vc(a,b,c){var d=a?a.length:0;for("number"==typeof c&&(d=(0>c?Sd(0,d+c):Td(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function wc(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++c<d;)for(var f=-1,g=b[c];++f<e;)a[f]===g&&(Kd.call(a,f--,1),e--);return a}function xc(a,b,c){a=+a||0,c="number"==typeof c?c:+c||1,null==b&&(b=a,a=0);for(var d=-1,e=Sd(0,Cd((b-a)/(c||1))),f=nd(e);++d<e;)f[d]=a,a+=c;return f}function yc(a,c,d){var e=-1,f=a?a.length:0,g=[];for(c=b.createCallback(c,d,3);++e<f;){var h=a[e];c(h,e,a)&&(g.push(h),Kd.call(a,e--,1),f--)}return g}function zc(a,c,d){if("number"!=typeof c&&null!=c){var e=0,f=-1,g=a?a.length:0;for(c=b.createCallback(c,d,3);++f<g&&c(a[f],f,a);)e++}else e=null==c||d?1:Sd(0,c);return p(a,e)}function Ac(a,c,d,e){var f=0,g=a?a.length:f;for(d=d?b.createCallback(d,e,1):Zc,c=d(c);g>f;){var h=f+g>>>1;d(a[h])<c?f=h+1:g=h}return f}function Bc(){return eb(_(arguments,!0,!0))}function Cc(a,c,d,e){return"boolean"!=typeof c&&null!=c&&(e=d,d="function"!=typeof c&&e&&e[c]===a?null:c,c=!1),null!=d&&(d=b.createCallback(d,e,3)),eb(a,c,d)}function Dc(a){return Z(a,p(arguments,1))}function Ec(){for(var a=-1,b=arguments.length;++a<b;){var c=arguments[a];if(Zd(c)||mb(c))var d=d?eb(Z(d,c).concat(Z(c,d))):c}return d||[]}function Fc(){for(var a=arguments.length>1?arguments:arguments[0],b=-1,c=a?ac(me(a,"length")):0,d=nd(0>c?0:c);++b<c;)d[b]=me(a,b);return d}function Gc(a,b){var c=-1,d=a?a.length:0,e={};for(b||!d||Zd(a[0])||(b=[]);++c<d;){var f=a[c];b?e[f]=b[c]:f&&(e[f[0]]=f[1])}return e}function Hc(a,b){if(!Db(b))throw new wd;return function(){return--a<1?b.apply(this,arguments):void 0}}function Ic(a,b){return arguments.length>2?gb(a,17,p(arguments,2),null,b):gb(a,1,null,null,b)}function Jc(a){for(var b=arguments.length>1?_(arguments,!0,!1,1):ub(a),c=-1,d=b.length;++c<d;){var e=b[c];a[e]=gb(a[e],1,null,null,a)}return a}function Kc(a,b){return arguments.length>2?gb(b,19,p(arguments,2),null,a):gb(b,3,null,null,a)}function Lc(){for(var a=arguments,b=a.length;b--;)if(!Db(a[b]))throw new wd;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Mc(a,b){return b="number"==typeof b?b:+b||a.length,gb(a,4,null,null,null,b)}function Nc(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!Db(a))throw new wd;if(b=Sd(0,b)||0,c===!0){var n=!0;m=!1}else Eb(c)&&(n=c.leading,l="maxWait"in c&&(Sd(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(oe()-g);if(0>=c){e&&Dd(e);var l=j;e=i=j=r,l&&(k=oe(),f=a.apply(h,d),i||e||(d=h=null))}else i=Jd(o,c)},p=function(){i&&Dd(i),e=i=j=r,(m||l!==b)&&(k=oe(),f=a.apply(h,d),i||e||(d=h=null))};return function(){if(d=arguments,g=oe(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k),r=0>=q;r?(e&&(e=Dd(e)),k=g,f=a.apply(h,d)):e||(e=Jd(p,q))}return r&&i?i=Dd(i):i||b===l||(i=Jd(o,b)),c&&(r=!0,f=a.apply(h,d)),!r||i||e||(d=h=null),f}}function Oc(a){if(!Db(a))throw new wd;var b=p(arguments,1);return Jd(function(){a.apply(r,b)},1)}function Pc(a,b){if(!Db(a))throw new wd;var c=p(arguments,2);return Jd(function(){a.apply(r,c)},b)}function Qc(a,b){if(!Db(a))throw new wd;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):v+arguments[0];return Hd.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Rc(a){var b,c;if(!Db(a))throw new wd;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Sc(a){return gb(a,16,p(arguments,1))}function Tc(a){return gb(a,32,null,p(arguments,1))}function Uc(a,b,c){var d=!0,e=!0;if(!Db(a))throw new wd;return c===!1?d=!1:Eb(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),W.leading=d,W.maxWait=b,W.trailing=e,Nc(a,b,W)}function Vc(a,b){return gb(b,16,[a])}function Wc(a){return function(){return a}}function Xc(a,b,c){var d=typeof a;if(null==a||"function"==d)return t(a,b,c);if("object"!=d)return bd(a);var e=_d(a),f=e[0],g=a[f];return 1!=e.length||g!==g||Eb(g)?function(b){for(var c=e.length,d=!1;c--&&(d=ab(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return g===b&&(0!==g||1/g==1/b)}}function Yc(a){return null==a?"":vd(a).replace(de,hb)}function Zc(a){return a}function $c(a,d,e){var f=!0,g=d&&ub(d);d&&(e||g.length)||(null==e&&(e=d),h=c,d=a,a=b,g=ub(d)),e===!1?f=!1:Eb(e)&&"chain"in e&&(f=e.chain);var h=a,i=Db(h);Yb(g,function(b){var c=a[b]=d[b];i&&(h.prototype[b]=function(){var b=this.__chain__,d=this.__wrapped__,e=[d];Id.apply(e,arguments);var g=c.apply(a,e);if(f||b){if(d===g&&Eb(g))return this;g=new h(g),g.__chain__=b}return g})})}function _c(){return a._=zd,this}function ad(){}function bd(a){return function(b){return b[a]}}function cd(a,b,c){var d=null==a,e=null==b;if(null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0,c||a%1||b%1){var f=Vd();return Td(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b)}return cb(a,b)}function dd(a,b){if(a){var c=a[b];return Db(c)?a[b]():c}}function ed(a,c,d){var e=b.templateSettings;a=vd(a||""),d=fe({},d,e);var f,g=fe({},d.imports,e.imports),h=_d(g),i=Rb(g),j=0,l=d.interpolate||H,m="__p += '",n=ud((d.escape||H).source+"|"+l.source+"|"+(l===F?C:H).source+"|"+(d.evaluate||H).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(j,h).replace(J,k),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),j=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(z,""):m).replace(A,"$1").replace(B,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+L++ +"]")+"\n*/";try{var s=qd(h,"return "+m+q).apply(r,i)}catch(t){throw t.source=m,t}return c?s(c):(s.source=m,s)}function fd(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=nd(a);for(b=t(b,c,1);++d<a;)e[d]=b(d);return e}function gd(a){return null==a?"":vd(a).replace(ce,lb)}function hd(a){var b=++u;return vd(null==a?"":a)+b}function id(a){return a=new c(a),a.__chain__=!0,a}function jd(a,b){return b(a),a}function kd(){return this.__chain__=!0,this}function ld(){return vd(this.__wrapped__)}function md(){return this.__wrapped__}a=a?db.defaults($.Object(),a,db.pick($,K)):$;var nd=a.Array,od=a.Boolean,pd=a.Date,qd=a.Function,rd=a.Math,sd=a.Number,td=a.Object,ud=a.RegExp,vd=a.String,wd=a.TypeError,xd=[],yd=td.prototype,zd=a._,Ad=yd.toString,Bd=ud("^"+vd(Ad).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Cd=rd.ceil,Dd=a.clearTimeout,Ed=rd.floor,Fd=qd.prototype.toString,Gd=jb(Gd=td.getPrototypeOf)&&Gd,Hd=yd.hasOwnProperty,Id=xd.push,Jd=a.setTimeout,Kd=xd.splice,Ld=xd.unshift,Md=function(){try{var a={},b=jb(b=td.defineProperty)&&b,c=b(a,a,a)&&b}catch(d){}return c}(),Nd=jb(Nd=td.create)&&Nd,Od=jb(Od=nd.isArray)&&Od,Pd=a.isFinite,Qd=a.isNaN,Rd=jb(Rd=td.keys)&&Rd,Sd=rd.max,Td=rd.min,Ud=a.parseInt,Vd=rd.random,Wd={};Wd[N]=nd,Wd[O]=od,Wd[P]=pd,Wd[Q]=qd,Wd[S]=td,Wd[R]=sd,Wd[T]=ud,Wd[U]=vd,c.prototype=b.prototype;var Xd=b.support={};Xd.funcDecomp=!jb(a.WinRTError)&&I.test(q),Xd.funcNames="string"==typeof qd.name,b.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:b}},Nd||(s=function(){function b(){}return function(c){if(Eb(c)){b.prototype=c;var d=new b;b.prototype=null}return d||a.Object()}}());var Yd=Md?function(a,b){X.value=b,Md(a,"__bindData__",X)}:ad,Zd=Od||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ad.call(a)==N||!1},$d=function(a){var b,c=a,d=[];if(!c)return d;if(!Y[typeof a])return d;for(b in c)Hd.call(c,b)&&d.push(b);return d},_d=Rd?function(a){return Eb(a)?Rd(a):[]}:$d,ae={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},be=wb(ae),ce=ud("("+_d(be).join("|")+")","g"),de=ud("["+_d(ae).join("")+"]","g"),ee=function(a,b,c){var d,e=a,f=e;if(!e)return f;var g=arguments,h=0,i="number"==typeof c?2:g.length;if(i>3&&"function"==typeof g[i-2])var j=t(g[--i-1],g[i--],2);else i>2&&"function"==typeof g[i-1]&&(j=g[--i]);for(;++h<i;)if(e=g[h],e&&Y[typeof e])for(var k=-1,l=Y[typeof e]&&_d(e),m=l?l.length:0;++k<m;)d=l[k],f[d]=j?j(f[d],e[d]):e[d];return f},fe=function(a,b,c){var d,e=a,f=e;if(!e)return f;for(var g=arguments,h=0,i="number"==typeof c?2:g.length;++h<i;)if(e=g[h],e&&Y[typeof e])for(var j=-1,k=Y[typeof e]&&_d(e),l=k?k.length:0;++j<l;)d=k[j],"undefined"==typeof f[d]&&(f[d]=e[d]);return f},ge=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:t(b,c,3);for(d in e)if(b(e[d],d,a)===!1)return f;return f},he=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:t(b,c,3);for(var g=-1,h=Y[typeof e]&&_d(e),i=h?h.length:0;++g<i;)if(d=h[g],b(e[d],d,a)===!1)return f;return f},ie=Gd?function(a){if(!a||Ad.call(a)!=S)return!1;var b=a.valueOf,c=jb(b)&&(c=Gd(b))&&Gd(c);return c?a==c||Gd(a)==c:kb(a)}:kb,je=fb(function(a,b,c){Hd.call(a,c)?a[c]++:a[c]=1}),ke=fb(function(a,b,c){(Hd.call(a,c)?a[c]:a[c]=[]).push(b)}),le=fb(function(a,b,c){a[c]=b}),me=_b,ne=Vb,oe=jb(oe=pd.now)&&oe||function(){return(new pd).getTime()},pe=8==Ud(y+"08")?Ud:function(a,b){return Ud(Jb(a)?a.replace(G,""):a,b||0)};return b.after=Hc,b.assign=ee,b.at=Sb,b.bind=Ic,b.bindAll=Jc,b.bindKey=Kc,b.chain=id,b.compact=lc,b.compose=Lc,b.constant=Wc,b.countBy=je,b.create=pb,b.createCallback=Xc,b.curry=Mc,b.debounce=Nc,b.defaults=fe,b.defer=Oc,b.delay=Pc,b.difference=mc,b.filter=Vb,b.flatten=qc,b.forEach=Yb,b.forEachRight=Zb,b.forIn=ge,b.forInRight=sb,b.forOwn=he,b.forOwnRight=tb,b.functions=ub,b.groupBy=ke,b.indexBy=le,b.initial=sc,b.intersection=tc,b.invert=wb,b.invoke=$b,b.keys=_d,b.map=_b,b.mapValues=Lb,b.max=ac,b.memoize=Qc,b.merge=Mb,b.min=bc,b.omit=Nb,b.once=Rc,b.pairs=Ob,b.partial=Sc,b.partialRight=Tc,b.pick=Pb,b.pluck=me,b.property=bd,b.pull=wc,b.range=xc,b.reject=ec,b.remove=yc,b.rest=zc,b.shuffle=gc,b.sortBy=jc,b.tap=jd,b.throttle=Uc,b.times=fd,b.toArray=kc,b.transform=Qb,b.union=Bc,b.uniq=Cc,b.values=Rb,b.where=ne,b.without=Dc,b.wrap=Vc,b.xor=Ec,b.zip=Fc,b.zipObject=Gc,b.collect=_b,b.drop=zc,b.each=Yb,b.eachRight=Zb,b.extend=ee,b.methods=ub,b.object=Gc,b.select=Vb,b.tail=zc,b.unique=Cc,b.unzip=Fc,$c(b),b.clone=nb,b.cloneDeep=ob,b.contains=Tb,b.escape=Yc,b.every=Ub,b.find=Wb,b.findIndex=nc,b.findKey=qb,b.findLast=Xb,b.findLastIndex=oc,b.findLastKey=rb,b.has=vb,b.identity=Zc,b.indexOf=rc,b.isArguments=mb,b.isArray=Zd,b.isBoolean=xb,b.isDate=yb,b.isElement=zb,b.isEmpty=Ab,b.isEqual=Bb,b.isFinite=Cb,b.isFunction=Db,b.isNaN=Fb,b.isNull=Gb,b.isNumber=Hb,b.isObject=Eb,b.isPlainObject=ie,b.isRegExp=Ib,b.isString=Jb,b.isUndefined=Kb,b.lastIndexOf=vc,b.mixin=$c,b.noConflict=_c,b.noop=ad,b.now=oe,b.parseInt=pe,b.random=cd,b.reduce=cc,b.reduceRight=dc,b.result=dd,b.runInContext=q,b.size=hc,b.some=ic,b.sortedIndex=Ac,b.template=ed,b.unescape=gd,b.uniqueId=hd,b.all=Ub,b.any=ic,b.detect=Wb,b.findWhere=Wb,b.foldl=cc,b.foldr=dc,b.include=Tb,b.inject=cc,$c(function(){var a={};return he(b,function(c,d){b.prototype[d]||(a[d]=c)}),a}(),!1),b.first=pc,b.last=uc,b.sample=fc,b.take=pc,b.head=pc,he(b,function(a,d){var e="sample"!==d;b.prototype[d]||(b.prototype[d]=function(b,d){var f=this.__chain__,g=a(this.__wrapped__,b,d);return f||null!=b&&(!d||e&&"function"==typeof b)?new c(g,f):g})}),b.VERSION="2.4.1",b.prototype.chain=kd,b.prototype.toString=ld,b.prototype.value=md,b.prototype.valueOf=md,Yb(["join","pop","shift"],function(a){var d=xd[a];b.prototype[a]=function(){var a=this.__chain__,b=d.apply(this.__wrapped__,arguments);return a?new c(b,a):b}}),Yb(["push","reverse","sort","unshift"],function(a){var c=xd[a];b.prototype[a]=function(){return c.apply(this.__wrapped__,arguments),this}}),Yb(["concat","slice","splice"],function(a){var d=xd[a];b.prototype[a]=function(){return new c(d.apply(this.__wrapped__,arguments),this.__chain__)}}),b}var r,s=[],t=[],u=0,v=+new Date+"",w=75,x=40,y=" \f \n\r\u2028\u2029 ᠎              ",z=/\b__p \+= '';/g,A=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,E=/^\s*function[ \n\r\t]+\w/,F=/<%=([\s\S]+?)%>/g,G=RegExp("^["+y+"]*0+(?=.$)"),H=/($^)/,I=/\bthis\b/,J=/['\n\r\t\u2028\u2029\\]/g,K=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],L=0,M="[object Arguments]",N="[object Array]",O="[object Boolean]",P="[object Date]",Q="[object Function]",R="[object Number]",S="[object Object]",T="[object RegExp]",U="[object String]",V={};V[Q]=!1,V[M]=V[N]=V[O]=V[P]=V[R]=V[S]=V[T]=V[U]=!0;var W={leading:!1,maxWait:0,trailing:!1},X={configurable:!1,enumerable:!1,value:null,writable:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=Y[typeof window]&&window||this,_=Y[typeof d]&&d&&!d.nodeType&&d,ab=Y[typeof c]&&c&&!c.nodeType&&c,bb=ab&&ab.exports===_&&_,cb=Y[typeof b]&&b;!cb||cb.global!==cb&&cb.window!==cb||($=cb);var db=q();"function"==typeof a&&"object"==typeof a.amd&&a.amd?($._=db,a(function(){return db})):_&&ab?bb?(ab.exports=db)._=db:_._=db:$._=db}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],13:[function(a,b,c){!function(a){function b(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function c(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var d=function(){return d.cache.hasOwnProperty(arguments[0])||(d.cache[arguments[0]]=d.parse(arguments[0])),d.format.call(null,d.cache[arguments[0]],arguments)};d.format=function(a,e){var f,g,h,i,j,k,l,m=1,n=a.length,o="",p=[];for(g=0;n>g;g++)if(o=b(a[g]),"string"===o)p.push(a[g]);else if("array"===o){if(i=a[g],i[2])for(f=e[m],h=0;h<i[2].length;h++){if(!f.hasOwnProperty(i[2][h]))throw d('[sprintf] property "%s" does not exist',i[2][h]);f=f[i[2][h]]}else f=i[1]?e[i[1]]:e[m++];if(/[^s]/.test(i[8])&&"number"!=b(f))throw d("[sprintf] expecting number but found %s",b(f));switch(i[8]){case"b":f=f.toString(2);break;case"c":f=String.fromCharCode(f);break;case"d":f=parseInt(f,10);break;case"e":f=i[7]?f.toExponential(i[7]):f.toExponential();break;case"f":f=i[7]?parseFloat(f).toFixed(i[7]):parseFloat(f);break;case"o":f=f.toString(8);break;case"s":f=(f=String(f))&&i[7]?f.substring(0,i[7]):f;break;case"u":f>>>=0;break;case"x":f=f.toString(16);break;case"X":f=f.toString(16).toUpperCase()}f=/[def]/.test(i[8])&&i[3]&&f>=0?"+"+f:f,k=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",l=i[6]-String(f).length,j=i[6]?c(k,l):"",p.push(i[5]?f+j:j+f)}return p.join("")},d.cache={},d.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d};var e=function(a,b,c){return c=b.slice(0),c.splice(0,0,a),d.apply(null,c)};a.sprintf=d,a.vsprintf=e}("undefined"!=typeof c?c:window)},{}],14:[function(a,b){function c(){}function d(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function e(){if(q.XMLHttpRequest&&("file:"!=q.location.protocol||!q.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}return!1}function f(a){return a===Object(a)}function g(a){if(!f(a))return a;var b=[];for(var c in a)null!=a[c]&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}function h(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;g>f;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function i(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;i>h;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=r(c.slice(b+1)),g[d]=e;return g}function j(a){return a.split(/ *; */).shift()}function k(a){return p(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function l(a,b){b=b||{},this.req=a,this.xhr=this.req.xhr,this.text=this.xhr.responseText,this.setStatusProperties(this.xhr.status),this.header=this.headers=i(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text):null}function m(a,b){var c=this;o.call(this),this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){try{var b=new l(c);"HEAD"==a&&(b.text=null),c.callback(null,b)}catch(d){var e=new Error("Parser is unable to parse the response");e.parse=!0,e.original=d,c.callback(e)}})}function n(a,b){return"function"==typeof b?new m("GET",a).end(b):1==arguments.length?new m("GET",a):new m(a,b)}var o=a("emitter"),p=a("reduce"),q="undefined"==typeof window?this:window,r="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};n.serializeObject=g,n.parseString=h,n.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},n.serialize={"application/x-www-form-urlencoded":g,"application/json":JSON.stringify},n.parse={"application/x-www-form-urlencoded":h,"application/json":JSON.parse},l.prototype.get=function(a){return this.header[a.toLowerCase()]},l.prototype.setHeaderProperties=function(){var a=this.header["content-type"]||"";this.type=j(a);var b=k(a);for(var c in b)this[c]=b[c]},l.prototype.parseBody=function(a){var b=n.parse[this.type];return b&&a&&a.length?b(a):null},l.prototype.setStatusProperties=function(a){var b=a/100|0;this.status=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=4==b||5==b?this.toError():!1,this.accepted=202==a,this.noContent=204==a||1223==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a},l.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot "+b+" "+c+" ("+this.status+")",e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},n.Response=l,o(m.prototype),m.prototype.use=function(a){return a(this),this},m.prototype.timeout=function(a){return this._timeout=a,this},m.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},m.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},m.prototype.set=function(a,b){if(f(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},m.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},m.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},m.prototype.type=function(a){return this.set("Content-Type",n.types[a]||a),this},m.prototype.accept=function(a){return this.set("Accept",n.types[a]||a),this},m.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},m.prototype.query=function(a){return"string"!=typeof a&&(a=g(a)),a&&this._query.push(a),this},m.prototype.field=function(a,b){return this._formData||(this._formData=new FormData),this._formData.append(a,b),this},m.prototype.attach=function(a,b,c){return this._formData||(this._formData=new FormData),this._formData.append(a,b,c),this},m.prototype.send=function(a){var b=f(a),c=this.getHeader("Content-Type");if(b&&f(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==c?this._data?this._data+"&"+a:a:(this._data||"")+a):this._data=a;return b?(c||this.type("json"),this):this},m.prototype.callback=function(a,b){var c=this._callback;return 2==c.length?c(a,b):a?this.emit("error",a):void c(b)},m.prototype.crossDomainError=function(){var a=new Error("Origin is not allowed by Access-Control-Allow-Origin");a.crossDomain=!0,this.callback(a)},m.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},m.prototype.withCredentials=function(){return this._withCredentials=!0,this},m.prototype.end=function(a){var b=this,f=this.xhr=e(),g=this._query.join("&"),h=this._timeout,i=this._formData||this._data;if(this._callback=a||c,f.onreadystatechange=function(){return 4==f.readyState?0==f.status?b.aborted?b.timeoutError():b.crossDomainError():void b.emit("end"):void 0},f.upload&&(f.upload.onprogress=function(a){a.percent=a.loaded/a.total*100,b.emit("progress",a)}),h&&!this._timer&&(this._timer=setTimeout(function(){b.abort()},h)),g&&(g=n.serializeObject(g),this.url+=~this.url.indexOf("?")?"&"+g:"?"+g),f.open(this.method,this.url,!0),this._withCredentials&&(f.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof i&&!d(i)){var j=n.serialize[this.getHeader("Content-Type")];j&&(i=j(i))}for(var k in this.header)null!=this.header[k]&&f.setRequestHeader(k,this.header[k]);return this.emit("request",this),f.send(i),this},n.Request=m,n.get=function(a,b,c){var d=n("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},n.head=function(a,b,c){var d=n("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.del=function(a,b){var c=n("DELETE",a);return b&&c.end(b),c},n.patch=function(a,b,c){var d=n("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.post=function(a,b,c){var d=n("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.put=function(a,b,c){var d=n("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},b.exports=n},{emitter:15,reduce:16}],15:[function(a,b){function c(a){return a?d(a):void 0}function d(a){for(var b in c.prototype)a[b]=c.prototype[b];return a}b.exports=c,c.prototype.on=c.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},c.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},c.fn=b,this.on(a,c),this},c.prototype.off=c.prototype.removeListener=c.prototype.removeAllListeners=c.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;for(var d,e=0;e<c.length;e++)if(d=c[e],d===b||d.fn===b){c.splice(e,1);break}return this},c.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c){c=c.slice(0);for(var d=0,e=c.length;e>d;++d)c[d].apply(this,b)}return this},c.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},c.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],16:[function(a,b){b.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];e>d;)f=b.call(null,f,a[d],++d,a);return f}},{}]},{},[1])(1)});
/*! moussaka-client - v0.1.6 - 2015-01-03 */!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.MoussakaClient=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){!function(a,b){"use strict";var c=a("./libs/logger.js"),d=a("./libs/moussakaClient.js");d.types={},d.types.Color=a("./libs/types/color.js"),d.types.Position=a("./libs/types/position.js"),c.trace("MoussakaClient module loaded."),b.exports=d}(a,b)},{"./libs/logger.js":2,"./libs/moussakaClient.js":3,"./libs/types/color.js":5,"./libs/types/position.js":6}],2:[function(a,b){!function(a,b){"use strict";var c=a("sprintf-js").sprintf,d=function(a){this.logLevel=a||this.severity.warning.level};d.prototype.severity={trace:{label:"trace",level:0},info:{label:"info",level:1},warning:{label:"warning",level:2},error:{label:"error",level:3},exception:{label:"exception",level:4}},d.prototype.log=function(a,b){a||(a=this.severity.info),b||(b="No message provided in log statement."),a.level>=this.logLevel&&console.log(c("[%s] [%s]: %s",(new Date).toLocaleTimeString(),a.label,b))},d.prototype.trace=function(a){this.log(this.severity.trace,a)},d.prototype.info=function(a){this.log(this.severity.info,a)},d.prototype.warning=function(a){this.log(this.severity.warning,a)},d.prototype.error=function(a){this.log(this.severity.error,a)},d.prototype.exception=function(a){this.log(this.severity.exception,a)},b.exports=new d}(a,b)},{"sprintf-js":15}],3:[function(a,b){!function(a,b){"use strict";var c=a("./utils.js"),d=a("lodash"),e=a("superagent"),f=a("./logger.js"),g=a("./ref.js"),h=a("path"),i=a("events").EventEmitter,j=a("util").inherits,k=function(a){this.deviceName=null,this.apiKey=null,this.projectId=null,this.projectVersion=null,this.serverUrl="http://localhost:3000/",this.pollInterval=1e3,d.assign(this,a),this.registeredVars={},this.connected=!1,this.dataSchema={},this.polling=!1,this.intervalId=null,this.pollErrorCount=0,this.pollReady=!0,a.logLevel&&(f.logLevel=a.logLevel)};j(k,i),k.prototype.getBaseUrl=function(){if(!this.serverUrl)throw new Error("Server URL not defined.");var a=this.serverUrl;return"/"===a.substr(-1)?a.substr(0,a.length-1):a},k.prototype.getErrorDetail=function(a){var b="An unknown error occurred";return a.body&&a.body.detail?b=a.body.detail:a.text&&(b=a.text),b},k.prototype.serializeValue=function(a){switch(typeof a){case"boolean":return{values:{b:a}};case"number":return{values:{n:a}};case"string":return{values:{s:a}};case"object":if(a.serialize)return a.serialize();throw new Error("Cannot serialize object without serialize method.");default:throw new Error("Cannot serialize undefined or unsupported variable.")}},k.prototype.getStateSnapshot=function(){var a={};return d.each(this.registeredVars,function(b,c){var d=b.ref.value;return"undefined"==typeof d||null===d?!0:void(a[c]=this.serializeValue(d))},this),a},k.prototype.registerVar=function(a,b,c){if(this.registeredVars[a])throw new Error("Variable with that name already registered.");var d=new g(b);return this.registeredVars[a]={ref:d,schema:c},this.updateSchema(),d},k.prototype.updateSchema=function(){if(this.connected)throw new Error("Cannot update schema after connect.");var a={};d.each(this.registeredVars,function(b,c){if(!b.schema){var d=null,e=b.ref;switch(f.trace("Updating schema with: "+c),f.trace("Type: "+typeof e.value),f.trace("Complex: "+!!e.value.getType),typeof e.value){case"boolean":d="boolean";break;case"number":d="float";break;case"string":d="string"}if(e.value.getType&&(d=e.value.getType()),!d)throw new Error("Cannot deduce object type. Please pass in a schema object.");b.schema={type:d}}a[c]=b.schema},this),this.dataSchema=a},k.prototype.connect=function(){c.validateRequiredOptions(this,["deviceName","apiKey","projectId","projectVersion"]);var a=this.getBaseUrl()+h.join("/projects/",this.projectId,"devices/");f.trace("Connecting device at: "+a),e.put(a).send({projectId:this.projectId,projectVersion:this.projectVersion,deviceName:this.deviceName,dataSchema:this.dataSchema,currentState:this.getStateSnapshot()}).set("apikey",this.apiKey).end(function(a,b){return a?this.emit("error",a):void(b.ok?(this.connected=!0,this._id=b.body.data._id,f.trace("Connected!: _id: "+this._id),this.emit("connect",this._id),this.beginPolling()):this.emit("error",new Error("Server returned error: Status: "+b.status+" Detail: "+this.getErrorDetail(b))))}.bind(this))},k.prototype.disconnect=function(){c.validateRequiredOptions(this,["deviceName","apiKey","projectId","projectVersion"]);var a=this.getBaseUrl()+h.join("/projects/",this.projectId,"devices/",this._id,"/");f.trace("Disconnecting device at: "+a),this.stopPolling(),e.del(a).set("apikey",this.apiKey).end(function(a,b){return a?this.emit("error",a):void(b.ok?(this.connected=!1,this.emit("disconnect")):this.emit("error",new Error("Server returned error: Status: "+b.status+" Detail: "+this.getErrorDetail(b))))}.bind(this))},k.prototype.beginPolling=function(){if(!this.connected||this.polling)throw new Error("This method should only be called by the connect function.");f.trace("Starting polling"),this.intervalId=setInterval(this.pollFn.bind(this),this.pollInterval),this.polling=!0},k.prototype.pollFn=function(){c.validateRequiredOptions(this,["deviceName","apiKey","projectId","projectVersion","_id"]);var a=this.getBaseUrl()+h.join("/projects/",this.projectId,"sessions/",this._id,"/updates/");f.trace("Polling with URL: "+a),this.emit("poll"),this.pollReady||f.warn("pollFn called before last poll completed. Skipping poll. Make sure poll frequency is not to fast."),this.pollReady=!1,e.get(a).set("apikey",this.apiKey).end(function(a,b){return this.pollReady=!0,a?(++this.pollErrorCount>5&&(f.error("5 poll errors encountered in a row. Disconnecting..."),this.disconnect()),this.emit("error",a)):b.ok?(this.pollErrorCount=0,void this.applyUpdates(b.body.data)):this.emit("error",new Error("Server returned error: Status: "+b.status+" Detail: "+this.getErrorDetail(b)))}.bind(this))},k.prototype.stopPolling=function(){if(f.trace("Stopping polling"),!this.intervalId&&this.polling)throw new Error("Polling started but no intervalId.");if(!this.intervalId||!this.polling)throw new Error("Polling has not been started.");clearInterval(this.intervalId),this.polling=!1},k.prototype.applyUpdates=function(a){return a?void d.forIn(a,function(a,b){var c=a.values,d=this.registeredVars[b],e=d.schema.type,g=d.ref;switch(d.schema.type){case"float":case"double":case"decimal":g.value=c.n;break;case"string":g.value=c.s;break;case"boolean":g.value=c.b;break;default:g.value.setValues?g.value.setValues(c):f.warn("Unsupported variable type: "+e)}},this):void f.warn("Updates is null.")},b.exports=k}(a,b)},{"./logger.js":2,"./ref.js":4,"./utils.js":7,events:8,lodash:14,path:10,superagent:16,util:13}],4:[function(a,b){!function(a,b){"use strict";var c=a("./logger.js"),d=function(a){var b=this;this.internalValue=a,this.internalType=typeof a,Object.defineProperty(this,"value",{get:function(){return b.internalValue},set:function(a){b.internalType!==typeof a&&c.warn("Type of value: "+typeof a+" does not match type of reference: "+b.internalType),b.internalValue=a}})};b.exports=d}(a,b)},{"./logger.js":2}],5:[function(a,b){!function(a,b){"use strict";var c=a("../utils.js"),d=function(a,b,d,e){if(1===arguments.length){var f=a;this.setValues(f)}else{if(4!==arguments.length)throw new Error("Invalid number of arguments.");this.r=a,this.g=b,this.b=d,this.a=e}c.validateRequiredOptions(this,["r","g","b","a"])};d.prototype.setValues=function(a){c.validateRequiredOptions(a,["r","g","b","a"]),this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a},d.prototype.getValues=function(){return{r:this.r,g:this.g,b:this.b,a:this.a}},d.prototype.getType=function(){return"color"},d.prototype.serialize=function(){return{values:this.getValues()}},d.prototype.deserialize=function(a){this.setValues(a.values)},b.exports=d}(a,b)},{"../utils.js":7}],6:[function(a,b){!function(a,b){"use strict";var c=a("../utils.js"),d=function(a,b,d){if(1===arguments.length)if("object"==typeof a){var e=a;this.setValues(e)}else{if("number"!=typeof a)throw new Error("Value for x required.");this.x=a}else this.x=a;this.y=this.y||b||0,this.z=this.z||d||0,c.validateRequiredOptions(this,["x","y","z"])};d.prototype.setValues=function(a){c.validateRequiredOptions(a,["x"]),this.x=a.x,this.y=a.y||0,this.z=a.z||0},d.prototype.getValues=function(){return{x:this.r,y:this.g,z:this.b}},d.prototype.getType=function(){return"position"},d.prototype.serialize=function(){return{values:this.getValues()}},d.prototype.deserialize=function(a){this.setValues(a.values)},b.exports=d}(a,b)},{"../utils.js":7}],7:[function(a,b){!function(a,b){"use strict";{var c=a("lodash");a("./logger.js")}b.exports={validateRequiredOptions:function(a,b,d){return d=d||!0,!a&&b.length>0?!1:(c.each(b,function(b){if(!c.contains(Object.keys(a),b))throw new Error("Missing required option: "+b);var d=a[b];if("undefined"==typeof d||null===d||"string"==typeof d&&""===d.trim())throw new Error("Option is undefined, null or empty string: "+b)}),!0)}}}(a,b)},{"./logger.js":2,lodash:14}],8:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function d(a){return"function"==typeof a}function e(a){return"number"==typeof a}function f(a){return"object"==typeof a&&null!==a}function g(a){return void 0===a}b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!e(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,h,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||f(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],g(c))return!1;if(d(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];c.apply(this,h)}else if(f(c)){for(e=arguments.length,h=new Array(e-1),i=1;e>i;i++)h[i-1]=arguments[i];for(j=c.slice(),e=j.length,i=0;e>i;i++)j[i].apply(this,h)}return!0},c.prototype.addListener=function(a,b){var e;if(!d(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d(b.listener)?b.listener:b),this._events[a]?f(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,f(this._events[a])&&!this._events[a].warned){var e;e=g(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),e||(e=!0,b.apply(this,arguments))}if(!d(b))throw TypeError("listener must be a function");var e=!1;return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,g,h;if(!d(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],g=c.length,e=-1,c===b||d(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(f(c)){for(h=g;h-->0;)if(c[h]===b||c[h].listener&&c[h].listener===b){e=h;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d(a._events[b])?1:a._events[b].length:0}},{}],9:[function(a,b){b.exports="function"==typeof Object.create?function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],10:[function(a,b,c){(function(a){function b(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function d(a,b){if(a.filter)return a.filter(b);for(var c=[],d=0;d<a.length;d++)b(a[d],d,a)&&c.push(a[d]);return c}var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,f=function(a){return e.exec(a).slice(1)};c.resolve=function(){for(var c="",e=!1,f=arguments.length-1;f>=-1&&!e;f--){var g=f>=0?arguments[f]:a.cwd();if("string"!=typeof g)throw new TypeError("Arguments to path.resolve must be strings");g&&(c=g+"/"+c,e="/"===g.charAt(0))}return c=b(d(c.split("/"),function(a){return!!a}),!e).join("/"),(e?"/":"")+c||"."},c.normalize=function(a){var e=c.isAbsolute(a),f="/"===g(a,-1);return a=b(d(a.split("/"),function(a){return!!a}),!e).join("/"),a||e||(a="."),a&&f&&(a+="/"),(e?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a){if("string"!=typeof a)throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b<a.length&&""===a[b];b++);for(var c=a.length-1;c>=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i<e.length;i++)j.push("..");return j=j.concat(f.slice(h)),j.join("/")},c.sep="/",c.delimiter=":",c.dirname=function(a){var b=f(a),c=b[0],d=b[1];return c||d?(d&&(d=d.substr(0,d.length-1)),c+d):"."},c.basename=function(a,b){var c=f(a)[2];return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return f(a)[3]};var g="b"==="ab".substr(-1)?function(a,b,c){return a.substr(b,c)}:function(a,b,c){return 0>b&&(b=a.length+b),a.substr(b,c)}}).call(this,a("_process"))},{_process:11}],11:[function(a,b){function c(){}var d=b.exports={};d.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),d.title="browser",d.browser=!0,d.env={},d.argv=[],d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],13:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c<arguments.length;c++)b.push(e(arguments[c]));return b.join(" ")}for(var c=1,d=arguments,f=d.length,g=String(a).replace(G,function(a){if("%%"===a)return"%";if(c>=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":12,_process:11,inherits:9}],14:[function(b,c,d){(function(b){(function(){function e(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d<e;)if(a[d]===b)return d;return-1}function f(a,b){var c=typeof b;if(a=a.cache,"boolean"==c||null==b)return a[b]?0:-1;"number"!=c&&"string"!=c&&(c="object");var d="number"==c?b:v+b;return a=(a=a[c])&&a[d],"object"==c?a&&e(a,b)>-1?0:-1:a?0:-1}function g(a){var b=this.cache,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:v+a,e=b[c]||(b[c]={});"object"==c?(e[d]||(e[d]=[])).push(a):e[d]=!0}}function h(a){return a.charCodeAt(0)}function i(a,b){for(var c=a.criteria,d=b.criteria,e=-1,f=c.length;++e<f;){var g=c[e],h=d[e];if(g!==h){if(g>h||"undefined"==typeof g)return 1;if(h>g||"undefined"==typeof h)return-1}}return a.index-b.index}function j(a){var b=-1,c=a.length,d=a[0],e=a[c/2|0],f=a[c-1];if(d&&"object"==typeof d&&e&&"object"==typeof e&&f&&"object"==typeof f)return!1;var h=m();h["false"]=h["null"]=h["true"]=h.undefined=!1;var i=m();for(i.array=a,i.cache=h,i.push=g;++b<c;)i.push(a[b]);return i}function k(a){return"\\"+Z[a]}function l(){return s.pop()||[]}function m(){return t.pop()||{array:null,cache:null,criteria:null,"false":!1,index:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,value:null}}function n(a){a.length=0,s.length<x&&s.push(a)}function o(a){var b=a.cache;b&&o(b),a.array=a.cache=a.criteria=a.object=a.number=a.string=a.value=null,t.length<x&&t.push(a)}function p(a,b,c){b||(b=0),"undefined"==typeof c&&(c=a?a.length:0);for(var d=-1,e=c-b||0,f=Array(0>e?0:e);++d<e;)f[d]=a[b+d];return f}function q(a){function b(a){return a&&"object"==typeof a&&!Zd(a)&&Hd.call(a,"__wrapped__")?a:new c(a)}function c(a,b){this.__chain__=!!b,this.__wrapped__=a}function d(a){function b(){if(d){var a=p(d);Id.apply(a,arguments)}if(this instanceof b){var f=s(c.prototype),g=c.apply(f,a||arguments);return Eb(g)?g:f}return c.apply(e,a||arguments)}var c=a[0],d=a[2],e=a[4];return Yd(b,a),b}function g(a,b,c,d,e){if(c){var f=c(a);if("undefined"!=typeof f)return f}var h=Eb(a);if(!h)return a;var i=Ad.call(a);if(!V[i])return a;var j=Wd[i];switch(i){case O:case P:return new j(+a);case R:case U:return new j(a);case T:return f=j(a.source,D.exec(a)),f.lastIndex=a.lastIndex,f}var k=Zd(a);if(b){var m=!d;d||(d=l()),e||(e=l());for(var o=d.length;o--;)if(d[o]==a)return e[o];f=k?j(a.length):{}}else f=k?p(a):ee({},a);return k&&(Hd.call(a,"index")&&(f.index=a.index),Hd.call(a,"input")&&(f.input=a.input)),b?(d.push(a),e.push(f),(k?Yb:he)(a,function(a,h){f[h]=g(a,b,c,d,e)}),m&&(n(d),n(e)),f):f}function s(a){return Eb(a)?Nd(a):{}}function t(a,b,c){if("function"!=typeof a)return Zc;if("undefined"==typeof b||!("prototype"in a))return a;var d=a.__bindData__;if("undefined"==typeof d&&(Xd.funcNames&&(d=!a.name),d=d||!Xd.funcDecomp,!d)){var e=Fd.call(a);Xd.funcNames||(d=!E.test(e)),d||(d=I.test(e),Yd(a,d))}if(d===!1||d!==!0&&1&d[1])return a;switch(c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return Ic(a,b)}function x(a){function b(){var a=i?g:this;if(e){var n=p(e);Id.apply(n,arguments)}if((f||k)&&(n||(n=p(arguments)),f&&Id.apply(n,f),k&&n.length<h))return d|=16,x([c,l?d:-4&d,n,null,g,h]);if(n||(n=arguments),j&&(c=a[m]),this instanceof b){a=s(c.prototype);var o=c.apply(a,n);return Eb(o)?o:a}return c.apply(a,n)}var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=1&d,j=2&d,k=4&d,l=8&d,m=c;return Yd(b,a),b}function Z(a,b){var c=-1,d=ib(),g=a?a.length:0,h=g>=w&&d===e,i=[];if(h){var k=j(b);k?(d=f,b=k):h=!1}for(;++c<g;){var l=a[c];d(b,l)<0&&i.push(l)}return h&&o(b),i}function _(a,b,c,d){for(var e=(d||0)-1,f=a?a.length:0,g=[];++e<f;){var h=a[e];if(h&&"object"==typeof h&&"number"==typeof h.length&&(Zd(h)||mb(h))){b||(h=_(h,b,c));var i=-1,j=h.length,k=g.length;for(g.length+=j;++i<j;)g[k++]=h[i]}else c||g.push(h)}return g}function ab(a,b,c,d,e,f){if(c){var g=c(a,b);if("undefined"!=typeof g)return!!g}if(a===b)return 0!==a||1/a==1/b;var h=typeof a,i=typeof b;if(!(a!==a||a&&Y[h]||b&&Y[i]))return!1;if(null==a||null==b)return a===b;var j=Ad.call(a),k=Ad.call(b);if(j==M&&(j=S),k==M&&(k=S),j!=k)return!1;switch(j){case O:case P:return+a==+b;case R:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case T:case U:return a==vd(b)}var m=j==N;if(!m){var o=Hd.call(a,"__wrapped__"),p=Hd.call(b,"__wrapped__");if(o||p)return ab(o?a.__wrapped__:a,p?b.__wrapped__:b,c,d,e,f);if(j!=S)return!1;var q=a.constructor,r=b.constructor;if(q!=r&&!(Db(q)&&q instanceof q&&Db(r)&&r instanceof r)&&"constructor"in a&&"constructor"in b)return!1}var s=!e;e||(e=l()),f||(f=l());for(var t=e.length;t--;)if(e[t]==a)return f[t]==b;var u=0;if(g=!0,e.push(a),f.push(b),m){if(t=a.length,u=b.length,g=u==t,g||d)for(;u--;){var v=t,w=b[u];if(d)for(;v--&&!(g=ab(a[v],w,c,d,e,f)););else if(!(g=ab(a[u],w,c,d,e,f)))break}}else ge(b,function(b,h,i){return Hd.call(i,h)?(u++,g=Hd.call(a,h)&&ab(a[h],b,c,d,e,f)):void 0}),g&&!d&&ge(a,function(a,b,c){return Hd.call(c,b)?g=--u>-1:void 0});return e.pop(),f.pop(),s&&(n(e),n(f)),g}function bb(a,b,c,d,e){(Zd(b)?Yb:he)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Zd(b))||ie(b))){for(var k=d.length;k--;)if(g=d[k]==b){j=e[k];break}if(!g){var l;c&&(i=c(j,b),(l="undefined"!=typeof i)&&(j=i)),l||(j=h?Zd(j)?j:[]:ie(j)?j:{}),d.push(b),e.push(j),l||bb(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function cb(a,b){return a+Ed(Vd()*(b-a+1))}function eb(a,b,c){var d=-1,g=ib(),h=a?a.length:0,i=[],k=!b&&h>=w&&g===e,m=c||k?l():i;if(k){var p=j(m);g=f,m=p}for(;++d<h;){var q=a[d],r=c?c(q,d,a):q;(b?!d||m[m.length-1]!==r:g(m,r)<0)&&((c||k)&&m.push(r),i.push(q))}return k?(n(m.array),o(m)):c&&n(m),i}function fb(a){return function(c,d,e){var f={};d=b.createCallback(d,e,3);var g=-1,h=c?c.length:0;if("number"==typeof h)for(;++g<h;){var i=c[g];a(f,i,d(i,g,c),c)}else he(c,function(b,c,e){a(f,b,d(b,c,e),e)});return f}}function gb(a,b,c,e,f,g){var h=1&b,i=2&b,j=4&b,k=16&b,l=32&b;if(!i&&!Db(a))throw new wd;k&&!c.length&&(b&=-17,k=c=!1),l&&!e.length&&(b&=-33,l=e=!1);var m=a&&a.__bindData__;if(m&&m!==!0)return m=p(m),m[2]&&(m[2]=p(m[2])),m[3]&&(m[3]=p(m[3])),!h||1&m[1]||(m[4]=f),!h&&1&m[1]&&(b|=8),!j||4&m[1]||(m[5]=g),k&&Id.apply(m[2]||(m[2]=[]),c),l&&Ld.apply(m[3]||(m[3]=[]),e),m[1]|=b,gb.apply(null,m);var n=1==b||17===b?d:x;return n([a,b,c,e,f,g])}function hb(a){return ae[a]}function ib(){var a=(a=b.indexOf)===rc?e:a;return a}function jb(a){return"function"==typeof a&&Bd.test(a)}function kb(a){var b,c;return a&&Ad.call(a)==S&&(b=a.constructor,!Db(b)||b instanceof b)?(ge(a,function(a,b){c=b}),"undefined"==typeof c||Hd.call(a,c)):!1}function lb(a){return be[a]}function mb(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ad.call(a)==M||!1}function nb(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c=b,b=!1),g(a,b,"function"==typeof c&&t(c,d,1))}function ob(a,b,c){return g(a,!0,"function"==typeof b&&t(b,c,1))}function pb(a,b){var c=s(a);return b?ee(c,b):c}function qb(a,c,d){var e;return c=b.createCallback(c,d,3),he(a,function(a,b,d){return c(a,b,d)?(e=b,!1):void 0}),e}function rb(a,c,d){var e;return c=b.createCallback(c,d,3),tb(a,function(a,b,d){return c(a,b,d)?(e=b,!1):void 0}),e}function sb(a,b,c){var d=[];ge(a,function(a,b){d.push(b,a)});var e=d.length;for(b=t(b,c,3);e--&&b(d[e--],d[e],a)!==!1;);return a}function tb(a,b,c){var d=_d(a),e=d.length;for(b=t(b,c,3);e--;){var f=d[e];if(b(a[f],f,a)===!1)break}return a}function ub(a){var b=[];return ge(a,function(a,c){Db(a)&&b.push(c)}),b.sort()}function vb(a,b){return a?Hd.call(a,b):!1}function wb(a){for(var b=-1,c=_d(a),d=c.length,e={};++b<d;){var f=c[b];e[a[f]]=f}return e}function xb(a){return a===!0||a===!1||a&&"object"==typeof a&&Ad.call(a)==O||!1}function yb(a){return a&&"object"==typeof a&&Ad.call(a)==P||!1}function zb(a){return a&&1===a.nodeType||!1}function Ab(a){var b=!0;if(!a)return b;var c=Ad.call(a),d=a.length;return c==N||c==U||c==M||c==S&&"number"==typeof d&&Db(a.splice)?!d:(he(a,function(){return b=!1}),b)}function Bb(a,b,c,d){return ab(a,b,"function"==typeof c&&t(c,d,2))}function Cb(a){return Pd(a)&&!Qd(parseFloat(a))}function Db(a){return"function"==typeof a}function Eb(a){return!(!a||!Y[typeof a])}function Fb(a){return Hb(a)&&a!=+a}function Gb(a){return null===a}function Hb(a){return"number"==typeof a||a&&"object"==typeof a&&Ad.call(a)==R||!1}function Ib(a){return a&&"object"==typeof a&&Ad.call(a)==T||!1}function Jb(a){return"string"==typeof a||a&&"object"==typeof a&&Ad.call(a)==U||!1}function Kb(a){return"undefined"==typeof a}function Lb(a,c,d){var e={};return c=b.createCallback(c,d,3),he(a,function(a,b,d){e[b]=c(a,b,d)}),e}function Mb(a){var b=arguments,c=2;if(!Eb(a))return a;if("number"!=typeof b[2]&&(c=b.length),c>3&&"function"==typeof b[c-2])var d=t(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var e=p(arguments,1,c),f=-1,g=l(),h=l();++f<c;)bb(a,e[f],d,g,h);return n(g),n(h),a}function Nb(a,c,d){var e={};if("function"!=typeof c){var f=[];ge(a,function(a,b){f.push(b)}),f=Z(f,_(arguments,!0,!1,1));for(var g=-1,h=f.length;++g<h;){var i=f[g];
e[i]=a[i]}}else c=b.createCallback(c,d,3),ge(a,function(a,b,d){c(a,b,d)||(e[b]=a)});return e}function Ob(a){for(var b=-1,c=_d(a),d=c.length,e=nd(d);++b<d;){var f=c[b];e[b]=[f,a[f]]}return e}function Pb(a,c,d){var e={};if("function"!=typeof c)for(var f=-1,g=_(arguments,!0,!1,1),h=Eb(a)?g.length:0;++f<h;){var i=g[f];i in a&&(e[i]=a[i])}else c=b.createCallback(c,d,3),ge(a,function(a,b,d){c(a,b,d)&&(e[b]=a)});return e}function Qb(a,c,d,e){var f=Zd(a);if(null==d)if(f)d=[];else{var g=a&&a.constructor,h=g&&g.prototype;d=s(h)}return c&&(c=b.createCallback(c,e,4),(f?Yb:he)(a,function(a,b,e){return c(d,a,b,e)})),d}function Rb(a){for(var b=-1,c=_d(a),d=c.length,e=nd(d);++b<d;)e[b]=a[c[b]];return e}function Sb(a){for(var b=arguments,c=-1,d=_(b,!0,!1,1),e=b[2]&&b[2][b[1]]===a?1:d.length,f=nd(e);++c<e;)f[c]=a[d[c]];return f}function Tb(a,b,c){var d=-1,e=ib(),f=a?a.length:0,g=!1;return c=(0>c?Sd(0,f+c):c)||0,Zd(a)?g=e(a,b,c)>-1:"number"==typeof f?g=(Jb(a)?a.indexOf(b,c):e(a,b,c))>-1:he(a,function(a){return++d>=c?!(g=a===b):void 0}),g}function Ub(a,c,d){var e=!0;c=b.createCallback(c,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&(e=!!c(a[f],f,a)););else he(a,function(a,b,d){return e=!!c(a,b,d)});return e}function Vb(a,c,d){var e=[];c=b.createCallback(c,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g;){var h=a[f];c(h,f,a)&&e.push(h)}else he(a,function(a,b,d){c(a,b,d)&&e.push(a)});return e}function Wb(a,c,d){c=b.createCallback(c,d,3);var e=-1,f=a?a.length:0;if("number"!=typeof f){var g;return he(a,function(a,b,d){return c(a,b,d)?(g=a,!1):void 0}),g}for(;++e<f;){var h=a[e];if(c(h,e,a))return h}}function Xb(a,c,d){var e;return c=b.createCallback(c,d,3),Zb(a,function(a,b,d){return c(a,b,d)?(e=a,!1):void 0}),e}function Yb(a,b,c){var d=-1,e=a?a.length:0;if(b=b&&"undefined"==typeof c?b:t(b,c,3),"number"==typeof e)for(;++d<e&&b(a[d],d,a)!==!1;);else he(a,b);return a}function Zb(a,b,c){var d=a?a.length:0;if(b=b&&"undefined"==typeof c?b:t(b,c,3),"number"==typeof d)for(;d--&&b(a[d],d,a)!==!1;);else{var e=_d(a);d=e.length,he(a,function(a,c,f){return c=e?e[--d]:--d,b(f[c],c,f)})}return a}function $b(a,b){var c=p(arguments,2),d=-1,e="function"==typeof b,f=a?a.length:0,g=nd("number"==typeof f?f:0);return Yb(a,function(a){g[++d]=(e?b:a[b]).apply(a,c)}),g}function _b(a,c,d){var e=-1,f=a?a.length:0;if(c=b.createCallback(c,d,3),"number"==typeof f)for(var g=nd(f);++e<f;)g[e]=c(a[e],e,a);else g=[],he(a,function(a,b,d){g[++e]=c(a,b,d)});return g}function ac(a,c,d){var e=-1/0,f=e;if("function"!=typeof c&&d&&d[c]===a&&(c=null),null==c&&Zd(a))for(var g=-1,i=a.length;++g<i;){var j=a[g];j>f&&(f=j)}else c=null==c&&Jb(a)?h:b.createCallback(c,d,3),Yb(a,function(a,b,d){var g=c(a,b,d);g>e&&(e=g,f=a)});return f}function bc(a,c,d){var e=1/0,f=e;if("function"!=typeof c&&d&&d[c]===a&&(c=null),null==c&&Zd(a))for(var g=-1,i=a.length;++g<i;){var j=a[g];f>j&&(f=j)}else c=null==c&&Jb(a)?h:b.createCallback(c,d,3),Yb(a,function(a,b,d){var g=c(a,b,d);e>g&&(e=g,f=a)});return f}function cc(a,c,d,e){if(!a)return d;var f=arguments.length<3;c=b.createCallback(c,e,4);var g=-1,h=a.length;if("number"==typeof h)for(f&&(d=a[++g]);++g<h;)d=c(d,a[g],g,a);else he(a,function(a,b,e){d=f?(f=!1,a):c(d,a,b,e)});return d}function dc(a,c,d,e){var f=arguments.length<3;return c=b.createCallback(c,e,4),Zb(a,function(a,b,e){d=f?(f=!1,a):c(d,a,b,e)}),d}function ec(a,c,d){return c=b.createCallback(c,d,3),Vb(a,function(a,b,d){return!c(a,b,d)})}function fc(a,b,c){if(a&&"number"!=typeof a.length&&(a=Rb(a)),null==b||c)return a?a[cb(0,a.length-1)]:r;var d=gc(a);return d.length=Td(Sd(0,b),d.length),d}function gc(a){var b=-1,c=a?a.length:0,d=nd("number"==typeof c?c:0);return Yb(a,function(a){var c=cb(0,++b);d[b]=d[c],d[c]=a}),d}function hc(a){var b=a?a.length:0;return"number"==typeof b?b:_d(a).length}function ic(a,c,d){var e;c=b.createCallback(c,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&!(e=c(a[f],f,a)););else he(a,function(a,b,d){return!(e=c(a,b,d))});return!!e}function jc(a,c,d){var e=-1,f=Zd(c),g=a?a.length:0,h=nd("number"==typeof g?g:0);for(f||(c=b.createCallback(c,d,3)),Yb(a,function(a,b,d){var g=h[++e]=m();f?g.criteria=_b(c,function(b){return a[b]}):(g.criteria=l())[0]=c(a,b,d),g.index=e,g.value=a}),g=h.length,h.sort(i);g--;){var j=h[g];h[g]=j.value,f||n(j.criteria),o(j)}return h}function kc(a){return a&&"number"==typeof a.length?p(a):Rb(a)}function lc(a){for(var b=-1,c=a?a.length:0,d=[];++b<c;){var e=a[b];e&&d.push(e)}return d}function mc(a){return Z(a,_(arguments,!0,!0,1))}function nc(a,c,d){var e=-1,f=a?a.length:0;for(c=b.createCallback(c,d,3);++e<f;)if(c(a[e],e,a))return e;return-1}function oc(a,c,d){var e=a?a.length:0;for(c=b.createCallback(c,d,3);e--;)if(c(a[e],e,a))return e;return-1}function pc(a,c,d){var e=0,f=a?a.length:0;if("number"!=typeof c&&null!=c){var g=-1;for(c=b.createCallback(c,d,3);++g<f&&c(a[g],g,a);)e++}else if(e=c,null==e||d)return a?a[0]:r;return p(a,0,Td(Sd(0,e),f))}function qc(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c="function"!=typeof b&&d&&d[b]===a?null:b,b=!1),null!=c&&(a=_b(a,c,d)),_(a,b)}function rc(a,b,c){if("number"==typeof c){var d=a?a.length:0;c=0>c?Sd(0,d+c):c||0}else if(c){var f=Ac(a,b);return a[f]===b?f:-1}return e(a,b,c)}function sc(a,c,d){var e=0,f=a?a.length:0;if("number"!=typeof c&&null!=c){var g=f;for(c=b.createCallback(c,d,3);g--&&c(a[g],g,a);)e++}else e=null==c||d?1:c||e;return p(a,0,Td(Sd(0,f-e),f))}function tc(){for(var a=[],b=-1,c=arguments.length,d=l(),g=ib(),h=g===e,i=l();++b<c;){var k=arguments[b];(Zd(k)||mb(k))&&(a.push(k),d.push(h&&k.length>=w&&j(b?a[b]:i)))}var m=a[0],p=-1,q=m?m.length:0,r=[];a:for(;++p<q;){var s=d[0];if(k=m[p],(s?f(s,k):g(i,k))<0){for(b=c,(s||i).push(k);--b;)if(s=d[b],(s?f(s,k):g(a[b],k))<0)continue a;r.push(k)}}for(;c--;)s=d[c],s&&o(s);return n(d),n(i),r}function uc(a,c,d){var e=0,f=a?a.length:0;if("number"!=typeof c&&null!=c){var g=f;for(c=b.createCallback(c,d,3);g--&&c(a[g],g,a);)e++}else if(e=c,null==e||d)return a?a[f-1]:r;return p(a,Sd(0,f-e))}function vc(a,b,c){var d=a?a.length:0;for("number"==typeof c&&(d=(0>c?Sd(0,d+c):Td(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function wc(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++c<d;)for(var f=-1,g=b[c];++f<e;)a[f]===g&&(Kd.call(a,f--,1),e--);return a}function xc(a,b,c){a=+a||0,c="number"==typeof c?c:+c||1,null==b&&(b=a,a=0);for(var d=-1,e=Sd(0,Cd((b-a)/(c||1))),f=nd(e);++d<e;)f[d]=a,a+=c;return f}function yc(a,c,d){var e=-1,f=a?a.length:0,g=[];for(c=b.createCallback(c,d,3);++e<f;){var h=a[e];c(h,e,a)&&(g.push(h),Kd.call(a,e--,1),f--)}return g}function zc(a,c,d){if("number"!=typeof c&&null!=c){var e=0,f=-1,g=a?a.length:0;for(c=b.createCallback(c,d,3);++f<g&&c(a[f],f,a);)e++}else e=null==c||d?1:Sd(0,c);return p(a,e)}function Ac(a,c,d,e){var f=0,g=a?a.length:f;for(d=d?b.createCallback(d,e,1):Zc,c=d(c);g>f;){var h=f+g>>>1;d(a[h])<c?f=h+1:g=h}return f}function Bc(){return eb(_(arguments,!0,!0))}function Cc(a,c,d,e){return"boolean"!=typeof c&&null!=c&&(e=d,d="function"!=typeof c&&e&&e[c]===a?null:c,c=!1),null!=d&&(d=b.createCallback(d,e,3)),eb(a,c,d)}function Dc(a){return Z(a,p(arguments,1))}function Ec(){for(var a=-1,b=arguments.length;++a<b;){var c=arguments[a];if(Zd(c)||mb(c))var d=d?eb(Z(d,c).concat(Z(c,d))):c}return d||[]}function Fc(){for(var a=arguments.length>1?arguments:arguments[0],b=-1,c=a?ac(me(a,"length")):0,d=nd(0>c?0:c);++b<c;)d[b]=me(a,b);return d}function Gc(a,b){var c=-1,d=a?a.length:0,e={};for(b||!d||Zd(a[0])||(b=[]);++c<d;){var f=a[c];b?e[f]=b[c]:f&&(e[f[0]]=f[1])}return e}function Hc(a,b){if(!Db(b))throw new wd;return function(){return--a<1?b.apply(this,arguments):void 0}}function Ic(a,b){return arguments.length>2?gb(a,17,p(arguments,2),null,b):gb(a,1,null,null,b)}function Jc(a){for(var b=arguments.length>1?_(arguments,!0,!1,1):ub(a),c=-1,d=b.length;++c<d;){var e=b[c];a[e]=gb(a[e],1,null,null,a)}return a}function Kc(a,b){return arguments.length>2?gb(b,19,p(arguments,2),null,a):gb(b,3,null,null,a)}function Lc(){for(var a=arguments,b=a.length;b--;)if(!Db(a[b]))throw new wd;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Mc(a,b){return b="number"==typeof b?b:+b||a.length,gb(a,4,null,null,null,b)}function Nc(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!Db(a))throw new wd;if(b=Sd(0,b)||0,c===!0){var n=!0;m=!1}else Eb(c)&&(n=c.leading,l="maxWait"in c&&(Sd(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(oe()-g);if(0>=c){e&&Dd(e);var l=j;e=i=j=r,l&&(k=oe(),f=a.apply(h,d),i||e||(d=h=null))}else i=Jd(o,c)},p=function(){i&&Dd(i),e=i=j=r,(m||l!==b)&&(k=oe(),f=a.apply(h,d),i||e||(d=h=null))};return function(){if(d=arguments,g=oe(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k),r=0>=q;r?(e&&(e=Dd(e)),k=g,f=a.apply(h,d)):e||(e=Jd(p,q))}return r&&i?i=Dd(i):i||b===l||(i=Jd(o,b)),c&&(r=!0,f=a.apply(h,d)),!r||i||e||(d=h=null),f}}function Oc(a){if(!Db(a))throw new wd;var b=p(arguments,1);return Jd(function(){a.apply(r,b)},1)}function Pc(a,b){if(!Db(a))throw new wd;var c=p(arguments,2);return Jd(function(){a.apply(r,c)},b)}function Qc(a,b){if(!Db(a))throw new wd;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):v+arguments[0];return Hd.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Rc(a){var b,c;if(!Db(a))throw new wd;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Sc(a){return gb(a,16,p(arguments,1))}function Tc(a){return gb(a,32,null,p(arguments,1))}function Uc(a,b,c){var d=!0,e=!0;if(!Db(a))throw new wd;return c===!1?d=!1:Eb(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),W.leading=d,W.maxWait=b,W.trailing=e,Nc(a,b,W)}function Vc(a,b){return gb(b,16,[a])}function Wc(a){return function(){return a}}function Xc(a,b,c){var d=typeof a;if(null==a||"function"==d)return t(a,b,c);if("object"!=d)return bd(a);var e=_d(a),f=e[0],g=a[f];return 1!=e.length||g!==g||Eb(g)?function(b){for(var c=e.length,d=!1;c--&&(d=ab(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return g===b&&(0!==g||1/g==1/b)}}function Yc(a){return null==a?"":vd(a).replace(de,hb)}function Zc(a){return a}function $c(a,d,e){var f=!0,g=d&&ub(d);d&&(e||g.length)||(null==e&&(e=d),h=c,d=a,a=b,g=ub(d)),e===!1?f=!1:Eb(e)&&"chain"in e&&(f=e.chain);var h=a,i=Db(h);Yb(g,function(b){var c=a[b]=d[b];i&&(h.prototype[b]=function(){var b=this.__chain__,d=this.__wrapped__,e=[d];Id.apply(e,arguments);var g=c.apply(a,e);if(f||b){if(d===g&&Eb(g))return this;g=new h(g),g.__chain__=b}return g})})}function _c(){return a._=zd,this}function ad(){}function bd(a){return function(b){return b[a]}}function cd(a,b,c){var d=null==a,e=null==b;if(null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0,c||a%1||b%1){var f=Vd();return Td(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b)}return cb(a,b)}function dd(a,b){if(a){var c=a[b];return Db(c)?a[b]():c}}function ed(a,c,d){var e=b.templateSettings;a=vd(a||""),d=fe({},d,e);var f,g=fe({},d.imports,e.imports),h=_d(g),i=Rb(g),j=0,l=d.interpolate||H,m="__p += '",n=ud((d.escape||H).source+"|"+l.source+"|"+(l===F?C:H).source+"|"+(d.evaluate||H).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(j,h).replace(J,k),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),j=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(z,""):m).replace(A,"$1").replace(B,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+L++ +"]")+"\n*/";try{var s=qd(h,"return "+m+q).apply(r,i)}catch(t){throw t.source=m,t}return c?s(c):(s.source=m,s)}function fd(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=nd(a);for(b=t(b,c,1);++d<a;)e[d]=b(d);return e}function gd(a){return null==a?"":vd(a).replace(ce,lb)}function hd(a){var b=++u;return vd(null==a?"":a)+b}function id(a){return a=new c(a),a.__chain__=!0,a}function jd(a,b){return b(a),a}function kd(){return this.__chain__=!0,this}function ld(){return vd(this.__wrapped__)}function md(){return this.__wrapped__}a=a?db.defaults($.Object(),a,db.pick($,K)):$;var nd=a.Array,od=a.Boolean,pd=a.Date,qd=a.Function,rd=a.Math,sd=a.Number,td=a.Object,ud=a.RegExp,vd=a.String,wd=a.TypeError,xd=[],yd=td.prototype,zd=a._,Ad=yd.toString,Bd=ud("^"+vd(Ad).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Cd=rd.ceil,Dd=a.clearTimeout,Ed=rd.floor,Fd=qd.prototype.toString,Gd=jb(Gd=td.getPrototypeOf)&&Gd,Hd=yd.hasOwnProperty,Id=xd.push,Jd=a.setTimeout,Kd=xd.splice,Ld=xd.unshift,Md=function(){try{var a={},b=jb(b=td.defineProperty)&&b,c=b(a,a,a)&&b}catch(d){}return c}(),Nd=jb(Nd=td.create)&&Nd,Od=jb(Od=nd.isArray)&&Od,Pd=a.isFinite,Qd=a.isNaN,Rd=jb(Rd=td.keys)&&Rd,Sd=rd.max,Td=rd.min,Ud=a.parseInt,Vd=rd.random,Wd={};Wd[N]=nd,Wd[O]=od,Wd[P]=pd,Wd[Q]=qd,Wd[S]=td,Wd[R]=sd,Wd[T]=ud,Wd[U]=vd,c.prototype=b.prototype;var Xd=b.support={};Xd.funcDecomp=!jb(a.WinRTError)&&I.test(q),Xd.funcNames="string"==typeof qd.name,b.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:b}},Nd||(s=function(){function b(){}return function(c){if(Eb(c)){b.prototype=c;var d=new b;b.prototype=null}return d||a.Object()}}());var Yd=Md?function(a,b){X.value=b,Md(a,"__bindData__",X)}:ad,Zd=Od||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ad.call(a)==N||!1},$d=function(a){var b,c=a,d=[];if(!c)return d;if(!Y[typeof a])return d;for(b in c)Hd.call(c,b)&&d.push(b);return d},_d=Rd?function(a){return Eb(a)?Rd(a):[]}:$d,ae={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},be=wb(ae),ce=ud("("+_d(be).join("|")+")","g"),de=ud("["+_d(ae).join("")+"]","g"),ee=function(a,b,c){var d,e=a,f=e;if(!e)return f;var g=arguments,h=0,i="number"==typeof c?2:g.length;if(i>3&&"function"==typeof g[i-2])var j=t(g[--i-1],g[i--],2);else i>2&&"function"==typeof g[i-1]&&(j=g[--i]);for(;++h<i;)if(e=g[h],e&&Y[typeof e])for(var k=-1,l=Y[typeof e]&&_d(e),m=l?l.length:0;++k<m;)d=l[k],f[d]=j?j(f[d],e[d]):e[d];return f},fe=function(a,b,c){var d,e=a,f=e;if(!e)return f;for(var g=arguments,h=0,i="number"==typeof c?2:g.length;++h<i;)if(e=g[h],e&&Y[typeof e])for(var j=-1,k=Y[typeof e]&&_d(e),l=k?k.length:0;++j<l;)d=k[j],"undefined"==typeof f[d]&&(f[d]=e[d]);return f},ge=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:t(b,c,3);for(d in e)if(b(e[d],d,a)===!1)return f;return f},he=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:t(b,c,3);for(var g=-1,h=Y[typeof e]&&_d(e),i=h?h.length:0;++g<i;)if(d=h[g],b(e[d],d,a)===!1)return f;return f},ie=Gd?function(a){if(!a||Ad.call(a)!=S)return!1;var b=a.valueOf,c=jb(b)&&(c=Gd(b))&&Gd(c);return c?a==c||Gd(a)==c:kb(a)}:kb,je=fb(function(a,b,c){Hd.call(a,c)?a[c]++:a[c]=1}),ke=fb(function(a,b,c){(Hd.call(a,c)?a[c]:a[c]=[]).push(b)}),le=fb(function(a,b,c){a[c]=b}),me=_b,ne=Vb,oe=jb(oe=pd.now)&&oe||function(){return(new pd).getTime()},pe=8==Ud(y+"08")?Ud:function(a,b){return Ud(Jb(a)?a.replace(G,""):a,b||0)};return b.after=Hc,b.assign=ee,b.at=Sb,b.bind=Ic,b.bindAll=Jc,b.bindKey=Kc,b.chain=id,b.compact=lc,b.compose=Lc,b.constant=Wc,b.countBy=je,b.create=pb,b.createCallback=Xc,b.curry=Mc,b.debounce=Nc,b.defaults=fe,b.defer=Oc,b.delay=Pc,b.difference=mc,b.filter=Vb,b.flatten=qc,b.forEach=Yb,b.forEachRight=Zb,b.forIn=ge,b.forInRight=sb,b.forOwn=he,b.forOwnRight=tb,b.functions=ub,b.groupBy=ke,b.indexBy=le,b.initial=sc,b.intersection=tc,b.invert=wb,b.invoke=$b,b.keys=_d,b.map=_b,b.mapValues=Lb,b.max=ac,b.memoize=Qc,b.merge=Mb,b.min=bc,b.omit=Nb,b.once=Rc,b.pairs=Ob,b.partial=Sc,b.partialRight=Tc,b.pick=Pb,b.pluck=me,b.property=bd,b.pull=wc,b.range=xc,b.reject=ec,b.remove=yc,b.rest=zc,b.shuffle=gc,b.sortBy=jc,b.tap=jd,b.throttle=Uc,b.times=fd,b.toArray=kc,b.transform=Qb,b.union=Bc,b.uniq=Cc,b.values=Rb,b.where=ne,b.without=Dc,b.wrap=Vc,b.xor=Ec,b.zip=Fc,b.zipObject=Gc,b.collect=_b,b.drop=zc,b.each=Yb,b.eachRight=Zb,b.extend=ee,b.methods=ub,b.object=Gc,b.select=Vb,b.tail=zc,b.unique=Cc,b.unzip=Fc,$c(b),b.clone=nb,b.cloneDeep=ob,b.contains=Tb,b.escape=Yc,b.every=Ub,b.find=Wb,b.findIndex=nc,b.findKey=qb,b.findLast=Xb,b.findLastIndex=oc,b.findLastKey=rb,b.has=vb,b.identity=Zc,b.indexOf=rc,b.isArguments=mb,b.isArray=Zd,b.isBoolean=xb,b.isDate=yb,b.isElement=zb,b.isEmpty=Ab,b.isEqual=Bb,b.isFinite=Cb,b.isFunction=Db,b.isNaN=Fb,b.isNull=Gb,b.isNumber=Hb,b.isObject=Eb,b.isPlainObject=ie,b.isRegExp=Ib,b.isString=Jb,b.isUndefined=Kb,b.lastIndexOf=vc,b.mixin=$c,b.noConflict=_c,b.noop=ad,b.now=oe,b.parseInt=pe,b.random=cd,b.reduce=cc,b.reduceRight=dc,b.result=dd,b.runInContext=q,b.size=hc,b.some=ic,b.sortedIndex=Ac,b.template=ed,b.unescape=gd,b.uniqueId=hd,b.all=Ub,b.any=ic,b.detect=Wb,b.findWhere=Wb,b.foldl=cc,b.foldr=dc,b.include=Tb,b.inject=cc,$c(function(){var a={};return he(b,function(c,d){b.prototype[d]||(a[d]=c)}),a}(),!1),b.first=pc,b.last=uc,b.sample=fc,b.take=pc,b.head=pc,he(b,function(a,d){var e="sample"!==d;b.prototype[d]||(b.prototype[d]=function(b,d){var f=this.__chain__,g=a(this.__wrapped__,b,d);return f||null!=b&&(!d||e&&"function"==typeof b)?new c(g,f):g})}),b.VERSION="2.4.1",b.prototype.chain=kd,b.prototype.toString=ld,b.prototype.value=md,b.prototype.valueOf=md,Yb(["join","pop","shift"],function(a){var d=xd[a];b.prototype[a]=function(){var a=this.__chain__,b=d.apply(this.__wrapped__,arguments);return a?new c(b,a):b}}),Yb(["push","reverse","sort","unshift"],function(a){var c=xd[a];b.prototype[a]=function(){return c.apply(this.__wrapped__,arguments),this}}),Yb(["concat","slice","splice"],function(a){var d=xd[a];b.prototype[a]=function(){return new c(d.apply(this.__wrapped__,arguments),this.__chain__)}}),b}var r,s=[],t=[],u=0,v=+new Date+"",w=75,x=40,y=" \f \n\r\u2028\u2029 ᠎              ",z=/\b__p \+= '';/g,A=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,E=/^\s*function[ \n\r\t]+\w/,F=/<%=([\s\S]+?)%>/g,G=RegExp("^["+y+"]*0+(?=.$)"),H=/($^)/,I=/\bthis\b/,J=/['\n\r\t\u2028\u2029\\]/g,K=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],L=0,M="[object Arguments]",N="[object Array]",O="[object Boolean]",P="[object Date]",Q="[object Function]",R="[object Number]",S="[object Object]",T="[object RegExp]",U="[object String]",V={};V[Q]=!1,V[M]=V[N]=V[O]=V[P]=V[R]=V[S]=V[T]=V[U]=!0;var W={leading:!1,maxWait:0,trailing:!1},X={configurable:!1,enumerable:!1,value:null,writable:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=Y[typeof window]&&window||this,_=Y[typeof d]&&d&&!d.nodeType&&d,ab=Y[typeof c]&&c&&!c.nodeType&&c,bb=ab&&ab.exports===_&&_,cb=Y[typeof b]&&b;!cb||cb.global!==cb&&cb.window!==cb||($=cb);var db=q();"function"==typeof a&&"object"==typeof a.amd&&a.amd?($._=db,a(function(){return db})):_&&ab?bb?(ab.exports=db)._=db:_._=db:$._=db}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(a,b,c){!function(a){function b(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function c(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var d=function(){return d.cache.hasOwnProperty(arguments[0])||(d.cache[arguments[0]]=d.parse(arguments[0])),d.format.call(null,d.cache[arguments[0]],arguments)};d.format=function(a,e){var f,g,h,i,j,k,l,m=1,n=a.length,o="",p=[];for(g=0;n>g;g++)if(o=b(a[g]),"string"===o)p.push(a[g]);else if("array"===o){if(i=a[g],i[2])for(f=e[m],h=0;h<i[2].length;h++){if(!f.hasOwnProperty(i[2][h]))throw d('[sprintf] property "%s" does not exist',i[2][h]);f=f[i[2][h]]}else f=i[1]?e[i[1]]:e[m++];if(/[^s]/.test(i[8])&&"number"!=b(f))throw d("[sprintf] expecting number but found %s",b(f));switch(i[8]){case"b":f=f.toString(2);break;case"c":f=String.fromCharCode(f);break;case"d":f=parseInt(f,10);break;case"e":f=i[7]?f.toExponential(i[7]):f.toExponential();break;case"f":f=i[7]?parseFloat(f).toFixed(i[7]):parseFloat(f);break;case"o":f=f.toString(8);break;case"s":f=(f=String(f))&&i[7]?f.substring(0,i[7]):f;break;case"u":f>>>=0;break;case"x":f=f.toString(16);break;case"X":f=f.toString(16).toUpperCase()}f=/[def]/.test(i[8])&&i[3]&&f>=0?"+"+f:f,k=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",l=i[6]-String(f).length,j=i[6]?c(k,l):"",p.push(i[5]?f+j:j+f)}return p.join("")},d.cache={},d.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d};var e=function(a,b,c){return c=b.slice(0),c.splice(0,0,a),d.apply(null,c)};a.sprintf=d,a.vsprintf=e}("undefined"!=typeof c?c:window)},{}],16:[function(a,b){function c(){}function d(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function e(){if(q.XMLHttpRequest&&("file:"!=q.location.protocol||!q.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}return!1}function f(a){return a===Object(a)}function g(a){if(!f(a))return a;var b=[];for(var c in a)null!=a[c]&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}function h(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;g>f;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function i(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;i>h;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=r(c.slice(b+1)),g[d]=e;return g}function j(a){return a.split(/ *; */).shift()}function k(a){return p(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function l(a,b){b=b||{},this.req=a,this.xhr=this.req.xhr,this.text=this.xhr.responseText,this.setStatusProperties(this.xhr.status),this.header=this.headers=i(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text):null}function m(a,b){var c=this;o.call(this),this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){try{var b=new l(c);"HEAD"==a&&(b.text=null),c.callback(null,b)}catch(d){var e=new Error("Parser is unable to parse the response");e.parse=!0,e.original=d,c.callback(e)}})}function n(a,b){return"function"==typeof b?new m("GET",a).end(b):1==arguments.length?new m("GET",a):new m(a,b)}var o=a("emitter"),p=a("reduce"),q="undefined"==typeof window?this:window,r="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};n.serializeObject=g,n.parseString=h,n.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},n.serialize={"application/x-www-form-urlencoded":g,"application/json":JSON.stringify},n.parse={"application/x-www-form-urlencoded":h,"application/json":JSON.parse},l.prototype.get=function(a){return this.header[a.toLowerCase()]},l.prototype.setHeaderProperties=function(){var a=this.header["content-type"]||"";this.type=j(a);var b=k(a);for(var c in b)this[c]=b[c]},l.prototype.parseBody=function(a){var b=n.parse[this.type];return b&&a&&a.length?b(a):null},l.prototype.setStatusProperties=function(a){var b=a/100|0;this.status=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=4==b||5==b?this.toError():!1,this.accepted=202==a,this.noContent=204==a||1223==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a},l.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot "+b+" "+c+" ("+this.status+")",e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},n.Response=l,o(m.prototype),m.prototype.use=function(a){return a(this),this},m.prototype.timeout=function(a){return this._timeout=a,this},m.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},m.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},m.prototype.set=function(a,b){if(f(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},m.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},m.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},m.prototype.type=function(a){return this.set("Content-Type",n.types[a]||a),this},m.prototype.accept=function(a){return this.set("Accept",n.types[a]||a),this},m.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},m.prototype.query=function(a){return"string"!=typeof a&&(a=g(a)),a&&this._query.push(a),this},m.prototype.field=function(a,b){return this._formData||(this._formData=new FormData),this._formData.append(a,b),this},m.prototype.attach=function(a,b,c){return this._formData||(this._formData=new FormData),this._formData.append(a,b,c),this},m.prototype.send=function(a){var b=f(a),c=this.getHeader("Content-Type");if(b&&f(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==c?this._data?this._data+"&"+a:a:(this._data||"")+a):this._data=a;return b?(c||this.type("json"),this):this},m.prototype.callback=function(a,b){var c=this._callback;return 2==c.length?c(a,b):a?this.emit("error",a):void c(b)},m.prototype.crossDomainError=function(){var a=new Error("Origin is not allowed by Access-Control-Allow-Origin");a.crossDomain=!0,this.callback(a)},m.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},m.prototype.withCredentials=function(){return this._withCredentials=!0,this},m.prototype.end=function(a){var b=this,f=this.xhr=e(),g=this._query.join("&"),h=this._timeout,i=this._formData||this._data;if(this._callback=a||c,f.onreadystatechange=function(){return 4==f.readyState?0==f.status?b.aborted?b.timeoutError():b.crossDomainError():void b.emit("end"):void 0},f.upload&&(f.upload.onprogress=function(a){a.percent=a.loaded/a.total*100,b.emit("progress",a)}),h&&!this._timer&&(this._timer=setTimeout(function(){b.abort()},h)),g&&(g=n.serializeObject(g),this.url+=~this.url.indexOf("?")?"&"+g:"?"+g),f.open(this.method,this.url,!0),this._withCredentials&&(f.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof i&&!d(i)){var j=n.serialize[this.getHeader("Content-Type")];j&&(i=j(i))}for(var k in this.header)null!=this.header[k]&&f.setRequestHeader(k,this.header[k]);return this.emit("request",this),f.send(i),this},n.Request=m,n.get=function(a,b,c){var d=n("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},n.head=function(a,b,c){var d=n("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.del=function(a,b){var c=n("DELETE",a);return b&&c.end(b),c},n.patch=function(a,b,c){var d=n("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.post=function(a,b,c){var d=n("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.put=function(a,b,c){var d=n("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},b.exports=n},{emitter:17,reduce:18}],17:[function(a,b){function c(a){return a?d(a):void 0}function d(a){for(var b in c.prototype)a[b]=c.prototype[b];return a}b.exports=c,c.prototype.on=c.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},c.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},c.fn=b,this.on(a,c),this},c.prototype.off=c.prototype.removeListener=c.prototype.removeAllListeners=c.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;for(var d,e=0;e<c.length;e++)if(d=c[e],d===b||d.fn===b){c.splice(e,1);break}return this},c.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c){c=c.slice(0);for(var d=0,e=c.length;e>d;++d)c[d].apply(this,b)}return this},c.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},c.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],18:[function(a,b){b.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];e>d;)f=b.call(null,f,a[d],++d,a);return f}},{}]},{},[1])(1)});

@@ -10,3 +10,2 @@ // Main entry point

grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-glue-js');
grunt.loadNpmTasks('grunt-contrib-uglify');

@@ -13,0 +12,0 @@ grunt.loadNpmTasks('grunt-browserify');

@@ -5,4 +5,12 @@ // Main entry point

// Load main module
var logger = require('./libs/logger.js');
var MoussakaClient = require('./libs/moussakaClient.js');
// Expose types
MoussakaClient.types = {};
MoussakaClient.types.Color = require('./libs/types/color.js');
MoussakaClient.types.Position = require('./libs/types/position.js');
// Export
logger.trace('MoussakaClient module loaded.');

@@ -9,0 +17,0 @@ module.exports = MoussakaClient;

@@ -27,7 +27,8 @@ // Main class

utils.validateRequiredOptions(opts, ['deviceName', 'apiKey',
'projectId', 'projectVersion'
]);
// Defaults
this.deviceName = null;
this.apiKey = null;
this.projectId = null;
this.projectVersion = null;
// Defaults
this.serverUrl = 'http://localhost:3000/';

@@ -39,3 +40,3 @@ this.pollInterval = 1000; //ms

// Fields
this.registedVars = {};
this.registeredVars = {};
this.connected = false;

@@ -69,4 +70,59 @@ this.dataSchema = {};

MoussakaClient.prototype.getErrorDetail = function (res) {
var msg = 'An unknown error occurred';
if (res.body && res.body.detail) {
msg = res.body.detail;
} else if (res.text) {
msg = res.text;
}
return msg;
};
MoussakaClient.prototype.serializeValue = function (value) {
switch (typeof (value)) {
case 'boolean':
return {
values: {
b: value
}
};
case 'number':
return {
values: {
n: value
}
};
case 'string':
return {
values: {
s: value
}
};
case 'object':
if (value.serialize) {
return value.serialize();
} else {
throw new Error('Cannot serialize object without serialize method.');
}
break;
default:
throw new Error('Cannot serialize undefined or unsupported variable.');
}
};
MoussakaClient.prototype.getStateSnapshot = function () {
var snapshot = {};
_.each(this.registeredVars, function (registeredVar, name) {
var value = registeredVar.ref.value;
if (typeof (value) === 'undefined' ||
value === null) {
return true; // Skip
}
snapshot[name] = this.serializeValue(value);
}, this);
return snapshot;
};
MoussakaClient.prototype.registerVar = function (name, value, schema) {
if (this.registedVars[name]) {
if (this.registeredVars[name]) {
throw new Error('Variable with that name already registered.');

@@ -77,3 +133,3 @@ }

this.registedVars[name] = {
this.registeredVars[name] = {
ref: ref,

@@ -94,3 +150,3 @@ schema: schema

var dataSchema = {};
_.each(this.registedVars, function (variable, name) {
_.each(this.registeredVars, function (variable, name) {
if (!variable.schema) {

@@ -139,5 +195,10 @@ // Create a schema by guessing

MoussakaClient.prototype.connect = function () {
utils.validateRequiredOptions(this, ['deviceName', 'apiKey',
'projectId', 'projectVersion'
]);
var url = this.getBaseUrl() + path.join('/projects/',
this.projectId, 'devices/');
logger.trace('Connecting device at: ' + url);
superagent.put(url)

@@ -147,4 +208,7 @@ .send({

projectVersion: this.projectVersion,
deviceName: this.deviceName
deviceName: this.deviceName,
dataSchema: this.dataSchema,
currentState: this.getStateSnapshot()
})
.set('apikey', this.apiKey)
.end(function (e, res) {

@@ -157,3 +221,3 @@ if (e) {

this.connected = true;
this._id = res.body._id;
this._id = res.body.data._id;
logger.trace('Connected!: _id: ' + this._id);

@@ -164,3 +228,3 @@ this.emit('connect', this._id);

this.emit('error', new Error('Server returned error: Status: ' +
res.status + ' Detail:' + res.body.detail));
res.status + ' Detail: ' + this.getErrorDetail(res)));
}

@@ -172,2 +236,6 @@

MoussakaClient.prototype.disconnect = function () {
utils.validateRequiredOptions(this, ['deviceName', 'apiKey',
'projectId', 'projectVersion'
]);
var url = this.getBaseUrl() + path.join('/projects/',

@@ -180,2 +248,3 @@ this.projectId, 'devices/', this._id, '/');

superagent.del(url)
.set('apikey', this.apiKey)
.end(function (e, res) {

@@ -191,3 +260,3 @@ if (e) {

this.emit('error', new Error('Server returned error: Status: ' +
res.status + ' Detail:' + res.body.detail));
res.status + ' Detail: ' + this.getErrorDetail(res)));
}

@@ -212,2 +281,6 @@

MoussakaClient.prototype.pollFn = function () {
utils.validateRequiredOptions(this, ['deviceName', 'apiKey',
'projectId', 'projectVersion', '_id'
]);
var url = this.getBaseUrl() + path.join('/projects/',

@@ -227,2 +300,3 @@ this.projectId, 'sessions/', this._id, '/updates/');

superagent.get(url)
.set('apikey', this.apiKey)
.end(function (e, res) {

@@ -241,7 +315,7 @@ this.pollReady = true;

this.pollErrorCount = 0;
this.applyUpdates(res.body);
this.applyUpdates(res.body.data);
} else {
return this.emit('error',
new Error('Server returned error: Status: ' +
res.status + ' Detail:' + res.body.detail));
res.status + ' Detail: ' + this.getErrorDetail(res)));
}

@@ -270,5 +344,5 @@

_.each(updates, function (update, key) {
_.forIn(updates, function (update, key) {
var values = update.values;
var variable = this.registedVars[key];
var variable = this.registeredVars[key];
var type = variable.schema.type;

@@ -275,0 +349,0 @@ var ref = variable.ref;

@@ -45,4 +45,15 @@ // Color Type

Color.prototype.serialize = function () {
return {
values: this.getValues()
};
};
Color.prototype.deserialize = function (data) {
this.setValues(data.values);
};
module.exports = Color;
})(require, module);

@@ -19,7 +19,9 @@ // Position Type

}
} else {
this.x = x;
}
// Defaults
this.y = this.y || 0;
this.z = this.z || 0;
this.y = this.y || y || 0;
this.z = this.z || z || 0;

@@ -48,4 +50,14 @@ utils.validateRequiredOptions(this, ['x', 'y', 'z']);

Position.prototype.serialize = function () {
return {
values: this.getValues()
};
};
Position.prototype.deserialize = function (data) {
this.setValues(data.values);
};
module.exports = Position;
})(require, module);

@@ -9,3 +9,5 @@ // Utils

module.exports = {
validateRequiredOptions: function (object, keys) {
validateRequiredOptions: function (object, keys, strict) {
strict = strict || true;
if (!object && keys.length > 0) {

@@ -18,2 +20,10 @@ return false;

}
var value = object[key];
if (typeof (value) === 'undefined' ||
value === null ||
(typeof (value) === 'string' && value.trim() === '')) {
throw new Error(
'Option is undefined, null or empty string: ' +
key);
}
});

@@ -20,0 +30,0 @@ return true;

{
"name": "moussaka-client",
"version": "0.1.2",
"version": "0.1.6",
"description": "A javascript library that allows you to use javascript applications with the Moussaka prototyping framework.",
"main": "index.js",
"scripts": {
"test": "./node_modules/mocha/bin/_mocha -t 20000 tests/test.js",
"test": "./node_modules/mocha/bin/_mocha -t 20000 -b tests/test.js",
"coveralls": "./gencoverage.sh"

@@ -9,0 +9,0 @@ },

@@ -17,3 +17,3 @@ moussaka-client

var aString = client.registerVar('aString', 'string beans');
var aColor = client.registerVar('aColor', new Color(1, 0, 0, 1)); // Moussaka type
var aColor = client.registerVar('aColor', new MoussakaClient.types.Color(1, 0, 0, 1)); // Moussaka type

@@ -35,5 +35,5 @@ // Define specific schema

console.log(aNumber.value);
console.log(aNumber.aString);
console.log(aNumber.aColor.toString());
console.log(aNumber.validatedNumber);
console.log(aString.value);
console.log(aColor.value.toString());
console.log(validatedNumber.value);
}

@@ -40,0 +40,0 @@

(function (require, module) {
'use strict';
var logger = require('../libs/logger.js');
var _ = require('lodash');
var chai = require('chai');

@@ -18,3 +19,7 @@

'\/projects\/.+\/devices\/$': function(req, res) {
var registeredVars = Object.keys(that.client.registeredVars);
expect(req.method).to.equal('PUT');
expect(req.headers)
.to.have.property('apikey');
expect(req.body)

@@ -26,6 +31,19 @@ .to.have.property('projectId', client.projectId);

.to.have.property('deviceName', client.deviceName);
expect(req.body)
.to.have.property('dataSchema');
expect(Object.keys(req.body.dataSchema))
.to.have.length(registeredVars.length);
expect(req.body)
.to.have.property('currentState');
expect(Object.keys(req.body.currentState))
.to.have.length(registeredVars.length);
_.each(req.body.currentState, function(value, key) {
expect(value)
.to.have.property('values');
});
// Send back _id
res.statusCode = 200;
var returnString = JSON.stringify({ _id: _id });
var returnString = JSON.stringify({ data: { _id: _id }});
res.setHeader('Content-Type', 'application/json');

@@ -36,2 +54,4 @@ res.end(returnString);

expect(req.method).to.equal('GET');
expect(req.headers)
.to.have.property('apikey');
that.stats.pollCount++;

@@ -41,3 +61,3 @@

res.statusCode = 200;
var returnString = JSON.stringify(that.updates);
var returnString = JSON.stringify({data: that.updates});
that.updates = {};

@@ -49,6 +69,8 @@ res.setHeader('Content-Type', 'application/json');

expect(req.method).to.equal('DELETE');
expect(req.headers)
.to.have.property('apikey');
// Send back _id
res.statusCode = 200;
var returnString = '{}';
var returnString = JSON.stringify({ data: {} });
res.setHeader('Content-Type', 'application/json');

@@ -55,0 +77,0 @@ res.end(returnString);

@@ -5,2 +5,3 @@ (function (require, module) {

var Color = require('../libs/types/color.js');
var Position = require('../libs/types/position.js');
var chance = require('chance').Chance();

@@ -26,4 +27,7 @@ var MockServer = require('./mockServer.js');

var aColor;
var aPosition;
var _id = chance.guid();
var mockResponses;
var pollInterval = 50;
var pollsToCheck = 5;

@@ -48,14 +52,25 @@ // Setup Intercept

it('should register vars without error', function() {
client = chai.factory.create('client');
client = chai.factory.create('client', { pollInterval: 50 });
aNumber = client.registerVar('aNumber', 5);
aString = client.registerVar('aString', 'stringme');
aColor = client.registerVar('aColor', new Color(1, 0, 0, 1));
aPosition = client.registerVar('aPosition', new Position(22, 56));
mockResponses = new MockResponses(client, _id);
});
it('should throw error if missing var', function() {
var badClient = chai.factory.create('client', { projectId: null });
expect(badClient.connect)
.to.throw(Error);
});
it('should connect to server', function(done) {
client.on('connect', function() {
expect(client._id).to.eql(_id);
done();
try {
expect(client._id).to.eql(_id);
done();
} catch(ex) {
done(ex);
}
});

@@ -68,9 +83,14 @@

it('should poll regularly', function(done) {
logger.info('Waiting for 5 seconds to test polling');
logger.info('Waiting to test polling');
mockResponses.stats.pollCount = 0;
setTimeout(function() {
// Variability for slow test VMs
expect(mockResponses.stats.pollCount)
.to.be.within(4, 5);
done();
}, 5000);
try {
// Variability for slow test VMs
expect(mockResponses.stats.pollCount)
.to.be.within(pollsToCheck - 1, pollsToCheck + 1);
done();
} catch(ex) {
done(ex);
}
}, pollInterval * pollsToCheck);
});

@@ -88,22 +108,25 @@

values: { r: 0, g: 0, b: 1, a: 0.5 }
},
'aPosition': {
values: { x: 3, y: 2, z: 1 }
}
};
logger.info('Waiting for 2 seconds to test updates');
logger.info('Waiting for to test updates');
setTimeout(function() {
expect(aNumber.value)
.to.eql(50);
expect(aString.value)
.to.eql('newString');
expect(aColor.value)
.to.have.property('r', 0);
expect(aColor.value)
.to.have.property('g', 0);
expect(aColor.value)
.to.have.property('b', 1);
expect(aColor.value)
.to.have.property('a', 0.5);
done();
}, 2000);
try {
expect(aNumber.value)
.to.eql(50);
expect(aString.value)
.to.eql('newString');
expect(aColor.value)
.to.include({ r: 0, g: 0, b: 1, a: 0.5 });
expect(aPosition.value)
.to.include({ x: 3, y: 2, z: 1 });
done();
} catch(ex) {
done(ex);
}
}, pollInterval * 5);
});

@@ -114,9 +137,14 @@

mockResponses.stats.pollCount = 0;
logger.info('Waiting for 2 seconds to check if polling stopped');
logger.info('Waiting to check if polling stopped');
setTimeout(function() {
// Variability for slow test VMs
expect(mockResponses.stats.pollCount)
.to.eql(0);
done();
}, 2000);
try {
// Variability for slow test VMs
expect(mockResponses.stats.pollCount)
.to.eql(0);
done();
} catch(ex) {
done(ex);
}
}, pollInterval * 5);
});

@@ -123,0 +151,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc