gof
Version:
An extreme fast and highly scalable Firebase geo-query library.
1 lines • 24.3 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("geoOnFire",[],t):"object"==typeof exports?exports.geoOnFire=t():e.geoOnFire=t()}(this,function(){return function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={exports:{},id:a,loaded:!1};return e[a].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(1),r=n(3),s=n(4),u=n(19),c=function(){function e(t,n){a(this,e),s.GofValidation.validateConstructor(t,n,"geoOnFire()"),this._utils=o.GofUtils,this._db=new r.GofDb(t,n),this.registerEvents(),this._activeQuery={geohashes:[],entries:[],parameters:[],dbListeners:[]}}return i(e,[{key:"getLocationsByRadius",value:function(e,t){var n=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;s.GofValidation.validateLocationsByRadius(e,t,a,i,"getLocationsByRadius()"),this._activeQuery.parameters={center:e,radius:t,startAt:a,endAt:i};var o=this._utils.getBoundariesFromRadius(e,t),r=this._utils.caluclatePrecisionFromBoundaries(o);return this._activeQuery.geohashes=this._utils.getGeohashesInBoundaries(o,r),this._activeQuery.entries=this._db.getLocationsFromGeohashes(this._activeQuery.geohashes).then(function(a){return n._utils.getLocationsInRadius(a,e,t)}).then(function(e){return n._db.fetchLocations(e,a,i)}),this.getLocationsByRadius}},{key:"getLocationsByBoundaries",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;s.GofValidation.validateLocationsByBoundaries(e,n,a,"getLocationsByBoundaries()"),this._activeQuery.parameters={boundaries:e,startAt:n,endAt:a};var i=this._utils.caluclatePrecisionFromBoundaries(e);return this._activeQuery.geohashes=this._utils.getGeohashesInBoundaries(e,i),this._activeQuery.entries=this._db.getLocationsFromGeohashes(this._activeQuery.geohashes).then(function(n){return t._utils.getLocationsInBoundaries(n,e)}).then(function(e){return t._db.fetchLocations(e,n,a)}),this.getLocationsByBoundaries}},{key:"createEntry",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9;s.GofValidation.validateCreateEntry(e,n,a,"createEntry()");var i=this._utils.getGeohashByLocation(e.location,a),o=this._utils.getGeohashPrecisions(i,n,a),r=this._utils.setPrecisionsForEntry(n,e);return this._db.pushEntry(r).then(function(n){return t._db.setGeohashLocations(n.key,e.location,o)})}},{key:"updateEntryLocation",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;return s.GofValidation.validateUpdateEntryLocation(e,t,n,"updateEntryLocation()"),this._db.updateEntry(e,t,n)}},{key:"deleteEntry",value:function(e){return s.GofValidation.validateDeleteEntry(e,"deleteEntry()"),this._db.deleteEntry(e)}},{key:"registerEvents",value:function(){var e=this;this.getLocationsByBoundaries.on=function(t){return e.attachQueryEvent(t,"bounds",function(){e.getLocationsByBoundaries(e._activeQuery.parameters.boundaries,e._activeQuery.parameters.startAt,e._activeQuery.parameters.endAt)})},this.getLocationsByRadius.on=function(t){return e.attachQueryEvent(t,"radius",function(){e.getLocationsByRadius(e._activeQuery.parameters.center,e._activeQuery.parameters.radius,e._activeQuery.parameters.startAt,e._activeQuery.parameters.endAt)})},this.getLocationsByBoundaries.once=function(){return e._activeQuery.entries},this.getLocationsByRadius.once=function(){return e._activeQuery.entries}}},{key:"attachQueryEvent",value:function(e,t,n){var a=this;s.GofValidation.validateOn(e,"on()");var i=new Event(t),o=void 0,r={then:function(e){o=e,window.dispatchEvent(i)}};return this._activeQuery.dbListeners=u.GofDbListeners.attachDbListeners(e,this._db._refs,this._activeQuery.geohashes,i),window.addEventListener(t,function(){n(),a._activeQuery.entries.then(function(e){return o(e)})}),r}},{key:"destroy",value:function(){this._activeQuery.dbListeners.length&&(this._activeQuery.dbListeners.forEach(function(e){e.off()}),this._activeQuery.dbListeners=[])}}]),e}();t.default=c,e.exports=t.default},function(e,t,n){"use strict";function a(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(t,"__esModule",{value:!0}),t.GofUtils=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(2),s=a(r);t.GofUtils=function(){function e(){i(this,e)}return o(e,null,[{key:"getGeohashByLocation",value:function(e,t){return s.default.encode(e.lat,e.lng,t)}},{key:"getGeohashPrecisions",value:function(e,t,n){for(var a=[],i=0;n-t>=i;i++)a.push(e.substring(0,e.length-i));return a}},{key:"setPrecisionsForEntry",value:function(e,t){var n=t;return n.minPrecision=e,n.maxPrecision=9,n}},{key:"getGeohashActions",value:function(e,t){var n={};return n.add=t.filter(function(t){return e.indexOf(t)<0}),n.delete=e.filter(function(e){return t.indexOf(e)<0}),n.update=e.filter(function(e){return n.add.concat(n.delete).indexOf(e)<0}),n}},{key:"getGeohashesInBoundaries",value:function(e,t){return s.default.bboxes(e.sw.lat,e.sw.lng,e.ne.lat,e.ne.lng,t)}},{key:"getLocationsInBoundaries",value:function(e,t){var n=this,a=[];return e.map(function(e){e.val()&&e.forEach(function(e){n.isInBoundaries(e.val(),t)&&a.push(new Promise(function(t,n){t(e.key)}))})}),Promise.all(a)}},{key:"isInBoundaries",value:function e(t,n){var e=!1;return n.sw.lat<=t.lat&&n.sw.lng<=t.lng&&n.ne.lat>=t.lat&&n.ne.lng>=t.lng&&(e=!0),e}},{key:"getBoundariesFromRadius",value:function(e,t){var n=110.54,a=111.32,i={sw:{},ne:{}};return i.sw.lat=e.lat-1/n*t,i.sw.lng=e.lng-1/(a*Math.cos(this.degreesToRadians(e.lat)))*t,i.ne.lat=e.lat+1/n*t,i.ne.lng=e.lng+1/(a*Math.cos(this.degreesToRadians(e.lat)))*t,i}},{key:"getLocationsInRadius",value:function(e,t,n){var a=this,i=[];return e.map(function(e){e.val()&&e.forEach(function(e){a.isInRadius(e.val(),t,n)&&i.push(new Promise(function(t,n){t(e.key)}))})}),Promise.all(i)}},{key:"isInRadius",value:function e(t,n,a){var e=!1;return this.distBtwLocations(t,n)<=a&&(e=!0),e}},{key:"distBtwLocations",value:function(e,t){var n=Math.PI*t.lat/180,a=Math.PI*e.lat/180,i=t.lng-e.lng,o=Math.PI*i/180,r=Math.sin(n)*Math.sin(a)+Math.cos(n)*Math.cos(a)*Math.cos(o);return r=Math.acos(r),r=180*r/Math.PI,r=60*r*1.1515,r*=1.609344}},{key:"caluclatePrecisionFromBoundaries",value:function(e){var t=void 0,n=this.distBtwLocations({lat:e.sw.lat,lng:e.sw.lng},{lat:e.ne.lat,lng:e.ne.lng});return t=n<.02?9:n<.1?8:n<.7?7:n<4?6:n<25?5:n<150?4:n<800?3:n<4e3?2:1}},{key:"degreesToRadians",value:function(e){return e*Math.PI/180}}]),e}()},function(e,t){function n(e,t){return e/Math.pow(2,t)&1}for(var a="0123456789bcdefghjkmnpqrstuvwxyz",i={},o=0;o<a.length;o++)i[a.charAt(o)]=o;var r="auto",s=[0,5,7,8,11,12,13,15,16,17,18],u=function(e,t,n){if(n===r){if("number"==typeof e||"number"==typeof t)throw new Error("string notation required for auto precision.");var i=e.split(".")[1].length,o=t.split(".")[1].length,u=Math.max(i,o);n=s[u]}else void 0===n&&(n=9);for(var c,l=[],d=0,f=0,h=0,v=90,y=-90,p=180,m=-180;l.length<n;)if(f%2===0?(c=(p+m)/2,t>c?(h=(h<<1)+1,m=c):(h=(h<<1)+0,p=c)):(c=(v+y)/2,e>c?(h=(h<<1)+1,y=c):(h=(h<<1)+0,v=c)),d++,f++,5===d){var g=a[h];l.push(g),d=0,h=0}return l.join("")},c=function(e,t,n){n=n||52;for(var a,i=0,o=90,r=-90,s=180,u=-180,c=0;i<n;)c*=2,i%2===0?(a=(s+u)/2,t>a?(c+=1,u=a):s=a):(a=(o+r)/2,e>a?(c+=1,r=a):o=a),i++;return c},l=function(e){for(var t,n=!0,a=90,o=-90,r=180,s=-180,u=0,c=0,l=e.length;c<l;c++){var d=e[c].toLowerCase();u=i[d];for(var f=4;f>=0;f--){var h=u>>f&1;n?(t=(r+s)/2,1===h?s=t:r=t):(t=(a+o)/2,1===h?o=t:a=t),n=!n}}return[o,s,a,r]},d=function(e,t){t=t||52;for(var a=90,i=-90,o=180,r=-180,s=0,u=0,c=t/2,l=0;l<c;l++)u=n(e,2*(c-l)-1),s=n(e,2*(c-l)-2),0===s?a=(a+i)/2:i=(a+i)/2,0===u?o=(o+r)/2:r=(o+r)/2;return[i,r,a,o]},f=function(e){var t=l(e),n=(t[0]+t[2])/2,a=(t[1]+t[3])/2,i=t[2]-n,o=t[3]-a;return{latitude:n,longitude:a,error:{latitude:i,longitude:o}}},h=function(e,t){var n=d(e,t),a=(n[0]+n[2])/2,i=(n[1]+n[3])/2,o=n[2]-a,r=n[3]-i;return{latitude:a,longitude:i,error:{latitude:o,longitude:r}}},v=function(e,t){var n=f(e),a=n.latitude+t[0]*n.error.latitude*2,i=n.longitude+t[1]*n.error.longitude*2;return u(a,i,e.length)},y=function(e,t,n){n=n||52;var a=h(e,n),i=a.latitude+t[0]*a.error.latitude*2,o=a.longitude+t[1]*a.error.longitude*2;return c(i,o,n)},p=function(e){function t(e,t){return n=r+e*c,a=s+t*l,u(n,a,i)}var n,a,i=e.length,o=f(e),r=o.latitude,s=o.longitude,c=2*o.error.latitude,l=2*o.error.longitude,d=[t(1,0),t(1,1),t(0,1),t(-1,1),t(-1,0),t(-1,-1),t(0,-1),t(1,-1)];return d},m=function(e,t){function n(e,n){return a=r+e*u,i=s+n*l,c(a,i,t)}t=t||52;var a,i,o=h(e,t),r=o.latitude,s=o.longitude,u=2*o.error.latitude,l=2*o.error.longitude,d=[n(1,0),n(1,1),n(0,1),n(-1,1),n(-1,0),n(-1,-1),n(0,-1),n(1,-1)];return d},g=function(e,t,n,a,i){i=i||9;for(var o=u(e,t,i),r=u(n,a,i),s=f(o),c=2*s.error.latitude,d=2*s.error.longitude,h=l(o),y=l(r),p=Math.round((y[0]-h[0])/c),m=Math.round((y[1]-h[1])/d),g=[],b=0;b<=p;b++)for(var _=0;_<=m;_++)g.push(v(o,[b,_]));return g},b=function(e,t,n,a,i){i=i||52;for(var o=c(e,t,i),r=c(n,a,i),s=h(o,i),u=2*s.error.latitude,l=2*s.error.longitude,f=d(o,i),v=d(r,i),p=Math.round((v[0]-f[0])/u),m=Math.round((v[1]-f[1])/l),g=[],b=0;b<=p;b++)for(var _=0;_<=m;_++)g.push(y(o,[b,_],i));return g},_={ENCODE_AUTO:r,encode:u,encode_uint64:c,encode_int:c,decode:f,decode_int:h,decode_uint64:h,decode_bbox:l,decode_bbox_uint64:d,decode_bbox_int:d,neighbor:v,neighbor_int:y,neighbors:p,neighbors_int:m,bboxes:g,bboxes_int:b};e.exports=_},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.GofDb=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(1);t.GofDb=function(){function e(t,n){a(this,e);var i=t.replace(" ","-").toLowerCase();this._refs={entries:n.child(""+i),geohashes:n.child(i+"-geo")},this._utils=o.GofUtils}return i(e,[{key:"pushEntry",value:function(e){return this._refs.entries.push(e)}},{key:"setGeohashLocations",value:function(e,t,n){return Promise.all(this.getLocationNodesToAdd(e,t,n))}},{key:"fetchLocations",value:function(e,t,n){var a=[];if(n)for(var i=n>e.length?e.length:n,o=t-1;o<i;o++)a.push(this._refs.entries.child(""+e[o]).once("value"));else for(var r=t-1;r<e.length-(t-1);r++)a.push(this._refs.entries.child(""+e[r]).once("value"));return Promise.all(a)}},{key:"getLocationsFromGeohashes",value:function(e){for(var t=[],n=0;n<e.length;n++)t.push(this._refs.geohashes.child(""+e[n]).once("value"));return Promise.all(t).catch(function(){throw new Error("Unable to get the entries.")})}},{key:"updateEntry",value:function(e,t,n){var a=this,i=this._utils.setPrecisionsForEntry(n,t),o=this._utils.getGeohashByLocation(t.location,i.maxPrecision),r=this._utils.getGeohashPrecisions(o,i.minPrecision,i.maxPrecision);return this._refs.entries.child(""+e).once("value").then(function(n){var i=n.val(),o=a._utils.getGeohashByLocation(i.location,i.maxPrecision),s=a._utils.getGeohashPrecisions(o,i.minPrecision,i.maxPrecision),u=[],c=a._utils.getGeohashActions(s,r);return u.concat(a.getLocationNodesToAdd(e,t.location,c.add)),u.concat(a.getLocationNodesToUpdate(e,t.location,c.update)),u.concat(a.getLocationNodesToDelete(e,c.delete)),u.push(a._refs.entries.child(""+e).update(t)),Promise.all(u)}).catch(function(){throw new Error('\n Unable to update the entry, Make sure the entry with "'+e+'" exists\n ')})}},{key:"deleteEntry",value:function(e){var t=this;return this._refs.entries.child(""+e).once("value").then(function(e){var n=e.val(),a=t._utils.getGeohashByLocation(n.location,n.maxPrecision),i=t._utils.getGeohashPrecisions(a,n.minPrecision,n.maxPrecision),o=t.getLocationNodesToDelete(e.key,i);return o.push(t._refs.entries.child(""+e.key).remove()),Promise.all(o)}).catch(function(){throw new Error('\n Unable to delete the entry, Make sure the entry with "'+e+'" exists\n ')})}},{key:"getLocationNodesToAdd",value:function(e,t,n){for(var a=[],i=0;n.length>i;i++)a.push(this._refs.geohashes.child(n[i]+"/"+e).set(t));return a}},{key:"getLocationNodesToUpdate",value:function(e,t,n){for(var a=[],i=0;n.length>i;i++)a.push(this._refs.geohashes.child(n[i]+"/"+e).update(t));return a}},{key:"getLocationNodesToDelete",value:function(e,t){for(var n=[],a=0;t.length>a;a++)n.push(this._refs.geohashes.child(t[a]+"/"+e).remove());return n}}]),e}()},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.GofValidation=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(5),r=n(7),s=n(9),u=n(10),c=n(11),l=n(12),d=n(13),f=n(14),h=n(15),v=n(16),y=n(17),p=n(18);t.GofValidation=function(){function e(){a(this,e)}return i(e,null,[{key:"validateConstructor",value:function(e,t,n){(0,h.validateNameParameter)(e,n),(0,o.validateDbParameter)(t,n)}},{key:"validateLocationsByRadius",value:function(e,t,n,a,i){(0,r.validateCenterParameter)(e,i),(0,s.validateRadiusParameter)(t,i),(0,u.validateEntryLimitationParameters)(n,a,i)}},{key:"validateLocationsByBoundaries",value:function(e,t,n,a){(0,c.validateBoundariesParameter)(e,a,"boundaries"),(0,u.validateEntryLimitationParameters)(t,n,a)}},{key:"validateCreateEntry",value:function(e,t,n,a){(0,l.validateEntryParameter)(e,a,"entry.location"),(0,d.validatePriorityParameter)(t,a),(0,f.validateMaxPrecisionParameter)(n,a)}},{key:"validateUpdateEntryLocation",value:function(e,t,n,a){(0,v.validatePushKeyParameter)(e,a),(0,y.validateNewValueParameter)(t,a,"newValue.location"),(0,d.validatePriorityParameter)(n,a)}},{key:"validateDeleteEntry",value:function(e,t){(0,v.validatePushKeyParameter)(e,t)}},{key:"validateOn",value:function(e,t){(0,p.validateEventTypeParameter)(e,t)}}]),e}()},function(e,t,n){"use strict";function a(e,t){i.GofBasicValidation.validateObject(e,{fName:t,p1:"firebase.database()"}),i.GofBasicValidation.validateReference(e,{fName:t,p1:"firebase.database()"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validateDbParameter=a;var i=n(6)},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();t.GofBasicValidation=function(){function e(){n(this,e)}return i(e,null,[{key:"validateNumber",value:function(e,t){"number"!=typeof e?this.throwError(t.fName,t.p1+" must be of type number!"):isNaN(e)&&this.throwError(t.fName,t.p1+" should not contain the value NaN!")}},{key:"validateString",value:function(e,t){"string"!=typeof e&&this.throwError(t.fName,t.p1+" must be of type string!")}},{key:"validateFunction",value:function(e,t){"function"!=typeof e&&this.throwError(t.fName,t.p1+" must be of type function!")}},{key:"validateObject",value:function(e,t){"object"!==("undefined"==typeof e?"undefined":a(e))&&this.throwError(t.fName,t.p1+" must be of type object!")}},{key:"containsSpecialChars",value:function(e,t){e.match(/[^A-Za-z0-9\-_ ]/)&&this.throwError(t.fName,t.p1+" should not contain special chars!")}},{key:"containsSpaces",value:function(e,t){/\s/.test(e)&&this.throwError(t.fName,t.p1+" should not contain white spaces!")}},{key:"validateReference",value:function(e,t){"function"!=typeof e.child&&this.throwError(t.fName,t.p1+" is not a valid firebase database reference!")}},{key:"validateEventType",value:function(e,t){"child_moved"===e?this.throwError(t.fName,t.p1+' of "child_moved" is not supported. You have to use one of the follwoing types: "value", "child_added", "child_changed", "child_removed"'):"value"!==e&&"child_added"!==e&&"child_changed"!==e&&"child_removed"!==e&&this.throwError(t.fName,'"'+e+'" is not a valid '+t.p1+'. You have to use one of the follwoing types: "value", "child_added", "child_changed", "child_removed"')}},{key:"isLowerThan",value:function(e,t,n){e<t&&this.throwError(n.fName,n.p1+" must be higher or same as "+n.p2+"!")}},{key:"isHigherThan",value:function(e,t,n){e>t&&this.throwError(n.fName,n.p1+" must be lower or same as "+n.p2+"!")}},{key:"hasDecimalPlaces",value:function(e,t){e%1!==0&&this.throwError(t.fName,t.p1+" should not contain decimal places!")}},{key:"throwError",value:function(e,t){throw new Error(e+" - "+t)}}]),e}()},function(e,t,n){"use strict";function a(e,t){i.GofCoordinatesValidation.validateCoordinates(e,t,"center")}Object.defineProperty(t,"__esModule",{value:!0}),t.validateCenterParameter=a;var i=n(8)},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.GofCoordinatesValidation=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),o=n(6);t.GofCoordinatesValidation=function(){function e(){a(this,e)}return i(e,null,[{key:"validateCoordinates",value:function(e,t,n){this.validateLat(e.lat,t,n+".lat"),this.validateLng(e.lng,t,n+".lng")}},{key:"validateLat",value:function(e,t,n){o.GofBasicValidation.validateNumber(e,{fName:t,p1:n}),o.GofBasicValidation.isHigherThan(e,90,{fName:t,p1:n,p2:90}),o.GofBasicValidation.isLowerThan(e,-90,{fName:t,p1:n,p2:-90})}},{key:"validateLng",value:function(e,t,n){o.GofBasicValidation.validateNumber(e,{fName:t,p1:n}),o.GofBasicValidation.isHigherThan(e,180,{fName:t,p1:n,p2:180}),o.GofBasicValidation.isLowerThan(e,-180,{fName:t,p1:n,p2:-180})}}]),e}()},function(e,t,n){"use strict";function a(e,t){i.GofBasicValidation.validateNumber(e,{fName:t,p1:"radius"}),i.GofBasicValidation.isLowerThan(e,0,{fName:t,p1:"radius",p2:"0"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validateRadiusParameter=a;var i=n(6)},function(e,t,n){"use strict";function a(e,t,n){t&&o(t,n,"endAt"),i(e,t,n,"startAt")}function i(e,t,n,a){r.GofBasicValidation.validateNumber(e,{fName:n,p1:a}),r.GofBasicValidation.isLowerThan(e,1,{fName:n,p1:a,p2:"1"}),r.GofBasicValidation.hasDecimalPlaces(e,{fName:n,p1:a}),r.GofBasicValidation.isHigherThan(e,t,{fName:n,p1:a,p2:"endAt"})}function o(e,t,n){r.GofBasicValidation.validateNumber(e,{fName:t,p1:n}),r.GofBasicValidation.hasDecimalPlaces(e,{fName:t,p1:n})}Object.defineProperty(t,"__esModule",{value:!0}),t.validateEntryLimitationParameters=a;var r=n(6)},function(e,t,n){"use strict";function a(e,t,n){i.GofCoordinatesValidation.validateCoordinates(e.sw,t,n+".sw"),i.GofCoordinatesValidation.validateCoordinates(e.ne,t,n+".ne"),o.GofBasicValidation.isHigherThan(e.sw.lat,e.ne.lat,{fName:t,p1:"boundaries.sw.lat",p2:"boundaries.ne.lat"}),o.GofBasicValidation.isHigherThan(e.sw.lng,e.ne.lng,{fName:t,p1:"boundaries.sw.lng",p2:"boundaries.ne.lng"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validateBoundariesParameter=a;var i=n(8),o=n(6)},function(e,t,n){"use strict";function a(e,t,n){i.GofCoordinatesValidation.validateCoordinates(e.location,t,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.validateEntryParameter=a;var i=n(8)},function(e,t,n){"use strict";function a(e,t){i.GofBasicValidation.validateNumber(e,{fName:t,p1:"priority"}),i.GofBasicValidation.hasDecimalPlaces(e,{fName:t,p1:"priority"}),i.GofBasicValidation.isLowerThan(e,1,{fName:t,p1:"priority",p2:"1"}),i.GofBasicValidation.isHigherThan(e,5,{fName:t,p1:"priority",p2:"5"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validatePriorityParameter=a;var i=n(6)},function(e,t,n){"use strict";function a(e,t){i.GofBasicValidation.validateNumber(e,{fName:t,p1:"maxPrecision"}),i.GofBasicValidation.hasDecimalPlaces(e,{fName:t,p1:"maxPrecision"}),i.GofBasicValidation.isLowerThan(e,7,{fName:t,p1:"maxPrecision",p2:"7"}),i.GofBasicValidation.isHigherThan(e,9,{fName:t,p1:"maxPrecision",p2:"9"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validateMaxPrecisionParameter=a;var i=n(6)},function(e,t,n){"use strict";function a(e,t){i.GofBasicValidation.validateString(e,{fName:t,p1:"name"}),i.GofBasicValidation.containsSpecialChars(e,{fName:t,p1:"name"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validateNameParameter=a;var i=n(6)},function(e,t,n){"use strict";function a(e,t){i.GofBasicValidation.validateString(e,{fName:t,p1:"pushKey"}),i.GofBasicValidation.containsSpecialChars(e,{fName:t,p1:"pushKey"}),i.GofBasicValidation.containsSpaces(e,{fName:t,p1:"pushKey"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validatePushKeyParameter=a;var i=n(6)},function(e,t,n){"use strict";function a(e,t,n){(0,i.validateEntryParameter)(e,t,"newValue.location"),(0,o.validatePriorityParameter)(e.minPrecision,t),(0,r.validateMaxPrecisionParameter)(e.maxPrecision,t)}Object.defineProperty(t,"__esModule",{value:!0}),t.validateNewValueParameter=a;var i=n(12),o=n(13),r=n(14)},function(e,t,n){"use strict";function a(e,t){i.GofBasicValidation.validateString(e,{fName:t,p1:"type"}),i.GofBasicValidation.validateEventType(e,{fName:t,p1:"type"})}Object.defineProperty(t,"__esModule",{value:!0}),t.validateEventTypeParameter=a;var i=n(6)},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();t.GofDbListeners=function(){function e(){n(this,e)}return a(e,null,[{key:"attachDbListeners",value:function(e,t,n,a){var i=[];return"value"===e?i=this.onValue(t,n,a):"child_added"===e?i=this.onChildAdded(t,n,a):"child_changed"===e?i=this.onChildChanged(t,n,a):"child_removed"===e&&(i=this.onChildRemoved(t,n,a)),i}},{key:"onValue",value:function(e,t,n){var a=[];return t.forEach(function(t){e.geohashes.child(t).on("value",function(e){window.dispatchEvent(n)});var i=e.geohashes.child(t);a.push(i)}),a}},{key:"onChildAdded",value:function(e,t,n){var a=[];return t.forEach(function(t){e.geohashes.child(t).on("child_added",function(e){window.dispatchEvent(n)});var i=e.geohashes.child(t);a.push(i)}),a}},{key:"onChildChanged",value:function(e,t,n){var a=[];return t.forEach(function(t){e.geohashes.child(t).on("child_changed",function(e){window.dispatchEvent(n)});var i=e.geohashes.child(t);a.push(i)}),a}},{key:"onChildRemoved",value:function(e,t,n){var a=[];return t.forEach(function(t){e.geohashes.child(t).on("child_removed",function(e){window.dispatchEvent(n)});var i=e.geohashes.child(t);a.push(i)}),a}}]),e}()}])});