(function(){"use strict";u8.Base.Geolocation=function(){};u8.Base.Geolocation.makeClass({name:"Geolocation"});$.extend(u8.Base.Geolocation.prototype,{createProvider:function(t,e){Function.chain(this._loadSettings.bind(this,t),this._loadProviderType.bind(this,t),this._createProvider.bind(this,t))(e)},getCurrentLocation:function(e){if("geolocation"in navigator){navigator.geolocation.getCurrentPosition(function(n){var o=n&&n.coords&&t(n.coords.latitude,n.coords.longitude);e(o)},function(){e(null)})}else{e(null)}},getMapTheme:function(t){return u8.Base.Geolocation.MapThemes.get(t)},getMapThemeOrDefault:function(t){if(!t){t="default"}return this.getMapTheme(t)||this.getMapTheme("default")},addMapTheme:function(t,e){u8.Base.Geolocation.MapThemes.add(t,e)},_loadSettings:function(t,e){this.settings={licenseMode:"None"};return e()},_loadProviderType:function(t,e){u8.using({types:this._getProviderName(t)},e)},_createProvider:function(t,e){var n=this._getProviderName(t)+"Provider";t=$.extend({settings:this.settings},t);var o=u8.create(n,t);this._onProviderCreate(o);o.load(function(t,n){e(t,n);if(n.error&&!n.error.handled){var o="TXT_net_maps_text_2";u8.services.texts.loadText(o,function(){u8.services.notification.error($t(o))})}})},_getProviderName:function(t){return t&&t.provider||this.settings.provider||"BingMaps"},_onProviderCreate:function(t){}});u8.Base.Geolocation.Location=function(t){$.extend(this,t)};$.extend(u8.Base.Geolocation.Location,{equals:function(t,e){if(!t&&!e){return true}if(!t||!e){return false}return t.lat==e.lat&&t.lng==e.lng},distance:function(t,e){if(!t||!e){return 0}var n=6371,o=Math.PI/180,a=(e.lat-t.lat)*o,i=(e.lng-t.lng)*o,r=Math.sin(a/2)*Math.sin(a/2)+Math.cos(t.lat*o)*Math.cos(e.lat*o)*Math.sin(i/2)*Math.sin(i/2),s=2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)),u=n*s;return u},normalDistance:function(t,e,n){var o=t.lat,a=t.lng;var i=e.lat,r=e.lng;var s=n.lat,u=n.lng;var c=(o-i)/(a-r);var l=(i*a-o*r)/(a-r);var d=s+1/c*u;var h=(d-l)/(c+1/c);var f=-(1/c)*h+d;return Math.sqrt(Math.pow(u-h,2)+Math.pow(s-f,2))}});u8.Base.Geolocation.Bounds=function(t){$.extend(this,t)};$.extend(u8.Base.Geolocation.Bounds.prototype,{});u8.services.add({name:"geolocation",scope:"Application",ctor:u8.Base.Geolocation});function t(t,e){return new u8.Base.Geolocation.Location({lat:t,lng:e})}})();