/* eslint-disable */

!function(){"use strict";var b=Math.PI,d=Math.sin,e=Math.cos,f=Math.tan,g=Math.asin,h=Math.atan2,i=Math.acos,c=b/180;function j(a){return new Date((a+.5-2440588)*864e5)}function k(a){var b;return a.valueOf()/864e5-.5+2440588-2451545}var l=23.4397*c;function m(a,b){return h(d(a)*e(l)-f(b)*d(l),e(a))}function n(b,a){return g(d(a)*e(l)+e(a)*d(l)*d(b))}function o(a,b,c){return h(d(a),e(a)*d(b)-f(c)*e(b))}function p(c,a,b){return g(d(a)*d(b)+e(a)*e(b)*e(c))}function q(a,b){return c*(280.16+360.9856235*a)-b}function r(a){return c*(357.5291+.98560028*a)}function s(a){var e=c*(1.9148*d(a)+.02*d(2*a)+3e-4*d(3*a));return a+e+102.9372*c+b}function t(b){var c=r(b),a=s(c);return{dec:n(a,0),ra:m(a,0)}}var a={};a.getPosition=function(f,g,h){var b=c*g,d=k(f),a=t(d),e=q(d,-(c*h))-a.ra;return{azimuth:o(e,b,a.dec),altitude:p(e,b,a.dec)}};var u=a.times=[[-0.833,"sunrise","sunset"],[-0.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];function v(a,c,d){return 9e-4+(a+c)/(2*b)+d}function w(a,b,c){return 2451545+a+.0053*d(b)-.0069*d(2*c)}function x(f,g,h,j,k,l,m){var c,a,b,n=(c=f,a=h,b=j,i((d(c)-d(a)*d(b))/(e(a)*e(b)))),o=v(n,g,k);return w(o,l,m)}function y(a){var b=c*(134.963+13.064993*a),f=c*(218.316+13.176396*a)+6.289*c*d(b),g=5.128*c*d(c*(93.272+13.22935*a)),h=385001-20905*e(b);return{ra:m(f,g),dec:n(f,g),dist:h}}function z(a,b){return new Date(a.valueOf()+864e5*b/24)}a.addTime=function(a,b,c){u.push([a,b,c])},a.getTimes=function(y,z,A,e){e=e||0;var F,B,G,a,o,f,g,p,h=-(c*A),C=c*z,D=-2.076*Math.sqrt(e)/60,q=Math.round((B=k(y))-9e-4-h/(2*b)),t=v(0,h,q),i=r(t),l=s(i),E=n(l,0),d=w(t,i,l),m={solarNoon:j(d),nadir:j(d-.5)};for(a=0,o=u.length;a<o;a+=1)g=x(((f=u[a])[0]+D)*c,h,C,E,q,i,l),p=d-(g-d),m[f[1]]=j(p),m[f[2]]=j(g);return m},a.getMoonPosition=function(m,n,r){var b,s=-(c*r),i=c*n,l=k(m),a=y(l),g=q(l,s)-a.ra,j=p(g,i,a.dec),t=h(d(g),f(i)*e(a.dec)-d(a.dec)*e(g));return j+=((b=j)<0&&(b=0),2967e-7/Math.tan(b+.00312536/(b+.08901179))),{azimuth:o(g,i,a.dec),altitude:j,distance:a.dist,parallacticAngle:t}},a.getMoonIllumination=function(l){var c=k(l||new Date),a=t(c),b=y(c),f=i(d(a.dec)*d(b.dec)+e(a.dec)*e(b.dec)*e(a.ra-b.ra)),g=h(149598e3*d(f),b.dist-149598e3*e(f)),j=h(e(a.dec)*d(a.ra-b.ra),d(a.dec)*e(b.dec)-e(a.dec)*d(b.dec)*e(a.ra-b.ra));return{fraction:(1+e(g))/2,phase:.5+.5*g*(j<0?-1:1)/Math.PI,angle:j}},a.getMoonTimes=function(w,r,s,x){var e=new Date(w);x?e.setUTCHours(0,0,0,0):e.setHours(0,0,0,0);for(var m,n,f,g,h,i,j,o,t,k,b,l,v,u=.133*c,p=a.getMoonPosition(e,r,s).altitude-u,d=1;d<=24&&(m=a.getMoonPosition(z(e,d),r,s).altitude-u,n=a.getMoonPosition(z(e,d+1),r,s).altitude-u,h=(p+n)/2-m,i=(n-p)/2,j=-i/(2*h),o=(h*j+i)*j+m,t=i*i-4*h*m,k=0,t>=0&&(b=j-(v=Math.sqrt(t)/(2*Math.abs(h))),l=j+v,1>=Math.abs(b)&&k++,1>=Math.abs(l)&&k++,b< -1&&(b=l)),1===k?p<0?f=d+b:g=d+b:2===k&&(f=d+(o<0?l:b),g=d+(o<0?b:l)),!f||!g);d+=2)p=n;var q={};return f&&(q.rise=z(e,f)),g&&(q.set=z(e,g)),f||g||(q[o>0?"alwaysUp":"alwaysDown"]=!0),q},"object"==typeof exports&&"undefined"!=typeof module?module.exports=a:"function"==typeof define&&define.amd?define(a):window.SunCalc=a}()
