astro-viewer 1.3.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 +373 -0
- package/dist/astroviewer.cjs +13941 -0
- package/dist/astroviewer.cjs.map +1 -0
- package/dist/astroviewer.js +2 -0
- package/dist/astroviewer.js.map +1 -0
- package/dist/astroviewer.min.js +2 -0
- package/dist/astroviewer.min.js.map +1 -0
- package/lib-esm/AstroSphere.d.ts +114 -0
- package/lib-esm/AstroSphere.d.ts.map +1 -0
- package/lib-esm/AstroSphere.js +679 -0
- package/lib-esm/AstroSphere.js.map +1 -0
- package/lib-esm/AstroViewer.d.ts +81 -0
- package/lib-esm/AstroViewer.d.ts.map +1 -0
- package/lib-esm/AstroViewer.js +348 -0
- package/lib-esm/AstroViewer.js.map +1 -0
- package/lib-esm/Camera.d.ts +74 -0
- package/lib-esm/Camera.d.ts.map +1 -0
- package/lib-esm/Camera.js +334 -0
- package/lib-esm/Camera.js.map +1 -0
- package/lib-esm/Config.d.ts +20 -0
- package/lib-esm/Config.d.ts.map +1 -0
- package/lib-esm/Config.js +32 -0
- package/lib-esm/Config.js.map +1 -0
- package/lib-esm/Global.d.ts +27 -0
- package/lib-esm/Global.d.ts.map +1 -0
- package/lib-esm/Global.js +52 -0
- package/lib-esm/Global.js.map +1 -0
- package/lib-esm/index.d.ts +17 -0
- package/lib-esm/index.d.ts.map +1 -0
- package/lib-esm/index.js +16 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/model/AbstractSkyEntity.d.ts +55 -0
- package/lib-esm/model/AbstractSkyEntity.d.ts.map +1 -0
- package/lib-esm/model/AbstractSkyEntity.js +153 -0
- package/lib-esm/model/AbstractSkyEntity.js.map +1 -0
- package/lib-esm/model/AstroGL.d.ts +11 -0
- package/lib-esm/model/AstroGL.d.ts.map +1 -0
- package/lib-esm/model/AstroGL.js +2 -0
- package/lib-esm/model/AstroGL.js.map +1 -0
- package/lib-esm/model/ColorMaps.d.ts +17 -0
- package/lib-esm/model/ColorMaps.d.ts.map +1 -0
- package/lib-esm/model/ColorMaps.js +1288 -0
- package/lib-esm/model/ColorMaps.js.map +1 -0
- package/lib-esm/model/FoV.d.ts +63 -0
- package/lib-esm/model/FoV.d.ts.map +1 -0
- package/lib-esm/model/FoV.js +275 -0
- package/lib-esm/model/FoV.js.map +1 -0
- package/lib-esm/model/MetadataColumn.d.ts +50 -0
- package/lib-esm/model/MetadataColumn.d.ts.map +1 -0
- package/lib-esm/model/MetadataColumn.js +95 -0
- package/lib-esm/model/MetadataColumn.js.map +1 -0
- package/lib-esm/model/MetadataManager.d.ts +43 -0
- package/lib-esm/model/MetadataManager.d.ts.map +1 -0
- package/lib-esm/model/MetadataManager.js +117 -0
- package/lib-esm/model/MetadataManager.js.map +1 -0
- package/lib-esm/model/Point.d.ts +53 -0
- package/lib-esm/model/Point.d.ts.map +1 -0
- package/lib-esm/model/Point.js +133 -0
- package/lib-esm/model/Point.js.map +1 -0
- package/lib-esm/model/Point2D.d.ts +9 -0
- package/lib-esm/model/Point2D.d.ts.map +1 -0
- package/lib-esm/model/Point2D.js +16 -0
- package/lib-esm/model/Point2D.js.map +1 -0
- package/lib-esm/model/Source.d.ts +34 -0
- package/lib-esm/model/Source.d.ts.map +1 -0
- package/lib-esm/model/Source.js +63 -0
- package/lib-esm/model/Source.js.map +1 -0
- package/lib-esm/model/catalogues/CatalogueGL.d.ts +91 -0
- package/lib-esm/model/catalogues/CatalogueGL.d.ts.map +1 -0
- package/lib-esm/model/catalogues/CatalogueGL.js +614 -0
- package/lib-esm/model/catalogues/CatalogueGL.js.map +1 -0
- package/lib-esm/model/catalogues/CatalogueProps.d.ts +2 -0
- package/lib-esm/model/catalogues/CatalogueProps.d.ts.map +1 -0
- package/lib-esm/model/catalogues/CatalogueProps.js +156 -0
- package/lib-esm/model/catalogues/CatalogueProps.js.map +1 -0
- package/lib-esm/model/footprints/Footprint.d.ts +44 -0
- package/lib-esm/model/footprints/Footprint.d.ts.map +1 -0
- package/lib-esm/model/footprints/Footprint.js +104 -0
- package/lib-esm/model/footprints/Footprint.js.map +1 -0
- package/lib-esm/model/footprints/FootprintProps.d.ts +2 -0
- package/lib-esm/model/footprints/FootprintProps.d.ts.map +1 -0
- package/lib-esm/model/footprints/FootprintProps.js +87 -0
- package/lib-esm/model/footprints/FootprintProps.js.map +1 -0
- package/lib-esm/model/footprints/FootprintSetGL.d.ts +106 -0
- package/lib-esm/model/footprints/FootprintSetGL.d.ts.map +1 -0
- package/lib-esm/model/footprints/FootprintSetGL.js +592 -0
- package/lib-esm/model/footprints/FootprintSetGL.js.map +1 -0
- package/lib-esm/model/grid/EquatorialGrid.d.ts +49 -0
- package/lib-esm/model/grid/EquatorialGrid.d.ts.map +1 -0
- package/lib-esm/model/grid/EquatorialGrid.js +302 -0
- package/lib-esm/model/grid/EquatorialGrid.js.map +1 -0
- package/lib-esm/model/grid/GridTextHelper.d.ts +26 -0
- package/lib-esm/model/grid/GridTextHelper.d.ts.map +1 -0
- package/lib-esm/model/grid/GridTextHelper.js +92 -0
- package/lib-esm/model/grid/GridTextHelper.js.map +1 -0
- package/lib-esm/model/grid/HealpixGrid.d.ts +49 -0
- package/lib-esm/model/grid/HealpixGrid.d.ts.map +1 -0
- package/lib-esm/model/grid/HealpixGrid.js +306 -0
- package/lib-esm/model/grid/HealpixGrid.js.map +1 -0
- package/lib-esm/model/hips/AllSky.d.ts +40 -0
- package/lib-esm/model/hips/AllSky.d.ts.map +1 -0
- package/lib-esm/model/hips/AllSky.js +232 -0
- package/lib-esm/model/hips/AllSky.js.map +1 -0
- package/lib-esm/model/hips/AncestorTile.d.ts +38 -0
- package/lib-esm/model/hips/AncestorTile.d.ts.map +1 -0
- package/lib-esm/model/hips/AncestorTile.js +248 -0
- package/lib-esm/model/hips/AncestorTile.js.map +1 -0
- package/lib-esm/model/hips/FoVHelper.d.ts +11 -0
- package/lib-esm/model/hips/FoVHelper.d.ts.map +1 -0
- package/lib-esm/model/hips/FoVHelper.js +107 -0
- package/lib-esm/model/hips/FoVHelper.js.map +1 -0
- package/lib-esm/model/hips/HiPS.d.ts +47 -0
- package/lib-esm/model/hips/HiPS.d.ts.map +1 -0
- package/lib-esm/model/hips/HiPS.js +222 -0
- package/lib-esm/model/hips/HiPS.js.map +1 -0
- package/lib-esm/model/hips/HiPSDescriptor.d.ts +37 -0
- package/lib-esm/model/hips/HiPSDescriptor.d.ts.map +1 -0
- package/lib-esm/model/hips/HiPSDescriptor.js +132 -0
- package/lib-esm/model/hips/HiPSDescriptor.js.map +1 -0
- package/lib-esm/model/hips/Tile.d.ts +51 -0
- package/lib-esm/model/hips/Tile.d.ts.map +1 -0
- package/lib-esm/model/hips/Tile.js +355 -0
- package/lib-esm/model/hips/Tile.js.map +1 -0
- package/lib-esm/model/hips/TileBuffer.d.ts +39 -0
- package/lib-esm/model/hips/TileBuffer.d.ts.map +1 -0
- package/lib-esm/model/hips/TileBuffer.js +148 -0
- package/lib-esm/model/hips/TileBuffer.js.map +1 -0
- package/lib-esm/model/hips/VisibleTilesManager.d.ts +35 -0
- package/lib-esm/model/hips/VisibleTilesManager.d.ts.map +1 -0
- package/lib-esm/model/hips/VisibleTilesManager.js +160 -0
- package/lib-esm/model/hips/VisibleTilesManager.js.map +1 -0
- package/lib-esm/model/tap/TapMetadata.d.ts +31 -0
- package/lib-esm/model/tap/TapMetadata.d.ts.map +1 -0
- package/lib-esm/model/tap/TapMetadata.js +55 -0
- package/lib-esm/model/tap/TapMetadata.js.map +1 -0
- package/lib-esm/model/tap/TapMetadataList.d.ts +23 -0
- package/lib-esm/model/tap/TapMetadataList.d.ts.map +1 -0
- package/lib-esm/model/tap/TapMetadataList.js +58 -0
- package/lib-esm/model/tap/TapMetadataList.js.map +1 -0
- package/lib-esm/model/tap/TapRepo.d.ts +27 -0
- package/lib-esm/model/tap/TapRepo.d.ts.map +1 -0
- package/lib-esm/model/tap/TapRepo.js +51 -0
- package/lib-esm/model/tap/TapRepo.js.map +1 -0
- package/lib-esm/services/SesameService.d.ts +14 -0
- package/lib-esm/services/SesameService.d.ts.map +1 -0
- package/lib-esm/services/SesameService.js +54 -0
- package/lib-esm/services/SesameService.js.map +1 -0
- package/lib-esm/services/helpers.d.ts +5 -0
- package/lib-esm/services/helpers.d.ts.map +1 -0
- package/lib-esm/services/helpers.js +16 -0
- package/lib-esm/services/helpers.js.map +1 -0
- package/lib-esm/services/hipsNodeService.d.ts +7 -0
- package/lib-esm/services/hipsNodeService.d.ts.map +1 -0
- package/lib-esm/services/hipsNodeService.js +65 -0
- package/lib-esm/services/hipsNodeService.js.map +1 -0
- package/lib-esm/services/parse-hipslist.d.ts +3 -0
- package/lib-esm/services/parse-hipslist.d.ts.map +1 -0
- package/lib-esm/services/parse-hipslist.js +25 -0
- package/lib-esm/services/parse-hipslist.js.map +1 -0
- package/lib-esm/services/queryCatalogueByFoV.d.ts +2 -0
- package/lib-esm/services/queryCatalogueByFoV.d.ts.map +1 -0
- package/lib-esm/services/queryCatalogueByFoV.js +56 -0
- package/lib-esm/services/queryCatalogueByFoV.js.map +1 -0
- package/lib-esm/services/queryFootprintSetByFov.d.ts +2 -0
- package/lib-esm/services/queryFootprintSetByFov.d.ts.map +1 -0
- package/lib-esm/services/queryFootprintSetByFov.js +128 -0
- package/lib-esm/services/queryFootprintSetByFov.js.map +1 -0
- package/lib-esm/services/tapRepoService.d.ts +2 -0
- package/lib-esm/services/tapRepoService.d.ts.map +1 -0
- package/lib-esm/services/tapRepoService.js +190 -0
- package/lib-esm/services/tapRepoService.js.map +1 -0
- package/lib-esm/services/types.d.ts +13 -0
- package/lib-esm/services/types.d.ts.map +1 -0
- package/lib-esm/services/types.js +2 -0
- package/lib-esm/services/types.js.map +1 -0
- package/lib-esm/shader/CatalogueShaderProgram.d.ts +35 -0
- package/lib-esm/shader/CatalogueShaderProgram.d.ts.map +1 -0
- package/lib-esm/shader/CatalogueShaderProgram.js +94 -0
- package/lib-esm/shader/CatalogueShaderProgram.js.map +1 -0
- package/lib-esm/shader/FootprintShaderProgram.d.ts +31 -0
- package/lib-esm/shader/FootprintShaderProgram.d.ts.map +1 -0
- package/lib-esm/shader/FootprintShaderProgram.js +86 -0
- package/lib-esm/shader/FootprintShaderProgram.js.map +1 -0
- package/lib-esm/shader/GridShaderManager.d.ts +6 -0
- package/lib-esm/shader/GridShaderManager.d.ts.map +1 -0
- package/lib-esm/shader/GridShaderManager.js +29 -0
- package/lib-esm/shader/GridShaderManager.js.map +1 -0
- package/lib-esm/shader/HiPSShaderProgram.d.ts +54 -0
- package/lib-esm/shader/HiPSShaderProgram.d.ts.map +1 -0
- package/lib-esm/shader/HiPSShaderProgram.js +257 -0
- package/lib-esm/shader/HiPSShaderProgram.js.map +1 -0
- package/lib-esm/shader/ShaderManager.d.ts +12 -0
- package/lib-esm/shader/ShaderManager.d.ts.map +1 -0
- package/lib-esm/shader/ShaderManager.js +344 -0
- package/lib-esm/shader/ShaderManager.js.map +1 -0
- package/lib-esm/shader/ShaderManagerMutliHiPS.d.ts +12 -0
- package/lib-esm/shader/ShaderManagerMutliHiPS.d.ts.map +1 -0
- package/lib-esm/shader/ShaderManagerMutliHiPS.js +750 -0
- package/lib-esm/shader/ShaderManagerMutliHiPS.js.map +1 -0
- package/lib-esm/utils/CoordsType.d.ts +10 -0
- package/lib-esm/utils/CoordsType.d.ts.map +1 -0
- package/lib-esm/utils/CoordsType.js +12 -0
- package/lib-esm/utils/CoordsType.js.map +1 -0
- package/lib-esm/utils/FoVUtils.d.ts +46 -0
- package/lib-esm/utils/FoVUtils.d.ts.map +1 -0
- package/lib-esm/utils/FoVUtils.js +217 -0
- package/lib-esm/utils/FoVUtils.js.map +1 -0
- package/lib-esm/utils/GeomUtils.d.ts +36 -0
- package/lib-esm/utils/GeomUtils.d.ts.map +1 -0
- package/lib-esm/utils/GeomUtils.js +267 -0
- package/lib-esm/utils/GeomUtils.js.map +1 -0
- package/lib-esm/utils/MouseHelper.d.ts +36 -0
- package/lib-esm/utils/MouseHelper.d.ts.map +1 -0
- package/lib-esm/utils/MouseHelper.js +94 -0
- package/lib-esm/utils/MouseHelper.js.map +1 -0
- package/lib-esm/utils/PerspectiveMatrixManager.d.ts +11 -0
- package/lib-esm/utils/PerspectiveMatrixManager.d.ts.map +1 -0
- package/lib-esm/utils/PerspectiveMatrixManager.js +37 -0
- package/lib-esm/utils/PerspectiveMatrixManager.js.map +1 -0
- package/lib-esm/utils/RayPickingUtils.d.ts +30 -0
- package/lib-esm/utils/RayPickingUtils.d.ts.map +1 -0
- package/lib-esm/utils/RayPickingUtils.js +112 -0
- package/lib-esm/utils/RayPickingUtils.js.map +1 -0
- package/lib-esm/utils/STCSParser.d.ts +16 -0
- package/lib-esm/utils/STCSParser.d.ts.map +1 -0
- package/lib-esm/utils/STCSParser.js +96 -0
- package/lib-esm/utils/STCSParser.js.map +1 -0
- package/lib-esm/utils/ShaderUtility.d.ts +2 -0
- package/lib-esm/utils/ShaderUtility.d.ts.map +1 -0
- package/lib-esm/utils/ShaderUtility.js +23 -0
- package/lib-esm/utils/ShaderUtility.js.map +1 -0
- package/lib-esm/utils/Utils.d.ts +32 -0
- package/lib-esm/utils/Utils.d.ts.map +1 -0
- package/lib-esm/utils/Utils.js +77 -0
- package/lib-esm/utils/Utils.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +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,()=>(()=>{"use strict";var e={d:(t,i)=>{for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AstroViewer:()=>Ve,COLOR_MAP_SAMPLE_COUNT:()=>Z,CatalogueGL:()=>Fe,ColorMaps:()=>K,ColumnType:()=>Ee,CoordsType:()=>ne,FoV:()=>ge,FoVUtils:()=>le,Footprint:()=>Be,FootprintSetGL:()=>Ne,HiPS:()=>oe,HiPSDescriptor:()=>ye,MetadataColumn:()=>Te,MetadataManager:()=>Ie,Point:()=>he,Source:()=>Ae,createColorMapFromSamples:()=>Q});const i=!1,s=34,r=(Math.PI,1e-5);var o="undefined"!=typeof Float32Array?Float32Array:Array;function a(){var e=new o(3);return o!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function n(e){var t=new o(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function h(e){var t=e[0],i=e[1],s=e[2];return Math.sqrt(t*t+i*i+s*s)}function l(e,t,i){var s=new o(3);return s[0]=e,s[1]=t,s[2]=i,s}function c(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function d(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function u(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function _(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function g(e,t,i){var s=t[0],r=t[1],o=t[2],a=i[3]*s+i[7]*r+i[11]*o+i[15];return a=a||1,e[0]=(i[0]*s+i[4]*r+i[8]*o+i[12])/a,e[1]=(i[1]*s+i[5]*r+i[9]*o+i[13])/a,e[2]=(i[2]*s+i[6]*r+i[10]*o+i[14])/a,e}function p(){var e=new o(16);return o!=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 f(e,t,i,s,r,o,a,n,h,l,c,d,u,_,g,p,f){return e[0]=t,e[1]=i,e[2]=s,e[3]=r,e[4]=o,e[5]=a,e[6]=n,e[7]=h,e[8]=l,e[9]=c,e[10]=d,e[11]=u,e[12]=_,e[13]=g,e[14]=p,e[15]=f,e}function m(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 x(e,t){var i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],n=t[5],h=t[6],l=t[7],c=t[8],d=t[9],u=t[10],_=t[11],g=t[12],p=t[13],f=t[14],m=t[15],x=i*n-s*a,v=i*h-r*a,S=i*l-o*a,b=s*h-r*n,M=s*l-o*n,P=r*l-o*h,w=c*p-d*g,y=c*f-u*g,A=c*m-_*g,C=d*f-u*p,E=d*m-_*p,T=u*m-_*f,I=x*T-v*E+S*C+b*A-M*y+P*w;return I?(I=1/I,e[0]=(n*T-h*E+l*C)*I,e[1]=(r*E-s*T-o*C)*I,e[2]=(p*P-f*M+m*b)*I,e[3]=(u*M-d*P-_*b)*I,e[4]=(h*A-a*T-l*y)*I,e[5]=(i*T-r*A+o*y)*I,e[6]=(f*S-g*P-m*v)*I,e[7]=(c*P-u*S+_*v)*I,e[8]=(a*E-n*A+l*w)*I,e[9]=(s*A-i*E-o*w)*I,e[10]=(g*M-p*S+m*x)*I,e[11]=(d*S-c*M-_*x)*I,e[12]=(n*y-a*C-h*w)*I,e[13]=(i*C-s*y+r*w)*I,e[14]=(p*v-g*b-f*x)*I,e[15]=(c*b-d*v+u*x)*I,e):null}function v(e,t,i){var s=t[0],r=t[1],o=t[2],a=t[3],n=t[4],h=t[5],l=t[6],c=t[7],d=t[8],u=t[9],_=t[10],g=t[11],p=t[12],f=t[13],m=t[14],x=t[15],v=i[0],S=i[1],b=i[2],M=i[3];return e[0]=v*s+S*n+b*d+M*p,e[1]=v*r+S*h+b*u+M*f,e[2]=v*o+S*l+b*_+M*m,e[3]=v*a+S*c+b*g+M*x,v=i[4],S=i[5],b=i[6],M=i[7],e[4]=v*s+S*n+b*d+M*p,e[5]=v*r+S*h+b*u+M*f,e[6]=v*o+S*l+b*_+M*m,e[7]=v*a+S*c+b*g+M*x,v=i[8],S=i[9],b=i[10],M=i[11],e[8]=v*s+S*n+b*d+M*p,e[9]=v*r+S*h+b*u+M*f,e[10]=v*o+S*l+b*_+M*m,e[11]=v*a+S*c+b*g+M*x,v=i[12],S=i[13],b=i[14],M=i[15],e[12]=v*s+S*n+b*d+M*p,e[13]=v*r+S*h+b*u+M*f,e[14]=v*o+S*l+b*_+M*m,e[15]=v*a+S*c+b*g+M*x,e}function S(e,t,i){var s,r,o,a,n,h,l,c,d,u,_,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]):(s=t[0],r=t[1],o=t[2],a=t[3],n=t[4],h=t[5],l=t[6],c=t[7],d=t[8],u=t[9],_=t[10],g=t[11],e[0]=s,e[1]=r,e[2]=o,e[3]=a,e[4]=n,e[5]=h,e[6]=l,e[7]=c,e[8]=d,e[9]=u,e[10]=_,e[11]=g,e[12]=s*p+n*f+d*m+t[12],e[13]=r*p+h*f+u*m+t[13],e[14]=o*p+l*f+_*m+t[14],e[15]=a*p+c*f+g*m+t[15]),e}function b(e,t,i,s){var r,o,a,n,h,l,c,d,u,_,g,p,f,m,x,v,S,b,M,P,w,y,A,C,E=s[0],T=s[1],I=s[2],F=Math.sqrt(E*E+T*T+I*I);return F<1e-6?null:(E*=F=1/F,T*=F,I*=F,r=Math.sin(i),a=1-(o=Math.cos(i)),n=t[0],h=t[1],l=t[2],c=t[3],d=t[4],u=t[5],_=t[6],g=t[7],p=t[8],f=t[9],m=t[10],x=t[11],v=E*E*a+o,S=T*E*a+I*r,b=I*E*a-T*r,M=E*T*a-I*r,P=T*T*a+o,w=I*T*a+E*r,y=E*I*a+T*r,A=T*I*a-E*r,C=I*I*a+o,e[0]=n*v+d*S+p*b,e[1]=h*v+u*S+f*b,e[2]=l*v+_*S+m*b,e[3]=c*v+g*S+x*b,e[4]=n*M+d*P+p*w,e[5]=h*M+u*P+f*w,e[6]=l*M+_*P+m*w,e[7]=c*M+g*P+x*w,e[8]=n*y+d*A+p*C,e[9]=h*y+u*A+f*C,e[10]=l*y+_*A+m*C,e[11]=c*y+g*A+x*C,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}Math.random,Math.PI,Math.PI,a();function M(e){const t=_(e,e),i=Math.sqrt(t);let s=Math.acos(e[2]/i);s=y(s);let r=Math.atan2(e[1],e[0]);return r=y(r),r<0&&(r+=360),{phi:r,theta:s}}function P(e){const t=e.substring(1,3),i=e.substring(3,5),s=e.substring(5,7),r=parseInt(t,16),o=parseInt(i,16),a=parseInt(s,16),n=(r/255).toFixed(2),h=(o/255).toFixed(2),l=(a/255).toFixed(2);return[parseFloat(n),parseFloat(h),parseFloat(l)]}function w(e){return e/180*Math.PI}function y(e){return 180*e/Math.PI}function A(e,t){let i=e;return i<0&&(i+=360),{ra:i,dec:90-t}}function C(e,t,i=1){return[i*Math.sin(w(t))*Math.cos(w(e)),i*Math.sin(w(t))*Math.sin(w(e)),i*Math.cos(w(t))]}function E(e,t){let i=e;return i<0&&(i+=360),{phi:i,theta:90-t}}function T(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)}}function I(e){let t=1;e<0&&(t=-1);const i=Math.abs(e);let s=Math.trunc(i);const r=Math.trunc(60*(i-s)),o=3600*(i-s-r/60);return s*=t,{d:s,m:r,s:o}}class F{}F.halfpi=1.5707963267948966,F.inv_halfpi=2/Math.PI,F.twopi=2*Math.PI,F.inv_twopi=1/(2*Math.PI);class R{constructor(e,t,i,s){null!=e?(this.theta=B.atan2(Math.sqrt(e.x*e.x+e.y*e.y),e.z),this.phi=t?-B.atan2(e.y,e.x):B.atan2(e.y,e.x),this.phi<0&&(this.phi=this.phi+2*Math.PI),this.phi>=2*Math.PI&&(this.phi=this.phi-2*Math.PI)):(this.theta=i,this.phi=s)}}class D{constructor(e,t){this.z=e,this.phi=t}}class B{constructor(e){B.PI4_A=.7853981554508209,B.PI4_B=7.946627356147928e-9,B.PI4_C=3061616997868383e-32,B.M_1_PI=.3183098861837907,e&&(this.sth=0,this.have_sth=!1,this.z=B.cos(e.theta),this._phi=e.phi,Math.abs(this.z)>.99&&(this.sth=B.sin(e.theta),this.have_sth=!0))}setZ(e){this.z=e}get phi(){return this._phi}set phi(e){this._phi=e}setSth(e){this.sth=e}toPointing(e){const t=this.have_sth?this.sth:Math.sqrt((1-this.z)*(1+this.z));return new R(null,!1,B.atan2(t,this.z),this._phi)}toVec3(){var e=this.have_sth?this.sth:Math.sqrt((1-this.z)*(1+this.z));return new L(e*B.cos(this.phi),e*B.sin(this.phi),this.z)}toZphi(){return new D(this.z,this.phi)}static sin(e){let t=e*B.M_1_PI,i=Math.floor(t<0?t-.5:t+.5),s=4*i;return e-=s*B.PI4_A,e-=s*B.PI4_B,e-=s*B.PI4_C,1&i&&(e=-e),this.sincoshelper(e)}static cos(e){let t=e*B.M_1_PI-.5,i=1+2*Math.floor(t<0?t-.5:t+.5),s=2*i;return e-=s*B.PI4_A,e-=s*B.PI4_B,e-=s*B.PI4_C,2&i||(e=-e),B.sincoshelper(e)}static sincoshelper(e){let t=e*e,i=-7972559550090379e-33;return i=i*t+2810099727108632e-30,i=i*t-7647122191181588e-28,i=i*t+1.605904306056645e-10,i=i*t-2.5052108376350205e-8,i=i*t+27557319223919875e-22,i=i*t-.00019841269841269616,i=i*t+.00833333333333333,i=i*t-.16666666666666666,t*i*e+e}static asin(e){return B.mulsign(B.atan2k(Math.abs(e),Math.sqrt((1+e)*(1-e))),e)}static acos(e){return B.mulsign(B.atan2k(Math.sqrt((1+e)*(1-e)),Math.abs(e)),e)+(e<0?Math.PI:0)}static mulsign(e,t){return B.copySign(1,t)*e}static copySign(e,t){return t<0?-Math.abs(e):Math.abs(e)}static atanhelper(e){let t=e*e,i=-1887960084630735e-20;return i=i*t+.00020985007664581698,i=i*t-.0011061183148667248,i=i*t+.003700267441887131,i=i*t-.008898961958876555,i=i*t+.016599329773529202,i=i*t-.025451762493231264,i=i*t+.03378525800013531,i=i*t-.04076291912768365,i=i*t+.04666671500778406,i=i*t-.052367485230348246,i=i*t+.05876663929266736,i=i*t-.06665735793610805,i=i*t+.07692195383117696,i=i*t-.09090899500824501,i=i*t+.11111110564826142,i=i*t-.1428571426677133,i=i*t+.19999999999659127,i=i*t-.3333333333333111,i*t*e+e}static atan2k(e,t){let i=0;if(t<0&&(t=-t,i=-2),e>t){let s=t;t=e,e=-s,i+=1}return B.atanhelper(e/t)+i*(Math.PI/2)}static atan2(e,t){let i=B.atan2k(Math.abs(e),t);return i=B.mulsign(i,t),(B.isinf(t)||0==t)&&(i=Math.PI/2-(B.isinf(t)?B.copySign(1,t)*(Math.PI/2):0)),B.isinf(e)&&(i=Math.PI/2-(B.isinf(t)?B.copySign(1,t)*(1*Math.PI/4):0)),0==e&&(i=-1==B.copySign(1,t)?Math.PI:0),B.isnan(t)||B.isnan(e)?NaN:B.mulsign(i,e)}static isnan(e){return e!=e}static isinf(e){return Math.abs(e)===1/0}}B.PI4_A=.7853981554508209,B.PI4_B=7.946627356147928e-9,B.PI4_C=3061616997868383e-32,B.M_1_PI=.3183098861837907;class L{constructor(e,t,i){if(e instanceof R){let t=e,i=B.sin(t.theta);this.x=i*B.cos(t.phi),this.y=i*B.sin(t.phi),this.z=B.cos(t.theta)}else this.x=e,this.y=t,this.z=i}getX(){return this.x}getY(){return this.y}getZ(){return this.z}scale(e){this.x*=e,this.y*=e,this.z*=e}cross(e){return new L(this.y*e.z-e.y*this.z,this.z*e.x-e.z*this.x,this.x*e.y-e.x*this.y)}add(e){return new L(this.x+e.x,this.y+e.y,this.z+e.z)}normalize(){let e=1/this.length();this.x*=e,this.y*=e,this.z*=e}norm(){let e=1/this.length();return new L(this.x*e,this.y*e,this.z*e)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}sub(e){return new L(this.x-e.x,this.y-e.y,this.z-e.z)}angle(e){return B.atan2(this.cross(e).length(),this.dot(e))}flip(){this.x*=-1,this.y*=-1,this.z*=-1}static pointing2Vec3(e){let t=B.sin(e.theta),i=t*B.cos(e.phi),s=t*B.sin(e.phi),r=B.cos(e.theta);return new L(i,s,r)}}class N{constructor(e){let t=e.length;if(t>=2){this.center=e[0].add(e[1]),this.center.normalize(),this.cosrad=e[0].dot(this.center);for(let i=2;i<t;++i)e[i].dot(this.center)<this.cosrad&&this.getCircle(e,i)}else console.log("too few points")}getCircle(e,t){this.center=e[0].add(e[t]),this.center.normalize(),this.cosrad=e[0].dot(this.center);for(let i=1;i<t;++i)e[i].dot(this.center)<this.cosrad&&this.getCircle2(e,i,t)}getCircle2(e,t,i){this.center=e[t].add(e[i]),this.center.normalize(),this.cosrad=e[t].dot(this.center);for(let s=0;s<t;++s)e[s].dot(this.center)<this.cosrad&&(this.center=e[t].sub(e[s]).cross(e[i].sub(e[s])),this.center.normalize(),this.cosrad=e[s].dot(this.center),this.cosrad<0&&(this.center.flip(),this.cosrad=-this.cosrad))}getCenter(){return new L(this.center.x,this.center.y,this.center.z)}getCosrad(){return this.cosrad}}class V{constructor(e,t,i){this.fx=e,this.fy=t,this.face=i,this.jrll=new Uint8Array([2,2,2,2,3,3,3,3,4,4,4,4]),this.jpll=new Uint8Array([1,3,5,7,0,2,4,6,1,3,5,7]),this.halfpi=Math.PI/2}toHploc(){let e,t=new B,i=this.jrll[this.face]-this.fx-this.fy;if(i<1){e=i;let s=e*e/3;t.z=1-s,t.z>.99&&(t.sth=Math.sqrt(s*(2-s)),t.have_sth=!0)}else if(i>3){e=4-i;let s=e*e/3;t.z=s-1,t.z<-.99&&(t.sth=Math.sqrt(s*(2-s)),t.have_sth=!0)}else e=1,t.z=2*(2-i)/3;let s=this.jpll[this.face]*e+this.fx-this.fy;return s<0&&(s+=8),s>=8&&(s-=8),t.phi=e<1e-15?0:.5*this.halfpi*s/e,t}toVec3(){return this.toHploc().toVec3()}}class z{constructor(e){this.p=new Array(e),this.o=new Int32Array(e),this.s=0,this.m=0}push(e,t){this.p[this.s]=e,this.o[this.s]=t,++this.s}pop(){--this.s}popToMark(){this.s=this.m}size(){return this.s}mark(){this.m=this.s}otop(){return this.o[this.s-1]}ptop(){return this.p[this.s-1]}}class O{constructor(e){e<0&&console.error("capacity must be positive"),this.r=new Int32Array(e<<1),this.sz=0}append(e){this.append1(e,e+1)}append1(e,t){if(e>=t)return;if(this.sz>0&&e<=this.r[this.sz-1])return e<this.r[this.sz-2]&&console.error("bad append operation"),void(t>this.r[this.sz-1]&&(this.r[this.sz-1]=t));let i=this.sz+2;if(this.r.length<i){let e=Math.max(2*this.r.length,i),t=new Int32Array(e);t.set(this.r),this.r=t}this.r[this.sz]=e,this.r[this.sz+1]=t,this.sz+=2}ensureCapacity(e){this.r.length<e&&this.resize(Math.max(2*this.r.length,e))}resize(e){if(e<this.sz&&console.error("requested array size too small"),e==this.r.length)return;new Int32Array(e);let t=this.r.slice(0,this.sz+1);this.r=t}}class U{constructor(e,t,i){this.ix=e,this.iy=t,this.face=i}}class H{constructor(e){this.order_max=29,this.inv_halfpi=2/Math.PI,this.twothird=2/3,this.ns_max=Math.pow(2,this.order_max),this.ctab=new Uint16Array([0,1,256,257,2,3,258,259,512,513,768,769,514,515,770,771,4,5,260,261,6,7,262,263,516,517,772,773,518,519,774,775,1024,1025,1280,1281,1026,1027,1282,1283,1536,1537,1792,1793,1538,1539,1794,1795,1028,1029,1284,1285,1030,1031,1286,1287,1540,1541,1796,1797,1542,1543,1798,1799,8,9,264,265,10,11,266,267,520,521,776,777,522,523,778,779,12,13,268,269,14,15,270,271,524,525,780,781,526,527,782,783,1032,1033,1288,1289,1034,1035,1290,1291,1544,1545,1800,1801,1546,1547,1802,1803,1036,1037,1292,1293,1038,1039,1294,1295,1548,1549,1804,1805,1550,1551,1806,1807,2048,2049,2304,2305,2050,2051,2306,2307,2560,2561,2816,2817,2562,2563,2818,2819,2052,2053,2308,2309,2054,2055,2310,2311,2564,2565,2820,2821,2566,2567,2822,2823,3072,3073,3328,3329,3074,3075,3330,3331,3584,3585,3840,3841,3586,3587,3842,3843,3076,3077,3332,3333,3078,3079,3334,3335,3588,3589,3844,3845,3590,3591,3846,3847,2056,2057,2312,2313,2058,2059,2314,2315,2568,2569,2824,2825,2570,2571,2826,2827,2060,2061,2316,2317,2062,2063,2318,2319,2572,2573,2828,2829,2574,2575,2830,2831,3080,3081,3336,3337,3082,3083,3338,3339,3592,3593,3848,3849,3594,3595,3850,3851,3084,3085,3340,3341,3086,3087,3342,3343,3596,3597,3852,3853,3598,3599,3854,3855]),this.utab=new Uint16Array([0,1,4,5,16,17,20,21,64,65,68,69,80,81,84,85,256,257,260,261,272,273,276,277,320,321,324,325,336,337,340,341,1024,1025,1028,1029,1040,1041,1044,1045,1088,1089,1092,1093,1104,1105,1108,1109,1280,1281,1284,1285,1296,1297,1300,1301,1344,1345,1348,1349,1360,1361,1364,1365,4096,4097,4100,4101,4112,4113,4116,4117,4160,4161,4164,4165,4176,4177,4180,4181,4352,4353,4356,4357,4368,4369,4372,4373,4416,4417,4420,4421,4432,4433,4436,4437,5120,5121,5124,5125,5136,5137,5140,5141,5184,5185,5188,5189,5200,5201,5204,5205,5376,5377,5380,5381,5392,5393,5396,5397,5440,5441,5444,5445,5456,5457,5460,5461,16384,16385,16388,16389,16400,16401,16404,16405,16448,16449,16452,16453,16464,16465,16468,16469,16640,16641,16644,16645,16656,16657,16660,16661,16704,16705,16708,16709,16720,16721,16724,16725,17408,17409,17412,17413,17424,17425,17428,17429,17472,17473,17476,17477,17488,17489,17492,17493,17664,17665,17668,17669,17680,17681,17684,17685,17728,17729,17732,17733,17744,17745,17748,17749,20480,20481,20484,20485,20496,20497,20500,20501,20544,20545,20548,20549,20560,20561,20564,20565,20736,20737,20740,20741,20752,20753,20756,20757,20800,20801,20804,20805,20816,20817,20820,20821,21504,21505,21508,21509,21520,21521,21524,21525,21568,21569,21572,21573,21584,21585,21588,21589,21760,21761,21764,21765,21776,21777,21780,21781,21824,21825,21828,21829,21840,21841,21844,21845]),this.jrll=new Int16Array([2,2,2,2,3,3,3,3,4,4,4,4]),this.jpll=new Int16Array([1,3,5,7,0,2,4,6,1,3,5,7]),this.xoffset=new Int16Array([-1,-1,0,1,1,1,0,-1]),this.yoffset=new Int16Array([0,1,1,1,0,-1,-1,-1]),this.facearray=[new Int16Array([8,9,10,11,-1,-1,-1,-1,10,11,8,9]),new Int16Array([5,6,7,4,8,9,10,11,9,10,11,8]),new Int16Array([-1,-1,-1,-1,5,6,7,4,-1,-1,-1,-1]),new Int16Array([4,5,6,7,11,8,9,10,11,8,9,10]),new Int16Array([0,1,2,3,4,5,6,7,8,9,10,11]),new Int16Array([1,2,3,0,0,1,2,3,5,6,7,4]),new Int16Array([-1,-1,-1,-1,7,4,5,6,-1,-1,-1,-1]),new Int16Array([3,0,1,2,3,0,1,2,4,5,6,7]),new Int16Array([2,3,0,1,-1,-1,-1,-1,0,1,2,3])],this.swaparray=[new Int16Array([0,0,3]),new Int16Array([0,0,6]),new Int16Array([0,0,0]),new Int16Array([0,0,5]),new Int16Array([0,0,0]),new Int16Array([5,0,0]),new Int16Array([0,0,0]),new Int16Array([6,0,0]),new Int16Array([3,0,0])],e<=this.ns_max&&e>0&&(this.nside=e,this.npface=this.nside*this.nside,this.npix=12*this.npface,this.order=this.nside2order(this.nside),this.nl2=2*this.nside,this.nl3=3*this.nside,this.nl4=4*this.nside,this.fact2=4/this.npix,this.fact1=(this.nside<<1)*this.fact2,this.ncap=2*this.nside*(this.nside-1)),this.bn=[],this.mpr=[],this.cmpr=[],this.smpr=[]}computeBn(){for(let e=0;e<=this.order_max;++e)this.bn[e]=new H(1<<e),this.mpr[e]=this.bn[e].maxPixrad(),this.cmpr[e]=B.cos(this.mpr[e]),this.smpr[e]=B.sin(this.mpr[e])}getNPix(){return this.npix}getBoundaries(e){let t=new Array,i=this.nest2xyf(e),s=.5/this.nside,r=(i.ix+.5)/this.nside,o=(i.iy+.5)/this.nside;return t[0]=new V(r+s,o+s,i.face).toVec3(),t[1]=new V(r-s,o+s,i.face).toVec3(),t[2]=new V(r-s,o-s,i.face).toVec3(),t[3]=new V(r+s,o-s,i.face).toVec3(),t}getBoundariesWithStep(e,t){let i=new Array,s=this.nest2xyf(e),r=.5/this.nside,o=(s.ix+.5)/this.nside,a=(s.iy+.5)/this.nside,n=1/(this.nside*t);for(let e=0;e<t;e++)i[e]=new V(o+r-e*n,a+r,s.face).toVec3(),i[e+t]=new V(o-r,a+r-e*n,s.face).toVec3(),i[e+2*t]=new V(o-r+e*n,a-r,s.face).toVec3(),i[e+3*t]=new V(o+r,a-r+e*n,s.face).toVec3();return i}getPointsForXyfNoStep(e,t,i){let s=new Array,r=new U(e,t,i),o=.5/this.nside,a=(r.ix+.5)/this.nside,n=(r.iy+.5)/this.nside;return s[0]=new V(a+o,n+o,r.face).toVec3(),s[1]=new V(a-o,n+o,r.face).toVec3(),s[2]=new V(a-o,n-o,r.face).toVec3(),s[3]=new V(a+o,n-o,r.face).toVec3(),s}getPointsForXyf(e,t,i,s){let r=i*Math.pow(2,this.order),o=new Array,a=new U(e,t,s),n=.5/r,h=(a.ix+.5)/r,l=(a.iy+.5)/r;return o[0]=new V(h+n,l+n,a.face).toVec3(),o[1]=new V(h-n,l+n,a.face).toVec3(),o[2]=new V(h-n,l-n,a.face).toVec3(),o[3]=new V(h+n,l-n,a.face).toVec3(),o}neighbours(e){let t=new Int32Array(8),i=this.nest2xyf(e),s=i.ix,r=i.iy,o=i.face;var a=this.nside-1;if(s>0&&s<a&&r>0&&r<a){let e=Math.floor(o<<2*this.order),i=this.spread_bits(s),a=this.spread_bits(r)<<1,n=this.spread_bits(s+1),h=this.spread_bits(r+1)<<1,l=this.spread_bits(s-1),c=this.spread_bits(r-1)<<1;t[0]=e+l+a,t[1]=e+l+h,t[2]=e+i+h,t[3]=e+n+h,t[4]=e+n+a,t[5]=e+n+c,t[6]=e+i+c,t[7]=e+l+c}else for(let e=0;e<8;++e){let i=s+this.xoffset[e],a=r+this.yoffset[e],n=4;i<0?(i+=this.nside,n-=1):i>=this.nside&&(i-=this.nside,n+=1),a<0?(a+=this.nside,n-=3):a>=this.nside&&(a-=this.nside,n+=3);let h=this.facearray[n][o];if(h>=0){let s=this.swaparray[n][o>>>2];if((1&s)>0&&(i=Math.floor(this.nside-i-1)),(2&s)>0&&(a=Math.floor(this.nside-a-1)),(4&s)>0){let e=i;i=a,a=e}t[e]=this.xyf2nest(i,a,h)}else t[e]=-1}return t}nside2order(e){return e&e-1?-1:Math.log2(e)}nest2xyf(e){let t=Math.floor(e&this.npface-1);return new U(this.compress_bits(t),this.compress_bits(t>>1),Math.floor(e>>2*this.order))}xyf2nest(e,t,i){return Math.floor(i<<2*this.order)+this.spread_bits(e)+(this.spread_bits(t)<<1)}loc2pix(e){let t,i=e.z,s=e.phi,r=Math.abs(i),o=this.fmodulo(s*this.inv_halfpi,4);if(r<=this.twothird){let e=this.nside*(.5+o),s=this.nside*(.75*i),r=Math.floor(e-s),a=Math.floor(e+s),n=Math.floor(r>>>this.order),h=Math.floor(a>>>this.order),l=Math.floor(n==h?4|n:n<h?n:h+8),c=Math.floor(a&this.nside-1),d=Math.floor(this.nside-(r&this.nside-1)-1);t=this.xyf2nest(c,d,l)}else{let s=Math.min(3,Math.floor(o)),a=o-s,n=r<.99||!e.have_sth?this.nside*Math.sqrt(3*(1-r)):this.nside*e.sth/Math.sqrt((1+r)/3),h=Math.floor(a*n),l=Math.floor((1-a)*n);h>=this.nside&&(h=this.nside-1),l>=this.nside&&(l=this.nside-1),t=i>=0?this.xyf2nest(Math.floor(this.nside-l-1),Math.floor(this.nside-h-1),s):this.xyf2nest(Math.floor(h),Math.floor(l),s+8)}return t}pix2vec(e){return this.pix2loc(e).toVec3()}pix2zphi(e){return this.pix2loc(e).toZphi()}pix2ang(e,t){return this.pix2loc(e).toPointing(t)}pix2loc(e){let t,i=new B(void 0),s=this.nest2xyf(e),r=(this.jrll[s.face]<<this.order)-s.ix-s.iy-1;if(r<this.nside){t=r;let e=t*t*this.fact2;i.z=1-e,i.z>.99&&(i.sth=Math.sqrt(e*(2-e)),i.have_sth=!0)}else if(r>this.nl3){t=this.nl4-r;let e=t*t*this.fact2;i.z=e-1,i.z<-.99&&(i.sth=Math.sqrt(e*(2-e)),i.have_sth=!0)}else t=this.nside,i.z=(this.nl2-r)*this.fact1;let o=this.jpll[s.face]*t+s.ix-s.iy;return o<0&&(o+=8*t),i.phi=t==this.nside?.75*F.halfpi*o*this.fact1:.5*F.halfpi*o/t,i}za2vec(e,t){const i=Math.sqrt(1-e*e),s=i*Math.cos(t),r=i*Math.sin(t);return new L(s,r,e)}ang2vec(e,t){const i=Math.cos(e);return this.za2vec(i,t)}vec2ang(e){const{z:t,a:i}=this.vec2za(e.getX(),e.getY(),e.getZ());return{theta:Math.acos(t),phi:i}}vec2za(e,t,i){const s=e*e+t*t;if(0==s)return{z:i<0?-1:1,a:0};{const r=Math.PI/2,o=(Math.atan2(t,e)+r)%r;return{z:i/=Math.sqrt(i*i+s),a:o}}}ang2pix(e,t){return this.loc2pix(new B(e))}fmodulo(e,t){if(e>=0)return e<t?e:e%t;var i=e%t+t;return i===t?0:i}compress_bits(e){var t=Math.floor(21845&e)|Math.floor((1431633920&e)>>>15);return this.ctab[255&t]|this.ctab[t>>>8]<<4}spread_bits(e){return Math.floor(this.utab[255&e])|Math.floor(this.utab[e>>>8&255]<<16)|Math.floor(this.utab[e>>>16&255]<<32)|Math.floor(this.utab[e>>>24&255]<<48)}queryPolygonInclusive(e,t){let i=0!=t,s=e.length;if(!(s>=3))return void console.log("not enough vertices in polygon");let r=new Array;for(let t=0;t<s;++t)r[t]=L.pointing2Vec3(e[t]);let o=new Array,a=0,n=0,h=!1;for(;n<r.length;){let e=r[n],t=null,i=null;n==r.length-1?(i=r[1],t=r[0]):n==r.length-2?(i=r[0],t=r[n+1]):(t=r[n+1],i=r[n+2]),o[n]=e.cross(t).norm();let s=o[n].dot(i);if(0==n)a=s<0?-1:1,new R(e),h=!1;else{if(a*s<0){new R(t),r.splice(n+1,1),o.splice(n,1),h=!0,n-=1;continue}new R(e),h=!1}o[n].scale(a),n+=1}s=r.length;let l=new Array(i?s+1:s);if(l=l.fill(F.halfpi),i){let e=new N(r);o[s]=e.getCenter(),l[s]=B.acos(e.getCosrad())}return this.queryMultiDisc(o,l,t)}queryMultiDisc(e,t,i){this.computeBn();let s=0!=i,r=e.length;if(r!=t.length)return void console.error("inconsistent input arrays");let o=new O(8),a=0;s&&(Math.pow(2,this.order_max-this.order)>=i||console.error("invalid oversampling factor"),i&i-1&&console.error("oversampling factor must be a power of 2"),a=this.ilog2(i));let n,h,l=this.order+a,c=new Array(l+1);for(n=0;n<=l;++n){c[n]=new Array(r);let e=this.bn[n].maxPixrad();for(h=0;h<r;++h)c[n][h]=new Float64Array(3),c[n][h][0]=t[h]+e>Math.PI?-1:B.cos(t[h]+e),c[n][h][1]=0==n?B.cos(t[h]):c[0][h][1],c[n][h][2]=t[h]-e<0?1:B.cos(t[h]-e)}let d=new z(12+3*l);for(let e=0;e<12;e++)d.push(11-e,0);for(;d.size()>0;){let t=d.ptop(),i=d.otop();d.pop();let a=this.bn[i].pix2vec(t),n=3;for(let t=0;t<r&&n>0;++t){let s=a.dot(e[t]);for(let e=0;e<n;++e)s<c[i][t][e]&&(n=e)}n>0&&this.check_pixel(i,l,n,o,t,d,s)}return o}ilog2(e){let t=Math.max(e,1);return 31-Math.clz32(t)}cosdist_zphi(e,t,i,s){return e*i+B.cos(t-s)*Math.sqrt((1-e*e)*(1-i*i))}check_pixel(e,t,i,s,r,o,a){if(0!=i)if(e<this.order)if(i>=3){let t=2*(this.order-e);s.append1(r<<t,r+1<<t)}else for(let t=0;t<4;++t)o.push(4*r+3-t,e+1);else if(e>this.order)if(i>=2)s.append(r>>>2*(e-this.order)),o.popToMark();else if(e<t)for(let t=0;t<4;++t)o.push(4*r+3-t,e+1);else s.append(r>>>2*(e-this.order)),o.popToMark();else if(i>=2)s.append(r);else if(a)if(this.order<t){o.mark();for(let t=0;t<4;++t)o.push(4*r+3-t,e+1)}else s.append(r)}maxPixrad(){let e=new D(2/3,Math.PI/this.nl4),t=this.convertZphi2xyz(e),i=new L(t[0],t[1],t[2]),s=1-1/this.nside;s*=s;let r=new D(1-s/3,0),o=this.convertZphi2xyz(r),a=new L(o[0],o[1],o[2]);return i.angle(a)}convertZphi2xyz(e){let t=Math.sqrt((1-e.z)*(1+e.z));return[t*B.cos(e.phi),t*B.sin(e.phi),e.z]}queryDiscInclusive(e,t,i){this.computeBn();let s=0!=i,r=new O;if(t>=Math.PI)return r.append1(0,this.npix),r;let o=0;s&&(i&i-1&&console.error("oversampling factor must be a power of 2"),o=this.ilog2(i));let a=Math.min(this.order_max,this.order+o),n=L.pointing2Vec3(e),h=new Array(a+1),l=new Array(a+1),c=B.cos(t),d=B.sin(t);for(let e=0;e<=a;e++){let i=this.mpr[e],s=this.cmpr[e],r=this.smpr[e];h[e]=t+i>Math.PI?-1:c*s-d*r,l[e]=t-i<0?1:c*s+d*r}let u=new z(12+3*a);for(let e=0;e<12;e++)u.push(11-e,0);for(;u.size()>0;){let t=u.ptop(),i=u.otop();u.pop();let o=this.bn[i].pix2zphi(t),d=this.cosdist_zphi(n.z,e.phi,o.z,o.phi);if(d>h[i]){let e=d<c?1:d<=l[i]?2:3;this.check_pixel(i,a,e,r,t,u,s)}}return r}}const G=new class{_healpix;_selectionnside;_useCORSProxy;_corsProxyUrl;_maxDecimals;_debug;_insideSphere;_version;constructor(){this._useCORSProxy=false,this._corsProxyUrl="http://localhost:4000/",this._maxDecimals=15,this._debug=false,this._insideSphere=false,this._version="Astrobrowser v1.0.0",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 H(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}},k=class{insideSphere=!1;cam_pos=a();cam_speed=1;vMatrix=p();T=p();R=p();FoV=180;previousFoV=180;move=a();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=n(e),this.vMatrix=p(),this.T=p(),this.R=p(),S(this.T,this.T,[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]),this.FoV=this.previousFoV=180,this.move=n([0,0,0]),this.goTo(0,0)}goTo(e,t){const i=360-e;this.goToPhiTheta(E(i,t))}goToPhiTheta(e){const t=C(e.phi,e.theta,this.cam_pos[2]);let i=p();i=S(i,i,l(t[0],t[1],t[2]));const s=n([0,1,0]);var r,a;i=function(e,t,i,s){var r=t[0],o=t[1],a=t[2],n=s[0],h=s[1],l=s[2],c=r-i[0],d=o-i[1],u=a-i[2],_=c*c+d*d+u*u;_>0&&(c*=_=1/Math.sqrt(_),d*=_,u*=_);var g=h*u-l*d,p=l*c-n*u,f=n*d-h*c;return(_=g*g+p*p+f*f)>0&&(g*=_=1/Math.sqrt(_),p*=_,f*=_),e[0]=g,e[1]=p,e[2]=f,e[3]=0,e[4]=d*f-u*p,e[5]=u*g-c*f,e[6]=c*p-d*g,e[7]=0,e[8]=c,e[9]=d,e[10]=u,e[11]=0,e[12]=r,e[13]=o,e[14]=a,e[15]=1,e}(i,[i[12],i[13],i[14]],[0,0,0],s),this.R=(r=i,(a=new o(16))[0]=r[0],a[1]=r[1],a[2]=r[2],a[3]=r[3],a[4]=r[4],a[5]=r[5],a[6]=r[6],a[7]=r[7],a[8]=r[8],a[9]=r[9],a[10]=r[10],a[11]=r[11],a[12]=r[12],a[13]=r[13],a[14]=r[14],a[15]=r[15],a),this.R[12]=0,this.R[13]=0,this.R[14]=0;const h=p();0!==this.cam_pos[2]&&x(h,i),this.vMatrix=h}toggleInsideSphere(){G.insideSphere?this.cam_pos[2]<=2?this.cam_pos[2]=-2+this.cam_pos[2]:this.cam_pos[2]=-.005:this.cam_pos[2]=2+this.cam_pos[2],S(this.T,p(),this.cam_pos),this.refreshViewMatrix()}zoom(e){if(this.move=n([0,0,0]),this.move[2]+=this.cam_speed*e,G.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),s=.015+.985*Math.pow(i,1.2);this.move[2]*=s,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=p();S(this.T,t,this.cam_pos),this.refreshViewMatrix()}moveAlongView(e){const t=p();x(t,this.R);const i=l(0,0,-1),s=a();g(s,i,t);const r=Math.hypot(s[0],s[1],s[2]);r>0&&(s[0]/=r,s[1]/=r,s[2]/=r),this.cam_pos[0]+=s[0]*e,this.cam_pos[1]+=s[1]*e,this.cam_pos[2]+=s[2]*e;const o=p();S(this.T,o,this.cam_pos),this.refreshViewMatrix()}translate(e){this.cam_pos[2]=e+1;const t=p();S(this.T,t,this.cam_pos),this.refreshViewMatrix()}rotateX(e){if(this.lockRotX)return;const t=.01*e;this.theta+=t,b(this.R,this.R,t,[1,0,0]),this.refreshViewMatrix()}rotateY(e){if(this.lockRotY)return;const t=.01*e;this.phi+=t,b(this.R,this.R,t,[0,1,0]),this.refreshViewMatrix()}rotateZ(e){if(this.lockRotZ)return;const t=.01*e;b(this.R,this.R,t,[0,0,1]),this.refreshViewMatrix()}rotateXRadian(e){this.lockRotX||(b(this.R,this.R,e,[1,0,0]),this.refreshViewMatrix())}rotateYRadian(e){this.lockRotY||(this.phi+=e,b(this.R,this.R,e,[0,1,0]),this.refreshViewMatrix())}rotateZRadian(e){this.lockRotZ||(b(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;if(this.lockRotX&&this.lockRotY)return;const s=this.getCameraPosition(),r=Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]),o=Math.max(r-1,1e-6),a=Math.min(1,o/.45),n=.02+.98*Math.pow(a,1.55),h=Math.min(1,this.FoV/18),l=i*n*(.06+1.55*Math.pow(h,.52))/1.9*this.rotationSensitivity;let c=this.lockRotX?0:t,d=this.lockRotY?0:e;const u=Math.sqrt(c*c+d*d);0!==u&&(c/=u,d/=u,b(this.R,this.R,-l,[c,d,0]),this.refreshViewMatrix())}setRotationSensitivity(e){this.rotationSensitivity=Math.min(3,Math.max(.2,e))}getRotationSensitivity(){return this.rotationSensitivity}refreshViewMatrix(){const e=p(),t=p();x(e,this.T),x(t,this.R),v(this.vMatrix,e,t)}refreshFoV(e){this.previousFoV=this.FoV,this.FoV=e}getCameraMatrix(){return this.vMatrix}getCameraPosition(){const e=p();return x(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=l(e[0],e[1],e[2]),S(this.T,p(),this.cam_pos),this.refreshViewMatrix()}getCameraAngle(){const[e,t,i]=this.getCameraPosition(),s=M(l(e,t,i));return console.log("[Camera::getCameraAngle]",s),s}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}};class X{static lastNearestVisibleObjectIdx=-1;static getNearestVisibleObjectIdx(){return this.lastNearestVisibleObjectIdx}static getRayFromMouse(e,t,i,s,r){const o=s.canvas.getBoundingClientRect(),a=t,n=[2*e/o.width-1,1-2*a/o.height,-1,1],h=p();x(h,i);const c=[0,0,0,0];X.mat4MultiplyVec4(h,n,c);const d=[c[0],c[1],-1,0],u=p();x(u,r);const _=[0,0,0,0];X.mat4MultiplyVec4(u,d,_);const g=l(_[0],_[1],_[2]);return f=g,v=(m=g)[0],S=m[1],b=m[2],(M=v*v+S*S+b*b)>0&&(M=1/Math.sqrt(M)),f[0]=m[0]*M,f[1]=m[1]*M,f[2]=m[2]*M,g;var f,m,v,S,b,M}static mat4MultiplyVec4(e,t,i){const s=t[0],r=t[1],o=t[2],a=t[3];return i[0]=e[0]*s+e[4]*r+e[8]*o+e[12]*a,i[1]=e[1]*s+e[5]*r+e[9]*o+e[13]*a,i[2]=e[2]*s+e[6]*r+e[10]*o+e[14]*a,i[3]=e[3]*s+e[7]*r+e[11]*o+e[15]*a,i}static raySphere(e,t,i){let s=-1;const r=a();d(r,e,i.center);const o=_(t,r),n=o*o-(_(r,r)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,i=-o-e;t<0&&i<0||(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}static getIntersectionPointWithSingleModel(e,t,i,s,r,o){const n=r.getCameraMatrix(),h=X.getRayFromMouse(e,t,o,s,n),l=X.raySphere(r.getCameraPosition(),h,i);let d=[];if(l>=0){const e=a();u(e,h,l),c(e,r.getCameraPosition(),e);const t=[e[0],e[1],e[2],1],s=[0,0,0,0];X.mat4MultiplyVec4(i.getModelMatrixInverse(),t,s),d=[s[0],s[1],s[2]]}return d}}const Y=X,q=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=T(this._raDecDeg.ra),this.decDMS=I(this._raDecDeg.dec))}computeNpix(){if(!this._xyz)return null;const e=G.getHealpix(G.nsideForSelection),t=new L(this._xyz[0],this._xyz[1],this._xyz[2]),i=new R(t,!1);return e.ang2pix(i,!1)}update(e){const t=(i=e,Array.isArray(i)?l(i[0],i[1],i[2]):i);var i;const s=M(t),r=A(s.phi,s.theta);this._xyz=[t[0],t[1],t[2]],this._phiThetaDeg=s,this._raDecDeg=r,this.raHMS=T(r.ra),this.decDMS=I(r.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}};class W{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 sampler2D uSampler0;\n uniform sampler2D uSampler1;\n uniform sampler2D uSampler2;\n uniform sampler2D uSampler3;\n uniform sampler2D uSampler4;\n uniform sampler2D uSampler5;\n uniform sampler2D uSampler6;\n uniform sampler2D uSampler7;\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 out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0){\n vec4 mycolor;\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n mycolor = color0;\n finalColor += mycolor.rgb * uFactor0;\n } else if (uFactor7 >= 0.0){\n finalColor = vec3(1.0, 0.0, 0.0);\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 sampler2D uSampler0;\n uniform sampler2D uSampler1;\n uniform sampler2D uSampler2;\n uniform sampler2D uSampler3;\n uniform sampler2D uSampler4;\n uniform sampler2D uSampler5;\n uniform sampler2D uSampler6;\n uniform sampler2D uSampler7;\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 out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0){\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n float gray = 0.21 * color0.r + 0.71 * color0.g + 0.07 * color0.b;\n finalColor = color0.rgb * (1.0 - uFactor0) + vec3(gray) * uFactor0;\n }\n if (uFactor1 >= 0.0){\n #if __VERSION__ > 120\n vec4 color1 = texture(uSampler1, vTextureCoord);\n #else\n vec4 color1 = texture2D(uSampler1, vTextureCoord);\n #endif\n finalColor += color1.rgb * uFactor1;\n }\n if (uFactor2 >= 0.0){\n #if __VERSION__ > 120\n vec4 color2 = texture(uSampler2, vTextureCoord);\n #else\n vec4 color2 = texture2D(uSampler2, vTextureCoord);\n #endif\n finalColor += color2.rgb * uFactor2;\n }\n if (uFactor3 >= 0.0){\n #if __VERSION__ > 120\n vec4 color3 = texture(uSampler3, vTextureCoord);\n #else\n vec4 color3 = texture2D(uSampler3, vTextureCoord);\n #endif\n finalColor += color3.rgb * uFactor3;\n }\n if (uFactor4 >= 0.0){\n #if __VERSION__ > 120\n vec4 color4 = texture(uSampler4, vTextureCoord);\n #else\n vec4 color4 = texture2D(uSampler4, vTextureCoord);\n #endif\n finalColor += color4.rgb * uFactor4;\n }\n if (uFactor5 >= 0.0){\n #if __VERSION__ > 120\n vec4 color5 = texture(uSampler5, vTextureCoord);\n #else\n vec4 color5 = texture2D(uSampler5, vTextureCoord);\n #endif\n finalColor += color5.rgb * uFactor5;\n }\n if (uFactor6 >= 0.0){\n #if __VERSION__ > 120\n vec4 color6 = texture(uSampler6, vTextureCoord);\n #else\n vec4 color6 = texture2D(uSampler6, vTextureCoord);\n #endif\n finalColor += color6.rgb * uFactor6;\n }\n if (uFactor7 >= 0.0){\n #if __VERSION__ > 120\n vec4 color7 = texture(uSampler7, vTextureCoord);\n #else\n vec4 color7 = texture2D(uSampler7, vTextureCoord);\n #endif\n finalColor += color7.rgb * uFactor7;\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 // UBO\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n uniform sampler2D uSampler0;\n uniform float uFactor0;\n\n out vec4 fragColor;\n\n void main() {\n #if __VERSION__ > 120\n vec4 color0 = texture(uSampler0, vTextureCoord);\n #else\n vec4 color0 = texture2D(uSampler0, vTextureCoord);\n #endif\n\n int x = int(color0.r * 255.0);\n float px = r_palette[x] / 256.0;\n\n int y = int(color0.g * 255.0);\n float py = g_palette[y] / 256.0;\n\n int z = int(color0.b * 255.0);\n float pz = b_palette[z] / 256.0;\n\n // uFactor0 reserved for future blending if needed\n fragColor = vec4(px, py, pz, 1.0);\n }"}}const Z=256;function j(e,t){if(!Array.isArray(t))throw new Error(`Channel "${e}" must be an array.`);if(t.length!==Z)throw new Error(`Channel "${e}" must contain exactly ${Z} samples.`);for(let i=0;i<t.length;i+=1){const s=t[i];if(!Number.isFinite(s))throw new Error(`Channel "${e}" contains a non-finite value at index ${i}.`);if(s<0||s>255)throw new Error(`Channel "${e}" contains an out-of-range value at index ${i}. Expected 0..255.`)}}function $(e){const t=new Float32Array(4*Z);for(let i=0;i<Z;i+=1)t[4*i]=e[i];return t}function Q(e,t){const i=e.trim();if(!i)throw new Error("Color map name must not be empty.");return j("r",t.r),j("g",t.g),j("b",t.b),{name:i,r:$(t.r),g:$(t.g),b:$(t.b)}}const K={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])}},J=K;class ee{_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"},this.gl_attributes={vertex_pos:"aVertexPosition",text_coords:"aTextureCoord"},this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,textureAlpha:null,clorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;return this._shaderProgram||(this._shaderProgram=e.createProgram(),this.initShaders()),e.useProgram(this._shaderProgram),this._shaderProgram}setRuntimeColorMap(e){this._runtimeColorMap=e}initShaders(){const e=this._webgl,t=W.hipsNativeFS();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=W.hipsVS();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")):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setGrayscaleShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=W.hipsGrayscaleFS();this.changeFSShader(e)}setNativeShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=W.hipsNativeFS();this.changeFSShader(e)}setColorMapShader(){const e=this._webgl;e.detachShader(this.shaderProgram,this._fragmentShader);const t=W.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 s=["r_palette","g_palette","b_palette"],r=e.getUniformIndices(this.shaderProgram,s),o=e.getActiveUniforms(this.shaderProgram,r,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)}s.forEach((e,t)=>{this._UBO_colorMapVariableInfo[e]={index:r[t],offset:o[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")}enableShaders(e,t,i,s){const r=this._webgl;if(r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model),this.locations.vMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_view),this.locations.sampler=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.sampler),this.locations.textureAlpha=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.factor),this.locations.clorMapIdx=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.colormapIdx),r.uniform1i(this.locations.clorMapIdx,s),this.locations.sampler&&r.uniform1i(this.locations.sampler,0),this.locations.vertexPositionAttribute=r.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.textureCoordAttribute=r.getAttribLocation(this.shaderProgram,this.gl_attributes.text_coords),s>=2&&this._UBO_colorMapBuffer&&null!==this._colorMapBlockIndex){let e;if(r.uniformBlockBinding(this.shaderProgram,this._colorMapBlockIndex,0),r.bindBuffer(r.UNIFORM_BUFFER,this._UBO_colorMapBuffer),2===s?e={r:K.planck.r,g:K.planck.g,b:K.planck.b}:3===s?e={r:K.cmb.r,g:K.cmb.g,b:K.cmb.b}:4===s?e={r:K.rainbow.r,g:K.rainbow.g,b:K.rainbow.b}:5===s?e={r:K.eosb.r,g:K.eosb.g,b:K.eosb.b}:6===s?e={r:K.cubehelix.r,g:K.cubehelix.g,b:K.cubehelix.b}:7===s?e={r:K.hot.r,g:K.hot.g,b:K.hot.b}:8===s&&(e={r:K.gray.r,g:K.gray.g,b:K.gray.b}),e||(e=this._runtimeColorMap),e){const t=this._UBO_colorMapVariableInfo;r.bufferSubData(r.UNIFORM_BUFFER,t.r_palette.offset,e.r,0),r.bufferSubData(r.UNIFORM_BUFFER,t.g_palette.offset,e.g,0),r.bufferSubData(r.UNIFORM_BUFFER,t.b_palette.offset,e.b,0)}r.bindBuffer(r.UNIFORM_BUFFER,null)}r.uniformMatrix4fv(this.locations.mMatrix,!1,i),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.vMatrix,!1,t)}}class te{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=p();R=p();modelMatrix=p();inverseModelMatrix=p();galacticMatrixInverted=p();_webgl;_hipsShaderProgram;constructor(e,t,i,s,r,o,a){this._webgl=o,this.xRad=i,this.yRad=s,this._name=r,this.center=n(t),this.radius=e,this.isGalacticHips=!!a,f(this.galacticMatrixInverted,-.054875582456588745,-.8734370470046997,-.48383501172065735,0,.49410945177078247,-.4448296129703522,.7469822764396667,0,-.8676661849021912,-.19807636737823486,.4559837877750397,0,0,0,0,1),this._hipsShaderProgram=new ee(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=p(),this.R=p(),this.modelMatrix=p(),this.inverseModelMatrix=p(),this.translate(this.center),this.rotate(this.xRad,this.yRad)}translate(e){S(this.T,this.T,e),this.refreshModelMatrix()}rotate(e,t){b(this.R,this.R,t,[0,0,1]),b(this.R,this.R,e,[1,0,0]),this.refreshModelMatrix()}rotateFromZero(e,t){m(this.R),b(this.R,this.R,e,[1,0,0]),b(this.R,this.R,t,[0,0,1]),this.refreshModelMatrix()}refreshModelMatrix(){const e=p();x(e,this.R),v(this.modelMatrix,this.T,e),G.insideSphere||(this.modelMatrix[1]=-this.modelMatrix[1],this.modelMatrix[5]=-this.modelMatrix[5],this.modelMatrix[9]=-this.modelMatrix[9],this.modelMatrix[13]=-this.modelMatrix[13]),this.isGalacticHips&&v(this.modelMatrix,this.modelMatrix,this.galacticMatrixInverted)}getModelMatrixInverse(){return m(this.inverseModelMatrix),x(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),s=Math.sin(t),r=e[1],o=e[5],a=e[9];return e[1]=e[1]*i-e[2]*s,e[5]=e[5]*i-e[6]*s,e[9]=e[9]*i-e[10]*s,e[2]=e[2]*i+r*s,e[6]=e[6]*i+o*s,e[10]=e[10]*i+a*s,e}rotateY(e,t){const i=Math.cos(t),s=Math.sin(t),r=e[0],o=e[4],a=e[8];return e[0]=i*e[0]+s*e[2],e[4]=i*e[4]+s*e[6],e[8]=i*e[8]+s*e[10],e[2]=i*e[2]-s*r,e[6]=i*e[6]-s*o,e[10]=i*e[10]-s*a,e}}const ie=new class{getHiPSNorder(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){let t,i;return e>=179?(t=10,i=10):e>=25?(t=9,i=9):e>=12.5?(t=8,i=8):e>=6?(t=6,i=6):e>=3.2?(t=5,i=5):e>=1.6?(t=4,i=4):e>=.85?(t=3,i=3):e>=.42?(t=2,i=2):e>=.21?(t=1,i=1):e>=.12?(t=.5,i=.5):e>=.06?(t=.25,i=.25):(t=10,i=10),{raStep:t,decStep:i}}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}}},se=class{_hips;_tileno;_baseurl;_order;_ready=!1;_format;_isGalacticHips;opacity=1;_hipsShaderIndex=0;_pixels=[];_texture=null;_image;_texurl="";vertexPosition;vertexPositionBuffer;vertexIndices;vertexIndexBuffer;_tileBuffer;_hipsShaderProgram;_webgl;constructor(e,t,i,s,r,o){this._hipsShaderProgram=r,this._tileBuffer=s,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}`,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,!0),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),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")}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=ie.getRefOrder(this._order),i=G.getHealpix(this._order).nest2xyf(this._tileno),s=t-this._order,r=i.ix<<s,o=(i.ix<<s)+(1<<s),a=i.iy<<s,n=(i.iy<<s)+(1<<s),h=G.getHealpix(t);this._pixels=[],this.setupPositionAndTexture4Quadrant(r,o/2,a,n/2,0,h,s,i),this.setupPositionAndTexture4Quadrant(o/2,o,a,n/2,1,h,s,i),this.setupPositionAndTexture4Quadrant(r,o/2,n/2,n,2,h,s,i),this.setupPositionAndTexture4Quadrant(o/2,o,n/2,n,3,h,s,i);const l=this.vertexPosition[0].length/20;this.vertexIndices=this.computeVertexIndices(l),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 s=0;s<e;s++)t[6*s]=i,t[6*s+1]=i+1,t[6*s+2]=i+2,t[6*s+3]=i+2,t[6*s+4]=i+3,t[6*s+5]=i,i+=4;return t}setupPositionAndTexture4Quadrant2(e,t,i,s,r,o,a,n){this.vertexPosition[r]=new Float32Array(20*(t-e)*(s-i));const h=1/(1<<a);let l=0;for(let c=e;c<t;c++)for(let e=i;e<s;e++){const t=o.getPointsForXyfNoStep(c,e,n.face),i=e-(n.iy<<a),s=c-(n.ix<<a);this.vertexPosition[r][20*l]=t[0].x,this.vertexPosition[r][20*l+1]=t[0].y,this.vertexPosition[r][20*l+2]=t[0].z,this.vertexPosition[r][20*l+3]=h+h*i,this.vertexPosition[r][20*l+4]=1-(h+h*s),this.vertexPosition[r][20*l+5]=t[1].x,this.vertexPosition[r][20*l+6]=t[1].y,this.vertexPosition[r][20*l+7]=t[1].z,this.vertexPosition[r][20*l+8]=h+h*i,this.vertexPosition[r][20*l+9]=1-h*s,this.vertexPosition[r][20*l+10]=t[2].x,this.vertexPosition[r][20*l+11]=t[2].y,this.vertexPosition[r][20*l+12]=t[2].z,this.vertexPosition[r][20*l+13]=h*i,this.vertexPosition[r][20*l+14]=1-h*s,this.vertexPosition[r][20*l+15]=t[3].x,this.vertexPosition[r][20*l+16]=t[3].y,this.vertexPosition[r][20*l+17]=t[3].z,this.vertexPosition[r][20*l+18]=h*i,this.vertexPosition[r][20*l+19]=1-(h+h*s),l++}this.vertexPositionBuffer[r]=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexPositionBuffer[r]),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexPosition[r],this._webgl.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,i,s,r,o,a,n){const h=this._webgl;this.vertexPosition[r]=new Float32Array(20*(t-e)*(s-i));const l=1/(1<<a);let c=0;for(let h=e;h<t;h++)for(let e=i;e<s;e++){const t=o.xyf2nest(h,e,n.face);this._pixels.push(t);const i=o.getBoundaries(t),s=e-(n.iy<<a),d=h-(n.ix<<a);this.vertexPosition[r][20*c]=i[0].x,this.vertexPosition[r][20*c+1]=i[0].y,this.vertexPosition[r][20*c+2]=i[0].z,this.vertexPosition[r][20*c+3]=l+l*s,this.vertexPosition[r][20*c+4]=1-(l+l*d),this.vertexPosition[r][20*c+5]=i[1].x,this.vertexPosition[r][20*c+6]=i[1].y,this.vertexPosition[r][20*c+7]=i[1].z,this.vertexPosition[r][20*c+8]=l+l*s,this.vertexPosition[r][20*c+9]=1-l*d,this.vertexPosition[r][20*c+10]=i[2].x,this.vertexPosition[r][20*c+11]=i[2].y,this.vertexPosition[r][20*c+12]=i[2].z,this.vertexPosition[r][20*c+13]=l*s,this.vertexPosition[r][20*c+14]=1-l*d,this.vertexPosition[r][20*c+15]=i[3].x,this.vertexPosition[r][20*c+16]=i[3].y,this.vertexPosition[r][20*c+17]=i[3].z,this.vertexPosition[r][20*c+18]=l*s,this.vertexPosition[r][20*c+19]=1-(l+l*d),c++}this.vertexPositionBuffer[r]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[r]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[r],h.STATIC_DRAW)}draw(e,t,i,s,r,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,s,r,o);n&&(a=n)}this._hipsShaderProgram.enableShaders(i,s,r,o);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),n.uniform1f(this._hipsShaderProgram.locations.textureAlpha,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,s,r,o){const a=new Set([0,1,2,3]),n=this._order+1;if(t.has(n)){for(let h=0;h<4;h++){const l=(this._tileno<<2)+h;if(t.get(n).includes(l)){const h=this._isGalacticHips?this._tileBuffer.getGalTile(l,n,this._hips):this._tileBuffer.getTile(l,n,this._hips);h.draw(e,t,i,s,r,o,this._hipsShaderProgram),h._ready&&a.delete(h._tileno-(this._tileno<<2))}}return a}}};class re{_ready=!1;_hips;_format;_baseurl;_isGalacticHips;_order=3;opacity=1;_hipsShaderIndex=0;_texture=null;_image;_texurl;_textureLoaded=!1;_maxTiles=0;_numFacesXTile=0;_numFaces=0;vertexPosition;vertexPositionBuffer;vertexIndexBuffer;vidx=0;_webgl;_tileBuffer;_hipsShaderProgram;constructor(e,t,i,s){this._tileBuffer=i,this._hips=e,this._webgl=t,this._format=e.format,this._baseurl=e.baseURL,this._isGalacticHips=e.isGalacticHips,this._hipsShaderProgram=s,this.initImage()}initImage(){this._image=new Image,this._texurl=`${this._baseurl}/Norder3/Allsky.${this._format}`,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}imageLoaded(){this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,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,!0),e.bindTexture(e.TEXTURE_2D,this._texture),e.isTexture(this._texture)||console.log("error in texture"),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),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.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)}initModelBuffer(){const e=this._webgl,t=this._order+1,i=G.getHealpix(this._order);this._maxTiles=i.getNPix();const s=G.getHealpix(t);this._numFacesXTile=4,this._numFaces=this._numFacesXTile*this._maxTiles,this.vertexPosition=new Float32Array(20*this._numFaces);let r=0,o=0;this.vidx=0;for(let e=0;e<this._maxTiles;e++){const t=i.nest2xyf(e),a=t.ix<<1,n=2+(t.ix<<1),h=t.iy<<1,l=2+(t.iy<<1);this.setupPositionAndTexture4Quadrant(r,o,a,a+(n-a)/2,h,h+(l-h)/2,s,t,0,0),this.setupPositionAndTexture4Quadrant(r,o,a+(n-a)/2,n,h,h+(l-h)/2,s,t,0,1),this.setupPositionAndTexture4Quadrant(r,o,a,a+(n-a)/2,h+(l-h)/2,l,s,t,1,0),this.setupPositionAndTexture4Quadrant(r,o,a+(n-a)/2,n,h+(l-h)/2,l,s,t,1,1),r++,27===r&&(o++,r=0)}const a=new Uint16Array(6*this._numFaces);let n=0;for(let e=0;e<this._numFaces;e++)a[6*e]=n,a[6*e+1]=n+1,a[6*e+2]=n+3,a[6*e+3]=n+1,a[6*e+4]=n+2,a[6*e+5]=n+3,n+=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,a,e.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,i,s,r,o,a,n,h,l){let c=[];const d=2**(a.order-3),u=1/(27*d),_=1/(29*d),g=u/64,p=_/64,f=d*u*e+u*h,m=d*_*t+_*l;for(let e=i;e<s;e++)for(let t=r;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]=u+f-g,this.vertexPosition[20*this.vidx+4]=1-(_+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]=u+f-g,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+g,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+g,this.vertexPosition[20*this.vidx+19]=1-(_+m)+p,this.vidx++}draw(e,t,i,s,r,o){if(!this._ready)return!1;let a=[];if(e>=this._order){const n=this.drawChildren(e,t,i,s,r,o);n&&(a=n)}const n=this._webgl;this._hipsShaderProgram.enableShaders(i,s,r,o),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),n.uniform1f(this._hipsShaderProgram.locations.textureAlpha,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,s,r,o){const a=this._order;if(!t.has(a))return;const n=t.get(a),h=[];for(let l=0;l<n.length;l++){const c=n[l],d=this._isGalacticHips?this._tileBuffer.getGalTile(c,a,this._hips):this._tileBuffer.getTile(c,a,this._hips);d.draw(e,t,i,s,r,o,this._hipsShaderProgram),d.getReadyState()&&h.push(c)}return h}}class oe extends te{_ancestorTiles;_allSkyTile;_descriptor;_format;_baseurl;_maxorder;_minorder;_visibleorder=3;_allSky=!0;samplerIdx=0;colorMapIdx=0;colorMap=J.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,s,r,o,a){super(e,t,i,s,r.surveyName,o,r.isGalactic),this._descriptor=r,this.initGL(o),this._healpixGrid=a,this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this),console.log("HiPS frame "+r.hipsFrame),console.log("HiPS minOrder "+r.minOrder),this._format=r.imgFormats[0],this._baseurl=r.url,this._maxorder=r.maxOrder,this._minorder=r.minOrder,this.initShaders();let n=ie.getHiPSNorder(180);if(this._visibleorder=Math.min(n,this._maxorder),this._ancestorTiles=[],this._allSkyTile=null,this._allSky=!0,this._allSky)this._allSkyTile=new re(this,this._webgl,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram);else for(let e=0;e<12;e++)this._ancestorTiles.push(new se(e,0,this,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram,this._webgl))}getProperty(e){return this._descriptor.getProperty(e)}changeFormat(e){this._format=e,this._tileBuffer?.clearAll&&this._tileBuffer.clearAll(),this._tileBuffer&&(this._tileBuffer._format=this._format);const t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;this._tileBuffer?.updateTiles&&this._tileBuffer.updateTiles(t.pixels,t.order)}changeColorMap(e){switch(console.log("HiPS.changeColorMap -> shaderProgram",super.hipsShaderProgram.shaderProgram),this.colorMap=e,e.name){case"grayscale":this.colorMapIdx=1,this.colorMap=J.grayscale,super.hipsShaderProgram.setGrayscaleShader();break;case"planck":this.colorMapIdx=2,this.colorMap=J.planck,super.hipsShaderProgram.setColorMapShader();break;case"cmb":this.colorMapIdx=3,this.colorMap=J.cmb,super.hipsShaderProgram.setColorMapShader();break;case"rainbow":this.colorMapIdx=4,this.colorMap=J.rainbow,super.hipsShaderProgram.setColorMapShader();break;case"eosb":this.colorMapIdx=5,this.colorMap=J.eosb,super.hipsShaderProgram.setColorMapShader();break;case"cubehelix":this.colorMapIdx=6,this.colorMap=J.cubehelix,super.hipsShaderProgram.setColorMapShader();break;case"hot":this.colorMapIdx=7,this.colorMap=J.hot,super.hipsShaderProgram.setColorMapShader();break;case"gray":this.colorMapIdx=8,this.colorMap=J.gray,super.hipsShaderProgram.setColorMapShader();break;case"native":this.colorMapIdx=0,this.colorMap=J.native,super.hipsShaderProgram.setNativeShader();break;default:this.colorMapIdx=9,this.colorMap=e,super.hipsShaderProgram.setColorMapShader()}}initShaders(){super.hipsShaderProgram.enableProgram()}getCurrentHealpixOrder(){return this._visibleorder}refresh(){const e=this._healpixGrid.getMinFoV();this._visibleorder=Math.min(ie.getHiPSNorder(e),this._maxorder)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh();const s=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,s,this.colorMapIdx):this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.ancestorsMap,i,t,s,this.colorMapIdx));const r=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(r,o,i,t,s,this.colorMapIdx)})}}class ae{_pMatrix;_aspectRatio=1;constructor(e,t,i,s=.1,r){this._pMatrix=this.computePerspectiveMatrix(e,t,i,s,r)}get pMatrix(){return this._pMatrix}set pMatrix(e){this._pMatrix=e}computePerspectiveMatrix(e,t,i,s=.1,r){this._aspectRatio=e.width/e.height;const o=p();let a;if(r)a=1.1;else{const e=t.getCameraMatrix(),i=-Number(e[14]),s=1,r=Math.sqrt(Math.max(i**2-s**2,0)),o=Math.atan2(r,s),n=r*Math.sin(o);a=n>0?n:s}return function(e,t,i,s,r){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!=r&&r!==1/0){var a=1/(s-r);e[10]=(r+s)*a,e[14]=2*r*s*a}else e[10]=-1,e[14]=-2*s}(o,i*Math.PI/180,this._aspectRatio,s,a),this._pMatrix=o,o}}var ne;!function(e){e.CARTESIAN="cartesian",e.SPHERICAL="spherical",e.ASTRO="astro"}(ne||(ne={}));class he{_x;_y;_z;_xyz;_raDeg;_decDeg;_raRad;_decRad;_raDecDeg;constructor(e,t){this._xyz=[0,0,0],this._raDecDeg=[0,0];const i=G.MAX_DECIMALS??12;if(t===ne.CARTESIAN){const{x:t,y:s,z:r}=e;this._x=Number(t.toFixed(i)),this._y=Number(s.toFixed(i)),this._z=Number(r.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===ne.ASTRO){const{raDeg:t,decDeg:s}=e;this._raDeg=Number(t),this._decDeg=Number(s),this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[r,o,a]=this.computeCartesianCoords();this._x=Number(r.toFixed(i)),this._y=Number(o.toFixed(i)),this._z=Number(a.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else t===ne.SPHERICAL?(console.log(`${ne.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=M(l(this._xyz[0],this._xyz[1],this._xyz[2])),t=A(e.phi,e.theta);return[t.ra,t.dec]}computeCartesianCoords(){const e=E(this._raDeg,this._decDeg),[t,i,s]=C(e.phi,e.theta,1);return[t,i,s]}computeHealpixPhiTheta(){return E(this._raDeg,this._decDeg)}scale(e){return new he({x:this.x*e,y:this.y*e,z:this.z*e},ne.CARTESIAN)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){return new he({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},ne.CARTESIAN)}norm(){const e=1/this.length();return new he({x:this.x*e,y:this.y*e,z:this.z*e},ne.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 he({x:this.x-e.x,y:this.y-e.y,z:this.z-e.z},ne.CARTESIAN)}add(e){return new he({x:this.x+e.x,y:this.y+e.y,z:this.z+e.z},ne.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}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]})`}}class le{getMinFoV(){return this._fovY_deg<=this._fovX_deg?this._fovY_deg:this._fovX_deg}static getFoVPolygon(e,t,i,s,r,o){const a=e.getCameraMatrix(),n=i.getModelMatrix(),h=t.clientWidth,l=t.clientHeight;let c=[];if(Y.getIntersectionPointWithSingleModel(0,0,s,r,e,o).length>0)c=le.getScreenCornersIntersection(o,e,t,s,r);else{let t=p();t=v(t,a,n),t=v(t,o,t);const i=[t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]],d=[t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]],u=[t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]],_=[t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]],g=Y.getIntersectionPointWithSingleModel(h/2,0,s,r,e,o),f=Y.getIntersectionPointWithSingleModel(h,l/2,s,r,e,o);if(0===g.length&&0===f.length){const e=le.getNearestSpherePoint(i),t=le.getNearestSpherePoint(d),s=le.getNearestSpherePoint(_),r=le.getNearestSpherePoint(u),o=le.computeMiddlePoint(s[0],e[0])[0],a=le.computeMiddlePoint(e[0],r[0])[0],n=le.computeMiddlePoint(r[0],t[0])[0],h=le.computeMiddlePoint(t[0],s[0])[0];c.push(e[0],a,r[0],n,t[0],h,s[0],o)}else if(0===g.length){const e=le.getNearestSpherePoint(i),s=le.getNearestSpherePoint(d),r=le.getFrustumIntersectionWithSphere(t,_,d,i),o=le.getFrustumIntersectionWithSphere(t,u,i,d),a=le.computeMiddlePoint(r[1],e[0])[0],n=le.computeMiddlePoint(e[0],o[0])[0],h=le.computeMiddlePoint(o[1],s[0])[0],l=le.computeMiddlePoint(s[0],r[0])[0];c.push(e[0],n,o[0],o[1],h,s[0],l,r[0],r[1],a)}else if(0===f.length){const e=le.getFrustumIntersectionWithSphere(t,i,_,u),s=le.getFrustumIntersectionWithSphere(t,d,u,_),r=le.getNearestSpherePoint(_),o=le.getNearestSpherePoint(u),a=le.computeMiddlePoint(r[0],e[0])[0],n=le.computeMiddlePoint(e[1],o[0])[0],h=le.computeMiddlePoint(o[0],s[0])[0],l=le.computeMiddlePoint(s[1],r[0])[0];c.push(e[0],e[1],n,o[0],h,s[0],s[1],l,r[0],a)}else{const e=le.getFrustumIntersectionWithSphere(t,i,_,u),s=le.getFrustumIntersectionWithSphere(t,d,u,_),r=le.getFrustumIntersectionWithSphere(t,_,d,i),o=le.getFrustumIntersectionWithSphere(t,u,i,d);c.push(e[0],e[1],o[0],o[1],s[0],s[1],r[0],r[1])}}return c}static getScreenCornersIntersection(e,t,i,s,r){const o=i.clientWidth,a=i.clientHeight,n=Y.getIntersectionPointWithSingleModel(0,0,s,r,t,e),h=Y.getIntersectionPointWithSingleModel(o/2,0,s,r,t,e),l=Y.getIntersectionPointWithSingleModel(o,0,s,r,t,e),c=Y.getIntersectionPointWithSingleModel(o,a/2,s,r,t,e),d=Y.getIntersectionPointWithSingleModel(o,a,s,r,t,e),u=Y.getIntersectionPointWithSingleModel(o/2,a,s,r,t,e),_=Y.getIntersectionPointWithSingleModel(0,a,s,r,t,e),g=Y.getIntersectionPointWithSingleModel(0,a/2,s,r,t,e),p=[],f=e=>{e.length>0&&p.push(new he({x:e[0],y:e[1],z:e[2]},ne.CARTESIAN))};return f(n),f(h),f(l),f(c),f(d),f(u),f(_),f(g),p}static getCenterJ2000(e,t,i,s,r){const o=e.clientWidth,a=e.clientHeight,n=Y.getIntersectionPointWithSingleModel(o/2,a/2,t,i,s,r);if(n.length<=0)throw Error("Central point is null");return new he({x:n[0],y:n[1],z:n[2]},ne.CARTESIAN)}static computeMiddlePoint(e,t){const i=(e.x+t.x)/2,s=(e.y+t.y)/2,r=(e.z+t.z)/2,o=Math.hypot(i,s,r)||1;return[new he({x:i/o,y:s/o,z:r/o},ne.CARTESIAN)]}static getNearestSpherePoint(e){const[t,i,s,r]=e,o=1/Math.sqrt(t*t+i*i+s*s),a=1*o,n=-1*o,h=[t*a,i*a,s*a],l=[t*n,i*n,s*n],c=Math.sqrt(t*t+i*i+s*s)||1,d=Math.abs(t*h[0]+i*h[1]+s*h[2]+r)/c<=Math.abs(t*l[0]+i*l[1]+s*l[2]+r)/c?h:l;return[new he({x:d[0],y:d[1],z:d[2]},ne.CARTESIAN)]}static getFrustumIntersectionWithSphere(e,t,i,s){const[r,o,a,n]=t,h=r*r+o*o+a*a||1,l=-r*n/h,c=-o*n/h,d=-a*n/h,u=Math.abs(n)/Math.sqrt(h),_=[];if(1>u){const e=Math.sqrt(1-u*u),t=t=>{const[i,s,r,o]=t,a=1/Math.sqrt(i*i+s*s+r*r),n=e*a,h=-e*a,u=[l+i*n,c+s*n,d+r*n],_=[l+i*h,c+s*h,d+r*h],g=Math.sqrt(i*i+s*s+r*r)||1;return Math.abs(i*u[0]+s*u[1]+r*u[2]+o)/g<=Math.abs(i*_[0]+s*_[1]+r*_[2]+o)/g?u:_},r=t(i),o=t(s);_.push(new he({x:r[0],y:r[1],z:r[2]},ne.CARTESIAN),new he({x:o[0],y:o[1],z:o[2]},ne.CARTESIAN))}else 1===u&&_.push(new he({x:l,y:c,z:d},ne.CARTESIAN),new he({x:l,y:c,z:d},ne.CARTESIAN));return _}static getAstroFoVPolygon(e){return e.map(e=>e.toADQL()).join(",")}}function ce(){var e=new o(4);return o!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function de(e,t,i){var s=t[0],r=t[1],o=t[2],a=t[3];return e[0]=i[0]*s+i[4]*r+i[8]*o+i[12]*a,e[1]=i[1]*s+i[5]*r+i[9]*o+i[13]*a,e[2]=i[2]*s+i[6]*r+i[10]*o+i[14]*a,e[3]=i[3]*s+i[7]*r+i[11]*o+i[15]*a,e}ce();const ue=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 }"}},_e=class{_divEqContainerElement;_divHPXContainerElement;_divSets;_divSetNdx;constructor(){this._divEqContainerElement=document.querySelector("#gridcoords"),this._divHPXContainerElement=document.querySelector("#gridhpx"),this._divSetNdx=0,this._divSets=[]}initHtml(){}resetDivSets(){for(;this._divSetNdx<this._divSets.length;++this._divSetNdx)this._divSets[this._divSetNdx].style.display="none";this._divSetNdx=0}addHPXDivSet(e,t,i){let s=this._divSets[this._divSetNdx++];if(!s){const e=document.createElement("div"),t=document.createTextNode("");if(e.className="floating-div-ra",e.appendChild(t),this._divHPXContainerElement||(this._divHPXContainerElement=document.querySelector("#gridhpx")),!this._divHPXContainerElement)return;this._divHPXContainerElement.appendChild(e),s={div:e,textNode:t,style:e.style},this._divSets.push(s)}s.style.display="block",s.style.left=`${Math.floor(t+25)}px`,s.style.top=`${Math.floor(i)}px`,s.textNode.nodeValue=e}addEqDivSet(e,t,i,s){let r=this._divSets[this._divSetNdx++];if(!r){const e=document.createElement("div"),t=document.createTextNode("");if(e.className="ra"===s?"floating-div-ra":"floating-div-dec",e.appendChild(t),this._divEqContainerElement||(this._divEqContainerElement=document.querySelector("#gridcoords")),!this._divEqContainerElement)return;this._divEqContainerElement.appendChild(e),r={div:e,textNode:t,style:e.style},this._divSets.push(r)}r.style.display="block","ra"===s?(r.style.left=`${Math.floor(t+25)}px`,r.style.top=`${Math.floor(i)}px`):(r.style.left=`${Math.floor(t)}px`,r.style.top=`${Math.floor(i+25)}px`),r.textNode.nodeValue=e}};class ge{static MIN_FOV_DEG=1e-6;fovXDeg=180;fovYDeg=180;ratio=0;_minFoV=180;_webgl;constructor(e){this._webgl=e}getFoV(e,t,i,s){const r=this._webgl;if(!r||!r.canvas)return this.fovXDeg=180,this.fovYDeg=180,this._minFoV=this.minFoV,this;const o=r.canvas.getBoundingClientRect(),a=o.width,n=o.height,h=this.computeAngle(0,n/2,e,t,i,s);this.fovXDeg=h.angleDeg;const l=this.computeAngle(a/2,0,e,t,i,s);return this.fovYDeg=l.angleDeg,this._minFoV=this.minFoV,this.ratio=this.computeRatio(i),this}computeRatio(e){if(!e)throw Error("Camera not defined");const t=e.getCameraPosition();return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])/this.fovYDeg}changeMinFov(e){console.log("inside changeMinFov"),this.fovYDeg<=this.fovXDeg?this.fovYDeg=e:this.fovXDeg=e,console.log("changeMinFov: ping"),this.minFoV}get minFoV(){const e=this.fovYDeg<=this.fovXDeg?this.fovYDeg:this.fovXDeg;return this._minFoV=Math.max(e,ge.MIN_FOV_DEG),this._minFoV}get xFoV(){return this.fovXDeg}get yFoV(){return this.fovYDeg}computeDistanceFromAngle(e){return e*this.ratio}computeAngle(e,t,i,s,r,o){if(!o)return console.warn("FoV: projection matrix is null"),{angleDeg:180,distance:1};const n=r.getCameraMatrix();if(!r)return console.warn("FoV: camera is null"),{angleDeg:180,distance:1};const f=Y.getRayFromMouse(e,t,o,this._webgl,n),m=Y.raySphere(r.getCameraPosition(),f,s);let v;if(m>0){const e=a();u(e,f,m),c(e,r.getCameraPosition(),e);const t=s.center,i=a();d(i,e,t);const o=l(t[0],t[1],t[2]+s.radius),n=p();x(n,r.getCameraMatrix());const S=a();g(S,o,n);const b=a();d(b,S,t);const M=_(i,b),P=h(i),w=h(b),A=Math.min(1,Math.max(-1,M/(P*w)));v=2*y(Math.acos(A))}else v=180;return{angleDeg:i?360-v:v,distance:m}}computeCameraPositionForMinFoV(e){return[0,0,0]}computeCameraPositionForFoV(e){return[0,0,0]}computeCameraPositionForAngularDiameter(e){return[0,0,0]}}const pe=class{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}};class fe{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,s,r,o=[],a=0,n=0;if(e[0][0].decDeg>=10?n=1:e[0][0].decDeg<=-10?n=-1:a=1,0===a){const h=fe.projectIn2D(e[0][0]);t=s=h.x,i=r=h.y;for(const h of e){const e=[];for(const l of h){if(l.decDeg>10*n&&-1===n||l.decDeg<10*n&&1===n){a=1,o=[];break}const h=fe.projectIn2D(l);e.push(h),h.x>t&&(t=h.x),h.y>i&&(i=h.y),h.x<s&&(s=h.x),h.y<r&&(r=h.y)}o.push(e)}}if(0===a)return{poly4selection:o,flag:a,maxx:t,maxy:i,minx:s,miny:r};const h=180;let l=e[0][0].raDeg<h;t=s=e[0][0].raDeg,i=r=e[0][0].decDeg;for(const n of e){const e=[];for(const c of n){const n=new pe(c.raDeg,c.decDeg);if(e.push(n),c.raDeg>t&&(t=c.raDeg),c.decDeg>i&&(i=c.decDeg),c.raDeg<s&&(s=c.raDeg),c.decDeg<r&&(r=c.decDeg),c.raDeg>=h&&l||c.raDeg<=h&&!l){a=2,o=[];break}}o.push(e)}if(1===a)return{poly4selection:o,flag:a,maxx:t,maxy:i,minx:s,miny:r};let c=e[0][0].raDeg;t=c>=h?c-360:c,i=e[0][0].decDeg,s=t,r=i;for(const a of e){const e=[];for(const o of a){const a=o.raDeg>=h?o.raDeg-360:o.raDeg;a>t&&(t=a),o.decDeg>i&&(i=o.decDeg),a<s&&(s=a),o.decDeg<r&&(r=o.decDeg),e.push(new pe(a,o.decDeg))}o.push(e)}return{poly4selection:o,flag:a,maxx:t,maxy:i,minx:s,miny:r}}static stereographic(e){const t=Number(e.xyz[0]),i=Number(e.xyz[1]),s=Number(e.xyz[2]);return{x:2*t/(1-s),y:2*i/(1-s)}}static projectIn2D(e){const t=fe.stereographic(e);return new pe(t.x,t.y)}static checkPointInsidePolygon5(e,t){let i;if(0===e.flag)i=fe.projectIn2D(t);else if(1===e.flag)i=new pe(t.raDeg,t.decDeg);else{const e=180,s=t.raDeg>=e?t.raDeg-360:t.raDeg;i=new pe(s,t.decDeg)}const s=new pe(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 r=0;r<t.length-1;r++){const o=t[r],a=t[r+1],n=(a.y-o.y)*(s.x-i.x)-(a.x-o.x)*(s.y-i.y),h=(a.x-o.x)*(i.y-o.y)-(a.y-o.y)*(i.x-o.x),l=(s.x-i.x)*(i.y-o.y)-(s.y-i.y)*(i.x-o.x);if(0!==n){const t=h/n,i=l/n;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const r=t[t.length-1],o=t[0],a=(o.y-r.y)*(s.x-i.x)-(o.x-r.x)*(s.y-i.y),n=(o.x-r.x)*(i.y-r.y)-(o.y-r.y)*(i.x-r.x),h=(s.x-i.x)*(i.y-r.y)-(s.y-i.y)*(i.x-r.x);if(0!==a){const t=n/a,i=h/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}static checkPointInsidePolygon4(e,t){const i=fe.projectIn2D(t);let s=t.raDeg+15;s>360&&(s=t.raDeg-15);const r=new he({raDeg:s,decDeg:t.decDeg},ne.ASTRO),o=fe.projectIn2D(r);for(const t of e){let e=0;for(let s=0;s<t.length-1;s++){const r=fe.projectIn2D(t[s]),a=fe.projectIn2D(t[s+1]),n=(a.y-r.y)*(o.x-i.x)-(a.x-r.x)*(o.y-i.y),h=(a.x-r.x)*(i.y-r.y)-(a.y-r.y)*(i.x-r.x),l=(o.x-i.x)*(i.y-r.y)-(o.y-i.y)*(i.x-r.x);if(0!==n){const t=h/n,i=l/n;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const s=fe.projectIn2D(t[t.length-1]),r=fe.projectIn2D(t[0]),a=(r.y-s.y)*(o.x-i.x)-(r.x-s.x)*(o.y-i.y),n=(r.x-s.x)*(i.y-s.y)-(r.y-s.y)*(i.x-s.x),h=(o.x-i.x)*(i.y-s.y)-(o.y-i.y)*(i.x-s.x);if(0!==a){const t=n/a,i=h/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}}const me=fe;class xe{_hips;_tileno;_baseurl;_order;_format;_maxorder;_isGalacticHips;_ready=!1;_abort=!1;_image;_textureLoaded=!1;_texture;_texurl="";_hipsShaderIndex=0;_cacheTime0;_inView=!0;_amIStillInFoV_requsetID;vertexPosition=[];vertexPositionBuffer=[];vertexIndices=new Uint16Array;vertexIndexBuffer;_tileBuffer;opacity=1;_webgl;_visibleTileManager;constructor(e,t,i,s,r,o){this._visibleTileManager=o,this._webgl=r,this._tileBuffer=s,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}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}`);this._image=new Image;const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,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}imageLoaded(){this._ready=!0}textureLoaded(e){e.enableProgram();const t=this._webgl;this._texture=t.createTexture(),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,this._texture),t.isTexture(this._texture)||console.log("error in texture"),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.bindTexture(t.TEXTURE_2D,this._texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this._image),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),t.isTexture(this._texture)||console.warn("Texture creation failed"),this.initModelBuffer(),this._textureLoaded=!0}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=ie.getRefOrder(this._order),i=G.getHealpix(this._order).nest2xyf(this._tileno),s=t-this._order,r=i.ix<<s,o=(i.ix<<s)+(1<<s),a=i.iy<<s,n=(i.iy<<s)+(1<<s),h=G.getHealpix(t);this.setupPositionAndTexture4Quadrant2(r,r+(o-r)/2,a,a+(n-a)/2,0,h,s,i),this.setupPositionAndTexture4Quadrant2(r+(o-r)/2,o,a,a+(n-a)/2,1,h,s,i),this.setupPositionAndTexture4Quadrant2(r,r+(o-r)/2,a+(n-a)/2,n,2,h,s,i),this.setupPositionAndTexture4Quadrant2(r+(o-r)/2,o,a+(n-a)/2,n,3,h,s,i);const l=this.vertexPosition[0].length/20,c=this.computeVertexIndices(l);c.length>65535?this.vertexIndices=new Uint32Array(c):this.vertexIndices=new Uint16Array(c),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 s=0;s<e;s++){const e=i;t[6*s]=e,t[6*s+1]=e+1,t[6*s+2]=e+2,t[6*s+3]=e+2,t[6*s+4]=e+3,t[6*s+5]=e,i+=4}return t}setupPositionAndTexture4Quadrant2(e,t,i,s,r,o,a,n){const h=this._webgl;this.vertexPosition[r]=new Float32Array(20*(t-e)*(s-i));const l=1/(1<<a);let c=0;for(let h=e;h<t;h++)for(let e=i;e<s;e++){const t=o.getPointsForXyfNoStep(h,e,n.face),i=e-(n.iy<<a),s=h-(n.ix<<a);this.vertexPosition[r][20*c]=t[0].x,this.vertexPosition[r][20*c+1]=t[0].y,this.vertexPosition[r][20*c+2]=t[0].z,this.vertexPosition[r][20*c+3]=l+l*i+0,this.vertexPosition[r][20*c+4]=1-(l+l*s)-0,this.vertexPosition[r][20*c+5]=t[1].x,this.vertexPosition[r][20*c+6]=t[1].y,this.vertexPosition[r][20*c+7]=t[1].z,this.vertexPosition[r][20*c+8]=l+l*i+0,this.vertexPosition[r][20*c+9]=1-l*s+0,this.vertexPosition[r][20*c+10]=t[2].x,this.vertexPosition[r][20*c+11]=t[2].y,this.vertexPosition[r][20*c+12]=t[2].z,this.vertexPosition[r][20*c+13]=l*i-0,this.vertexPosition[r][20*c+14]=1-l*s+0,this.vertexPosition[r][20*c+15]=t[3].x,this.vertexPosition[r][20*c+16]=t[3].y,this.vertexPosition[r][20*c+17]=t[3].z,this.vertexPosition[r][20*c+18]=l*i-0,this.vertexPosition[r][20*c+19]=1-(l+l*s)-0,c++}this.vertexPositionBuffer[r]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[r]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[r],h.STATIC_DRAW)}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,s,r,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 h=this.drawChildren(e,t,i,s,r,o,a);h&&(n=h)}const h=this._webgl;a.enableShaders(i,s,r,o),h.enableVertexAttribArray(a.locations.vertexPositionAttribute),h.enableVertexAttribArray(a.locations.textureCoordAttribute),h.activeTexture(h.TEXTURE0+this._hipsShaderIndex),h.bindTexture(h.TEXTURE_2D,this._texture),h.uniform1f(a.locations.textureAlpha,this.opacity),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const l=this.vertexIndices.length,c=this.vertexIndices instanceof Uint32Array?h.UNSIGNED_INT:h.UNSIGNED_SHORT;n.forEach(e=>{h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[e]),h.vertexAttribPointer(a.locations.vertexPositionAttribute,3,h.FLOAT,!1,20,0),h.vertexAttribPointer(a.locations.textureCoordAttribute,2,h.FLOAT,!1,20,12),h.drawElements(h.TRIANGLES,l,c,0)}),h.disableVertexAttribArray(a.locations.vertexPositionAttribute),h.disableVertexAttribArray(a.locations.textureCoordAttribute)}drawChildren(e,t,i,s,r,o,a){const n=new Set([0,1,2,3]),h=this._order+1;if(t.has(h)){for(let l=0;l<4;l++){const c=(this._tileno<<2)+l;if(t.get(h).includes(c)){const l=this._isGalacticHips?this._tileBuffer.getGalTile(c,h,this._hips):this._tileBuffer.getTile(c,h,this._hips);l.draw(e,t,i,s,r,o,a),l._ready&&n.delete(c-(this._tileno<<2))}}return n}}}class ve{_tiles;_cachedTiles;_activeHiPS;_galTiles;_galCachedTiles;_galActiveHiPS;_cacheAliveMilliSeconds;_cleanerId;_webgl;_visibleTileManager;_hipsShaderProgram;constructor(e=1,t,i,s){this._hipsShaderProgram=i,this._visibleTileManager=s,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 s=this.key(t,e,i.baseURL);if(!this._tiles.has(s))if(this._cachedTiles.has(s)){const e=this._cachedTiles.get(s);this._tiles.set(s,e),this._cachedTiles.delete(s),e.resetCacheTime0()}else{const r=new xe(e,t,i,this,this._webgl,this._visibleTileManager);this._tiles.set(s,r)}return this._tiles.get(s)}getGalTile(e,t,i){const s=this.key(t,e,i.baseURL);if(!this._galTiles.has(s))if(this._galCachedTiles.has(s)){const e=this._galCachedTiles.get(s);this._galTiles.set(s,e),this._galCachedTiles.delete(s),e.resetCacheTime0()}else{const r=new xe(e,t,i,this,this._webgl,this._visibleTileManager);this._galTiles.set(s,r)}return this._galTiles.get(s)}moveTileToCache(e,t,i){const s=this.key(t,e,i.baseURL);if(this._tiles.has(s)){const e=this._tiles.get(s);e.setCacheTime0(),this._cachedTiles.set(s,e),this._tiles.delete(s)}if(this._galTiles.has(s)){const e=this._galTiles.get(s);e.setCacheTime0(),this._galCachedTiles.set(s,e),this._galTiles.delete(s)}}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const s=i.cacheTime0;!i.inView&&void 0!==s&&e-s>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._cachedTiles.delete(t))}for(const[t,i]of this._galCachedTiles){const s=i.cacheTime0;!i.inView&&void 0!==s&&e-s>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._galCachedTiles.delete(t))}}key(e,t,i){return`${e}#${t}#${i}`}dispose(){window.clearInterval(this._cleanerId)}}class Se{_visibleTilesByOrder;_ancestorsMap;initialised;_galVisibleTilesByOrder;_galAncestorsMap;_galacticMatrixInverted;_galacticMatrix;insideSphere=i;_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=p(),this._galacticMatrix=p(),f(this._galacticMatrixInverted,-.054876,-.873437,-.483835,0,.494109,-.44483,.746982,-0,-.867666,-.198076,.455984,0,0,0,0,1),x(this._galacticMatrix,this._galacticMatrixInverted),this._tileBuffer=new ve(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,s){if(!this.initialised)return;G.insideSphere&&e<3&&(e=3),this._ancestorsMap.set(e,[]),this._galAncestorsMap.set(e,[]);let r=[],o=[];if(0===e){const t=G.getHealpix(0).getNPix();for(let i=0;i<t;i++)r.push(i),this._ancestorsMap.get(e).push(i),o.push(i),this._galAncestorsMap.get(e).push(i)}else{const a=G.getHealpix(e),n=t.canvas.width,h=t.canvas.height;for(let t=0;t<=n;t+=n/30)for(let n=0;n<=h;n+=h/30){const h=Y.getIntersectionPointWithSingleModel(t,n,this._healpixGrid,this._webgl,i,s);if(h.length>0){const t=ce();de(t,[h[0],h[1],h[2],1],this._galacticMatrix);const i=new R(new L(t[0],t[1],t[2])),s=a.ang2pix(i),n=new R(new L(h[0],h[1],h[2])),l=a.ang2pix(n);r.includes(l)||(r.push(l),this._ancestorsMap.get(e).push(l),this._tileBuffer.addTile(e,l)),o.includes(s)||(o.push(s),this._galAncestorsMap.get(e).push(s),this._tileBuffer.addGalTile(e,s))}}}this._visibleTilesByOrder={pixels:r,order:e},this._galVisibleTilesByOrder={pixels:o,order:e};for(let t=1;t<e;t++){const i=e-t,s=this._ancestorsMap.get(i)??[];this._ancestorsMap.set(i,s);for(let e=0;e<r.length;e++){const o=r[e]>>2*t;s.includes(o)||(s.push(o),this._tileBuffer.addTile(i,o))}}for(let t=1;t<e;t++){const i=e-t,s=this._galAncestorsMap.get(i)??[];this._galAncestorsMap.set(i,s);for(let e=0;e<o.length;e++){const r=o[e]>>2*t;s.includes(r)||(s.push(r),this._tileBuffer.addGalTile(i,r))}}}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}}class be extends te{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_visibleorder=0;showGrid=!1;_shaderProgram;fragmentShader;vertexShader;defaultColor="#ec0acaff";gridText=new _e;_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){super(be.RADIUS,be.INITIAL_POSITION,be.INITIAL_PhiRad,be.INITIAL_ThetaRad,"healpix-grid",e),this.init(),this._visibleTilesManager=new Se(this._webgl,super.hipsShaderProgram,this),this._visibleTilesManager.init(i)}init(){console.log("HealpixGridSingleton.init()"),this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders();const e=ie.getHiPSNorder(be.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 ge(super.webgl)}get fovObj(){return this._fovObj}get RADIUS(){return be.RADIUS}get INITIAL_POSITION(){return be.INITIAL_POSITION}get INITIAL_PhiRad(){return be.INITIAL_PhiRad}get INITIAL_ThetaRad(){return be.INITIAL_ThetaRad}refreshFoV(e,t){return this._fovObj.getFoV(G.insideSphere,this,e,t)}getFoV(){return this._fovObj}getMinFoV(){return this._fovObj.minFoV}initShaders(){const e=super.webgl,t=ue.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=ue.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=G.getHealpix(t),s=G.getHealpix(t+1),r=G.getHealpix(t+2);let o=0,a=0;this._indexes=new Uint32Array(17*e.length),this._vertexCataloguePosition=new Float32Array(48*e.length);for(let t=0;t<e.length;t++){const n=i.getBoundaries(e[t]),h=e[t]<<2,l=h+1,c=h+2,d=h+3,u=s.getBoundaries(h),_=s.getBoundaries(d),g=e=>{this._vertexCataloguePosition[o]=1*e.x,this._vertexCataloguePosition[o+1]=1*e.y,this._vertexCataloguePosition[o+2]=1*e.z,this._indexes[a]=Math.floor(o/3),a+=1,o+=3};g(n[0]);let p=3+(d<<2),f=r.getBoundaries(p);g(f[1]),g(_[1]);let m=2+(c<<2);f=r.getBoundaries(m),g(f[0]),g(n[1]),g(f[2]),g(u[1]);let x=h<<2;f=r.getBoundaries(x),g(f[1]),g(n[2]),g(f[3]),g(u[3]);let v=1+(l<<2);f=r.getBoundaries(v),g(f[2]),g(n[3]),g(f[0]),g(_[3]),f=r.getBoundaries(p),g(f[3]),this._indexes[a]=4294967295,this._nPrimitiveFlags+=1,a+=1}}refresh(e,t){this.refreshFoV(e,t);const i=this.getMinFoV();this._visibleorder=ie.getHiPSNorder(i)}enableShader(e,t,i){const s=super.webgl;s.useProgram(this._shaderProgram);const r=s.getUniformLocation(this._shaderProgram,"uMVMatrix"),o=s.getUniformLocation(this._shaderProgram,"uPMatrix"),a=super.webgl.getUniformLocation(this._shaderProgram,"u_fragcolor");this._attribLocations.position=s.getAttribLocation(this._shaderProgram,"aCatPosition");let n=p();if(n=v(n,i,e),r&&s.uniformMatrix4fv(r,!1,n),o&&s.uniformMatrix4fv(o,!1,t),a){const e=P(this.defaultColor);s.uniform4f(a,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(),s=e.camera;if(!s)return;const r=s.getCameraMatrix(),o=e.pMatrix;if(!o)return;if(this.refresh(s,o),!this.showGrid)return void this.gridText.resetDivSets();const a=this._visibleTilesManager.visibleTilesByOrder,n=a.pixels,h=a.order;this.initBuffers(n,h),this.enableShader(i,o,r),t.bindBuffer(t.ARRAY_BUFFER,this._vertexCataloguePositionBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexCataloguePosition,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,be.ELEM_SIZE,t.FLOAT,!1,be.BYTES_X_ELEM*be.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 l=p();l=v(l,r,i);let c=p();c=v(c,o,l);const d=le.getCenterJ2000(t.canvas,this,this._webgl,s,o),u=this.getMinFoV()*Math.PI/180/2;for(let e=0;e<n.length;e++){const i=G.getHealpix(this._visibleorder).pix2vec(n[e]),s=new he({x:i.x,y:i.y,z:i.z},ne.CARTESIAN);if(me.orthodromicDistance(d,s)<u){const s=[i.x,i.y,i.z,1],r=ce();de(r,s,c),r[0]/=r[3],r[1]/=r[3];const o=(.5*r[0]+.5)*t.canvas.width,a=(-.5*r[1]+.5)*t.canvas.height;this.gridText.addHPXDivSet(this._visibleorder+"/"+n[e],o,a)}}this.gridText.resetDivSets(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}get visibleorder(){return this._visibleorder}}class Me extends te{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;showGrid=!1;_shaderProgram;_vertexShader;_fragmentShader;defaultColor="#41d421";gridText=new _e;_attribLocations={position:0,selected:1,pointSize:2,color:3};_phiVertexPositionBuffer;_thetaVertexPositionBuffer;_fov;_phiStep=0;_phiStepRad=0;_thetaStep=0;_thetaStepRad=0;_phiArray=[];_thetaArray=[];_dec4Labels=new Map;_ra4Labels=new Map;_healpixGrid;constructor(e,t){super(be.RADIUS,be.INITIAL_POSITION,be.INITIAL_PhiRad,be.INITIAL_ThetaRad,"equatorial-grid",e),this._healpixGrid=t}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=ue.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=ue.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){const t=ie.getRADegSteps(e),i=t.raStep,s=t.decStep;this._phiStep=i,this._phiStepRad=w(i),this._thetaStep=s,this._thetaStepRad=w(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/i*3),s=w(e);for(let e=0;e<360;e+=i){const r=w(e),o=1*Math.sin(s)*Math.cos(r),a=1*Math.sin(s)*Math.sin(r),n=1*Math.cos(s),h=Math.floor(e/i);t[3*h+0]=o,t[3*h+1]=a,t[3*h+2]=n,this._dec4Labels.has(e)||this._dec4Labels.set(e,[]),this._dec4Labels.get(e).push([o,a,n])}this._phiArray.push(t)}for(let e=0;e<360;e+=i){const t=new Float32Array(360/s*3),i=w(e);for(let e=0;e<360;e+=s){const r=w(e),o=1*Math.sin(r)*Math.cos(i),a=1*Math.sin(r)*Math.sin(i),n=1*Math.cos(r),h=Math.floor(e/s);t[3*h+0]=o,t[3*h+1]=a,t[3*h+2]=n;const l=90-e;this._ra4Labels.has(l)||this._ra4Labels.set(l,[]),this._ra4Labels.get(l).push([o,a,n])}this._thetaArray.push(t)}}refresh(e){this._fov!==e&&(this._fov=e,this.initBuffers(this._fov))}vectorDistance(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z;return Math.sqrt(i*i+s*s+r*r)}enableShader(e,t,i){const s=super.webgl;s.useProgram(this._shaderProgram);const r=p();v(r,i,e);const o=s.getUniformLocation(this._shaderProgram,"uMVMatrix"),a=s.getUniformLocation(this._shaderProgram,"uPMatrix"),n=s.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=s.getAttribLocation(this._shaderProgram,"aCatPosition"),o&&s.uniformMatrix4fv(o,!1,r),a&&s.uniformMatrix4fv(a,!1,t),n){const e=P(this.defaultColor);s.uniform4f(n,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,s=this.getModelMatrix(),r=e.camera;if(!r)return;const o=r.getCameraMatrix(),a=e.pMatrix;if(!a)return;if(!o)return;if(0===this._thetaArray.length)return;if(this.refresh(t),!this.showGrid)return void this.gridText.resetDivSets();this.enableShader(s,a,o);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 n=le.getCenterJ2000(i.canvas,this._healpixGrid,this._webgl,r,a),h=p();v(h,o,s);const l=p();v(l,a,h);for(const[e,t]of this._dec4Labels.entries())if(Math.abs(e-n.raDeg)<=this._phiStep)for(let e=0;e<t.length;e++){const[i,s,r]=t[e],o=[i,s,r,1],a=new he({x:i,y:s,z:r},ne.CARTESIAN).decDeg;if(Math.abs(a-n.decDeg)<60){const e=ce();de(e,o,l),e[0]/=e[3],e[1]/=e[3];const t=(.5*e[0]+.5)*super.webgl.canvas.width,i=(-.5*e[1]+.5)*super.webgl.canvas.height;this.gridText.addEqDivSet(a.toFixed(2),t,i,"dec")}}for(const[e,t]of this._ra4Labels.entries())if(Math.abs(e-n.decDeg)<=this._thetaStep)for(let e=0;e<t.length;e++){const[i,s,r]=t[e],o=[i,s,r,1],a=new he({x:i,y:s,z:r},ne.CARTESIAN),h=this.vectorDistance(a,n),c=a.raDeg;if(h<w(50)){const e=ce();de(e,o,l),e[0]/=e[3],e[1]/=e[3];const t=(.5*e[0]+.5)*super.webgl.canvas.width,i=(-.5*e[1]+.5)*super.webgl.canvas.height;this.gridText.addEqDivSet(c.toFixed(2),t,i,"ra")}}this.gridText.resetDivSets(),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null)}}class Pe{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;startup=!0;fov;activeCatalogues=[];activeFootprintSets=[];_webgl;_selectedColorMap;_cameraStatusChanged=!1;lastHoveredSource=null;lastHoveredCatalogue=null;zoomSensitivity=1;constructor(e,t){console.log("[AstroSphere] new instance for canvas",e.id),this._webgl=t,this.mouseHelper=new q,this.canvas=e,this._selectedColorMap=J.native,G.insideSphere=i,this.initCamera(),this._healpixGrid=new be(this._webgl),this._perspectiveMatrixManager=new ae(e,this._camera,s,r,i),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s,r,i),this._equatorialGrid=new Me(this._webgl,this._healpixGrid),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(){this._camera=new k([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=A(e.phi,e.theta),i=T(t.ra),s=I(t.dec);return this.centralPoinCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:s},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,s=this.mouseHelper.decDMS;return this.mousePointCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:s},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,s=this.clamp(Math.abs(t)/120,Pe.MIN_WHEEL_SCALE,Pe.MAX_WHEEL_SCALE);return i*this.clamp(.0012+.0025*Math.sqrt(Math.max(e,0)),.0012,.04)*s*this.zoomSensitivity}setZoomSensitivity(e){this.zoomSensitivity=this.clamp(e,.2,3)}getZoomSensitivity(){return this.zoomSensitivity}emitCameraChanged(e){if(!this._activeHiPS)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){G.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 s=Y.getIntersectionPointWithSingleModel(this.lastMouseX,this.lastMouseY,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return s&&s.length>0?(this.mouseHelper.update(s),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(),s=t.clientX-i.left,r=t.clientY-i.top;this.lastMouseX=s,this.lastMouseY=r;const o=Math.hypot(s-(this.pointerDownX??s),r-(this.pointerDownY??r)),a=Date.now()-this.pointerDownAt;if(o<=4&&a<=250){const e=Y.getIntersectionPointWithSingleModel(s,r,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(),s=t.clientX-i.left,r=t.clientY-i.top,o=s,a=r;if(this._healpixGrid){if(this.mouseDown){document.body.style.cursor="grab";const t=(o-(this.lastMouseX??o))*Math.PI/e.width,i=(a-(this.lastMouseY??a))*Math.PI/e.height;this.inertiaX+=.1*t,this.inertiaY+=.1*i,this.updateCentralPoint()}else{const e=Y.getIntersectionPointWithSingleModel(s,r,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=a,this._cameraStatusChanged=!0,this.emitCameraChanged("pointermove"),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.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(),s=t.clientX-i.left,r=t.clientY-i.top,o=Y.getIntersectionPointWithSingleModel(s,r,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,s=t.height;return M(Y.getIntersectionPointWithSingleModel(i/2,s/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix))}activateHiPS(e){this._activeHiPS=new oe(1,[0,0,0],0,0,e,this._webgl,this._healpixGrid)}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)}getHoveredFootprints(){let e=[];return this.activeFootprintSets.forEach(t=>{e.push(t.hoveredFootprints)}),e}goTo(e,t){this._camera.goTo(e,t)}getFoV(){return this.fov}getFoVPolygon(){if(null==this.healpixGrid)throw new Error(`healpixGrid is ${this.healpixGrid}`);return le.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,r,!1)}getInsideSphere(){return G.insideSphere}toggleInsideSphere(){G.insideSphere=!G.insideSphere,this._camera.toggleInsideSphere()}setCameraPosition(e){this._camera.setCameraPosition(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s,r,G.insideSphere)}setCameraMatrix(e){this._camera.setCameraMatrix(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s,r,G.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;return null==e||null==t?null:{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 he({raDeg:e,decDeg:t},ne.ASTRO),mouseHoverPoint:this.mousePointCoords,colorMap:this._selectedColorMap,getFoVPolygon:this.getFoVPolygon()}}changeColorMap(e){this._activeHiPS&&(this._selectedColorMap=e,this._activeHiPS?.changeColorMap(e))}prevFov=0;prevCentralRaDeg=null;prevCentralDecDeg=null;get activeHiPS(){return this._activeHiPS}draw(e){if(this._refreshingStatus)return;if(!this._webgl)return;if(!this._activeHiPS)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,r,G.insideSphere);let t=!1,i=0,o=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.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,i=this.inertiaY,o=this.inertiaX,this.inertiaX*=.95,this.inertiaY*=.95,this._camera.rotate(o,i),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s,r,G.insideSphere)):(this.inertiaY=0,this.inertiaX=0),t){const e=this.updateCentralPoint(),t=e.astroDeg.ra,i=e.astroDeg.dec,s=null===this.prevCentralRaDeg||Math.abs(t-this.prevCentralRaDeg)>1e-5,r=null===this.prevCentralDecDeg||Math.abs(i-this.prevCentralDecDeg)>1e-5;(s||r)&&(this.prevCentralRaDeg=t,this.prevCentralDecDeg=i)}if(this._cameraStatusChanged){const e=this.getCurrentStatus();e&&this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:e,bubbles:!0,composed:!0})),this.startup||(this._cameraStatusChanged=!1)}this._webgl.disable(this._webgl.DEPTH_TEST),this._webgl.enable(this._webgl.BLEND),this._webgl.enable(this._webgl.CULL_FACE),this._webgl.cullFace(G.insideSphere?this._webgl.BACK:this._webgl.FRONT),this._webgl.blendFunc(this._webgl.SRC_ALPHA,this._webgl.ONE_MINUS_SRC_ALPHA);const a=Math.min(this._healpixGrid.visibleorder,this._activeHiPS.maxOrder);this._healpixGrid.visibleTilesManager.computeVisiblePixels(a,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);const n={fovDeg:this._healpixGrid.getMinFoV(),camera:this._camera,pMatrix:this._perspectiveMatrixManager.pMatrix};if(this._activeHiPS.draw(n),this._healpixGrid.draw(n),this._equatorialGrid.draw(n),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=A(t.phi,t.theta),s=T(i.ra),r=I(i.dec);this.prevFov=this._healpixGrid.getMinFoV(),this._cameraStatusChanged=!0,console.log("(startup coords)",{raDeg:i.ra,decDeg:i.dec,raHMS:s,decDMS:r})}this.activeCatalogues.forEach(e=>{this._activeHiPS&&e.draw(this._activeHiPS.getModelMatrix(),this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.emitHoveredSourceIfChanged(),this.activeFootprintSets.forEach(e=>{this._activeHiPS&&e.draw(this._activeHiPS.getModelMatrix(),this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)})}emitHoveredSourceIfChanged(){let e=null,t=null;for(const i of this.activeCatalogues){const s=i.getPrimaryHoveredSource();if(s){e=s,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})))}}const we=Pe;class ye{_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(),s=this.getValue(t);if(i&&void 0!==s&&this._propertiesMap.set(i,s),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}}class Ae{_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=G.getHealpix(G.nsideForSelection),t=new L(this._point.x,this._point.y,this._point.z),i=new R(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}}class Ce{_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=W.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=W.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 s=this._webgl;s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let r=p();r=v(r,i,t),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.mvMatrix,!1,r)}}var Ee;!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"}(Ee||(Ee={}));class Te{_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??Ee.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)}}}class Ie{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==Ee.NUMBER&&(this.addHueColumn(e),this.addShapeColumn(e)),e.columnType==Ee.GEOM_RA&&this.addRaColumn(e),e.columnType==Ee.GEOM_DEC&&this.addDecColumn(e),e.columnType==Ee.GEOM_FOOTPRINT&&this.addOutlineColumn(e),e.columnType==Ee.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 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._shapeColumnList.find(t=>t.name===e)}resetShapeColumn(){this._selectedShapeColumn=void 0}resetHueColumn(){this._selectedHueColumn=void 0}}class Fe{_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,s,r,o){this._webgl=r,this._ready=!1,this._visibleTilesManager=o,this.TYPE="SOURCE_CATALOGUE",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=s,this._sources=[],this.vertexCataloguePosition=new Float32Array(0),this.hoveredIndexes=[],this.selectedIndexes=[],this.extHoveredIndexes=[],this._oldMouseCoords=null,this._healpixDensityMap=new Map,this._catalogueShaderProgram=new Ce(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 s of this._sources){const r=s.details[e];if(isNaN(Number(r)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain number only values`),{min:0,max:0};r<t&&(t=r),r>i&&(i=r)}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==Ie.STANDARD_SIZE){this._metadataManager.resetShapeColumn();for(const e of this._sources){const t=Fe.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 s=this.minMax(i);if(s.min!=s.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),r=Number(s.min),o=Number(s.max),a=(t-r)/Math.max(1e-12,o-r)*12+8;e.shapeSize=a}this._bufferInitialised=!1}else console.warn(`${s} min and max are equals. No resizing will be applied.`)}changeMetaShapeHue(e){if(!this._webgl)return;if(e==Ie.STANDARD_HUE){this._metadataManager.resetHueColumn();for(const e of this._sources){const t=Fe.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 s=this.minMax(i);if(s.min!=s.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),r=Number(s.min),o=Number(s.max),a=(t-r)/Math.max(1e-12,o-r);e.brightnessFactor=-(2*a-1)}this._bufferInitialised=!1}else console.warn(`${s} 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 Ie(t);const i=this._metadataManager.selectedRaColumn?.index??-1,s=this._metadataManager.selectedDecColumn?.index??-1;if(i<0||s<0)throw new Error(`(ra, dec) idx not defined (${i}, ${s}) `);for(let t=0;t<e.length;t++){const r=new he({raDeg:e[t][i],decDeg:e[t][s]},ne.ASTRO),o=new Ae(r,e[t]);o.shapeSize=o.shapeSize??Fe.STANDARD_SHAPE_SIZE,o.brightnessFactor=3,this.addSource(o),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,s=t.point;if(i.raDeg!==s.raDeg||i.decDeg!==s.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 s=i*Fe.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(s+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&(this.hoveredIndexes.splice(e,1),this.vertexCataloguePosition[s+3]=0,this.vertexCataloguePosition[s+4]=this._sources[i]?.shapeSize??Fe.STANDARD_SHAPE_SIZE)}}extAddSources2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findSourceIndex(e);if(t<0)return;const i=t*Fe.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??Fe.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*Fe.ELEM_SIZE);let t=0;for(let i=0;i<e;i++){const e=this._sources[i],s=e.healpixPixel,r=this._healpixDensityMap.get(s);r?r.includes(i)||r.push(i):this._healpixDensityMap.set(s,[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??Fe.STANDARD_SHAPE_SIZE,this.vertexCataloguePosition[t+5]=e.brightnessFactor??0,t+=Fe.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 s=this._healpixDensityMap.get(i),r=this.getSelectionRadius();for(let i=0;i<s.length;i++){const o=s[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,h=a.point.y-e.y,l=a.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=r&&t.push(o)}}return t}setSelectedIndexes(e){e.forEach(e=>{if(e<0||e>=this._sources.length)return;const t=e*Fe.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??Fe.STANDARD_SHAPE_SIZE):(this.selectedIndexes.push(e),this.vertexCataloguePosition[t+3]=2,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??Fe.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 s=[],r=[];return i.forEach(e=>{const t=this._sources[e];if(!t)return;const i=this.selectedIndexes.includes(e);s.push({source:t,selected:i}),r.push(t)}),r.length?{sources:r,selectionState:s}: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 s=this._healpixDensityMap.get(i),r=this.getSelectionRadius();for(let i=0;i<s.length;i++){const o=s[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,h=a.point.y-e.y,l=a.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=r&&t.push(o)}}return t}draw(e,t,i,s){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;this._catalogueShaderProgram.enableShaders(s,e,i),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.position,3,this._webgl.FLOAT,!1,Fe.BYTES_X_ELEM*Fe.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.position),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.hovered,1,this._webgl.FLOAT,!1,Fe.BYTES_X_ELEM*Fe.ELEM_SIZE,3*Fe.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.hovered),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.pointSize,1,this._webgl.FLOAT,!1,Fe.BYTES_X_ELEM*Fe.ELEM_SIZE,4*Fe.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.pointSize),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.brightness,1,this._webgl.FLOAT,!1,Fe.BYTES_X_ELEM*Fe.ELEM_SIZE,5*Fe.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.brightness);const r=P(this._shapeColor);this._catalogueShaderProgram.locations.color&&this._webgl.uniform4f(this._catalogueShaderProgram.locations.color,r[0],r[1],r[2],1);for(let e=0;e<this.selectedIndexes.length;e++){const t=this.selectedIndexes[e],i=t*Fe.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]*Fe.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*Fe.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/Fe.ELEM_SIZE;this._webgl.drawArrays(this._webgl.POINTS,0,o),this._oldMouseCoords=t.xyz}}class Re{static parseSTCS(e){const t=Re.cleanStcs(e);return t.includes("POLYGON")?Re.parsePolygon(t):t.includes("CIRCLE")?Re.parseCircle(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){let t=0;const i=[],s=G.MAX_DECIMALS??12,r=e.split("POLYGON ");for(let e=1;e<r.length;e++){const o=[],a=r[e].trim().split(" "),n=Number(parseFloat(a[0]).toFixed(s)),h=Number(parseFloat(a[1]).toFixed(s)),l=Number(parseFloat(a[a.length-2]).toFixed(s)),c=Number(parseFloat(a[a.length-1]).toFixed(s));if(n===l&&h===c&&a.splice(a.length-2,2),a.length>2){for(let e=0;e<a.length-1;e+=2){const i=Number(parseFloat(a[e]).toFixed(s)),r=Number(parseFloat(a[e+1]).toFixed(s)),n=new he({raDeg:i,decDeg:r},ne.ASTRO);o.push(n),t+=1}i.push(o)}}return{totpoints:t,polygons:i}}static parseCircle(e){let t=0;const i=[],s=e.split("CIRCLE ");for(let e=1;e<s.length;e++){const r=[],o=s[e].trim().split(" "),a=Number(o[0]),n=Number(o[1]),h=Number(o[2]),l=24,c=2*Math.PI/l;for(let e=l;e>0;e--){const i=h*Math.cos(e*c)+a,s=h*Math.sin(e*c)+n,o=new he({raDeg:i,decDeg:s},ne.ASTRO);r.push(o),t+=1}i.push(r)}return{totpoints:t,polygons:i}}}const De=Re;class Be{_polygons=[];_convexPolygons=[];_stcs;_valid=!1;_details;_totPoints=0;_totConvexPoints=0;_npix256;_footprintsPointsOrder;_selectionObj;_identifier;_center;constructor(e,t=[],i){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=[]}computeSelectionObject(){return me.computeSelectionObject(this._polygons)}computePoints(){const e=De.parseSTCS(this._stcs);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}}class Le{_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=W.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=W.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 s=this._webgl;s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let r=p();r=v(r,i,t),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.mvMatrix,!1,r)}}class Ne{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";_bufferInitialised=!1;_webgl;_isVisible=!0;_metadataManager;_providerUrl;_footprintShaderProgram;_visibleTilesManager;constructor(e,t,i,s,r,o){this._webgl=r,this._ready=!1,this._visibleTilesManager=o,this.TYPE="FOOTPRINT_SET",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=s,this.initFootprintArrays(),this.oldMouseCoords=null,this._footprintShaderProgram=new Le(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 Ie(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][0]){const s=new Be(e[t][i],e[t]);s._valid&&(this.addFootprint(s),this.totPoints+=s.totPoints,this.totConvexPoints+=s.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 s=0,r=0;this.nPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this.footprintPolygons[t].polygons;t>0&&(this.indexes[r++]=i,this.nPrimitiveFlags++);for(const t of e){t!==e[0]&&(this.indexes[r++]=i,this.nPrimitiveFlags++);for(const e of t)this.vertexCataloguePosition[s++]=1*e.x,this.vertexCataloguePosition[s++]=1*e.y,this.vertexCataloguePosition[s++]=1*e.z,this.indexes[r++]=Math.floor((s-1)/3)}}this.indexes[this.indexes.length-1]=i,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 he({x:e.x,y:e.y,z:e.z},ne.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const i=this.footprintPolygons[e];if(i.selectionObj&&me.checkPointInsidePolygon5(i.selectionObj,t)){const e=[...i.details],t=this._metadataManager.selectedOutlineColumn?.index??-1;if(t<0)continue;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 he({x:e.x,y:e.y,z:e.z},ne.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const s=this.footprintPolygons[e];s.selectionObj&&me.checkPointInsidePolygon5(s.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 s=[],r=[];return i.forEach(e=>{const t=this.footprintPolygons[e];if(!t)return;const i=this.selectedIndexes.includes(e);s.push({footprint:t,selected:i}),r.push(t)}),r.length?{footprints:r,selectionState:s}:null}FootprintPolygonMatches(e,t){if(e===t)return!0;const i=e.convexPolygons,s=t.convexPolygons;if(i!==s||i!==s)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 s=i*Ne.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(s+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*Ne.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 s=0,r=0;this.nHoveredPrimitiveFlags=0;for(let t=0;t<e;t++){let e=this._hoveredFootprints[t].polygons;t>0&&(this.hoveredElementIndexes[r]=i,this.nHoveredPrimitiveFlags+=1,r+=1);for(let t=0;t<e.length;t++){t>0&&(this.hoveredElementIndexes[r]=i,this.nHoveredPrimitiveFlags+=1,r+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.hoveredVertexPosition[s]=1*t.x,this.hoveredVertexPosition[s+1]=1*t.y,this.hoveredVertexPosition[s+2]=1*t.z,this.hoveredElementIndexes[r]=Math.floor(s/3),r+=1,s+=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 s=0,r=0;this.nSlectedPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this._selectedFootprints[t].polygons;t>0&&(this.selectedElementIndexes[r]=i,this.nSlectedPrimitiveFlags+=1,r+=1);for(let t=0;t<e.length;t++){t>0&&(this.selectedElementIndexes[r]=i,this.nSlectedPrimitiveFlags+=1,r+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.selectedVertexPosition[s]=1*t.x,this.selectedVertexPosition[s+1]=1*t.y,this.selectedVertexPosition[s+2]=1*t.z,this.selectedElementIndexes[r]=Math.floor(s/3),r+=1,s+=3}}}}changeColor(e){this._shapeColor=e}draw(e,t,i,s){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;if(this._footprintShaderProgram.enableShaders(s,e,i),null!=t&&t.xyz!=this.oldMouseCoords&&this.checkSelection(t),this._hoveredFootprints.length>0){const e=P("#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,Ne.ELEM_SIZE,this._webgl.FLOAT,!1,Ne.BYTES_X_ELEM*Ne.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=P("#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,Ne.ELEM_SIZE,this._webgl.FLOAT,!1,Ne.BYTES_X_ELEM*Ne.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.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,Ne.ELEM_SIZE,this._webgl.FLOAT,!1,Ne.BYTES_X_ELEM*Ne.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexes,this._webgl.STATIC_DRAW);const r=[...P(this._shapeColor),1];this._webgl.uniform4f(this._footprintShaderProgram.locations.color,...r),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}}class Ve{astroSphere;canvas;webgl;rafId=null;webglContextList=new Map;viewfinderEl=null;viewfinderVisible=false;viewfinderColor="rgba(75,148,226,0.68)";run(){return this.tick()}createCatalogue(e,t,i,s){return new Fe(e,t,i,s,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,s){return new Ne(e,t,i,s,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideFootprintSet(e,t){e.setIsVisible(t)}deleteFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}changeFootprintSetColor(e,t){e.changeColor(t)}getHoveredFootprints(){return this.astroSphere.getHoveredFootprints()}getDefaultHiPSURL(){return"https://cdn.skies.esac.esa.int/DSSColor/"}activateHiPS(e){this.astroSphere.activateHiPS(e)}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 s=await i.text(),r=new ye(s,t);return this.astroSphere.activateHiPS(r),r.surveyName}changeColorMap(e){const t=J[e];this.astroSphere.changeColorMap(t)}changeCustomColorMap(e){this.astroSphere.changeColorMap(e)}getActiveHiPS(){return this.astroSphere.activeHiPS}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)}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()}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){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 we(this.canvas,this.webgl)}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)),s=Math.max(1,Math.floor(e.height*t));this.canvas.width===i&&this.canvas.height===s||(this.canvas.width=i,this.canvas.height=s,this.webgl.viewport(0,0,this.canvas.width,this.canvas.height))};"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)}}return console.log("astroviewer UMD loaded"),t})());
|
|
2
|
+
//# sourceMappingURL=astroviewer.js.map
|