"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/slicedToArray"),r=require("lodash");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=e(t);function n(t){if(!t||"string"!=typeof t||t.length<1)return[];if(-1===t.indexOf("N")&&-1===t.indexOf("S")&&-1===t.indexOf("W")&&-1===t.indexOf("E")){var r=t.split(",");return r[0]&&r[1]?(r[0]=parseFloat(r[0]),r[1]=parseFloat(r[1]),r):[]}var e=t.split(/[°'"]+/).join(" ").split(/[^\w\S]+/),n=[],i=[],o=0,s=0;for(var u in e)if(isNaN(e[u])){var l=parseFloat(e[u]),f=e[u];Number.isNaN(l)||(o+=l/Math.pow(60,s),s+=1,f=e[u].replace(l,""));var h=f;"S"!==(f=a.default(h,1)[0])&&"W"!==f||(o*=-1),n[n.length]=f,i[i.length]=o,o=0,s=0}else o+=parseFloat(e[u])/Math.pow(60,s),s+=1;if("W"===n[0]||"E"===n[0]){var p=i[0];i[0]=i[1],i[1]=p}return i}function i(t){return t*Math.PI/180}function o(t){var e=!0;return r.isArray(t)&&2===t.length?t.forEach((function(t){Number.isFinite(t)||(e=!1)})):e=!1,e}exports.getAssetCoordinates=function(t){if(!t)return null;var e=r.get(t,["top_hole","coordinates"]),a=r.get(t,["top_hole","raw"]);if(e)return e;if(a){var i=n(a);if(o(i))return i}return null},exports.getAssetV2Coordinates=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"attributes.top_hole";if(!t)return null;var a=r.get(t,e)||{},i=a.coordinates,s=a.raw;if(i)return i;if(s){var u=n(s);if(o(u))return u}return null},exports.getDistanceByCoordinates=function(t,r){var e=i(t[0]),a=i(r[0]),n=i(r[0]-t[0]),o=i(r[1]-t[1]),s=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e)*Math.cos(a)*Math.sin(o/2)*Math.sin(o/2);return 6371e3*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))/1609.34},exports.isValidCoordinates=function(t){var r=a.default(t,2),e=r[0],n=r[1];return Math.abs(e)<=90&&Math.abs(n)<=180},exports.isValidLatLng=o,exports.parseLatLng=n;
