astro-viewer 3.7.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +325 -222
- package/dist/astroviewer.cjs +654 -108
- package/dist/astroviewer.cjs.map +1 -1
- package/dist/astroviewer.js +655 -108
- package/dist/astroviewer.js.map +1 -1
- package/dist/astroviewer.min.js +1 -1
- package/dist/astroviewer.min.js.map +1 -1
- package/lib-esm/AstroSphere.d.ts +13 -1
- package/lib-esm/AstroSphere.d.ts.map +1 -1
- package/lib-esm/AstroSphere.js +94 -5
- package/lib-esm/AstroSphere.js.map +1 -1
- package/lib-esm/AstroViewer.d.ts +11 -0
- package/lib-esm/AstroViewer.d.ts.map +1 -1
- package/lib-esm/AstroViewer.js +37 -2
- package/lib-esm/AstroViewer.js.map +1 -1
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.d.ts.map +1 -1
- package/lib-esm/index.js +0 -1
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/model/grid/HealpixGrid.d.ts.map +1 -1
- package/lib-esm/model/grid/HealpixGrid.js +7 -1
- package/lib-esm/model/grid/HealpixGrid.js.map +1 -1
- package/lib-esm/model/hips/AllSky.d.ts +0 -1
- package/lib-esm/model/hips/AllSky.d.ts.map +1 -1
- package/lib-esm/model/hips/AllSky.js +11 -32
- package/lib-esm/model/hips/AllSky.js.map +1 -1
- package/lib-esm/model/hips/AncestorTile.d.ts.map +1 -1
- package/lib-esm/model/hips/AncestorTile.js +10 -27
- package/lib-esm/model/hips/AncestorTile.js.map +1 -1
- package/lib-esm/model/hips/FitsTileLoader.d.ts +4 -0
- package/lib-esm/model/hips/FitsTileLoader.d.ts.map +1 -1
- package/lib-esm/model/hips/FitsTileLoader.js +39 -1
- package/lib-esm/model/hips/FitsTileLoader.js.map +1 -1
- package/lib-esm/model/hips/HiPS.d.ts +31 -0
- package/lib-esm/model/hips/HiPS.d.ts.map +1 -1
- package/lib-esm/model/hips/HiPS.js +193 -0
- package/lib-esm/model/hips/HiPS.js.map +1 -1
- package/lib-esm/model/hips/HiPSCoverage.d.ts +6 -1
- package/lib-esm/model/hips/HiPSCoverage.d.ts.map +1 -1
- package/lib-esm/model/hips/HiPSCoverage.js +20 -2
- package/lib-esm/model/hips/HiPSCoverage.js.map +1 -1
- package/lib-esm/model/hips/Tile.d.ts +0 -1
- package/lib-esm/model/hips/Tile.d.ts.map +1 -1
- package/lib-esm/model/hips/Tile.js +9 -27
- package/lib-esm/model/hips/Tile.js.map +1 -1
- package/lib-esm/model/hips/TileBuffer.d.ts.map +1 -1
- package/lib-esm/model/hips/TileBuffer.js +6 -0
- package/lib-esm/model/hips/TileBuffer.js.map +1 -1
- package/lib-esm/shader/HiPSShaderProgram.d.ts +7 -1
- package/lib-esm/shader/HiPSShaderProgram.d.ts.map +1 -1
- package/lib-esm/shader/HiPSShaderProgram.js +23 -1
- package/lib-esm/shader/HiPSShaderProgram.js.map +1 -1
- package/lib-esm/shader/ShaderManager.d.ts.map +1 -1
- package/lib-esm/shader/ShaderManager.js +46 -10
- package/lib-esm/shader/ShaderManager.js.map +1 -1
- package/package.json +1 -1
package/dist/astroviewer.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("astroviewer",[],t):"object"==typeof exports?exports.astroviewer=t():e.astroviewer=t()}(self,()=>(()=>{var e={3890(e,t,i){"use strict";i.d(t,{mat4:()=>r,vec3:()=>s,vec4:()=>o});var r={};i.r(r),i.d(r,{clone:()=>h,create:()=>l,fromValues:()=>c,identity:()=>d,invert:()=>g,multiply:()=>_,perspective:()=>m,rotate:()=>f,set:()=>u,targetTo:()=>x,translate:()=>p});var s={};i.r(s),i.d(s,{add:()=>y,clone:()=>S,create:()=>b,cross:()=>I,dot:()=>A,fromValues:()=>M,length:()=>v,normalize:()=>E,scale:()=>w,scaleAndAdd:()=>C,set:()=>T,subtract:()=>P,transformMat4:()=>F});var o={};i.r(o),i.d(o,{create:()=>L,fromValues:()=>D,transformMat4:()=>B});var a=1e-6,n="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI,Math.PI;function l(){var e=new n(16);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function h(e){var t=new n(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function c(e,t,i,r,s,o,a,l,h,c,u,d,g,_,p,f){var m=new n(16);return m[0]=e,m[1]=t,m[2]=i,m[3]=r,m[4]=s,m[5]=o,m[6]=a,m[7]=l,m[8]=h,m[9]=c,m[10]=u,m[11]=d,m[12]=g,m[13]=_,m[14]=p,m[15]=f,m}function u(e,t,i,r,s,o,a,n,l,h,c,u,d,g,_,p,f){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=o,e[5]=a,e[6]=n,e[7]=l,e[8]=h,e[9]=c,e[10]=u,e[11]=d,e[12]=g,e[13]=_,e[14]=p,e[15]=f,e}function d(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function g(e,t){var i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],n=t[5],l=t[6],h=t[7],c=t[8],u=t[9],d=t[10],g=t[11],_=t[12],p=t[13],f=t[14],m=t[15],x=i*n-r*a,b=i*l-s*a,S=i*h-o*a,v=r*l-s*n,M=r*h-o*n,T=s*h-o*l,y=c*p-u*_,P=c*f-d*_,w=c*m-g*_,C=u*f-d*p,E=u*m-g*p,A=d*m-g*f,I=x*A-b*E+S*C+v*w-M*P+T*y;return I?(I=1/I,e[0]=(n*A-l*E+h*C)*I,e[1]=(s*E-r*A-o*C)*I,e[2]=(p*T-f*M+m*v)*I,e[3]=(d*M-u*T-g*v)*I,e[4]=(l*w-a*A-h*P)*I,e[5]=(i*A-s*w+o*P)*I,e[6]=(f*S-_*T-m*b)*I,e[7]=(c*T-d*S+g*b)*I,e[8]=(a*E-n*w+h*y)*I,e[9]=(r*w-i*E-o*y)*I,e[10]=(_*M-p*S+m*x)*I,e[11]=(u*S-c*M-g*x)*I,e[12]=(n*P-a*C-l*y)*I,e[13]=(i*C-r*P+s*y)*I,e[14]=(p*b-_*v-f*x)*I,e[15]=(c*v-u*b+d*x)*I,e):null}function _(e,t,i){var r=t[0],s=t[1],o=t[2],a=t[3],n=t[4],l=t[5],h=t[6],c=t[7],u=t[8],d=t[9],g=t[10],_=t[11],p=t[12],f=t[13],m=t[14],x=t[15],b=i[0],S=i[1],v=i[2],M=i[3];return e[0]=b*r+S*n+v*u+M*p,e[1]=b*s+S*l+v*d+M*f,e[2]=b*o+S*h+v*g+M*m,e[3]=b*a+S*c+v*_+M*x,b=i[4],S=i[5],v=i[6],M=i[7],e[4]=b*r+S*n+v*u+M*p,e[5]=b*s+S*l+v*d+M*f,e[6]=b*o+S*h+v*g+M*m,e[7]=b*a+S*c+v*_+M*x,b=i[8],S=i[9],v=i[10],M=i[11],e[8]=b*r+S*n+v*u+M*p,e[9]=b*s+S*l+v*d+M*f,e[10]=b*o+S*h+v*g+M*m,e[11]=b*a+S*c+v*_+M*x,b=i[12],S=i[13],v=i[14],M=i[15],e[12]=b*r+S*n+v*u+M*p,e[13]=b*s+S*l+v*d+M*f,e[14]=b*o+S*h+v*g+M*m,e[15]=b*a+S*c+v*_+M*x,e}function p(e,t,i){var r,s,o,a,n,l,h,c,u,d,g,_,p=i[0],f=i[1],m=i[2];return t===e?(e[12]=t[0]*p+t[4]*f+t[8]*m+t[12],e[13]=t[1]*p+t[5]*f+t[9]*m+t[13],e[14]=t[2]*p+t[6]*f+t[10]*m+t[14],e[15]=t[3]*p+t[7]*f+t[11]*m+t[15]):(r=t[0],s=t[1],o=t[2],a=t[3],n=t[4],l=t[5],h=t[6],c=t[7],u=t[8],d=t[9],g=t[10],_=t[11],e[0]=r,e[1]=s,e[2]=o,e[3]=a,e[4]=n,e[5]=l,e[6]=h,e[7]=c,e[8]=u,e[9]=d,e[10]=g,e[11]=_,e[12]=r*p+n*f+u*m+t[12],e[13]=s*p+l*f+d*m+t[13],e[14]=o*p+h*f+g*m+t[14],e[15]=a*p+c*f+_*m+t[15]),e}function f(e,t,i,r){var s,o,n,l,h,c,u,d,g,_,p,f,m,x,b,S,v,M,T,y,P,w,C,E,A=r[0],I=r[1],F=r[2],R=Math.sqrt(A*A+I*I+F*F);return R<a?null:(A*=R=1/R,I*=R,F*=R,s=Math.sin(i),n=1-(o=Math.cos(i)),l=t[0],h=t[1],c=t[2],u=t[3],d=t[4],g=t[5],_=t[6],p=t[7],f=t[8],m=t[9],x=t[10],b=t[11],S=A*A*n+o,v=I*A*n+F*s,M=F*A*n-I*s,T=A*I*n-F*s,y=I*I*n+o,P=F*I*n+A*s,w=A*F*n+I*s,C=I*F*n-A*s,E=F*F*n+o,e[0]=l*S+d*v+f*M,e[1]=h*S+g*v+m*M,e[2]=c*S+_*v+x*M,e[3]=u*S+p*v+b*M,e[4]=l*T+d*y+f*P,e[5]=h*T+g*y+m*P,e[6]=c*T+_*y+x*P,e[7]=u*T+p*y+b*P,e[8]=l*w+d*C+f*E,e[9]=h*w+g*C+m*E,e[10]=c*w+_*C+x*E,e[11]=u*w+p*C+b*E,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}var m=function(e,t,i,r,s){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var a=1/(r-s);e[10]=(s+r)*a,e[14]=2*s*r*a}else e[10]=-1,e[14]=-2*r;return e};function x(e,t,i,r){var s=t[0],o=t[1],a=t[2],n=r[0],l=r[1],h=r[2],c=s-i[0],u=o-i[1],d=a-i[2],g=c*c+u*u+d*d;g>0&&(c*=g=1/Math.sqrt(g),u*=g,d*=g);var _=l*d-h*u,p=h*c-n*d,f=n*u-l*c;return(g=_*_+p*p+f*f)>0&&(_*=g=1/Math.sqrt(g),p*=g,f*=g),e[0]=_,e[1]=p,e[2]=f,e[3]=0,e[4]=u*f-d*p,e[5]=d*_-c*f,e[6]=c*p-u*_,e[7]=0,e[8]=c,e[9]=u,e[10]=d,e[11]=0,e[12]=s,e[13]=o,e[14]=a,e[15]=1,e}function b(){var e=new n(3);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function S(e){var t=new n(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function v(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function M(e,t,i){var r=new n(3);return r[0]=e,r[1]=t,r[2]=i,r}function T(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e}function y(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function P(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function w(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function C(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function E(e,t){var i=t[0],r=t[1],s=t[2],o=i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function A(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function I(e,t,i){var r=t[0],s=t[1],o=t[2],a=i[0],n=i[1],l=i[2];return e[0]=s*l-o*n,e[1]=o*a-r*l,e[2]=r*n-s*a,e}function F(e,t,i){var r=t[0],s=t[1],o=t[2],a=i[3]*r+i[7]*s+i[11]*o+i[15];return a=a||1,e[0]=(i[0]*r+i[4]*s+i[8]*o+i[12])/a,e[1]=(i[1]*r+i[5]*s+i[9]*o+i[13])/a,e[2]=(i[2]*r+i[6]*s+i[10]*o+i[14])/a,e}var R;R=b();function L(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function D(e,t,i,r){var s=new n(4);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s}function B(e,t,i){var r=t[0],s=t[1],o=t[2],a=t[3];return e[0]=i[0]*r+i[4]*s+i[8]*o+i[12]*a,e[1]=i[1]*r+i[5]*s+i[9]*o+i[13]*a,e[2]=i[2]*r+i[6]*s+i[10]*o+i[14]*a,e[3]=i[3]*r+i[7]*s+i[11]*o+i[15]*a,e}!function(){var e=L()}()},4723(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(2919),o=r(i(7734)),a=r(i(4639)),n=r(i(4382)),l=r(i(4396)),h=i(7930),c=i(3726),u=i(9685),d=i(6553),g=i(8083),_=i(9839),p=i(4595),f=i(8145),m=r(i(619)),x=i(5409),b=i(3956),S=i(8868),v=i(1741),M=i(6878),T=i(3890);class y{static MIN_WHEEL_SCALE=.85;static MAX_WHEEL_SCALE=1.8;_camera;_perspectiveMatrixManager;centralPoinCoords;mousePointCoords;canvas;_healpixGrid;_equatorialGrid;mouseHelper;mouseDown=!1;lastMouseX=null;lastMouseY=null;inertiaX=0;inertiaY=0;zoomInertia=0;pointerDownX=null;pointerDownY=null;pointerDownAt=0;_activeHiPS=null;_activeXYZ2=null;_activeMeshHiPS=null;_activeBaseLayer=null;startup=!0;fov;activeCatalogues=[];activeFootprintSets=[];activePolylineSets=[];activeSensorCones=[];activeSatelliteObjects=[];_webgl;_selectedColorMap;_cameraStatusChanged=!1;lastCameraChangedAt=0;lastCameraMotionAt=0;lastHoveredSource=null;lastHoveredCatalogue=null;zoomSensitivity=1;lockedEastWestRaDeg=null;lockedNorthSouthDecDeg=null;keepCameraNorthUp=!0;gridLabelContainers;constructor(e,t,i={}){console.log("[AstroSphere] new instance for canvas",e.id),this._webgl=t,this.mouseHelper=new l.default,this.canvas=e,this.gridLabelContainers=i.gridLabelContainers;this._selectedColorMap=m.default.native,n.default.insideSphere=s.bootSetup.insideSphere,this.initCamera(),this._healpixGrid=new p.HealpixGrid(this._webgl,this.gridLabelContainers),this._perspectiveMatrixManager=new u.PerspectiveMatrixManager(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._equatorialGrid=new _.EquatorialGrid(this._webgl,this._healpixGrid,this.gridLabelContainers),this._equatorialGrid.init(this._healpixGrid.getMinFoV()),this.updateCentralPoint(),this.startup=!0,this.addEventListeners(e),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}initCamera(){s.bootSetup.insideSphere?this._camera=new o.default([0,0,-.005],!0):this._camera=new o.default([0,0,4],!1)}setCamera(e){this._camera=e}setCameraRotationSensitivity(e){this._camera.setRotationSensitivity(e)}getCameraRotationSensitivity(){return this._camera.getRotationSensitivity()}get healpixGrid(){return this._healpixGrid}get equatorialGrid(){return this._equatorialGrid}updateCentralPoint(){const e=this.getPhiThetaDeg(this.canvas),t=(0,h.sphericalToAstroDeg)(e.phi,e.theta),i=(0,h.raDegToHMS)(t.ra),r=(0,h.decDegToDMS)(t.dec);return this.centralPoinCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.centralPoinCoords}updateLastMousePoint(){const e={phi:this.mouseHelper.phi,theta:this.mouseHelper.theta},t={ra:this.mouseHelper.ra,dec:this.mouseHelper.dec},i=this.mouseHelper.raHMS,r=this.mouseHelper.decDMS;return this.mousePointCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.mousePointCoords}clearLastMousePoint(){this.mousePointCoords=void 0}getCentralPointCoordinates(){return this.centralPoinCoords}getLastMousePointCoordinates(){return this.mousePointCoords}clamp(e,t,i){return Math.min(i,Math.max(t,e))}computeZoomStep(e,t){const i=t<0?-1:1,r=this.clamp(Math.abs(t)/120,y.MIN_WHEEL_SCALE,y.MAX_WHEEL_SCALE);return i*this.clamp(.0012+.0025*Math.sqrt(Math.max(e,0)),.0012,.04)*r*this.zoomSensitivity}setZoomSensitivity(e){this.zoomSensitivity=this.clamp(e,.2,3)}getZoomSensitivity(){return this.zoomSensitivity}filterRotationDeltaByAstroLocks(e,t){const i=this._camera.isRotationLockedY(),r=this._camera.isRotationLockedX();if(!i&&!r)return{deltaX:e,deltaY:t};const s=a.default.getIntersectionPointWithSingleModel(this.canvas.clientWidth/2,this.canvas.clientHeight/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!s||s.length<3)return{deltaX:e,deltaY:t};const o=T.vec3.normalize(T.vec3.create(),T.vec3.fromValues(s[0],s[1],s[2])),n=T.vec3.fromValues(0,0,1),l=T.vec3.cross(T.vec3.create(),n,o);T.vec3.length(l)<1e-6?T.vec3.set(l,1,0,0):T.vec3.normalize(l,l);const h=T.vec3.scale(T.vec3.create(),o,T.vec3.dot(n,o)),c=T.vec3.subtract(T.vec3.create(),n,h);T.vec3.length(c)<1e-6&&T.vec3.cross(c,o,l),T.vec3.normalize(c,c);const u=this.projectModelDirectionToScreen(o,l),d=this.projectModelDirectionToScreen(o,c);if(!u||!d)return{deltaX:e,deltaY:t};let g=e,_=t;if(i){const e=g*u.x+_*u.y;g-=e*u.x,_-=e*u.y}if(r){const e=g*d.x+_*d.y;g-=e*d.x,_-=e*d.y}return{deltaX:g,deltaY:_}}projectModelDirectionToScreen(e,t){const i=T.vec3.scaleAndAdd(T.vec3.create(),e,t,.01),r=this.projectModelPointToScreen(e),s=this.projectModelPointToScreen(i);if(!r||!s)return null;const o=s.x-r.x,a=s.y-r.y,n=Math.hypot(o,a);return n<1e-6?null:{x:o/n,y:a/n}}projectModelPointToScreen(e){const t=this._camera.getCameraMatrix(),i=this._healpixGrid.getModelMatrix(),r=T.mat4.create(),s=T.mat4.create();T.mat4.multiply(r,t,i),T.mat4.multiply(s,this._perspectiveMatrixManager.pMatrix,r);const o=T.vec4.fromValues(e[0],e[1],e[2],1);return T.vec4.transformMat4(o,o,s),Math.abs(o[3])<1e-6?null:{x:o[0]/o[3],y:-o[1]/o[3]}}enforceAstronomicalRotationLocks(){if(null==this.lockedEastWestRaDeg&&null==this.lockedNorthSouthDecDeg)return!1;const e=this.updateCentralPoint();if(!e)return!1;const t=this.lockedEastWestRaDeg??e.astroDeg.ra,i=this.lockedNorthSouthDecDeg??e.astroDeg.dec;return(Math.abs(t-e.astroDeg.ra)>1e-6||Math.abs(i-e.astroDeg.dec)>1e-6)&&(this._camera.goTo(t,i),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}enforceCameraNorthUp(){if(!this.keepCameraNorthUp)return!1;const e=this.updateCentralPoint();return!!e&&(this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}emitCameraChanged(e){if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid?.fovObj)return;const t=this.getCurrentStatus();t&&this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:t,bubbles:!0,composed:!0}))}addEventListeners(e){n.default.debug&&console.log("[AstroSphere::addEventListeners]");const t=e.getBoundingClientRect();this.lastMouseX=t.left,this.lastMouseY=t.top;console.log("[AstroSphere] registering pointer and wheel listeners on canvas"),e.onpointerdown=t=>{e.setPointerCapture(t.pointerId),this.mouseDown=!0;const i=e.getBoundingClientRect();this.lastMouseX=t.clientX-i.left,this.lastMouseY=t.clientY-i.top,this.pointerDownX=this.lastMouseX,this.pointerDownY=this.lastMouseY,this.pointerDownAt=Date.now();const r=a.default.getIntersectionPointWithSingleModel(this.lastMouseX,this.lastMouseY,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return r&&r.length>0?(this.mouseHelper.update(r),this.updateLastMousePoint()):this.clearLastMousePoint(),t.preventDefault(),!1},e.onpointerup=t=>{if(e.releasePointerCapture(t.pointerId),this.mouseDown=!1,document.body.style.cursor="auto",0!==t.button)return t.preventDefault(),!1;const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top;this.lastMouseX=r,this.lastMouseY=s;const o=Math.hypot(r-(this.pointerDownX??r),s-(this.pointerDownY??s)),n=Date.now()-this.pointerDownAt;if(o<=4&&n<=250){const e=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(e&&e.length>0){this.mouseHelper.update(e),this.updateLastMousePoint();for(const e of this.activeCatalogues){const t=e.selectPrimarySourceFromClick(this.mouseHelper);t?.sources.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("source-clicked",{detail:{source:t.sources,selectionState:t.selectionState,catalogue:e},bubbles:!0,composed:!0}))}for(const e of this.activeFootprintSets){const t=e.selectPrimaryFootprintFromClick(this.mouseHelper);t?.footprints.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-clicked",{detail:{footprint:t.footprints,selectionState:t.selectionState,footprintSet:e},bubbles:!0,composed:!0}))}}}else this.clearLastMousePoint()},e.onpointermove=t=>{const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,o=r,l=s;if(this._healpixGrid){if(this.mouseDown){document.body.style.cursor="grab";const t=n.default.insideSphere?-1:1,i=n.default.insideSphere?10:1,r=t*i*(o-(this.lastMouseX??o))*Math.PI/e.width,s=t*i*(l-(this.lastMouseY??l))*Math.PI/e.height,a=this.filterRotationDeltaByAstroLocks(r,s);this.inertiaX+=.1*a.deltaX,this.inertiaY+=.1*a.deltaY,this.updateCentralPoint()}else{const e=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);e&&e.length>0?(this.mouseHelper.update(e),this.updateLastMousePoint()):this.clearLastMousePoint()}this.centralPoinCoords||this.updateCentralPoint(),this.lastMouseX=o,this.lastMouseY=l,this._cameraStatusChanged=!0,t.preventDefault()}},e.onpointerleave=()=>{this.clearLastMousePoint(),this._cameraStatusChanged=!0,this.emitCameraChanged("pointerleave")},console.log("[AstroSphere] adding wheel event listener with passive: false"),e.addEventListener("wheel",e=>{const t=this._healpixGrid.getMinFoV(),i=this.computeZoomStep(t,e.deltaY);this.zoomInertia=0,this._camera.zoom(i),this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this._cameraStatusChanged=!0,this.emitCameraChanged("wheel"),e.preventDefault()},{passive:!1}),e.addEventListener("contextmenu",t=>{t.preventDefault();const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,o=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!o||0===o.length)return!1;this.mouseHelper.update(o),this.updateLastMousePoint();for(const e of this.activeCatalogues){const i=e.getSourcesFromPointer(this.mouseHelper);if(i?.sources.length){this._webgl.canvas.dispatchEvent(new CustomEvent("source-contextmenu",{detail:{source:i.sources,catalogue:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}for(const e of this.activeFootprintSets){const i=e.getFootprintsFromPointer(this.mouseHelper);if(i?.footprints.length){this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-contextmenu",{detail:{footprint:i.footprints,footprintSet:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}return!1}),console.log("[AstroSphere] registering global keydown listener on document"),document.addEventListener("keydown",e=>{if(e.ctrlKey)switch(e.key){case"1":this._camera.clearRotationLock();break;case"2":this._camera.setRotationLock({x:!0,y:!1,z:!1});break;case"3":this._camera.setRotationLock({x:!1,y:!0,z:!1});break;case"4":this._camera.setRotationLock({x:!1,y:!1,z:!0})}},{capture:!0})}getPhiThetaDeg(e){const t=e.getBoundingClientRect(),i=t.width,r=t.height,s=a.default.getIntersectionPointWithSingleModel(i/2,r/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return(0,h.cartesianToSpherical)(s)}changeHiPSFormat(e){if(!this._activeHiPS)throw new Error("No active HiPS.");this._activeHiPS.changeFormat(e)}activateHiPS(e){this._activeHiPS&&this._healpixGrid.visibleTilesManager.tileBuffer.removeHiPS(this._activeHiPS),this._activeHiPS=new c.HiPS(1,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="hips"}activateXYZ(e){this.activateXYZ2(new S.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver)),this._activeBaseLayer="xyz"}activateXYZ2(e){this._activeXYZ2=new v.XYZMap(1,[0,0,0],0,0,e,this._webgl,this.gridLabelContainers),this._activeBaseLayer="xyz"}activateMeshHiPS(e){this._activeMeshHiPS=new M.MeshHiPS(e.meshRadius,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="meships"}activateWMTS(e){const t=new b.WMTSAdapter(e).toXYZLayerConfig();this._activeXYZ2=new v.XYZMap(1,[0,0,0],0,0,new S.XYZMapDescriptor(e.layer?`WMTS ${e.layer}`:"WMTS Earth2 Layer",t.urlTemplate,t.minZoom??0,t.maxZoom??8,t.segmentsPerSide??48,t.maxCachedTiles??384,8,t.urlResolver),this._webgl,this.gridLabelContainers),this._activeBaseLayer="xyz"}async showCatalogue(e){return e&&this.activeCatalogues.push(e),e}deleteCatalogue(e){this.activeCatalogues=this.activeCatalogues.filter(t=>t!==e)}async showFootprintSet(e){return e&&this.activeFootprintSets.push(e),e}deleteFootprintSet(e){this.activeFootprintSets=this.activeFootprintSets.filter(t=>t!==e)}async showPolylineSet(e){return e&&this.activePolylineSets.push(e),e}deletePolylineSet(e){this.activePolylineSets=this.activePolylineSets.filter(t=>t!==e),e.dispose()}async showSensorCone(e){return e&&this.activeSensorCones.push(e),e}deleteSensorCone(e){this.activeSensorCones=this.activeSensorCones.filter(t=>t!==e),e.dispose()}async showSatelliteObject(e){return e&&this.activeSatelliteObjects.push(e),e}deleteSatelliteObject(e){this.activeSatelliteObjects=this.activeSatelliteObjects.filter(t=>t!==e),e.dispose()}getHoveredFootprints(){let e=[];return this.activeFootprintSets.forEach(t=>{e.push(t.hoveredFootprints)}),e}goTo(e,t){this._camera.goTo(e,t)}getActiveCoordinateMode(){return"xyz"===this._activeBaseLayer?"lonlat":"hips"===this._activeBaseLayer&&this._activeHiPS?.isGalacticHips?"galactic":"equatorial"}resetAxesOrientation(){const e=this.updateCentralPoint();e&&(this.inertiaX=0,this.inertiaY=0,this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),this._cameraStatusChanged=!0)}setKeepCameraNorthUp(e){this.keepCameraNorthUp=e,e&&this.resetAxesOrientation()}isKeepCameraNorthUp(){return this.keepCameraNorthUp}getFoV(){return"xyz"===this._activeBaseLayer&&this._activeXYZ2?this._activeXYZ2.getFoV():this.fov}getFoVPolygon(){if(null==this.healpixGrid)throw new Error(`healpixGrid is ${this.healpixGrid}`);return g.FoVUtils.getFoVPolygon(this._camera,this.canvas,this._healpixGrid,this._healpixGrid,this._webgl,this._perspectiveMatrixManager.pMatrix)}changeFoV(e){const t=this._healpixGrid.getFoV().computeDistanceFromAngle(e);this._camera.translate(t),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}changeFoV2(e){const t=this._healpixGrid.getFoV().computeCameraPositionForFoV(e);this._camera.setCameraPosition(t)}changeFoV3(e){const t=this._healpixGrid.getFoV().computeCameraPositionForAngularDiameter(e);this._camera.setCameraPosition(t),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,!1)}getInsideSphere(){return n.default.insideSphere}toggleInsideSphere(){const e=this.updateCentralPoint();this.inertiaX=0,this.inertiaY=0,this.zoomInertia=0,n.default.insideSphere=!n.default.insideSphere,this._camera.toggleInsideSphere(),this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.updateCentralPoint(),this.lastCameraMotionAt=performance.now(),this._cameraStatusChanged=!0,this.emitCameraChanged("inside-sphere-toggle"),requestAnimationFrame(()=>this.draw(this.canvas))}setCameraPosition(e){this._camera.setCameraPosition(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}setCameraMatrix(e){this._camera.setCameraMatrix(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}_refreshingStatus=!1;applyFullCameraState(e,t){this._refreshingStatus=!0,this._camera=e.camera,this._healpixGrid.setModelMatrix(e.mMatrix),this._perspectiveMatrixManager.pMatrix=e.pMatrix,this.setCameraMatrix(e.vMatrix),t&&this._activeHiPS?.changeColorMap(e.colorMap),this._refreshingStatus=!1}getCurrentStatus(){this.updateCentralPoint();const e=this.centralPoinCoords?.astroDeg.ra,t=this.centralPoinCoords?.astroDeg.dec;if(null==e||null==t)return null;let i=[];try{i=this.getFoVPolygon()}catch(e){console.warn("[AstroSphere] getCurrentStatus: FoV polygon is not available.",e)}return{fovDeg:this.fov.minFoV,fovXDeg:this.fov.xFoV,fovYDeg:this.fov.yFoV,position:this._camera.getCameraPosition(),vMatrix:this._camera.getCameraMatrix(),pMatrix:this._perspectiveMatrixManager.pMatrix,mMatrix:this._healpixGrid.getModelMatrix(),camera:this._camera,timestamp:performance.now(),centralPoint:new d.Point({raDeg:e,decDeg:t},f.CoordsType.ASTRO),mouseHoverPoint:this.mousePointCoords,colorMap:this._selectedColorMap,getFoVPolygon:i}}changeColorMap(e){(this._activeHiPS||this._activeXYZ2||this._activeMeshHiPS)&&(this._selectedColorMap=e,this._activeHiPS?.changeColorMap(e),this._activeXYZ2?.changeColorMap(e))}prevFov=0;prevCentralRaDeg=null;prevCentralDecDeg=null;get activeHiPS(){return this._activeHiPS}get activeXYZ(){return this._activeXYZ2}get activeMeshHiPS(){return this._activeMeshHiPS}isLonLatGridVisible(){return this._activeXYZ2?.isLonLatGridVisible()??!1}toggleLonLatGrid(){return this._activeXYZ2?.toggleLonLatGrid()??!1}setEastWestRotationLocked(e){this._camera.setRotationLock({y:e}),e&&(this.inertiaX=0),this.lockedEastWestRaDeg=e?this.updateCentralPoint()?.astroDeg.ra??null:null}isEastWestRotationLocked(){return this._camera.isRotationLockedY()}setNorthSouthRotationLocked(e){this._camera.setRotationLock({x:e}),e&&(this.inertiaY=0),this.lockedNorthSouthDecDeg=e?this.updateCentralPoint()?.astroDeg.dec??null:null}isNorthSouthRotationLocked(){return this._camera.isRotationLockedX()}getXYZDebugStats(){return{activeBaseLayer:this._activeBaseLayer,layer:this._activeXYZ2?.getDebugStats()??null,requests:x.xyzTileRequestScheduler.getDebugStats()}}getHiPSDebugStats(){return this._activeHiPS?this._activeHiPS.getDebugStats():null}getMeshHiPSDebugStats(){return this._activeMeshHiPS?this._activeMeshHiPS.getDebugStats():null}draw(e){if(this._refreshingStatus)return;if(!this._webgl)return;if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid||0===Object.keys(this._healpixGrid).length)return;if(void 0===this._healpixGrid.fovObj)return;this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);let t=!1,i=0,r=0;if(this._webgl.viewport(0,0,this._webgl.drawingBufferWidth,this._webgl.drawingBufferHeight),this._webgl.clear(this._webgl.COLOR_BUFFER_BIT|this._webgl.DEPTH_BUFFER_BIT),0!==this.zoomInertia&&(Math.abs(this.zoomInertia)>1e-4?(this._camera.zoom(this.zoomInertia),this.zoomInertia*=.95,this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.prevFov!==this.fov.minFoV&&(this.centralPoinCoords||(this.centralPoinCoords=this.updateCentralPoint()),this.prevFov=this.fov.minFoV)):this.zoomInertia=0,this._cameraStatusChanged=!0),this.mouseDown||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02){t=!0;const o=this.filterRotationDeltaByAstroLocks(this.inertiaX,this.inertiaY);r=o.deltaX,i=o.deltaY,this.inertiaX=.95*o.deltaX,this.inertiaY=.95*o.deltaY,this._camera.rotate(r,i),this.lastCameraMotionAt=performance.now(),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);this.enforceAstronomicalRotationLocks()||this.enforceCameraNorthUp()}else this.inertiaY=0,this.inertiaX=0;const o=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix);if(Number.isFinite(o.minFoV)&&o.minFoV>0&&(this.fov=o,this._camera.refreshFoV(this.fov.minFoV),this.prevFov=this.fov.minFoV),t){const e=this.updateCentralPoint(),t=e.astroDeg.ra,i=e.astroDeg.dec,r=null===this.prevCentralRaDeg||Math.abs(t-this.prevCentralRaDeg)>1e-5,s=null===this.prevCentralDecDeg||Math.abs(i-this.prevCentralDecDeg)>1e-5;(r||s)&&(this.prevCentralRaDeg=t,this.prevCentralDecDeg=i)}if(this._cameraStatusChanged){const e=performance.now(),t=!this.mouseDown||e-this.lastCameraChangedAt>100,i=t?this.getCurrentStatus():null;i&&(this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:i,bubbles:!0,composed:!0})),this.lastCameraChangedAt=e),!this.startup&&t&&(this._cameraStatusChanged=!1)}if(this._webgl.disable(this._webgl.DEPTH_TEST),this._webgl.enable(this._webgl.BLEND),this._webgl.enable(this._webgl.CULL_FACE),this._webgl.cullFace(n.default.insideSphere?this._webgl.FRONT:this._webgl.BACK),this._webgl.blendFunc(this._webgl.SRC_ALPHA,this._webgl.ONE_MINUS_SRC_ALPHA),"hips"===this._activeBaseLayer&&this._activeHiPS){const e=Math.min(this._healpixGrid.visibleorder,this._activeHiPS.maxOrder);this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}if("meships"===this._activeBaseLayer&&this._activeMeshHiPS){const e=this._activeMeshHiPS.refreshOrder(this.fov?.minFoV??this._healpixGrid.getMinFoV());this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}const a=this.fov?.minFoV??this._healpixGrid.getMinFoV(),l=performance.now(),c=this.mouseDown||Math.abs(this.zoomInertia)>1e-4||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02||l-this.lastCameraMotionAt<220,u={fovDeg:a,camera:this._camera,pMatrix:this._perspectiveMatrixManager.pMatrix,centerSphericalDeg:this.updateCentralPoint().sphericalDeg,fovPolygon:void 0,viewportSphericalSamples:void 0,cameraMoving:c};if("hips"===this._activeBaseLayer&&this._activeHiPS?.draw(u),"xyz"===this._activeBaseLayer&&this._activeXYZ2?.draw(u),"meships"===this._activeBaseLayer&&this._activeMeshHiPS?.draw(u),this._healpixGrid.draw(u),this._equatorialGrid.draw(u),this._webgl.enable(this._webgl.DEPTH_TEST),this._webgl.disable(this._webgl.CULL_FACE),this.startup){this.startup=!1;const t=this.getPhiThetaDeg(e),i=(0,h.sphericalToAstroDeg)(t.phi,t.theta),r=(0,h.raDegToHMS)(i.ra),s=(0,h.decDegToDMS)(i.dec);this.prevFov=this.fov?.minFoV??this._healpixGrid.getMinFoV(),this._cameraStatusChanged=!0,console.log("(startup coords)",{raDeg:i.ra,decDeg:i.dec,raHMS:r,decDMS:s})}this.activeCatalogues.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.emitHoveredSourceIfChanged(),this.activeFootprintSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.activePolylineSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.activeSensorCones.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(this._perspectiveMatrixManager.pMatrix,this._camera.getCameraMatrix(),t)}),this.activeSatelliteObjects.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(this._perspectiveMatrixManager.pMatrix,this._camera.getCameraMatrix(),t)})}emitHoveredSourceIfChanged(){let e=null,t=null;for(const i of this.activeCatalogues){const r=i.getPrimaryHoveredSource();if(r){e=r,t=i;break}}e===this.lastHoveredSource&&t===this.lastHoveredCatalogue||(this.lastHoveredSource=e,this.lastHoveredCatalogue=t,this._webgl.canvas.dispatchEvent(new CustomEvent("source-hovered",{detail:{source:e,catalogue:t},bubbles:!0,composed:!0})))}}t.default=y},772(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AstroViewer=void 0;const s=r(i(4723)),o=i(5087),a=i(1232),n=i(592),l=i(2919),h=r(i(619)),c=i(5409),u=i(8868),d=i(5781),g=i(9022),_=i(3665),p=i(3603),f=i(3102),m=i(847);t.AstroViewer=class{astroSphere;canvas;webgl;rafId=null;webglContextList=new Map;viewfinderEl=null;viewfinderVisible=l.bootSetup.showViewfinder;viewfinderColor="rgba(75,148,226,0.68)";options={};run(){return this.tick()}createCatalogue(e,t,i,r){return new a.CatalogueGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showCatalogue(e){this.astroSphere.showCatalogue(e)}hideCatalogue(e,t){e.setIsVisible(t)}deleteCatalogue(e){this.astroSphere.deleteCatalogue(e)}changeCatalogueRA(e,t){return e.changeMetaRA(t),e}changeCatalogueDec(e,t){return e.changeMetaDec(t),e}changeCatalogueColor(e,t){return e.changeColor(t),e}setCatalogueShapeHue(e,t){return e.changeMetaShapeHue(t),e}setCatalogueShapeSize(e,t){return e.changeMetaShapeSize(t),e}createFootprintSet(e,t,i,r){return new n.FootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideFootprintSet(e,t){e.setIsVisible(t)}deleteFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPointSet(e,t,i,r){return new d.TerraPointSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPointSet(e){this.astroSphere.showCatalogue(e)}hideTerraPointSet(e,t){e.setIsVisible(t)}deleteTerraPointSet(e){this.astroSphere.deleteCatalogue(e)}createTerraFootprintSet(e,t,i,r){return new g.TerraFootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideTerraFootprintSet(e,t){e.setIsVisible(t)}deleteTerraFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPolylineSet(e,t,i,r){return new _.TerraPolylineSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPolylineSet(e){this.astroSphere.showPolylineSet(e)}hideTerraPolylineSet(e,t){e.setIsVisible(t)}deleteTerraPolylineSet(e){this.astroSphere.deletePolylineSet(e)}changeTerraPolylineSetColor(e,t){return e.changeColor(t),e}createSensorCone(e){return new f.SensorConeGL(e,this.webgl)}showSensorCone(e){this.astroSphere.showSensorCone(e)}hideSensorCone(e,t){e.setIsVisible(t)}deleteSensorCone(e){this.astroSphere.deleteSensorCone(e)}createSatelliteObject(e){return new p.SatelliteObjectGL(e,this.webgl)}showSatelliteObject(e){this.astroSphere.showSatelliteObject(e)}hideSatelliteObject(e,t){e.setIsVisible(t)}deleteSatelliteObject(e){this.astroSphere.deleteSatelliteObject(e)}changeFootprintSetColor(e,t){e.changeColor(t)}getHoveredFootprints(){return this.astroSphere.getHoveredFootprints()}getDefaultHiPSURL(){return l.bootSetup.defaultHipsUrl}activateHiPS(e){this.astroSphere.activateHiPS(e)}activateXYZ(e){this.astroSphere.activateXYZ(e)}activateXYZ2(e){const t=new u.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver);this.astroSphere.activateXYZ2(t)}activateWMTS(e){this.astroSphere.activateWMTS(e)}activateMeshHiPS(e){this.astroSphere.activateMeshHiPS(new m.MeshHiPSDescriptor(e))}setXYZMaxConcurrentRequests(e){c.xyzTileRequestScheduler.setMaxConcurrent(e)}getXYZMaxConcurrentRequests(){return c.xyzTileRequestScheduler.getMaxConcurrent()}getXYZDebugStats(){return this.astroSphere.getXYZDebugStats()}getHiPSDebugStats(){return this.astroSphere.getHiPSDebugStats()}getMeshHiPSDebugStats(){return this.astroSphere.getMeshHiPSDebugStats()}async loadHiPS(e){const t=e.endsWith("/")?e:e+"/",i=await fetch(t+"properties");if(!i.ok)throw new Error(`HTTP ${i.status} fetching properties`);const r=await i.text(),s=new o.HiPSDescriptor(r,t);return this.astroSphere.activateHiPS(s),s.surveyName}async loadMeshHiPS(e,t={}){const i=e.endsWith("/")?e:e+"/";let r="";const s=await fetch(i+"properties");if(s.ok)r=await s.text();else{const e=await fetch(i+"properties.json");if(!e.ok)throw new Error(`HTTP ${e.status} fetching MeshHiPS properties`);const t=await e.json();r=Object.entries(t).map(([e,t])=>`${e}=${String(t)}`).join("\n")}const o=new m.MeshHiPSDescriptor({...t,baseUrl:i},r);return this.astroSphere.activateMeshHiPS(o),o.name}changeColorMap(e){const t=h.default[e];this.astroSphere.changeColorMap(t)}changeCustomColorMap(e){this.astroSphere.changeColorMap(e)}getActiveHiPS(){return this.astroSphere.activeHiPS}changeHiPSFormat(e){this.astroSphere.changeHiPSFormat(e)}getActiveHiPSFormats(){return this.astroSphere.activeHiPS?.availableFormats??[]}getActiveXYZ(){return this.astroSphere.activeXYZ}setCamera(e){this.astroSphere.setCamera(e)}setCameraPosition(e){this.astroSphere.setCameraPosition(e)}setCameraMatrix(e){this.astroSphere.setCameraMatrix(e)}restoreAstroViewerState(e,t){this.astroSphere.applyFullCameraState(e,t)}getCurrentAstroViewerStatus(){return this.astroSphere.getCurrentStatus()}goTo(e,t){this.astroSphere.goTo(e,t)}getActiveCoordinateMode(){return this.astroSphere.getActiveCoordinateMode()}getCenterCoordinates(){return this.astroSphere.getCentralPointCoordinates()}getCoordinatesFromMouse(){return this.astroSphere.getLastMousePointCoordinates()}setModelMatrix(e){this.astroSphere.healpixGrid.setModelMatrix(e)}toggleHealpixGrid(){this.astroSphere.healpixGrid.toggleShowGrid()}isHealpixGridVisible(){return this.astroSphere.healpixGrid.isVisible()}toggleEquatorialGrid(){return this.astroSphere.equatorialGrid.toggleShowGrid()}isEquatorialGridVisible(){return this.astroSphere.equatorialGrid.isVisible()}toggleLonLatGrid(){return this.astroSphere.toggleLonLatGrid()}isLonLatGridVisible(){return this.astroSphere.isLonLatGridVisible()}setEastWestRotationLocked(e){this.astroSphere.setEastWestRotationLocked(e)}isEastWestRotationLocked(){return this.astroSphere.isEastWestRotationLocked()}setNorthSouthRotationLocked(e){this.astroSphere.setNorthSouthRotationLocked(e)}isNorthSouthRotationLocked(){return this.astroSphere.isNorthSouthRotationLocked()}resetAxesOrientation(){this.astroSphere.resetAxesOrientation()}setKeepCameraNorthUp(e){this.astroSphere.setKeepCameraNorthUp(e)}isKeepCameraNorthUp(){return this.astroSphere.isKeepCameraNorthUp()}getFoV(){return this.astroSphere.getFoV()}getFoVPolygon(){return this.astroSphere.getFoVPolygon()}changeFoV(e){this.astroSphere.changeFoV(e)}changeFoV2(e){this.astroSphere.changeFoV2(e)}changeFoV3(e){this.astroSphere.changeFoV3(e)}getInsideSphere(){return this.astroSphere.getInsideSphere()}toggleInsideSphere(){this.astroSphere.toggleInsideSphere()}toggleViewfinder(){return this.viewfinderVisible=!this.viewfinderVisible,this.syncViewfinderVisibility(),this.viewfinderVisible}setViewfinderVisible(e){this.viewfinderVisible=e,this.syncViewfinderVisibility()}isViewfinderVisible(){return this.viewfinderVisible}setViewfinderColor(e){this.viewfinderColor=e,this.syncViewfinderColor()}getViewfinderColor(){return this.viewfinderColor}setRotationSensitivity(e){this.astroSphere.setCameraRotationSensitivity(e)}getRotationSensitivity(){return this.astroSphere.getCameraRotationSensitivity()}setZoomSensitivity(e){this.astroSphere.setZoomSensitivity(e)}getZoomSensitivity(){return this.astroSphere.getZoomSensitivity()}constructor(e,t={}){this.options=t,this.init(e),this.webglContextList=new Map}init(e){console.log("init webgl"),this.canvas=e,this.initViewfinder();const t=this.canvas.getContext("webgl2",{alpha:!1});if(!t)throw alert("Could not initialise WebGL, sorry :-("),new Error("WebGL2 not available");this.webgl=t;try{this.webgl.clearColor(0,.06274509792,50*.00392156862,.7)}catch(e){console.log("Error instantiating WebGL context")}this.initListeners(),this.astroSphere=new s.default(this.canvas,this.webgl,{gridLabelContainers:this.options.gridLabelContainers})}initViewfinder(){const e=this.canvas.parentElement;if(!e)return;"static"===window.getComputedStyle(e).position&&(e.style.position="relative");const t=document.createElement("div");t.setAttribute("data-astro-viewfinder","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.width="44px",t.style.height="44px",t.style.transform="translate(-50%, -50%)",t.style.pointerEvents="none",t.style.zIndex="1",t.style.boxSizing="border-box";const i=[{left:"50%",top:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"50%",bottom:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"},{right:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"}];for(const e of i){const i=document.createElement("div");i.style.position="absolute",i.style.left=e.left??"auto",i.style.right=e.right??"auto",i.style.top=e.top??"auto",i.style.bottom=e.bottom??"auto",i.style.width=e.width,i.style.height=e.height,i.style.transform=e.transform,i.style.background="currentColor",i.style.borderRadius="999px",i.style.boxShadow="0 0 0 1px rgba(0, 0, 0, 0.14)",t.appendChild(i)}e.appendChild(t),this.viewfinderEl=t,this.syncViewfinderVisibility(),this.syncViewfinderColor()}syncViewfinderVisibility(){this.viewfinderEl&&(this.viewfinderEl.style.display=this.viewfinderVisible?"block":"none")}syncViewfinderColor(){this.viewfinderEl&&(this.viewfinderEl.style.color=this.viewfinderColor)}initListeners(){console.log("inside initListeners");const e=()=>{console.log("[resizeCanvas]");const e=this.canvas.getBoundingClientRect(),t=window.devicePixelRatio||1,i=Math.max(1,Math.floor(e.width*t)),r=Math.max(1,Math.floor(e.height*t));this.canvas.width===i&&this.canvas.height===r||(this.canvas.width=i,this.canvas.height=r,this.webgl.viewport(0,0,this.canvas.width,this.canvas.height))};if("ResizeObserver"in window){new ResizeObserver(()=>{e()}).observe(this.canvas)}window.addEventListener("resize",e),this.canvas.addEventListener("webglcontextlost",e=>{console.log("[handleContextLost]"),e.preventDefault(),null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)},!1),this.canvas.addEventListener("webglcontextrestored",e=>{console.log("[handleContextRestored]"),this.webgl.clearColor(0,.06274509792,50*.00392156862,.7),this.webgl.enable(this.webgl.DEPTH_TEST),this.rafId=requestAnimationFrame(()=>this.tick())},!1),e()}tick(){return this.drawScene(),this.rafId=requestAnimationFrame(()=>this.tick()),this.rafId}drawScene(){this.astroSphere.draw(this.canvas)}}},7734(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(3890),o=i(7930),a=r(i(4382));t.default=class{insideSphere=!1;cam_pos=s.vec3.create();cam_speed=1;vMatrix=s.mat4.create();T=s.mat4.create();R=s.mat4.create();FoV=180;previousFoV=180;move=s.vec3.create();phi=0;theta=0;rotationSensitivity=1;lockRotX=!1;lockRotY=!1;lockRotZ=!1;constructor(e,t){this.init(e,t)}init(e,t){this.insideSphere=t,this.cam_pos=s.vec3.clone(e),this.vMatrix=s.mat4.create(),this.T=s.mat4.create(),this.R=s.mat4.create(),s.mat4.translate(this.T,this.T,[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]),this.FoV=this.previousFoV=180,this.move=s.vec3.clone([0,0,0]);this.goTo(0,0)}goTo(e,t){this.goToPhiTheta((0,o.astroDegToSpherical)(e,t))}goToPhiTheta(e){const t=(0,o.sphericalToCartesian)(e.phi,e.theta,this.cam_pos[2]),i=s.vec3.normalize(s.vec3.create(),s.vec3.fromValues(t[0],t[1],t[2])),r=s.vec3.fromValues(0,0,1),a=s.vec3.scale(s.vec3.create(),i,s.vec3.dot(r,i)),n=s.vec3.subtract(s.vec3.create(),r,a);s.vec3.length(n)<1e-6?s.vec3.set(n,0,1,0):s.vec3.normalize(n,n);let l=s.mat4.create();l=s.mat4.translate(l,l,s.vec3.fromValues(t[0],t[1],t[2]));const h=[l[12],l[13],l[14]];l=s.mat4.targetTo(l,h,[0,0,0],n),this.R=s.mat4.clone(l),this.R[12]=0,this.R[13]=0,this.R[14]=0;const c=s.mat4.create();0!==this.cam_pos[2]&&s.mat4.invert(c,l),this.vMatrix=c}toggleInsideSphere(){this.insideSphere=a.default.insideSphere,a.default.insideSphere?(this.cam_pos[0]=0,this.cam_pos[1]=0,this.cam_pos[2]=-.005):this.cam_pos[2]=2+this.cam_pos[2],s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}zoom(e){if(this.move=s.vec3.clone([0,0,0]),this.move[2]+=this.cam_speed*e,a.default.insideSphere)this.cam_pos[2]+this.move[2]>=-.005&&e>0?(this.cam_pos[2]=-.005,e=0):this.cam_pos[2]+this.move[2]<=-.9885&&e<0?(this.cam_pos[2]=-.9885,e=0):this.cam_pos[2]+=this.move[2];else{const t=Math.max(this.cam_pos[2]-1,1e-6),i=Math.min(1,t/.3),r=.015+.985*Math.pow(i,1.2);this.move[2]*=r,this.cam_pos[2]+this.move[2]<=1.000001&&e<0?this.cam_pos[2]=1.000001:this.cam_pos[2]+=this.move[2]}const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}moveAlongView(e){const t=s.mat4.create();s.mat4.invert(t,this.R);const i=s.vec3.fromValues(0,0,-1),r=s.vec3.create();s.vec3.transformMat4(r,i,t);const o=Math.hypot(r[0],r[1],r[2]);o>0&&(r[0]/=o,r[1]/=o,r[2]/=o),this.cam_pos[0]+=r[0]*e,this.cam_pos[1]+=r[1]*e,this.cam_pos[2]+=r[2]*e;const a=s.mat4.create();s.mat4.translate(this.T,a,this.cam_pos),this.refreshViewMatrix()}translate(e){this.cam_pos[2]=e+1;const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}rotateX(e){if(this.lockRotX)return;const t=.01*e;this.theta+=t,s.mat4.rotate(this.R,this.R,t,[1,0,0]),this.refreshViewMatrix()}rotateY(e){if(this.lockRotY)return;const t=.01*e;this.phi+=t,s.mat4.rotate(this.R,this.R,t,[0,1,0]),this.refreshViewMatrix()}rotateZ(e){if(this.lockRotZ)return;const t=.01*e;s.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshViewMatrix()}rotateXRadian(e){this.lockRotX||(s.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshViewMatrix())}rotateYRadian(e){this.lockRotY||(this.phi+=e,s.mat4.rotate(this.R,this.R,e,[0,1,0]),this.refreshViewMatrix())}rotateZRadian(e){this.lockRotZ||(s.mat4.rotate(this.R,this.R,e,[0,0,1]),this.refreshViewMatrix())}rotate(e,t){if(this.lockRotZ)return;const i=Math.sqrt(e*e+t*t);if(0===i)return;const r=this.getCameraPosition(),o=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),a=Math.max(o-1,1e-6),n=Math.min(1,a/.45),l=.02+.98*Math.pow(n,1.55),h=Math.min(1,this.FoV/18),c=i*l*(.06+1.55*Math.pow(h,.52))/1.9*this.rotationSensitivity;let u=t,d=e;const g=Math.sqrt(u*u+d*d);0!==g&&(u/=g,d/=g,s.mat4.rotate(this.R,this.R,-c,[u,d,0]),this.refreshViewMatrix())}setRotationSensitivity(e){this.rotationSensitivity=Math.min(3,Math.max(.2,e))}getRotationSensitivity(){return this.rotationSensitivity}refreshViewMatrix(){const e=s.mat4.create(),t=s.mat4.create();s.mat4.invert(e,this.T),s.mat4.invert(t,this.R),s.mat4.multiply(this.vMatrix,e,t)}refreshFoV(e){this.previousFoV=this.FoV,this.FoV=e}getCameraMatrix(){return this.vMatrix}getCameraPosition(){const e=s.mat4.create();return s.mat4.invert(e,this.vMatrix)?[e[12],e[13],e[14]]:[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]}setCameraMatrix(e){this.vMatrix=e}setCameraPosition(e){this.cam_pos=s.vec3.fromValues(e[0],e[1],e[2]),s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}getCameraAngle(){const[e,t,i]=this.getCameraPosition(),r=s.vec3.fromValues(e,t,i),a=(0,o.cartesianToSpherical)(r);return console.log("[Camera::getCameraAngle]",a),a}setRotationLock(e){void 0!==e.x&&(this.lockRotX=e.x),void 0!==e.y&&(this.lockRotY=e.y),void 0!==e.z&&(this.lockRotZ=e.z)}clearRotationLock(){this.lockRotX=this.lockRotY=this.lockRotZ=!1}isRotationLockedX(){return this.lockRotX}isRotationLockedY(){return this.lockRotY}isRotationLockedZ(){return this.lockRotZ}}},2919(e,t){"use strict";t.bootSetup=void 0,t.bootSetup={insideSphere:!1,defaultHips:"",camera_fov_deg:34,camera_fov_rad:34*Math.PI/180,inside_camera_fov_deg:60,inside_camera_fov_rad:60*Math.PI/180,camera_near_plane:1e-5,camera_far_plane:2.5,corsProxyUrl:"http://localhost:4000/",useCORSProxy:!1,maxDecimals:15,defaultHipsUrl:"https://cdn.skies.esac.esa.int/DSSColor/",version:"Astrobrowser v1.0.0",debug:!1,insideView:!1,showViewfinder:!0}},4382(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(4851),s=i(2919);const o=new class{_healpix;_selectionnside;_useCORSProxy;_corsProxyUrl;_maxDecimals;_debug;_insideSphere;_version;constructor(){this._useCORSProxy=s.bootSetup.useCORSProxy,this._corsProxyUrl=s.bootSetup.corsProxyUrl,this._maxDecimals=s.bootSetup.maxDecimals,this._debug=s.bootSetup.debug,this._insideSphere=s.bootSetup.insideView,this._version=s.bootSetup.version,this._healpix={},this._selectionnside=32}init(){console.log("Global.init()")}get version(){return this._version}set corsProxyUrl(e){this._corsProxyUrl=e}get corsProxyUrl(){return this._corsProxyUrl}get useCORSProxy(){return this._useCORSProxy}set useCORSProxy(e){this._useCORSProxy=e}get debug(){return this._debug}getHealpix(e){return void 0===this._healpix[e]&&(this._healpix[e]=new r.Healpix(Math.pow(2,e))),this._healpix[e]}get MAX_DECIMALS(){return this._maxDecimals}set insideSphere(e){this._insideSphere=e}get insideSphere(){return this._insideSphere}get nsideForSelection(){return this._selectionnside}};t.default=o},1229(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=t.Source=t.MeshHiPSDescriptor=t.MeshHiPS=t.WMTSAdapter=t.XYZMap=t.HiPS=t.createColorMapFromSamples=t.COLOR_MAP_SAMPLE_COUNT=t.ColorMaps=t.GeoJSONParser=t.CoordsType=t.FoVUtils=t.CartesianOpts=t.PointInitOpts=t.AstroOpts=t.SphericalOpts=t.Point=t.ColumnType=t.MetadataInit=t.MetadataColumn=t.MetadataManager=t.ObservationTrackViewerAdapter=t.ObservationTrackTimeline=t.footprintToRing=t.createObservationTrackTimeline=t.SensorConeGL=t.SatelliteObjectGL=t.TerraPolylineSetGL=t.TerraFootprintSetGL=t.TerraPointSetGL=t.CatalogueGL=t.FootprintSetGL=t.HoveredFootprintDetail=t.SphereFoV=t.FoV=t.HiPSDescriptor=t.AstroViewer=void 0;var s=i(772);Object.defineProperty(t,"AstroViewer",{enumerable:!0,get:function(){return s.AstroViewer}});var o=i(5087);Object.defineProperty(t,"HiPSDescriptor",{enumerable:!0,get:function(){return o.HiPSDescriptor}});var a=i(5803);Object.defineProperty(t,"FoV",{enumerable:!0,get:function(){return a.SphereFoV}});var n=i(5803);Object.defineProperty(t,"SphereFoV",{enumerable:!0,get:function(){return n.SphereFoV}});var l=i(592);Object.defineProperty(t,"HoveredFootprintDetail",{enumerable:!0,get:function(){return l.HoveredFootprintDetail}}),Object.defineProperty(t,"FootprintSetGL",{enumerable:!0,get:function(){return l.FootprintSetGL}});var h=i(1232);Object.defineProperty(t,"CatalogueGL",{enumerable:!0,get:function(){return h.CatalogueGL}});var c=i(5781);Object.defineProperty(t,"TerraPointSetGL",{enumerable:!0,get:function(){return c.TerraPointSetGL}});var u=i(9022);Object.defineProperty(t,"TerraFootprintSetGL",{enumerable:!0,get:function(){return u.TerraFootprintSetGL}});var d=i(3665);Object.defineProperty(t,"TerraPolylineSetGL",{enumerable:!0,get:function(){return d.TerraPolylineSetGL}});var g=i(3603);Object.defineProperty(t,"SatelliteObjectGL",{enumerable:!0,get:function(){return g.SatelliteObjectGL}});var _=i(3102);Object.defineProperty(t,"SensorConeGL",{enumerable:!0,get:function(){return _.SensorConeGL}});var p=i(5866);Object.defineProperty(t,"createObservationTrackTimeline",{enumerable:!0,get:function(){return p.createObservationTrackTimeline}}),Object.defineProperty(t,"footprintToRing",{enumerable:!0,get:function(){return p.footprintToRing}}),Object.defineProperty(t,"ObservationTrackTimeline",{enumerable:!0,get:function(){return p.ObservationTrackTimeline}}),Object.defineProperty(t,"ObservationTrackViewerAdapter",{enumerable:!0,get:function(){return p.ObservationTrackViewerAdapter}});var f=i(5403);Object.defineProperty(t,"MetadataManager",{enumerable:!0,get:function(){return f.MetadataManager}});var m=i(1072);Object.defineProperty(t,"MetadataColumn",{enumerable:!0,get:function(){return m.MetadataColumn}}),Object.defineProperty(t,"MetadataInit",{enumerable:!0,get:function(){return m.MetadataInit}}),Object.defineProperty(t,"ColumnType",{enumerable:!0,get:function(){return m.ColumnType}});var x=i(6553);Object.defineProperty(t,"Point",{enumerable:!0,get:function(){return x.Point}}),Object.defineProperty(t,"SphericalOpts",{enumerable:!0,get:function(){return x.SphericalOpts}}),Object.defineProperty(t,"AstroOpts",{enumerable:!0,get:function(){return x.AstroOpts}}),Object.defineProperty(t,"PointInitOpts",{enumerable:!0,get:function(){return x.PointInitOpts}}),Object.defineProperty(t,"CartesianOpts",{enumerable:!0,get:function(){return x.CartesianOpts}});var b=i(8083);Object.defineProperty(t,"FoVUtils",{enumerable:!0,get:function(){return b.FoVUtils}});var S=i(8145);Object.defineProperty(t,"CoordsType",{enumerable:!0,get:function(){return S.CoordsType}});var v=i(8755);Object.defineProperty(t,"GeoJSONParser",{enumerable:!0,get:function(){return r(v).default}});var M=i(619);Object.defineProperty(t,"ColorMaps",{enumerable:!0,get:function(){return M.ColorMaps}}),Object.defineProperty(t,"COLOR_MAP_SAMPLE_COUNT",{enumerable:!0,get:function(){return M.COLOR_MAP_SAMPLE_COUNT}}),Object.defineProperty(t,"createColorMapFromSamples",{enumerable:!0,get:function(){return M.createColorMapFromSamples}});var T=i(3726);Object.defineProperty(t,"HiPS",{enumerable:!0,get:function(){return T.HiPS}});var y=i(1741);Object.defineProperty(t,"XYZMap",{enumerable:!0,get:function(){return y.XYZMap}});var P=i(3956);Object.defineProperty(t,"WMTSAdapter",{enumerable:!0,get:function(){return P.WMTSAdapter}});var w=i(6878);Object.defineProperty(t,"MeshHiPS",{enumerable:!0,get:function(){return w.MeshHiPS}});var C=i(847);Object.defineProperty(t,"MeshHiPSDescriptor",{enumerable:!0,get:function(){return C.MeshHiPSDescriptor}});var E=i(146);Object.defineProperty(t,"Source",{enumerable:!0,get:function(){return E.Source}});var A=i(2475);Object.defineProperty(t,"Footprint",{enumerable:!0,get:function(){return A.Footprint}}),console.log("astroviewer UMD loaded")},4735(e,t,i){"use strict";t.AbstractSkyEntity=void 0;const r=i(3890),s=i(7786);t.AbstractSkyEntity=class{refreshMe=!1;fovX_deg=180;fovY_deg=180;xRad;yRad;prevFoV=this.fovX_deg;_name;center;radius;isGalacticHips;vertexTextureCoordBuffer=null;vertexPositionBuffer=null;vertexIndexBuffer=null;shaderProgram=null;T=r.mat4.create();R=r.mat4.create();modelMatrix=r.mat4.create();inverseModelMatrix=r.mat4.create();galacticMatrixInverted=r.mat4.create();_webgl;_hipsShaderProgram;constructor(e,t,i,o,a,n,l){this._webgl=n,this.xRad=i,this.yRad=o,this._name=a,this.center=r.vec3.clone(t),this.radius=e,this.isGalacticHips=!!l,r.mat4.set(this.galacticMatrixInverted,-.054875582456588745,-.8734370470046997,-.48383501172065735,0,.49410945177078247,-.4448296129703522,.7469822764396667,0,-.8676661849021912,-.19807636737823486,.4559837877750397,0,0,0,0,1),this._hipsShaderProgram=new s.HiPSShaderProgram(this._webgl)}get name(){return this._name}get hipsShaderProgram(){return this._hipsShaderProgram}get webgl(){return this._webgl}initGL(e){this.vertexTextureCoordBuffer=e.createBuffer(),this.vertexPositionBuffer=e.createBuffer(),this.vertexIndexBuffer=e.createBuffer(),this.shaderProgram=e.createProgram(),this.T=r.mat4.create(),this.R=r.mat4.create(),this.modelMatrix=r.mat4.create(),this.inverseModelMatrix=r.mat4.create(),this.translate(this.center),this.rotate(this.xRad,this.yRad)}translate(e){r.mat4.translate(this.T,this.T,e),this.refreshModelMatrix()}rotate(e,t){r.mat4.rotate(this.R,this.R,t,[0,0,1]),r.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshModelMatrix()}rotateFromZero(e,t){r.mat4.identity(this.R),r.mat4.rotate(this.R,this.R,e,[1,0,0]),r.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshModelMatrix()}refreshModelMatrix(){const e=r.mat4.create();r.mat4.invert(e,this.R),r.mat4.multiply(this.modelMatrix,this.T,e),this.isGalacticHips&&r.mat4.multiply(this.modelMatrix,this.modelMatrix,this.galacticMatrixInverted)}getModelMatrixInverse(){return r.mat4.identity(this.inverseModelMatrix),r.mat4.invert(this.inverseModelMatrix,this.modelMatrix),this.inverseModelMatrix}getModelMatrix(){return this.modelMatrix}setModelMatrix(e){this.modelMatrix=e}setGeometryNeedsToBeRefreshed(){this.refreshGeometryOnFoVChanged=!1}rotateX(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[1],o=e[5],a=e[9];return e[1]=e[1]*i-e[2]*r,e[5]=e[5]*i-e[6]*r,e[9]=e[9]*i-e[10]*r,e[2]=e[2]*i+s*r,e[6]=e[6]*i+o*r,e[10]=e[10]*i+a*r,e}rotateY(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[0],o=e[4],a=e[8];return e[0]=i*e[0]+r*e[2],e[4]=i*e[4]+r*e[6],e[8]=i*e[8]+r*e[10],e[2]=i*e[2]-r*s,e[6]=i*e[6]-r*o,e[10]=i*e[10]-r*a,e}}},619(e,t){"use strict";function i(e,i){if(!Array.isArray(i))throw new Error(`Channel "${e}" must be an array.`);if(i.length!==t.COLOR_MAP_SAMPLE_COUNT)throw new Error(`Channel "${e}" must contain exactly ${t.COLOR_MAP_SAMPLE_COUNT} samples.`);for(let t=0;t<i.length;t+=1){const r=i[t];if(!Number.isFinite(r))throw new Error(`Channel "${e}" contains a non-finite value at index ${t}.`);if(r<0||r>255)throw new Error(`Channel "${e}" contains an out-of-range value at index ${t}. Expected 0..255.`)}}function r(e){const i=new Float32Array(4*t.COLOR_MAP_SAMPLE_COUNT);for(let r=0;r<t.COLOR_MAP_SAMPLE_COUNT;r+=1)i[4*r]=e[r];return i}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorMaps=t.COLOR_MAP_SAMPLE_COUNT=void 0,t.createColorMapFromSamples=function(e,t){const s=e.trim();if(!s)throw new Error("Color map name must not be empty.");return i("r",t.r),i("g",t.g),i("b",t.b),{name:s,r:r(t.r),g:r(t.g),b:r(t.b)}},t.COLOR_MAP_SAMPLE_COUNT=256,t.ColorMaps={grayscale:{name:"grayscale",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},native:{name:"native",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},planck:{name:"planck",r:new Float32Array([0,0,0,0,.769231,0,0,0,1.53846,0,0,0,2.30769,0,0,0,3.07692,0,0,0,3.84615,0,0,0,4.61538,0,0,0,5.38462,0,0,0,6.15385,0,0,0,6.92308,0,0,0,7.69231,0,0,0,8.46154,0,0,0,9.23077,0,0,0,10,0,0,0,11.5385,0,0,0,13.0769,0,0,0,14.6154,0,0,0,16.1538,0,0,0,17.6923,0,0,0,19.2308,0,0,0,20.7692,0,0,0,22.3077,0,0,0,23.8462,0,0,0,25.3846,0,0,0,26.9231,0,0,0,28.4615,0,0,0,30,0,0,0,33.8462,0,0,0,37.6923,0,0,0,41.5385,0,0,0,45.3846,0,0,0,49.2308,0,0,0,53.0769,0,0,0,56.9231,0,0,0,60.7692,0,0,0,64.6154,0,0,0,68.4615,0,0,0,72.3077,0,0,0,76.1538,0,0,0,80,0,0,0,88.5385,0,0,0,97.0769,0,0,0,105.615,0,0,0,114.154,0,0,0,122.692,0,0,0,131.231,0,0,0,139.769,0,0,0,148.308,0,0,0,156.846,0,0,0,165.385,0,0,0,173.923,0,0,0,182.462,0,0,0,191,0,0,0,193.846,0,0,0,196.692,0,0,0,199.538,0,0,0,202.385,0,0,0,205.231,0,0,0,208.077,0,0,0,210.923,0,0,0,213.769,0,0,0,216.615,0,0,0,219.462,0,0,0,222.308,0,0,0,225.154,0,0,0,228,0,0,0,229.182,0,0,0,230.364,0,0,0,231.545,0,0,0,232.727,0,0,0,233.909,0,0,0,235.091,0,0,0,236.273,0,0,0,237.455,0,0,0,238.636,0,0,0,239.818,0,0,0,241,0,0,0,241,0,0,0,241.364,0,0,0,241.727,0,0,0,242.091,0,0,0,242.455,0,0,0,242.818,0,0,0,243.182,0,0,0,243.545,0,0,0,243.909,0,0,0,244.273,0,0,0,244.636,0,0,0,245,0,0,0,245.231,0,0,0,245.462,0,0,0,245.692,0,0,0,245.923,0,0,0,246.154,0,0,0,246.385,0,0,0,246.615,0,0,0,246.846,0,0,0,247.077,0,0,0,247.308,0,0,0,247.538,0,0,0,247.769,0,0,0,248,0,0,0,248.146,0,0,0,248.292,0,0,0,248.438,0,0,0,248.585,0,0,0,248.731,0,0,0,248.877,0,0,0,249.023,0,0,0,249.169,0,0,0,249.315,0,0,0,249.462,0,0,0,249.608,0,0,0,249.754,0,0,0,249.9,0,0,0,249.312,0,0,0,248.723,0,0,0,248.135,0,0,0,247.546,0,0,0,246.958,0,0,0,246.369,0,0,0,245.781,0,0,0,245.192,0,0,0,244.604,0,0,0,244.015,0,0,0,243.427,0,0,0,242.838,0,0,0,242.25,0,0,0,239.308,0,0,0,236.365,0,0,0,233.423,0,0,0,230.481,0,0,0,227.538,0,0,0,224.596,0,0,0,221.654,0,0,0,218.712,0,0,0,215.769,0,0,0,212.827,0,0,0,209.885,0,0,0,206.942,0,0,0,204,0,0,0,201,0,0,0,198,0,0,0,195,0,0,0,192,0,0,0,189,0,0,0,186,0,0,0,183,0,0,0,180,0,0,0,177,0,0,0,174,0,0,0,171,0,0,0,168,0,0,0,165,0,0,0,161.077,0,0,0,157.154,0,0,0,153.231,0,0,0,149.308,0,0,0,145.385,0,0,0,141.462,0,0,0,137.538,0,0,0,133.615,0,0,0,129.692,0,0,0,125.769,0,0,0,121.846,0,0,0,117.923,0,0,0,114,0,0,0,115.038,0,0,0,116.077,0,0,0,117.115,0,0,0,118.154,0,0,0,119.192,0,0,0,120.231,0,0,0,121.269,0,0,0,122.308,0,0,0,123.346,0,0,0,124.385,0,0,0,125.423,0,0,0,126.462,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),g:new Float32Array([0,0,0,0,1.53846,0,0,0,3.07692,0,0,0,4.61538,0,0,0,6.15385,0,0,0,7.69231,0,0,0,9.23077,0,0,0,10.7692,0,0,0,12.3077,0,0,0,13.8462,0,0,0,15.3846,0,0,0,16.9231,0,0,0,18.4615,0,0,0,20,0,0,0,32.6154,0,0,0,45.2308,0,0,0,57.8462,0,0,0,70.4615,0,0,0,83.0769,0,0,0,95.6923,0,0,0,108.308,0,0,0,120.923,0,0,0,133.538,0,0,0,146.154,0,0,0,158.769,0,0,0,171.385,0,0,0,184,0,0,0,187.923,0,0,0,191.846,0,0,0,195.769,0,0,0,199.692,0,0,0,203.615,0,0,0,207.538,0,0,0,211.462,0,0,0,215.385,0,0,0,219.308,0,0,0,223.231,0,0,0,227.154,0,0,0,231.077,0,0,0,235,0,0,0,235.308,0,0,0,235.615,0,0,0,235.923,0,0,0,236.231,0,0,0,236.538,0,0,0,236.846,0,0,0,237.154,0,0,0,237.462,0,0,0,237.769,0,0,0,238.077,0,0,0,238.385,0,0,0,238.692,0,0,0,239,0,0,0,239.077,0,0,0,239.154,0,0,0,239.231,0,0,0,239.308,0,0,0,239.385,0,0,0,239.462,0,0,0,239.538,0,0,0,239.615,0,0,0,239.692,0,0,0,239.769,0,0,0,239.846,0,0,0,239.923,0,0,0,240,0,0,0,240.091,0,0,0,240.182,0,0,0,240.273,0,0,0,240.364,0,0,0,240.455,0,0,0,240.545,0,0,0,240.636,0,0,0,240.727,0,0,0,240.818,0,0,0,240.909,0,0,0,241,0,0,0,241,0,0,0,240.909,0,0,0,240.818,0,0,0,240.727,0,0,0,240.636,0,0,0,240.545,0,0,0,240.455,0,0,0,240.364,0,0,0,240.273,0,0,0,240.182,0,0,0,240.091,0,0,0,240,0,0,0,239.615,0,0,0,239.231,0,0,0,238.846,0,0,0,238.462,0,0,0,238.077,0,0,0,237.692,0,0,0,237.308,0,0,0,236.923,0,0,0,236.538,0,0,0,236.154,0,0,0,235.769,0,0,0,235.385,0,0,0,235,0,0,0,232.615,0,0,0,230.231,0,0,0,227.846,0,0,0,225.462,0,0,0,223.077,0,0,0,220.692,0,0,0,218.308,0,0,0,215.923,0,0,0,213.538,0,0,0,211.154,0,0,0,208.769,0,0,0,206.385,0,0,0,204,0,0,0,200.077,0,0,0,196.154,0,0,0,192.231,0,0,0,188.308,0,0,0,184.385,0,0,0,180.462,0,0,0,176.538,0,0,0,172.615,0,0,0,168.692,0,0,0,164.769,0,0,0,160.846,0,0,0,156.923,0,0,0,153,0,0,0,147.115,0,0,0,141.231,0,0,0,135.346,0,0,0,129.462,0,0,0,123.577,0,0,0,117.692,0,0,0,111.808,0,0,0,105.923,0,0,0,100.038,0,0,0,94.1538,0,0,0,88.2692,0,0,0,82.3846,0,0,0,76.5,0,0,0,73.0769,0,0,0,69.6538,0,0,0,66.2308,0,0,0,62.8077,0,0,0,59.3846,0,0,0,55.9615,0,0,0,52.5385,0,0,0,49.1154,0,0,0,45.6923,0,0,0,42.2692,0,0,0,38.8462,0,0,0,35.4231,0,0,0,32,0,0,0,29.5385,0,0,0,27.0769,0,0,0,24.6154,0,0,0,22.1538,0,0,0,19.6923,0,0,0,17.2308,0,0,0,14.7692,0,0,0,12.3077,0,0,0,9.84615,0,0,0,7.38462,0,0,0,4.92308,0,0,0,2.46154,0,0,0,0,0,0,0,9.80769,0,0,0,19.6154,0,0,0,29.4231,0,0,0,39.2308,0,0,0,49.0385,0,0,0,58.8462,0,0,0,68.6538,0,0,0,78.4615,0,0,0,88.2692,0,0,0,98.0769,0,0,0,107.885,0,0,0,117.692,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254.615,0,0,0,254.231,0,0,0,253.846,0,0,0,253.462,0,0,0,253.077,0,0,0,252.692,0,0,0,252.308,0,0,0,251.923,0,0,0,251.538,0,0,0,251.154,0,0,0,250.769,0,0,0,250.385,0,0,0,250,0,0,0,249.615,0,0,0,249.231,0,0,0,248.846,0,0,0,248.462,0,0,0,248.077,0,0,0,247.692,0,0,0,247.308,0,0,0,246.923,0,0,0,246.538,0,0,0,246.154,0,0,0,245.769,0,0,0,245.385,0,0,0,245,0,0,0,242,0,0,0,239,0,0,0,236,0,0,0,233,0,0,0,230,0,0,0,227,0,0,0,224,0,0,0,221,0,0,0,218,0,0,0,215,0,0,0,212,0,0,0,212,0,0,0,208.636,0,0,0,205.273,0,0,0,201.909,0,0,0,198.545,0,0,0,195.182,0,0,0,191.818,0,0,0,188.455,0,0,0,185.091,0,0,0,181.727,0,0,0,178.364,0,0,0,175,0,0,0,171.538,0,0,0,168.077,0,0,0,164.615,0,0,0,161.154,0,0,0,157.692,0,0,0,154.231,0,0,0,150.769,0,0,0,147.308,0,0,0,143.846,0,0,0,140.385,0,0,0,136.923,0,0,0,133.462,0,0,0,130,0,0,0,122.942,0,0,0,115.885,0,0,0,108.827,0,0,0,101.769,0,0,0,94.7115,0,0,0,87.6539,0,0,0,80.5962,0,0,0,73.5385,0,0,0,66.4808,0,0,0,59.4231,0,0,0,52.3654,0,0,0,45.3077,0,0,0,38.25,0,0,0,36.2885,0,0,0,34.3269,0,0,0,32.3654,0,0,0,30.4038,0,0,0,28.4423,0,0,0,26.4808,0,0,0,24.5192,0,0,0,22.5577,0,0,0,20.5962,0,0,0,18.6346,0,0,0,16.6731,0,0,0,14.7115,0,0,0,12.75,0,0,0,11.7692,0,0,0,10.7885,0,0,0,9.80769,0,0,0,8.82692,0,0,0,7.84615,0,0,0,6.86539,0,0,0,5.88461,0,0,0,4.90385,0,0,0,3.92308,0,0,0,2.94231,0,0,0,1.96154,0,0,0,.980769,0,0,0,0,0,0,0,2.46154,0,0,0,4.92308,0,0,0,7.38462,0,0,0,9.84616,0,0,0,12.3077,0,0,0,14.7692,0,0,0,17.2308,0,0,0,19.6923,0,0,0,22.1538,0,0,0,24.6154,0,0,0,27.0769,0,0,0,29.5385,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,41.3077,0,0,0,50.6154,0,0,0,59.9231,0,0,0,69.2308,0,0,0,78.5385,0,0,0,87.8462,0,0,0,97.1539,0,0,0,106.462,0,0,0,115.769,0,0,0,125.077,0,0,0,134.385,0,0,0,143.692,0,0,0,153,0,0,0,156.923,0,0,0,160.846,0,0,0,164.769,0,0,0,168.692,0,0,0,172.615,0,0,0,176.538,0,0,0,180.462,0,0,0,184.385,0,0,0,188.308,0,0,0,192.231,0,0,0,196.154,0,0,0,200.077,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.838,0,0,0,243.427,0,0,0,244.015,0,0,0,244.604,0,0,0,245.192,0,0,0,245.781,0,0,0,246.369,0,0,0,246.958,0,0,0,247.546,0,0,0,248.135,0,0,0,248.723,0,0,0,249.312,0,0,0,249.9,0,0,0,250.096,0,0,0,250.292,0,0,0,250.488,0,0,0,250.685,0,0,0,250.881,0,0,0,251.077,0,0,0,251.273,0,0,0,251.469,0,0,0,251.665,0,0,0,251.862,0,0,0,252.058,0,0,0,252.254,0,0,0,252.45,0,0,0,252.682,0,0,0,252.914,0,0,0,253.145,0,0,0,253.377,0,0,0,253.609,0,0,0,253.841,0,0,0,254.073,0,0,0,254.305,0,0,0,254.536,0,0,0,254.768,0,0,0,255,0,0,0])},cmb:{name:"cmb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,12,0,0,0,18,0,0,0,24,0,0,0,30,0,0,0,36,0,0,0,42,0,0,0,48,0,0,0,54,0,0,0,60,0,0,0,66,0,0,0,72,0,0,0,78,0,0,0,85,0,0,0,91,0,0,0,97,0,0,0,103,0,0,0,109,0,0,0,115,0,0,0,121,0,0,0,127,0,0,0,133,0,0,0,139,0,0,0,145,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,170,0,0,0,176,0,0,0,182,0,0,0,188,0,0,0,194,0,0,0,200,0,0,0,206,0,0,0,212,0,0,0,218,0,0,0,224,0,0,0,230,0,0,0,236,0,0,0,242,0,0,0,248,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,251,0,0,0,247,0,0,0,244,0,0,0,240,0,0,0,236,0,0,0,233,0,0,0,229,0,0,0,226,0,0,0,222,0,0,0,218,0,0,0,215,0,0,0,211,0,0,0,208,0,0,0,204,0,0,0,200,0,0,0,197,0,0,0,193,0,0,0,190,0,0,0,186,0,0,0,182,0,0,0,179,0,0,0,175,0,0,0,172,0,0,0,168,0,0,0,164,0,0,0,161,0,0,0,157,0,0,0,154,0,0,0,150,0,0,0,146,0,0,0,143,0,0,0,139,0,0,0,136,0,0,0,132,0,0,0,128,0,0,0,125,0,0,0,121,0,0,0,118,0,0,0,114,0,0,0,110,0,0,0,107,0,0,0,103,0,0,0,100,0,0,0]),g:new Float32Array([0,0,0,0,2,0,0,0,5,0,0,0,8,0,0,0,10,0,0,0,13,0,0,0,16,0,0,0,18,0,0,0,21,0,0,0,24,0,0,0,26,0,0,0,29,0,0,0,32,0,0,0,34,0,0,0,37,0,0,0,40,0,0,0,42,0,0,0,45,0,0,0,48,0,0,0,50,0,0,0,53,0,0,0,56,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,66,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,80,0,0,0,82,0,0,0,85,0,0,0,88,0,0,0,90,0,0,0,93,0,0,0,96,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,106,0,0,0,109,0,0,0,112,0,0,0,114,0,0,0,117,0,0,0,119,0,0,0,122,0,0,0,124,0,0,0,127,0,0,0,129,0,0,0,132,0,0,0,134,0,0,0,137,0,0,0,139,0,0,0,142,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,152,0,0,0,155,0,0,0,157,0,0,0,160,0,0,0,162,0,0,0,165,0,0,0,167,0,0,0,170,0,0,0,172,0,0,0,175,0,0,0,177,0,0,0,180,0,0,0,182,0,0,0,185,0,0,0,188,0,0,0,190,0,0,0,193,0,0,0,195,0,0,0,198,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,208,0,0,0,210,0,0,0,213,0,0,0,215,0,0,0,218,0,0,0,221,0,0,0,221,0,0,0,221,0,0,0,222,0,0,0,222,0,0,0,222,0,0,0,223,0,0,0,223,0,0,0,224,0,0,0,224,0,0,0,224,0,0,0,225,0,0,0,225,0,0,0,225,0,0,0,226,0,0,0,226,0,0,0,227,0,0,0,227,0,0,0,227,0,0,0,228,0,0,0,228,0,0,0,229,0,0,0,229,0,0,0,229,0,0,0,230,0,0,0,230,0,0,0,230,0,0,0,231,0,0,0,231,0,0,0,232,0,0,0,232,0,0,0,232,0,0,0,233,0,0,0,233,0,0,0,233,0,0,0,234,0,0,0,234,0,0,0,235,0,0,0,235,0,0,0,235,0,0,0,236,0,0,0,236,0,0,0,237,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,227,0,0,0,226,0,0,0,225,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,215,0,0,0,214,0,0,0,213,0,0,0,211,0,0,0,210,0,0,0,209,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,195,0,0,0,194,0,0,0,193,0,0,0,191,0,0,0,190,0,0,0,189,0,0,0,187,0,0,0,186,0,0,0,185,0,0,0,183,0,0,0,182,0,0,0,181,0,0,0,180,0,0,0,177,0,0,0,175,0,0,0,172,0,0,0,170,0,0,0,167,0,0,0,165,0,0,0,162,0,0,0,160,0,0,0,157,0,0,0,155,0,0,0,152,0,0,0,150,0,0,0,147,0,0,0,145,0,0,0,142,0,0,0,140,0,0,0,137,0,0,0,135,0,0,0,132,0,0,0,130,0,0,0,127,0,0,0,125,0,0,0,122,0,0,0,120,0,0,0,117,0,0,0,115,0,0,0,112,0,0,0,110,0,0,0,107,0,0,0,105,0,0,0,102,0,0,0,100,0,0,0,97,0,0,0,95,0,0,0,92,0,0,0,90,0,0,0,87,0,0,0,85,0,0,0,82,0,0,0,80,0,0,0,77,0,0,0,75,0,0,0,73,0,0,0,71,0,0,0,69,0,0,0,68,0,0,0,66,0,0,0,64,0,0,0,62,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,54,0,0,0,52,0,0,0,50,0,0,0,48,0,0,0,47,0,0,0,45,0,0,0,43,0,0,0,41,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,34,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,26,0,0,0,24,0,0,0,22,0,0,0,20,0,0,0,19,0,0,0,17,0,0,0,15,0,0,0,13,0,0,0,12,0,0,0,10,0,0,0,8,0,0,0,6,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254,0,0,0,253,0,0,0,252,0,0,0,251,0,0,0,250,0,0,0,249,0,0,0,248,0,0,0,247,0,0,0,246,0,0,0,245,0,0,0,245,0,0,0,244,0,0,0,243,0,0,0,242,0,0,0,241,0,0,0,240,0,0,0,239,0,0,0,238,0,0,0,237,0,0,0,236,0,0,0,236,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,232,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,228,0,0,0,227,0,0,0,226,0,0,0,226,0,0,0,225,0,0,0,224,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,220,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,217,0,0,0,211,0,0,0,206,0,0,0,201,0,0,0,196,0,0,0,191,0,0,0,186,0,0,0,181,0,0,0,176,0,0,0,171,0,0,0,166,0,0,0,161,0,0,0,156,0,0,0,151,0,0,0,146,0,0,0,141,0,0,0,136,0,0,0,131,0,0,0,126,0,0,0,121,0,0,0,116,0,0,0,111,0,0,0,105,0,0,0,100,0,0,0,95,0,0,0,90,0,0,0,85,0,0,0,80,0,0,0,75,0,0,0,70,0,0,0,65,0,0,0,60,0,0,0,55,0,0,0,50,0,0,0,45,0,0,0,40,0,0,0,35,0,0,0,30,0,0,0,25,0,0,0,20,0,0,0,15,0,0,0,10,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},rainbow:{name:"rainbow",r:new Float32Array([0,0,0,0,4,0,0,0,9,0,0,0,13,0,0,0,18,0,0,0,22,0,0,0,27,0,0,0,31,0,0,0,36,0,0,0,40,0,0,0,45,0,0,0,50,0,0,0,54,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,68,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,79,0,0,0,80,0,0,0,82,0,0,0,83,0,0,0,85,0,0,0,84,0,0,0,86,0,0,0,87,0,0,0,88,0,0,0,86,0,0,0,87,0,0,0,87,0,0,0,87,0,0,0,85,0,0,0,84,0,0,0,84,0,0,0,84,0,0,0,83,0,0,0,79,0,0,0,78,0,0,0,77,0,0,0,76,0,0,0,71,0,0,0,70,0,0,0,68,0,0,0,66,0,0,0,60,0,0,0,58,0,0,0,55,0,0,0,53,0,0,0,46,0,0,0,43,0,0,0,40,0,0,0,36,0,0,0,33,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,12,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,33,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,80,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,101,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,123,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,153,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,169,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,212,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,38,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,84,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,106,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,127,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,152,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,195,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,216,0,0,0,220,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,250,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,221,0,0,0,216,0,0,0,212,0,0,0,208,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,161,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,119,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,85,0,0,0,80,0,0,0,76,0,0,0,72,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,51,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,29,0,0,0,21,0,0,0,17,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0]),b:new Float32Array([0,0,0,0,3,0,0,0,7,0,0,0,10,0,0,0,14,0,0,0,19,0,0,0,23,0,0,0,28,0,0,0,32,0,0,0,38,0,0,0,43,0,0,0,48,0,0,0,53,0,0,0,59,0,0,0,63,0,0,0,68,0,0,0,72,0,0,0,77,0,0,0,81,0,0,0,86,0,0,0,91,0,0,0,95,0,0,0,100,0,0,0,104,0,0,0,109,0,0,0,113,0,0,0,118,0,0,0,122,0,0,0,127,0,0,0,132,0,0,0,136,0,0,0,141,0,0,0,145,0,0,0,150,0,0,0,154,0,0,0,159,0,0,0,163,0,0,0,168,0,0,0,173,0,0,0,177,0,0,0,182,0,0,0,186,0,0,0,191,0,0,0,195,0,0,0,200,0,0,0,204,0,0,0,209,0,0,0,214,0,0,0,218,0,0,0,223,0,0,0,227,0,0,0,232,0,0,0,236,0,0,0,241,0,0,0,245,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,225,0,0,0,220,0,0,0,216,0,0,0,212,0,0,0,203,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,157,0,0,0,152,0,0,0,148,0,0,0,144,0,0,0,135,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,114,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,84,0,0,0,80,0,0,0,76,0,0,0,67,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,46,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},eosb:{name:"eosb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,18,0,0,0,27,0,0,0,36,0,0,0,45,0,0,0,49,0,0,0,57,0,0,0,72,0,0,0,81,0,0,0,91,0,0,0,100,0,0,0,109,0,0,0,118,0,0,0,127,0,0,0,136,0,0,0,131,0,0,0,139,0,0,0,163,0,0,0,173,0,0,0,182,0,0,0,191,0,0,0,200,0,0,0,209,0,0,0,218,0,0,0,227,0,0,0,213,0,0,0,221,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,253,0,0,0,251,0,0,0,249,0,0,0,247,0,0,0,245,0,0,0,243,0,0,0,241,0,0,0,215,0,0,0,214,0,0,0,235,0,0,0,234,0,0,0,232,0,0,0,230,0,0,0,228,0,0,0,226,0,0,0,224,0,0,0,222,0,0,0,198,0,0,0,196,0,0,0,216,0,0,0,215,0,0,0,213,0,0,0,211,0,0,0,209,0,0,0,207,0,0,0,205,0,0,0,203,0,0,0,181,0,0,0,179,0,0,0,197,0,0,0,196,0,0,0,194,0,0,0,192,0,0,0,190,0,0,0,188,0,0,0,186,0,0,0,184,0,0,0,164,0,0,0,162,0,0,0,178,0,0,0,176,0,0,0,175,0,0,0,173,0,0,0,171,0,0,0,169,0,0,0,167,0,0,0,165,0,0,0,147,0,0,0,145,0,0,0,159,0,0,0,157,0,0,0,156,0,0,0,154,0,0,0,152,0,0,0,150,0,0,0,148,0,0,0,146,0,0,0,130,0,0,0,128,0,0,0,140,0,0,0,138,0,0,0,137,0,0,0,135,0,0,0,133,0,0,0,131,0,0,0,129,0,0,0,127,0,0,0,113,0,0,0,111,0,0,0,121,0,0,0,119,0,0,0,117,0,0,0,117,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,15,0,0,0,23,0,0,0,31,0,0,0,39,0,0,0,47,0,0,0,55,0,0,0,57,0,0,0,64,0,0,0,79,0,0,0,87,0,0,0,95,0,0,0,103,0,0,0,111,0,0,0,119,0,0,0,127,0,0,0,135,0,0,0,129,0,0,0,136,0,0,0,159,0,0,0,167,0,0,0,175,0,0,0,183,0,0,0,191,0,0,0,199,0,0,0,207,0,0,0,215,0,0,0,200,0,0,0,207,0,0,0,239,0,0,0,247,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,250,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,225,0,0,0,198,0,0,0,195,0,0,0,212,0,0,0,208,0,0,0,204,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,182,0,0,0,160,0,0,0,156,0,0,0,169,0,0,0,165,0,0,0,161,0,0,0,157,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,122,0,0,0,118,0,0,0,127,0,0,0,125,0,0,0,123,0,0,0,121,0,0,0,119,0,0,0,116,0,0,0,114,0,0,0,112,0,0,0,99,0,0,0,97,0,0,0,106,0,0,0,104,0,0,0,102,0,0,0,99,0,0,0,97,0,0,0,95,0,0,0,93,0,0,0,91,0,0,0,80,0,0,0,78,0,0,0,84,0,0,0,82,0,0,0,80,0,0,0,78,0,0,0,76,0,0,0,74,0,0,0,72,0,0,0,70,0,0,0,61,0,0,0,59,0,0,0,63,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,53,0,0,0,50,0,0,0,48,0,0,0,42,0,0,0,40,0,0,0,42,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,19,0,0,0,16,0,0,0,14,0,0,0,12,0,0,0,13,0,0,0,8,0,0,0,6,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),b:new Float32Array([116,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,136,0,0,0,140,0,0,0,144,0,0,0,148,0,0,0,153,0,0,0,157,0,0,0,145,0,0,0,149,0,0,0,170,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,195,0,0,0,199,0,0,0,183,0,0,0,187,0,0,0,212,0,0,0,216,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,238,0,0,0,242,0,0,0,221,0,0,0,225,0,0,0,255,0,0,0,247,0,0,0,239,0,0,0,231,0,0,0,223,0,0,0,215,0,0,0,207,0,0,0,199,0,0,0,172,0,0,0,164,0,0,0,175,0,0,0,167,0,0,0,159,0,0,0,151,0,0,0,143,0,0,0,135,0,0,0,127,0,0,0,119,0,0,0,100,0,0,0,93,0,0,0,95,0,0,0,87,0,0,0,79,0,0,0,71,0,0,0,63,0,0,0,55,0,0,0,47,0,0,0,39,0,0,0,28,0,0,0,21,0,0,0,15,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},cubehelix:{name:"cubehelix",r:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,24,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,24,0,0,0,24,0,0,0,24,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,20,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,27,0,0,0,28,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,35,0,0,0,36,0,0,0,38,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,49,0,0,0,51,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,60,0,0,0,62,0,0,0,65,0,0,0,67,0,0,0,70,0,0,0,72,0,0,0,75,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,89,0,0,0,92,0,0,0,95,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,107,0,0,0,110,0,0,0,113,0,0,0,116,0,0,0,120,0,0,0,123,0,0,0,126,0,0,0,129,0,0,0,132,0,0,0,135,0,0,0,138,0,0,0,141,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,153,0,0,0,155,0,0,0,158,0,0,0,161,0,0,0,164,0,0,0,166,0,0,0,169,0,0,0,171,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,181,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,199,0,0,0,201,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,207,0,0,0,208,0,0,0,209,0,0,0,209,0,0,0,210,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,210,0,0,0,210,0,0,0,210,0,0,0,209,0,0,0,208,0,0,0,208,0,0,0,207,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,205,0,0,0,204,0,0,0,203,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,201,0,0,0,200,0,0,0,199,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,197,0,0,0,196,0,0,0,196,0,0,0,195,0,0,0,195,0,0,0,194,0,0,0,194,0,0,0,194,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,194,0,0,0,194,0,0,0,195,0,0,0,195,0,0,0,196,0,0,0,196,0,0,0,197,0,0,0,198,0,0,0,199,0,0,0,200,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,208,0,0,0,209,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,217,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,223,0,0,0,225,0,0,0,227,0,0,0,229,0,0,0,231,0,0,0,232,0,0,0,234,0,0,0,236,0,0,0,238,0,0,0,240,0,0,0,242,0,0,0,244,0,0,0,245,0,0,0,247,0,0,0,249,0,0,0,251,0,0,0,253,0,0,0,255]),g:new Float32Array([0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,28,0,0,0,29,0,0,0,31,0,0,0,32,0,0,0,34,0,0,0,35,0,0,0,37,0,0,0,38,0,0,0,40,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,46,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,58,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,73,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,79,0,0,0,81,0,0,0,83,0,0,0,84,0,0,0,86,0,0,0,88,0,0,0,89,0,0,0,91,0,0,0,92,0,0,0,94,0,0,0,95,0,0,0,97,0,0,0,98,0,0,0,99,0,0,0,101,0,0,0,102,0,0,0,103,0,0,0,104,0,0,0,106,0,0,0,107,0,0,0,108,0,0,0,109,0,0,0,110,0,0,0,111,0,0,0,112,0,0,0,113,0,0,0,114,0,0,0,114,0,0,0,115,0,0,0,116,0,0,0,116,0,0,0,117,0,0,0,118,0,0,0,118,0,0,0,119,0,0,0,119,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,123,0,0,0,123,0,0,0,124,0,0,0,124,0,0,0,125,0,0,0,125,0,0,0,126,0,0,0,127,0,0,0,127,0,0,0,128,0,0,0,129,0,0,0,130,0,0,0,131,0,0,0,131,0,0,0,132,0,0,0,133,0,0,0,135,0,0,0,136,0,0,0,137,0,0,0,138,0,0,0,139,0,0,0,140,0,0,0,142,0,0,0,143,0,0,0,144,0,0,0,146,0,0,0,147,0,0,0,149,0,0,0,150,0,0,0,152,0,0,0,154,0,0,0,155,0,0,0,157,0,0,0,158,0,0,0,160,0,0,0,162,0,0,0,164,0,0,0,165,0,0,0,167,0,0,0,169,0,0,0,171,0,0,0,172,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,180,0,0,0,182,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,208,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,216,0,0,0,218,0,0,0,219,0,0,0,221,0,0,0,222,0,0,0,224,0,0,0,225,0,0,0,226,0,0,0,228,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,232,0,0,0,233,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,247,0,0,0,248,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,250,0,0,0,251,0,0,0,251,0,0,0,252,0,0,0,252,0,0,0,253,0,0,0,253,0,0,0,254,0,0,0,255,0,0,0]),b:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,11,0,0,0,13,0,0,0,15,0,0,0,17,0,0,0,19,0,0,0,21,0,0,0,23,0,0,0,25,0,0,0,27,0,0,0,29,0,0,0,31,0,0,0,33,0,0,0,35,0,0,0,37,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,54,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,63,0,0,0,65,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,70,0,0,0,71,0,0,0,72,0,0,0,73,0,0,0,74,0,0,0,74,0,0,0,75,0,0,0,76,0,0,0,76,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,76,0,0,0,76,0,0,0,75,0,0,0,75,0,0,0,74,0,0,0,73,0,0,0,73,0,0,0,72,0,0,0,71,0,0,0,70,0,0,0,69,0,0,0,68,0,0,0,67,0,0,0,66,0,0,0,66,0,0,0,65,0,0,0,64,0,0,0,63,0,0,0,61,0,0,0,60,0,0,0,59,0,0,0,58,0,0,0,58,0,0,0,57,0,0,0,56,0,0,0,55,0,0,0,54,0,0,0,53,0,0,0,52,0,0,0,51,0,0,0,51,0,0,0,50,0,0,0,49,0,0,0,49,0,0,0,48,0,0,0,48,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,48,0,0,0,48,0,0,0,49,0,0,0,50,0,0,0,50,0,0,0,51,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,65,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,88,0,0,0,91,0,0,0,94,0,0,0,96,0,0,0,99,0,0,0,102,0,0,0,105,0,0,0,108,0,0,0,111,0,0,0,114,0,0,0,117,0,0,0,120,0,0,0,124,0,0,0,127,0,0,0,130,0,0,0,133,0,0,0,136,0,0,0,140,0,0,0,143,0,0,0,146,0,0,0,149,0,0,0,153,0,0,0,156,0,0,0,159,0,0,0,162,0,0,0,165,0,0,0,169,0,0,0,172,0,0,0,175,0,0,0,178,0,0,0,181,0,0,0,184,0,0,0,186,0,0,0,189,0,0,0,192,0,0,0,195,0,0,0,197,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,210,0,0,0,212,0,0,0,214,0,0,0,216,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,224,0,0,0,226,0,0,0,227,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,233,0,0,0,234,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,241,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,252,0,0,0,253,0,0,0,255,0,0,0])},hot:{name:"hot",r:new Float32Array([0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.30769,4.61538,6.92308,9.23077,11.5385,13.8462,16.1538,18.4615,20.7692,23.0769,25.3846,27.6923,30,32.3077,34.6154,36.9231,39.2308,41.5385,43.8462,46.1538,48.4615,50.7692,53.0769,55.3846,57.6923,60,62.3077,64.6154,66.9231,69.2308,71.5385,73.8462,76.1538,78.4615,80.7692,83.0769,85.3846,87.6923,90,92.3077,94.6154,96.9231,99.2308,101.538,103.846,106.154,108.462,110.769,113.077,115.385,117.692,120,122.308,124.615,126.923,129.231,131.538,133.846,136.154,138.462,140.769,143.077,145.385,147.692,150,152.308,154.615,156.923,159.231,161.538,163.846,166.154,168.462,170.769,173.077,175.385,177.692,180,182.308,184.615,186.923,189.231,191.538,193.846,196.154,198.462,200.769,203.077,205.385,207.692,210,212.308,214.615,216.923,219.231,221.538,223.846,226.154,228.462,230.769,233.077,235.385,237.692,240,242.308,244.615,246.923,249.231,251.538,253.846,255,255,255,255,255,255,255]),b:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.980769,1.96154,2.94231,3.92308,4.90385,5.88461,6.86539,7.84615,8.82692,9.80769,10.7885,11.7692,12.75,13.7308,14.7115,15.6923,16.6731,17.6538,18.6346,19.6154,20.5962,21.5769,22.5577,23.5385,24.5192,25.5,26.4808,27.4615,28.4423,29.4231,30.4038,31.3846,32.3654,33.3462,34.3269,35.3077,36.2885,37.2692,38.25,39.2308,40.2115,41.1923,42.1731,43.1538,44.1346,45.1154,46.0962,47.0769,48.0577,49.0385,50.0192,51,51.9808,52.9615,53.9423,54.9231,55.9038,56.8846,57.8654,58.8462,59.8269,60.8077,61.7885,62.7692,63.75,64.7308,65.7115,66.6923,67.6731,68.6538,69.6346,70.6154,71.5962,72.5769,73.5577,74.5385,75.5192,76.5,77.4808,78.4615,79.4423,80.4231,81.4038,82.3846,83.3654,84.3462,85.3269,86.3077,87.2885,88.2692,89.25,90.2308,91.2115,92.1923,93.1731,94.1538,95.1346,96.1154,97.0962,98.0769,99.0577,100.038,101.019,102,102.981,103.962,104.942,105.923,106.904,107.885,108.865,109.846,110.827,111.808,112.788,113.769,114.75,115.731,116.711,117.692,118.673,119.654,120.634,121.615,122.596,123.577,124.557,125.538,126.519,127.5])},gray:{name:"gray",r:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),g:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),b:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255])}},t.default=t.ColorMaps},1072(e,t){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataColumn=t.ColumnType=void 0,function(e){e.STRING="STRING",e.NUMBER="NUMBER",e.GEOM_RA="GEOM_RA",e.GEOM_DEC="GEOM_DEC",e.GEOM_FOOTPRINT="GEOM_FOOTPRINT",e.MAIN_NAME="MAIN_NAME"}(i||(t.ColumnType=i={}));t.MetadataColumn=class{_index;_name;_description="";_columnType;_unit;_details=new Map;constructor(e){if(!e.name)throw new Error("No name column defined.");if(this._name=e.name,e.index<0||isNaN(e.index))throw new Error("No index column defined.");this._index=e.index,this._columnType=e.columnType??i.STRING,this._unit=e.unit??"",this._description=e.description??"",e.details&&(this._details=new Map(e.details))}get details(){return new Map(this._details)}getDetail(e,t){return this._details.has(e)?this._details.get(e):t}getString(e,t=""){const i=this._details.get(e);return"string"==typeof i?i:t}getNumber(e,t=NaN){const i=this._details.get(e);return"number"==typeof i?i:t}setDetail(e,t){this._details.set(e,t)}setDetails(e){const t=e instanceof Map?e.entries():Object.entries(e);for(const[e,i]of t)this._details.set(e,i)}detailKeys(){return Array.from(this._details.keys())}detailValues(){return Array.from(this._details.values())}detailEntries(){return Array.from(this._details.entries())}get name(){return this._name}get description(){return this._description}get columnType(){return this._columnType}get index(){return this._index}get unit(){return this._unit}toJSON(){return{name:this._name,description:this._description,columnType:this._columnType,index:this._index,unit:this._unit,details:Object.fromEntries(this._details)}}}},5403(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataManager=void 0;const r=i(1072);t.MetadataManager=class{static STANDARD_SIZE="STANDARD_SIZE";static STANDARD_HUE="STANDARD_HUE";_outlineColumnList=[];_raColumnList=[];_decColumnList=[];_shapeColumnList=[];_hueColumnList=[];_selectedOutlineColumn;_selectedRaColumn;_selectedDecColumn;_selectedShapeColumn;_selectedHueColumn;_selectedNameColumn;_columns=[];constructor(e){e.forEach(e=>{e.columnType==r.ColumnType.NUMBER&&(this.addHueColumn(e),this.addShapeColumn(e)),e.columnType==r.ColumnType.GEOM_RA&&this.addRaColumn(e),e.columnType==r.ColumnType.GEOM_DEC&&this.addDecColumn(e),e.columnType==r.ColumnType.GEOM_FOOTPRINT&&this.addOutlineColumn(e),e.columnType==r.ColumnType.MAIN_NAME&&(this._selectedNameColumn=e),this._columns.push(e)})}addOutlineColumn(e){this._outlineColumnList.push(e),this._selectedOutlineColumn=e}addRaColumn(e){this._selectedRaColumn=this._selectedRaColumn||e,this._raColumnList.push(e)}addDecColumn(e){this._selectedDecColumn=this._selectedDecColumn||e,this._decColumnList.push(e)}addHueColumn(e){this._hueColumnList.push(e)}addShapeColumn(e){this._shapeColumnList.push(e)}get selectedRaColumn(){return this._selectedRaColumn}get selectedDecColumn(){return this._selectedDecColumn}get selectedHueColumn(){return this._selectedHueColumn}get selectedShapeColumn(){return this._selectedShapeColumn}get selectedOutlineColumn(){return this._selectedOutlineColumn}get selectedNameColumn(){return this._selectedNameColumn}get columns(){return this._columns}get raColumnList(){return this._raColumnList}get decColumnList(){return this._decColumnList}get outlineColumnList(){return this._outlineColumnList}get hueColumnList(){return this._hueColumnList}get shapeColumnList(){return this._shapeColumnList}set selectedRaColumn(e){this._selectedRaColumn=this._raColumnList.find(t=>t.name===e)||this._selectedRaColumn}set selectedDecColumn(e){this._selectedDecColumn=this._decColumnList.find(t=>t.name===e)||this._selectedDecColumn}set selectedOutlineColumn(e){this._selectedOutlineColumn=this._outlineColumnList.find(t=>t.name===e)||this._selectedOutlineColumn}set selectedHueColumn(e){this._selectedHueColumn=this._hueColumnList.find(t=>t.name===e)}set selectedShapeColumn(e){this._selectedShapeColumn=this._shapeColumnList.find(t=>t.name===e)}set selectedNameColumn(e){this._selectedNameColumn=this._columns.find(t=>t.name===e)}resetShapeColumn(){this._selectedShapeColumn=void 0}resetHueColumn(){this._selectedHueColumn=void 0}}},6553(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=i(3890),o=i(7930),a=i(8145),n=r(i(4382));class l{_x;_y;_z;_xyz;_raDeg;_decDeg;_raRad;_decRad;_raDecDeg;_lonLatDeg;constructor(e,t){this._xyz=[0,0,0],this._raDecDeg=[0,0];const i=n.default.MAX_DECIMALS??12;if(t===a.CoordsType.CARTESIAN){const{x:t,y:r,z:s}=e;this._x=Number(t.toFixed(i)),this._y=Number(r.toFixed(i)),this._z=Number(s.toFixed(i)),this._xyz=[this._x,this._y,this._z];const[o,a]=this.computeAstroCoords();this._raDeg=Number(o),this._decDeg=Number(a),this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180,this._raDecDeg=[this._raDeg,this._decDeg]}else if(t===a.CoordsType.ASTRO){const{raDeg:t,decDeg:r}=e;this._raDeg=Number(t),this._decDeg=Number(r),this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,o,a]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(o.toFixed(i)),this._z=Number(a.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else if(t===a.CoordsType.GEOGRAPHIC){const{lonDeg:t,latDeg:r}=e;this._lonLatDeg=[Number(t),Number(r)],this._raDeg=this._lonLatDeg[0],this._decDeg=this._lonLatDeg[1],this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,o,a]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(o.toFixed(i)),this._z=Number(a.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else t===a.CoordsType.SPHERICAL?(console.log(`${a.CoordsType.SPHERICAL} not implemented yet`),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0):(console.error("CoordsType "+String(t)+" not recognised."),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0)}computeAstroCoords(){const e=(0,o.cartesianToSpherical)(s.vec3.fromValues(this._xyz[0],this._xyz[1],this._xyz[2])),t=(0,o.sphericalToAstroDeg)(e.phi,e.theta);return[t.ra,t.dec]}computeCartesianCoords(){const e=(0,o.astroDegToSpherical)(this._raDeg,this._decDeg),[t,i,r]=(0,o.sphericalToCartesian)(e.phi,e.theta,1);return[t,i,r]}computeHealpixPhiTheta(){return(0,o.astroDegToSpherical)(this._raDeg,this._decDeg)}scale(e){return new l({x:this.x*e,y:this.y*e,z:this.z*e},a.CoordsType.CARTESIAN)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){return new l({x:this.y*e.z-e.y*this.z,y:this.z*e.x-e.z*this.x,z:this.x*e.y-e.x*this.y},a.CoordsType.CARTESIAN)}norm(){const e=1/this.length();return new l({x:this.x*e,y:this.y*e,z:this.z*e},a.CoordsType.CARTESIAN)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}subtract(e){return new l({x:this.x-e.x,y:this.y-e.y,z:this.z-e.z},a.CoordsType.CARTESIAN)}add(e){return new l({x:this.x+e.x,y:this.y+e.y,z:this.z+e.z},a.CoordsType.CARTESIAN)}get x(){return this._x}get y(){return this._y}get z(){return this._z}get xyz(){return this._xyz}get raDeg(){return this._raDeg}get decDeg(){return this._decDeg}get raDecDeg(){return this._raDecDeg}get lonDeg(){return this._lonLatDeg?.[0]??this._raDeg}get latDeg(){return this._lonLatDeg?.[1]??this._decDeg}get lonLatDeg(){return this._lonLatDeg??[this._raDeg,this._decDeg]}toADQL(){return`${this._raDecDeg[0]},${this._raDecDeg[1]}`}toString(){return`(raDeg, decDeg) => (${this._raDecDeg[0]},${this._raDecDeg[1]}) (x, y,z) => (${this._xyz[0]},${this._xyz[1]},${this._xyz[2]})`}}t.Point=l},7559(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}}},146(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Source=void 0;const s=i(4851),o=r(i(4382));t.Source=class{_point;_name;_details;_h_pix;_shapesize;_brightnessFactor;constructor(e,t=[]){this._point=e,this._details=t,this._shapesize=16,this._brightnessFactor=-99,this.computeHealpixPixel()}getDetailByindex(e){if(!(e<0||e>=this._details.length))return this._details[e]}get details(){return this._details}computeHealpixPixel(){const e=o.default.getHealpix(o.default.nsideForSelection),t=new s.Vec3(this._point.x,this._point.y,this._point.z),i=new s.Pointing(t,!1);this._h_pix=e.ang2pix(i,!1)}get point(){return this._point}get name(){return this._name}get healpixPixel(){return this._h_pix}get shapeSize(){return this._shapesize}set shapeSize(e){this._shapesize=e}get brightnessFactor(){return this._brightnessFactor}set brightnessFactor(e){this._brightnessFactor=e}}},5803(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SphereFoV=void 0;const r=i(3890),s=i(7930);class o{static MIN_FOV_DEG=1e-6;fovXDeg=180;fovYDeg=180;ratio=0;_minFoV=180;_webgl;_lastModel=null;_lastCamera=null;constructor(e){this._webgl=e}getFoV(e,t,i,r){this._lastModel=t,this._lastCamera=i;const s=this._webgl.canvas;if(!s)return this.fovXDeg=180,this.fovYDeg=180,this._minFoV=this.minFoV,this;const o=s.getBoundingClientRect(),a=o.width,n=o.height;return this.fovXDeg=this.computeAngle(0,n/2,e,t,i,r).angleDeg,this.fovYDeg=this.computeAngle(a/2,0,e,t,i,r).angleDeg,this._minFoV=this.minFoV,this.ratio=this.computeRatio(i),this}computeRatio(e){const t=e.getCameraPosition();return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])/this.fovYDeg}get minFoV(){const e=this.fovYDeg<=this.fovXDeg?this.fovYDeg:this.fovXDeg;return this._minFoV=Math.max(e,o.MIN_FOV_DEG),this._minFoV}get xFoV(){return this.fovXDeg}get yFoV(){return this.fovYDeg}computeDistanceFromAngle(e){return e*this.ratio}changeMinFov(e){this.fovYDeg<=this.fovXDeg?this.fovYDeg=e:this.fovXDeg=e,this.minFoV}computeCameraPositionForMinFoV(e){return this.computeCameraPositionForFoV(e)}computeCameraPositionForFoV(e){return this.computeCameraPositionForAngularDiameter(e)}computeCameraPositionForAngularDiameter(e){if(!this._lastModel||!this._lastCamera)return[0,0,0];const t=1e-6,i=Math.max(t,Math.min(180-t,e))*Math.PI/360,s=Math.sin(i);if(s<=0)return[0,0,0];const o=this._lastModel,a=this._lastCamera,n=Math.max(o.radius/s,o.radius+1e-4),l=a.getCameraPosition(),h=r.vec3.fromValues(l[0]-o.center[0],l[1]-o.center[1],l[2]-o.center[2]);return r.vec3.length(h)<t?r.vec3.set(h,0,0,1):r.vec3.normalize(h,h),[o.center[0]+h[0]*n,o.center[1]+h[1]*n,o.center[2]+h[2]*n]}computeAngle(e,t,i,r,s,o){const a=this._webgl.canvas.getBoundingClientRect(),n=this.getIntersectionPointWithModel(a.width/2,a.height/2,r,s,o),l=this.getIntersectionPointWithModel(e,t,r,s,o);if(!n||!l)return{angleDeg:180,distance:-1};return{angleDeg:2*this.computeAngularDistanceDeg(n.point,l.point),distance:l.distance}}computeAngularDistanceDeg(e,t){const i=r.vec3.normalize(r.vec3.create(),e),o=r.vec3.normalize(r.vec3.create(),t),a=r.vec3.dot(i,o),n=r.vec3.cross(r.vec3.create(),i,o),l=Math.atan2(r.vec3.length(n),Math.min(1,Math.max(-1,a)));return(0,s.radToDeg)(l)}getIntersectionPointWithModel(e,t,i,s,o){const a=this.getRayFromMouse(e,t,o,s.getCameraMatrix()),n=this.raySphere(s.getCameraPosition(),a,i);if(n<0)return null;const l=r.vec3.create();r.vec3.scale(l,a,n),r.vec3.add(l,s.getCameraPosition(),l);const h=[l[0],l[1],l[2],1],c=[0,0,0,0];return this.mat4MultiplyVec4(i.getModelMatrixInverse(),h,c),{point:r.vec3.fromValues(c[0],c[1],c[2]),distance:n}}getRayFromMouse(e,t,i,s){const o=this._webgl.canvas.getBoundingClientRect(),a=[2*e/o.width-1,1-2*t/o.height,-1,1],n=r.mat4.create();r.mat4.invert(n,i);const l=[0,0,0,0];this.mat4MultiplyVec4(n,a,l);const h=[l[0],l[1],-1,0],c=r.mat4.create();r.mat4.invert(c,s);const u=[0,0,0,0];this.mat4MultiplyVec4(c,h,u);const d=r.vec3.fromValues(u[0],u[1],u[2]);return r.vec3.normalize(d,d),d}raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}mat4MultiplyVec4(e,t,i){i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3]}}t.SphereFoV=o},1232(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueGL=void 0;const r=i(146),s=i(6553),o=i(8145),a=i(7930),n=i(3559),l=i(5403);class h{_kind="CatalogueGL";static ELEM_SIZE=6;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static STANDARD_SHAPE_SIZE=10;static STANDARD_SHAPE_HUE=3;_ready;_name;_description;_sources;vertexCataloguePositionBuffer=null;vertexhoveredCataloguePositionBuffer=null;vertexCataloguePosition;_bufferInitialised=!1;_webgl;hoveredIndexes;selectedIndexes;extHoveredIndexes;_oldMouseCoords;_metadataManager;_isVisible=!0;_shapeColor="#8F00FF";_healpixDensityMap;_providerUrl;_catalogueShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,o){this._webgl=s,this._ready=!1,this._visibleTilesManager=o,this.TYPE="SOURCE_CATALOGUE",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this._sources=[],this.vertexCataloguePosition=new Float32Array(0),this.hoveredIndexes=[],this.selectedIndexes=[],this.extHoveredIndexes=[],this._oldMouseCoords=null,this._healpixDensityMap=new Map,this._catalogueShaderProgram=new n.CatalogueShaderProgram(this._webgl),this._catalogueShaderProgram.shaderProgram,this._isVisible=!0}setIsVisible(e){this._isVisible=e}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get isVisible(){return this._isVisible}minMax(e){if(!this._sources.length)return{min:0,max:0};let t=this._sources[0].details[e];if(isNaN(Number(t)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain only number values`),{min:0,max:0};let i=t;for(const r of this._sources){const s=r.details[e];if(isNaN(Number(s)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain number only values`),{min:0,max:0};s<t&&(t=s),s>i&&(i=s)}return{min:Number(t),max:Number(i)}}get metadataManager(){return this._metadataManager}changeMetaRA(e){this._metadataManager.selectedRaColumn=e}changeMetaDec(e){this._metadataManager.selectedDecColumn=e}changeColor(e){this._shapeColor=e}changeMetaShapeSize(e){if(!this._webgl)return;if(e==l.MetadataManager.STANDARD_SIZE){this._metadataManager.resetShapeColumn();for(const e of this._sources){const t=h.STANDARD_SHAPE_SIZE;e.shapeSize=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedShapeColumn=e;const i=this._metadataManager.selectedShapeColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedShapeColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),o=Number(r.max),a=12*((t-s)/Math.max(1e-12,o-s))+8;e.shapeSize=a}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}changeMetaShapeHue(e){if(!this._webgl)return;if(e==l.MetadataManager.STANDARD_HUE){this._metadataManager.resetHueColumn();for(const e of this._sources){const t=h.STANDARD_SHAPE_HUE;e.brightnessFactor=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedHueColumn=e;const i=this._metadataManager.selectedHueColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedHueColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),o=Number(r.max),a=(t-s)/Math.max(1e-12,o-s);e.brightnessFactor=-(2*a-1)}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}get sources(){return this._sources}addSource(e){this._sources.push(e)}addSources(e,t){this._ready=!1,this._sources=[],this._metadataManager=new l.MetadataManager(t);const i=this._metadataManager.selectedRaColumn?.index??-1,a=this._metadataManager.selectedDecColumn?.index??-1;if(i<0||a<0)throw new Error(`(ra, dec) idx not defined (${i}, ${a}) `);for(let t=0;t<e.length;t++){const n=new s.Point({raDeg:e[t][i],decDeg:e[t][a]},o.CoordsType.ASTRO),l=new r.Source(n,e[t]);l.shapeSize=l.shapeSize??h.STANDARD_SHAPE_SIZE,l.brightnessFactor=3,this.addSource(l),this._metadataManager.selectedHueColumn?.name&&this.changeMetaShapeHue(this._metadataManager.selectedHueColumn.name),this._metadataManager.selectedShapeColumn?.name&&this.changeMetaShapeSize(this._metadataManager.selectedShapeColumn.name)}this._ready=!0,this._bufferInitialised=!1}clearSources(){this._sources=[],this.hoveredIndexes=[],this._healpixDensityMap.clear(),this.vertexCataloguePosition=new Float32Array(0)}sourceMatches(e,t){if(e===t)return!0;const i=e.point,r=t.point;if(i.raDeg!==r.raDeg||i.decDeg!==r.decDeg)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findSourceIndex(e){const t=this._sources.indexOf(e);return t>=0?t:this._sources.findIndex(t=>this.sourceMatches(t,e))}extHighlightSource(e,t){const i=this.findSourceIndex(e);if(i<0)return;const r=i*h.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&(this.hoveredIndexes.splice(e,1),this.vertexCataloguePosition[r+3]=0,this.vertexCataloguePosition[r+4]=this._sources[i]?.shapeSize??h.STANDARD_SHAPE_SIZE)}}extAddSources2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findSourceIndex(e);if(t<0)return;const i=t*h.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&(this.selectedIndexes.splice(e,1),this.vertexCataloguePosition[i+3]=0,this.vertexCataloguePosition[i+4]=this._sources[t]?.shapeSize??h.STANDARD_SHAPE_SIZE)}else this.selectedIndexes.push(t)}initBuffer(){this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.vertexhoveredCataloguePositionBuffer=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer);const e=this._sources.length;this.vertexCataloguePosition=new Float32Array(e*h.ELEM_SIZE);let t=0;for(let i=0;i<e;i++){const e=this._sources[i],r=e.healpixPixel,s=this._healpixDensityMap.get(r);s?s.includes(i)||s.push(i):this._healpixDensityMap.set(r,[i]),this.vertexCataloguePosition[t+0]=e.point.x,this.vertexCataloguePosition[t+1]=e.point.y,this.vertexCataloguePosition[t+2]=e.point.z,this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=e.shapeSize??h.STANDARD_SHAPE_SIZE,this.vertexCataloguePosition[t+5]=e.brightnessFactor??0,t+=h.ELEM_SIZE}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._bufferInitialised=!0}getSelectionRadius(){switch(this._visibleTilesManager.getVisibleOrder()){case 0:case 1:case 2:return.01;case 3:case 4:case 5:return.005;case 6:case 7:case 8:return.001;case 9:return 5e-4;default:return 1e-4}}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkClicking: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const o=r[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,l=a.point.y-e.y,h=a.point.z-e.z;Math.sqrt(n*n+l*l+h*h)<=s&&t.push(o)}}return t}setSelectedIndexes(e){e.forEach(e=>{if(e<0||e>=this._sources.length)return;const t=e*h.ELEM_SIZE;t+4>=this.vertexCataloguePosition.length||(this.selectedIndexes.includes(e)?(this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1),this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??h.STANDARD_SHAPE_SIZE):(this.selectedIndexes.push(e),this.vertexCataloguePosition[t+3]=2,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??h.STANDARD_SHAPE_SIZE))})}getSourcesFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{sources:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this._sources[e];t&&i.push(t)}),i.length?{sources:i,pickedIndexes:t}:null}selectPrimarySourceFromClick(e){const t=this.getSourcesFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{sources:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this._sources[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({source:t,selected:i}),s.push(t)}),s.length?{sources:s,selectionState:r}:null}getPrimaryHoveredSource(){if(!this.hoveredIndexes.length)return null;const e=this.hoveredIndexes[0];return this._sources[e]??null}checkHovering(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkHovering: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const o=r[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,l=a.point.y-e.y,h=a.point.z-e.z;Math.sqrt(n*n+l*l+h*h)<=s&&t.push(o)}}return t}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;this._catalogueShaderProgram.enableShaders(r,e,i),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.position,3,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.position),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.hovered,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,3*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.hovered),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.pointSize,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,4*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.pointSize),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.brightness,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,5*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.brightness);const s=(0,a.colorHex2RGB)(this._shapeColor);this._catalogueShaderProgram.locations.color&&this._webgl.uniform4f(this._catalogueShaderProgram.locations.color,s[0],s[1],s[2],1);for(let e=0;e<this.selectedIndexes.length;e++){const t=this.selectedIndexes[e],i=t*h.ELEM_SIZE;this.vertexCataloguePosition[i+3]=2,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e]*h.ELEM_SIZE;this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[this.hoveredIndexes[e]].shapeSize}null!=t&&t.xyz!==this._oldMouseCoords&&(this.hoveredIndexes=this.checkHovering(t));for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e],i=t*h.ELEM_SIZE;this.vertexCataloguePosition[i+3]=1,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW);const o=this.vertexCataloguePosition.length/h.ELEM_SIZE;this._webgl.drawArrays(this._webgl.POINTS,0,o),this._oldMouseCoords=t.xyz}}t.CatalogueGL=h},3956(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WMTSAdapter=void 0;t.WMTSAdapter=class{_config;constructor(e){this._config=e}toXYZLayerConfig(){const e=this.getInferredMaxZoom();return{urlTemplate:this._config.urlTemplate??this._config.baseUrl,minZoom:this._config.minZoom,maxZoom:e,segmentsPerSide:this._config.segmentsPerSide,tileSize:this._config.tileSize,maxCachedTiles:this._config.maxCachedTiles,subdomains:this._config.subdomains,attribution:this._config.attribution,flipY:this._config.flipY,urlResolver:e=>this.getTileUrl(e)}}getInferredMaxZoom(){const e=this._config.matrixLabels?.length??0,t=e>0?e-1:void 0;return null==t?this._config.maxZoom:null==this._config.maxZoom?t:Math.min(this._config.maxZoom,t)}getTileUrl(e){return"rest"===this._config.requestEncoding?this.buildRestUrl(e):this.buildKvpUrl(e)}buildRestUrl(e){const t=function(e,t){return Object.entries(t).reduce((e,[t,i])=>e.replace(new RegExp(`\\{${t}\\}`,"g"),i),e)}(this._config.urlTemplate??this._config.baseUrl,this.getCommonTokenValues(e));return t.replace(/(?<!:)\/{2,}/g,"/")}buildKvpUrl(e){const t=new URL(this._config.baseUrl),i=this.getCommonTokenValues(e),r=t.searchParams;r.set("SERVICE","WMTS"),r.set("REQUEST","GetTile"),r.set("VERSION",this._config.version??"1.0.0"),r.set("LAYER",this._config.layer),r.set("STYLE",this._config.style??"default"),r.set("FORMAT",this._config.format??"image/png"),r.set("TILEMATRIXSET",this._config.tileMatrixSet),r.set("TILEMATRIX",i.TileMatrix),r.set("TILEROW",i.TileRow),r.set("TILECOL",i.TileCol);for(const[e,t]of Object.entries(this._config.dimensions??{}))r.set(e,t);return t.toString()}getCommonTokenValues(e){const t=2**e.z,i=this._config.flipY?t-1-e.y:e.y,r=this._config.matrixLabels?.[e.z]??String(e.z),s=this._config.format??"image/png",o=s.replace(/^image\//,"");return{Layer:this._config.layer,Style:this._config.style??"default",Time:this._config.time??"",TileMatrixSet:this._config.tileMatrixSet,TileMatrix:r,TileRow:String(i),TileCol:String(e.x),Format:o,TileFormat:s,TileFormatExtension:o,...Object.fromEntries(Object.entries(this._config.dimensions??{}).map(([e,t])=>[e,t]))}}}},3174(e,t,i){"use strict";t.XYZAnchestorTile=void 0;const r=i(8819),s=i(1375);class o extends s.XYZTile{_ancestorMeshBuilder;_ancestorWebgl;_segmentsPerSide;_meshCache=new Map;constructor(e,t,i,s,o=new r.XYZMeshBuilder,a=16){super(e,t,i,s,o,a),this._ancestorMeshBuilder=o,this._ancestorWebgl=i,this._segmentsPerSide=a}draw(e,t,i,r,s,o,a){if("number"!=typeof e)return super.draw(e,t,i,r);if(!s||!o||void 0===a)return!1;const n=t,l=i,h=r;let c=!1;if(e<=this.coord.z)return super.draw(h,s,o,a);for(const e of n){if(!this.isAncestorOf(e))continue;const t=`${this.coord.z}/${this.coord.x}/${this.coord.y}`;if(!l.has(t))continue;const i=this.getRemappedMesh(e);c=super.drawRemapped(i,h,s,o,a)||c}return c}dispose(){for(const e of this._meshCache.values())e.positionBuffer&&this._ancestorWebgl.deleteBuffer(e.positionBuffer),e.uvBuffer&&this._ancestorWebgl.deleteBuffer(e.uvBuffer),e.indexBuffer&&this._ancestorWebgl.deleteBuffer(e.indexBuffer);this._meshCache.clear(),super.dispose()}getRemappedMesh(e){const t=`${e.z}/${e.x}/${e.y}->${this.coord.z}/${this.coord.x}/${this.coord.y}`,i=this._meshCache.get(t);if(i)return i;const r=this._ancestorMeshBuilder.buildAncestorMesh(e,this.coord,this._segmentsPerSide),s=this._ancestorMeshBuilder.uploadMesh(r,this._ancestorWebgl);return this._meshCache.set(t,s),s}isAncestorOf(e){if(e.z<=this.coord.z)return e.z===this.coord.z&&e.x===this.coord.x&&e.y===this.coord.y;const t=e.z-this.coord.z;return e.x>>t===this.coord.x&&e.y>>t===this.coord.y}}t.XYZAnchestorTile=o},8284(e,t){"use strict";t.xyzFovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static ZOOM_MIN_FOV={2:179,3:90,4:30,5:20,6:6,7:3.2,8:1.6,9:.85,10:.42,11:.21,12:.12,13:.06,14:.015,15:0};getZoom(e,t){const r=this.getRawZoom(e);if(void 0===t||t===r)return r;if(r>t){const r=i.ZOOM_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.ZOOM_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawZoom(e){return e>=179?2:e>=90?3:e>=30?4:e>=20?5:e>=6?6:e>=3.2?7:e>=1.6?8:e>=.85?9:e>=.42?10:e>=.21?11:e>=.12?12:e>=.06?13:e>=.015?14:15}getLonLatSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{lonStep:i,latStep:r}}}t.xyzFovHelper=new i},1741(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMap=void 0;const r=i(4735),s=i(6937),o=i(8284),a=i(619),n=i(8124),l=i(149),h=i(2737),c=i(3174),u=i(8819);class d extends r.AbstractSkyEntity{_xyzShaderProgram;_descriptor;_visibleTilesManager;_tileBuffer;_meshBuilder;_baseurl;_zoom;_latLonGrid;_colorMapIdx=0;_colorMap=a.ColorMaps.native;constructor(e,t,i,r,a,c,d){super(e,t,i,r,a.name,c,!1),this._descriptor=a,this._xyzShaderProgram=new l.XYZShaderProgram(c),this._meshBuilder=new u.XYZMeshBuilder,this._tileBuffer=new h.XYZTileBuffer(1),this.initGL(c),this._latLonGrid=new n.LatLonGrid(e,t,i,r,"LatLonGrid",this._webgl,d),this._visibleTilesManager=new s.XYZVisibleTilesManager,this._baseurl=a.url,this.initShaders();this._zoom=o.xyzFovHelper.getZoom(180)}changeColorMap(e){switch(this._colorMap=e,e.name){case"grayscale":this._colorMapIdx=1,this._colorMap=a.ColorMaps.grayscale;break;case"planck":this._colorMapIdx=2,this._colorMap=a.ColorMaps.planck;break;case"cmb":this._colorMapIdx=3,this._colorMap=a.ColorMaps.cmb;break;case"rainbow":this._colorMapIdx=4,this._colorMap=a.ColorMaps.rainbow;break;case"eosb":this._colorMapIdx=5,this._colorMap=a.ColorMaps.eosb;break;case"cubehelix":this._colorMapIdx=6,this._colorMap=a.ColorMaps.cubehelix;break;case"hot":this._colorMapIdx=7,this._colorMap=a.ColorMaps.hot;break;case"gray":this._colorMapIdx=8,this._colorMap=a.ColorMaps.gray;break;case"native":this._colorMapIdx=0,this._colorMap=a.ColorMaps.native;break;default:this._colorMapIdx=9,this._colorMap=e}}initShaders(){this._xyzShaderProgram.enableProgram()}isLonLatGridVisible(){return this._latLonGrid.isVisible()}toggleLonLatGrid(){return this._latLonGrid.toggleShowGrid()}getFoV(){return this._latLonGrid.getFoV()}refresh(e){const t=this._latLonGrid.refreshFoV(e);this._zoom=o.xyzFovHelper.getZoom(t)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();this._xyzShaderProgram.setRuntimeColorMap(this._colorMap);const s=this._visibleTilesManager.computeVisibleTiles(this._zoom,this,this._webgl,e.camera,e.pMatrix),o=s.visibleTiles,a=s.ancestorsMap,n=this._tileBuffer.ensureTiles(this.getTilesToEnsure(o,a),e=>this.createTile(e));this._tileBuffer.evictCached(this._descriptor.maxCachedTiles);for(const e of n){const o=this._tileBuffer.getActiveTile(e);if(!o||o.coord.z!==s.currentZoom)continue;if(o.draw(i,t,r,this._colorMapIdx))continue;const n=this.findBestAvailableAncestor(o.coord);n?.draw(s.currentZoom,[o.coord],a,i,t,r,this._colorMapIdx)}this._latLonGrid.draw(e)}createTile(e){return new c.XYZAnchestorTile(e,this.resolveTileUrl(e),this._webgl,this._xyzShaderProgram,this._meshBuilder,this._descriptor.segmentsPerSide)}getTilesToEnsure(e,t){const i=new Map;for(const t of e)i.set(this.tileKey(t),t);for(const e of t.values())i.set(this.tileKey(e),e);return Array.from(i.values())}findBestAvailableAncestor(e){for(let t=e.z-1;t>=0;t--){const i=e.z-t,r={z:t,x:e.x>>i,y:e.y>>i},s=this._tileBuffer.getAnyTile(this.tileKey(r));if(s?.ready)return s}return null}resolveTileUrl(e){const t=this._descriptor.urlResolver;if(t)return t(e);const i=2**e.z,r=this._descriptor.flipY?i-1-e.y:e.y,s=this._descriptor.subdomains,o=s.length>0?s[Math.abs(e.x+e.y+e.z)%s.length]:"";return this._baseurl.replace(/\{z\}/g,String(e.z)).replace(/\{x\}/g,String(e.x)).replace(/\{y\}/g,String(r)).replace(/\{s\}/g,o??"")}getDebugStats(){const e=Array.from(this._tileBuffer.activeTiles.values(),e=>e.tile),t=Array.from(this._tileBuffer.cachedTiles.values(),e=>e.tile),i=[...e,...t],r=this._visibleTilesManager.selection;return{cacheSize:this._tileBuffer.size,visibleTileCount:r.visibleTiles.length,currentTileCount:e.filter(e=>e.coord.z===r.currentZoom).length,fallbackTileCount:r.ancestorsMap.size,coreTileCount:r.visibleTiles.length,coverageTileCount:r.visibleTiles.length,readyTileCount:i.filter(e=>e.ready).length,loadingTileCount:i.filter(e=>e.loading).length,coolingDownTileCount:0,currentZoom:r.currentZoom,tileSelectionKey:r.key,isSettling:!1,coarseTileCount:r.ancestorsMap.size,hasPendingSelection:!1,pendingSelectionKey:null}}tileKey(e){return`${e.z}/${e.x}/${e.y}`}}t.XYZMap=d},8868(e,t){"use strict";t.XYZMapDescriptor=void 0;t.XYZMapDescriptor=class{_name;_url;_urlResolver;_minZoom;_maxZoom;_segmentsPerSide;_tileSize;_maxCachedTiles;_interactionDebounceMs;_subdomains;_attribution;_flipY;_maxConcurrentLoads;constructor(e,t,i=0,r=8,s=16,o=384,a=8,n){this._name=e,this._url=t,this._urlResolver=n,this._minZoom=i,this._maxZoom=r,this._segmentsPerSide=s,this._maxCachedTiles=o,this._interactionDebounceMs=100,this._subdomains=["a","b","c"],this._attribution="",this._flipY=!1,this._maxConcurrentLoads=a}get url(){return this._url}get urlResolver(){return this._urlResolver}get name(){return this._name}get minZoom(){return this._minZoom}get maxZoom(){return this._maxZoom}get segmentsPerSide(){return this._segmentsPerSide}get maxCachedTiles(){return this._maxCachedTiles}get interactionDebounceMs(){return this._interactionDebounceMs}get subdomains(){return this._subdomains}get attribution(){return this._attribution}get flipY(){return this._flipY}get maxConcurrentLoads(){return this._maxConcurrentLoads}}},8819(e,t,i){"use strict";t.XYZMeshBuilder=void 0;const r=i(7930),s=85.0511287798066;function o(e){const t=Math.PI*(1-2*e);return 180*Math.atan(Math.sinh(t))/Math.PI}function a(e){return e<0?e+360:e}t.XYZMeshBuilder=class{buildTileMesh(e,t=16){const i=Math.max(1,Math.floor(t)),n=i+1,l=n*n,h=new Float32Array(3*l),c=new Float32Array(2*l),u=2**e.z;let d=0,g=0;for(let t=0;t<=i;t++){const n=t/i,l=(e.y+n)/u,_=90-Math.max(-85.0511287798066,Math.min(s,o(l)));for(let t=0;t<=i;t++){const s=t/i,o=a(360*((e.x+s)/u)-180),[l,p,f]=(0,r.sphericalToCartesian)(o,_,1);h[d++]=l,h[d++]=p,h[d++]=f,c[g++]=s,c[g++]=1-n}}const _=new Uint32Array(i*i*2*3);let p=0;for(let e=0;e<i;e++)for(let t=0;t<i;t++){const i=e*n+t,r=i+1,s=i+n,o=s+1;_[p++]=i,_[p++]=s,_[p++]=r,_[p++]=r,_[p++]=s,_[p++]=o}return{positions:h,uvs:c,indices:_.length>65535?_:new Uint16Array(_)}}buildAncestorMesh(e,t,i=16){const r=this.buildTileMesh(e,i),s=e.z-t.z,o=2**s,a=e.x-(t.x<<s),n=e.y-(t.y<<s),l=new Float32Array(r.uvs.length);for(let e=0;e<r.uvs.length;e+=2){const t=r.uvs[e]??0,i=1-(r.uvs[e+1]??0);l[e]=(a+t)/o,l[e+1]=1-(n+i)/o}return{positions:r.positions,uvs:l,indices:r.indices}}uploadMesh(e,t){const i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer(),o=e.indices instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT;return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.uvs,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:i,uvBuffer:r,indexBuffer:s,indexCount:e.indices.length,indexType:o}}}},1375(e,t,i){"use strict";t.XYZTile=void 0;const r=i(8819);t.XYZTile=class{_coord;_url;_webgl;_shaderProgram;_meshBuilder;_gpuMesh;_texture=null;_image;_ready=!1;_loading=!1;_aborted=!1;_failedUntil=0;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,i,s,o=new r.XYZMeshBuilder,a=16){this._coord=e,this._url=t,this._webgl=i,this._shaderProgram=s,this._meshBuilder=o;const n=this._meshBuilder.buildTileMesh(e,a);this._gpuMesh=this._meshBuilder.uploadMesh(n,this._webgl),this.initImage()}get coord(){return this._coord}get ready(){return this._ready}get loading(){return this._loading}get failedUntil(){return this._failedUntil}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}initImage(){if(this._loading||this._ready||this._aborted)return;const e=Date.now();if(this._failedUntil>e)return;this._loading=!0;const t=new Image;this._image=t,t.crossOrigin="anonymous",t.onload=()=>this.imageLoaded(),t.onerror=()=>{this._ready=!1,this._loading=!1,this._failedUntil=Date.now()+3e4},t.src=this._url}imageLoaded(){this._image&&!this._aborted&&(this.textureLoaded(this._image),this._loading=!1,this._failedUntil=0,this._ready=!0)}textureLoaded(e){const t=this._webgl;this._shaderProgram.enableProgram();const i=t.createTexture();if(!i)throw new Error(`Could not create XYZ texture for ${this.key}`);this._texture=i,t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}draw(e,t,i,r){return this.touch(),!(!this._ready||!this._texture||this._aborted)&&(this.drawWithGpuMesh(this._gpuMesh,e,t,i,r),!0)}drawRemapped(e,t,i,r,s){return this.touch(),!(!this._ready||!this._texture||this._aborted)&&(this.drawWithGpuMesh(e,t,i,r,s),!0)}dispose(){const e=this._webgl;this._texture&&(e.deleteTexture(this._texture),this._texture=null),this._gpuMesh.positionBuffer&&(e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh.positionBuffer=null),this._gpuMesh.uvBuffer&&(e.deleteBuffer(this._gpuMesh.uvBuffer),this._gpuMesh.uvBuffer=null),this._gpuMesh.indexBuffer&&(e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh.indexBuffer=null),this._image=void 0,this._ready=!1,this._loading=!1,this._aborted=!0}drawWithGpuMesh(e,t,i,r,s){if(!this._texture)return;const o=this._webgl;this._shaderProgram.enableShaders(t,i,r,s),o.bindBuffer(o.ARRAY_BUFFER,e.positionBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),o.bindBuffer(o.ARRAY_BUFFER,e.uvBuffer),o.vertexAttribPointer(this._shaderProgram.locations.textureCoordAttribute,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._texture),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,e.indexBuffer),o.drawElements(o.TRIANGLES,e.indexCount,e.indexType,0),o.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),o.disableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute)}get key(){return`${this._coord.z}/${this._coord.x}/${this._coord.y}`}}},2737(e,t){"use strict";t.XYZTileBuffer=void 0;class i{_tiles=new Map;_cachedTiles=new Map;_cacheAliveMilliSeconds;_cleanerId;constructor(e=1){this._cacheAliveMilliSeconds=60*e*1e3,"undefined"!=typeof window&&(this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4))}get activeTiles(){return this._tiles}get cachedTiles(){return this._cachedTiles}get size(){return this._tiles.size+this._cachedTiles.size}ensureTiles(e,t){const i=[];for(const r of e){const e=this.getTile(r,t);this.touchTile(e),i.push(this.key(r))}return this.syncVisibleTiles(i),i}getTile(e,t){const i=this.key(e);if(this._tiles.has(i))return this._tiles.get(i).tile;if(this._cachedTiles.has(i)){const e=this._cachedTiles.get(i);return e.cacheTime0=void 0,this._tiles.set(i,e),this._cachedTiles.delete(i),e.tile}const r=t(e);return this._tiles.set(i,{tile:r}),r}getActiveTile(e){return this._tiles.get(e)?.tile??null}getAnyTile(e){return this._tiles.get(e)?.tile??this._cachedTiles.get(e)?.tile??null}getActiveTiles(){return Array.from(this._tiles.values(),e=>e.tile)}syncVisibleTiles(e){const t=new Set(e);for(const[e,i]of this._tiles)t.has(e)?this.touchTile(i.tile):(i.cacheTime0=Date.now(),this._cachedTiles.set(e,i),this._tiles.delete(e))}evictCached(e){if(this.size<=e)return;const t=Array.from(this._cachedTiles.entries()).sort((e,t)=>this.getTileAgeScore(e[1].tile)-this.getTileAgeScore(t[1].tile));for(const[i,r]of t){if(this.size<=e)break;r.tile.loading||(r.tile.dispose?.(),this._cachedTiles.delete(i))}}dispose(){void 0!==this._cleanerId&&"undefined"!=typeof window&&(window.clearInterval(this._cleanerId),this._cleanerId=void 0);for(const e of this._tiles.values())e.tile.dispose?.();for(const e of this._cachedTiles.values())e.tile.dispose?.();this._tiles.clear(),this._cachedTiles.clear()}key(e){return i.key(e)}static key(e){return`${e.z}/${e.x}/${e.y}`}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;void 0===r||e-r<=this._cacheAliveMilliSeconds||i.tile.loading||(i.tile.dispose?.(),this._cachedTiles.delete(t))}}touchTile(e){e.touch?.()}getTileAgeScore(e){const t=e.lastUsedAt??0,i=e.createdAt??t;return Math.min(t||i,i)}}t.XYZTileBuffer=i},5409(e,t){"use strict";t.xyzTileRequestScheduler=void 0;class i extends Error{cooldownMs;retryable;constructor(e,t,i=!0){super(e),this.name="XYZTileRequestError",this.cooldownMs=t,this.retryable=i}}class r{_maxConcurrent;_activeCount=0;_queue=[];_inflight=new Map;_hostBackoff=new Map;_sequence=0;constructor(e=4){this._maxConcurrent=e}setMaxConcurrent(e){this._maxConcurrent=Math.max(1,Math.floor(e)),this.pump()}getMaxConcurrent(){return this._maxConcurrent}getDebugStats(){const e=Date.now(),t=Array.from(this._hostBackoff.entries()).map(([t,i])=>({host:t,cooldownMs:Math.max(0,i.cooldownUntil-e),consecutiveFailures:i.consecutiveFailures})).filter(e=>e.cooldownMs>0||e.consecutiveFailures>0).sort((e,t)=>t.cooldownMs-e.cooldownMs);return{activeRequests:this._activeCount,queuedRequests:this._queue.length,inflightRequests:this._inflight.size,maxConcurrentRequests:this._maxConcurrent,highestQueuedPriority:this._queue[0]?.priority??null,hostsInBackoff:t}}load(e,t=0){const r=this._inflight.get(e);if(r)return r;const s=this.getHostCooldown(e),o=Date.now();if(s>o)return Promise.reject(new i(`Cooldown active for ${new URL(e).host}`,s-o));const a=new Promise((i,r)=>{this._queue.push({url:e,resolve:i,reject:r,priority:t,sequence:this._sequence++}),this._queue.sort((e,t)=>t.priority-e.priority||e.sequence-t.sequence),this.pump()}).finally(()=>{this._inflight.delete(e)});return this._inflight.set(e,a),a}pump(){for(;this._activeCount<this._maxConcurrent&&this._queue.length>0;){const e=this._queue.shift();if(!e)return;const t=this.getHostCooldown(e.url),r=Date.now();t>r?e.reject(new i(`Cooldown active for ${new URL(e.url).host}`,t-r)):(this._activeCount+=1,this.fetchBlob(e).then(e.resolve).catch(e.reject).finally(()=>{this._activeCount-=1,this.pump()}))}}async fetchBlob(e){try{const t=await fetch(e.url,{mode:"cors",cache:"force-cache"});if(!t.ok){const r=429===t.status||t.status>=500,s=this.registerFailure(e.url,r);throw new i(`HTTP ${t.status} loading ${e.url}`,r?s:3e5,r)}return this.registerSuccess(e.url),await t.blob()}catch(t){if(t instanceof i)throw t;const r=this.registerFailure(e.url,!1);throw new i(`Network/CORS failure loading ${e.url}`,r,!0)}}getHostCooldown(e){try{return this._hostBackoff.get(new URL(e).host)?.cooldownUntil??0}catch{return 0}}registerSuccess(e){try{const t=new URL(e).host;this._hostBackoff.set(t,{cooldownUntil:0,consecutiveFailures:0})}catch{}}registerFailure(e,t){if(!t)return 0;try{const t=new URL(e).host,i=(this._hostBackoff.get(t)??{cooldownUntil:0,consecutiveFailures:0}).consecutiveFailures+1,r=4e3,s=Math.min(12e4,r*2**Math.min(i-1,5));return this._hostBackoff.set(t,{cooldownUntil:Date.now()+s,consecutiveFailures:i}),s}catch{return 3e4}}}t.xyzTileRequestScheduler=new r},6937(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XYZVisibleTilesManager=void 0;const s=r(i(2166));t.XYZVisibleTilesManager=class{_ancestorsMap=new Map;_visibleTilesMap=new Map;_visibleTiles=[];_selection={key:"0:",currentZoom:0,visibleTiles:[],visibleTilesMap:new Map,ancestorsMap:new Map};get ancestorsMap(){return this._ancestorsMap}get visibleTiles(){return this._visibleTiles}get visibleTilesMap(){return this._visibleTilesMap}get selection(){return this._selection}computeVisibleTiles(e,t,i,r,o,a=9,n=2){return this._visibleTiles=s.default.getVisibleTilesFromViewport(e,t,i,r,o,a,n),this._visibleTilesMap=this.buildTileMap(this._visibleTiles),this.refreshAncestorsMap(this._visibleTiles),this._selection={key:this.buildSelectionKey(e,this._visibleTiles),currentZoom:e,visibleTiles:this._visibleTiles,visibleTilesMap:this._visibleTilesMap,ancestorsMap:this._ancestorsMap},this._selection}refreshAncestorsMap(e){this._ancestorsMap.clear();for(const t of e)for(let e=t.z-1;e>=0;e--){const i=t.z-e,r={z:e,x:t.x>>i,y:t.y>>i};this._ancestorsMap.set(`${r.z}/${r.x}/${r.y}`,r)}}buildTileMap(e){const t=new Map;for(const i of e)t.set(this.key(i),i);return t}buildSelectionKey(e,t){return`${e}:${t.map(e=>`${e.x}/${e.y}`).join("|")}`}key(e){return`${e.z}/${e.x}/${e.y}`}}},2475(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=void 0;const s=r(i(2930)),o=r(i(9665)),a=i(8145);class n{_polygons=[];_convexPolygons=[];_stcs;_valid=!1;_details;_totPoints=0;_totConvexPoints=0;_npix256;_footprintsPointsOrder;_coordsType;_selectionObj;_identifier;_center;constructor(e,t=[],i,r=a.CoordsType.ASTRO){this._coordsType=r,e?(this._stcs=e.toUpperCase(),this._details=t,this._totPoints=0,this._totConvexPoints=0,this._footprintsPointsOrder=i,this.computePoints(),this._selectionObj=this.computeSelectionObject(),this._valid=!0):this._details=[]}static fromPolygons(e,t=[],i=a.CoordsType.ASTRO){const r=new n(void 0,[],void 0,i);return r._polygons=e,r._details=t,r._totPoints=e.reduce((e,t)=>e+t.length,0),r._totConvexPoints=0,r._coordsType=i,r._selectionObj=r.computeSelectionObject(),r._valid=r._totPoints>0,r}computeSelectionObject(){return s.default.computeSelectionObject(this._polygons)}computePoints(){const e=o.default.parseSTCS(this._stcs,{coordsType:this._coordsType});this._polygons=e.polygons,this._totPoints=e.totpoints}get valid(){return this._valid}get totPoints(){return this._totPoints}get totConvexPoints(){return this._totConvexPoints}get polygons(){return this._polygons}get convexPolygons(){return this._convexPolygons}get identifier(){return this._identifier}get center(){return this._center}get pixels(){return this._npix256}get details(){return this._details}get selectionObj(){return this._selectionObj}}t.Footprint=n},592(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintSetGL=void 0;const s=i(2475),o=i(7930),a=i(8909),n=i(6553),l=r(i(2930)),h=i(8145),c=i(5403);class u{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static CONVEXPOLY_ELEM_SIZE=3;_kind="FootprintSetGL";_ready;_name;_description;extHoveredIndexes;oldMouseCoords;healpixDensityMap;totConvexPoints;vertexCataloguePositionBuffer;indexBuffer;hoveredVertexPositionBuffer;hoveredIndexBuffer;selectedVertexPositionBuffer;selectedIndexBuffer;indexes;footprintPolygons=[];vertexCataloguePosition;totPoints;nPrimitiveFlags=0;hoveredIndexes;hoveredElementIndexes;_hoveredFootprints=[];hoveredVertexPosition;totHoveredPoints;nHoveredPrimitiveFlags=0;selectedIndexes;selectedElementIndexes;_selectedFootprints=[];selectedVertexPosition;totSelectedPoints;nSlectedPrimitiveFlags=0;_shapeColor="#00fff2ff";_coordsType=h.CoordsType.ASTRO;_bufferInitialised=!1;_webgl;_isVisible=!0;_metadataManager;_providerUrl;_footprintShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,o){this._webgl=s,this._ready=!1,this._visibleTilesManager=o,this.TYPE="FOOTPRINT_SET",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this.initFootprintArrays(),this.oldMouseCoords=null,this._footprintShaderProgram=new a.FootprintShaderProgram(this._webgl),this._footprintShaderProgram.shaderProgram}initFootprintArrays(){this.footprintPolygons=[],this.indexes=new Uint32Array,this.vertexCataloguePosition=new Float32Array,this.totPoints=0,this.totConvexPoints=0,this.extHoveredIndexes=new Uint32Array,this._hoveredFootprints=[],this.hoveredVertexPosition=new Float32Array,this.totHoveredPoints=0,this.hoveredIndexes=[],this.hoveredElementIndexes=new Uint32Array,this._selectedFootprints=[],this.selectedVertexPosition=new Float32Array,this.totSelectedPoints=0,this.selectedIndexes=[],this.selectedElementIndexes=new Uint32Array}initGLBuffers(){this._webgl&&(this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.indexBuffer=this._webgl.createBuffer(),this.hoveredVertexPositionBuffer=this._webgl.createBuffer(),this.hoveredIndexBuffer=this._webgl.createBuffer(),this.selectedVertexPositionBuffer=this._webgl.createBuffer(),this.selectedIndexBuffer=this._webgl.createBuffer())}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get metadataManager(){return this._metadataManager}addFootprint(e){this.footprintPolygons.push(e)}addFootprints(e,t){this._ready=!1,this._metadataManager=new c.MetadataManager(t);const i=this._metadataManager.selectedOutlineColumn?.index??-1;if(i<0)throw new Error("geomColumn or its index is undefined in footprintsetProps");for(let t=0;t<e.length;t++)if(null!==e[t][i]){const r=new s.Footprint(e[t][i],e[t],void 0,this._coordsType);r._valid&&(this.addFootprint(r),this.totPoints+=r.totPoints,this.totConvexPoints+=r.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}clearFootprints(){this.initFootprintArrays()}initBuffer(){if(!this._webgl)return;this.initGLBuffers();const e=this.footprintPolygons.length;let t=e-1;for(let i=0;i<e;i++)t+=this.footprintPolygons[i].polygons.length-1;this.indexes=new Uint32Array(this.totPoints+t+1);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this.vertexCataloguePosition=new Float32Array(3*this.totPoints);let r=0,s=0;this.nPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this.footprintPolygons[t].polygons;t>0&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const t of e){t!==e[0]&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const e of t)this.vertexCataloguePosition[r++]=1*e.x,this.vertexCataloguePosition[r++]=1*e.y,this.vertexCataloguePosition[r++]=1*e.z,this.indexes[s++]=Math.floor((r-1)/3)}}this.indexes[this.indexes.length-1]=i,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexes,this._webgl.STATIC_DRAW),this._bufferInitialised=!0,console.log("Buffer initialized")}checkSelection(e){if(!e.x||!e.y||!e.z)return;if(!e.computeNpix())return;this._hoveredFootprints=[],this.totHoveredPoints=0;const t=new n.Point({x:e.x,y:e.y,z:e.z},h.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const i=this.footprintPolygons[e];if(i.selectionObj&&l.default.checkPointInsidePolygon5(i.selectionObj,t)){const e=[...i.details],t=this._metadataManager.selectedOutlineColumn?.index??-1;t>=0&&e.splice(t,1),this._hoveredFootprints.push(i),this.totHoveredPoints+=i.totPoints}}this.initHoveringBuffer()}get hoveredFootprints(){return{metadata:this._metadataManager,footprints:this._hoveredFootprints,tableName:this._name,description:this._description,provider:this._providerUrl}}get selectedFootprints(){return this._selectedFootprints}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return[];const t=[],i=new n.Point({x:e.x,y:e.y,z:e.z},h.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const r=this.footprintPolygons[e];r.selectionObj&&(l.default.checkPointInsidePolygon5(r.selectionObj,i)&&t.push(e))}return t}setSelectedIndexes(e){e.forEach(e=>{e<0||e>=this.footprintPolygons.length||(this.selectedIndexes.includes(e)?this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1):this.selectedIndexes.push(e))}),this.refreshSelectedFootprints()}refreshSelectedFootprints(){if(this._selectedFootprints=this.selectedIndexes.map(e=>this.footprintPolygons[e]).filter(e=>Boolean(e)),this.totSelectedPoints=this._selectedFootprints.reduce((e,t)=>e+t.totPoints,0),0===this._selectedFootprints.length)return this.selectedVertexPosition=new Float32Array,this.selectedElementIndexes=new Uint32Array,void(this.nSlectedPrimitiveFlags=0);this.initSelectionBuffer()}getFootprintsFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{footprints:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this.footprintPolygons[e];t&&i.push(t)}),i.length?{footprints:i,pickedIndexes:t}:null}selectPrimaryFootprintFromClick(e){const t=this.getFootprintsFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{footprints:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this.footprintPolygons[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({footprint:t,selected:i}),s.push(t)}),s.length?{footprints:s,selectionState:r}:null}FootprintPolygonMatches(e,t){if(e===t)return!0;const i=e.convexPolygons,r=t.convexPolygons;if(i!==r||i!==r)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findFootprintPolygonIndex(e){const t=this.footprintPolygons.indexOf(e);return t>=0?t:this.footprintPolygons.findIndex(t=>this.FootprintPolygonMatches(t,e))}extHighlightFootprint(e,t){const i=this.findFootprintPolygonIndex(e);if(i<0)return;const r=i*u.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&this.hoveredIndexes.splice(e,1)}}extAddPolygons2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findFootprintPolygonIndex(e);if(t<0)return;const i=t*u.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&this.selectedIndexes.splice(e,1)}else this.selectedIndexes.push(t);this.refreshSelectedFootprints()}initHoveringBuffer(){if(!this._webgl)return;if(0==this._hoveredFootprints.length)return;let e=this._hoveredFootprints.length,t=e-1;for(let i=0;i<e;i++)t+=this._hoveredFootprints[i].polygons.length-1;this.hoveredElementIndexes=new Uint32Array(this.totHoveredPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this.hoveredVertexPosition=new Float32Array(3*this.totHoveredPoints);let r=0,s=0;this.nHoveredPrimitiveFlags=0;for(let t=0;t<e;t++){let e=this._hoveredFootprints[t].polygons;t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.hoveredVertexPosition[r]=1*t.x,this.hoveredVertexPosition[r+1]=1*t.y,this.hoveredVertexPosition[r+2]=1*t.z,this.hoveredElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}initSelectionBuffer(){if(!this._webgl)return;if(0==this._selectedFootprints.length)return;const e=this._selectedFootprints.length;let t=e-1;for(let i=0;i<e;i++)t+=this._selectedFootprints[i].polygons.length-1;this.selectedElementIndexes=new Uint32Array(this.totSelectedPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this.selectedVertexPosition=new Float32Array(3*this.totSelectedPoints);let r=0,s=0;this.nSlectedPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this._selectedFootprints[t].polygons;t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.selectedVertexPosition[r]=1*t.x,this.selectedVertexPosition[r+1]=1*t.y,this.selectedVertexPosition[r+2]=1*t.z,this.selectedElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}changeColor(e){this._shapeColor=e}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;if(this._footprintShaderProgram.enableShaders(r,e,i),null!=t&&t.xyz!=this.oldMouseCoords&&this.checkSelection(t),this._hoveredFootprints.length>0){const e=(0,o.colorHex2RGB)("#00FF00"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.hoveredVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.hoveredVertexPosition.length/3+this.nHoveredPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}if(this._selectedFootprints.length>0){const e=(0,o.colorHex2RGB)("#ECB462"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.selectedVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.selectedVertexPosition.length/3+this.nSlectedPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);const s=[...(0,o.colorHex2RGB)(this._shapeColor),1];this._webgl.uniform4f(this._footprintShaderProgram.locations.color,...s),this._webgl.drawElements(this._webgl.LINE_LOOP,this.indexes.length,this._webgl.UNSIGNED_INT,0),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null),this.oldMouseCoords=t.xyz}}t.FootprintSetGL=u},9839(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EquatorialGrid=void 0;const s=i(3890),o=i(229),a=i(7930),n=r(i(4707)),l=i(6553),h=i(8145),c=i(8083),u=r(i(5361)),d=i(4595),g=i(4735);class _ extends g.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;showGrid=!1;_shaderProgram;_vertexShader;_fragmentShader;defaultColor="#41d421";gridText;_attribLocations={position:0,selected:1,pointSize:2,color:3};_phiVertexPositionBuffer;_thetaVertexPositionBuffer;_fov;_phiStep=0;_phiStepRad=0;_thetaStep=0;_thetaStepRad=0;_phiArray=[];_thetaArray=[];_bufferKey="";_dec4Labels=new Map;_ra4Labels=new Map;_healpixGrid;constructor(e,t,i){super(d.HealpixGrid.RADIUS,d.HealpixGrid.INITIAL_POSITION,d.HealpixGrid.INITIAL_PhiRad,d.HealpixGrid.INITIAL_ThetaRad,"equatorial-grid",e),this._healpixGrid=t,this.gridText=new u.default("equatorial",i)}init(e){this._fov=e,this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders(),this._phiVertexPositionBuffer=super.webgl.createBuffer(),this._thetaVertexPositionBuffer=super.webgl.createBuffer(),this.initBuffers(this._fov)}initShaders(){const e=n.default.healpixGridFS();if(this._fragmentShader=super.webgl.createShader(super.webgl.FRAGMENT_SHADER),super.webgl.shaderSource(this._fragmentShader,e),super.webgl.compileShader(this._fragmentShader),!super.webgl.getShaderParameter(this._fragmentShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(e),void alert(e)}const t=n.default.healpixGridVS();if(this._vertexShader=super.webgl.createShader(super.webgl.VERTEX_SHADER),super.webgl.shaderSource(this._vertexShader,t),super.webgl.compileShader(this._vertexShader),!super.webgl.getShaderParameter(this._vertexShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(e),void alert(e)}super.webgl.attachShader(this._shaderProgram,this._vertexShader),super.webgl.attachShader(this._shaderProgram,this._fragmentShader),super.webgl.linkProgram(this._shaderProgram),super.webgl.getProgramParameter(this._shaderProgram,super.webgl.LINK_STATUS)||alert("Could not initialise shaders"),super.webgl.useProgram(this._shaderProgram)}initBuffers(e,t=!1){const i=o.fovHelper.getRADegSteps(e,t),r=i.raStep,s=i.decStep;this._phiStep=r,this._phiStepRad=(0,a.degToRad)(r),this._thetaStep=s,this._thetaStepRad=(0,a.degToRad)(s),this._ra4Labels=new Map,this._dec4Labels=new Map,this._phiArray=[],this._thetaArray=[];for(let e=s;e<180;e+=s){const t=new Float32Array(360/r*3),i=(0,a.degToRad)(e);for(let e=0;e<360;e+=r){const s=(0,a.degToRad)(e),o=1*Math.sin(i)*Math.cos(s),n=1*Math.sin(i)*Math.sin(s),l=1*Math.cos(i),h=Math.floor(e/r);t[3*h+0]=o,t[3*h+1]=n,t[3*h+2]=l,this._dec4Labels.has(e)||this._dec4Labels.set(e,[]),this._dec4Labels.get(e).push([o,n,l])}this._phiArray.push(t)}for(let e=0;e<360;e+=r){const t=new Float32Array(360/s*3),i=(0,a.degToRad)(e);for(let e=0;e<360;e+=s){const r=(0,a.degToRad)(e),o=1*Math.sin(r)*Math.cos(i),n=1*Math.sin(r)*Math.sin(i),l=1*Math.cos(r),h=Math.floor(e/s);t[3*h+0]=o,t[3*h+1]=n,t[3*h+2]=l;const c=90-e;this._ra4Labels.has(c)||this._ra4Labels.set(c,[]),this._ra4Labels.get(c).push([o,n,l])}this._thetaArray.push(t)}}refresh(e,t=!1){const i=o.fovHelper.getRADegSteps(e,t),r=`${t?"coarse":"settled"}:${i.raStep}:${i.decStep}`;this._bufferKey!==r&&(this._fov=e,this._bufferKey=r,this.initBuffers(this._fov,t))}vectorDistance(e,t){const i=e.x-t.x,r=e.y-t.y,s=e.z-t.z;return Math.sqrt(i*i+r*r+s*s)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const o=s.mat4.create();s.mat4.multiply(o,i,e);const n=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),l=r.getUniformLocation(this._shaderProgram,"uPMatrix"),h=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),n&&r.uniformMatrix4fv(n,!1,o),l&&r.uniformMatrix4fv(l,!1,t),h){const e=(0,a.colorHex2RGB)(this.defaultColor);r.uniform4f(h,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}draw(e){const t=e.fovDeg;if(!t)return;const i=super.webgl,r=this.getModelMatrix(),o=e.camera;if(!o)return;const n=o.getCameraMatrix(),u=e.pMatrix;if(!u)return;if(!n)return;if(0===this._thetaArray.length)return;if(this.refresh(t,!!e.cameraMoving),!this.showGrid)return void this.gridText.resetDivSets();this.enableShader(r,u,n);for(let e=0;e<this._phiArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._phiVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._phiArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._phiStep);for(let e=0;e<this._thetaArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._thetaVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._thetaArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._thetaStep);const d=c.FoVUtils.getCenterJ2000(i.canvas,this._healpixGrid,this._webgl,o,u),g=s.mat4.create();s.mat4.multiply(g,n,r);const _=s.mat4.create();s.mat4.multiply(_,u,g);for(const[e,t]of this._dec4Labels.entries())if(Math.abs(e-d.raDeg)<=this._phiStep)for(let e=0;e<t.length;e++){const[i,r,o]=t[e],a=[i,r,o,1],n=new l.Point({x:i,y:r,z:o},h.CoordsType.CARTESIAN).decDeg;if(Math.abs(n-d.decDeg)<60){const e=s.vec4.create();s.vec4.transformMat4(e,a,_),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(n.toFixed(2),i,r,"dec")}}for(const[e,t]of this._ra4Labels.entries())if(Math.abs(e-d.decDeg)<=this._thetaStep)for(let e=0;e<t.length;e++){const[i,r,o]=t[e],n=[i,r,o,1],c=new l.Point({x:i,y:r,z:o},h.CoordsType.CARTESIAN),u=this.vectorDistance(c,d),g=c.raDeg;if(u<(0,a.degToRad)(50)){const e=s.vec4.create();s.vec4.transformMat4(e,n,_),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(g.toFixed(2),i,r,"ra")}}this.gridText.resetDivSets(),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null)}}t.EquatorialGrid=_},5361(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{layer;state;containers;constructor(e="equatorial",t){this.layer=e,this.containers=t,this.state={container:this.resolveContainer(e),divSets:[],divSetNdx:0}}initHtml(){this.refreshContainer(this.layer,this.state)}resetDivSets(e=this.layer){const t=e===this.layer?this.state:{container:this.resolveContainer(e),divSets:[],divSetNdx:0};for(this.refreshContainer(e,t);t.divSetNdx<t.divSets.length;++t.divSetNdx)t.divSets[t.divSetNdx].style.display="none";t.divSetNdx=0}addHPXDivSet(e,t,i){this.addLabel("healpix",e,t+25,i,"hpx")}addEqDivSet(e,t,i,r){this.addLabel("equatorial",e,"ra"===r?t+25:t,"ra"===r?i:i+25,r)}addLonLatDivSet(e,t,i,r){this.addLabel("lonlat",e,"lon"===r?t+25:t,"lon"===r?i:i+25,r)}addLabel(e,t,i,r,s){const o=e===this.layer?this.state:{container:this.resolveContainer(e),divSets:[],divSetNdx:0};if(this.refreshContainer(e,o),!o.container)return;let a=o.divSets[o.divSetNdx++];if(!a){const e=document.createElement("div"),t=document.createTextNode("");e.appendChild(t),o.container.appendChild(e),a={div:e,textNode:t,style:e.style},o.divSets.push(a)}a.div.className=this.classNameForKind(s),a.style.display="block",a.style.position="absolute",a.style.zIndex="2",a.style.pointerEvents="none",a.style.font='12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',a.style.textShadow="0 1px 2px rgba(0, 0, 0, 0.7)",a.style.color=this.colorForKind(s);const n=o.container.getBoundingClientRect();a.style.left=`${Math.floor(i-n.left)}px`,a.style.top=`${Math.floor(r-n.top)}px`,a.textNode.nodeValue=t}colorForKind(e){switch(e){case"dec":return"#3fd35f";case"lat":return"#f6d35b";case"lon":return"#40c8ff";default:return"#5b7cff"}}classNameForKind(e){switch(e){case"dec":return"floating-div-dec";case"lat":return"floating-div-lat";case"lon":return"floating-div-lon";default:return"floating-div-ra"}}resolveContainer(e){if("healpix"===e){const e=this.containers?.resolveHealpix?.();return e||(this.containers?.healpix?this.containers.healpix:document.querySelector("#gridhpx"))}const t=this.containers?.resolveCoords?.();return t||(this.containers?.coords?this.containers.coords:document.querySelector("#gridcoords"))}refreshContainer(e,t){const i=this.resolveContainer(e);if(i!==t.container){for(const e of t.divSets)e.div.remove();t.container=i,t.divSets=[],t.divSetNdx=0}}}},4595(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HealpixGrid=void 0;const s=i(4735),o=r(i(4382)),a=i(3890),n=i(229),l=i(8083),h=i(5803),c=i(8145),u=i(6553),d=r(i(4707)),g=r(i(2930)),_=r(i(5361)),p=i(7930),f=i(2056),m=i(2919);class x extends s.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_visibleorder=0;showGrid=!1;_shaderProgram;fragmentShader;vertexShader;defaultColor="#ec0acaff";gridText;_attribLocations={position:0,selected:1,pointSize:2,color:3};_nPrimitiveFlags=0;_vertexCataloguePositionBuffer;_indexBuffer;_vertexCataloguePosition=new Float32Array(0);_indexes=new Uint32Array(0);_fovObj;static INITIAL_FOV=180;static RADIUS=1;static INITIAL_POSITION=[0,0,0];static INITIAL_PhiRad=0;static INITIAL_ThetaRad=0;_visibleTilesManager;constructor(e,t){super(x.RADIUS,x.INITIAL_POSITION,x.INITIAL_PhiRad,x.INITIAL_ThetaRad,"healpix-grid",e),this.gridText=new _.default("healpix",t),this.init(),this._visibleTilesManager=new f.VisibleTilesManager(this._webgl,super.hipsShaderProgram,this),this._visibleTilesManager.init(m.bootSetup.insideSphere)}init(){console.log("HealpixGridSingleton.init()"),this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders();const e=n.fovHelper.getHiPSNorder(x.INITIAL_FOV);this._visibleorder=e,this._nPrimitiveFlags=0,this._vertexCataloguePositionBuffer=super.webgl.createBuffer(),this._indexBuffer=super.webgl.createBuffer(),this._vertexCataloguePosition=new Float32Array(0),this._fovObj=new h.SphereFoV(super.webgl)}get fovObj(){return this._fovObj}get RADIUS(){return x.RADIUS}get INITIAL_POSITION(){return x.INITIAL_POSITION}get INITIAL_PhiRad(){return x.INITIAL_PhiRad}get INITIAL_ThetaRad(){return x.INITIAL_ThetaRad}refreshFoV(e,t){return this._fovObj.getFoV(o.default.insideSphere,this,e,t)}getFoV(){return this._fovObj}getMinFoV(){return this._fovObj.minFoV}initShaders(){const e=super.webgl,t=d.default.healpixGridFS();if(this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this.fragmentShader,t),e.compileShader(this.fragmentShader),!e.getShaderParameter(this.fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this.fragmentShader)||"Fragment shader compile error");const i=d.default.healpixGridVS();this.vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this.vertexShader,i),e.compileShader(this.vertexShader),e.getShaderParameter(this.vertexShader,e.COMPILE_STATUS)?(e.attachShader(this._shaderProgram,this.vertexShader),e.attachShader(this._shaderProgram,this.fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)):alert(e.getShaderInfoLog(this.vertexShader)||"Vertex shader compile error")}initBuffers(e,t){this._nPrimitiveFlags=0;const i=o.default.getHealpix(t),r=o.default.getHealpix(t+1),s=o.default.getHealpix(t+2);let a=0,n=0;this._indexes=new Uint32Array(17*e.length),this._vertexCataloguePosition=new Float32Array(48*e.length);for(let t=0;t<e.length;t++){const o=i.getBoundaries(e[t]),l=e[t]<<2,h=l+1,c=l+2,u=l+3,d=r.getBoundaries(l),g=r.getBoundaries(u),_=e=>{this._vertexCataloguePosition[a]=1*e.x,this._vertexCataloguePosition[a+1]=1*e.y,this._vertexCataloguePosition[a+2]=1*e.z,this._indexes[n]=Math.floor(a/3),n+=1,a+=3};_(o[0]);let p=(u<<2)+3,f=s.getBoundaries(p);_(f[1]),_(g[1]);let m=(c<<2)+2;f=s.getBoundaries(m),_(f[0]),_(o[1]),_(f[2]),_(d[1]);let x=l<<2;f=s.getBoundaries(x),_(f[1]),_(o[2]),_(f[3]),_(d[3]);let b=(h<<2)+1;f=s.getBoundaries(b),_(f[2]),_(o[3]),_(f[0]),_(g[3]),f=s.getBoundaries(p),_(f[3]),this._indexes[n]=4294967295,this._nPrimitiveFlags+=1,n+=1}}refresh(e,t){this.refreshFoV(e,t);const i=this.getMinFoV();this._visibleorder=n.fovHelper.getHiPSNorder(i,this._visibleorder)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const s=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),o=r.getUniformLocation(this._shaderProgram,"uPMatrix"),n=super.webgl.getUniformLocation(this._shaderProgram,"u_fragcolor");this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition");let l=a.mat4.create();if(l=a.mat4.multiply(l,i,e),s&&r.uniformMatrix4fv(s,!1,l),o&&r.uniformMatrix4fv(o,!1,t),n){const e=(0,p.colorHex2RGB)(this.defaultColor);r.uniform4f(n,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}get visibleTilesManager(){return this._visibleTilesManager}draw(e){const t=super.webgl,i=this.getModelMatrix(),r=e.camera;if(!r)return;const s=r.getCameraMatrix(),h=e.pMatrix;if(!h)return;const d=e.fovDeg??this.getMinFoV(),_=Number.isFinite(d)&&d>0?d:1e-6;if(this._visibleorder=n.fovHelper.getHiPSNorder(_,this._visibleorder),!this.showGrid)return void this.gridText.resetDivSets();const p=this._visibleTilesManager.visibleTilesByOrder,f=p.pixels,m=p.order;this.initBuffers(f,m),this.enableShader(i,h,s),t.bindBuffer(t.ARRAY_BUFFER,this._vertexCataloguePositionBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexCataloguePosition,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,x.ELEM_SIZE,t.FLOAT,!1,x.BYTES_X_ELEM*x.ELEM_SIZE,0),t.enableVertexAttribArray(this._attribLocations.position),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indexes,t.STATIC_DRAW),t.drawElements(t.LINE_LOOP,this._vertexCataloguePosition.length/3+this._nPrimitiveFlags,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);let b=a.mat4.create();b=a.mat4.multiply(b,s,i);let S=a.mat4.create();S=a.mat4.multiply(S,h,b);const v=l.FoVUtils.getCenterJ2000(t.canvas,this,this._webgl,r,h),M=this.getMinFoV()*Math.PI/180/2;for(let e=0;e<f.length;e++){const i=o.default.getHealpix(this._visibleorder).pix2vec(f[e]),r=new u.Point({x:i.x,y:i.y,z:i.z},c.CoordsType.CARTESIAN);if(g.default.orthodromicDistance(v,r)<M){const r=[i.x,i.y,i.z,1],s=a.vec4.create();a.vec4.transformMat4(s,r,S),s[0]/=s[3],s[1]/=s[3];const o=t.canvas.getBoundingClientRect(),n=o.left+(.5*s[0]+.5)*o.width,l=o.top+(-.5*s[1]+.5)*o.height;this.gridText.addHPXDivSet(this._visibleorder+"/"+f[e],n,l)}}this.gridText.resetDivSets(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}get visibleorder(){return this._visibleorder}}t.HealpixGrid=x},8124(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LatLonGrid=void 0;const s=i(3890),o=i(4735),a=i(8284),n=r(i(4707)),l=i(7930),h=i(5803),c=r(i(4382)),u=r(i(5361));class d extends o.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_shaderProgram;_vertexShader;_fragmentShader;_attribLocations={position:0};_lonVertexPositionBuffer;_latVertexPositionBuffer;_lonStep=10;_latStep=10;_segmentStep=1;_fovObj;_fovDeg=180;_showGrid=!0;_lonArray=[];_latArray=[];_bufferKey="";defaultColor="#41d4d4";gridText;constructor(e,t,i,r,s,o,a){super(e,t,i,r,s,o),this.gridText=new u.default("lonlat",a),this._fovObj=new h.SphereFoV(o),this.init()}init(){this.initGL(super.webgl);const e=super.webgl;this._shaderProgram=e.createProgram(),this.initShaders(),this._lonVertexPositionBuffer=e.createBuffer(),this._latVertexPositionBuffer=e.createBuffer(),this.initBuffers(this._fovDeg)}initShaders(){const e=super.webgl,t=n.default.healpixGridFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(t),void alert(t)}const i=n.default.healpixGridVS();if(this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),!e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(t),void alert(t)}e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)}initBuffers(e,t,i=!1){const r=a.xyzFovHelper.getLonLatSteps(e,i);this._lonStep=r.lonStep,this._latStep=r.latStep,this._segmentStep=Math.max(Math.min(this._lonStep,this._latStep),.25),this._lonArray=[],this._latArray=[];const s=t?{lon:this.normalizeLon(t.phi>180?t.phi-360:t.phi),lat:90-t.theta}:null,o=!!s&&!i&&e<2,n=o?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._lonStep):this.buildLonRange(0,180,this._lonStep),l=o?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._latStep):this.buildLatRange(0,90,this._latStep),h=o&&s?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._segmentStep):this.buildLatRange(0,90,this._segmentStep),c=o&&s?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._segmentStep):this.buildLonRange(0,180,this._segmentStep);for(const e of n){const t=[];for(const i of h)t.push(...this.lonLatToCartesian(e,Math.min(i,90)));this._lonArray.push(new Float32Array(t))}for(const e of l){const t=[];if(!(e<=-90||e>=90)){for(const i of c)t.push(...this.lonLatToCartesian(Math.min(i,180),e));this._latArray.push(new Float32Array(t))}}}buildLonRange(e,t,i){const r=[],s=Math.floor((e-t)/i)*i,o=Math.ceil((e+t)/i)*i;for(let e=s;e<=o;e+=i)r.push(this.normalizeLon(e));return r}buildLatRange(e,t,i){const r=[],s=Math.max(-90,Math.floor((e-t)/i)*i),o=Math.min(90,Math.ceil((e+t)/i)*i);for(let e=s;e<=o;e+=i)r.push(e);return r}lonLatToCartesian(e,t){const i=(0,l.degToRad)(e),r=(0,l.degToRad)(t),s=Math.cos(r);return[s*Math.cos(i),s*Math.sin(i),Math.sin(r)]}refresh(e,t){const i=!!t.cameraMoving,r=a.xyzFovHelper.getLonLatSteps(e,i),s=t.centerSphericalDeg,o=!!s&&!i&&e<2,n=s?this.normalizeLon(s.phi>180?s.phi-360:s.phi):0,l=s?90-s.theta:0,h=o?`${this.roundToStep(n,Math.max(r.lonStep,e))}:${this.roundToStep(l,Math.max(r.latStep,e))}`:"global",c=`${i?"coarse":"settled"}:${r.lonStep}:${r.latStep}:${h}`;this._bufferKey!==c&&(this._fovDeg=e,this._bufferKey=c,this.initBuffers(this._fovDeg,t.centerSphericalDeg,i))}refreshFoV(e){return e.camera&&e.pMatrix?(this._fovObj.getFoV(c.default.insideSphere,this,e.camera,e.pMatrix),this.refresh(this._fovObj.minFoV,e),this._fovObj.minFoV):this._fovDeg}getMinFoVDeg(){return this._fovObj.minFoV}getFoV(){return this._fovObj}isVisible(){return this._showGrid}toggleShowGrid(){return this._showGrid=!this._showGrid,this._showGrid}setShowGrid(e){this._showGrid=e}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const o=s.mat4.create();s.mat4.multiply(o,i,e);const a=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),n=r.getUniformLocation(this._shaderProgram,"uPMatrix"),h=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),a&&r.uniformMatrix4fv(a,!1,o),n&&r.uniformMatrix4fv(n,!1,t),h){const e=(0,l.colorHex2RGB)(this.defaultColor);r.uniform4f(h,e[0],e[1],e[2],1)}}draw(e){if(!this._showGrid)return void this.gridText.resetDivSets();const t=super.webgl,i=e.camera;if(!i)return;const r=e.pMatrix;if(!r)return;this.refreshFoV(e);const s=i.getCameraMatrix();if(!s)return;const o=this.getModelMatrix();this.enableShader(o,r,s);for(const e of this._lonArray)t.bindBuffer(t.ARRAY_BUFFER,this._lonVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_STRIP,0,e.length/d.ELEM_SIZE);for(const e of this._latArray)t.bindBuffer(t.ARRAY_BUFFER,this._latVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_LOOP,0,e.length/d.ELEM_SIZE);this.drawLabels(e,o,r,s),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}drawLabels(e,t,i,r){const s=e.centerSphericalDeg;if(!s)return void this.gridText.resetDivSets();const o=this.normalizeLon(s.phi>180?s.phi-360:s.phi),a=90-s.theta,n=this.normalizeLon(this.roundToStep(o,this._lonStep)),l=Math.max(-90+this._latStep,Math.min(90-this._latStep,this.roundToStep(a,this._latStep))),h=this.lonLatToCartesian(n,Math.max(-80,Math.min(80,a))),c=this.lonLatToCartesian(o,l),u=this.projectPointToScreen(h,t,i,r);u&&this.gridText.addLonLatDivSet(`${n.toFixed(0)}° lon`,u.x,u.y,"lon");const d=this.projectPointToScreen(c,t,i,r);d&&this.gridText.addLonLatDivSet(`${l.toFixed(0)}° lat`,d.x,d.y,"lat"),this.gridText.resetDivSets()}projectPointToScreen(e,t,i,r){const o=s.mat4.create(),a=s.mat4.create();s.mat4.multiply(o,r,t),s.mat4.multiply(a,i,o);const n=s.vec4.fromValues(e[0],e[1],e[2],1);if(s.vec4.transformMat4(n,n,a),Math.abs(n[3])<1e-6)return null;if(n[0]/=n[3],n[1]/=n[3],n[0]<-1||n[0]>1||n[1]<-1||n[1]>1)return null;const l=super.webgl.canvas.getBoundingClientRect();return{x:l.left+(.5*n[0]+.5)*l.width,y:l.top+(-.5*n[1]+.5)*l.height}}roundToStep(e,t){return t<=0?e:Math.round(e/t)*t}normalizeLon(e){let t=e;for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}t.LatLonGrid=d},2368(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(1399);t.default=class{_ready=!1;_hips;_format;_baseurl;_isGalacticHips;_order=3;opacity=1;_hipsShaderIndex=0;_texture=null;_image;_texurl;_fitsTile;_textureLoaded=!1;_maxTiles=0;_numFacesXTile=0;_numFaces=0;vertexPosition;vertexPositionBuffer;vertexIndexBuffer;vidx=0;_webgl;_tileBuffer;_hipsShaderProgram;constructor(e,t,i,r){this._tileBuffer=i,this._hips=e,this._webgl=t,this._format=e.format,this._baseurl=e.baseURL,this._isGalacticHips=e.isGalacticHips,this._hipsShaderProgram=r,this.initImage()}initImage(){this._texurl=`${this._baseurl}/Norder3/Allsky.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.setAttribute("crossorigin","anonymous"),this._image.src=this._texurl}async loadFits(){try{this._fitsTile=await(0,o.loadFitsTile)(this._texurl),this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}catch(e){console.error(`[AllSky] Unable to load FITS atlas ${this._texurl}`,e)}}imageLoaded(){this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;if(this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),e.bindTexture(e.TEXTURE_2D,this._texture),"fits"===this._format){const t=this._fitsTile;if(!t)throw new Error(`FITS AllSky data not loaded: ${this._texurl}`);e.texImage2D(e.TEXTURE_2D,0,e.R32F,t.width,t.height,0,e.RED,e.FLOAT,t.pixels),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.generateMipmap(e.TEXTURE_2D);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.isTexture(this._texture)||console.log("error in texture")}getFitsDataRange(){const e=this._hips.dataRange;if(void 0!==e.min&&void 0!==e.max&&Number.isFinite(e.min)&&Number.isFinite(e.max)&&e.max>e.min)return{min:e.min,max:e.max};const t=this._fitsTile;return t&&null!==t.dataMin&&null!==t.dataMax&&Number.isFinite(t.dataMin)&&Number.isFinite(t.dataMax)&&t.dataMax>t.dataMin?{min:t.dataMin,max:t.dataMax}:null}initModelBuffer(){const e=this._webgl,t=this._order+1,i=s.default.getHealpix(this._order);this._maxTiles=i.getNPix();const r=s.default.getHealpix(t);this._numFacesXTile=4,this._numFaces=this._numFacesXTile*this._maxTiles,this.vertexPosition=new Float32Array(20*this._numFaces);let o=0,a=0;this.vidx=0;for(let e=0;e<this._maxTiles;e++){const t=i.nest2xyf(e),s=t.ix<<1,n=2+(t.ix<<1),l=t.iy<<1,h=2+(t.iy<<1);this.setupPositionAndTexture4Quadrant(o,a,s,s+(n-s)/2,l,l+(h-l)/2,r,t,0,0),this.setupPositionAndTexture4Quadrant(o,a,s+(n-s)/2,n,l,l+(h-l)/2,r,t,0,1),this.setupPositionAndTexture4Quadrant(o,a,s,s+(n-s)/2,l+(h-l)/2,h,r,t,1,0),this.setupPositionAndTexture4Quadrant(o,a,s+(n-s)/2,n,l+(h-l)/2,h,r,t,1,1),o++,27===o&&(a++,o=0)}const n=new Uint16Array(6*this._numFaces);let l=0;for(let e=0;e<this._numFaces;e++)n[6*e]=l,n[6*e+1]=l+1,n[6*e+2]=l+3,n[6*e+3]=l+1,n[6*e+4]=l+2,n[6*e+5]=l+3,l+=4;this.vertexPositionBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexPositionBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexPosition,e.STATIC_DRAW),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,i,r,s,o,a,n,l,h){let c=[];const u=2**(a.order-3),d=1/(27*u),g=1/(29*u),_=d/64,p=g/64,f=u*d*e+d*l,m=u*g*t+g*h;for(let e=i;e<r;e++)for(let t=s;t<o;t++)c=a.getPointsForXyfNoStep(e,t,n.face),this.vertexPosition[20*this.vidx]=c[0].x,this.vertexPosition[20*this.vidx+1]=c[0].y,this.vertexPosition[20*this.vidx+2]=c[0].z,this.vertexPosition[20*this.vidx+3]=d+f-_,this.vertexPosition[20*this.vidx+4]=1-(g+m)+p,this.vertexPosition[20*this.vidx+5]=c[1].x,this.vertexPosition[20*this.vidx+6]=c[1].y,this.vertexPosition[20*this.vidx+7]=c[1].z,this.vertexPosition[20*this.vidx+8]=d+f-_,this.vertexPosition[20*this.vidx+9]=1-m-p,this.vertexPosition[20*this.vidx+10]=c[2].x,this.vertexPosition[20*this.vidx+11]=c[2].y,this.vertexPosition[20*this.vidx+12]=c[2].z,this.vertexPosition[20*this.vidx+13]=f+_,this.vertexPosition[20*this.vidx+14]=1-m-p,this.vertexPosition[20*this.vidx+15]=c[3].x,this.vertexPosition[20*this.vidx+16]=c[3].y,this.vertexPosition[20*this.vidx+17]=c[3].z,this.vertexPosition[20*this.vidx+18]=f+_,this.vertexPosition[20*this.vidx+19]=1-(g+m)+p,this.vidx++}draw(e,t,i,r,s,o){if(!this._ready)return!1;let a=[];if(e>=this._order){const n=this.drawChildren(e,t,i,r,s,o);n&&(a=n)}const n=this._webgl;if(this._hipsShaderProgram.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return console.error(`[AllSky] No display range available for FITS atlas ${this._texurl}`),!1;this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max)}else this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!1);n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture);const l=this._hipsShaderProgram.locations.textureAlpha[this._hipsShaderIndex];l&&n.uniform1f(l,this.opacity),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12);for(let e=0;e<this._maxTiles;e++)a.includes(e)||n.drawElements(n.TRIANGLES,6*this._numFacesXTile,n.UNSIGNED_SHORT,12*e*this._numFacesXTile);return n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,o){const a=this._order;if(!t.has(a))return;const n=t.get(a),l=[];for(let h=0;h<n.length;h++){const c=n[h],u=this._isGalacticHips?this._tileBuffer.getGalTile(c,a,this._hips):this._tileBuffer.getTile(c,a,this._hips);u.draw(e,t,i,r,s,o,this._hipsShaderProgram),u.getReadyState()&&l.push(c)}return l}}},2885(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(229),a=i(1399);t.default=class{_hips;_tileno;_baseurl;_order;_ready=!1;_format;_isGalacticHips;opacity=1;_hipsShaderIndex=0;_pixels=[];_texture=null;_image;_texurl="";_fitsTile;vertexPosition;vertexPositionBuffer;vertexIndices;vertexIndexBuffer;_tileBuffer;_hipsShaderProgram;_webgl;constructor(e,t,i,r,s,o){this._hipsShaderProgram=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._webgl=o,this._format=i.format,this._baseurl=i.baseURL,this._isGalacticHips=i.isGalacticHips,this._order=t,this.initImage()}destroyIntervals(){}initImage(){const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}async loadFits(){try{this._fitsTile=await(0,a.loadFitsTile)(this._texurl),this.textureLoaded();const e=this._fitsTile;if(!e)throw new Error(`FITS tile data not loaded: ${this._texurl}`);const t=this._webgl;t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.bindTexture(t.TEXTURE_2D,this._texture),t.texImage2D(t.TEXTURE_2D,0,t.R32F,e.width,e.height,0,t.RED,t.FLOAT,e.pixels),this.initModelBuffer(),this._ready=!0}catch(e){console.error(`[AncestorTile] Unable to load FITS tile ${this._texurl}`,e)}}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.crossOrigin="anonymous",this._image.src=this._texurl}imageLoaded(){this.textureLoaded(),this.initModelBuffer();const e=this._webgl;e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),e.bindTexture(e.TEXTURE_2D,this._texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),"fits"===this._format?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR)),e.isTexture(this._texture)||console.log("error in texture")}getFitsDataRange(){const e=this._hips.dataRange;if(void 0!==e.min&&void 0!==e.max&&Number.isFinite(e.min)&&Number.isFinite(e.max)&&e.max>e.min)return{min:e.min,max:e.max};const t=this._fitsTile;return t&&null!==t.dataMin&&null!==t.dataMax&&Number.isFinite(t.dataMin)&&Number.isFinite(t.dataMax)&&t.dataMax>t.dataMin?{min:t.dataMin,max:t.dataMax}:null}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=o.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,a=i.ix<<r,n=(i.ix<<r)+(1<<r),l=i.iy<<r,h=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this._pixels=[],this.setupPositionAndTexture4Quadrant(a,n/2,l,h/2,0,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,l,h/2,1,c,r,i),this.setupPositionAndTexture4Quadrant(a,n/2,h/2,h,2,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,h/2,h,3,c,r,i);const u=this.vertexPosition[0].length/20;this.vertexIndices=this.computeVertexIndices(u),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint16Array(6*e);let i=0;for(let r=0;r<e;r++)t[6*r]=i,t[6*r+1]=i+1,t[6*r+2]=i+2,t[6*r+3]=i+2,t[6*r+4]=i+3,t[6*r+5]=i,i+=4;return t}setupPositionAndTexture4Quadrant(e,t,i,r,s,o,a,n){const l=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const h=1/(1<<a);let c=0;for(let l=e;l<t;l++)for(let e=i;e<r;e++){const t=o.xyf2nest(l,e,n.face);this._pixels.push(t);const i=o.getBoundaries(t),r=e-(n.iy<<a),u=l-(n.ix<<a);this.vertexPosition[s][20*c]=i[0].x,this.vertexPosition[s][20*c+1]=i[0].y,this.vertexPosition[s][20*c+2]=i[0].z,this.vertexPosition[s][20*c+3]=h+h*r,this.vertexPosition[s][20*c+4]=1-(h+h*u),this.vertexPosition[s][20*c+5]=i[1].x,this.vertexPosition[s][20*c+6]=i[1].y,this.vertexPosition[s][20*c+7]=i[1].z,this.vertexPosition[s][20*c+8]=h+h*r,this.vertexPosition[s][20*c+9]=1-h*u,this.vertexPosition[s][20*c+10]=i[2].x,this.vertexPosition[s][20*c+11]=i[2].y,this.vertexPosition[s][20*c+12]=i[2].z,this.vertexPosition[s][20*c+13]=h*r,this.vertexPosition[s][20*c+14]=1-h*u,this.vertexPosition[s][20*c+15]=i[3].x,this.vertexPosition[s][20*c+16]=i[3].y,this.vertexPosition[s][20*c+17]=i[3].z,this.vertexPosition[s][20*c+18]=h*r,this.vertexPosition[s][20*c+19]=1-(h+h*u),c++}this.vertexPositionBuffer[s]=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[s]),l.bufferData(l.ARRAY_BUFFER,this.vertexPosition[s],l.STATIC_DRAW)}draw(e,t,i,r,s,o){if(!this._ready)return!1;let a=new Set([0,1,2,3]);if(e>this._order){const n=this.drawChildren(e,t,i,r,s,o);n&&(a=n)}if(this._hipsShaderProgram.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return console.error(`[AncestorTile] No display range available for FITS tile ${this._texurl}`),!1;this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max)}else this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!1);const n=this._webgl;n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture);const l=this._hipsShaderProgram.locations.textureAlpha[this._hipsShaderIndex];l&&n.uniform1f(l,this.opacity),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const h=this.vertexIndices.length;return a.forEach(e=>{n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer[e]),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12),n.drawElements(n.TRIANGLES,h,n.UNSIGNED_SHORT,0)}),n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,o){const a=new Set([0,1,2,3]),n=this._order+1;if(t.has(n)){for(let l=0;l<4;l++){const h=(this._tileno<<2)+l;if(t.get(n).includes(h)){const c=this._isGalacticHips?this._tileBuffer.getGalTile(h,n,this._hips):this._tileBuffer.getTile(h,n,this._hips);c.draw(e,t,i,r,s,o,this._hipsShaderProgram),c.getReadyState()&&a.delete(l)}}return a}}}},1399(e,t,i){"use strict";t.loadFitsTile=async function(e){const t=await r.FITSParser.loadFITSFile(e);if(!t?.primaryHDU)throw new Error(`Unable to load FITS tile: ${e}`);const i=t.primaryHDU;if(2!==i.naxis)throw new Error(`Expected a 2D FITS tile, got NAXIS=${i.naxis}: ${e}`);const[o,a]=i.shape;if(!Number.isInteger(o)||!Number.isInteger(a)||o<=0||a<=0)throw new Error(`Invalid FITS tile dimensions: ${e}`);const n=i.typedData;if(!n||n.length!==o*a)throw new Error(`Invalid FITS tile payload: ${e}`);if(n instanceof BigInt64Array)throw new Error(`BITPIX=64 FITS tiles are not supported for HiPS rendering: ${e}`);const l=s(i.header,r.FITSHeaderManager.BSCALE)??1,h=s(i.header,r.FITSHeaderManager.BZERO)??0,c=s(i.header,r.FITSHeaderManager.BLANK),u=s(i.header,r.FITSHeaderManager.DATAMIN),d=s(i.header,r.FITSHeaderManager.DATAMAX),g=new Float32Array(n.length);for(let e=0;e<n.length;e++){const t=n[e];!Number.isFinite(t)||null!==c&&t===c?g[e]=Number.NaN:g[e]=t*l+h}return{width:o,height:a,pixels:g,dataMin:u,dataMax:d}};const r=i(1677);function s(e,t){const i=e.findById(t);if(!i)return null;const r=Number(i.value);return Number.isFinite(r)?r:null}},229(e,t){"use strict";t.fovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static HIPS_ORDER_MIN_FOV={0:179,1:90,2:30,3:20,4:6,5:3.2,6:1.6,7:.85,8:.42,9:.21,10:.12,11:.06,12:.015,13:0};getHiPSNorder(e,t){const r=this.getRawHiPSNorder(e);if(void 0===t||t===r)return r;if(r>t){const r=i.HIPS_ORDER_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.HIPS_ORDER_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawHiPSNorder(e){return e>=179?0:e>=90?1:e>=30?2:e>=20?3:e>=6?4:e>=3.2?5:e>=1.6?6:e>=.85?7:e>=.42?8:e>=.21?9:e>=.12?10:e>=.06?11:e>=.015?12:13}getRADegSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{raStep:i,decStep:r}}getRefOrder(e){switch(e){case 0:case 1:case 2:case 3:return e+6;case 4:case 5:case 6:case 7:return e+5;case 8:return e+4;default:return e+3}}}t.fovHelper=new i},3726(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPS=void 0;const s=i(4735),o=i(229),a=r(i(619)),n=r(i(2885)),l=r(i(2368));class h extends s.AbstractSkyEntity{_ancestorTiles;_allSkyTile;_descriptor;_format;_baseurl;_maxorder;_minorder;_visibleorder=3;_allSky=!0;samplerIdx=0;colorMapIdx=0;colorMap=a.default.native;_healpixGrid;get maxOrder(){return this._maxorder}get minOrder(){return this._minorder}get baseURL(){return this._baseurl}get format(){return this._format}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}constructor(e,t,i,r,s,a,n){super(e,t,i,r,s.surveyName,a,s.isGalactic),this._descriptor=s,this.initGL(a),this._healpixGrid=n,this._format=this.selectDefaultFormat(s.imgFormats),this._baseurl=s.url,this._maxorder=s.maxOrder,this._minorder=s.minOrder,this.isGalacticHips?this._healpixGrid.visibleTilesManager.tileBuffer.addGalHiPS(this):this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this),console.log("HiPS frame "+s.hipsFrame),console.log("HiPS minOrder "+s.minOrder),this.initShaders();let l=o.fovHelper.getHiPSNorder(180);this._visibleorder=Math.min(l,this._maxorder),this._ancestorTiles=[],this._allSkyTile=null,this._allSky=!0,this.initBaseTiles()}initBaseTiles(){if(this._ancestorTiles=[],this._allSkyTile=null,this._allSky)this._allSkyTile=new l.default(this,this._webgl,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram);else for(let e=0;e<12;e++)this._ancestorTiles.push(new n.default(e,0,this,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram,this._webgl))}getProperty(e){return this._descriptor.getProperty(e)}changeFormat(e){const t=e.toLowerCase();if(!this._descriptor.imgFormats.includes(t))throw new Error(`HiPS format "${e}" is not supported. Available formats: ${this._descriptor.imgFormats.join(", ")}`);if(t===this._format.toLowerCase())return;this._healpixGrid.visibleTilesManager.tileBuffer.invalidateHiPS(this),this._format=t,this.initBaseTiles()}get availableFormats(){return this._descriptor.imgFormats}changeColorMap(e){switch(console.log("HiPS.changeColorMap -> shaderProgram",super.hipsShaderProgram.shaderProgram),this.colorMap=e,e.name){case"grayscale":this.colorMapIdx=1,this.colorMap=a.default.grayscale,super.hipsShaderProgram.setGrayscaleShader();break;case"planck":this.colorMapIdx=2,this.colorMap=a.default.planck,super.hipsShaderProgram.setColorMapShader();break;case"cmb":this.colorMapIdx=3,this.colorMap=a.default.cmb,super.hipsShaderProgram.setColorMapShader();break;case"rainbow":this.colorMapIdx=4,this.colorMap=a.default.rainbow,super.hipsShaderProgram.setColorMapShader();break;case"eosb":this.colorMapIdx=5,this.colorMap=a.default.eosb,super.hipsShaderProgram.setColorMapShader();break;case"cubehelix":this.colorMapIdx=6,this.colorMap=a.default.cubehelix,super.hipsShaderProgram.setColorMapShader();break;case"hot":this.colorMapIdx=7,this.colorMap=a.default.hot,super.hipsShaderProgram.setColorMapShader();break;case"gray":this.colorMapIdx=8,this.colorMap=a.default.gray,super.hipsShaderProgram.setColorMapShader();break;case"native":this.colorMapIdx=0,this.colorMap=a.default.native,super.hipsShaderProgram.setNativeShader();break;default:this.colorMapIdx=9,this.colorMap=e,super.hipsShaderProgram.setColorMapShader()}}initShaders(){super.hipsShaderProgram.enableProgram()}selectDefaultFormat(e){if(e.includes("png"))return"png";if(e.includes("jpg"))return"jpg";if(e.includes("fits"))return"fits";if(e.length>0)return e[0];throw new Error("HiPS descriptor does not define a tile format")}get dataRange(){return this._descriptor.dataRange}getCurrentHealpixOrder(){return this._visibleorder}getDebugStats(){const e=this._healpixGrid.visibleTilesManager.tileBuffer,t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;return{activeBaseLayer:"hips",hipsName:this._descriptor.surveyName,hipsUrl:this._baseurl,isGalactic:this.isGalacticHips,currentOrder:t.order,visibleTileCount:t.pixels.length,activeTileCount:e.activeTileCount,cachedTileCount:e.cachedTileCount,cacheSize:e.size,readyTileCount:e.readyTileCount,loadingTileCount:e.loadingTileCount}}refresh(e){const t=e.fovDeg??this._healpixGrid.getMinFoV(),i=Number.isFinite(t)&&t>0?t:1e-6;this._visibleorder=Math.min(o.fovHelper.getHiPSNorder(i,this._visibleorder),this._maxorder)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();if(super.hipsShaderProgram.setRuntimeColorMap(this.colorMap),this._allSky&&this._allSkyTile)return void(this.isGalacticHips?this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.galAncestorsMap,i,t,r,this.colorMapIdx):this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.ancestorsMap,i,t,r,this.colorMapIdx));const s=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order:this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,o=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galAncestorsMap:this._healpixGrid.visibleTilesManager.ancestorsMap;this._ancestorTiles.forEach(e=>{e.draw(s,o,i,t,r,this.colorMapIdx)})}}t.HiPS=h},5087(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSDescriptor=void 0;t.HiPSDescriptor=class{_minOrder=3;_imgformats=[];_datarange={min:void 0,max:void 0};_maxOrder;_tilewidth;_hipsFrame;_hipsName="NONAME";_hipsurl;_emMin;_emMax;_isGalctic=!1;_propertiesRawText;_propertiesMap=new Map;constructor(e,t){this._hipsurl=t,this._propertiesRawText=e;const i=e.split(/\r\n|\n/);for(const e of i){const t=e.trim();if(!t||t.startsWith("#"))continue;const i=t.slice(0,t.indexOf("=")).trim(),r=this.getValue(t);if(i&&void 0!==r&&this._propertiesMap.set(i,r),t.startsWith("hips_tile_format")||t.startsWith("format")){const e=this.getValue(t)?.replace(/jpeg/gi,"jpg")??"";this._imgformats=e.split(/\s+/).filter(Boolean)}else if(t.startsWith("hips_data_range")){const e=this.getValue(t);if(e){const[t,i]=e.split(/\s+/);this._datarange.min=parseFloat(t),this._datarange.max=parseFloat(i)}}else if(t.startsWith("hips_tile_width")){const e=Number(this.getValue(t));this._tilewidth=Number.isFinite(e)?e:void 0}else if(t.startsWith("hips_order_min")){const e=Number(this.getValue(t));this._minOrder=Number.isFinite(e)?e:this._minOrder}else if(t.startsWith("hips_order")||t.startsWith("maxOrder")){const e=Number(this.getValue(t));this._maxOrder=Number.isFinite(e)?e:this._maxOrder}else if(t.startsWith("hips_frame")||t.startsWith("frame"))this._hipsFrame=this.getValue(t);else if(t.startsWith("obs_collection")||t.startsWith("label"))this._hipsName=this.getValue(t)??this._hipsName;else if(t.startsWith("em_min")){const e=Number(this.getValue(t));this._emMin=Number.isFinite(e)?e:void 0}else if(t.startsWith("em_max")){const e=Number(this.getValue(t));this._emMax=Number.isFinite(e)?e:void 0}}if(this._hipsName||console.warn(`[HiPSDescriptor] hipsName not defined in properties of ${this._hipsurl}. Defaulting to 'NONAME'.`),this._hipsFrame||(console.warn(`[HiPSDescriptor] hips_frame not defined in properties of ${this._hipsurl}. Defaulting to 'equatorial'.`),this._hipsFrame="equatorial"),this._isGalctic=this._hipsFrame.toLowerCase().includes("gal"),void 0===this._maxOrder||0===this._imgformats.length)throw new Error(`[HiPSDescriptor] Invalid properties for ${this._hipsurl}. maxOrder=${this._maxOrder}, imgFormats.length=${this._imgformats.length}`)}getValue(e){const t=e.indexOf("=");if(!(t<0))return e.slice(t+1).trim()}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}getProperty(e){return this._propertiesMap.get(e)}get surveyName(){return this._hipsName}get url(){return this._hipsurl}get maxOrder(){return this._maxOrder}get minOrder(){return this._minOrder}get imgFormats(){return this._imgformats}get hipsFrame(){return this._hipsFrame}get isGalactic(){return this._isGalctic}get emMin(){return this._emMin}get emMax(){return this._emMax}get tileWidth(){return this._tilewidth}get dataRange(){return this._datarange}}},8256(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(229),a=i(1399);t.default=class{_hips;_tileno;_baseurl;_order;_format;_maxorder;_isGalacticHips;_ready=!1;_abort=!1;_image;_textureLoaded=!1;_texture;_texurl="";_hipsShaderIndex=0;_fitsTile;_cacheTime0;_inView=!0;_amIStillInFoV_requsetID;vertexPosition=[];vertexPositionBuffer=[];vertexIndices=new Uint16Array;vertexIndexBuffer;_tileBuffer;opacity=1;_webgl;_visibleTileManager;constructor(e,t,i,r,s,o){this._visibleTileManager=o,this._webgl=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._format=i.format,this._baseurl=i.baseURL,this._maxorder=i.maxOrder,this._isGalacticHips=i.isGalacticHips,this._order=t,this._amIStillInFoV_requsetID=window.setInterval(()=>{this.amIStillInFoV()},5e3),this.initImage()}destroyIntervals(){window.clearInterval(this._amIStillInFoV_requsetID)}getReadyState(){return this._ready}isLoading(){return!this._ready&&!this._abort}get cacheTime0(){return this._cacheTime0}resetCacheTime0(){this._cacheTime0=void 0}setCacheTime0(){this._cacheTime0=(new Date).getTime()}initImage(){if(this._order>this._maxorder)return this._ready=!1,this._abort=!0,this.destroyIntervals(),void console.warn(`[Tile] Skipping tile request above max order: requested order ${this._order}, max order ${this._maxorder}, url ${this._baseurl}`);const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{this._ready=!1,this._abort=!0,this.destroyIntervals()},this._image.crossOrigin="anonymous",this._image.src=this._texurl}async loadFits(){try{this._fitsTile=await(0,a.loadFitsTile)(this._texurl),this._ready=!0}catch(e){console.error(`[Tile] Unable to load FITS tile ${this._texurl}`,e),this._ready=!1,this._abort=!0,this.destroyIntervals()}}imageLoaded(){this._ready=!0}textureLoaded(e){e.enableProgram();const t=this._webgl;if(this._texture=t.createTexture(),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),t.bindTexture(t.TEXTURE_2D,this._texture),"fits"===this._format){const e=this._fitsTile;if(!e)throw new Error(`FITS tile data not loaded: ${this._texurl}`);t.texImage2D(t.TEXTURE_2D,0,t.R32F,e.width,e.height,0,t.RED,t.FLOAT,e.pixels),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)}else t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this._image),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this.initModelBuffer(),this._textureLoaded=!0}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=o.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,a=i.ix<<r,n=(i.ix<<r)+(1<<r),l=i.iy<<r,h=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this.setupPositionAndTexture4Quadrant2(a,a+(n-a)/2,l,l+(h-l)/2,0,c,r,i),this.setupPositionAndTexture4Quadrant2(a+(n-a)/2,n,l,l+(h-l)/2,1,c,r,i),this.setupPositionAndTexture4Quadrant2(a,a+(n-a)/2,l+(h-l)/2,h,2,c,r,i),this.setupPositionAndTexture4Quadrant2(a+(n-a)/2,n,l+(h-l)/2,h,3,c,r,i);const u=this.vertexPosition[0].length/20,d=this.computeVertexIndices(u);d.length>65535?this.vertexIndices=new Uint32Array(d):this.vertexIndices=new Uint16Array(d),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint32Array(6*e);let i=0;for(let r=0;r<e;r++){const e=i;t[6*r]=e,t[6*r+1]=e+1,t[6*r+2]=e+2,t[6*r+3]=e+2,t[6*r+4]=e+3,t[6*r+5]=e,i+=4}return t}setupPositionAndTexture4Quadrant2(e,t,i,r,s,o,a,n){const l=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const h=1/(1<<a);let c=0;for(let l=e;l<t;l++)for(let e=i;e<r;e++){const t=o.getPointsForXyfNoStep(l,e,n.face),i=e-(n.iy<<a),r=l-(n.ix<<a);this.vertexPosition[s][20*c]=t[0].x,this.vertexPosition[s][20*c+1]=t[0].y,this.vertexPosition[s][20*c+2]=t[0].z,this.vertexPosition[s][20*c+3]=h+h*i+0,this.vertexPosition[s][20*c+4]=1-(h+h*r)-0,this.vertexPosition[s][20*c+5]=t[1].x,this.vertexPosition[s][20*c+6]=t[1].y,this.vertexPosition[s][20*c+7]=t[1].z,this.vertexPosition[s][20*c+8]=h+h*i+0,this.vertexPosition[s][20*c+9]=1-h*r+0,this.vertexPosition[s][20*c+10]=t[2].x,this.vertexPosition[s][20*c+11]=t[2].y,this.vertexPosition[s][20*c+12]=t[2].z,this.vertexPosition[s][20*c+13]=h*i-0,this.vertexPosition[s][20*c+14]=1-h*r+0,this.vertexPosition[s][20*c+15]=t[3].x,this.vertexPosition[s][20*c+16]=t[3].y,this.vertexPosition[s][20*c+17]=t[3].z,this.vertexPosition[s][20*c+18]=h*i-0,this.vertexPosition[s][20*c+19]=1-(h+h*r)-0,c++}this.vertexPositionBuffer[s]=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[s]),l.bufferData(l.ARRAY_BUFFER,this.vertexPosition[s],l.STATIC_DRAW)}getFitsDataRange(){const e=this._hips.dataRange;if(void 0!==e.min&&void 0!==e.max&&Number.isFinite(e.min)&&Number.isFinite(e.max)&&e.max>e.min)return{min:e.min,max:e.max};const t=this._fitsTile;return t&&null!==t.dataMin&&null!==t.dataMax&&Number.isFinite(t.dataMin)&&Number.isFinite(t.dataMax)&&t.dataMax>t.dataMin?{min:t.dataMin,max:t.dataMax}:null}get inView(){return this._inView}moveToCache(){this._tileBuffer.moveTileToCache(this._tileno,this._order,this._hips),this._inView=!1,this.destroyIntervals()}amIStillInFoV(){this._textureLoaded&&(this._ready=!0),this._isGalacticHips?(this._visibleTileManager.galAncestorsMap.has(this._order)&&(this._visibleTileManager.galAncestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.galVisibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache())):(this._visibleTileManager.ancestorsMap.has(this._order)&&(this._visibleTileManager.ancestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.visibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache()))}draw(e,t,i,r,s,o,a){if(!this._ready||this._abort)return;this._textureLoaded||this.textureLoaded(a);let n=new Set([0,1,2,3]);if(e>this._order&&this._order<this._maxorder){const l=this.drawChildren(e,t,i,r,s,o,a);l&&(n=l)}const l=this._webgl;if(a.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return void console.error(`[Tile] No display range available for FITS tile ${this._texurl}`);a.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max)}else a.setTextureDataMode(this._hipsShaderIndex,!1);const h=a.locations;l.enableVertexAttribArray(h.vertexPositionAttribute),l.enableVertexAttribArray(h.textureCoordAttribute),l.activeTexture(l.TEXTURE0+this._hipsShaderIndex),l.bindTexture(l.TEXTURE_2D,this._texture);const c=h.textureAlpha[this._hipsShaderIndex];c&&l.uniform1f(c,this.opacity),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const u=this.vertexIndices.length,d=this.vertexIndices instanceof Uint32Array?l.UNSIGNED_INT:l.UNSIGNED_SHORT;n.forEach(e=>{l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[e]),l.vertexAttribPointer(h.vertexPositionAttribute,3,l.FLOAT,!1,20,0),l.vertexAttribPointer(h.textureCoordAttribute,2,l.FLOAT,!1,20,12),l.drawElements(l.TRIANGLES,u,d,0)}),l.disableVertexAttribArray(h.vertexPositionAttribute),l.disableVertexAttribArray(h.textureCoordAttribute)}drawChildren(e,t,i,r,s,o,a){const n=new Set([0,1,2,3]),l=this._order+1;if(t.has(l)){for(let h=0;h<4;h++){const c=(this._tileno<<2)+h;if(t.get(l).includes(c)){const u=this._isGalacticHips?this._tileBuffer.getGalTile(c,l,this._hips):this._tileBuffer.getTile(c,l,this._hips);u.draw(e,t,i,r,s,o,a),u.getReadyState()&&n.delete(h)}}return n}}}},4006(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TileBuffer=void 0;const s=r(i(8256));t.TileBuffer=class{_tiles;_cachedTiles;_activeHiPS;_galTiles;_galCachedTiles;_galActiveHiPS;_cacheAliveMilliSeconds;_cleanerId;_webgl;_visibleTileManager;_hipsShaderProgram;constructor(e=1,t,i,r){this._hipsShaderProgram=i,this._visibleTileManager=r,this._webgl=t,this._tiles=new Map,this._cachedTiles=new Map,this._activeHiPS=new Map,this._galTiles=new Map,this._galCachedTiles=new Map,this._galActiveHiPS=new Map,this._cacheAliveMilliSeconds=60*e*1e3,this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4)}addHiPS(e){this._activeHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._activeHiPS.set(e,new Map)}addGalHiPS(e){this._galActiveHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._galActiveHiPS.set(e,new Map)}addTile(e,t){for(const i of this._activeHiPS.keys())e>i.maxOrder||this.getTile(t,e,i)}addGalTile(e,t){for(const i of this._galActiveHiPS.keys())e>i.maxOrder||this.getGalTile(t,e,i)}getTile(e,t,i){const r=this.key(t,e,i);if(!this._tiles.has(r))if(this._cachedTiles.has(r)){const e=this._cachedTiles.get(r);this._tiles.set(r,e),this._cachedTiles.delete(r),e.resetCacheTime0()}else{const o=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._tiles.set(r,o)}return this._tiles.get(r)}getGalTile(e,t,i){const r=this.key(t,e,i);if(!this._galTiles.has(r))if(this._galCachedTiles.has(r)){const e=this._galCachedTiles.get(r);this._galTiles.set(r,e),this._galCachedTiles.delete(r),e.resetCacheTime0()}else{const o=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._galTiles.set(r,o)}return this._galTiles.get(r)}moveTileToCache(e,t,i){const r=this.key(t,e,i);if(this._tiles.has(r)){const e=this._tiles.get(r);e.setCacheTime0(),this._cachedTiles.set(r,e),this._tiles.delete(r)}if(this._galTiles.has(r)){const e=this._galTiles.get(r);e.setCacheTime0(),this._galCachedTiles.set(r,e),this._galTiles.delete(r)}}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._cachedTiles.delete(t))}for(const[t,i]of this._galCachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._galCachedTiles.delete(t))}}key(e,t,i){return`${e}#${t}#${i.baseURL}#${i.format}`}removeHiPS(e){this.invalidateHiPS(e),this._activeHiPS.delete(e),this._galActiveHiPS.delete(e)}invalidateHiPS(e){const t=t=>t.includes(`#${e.baseURL}#`),i=e=>{for(const[i,r]of e)t(i)&&(r.destroyIntervals(),e.delete(i))};i(this._tiles),i(this._cachedTiles),i(this._galTiles),i(this._galCachedTiles)}dispose(){window.clearInterval(this._cleanerId)}get size(){return this._tiles.size+this._cachedTiles.size+this._galTiles.size+this._galCachedTiles.size}get activeTileCount(){return this._tiles.size+this._galTiles.size}get cachedTileCount(){return this._cachedTiles.size+this._galCachedTiles.size}get readyTileCount(){let e=0;for(const t of this._tiles.values())t.getReadyState()&&e++;for(const t of this._galTiles.values())t.getReadyState()&&e++;for(const t of this._cachedTiles.values())t.getReadyState()&&e++;for(const t of this._galCachedTiles.values())t.getReadyState()&&e++;return e}get loadingTileCount(){let e=0;for(const t of this._tiles.values())t.isLoading()&&e++;for(const t of this._galTiles.values())t.isLoading()&&e++;for(const t of this._cachedTiles.values())t.isLoading()&&e++;for(const t of this._galCachedTiles.values())t.isLoading()&&e++;return e}}},2056(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VisibleTilesManager=void 0;const s=r(i(4382)),o=i(4851),a=r(i(4639)),n=i(4006),l=i(3890),h=i(2919);t.VisibleTilesManager=class{_visibleTilesByOrder;_ancestorsMap;initialised;_galVisibleTilesByOrder;_galAncestorsMap;_galacticMatrixInverted;_galacticMatrix;insideSphere=h.bootSetup.insideSphere;_tileBuffer;_healpixGrid;_webgl;constructor(e,t,i){this._webgl=e,this._healpixGrid=i,this._visibleTilesByOrder={pixels:[],order:0},this._ancestorsMap=new Map,this.initialised=!1,this._galVisibleTilesByOrder={pixels:[],order:0},this._galAncestorsMap=new Map,this._galacticMatrixInverted=l.mat4.create(),this._galacticMatrix=l.mat4.create(),l.mat4.set(this._galacticMatrixInverted,-.054876,-.873437,-.483835,0,.494109,-.44483,.746982,-0,-.867666,-.198076,.455984,0,0,0,0,1),l.mat4.invert(this._galacticMatrix,this._galacticMatrixInverted),this._tileBuffer=new n.TileBuffer(1,e,t,this)}get healpixGrid(){return this._healpixGrid}get tileBuffer(){return this._tileBuffer}init(e){this.initialised=!0,this.insideSphere=e}getVisibleOrder(){return this._healpixGrid.visibleorder}computeVisiblePixels(e,t,i,r){if(!this.initialised)return;s.default.insideSphere&&e<3&&(e=3),this._ancestorsMap.set(e,[]),this._galAncestorsMap.set(e,[]);let n=[],h=[];if(0===e){const t=s.default.getHealpix(0).getNPix();for(let i=0;i<t;i++)n.push(i),this._ancestorsMap.get(e).push(i),h.push(i),this._galAncestorsMap.get(e).push(i)}else{const c=s.default.getHealpix(e),u=t.canvas.width,d=t.canvas.height;for(let t=0;t<=u;t+=u/30)for(let s=0;s<=d;s+=d/30){const u=a.default.getIntersectionPointWithSingleModel(t,s,this._healpixGrid,this._webgl,i,r);if(u.length>0){const t=l.vec4.create();l.vec4.transformMat4(t,[u[0],u[1],u[2],1],this._galacticMatrix);const i=new o.Pointing(new o.Vec3(t[0],t[1],t[2])),r=c.ang2pix(i),s=new o.Pointing(new o.Vec3(u[0],u[1],u[2])),a=c.ang2pix(s);n.includes(a)||(n.push(a),this._ancestorsMap.get(e).push(a),this._tileBuffer.addTile(e,a)),h.includes(r)||(h.push(r),this._galAncestorsMap.get(e).push(r),this._tileBuffer.addGalTile(e,r))}}}this._visibleTilesByOrder={pixels:n,order:e},this._galVisibleTilesByOrder={pixels:h,order:e};for(let t=1;t<e;t++){const i=e-t,r=this._ancestorsMap.get(i)??[];this._ancestorsMap.set(i,r);for(let e=0;e<n.length;e++){const s=n[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addTile(i,s))}}for(let t=1;t<e;t++){const i=e-t,r=this._galAncestorsMap.get(i)??[];this._galAncestorsMap.set(i,r);for(let e=0;e<h.length;e++){const s=h[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addGalTile(i,s))}}}get visibleTilesByOrder(){return this._visibleTilesByOrder}get ancestorsMap(){return this._ancestorsMap}get galVisibleTilesByOrder(){return this._galVisibleTilesByOrder}get galAncestorsMap(){return this._galAncestorsMap}get visibleOrder(){return this._visibleTilesByOrder.order}}},6878(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPS=void 0;const r=i(4735),s=i(229),o=i(2257),a=i(8170);class n extends r.AbstractSkyEntity{_descriptor;_healpixGrid;_shaderProgram;_tiles=new Map;_currentOrder;_visibleTiles=[];_coverageTiles=[];constructor(e,t,i,r,s,a,n){super(e,t,i,r,s.name,a,!1),this._descriptor=s,this._healpixGrid=n,this.initGL(a),this._shaderProgram=new o.MeshHiPSShaderProgram(a),this._shaderProgram.enableProgram(),this._currentOrder=s.selectedOrder}get currentOrder(){return this._currentOrder}get maxOrder(){return this._descriptor.maxOrder}get minOrder(){return this._descriptor.minOrder}get baseURL(){return this._descriptor.baseUrl}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}getProperty(e){return this._descriptor.getProperty(e)}refreshOrder(e){if(this._descriptor.fixedOrder)return this._currentOrder=this._descriptor.selectedOrder,this._currentOrder;const t=Number.isFinite(e)&&e>0?e:this._healpixGrid.getMinFoV(),i=Number.isFinite(t)&&t>0?t:1e-6,r=s.fovHelper.getHiPSNorder(i,this._currentOrder);return this._currentOrder=Math.max(this._descriptor.minOrder,Math.min(this._descriptor.maxOrder,r)),this._currentOrder}draw(e){const t=e.camera.getCameraMatrix();if(!t||!e.pMatrix)return;this.refreshOrder(e.fovDeg),this._visibleTiles=this.resolveVisibleTiles(),this._coverageTiles=this.resolveCoverageTiles(this._visibleTiles),this.ensureTiles(this._coverageTiles),this.evictCached();const i=this._webgl,r=e.pMatrix,s=this.getModelMatrix(),o=i.isEnabled(i.CULL_FACE),a=i.isEnabled(i.DEPTH_TEST),n=i.getParameter(i.DEPTH_WRITEMASK),l=i.getParameter(i.DEPTH_FUNC);i.enable(i.DEPTH_TEST),i.depthMask(!0),i.depthFunc(i.LEQUAL),i.disable(i.CULL_FACE);const h=this.groupTilesByOrder(this._coverageTiles),c=Array.from(h.keys()).sort((e,t)=>e-t);for(const e of c)for(const i of h.get(e)??[])this._tiles.get(this.tileKey(i))?.draw(r,t,s,this._descriptor.color,this._descriptor.wireframe);o&&i.enable(i.CULL_FACE),a||i.disable(i.DEPTH_TEST),i.depthFunc(l),i.depthMask(n)}getDebugStats(){const e=Array.from(this._tiles.values());return{activeBaseLayer:"meships",meshHiPSName:this._descriptor.name,meshHiPSUrl:this._descriptor.baseUrl,currentOrder:this._currentOrder,visibleTileCount:this._visibleTiles.length,coverageTileCount:this._coverageTiles.length,cacheSize:this._tiles.size,readyTileCount:e.filter(e=>e.ready).length,loadingTileCount:e.filter(e=>e.loading).length,failedTileCount:e.filter(e=>e.failed).length}}resolveVisibleTiles(){const e=this._healpixGrid.visibleTilesManager,t=e?.visibleTilesByOrder,i=t?.order===this._currentOrder&&Array.isArray(t.pixels)?t.pixels:[];if(i.length>0)return i.map(e=>({order:this._currentOrder,ipix:e}));const r=12*4**this._currentOrder;return Array.from({length:r},(e,t)=>({order:this._currentOrder,ipix:t}))}resolveCoverageTiles(e){const t=new Map,i=e=>{e.order<this._descriptor.minOrder||e.order>this._descriptor.maxOrder||t.set(this.tileKey(e),e)};for(const t of e){i(t);for(let e=t.order-1;e>=this._descriptor.minOrder;e--){const r=2*(t.order-e);i({order:e,ipix:t.ipix>>r})}}const r=this._healpixGrid.visibleTilesManager,s=r?.ancestorsMap;if(s)for(const[e,t]of s)if(!(e<this._descriptor.minOrder||e>this._descriptor.maxOrder))for(const r of t)i({order:e,ipix:r});return Array.from(t.values())}groupTilesByOrder(e){const t=new Map;for(const i of e){const e=t.get(i.order)??[];e.push(i),t.set(i.order,e)}return t}ensureTiles(e){for(const t of e){const e=this.tileKey(t);this._tiles.has(e)||this._tiles.set(e,new a.MeshHiPSTile(t,this._descriptor.getTileUrl(t.order,t.ipix),this._webgl,this._shaderProgram))}}evictCached(){const e=this._descriptor.maxCachedTiles;if(this._tiles.size<=e)return;const t=new Set(this._coverageTiles.map(e=>this.tileKey(e))),i=Array.from(this._tiles.entries()).filter(([e])=>!t.has(e)).sort((e,t)=>e[1].lastUsedAt-t[1].lastUsedAt);for(;this._tiles.size>e&&i.length>0;){const[e,t]=i.shift();t.dispose(),this._tiles.delete(e)}}tileKey(e){return`${e.order}/${e.ipix}`}}t.MeshHiPS=n},847(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSDescriptor=void 0;t.MeshHiPSDescriptor=class{_name="MeshHiPS";_baseUrl;_minOrder=0;_maxOrder=0;_selectedOrder;_fixedOrder=!1;_maxCachedTiles=384;_color=[.32,.34,.36,1];_wireframe=!1;_propertiesRawText="";_propertiesMap=new Map;_meshRadius=null;constructor(e,t=""){if(this._baseUrl=this.normalizeBaseUrl(e.baseUrl),this._propertiesRawText=t,this.parseProperties(t),this._name=e.name??this._propertiesMap.get("obs_collection")??this._propertiesMap.get("label")??this._name,this._minOrder=e.minOrder??this.readNumber("hips_order_min",this._minOrder),this._maxOrder=e.maxOrder??this.readNumber("hips_order",this.readNumber("hips_order_max",this._maxOrder)),this._fixedOrder=void 0!==e.order,this._selectedOrder=e.order??this._minOrder,this._maxCachedTiles=e.maxCachedTiles??this._maxCachedTiles,e.color)this._color=e.color;else if(this._propertiesMap.has("mesh_color")){const e=(this._propertiesMap.get("mesh_color")||"").split(/[,\s]+/).map(e=>Number(e)).filter(Number.isFinite);if(e.length>=3){let[t,i,r,s]=e;(t>1||i>1||r>1)&&(t/=255,i/=255,r/=255),Number.isFinite(s)||(s=1),this._color=[t,i,r,s]}}else this._color=this._color;if(this._wireframe=e.wireframe??this._wireframe,this._selectedOrder=this.clampOrder(this._selectedOrder),Number.isFinite(e.meshRadius))this._meshRadius=e.meshRadius;else{const e=this.readNumber("mesh_radius",NaN);if(!Number.isFinite(e))throw new Error('Missing mandatory property "mesh_radius" in MeshHiPS properties');this._meshRadius=e}}get name(){return this._name}get baseUrl(){return this._baseUrl}get minOrder(){return this._minOrder}get maxOrder(){return this._maxOrder}get selectedOrder(){return this._selectedOrder}get fixedOrder(){return this._fixedOrder}get maxCachedTiles(){return this._maxCachedTiles}get color(){return this._color}get wireframe(){return this._wireframe}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}get meshRadius(){return this._meshRadius}getProperty(e){return this._propertiesMap.get(e)}getTileUrl(e,t){const i=1e4*Math.floor(t/1e4);return`${this._baseUrl}Norder${e}/Dir${i}/Npix${t}.obj`}parseProperties(e){const t=e.split(/\r\n|\n/);for(const e of t){const t=e.trim();if(!t||t.startsWith("#"))continue;const i=t.indexOf("=");i<0||this._propertiesMap.set(t.slice(0,i).trim(),t.slice(i+1).trim())}}readNumber(e,t){const i=Number(this._propertiesMap.get(e));return Number.isFinite(i)?i:t}clampOrder(e){return Math.max(this._minOrder,Math.min(this._maxOrder,e))}normalizeBaseUrl(e){return e.endsWith("/")?e:`${e}/`}}},8170(e,t,i){"use strict";t.MeshHiPSTile=void 0;const r=i(4322);t.MeshHiPSTile=class{coord;_url;_webgl;_shaderProgram;_gpuMesh=null;_ready=!1;_loading=!1;_failed=!1;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,i,r){this.coord=e,this._url=t,this._webgl=i,this._shaderProgram=r,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}draw(e,t,i,r,s){if(this.touch(),!this._ready||!this._gpuMesh)return!1;const o=this._webgl;return this._shaderProgram.enableShaders(e,t,i,r),o.bindBuffer(o.ARRAY_BUFFER,this._gpuMesh.positionBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(o.bindBuffer(o.ARRAY_BUFFER,this._gpuMesh.normalBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,s?this._gpuMesh.lineIndexBuffer:this._gpuMesh.indexBuffer),o.drawElements(s?o.LINES:o.TRIANGLES,s?this._gpuMesh.lineIndexCount:this._gpuMesh.indexCount,this._gpuMesh.indexType,0),o.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&o.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),!0}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._url);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._url}`);const t=r.OBJMeshParser.parse(await e.text());this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[MeshHiPSTile] load failed",this._url,e),this._failed=!0,this._ready=!1}finally{this._loading=!1}}}uploadMesh(e){const t=this._webgl,i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer(),o=t.createBuffer();if(!(i&&r&&s&&o))throw new Error(`Could not create MeshHiPS buffers for ${this.key}`);const a=this.buildLineIndices(e.indices);return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o),t.bufferData(t.ELEMENT_ARRAY_BUFFER,a,t.STATIC_DRAW),{positionBuffer:i,normalBuffer:r,indexBuffer:s,lineIndexBuffer:o,indexCount:e.indices.length,lineIndexCount:a.length,indexType:t.UNSIGNED_INT}}buildLineIndices(e){const t=new Uint32Array(2*e.length);let i=0;for(let r=0;r<e.length;r+=3){const s=e[r],o=e[r+1],a=e[r+2];t[i++]=s,t[i++]=o,t[i++]=o,t[i++]=a,t[i++]=a,t[i++]=s}return t}get key(){return`${this.coord.order}/${this.coord.ipix}`}}},4322(e,t){"use strict";t.OBJMeshParser=void 0;class i{static parse(e,t={}){const r=t.preferFileNormals??!0,s=t.generatedNormals??"smooth",o=[],a=[],n=[],l=e.split(/\r\n|\n/);for(const e of l){const t=e.trim();if(t&&!t.startsWith("#")){if(t.startsWith("v ")){const e=t.split(/\s+/);if(e.length<4)continue;const i=Number(e[1]),r=Number(e[2]),s=Number(e[3]);if(![i,r,s].every(Number.isFinite))continue;o.push(i,r,s);continue}if(t.startsWith("vn ")){const e=t.split(/\s+/);if(e.length<4)continue;const i=Number(e[1]),r=Number(e[2]),s=Number(e[3]);if(![i,r,s].every(Number.isFinite))continue;const o=Math.hypot(i,r,s)||1;a.push(i/o,r/o,s/o);continue}if(t.startsWith("f ")){const e=t.slice(2).trim().split(/\s+/).map(e=>i.parseFaceToken(e,o.length/3,a.length/3)).filter(e=>null!==e);e.length>=3&&n.push(e)}}}const h=i.triangulateFaces(n);return r&&h.length>0&&h.every(e=>void 0!==e.normalIndex)?i.buildMeshWithFileNormals(o,a,h):"flat"===s?i.buildMeshWithFlatNormals(o,h):i.buildMeshWithSmoothNormals(o,h)}static parseFaceToken(e,t,r){const s=e.split("/"),o=i.parseIndex(s[0],t);if(null===o)return null;const a=s.length>=3?s[2]:void 0;return{positionIndex:o,normalIndex:(a?i.parseIndex(a,r):null)??void 0}}static parseIndex(e,t){if(!e)return null;const i=Number(e);if(!Number.isInteger(i)||0===i)return null;const r=i>0?i-1:t+i;return r>=0&&r<t?r:null}static triangulateFaces(e){const t=[];for(const i of e){const e=i[0];for(let r=1;r<i.length-1;r++)t.push(e,i[r],i[r+1])}return t}static buildMeshWithFileNormals(e,t,i){const r=[],s=[],o=[],a=new Map;for(const n of i){const i=n.normalIndex,l=`${n.positionIndex}/${i}`;let h=a.get(l);void 0===h&&(h=r.length/3,a.set(l,h),r.push(e[3*n.positionIndex],e[3*n.positionIndex+1],e[3*n.positionIndex+2]),s.push(t[3*i],t[3*i+1],t[3*i+2])),o.push(h)}return{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static buildMeshWithSmoothNormals(e,t){const r=[...e],s=new Array(r.length).fill(0),o=t.map(e=>e.positionIndex);return i.computeVertexNormals(r,o,s),{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static buildMeshWithFlatNormals(e,t){const r=[],s=[],o=[];for(let a=0;a<t.length;a+=3){const n=t[a],l=t[a+1],h=t[a+2];if(!n||!l||!h)continue;const c=i.computeFaceNormal(e,n.positionIndex,l.positionIndex,h.positionIndex);for(const t of[n,l,h])r.push(e[3*t.positionIndex],e[3*t.positionIndex+1],e[3*t.positionIndex+2]),s.push(c[0],c[1],c[2]),o.push(o.length)}return{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static computeVertexNormals(e,t,r){for(let s=0;s<t.length;s+=3){const o=t[s],a=t[s+1],n=t[s+2],l=i.computeRawFaceNormal(e,o,a,n);r[3*o]+=l[0],r[3*o+1]+=l[1],r[3*o+2]+=l[2],r[3*a]+=l[0],r[3*a+1]+=l[1],r[3*a+2]+=l[2],r[3*n]+=l[0],r[3*n+1]+=l[1],r[3*n+2]+=l[2]}for(let e=0;e<r.length;e+=3){const t=r[e],i=r[e+1],s=r[e+2],o=Math.hypot(t,i,s)||1;r[e]=t/o,r[e+1]=i/o,r[e+2]=s/o}}static computeFaceNormal(e,t,r,s){const[o,a,n]=i.computeRawFaceNormal(e,t,r,s),l=Math.hypot(o,a,n)||1;return[o/l,a/l,n/l]}static computeRawFaceNormal(e,t,i,r){const s=e[3*t],o=e[3*t+1],a=e[3*t+2],n=e[3*i]-s,l=e[3*i+1]-o,h=e[3*i+2]-a,c=e[3*r]-s,u=e[3*r+1]-o,d=e[3*r+2]-a;return[l*d-h*u,h*c-n*d,n*u-l*c]}}t.OBJMeshParser=i},8022(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackTimeline=void 0,t.createObservationTrackTimeline=function(e){return new i(e)},t.footprintToRing=s;class i{samples;startMs;endMs;currentMs;playing=!1;rafId=null;lastFrameNowMs=null;playbackRate;onFrame;onStop;constructor(e){if(this.samples=e.samples.map((e,t)=>({...e,index:t,timeMs:Date.parse(String(e.timestamp))})).filter(e=>Number.isFinite(e.timeMs)).sort((e,t)=>e.timeMs-t.timeMs),0===this.samples.length)throw new Error("ObservationTrackTimeline requires at least one timestamped sample.");this.startMs=this.samples[0].timeMs,this.endMs=this.samples[this.samples.length-1].timeMs,this.currentMs=this.startMs,this.playbackRate=e.playbackRate??1,this.onFrame=e.onFrame,this.onStop=e.onStop,this.emitFrame()}play(){this.playing||(this.playing=!0,this.lastFrameNowMs=null,this.rafId=requestAnimationFrame(e=>this.tick(e)))}pause(){this.playing&&(this.playing=!1,this.cancelPendingFrame(),this.onStop?.(this.getState()))}seek(e){const t=c(e);this.currentMs=this.startMs+(this.endMs-this.startMs)*t,this.emitFrame()}destroy(){this.playing=!1,this.cancelPendingFrame(),this.onStop?.(this.getState())}getState(){return{startMs:this.startMs,endMs:this.endMs,currentMs:this.currentMs,progress01:this.getProgress(),playing:this.playing}}tick(e){if(!this.playing)return;null===this.lastFrameNowMs&&(this.lastFrameNowMs=e);const t=e-this.lastFrameNowMs;if(this.lastFrameNowMs=e,this.currentMs+=t*this.playbackRate,this.currentMs>=this.endMs)return this.currentMs=this.endMs,this.emitFrame(),void this.pause();this.emitFrame(),this.rafId=requestAnimationFrame(e=>this.tick(e))}emitFrame(){const e=function(e,t){const i=e[0],s=e[e.length-1];if(t<=i.timeMs)return r(i,i,0);if(t>=s.timeMs)return r(s,s,0);for(let i=0;i<e.length-1;i++){const s=e[i],o=e[i+1];if(t>=s.timeMs&&t<=o.timeMs){return r(s,o,(t-s.timeMs)/(o.timeMs-s.timeMs))}}return r(s,s,0)}(this.samples,this.currentMs);this.onFrame?.({currentMs:this.currentMs,progress01:this.getProgress(),...e})}getProgress(){return this.endMs===this.startMs?0:c((this.currentMs-this.startMs)/(this.endMs-this.startMs))}cancelPendingFrame(){null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}function r(e,t,i){const r=function(e,t,i){const r=e.groundTrackPoint,s=t.groundTrackPoint,o=h(e.timeMs,t.timeMs,i);return{timestamp:new Date(o).toISOString(),longitudeDeg:n(r.longitudeDeg,s.longitudeDeg,i),latitudeDeg:h(r.latitudeDeg,s.latitudeDeg,i),altitudeKm:h(r.altitudeKm,s.altitudeKm,i)}}(e,t,i),l=i<.5?e:t,c=function(e,t,i,r){const l=o(s(e)),c=o(s(t));if(l.length<3||l.length!==c.length)return r;const u=l.map(([e,t],r)=>{const[s,o]=c[r];return[n(e,s,i),h(t,o,i)]});return function(e){if(0===e.length)return e;const t=e[0],i=e[e.length-1];return a(t,i)?e:[...e,[...t]]}(u)}(e.footprint,t.footprint,i,s(l.footprint));return{markerPoint:r,currentGroundPoint:r,currentFootprint:c,interpolationT:i,previousSample:e,nextSample:t,nearestSample:l,nearestSampleIndex:l.index}}function s(e){if(function(e){return!Array.isArray(e)&&"coordinates"in e}(e))return e.coordinates.map(e=>[e.longitudeDeg,e.latitudeDeg]);if(function(e){return!Array.isArray(e)&&"polygons"in e}(e)){const t=e.polygons[0];return t?s(t):[]}return Array.isArray(e)?e:[]}function o(e){if(!Array.isArray(e))return[];const t=[];for(const i of e){if(!Array.isArray(i)||i.length<2)return[];const e=Number(i[0]),r=Number(i[1]);if(!Number.isFinite(e)||!Number.isFinite(r)||r<-90||r>90)return[];t.push([l(e),r])}for(;t.length>1&&a(t[0],t[t.length-1]);)t.pop();return t}function a(e,t){return Math.abs(e[0]-t[0])<1e-9&&Math.abs(e[1]-t[1])<1e-9}function n(e,t,i){const r=l(t-e);return l(e+r*i)}function l(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}function h(e,t,i){return e+(t-e)*i}function c(e){return Math.max(0,Math.min(1,Number.isFinite(e)?e:0))}t.ObservationTrackTimeline=i},5772(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackViewerAdapter=void 0;const s=r(i(8755)),o=i(1072),a=i(5403),n=i(8022),l={showSatelliteModel:!0,showGroundTrack:!0,showFootprint:!0,showSensorCone:!0,showCurrentFootprintOnly:!1,showAllFootprints:!0},h={groundTrack:"#ffe066",footprints:"#00fff2",currentFootprint:"#ff4d4d",marker:"#ff4d4d",satelliteObject:[1,.84,.22,1],sensorCone:[0,1,.95,.68],target:"#ffb347"};t.ObservationTrackViewerAdapter=class{activeHandle=null;viewer;metadataManagerFactory;colors;onFrame;constructor(e){this.viewer=e.viewer,this.metadataManagerFactory=e.metadataManagerFactory??(()=>new a.MetadataManager([])),this.colors={...h,...e.colors},this.onFrame=e.onFrame}load(e){this.clear();const t=new c(this.viewer,e,this.metadataManagerFactory,this.colors,this.onFrame);return this.activeHandle=t,t}clear(){this.activeHandle?.dispose(),this.activeHandle=null}};class c{viewer;track;metadataManagerFactory;colors;onFrame;timeline;objects={target:null,groundTrack:null,footprints:null,currentFootprint:null,marker:null,satelliteObject:null,sensorCone:null};visualisation;currentFootprintIndex=-1;disposed=!1;constructor(e,t,i,r,s){this.viewer=e,this.track=t,this.metadataManagerFactory=i,this.colors=r,this.onFrame=s,function(e){if(!e.samples||0===e.samples.length)throw new Error("ObservationTrackViewerAdapter requires at least one sample.")}(t),this.visualisation={...l,...t.visualisation},this.createStaticObjects(),this.timeline=(0,n.createObservationTrackTimeline)({samples:t.samples,playbackRate:1,onFrame:e=>this.updateFrame(e)}),this.applyVisualisation()}play(){this.timeline.play()}pause(){this.timeline.pause()}seek(e){this.timeline.seek(e)}setVisualisation(e){this.visualisation={...this.visualisation,...e},this.applyVisualisation()}dispose(){this.disposed||(this.disposed=!0,this.timeline.destroy(),this.deleteObjects())}createStaticObjects(){this.objects.target=this.createTargetOverlay(),this.objects.footprints=this.createAllFootprintsOverlay(),this.objects.groundTrack=this.createGroundTrackOverlay(),this.objects.marker=this.createMarkerOverlay(),this.objects.satelliteObject=this.createSatelliteObject(),this.objects.sensorCone=this.createSensorCone()}createTargetOverlay(){const e=this.track.target?.geojson;if(!e)return null;const t=this.viewer.createTerraFootprintSet(this.track.target?.name??"Observation target","ObservationTrack target GeoJSON",this.track.target?.geojsonUrl??"ObservationTrack",this.metadataManagerFactory());return t.addGeoJSONFeatures(s.default.parseGeoJSON(e)),this.viewer.changeFootprintSetColor(t,this.colors.target),this.viewer.showTerraFootprintSet(t),t}createAllFootprintsOverlay(){const e={type:"FeatureCollection",features:this.track.samples.map((e,t)=>u(e,t))},t=this.viewer.createTerraFootprintSet(`${this.track.satellite?.name??"Satellite"} footprints`,"ObservationTrack sampled sensor footprints",this.track.id??"ObservationTrack",this.metadataManagerFactory());return t.addGeoJSONFeatures(s.default.parseGeoJSON(e)),this.viewer.changeFootprintSetColor(t,this.colors.footprints),this.viewer.showTerraFootprintSet(t),t}createGroundTrackOverlay(){const e=this.viewer.createTerraPolylineSet(`${this.track.satellite?.name??"Satellite"} ground track`,"ObservationTrack GroundTrackPoint[]",this.track.id??"ObservationTrack",this.metadataManagerFactory());return e.addGroundTrack(this.track.samples.map(e=>({...e.groundTrackPoint,timestamp:e.timestamp})),{name:`${this.track.satellite?.name??"Satellite"} ground track`}),this.viewer.changeTerraPolylineSetColor(e,this.colors.groundTrack),this.viewer.showTerraPolylineSet(e),e}createMarkerOverlay(){const e=this.viewer.createTerraPointSet(`${this.track.satellite?.name??"Satellite"} marker`,"ObservationTrack interpolated satellite marker",this.track.id??"ObservationTrack",new a.MetadataManager(_()));return this.viewer.changeCatalogueColor(e,this.colors.marker),this.viewer.showTerraPointSet(e),e}createSatelliteObject(){const e=this.track.satellite?.model?.objUrl;if(!e)return null;const t=this.viewer.createSatelliteObject({name:`${this.track.satellite?.name??"Satellite"} object`,objUrl:e,color:this.colors.satelliteObject,scale:this.track.satellite?.model?.visualScale});return this.viewer.showSatelliteObject(t),t}createSensorCone(){const e=this.viewer.createSensorCone({name:`${this.track.sensor?.name??"Sensor"} cone`,color:this.colors.sensorCone,wireframe:!0,filled:!1});return this.viewer.showSensorCone(e),e}updateFrame(e){this.disposed||(this.updateMarker(e.currentGroundPoint),this.updateSatelliteObject(e),this.updateSensorCone(e),this.updateCurrentFootprint(e),this.onFrame?.(e))}updateMarker(e){const t=this.objects.marker;t&&(t.clearSources(),t.addSources([[e.longitudeDeg,e.latitudeDeg,String(e.timestamp??""),e.altitudeKm]],_()))}updateSatelliteObject(e){const t=this.objects.satelliteObject;t&&t.setPosition(e.currentGroundPoint,e.previousSample?.groundTrackPoint??null,e.nextSample?.groundTrackPoint??null)}updateSensorCone(e){const t=this.objects.sensorCone;t&&t.setGeometry(e.currentGroundPoint,e.currentFootprint)}updateCurrentFootprint(e){e.nearestSampleIndex!==this.currentFootprintIndex&&(this.objects.currentFootprint&&this.viewer.deleteTerraFootprintSet(this.objects.currentFootprint),this.objects.currentFootprint=this.createCurrentFootprintOverlay(e.nearestSample),this.currentFootprintIndex=e.nearestSampleIndex,this.applyVisualisation())}createCurrentFootprintOverlay(e){const t={type:"FeatureCollection",features:[u(e,e.index,"Current footprint")]},i=this.viewer.createTerraFootprintSet(`${this.track.satellite?.name??"Satellite"} current footprint`,"ObservationTrack nearest sampled footprint",this.track.id??"ObservationTrack",this.metadataManagerFactory());return i.addGeoJSONFeatures(s.default.parseGeoJSON(t)),this.viewer.changeFootprintSetColor(i,this.colors.currentFootprint),this.viewer.showTerraFootprintSet(i),i}applyVisualisation(){const e=Boolean(this.visualisation.showFootprint),t=e&&Boolean(this.visualisation.showAllFootprints)&&!this.visualisation.showCurrentFootprintOnly,i=e&&(Boolean(this.visualisation.showCurrentFootprintOnly)||!t);this.objects.target&&this.viewer.hideTerraFootprintSet(this.objects.target,!0),this.objects.groundTrack&&this.viewer.hideTerraPolylineSet(this.objects.groundTrack,Boolean(this.visualisation.showGroundTrack)),this.objects.footprints&&this.viewer.hideTerraFootprintSet(this.objects.footprints,t),this.objects.currentFootprint&&this.viewer.hideTerraFootprintSet(this.objects.currentFootprint,i),this.objects.marker&&this.viewer.hideTerraPointSet(this.objects.marker,!0),this.objects.satelliteObject&&this.viewer.hideSatelliteObject(this.objects.satelliteObject,Boolean(this.visualisation.showSatelliteModel)),this.objects.sensorCone&&this.viewer.hideSensorCone(this.objects.sensorCone,Boolean(this.visualisation.showSensorCone))}deleteObjects(){this.objects.target&&this.viewer.deleteTerraFootprintSet(this.objects.target),this.objects.groundTrack&&this.viewer.deleteTerraPolylineSet(this.objects.groundTrack),this.objects.footprints&&this.viewer.deleteTerraFootprintSet(this.objects.footprints),this.objects.currentFootprint&&this.viewer.deleteTerraFootprintSet(this.objects.currentFootprint),this.objects.marker&&this.viewer.deleteTerraPointSet(this.objects.marker),this.objects.satelliteObject&&this.viewer.deleteSatelliteObject(this.objects.satelliteObject),this.objects.sensorCone&&this.viewer.deleteSensorCone(this.objects.sensorCone),this.objects.target=null,this.objects.groundTrack=null,this.objects.footprints=null,this.objects.currentFootprint=null,this.objects.marker=null,this.objects.satelliteObject=null,this.objects.sensorCone=null}}function u(e,t,i=`Footprint ${t+1}`){return{type:"Feature",properties:{name:i,timestamp:String(e.timestamp),intersectsTarget:String(Boolean(e.intersectsTarget??e.intersects))},geometry:d(e.footprint)}}function d(e){return!Array.isArray(e)&&"polygons"in e?{type:"MultiPolygon",coordinates:e.polygons.map(e=>[g((0,n.footprintToRing)(e))])}:{type:"Polygon",coordinates:[g((0,n.footprintToRing)(e))]}}function g(e){if(0===e.length)return e;const t=e[0],i=e[e.length-1];return Math.abs(t[0]-i[0])<1e-9&&Math.abs(t[1]-i[1])<1e-9?e:[...e,[t[0],t[1]]]}function _(){return[new o.MetadataColumn({index:0,name:"longitudeDeg",columnType:o.ColumnType.GEOM_RA,unit:"deg"}),new o.MetadataColumn({index:1,name:"latitudeDeg",columnType:o.ColumnType.GEOM_DEC,unit:"deg"}),new o.MetadataColumn({index:2,name:"timestamp",columnType:o.ColumnType.MAIN_NAME,unit:""}),new o.MetadataColumn({index:3,name:"altitudeKm",columnType:o.ColumnType.NUMBER,unit:"km"})]}},5866(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackViewerAdapter=t.ObservationTrackTimeline=t.footprintToRing=t.createObservationTrackTimeline=void 0;var r=i(8022);Object.defineProperty(t,"createObservationTrackTimeline",{enumerable:!0,get:function(){return r.createObservationTrackTimeline}}),Object.defineProperty(t,"footprintToRing",{enumerable:!0,get:function(){return r.footprintToRing}}),Object.defineProperty(t,"ObservationTrackTimeline",{enumerable:!0,get:function(){return r.ObservationTrackTimeline}});var s=i(5772);Object.defineProperty(t,"ObservationTrackViewerAdapter",{enumerable:!0,get:function(){return s.ObservationTrackViewerAdapter}})},3603(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SatelliteObjectGL=void 0;const r=i(3890),s=i(2257),o=i(4322),a=i(6553),n=i(8145);class l{_options;_webgl;static EARTH_RADIUS_KM=6371;_kind="SatelliteObjectGL";_gpuMesh=null;_shaderProgram;_modelMatrix=r.mat4.create();_isVisible=!0;_ready=!1;_loading=!1;_failed=!1;_color;_scale;constructor(e,t){this._options=e,this._webgl=t,this._shaderProgram=new s.MeshHiPSShaderProgram(this._webgl,{twoSidedLighting:!0,markerLighting:!0}),this._color=e.color??[1,.85,.25,1],this._scale=e.scale??.025,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._options.objUrl);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._options.objUrl}`);const t=o.OBJMeshParser.parse(await e.text(),{preferFileNormals:!0,generatedNormals:"flat"});this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[SatelliteObjectGL] load failed",this._options.objUrl,e),this._ready=!1,this._failed=!0}finally{this._loading=!1}}}setIsVisible(e){this._isVisible=e}setColor(e){this._color=e}setScale(e){Number.isFinite(e)&&e>0&&(this._scale=e)}setPosition(e,t,i){if(!c(e))return;const s=h(e),o=r.vec3.normalize(r.vec3.create(),s),a=this.computeForward(e,s,o,t,i),n=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),a,o));if(r.vec3.length(n)<1e-6)return void this.setFallbackMatrix(s,o);const l=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),o,n));this.setMatrixFromBasis(s,n,l,o)}draw(e,t,i){if(!this._isVisible||!this._ready||!this._gpuMesh)return;const s=this._webgl,o=r.mat4.multiply(r.mat4.create(),i,this._modelMatrix);this._shaderProgram.enableShaders(e,t,o,this._color),s.bindBuffer(s.ARRAY_BUFFER,this._gpuMesh.positionBuffer),s.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(s.bindBuffer(s.ARRAY_BUFFER,this._gpuMesh.normalBuffer),s.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this._gpuMesh.indexBuffer),s.drawElements(s.TRIANGLES,this._gpuMesh.indexCount,this._gpuMesh.indexType,0),s.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&s.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),s.bindBuffer(s.ARRAY_BUFFER,null),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,null)}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}computeForward(e,t,i,s,o){const a=s&&c(s)?h(s):null,n=o&&c(o)?h(o):null;let l=r.vec3.create();if(a&&n)r.vec3.subtract(l,n,a);else if(n)r.vec3.subtract(l,n,t);else{if(!a)return this.localEastFallback(e,i);r.vec3.subtract(l,t,a)}const u=r.vec3.scale(r.vec3.create(),i,r.vec3.dot(l,i));return r.vec3.subtract(l,l,u),r.vec3.length(l)<1e-6?this.localEastFallback(e,i):r.vec3.normalize(l,l)}localEastFallback(e,t){const i=h({...e,longitudeDeg:e.longitudeDeg+.01}),s=r.vec3.subtract(r.vec3.create(),i,h(e)),o=r.vec3.scale(r.vec3.create(),t,r.vec3.dot(s,t));return r.vec3.subtract(s,s,o),r.vec3.normalize(s,s)}setFallbackMatrix(e,t){const i=Math.abs(t[2])>.9?r.vec3.fromValues(1,0,0):r.vec3.fromValues(0,0,1),s=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),i,t)),o=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),t,s));this.setMatrixFromBasis(e,s,o,t)}setMatrixFromBasis(e,t,i,s){const o=this._scale;this._modelMatrix=r.mat4.fromValues(t[0]*o,t[1]*o,t[2]*o,0,i[0]*o,i[1]*o,i[2]*o,0,s[0]*o,s[1]*o,s[2]*o,0,e[0],e[1],e[2],1)}uploadMesh(e){const t=this._webgl,i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer();if(!i||!r||!s)throw new Error(`Could not create SatelliteObjectGL buffers for ${this._options.name}`);return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:i,normalBuffer:r,indexBuffer:s,lineIndexBuffer:null,indexCount:e.indices.length,lineIndexCount:0,indexType:t.UNSIGNED_INT}}}function h(e){const t=new a.Point({lonDeg:u(e.longitudeDeg),latDeg:e.latitudeDeg},n.CoordsType.GEOGRAPHIC),i=1+Math.max(0,e.altitudeKm??0)/l.EARTH_RADIUS_KM;return r.vec3.fromValues(t.x*i,t.y*i,t.z*i)}function c(e){return Number.isFinite(e.longitudeDeg)&&Number.isFinite(e.latitudeDeg)&&e.latitudeDeg>=-90&&e.latitudeDeg<=90}function u(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.SatelliteObjectGL=l},3102(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SensorConeGL=void 0;const r=i(8909),s=i(8145),o=i(6553);class a{_options;_webgl;static EARTH_RADIUS_KM=6371;static ELEM_SIZE=3;_kind="SensorConeGL";_lineBuffer=null;_lineVertexCount=0;_isVisible=!0;_shaderProgram;_color;constructor(e,t){this._options=e,this._webgl=t,this._shaderProgram=new r.FootprintShaderProgram(this._webgl),this._color=e.color??[0,1,.95,.68]}setGeometry(e,t){if(!h((i=e).longitudeDeg,i.latitudeDeg)||void 0!==i.altitudeKm&&!Number.isFinite(i.altitudeKm))return void this.clear();var i;const r=function(e){const t=[];for(const i of e){if(!Array.isArray(i)||i.length<2)return[];const e=Number(i[0]),r=Number(i[1]);if(!h(e,r))return[];t.push([u(e),r])}for(;t.length>1&&c(t[0],t[t.length-1]);)t.pop();const i=new Set(t.map(([e,t])=>`${e.toFixed(9)},${t.toFixed(9)}`));return i.size>=3?t:[]}(t);if(r.length<3||function(e){for(let t=0;t<e.length;t++){const i=e[t],r=e[(t+1)%e.length];if(Math.abs(u(r[0])-u(i[0]))>180)return!0}return!1}(r))return void this.clear();const s=n(e),o=r.map(([e,t])=>n({longitudeDeg:e,latitudeDeg:t,altitudeKm:0})),a=this.buildLineVertices(s,o);this.uploadLineVertices(a)}setIsVisible(e){this._isVisible=e}setColor(e){this._color=e}clear(){this._lineVertexCount=0,this._lineBuffer&&(this._webgl.deleteBuffer(this._lineBuffer),this._lineBuffer=null)}draw(e,t,i){if(!this._isVisible)return;if(!this._lineBuffer||0===this._lineVertexCount)return;const r=this._webgl,s=r.isEnabled(r.BLEND),o=r.isEnabled(r.DEPTH_TEST),n=r.isEnabled(r.CULL_FACE),l=r.getParameter(r.DEPTH_WRITEMASK),h=r.getParameter(r.DEPTH_FUNC),c=r.getParameter(r.BLEND_SRC_RGB),u=r.getParameter(r.BLEND_DST_RGB),d=r.getParameter(r.BLEND_SRC_ALPHA),g=r.getParameter(r.BLEND_DST_ALPHA);r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.enable(r.DEPTH_TEST),r.depthMask(!1),r.disable(r.CULL_FACE),this._shaderProgram.enableShaders(e,i,t),r.uniform4f(this._shaderProgram.locations.color,this._color[0],this._color[1],this._color[2],this._color[3]),r.bindBuffer(r.ARRAY_BUFFER,this._lineBuffer),r.vertexAttribPointer(this._shaderProgram.locations.position,a.ELEM_SIZE,r.FLOAT,!1,0,0),r.enableVertexAttribArray(this._shaderProgram.locations.position),r.drawArrays(r.LINES,0,this._lineVertexCount),r.disableVertexAttribArray(this._shaderProgram.locations.position),r.bindBuffer(r.ARRAY_BUFFER,null),r.depthMask(l),r.depthFunc(h),r.blendFuncSeparate(c,u,d,g),n?r.enable(r.CULL_FACE):r.disable(r.CULL_FACE),o?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),s?r.enable(r.BLEND):r.disable(r.BLEND)}dispose(){this.clear()}buildLineVertices(e,t){const i=4*t.length,r=new Float32Array(i*a.ELEM_SIZE);let s=0;for(const i of t)s=l(r,s,e),s=l(r,s,i);for(let e=0;e<t.length;e++){const i=t[e],o=t[(e+1)%t.length];s=l(r,s,i),s=l(r,s,o)}return r}uploadLineVertices(e){if(this._lineBuffer||(this._lineBuffer=this._webgl.createBuffer()),!this._lineBuffer)throw new Error(`Could not create SensorConeGL line buffer for ${this._options.name}`);this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this._lineBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,e,this._webgl.DYNAMIC_DRAW),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._lineVertexCount=e.length/a.ELEM_SIZE}}function n(e){const t=new o.Point({lonDeg:u(e.longitudeDeg),latDeg:e.latitudeDeg},s.CoordsType.GEOGRAPHIC),i=1+Math.max(0,e.altitudeKm??0)/a.EARTH_RADIUS_KM;return[t.x*i,t.y*i,t.z*i]}function l(e,t,i){return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],t+a.ELEM_SIZE}function h(e,t){return Number.isFinite(e)&&Number.isFinite(t)&&t>=-90&&t<=90}function c(e,t){return Math.abs(e[0]-t[0])<1e-9&&Math.abs(e[1]-t[1])<1e-9}function u(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.SensorConeGL=a},9022(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraFootprintSetGL=void 0;const r=i(592),s=i(8145),o=i(2475),a=i(1072),n=i(5403),l=i(1072);class h extends r.FootprintSetGL{_kind="TerraFootprintSetGL";_coordsType=s.CoordsType.GEOGRAPHIC;addGeoJSONFeatures(e){this._ready=!1,this.clearFootprints(),this._metadataManager=new n.MetadataManager(this.createGeoJSONMetadataColumns(e));for(const t of e){const e=o.Footprint.fromPolygons(t.polygons,this.createGeoJSONDetails(t),s.CoordsType.GEOGRAPHIC);e.valid&&(this.addFootprint(e),this.totPoints+=e.totPoints,this.totConvexPoints+=e.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}createGeoJSONMetadataColumns(e){const t=new Set;return e.forEach(e=>Object.keys(e.properties).forEach(e=>t.add(e))),Array.from(t).map((t,i)=>{const r=e.map(e=>e.properties[t]).filter(e=>null!=e&&""!==e),s=r.length>0&&r.every(e=>"number"==typeof e||!Number.isNaN(Number(e))),o=/^name$|nome|denominazione|label|title/i.test(t);return new a.MetadataColumn({index:i,name:t,columnType:o?l.ColumnType.MAIN_NAME:s?l.ColumnType.NUMBER:l.ColumnType.STRING,unit:""})})}createGeoJSONDetails(e){return Object.entries(e.properties).map(([e,t])=>({key:e,value:"number"==typeof t?t:String(t??"")}))}}t.TerraFootprintSetGL=h},5781(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPointSetGL=void 0;const r=i(1232);class s extends r.CatalogueGL{_kind="TerraPointSetGL"}t.TerraPointSetGL=s},3665(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPolylineSetGL=void 0;const r=i(8909),s=i(8145),o=i(7930),a=i(6553);class n{_name;_description;_providerUrl;_metadataManager;_webgl;_visibleTilesManager;static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_kind="TerraPolylineSetGL";_isVisible=!0;_ready=!0;_shapeColor="#ffe066";_bufferInitialised=!1;paths=[];renderSegments=[];_polylineShaderProgram;constructor(e,t,i,s,o,a){this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=s,this._webgl=o,this._visibleTilesManager=a,this._polylineShaderProgram=new r.FootprintShaderProgram(this._webgl)}addPath(e,t){this.paths.push({points:[...e],metadata:t}),this._ready=!0,this._bufferInitialised=!1}addGroundTrack(e,t){this.addPath(e,t)}clearPaths(){this.paths=[],this.disposeBuffers(),this.renderSegments=[],this._bufferInitialised=!1}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}changeColor(e){this._shapeColor=e}dispose(){this.disposeBuffers(),this.renderSegments=[],this.paths=[],this._bufferInitialised=!1}draw(e,t,i,r){if(!this._isVisible)return;if(!this._ready)return;if(!i)return;if(!this._webgl)return;if(this._bufferInitialised||this.initBuffers(),0===this.renderSegments.length)return;this._polylineShaderProgram.enableShaders(r,e,i);const s=(0,o.colorHex2RGB)(this._shapeColor);this._webgl.uniform4f(this._polylineShaderProgram.locations.color,s[0],s[1],s[2],1);for(const e of this.renderSegments)!e.buffer||e.vertices.length<2*n.ELEM_SIZE||(this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,e.buffer),this._webgl.vertexAttribPointer(this._polylineShaderProgram.locations.position,n.ELEM_SIZE,this._webgl.FLOAT,!1,n.BYTES_X_ELEM*n.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._polylineShaderProgram.locations.position),this._webgl.drawArrays(this._webgl.LINE_STRIP,0,e.vertices.length/n.ELEM_SIZE));this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null)}initBuffers(){this.disposeBuffers(),this.renderSegments=this.buildRenderSegments();for(const e of this.renderSegments){const t=this._webgl.createBuffer();e.buffer=t,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,t),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,e.vertices,this._webgl.STATIC_DRAW)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._bufferInitialised=!0}buildRenderSegments(){const e=[];for(const t of this.paths)for(const i of this.splitPath(t.points)){if(i.length<2)continue;const t=new Float32Array(i.length*n.ELEM_SIZE);let r=0;for(const e of i){const i=new a.Point({lonDeg:c(e.longitudeDeg),latDeg:e.latitudeDeg},s.CoordsType.GEOGRAPHIC);t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z,r+=n.ELEM_SIZE}e.push({vertices:t,buffer:null})}return e}splitPath(e){const t=[];let i=[],r=null;for(const s of e)l(s)?(r&&h(r.longitudeDeg,s.longitudeDeg)&&(i.length>1&&t.push(i),i=[]),i.push(s),r=s):(i.length>1&&t.push(i),i=[],r=null);return i.length>1&&t.push(i),t}disposeBuffers(){for(const e of this.renderSegments)e.buffer&&(this._webgl.deleteBuffer(e.buffer),e.buffer=null)}}function l(e){return Number.isFinite(e.longitudeDeg)&&Number.isFinite(e.latitudeDeg)&&e.latitudeDeg>=-90&&e.latitudeDeg<=90}function h(e,t){return Math.abs(c(t)-c(e))>180}function c(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.TerraPolylineSetGL=n},3559(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueShaderProgram=void 0;const s=i(3890),o=r(i(5947));t.CatalogueShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix"},this.gl_attributes={vertex_pos:"aCatPosition",vertex_selected:"a_selected",point_size:"a_pointsize",point_hue:"a_brightness"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,hovered:-1,pointSize:-1,brightness:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=o.default.catalogueFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=o.default.catalogueVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.hovered=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_selected),this.locations.pointSize=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_size),this.locations.brightness=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_hue),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let o=s.mat4.create();o=s.mat4.multiply(o,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,o)}}},8909(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintShaderProgram=void 0;const s=i(3890),o=r(i(5947));t.FootprintShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix",point_size:"u_pointsize"},this.gl_attributes={vertex_pos:"aCatPosition"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,pointSize:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=o.default.footprintFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=o.default.footprintVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.pointSize=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.point_size),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let o=s.mat4.create();o=s.mat4.multiply(o,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,o)}}},4707(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{static healpixGridVS(){return"#version 300 es\n in vec4 aCatPosition;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = 7.0;\n }"}static healpixGridFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n // fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n fragColor = u_fragcolor;\n }"}}},7786(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSShaderProgram=void 0;const s=r(i(5947)),o=i(619);t.HiPSShaderProgram=class{_colorMapBlockIndex=null;_runtimeColorMap;_shaderProgram;_vertexShader;_fragmentShader;_UBO_colorMapBuffer=null;_UBO_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={sampler:"uSampler0",factor:"uFactor0",m_perspective:"uPMatrix",m_model:"uMMatrix",m_view:"uVMatrix",colormapIdx:"cmapIdx",colormap_red:"r",colormap_green:"g",colormap_blue:"b",textureMode:"uTextureMode",dataMin:"uDataMin",dataMax:"uDataMax"},this.gl_attributes={vertex_pos:"aVertexPosition",text_coords:"aTextureCoord"},this.locations={pMatrix:null,mMatrix:null,vMatrix:null,samplers:new Array(8).fill(null),textureAlpha:new Array(8).fill(null),textureMode:new Array(8).fill(null),dataMin:new Array(8).fill(null),dataMax:new Array(8).fill(null),clorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();this._shaderProgram=t,this.initShaders(t)}return e.useProgram(this._shaderProgram),this._shaderProgram}setRuntimeColorMap(e){this._runtimeColorMap=e}initShaders(e){const t=this._webgl,i=s.default.hipsNativeFS();if(this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,i),t.compileShader(this._fragmentShader),!t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS))return void alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=s.default.hipsVS();this._vertexShader=t.createShader(t.VERTEX_SHADER),t.shaderSource(this._vertexShader,r),t.compileShader(this._vertexShader),t.getShaderParameter(this._vertexShader,t.COMPILE_STATUS)?(t.attachShader(e,this._vertexShader),t.attachShader(e,this._fragmentShader),t.linkProgram(e),t.getProgramParameter(e,t.LINK_STATUS)||alert("Could not initialise shaders")):alert(t.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setGrayscaleShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsGrayscaleFS();this.changeFSShader(e)}setNativeShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsNativeFS();this.changeFSShader(e)}setColorMapShader(){const e=this._webgl;e.detachShader(this.shaderProgram,this._fragmentShader);const t=s.default.hipsColorMapFS();this.changeFSShader(t);const i=e.getUniformBlockIndex(this.shaderProgram,"colormap");if(i===e.INVALID_INDEX)return console.warn('HiPSShaderProgram: uniform block "colormap" not found in hipsColorMapFS()'),this._colorMapBlockIndex=null,void(this._UBO_colorMapBuffer=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],o=e.getUniformIndices(this.shaderProgram,r),a=e.getActiveUniforms(this.shaderProgram,o,e.UNIFORM_OFFSET);if(!this._UBO_colorMapBuffer){this._UBO_colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._UBO_colorMapBuffer);const t=12288;e.bufferData(e.UNIFORM_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._UBO_colorMapBuffer)}r.forEach((e,t)=>{this._UBO_colorMapVariableInfo[e]={index:o[t],offset:a[t]}})}changeFSShader(e){const t=this._webgl;this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,e),t.compileShader(this._fragmentShader),t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS)?(t.attachShader(this.shaderProgram,this._fragmentShader),t.linkProgram(this.shaderProgram),t.getProgramParameter(this.shaderProgram,t.LINK_STATUS)||alert("Could not initialise shaders"),t.useProgram(this.shaderProgram)):alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error")}setTextureDataMode(e,t,i,r){if(e<0||e>=8)throw new Error(`Invalid HiPS sampler index: ${e}`);const s=this._webgl,o=this.locations.textureMode[e];if(o&&s.uniform1i(o,t?1:0),!t)return;if(void 0===i||void 0===r||!Number.isFinite(i)||!Number.isFinite(r)||r<=i)throw new Error("Invalid FITS display range.");const a=this.locations.dataMin[e],n=this.locations.dataMax[e];a&&s.uniform1f(a,i),n&&s.uniform1f(n,r)}enableShaders(e,t,i,r){const s=this._webgl;s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model),this.locations.vMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_view),this.locations.clorMapIdx=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.colormapIdx);for(let e=0;e<8;e++)this.locations.samplers[e]=s.getUniformLocation(this.shaderProgram,`uSampler${e}`),this.locations.textureAlpha[e]=s.getUniformLocation(this.shaderProgram,`uFactor${e}`),this.locations.textureMode[e]=s.getUniformLocation(this.shaderProgram,`uTextureMode${e}`),this.locations.dataMin[e]=s.getUniformLocation(this.shaderProgram,`uDataMin${e}`),this.locations.dataMax[e]=s.getUniformLocation(this.shaderProgram,`uDataMax${e}`),this.locations.samplers[e]&&s.uniform1i(this.locations.samplers[e],e);if(s.uniform1i(this.locations.clorMapIdx,r),this.locations.vertexPositionAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.textureCoordAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.text_coords),r>=2&&this._UBO_colorMapBuffer&&null!==this._colorMapBlockIndex){let e;if(s.uniformBlockBinding(this.shaderProgram,this._colorMapBlockIndex,0),s.bindBuffer(s.UNIFORM_BUFFER,this._UBO_colorMapBuffer),2===r?e={r:o.ColorMaps.planck.r,g:o.ColorMaps.planck.g,b:o.ColorMaps.planck.b}:3===r?e={r:o.ColorMaps.cmb.r,g:o.ColorMaps.cmb.g,b:o.ColorMaps.cmb.b}:4===r?e={r:o.ColorMaps.rainbow.r,g:o.ColorMaps.rainbow.g,b:o.ColorMaps.rainbow.b}:5===r?e={r:o.ColorMaps.eosb.r,g:o.ColorMaps.eosb.g,b:o.ColorMaps.eosb.b}:6===r?e={r:o.ColorMaps.cubehelix.r,g:o.ColorMaps.cubehelix.g,b:o.ColorMaps.cubehelix.b}:7===r?e={r:o.ColorMaps.hot.r,g:o.ColorMaps.hot.g,b:o.ColorMaps.hot.b}:8===r&&(e={r:o.ColorMaps.gray.r,g:o.ColorMaps.gray.g,b:o.ColorMaps.gray.b}),e||(e=this._runtimeColorMap),e){const t=this._UBO_colorMapVariableInfo;s.bufferSubData(s.UNIFORM_BUFFER,t.r_palette.offset,e.r,0),s.bufferSubData(s.UNIFORM_BUFFER,t.g_palette.offset,e.g,0),s.bufferSubData(s.UNIFORM_BUFFER,t.b_palette.offset,e.b,0)}s.bindBuffer(s.UNIFORM_BUFFER,null)}s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t)}}},2257(e,t){"use strict";t.MeshHiPSShaderProgram=void 0;t.MeshHiPSShaderProgram=class{_webgl;_options;locations;_shaderProgram;constructor(e,t={}){this._webgl=e,this._options=t,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,color:null,vertexPositionAttribute:-1,vertexNormalAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create MeshHiPS shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}enableShaders(e,t,i,r){const s=this._webgl,o=this.shaderProgram;s.useProgram(o),this.locations.pMatrix=s.getUniformLocation(o,"uPMatrix"),this.locations.vMatrix=s.getUniformLocation(o,"uVMatrix"),this.locations.mMatrix=s.getUniformLocation(o,"uMMatrix"),this.locations.color=s.getUniformLocation(o,"uColor"),this.locations.vertexPositionAttribute=s.getAttribLocation(o,"aVertexPosition"),this.locations.vertexNormalAttribute=s.getAttribLocation(o,"aVertexNormal"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniform4fv(this.locations.color,r)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n precision mediump float;\n in vec3 aVertexPosition;\n in vec3 aVertexNormal;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec3 vNormal;\n void main(void) {\n vec3 worldPos = (uMMatrix * vec4(aVertexPosition, 1.0)).xyz;\n vNormal = normalize((uMMatrix * vec4(aVertexNormal, 0.0)).xyz);\n gl_Position = uPMatrix * uVMatrix * vec4(worldPos, 1.0);\n }"),i=this.compileShader(e.FRAGMENT_SHADER,`#version 300 es\n precision mediump float;\n in vec3 vNormal;\n uniform vec4 uColor;\n out vec4 outColor;\n void main(void) {\n vec3 normal = normalize(vNormal);\n vec3 lightDir = normalize(vec3(0.45, 0.8, 0.35));\n float diffuse = ${this._options.twoSidedLighting?"abs(dot(normal, lightDir))":"max(dot(normal, lightDir), 0.0)"};\n float rim = pow(1.0 - max(dot(normal, vec3(0.0, 0.0, 1.0)), 0.0), 2.0);\n vec3 color = ${this._options.markerLighting?"uColor.rgb * (0.78 + diffuse * 0.18) + vec3(0.06, 0.08, 0.07) * rim":"uColor.rgb * (0.24 + diffuse * 0.78) + vec3(0.16, 0.24, 0.20) * rim"};\n outColor = vec4(color, uColor.a);\n }`);if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,i),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise MeshHiPS shaders")}compileShader(e,t){const i=this._webgl,r=i.createShader(e);if(!r)throw new Error("Could not create MeshHiPS shader");if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(r)||"MeshHiPS shader compile error");return r}}},5947(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class i{static catalogueVS(){return"#version 300 es\n in vec4 aCatPosition;\n in float a_selected;\n in float a_pointsize;\n in float a_brightness;\n\n out float v_selected;\n out float v_brightness;\n out lowp vec4 vColor; // not used\n\n uniform mat4 uPMatrix;\n uniform mat4 uMVMatrix;\n\n void main() {\n\n gl_Position = (uPMatrix * uMVMatrix * aCatPosition);\n gl_PointSize = a_pointsize;\n v_selected = a_selected;\n v_brightness = a_brightness;\n }"}static catalogueFS(){return"#version 300 es\n precision mediump float;\n \n #ifdef GL_OES_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n #endif\n\n // https://www.desultoryquest.com/blog/drawing-anti-aliased-circular-points-using-opengl-slash-webgl/\n\n // precision mediump float;\n\n in float v_selected;\n in float v_brightness;\n\n uniform vec4 u_fragcolor;\n\n out vec4 fragColor;\n\n // varying float v_selected;\n // varying float v_brightness;\n\n const float EPSILON = 1e-10;\n \n vec3 RGBtoHCV(in vec3 rgb) {\n // RGB [0..1] to Hue-Chroma-Value [0..1]\n // Based on work by Sam Hocevar and Emil Persson\n vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1., 2. / 3.) : vec4(rgb.gb, 0., -1. / 3.);\n vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);\n float c = q.x - min(q.w, q.y);\n float h = abs((q.w - q.y) / (6. * c + EPSILON) + q.z);\n return vec3(h, c, q.x);\n }\n\n vec3 RGBtoHSL(in vec3 rgb) {\n // RGB [0..1] to Hue-Saturation-Lightness [0..1]\n vec3 hcv = RGBtoHCV(rgb);\n //vec3 hcv = vec3(1., 1., 1.);\n float z = hcv.z - hcv.y * 0.5;\n float s = hcv.y / (1. - abs(z * 2. - 1.) + EPSILON);\n return vec3(hcv.x, s, z);\n }\n\n vec3 HUEtoRGB(in float hue){\n // Hue [0..1] to RGB [0..1]\n // See http://www.chilliant.com/rgb2hsv.html\n vec3 rgb = abs(hue * 6. - vec3(3, 2, 4)) * vec3(1, -1, -1) + vec3(-1, 2, 2);\n return clamp(rgb, 0., 1.);\n }\n\n vec3 HSLtoRGB(in vec3 hsl) {\n // Hue-Saturation-Lightness [0..1] to RGB [0..1]\n vec3 rgb = HUEtoRGB(hsl.x);\n float c = (1. - abs(2. * hsl.z - 1.)) * hsl.y;\n return (rgb - 0.5) * c + hsl.z;\n }\n \n void main() {\n\n float r = 0.0, delta = 0.0, alpha = 1.0;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n r = dot(cxy, cxy);\n if (r > 1.0) {\n discard;\n }\n\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n #endif\n\n if (v_selected == 1.0){\n // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n } else if (v_selected == 2.0){\n // gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n }else{\n if (r < 0.4) {\n discard;\n }\n if ( v_brightness >= -1.0 && v_brightness <= 1.0) {\n // Round-trip RGB->HSL->RGB with time-dependent lightness\n vec3 hsl = RGBtoHSL(vec3(u_fragcolor));\n //hsl.z = pow(hsl.z, sin(iTime) + 1.5);\n // hsl.z = pow(hsl.z, v_brightness + 1.5);\n hsl.z = pow(hsl.z, v_brightness + 1.5);\n vec3 hslcolor = HSLtoRGB(hsl);\n // gl_FragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n fragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n } else {\n // gl_FragColor = u_fragcolor * (alpha);\n fragColor = u_fragcolor * (alpha);\n }\n }\n }"}static footprintVS(){return"#version 300 es\n precision highp float;\n\n layout(location = 0) in vec4 aCatPosition;\n\n uniform float u_pointsize;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = u_pointsize; // Works in WebGL2\n }"}static footprintFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n fragColor = u_fragcolor;\n }"}static hipsVS(){return"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n\n uniform mat4 uMMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uPMatrix;\n\n out vec2 vTextureCoord;\n\n void main() {\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n vTextureCoord = aTextureCoord;\n }"}static hipsNativeFS(){return`#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n finalColor +=\n sampleHiPSTexture0(vTextureCoord).rgb * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n finalColor +=\n sampleHiPSTexture1(vTextureCoord).rgb * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n finalColor +=\n sampleHiPSTexture2(vTextureCoord).rgb * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n finalColor +=\n sampleHiPSTexture3(vTextureCoord).rgb * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n finalColor +=\n sampleHiPSTexture4(vTextureCoord).rgb * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n finalColor +=\n sampleHiPSTexture5(vTextureCoord).rgb * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n finalColor +=\n sampleHiPSTexture6(vTextureCoord).rgb * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n finalColor +=\n sampleHiPSTexture7(vTextureCoord).rgb * uFactor7;\n }\n\n fragColor = vec4(finalColor, 1.0);\n }`}static hipsGrayscaleFS(){return`#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n vec4 color0 = sampleHiPSTexture0(vTextureCoord);\n\n float gray =\n 0.21 * color0.r +\n 0.71 * color0.g +\n 0.07 * color0.b;\n\n finalColor =\n color0.rgb * (1.0 - uFactor0) +\n vec3(gray) * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n vec4 color1 = sampleHiPSTexture1(vTextureCoord);\n finalColor += color1.rgb * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n vec4 color2 = sampleHiPSTexture2(vTextureCoord);\n finalColor += color2.rgb * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n vec4 color3 = sampleHiPSTexture3(vTextureCoord);\n finalColor += color3.rgb * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n vec4 color4 = sampleHiPSTexture4(vTextureCoord);\n finalColor += color4.rgb * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n vec4 color5 = sampleHiPSTexture5(vTextureCoord);\n finalColor += color5.rgb * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n vec4 color6 = sampleHiPSTexture6(vTextureCoord);\n finalColor += color6.rgb * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n vec4 color7 = sampleHiPSTexture7(vTextureCoord);\n finalColor += color7.rgb * uFactor7;\n }\n\n fragColor = vec4(finalColor, 1.0);\n }`}static hipsColorMapFS(){return`#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n vec3 applyColorMap(vec4 color) {\n int x = int(clamp(color.r, 0.0, 1.0) * 255.0);\n int y = int(clamp(color.g, 0.0, 1.0) * 255.0);\n int z = int(clamp(color.b, 0.0, 1.0) * 255.0);\n\n float px = r_palette[x] / 256.0;\n float py = g_palette[y] / 256.0;\n float pz = b_palette[z] / 256.0;\n\n return vec3(px, py, pz);\n }\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture0(vTextureCoord)\n ) * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture1(vTextureCoord)\n ) * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture2(vTextureCoord)\n ) * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture3(vTextureCoord)\n ) * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture4(vTextureCoord)\n ) * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture5(vTextureCoord)\n ) * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture6(vTextureCoord)\n ) * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture7(vTextureCoord)\n ) * uFactor7;\n }\n\n fragColor = vec4(finalColor, 1.0);\n }`}static hipsSamplerGLSL(e){return`\n uniform sampler2D uSampler${e};\n uniform int uTextureMode${e};\n uniform float uDataMin${e};\n uniform float uDataMax${e};\n\n vec4 sampleHiPSTexture${e}(vec2 uv) {\n vec4 color = texture(uSampler${e}, uv);\n\n // JPG / PNG\n if (uTextureMode${e} == 0) {\n return color;\n }\n\n // FITS physical value stored in red channel\n float value = color.r;\n\n if (isnan(value)) {\n discard;\n }\n\n float normalized = clamp(\n (value - uDataMin${e}) /\n (uDataMax${e} - uDataMin${e}),\n 0.0,\n 1.0\n );\n\n return vec4(\n normalized,\n normalized,\n normalized,\n 1.0\n );\n }\n `}static hipsSamplersGLSL(){return Array.from({length:8},(e,t)=>i.hipsSamplerGLSL(t)).join("\n")}}t.default=i},149(e,t,i){"use strict";t.XYZShaderProgram=void 0;const r=i(619);t.XYZShaderProgram=class{locations;_webgl;_shaderProgram;_colorMapBlockIndex=null;_colorMapBuffer=null;_runtimeColorMap;_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,colorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create XYZ shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setRuntimeColorMap(e){this._runtimeColorMap=e}enableShaders(e,t,i,r=0){const s=this._webgl,o=this.shaderProgram;s.useProgram(o),this.locations.pMatrix=s.getUniformLocation(o,"uPMatrix"),this.locations.mMatrix=s.getUniformLocation(o,"uMMatrix"),this.locations.vMatrix=s.getUniformLocation(o,"uVMatrix"),this.locations.sampler=s.getUniformLocation(o,"uSampler"),this.locations.colorMapIdx=s.getUniformLocation(o,"cmapIdx"),this.locations.vertexPositionAttribute=s.getAttribLocation(o,"aVertexPosition"),this.locations.textureCoordAttribute=s.getAttribLocation(o,"aTextureCoord"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniform1i(this.locations.sampler,0),s.uniform1i(this.locations.colorMapIdx,r),r>=2&&this.uploadColorMap(r)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec2 vTextureCoord;\n void main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n }"),i=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec2 vTextureCoord;\n uniform sampler2D uSampler;\n uniform int cmapIdx;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n out vec4 outColor;\n\n void main(void) {\n vec4 color = texture(uSampler, vTextureCoord);\n\n if (cmapIdx == 1) {\n float gray = 0.21 * color.r + 0.71 * color.g + 0.07 * color.b;\n outColor = vec4(vec3(gray), color.a);\n return;\n }\n\n if (cmapIdx >= 2) {\n int rIndex = int(clamp(color.r * 255.0, 0.0, 255.0));\n int gIndex = int(clamp(color.g * 255.0, 0.0, 255.0));\n int bIndex = int(clamp(color.b * 255.0, 0.0, 255.0));\n\n outColor = vec4(\n r_palette[rIndex] / 256.0,\n g_palette[gIndex] / 256.0,\n b_palette[bIndex] / 256.0,\n color.a\n );\n return;\n }\n\n outColor = color;\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,i),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise XYZ shaders");this.initColorMapBuffer()}compileShader(e,t){const i=this._webgl,r=i.createShader(e);if(!r)throw new Error("Could not create XYZ shader");if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(r)||"XYZ shader compile error");return r}initColorMapBuffer(){const e=this._webgl,t=this._shaderProgram,i=e.getUniformBlockIndex(t,"colormap");if(i===e.INVALID_INDEX)return void(this._colorMapBlockIndex=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],s=e.getUniformIndices(t,r),o=e.getActiveUniforms(t,s,e.UNIFORM_OFFSET);r.forEach((e,t)=>{this._colorMapVariableInfo[e]={index:s[t],offset:o[t]}}),this._colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._colorMapBuffer),e.bufferData(e.UNIFORM_BUFFER,12288,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._colorMapBuffer),e.uniformBlockBinding(t,i,0)}uploadColorMap(e){if(!this._colorMapBuffer||null===this._colorMapBlockIndex)return;const t=this.getColorMap(e);if(!t)return;const i=this._webgl,r=this.shaderProgram;i.uniformBlockBinding(r,this._colorMapBlockIndex,0),i.bindBuffer(i.UNIFORM_BUFFER,this._colorMapBuffer);const s=this._colorMapVariableInfo;i.bufferSubData(i.UNIFORM_BUFFER,s.r_palette.offset,t.r,0),i.bufferSubData(i.UNIFORM_BUFFER,s.g_palette.offset,t.g,0),i.bufferSubData(i.UNIFORM_BUFFER,s.b_palette.offset,t.b,0),i.bindBuffer(i.UNIFORM_BUFFER,null)}getColorMap(e){switch(e){case 2:return r.ColorMaps.planck;case 3:return r.ColorMaps.cmb;case 4:return r.ColorMaps.rainbow;case 5:return r.ColorMaps.eosb;case 6:return r.ColorMaps.cubehelix;case 7:return r.ColorMaps.hot;case 8:return r.ColorMaps.gray;default:return this._runtimeColorMap}}}},8145(e,t){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsType=void 0,function(e){e.CARTESIAN="cartesian",e.SPHERICAL="spherical",e.ASTRO="astro",e.GEOGRAPHIC="geographic"}(i||(t.CoordsType=i={}))},8083(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FoVUtils=void 0;const s=i(6553),o=r(i(4639)),a=i(8145),n=i(3890);class l{getMinFoV(){return this._fovY_deg<=this._fovX_deg?this._fovY_deg:this._fovX_deg}static getFoVPolygon(e,t,i,r,s,a){const h=e.getCameraMatrix(),c=i.getModelMatrix(),u=t.clientWidth,d=t.clientHeight;let g=[];if(o.default.getIntersectionPointWithSingleModel(0,0,r,s,e,a).length>0){g=l.getScreenCornersIntersection(a,e,t,r,s)}else{let t=n.mat4.create();t=n.mat4.multiply(t,h,c),t=n.mat4.multiply(t,a,t);const i=[t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]],_=[t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]],p=[t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]],f=[t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]],m=o.default.getIntersectionPointWithSingleModel(u/2,0,r,s,e,a),x=o.default.getIntersectionPointWithSingleModel(u,d/2,r,s,e,a);if(0===m.length&&0===x.length){const e=l.getNearestSpherePoint(i),t=l.getNearestSpherePoint(_),r=l.getNearestSpherePoint(f),s=l.getNearestSpherePoint(p),o=l.computeMiddlePoint(r[0],e[0])[0],a=l.computeMiddlePoint(e[0],s[0])[0],n=l.computeMiddlePoint(s[0],t[0])[0],h=l.computeMiddlePoint(t[0],r[0])[0];g.push(e[0],a,s[0],n,t[0],h,r[0],o)}else if(0===m.length){const e=l.getNearestSpherePoint(i),r=l.getNearestSpherePoint(_),s=l.getFrustumIntersectionWithSphere(t,f,_,i),o=l.getFrustumIntersectionWithSphere(t,p,i,_),a=l.computeMiddlePoint(s[1],e[0])[0],n=l.computeMiddlePoint(e[0],o[0])[0],h=l.computeMiddlePoint(o[1],r[0])[0],c=l.computeMiddlePoint(r[0],s[0])[0];g.push(e[0],n,o[0],o[1],h,r[0],c,s[0],s[1],a)}else if(0===x.length){const e=l.getFrustumIntersectionWithSphere(t,i,f,p),r=l.getFrustumIntersectionWithSphere(t,_,p,f),s=l.getNearestSpherePoint(f),o=l.getNearestSpherePoint(p),a=l.computeMiddlePoint(s[0],e[0])[0],n=l.computeMiddlePoint(e[1],o[0])[0],h=l.computeMiddlePoint(o[0],r[0])[0],c=l.computeMiddlePoint(r[1],s[0])[0];g.push(e[0],e[1],n,o[0],h,r[0],r[1],c,s[0],a)}else{const e=l.getFrustumIntersectionWithSphere(t,i,f,p),r=l.getFrustumIntersectionWithSphere(t,_,p,f),s=l.getFrustumIntersectionWithSphere(t,f,_,i),o=l.getFrustumIntersectionWithSphere(t,p,i,_);g.push(e[0],e[1],o[0],o[1],r[0],r[1],s[0],s[1])}}return g}static getScreenCornersIntersection(e,t,i,r,n){const l=i.clientWidth,h=i.clientHeight,c=o.default.getIntersectionPointWithSingleModel(0,0,r,n,t,e),u=o.default.getIntersectionPointWithSingleModel(l/2,0,r,n,t,e),d=o.default.getIntersectionPointWithSingleModel(l,0,r,n,t,e),g=o.default.getIntersectionPointWithSingleModel(l,h/2,r,n,t,e),_=o.default.getIntersectionPointWithSingleModel(l,h,r,n,t,e),p=o.default.getIntersectionPointWithSingleModel(l/2,h,r,n,t,e),f=o.default.getIntersectionPointWithSingleModel(0,h,r,n,t,e),m=o.default.getIntersectionPointWithSingleModel(0,h/2,r,n,t,e),x=[],b=e=>{e.length>0&&x.push(new s.Point({x:e[0],y:e[1],z:e[2]},a.CoordsType.CARTESIAN))};return b(c),b(u),b(d),b(g),b(_),b(p),b(f),b(m),x}static getCenterJ2000(e,t,i,r,n){const l=e.clientWidth,h=e.clientHeight,c=o.default.getIntersectionPointWithSingleModel(l/2,h/2,t,i,r,n);if(c.length<=0)throw Error("Central point is null");return new s.Point({x:c[0],y:c[1],z:c[2]},a.CoordsType.CARTESIAN)}static computeMiddlePoint(e,t){const i=(e.x+t.x)/2,r=(e.y+t.y)/2,o=(e.z+t.z)/2,n=Math.hypot(i,r,o)||1,l=i/n,h=r/n,c=o/n;return[new s.Point({x:l,y:h,z:c},a.CoordsType.CARTESIAN)]}static getNearestSpherePoint(e){const[t,i,r,o]=e,n=1/Math.sqrt(t*t+i*i+r*r),l=1*n,h=-1*n,c=[t*l,i*l,r*l],u=[t*h,i*h,r*h],d=Math.sqrt(t*t+i*i+r*r)||1,g=Math.abs(t*c[0]+i*c[1]+r*c[2]+o)/d<=Math.abs(t*u[0]+i*u[1]+r*u[2]+o)/d?c:u;return[new s.Point({x:g[0],y:g[1],z:g[2]},a.CoordsType.CARTESIAN)]}static getFrustumIntersectionWithSphere(e,t,i,r){const[o,n,l,h]=t,c=o*o+n*n+l*l||1,u=-o*h/c,d=-n*h/c,g=-l*h/c,_=Math.abs(h)/Math.sqrt(c),p=[];if(1>_){const e=Math.sqrt(1-_*_),t=t=>{const[i,r,s,o]=t,a=1/Math.sqrt(i*i+r*r+s*s),n=e*a,l=-e*a,h=[u+i*n,d+r*n,g+s*n],c=[u+i*l,d+r*l,g+s*l],_=Math.sqrt(i*i+r*r+s*s)||1;return Math.abs(i*h[0]+r*h[1]+s*h[2]+o)/_<=Math.abs(i*c[0]+r*c[1]+s*c[2]+o)/_?h:c},o=t(i),n=t(r);p.push(new s.Point({x:o[0],y:o[1],z:o[2]},a.CoordsType.CARTESIAN),new s.Point({x:n[0],y:n[1],z:n[2]},a.CoordsType.CARTESIAN))}else 1===_&&p.push(new s.Point({x:u,y:d,z:g},a.CoordsType.CARTESIAN),new s.Point({x:u,y:d,z:g},a.CoordsType.CARTESIAN));return p}static getAstroFoVPolygon(e){return e.map(e=>e.toADQL()).join(",")}}t.FoVUtils=l},8755(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(8145),s=i(6553);class o{static isGeoJSON(e){if(!e||"object"!=typeof e)return!1;const t=e.type;return"FeatureCollection"===t||"Feature"===t||"Polygon"===t||"MultiPolygon"===t||"GeometryCollection"===t}static parseGeoJSON(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON root must be an object");const t=e;if("FeatureCollection"===t.type){if(!Array.isArray(t.features))throw new Error("GeoJSON FeatureCollection has no features array");return t.features.flatMap(e=>o.parseFeature(e))}if("Feature"===t.type)return o.parseFeature(t);if("Polygon"===t.type||"MultiPolygon"===t.type||"GeometryCollection"===t.type)return o.parseGeometry(t,{});throw new Error(`Unsupported GeoJSON type: ${t.type??"unknown"}`)}static parseFeature(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON feature must be an object");const t=e;if("Feature"!==t.type)throw new Error("GeoJSON feature has invalid type");return t.geometry?o.parseGeometry(t.geometry,t.properties??{},t.id):[]}static parseGeometry(e,t,i){return"Polygon"===e.type?[{id:i,geometryType:"Polygon",properties:t,polygons:o.parsePolygonCoordinates(e.coordinates)}]:"MultiPolygon"===e.type?[{id:i,geometryType:"MultiPolygon",properties:t,polygons:o.parseMultiPolygonCoordinates(e.coordinates)}]:"GeometryCollection"===e.type&&Array.isArray(e.geometries)?e.geometries.flatMap(e=>o.parseGeometry(e,t,i)):[]}static parseMultiPolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON MultiPolygon coordinates must be an array");return e.flatMap(e=>o.parsePolygonCoordinates(e))}static parsePolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON Polygon coordinates must be an array");return e.map(e=>o.parseLinearRing(e)).filter(e=>e.length>=3)}static parseLinearRing(e){if(!Array.isArray(e))throw new Error("GeoJSON linear ring must be an array");const t=e.map(e=>o.parsePosition(e));if(t.length>1){const e=t[0],i=t[t.length-1];e.lonDeg===i.lonDeg&&e.latDeg===i.latDeg&&t.pop()}return t}static parsePosition(e){if(!Array.isArray(e)||e.length<2)throw new Error("GeoJSON position must be [longitude, latitude]");const[t,i]=e;if(!Number.isFinite(t)||!Number.isFinite(i))throw new Error("GeoJSON position contains non-finite longitude/latitude");return new s.Point({lonDeg:t,latDeg:i},r.CoordsType.GEOGRAPHIC)}}t.default=o},2930(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),o=r(i(7559)),a=i(8145);class n{static orthodromicDistance(e,t){return Math.acos(Math.sin(e.decDeg*Math.PI/180)*Math.sin(t.decDeg*Math.PI/180)+Math.cos(e.decDeg*Math.PI/180)*Math.cos(t.decDeg*Math.PI/180)*Math.cos((t.raDeg-e.raDeg)*Math.PI/180))}static computeSelectionObject(e){let t,i,r,s,a=[],l=0;let h=0;if(e[0][0].decDeg>=10?h=1:e[0][0].decDeg<=-10?h=-1:l=1,0===l){const o=n.projectIn2D(e[0][0]);t=r=o.x,i=s=o.y;for(const o of e){const e=[];for(const c of o){if(c.decDeg>10*h&&-1===h||c.decDeg<10*h&&1===h){l=1,a=[];break}const o=n.projectIn2D(c);e.push(o),o.x>t&&(t=o.x),o.y>i&&(i=o.y),o.x<r&&(r=o.x),o.y<s&&(s=o.y)}a.push(e)}}if(0===l)return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s};const c=180;let u=e[0][0].raDeg<c;t=r=e[0][0].raDeg,i=s=e[0][0].decDeg;for(const n of e){const e=[];for(const h of n){const n=new o.default(h.raDeg,h.decDeg);if(e.push(n),h.raDeg>t&&(t=h.raDeg),h.decDeg>i&&(i=h.decDeg),h.raDeg<r&&(r=h.raDeg),h.decDeg<s&&(s=h.decDeg),h.raDeg>=c&&u||h.raDeg<=c&&!u){l=2,a=[];break}}a.push(e)}if(1===l)return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s};let d=e[0][0].raDeg;t=d>=c?d-360:d,i=e[0][0].decDeg,r=t,s=i;for(const n of e){const e=[];for(const a of n){const n=a.raDeg>=c?a.raDeg-360:a.raDeg;n>t&&(t=n),a.decDeg>i&&(i=a.decDeg),n<r&&(r=n),a.decDeg<s&&(s=a.decDeg),e.push(new o.default(n,a.decDeg))}a.push(e)}return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s}}static stereographic(e){const t=Number(e.xyz[0]),i=Number(e.xyz[1]),r=Number(e.xyz[2]);return{x:2*t/(1-r),y:2*i/(1-r)}}static projectIn2D(e){const t=n.stereographic(e);return new o.default(t.x,t.y)}static checkPointInsidePolygon5(e,t){let i;if(0===e.flag)i=n.projectIn2D(t);else if(1===e.flag)i=new o.default(t.raDeg,t.decDeg);else{const e=180,r=t.raDeg>=e?t.raDeg-360:t.raDeg;i=new o.default(r,t.decDeg)}const r=new o.default(i.x,i.y+2*Math.abs(e.maxy-e.miny));if(i.x>e.maxx||i.x<e.minx||i.y>e.maxy||i.y<e.miny)return!1;for(const t of e.poly4selection){let e=0;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],n=(a.y-o.y)*(r.x-i.x)-(a.x-o.x)*(r.y-i.y),l=(a.x-o.x)*(i.y-o.y)-(a.y-o.y)*(i.x-o.x),h=(r.x-i.x)*(i.y-o.y)-(r.y-i.y)*(i.x-o.x);if(0!==n){const t=l/n,i=h/n;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const s=t[t.length-1],o=t[0],a=(o.y-s.y)*(r.x-i.x)-(o.x-s.x)*(r.y-i.y),n=(o.x-s.x)*(i.y-s.y)-(o.y-s.y)*(i.x-s.x),l=(r.x-i.x)*(i.y-s.y)-(r.y-i.y)*(i.x-s.x);if(0!==a){const t=n/a,i=l/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}static checkPointInsidePolygon4(e,t){const i=n.projectIn2D(t);let r=t.raDeg+15;r>360&&(r=t.raDeg-15);const o=new s.Point({raDeg:r,decDeg:t.decDeg},a.CoordsType.ASTRO),l=n.projectIn2D(o);for(const t of e){let e=0;for(let r=0;r<t.length-1;r++){const s=n.projectIn2D(t[r]),o=n.projectIn2D(t[r+1]),a=(o.y-s.y)*(l.x-i.x)-(o.x-s.x)*(l.y-i.y),h=(o.x-s.x)*(i.y-s.y)-(o.y-s.y)*(i.x-s.x),c=(l.x-i.x)*(i.y-s.y)-(l.y-i.y)*(i.x-s.x);if(0!==a){const t=h/a,i=c/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const r=n.projectIn2D(t[t.length-1]),s=n.projectIn2D(t[0]),o=(s.y-r.y)*(l.x-i.x)-(s.x-r.x)*(l.y-i.y),a=(s.x-r.x)*(i.y-r.y)-(s.y-r.y)*(i.x-r.x),h=(l.x-i.x)*(i.y-r.y)-(l.y-i.y)*(i.x-r.x);if(0!==o){const t=a/o,i=h/o;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}}t.default=n},4396(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(3890),o=i(4851),a=r(i(4382)),n=i(7930);t.default=class{_xyz=null;_raDecDeg=null;_phiThetaDeg=null;raHMS;decDMS;constructor(e,t,i){null!=e&&(this._xyz=e),null!=t&&(this._raDecDeg=t),null!=i&&(this._phiThetaDeg=i),this._raDecDeg&&(this.raHMS=(0,n.raDegToHMS)(this._raDecDeg.ra),this.decDMS=(0,n.decDegToDMS)(this._raDecDeg.dec))}computeNpix(){if(!this._xyz)return null;const e=a.default.getHealpix(a.default.nsideForSelection),t=new o.Vec3(this._xyz[0],this._xyz[1],this._xyz[2]),i=new o.Pointing(t,!1);return e.ang2pix(i,!1)}update(e){const t=(i=e,Array.isArray(i)?s.vec3.fromValues(i[0],i[1],i[2]):i);var i;const r=(0,n.cartesianToSpherical)(t),o=(0,n.sphericalToAstroDeg)(r.phi,r.theta);this._xyz=[t[0],t[1],t[2]],this._phiThetaDeg=r,this._raDecDeg=o,this.raHMS=(0,n.raDegToHMS)(o.ra),this.decDMS=(0,n.decDegToDMS)(o.dec)}clear(){this._xyz=null,this._raDecDeg=null,this._phiThetaDeg=null,this.raHMS=void 0,this.decDMS=void 0}get xyz(){return this._xyz}get x(){return this._xyz?this._xyz[0]:null}get y(){return this._xyz?this._xyz[1]:null}get z(){return this._xyz?this._xyz[2]:null}get ra(){return this._raDecDeg?this._raDecDeg.ra:null}get dec(){return this._raDecDeg?this._raDecDeg.dec:null}get phi(){return this._phiThetaDeg?this._phiThetaDeg.phi:null}get theta(){return this._phiThetaDeg?this._phiThetaDeg.theta:null}get raDecDeg(){return this._raDecDeg}get phiThetaDeg(){return this._phiThetaDeg}}},9685(e,t,i){"use strict";t.PerspectiveMatrixManager=void 0;const r=i(3890),s=i(2919);t.PerspectiveMatrixManager=class{_pMatrix;_aspectRatio=1;constructor(e,t,i,r=.1,s){this._pMatrix=this.computePerspectiveMatrix(e,t,i,r,s)}get pMatrix(){return this._pMatrix}set pMatrix(e){this._pMatrix=e}computePerspectiveMatrix(e,t,i,o=.1,a){this._aspectRatio=e.width/e.height;const n=r.mat4.create();let l;if(a)l=1.1;else{const e=t.getCameraMatrix(),i=-Number(e[14]),r=1,s=Math.sqrt(Math.max(i**2-r**2,0)),o=Math.atan2(s,r),a=s*Math.sin(o);l=a>0?a:r}const h=a?s.bootSetup.inside_camera_fov_deg:i,c=a?Math.max(o,.001):o;return r.mat4.perspective(n,h*Math.PI/180,this._aspectRatio,c,l),this._pMatrix=n,n}}},4639(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(3890);class s{static lastNearestVisibleObjectIdx=-1;static getNearestVisibleObjectIdx(){return this.lastNearestVisibleObjectIdx}static getRayFromMouse(e,t,i,o,a){const n=o.canvas.getBoundingClientRect(),l=t,h=[2*e/n.width-1,1-2*l/n.height,-1,1],c=r.mat4.create();r.mat4.invert(c,i);const u=[0,0,0,0];s.mat4MultiplyVec4(c,h,u);const d=[u[0],u[1],-1,0],g=r.mat4.create();r.mat4.invert(g,a);const _=[0,0,0,0];s.mat4MultiplyVec4(g,d,_);const p=r.vec3.fromValues(_[0],_[1],_[2]);return r.vec3.normalize(p,p),p}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],o=t[2],a=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*o+e[12]*a,i[1]=e[1]*r+e[5]*s+e[9]*o+e[13]*a,i[2]=e[2]*r+e[6]*s+e[10]*o+e[14]*a,i[3]=e[3]*r+e[7]*s+e[11]*o+e[15]*a,i}static raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;t<0&&i<0||(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}static getIntersectionPointWithSingleModel(e,t,i,o,a,n){const l=a.getCameraMatrix(),h=s.getRayFromMouse(e,t,n,o,l),c=s.raySphere(a.getCameraPosition(),h,i);let u=[];if(c>=0){const e=r.vec3.create();r.vec3.scale(e,h,c),r.vec3.add(e,a.getCameraPosition(),e);const t=[e[0],e[1],e[2],1],o=[0,0,0,0];s.mat4MultiplyVec4(i.getModelMatrixInverse(),t,o),u=[o[0],o[1],o[2]]}return u}}t.default=s},9665(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),o=i(8145),a=r(i(4382));class n{static parseSTCS(e,t={}){const i=n.cleanStcs(e);return i.includes("POLYGON")?n.parsePolygon(i,t):i.includes("CIRCLE")?n.parseCircle(i,t):(console.warn("STCS not recognised"),{totpoints:0,polygons:[]})}static cleanStcs(e){let t=e.toUpperCase();return t=t.replace(/'ICRS'/g,"").replace(/\bICRS\b/g,"").replace(/\bJ2000\b/g,"").replace(/\bUNION\b/g,"").replace(/\bTOPOCENTER\b/g,""),t=t.replace(/[()]/g,""),t=t.replace(/ {2,}/g," ").trim(),t}static parsePolygon(e,t={}){let i=0;const r=[],n=a.default.MAX_DECIMALS??12,l=t.coordsType??o.CoordsType.ASTRO,h=e.split("POLYGON ");for(let e=1;e<h.length;e++){const t=[],a=h[e].trim().split(" "),c=Number(parseFloat(a[0]).toFixed(n)),u=Number(parseFloat(a[1]).toFixed(n)),d=Number(parseFloat(a[a.length-2]).toFixed(n)),g=Number(parseFloat(a[a.length-1]).toFixed(n));if(c===d&&u===g&&a.splice(a.length-2,2),a.length>2){for(let e=0;e<a.length-1;e+=2){const r=Number(parseFloat(a[e]).toFixed(n)),h=Number(parseFloat(a[e+1]).toFixed(n)),c=l===o.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:h},o.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:h},o.CoordsType.ASTRO);t.push(c),i+=1}r.push(t)}}return{totpoints:i,polygons:r}}static parseCircle(e,t={}){let i=0;const r=[],a=t.coordsType??o.CoordsType.ASTRO,n=e.split("CIRCLE ");for(let e=1;e<n.length;e++){const t=[],l=n[e].trim().split(" "),h=Number(l[0]),c=Number(l[1]),u=Number(l[2]),d=4*6,g=2*Math.PI/d;for(let e=d;e>0;e--){const r=u*Math.cos(e*g)+h,n=u*Math.sin(e*g)+c,l=a===o.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:n},o.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:n},o.CoordsType.ASTRO);t.push(l),i+=1}r.push(t)}return{totpoints:i,polygons:r}}}t.default=n},7930(e,t,i){"use strict";t.cartesianToSpherical=function(e){const t=r.vec3.dot(e,e),i=Math.sqrt(t);let s=Math.acos(e[2]/i);s=o(s);let a=Math.atan2(e[1],e[0]);a=o(a),a<0&&(a+=360);return{phi:a,theta:s}},t.colorHex2RGB=function(e){const t=e.substring(1,3),i=e.substring(3,5),r=e.substring(5,7),s=parseInt(t,16),o=parseInt(i,16),a=parseInt(r,16),n=(s/255).toFixed(2),l=(o/255).toFixed(2),h=(a/255).toFixed(2);return[parseFloat(n),parseFloat(l),parseFloat(h)]},t.degToRad=s,t.radToDeg=o,t.sphericalToAstroDeg=function(e,t){let i=e;i<0&&(i+=360);return{ra:i,dec:90-t}},t.sphericalToCartesian=function(e,t,i=1){const r=i*Math.sin(s(t))*Math.cos(s(e)),o=i*Math.sin(s(t))*Math.sin(s(e)),a=i*Math.cos(s(t));return[r,o,a]},t.astroDegToSpherical=function(e,t){let i=e;i<0&&(i+=360);return{phi:i,theta:90-t}},t.raDegToHMS=function(e){const t=Math.floor(e/15),i=Math.floor(60*(e/15-t));return{h:t,m:i,s:3600*(e/15-t-i/60)}},t.decDegToDMS=function(e){let t=1;e<0&&(t=-1);const i=Math.abs(e);let r=Math.trunc(i);const s=Math.trunc(60*(i-r)),o=3600*(i-r-s/60);return r*=t,{d:r,m:s,s:o}};const r=i(3890);function s(e){return e/180*Math.PI}function o(e){return 180*e/Math.PI}},2166(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(3890),s=85.0511287798066;class o{static getRayFromMouse(e,t,i,s,a){const n=s.canvas.getBoundingClientRect(),l=[2*e/n.width-1,1-2*t/n.height,-1,1],h=r.mat4.create();r.mat4.invert(h,i);const c=[0,0,0,0];o.mat4MultiplyVec4(h,l,c);const u=[c[0],c[1],-1,0],d=r.mat4.create();r.mat4.invert(d,a);const g=[0,0,0,0];o.mat4MultiplyVec4(d,u,g);const _=r.vec3.fromValues(g[0],g[1],g[2]);return r.vec3.normalize(_,_),_}static raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}static getIntersectionPointWithModel(e,t,i,s,a,n){const l=a.getCameraMatrix(),h=o.getRayFromMouse(e,t,n,s,l),c=o.raySphere(a.getCameraPosition(),h,i);if(c<0)return null;const u=r.vec3.create();r.vec3.scale(u,h,c),r.vec3.add(u,a.getCameraPosition(),u);const d=[u[0],u[1],u[2],1],g=[0,0,0,0];return o.mat4MultiplyVec4(i.getModelMatrixInverse(),d,g),[g[0],g[1],g[2]]}static getLonLatFromMouse(e,t,i,r,s,a){const n=o.getIntersectionPointWithModel(e,t,i,r,s,a);return n?o.modelPointToLonLat(n):null}static getTileFromMouse(e,t,i,r,s,a,n){const l=o.getLonLatFromMouse(e,t,r,s,a,n);return l&&o.isMercatorLatitude(l.latDeg)?o.lonLatToTile(l.lonDeg,l.latDeg,i):null}static getVisibleTilesFromViewport(e,t,i,r,s,a=9,n=2){const l=i.canvas.getBoundingClientRect(),h=Math.max(2,Math.floor(a)),c=Math.max(2*h+1,21),u=Math.max(0,Math.floor(n)),d=[],g=(a,n)=>{const l=o.getTileFromMouse(a,n,e,t,i,r,s);l&&(d.push(l),d.push(...o.getNeighborTiles(l,u)))};for(let e=0;e<h;e++){const t=1===h?l.height/2:e/(h-1)*l.height;for(let e=0;e<h;e++){g(1===h?l.width/2:e/(h-1)*l.width,t)}}for(let e=0;e<c;e++){const t=1===c?.5:e/(c-1),i=t*l.width,r=t*l.height;g(i,0),g(i,l.height),g(0,r),g(l.width,r)}return o.fillSmallTileGaps(o.deduplicateTiles(d))}static modelPointToLonLat(e){const[t,i,r]=e,s=Math.hypot(t,i,r);if(!Number.isFinite(s)||0===s)return{lonDeg:0,latDeg:0};return{lonDeg:180*Math.atan2(i,t)/Math.PI,latDeg:180*Math.asin(Math.max(-1,Math.min(1,r/s)))/Math.PI}}static lonLatToTile(e,t,i){const r=Math.max(0,Math.floor(i)),s=2**r,a=Math.floor((e+180)/360*s),n=Math.floor(o.latToTileY(t,r));return{z:r,x:o.wrapTileX(a,s),y:o.clampTileY(n,s)}}static getNeighborTiles(e,t=1){const i=2**e.z,r=[],s=Math.max(0,Math.floor(t));for(let t=-s;t<=s;t++)for(let a=-s;a<=s;a++)r.push({z:e.z,x:o.wrapTileX(e.x+t,i),y:o.clampTileY(e.y+a,i)});return o.deduplicateTiles(r)}static deduplicateTiles(e){const t=new Map;for(const i of e)t.set(`${i.z}/${i.x}/${i.y}`,i);return Array.from(t.values())}static fillSmallTileGaps(e){if(0===e.length)return e;const t=e[0].z,i=2**t,r=new Map,s=e=>{r.set((e=>`${e.z}/${e.x}/${e.y}`)(e),e)},a=(e,s)=>s>=0&&s<i&&r.has(`${t}/${o.wrapTileX(e,i)}/${s}`);for(const t of e)s(t);for(const r of e){const e=r.x,n=r.y;a(e-2,n)&&!a(e-1,n)&&s({z:t,x:o.wrapTileX(e-1,i),y:n}),a(e+2,n)&&!a(e+1,n)&&s({z:t,x:o.wrapTileX(e+1,i),y:n}),a(e,n-2)&&!a(e,n-1)&&s({z:t,x:e,y:n-1}),a(e,n+2)&&!a(e,n+1)&&s({z:t,x:e,y:n+1})}return Array.from(r.values())}static latToTileY(e,t){const i=Math.max(-85.0511287798066,Math.min(s,e))*Math.PI/180,r=2**t;return(1-Math.asinh(Math.tan(i))/Math.PI)/2*r}static isMercatorLatitude(e){return Math.abs(e)<=s}static wrapTileX(e,t){return(e%t+t)%t}static clampTileY(e,t){return Math.max(0,Math.min(t-1,e))}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],o=t[2],a=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*o+e[12]*a,i[1]=e[1]*r+e[5]*s+e[9]*o+e[13]*a,i[2]=e[2]*r+e[6]*s+e[10]*o+e[14]*a,i[3]=e[3]*r+e[7]*s+e[11]*o+e[15]*a,i}}t.default=o},7223(){},4851(e,t,i){"use strict";i.d(t,{Healpix:()=>m,Pointing:()=>s,Vec3:()=>r});class r{x;y;z;constructor(e,t,i){if(![e,t,i].every(Number.isFinite))throw new RangeError("Vec3 coordinates must be finite numbers.");this.x=e,this.y=t,this.z=i}getX(){return this.x}getY(){return this.y}getZ(){return this.z}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.lengthSquared())}normalize(){const e=this.length();if(0===e)throw new RangeError("Cannot normalize a zero-length vector.");return new r(this.x/e,this.y/e,this.z/e)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}}class s{theta;phi;constructor(e,t=!1,i,s){if(e){const i=new r(e.x,e.y,e.z).normalize();return this.theta=Math.atan2(Math.sqrt(i.x*i.x+i.y*i.y),i.z),void(this.phi=o(t?-Math.atan2(i.y,i.x):Math.atan2(i.y,i.x)))}if(!Number.isFinite(i)||!Number.isFinite(s))throw new RangeError("Pointing requires either a Vec3-like object or finite theta/phi radians.");this.theta=i,this.phi=o(s)}toVec3(){const e=Math.sin(this.theta);return new r(e*Math.cos(this.phi),e*Math.sin(this.phi),Math.cos(this.theta))}}function o(e){const t=2*Math.PI;return(e%t+t)%t}class a{r=[];append(e){this.appendRange(e,e+1)}appendRange(e,t){if(!Number.isInteger(e)||!Number.isInteger(t))throw new RangeError("RangeSet bounds must be integers.");if(!(e>=t))for(let i=e;i<t;i+=1)this.r.push(i)}toArray(){return[...this.r]}}const n=2/3,l=Math.PI/2,h=2*Math.PI,c=26,u=[2,2,2,2,3,3,3,3,4,4,4,4],d=[1,3,5,7,0,2,4,6,1,3,5,7],g=[-1,-1,0,1,1,1,0,-1],_=[0,1,1,1,0,-1,-1,-1],p=[[8,9,10,11,-1,-1,-1,-1,10,11,8,9],[5,6,7,4,8,9,10,11,9,10,11,8],[-1,-1,-1,-1,5,6,7,4,-1,-1,-1,-1],[4,5,6,7,11,8,9,10,11,8,9,10],[0,1,2,3,4,5,6,7,8,9,10,11],[1,2,3,0,0,1,2,3,5,6,7,4],[-1,-1,-1,-1,7,4,5,6,-1,-1,-1,-1],[3,0,1,2,3,0,1,2,4,5,6,7],[2,3,0,1,-1,-1,-1,-1,0,1,2,3]],f=[[0,0,3],[0,0,6],[0,0,0],[0,0,5],[0,0,0],[5,0,0],[0,0,0],[6,0,0],[3,0,0]];class m{nside;order;npix;constructor(e){if(!Number.isInteger(e)||e<=0)throw new RangeError("nside must be a positive integer.");const t=Math.log2(e);if(!Number.isInteger(t))throw new RangeError("nside must be a power of two.");if(t>c)throw new RangeError("nside order must be <= 26 for safe JavaScript integer arithmetic.");this.nside=e,this.order=t,this.npix=12*e*e}getNPix(){return this.npix}nside2order(e){if(!Number.isInteger(e)||e<=0)return-1;const t=Math.log2(e);return Number.isInteger(t)?t:-1}nest2xyf(e){this.assertPixel(e);const t=this.nside*this.nside,i=Math.floor(e/t),r=e%t;return{ix:b(r),iy:b(r>>1),face:i}}xyf2nest(e,t,i){if(!Number.isInteger(i)||i<0||i>=12)throw new RangeError("face must be an integer in [0, 11].");if(!Number.isInteger(e)||e<0||e>=this.nside)throw new RangeError("ix must be an integer in [0, nside).");if(!Number.isInteger(t)||t<0||t>=this.nside)throw new RangeError("iy must be an integer in [0, nside).");return i*this.nside*this.nside+x(e)+2*x(t)}ang2pix(e,t=!1){if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("pointing theta and phi must be finite radians.");if(e.theta<0||e.theta>Math.PI)throw new RangeError("pointing theta must be in [0, pi].");const i=Math.cos(e.theta),r=Math.abs(i),s=S(e.phi)/l;if(r<=n){const e=this.nside*(.5+s),t=this.nside*i*.75,r=Math.floor(e-t),o=Math.floor(e+t),a=Math.floor(r/this.nside),n=Math.floor(o/this.nside),l=a===n?4|a:a<n?a:n+8,h=v(o,this.nside),c=this.nside-v(r,this.nside)-1;return this.xyf2nest(h,c,l)}const o=Math.min(3,Math.floor(s)),a=s-o,h=Math.sin(e.theta),c=r<.99?this.nside*Math.sqrt(3*(1-r)):this.nside*h/Math.sqrt((1+r)/3),u=Math.min(this.nside-1,Math.floor(a*c)),d=Math.min(this.nside-1,Math.floor((1-a)*c));return i>=0?this.xyf2nest(this.nside-d-1,this.nside-u-1,o):this.xyf2nest(u,d,o+8)}pix2vec(e){return this.pix2ang(e).toVec3()}pix2ang(e,t=!1){const{z:i,phi:r}=this.pix2zphi(e),o=Math.acos(M(i,-1,1));return new s(null,t,o,r)}getBoundaries(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=.5/this.nside,o=(t+.5)/this.nside,a=(i+.5)/this.nside;return[this.faceLocalToVec3(o+s,a+s,r),this.faceLocalToVec3(o-s,a+s,r),this.faceLocalToVec3(o-s,a-s,r),this.faceLocalToVec3(o+s,a-s,r)]}getBoundariesWithStep(e,t){if(!Number.isInteger(t)||t<=0)throw new RangeError("step must be a positive integer.");const{ix:i,iy:r,face:s}=this.nest2xyf(e),o=.5/this.nside,a=(i+.5)/this.nside,n=(r+.5)/this.nside,l=1/(this.nside*t),h=new Array(4*t);for(let e=0;e<t;e+=1)h[e]=this.faceLocalToVec3(a+o-e*l,n+o,s),h[e+t]=this.faceLocalToVec3(a-o,n+o-e*l,s),h[e+2*t]=this.faceLocalToVec3(a-o+e*l,n-o,s),h[e+3*t]=this.faceLocalToVec3(a+o,n-o+e*l,s);return h}getPointsForXyfNoStep(e,t,i){this.assertXyf(e,t,i);const r=.5/this.nside,s=(e+.5)/this.nside,o=(t+.5)/this.nside;return[this.faceLocalToVec3(s+r,o+r,i),this.faceLocalToVec3(s-r,o+r,i),this.faceLocalToVec3(s-r,o-r,i),this.faceLocalToVec3(s+r,o-r,i)]}neighbours(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=new Int32Array(8),o=this.nside-1;if(t>0&&t<o&&i>0&&i<o)return s[0]=this.xyf2nest(t-1,i,r),s[1]=this.xyf2nest(t-1,i+1,r),s[2]=this.xyf2nest(t,i+1,r),s[3]=this.xyf2nest(t+1,i+1,r),s[4]=this.xyf2nest(t+1,i,r),s[5]=this.xyf2nest(t+1,i-1,r),s[6]=this.xyf2nest(t,i-1,r),s[7]=this.xyf2nest(t-1,i-1,r),s;for(let e=0;e<s.length;e+=1){let o=t+g[e],a=i+_[e],n=4;o<0?(o+=this.nside,n-=1):o>=this.nside&&(o-=this.nside,n+=1),a<0?(a+=this.nside,n-=3):a>=this.nside&&(a-=this.nside,n+=3);const l=p[n][r];if(l<0){s[e]=-1;continue}const h=f[n][Math.floor(r/4)];if((1&h)>0&&(o=this.nside-o-1),(2&h)>0&&(a=this.nside-a-1),(4&h)>0){const e=o;o=a,a=e}s[e]=this.xyf2nest(o,a,l)}return s}queryDiscInclusive(e,t,i){if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("pointing theta and phi must be finite radians.");if(!Number.isFinite(t)||t<0)throw new RangeError("radiusRad must be a non-negative finite number.");if(!Number.isInteger(i)||i<0||i>0&&!T(i))throw new RangeError("fact must be zero or a positive power of two.");const r=new a;if(t>=Math.PI)return r.appendRange(0,this.npix),r;const s=0!==i,o=s?Math.log2(i):0,n=Math.min(c,this.order+o),l=e.toVec3(),h=Math.cos(t),u=Math.sin(t),d=[],g=[],_=new Map,p=new Set,f=[];for(let e=0;e<=n;e+=1){const i=y(2**e),r=Math.cos(i),s=Math.sin(i);d[e]=t+i>Math.PI?-1:h*r-u*s,g[e]=t-i<0?1:h*r+u*s}for(let e=11;e>=0;e-=1)f.push({pixel:e,order:0});for(;f.length>0;){const e=f.pop();if(!e)break;let t=_.get(e.order);t||(t=e.order===this.order?this:new m(2**e.order),_.set(e.order,t));const i=t.pix2vec(e.pixel),r=l.dot(i);if(r+2e-7<=d[e.order])continue;const o=r<h?1:r<=g[e.order]?2:3;this.collectDiscPixel(e.order,n,o,e.pixel,s,f,p)}for(const e of[...p].sort((e,t)=>e-t))r.append(e);return r}queryPolygonInclusive(e,t){if(e.length<3)throw new RangeError("vertices must contain at least three points.");const i=e.map(e=>{if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("polygon vertex theta and phi must be finite radians.");return e.toVec3()}),r=[];let s=0,o=0;for(;o<i.length;){const e=i[o],t=i[(o+1)%i.length],a=i[(o+2)%i.length],n=I(A(e,t)),l=n.dot(a);if(0===o)s=l<0?-1:1;else if(s*l<0){i.splice((o+1)%i.length,1),r.splice(o,1),o=Math.max(0,o-1);continue}r[o]=E(n,s),o+=1}const a=new Array(r.length).fill(l);if(0!==t){const e=function(e){if(e.length<2)throw new RangeError("at least two points are required to find a containing circle.");let t=I(w(e[0],e[1])),i=e[0].dot(t);for(let r=2;r<e.length;r+=1)e[r].dot(t)<i&&({center:t,cosRadius:i}=F(e,r));return{center:t,cosRadius:i}}(i);r.push(e.center),a.push(Math.acos(M(e.cosRadius,-1,1)))}return this.queryMultiDisc(r,a,t)}queryMultiDisc(e,t,i){if(e.length!==t.length)throw new RangeError("normals and radiusRad must have the same length.");if(!Number.isInteger(i)||i<0||i>0&&!T(i))throw new RangeError("fact must be zero or a positive power of two.");const r=0!==i,s=r?Math.log2(i):0,o=Math.min(c,this.order+s),n=new a,l=new Set,h=[],u=new Map,d=[];for(const e of t)if(!Number.isFinite(e)||e<0)throw new RangeError("radiusRad values must be non-negative finite numbers.");for(let i=0;i<=o;i+=1){const r=y(2**i);d[i]=e.map((e,s)=>{const o=t[s];return[o+r>Math.PI?-1:Math.cos(o+r),0===i?Math.cos(o):d[0][s][1],o-r<0?1:Math.cos(o-r)]})}for(let e=11;e>=0;e-=1)h.push({pixel:e,order:0});for(;h.length>0;){const t=h.pop();if(!t)break;let i=u.get(t.order);i||(i=t.order===this.order?this:new m(2**t.order),u.set(t.order,i));const s=i.pix2vec(t.pixel);let a=3;for(let i=0;i<e.length&&a>0;i+=1){const r=s.dot(e[i]);for(let e=0;e<a;e+=1)r<d[t.order][i][e]&&(a=e)}a>0&&this.collectDiscPixel(t.order,o,a,t.pixel,r,h,l)}for(const e of[...l].sort((e,t)=>e-t))n.append(e);return n}assertPixel(e){if(!Number.isInteger(e)||e<0||e>=this.npix)throw new RangeError("pixel must be an integer in [0, npix).")}assertXyf(e,t,i){if(!Number.isInteger(i)||i<0||i>=12)throw new RangeError("face must be an integer in [0, 11].");if(!Number.isInteger(e)||e<0||e>=this.nside)throw new RangeError("x must be an integer in [0, nside).");if(!Number.isInteger(t)||t<0||t>=this.nside)throw new RangeError("y must be an integer in [0, nside).")}pix2zphi(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=1/(3*this.nside*this.nside),o=2/(3*this.nside),a=u[r]*this.nside-t-i-1;let n,h;a<this.nside?(n=a,h=1-n*n*s):a>3*this.nside?(n=4*this.nside-a,h=n*n*s-1):(n=this.nside,h=(2*this.nside-a)*o);const c=v(d[r]*n+t-i,8*n);return{z:h,phi:S(n===this.nside?.75*l*c*o:.5*l*c/n)}}faceLocalToVec3(e,t,i){const s=u[i]-e-t;let o,a;s<1?(o=s,a=1-o*o/3):s>3?(o=4-s,a=o*o/3-1):(o=1,a=(2-s)*n);const h=v(d[i]*o+e-t,8*o),c=o<=Number.EPSILON?0:.5*l*h/o,g=Math.sqrt(Math.max(0,(1-a)*(1+a)));return new r(g*Math.cos(c),g*Math.sin(c),a)}collectDiscPixel(e,t,i,r,s,o,a){if(0!==i)if(e<this.order)if(i>=3){const t=4**(this.order-e);for(let e=r*t;e<(r+1)*t;e+=1)a.add(e)}else P(o,r,e);else{if(e>this.order){const s=Math.floor(r/4**(e-this.order));return void(i>=2||e>=t?a.add(s):P(o,r,e))}i>=2?a.add(r):s&&(e<t?P(o,r,e):a.add(r))}}}function x(e){let t=0;for(let i=0;i<=c;i+=1)t+=Math.floor(e/2**i)%2*2**(2*i);return t}function b(e){let t=0;for(let i=0;i<=c;i+=1)t+=Math.floor(e/2**(2*i))%2*2**i;return t}function S(e){return(e%h+h)%h}function v(e,t){return(e%t+t)%t}function M(e,t,i){return Math.min(i,Math.max(t,e))}function T(e){return e>0&&2**Math.floor(Math.log2(e))===e}function y(e){const t=n,i=Math.PI/(4*e),s=Math.sqrt(.5555555555555556),o=new r(s*Math.cos(i),s*Math.sin(i),t),a=1-(1-1/e)**2/3,l=new r(Math.sqrt((1-a)*(1+a)),0,a);return Math.acos(M(o.dot(l),-1,1))}function P(e,t,i){for(let r=3;r>=0;r-=1)e.push({pixel:4*t+r,order:i+1})}function w(e,t){return new r(e.x+t.x,e.y+t.y,e.z+t.z)}function C(e,t){return new r(e.x-t.x,e.y-t.y,e.z-t.z)}function E(e,t){return new r(e.x*t,e.y*t,e.z*t)}function A(e,t){return new r(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)}function I(e){return e.normalize()}function F(e,t){let i=I(w(e[0],e[t])),r=e[0].dot(i);for(let s=1;s<t;s+=1)e[s].dot(i)<r&&({center:i,cosRadius:r}=R(e,s,t));return{center:i,cosRadius:r}}function R(e,t,i){let r=I(w(e[t],e[i])),s=e[t].dot(r);for(let o=0;o<t;o+=1)e[o].dot(r)<s&&(r=I(A(C(e[t],e[o]),C(e[i],e[o]))),s=e[o].dot(r),s<0&&(r=E(r,-1),s=-s));return{center:r,cosRadius:s}}},1677(e,t,i){"use strict";i.d(t,{FITSHeaderManager:()=>s,FITSParser:()=>b});class r{_key="";_value="";_comment="";constructor(e,t,i){this._key=e,this._value=t,this._comment=i}get key(){return this._key}get comment(){return this._comment}get value(){return this._value}}class s{static SIMPLE="SIMPLE";static BITPIX="BITPIX";static BZERO="BZERO";static BSCALE="BSCALE";static BLANK="BLANK";static NAXIS="NAXIS";static NAXIS1="NAXIS1";static NAXIS2="NAXIS2";static DATAMIN="DATAMIN";static DATAMAX="DATAMAX";static CRVAL1="CRVAL1";static CRVAL2="CRVAL2";static CTYPE1="CTYPE1";static CTYPE2="CTYPE2";static CRPIX1="CRPIX1";static CRPIX2="CRPIX2";static ORIGIN="ORIGIN";static COMMENT="COMMENT";static XTENSION="XTENSION";static PCOUNT="PCOUNT";static GCOUNT="GCOUNT";static TFIELDS="TFIELDS";static TFORM="TFORM";static TTYPE="TTYPE";static TUNIT="TUNIT";static TSCAL="TSCAL";static TZERO="TZERO";static TNULL="TNULL";static TBCOL="TBCOL";items=[];constructor(e=!0){e&&(this.items[0]=new r(s.SIMPLE,"T",""),this.items[1]=new r(s.BITPIX,"",""),this.items[2]=new r(s.NAXIS,2,""),this.items[3]=new r(s.NAXIS1,"",""),this.items[4]=new r(s.NAXIS2,"",""))}insert(e){e.key===s.SIMPLE?this.items[0]=e:e.key===s.BITPIX?this.items[1]=e:e.key===s.NAXIS?this.items[2]=e:e.key===s.NAXIS1?this.items[3]=e:e.key===s.NAXIS2?this.items[4]=e:this.items.push(e)}getItems(){return this.items}remove(e){this.items=this.items.filter(t=>t.key!==e)}findById(e){const t=this.items.find(t=>t.key===e);return t||null}static tableFieldKey(e,t){if(!Number.isInteger(t)||t<1)throw new RangeError(`FITS table field index must be >= 1, received ${t}.`);return`${e}${t}`}static naxisKey(e){if(!Number.isInteger(e)||e<1)throw new RangeError(`FITS axis must be a positive integer, received ${e}.`);return`NAXIS${e}`}static getFITSItemStringValue(e,t){const i=e.findById(t);return i?String(i.value).trim().replace(/^'/,"").replace(/'$/,"").trim():null}}var o=i(7223);class a{static BLOCK_SIZE=2880;static CARD_SIZE=80;static INTEGER_KEYWORDS=new Set(["BITPIX","NAXIS","PCOUNT","GCOUNT"]);static LOGICAL_KEYWORDS=new Set(["SIMPLE","EXTEND"]);static serialize(e,t){const i=e.getItems(),r=new Map(i.map(e=>[e.key.toUpperCase(),e])),s=[];return a.appendMandatoryCards(s,r,t),a.appendRemainingCards(s,i),s.push(a.card80("END")),a.encodeAndPad(s)}static appendMandatoryCards(e,t,i){if(i){const i=t.get("SIMPLE");if(!i)throw new Error("Missing mandatory SIMPLE card in Primary HDU");e.push(...a.makeKeywordWithComment("SIMPLE",i.value,i.comment))}else{const i=t.get("XTENSION");if(!i)throw new Error("Missing mandatory XTENSION card in extension HDU");e.push(...a.makeKeywordWithComment("XTENSION",i.value,i.comment))}const r=t.get("BITPIX");if(!r)throw new Error("Missing mandatory BITPIX card");e.push(...a.makeKeywordWithComment("BITPIX",r.value,r.comment));const s=t.get("NAXIS");if(!s)throw new Error("Missing mandatory NAXIS card");const o=Number(s.value);if(!Number.isInteger(o)||o<0)throw new Error(`Invalid NAXIS value: ${s.value}`);e.push(...a.makeKeywordWithComment("NAXIS",o,s.comment));for(let i=1;i<=o;i++){const r=`NAXIS${i}`,s=t.get(r);if(!s)throw new Error(`Missing mandatory ${r} card`);e.push(...a.makeKeywordWithComment(r,s.value,s.comment))}if(!i){const i=t.get("PCOUNT"),r=t.get("GCOUNT");if(!i)throw new Error("Missing mandatory PCOUNT card in extension HDU");if(!r)throw new Error("Missing mandatory GCOUNT card in extension HDU");e.push(...a.makeKeywordWithComment("PCOUNT",i.value,i.comment)),e.push(...a.makeKeywordWithComment("GCOUNT",r.value,r.comment))}if(i){const i=t.get("EXTEND");i&&e.push(...a.makeKeywordWithComment("EXTEND",i.value,i.comment))}}static appendRemainingCards(e,t){for(const i of t){const t=i.key.toUpperCase();"SIMPLE"===t||"XTENSION"===t||"BITPIX"===t||"NAXIS"===t||/^NAXIS\d+$/.test(t)||"PCOUNT"===t||"GCOUNT"===t||"EXTEND"===t||"END"===t||e.push(...a.makeKeywordWithComment(i.key,i.value,i.comment))}}static makeKeywordWithComment(e,t,i){const r=e.toUpperCase();if("END"===r)return[a.card80("END")];if("COMMENT"===r||"HISTORY"===r)return a.makeCommentCards(r,String(t??i??""));let s=a.keyword(r)+a.valueField20(r,t);if(!i||0===i.length)return[a.card80(s)];const o=` / ${i}`,n=a.CARD_SIZE-s.length;if(n<=0)return[a.card80(s),...a.makeCommentCards("COMMENT",i)];s+=o.slice(0,n);const l=o.slice(n).replace(/^\s*\/\s*/,"");return 0===l.length?[a.card80(s)]:[a.card80(s),...a.makeCommentCards("COMMENT",l)]}static makeCommentCards(e,t){const i=a.keyword(e),r=a.CARD_SIZE-i.length,s=String(t??"");if(0===s.length)return[a.card80(i)];const o=[];for(let e=0;e<s.length;e+=r)o.push(a.card80(i+s.slice(e,e+r)));return o}static valueField20(e,t){if(a.LOGICAL_KEYWORDS.has(e)){return`= ${(!0===t||"T"===t||"t"===t?"T":"F").padStart(20," ")}`}if(a.INTEGER_KEYWORDS.has(e)||/^NAXIS\d+$/.test(e)){const i=Number(t);if(!Number.isFinite(i)||!Number.isInteger(i))throw new Error(`FITS header: ${e} must be an integer, got ${t}`);return`= ${String(i).padStart(20," ")}`}if("number"==typeof t){let e=Number.isInteger(t)?String(t):t.toExponential(10).replace("e","E");return e.length>20&&(e=t.toExponential(8).replace("e","E")),`= ${e.padStart(20," ")}`}return"string"==typeof t?`= ${a.quoteFitsString(t)}`:""}static quoteFitsString(e){return`'${e.replace(/^'+|'+$/g,"").replace(/'/g,"''")}'`}static keyword(e){return(e??"").toUpperCase().padEnd(8," ").slice(0,8)}static card80(e){return e.length>=a.CARD_SIZE?e.slice(0,a.CARD_SIZE):e.padEnd(a.CARD_SIZE," ")}static encodeAndPad(e){let t=e.join("");const i=t.length%a.BLOCK_SIZE;return 0!==i&&(t+=" ".repeat(a.BLOCK_SIZE-i)),(new TextEncoder).encode(t)}}class n{static createFITS(e){const t=a.serialize(e.header,!0),i=this.createData(e.data,e.header),r=new Uint8Array(t.length+i.length);return r.set(t,0),r.set(i,t.length),r}static createHDU(e,t){const i=a.serialize(e.header,t),r=e.rawData??new Uint8Array(0);if(r.byteLength!==e.dataByteLength)throw new Error(`HDU payload length mismatch: rawData contains ${r.byteLength} bytes, but dataByteLength=${e.dataByteLength}.`);const s=n.padData(r),o=new Uint8Array(i.byteLength+s.byteLength);return o.set(i,0),o.set(s,i.byteLength),o}static padData(e){if(0===e.byteLength)return new Uint8Array(0);const t=e.byteLength%2880;if(0===t)return e.slice();const i=new Uint8Array(e.byteLength+(2880-t));return i.set(e),i}static createData(e,t){const i=e.reduce((e,t)=>e+t.length,0),r=Math.abs(Number(t.findById("BITPIX")?.value??0)),s=Number(t.findById("NAXIS")?.value??0);let o=1;for(let e=1;e<=s;e++)o*=Number(t.findById(`NAXIS${e}`)?.value??0);const a=s>0?o*(r/8):0;if(a&&a!==i)throw new Error(`Data length ${i} does not match header expectation ${a} (BITPIX=${r}, NAXIS=${s})`);let l=new Uint8Array(i),h=0;for(const t of e)l.set(t,h),h+=t.length;return n.padData(l)}static createFITSFile(e){if(0===e.length)throw new Error("Cannot write an empty FITSFile.");if(null===e.primaryHDU)throw new Error("FITSFile must start with a PrimaryHDU.");const t=e.hdus.map((e,t)=>n.createHDU(e,0===t)),i=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(i);let s=0;for(const e of t)r.set(e,s),s+=e.byteLength;return r}static writeFITSFileModel(e,t){const i=n.createFITSFile(e);o.writeFileSync(t,i)}static writeFITSFile(e,t){const i=n.createFITS(e);o.writeFileSync(t,i)}}class l{static CARD_SIZE=80;static BLOCK_SIZE=2880;static getFITSItemStringValue(e,t){const i=e.findById(t);return i?String(i.value).trim().replace(/^'/,"").replace(/'$/,"").trim():null}static getFITSItemValue(e,t){const i=e.findById(t);if(!i)return null;const r=Number(i.value);return Number.isNaN(r)?null:r}static getHeaderByteLength(e,t=0){const i=new TextDecoder("ascii");for(let r=t;r+l.CARD_SIZE<=e.byteLength;r+=l.CARD_SIZE){if("END"===i.decode(e.subarray(r,r+8)).trim()){const e=r+l.CARD_SIZE-t;return Math.ceil(e/l.BLOCK_SIZE)*l.BLOCK_SIZE}}throw new Error("Invalid FITS header: END card not found.")}static parse(e,t=0){const i=new TextDecoder("ascii"),o=l.getHeaderByteLength(e,t),a=new s(!1);for(let s=t;s<t+o;s+=l.CARD_SIZE){const t=i.decode(e.subarray(s,s+l.CARD_SIZE)),o=t.slice(0,8).trim();if("END"===o)break;if(!o)continue;let n,h="";const c=t.slice(10).trim().split("/")[0].trim();n=Number.isNaN(Number(c))?c:Number(c),t.includes("/")&&(h=t.slice(10).trim().split("/")[1]?.trim()??""),a.insert(new r(o,n,h))}return a}}class h{static getShape(e){const t=l.getFITSItemValue(e,s.NAXIS);if(null===t)throw new Error("NAXIS not defined.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid FITS NAXIS value: ${t}`);const i=[];for(let r=1;r<=t;r++){const t=l.getFITSItemValue(e,s.naxisKey(r));if(null===t)throw new Error(`NAXIS${r} not defined.`);i.push(t)}return i}static getElementCount(e){return 0===e.length?0:e.reduce((e,t)=>e*t,1)}}class c{static SUPPORTED_BITPIX=new Set([8,16,32,64,-32,-64]);static assertSupportedBITPIX(e){if(!c.SUPPORTED_BITPIX.has(e))throw new Error(`Unsupported FITS BITPIX value: ${e}`)}static extractPixelFromView(e,t,i){switch(i){case 8:return e.getUint8(t);case 16:return e.getInt16(t,!1);case 32:return e.getInt32(t,!1);case-32:return e.getFloat32(t,!1);case-64:return e.getFloat64(t,!1);case 64:{const i=e.getBigInt64(t,!1),r=Number(i);if(!Number.isSafeInteger(r))throw new RangeError(`BITPIX=64 value ${i} cannot be represented exactly as a JavaScript number.`);return r}default:throw new Error(`Unsupported FITS BITPIX value: ${i}`)}}static computePhysicalMinAndMax(e,t){const i=l.getFITSItemValue(e,s.BITPIX);if(null===i)return null;c.assertSupportedBITPIX(i);if(0===h.getShape(e).length||0===t.byteLength)return e;const o=e.findById(s.DATAMIN),a=e.findById(s.DATAMAX);if(null===o||null===a)try{const[i,n]=c.computePhysicalValues(t,e);null===o&&null!==i&&e.insert(new r(s.DATAMIN,i,"computed by jsfitsio")),null===a&&null!==n&&e.insert(new r(s.DATAMAX,n,"computed by jsfitsio"))}catch(t){if(64===i&&t instanceof RangeError)return e;throw t}return e}static createTypedArray(e,t){c.assertSupportedBITPIX(t);const i=Math.abs(t)/8;if(e.byteLength%i!==0)throw new Error(`Payload byte length ${e.byteLength} is not aligned with BITPIX=${t}.`);const r=e.byteLength/i,s=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case 8:return e.slice();case 16:{const e=new Int16Array(r);for(let t=0;t<r;t++)e[t]=s.getInt16(2*t,!1);return e}case 32:{const e=new Int32Array(r);for(let t=0;t<r;t++)e[t]=s.getInt32(4*t,!1);return e}case 64:{const e=new BigInt64Array(r);for(let t=0;t<r;t++)e[t]=s.getBigInt64(8*t,!1);return e}case-32:{const e=new Float32Array(r);for(let t=0;t<r;t++)e[t]=s.getFloat32(4*t,!1);return e}case-64:{const e=new Float64Array(r);for(let t=0;t<r;t++)e[t]=s.getFloat64(8*t,!1);return e}default:throw new Error(`Unsupported FITS BITPIX value: ${t}`)}}static computePhysicalValues(e,t){const i=l.getFITSItemValue(t,s.BITPIX);if(null===i)return[null,null];c.assertSupportedBITPIX(i);const r=h.getShape(t),o=h.getElementCount(r);if(0===o)return[null,null];const a=l.getFITSItemValue(t,s.BLANK),n=l.getFITSItemValue(t,s.BZERO)??0,u=l.getFITSItemValue(t,s.BSCALE)??1,d=Math.abs(i)/8,g=o*d;if(e.byteLength<g)throw new Error(`FITS payload is too short: expected ${g} bytes, received ${e.byteLength}.`);const _=new DataView(e.buffer,e.byteOffset,e.byteLength);let p=null,f=null;for(let e=0;e<o;e++){const t=c.extractPixelFromView(_,e*d,i);if(i>0&&null!==a&&t===a)continue;const r=c.pixel2physicalValue(t,u,n);Number.isNaN(r)||((null===p||r<p)&&(p=r),(null===f||r>f)&&(f=r))}return[p,f]}static pixel2physicalValue(e,t,i){if(null===i||null===t)throw new Error("Either BZERO or BSCALE is null");return i+t*e}static extractPixelValue(e,t,i){c.assertSupportedBITPIX(i);const r=new DataView(e.buffer,e.byteOffset,e.byteLength);return c.extractPixelFromView(r,t,i)}}class u{header;rawData;dataOffset;dataByteLength;constructor(e,t,i,r){this.header=e,this.rawData=t,this.dataOffset=i,this.dataByteLength=r}}class d extends u{bitpix;shape;typedData;type="IMAGE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.bitpix=s,this.shape=o,this.typedData=a}get naxis(){return this.shape.length}get elementCount(){return 0===this.shape.length?0:this.shape.reduce((e,t)=>e*t,1)}}class g extends d{type="PRIMARY";constructor(e,t,i,r,s,o,a){super(e,t,i,r,s,o,a)}}class _{_hdus;constructor(e=[]){this._hdus=[...e]}get hdus(){return this._hdus}get length(){return this._hdus.length}get primaryHDU(){const e=this._hdus[0];return e instanceof g?e:null}getHDU(e){return this._hdus[e]??null}addHDU(e){this._hdus.push(e)}}class p extends u{rowByteLength;rowCount;columns;type="BINTABLE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.rowByteLength=s,this.rowCount=o,this.columns=a}get columnCount(){return this.columns.length}getRowView(e){if(e<0||e>=this.rowCount)throw new RangeError(`Invalid row index ${e}.`);const t=e*this.rowByteLength;return new DataView(this.rawData.buffer,this.rawData.byteOffset+t,this.rowByteLength)}getRow(e){return this.columns.map((t,i)=>this.getCell(e,i))}getCell(e,t){const i=this.resolveColumn(t),r=this.getRowView(e),s=i.byteOffset,o=i.repeat;switch(i.type){case"CHAR":{const e=new Uint8Array(r.buffer,r.byteOffset+s,i.byteWidth);return new TextDecoder("ascii").decode(e).replace(/\s+$/,"")}case"LOGICAL":{const e=[];for(let t=0;t<o;t++){const i=String.fromCharCode(r.getUint8(s+t));e.push("T"===i)}return 1===o?e[0]:e}case"UINT8":{const e=[];for(let t=0;t<o;t++){const o=r.getUint8(s+t);e.push(this.applyNumericScaling(o,i.scale,i.zero))}return 1===o?e[0]:e}case"INT16":return this.readNumericColumn(r,s,o,2,(e,t)=>e.getInt16(t,!1),i.scale,i.zero,i.nullValue);case"INT32":return this.readNumericColumn(r,s,o,4,(e,t)=>e.getInt32(t,!1),i.scale,i.zero,i.nullValue);case"INT64":{const e=[];for(let t=0;t<o;t++){const i=r.getBigInt64(s+8*t,!1);e.push(i)}return 1===o?e[0]:e}case"FLOAT32":return this.readNumericColumn(r,s,o,4,(e,t)=>e.getFloat32(t,!1),i.scale,i.zero,null);case"FLOAT64":return this.readNumericColumn(r,s,o,8,(e,t)=>e.getFloat64(t,!1),i.scale,i.zero,null);case"COMPLEX64":{const e=[];for(let t=0;t<o;t++){const i=s+8*t;e.push({real:r.getFloat32(i,!1),imaginary:r.getFloat32(i+4,!1)})}return 1===o?e[0]:e}case"COMPLEX128":{const e=[];for(let t=0;t<o;t++){const i=s+16*t;e.push({real:r.getFloat64(i,!1),imaginary:r.getFloat64(i+8,!1)})}return 1===o?e[0]:e}case"BIT":return new Uint8Array(r.buffer,r.byteOffset+s,i.byteWidth).slice();default:throw new Error(`Unsupported BINTABLE column type: ${i.type}`)}}readNumericColumn(e,t,i,r,s,o,a,n){const l=[];for(let h=0;h<i;h++){const i=s(e,t+h*r);null===n||i!==n?l.push(this.applyNumericScaling(i,o,a)):l.push(null)}return 1===i?l[0]:l}applyNumericScaling(e,t,i){return i+t*e}resolveColumn(e){if("number"==typeof e){if(!Number.isInteger(e)||e<0||e>=this.columns.length)throw new RangeError(`Invalid column index ${e}.`);return this.columns[e]}const t=this.columns.find(t=>t.name===e);if(!t)throw new Error(`BINTABLE column '${e}' not found.`);return t}}class f{static parseTFORM(e){const t=e.trim().replace(/^'/,"").replace(/'$/,"").trim().toUpperCase().match(/^(\d*)([LXBIJKAEDCM])$/);if(!t)throw new Error(`Unsupported FITS TFORM value: ${e}`);const i=t[1]?Number(t[1]):1,r=t[2],s=f.bytesPerType(r);return{repeat:i,code:r,byteWidth:"X"===r?Math.ceil(i/8):i*s}}static bytesPerType(e){switch(e){case"L":case"B":case"A":return 1;case"I":return 2;case"J":case"E":return 4;case"K":case"D":case"C":return 8;case"M":return 16;case"X":return 0;default:throw new Error(`Unsupported FITS binary table type: ${e}`)}}}class m extends u{rowByteLength;rowCount;columns;type="TABLE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.rowByteLength=s,this.rowCount=o,this.columns=a}get columnCount(){return this.columns.length}getRowView(e){if(!Number.isInteger(e)||e<0||e>=this.rowCount)throw new RangeError(`Invalid row index ${e}.`);const t=e*this.rowByteLength;return this.rawData.subarray(t,t+this.rowByteLength)}getRowText(e){return new TextDecoder("ascii").decode(this.getRowView(e))}resolveColumn(e){if("number"==typeof e){if(!Number.isInteger(e)||e<0||e>=this.columns.length)throw new RangeError(`Invalid column index ${e}.`);return this.columns[e]}const t=this.columns.find(t=>t.name===e);if(!t)throw new Error(`ASCII TABLE column '${e}' not found.`);return t}getCell(e,t){const i=this.resolveColumn(t),r=this.getRowView(e).subarray(i.byteOffset,i.byteOffset+i.width),s=new TextDecoder("ascii").decode(r),o=s.trim();if(0===o.length)return"CHAR"===i.type?"":null;switch(i.type){case"CHAR":return s.replace(/\s+$/,"");case"INTEGER":{const e=Number.parseInt(o,10);return Number.isNaN(e)?null:e}case"FLOAT":case"EXPONENTIAL":case"DOUBLE":{const e=o.replace(/[dD]/,"E"),t=Number.parseFloat(e);return Number.isNaN(t)?null:t}default:throw new Error(`Unsupported ASCII TABLE column type: ${i.type}`)}}getRow(e){return this.columns.map((t,i)=>this.getCell(e,i))}}class x{static parseTFORM(e){const t=e.trim().replace(/^'/,"").replace(/'$/,"").trim().toUpperCase().match(/^([AIFED])(\d+)(?:\.(\d+))?$/);if(!t)throw new Error(`Unsupported FITS ASCII table TFORM value: ${e}`);const i=t[1],r=Number(t[2]),s=void 0!==t[3]?Number(t[3]):null;if(!Number.isInteger(r)||r<=0)throw new Error(`Invalid FITS ASCII table field width: ${r}`);if("A"===i||"I"===i){if(null!==s)throw new Error(`TFORM ${e} must not specify decimal places.`)}else if(null===s)throw new Error(`TFORM ${e} requires decimal places.`);return{code:i,width:r,decimals:s}}}class b{static async loadFITS(e,t={}){const i=await b.loadFITSFile(e,t);if(null===i)return null;const r=i.primaryHDU;if(null===r||null===r.rawData)return null;if(2!==h.getShape(r.header).length)throw new Error("Legacy loadFITS() supports only 2D FITS images. Use loadFITSFile() for N-dimensional images.");return{header:r.header,data:b.createMatrix(r.rawData,r.header)}}static async loadFITSFile(e,t={}){const i=await b.getFile(e);return 0===i.byteLength?null:b.processFITSFile(i,t)}static processFITSFile(e,t){const i=new _;let r=0,s=0;for(;r<e.byteLength&&!b.isPaddingOnly(e,r);){const o=l.parse(e,r),a=r+l.getHeaderByteLength(e,r);switch(b.getHDUType(o,s)){case"PRIMARY":case"IMAGE":{const n=b.getImagePayloadByteLength(o);if(a+n>e.byteLength)throw new Error(`Invalid FITS HDU ${s}: expected ${n} payload bytes at offset ${a}, but only `+(e.byteLength-a)+" remain.");const l=e.subarray(a,a+n),h=b.createImageHDU(o,l,a,n,0===s,t);i.addHDU(h);r=a+b.getPaddedByteLength(n);break}case"BINTABLE":{const t=b.getBinaryTablePayloadByteLength(o);if(a+t>e.byteLength)throw new Error(`Invalid BINTABLE HDU ${s}.`);const n=e.subarray(a,a+t),l=b.createBinaryTableHDU(o,n,a,t);i.addHDU(l),r=a+b.getPaddedByteLength(t);break}case"TABLE":{const t=b.getAsciiTablePayloadByteLength(o);if(a+t>e.byteLength)throw new Error(`Invalid ASCII TABLE HDU ${s}: expected ${t} payload bytes at offset ${a}, but only `+(e.byteLength-a)+" remain.");const n=e.subarray(a,a+t),l=b.createAsciiTableHDU(o,n,a,t);i.addHDU(l),r=a+b.getPaddedByteLength(t);break}default:throw new Error(`Unsupported FITS HDU type at index ${s}.`)}s++}return i}static getPaddedByteLength(e){return 0===e?0:Math.ceil(e/l.BLOCK_SIZE)*l.BLOCK_SIZE}static isPaddingOnly(e,t){for(let i=t;i<e.byteLength;i++){const t=e[i];if(0!==t&&32!==t)return!1}return!0}static getHDUType(e,t){if(0===t)return"PRIMARY";const i=l.getFITSItemStringValue(e,s.XTENSION);if(null===i)return"UNKNOWN";switch(i.toUpperCase()){case"IMAGE":return"IMAGE";case"BINTABLE":return"BINTABLE";case"TABLE":return"TABLE";default:return"UNKNOWN"}}static createImageHDU(e,t,i,r,o,a){const n=a.computeDataMinMax?c.computePhysicalMinAndMax(e,t)??e:e,u=l.getFITSItemValue(n,s.BITPIX);if(null===u)throw new Error("BITPIX not defined.");const _=h.getShape(n),p=c.createTypedArray(t,u);return o?new g(n,t,i,r,u,_,p):new d(n,t,i,r,u,_,p)}static getImagePayloadByteLength(e){const t=l.getFITSItemValue(e,s.BITPIX);if(null===t)throw new Error("BITPIX not defined.");c.assertSupportedBITPIX(t);const i=h.getShape(e);if(0===i.length)return 0;return i.reduce((e,t)=>e*t,1)*(Math.abs(t)/8)}static getBinaryTablePayloadByteLength(e){const t=l.getFITSItemValue(e,s.NAXIS1),i=l.getFITSItemValue(e,s.NAXIS2),r=l.getFITSItemValue(e,s.PCOUNT)??0;if(null===t||null===i)throw new Error("BINTABLE requires NAXIS1 and NAXIS2.");return t*i+r}static getBinaryTableColumns(e){const t=l.getFITSItemValue(e,s.TFIELDS);if(null===t)throw new Error("BINTABLE requires TFIELDS.");const i=[];let r=0;for(let o=1;o<=t;o++){const t=l.getFITSItemStringValue(e,s.tableFieldKey("TFORM",o));if(null===t)throw new Error(`Missing TFORM${o}.`);const a=f.parseTFORM(t),n=l.getFITSItemStringValue(e,s.tableFieldKey("TTYPE",o)),h=l.getFITSItemStringValue(e,s.tableFieldKey("TUNIT",o));i.push({index:o,name:n,format:t,type:b.mapBinaryType(a.code),repeat:a.repeat,byteOffset:r,byteWidth:a.byteWidth,unit:h,scale:l.getFITSItemValue(e,s.tableFieldKey("TSCAL",o))??1,zero:l.getFITSItemValue(e,s.tableFieldKey("TZERO",o))??0,nullValue:l.getFITSItemValue(e,s.tableFieldKey("TNULL",o))}),r+=a.byteWidth}return i}static mapBinaryType(e){switch(e.toUpperCase()){case"L":return"LOGICAL";case"X":return"BIT";case"B":return"UINT8";case"I":return"INT16";case"J":return"INT32";case"K":return"INT64";case"A":return"CHAR";case"E":return"FLOAT32";case"D":return"FLOAT64";case"C":return"COMPLEX64";case"M":return"COMPLEX128";default:return"UNKNOWN"}}static createBinaryTableHDU(e,t,i,r){const o=l.getFITSItemValue(e,s.NAXIS1),a=l.getFITSItemValue(e,s.NAXIS2);if(null===o||null===a)throw new Error("Invalid BINTABLE header.");const n=b.getBinaryTableColumns(e),h=n.reduce((e,t)=>e+t.byteWidth,0);if(h!==o)throw new Error(`BINTABLE columns occupy ${h} bytes per row, but NAXIS1=${o}.`);return new p(e,t,i,r,o,a,n)}static getAsciiTablePayloadByteLength(e){const t=l.getFITSItemValue(e,s.NAXIS1),i=l.getFITSItemValue(e,s.NAXIS2);if(null===t||null===i)throw new Error("ASCII TABLE requires NAXIS1 and NAXIS2.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid ASCII TABLE NAXIS1=${t}.`);if(!Number.isInteger(i)||i<0)throw new Error(`Invalid ASCII TABLE NAXIS2=${i}.`);const r=l.getFITSItemValue(e,s.PCOUNT)??0;if(0!==r)throw new Error(`ASCII TABLE requires PCOUNT=0, received ${r}.`);return t*i}static mapAsciiType(e){switch(e.toUpperCase()){case"A":return"CHAR";case"I":return"INTEGER";case"F":return"FLOAT";case"E":return"EXPONENTIAL";case"D":return"DOUBLE";default:return"UNKNOWN"}}static getAsciiTableColumns(e){const t=l.getFITSItemValue(e,s.TFIELDS);if(null===t)throw new Error("ASCII TABLE requires TFIELDS.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid ASCII TABLE TFIELDS=${t}.`);const i=[];for(let r=1;r<=t;r++){const t=l.getFITSItemStringValue(e,s.tableFieldKey("TFORM",r));if(null===t)throw new Error(`Missing TFORM${r}.`);const o=l.getFITSItemValue(e,s.tableFieldKey("TBCOL",r));if(null===o)throw new Error(`Missing TBCOL${r}.`);if(!Number.isInteger(o)||o<1)throw new Error(`Invalid TBCOL${r}=${o}.`);const a=x.parseTFORM(t),n=l.getFITSItemStringValue(e,s.tableFieldKey("TTYPE",r)),h=l.getFITSItemStringValue(e,s.tableFieldKey("TUNIT",r));i.push({index:r,name:n,format:t,type:b.mapAsciiType(a.code),startColumn:o,byteOffset:o-1,width:a.width,decimals:a.decimals,unit:h})}return i}static validateAsciiTableColumns(e,t){for(const i of e){const e=i.byteOffset+i.width;if(e>t)throw new Error(`ASCII TABLE column ${i.index} extends to byte ${e}, but NAXIS1=${t}.`)}}static createAsciiTableHDU(e,t,i,r){const o=l.getFITSItemValue(e,s.NAXIS1),a=l.getFITSItemValue(e,s.NAXIS2);if(null===o||null===a)throw new Error("Invalid ASCII TABLE header.");const n=b.getAsciiTableColumns(e);return b.validateAsciiTableColumns(n,o),new m(e,t,i,r,o,a,n)}static createMatrix(e,t){const i=l.getFITSItemValue(t,s.NAXIS1);if(null===i)throw new Error("NAXIS1 not defined.");const r=l.getFITSItemValue(t,s.NAXIS2);if(null===r)throw new Error("NAXIS2 not defined.");const o=l.getFITSItemValue(t,s.BITPIX);if(null===o)throw new Error("BITPIX not defined.");const a=Math.abs(o/8),n=[];for(let t=0;t<r;t++)n.push(e.slice(t*i*a,(t+1)*i*a));return n}static saveFITSLocally(e,t){return n.writeFITSFile(e,t)}static async getFile(e){if(e.substring(0,5).toLowerCase().includes("http")){const t=await i.e(911).then(i.bind(i,1911)),r=await t.getFile(e);if(r?.byteLength){return new Uint8Array(r)}return new Uint8Array(0)}{const t=await i.e(64).then(i.bind(i,7064)),r=await t.getLocalFile(e);if(r?.length){return new Uint8Array(r)}return new Uint8Array(0)}}}}};const t={};function i(r){const s=t[r];if(void 0!==s)return s.exports;const o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,i),o.exports}return i.m=e,i.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var s=t[r++],o=t[r++];i.o(e,s)?0===o&&r++:0===o?Object.defineProperty(e,s,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,s,{enumerable:!0,get:o})}else for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>e+".astroviewer.min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e={},t="astroviewer:";i.l=(r,s,o,a)=>{if(e[r])return void e[r].push(s);let n,l;if(void 0!==o){const e=document.getElementsByTagName("script");for(var h=0;h<e.length;h++){const i=e[h];if(i.getAttribute("src")==r||i.getAttribute("data-webpack")==t+o){n=i;break}}}n||(l=!0,n=document.createElement("script"),n.charset="utf-8",i.nc&&n.setAttribute("nonce",i.nc),n.setAttribute("data-webpack",t+o),n.src=r),e[r]=[s];const c=(t,i)=>{n.onerror=n.onload=null,clearTimeout(u);const s=e[r];if(delete e[r],n.parentNode?.removeChild(n),s?.forEach(e=>e(i)),t)return t(i)},u=setTimeout(c.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=c.bind(null,n.onerror),n.onload=c.bind(null,n.onload),l&&document.head.appendChild(n)}})(),i.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{let e;i.g.importScripts&&(e=i.g.location+"");const t=i.g.document;if(!e&&t&&("SCRIPT"===t.currentScript?.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){const i=t.getElementsByTagName("script");if(i.length){let t=i.length-1;for(;t>-1&&(!e||!/^http(s?):/.test(e));)e=i[t--].src}}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{const e={792:0};i.f.j=(t,r)=>{let s=i.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else{const o=new Promise((i,r)=>s=e[t]=[i,r]);r.push(s[2]=o);const a=i.p+i.u(t),n=new Error,l=r=>{if(i.o(e,t)&&(s=e[t],0!==s&&(e[t]=void 0),s)){const e=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;n.message="Loading chunk "+t+" failed.\n("+e+": "+i+")",n.name="ChunkLoadError",n.type=e,n.request=i,n.event=r,s[1](n)}};i.l(a,l,"chunk-"+t,t)}};const t=(t,r)=>{let[s,o,a]=r;var n,l,h=0;if(s.some(t=>0!==e[t])){for(n in o)i.o(o,n)&&(i.m[n]=o[n]);if(a)a(i)}for(t&&t(r);h<s.length;h++)l=s[h],i.o(e,l)&&e[l]&&e[l][0](),e[l]=0},r=self.webpackChunkastroviewer=self.webpackChunkastroviewer||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),i(1229)})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("astroviewer",[],t):"object"==typeof exports?exports.astroviewer=t():e.astroviewer=t()}(self,()=>(()=>{var e={3890(e,t,i){"use strict";i.d(t,{mat4:()=>r,vec3:()=>s,vec4:()=>o});var r={};i.r(r),i.d(r,{clone:()=>h,create:()=>l,fromValues:()=>c,identity:()=>d,invert:()=>g,multiply:()=>_,perspective:()=>m,rotate:()=>f,set:()=>u,targetTo:()=>S,translate:()=>p});var s={};i.r(s),i.d(s,{add:()=>y,clone:()=>v,create:()=>x,cross:()=>I,dot:()=>A,fromValues:()=>M,length:()=>b,normalize:()=>E,scale:()=>w,scaleAndAdd:()=>C,set:()=>T,subtract:()=>P,transformMat4:()=>F});var o={};i.r(o),i.d(o,{create:()=>L,fromValues:()=>D,transformMat4:()=>B});var a=1e-6,n="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI,Math.PI;function l(){var e=new n(16);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function h(e){var t=new n(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function c(e,t,i,r,s,o,a,l,h,c,u,d,g,_,p,f){var m=new n(16);return m[0]=e,m[1]=t,m[2]=i,m[3]=r,m[4]=s,m[5]=o,m[6]=a,m[7]=l,m[8]=h,m[9]=c,m[10]=u,m[11]=d,m[12]=g,m[13]=_,m[14]=p,m[15]=f,m}function u(e,t,i,r,s,o,a,n,l,h,c,u,d,g,_,p,f){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=o,e[5]=a,e[6]=n,e[7]=l,e[8]=h,e[9]=c,e[10]=u,e[11]=d,e[12]=g,e[13]=_,e[14]=p,e[15]=f,e}function d(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function g(e,t){var i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],n=t[5],l=t[6],h=t[7],c=t[8],u=t[9],d=t[10],g=t[11],_=t[12],p=t[13],f=t[14],m=t[15],S=i*n-r*a,x=i*l-s*a,v=i*h-o*a,b=r*l-s*n,M=r*h-o*n,T=s*h-o*l,y=c*p-u*_,P=c*f-d*_,w=c*m-g*_,C=u*f-d*p,E=u*m-g*p,A=d*m-g*f,I=S*A-x*E+v*C+b*w-M*P+T*y;return I?(I=1/I,e[0]=(n*A-l*E+h*C)*I,e[1]=(s*E-r*A-o*C)*I,e[2]=(p*T-f*M+m*b)*I,e[3]=(d*M-u*T-g*b)*I,e[4]=(l*w-a*A-h*P)*I,e[5]=(i*A-s*w+o*P)*I,e[6]=(f*v-_*T-m*x)*I,e[7]=(c*T-d*v+g*x)*I,e[8]=(a*E-n*w+h*y)*I,e[9]=(r*w-i*E-o*y)*I,e[10]=(_*M-p*v+m*S)*I,e[11]=(u*v-c*M-g*S)*I,e[12]=(n*P-a*C-l*y)*I,e[13]=(i*C-r*P+s*y)*I,e[14]=(p*x-_*b-f*S)*I,e[15]=(c*b-u*x+d*S)*I,e):null}function _(e,t,i){var r=t[0],s=t[1],o=t[2],a=t[3],n=t[4],l=t[5],h=t[6],c=t[7],u=t[8],d=t[9],g=t[10],_=t[11],p=t[12],f=t[13],m=t[14],S=t[15],x=i[0],v=i[1],b=i[2],M=i[3];return e[0]=x*r+v*n+b*u+M*p,e[1]=x*s+v*l+b*d+M*f,e[2]=x*o+v*h+b*g+M*m,e[3]=x*a+v*c+b*_+M*S,x=i[4],v=i[5],b=i[6],M=i[7],e[4]=x*r+v*n+b*u+M*p,e[5]=x*s+v*l+b*d+M*f,e[6]=x*o+v*h+b*g+M*m,e[7]=x*a+v*c+b*_+M*S,x=i[8],v=i[9],b=i[10],M=i[11],e[8]=x*r+v*n+b*u+M*p,e[9]=x*s+v*l+b*d+M*f,e[10]=x*o+v*h+b*g+M*m,e[11]=x*a+v*c+b*_+M*S,x=i[12],v=i[13],b=i[14],M=i[15],e[12]=x*r+v*n+b*u+M*p,e[13]=x*s+v*l+b*d+M*f,e[14]=x*o+v*h+b*g+M*m,e[15]=x*a+v*c+b*_+M*S,e}function p(e,t,i){var r,s,o,a,n,l,h,c,u,d,g,_,p=i[0],f=i[1],m=i[2];return t===e?(e[12]=t[0]*p+t[4]*f+t[8]*m+t[12],e[13]=t[1]*p+t[5]*f+t[9]*m+t[13],e[14]=t[2]*p+t[6]*f+t[10]*m+t[14],e[15]=t[3]*p+t[7]*f+t[11]*m+t[15]):(r=t[0],s=t[1],o=t[2],a=t[3],n=t[4],l=t[5],h=t[6],c=t[7],u=t[8],d=t[9],g=t[10],_=t[11],e[0]=r,e[1]=s,e[2]=o,e[3]=a,e[4]=n,e[5]=l,e[6]=h,e[7]=c,e[8]=u,e[9]=d,e[10]=g,e[11]=_,e[12]=r*p+n*f+u*m+t[12],e[13]=s*p+l*f+d*m+t[13],e[14]=o*p+h*f+g*m+t[14],e[15]=a*p+c*f+_*m+t[15]),e}function f(e,t,i,r){var s,o,n,l,h,c,u,d,g,_,p,f,m,S,x,v,b,M,T,y,P,w,C,E,A=r[0],I=r[1],F=r[2],R=Math.sqrt(A*A+I*I+F*F);return R<a?null:(A*=R=1/R,I*=R,F*=R,s=Math.sin(i),n=1-(o=Math.cos(i)),l=t[0],h=t[1],c=t[2],u=t[3],d=t[4],g=t[5],_=t[6],p=t[7],f=t[8],m=t[9],S=t[10],x=t[11],v=A*A*n+o,b=I*A*n+F*s,M=F*A*n-I*s,T=A*I*n-F*s,y=I*I*n+o,P=F*I*n+A*s,w=A*F*n+I*s,C=I*F*n-A*s,E=F*F*n+o,e[0]=l*v+d*b+f*M,e[1]=h*v+g*b+m*M,e[2]=c*v+_*b+S*M,e[3]=u*v+p*b+x*M,e[4]=l*T+d*y+f*P,e[5]=h*T+g*y+m*P,e[6]=c*T+_*y+S*P,e[7]=u*T+p*y+x*P,e[8]=l*w+d*C+f*E,e[9]=h*w+g*C+m*E,e[10]=c*w+_*C+S*E,e[11]=u*w+p*C+x*E,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}var m=function(e,t,i,r,s){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var a=1/(r-s);e[10]=(s+r)*a,e[14]=2*s*r*a}else e[10]=-1,e[14]=-2*r;return e};function S(e,t,i,r){var s=t[0],o=t[1],a=t[2],n=r[0],l=r[1],h=r[2],c=s-i[0],u=o-i[1],d=a-i[2],g=c*c+u*u+d*d;g>0&&(c*=g=1/Math.sqrt(g),u*=g,d*=g);var _=l*d-h*u,p=h*c-n*d,f=n*u-l*c;return(g=_*_+p*p+f*f)>0&&(_*=g=1/Math.sqrt(g),p*=g,f*=g),e[0]=_,e[1]=p,e[2]=f,e[3]=0,e[4]=u*f-d*p,e[5]=d*_-c*f,e[6]=c*p-u*_,e[7]=0,e[8]=c,e[9]=u,e[10]=d,e[11]=0,e[12]=s,e[13]=o,e[14]=a,e[15]=1,e}function x(){var e=new n(3);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function v(e){var t=new n(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function b(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function M(e,t,i){var r=new n(3);return r[0]=e,r[1]=t,r[2]=i,r}function T(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e}function y(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function P(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function w(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function C(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function E(e,t){var i=t[0],r=t[1],s=t[2],o=i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function A(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function I(e,t,i){var r=t[0],s=t[1],o=t[2],a=i[0],n=i[1],l=i[2];return e[0]=s*l-o*n,e[1]=o*a-r*l,e[2]=r*n-s*a,e}function F(e,t,i){var r=t[0],s=t[1],o=t[2],a=i[3]*r+i[7]*s+i[11]*o+i[15];return a=a||1,e[0]=(i[0]*r+i[4]*s+i[8]*o+i[12])/a,e[1]=(i[1]*r+i[5]*s+i[9]*o+i[13])/a,e[2]=(i[2]*r+i[6]*s+i[10]*o+i[14])/a,e}var R;R=x();function L(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function D(e,t,i,r){var s=new n(4);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s}function B(e,t,i){var r=t[0],s=t[1],o=t[2],a=t[3];return e[0]=i[0]*r+i[4]*s+i[8]*o+i[12]*a,e[1]=i[1]*r+i[5]*s+i[9]*o+i[13]*a,e[2]=i[2]*r+i[6]*s+i[10]*o+i[14]*a,e[3]=i[3]*r+i[7]*s+i[11]*o+i[15]*a,e}!function(){var e=L()}()},4723(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(2919),o=r(i(7734)),a=r(i(4639)),n=r(i(4382)),l=r(i(4396)),h=i(7930),c=i(3726),u=i(9685),d=i(6553),g=i(8083),_=i(9839),p=i(4595),f=i(8145),m=r(i(619)),S=i(5409),x=i(3956),v=i(8868),b=i(1741),M=i(6878),T=i(3890);class y{static MIN_WHEEL_SCALE=.85;static MAX_WHEEL_SCALE=1.8;_camera;_perspectiveMatrixManager;centralPoinCoords;mousePointCoords;canvas;_healpixGrid;_equatorialGrid;mouseHelper;mouseDown=!1;lastMouseX=null;lastMouseY=null;inertiaX=0;inertiaY=0;zoomInertia=0;pointerDownX=null;pointerDownY=null;pointerDownAt=0;_activeHiPS=null;_activeHiPSLayers=[];_activeXYZ2=null;_activeMeshHiPS=null;_activeBaseLayer=null;startup=!0;fov;activeCatalogues=[];activeFootprintSets=[];activePolylineSets=[];activeSensorCones=[];activeSatelliteObjects=[];_webgl;_selectedColorMap;_cameraStatusChanged=!1;lastCameraChangedAt=0;lastCameraMotionAt=0;lastHoveredSource=null;lastHoveredCatalogue=null;zoomSensitivity=1;lockedEastWestRaDeg=null;lockedNorthSouthDecDeg=null;keepCameraNorthUp=!0;gridLabelContainers;constructor(e,t,i={}){console.log("[AstroSphere] new instance for canvas",e.id),this._webgl=t,this.mouseHelper=new l.default,this.canvas=e,this.gridLabelContainers=i.gridLabelContainers;this._selectedColorMap=m.default.native,n.default.insideSphere=s.bootSetup.insideSphere,this.initCamera(),this._healpixGrid=new p.HealpixGrid(this._webgl,this.gridLabelContainers),this._perspectiveMatrixManager=new u.PerspectiveMatrixManager(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._equatorialGrid=new _.EquatorialGrid(this._webgl,this._healpixGrid,this.gridLabelContainers),this._equatorialGrid.init(this._healpixGrid.getMinFoV()),this.updateCentralPoint(),this.startup=!0,this.addEventListeners(e),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}initCamera(){s.bootSetup.insideSphere?this._camera=new o.default([0,0,-.005],!0):this._camera=new o.default([0,0,4],!1)}setCamera(e){this._camera=e}setCameraRotationSensitivity(e){this._camera.setRotationSensitivity(e)}getCameraRotationSensitivity(){return this._camera.getRotationSensitivity()}get healpixGrid(){return this._healpixGrid}get equatorialGrid(){return this._equatorialGrid}updateCentralPoint(){const e=this.getPhiThetaDeg(this.canvas),t=(0,h.sphericalToAstroDeg)(e.phi,e.theta),i=(0,h.raDegToHMS)(t.ra),r=(0,h.decDegToDMS)(t.dec);return this.centralPoinCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.centralPoinCoords}updateLastMousePoint(){const e={phi:this.mouseHelper.phi,theta:this.mouseHelper.theta},t={ra:this.mouseHelper.ra,dec:this.mouseHelper.dec},i=this.mouseHelper.raHMS,r=this.mouseHelper.decDMS;return this.mousePointCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.mousePointCoords}clearLastMousePoint(){this.mousePointCoords=void 0}getCentralPointCoordinates(){return this.centralPoinCoords}getLastMousePointCoordinates(){return this.mousePointCoords}clamp(e,t,i){return Math.min(i,Math.max(t,e))}computeZoomStep(e,t){const i=t<0?-1:1,r=this.clamp(Math.abs(t)/120,y.MIN_WHEEL_SCALE,y.MAX_WHEEL_SCALE);return i*this.clamp(.0012+.0025*Math.sqrt(Math.max(e,0)),.0012,.04)*r*this.zoomSensitivity}setZoomSensitivity(e){this.zoomSensitivity=this.clamp(e,.2,3)}getZoomSensitivity(){return this.zoomSensitivity}filterRotationDeltaByAstroLocks(e,t){const i=this._camera.isRotationLockedY(),r=this._camera.isRotationLockedX();if(!i&&!r)return{deltaX:e,deltaY:t};const s=a.default.getIntersectionPointWithSingleModel(this.canvas.clientWidth/2,this.canvas.clientHeight/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!s||s.length<3)return{deltaX:e,deltaY:t};const o=T.vec3.normalize(T.vec3.create(),T.vec3.fromValues(s[0],s[1],s[2])),n=T.vec3.fromValues(0,0,1),l=T.vec3.cross(T.vec3.create(),n,o);T.vec3.length(l)<1e-6?T.vec3.set(l,1,0,0):T.vec3.normalize(l,l);const h=T.vec3.scale(T.vec3.create(),o,T.vec3.dot(n,o)),c=T.vec3.subtract(T.vec3.create(),n,h);T.vec3.length(c)<1e-6&&T.vec3.cross(c,o,l),T.vec3.normalize(c,c);const u=this.projectModelDirectionToScreen(o,l),d=this.projectModelDirectionToScreen(o,c);if(!u||!d)return{deltaX:e,deltaY:t};let g=e,_=t;if(i){const e=g*u.x+_*u.y;g-=e*u.x,_-=e*u.y}if(r){const e=g*d.x+_*d.y;g-=e*d.x,_-=e*d.y}return{deltaX:g,deltaY:_}}projectModelDirectionToScreen(e,t){const i=T.vec3.scaleAndAdd(T.vec3.create(),e,t,.01),r=this.projectModelPointToScreen(e),s=this.projectModelPointToScreen(i);if(!r||!s)return null;const o=s.x-r.x,a=s.y-r.y,n=Math.hypot(o,a);return n<1e-6?null:{x:o/n,y:a/n}}projectModelPointToScreen(e){const t=this._camera.getCameraMatrix(),i=this._healpixGrid.getModelMatrix(),r=T.mat4.create(),s=T.mat4.create();T.mat4.multiply(r,t,i),T.mat4.multiply(s,this._perspectiveMatrixManager.pMatrix,r);const o=T.vec4.fromValues(e[0],e[1],e[2],1);return T.vec4.transformMat4(o,o,s),Math.abs(o[3])<1e-6?null:{x:o[0]/o[3],y:-o[1]/o[3]}}enforceAstronomicalRotationLocks(){if(null==this.lockedEastWestRaDeg&&null==this.lockedNorthSouthDecDeg)return!1;const e=this.updateCentralPoint();if(!e)return!1;const t=this.lockedEastWestRaDeg??e.astroDeg.ra,i=this.lockedNorthSouthDecDeg??e.astroDeg.dec;return(Math.abs(t-e.astroDeg.ra)>1e-6||Math.abs(i-e.astroDeg.dec)>1e-6)&&(this._camera.goTo(t,i),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}enforceCameraNorthUp(){if(!this.keepCameraNorthUp)return!1;const e=this.updateCentralPoint();return!!e&&(this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}emitCameraChanged(e){if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid?.fovObj)return;const t=this.getCurrentStatus();t&&this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:t,bubbles:!0,composed:!0}))}addEventListeners(e){n.default.debug&&console.log("[AstroSphere::addEventListeners]");const t=e.getBoundingClientRect();this.lastMouseX=t.left,this.lastMouseY=t.top;console.log("[AstroSphere] registering pointer and wheel listeners on canvas"),e.onpointerdown=t=>{e.setPointerCapture(t.pointerId),this.mouseDown=!0;const i=e.getBoundingClientRect();this.lastMouseX=t.clientX-i.left,this.lastMouseY=t.clientY-i.top,this.pointerDownX=this.lastMouseX,this.pointerDownY=this.lastMouseY,this.pointerDownAt=Date.now();const r=a.default.getIntersectionPointWithSingleModel(this.lastMouseX,this.lastMouseY,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return r&&r.length>0?(this.mouseHelper.update(r),this.updateLastMousePoint()):this.clearLastMousePoint(),t.preventDefault(),!1},e.onpointerup=t=>{if(e.releasePointerCapture(t.pointerId),this.mouseDown=!1,document.body.style.cursor="auto",0!==t.button)return t.preventDefault(),!1;const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top;this.lastMouseX=r,this.lastMouseY=s;const o=Math.hypot(r-(this.pointerDownX??r),s-(this.pointerDownY??s)),n=Date.now()-this.pointerDownAt;if(o<=4&&n<=250){const e=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(e&&e.length>0){this.mouseHelper.update(e),this.updateLastMousePoint();for(const e of this.activeCatalogues){const t=e.selectPrimarySourceFromClick(this.mouseHelper);t?.sources.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("source-clicked",{detail:{source:t.sources,selectionState:t.selectionState,catalogue:e},bubbles:!0,composed:!0}))}for(const e of this.activeFootprintSets){const t=e.selectPrimaryFootprintFromClick(this.mouseHelper);t?.footprints.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-clicked",{detail:{footprint:t.footprints,selectionState:t.selectionState,footprintSet:e},bubbles:!0,composed:!0}))}}}else this.clearLastMousePoint()},e.onpointermove=t=>{const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,o=r,l=s;if(this._healpixGrid){if(this.mouseDown){document.body.style.cursor="grab";const t=n.default.insideSphere?-1:1,i=n.default.insideSphere?10:1,r=t*i*(o-(this.lastMouseX??o))*Math.PI/e.width,s=t*i*(l-(this.lastMouseY??l))*Math.PI/e.height,a=this.filterRotationDeltaByAstroLocks(r,s);this.inertiaX+=.1*a.deltaX,this.inertiaY+=.1*a.deltaY,this.updateCentralPoint()}else{const e=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);e&&e.length>0?(this.mouseHelper.update(e),this.updateLastMousePoint()):this.clearLastMousePoint()}this.centralPoinCoords||this.updateCentralPoint(),this.lastMouseX=o,this.lastMouseY=l,this._cameraStatusChanged=!0,t.preventDefault()}},e.onpointerleave=()=>{this.clearLastMousePoint(),this._cameraStatusChanged=!0,this.emitCameraChanged("pointerleave")},console.log("[AstroSphere] adding wheel event listener with passive: false"),e.addEventListener("wheel",e=>{const t=this._healpixGrid.getMinFoV(),i=this.computeZoomStep(t,e.deltaY);this.zoomInertia=0,this._camera.zoom(i),this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this._cameraStatusChanged=!0,this.emitCameraChanged("wheel"),e.preventDefault()},{passive:!1}),e.addEventListener("contextmenu",t=>{t.preventDefault();const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,o=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!o||0===o.length)return!1;this.mouseHelper.update(o),this.updateLastMousePoint();for(const e of this.activeCatalogues){const i=e.getSourcesFromPointer(this.mouseHelper);if(i?.sources.length){this._webgl.canvas.dispatchEvent(new CustomEvent("source-contextmenu",{detail:{source:i.sources,catalogue:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}for(const e of this.activeFootprintSets){const i=e.getFootprintsFromPointer(this.mouseHelper);if(i?.footprints.length){this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-contextmenu",{detail:{footprint:i.footprints,footprintSet:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}return!1}),console.log("[AstroSphere] registering global keydown listener on document"),document.addEventListener("keydown",e=>{if(e.ctrlKey)switch(e.key){case"1":this._camera.clearRotationLock();break;case"2":this._camera.setRotationLock({x:!0,y:!1,z:!1});break;case"3":this._camera.setRotationLock({x:!1,y:!0,z:!1});break;case"4":this._camera.setRotationLock({x:!1,y:!1,z:!0})}},{capture:!0})}getPhiThetaDeg(e){const t=e.getBoundingClientRect(),i=t.width,r=t.height,s=a.default.getIntersectionPointWithSingleModel(i/2,r/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return(0,h.cartesianToSpherical)(s)}changeHiPSFormat(e){if(!this._activeHiPS)throw new Error("No active HiPS.");this._activeHiPS.changeFormat(e)}setHiPSFITSScaleFunction(e,t){if(!this._activeHiPS)throw new Error("No active HiPS.");this._activeHiPS.setFITSScaleFunction(e,t)}getActiveHiPSFITSStretch(){return this._activeHiPS?.fitsStretch??null}setHiPSFITSRangeMode(e){if(!this._activeHiPS)throw new Error("No active HiPS.");this._activeHiPS.setFITSRangeMode(e)}createHiPS(e){return new c.HiPS(1,[0,0,0],0,0,e,this._webgl,this._healpixGrid)}activateHiPS(e){const t=this._healpixGrid.visibleTilesManager.tileBuffer;for(const e of this._activeHiPSLayers)t.removeHiPS(e);this._activeHiPSLayers=[];const i=this.createHiPS(e);return this._activeHiPSLayers.push(i),this._activeHiPS=i,this._activeBaseLayer="hips",i}setHiPSOpacity(e,t){if(!this._activeHiPSLayers.includes(e))throw new Error("HiPS layer is not active in this AstroSphere.");e.setOpacity(t)}addHiPS(e){const t=e=>String(e).replace(/\/+$/,""),i=t(e.url),r=this._activeHiPSLayers.find(e=>t(e.baseURL)===i);if(r)throw new Error(`HiPS already active: ${String(e.url)}`);const s=this.createHiPS(e);return this._activeHiPSLayers.push(s),this._activeHiPS=s,this._activeBaseLayer="hips",s}removeHiPS(e){const t=this._activeHiPSLayers.indexOf(e);if(-1!==t){if(this._healpixGrid.visibleTilesManager.tileBuffer.removeHiPS(e),this._activeHiPSLayers.splice(t,1),0===this._activeHiPSLayers.length)return this._activeHiPS=null,void("hips"===this._activeBaseLayer&&(this._activeBaseLayer=null));this._activeHiPS===e&&(this._activeHiPS=this._activeHiPSLayers[this._activeHiPSLayers.length-1])}}removeAllHiPS(){const e=this._healpixGrid.visibleTilesManager.tileBuffer;for(const t of this._activeHiPSLayers)e.removeHiPS(t);this._activeHiPSLayers=[],this._activeHiPS=null,"hips"===this._activeBaseLayer&&(this._activeBaseLayer=null)}activateXYZ(e){this.activateXYZ2(new v.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver)),this._activeBaseLayer="xyz"}activateXYZ2(e){this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,e,this._webgl,this.gridLabelContainers),this._activeBaseLayer="xyz"}activateMeshHiPS(e){this._activeMeshHiPS=new M.MeshHiPS(e.meshRadius,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="meships"}activateWMTS(e){const t=new x.WMTSAdapter(e).toXYZLayerConfig();this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,new v.XYZMapDescriptor(e.layer?`WMTS ${e.layer}`:"WMTS Earth2 Layer",t.urlTemplate,t.minZoom??0,t.maxZoom??8,t.segmentsPerSide??48,t.maxCachedTiles??384,8,t.urlResolver),this._webgl,this.gridLabelContainers),this._activeBaseLayer="xyz"}async showCatalogue(e){return e&&this.activeCatalogues.push(e),e}deleteCatalogue(e){this.activeCatalogues=this.activeCatalogues.filter(t=>t!==e)}async showFootprintSet(e){return e&&this.activeFootprintSets.push(e),e}deleteFootprintSet(e){this.activeFootprintSets=this.activeFootprintSets.filter(t=>t!==e)}async showPolylineSet(e){return e&&this.activePolylineSets.push(e),e}deletePolylineSet(e){this.activePolylineSets=this.activePolylineSets.filter(t=>t!==e),e.dispose()}async showSensorCone(e){return e&&this.activeSensorCones.push(e),e}deleteSensorCone(e){this.activeSensorCones=this.activeSensorCones.filter(t=>t!==e),e.dispose()}async showSatelliteObject(e){return e&&this.activeSatelliteObjects.push(e),e}deleteSatelliteObject(e){this.activeSatelliteObjects=this.activeSatelliteObjects.filter(t=>t!==e),e.dispose()}getHoveredFootprints(){let e=[];return this.activeFootprintSets.forEach(t=>{e.push(t.hoveredFootprints)}),e}goTo(e,t){this._camera.goTo(e,t)}getActiveCoordinateMode(){return"xyz"===this._activeBaseLayer?"lonlat":"hips"===this._activeBaseLayer&&this._activeHiPS?.isGalacticHips?"galactic":"equatorial"}resetAxesOrientation(){const e=this.updateCentralPoint();e&&(this.inertiaX=0,this.inertiaY=0,this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),this._cameraStatusChanged=!0)}setKeepCameraNorthUp(e){this.keepCameraNorthUp=e,e&&this.resetAxesOrientation()}isKeepCameraNorthUp(){return this.keepCameraNorthUp}getFoV(){return"xyz"===this._activeBaseLayer&&this._activeXYZ2?this._activeXYZ2.getFoV():this.fov}getFoVPolygon(){if(null==this.healpixGrid)throw new Error(`healpixGrid is ${this.healpixGrid}`);return g.FoVUtils.getFoVPolygon(this._camera,this.canvas,this._healpixGrid,this._healpixGrid,this._webgl,this._perspectiveMatrixManager.pMatrix)}changeFoV(e){const t=this._healpixGrid.getFoV().computeDistanceFromAngle(e);this._camera.translate(t),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}changeFoV2(e){const t=this._healpixGrid.getFoV().computeCameraPositionForFoV(e);this._camera.setCameraPosition(t)}changeFoV3(e){const t=this._healpixGrid.getFoV().computeCameraPositionForAngularDiameter(e);this._camera.setCameraPosition(t),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,!1)}getInsideSphere(){return n.default.insideSphere}toggleInsideSphere(){const e=this.updateCentralPoint();this.inertiaX=0,this.inertiaY=0,this.zoomInertia=0,n.default.insideSphere=!n.default.insideSphere,this._camera.toggleInsideSphere(),this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.updateCentralPoint(),this.lastCameraMotionAt=performance.now(),this._cameraStatusChanged=!0,this.emitCameraChanged("inside-sphere-toggle"),requestAnimationFrame(()=>this.draw(this.canvas))}setCameraPosition(e){this._camera.setCameraPosition(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}setCameraMatrix(e){this._camera.setCameraMatrix(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}_refreshingStatus=!1;applyFullCameraState(e,t){this._refreshingStatus=!0,this._camera=e.camera,this._healpixGrid.setModelMatrix(e.mMatrix),this._perspectiveMatrixManager.pMatrix=e.pMatrix,this.setCameraMatrix(e.vMatrix),t&&this._activeHiPS?.changeColorMap(e.colorMap),this._refreshingStatus=!1}getCurrentStatus(){this.updateCentralPoint();const e=this.centralPoinCoords?.astroDeg.ra,t=this.centralPoinCoords?.astroDeg.dec;if(null==e||null==t)return null;let i=[];try{i=this.getFoVPolygon()}catch(e){console.warn("[AstroSphere] getCurrentStatus: FoV polygon is not available.",e)}return{fovDeg:this.fov.minFoV,fovXDeg:this.fov.xFoV,fovYDeg:this.fov.yFoV,position:this._camera.getCameraPosition(),vMatrix:this._camera.getCameraMatrix(),pMatrix:this._perspectiveMatrixManager.pMatrix,mMatrix:this._healpixGrid.getModelMatrix(),camera:this._camera,timestamp:performance.now(),centralPoint:new d.Point({raDeg:e,decDeg:t},f.CoordsType.ASTRO),mouseHoverPoint:this.mousePointCoords,colorMap:this._selectedColorMap,getFoVPolygon:i}}changeColorMap(e){(this._activeHiPS||this._activeXYZ2||this._activeMeshHiPS)&&(this._selectedColorMap=e,this._activeHiPS?.changeColorMap(e),this._activeXYZ2?.changeColorMap(e))}prevFov=0;prevCentralRaDeg=null;prevCentralDecDeg=null;get activeHiPS(){return this._activeHiPS}get activeHiPSLayers(){return this._activeHiPSLayers}setActiveHiPS(e){if(!this._activeHiPSLayers.includes(e))throw new Error("HiPS layer is not active in this AstroSphere.");this._activeHiPS=e,this._activeBaseLayer="hips"}get activeXYZ(){return this._activeXYZ2}get activeMeshHiPS(){return this._activeMeshHiPS}isLonLatGridVisible(){return this._activeXYZ2?.isLonLatGridVisible()??!1}toggleLonLatGrid(){return this._activeXYZ2?.toggleLonLatGrid()??!1}setEastWestRotationLocked(e){this._camera.setRotationLock({y:e}),e&&(this.inertiaX=0),this.lockedEastWestRaDeg=e?this.updateCentralPoint()?.astroDeg.ra??null:null}isEastWestRotationLocked(){return this._camera.isRotationLockedY()}setNorthSouthRotationLocked(e){this._camera.setRotationLock({x:e}),e&&(this.inertiaY=0),this.lockedNorthSouthDecDeg=e?this.updateCentralPoint()?.astroDeg.dec??null:null}isNorthSouthRotationLocked(){return this._camera.isRotationLockedX()}getXYZDebugStats(){return{activeBaseLayer:this._activeBaseLayer,layer:this._activeXYZ2?.getDebugStats()??null,requests:S.xyzTileRequestScheduler.getDebugStats()}}getHiPSDebugStats(){return this._activeHiPS?this._activeHiPS.getDebugStats():null}getMeshHiPSDebugStats(){return this._activeMeshHiPS?this._activeMeshHiPS.getDebugStats():null}draw(e){if(this._refreshingStatus)return;if(!this._webgl)return;if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid||0===Object.keys(this._healpixGrid).length)return;if(void 0===this._healpixGrid.fovObj)return;this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);let t=!1,i=0,r=0;if(this._webgl.viewport(0,0,this._webgl.drawingBufferWidth,this._webgl.drawingBufferHeight),this._webgl.clear(this._webgl.COLOR_BUFFER_BIT|this._webgl.DEPTH_BUFFER_BIT),0!==this.zoomInertia&&(Math.abs(this.zoomInertia)>1e-4?(this._camera.zoom(this.zoomInertia),this.zoomInertia*=.95,this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.prevFov!==this.fov.minFoV&&(this.centralPoinCoords||(this.centralPoinCoords=this.updateCentralPoint()),this.prevFov=this.fov.minFoV)):this.zoomInertia=0,this._cameraStatusChanged=!0),this.mouseDown||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02){t=!0;const o=this.filterRotationDeltaByAstroLocks(this.inertiaX,this.inertiaY);r=o.deltaX,i=o.deltaY,this.inertiaX=.95*o.deltaX,this.inertiaY=.95*o.deltaY,this._camera.rotate(r,i),this.lastCameraMotionAt=performance.now(),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);this.enforceAstronomicalRotationLocks()||this.enforceCameraNorthUp()}else this.inertiaY=0,this.inertiaX=0;const o=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix);if(Number.isFinite(o.minFoV)&&o.minFoV>0&&(this.fov=o,this._camera.refreshFoV(this.fov.minFoV),this.prevFov=this.fov.minFoV),t){const e=this.updateCentralPoint(),t=e.astroDeg.ra,i=e.astroDeg.dec,r=null===this.prevCentralRaDeg||Math.abs(t-this.prevCentralRaDeg)>1e-5,s=null===this.prevCentralDecDeg||Math.abs(i-this.prevCentralDecDeg)>1e-5;(r||s)&&(this.prevCentralRaDeg=t,this.prevCentralDecDeg=i)}if(this._cameraStatusChanged){const e=performance.now(),t=!this.mouseDown||e-this.lastCameraChangedAt>100,i=t?this.getCurrentStatus():null;i&&(this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:i,bubbles:!0,composed:!0})),this.lastCameraChangedAt=e),!this.startup&&t&&(this._cameraStatusChanged=!1)}if(this._webgl.disable(this._webgl.DEPTH_TEST),this._webgl.enable(this._webgl.BLEND),this._webgl.enable(this._webgl.CULL_FACE),this._webgl.cullFace(n.default.insideSphere?this._webgl.FRONT:this._webgl.BACK),this._webgl.blendFunc(this._webgl.SRC_ALPHA,this._webgl.ONE_MINUS_SRC_ALPHA),"hips"===this._activeBaseLayer&&this._activeHiPSLayers.length>0){const e=Math.max(...this._activeHiPSLayers.map(e=>e.maxOrder)),t=Math.min(this._healpixGrid.visibleorder,e);this._healpixGrid.visibleTilesManager.computeVisiblePixels(t,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}if("meships"===this._activeBaseLayer&&this._activeMeshHiPS){const e=this._activeMeshHiPS.refreshOrder(this.fov?.minFoV??this._healpixGrid.getMinFoV());this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}const a=this.fov?.minFoV??this._healpixGrid.getMinFoV(),l=performance.now(),c=this.mouseDown||Math.abs(this.zoomInertia)>1e-4||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02||l-this.lastCameraMotionAt<220,u={fovDeg:a,camera:this._camera,pMatrix:this._perspectiveMatrixManager.pMatrix,centerSphericalDeg:this.updateCentralPoint().sphericalDeg,fovPolygon:void 0,viewportSphericalSamples:void 0,cameraMoving:c};if("hips"===this._activeBaseLayer){for(const e of this._activeHiPSLayers)e!==this._activeHiPS&&e.draw(u);this._activeHiPS?.draw(u)}if("xyz"===this._activeBaseLayer&&this._activeXYZ2?.draw(u),"meships"===this._activeBaseLayer&&this._activeMeshHiPS?.draw(u),this._healpixGrid.draw(u),this._equatorialGrid.draw(u),this._webgl.enable(this._webgl.DEPTH_TEST),this._webgl.disable(this._webgl.CULL_FACE),this.startup){this.startup=!1;const t=this.getPhiThetaDeg(e),i=(0,h.sphericalToAstroDeg)(t.phi,t.theta),r=(0,h.raDegToHMS)(i.ra),s=(0,h.decDegToDMS)(i.dec);this.prevFov=this.fov?.minFoV??this._healpixGrid.getMinFoV(),this._cameraStatusChanged=!0,console.log("(startup coords)",{raDeg:i.ra,decDeg:i.dec,raHMS:r,decDMS:s})}this.activeCatalogues.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.emitHoveredSourceIfChanged(),this.activeFootprintSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.activePolylineSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.activeSensorCones.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(this._perspectiveMatrixManager.pMatrix,this._camera.getCameraMatrix(),t)}),this.activeSatelliteObjects.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(this._perspectiveMatrixManager.pMatrix,this._camera.getCameraMatrix(),t)})}emitHoveredSourceIfChanged(){let e=null,t=null;for(const i of this.activeCatalogues){const r=i.getPrimaryHoveredSource();if(r){e=r,t=i;break}}e===this.lastHoveredSource&&t===this.lastHoveredCatalogue||(this.lastHoveredSource=e,this.lastHoveredCatalogue=t,this._webgl.canvas.dispatchEvent(new CustomEvent("source-hovered",{detail:{source:e,catalogue:t},bubbles:!0,composed:!0})))}}t.default=y},772(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AstroViewer=void 0;const s=r(i(4723)),o=i(5087),a=i(1232),n=i(592),l=i(2919),h=r(i(619)),c=i(5409),u=i(8868),d=i(5781),g=i(9022),_=i(3665),p=i(3603),f=i(3102),m=i(847);t.AstroViewer=class{astroSphere;canvas;webgl;rafId=null;webglContextList=new Map;viewfinderEl=null;viewfinderVisible=l.bootSetup.showViewfinder;viewfinderColor="rgba(75,148,226,0.68)";options={};run(){return this.tick()}createCatalogue(e,t,i,r){return new a.CatalogueGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showCatalogue(e){this.astroSphere.showCatalogue(e)}hideCatalogue(e,t){e.setIsVisible(t)}deleteCatalogue(e){this.astroSphere.deleteCatalogue(e)}changeCatalogueRA(e,t){return e.changeMetaRA(t),e}changeCatalogueDec(e,t){return e.changeMetaDec(t),e}changeCatalogueColor(e,t){return e.changeColor(t),e}setCatalogueShapeHue(e,t){return e.changeMetaShapeHue(t),e}setCatalogueShapeSize(e,t){return e.changeMetaShapeSize(t),e}createFootprintSet(e,t,i,r){return new n.FootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideFootprintSet(e,t){e.setIsVisible(t)}deleteFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPointSet(e,t,i,r){return new d.TerraPointSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPointSet(e){this.astroSphere.showCatalogue(e)}hideTerraPointSet(e,t){e.setIsVisible(t)}deleteTerraPointSet(e){this.astroSphere.deleteCatalogue(e)}createTerraFootprintSet(e,t,i,r){return new g.TerraFootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideTerraFootprintSet(e,t){e.setIsVisible(t)}deleteTerraFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPolylineSet(e,t,i,r){return new _.TerraPolylineSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPolylineSet(e){this.astroSphere.showPolylineSet(e)}hideTerraPolylineSet(e,t){e.setIsVisible(t)}deleteTerraPolylineSet(e){this.astroSphere.deletePolylineSet(e)}changeTerraPolylineSetColor(e,t){return e.changeColor(t),e}createSensorCone(e){return new f.SensorConeGL(e,this.webgl)}showSensorCone(e){this.astroSphere.showSensorCone(e)}hideSensorCone(e,t){e.setIsVisible(t)}deleteSensorCone(e){this.astroSphere.deleteSensorCone(e)}createSatelliteObject(e){return new p.SatelliteObjectGL(e,this.webgl)}showSatelliteObject(e){this.astroSphere.showSatelliteObject(e)}hideSatelliteObject(e,t){e.setIsVisible(t)}deleteSatelliteObject(e){this.astroSphere.deleteSatelliteObject(e)}changeFootprintSetColor(e,t){e.changeColor(t)}getHoveredFootprints(){return this.astroSphere.getHoveredFootprints()}getDefaultHiPSURL(){return l.bootSetup.defaultHipsUrl}activateHiPS(e){this.astroSphere.activateHiPS(e)}activateXYZ(e){this.astroSphere.activateXYZ(e)}activateXYZ2(e){const t=new u.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver);this.astroSphere.activateXYZ2(t)}activateWMTS(e){this.astroSphere.activateWMTS(e)}activateMeshHiPS(e){this.astroSphere.activateMeshHiPS(new m.MeshHiPSDescriptor(e))}setXYZMaxConcurrentRequests(e){c.xyzTileRequestScheduler.setMaxConcurrent(e)}getXYZMaxConcurrentRequests(){return c.xyzTileRequestScheduler.getMaxConcurrent()}getXYZDebugStats(){return this.astroSphere.getXYZDebugStats()}getHiPSDebugStats(){return this.astroSphere.getHiPSDebugStats()}getMeshHiPSDebugStats(){return this.astroSphere.getMeshHiPSDebugStats()}async loadHiPS(e){const t=e.endsWith("/")?e:e+"/",i=await fetch(t+"properties");if(!i.ok)throw new Error(`HTTP ${i.status} fetching properties`);const r=await i.text(),s=new o.HiPSDescriptor(r,t);return this.astroSphere.activateHiPS(s),s.surveyName}async loadMeshHiPS(e,t={}){const i=e.endsWith("/")?e:e+"/";let r="";const s=await fetch(i+"properties");if(s.ok)r=await s.text();else{const e=await fetch(i+"properties.json");if(!e.ok)throw new Error(`HTTP ${e.status} fetching MeshHiPS properties`);const t=await e.json();r=Object.entries(t).map(([e,t])=>`${e}=${String(t)}`).join("\n")}const o=new m.MeshHiPSDescriptor({...t,baseUrl:i},r);return this.astroSphere.activateMeshHiPS(o),o.name}setActiveHiPS(e){this.astroSphere.setActiveHiPS(e)}setHiPSOpacity(e,t){this.astroSphere.setHiPSOpacity(e,t)}changeColorMap(e){const t=h.default[e];this.astroSphere.changeColorMap(t)}changeCustomColorMap(e){this.astroSphere.changeColorMap(e)}addHiPS(e){return this.astroSphere.addHiPS(e)}async addHiPSFromUrl(e){const t=e.endsWith("/")?e:e+"/",i=await fetch(t+"properties");if(!i.ok)throw new Error(`HTTP ${i.status} fetching properties`);const r=await i.text(),s=new o.HiPSDescriptor(r,t);return this.astroSphere.addHiPS(s)}removeHiPS(e){this.astroSphere.removeHiPS(e)}removeAllHiPS(){this.astroSphere.removeAllHiPS()}getActiveHiPSLayers(){return this.astroSphere.activeHiPSLayers}getActiveHiPS(){return this.astroSphere.activeHiPS}changeHiPSFormat(e){this.astroSphere.changeHiPSFormat(e)}setHiPSFITSScaleFunction(e,t){this.astroSphere.setHiPSFITSScaleFunction(e,t)}getActiveHiPSFITSStretch(){return this.astroSphere.getActiveHiPSFITSStretch()}setHiPSFITSRangeMode(e){this.astroSphere.setHiPSFITSRangeMode(e)}getActiveHiPSFormats(){return this.astroSphere.activeHiPS?.availableFormats??[]}getActiveXYZ(){return this.astroSphere.activeXYZ}setCamera(e){this.astroSphere.setCamera(e)}setCameraPosition(e){this.astroSphere.setCameraPosition(e)}setCameraMatrix(e){this.astroSphere.setCameraMatrix(e)}restoreAstroViewerState(e,t){this.astroSphere.applyFullCameraState(e,t)}getCurrentAstroViewerStatus(){return this.astroSphere.getCurrentStatus()}goTo(e,t){this.astroSphere.goTo(e,t)}getActiveCoordinateMode(){return this.astroSphere.getActiveCoordinateMode()}getCenterCoordinates(){return this.astroSphere.getCentralPointCoordinates()}getCoordinatesFromMouse(){return this.astroSphere.getLastMousePointCoordinates()}setModelMatrix(e){this.astroSphere.healpixGrid.setModelMatrix(e)}toggleHealpixGrid(){this.astroSphere.healpixGrid.toggleShowGrid()}isHealpixGridVisible(){return this.astroSphere.healpixGrid.isVisible()}toggleEquatorialGrid(){return this.astroSphere.equatorialGrid.toggleShowGrid()}isEquatorialGridVisible(){return this.astroSphere.equatorialGrid.isVisible()}toggleLonLatGrid(){return this.astroSphere.toggleLonLatGrid()}isLonLatGridVisible(){return this.astroSphere.isLonLatGridVisible()}setEastWestRotationLocked(e){this.astroSphere.setEastWestRotationLocked(e)}isEastWestRotationLocked(){return this.astroSphere.isEastWestRotationLocked()}setNorthSouthRotationLocked(e){this.astroSphere.setNorthSouthRotationLocked(e)}isNorthSouthRotationLocked(){return this.astroSphere.isNorthSouthRotationLocked()}resetAxesOrientation(){this.astroSphere.resetAxesOrientation()}setKeepCameraNorthUp(e){this.astroSphere.setKeepCameraNorthUp(e)}isKeepCameraNorthUp(){return this.astroSphere.isKeepCameraNorthUp()}getFoV(){return this.astroSphere.getFoV()}getFoVPolygon(){return this.astroSphere.getFoVPolygon()}changeFoV(e){this.astroSphere.changeFoV(e)}changeFoV2(e){this.astroSphere.changeFoV2(e)}changeFoV3(e){this.astroSphere.changeFoV3(e)}getInsideSphere(){return this.astroSphere.getInsideSphere()}toggleInsideSphere(){this.astroSphere.toggleInsideSphere()}toggleViewfinder(){return this.viewfinderVisible=!this.viewfinderVisible,this.syncViewfinderVisibility(),this.viewfinderVisible}setViewfinderVisible(e){this.viewfinderVisible=e,this.syncViewfinderVisibility()}isViewfinderVisible(){return this.viewfinderVisible}setViewfinderColor(e){this.viewfinderColor=e,this.syncViewfinderColor()}getViewfinderColor(){return this.viewfinderColor}setRotationSensitivity(e){this.astroSphere.setCameraRotationSensitivity(e)}getRotationSensitivity(){return this.astroSphere.getCameraRotationSensitivity()}setZoomSensitivity(e){this.astroSphere.setZoomSensitivity(e)}getZoomSensitivity(){return this.astroSphere.getZoomSensitivity()}constructor(e,t={}){this.options=t,this.init(e),this.webglContextList=new Map}init(e){console.log("init webgl"),this.canvas=e,this.initViewfinder();const t=this.canvas.getContext("webgl2",{alpha:!1});if(!t)throw alert("Could not initialise WebGL, sorry :-("),new Error("WebGL2 not available");this.webgl=t;try{this.webgl.clearColor(0,.06274509792,50*.00392156862,.7)}catch(e){console.log("Error instantiating WebGL context")}this.initListeners(),this.astroSphere=new s.default(this.canvas,this.webgl,{gridLabelContainers:this.options.gridLabelContainers})}initViewfinder(){const e=this.canvas.parentElement;if(!e)return;"static"===window.getComputedStyle(e).position&&(e.style.position="relative");const t=document.createElement("div");t.setAttribute("data-astro-viewfinder","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.width="44px",t.style.height="44px",t.style.transform="translate(-50%, -50%)",t.style.pointerEvents="none",t.style.zIndex="1",t.style.boxSizing="border-box";const i=[{left:"50%",top:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"50%",bottom:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"},{right:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"}];for(const e of i){const i=document.createElement("div");i.style.position="absolute",i.style.left=e.left??"auto",i.style.right=e.right??"auto",i.style.top=e.top??"auto",i.style.bottom=e.bottom??"auto",i.style.width=e.width,i.style.height=e.height,i.style.transform=e.transform,i.style.background="currentColor",i.style.borderRadius="999px",i.style.boxShadow="0 0 0 1px rgba(0, 0, 0, 0.14)",t.appendChild(i)}e.appendChild(t),this.viewfinderEl=t,this.syncViewfinderVisibility(),this.syncViewfinderColor()}syncViewfinderVisibility(){this.viewfinderEl&&(this.viewfinderEl.style.display=this.viewfinderVisible?"block":"none")}syncViewfinderColor(){this.viewfinderEl&&(this.viewfinderEl.style.color=this.viewfinderColor)}initListeners(){console.log("inside initListeners");const e=()=>{console.log("[resizeCanvas]");const e=this.canvas.getBoundingClientRect(),t=window.devicePixelRatio||1,i=Math.max(1,Math.floor(e.width*t)),r=Math.max(1,Math.floor(e.height*t));this.canvas.width===i&&this.canvas.height===r||(this.canvas.width=i,this.canvas.height=r,this.webgl.viewport(0,0,this.canvas.width,this.canvas.height))};if("ResizeObserver"in window){new ResizeObserver(()=>{e()}).observe(this.canvas)}window.addEventListener("resize",e),this.canvas.addEventListener("webglcontextlost",e=>{console.log("[handleContextLost]"),e.preventDefault(),null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)},!1),this.canvas.addEventListener("webglcontextrestored",e=>{console.log("[handleContextRestored]"),this.webgl.clearColor(0,.06274509792,50*.00392156862,.7),this.webgl.enable(this.webgl.DEPTH_TEST),this.rafId=requestAnimationFrame(()=>this.tick())},!1),e()}tick(){return this.drawScene(),this.rafId=requestAnimationFrame(()=>this.tick()),this.rafId}drawScene(){this.astroSphere.draw(this.canvas)}}},7734(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(3890),o=i(7930),a=r(i(4382));t.default=class{insideSphere=!1;cam_pos=s.vec3.create();cam_speed=1;vMatrix=s.mat4.create();T=s.mat4.create();R=s.mat4.create();FoV=180;previousFoV=180;move=s.vec3.create();phi=0;theta=0;rotationSensitivity=1;lockRotX=!1;lockRotY=!1;lockRotZ=!1;constructor(e,t){this.init(e,t)}init(e,t){this.insideSphere=t,this.cam_pos=s.vec3.clone(e),this.vMatrix=s.mat4.create(),this.T=s.mat4.create(),this.R=s.mat4.create(),s.mat4.translate(this.T,this.T,[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]),this.FoV=this.previousFoV=180,this.move=s.vec3.clone([0,0,0]);this.goTo(0,0)}goTo(e,t){this.goToPhiTheta((0,o.astroDegToSpherical)(e,t))}goToPhiTheta(e){const t=(0,o.sphericalToCartesian)(e.phi,e.theta,this.cam_pos[2]),i=s.vec3.normalize(s.vec3.create(),s.vec3.fromValues(t[0],t[1],t[2])),r=s.vec3.fromValues(0,0,1),a=s.vec3.scale(s.vec3.create(),i,s.vec3.dot(r,i)),n=s.vec3.subtract(s.vec3.create(),r,a);s.vec3.length(n)<1e-6?s.vec3.set(n,0,1,0):s.vec3.normalize(n,n);let l=s.mat4.create();l=s.mat4.translate(l,l,s.vec3.fromValues(t[0],t[1],t[2]));const h=[l[12],l[13],l[14]];l=s.mat4.targetTo(l,h,[0,0,0],n),this.R=s.mat4.clone(l),this.R[12]=0,this.R[13]=0,this.R[14]=0;const c=s.mat4.create();0!==this.cam_pos[2]&&s.mat4.invert(c,l),this.vMatrix=c}toggleInsideSphere(){this.insideSphere=a.default.insideSphere,a.default.insideSphere?(this.cam_pos[0]=0,this.cam_pos[1]=0,this.cam_pos[2]=-.005):this.cam_pos[2]=2+this.cam_pos[2],s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}zoom(e){if(this.move=s.vec3.clone([0,0,0]),this.move[2]+=this.cam_speed*e,a.default.insideSphere)this.cam_pos[2]+this.move[2]>=-.005&&e>0?(this.cam_pos[2]=-.005,e=0):this.cam_pos[2]+this.move[2]<=-.9885&&e<0?(this.cam_pos[2]=-.9885,e=0):this.cam_pos[2]+=this.move[2];else{const t=Math.max(this.cam_pos[2]-1,1e-6),i=Math.min(1,t/.3),r=.015+.985*Math.pow(i,1.2);this.move[2]*=r,this.cam_pos[2]+this.move[2]<=1.000001&&e<0?this.cam_pos[2]=1.000001:this.cam_pos[2]+=this.move[2]}const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}moveAlongView(e){const t=s.mat4.create();s.mat4.invert(t,this.R);const i=s.vec3.fromValues(0,0,-1),r=s.vec3.create();s.vec3.transformMat4(r,i,t);const o=Math.hypot(r[0],r[1],r[2]);o>0&&(r[0]/=o,r[1]/=o,r[2]/=o),this.cam_pos[0]+=r[0]*e,this.cam_pos[1]+=r[1]*e,this.cam_pos[2]+=r[2]*e;const a=s.mat4.create();s.mat4.translate(this.T,a,this.cam_pos),this.refreshViewMatrix()}translate(e){this.cam_pos[2]=e+1;const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}rotateX(e){if(this.lockRotX)return;const t=.01*e;this.theta+=t,s.mat4.rotate(this.R,this.R,t,[1,0,0]),this.refreshViewMatrix()}rotateY(e){if(this.lockRotY)return;const t=.01*e;this.phi+=t,s.mat4.rotate(this.R,this.R,t,[0,1,0]),this.refreshViewMatrix()}rotateZ(e){if(this.lockRotZ)return;const t=.01*e;s.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshViewMatrix()}rotateXRadian(e){this.lockRotX||(s.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshViewMatrix())}rotateYRadian(e){this.lockRotY||(this.phi+=e,s.mat4.rotate(this.R,this.R,e,[0,1,0]),this.refreshViewMatrix())}rotateZRadian(e){this.lockRotZ||(s.mat4.rotate(this.R,this.R,e,[0,0,1]),this.refreshViewMatrix())}rotate(e,t){if(this.lockRotZ)return;const i=Math.sqrt(e*e+t*t);if(0===i)return;const r=this.getCameraPosition(),o=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),a=Math.max(o-1,1e-6),n=Math.min(1,a/.45),l=.02+.98*Math.pow(n,1.55),h=Math.min(1,this.FoV/18),c=i*l*(.06+1.55*Math.pow(h,.52))/1.9*this.rotationSensitivity;let u=t,d=e;const g=Math.sqrt(u*u+d*d);0!==g&&(u/=g,d/=g,s.mat4.rotate(this.R,this.R,-c,[u,d,0]),this.refreshViewMatrix())}setRotationSensitivity(e){this.rotationSensitivity=Math.min(3,Math.max(.2,e))}getRotationSensitivity(){return this.rotationSensitivity}refreshViewMatrix(){const e=s.mat4.create(),t=s.mat4.create();s.mat4.invert(e,this.T),s.mat4.invert(t,this.R),s.mat4.multiply(this.vMatrix,e,t)}refreshFoV(e){this.previousFoV=this.FoV,this.FoV=e}getCameraMatrix(){return this.vMatrix}getCameraPosition(){const e=s.mat4.create();return s.mat4.invert(e,this.vMatrix)?[e[12],e[13],e[14]]:[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]}setCameraMatrix(e){this.vMatrix=e}setCameraPosition(e){this.cam_pos=s.vec3.fromValues(e[0],e[1],e[2]),s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}getCameraAngle(){const[e,t,i]=this.getCameraPosition(),r=s.vec3.fromValues(e,t,i),a=(0,o.cartesianToSpherical)(r);return console.log("[Camera::getCameraAngle]",a),a}setRotationLock(e){void 0!==e.x&&(this.lockRotX=e.x),void 0!==e.y&&(this.lockRotY=e.y),void 0!==e.z&&(this.lockRotZ=e.z)}clearRotationLock(){this.lockRotX=this.lockRotY=this.lockRotZ=!1}isRotationLockedX(){return this.lockRotX}isRotationLockedY(){return this.lockRotY}isRotationLockedZ(){return this.lockRotZ}}},2919(e,t){"use strict";t.bootSetup=void 0,t.bootSetup={insideSphere:!1,defaultHips:"",camera_fov_deg:34,camera_fov_rad:34*Math.PI/180,inside_camera_fov_deg:60,inside_camera_fov_rad:60*Math.PI/180,camera_near_plane:1e-5,camera_far_plane:2.5,corsProxyUrl:"http://localhost:4000/",useCORSProxy:!1,maxDecimals:15,defaultHipsUrl:"https://cdn.skies.esac.esa.int/DSSColor/",version:"Astrobrowser v1.0.0",debug:!1,insideView:!1,showViewfinder:!0}},4382(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(4851),s=i(2919);const o=new class{_healpix;_selectionnside;_useCORSProxy;_corsProxyUrl;_maxDecimals;_debug;_insideSphere;_version;constructor(){this._useCORSProxy=s.bootSetup.useCORSProxy,this._corsProxyUrl=s.bootSetup.corsProxyUrl,this._maxDecimals=s.bootSetup.maxDecimals,this._debug=s.bootSetup.debug,this._insideSphere=s.bootSetup.insideView,this._version=s.bootSetup.version,this._healpix={},this._selectionnside=32}init(){console.log("Global.init()")}get version(){return this._version}set corsProxyUrl(e){this._corsProxyUrl=e}get corsProxyUrl(){return this._corsProxyUrl}get useCORSProxy(){return this._useCORSProxy}set useCORSProxy(e){this._useCORSProxy=e}get debug(){return this._debug}getHealpix(e){return void 0===this._healpix[e]&&(this._healpix[e]=new r.Healpix(Math.pow(2,e))),this._healpix[e]}get MAX_DECIMALS(){return this._maxDecimals}set insideSphere(e){this._insideSphere=e}get insideSphere(){return this._insideSphere}get nsideForSelection(){return this._selectionnside}};t.default=o},1229(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=t.Source=t.MeshHiPSDescriptor=t.MeshHiPS=t.WMTSAdapter=t.XYZMap=t.HiPS=t.createColorMapFromSamples=t.COLOR_MAP_SAMPLE_COUNT=t.ColorMaps=t.GeoJSONParser=t.CoordsType=t.FoVUtils=t.CartesianOpts=t.PointInitOpts=t.AstroOpts=t.SphericalOpts=t.Point=t.ColumnType=t.MetadataInit=t.MetadataColumn=t.MetadataManager=t.ObservationTrackViewerAdapter=t.ObservationTrackTimeline=t.footprintToRing=t.createObservationTrackTimeline=t.SensorConeGL=t.SatelliteObjectGL=t.TerraPolylineSetGL=t.TerraFootprintSetGL=t.TerraPointSetGL=t.CatalogueGL=t.FootprintSetGL=t.HoveredFootprintDetail=t.SphereFoV=t.FoV=t.HiPSDescriptor=t.AstroViewer=void 0;var s=i(772);Object.defineProperty(t,"AstroViewer",{enumerable:!0,get:function(){return s.AstroViewer}});var o=i(5087);Object.defineProperty(t,"HiPSDescriptor",{enumerable:!0,get:function(){return o.HiPSDescriptor}});var a=i(5803);Object.defineProperty(t,"FoV",{enumerable:!0,get:function(){return a.SphereFoV}});var n=i(5803);Object.defineProperty(t,"SphereFoV",{enumerable:!0,get:function(){return n.SphereFoV}});var l=i(592);Object.defineProperty(t,"HoveredFootprintDetail",{enumerable:!0,get:function(){return l.HoveredFootprintDetail}}),Object.defineProperty(t,"FootprintSetGL",{enumerable:!0,get:function(){return l.FootprintSetGL}});var h=i(1232);Object.defineProperty(t,"CatalogueGL",{enumerable:!0,get:function(){return h.CatalogueGL}});var c=i(5781);Object.defineProperty(t,"TerraPointSetGL",{enumerable:!0,get:function(){return c.TerraPointSetGL}});var u=i(9022);Object.defineProperty(t,"TerraFootprintSetGL",{enumerable:!0,get:function(){return u.TerraFootprintSetGL}});var d=i(3665);Object.defineProperty(t,"TerraPolylineSetGL",{enumerable:!0,get:function(){return d.TerraPolylineSetGL}});var g=i(3603);Object.defineProperty(t,"SatelliteObjectGL",{enumerable:!0,get:function(){return g.SatelliteObjectGL}});var _=i(3102);Object.defineProperty(t,"SensorConeGL",{enumerable:!0,get:function(){return _.SensorConeGL}});var p=i(5866);Object.defineProperty(t,"createObservationTrackTimeline",{enumerable:!0,get:function(){return p.createObservationTrackTimeline}}),Object.defineProperty(t,"footprintToRing",{enumerable:!0,get:function(){return p.footprintToRing}}),Object.defineProperty(t,"ObservationTrackTimeline",{enumerable:!0,get:function(){return p.ObservationTrackTimeline}}),Object.defineProperty(t,"ObservationTrackViewerAdapter",{enumerable:!0,get:function(){return p.ObservationTrackViewerAdapter}});var f=i(5403);Object.defineProperty(t,"MetadataManager",{enumerable:!0,get:function(){return f.MetadataManager}});var m=i(1072);Object.defineProperty(t,"MetadataColumn",{enumerable:!0,get:function(){return m.MetadataColumn}}),Object.defineProperty(t,"MetadataInit",{enumerable:!0,get:function(){return m.MetadataInit}}),Object.defineProperty(t,"ColumnType",{enumerable:!0,get:function(){return m.ColumnType}});var S=i(6553);Object.defineProperty(t,"Point",{enumerable:!0,get:function(){return S.Point}}),Object.defineProperty(t,"SphericalOpts",{enumerable:!0,get:function(){return S.SphericalOpts}}),Object.defineProperty(t,"AstroOpts",{enumerable:!0,get:function(){return S.AstroOpts}}),Object.defineProperty(t,"PointInitOpts",{enumerable:!0,get:function(){return S.PointInitOpts}}),Object.defineProperty(t,"CartesianOpts",{enumerable:!0,get:function(){return S.CartesianOpts}});var x=i(8083);Object.defineProperty(t,"FoVUtils",{enumerable:!0,get:function(){return x.FoVUtils}});var v=i(8145);Object.defineProperty(t,"CoordsType",{enumerable:!0,get:function(){return v.CoordsType}});var b=i(8755);Object.defineProperty(t,"GeoJSONParser",{enumerable:!0,get:function(){return r(b).default}});var M=i(619);Object.defineProperty(t,"ColorMaps",{enumerable:!0,get:function(){return M.ColorMaps}}),Object.defineProperty(t,"COLOR_MAP_SAMPLE_COUNT",{enumerable:!0,get:function(){return M.COLOR_MAP_SAMPLE_COUNT}}),Object.defineProperty(t,"createColorMapFromSamples",{enumerable:!0,get:function(){return M.createColorMapFromSamples}});var T=i(3726);Object.defineProperty(t,"HiPS",{enumerable:!0,get:function(){return T.HiPS}});var y=i(1741);Object.defineProperty(t,"XYZMap",{enumerable:!0,get:function(){return y.XYZMap}});var P=i(3956);Object.defineProperty(t,"WMTSAdapter",{enumerable:!0,get:function(){return P.WMTSAdapter}});var w=i(6878);Object.defineProperty(t,"MeshHiPS",{enumerable:!0,get:function(){return w.MeshHiPS}});var C=i(847);Object.defineProperty(t,"MeshHiPSDescriptor",{enumerable:!0,get:function(){return C.MeshHiPSDescriptor}});var E=i(146);Object.defineProperty(t,"Source",{enumerable:!0,get:function(){return E.Source}});var A=i(2475);Object.defineProperty(t,"Footprint",{enumerable:!0,get:function(){return A.Footprint}})},4735(e,t,i){"use strict";t.AbstractSkyEntity=void 0;const r=i(3890),s=i(7786);t.AbstractSkyEntity=class{refreshMe=!1;fovX_deg=180;fovY_deg=180;xRad;yRad;prevFoV=this.fovX_deg;_name;center;radius;isGalacticHips;vertexTextureCoordBuffer=null;vertexPositionBuffer=null;vertexIndexBuffer=null;shaderProgram=null;T=r.mat4.create();R=r.mat4.create();modelMatrix=r.mat4.create();inverseModelMatrix=r.mat4.create();galacticMatrixInverted=r.mat4.create();_webgl;_hipsShaderProgram;constructor(e,t,i,o,a,n,l){this._webgl=n,this.xRad=i,this.yRad=o,this._name=a,this.center=r.vec3.clone(t),this.radius=e,this.isGalacticHips=!!l,r.mat4.set(this.galacticMatrixInverted,-.054875582456588745,-.8734370470046997,-.48383501172065735,0,.49410945177078247,-.4448296129703522,.7469822764396667,0,-.8676661849021912,-.19807636737823486,.4559837877750397,0,0,0,0,1),this._hipsShaderProgram=new s.HiPSShaderProgram(this._webgl)}get name(){return this._name}get hipsShaderProgram(){return this._hipsShaderProgram}get webgl(){return this._webgl}initGL(e){this.vertexTextureCoordBuffer=e.createBuffer(),this.vertexPositionBuffer=e.createBuffer(),this.vertexIndexBuffer=e.createBuffer(),this.shaderProgram=e.createProgram(),this.T=r.mat4.create(),this.R=r.mat4.create(),this.modelMatrix=r.mat4.create(),this.inverseModelMatrix=r.mat4.create(),this.translate(this.center),this.rotate(this.xRad,this.yRad)}translate(e){r.mat4.translate(this.T,this.T,e),this.refreshModelMatrix()}rotate(e,t){r.mat4.rotate(this.R,this.R,t,[0,0,1]),r.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshModelMatrix()}rotateFromZero(e,t){r.mat4.identity(this.R),r.mat4.rotate(this.R,this.R,e,[1,0,0]),r.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshModelMatrix()}refreshModelMatrix(){const e=r.mat4.create();r.mat4.invert(e,this.R),r.mat4.multiply(this.modelMatrix,this.T,e),this.isGalacticHips&&r.mat4.multiply(this.modelMatrix,this.modelMatrix,this.galacticMatrixInverted)}getModelMatrixInverse(){return r.mat4.identity(this.inverseModelMatrix),r.mat4.invert(this.inverseModelMatrix,this.modelMatrix),this.inverseModelMatrix}getModelMatrix(){return this.modelMatrix}setModelMatrix(e){this.modelMatrix=e}setGeometryNeedsToBeRefreshed(){this.refreshGeometryOnFoVChanged=!1}rotateX(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[1],o=e[5],a=e[9];return e[1]=e[1]*i-e[2]*r,e[5]=e[5]*i-e[6]*r,e[9]=e[9]*i-e[10]*r,e[2]=e[2]*i+s*r,e[6]=e[6]*i+o*r,e[10]=e[10]*i+a*r,e}rotateY(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[0],o=e[4],a=e[8];return e[0]=i*e[0]+r*e[2],e[4]=i*e[4]+r*e[6],e[8]=i*e[8]+r*e[10],e[2]=i*e[2]-r*s,e[6]=i*e[6]-r*o,e[10]=i*e[10]-r*a,e}}},619(e,t){"use strict";function i(e,i){if(!Array.isArray(i))throw new Error(`Channel "${e}" must be an array.`);if(i.length!==t.COLOR_MAP_SAMPLE_COUNT)throw new Error(`Channel "${e}" must contain exactly ${t.COLOR_MAP_SAMPLE_COUNT} samples.`);for(let t=0;t<i.length;t+=1){const r=i[t];if(!Number.isFinite(r))throw new Error(`Channel "${e}" contains a non-finite value at index ${t}.`);if(r<0||r>255)throw new Error(`Channel "${e}" contains an out-of-range value at index ${t}. Expected 0..255.`)}}function r(e){const i=new Float32Array(4*t.COLOR_MAP_SAMPLE_COUNT);for(let r=0;r<t.COLOR_MAP_SAMPLE_COUNT;r+=1)i[4*r]=e[r];return i}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorMaps=t.COLOR_MAP_SAMPLE_COUNT=void 0,t.createColorMapFromSamples=function(e,t){const s=e.trim();if(!s)throw new Error("Color map name must not be empty.");return i("r",t.r),i("g",t.g),i("b",t.b),{name:s,r:r(t.r),g:r(t.g),b:r(t.b)}},t.COLOR_MAP_SAMPLE_COUNT=256,t.ColorMaps={grayscale:{name:"grayscale",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},native:{name:"native",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},planck:{name:"planck",r:new Float32Array([0,0,0,0,.769231,0,0,0,1.53846,0,0,0,2.30769,0,0,0,3.07692,0,0,0,3.84615,0,0,0,4.61538,0,0,0,5.38462,0,0,0,6.15385,0,0,0,6.92308,0,0,0,7.69231,0,0,0,8.46154,0,0,0,9.23077,0,0,0,10,0,0,0,11.5385,0,0,0,13.0769,0,0,0,14.6154,0,0,0,16.1538,0,0,0,17.6923,0,0,0,19.2308,0,0,0,20.7692,0,0,0,22.3077,0,0,0,23.8462,0,0,0,25.3846,0,0,0,26.9231,0,0,0,28.4615,0,0,0,30,0,0,0,33.8462,0,0,0,37.6923,0,0,0,41.5385,0,0,0,45.3846,0,0,0,49.2308,0,0,0,53.0769,0,0,0,56.9231,0,0,0,60.7692,0,0,0,64.6154,0,0,0,68.4615,0,0,0,72.3077,0,0,0,76.1538,0,0,0,80,0,0,0,88.5385,0,0,0,97.0769,0,0,0,105.615,0,0,0,114.154,0,0,0,122.692,0,0,0,131.231,0,0,0,139.769,0,0,0,148.308,0,0,0,156.846,0,0,0,165.385,0,0,0,173.923,0,0,0,182.462,0,0,0,191,0,0,0,193.846,0,0,0,196.692,0,0,0,199.538,0,0,0,202.385,0,0,0,205.231,0,0,0,208.077,0,0,0,210.923,0,0,0,213.769,0,0,0,216.615,0,0,0,219.462,0,0,0,222.308,0,0,0,225.154,0,0,0,228,0,0,0,229.182,0,0,0,230.364,0,0,0,231.545,0,0,0,232.727,0,0,0,233.909,0,0,0,235.091,0,0,0,236.273,0,0,0,237.455,0,0,0,238.636,0,0,0,239.818,0,0,0,241,0,0,0,241,0,0,0,241.364,0,0,0,241.727,0,0,0,242.091,0,0,0,242.455,0,0,0,242.818,0,0,0,243.182,0,0,0,243.545,0,0,0,243.909,0,0,0,244.273,0,0,0,244.636,0,0,0,245,0,0,0,245.231,0,0,0,245.462,0,0,0,245.692,0,0,0,245.923,0,0,0,246.154,0,0,0,246.385,0,0,0,246.615,0,0,0,246.846,0,0,0,247.077,0,0,0,247.308,0,0,0,247.538,0,0,0,247.769,0,0,0,248,0,0,0,248.146,0,0,0,248.292,0,0,0,248.438,0,0,0,248.585,0,0,0,248.731,0,0,0,248.877,0,0,0,249.023,0,0,0,249.169,0,0,0,249.315,0,0,0,249.462,0,0,0,249.608,0,0,0,249.754,0,0,0,249.9,0,0,0,249.312,0,0,0,248.723,0,0,0,248.135,0,0,0,247.546,0,0,0,246.958,0,0,0,246.369,0,0,0,245.781,0,0,0,245.192,0,0,0,244.604,0,0,0,244.015,0,0,0,243.427,0,0,0,242.838,0,0,0,242.25,0,0,0,239.308,0,0,0,236.365,0,0,0,233.423,0,0,0,230.481,0,0,0,227.538,0,0,0,224.596,0,0,0,221.654,0,0,0,218.712,0,0,0,215.769,0,0,0,212.827,0,0,0,209.885,0,0,0,206.942,0,0,0,204,0,0,0,201,0,0,0,198,0,0,0,195,0,0,0,192,0,0,0,189,0,0,0,186,0,0,0,183,0,0,0,180,0,0,0,177,0,0,0,174,0,0,0,171,0,0,0,168,0,0,0,165,0,0,0,161.077,0,0,0,157.154,0,0,0,153.231,0,0,0,149.308,0,0,0,145.385,0,0,0,141.462,0,0,0,137.538,0,0,0,133.615,0,0,0,129.692,0,0,0,125.769,0,0,0,121.846,0,0,0,117.923,0,0,0,114,0,0,0,115.038,0,0,0,116.077,0,0,0,117.115,0,0,0,118.154,0,0,0,119.192,0,0,0,120.231,0,0,0,121.269,0,0,0,122.308,0,0,0,123.346,0,0,0,124.385,0,0,0,125.423,0,0,0,126.462,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),g:new Float32Array([0,0,0,0,1.53846,0,0,0,3.07692,0,0,0,4.61538,0,0,0,6.15385,0,0,0,7.69231,0,0,0,9.23077,0,0,0,10.7692,0,0,0,12.3077,0,0,0,13.8462,0,0,0,15.3846,0,0,0,16.9231,0,0,0,18.4615,0,0,0,20,0,0,0,32.6154,0,0,0,45.2308,0,0,0,57.8462,0,0,0,70.4615,0,0,0,83.0769,0,0,0,95.6923,0,0,0,108.308,0,0,0,120.923,0,0,0,133.538,0,0,0,146.154,0,0,0,158.769,0,0,0,171.385,0,0,0,184,0,0,0,187.923,0,0,0,191.846,0,0,0,195.769,0,0,0,199.692,0,0,0,203.615,0,0,0,207.538,0,0,0,211.462,0,0,0,215.385,0,0,0,219.308,0,0,0,223.231,0,0,0,227.154,0,0,0,231.077,0,0,0,235,0,0,0,235.308,0,0,0,235.615,0,0,0,235.923,0,0,0,236.231,0,0,0,236.538,0,0,0,236.846,0,0,0,237.154,0,0,0,237.462,0,0,0,237.769,0,0,0,238.077,0,0,0,238.385,0,0,0,238.692,0,0,0,239,0,0,0,239.077,0,0,0,239.154,0,0,0,239.231,0,0,0,239.308,0,0,0,239.385,0,0,0,239.462,0,0,0,239.538,0,0,0,239.615,0,0,0,239.692,0,0,0,239.769,0,0,0,239.846,0,0,0,239.923,0,0,0,240,0,0,0,240.091,0,0,0,240.182,0,0,0,240.273,0,0,0,240.364,0,0,0,240.455,0,0,0,240.545,0,0,0,240.636,0,0,0,240.727,0,0,0,240.818,0,0,0,240.909,0,0,0,241,0,0,0,241,0,0,0,240.909,0,0,0,240.818,0,0,0,240.727,0,0,0,240.636,0,0,0,240.545,0,0,0,240.455,0,0,0,240.364,0,0,0,240.273,0,0,0,240.182,0,0,0,240.091,0,0,0,240,0,0,0,239.615,0,0,0,239.231,0,0,0,238.846,0,0,0,238.462,0,0,0,238.077,0,0,0,237.692,0,0,0,237.308,0,0,0,236.923,0,0,0,236.538,0,0,0,236.154,0,0,0,235.769,0,0,0,235.385,0,0,0,235,0,0,0,232.615,0,0,0,230.231,0,0,0,227.846,0,0,0,225.462,0,0,0,223.077,0,0,0,220.692,0,0,0,218.308,0,0,0,215.923,0,0,0,213.538,0,0,0,211.154,0,0,0,208.769,0,0,0,206.385,0,0,0,204,0,0,0,200.077,0,0,0,196.154,0,0,0,192.231,0,0,0,188.308,0,0,0,184.385,0,0,0,180.462,0,0,0,176.538,0,0,0,172.615,0,0,0,168.692,0,0,0,164.769,0,0,0,160.846,0,0,0,156.923,0,0,0,153,0,0,0,147.115,0,0,0,141.231,0,0,0,135.346,0,0,0,129.462,0,0,0,123.577,0,0,0,117.692,0,0,0,111.808,0,0,0,105.923,0,0,0,100.038,0,0,0,94.1538,0,0,0,88.2692,0,0,0,82.3846,0,0,0,76.5,0,0,0,73.0769,0,0,0,69.6538,0,0,0,66.2308,0,0,0,62.8077,0,0,0,59.3846,0,0,0,55.9615,0,0,0,52.5385,0,0,0,49.1154,0,0,0,45.6923,0,0,0,42.2692,0,0,0,38.8462,0,0,0,35.4231,0,0,0,32,0,0,0,29.5385,0,0,0,27.0769,0,0,0,24.6154,0,0,0,22.1538,0,0,0,19.6923,0,0,0,17.2308,0,0,0,14.7692,0,0,0,12.3077,0,0,0,9.84615,0,0,0,7.38462,0,0,0,4.92308,0,0,0,2.46154,0,0,0,0,0,0,0,9.80769,0,0,0,19.6154,0,0,0,29.4231,0,0,0,39.2308,0,0,0,49.0385,0,0,0,58.8462,0,0,0,68.6538,0,0,0,78.4615,0,0,0,88.2692,0,0,0,98.0769,0,0,0,107.885,0,0,0,117.692,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254.615,0,0,0,254.231,0,0,0,253.846,0,0,0,253.462,0,0,0,253.077,0,0,0,252.692,0,0,0,252.308,0,0,0,251.923,0,0,0,251.538,0,0,0,251.154,0,0,0,250.769,0,0,0,250.385,0,0,0,250,0,0,0,249.615,0,0,0,249.231,0,0,0,248.846,0,0,0,248.462,0,0,0,248.077,0,0,0,247.692,0,0,0,247.308,0,0,0,246.923,0,0,0,246.538,0,0,0,246.154,0,0,0,245.769,0,0,0,245.385,0,0,0,245,0,0,0,242,0,0,0,239,0,0,0,236,0,0,0,233,0,0,0,230,0,0,0,227,0,0,0,224,0,0,0,221,0,0,0,218,0,0,0,215,0,0,0,212,0,0,0,212,0,0,0,208.636,0,0,0,205.273,0,0,0,201.909,0,0,0,198.545,0,0,0,195.182,0,0,0,191.818,0,0,0,188.455,0,0,0,185.091,0,0,0,181.727,0,0,0,178.364,0,0,0,175,0,0,0,171.538,0,0,0,168.077,0,0,0,164.615,0,0,0,161.154,0,0,0,157.692,0,0,0,154.231,0,0,0,150.769,0,0,0,147.308,0,0,0,143.846,0,0,0,140.385,0,0,0,136.923,0,0,0,133.462,0,0,0,130,0,0,0,122.942,0,0,0,115.885,0,0,0,108.827,0,0,0,101.769,0,0,0,94.7115,0,0,0,87.6539,0,0,0,80.5962,0,0,0,73.5385,0,0,0,66.4808,0,0,0,59.4231,0,0,0,52.3654,0,0,0,45.3077,0,0,0,38.25,0,0,0,36.2885,0,0,0,34.3269,0,0,0,32.3654,0,0,0,30.4038,0,0,0,28.4423,0,0,0,26.4808,0,0,0,24.5192,0,0,0,22.5577,0,0,0,20.5962,0,0,0,18.6346,0,0,0,16.6731,0,0,0,14.7115,0,0,0,12.75,0,0,0,11.7692,0,0,0,10.7885,0,0,0,9.80769,0,0,0,8.82692,0,0,0,7.84615,0,0,0,6.86539,0,0,0,5.88461,0,0,0,4.90385,0,0,0,3.92308,0,0,0,2.94231,0,0,0,1.96154,0,0,0,.980769,0,0,0,0,0,0,0,2.46154,0,0,0,4.92308,0,0,0,7.38462,0,0,0,9.84616,0,0,0,12.3077,0,0,0,14.7692,0,0,0,17.2308,0,0,0,19.6923,0,0,0,22.1538,0,0,0,24.6154,0,0,0,27.0769,0,0,0,29.5385,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,41.3077,0,0,0,50.6154,0,0,0,59.9231,0,0,0,69.2308,0,0,0,78.5385,0,0,0,87.8462,0,0,0,97.1539,0,0,0,106.462,0,0,0,115.769,0,0,0,125.077,0,0,0,134.385,0,0,0,143.692,0,0,0,153,0,0,0,156.923,0,0,0,160.846,0,0,0,164.769,0,0,0,168.692,0,0,0,172.615,0,0,0,176.538,0,0,0,180.462,0,0,0,184.385,0,0,0,188.308,0,0,0,192.231,0,0,0,196.154,0,0,0,200.077,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.838,0,0,0,243.427,0,0,0,244.015,0,0,0,244.604,0,0,0,245.192,0,0,0,245.781,0,0,0,246.369,0,0,0,246.958,0,0,0,247.546,0,0,0,248.135,0,0,0,248.723,0,0,0,249.312,0,0,0,249.9,0,0,0,250.096,0,0,0,250.292,0,0,0,250.488,0,0,0,250.685,0,0,0,250.881,0,0,0,251.077,0,0,0,251.273,0,0,0,251.469,0,0,0,251.665,0,0,0,251.862,0,0,0,252.058,0,0,0,252.254,0,0,0,252.45,0,0,0,252.682,0,0,0,252.914,0,0,0,253.145,0,0,0,253.377,0,0,0,253.609,0,0,0,253.841,0,0,0,254.073,0,0,0,254.305,0,0,0,254.536,0,0,0,254.768,0,0,0,255,0,0,0])},cmb:{name:"cmb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,12,0,0,0,18,0,0,0,24,0,0,0,30,0,0,0,36,0,0,0,42,0,0,0,48,0,0,0,54,0,0,0,60,0,0,0,66,0,0,0,72,0,0,0,78,0,0,0,85,0,0,0,91,0,0,0,97,0,0,0,103,0,0,0,109,0,0,0,115,0,0,0,121,0,0,0,127,0,0,0,133,0,0,0,139,0,0,0,145,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,170,0,0,0,176,0,0,0,182,0,0,0,188,0,0,0,194,0,0,0,200,0,0,0,206,0,0,0,212,0,0,0,218,0,0,0,224,0,0,0,230,0,0,0,236,0,0,0,242,0,0,0,248,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,251,0,0,0,247,0,0,0,244,0,0,0,240,0,0,0,236,0,0,0,233,0,0,0,229,0,0,0,226,0,0,0,222,0,0,0,218,0,0,0,215,0,0,0,211,0,0,0,208,0,0,0,204,0,0,0,200,0,0,0,197,0,0,0,193,0,0,0,190,0,0,0,186,0,0,0,182,0,0,0,179,0,0,0,175,0,0,0,172,0,0,0,168,0,0,0,164,0,0,0,161,0,0,0,157,0,0,0,154,0,0,0,150,0,0,0,146,0,0,0,143,0,0,0,139,0,0,0,136,0,0,0,132,0,0,0,128,0,0,0,125,0,0,0,121,0,0,0,118,0,0,0,114,0,0,0,110,0,0,0,107,0,0,0,103,0,0,0,100,0,0,0]),g:new Float32Array([0,0,0,0,2,0,0,0,5,0,0,0,8,0,0,0,10,0,0,0,13,0,0,0,16,0,0,0,18,0,0,0,21,0,0,0,24,0,0,0,26,0,0,0,29,0,0,0,32,0,0,0,34,0,0,0,37,0,0,0,40,0,0,0,42,0,0,0,45,0,0,0,48,0,0,0,50,0,0,0,53,0,0,0,56,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,66,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,80,0,0,0,82,0,0,0,85,0,0,0,88,0,0,0,90,0,0,0,93,0,0,0,96,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,106,0,0,0,109,0,0,0,112,0,0,0,114,0,0,0,117,0,0,0,119,0,0,0,122,0,0,0,124,0,0,0,127,0,0,0,129,0,0,0,132,0,0,0,134,0,0,0,137,0,0,0,139,0,0,0,142,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,152,0,0,0,155,0,0,0,157,0,0,0,160,0,0,0,162,0,0,0,165,0,0,0,167,0,0,0,170,0,0,0,172,0,0,0,175,0,0,0,177,0,0,0,180,0,0,0,182,0,0,0,185,0,0,0,188,0,0,0,190,0,0,0,193,0,0,0,195,0,0,0,198,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,208,0,0,0,210,0,0,0,213,0,0,0,215,0,0,0,218,0,0,0,221,0,0,0,221,0,0,0,221,0,0,0,222,0,0,0,222,0,0,0,222,0,0,0,223,0,0,0,223,0,0,0,224,0,0,0,224,0,0,0,224,0,0,0,225,0,0,0,225,0,0,0,225,0,0,0,226,0,0,0,226,0,0,0,227,0,0,0,227,0,0,0,227,0,0,0,228,0,0,0,228,0,0,0,229,0,0,0,229,0,0,0,229,0,0,0,230,0,0,0,230,0,0,0,230,0,0,0,231,0,0,0,231,0,0,0,232,0,0,0,232,0,0,0,232,0,0,0,233,0,0,0,233,0,0,0,233,0,0,0,234,0,0,0,234,0,0,0,235,0,0,0,235,0,0,0,235,0,0,0,236,0,0,0,236,0,0,0,237,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,227,0,0,0,226,0,0,0,225,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,215,0,0,0,214,0,0,0,213,0,0,0,211,0,0,0,210,0,0,0,209,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,195,0,0,0,194,0,0,0,193,0,0,0,191,0,0,0,190,0,0,0,189,0,0,0,187,0,0,0,186,0,0,0,185,0,0,0,183,0,0,0,182,0,0,0,181,0,0,0,180,0,0,0,177,0,0,0,175,0,0,0,172,0,0,0,170,0,0,0,167,0,0,0,165,0,0,0,162,0,0,0,160,0,0,0,157,0,0,0,155,0,0,0,152,0,0,0,150,0,0,0,147,0,0,0,145,0,0,0,142,0,0,0,140,0,0,0,137,0,0,0,135,0,0,0,132,0,0,0,130,0,0,0,127,0,0,0,125,0,0,0,122,0,0,0,120,0,0,0,117,0,0,0,115,0,0,0,112,0,0,0,110,0,0,0,107,0,0,0,105,0,0,0,102,0,0,0,100,0,0,0,97,0,0,0,95,0,0,0,92,0,0,0,90,0,0,0,87,0,0,0,85,0,0,0,82,0,0,0,80,0,0,0,77,0,0,0,75,0,0,0,73,0,0,0,71,0,0,0,69,0,0,0,68,0,0,0,66,0,0,0,64,0,0,0,62,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,54,0,0,0,52,0,0,0,50,0,0,0,48,0,0,0,47,0,0,0,45,0,0,0,43,0,0,0,41,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,34,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,26,0,0,0,24,0,0,0,22,0,0,0,20,0,0,0,19,0,0,0,17,0,0,0,15,0,0,0,13,0,0,0,12,0,0,0,10,0,0,0,8,0,0,0,6,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254,0,0,0,253,0,0,0,252,0,0,0,251,0,0,0,250,0,0,0,249,0,0,0,248,0,0,0,247,0,0,0,246,0,0,0,245,0,0,0,245,0,0,0,244,0,0,0,243,0,0,0,242,0,0,0,241,0,0,0,240,0,0,0,239,0,0,0,238,0,0,0,237,0,0,0,236,0,0,0,236,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,232,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,228,0,0,0,227,0,0,0,226,0,0,0,226,0,0,0,225,0,0,0,224,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,220,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,217,0,0,0,211,0,0,0,206,0,0,0,201,0,0,0,196,0,0,0,191,0,0,0,186,0,0,0,181,0,0,0,176,0,0,0,171,0,0,0,166,0,0,0,161,0,0,0,156,0,0,0,151,0,0,0,146,0,0,0,141,0,0,0,136,0,0,0,131,0,0,0,126,0,0,0,121,0,0,0,116,0,0,0,111,0,0,0,105,0,0,0,100,0,0,0,95,0,0,0,90,0,0,0,85,0,0,0,80,0,0,0,75,0,0,0,70,0,0,0,65,0,0,0,60,0,0,0,55,0,0,0,50,0,0,0,45,0,0,0,40,0,0,0,35,0,0,0,30,0,0,0,25,0,0,0,20,0,0,0,15,0,0,0,10,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},rainbow:{name:"rainbow",r:new Float32Array([0,0,0,0,4,0,0,0,9,0,0,0,13,0,0,0,18,0,0,0,22,0,0,0,27,0,0,0,31,0,0,0,36,0,0,0,40,0,0,0,45,0,0,0,50,0,0,0,54,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,68,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,79,0,0,0,80,0,0,0,82,0,0,0,83,0,0,0,85,0,0,0,84,0,0,0,86,0,0,0,87,0,0,0,88,0,0,0,86,0,0,0,87,0,0,0,87,0,0,0,87,0,0,0,85,0,0,0,84,0,0,0,84,0,0,0,84,0,0,0,83,0,0,0,79,0,0,0,78,0,0,0,77,0,0,0,76,0,0,0,71,0,0,0,70,0,0,0,68,0,0,0,66,0,0,0,60,0,0,0,58,0,0,0,55,0,0,0,53,0,0,0,46,0,0,0,43,0,0,0,40,0,0,0,36,0,0,0,33,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,12,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,33,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,80,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,101,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,123,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,153,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,169,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,212,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,38,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,84,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,106,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,127,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,152,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,195,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,216,0,0,0,220,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,250,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,221,0,0,0,216,0,0,0,212,0,0,0,208,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,161,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,119,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,85,0,0,0,80,0,0,0,76,0,0,0,72,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,51,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,29,0,0,0,21,0,0,0,17,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0]),b:new Float32Array([0,0,0,0,3,0,0,0,7,0,0,0,10,0,0,0,14,0,0,0,19,0,0,0,23,0,0,0,28,0,0,0,32,0,0,0,38,0,0,0,43,0,0,0,48,0,0,0,53,0,0,0,59,0,0,0,63,0,0,0,68,0,0,0,72,0,0,0,77,0,0,0,81,0,0,0,86,0,0,0,91,0,0,0,95,0,0,0,100,0,0,0,104,0,0,0,109,0,0,0,113,0,0,0,118,0,0,0,122,0,0,0,127,0,0,0,132,0,0,0,136,0,0,0,141,0,0,0,145,0,0,0,150,0,0,0,154,0,0,0,159,0,0,0,163,0,0,0,168,0,0,0,173,0,0,0,177,0,0,0,182,0,0,0,186,0,0,0,191,0,0,0,195,0,0,0,200,0,0,0,204,0,0,0,209,0,0,0,214,0,0,0,218,0,0,0,223,0,0,0,227,0,0,0,232,0,0,0,236,0,0,0,241,0,0,0,245,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,225,0,0,0,220,0,0,0,216,0,0,0,212,0,0,0,203,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,157,0,0,0,152,0,0,0,148,0,0,0,144,0,0,0,135,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,114,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,84,0,0,0,80,0,0,0,76,0,0,0,67,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,46,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},eosb:{name:"eosb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,18,0,0,0,27,0,0,0,36,0,0,0,45,0,0,0,49,0,0,0,57,0,0,0,72,0,0,0,81,0,0,0,91,0,0,0,100,0,0,0,109,0,0,0,118,0,0,0,127,0,0,0,136,0,0,0,131,0,0,0,139,0,0,0,163,0,0,0,173,0,0,0,182,0,0,0,191,0,0,0,200,0,0,0,209,0,0,0,218,0,0,0,227,0,0,0,213,0,0,0,221,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,253,0,0,0,251,0,0,0,249,0,0,0,247,0,0,0,245,0,0,0,243,0,0,0,241,0,0,0,215,0,0,0,214,0,0,0,235,0,0,0,234,0,0,0,232,0,0,0,230,0,0,0,228,0,0,0,226,0,0,0,224,0,0,0,222,0,0,0,198,0,0,0,196,0,0,0,216,0,0,0,215,0,0,0,213,0,0,0,211,0,0,0,209,0,0,0,207,0,0,0,205,0,0,0,203,0,0,0,181,0,0,0,179,0,0,0,197,0,0,0,196,0,0,0,194,0,0,0,192,0,0,0,190,0,0,0,188,0,0,0,186,0,0,0,184,0,0,0,164,0,0,0,162,0,0,0,178,0,0,0,176,0,0,0,175,0,0,0,173,0,0,0,171,0,0,0,169,0,0,0,167,0,0,0,165,0,0,0,147,0,0,0,145,0,0,0,159,0,0,0,157,0,0,0,156,0,0,0,154,0,0,0,152,0,0,0,150,0,0,0,148,0,0,0,146,0,0,0,130,0,0,0,128,0,0,0,140,0,0,0,138,0,0,0,137,0,0,0,135,0,0,0,133,0,0,0,131,0,0,0,129,0,0,0,127,0,0,0,113,0,0,0,111,0,0,0,121,0,0,0,119,0,0,0,117,0,0,0,117,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,15,0,0,0,23,0,0,0,31,0,0,0,39,0,0,0,47,0,0,0,55,0,0,0,57,0,0,0,64,0,0,0,79,0,0,0,87,0,0,0,95,0,0,0,103,0,0,0,111,0,0,0,119,0,0,0,127,0,0,0,135,0,0,0,129,0,0,0,136,0,0,0,159,0,0,0,167,0,0,0,175,0,0,0,183,0,0,0,191,0,0,0,199,0,0,0,207,0,0,0,215,0,0,0,200,0,0,0,207,0,0,0,239,0,0,0,247,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,250,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,225,0,0,0,198,0,0,0,195,0,0,0,212,0,0,0,208,0,0,0,204,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,182,0,0,0,160,0,0,0,156,0,0,0,169,0,0,0,165,0,0,0,161,0,0,0,157,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,122,0,0,0,118,0,0,0,127,0,0,0,125,0,0,0,123,0,0,0,121,0,0,0,119,0,0,0,116,0,0,0,114,0,0,0,112,0,0,0,99,0,0,0,97,0,0,0,106,0,0,0,104,0,0,0,102,0,0,0,99,0,0,0,97,0,0,0,95,0,0,0,93,0,0,0,91,0,0,0,80,0,0,0,78,0,0,0,84,0,0,0,82,0,0,0,80,0,0,0,78,0,0,0,76,0,0,0,74,0,0,0,72,0,0,0,70,0,0,0,61,0,0,0,59,0,0,0,63,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,53,0,0,0,50,0,0,0,48,0,0,0,42,0,0,0,40,0,0,0,42,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,19,0,0,0,16,0,0,0,14,0,0,0,12,0,0,0,13,0,0,0,8,0,0,0,6,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),b:new Float32Array([116,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,136,0,0,0,140,0,0,0,144,0,0,0,148,0,0,0,153,0,0,0,157,0,0,0,145,0,0,0,149,0,0,0,170,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,195,0,0,0,199,0,0,0,183,0,0,0,187,0,0,0,212,0,0,0,216,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,238,0,0,0,242,0,0,0,221,0,0,0,225,0,0,0,255,0,0,0,247,0,0,0,239,0,0,0,231,0,0,0,223,0,0,0,215,0,0,0,207,0,0,0,199,0,0,0,172,0,0,0,164,0,0,0,175,0,0,0,167,0,0,0,159,0,0,0,151,0,0,0,143,0,0,0,135,0,0,0,127,0,0,0,119,0,0,0,100,0,0,0,93,0,0,0,95,0,0,0,87,0,0,0,79,0,0,0,71,0,0,0,63,0,0,0,55,0,0,0,47,0,0,0,39,0,0,0,28,0,0,0,21,0,0,0,15,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},cubehelix:{name:"cubehelix",r:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,24,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,24,0,0,0,24,0,0,0,24,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,20,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,27,0,0,0,28,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,35,0,0,0,36,0,0,0,38,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,49,0,0,0,51,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,60,0,0,0,62,0,0,0,65,0,0,0,67,0,0,0,70,0,0,0,72,0,0,0,75,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,89,0,0,0,92,0,0,0,95,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,107,0,0,0,110,0,0,0,113,0,0,0,116,0,0,0,120,0,0,0,123,0,0,0,126,0,0,0,129,0,0,0,132,0,0,0,135,0,0,0,138,0,0,0,141,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,153,0,0,0,155,0,0,0,158,0,0,0,161,0,0,0,164,0,0,0,166,0,0,0,169,0,0,0,171,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,181,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,199,0,0,0,201,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,207,0,0,0,208,0,0,0,209,0,0,0,209,0,0,0,210,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,210,0,0,0,210,0,0,0,210,0,0,0,209,0,0,0,208,0,0,0,208,0,0,0,207,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,205,0,0,0,204,0,0,0,203,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,201,0,0,0,200,0,0,0,199,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,197,0,0,0,196,0,0,0,196,0,0,0,195,0,0,0,195,0,0,0,194,0,0,0,194,0,0,0,194,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,194,0,0,0,194,0,0,0,195,0,0,0,195,0,0,0,196,0,0,0,196,0,0,0,197,0,0,0,198,0,0,0,199,0,0,0,200,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,208,0,0,0,209,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,217,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,223,0,0,0,225,0,0,0,227,0,0,0,229,0,0,0,231,0,0,0,232,0,0,0,234,0,0,0,236,0,0,0,238,0,0,0,240,0,0,0,242,0,0,0,244,0,0,0,245,0,0,0,247,0,0,0,249,0,0,0,251,0,0,0,253,0,0,0,255]),g:new Float32Array([0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,28,0,0,0,29,0,0,0,31,0,0,0,32,0,0,0,34,0,0,0,35,0,0,0,37,0,0,0,38,0,0,0,40,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,46,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,58,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,73,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,79,0,0,0,81,0,0,0,83,0,0,0,84,0,0,0,86,0,0,0,88,0,0,0,89,0,0,0,91,0,0,0,92,0,0,0,94,0,0,0,95,0,0,0,97,0,0,0,98,0,0,0,99,0,0,0,101,0,0,0,102,0,0,0,103,0,0,0,104,0,0,0,106,0,0,0,107,0,0,0,108,0,0,0,109,0,0,0,110,0,0,0,111,0,0,0,112,0,0,0,113,0,0,0,114,0,0,0,114,0,0,0,115,0,0,0,116,0,0,0,116,0,0,0,117,0,0,0,118,0,0,0,118,0,0,0,119,0,0,0,119,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,123,0,0,0,123,0,0,0,124,0,0,0,124,0,0,0,125,0,0,0,125,0,0,0,126,0,0,0,127,0,0,0,127,0,0,0,128,0,0,0,129,0,0,0,130,0,0,0,131,0,0,0,131,0,0,0,132,0,0,0,133,0,0,0,135,0,0,0,136,0,0,0,137,0,0,0,138,0,0,0,139,0,0,0,140,0,0,0,142,0,0,0,143,0,0,0,144,0,0,0,146,0,0,0,147,0,0,0,149,0,0,0,150,0,0,0,152,0,0,0,154,0,0,0,155,0,0,0,157,0,0,0,158,0,0,0,160,0,0,0,162,0,0,0,164,0,0,0,165,0,0,0,167,0,0,0,169,0,0,0,171,0,0,0,172,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,180,0,0,0,182,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,208,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,216,0,0,0,218,0,0,0,219,0,0,0,221,0,0,0,222,0,0,0,224,0,0,0,225,0,0,0,226,0,0,0,228,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,232,0,0,0,233,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,247,0,0,0,248,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,250,0,0,0,251,0,0,0,251,0,0,0,252,0,0,0,252,0,0,0,253,0,0,0,253,0,0,0,254,0,0,0,255,0,0,0]),b:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,11,0,0,0,13,0,0,0,15,0,0,0,17,0,0,0,19,0,0,0,21,0,0,0,23,0,0,0,25,0,0,0,27,0,0,0,29,0,0,0,31,0,0,0,33,0,0,0,35,0,0,0,37,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,54,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,63,0,0,0,65,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,70,0,0,0,71,0,0,0,72,0,0,0,73,0,0,0,74,0,0,0,74,0,0,0,75,0,0,0,76,0,0,0,76,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,76,0,0,0,76,0,0,0,75,0,0,0,75,0,0,0,74,0,0,0,73,0,0,0,73,0,0,0,72,0,0,0,71,0,0,0,70,0,0,0,69,0,0,0,68,0,0,0,67,0,0,0,66,0,0,0,66,0,0,0,65,0,0,0,64,0,0,0,63,0,0,0,61,0,0,0,60,0,0,0,59,0,0,0,58,0,0,0,58,0,0,0,57,0,0,0,56,0,0,0,55,0,0,0,54,0,0,0,53,0,0,0,52,0,0,0,51,0,0,0,51,0,0,0,50,0,0,0,49,0,0,0,49,0,0,0,48,0,0,0,48,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,48,0,0,0,48,0,0,0,49,0,0,0,50,0,0,0,50,0,0,0,51,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,65,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,88,0,0,0,91,0,0,0,94,0,0,0,96,0,0,0,99,0,0,0,102,0,0,0,105,0,0,0,108,0,0,0,111,0,0,0,114,0,0,0,117,0,0,0,120,0,0,0,124,0,0,0,127,0,0,0,130,0,0,0,133,0,0,0,136,0,0,0,140,0,0,0,143,0,0,0,146,0,0,0,149,0,0,0,153,0,0,0,156,0,0,0,159,0,0,0,162,0,0,0,165,0,0,0,169,0,0,0,172,0,0,0,175,0,0,0,178,0,0,0,181,0,0,0,184,0,0,0,186,0,0,0,189,0,0,0,192,0,0,0,195,0,0,0,197,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,210,0,0,0,212,0,0,0,214,0,0,0,216,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,224,0,0,0,226,0,0,0,227,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,233,0,0,0,234,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,241,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,252,0,0,0,253,0,0,0,255,0,0,0])},hot:{name:"hot",r:new Float32Array([0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.30769,4.61538,6.92308,9.23077,11.5385,13.8462,16.1538,18.4615,20.7692,23.0769,25.3846,27.6923,30,32.3077,34.6154,36.9231,39.2308,41.5385,43.8462,46.1538,48.4615,50.7692,53.0769,55.3846,57.6923,60,62.3077,64.6154,66.9231,69.2308,71.5385,73.8462,76.1538,78.4615,80.7692,83.0769,85.3846,87.6923,90,92.3077,94.6154,96.9231,99.2308,101.538,103.846,106.154,108.462,110.769,113.077,115.385,117.692,120,122.308,124.615,126.923,129.231,131.538,133.846,136.154,138.462,140.769,143.077,145.385,147.692,150,152.308,154.615,156.923,159.231,161.538,163.846,166.154,168.462,170.769,173.077,175.385,177.692,180,182.308,184.615,186.923,189.231,191.538,193.846,196.154,198.462,200.769,203.077,205.385,207.692,210,212.308,214.615,216.923,219.231,221.538,223.846,226.154,228.462,230.769,233.077,235.385,237.692,240,242.308,244.615,246.923,249.231,251.538,253.846,255,255,255,255,255,255,255]),b:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.980769,1.96154,2.94231,3.92308,4.90385,5.88461,6.86539,7.84615,8.82692,9.80769,10.7885,11.7692,12.75,13.7308,14.7115,15.6923,16.6731,17.6538,18.6346,19.6154,20.5962,21.5769,22.5577,23.5385,24.5192,25.5,26.4808,27.4615,28.4423,29.4231,30.4038,31.3846,32.3654,33.3462,34.3269,35.3077,36.2885,37.2692,38.25,39.2308,40.2115,41.1923,42.1731,43.1538,44.1346,45.1154,46.0962,47.0769,48.0577,49.0385,50.0192,51,51.9808,52.9615,53.9423,54.9231,55.9038,56.8846,57.8654,58.8462,59.8269,60.8077,61.7885,62.7692,63.75,64.7308,65.7115,66.6923,67.6731,68.6538,69.6346,70.6154,71.5962,72.5769,73.5577,74.5385,75.5192,76.5,77.4808,78.4615,79.4423,80.4231,81.4038,82.3846,83.3654,84.3462,85.3269,86.3077,87.2885,88.2692,89.25,90.2308,91.2115,92.1923,93.1731,94.1538,95.1346,96.1154,97.0962,98.0769,99.0577,100.038,101.019,102,102.981,103.962,104.942,105.923,106.904,107.885,108.865,109.846,110.827,111.808,112.788,113.769,114.75,115.731,116.711,117.692,118.673,119.654,120.634,121.615,122.596,123.577,124.557,125.538,126.519,127.5])},gray:{name:"gray",r:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),g:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),b:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255])}},t.default=t.ColorMaps},1072(e,t){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataColumn=t.ColumnType=void 0,function(e){e.STRING="STRING",e.NUMBER="NUMBER",e.GEOM_RA="GEOM_RA",e.GEOM_DEC="GEOM_DEC",e.GEOM_FOOTPRINT="GEOM_FOOTPRINT",e.MAIN_NAME="MAIN_NAME"}(i||(t.ColumnType=i={}));t.MetadataColumn=class{_index;_name;_description="";_columnType;_unit;_details=new Map;constructor(e){if(!e.name)throw new Error("No name column defined.");if(this._name=e.name,e.index<0||isNaN(e.index))throw new Error("No index column defined.");this._index=e.index,this._columnType=e.columnType??i.STRING,this._unit=e.unit??"",this._description=e.description??"",e.details&&(this._details=new Map(e.details))}get details(){return new Map(this._details)}getDetail(e,t){return this._details.has(e)?this._details.get(e):t}getString(e,t=""){const i=this._details.get(e);return"string"==typeof i?i:t}getNumber(e,t=NaN){const i=this._details.get(e);return"number"==typeof i?i:t}setDetail(e,t){this._details.set(e,t)}setDetails(e){const t=e instanceof Map?e.entries():Object.entries(e);for(const[e,i]of t)this._details.set(e,i)}detailKeys(){return Array.from(this._details.keys())}detailValues(){return Array.from(this._details.values())}detailEntries(){return Array.from(this._details.entries())}get name(){return this._name}get description(){return this._description}get columnType(){return this._columnType}get index(){return this._index}get unit(){return this._unit}toJSON(){return{name:this._name,description:this._description,columnType:this._columnType,index:this._index,unit:this._unit,details:Object.fromEntries(this._details)}}}},5403(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataManager=void 0;const r=i(1072);t.MetadataManager=class{static STANDARD_SIZE="STANDARD_SIZE";static STANDARD_HUE="STANDARD_HUE";_outlineColumnList=[];_raColumnList=[];_decColumnList=[];_shapeColumnList=[];_hueColumnList=[];_selectedOutlineColumn;_selectedRaColumn;_selectedDecColumn;_selectedShapeColumn;_selectedHueColumn;_selectedNameColumn;_columns=[];constructor(e){e.forEach(e=>{e.columnType==r.ColumnType.NUMBER&&(this.addHueColumn(e),this.addShapeColumn(e)),e.columnType==r.ColumnType.GEOM_RA&&this.addRaColumn(e),e.columnType==r.ColumnType.GEOM_DEC&&this.addDecColumn(e),e.columnType==r.ColumnType.GEOM_FOOTPRINT&&this.addOutlineColumn(e),e.columnType==r.ColumnType.MAIN_NAME&&(this._selectedNameColumn=e),this._columns.push(e)})}addOutlineColumn(e){this._outlineColumnList.push(e),this._selectedOutlineColumn=e}addRaColumn(e){this._selectedRaColumn=this._selectedRaColumn||e,this._raColumnList.push(e)}addDecColumn(e){this._selectedDecColumn=this._selectedDecColumn||e,this._decColumnList.push(e)}addHueColumn(e){this._hueColumnList.push(e)}addShapeColumn(e){this._shapeColumnList.push(e)}get selectedRaColumn(){return this._selectedRaColumn}get selectedDecColumn(){return this._selectedDecColumn}get selectedHueColumn(){return this._selectedHueColumn}get selectedShapeColumn(){return this._selectedShapeColumn}get selectedOutlineColumn(){return this._selectedOutlineColumn}get selectedNameColumn(){return this._selectedNameColumn}get columns(){return this._columns}get raColumnList(){return this._raColumnList}get decColumnList(){return this._decColumnList}get outlineColumnList(){return this._outlineColumnList}get hueColumnList(){return this._hueColumnList}get shapeColumnList(){return this._shapeColumnList}set selectedRaColumn(e){this._selectedRaColumn=this._raColumnList.find(t=>t.name===e)||this._selectedRaColumn}set selectedDecColumn(e){this._selectedDecColumn=this._decColumnList.find(t=>t.name===e)||this._selectedDecColumn}set selectedOutlineColumn(e){this._selectedOutlineColumn=this._outlineColumnList.find(t=>t.name===e)||this._selectedOutlineColumn}set selectedHueColumn(e){this._selectedHueColumn=this._hueColumnList.find(t=>t.name===e)}set selectedShapeColumn(e){this._selectedShapeColumn=this._shapeColumnList.find(t=>t.name===e)}set selectedNameColumn(e){this._selectedNameColumn=this._columns.find(t=>t.name===e)}resetShapeColumn(){this._selectedShapeColumn=void 0}resetHueColumn(){this._selectedHueColumn=void 0}}},6553(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=i(3890),o=i(7930),a=i(8145),n=r(i(4382));class l{_x;_y;_z;_xyz;_raDeg;_decDeg;_raRad;_decRad;_raDecDeg;_lonLatDeg;constructor(e,t){this._xyz=[0,0,0],this._raDecDeg=[0,0];const i=n.default.MAX_DECIMALS??12;if(t===a.CoordsType.CARTESIAN){const{x:t,y:r,z:s}=e;this._x=Number(t.toFixed(i)),this._y=Number(r.toFixed(i)),this._z=Number(s.toFixed(i)),this._xyz=[this._x,this._y,this._z];const[o,a]=this.computeAstroCoords();this._raDeg=Number(o),this._decDeg=Number(a),this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180,this._raDecDeg=[this._raDeg,this._decDeg]}else if(t===a.CoordsType.ASTRO){const{raDeg:t,decDeg:r}=e;this._raDeg=Number(t),this._decDeg=Number(r),this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,o,a]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(o.toFixed(i)),this._z=Number(a.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else if(t===a.CoordsType.GEOGRAPHIC){const{lonDeg:t,latDeg:r}=e;this._lonLatDeg=[Number(t),Number(r)],this._raDeg=this._lonLatDeg[0],this._decDeg=this._lonLatDeg[1],this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,o,a]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(o.toFixed(i)),this._z=Number(a.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else t===a.CoordsType.SPHERICAL?(console.log(`${a.CoordsType.SPHERICAL} not implemented yet`),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0):(console.error("CoordsType "+String(t)+" not recognised."),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0)}computeAstroCoords(){const e=(0,o.cartesianToSpherical)(s.vec3.fromValues(this._xyz[0],this._xyz[1],this._xyz[2])),t=(0,o.sphericalToAstroDeg)(e.phi,e.theta);return[t.ra,t.dec]}computeCartesianCoords(){const e=(0,o.astroDegToSpherical)(this._raDeg,this._decDeg),[t,i,r]=(0,o.sphericalToCartesian)(e.phi,e.theta,1);return[t,i,r]}computeHealpixPhiTheta(){return(0,o.astroDegToSpherical)(this._raDeg,this._decDeg)}scale(e){return new l({x:this.x*e,y:this.y*e,z:this.z*e},a.CoordsType.CARTESIAN)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){return new l({x:this.y*e.z-e.y*this.z,y:this.z*e.x-e.z*this.x,z:this.x*e.y-e.x*this.y},a.CoordsType.CARTESIAN)}norm(){const e=1/this.length();return new l({x:this.x*e,y:this.y*e,z:this.z*e},a.CoordsType.CARTESIAN)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}subtract(e){return new l({x:this.x-e.x,y:this.y-e.y,z:this.z-e.z},a.CoordsType.CARTESIAN)}add(e){return new l({x:this.x+e.x,y:this.y+e.y,z:this.z+e.z},a.CoordsType.CARTESIAN)}get x(){return this._x}get y(){return this._y}get z(){return this._z}get xyz(){return this._xyz}get raDeg(){return this._raDeg}get decDeg(){return this._decDeg}get raDecDeg(){return this._raDecDeg}get lonDeg(){return this._lonLatDeg?.[0]??this._raDeg}get latDeg(){return this._lonLatDeg?.[1]??this._decDeg}get lonLatDeg(){return this._lonLatDeg??[this._raDeg,this._decDeg]}toADQL(){return`${this._raDecDeg[0]},${this._raDecDeg[1]}`}toString(){return`(raDeg, decDeg) => (${this._raDecDeg[0]},${this._raDecDeg[1]}) (x, y,z) => (${this._xyz[0]},${this._xyz[1]},${this._xyz[2]})`}}t.Point=l},7559(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}}},146(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Source=void 0;const s=i(4851),o=r(i(4382));t.Source=class{_point;_name;_details;_h_pix;_shapesize;_brightnessFactor;constructor(e,t=[]){this._point=e,this._details=t,this._shapesize=16,this._brightnessFactor=-99,this.computeHealpixPixel()}getDetailByindex(e){if(!(e<0||e>=this._details.length))return this._details[e]}get details(){return this._details}computeHealpixPixel(){const e=o.default.getHealpix(o.default.nsideForSelection),t=new s.Vec3(this._point.x,this._point.y,this._point.z),i=new s.Pointing(t,!1);this._h_pix=e.ang2pix(i,!1)}get point(){return this._point}get name(){return this._name}get healpixPixel(){return this._h_pix}get shapeSize(){return this._shapesize}set shapeSize(e){this._shapesize=e}get brightnessFactor(){return this._brightnessFactor}set brightnessFactor(e){this._brightnessFactor=e}}},5803(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SphereFoV=void 0;const r=i(3890),s=i(7930);class o{static MIN_FOV_DEG=1e-6;fovXDeg=180;fovYDeg=180;ratio=0;_minFoV=180;_webgl;_lastModel=null;_lastCamera=null;constructor(e){this._webgl=e}getFoV(e,t,i,r){this._lastModel=t,this._lastCamera=i;const s=this._webgl.canvas;if(!s)return this.fovXDeg=180,this.fovYDeg=180,this._minFoV=this.minFoV,this;const o=s.getBoundingClientRect(),a=o.width,n=o.height;return this.fovXDeg=this.computeAngle(0,n/2,e,t,i,r).angleDeg,this.fovYDeg=this.computeAngle(a/2,0,e,t,i,r).angleDeg,this._minFoV=this.minFoV,this.ratio=this.computeRatio(i),this}computeRatio(e){const t=e.getCameraPosition();return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])/this.fovYDeg}get minFoV(){const e=this.fovYDeg<=this.fovXDeg?this.fovYDeg:this.fovXDeg;return this._minFoV=Math.max(e,o.MIN_FOV_DEG),this._minFoV}get xFoV(){return this.fovXDeg}get yFoV(){return this.fovYDeg}computeDistanceFromAngle(e){return e*this.ratio}changeMinFov(e){this.fovYDeg<=this.fovXDeg?this.fovYDeg=e:this.fovXDeg=e,this.minFoV}computeCameraPositionForMinFoV(e){return this.computeCameraPositionForFoV(e)}computeCameraPositionForFoV(e){return this.computeCameraPositionForAngularDiameter(e)}computeCameraPositionForAngularDiameter(e){if(!this._lastModel||!this._lastCamera)return[0,0,0];const t=1e-6,i=Math.max(t,Math.min(180-t,e))*Math.PI/360,s=Math.sin(i);if(s<=0)return[0,0,0];const o=this._lastModel,a=this._lastCamera,n=Math.max(o.radius/s,o.radius+1e-4),l=a.getCameraPosition(),h=r.vec3.fromValues(l[0]-o.center[0],l[1]-o.center[1],l[2]-o.center[2]);return r.vec3.length(h)<t?r.vec3.set(h,0,0,1):r.vec3.normalize(h,h),[o.center[0]+h[0]*n,o.center[1]+h[1]*n,o.center[2]+h[2]*n]}computeAngle(e,t,i,r,s,o){const a=this._webgl.canvas.getBoundingClientRect(),n=this.getIntersectionPointWithModel(a.width/2,a.height/2,r,s,o),l=this.getIntersectionPointWithModel(e,t,r,s,o);if(!n||!l)return{angleDeg:180,distance:-1};return{angleDeg:2*this.computeAngularDistanceDeg(n.point,l.point),distance:l.distance}}computeAngularDistanceDeg(e,t){const i=r.vec3.normalize(r.vec3.create(),e),o=r.vec3.normalize(r.vec3.create(),t),a=r.vec3.dot(i,o),n=r.vec3.cross(r.vec3.create(),i,o),l=Math.atan2(r.vec3.length(n),Math.min(1,Math.max(-1,a)));return(0,s.radToDeg)(l)}getIntersectionPointWithModel(e,t,i,s,o){const a=this.getRayFromMouse(e,t,o,s.getCameraMatrix()),n=this.raySphere(s.getCameraPosition(),a,i);if(n<0)return null;const l=r.vec3.create();r.vec3.scale(l,a,n),r.vec3.add(l,s.getCameraPosition(),l);const h=[l[0],l[1],l[2],1],c=[0,0,0,0];return this.mat4MultiplyVec4(i.getModelMatrixInverse(),h,c),{point:r.vec3.fromValues(c[0],c[1],c[2]),distance:n}}getRayFromMouse(e,t,i,s){const o=this._webgl.canvas.getBoundingClientRect(),a=[2*e/o.width-1,1-2*t/o.height,-1,1],n=r.mat4.create();r.mat4.invert(n,i);const l=[0,0,0,0];this.mat4MultiplyVec4(n,a,l);const h=[l[0],l[1],-1,0],c=r.mat4.create();r.mat4.invert(c,s);const u=[0,0,0,0];this.mat4MultiplyVec4(c,h,u);const d=r.vec3.fromValues(u[0],u[1],u[2]);return r.vec3.normalize(d,d),d}raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}mat4MultiplyVec4(e,t,i){i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3]}}t.SphereFoV=o},1232(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueGL=void 0;const r=i(146),s=i(6553),o=i(8145),a=i(7930),n=i(3559),l=i(5403);class h{_kind="CatalogueGL";static ELEM_SIZE=6;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static STANDARD_SHAPE_SIZE=10;static STANDARD_SHAPE_HUE=3;_ready;_name;_description;_sources;vertexCataloguePositionBuffer=null;vertexhoveredCataloguePositionBuffer=null;vertexCataloguePosition;_bufferInitialised=!1;_webgl;hoveredIndexes;selectedIndexes;extHoveredIndexes;_oldMouseCoords;_metadataManager;_isVisible=!0;_shapeColor="#8F00FF";_healpixDensityMap;_providerUrl;_catalogueShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,o){this._webgl=s,this._ready=!1,this._visibleTilesManager=o,this.TYPE="SOURCE_CATALOGUE",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this._sources=[],this.vertexCataloguePosition=new Float32Array(0),this.hoveredIndexes=[],this.selectedIndexes=[],this.extHoveredIndexes=[],this._oldMouseCoords=null,this._healpixDensityMap=new Map,this._catalogueShaderProgram=new n.CatalogueShaderProgram(this._webgl),this._catalogueShaderProgram.shaderProgram,this._isVisible=!0}setIsVisible(e){this._isVisible=e}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get isVisible(){return this._isVisible}minMax(e){if(!this._sources.length)return{min:0,max:0};let t=this._sources[0].details[e];if(isNaN(Number(t)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain only number values`),{min:0,max:0};let i=t;for(const r of this._sources){const s=r.details[e];if(isNaN(Number(s)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain number only values`),{min:0,max:0};s<t&&(t=s),s>i&&(i=s)}return{min:Number(t),max:Number(i)}}get metadataManager(){return this._metadataManager}changeMetaRA(e){this._metadataManager.selectedRaColumn=e}changeMetaDec(e){this._metadataManager.selectedDecColumn=e}changeColor(e){this._shapeColor=e}changeMetaShapeSize(e){if(!this._webgl)return;if(e==l.MetadataManager.STANDARD_SIZE){this._metadataManager.resetShapeColumn();for(const e of this._sources){const t=h.STANDARD_SHAPE_SIZE;e.shapeSize=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedShapeColumn=e;const i=this._metadataManager.selectedShapeColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedShapeColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),o=Number(r.max),a=12*((t-s)/Math.max(1e-12,o-s))+8;e.shapeSize=a}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}changeMetaShapeHue(e){if(!this._webgl)return;if(e==l.MetadataManager.STANDARD_HUE){this._metadataManager.resetHueColumn();for(const e of this._sources){const t=h.STANDARD_SHAPE_HUE;e.brightnessFactor=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedHueColumn=e;const i=this._metadataManager.selectedHueColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedHueColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),o=Number(r.max),a=(t-s)/Math.max(1e-12,o-s);e.brightnessFactor=-(2*a-1)}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}get sources(){return this._sources}addSource(e){this._sources.push(e)}addSources(e,t){this._ready=!1,this._sources=[],this._metadataManager=new l.MetadataManager(t);const i=this._metadataManager.selectedRaColumn?.index??-1,a=this._metadataManager.selectedDecColumn?.index??-1;if(i<0||a<0)throw new Error(`(ra, dec) idx not defined (${i}, ${a}) `);for(let t=0;t<e.length;t++){const n=new s.Point({raDeg:e[t][i],decDeg:e[t][a]},o.CoordsType.ASTRO),l=new r.Source(n,e[t]);l.shapeSize=l.shapeSize??h.STANDARD_SHAPE_SIZE,l.brightnessFactor=3,this.addSource(l),this._metadataManager.selectedHueColumn?.name&&this.changeMetaShapeHue(this._metadataManager.selectedHueColumn.name),this._metadataManager.selectedShapeColumn?.name&&this.changeMetaShapeSize(this._metadataManager.selectedShapeColumn.name)}this._ready=!0,this._bufferInitialised=!1}clearSources(){this._sources=[],this.hoveredIndexes=[],this._healpixDensityMap.clear(),this.vertexCataloguePosition=new Float32Array(0)}sourceMatches(e,t){if(e===t)return!0;const i=e.point,r=t.point;if(i.raDeg!==r.raDeg||i.decDeg!==r.decDeg)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findSourceIndex(e){const t=this._sources.indexOf(e);return t>=0?t:this._sources.findIndex(t=>this.sourceMatches(t,e))}extHighlightSource(e,t){const i=this.findSourceIndex(e);if(i<0)return;const r=i*h.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&(this.hoveredIndexes.splice(e,1),this.vertexCataloguePosition[r+3]=0,this.vertexCataloguePosition[r+4]=this._sources[i]?.shapeSize??h.STANDARD_SHAPE_SIZE)}}extAddSources2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findSourceIndex(e);if(t<0)return;const i=t*h.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&(this.selectedIndexes.splice(e,1),this.vertexCataloguePosition[i+3]=0,this.vertexCataloguePosition[i+4]=this._sources[t]?.shapeSize??h.STANDARD_SHAPE_SIZE)}else this.selectedIndexes.push(t)}initBuffer(){this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.vertexhoveredCataloguePositionBuffer=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer);const e=this._sources.length;this.vertexCataloguePosition=new Float32Array(e*h.ELEM_SIZE);let t=0;for(let i=0;i<e;i++){const e=this._sources[i],r=e.healpixPixel,s=this._healpixDensityMap.get(r);s?s.includes(i)||s.push(i):this._healpixDensityMap.set(r,[i]),this.vertexCataloguePosition[t+0]=e.point.x,this.vertexCataloguePosition[t+1]=e.point.y,this.vertexCataloguePosition[t+2]=e.point.z,this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=e.shapeSize??h.STANDARD_SHAPE_SIZE,this.vertexCataloguePosition[t+5]=e.brightnessFactor??0,t+=h.ELEM_SIZE}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._bufferInitialised=!0}getSelectionRadius(){switch(this._visibleTilesManager.getVisibleOrder()){case 0:case 1:case 2:return.01;case 3:case 4:case 5:return.005;case 6:case 7:case 8:return.001;case 9:return 5e-4;default:return 1e-4}}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkClicking: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const o=r[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,l=a.point.y-e.y,h=a.point.z-e.z;Math.sqrt(n*n+l*l+h*h)<=s&&t.push(o)}}return t}setSelectedIndexes(e){e.forEach(e=>{if(e<0||e>=this._sources.length)return;const t=e*h.ELEM_SIZE;t+4>=this.vertexCataloguePosition.length||(this.selectedIndexes.includes(e)?(this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1),this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??h.STANDARD_SHAPE_SIZE):(this.selectedIndexes.push(e),this.vertexCataloguePosition[t+3]=2,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??h.STANDARD_SHAPE_SIZE))})}getSourcesFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{sources:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this._sources[e];t&&i.push(t)}),i.length?{sources:i,pickedIndexes:t}:null}selectPrimarySourceFromClick(e){const t=this.getSourcesFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{sources:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this._sources[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({source:t,selected:i}),s.push(t)}),s.length?{sources:s,selectionState:r}:null}getPrimaryHoveredSource(){if(!this.hoveredIndexes.length)return null;const e=this.hoveredIndexes[0];return this._sources[e]??null}checkHovering(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkHovering: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const o=r[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,l=a.point.y-e.y,h=a.point.z-e.z;Math.sqrt(n*n+l*l+h*h)<=s&&t.push(o)}}return t}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;this._catalogueShaderProgram.enableShaders(r,e,i),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.position,3,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.position),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.hovered,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,3*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.hovered),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.pointSize,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,4*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.pointSize),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.brightness,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,5*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.brightness);const s=(0,a.colorHex2RGB)(this._shapeColor);this._catalogueShaderProgram.locations.color&&this._webgl.uniform4f(this._catalogueShaderProgram.locations.color,s[0],s[1],s[2],1);for(let e=0;e<this.selectedIndexes.length;e++){const t=this.selectedIndexes[e],i=t*h.ELEM_SIZE;this.vertexCataloguePosition[i+3]=2,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e]*h.ELEM_SIZE;this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[this.hoveredIndexes[e]].shapeSize}null!=t&&t.xyz!==this._oldMouseCoords&&(this.hoveredIndexes=this.checkHovering(t));for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e],i=t*h.ELEM_SIZE;this.vertexCataloguePosition[i+3]=1,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW);const o=this.vertexCataloguePosition.length/h.ELEM_SIZE;this._webgl.drawArrays(this._webgl.POINTS,0,o),this._oldMouseCoords=t.xyz}}t.CatalogueGL=h},3956(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WMTSAdapter=void 0;t.WMTSAdapter=class{_config;constructor(e){this._config=e}toXYZLayerConfig(){const e=this.getInferredMaxZoom();return{urlTemplate:this._config.urlTemplate??this._config.baseUrl,minZoom:this._config.minZoom,maxZoom:e,segmentsPerSide:this._config.segmentsPerSide,tileSize:this._config.tileSize,maxCachedTiles:this._config.maxCachedTiles,subdomains:this._config.subdomains,attribution:this._config.attribution,flipY:this._config.flipY,urlResolver:e=>this.getTileUrl(e)}}getInferredMaxZoom(){const e=this._config.matrixLabels?.length??0,t=e>0?e-1:void 0;return null==t?this._config.maxZoom:null==this._config.maxZoom?t:Math.min(this._config.maxZoom,t)}getTileUrl(e){return"rest"===this._config.requestEncoding?this.buildRestUrl(e):this.buildKvpUrl(e)}buildRestUrl(e){const t=function(e,t){return Object.entries(t).reduce((e,[t,i])=>e.replace(new RegExp(`\\{${t}\\}`,"g"),i),e)}(this._config.urlTemplate??this._config.baseUrl,this.getCommonTokenValues(e));return t.replace(/(?<!:)\/{2,}/g,"/")}buildKvpUrl(e){const t=new URL(this._config.baseUrl),i=this.getCommonTokenValues(e),r=t.searchParams;r.set("SERVICE","WMTS"),r.set("REQUEST","GetTile"),r.set("VERSION",this._config.version??"1.0.0"),r.set("LAYER",this._config.layer),r.set("STYLE",this._config.style??"default"),r.set("FORMAT",this._config.format??"image/png"),r.set("TILEMATRIXSET",this._config.tileMatrixSet),r.set("TILEMATRIX",i.TileMatrix),r.set("TILEROW",i.TileRow),r.set("TILECOL",i.TileCol);for(const[e,t]of Object.entries(this._config.dimensions??{}))r.set(e,t);return t.toString()}getCommonTokenValues(e){const t=2**e.z,i=this._config.flipY?t-1-e.y:e.y,r=this._config.matrixLabels?.[e.z]??String(e.z),s=this._config.format??"image/png",o=s.replace(/^image\//,"");return{Layer:this._config.layer,Style:this._config.style??"default",Time:this._config.time??"",TileMatrixSet:this._config.tileMatrixSet,TileMatrix:r,TileRow:String(i),TileCol:String(e.x),Format:o,TileFormat:s,TileFormatExtension:o,...Object.fromEntries(Object.entries(this._config.dimensions??{}).map(([e,t])=>[e,t]))}}}},3174(e,t,i){"use strict";t.XYZAnchestorTile=void 0;const r=i(8819),s=i(1375);class o extends s.XYZTile{_ancestorMeshBuilder;_ancestorWebgl;_segmentsPerSide;_meshCache=new Map;constructor(e,t,i,s,o=new r.XYZMeshBuilder,a=16){super(e,t,i,s,o,a),this._ancestorMeshBuilder=o,this._ancestorWebgl=i,this._segmentsPerSide=a}draw(e,t,i,r,s,o,a){if("number"!=typeof e)return super.draw(e,t,i,r);if(!s||!o||void 0===a)return!1;const n=t,l=i,h=r;let c=!1;if(e<=this.coord.z)return super.draw(h,s,o,a);for(const e of n){if(!this.isAncestorOf(e))continue;const t=`${this.coord.z}/${this.coord.x}/${this.coord.y}`;if(!l.has(t))continue;const i=this.getRemappedMesh(e);c=super.drawRemapped(i,h,s,o,a)||c}return c}dispose(){for(const e of this._meshCache.values())e.positionBuffer&&this._ancestorWebgl.deleteBuffer(e.positionBuffer),e.uvBuffer&&this._ancestorWebgl.deleteBuffer(e.uvBuffer),e.indexBuffer&&this._ancestorWebgl.deleteBuffer(e.indexBuffer);this._meshCache.clear(),super.dispose()}getRemappedMesh(e){const t=`${e.z}/${e.x}/${e.y}->${this.coord.z}/${this.coord.x}/${this.coord.y}`,i=this._meshCache.get(t);if(i)return i;const r=this._ancestorMeshBuilder.buildAncestorMesh(e,this.coord,this._segmentsPerSide),s=this._ancestorMeshBuilder.uploadMesh(r,this._ancestorWebgl);return this._meshCache.set(t,s),s}isAncestorOf(e){if(e.z<=this.coord.z)return e.z===this.coord.z&&e.x===this.coord.x&&e.y===this.coord.y;const t=e.z-this.coord.z;return e.x>>t===this.coord.x&&e.y>>t===this.coord.y}}t.XYZAnchestorTile=o},8284(e,t){"use strict";t.xyzFovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static ZOOM_MIN_FOV={2:179,3:90,4:30,5:20,6:6,7:3.2,8:1.6,9:.85,10:.42,11:.21,12:.12,13:.06,14:.015,15:0};getZoom(e,t){const r=this.getRawZoom(e);if(void 0===t||t===r)return r;if(r>t){const r=i.ZOOM_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.ZOOM_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawZoom(e){return e>=179?2:e>=90?3:e>=30?4:e>=20?5:e>=6?6:e>=3.2?7:e>=1.6?8:e>=.85?9:e>=.42?10:e>=.21?11:e>=.12?12:e>=.06?13:e>=.015?14:15}getLonLatSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{lonStep:i,latStep:r}}}t.xyzFovHelper=new i},1741(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMap=void 0;const r=i(4735),s=i(6937),o=i(8284),a=i(619),n=i(8124),l=i(149),h=i(2737),c=i(3174),u=i(8819);class d extends r.AbstractSkyEntity{_xyzShaderProgram;_descriptor;_visibleTilesManager;_tileBuffer;_meshBuilder;_baseurl;_zoom;_latLonGrid;_colorMapIdx=0;_colorMap=a.ColorMaps.native;constructor(e,t,i,r,a,c,d){super(e,t,i,r,a.name,c,!1),this._descriptor=a,this._xyzShaderProgram=new l.XYZShaderProgram(c),this._meshBuilder=new u.XYZMeshBuilder,this._tileBuffer=new h.XYZTileBuffer(1),this.initGL(c),this._latLonGrid=new n.LatLonGrid(e,t,i,r,"LatLonGrid",this._webgl,d),this._visibleTilesManager=new s.XYZVisibleTilesManager,this._baseurl=a.url,this.initShaders();this._zoom=o.xyzFovHelper.getZoom(180)}changeColorMap(e){switch(this._colorMap=e,e.name){case"grayscale":this._colorMapIdx=1,this._colorMap=a.ColorMaps.grayscale;break;case"planck":this._colorMapIdx=2,this._colorMap=a.ColorMaps.planck;break;case"cmb":this._colorMapIdx=3,this._colorMap=a.ColorMaps.cmb;break;case"rainbow":this._colorMapIdx=4,this._colorMap=a.ColorMaps.rainbow;break;case"eosb":this._colorMapIdx=5,this._colorMap=a.ColorMaps.eosb;break;case"cubehelix":this._colorMapIdx=6,this._colorMap=a.ColorMaps.cubehelix;break;case"hot":this._colorMapIdx=7,this._colorMap=a.ColorMaps.hot;break;case"gray":this._colorMapIdx=8,this._colorMap=a.ColorMaps.gray;break;case"native":this._colorMapIdx=0,this._colorMap=a.ColorMaps.native;break;default:this._colorMapIdx=9,this._colorMap=e}}initShaders(){this._xyzShaderProgram.enableProgram()}isLonLatGridVisible(){return this._latLonGrid.isVisible()}toggleLonLatGrid(){return this._latLonGrid.toggleShowGrid()}getFoV(){return this._latLonGrid.getFoV()}refresh(e){const t=this._latLonGrid.refreshFoV(e);this._zoom=o.xyzFovHelper.getZoom(t)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();this._xyzShaderProgram.setRuntimeColorMap(this._colorMap);const s=this._visibleTilesManager.computeVisibleTiles(this._zoom,this,this._webgl,e.camera,e.pMatrix),o=s.visibleTiles,a=s.ancestorsMap,n=this._tileBuffer.ensureTiles(this.getTilesToEnsure(o,a),e=>this.createTile(e));this._tileBuffer.evictCached(this._descriptor.maxCachedTiles);for(const e of n){const o=this._tileBuffer.getActiveTile(e);if(!o||o.coord.z!==s.currentZoom)continue;if(o.draw(i,t,r,this._colorMapIdx))continue;const n=this.findBestAvailableAncestor(o.coord);n?.draw(s.currentZoom,[o.coord],a,i,t,r,this._colorMapIdx)}this._latLonGrid.draw(e)}createTile(e){return new c.XYZAnchestorTile(e,this.resolveTileUrl(e),this._webgl,this._xyzShaderProgram,this._meshBuilder,this._descriptor.segmentsPerSide)}getTilesToEnsure(e,t){const i=new Map;for(const t of e)i.set(this.tileKey(t),t);for(const e of t.values())i.set(this.tileKey(e),e);return Array.from(i.values())}findBestAvailableAncestor(e){for(let t=e.z-1;t>=0;t--){const i=e.z-t,r={z:t,x:e.x>>i,y:e.y>>i},s=this._tileBuffer.getAnyTile(this.tileKey(r));if(s?.ready)return s}return null}resolveTileUrl(e){const t=this._descriptor.urlResolver;if(t)return t(e);const i=2**e.z,r=this._descriptor.flipY?i-1-e.y:e.y,s=this._descriptor.subdomains,o=s.length>0?s[Math.abs(e.x+e.y+e.z)%s.length]:"";return this._baseurl.replace(/\{z\}/g,String(e.z)).replace(/\{x\}/g,String(e.x)).replace(/\{y\}/g,String(r)).replace(/\{s\}/g,o??"")}getDebugStats(){const e=Array.from(this._tileBuffer.activeTiles.values(),e=>e.tile),t=Array.from(this._tileBuffer.cachedTiles.values(),e=>e.tile),i=[...e,...t],r=this._visibleTilesManager.selection;return{cacheSize:this._tileBuffer.size,visibleTileCount:r.visibleTiles.length,currentTileCount:e.filter(e=>e.coord.z===r.currentZoom).length,fallbackTileCount:r.ancestorsMap.size,coreTileCount:r.visibleTiles.length,coverageTileCount:r.visibleTiles.length,readyTileCount:i.filter(e=>e.ready).length,loadingTileCount:i.filter(e=>e.loading).length,coolingDownTileCount:0,currentZoom:r.currentZoom,tileSelectionKey:r.key,isSettling:!1,coarseTileCount:r.ancestorsMap.size,hasPendingSelection:!1,pendingSelectionKey:null}}tileKey(e){return`${e.z}/${e.x}/${e.y}`}}t.XYZMap=d},8868(e,t){"use strict";t.XYZMapDescriptor=void 0;t.XYZMapDescriptor=class{_name;_url;_urlResolver;_minZoom;_maxZoom;_segmentsPerSide;_tileSize;_maxCachedTiles;_interactionDebounceMs;_subdomains;_attribution;_flipY;_maxConcurrentLoads;constructor(e,t,i=0,r=8,s=16,o=384,a=8,n){this._name=e,this._url=t,this._urlResolver=n,this._minZoom=i,this._maxZoom=r,this._segmentsPerSide=s,this._maxCachedTiles=o,this._interactionDebounceMs=100,this._subdomains=["a","b","c"],this._attribution="",this._flipY=!1,this._maxConcurrentLoads=a}get url(){return this._url}get urlResolver(){return this._urlResolver}get name(){return this._name}get minZoom(){return this._minZoom}get maxZoom(){return this._maxZoom}get segmentsPerSide(){return this._segmentsPerSide}get maxCachedTiles(){return this._maxCachedTiles}get interactionDebounceMs(){return this._interactionDebounceMs}get subdomains(){return this._subdomains}get attribution(){return this._attribution}get flipY(){return this._flipY}get maxConcurrentLoads(){return this._maxConcurrentLoads}}},8819(e,t,i){"use strict";t.XYZMeshBuilder=void 0;const r=i(7930),s=85.0511287798066;function o(e){const t=Math.PI*(1-2*e);return 180*Math.atan(Math.sinh(t))/Math.PI}function a(e){return e<0?e+360:e}t.XYZMeshBuilder=class{buildTileMesh(e,t=16){const i=Math.max(1,Math.floor(t)),n=i+1,l=n*n,h=new Float32Array(3*l),c=new Float32Array(2*l),u=2**e.z;let d=0,g=0;for(let t=0;t<=i;t++){const n=t/i,l=(e.y+n)/u,_=90-Math.max(-85.0511287798066,Math.min(s,o(l)));for(let t=0;t<=i;t++){const s=t/i,o=a(360*((e.x+s)/u)-180),[l,p,f]=(0,r.sphericalToCartesian)(o,_,1);h[d++]=l,h[d++]=p,h[d++]=f,c[g++]=s,c[g++]=1-n}}const _=new Uint32Array(i*i*2*3);let p=0;for(let e=0;e<i;e++)for(let t=0;t<i;t++){const i=e*n+t,r=i+1,s=i+n,o=s+1;_[p++]=i,_[p++]=s,_[p++]=r,_[p++]=r,_[p++]=s,_[p++]=o}return{positions:h,uvs:c,indices:_.length>65535?_:new Uint16Array(_)}}buildAncestorMesh(e,t,i=16){const r=this.buildTileMesh(e,i),s=e.z-t.z,o=2**s,a=e.x-(t.x<<s),n=e.y-(t.y<<s),l=new Float32Array(r.uvs.length);for(let e=0;e<r.uvs.length;e+=2){const t=r.uvs[e]??0,i=1-(r.uvs[e+1]??0);l[e]=(a+t)/o,l[e+1]=1-(n+i)/o}return{positions:r.positions,uvs:l,indices:r.indices}}uploadMesh(e,t){const i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer(),o=e.indices instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT;return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.uvs,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:i,uvBuffer:r,indexBuffer:s,indexCount:e.indices.length,indexType:o}}}},1375(e,t,i){"use strict";t.XYZTile=void 0;const r=i(8819);t.XYZTile=class{_coord;_url;_webgl;_shaderProgram;_meshBuilder;_gpuMesh;_texture=null;_image;_ready=!1;_loading=!1;_aborted=!1;_failedUntil=0;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,i,s,o=new r.XYZMeshBuilder,a=16){this._coord=e,this._url=t,this._webgl=i,this._shaderProgram=s,this._meshBuilder=o;const n=this._meshBuilder.buildTileMesh(e,a);this._gpuMesh=this._meshBuilder.uploadMesh(n,this._webgl),this.initImage()}get coord(){return this._coord}get ready(){return this._ready}get loading(){return this._loading}get failedUntil(){return this._failedUntil}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}initImage(){if(this._loading||this._ready||this._aborted)return;const e=Date.now();if(this._failedUntil>e)return;this._loading=!0;const t=new Image;this._image=t,t.crossOrigin="anonymous",t.onload=()=>this.imageLoaded(),t.onerror=()=>{this._ready=!1,this._loading=!1,this._failedUntil=Date.now()+3e4},t.src=this._url}imageLoaded(){this._image&&!this._aborted&&(this.textureLoaded(this._image),this._loading=!1,this._failedUntil=0,this._ready=!0)}textureLoaded(e){const t=this._webgl;this._shaderProgram.enableProgram();const i=t.createTexture();if(!i)throw new Error(`Could not create XYZ texture for ${this.key}`);this._texture=i,t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}draw(e,t,i,r){return this.touch(),!(!this._ready||!this._texture||this._aborted)&&(this.drawWithGpuMesh(this._gpuMesh,e,t,i,r),!0)}drawRemapped(e,t,i,r,s){return this.touch(),!(!this._ready||!this._texture||this._aborted)&&(this.drawWithGpuMesh(e,t,i,r,s),!0)}dispose(){const e=this._webgl;this._texture&&(e.deleteTexture(this._texture),this._texture=null),this._gpuMesh.positionBuffer&&(e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh.positionBuffer=null),this._gpuMesh.uvBuffer&&(e.deleteBuffer(this._gpuMesh.uvBuffer),this._gpuMesh.uvBuffer=null),this._gpuMesh.indexBuffer&&(e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh.indexBuffer=null),this._image=void 0,this._ready=!1,this._loading=!1,this._aborted=!0}drawWithGpuMesh(e,t,i,r,s){if(!this._texture)return;const o=this._webgl;this._shaderProgram.enableShaders(t,i,r,s),o.bindBuffer(o.ARRAY_BUFFER,e.positionBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),o.bindBuffer(o.ARRAY_BUFFER,e.uvBuffer),o.vertexAttribPointer(this._shaderProgram.locations.textureCoordAttribute,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._texture),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,e.indexBuffer),o.drawElements(o.TRIANGLES,e.indexCount,e.indexType,0),o.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),o.disableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute)}get key(){return`${this._coord.z}/${this._coord.x}/${this._coord.y}`}}},2737(e,t){"use strict";t.XYZTileBuffer=void 0;class i{_tiles=new Map;_cachedTiles=new Map;_cacheAliveMilliSeconds;_cleanerId;constructor(e=1){this._cacheAliveMilliSeconds=60*e*1e3,"undefined"!=typeof window&&(this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4))}get activeTiles(){return this._tiles}get cachedTiles(){return this._cachedTiles}get size(){return this._tiles.size+this._cachedTiles.size}ensureTiles(e,t){const i=[];for(const r of e){const e=this.getTile(r,t);this.touchTile(e),i.push(this.key(r))}return this.syncVisibleTiles(i),i}getTile(e,t){const i=this.key(e);if(this._tiles.has(i))return this._tiles.get(i).tile;if(this._cachedTiles.has(i)){const e=this._cachedTiles.get(i);return e.cacheTime0=void 0,this._tiles.set(i,e),this._cachedTiles.delete(i),e.tile}const r=t(e);return this._tiles.set(i,{tile:r}),r}getActiveTile(e){return this._tiles.get(e)?.tile??null}getAnyTile(e){return this._tiles.get(e)?.tile??this._cachedTiles.get(e)?.tile??null}getActiveTiles(){return Array.from(this._tiles.values(),e=>e.tile)}syncVisibleTiles(e){const t=new Set(e);for(const[e,i]of this._tiles)t.has(e)?this.touchTile(i.tile):(i.cacheTime0=Date.now(),this._cachedTiles.set(e,i),this._tiles.delete(e))}evictCached(e){if(this.size<=e)return;const t=Array.from(this._cachedTiles.entries()).sort((e,t)=>this.getTileAgeScore(e[1].tile)-this.getTileAgeScore(t[1].tile));for(const[i,r]of t){if(this.size<=e)break;r.tile.loading||(r.tile.dispose?.(),this._cachedTiles.delete(i))}}dispose(){void 0!==this._cleanerId&&"undefined"!=typeof window&&(window.clearInterval(this._cleanerId),this._cleanerId=void 0);for(const e of this._tiles.values())e.tile.dispose?.();for(const e of this._cachedTiles.values())e.tile.dispose?.();this._tiles.clear(),this._cachedTiles.clear()}key(e){return i.key(e)}static key(e){return`${e.z}/${e.x}/${e.y}`}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;void 0===r||e-r<=this._cacheAliveMilliSeconds||i.tile.loading||(i.tile.dispose?.(),this._cachedTiles.delete(t))}}touchTile(e){e.touch?.()}getTileAgeScore(e){const t=e.lastUsedAt??0,i=e.createdAt??t;return Math.min(t||i,i)}}t.XYZTileBuffer=i},5409(e,t){"use strict";t.xyzTileRequestScheduler=void 0;class i extends Error{cooldownMs;retryable;constructor(e,t,i=!0){super(e),this.name="XYZTileRequestError",this.cooldownMs=t,this.retryable=i}}class r{_maxConcurrent;_activeCount=0;_queue=[];_inflight=new Map;_hostBackoff=new Map;_sequence=0;constructor(e=4){this._maxConcurrent=e}setMaxConcurrent(e){this._maxConcurrent=Math.max(1,Math.floor(e)),this.pump()}getMaxConcurrent(){return this._maxConcurrent}getDebugStats(){const e=Date.now(),t=Array.from(this._hostBackoff.entries()).map(([t,i])=>({host:t,cooldownMs:Math.max(0,i.cooldownUntil-e),consecutiveFailures:i.consecutiveFailures})).filter(e=>e.cooldownMs>0||e.consecutiveFailures>0).sort((e,t)=>t.cooldownMs-e.cooldownMs);return{activeRequests:this._activeCount,queuedRequests:this._queue.length,inflightRequests:this._inflight.size,maxConcurrentRequests:this._maxConcurrent,highestQueuedPriority:this._queue[0]?.priority??null,hostsInBackoff:t}}load(e,t=0){const r=this._inflight.get(e);if(r)return r;const s=this.getHostCooldown(e),o=Date.now();if(s>o)return Promise.reject(new i(`Cooldown active for ${new URL(e).host}`,s-o));const a=new Promise((i,r)=>{this._queue.push({url:e,resolve:i,reject:r,priority:t,sequence:this._sequence++}),this._queue.sort((e,t)=>t.priority-e.priority||e.sequence-t.sequence),this.pump()}).finally(()=>{this._inflight.delete(e)});return this._inflight.set(e,a),a}pump(){for(;this._activeCount<this._maxConcurrent&&this._queue.length>0;){const e=this._queue.shift();if(!e)return;const t=this.getHostCooldown(e.url),r=Date.now();t>r?e.reject(new i(`Cooldown active for ${new URL(e.url).host}`,t-r)):(this._activeCount+=1,this.fetchBlob(e).then(e.resolve).catch(e.reject).finally(()=>{this._activeCount-=1,this.pump()}))}}async fetchBlob(e){try{const t=await fetch(e.url,{mode:"cors",cache:"force-cache"});if(!t.ok){const r=429===t.status||t.status>=500,s=this.registerFailure(e.url,r);throw new i(`HTTP ${t.status} loading ${e.url}`,r?s:3e5,r)}return this.registerSuccess(e.url),await t.blob()}catch(t){if(t instanceof i)throw t;const r=this.registerFailure(e.url,!1);throw new i(`Network/CORS failure loading ${e.url}`,r,!0)}}getHostCooldown(e){try{return this._hostBackoff.get(new URL(e).host)?.cooldownUntil??0}catch{return 0}}registerSuccess(e){try{const t=new URL(e).host;this._hostBackoff.set(t,{cooldownUntil:0,consecutiveFailures:0})}catch{}}registerFailure(e,t){if(!t)return 0;try{const t=new URL(e).host,i=(this._hostBackoff.get(t)??{cooldownUntil:0,consecutiveFailures:0}).consecutiveFailures+1,r=4e3,s=Math.min(12e4,r*2**Math.min(i-1,5));return this._hostBackoff.set(t,{cooldownUntil:Date.now()+s,consecutiveFailures:i}),s}catch{return 3e4}}}t.xyzTileRequestScheduler=new r},6937(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XYZVisibleTilesManager=void 0;const s=r(i(2166));t.XYZVisibleTilesManager=class{_ancestorsMap=new Map;_visibleTilesMap=new Map;_visibleTiles=[];_selection={key:"0:",currentZoom:0,visibleTiles:[],visibleTilesMap:new Map,ancestorsMap:new Map};get ancestorsMap(){return this._ancestorsMap}get visibleTiles(){return this._visibleTiles}get visibleTilesMap(){return this._visibleTilesMap}get selection(){return this._selection}computeVisibleTiles(e,t,i,r,o,a=9,n=2){return this._visibleTiles=s.default.getVisibleTilesFromViewport(e,t,i,r,o,a,n),this._visibleTilesMap=this.buildTileMap(this._visibleTiles),this.refreshAncestorsMap(this._visibleTiles),this._selection={key:this.buildSelectionKey(e,this._visibleTiles),currentZoom:e,visibleTiles:this._visibleTiles,visibleTilesMap:this._visibleTilesMap,ancestorsMap:this._ancestorsMap},this._selection}refreshAncestorsMap(e){this._ancestorsMap.clear();for(const t of e)for(let e=t.z-1;e>=0;e--){const i=t.z-e,r={z:e,x:t.x>>i,y:t.y>>i};this._ancestorsMap.set(`${r.z}/${r.x}/${r.y}`,r)}}buildTileMap(e){const t=new Map;for(const i of e)t.set(this.key(i),i);return t}buildSelectionKey(e,t){return`${e}:${t.map(e=>`${e.x}/${e.y}`).join("|")}`}key(e){return`${e.z}/${e.x}/${e.y}`}}},2475(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=void 0;const s=r(i(2930)),o=r(i(9665)),a=i(8145);class n{_polygons=[];_convexPolygons=[];_stcs;_valid=!1;_details;_totPoints=0;_totConvexPoints=0;_npix256;_footprintsPointsOrder;_coordsType;_selectionObj;_identifier;_center;constructor(e,t=[],i,r=a.CoordsType.ASTRO){this._coordsType=r,e?(this._stcs=e.toUpperCase(),this._details=t,this._totPoints=0,this._totConvexPoints=0,this._footprintsPointsOrder=i,this.computePoints(),this._selectionObj=this.computeSelectionObject(),this._valid=!0):this._details=[]}static fromPolygons(e,t=[],i=a.CoordsType.ASTRO){const r=new n(void 0,[],void 0,i);return r._polygons=e,r._details=t,r._totPoints=e.reduce((e,t)=>e+t.length,0),r._totConvexPoints=0,r._coordsType=i,r._selectionObj=r.computeSelectionObject(),r._valid=r._totPoints>0,r}computeSelectionObject(){return s.default.computeSelectionObject(this._polygons)}computePoints(){const e=o.default.parseSTCS(this._stcs,{coordsType:this._coordsType});this._polygons=e.polygons,this._totPoints=e.totpoints}get valid(){return this._valid}get totPoints(){return this._totPoints}get totConvexPoints(){return this._totConvexPoints}get polygons(){return this._polygons}get convexPolygons(){return this._convexPolygons}get identifier(){return this._identifier}get center(){return this._center}get pixels(){return this._npix256}get details(){return this._details}get selectionObj(){return this._selectionObj}}t.Footprint=n},592(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintSetGL=void 0;const s=i(2475),o=i(7930),a=i(8909),n=i(6553),l=r(i(2930)),h=i(8145),c=i(5403);class u{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static CONVEXPOLY_ELEM_SIZE=3;_kind="FootprintSetGL";_ready;_name;_description;extHoveredIndexes;oldMouseCoords;healpixDensityMap;totConvexPoints;vertexCataloguePositionBuffer;indexBuffer;hoveredVertexPositionBuffer;hoveredIndexBuffer;selectedVertexPositionBuffer;selectedIndexBuffer;indexes;footprintPolygons=[];vertexCataloguePosition;totPoints;nPrimitiveFlags=0;hoveredIndexes;hoveredElementIndexes;_hoveredFootprints=[];hoveredVertexPosition;totHoveredPoints;nHoveredPrimitiveFlags=0;selectedIndexes;selectedElementIndexes;_selectedFootprints=[];selectedVertexPosition;totSelectedPoints;nSlectedPrimitiveFlags=0;_shapeColor="#00fff2ff";_coordsType=h.CoordsType.ASTRO;_bufferInitialised=!1;_webgl;_isVisible=!0;_metadataManager;_providerUrl;_footprintShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,o){this._webgl=s,this._ready=!1,this._visibleTilesManager=o,this.TYPE="FOOTPRINT_SET",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this.initFootprintArrays(),this.oldMouseCoords=null,this._footprintShaderProgram=new a.FootprintShaderProgram(this._webgl),this._footprintShaderProgram.shaderProgram}initFootprintArrays(){this.footprintPolygons=[],this.indexes=new Uint32Array,this.vertexCataloguePosition=new Float32Array,this.totPoints=0,this.totConvexPoints=0,this.extHoveredIndexes=new Uint32Array,this._hoveredFootprints=[],this.hoveredVertexPosition=new Float32Array,this.totHoveredPoints=0,this.hoveredIndexes=[],this.hoveredElementIndexes=new Uint32Array,this._selectedFootprints=[],this.selectedVertexPosition=new Float32Array,this.totSelectedPoints=0,this.selectedIndexes=[],this.selectedElementIndexes=new Uint32Array}initGLBuffers(){this._webgl&&(this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.indexBuffer=this._webgl.createBuffer(),this.hoveredVertexPositionBuffer=this._webgl.createBuffer(),this.hoveredIndexBuffer=this._webgl.createBuffer(),this.selectedVertexPositionBuffer=this._webgl.createBuffer(),this.selectedIndexBuffer=this._webgl.createBuffer())}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get metadataManager(){return this._metadataManager}addFootprint(e){this.footprintPolygons.push(e)}addFootprints(e,t){this._ready=!1,this._metadataManager=new c.MetadataManager(t);const i=this._metadataManager.selectedOutlineColumn?.index??-1;if(i<0)throw new Error("geomColumn or its index is undefined in footprintsetProps");for(let t=0;t<e.length;t++)if(null!==e[t][i]){const r=new s.Footprint(e[t][i],e[t],void 0,this._coordsType);r._valid&&(this.addFootprint(r),this.totPoints+=r.totPoints,this.totConvexPoints+=r.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}clearFootprints(){this.initFootprintArrays()}initBuffer(){if(!this._webgl)return;this.initGLBuffers();const e=this.footprintPolygons.length;let t=e-1;for(let i=0;i<e;i++)t+=this.footprintPolygons[i].polygons.length-1;this.indexes=new Uint32Array(this.totPoints+t+1);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this.vertexCataloguePosition=new Float32Array(3*this.totPoints);let r=0,s=0;this.nPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this.footprintPolygons[t].polygons;t>0&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const t of e){t!==e[0]&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const e of t)this.vertexCataloguePosition[r++]=1*e.x,this.vertexCataloguePosition[r++]=1*e.y,this.vertexCataloguePosition[r++]=1*e.z,this.indexes[s++]=Math.floor((r-1)/3)}}this.indexes[this.indexes.length-1]=i,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexes,this._webgl.STATIC_DRAW),this._bufferInitialised=!0,console.log("Buffer initialized")}checkSelection(e){if(!e.x||!e.y||!e.z)return;if(!e.computeNpix())return;this._hoveredFootprints=[],this.totHoveredPoints=0;const t=new n.Point({x:e.x,y:e.y,z:e.z},h.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const i=this.footprintPolygons[e];if(i.selectionObj&&l.default.checkPointInsidePolygon5(i.selectionObj,t)){const e=[...i.details],t=this._metadataManager.selectedOutlineColumn?.index??-1;t>=0&&e.splice(t,1),this._hoveredFootprints.push(i),this.totHoveredPoints+=i.totPoints}}this.initHoveringBuffer()}get hoveredFootprints(){return{metadata:this._metadataManager,footprints:this._hoveredFootprints,tableName:this._name,description:this._description,provider:this._providerUrl}}get selectedFootprints(){return this._selectedFootprints}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return[];const t=[],i=new n.Point({x:e.x,y:e.y,z:e.z},h.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const r=this.footprintPolygons[e];r.selectionObj&&(l.default.checkPointInsidePolygon5(r.selectionObj,i)&&t.push(e))}return t}setSelectedIndexes(e){e.forEach(e=>{e<0||e>=this.footprintPolygons.length||(this.selectedIndexes.includes(e)?this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1):this.selectedIndexes.push(e))}),this.refreshSelectedFootprints()}refreshSelectedFootprints(){if(this._selectedFootprints=this.selectedIndexes.map(e=>this.footprintPolygons[e]).filter(e=>Boolean(e)),this.totSelectedPoints=this._selectedFootprints.reduce((e,t)=>e+t.totPoints,0),0===this._selectedFootprints.length)return this.selectedVertexPosition=new Float32Array,this.selectedElementIndexes=new Uint32Array,void(this.nSlectedPrimitiveFlags=0);this.initSelectionBuffer()}getFootprintsFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{footprints:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this.footprintPolygons[e];t&&i.push(t)}),i.length?{footprints:i,pickedIndexes:t}:null}selectPrimaryFootprintFromClick(e){const t=this.getFootprintsFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{footprints:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this.footprintPolygons[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({footprint:t,selected:i}),s.push(t)}),s.length?{footprints:s,selectionState:r}:null}FootprintPolygonMatches(e,t){if(e===t)return!0;const i=e.convexPolygons,r=t.convexPolygons;if(i!==r||i!==r)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findFootprintPolygonIndex(e){const t=this.footprintPolygons.indexOf(e);return t>=0?t:this.footprintPolygons.findIndex(t=>this.FootprintPolygonMatches(t,e))}extHighlightFootprint(e,t){const i=this.findFootprintPolygonIndex(e);if(i<0)return;const r=i*u.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&this.hoveredIndexes.splice(e,1)}}extAddPolygons2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findFootprintPolygonIndex(e);if(t<0)return;const i=t*u.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&this.selectedIndexes.splice(e,1)}else this.selectedIndexes.push(t);this.refreshSelectedFootprints()}initHoveringBuffer(){if(!this._webgl)return;if(0==this._hoveredFootprints.length)return;let e=this._hoveredFootprints.length,t=e-1;for(let i=0;i<e;i++)t+=this._hoveredFootprints[i].polygons.length-1;this.hoveredElementIndexes=new Uint32Array(this.totHoveredPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this.hoveredVertexPosition=new Float32Array(3*this.totHoveredPoints);let r=0,s=0;this.nHoveredPrimitiveFlags=0;for(let t=0;t<e;t++){let e=this._hoveredFootprints[t].polygons;t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.hoveredVertexPosition[r]=1*t.x,this.hoveredVertexPosition[r+1]=1*t.y,this.hoveredVertexPosition[r+2]=1*t.z,this.hoveredElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}initSelectionBuffer(){if(!this._webgl)return;if(0==this._selectedFootprints.length)return;const e=this._selectedFootprints.length;let t=e-1;for(let i=0;i<e;i++)t+=this._selectedFootprints[i].polygons.length-1;this.selectedElementIndexes=new Uint32Array(this.totSelectedPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this.selectedVertexPosition=new Float32Array(3*this.totSelectedPoints);let r=0,s=0;this.nSlectedPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this._selectedFootprints[t].polygons;t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.selectedVertexPosition[r]=1*t.x,this.selectedVertexPosition[r+1]=1*t.y,this.selectedVertexPosition[r+2]=1*t.z,this.selectedElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}changeColor(e){this._shapeColor=e}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;if(this._footprintShaderProgram.enableShaders(r,e,i),null!=t&&t.xyz!=this.oldMouseCoords&&this.checkSelection(t),this._hoveredFootprints.length>0){const e=(0,o.colorHex2RGB)("#00FF00"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.hoveredVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.hoveredVertexPosition.length/3+this.nHoveredPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}if(this._selectedFootprints.length>0){const e=(0,o.colorHex2RGB)("#ECB462"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.selectedVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.selectedVertexPosition.length/3+this.nSlectedPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);const s=[...(0,o.colorHex2RGB)(this._shapeColor),1];this._webgl.uniform4f(this._footprintShaderProgram.locations.color,...s),this._webgl.drawElements(this._webgl.LINE_LOOP,this.indexes.length,this._webgl.UNSIGNED_INT,0),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null),this.oldMouseCoords=t.xyz}}t.FootprintSetGL=u},9839(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EquatorialGrid=void 0;const s=i(3890),o=i(229),a=i(7930),n=r(i(4707)),l=i(6553),h=i(8145),c=i(8083),u=r(i(5361)),d=i(4595),g=i(4735);class _ extends g.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;showGrid=!1;_shaderProgram;_vertexShader;_fragmentShader;defaultColor="#41d421";gridText;_attribLocations={position:0,selected:1,pointSize:2,color:3};_phiVertexPositionBuffer;_thetaVertexPositionBuffer;_fov;_phiStep=0;_phiStepRad=0;_thetaStep=0;_thetaStepRad=0;_phiArray=[];_thetaArray=[];_bufferKey="";_dec4Labels=new Map;_ra4Labels=new Map;_healpixGrid;constructor(e,t,i){super(d.HealpixGrid.RADIUS,d.HealpixGrid.INITIAL_POSITION,d.HealpixGrid.INITIAL_PhiRad,d.HealpixGrid.INITIAL_ThetaRad,"equatorial-grid",e),this._healpixGrid=t,this.gridText=new u.default("equatorial",i)}init(e){this._fov=e,this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders(),this._phiVertexPositionBuffer=super.webgl.createBuffer(),this._thetaVertexPositionBuffer=super.webgl.createBuffer(),this.initBuffers(this._fov)}initShaders(){const e=n.default.healpixGridFS();if(this._fragmentShader=super.webgl.createShader(super.webgl.FRAGMENT_SHADER),super.webgl.shaderSource(this._fragmentShader,e),super.webgl.compileShader(this._fragmentShader),!super.webgl.getShaderParameter(this._fragmentShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(e),void alert(e)}const t=n.default.healpixGridVS();if(this._vertexShader=super.webgl.createShader(super.webgl.VERTEX_SHADER),super.webgl.shaderSource(this._vertexShader,t),super.webgl.compileShader(this._vertexShader),!super.webgl.getShaderParameter(this._vertexShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(e),void alert(e)}super.webgl.attachShader(this._shaderProgram,this._vertexShader),super.webgl.attachShader(this._shaderProgram,this._fragmentShader),super.webgl.linkProgram(this._shaderProgram),super.webgl.getProgramParameter(this._shaderProgram,super.webgl.LINK_STATUS)||alert("Could not initialise shaders"),super.webgl.useProgram(this._shaderProgram)}initBuffers(e,t=!1){const i=o.fovHelper.getRADegSteps(e,t),r=i.raStep,s=i.decStep;this._phiStep=r,this._phiStepRad=(0,a.degToRad)(r),this._thetaStep=s,this._thetaStepRad=(0,a.degToRad)(s),this._ra4Labels=new Map,this._dec4Labels=new Map,this._phiArray=[],this._thetaArray=[];for(let e=s;e<180;e+=s){const t=new Float32Array(360/r*3),i=(0,a.degToRad)(e);for(let e=0;e<360;e+=r){const s=(0,a.degToRad)(e),o=1*Math.sin(i)*Math.cos(s),n=1*Math.sin(i)*Math.sin(s),l=1*Math.cos(i),h=Math.floor(e/r);t[3*h+0]=o,t[3*h+1]=n,t[3*h+2]=l,this._dec4Labels.has(e)||this._dec4Labels.set(e,[]),this._dec4Labels.get(e).push([o,n,l])}this._phiArray.push(t)}for(let e=0;e<360;e+=r){const t=new Float32Array(360/s*3),i=(0,a.degToRad)(e);for(let e=0;e<360;e+=s){const r=(0,a.degToRad)(e),o=1*Math.sin(r)*Math.cos(i),n=1*Math.sin(r)*Math.sin(i),l=1*Math.cos(r),h=Math.floor(e/s);t[3*h+0]=o,t[3*h+1]=n,t[3*h+2]=l;const c=90-e;this._ra4Labels.has(c)||this._ra4Labels.set(c,[]),this._ra4Labels.get(c).push([o,n,l])}this._thetaArray.push(t)}}refresh(e,t=!1){const i=o.fovHelper.getRADegSteps(e,t),r=`${t?"coarse":"settled"}:${i.raStep}:${i.decStep}`;this._bufferKey!==r&&(this._fov=e,this._bufferKey=r,this.initBuffers(this._fov,t))}vectorDistance(e,t){const i=e.x-t.x,r=e.y-t.y,s=e.z-t.z;return Math.sqrt(i*i+r*r+s*s)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const o=s.mat4.create();s.mat4.multiply(o,i,e);const n=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),l=r.getUniformLocation(this._shaderProgram,"uPMatrix"),h=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),n&&r.uniformMatrix4fv(n,!1,o),l&&r.uniformMatrix4fv(l,!1,t),h){const e=(0,a.colorHex2RGB)(this.defaultColor);r.uniform4f(h,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}draw(e){const t=e.fovDeg;if(!t)return;const i=super.webgl,r=this.getModelMatrix(),o=e.camera;if(!o)return;const n=o.getCameraMatrix(),u=e.pMatrix;if(!u)return;if(!n)return;if(0===this._thetaArray.length)return;if(this.refresh(t,!!e.cameraMoving),!this.showGrid)return void this.gridText.resetDivSets();this.enableShader(r,u,n);for(let e=0;e<this._phiArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._phiVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._phiArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._phiStep);for(let e=0;e<this._thetaArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._thetaVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._thetaArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._thetaStep);const d=c.FoVUtils.getCenterJ2000(i.canvas,this._healpixGrid,this._webgl,o,u),g=s.mat4.create();s.mat4.multiply(g,n,r);const _=s.mat4.create();s.mat4.multiply(_,u,g);for(const[e,t]of this._dec4Labels.entries())if(Math.abs(e-d.raDeg)<=this._phiStep)for(let e=0;e<t.length;e++){const[i,r,o]=t[e],a=[i,r,o,1],n=new l.Point({x:i,y:r,z:o},h.CoordsType.CARTESIAN).decDeg;if(Math.abs(n-d.decDeg)<60){const e=s.vec4.create();s.vec4.transformMat4(e,a,_),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(n.toFixed(2),i,r,"dec")}}for(const[e,t]of this._ra4Labels.entries())if(Math.abs(e-d.decDeg)<=this._thetaStep)for(let e=0;e<t.length;e++){const[i,r,o]=t[e],n=[i,r,o,1],c=new l.Point({x:i,y:r,z:o},h.CoordsType.CARTESIAN),u=this.vectorDistance(c,d),g=c.raDeg;if(u<(0,a.degToRad)(50)){const e=s.vec4.create();s.vec4.transformMat4(e,n,_),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(g.toFixed(2),i,r,"ra")}}this.gridText.resetDivSets(),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null)}}t.EquatorialGrid=_},5361(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{layer;state;containers;constructor(e="equatorial",t){this.layer=e,this.containers=t,this.state={container:this.resolveContainer(e),divSets:[],divSetNdx:0}}initHtml(){this.refreshContainer(this.layer,this.state)}resetDivSets(e=this.layer){const t=e===this.layer?this.state:{container:this.resolveContainer(e),divSets:[],divSetNdx:0};for(this.refreshContainer(e,t);t.divSetNdx<t.divSets.length;++t.divSetNdx)t.divSets[t.divSetNdx].style.display="none";t.divSetNdx=0}addHPXDivSet(e,t,i){this.addLabel("healpix",e,t+25,i,"hpx")}addEqDivSet(e,t,i,r){this.addLabel("equatorial",e,"ra"===r?t+25:t,"ra"===r?i:i+25,r)}addLonLatDivSet(e,t,i,r){this.addLabel("lonlat",e,"lon"===r?t+25:t,"lon"===r?i:i+25,r)}addLabel(e,t,i,r,s){const o=e===this.layer?this.state:{container:this.resolveContainer(e),divSets:[],divSetNdx:0};if(this.refreshContainer(e,o),!o.container)return;let a=o.divSets[o.divSetNdx++];if(!a){const e=document.createElement("div"),t=document.createTextNode("");e.appendChild(t),o.container.appendChild(e),a={div:e,textNode:t,style:e.style},o.divSets.push(a)}a.div.className=this.classNameForKind(s),a.style.display="block",a.style.position="absolute",a.style.zIndex="2",a.style.pointerEvents="none",a.style.font='12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',a.style.textShadow="0 1px 2px rgba(0, 0, 0, 0.7)",a.style.color=this.colorForKind(s);const n=o.container.getBoundingClientRect();a.style.left=`${Math.floor(i-n.left)}px`,a.style.top=`${Math.floor(r-n.top)}px`,a.textNode.nodeValue=t}colorForKind(e){switch(e){case"dec":return"#3fd35f";case"lat":return"#f6d35b";case"lon":return"#40c8ff";default:return"#5b7cff"}}classNameForKind(e){switch(e){case"dec":return"floating-div-dec";case"lat":return"floating-div-lat";case"lon":return"floating-div-lon";default:return"floating-div-ra"}}resolveContainer(e){if("healpix"===e){const e=this.containers?.resolveHealpix?.();return e||(this.containers?.healpix?this.containers.healpix:document.querySelector("#gridhpx"))}const t=this.containers?.resolveCoords?.();return t||(this.containers?.coords?this.containers.coords:document.querySelector("#gridcoords"))}refreshContainer(e,t){const i=this.resolveContainer(e);if(i!==t.container){for(const e of t.divSets)e.div.remove();t.container=i,t.divSets=[],t.divSetNdx=0}}}},4595(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HealpixGrid=void 0;const s=i(4735),o=r(i(4382)),a=i(3890),n=i(229),l=i(8083),h=i(5803),c=i(8145),u=i(6553),d=r(i(4707)),g=r(i(2930)),_=r(i(5361)),p=i(7930),f=i(2056),m=i(2919);class S extends s.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_visibleorder=0;showGrid=!1;_shaderProgram;fragmentShader;vertexShader;defaultColor="#ec0acaff";gridText;_attribLocations={position:0,selected:1,pointSize:2,color:3};_nPrimitiveFlags=0;_vertexCataloguePositionBuffer;_indexBuffer;_vertexCataloguePosition=new Float32Array(0);_indexes=new Uint32Array(0);_fovObj;static INITIAL_FOV=180;static RADIUS=1;static INITIAL_POSITION=[0,0,0];static INITIAL_PhiRad=0;static INITIAL_ThetaRad=0;_visibleTilesManager;constructor(e,t){super(S.RADIUS,S.INITIAL_POSITION,S.INITIAL_PhiRad,S.INITIAL_ThetaRad,"healpix-grid",e),this.gridText=new _.default("healpix",t),this.init(),this._visibleTilesManager=new f.VisibleTilesManager(this._webgl,super.hipsShaderProgram,this),this._visibleTilesManager.init(m.bootSetup.insideSphere)}init(){console.log("HealpixGridSingleton.init()"),this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders();const e=n.fovHelper.getHiPSNorder(S.INITIAL_FOV);this._visibleorder=e,this._nPrimitiveFlags=0,this._vertexCataloguePositionBuffer=super.webgl.createBuffer(),this._indexBuffer=super.webgl.createBuffer(),this._vertexCataloguePosition=new Float32Array(0),this._fovObj=new h.SphereFoV(super.webgl)}get fovObj(){return this._fovObj}get RADIUS(){return S.RADIUS}get INITIAL_POSITION(){return S.INITIAL_POSITION}get INITIAL_PhiRad(){return S.INITIAL_PhiRad}get INITIAL_ThetaRad(){return S.INITIAL_ThetaRad}refreshFoV(e,t){return this._fovObj.getFoV(o.default.insideSphere,this,e,t)}getFoV(){return this._fovObj}getMinFoV(){return this._fovObj.minFoV}initShaders(){const e=super.webgl,t=d.default.healpixGridFS();if(this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this.fragmentShader,t),e.compileShader(this.fragmentShader),!e.getShaderParameter(this.fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this.fragmentShader)||"Fragment shader compile error");const i=d.default.healpixGridVS();this.vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this.vertexShader,i),e.compileShader(this.vertexShader),e.getShaderParameter(this.vertexShader,e.COMPILE_STATUS)?(e.attachShader(this._shaderProgram,this.vertexShader),e.attachShader(this._shaderProgram,this.fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)):alert(e.getShaderInfoLog(this.vertexShader)||"Vertex shader compile error")}initBuffers(e,t){this._nPrimitiveFlags=0;const i=o.default.getHealpix(t),r=o.default.getHealpix(t+1),s=o.default.getHealpix(t+2);let a=0,n=0;this._indexes=new Uint32Array(17*e.length),this._vertexCataloguePosition=new Float32Array(48*e.length);for(let t=0;t<e.length;t++){const o=i.getBoundaries(e[t]),l=e[t]<<2,h=l+1,c=l+2,u=l+3,d=r.getBoundaries(l),g=r.getBoundaries(u),_=e=>{this._vertexCataloguePosition[a]=1*e.x,this._vertexCataloguePosition[a+1]=1*e.y,this._vertexCataloguePosition[a+2]=1*e.z,this._indexes[n]=Math.floor(a/3),n+=1,a+=3};_(o[0]);let p=(u<<2)+3,f=s.getBoundaries(p);_(f[1]),_(g[1]);let m=(c<<2)+2;f=s.getBoundaries(m),_(f[0]),_(o[1]),_(f[2]),_(d[1]);let S=l<<2;f=s.getBoundaries(S),_(f[1]),_(o[2]),_(f[3]),_(d[3]);let x=(h<<2)+1;f=s.getBoundaries(x),_(f[2]),_(o[3]),_(f[0]),_(g[3]),f=s.getBoundaries(p),_(f[3]),this._indexes[n]=4294967295,this._nPrimitiveFlags+=1,n+=1}}refresh(e,t){this.refreshFoV(e,t);const i=this.getMinFoV();this._visibleorder=n.fovHelper.getHiPSNorder(i,this._visibleorder)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const s=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),o=r.getUniformLocation(this._shaderProgram,"uPMatrix"),n=super.webgl.getUniformLocation(this._shaderProgram,"u_fragcolor");this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition");let l=a.mat4.create();if(l=a.mat4.multiply(l,i,e),s&&r.uniformMatrix4fv(s,!1,l),o&&r.uniformMatrix4fv(o,!1,t),n){const e=(0,p.colorHex2RGB)(this.defaultColor);r.uniform4f(n,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}get visibleTilesManager(){return this._visibleTilesManager}draw(e){const t=super.webgl,i=this.getModelMatrix(),r=e.camera;if(!r)return;const s=r.getCameraMatrix(),h=e.pMatrix;if(!h)return;const d=e.fovDeg??this.getMinFoV(),_=Number.isFinite(d)&&d>0?d:1e-6;if(this._visibleorder=n.fovHelper.getHiPSNorder(_,this._visibleorder),!this.showGrid)return void this.gridText.resetDivSets();const p=this._visibleTilesManager.visibleTilesByOrder,f=p.pixels,m=p.order;this.initBuffers(f,m),this.enableShader(i,h,s),t.bindBuffer(t.ARRAY_BUFFER,this._vertexCataloguePositionBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexCataloguePosition,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,S.ELEM_SIZE,t.FLOAT,!1,S.BYTES_X_ELEM*S.ELEM_SIZE,0),t.enableVertexAttribArray(this._attribLocations.position),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indexes,t.STATIC_DRAW),t.drawElements(t.LINE_LOOP,this._vertexCataloguePosition.length/3+this._nPrimitiveFlags,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);let x=a.mat4.create();x=a.mat4.multiply(x,s,i);let v=a.mat4.create();v=a.mat4.multiply(v,h,x);const b=l.FoVUtils.getCenterJ2000(t.canvas,this,this._webgl,r,h),M=this.getMinFoV()*Math.PI/180/2,T=o.default.getHealpix(this._visibleorder),y=T.getNPix();for(let e=0;e<f.length;e++){const i=f[e];if(!Number.isInteger(i)||i<0||i>=y)continue;const r=T.pix2vec(i),s=new u.Point({x:r.x,y:r.y,z:r.z},c.CoordsType.CARTESIAN);if(g.default.orthodromicDistance(b,s)<M){const i=[r.x,r.y,r.z,1],s=a.vec4.create();a.vec4.transformMat4(s,i,v),s[0]/=s[3],s[1]/=s[3];const o=t.canvas.getBoundingClientRect(),n=o.left+(.5*s[0]+.5)*o.width,l=o.top+(-.5*s[1]+.5)*o.height;this.gridText.addHPXDivSet(this._visibleorder+"/"+f[e],n,l)}}this.gridText.resetDivSets(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}get visibleorder(){return this._visibleorder}}t.HealpixGrid=S},8124(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LatLonGrid=void 0;const s=i(3890),o=i(4735),a=i(8284),n=r(i(4707)),l=i(7930),h=i(5803),c=r(i(4382)),u=r(i(5361));class d extends o.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_shaderProgram;_vertexShader;_fragmentShader;_attribLocations={position:0};_lonVertexPositionBuffer;_latVertexPositionBuffer;_lonStep=10;_latStep=10;_segmentStep=1;_fovObj;_fovDeg=180;_showGrid=!0;_lonArray=[];_latArray=[];_bufferKey="";defaultColor="#41d4d4";gridText;constructor(e,t,i,r,s,o,a){super(e,t,i,r,s,o),this.gridText=new u.default("lonlat",a),this._fovObj=new h.SphereFoV(o),this.init()}init(){this.initGL(super.webgl);const e=super.webgl;this._shaderProgram=e.createProgram(),this.initShaders(),this._lonVertexPositionBuffer=e.createBuffer(),this._latVertexPositionBuffer=e.createBuffer(),this.initBuffers(this._fovDeg)}initShaders(){const e=super.webgl,t=n.default.healpixGridFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(t),void alert(t)}const i=n.default.healpixGridVS();if(this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),!e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(t),void alert(t)}e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)}initBuffers(e,t,i=!1){const r=a.xyzFovHelper.getLonLatSteps(e,i);this._lonStep=r.lonStep,this._latStep=r.latStep,this._segmentStep=Math.max(Math.min(this._lonStep,this._latStep),.25),this._lonArray=[],this._latArray=[];const s=t?{lon:this.normalizeLon(t.phi>180?t.phi-360:t.phi),lat:90-t.theta}:null,o=!!s&&!i&&e<2,n=o?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._lonStep):this.buildLonRange(0,180,this._lonStep),l=o?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._latStep):this.buildLatRange(0,90,this._latStep),h=o&&s?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._segmentStep):this.buildLatRange(0,90,this._segmentStep),c=o&&s?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._segmentStep):this.buildLonRange(0,180,this._segmentStep);for(const e of n){const t=[];for(const i of h)t.push(...this.lonLatToCartesian(e,Math.min(i,90)));this._lonArray.push(new Float32Array(t))}for(const e of l){const t=[];if(!(e<=-90||e>=90)){for(const i of c)t.push(...this.lonLatToCartesian(Math.min(i,180),e));this._latArray.push(new Float32Array(t))}}}buildLonRange(e,t,i){const r=[],s=Math.floor((e-t)/i)*i,o=Math.ceil((e+t)/i)*i;for(let e=s;e<=o;e+=i)r.push(this.normalizeLon(e));return r}buildLatRange(e,t,i){const r=[],s=Math.max(-90,Math.floor((e-t)/i)*i),o=Math.min(90,Math.ceil((e+t)/i)*i);for(let e=s;e<=o;e+=i)r.push(e);return r}lonLatToCartesian(e,t){const i=(0,l.degToRad)(e),r=(0,l.degToRad)(t),s=Math.cos(r);return[s*Math.cos(i),s*Math.sin(i),Math.sin(r)]}refresh(e,t){const i=!!t.cameraMoving,r=a.xyzFovHelper.getLonLatSteps(e,i),s=t.centerSphericalDeg,o=!!s&&!i&&e<2,n=s?this.normalizeLon(s.phi>180?s.phi-360:s.phi):0,l=s?90-s.theta:0,h=o?`${this.roundToStep(n,Math.max(r.lonStep,e))}:${this.roundToStep(l,Math.max(r.latStep,e))}`:"global",c=`${i?"coarse":"settled"}:${r.lonStep}:${r.latStep}:${h}`;this._bufferKey!==c&&(this._fovDeg=e,this._bufferKey=c,this.initBuffers(this._fovDeg,t.centerSphericalDeg,i))}refreshFoV(e){return e.camera&&e.pMatrix?(this._fovObj.getFoV(c.default.insideSphere,this,e.camera,e.pMatrix),this.refresh(this._fovObj.minFoV,e),this._fovObj.minFoV):this._fovDeg}getMinFoVDeg(){return this._fovObj.minFoV}getFoV(){return this._fovObj}isVisible(){return this._showGrid}toggleShowGrid(){return this._showGrid=!this._showGrid,this._showGrid}setShowGrid(e){this._showGrid=e}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const o=s.mat4.create();s.mat4.multiply(o,i,e);const a=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),n=r.getUniformLocation(this._shaderProgram,"uPMatrix"),h=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),a&&r.uniformMatrix4fv(a,!1,o),n&&r.uniformMatrix4fv(n,!1,t),h){const e=(0,l.colorHex2RGB)(this.defaultColor);r.uniform4f(h,e[0],e[1],e[2],1)}}draw(e){if(!this._showGrid)return void this.gridText.resetDivSets();const t=super.webgl,i=e.camera;if(!i)return;const r=e.pMatrix;if(!r)return;this.refreshFoV(e);const s=i.getCameraMatrix();if(!s)return;const o=this.getModelMatrix();this.enableShader(o,r,s);for(const e of this._lonArray)t.bindBuffer(t.ARRAY_BUFFER,this._lonVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_STRIP,0,e.length/d.ELEM_SIZE);for(const e of this._latArray)t.bindBuffer(t.ARRAY_BUFFER,this._latVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_LOOP,0,e.length/d.ELEM_SIZE);this.drawLabels(e,o,r,s),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}drawLabels(e,t,i,r){const s=e.centerSphericalDeg;if(!s)return void this.gridText.resetDivSets();const o=this.normalizeLon(s.phi>180?s.phi-360:s.phi),a=90-s.theta,n=this.normalizeLon(this.roundToStep(o,this._lonStep)),l=Math.max(-90+this._latStep,Math.min(90-this._latStep,this.roundToStep(a,this._latStep))),h=this.lonLatToCartesian(n,Math.max(-80,Math.min(80,a))),c=this.lonLatToCartesian(o,l),u=this.projectPointToScreen(h,t,i,r);u&&this.gridText.addLonLatDivSet(`${n.toFixed(0)}° lon`,u.x,u.y,"lon");const d=this.projectPointToScreen(c,t,i,r);d&&this.gridText.addLonLatDivSet(`${l.toFixed(0)}° lat`,d.x,d.y,"lat"),this.gridText.resetDivSets()}projectPointToScreen(e,t,i,r){const o=s.mat4.create(),a=s.mat4.create();s.mat4.multiply(o,r,t),s.mat4.multiply(a,i,o);const n=s.vec4.fromValues(e[0],e[1],e[2],1);if(s.vec4.transformMat4(n,n,a),Math.abs(n[3])<1e-6)return null;if(n[0]/=n[3],n[1]/=n[3],n[0]<-1||n[0]>1||n[1]<-1||n[1]>1)return null;const l=super.webgl.canvas.getBoundingClientRect();return{x:l.left+(.5*n[0]+.5)*l.width,y:l.top+(-.5*n[1]+.5)*l.height}}roundToStep(e,t){return t<=0?e:Math.round(e/t)*t}normalizeLon(e){let t=e;for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}t.LatLonGrid=d},2368(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(1399);t.default=class{_ready=!1;_hips;_format;_baseurl;_isGalacticHips;_order=3;_hipsShaderIndex=0;_texture=null;_image;_texurl;_fitsTile;_textureLoaded=!1;_maxTiles=0;_numFacesXTile=0;_numFaces=0;vertexPosition;vertexPositionBuffer;vertexIndexBuffer;vidx=0;_webgl;_tileBuffer;_hipsShaderProgram;constructor(e,t,i,r){this._tileBuffer=i,this._hips=e,this._webgl=t,this._format=e.format,this._baseurl=e.baseURL,this._isGalacticHips=e.isGalacticHips,this._hipsShaderProgram=r,this.initImage()}initImage(){this._texurl=`${this._baseurl}/Norder3/Allsky.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.setAttribute("crossorigin","anonymous"),this._image.src=this._texurl}async loadFits(){try{this._fitsTile=await(0,o.loadFitsTile)(this._texurl),this._hips.observeFITSDataRange(this._fitsTile),this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}catch(e){console.error(`[AllSky] Unable to load FITS atlas ${this._texurl}`,e)}}imageLoaded(){this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;if(this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),e.bindTexture(e.TEXTURE_2D,this._texture),"fits"===this._format){const t=this._fitsTile;if(!t)throw new Error(`FITS AllSky data not loaded: ${this._texurl}`);e.texImage2D(e.TEXTURE_2D,0,e.R32F,t.width,t.height,0,e.RED,e.FLOAT,t.pixels),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.generateMipmap(e.TEXTURE_2D);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.isTexture(this._texture)||console.log("error in texture")}getFitsDataRange(){return this._hips.getFITSDisplayRange(this._fitsTile)}initModelBuffer(){const e=this._webgl,t=this._order+1,i=s.default.getHealpix(this._order);this._maxTiles=i.getNPix();const r=s.default.getHealpix(t);this._numFacesXTile=4,this._numFaces=this._numFacesXTile*this._maxTiles,this.vertexPosition=new Float32Array(20*this._numFaces);let o=0,a=0;this.vidx=0;for(let e=0;e<this._maxTiles;e++){const t=i.nest2xyf(e),s=t.ix<<1,n=2+(t.ix<<1),l=t.iy<<1,h=2+(t.iy<<1);this.setupPositionAndTexture4Quadrant(o,a,s,s+(n-s)/2,l,l+(h-l)/2,r,t,0,0),this.setupPositionAndTexture4Quadrant(o,a,s+(n-s)/2,n,l,l+(h-l)/2,r,t,0,1),this.setupPositionAndTexture4Quadrant(o,a,s,s+(n-s)/2,l+(h-l)/2,h,r,t,1,0),this.setupPositionAndTexture4Quadrant(o,a,s+(n-s)/2,n,l+(h-l)/2,h,r,t,1,1),o++,27===o&&(a++,o=0)}const n=new Uint16Array(6*this._numFaces);let l=0;for(let e=0;e<this._numFaces;e++)n[6*e]=l,n[6*e+1]=l+1,n[6*e+2]=l+3,n[6*e+3]=l+1,n[6*e+4]=l+2,n[6*e+5]=l+3,l+=4;this.vertexPositionBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexPositionBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexPosition,e.STATIC_DRAW),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,i,r,s,o,a,n,l,h){let c=[];const u=2**(a.order-3),d=1/(27*u),g=1/(29*u),_=d/64,p=g/64,f=u*d*e+d*l,m=u*g*t+g*h;for(let e=i;e<r;e++)for(let t=s;t<o;t++)c=a.getPointsForXyfNoStep(e,t,n.face),this.vertexPosition[20*this.vidx]=c[0].x,this.vertexPosition[20*this.vidx+1]=c[0].y,this.vertexPosition[20*this.vidx+2]=c[0].z,this.vertexPosition[20*this.vidx+3]=d+f-_,this.vertexPosition[20*this.vidx+4]=1-(g+m)+p,this.vertexPosition[20*this.vidx+5]=c[1].x,this.vertexPosition[20*this.vidx+6]=c[1].y,this.vertexPosition[20*this.vidx+7]=c[1].z,this.vertexPosition[20*this.vidx+8]=d+f-_,this.vertexPosition[20*this.vidx+9]=1-m-p,this.vertexPosition[20*this.vidx+10]=c[2].x,this.vertexPosition[20*this.vidx+11]=c[2].y,this.vertexPosition[20*this.vidx+12]=c[2].z,this.vertexPosition[20*this.vidx+13]=f+_,this.vertexPosition[20*this.vidx+14]=1-m-p,this.vertexPosition[20*this.vidx+15]=c[3].x,this.vertexPosition[20*this.vidx+16]=c[3].y,this.vertexPosition[20*this.vidx+17]=c[3].z,this.vertexPosition[20*this.vidx+18]=f+_,this.vertexPosition[20*this.vidx+19]=1-(g+m)+p,this.vidx++}draw(e,t,i,r,s,o){if(!this._ready)return!1;let a=[];if(e>=this._order){const n=this.drawChildren(e,t,i,r,s,o);n&&(a=n)}const n=this._webgl;if(this._hipsShaderProgram.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return console.error(`[AllSky] No display range available for FITS atlas ${this._texurl}`),!1;this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max,this._hips.fitsStretch.scaleFunctionIndex,this._hips.fitsStretch.scaleParam)}else this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!1);n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture);const l=this._hipsShaderProgram.locations.textureAlpha[this._hipsShaderIndex];null!==l&&n.uniform1f(l,1),this._hipsShaderProgram.setLayerOpacity(this._hips.opacity),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12);for(let e=0;e<this._maxTiles;e++)a.includes(e)||n.drawElements(n.TRIANGLES,6*this._numFacesXTile,n.UNSIGNED_SHORT,12*e*this._numFacesXTile);return n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,o){const a=this._order;if(!t.has(a))return;const n=t.get(a),l=[];for(let h=0;h<n.length;h++){const c=n[h];if(!this._hips.intersectsCoverage(a,c)){l.push(c);continue}const u=this._isGalacticHips?this._tileBuffer.getGalTile(c,a,this._hips):this._tileBuffer.getTile(c,a,this._hips);u.draw(e,t,i,r,s,o,this._hipsShaderProgram),u.getReadyState()&&l.push(c)}return l}}},2885(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(229),a=i(1399);t.default=class{_hips;_tileno;_baseurl;_order;_ready=!1;_format;_isGalacticHips;opacity=1;_hipsShaderIndex=0;_pixels=[];_texture=null;_image;_texurl="";_fitsTile;vertexPosition;vertexPositionBuffer;vertexIndices;vertexIndexBuffer;_tileBuffer;_hipsShaderProgram;_webgl;constructor(e,t,i,r,s,o){this._hipsShaderProgram=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._webgl=o,this._format=i.format,this._baseurl=i.baseURL,this._isGalacticHips=i.isGalacticHips,this._order=t,this.initImage()}destroyIntervals(){}initImage(){const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}async loadFits(){try{this._fitsTile=await(0,a.loadFitsTile)(this._texurl),this._hips.observeFITSDataRange(this._fitsTile),this.textureLoaded();const e=this._fitsTile;if(!e)throw new Error(`FITS tile data not loaded: ${this._texurl}`);const t=this._webgl;t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.bindTexture(t.TEXTURE_2D,this._texture),t.texImage2D(t.TEXTURE_2D,0,t.R32F,e.width,e.height,0,t.RED,t.FLOAT,e.pixels),this.initModelBuffer(),this._ready=!0}catch(e){console.error(`[AncestorTile] Unable to load FITS tile ${this._texurl}`,e)}}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.crossOrigin="anonymous",this._image.src=this._texurl}imageLoaded(){this.textureLoaded(),this.initModelBuffer();const e=this._webgl;e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),e.bindTexture(e.TEXTURE_2D,this._texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),"fits"===this._format?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR)),e.isTexture(this._texture)||console.log("error in texture")}getFitsDataRange(){return this._hips.getFITSDisplayRange(this._fitsTile)}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=o.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,a=i.ix<<r,n=(i.ix<<r)+(1<<r),l=i.iy<<r,h=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this._pixels=[],this.setupPositionAndTexture4Quadrant(a,n/2,l,h/2,0,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,l,h/2,1,c,r,i),this.setupPositionAndTexture4Quadrant(a,n/2,h/2,h,2,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,h/2,h,3,c,r,i);const u=this.vertexPosition[0].length/20;this.vertexIndices=this.computeVertexIndices(u),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint16Array(6*e);let i=0;for(let r=0;r<e;r++)t[6*r]=i,t[6*r+1]=i+1,t[6*r+2]=i+2,t[6*r+3]=i+2,t[6*r+4]=i+3,t[6*r+5]=i,i+=4;return t}setupPositionAndTexture4Quadrant(e,t,i,r,s,o,a,n){const l=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const h=1/(1<<a);let c=0;for(let l=e;l<t;l++)for(let e=i;e<r;e++){const t=o.xyf2nest(l,e,n.face);this._pixels.push(t);const i=o.getBoundaries(t),r=e-(n.iy<<a),u=l-(n.ix<<a);this.vertexPosition[s][20*c]=i[0].x,this.vertexPosition[s][20*c+1]=i[0].y,this.vertexPosition[s][20*c+2]=i[0].z,this.vertexPosition[s][20*c+3]=h+h*r,this.vertexPosition[s][20*c+4]=1-(h+h*u),this.vertexPosition[s][20*c+5]=i[1].x,this.vertexPosition[s][20*c+6]=i[1].y,this.vertexPosition[s][20*c+7]=i[1].z,this.vertexPosition[s][20*c+8]=h+h*r,this.vertexPosition[s][20*c+9]=1-h*u,this.vertexPosition[s][20*c+10]=i[2].x,this.vertexPosition[s][20*c+11]=i[2].y,this.vertexPosition[s][20*c+12]=i[2].z,this.vertexPosition[s][20*c+13]=h*r,this.vertexPosition[s][20*c+14]=1-h*u,this.vertexPosition[s][20*c+15]=i[3].x,this.vertexPosition[s][20*c+16]=i[3].y,this.vertexPosition[s][20*c+17]=i[3].z,this.vertexPosition[s][20*c+18]=h*r,this.vertexPosition[s][20*c+19]=1-(h+h*u),c++}this.vertexPositionBuffer[s]=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[s]),l.bufferData(l.ARRAY_BUFFER,this.vertexPosition[s],l.STATIC_DRAW)}draw(e,t,i,r,s,o){if(!this._ready)return!1;let a=new Set([0,1,2,3]);if(e>this._order){const n=this.drawChildren(e,t,i,r,s,o);n&&(a=n)}if(this._hipsShaderProgram.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return console.error(`[AncestorTile] No display range available for FITS tile ${this._texurl}`),!1;this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max,this._hips.fitsStretch.scaleFunctionIndex,this._hips.fitsStretch.scaleParam)}else this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!1);const n=this._webgl;n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture);const l=this._hipsShaderProgram.locations.textureAlpha[this._hipsShaderIndex];l&&n.uniform1f(l,this.opacity),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const h=this.vertexIndices.length;return a.forEach(e=>{n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer[e]),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12),n.drawElements(n.TRIANGLES,h,n.UNSIGNED_SHORT,0)}),n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,o){const a=new Set([0,1,2,3]),n=this._order+1;if(t.has(n)){for(let l=0;l<4;l++){const h=(this._tileno<<2)+l;if(!this._hips.intersectsCoverage(n,h))continue;if(t.get(n).includes(h)){if(!this._hips.intersectsCoverage(n,h)){a.delete(l);continue}const c=this._isGalacticHips?this._tileBuffer.getGalTile(h,n,this._hips):this._tileBuffer.getTile(h,n,this._hips);c.draw(e,t,i,r,s,o,this._hipsShaderProgram),c.getReadyState()&&a.delete(l)}}return a}}}},1399(e,t,i){"use strict";t.loadFitsTile=async function(e){const t=await r.FITSParser.loadFITSFile(e);if(!t?.primaryHDU)throw new Error(`Unable to load FITS tile: ${e}`);const i=t.primaryHDU;if(2!==i.naxis)throw new Error(`Expected a 2D FITS tile, got NAXIS=${i.naxis}: ${e}`);const[a,n]=i.shape;if(!Number.isInteger(a)||!Number.isInteger(n)||a<=0||n<=0)throw new Error(`Invalid FITS tile dimensions: ${e}`);const l=i.typedData;if(!l||l.length!==a*n)throw new Error(`Invalid FITS tile payload: ${e}`);if(l instanceof BigInt64Array)throw new Error(`BITPIX=64 FITS tiles are not supported for HiPS rendering: ${e}`);const h=o(i.header,r.FITSHeaderManager.BSCALE)??1,c=o(i.header,r.FITSHeaderManager.BZERO)??0,u=o(i.header,r.FITSHeaderManager.BLANK),d=o(i.header,r.FITSHeaderManager.DATAMIN),g=o(i.header,r.FITSHeaderManager.DATAMAX),_=new Float32Array(l.length);let p=null,f=null;const m=[],S=Math.max(1,Math.floor(l.length/8192));for(let e=0;e<l.length;e++){const t=l[e];if(!Number.isFinite(t)||null!==u&&t===u){_[e]=Number.NaN;continue}const i=t*h+c;_[e]=i,Number.isFinite(i)&&(p=null===p?i:Math.min(p,i),f=null===f?i:Math.max(f,i),e%S===0&&m.push(i))}const x=function(e){if(0===e.length)return null;e.sort((e,t)=>e-t);const t=s(e,.005),i=s(e,.995);if(!Number.isFinite(t)||!Number.isFinite(i)||i<=t)return null;return{min:t,max:i}}(m);return{width:a,height:n,pixels:_,dataMin:d,dataMax:g,physicalMin:p,physicalMax:f,robustMin:x?.min??null,robustMax:x?.max??null}};const r=i(1677);function s(e,t){return e[Math.min(e.length-1,Math.max(0,Math.round((e.length-1)*t)))]}function o(e,t){const i=e.findById(t);if(!i)return null;const r=Number(i.value);return Number.isFinite(r)?r:null}},229(e,t){"use strict";t.fovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static HIPS_ORDER_MIN_FOV={0:179,1:90,2:30,3:20,4:6,5:3.2,6:1.6,7:.85,8:.42,9:.21,10:.12,11:.06,12:.015,13:0};getHiPSNorder(e,t){const r=this.getRawHiPSNorder(e);if(void 0===t||t===r)return r;if(r>t){const r=i.HIPS_ORDER_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.HIPS_ORDER_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawHiPSNorder(e){return e>=179?0:e>=90?1:e>=30?2:e>=20?3:e>=6?4:e>=3.2?5:e>=1.6?6:e>=.85?7:e>=.42?8:e>=.21?9:e>=.12?10:e>=.06?11:e>=.015?12:13}getRADegSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{raStep:i,decStep:r}}getRefOrder(e){switch(e){case 0:case 1:case 2:case 3:return e+6;case 4:case 5:case 6:case 7:return e+5;case 8:return e+4;default:return e+3}}}t.fovHelper=new i},3726(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPS=void 0;const s=i(4735),o=i(229),a=r(i(619)),n=r(i(2885)),l=r(i(2368)),h=i(9912),c={linear:0,sqrt:1,log:2,asinh:3,gamma:4},u={linear:1,sqrt:1,log:100,asinh:10,gamma:.5};class d extends s.AbstractSkyEntity{_ancestorTiles;_allSkyTile;_descriptor;_coverage;_coverageResolved=!1;_opacity=1;_format;_baseurl;_maxorder;_minorder;_visibleorder=3;_allSky=!0;samplerIdx=0;colorMapIdx=0;colorMap=a.default.native;_fitsStretch={scaleFunction:"linear",scaleFunctionIndex:c.linear,scaleParam:u.linear,rangeMode:"robust"};_robustFITSRanges=[];_healpixGrid;get maxOrder(){return this._maxorder}get minOrder(){return this._minorder}get baseURL(){return this._baseurl}get format(){return this._format}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}constructor(e,t,i,r,s,a,n){super(e,t,i,r,s.surveyName,a,s.isGalactic),this._descriptor=s,this.initGL(a),this._healpixGrid=n,this._format=this.selectDefaultFormat(s.imgFormats),this._baseurl=s.url,this._maxorder=s.maxOrder,this._minorder=s.minOrder,this._coverage=new h.HiPSCoverage,this._coverage.load(this._baseurl).then(()=>{this._coverageResolved=!0}).catch(e=>{console.warn(`[HiPS] Coverage unavailable for ${this._baseurl}; continuing without MOC filtering.`,e),this._coverage.clear(),this._coverageResolved=!0}),this.isGalacticHips?this._healpixGrid.visibleTilesManager.tileBuffer.addGalHiPS(this):this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this),console.log("HiPS frame "+s.hipsFrame),console.log("HiPS minOrder "+s.minOrder),this.initShaders();let l=o.fovHelper.getHiPSNorder(180);this._visibleorder=Math.min(l,this._maxorder),this._ancestorTiles=[],this._allSkyTile=null,this._allSky=!0,this.initBaseTiles()}setOpacity(e){if(!Number.isFinite(e))throw new Error(`Invalid HiPS opacity: ${e}`);this._opacity=Math.min(1,Math.max(0,e))}get opacity(){return this._opacity}intersectsCoverage(e,t){return!!this._coverageResolved&&this._coverage.intersectsTile(e,t)}get coverageLoaded(){return this._coverage.loaded}initBaseTiles(){if(this._ancestorTiles=[],this._allSkyTile=null,this._allSky)this._allSkyTile=new l.default(this,this._webgl,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram);else for(let e=0;e<12;e++)this._ancestorTiles.push(new n.default(e,0,this,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram,this._webgl))}getProperty(e){return this._descriptor.getProperty(e)}changeFormat(e){const t=e.toLowerCase();if(!this._descriptor.imgFormats.includes(t))throw new Error(`HiPS format "${e}" is not supported. Available formats: ${this._descriptor.imgFormats.join(", ")}`);if(t===this._format.toLowerCase())return;this._healpixGrid.visibleTilesManager.tileBuffer.invalidateHiPS(this),this._format=t,this.initBaseTiles()}get availableFormats(){return this._descriptor.imgFormats}changeColorMap(e){switch(console.log("HiPS.changeColorMap -> shaderProgram",super.hipsShaderProgram.shaderProgram),this.colorMap=e,e.name){case"grayscale":this.colorMapIdx=1,this.colorMap=a.default.grayscale,super.hipsShaderProgram.setGrayscaleShader();break;case"planck":this.colorMapIdx=2,this.colorMap=a.default.planck,super.hipsShaderProgram.setColorMapShader();break;case"cmb":this.colorMapIdx=3,this.colorMap=a.default.cmb,super.hipsShaderProgram.setColorMapShader();break;case"rainbow":this.colorMapIdx=4,this.colorMap=a.default.rainbow,super.hipsShaderProgram.setColorMapShader();break;case"eosb":this.colorMapIdx=5,this.colorMap=a.default.eosb,super.hipsShaderProgram.setColorMapShader();break;case"cubehelix":this.colorMapIdx=6,this.colorMap=a.default.cubehelix,super.hipsShaderProgram.setColorMapShader();break;case"hot":this.colorMapIdx=7,this.colorMap=a.default.hot,super.hipsShaderProgram.setColorMapShader();break;case"gray":this.colorMapIdx=8,this.colorMap=a.default.gray,super.hipsShaderProgram.setColorMapShader();break;case"native":this.colorMapIdx=0,this.colorMap=a.default.native,super.hipsShaderProgram.setNativeShader();break;default:this.colorMapIdx=9,this.colorMap=e,super.hipsShaderProgram.setColorMapShader()}}initShaders(){super.hipsShaderProgram.enableProgram()}selectDefaultFormat(e){if(e.includes("png"))return"png";if(e.includes("jpg"))return"jpg";if(e.includes("fits"))return"fits";if(e.length>0)return e[0];throw new Error("HiPS descriptor does not define a tile format")}get dataRange(){return this._descriptor.dataRange}get fitsStretch(){return this._fitsStretch}setFITSScaleFunction(e,t){const i=c[e];if(void 0===i)throw new Error(`Unsupported FITS scale function: ${e}`);const r=t??u[e];if(!Number.isFinite(r)||r<=0)throw new Error(`Invalid FITS scale parameter: ${r}`);this._fitsStretch={...this._fitsStretch,scaleFunction:e,scaleFunctionIndex:i,scaleParam:r}}setFITSRangeMode(e){if("robust"!==e&&"hips"!==e&&"tile"!==e)throw new Error(`Unsupported FITS range mode: ${e}`);this._fitsStretch={...this._fitsStretch,rangeMode:e}}observeFITSDataRange(e){null===e.robustMin||null===e.robustMax||!Number.isFinite(e.robustMin)||!Number.isFinite(e.robustMax)||e.robustMax<=e.robustMin||(this._robustFITSRanges.push({min:e.robustMin,max:e.robustMax}),this._robustFITSRanges.length>512&&this._robustFITSRanges.shift())}getFITSDisplayRange(e){const t=this.getHiPSDataRange();if("hips"===this._fitsStretch.rangeMode&&t)return t;if("robust"===this._fitsStretch.rangeMode){const t=this.getRobustFITSRange()??this.getTileRobustRange(e);if(t)return t}const i=this.getTilePhysicalRange(e)??this.getTileHeaderRange(e);return i||t}getHiPSDataRange(){const e=this.dataRange;return void 0!==e.min&&void 0!==e.max&&Number.isFinite(e.min)&&Number.isFinite(e.max)&&e.max>e.min?{min:e.min,max:e.max}:null}getRobustFITSRange(){if(0===this._robustFITSRanges.length)return null;const e=this._robustFITSRanges.map(e=>e.min).sort((e,t)=>e-t),t=this._robustFITSRanges.map(e=>e.max).sort((e,t)=>e-t),i=e[Math.floor(.1*(e.length-1))],r=t[Math.ceil(.9*(t.length-1))];return!Number.isFinite(i)||!Number.isFinite(r)||r<=i?null:{min:i,max:r}}getTileRobustRange(e){return e&&null!==e.robustMin&&null!==e.robustMax&&Number.isFinite(e.robustMin)&&Number.isFinite(e.robustMax)&&e.robustMax>e.robustMin?{min:e.robustMin,max:e.robustMax}:null}getTilePhysicalRange(e){return e&&null!==e.physicalMin&&null!==e.physicalMax&&Number.isFinite(e.physicalMin)&&Number.isFinite(e.physicalMax)&&e.physicalMax>e.physicalMin?{min:e.physicalMin,max:e.physicalMax}:null}getTileHeaderRange(e){return e&&null!==e.dataMin&&null!==e.dataMax&&Number.isFinite(e.dataMin)&&Number.isFinite(e.dataMax)&&e.dataMax>e.dataMin?{min:e.dataMin,max:e.dataMax}:null}getCurrentHealpixOrder(){return this._visibleorder}getDebugStats(){const e=this._healpixGrid.visibleTilesManager.tileBuffer,t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;return{activeBaseLayer:"hips",hipsName:this._descriptor.surveyName,hipsUrl:this._baseurl,isGalactic:this.isGalacticHips,currentOrder:t.order,visibleTileCount:t.pixels.length,activeTileCount:e.activeTileCount,cachedTileCount:e.cachedTileCount,cacheSize:e.size,readyTileCount:e.readyTileCount,loadingTileCount:e.loadingTileCount}}refresh(e){const t=e.fovDeg??this._healpixGrid.getMinFoV(),i=Number.isFinite(t)&&t>0?t:1e-6;this._visibleorder=Math.min(o.fovHelper.getHiPSNorder(i,this._visibleorder),this._maxorder)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();if(super.hipsShaderProgram.setRuntimeColorMap(this.colorMap),this._allSky&&this._allSkyTile)return void(this.isGalacticHips?this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.galAncestorsMap,i,t,r,this.colorMapIdx):this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.ancestorsMap,i,t,r,this.colorMapIdx));const s=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order:this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,o=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galAncestorsMap:this._healpixGrid.visibleTilesManager.ancestorsMap;this._ancestorTiles.forEach(e=>{e.draw(s,o,i,t,r,this.colorMapIdx)})}}t.HiPS=d},9912(e,t,i){"use strict";t.HiPSCoverage=void 0;const r=i(1677);class s{intersec(e,t){throw new Error("Method not implemented.")}ises(e,t,i,r){throw new Error("Method not implemented.")}intersexpect(e,t,i,r){throw new Error("Method not implemented.")}intersectsT19(e,t){throw new Error("Method not implemented.")}_maxOrder=0;_intervals=[];_loaded=!1;get loaded(){return this._loaded}get maxOrder(){return this._maxOrder}get intervalCount(){return this._intervals.length}clear(){this._maxOrder=0,this._intervals=[],this._loaded=!1}async load(e){const t=e instanceof URL?e.href:String(e),i=t.endsWith("/")?t:`${t}/`;await this.loadMoc(`${i}Moc.fits`)}async loadMoc(e){this.clear();const t=await r.FITSParser.loadFITSFile(e);if(!t)throw new Error("Unable to load HiPS Moc.fits");const i=t.hdus.find(e=>e instanceof r.BinaryTableHDU);if(!(i instanceof r.BinaryTableHDU))throw new Error("HiPS Moc.fits does not contain a BINTABLE HDU.");const o=i.header.findById("MOCORDER");if(!o)throw new Error("HiPS Moc.fits does not define MOCORDER.");const a=Number(o.value);if(!Number.isInteger(a)||a<0)throw new Error(`Invalid MOCORDER value: ${o.value}`);this._maxOrder=a;const n=[];for(let e=0;e<i.rowCount;e++){const t=i.getCell(e,"UNIQ");if("number"!=typeof t||!Number.isInteger(t)||t<4)throw new Error(`Invalid MOC UNIQ value at row ${e}: ${String(t)}`);const{order:r,pixel:o}=s.decodeUniq(t);if(r>this._maxOrder)throw new Error(`MOC cell order ${r} exceeds MOCORDER ${this._maxOrder}.`);const a=4**(this._maxOrder-r);n.push({first:o*a,last:(o+1)*a-1})}this._intervals=s.mergeIntervals(n),this._loaded=!0}intersectsTile(e,t){if(!this._loaded)return!0;if(!Number.isInteger(e)||e<0||!Number.isInteger(t)||t<0)return!1;let i,r;if(e<=this._maxOrder){const s=4**(this._maxOrder-e);i=t*s,r=(t+1)*s-1}else{const s=2*(e-this._maxOrder),o=Math.floor(t/2**s);i=o,r=o}return this.intersectsInterval(i,r)}intersectsInterval(e,t){let i=0,r=this._intervals.length-1;for(;i<=r;){const s=Math.floor((i+r)/2),o=this._intervals[s];if(o.last<e)i=s+1;else{if(!(o.first>t))return!0;r=s-1}}return!1}static decodeUniq(e){let t=0;for(;4**(t+2)<=e;)t++;return{order:t,pixel:e-4**(t+1)}}static mergeIntervals(e){if(0===e.length)return[];e.sort((e,t)=>e.first-t.first);const t=[{...e[0]}];for(let i=1;i<e.length;i++){const r=e[i],s=t[t.length-1];r.first<=s.last+1?s.last=Math.max(s.last,r.last):t.push({...r})}return t}}t.HiPSCoverage=s},5087(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSDescriptor=void 0;t.HiPSDescriptor=class{_minOrder=3;_imgformats=[];_datarange={min:void 0,max:void 0};_maxOrder;_tilewidth;_hipsFrame;_hipsName="NONAME";_hipsurl;_emMin;_emMax;_isGalctic=!1;_propertiesRawText;_propertiesMap=new Map;constructor(e,t){this._hipsurl=t,this._propertiesRawText=e;const i=e.split(/\r\n|\n/);for(const e of i){const t=e.trim();if(!t||t.startsWith("#"))continue;const i=t.slice(0,t.indexOf("=")).trim(),r=this.getValue(t);if(i&&void 0!==r&&this._propertiesMap.set(i,r),t.startsWith("hips_tile_format")||t.startsWith("format")){const e=this.getValue(t)?.replace(/jpeg/gi,"jpg")??"";this._imgformats=e.split(/\s+/).filter(Boolean)}else if(t.startsWith("hips_data_range")){const e=this.getValue(t);if(e){const[t,i]=e.split(/\s+/);this._datarange.min=parseFloat(t),this._datarange.max=parseFloat(i)}}else if(t.startsWith("hips_tile_width")){const e=Number(this.getValue(t));this._tilewidth=Number.isFinite(e)?e:void 0}else if(t.startsWith("hips_order_min")){const e=Number(this.getValue(t));this._minOrder=Number.isFinite(e)?e:this._minOrder}else if(t.startsWith("hips_order")||t.startsWith("maxOrder")){const e=Number(this.getValue(t));this._maxOrder=Number.isFinite(e)?e:this._maxOrder}else if(t.startsWith("hips_frame")||t.startsWith("frame"))this._hipsFrame=this.getValue(t);else if(t.startsWith("obs_collection")||t.startsWith("label"))this._hipsName=this.getValue(t)??this._hipsName;else if(t.startsWith("em_min")){const e=Number(this.getValue(t));this._emMin=Number.isFinite(e)?e:void 0}else if(t.startsWith("em_max")){const e=Number(this.getValue(t));this._emMax=Number.isFinite(e)?e:void 0}}if(this._hipsName||console.warn(`[HiPSDescriptor] hipsName not defined in properties of ${this._hipsurl}. Defaulting to 'NONAME'.`),this._hipsFrame||(console.warn(`[HiPSDescriptor] hips_frame not defined in properties of ${this._hipsurl}. Defaulting to 'equatorial'.`),this._hipsFrame="equatorial"),this._isGalctic=this._hipsFrame.toLowerCase().includes("gal"),void 0===this._maxOrder||0===this._imgformats.length)throw new Error(`[HiPSDescriptor] Invalid properties for ${this._hipsurl}. maxOrder=${this._maxOrder}, imgFormats.length=${this._imgformats.length}`)}getValue(e){const t=e.indexOf("=");if(!(t<0))return e.slice(t+1).trim()}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}getProperty(e){return this._propertiesMap.get(e)}get surveyName(){return this._hipsName}get url(){return this._hipsurl}get maxOrder(){return this._maxOrder}get minOrder(){return this._minOrder}get imgFormats(){return this._imgformats}get hipsFrame(){return this._hipsFrame}get isGalactic(){return this._isGalctic}get emMin(){return this._emMin}get emMax(){return this._emMax}get tileWidth(){return this._tilewidth}get dataRange(){return this._datarange}}},8256(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(229),a=i(1399);t.default=class{_hips;_tileno;_baseurl;_order;_format;_maxorder;_isGalacticHips;_ready=!1;_abort=!1;_image;_textureLoaded=!1;_texture;_texurl="";_hipsShaderIndex=0;_fitsTile;_cacheTime0;_inView=!0;_amIStillInFoV_requsetID;vertexPosition=[];vertexPositionBuffer=[];vertexIndices=new Uint16Array;vertexIndexBuffer;_tileBuffer;_webgl;_visibleTileManager;constructor(e,t,i,r,s,o){this._visibleTileManager=o,this._webgl=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._format=i.format,this._baseurl=i.baseURL,this._maxorder=i.maxOrder,this._isGalacticHips=i.isGalacticHips,this._order=t,this._amIStillInFoV_requsetID=window.setInterval(()=>{this.amIStillInFoV()},5e3),this.initImage()}destroyIntervals(){window.clearInterval(this._amIStillInFoV_requsetID)}getReadyState(){return this._ready}isLoading(){return!this._ready&&!this._abort}get cacheTime0(){return this._cacheTime0}resetCacheTime0(){this._cacheTime0=void 0}setCacheTime0(){this._cacheTime0=(new Date).getTime()}initImage(){if(this._order>this._maxorder)return this._ready=!1,this._abort=!0,this.destroyIntervals(),void console.warn(`[Tile] Skipping tile request above max order: requested order ${this._order}, max order ${this._maxorder}, url ${this._baseurl}`);const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{this._ready=!1,this._abort=!0,this.destroyIntervals()},this._image.crossOrigin="anonymous",this._image.src=this._texurl}async loadFits(){try{this._fitsTile=await(0,a.loadFitsTile)(this._texurl),this._hips.observeFITSDataRange(this._fitsTile),this._ready=!0}catch(e){console.error(`[Tile] Unable to load FITS tile ${this._texurl}`,e),this._ready=!1,this._abort=!0,this.destroyIntervals()}}imageLoaded(){this._ready=!0}textureLoaded(e){e.enableProgram();const t=this._webgl;if(this._texture=t.createTexture(),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),t.bindTexture(t.TEXTURE_2D,this._texture),"fits"===this._format){const e=this._fitsTile;if(!e)throw new Error(`FITS tile data not loaded: ${this._texurl}`);t.texImage2D(t.TEXTURE_2D,0,t.R32F,e.width,e.height,0,t.RED,t.FLOAT,e.pixels),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)}else t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this._image),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this.initModelBuffer(),this._textureLoaded=!0}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=o.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,a=i.ix<<r,n=(i.ix<<r)+(1<<r),l=i.iy<<r,h=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this.setupPositionAndTexture4Quadrant2(a,a+(n-a)/2,l,l+(h-l)/2,0,c,r,i),this.setupPositionAndTexture4Quadrant2(a+(n-a)/2,n,l,l+(h-l)/2,1,c,r,i),this.setupPositionAndTexture4Quadrant2(a,a+(n-a)/2,l+(h-l)/2,h,2,c,r,i),this.setupPositionAndTexture4Quadrant2(a+(n-a)/2,n,l+(h-l)/2,h,3,c,r,i);const u=this.vertexPosition[0].length/20,d=this.computeVertexIndices(u);d.length>65535?this.vertexIndices=new Uint32Array(d):this.vertexIndices=new Uint16Array(d),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint32Array(6*e);let i=0;for(let r=0;r<e;r++){const e=i;t[6*r]=e,t[6*r+1]=e+1,t[6*r+2]=e+2,t[6*r+3]=e+2,t[6*r+4]=e+3,t[6*r+5]=e,i+=4}return t}setupPositionAndTexture4Quadrant2(e,t,i,r,s,o,a,n){const l=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const h=1/(1<<a);let c=0;for(let l=e;l<t;l++)for(let e=i;e<r;e++){const t=o.getPointsForXyfNoStep(l,e,n.face),i=e-(n.iy<<a),r=l-(n.ix<<a);this.vertexPosition[s][20*c]=t[0].x,this.vertexPosition[s][20*c+1]=t[0].y,this.vertexPosition[s][20*c+2]=t[0].z,this.vertexPosition[s][20*c+3]=h+h*i+0,this.vertexPosition[s][20*c+4]=1-(h+h*r)-0,this.vertexPosition[s][20*c+5]=t[1].x,this.vertexPosition[s][20*c+6]=t[1].y,this.vertexPosition[s][20*c+7]=t[1].z,this.vertexPosition[s][20*c+8]=h+h*i+0,this.vertexPosition[s][20*c+9]=1-h*r+0,this.vertexPosition[s][20*c+10]=t[2].x,this.vertexPosition[s][20*c+11]=t[2].y,this.vertexPosition[s][20*c+12]=t[2].z,this.vertexPosition[s][20*c+13]=h*i-0,this.vertexPosition[s][20*c+14]=1-h*r+0,this.vertexPosition[s][20*c+15]=t[3].x,this.vertexPosition[s][20*c+16]=t[3].y,this.vertexPosition[s][20*c+17]=t[3].z,this.vertexPosition[s][20*c+18]=h*i-0,this.vertexPosition[s][20*c+19]=1-(h+h*r)-0,c++}this.vertexPositionBuffer[s]=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[s]),l.bufferData(l.ARRAY_BUFFER,this.vertexPosition[s],l.STATIC_DRAW)}getFitsDataRange(){return this._hips.getFITSDisplayRange(this._fitsTile)}get inView(){return this._inView}moveToCache(){this._tileBuffer.moveTileToCache(this._tileno,this._order,this._hips),this._inView=!1,this.destroyIntervals()}amIStillInFoV(){this._textureLoaded&&(this._ready=!0),this._isGalacticHips?(this._visibleTileManager.galAncestorsMap.has(this._order)&&(this._visibleTileManager.galAncestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.galVisibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache())):(this._visibleTileManager.ancestorsMap.has(this._order)&&(this._visibleTileManager.ancestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.visibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache()))}draw(e,t,i,r,s,o,a){if(!this._ready||this._abort)return;this._textureLoaded||this.textureLoaded(a);let n=new Set([0,1,2,3]);if(e>this._order&&this._order<this._maxorder){const l=this.drawChildren(e,t,i,r,s,o,a);l&&(n=l)}const l=this._webgl;if(a.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return void console.error(`[Tile] No display range available for FITS tile ${this._texurl}`);a.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max,this._hips.fitsStretch.scaleFunctionIndex,this._hips.fitsStretch.scaleParam)}else a.setTextureDataMode(this._hipsShaderIndex,!1);const h=a.locations;l.enableVertexAttribArray(h.vertexPositionAttribute),l.enableVertexAttribArray(h.textureCoordAttribute),l.activeTexture(l.TEXTURE0+this._hipsShaderIndex),l.bindTexture(l.TEXTURE_2D,this._texture);const c=h.textureAlpha[this._hipsShaderIndex];c&&l.uniform1f(c,1),a.setLayerOpacity(this._hips.opacity),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const u=this.vertexIndices.length,d=this.vertexIndices instanceof Uint32Array?l.UNSIGNED_INT:l.UNSIGNED_SHORT;n.forEach(e=>{l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[e]),l.vertexAttribPointer(h.vertexPositionAttribute,3,l.FLOAT,!1,20,0),l.vertexAttribPointer(h.textureCoordAttribute,2,l.FLOAT,!1,20,12),l.drawElements(l.TRIANGLES,u,d,0)}),l.disableVertexAttribArray(h.vertexPositionAttribute),l.disableVertexAttribArray(h.textureCoordAttribute)}drawChildren(e,t,i,r,s,o,a){const n=new Set([0,1,2,3]),l=this._order+1;if(t.has(l)){for(let h=0;h<4;h++){const c=(this._tileno<<2)+h;if(t.get(l).includes(c)){if(!this._hips.intersectsCoverage(l,c))continue;const u=this._isGalacticHips?this._tileBuffer.getGalTile(c,l,this._hips):this._tileBuffer.getTile(c,l,this._hips);u.draw(e,t,i,r,s,o,a),u.getReadyState()&&n.delete(h)}}return n}}}},4006(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TileBuffer=void 0;const s=r(i(8256));t.TileBuffer=class{_tiles;_cachedTiles;_activeHiPS;_galTiles;_galCachedTiles;_galActiveHiPS;_cacheAliveMilliSeconds;_cleanerId;_webgl;_visibleTileManager;_hipsShaderProgram;constructor(e=1,t,i,r){this._hipsShaderProgram=i,this._visibleTileManager=r,this._webgl=t,this._tiles=new Map,this._cachedTiles=new Map,this._activeHiPS=new Map,this._galTiles=new Map,this._galCachedTiles=new Map,this._galActiveHiPS=new Map,this._cacheAliveMilliSeconds=60*e*1e3,this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4)}addHiPS(e){this._activeHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._activeHiPS.set(e,new Map)}addGalHiPS(e){this._galActiveHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._galActiveHiPS.set(e,new Map)}addTile(e,t){for(const i of this._activeHiPS.keys())e>i.maxOrder||i.intersectsCoverage(e,t)&&this.getTile(t,e,i)}addGalTile(e,t){for(const i of this._galActiveHiPS.keys())e>i.maxOrder||i.intersectsCoverage(e,t)&&this.getGalTile(t,e,i)}getTile(e,t,i){const r=this.key(t,e,i);if(!this._tiles.has(r))if(this._cachedTiles.has(r)){const e=this._cachedTiles.get(r);this._tiles.set(r,e),this._cachedTiles.delete(r),e.resetCacheTime0()}else{const o=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._tiles.set(r,o)}return this._tiles.get(r)}getGalTile(e,t,i){const r=this.key(t,e,i);if(!this._galTiles.has(r))if(this._galCachedTiles.has(r)){const e=this._galCachedTiles.get(r);this._galTiles.set(r,e),this._galCachedTiles.delete(r),e.resetCacheTime0()}else{const o=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._galTiles.set(r,o)}return this._galTiles.get(r)}moveTileToCache(e,t,i){const r=this.key(t,e,i);if(this._tiles.has(r)){const e=this._tiles.get(r);e.setCacheTime0(),this._cachedTiles.set(r,e),this._tiles.delete(r)}if(this._galTiles.has(r)){const e=this._galTiles.get(r);e.setCacheTime0(),this._galCachedTiles.set(r,e),this._galTiles.delete(r)}}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._cachedTiles.delete(t))}for(const[t,i]of this._galCachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._galCachedTiles.delete(t))}}key(e,t,i){return`${e}#${t}#${i.baseURL}#${i.format}`}removeHiPS(e){this.invalidateHiPS(e),this._activeHiPS.delete(e),this._galActiveHiPS.delete(e)}invalidateHiPS(e){const t=t=>t.includes(`#${e.baseURL}#`),i=e=>{for(const[i,r]of e)t(i)&&(r.destroyIntervals(),e.delete(i))};i(this._tiles),i(this._cachedTiles),i(this._galTiles),i(this._galCachedTiles)}dispose(){window.clearInterval(this._cleanerId)}get size(){return this._tiles.size+this._cachedTiles.size+this._galTiles.size+this._galCachedTiles.size}get activeTileCount(){return this._tiles.size+this._galTiles.size}get cachedTileCount(){return this._cachedTiles.size+this._galCachedTiles.size}get readyTileCount(){let e=0;for(const t of this._tiles.values())t.getReadyState()&&e++;for(const t of this._galTiles.values())t.getReadyState()&&e++;for(const t of this._cachedTiles.values())t.getReadyState()&&e++;for(const t of this._galCachedTiles.values())t.getReadyState()&&e++;return e}get loadingTileCount(){let e=0;for(const t of this._tiles.values())t.isLoading()&&e++;for(const t of this._galTiles.values())t.isLoading()&&e++;for(const t of this._cachedTiles.values())t.isLoading()&&e++;for(const t of this._galCachedTiles.values())t.isLoading()&&e++;return e}}},2056(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VisibleTilesManager=void 0;const s=r(i(4382)),o=i(4851),a=r(i(4639)),n=i(4006),l=i(3890),h=i(2919);t.VisibleTilesManager=class{_visibleTilesByOrder;_ancestorsMap;initialised;_galVisibleTilesByOrder;_galAncestorsMap;_galacticMatrixInverted;_galacticMatrix;insideSphere=h.bootSetup.insideSphere;_tileBuffer;_healpixGrid;_webgl;constructor(e,t,i){this._webgl=e,this._healpixGrid=i,this._visibleTilesByOrder={pixels:[],order:0},this._ancestorsMap=new Map,this.initialised=!1,this._galVisibleTilesByOrder={pixels:[],order:0},this._galAncestorsMap=new Map,this._galacticMatrixInverted=l.mat4.create(),this._galacticMatrix=l.mat4.create(),l.mat4.set(this._galacticMatrixInverted,-.054876,-.873437,-.483835,0,.494109,-.44483,.746982,-0,-.867666,-.198076,.455984,0,0,0,0,1),l.mat4.invert(this._galacticMatrix,this._galacticMatrixInverted),this._tileBuffer=new n.TileBuffer(1,e,t,this)}get healpixGrid(){return this._healpixGrid}get tileBuffer(){return this._tileBuffer}init(e){this.initialised=!0,this.insideSphere=e}getVisibleOrder(){return this._healpixGrid.visibleorder}computeVisiblePixels(e,t,i,r){if(!this.initialised)return;s.default.insideSphere&&e<3&&(e=3),this._ancestorsMap.set(e,[]),this._galAncestorsMap.set(e,[]);let n=[],h=[];if(0===e){const t=s.default.getHealpix(0).getNPix();for(let i=0;i<t;i++)n.push(i),this._ancestorsMap.get(e).push(i),h.push(i),this._galAncestorsMap.get(e).push(i)}else{const c=s.default.getHealpix(e),u=t.canvas.width,d=t.canvas.height;for(let t=0;t<=u;t+=u/30)for(let s=0;s<=d;s+=d/30){const u=a.default.getIntersectionPointWithSingleModel(t,s,this._healpixGrid,this._webgl,i,r);if(u.length>0){const t=l.vec4.create();l.vec4.transformMat4(t,[u[0],u[1],u[2],1],this._galacticMatrix);const i=new o.Pointing(new o.Vec3(t[0],t[1],t[2])),r=c.ang2pix(i),s=new o.Pointing(new o.Vec3(u[0],u[1],u[2])),a=c.ang2pix(s);n.includes(a)||(n.push(a),this._ancestorsMap.get(e).push(a),this._tileBuffer.addTile(e,a)),h.includes(r)||(h.push(r),this._galAncestorsMap.get(e).push(r),this._tileBuffer.addGalTile(e,r))}}}this._visibleTilesByOrder={pixels:n,order:e},this._galVisibleTilesByOrder={pixels:h,order:e};for(let t=1;t<e;t++){const i=e-t,r=this._ancestorsMap.get(i)??[];this._ancestorsMap.set(i,r);for(let e=0;e<n.length;e++){const s=n[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addTile(i,s))}}for(let t=1;t<e;t++){const i=e-t,r=this._galAncestorsMap.get(i)??[];this._galAncestorsMap.set(i,r);for(let e=0;e<h.length;e++){const s=h[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addGalTile(i,s))}}}get visibleTilesByOrder(){return this._visibleTilesByOrder}get ancestorsMap(){return this._ancestorsMap}get galVisibleTilesByOrder(){return this._galVisibleTilesByOrder}get galAncestorsMap(){return this._galAncestorsMap}get visibleOrder(){return this._visibleTilesByOrder.order}}},6878(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPS=void 0;const r=i(4735),s=i(229),o=i(2257),a=i(8170);class n extends r.AbstractSkyEntity{_descriptor;_healpixGrid;_shaderProgram;_tiles=new Map;_currentOrder;_visibleTiles=[];_coverageTiles=[];constructor(e,t,i,r,s,a,n){super(e,t,i,r,s.name,a,!1),this._descriptor=s,this._healpixGrid=n,this.initGL(a),this._shaderProgram=new o.MeshHiPSShaderProgram(a),this._shaderProgram.enableProgram(),this._currentOrder=s.selectedOrder}get currentOrder(){return this._currentOrder}get maxOrder(){return this._descriptor.maxOrder}get minOrder(){return this._descriptor.minOrder}get baseURL(){return this._descriptor.baseUrl}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}getProperty(e){return this._descriptor.getProperty(e)}refreshOrder(e){if(this._descriptor.fixedOrder)return this._currentOrder=this._descriptor.selectedOrder,this._currentOrder;const t=Number.isFinite(e)&&e>0?e:this._healpixGrid.getMinFoV(),i=Number.isFinite(t)&&t>0?t:1e-6,r=s.fovHelper.getHiPSNorder(i,this._currentOrder);return this._currentOrder=Math.max(this._descriptor.minOrder,Math.min(this._descriptor.maxOrder,r)),this._currentOrder}draw(e){const t=e.camera.getCameraMatrix();if(!t||!e.pMatrix)return;this.refreshOrder(e.fovDeg),this._visibleTiles=this.resolveVisibleTiles(),this._coverageTiles=this.resolveCoverageTiles(this._visibleTiles),this.ensureTiles(this._coverageTiles),this.evictCached();const i=this._webgl,r=e.pMatrix,s=this.getModelMatrix(),o=i.isEnabled(i.CULL_FACE),a=i.isEnabled(i.DEPTH_TEST),n=i.getParameter(i.DEPTH_WRITEMASK),l=i.getParameter(i.DEPTH_FUNC);i.enable(i.DEPTH_TEST),i.depthMask(!0),i.depthFunc(i.LEQUAL),i.disable(i.CULL_FACE);const h=this.groupTilesByOrder(this._coverageTiles),c=Array.from(h.keys()).sort((e,t)=>e-t);for(const e of c)for(const i of h.get(e)??[])this._tiles.get(this.tileKey(i))?.draw(r,t,s,this._descriptor.color,this._descriptor.wireframe);o&&i.enable(i.CULL_FACE),a||i.disable(i.DEPTH_TEST),i.depthFunc(l),i.depthMask(n)}getDebugStats(){const e=Array.from(this._tiles.values());return{activeBaseLayer:"meships",meshHiPSName:this._descriptor.name,meshHiPSUrl:this._descriptor.baseUrl,currentOrder:this._currentOrder,visibleTileCount:this._visibleTiles.length,coverageTileCount:this._coverageTiles.length,cacheSize:this._tiles.size,readyTileCount:e.filter(e=>e.ready).length,loadingTileCount:e.filter(e=>e.loading).length,failedTileCount:e.filter(e=>e.failed).length}}resolveVisibleTiles(){const e=this._healpixGrid.visibleTilesManager,t=e?.visibleTilesByOrder,i=t?.order===this._currentOrder&&Array.isArray(t.pixels)?t.pixels:[];if(i.length>0)return i.map(e=>({order:this._currentOrder,ipix:e}));const r=12*4**this._currentOrder;return Array.from({length:r},(e,t)=>({order:this._currentOrder,ipix:t}))}resolveCoverageTiles(e){const t=new Map,i=e=>{e.order<this._descriptor.minOrder||e.order>this._descriptor.maxOrder||t.set(this.tileKey(e),e)};for(const t of e){i(t);for(let e=t.order-1;e>=this._descriptor.minOrder;e--){const r=2*(t.order-e);i({order:e,ipix:t.ipix>>r})}}const r=this._healpixGrid.visibleTilesManager,s=r?.ancestorsMap;if(s)for(const[e,t]of s)if(!(e<this._descriptor.minOrder||e>this._descriptor.maxOrder))for(const r of t)i({order:e,ipix:r});return Array.from(t.values())}groupTilesByOrder(e){const t=new Map;for(const i of e){const e=t.get(i.order)??[];e.push(i),t.set(i.order,e)}return t}ensureTiles(e){for(const t of e){const e=this.tileKey(t);this._tiles.has(e)||this._tiles.set(e,new a.MeshHiPSTile(t,this._descriptor.getTileUrl(t.order,t.ipix),this._webgl,this._shaderProgram))}}evictCached(){const e=this._descriptor.maxCachedTiles;if(this._tiles.size<=e)return;const t=new Set(this._coverageTiles.map(e=>this.tileKey(e))),i=Array.from(this._tiles.entries()).filter(([e])=>!t.has(e)).sort((e,t)=>e[1].lastUsedAt-t[1].lastUsedAt);for(;this._tiles.size>e&&i.length>0;){const[e,t]=i.shift();t.dispose(),this._tiles.delete(e)}}tileKey(e){return`${e.order}/${e.ipix}`}}t.MeshHiPS=n},847(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSDescriptor=void 0;t.MeshHiPSDescriptor=class{_name="MeshHiPS";_baseUrl;_minOrder=0;_maxOrder=0;_selectedOrder;_fixedOrder=!1;_maxCachedTiles=384;_color=[.32,.34,.36,1];_wireframe=!1;_propertiesRawText="";_propertiesMap=new Map;_meshRadius=null;constructor(e,t=""){if(this._baseUrl=this.normalizeBaseUrl(e.baseUrl),this._propertiesRawText=t,this.parseProperties(t),this._name=e.name??this._propertiesMap.get("obs_collection")??this._propertiesMap.get("label")??this._name,this._minOrder=e.minOrder??this.readNumber("hips_order_min",this._minOrder),this._maxOrder=e.maxOrder??this.readNumber("hips_order",this.readNumber("hips_order_max",this._maxOrder)),this._fixedOrder=void 0!==e.order,this._selectedOrder=e.order??this._minOrder,this._maxCachedTiles=e.maxCachedTiles??this._maxCachedTiles,e.color)this._color=e.color;else if(this._propertiesMap.has("mesh_color")){const e=(this._propertiesMap.get("mesh_color")||"").split(/[,\s]+/).map(e=>Number(e)).filter(Number.isFinite);if(e.length>=3){let[t,i,r,s]=e;(t>1||i>1||r>1)&&(t/=255,i/=255,r/=255),Number.isFinite(s)||(s=1),this._color=[t,i,r,s]}}else this._color=this._color;if(this._wireframe=e.wireframe??this._wireframe,this._selectedOrder=this.clampOrder(this._selectedOrder),Number.isFinite(e.meshRadius))this._meshRadius=e.meshRadius;else{const e=this.readNumber("mesh_radius",NaN);if(!Number.isFinite(e))throw new Error('Missing mandatory property "mesh_radius" in MeshHiPS properties');this._meshRadius=e}}get name(){return this._name}get baseUrl(){return this._baseUrl}get minOrder(){return this._minOrder}get maxOrder(){return this._maxOrder}get selectedOrder(){return this._selectedOrder}get fixedOrder(){return this._fixedOrder}get maxCachedTiles(){return this._maxCachedTiles}get color(){return this._color}get wireframe(){return this._wireframe}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}get meshRadius(){return this._meshRadius}getProperty(e){return this._propertiesMap.get(e)}getTileUrl(e,t){const i=1e4*Math.floor(t/1e4);return`${this._baseUrl}Norder${e}/Dir${i}/Npix${t}.obj`}parseProperties(e){const t=e.split(/\r\n|\n/);for(const e of t){const t=e.trim();if(!t||t.startsWith("#"))continue;const i=t.indexOf("=");i<0||this._propertiesMap.set(t.slice(0,i).trim(),t.slice(i+1).trim())}}readNumber(e,t){const i=Number(this._propertiesMap.get(e));return Number.isFinite(i)?i:t}clampOrder(e){return Math.max(this._minOrder,Math.min(this._maxOrder,e))}normalizeBaseUrl(e){return e.endsWith("/")?e:`${e}/`}}},8170(e,t,i){"use strict";t.MeshHiPSTile=void 0;const r=i(4322);t.MeshHiPSTile=class{coord;_url;_webgl;_shaderProgram;_gpuMesh=null;_ready=!1;_loading=!1;_failed=!1;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,i,r){this.coord=e,this._url=t,this._webgl=i,this._shaderProgram=r,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}draw(e,t,i,r,s){if(this.touch(),!this._ready||!this._gpuMesh)return!1;const o=this._webgl;return this._shaderProgram.enableShaders(e,t,i,r),o.bindBuffer(o.ARRAY_BUFFER,this._gpuMesh.positionBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(o.bindBuffer(o.ARRAY_BUFFER,this._gpuMesh.normalBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,s?this._gpuMesh.lineIndexBuffer:this._gpuMesh.indexBuffer),o.drawElements(s?o.LINES:o.TRIANGLES,s?this._gpuMesh.lineIndexCount:this._gpuMesh.indexCount,this._gpuMesh.indexType,0),o.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&o.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),!0}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._url);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._url}`);const t=r.OBJMeshParser.parse(await e.text());this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[MeshHiPSTile] load failed",this._url,e),this._failed=!0,this._ready=!1}finally{this._loading=!1}}}uploadMesh(e){const t=this._webgl,i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer(),o=t.createBuffer();if(!(i&&r&&s&&o))throw new Error(`Could not create MeshHiPS buffers for ${this.key}`);const a=this.buildLineIndices(e.indices);return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o),t.bufferData(t.ELEMENT_ARRAY_BUFFER,a,t.STATIC_DRAW),{positionBuffer:i,normalBuffer:r,indexBuffer:s,lineIndexBuffer:o,indexCount:e.indices.length,lineIndexCount:a.length,indexType:t.UNSIGNED_INT}}buildLineIndices(e){const t=new Uint32Array(2*e.length);let i=0;for(let r=0;r<e.length;r+=3){const s=e[r],o=e[r+1],a=e[r+2];t[i++]=s,t[i++]=o,t[i++]=o,t[i++]=a,t[i++]=a,t[i++]=s}return t}get key(){return`${this.coord.order}/${this.coord.ipix}`}}},4322(e,t){"use strict";t.OBJMeshParser=void 0;class i{static parse(e,t={}){const r=t.preferFileNormals??!0,s=t.generatedNormals??"smooth",o=[],a=[],n=[],l=e.split(/\r\n|\n/);for(const e of l){const t=e.trim();if(t&&!t.startsWith("#")){if(t.startsWith("v ")){const e=t.split(/\s+/);if(e.length<4)continue;const i=Number(e[1]),r=Number(e[2]),s=Number(e[3]);if(![i,r,s].every(Number.isFinite))continue;o.push(i,r,s);continue}if(t.startsWith("vn ")){const e=t.split(/\s+/);if(e.length<4)continue;const i=Number(e[1]),r=Number(e[2]),s=Number(e[3]);if(![i,r,s].every(Number.isFinite))continue;const o=Math.hypot(i,r,s)||1;a.push(i/o,r/o,s/o);continue}if(t.startsWith("f ")){const e=t.slice(2).trim().split(/\s+/).map(e=>i.parseFaceToken(e,o.length/3,a.length/3)).filter(e=>null!==e);e.length>=3&&n.push(e)}}}const h=i.triangulateFaces(n);return r&&h.length>0&&h.every(e=>void 0!==e.normalIndex)?i.buildMeshWithFileNormals(o,a,h):"flat"===s?i.buildMeshWithFlatNormals(o,h):i.buildMeshWithSmoothNormals(o,h)}static parseFaceToken(e,t,r){const s=e.split("/"),o=i.parseIndex(s[0],t);if(null===o)return null;const a=s.length>=3?s[2]:void 0;return{positionIndex:o,normalIndex:(a?i.parseIndex(a,r):null)??void 0}}static parseIndex(e,t){if(!e)return null;const i=Number(e);if(!Number.isInteger(i)||0===i)return null;const r=i>0?i-1:t+i;return r>=0&&r<t?r:null}static triangulateFaces(e){const t=[];for(const i of e){const e=i[0];for(let r=1;r<i.length-1;r++)t.push(e,i[r],i[r+1])}return t}static buildMeshWithFileNormals(e,t,i){const r=[],s=[],o=[],a=new Map;for(const n of i){const i=n.normalIndex,l=`${n.positionIndex}/${i}`;let h=a.get(l);void 0===h&&(h=r.length/3,a.set(l,h),r.push(e[3*n.positionIndex],e[3*n.positionIndex+1],e[3*n.positionIndex+2]),s.push(t[3*i],t[3*i+1],t[3*i+2])),o.push(h)}return{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static buildMeshWithSmoothNormals(e,t){const r=[...e],s=new Array(r.length).fill(0),o=t.map(e=>e.positionIndex);return i.computeVertexNormals(r,o,s),{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static buildMeshWithFlatNormals(e,t){const r=[],s=[],o=[];for(let a=0;a<t.length;a+=3){const n=t[a],l=t[a+1],h=t[a+2];if(!n||!l||!h)continue;const c=i.computeFaceNormal(e,n.positionIndex,l.positionIndex,h.positionIndex);for(const t of[n,l,h])r.push(e[3*t.positionIndex],e[3*t.positionIndex+1],e[3*t.positionIndex+2]),s.push(c[0],c[1],c[2]),o.push(o.length)}return{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static computeVertexNormals(e,t,r){for(let s=0;s<t.length;s+=3){const o=t[s],a=t[s+1],n=t[s+2],l=i.computeRawFaceNormal(e,o,a,n);r[3*o]+=l[0],r[3*o+1]+=l[1],r[3*o+2]+=l[2],r[3*a]+=l[0],r[3*a+1]+=l[1],r[3*a+2]+=l[2],r[3*n]+=l[0],r[3*n+1]+=l[1],r[3*n+2]+=l[2]}for(let e=0;e<r.length;e+=3){const t=r[e],i=r[e+1],s=r[e+2],o=Math.hypot(t,i,s)||1;r[e]=t/o,r[e+1]=i/o,r[e+2]=s/o}}static computeFaceNormal(e,t,r,s){const[o,a,n]=i.computeRawFaceNormal(e,t,r,s),l=Math.hypot(o,a,n)||1;return[o/l,a/l,n/l]}static computeRawFaceNormal(e,t,i,r){const s=e[3*t],o=e[3*t+1],a=e[3*t+2],n=e[3*i]-s,l=e[3*i+1]-o,h=e[3*i+2]-a,c=e[3*r]-s,u=e[3*r+1]-o,d=e[3*r+2]-a;return[l*d-h*u,h*c-n*d,n*u-l*c]}}t.OBJMeshParser=i},8022(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackTimeline=void 0,t.createObservationTrackTimeline=function(e){return new i(e)},t.footprintToRing=s;class i{samples;startMs;endMs;currentMs;playing=!1;rafId=null;lastFrameNowMs=null;playbackRate;onFrame;onStop;constructor(e){if(this.samples=e.samples.map((e,t)=>({...e,index:t,timeMs:Date.parse(String(e.timestamp))})).filter(e=>Number.isFinite(e.timeMs)).sort((e,t)=>e.timeMs-t.timeMs),0===this.samples.length)throw new Error("ObservationTrackTimeline requires at least one timestamped sample.");this.startMs=this.samples[0].timeMs,this.endMs=this.samples[this.samples.length-1].timeMs,this.currentMs=this.startMs,this.playbackRate=e.playbackRate??1,this.onFrame=e.onFrame,this.onStop=e.onStop,this.emitFrame()}play(){this.playing||(this.playing=!0,this.lastFrameNowMs=null,this.rafId=requestAnimationFrame(e=>this.tick(e)))}pause(){this.playing&&(this.playing=!1,this.cancelPendingFrame(),this.onStop?.(this.getState()))}seek(e){const t=c(e);this.currentMs=this.startMs+(this.endMs-this.startMs)*t,this.emitFrame()}destroy(){this.playing=!1,this.cancelPendingFrame(),this.onStop?.(this.getState())}getState(){return{startMs:this.startMs,endMs:this.endMs,currentMs:this.currentMs,progress01:this.getProgress(),playing:this.playing}}tick(e){if(!this.playing)return;null===this.lastFrameNowMs&&(this.lastFrameNowMs=e);const t=e-this.lastFrameNowMs;if(this.lastFrameNowMs=e,this.currentMs+=t*this.playbackRate,this.currentMs>=this.endMs)return this.currentMs=this.endMs,this.emitFrame(),void this.pause();this.emitFrame(),this.rafId=requestAnimationFrame(e=>this.tick(e))}emitFrame(){const e=function(e,t){const i=e[0],s=e[e.length-1];if(t<=i.timeMs)return r(i,i,0);if(t>=s.timeMs)return r(s,s,0);for(let i=0;i<e.length-1;i++){const s=e[i],o=e[i+1];if(t>=s.timeMs&&t<=o.timeMs){return r(s,o,(t-s.timeMs)/(o.timeMs-s.timeMs))}}return r(s,s,0)}(this.samples,this.currentMs);this.onFrame?.({currentMs:this.currentMs,progress01:this.getProgress(),...e})}getProgress(){return this.endMs===this.startMs?0:c((this.currentMs-this.startMs)/(this.endMs-this.startMs))}cancelPendingFrame(){null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}function r(e,t,i){const r=function(e,t,i){const r=e.groundTrackPoint,s=t.groundTrackPoint,o=h(e.timeMs,t.timeMs,i);return{timestamp:new Date(o).toISOString(),longitudeDeg:n(r.longitudeDeg,s.longitudeDeg,i),latitudeDeg:h(r.latitudeDeg,s.latitudeDeg,i),altitudeKm:h(r.altitudeKm,s.altitudeKm,i)}}(e,t,i),l=i<.5?e:t,c=function(e,t,i,r){const l=o(s(e)),c=o(s(t));if(l.length<3||l.length!==c.length)return r;const u=l.map(([e,t],r)=>{const[s,o]=c[r];return[n(e,s,i),h(t,o,i)]});return function(e){if(0===e.length)return e;const t=e[0],i=e[e.length-1];return a(t,i)?e:[...e,[...t]]}(u)}(e.footprint,t.footprint,i,s(l.footprint));return{markerPoint:r,currentGroundPoint:r,currentFootprint:c,interpolationT:i,previousSample:e,nextSample:t,nearestSample:l,nearestSampleIndex:l.index}}function s(e){if(function(e){return!Array.isArray(e)&&"coordinates"in e}(e))return e.coordinates.map(e=>[e.longitudeDeg,e.latitudeDeg]);if(function(e){return!Array.isArray(e)&&"polygons"in e}(e)){const t=e.polygons[0];return t?s(t):[]}return Array.isArray(e)?e:[]}function o(e){if(!Array.isArray(e))return[];const t=[];for(const i of e){if(!Array.isArray(i)||i.length<2)return[];const e=Number(i[0]),r=Number(i[1]);if(!Number.isFinite(e)||!Number.isFinite(r)||r<-90||r>90)return[];t.push([l(e),r])}for(;t.length>1&&a(t[0],t[t.length-1]);)t.pop();return t}function a(e,t){return Math.abs(e[0]-t[0])<1e-9&&Math.abs(e[1]-t[1])<1e-9}function n(e,t,i){const r=l(t-e);return l(e+r*i)}function l(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}function h(e,t,i){return e+(t-e)*i}function c(e){return Math.max(0,Math.min(1,Number.isFinite(e)?e:0))}t.ObservationTrackTimeline=i},5772(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackViewerAdapter=void 0;const s=r(i(8755)),o=i(1072),a=i(5403),n=i(8022),l={showSatelliteModel:!0,showGroundTrack:!0,showFootprint:!0,showSensorCone:!0,showCurrentFootprintOnly:!1,showAllFootprints:!0},h={groundTrack:"#ffe066",footprints:"#00fff2",currentFootprint:"#ff4d4d",marker:"#ff4d4d",satelliteObject:[1,.84,.22,1],sensorCone:[0,1,.95,.68],target:"#ffb347"};t.ObservationTrackViewerAdapter=class{activeHandle=null;viewer;metadataManagerFactory;colors;onFrame;constructor(e){this.viewer=e.viewer,this.metadataManagerFactory=e.metadataManagerFactory??(()=>new a.MetadataManager([])),this.colors={...h,...e.colors},this.onFrame=e.onFrame}load(e){this.clear();const t=new c(this.viewer,e,this.metadataManagerFactory,this.colors,this.onFrame);return this.activeHandle=t,t}clear(){this.activeHandle?.dispose(),this.activeHandle=null}};class c{viewer;track;metadataManagerFactory;colors;onFrame;timeline;objects={target:null,groundTrack:null,footprints:null,currentFootprint:null,marker:null,satelliteObject:null,sensorCone:null};visualisation;currentFootprintIndex=-1;disposed=!1;constructor(e,t,i,r,s){this.viewer=e,this.track=t,this.metadataManagerFactory=i,this.colors=r,this.onFrame=s,function(e){if(!e.samples||0===e.samples.length)throw new Error("ObservationTrackViewerAdapter requires at least one sample.")}(t),this.visualisation={...l,...t.visualisation},this.createStaticObjects(),this.timeline=(0,n.createObservationTrackTimeline)({samples:t.samples,playbackRate:1,onFrame:e=>this.updateFrame(e)}),this.applyVisualisation()}play(){this.timeline.play()}pause(){this.timeline.pause()}seek(e){this.timeline.seek(e)}setVisualisation(e){this.visualisation={...this.visualisation,...e},this.applyVisualisation()}dispose(){this.disposed||(this.disposed=!0,this.timeline.destroy(),this.deleteObjects())}createStaticObjects(){this.objects.target=this.createTargetOverlay(),this.objects.footprints=this.createAllFootprintsOverlay(),this.objects.groundTrack=this.createGroundTrackOverlay(),this.objects.marker=this.createMarkerOverlay(),this.objects.satelliteObject=this.createSatelliteObject(),this.objects.sensorCone=this.createSensorCone()}createTargetOverlay(){const e=this.track.target?.geojson;if(!e)return null;const t=this.viewer.createTerraFootprintSet(this.track.target?.name??"Observation target","ObservationTrack target GeoJSON",this.track.target?.geojsonUrl??"ObservationTrack",this.metadataManagerFactory());return t.addGeoJSONFeatures(s.default.parseGeoJSON(e)),this.viewer.changeFootprintSetColor(t,this.colors.target),this.viewer.showTerraFootprintSet(t),t}createAllFootprintsOverlay(){const e={type:"FeatureCollection",features:this.track.samples.map((e,t)=>u(e,t))},t=this.viewer.createTerraFootprintSet(`${this.track.satellite?.name??"Satellite"} footprints`,"ObservationTrack sampled sensor footprints",this.track.id??"ObservationTrack",this.metadataManagerFactory());return t.addGeoJSONFeatures(s.default.parseGeoJSON(e)),this.viewer.changeFootprintSetColor(t,this.colors.footprints),this.viewer.showTerraFootprintSet(t),t}createGroundTrackOverlay(){const e=this.viewer.createTerraPolylineSet(`${this.track.satellite?.name??"Satellite"} ground track`,"ObservationTrack GroundTrackPoint[]",this.track.id??"ObservationTrack",this.metadataManagerFactory());return e.addGroundTrack(this.track.samples.map(e=>({...e.groundTrackPoint,timestamp:e.timestamp})),{name:`${this.track.satellite?.name??"Satellite"} ground track`}),this.viewer.changeTerraPolylineSetColor(e,this.colors.groundTrack),this.viewer.showTerraPolylineSet(e),e}createMarkerOverlay(){const e=this.viewer.createTerraPointSet(`${this.track.satellite?.name??"Satellite"} marker`,"ObservationTrack interpolated satellite marker",this.track.id??"ObservationTrack",new a.MetadataManager(_()));return this.viewer.changeCatalogueColor(e,this.colors.marker),this.viewer.showTerraPointSet(e),e}createSatelliteObject(){const e=this.track.satellite?.model?.objUrl;if(!e)return null;const t=this.viewer.createSatelliteObject({name:`${this.track.satellite?.name??"Satellite"} object`,objUrl:e,color:this.colors.satelliteObject,scale:this.track.satellite?.model?.visualScale});return this.viewer.showSatelliteObject(t),t}createSensorCone(){const e=this.viewer.createSensorCone({name:`${this.track.sensor?.name??"Sensor"} cone`,color:this.colors.sensorCone,wireframe:!0,filled:!1});return this.viewer.showSensorCone(e),e}updateFrame(e){this.disposed||(this.updateMarker(e.currentGroundPoint),this.updateSatelliteObject(e),this.updateSensorCone(e),this.updateCurrentFootprint(e),this.onFrame?.(e))}updateMarker(e){const t=this.objects.marker;t&&(t.clearSources(),t.addSources([[e.longitudeDeg,e.latitudeDeg,String(e.timestamp??""),e.altitudeKm]],_()))}updateSatelliteObject(e){const t=this.objects.satelliteObject;t&&t.setPosition(e.currentGroundPoint,e.previousSample?.groundTrackPoint??null,e.nextSample?.groundTrackPoint??null)}updateSensorCone(e){const t=this.objects.sensorCone;t&&t.setGeometry(e.currentGroundPoint,e.currentFootprint)}updateCurrentFootprint(e){e.nearestSampleIndex!==this.currentFootprintIndex&&(this.objects.currentFootprint&&this.viewer.deleteTerraFootprintSet(this.objects.currentFootprint),this.objects.currentFootprint=this.createCurrentFootprintOverlay(e.nearestSample),this.currentFootprintIndex=e.nearestSampleIndex,this.applyVisualisation())}createCurrentFootprintOverlay(e){const t={type:"FeatureCollection",features:[u(e,e.index,"Current footprint")]},i=this.viewer.createTerraFootprintSet(`${this.track.satellite?.name??"Satellite"} current footprint`,"ObservationTrack nearest sampled footprint",this.track.id??"ObservationTrack",this.metadataManagerFactory());return i.addGeoJSONFeatures(s.default.parseGeoJSON(t)),this.viewer.changeFootprintSetColor(i,this.colors.currentFootprint),this.viewer.showTerraFootprintSet(i),i}applyVisualisation(){const e=Boolean(this.visualisation.showFootprint),t=e&&Boolean(this.visualisation.showAllFootprints)&&!this.visualisation.showCurrentFootprintOnly,i=e&&(Boolean(this.visualisation.showCurrentFootprintOnly)||!t);this.objects.target&&this.viewer.hideTerraFootprintSet(this.objects.target,!0),this.objects.groundTrack&&this.viewer.hideTerraPolylineSet(this.objects.groundTrack,Boolean(this.visualisation.showGroundTrack)),this.objects.footprints&&this.viewer.hideTerraFootprintSet(this.objects.footprints,t),this.objects.currentFootprint&&this.viewer.hideTerraFootprintSet(this.objects.currentFootprint,i),this.objects.marker&&this.viewer.hideTerraPointSet(this.objects.marker,!0),this.objects.satelliteObject&&this.viewer.hideSatelliteObject(this.objects.satelliteObject,Boolean(this.visualisation.showSatelliteModel)),this.objects.sensorCone&&this.viewer.hideSensorCone(this.objects.sensorCone,Boolean(this.visualisation.showSensorCone))}deleteObjects(){this.objects.target&&this.viewer.deleteTerraFootprintSet(this.objects.target),this.objects.groundTrack&&this.viewer.deleteTerraPolylineSet(this.objects.groundTrack),this.objects.footprints&&this.viewer.deleteTerraFootprintSet(this.objects.footprints),this.objects.currentFootprint&&this.viewer.deleteTerraFootprintSet(this.objects.currentFootprint),this.objects.marker&&this.viewer.deleteTerraPointSet(this.objects.marker),this.objects.satelliteObject&&this.viewer.deleteSatelliteObject(this.objects.satelliteObject),this.objects.sensorCone&&this.viewer.deleteSensorCone(this.objects.sensorCone),this.objects.target=null,this.objects.groundTrack=null,this.objects.footprints=null,this.objects.currentFootprint=null,this.objects.marker=null,this.objects.satelliteObject=null,this.objects.sensorCone=null}}function u(e,t,i=`Footprint ${t+1}`){return{type:"Feature",properties:{name:i,timestamp:String(e.timestamp),intersectsTarget:String(Boolean(e.intersectsTarget??e.intersects))},geometry:d(e.footprint)}}function d(e){return!Array.isArray(e)&&"polygons"in e?{type:"MultiPolygon",coordinates:e.polygons.map(e=>[g((0,n.footprintToRing)(e))])}:{type:"Polygon",coordinates:[g((0,n.footprintToRing)(e))]}}function g(e){if(0===e.length)return e;const t=e[0],i=e[e.length-1];return Math.abs(t[0]-i[0])<1e-9&&Math.abs(t[1]-i[1])<1e-9?e:[...e,[t[0],t[1]]]}function _(){return[new o.MetadataColumn({index:0,name:"longitudeDeg",columnType:o.ColumnType.GEOM_RA,unit:"deg"}),new o.MetadataColumn({index:1,name:"latitudeDeg",columnType:o.ColumnType.GEOM_DEC,unit:"deg"}),new o.MetadataColumn({index:2,name:"timestamp",columnType:o.ColumnType.MAIN_NAME,unit:""}),new o.MetadataColumn({index:3,name:"altitudeKm",columnType:o.ColumnType.NUMBER,unit:"km"})]}},5866(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackViewerAdapter=t.ObservationTrackTimeline=t.footprintToRing=t.createObservationTrackTimeline=void 0;var r=i(8022);Object.defineProperty(t,"createObservationTrackTimeline",{enumerable:!0,get:function(){return r.createObservationTrackTimeline}}),Object.defineProperty(t,"footprintToRing",{enumerable:!0,get:function(){return r.footprintToRing}}),Object.defineProperty(t,"ObservationTrackTimeline",{enumerable:!0,get:function(){return r.ObservationTrackTimeline}});var s=i(5772);Object.defineProperty(t,"ObservationTrackViewerAdapter",{enumerable:!0,get:function(){return s.ObservationTrackViewerAdapter}})},3603(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SatelliteObjectGL=void 0;const r=i(3890),s=i(2257),o=i(4322),a=i(6553),n=i(8145);class l{_options;_webgl;static EARTH_RADIUS_KM=6371;_kind="SatelliteObjectGL";_gpuMesh=null;_shaderProgram;_modelMatrix=r.mat4.create();_isVisible=!0;_ready=!1;_loading=!1;_failed=!1;_color;_scale;constructor(e,t){this._options=e,this._webgl=t,this._shaderProgram=new s.MeshHiPSShaderProgram(this._webgl,{twoSidedLighting:!0,markerLighting:!0}),this._color=e.color??[1,.85,.25,1],this._scale=e.scale??.025,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._options.objUrl);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._options.objUrl}`);const t=o.OBJMeshParser.parse(await e.text(),{preferFileNormals:!0,generatedNormals:"flat"});this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[SatelliteObjectGL] load failed",this._options.objUrl,e),this._ready=!1,this._failed=!0}finally{this._loading=!1}}}setIsVisible(e){this._isVisible=e}setColor(e){this._color=e}setScale(e){Number.isFinite(e)&&e>0&&(this._scale=e)}setPosition(e,t,i){if(!c(e))return;const s=h(e),o=r.vec3.normalize(r.vec3.create(),s),a=this.computeForward(e,s,o,t,i),n=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),a,o));if(r.vec3.length(n)<1e-6)return void this.setFallbackMatrix(s,o);const l=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),o,n));this.setMatrixFromBasis(s,n,l,o)}draw(e,t,i){if(!this._isVisible||!this._ready||!this._gpuMesh)return;const s=this._webgl,o=r.mat4.multiply(r.mat4.create(),i,this._modelMatrix);this._shaderProgram.enableShaders(e,t,o,this._color),s.bindBuffer(s.ARRAY_BUFFER,this._gpuMesh.positionBuffer),s.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(s.bindBuffer(s.ARRAY_BUFFER,this._gpuMesh.normalBuffer),s.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this._gpuMesh.indexBuffer),s.drawElements(s.TRIANGLES,this._gpuMesh.indexCount,this._gpuMesh.indexType,0),s.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&s.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),s.bindBuffer(s.ARRAY_BUFFER,null),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,null)}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}computeForward(e,t,i,s,o){const a=s&&c(s)?h(s):null,n=o&&c(o)?h(o):null;let l=r.vec3.create();if(a&&n)r.vec3.subtract(l,n,a);else if(n)r.vec3.subtract(l,n,t);else{if(!a)return this.localEastFallback(e,i);r.vec3.subtract(l,t,a)}const u=r.vec3.scale(r.vec3.create(),i,r.vec3.dot(l,i));return r.vec3.subtract(l,l,u),r.vec3.length(l)<1e-6?this.localEastFallback(e,i):r.vec3.normalize(l,l)}localEastFallback(e,t){const i=h({...e,longitudeDeg:e.longitudeDeg+.01}),s=r.vec3.subtract(r.vec3.create(),i,h(e)),o=r.vec3.scale(r.vec3.create(),t,r.vec3.dot(s,t));return r.vec3.subtract(s,s,o),r.vec3.normalize(s,s)}setFallbackMatrix(e,t){const i=Math.abs(t[2])>.9?r.vec3.fromValues(1,0,0):r.vec3.fromValues(0,0,1),s=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),i,t)),o=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),t,s));this.setMatrixFromBasis(e,s,o,t)}setMatrixFromBasis(e,t,i,s){const o=this._scale;this._modelMatrix=r.mat4.fromValues(t[0]*o,t[1]*o,t[2]*o,0,i[0]*o,i[1]*o,i[2]*o,0,s[0]*o,s[1]*o,s[2]*o,0,e[0],e[1],e[2],1)}uploadMesh(e){const t=this._webgl,i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer();if(!i||!r||!s)throw new Error(`Could not create SatelliteObjectGL buffers for ${this._options.name}`);return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:i,normalBuffer:r,indexBuffer:s,lineIndexBuffer:null,indexCount:e.indices.length,lineIndexCount:0,indexType:t.UNSIGNED_INT}}}function h(e){const t=new a.Point({lonDeg:u(e.longitudeDeg),latDeg:e.latitudeDeg},n.CoordsType.GEOGRAPHIC),i=1+Math.max(0,e.altitudeKm??0)/l.EARTH_RADIUS_KM;return r.vec3.fromValues(t.x*i,t.y*i,t.z*i)}function c(e){return Number.isFinite(e.longitudeDeg)&&Number.isFinite(e.latitudeDeg)&&e.latitudeDeg>=-90&&e.latitudeDeg<=90}function u(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.SatelliteObjectGL=l},3102(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SensorConeGL=void 0;const r=i(8909),s=i(8145),o=i(6553);class a{_options;_webgl;static EARTH_RADIUS_KM=6371;static ELEM_SIZE=3;_kind="SensorConeGL";_lineBuffer=null;_lineVertexCount=0;_isVisible=!0;_shaderProgram;_color;constructor(e,t){this._options=e,this._webgl=t,this._shaderProgram=new r.FootprintShaderProgram(this._webgl),this._color=e.color??[0,1,.95,.68]}setGeometry(e,t){if(!h((i=e).longitudeDeg,i.latitudeDeg)||void 0!==i.altitudeKm&&!Number.isFinite(i.altitudeKm))return void this.clear();var i;const r=function(e){const t=[];for(const i of e){if(!Array.isArray(i)||i.length<2)return[];const e=Number(i[0]),r=Number(i[1]);if(!h(e,r))return[];t.push([u(e),r])}for(;t.length>1&&c(t[0],t[t.length-1]);)t.pop();const i=new Set(t.map(([e,t])=>`${e.toFixed(9)},${t.toFixed(9)}`));return i.size>=3?t:[]}(t);if(r.length<3||function(e){for(let t=0;t<e.length;t++){const i=e[t],r=e[(t+1)%e.length];if(Math.abs(u(r[0])-u(i[0]))>180)return!0}return!1}(r))return void this.clear();const s=n(e),o=r.map(([e,t])=>n({longitudeDeg:e,latitudeDeg:t,altitudeKm:0})),a=this.buildLineVertices(s,o);this.uploadLineVertices(a)}setIsVisible(e){this._isVisible=e}setColor(e){this._color=e}clear(){this._lineVertexCount=0,this._lineBuffer&&(this._webgl.deleteBuffer(this._lineBuffer),this._lineBuffer=null)}draw(e,t,i){if(!this._isVisible)return;if(!this._lineBuffer||0===this._lineVertexCount)return;const r=this._webgl,s=r.isEnabled(r.BLEND),o=r.isEnabled(r.DEPTH_TEST),n=r.isEnabled(r.CULL_FACE),l=r.getParameter(r.DEPTH_WRITEMASK),h=r.getParameter(r.DEPTH_FUNC),c=r.getParameter(r.BLEND_SRC_RGB),u=r.getParameter(r.BLEND_DST_RGB),d=r.getParameter(r.BLEND_SRC_ALPHA),g=r.getParameter(r.BLEND_DST_ALPHA);r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.enable(r.DEPTH_TEST),r.depthMask(!1),r.disable(r.CULL_FACE),this._shaderProgram.enableShaders(e,i,t),r.uniform4f(this._shaderProgram.locations.color,this._color[0],this._color[1],this._color[2],this._color[3]),r.bindBuffer(r.ARRAY_BUFFER,this._lineBuffer),r.vertexAttribPointer(this._shaderProgram.locations.position,a.ELEM_SIZE,r.FLOAT,!1,0,0),r.enableVertexAttribArray(this._shaderProgram.locations.position),r.drawArrays(r.LINES,0,this._lineVertexCount),r.disableVertexAttribArray(this._shaderProgram.locations.position),r.bindBuffer(r.ARRAY_BUFFER,null),r.depthMask(l),r.depthFunc(h),r.blendFuncSeparate(c,u,d,g),n?r.enable(r.CULL_FACE):r.disable(r.CULL_FACE),o?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),s?r.enable(r.BLEND):r.disable(r.BLEND)}dispose(){this.clear()}buildLineVertices(e,t){const i=4*t.length,r=new Float32Array(i*a.ELEM_SIZE);let s=0;for(const i of t)s=l(r,s,e),s=l(r,s,i);for(let e=0;e<t.length;e++){const i=t[e],o=t[(e+1)%t.length];s=l(r,s,i),s=l(r,s,o)}return r}uploadLineVertices(e){if(this._lineBuffer||(this._lineBuffer=this._webgl.createBuffer()),!this._lineBuffer)throw new Error(`Could not create SensorConeGL line buffer for ${this._options.name}`);this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this._lineBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,e,this._webgl.DYNAMIC_DRAW),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._lineVertexCount=e.length/a.ELEM_SIZE}}function n(e){const t=new o.Point({lonDeg:u(e.longitudeDeg),latDeg:e.latitudeDeg},s.CoordsType.GEOGRAPHIC),i=1+Math.max(0,e.altitudeKm??0)/a.EARTH_RADIUS_KM;return[t.x*i,t.y*i,t.z*i]}function l(e,t,i){return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],t+a.ELEM_SIZE}function h(e,t){return Number.isFinite(e)&&Number.isFinite(t)&&t>=-90&&t<=90}function c(e,t){return Math.abs(e[0]-t[0])<1e-9&&Math.abs(e[1]-t[1])<1e-9}function u(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.SensorConeGL=a},9022(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraFootprintSetGL=void 0;const r=i(592),s=i(8145),o=i(2475),a=i(1072),n=i(5403),l=i(1072);class h extends r.FootprintSetGL{_kind="TerraFootprintSetGL";_coordsType=s.CoordsType.GEOGRAPHIC;addGeoJSONFeatures(e){this._ready=!1,this.clearFootprints(),this._metadataManager=new n.MetadataManager(this.createGeoJSONMetadataColumns(e));for(const t of e){const e=o.Footprint.fromPolygons(t.polygons,this.createGeoJSONDetails(t),s.CoordsType.GEOGRAPHIC);e.valid&&(this.addFootprint(e),this.totPoints+=e.totPoints,this.totConvexPoints+=e.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}createGeoJSONMetadataColumns(e){const t=new Set;return e.forEach(e=>Object.keys(e.properties).forEach(e=>t.add(e))),Array.from(t).map((t,i)=>{const r=e.map(e=>e.properties[t]).filter(e=>null!=e&&""!==e),s=r.length>0&&r.every(e=>"number"==typeof e||!Number.isNaN(Number(e))),o=/^name$|nome|denominazione|label|title/i.test(t);return new a.MetadataColumn({index:i,name:t,columnType:o?l.ColumnType.MAIN_NAME:s?l.ColumnType.NUMBER:l.ColumnType.STRING,unit:""})})}createGeoJSONDetails(e){return Object.entries(e.properties).map(([e,t])=>({key:e,value:"number"==typeof t?t:String(t??"")}))}}t.TerraFootprintSetGL=h},5781(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPointSetGL=void 0;const r=i(1232);class s extends r.CatalogueGL{_kind="TerraPointSetGL"}t.TerraPointSetGL=s},3665(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPolylineSetGL=void 0;const r=i(8909),s=i(8145),o=i(7930),a=i(6553);class n{_name;_description;_providerUrl;_metadataManager;_webgl;_visibleTilesManager;static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_kind="TerraPolylineSetGL";_isVisible=!0;_ready=!0;_shapeColor="#ffe066";_bufferInitialised=!1;paths=[];renderSegments=[];_polylineShaderProgram;constructor(e,t,i,s,o,a){this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=s,this._webgl=o,this._visibleTilesManager=a,this._polylineShaderProgram=new r.FootprintShaderProgram(this._webgl)}addPath(e,t){this.paths.push({points:[...e],metadata:t}),this._ready=!0,this._bufferInitialised=!1}addGroundTrack(e,t){this.addPath(e,t)}clearPaths(){this.paths=[],this.disposeBuffers(),this.renderSegments=[],this._bufferInitialised=!1}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}changeColor(e){this._shapeColor=e}dispose(){this.disposeBuffers(),this.renderSegments=[],this.paths=[],this._bufferInitialised=!1}draw(e,t,i,r){if(!this._isVisible)return;if(!this._ready)return;if(!i)return;if(!this._webgl)return;if(this._bufferInitialised||this.initBuffers(),0===this.renderSegments.length)return;this._polylineShaderProgram.enableShaders(r,e,i);const s=(0,o.colorHex2RGB)(this._shapeColor);this._webgl.uniform4f(this._polylineShaderProgram.locations.color,s[0],s[1],s[2],1);for(const e of this.renderSegments)!e.buffer||e.vertices.length<2*n.ELEM_SIZE||(this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,e.buffer),this._webgl.vertexAttribPointer(this._polylineShaderProgram.locations.position,n.ELEM_SIZE,this._webgl.FLOAT,!1,n.BYTES_X_ELEM*n.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._polylineShaderProgram.locations.position),this._webgl.drawArrays(this._webgl.LINE_STRIP,0,e.vertices.length/n.ELEM_SIZE));this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null)}initBuffers(){this.disposeBuffers(),this.renderSegments=this.buildRenderSegments();for(const e of this.renderSegments){const t=this._webgl.createBuffer();e.buffer=t,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,t),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,e.vertices,this._webgl.STATIC_DRAW)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._bufferInitialised=!0}buildRenderSegments(){const e=[];for(const t of this.paths)for(const i of this.splitPath(t.points)){if(i.length<2)continue;const t=new Float32Array(i.length*n.ELEM_SIZE);let r=0;for(const e of i){const i=new a.Point({lonDeg:c(e.longitudeDeg),latDeg:e.latitudeDeg},s.CoordsType.GEOGRAPHIC);t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z,r+=n.ELEM_SIZE}e.push({vertices:t,buffer:null})}return e}splitPath(e){const t=[];let i=[],r=null;for(const s of e)l(s)?(r&&h(r.longitudeDeg,s.longitudeDeg)&&(i.length>1&&t.push(i),i=[]),i.push(s),r=s):(i.length>1&&t.push(i),i=[],r=null);return i.length>1&&t.push(i),t}disposeBuffers(){for(const e of this.renderSegments)e.buffer&&(this._webgl.deleteBuffer(e.buffer),e.buffer=null)}}function l(e){return Number.isFinite(e.longitudeDeg)&&Number.isFinite(e.latitudeDeg)&&e.latitudeDeg>=-90&&e.latitudeDeg<=90}function h(e,t){return Math.abs(c(t)-c(e))>180}function c(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.TerraPolylineSetGL=n},3559(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueShaderProgram=void 0;const s=i(3890),o=r(i(5947));t.CatalogueShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix"},this.gl_attributes={vertex_pos:"aCatPosition",vertex_selected:"a_selected",point_size:"a_pointsize",point_hue:"a_brightness"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,hovered:-1,pointSize:-1,brightness:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=o.default.catalogueFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=o.default.catalogueVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.hovered=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_selected),this.locations.pointSize=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_size),this.locations.brightness=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_hue),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let o=s.mat4.create();o=s.mat4.multiply(o,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,o)}}},8909(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintShaderProgram=void 0;const s=i(3890),o=r(i(5947));t.FootprintShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix",point_size:"u_pointsize"},this.gl_attributes={vertex_pos:"aCatPosition"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,pointSize:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=o.default.footprintFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=o.default.footprintVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.pointSize=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.point_size),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let o=s.mat4.create();o=s.mat4.multiply(o,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,o)}}},4707(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{static healpixGridVS(){return"#version 300 es\n in vec4 aCatPosition;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = 7.0;\n }"}static healpixGridFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n // fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n fragColor = u_fragcolor;\n }"}}},7786(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSShaderProgram=void 0;const s=r(i(5947)),o=i(619);t.HiPSShaderProgram=class{_colorMapBlockIndex=null;_runtimeColorMap;_shaderProgram;_vertexShader;_fragmentShader;_UBO_colorMapBuffer=null;_UBO_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={sampler:"uSampler0",factor:"uFactor0",m_perspective:"uPMatrix",m_model:"uMMatrix",m_view:"uVMatrix",colormapIdx:"cmapIdx",colormap_red:"r",colormap_green:"g",colormap_blue:"b",textureMode:"uTextureMode",dataMin:"uDataMin",dataMax:"uDataMax",scaleFunction:"uScaleFunction",scaleParam:"uScaleParam"},this.gl_attributes={vertex_pos:"aVertexPosition",text_coords:"aTextureCoord"},this.locations={pMatrix:null,mMatrix:null,vMatrix:null,samplers:new Array(8).fill(null),textureAlpha:new Array(8).fill(null),textureMode:new Array(8).fill(null),dataMin:new Array(8).fill(null),dataMax:new Array(8).fill(null),scaleFunction:new Array(8).fill(null),scaleParam:new Array(8).fill(null),layerOpacity:null,clorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();this._shaderProgram=t,this.initShaders(t)}return e.useProgram(this._shaderProgram),this._shaderProgram}setLayerOpacity(e){const t=this._webgl;this.locations.layerOpacity=t.getUniformLocation(this.shaderProgram,"uLayerOpacity"),null!==this.locations.layerOpacity&&t.uniform1f(this.locations.layerOpacity,e)}setRuntimeColorMap(e){this._runtimeColorMap=e}initShaders(e){const t=this._webgl,i=s.default.hipsNativeFS();if(this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,i),t.compileShader(this._fragmentShader),!t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS))return void alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=s.default.hipsVS();this._vertexShader=t.createShader(t.VERTEX_SHADER),t.shaderSource(this._vertexShader,r),t.compileShader(this._vertexShader),t.getShaderParameter(this._vertexShader,t.COMPILE_STATUS)?(t.attachShader(e,this._vertexShader),t.attachShader(e,this._fragmentShader),t.linkProgram(e),t.getProgramParameter(e,t.LINK_STATUS)||alert("Could not initialise shaders")):alert(t.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setGrayscaleShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsGrayscaleFS();this.changeFSShader(e)}setNativeShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsNativeFS();this.changeFSShader(e)}setColorMapShader(){const e=this._webgl;e.detachShader(this.shaderProgram,this._fragmentShader);const t=s.default.hipsColorMapFS();this.changeFSShader(t);const i=e.getUniformBlockIndex(this.shaderProgram,"colormap");if(i===e.INVALID_INDEX)return console.warn('HiPSShaderProgram: uniform block "colormap" not found in hipsColorMapFS()'),this._colorMapBlockIndex=null,void(this._UBO_colorMapBuffer=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],o=e.getUniformIndices(this.shaderProgram,r),a=e.getActiveUniforms(this.shaderProgram,o,e.UNIFORM_OFFSET);if(!this._UBO_colorMapBuffer){this._UBO_colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._UBO_colorMapBuffer);const t=12288;e.bufferData(e.UNIFORM_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._UBO_colorMapBuffer)}r.forEach((e,t)=>{this._UBO_colorMapVariableInfo[e]={index:o[t],offset:a[t]}})}changeFSShader(e){const t=this._webgl;this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,e),t.compileShader(this._fragmentShader),t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS)?(t.attachShader(this.shaderProgram,this._fragmentShader),t.linkProgram(this.shaderProgram),t.getProgramParameter(this.shaderProgram,t.LINK_STATUS)||alert("Could not initialise shaders"),t.useProgram(this.shaderProgram)):alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error")}setTextureDataMode(e,t,i,r,s=0,o=1){if(e<0||e>=8)throw new Error(`Invalid HiPS sampler index: ${e}`);const a=this._webgl,n=this.locations.textureMode[e];if(n&&a.uniform1i(n,t?1:0),!t)return;if(void 0===i||void 0===r||!Number.isFinite(i)||!Number.isFinite(r)||r<=i)throw new Error("Invalid FITS display range.");const l=this.locations.dataMin[e],h=this.locations.dataMax[e],c=this.locations.scaleFunction[e],u=this.locations.scaleParam[e];l&&a.uniform1f(l,i),h&&a.uniform1f(h,r),c&&a.uniform1i(c,s),u&&a.uniform1f(u,o)}enableShaders(e,t,i,r){const s=this._webgl;s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model),this.locations.vMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_view),this.locations.clorMapIdx=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.colormapIdx);for(let e=0;e<8;e++)this.locations.samplers[e]=s.getUniformLocation(this.shaderProgram,`uSampler${e}`),this.locations.textureAlpha[e]=s.getUniformLocation(this.shaderProgram,`uFactor${e}`),this.locations.textureMode[e]=s.getUniformLocation(this.shaderProgram,`uTextureMode${e}`),this.locations.dataMin[e]=s.getUniformLocation(this.shaderProgram,`uDataMin${e}`),this.locations.dataMax[e]=s.getUniformLocation(this.shaderProgram,`uDataMax${e}`),this.locations.scaleFunction[e]=s.getUniformLocation(this.shaderProgram,`uScaleFunction${e}`),this.locations.scaleParam[e]=s.getUniformLocation(this.shaderProgram,`uScaleParam${e}`),this.locations.samplers[e]&&s.uniform1i(this.locations.samplers[e],e);if(s.uniform1i(this.locations.clorMapIdx,r),this.locations.vertexPositionAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.textureCoordAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.text_coords),r>=2&&this._UBO_colorMapBuffer&&null!==this._colorMapBlockIndex){let e;if(s.uniformBlockBinding(this.shaderProgram,this._colorMapBlockIndex,0),s.bindBuffer(s.UNIFORM_BUFFER,this._UBO_colorMapBuffer),2===r?e={r:o.ColorMaps.planck.r,g:o.ColorMaps.planck.g,b:o.ColorMaps.planck.b}:3===r?e={r:o.ColorMaps.cmb.r,g:o.ColorMaps.cmb.g,b:o.ColorMaps.cmb.b}:4===r?e={r:o.ColorMaps.rainbow.r,g:o.ColorMaps.rainbow.g,b:o.ColorMaps.rainbow.b}:5===r?e={r:o.ColorMaps.eosb.r,g:o.ColorMaps.eosb.g,b:o.ColorMaps.eosb.b}:6===r?e={r:o.ColorMaps.cubehelix.r,g:o.ColorMaps.cubehelix.g,b:o.ColorMaps.cubehelix.b}:7===r?e={r:o.ColorMaps.hot.r,g:o.ColorMaps.hot.g,b:o.ColorMaps.hot.b}:8===r&&(e={r:o.ColorMaps.gray.r,g:o.ColorMaps.gray.g,b:o.ColorMaps.gray.b}),e||(e=this._runtimeColorMap),e){const t=this._UBO_colorMapVariableInfo;s.bufferSubData(s.UNIFORM_BUFFER,t.r_palette.offset,e.r,0),s.bufferSubData(s.UNIFORM_BUFFER,t.g_palette.offset,e.g,0),s.bufferSubData(s.UNIFORM_BUFFER,t.b_palette.offset,e.b,0)}s.bindBuffer(s.UNIFORM_BUFFER,null)}s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t)}}},2257(e,t){"use strict";t.MeshHiPSShaderProgram=void 0;t.MeshHiPSShaderProgram=class{_webgl;_options;locations;_shaderProgram;constructor(e,t={}){this._webgl=e,this._options=t,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,color:null,vertexPositionAttribute:-1,vertexNormalAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create MeshHiPS shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}enableShaders(e,t,i,r){const s=this._webgl,o=this.shaderProgram;s.useProgram(o),this.locations.pMatrix=s.getUniformLocation(o,"uPMatrix"),this.locations.vMatrix=s.getUniformLocation(o,"uVMatrix"),this.locations.mMatrix=s.getUniformLocation(o,"uMMatrix"),this.locations.color=s.getUniformLocation(o,"uColor"),this.locations.vertexPositionAttribute=s.getAttribLocation(o,"aVertexPosition"),this.locations.vertexNormalAttribute=s.getAttribLocation(o,"aVertexNormal"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniform4fv(this.locations.color,r)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n precision mediump float;\n in vec3 aVertexPosition;\n in vec3 aVertexNormal;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec3 vNormal;\n void main(void) {\n vec3 worldPos = (uMMatrix * vec4(aVertexPosition, 1.0)).xyz;\n vNormal = normalize((uMMatrix * vec4(aVertexNormal, 0.0)).xyz);\n gl_Position = uPMatrix * uVMatrix * vec4(worldPos, 1.0);\n }"),i=this.compileShader(e.FRAGMENT_SHADER,`#version 300 es\n precision mediump float;\n in vec3 vNormal;\n uniform vec4 uColor;\n out vec4 outColor;\n void main(void) {\n vec3 normal = normalize(vNormal);\n vec3 lightDir = normalize(vec3(0.45, 0.8, 0.35));\n float diffuse = ${this._options.twoSidedLighting?"abs(dot(normal, lightDir))":"max(dot(normal, lightDir), 0.0)"};\n float rim = pow(1.0 - max(dot(normal, vec3(0.0, 0.0, 1.0)), 0.0), 2.0);\n vec3 color = ${this._options.markerLighting?"uColor.rgb * (0.78 + diffuse * 0.18) + vec3(0.06, 0.08, 0.07) * rim":"uColor.rgb * (0.24 + diffuse * 0.78) + vec3(0.16, 0.24, 0.20) * rim"};\n outColor = vec4(color, uColor.a);\n }`);if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,i),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise MeshHiPS shaders")}compileShader(e,t){const i=this._webgl,r=i.createShader(e);if(!r)throw new Error("Could not create MeshHiPS shader");if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(r)||"MeshHiPS shader compile error");return r}}},5947(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class i{static catalogueVS(){return"#version 300 es\n in vec4 aCatPosition;\n in float a_selected;\n in float a_pointsize;\n in float a_brightness;\n\n out float v_selected;\n out float v_brightness;\n out lowp vec4 vColor; // not used\n\n uniform mat4 uPMatrix;\n uniform mat4 uMVMatrix;\n\n void main() {\n\n gl_Position = (uPMatrix * uMVMatrix * aCatPosition);\n gl_PointSize = a_pointsize;\n v_selected = a_selected;\n v_brightness = a_brightness;\n }"}static catalogueFS(){return"#version 300 es\n precision mediump float;\n \n #ifdef GL_OES_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n #endif\n\n // https://www.desultoryquest.com/blog/drawing-anti-aliased-circular-points-using-opengl-slash-webgl/\n\n // precision mediump float;\n\n in float v_selected;\n in float v_brightness;\n\n uniform vec4 u_fragcolor;\n\n out vec4 fragColor;\n\n // varying float v_selected;\n // varying float v_brightness;\n\n const float EPSILON = 1e-10;\n \n vec3 RGBtoHCV(in vec3 rgb) {\n // RGB [0..1] to Hue-Chroma-Value [0..1]\n // Based on work by Sam Hocevar and Emil Persson\n vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1., 2. / 3.) : vec4(rgb.gb, 0., -1. / 3.);\n vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);\n float c = q.x - min(q.w, q.y);\n float h = abs((q.w - q.y) / (6. * c + EPSILON) + q.z);\n return vec3(h, c, q.x);\n }\n\n vec3 RGBtoHSL(in vec3 rgb) {\n // RGB [0..1] to Hue-Saturation-Lightness [0..1]\n vec3 hcv = RGBtoHCV(rgb);\n //vec3 hcv = vec3(1., 1., 1.);\n float z = hcv.z - hcv.y * 0.5;\n float s = hcv.y / (1. - abs(z * 2. - 1.) + EPSILON);\n return vec3(hcv.x, s, z);\n }\n\n vec3 HUEtoRGB(in float hue){\n // Hue [0..1] to RGB [0..1]\n // See http://www.chilliant.com/rgb2hsv.html\n vec3 rgb = abs(hue * 6. - vec3(3, 2, 4)) * vec3(1, -1, -1) + vec3(-1, 2, 2);\n return clamp(rgb, 0., 1.);\n }\n\n vec3 HSLtoRGB(in vec3 hsl) {\n // Hue-Saturation-Lightness [0..1] to RGB [0..1]\n vec3 rgb = HUEtoRGB(hsl.x);\n float c = (1. - abs(2. * hsl.z - 1.)) * hsl.y;\n return (rgb - 0.5) * c + hsl.z;\n }\n \n void main() {\n\n float r = 0.0, delta = 0.0, alpha = 1.0;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n r = dot(cxy, cxy);\n if (r > 1.0) {\n discard;\n }\n\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n #endif\n\n if (v_selected == 1.0){\n // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n } else if (v_selected == 2.0){\n // gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n }else{\n if (r < 0.4) {\n discard;\n }\n if ( v_brightness >= -1.0 && v_brightness <= 1.0) {\n // Round-trip RGB->HSL->RGB with time-dependent lightness\n vec3 hsl = RGBtoHSL(vec3(u_fragcolor));\n //hsl.z = pow(hsl.z, sin(iTime) + 1.5);\n // hsl.z = pow(hsl.z, v_brightness + 1.5);\n hsl.z = pow(hsl.z, v_brightness + 1.5);\n vec3 hslcolor = HSLtoRGB(hsl);\n // gl_FragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n fragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n } else {\n // gl_FragColor = u_fragcolor * (alpha);\n fragColor = u_fragcolor * (alpha);\n }\n }\n }"}static footprintVS(){return"#version 300 es\n precision mediump float;\n\n layout(location = 0) in vec4 aCatPosition;\n\n uniform float u_pointsize;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = u_pointsize; // Works in WebGL2\n }"}static footprintFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n fragColor = u_fragcolor;\n }"}static hipsVS(){return"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n\n uniform mat4 uMMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uPMatrix;\n\n out vec2 vTextureCoord;\n\n void main() {\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n vTextureCoord = aTextureCoord;\n }"}static hipsNativeFS(){return`#version 300 es\n precision highp float;\n\n in vec2 vTextureCoord;\n\n uniform float uLayerOpacity;\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n finalColor +=\n sampleHiPSTexture0(vTextureCoord).rgb * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n finalColor +=\n sampleHiPSTexture1(vTextureCoord).rgb * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n finalColor +=\n sampleHiPSTexture2(vTextureCoord).rgb * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n finalColor +=\n sampleHiPSTexture3(vTextureCoord).rgb * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n finalColor +=\n sampleHiPSTexture4(vTextureCoord).rgb * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n finalColor +=\n sampleHiPSTexture5(vTextureCoord).rgb * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n finalColor +=\n sampleHiPSTexture6(vTextureCoord).rgb * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n finalColor +=\n sampleHiPSTexture7(vTextureCoord).rgb * uFactor7;\n }\n\n fragColor = vec4(finalColor, uLayerOpacity);\n }`}static hipsGrayscaleFS(){return`#version 300 es\n precision highp float;\n\n in vec2 vTextureCoord;\n\n uniform float uLayerOpacity;\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n vec4 color0 = sampleHiPSTexture0(vTextureCoord);\n\n float gray =\n 0.21 * color0.r +\n 0.71 * color0.g +\n 0.07 * color0.b;\n\n finalColor =\n color0.rgb * (1.0 - uFactor0) +\n vec3(gray) * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n vec4 color1 = sampleHiPSTexture1(vTextureCoord);\n finalColor += color1.rgb * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n vec4 color2 = sampleHiPSTexture2(vTextureCoord);\n finalColor += color2.rgb * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n vec4 color3 = sampleHiPSTexture3(vTextureCoord);\n finalColor += color3.rgb * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n vec4 color4 = sampleHiPSTexture4(vTextureCoord);\n finalColor += color4.rgb * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n vec4 color5 = sampleHiPSTexture5(vTextureCoord);\n finalColor += color5.rgb * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n vec4 color6 = sampleHiPSTexture6(vTextureCoord);\n finalColor += color6.rgb * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n vec4 color7 = sampleHiPSTexture7(vTextureCoord);\n finalColor += color7.rgb * uFactor7;\n }\n\n fragColor = vec4(finalColor, uLayerOpacity);\n }`}static hipsColorMapFS(){return`#version 300 es\n precision highp float;\n\n uniform float uLayerOpacity;\n\n in vec2 vTextureCoord;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n vec3 applyColorMap(vec4 color) {\n int x = int(clamp(color.r, 0.0, 1.0) * 255.0);\n int y = int(clamp(color.g, 0.0, 1.0) * 255.0);\n int z = int(clamp(color.b, 0.0, 1.0) * 255.0);\n\n float px = r_palette[x] / 256.0;\n float py = g_palette[y] / 256.0;\n float pz = b_palette[z] / 256.0;\n\n return vec3(px, py, pz);\n }\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture0(vTextureCoord)\n ) * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture1(vTextureCoord)\n ) * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture2(vTextureCoord)\n ) * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture3(vTextureCoord)\n ) * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture4(vTextureCoord)\n ) * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture5(vTextureCoord)\n ) * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture6(vTextureCoord)\n ) * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture7(vTextureCoord)\n ) * uFactor7;\n }\n\n fragColor = vec4(finalColor, uLayerOpacity);\n }`}static hipsSamplerGLSL(e){return`\n uniform sampler2D uSampler${e};\n uniform int uTextureMode${e};\n uniform float uDataMin${e};\n uniform float uDataMax${e};\n uniform int uScaleFunction${e};\n uniform float uScaleParam${e};\n\n float asinhCompat${e}(float value) {\n return log(value + sqrt(value * value + 1.0));\n }\n\n float applyFitsScale${e}(float normalized) {\n float x = clamp(normalized, 0.0, 1.0);\n\n if (uScaleFunction${e} == 1) {\n return sqrt(x);\n }\n\n if (uScaleFunction${e} == 2) {\n float strength = max(uScaleParam${e}, 1.0);\n return log(1.0 + strength * x) / log(1.0 + strength);\n }\n\n if (uScaleFunction${e} == 3) {\n float strength = max(uScaleParam${e}, 1.0);\n return asinhCompat${e}(strength * x) / asinhCompat${e}(strength);\n }\n\n if (uScaleFunction${e} == 4) {\n return pow(x, max(uScaleParam${e}, 0.0001));\n }\n\n return x;\n }\n\n vec4 sampleHiPSTexture${e}(vec2 uv) {\n vec4 color = texture(uSampler${e}, uv);\n\n // JPG / PNG\n if (uTextureMode${e} == 0) {\n return color;\n }\n\n // FITS physical value stored in red channel\n float value = color.r;\n\n if (isnan(value)) {\n discard;\n }\n\n float normalized = clamp(\n (value - uDataMin${e}) /\n (uDataMax${e} - uDataMin${e}),\n 0.0,\n 1.0\n );\n\n float scaled = applyFitsScale${e}(normalized);\n\n return vec4(\n scaled,\n scaled,\n scaled,\n 1.0\n );\n }\n `}static hipsSamplersGLSL(){return Array.from({length:8},(e,t)=>i.hipsSamplerGLSL(t)).join("\n")}}t.default=i},149(e,t,i){"use strict";t.XYZShaderProgram=void 0;const r=i(619);t.XYZShaderProgram=class{locations;_webgl;_shaderProgram;_colorMapBlockIndex=null;_colorMapBuffer=null;_runtimeColorMap;_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,colorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create XYZ shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setRuntimeColorMap(e){this._runtimeColorMap=e}enableShaders(e,t,i,r=0){const s=this._webgl,o=this.shaderProgram;s.useProgram(o),this.locations.pMatrix=s.getUniformLocation(o,"uPMatrix"),this.locations.mMatrix=s.getUniformLocation(o,"uMMatrix"),this.locations.vMatrix=s.getUniformLocation(o,"uVMatrix"),this.locations.sampler=s.getUniformLocation(o,"uSampler"),this.locations.colorMapIdx=s.getUniformLocation(o,"cmapIdx"),this.locations.vertexPositionAttribute=s.getAttribLocation(o,"aVertexPosition"),this.locations.textureCoordAttribute=s.getAttribLocation(o,"aTextureCoord"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniform1i(this.locations.sampler,0),s.uniform1i(this.locations.colorMapIdx,r),r>=2&&this.uploadColorMap(r)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec2 vTextureCoord;\n void main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n }"),i=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec2 vTextureCoord;\n uniform sampler2D uSampler;\n uniform int cmapIdx;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n out vec4 outColor;\n\n void main(void) {\n vec4 color = texture(uSampler, vTextureCoord);\n\n if (cmapIdx == 1) {\n float gray = 0.21 * color.r + 0.71 * color.g + 0.07 * color.b;\n outColor = vec4(vec3(gray), color.a);\n return;\n }\n\n if (cmapIdx >= 2) {\n int rIndex = int(clamp(color.r * 255.0, 0.0, 255.0));\n int gIndex = int(clamp(color.g * 255.0, 0.0, 255.0));\n int bIndex = int(clamp(color.b * 255.0, 0.0, 255.0));\n\n outColor = vec4(\n r_palette[rIndex] / 256.0,\n g_palette[gIndex] / 256.0,\n b_palette[bIndex] / 256.0,\n color.a\n );\n return;\n }\n\n outColor = color;\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,i),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise XYZ shaders");this.initColorMapBuffer()}compileShader(e,t){const i=this._webgl,r=i.createShader(e);if(!r)throw new Error("Could not create XYZ shader");if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(r)||"XYZ shader compile error");return r}initColorMapBuffer(){const e=this._webgl,t=this._shaderProgram,i=e.getUniformBlockIndex(t,"colormap");if(i===e.INVALID_INDEX)return void(this._colorMapBlockIndex=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],s=e.getUniformIndices(t,r),o=e.getActiveUniforms(t,s,e.UNIFORM_OFFSET);r.forEach((e,t)=>{this._colorMapVariableInfo[e]={index:s[t],offset:o[t]}}),this._colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._colorMapBuffer),e.bufferData(e.UNIFORM_BUFFER,12288,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._colorMapBuffer),e.uniformBlockBinding(t,i,0)}uploadColorMap(e){if(!this._colorMapBuffer||null===this._colorMapBlockIndex)return;const t=this.getColorMap(e);if(!t)return;const i=this._webgl,r=this.shaderProgram;i.uniformBlockBinding(r,this._colorMapBlockIndex,0),i.bindBuffer(i.UNIFORM_BUFFER,this._colorMapBuffer);const s=this._colorMapVariableInfo;i.bufferSubData(i.UNIFORM_BUFFER,s.r_palette.offset,t.r,0),i.bufferSubData(i.UNIFORM_BUFFER,s.g_palette.offset,t.g,0),i.bufferSubData(i.UNIFORM_BUFFER,s.b_palette.offset,t.b,0),i.bindBuffer(i.UNIFORM_BUFFER,null)}getColorMap(e){switch(e){case 2:return r.ColorMaps.planck;case 3:return r.ColorMaps.cmb;case 4:return r.ColorMaps.rainbow;case 5:return r.ColorMaps.eosb;case 6:return r.ColorMaps.cubehelix;case 7:return r.ColorMaps.hot;case 8:return r.ColorMaps.gray;default:return this._runtimeColorMap}}}},8145(e,t){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsType=void 0,function(e){e.CARTESIAN="cartesian",e.SPHERICAL="spherical",e.ASTRO="astro",e.GEOGRAPHIC="geographic"}(i||(t.CoordsType=i={}))},8083(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FoVUtils=void 0;const s=i(6553),o=r(i(4639)),a=i(8145),n=i(3890);class l{getMinFoV(){return this._fovY_deg<=this._fovX_deg?this._fovY_deg:this._fovX_deg}static getFoVPolygon(e,t,i,r,s,a){const h=e.getCameraMatrix(),c=i.getModelMatrix(),u=t.clientWidth,d=t.clientHeight;let g=[];if(o.default.getIntersectionPointWithSingleModel(0,0,r,s,e,a).length>0){g=l.getScreenCornersIntersection(a,e,t,r,s)}else{let t=n.mat4.create();t=n.mat4.multiply(t,h,c),t=n.mat4.multiply(t,a,t);const i=[t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]],_=[t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]],p=[t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]],f=[t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]],m=o.default.getIntersectionPointWithSingleModel(u/2,0,r,s,e,a),S=o.default.getIntersectionPointWithSingleModel(u,d/2,r,s,e,a);if(0===m.length&&0===S.length){const e=l.getNearestSpherePoint(i),t=l.getNearestSpherePoint(_),r=l.getNearestSpherePoint(f),s=l.getNearestSpherePoint(p),o=l.computeMiddlePoint(r[0],e[0])[0],a=l.computeMiddlePoint(e[0],s[0])[0],n=l.computeMiddlePoint(s[0],t[0])[0],h=l.computeMiddlePoint(t[0],r[0])[0];g.push(e[0],a,s[0],n,t[0],h,r[0],o)}else if(0===m.length){const e=l.getNearestSpherePoint(i),r=l.getNearestSpherePoint(_),s=l.getFrustumIntersectionWithSphere(t,f,_,i),o=l.getFrustumIntersectionWithSphere(t,p,i,_),a=l.computeMiddlePoint(s[1],e[0])[0],n=l.computeMiddlePoint(e[0],o[0])[0],h=l.computeMiddlePoint(o[1],r[0])[0],c=l.computeMiddlePoint(r[0],s[0])[0];g.push(e[0],n,o[0],o[1],h,r[0],c,s[0],s[1],a)}else if(0===S.length){const e=l.getFrustumIntersectionWithSphere(t,i,f,p),r=l.getFrustumIntersectionWithSphere(t,_,p,f),s=l.getNearestSpherePoint(f),o=l.getNearestSpherePoint(p),a=l.computeMiddlePoint(s[0],e[0])[0],n=l.computeMiddlePoint(e[1],o[0])[0],h=l.computeMiddlePoint(o[0],r[0])[0],c=l.computeMiddlePoint(r[1],s[0])[0];g.push(e[0],e[1],n,o[0],h,r[0],r[1],c,s[0],a)}else{const e=l.getFrustumIntersectionWithSphere(t,i,f,p),r=l.getFrustumIntersectionWithSphere(t,_,p,f),s=l.getFrustumIntersectionWithSphere(t,f,_,i),o=l.getFrustumIntersectionWithSphere(t,p,i,_);g.push(e[0],e[1],o[0],o[1],r[0],r[1],s[0],s[1])}}return g}static getScreenCornersIntersection(e,t,i,r,n){const l=i.clientWidth,h=i.clientHeight,c=o.default.getIntersectionPointWithSingleModel(0,0,r,n,t,e),u=o.default.getIntersectionPointWithSingleModel(l/2,0,r,n,t,e),d=o.default.getIntersectionPointWithSingleModel(l,0,r,n,t,e),g=o.default.getIntersectionPointWithSingleModel(l,h/2,r,n,t,e),_=o.default.getIntersectionPointWithSingleModel(l,h,r,n,t,e),p=o.default.getIntersectionPointWithSingleModel(l/2,h,r,n,t,e),f=o.default.getIntersectionPointWithSingleModel(0,h,r,n,t,e),m=o.default.getIntersectionPointWithSingleModel(0,h/2,r,n,t,e),S=[],x=e=>{e.length>0&&S.push(new s.Point({x:e[0],y:e[1],z:e[2]},a.CoordsType.CARTESIAN))};return x(c),x(u),x(d),x(g),x(_),x(p),x(f),x(m),S}static getCenterJ2000(e,t,i,r,n){const l=e.clientWidth,h=e.clientHeight,c=o.default.getIntersectionPointWithSingleModel(l/2,h/2,t,i,r,n);if(c.length<=0)throw Error("Central point is null");return new s.Point({x:c[0],y:c[1],z:c[2]},a.CoordsType.CARTESIAN)}static computeMiddlePoint(e,t){const i=(e.x+t.x)/2,r=(e.y+t.y)/2,o=(e.z+t.z)/2,n=Math.hypot(i,r,o)||1,l=i/n,h=r/n,c=o/n;return[new s.Point({x:l,y:h,z:c},a.CoordsType.CARTESIAN)]}static getNearestSpherePoint(e){const[t,i,r,o]=e,n=1/Math.sqrt(t*t+i*i+r*r),l=1*n,h=-1*n,c=[t*l,i*l,r*l],u=[t*h,i*h,r*h],d=Math.sqrt(t*t+i*i+r*r)||1,g=Math.abs(t*c[0]+i*c[1]+r*c[2]+o)/d<=Math.abs(t*u[0]+i*u[1]+r*u[2]+o)/d?c:u;return[new s.Point({x:g[0],y:g[1],z:g[2]},a.CoordsType.CARTESIAN)]}static getFrustumIntersectionWithSphere(e,t,i,r){const[o,n,l,h]=t,c=o*o+n*n+l*l||1,u=-o*h/c,d=-n*h/c,g=-l*h/c,_=Math.abs(h)/Math.sqrt(c),p=[];if(1>_){const e=Math.sqrt(1-_*_),t=t=>{const[i,r,s,o]=t,a=1/Math.sqrt(i*i+r*r+s*s),n=e*a,l=-e*a,h=[u+i*n,d+r*n,g+s*n],c=[u+i*l,d+r*l,g+s*l],_=Math.sqrt(i*i+r*r+s*s)||1;return Math.abs(i*h[0]+r*h[1]+s*h[2]+o)/_<=Math.abs(i*c[0]+r*c[1]+s*c[2]+o)/_?h:c},o=t(i),n=t(r);p.push(new s.Point({x:o[0],y:o[1],z:o[2]},a.CoordsType.CARTESIAN),new s.Point({x:n[0],y:n[1],z:n[2]},a.CoordsType.CARTESIAN))}else 1===_&&p.push(new s.Point({x:u,y:d,z:g},a.CoordsType.CARTESIAN),new s.Point({x:u,y:d,z:g},a.CoordsType.CARTESIAN));return p}static getAstroFoVPolygon(e){return e.map(e=>e.toADQL()).join(",")}}t.FoVUtils=l},8755(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(8145),s=i(6553);class o{static isGeoJSON(e){if(!e||"object"!=typeof e)return!1;const t=e.type;return"FeatureCollection"===t||"Feature"===t||"Polygon"===t||"MultiPolygon"===t||"GeometryCollection"===t}static parseGeoJSON(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON root must be an object");const t=e;if("FeatureCollection"===t.type){if(!Array.isArray(t.features))throw new Error("GeoJSON FeatureCollection has no features array");return t.features.flatMap(e=>o.parseFeature(e))}if("Feature"===t.type)return o.parseFeature(t);if("Polygon"===t.type||"MultiPolygon"===t.type||"GeometryCollection"===t.type)return o.parseGeometry(t,{});throw new Error(`Unsupported GeoJSON type: ${t.type??"unknown"}`)}static parseFeature(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON feature must be an object");const t=e;if("Feature"!==t.type)throw new Error("GeoJSON feature has invalid type");return t.geometry?o.parseGeometry(t.geometry,t.properties??{},t.id):[]}static parseGeometry(e,t,i){return"Polygon"===e.type?[{id:i,geometryType:"Polygon",properties:t,polygons:o.parsePolygonCoordinates(e.coordinates)}]:"MultiPolygon"===e.type?[{id:i,geometryType:"MultiPolygon",properties:t,polygons:o.parseMultiPolygonCoordinates(e.coordinates)}]:"GeometryCollection"===e.type&&Array.isArray(e.geometries)?e.geometries.flatMap(e=>o.parseGeometry(e,t,i)):[]}static parseMultiPolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON MultiPolygon coordinates must be an array");return e.flatMap(e=>o.parsePolygonCoordinates(e))}static parsePolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON Polygon coordinates must be an array");return e.map(e=>o.parseLinearRing(e)).filter(e=>e.length>=3)}static parseLinearRing(e){if(!Array.isArray(e))throw new Error("GeoJSON linear ring must be an array");const t=e.map(e=>o.parsePosition(e));if(t.length>1){const e=t[0],i=t[t.length-1];e.lonDeg===i.lonDeg&&e.latDeg===i.latDeg&&t.pop()}return t}static parsePosition(e){if(!Array.isArray(e)||e.length<2)throw new Error("GeoJSON position must be [longitude, latitude]");const[t,i]=e;if(!Number.isFinite(t)||!Number.isFinite(i))throw new Error("GeoJSON position contains non-finite longitude/latitude");return new s.Point({lonDeg:t,latDeg:i},r.CoordsType.GEOGRAPHIC)}}t.default=o},2930(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),o=r(i(7559)),a=i(8145);class n{static orthodromicDistance(e,t){return Math.acos(Math.sin(e.decDeg*Math.PI/180)*Math.sin(t.decDeg*Math.PI/180)+Math.cos(e.decDeg*Math.PI/180)*Math.cos(t.decDeg*Math.PI/180)*Math.cos((t.raDeg-e.raDeg)*Math.PI/180))}static computeSelectionObject(e){let t,i,r,s,a=[],l=0;let h=0;if(e[0][0].decDeg>=10?h=1:e[0][0].decDeg<=-10?h=-1:l=1,0===l){const o=n.projectIn2D(e[0][0]);t=r=o.x,i=s=o.y;for(const o of e){const e=[];for(const c of o){if(c.decDeg>10*h&&-1===h||c.decDeg<10*h&&1===h){l=1,a=[];break}const o=n.projectIn2D(c);e.push(o),o.x>t&&(t=o.x),o.y>i&&(i=o.y),o.x<r&&(r=o.x),o.y<s&&(s=o.y)}a.push(e)}}if(0===l)return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s};const c=180;let u=e[0][0].raDeg<c;t=r=e[0][0].raDeg,i=s=e[0][0].decDeg;for(const n of e){const e=[];for(const h of n){const n=new o.default(h.raDeg,h.decDeg);if(e.push(n),h.raDeg>t&&(t=h.raDeg),h.decDeg>i&&(i=h.decDeg),h.raDeg<r&&(r=h.raDeg),h.decDeg<s&&(s=h.decDeg),h.raDeg>=c&&u||h.raDeg<=c&&!u){l=2,a=[];break}}a.push(e)}if(1===l)return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s};let d=e[0][0].raDeg;t=d>=c?d-360:d,i=e[0][0].decDeg,r=t,s=i;for(const n of e){const e=[];for(const a of n){const n=a.raDeg>=c?a.raDeg-360:a.raDeg;n>t&&(t=n),a.decDeg>i&&(i=a.decDeg),n<r&&(r=n),a.decDeg<s&&(s=a.decDeg),e.push(new o.default(n,a.decDeg))}a.push(e)}return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s}}static stereographic(e){const t=Number(e.xyz[0]),i=Number(e.xyz[1]),r=Number(e.xyz[2]);return{x:2*t/(1-r),y:2*i/(1-r)}}static projectIn2D(e){const t=n.stereographic(e);return new o.default(t.x,t.y)}static checkPointInsidePolygon5(e,t){let i;if(0===e.flag)i=n.projectIn2D(t);else if(1===e.flag)i=new o.default(t.raDeg,t.decDeg);else{const e=180,r=t.raDeg>=e?t.raDeg-360:t.raDeg;i=new o.default(r,t.decDeg)}const r=new o.default(i.x,i.y+2*Math.abs(e.maxy-e.miny));if(i.x>e.maxx||i.x<e.minx||i.y>e.maxy||i.y<e.miny)return!1;for(const t of e.poly4selection){let e=0;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],n=(a.y-o.y)*(r.x-i.x)-(a.x-o.x)*(r.y-i.y),l=(a.x-o.x)*(i.y-o.y)-(a.y-o.y)*(i.x-o.x),h=(r.x-i.x)*(i.y-o.y)-(r.y-i.y)*(i.x-o.x);if(0!==n){const t=l/n,i=h/n;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const s=t[t.length-1],o=t[0],a=(o.y-s.y)*(r.x-i.x)-(o.x-s.x)*(r.y-i.y),n=(o.x-s.x)*(i.y-s.y)-(o.y-s.y)*(i.x-s.x),l=(r.x-i.x)*(i.y-s.y)-(r.y-i.y)*(i.x-s.x);if(0!==a){const t=n/a,i=l/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}static checkPointInsidePolygon4(e,t){const i=n.projectIn2D(t);let r=t.raDeg+15;r>360&&(r=t.raDeg-15);const o=new s.Point({raDeg:r,decDeg:t.decDeg},a.CoordsType.ASTRO),l=n.projectIn2D(o);for(const t of e){let e=0;for(let r=0;r<t.length-1;r++){const s=n.projectIn2D(t[r]),o=n.projectIn2D(t[r+1]),a=(o.y-s.y)*(l.x-i.x)-(o.x-s.x)*(l.y-i.y),h=(o.x-s.x)*(i.y-s.y)-(o.y-s.y)*(i.x-s.x),c=(l.x-i.x)*(i.y-s.y)-(l.y-i.y)*(i.x-s.x);if(0!==a){const t=h/a,i=c/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const r=n.projectIn2D(t[t.length-1]),s=n.projectIn2D(t[0]),o=(s.y-r.y)*(l.x-i.x)-(s.x-r.x)*(l.y-i.y),a=(s.x-r.x)*(i.y-r.y)-(s.y-r.y)*(i.x-r.x),h=(l.x-i.x)*(i.y-r.y)-(l.y-i.y)*(i.x-r.x);if(0!==o){const t=a/o,i=h/o;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}}t.default=n},4396(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(3890),o=i(4851),a=r(i(4382)),n=i(7930);t.default=class{_xyz=null;_raDecDeg=null;_phiThetaDeg=null;raHMS;decDMS;constructor(e,t,i){null!=e&&(this._xyz=e),null!=t&&(this._raDecDeg=t),null!=i&&(this._phiThetaDeg=i),this._raDecDeg&&(this.raHMS=(0,n.raDegToHMS)(this._raDecDeg.ra),this.decDMS=(0,n.decDegToDMS)(this._raDecDeg.dec))}computeNpix(){if(!this._xyz)return null;const e=a.default.getHealpix(a.default.nsideForSelection),t=new o.Vec3(this._xyz[0],this._xyz[1],this._xyz[2]),i=new o.Pointing(t,!1);return e.ang2pix(i,!1)}update(e){const t=(i=e,Array.isArray(i)?s.vec3.fromValues(i[0],i[1],i[2]):i);var i;const r=(0,n.cartesianToSpherical)(t),o=(0,n.sphericalToAstroDeg)(r.phi,r.theta);this._xyz=[t[0],t[1],t[2]],this._phiThetaDeg=r,this._raDecDeg=o,this.raHMS=(0,n.raDegToHMS)(o.ra),this.decDMS=(0,n.decDegToDMS)(o.dec)}clear(){this._xyz=null,this._raDecDeg=null,this._phiThetaDeg=null,this.raHMS=void 0,this.decDMS=void 0}get xyz(){return this._xyz}get x(){return this._xyz?this._xyz[0]:null}get y(){return this._xyz?this._xyz[1]:null}get z(){return this._xyz?this._xyz[2]:null}get ra(){return this._raDecDeg?this._raDecDeg.ra:null}get dec(){return this._raDecDeg?this._raDecDeg.dec:null}get phi(){return this._phiThetaDeg?this._phiThetaDeg.phi:null}get theta(){return this._phiThetaDeg?this._phiThetaDeg.theta:null}get raDecDeg(){return this._raDecDeg}get phiThetaDeg(){return this._phiThetaDeg}}},9685(e,t,i){"use strict";t.PerspectiveMatrixManager=void 0;const r=i(3890),s=i(2919);t.PerspectiveMatrixManager=class{_pMatrix;_aspectRatio=1;constructor(e,t,i,r=.1,s){this._pMatrix=this.computePerspectiveMatrix(e,t,i,r,s)}get pMatrix(){return this._pMatrix}set pMatrix(e){this._pMatrix=e}computePerspectiveMatrix(e,t,i,o=.1,a){this._aspectRatio=e.width/e.height;const n=r.mat4.create();let l;if(a)l=1.1;else{const e=t.getCameraMatrix(),i=-Number(e[14]),r=1,s=Math.sqrt(Math.max(i**2-r**2,0)),o=Math.atan2(s,r),a=s*Math.sin(o);l=a>0?a:r}const h=a?s.bootSetup.inside_camera_fov_deg:i,c=a?Math.max(o,.001):o;return r.mat4.perspective(n,h*Math.PI/180,this._aspectRatio,c,l),this._pMatrix=n,n}}},4639(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(3890);class s{static lastNearestVisibleObjectIdx=-1;static getNearestVisibleObjectIdx(){return this.lastNearestVisibleObjectIdx}static getRayFromMouse(e,t,i,o,a){const n=o.canvas.getBoundingClientRect(),l=t,h=[2*e/n.width-1,1-2*l/n.height,-1,1],c=r.mat4.create();r.mat4.invert(c,i);const u=[0,0,0,0];s.mat4MultiplyVec4(c,h,u);const d=[u[0],u[1],-1,0],g=r.mat4.create();r.mat4.invert(g,a);const _=[0,0,0,0];s.mat4MultiplyVec4(g,d,_);const p=r.vec3.fromValues(_[0],_[1],_[2]);return r.vec3.normalize(p,p),p}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],o=t[2],a=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*o+e[12]*a,i[1]=e[1]*r+e[5]*s+e[9]*o+e[13]*a,i[2]=e[2]*r+e[6]*s+e[10]*o+e[14]*a,i[3]=e[3]*r+e[7]*s+e[11]*o+e[15]*a,i}static raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;t<0&&i<0||(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}static getIntersectionPointWithSingleModel(e,t,i,o,a,n){const l=a.getCameraMatrix(),h=s.getRayFromMouse(e,t,n,o,l),c=s.raySphere(a.getCameraPosition(),h,i);let u=[];if(c>=0){const e=r.vec3.create();r.vec3.scale(e,h,c),r.vec3.add(e,a.getCameraPosition(),e);const t=[e[0],e[1],e[2],1],o=[0,0,0,0];s.mat4MultiplyVec4(i.getModelMatrixInverse(),t,o),u=[o[0],o[1],o[2]]}return u}}t.default=s},9665(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),o=i(8145),a=r(i(4382));class n{static parseSTCS(e,t={}){const i=n.cleanStcs(e);return i.includes("POLYGON")?n.parsePolygon(i,t):i.includes("CIRCLE")?n.parseCircle(i,t):(console.warn("STCS not recognised"),{totpoints:0,polygons:[]})}static cleanStcs(e){let t=e.toUpperCase();return t=t.replace(/'ICRS'/g,"").replace(/\bICRS\b/g,"").replace(/\bJ2000\b/g,"").replace(/\bUNION\b/g,"").replace(/\bTOPOCENTER\b/g,""),t=t.replace(/[()]/g,""),t=t.replace(/ {2,}/g," ").trim(),t}static parsePolygon(e,t={}){let i=0;const r=[],n=a.default.MAX_DECIMALS??12,l=t.coordsType??o.CoordsType.ASTRO,h=e.split("POLYGON ");for(let e=1;e<h.length;e++){const t=[],a=h[e].trim().split(" "),c=Number(parseFloat(a[0]).toFixed(n)),u=Number(parseFloat(a[1]).toFixed(n)),d=Number(parseFloat(a[a.length-2]).toFixed(n)),g=Number(parseFloat(a[a.length-1]).toFixed(n));if(c===d&&u===g&&a.splice(a.length-2,2),a.length>2){for(let e=0;e<a.length-1;e+=2){const r=Number(parseFloat(a[e]).toFixed(n)),h=Number(parseFloat(a[e+1]).toFixed(n)),c=l===o.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:h},o.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:h},o.CoordsType.ASTRO);t.push(c),i+=1}r.push(t)}}return{totpoints:i,polygons:r}}static parseCircle(e,t={}){let i=0;const r=[],a=t.coordsType??o.CoordsType.ASTRO,n=e.split("CIRCLE ");for(let e=1;e<n.length;e++){const t=[],l=n[e].trim().split(" "),h=Number(l[0]),c=Number(l[1]),u=Number(l[2]),d=4*6,g=2*Math.PI/d;for(let e=d;e>0;e--){const r=u*Math.cos(e*g)+h,n=u*Math.sin(e*g)+c,l=a===o.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:n},o.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:n},o.CoordsType.ASTRO);t.push(l),i+=1}r.push(t)}return{totpoints:i,polygons:r}}}t.default=n},7930(e,t,i){"use strict";t.cartesianToSpherical=function(e){const t=r.vec3.dot(e,e),i=Math.sqrt(t);let s=Math.acos(e[2]/i);s=o(s);let a=Math.atan2(e[1],e[0]);a=o(a),a<0&&(a+=360);return{phi:a,theta:s}},t.colorHex2RGB=function(e){const t=e.substring(1,3),i=e.substring(3,5),r=e.substring(5,7),s=parseInt(t,16),o=parseInt(i,16),a=parseInt(r,16),n=(s/255).toFixed(2),l=(o/255).toFixed(2),h=(a/255).toFixed(2);return[parseFloat(n),parseFloat(l),parseFloat(h)]},t.degToRad=s,t.radToDeg=o,t.sphericalToAstroDeg=function(e,t){let i=e;i<0&&(i+=360);return{ra:i,dec:90-t}},t.sphericalToCartesian=function(e,t,i=1){const r=i*Math.sin(s(t))*Math.cos(s(e)),o=i*Math.sin(s(t))*Math.sin(s(e)),a=i*Math.cos(s(t));return[r,o,a]},t.astroDegToSpherical=function(e,t){let i=e;i<0&&(i+=360);return{phi:i,theta:90-t}},t.raDegToHMS=function(e){const t=Math.floor(e/15),i=Math.floor(60*(e/15-t));return{h:t,m:i,s:3600*(e/15-t-i/60)}},t.decDegToDMS=function(e){let t=1;e<0&&(t=-1);const i=Math.abs(e);let r=Math.trunc(i);const s=Math.trunc(60*(i-r)),o=3600*(i-r-s/60);return r*=t,{d:r,m:s,s:o}};const r=i(3890);function s(e){return e/180*Math.PI}function o(e){return 180*e/Math.PI}},2166(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(3890),s=85.0511287798066;class o{static getRayFromMouse(e,t,i,s,a){const n=s.canvas.getBoundingClientRect(),l=[2*e/n.width-1,1-2*t/n.height,-1,1],h=r.mat4.create();r.mat4.invert(h,i);const c=[0,0,0,0];o.mat4MultiplyVec4(h,l,c);const u=[c[0],c[1],-1,0],d=r.mat4.create();r.mat4.invert(d,a);const g=[0,0,0,0];o.mat4MultiplyVec4(d,u,g);const _=r.vec3.fromValues(g[0],g[1],g[2]);return r.vec3.normalize(_,_),_}static raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}static getIntersectionPointWithModel(e,t,i,s,a,n){const l=a.getCameraMatrix(),h=o.getRayFromMouse(e,t,n,s,l),c=o.raySphere(a.getCameraPosition(),h,i);if(c<0)return null;const u=r.vec3.create();r.vec3.scale(u,h,c),r.vec3.add(u,a.getCameraPosition(),u);const d=[u[0],u[1],u[2],1],g=[0,0,0,0];return o.mat4MultiplyVec4(i.getModelMatrixInverse(),d,g),[g[0],g[1],g[2]]}static getLonLatFromMouse(e,t,i,r,s,a){const n=o.getIntersectionPointWithModel(e,t,i,r,s,a);return n?o.modelPointToLonLat(n):null}static getTileFromMouse(e,t,i,r,s,a,n){const l=o.getLonLatFromMouse(e,t,r,s,a,n);return l&&o.isMercatorLatitude(l.latDeg)?o.lonLatToTile(l.lonDeg,l.latDeg,i):null}static getVisibleTilesFromViewport(e,t,i,r,s,a=9,n=2){const l=i.canvas.getBoundingClientRect(),h=Math.max(2,Math.floor(a)),c=Math.max(2*h+1,21),u=Math.max(0,Math.floor(n)),d=[],g=(a,n)=>{const l=o.getTileFromMouse(a,n,e,t,i,r,s);l&&(d.push(l),d.push(...o.getNeighborTiles(l,u)))};for(let e=0;e<h;e++){const t=1===h?l.height/2:e/(h-1)*l.height;for(let e=0;e<h;e++){g(1===h?l.width/2:e/(h-1)*l.width,t)}}for(let e=0;e<c;e++){const t=1===c?.5:e/(c-1),i=t*l.width,r=t*l.height;g(i,0),g(i,l.height),g(0,r),g(l.width,r)}return o.fillSmallTileGaps(o.deduplicateTiles(d))}static modelPointToLonLat(e){const[t,i,r]=e,s=Math.hypot(t,i,r);if(!Number.isFinite(s)||0===s)return{lonDeg:0,latDeg:0};return{lonDeg:180*Math.atan2(i,t)/Math.PI,latDeg:180*Math.asin(Math.max(-1,Math.min(1,r/s)))/Math.PI}}static lonLatToTile(e,t,i){const r=Math.max(0,Math.floor(i)),s=2**r,a=Math.floor((e+180)/360*s),n=Math.floor(o.latToTileY(t,r));return{z:r,x:o.wrapTileX(a,s),y:o.clampTileY(n,s)}}static getNeighborTiles(e,t=1){const i=2**e.z,r=[],s=Math.max(0,Math.floor(t));for(let t=-s;t<=s;t++)for(let a=-s;a<=s;a++)r.push({z:e.z,x:o.wrapTileX(e.x+t,i),y:o.clampTileY(e.y+a,i)});return o.deduplicateTiles(r)}static deduplicateTiles(e){const t=new Map;for(const i of e)t.set(`${i.z}/${i.x}/${i.y}`,i);return Array.from(t.values())}static fillSmallTileGaps(e){if(0===e.length)return e;const t=e[0].z,i=2**t,r=new Map,s=e=>{r.set((e=>`${e.z}/${e.x}/${e.y}`)(e),e)},a=(e,s)=>s>=0&&s<i&&r.has(`${t}/${o.wrapTileX(e,i)}/${s}`);for(const t of e)s(t);for(const r of e){const e=r.x,n=r.y;a(e-2,n)&&!a(e-1,n)&&s({z:t,x:o.wrapTileX(e-1,i),y:n}),a(e+2,n)&&!a(e+1,n)&&s({z:t,x:o.wrapTileX(e+1,i),y:n}),a(e,n-2)&&!a(e,n-1)&&s({z:t,x:e,y:n-1}),a(e,n+2)&&!a(e,n+1)&&s({z:t,x:e,y:n+1})}return Array.from(r.values())}static latToTileY(e,t){const i=Math.max(-85.0511287798066,Math.min(s,e))*Math.PI/180,r=2**t;return(1-Math.asinh(Math.tan(i))/Math.PI)/2*r}static isMercatorLatitude(e){return Math.abs(e)<=s}static wrapTileX(e,t){return(e%t+t)%t}static clampTileY(e,t){return Math.max(0,Math.min(t-1,e))}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],o=t[2],a=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*o+e[12]*a,i[1]=e[1]*r+e[5]*s+e[9]*o+e[13]*a,i[2]=e[2]*r+e[6]*s+e[10]*o+e[14]*a,i[3]=e[3]*r+e[7]*s+e[11]*o+e[15]*a,i}}t.default=o},7223(){},4851(e,t,i){"use strict";i.d(t,{Healpix:()=>m,Pointing:()=>s,Vec3:()=>r});class r{x;y;z;constructor(e,t,i){if(![e,t,i].every(Number.isFinite))throw new RangeError("Vec3 coordinates must be finite numbers.");this.x=e,this.y=t,this.z=i}getX(){return this.x}getY(){return this.y}getZ(){return this.z}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.lengthSquared())}normalize(){const e=this.length();if(0===e)throw new RangeError("Cannot normalize a zero-length vector.");return new r(this.x/e,this.y/e,this.z/e)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}}class s{theta;phi;constructor(e,t=!1,i,s){if(e){const i=new r(e.x,e.y,e.z).normalize();return this.theta=Math.atan2(Math.sqrt(i.x*i.x+i.y*i.y),i.z),void(this.phi=o(t?-Math.atan2(i.y,i.x):Math.atan2(i.y,i.x)))}if(!Number.isFinite(i)||!Number.isFinite(s))throw new RangeError("Pointing requires either a Vec3-like object or finite theta/phi radians.");this.theta=i,this.phi=o(s)}toVec3(){const e=Math.sin(this.theta);return new r(e*Math.cos(this.phi),e*Math.sin(this.phi),Math.cos(this.theta))}}function o(e){const t=2*Math.PI;return(e%t+t)%t}class a{r=[];append(e){this.appendRange(e,e+1)}appendRange(e,t){if(!Number.isInteger(e)||!Number.isInteger(t))throw new RangeError("RangeSet bounds must be integers.");if(!(e>=t))for(let i=e;i<t;i+=1)this.r.push(i)}toArray(){return[...this.r]}}const n=2/3,l=Math.PI/2,h=2*Math.PI,c=26,u=[2,2,2,2,3,3,3,3,4,4,4,4],d=[1,3,5,7,0,2,4,6,1,3,5,7],g=[-1,-1,0,1,1,1,0,-1],_=[0,1,1,1,0,-1,-1,-1],p=[[8,9,10,11,-1,-1,-1,-1,10,11,8,9],[5,6,7,4,8,9,10,11,9,10,11,8],[-1,-1,-1,-1,5,6,7,4,-1,-1,-1,-1],[4,5,6,7,11,8,9,10,11,8,9,10],[0,1,2,3,4,5,6,7,8,9,10,11],[1,2,3,0,0,1,2,3,5,6,7,4],[-1,-1,-1,-1,7,4,5,6,-1,-1,-1,-1],[3,0,1,2,3,0,1,2,4,5,6,7],[2,3,0,1,-1,-1,-1,-1,0,1,2,3]],f=[[0,0,3],[0,0,6],[0,0,0],[0,0,5],[0,0,0],[5,0,0],[0,0,0],[6,0,0],[3,0,0]];class m{nside;order;npix;constructor(e){if(!Number.isInteger(e)||e<=0)throw new RangeError("nside must be a positive integer.");const t=Math.log2(e);if(!Number.isInteger(t))throw new RangeError("nside must be a power of two.");if(t>c)throw new RangeError("nside order must be <= 26 for safe JavaScript integer arithmetic.");this.nside=e,this.order=t,this.npix=12*e*e}getNPix(){return this.npix}nside2order(e){if(!Number.isInteger(e)||e<=0)return-1;const t=Math.log2(e);return Number.isInteger(t)?t:-1}nest2xyf(e){this.assertPixel(e);const t=this.nside*this.nside,i=Math.floor(e/t),r=e%t;return{ix:x(r),iy:x(r>>1),face:i}}xyf2nest(e,t,i){if(!Number.isInteger(i)||i<0||i>=12)throw new RangeError("face must be an integer in [0, 11].");if(!Number.isInteger(e)||e<0||e>=this.nside)throw new RangeError("ix must be an integer in [0, nside).");if(!Number.isInteger(t)||t<0||t>=this.nside)throw new RangeError("iy must be an integer in [0, nside).");return i*this.nside*this.nside+S(e)+2*S(t)}ang2pix(e,t=!1){if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("pointing theta and phi must be finite radians.");if(e.theta<0||e.theta>Math.PI)throw new RangeError("pointing theta must be in [0, pi].");const i=Math.cos(e.theta),r=Math.abs(i),s=v(e.phi)/l;if(r<=n){const e=this.nside*(.5+s),t=this.nside*i*.75,r=Math.floor(e-t),o=Math.floor(e+t),a=Math.floor(r/this.nside),n=Math.floor(o/this.nside),l=a===n?4|a:a<n?a:n+8,h=b(o,this.nside),c=this.nside-b(r,this.nside)-1;return this.xyf2nest(h,c,l)}const o=Math.min(3,Math.floor(s)),a=s-o,h=Math.sin(e.theta),c=r<.99?this.nside*Math.sqrt(3*(1-r)):this.nside*h/Math.sqrt((1+r)/3),u=Math.min(this.nside-1,Math.floor(a*c)),d=Math.min(this.nside-1,Math.floor((1-a)*c));return i>=0?this.xyf2nest(this.nside-d-1,this.nside-u-1,o):this.xyf2nest(u,d,o+8)}pix2vec(e){return this.pix2ang(e).toVec3()}pix2ang(e,t=!1){const{z:i,phi:r}=this.pix2zphi(e),o=Math.acos(M(i,-1,1));return new s(null,t,o,r)}getBoundaries(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=.5/this.nside,o=(t+.5)/this.nside,a=(i+.5)/this.nside;return[this.faceLocalToVec3(o+s,a+s,r),this.faceLocalToVec3(o-s,a+s,r),this.faceLocalToVec3(o-s,a-s,r),this.faceLocalToVec3(o+s,a-s,r)]}getBoundariesWithStep(e,t){if(!Number.isInteger(t)||t<=0)throw new RangeError("step must be a positive integer.");const{ix:i,iy:r,face:s}=this.nest2xyf(e),o=.5/this.nside,a=(i+.5)/this.nside,n=(r+.5)/this.nside,l=1/(this.nside*t),h=new Array(4*t);for(let e=0;e<t;e+=1)h[e]=this.faceLocalToVec3(a+o-e*l,n+o,s),h[e+t]=this.faceLocalToVec3(a-o,n+o-e*l,s),h[e+2*t]=this.faceLocalToVec3(a-o+e*l,n-o,s),h[e+3*t]=this.faceLocalToVec3(a+o,n-o+e*l,s);return h}getPointsForXyfNoStep(e,t,i){this.assertXyf(e,t,i);const r=.5/this.nside,s=(e+.5)/this.nside,o=(t+.5)/this.nside;return[this.faceLocalToVec3(s+r,o+r,i),this.faceLocalToVec3(s-r,o+r,i),this.faceLocalToVec3(s-r,o-r,i),this.faceLocalToVec3(s+r,o-r,i)]}neighbours(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=new Int32Array(8),o=this.nside-1;if(t>0&&t<o&&i>0&&i<o)return s[0]=this.xyf2nest(t-1,i,r),s[1]=this.xyf2nest(t-1,i+1,r),s[2]=this.xyf2nest(t,i+1,r),s[3]=this.xyf2nest(t+1,i+1,r),s[4]=this.xyf2nest(t+1,i,r),s[5]=this.xyf2nest(t+1,i-1,r),s[6]=this.xyf2nest(t,i-1,r),s[7]=this.xyf2nest(t-1,i-1,r),s;for(let e=0;e<s.length;e+=1){let o=t+g[e],a=i+_[e],n=4;o<0?(o+=this.nside,n-=1):o>=this.nside&&(o-=this.nside,n+=1),a<0?(a+=this.nside,n-=3):a>=this.nside&&(a-=this.nside,n+=3);const l=p[n][r];if(l<0){s[e]=-1;continue}const h=f[n][Math.floor(r/4)];if((1&h)>0&&(o=this.nside-o-1),(2&h)>0&&(a=this.nside-a-1),(4&h)>0){const e=o;o=a,a=e}s[e]=this.xyf2nest(o,a,l)}return s}queryDiscInclusive(e,t,i){if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("pointing theta and phi must be finite radians.");if(!Number.isFinite(t)||t<0)throw new RangeError("radiusRad must be a non-negative finite number.");if(!Number.isInteger(i)||i<0||i>0&&!T(i))throw new RangeError("fact must be zero or a positive power of two.");const r=new a;if(t>=Math.PI)return r.appendRange(0,this.npix),r;const s=0!==i,o=s?Math.log2(i):0,n=Math.min(c,this.order+o),l=e.toVec3(),h=Math.cos(t),u=Math.sin(t),d=[],g=[],_=new Map,p=new Set,f=[];for(let e=0;e<=n;e+=1){const i=y(2**e),r=Math.cos(i),s=Math.sin(i);d[e]=t+i>Math.PI?-1:h*r-u*s,g[e]=t-i<0?1:h*r+u*s}for(let e=11;e>=0;e-=1)f.push({pixel:e,order:0});for(;f.length>0;){const e=f.pop();if(!e)break;let t=_.get(e.order);t||(t=e.order===this.order?this:new m(2**e.order),_.set(e.order,t));const i=t.pix2vec(e.pixel),r=l.dot(i);if(r+2e-7<=d[e.order])continue;const o=r<h?1:r<=g[e.order]?2:3;this.collectDiscPixel(e.order,n,o,e.pixel,s,f,p)}for(const e of[...p].sort((e,t)=>e-t))r.append(e);return r}queryPolygonInclusive(e,t){if(e.length<3)throw new RangeError("vertices must contain at least three points.");const i=e.map(e=>{if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("polygon vertex theta and phi must be finite radians.");return e.toVec3()}),r=[];let s=0,o=0;for(;o<i.length;){const e=i[o],t=i[(o+1)%i.length],a=i[(o+2)%i.length],n=I(A(e,t)),l=n.dot(a);if(0===o)s=l<0?-1:1;else if(s*l<0){i.splice((o+1)%i.length,1),r.splice(o,1),o=Math.max(0,o-1);continue}r[o]=E(n,s),o+=1}const a=new Array(r.length).fill(l);if(0!==t){const e=function(e){if(e.length<2)throw new RangeError("at least two points are required to find a containing circle.");let t=I(w(e[0],e[1])),i=e[0].dot(t);for(let r=2;r<e.length;r+=1)e[r].dot(t)<i&&({center:t,cosRadius:i}=F(e,r));return{center:t,cosRadius:i}}(i);r.push(e.center),a.push(Math.acos(M(e.cosRadius,-1,1)))}return this.queryMultiDisc(r,a,t)}queryMultiDisc(e,t,i){if(e.length!==t.length)throw new RangeError("normals and radiusRad must have the same length.");if(!Number.isInteger(i)||i<0||i>0&&!T(i))throw new RangeError("fact must be zero or a positive power of two.");const r=0!==i,s=r?Math.log2(i):0,o=Math.min(c,this.order+s),n=new a,l=new Set,h=[],u=new Map,d=[];for(const e of t)if(!Number.isFinite(e)||e<0)throw new RangeError("radiusRad values must be non-negative finite numbers.");for(let i=0;i<=o;i+=1){const r=y(2**i);d[i]=e.map((e,s)=>{const o=t[s];return[o+r>Math.PI?-1:Math.cos(o+r),0===i?Math.cos(o):d[0][s][1],o-r<0?1:Math.cos(o-r)]})}for(let e=11;e>=0;e-=1)h.push({pixel:e,order:0});for(;h.length>0;){const t=h.pop();if(!t)break;let i=u.get(t.order);i||(i=t.order===this.order?this:new m(2**t.order),u.set(t.order,i));const s=i.pix2vec(t.pixel);let a=3;for(let i=0;i<e.length&&a>0;i+=1){const r=s.dot(e[i]);for(let e=0;e<a;e+=1)r<d[t.order][i][e]&&(a=e)}a>0&&this.collectDiscPixel(t.order,o,a,t.pixel,r,h,l)}for(const e of[...l].sort((e,t)=>e-t))n.append(e);return n}assertPixel(e){if(!Number.isInteger(e)||e<0||e>=this.npix)throw new RangeError("pixel must be an integer in [0, npix).")}assertXyf(e,t,i){if(!Number.isInteger(i)||i<0||i>=12)throw new RangeError("face must be an integer in [0, 11].");if(!Number.isInteger(e)||e<0||e>=this.nside)throw new RangeError("x must be an integer in [0, nside).");if(!Number.isInteger(t)||t<0||t>=this.nside)throw new RangeError("y must be an integer in [0, nside).")}pix2zphi(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=1/(3*this.nside*this.nside),o=2/(3*this.nside),a=u[r]*this.nside-t-i-1;let n,h;a<this.nside?(n=a,h=1-n*n*s):a>3*this.nside?(n=4*this.nside-a,h=n*n*s-1):(n=this.nside,h=(2*this.nside-a)*o);const c=b(d[r]*n+t-i,8*n);return{z:h,phi:v(n===this.nside?.75*l*c*o:.5*l*c/n)}}faceLocalToVec3(e,t,i){const s=u[i]-e-t;let o,a;s<1?(o=s,a=1-o*o/3):s>3?(o=4-s,a=o*o/3-1):(o=1,a=(2-s)*n);const h=b(d[i]*o+e-t,8*o),c=o<=Number.EPSILON?0:.5*l*h/o,g=Math.sqrt(Math.max(0,(1-a)*(1+a)));return new r(g*Math.cos(c),g*Math.sin(c),a)}collectDiscPixel(e,t,i,r,s,o,a){if(0!==i)if(e<this.order)if(i>=3){const t=4**(this.order-e);for(let e=r*t;e<(r+1)*t;e+=1)a.add(e)}else P(o,r,e);else{if(e>this.order){const s=Math.floor(r/4**(e-this.order));return void(i>=2||e>=t?a.add(s):P(o,r,e))}i>=2?a.add(r):s&&(e<t?P(o,r,e):a.add(r))}}}function S(e){let t=0;for(let i=0;i<=c;i+=1)t+=Math.floor(e/2**i)%2*2**(2*i);return t}function x(e){let t=0;for(let i=0;i<=c;i+=1)t+=Math.floor(e/2**(2*i))%2*2**i;return t}function v(e){return(e%h+h)%h}function b(e,t){return(e%t+t)%t}function M(e,t,i){return Math.min(i,Math.max(t,e))}function T(e){return e>0&&2**Math.floor(Math.log2(e))===e}function y(e){const t=n,i=Math.PI/(4*e),s=Math.sqrt(.5555555555555556),o=new r(s*Math.cos(i),s*Math.sin(i),t),a=1-(1-1/e)**2/3,l=new r(Math.sqrt((1-a)*(1+a)),0,a);return Math.acos(M(o.dot(l),-1,1))}function P(e,t,i){for(let r=3;r>=0;r-=1)e.push({pixel:4*t+r,order:i+1})}function w(e,t){return new r(e.x+t.x,e.y+t.y,e.z+t.z)}function C(e,t){return new r(e.x-t.x,e.y-t.y,e.z-t.z)}function E(e,t){return new r(e.x*t,e.y*t,e.z*t)}function A(e,t){return new r(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)}function I(e){return e.normalize()}function F(e,t){let i=I(w(e[0],e[t])),r=e[0].dot(i);for(let s=1;s<t;s+=1)e[s].dot(i)<r&&({center:i,cosRadius:r}=R(e,s,t));return{center:i,cosRadius:r}}function R(e,t,i){let r=I(w(e[t],e[i])),s=e[t].dot(r);for(let o=0;o<t;o+=1)e[o].dot(r)<s&&(r=I(A(C(e[t],e[o]),C(e[i],e[o]))),s=e[o].dot(r),s<0&&(r=E(r,-1),s=-s));return{center:r,cosRadius:s}}},1677(e,t,i){"use strict";i.d(t,{BinaryTableHDU:()=>p,FITSHeaderManager:()=>s,FITSParser:()=>x});class r{_key="";_value="";_comment="";constructor(e,t,i){this._key=e,this._value=t,this._comment=i}get key(){return this._key}get comment(){return this._comment}get value(){return this._value}}class s{static SIMPLE="SIMPLE";static BITPIX="BITPIX";static BZERO="BZERO";static BSCALE="BSCALE";static BLANK="BLANK";static NAXIS="NAXIS";static NAXIS1="NAXIS1";static NAXIS2="NAXIS2";static DATAMIN="DATAMIN";static DATAMAX="DATAMAX";static CRVAL1="CRVAL1";static CRVAL2="CRVAL2";static CTYPE1="CTYPE1";static CTYPE2="CTYPE2";static CRPIX1="CRPIX1";static CRPIX2="CRPIX2";static ORIGIN="ORIGIN";static COMMENT="COMMENT";static XTENSION="XTENSION";static PCOUNT="PCOUNT";static GCOUNT="GCOUNT";static TFIELDS="TFIELDS";static TFORM="TFORM";static TTYPE="TTYPE";static TUNIT="TUNIT";static TSCAL="TSCAL";static TZERO="TZERO";static TNULL="TNULL";static TBCOL="TBCOL";items=[];constructor(e=!0){e&&(this.items[0]=new r(s.SIMPLE,"T",""),this.items[1]=new r(s.BITPIX,"",""),this.items[2]=new r(s.NAXIS,2,""),this.items[3]=new r(s.NAXIS1,"",""),this.items[4]=new r(s.NAXIS2,"",""))}insert(e){e.key===s.SIMPLE?this.items[0]=e:e.key===s.BITPIX?this.items[1]=e:e.key===s.NAXIS?this.items[2]=e:e.key===s.NAXIS1?this.items[3]=e:e.key===s.NAXIS2?this.items[4]=e:this.items.push(e)}getItems(){return this.items}remove(e){this.items=this.items.filter(t=>t.key!==e)}findById(e){const t=this.items.find(t=>t.key===e);return t||null}static tableFieldKey(e,t){if(!Number.isInteger(t)||t<1)throw new RangeError(`FITS table field index must be >= 1, received ${t}.`);return`${e}${t}`}static naxisKey(e){if(!Number.isInteger(e)||e<1)throw new RangeError(`FITS axis must be a positive integer, received ${e}.`);return`NAXIS${e}`}static getFITSItemStringValue(e,t){const i=e.findById(t);return i?String(i.value).trim().replace(/^'/,"").replace(/'$/,"").trim():null}}var o=i(7223);class a{static BLOCK_SIZE=2880;static CARD_SIZE=80;static INTEGER_KEYWORDS=new Set(["BITPIX","NAXIS","PCOUNT","GCOUNT"]);static LOGICAL_KEYWORDS=new Set(["SIMPLE","EXTEND"]);static serialize(e,t){const i=e.getItems(),r=new Map(i.map(e=>[e.key.toUpperCase(),e])),s=[];return a.appendMandatoryCards(s,r,t),a.appendRemainingCards(s,i),s.push(a.card80("END")),a.encodeAndPad(s)}static appendMandatoryCards(e,t,i){if(i){const i=t.get("SIMPLE");if(!i)throw new Error("Missing mandatory SIMPLE card in Primary HDU");e.push(...a.makeKeywordWithComment("SIMPLE",i.value,i.comment))}else{const i=t.get("XTENSION");if(!i)throw new Error("Missing mandatory XTENSION card in extension HDU");e.push(...a.makeKeywordWithComment("XTENSION",i.value,i.comment))}const r=t.get("BITPIX");if(!r)throw new Error("Missing mandatory BITPIX card");e.push(...a.makeKeywordWithComment("BITPIX",r.value,r.comment));const s=t.get("NAXIS");if(!s)throw new Error("Missing mandatory NAXIS card");const o=Number(s.value);if(!Number.isInteger(o)||o<0)throw new Error(`Invalid NAXIS value: ${s.value}`);e.push(...a.makeKeywordWithComment("NAXIS",o,s.comment));for(let i=1;i<=o;i++){const r=`NAXIS${i}`,s=t.get(r);if(!s)throw new Error(`Missing mandatory ${r} card`);e.push(...a.makeKeywordWithComment(r,s.value,s.comment))}if(!i){const i=t.get("PCOUNT"),r=t.get("GCOUNT");if(!i)throw new Error("Missing mandatory PCOUNT card in extension HDU");if(!r)throw new Error("Missing mandatory GCOUNT card in extension HDU");e.push(...a.makeKeywordWithComment("PCOUNT",i.value,i.comment)),e.push(...a.makeKeywordWithComment("GCOUNT",r.value,r.comment))}if(i){const i=t.get("EXTEND");i&&e.push(...a.makeKeywordWithComment("EXTEND",i.value,i.comment))}}static appendRemainingCards(e,t){for(const i of t){const t=i.key.toUpperCase();"SIMPLE"===t||"XTENSION"===t||"BITPIX"===t||"NAXIS"===t||/^NAXIS\d+$/.test(t)||"PCOUNT"===t||"GCOUNT"===t||"EXTEND"===t||"END"===t||e.push(...a.makeKeywordWithComment(i.key,i.value,i.comment))}}static makeKeywordWithComment(e,t,i){const r=e.toUpperCase();if("END"===r)return[a.card80("END")];if("COMMENT"===r||"HISTORY"===r)return a.makeCommentCards(r,String(t??i??""));let s=a.keyword(r)+a.valueField20(r,t);if(!i||0===i.length)return[a.card80(s)];const o=` / ${i}`,n=a.CARD_SIZE-s.length;if(n<=0)return[a.card80(s),...a.makeCommentCards("COMMENT",i)];s+=o.slice(0,n);const l=o.slice(n).replace(/^\s*\/\s*/,"");return 0===l.length?[a.card80(s)]:[a.card80(s),...a.makeCommentCards("COMMENT",l)]}static makeCommentCards(e,t){const i=a.keyword(e),r=a.CARD_SIZE-i.length,s=String(t??"");if(0===s.length)return[a.card80(i)];const o=[];for(let e=0;e<s.length;e+=r)o.push(a.card80(i+s.slice(e,e+r)));return o}static valueField20(e,t){if(a.LOGICAL_KEYWORDS.has(e)){return`= ${(!0===t||"T"===t||"t"===t?"T":"F").padStart(20," ")}`}if(a.INTEGER_KEYWORDS.has(e)||/^NAXIS\d+$/.test(e)){const i=Number(t);if(!Number.isFinite(i)||!Number.isInteger(i))throw new Error(`FITS header: ${e} must be an integer, got ${t}`);return`= ${String(i).padStart(20," ")}`}if("number"==typeof t){let e=Number.isInteger(t)?String(t):t.toExponential(10).replace("e","E");return e.length>20&&(e=t.toExponential(8).replace("e","E")),`= ${e.padStart(20," ")}`}return"string"==typeof t?`= ${a.quoteFitsString(t)}`:""}static quoteFitsString(e){return`'${e.replace(/^'+|'+$/g,"").replace(/'/g,"''")}'`}static keyword(e){return(e??"").toUpperCase().padEnd(8," ").slice(0,8)}static card80(e){return e.length>=a.CARD_SIZE?e.slice(0,a.CARD_SIZE):e.padEnd(a.CARD_SIZE," ")}static encodeAndPad(e){let t=e.join("");const i=t.length%a.BLOCK_SIZE;return 0!==i&&(t+=" ".repeat(a.BLOCK_SIZE-i)),(new TextEncoder).encode(t)}}class n{static createFITS(e){const t=a.serialize(e.header,!0),i=this.createData(e.data,e.header),r=new Uint8Array(t.length+i.length);return r.set(t,0),r.set(i,t.length),r}static createHDU(e,t){const i=a.serialize(e.header,t),r=e.rawData??new Uint8Array(0);if(r.byteLength!==e.dataByteLength)throw new Error(`HDU payload length mismatch: rawData contains ${r.byteLength} bytes, but dataByteLength=${e.dataByteLength}.`);const s=n.padData(r),o=new Uint8Array(i.byteLength+s.byteLength);return o.set(i,0),o.set(s,i.byteLength),o}static padData(e){if(0===e.byteLength)return new Uint8Array(0);const t=e.byteLength%2880;if(0===t)return e.slice();const i=new Uint8Array(e.byteLength+(2880-t));return i.set(e),i}static createData(e,t){const i=e.reduce((e,t)=>e+t.length,0),r=Math.abs(Number(t.findById("BITPIX")?.value??0)),s=Number(t.findById("NAXIS")?.value??0);let o=1;for(let e=1;e<=s;e++)o*=Number(t.findById(`NAXIS${e}`)?.value??0);const a=s>0?o*(r/8):0;if(a&&a!==i)throw new Error(`Data length ${i} does not match header expectation ${a} (BITPIX=${r}, NAXIS=${s})`);let l=new Uint8Array(i),h=0;for(const t of e)l.set(t,h),h+=t.length;return n.padData(l)}static createFITSFile(e){if(0===e.length)throw new Error("Cannot write an empty FITSFile.");if(null===e.primaryHDU)throw new Error("FITSFile must start with a PrimaryHDU.");const t=e.hdus.map((e,t)=>n.createHDU(e,0===t)),i=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(i);let s=0;for(const e of t)r.set(e,s),s+=e.byteLength;return r}static writeFITSFileModel(e,t){const i=n.createFITSFile(e);o.writeFileSync(t,i)}static writeFITSFile(e,t){const i=n.createFITS(e);o.writeFileSync(t,i)}}class l{static CARD_SIZE=80;static BLOCK_SIZE=2880;static getFITSItemStringValue(e,t){const i=e.findById(t);return i?String(i.value).trim().replace(/^'/,"").replace(/'$/,"").trim():null}static getFITSItemValue(e,t){const i=e.findById(t);if(!i)return null;const r=Number(i.value);return Number.isNaN(r)?null:r}static getHeaderByteLength(e,t=0){const i=new TextDecoder("ascii");for(let r=t;r+l.CARD_SIZE<=e.byteLength;r+=l.CARD_SIZE){if("END"===i.decode(e.subarray(r,r+8)).trim()){const e=r+l.CARD_SIZE-t;return Math.ceil(e/l.BLOCK_SIZE)*l.BLOCK_SIZE}}throw new Error("Invalid FITS header: END card not found.")}static parse(e,t=0){const i=new TextDecoder("ascii"),o=l.getHeaderByteLength(e,t),a=new s(!1);for(let s=t;s<t+o;s+=l.CARD_SIZE){const t=i.decode(e.subarray(s,s+l.CARD_SIZE)),o=t.slice(0,8).trim();if("END"===o)break;if(!o)continue;let n,h="";const c=t.slice(10).trim().split("/")[0].trim();n=Number.isNaN(Number(c))?c:Number(c),t.includes("/")&&(h=t.slice(10).trim().split("/")[1]?.trim()??""),a.insert(new r(o,n,h))}return a}}class h{static getShape(e){const t=l.getFITSItemValue(e,s.NAXIS);if(null===t)throw new Error("NAXIS not defined.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid FITS NAXIS value: ${t}`);const i=[];for(let r=1;r<=t;r++){const t=l.getFITSItemValue(e,s.naxisKey(r));if(null===t)throw new Error(`NAXIS${r} not defined.`);i.push(t)}return i}static getElementCount(e){return 0===e.length?0:e.reduce((e,t)=>e*t,1)}}class c{static SUPPORTED_BITPIX=new Set([8,16,32,64,-32,-64]);static assertSupportedBITPIX(e){if(!c.SUPPORTED_BITPIX.has(e))throw new Error(`Unsupported FITS BITPIX value: ${e}`)}static extractPixelFromView(e,t,i){switch(i){case 8:return e.getUint8(t);case 16:return e.getInt16(t,!1);case 32:return e.getInt32(t,!1);case-32:return e.getFloat32(t,!1);case-64:return e.getFloat64(t,!1);case 64:{const i=e.getBigInt64(t,!1),r=Number(i);if(!Number.isSafeInteger(r))throw new RangeError(`BITPIX=64 value ${i} cannot be represented exactly as a JavaScript number.`);return r}default:throw new Error(`Unsupported FITS BITPIX value: ${i}`)}}static computePhysicalMinAndMax(e,t){const i=l.getFITSItemValue(e,s.BITPIX);if(null===i)return null;c.assertSupportedBITPIX(i);if(0===h.getShape(e).length||0===t.byteLength)return e;const o=e.findById(s.DATAMIN),a=e.findById(s.DATAMAX);if(null===o||null===a)try{const[i,n]=c.computePhysicalValues(t,e);null===o&&null!==i&&e.insert(new r(s.DATAMIN,i,"computed by jsfitsio")),null===a&&null!==n&&e.insert(new r(s.DATAMAX,n,"computed by jsfitsio"))}catch(t){if(64===i&&t instanceof RangeError)return e;throw t}return e}static createTypedArray(e,t){c.assertSupportedBITPIX(t);const i=Math.abs(t)/8;if(e.byteLength%i!==0)throw new Error(`Payload byte length ${e.byteLength} is not aligned with BITPIX=${t}.`);const r=e.byteLength/i,s=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case 8:return e.slice();case 16:{const e=new Int16Array(r);for(let t=0;t<r;t++)e[t]=s.getInt16(2*t,!1);return e}case 32:{const e=new Int32Array(r);for(let t=0;t<r;t++)e[t]=s.getInt32(4*t,!1);return e}case 64:{const e=new BigInt64Array(r);for(let t=0;t<r;t++)e[t]=s.getBigInt64(8*t,!1);return e}case-32:{const e=new Float32Array(r);for(let t=0;t<r;t++)e[t]=s.getFloat32(4*t,!1);return e}case-64:{const e=new Float64Array(r);for(let t=0;t<r;t++)e[t]=s.getFloat64(8*t,!1);return e}default:throw new Error(`Unsupported FITS BITPIX value: ${t}`)}}static computePhysicalValues(e,t){const i=l.getFITSItemValue(t,s.BITPIX);if(null===i)return[null,null];c.assertSupportedBITPIX(i);const r=h.getShape(t),o=h.getElementCount(r);if(0===o)return[null,null];const a=l.getFITSItemValue(t,s.BLANK),n=l.getFITSItemValue(t,s.BZERO)??0,u=l.getFITSItemValue(t,s.BSCALE)??1,d=Math.abs(i)/8,g=o*d;if(e.byteLength<g)throw new Error(`FITS payload is too short: expected ${g} bytes, received ${e.byteLength}.`);const _=new DataView(e.buffer,e.byteOffset,e.byteLength);let p=null,f=null;for(let e=0;e<o;e++){const t=c.extractPixelFromView(_,e*d,i);if(i>0&&null!==a&&t===a)continue;const r=c.pixel2physicalValue(t,u,n);Number.isNaN(r)||((null===p||r<p)&&(p=r),(null===f||r>f)&&(f=r))}return[p,f]}static pixel2physicalValue(e,t,i){if(null===i||null===t)throw new Error("Either BZERO or BSCALE is null");return i+t*e}static extractPixelValue(e,t,i){c.assertSupportedBITPIX(i);const r=new DataView(e.buffer,e.byteOffset,e.byteLength);return c.extractPixelFromView(r,t,i)}}class u{header;rawData;dataOffset;dataByteLength;constructor(e,t,i,r){this.header=e,this.rawData=t,this.dataOffset=i,this.dataByteLength=r}}class d extends u{bitpix;shape;typedData;type="IMAGE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.bitpix=s,this.shape=o,this.typedData=a}get naxis(){return this.shape.length}get elementCount(){return 0===this.shape.length?0:this.shape.reduce((e,t)=>e*t,1)}}class g extends d{type="PRIMARY";constructor(e,t,i,r,s,o,a){super(e,t,i,r,s,o,a)}}class _{_hdus;constructor(e=[]){this._hdus=[...e]}get hdus(){return this._hdus}get length(){return this._hdus.length}get primaryHDU(){const e=this._hdus[0];return e instanceof g?e:null}getHDU(e){return this._hdus[e]??null}addHDU(e){this._hdus.push(e)}}class p extends u{rowByteLength;rowCount;columns;type="BINTABLE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.rowByteLength=s,this.rowCount=o,this.columns=a}get columnCount(){return this.columns.length}getRowView(e){if(e<0||e>=this.rowCount)throw new RangeError(`Invalid row index ${e}.`);const t=e*this.rowByteLength;return new DataView(this.rawData.buffer,this.rawData.byteOffset+t,this.rowByteLength)}getRow(e){return this.columns.map((t,i)=>this.getCell(e,i))}getCell(e,t){const i=this.resolveColumn(t),r=this.getRowView(e),s=i.byteOffset,o=i.repeat;switch(i.type){case"CHAR":{const e=new Uint8Array(r.buffer,r.byteOffset+s,i.byteWidth);return new TextDecoder("ascii").decode(e).replace(/\s+$/,"")}case"LOGICAL":{const e=[];for(let t=0;t<o;t++){const i=String.fromCharCode(r.getUint8(s+t));e.push("T"===i)}return 1===o?e[0]:e}case"UINT8":{const e=[];for(let t=0;t<o;t++){const o=r.getUint8(s+t);e.push(this.applyNumericScaling(o,i.scale,i.zero))}return 1===o?e[0]:e}case"INT16":return this.readNumericColumn(r,s,o,2,(e,t)=>e.getInt16(t,!1),i.scale,i.zero,i.nullValue);case"INT32":return this.readNumericColumn(r,s,o,4,(e,t)=>e.getInt32(t,!1),i.scale,i.zero,i.nullValue);case"INT64":{const e=[];for(let t=0;t<o;t++){const i=r.getBigInt64(s+8*t,!1);e.push(i)}return 1===o?e[0]:e}case"FLOAT32":return this.readNumericColumn(r,s,o,4,(e,t)=>e.getFloat32(t,!1),i.scale,i.zero,null);case"FLOAT64":return this.readNumericColumn(r,s,o,8,(e,t)=>e.getFloat64(t,!1),i.scale,i.zero,null);case"COMPLEX64":{const e=[];for(let t=0;t<o;t++){const i=s+8*t;e.push({real:r.getFloat32(i,!1),imaginary:r.getFloat32(i+4,!1)})}return 1===o?e[0]:e}case"COMPLEX128":{const e=[];for(let t=0;t<o;t++){const i=s+16*t;e.push({real:r.getFloat64(i,!1),imaginary:r.getFloat64(i+8,!1)})}return 1===o?e[0]:e}case"BIT":return new Uint8Array(r.buffer,r.byteOffset+s,i.byteWidth).slice();default:throw new Error(`Unsupported BINTABLE column type: ${i.type}`)}}readNumericColumn(e,t,i,r,s,o,a,n){const l=[];for(let h=0;h<i;h++){const i=s(e,t+h*r);null===n||i!==n?l.push(this.applyNumericScaling(i,o,a)):l.push(null)}return 1===i?l[0]:l}applyNumericScaling(e,t,i){return i+t*e}resolveColumn(e){if("number"==typeof e){if(!Number.isInteger(e)||e<0||e>=this.columns.length)throw new RangeError(`Invalid column index ${e}.`);return this.columns[e]}const t=this.columns.find(t=>t.name===e);if(!t)throw new Error(`BINTABLE column '${e}' not found.`);return t}}class f{static parseTFORM(e){const t=e.trim().replace(/^'/,"").replace(/'$/,"").trim().toUpperCase().match(/^(\d*)([LXBIJKAEDCM])$/);if(!t)throw new Error(`Unsupported FITS TFORM value: ${e}`);const i=t[1]?Number(t[1]):1,r=t[2],s=f.bytesPerType(r);return{repeat:i,code:r,byteWidth:"X"===r?Math.ceil(i/8):i*s}}static bytesPerType(e){switch(e){case"L":case"B":case"A":return 1;case"I":return 2;case"J":case"E":return 4;case"K":case"D":case"C":return 8;case"M":return 16;case"X":return 0;default:throw new Error(`Unsupported FITS binary table type: ${e}`)}}}class m extends u{rowByteLength;rowCount;columns;type="TABLE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.rowByteLength=s,this.rowCount=o,this.columns=a}get columnCount(){return this.columns.length}getRowView(e){if(!Number.isInteger(e)||e<0||e>=this.rowCount)throw new RangeError(`Invalid row index ${e}.`);const t=e*this.rowByteLength;return this.rawData.subarray(t,t+this.rowByteLength)}getRowText(e){return new TextDecoder("ascii").decode(this.getRowView(e))}resolveColumn(e){if("number"==typeof e){if(!Number.isInteger(e)||e<0||e>=this.columns.length)throw new RangeError(`Invalid column index ${e}.`);return this.columns[e]}const t=this.columns.find(t=>t.name===e);if(!t)throw new Error(`ASCII TABLE column '${e}' not found.`);return t}getCell(e,t){const i=this.resolveColumn(t),r=this.getRowView(e).subarray(i.byteOffset,i.byteOffset+i.width),s=new TextDecoder("ascii").decode(r),o=s.trim();if(0===o.length)return"CHAR"===i.type?"":null;switch(i.type){case"CHAR":return s.replace(/\s+$/,"");case"INTEGER":{const e=Number.parseInt(o,10);return Number.isNaN(e)?null:e}case"FLOAT":case"EXPONENTIAL":case"DOUBLE":{const e=o.replace(/[dD]/,"E"),t=Number.parseFloat(e);return Number.isNaN(t)?null:t}default:throw new Error(`Unsupported ASCII TABLE column type: ${i.type}`)}}getRow(e){return this.columns.map((t,i)=>this.getCell(e,i))}}class S{static parseTFORM(e){const t=e.trim().replace(/^'/,"").replace(/'$/,"").trim().toUpperCase().match(/^([AIFED])(\d+)(?:\.(\d+))?$/);if(!t)throw new Error(`Unsupported FITS ASCII table TFORM value: ${e}`);const i=t[1],r=Number(t[2]),s=void 0!==t[3]?Number(t[3]):null;if(!Number.isInteger(r)||r<=0)throw new Error(`Invalid FITS ASCII table field width: ${r}`);if("A"===i||"I"===i){if(null!==s)throw new Error(`TFORM ${e} must not specify decimal places.`)}else if(null===s)throw new Error(`TFORM ${e} requires decimal places.`);return{code:i,width:r,decimals:s}}}class x{static async loadFITS(e,t={}){const i=await x.loadFITSFile(e,t);if(null===i)return null;const r=i.primaryHDU;if(null===r||null===r.rawData)return null;if(2!==h.getShape(r.header).length)throw new Error("Legacy loadFITS() supports only 2D FITS images. Use loadFITSFile() for N-dimensional images.");return{header:r.header,data:x.createMatrix(r.rawData,r.header)}}static async loadFITSFile(e,t={}){const i=await x.getFile(e);return 0===i.byteLength?null:x.processFITSFile(i,t)}static processFITSFile(e,t){const i=new _;let r=0,s=0;for(;r<e.byteLength&&!x.isPaddingOnly(e,r);){const o=l.parse(e,r),a=r+l.getHeaderByteLength(e,r);switch(x.getHDUType(o,s)){case"PRIMARY":case"IMAGE":{const n=x.getImagePayloadByteLength(o);if(a+n>e.byteLength)throw new Error(`Invalid FITS HDU ${s}: expected ${n} payload bytes at offset ${a}, but only `+(e.byteLength-a)+" remain.");const l=e.subarray(a,a+n),h=x.createImageHDU(o,l,a,n,0===s,t);i.addHDU(h);r=a+x.getPaddedByteLength(n);break}case"BINTABLE":{const t=x.getBinaryTablePayloadByteLength(o);if(a+t>e.byteLength)throw new Error(`Invalid BINTABLE HDU ${s}.`);const n=e.subarray(a,a+t),l=x.createBinaryTableHDU(o,n,a,t);i.addHDU(l),r=a+x.getPaddedByteLength(t);break}case"TABLE":{const t=x.getAsciiTablePayloadByteLength(o);if(a+t>e.byteLength)throw new Error(`Invalid ASCII TABLE HDU ${s}: expected ${t} payload bytes at offset ${a}, but only `+(e.byteLength-a)+" remain.");const n=e.subarray(a,a+t),l=x.createAsciiTableHDU(o,n,a,t);i.addHDU(l),r=a+x.getPaddedByteLength(t);break}default:throw new Error(`Unsupported FITS HDU type at index ${s}.`)}s++}return i}static getPaddedByteLength(e){return 0===e?0:Math.ceil(e/l.BLOCK_SIZE)*l.BLOCK_SIZE}static isPaddingOnly(e,t){for(let i=t;i<e.byteLength;i++){const t=e[i];if(0!==t&&32!==t)return!1}return!0}static getHDUType(e,t){if(0===t)return"PRIMARY";const i=l.getFITSItemStringValue(e,s.XTENSION);if(null===i)return"UNKNOWN";switch(i.toUpperCase()){case"IMAGE":return"IMAGE";case"BINTABLE":return"BINTABLE";case"TABLE":return"TABLE";default:return"UNKNOWN"}}static createImageHDU(e,t,i,r,o,a){const n=a.computeDataMinMax?c.computePhysicalMinAndMax(e,t)??e:e,u=l.getFITSItemValue(n,s.BITPIX);if(null===u)throw new Error("BITPIX not defined.");const _=h.getShape(n),p=c.createTypedArray(t,u);return o?new g(n,t,i,r,u,_,p):new d(n,t,i,r,u,_,p)}static getImagePayloadByteLength(e){const t=l.getFITSItemValue(e,s.BITPIX);if(null===t)throw new Error("BITPIX not defined.");c.assertSupportedBITPIX(t);const i=h.getShape(e);if(0===i.length)return 0;return i.reduce((e,t)=>e*t,1)*(Math.abs(t)/8)}static getBinaryTablePayloadByteLength(e){const t=l.getFITSItemValue(e,s.NAXIS1),i=l.getFITSItemValue(e,s.NAXIS2),r=l.getFITSItemValue(e,s.PCOUNT)??0;if(null===t||null===i)throw new Error("BINTABLE requires NAXIS1 and NAXIS2.");return t*i+r}static getBinaryTableColumns(e){const t=l.getFITSItemValue(e,s.TFIELDS);if(null===t)throw new Error("BINTABLE requires TFIELDS.");const i=[];let r=0;for(let o=1;o<=t;o++){const t=l.getFITSItemStringValue(e,s.tableFieldKey("TFORM",o));if(null===t)throw new Error(`Missing TFORM${o}.`);const a=f.parseTFORM(t),n=l.getFITSItemStringValue(e,s.tableFieldKey("TTYPE",o)),h=l.getFITSItemStringValue(e,s.tableFieldKey("TUNIT",o));i.push({index:o,name:n,format:t,type:x.mapBinaryType(a.code),repeat:a.repeat,byteOffset:r,byteWidth:a.byteWidth,unit:h,scale:l.getFITSItemValue(e,s.tableFieldKey("TSCAL",o))??1,zero:l.getFITSItemValue(e,s.tableFieldKey("TZERO",o))??0,nullValue:l.getFITSItemValue(e,s.tableFieldKey("TNULL",o))}),r+=a.byteWidth}return i}static mapBinaryType(e){switch(e.toUpperCase()){case"L":return"LOGICAL";case"X":return"BIT";case"B":return"UINT8";case"I":return"INT16";case"J":return"INT32";case"K":return"INT64";case"A":return"CHAR";case"E":return"FLOAT32";case"D":return"FLOAT64";case"C":return"COMPLEX64";case"M":return"COMPLEX128";default:return"UNKNOWN"}}static createBinaryTableHDU(e,t,i,r){const o=l.getFITSItemValue(e,s.NAXIS1),a=l.getFITSItemValue(e,s.NAXIS2);if(null===o||null===a)throw new Error("Invalid BINTABLE header.");const n=x.getBinaryTableColumns(e),h=n.reduce((e,t)=>e+t.byteWidth,0);if(h!==o)throw new Error(`BINTABLE columns occupy ${h} bytes per row, but NAXIS1=${o}.`);return new p(e,t,i,r,o,a,n)}static getAsciiTablePayloadByteLength(e){const t=l.getFITSItemValue(e,s.NAXIS1),i=l.getFITSItemValue(e,s.NAXIS2);if(null===t||null===i)throw new Error("ASCII TABLE requires NAXIS1 and NAXIS2.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid ASCII TABLE NAXIS1=${t}.`);if(!Number.isInteger(i)||i<0)throw new Error(`Invalid ASCII TABLE NAXIS2=${i}.`);const r=l.getFITSItemValue(e,s.PCOUNT)??0;if(0!==r)throw new Error(`ASCII TABLE requires PCOUNT=0, received ${r}.`);return t*i}static mapAsciiType(e){switch(e.toUpperCase()){case"A":return"CHAR";case"I":return"INTEGER";case"F":return"FLOAT";case"E":return"EXPONENTIAL";case"D":return"DOUBLE";default:return"UNKNOWN"}}static getAsciiTableColumns(e){const t=l.getFITSItemValue(e,s.TFIELDS);if(null===t)throw new Error("ASCII TABLE requires TFIELDS.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid ASCII TABLE TFIELDS=${t}.`);const i=[];for(let r=1;r<=t;r++){const t=l.getFITSItemStringValue(e,s.tableFieldKey("TFORM",r));if(null===t)throw new Error(`Missing TFORM${r}.`);const o=l.getFITSItemValue(e,s.tableFieldKey("TBCOL",r));if(null===o)throw new Error(`Missing TBCOL${r}.`);if(!Number.isInteger(o)||o<1)throw new Error(`Invalid TBCOL${r}=${o}.`);const a=S.parseTFORM(t),n=l.getFITSItemStringValue(e,s.tableFieldKey("TTYPE",r)),h=l.getFITSItemStringValue(e,s.tableFieldKey("TUNIT",r));i.push({index:r,name:n,format:t,type:x.mapAsciiType(a.code),startColumn:o,byteOffset:o-1,width:a.width,decimals:a.decimals,unit:h})}return i}static validateAsciiTableColumns(e,t){for(const i of e){const e=i.byteOffset+i.width;if(e>t)throw new Error(`ASCII TABLE column ${i.index} extends to byte ${e}, but NAXIS1=${t}.`)}}static createAsciiTableHDU(e,t,i,r){const o=l.getFITSItemValue(e,s.NAXIS1),a=l.getFITSItemValue(e,s.NAXIS2);if(null===o||null===a)throw new Error("Invalid ASCII TABLE header.");const n=x.getAsciiTableColumns(e);return x.validateAsciiTableColumns(n,o),new m(e,t,i,r,o,a,n)}static createMatrix(e,t){const i=l.getFITSItemValue(t,s.NAXIS1);if(null===i)throw new Error("NAXIS1 not defined.");const r=l.getFITSItemValue(t,s.NAXIS2);if(null===r)throw new Error("NAXIS2 not defined.");const o=l.getFITSItemValue(t,s.BITPIX);if(null===o)throw new Error("BITPIX not defined.");const a=Math.abs(o/8),n=[];for(let t=0;t<r;t++)n.push(e.slice(t*i*a,(t+1)*i*a));return n}static saveFITSLocally(e,t){return n.writeFITSFile(e,t)}static async getFile(e){if(e.substring(0,5).toLowerCase().includes("http")){const t=await i.e(911).then(i.bind(i,1911)),r=await t.getFile(e);if(r?.byteLength){return new Uint8Array(r)}return new Uint8Array(0)}{const t=await i.e(64).then(i.bind(i,7064)),r=await t.getLocalFile(e);if(r?.length){return new Uint8Array(r)}return new Uint8Array(0)}}}}};const t={};function i(r){const s=t[r];if(void 0!==s)return s.exports;const o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,i),o.exports}return i.m=e,i.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var s=t[r++],o=t[r++];i.o(e,s)?0===o&&r++:0===o?Object.defineProperty(e,s,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,s,{enumerable:!0,get:o})}else for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>e+".astroviewer.min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e={},t="astroviewer:";i.l=(r,s,o,a)=>{if(e[r])return void e[r].push(s);let n,l;if(void 0!==o){const e=document.getElementsByTagName("script");for(var h=0;h<e.length;h++){const i=e[h];if(i.getAttribute("src")==r||i.getAttribute("data-webpack")==t+o){n=i;break}}}n||(l=!0,n=document.createElement("script"),n.charset="utf-8",i.nc&&n.setAttribute("nonce",i.nc),n.setAttribute("data-webpack",t+o),n.src=r),e[r]=[s];const c=(t,i)=>{n.onerror=n.onload=null,clearTimeout(u);const s=e[r];if(delete e[r],n.parentNode?.removeChild(n),s?.forEach(e=>e(i)),t)return t(i)},u=setTimeout(c.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=c.bind(null,n.onerror),n.onload=c.bind(null,n.onload),l&&document.head.appendChild(n)}})(),i.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{let e;i.g.importScripts&&(e=i.g.location+"");const t=i.g.document;if(!e&&t&&("SCRIPT"===t.currentScript?.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){const i=t.getElementsByTagName("script");if(i.length){let t=i.length-1;for(;t>-1&&(!e||!/^http(s?):/.test(e));)e=i[t--].src}}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{const e={792:0};i.f.j=(t,r)=>{let s=i.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else{const o=new Promise((i,r)=>s=e[t]=[i,r]);r.push(s[2]=o);const a=i.p+i.u(t),n=new Error,l=r=>{if(i.o(e,t)&&(s=e[t],0!==s&&(e[t]=void 0),s)){const e=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;n.message="Loading chunk "+t+" failed.\n("+e+": "+i+")",n.name="ChunkLoadError",n.type=e,n.request=i,n.event=r,s[1](n)}};i.l(a,l,"chunk-"+t,t)}};const t=(t,r)=>{let[s,o,a]=r;var n,l,h=0;if(s.some(t=>0!==e[t])){for(n in o)i.o(o,n)&&(i.m[n]=o[n]);if(a)a(i)}for(t&&t(r);h<s.length;h++)l=s[h],i.o(e,l)&&e[l]&&e[l][0](),e[l]=0},r=self.webpackChunkastroviewer=self.webpackChunkastroviewer||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),i(1229)})());
|
|
2
2
|
//# sourceMappingURL=astroviewer.min.js.map
|