/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../core/Error","../chunks/pe","./Point","./SpatialReference"],(function(e,n,t,o,r){"use strict";function i(){return t.isLoaded()}function a(){return t.isSupported()}function s(){return t.load()}function c(e,n){const i=[];e=(e=(e=e.replace(/[\u00B0\u00BA]/g,"^")).replace(/\u2032/g,"'")).replace(/\u2033/g,'"');const a=S(n);return t.PeNotationDms.dmsToGeog(a,1,[e],i)?new o(i[0][0],i[0][1],n||r.WGS84):null}function l(e,n,i){const a=[],s=m(i);if(-1===s)return console.warn(`invalid conversionMode: ${i}`),null;const c=S(n);return t.PeNotationMgrs.mgrsToGeogExtended(c,1,[e],s,a)?new o(a[0][0],a[0][1],n||r.WGS84):null}function u(e,n){const i=[];!n&&/\(.+27/.test(e)&&(n=r.GCS_NAD_1927);const a=S(n);return t.PeNotationUsng.usngToGeog(a,1,[e],i)?new o(i[0][0],i[0][1],n||r.WGS84):null}function d(e,n,i){const a=[],s=M(i);if(-1===s)return console.warn(`invalid conversionMode: ${i}`),null;const c=S(n);return t.PeNotationUtm.utmToGeog(c,1,[e],s,a)?new o(a[0][0],a[0][1],n||r.WGS84):null}function g(e,n,o=0){const r=[[e.x,e.y]],i=[],a=S(e.spatialReference);let s=0;switch(n){case"dd":s=t.PeNotationDms.geogToDd(a,1,r,o,i);break;case"ddm":s=t.PeNotationDms.geogToDdm(a,1,r,o,i);break;case"dms":s=t.PeNotationDms.geogToDms(a,1,r,o,i);break;default:return console.warn(`invalid format: ${n}`),null}return s?i[0]:null}function P(e,n,o=0,r=!1){const i=[[e.x,e.y]],a=[],s=S(e.spatialReference);let c=m(n);if(-1===c)return console.warn(`invalid conversionMode: ${n}`),null;r&&(c|=t.PeNotationMgrs.PE_MGRS_ADD_SPACES);return t.PeNotationMgrs.geogToMgrsExtended(s,1,i,o,!1,c,a)?a[0]:null}function f(e,n=0,o=!1){const r=[[e.x,e.y]],i=[],a=S(e.spatialReference);return t.PeNotationUsng.geogToUsng(a,1,r,n,!1,o,i)?i[0]:null}function _(e,n,o=!1){const r=[[e.x,e.y]],i=[],a=S(e.spatialReference);let s=M(n);if(-1===s)return console.warn(`invalid conversionMode: ${n}`),null;o&&(s|=t.PeNotationUtm.PE_UTM_OPTS_ADD_SPACES);return t.PeNotationUtm.geogToUtm(a,1,r,s,i)?i[0]:null}function S(e){let o=null;if(e||(e=r.WGS84),e.wkid){if(o=t.PeFactory.geogcs(e.wkid),!o)throw new n("coordinate-formatter:invalid-spatial-reference","wkid is not valid")}else{if(!e.wkt)throw new n("coordinate-formatter:invalid-spatial-reference","wkid and wkt are missing");if(o=t.PeFactory.fromString(t.PeDefs.PE_TYPE_GEOGCS,e.wkt),!o)throw new n("coordinate-formatter:invalid-spatial-reference","wkt is not valid")}return o}function m(e){let n=-1;switch(e){case"automatic":n=t.PeNotationMgrs.PE_MGRS_STYLE_AUTO;break;case"new-180-in-zone-01":n=t.PeNotationMgrs.PE_MGRS_STYLE_NEW|t.PeNotationMgrs.PE_MGRS_180_ZONE_1_PLUS;break;case"new-180-in-zone-60":n=t.PeNotationMgrs.PE_MGRS_STYLE_NEW;break;case"old-180-in-zone-01":n=t.PeNotationMgrs.PE_MGRS_STYLE_OLD|t.PeNotationMgrs.PE_MGRS_180_ZONE_1_PLUS;break;case"old-180-in-zone-60":n=t.PeNotationMgrs.PE_MGRS_STYLE_OLD}return n}function M(e){let n=-1;switch(e){case"latitude-band-indicators":n=t.PeNotationUtm.PE_UTM_OPTS_NONE;break;case"north-south-indicators":n=t.PeNotationUtm.PE_UTM_OPTS_NS}return n}e.fromLatitudeLongitude=c,e.fromMgrs=l,e.fromUsng=u,e.fromUtm=d,e.isLoaded=i,e.isSupported=a,e.load=s,e.toLatitudeLongitude=g,e.toMgrs=P,e.toUsng=f,e.toUtm=_,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
