forked from ofrohn/d3-celestial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
celestial.min.js
5 lines (4 loc) · 79.5 KB
/
celestial.min.js
1
2
3
4
5
// Copyright 2015 Olaf Frohn https://github.com/ofrohn, see LICENSE
!function(){function t(t,e){function a(a,r){var i=t([a*=180/Math.PI,r*=180/Math.PI]),o=e([a,r]);return[(1-n)*i[0]+n*o[0],(n-1)*i[1]-n*o[1]]}var n,r=d3.geo.projection(a).scale(1),i=r.center,o=r.translate;return r.alpha=function(a){if(!arguments.length)return n;n=+a;var s=t.center(),l=e.center(),c=t.translate(),h=e.translate();return i([(1-n)*s[0]+n*l[0],(1-n)*s[1]+n*l[1]]),o([(1-n)*c[0]+n*h[0],(1-n)*c[1]+n*h[1]]),r},delete r.translate,delete r.center,r.alpha(0)}function e(t,e){var n=a(t.map(function(t){return t*K}),e);return n.map(function(t){return t/K})}function a(t,e){var a,n,r,i,o,s,l,c,h,u,p=1e-5;return e?(s=t[0],0>s&&(s+=Q),l=t[1],s-=e[0],i=e[1],o=e[2],a=Math.sin(l)*Math.sin(i)-Math.cos(l)*Math.cos(i)*Math.cos(s),Math.abs(a)<p&&(a=-Math.cos(l+i)+Math.cos(l)*Math.cos(i)*(1-Math.cos(s))),n=-Math.cos(l)*Math.sin(s),c=0!==a||0!==n?Math.atan2(n,a):s-Math.PI,h=o+c,h>Math.PI&&(h-=Q),s%Math.PI===0?(u=l+Math.cos(s)*i,u>Z&&(u=Math.PI-u),-Z>u&&(u=-Math.PI-u)):(r=Math.sin(l)*Math.cos(i)+Math.cos(l)*Math.sin(i)*Math.cos(s),Math.abs(r)>.99?(u=Math.abs(Math.acos(Math.sqrt(a*a+n*n))),0>r&&(u*=-1)):u=Math.asin(r)),[h,u]):t}function n(t,e){var a=t.getUTCFullYear(),n=t.getUTCMonth()+1,r=t.getUTCDate(),i=t.getUTCHours(),o=t.getUTCMinutes(),s=t.getUTCSeconds();(1==n||2==n)&&(a-=1,n+=12);var l=Math.floor(a/100),c=2-l+Math.floor(l/4),h=Math.floor(365.25*a),u=Math.floor(30.6001*(n+1)),p=c+h+u-730550.5+r+(i+o/60+s/3600)/24,d=p/36525,f=280.46061837+360.98564736629*p+387933e-9*d*d-d*d*d/3871e4+e;if(f>0)for(;f>360;)f-=360;else for(;0>f;)f+=360;return f}function r(t,a){return e(t,X[a])}function i(t,e){if("equatorial"===e)return t;for(var a=X[e],n=t.features,r=0;r<n.length;r++)n[r].geometry.coordinates=l(n[r],a);return t}function o(t){var e=[];for(var a in t)if(v(t,a)&&-1!==O.planets.which.indexOf(a)){var n=dt().id(a);v(t[a],"parent")&&n.parentBody(t[a].parent),n.elements(t[a].elements[0]),"ter"===a?W.origin=n:e.push(n)}return e.push(dt().id("sol")),e.push(dt().id("lun")),e}function s(t,e){for(var a={},n=(X[e],t.features),r=0;r<n.length;r++)a[n[r].id]={name:n[r].properties.name,center:n[r].properties.display.slice(0,2),scale:n[r].properties.display[2]};return a}function l(t,a){var n=[];switch(t.geometry.type){case"Point":n=e(t.geometry.coordinates,a);break;case"LineString":n.push(p(t.geometry.coordinates,a));break;case"MultiLineString":n=d(t.geometry.coordinates,a);break;case"Polygon":n.push(p(t.geometry.coordinates[0],a));break;case"MultiPolygon":n.push(d(t.geometry.coordinates[0],a))}return n}function c(t,e){var a=[];if(!e)return[];b(e)||(e=[e]);for(var n=0;n<e.length;n++)switch(e[n]){case"center":a=a.concat("lat"===t?u(t,O.center[0],"N"):u(t,O.center[1],"S"));break;case"outline":"lon"===t?(a=a.concat(u(t,O.center[1]-89.99,"S")),a=a.concat(u(t,O.center[1]+89.99),"N")):(a=a.concat(u(t,O.center[0]-179.99,"E")),a=a.concat(u(t,O.center[0]+179.99,"W")));break;default:if(y(e[n])){a=a.concat("lat"===t?u(t,e[n],"N"):u(t,e[n],"S"));break}}return h(a)}function h(t){for(var e=[],a=0;a<t.length;a++){var n={type:"Feature",id:a,properties:{},geometry:{type:"Point"}};n.properties.value=t[a].value,n.properties.orientation=t[a].orientation,n.geometry.coordinates=t[a].coordinates,e.push(n)}return e}function u(t,e,a){var n,r,i,o,s,l=t,c=[],h=e;"equatorial"===O.transform&&"lon"===l&&(l="ra"),"ra"===l?(n=0,r=23,i=1):"lon"===l?(n=0,r=350,i=10):(n=-80,r=80,i=10);for(var u=n;r>=u;u+=i){var p=a;"lat"===l?(s=[h,u],o=u.toString()+"°",p+=0>u?"S":"N"):"ra"===l?(s=[15*u,h],o=u.toString()+"ʰ"):(s=[u,h],o=u.toString()+"°"),c.push({coordinates:s,value:o,orientation:p})}return c}function p(t,a){for(var n=[],r=0;r<t.length;r++)n.push(e(t[r],a));return n}function d(t,e){for(var a=[],n=0;n<t.length;n++)a.push(p(t[n],e));return a}function f(t){return document.getElementById(t)}function m(t){return t+"px"}function M(t,e){return Math.round(Math.pow(10,e)*t)/Math.pow(10,e)}function g(t){return 10>t?"0"+t:t}function v(t,e){return null!==t&&hasOwnProperty.call(t,e)}function y(t){return!isNaN(parseFloat(t))&&isFinite(t)}function b(t){return"[object Array]"===Object.prototype.toString.call(t)}function w(t){var e=0,a=0;if(t.offsetParent)do e+=t.offsetLeft,a+=t.offsetTop;while(null!==(t=t.offsetParent));return[e,a]}function x(t,e){for(;t.parentNode;){if(t.id===e)return!0;t=t.parentNode}return!1}function k(t,e,a){var n=e.valueOf()-t.valueOf(),r=a||"d";switch(r){case"y":case"yr":n/=31556926080;break;case"m":case"mo":n/=26298e5;break;case"d":case"dy":n/=864e5;break;case"h":case"hr":n/=36e5;break;case"n":case"mn":n/=6e4;break;case"s":case"sec":n/=1e3;break;case"ms":}return Math.floor(n)}function z(t){if(t){var e=t.split(".");if(!(e.length<1)&&(e=e[0].split("-"),e[0]=e[0].replace(/\D/g,""),e[0]))return e[1]=e[1]?e[1].replace(/\D/g,""):"1",e[2]=e[2]?e[2].replace(/\D/g,""):"1",new Date(Date.UTC(e[0],e[1]-1,e[2]))}}function P(t,e){return t=(t*K+Q)%Q,e=(e*K+Q)%Q,Math.abs(t-e)>Math.PI&&(t>e?t-=Q:e>t&&(e-=Q)),d3.interpolateNumber(t/K,e/K)}function I(t){function e(){var t=this,e=t.value;j(t)!==!1&&(c.width=e,W.resize({width:e}))}function a(){var t=this,e=t.value,a=D(e,c.transform);null!==a&&(c.center[0]=a),c.transform=e,W.reload({transform:e})}function n(){var t=this;t&&(c.projection=t.value,W.reproject(c))}function r(){j(this)!==!1&&i()!==!1&&W.rotate(c)}function i(){var t=f("centerx"),e=f("centery"),a=f("centerz");if(t&&e){if("equatorial"!==c.transform)c.center[0]=parseFloat(t.value);else{var n=parseFloat(t.value);c.center[0]=n>12?15*n-360:15*n}c.center[1]=parseFloat(e.value);var r=parseFloat(a.value);return c.center[2]=isNaN(r)?0:r,""!==t.value&&""!==e.value}}function o(){var t=this.value,e=[];if(""===t)return W.constellation=null,void W.redraw();var a=W.constellations[t];c.center=a.center,E(c.center,c.transform);var n=W.zoomBy();1!==n&&e.push({param:"zoom",value:1/n,duration:0}),e.push({param:"center",value:a.center,duration:0});var r=a.scale>10?10:a.scale;e.push({param:"zoom",value:r,duration:0}),W.constellation=t,W.animate(e,!1)}function s(){var t,e=this;switch(e.type){case"checkbox":t=e.checked,q(e);break;case"number":if(j(e)===!1)return;t=parseFloat(e.value);break;case"color":if(A(e)===!1)return;t=e.value;break;case"text":if(-1===e.id.search(/fill$/))return;if(A(e)===!1)return;t=e.value}null!==t&&(l(e.id,t),i(),W.apply(c))}function l(t,e){var a=t.split("-");switch(a.length){case 1:c[a[0]]=e;break;case 2:c[a[0]][a[1]]=e;break;case 3:c[a[0]][a[1]][a[2]]=e;break;default:return}}var c=et.set(t),h=W.projections(),u=W.eulerAngles(),p=d3.select("#celestial-form").append("div").attr("class","ctrl"),d=p.append("form").attr("id","params").attr("name","params").attr("method","get").attr("action","#"),m=d.append("div").attr("class","col").attr("id","general");m.append("label").attr("title","Map width in pixel, 0 indicates full width").attr("for","width").html("Width "),m.append("input").attr("type","number").attr("maxlength","4").attr("max","20000").attr("min","0").attr("title","Map width").attr("id","width").attr("value",c.width).on("change",e),m.append("span").html("px"),m.append("label").attr("title","Map projection, (hemi) indicates hemispherical projection").attr("for","projection").html("Projection");var M=m.append("select").attr("id","projection").on("change",n),g=0,v=Object.keys(h).map(function(t,e){var a=h[t].clip&&h[t].clip===!0?h[t].n+" (hemi)":h[t].n;return t===c.projection&&(g=e),{o:t,n:a}});M.selectAll("option").data(v).enter().append("option").attr("value",function(t){return t.o}).text(function(t){return t.n}),M.property("selectedIndex",g),g=0,m.append("label").attr("title","Coordinate space in which the map is displayed").attr("for","transform").html("Coordinates"),M=m.append("select").attr("id","transform").on("change",a),v=Object.keys(u).map(function(t,e){return t===c.transform&&(g=e),{o:t,n:t.replace(/^([a-z])/,function(t,e){return e.toUpperCase()})}}),M.selectAll("option").data(v).enter().append("option").attr("value",function(t){return t.o}).text(function(t){return t.n}),M.property("selectedIndex",g),m.append("br"),m.append("label").attr("title","Center coordinates long/lat in selected coordinate space").attr("for","centerx").html("Center"),m.append("input").attr("type","number").attr("id","centerx").attr("title","Center right ascension/longitude").attr("max","24").attr("min","0").attr("step","0.1").on("change",r),m.append("span").attr("id","cxunit").html("h"),m.append("input").attr("type","number").attr("id","centery").attr("title","Center declination/latitude").attr("max","90").attr("min","-90").attr("step","0.1").on("change",r),m.append("span").html("°"),m.append("label").attr("title","Orientation").attr("for","centerz").html("Orientation"),m.append("input").attr("type","number").attr("id","centerz").attr("title","Center orientation").attr("max","180").attr("min","-180").attr("step","0.1").on("change",r),m.append("span").html("°"),m.append("label").attr("for","orientationfixed").html("Fixed"),m.append("input").attr("type","checkbox").attr("id","orientationfixed").property("checked",c.orientationfixed).on("change",s),m.append("label").attr("title","Center and zoom in on this constellation").attr("for","constellation").html("Show"),m.append("select").attr("id","constellation").on("change",o),E(c.center,c.transform),m=d.append("div").attr("class","col").attr("id","stars"),m.append("label").attr("class","header").attr("for","stars-show").html("Stars"),m.append("input").attr("type","checkbox").attr("id","stars-show").property("checked",c.stars.show).on("change",s),m.append("label").attr("for","stars-limit").html("down to magnitude"),m.append("input").attr("type","number").attr("id","stars-limit").attr("title","Star display limit (magnitude)").attr("value",c.stars.limit).attr("max","6").attr("min","-1").attr("step","0.1").on("change",s),m.append("label").attr("for","stars-colors").html("with spectral colors"),m.append("input").attr("type","checkbox").attr("id","stars-colors").property("checked",c.stars.colors).on("change",s),m.append("label").attr("for","stars-color").html("or default color "),m.append("input").attr("type","color").attr("autocomplete","off").attr("id","stars-style-fill").attr("title","Star color").property("value",c.stars.style.fill).on("change",s),m.append("br"),m.append("label").attr("for","stars-names").html("Show designations"),m.append("input").attr("type","checkbox").attr("id","stars-names").property("checked",c.stars.names).on("change",s),m.append("label").attr("for","stars-namelimit").html("down to mag"),m.append("input").attr("type","number").attr("id","stars-namelimit").attr("title","Star designaton display limit (magnitude)").attr("value",c.stars.namelimit).attr("max","6").attr("min","-1").attr("step","0.1").on("change",s),m.append("label").attr("for","stars-desig").attr("title","include HD/HIP designations").html("all"),m.append("input").attr("type","checkbox").attr("id","stars-desig").property("checked",c.stars.desig).on("change",s),m.append("label").attr("for","stars-proper").html("proper names"),m.append("input").attr("type","checkbox").attr("id","stars-proper").property("checked",c.stars.proper).on("change",s),m.append("label").attr("for","stars-propernamelimit").html("down to mag"),m.append("input").attr("type","number").attr("id","stars-propernamelimit").attr("title","Star name display limit (magnitude)").attr("value",c.stars.propernamelimit).attr("max","6").attr("min","-1").attr("step","0.1").on("change",s),m.append("br"),m.append("label").attr("for","stars-size").html("Stellar disk size: base"),m.append("input").attr("type","number").attr("id","stars-size").attr("title","Size of the displayed star disk; base").attr("value",c.stars.size).attr("max","100").attr("min","0").attr("step","0.1").on("change",s),m.append("label").attr("for","stars-exponent").html(" * e ^ (exponent"),m.append("input").attr("type","number").attr("id","stars-exponent").attr("title","Size of the displayed star disk; exponent").attr("value",c.stars.exponent).attr("max","3").attr("min","-1").attr("step","0.01").on("change",s),m.append("span").text(" * (magnitude + 2)) [* adaptation]"),q(f("stars-show")),m=d.append("div").attr("class","col").attr("id","dsos"),m.append("label").attr("class","header").attr("title","Deep Space Objects").attr("for","dsos-show").html("DSOs"),m.append("input").attr("type","checkbox").attr("id","dsos-show").property("checked",c.dsos.show).on("change",s),m.append("label").attr("for","dsos-limit").html("down to mag"),m.append("input").attr("type","number").attr("id","dsos-limit").attr("title","DSO display limit (magnitude)").attr("value",c.dsos.limit).attr("max","6").attr("min","0").attr("step","0.1").on("change",s),m.append("label").attr("for","dsos-names").html("with names"),m.append("input").attr("type","checkbox").attr("id","dsos-names").property("checked",c.dsos.names).on("change",s),m.append("label").attr("for","dsos-desig").html("or designations"),m.append("input").attr("type","checkbox").attr("id","dsos-desig").property("checked",c.dsos.desig).on("change",s),m.append("label").attr("for","dsos-namelimit").html("down to mag"),m.append("input").attr("type","number").attr("id","dsos-namelimit").attr("title","DSO name display limit (magnitude)").attr("value",c.dsos.namelimit).attr("max","6").attr("min","0").attr("step","0.1").on("change",s),m.append("br"),m.append("label").attr("for","dsos-size").html("DSO symbol size: (base"),m.append("input").attr("type","number").attr("id","dsos-size").attr("title","Size of the displayed symbol: base").attr("value",c.dsos.size).attr("max","100").attr("min","0").attr("step","0.1").on("change",s),m.append("label").attr("for","dsos-exponent").html(" * 2 [* adaptation] - magnitude) ^ exponent"),m.append("input").attr("type","number").attr("id","dsos-exponent").attr("title","Size of the displayed symbol; exponent").attr("value",c.dsos.exponent).attr("max","3").attr("min","-1").attr("step","0.01").on("change",s),q(f("dsos-show")),m=d.append("div").attr("class","col").attr("id","constellations"),m.append("label").attr("class","header").html("Constellations"),m.append("label").attr("for","constellations-names").html("Show names"),m.append("input").attr("type","checkbox").attr("id","constellations-names").property("checked",c.constellations.names).on("change",s),m.append("label").attr("for","constellations-desig").html("abbreviated"),m.append("input").attr("type","checkbox").attr("id","constellations-desig").property("checked",c.constellations.desig).on("change",s),m.append("label").attr("for","constellations-lines").html("with lines"),m.append("input").attr("type","checkbox").attr("id","constellations-lines").property("checked",c.constellations.lines).on("change",s),m.append("label").attr("for","constellations-bounds").html("with boundaries"),m.append("input").attr("type","checkbox").attr("id","constellations-bounds").property("checked",c.constellations.bounds).on("change",s),q(f("constellations-names")),m=d.append("div").attr("class","col").attr("id","lines"),m.append("label").attr("class","header").html("Lines"),m.append("label").attr("title","Laitudet/longitude grid lines").attr("for","lines-graticule").html("Graticule"),m.append("input").attr("type","checkbox").attr("id","lines-graticule-show").property("checked",c.lines.graticule.show).on("change",s),m.append("label").attr("for","lines-equatorial").html("Equator"),m.append("input").attr("type","checkbox").attr("id","lines-equatorial-show").property("checked",c.lines.equatorial.show).on("change",s),m.append("label").attr("for","lines-ecliptic").html("Ecliptic"),m.append("input").attr("type","checkbox").attr("id","lines-ecliptic-show").property("checked",c.lines.ecliptic.show).on("change",s),m.append("label").attr("for","lines-galactic").html("Galactic plane"),m.append("input").attr("type","checkbox").attr("id","lines-galactic-show").property("checked",c.lines.galactic.show).on("change",s),m.append("label").attr("for","lines-supergalactic").html("Supergalactic plane"),m.append("input").attr("type","checkbox").attr("id","lines-supergalactic-show").property("checked",c.lines.supergalactic.show).on("change",s),m=d.append("div").attr("class","col").attr("id","other"),m.append("label").attr("class","header").html("Other"),m.append("label").attr("for","mw-show").html("Milky Way"),m.append("input").attr("type","checkbox").attr("id","mw-show").property("checked",c.mw.show).on("change",s),m.append("label").attr("for","mw-style-fill").html(" color"),m.append("input").attr("type","color").attr("id","mw-style-fill").attr("title","Milky Way color").attr("value",c.mw.style.fill).on("change",s),m.append("label").attr("for","mw-style-opacity").html(" opacity"),m.append("input").attr("type","number").attr("id","mw-style-opacity").attr("title","Transparency of each Milky Way layer").attr("value",c.mw.style.opacity).attr("max","1").attr("min","0").attr("step","0.01").on("change",s),m.append("br"),m.append("label").attr("for","background").html("Background color"),m.append("input").attr("type","color").attr("id","background-fill").attr("title","Background color").attr("value",c.background.fill).on("change",s),m.append("label").attr("title","Star/DSO sizes are increased with higher zoom-levels").attr("for","adaptable").html("Adaptable object sizes"),m.append("input").attr("type","checkbox").attr("id","adaptable").property("checked",c.adaptable).on("change",s),C(),D(c.transform)}function q(t){var e,a=t.id;switch(a){case"stars-show":e=!f(a).checked;for(var n=0;n<ot[a].length;n++)T(ot[a][n],e);case"stars-names":for(e=!f("stars-names").checked||!f("stars-show").checked,n=0;n<ot["stars-names"].length;n++)T(ot["stars-names"][n],e);case"stars-proper":for(e=!f("stars-names").checked||!f("stars-show").checked||!f("stars-proper").checked,n=0;n<ot["stars-proper"].length;n++)T(ot["stars-proper"][n],e);break;case"dsos-show":for(e=!f(a).checked,n=0;n<ot[a].length;n++)T(ot[a][n],e);case"dsos-names":for(e=!f("dsos-names").checked||!f("dsos-show").checked,n=0;n<ot["dsos-names"].length;n++)T(ot["dsos-names"][n],e);break;case"constellations-show":for(e=!f(a).checked,n=0;n<ot[a].length;n++)T(ot[a][n],e);break;case"mw-show":for(e=!f(a).checked,n=0;n<ot[a].length;n++)T(ot[a][n],e)}}function T(t,e){var a=f(t);a.disabled=e,a.previousSibling.style.color=e?"#999":"#000"}function S(t,e){var a=w(t);d3.select("#error").html(e).style({top:m(a[1]+t.offsetHeight+1),left:m(a[0]),opacity:1}),t.focus()}function j(t){var e,a="hr"===t.id||"min"===t.id||"sec"===t.id?1:0;if(t.validity){if(e=t.validity,e.typeMismatch||e.badInput)return S(t,t.title+": check field value"),!1;if(e.rangeOverflow||e.rangeUnderflow)return S(t,t.title+" must be between "+(parseInt(t.min)+a)+" and "+(parseInt(t.max)-a)),!1}else{if(e=t.value,!y(e))return S(t,t.title+": check field value"),!1;if(e=parseFloat(e),e<t.min||e>t.max)return S(t,t.title+" must be between "+(t.min+a)+" and "+(+t.max-a)),!1}return d3.select("#error").style({top:"-9999px",left:"-9999px",opacity:0}),!0}function A(t){var e;if(t.validity){if(e=t.validity,e.typeMismatch||e.badInput)return S(t,t.title+": check field value"),!1;if(-1===t.value.search(/^#[0-9A-F]{6}$/i))return S(t,t.title+": not a color value"),!1}else{if(e=t.value,""===e)return!0;if(-1===e.search(/^#[0-9A-F]{6}$/i))return S(t,t.title+": not a color value"),!1}return d3.select("#error").style({top:"-9999px",left:"-9999px",opacity:0}),!0}function D(t,e){var a=f("centerx");return a?(e&&("equatorial"===t&&"equatorial"!==e?(a.value=(a.value/15).toFixed(1),a.value<0&&(a.value+=24)):"equatorial"!==t&&"equatorial"===e&&(a.value=(15*a.value).toFixed(1),a.value>180&&(a.value-=360))),"equatorial"===t?(a.min="0",a.max="24",f("cxunit").innerHTML="h"):(a.min="-180",a.max="180",f("cxunit").innerHTML="°"),a.value):null}function E(t,e){var a=f("centerx"),n=f("centery"),r=f("centerz");a&&n&&(null===t&&(t=[0,0,0]),t.length<=2&&(t[2]=0),a.value="equatorial"!==e?t[0].toFixed(1):t[0]<0?(t[0]/15+24).toFixed(1):(t[0]/15).toFixed(1),n.value=t[1].toFixed(1),r.value=null!==t[2]?t[2].toFixed(1):0)}function C(){var t,e,a,n=/\d+(\.\d+)?/g,r={s:6,d:6},i=W.settings();return a=i.dsos.data,t=a.match(n),null!==t&&(r.d=parseFloat(t[t.length-1])),6!=r.d&&(f("dsos-limit").max=r.d,f("dsos-namelimit").max=r.d),e=i.stars.data,t=e.match(n),null!==t&&(r.s=parseFloat(t[t.length-1])),6!=r.s&&(f("stars-limit").max=r.s,f("stars-namelimit").max=r.s),r}function F(t){function e(){h.setTime(Date.now()),f("datetime").value=r(h,u),i()}function a(){navigator.geolocation.getCurrentPosition(function(t){c=[M(t.coords.latitude,4),M(t.coords.longitude,4)],f("lat").value=c[0],f("lon").value=c[1],i()})}function n(){p.show(h)}function r(t,e){var a;if(e&&"0"!==e){var n=Math.floor(Math.abs(e)/60),r=Math.abs(e)-60*n,i=0>e?" +":" −";a=i+g(n)+g(r)}else a=" ±0000";return s(t)+a}function i(){var e=f("lon").value,a=f("lat").value;h=s.parse(f("datetime").value.slice(0,-6));var n=h.getTimezoneOffset(),r=new Date(h.valueOf()+6e4*(u-n));t.horizon.show=!!f("horizon-show").checked,t.planets.show=!!f("planets-show").checked,""!==e&&""!==a&&(c=[parseFloat(a),parseFloat(e)],l=W.getPoint(tt.inverse(r,[90,0],c),t.transform),l[2]=0,"zenith"===t.follow?W.rotate({center:l,horizon:t.horizon}):W.apply({horizon:t.horizon}))}var o=d3.select("#celestial-form").append("div").attr("id","loc"),s=d3.time.format("%Y-%m-%d %H:%M:%S"),l=[0,0],c=[0,0],h=new Date,u=h.getTimezoneOffset(),p=new mt(t,function(t,e){f("datetime").value=r(t,e),u=e,i()});v(t,"geopos")&&null!==t.geopos&&2===t.geopos.length&&(c=t.geopos);var d=o.append("div").attr("class","col").attr("id","location");d.append("label").attr("title","Location coordinates long/lat").attr("for","lat").html("Location"),d.append("input").attr("type","number").attr("id","lat").attr("title","Latitude").attr("placeholder","Latitude").attr("max","90").attr("min","-90").attr("step","0.0001").attr("value",c[0]).on("change",function(){j(this)===!0&&i()}),d.append("span").html("°"),d.append("input").attr("type","number").attr("id","lon").attr("title","Longitude").attr("placeholder","Longitude").attr("max","180").attr("min","-180").attr("step","0.0001").attr("value",c[1]).on("change",function(){j(this)===!0&&i()}),d.append("span").html("°"),"geolocation"in navigator&&d.append("input").attr("type","button").attr("value","Here").attr("id","here").on("click",a),d.append("label").attr("title","Local date/time").attr("for","datetime").html(" Date/time"),d.append("input").attr("type","button").attr("id","day-left").attr("title","One day back").on("click",function(){h.setDate(h.getDate()-1),f("datetime").value=r(h,u),i()}),d.append("input").attr("type","text").attr("id","datetime").attr("title","Date and time").attr("value",r(h,u)).on("click",n,!0).on("input",function(){this.value=r(h,u),p.isVisible()||n()}),d.append("div").attr("id","datepick").on("click",n),d.append("input").attr("type","button").attr("id","day-right").attr("title","One day forward").on("click",function(){h.setDate(h.getDate()+1),f("datetime").value=r(h,u),i()}),d.append("input").attr("type","button").attr("value","Now").attr("id","now").on("click",e),d.append("br"),d.append("label").attr("title","Show horizon marker").attr("for","horizon-show").html(" Horizon marker"),d.append("input").attr("type","checkbox").attr("id","horizon-show").property("checked",t.horizon.show).on("change",i),d.append("label").attr("title","Show solar system objects").attr("for","planets-show").html(" Planets, Sun & Moon"),d.append("input").attr("type","checkbox").attr("id","planets-show").property("checked",t.planets.show).on("change",i),d3.select(document).on("mousedown",function(){!x(d3.event.target,"celestial-date")&&p.isVisible()&&p.hide()}),W.getPosition=function(){},W.date=function(t){return t?void(p.isVisible()||(h.setTime(t.valueOf()),f("datetime").value=r(t,u),W.redraw())):h},W.position=function(){return c},W.zenith=function(){return l},W.nadir=function(){var t=-l[1],e=l[0]+180;return e>180&&(e-=360),[e,t-.001]},setTimeout(i,1e3)}var O,L,N,H,U,W={version:"0.6.8",container:null,data:[]},_=.035,G=1.4,V=2e3,B=2500,Y=1500,R=10;W.display=function(a){function n(){for(var t in O.lines)v(O.lines,t)&&("graticule"===t?(Mt.append("path").datum(Nt).attr("class","graticule"),v(O.lines.graticule,"lon")&&O.lines.graticule.lon.pos.length>0&&Mt.selectAll(".gridvalues_lon").data(c("lon",O.lines.graticule.lon.pos)).enter().append("path").attr("class","graticule_lon"),v(O.lines.graticule,"lat")&&O.lines.graticule.lat.pos.length>0&&Mt.selectAll(".gridvalues_lat").data(c("lat",O.lines.graticule.lat.pos)).enter().append("path").attr("class","graticule_lat")):Mt.append("path").datum(d3.geo.circle().angle([90]).origin(e(J[t],X[Pt]))).attr("class",t));d3.json(Ft+"mw.json",function(t,e){if(t)return window.alert("Your Browser doesn't support local file loading or the file doesn't exist. See readme.md"),console.warn(t);var a=i(e,Pt);Mt.selectAll(".mway").data(a.features).enter().append("path").attr("class","mw"),d()}),d3.json(Ft+"constellations.json",function(t,e){if(t)return console.warn(t);var n=i(e,Pt);Mt.selectAll(".constnames").data(n.features).enter().append("text").attr("class","constname");var r=s(e,Pt);if(f("constellation")){var o=d3.select("#constellation"),l=0,c=Object.keys(r).map(function(t,e){return t===a.constellation&&(l=e),{o:t,n:r[t].name}});c=[{o:"",n:"(Select constellation)"}].concat(c),o.selectAll("option").data(c).enter().append("option").attr("value",function(t){return t.o}).text(function(t){return t.n}),o.property("selectedIndex",l)}W.constellations=r,d()}),d3.json(Ft+"constellations.bounds.json",function(t,e){if(t)return console.warn(t);var a=i(e,Pt);Mt.selectAll(".bounds").data(a.features).enter().append("path").attr("class","boundaryline"),d()}),d3.json(Ft+"constellations.lines.json",function(t,e){if(t)return console.warn(t);var a=i(e,Pt);Mt.selectAll(".lines").data(a.features).enter().append("path").attr("class","constline"),d()}),d3.json(Ft+O.stars.data,function(t,e){if(t)return console.warn(t);var a=i(e,Pt);Mt.selectAll(".stars").data(a.features).enter().append("path").attr("class","star"),d()}),d3.json(Ft+O.dsos.data,function(t,e){if(t)return console.warn(t);var a=i(e,Pt);Mt.selectAll(".dsos").data(a.features).enter().append("path").attr("class","dso"),d()}),d3.json(Ft+"planets.json",function(t,e){if(t)return console.warn(t);var a=o(e,Pt);Mt.selectAll(".planets").data(a).enter().append("path").attr("class","planet"),d()}),W.data.length>0&&W.data.forEach(function(t){v(t,"file")?d3.json(t.file,t.callback):setTimeout(t.callback,0)},this)}function r(t){if(t&&1!==t){var e=L.scale(),a=e*t,n=N.scaleExtent(),r=Y*Math.sqrt(Math.abs(1-t));a<n[0]&&(a=n[0]),a>n[1]&&(a=n[1]);var i=d3.interpolateNumber(e,a);return d3.select({}).transition().duration(r).tween("scale",function(){return function(t){var e=i(t);L.scale(e),d()}}).transition().duration(0).tween("scale",function(){N.scale(a),d()}),r}}function l(t){O=O.set(t),d()}function h(t){var e,a,n,r=O.center,i=L.rotate(),o=L.scale(),s=V,l=!1,c=O.orientationfixed;M(i[1],1)===-M(t.center[1],1)&&(l=!0),O=O.set(t);var h=M(d3.geo.distance(r,O.center),2),u=d3.geo.distance([r[2],0],[O.center[2],0]);return _>h&&_>u?(Ct=ut(O.center),L.rotate(Ct),d()):(a=o>Tt*G?d3.interpolateNumber(o,Tt):function(){return o},n=0===u?function(){return i[2]}:P(r[2],O.center[2]),h>3.14&&(O.center[0]-=.01),O.orientationfixed=!1,e=0===h?function(){return O.center}:d3.geo.interpolate(r,O.center),s=0!==h?s*h:s*u,d3.select({}).transition().duration(s).tween("center",function(){return function(t){var r=ut(e(t));r[2]=n(t);var o=a(.5>t?t:1-t);l&&(r[1]=i[1]),L.scale(o),L.rotate(r),d()}}).transition().duration(0).tween("center",function(){O.orientationfixed=c,Ct=ut(O.center),L.rotate(Ct),d()})),s}function u(t){kt=ct(),(O.width!==kt||t)&&(qt=kt/It,Tt=zt.scale*kt/1024,Ot.attr("width",kt).attr("height",qt),N.scaleExtent([Tt,Tt*R]).scale(Tt),L.translate([kt/2,qt/2]).scale(Tt),bt&&(bt.style.height=m(qt)),d())}function p(e){var a=ht(e.projection);if(a){var n=L.rotate(),i=L.center(),o=L.scale(),s=N.scaleExtent(),l=W.projection(O.projection).center(i).translate([kt/2,qt/2]).scale([s[0]]),c=B,h=0,u=d3.interpolateNumber(It,a.ratio);zt.clip!=a.clip&&(c=0);var f=W.projection(e.projection).center(i).translate([kt/2,kt/a.ratio/2]).scale([a.scale*kt/1024]),M=O.adaptable;return o>s[0]?(h=r(.1),setTimeout(p,h,e),h+c):(O.location&&T("horizon-show",a.clip),L=t(l,f),O.adaptable=!1,d3.select({}).transition().duration(c).tween("projection",function(){return function(t){L.alpha(t).rotate(n),H.projection(L),q(a.clip),It=u(t),qt=kt/It,Ot.attr("width",kt).attr("height",qt),bt&&(bt.style.height=m(qt)),d()}}).transition().duration(0).tween("projection",function(){zt=a,It=zt.ratio,qt=kt/zt.ratio,Tt=zt.scale*kt/1024,Ot.attr("width",kt).attr("height",qt),bt&&(bt.style.height=m(qt)),O.projection=e.projection,L=W.projection(e.projection).rotate(n).translate([kt/2,qt/2]).scale(Tt),H.projection(L),q(zt.clip),N.projection(L).scaleExtent([Tt,Tt*R]).scale(Tt),O.adaptable=M,d()}),c)}}function d(){var t=L.rotate();O.adaptable&&(Et=Math.sqrt(L.scale()/Tt)),Et||(Et=1),St=O.stars.size,At=O.stars.exponent,jt=O.dsos.size||St,Dt=O.dsos.exponent,O.orientationfixed&&(t[2]=O.center[2],L.rotate(t)),O.center=[-t[0],-t[1],t[2]],E(O.center,O.transform),lt(),g(),O.mw.show&&Mt.selectAll(".mw").each(function(t){w(O.mw.style),H(t),Lt.fill()});for(var e in O.lines)v(O.lines,e)&&O.lines[e].show===!0&&(w(O.lines[e]),Mt.selectAll("."+e).attr("d",H),Lt.stroke());if(v(O.lines.graticule,"lon")&&(x(O.lines.graticule.lon),Mt.selectAll(".graticule_lon").each(function(t){if(y(t.geometry.coordinates)){var e=L(t.geometry.coordinates);st(e,t.properties.orientation),Lt.fillText(t.properties.value,e[0],e[1])}})),v(O.lines.graticule,"lat")&&(x(O.lines.graticule.lat),Mt.selectAll(".graticule_lat").each(function(t){if(y(t.geometry.coordinates)){var e=L(t.geometry.coordinates);st(e,t.properties.orientation),Lt.fillText(t.properties.value,e[0],e[1])}})),g(!0),O.constellations.show&&(O.constellations.bounds&&(Mt.selectAll(".boundaryline").each(function(t){w(O.constellations.boundstyle),W.constellation&&W.constellation===t.id&&(Lt.lineWidth*=1.5,Lt.setLineDash([])),H(t),Lt.stroke()}),g(!0)),O.constellations.names&&(x(O.constellations.namestyle),Mt.selectAll(".constname").each(function(t){if(y(t.geometry.coordinates)){k(t.properties.rank,O.constellations.namestyle.font);var e=L(t.geometry.coordinates);Lt.fillText(ot(t),e[0],e[1])}})),O.constellations.lines&&Mt.selectAll(".constline").each(function(t){w(O.constellations.linestyle),H(t),Lt.stroke()})),O.stars.show&&(w(O.stars.style),Mt.selectAll(".star").each(function(t){if(y(t.geometry.coordinates)&&t.properties.mag<=O.stars.limit){var e=L(t.geometry.coordinates),a=tt(t);Lt.fillStyle=it(t),Lt.beginPath(),Lt.arc(e[0],e[1],a,0,2*Math.PI),Lt.closePath(),Lt.fill(),O.stars.names&&t.properties.mag<=O.stars.namelimit*Et&&(x(O.stars.namestyle),Lt.fillText(Q(t),e[0]+a,e[1])),O.stars.proper&&t.properties.mag<=O.stars.propernamelimit*Et&&(x(O.stars.propernamestyle),Lt.fillText(K(t),e[0]-a,e[1]))}})),O.dsos.show&&Mt.selectAll(".dso").each(function(t){if(y(t.geometry.coordinates)&&S(t.properties,O.dsos.limit)){var e=L(t.geometry.coordinates),a=t.properties.type;w(O.dsos.symbols[a]);var n=j(t,e);v(O.dsos.symbols[a],"stroke")?Lt.stroke():Lt.fill(),O.dsos.names&&S(t.properties,O.dsos.namelimit)&&(x(O.dsos.namestyle),Lt.fillStyle=O.dsos.symbols[a].fill,Lt.fillText(C(t),e[0]+n,e[1]-n))}}),O.location&&"equatorial"===O.transform&&O.planets.show&&W.origin){var a=W.date(),n=W.origin(a).spherical();Mt.selectAll(".planet").each(function(t){var e=t.id(),r=t(a).equatorial(n);if(y(r.pos)){var i=L(r.pos),o=O.planets.symbols[e];"lun"!==e?(x(O.planets.style),Lt.fillStyle=o.fill,Lt.fillText(o.symbol,i[0],i[1])):rt.symbol().type("crescent").size(144).age(r.age).position(i)(Lt)}})}W.data.length>0&&W.data.forEach(function(t){t.redraw()}),O.location&&O.horizon.show&&!zt.clip&&(U.origin(W.nadir()),w(O.horizon),Mt.selectAll(".horizon").datum(U).attr("d",H),Lt.fill(),O.horizon.stroke&&Lt.stroke()),O.controls&&z(L.scale())}function g(t){var e=L.rotate();L.rotate([0,0]),
w(O.background),Mt.selectAll(".outline").attr("d",H),t===!0?Lt.stroke():Lt.fill(),L.rotate(e)}function y(t){return zt.clip&&d3.geo.distance(O.center,t)>Z?0:1}function w(t){Lt.fillStyle=t.fill||null,Lt.strokeStyle=t.stroke||null,Lt.lineWidth=t.width||null,Lt.globalAlpha=t.opacity||1,Lt.font=t.font||null,Lt.setLineDash(v(t,"dash")?t.dash:[]),Lt.beginPath()}function x(t){Lt.fillStyle=t.fill,Lt.textAlign=t.align||"left",Lt.textBaseline=t.baseline||"bottom",Lt.globalAlpha=t.opacity||1,Lt.font=t.font}function k(t,e){Lt.font=b(e)?1===e.length?e[0]:t>e.length?e[e.length-1]:e[t-1]:e}function z(t){var e=f("celestial-zoomin"),a=f("celestial-zoomout");e&&a&&(e.disabled=t>=Tt*R*.99,a.disabled=Tt>=t)}function q(t){t?(L.clipAngle(90),Mt.selectAll(".outline").remove(),Mt.append("path").datum(d3.geo.circle().angle([90])).attr("class","outline")):(L.clipAngle(null),Mt.selectAll(".outline").remove(),Mt.append("path").datum(Nt.outline).attr("class","outline"))}function S(t,e){return 999===t.mag&&Math.sqrt(parseInt(t.dim))>e||999!==t.mag&&t.mag<=e}function j(t,e){var a=t.properties,n=D(a)||9,r=A(a.type);return rt.symbol().type(r).size(n).position(e)(Lt),Math.sqrt(n)/2}function A(t){return t&&v(O.dsos.symbols,t)?O.dsos.symbols[t].shape:"circle"}function D(t){return t.mag&&999!==t.mag?Math.pow(2*jt*Et-t.mag,Dt):Math.pow(parseInt(t.dim)*jt*Et/7,.5)}function C(t){var e=t.properties;if(""!==e.name)return O.dsos.desig&&e.desig?e.desig:e.name}function Q(t){var e=t.properties.desig;return O.stars.desig?e:e.replace(/^(HD|HIP|V\d{3}).+/,"")}function K(t){var e=t.properties.name;return e}function tt(t){var e=t.properties.mag;if(null===e)return.1;var a=St*Et*Math.exp(At*(e+2));return Math.max(a,.1)}function it(t){var e=t.properties.bv;return!O.stars.colors||isNaN(e)?O.stars.style.fill:at(e)}function ot(t){return O.constellations.desig?t.properties.desig:t.properties[O.lang]}function st(t,e){for(var a=e.split(""),n="center",r="middle",i=a.length-1;i>=0;i--)switch(a[i]){case"N":r="bottom";break;case"S":r="top";break;case"E":n="left",t[0]+=2;break;case"W":n="right",t[0]-=2}return Lt.textAlign=n,Lt.textBaseline=r,t}function lt(){Lt.clearRect(0,0,kt+xt[0],qt+xt[1])}function ct(){return O.width&&O.width>0?O.width:bt?bt.clientWidth-xt[0]:window.innerWidth-2*xt[0]}function ht(t){if(v(nt,t)){var e=nt[t];return v(e,"ratio")||(e.ratio=2),e}}function ut(t){if(null===t)return[0,0,0];var e=$.equatorial;return t[2]||(t[2]=0),[e[0]-t[0],e[1]-t[1],e[2]+t[2]]}function pt(){if(gt&&!(gt.length<1)){var t,e=gt[vt];switch(e.param){case"projection":t=p({projection:e.value});break;case"center":t=h({center:e.value});break;case"zoom":t=r(e.value)}e.callback&&setTimeout(e.callback,t),vt++,yt===!0&&vt===gt.length&&(vt=0),t=0===e.duration||e.duration<t?t:e.duration,vt<gt.length&&(mt=setTimeout(pt,t))}}function dt(){clearTimeout(mt)}var ft,mt,Mt=W.container,gt=[],vt=0,yt=!1;O=et.set(a),O.stars.size=O.stars.size||7,O.stars.exponent=O.stars.exponent||-.28,O.center=O.center||[0,0],O.lang&&-1!==O.lang.search(/^de|es$/)||(O.lang="name");var bt=f(O.container);if(bt){ft="#"+O.container;var wt=window.getComputedStyle(bt,null);parseInt(wt.width)||O.width||(bt.style.width=m(bt.parentNode.clientWidth))}else ft="body",bt=null;var xt=[16,16],kt=ct(),zt=ht(O.projection);if(O.lines.graticule.lat&&"outline"===O.lines.graticule.lat.pos[0]&&(zt.scale-=2),zt){var Pt=O.transform||"equatorial",It=zt.ratio,qt=kt/It,Tt=zt.scale*kt/1024,St=O.stars.size,jt=O.dsos.size||St,At=O.stars.exponent,Dt=O.dsos.exponent||At,Et=1,Ct=ut(O.center),Ft=O.datapath||"";Ft=Ft.replace(/([^\/]$)/,"$1/"),"body"!=ft&&(f(O.container).style.height=m(qt)),L=W.projection(O.projection).rotate(Ct).translate([kt/2,qt/2]).scale(Tt),N=d3.geo.zoom().projection(L).center([kt/2,qt/2]).scaleExtent([Tt,Tt*R]).on("zoom.redraw",d);var Ot=d3.select(ft).selectAll("canvas");0===Ot[0].length&&(Ot=d3.select(ft).append("canvas")),Ot.attr("width",kt).attr("height",qt);var Lt=Ot.node().getContext("2d"),Nt=d3.geo.graticule().minorStep([15,10]);H=d3.geo.path().projection(L).context(Lt),Mt?Mt.selectAll("*").remove():Mt=d3.select(ft).append("container"),O.interactive?Ot.call(N):Ot.attr("style","cursor: default!important"),q(zt.clip),d3.select(window).on("resize",u),d3.select(ft).on("dblclick",function(){return r(1.5625),!1}),O.controls===!0&&null===f("celestial-zoomin")&&(d3.select(ft).append("input").attr("type","button").attr("id","celestial-zoomin").attr("value","+").on("click",function(){return r(1.25),!1}),d3.select(ft).append("input").attr("type","button").attr("id","celestial-zoomout").attr("value","−").on("click",function(){return r(.8),!1})),O.location===!0&&(U=d3.geo.circle().angle([90]),Mt.append("path").datum(U).attr("class","horizon"),null===f("loc")?F(O):"zenith"===O.follow&&h({center:W.zenith()}),T("horizon-show",zt.clip)),O.form===!0&&null===f("params")&&I(O),null===f("error")&&d3.select("body").append("div").attr("id","error"),this.container=Mt,this.clip=y,this.map=H,this.mapProjection=L,this.context=Lt,this.setStyle=w,this.setTextStyle=x,this.setConstStyle=k,this.dsoSymbol=j,this.redraw=d,this.resize=function(t){t&&v(t,"width")&&(O.width=t.width),u(!0)},this.reload=function(t){t&&v(t,"transform")&&(Pt=O.transform=t.transform,Nt.minorStep("equatorial"===Pt?[15,10]:[10,10]),Mt.selectAll("*").remove(),q(),Mt.append("path").datum(U).attr("class","horizon"),n())},this.apply=function(t){l(t)},this.reproject=function(t){return p(t)},this.rotate=function(t){return t?h(t):O.center},this.zoomBy=function(t){return t?r(t):L.scale()/Tt},this.color=function(t){return t&&v(O.dsos.symbols,t)?O.dsos.symbols[t].fill:"#000"},this.animate=function(t,e){t&&(gt=t,vt=0,yt=e?!0:!1,pt())},this.stop=function(t){dt(),t===!0&&(gt=[])},this.go=function(t){gt.length<1||(t&&t<gt.length&&(vt=t),pt())},v(this,"date")||(this.date=function(){console.log("Celestial.date() needs config.location = true to work.")}),n()}},W.projection=function(t){var e,a,n;if(!v(nt,t))throw new Error("Projection not supported: "+t);return e=nt[t],a=null!==e.arg?d3.geo[t].raw(e.arg):d3.geo[t].raw,n=function(t,e){var n=a(-t,e);return n},n.invert=function(t,e){try{var n=a.invert(t,e);return n[0]=n&&-n[0],n}catch(r){console.log(r)}},d3.geo.projection(n)};var $={equatorial:[0,0,0],ecliptic:[0,0,23.4393],galactic:[93.5949,28.9362,-58.5988],supergalactic:[137.31,59.5283,57.7303]},J={equatorial:[0,90],ecliptic:[-90,66.5607],galactic:[-167.1405,27.1283],supergalactic:[-76.2458,15.7089]};W.eulerAngles=function(){return $},W.poles=function(){return J};var Q=2*Math.PI,Z=Math.PI/2,K=Math.PI/180,X={ecliptic:[-90,23.4393,90],"inverse ecliptic":[90,23.4393,-90],galactic:[-167.1405,62.8717,122.9319],"inverse galactic":[122.9319,62.8717,-167.1405],supergalactic:[283.7542,74.2911,26.4504],"inverse supergalactic":[26.4504,74.2911,283.7542],init:function(){for(var t in this)this[t].constructor==Array&&(this[t]=this[t].map(function(t){return t*K}))},add:function(t,e){return e&&t&&3===e.length&&!this.hasOwnProperty(t)?(this[t]=e.map(function(t){return t*K}),this[t]):void 0}};X.init(),W.euler=function(){return X};var tt=function(t,e,a){var r=n(t,a[1])-e[0];0>r&&(r+=360),r*=K;var i=e[1]*K,o=a[0]*K,s=Math.asin(Math.sin(i)*Math.sin(o)+Math.cos(i)*Math.cos(o)*Math.cos(r)),l=Math.acos((Math.sin(i)-Math.sin(s)*Math.sin(o))/(Math.cos(s)*Math.cos(o)));return Math.sin(r)>0&&(l=2*Math.PI-l),[s/K,l/K,0]};tt.inverse=function(t,e,a){var r=e[0]*K,i=e[1]*K,o=a[0]*K,s=Math.asin(Math.sin(r)*Math.sin(o)+Math.cos(r)*Math.cos(o)*Math.cos(i)),l=((Math.sin(r)-Math.sin(s)*Math.sin(o))/(Math.cos(s)*Math.cos(o))).toFixed(6);l=Math.acos(l),l/=K;var c=n(t,a[1])-l;return[c,s/K,0]},W.horizontal=tt,W.add=function(t){var e={};return v(t,"type")?"dso"!==t.type&&"json"!==t.type||v(t,"file")&&v(t,"callback")?"line"!==t.type&&"raw"!==t.type||v(t,"callback")?(v(t,"file")&&(e.file=t.file),e.type=t.type,v(t,"callback")&&(e.callback=t.callback),v(t,"redraw")&&(e.redraw=t.redraw),void W.data.push(e)):console.log("Can't add line"):console.log("Can't add data file"):console.log("Missing type")},W.remove=function(t){return null!==t&&t<W.data.length?W.data.splice(t,1):void 0},W.clear=function(){W.data=[]},W.getData=i,W.getPoint=r;var et={width:0,projection:"aitoff",transform:"equatorial",center:null,geopos:null,follow:"zenith",orientationfixed:!0,adaptable:!0,interactive:!0,form:!1,location:!1,daterange:[],controls:!0,lang:"",container:"celestial-map",datapath:"data/",stars:{show:!0,limit:6,colors:!0,style:{fill:"#ffffff",opacity:1},names:!0,proper:!1,desig:!1,namestyle:{fill:"#ddddbb",font:"11px 'Palatino Linotype', Georgia, Times, 'Times Roman', serif",align:"left",baseline:"top"},namelimit:2.5,propernamestyle:{fill:"#ddddbb",font:"13px 'Palatino Linotype', Georgia, Times, 'Times Roman', serif",align:"right",baseline:"bottom"},propernamelimit:1.5,size:7,exponent:-.28,data:"stars.6.json"},dsos:{show:!0,limit:6,names:!0,desig:!0,namestyle:{fill:"#cccccc",font:"11px 'Lucida Sans Unicode', Helvetica, Arial, serif",align:"left",baseline:"top"},namelimit:4,size:null,exponent:1.4,data:"dsos.bright.json",symbols:{gg:{shape:"circle",fill:"#ff0000"},g:{shape:"ellipse",fill:"#ff0000"},s:{shape:"ellipse",fill:"#ff0000"},s0:{shape:"ellipse",fill:"#ff0000"},sd:{shape:"ellipse",fill:"#ff0000"},e:{shape:"ellipse",fill:"#ff0000"},i:{shape:"ellipse",fill:"#ff0000"},oc:{shape:"circle",fill:"#ff9900",stroke:"#ff9900",width:2},gc:{shape:"circle",fill:"#ff9900"},en:{shape:"square",fill:"#ff00cc"},bn:{shape:"square",fill:"#ff00cc"},sfr:{shape:"square",fill:"#cc00ff"},rn:{shape:"square",fill:"#0000ff"},pn:{shape:"diamond",fill:"#00cccc"},snr:{shape:"diamond",fill:"#ff00cc"},dn:{shape:"square",fill:"#999999",stroke:"#999999",width:2},pos:{shape:"marker",fill:"#cccccc",stroke:"#cccccc",width:1.5}}},constellations:{show:!0,names:!0,desig:!0,namestyle:{fill:"#cccc99",align:"center",baseline:"middle",opacity:.8,font:["14px 'Lucida Sans Unicode', Helvetica, Arial, sans-serif","12px 'Lucida Sans Unicode', Helvetica, Arial, sans-serif","11px 'Lucida Sans Unicode', Helvetica, Arial, sans-serif"]},lines:!0,linestyle:{stroke:"#cccccc",width:1.5,opacity:.6},bounds:!1,boundstyle:{stroke:"#ccff00",width:1,opacity:.8,dash:[2,4]}},mw:{show:!0,style:{fill:"#ffffff",opacity:"0.15"}},lines:{graticule:{show:!0,stroke:"#cccccc",width:.6,opacity:.8,lon:{pos:[""],fill:"#eee",font:"10px 'Lucida Sans Unicode', Helvetica, Arial, sans-serif"},lat:{pos:[""],fill:"#eee",font:"10px 'Lucida Sans Unicode', Helvetica, Arial, sans-serif"}},equatorial:{show:!0,stroke:"#aaaaaa",width:1.3,opacity:.7},ecliptic:{show:!0,stroke:"#66cc66",width:1.3,opacity:.7},galactic:{show:!1,stroke:"#cc6666",width:1.3,opacity:.7},supergalactic:{show:!1,stroke:"#cc66cc",width:1.3,opacity:.7}},background:{fill:"#000000",opacity:1,stroke:"#000000",width:1.5},horizon:{show:!1,stroke:"#000099",width:1,fill:"#000000",opacity:.5},planets:{show:!1,which:["sol","mer","ven","ter","lun","mar","jup","sat","ura","nep"],style:{fill:"#00ccff",font:"bold 17px 'Lucida Sans Unicode', Consolas, sans-serif",align:"center",baseline:"middle"},symbols:{sol:{symbol:"☉",fill:"#ffff00"},mer:{symbol:"☿",fill:"#cccccc"},ven:{symbol:"♀",fill:"#eeeecc"},ter:{symbol:"⊕",fill:"#00ffff"},lun:{symbol:"●",fill:"#ffffff"},mar:{symbol:"♂",fill:"#ff9999"},cer:{symbol:"⚳",fill:"#cccccc"},ves:{symbol:"⚶",fill:"#cccccc"},jup:{symbol:"♃",fill:"#ff9966"},sat:{symbol:"♄",fill:"#ffcc66"},ura:{symbol:"♅",fill:"#66ccff"},nep:{symbol:"♆",fill:"#6666ff"},plu:{symbol:"♇",fill:"#aaaaaa"},eri:{symbol:"⚪",fill:"#eeeeee"}}},daylight:{show:!1,fill:"#fff",opacity:.4},set:function(t){var e,a,n={};if(!t)return this;for(e in this)if(v(this,e))if(v(t,e)&&null!==t[e])if(null===this[e]||this[e].constructor!=Object)n[e]=t[e];else{n[e]={};for(a in this[e])n[e][a]=v(t[e],a)?t[e][a]:this[e][a]}else n[e]=this[e];return n}};W.settings=function(){return et};var at=d3.scale.quantize().domain([3.347,-.335]).range(["#ff4700","#ff4b00","#ff4f00","#ff5300","#ff5600","#ff5900","#ff5b00","#ff5d00","#ff6000","#ff6300","#ff6500","#ff6700","#ff6900","#ff6b00","#ff6d00","#ff7000","#ff7300","#ff7500","#ff7800","#ff7a00","#ff7c00","#ff7e00","#ff8100","#ff8300","#ff8506","#ff870a","#ff8912","#ff8b1a","#ff8e21","#ff9127","#ff932c","#ff9631","#ff9836","#ff9a3c","#ff9d3f","#ffa148","#ffa34b","#ffa54f","#ffa753","#ffa957","#ffab5a","#ffad5e","#ffb165","#ffb269","#ffb46b","#ffb872","#ffb975","#ffbb78","#ffbe7e","#ffc184","#ffc489","#ffc78f","#ffc892","#ffc994","#ffcc99","#ffce9f","#ffd1a3","#ffd3a8","#ffd5ad","#ffd7b1","#ffd9b6","#ffdbba","#ffddbe","#ffdfc2","#ffe1c6","#ffe3ca","#ffe4ce","#ffe8d5","#ffe9d9","#ffebdc","#ffece0","#ffefe6","#fff0e9","#fff2ec","#fff4f2","#fff5f5","#fff6f8","#fff9fd","#fef9ff","#f9f6ff","#f6f4ff","#f3f2ff","#eff0ff","#ebeeff","#e9edff","#e6ebff","#e3e9ff","#e0e7ff","#dee6ff","#dce5ff","#d9e3ff","#d7e2ff","#d3e0ff","#c9d9ff","#bfd3ff","#b7ceff","#afc9ff","#a9c5ff","#a4c2ff","#9fbfff","#9bbcff"]),nt={airy:{n:"Airy’s Minimum Error",arg:Math.PI/2,scale:360,ratio:1,clip:!0},aitoff:{n:"Aitoff",arg:null,scale:162},armadillo:{n:"Armadillo",arg:0,scale:250},august:{n:"August",arg:null,scale:94,ratio:1.4},azimuthalEqualArea:{n:"Azimuthal Equal Area",arg:null,scale:340,ratio:1,clip:!0},azimuthalEquidistant:{n:"Azimuthal Equidistant",arg:null,scale:320,ratio:1,clip:!0},baker:{n:"Baker Dinomic",arg:null,scale:160,ratio:1.4},berghaus:{n:"Berghaus Star",arg:0,scale:320,ratio:1,clip:!0},boggs:{n:"Boggs Eumorphic",arg:null,scale:170},bonne:{n:"Bonne",arg:Math.PI/2.5,scale:225,ratio:.88},bromley:{n:"Bromley",arg:null,scale:162},cassini:{n:"Cassini",arg:null,scale:325,ratio:1,clip:!0},collignon:{n:"Collignon",arg:null,scale:100,ratio:2.6},craig:{n:"Craig Retroazimuthal",arg:0,scale:310,ratio:1.5,clip:!0},craster:{n:"Craster Parabolic",arg:null,scale:160},cylindricalEqualArea:{n:"Cylindrical Equal Area",arg:Math.PI/6,scale:190,ratio:2.3},cylindricalStereographic:{n:"Cylindrical Stereographic",arg:Math.PI/4,scale:230,ratio:1.3},eckert1:{n:"Eckert I",arg:null,scale:175},eckert2:{n:"Eckert II",arg:null,scale:175},eckert3:{n:"Eckert III",arg:null,scale:190},eckert4:{n:"Eckert IV",arg:null,scale:190},eckert5:{n:"Eckert V",arg:null,scale:182},eckert6:{n:"Eckert VI",arg:null,scale:182},eisenlohr:{n:"Eisenlohr",arg:null,scale:102},equirectangular:{n:"Equirectangular",arg:null,scale:165},fahey:{n:"Fahey",arg:null,scale:196,ratio:1.4},mtFlatPolarParabolic:{n:"Flat Polar Parabolic",arg:null,scale:175},mtFlatPolarQuartic:{n:"Flat Polar Quartic",arg:null,scale:230,ratio:1.65},mtFlatPolarSinusoidal:{n:"Flat Polar Sinusoidal",arg:null,scale:175,ratio:1.9},foucaut:{n:"Foucaut",arg:null,scale:142},ginzburg4:{n:"Ginzburg IV",arg:null,scale:180,ratio:1.7},ginzburg5:{n:"Ginzburg V",arg:null,scale:196,ratio:1.55},ginzburg6:{n:"Ginzburg VI",arg:null,scale:190,ratio:1.4},ginzburg8:{n:"Ginzburg VIII",arg:null,scale:205,ratio:1.3},ginzburg9:{n:"Ginzburg IX",arg:null,scale:190,ratio:1.4},homolosine:{n:"Goode Homolosine",arg:null,scale:160,ratio:2.2},hammer:{n:"Hammer",arg:2,scale:180},hatano:{n:"Hatano",arg:null,scale:186},healpix:{n:"HEALPix",arg:1,scale:320,ratio:1.2},hill:{n:"Hill Eucyclic",arg:2,scale:190,ratio:1.1},kavrayskiy7:{n:"Kavrayskiy VII",arg:null,scale:185,ratio:1.75},lagrange:{n:"Lagrange",arg:Math.PI/4,scale:88,ratio:1.6,clip:!1},larrivee:{n:"l'Arrivée",arg:null,scale:160,ratio:1.25},laskowski:{n:"Laskowski Tri-Optimal",arg:null,scale:165,ratio:1.7},loximuthal:{n:"Loximuthal",arg:Math.PI/4,scale:175,ratio:1.8},mercator:{n:"Mercator",arg:null,scale:160,ratio:1.3},miller:{n:"Miller",arg:null,scale:160,ratio:1.5},mollweide:{n:"Mollweide",arg:null,scale:180},naturalEarth:{n:"Natural Earth",arg:null,scale:185,ratio:1.85},nellHammer:{n:"Nell Hammer",arg:null,scale:160,ratio:2.6},orthographic:{n:"Orthographic",arg:null,scale:480,ratio:1,clip:!0},patterson:{n:"Patterson Cylindrical",arg:null,scale:160,ratio:1.75},polyconic:{n:"Polyconic",arg:null,scale:160,ratio:1.3},quincuncial:{n:"Quincuncial",arg:null,scale:160,ratio:1.3},rectangularPolyconic:{n:"Rectangular Polyconic",arg:0,scale:160,ratio:1.65},robinson:{n:"Robinson",arg:null,scale:160},sinusoidal:{n:"Sinusoidal",arg:null,scale:160,ratio:2},stereographic:{n:"Stereographic",arg:null,scale:500,ratio:1,clip:!0},times:{n:"Times",arg:null,scale:210,ratio:1.4},twoPointEquidistant:{n:"Two-Point Equidistant",arg:Math.PI/2,scale:320,ratio:1.15,clip:!0},vanDerGrinten:{n:"van Der Grinten",arg:null,scale:160,ratio:1},vanDerGrinten2:{n:"van Der Grinten II",arg:null,scale:160,ratio:1},vanDerGrinten3:{n:"van Der Grinten III",arg:null,scale:160,ratio:1},vanDerGrinten4:{n:"van Der Grinten IV",arg:null,scale:160,ratio:1.6},wagner4:{n:"Wagner IV",arg:null,scale:185},wagner6:{n:"Wagner VI",arg:null,scale:160},wagner7:{n:"Wagner VII",arg:null,scale:190,ratio:1.8},wiechel:{n:"Wiechel",arg:null,scale:360,ratio:1,clip:!0},winkel3:{n:"Winkel Tripel",arg:null,scale:196,ratio:1.7}};W.projections=function(){return nt};var rt={};rt.symbol=function(){function t(t){o[a()](t)}var e,a=d3.functor("circle"),n=d3.functor(64),r=d3.functor(Math.PI),i=(d3.functor("#fff"),d3.functor("")),o=(d3.functor([2,2]),{circle:function(t){var a=Math.sqrt(n()),r=a/2;return t.arc(e[0],e[1],r,0,2*Math.PI),r},square:function(t){var a=Math.sqrt(n()),r=a/1.7;return t.moveTo(e[0]-r,e[1]-r),t.lineTo(e[0]+r,e[1]-r),t.lineTo(e[0]+r,e[1]+r),t.lineTo(e[0]-r,e[1]+r),t.closePath(),r},diamond:function(t){var a=Math.sqrt(n()),r=a/1.5;return t.moveTo(e[0],e[1]-r),t.lineTo(e[0]+r,e[1]),t.lineTo(e[0],e[1]+r),t.lineTo(e[0]-r,e[1]),t.closePath(),r},triangle:function(t){var a=Math.sqrt(n()),r=a/Math.sqrt(3);return t.moveTo(e[0],e[1]-r),t.lineTo(e[0]+r,e[1]+r),t.lineTo(e[0]-r,e[1]+r),t.closePath(),r},ellipse:function(t){var a=Math.sqrt(n()),r=a/2;return t.save(),t.translate(e[0],e[1]),t.scale(1.6,.8),t.beginPath(),t.arc(0,0,r,0,2*Math.PI),t.closePath(),t.restore(),r},marker:function(t){var a=Math.sqrt(n()),r=a/2;return t.moveTo(e[0],e[1]-r),t.lineTo(e[0],e[1]+r),t.moveTo(e[0]-r,e[1]),t.lineTo(e[0]+r,e[1]),t.closePath(),r},"cross-circle":function(t){var a=Math.sqrt(n()),r=a/2;return t.moveTo(e[0],e[1]-a),t.lineTo(e[0],e[1]+a),t.moveTo(e[0]-a,e[1]),t.lineTo(e[0]+a,e[1]),t.stroke(),t.beginPath(),t.moveTo(e[0],e[1]),t.arc(e[0],e[1],r,0,2*Math.PI),t.closePath(),r},"stroke-circle":function(t){var a=Math.sqrt(n()),r=a/2;return t.moveTo(e[0],e[1]-a),t.lineTo(e[0],e[1]+a),t.stroke(),t.beginPath(),t.moveTo(e[0],e[1]),t.arc(e[0],e[1],r,0,2*Math.PI),t.closePath(),r},crescent:function(t){var a=Math.sqrt(n()),i=a/2,o=r(),s=.5*(1-Math.cos(o)),l=1.6*Math.abs(s-.5)+.01,c=o>Math.PI,h=Math.abs(s)>.5?c:!c;return t.save(),t.fillStyle="#557",t.moveTo(e[0],e[1]),t.arc(e[0],e[1],i,0,2*Math.PI),t.closePath(),t.fill(),t.fillStyle="#eee",t.beginPath(),t.moveTo(e[0],e[1]),t.arc(e[0],e[1],i,-Math.PI/2,Math.PI/2,c),t.scale(l,1),t.arc(e[0]/l,e[1],i,Math.PI/2,-Math.PI/2,h),t.closePath(),t.fill(),t.restore(),i}});return t.type=function(e){return arguments.length?(a=d3.functor(e),t):a},t.size=function(e){return arguments.length?(n=d3.functor(e),t):n},t.age=function(e){return arguments.length?(r=d3.functor(e),t):r},t.text=function(e){return arguments.length?(i=d3.functor(e),t):i},t.position=function(a){return arguments.length?(e=a,t):void 0},t},W.Canvas=rt;var it={sinh:function(t){return(Math.pow(Math.E,t)-Math.pow(Math.E,-t))/2},cosh:function(t){return(Math.pow(Math.E,t)+Math.pow(Math.E,-t))/2},tanh:function(t){return 2/(1+Math.exp(-2*t))-1},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},normalize0:function(t){return(t+3*Math.PI)%(2*Math.PI)-Math.PI},normalize:function(t){return(t+2*Math.PI)%(2*Math.PI)},cartesian:function(t){var e=t[0],a=Z-t[1],n=t[2];return{x:n*Math.sin(a)*Math.cos(e),y:n*Math.sin(a)*Math.sin(e),z:n*Math.cos(a)}},spherical:function(t){var e=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z),a=Math.atan(t.y/t.x),n=Math.acos(t.z/e);return[a/K,n/K,e]}},ot={"stars-show":["stars-limit","stars-colors","stars-style-fill","stars-names","stars-size","stars-exponent"],"stars-names":["stars-proper","stars-desig","stars-namelimit"],"stars-proper":["stars-propernamelimit"],"dsos-show":["dsos-limit","dsos-names","dsos-size","dsos-exponent"],"dsos-names":["dsos-desig","dsos-namelimit"],"mw-show":["mw-style-opacity","mw-style-fill"],"constellations-names":["constellations-desig"]},st={sol:.0002959122082855911,mer:0x95955473dbc3,ven:0x89d9374048629,ter:0xa923c08a47948,lun:36599199229256,mar:319711652803400,cer:467549107200,ves:129071530155,jup:0xd2088431b2a1400,sat:0x3ee37dea29c61e0,ura:0x99ad2c257ccb88,nep:0xb54f909dc5b7b8,plu:7327611364884,eri:827117568e4},lt={sol:"☉",mer:"☿",ven:"♀",ter:"⊕",lun:"●",mar:"♂",cer:"⚳",ves:"⚶",jup:"♃",sat:"♄",ura:"♅",nep:"♆",plu:"♇",eri:"⚪"},ct=23.43928*K,ht=Math.sin(ct),ut=Math.cos(ct),pt=["a","e","i","w","M","L","W","N","n","ep","ref","lecl","becl","Tilt"],dt=function(){function t(e){return w(e),"sol"===d?(b.x=0,b.y=0,b.z=0,t):(x(),t)}function e(t,e){for(var a=e>1?t*t:-t*t,n=e*a*t/6,r=(1-e)*t-n,i=4;Math.abs(n)>1e-15;)n*=a/(i*(i+1)),r-=n,i+=2;return r}function n(){var t,a,n,r,i=b.e,o=b.M,s=1e-8,l=0,c=1.9,h=!1,u=0;if(!o)return 0;if(1>i&&((o<-Math.PI||o>Math.PI)&&(r=it.normalize0(o),l=o-r,o=r),.9>i)){t=Math.atan2(Math.sin(o),Math.cos(o)-i);do a=(t-i*Math.sin(t)-o)/(1-i*Math.cos(t)),t-=a;while(Math.abs(a)>s);return t}if(0>o&&(o=-o,h=!0),t=o,s*=Math.abs(1-i),1e-15>s&&(s=1e-15),(i>.8&&o<Math.PI/3||i>1)&&(n=o/Math.abs(1-i),n*n>6*Math.abs(1-i)&&(n=o<Math.PI?Math.pow(6*o,1/3):it.asinh(o/i)),t=n),i>1&&o>4&&(t=Math.log(o)),1>i)for(;Math.abs(c)>s;)a=u++>8?e(t,i)-o:t-i*Math.sin(t)-o,c=-a/(1-i*Math.cos(t)),t+=c;else for(;Math.abs(c)>s;)a=u++>7?-e(t,i)-o:i*it.sinh(t)-t-o,c=-a/(i*it.cosh(t)-1),t+=c;return h?l-t:l+t}function r(){var t,e,a,r,i;1===b.e?(i=b.jd0-b.T,r=b.w0*i*.5,e=Math.pow(r+Math.sqrt(r*r+1),1/3),b.v=2*Math.atan(e-1/e)):(b.E=n(),b.e>1?(t=b.e-it.cosh(b.E),e=it.sinh(b.E)):(t=Math.cos(b.E)-b.e,e=Math.sin(b.E)),e*=Math.sqrt(Math.abs(1-b.e*b.e)),b.v=Math.atan2(e,t)),a=b.q*(1+b.e),b.r=a/(1+b.e*Math.cos(b.v))}function i(){b.hasOwnProperty("w")||(b.w=b.W-b.N),b.hasOwnProperty("M")||(b.M=b.L-b.W),b.e<1&&(b.M=it.normalize0(b.M)),b.P=Q*Math.sqrt(Math.pow(b.a,3)/M)/365.25,b.T=b.jd0-b.M/Z/b.P,1!==b.e?(b.q=b.a*(1-b.e),b.t0=b.a*Math.sqrt(Math.abs(b.a)/M)):(b.w0=3/Math.sqrt(2)/(b.q*Math.sqrt(b.q/M)),b.a=0,b.t0=0),b.am=Math.sqrt(M*b.q*(1+b.e))}function o(){if(!b.ref||"ecl"===b.ref)return b.tx=b.x,b.ty=b.y,void(b.tz=b.z);var t=b.lecl,e=Math.PI/2-b.becl,n=[0,e,-t];a(b,n);var r=it.cartesian([b.tl,b.tb,b.r]);b.tx=r.x,b.ty=r.y,b.tz=r.z}function s(t){ct=(23.439292-.0130042*b.cy-1.667e-7*b.cy*b.cy+5.028e-7*b.cy*b.cy*b.cy)*K,ht=Math.sin(ct),ut=Math.cos(ct);var e="lun"===d?{x:0,y:0,z:0}:{x:t.x,y:t.y,z:t.z};b.xeq=b.x-e.x,b.yeq=(b.y-e.y)*ut-(b.z-e.z)*ht,b.zeq=(b.y-e.y)*ht+(b.z-e.z)*ut,b.ra=it.normalize(Math.atan2(b.yeq,b.xeq)),b.dec=Math.atan2(b.zeq,Math.sqrt(b.xeq*b.xeq+b.yeq*b.yeq)),"lun"===d&&(b=p(b,t)),b.pos=[b.ra/K,b.dec/K],b.rt=Math.sqrt(b.xeq*b.xeq+b.yeq*b.yeq+b.zeq*b.zeq)}function l(){var t=b.v+b.w;return b.x=b.r*(Math.cos(b.N)*Math.cos(t)-Math.sin(b.N)*Math.sin(t)*Math.cos(b.i)),b.y=b.r*(Math.sin(b.N)*Math.cos(t)+Math.cos(b.N)*Math.sin(t)*Math.cos(b.i)),b.z=b.r*Math.sin(t)*Math.sin(b.i),b}function c(){var t=Math.atan2(b.y,b.x),e=Math.atan2(b.z,Math.sqrt(b.x*b.x+b.y*b.y));return b.l=it.normalize(t),b.b=e,b}function h(t){var e=t.getUTCFullYear(),a=t.getUTCMonth()+1,n=t.getUTCDate(),r=(t.getUTCHours()-12+t.getUTCMinutes()/60+t.getUTCSeconds()/3600)/24,i=-4799;if(i>e)return-1;var o=Math.floor((14-a)/12),s=e+4800-o,l=a+12*o-3,c=n+Math.floor((153*l+2)/5)+365*s+Math.floor(s/4)-Math.floor(s/100)+Math.floor(s/400)-32045;return c+r}function u(t){return"undefined"!=typeof ft?ft.elements(t):void 0}function p(t,e){return c(),"undefined"!=typeof ft?ft.corr(t,e):void 0}var d,f,m,M=st.sol,g="sol",y={},b={},w=function(t){var e;b=[],t&&(e=t instanceof Date?new Date(t.valueOf()):z(t)),e||(e=new Date),b.jd=h(e),e=z(y.ep),e||(e=z("2000-01-01")),b.jd0=h(e),b.d=b.jd-b.jd0,b.cy=b.d/36525},x=function(){var t;if("lun"===d){if(b=u(b),!b)return}else{for(var e=0;e<pt.length;e++)t=pt[e],v(y,t)&&(v(y,"d"+t)?b[t]=y[t]+y["d"+t]*b.cy:v(y,t)&&(b[t]=y[t]));v(b,"M")&&!v(b,"dM")&&v(b,"n")&&(b.M+=b.n*b.d)}i(),r(),l()};return t.cartesian=function(){return b},t.spherical=function(){return c(),b},t.equatorial=function(t){return s(t),b},t.transpose=function(){return o(b),b},t.elements=function(e){var a;if(!arguments.length)return y;for(var n=0;n<pt.length;n++)a=pt[n],v(e,a)&&(y[a]=e[a],"a"===a||"e"===a?y[a]*=1:"ref"!==a&&"ep"!==a&&(y[a]*=K),v(e,"d"+a)&&(a="d"+a,y[a]=e[a],y[a]*="da"===a||"de"===a?1:K));return t},t.parentBody=function(e){return arguments.length?(g=e,M=st[g],t):g},t.id=function(e){return arguments.length?(d=e,m=lt[e],t):d},t.name=function(e){return arguments.length?(f=e,t):f},t.symbol=function(e){return arguments.length?(m=lt[e],t):m},t},ft={elements:function(t){var e=(t.jd-2451545)/36525,a=e*e,n=e*a,r=e*n,i=1e-4*a,o=1e-6*n,s=1e-8*r,l=3400.4*Math.cos(K*(235.7004+890534.223*e-32.601*i+3.664*o-1.769*s))-635.6*Math.cos(K*(100.737+413335.3554*e-122.571*i-10.684*o+5.028*s))-235.6*Math.cos(K*(134.9634+477198.8676*e+89.97*i+14.348*o-6.797*s))+218.1*Math.cos(K*(238.1713+854535.1727*e-31.065*i+3.623*o-1.769*s))+181*Math.cos(K*(10.6638+1367733.0907*e+57.37*i+18.011*o-8.566*s))-39.9*Math.cos(K*(103.2079+377336.3051*e-121.035*i-10.724*o+5.028*s))-38.4*Math.cos(K*(233.2295+926533.2733*e-34.136*i+3.705*o-1.769*s))+33.8*Math.cos(K*(336.4374+1303869.5784*e-155.171*i-7.02*o+3.259*s))+28.8*Math.cos(K*(111.4008+1781068.4461*e-65.201*i+7.328*o-3.538*s))+12.6*Math.cos(K*(13.1347+1331734.0404*e+58.906*i+17.971*o-8.566*s))+11.4*Math.cos(K*(186.5442+966404.0351*e-68.058*i-.567*o+.232*s))-11.1*Math.cos(K*(222.5657-441199.8173*e-91.506*i-14.307*o+6.797*s))-10.2*Math.cos(K*(269.9268+954397.7353*e+179.941*i+28.695*o-13.594*s))+9.7*Math.cos(K*(145.6272+1844931.9583*e+147.34*i+32.359*o-15.363*s))+9.6*Math.cos(K*(240.6422+818536.1225*e-29.529*i+3.582*o-1.769*s))+8*Math.cos(K*(297.8502+445267.1115*e-16.3*i+1.832*o-.884*s))-6.2*Math.cos(K*(132.4925+513197.9179*e+88.434*i+14.388*o-6.797*s))+6*Math.cos(K*(173.5506+1335801.3346*e-48.901*i+5.496*o-2.653*s))+3.7*Math.cos(K*(113.8717+1745069.3958*e-63.665*i+7.287*o-3.538*s))+3.6*Math.cos(K*(338.9083+1267870.5281*e-153.636*i-7.061*o+3.259*s))+3.2*Math.cos(K*(246.3642+2258267.3137*e+24.769*i+21.675*o-10.335*s))-3*Math.cos(K*(8.1929+1403732.141*e+55.834*i+18.052*o-8.566*s))+2.3*Math.cos(K*(98.2661+449334.4057*e-124.107*i-10.643*o+5.028*s))-2.2*Math.cos(K*(357.5291+35999.0503*e-1.536*i+.041*o+0*s))-2*Math.cos(K*(38.5872+858602.4669*e-138.871*i-8.852*o+4.144*s))-1.8*Math.cos(K*(105.6788+341337.2548*e-119.499*i-10.765*o+5.028*s))-1.7*Math.cos(K*(201.474+826670.7108*e-245.142*i-21.367*o+10.057*s))+1.6*Math.cos(K*(184.1196+401329.0556*e+125.428*i+18.579*o-8.798*s))-1.4*Math.cos(K*(308.4192-489205.1674*e+158.029*i+14.915*o-7.029*s))+1.3*Math.cos(K*(325.7736-63863.5122*e-212.541*i-25.031*o+11.826*s)),c=-.55*Math.cos(K*(238.2+854535.2*e))+.1*Math.cos(K*(103.2+377336.3*e))+.1*Math.cos(K*(233.2+926533.3*e)),h=383397.6+l+c*e,u=.014217*Math.cos(K*(100.737+413335.3554*e-122.571*i-10.684*o+5.028*s))+.008551*Math.cos(K*(325.7736-63863.5122*e-212.541*i-25.031*o+11.826*s))-.001383*Math.cos(K*(134.9634+477198.8676*e+89.97*i+14.348*o-6.797*s))+.001353*Math.cos(K*(10.6638+1367733.0907*e+57.37*i+18.011*o-8.566*s))-.001146*Math.cos(K*(66.5106+349471.8432*e-335.112*i-35.715*o+16.854*s))-915e-6*Math.cos(K*(201.474+826670.7108*e-245.142*i-21.367*o+10.057*s))+869e-6*Math.cos(K*(103.2079+377336.3051*e-121.035*i-10.724*o+5.028*s))-628e-6*Math.cos(K*(235.7004+890534.223*e-32.601*i+3.664*o-1.769*s))-393e-6*Math.cos(K*(291.5472-127727.0245*e-425.082*i-50.062*o+23.651*s))+284e-6*Math.cos(K*(328.2445-99862.5625*e-211.005*i-25.072*o+11.826*s))-278e-6*Math.cos(K*(162.8868-31931.7561*e-106.271*i-12.516*o+5.913*s))-24e-5*Math.cos(K*(269.9268+954397.7353*e+179.941*i+28.695*o-13.594*s))+23e-5*Math.cos(K*(111.4008+1781068.4461*e-65.201*i+7.328*o-3.538*s))+229e-6*Math.cos(K*(167.2476+762807.1986*e-457.683*i-46.398*o+21.882*s))-202e-6*Math.cos(K*(83.3826-12006.2998*e+247.999*i+29.262*o-13.826*s))+19e-5*Math.cos(K*(190.8102-541062.3799*e-302.511*i-39.379*o+18.623*s))+177e-6*Math.cos(K*(357.5291+35999.0503*e-1.536*i+.041*o+0*s))+153e-6*Math.cos(K*(32.2842+285608.3309*e-547.653*i-60.746*o+28.679*s))-137e-6*Math.cos(K*(44.8902+1431596.6029*e+269.911*i+43.043*o-20.392*s))+122e-6*Math.cos(K*(145.6272+1844931.9583*e+147.34*i+32.359*o-15.363*s))+116e-6*Math.cos(K*(302.211+1240006.0662*e-367.713*i-32.051*o+15.085*s))-111e-6*Math.cos(K*(203.9449+790671.6605*e-243.606*i-21.408*o+10.057*s))-108e-6*Math.cos(K*(68.9815+313472.7929*e-333.576*i-35.756*o+16.854*s))+96e-6*Math.cos(K*(336.4374+1303869.5784*e-155.171*i-7.02*o+3.259*s))-9e-5*Math.cos(K*(98.2661+449334.4057*e-124.107*i-10.643*o+5.028*s))+9e-5*Math.cos(K*(13.1347+1331734.0404*e+58.906*i+17.971*o-8.566*s))+56e-6*Math.cos(K*(55.8468-1018261.2475*e-392.482*i-53.726*o+25.42*s))-56e-6*Math.cos(K*(238.1713+854535.1727*e-31.065*i+3.623*o-1.769*s))+52e-6*Math.cos(K*(308.4192-489205.1674*e+158.029*i+14.915*o-7.029*s))-5e-5*Math.cos(K*(133.0212+698943.6863*e-670.224*i-71.429*o+33.708*s))-49e-6*Math.cos(K*(267.9846+1176142.554*e-580.254*i-57.082*o+26.911*s))-49e-6*Math.cos(K*(184.1196+401329.0556*e+125.428*i+18.579*o-8.798*s))-45e-6*Math.cos(K*(49.1562-75869.812*e+35.458*i+4.231*o-2.001*s))+44e-6*Math.cos(K*(257.3208-191590.5367*e-637.623*i-75.093*o+35.477*s))+42e-6*Math.cos(K*(105.6788+341337.2548*e-119.499*i-10.765*o+5.028*s))+42e-6*Math.cos(K*(160.4159+4067.2942*e-107.806*i-12.475*o+5.913*s))+4e-5*Math.cos(K*(246.3642+2258267.3137*e+24.769*i+21.675*o-10.335*s))-4e-5*Math.cos(K*(156.5838-604925.8921*e-515.053*i-64.41*o+30.448*s))+36e-6*Math.cos(K*(169.7185+726808.1483*e-456.147*i-46.439*o+21.882*s))+29e-6*Math.cos(K*(113.8717+1745069.3958*e-63.665*i+7.287*o-3.538*s))-29e-6*Math.cos(K*(297.8502+445267.1115*e-16.3*i+1.832*o-.884*s))-28e-6*Math.cos(K*(294.0181-163726.0747*e-423.546*i-50.103*o+23.651*s))+27e-6*Math.cos(K*(263.6238+381403.5993*e-228.841*i-23.199*o+10.941*s))-26e-6*Math.cos(K*(358.0578+221744.8187*e-760.194*i-85.777*o+40.505*s))-26e-6*Math.cos(K*(8.1929+1403732.141*e+55.834*i+18.052*o-8.566*s)),p=-.0022*Math.cos(K*(103.2+377336.3*e)),d=.055544+u+.001*e*p,f=.0011776*Math.cos(K*(49.1562-75869.812*e+35.458*i+4.231*o-2.001*s))-971e-7*Math.cos(K*(235.7004+890534.223*e-32.601*i+3.664*o-1.769*s))+908e-7*Math.cos(K*(186.5442+966404.0351*e-68.058*i-.567*o+.232*s))+623e-7*Math.cos(K*(83.3826-12006.2998*e+247.999*i+29.262*o-13.826*s))+483e-7*Math.cos(K*(51.6271-111868.8623*e+36.994*i+4.19*o-2.001*s))+348e-7*Math.cos(K*(100.737+413335.3554*e-122.571*i-10.684*o+5.028*s))-316e-7*Math.cos(K*(308.4192-489205.1674*e+158.029*i+14.915*o-7.029*s))-253e-7*Math.cos(K*(46.6853-39870.7617*e+33.922*i+4.272*o-2.001*s))-141e-7*Math.cos(K*(274.1928-553068.6797*e-54.513*i-10.116*o+4.797*s))+127e-7*Math.cos(K*(325.7736-63863.5122*e-212.541*i-25.031*o+11.826*s))+117e-7*Math.cos(K*(184.1196+401329.0556*e+125.428*i+18.579*o-8.798*s))-78e-7*Math.cos(K*(98.3124-151739.624*e+70.916*i+8.462*o-4.001*s))-63e-7*Math.cos(K*(238.1713+854535.1727*e-31.065*i+3.623*o-1.769*s))+63e-7*Math.cos(K*(134.9634+477198.8676*e+89.97*i+14.348*o-6.797*s))+36e-7*Math.cos(K*(321.5076+1443602.9027*e+21.912*i+13.78*o-6.566*s))-35e-7*Math.cos(K*(10.6638+1367733.0907*e+57.37*i+18.011*o-8.566*s))+24e-7*Math.cos(K*(149.8932+337465.5434*e-87.113*i-6.453*o+3.028*s))+24e-7*Math.cos(K*(170.9849-930404.9848*e+66.523*i+.608*o-.232*s)),m=-.0203*Math.cos(K*(125-1934.1*e))+.0034*Math.cos(K*(220.2-1935.5*e)),M=.0449858+f+.001*m,g=-15.448*Math.sin(K*(100.737+413335.3554*e-122.571*i-10.684*o+5.028*s))-9.642*Math.sin(K*(325.7736-63863.5122*e-212.541*i-25.031*o+11.826*s))-2.721*Math.sin(K*(134.9634+477198.8676*e+89.97*i+14.348*o-6.797*s))+2.607*Math.sin(K*(66.5106+349471.8432*e-335.112*i-35.715*o+16.854*s))+2.085*Math.sin(K*(201.474+826670.7108*e-245.142*i-21.367*o+10.057*s))+1.477*Math.sin(K*(10.6638+1367733.0907*e+57.37*i+18.011*o-8.566*s))+.968*Math.sin(K*(291.5472-127727.0245*e-425.082*i-50.062*o+23.651*s))-.949*Math.sin(K*(103.2079+377336.3051*e-121.035*i-10.724*o+5.028*s))-.703*Math.sin(K*(167.2476+762807.1986*e-457.683*i-46.398*o+21.882*s))-.66*Math.sin(K*(235.7004+890534.223*e-32.601*i+3.664*o-1.769*s))-.577*Math.sin(K*(190.8102-541062.3799*e-302.511*i-39.379*o+18.623*s))-.524*Math.sin(K*(269.9268+954397.7353*e+179.941*i+28.695*o-13.594*s))-.482*Math.sin(K*(32.2842+285608.3309*e-547.653*i-60.746*o+28.679*s))+.452*Math.sin(K*(357.5291+35999.0503*e-1.536*i+.041*o+0*s))-.381*Math.sin(K*(302.211+1240006.0662*e-367.713*i-32.051*o+15.085*s))-.342*Math.sin(K*(328.2445-99862.5625*e-211.005*i-25.072*o+11.826*s))-.312*Math.sin(K*(44.8902+1431596.6029*e+269.911*i+43.043*o-20.392*s))+.282*Math.sin(K*(162.8868-31931.7561*e-106.271*i-12.516*o+5.913*s))+.255*Math.sin(K*(203.9449+790671.6605*e-243.606*i-21.408*o+10.057*s))+.252*Math.sin(K*(68.9815+313472.7929*e-333.576*i-35.756*o+16.854*s))-.211*Math.sin(K*(83.3826-12006.2998*e+247.999*i+29.262*o-13.826*s))+.193*Math.sin(K*(267.9846+1176142.554*e-580.254*i-57.082*o+26.911*s))+.191*Math.sin(K*(133.0212+698943.6863*e-670.224*i-71.429*o+33.708*s))-.184*Math.sin(K*(55.8468-1018261.2475*e-392.482*i-53.726*o+25.42*s))+.182*Math.sin(K*(145.6272+1844931.9583*e+147.34*i+32.359*o-15.363*s))-.158*Math.sin(K*(257.3208-191590.5367*e-637.623*i-75.093*o+35.477*s))+.148*Math.sin(K*(156.5838-604925.8921*e-515.053*i-64.41*o+30.448*s))-.111*Math.sin(K*(169.7185+726808.1483*e-456.147*i-46.439*o+21.882*s))+.101*Math.sin(K*(13.1347+1331734.0404*e+58.906*i+17.971*o-8.566*s))+.1*Math.sin(K*(358.0578+221744.8187*e-760.194*i-85.777*o+40.505*s))+.087*Math.sin(K*(98.2661+449334.4057*e-124.107*i-10.643*o+5.028*s))+.08*Math.sin(K*(42.948+1653341.4216*e-490.283*i-42.734*o+20.113*s))+.08*Math.sin(K*(222.5657-441199.8173*e-91.506*i-14.307*o+6.797*s))+.077*Math.sin(K*(294.0181-163726.0747*e-423.546*i-50.103*o+23.651*s))-.073*Math.sin(K*(280.8834-1495460.1151*e-482.452*i-68.074*o+32.217*s))-.071*Math.sin(K*(304.6819+1204007.0159*e-366.177*i-32.092*o+15.085*s))-.069*Math.sin(K*(233.7582+1112279.0417*e-792.795*i-82.113*o+38.736*s))-.067*Math.sin(K*(34.7551+249609.2807*e-546.117*i-60.787*o+28.679*s))-.067*Math.sin(K*(263.6238+381403.5993*e-228.841*i-23.199*o+10.941*s))+.055*Math.sin(K*(21.6203-1082124.7597*e-605.023*i-78.757*o+37.246*s))+.055*Math.sin(K*(308.4192-489205.1674*e+158.029*i+14.915*o-7.029*s))-.054*Math.sin(K*(8.7216+1589477.9094*e-702.824*i-67.766*o+31.939*s))-.052*Math.sin(K*(179.8536+1908795.4705*e+359.881*i+57.39*o-27.189*s))-.05*Math.sin(K*(98.7948+635080.1741*e-882.765*i-96.461*o+45.533*s))-.049*Math.sin(K*(128.6604-95795.2683*e-318.812*i-37.547*o+17.738*s))-.047*Math.sin(K*(17.3544+425341.6552*e-370.57*i-39.946*o+18.854*s))-.044*Math.sin(K*(160.4159+4067.2942*e-107.806*i-12.475*o+5.913*s))-.043*Math.sin(K*(238.1713+854535.1727*e-31.065*i+3.623*o-1.769*s))+.042*Math.sin(K*(270.4555+1140143.5037*e-578.718*i-57.123*o+26.911*s))-.042*Math.sin(K*(132.4925+513197.9179*e+88.434*i+14.388*o-6.797*s))-.041*Math.sin(K*(122.3573-668789.4043*e-727.594*i-89.441*o+42.274*s))-.04*Math.sin(K*(105.6788+341337.2548*e-119.499*i-10.765*o+5.028*s))+.038*Math.sin(K*(135.4921+662944.6361*e-668.688*i-71.47*o+33.708*s))-.037*Math.sin(K*(242.391-51857.2124*e-460.54*i-54.293*o+25.652*s))+.036*Math.sin(K*(336.4374+1303869.5784*e-155.171*i-7.02*o+3.259*s))+.035*Math.sin(K*(223.0943-255454.0489*e-850.164*i-100.124*o+47.302*s))-.034*Math.sin(K*(193.2811-577061.4302*e-300.976*i-39.419*o+18.623*s))+.031*Math.sin(K*(87.6023-918398.685*e-181.476*i-28.654*o+13.594*s)),v=2.4*Math.sin(K*(103.2+377336.3*e)),y=83.353+4069.0137*e-103.238*i-12.492*o+5.263*s+g+.001*e*v,b=-1.4979*Math.sin(K*(49.1562-75869.812*e+35.458*i+4.231*o-2.001*s))-.15*Math.sin(K*(357.5291+35999.0503*e-1.536*i+.041*o+0*s))-.1226*Math.sin(K*(235.7004+890534.223*e-32.601*i+3.664*o-1.769*s))+.1176*Math.sin(K*(186.5442+966404.0351*e-68.058*i-.567*o+.232*s))-.0801*Math.sin(K*(83.3826-12006.2998*e+247.999*i+29.262*o-13.826*s))-.0616*Math.sin(K*(51.6271-111868.8623*e+36.994*i+4.19*o-2.001*s))+.049*Math.sin(K*(100.737+413335.3554*e-122.571*i-10.684*o+5.028*s))+.0409*Math.sin(K*(308.4192-489205.1674*e+158.029*i+14.915*o-7.029*s))+.0327*Math.sin(K*(134.9634+477198.8676*e+89.97*i+14.348*o-6.797*s))+.0324*Math.sin(K*(46.6853-39870.7617*e+33.922*i+4.272*o-2.001*s))+.0196*Math.sin(K*(98.3124-151739.624*e+70.916*i+8.462*o-4.001*s))+.018*Math.sin(K*(274.1928-553068.6797*e-54.513*i-10.116*o+4.797*s))+.015*Math.sin(K*(325.7736-63863.5122*e-212.541*i-25.031*o+11.826*s))-.015*Math.sin(K*(184.1196+401329.0556*e+125.428*i+18.579*o-8.798*s))-.0078*Math.sin(K*(238.1713+854535.1727*e-31.065*i+3.623*o-1.769*s))-.0045*Math.sin(K*(10.6638+1367733.0907*e+57.37*i+18.011*o-8.566*s))+.0044*Math.sin(K*(321.5076+1443602.9027*e+21.912*i+13.78*o-6.566*s))-.0042*Math.sin(K*(162.8868-31931.7561*e-106.271*i-12.516*o+5.913*s))-.0031*Math.sin(K*(170.9849-930404.9848*e+66.523*i+.608*o-.232*s))+.0031*Math.sin(K*(103.2079+377336.3051*e-121.035*i-10.724*o+5.028*s))+.0029*Math.sin(K*(222.612-1042273.8471*e+103.516*i+4.798*o-2.232*s))+.0028*Math.sin(K*(184.0733+1002403.0853*e-69.594*i-.526*o+.232*s)),w=25.9*Math.sin(K*(125-1934.1*e))-4.3*Math.sin(K*(220.2-1935.5*e)),x=.38*Math.sin(K*(357.5+35999.1*e)),k=125.0446-1934.13618*e+20.762*i+2.139*o-1.65*s+b+.001*(w+x*e),z=-.92581*Math.sin(K*(235.7004+890534.223*e-32.601*i+3.664*o-1.769*s))+.33262*Math.sin(K*(100.737+413335.3554*e-122.571*i-10.684*o+5.028*s))-.18402*Math.sin(K*(357.5291+35999.0503*e-1.536*i+.041*o+0*s))+.11007*Math.sin(K*(134.9634+477198.8676*e+89.97*i+14.348*o-6.797*s))-.06055*Math.sin(K*(238.1713+854535.1727*e-31.065*i+3.623*o-1.769*s))+.04741*Math.sin(K*(325.7736-63863.5122*e-212.541*i-25.031*o+11.826*s))-.03086*Math.sin(K*(10.6638+1367733.0907*e+57.37*i+18.011*o-8.566*s))+.02184*Math.sin(K*(103.2079+377336.3051*e-121.035*i-10.724*o+5.028*s))+.01645*Math.sin(K*(49.1562-75869.812*e+35.458*i+4.231*o-2.001*s))+.01022*Math.sin(K*(233.2295+926533.2733*e-34.136*i+3.705*o-1.769*s))-.00756*Math.sin(K*(336.4374+1303869.5784*e-155.171*i-7.02*o+3.259*s))-.0053*Math.sin(K*(222.5657-441199.8173*e-91.506*i-14.307*o+6.797*s))-.00496*Math.sin(K*(162.8868-31931.7561*e-106.271*i-12.516*o+5.913*s))-.00472*Math.sin(K*(297.8502+445267.1115*e-16.3*i+1.832*o-.884*s))-.00271*Math.sin(K*(240.6422+818536.1225*e-29.529*i+3.582*o-1.769*s))+.00264*Math.sin(K*(132.4925+513197.9179*e+88.434*i+14.388*o-6.797*s))-.00254*Math.sin(K*(186.5442+966404.0351*e-68.058*i-.567*o+.232*s))+.00234*Math.sin(K*(269.9268+954397.7353*e+179.941*i+28.695*o-13.594*s))-.0022*Math.sin(K*(13.1347+1331734.0404*e+58.906*i+17.971*o-8.566*s))-.00202*Math.sin(K*(355.0582+71998.1006*e-3.072*i+.082*o+0*s))+.00167*Math.sin(K*(328.2445-99862.5625*e-211.005*i-25.072*o+11.826*s))-.00143*Math.sin(K*(173.5506+1335801.3346*e-48.901*i+5.496*o-2.653*s))-.00121*Math.sin(K*(98.2661+449334.4057*e-124.107*i-10.643*o+5.028*s))-.00116*Math.sin(K*(145.6272+1844931.9583*e+147.34*i+32.359*o-15.363*s))+.00102*Math.sin(K*(105.6788+341337.2548*e-119.499*i-10.765*o+5.028*s))-9e-4*Math.sin(K*(184.1196+401329.0556*e+125.428*i+18.579*o-8.798*s))-86e-5*Math.sin(K*(338.9083+1267870.5281*e-153.636*i-7.061*o+3.259*s))-78e-5*Math.sin(K*(111.4008+1781068.4461*e-65.201*i+7.328*o-3.538*s))+69e-5*Math.sin(K*(323.3027-27864.4619*e-214.077*i-24.99*o+11.826*s))+66e-5*Math.sin(K*(51.6271-111868.8623*e+36.994*i+4.19*o-2.001*s))+65e-5*Math.sin(K*(38.5872+858602.4669*e-138.871*i-8.852*o+4.144*s))-6e-4*Math.sin(K*(83.3826-12006.2998*e+247.999*i+29.262*o-13.826*s))+54e-5*Math.sin(K*(201.474+826670.7108*e-245.142*i-21.367*o+10.057*s))-52e-5*Math.sin(K*(308.4192-489205.1674*e+158.029*i+14.915*o-7.029*s))+48e-5*Math.sin(K*(8.1929+1403732.141*e+55.834*i+18.052*o-8.566*s))-41e-5*Math.sin(K*(46.6853-39870.7617*e+33.922*i+4.272*o-2.001*s))-33e-5*Math.sin(K*(274.1928-553068.6797*e-54.513*i-10.116*o+4.797*s))+3e-4*Math.sin(K*(160.4159+4067.2942*e-107.806*i-12.475*o+5.913*s)),P=3.96*Math.sin(K*(119.7+131.8*e))+1.96*Math.sin(K*(125-1934.1*e)),I=.463*Math.sin(K*(357.5+35999.1*e))+.152*Math.sin(K*(238.2+854535.2*e))-.071*Math.sin(K*(27.8+131.8*e))-.055*Math.sin(K*(103.2+377336.3*e))-.026*Math.sin(K*(233.2+926533.3*e)),q=14*Math.sin(K*(357.5+35999.1*e))+5*Math.sin(K*(238.2+854535.2*e)),T=218.31665+481267.88134*e-13.268*i+1.856*o-1.534*s+z+.001*(P+I*e+q*i);
return t.a=h,t.e=d,t.i=2*Math.asin(M),t.w=it.normalize(K*(y-k)),t.N=it.normalize(K*k),t.M=it.normalize(K*(T-y)),t},corr:function(t,e){var a=it.normalize(e.M+Math.PI),n=it.normalize(e.w+Math.PI),r=t.M+t.w,i=r+t.N-a-n,o=-.022234*Math.sin(t.M-2*i)+.011494*Math.sin(2*i)+-.003246*Math.sin(a)+-.001029*Math.sin(2*t.M-2*i)+-994838e-9*Math.sin(t.M-2*i+a)+925025e-9*Math.sin(t.M+2*i)+802851e-9*Math.sin(2*i-a)+715585e-9*Math.sin(t.M-a)+-610865e-9*Math.sin(i)+-541052e-9*Math.sin(t.M+a)+-261799e-9*Math.sin(2*r-2*i)+191986e-9*Math.sin(t.M-4*i);t.ra+=o;var s=-.003019*Math.sin(r-2*i)+-959931e-9*Math.sin(t.M-r-2*i)+-802851e-9*Math.sin(t.M+r-2*i)+575958e-9*Math.sin(r+2*i)+296706e-9*Math.sin(2*t.M+r);return t.dec+=s,t.age=it.normalize(t.l-e.l+Math.PI),t.phase=.5*(1-Math.cos(t.age)),t}},mt=function(t,e){function a(){var t=f("mon").value,e=f("yr").value,a=new Date(e,t,1),n=d3.select("#cal"),r=new Date;e=parseInt(e),t=parseInt(t),a.setDate(a.getDate()-a.getDay());for(var i=n.node();i.firstChild;)i.removeChild(i.firstChild);for(var o=0;7>o;o++)n.append("div").classed({date:!0,weekday:!0}).html(w[o]);for(o=0;42>o;o++){var s=a.getMonth(),l=a.getDay(),c=x(a);n.append("div").classed({date:!0,grey:s!==t,weekend:s===t&&(0===l||6===l),today:0===k(a,r),selected:0===k(a,g)}).attr("id",c).on("click",M).html(a.getDate().toString()),a.setDate(a.getDate()+1)}}function n(){P.append("select").attr("title","Year").attr("id","yr").on("change",a),r()}function r(){var t=d3.select("select#yr"),e=g.getFullYear(),a=0,n=c(g);t.selectAll("*").remove(),t.selectAll("option").data(n).enter().append("option").text(function(t,n){return t===e&&(a=n),t.toString()}),t.property("selectedIndex",a)}function i(){var t=P.append("select").attr("title","Month").attr("id","mon").on("change",a),e=0,n=g.getMonth();t.selectAll("option").data(b).enter().append("option").attr("value",function(t,a){return a===n&&(e=a),a}).text(function(t){return t}),t.property("selectedIndex",e)}function o(t){P.append("div").attr("id",t).on("click",function(){var e=f("mon"),n=f("yr");"left"===t?0===e.selectedIndex?(e.selectedIndex=11,n.selectedIndex--):e.selectedIndex--:11===e.selectedIndex?(e.selectedIndex=0,n.selectedIndex++):e.selectedIndex++,a()})}function s(){P.append("input").attr("type","number").attr("id","hr").attr("title","Hours").attr("max","24").attr("min","-1").attr("step","1").attr("value",g.getHours()).on("change",function(){j(this)===!0&&M()}),P.append("input").attr("type","number").attr("id","min").attr("title","Minutes").attr("max","60").attr("min","-1").attr("step","1").attr("value",g.getMinutes()).on("change",function(){j(this)===!0&&M()}),P.append("input").attr("type","number").attr("id","sec").attr("title","Seconds").attr("max","60").attr("min","-1").attr("step","1").attr("value",g.getSeconds()).on("change",function(){j(this)===!0&&M()})}function l(){var t=P.append("select").attr("title","Time zone offset from UTC").attr("id","tz").on("change",M),e=15,a=g.getTimezoneOffset();t.selectAll("option").data(v).enter().append("option").attr("value",function(t,n){var r=Object.keys(t)[0];return t[r]===a&&(e=n),t[r]}).text(function(t){return Object.keys(t)[0]}),t.property("selectedIndex",e)}function c(t){for(var e=h(t.getFullYear()),a=[],n=e[0];n<=e[1];n++)a.push(n);return a}function h(t){return!z||z.length<1?[t-10,t+10]:1===z.length&&y(z[0])?z[0]>=100?[z[0]-10,z[0]+10]:[t-z[0],t+z[0]]:2===z.length&&y(z[0])&&y(z[1])?z[1]>=100?[z[0],z[1]]:[z[0]-z[1],z[0]+z[1]]:[t-10,t+10]}function u(t,e){for(var a=f(t),n=0;n<a.childNodes.length;n++)if(a.childNodes[n].value==e){a.selectedIndex=n;break}}function p(t){t&&g.setTime(t.valueOf()),u("yr",g.getFullYear()),u("mon",g.getMonth()),a(),f("hr").value=g.getHours(),f("min").value=g.getMinutes(),f("sec").value=g.getSeconds()}function d(){d3.select("#celestial-date").style("opacity",0),d3.select("#error").style({top:"-9999px",left:"-9999px",opacity:0}),d3.select("#datepick").classed("active",!1),setTimeout(function(){f("celestial-date").style.top=m(-9999)},600)}function M(){var t=f("hr").value,a=f("min").value,n=f("sec").value,i=f("tz").value;this.id&&-1!==this.id.search(/^\d/)&&(g=x.parse(this.id)),r(),g.setHours(t,a,n),p(),e(g,i)}var g=new Date,v=(d3.time.format("%Z"),[{"−12:00":720},{"−11:00":660},{"−10:00":600},{"−09:30":570},{"−09:00":540},{"−08:00":480},{"−07:00":420},{"−06:00":360},{"−05:00":300},{"−04:30":270},{"−04:00":240},{"−03:30":210},{"−03:00":180},{"−02:00":120},{"−01:00":60},{"±00:00":0},{"+01:00":-60},{"+02:00":-120},{"+03:00":-180},{"+03:30":-210},{"+04:00":-240},{"+04:30":-270},{"+05:00":-300},{"+05:30":-330},{"+05:45":-345},{"+06:00":-360},{"+06:30":-390},{"+07:00":-420},{"+08:00":-480},{"+08:30":-510},{"+08:45":-525},{"+09:00":-540},{"+09:30":-570},{"+10:00":-600},{"+10:30":-630},{"+11:00":-660},{"+12:00":-720},{"+12:45":-765},{"+13:00":-780},{"+14:00":-840}]),b=["January","February","March","April","May","June","July","August","September","October","November","December"],w=["Su","M","Tu","W","Th","F","Sa"],x=(c(g),d3.time.format("%Y-%m-%d")),z=t.daterange||[],P=d3.select("#celestial-form").append("div").attr("id","celestial-date");o("left"),i(),n(),o("right");P.append("div").attr("id","cal");a(),s(),l(),this.show=function(t){var e=f("celestial-date"),a=f("datepick"),n=a.offsetLeft+a.offsetWidth-e.offsetWidth,r=a.offsetTop-e.offsetHeight-1;-9999===e.offsetTop?(g.setTime(t.valueOf()),p(),d3.select("#celestial-date").style({top:m(r),left:m(n),opacity:1}),d3.select("#datepick").classed("active",!0)):d()},this.isVisible=function(){return-9999!==f("celestial-date").offsetTop},this.hide=function(){d()}};!function(){function t(t,e,a){var n=t.translate(),r=Math.atan2(e[1]-n[1],e[0]-n[0])-Math.atan2(a[1]-n[1],a[0]-n[0]);return[Math.cos(r/2),0,0,Math.sin(r/2)]}function e(t,e){var a=t.invert(e);return a&&isFinite(a[0])&&isFinite(a[1])&&s(a)}function a(t){var e=.5*t[0]*u,a=.5*t[1]*u,n=.5*t[2]*u,r=Math.sin(e),i=Math.cos(e),o=Math.sin(a),s=Math.cos(a),l=Math.sin(n),c=Math.cos(n);return[i*s*c+r*o*l,r*s*c-i*o*l,i*o*c+r*s*l,i*s*l-r*o*c]}function n(t,e){var a=t[0],n=t[1],r=t[2],i=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[a*o-n*s-r*l-i*c,a*s+n*o+r*c-i*l,a*l-n*c+r*o+i*s,a*c+n*l-r*s+i*o]}function r(t,e){if(t&&e){var a=c(t,e),n=Math.sqrt(l(a,a)),r=.5*Math.acos(Math.max(-1,Math.min(1,l(t,e)))),i=Math.sin(r)/n;return n&&[Math.cos(r),a[2]*i,-a[1]*i,a[0]*i]}}function i(t,e){var a=Math.max(-1,Math.min(1,l(t,e))),n=0>a?-1:1,r=Math.acos(n*a),i=Math.sin(r);return i?function(a){var o=n*Math.sin((1-a)*r)/i,s=Math.sin(a*r)/i;return[t[0]*o+e[0]*s,t[1]*o+e[1]*s,t[2]*o+e[2]*s,t[3]*o+e[3]*s]}:function(){return t}}function o(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*p,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*p,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*p]}function s(t){var e=t[0]*u,a=t[1]*u,n=Math.cos(a);return[n*Math.cos(e),n*Math.sin(e),Math.sin(a)]}function l(t,e){for(var a=0,n=t.length,r=0;n>a;++a)r+=t[a]*e[a];return r}function c(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function h(t){for(var e=0,a=arguments.length,n=[];++e<a;)n.push(arguments[e]);var r=d3.dispatch.apply(null,n);return r.of=function(e,a){return function(n){try{var i=n.sourceEvent=d3.event;n.target=t,d3.event=n,r[n.type].apply(e,a)}finally{d3.event=i}}},r}var u=Math.PI/180,p=180/Math.PI;d3.geo.zoom=function(){function l(t){m++||t({type:"zoomstart"})}function c(t){t({type:"zoom"})}function u(t){--m||t({type:"zoomend"})}var p,d,f,m=0,M=h(g,"zoomstart","zoom","zoomend"),g=d3.behavior.zoom().on("zoomstart",function(){var i=d3.mouse(this),s=a(p.rotate()),h=e(p,i);h&&(f=h),v.call(g,"zoom",function(){p.scale(y.k=d3.event.scale);var a=d3.mouse(this),l=r(f,e(p,a));p.rotate(y.r=o(s=l?n(s,l):n(t(p,i,a),s))),i=a,c(M.of(this,arguments))}),l(M.of(this,arguments))}).on("zoomend",function(){v.call(g,"zoom",null),u(M.of(this,arguments))}),v=g.on,y={r:[0,0,0],k:1};return g.rotateTo=function(t){var e=r(s(t),s([-y.r[0],-y.r[1]]));return o(n(a(y.r),e))},g.projection=function(t){return arguments.length?(p=t,y={r:p.rotate(),k:p.scale()},g.scale(y.k)):p},g.duration=function(t){return arguments.length?(d=t,g):d},g.event=function(t){t.each(function(){var t=d3.select(this),e=M.of(this,arguments),n=y,r=d3.transition(t);if(r!==t){r.each("start.zoom",function(){this.__chart__&&(y=this.__chart__,y.hasOwnProperty("r")||(y.r=p.rotate())),p.rotate(y.r).scale(y.k),l(e)}).tween("zoom:zoom",function(){var t=g.size()[0],s=i(a(y.r),a(n.r)),l=d3.geo.distance(y.r,n.r),h=d3.interpolateZoom([0,0,t/y.k],[l,0,t/n.k]);return d&&r.duration(d(.001*h.duration)),function(a){var n=h(a);this.__chart__=y={r:o(s(n[0]/l)),k:t/n[2]},p.rotate(y.r).scale(y.k),g.scale(y.k),c(e)}}).each("end.zoom",function(){u(e)});try{r.each("interrupt.zoom",function(){u(e)})}catch(s){console.log(s)}}else this.__chart__=y,l(e),c(e),u(e)})},d3.rebind(g,M,"on")}}(),this.Celestial=W}();