/*
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/lang","../../core/maybe","../SpatialReference","./Ellipsoid","./spatialReferenceUtils"],(function(e,n,t,i,r,a){"use strict";const o=57.29577951308232,s=.017453292519943;function l(e){return e*o}function c(e){return e*s}function u(e){return e/r.earth.radius}function h(e){return Math.PI/2-2*Math.atan(Math.exp(-e/r.earth.radius))}function p(e){return null!=e.wkid||null!=e.wkt}const f=[0,0];function g(e,n,t,i,r){const a=e,o=r;if(o.spatialReference=t,"x"in a&&"x"in o)[o.x,o.y]=n(a.x,a.y,f,i);else if("xmin"in a&&"xmin"in o)[o.xmin,o.ymin]=n(a.xmin,a.ymin,f,i),[o.xmax,o.ymax]=n(a.xmax,a.ymax,f,i);else if("paths"in a&&"paths"in o||"rings"in a&&"rings"in o){const e="paths"in a?a.paths:a.rings,t=[];let r;for(let a=0;a<e.length;a++){const o=e[a];r=[],t.push(r);for(let e=0;e<o.length;e++)r.push(n(o[e][0],o[e][1],[0,0],i)),o[e].length>2&&r[e].push(o[e][2]),o[e].length>3&&r[e].push(o[e][3])}"paths"in o?o.paths=t:o.rings=t}else if("points"in a&&"points"in o){const e=a.points,t=[];for(let r=0;r<e.length;r++)t[r]=n(e[r][0],e[r][1],[0,0],i),e[r].length>2&&t[r].push(e[r][2]),e[r].length>3&&t[r].push(e[r][3]);o.points=t}return r}function x(e,n){const t=e&&(p(e)?e:e.spatialReference),i=n&&(p(n)?n:n.spatialReference);return!(e&&"type"in e&&"mesh"===e.type||n&&"type"in n&&"mesh"===n.type||!t||!i)&&(!!a.equals(i,t)||(a.isWebMercator(i)&&a.isWGS84(t)||a.isWebMercator(t)&&a.isWGS84(i)))}function M(e,r){if(t.isNone(e))return null;const o=e.spatialReference,s=r&&(p(r)?r:r.spatialReference);return x(o,s)?a.equals(o,s)?n.clone(e):a.isWebMercator(s)?g(e,m,i.WebMercator,!1,n.clone(e)):a.isWGS84(s)?g(e,y,i.WGS84,!1,n.clone(e)):null:null}function m(e,n,t=[0,0]){n>89.99999?n=89.99999:n<-89.99999&&(n=-89.99999);const i=c(n);return t[0]=c(e)*r.earth.radius,t[1]=r.earth.halfSemiMajorAxis*Math.log((1+Math.sin(i))/(1-Math.sin(i))),t}function y(e,n,t=[0,0],i=!1){const a=l(e/r.earth.radius);return t[0]=i?a:a-360*Math.floor((a+180)/360),t[1]=l(Math.PI/2-2*Math.atan(Math.exp(-n/r.earth.radius))),t}function d(e,t=!1,r=n.clone(e)){return g(e,m,i.WebMercator,t,r)}function W(e,t=!1,r=n.clone(e)){return g(e,y,i.WGS84,t,r)}e.canProject=x,e.geographicToWebMercator=d,e.lngLatToXY=m,e.project=M,e.webMercatorToGeographic=W,e.x2lon=u,e.xyToLngLat=y,e.y2lat=h,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
