diff --git a/build/marsdb.js b/build/marsdb.js index 3728206..4d51593 100644 --- a/build/marsdb.js +++ b/build/marsdb.js @@ -5414,6 +5414,7 @@ var EJSON = require('./dist/EJSON')['default']; var Base64 = require('./dist/Base64')['default']; module.exports = { + __esModule: true, 'default': Collection, Random: Random, EJSON: EJSON, diff --git a/build/marsdb.min.js b/build/marsdb.min.js index 74c8b16..1afd50c 100644 --- a/build/marsdb.min.js +++ b/build/marsdb.min.js @@ -1,4 +1,4 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Mars=e()}}(function(){var e;return function t(e,n,r){function i(a,u){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a255)throw new Error("Not ascii. Base64.encode can only take ascii strings.");e[n]=r}}for(var i=[],o=null,a=null,s=null,l=null,n=0;n>2&63,a=(3&e[n])<<4;break;case 1:a|=e[n]>>4&15,s=(15&e[n])<<2;break;case 2:s|=e[n]>>6&3,l=63&e[n],i.push(u(o)),i.push(u(a)),i.push(u(s)),i.push(u(l)),o=null,a=null,s=null,l=null}return null!=o&&(i.push(u(o)),i.push(u(a)),null==s?i.push("="):i.push(u(s)),null==l&&i.push("=")),i.join("")}},{key:"decode",value:function(e){var t=Math.floor(3*e.length/4);"="==e.charAt(e.length-1)&&(t--,"="==e.charAt(e.length-2)&&t--);for(var n=this.newBinary(t),r=null,i=null,o=null,a=0,u=0;uc)throw new Error("invalid base64 string");r=c<<2;break;case 1:if(0>c)throw new Error("invalid base64 string");r|=c>>4,n[a++]=r,i=(15&c)<<4;break;case 2:c>=0&&(i|=c>>2,n[a++]=i,o=(3&c)<<6);break;case 3:c>=0&&(n[a++]=o|c)}}return n}},{key:"newBinary",value:function(e){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer){for(var t=[],n=0;e>n;n++)t.push(0);return t.$Uint8ArrayPolyfill=!0,t}return new Uint8Array(new ArrayBuffer(e))}}]),e}();n.Base64=l,n["default"]=new l},{}],2:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n=0||"undefined"==typeof e,"skip(...): skip must be a positive number"),this._skip=e,this}},{key:"limit",value:function(e){return this._ensureNotExecuting(),(0,b["default"])(e>=0||"undefined"==typeof e,"limit(...): limit must be a positive number"),this._limit=e,this}},{key:"find",value:function(e){return this._ensureNotExecuting(),this._query=e||this._query,this._ensureMatcherSorter(),this}},{key:"sort",value:function(e){return this._ensureNotExecuting(),(0,b["default"])("object"==typeof e||"undefined"==typeof e||Array.isArray(e),"sort(...): argument must be an object"),this._sort=e,this._ensureMatcherSorter(),this}},{key:"sortFunc",value:function(e){return(0,b["default"])("function"==typeof e,"sortFunc(...): argument must be a function"),this.addPipeline(S.Sort,e),this}},{key:"filter",value:function(e){return(0,b["default"])("function"==typeof e,"filter(...): argument must be a function"),this.addPipeline(S.Filter,e),this}},{key:"map",value:function(e){return(0,b["default"])("function"==typeof e,"map(...): mapper must be a function"),this.addPipeline(S.Map,e),this}},{key:"reduce",value:function(e,t){return(0,b["default"])("function"==typeof e,"reduce(...): reducer argument must be a function"),this.addPipeline(S.Reduce,e,t),this}},{key:"aggregate",value:function(e){return(0,b["default"])("function"==typeof e,"aggregate(...): aggregator must be a function"),this.addPipeline(S.Aggregate,e),this}},{key:"join",value:function(e){return this.joinEach(e)}},{key:"joinEach",value:function(e){return(0,b["default"])("function"==typeof e,"joinEach(...): argument must be a function"),this.addPipeline(S.JoinEach,e),this}},{key:"joinAll",value:function(e){return(0,b["default"])("function"==typeof e,"joinAll(...): argument must be a function"),this.addPipeline(S.JoinAll,e),this}},{key:"addPipeline",value:function(e,t){this._ensureNotExecuting(),(0,b["default"])(e&&S[e],"Unknown pipeline processor type %s",e);for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;n>i;i++)r[i-2]=arguments[i];return this._pipeline.push({type:e,value:t,args:r||[]}),this}},{key:"processPipeline",value:function(e){var t=this,n=arguments.length<=1||void 0===arguments[1]?0:arguments[1],r=this._pipeline[n];return r?Promise.resolve(M[r.type](e,r,this)).then(function(e){return t.processPipeline(e,n+1)}):Promise.resolve(e)}},{key:"processSkipLimits",value:function(e){var t=this._skip||0,n=this._limit||e.length;return e.slice(t,n+t)}},{key:"exec",value:function(){var e=this;return this._executing=!0,this._matchObjects().then(function(t){return e.processPipeline(t)}).then(function(t){return e._executing=!1,t})}},{key:"then",value:function(e,t){return this.exec().then(e,t)}},{key:"ids",value:function(){var e=this;return this._executing=!0,this._matchObjects().then(function(e){return e.map(function(e){return e._id})}).then(function(t){return e._executing=!1,t})}},{key:"_matchObjects",value:function(){var e=this;return new x["default"](this.db).retriveForQeury(this._query).then(function(t){var n=[],r=e._limit&&!e._skip&&!e._sorter;if((0,f["default"])(t,function(t){var i=e._matcher.documentMatches(t);return i.result&&n.push(t),r&&n.length===e._limit?!1:void 0}),r)return n;if(e._sorter){var i=e._sorter.getComparator();n.sort(i)}return e.processSkipLimits(n)})}},{key:"_ensureMatcherSorter",value:function(){this._sorter=void 0,this._matcher=new j["default"](this._query||{}),(this._matcher.hasGeoQuery||this._sort)&&(this._sorter=new A["default"](this._sort||[],{matcher:this._matcher}))}},{key:"_ensureNotExecuting",value:function(){(0,b["default"])(!this.isExecuting,"_ensureNotExecuting(...): cursor is executing, cursor is immutable!")}},{key:"isExecuting",get:function(){return!!this._executing}}]),t}(g["default"]);n.Cursor=P,n["default"]=P},{"./DocumentMatcher":7,"./DocumentRetriver":9,"./DocumentSorter":10,eventemitter3:19,invariant:21,keymirror:22,"lodash/collection/each":27,"lodash/lang/isObject":95,"lodash/lang/toArray":98}],5:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t,n){var r=null,i=0,o=null,a=!0,u=null,s=function(){var s=this,l=arguments;if(o){var c=n&&i>=n;a=!c,c&&u&&(clearTimeout(r),u())}else o=new Promise(function(n,c){(u=function(){a?(r=setTimeout(u,t),a=!1):(o=null,i=0,r=null,a=!0,u=null,n(e.apply(s,l)))})()});return i+=1,o},l=function(e){n=e},c=function(e){t=e},f=function(){clearTimeout(r)};return s.updateBatchSize=l,s.updateWait=c,s.cancel=f,s}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;nt.updatedAt)||!p["default"].equals(e,t)),i=r||e&&!t&&this._matcher.documentMatches(e).result;return i?this.update():void 0}},{key:"_prepareListener",value:function(e){return a(e,0,0)}},{key:"_propagateUpdate",value:function(){var e=arguments.length<=0||void 0===arguments[0]?!1:arguments[0];this.emit("update",this._latestResult,e),!e&&this._parentCursor&&this._parentCursor._propagateUpdate&&this._parentCursor._propagateUpdate(!1)}}]),t}(d["default"]);n.CursorObservable=y,n["default"]=y},{"./Cursor":4,"./EJSON":11,"lodash/collection/size":33}],6:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e){var t=this,n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];(0,x["default"])(e,"Document(...): you must give a collection for the document"),n=(0,g["default"])(n)?j["default"].parse(n):n,Object.defineProperty(this,"remove",{value:function(){return(0,x["default"])(t._id,"remove(...): document must have an _id for remove"),e.remove({_id:self._id})},writable:!1}),Object.defineProperty(this,"update",{value:function(t){return(0,x["default"])(this._id,"update(...): document must have an _id for update"),e.update({_id:self._id},t)},writable:!1}),Object.defineProperty(this,"copy",{value:function(){return new i(e,j["default"].clone(t))},writable:!1}),Object.defineProperty(this,"serialize",{value:function(){return j["default"].stringify(t)},writable:!1});for(var r in e._methods)Object.defineProperty(this,r,{value:e._methods[r],writable:!1});(0,h["default"])(this,n)}function o(e){return"string"==typeof e||"number"==typeof e}function a(e){return o(e)||e&&"object"==typeof e&&e._id&&o(e._id)&&1===(0,w["default"])(e)}function u(e){return(0,y["default"])(e)&&!j["default"].isBinary(e)}function s(e){return e&&3===E._type(e)}function l(e){return u(e)||s(e)}function c(e,t){if(!s(e))return!1;var n=void 0;return(0,b["default"])(e,function(r,i){var o="$"===i.substr(0,1);if(void 0===n)n=o;else if(n!==o){if(!t)throw new Error("Inconsistent operator: "+JSON.stringify(e));n=!1}}),!!n}function f(e){return/^[0-9]+$/.test(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.Document=i,n.selectorIsId=o,n.selectorIsIdPerhapsAsObject=a,n.isArray=u,n.isPlainObject=s,n.isIndexable=l,n.isOperatorObject=c,n.isNumericKey=f;var d=e("lodash/object/assign"),h=r(d),p=e("lodash/lang/isArray"),y=r(p),v=e("lodash/lang/isString"),g=r(v),m=e("lodash/collection/each"),b=r(m),_=e("lodash/collection/size"),w=r(_),O=e("invariant"),x=r(O),k=e("./EJSON"),j=r(k);n["default"]=i;var E={_type:function(e){return"number"==typeof e?1:"string"==typeof e?2:"boolean"==typeof e?8:u(e)?4:null===e?10:e instanceof RegExp?11:"function"==typeof e?13:e instanceof Date?9:j["default"].isBinary(e)?5:3},_equal:function(e,t){return j["default"].equals(e,t,{keyOrderSensitive:!0})},_typeorder:function(e){return[-1,1,2,3,4,5,-1,6,7,8,0,9,-1,100,2,100,1,8,1][e]},_cmp:function(e,t){if(void 0===e)return void 0===t?0:-1;if(void 0===t)return 1;var n=E._type(e),r=E._type(t),i=E._typeorder(n),o=E._typeorder(r);if(i!==o)return o>i?-1:1;if(n!==r)throw Error("Missing type coercion logic in _cmp");if(7===n&&(n=r=2,e=e.toHexString(),t=t.toHexString()),9===n&&(n=r=1,e=e.getTime(),t=t.getTime()),1===n)return e-t;if(2===r)return t>e?-1:e===t?0:1;if(3===n){var a=function(e){var t=[];for(var n in e)t.push(n),t.push(e[n]);return t};return E._cmp(a(e),a(t))}if(4===n)for(var u=0;;u++){if(u===e.length)return u===t.length?0:-1;if(u===t.length)return 1;var s=E._cmp(e[u],t[u]);if(0!==s)return s}if(5===n){if(e.length!==t.length)return e.length-t.length;for(u=0;ut[u])return 1}return 0}if(8===n)return e?t?0:1:t?-1:0;if(10===n)return 0;if(11===n)throw Error("Sorting not supported on regular expression");if(13===n)throw Error("Sorting not supported on Javascript code");throw Error("Unknown type to sort")}};n.MongoTypeComp=E},{"./EJSON":11,invariant:21,"lodash/collection/each":27,"lodash/collection/size":33,"lodash/lang/isArray":88,"lodash/lang/isString":96,"lodash/object/assign":99}],7:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return function(t){return t instanceof RegExp?(0,h["default"])(t,e):"string"!=typeof t?!1:(e.lastIndex=0,e.test(t))}}function a(e){if((0,F.isOperatorObject)(e))throw Error("Can't create equalityValueSelector for operator object");return null==e?function(e){return null==e}:function(t){return F.MongoTypeComp._equal(e,t)}}function u(e,t){t=t||{};var n,r=e.split("."),i=r.length?r[0]:"",o=(0,F.isNumericKey)(i),a=r.length>=2&&(0,F.isNumericKey)(r[1]);r.length>1&&(n=u(r.slice(1).join(".")));var s=function(e){return e.dontIterate||delete e.dontIterate,e.arrayIndices&&!e.arrayIndices.length&&delete e.arrayIndices,e};return function(e,r){if(r||(r=[]),(0,F.isArray)(e)){if(!(o&&ii||void 0!==t.distance&&t.distance<=n||(t.result=!0,t.distance=n,e.arrayIndices?t.arrayIndices=e.arrayIndices:delete t.arrayIndices)}),t}}},X=function(e,t){e=Z(e),t=Z(t);var n=e[0]-t[0],r=e[1]-t[1];return(0,w["default"])(n)||(0,w["default"])(r)?null:Math.sqrt(n*n+r*r)},Z=function(e){return(0,N["default"])(e,D["default"])},ee=function(e){return{compileElementSelector:function(t){if((0,F.isArray)(t))return function(){return!1};void 0===t&&(t=null);var n=F.MongoTypeComp._type(t);return function(r){return void 0===r&&(r=null),F.MongoTypeComp._type(r)!==n?!1:e(F.MongoTypeComp._cmp(r,t))}}}},te={$lt:ee(function(e){return 0>e}),$gt:ee(function(e){return e>0}),$lte:ee(function(e){return 0>=e}),$gte:ee(function(e){return e>=0}),$mod:{compileElementSelector:function(e){if(!(0,F.isArray)(e)||2!==e.length||"number"!=typeof e[0]||"number"!=typeof e[1])throw Error("argument to $mod must be an array of two numbers");var t=e[0],n=e[1];return function(e){return"number"==typeof e&&e%t===n}}},$in:{compileElementSelector:function(e){if(!(0,F.isArray)(e))throw Error("$in needs an array");var t=[];return(0,A["default"])(e,function(e){if(e instanceof RegExp)t.push(o(e));else{if((0,F.isOperatorObject)(e))throw Error("cannot nest $ under $in");t.push(a(e))}}),function(e){return void 0===e&&(e=null),(0,T["default"])(t,function(t){return t(e)})}}},$size:{dontExpandLeafArrays:!0,compileElementSelector:function(e){if("string"==typeof e)e=0;else if("number"!=typeof e)throw Error("$size needs a number");return function(t){return(0,F.isArray)(t)&&t.length===e}}},$type:{dontIncludeLeafArrays:!0,compileElementSelector:function(e){if("number"!=typeof e)throw Error("$type needs a number");return function(t){return void 0!==t&&F.MongoTypeComp._type(t)===e}}},$regex:{compileElementSelector:function(e,t){if(!("string"==typeof e||e instanceof RegExp))throw Error("$regex has to be a string or RegExp");var n;if(void 0!==t.$options){if(/[^gim]/.test(t.$options))throw new Error("Only the i, m, and g regexp options are supported");var r=e instanceof RegExp?e.source:e;n=new RegExp(r,t.$options)}else n=e instanceof RegExp?e:new RegExp(e); return o(n)}},$elemMatch:{dontExpandLeafArrays:!0,compileElementSelector:function(e,t,n){if(!(0,F.isPlainObject)(e))throw Error("$elemMatch need an object");var r,i;return(0,F.isOperatorObject)(e,!0)?(r=W(e,n),i=!1):(r=U(e,n,{inElemMatch:!0}),i=!0),function(e){if(!(0,F.isArray)(e))return!1;for(var t=0;t=e.length)return void 0;for(;e.length0)throw new Error("$slice in $push must be zero or negative");o=n.$slice}var a=void 0;if(n.$sort){if(void 0===o)throw new Error("$sort requires $slice to be present");a=new x["default"](n.$sort).getComparator();for(var u=0;un?r.splice(0,1):r.pop()}}},$pull:function(e,t,n){if(void 0!==e){var r=e[t];if(void 0!==r){if(!(r instanceof Array))throw new Error("Cannot apply $pull/pullAll modifier to non-array");var i=[];if(null==n||"object"!=typeof n||n instanceof Array)for(var o=0;o0?this.retriveIds(t):this.retriveAll()}},{key:"retriveAll",value:function(){var e=this;return new Promise(function(t,n){var r=[];e.db.storage.createReadStream().on("data",function(t){return r.push(e.db.create(t.value))}).on("end",function(){return t(r)})})}},{key:"retriveIds",value:function(e){var t=this,n=e.map(function(e){return t.retriveOne(e)});return Promise.all(n)}},{key:"retriveOne",value:function(e){var t=this;return this.db.storage.get(e).then(function(e){return t.db.create(e)})}}]),e}();n.DocumentRetriver=y,n["default"]=y},{"./Document":6,"lodash/collection/size":33,"lodash/lang/isArray":88,"lodash/lang/isObject":95,"lodash/object/has":100}],10:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n=0)})}if(this.affectedByModifier){var u={};(0,f["default"])(this._sortSpecParts,function(e){u[e.path]=1}),this._selectorForAffectedByModifier=new x["default"](u)}this._keyComparator=E((0,b["default"])(this._sortSpecParts,function(e,t){return n._keyFieldComparator(t)})),this._keyFilter=null,r.matcher&&this._useWithMatcher(r.matcher)}return o(e,[{key:"getComparator",value:function(e){if(!e||!e.distances)return this._getBaseComparator();var t=e.distances;return E([this._getBaseComparator(),function(e,n){if(!t.has(e._id))throw Error("Missing distance for "+e._id);if(!t.has(n._id))throw Error("Missing distance for "+n._id);return t.get(e._id)-t.get(n._id)}])}},{key:"_getPaths",value:function(){return(0,w["default"])(this._sortSpecParts,"path")}},{key:"_getMinKeyFromDoc",value:function(e){var t=this,n=null;if(this._generateKeysFromDoc(e,function(e){return t._keyCompatibleWithSelector(e)?null===n?void(n=e):void(t._compareKeys(e,n)<0&&(n=e)):void 0}),null===n)throw Error("sort selector found no keys in doc?");return n}},{key:"_keyCompatibleWithSelector",value:function(e){return!this._keyFilter||this._keyFilter(e)}},{key:"_generateKeysFromDoc",value:function(e,t){if(0===this._sortSpecParts.length)throw new Error("can't generate keys without a spec");var n=[],r=function(e){return e.join(",")+","},i=null;if((0,f["default"])(this._sortSpecParts,function(t,o){var a=(0,O.expandArraysInBranches)(t.lookup(e),!0);a.length||(a=[{value:null}]);var u=!1;if(n[o]={},(0,f["default"])(a,function(e){if(!e.arrayIndices){if(a.length>1)throw Error("multiple branches but no array used?");return void(n[o][""]=e.value)}u=!0;var t=r(e.arrayIndices);if((0,l["default"])(n[o],t))throw Error("duplicate path: "+t);if(n[o][t]=e.value,i&&!(0,l["default"])(i,t))throw Error("cannot index parallel arrays")}),i){if(!(0,l["default"])(n[o],"")&&(0,g["default"])(i)!==(0,g["default"])(n[o]))throw Error("cannot index parallel arrays!")}else u&&(i={},(0,f["default"])(n[o],function(e,t){i[t]=!0}))}),!i){var o=(0,b["default"])(n,function(e){if(!(0,l["default"])(e,""))throw Error("no value in sole key case?");return e[""]});return void t(o)}(0,f["default"])(i,function(e,r){var i=(0,b["default"])(n,function(e){if((0,l["default"])(e,""))return e[""];if(!(0,l["default"])(e,r))throw Error("missing path?");return e[r]});t(i)})}},{key:"_compareKeys",value:function(e,t){if(e.length!==this._sortSpecParts.length||t.length!==this._sortSpecParts.length)throw Error("Key has wrong length");return this._keyComparator(e,t)}},{key:"_keyFieldComparator",value:function(e){var t=!this._sortSpecParts[e].ascending;return function(n,r){var i=k.MongoTypeComp._cmp(n[e],r[e]);return t&&(i=-i),i}}},{key:"_getBaseComparator",value:function(){var e=this;return this._sortSpecParts.length?function(t,n){var r=e._getMinKeyFromDoc(t),i=e._getMinKeyFromDoc(n);return e._compareKeys(r,i)}:function(e,t){return 0}}},{key:"_useWithMatcher",value:function(e){if(this._keyFilter)throw Error("called _useWithMatcher twice?");if(!(0,u["default"])(this._sortSpecParts)){var t=e._selector;if(!(t instanceof Function)){var n={};(0,f["default"])(this._sortSpecParts,function(e,t){n[e.path]=[]}),(0,f["default"])(t,function(e,t){var r=n[t];if(r){if(e instanceof RegExp){if(e.ignoreCase||e.multiline)return;return void r.push((0,O.regexpElementMatcher)(e))}return(0,k.isOperatorObject)(e)?void(0,f["default"])(e,function(t,n){(0,h["default"])(["$lt","$lte","$gt","$gte"],n)&&r.push(O.ELEMENT_OPERATORS[n].compileElementSelector(t)),"$regex"!==n||e.$options||r.push(O.ELEMENT_OPERATORS.$regex.compileElementSelector(t,e))}):void r.push((0,O.equalityElementMatcher)(e))}}),(0,u["default"])(n[this._sortSpecParts[0].path])||(this._keyFilter=function(e){return(0,y["default"])(this._sortSpecParts,function(t,r){return(0,y["default"])(n[t.path],function(t){return t(e[r])})})})}}}}]),e}();n.DocumentSorter=j,n["default"]=j;var E=function(e){return function(t,n){for(var r=0;r=u.length?!1:o!==u[r]?!1:i.equals(e[o],t[u[r]],n)?(r++,!0):!1}),a&&r===u.length}return r=0,a=(0,m["default"])(e).every(function(o){return(0,v["default"])(t,o)&&i.equals(e[o],t[o],n)?(r++,!0):!1}),a&&(0,m["default"])(t).length===r}},{key:"clone",value:function(e){var t,n=this;if("object"!=typeof e)return e;if(null===e)return null;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return e;if(this.isBinary(e)){t=s["default"].newBinary(e.length);for(var r=0;r2?!1:e._builtinConverters.some(function(e){return e.matchJSONValue(t)})},toJSONValue:function(t){var n={};return(0,_["default"])(t,function(t,r){n[r]=e.toJSONValue(t)}),{$escape:n}},fromJSONValue:function(t){var n={};return(0,_["default"])(t.$escape,function(t,r){n[r]=e.fromJSONValue(t)}),n}},{matchJSONValue:function(e){return(0,v["default"])(e,"$type")&&(0,v["default"])(e,"$value")&&2===(0,m["default"])(e).length},matchObject:function(t){return e._isCustomType(t)},toJSONValue:function(e){var t=e.toJSONValue();return{$type:e.typeName(),$value:t}},fromJSONValue:function(t){var n=t.$type;if(!(0,v["default"])(e._customTypes,n))throw new Error("Custom EJSON type "+n+" is not defined");var r=e._customTypes[n];return r(t.$value)}}]}},{key:"_isCustomType",value:function(e){return e&&"function"==typeof e.toJSONValue&&"function"==typeof e.typeName&&(0,v["default"])(this._customTypes,e.typeName())}},{key:"_adjustTypesToJSONValue",value:function(e){var t=this;if(null===e)return null;var n=this._toJSONValueHelper(e);return void 0!==n?n:"object"!=typeof e?e:((0,_["default"])(e,function(n,r){if("object"==typeof n||void 0===n||o(n)){var i=t._toJSONValueHelper(n);return i?void(e[r]=i):void t._adjustTypesToJSONValue(n)}}),e)}},{key:"_toJSONValueHelper",value:function(e){for(var t=0;t>>0,r-=e,r*=e,e=r>>>0,r-=e,e+=4294967296*r}return 2.3283064365386963e-10*(e>>>0)};return t.version="Mash 0.9",t}return function(t){var n=0,r=0,i=0,o=1;0==t.length&&(t=[+new Date]);var a=e();n=a(" "),r=a(" "),i=a(" ");for(var u=0;un&&(n+=1),r-=a(t[u]),0>r&&(r+=1),i-=a(t[u]),0>i&&(i+=1);a=null;var s=function(){var e=2091639*n+2.3283064365386963e-10*o;return n=r,r=i,i=e-(o=0|e)};return s.uint32=function(){return 4294967296*s()},s.fract53=function(){return s()+1.1102230246251565e-16*(2097152*s()|0)},s.version="Alea 0.9",s.args=t,s}(Array.prototype.slice.call(arguments))},a="23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz",u="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_",s=function(){function e(){r(this,e);var t=arguments[0];if(!(void 0!==t||"undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues)){var n="undefined"!=typeof window&&window.innerHeight||"undefined"!=typeof document&&document.documentElement&&document.documentElement.clientHeight||"undefined"!=typeof document&&document.body&&document.body.clientHeight||1,i="undefined"!=typeof window&&window.innerWidth||"undefined"!=typeof document&&document.documentElement&&document.documentElement.clientWidth||"undefined"!=typeof document&&document.body&&document.body.clientWidth||1,a="undefined"!=typeof navigator&&navigator.userAgent||"";t=[new Date,n,i,a,Math.random()]}void 0!==t&&(this.alea=o.apply(null,t))}return i(e,[{key:"fraction",value:function(){var e=this;if(e.alea)return e.alea();if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues){var t=new Uint32Array(1);return window.crypto.getRandomValues(t),2.3283064365386963e-10*t[0]}throw new Error("No random generator available")}},{key:"hexString",value:function(e){for(var t=this,n=[],r=0;e>r;++r)n.push(t.choice("0123456789abcdef"));return n.join("")}},{key:"_randomString",value:function(e,t){for(var n=this,r=[],i=0;e>i;i++)r[i]=n.choice(t);return r.join("")}},{key:"id",value:function(e){var t=this;return void 0===e&&(e=17),t._randomString(e,a)}},{key:"secret",value:function(e){var t=this;return void 0===e&&(e=43),t._randomString(e,u)}},{key:"choice",value:function(e){var t=Math.floor(this.fraction()*e.length);return"string"==typeof e?e.substr(t,1):e[t]}}],[{key:"createWithSeed",value:function(){if(0===arguments.length)throw new Error("No seeds were provided");return new e(arguments)}}]),e}();n.Random=s,n["default"]=s},{}],15:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n=0&&e.length%1===0}function f(e,t){return c(e)?d(e,t):v(e,t)}function d(e,t){for(var n=-1,r=e.length;++nr?r:null}):(n=V(e),t=n.length,function(){return r++,t>r?n[r]:null})}function b(e,t){return t=null==t?e.length-1:+t,function(){for(var n=Math.max(arguments.length-t,0),r=Array(n),i=0;n>i;i++)r[i]=arguments[i+t];switch(t){case 0:return e.call(this,r);case 1:return e.call(this,arguments[0],r)}}}function _(e){return function(t,n,r){return e(t,r)}}function w(e){return function(t,n,r){r=l(r||i),t=t||[];var o=m(t);if(0>=e)return r(null);var a=!1,u=0,c=!1;!function f(){if(a&&0>=u)return r(null);for(;e>u&&!c;){var i=o();if(null===i)return a=!0,void(0>=u&&r(null));u+=1,n(t[i],i,s(function(e){u-=1,e?(r(e),c=!0):f()}))}}()}}function O(e){return function(t,n,r){return e(J.eachOf,t,n,r)}}function x(e){return function(t,n,r,i){return e(w(n),t,r,i)}}function k(e){return function(t,n,r){return e(J.eachOfSeries,t,n,r)}}function j(e,t,n,r){r=l(r||i);var o=[];e(t,function(e,t,r){n(e,function(e,n){o[t]=n,r(e)})},function(e){r(e,o)})}function E(e,t,n,r){var i=[];e(t,function(e,t,r){n(e,function(n){n&&i.push({index:t,value:e}),r()})},function(){r(h(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})}function A(e,t,n,r){E(e,t,function(e,t){n(e,function(e){t(!e)})},r)}function S(e,t,n){return function(r,i,o,a){function u(){a&&a(n(!1,void 0))}function s(e,r,i){return a?void o(e,function(r){a&&t(r)&&(a(n(!0,e)),a=o=!1),i()}):i()}arguments.length>3?e(r,i,s,u):(a=o,o=i,e(r,s,u))}}function M(e,t){return t}function P(e,t,n){n=n||i;var r=c(t)?[]:{};e(t,function(e,t,n){e(b(function(e,i){i.length<=1&&(i=i[0]),r[t]=i,n(e)}))},function(e){n(e,r)})}function $(e,t,n,r){var i=[];e(t,function(e,t,r){n(e,function(e,t){i=i.concat(t||[]),r(e)})},function(e){r(e,i)})}function I(e,t,n){function r(e,t,n,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");return e.started=!0,B(t)||(t=[t]),0===t.length&&e.idle()?J.setImmediate(function(){e.drain()}):(d(t,function(t){var o={data:t,callback:r||i};n?e.tasks.unshift(o):e.tasks.push(o),e.tasks.length===e.concurrency&&e.saturated()}),void J.setImmediate(e.process))}function o(e,t){return function(){a-=1;var n=arguments;d(t,function(e){e.callback.apply(e,n)}),e.tasks.length+a===0&&e.drain(),e.process()}}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var a=0,u={tasks:[],concurrency:t,payload:n,saturated:i,empty:i,drain:i,started:!1,paused:!1,push:function(e,t){r(u,e,!1,t)},kill:function(){u.drain=i,u.tasks=[]},unshift:function(e,t){r(u,e,!0,t)},process:function(){if(!u.paused&&a=t;t++)J.setImmediate(u.process)}}};return u}function N(e){return b(function(t,n){t.apply(null,n.concat([b(function(t,n){"object"==typeof console&&(t?console.error&&console.error(t):console[e]&&d(n,function(t){console[e](t)}))})]))})}function C(e){return function(t,n,r){e(p(t),n,r)}}function T(e){return b(function(t,n){var r=b(function(n){var r=this,i=n.pop();return e(t,function(e,t,i){e.apply(r,n.concat([i]))},i)});return n.length?r.apply(this,n):r})}function L(e){return b(function(t){var n=t.pop();t.push(function(){var e=arguments;r?J.setImmediate(function(){n.apply(null,e)}):n.apply(null,e)});var r=!0;e.apply(this,t),r=!1})}var D,J={},q="object"==typeof self&&self.self===self&&self||"object"==typeof r&&r.global===r&&r||this;null!=q&&(D=q.async),J.noConflict=function(){return q.async=D,J};var R=Object.prototype.toString,B=Array.isArray||function(e){return"[object Array]"===R.call(e)},F=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},V=Object.keys||function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},U="function"==typeof setImmediate&&setImmediate,W=U?function(e){U(e)}:function(e){setTimeout(e,0)};"object"==typeof t&&"function"==typeof t.nextTick?J.nextTick=t.nextTick:J.nextTick=W,J.setImmediate=U?W:J.nextTick,J.forEach=J.each=function(e,t,n){return J.eachOf(e,_(t),n)},J.forEachSeries=J.eachSeries=function(e,t,n){return J.eachOfSeries(e,_(t),n)},J.forEachLimit=J.eachLimit=function(e,t,n,r){return w(t)(e,_(n),r)},J.forEachOf=J.eachOf=function(e,t,n){function r(e){e?n(e):(a+=1,a>=o&&n(null))}n=l(n||i),e=e||[];var o=c(e)?e.length:V(e).length,a=0;return o?void f(e,function(n,i){t(e[i],i,s(r))}):n(null)},J.forEachOfSeries=J.eachOfSeries=function(e,t,n){function r(){var i=!0;return null===a?n(null):(t(e[a],a,s(function(e){if(e)n(e);else{if(a=o(),null===a)return n(null);i?J.nextTick(r):r()}})),void(i=!1))}n=l(n||i),e=e||[];var o=m(e),a=o();r()},J.forEachOfLimit=J.eachOfLimit=function(e,t,n,r){w(t)(e,n,r)},J.map=O(j),J.mapSeries=k(j),J.mapLimit=x(j),J.inject=J.foldl=J.reduce=function(e,t,n,r){J.eachOfSeries(e,function(e,r,i){n(t,e,function(e,n){t=n,i(e)})},function(e){r(e||null,t)})},J.foldr=J.reduceRight=function(e,t,n,r){var i=h(e,o).reverse();J.reduce(i,t,n,r)},J.select=J.filter=O(E),J.selectLimit=J.filterLimit=x(E),J.selectSeries=J.filterSeries=k(E),J.reject=O(A),J.rejectLimit=x(A),J.rejectSeries=k(A),J.any=J.some=S(J.eachOf,a,o),J.someLimit=S(J.eachOfLimit,a,o),J.all=J.every=S(J.eachOf,u,u),J.everyLimit=S(J.eachOfLimit,u,u),J.detect=S(J.eachOf,o,M),J.detectSeries=S(J.eachOfSeries,o,M),J.detectLimit=S(J.eachOfLimit,o,M),J.sortBy=function(e,t,n){function r(e,t){var n=e.criteria,r=t.criteria;return r>n?-1:n>r?1:0}J.map(e,function(e,n){t(e,function(t,r){t?n(t):n(null,{value:e,criteria:r})})},function(e,t){return e?n(e):void n(null,h(t.sort(r),function(e){return e.value}))})},J.auto=function(e,t){function n(e){c.unshift(e)}function r(e){var t=g(c,e);t>=0&&c.splice(t,1)}function o(){u--,d(c.slice(0),function(e){e()})}t=l(t||i);var a=V(e),u=a.length;if(!u)return t(null);var s={},c=[];n(function(){u||t(null,s)}),d(a,function(i){function a(){return y(d,function(e,t){return e&&s.hasOwnProperty(t)},!0)&&!s.hasOwnProperty(i)}function u(){a()&&(r(u),c[c.length-1](f,s))}for(var l,c=B(e[i])?e[i]:[e[i]],f=b(function(e,n){if(n.length<=1&&(n=n[0]),e){var r={};v(s,function(e,t){r[t]=e}),r[i]=n,t(e,r)}else s[i]=n,J.setImmediate(o)}),d=c.slice(0,c.length-1),h=d.length;h--;){if(!(l=e[d[h]]))throw new Error("Has inexistant dependency");if(B(l)&&g(l,i)>=0)throw new Error("Has cyclic dependencies")}a()?c[c.length-1](f,s):n(u)})},J.retry=function(e,t,n){function r(e,t){if("number"==typeof t)e.times=parseInt(t,10)||o;else{if("object"!=typeof t)throw new Error("Unsupported argument type for 'times': "+typeof t);e.times=parseInt(t.times,10)||o,e.interval=parseInt(t.interval,10)||a}}function i(e,t){function n(e,n){return function(r){e(function(e,t){r(!e||n,{err:e,result:t})},t)}}function r(e){return function(t){setTimeout(function(){t(null)},e)}}for(;s.times;){var i=!(s.times-=1);u.push(n(s.task,i)),!i&&s.interval>0&&u.push(r(s.interval))}J.series(u,function(t,n){n=n[n.length-1],(e||s.callback)(n.err,n.result)})}var o=5,a=0,u=[],s={times:o,interval:a},l=arguments.length;if(1>l||l>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=l&&"function"==typeof e&&(n=t,t=e),"function"!=typeof e&&r(s,e),s.callback=n,s.task=t,s.callback?i():i},J.waterfall=function(e,t){function n(e){return b(function(r,i){if(r)t.apply(null,[r].concat(i));else{var o=e.next();o?i.push(n(o)):i.push(t),L(e).apply(null,i)}})}if(t=l(t||i),!B(e)){var r=new Error("First argument to waterfall must be an array of functions");return t(r)}return e.length?void n(J.iterator(e))():t()},J.parallel=function(e,t){P(J.eachOf,e,t)},J.parallelLimit=function(e,t,n){P(w(t),e,n)},J.series=function(e,t){P(J.eachOfSeries,e,t)},J.iterator=function(e){function t(n){function r(){return e.length&&e[n].apply(null,arguments),r.next()}return r.next=function(){return nr;){var o=r+(i-r+1>>>1);n(t,e[o])>=0?r=o:i=o-1}return r}function o(e,t,o,a){if(null!=a&&"function"!=typeof a)throw new Error("task callback must be a function");return e.started=!0,B(t)||(t=[t]),0===t.length?J.setImmediate(function(){e.drain()}):void d(t,function(t){var u={data:t,priority:o,callback:"function"==typeof a?a:i};e.tasks.splice(r(e.tasks,u,n)+1,0,u),e.tasks.length===e.concurrency&&e.saturated(),J.setImmediate(e.process)})}var a=J.queue(e,t);return a.push=function(e,t,n){o(a,e,t,n)},delete a.unshift,a},J.cargo=function(e,t){return I(e,1,t)},J.log=N("log"),J.dir=N("dir"),J.memoize=function(e,t){var n={},r={};t=t||o;var i=b(function(i){var o=i.pop(),a=t.apply(null,i);a in n?J.nextTick(function(){o.apply(null,n[a])}):a in r?r[a].push(o):(r[a]=[o],e.apply(null,i.concat([b(function(e){n[a]=e;var t=r[a];delete r[a];for(var i=0,o=t.length;o>i;i++)t[i].apply(null,e)})])))});return i.memo=n,i.unmemoized=e,i},J.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},J.times=C(J.map),J.timesSeries=C(J.mapSeries),J.timesLimit=function(e,t,n,r){return J.mapLimit(p(e),t,n,r)},J.seq=function(){var e=arguments;return b(function(t){var n=this,r=t[t.length-1];"function"==typeof r?t.pop():r=i,J.reduce(e,t,function(e,t,r){t.apply(n,e.concat([b(function(e,t){r(e,t)})]))},function(e,t){r.apply(n,[e].concat(t))})})},J.compose=function(){return J.seq.apply(null,Array.prototype.reverse.call(arguments))},J.applyEach=T(J.eachOf),J.applyEachSeries=T(J.eachOfSeries),J.forever=function(e,t){function n(e){return e?r(e):void o(n)}var r=s(t||i),o=L(e);n()},J.ensureAsync=L,J.constant=b(function(e){var t=[null].concat(e);return function(e){return e.apply(this,t)}}),J.wrapSync=J.asyncify=function(e){return b(function(t){var n,r=t.pop();try{n=e.apply(this,t)}catch(i){return r(i)}F(n)&&"function"==typeof n.then?n.then(function(e){r(null,e)})["catch"](function(e){r(e.message?e:new Error(e))}):r(null,n)})},"object"==typeof n&&n.exports?n.exports=J:"function"==typeof e&&e.amd?e([],function(){return J}):q.async=J}()}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:18}],18:[function(e,t,n){function r(){c=!1,u.length?l=u.concat(l):f=-1,l.length&&i()}function i(){if(!c){var e=setTimeout(r);c=!0;for(var t=l.length;t;){for(u=l,l=[];++f1)for(var n=1;ni;i++)u[i]=r[i].fn;return u},i.prototype.emit=function(e,t,n,r,i,a){var u=o?o+e:e;if(!this._events||!this._events[u])return!1;var s,l,c=this._events[u],f=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,i),!0;case 6:return c.fn.call(c.context,t,n,r,i,a),!0}for(l=1,s=new Array(f-1);f>l;l++)s[l-1]=arguments[l];c.fn.apply(c.context,s)}else{var d,h=c.length;for(l=0;h>l;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;default:if(!s)for(d=1,s=new Array(f-1);f>d;d++)s[d-1]=arguments[d];c[l].fn.apply(c[l].context,s)}}return!0},i.prototype.on=function(e,t,n){var i=new r(t,n||this),a=o?o+e:e;return this._events||(this._events=o?{}:Object.create(null)),this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],i]:this._events[a].push(i):this._events[a]=i,this},i.prototype.once=function(e,t,n){var i=new r(t,n||this,!0),a=o?o+e:e;return this._events||(this._events=o?{}:Object.create(null)),this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],i]:this._events[a].push(i):this._events[a]=i,this},i.prototype.removeListener=function(e,t,n,r){var i=o?o+e:e;if(!this._events||!this._events[i])return this;var a=this._events[i],u=[];if(t)if(a.fn)(a.fn!==t||r&&!a.once||n&&a.context!==n)&&u.push(a);else for(var s=0,l=a.length;l>s;s++)(a[s].fn!==t||r&&!a[s].once||n&&a[s].context!==n)&&u.push(a[s]);return u.length?this._events[i]=1===u.length?u[0]:u:delete this._events[i],this},i.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[o?o+e:e]:this._events=o?{}:Object.create(null),this):this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prototype.setMaxListeners=function(){return this},i.prefixed=o,"undefined"!=typeof t&&(t.exports=i)},{}],20:[function(e,t,n){!function(){function e(e){for(var t=[],n=[],r=0;rt!=r[o][0]>t&&e<(r[o][1]-r[i][1])*(t-r[i][0])/(r[o][0]-r[i][0])+r[i][1]&&(a=!a);return a}var r=this.gju={};"undefined"!=typeof t&&t.exports&&(t.exports=r),r.lineStringsIntersect=function(e,t){for(var n=[],r=0;r<=e.coordinates.length-2;++r)for(var i=0;i<=t.coordinates.length-2;++i){var o={x:e.coordinates[r][1],y:e.coordinates[r][0]},a={x:e.coordinates[r+1][1],y:e.coordinates[r+1][0]},u={x:t.coordinates[i][1],y:t.coordinates[i][0]},s={x:t.coordinates[i+1][1],y:t.coordinates[i+1][0]},l=(s.x-u.x)*(o.y-u.y)-(s.y-u.y)*(o.x-u.x),c=(a.x-o.x)*(o.y-u.y)-(a.y-o.y)*(o.x-u.x),f=(s.y-u.y)*(a.x-o.x)-(s.x-u.x)*(a.y-o.y);if(0!=f){var d=l/f,h=c/f;d>=0&&1>=d&&h>=0&&1>=h&&n.push({type:"Point",coordinates:[o.x+d*(a.x-o.x),o.y+d*(a.y-o.y)]})}}return 0==n.length&&(n=!1),n},r.pointInBoundingBox=function(e,t){return!(e.coordinates[1]t[1][0]||e.coordinates[0]t[1][1])},r.pointInPolygon=function(t,i){for(var o="Polygon"==i.type?[i.coordinates]:i.coordinates,a=!1,u=0;us;s++){var l=2*Math.PI*s/n,c=Math.asin(Math.sin(a[0])*Math.cos(o)+Math.cos(a[0])*Math.sin(o)*Math.cos(l)),f=a[1]+Math.atan2(Math.sin(l)*Math.sin(o)*Math.cos(a[0]),Math.cos(o)-Math.sin(a[0])*Math.sin(c));u[s]=[],u[s][1]=r.numberToDegree(c),u[s][0]=r.numberToDegree(f)}return{type:"Polygon",coordinates:[u]}},r.rectangleCentroid=function(e){var t=e.coordinates[0],n=t[0][0],r=t[0][1],i=t[2][0],o=t[2][1],a=i-n,u=o-r;return{type:"Point",coordinates:[n+a/2,r+u/2]}},r.pointDistance=function(e,t){var n=e.coordinates[0],i=e.coordinates[1],o=t.coordinates[0],a=t.coordinates[1],u=r.numberToRadius(a-i),s=r.numberToRadius(o-n),l=Math.pow(Math.sin(u/2),2)+Math.cos(r.numberToRadius(i))*Math.cos(r.numberToRadius(a))*Math.pow(Math.sin(s/2),2),c=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l));return 6371*c*1e3},r.geometryWithinRadius=function(e,t,n){if("Point"==e.type)return r.pointDistance(e,t)<=n;if("LineString"==e.type||"Polygon"==e.type){var i,o={};i="Polygon"==e.type?e.coordinates[0]:e.coordinates;for(var a in i)if(o.coordinates=i[a],r.pointDistance(o,t)>n)return!1}return!0},r.area=function(e){for(var t,n,r=0,i=e.coordinates[0],o=i.length-1,a=0;a0;)if(o=x[r-1],a=k[r-1],r--,a-o>1){for(d=e[a].lng()-e[o].lng(),h=e[a].lat()-e[o].lat(),Math.abs(d)>180&&(d=360-Math.abs(d)),d*=Math.cos(w*(e[a].lat()+e[o].lat())),p=d*d+h*h,u=o+1,s=o,c=-1;a>u;u++)y=e[u].lng()-e[o].lng(),v=e[u].lat()-e[o].lat(),Math.abs(y)>180&&(y=360-Math.abs(y)),y*=Math.cos(w*(e[u].lat()+e[o].lat())),g=y*y+v*v,m=e[u].lng()-e[a].lng(),b=e[u].lat()-e[a].lat(),Math.abs(m)>180&&(m=360-Math.abs(m)),m*=Math.cos(w*(e[u].lat()+e[a].lat())),_=m*m+b*b,l=g>=p+_?_:_>=p+g?g:(y*h-v*d)*(y*h-v*d)/p,l>c&&(s=u,c=l);f>c?(O[i]=o,i++):(r++,x[r-1]=s,k[r-1]=a,r++,x[r-1]=o,k[r-1]=s)}else O[i]=o,i++;O[i]=n-1,i++;for(var j=new Array,u=0;i>u;u++)j.push(e[O[u]]);return j.map(function(e){return{type:"Point",coordinates:[e.lng,e.lat]}})},r.destinationPoint=function(e,t,n){n/=6371,t=r.numberToRadius(t);var i=r.numberToRadius(e.coordinates[0]),o=r.numberToRadius(e.coordinates[1]),a=Math.asin(Math.sin(o)*Math.cos(n)+Math.cos(o)*Math.sin(n)*Math.cos(t)),u=i+Math.atan2(Math.sin(t)*Math.sin(n)*Math.cos(o),Math.cos(n)-Math.sin(o)*Math.sin(a));return u=(u+3*Math.PI)%(2*Math.PI)-Math.PI,{type:"Point",coordinates:[r.numberToDegree(u),r.numberToDegree(a)]}}}()},{}],21:[function(e,t,n){"use strict";var r=function(e,t,n,r,i,o,a,u){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,r,i,o,a,u],c=0;s=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return l[c++]}))}throw s.framesToPop=1,s}};t.exports=r},{}],22:[function(e,t,n){"use strict";var r=function(e){var t,n={};if(!(e instanceof Object)||Array.isArray(e))throw new Error("keyMirror(...): Argument must be an object.");for(t in e)e.hasOwnProperty(t)&&(n[t]=t);return n};t.exports=r},{}],23:[function(e,t,n){function r(e){var t=e?e.length:0;return t?e[t-1]:void 0}t.exports=r},{}],24:[function(e,t,n){t.exports=e("./every")},{"./every":28}],25:[function(e,t,n){t.exports=e("./some")},{"./some":34}],26:[function(e,t,n){t.exports=e("./includes")},{"./includes":30}],27:[function(e,t,n){t.exports=e("./forEach")},{"./forEach":29}],28:[function(e,t,n){function r(e,t,n){var r=u(e)?i:a;return n&&s(e,t,n)&&(t=void 0),("function"!=typeof t||void 0!==n)&&(t=o(t,n,3)),r(e,t)}var i=e("../internal/arrayEvery"),o=e("../internal/baseCallback"),a=e("../internal/baseEvery"),u=e("../lang/isArray"),s=e("../internal/isIterateeCall");t.exports=r},{"../internal/arrayEvery":39,"../internal/baseCallback":44,"../internal/baseEvery":48,"../internal/isIterateeCall":79,"../lang/isArray":88}],29:[function(e,t,n){var r=e("../internal/arrayEach"),i=e("../internal/baseEach"),o=e("../internal/createForEach"),a=o(r,i);t.exports=a},{"../internal/arrayEach":38,"../internal/baseEach":47,"../internal/createForEach":69}],30:[function(e,t,n){function r(e,t,n,r){var d=e?o(e):0;return s(d)||(e=c(e),d=e.length),n="number"!=typeof n||r&&u(t,n,r)?0:0>n?f(d+n,0):n||0,"string"==typeof e||!a(e)&&l(e)?d>=n&&e.indexOf(t,n)>-1:!!d&&i(e,t,n)>-1}var i=e("../internal/baseIndexOf"),o=e("../internal/getLength"),a=e("../lang/isArray"),u=e("../internal/isIterateeCall"),s=e("../internal/isLength"),l=e("../lang/isString"),c=e("../object/values"),f=Math.max;t.exports=r},{"../internal/baseIndexOf":52,"../internal/getLength":73,"../internal/isIterateeCall":79,"../internal/isLength":81,"../lang/isArray":88,"../lang/isString":96,"../object/values":104}],31:[function(e,t,n){function r(e,t,n){var r=u(e)?i:a;return t=o(t,n,3),r(e,t)}var i=e("../internal/arrayMap"),o=e("../internal/baseCallback"),a=e("../internal/baseMap"),u=e("../lang/isArray");t.exports=r},{"../internal/arrayMap":40,"../internal/baseCallback":44,"../internal/baseMap":56,"../lang/isArray":88}],32:[function(e,t,n){function r(e,t){return i(e,o(t))}var i=e("./map"),o=e("../utility/property");t.exports=r},{"../utility/property":106,"./map":31}],33:[function(e,t,n){function r(e){var t=e?i(e):0;return o(t)?t:a(e).length}var i=e("../internal/getLength"),o=e("../internal/isLength"),a=e("../object/keys");t.exports=r},{"../internal/getLength":73,"../internal/isLength":81,"../object/keys":101}],34:[function(e,t,n){function r(e,t,n){var r=u(e)?i:a;return n&&s(e,t,n)&&(t=void 0),("function"!=typeof t||void 0!==n)&&(t=o(t,n,3)),r(e,t)}var i=e("../internal/arraySome"),o=e("../internal/baseCallback"),a=e("../internal/baseSome"),u=e("../lang/isArray"),s=e("../internal/isIterateeCall");t.exports=r},{"../internal/arraySome":41,"../internal/baseCallback":44,"../internal/baseSome":62,"../internal/isIterateeCall":79,"../lang/isArray":88}],35:[function(e,t,n){var r=e("../internal/baseDelay"),i=e("./restParam"),o=i(function(e,t){return r(e,1,t)});t.exports=o},{"../internal/baseDelay":46,"./restParam":36}],36:[function(e,t,n){function r(e,t){if("function"!=typeof e)throw new TypeError(i);return t=o(void 0===t?e.length-1:+t||0,0),function(){for(var n=arguments,r=-1,i=o(n.length-t,0),a=Array(i);++rr;)e=e[t[r++]];return r&&r==o?e:void 0}}var i=e("./toObject");t.exports=r},{"./toObject":85}],52:[function(e,t,n){function r(e,t,n){if(t!==t)return i(e,n);for(var r=n-1,o=e.length;++rt&&(t=-t>i?0:i+t),n=void 0===n||n>i?i:+n||0,0>n&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r2?n[a-2]:void 0,s=a>2?n[2]:void 0,l=a>1?n[a-1]:void 0; +"lodash/function/defer":35,"lodash/object/keys":101}],16:[function(e,t,n){"use strict";var r=e("./dist/Collection")["default"],i=e("./dist/CursorObservable")["default"],o=e("./dist/StorageManager")["default"],a=e("./dist/Random")["default"],u=e("./dist/EJSON")["default"],s=e("./dist/Base64")["default"];t.exports={__esModule:!0,"default":r,Random:a,EJSON:u,Base64:s,Collection:r,CursorObservable:i,StorageManager:o}},{"./dist/Base64":1,"./dist/Collection":2,"./dist/CursorObservable":5,"./dist/EJSON":11,"./dist/Random":14,"./dist/StorageManager":15}],17:[function(t,n,r){(function(t,r){!function(){function i(){}function o(e){return e}function a(e){return!!e}function u(e){return!e}function s(e){return function(){if(null===e)throw new Error("Callback was already called.");e.apply(this,arguments),e=null}}function l(e){return function(){null!==e&&(e.apply(this,arguments),e=null)}}function c(e){return B(e)||"number"==typeof e.length&&e.length>=0&&e.length%1===0}function f(e,t){return c(e)?d(e,t):v(e,t)}function d(e,t){for(var n=-1,r=e.length;++nr?r:null}):(n=V(e),t=n.length,function(){return r++,t>r?n[r]:null})}function b(e,t){return t=null==t?e.length-1:+t,function(){for(var n=Math.max(arguments.length-t,0),r=Array(n),i=0;n>i;i++)r[i]=arguments[i+t];switch(t){case 0:return e.call(this,r);case 1:return e.call(this,arguments[0],r)}}}function _(e){return function(t,n,r){return e(t,r)}}function w(e){return function(t,n,r){r=l(r||i),t=t||[];var o=m(t);if(0>=e)return r(null);var a=!1,u=0,c=!1;!function f(){if(a&&0>=u)return r(null);for(;e>u&&!c;){var i=o();if(null===i)return a=!0,void(0>=u&&r(null));u+=1,n(t[i],i,s(function(e){u-=1,e?(r(e),c=!0):f()}))}}()}}function O(e){return function(t,n,r){return e(J.eachOf,t,n,r)}}function x(e){return function(t,n,r,i){return e(w(n),t,r,i)}}function k(e){return function(t,n,r){return e(J.eachOfSeries,t,n,r)}}function j(e,t,n,r){r=l(r||i);var o=[];e(t,function(e,t,r){n(e,function(e,n){o[t]=n,r(e)})},function(e){r(e,o)})}function E(e,t,n,r){var i=[];e(t,function(e,t,r){n(e,function(n){n&&i.push({index:t,value:e}),r()})},function(){r(h(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})}function A(e,t,n,r){E(e,t,function(e,t){n(e,function(e){t(!e)})},r)}function S(e,t,n){return function(r,i,o,a){function u(){a&&a(n(!1,void 0))}function s(e,r,i){return a?void o(e,function(r){a&&t(r)&&(a(n(!0,e)),a=o=!1),i()}):i()}arguments.length>3?e(r,i,s,u):(a=o,o=i,e(r,s,u))}}function M(e,t){return t}function P(e,t,n){n=n||i;var r=c(t)?[]:{};e(t,function(e,t,n){e(b(function(e,i){i.length<=1&&(i=i[0]),r[t]=i,n(e)}))},function(e){n(e,r)})}function $(e,t,n,r){var i=[];e(t,function(e,t,r){n(e,function(e,t){i=i.concat(t||[]),r(e)})},function(e){r(e,i)})}function I(e,t,n){function r(e,t,n,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");return e.started=!0,B(t)||(t=[t]),0===t.length&&e.idle()?J.setImmediate(function(){e.drain()}):(d(t,function(t){var o={data:t,callback:r||i};n?e.tasks.unshift(o):e.tasks.push(o),e.tasks.length===e.concurrency&&e.saturated()}),void J.setImmediate(e.process))}function o(e,t){return function(){a-=1;var n=arguments;d(t,function(e){e.callback.apply(e,n)}),e.tasks.length+a===0&&e.drain(),e.process()}}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var a=0,u={tasks:[],concurrency:t,payload:n,saturated:i,empty:i,drain:i,started:!1,paused:!1,push:function(e,t){r(u,e,!1,t)},kill:function(){u.drain=i,u.tasks=[]},unshift:function(e,t){r(u,e,!0,t)},process:function(){if(!u.paused&&a=t;t++)J.setImmediate(u.process)}}};return u}function N(e){return b(function(t,n){t.apply(null,n.concat([b(function(t,n){"object"==typeof console&&(t?console.error&&console.error(t):console[e]&&d(n,function(t){console[e](t)}))})]))})}function C(e){return function(t,n,r){e(p(t),n,r)}}function T(e){return b(function(t,n){var r=b(function(n){var r=this,i=n.pop();return e(t,function(e,t,i){e.apply(r,n.concat([i]))},i)});return n.length?r.apply(this,n):r})}function L(e){return b(function(t){var n=t.pop();t.push(function(){var e=arguments;r?J.setImmediate(function(){n.apply(null,e)}):n.apply(null,e)});var r=!0;e.apply(this,t),r=!1})}var D,J={},q="object"==typeof self&&self.self===self&&self||"object"==typeof r&&r.global===r&&r||this;null!=q&&(D=q.async),J.noConflict=function(){return q.async=D,J};var R=Object.prototype.toString,B=Array.isArray||function(e){return"[object Array]"===R.call(e)},F=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},V=Object.keys||function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},U="function"==typeof setImmediate&&setImmediate,W=U?function(e){U(e)}:function(e){setTimeout(e,0)};"object"==typeof t&&"function"==typeof t.nextTick?J.nextTick=t.nextTick:J.nextTick=W,J.setImmediate=U?W:J.nextTick,J.forEach=J.each=function(e,t,n){return J.eachOf(e,_(t),n)},J.forEachSeries=J.eachSeries=function(e,t,n){return J.eachOfSeries(e,_(t),n)},J.forEachLimit=J.eachLimit=function(e,t,n,r){return w(t)(e,_(n),r)},J.forEachOf=J.eachOf=function(e,t,n){function r(e){e?n(e):(a+=1,a>=o&&n(null))}n=l(n||i),e=e||[];var o=c(e)?e.length:V(e).length,a=0;return o?void f(e,function(n,i){t(e[i],i,s(r))}):n(null)},J.forEachOfSeries=J.eachOfSeries=function(e,t,n){function r(){var i=!0;return null===a?n(null):(t(e[a],a,s(function(e){if(e)n(e);else{if(a=o(),null===a)return n(null);i?J.nextTick(r):r()}})),void(i=!1))}n=l(n||i),e=e||[];var o=m(e),a=o();r()},J.forEachOfLimit=J.eachOfLimit=function(e,t,n,r){w(t)(e,n,r)},J.map=O(j),J.mapSeries=k(j),J.mapLimit=x(j),J.inject=J.foldl=J.reduce=function(e,t,n,r){J.eachOfSeries(e,function(e,r,i){n(t,e,function(e,n){t=n,i(e)})},function(e){r(e||null,t)})},J.foldr=J.reduceRight=function(e,t,n,r){var i=h(e,o).reverse();J.reduce(i,t,n,r)},J.select=J.filter=O(E),J.selectLimit=J.filterLimit=x(E),J.selectSeries=J.filterSeries=k(E),J.reject=O(A),J.rejectLimit=x(A),J.rejectSeries=k(A),J.any=J.some=S(J.eachOf,a,o),J.someLimit=S(J.eachOfLimit,a,o),J.all=J.every=S(J.eachOf,u,u),J.everyLimit=S(J.eachOfLimit,u,u),J.detect=S(J.eachOf,o,M),J.detectSeries=S(J.eachOfSeries,o,M),J.detectLimit=S(J.eachOfLimit,o,M),J.sortBy=function(e,t,n){function r(e,t){var n=e.criteria,r=t.criteria;return r>n?-1:n>r?1:0}J.map(e,function(e,n){t(e,function(t,r){t?n(t):n(null,{value:e,criteria:r})})},function(e,t){return e?n(e):void n(null,h(t.sort(r),function(e){return e.value}))})},J.auto=function(e,t){function n(e){c.unshift(e)}function r(e){var t=g(c,e);t>=0&&c.splice(t,1)}function o(){u--,d(c.slice(0),function(e){e()})}t=l(t||i);var a=V(e),u=a.length;if(!u)return t(null);var s={},c=[];n(function(){u||t(null,s)}),d(a,function(i){function a(){return y(d,function(e,t){return e&&s.hasOwnProperty(t)},!0)&&!s.hasOwnProperty(i)}function u(){a()&&(r(u),c[c.length-1](f,s))}for(var l,c=B(e[i])?e[i]:[e[i]],f=b(function(e,n){if(n.length<=1&&(n=n[0]),e){var r={};v(s,function(e,t){r[t]=e}),r[i]=n,t(e,r)}else s[i]=n,J.setImmediate(o)}),d=c.slice(0,c.length-1),h=d.length;h--;){if(!(l=e[d[h]]))throw new Error("Has inexistant dependency");if(B(l)&&g(l,i)>=0)throw new Error("Has cyclic dependencies")}a()?c[c.length-1](f,s):n(u)})},J.retry=function(e,t,n){function r(e,t){if("number"==typeof t)e.times=parseInt(t,10)||o;else{if("object"!=typeof t)throw new Error("Unsupported argument type for 'times': "+typeof t);e.times=parseInt(t.times,10)||o,e.interval=parseInt(t.interval,10)||a}}function i(e,t){function n(e,n){return function(r){e(function(e,t){r(!e||n,{err:e,result:t})},t)}}function r(e){return function(t){setTimeout(function(){t(null)},e)}}for(;s.times;){var i=!(s.times-=1);u.push(n(s.task,i)),!i&&s.interval>0&&u.push(r(s.interval))}J.series(u,function(t,n){n=n[n.length-1],(e||s.callback)(n.err,n.result)})}var o=5,a=0,u=[],s={times:o,interval:a},l=arguments.length;if(1>l||l>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=l&&"function"==typeof e&&(n=t,t=e),"function"!=typeof e&&r(s,e),s.callback=n,s.task=t,s.callback?i():i},J.waterfall=function(e,t){function n(e){return b(function(r,i){if(r)t.apply(null,[r].concat(i));else{var o=e.next();o?i.push(n(o)):i.push(t),L(e).apply(null,i)}})}if(t=l(t||i),!B(e)){var r=new Error("First argument to waterfall must be an array of functions");return t(r)}return e.length?void n(J.iterator(e))():t()},J.parallel=function(e,t){P(J.eachOf,e,t)},J.parallelLimit=function(e,t,n){P(w(t),e,n)},J.series=function(e,t){P(J.eachOfSeries,e,t)},J.iterator=function(e){function t(n){function r(){return e.length&&e[n].apply(null,arguments),r.next()}return r.next=function(){return nr;){var o=r+(i-r+1>>>1);n(t,e[o])>=0?r=o:i=o-1}return r}function o(e,t,o,a){if(null!=a&&"function"!=typeof a)throw new Error("task callback must be a function");return e.started=!0,B(t)||(t=[t]),0===t.length?J.setImmediate(function(){e.drain()}):void d(t,function(t){var u={data:t,priority:o,callback:"function"==typeof a?a:i};e.tasks.splice(r(e.tasks,u,n)+1,0,u),e.tasks.length===e.concurrency&&e.saturated(),J.setImmediate(e.process)})}var a=J.queue(e,t);return a.push=function(e,t,n){o(a,e,t,n)},delete a.unshift,a},J.cargo=function(e,t){return I(e,1,t)},J.log=N("log"),J.dir=N("dir"),J.memoize=function(e,t){var n={},r={};t=t||o;var i=b(function(i){var o=i.pop(),a=t.apply(null,i);a in n?J.nextTick(function(){o.apply(null,n[a])}):a in r?r[a].push(o):(r[a]=[o],e.apply(null,i.concat([b(function(e){n[a]=e;var t=r[a];delete r[a];for(var i=0,o=t.length;o>i;i++)t[i].apply(null,e)})])))});return i.memo=n,i.unmemoized=e,i},J.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},J.times=C(J.map),J.timesSeries=C(J.mapSeries),J.timesLimit=function(e,t,n,r){return J.mapLimit(p(e),t,n,r)},J.seq=function(){var e=arguments;return b(function(t){var n=this,r=t[t.length-1];"function"==typeof r?t.pop():r=i,J.reduce(e,t,function(e,t,r){t.apply(n,e.concat([b(function(e,t){r(e,t)})]))},function(e,t){r.apply(n,[e].concat(t))})})},J.compose=function(){return J.seq.apply(null,Array.prototype.reverse.call(arguments))},J.applyEach=T(J.eachOf),J.applyEachSeries=T(J.eachOfSeries),J.forever=function(e,t){function n(e){return e?r(e):void o(n)}var r=s(t||i),o=L(e);n()},J.ensureAsync=L,J.constant=b(function(e){var t=[null].concat(e);return function(e){return e.apply(this,t)}}),J.wrapSync=J.asyncify=function(e){return b(function(t){var n,r=t.pop();try{n=e.apply(this,t)}catch(i){return r(i)}F(n)&&"function"==typeof n.then?n.then(function(e){r(null,e)})["catch"](function(e){r(e.message?e:new Error(e))}):r(null,n)})},"object"==typeof n&&n.exports?n.exports=J:"function"==typeof e&&e.amd?e([],function(){return J}):q.async=J}()}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:18}],18:[function(e,t,n){function r(){c=!1,u.length?l=u.concat(l):f=-1,l.length&&i()}function i(){if(!c){var e=setTimeout(r);c=!0;for(var t=l.length;t;){for(u=l,l=[];++f1)for(var n=1;ni;i++)u[i]=r[i].fn;return u},i.prototype.emit=function(e,t,n,r,i,a){var u=o?o+e:e;if(!this._events||!this._events[u])return!1;var s,l,c=this._events[u],f=arguments.length;if("function"==typeof c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,i),!0;case 6:return c.fn.call(c.context,t,n,r,i,a),!0}for(l=1,s=new Array(f-1);f>l;l++)s[l-1]=arguments[l];c.fn.apply(c.context,s)}else{var d,h=c.length;for(l=0;h>l;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;default:if(!s)for(d=1,s=new Array(f-1);f>d;d++)s[d-1]=arguments[d];c[l].fn.apply(c[l].context,s)}}return!0},i.prototype.on=function(e,t,n){var i=new r(t,n||this),a=o?o+e:e;return this._events||(this._events=o?{}:Object.create(null)),this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],i]:this._events[a].push(i):this._events[a]=i,this},i.prototype.once=function(e,t,n){var i=new r(t,n||this,!0),a=o?o+e:e;return this._events||(this._events=o?{}:Object.create(null)),this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],i]:this._events[a].push(i):this._events[a]=i,this},i.prototype.removeListener=function(e,t,n,r){var i=o?o+e:e;if(!this._events||!this._events[i])return this;var a=this._events[i],u=[];if(t)if(a.fn)(a.fn!==t||r&&!a.once||n&&a.context!==n)&&u.push(a);else for(var s=0,l=a.length;l>s;s++)(a[s].fn!==t||r&&!a[s].once||n&&a[s].context!==n)&&u.push(a[s]);return u.length?this._events[i]=1===u.length?u[0]:u:delete this._events[i],this},i.prototype.removeAllListeners=function(e){return this._events?(e?delete this._events[o?o+e:e]:this._events=o?{}:Object.create(null),this):this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prototype.setMaxListeners=function(){return this},i.prefixed=o,"undefined"!=typeof t&&(t.exports=i)},{}],20:[function(e,t,n){!function(){function e(e){for(var t=[],n=[],r=0;rt!=r[o][0]>t&&e<(r[o][1]-r[i][1])*(t-r[i][0])/(r[o][0]-r[i][0])+r[i][1]&&(a=!a);return a}var r=this.gju={};"undefined"!=typeof t&&t.exports&&(t.exports=r),r.lineStringsIntersect=function(e,t){for(var n=[],r=0;r<=e.coordinates.length-2;++r)for(var i=0;i<=t.coordinates.length-2;++i){var o={x:e.coordinates[r][1],y:e.coordinates[r][0]},a={x:e.coordinates[r+1][1],y:e.coordinates[r+1][0]},u={x:t.coordinates[i][1],y:t.coordinates[i][0]},s={x:t.coordinates[i+1][1],y:t.coordinates[i+1][0]},l=(s.x-u.x)*(o.y-u.y)-(s.y-u.y)*(o.x-u.x),c=(a.x-o.x)*(o.y-u.y)-(a.y-o.y)*(o.x-u.x),f=(s.y-u.y)*(a.x-o.x)-(s.x-u.x)*(a.y-o.y);if(0!=f){var d=l/f,h=c/f;d>=0&&1>=d&&h>=0&&1>=h&&n.push({type:"Point",coordinates:[o.x+d*(a.x-o.x),o.y+d*(a.y-o.y)]})}}return 0==n.length&&(n=!1),n},r.pointInBoundingBox=function(e,t){return!(e.coordinates[1]t[1][0]||e.coordinates[0]t[1][1])},r.pointInPolygon=function(t,i){for(var o="Polygon"==i.type?[i.coordinates]:i.coordinates,a=!1,u=0;us;s++){var l=2*Math.PI*s/n,c=Math.asin(Math.sin(a[0])*Math.cos(o)+Math.cos(a[0])*Math.sin(o)*Math.cos(l)),f=a[1]+Math.atan2(Math.sin(l)*Math.sin(o)*Math.cos(a[0]),Math.cos(o)-Math.sin(a[0])*Math.sin(c));u[s]=[],u[s][1]=r.numberToDegree(c),u[s][0]=r.numberToDegree(f)}return{type:"Polygon",coordinates:[u]}},r.rectangleCentroid=function(e){var t=e.coordinates[0],n=t[0][0],r=t[0][1],i=t[2][0],o=t[2][1],a=i-n,u=o-r;return{type:"Point",coordinates:[n+a/2,r+u/2]}},r.pointDistance=function(e,t){var n=e.coordinates[0],i=e.coordinates[1],o=t.coordinates[0],a=t.coordinates[1],u=r.numberToRadius(a-i),s=r.numberToRadius(o-n),l=Math.pow(Math.sin(u/2),2)+Math.cos(r.numberToRadius(i))*Math.cos(r.numberToRadius(a))*Math.pow(Math.sin(s/2),2),c=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l));return 6371*c*1e3},r.geometryWithinRadius=function(e,t,n){if("Point"==e.type)return r.pointDistance(e,t)<=n;if("LineString"==e.type||"Polygon"==e.type){var i,o={};i="Polygon"==e.type?e.coordinates[0]:e.coordinates;for(var a in i)if(o.coordinates=i[a],r.pointDistance(o,t)>n)return!1}return!0},r.area=function(e){for(var t,n,r=0,i=e.coordinates[0],o=i.length-1,a=0;a0;)if(o=x[r-1],a=k[r-1],r--,a-o>1){for(d=e[a].lng()-e[o].lng(),h=e[a].lat()-e[o].lat(),Math.abs(d)>180&&(d=360-Math.abs(d)),d*=Math.cos(w*(e[a].lat()+e[o].lat())),p=d*d+h*h,u=o+1,s=o,c=-1;a>u;u++)y=e[u].lng()-e[o].lng(),v=e[u].lat()-e[o].lat(),Math.abs(y)>180&&(y=360-Math.abs(y)),y*=Math.cos(w*(e[u].lat()+e[o].lat())),g=y*y+v*v,m=e[u].lng()-e[a].lng(),b=e[u].lat()-e[a].lat(),Math.abs(m)>180&&(m=360-Math.abs(m)),m*=Math.cos(w*(e[u].lat()+e[a].lat())),_=m*m+b*b,l=g>=p+_?_:_>=p+g?g:(y*h-v*d)*(y*h-v*d)/p,l>c&&(s=u,c=l);f>c?(O[i]=o,i++):(r++,x[r-1]=s,k[r-1]=a,r++,x[r-1]=o,k[r-1]=s)}else O[i]=o,i++;O[i]=n-1,i++;for(var j=new Array,u=0;i>u;u++)j.push(e[O[u]]);return j.map(function(e){return{type:"Point",coordinates:[e.lng,e.lat]}})},r.destinationPoint=function(e,t,n){n/=6371,t=r.numberToRadius(t);var i=r.numberToRadius(e.coordinates[0]),o=r.numberToRadius(e.coordinates[1]),a=Math.asin(Math.sin(o)*Math.cos(n)+Math.cos(o)*Math.sin(n)*Math.cos(t)),u=i+Math.atan2(Math.sin(t)*Math.sin(n)*Math.cos(o),Math.cos(n)-Math.sin(o)*Math.sin(a));return u=(u+3*Math.PI)%(2*Math.PI)-Math.PI,{type:"Point",coordinates:[r.numberToDegree(u),r.numberToDegree(a)]}}}()},{}],21:[function(e,t,n){"use strict";var r=function(e,t,n,r,i,o,a,u){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,r,i,o,a,u],c=0;s=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return l[c++]}))}throw s.framesToPop=1,s}};t.exports=r},{}],22:[function(e,t,n){"use strict";var r=function(e){var t,n={};if(!(e instanceof Object)||Array.isArray(e))throw new Error("keyMirror(...): Argument must be an object.");for(t in e)e.hasOwnProperty(t)&&(n[t]=t);return n};t.exports=r},{}],23:[function(e,t,n){function r(e){var t=e?e.length:0;return t?e[t-1]:void 0}t.exports=r},{}],24:[function(e,t,n){t.exports=e("./every")},{"./every":28}],25:[function(e,t,n){t.exports=e("./some")},{"./some":34}],26:[function(e,t,n){t.exports=e("./includes")},{"./includes":30}],27:[function(e,t,n){t.exports=e("./forEach")},{"./forEach":29}],28:[function(e,t,n){function r(e,t,n){var r=u(e)?i:a;return n&&s(e,t,n)&&(t=void 0),("function"!=typeof t||void 0!==n)&&(t=o(t,n,3)),r(e,t)}var i=e("../internal/arrayEvery"),o=e("../internal/baseCallback"),a=e("../internal/baseEvery"),u=e("../lang/isArray"),s=e("../internal/isIterateeCall");t.exports=r},{"../internal/arrayEvery":39,"../internal/baseCallback":44,"../internal/baseEvery":48,"../internal/isIterateeCall":79,"../lang/isArray":88}],29:[function(e,t,n){var r=e("../internal/arrayEach"),i=e("../internal/baseEach"),o=e("../internal/createForEach"),a=o(r,i);t.exports=a},{"../internal/arrayEach":38,"../internal/baseEach":47,"../internal/createForEach":69}],30:[function(e,t,n){function r(e,t,n,r){var d=e?o(e):0;return s(d)||(e=c(e),d=e.length),n="number"!=typeof n||r&&u(t,n,r)?0:0>n?f(d+n,0):n||0,"string"==typeof e||!a(e)&&l(e)?d>=n&&e.indexOf(t,n)>-1:!!d&&i(e,t,n)>-1}var i=e("../internal/baseIndexOf"),o=e("../internal/getLength"),a=e("../lang/isArray"),u=e("../internal/isIterateeCall"),s=e("../internal/isLength"),l=e("../lang/isString"),c=e("../object/values"),f=Math.max;t.exports=r},{"../internal/baseIndexOf":52,"../internal/getLength":73,"../internal/isIterateeCall":79,"../internal/isLength":81,"../lang/isArray":88,"../lang/isString":96,"../object/values":104}],31:[function(e,t,n){function r(e,t,n){var r=u(e)?i:a;return t=o(t,n,3),r(e,t)}var i=e("../internal/arrayMap"),o=e("../internal/baseCallback"),a=e("../internal/baseMap"),u=e("../lang/isArray");t.exports=r},{"../internal/arrayMap":40,"../internal/baseCallback":44,"../internal/baseMap":56,"../lang/isArray":88}],32:[function(e,t,n){function r(e,t){return i(e,o(t))}var i=e("./map"),o=e("../utility/property");t.exports=r},{"../utility/property":106,"./map":31}],33:[function(e,t,n){function r(e){var t=e?i(e):0;return o(t)?t:a(e).length}var i=e("../internal/getLength"),o=e("../internal/isLength"),a=e("../object/keys");t.exports=r},{"../internal/getLength":73,"../internal/isLength":81,"../object/keys":101}],34:[function(e,t,n){function r(e,t,n){var r=u(e)?i:a;return n&&s(e,t,n)&&(t=void 0),("function"!=typeof t||void 0!==n)&&(t=o(t,n,3)),r(e,t)}var i=e("../internal/arraySome"),o=e("../internal/baseCallback"),a=e("../internal/baseSome"),u=e("../lang/isArray"),s=e("../internal/isIterateeCall");t.exports=r},{"../internal/arraySome":41,"../internal/baseCallback":44,"../internal/baseSome":62,"../internal/isIterateeCall":79,"../lang/isArray":88}],35:[function(e,t,n){var r=e("../internal/baseDelay"),i=e("./restParam"),o=i(function(e,t){return r(e,1,t)});t.exports=o},{"../internal/baseDelay":46,"./restParam":36}],36:[function(e,t,n){function r(e,t){if("function"!=typeof e)throw new TypeError(i);return t=o(void 0===t?e.length-1:+t||0,0),function(){for(var n=arguments,r=-1,i=o(n.length-t,0),a=Array(i);++rr;)e=e[t[r++]];return r&&r==o?e:void 0}}var i=e("./toObject");t.exports=r},{"./toObject":85}],52:[function(e,t,n){function r(e,t,n){if(t!==t)return i(e,n);for(var r=n-1,o=e.length;++rt&&(t=-t>i?0:i+t),n=void 0===n||n>i?i:+n||0,0>n&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r2?n[a-2]:void 0,s=a>2?n[2]:void 0,l=a>1?n[a-1]:void 0; for("function"==typeof u?(u=i(u,l,5),a-=2):(u="function"==typeof l?l:void 0,a-=u?1:0),s&&o(n[0],n[1],s)&&(u=3>a?void 0:u,a=1);++rl))return!1;for(;++s-1&&e%1==0&&t>e}var i=/^\d+$/,o=9007199254740991;t.exports=r},{}],79:[function(e,t,n){function r(e,t,n){if(!a(n))return!1;var r=typeof t;if("number"==r?i(n)&&o(t,n.length):"string"==r&&t in n){var u=n[t];return e===e?e===u:u!==u}return!1}var i=e("./isArrayLike"),o=e("./isIndex"),a=e("../lang/isObject");t.exports=r},{"../lang/isObject":95,"./isArrayLike":77,"./isIndex":78}],80:[function(e,t,n){function r(e,t){var n=typeof e;if("string"==n&&u.test(e)||"number"==n)return!0;if(i(e))return!1;var r=!a.test(e);return r||null!=t&&e in o(t)}var i=e("../lang/isArray"),o=e("./toObject"),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,u=/^\w*$/;t.exports=r},{"../lang/isArray":88,"./toObject":85}],81:[function(e,t,n){function r(e){return"number"==typeof e&&e>-1&&e%1==0&&i>=e}var i=9007199254740991;t.exports=r},{}],82:[function(e,t,n){function r(e){return!!e&&"object"==typeof e}t.exports=r},{}],83:[function(e,t,n){function r(e){return e===e&&!i(e)}var i=e("../lang/isObject");t.exports=r},{"../lang/isObject":95}],84:[function(e,t,n){function r(e){for(var t=s(e),n=t.length,r=n&&e.length,l=!!r&&u(r)&&(o(e)||i(e)),f=-1,d=[];++f0;++r