/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports"],(function(n){"use strict";var t,r,e,u={exports:{}};t=u,r=function(){var n=Math.PI,t=Math.sin,r=Math.cos,e=Math.tan,u=Math.asin,o=Math.atan2,i=Math.acos,a=n/180,c=864e5,f=2440588,d=2451545,s={dec:0,ra:0};function v(n){return n.valueOf()/c-.5+f}function M(n){return new Date((n+.5-f)*c)}function l(n){return v(n)-d}var p=23.4397*a;function h(n,u){return o(t(n)*r(p)-e(u)*t(p),r(n))}function x(n,e){return u(t(e)*r(p)+r(e)*t(p)*t(n))}function N(n,u,i){return o(t(n),r(n)*t(u)-e(i)*r(u))}function P(n,e,o){return u(t(e)*t(o)+r(e)*r(o)*r(n))}function E(n,t){return a*(280.16+360.9856235*n)-t}function I(n){return a*(357.5291+.98560028*n)}function O(n){return a*(1.9148*t(n)+.02*t(2*n)+3e-4*t(3*n))}function T(t,r){return t+r+102.9372*a+n}function g(n,t){var r=I(n),e=T(r,O(r));return t||(t={dec:0,ra:0}),t.dec=x(e,0),t.ra=h(e,0),t}var m={PolarException:{NORMAL:0,MIDNIGHT_SUN:1,POLAR_NIGHT:2},getPosition:function(n,t,r,e){var u=a*-r,o=a*t,i=l(n),c=g(i,s),f=E(i,u)-c.ra;return e||(e={azimuth:0,altitude:0}),e.azimuth=N(f,o,c.dec),e.altitude=P(f,o,c.dec),e}},A=[[-.83,"sunrise","sunset"]];m.addTime=function(n,t,r){A.push([n,t,r])};var L=9e-4;function R(t,r){return Math.round(t-L-r/(2*n))}function G(t,r,e){return L+(t+r)/(2*n)+e}function H(n,r,e){return d+n+.0053*t(r)-.0069*t(2*e)}function _(n,e,u){return i((t(n)-t(e)*t(u))/(r(e)*r(u)))}function z(n){var e=a*(134.963+13.064993*n),u=a*(93.272+13.22935*n),o=a*(218.316+13.176396*n)+6.289*a*t(e),i=5.128*a*t(u),c=385001-20905*r(e);return{ra:h(o,i),dec:x(o,i),dist:c}}return m.getTimes=function(n,e,u){var o=a*-u,i=a*e,c=R(l(n),o),f=G(0,o,c),d=I(f),s=O(d),v=T(d,s),p=x(v,0),h=H(f,d,v);function N(n){return H(G(_(n,i,p),o,c),d,v)}function P(n){var e=(t(n)-t(i)*t(p))/(r(i)*r(p));return e<-1?m.PolarException.MIDNIGHT_SUN:e>1?m.PolarException.POLAR_NIGHT:m.PolarException.NORMAL}var E,g,L,z,D,S={solarNoon:M(h),nadir:M(h-.5),polarException:m.PolarException.NORMAL};for(E=0,g=A.length;E<g;E+=1)D=h-((z=N((L=A[E])[0]*a))-h),S[L[1]]=M(D),S[L[2]]=M(z);return S.polarException=P(A[0][0]*a),S},m.getMoonPosition=function(n,t,r){var u=a*-r,o=a*t,i=l(n),c=z(i),f=E(i,u)-c.ra,d=P(f,o,c.dec);return d+=.017*a/e(d+10.26*a/(d+5.1*a)),{azimuth:N(f,o,c.dec),altitude:d,distance:c.dist}},m.getMoonFraction=function(n){var e=l(n),u=g(e),a=z(e),c=149598e3,f=i(t(u.dec)*t(a.dec)+r(u.dec)*r(a.dec)*r(u.ra-a.ra)),d=o(c*t(f),a.dist-c*r(f));return(1+r(d))/2},m},void 0!==(e=r())&&(t.exports=e);const o=u.exports;n.SunCalc=o}));
