astro-viewer 3.3.0 → 3.7.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.
Files changed (388) hide show
  1. package/DEPENDENCY-LICENSING.md +185 -0
  2. package/LICENSE-AGPL.md +661 -0
  3. package/LICENSE-COMMERCIAL.md +37 -0
  4. package/LICENSE.md +52 -13
  5. package/README.md +39 -16
  6. package/dist/64.astroviewer.cjs +37 -0
  7. package/dist/64.astroviewer.cjs.map +1 -0
  8. package/dist/64.astroviewer.js +41 -0
  9. package/dist/64.astroviewer.js.map +1 -0
  10. package/dist/64.astroviewer.min.js +2 -0
  11. package/dist/64.astroviewer.min.js.map +1 -0
  12. package/dist/911.astroviewer.cjs +4047 -0
  13. package/dist/911.astroviewer.cjs.map +1 -0
  14. package/dist/911.astroviewer.js +735 -0
  15. package/dist/911.astroviewer.js.map +1 -0
  16. package/dist/911.astroviewer.min.js +2 -0
  17. package/dist/911.astroviewer.min.js.map +1 -0
  18. package/dist/astroviewer.cjs +17550 -18845
  19. package/dist/astroviewer.cjs.map +1 -0
  20. package/dist/astroviewer.js +21710 -1
  21. package/dist/astroviewer.js.map +1 -0
  22. package/dist/astroviewer.min.js +2 -1
  23. package/dist/astroviewer.min.js.map +1 -0
  24. package/lib-esm/AstroSphere.d.ts +20 -2
  25. package/lib-esm/AstroSphere.d.ts.map +1 -0
  26. package/lib-esm/AstroSphere.js +81 -36
  27. package/lib-esm/AstroSphere.js.map +1 -0
  28. package/lib-esm/AstroViewer.d.ts +44 -20
  29. package/lib-esm/AstroViewer.d.ts.map +1 -0
  30. package/lib-esm/AstroViewer.js +148 -76
  31. package/lib-esm/AstroViewer.js.map +1 -0
  32. package/lib-esm/Camera.d.ts +1 -0
  33. package/lib-esm/Camera.d.ts.map +1 -0
  34. package/lib-esm/Camera.js +5 -6
  35. package/lib-esm/Camera.js.map +1 -0
  36. package/lib-esm/Config.d.ts +1 -0
  37. package/lib-esm/Config.d.ts.map +1 -0
  38. package/lib-esm/Config.js +5 -6
  39. package/lib-esm/Config.js.map +1 -0
  40. package/lib-esm/Global.d.ts +2 -1
  41. package/lib-esm/Global.d.ts.map +1 -0
  42. package/lib-esm/Global.js +6 -7
  43. package/lib-esm/Global.js.map +1 -0
  44. package/lib-esm/index.d.ts +11 -0
  45. package/lib-esm/index.d.ts.map +1 -0
  46. package/lib-esm/index.js +9 -6
  47. package/lib-esm/index.js.map +1 -0
  48. package/lib-esm/model/AbstractSkyEntity.d.ts +1 -0
  49. package/lib-esm/model/AbstractSkyEntity.d.ts.map +1 -0
  50. package/lib-esm/model/AbstractSkyEntity.js +5 -6
  51. package/lib-esm/model/AbstractSkyEntity.js.map +1 -0
  52. package/lib-esm/model/AstroGL.d.ts +1 -0
  53. package/lib-esm/model/AstroGL.d.ts.map +1 -0
  54. package/lib-esm/model/AstroGL.js +5 -6
  55. package/lib-esm/model/AstroGL.js.map +1 -0
  56. package/lib-esm/model/ColorMaps.d.ts +1 -0
  57. package/lib-esm/model/ColorMaps.d.ts.map +1 -0
  58. package/lib-esm/model/ColorMaps.js +5 -6
  59. package/lib-esm/model/ColorMaps.js.map +1 -0
  60. package/lib-esm/model/MetadataColumn.d.ts +1 -0
  61. package/lib-esm/model/MetadataColumn.d.ts.map +1 -0
  62. package/lib-esm/model/MetadataColumn.js +5 -6
  63. package/lib-esm/model/MetadataColumn.js.map +1 -0
  64. package/lib-esm/model/MetadataManager.d.ts +1 -0
  65. package/lib-esm/model/MetadataManager.d.ts.map +1 -0
  66. package/lib-esm/model/MetadataManager.js +5 -6
  67. package/lib-esm/model/MetadataManager.js.map +1 -0
  68. package/lib-esm/model/Point.d.ts +1 -0
  69. package/lib-esm/model/Point.d.ts.map +1 -0
  70. package/lib-esm/model/Point.js +5 -6
  71. package/lib-esm/model/Point.js.map +1 -0
  72. package/lib-esm/model/Point2D.d.ts +1 -0
  73. package/lib-esm/model/Point2D.d.ts.map +1 -0
  74. package/lib-esm/model/Point2D.js +5 -6
  75. package/lib-esm/model/Point2D.js.map +1 -0
  76. package/lib-esm/model/Source.d.ts +1 -0
  77. package/lib-esm/model/Source.d.ts.map +1 -0
  78. package/lib-esm/model/Source.js +6 -7
  79. package/lib-esm/model/Source.js.map +1 -0
  80. package/lib-esm/model/SphereFoV.d.ts +1 -0
  81. package/lib-esm/model/SphereFoV.d.ts.map +1 -0
  82. package/lib-esm/model/SphereFoV.js +5 -6
  83. package/lib-esm/model/SphereFoV.js.map +1 -0
  84. package/lib-esm/model/catalogues/CatalogueGL.d.ts +1 -0
  85. package/lib-esm/model/catalogues/CatalogueGL.d.ts.map +1 -0
  86. package/lib-esm/model/catalogues/CatalogueGL.js +5 -6
  87. package/lib-esm/model/catalogues/CatalogueGL.js.map +1 -0
  88. package/lib-esm/model/catalogues/CatalogueProps.d.ts +1 -0
  89. package/lib-esm/model/catalogues/CatalogueProps.d.ts.map +1 -0
  90. package/lib-esm/model/catalogues/CatalogueProps.js +5 -6
  91. package/lib-esm/model/catalogues/CatalogueProps.js.map +1 -0
  92. package/lib-esm/model/earth/WMTSAdapter.d.ts +1 -0
  93. package/lib-esm/model/earth/WMTSAdapter.d.ts.map +1 -0
  94. package/lib-esm/model/earth/WMTSAdapter.js +5 -6
  95. package/lib-esm/model/earth/WMTSAdapter.js.map +1 -0
  96. package/lib-esm/model/earth/XYZAnchestorTile.d.ts +1 -0
  97. package/lib-esm/model/earth/XYZAnchestorTile.d.ts.map +1 -0
  98. package/lib-esm/model/earth/XYZAnchestorTile.js +5 -6
  99. package/lib-esm/model/earth/XYZAnchestorTile.js.map +1 -0
  100. package/lib-esm/model/earth/XYZConfig.d.ts +1 -0
  101. package/lib-esm/model/earth/XYZConfig.d.ts.map +1 -0
  102. package/lib-esm/model/earth/XYZConfig.js +5 -6
  103. package/lib-esm/model/earth/XYZConfig.js.map +1 -0
  104. package/lib-esm/model/earth/XYZFoVHelper.d.ts +1 -0
  105. package/lib-esm/model/earth/XYZFoVHelper.d.ts.map +1 -0
  106. package/lib-esm/model/earth/XYZFoVHelper.js +5 -6
  107. package/lib-esm/model/earth/XYZFoVHelper.js.map +1 -0
  108. package/lib-esm/model/earth/XYZMap.d.ts +3 -1
  109. package/lib-esm/model/earth/XYZMap.d.ts.map +1 -0
  110. package/lib-esm/model/earth/XYZMap.js +7 -8
  111. package/lib-esm/model/earth/XYZMap.js.map +1 -0
  112. package/lib-esm/model/earth/XYZMapDescriptor.d.ts +1 -0
  113. package/lib-esm/model/earth/XYZMapDescriptor.d.ts.map +1 -0
  114. package/lib-esm/model/earth/XYZMapDescriptor.js +5 -6
  115. package/lib-esm/model/earth/XYZMapDescriptor.js.map +1 -0
  116. package/lib-esm/model/earth/XYZMeshBuilder.d.ts +1 -0
  117. package/lib-esm/model/earth/XYZMeshBuilder.d.ts.map +1 -0
  118. package/lib-esm/model/earth/XYZMeshBuilder.js +5 -6
  119. package/lib-esm/model/earth/XYZMeshBuilder.js.map +1 -0
  120. package/lib-esm/model/earth/XYZTile.d.ts +1 -0
  121. package/lib-esm/model/earth/XYZTile.d.ts.map +1 -0
  122. package/lib-esm/model/earth/XYZTile.js +5 -6
  123. package/lib-esm/model/earth/XYZTile.js.map +1 -0
  124. package/lib-esm/model/earth/XYZTileBuffer.d.ts +1 -0
  125. package/lib-esm/model/earth/XYZTileBuffer.d.ts.map +1 -0
  126. package/lib-esm/model/earth/XYZTileBuffer.js +5 -6
  127. package/lib-esm/model/earth/XYZTileBuffer.js.map +1 -0
  128. package/lib-esm/model/earth/XYZTileRequestScheduler.d.ts +1 -0
  129. package/lib-esm/model/earth/XYZTileRequestScheduler.d.ts.map +1 -0
  130. package/lib-esm/model/earth/XYZTileRequestScheduler.js +5 -6
  131. package/lib-esm/model/earth/XYZTileRequestScheduler.js.map +1 -0
  132. package/lib-esm/model/earth/XYZTypes.d.ts +1 -0
  133. package/lib-esm/model/earth/XYZTypes.d.ts.map +1 -0
  134. package/lib-esm/model/earth/XYZTypes.js +5 -6
  135. package/lib-esm/model/earth/XYZTypes.js.map +1 -0
  136. package/lib-esm/model/earth/XYZVisibleTilesManager.d.ts +1 -0
  137. package/lib-esm/model/earth/XYZVisibleTilesManager.d.ts.map +1 -0
  138. package/lib-esm/model/earth/XYZVisibleTilesManager.js +5 -6
  139. package/lib-esm/model/earth/XYZVisibleTilesManager.js.map +1 -0
  140. package/lib-esm/model/footprints/Footprint.d.ts +1 -0
  141. package/lib-esm/model/footprints/Footprint.d.ts.map +1 -0
  142. package/lib-esm/model/footprints/Footprint.js +5 -9
  143. package/lib-esm/model/footprints/Footprint.js.map +1 -0
  144. package/lib-esm/model/footprints/FootprintProps.d.ts +1 -0
  145. package/lib-esm/model/footprints/FootprintProps.d.ts.map +1 -0
  146. package/lib-esm/model/footprints/FootprintProps.js +5 -6
  147. package/lib-esm/model/footprints/FootprintProps.js.map +1 -0
  148. package/lib-esm/model/footprints/FootprintSetGL.d.ts +1 -0
  149. package/lib-esm/model/footprints/FootprintSetGL.d.ts.map +1 -0
  150. package/lib-esm/model/footprints/FootprintSetGL.js +5 -6
  151. package/lib-esm/model/footprints/FootprintSetGL.js.map +1 -0
  152. package/lib-esm/model/grid/EquatorialGrid.d.ts +3 -1
  153. package/lib-esm/model/grid/EquatorialGrid.d.ts.map +1 -0
  154. package/lib-esm/model/grid/EquatorialGrid.js +8 -8
  155. package/lib-esm/model/grid/EquatorialGrid.js.map +1 -0
  156. package/lib-esm/model/grid/GridTextHelper.d.ts +13 -4
  157. package/lib-esm/model/grid/GridTextHelper.d.ts.map +1 -0
  158. package/lib-esm/model/grid/GridTextHelper.js +72 -30
  159. package/lib-esm/model/grid/GridTextHelper.js.map +1 -0
  160. package/lib-esm/model/grid/HealpixGrid.d.ts +3 -1
  161. package/lib-esm/model/grid/HealpixGrid.d.ts.map +1 -0
  162. package/lib-esm/model/grid/HealpixGrid.js +8 -8
  163. package/lib-esm/model/grid/HealpixGrid.js.map +1 -0
  164. package/lib-esm/model/grid/LonLatGrid.d.ts +3 -1
  165. package/lib-esm/model/grid/LonLatGrid.d.ts.map +1 -0
  166. package/lib-esm/model/grid/LonLatGrid.js +8 -8
  167. package/lib-esm/model/grid/LonLatGrid.js.map +1 -0
  168. package/lib-esm/model/hips/AllSky.d.ts +8 -3
  169. package/lib-esm/model/hips/AllSky.d.ts.map +1 -0
  170. package/lib-esm/model/hips/AllSky.js +98 -34
  171. package/lib-esm/model/hips/AllSky.js.map +1 -0
  172. package/lib-esm/model/hips/AncestorTile.d.ts +8 -4
  173. package/lib-esm/model/hips/AncestorTile.d.ts.map +1 -0
  174. package/lib-esm/model/hips/AncestorTile.js +96 -58
  175. package/lib-esm/model/hips/AncestorTile.js.map +1 -0
  176. package/lib-esm/model/hips/FitsTileLoader.d.ts +9 -0
  177. package/lib-esm/model/hips/FitsTileLoader.d.ts.map +1 -0
  178. package/lib-esm/model/hips/FitsTileLoader.js +65 -0
  179. package/lib-esm/model/hips/FitsTileLoader.js.map +1 -0
  180. package/lib-esm/model/hips/FoVHelper.d.ts +1 -0
  181. package/lib-esm/model/hips/FoVHelper.d.ts.map +1 -0
  182. package/lib-esm/model/hips/FoVHelper.js +5 -6
  183. package/lib-esm/model/hips/FoVHelper.js.map +1 -0
  184. package/lib-esm/model/hips/HiPS.d.ts +10 -5
  185. package/lib-esm/model/hips/HiPS.d.ts.map +1 -0
  186. package/lib-esm/model/hips/HiPS.js +125 -78
  187. package/lib-esm/model/hips/HiPS.js.map +1 -0
  188. package/lib-esm/model/hips/HiPSConfig.d.ts +1 -0
  189. package/lib-esm/model/hips/HiPSConfig.d.ts.map +1 -0
  190. package/lib-esm/model/hips/HiPSConfig.js +1 -0
  191. package/lib-esm/model/hips/HiPSConfig.js.map +1 -0
  192. package/lib-esm/model/hips/HiPSCoverage.d.ts +15 -0
  193. package/lib-esm/model/hips/HiPSCoverage.d.ts.map +1 -0
  194. package/lib-esm/model/hips/HiPSCoverage.js +148 -0
  195. package/lib-esm/model/hips/HiPSCoverage.js.map +1 -0
  196. package/lib-esm/model/hips/HiPSDescriptor.d.ts +1 -0
  197. package/lib-esm/model/hips/HiPSDescriptor.d.ts.map +1 -0
  198. package/lib-esm/model/hips/HiPSDescriptor.js +5 -6
  199. package/lib-esm/model/hips/HiPSDescriptor.js.map +1 -0
  200. package/lib-esm/model/hips/Tile.d.ts +9 -4
  201. package/lib-esm/model/hips/Tile.d.ts.map +1 -0
  202. package/lib-esm/model/hips/Tile.js +116 -61
  203. package/lib-esm/model/hips/Tile.js.map +1 -0
  204. package/lib-esm/model/hips/TileBuffer.d.ts +14 -4
  205. package/lib-esm/model/hips/TileBuffer.d.ts.map +1 -0
  206. package/lib-esm/model/hips/TileBuffer.js +51 -17
  207. package/lib-esm/model/hips/TileBuffer.js.map +1 -0
  208. package/lib-esm/model/hips/VisibleTilesManager.d.ts +6 -5
  209. package/lib-esm/model/hips/VisibleTilesManager.d.ts.map +1 -0
  210. package/lib-esm/model/hips/VisibleTilesManager.js +11 -26
  211. package/lib-esm/model/hips/VisibleTilesManager.js.map +1 -0
  212. package/lib-esm/model/meships/MeshHiPS.d.ts +1 -0
  213. package/lib-esm/model/meships/MeshHiPS.d.ts.map +1 -0
  214. package/lib-esm/model/meships/MeshHiPS.js +1 -0
  215. package/lib-esm/model/meships/MeshHiPS.js.map +1 -0
  216. package/lib-esm/model/meships/MeshHiPSDescriptor.d.ts +1 -0
  217. package/lib-esm/model/meships/MeshHiPSDescriptor.d.ts.map +1 -0
  218. package/lib-esm/model/meships/MeshHiPSDescriptor.js +1 -0
  219. package/lib-esm/model/meships/MeshHiPSDescriptor.js.map +1 -0
  220. package/lib-esm/model/meships/MeshHiPSTile.d.ts +1 -0
  221. package/lib-esm/model/meships/MeshHiPSTile.d.ts.map +1 -0
  222. package/lib-esm/model/meships/MeshHiPSTile.js +1 -0
  223. package/lib-esm/model/meships/MeshHiPSTile.js.map +1 -0
  224. package/lib-esm/model/meships/MeshHiPSTypes.d.ts +1 -0
  225. package/lib-esm/model/meships/MeshHiPSTypes.d.ts.map +1 -0
  226. package/lib-esm/model/meships/MeshHiPSTypes.js +1 -0
  227. package/lib-esm/model/meships/MeshHiPSTypes.js.map +1 -0
  228. package/lib-esm/model/meships/OBJMeshParser.d.ts +15 -2
  229. package/lib-esm/model/meships/OBJMeshParser.d.ts.map +1 -0
  230. package/lib-esm/model/meships/OBJMeshParser.js +162 -45
  231. package/lib-esm/model/meships/OBJMeshParser.js.map +1 -0
  232. package/lib-esm/model/observation/ObservationTrackTimeline.d.ts +26 -0
  233. package/lib-esm/model/observation/ObservationTrackTimeline.d.ts.map +1 -0
  234. package/lib-esm/model/observation/ObservationTrackTimeline.js +232 -0
  235. package/lib-esm/model/observation/ObservationTrackTimeline.js.map +1 -0
  236. package/lib-esm/model/observation/ObservationTrackTypes.d.ts +130 -0
  237. package/lib-esm/model/observation/ObservationTrackTypes.d.ts.map +1 -0
  238. package/lib-esm/model/observation/ObservationTrackTypes.js +2 -0
  239. package/lib-esm/model/observation/ObservationTrackTypes.js.map +1 -0
  240. package/lib-esm/model/observation/ObservationTrackViewerAdapter.d.ts +12 -0
  241. package/lib-esm/model/observation/ObservationTrackViewerAdapter.d.ts.map +1 -0
  242. package/lib-esm/model/observation/ObservationTrackViewerAdapter.js +328 -0
  243. package/lib-esm/model/observation/ObservationTrackViewerAdapter.js.map +1 -0
  244. package/lib-esm/model/observation/index.d.ts +4 -0
  245. package/lib-esm/model/observation/index.d.ts.map +1 -0
  246. package/lib-esm/model/observation/index.js +3 -0
  247. package/lib-esm/model/observation/index.js.map +1 -0
  248. package/lib-esm/model/tap/TapMetadata.d.ts +1 -0
  249. package/lib-esm/model/tap/TapMetadata.d.ts.map +1 -0
  250. package/lib-esm/model/tap/TapMetadata.js +5 -6
  251. package/lib-esm/model/tap/TapMetadata.js.map +1 -0
  252. package/lib-esm/model/tap/TapMetadataList.d.ts +1 -0
  253. package/lib-esm/model/tap/TapMetadataList.d.ts.map +1 -0
  254. package/lib-esm/model/tap/TapMetadataList.js +5 -6
  255. package/lib-esm/model/tap/TapMetadataList.js.map +1 -0
  256. package/lib-esm/model/tap/TapRepo.d.ts +1 -0
  257. package/lib-esm/model/tap/TapRepo.d.ts.map +1 -0
  258. package/lib-esm/model/tap/TapRepo.js +5 -6
  259. package/lib-esm/model/tap/TapRepo.js.map +1 -0
  260. package/lib-esm/model/terra/SatelliteObjectGL.d.ts +43 -0
  261. package/lib-esm/model/terra/SatelliteObjectGL.d.ts.map +1 -0
  262. package/lib-esm/model/terra/SatelliteObjectGL.js +221 -0
  263. package/lib-esm/model/terra/SatelliteObjectGL.js.map +1 -0
  264. package/lib-esm/model/terra/SensorConeGL.d.ts +34 -0
  265. package/lib-esm/model/terra/SensorConeGL.d.ts.map +1 -0
  266. package/lib-esm/model/terra/SensorConeGL.js +193 -0
  267. package/lib-esm/model/terra/SensorConeGL.js.map +1 -0
  268. package/lib-esm/model/terra/TerraFootprintSetGL.d.ts +1 -0
  269. package/lib-esm/model/terra/TerraFootprintSetGL.d.ts.map +1 -0
  270. package/lib-esm/model/terra/TerraFootprintSetGL.js +5 -6
  271. package/lib-esm/model/terra/TerraFootprintSetGL.js.map +1 -0
  272. package/lib-esm/model/terra/TerraPointSetGL.d.ts +1 -0
  273. package/lib-esm/model/terra/TerraPointSetGL.d.ts.map +1 -0
  274. package/lib-esm/model/terra/TerraPointSetGL.js +5 -6
  275. package/lib-esm/model/terra/TerraPointSetGL.js.map +1 -0
  276. package/lib-esm/model/terra/TerraPolylineSetGL.d.ts +45 -0
  277. package/lib-esm/model/terra/TerraPolylineSetGL.d.ts.map +1 -0
  278. package/lib-esm/model/terra/TerraPolylineSetGL.js +178 -0
  279. package/lib-esm/model/terra/TerraPolylineSetGL.js.map +1 -0
  280. package/lib-esm/services/SesameService.d.ts +1 -0
  281. package/lib-esm/services/SesameService.d.ts.map +1 -0
  282. package/lib-esm/services/SesameService.js +5 -6
  283. package/lib-esm/services/SesameService.js.map +1 -0
  284. package/lib-esm/services/helpers.d.ts +1 -0
  285. package/lib-esm/services/helpers.d.ts.map +1 -0
  286. package/lib-esm/services/helpers.js +5 -6
  287. package/lib-esm/services/helpers.js.map +1 -0
  288. package/lib-esm/services/hipsNodeService.d.ts +1 -0
  289. package/lib-esm/services/hipsNodeService.d.ts.map +1 -0
  290. package/lib-esm/services/hipsNodeService.js +5 -6
  291. package/lib-esm/services/hipsNodeService.js.map +1 -0
  292. package/lib-esm/services/parse-hipslist.d.ts +1 -0
  293. package/lib-esm/services/parse-hipslist.d.ts.map +1 -0
  294. package/lib-esm/services/parse-hipslist.js +5 -6
  295. package/lib-esm/services/parse-hipslist.js.map +1 -0
  296. package/lib-esm/services/queryCatalogueByFoV.d.ts +1 -0
  297. package/lib-esm/services/queryCatalogueByFoV.d.ts.map +1 -0
  298. package/lib-esm/services/queryCatalogueByFoV.js +5 -6
  299. package/lib-esm/services/queryCatalogueByFoV.js.map +1 -0
  300. package/lib-esm/services/queryFootprintSetByFov.d.ts +1 -0
  301. package/lib-esm/services/queryFootprintSetByFov.d.ts.map +1 -0
  302. package/lib-esm/services/queryFootprintSetByFov.js +5 -6
  303. package/lib-esm/services/queryFootprintSetByFov.js.map +1 -0
  304. package/lib-esm/services/tapRepoService.d.ts +1 -0
  305. package/lib-esm/services/tapRepoService.d.ts.map +1 -0
  306. package/lib-esm/services/tapRepoService.js +5 -6
  307. package/lib-esm/services/tapRepoService.js.map +1 -0
  308. package/lib-esm/services/types.d.ts +1 -0
  309. package/lib-esm/services/types.d.ts.map +1 -0
  310. package/lib-esm/services/types.js +5 -6
  311. package/lib-esm/services/types.js.map +1 -0
  312. package/lib-esm/shader/CatalogueShaderProgram.d.ts +1 -0
  313. package/lib-esm/shader/CatalogueShaderProgram.d.ts.map +1 -0
  314. package/lib-esm/shader/CatalogueShaderProgram.js +5 -6
  315. package/lib-esm/shader/CatalogueShaderProgram.js.map +1 -0
  316. package/lib-esm/shader/FootprintShaderProgram.d.ts +1 -0
  317. package/lib-esm/shader/FootprintShaderProgram.d.ts.map +1 -0
  318. package/lib-esm/shader/FootprintShaderProgram.js +5 -6
  319. package/lib-esm/shader/FootprintShaderProgram.js.map +1 -0
  320. package/lib-esm/shader/GridShaderManager.d.ts +1 -0
  321. package/lib-esm/shader/GridShaderManager.d.ts.map +1 -0
  322. package/lib-esm/shader/GridShaderManager.js +5 -6
  323. package/lib-esm/shader/GridShaderManager.js.map +1 -0
  324. package/lib-esm/shader/HiPSShaderProgram.d.ts +10 -2
  325. package/lib-esm/shader/HiPSShaderProgram.d.ts.map +1 -0
  326. package/lib-esm/shader/HiPSShaderProgram.js +96 -59
  327. package/lib-esm/shader/HiPSShaderProgram.js.map +1 -0
  328. package/lib-esm/shader/MeshHiPSShaderProgram.d.ts +7 -1
  329. package/lib-esm/shader/MeshHiPSShaderProgram.d.ts.map +1 -0
  330. package/lib-esm/shader/MeshHiPSShaderProgram.js +10 -3
  331. package/lib-esm/shader/MeshHiPSShaderProgram.js.map +1 -0
  332. package/lib-esm/shader/ShaderManager.d.ts +3 -0
  333. package/lib-esm/shader/ShaderManager.d.ts.map +1 -0
  334. package/lib-esm/shader/ShaderManager.js +198 -100
  335. package/lib-esm/shader/ShaderManager.js.map +1 -0
  336. package/lib-esm/shader/ShaderManagerMutliHiPS.d.ts +1 -0
  337. package/lib-esm/shader/ShaderManagerMutliHiPS.d.ts.map +1 -0
  338. package/lib-esm/shader/ShaderManagerMutliHiPS.js +5 -6
  339. package/lib-esm/shader/ShaderManagerMutliHiPS.js.map +1 -0
  340. package/lib-esm/shader/XYZShaderProgram.d.ts +1 -0
  341. package/lib-esm/shader/XYZShaderProgram.d.ts.map +1 -0
  342. package/lib-esm/shader/XYZShaderProgram.js +5 -6
  343. package/lib-esm/shader/XYZShaderProgram.js.map +1 -0
  344. package/lib-esm/utils/CoordsType.d.ts +1 -0
  345. package/lib-esm/utils/CoordsType.d.ts.map +1 -0
  346. package/lib-esm/utils/CoordsType.js +5 -6
  347. package/lib-esm/utils/CoordsType.js.map +1 -0
  348. package/lib-esm/utils/FoVUtils.d.ts +1 -0
  349. package/lib-esm/utils/FoVUtils.d.ts.map +1 -0
  350. package/lib-esm/utils/FoVUtils.js +5 -6
  351. package/lib-esm/utils/FoVUtils.js.map +1 -0
  352. package/lib-esm/utils/GeoJSONParser.d.ts +1 -0
  353. package/lib-esm/utils/GeoJSONParser.d.ts.map +1 -0
  354. package/lib-esm/utils/GeoJSONParser.js +5 -6
  355. package/lib-esm/utils/GeoJSONParser.js.map +1 -0
  356. package/lib-esm/utils/GeomUtils.d.ts +1 -0
  357. package/lib-esm/utils/GeomUtils.d.ts.map +1 -0
  358. package/lib-esm/utils/GeomUtils.js +5 -6
  359. package/lib-esm/utils/GeomUtils.js.map +1 -0
  360. package/lib-esm/utils/MouseHelper.d.ts +1 -0
  361. package/lib-esm/utils/MouseHelper.d.ts.map +1 -0
  362. package/lib-esm/utils/MouseHelper.js +6 -7
  363. package/lib-esm/utils/MouseHelper.js.map +1 -0
  364. package/lib-esm/utils/PerspectiveMatrixManager.d.ts +1 -0
  365. package/lib-esm/utils/PerspectiveMatrixManager.d.ts.map +1 -0
  366. package/lib-esm/utils/PerspectiveMatrixManager.js +5 -6
  367. package/lib-esm/utils/PerspectiveMatrixManager.js.map +1 -0
  368. package/lib-esm/utils/RayPickingUtils.d.ts +1 -0
  369. package/lib-esm/utils/RayPickingUtils.d.ts.map +1 -0
  370. package/lib-esm/utils/RayPickingUtils.js +5 -6
  371. package/lib-esm/utils/RayPickingUtils.js.map +1 -0
  372. package/lib-esm/utils/STCSParser.d.ts +1 -0
  373. package/lib-esm/utils/STCSParser.d.ts.map +1 -0
  374. package/lib-esm/utils/STCSParser.js +5 -6
  375. package/lib-esm/utils/STCSParser.js.map +1 -0
  376. package/lib-esm/utils/ShaderUtility.d.ts +1 -0
  377. package/lib-esm/utils/ShaderUtility.d.ts.map +1 -0
  378. package/lib-esm/utils/ShaderUtility.js +5 -6
  379. package/lib-esm/utils/ShaderUtility.js.map +1 -0
  380. package/lib-esm/utils/Utils.d.ts +1 -0
  381. package/lib-esm/utils/Utils.d.ts.map +1 -0
  382. package/lib-esm/utils/Utils.js +5 -6
  383. package/lib-esm/utils/Utils.js.map +1 -0
  384. package/lib-esm/utils/XYZRayPickingUtils.d.ts +1 -0
  385. package/lib-esm/utils/XYZRayPickingUtils.d.ts.map +1 -0
  386. package/lib-esm/utils/XYZRayPickingUtils.js +5 -6
  387. package/lib-esm/utils/XYZRayPickingUtils.js.map +1 -0
  388. package/package.json +39 -22
@@ -1 +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={146:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Source=void 0;const s=r(1138),a=i(r(4382));t.Source=class{_point;_name;_details;_h_pix;_shapesize;_brightnessFactor;constructor(e,t=[]){this._point=e,this._details=t,this._shapesize=16,this._brightnessFactor=-99,this.computeHealpixPixel()}getDetailByindex(e){if(!(e<0||e>=this._details.length))return this._details[e]}get details(){return this._details}computeHealpixPixel(){const e=a.default.getHealpix(a.default.nsideForSelection),t=new s.Vec3(this._point.x,this._point.y,this._point.z),r=new s.Pointing(t,!1);this._h_pix=e.ang2pix(r,!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}}},149:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZShaderProgram=void 0;const i=r(619);t.XYZShaderProgram=class{locations;_webgl;_shaderProgram;_colorMapBlockIndex=null;_colorMapBuffer=null;_runtimeColorMap;_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,colorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create XYZ shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setRuntimeColorMap(e){this._runtimeColorMap=e}enableShaders(e,t,r,i=0){const s=this._webgl,a=this.shaderProgram;s.useProgram(a),this.locations.pMatrix=s.getUniformLocation(a,"uPMatrix"),this.locations.mMatrix=s.getUniformLocation(a,"uMMatrix"),this.locations.vMatrix=s.getUniformLocation(a,"uVMatrix"),this.locations.sampler=s.getUniformLocation(a,"uSampler"),this.locations.colorMapIdx=s.getUniformLocation(a,"cmapIdx"),this.locations.vertexPositionAttribute=s.getAttribLocation(a,"aVertexPosition"),this.locations.textureCoordAttribute=s.getAttribLocation(a,"aTextureCoord"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,r),s.uniform1i(this.locations.sampler,0),s.uniform1i(this.locations.colorMapIdx,i),i>=2&&this.uploadColorMap(i)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec2 vTextureCoord;\n void main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n }"),r=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec2 vTextureCoord;\n uniform sampler2D uSampler;\n uniform int cmapIdx;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n out vec4 outColor;\n\n void main(void) {\n vec4 color = texture(uSampler, vTextureCoord);\n\n if (cmapIdx == 1) {\n float gray = 0.21 * color.r + 0.71 * color.g + 0.07 * color.b;\n outColor = vec4(vec3(gray), color.a);\n return;\n }\n\n if (cmapIdx >= 2) {\n int rIndex = int(clamp(color.r * 255.0, 0.0, 255.0));\n int gIndex = int(clamp(color.g * 255.0, 0.0, 255.0));\n int bIndex = int(clamp(color.b * 255.0, 0.0, 255.0));\n\n outColor = vec4(\n r_palette[rIndex] / 256.0,\n g_palette[gIndex] / 256.0,\n b_palette[bIndex] / 256.0,\n color.a\n );\n return;\n }\n\n outColor = color;\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,r),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise XYZ shaders");this.initColorMapBuffer()}compileShader(e,t){const r=this._webgl,i=r.createShader(e);if(!i)throw new Error("Could not create XYZ shader");if(r.shaderSource(i,t),r.compileShader(i),!r.getShaderParameter(i,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(i)||"XYZ shader compile error");return i}initColorMapBuffer(){const e=this._webgl,t=this._shaderProgram,r=e.getUniformBlockIndex(t,"colormap");if(r===e.INVALID_INDEX)return void(this._colorMapBlockIndex=null);this._colorMapBlockIndex=r;const i=["r_palette","g_palette","b_palette"],s=e.getUniformIndices(t,i),a=e.getActiveUniforms(t,s,e.UNIFORM_OFFSET);i.forEach((e,t)=>{this._colorMapVariableInfo[e]={index:s[t],offset:a[t]}}),this._colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._colorMapBuffer),e.bufferData(e.UNIFORM_BUFFER,12288,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._colorMapBuffer),e.uniformBlockBinding(t,r,0)}uploadColorMap(e){if(!this._colorMapBuffer||null===this._colorMapBlockIndex)return;const t=this.getColorMap(e);if(!t)return;const r=this._webgl,i=this.shaderProgram;r.uniformBlockBinding(i,this._colorMapBlockIndex,0),r.bindBuffer(r.UNIFORM_BUFFER,this._colorMapBuffer);const s=this._colorMapVariableInfo;r.bufferSubData(r.UNIFORM_BUFFER,s.r_palette.offset,t.r,0),r.bufferSubData(r.UNIFORM_BUFFER,s.g_palette.offset,t.g,0),r.bufferSubData(r.UNIFORM_BUFFER,s.b_palette.offset,t.b,0),r.bindBuffer(r.UNIFORM_BUFFER,null)}getColorMap(e){switch(e){case 2:return i.ColorMaps.planck;case 3:return i.ColorMaps.cmb;case 4:return i.ColorMaps.rainbow;case 5:return i.ColorMaps.eosb;case 6:return i.ColorMaps.cubehelix;case 7:return i.ColorMaps.hot;case 8:return i.ColorMaps.gray;default:return this._runtimeColorMap}}}},229:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fovHelper=void 0;class r{static LEVEL_HYSTERESIS=.12;static HIPS_ORDER_MIN_FOV={0:179,1:90,2:30,3:20,4:6,5:3.2,6:1.6,7:.85,8:.42,9:.21,10:.12,11:.06,12:.015,13:0};getHiPSNorder(e,t){const i=this.getRawHiPSNorder(e);if(void 0===t||t===i)return i;if(i>t){const i=r.HIPS_ORDER_MIN_FOV[t];if(i>0&&e>i*(1-r.LEVEL_HYSTERESIS))return t}else{const s=r.HIPS_ORDER_MIN_FOV[i];if(s>0&&e<s*(1+r.LEVEL_HYSTERESIS))return t}return i}getRawHiPSNorder(e){return e>=179?0:e>=90?1:e>=30?2:e>=20?3:e>=6?4:e>=3.2?5:e>=1.6?6:e>=.85?7:e>=.42?8:e>=.21?9:e>=.12?10:e>=.06?11:e>=.015?12:13}getRADegSteps(e,t=!1){let r,i;return t&&e<.21||e>=179?(r=10,i=10):e>=25?(r=9,i=9):e>=12.5?(r=8,i=8):e>=6?(r=6,i=6):e>=3.2?(r=5,i=5):e>=1.6?(r=4,i=4):e>=.85?(r=3,i=3):e>=.42?(r=2,i=2):e>=.21?(r=1,i=1):e>=.12?(r=.5,i=.5):e>=.06?(r=.25,i=.25):(r=10,i=10),{raStep:r,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}}}t.fovHelper=new r,t.default=r},592:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintSetGL=void 0;const s=r(2475),a=r(7930),o=r(8909),n=r(6553),h=i(r(2930)),l=r(8145),c=r(5403);class u{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static CONVEXPOLY_ELEM_SIZE=3;_kind="FootprintSetGL";_ready;_name;_description;extHoveredIndexes;oldMouseCoords;healpixDensityMap;totConvexPoints;vertexCataloguePositionBuffer;indexBuffer;hoveredVertexPositionBuffer;hoveredIndexBuffer;selectedVertexPositionBuffer;selectedIndexBuffer;indexes;footprintPolygons=[];vertexCataloguePosition;totPoints;nPrimitiveFlags=0;hoveredIndexes;hoveredElementIndexes;_hoveredFootprints=[];hoveredVertexPosition;totHoveredPoints;nHoveredPrimitiveFlags=0;selectedIndexes;selectedElementIndexes;_selectedFootprints=[];selectedVertexPosition;totSelectedPoints;nSlectedPrimitiveFlags=0;_shapeColor="#00fff2ff";_coordsType=l.CoordsType.ASTRO;_bufferInitialised=!1;_webgl;_isVisible=!0;_metadataManager;_providerUrl;_footprintShaderProgram;_visibleTilesManager;constructor(e,t,r,i,s,a){this._webgl=s,this._ready=!1,this._visibleTilesManager=a,this.TYPE="FOOTPRINT_SET",this._name=e,this._description=t,this._providerUrl=r,this._metadataManager=i,this.initFootprintArrays(),this.oldMouseCoords=null,this._footprintShaderProgram=new o.FootprintShaderProgram(this._webgl),this._footprintShaderProgram.shaderProgram}initFootprintArrays(){this.footprintPolygons=[],this.indexes=new Uint32Array,this.vertexCataloguePosition=new Float32Array,this.totPoints=0,this.totConvexPoints=0,this.extHoveredIndexes=new Uint32Array,this._hoveredFootprints=[],this.hoveredVertexPosition=new Float32Array,this.totHoveredPoints=0,this.hoveredIndexes=[],this.hoveredElementIndexes=new Uint32Array,this._selectedFootprints=[],this.selectedVertexPosition=new Float32Array,this.totSelectedPoints=0,this.selectedIndexes=[],this.selectedElementIndexes=new Uint32Array}initGLBuffers(){this._webgl&&(this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.indexBuffer=this._webgl.createBuffer(),this.hoveredVertexPositionBuffer=this._webgl.createBuffer(),this.hoveredIndexBuffer=this._webgl.createBuffer(),this.selectedVertexPositionBuffer=this._webgl.createBuffer(),this.selectedIndexBuffer=this._webgl.createBuffer())}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get metadataManager(){return this._metadataManager}addFootprint(e){this.footprintPolygons.push(e)}addFootprints(e,t){this._ready=!1,this._metadataManager=new c.MetadataManager(t);const r=this._metadataManager.selectedOutlineColumn?.index??-1;if(r<0)throw new Error("geomColumn or its index is undefined in footprintsetProps");for(let t=0;t<e.length;t++)if(null!==e[t][r]){const i=new s.Footprint(e[t][r],e[t],void 0,this._coordsType);i._valid&&(this.addFootprint(i),this.totPoints+=i.totPoints,this.totConvexPoints+=i.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 r=0;r<e;r++)t+=this.footprintPolygons[r].polygons.length-1;this.indexes=new Uint32Array(this.totPoints+t+1);const r=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this.vertexCataloguePosition=new Float32Array(3*this.totPoints);let i=0,s=0;this.nPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this.footprintPolygons[t].polygons;t>0&&(this.indexes[s++]=r,this.nPrimitiveFlags++);for(const t of e){t!==e[0]&&(this.indexes[s++]=r,this.nPrimitiveFlags++);for(const e of t)this.vertexCataloguePosition[i++]=1*e.x,this.vertexCataloguePosition[i++]=1*e.y,this.vertexCataloguePosition[i++]=1*e.z,this.indexes[s++]=Math.floor((i-1)/3)}}this.indexes[this.indexes.length-1]=r,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexes,this._webgl.STATIC_DRAW),this._bufferInitialised=!0,console.log("Buffer initialized")}checkSelection(e){if(!e.x||!e.y||!e.z)return;if(!e.computeNpix())return;this._hoveredFootprints=[],this.totHoveredPoints=0;const t=new n.Point({x:e.x,y:e.y,z:e.z},l.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const r=this.footprintPolygons[e];if(r.selectionObj&&h.default.checkPointInsidePolygon5(r.selectionObj,t)){const e=[...r.details],t=this._metadataManager.selectedOutlineColumn?.index??-1;t>=0&&e.splice(t,1),this._hoveredFootprints.push(r),this.totHoveredPoints+=r.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=[],r=new n.Point({x:e.x,y:e.y,z:e.z},l.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const i=this.footprintPolygons[e];i.selectionObj&&h.default.checkPointInsidePolygon5(i.selectionObj,r)&&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 r=[];return t.forEach(e=>{const t=this.footprintPolygons[e];t&&r.push(t)}),r.length?{footprints:r,pickedIndexes:t}:null}selectPrimaryFootprintFromClick(e){const t=this.getFootprintsFromPointer(e),r=t?.pickedIndexes??[];if(this.setSelectedIndexes(r),!r.length)return{footprints:[],selectionState:[]};const i=[],s=[];return r.forEach(e=>{const t=this.footprintPolygons[e];if(!t)return;const r=this.selectedIndexes.includes(e);i.push({footprint:t,selected:r}),s.push(t)}),s.length?{footprints:s,selectionState:i}:null}FootprintPolygonMatches(e,t){if(e===t)return!0;const r=e.convexPolygons,i=t.convexPolygons;if(r!==i||r!==i)return!1;if(e.details.length!==t.details.length)return!1;for(let r=0;r<e.details.length;r++)if(!Object.is(e.details[r],t.details[r]))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 r=this.findFootprintPolygonIndex(e);if(r<0)return;const i=r*u.ELEM_SIZE;if(t)this.hoveredIndexes.includes(r)||this.hoveredIndexes.push(r);else{if(i+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(r);e>=0&&this.hoveredIndexes.splice(e,1)}}extAddPolygons2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findFootprintPolygonIndex(e);if(t<0)return;const r=t*u.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(r+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 r=0;r<e;r++)t+=this._hoveredFootprints[r].polygons.length-1;this.hoveredElementIndexes=new Uint32Array(this.totHoveredPoints+t);const r=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this.hoveredVertexPosition=new Float32Array(3*this.totHoveredPoints);let i=0,s=0;this.nHoveredPrimitiveFlags=0;for(let t=0;t<e;t++){let e=this._hoveredFootprints[t].polygons;t>0&&(this.hoveredElementIndexes[s]=r,this.nHoveredPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.hoveredElementIndexes[s]=r,this.nHoveredPrimitiveFlags+=1,s+=1);const a=e[t];for(let e=0;e<a.length;e++){const t=a[e];this.hoveredVertexPosition[i]=1*t.x,this.hoveredVertexPosition[i+1]=1*t.y,this.hoveredVertexPosition[i+2]=1*t.z,this.hoveredElementIndexes[s]=Math.floor(i/3),s+=1,i+=3}}}}initSelectionBuffer(){if(!this._webgl)return;if(0==this._selectedFootprints.length)return;const e=this._selectedFootprints.length;let t=e-1;for(let r=0;r<e;r++)t+=this._selectedFootprints[r].polygons.length-1;this.selectedElementIndexes=new Uint32Array(this.totSelectedPoints+t);const r=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this.selectedVertexPosition=new Float32Array(3*this.totSelectedPoints);let i=0,s=0;this.nSlectedPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this._selectedFootprints[t].polygons;t>0&&(this.selectedElementIndexes[s]=r,this.nSlectedPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.selectedElementIndexes[s]=r,this.nSlectedPrimitiveFlags+=1,s+=1);const a=e[t];for(let e=0;e<a.length;e++){const t=a[e];this.selectedVertexPosition[i]=1*t.x,this.selectedVertexPosition[i+1]=1*t.y,this.selectedVertexPosition[i+2]=1*t.z,this.selectedElementIndexes[s]=Math.floor(i/3),s+=1,i+=3}}}}changeColor(e){this._shapeColor=e}draw(e,t,r,i){if(!this.isVisible)return;if(!this._ready)return;if(!r)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;if(this._footprintShaderProgram.enableShaders(i,e,r),null!=t&&t.xyz!=this.oldMouseCoords&&this.checkSelection(t),this._hoveredFootprints.length>0){const e=(0,a.colorHex2RGB)("#00FF00"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.hoveredVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.hoveredVertexPosition.length/3+this.nHoveredPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}if(this._selectedFootprints.length>0){const e=(0,a.colorHex2RGB)("#ECB462"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.selectedVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.selectedVertexPosition.length/3+this.nSlectedPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);const s=[...(0,a.colorHex2RGB)(this._shapeColor),1];this._webgl.uniform4f(this._footprintShaderProgram.locations.color,...s),this._webgl.drawElements(this._webgl.LINE_LOOP,this.indexes.length,this._webgl.UNSIGNED_INT,0),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null),this.oldMouseCoords=t.xyz}}t.FootprintSetGL=u},619:(e,t)=>{function r(e,r){if(!Array.isArray(r))throw new Error(`Channel "${e}" must be an array.`);if(r.length!==t.COLOR_MAP_SAMPLE_COUNT)throw new Error(`Channel "${e}" must contain exactly ${t.COLOR_MAP_SAMPLE_COUNT} samples.`);for(let t=0;t<r.length;t+=1){const i=r[t];if(!Number.isFinite(i))throw new Error(`Channel "${e}" contains a non-finite value at index ${t}.`);if(i<0||i>255)throw new Error(`Channel "${e}" contains an out-of-range value at index ${t}. Expected 0..255.`)}}function i(e){const r=new Float32Array(4*t.COLOR_MAP_SAMPLE_COUNT);for(let i=0;i<t.COLOR_MAP_SAMPLE_COUNT;i+=1)r[4*i]=e[i];return r}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorMaps=t.COLOR_MAP_SAMPLE_COUNT=void 0,t.createColorMapFromSamples=function(e,t){const s=e.trim();if(!s)throw new Error("Color map name must not be empty.");return r("r",t.r),r("g",t.g),r("b",t.b),{name:s,r:i(t.r),g:i(t.g),b:i(t.b)}},t.COLOR_MAP_SAMPLE_COUNT=256,t.ColorMaps={grayscale:{name:"grayscale",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},native:{name:"native",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},planck:{name:"planck",r:new Float32Array([0,0,0,0,.769231,0,0,0,1.53846,0,0,0,2.30769,0,0,0,3.07692,0,0,0,3.84615,0,0,0,4.61538,0,0,0,5.38462,0,0,0,6.15385,0,0,0,6.92308,0,0,0,7.69231,0,0,0,8.46154,0,0,0,9.23077,0,0,0,10,0,0,0,11.5385,0,0,0,13.0769,0,0,0,14.6154,0,0,0,16.1538,0,0,0,17.6923,0,0,0,19.2308,0,0,0,20.7692,0,0,0,22.3077,0,0,0,23.8462,0,0,0,25.3846,0,0,0,26.9231,0,0,0,28.4615,0,0,0,30,0,0,0,33.8462,0,0,0,37.6923,0,0,0,41.5385,0,0,0,45.3846,0,0,0,49.2308,0,0,0,53.0769,0,0,0,56.9231,0,0,0,60.7692,0,0,0,64.6154,0,0,0,68.4615,0,0,0,72.3077,0,0,0,76.1538,0,0,0,80,0,0,0,88.5385,0,0,0,97.0769,0,0,0,105.615,0,0,0,114.154,0,0,0,122.692,0,0,0,131.231,0,0,0,139.769,0,0,0,148.308,0,0,0,156.846,0,0,0,165.385,0,0,0,173.923,0,0,0,182.462,0,0,0,191,0,0,0,193.846,0,0,0,196.692,0,0,0,199.538,0,0,0,202.385,0,0,0,205.231,0,0,0,208.077,0,0,0,210.923,0,0,0,213.769,0,0,0,216.615,0,0,0,219.462,0,0,0,222.308,0,0,0,225.154,0,0,0,228,0,0,0,229.182,0,0,0,230.364,0,0,0,231.545,0,0,0,232.727,0,0,0,233.909,0,0,0,235.091,0,0,0,236.273,0,0,0,237.455,0,0,0,238.636,0,0,0,239.818,0,0,0,241,0,0,0,241,0,0,0,241.364,0,0,0,241.727,0,0,0,242.091,0,0,0,242.455,0,0,0,242.818,0,0,0,243.182,0,0,0,243.545,0,0,0,243.909,0,0,0,244.273,0,0,0,244.636,0,0,0,245,0,0,0,245.231,0,0,0,245.462,0,0,0,245.692,0,0,0,245.923,0,0,0,246.154,0,0,0,246.385,0,0,0,246.615,0,0,0,246.846,0,0,0,247.077,0,0,0,247.308,0,0,0,247.538,0,0,0,247.769,0,0,0,248,0,0,0,248.146,0,0,0,248.292,0,0,0,248.438,0,0,0,248.585,0,0,0,248.731,0,0,0,248.877,0,0,0,249.023,0,0,0,249.169,0,0,0,249.315,0,0,0,249.462,0,0,0,249.608,0,0,0,249.754,0,0,0,249.9,0,0,0,249.312,0,0,0,248.723,0,0,0,248.135,0,0,0,247.546,0,0,0,246.958,0,0,0,246.369,0,0,0,245.781,0,0,0,245.192,0,0,0,244.604,0,0,0,244.015,0,0,0,243.427,0,0,0,242.838,0,0,0,242.25,0,0,0,239.308,0,0,0,236.365,0,0,0,233.423,0,0,0,230.481,0,0,0,227.538,0,0,0,224.596,0,0,0,221.654,0,0,0,218.712,0,0,0,215.769,0,0,0,212.827,0,0,0,209.885,0,0,0,206.942,0,0,0,204,0,0,0,201,0,0,0,198,0,0,0,195,0,0,0,192,0,0,0,189,0,0,0,186,0,0,0,183,0,0,0,180,0,0,0,177,0,0,0,174,0,0,0,171,0,0,0,168,0,0,0,165,0,0,0,161.077,0,0,0,157.154,0,0,0,153.231,0,0,0,149.308,0,0,0,145.385,0,0,0,141.462,0,0,0,137.538,0,0,0,133.615,0,0,0,129.692,0,0,0,125.769,0,0,0,121.846,0,0,0,117.923,0,0,0,114,0,0,0,115.038,0,0,0,116.077,0,0,0,117.115,0,0,0,118.154,0,0,0,119.192,0,0,0,120.231,0,0,0,121.269,0,0,0,122.308,0,0,0,123.346,0,0,0,124.385,0,0,0,125.423,0,0,0,126.462,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),g:new Float32Array([0,0,0,0,1.53846,0,0,0,3.07692,0,0,0,4.61538,0,0,0,6.15385,0,0,0,7.69231,0,0,0,9.23077,0,0,0,10.7692,0,0,0,12.3077,0,0,0,13.8462,0,0,0,15.3846,0,0,0,16.9231,0,0,0,18.4615,0,0,0,20,0,0,0,32.6154,0,0,0,45.2308,0,0,0,57.8462,0,0,0,70.4615,0,0,0,83.0769,0,0,0,95.6923,0,0,0,108.308,0,0,0,120.923,0,0,0,133.538,0,0,0,146.154,0,0,0,158.769,0,0,0,171.385,0,0,0,184,0,0,0,187.923,0,0,0,191.846,0,0,0,195.769,0,0,0,199.692,0,0,0,203.615,0,0,0,207.538,0,0,0,211.462,0,0,0,215.385,0,0,0,219.308,0,0,0,223.231,0,0,0,227.154,0,0,0,231.077,0,0,0,235,0,0,0,235.308,0,0,0,235.615,0,0,0,235.923,0,0,0,236.231,0,0,0,236.538,0,0,0,236.846,0,0,0,237.154,0,0,0,237.462,0,0,0,237.769,0,0,0,238.077,0,0,0,238.385,0,0,0,238.692,0,0,0,239,0,0,0,239.077,0,0,0,239.154,0,0,0,239.231,0,0,0,239.308,0,0,0,239.385,0,0,0,239.462,0,0,0,239.538,0,0,0,239.615,0,0,0,239.692,0,0,0,239.769,0,0,0,239.846,0,0,0,239.923,0,0,0,240,0,0,0,240.091,0,0,0,240.182,0,0,0,240.273,0,0,0,240.364,0,0,0,240.455,0,0,0,240.545,0,0,0,240.636,0,0,0,240.727,0,0,0,240.818,0,0,0,240.909,0,0,0,241,0,0,0,241,0,0,0,240.909,0,0,0,240.818,0,0,0,240.727,0,0,0,240.636,0,0,0,240.545,0,0,0,240.455,0,0,0,240.364,0,0,0,240.273,0,0,0,240.182,0,0,0,240.091,0,0,0,240,0,0,0,239.615,0,0,0,239.231,0,0,0,238.846,0,0,0,238.462,0,0,0,238.077,0,0,0,237.692,0,0,0,237.308,0,0,0,236.923,0,0,0,236.538,0,0,0,236.154,0,0,0,235.769,0,0,0,235.385,0,0,0,235,0,0,0,232.615,0,0,0,230.231,0,0,0,227.846,0,0,0,225.462,0,0,0,223.077,0,0,0,220.692,0,0,0,218.308,0,0,0,215.923,0,0,0,213.538,0,0,0,211.154,0,0,0,208.769,0,0,0,206.385,0,0,0,204,0,0,0,200.077,0,0,0,196.154,0,0,0,192.231,0,0,0,188.308,0,0,0,184.385,0,0,0,180.462,0,0,0,176.538,0,0,0,172.615,0,0,0,168.692,0,0,0,164.769,0,0,0,160.846,0,0,0,156.923,0,0,0,153,0,0,0,147.115,0,0,0,141.231,0,0,0,135.346,0,0,0,129.462,0,0,0,123.577,0,0,0,117.692,0,0,0,111.808,0,0,0,105.923,0,0,0,100.038,0,0,0,94.1538,0,0,0,88.2692,0,0,0,82.3846,0,0,0,76.5,0,0,0,73.0769,0,0,0,69.6538,0,0,0,66.2308,0,0,0,62.8077,0,0,0,59.3846,0,0,0,55.9615,0,0,0,52.5385,0,0,0,49.1154,0,0,0,45.6923,0,0,0,42.2692,0,0,0,38.8462,0,0,0,35.4231,0,0,0,32,0,0,0,29.5385,0,0,0,27.0769,0,0,0,24.6154,0,0,0,22.1538,0,0,0,19.6923,0,0,0,17.2308,0,0,0,14.7692,0,0,0,12.3077,0,0,0,9.84615,0,0,0,7.38462,0,0,0,4.92308,0,0,0,2.46154,0,0,0,0,0,0,0,9.80769,0,0,0,19.6154,0,0,0,29.4231,0,0,0,39.2308,0,0,0,49.0385,0,0,0,58.8462,0,0,0,68.6538,0,0,0,78.4615,0,0,0,88.2692,0,0,0,98.0769,0,0,0,107.885,0,0,0,117.692,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254.615,0,0,0,254.231,0,0,0,253.846,0,0,0,253.462,0,0,0,253.077,0,0,0,252.692,0,0,0,252.308,0,0,0,251.923,0,0,0,251.538,0,0,0,251.154,0,0,0,250.769,0,0,0,250.385,0,0,0,250,0,0,0,249.615,0,0,0,249.231,0,0,0,248.846,0,0,0,248.462,0,0,0,248.077,0,0,0,247.692,0,0,0,247.308,0,0,0,246.923,0,0,0,246.538,0,0,0,246.154,0,0,0,245.769,0,0,0,245.385,0,0,0,245,0,0,0,242,0,0,0,239,0,0,0,236,0,0,0,233,0,0,0,230,0,0,0,227,0,0,0,224,0,0,0,221,0,0,0,218,0,0,0,215,0,0,0,212,0,0,0,212,0,0,0,208.636,0,0,0,205.273,0,0,0,201.909,0,0,0,198.545,0,0,0,195.182,0,0,0,191.818,0,0,0,188.455,0,0,0,185.091,0,0,0,181.727,0,0,0,178.364,0,0,0,175,0,0,0,171.538,0,0,0,168.077,0,0,0,164.615,0,0,0,161.154,0,0,0,157.692,0,0,0,154.231,0,0,0,150.769,0,0,0,147.308,0,0,0,143.846,0,0,0,140.385,0,0,0,136.923,0,0,0,133.462,0,0,0,130,0,0,0,122.942,0,0,0,115.885,0,0,0,108.827,0,0,0,101.769,0,0,0,94.7115,0,0,0,87.6539,0,0,0,80.5962,0,0,0,73.5385,0,0,0,66.4808,0,0,0,59.4231,0,0,0,52.3654,0,0,0,45.3077,0,0,0,38.25,0,0,0,36.2885,0,0,0,34.3269,0,0,0,32.3654,0,0,0,30.4038,0,0,0,28.4423,0,0,0,26.4808,0,0,0,24.5192,0,0,0,22.5577,0,0,0,20.5962,0,0,0,18.6346,0,0,0,16.6731,0,0,0,14.7115,0,0,0,12.75,0,0,0,11.7692,0,0,0,10.7885,0,0,0,9.80769,0,0,0,8.82692,0,0,0,7.84615,0,0,0,6.86539,0,0,0,5.88461,0,0,0,4.90385,0,0,0,3.92308,0,0,0,2.94231,0,0,0,1.96154,0,0,0,.980769,0,0,0,0,0,0,0,2.46154,0,0,0,4.92308,0,0,0,7.38462,0,0,0,9.84616,0,0,0,12.3077,0,0,0,14.7692,0,0,0,17.2308,0,0,0,19.6923,0,0,0,22.1538,0,0,0,24.6154,0,0,0,27.0769,0,0,0,29.5385,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,41.3077,0,0,0,50.6154,0,0,0,59.9231,0,0,0,69.2308,0,0,0,78.5385,0,0,0,87.8462,0,0,0,97.1539,0,0,0,106.462,0,0,0,115.769,0,0,0,125.077,0,0,0,134.385,0,0,0,143.692,0,0,0,153,0,0,0,156.923,0,0,0,160.846,0,0,0,164.769,0,0,0,168.692,0,0,0,172.615,0,0,0,176.538,0,0,0,180.462,0,0,0,184.385,0,0,0,188.308,0,0,0,192.231,0,0,0,196.154,0,0,0,200.077,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.838,0,0,0,243.427,0,0,0,244.015,0,0,0,244.604,0,0,0,245.192,0,0,0,245.781,0,0,0,246.369,0,0,0,246.958,0,0,0,247.546,0,0,0,248.135,0,0,0,248.723,0,0,0,249.312,0,0,0,249.9,0,0,0,250.096,0,0,0,250.292,0,0,0,250.488,0,0,0,250.685,0,0,0,250.881,0,0,0,251.077,0,0,0,251.273,0,0,0,251.469,0,0,0,251.665,0,0,0,251.862,0,0,0,252.058,0,0,0,252.254,0,0,0,252.45,0,0,0,252.682,0,0,0,252.914,0,0,0,253.145,0,0,0,253.377,0,0,0,253.609,0,0,0,253.841,0,0,0,254.073,0,0,0,254.305,0,0,0,254.536,0,0,0,254.768,0,0,0,255,0,0,0])},cmb:{name:"cmb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,12,0,0,0,18,0,0,0,24,0,0,0,30,0,0,0,36,0,0,0,42,0,0,0,48,0,0,0,54,0,0,0,60,0,0,0,66,0,0,0,72,0,0,0,78,0,0,0,85,0,0,0,91,0,0,0,97,0,0,0,103,0,0,0,109,0,0,0,115,0,0,0,121,0,0,0,127,0,0,0,133,0,0,0,139,0,0,0,145,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,170,0,0,0,176,0,0,0,182,0,0,0,188,0,0,0,194,0,0,0,200,0,0,0,206,0,0,0,212,0,0,0,218,0,0,0,224,0,0,0,230,0,0,0,236,0,0,0,242,0,0,0,248,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,251,0,0,0,247,0,0,0,244,0,0,0,240,0,0,0,236,0,0,0,233,0,0,0,229,0,0,0,226,0,0,0,222,0,0,0,218,0,0,0,215,0,0,0,211,0,0,0,208,0,0,0,204,0,0,0,200,0,0,0,197,0,0,0,193,0,0,0,190,0,0,0,186,0,0,0,182,0,0,0,179,0,0,0,175,0,0,0,172,0,0,0,168,0,0,0,164,0,0,0,161,0,0,0,157,0,0,0,154,0,0,0,150,0,0,0,146,0,0,0,143,0,0,0,139,0,0,0,136,0,0,0,132,0,0,0,128,0,0,0,125,0,0,0,121,0,0,0,118,0,0,0,114,0,0,0,110,0,0,0,107,0,0,0,103,0,0,0,100,0,0,0]),g:new Float32Array([0,0,0,0,2,0,0,0,5,0,0,0,8,0,0,0,10,0,0,0,13,0,0,0,16,0,0,0,18,0,0,0,21,0,0,0,24,0,0,0,26,0,0,0,29,0,0,0,32,0,0,0,34,0,0,0,37,0,0,0,40,0,0,0,42,0,0,0,45,0,0,0,48,0,0,0,50,0,0,0,53,0,0,0,56,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,66,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,80,0,0,0,82,0,0,0,85,0,0,0,88,0,0,0,90,0,0,0,93,0,0,0,96,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,106,0,0,0,109,0,0,0,112,0,0,0,114,0,0,0,117,0,0,0,119,0,0,0,122,0,0,0,124,0,0,0,127,0,0,0,129,0,0,0,132,0,0,0,134,0,0,0,137,0,0,0,139,0,0,0,142,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,152,0,0,0,155,0,0,0,157,0,0,0,160,0,0,0,162,0,0,0,165,0,0,0,167,0,0,0,170,0,0,0,172,0,0,0,175,0,0,0,177,0,0,0,180,0,0,0,182,0,0,0,185,0,0,0,188,0,0,0,190,0,0,0,193,0,0,0,195,0,0,0,198,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,208,0,0,0,210,0,0,0,213,0,0,0,215,0,0,0,218,0,0,0,221,0,0,0,221,0,0,0,221,0,0,0,222,0,0,0,222,0,0,0,222,0,0,0,223,0,0,0,223,0,0,0,224,0,0,0,224,0,0,0,224,0,0,0,225,0,0,0,225,0,0,0,225,0,0,0,226,0,0,0,226,0,0,0,227,0,0,0,227,0,0,0,227,0,0,0,228,0,0,0,228,0,0,0,229,0,0,0,229,0,0,0,229,0,0,0,230,0,0,0,230,0,0,0,230,0,0,0,231,0,0,0,231,0,0,0,232,0,0,0,232,0,0,0,232,0,0,0,233,0,0,0,233,0,0,0,233,0,0,0,234,0,0,0,234,0,0,0,235,0,0,0,235,0,0,0,235,0,0,0,236,0,0,0,236,0,0,0,237,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,227,0,0,0,226,0,0,0,225,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,215,0,0,0,214,0,0,0,213,0,0,0,211,0,0,0,210,0,0,0,209,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,195,0,0,0,194,0,0,0,193,0,0,0,191,0,0,0,190,0,0,0,189,0,0,0,187,0,0,0,186,0,0,0,185,0,0,0,183,0,0,0,182,0,0,0,181,0,0,0,180,0,0,0,177,0,0,0,175,0,0,0,172,0,0,0,170,0,0,0,167,0,0,0,165,0,0,0,162,0,0,0,160,0,0,0,157,0,0,0,155,0,0,0,152,0,0,0,150,0,0,0,147,0,0,0,145,0,0,0,142,0,0,0,140,0,0,0,137,0,0,0,135,0,0,0,132,0,0,0,130,0,0,0,127,0,0,0,125,0,0,0,122,0,0,0,120,0,0,0,117,0,0,0,115,0,0,0,112,0,0,0,110,0,0,0,107,0,0,0,105,0,0,0,102,0,0,0,100,0,0,0,97,0,0,0,95,0,0,0,92,0,0,0,90,0,0,0,87,0,0,0,85,0,0,0,82,0,0,0,80,0,0,0,77,0,0,0,75,0,0,0,73,0,0,0,71,0,0,0,69,0,0,0,68,0,0,0,66,0,0,0,64,0,0,0,62,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,54,0,0,0,52,0,0,0,50,0,0,0,48,0,0,0,47,0,0,0,45,0,0,0,43,0,0,0,41,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,34,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,26,0,0,0,24,0,0,0,22,0,0,0,20,0,0,0,19,0,0,0,17,0,0,0,15,0,0,0,13,0,0,0,12,0,0,0,10,0,0,0,8,0,0,0,6,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254,0,0,0,253,0,0,0,252,0,0,0,251,0,0,0,250,0,0,0,249,0,0,0,248,0,0,0,247,0,0,0,246,0,0,0,245,0,0,0,245,0,0,0,244,0,0,0,243,0,0,0,242,0,0,0,241,0,0,0,240,0,0,0,239,0,0,0,238,0,0,0,237,0,0,0,236,0,0,0,236,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,232,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,228,0,0,0,227,0,0,0,226,0,0,0,226,0,0,0,225,0,0,0,224,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,220,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,217,0,0,0,211,0,0,0,206,0,0,0,201,0,0,0,196,0,0,0,191,0,0,0,186,0,0,0,181,0,0,0,176,0,0,0,171,0,0,0,166,0,0,0,161,0,0,0,156,0,0,0,151,0,0,0,146,0,0,0,141,0,0,0,136,0,0,0,131,0,0,0,126,0,0,0,121,0,0,0,116,0,0,0,111,0,0,0,105,0,0,0,100,0,0,0,95,0,0,0,90,0,0,0,85,0,0,0,80,0,0,0,75,0,0,0,70,0,0,0,65,0,0,0,60,0,0,0,55,0,0,0,50,0,0,0,45,0,0,0,40,0,0,0,35,0,0,0,30,0,0,0,25,0,0,0,20,0,0,0,15,0,0,0,10,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},rainbow:{name:"rainbow",r:new Float32Array([0,0,0,0,4,0,0,0,9,0,0,0,13,0,0,0,18,0,0,0,22,0,0,0,27,0,0,0,31,0,0,0,36,0,0,0,40,0,0,0,45,0,0,0,50,0,0,0,54,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,68,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,79,0,0,0,80,0,0,0,82,0,0,0,83,0,0,0,85,0,0,0,84,0,0,0,86,0,0,0,87,0,0,0,88,0,0,0,86,0,0,0,87,0,0,0,87,0,0,0,87,0,0,0,85,0,0,0,84,0,0,0,84,0,0,0,84,0,0,0,83,0,0,0,79,0,0,0,78,0,0,0,77,0,0,0,76,0,0,0,71,0,0,0,70,0,0,0,68,0,0,0,66,0,0,0,60,0,0,0,58,0,0,0,55,0,0,0,53,0,0,0,46,0,0,0,43,0,0,0,40,0,0,0,36,0,0,0,33,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,12,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,33,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,80,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,101,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,123,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,153,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,169,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,212,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,38,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,84,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,106,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,127,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,152,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,195,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,216,0,0,0,220,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,250,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,221,0,0,0,216,0,0,0,212,0,0,0,208,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,161,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,119,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,85,0,0,0,80,0,0,0,76,0,0,0,72,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,51,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,29,0,0,0,21,0,0,0,17,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0]),b:new Float32Array([0,0,0,0,3,0,0,0,7,0,0,0,10,0,0,0,14,0,0,0,19,0,0,0,23,0,0,0,28,0,0,0,32,0,0,0,38,0,0,0,43,0,0,0,48,0,0,0,53,0,0,0,59,0,0,0,63,0,0,0,68,0,0,0,72,0,0,0,77,0,0,0,81,0,0,0,86,0,0,0,91,0,0,0,95,0,0,0,100,0,0,0,104,0,0,0,109,0,0,0,113,0,0,0,118,0,0,0,122,0,0,0,127,0,0,0,132,0,0,0,136,0,0,0,141,0,0,0,145,0,0,0,150,0,0,0,154,0,0,0,159,0,0,0,163,0,0,0,168,0,0,0,173,0,0,0,177,0,0,0,182,0,0,0,186,0,0,0,191,0,0,0,195,0,0,0,200,0,0,0,204,0,0,0,209,0,0,0,214,0,0,0,218,0,0,0,223,0,0,0,227,0,0,0,232,0,0,0,236,0,0,0,241,0,0,0,245,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,225,0,0,0,220,0,0,0,216,0,0,0,212,0,0,0,203,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,157,0,0,0,152,0,0,0,148,0,0,0,144,0,0,0,135,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,114,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,84,0,0,0,80,0,0,0,76,0,0,0,67,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,46,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},eosb:{name:"eosb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,18,0,0,0,27,0,0,0,36,0,0,0,45,0,0,0,49,0,0,0,57,0,0,0,72,0,0,0,81,0,0,0,91,0,0,0,100,0,0,0,109,0,0,0,118,0,0,0,127,0,0,0,136,0,0,0,131,0,0,0,139,0,0,0,163,0,0,0,173,0,0,0,182,0,0,0,191,0,0,0,200,0,0,0,209,0,0,0,218,0,0,0,227,0,0,0,213,0,0,0,221,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,253,0,0,0,251,0,0,0,249,0,0,0,247,0,0,0,245,0,0,0,243,0,0,0,241,0,0,0,215,0,0,0,214,0,0,0,235,0,0,0,234,0,0,0,232,0,0,0,230,0,0,0,228,0,0,0,226,0,0,0,224,0,0,0,222,0,0,0,198,0,0,0,196,0,0,0,216,0,0,0,215,0,0,0,213,0,0,0,211,0,0,0,209,0,0,0,207,0,0,0,205,0,0,0,203,0,0,0,181,0,0,0,179,0,0,0,197,0,0,0,196,0,0,0,194,0,0,0,192,0,0,0,190,0,0,0,188,0,0,0,186,0,0,0,184,0,0,0,164,0,0,0,162,0,0,0,178,0,0,0,176,0,0,0,175,0,0,0,173,0,0,0,171,0,0,0,169,0,0,0,167,0,0,0,165,0,0,0,147,0,0,0,145,0,0,0,159,0,0,0,157,0,0,0,156,0,0,0,154,0,0,0,152,0,0,0,150,0,0,0,148,0,0,0,146,0,0,0,130,0,0,0,128,0,0,0,140,0,0,0,138,0,0,0,137,0,0,0,135,0,0,0,133,0,0,0,131,0,0,0,129,0,0,0,127,0,0,0,113,0,0,0,111,0,0,0,121,0,0,0,119,0,0,0,117,0,0,0,117,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,15,0,0,0,23,0,0,0,31,0,0,0,39,0,0,0,47,0,0,0,55,0,0,0,57,0,0,0,64,0,0,0,79,0,0,0,87,0,0,0,95,0,0,0,103,0,0,0,111,0,0,0,119,0,0,0,127,0,0,0,135,0,0,0,129,0,0,0,136,0,0,0,159,0,0,0,167,0,0,0,175,0,0,0,183,0,0,0,191,0,0,0,199,0,0,0,207,0,0,0,215,0,0,0,200,0,0,0,207,0,0,0,239,0,0,0,247,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,250,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,225,0,0,0,198,0,0,0,195,0,0,0,212,0,0,0,208,0,0,0,204,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,182,0,0,0,160,0,0,0,156,0,0,0,169,0,0,0,165,0,0,0,161,0,0,0,157,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,122,0,0,0,118,0,0,0,127,0,0,0,125,0,0,0,123,0,0,0,121,0,0,0,119,0,0,0,116,0,0,0,114,0,0,0,112,0,0,0,99,0,0,0,97,0,0,0,106,0,0,0,104,0,0,0,102,0,0,0,99,0,0,0,97,0,0,0,95,0,0,0,93,0,0,0,91,0,0,0,80,0,0,0,78,0,0,0,84,0,0,0,82,0,0,0,80,0,0,0,78,0,0,0,76,0,0,0,74,0,0,0,72,0,0,0,70,0,0,0,61,0,0,0,59,0,0,0,63,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,53,0,0,0,50,0,0,0,48,0,0,0,42,0,0,0,40,0,0,0,42,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,19,0,0,0,16,0,0,0,14,0,0,0,12,0,0,0,13,0,0,0,8,0,0,0,6,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),b:new Float32Array([116,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,136,0,0,0,140,0,0,0,144,0,0,0,148,0,0,0,153,0,0,0,157,0,0,0,145,0,0,0,149,0,0,0,170,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,195,0,0,0,199,0,0,0,183,0,0,0,187,0,0,0,212,0,0,0,216,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,238,0,0,0,242,0,0,0,221,0,0,0,225,0,0,0,255,0,0,0,247,0,0,0,239,0,0,0,231,0,0,0,223,0,0,0,215,0,0,0,207,0,0,0,199,0,0,0,172,0,0,0,164,0,0,0,175,0,0,0,167,0,0,0,159,0,0,0,151,0,0,0,143,0,0,0,135,0,0,0,127,0,0,0,119,0,0,0,100,0,0,0,93,0,0,0,95,0,0,0,87,0,0,0,79,0,0,0,71,0,0,0,63,0,0,0,55,0,0,0,47,0,0,0,39,0,0,0,28,0,0,0,21,0,0,0,15,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},cubehelix:{name:"cubehelix",r:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,24,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,24,0,0,0,24,0,0,0,24,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,20,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,27,0,0,0,28,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,35,0,0,0,36,0,0,0,38,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,49,0,0,0,51,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,60,0,0,0,62,0,0,0,65,0,0,0,67,0,0,0,70,0,0,0,72,0,0,0,75,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,89,0,0,0,92,0,0,0,95,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,107,0,0,0,110,0,0,0,113,0,0,0,116,0,0,0,120,0,0,0,123,0,0,0,126,0,0,0,129,0,0,0,132,0,0,0,135,0,0,0,138,0,0,0,141,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,153,0,0,0,155,0,0,0,158,0,0,0,161,0,0,0,164,0,0,0,166,0,0,0,169,0,0,0,171,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,181,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,199,0,0,0,201,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,207,0,0,0,208,0,0,0,209,0,0,0,209,0,0,0,210,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,210,0,0,0,210,0,0,0,210,0,0,0,209,0,0,0,208,0,0,0,208,0,0,0,207,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,205,0,0,0,204,0,0,0,203,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,201,0,0,0,200,0,0,0,199,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,197,0,0,0,196,0,0,0,196,0,0,0,195,0,0,0,195,0,0,0,194,0,0,0,194,0,0,0,194,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,194,0,0,0,194,0,0,0,195,0,0,0,195,0,0,0,196,0,0,0,196,0,0,0,197,0,0,0,198,0,0,0,199,0,0,0,200,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,208,0,0,0,209,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,217,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,223,0,0,0,225,0,0,0,227,0,0,0,229,0,0,0,231,0,0,0,232,0,0,0,234,0,0,0,236,0,0,0,238,0,0,0,240,0,0,0,242,0,0,0,244,0,0,0,245,0,0,0,247,0,0,0,249,0,0,0,251,0,0,0,253,0,0,0,255]),g:new Float32Array([0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,28,0,0,0,29,0,0,0,31,0,0,0,32,0,0,0,34,0,0,0,35,0,0,0,37,0,0,0,38,0,0,0,40,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,46,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,58,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,73,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,79,0,0,0,81,0,0,0,83,0,0,0,84,0,0,0,86,0,0,0,88,0,0,0,89,0,0,0,91,0,0,0,92,0,0,0,94,0,0,0,95,0,0,0,97,0,0,0,98,0,0,0,99,0,0,0,101,0,0,0,102,0,0,0,103,0,0,0,104,0,0,0,106,0,0,0,107,0,0,0,108,0,0,0,109,0,0,0,110,0,0,0,111,0,0,0,112,0,0,0,113,0,0,0,114,0,0,0,114,0,0,0,115,0,0,0,116,0,0,0,116,0,0,0,117,0,0,0,118,0,0,0,118,0,0,0,119,0,0,0,119,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,123,0,0,0,123,0,0,0,124,0,0,0,124,0,0,0,125,0,0,0,125,0,0,0,126,0,0,0,127,0,0,0,127,0,0,0,128,0,0,0,129,0,0,0,130,0,0,0,131,0,0,0,131,0,0,0,132,0,0,0,133,0,0,0,135,0,0,0,136,0,0,0,137,0,0,0,138,0,0,0,139,0,0,0,140,0,0,0,142,0,0,0,143,0,0,0,144,0,0,0,146,0,0,0,147,0,0,0,149,0,0,0,150,0,0,0,152,0,0,0,154,0,0,0,155,0,0,0,157,0,0,0,158,0,0,0,160,0,0,0,162,0,0,0,164,0,0,0,165,0,0,0,167,0,0,0,169,0,0,0,171,0,0,0,172,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,180,0,0,0,182,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,208,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,216,0,0,0,218,0,0,0,219,0,0,0,221,0,0,0,222,0,0,0,224,0,0,0,225,0,0,0,226,0,0,0,228,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,232,0,0,0,233,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,247,0,0,0,248,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,250,0,0,0,251,0,0,0,251,0,0,0,252,0,0,0,252,0,0,0,253,0,0,0,253,0,0,0,254,0,0,0,255,0,0,0]),b:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,11,0,0,0,13,0,0,0,15,0,0,0,17,0,0,0,19,0,0,0,21,0,0,0,23,0,0,0,25,0,0,0,27,0,0,0,29,0,0,0,31,0,0,0,33,0,0,0,35,0,0,0,37,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,54,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,63,0,0,0,65,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,70,0,0,0,71,0,0,0,72,0,0,0,73,0,0,0,74,0,0,0,74,0,0,0,75,0,0,0,76,0,0,0,76,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,76,0,0,0,76,0,0,0,75,0,0,0,75,0,0,0,74,0,0,0,73,0,0,0,73,0,0,0,72,0,0,0,71,0,0,0,70,0,0,0,69,0,0,0,68,0,0,0,67,0,0,0,66,0,0,0,66,0,0,0,65,0,0,0,64,0,0,0,63,0,0,0,61,0,0,0,60,0,0,0,59,0,0,0,58,0,0,0,58,0,0,0,57,0,0,0,56,0,0,0,55,0,0,0,54,0,0,0,53,0,0,0,52,0,0,0,51,0,0,0,51,0,0,0,50,0,0,0,49,0,0,0,49,0,0,0,48,0,0,0,48,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,48,0,0,0,48,0,0,0,49,0,0,0,50,0,0,0,50,0,0,0,51,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,65,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,88,0,0,0,91,0,0,0,94,0,0,0,96,0,0,0,99,0,0,0,102,0,0,0,105,0,0,0,108,0,0,0,111,0,0,0,114,0,0,0,117,0,0,0,120,0,0,0,124,0,0,0,127,0,0,0,130,0,0,0,133,0,0,0,136,0,0,0,140,0,0,0,143,0,0,0,146,0,0,0,149,0,0,0,153,0,0,0,156,0,0,0,159,0,0,0,162,0,0,0,165,0,0,0,169,0,0,0,172,0,0,0,175,0,0,0,178,0,0,0,181,0,0,0,184,0,0,0,186,0,0,0,189,0,0,0,192,0,0,0,195,0,0,0,197,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,210,0,0,0,212,0,0,0,214,0,0,0,216,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,224,0,0,0,226,0,0,0,227,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,233,0,0,0,234,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,241,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,252,0,0,0,253,0,0,0,255,0,0,0])},hot:{name:"hot",r:new Float32Array([0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.30769,4.61538,6.92308,9.23077,11.5385,13.8462,16.1538,18.4615,20.7692,23.0769,25.3846,27.6923,30,32.3077,34.6154,36.9231,39.2308,41.5385,43.8462,46.1538,48.4615,50.7692,53.0769,55.3846,57.6923,60,62.3077,64.6154,66.9231,69.2308,71.5385,73.8462,76.1538,78.4615,80.7692,83.0769,85.3846,87.6923,90,92.3077,94.6154,96.9231,99.2308,101.538,103.846,106.154,108.462,110.769,113.077,115.385,117.692,120,122.308,124.615,126.923,129.231,131.538,133.846,136.154,138.462,140.769,143.077,145.385,147.692,150,152.308,154.615,156.923,159.231,161.538,163.846,166.154,168.462,170.769,173.077,175.385,177.692,180,182.308,184.615,186.923,189.231,191.538,193.846,196.154,198.462,200.769,203.077,205.385,207.692,210,212.308,214.615,216.923,219.231,221.538,223.846,226.154,228.462,230.769,233.077,235.385,237.692,240,242.308,244.615,246.923,249.231,251.538,253.846,255,255,255,255,255,255,255]),b:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.980769,1.96154,2.94231,3.92308,4.90385,5.88461,6.86539,7.84615,8.82692,9.80769,10.7885,11.7692,12.75,13.7308,14.7115,15.6923,16.6731,17.6538,18.6346,19.6154,20.5962,21.5769,22.5577,23.5385,24.5192,25.5,26.4808,27.4615,28.4423,29.4231,30.4038,31.3846,32.3654,33.3462,34.3269,35.3077,36.2885,37.2692,38.25,39.2308,40.2115,41.1923,42.1731,43.1538,44.1346,45.1154,46.0962,47.0769,48.0577,49.0385,50.0192,51,51.9808,52.9615,53.9423,54.9231,55.9038,56.8846,57.8654,58.8462,59.8269,60.8077,61.7885,62.7692,63.75,64.7308,65.7115,66.6923,67.6731,68.6538,69.6346,70.6154,71.5962,72.5769,73.5577,74.5385,75.5192,76.5,77.4808,78.4615,79.4423,80.4231,81.4038,82.3846,83.3654,84.3462,85.3269,86.3077,87.2885,88.2692,89.25,90.2308,91.2115,92.1923,93.1731,94.1538,95.1346,96.1154,97.0962,98.0769,99.0577,100.038,101.019,102,102.981,103.962,104.942,105.923,106.904,107.885,108.865,109.846,110.827,111.808,112.788,113.769,114.75,115.731,116.711,117.692,118.673,119.654,120.634,121.615,122.596,123.577,124.557,125.538,126.519,127.5])},gray:{name:"gray",r:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),g:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),b:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255])}},t.default=t.ColorMaps},772:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AstroViewer=void 0;const s=i(r(4723)),a=r(5087),o=r(1232),n=r(592),h=r(2919),l=i(r(619)),c=r(5409),u=r(8868),d=r(5781),_=r(9022),f=r(847);t.AstroViewer=class{astroSphere;canvas;webgl;rafId=null;webglContextList=new Map;viewfinderEl=null;viewfinderVisible=h.bootSetup.showViewfinder;viewfinderColor="rgba(75,148,226,0.68)";run(){return this.tick()}createCatalogue(e,t,r,i){return new o.CatalogueGL(e,t,r,i,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,r,i){return new n.FootprintSetGL(e,t,r,i,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideFootprintSet(e,t){e.setIsVisible(t)}deleteFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPointSet(e,t,r,i){return new d.TerraPointSetGL(e,t,r,i,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPointSet(e){this.astroSphere.showCatalogue(e)}hideTerraPointSet(e,t){e.setIsVisible(t)}deleteTerraPointSet(e){this.astroSphere.deleteCatalogue(e)}createTerraFootprintSet(e,t,r,i){return new _.TerraFootprintSetGL(e,t,r,i,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideTerraFootprintSet(e,t){e.setIsVisible(t)}deleteTerraFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}changeFootprintSetColor(e,t){e.changeColor(t)}getHoveredFootprints(){return this.astroSphere.getHoveredFootprints()}getDefaultHiPSURL(){return h.bootSetup.defaultHipsUrl}activateHiPS(e){this.astroSphere.activateHiPS(e)}activateXYZ(e){this.astroSphere.activateXYZ(e)}activateXYZ2(e){const t=new u.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver);this.astroSphere.activateXYZ2(t)}activateWMTS(e){this.astroSphere.activateWMTS(e)}activateMeshHiPS(e){this.astroSphere.activateMeshHiPS(new f.MeshHiPSDescriptor(e))}setXYZMaxConcurrentRequests(e){c.xyzTileRequestScheduler.setMaxConcurrent(e)}getXYZMaxConcurrentRequests(){return c.xyzTileRequestScheduler.getMaxConcurrent()}getXYZDebugStats(){return this.astroSphere.getXYZDebugStats()}getHiPSDebugStats(){return this.astroSphere.getHiPSDebugStats()}getMeshHiPSDebugStats(){return this.astroSphere.getMeshHiPSDebugStats()}async loadHiPS(e){const t=e.endsWith("/")?e:e+"/",r=await fetch(t+"properties");if(!r.ok)throw new Error(`HTTP ${r.status} fetching properties`);const i=await r.text(),s=new a.HiPSDescriptor(i,t);return this.astroSphere.activateHiPS(s),s.surveyName}async loadMeshHiPS(e,t={}){const r=e.endsWith("/")?e:e+"/";let i="";const s=await fetch(r+"properties");if(s.ok)i=await s.text();else{const e=await fetch(r+"properties.json");if(!e.ok)throw new Error(`HTTP ${e.status} fetching MeshHiPS properties`);const t=await e.json();i=Object.entries(t).map(([e,t])=>`${e}=${String(t)}`).join("\n")}const a=new f.MeshHiPSDescriptor({...t,baseUrl:r},i);return this.astroSphere.activateMeshHiPS(a),a.name}changeColorMap(e){const t=l.default[e];this.astroSphere.changeColorMap(t)}changeCustomColorMap(e){this.astroSphere.changeColorMap(e)}getActiveHiPS(){return this.astroSphere.activeHiPS}getActiveXYZ(){return this.astroSphere.activeXYZ}setCamera(e){this.astroSphere.setCamera(e)}setCameraPosition(e){this.astroSphere.setCameraPosition(e)}setCameraMatrix(e){this.astroSphere.setCameraMatrix(e)}restoreAstroViewerState(e,t){this.astroSphere.applyFullCameraState(e,t)}getCurrentAstroViewerStatus(){return this.astroSphere.getCurrentStatus()}goTo(e,t){this.astroSphere.goTo(e,t)}getActiveCoordinateMode(){return this.astroSphere.getActiveCoordinateMode()}getCenterCoordinates(){return this.astroSphere.getCentralPointCoordinates()}getCoordinatesFromMouse(){return this.astroSphere.getLastMousePointCoordinates()}setModelMatrix(e){this.astroSphere.healpixGrid.setModelMatrix(e)}toggleHealpixGrid(){this.astroSphere.healpixGrid.toggleShowGrid()}isHealpixGridVisible(){return this.astroSphere.healpixGrid.isVisible()}toggleEquatorialGrid(){return this.astroSphere.equatorialGrid.toggleShowGrid()}isEquatorialGridVisible(){return this.astroSphere.equatorialGrid.isVisible()}toggleLonLatGrid(){return this.astroSphere.toggleLonLatGrid()}isLonLatGridVisible(){return this.astroSphere.isLonLatGridVisible()}setEastWestRotationLocked(e){this.astroSphere.setEastWestRotationLocked(e)}isEastWestRotationLocked(){return this.astroSphere.isEastWestRotationLocked()}setNorthSouthRotationLocked(e){this.astroSphere.setNorthSouthRotationLocked(e)}isNorthSouthRotationLocked(){return this.astroSphere.isNorthSouthRotationLocked()}resetAxesOrientation(){this.astroSphere.resetAxesOrientation()}setKeepCameraNorthUp(e){this.astroSphere.setKeepCameraNorthUp(e)}isKeepCameraNorthUp(){return this.astroSphere.isKeepCameraNorthUp()}getFoV(){return this.astroSphere.getFoV()}getFoVPolygon(){return this.astroSphere.getFoVPolygon()}changeFoV(e){this.astroSphere.changeFoV(e)}changeFoV2(e){this.astroSphere.changeFoV2(e)}changeFoV3(e){this.astroSphere.changeFoV3(e)}getInsideSphere(){return this.astroSphere.getInsideSphere()}toggleInsideSphere(){this.astroSphere.toggleInsideSphere()}toggleViewfinder(){return this.viewfinderVisible=!this.viewfinderVisible,this.syncViewfinderVisibility(),this.viewfinderVisible}setViewfinderVisible(e){this.viewfinderVisible=e,this.syncViewfinderVisibility()}isViewfinderVisible(){return this.viewfinderVisible}setViewfinderColor(e){this.viewfinderColor=e,this.syncViewfinderColor()}getViewfinderColor(){return this.viewfinderColor}setRotationSensitivity(e){this.astroSphere.setCameraRotationSensitivity(e)}getRotationSensitivity(){return this.astroSphere.getCameraRotationSensitivity()}setZoomSensitivity(e){this.astroSphere.setZoomSensitivity(e)}getZoomSensitivity(){return this.astroSphere.getZoomSensitivity()}constructor(e){this.init(e),this.webglContextList=new Map}init(e){console.log("init webgl"),this.canvas=e,this.initViewfinder();const t=this.canvas.getContext("webgl2",{alpha:!1});if(!t)throw alert("Could not initialise WebGL, sorry :-("),new Error("WebGL2 not available");this.webgl=t;try{this.webgl.clearColor(0,.06274509792,50*.00392156862,.7)}catch(e){console.log("Error instantiating WebGL context")}this.initListeners(),this.astroSphere=new s.default(this.canvas,this.webgl)}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 r=[{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 r){const r=document.createElement("div");r.style.position="absolute",r.style.left=e.left??"auto",r.style.right=e.right??"auto",r.style.top=e.top??"auto",r.style.bottom=e.bottom??"auto",r.style.width=e.width,r.style.height=e.height,r.style.transform=e.transform,r.style.background="currentColor",r.style.borderRadius="999px",r.style.boxShadow="0 0 0 1px rgba(0, 0, 0, 0.14)",t.appendChild(r)}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,r=Math.max(1,Math.floor(e.width*t)),i=Math.max(1,Math.floor(e.height*t));this.canvas.width===r&&this.canvas.height===i||(this.canvas.width=r,this.canvas.height=i,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)}}},847:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSDescriptor=void 0,t.MeshHiPSDescriptor=class{_name="MeshHiPS";_baseUrl;_minOrder=0;_maxOrder=0;_selectedOrder;_fixedOrder=!1;_maxCachedTiles=384;_color=[.32,.34,.36,1];_wireframe=!1;_propertiesRawText="";_propertiesMap=new Map;_meshRadius=null;constructor(e,t=""){if(this._baseUrl=this.normalizeBaseUrl(e.baseUrl),this._propertiesRawText=t,this.parseProperties(t),this._name=e.name??this._propertiesMap.get("obs_collection")??this._propertiesMap.get("label")??this._name,this._minOrder=e.minOrder??this.readNumber("hips_order_min",this._minOrder),this._maxOrder=e.maxOrder??this.readNumber("hips_order",this.readNumber("hips_order_max",this._maxOrder)),this._fixedOrder=void 0!==e.order,this._selectedOrder=e.order??this._minOrder,this._maxCachedTiles=e.maxCachedTiles??this._maxCachedTiles,e.color)this._color=e.color;else if(this._propertiesMap.has("mesh_color")){const e=(this._propertiesMap.get("mesh_color")||"").split(/[,\s]+/).map(e=>Number(e)).filter(Number.isFinite);if(e.length>=3){let[t,r,i,s]=e;(t>1||r>1||i>1)&&(t/=255,r/=255,i/=255),Number.isFinite(s)||(s=1),this._color=[t,r,i,s]}}else this._color=this._color;if(this._wireframe=e.wireframe??this._wireframe,this._selectedOrder=this.clampOrder(this._selectedOrder),Number.isFinite(e.meshRadius))this._meshRadius=e.meshRadius;else{const e=this.readNumber("mesh_radius",NaN);if(!Number.isFinite(e))throw new Error('Missing mandatory property "mesh_radius" in MeshHiPS properties');this._meshRadius=e}}get name(){return this._name}get baseUrl(){return this._baseUrl}get minOrder(){return this._minOrder}get maxOrder(){return this._maxOrder}get selectedOrder(){return this._selectedOrder}get fixedOrder(){return this._fixedOrder}get maxCachedTiles(){return this._maxCachedTiles}get color(){return this._color}get wireframe(){return this._wireframe}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}get meshRadius(){return this._meshRadius}getProperty(e){return this._propertiesMap.get(e)}getTileUrl(e,t){const r=1e4*Math.floor(t/1e4);return`${this._baseUrl}Norder${e}/Dir${r}/Npix${t}.obj`}parseProperties(e){const t=e.split(/\r\n|\n/);for(const e of t){const t=e.trim();if(!t||t.startsWith("#"))continue;const r=t.indexOf("=");r<0||this._propertiesMap.set(t.slice(0,r).trim(),t.slice(r+1).trim())}}readNumber(e,t){const r=Number(this._propertiesMap.get(e));return Number.isFinite(r)?r:t}clampOrder(e){return Math.max(this._minOrder,Math.min(this._maxOrder,e))}normalizeBaseUrl(e){return e.endsWith("/")?e:`${e}/`}}},1072:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataColumn=t.ColumnType=void 0,function(e){e.STRING="STRING",e.NUMBER="NUMBER",e.GEOM_RA="GEOM_RA",e.GEOM_DEC="GEOM_DEC",e.GEOM_FOOTPRINT="GEOM_FOOTPRINT",e.MAIN_NAME="MAIN_NAME"}(r||(t.ColumnType=r={})),t.MetadataColumn=class{_index;_name;_description="";_columnType;_unit;_details=new Map;constructor(e){if(!e.name)throw new Error("No name column defined.");if(this._name=e.name,e.index<0||isNaN(e.index))throw new Error("No index column defined.");this._index=e.index,this._columnType=e.columnType??r.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 r=this._details.get(e);return"string"==typeof r?r:t}getNumber(e,t=NaN){const r=this._details.get(e);return"number"==typeof r?r:t}setDetail(e,t){this._details.set(e,t)}setDetails(e){const t=e instanceof Map?e.entries():Object.entries(e);for(const[e,r]of t)this._details.set(e,r)}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)}}}},1138:(e,t,r)=>{r.r(t),r.d(t,{CircleFinder:()=>l,Constants:()=>i,Fxyf:()=>c,Healpix:()=>_,Hploc:()=>n,Pointing:()=>a,RangeSet:()=>u,Vec3:()=>h,Xyf:()=>d,Zphi:()=>o,pstack:()=>s});class i{}i.halfpi=1.5707963267948966,i.inv_halfpi=2/Math.PI,i.twopi=2*Math.PI,i.inv_twopi=1/(2*Math.PI);class s{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 a{constructor(e,t,r,i){null!=e?(this.theta=n.atan2(Math.sqrt(e.x*e.x+e.y*e.y),e.z),this.phi=t?-n.atan2(e.y,e.x):n.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=r,this.phi=i)}}class o{constructor(e,t){this.z=e,this.phi=t}}class n{constructor(e){n.PI4_A=.7853981554508209,n.PI4_B=7.946627356147928e-9,n.PI4_C=3061616997868383e-32,n.M_1_PI=.3183098861837907,e&&(this.sth=0,this.have_sth=!1,this.z=n.cos(e.theta),this._phi=e.phi,Math.abs(this.z)>.99&&(this.sth=n.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 a(null,!1,n.atan2(t,this.z),this._phi)}toVec3(){var e=this.have_sth?this.sth:Math.sqrt((1-this.z)*(1+this.z));return new h(e*n.cos(this.phi),e*n.sin(this.phi),this.z)}toZphi(){return new o(this.z,this.phi)}static sin(e){let t=e*n.M_1_PI,r=Math.floor(t<0?t-.5:t+.5),i=4*r;return e-=i*n.PI4_A,e-=i*n.PI4_B,e-=i*n.PI4_C,1&r&&(e=-e),this.sincoshelper(e)}static cos(e){let t=e*n.M_1_PI-.5,r=1+2*Math.floor(t<0?t-.5:t+.5),i=2*r;return e-=i*n.PI4_A,e-=i*n.PI4_B,e-=i*n.PI4_C,2&r||(e=-e),n.sincoshelper(e)}static sincoshelper(e){let t=e*e,r=-7972559550090379e-33;return r=r*t+2810099727108632e-30,r=r*t-7647122191181588e-28,r=r*t+1.605904306056645e-10,r=r*t-2.5052108376350205e-8,r=r*t+27557319223919875e-22,r=r*t-.00019841269841269616,r=r*t+.00833333333333333,r=r*t-.16666666666666666,t*r*e+e}static asin(e){return n.mulsign(n.atan2k(Math.abs(e),Math.sqrt((1+e)*(1-e))),e)}static acos(e){return n.mulsign(n.atan2k(Math.sqrt((1+e)*(1-e)),Math.abs(e)),e)+(e<0?Math.PI:0)}static mulsign(e,t){return n.copySign(1,t)*e}static copySign(e,t){return t<0?-Math.abs(e):Math.abs(e)}static atanhelper(e){let t=e*e,r=-1887960084630735e-20;return r=r*t+.00020985007664581698,r=r*t-.0011061183148667248,r=r*t+.003700267441887131,r=r*t-.008898961958876555,r=r*t+.016599329773529202,r=r*t-.025451762493231264,r=r*t+.03378525800013531,r=r*t-.04076291912768365,r=r*t+.04666671500778406,r=r*t-.052367485230348246,r=r*t+.05876663929266736,r=r*t-.06665735793610805,r=r*t+.07692195383117696,r=r*t-.09090899500824501,r=r*t+.11111110564826142,r=r*t-.1428571426677133,r=r*t+.19999999999659127,r=r*t-.3333333333333111,r*t*e+e}static atan2k(e,t){let r=0;if(t<0&&(t=-t,r=-2),e>t){let i=t;t=e,e=-i,r+=1}return n.atanhelper(e/t)+r*(Math.PI/2)}static atan2(e,t){let r=n.atan2k(Math.abs(e),t);return r=n.mulsign(r,t),(n.isinf(t)||0==t)&&(r=Math.PI/2-(n.isinf(t)?n.copySign(1,t)*(Math.PI/2):0)),n.isinf(e)&&(r=Math.PI/2-(n.isinf(t)?n.copySign(1,t)*(1*Math.PI/4):0)),0==e&&(r=-1==n.copySign(1,t)?Math.PI:0),n.isnan(t)||n.isnan(e)?NaN:n.mulsign(r,e)}static isnan(e){return e!=e}static isinf(e){return Math.abs(e)===1/0}}n.PI4_A=.7853981554508209,n.PI4_B=7.946627356147928e-9,n.PI4_C=3061616997868383e-32,n.M_1_PI=.3183098861837907;class h{constructor(e,t,r){if(e instanceof a){let t=e,r=n.sin(t.theta);this.x=r*n.cos(t.phi),this.y=r*n.sin(t.phi),this.z=n.cos(t.theta)}else this.x=e,this.y=t,this.z=r}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 h(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 h(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 h(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 h(this.x-e.x,this.y-e.y,this.z-e.z)}angle(e){return n.atan2(this.cross(e).length(),this.dot(e))}flip(){this.x*=-1,this.y*=-1,this.z*=-1}static pointing2Vec3(e){let t=n.sin(e.theta),r=t*n.cos(e.phi),i=t*n.sin(e.phi),s=n.cos(e.theta);return new h(r,i,s)}}class l{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 r=2;r<t;++r)e[r].dot(this.center)<this.cosrad&&this.getCircle(e,r)}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 r=1;r<t;++r)e[r].dot(this.center)<this.cosrad&&this.getCircle2(e,r,t)}getCircle2(e,t,r){this.center=e[t].add(e[r]),this.center.normalize(),this.cosrad=e[t].dot(this.center);for(let i=0;i<t;++i)e[i].dot(this.center)<this.cosrad&&(this.center=e[t].sub(e[i]).cross(e[r].sub(e[i])),this.center.normalize(),this.cosrad=e[i].dot(this.center),this.cosrad<0&&(this.center.flip(),this.cosrad=-this.cosrad))}getCenter(){return new h(this.center.x,this.center.y,this.center.z)}getCosrad(){return this.cosrad}}class c{constructor(e,t,r){this.fx=e,this.fy=t,this.face=r,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 n,r=this.jrll[this.face]-this.fx-this.fy;if(r<1){e=r;let i=e*e/3;t.z=1-i,t.z>.99&&(t.sth=Math.sqrt(i*(2-i)),t.have_sth=!0)}else if(r>3){e=4-r;let i=e*e/3;t.z=i-1,t.z<-.99&&(t.sth=Math.sqrt(i*(2-i)),t.have_sth=!0)}else e=1,t.z=2*(2-r)/3;let i=this.jpll[this.face]*e+this.fx-this.fy;return i<0&&(i+=8),i>=8&&(i-=8),t.phi=e<1e-15?0:.5*this.halfpi*i/e,t}toVec3(){return this.toHploc().toVec3()}}class u{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 r=this.sz+2;if(this.r.length<r){let e=Math.max(2*this.r.length,r),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 d{constructor(e,t,r){this.ix=e,this.iy=t,this.face=r}}class _{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 _(1<<e),this.mpr[e]=this.bn[e].maxPixrad(),this.cmpr[e]=n.cos(this.mpr[e]),this.smpr[e]=n.sin(this.mpr[e])}getNPix(){return this.npix}getBoundaries(e){let t=new Array,r=this.nest2xyf(e),i=.5/this.nside,s=(r.ix+.5)/this.nside,a=(r.iy+.5)/this.nside;return t[0]=new c(s+i,a+i,r.face).toVec3(),t[1]=new c(s-i,a+i,r.face).toVec3(),t[2]=new c(s-i,a-i,r.face).toVec3(),t[3]=new c(s+i,a-i,r.face).toVec3(),t}getBoundariesWithStep(e,t){let r=new Array,i=this.nest2xyf(e),s=.5/this.nside,a=(i.ix+.5)/this.nside,o=(i.iy+.5)/this.nside,n=1/(this.nside*t);for(let e=0;e<t;e++)r[e]=new c(a+s-e*n,o+s,i.face).toVec3(),r[e+t]=new c(a-s,o+s-e*n,i.face).toVec3(),r[e+2*t]=new c(a-s+e*n,o-s,i.face).toVec3(),r[e+3*t]=new c(a+s,o-s+e*n,i.face).toVec3();return r}getPointsForXyfNoStep(e,t,r){let i=new Array,s=new d(e,t,r),a=.5/this.nside,o=(s.ix+.5)/this.nside,n=(s.iy+.5)/this.nside;return i[0]=new c(o+a,n+a,s.face).toVec3(),i[1]=new c(o-a,n+a,s.face).toVec3(),i[2]=new c(o-a,n-a,s.face).toVec3(),i[3]=new c(o+a,n-a,s.face).toVec3(),i}getPointsForXyf(e,t,r,i){let s=r*Math.pow(2,this.order),a=new Array,o=new d(e,t,i),n=.5/s,h=(o.ix+.5)/s,l=(o.iy+.5)/s;return a[0]=new c(h+n,l+n,o.face).toVec3(),a[1]=new c(h-n,l+n,o.face).toVec3(),a[2]=new c(h-n,l-n,o.face).toVec3(),a[3]=new c(h+n,l-n,o.face).toVec3(),a}neighbours(e){let t=new Int32Array(8),r=this.nest2xyf(e),i=r.ix,s=r.iy,a=r.face;var o=this.nside-1;if(i>0&&i<o&&s>0&&s<o){let e=Math.floor(a<<2*this.order),r=this.spread_bits(i),o=this.spread_bits(s)<<1,n=this.spread_bits(i+1),h=this.spread_bits(s+1)<<1,l=this.spread_bits(i-1),c=this.spread_bits(s-1)<<1;t[0]=e+l+o,t[1]=e+l+h,t[2]=e+r+h,t[3]=e+n+h,t[4]=e+n+o,t[5]=e+n+c,t[6]=e+r+c,t[7]=e+l+c}else for(let e=0;e<8;++e){let r=i+this.xoffset[e],o=s+this.yoffset[e],n=4;r<0?(r+=this.nside,n-=1):r>=this.nside&&(r-=this.nside,n+=1),o<0?(o+=this.nside,n-=3):o>=this.nside&&(o-=this.nside,n+=3);let h=this.facearray[n][a];if(h>=0){let i=this.swaparray[n][a>>>2];if((1&i)>0&&(r=Math.floor(this.nside-r-1)),(2&i)>0&&(o=Math.floor(this.nside-o-1)),(4&i)>0){let e=r;r=o,o=e}t[e]=this.xyf2nest(r,o,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 d(this.compress_bits(t),this.compress_bits(t>>1),Math.floor(e>>2*this.order))}xyf2nest(e,t,r){return Math.floor(r<<2*this.order)+this.spread_bits(e)+(this.spread_bits(t)<<1)}loc2pix(e){let t,r=e.z,i=e.phi,s=Math.abs(r),a=this.fmodulo(i*this.inv_halfpi,4);if(s<=this.twothird){let e=this.nside*(.5+a),i=this.nside*(.75*r),s=Math.floor(e-i),o=Math.floor(e+i),n=Math.floor(s>>>this.order),h=Math.floor(o>>>this.order),l=Math.floor(n==h?4|n:n<h?n:h+8),c=Math.floor(o&this.nside-1),u=Math.floor(this.nside-(s&this.nside-1)-1);t=this.xyf2nest(c,u,l)}else{let i=Math.min(3,Math.floor(a)),o=a-i,n=s<.99||!e.have_sth?this.nside*Math.sqrt(3*(1-s)):this.nside*e.sth/Math.sqrt((1+s)/3),h=Math.floor(o*n),l=Math.floor((1-o)*n);h>=this.nside&&(h=this.nside-1),l>=this.nside&&(l=this.nside-1),t=r>=0?this.xyf2nest(Math.floor(this.nside-l-1),Math.floor(this.nside-h-1),i):this.xyf2nest(Math.floor(h),Math.floor(l),i+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,r=new n(void 0),s=this.nest2xyf(e),a=(this.jrll[s.face]<<this.order)-s.ix-s.iy-1;if(a<this.nside){t=a;let e=t*t*this.fact2;r.z=1-e,r.z>.99&&(r.sth=Math.sqrt(e*(2-e)),r.have_sth=!0)}else if(a>this.nl3){t=this.nl4-a;let e=t*t*this.fact2;r.z=e-1,r.z<-.99&&(r.sth=Math.sqrt(e*(2-e)),r.have_sth=!0)}else t=this.nside,r.z=(this.nl2-a)*this.fact1;let o=this.jpll[s.face]*t+s.ix-s.iy;return o<0&&(o+=8*t),r.phi=t==this.nside?.75*i.halfpi*o*this.fact1:.5*i.halfpi*o/t,r}za2vec(e,t){const r=Math.sqrt(1-e*e),i=r*Math.cos(t),s=r*Math.sin(t);return new h(i,s,e)}ang2vec(e,t){const r=Math.cos(e);return this.za2vec(r,t)}vec2ang(e){const{z:t,a:r}=this.vec2za(e.getX(),e.getY(),e.getZ());return{theta:Math.acos(t),phi:r}}vec2za(e,t,r){const i=e*e+t*t;if(0==i)return{z:r<0?-1:1,a:0};{const s=Math.PI/2,a=(Math.atan2(t,e)+s)%s;return{z:r/=Math.sqrt(r*r+i),a}}}ang2pix(e,t){return this.loc2pix(new n(e))}fmodulo(e,t){if(e>=0)return e<t?e:e%t;var r=e%t+t;return r===t?0:r}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 r=0!=t,s=e.length;if(!(s>=3))return void console.log("not enough vertices in polygon");let o=new Array;for(let t=0;t<s;++t)o[t]=h.pointing2Vec3(e[t]);let c=new Array,u=0,d=0,_=!1;for(;d<o.length;){let e=o[d],t=null,r=null;d==o.length-1?(r=o[1],t=o[0]):d==o.length-2?(r=o[0],t=o[d+1]):(t=o[d+1],r=o[d+2]),c[d]=e.cross(t).norm();let i=c[d].dot(r);if(0==d)u=i<0?-1:1,new a(e),_=!1;else{if(u*i<0){new a(t),o.splice(d+1,1),c.splice(d,1),_=!0,d-=1;continue}new a(e),_=!1}c[d].scale(u),d+=1}s=o.length;let f=new Array(r?s+1:s);if(f=f.fill(i.halfpi),r){let e=new l(o);c[s]=e.getCenter(),f[s]=n.acos(e.getCosrad())}return this.queryMultiDisc(c,f,t)}queryMultiDisc(e,t,r){this.computeBn();let i=0!=r,a=e.length;if(a!=t.length)return void console.error("inconsistent input arrays");let o=new u(8),h=0;i&&(Math.pow(2,this.order_max-this.order)>=r||console.error("invalid oversampling factor"),r&r-1&&console.error("oversampling factor must be a power of 2"),h=this.ilog2(r));let l,c,d=this.order+h,_=new Array(d+1);for(l=0;l<=d;++l){_[l]=new Array(a);let e=this.bn[l].maxPixrad();for(c=0;c<a;++c)_[l][c]=new Float64Array(3),_[l][c][0]=t[c]+e>Math.PI?-1:n.cos(t[c]+e),_[l][c][1]=0==l?n.cos(t[c]):_[0][c][1],_[l][c][2]=t[c]-e<0?1:n.cos(t[c]-e)}let f=new s(12+3*d);for(let e=0;e<12;e++)f.push(11-e,0);for(;f.size()>0;){let t=f.ptop(),r=f.otop();f.pop();let s=this.bn[r].pix2vec(t),n=3;for(let t=0;t<a&&n>0;++t){let i=s.dot(e[t]);for(let e=0;e<n;++e)i<_[r][t][e]&&(n=e)}n>0&&this.check_pixel(r,d,n,o,t,f,i)}return o}ilog2(e){let t=Math.max(e,1);return 31-Math.clz32(t)}cosdist_zphi(e,t,r,i){return e*r+n.cos(t-i)*Math.sqrt((1-e*e)*(1-r*r))}check_pixel(e,t,r,i,s,a,o){if(0!=r)if(e<this.order)if(r>=3){let t=2*(this.order-e);i.append1(s<<t,s+1<<t)}else for(let t=0;t<4;++t)a.push(4*s+3-t,e+1);else if(e>this.order)if(r>=2)i.append(s>>>2*(e-this.order)),a.popToMark();else if(e<t)for(let t=0;t<4;++t)a.push(4*s+3-t,e+1);else i.append(s>>>2*(e-this.order)),a.popToMark();else if(r>=2)i.append(s);else if(o)if(this.order<t){a.mark();for(let t=0;t<4;++t)a.push(4*s+3-t,e+1)}else i.append(s)}maxPixrad(){let e=new o(2/3,Math.PI/this.nl4),t=this.convertZphi2xyz(e),r=new h(t[0],t[1],t[2]),i=1-1/this.nside;i*=i;let s=new o(1-i/3,0),a=this.convertZphi2xyz(s),n=new h(a[0],a[1],a[2]);return r.angle(n)}convertZphi2xyz(e){let t=Math.sqrt((1-e.z)*(1+e.z));return[t*n.cos(e.phi),t*n.sin(e.phi),e.z]}queryDiscInclusive(e,t,r){this.computeBn();let i=0!=r,a=new u;if(t>=Math.PI)return a.append1(0,this.npix),a;let o=0;i&&(r&r-1&&console.error("oversampling factor must be a power of 2"),o=this.ilog2(r));let l=Math.min(this.order_max,this.order+o),c=h.pointing2Vec3(e),d=new Array(l+1),_=new Array(l+1),f=n.cos(t),g=n.sin(t);for(let e=0;e<=l;e++){let r=this.mpr[e],i=this.cmpr[e],s=this.smpr[e];d[e]=t+r>Math.PI?-1:f*i-g*s,_[e]=t-r<0?1:f*i+g*s}let p=new s(12+3*l);for(let e=0;e<12;e++)p.push(11-e,0);for(;p.size()>0;){let t=p.ptop(),r=p.otop();p.pop();let s=this.bn[r].pix2zphi(t),o=this.cosdist_zphi(c.z,e.phi,s.z,s.phi);if(o>d[r]){let e=o<f?1:o<=_[r]?2:3;this.check_pixel(r,l,e,a,t,p,i)}}return a}}},1229:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=t.Source=t.MeshHiPSDescriptor=t.MeshHiPS=t.WMTSAdapter=t.XYZMap=t.HiPS=t.createColorMapFromSamples=t.COLOR_MAP_SAMPLE_COUNT=t.ColorMaps=t.GeoJSONParser=t.CoordsType=t.FoVUtils=t.CartesianOpts=t.PointInitOpts=t.AstroOpts=t.SphericalOpts=t.Point=t.ColumnType=t.MetadataInit=t.MetadataColumn=t.MetadataManager=t.TerraFootprintSetGL=t.TerraPointSetGL=t.CatalogueGL=t.FootprintSetGL=t.HoveredFootprintDetail=t.SphereFoV=t.FoV=t.HiPSDescriptor=t.AstroViewer=void 0;var s=r(772);Object.defineProperty(t,"AstroViewer",{enumerable:!0,get:function(){return s.AstroViewer}});var a=r(5087);Object.defineProperty(t,"HiPSDescriptor",{enumerable:!0,get:function(){return a.HiPSDescriptor}});var o=r(5803);Object.defineProperty(t,"FoV",{enumerable:!0,get:function(){return o.SphereFoV}});var n=r(5803);Object.defineProperty(t,"SphereFoV",{enumerable:!0,get:function(){return n.SphereFoV}});var h=r(592);Object.defineProperty(t,"HoveredFootprintDetail",{enumerable:!0,get:function(){return h.HoveredFootprintDetail}}),Object.defineProperty(t,"FootprintSetGL",{enumerable:!0,get:function(){return h.FootprintSetGL}});var l=r(1232);Object.defineProperty(t,"CatalogueGL",{enumerable:!0,get:function(){return l.CatalogueGL}});var c=r(5781);Object.defineProperty(t,"TerraPointSetGL",{enumerable:!0,get:function(){return c.TerraPointSetGL}});var u=r(9022);Object.defineProperty(t,"TerraFootprintSetGL",{enumerable:!0,get:function(){return u.TerraFootprintSetGL}});var d=r(5403);Object.defineProperty(t,"MetadataManager",{enumerable:!0,get:function(){return d.MetadataManager}});var _=r(1072);Object.defineProperty(t,"MetadataColumn",{enumerable:!0,get:function(){return _.MetadataColumn}}),Object.defineProperty(t,"MetadataInit",{enumerable:!0,get:function(){return _.MetadataInit}}),Object.defineProperty(t,"ColumnType",{enumerable:!0,get:function(){return _.ColumnType}});var f=r(6553);Object.defineProperty(t,"Point",{enumerable:!0,get:function(){return f.Point}}),Object.defineProperty(t,"SphericalOpts",{enumerable:!0,get:function(){return f.SphericalOpts}}),Object.defineProperty(t,"AstroOpts",{enumerable:!0,get:function(){return f.AstroOpts}}),Object.defineProperty(t,"PointInitOpts",{enumerable:!0,get:function(){return f.PointInitOpts}}),Object.defineProperty(t,"CartesianOpts",{enumerable:!0,get:function(){return f.CartesianOpts}});var g=r(8083);Object.defineProperty(t,"FoVUtils",{enumerable:!0,get:function(){return g.FoVUtils}});var p=r(8145);Object.defineProperty(t,"CoordsType",{enumerable:!0,get:function(){return p.CoordsType}});var m=r(8755);Object.defineProperty(t,"GeoJSONParser",{enumerable:!0,get:function(){return i(m).default}});var M=r(619);Object.defineProperty(t,"ColorMaps",{enumerable:!0,get:function(){return M.ColorMaps}}),Object.defineProperty(t,"COLOR_MAP_SAMPLE_COUNT",{enumerable:!0,get:function(){return M.COLOR_MAP_SAMPLE_COUNT}}),Object.defineProperty(t,"createColorMapFromSamples",{enumerable:!0,get:function(){return M.createColorMapFromSamples}});var x=r(3726);Object.defineProperty(t,"HiPS",{enumerable:!0,get:function(){return x.HiPS}});var v=r(1741);Object.defineProperty(t,"XYZMap",{enumerable:!0,get:function(){return v.XYZMap}});var b=r(3956);Object.defineProperty(t,"WMTSAdapter",{enumerable:!0,get:function(){return b.WMTSAdapter}});var S=r(6878);Object.defineProperty(t,"MeshHiPS",{enumerable:!0,get:function(){return S.MeshHiPS}});var P=r(847);Object.defineProperty(t,"MeshHiPSDescriptor",{enumerable:!0,get:function(){return P.MeshHiPSDescriptor}});var y=r(146);Object.defineProperty(t,"Source",{enumerable:!0,get:function(){return y.Source}});var T=r(2475);Object.defineProperty(t,"Footprint",{enumerable:!0,get:function(){return T.Footprint}}),console.log("astroviewer UMD loaded")},1232:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueGL=void 0;const i=r(146),s=r(6553),a=r(8145),o=r(7930),n=r(3559),h=r(5403);class l{_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,r,i,s,a){this._webgl=s,this._ready=!1,this._visibleTilesManager=a,this.TYPE="SOURCE_CATALOGUE",this._name=e,this._description=t,this._providerUrl=r,this._metadataManager=i,this._sources=[],this.vertexCataloguePosition=new Float32Array(0),this.hoveredIndexes=[],this.selectedIndexes=[],this.extHoveredIndexes=[],this._oldMouseCoords=null,this._healpixDensityMap=new Map,this._catalogueShaderProgram=new n.CatalogueShaderProgram(this._webgl),this._catalogueShaderProgram.shaderProgram,this._isVisible=!0}setIsVisible(e){this._isVisible=e}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get isVisible(){return this._isVisible}minMax(e){if(!this._sources.length)return{min:0,max:0};let t=this._sources[0].details[e];if(isNaN(Number(t)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain only number values`),{min:0,max:0};let r=t;for(const i of this._sources){const s=i.details[e];if(isNaN(Number(s)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain number only values`),{min:0,max:0};s<t&&(t=s),s>r&&(r=s)}return{min:Number(t),max:Number(r)}}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==h.MetadataManager.STANDARD_SIZE){this._metadataManager.resetShapeColumn();for(const e of this._sources){const t=l.STANDARD_SHAPE_SIZE;e.shapeSize=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedShapeColumn=e;const r=this._metadataManager.selectedShapeColumn?.index??-1;if(r<0)return void(t&&(this._metadataManager.selectedShapeColumn=t));const i=this.minMax(r);if(i.min!=i.max){for(const e of this._sources){const t=Number(e.getDetailByindex(r)),s=Number(i.min),a=Number(i.max),o=(t-s)/Math.max(1e-12,a-s)*12+8;e.shapeSize=o}this._bufferInitialised=!1}else console.warn(`${i} min and max are equals. No resizing will be applied.`)}changeMetaShapeHue(e){if(!this._webgl)return;if(e==h.MetadataManager.STANDARD_HUE){this._metadataManager.resetHueColumn();for(const e of this._sources){const t=l.STANDARD_SHAPE_HUE;e.brightnessFactor=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedHueColumn=e;const r=this._metadataManager.selectedHueColumn?.index??-1;if(r<0)return void(t&&(this._metadataManager.selectedHueColumn=t));const i=this.minMax(r);if(i.min!=i.max){for(const e of this._sources){const t=Number(e.getDetailByindex(r)),s=Number(i.min),a=Number(i.max),o=(t-s)/Math.max(1e-12,a-s);e.brightnessFactor=-(2*o-1)}this._bufferInitialised=!1}else console.warn(`${i} 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 h.MetadataManager(t);const r=this._metadataManager.selectedRaColumn?.index??-1,o=this._metadataManager.selectedDecColumn?.index??-1;if(r<0||o<0)throw new Error(`(ra, dec) idx not defined (${r}, ${o}) `);for(let t=0;t<e.length;t++){const n=new s.Point({raDeg:e[t][r],decDeg:e[t][o]},a.CoordsType.ASTRO),h=new i.Source(n,e[t]);h.shapeSize=h.shapeSize??l.STANDARD_SHAPE_SIZE,h.brightnessFactor=3,this.addSource(h),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 r=e.point,i=t.point;if(r.raDeg!==i.raDeg||r.decDeg!==i.decDeg)return!1;if(e.details.length!==t.details.length)return!1;for(let r=0;r<e.details.length;r++)if(!Object.is(e.details[r],t.details[r]))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 r=this.findSourceIndex(e);if(r<0)return;const i=r*l.ELEM_SIZE;if(t)this.hoveredIndexes.includes(r)||this.hoveredIndexes.push(r);else{if(i+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(r);e>=0&&(this.hoveredIndexes.splice(e,1),this.vertexCataloguePosition[i+3]=0,this.vertexCataloguePosition[i+4]=this._sources[r]?.shapeSize??l.STANDARD_SHAPE_SIZE)}}extAddSources2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findSourceIndex(e);if(t<0)return;const r=t*l.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(r+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&(this.selectedIndexes.splice(e,1),this.vertexCataloguePosition[r+3]=0,this.vertexCataloguePosition[r+4]=this._sources[t]?.shapeSize??l.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*l.ELEM_SIZE);let t=0;for(let r=0;r<e;r++){const e=this._sources[r],i=e.healpixPixel,s=this._healpixDensityMap.get(i);s?s.includes(r)||s.push(r):this._healpixDensityMap.set(i,[r]),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??l.STANDARD_SHAPE_SIZE,this.vertexCataloguePosition[t+5]=e.brightnessFactor??0,t+=l.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=[],r=e.computeNpix();if(null!=r&&this._healpixDensityMap.has(r)){const i=this._healpixDensityMap.get(r),s=this.getSelectionRadius();for(let r=0;r<i.length;r++){const a=i[r],o=this._sources[a];if(!o)continue;const n=o.point.x-e.x,h=o.point.y-e.y,l=o.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=s&&t.push(a)}}return t}setSelectedIndexes(e){e.forEach(e=>{if(e<0||e>=this._sources.length)return;const t=e*l.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??l.STANDARD_SHAPE_SIZE):(this.selectedIndexes.push(e),this.vertexCataloguePosition[t+3]=2,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??l.STANDARD_SHAPE_SIZE))})}getSourcesFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{sources:[],pickedIndexes:[]};const r=[];return t.forEach(e=>{const t=this._sources[e];t&&r.push(t)}),r.length?{sources:r,pickedIndexes:t}:null}selectPrimarySourceFromClick(e){const t=this.getSourcesFromPointer(e),r=t?.pickedIndexes??[];if(this.setSelectedIndexes(r),!r.length)return{sources:[],selectionState:[]};const i=[],s=[];return r.forEach(e=>{const t=this._sources[e];if(!t)return;const r=this.selectedIndexes.includes(e);i.push({source:t,selected:r}),s.push(t)}),s.length?{sources:s,selectionState:i}: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=[],r=e.computeNpix();if(null!=r&&this._healpixDensityMap.has(r)){const i=this._healpixDensityMap.get(r),s=this.getSelectionRadius();for(let r=0;r<i.length;r++){const a=i[r],o=this._sources[a];if(!o)continue;const n=o.point.x-e.x,h=o.point.y-e.y,l=o.point.z-e.z;Math.sqrt(n*n+h*h+l*l)<=s&&t.push(a)}}return t}draw(e,t,r,i){if(!this.isVisible)return;if(!this._ready)return;if(!r)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;this._catalogueShaderProgram.enableShaders(i,e,r),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.position,3,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.position),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.hovered,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,3*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.hovered),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.pointSize,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,4*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.pointSize),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.brightness,1,this._webgl.FLOAT,!1,l.BYTES_X_ELEM*l.ELEM_SIZE,5*l.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.brightness);const s=(0,o.colorHex2RGB)(this._shapeColor);this._catalogueShaderProgram.locations.color&&this._webgl.uniform4f(this._catalogueShaderProgram.locations.color,s[0],s[1],s[2],1);for(let e=0;e<this.selectedIndexes.length;e++){const t=this.selectedIndexes[e],r=t*l.ELEM_SIZE;this.vertexCataloguePosition[r+3]=2,this.vertexCataloguePosition[r+4]=this._sources[t].shapeSize}for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e]*l.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],r=t*l.ELEM_SIZE;this.vertexCataloguePosition[r+3]=1,this.vertexCataloguePosition[r+4]=this._sources[t].shapeSize}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW);const a=this.vertexCataloguePosition.length/l.ELEM_SIZE;this._webgl.drawArrays(this._webgl.POINTS,0,a),this._oldMouseCoords=t.xyz}}t.CatalogueGL=l},1375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZTile=void 0;const i=r(8819);t.XYZTile=class{_coord;_url;_webgl;_shaderProgram;_meshBuilder;_gpuMesh;_texture=null;_image;_ready=!1;_loading=!1;_aborted=!1;_failedUntil=0;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,r,s,a=new i.XYZMeshBuilder,o=16){this._coord=e,this._url=t,this._webgl=r,this._shaderProgram=s,this._meshBuilder=a;const n=this._meshBuilder.buildTileMesh(e,o);this._gpuMesh=this._meshBuilder.uploadMesh(n,this._webgl),this.initImage()}get coord(){return this._coord}get ready(){return this._ready}get loading(){return this._loading}get failedUntil(){return this._failedUntil}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}initImage(){if(this._loading||this._ready||this._aborted)return;const e=Date.now();if(this._failedUntil>e)return;this._loading=!0;const t=new Image;this._image=t,t.crossOrigin="anonymous",t.onload=()=>this.imageLoaded(),t.onerror=()=>{this._ready=!1,this._loading=!1,this._failedUntil=Date.now()+3e4},t.src=this._url}imageLoaded(){this._image&&!this._aborted&&(this.textureLoaded(this._image),this._loading=!1,this._failedUntil=0,this._ready=!0)}textureLoaded(e){const t=this._webgl;this._shaderProgram.enableProgram();const r=t.createTexture();if(!r)throw new Error(`Could not create XYZ texture for ${this.key}`);this._texture=r,t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}draw(e,t,r,i){return this.touch(),!(!this._ready||!this._texture||this._aborted||(this.drawWithGpuMesh(this._gpuMesh,e,t,r,i),0))}drawRemapped(e,t,r,i,s){return this.touch(),!(!this._ready||!this._texture||this._aborted||(this.drawWithGpuMesh(e,t,r,i,s),0))}dispose(){const e=this._webgl;this._texture&&(e.deleteTexture(this._texture),this._texture=null),this._gpuMesh.positionBuffer&&(e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh.positionBuffer=null),this._gpuMesh.uvBuffer&&(e.deleteBuffer(this._gpuMesh.uvBuffer),this._gpuMesh.uvBuffer=null),this._gpuMesh.indexBuffer&&(e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh.indexBuffer=null),this._image=void 0,this._ready=!1,this._loading=!1,this._aborted=!0}drawWithGpuMesh(e,t,r,i,s){if(!this._texture)return;const a=this._webgl;this._shaderProgram.enableShaders(t,r,i,s),a.bindBuffer(a.ARRAY_BUFFER,e.positionBuffer),a.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),a.bindBuffer(a.ARRAY_BUFFER,e.uvBuffer),a.vertexAttribPointer(this._shaderProgram.locations.textureCoordAttribute,2,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._texture),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.indexBuffer),a.drawElements(a.TRIANGLES,e.indexCount,e.indexType,0),a.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),a.disableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute)}get key(){return`${this._coord.z}/${this._coord.x}/${this._coord.y}`}}},1741:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMap=void 0;const i=r(4735),s=r(6937),a=r(8284),o=r(619),n=r(8124),h=r(149),l=r(2737),c=r(3174),u=r(8819);class d extends i.AbstractSkyEntity{_xyzShaderProgram;_descriptor;_visibleTilesManager;_tileBuffer;_meshBuilder;_baseurl;_zoom;_latLonGrid;_colorMapIdx=0;_colorMap=o.ColorMaps.native;constructor(e,t,r,i,o,c){super(e,t,r,i,o.name,c,!1),this._descriptor=o,this._xyzShaderProgram=new h.XYZShaderProgram(c),this._meshBuilder=new u.XYZMeshBuilder,this._tileBuffer=new l.XYZTileBuffer(1),this.initGL(c),this._latLonGrid=new n.LatLonGrid(e,t,r,i,"LatLonGrid",this._webgl),this._visibleTilesManager=new s.XYZVisibleTilesManager,this._baseurl=o.url,this.initShaders(),this._zoom=a.xyzFovHelper.getZoom(180)}changeColorMap(e){switch(this._colorMap=e,e.name){case"grayscale":this._colorMapIdx=1,this._colorMap=o.ColorMaps.grayscale;break;case"planck":this._colorMapIdx=2,this._colorMap=o.ColorMaps.planck;break;case"cmb":this._colorMapIdx=3,this._colorMap=o.ColorMaps.cmb;break;case"rainbow":this._colorMapIdx=4,this._colorMap=o.ColorMaps.rainbow;break;case"eosb":this._colorMapIdx=5,this._colorMap=o.ColorMaps.eosb;break;case"cubehelix":this._colorMapIdx=6,this._colorMap=o.ColorMaps.cubehelix;break;case"hot":this._colorMapIdx=7,this._colorMap=o.ColorMaps.hot;break;case"gray":this._colorMapIdx=8,this._colorMap=o.ColorMaps.gray;break;case"native":this._colorMapIdx=0,this._colorMap=o.ColorMaps.native;break;default:this._colorMapIdx=9,this._colorMap=e}}initShaders(){this._xyzShaderProgram.enableProgram()}isLonLatGridVisible(){return this._latLonGrid.isVisible()}toggleLonLatGrid(){return this._latLonGrid.toggleShowGrid()}getFoV(){return this._latLonGrid.getFoV()}refresh(e){const t=this._latLonGrid.refreshFoV(e);this._zoom=a.xyzFovHelper.getZoom(t)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const r=e.pMatrix;if(!r)return;this.refresh(e);const i=this.getModelMatrix();this._xyzShaderProgram.setRuntimeColorMap(this._colorMap);const s=this._visibleTilesManager.computeVisibleTiles(this._zoom,this,this._webgl,e.camera,e.pMatrix),a=s.visibleTiles,o=s.ancestorsMap,n=this._tileBuffer.ensureTiles(this.getTilesToEnsure(a,o),e=>this.createTile(e));this._tileBuffer.evictCached(this._descriptor.maxCachedTiles);for(const e of n){const a=this._tileBuffer.getActiveTile(e);if(!a||a.coord.z!==s.currentZoom)continue;if(a.draw(r,t,i,this._colorMapIdx))continue;const n=this.findBestAvailableAncestor(a.coord);n?.draw(s.currentZoom,[a.coord],o,r,t,i,this._colorMapIdx)}this._latLonGrid.draw(e)}createTile(e){return new c.XYZAnchestorTile(e,this.resolveTileUrl(e),this._webgl,this._xyzShaderProgram,this._meshBuilder,this._descriptor.segmentsPerSide)}getTilesToEnsure(e,t){const r=new Map;for(const t of e)r.set(this.tileKey(t),t);for(const e of t.values())r.set(this.tileKey(e),e);return Array.from(r.values())}findBestAvailableAncestor(e){for(let t=e.z-1;t>=0;t--){const r=e.z-t,i={z:t,x:e.x>>r,y:e.y>>r},s=this._tileBuffer.getAnyTile(this.tileKey(i));if(s?.ready)return s}return null}resolveTileUrl(e){const t=this._descriptor.urlResolver;if(t)return t(e);const r=2**e.z,i=this._descriptor.flipY?r-1-e.y:e.y,s=this._descriptor.subdomains,a=s.length>0?s[Math.abs(e.x+e.y+e.z)%s.length]:"";return this._baseurl.replace(/\{z\}/g,String(e.z)).replace(/\{x\}/g,String(e.x)).replace(/\{y\}/g,String(i)).replace(/\{s\}/g,a??"")}getDebugStats(){const e=Array.from(this._tileBuffer.activeTiles.values(),e=>e.tile),t=Array.from(this._tileBuffer.cachedTiles.values(),e=>e.tile),r=[...e,...t],i=this._visibleTilesManager.selection;return{cacheSize:this._tileBuffer.size,visibleTileCount:i.visibleTiles.length,currentTileCount:e.filter(e=>e.coord.z===i.currentZoom).length,fallbackTileCount:i.ancestorsMap.size,coreTileCount:i.visibleTiles.length,coverageTileCount:i.visibleTiles.length,readyTileCount:r.filter(e=>e.ready).length,loadingTileCount:r.filter(e=>e.loading).length,coolingDownTileCount:0,currentZoom:i.currentZoom,tileSelectionKey:i.key,isSettling:!1,coarseTileCount:i.ancestorsMap.size,hasPendingSelection:!1,pendingSelectionKey:null}}tileKey(e){return`${e.z}/${e.x}/${e.y}`}}t.XYZMap=d},1961:(e,t,r)=>{r.r(t),r.d(t,{glMatrix:()=>i,mat2:()=>s,mat2d:()=>a,mat3:()=>o,mat4:()=>n,quat:()=>c,quat2:()=>u,vec2:()=>d,vec3:()=>h,vec4:()=>l});var i={};r.r(i),r.d(i,{ANGLE_ORDER:()=>p,ARRAY_TYPE:()=>f,EPSILON:()=>_,RANDOM:()=>g,equals:()=>P,round:()=>m,setMatrixArrayType:()=>M,toDegree:()=>S,toRadian:()=>b});var s={};r.r(s),r.d(s,{LDU:()=>H,add:()=>G,adjoint:()=>I,clone:()=>T,copy:()=>w,create:()=>y,determinant:()=>D,equals:()=>X,exactEquals:()=>k,frob:()=>z,fromRotation:()=>V,fromScaling:()=>N,fromValues:()=>A,identity:()=>C,invert:()=>F,mul:()=>Z,multiply:()=>L,multiplyScalar:()=>q,multiplyScalarAndAdd:()=>j,rotate:()=>B,scale:()=>O,set:()=>E,str:()=>U,sub:()=>W,subtract:()=>Y,transpose:()=>R});var a={};r.r(a),r.d(a,{add:()=>_e,clone:()=>K,copy:()=>Q,create:()=>$,determinant:()=>ie,equals:()=>Me,exactEquals:()=>me,frob:()=>de,fromRotation:()=>he,fromScaling:()=>le,fromTranslation:()=>ce,fromValues:()=>ee,identity:()=>J,invert:()=>re,mul:()=>xe,multiply:()=>se,multiplyScalar:()=>ge,multiplyScalarAndAdd:()=>pe,rotate:()=>ae,scale:()=>oe,set:()=>te,str:()=>ue,sub:()=>ve,subtract:()=>fe,translate:()=>ne});var o={};r.r(o),r.d(o,{add:()=>Xe,adjoint:()=>Re,clone:()=>Pe,copy:()=>ye,create:()=>be,determinant:()=>Fe,equals:()=>$e,exactEquals:()=>We,frob:()=>ke,fromMat2d:()=>Ue,fromMat4:()=>Se,fromQuat:()=>ze,fromRotation:()=>Ve,fromScaling:()=>Ne,fromTranslation:()=>Oe,fromValues:()=>Te,identity:()=>Ce,invert:()=>Ee,mul:()=>Ke,multiply:()=>Ie,multiplyScalar:()=>je,multiplyScalarAndAdd:()=>Ze,normalFromMat4:()=>He,projection:()=>Ge,rotate:()=>Le,scale:()=>Be,set:()=>we,str:()=>Ye,sub:()=>Qe,subtract:()=>qe,translate:()=>De,transpose:()=>Ae});var n={};r.r(n),r.d(n,{add:()=>Yt,adjoint:()=>nt,clone:()=>et,copy:()=>tt,create:()=>Je,decompose:()=>Ct,determinant:()=>ht,equals:()=>Zt,exactEquals:()=>jt,frob:()=>Gt,fromQuat:()=>Rt,fromQuat2:()=>Pt,fromRotation:()=>Mt,fromRotationTranslation:()=>St,fromRotationTranslationScale:()=>At,fromRotationTranslationScaleOrigin:()=>Et,fromScaling:()=>mt,fromTranslation:()=>pt,fromValues:()=>rt,fromXRotation:()=>xt,fromYRotation:()=>vt,fromZRotation:()=>bt,frustum:()=>Ft,getRotation:()=>wt,getScaling:()=>Tt,getTranslation:()=>yt,identity:()=>st,invert:()=>ot,lookAt:()=>Ut,mul:()=>Wt,multiply:()=>lt,multiplyScalar:()=>Xt,multiplyScalarAndAdd:()=>qt,ortho:()=>Vt,orthoNO:()=>Ot,orthoZO:()=>Nt,perspective:()=>Dt,perspectiveFromFieldOfView:()=>Bt,perspectiveNO:()=>It,perspectiveZO:()=>Lt,rotate:()=>dt,rotateX:()=>_t,rotateY:()=>ft,rotateZ:()=>gt,scale:()=>ut,set:()=>it,str:()=>Ht,sub:()=>$t,subtract:()=>kt,targetTo:()=>zt,translate:()=>ct,transpose:()=>at});var h={};r.r(h),r.d(h,{add:()=>ir,angle:()=>Dr,bezier:()=>Tr,ceil:()=>nr,clone:()=>Qt,copy:()=>tr,create:()=>Kt,cross:()=>br,dist:()=>Gr,distance:()=>fr,div:()=>Hr,divide:()=>or,dot:()=>vr,equals:()=>Vr,exactEquals:()=>Or,floor:()=>hr,forEach:()=>qr,fromValues:()=>er,hermite:()=>yr,inverse:()=>Mr,len:()=>kr,length:()=>Jt,lerp:()=>Sr,max:()=>cr,min:()=>lr,mul:()=>zr,multiply:()=>ar,negate:()=>mr,normalize:()=>xr,random:()=>wr,rotateX:()=>Rr,rotateY:()=>Fr,rotateZ:()=>Ir,round:()=>ur,scale:()=>dr,scaleAndAdd:()=>_r,set:()=>rr,slerp:()=>Pr,sqrDist:()=>Yr,sqrLen:()=>Xr,squaredDistance:()=>gr,squaredLength:()=>pr,str:()=>Br,sub:()=>Ur,subtract:()=>sr,transformMat3:()=>Ar,transformMat4:()=>Cr,transformQuat:()=>Er,zero:()=>Lr});var l={};r.r(l),r.d(l,{add:()=>Qr,ceil:()=>ri,clone:()=>Zr,copy:()=>$r,create:()=>jr,cross:()=>mi,dist:()=>Ei,distance:()=>li,div:()=>Ai,divide:()=>ti,dot:()=>pi,equals:()=>Ti,exactEquals:()=>yi,floor:()=>ii,forEach:()=>Di,fromValues:()=>Wr,inverse:()=>fi,len:()=>Fi,length:()=>ui,lerp:()=>Mi,max:()=>ai,min:()=>si,mul:()=>Ci,multiply:()=>ei,negate:()=>_i,normalize:()=>gi,random:()=>xi,round:()=>oi,scale:()=>ni,scaleAndAdd:()=>hi,set:()=>Kr,sqrDist:()=>Ri,sqrLen:()=>Ii,squaredDistance:()=>ci,squaredLength:()=>di,str:()=>Pi,sub:()=>wi,subtract:()=>Jr,transformMat4:()=>vi,transformQuat:()=>bi,zero:()=>Si});var c={};r.r(c),r.d(c,{add:()=>ss,calculateW:()=>Yi,clone:()=>es,conjugate:()=>$i,copy:()=>rs,create:()=>Li,dot:()=>ns,equals:()=>gs,exactEquals:()=>fs,exp:()=>ki,fromEuler:()=>Qi,fromMat3:()=>Ki,fromValues:()=>ts,getAngle:()=>Ni,getAxisAngle:()=>Vi,identity:()=>Bi,invert:()=>Wi,len:()=>cs,length:()=>ls,lerp:()=>hs,ln:()=>Xi,mul:()=>as,multiply:()=>Ui,normalize:()=>_s,pow:()=>qi,random:()=>Zi,rotateX:()=>zi,rotateY:()=>Hi,rotateZ:()=>Gi,rotationTo:()=>Ss,scale:()=>os,set:()=>is,setAxes:()=>ys,setAxisAngle:()=>Oi,slerp:()=>ji,sqlerp:()=>Ps,sqrLen:()=>ds,squaredLength:()=>us,str:()=>Ji});var u={};r.r(u),r.d(u,{add:()=>Zs,clone:()=>ws,conjugate:()=>ta,copy:()=>Ds,create:()=>Ts,dot:()=>Qs,equals:()=>la,exactEquals:()=>ha,fromMat4:()=>Is,fromRotation:()=>Fs,fromRotationTranslation:()=>Es,fromRotationTranslationValues:()=>As,fromTranslation:()=>Rs,fromValues:()=>Cs,getDual:()=>Vs,getReal:()=>Os,getTranslation:()=>zs,identity:()=>Ls,invert:()=>ea,len:()=>ia,length:()=>ra,lerp:()=>Js,mul:()=>$s,multiply:()=>Ws,normalize:()=>oa,rotateAroundAxis:()=>js,rotateByQuatAppend:()=>Xs,rotateByQuatPrepend:()=>qs,rotateX:()=>Gs,rotateY:()=>Ys,rotateZ:()=>ks,scale:()=>Ks,set:()=>Bs,setDual:()=>Us,setReal:()=>Ns,sqrLen:()=>aa,squaredLength:()=>sa,str:()=>na,translate:()=>Hs});var d={};r.r(d),r.d(d,{add:()=>ga,angle:()=>Ga,ceil:()=>xa,clone:()=>ua,copy:()=>_a,create:()=>ca,cross:()=>La,dist:()=>Qa,distance:()=>wa,div:()=>Ka,divide:()=>Ma,dot:()=>Da,equals:()=>ja,exactEquals:()=>qa,floor:()=>va,forEach:()=>to,fromValues:()=>da,inverse:()=>Fa,len:()=>Za,length:()=>Aa,lerp:()=>Ba,max:()=>Sa,min:()=>ba,mul:()=>$a,multiply:()=>ma,negate:()=>Ra,normalize:()=>Ia,random:()=>Oa,rotate:()=>Ha,round:()=>Pa,scale:()=>ya,scaleAndAdd:()=>Ta,set:()=>fa,signedAngle:()=>Ya,sqrDist:()=>Ja,sqrLen:()=>eo,squaredDistance:()=>Ca,squaredLength:()=>Ea,str:()=>Xa,sub:()=>Wa,subtract:()=>pa,transformMat2:()=>Va,transformMat2d:()=>Na,transformMat3:()=>Ua,transformMat4:()=>za,zero:()=>ka});var _=1e-6,f="undefined"!=typeof Float32Array?Float32Array:Array,g=Math.random,p="zyx";function m(e){return e>=0?Math.round(e):e%.5==0?Math.floor(e):Math.round(e)}function M(e){f=e}var x=Math.PI/180,v=180/Math.PI;function b(e){return e*x}function S(e){return e*v}function P(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_;return Math.abs(e-t)<=r*Math.max(1,Math.abs(e),Math.abs(t))}function y(){var e=new f(4);return f!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function T(e){var t=new f(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function w(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function C(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function A(e,t,r,i){var s=new f(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s}function E(e,t,r,i,s){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e}function R(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e}function F(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r*a-s*i;return o?(o=1/o,e[0]=a*o,e[1]=-i*o,e[2]=-s*o,e[3]=r*o,e):null}function I(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e}function D(e){return e[0]*e[3]-e[2]*e[1]}function L(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*n+a*h,e[1]=s*n+o*h,e[2]=i*l+a*c,e[3]=s*l+o*c,e}function B(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h+a*n,e[1]=s*h+o*n,e[2]=i*-n+a*h,e[3]=s*-n+o*h,e}function O(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1];return e[0]=i*n,e[1]=s*n,e[2]=a*h,e[3]=o*h,e}function V(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e}function N(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e}function U(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function z(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3])}function H(e,t,r,i){return e[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-e[2]*r[1],[e,t,r]}function G(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Y(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function k(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function X(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=t[0],n=t[1],h=t[2],l=t[3];return Math.abs(r-o)<=_*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=_*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-l)<=_*Math.max(1,Math.abs(a),Math.abs(l))}function q(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function j(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e}var Z=L,W=Y;function $(){var e=new f(6);return f!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e}function K(e){var t=new f(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function Q(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function J(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function ee(e,t,r,i,s,a){var o=new f(6);return o[0]=e,o[1]=t,o[2]=r,o[3]=i,o[4]=s,o[5]=a,o}function te(e,t,r,i,s,a,o){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e}function re(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=r*a-i*s;return h?(h=1/h,e[0]=a*h,e[1]=-i*h,e[2]=-s*h,e[3]=r*h,e[4]=(s*n-a*o)*h,e[5]=(i*o-r*n)*h,e):null}function ie(e){return e[0]*e[3]-e[1]*e[2]}function se(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=r[0],c=r[1],u=r[2],d=r[3],_=r[4],f=r[5];return e[0]=i*l+a*c,e[1]=s*l+o*c,e[2]=i*u+a*d,e[3]=s*u+o*d,e[4]=i*_+a*f+n,e[5]=s*_+o*f+h,e}function ae(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=Math.sin(r),c=Math.cos(r);return e[0]=i*c+a*l,e[1]=s*c+o*l,e[2]=i*-l+a*c,e[3]=s*-l+o*c,e[4]=n,e[5]=h,e}function oe(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=r[0],c=r[1];return e[0]=i*l,e[1]=s*l,e[2]=a*c,e[3]=o*c,e[4]=n,e[5]=h,e}function ne(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=r[0],c=r[1];return e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=i*l+a*c+n,e[5]=s*l+o*c+h,e}function he(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e[4]=0,e[5]=0,e}function le(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e}function ce(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e}function ue(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"}function de(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+1)}function _e(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e}function fe(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e}function ge(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e}function pe(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e}function me(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]}function Me(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=t[0],l=t[1],c=t[2],u=t[3],d=t[4],f=t[5];return Math.abs(r-h)<=_*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(i-l)<=_*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(s-c)<=_*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-u)<=_*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-d)<=_*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(n-f)<=_*Math.max(1,Math.abs(n),Math.abs(f))}var xe=se,ve=fe;function be(){var e=new f(9);return f!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Se(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function Pe(e){var t=new f(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ye(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Te(e,t,r,i,s,a,o,n,h){var l=new f(9);return l[0]=e,l[1]=t,l[2]=r,l[3]=i,l[4]=s,l[5]=a,l[6]=o,l[7]=n,l[8]=h,l}function we(e,t,r,i,s,a,o,n,h,l){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e[8]=l,e}function Ce(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ae(e,t){if(e===t){var r=t[1],i=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function Ee(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=c*o-n*l,d=-c*a+n*h,_=l*a-o*h,f=r*u+i*d+s*_;return f?(f=1/f,e[0]=u*f,e[1]=(-c*i+s*l)*f,e[2]=(n*i-s*o)*f,e[3]=d*f,e[4]=(c*r-s*h)*f,e[5]=(-n*r+s*a)*f,e[6]=_*f,e[7]=(-l*r+i*h)*f,e[8]=(o*r-i*a)*f,e):null}function Re(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8];return e[0]=o*c-n*l,e[1]=s*l-i*c,e[2]=i*n-s*o,e[3]=n*h-a*c,e[4]=r*c-s*h,e[5]=s*a-r*n,e[6]=a*l-o*h,e[7]=i*h-r*l,e[8]=r*o-i*a,e}function Fe(e){var t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],n=e[6],h=e[7],l=e[8];return t*(l*a-o*h)+r*(-l*s+o*n)+i*(h*s-a*n)}function Ie(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=r[0],_=r[1],f=r[2],g=r[3],p=r[4],m=r[5],M=r[6],x=r[7],v=r[8];return e[0]=d*i+_*o+f*l,e[1]=d*s+_*n+f*c,e[2]=d*a+_*h+f*u,e[3]=g*i+p*o+m*l,e[4]=g*s+p*n+m*c,e[5]=g*a+p*h+m*u,e[6]=M*i+x*o+v*l,e[7]=M*s+x*n+v*c,e[8]=M*a+x*h+v*u,e}function De(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=r[0],_=r[1];return e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=n,e[5]=h,e[6]=d*i+_*o+l,e[7]=d*s+_*n+c,e[8]=d*a+_*h+u,e}function Le(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=Math.sin(r),_=Math.cos(r);return e[0]=_*i+d*o,e[1]=_*s+d*n,e[2]=_*a+d*h,e[3]=_*o-d*i,e[4]=_*n-d*s,e[5]=_*h-d*a,e[6]=l,e[7]=c,e[8]=u,e}function Be(e,t,r){var i=r[0],s=r[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Oe(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e}function Ve(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ne(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Ue(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e}function ze(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r+r,n=i+i,h=s+s,l=r*o,c=i*o,u=i*n,d=s*o,_=s*n,f=s*h,g=a*o,p=a*n,m=a*h;return e[0]=1-u-f,e[3]=c-m,e[6]=d+p,e[1]=c+m,e[4]=1-l-f,e[7]=_-g,e[2]=d-p,e[5]=_+g,e[8]=1-l-u,e}function He(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],M=r*n-i*o,x=r*h-s*o,v=r*l-a*o,b=i*h-s*n,S=i*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p,R=M*E-x*A+v*C+b*w-S*T+P*y;return R?(R=1/R,e[0]=(n*E-h*A+l*C)*R,e[1]=(h*w-o*E-l*T)*R,e[2]=(o*A-n*w+l*y)*R,e[3]=(s*A-i*E-a*C)*R,e[4]=(r*E-s*w+a*T)*R,e[5]=(i*w-r*A-a*y)*R,e[6]=(g*P-p*S+m*b)*R,e[7]=(p*v-f*P-m*x)*R,e[8]=(f*S-g*v+m*M)*R,e):null}function Ge(e,t,r){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/r,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}function Ye(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"}function ke(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8])}function Xe(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e}function qe(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e}function je(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e}function Ze(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e}function We(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]}function $e(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=e[8],u=t[0],d=t[1],f=t[2],g=t[3],p=t[4],m=t[5],M=t[6],x=t[7],v=t[8];return Math.abs(r-u)<=_*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-d)<=_*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(s-f)<=_*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-g)<=_*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(o-p)<=_*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(n-m)<=_*Math.max(1,Math.abs(n),Math.abs(m))&&Math.abs(h-M)<=_*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(l-x)<=_*Math.max(1,Math.abs(l),Math.abs(x))&&Math.abs(c-v)<=_*Math.max(1,Math.abs(c),Math.abs(v))}var Ke=Ie,Qe=qe;function Je(){var e=new f(16);return f!=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 et(e){var t=new f(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function tt(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function rt(e,t,r,i,s,a,o,n,h,l,c,u,d,_,g,p){var m=new f(16);return m[0]=e,m[1]=t,m[2]=r,m[3]=i,m[4]=s,m[5]=a,m[6]=o,m[7]=n,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=g,m[15]=p,m}function it(e,t,r,i,s,a,o,n,h,l,c,u,d,_,f,g,p){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e[8]=l,e[9]=c,e[10]=u,e[11]=d,e[12]=_,e[13]=f,e[14]=g,e[15]=p,e}function st(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 at(e,t){if(e===t){var r=t[1],i=t[2],s=t[3],a=t[6],o=t[7],n=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=a,e[11]=t[14],e[12]=s,e[13]=o,e[14]=n}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function ot(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],M=r*n-i*o,x=r*h-s*o,v=r*l-a*o,b=i*h-s*n,S=i*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p,R=M*E-x*A+v*C+b*w-S*T+P*y;return R?(R=1/R,e[0]=(n*E-h*A+l*C)*R,e[1]=(s*A-i*E-a*C)*R,e[2]=(g*P-p*S+m*b)*R,e[3]=(d*S-u*P-_*b)*R,e[4]=(h*w-o*E-l*T)*R,e[5]=(r*E-s*w+a*T)*R,e[6]=(p*v-f*P-m*x)*R,e[7]=(c*P-d*v+_*x)*R,e[8]=(o*A-n*w+l*y)*R,e[9]=(i*w-r*A-a*y)*R,e[10]=(f*S-g*v+m*M)*R,e[11]=(u*v-c*S-_*M)*R,e[12]=(n*T-o*C-h*y)*R,e[13]=(r*C-i*T+s*y)*R,e[14]=(g*x-f*b-p*M)*R,e[15]=(c*b-u*x+d*M)*R,e):null}function nt(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=t[4],n=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],g=t[13],p=t[14],m=t[15],M=r*n-i*o,x=r*h-s*o,v=r*l-a*o,b=i*h-s*n,S=i*l-a*n,P=s*l-a*h,y=c*g-u*f,T=c*p-d*f,w=c*m-_*f,C=u*p-d*g,A=u*m-_*g,E=d*m-_*p;return e[0]=n*E-h*A+l*C,e[1]=s*A-i*E-a*C,e[2]=g*P-p*S+m*b,e[3]=d*S-u*P-_*b,e[4]=h*w-o*E-l*T,e[5]=r*E-s*w+a*T,e[6]=p*v-f*P-m*x,e[7]=c*P-d*v+_*x,e[8]=o*A-n*w+l*y,e[9]=i*w-r*A-a*y,e[10]=f*S-g*v+m*M,e[11]=u*v-c*S-_*M,e[12]=n*T-o*C-h*y,e[13]=r*C-i*T+s*y,e[14]=g*x-f*b-p*M,e[15]=c*b-u*x+d*M,e}function ht(e){var t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],n=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],_=e[12],f=e[13],g=e[14],p=t*o-r*a,m=t*n-i*a,M=r*n-i*o,x=l*f-c*_,v=l*g-u*_,b=c*g-u*f;return h*(t*b-r*v+i*x)-s*(a*b-o*v+n*x)+e[15]*(l*M-c*m+u*p)-d*(_*M-f*m+g*p)}function lt(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],f=t[11],g=t[12],p=t[13],m=t[14],M=t[15],x=r[0],v=r[1],b=r[2],S=r[3];return e[0]=x*i+v*n+b*u+S*g,e[1]=x*s+v*h+b*d+S*p,e[2]=x*a+v*l+b*_+S*m,e[3]=x*o+v*c+b*f+S*M,x=r[4],v=r[5],b=r[6],S=r[7],e[4]=x*i+v*n+b*u+S*g,e[5]=x*s+v*h+b*d+S*p,e[6]=x*a+v*l+b*_+S*m,e[7]=x*o+v*c+b*f+S*M,x=r[8],v=r[9],b=r[10],S=r[11],e[8]=x*i+v*n+b*u+S*g,e[9]=x*s+v*h+b*d+S*p,e[10]=x*a+v*l+b*_+S*m,e[11]=x*o+v*c+b*f+S*M,x=r[12],v=r[13],b=r[14],S=r[15],e[12]=x*i+v*n+b*u+S*g,e[13]=x*s+v*h+b*d+S*p,e[14]=x*a+v*l+b*_+S*m,e[15]=x*o+v*c+b*f+S*M,e}function ct(e,t,r){var i,s,a,o,n,h,l,c,u,d,_,f,g=r[0],p=r[1],m=r[2];return t===e?(e[12]=t[0]*g+t[4]*p+t[8]*m+t[12],e[13]=t[1]*g+t[5]*p+t[9]*m+t[13],e[14]=t[2]*g+t[6]*p+t[10]*m+t[14],e[15]=t[3]*g+t[7]*p+t[11]*m+t[15]):(i=t[0],s=t[1],a=t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=t[8],d=t[9],_=t[10],f=t[11],e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=n,e[5]=h,e[6]=l,e[7]=c,e[8]=u,e[9]=d,e[10]=_,e[11]=f,e[12]=i*g+n*p+u*m+t[12],e[13]=s*g+h*p+d*m+t[13],e[14]=a*g+l*p+_*m+t[14],e[15]=o*g+c*p+f*m+t[15]),e}function ut(e,t,r){var i=r[0],s=r[1],a=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function dt(e,t,r,i){var s,a,o,n,h,l,c,u,d,f,g,p,m,M,x,v,b,S,P,y,T,w,C,A,E=i[0],R=i[1],F=i[2],I=Math.sqrt(E*E+R*R+F*F);return I<_?null:(E*=I=1/I,R*=I,F*=I,s=Math.sin(r),o=1-(a=Math.cos(r)),n=t[0],h=t[1],l=t[2],c=t[3],u=t[4],d=t[5],f=t[6],g=t[7],p=t[8],m=t[9],M=t[10],x=t[11],v=E*E*o+a,b=R*E*o+F*s,S=F*E*o-R*s,P=E*R*o-F*s,y=R*R*o+a,T=F*R*o+E*s,w=E*F*o+R*s,C=R*F*o-E*s,A=F*F*o+a,e[0]=n*v+u*b+p*S,e[1]=h*v+d*b+m*S,e[2]=l*v+f*b+M*S,e[3]=c*v+g*b+x*S,e[4]=n*P+u*y+p*T,e[5]=h*P+d*y+m*T,e[6]=l*P+f*y+M*T,e[7]=c*P+g*y+x*T,e[8]=n*w+u*C+p*A,e[9]=h*w+d*C+m*A,e[10]=l*w+f*C+M*A,e[11]=c*w+g*C+x*A,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function _t(e,t,r){var i=Math.sin(r),s=Math.cos(r),a=t[4],o=t[5],n=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*s+l*i,e[5]=o*s+c*i,e[6]=n*s+u*i,e[7]=h*s+d*i,e[8]=l*s-a*i,e[9]=c*s-o*i,e[10]=u*s-n*i,e[11]=d*s-h*i,e}function ft(e,t,r){var i=Math.sin(r),s=Math.cos(r),a=t[0],o=t[1],n=t[2],h=t[3],l=t[8],c=t[9],u=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*s-l*i,e[1]=o*s-c*i,e[2]=n*s-u*i,e[3]=h*s-d*i,e[8]=a*i+l*s,e[9]=o*i+c*s,e[10]=n*i+u*s,e[11]=h*i+d*s,e}function gt(e,t,r){var i=Math.sin(r),s=Math.cos(r),a=t[0],o=t[1],n=t[2],h=t[3],l=t[4],c=t[5],u=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*s+l*i,e[1]=o*s+c*i,e[2]=n*s+u*i,e[3]=h*s+d*i,e[4]=l*s-a*i,e[5]=c*s-o*i,e[6]=u*s-n*i,e[7]=d*s-h*i,e}function pt(e,t){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]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function mt(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Mt(e,t,r){var i,s,a,o=r[0],n=r[1],h=r[2],l=Math.sqrt(o*o+n*n+h*h);return l<_?null:(o*=l=1/l,n*=l,h*=l,i=Math.sin(t),a=1-(s=Math.cos(t)),e[0]=o*o*a+s,e[1]=n*o*a+h*i,e[2]=h*o*a-n*i,e[3]=0,e[4]=o*n*a-h*i,e[5]=n*n*a+s,e[6]=h*n*a+o*i,e[7]=0,e[8]=o*h*a+n*i,e[9]=n*h*a-o*i,e[10]=h*h*a+s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function xt(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function vt(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function bt(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=i,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 St(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=i+i,h=s+s,l=a+a,c=i*n,u=i*h,d=i*l,_=s*h,f=s*l,g=a*l,p=o*n,m=o*h,M=o*l;return e[0]=1-(_+g),e[1]=u+M,e[2]=d-m,e[3]=0,e[4]=u-M,e[5]=1-(c+g),e[6]=f+p,e[7]=0,e[8]=d+m,e[9]=f-p,e[10]=1-(c+_),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Pt(e,t){var r=new f(3),i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=i*i+s*s+a*a+o*o;return u>0?(r[0]=2*(n*o+c*i+h*a-l*s)/u,r[1]=2*(h*o+c*s+l*i-n*a)/u,r[2]=2*(l*o+c*a+n*s-h*i)/u):(r[0]=2*(n*o+c*i+h*a-l*s),r[1]=2*(h*o+c*s+l*i-n*a),r[2]=2*(l*o+c*a+n*s-h*i)),St(e,t,r),e}function yt(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Tt(e,t){var r=t[0],i=t[1],s=t[2],a=t[4],o=t[5],n=t[6],h=t[8],l=t[9],c=t[10];return e[0]=Math.sqrt(r*r+i*i+s*s),e[1]=Math.sqrt(a*a+o*o+n*n),e[2]=Math.sqrt(h*h+l*l+c*c),e}function wt(e,t){var r=new f(3);Tt(r,t);var i=1/r[0],s=1/r[1],a=1/r[2],o=t[0]*i,n=t[1]*s,h=t[2]*a,l=t[4]*i,c=t[5]*s,u=t[6]*a,d=t[8]*i,_=t[9]*s,g=t[10]*a,p=o+c+g,m=0;return p>0?(m=2*Math.sqrt(p+1),e[3]=.25*m,e[0]=(u-_)/m,e[1]=(d-h)/m,e[2]=(n-l)/m):o>c&&o>g?(m=2*Math.sqrt(1+o-c-g),e[3]=(u-_)/m,e[0]=.25*m,e[1]=(n+l)/m,e[2]=(d+h)/m):c>g?(m=2*Math.sqrt(1+c-o-g),e[3]=(d-h)/m,e[0]=(n+l)/m,e[1]=.25*m,e[2]=(u+_)/m):(m=2*Math.sqrt(1+g-o-c),e[3]=(n-l)/m,e[0]=(d+h)/m,e[1]=(u+_)/m,e[2]=.25*m),e}function Ct(e,t,r,i){t[0]=i[12],t[1]=i[13],t[2]=i[14];var s=i[0],a=i[1],o=i[2],n=i[4],h=i[5],l=i[6],c=i[8],u=i[9],d=i[10];r[0]=Math.sqrt(s*s+a*a+o*o),r[1]=Math.sqrt(n*n+h*h+l*l),r[2]=Math.sqrt(c*c+u*u+d*d);var _=1/r[0],f=1/r[1],g=1/r[2],p=s*_,m=a*f,M=o*g,x=n*_,v=h*f,b=l*g,S=c*_,P=u*f,y=d*g,T=p+v+y,w=0;return T>0?(w=2*Math.sqrt(T+1),e[3]=.25*w,e[0]=(b-P)/w,e[1]=(S-M)/w,e[2]=(m-x)/w):p>v&&p>y?(w=2*Math.sqrt(1+p-v-y),e[3]=(b-P)/w,e[0]=.25*w,e[1]=(m+x)/w,e[2]=(S+M)/w):v>y?(w=2*Math.sqrt(1+v-p-y),e[3]=(S-M)/w,e[0]=(m+x)/w,e[1]=.25*w,e[2]=(b+P)/w):(w=2*Math.sqrt(1+y-p-v),e[3]=(m-x)/w,e[0]=(S+M)/w,e[1]=(b+P)/w,e[2]=.25*w),e}function At(e,t,r,i){var s=t[0],a=t[1],o=t[2],n=t[3],h=s+s,l=a+a,c=o+o,u=s*h,d=s*l,_=s*c,f=a*l,g=a*c,p=o*c,m=n*h,M=n*l,x=n*c,v=i[0],b=i[1],S=i[2];return e[0]=(1-(f+p))*v,e[1]=(d+x)*v,e[2]=(_-M)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(u+p))*b,e[6]=(g+m)*b,e[7]=0,e[8]=(_+M)*S,e[9]=(g-m)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Et(e,t,r,i,s){var a=t[0],o=t[1],n=t[2],h=t[3],l=a+a,c=o+o,u=n+n,d=a*l,_=a*c,f=a*u,g=o*c,p=o*u,m=n*u,M=h*l,x=h*c,v=h*u,b=i[0],S=i[1],P=i[2],y=s[0],T=s[1],w=s[2],C=(1-(g+m))*b,A=(_+v)*b,E=(f-x)*b,R=(_-v)*S,F=(1-(d+m))*S,I=(p+M)*S,D=(f+x)*P,L=(p-M)*P,B=(1-(d+g))*P;return e[0]=C,e[1]=A,e[2]=E,e[3]=0,e[4]=R,e[5]=F,e[6]=I,e[7]=0,e[8]=D,e[9]=L,e[10]=B,e[11]=0,e[12]=r[0]+y-(C*y+R*T+D*w),e[13]=r[1]+T-(A*y+F*T+L*w),e[14]=r[2]+w-(E*y+I*T+B*w),e[15]=1,e}function Rt(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r+r,n=i+i,h=s+s,l=r*o,c=i*o,u=i*n,d=s*o,_=s*n,f=s*h,g=a*o,p=a*n,m=a*h;return e[0]=1-u-f,e[1]=c+m,e[2]=d-p,e[3]=0,e[4]=c-m,e[5]=1-l-f,e[6]=_+g,e[7]=0,e[8]=d+p,e[9]=_-g,e[10]=1-l-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ft(e,t,r,i,s,a,o){var n=1/(r-t),h=1/(s-i),l=1/(a-o);return e[0]=2*a*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*h,e[6]=0,e[7]=0,e[8]=(r+t)*n,e[9]=(s+i)*h,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e}function It(e,t,r,i,s){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var o=1/(i-s);e[10]=(s+i)*o,e[14]=2*s*i*o}else e[10]=-1,e[14]=-2*i;return e}var Dt=It;function Lt(e,t,r,i,s){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var o=1/(i-s);e[10]=s*o,e[14]=s*i*o}else e[10]=-1,e[14]=-i;return e}function Bt(e,t,r,i){var s=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),n=Math.tan(t.rightDegrees*Math.PI/180),h=2/(o+n),l=2/(s+a);return e[0]=h,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-n)*h*.5,e[9]=(s-a)*l*.5,e[10]=i/(r-i),e[11]=-1,e[12]=0,e[13]=0,e[14]=i*r/(r-i),e[15]=0,e}function Ot(e,t,r,i,s,a,o){var n=1/(t-r),h=1/(i-s),l=1/(a-o);return e[0]=-2*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*n,e[13]=(s+i)*h,e[14]=(o+a)*l,e[15]=1,e}var Vt=Ot;function Nt(e,t,r,i,s,a,o){var n=1/(t-r),h=1/(i-s),l=1/(a-o);return e[0]=-2*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*n,e[13]=(s+i)*h,e[14]=a*l,e[15]=1,e}function Ut(e,t,r,i){var s,a,o,n,h,l,c,u,d,f,g=t[0],p=t[1],m=t[2],M=i[0],x=i[1],v=i[2],b=r[0],S=r[1],P=r[2];return Math.abs(g-b)<_&&Math.abs(p-S)<_&&Math.abs(m-P)<_?st(e):(c=g-b,u=p-S,d=m-P,s=x*(d*=f=1/Math.sqrt(c*c+u*u+d*d))-v*(u*=f),a=v*(c*=f)-M*d,o=M*u-x*c,(f=Math.sqrt(s*s+a*a+o*o))?(s*=f=1/f,a*=f,o*=f):(s=0,a=0,o=0),n=u*o-d*a,h=d*s-c*o,l=c*a-u*s,(f=Math.sqrt(n*n+h*h+l*l))?(n*=f=1/f,h*=f,l*=f):(n=0,h=0,l=0),e[0]=s,e[1]=n,e[2]=c,e[3]=0,e[4]=a,e[5]=h,e[6]=u,e[7]=0,e[8]=o,e[9]=l,e[10]=d,e[11]=0,e[12]=-(s*g+a*p+o*m),e[13]=-(n*g+h*p+l*m),e[14]=-(c*g+u*p+d*m),e[15]=1,e)}function zt(e,t,r,i){var s=t[0],a=t[1],o=t[2],n=i[0],h=i[1],l=i[2],c=s-r[0],u=a-r[1],d=o-r[2],_=c*c+u*u+d*d;_>0&&(c*=_=1/Math.sqrt(_),u*=_,d*=_);var f=h*d-l*u,g=l*c-n*d,p=n*u-h*c;return(_=f*f+g*g+p*p)>0&&(f*=_=1/Math.sqrt(_),g*=_,p*=_),e[0]=f,e[1]=g,e[2]=p,e[3]=0,e[4]=u*p-d*g,e[5]=d*f-c*p,e[6]=c*g-u*f,e[7]=0,e[8]=c,e[9]=u,e[10]=d,e[11]=0,e[12]=s,e[13]=a,e[14]=o,e[15]=1,e}function Ht(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function Gt(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function Yt(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function kt(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function Xt(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function qt(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e[9]=t[9]+r[9]*i,e[10]=t[10]+r[10]*i,e[11]=t[11]+r[11]*i,e[12]=t[12]+r[12]*i,e[13]=t[13]+r[13]*i,e[14]=t[14]+r[14]*i,e[15]=t[15]+r[15]*i,e}function jt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function Zt(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],g=e[12],p=e[13],m=e[14],M=e[15],x=t[0],v=t[1],b=t[2],S=t[3],P=t[4],y=t[5],T=t[6],w=t[7],C=t[8],A=t[9],E=t[10],R=t[11],F=t[12],I=t[13],D=t[14],L=t[15];return Math.abs(r-x)<=_*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(i-v)<=_*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(s-b)<=_*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(a-S)<=_*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-P)<=_*Math.max(1,Math.abs(o),Math.abs(P))&&Math.abs(n-y)<=_*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(h-T)<=_*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(l-w)<=_*Math.max(1,Math.abs(l),Math.abs(w))&&Math.abs(c-C)<=_*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-A)<=_*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(d-E)<=_*Math.max(1,Math.abs(d),Math.abs(E))&&Math.abs(f-R)<=_*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(g-F)<=_*Math.max(1,Math.abs(g),Math.abs(F))&&Math.abs(p-I)<=_*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(m-D)<=_*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(M-L)<=_*Math.max(1,Math.abs(M),Math.abs(L))}var Wt=lt,$t=kt;function Kt(){var e=new f(3);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Qt(e){var t=new f(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Jt(e){var t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)}function er(e,t,r){var i=new f(3);return i[0]=e,i[1]=t,i[2]=r,i}function tr(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function rr(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e}function ir(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function sr(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function ar(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function or(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function nr(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function hr(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function lr(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function cr(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function ur(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e[2]=m(t[2]),e}function dr(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function _r(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function fr(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(r*r+i*i+s*s)}function gr(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return r*r+i*i+s*s}function pr(e){var t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i}function mr(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Mr(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function xr(e,t){var r=t[0],i=t[1],s=t[2],a=r*r+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function vr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function br(e,t,r){var i=t[0],s=t[1],a=t[2],o=r[0],n=r[1],h=r[2];return e[0]=s*h-a*n,e[1]=a*o-i*h,e[2]=i*n-s*o,e}function Sr(e,t,r,i){var s=t[0],a=t[1],o=t[2];return e[0]=s+i*(r[0]-s),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e}function Pr(e,t,r,i){var s=Math.acos(Math.min(Math.max(vr(t,r),-1),1)),a=Math.sin(s),o=Math.sin((1-i)*s)/a,n=Math.sin(i*s)/a;return e[0]=o*t[0]+n*r[0],e[1]=o*t[1]+n*r[1],e[2]=o*t[2]+n*r[2],e}function yr(e,t,r,i,s,a){var o=a*a,n=o*(2*a-3)+1,h=o*(a-2)+a,l=o*(a-1),c=o*(3-2*a);return e[0]=t[0]*n+r[0]*h+i[0]*l+s[0]*c,e[1]=t[1]*n+r[1]*h+i[1]*l+s[1]*c,e[2]=t[2]*n+r[2]*h+i[2]*l+s[2]*c,e}function Tr(e,t,r,i,s,a){var o=1-a,n=o*o,h=a*a,l=n*o,c=3*a*n,u=3*h*o,d=h*a;return e[0]=t[0]*l+r[0]*c+i[0]*u+s[0]*d,e[1]=t[1]*l+r[1]*c+i[1]*u+s[1]*d,e[2]=t[2]*l+r[2]*c+i[2]*u+s[2]*d,e}function wr(e,t){t=void 0===t?1:t;var r=2*g()*Math.PI,i=2*g()-1,s=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(r)*s,e[1]=Math.sin(r)*s,e[2]=i*t,e}function Cr(e,t,r){var i=t[0],s=t[1],a=t[2],o=r[3]*i+r[7]*s+r[11]*a+r[15];return o=o||1,e[0]=(r[0]*i+r[4]*s+r[8]*a+r[12])/o,e[1]=(r[1]*i+r[5]*s+r[9]*a+r[13])/o,e[2]=(r[2]*i+r[6]*s+r[10]*a+r[14])/o,e}function Ar(e,t,r){var i=t[0],s=t[1],a=t[2];return e[0]=i*r[0]+s*r[3]+a*r[6],e[1]=i*r[1]+s*r[4]+a*r[7],e[2]=i*r[2]+s*r[5]+a*r[8],e}function Er(e,t,r){var i=r[0],s=r[1],a=r[2],o=r[3],n=t[0],h=t[1],l=t[2],c=s*l-a*h,u=a*n-i*l,d=i*h-s*n;return c+=c,u+=u,d+=d,e[0]=n+o*c+s*d-a*u,e[1]=h+o*u+a*c-i*d,e[2]=l+o*d+i*u-s*c,e}function Rr(e,t,r,i){var s=[],a=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],a[0]=s[0],a[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),a[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e}function Fr(e,t,r,i){var s=[],a=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],a[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),a[1]=s[1],a[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e}function Ir(e,t,r,i){var s=[],a=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],a[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),a[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),a[2]=s[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e}function Dr(e,t){var r=e[0],i=e[1],s=e[2],a=t[0],o=t[1],n=t[2],h=Math.sqrt((r*r+i*i+s*s)*(a*a+o*o+n*n)),l=h&&vr(e,t)/h;return Math.acos(Math.min(Math.max(l,-1),1))}function Lr(e){return e[0]=0,e[1]=0,e[2]=0,e}function Br(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Or(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Vr(e,t){var r=e[0],i=e[1],s=e[2],a=t[0],o=t[1],n=t[2];return Math.abs(r-a)<=_*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=_*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-n)<=_*Math.max(1,Math.abs(s),Math.abs(n))}var Nr,Ur=sr,zr=ar,Hr=or,Gr=fr,Yr=gr,kr=Jt,Xr=pr,qr=(Nr=Kt(),function(e,t,r,i,s,a){var o,n;for(t||(t=3),r||(r=0),n=i?Math.min(i*t+r,e.length):e.length,o=r;o<n;o+=t)Nr[0]=e[o],Nr[1]=e[o+1],Nr[2]=e[o+2],s(Nr,Nr,a),e[o]=Nr[0],e[o+1]=Nr[1],e[o+2]=Nr[2];return e});function jr(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Zr(e){var t=new f(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Wr(e,t,r,i){var s=new f(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s}function $r(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Kr(e,t,r,i,s){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e}function Qr(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Jr(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function ei(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function ti(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function ri(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function ii(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function si(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function ai(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function oi(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e[2]=m(t[2]),e[3]=m(t[3]),e}function ni(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function hi(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e}function li(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(r*r+i*i+s*s+a*a)}function ci(e,t){var r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2],a=t[3]-e[3];return r*r+i*i+s*s+a*a}function ui(e){var t=e[0],r=e[1],i=e[2],s=e[3];return Math.sqrt(t*t+r*r+i*i+s*s)}function di(e){var t=e[0],r=e[1],i=e[2],s=e[3];return t*t+r*r+i*i+s*s}function _i(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function fi(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function gi(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r*r+i*i+s*s+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=i*o,e[2]=s*o,e[3]=a*o,e}function pi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function mi(e,t,r,i){var s=r[0]*i[1]-r[1]*i[0],a=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],n=r[1]*i[2]-r[2]*i[1],h=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],c=t[0],u=t[1],d=t[2],_=t[3];return e[0]=u*l-d*h+_*n,e[1]=-c*l+d*o-_*a,e[2]=c*h-u*o+_*s,e[3]=-c*n+u*a-d*s,e}function Mi(e,t,r,i){var s=t[0],a=t[1],o=t[2],n=t[3];return e[0]=s+i*(r[0]-s),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e[3]=n+i*(r[3]-n),e}function xi(e,t){var r,i,s,a,o,n,h;t=void 0===t?1:t,o=(r=2*(h=g())-1)*r+(i=(4*g()-2)*Math.sqrt(h*-h+h))*i,n=(s=2*(h=g())-1)*s+(a=(4*g()-2)*Math.sqrt(h*-h+h))*a;var l=Math.sqrt((1-o)/n);return e[0]=t*r,e[1]=t*i,e[2]=t*s*l,e[3]=t*a*l,e}function vi(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3];return e[0]=r[0]*i+r[4]*s+r[8]*a+r[12]*o,e[1]=r[1]*i+r[5]*s+r[9]*a+r[13]*o,e[2]=r[2]*i+r[6]*s+r[10]*a+r[14]*o,e[3]=r[3]*i+r[7]*s+r[11]*a+r[15]*o,e}function bi(e,t,r){var i=r[0],s=r[1],a=r[2],o=r[3],n=t[0],h=t[1],l=t[2],c=s*l-a*h,u=a*n-i*l,d=i*h-s*n;return c+=c,u+=u,d+=d,e[0]=n+o*c+s*d-a*u,e[1]=h+o*u+a*c-i*d,e[2]=l+o*d+i*u-s*c,e[3]=t[3],e}function Si(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function Pi(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function yi(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function Ti(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=t[0],n=t[1],h=t[2],l=t[3];return Math.abs(r-o)<=_*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=_*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-l)<=_*Math.max(1,Math.abs(a),Math.abs(l))}var wi=Jr,Ci=ei,Ai=ti,Ei=li,Ri=ci,Fi=ui,Ii=di,Di=function(){var e=jr();return function(t,r,i,s,a,o){var n,h;for(r||(r=4),i||(i=0),h=s?Math.min(s*r+i,t.length):t.length,n=i;n<h;n+=r)e[0]=t[n],e[1]=t[n+1],e[2]=t[n+2],e[3]=t[n+3],a(e,e,o),t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3];return t}}();function Li(){var e=new f(4);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Bi(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Oi(e,t,r){r*=.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function Vi(e,t){var r=2*Math.acos(t[3]),i=Math.sin(r/2);return i>_?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),r}function Ni(e,t){var r=ns(e,t);return Math.acos(2*r*r-1)}function Ui(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*c+o*n+s*l-a*h,e[1]=s*c+o*h+a*n-i*l,e[2]=a*c+o*l+i*h-s*n,e[3]=o*c-i*n-s*h-a*l,e}function zi(e,t,r){r*=.5;var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h+o*n,e[1]=s*h+a*n,e[2]=a*h-s*n,e[3]=o*h-i*n,e}function Hi(e,t,r){r*=.5;var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h-a*n,e[1]=s*h+o*n,e[2]=a*h+i*n,e[3]=o*h-s*n,e}function Gi(e,t,r){r*=.5;var i=t[0],s=t[1],a=t[2],o=t[3],n=Math.sin(r),h=Math.cos(r);return e[0]=i*h+s*n,e[1]=s*h-i*n,e[2]=a*h+o*n,e[3]=o*h-a*n,e}function Yi(e,t){var r=t[0],i=t[1],s=t[2];return e[0]=r,e[1]=i,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-i*i-s*s)),e}function ki(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=Math.sqrt(r*r+i*i+s*s),n=Math.exp(a),h=o>0?n*Math.sin(o)/o:0;return e[0]=r*h,e[1]=i*h,e[2]=s*h,e[3]=n*Math.cos(o),e}function Xi(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=Math.sqrt(r*r+i*i+s*s),n=o>0?Math.atan2(o,a)/o:0;return e[0]=r*n,e[1]=i*n,e[2]=s*n,e[3]=.5*Math.log(r*r+i*i+s*s+a*a),e}function qi(e,t,r){return Xi(e,t),os(e,e,r),ki(e,e),e}function ji(e,t,r,i){var s,a,o,n,h,l=t[0],c=t[1],u=t[2],d=t[3],f=r[0],g=r[1],p=r[2],m=r[3];return(a=l*f+c*g+u*p+d*m)<0&&(a=-a,f=-f,g=-g,p=-p,m=-m),1-a>_?(s=Math.acos(a),o=Math.sin(s),n=Math.sin((1-i)*s)/o,h=Math.sin(i*s)/o):(n=1-i,h=i),e[0]=n*l+h*f,e[1]=n*c+h*g,e[2]=n*u+h*p,e[3]=n*d+h*m,e}function Zi(e){var t=g(),r=g(),i=g(),s=Math.sqrt(1-t),a=Math.sqrt(t);return e[0]=s*Math.sin(2*Math.PI*r),e[1]=s*Math.cos(2*Math.PI*r),e[2]=a*Math.sin(2*Math.PI*i),e[3]=a*Math.cos(2*Math.PI*i),e}function Wi(e,t){var r=t[0],i=t[1],s=t[2],a=t[3],o=r*r+i*i+s*s+a*a,n=o?1/o:0;return e[0]=-r*n,e[1]=-i*n,e[2]=-s*n,e[3]=a*n,e}function $i(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Ki(e,t){var r,i=t[0]+t[4]+t[8];if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var s=0;t[4]>t[0]&&(s=1),t[8]>t[3*s+s]&&(s=2);var a=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[3*s+s]-t[3*a+a]-t[3*o+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+s]+t[3*s+a])*r,e[o]=(t[3*o+s]+t[3*s+o])*r}return e}function Qi(e,t,r,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:p,a=Math.PI/360;t*=a,i*=a,r*=a;var o=Math.sin(t),n=Math.cos(t),h=Math.sin(r),l=Math.cos(r),c=Math.sin(i),u=Math.cos(i);switch(s){case"xyz":e[0]=o*l*u+n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u-o*h*c;break;case"xzy":e[0]=o*l*u-n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u+o*h*c;break;case"yxz":e[0]=o*l*u+n*h*c,e[1]=n*h*u-o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u+o*h*c;break;case"yzx":e[0]=o*l*u+n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u-o*h*c;break;case"zxy":e[0]=o*l*u-n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c+o*h*u,e[3]=n*l*u-o*h*c;break;case"zyx":e[0]=o*l*u-n*h*c,e[1]=n*h*u+o*l*c,e[2]=n*l*c-o*h*u,e[3]=n*l*u+o*h*c;break;default:throw new Error("Unknown angle order "+s)}return e}function Ji(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}var es=Zr,ts=Wr,rs=$r,is=Kr,ss=Qr,as=Ui,os=ni,ns=pi,hs=Mi,ls=ui,cs=ls,us=di,ds=us,_s=gi,fs=yi;function gs(e,t){return Math.abs(pi(e,t))>=1-_}var ps,ms,Ms,xs,vs,bs,Ss=(ps=Kt(),ms=er(1,0,0),Ms=er(0,1,0),function(e,t,r){var i=vr(t,r);return i<-.999999?(br(ps,ms,t),kr(ps)<1e-6&&br(ps,Ms,t),xr(ps,ps),Oi(e,ps,Math.PI),e):i>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(br(ps,t,r),e[0]=ps[0],e[1]=ps[1],e[2]=ps[2],e[3]=1+i,_s(e,e))}),Ps=(xs=Li(),vs=Li(),function(e,t,r,i,s,a){return ji(xs,t,s,a),ji(vs,r,i,a),ji(e,xs,vs,2*a*(1-a)),e}),ys=(bs=be(),function(e,t,r,i){return bs[0]=r[0],bs[3]=r[1],bs[6]=r[2],bs[1]=i[0],bs[4]=i[1],bs[7]=i[2],bs[2]=-t[0],bs[5]=-t[1],bs[8]=-t[2],_s(e,Ki(e,bs))});function Ts(){var e=new f(8);return f!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e}function ws(e){var t=new f(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function Cs(e,t,r,i,s,a,o,n){var h=new f(8);return h[0]=e,h[1]=t,h[2]=r,h[3]=i,h[4]=s,h[5]=a,h[6]=o,h[7]=n,h}function As(e,t,r,i,s,a,o){var n=new f(8);n[0]=e,n[1]=t,n[2]=r,n[3]=i;var h=.5*s,l=.5*a,c=.5*o;return n[4]=h*i+l*r-c*t,n[5]=l*i+c*e-h*r,n[6]=c*i+h*t-l*e,n[7]=-h*e-l*t-c*r,n}function Es(e,t,r){var i=.5*r[0],s=.5*r[1],a=.5*r[2],o=t[0],n=t[1],h=t[2],l=t[3];return e[0]=o,e[1]=n,e[2]=h,e[3]=l,e[4]=i*l+s*h-a*n,e[5]=s*l+a*o-i*h,e[6]=a*l+i*n-s*o,e[7]=-i*o-s*n-a*h,e}function Rs(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e}function Fs(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function Is(e,t){var r=Li();wt(r,t);var i=new f(3);return yt(i,t),Es(e,r,i),e}function Ds(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function Ls(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function Bs(e,t,r,i,s,a,o,n,h){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=o,e[6]=n,e[7]=h,e}var Os=rs;function Vs(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e}var Ns=rs;function Us(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e}function zs(e,t){var r=t[4],i=t[5],s=t[6],a=t[7],o=-t[0],n=-t[1],h=-t[2],l=t[3];return e[0]=2*(r*l+a*o+i*h-s*n),e[1]=2*(i*l+a*n+s*o-r*h),e[2]=2*(s*l+a*h+r*n-i*o),e}function Hs(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=.5*r[0],h=.5*r[1],l=.5*r[2],c=t[4],u=t[5],d=t[6],_=t[7];return e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=o*n+s*l-a*h+c,e[5]=o*h+a*n-i*l+u,e[6]=o*l+i*h-s*n+d,e[7]=-i*n-s*h-a*l+_,e}function Gs(e,t,r){var i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*i+h*a-l*s,d=h*o+c*s+l*i-n*a,_=l*o+c*a+n*s-h*i,f=c*o-n*i-h*s-l*a;return zi(e,t,r),i=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*i+d*a-_*s,e[5]=d*o+f*s+_*i-u*a,e[6]=_*o+f*a+u*s-d*i,e[7]=f*o-u*i-d*s-_*a,e}function Ys(e,t,r){var i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*i+h*a-l*s,d=h*o+c*s+l*i-n*a,_=l*o+c*a+n*s-h*i,f=c*o-n*i-h*s-l*a;return Hi(e,t,r),i=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*i+d*a-_*s,e[5]=d*o+f*s+_*i-u*a,e[6]=_*o+f*a+u*s-d*i,e[7]=f*o-u*i-d*s-_*a,e}function ks(e,t,r){var i=-t[0],s=-t[1],a=-t[2],o=t[3],n=t[4],h=t[5],l=t[6],c=t[7],u=n*o+c*i+h*a-l*s,d=h*o+c*s+l*i-n*a,_=l*o+c*a+n*s-h*i,f=c*o-n*i-h*s-l*a;return Gi(e,t,r),i=e[0],s=e[1],a=e[2],o=e[3],e[4]=u*o+f*i+d*a-_*s,e[5]=d*o+f*s+_*i-u*a,e[6]=_*o+f*a+u*s-d*i,e[7]=f*o-u*i-d*s-_*a,e}function Xs(e,t,r){var i=r[0],s=r[1],a=r[2],o=r[3],n=t[0],h=t[1],l=t[2],c=t[3];return e[0]=n*o+c*i+h*a-l*s,e[1]=h*o+c*s+l*i-n*a,e[2]=l*o+c*a+n*s-h*i,e[3]=c*o-n*i-h*s-l*a,n=t[4],h=t[5],l=t[6],c=t[7],e[4]=n*o+c*i+h*a-l*s,e[5]=h*o+c*s+l*i-n*a,e[6]=l*o+c*a+n*s-h*i,e[7]=c*o-n*i-h*s-l*a,e}function qs(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[0],h=r[1],l=r[2],c=r[3];return e[0]=i*c+o*n+s*l-a*h,e[1]=s*c+o*h+a*n-i*l,e[2]=a*c+o*l+i*h-s*n,e[3]=o*c-i*n-s*h-a*l,n=r[4],h=r[5],l=r[6],c=r[7],e[4]=i*c+o*n+s*l-a*h,e[5]=s*c+o*h+a*n-i*l,e[6]=a*c+o*l+i*h-s*n,e[7]=o*c-i*n-s*h-a*l,e}function js(e,t,r,i){if(Math.abs(i)<_)return Ds(e,t);var s=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);i*=.5;var a=Math.sin(i),o=a*r[0]/s,n=a*r[1]/s,h=a*r[2]/s,l=Math.cos(i),c=t[0],u=t[1],d=t[2],f=t[3];e[0]=c*l+f*o+u*h-d*n,e[1]=u*l+f*n+d*o-c*h,e[2]=d*l+f*h+c*n-u*o,e[3]=f*l-c*o-u*n-d*h;var g=t[4],p=t[5],m=t[6],M=t[7];return e[4]=g*l+M*o+p*h-m*n,e[5]=p*l+M*n+m*o-g*h,e[6]=m*l+M*h+g*n-p*o,e[7]=M*l-g*o-p*n-m*h,e}function Zs(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e}function Ws(e,t,r){var i=t[0],s=t[1],a=t[2],o=t[3],n=r[4],h=r[5],l=r[6],c=r[7],u=t[4],d=t[5],_=t[6],f=t[7],g=r[0],p=r[1],m=r[2],M=r[3];return e[0]=i*M+o*g+s*m-a*p,e[1]=s*M+o*p+a*g-i*m,e[2]=a*M+o*m+i*p-s*g,e[3]=o*M-i*g-s*p-a*m,e[4]=i*c+o*n+s*l-a*h+u*M+f*g+d*m-_*p,e[5]=s*c+o*h+a*n-i*l+d*M+f*p+_*g-u*m,e[6]=a*c+o*l+i*h-s*n+_*M+f*m+u*p-d*g,e[7]=o*c-i*n-s*h-a*l+f*M-u*g-d*p-_*m,e}var $s=Ws;function Ks(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e}var Qs=ns;function Js(e,t,r,i){var s=1-i;return Qs(t,r)<0&&(i=-i),e[0]=t[0]*s+r[0]*i,e[1]=t[1]*s+r[1]*i,e[2]=t[2]*s+r[2]*i,e[3]=t[3]*s+r[3]*i,e[4]=t[4]*s+r[4]*i,e[5]=t[5]*s+r[5]*i,e[6]=t[6]*s+r[6]*i,e[7]=t[7]*s+r[7]*i,e}function ea(e,t){var r=sa(t);return e[0]=-t[0]/r,e[1]=-t[1]/r,e[2]=-t[2]/r,e[3]=t[3]/r,e[4]=-t[4]/r,e[5]=-t[5]/r,e[6]=-t[6]/r,e[7]=t[7]/r,e}function ta(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e[4]=-t[4],e[5]=-t[5],e[6]=-t[6],e[7]=t[7],e}var ra=ls,ia=ra,sa=us,aa=sa;function oa(e,t){var r=sa(t);if(r>0){r=Math.sqrt(r);var i=t[0]/r,s=t[1]/r,a=t[2]/r,o=t[3]/r,n=t[4],h=t[5],l=t[6],c=t[7],u=i*n+s*h+a*l+o*c;e[0]=i,e[1]=s,e[2]=a,e[3]=o,e[4]=(n-i*u)/r,e[5]=(h-s*u)/r,e[6]=(l-a*u)/r,e[7]=(c-o*u)/r}return e}function na(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"}function ha(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]}function la(e,t){var r=e[0],i=e[1],s=e[2],a=e[3],o=e[4],n=e[5],h=e[6],l=e[7],c=t[0],u=t[1],d=t[2],f=t[3],g=t[4],p=t[5],m=t[6],M=t[7];return Math.abs(r-c)<=_*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(i-u)<=_*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(s-d)<=_*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-f)<=_*Math.max(1,Math.abs(a),Math.abs(f))&&Math.abs(o-g)<=_*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(n-p)<=_*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(h-m)<=_*Math.max(1,Math.abs(h),Math.abs(m))&&Math.abs(l-M)<=_*Math.max(1,Math.abs(l),Math.abs(M))}function ca(){var e=new f(2);return f!=Float32Array&&(e[0]=0,e[1]=0),e}function ua(e){var t=new f(2);return t[0]=e[0],t[1]=e[1],t}function da(e,t){var r=new f(2);return r[0]=e,r[1]=t,r}function _a(e,t){return e[0]=t[0],e[1]=t[1],e}function fa(e,t,r){return e[0]=t,e[1]=r,e}function ga(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function pa(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function ma(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function Ma(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function xa(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function va(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function ba(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function Sa(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function Pa(e,t){return e[0]=m(t[0]),e[1]=m(t[1]),e}function ya(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function Ta(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e}function wa(e,t){var r=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(r*r+i*i)}function Ca(e,t){var r=t[0]-e[0],i=t[1]-e[1];return r*r+i*i}function Aa(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function Ea(e){var t=e[0],r=e[1];return t*t+r*r}function Ra(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Fa(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Ia(e,t){var r=t[0],i=t[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e}function Da(e,t){return e[0]*t[0]+e[1]*t[1]}function La(e,t,r){var i=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=i,e}function Ba(e,t,r,i){var s=t[0],a=t[1];return e[0]=s+i*(r[0]-s),e[1]=a+i*(r[1]-a),e}function Oa(e,t){t=void 0===t?1:t;var r=2*g()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function Va(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s,e[1]=r[1]*i+r[3]*s,e}function Na(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s+r[4],e[1]=r[1]*i+r[3]*s+r[5],e}function Ua(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[3]*s+r[6],e[1]=r[1]*i+r[4]*s+r[7],e}function za(e,t,r){var i=t[0],s=t[1];return e[0]=r[0]*i+r[4]*s+r[12],e[1]=r[1]*i+r[5]*s+r[13],e}function Ha(e,t,r,i){var s=t[0]-r[0],a=t[1]-r[1],o=Math.sin(i),n=Math.cos(i);return e[0]=s*n-a*o+r[0],e[1]=s*o+a*n+r[1],e}function Ga(e,t){var r=e[0],i=e[1],s=t[0],a=t[1];return Math.abs(Math.atan2(i*s-r*a,r*s+i*a))}function Ya(e,t){var r=e[0],i=e[1],s=t[0],a=t[1];return Math.atan2(r*a-i*s,r*s+i*a)}function ka(e){return e[0]=0,e[1]=0,e}function Xa(e){return"vec2("+e[0]+", "+e[1]+")"}function qa(e,t){return e[0]===t[0]&&e[1]===t[1]}function ja(e,t){var r=e[0],i=e[1],s=t[0],a=t[1];return Math.abs(r-s)<=_*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-a)<=_*Math.max(1,Math.abs(i),Math.abs(a))}var Za=Aa,Wa=pa,$a=ma,Ka=Ma,Qa=wa,Ja=Ca,eo=Ea,to=function(){var e=ca();return function(t,r,i,s,a,o){var n,h;for(r||(r=2),i||(i=0),h=s?Math.min(s*r+i,t.length):t.length,n=i;n<h;n+=r)e[0]=t[n],e[1]=t[n+1],a(e,e,o),t[n]=e[0],t[n+1]=e[1];return t}}()},2056:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VisibleTilesManager=void 0;const s=i(r(4382)),a=r(1138),o=i(r(4639)),n=r(4006),h=r(1961),l=r(2919);t.VisibleTilesManager=class{_visibleTilesByOrder;_ancestorsMap;initialised;_galVisibleTilesByOrder;_galAncestorsMap;_galacticMatrixInverted;_galacticMatrix;insideSphere=l.bootSetup.insideSphere;_tileBuffer;_healpixGrid;_webgl;constructor(e,t,r){this._webgl=e,this._healpixGrid=r,this._visibleTilesByOrder={pixels:[],order:0},this._ancestorsMap=new Map,this.initialised=!1,this._galVisibleTilesByOrder={pixels:[],order:0},this._galAncestorsMap=new Map,this._galacticMatrixInverted=h.mat4.create(),this._galacticMatrix=h.mat4.create(),h.mat4.set(this._galacticMatrixInverted,-.054876,-.873437,-.483835,0,.494109,-.44483,.746982,-0,-.867666,-.198076,.455984,0,0,0,0,1),h.mat4.invert(this._galacticMatrix,this._galacticMatrixInverted),this._tileBuffer=new n.TileBuffer(1,e,t,this)}get healpixGrid(){return this._healpixGrid}get tileBuffer(){return this._tileBuffer}init(e){this.initialised=!0,this.insideSphere=e}getVisibleOrder(){return this._healpixGrid.visibleorder}computeVisiblePixels(e,t,r,i){if(!this.initialised)return;s.default.insideSphere&&e<3&&(e=3),this._ancestorsMap.set(e,[]),this._galAncestorsMap.set(e,[]);let n=[],l=[];if(0===e){const t=s.default.getHealpix(0).getNPix();for(let r=0;r<t;r++)n.push(r),this._ancestorsMap.get(e).push(r),l.push(r),this._galAncestorsMap.get(e).push(r)}else{const c=s.default.getHealpix(e),u=t.canvas.width,d=t.canvas.height;for(let t=0;t<=u;t+=u/30)for(let s=0;s<=d;s+=d/30){const u=o.default.getIntersectionPointWithSingleModel(t,s,this._healpixGrid,this._webgl,r,i);if(u.length>0){const t=h.vec4.create();h.vec4.transformMat4(t,[u[0],u[1],u[2],1],this._galacticMatrix);const r=new a.Pointing(new a.Vec3(t[0],t[1],t[2])),i=c.ang2pix(r),s=new a.Pointing(new a.Vec3(u[0],u[1],u[2])),o=c.ang2pix(s);n.includes(o)||(n.push(o),this._ancestorsMap.get(e).push(o),this._tileBuffer.addTile(e,o)),l.includes(i)||(l.push(i),this._galAncestorsMap.get(e).push(i),this._tileBuffer.addGalTile(e,i))}}}this._visibleTilesByOrder={pixels:n,order:e},this._galVisibleTilesByOrder={pixels:l,order:e};for(let t=1;t<e;t++){const r=e-t,i=this._ancestorsMap.get(r)??[];this._ancestorsMap.set(r,i);for(let e=0;e<n.length;e++){const s=n[e]>>2*t;i.includes(s)||(i.push(s),this._tileBuffer.addTile(r,s))}}for(let t=1;t<e;t++){const r=e-t,i=this._galAncestorsMap.get(r)??[];this._galAncestorsMap.set(r,i);for(let e=0;e<l.length;e++){const s=l[e]>>2*t;i.includes(s)||(i.push(s),this._tileBuffer.addGalTile(r,s))}}}get visibleTilesByOrder(){return this._visibleTilesByOrder}get ancestorsMap(){return this._ancestorsMap}get galVisibleTilesByOrder(){return this._galVisibleTilesByOrder}get galAncestorsMap(){return this._galAncestorsMap}get visibleOrder(){return this._visibleTilesByOrder.order}}},2166:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(1961),s=85.0511287798066;class a{static getRayFromMouse(e,t,r,s,o){const n=s.canvas.getBoundingClientRect(),h=[2*e/n.width-1,1-2*t/n.height,-1,1],l=i.mat4.create();i.mat4.invert(l,r);const c=[0,0,0,0];a.mat4MultiplyVec4(l,h,c);const u=[c[0],c[1],-1,0],d=i.mat4.create();i.mat4.invert(d,o);const _=[0,0,0,0];a.mat4MultiplyVec4(d,u,_);const f=i.vec3.fromValues(_[0],_[1],_[2]);return i.vec3.normalize(f,f),f}static raySphere(e,t,r){let s=-1;const a=i.vec3.create();i.vec3.subtract(a,e,r.center);const o=i.vec3.dot(t,a),n=o*o-(i.vec3.dot(a,a)-r.radius*r.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,r=-o-e;(t>=0||r>=0)&&(s=r<0?t:Math.min(t,r))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}static getIntersectionPointWithModel(e,t,r,s,o,n){const h=o.getCameraMatrix(),l=a.getRayFromMouse(e,t,n,s,h),c=a.raySphere(o.getCameraPosition(),l,r);if(c<0)return null;const u=i.vec3.create();i.vec3.scale(u,l,c),i.vec3.add(u,o.getCameraPosition(),u);const d=[u[0],u[1],u[2],1],_=[0,0,0,0];return a.mat4MultiplyVec4(r.getModelMatrixInverse(),d,_),[_[0],_[1],_[2]]}static getLonLatFromMouse(e,t,r,i,s,o){const n=a.getIntersectionPointWithModel(e,t,r,i,s,o);return n?a.modelPointToLonLat(n):null}static getTileFromMouse(e,t,r,i,s,o,n){const h=a.getLonLatFromMouse(e,t,i,s,o,n);return h&&a.isMercatorLatitude(h.latDeg)?a.lonLatToTile(h.lonDeg,h.latDeg,r):null}static getVisibleTilesFromViewport(e,t,r,i,s,o=9,n=2){const h=r.canvas.getBoundingClientRect(),l=Math.max(2,Math.floor(o)),c=Math.max(2*l+1,21),u=Math.max(0,Math.floor(n)),d=[],_=(o,n)=>{const h=a.getTileFromMouse(o,n,e,t,r,i,s);h&&(d.push(h),d.push(...a.getNeighborTiles(h,u)))};for(let e=0;e<l;e++){const t=1===l?h.height/2:e/(l-1)*h.height;for(let e=0;e<l;e++)_(1===l?h.width/2:e/(l-1)*h.width,t)}for(let e=0;e<c;e++){const t=1===c?.5:e/(c-1),r=t*h.width,i=t*h.height;_(r,0),_(r,h.height),_(0,i),_(h.width,i)}return a.fillSmallTileGaps(a.deduplicateTiles(d))}static modelPointToLonLat(e){const[t,r,i]=e,s=Math.hypot(t,r,i);return Number.isFinite(s)&&0!==s?{lonDeg:180*Math.atan2(r,t)/Math.PI,latDeg:180*Math.asin(Math.max(-1,Math.min(1,i/s)))/Math.PI}:{lonDeg:0,latDeg:0}}static lonLatToTile(e,t,r){const i=Math.max(0,Math.floor(r)),s=2**i,o=Math.floor((e+180)/360*s),n=Math.floor(a.latToTileY(t,i));return{z:i,x:a.wrapTileX(o,s),y:a.clampTileY(n,s)}}static getNeighborTiles(e,t=1){const r=2**e.z,i=[],s=Math.max(0,Math.floor(t));for(let t=-s;t<=s;t++)for(let o=-s;o<=s;o++)i.push({z:e.z,x:a.wrapTileX(e.x+t,r),y:a.clampTileY(e.y+o,r)});return a.deduplicateTiles(i)}static deduplicateTiles(e){const t=new Map;for(const r of e)t.set(`${r.z}/${r.x}/${r.y}`,r);return Array.from(t.values())}static fillSmallTileGaps(e){if(0===e.length)return e;const t=e[0].z,r=2**t,i=new Map,s=e=>{i.set((e=>`${e.z}/${e.x}/${e.y}`)(e),e)},o=(e,s)=>s>=0&&s<r&&i.has(`${t}/${a.wrapTileX(e,r)}/${s}`);for(const t of e)s(t);for(const i of e){const e=i.x,n=i.y;o(e-2,n)&&!o(e-1,n)&&s({z:t,x:a.wrapTileX(e-1,r),y:n}),o(e+2,n)&&!o(e+1,n)&&s({z:t,x:a.wrapTileX(e+1,r),y:n}),o(e,n-2)&&!o(e,n-1)&&s({z:t,x:e,y:n-1}),o(e,n+2)&&!o(e,n+1)&&s({z:t,x:e,y:n+1})}return Array.from(i.values())}static latToTileY(e,t){const r=Math.max(-85.0511287798066,Math.min(s,e))*Math.PI/180,i=2**t;return(1-Math.asinh(Math.tan(r))/Math.PI)/2*i}static isMercatorLatitude(e){return Math.abs(e)<=s}static wrapTileX(e,t){return(e%t+t)%t}static clampTileY(e,t){return Math.max(0,Math.min(t-1,e))}static mat4MultiplyVec4(e,t,r){const i=t[0],s=t[1],a=t[2],o=t[3];return r[0]=e[0]*i+e[4]*s+e[8]*a+e[12]*o,r[1]=e[1]*i+e[5]*s+e[9]*a+e[13]*o,r[2]=e[2]*i+e[6]*s+e[10]*a+e[14]*o,r[3]=e[3]*i+e[7]*s+e[11]*a+e[15]*o,r}}t.default=a},2257:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSShaderProgram=void 0,t.MeshHiPSShaderProgram=class{_webgl;locations;_shaderProgram;constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,color:null,vertexPositionAttribute:-1,vertexNormalAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create MeshHiPS shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}enableShaders(e,t,r,i){const s=this._webgl,a=this.shaderProgram;s.useProgram(a),this.locations.pMatrix=s.getUniformLocation(a,"uPMatrix"),this.locations.vMatrix=s.getUniformLocation(a,"uVMatrix"),this.locations.mMatrix=s.getUniformLocation(a,"uMMatrix"),this.locations.color=s.getUniformLocation(a,"uColor"),this.locations.vertexPositionAttribute=s.getAttribLocation(a,"aVertexPosition"),this.locations.vertexNormalAttribute=s.getAttribLocation(a,"aVertexNormal"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,r),s.uniform4fv(this.locations.color,i)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n precision mediump float;\n in vec3 aVertexPosition;\n in vec3 aVertexNormal;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec3 vNormal;\n void main(void) {\n vec3 worldPos = (uMMatrix * vec4(aVertexPosition, 1.0)).xyz;\n vNormal = normalize((uMMatrix * vec4(aVertexNormal, 0.0)).xyz);\n gl_Position = uPMatrix * uVMatrix * vec4(worldPos, 1.0);\n }"),r=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec3 vNormal;\n uniform vec4 uColor;\n out vec4 outColor;\n void main(void) {\n vec3 normal = normalize(vNormal);\n vec3 lightDir = normalize(vec3(0.45, 0.8, 0.35));\n float diffuse = max(dot(normal, lightDir), 0.0);\n float rim = pow(1.0 - max(dot(normal, vec3(0.0, 0.0, 1.0)), 0.0), 2.0);\n vec3 color = uColor.rgb * (0.24 + diffuse * 0.78) + vec3(0.16, 0.24, 0.20) * rim;\n outColor = vec4(color, uColor.a);\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,r),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise MeshHiPS shaders")}compileShader(e,t){const r=this._webgl,i=r.createShader(e);if(!i)throw new Error("Could not create MeshHiPS shader");if(r.shaderSource(i,t),r.compileShader(i),!r.getShaderParameter(i,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(i)||"MeshHiPS shader compile error");return i}}},2368:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(4382));t.default=class{_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,r,i){this._tileBuffer=r,this._hips=e,this._webgl=t,this._format=e.format,this._baseurl=e.baseURL,this._isGalacticHips=e.isGalacticHips,this._hipsShaderProgram=i,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,r=s.default.getHealpix(this._order);this._maxTiles=r.getNPix();const i=s.default.getHealpix(t);this._numFacesXTile=4,this._numFaces=this._numFacesXTile*this._maxTiles,this.vertexPosition=new Float32Array(20*this._numFaces);let a=0,o=0;this.vidx=0;for(let e=0;e<this._maxTiles;e++){const t=r.nest2xyf(e),s=t.ix<<1,n=2+(t.ix<<1),h=t.iy<<1,l=2+(t.iy<<1);this.setupPositionAndTexture4Quadrant(a,o,s,s+(n-s)/2,h,h+(l-h)/2,i,t,0,0),this.setupPositionAndTexture4Quadrant(a,o,s+(n-s)/2,n,h,h+(l-h)/2,i,t,0,1),this.setupPositionAndTexture4Quadrant(a,o,s,s+(n-s)/2,h+(l-h)/2,l,i,t,1,0),this.setupPositionAndTexture4Quadrant(a,o,s+(n-s)/2,n,h+(l-h)/2,l,i,t,1,1),a++,27===a&&(o++,a=0)}const n=new Uint16Array(6*this._numFaces);let h=0;for(let e=0;e<this._numFaces;e++)n[6*e]=h,n[6*e+1]=h+1,n[6*e+2]=h+3,n[6*e+3]=h+1,n[6*e+4]=h+2,n[6*e+5]=h+3,h+=4;this.vertexPositionBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexPositionBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexPosition,e.STATIC_DRAW),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,r,i,s,a,o,n,h,l){let c=[];const u=2**(o.order-3),d=1/(27*u),_=1/(29*u),f=d/64,g=_/64,p=u*d*e+d*h,m=u*_*t+_*l;for(let e=r;e<i;e++)for(let t=s;t<a;t++)c=o.getPointsForXyfNoStep(e,t,n.face),this.vertexPosition[20*this.vidx]=c[0].x,this.vertexPosition[20*this.vidx+1]=c[0].y,this.vertexPosition[20*this.vidx+2]=c[0].z,this.vertexPosition[20*this.vidx+3]=d+p-f,this.vertexPosition[20*this.vidx+4]=1-(_+m)+g,this.vertexPosition[20*this.vidx+5]=c[1].x,this.vertexPosition[20*this.vidx+6]=c[1].y,this.vertexPosition[20*this.vidx+7]=c[1].z,this.vertexPosition[20*this.vidx+8]=d+p-f,this.vertexPosition[20*this.vidx+9]=1-m-g,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]=p+f,this.vertexPosition[20*this.vidx+14]=1-m-g,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]=p+f,this.vertexPosition[20*this.vidx+19]=1-(_+m)+g,this.vidx++}draw(e,t,r,i,s,a){if(!this._ready)return!1;let o=[];if(e>=this._order){const n=this.drawChildren(e,t,r,i,s,a);n&&(o=n)}const n=this._webgl;this._hipsShaderProgram.enableShaders(r,i,s,a),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++)o.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,r,i,s,a){const o=this._order;if(!t.has(o))return;const n=t.get(o),h=[];for(let l=0;l<n.length;l++){const c=n[l],u=this._isGalacticHips?this._tileBuffer.getGalTile(c,o,this._hips):this._tileBuffer.getTile(c,o,this._hips);u.draw(e,t,r,i,s,a,this._hipsShaderProgram),u.getReadyState()&&h.push(c)}return h}}},2475:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=void 0;const s=i(r(2930)),a=i(r(9665)),o=r(8145);class n{_polygons=[];_convexPolygons=[];_stcs;_valid=!1;_details;_totPoints=0;_totConvexPoints=0;_npix256;_footprintsPointsOrder;_coordsType;_selectionObj;_identifier;_center;constructor(e,t=[],r,i=o.CoordsType.ASTRO){this._coordsType=i,e?(this._stcs=e.toUpperCase(),this._details=t,this._totPoints=0,this._totConvexPoints=0,this._footprintsPointsOrder=r,this.computePoints(),this._selectionObj=this.computeSelectionObject(),this._valid=!0):this._details=[]}static fromPolygons(e,t=[],r=o.CoordsType.ASTRO){const i=new n(void 0,[],void 0,r);return i._polygons=e,i._details=t,i._totPoints=e.reduce((e,t)=>e+t.length,0),i._totConvexPoints=0,i._coordsType=r,i._selectionObj=i.computeSelectionObject(),i._valid=i._totPoints>0,i}computeSelectionObject(){return s.default.computeSelectionObject(this._polygons)}computePoints(){const e=a.default.parseSTCS(this._stcs,{coordsType:this._coordsType});this._polygons=e.polygons,this._totPoints=e.totpoints}get valid(){return this._valid}get totPoints(){return this._totPoints}get totConvexPoints(){return this._totConvexPoints}get polygons(){return this._polygons}get convexPolygons(){return this._convexPolygons}get identifier(){return this._identifier}get center(){return this._center}get pixels(){return this._npix256}get details(){return this._details}get selectionObj(){return this._selectionObj}}t.Footprint=n},2737:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZTileBuffer=void 0;class r{_tiles=new Map;_cachedTiles=new Map;_cacheAliveMilliSeconds;_cleanerId;constructor(e=1){this._cacheAliveMilliSeconds=60*e*1e3,"undefined"!=typeof window&&(this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4))}get activeTiles(){return this._tiles}get cachedTiles(){return this._cachedTiles}get size(){return this._tiles.size+this._cachedTiles.size}ensureTiles(e,t){const r=[];for(const i of e){const e=this.getTile(i,t);this.touchTile(e),r.push(this.key(i))}return this.syncVisibleTiles(r),r}getTile(e,t){const r=this.key(e);if(this._tiles.has(r))return this._tiles.get(r).tile;if(this._cachedTiles.has(r)){const e=this._cachedTiles.get(r);return e.cacheTime0=void 0,this._tiles.set(r,e),this._cachedTiles.delete(r),e.tile}const i=t(e);return this._tiles.set(r,{tile:i}),i}getActiveTile(e){return this._tiles.get(e)?.tile??null}getAnyTile(e){return this._tiles.get(e)?.tile??this._cachedTiles.get(e)?.tile??null}getActiveTiles(){return Array.from(this._tiles.values(),e=>e.tile)}syncVisibleTiles(e){const t=new Set(e);for(const[e,r]of this._tiles)t.has(e)?this.touchTile(r.tile):(r.cacheTime0=Date.now(),this._cachedTiles.set(e,r),this._tiles.delete(e))}evictCached(e){if(this.size<=e)return;const t=Array.from(this._cachedTiles.entries()).sort((e,t)=>this.getTileAgeScore(e[1].tile)-this.getTileAgeScore(t[1].tile));for(const[r,i]of t){if(this.size<=e)break;i.tile.loading||(i.tile.dispose?.(),this._cachedTiles.delete(r))}}dispose(){void 0!==this._cleanerId&&"undefined"!=typeof window&&(window.clearInterval(this._cleanerId),this._cleanerId=void 0);for(const e of this._tiles.values())e.tile.dispose?.();for(const e of this._cachedTiles.values())e.tile.dispose?.();this._tiles.clear(),this._cachedTiles.clear()}key(e){return r.key(e)}static key(e){return`${e.z}/${e.x}/${e.y}`}cacheCleaner(){const e=Date.now();for(const[t,r]of this._cachedTiles){const i=r.cacheTime0;void 0===i||e-i<=this._cacheAliveMilliSeconds||r.tile.loading||(r.tile.dispose?.(),this._cachedTiles.delete(t))}}touchTile(e){e.touch?.()}getTileAgeScore(e){const t=e.lastUsedAt??0,r=e.createdAt??t;return Math.min(t||r,r)}}t.XYZTileBuffer=r},2885:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(4382)),a=r(229);t.default=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,r,i,s,a){this._hipsShaderProgram=s,this._tileBuffer=i,this._hips=r,this._tileno=e,this._webgl=a,this._format=r.format,this._baseurl=r.baseURL,this._isGalacticHips=r.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=a.fovHelper.getRefOrder(this._order),r=s.default.getHealpix(this._order).nest2xyf(this._tileno),i=t-this._order,o=r.ix<<i,n=(r.ix<<i)+(1<<i),h=r.iy<<i,l=(r.iy<<i)+(1<<i),c=s.default.getHealpix(t);this._pixels=[],this.setupPositionAndTexture4Quadrant(o,n/2,h,l/2,0,c,i,r),this.setupPositionAndTexture4Quadrant(n/2,n,h,l/2,1,c,i,r),this.setupPositionAndTexture4Quadrant(o,n/2,l/2,l,2,c,i,r),this.setupPositionAndTexture4Quadrant(n/2,n,l/2,l,3,c,i,r);const u=this.vertexPosition[0].length/20;this.vertexIndices=this.computeVertexIndices(u),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint16Array(6*e);let r=0;for(let i=0;i<e;i++)t[6*i]=r,t[6*i+1]=r+1,t[6*i+2]=r+2,t[6*i+3]=r+2,t[6*i+4]=r+3,t[6*i+5]=r,r+=4;return t}setupPositionAndTexture4Quadrant2(e,t,r,i,s,a,o,n){this.vertexPosition[s]=new Float32Array(20*(t-e)*(i-r));const h=1/(1<<o);let l=0;for(let c=e;c<t;c++)for(let e=r;e<i;e++){const t=a.getPointsForXyfNoStep(c,e,n.face),r=e-(n.iy<<o),i=c-(n.ix<<o);this.vertexPosition[s][20*l]=t[0].x,this.vertexPosition[s][20*l+1]=t[0].y,this.vertexPosition[s][20*l+2]=t[0].z,this.vertexPosition[s][20*l+3]=h+h*r,this.vertexPosition[s][20*l+4]=1-(h+h*i),this.vertexPosition[s][20*l+5]=t[1].x,this.vertexPosition[s][20*l+6]=t[1].y,this.vertexPosition[s][20*l+7]=t[1].z,this.vertexPosition[s][20*l+8]=h+h*r,this.vertexPosition[s][20*l+9]=1-h*i,this.vertexPosition[s][20*l+10]=t[2].x,this.vertexPosition[s][20*l+11]=t[2].y,this.vertexPosition[s][20*l+12]=t[2].z,this.vertexPosition[s][20*l+13]=h*r,this.vertexPosition[s][20*l+14]=1-h*i,this.vertexPosition[s][20*l+15]=t[3].x,this.vertexPosition[s][20*l+16]=t[3].y,this.vertexPosition[s][20*l+17]=t[3].z,this.vertexPosition[s][20*l+18]=h*r,this.vertexPosition[s][20*l+19]=1-(h+h*i),l++}this.vertexPositionBuffer[s]=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexPositionBuffer[s]),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexPosition[s],this._webgl.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,r,i,s,a,o,n){const h=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(i-r));const l=1/(1<<o);let c=0;for(let h=e;h<t;h++)for(let e=r;e<i;e++){const t=a.xyf2nest(h,e,n.face);this._pixels.push(t);const r=a.getBoundaries(t),i=e-(n.iy<<o),u=h-(n.ix<<o);this.vertexPosition[s][20*c]=r[0].x,this.vertexPosition[s][20*c+1]=r[0].y,this.vertexPosition[s][20*c+2]=r[0].z,this.vertexPosition[s][20*c+3]=l+l*i,this.vertexPosition[s][20*c+4]=1-(l+l*u),this.vertexPosition[s][20*c+5]=r[1].x,this.vertexPosition[s][20*c+6]=r[1].y,this.vertexPosition[s][20*c+7]=r[1].z,this.vertexPosition[s][20*c+8]=l+l*i,this.vertexPosition[s][20*c+9]=1-l*u,this.vertexPosition[s][20*c+10]=r[2].x,this.vertexPosition[s][20*c+11]=r[2].y,this.vertexPosition[s][20*c+12]=r[2].z,this.vertexPosition[s][20*c+13]=l*i,this.vertexPosition[s][20*c+14]=1-l*u,this.vertexPosition[s][20*c+15]=r[3].x,this.vertexPosition[s][20*c+16]=r[3].y,this.vertexPosition[s][20*c+17]=r[3].z,this.vertexPosition[s][20*c+18]=l*i,this.vertexPosition[s][20*c+19]=1-(l+l*u),c++}this.vertexPositionBuffer[s]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[s]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[s],h.STATIC_DRAW)}draw(e,t,r,i,s,a){if(!this._ready)return!1;let o=new Set([0,1,2,3]);if(e>this._order){const n=this.drawChildren(e,t,r,i,s,a);n&&(o=n)}this._hipsShaderProgram.enableShaders(r,i,s,a);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 o.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,r,i,s,a){const o=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,r,i,s,a,this._hipsShaderProgram),h._ready&&o.delete(h._tileno-(this._tileno<<2))}}return o}}}},2919:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bootSetup=t.tapRepos=t.hipsNodes=void 0,t.hipsNodes=["https://skies.esac.esa.int/","https://alasky.cds.unistra.fr/"],t.tapRepos=["https://sky.esa.int/esasky-tap/tap/"],t.bootSetup={insideSphere:!1,defaultHips:"",camera_fov_deg:34,camera_fov_rad:34*Math.PI/180,inside_camera_fov_deg:60,inside_camera_fov_rad:60*Math.PI/180,camera_near_plane:1e-5,camera_far_plane:2.5,corsProxyUrl:"http://localhost:4000/",useCORSProxy:!1,maxDecimals:15,defaultHipsUrl:"https://cdn.skies.esac.esa.int/DSSColor/",version:"Astrobrowser v1.0.0",debug:!1,insideView:!1,showViewfinder:!0}},2930:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6553),a=i(r(7559)),o=r(8145);class n{static orthodromicDistance(e,t){return Math.acos(Math.sin(e.decDeg*Math.PI/180)*Math.sin(t.decDeg*Math.PI/180)+Math.cos(e.decDeg*Math.PI/180)*Math.cos(t.decDeg*Math.PI/180)*Math.cos((t.raDeg-e.raDeg)*Math.PI/180))}static computeSelectionObject(e){let t,r,i,s,o=[],h=0,l=0;if(e[0][0].decDeg>=10?l=1:e[0][0].decDeg<=-10?l=-1:h=1,0===h){const a=n.projectIn2D(e[0][0]);t=i=a.x,r=s=a.y;for(const a of e){const e=[];for(const c of a){if(c.decDeg>10*l&&-1===l||c.decDeg<10*l&&1===l){h=1,o=[];break}const a=n.projectIn2D(c);e.push(a),a.x>t&&(t=a.x),a.y>r&&(r=a.y),a.x<i&&(i=a.x),a.y<s&&(s=a.y)}o.push(e)}}if(0===h)return{poly4selection:o,flag:h,maxx:t,maxy:r,minx:i,miny:s};const c=180;let u=e[0][0].raDeg<c;t=i=e[0][0].raDeg,r=s=e[0][0].decDeg;for(const n of e){const e=[];for(const l of n){const n=new a.default(l.raDeg,l.decDeg);if(e.push(n),l.raDeg>t&&(t=l.raDeg),l.decDeg>r&&(r=l.decDeg),l.raDeg<i&&(i=l.raDeg),l.decDeg<s&&(s=l.decDeg),l.raDeg>=c&&u||l.raDeg<=c&&!u){h=2,o=[];break}}o.push(e)}if(1===h)return{poly4selection:o,flag:h,maxx:t,maxy:r,minx:i,miny:s};let d=e[0][0].raDeg;t=d>=c?d-360:d,r=e[0][0].decDeg,i=t,s=r;for(const n of e){const e=[];for(const o of n){const n=o.raDeg>=c?o.raDeg-360:o.raDeg;n>t&&(t=n),o.decDeg>r&&(r=o.decDeg),n<i&&(i=n),o.decDeg<s&&(s=o.decDeg),e.push(new a.default(n,o.decDeg))}o.push(e)}return{poly4selection:o,flag:h,maxx:t,maxy:r,minx:i,miny:s}}static stereographic(e){const t=Number(e.xyz[0]),r=Number(e.xyz[1]),i=Number(e.xyz[2]);return{x:2*t/(1-i),y:2*r/(1-i)}}static projectIn2D(e){const t=n.stereographic(e);return new a.default(t.x,t.y)}static checkPointInsidePolygon5(e,t){let r;if(0===e.flag)r=n.projectIn2D(t);else if(1===e.flag)r=new a.default(t.raDeg,t.decDeg);else{const e=180,i=t.raDeg>=e?t.raDeg-360:t.raDeg;r=new a.default(i,t.decDeg)}const i=new a.default(r.x,r.y+2*Math.abs(e.maxy-e.miny));if(r.x>e.maxx||r.x<e.minx||r.y>e.maxy||r.y<e.miny)return!1;for(const t of e.poly4selection){let e=0;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],n=(o.y-a.y)*(i.x-r.x)-(o.x-a.x)*(i.y-r.y),h=(o.x-a.x)*(r.y-a.y)-(o.y-a.y)*(r.x-a.x),l=(i.x-r.x)*(r.y-a.y)-(i.y-r.y)*(r.x-a.x);if(0!==n){const t=h/n,r=l/n;t>=0&&t<=1&&r>=0&&r<=1&&e++}}{const s=t[t.length-1],a=t[0],o=(a.y-s.y)*(i.x-r.x)-(a.x-s.x)*(i.y-r.y),n=(a.x-s.x)*(r.y-s.y)-(a.y-s.y)*(r.x-s.x),h=(i.x-r.x)*(r.y-s.y)-(i.y-r.y)*(r.x-s.x);if(0!==o){const t=n/o,r=h/o;t>=0&&t<=1&&r>=0&&r<=1&&e++}}if(e%2==1)return!0}return!1}static checkPointInsidePolygon4(e,t){const r=n.projectIn2D(t);let i=t.raDeg+15;i>360&&(i=t.raDeg-15);const a=new s.Point({raDeg:i,decDeg:t.decDeg},o.CoordsType.ASTRO),h=n.projectIn2D(a);for(const t of e){let e=0;for(let i=0;i<t.length-1;i++){const s=n.projectIn2D(t[i]),a=n.projectIn2D(t[i+1]),o=(a.y-s.y)*(h.x-r.x)-(a.x-s.x)*(h.y-r.y),l=(a.x-s.x)*(r.y-s.y)-(a.y-s.y)*(r.x-s.x),c=(h.x-r.x)*(r.y-s.y)-(h.y-r.y)*(r.x-s.x);if(0!==o){const t=l/o,r=c/o;t>=0&&t<=1&&r>=0&&r<=1&&e++}}{const i=n.projectIn2D(t[t.length-1]),s=n.projectIn2D(t[0]),a=(s.y-i.y)*(h.x-r.x)-(s.x-i.x)*(h.y-r.y),o=(s.x-i.x)*(r.y-i.y)-(s.y-i.y)*(r.x-i.x),l=(h.x-r.x)*(r.y-i.y)-(h.y-r.y)*(r.x-i.x);if(0!==a){const t=o/a,r=l/a;t>=0&&t<=1&&r>=0&&r<=1&&e++}}if(e%2==1)return!0}return!1}}t.default=n},3174:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZAncestorTile=t.XYZAnchestorTile=void 0;const i=r(8819),s=r(1375);class a extends s.XYZTile{_ancestorMeshBuilder;_ancestorWebgl;_segmentsPerSide;_meshCache=new Map;constructor(e,t,r,s,a=new i.XYZMeshBuilder,o=16){super(e,t,r,s,a,o),this._ancestorMeshBuilder=a,this._ancestorWebgl=r,this._segmentsPerSide=o}draw(e,t,r,i,s,a,o){if("number"!=typeof e)return super.draw(e,t,r,i);if(!s||!a||void 0===o)return!1;const n=t,h=r,l=i;let c=!1;if(e<=this.coord.z)return super.draw(l,s,a,o);for(const e of n){if(!this.isAncestorOf(e))continue;const t=`${this.coord.z}/${this.coord.x}/${this.coord.y}`;if(!h.has(t))continue;const r=this.getRemappedMesh(e);c=super.drawRemapped(r,l,s,a,o)||c}return c}dispose(){for(const e of this._meshCache.values())e.positionBuffer&&this._ancestorWebgl.deleteBuffer(e.positionBuffer),e.uvBuffer&&this._ancestorWebgl.deleteBuffer(e.uvBuffer),e.indexBuffer&&this._ancestorWebgl.deleteBuffer(e.indexBuffer);this._meshCache.clear(),super.dispose()}getRemappedMesh(e){const t=`${e.z}/${e.x}/${e.y}->${this.coord.z}/${this.coord.x}/${this.coord.y}`,r=this._meshCache.get(t);if(r)return r;const i=this._ancestorMeshBuilder.buildAncestorMesh(e,this.coord,this._segmentsPerSide),s=this._ancestorMeshBuilder.uploadMesh(i,this._ancestorWebgl);return this._meshCache.set(t,s),s}isAncestorOf(e){if(e.z<=this.coord.z)return e.z===this.coord.z&&e.x===this.coord.x&&e.y===this.coord.y;const t=e.z-this.coord.z;return e.x>>t===this.coord.x&&e.y>>t===this.coord.y}}t.XYZAnchestorTile=a,t.XYZAncestorTile=a},3559:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueShaderProgram=void 0;const s=r(1961),a=i(r(5947));t.CatalogueShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix"},this.gl_attributes={vertex_pos:"aCatPosition",vertex_selected:"a_selected",point_size:"a_pointsize",point_hue:"a_brightness"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,hovered:-1,pointSize:-1,brightness:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=a.default.catalogueFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=a.default.catalogueVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),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,r){const i=this._webgl;i.useProgram(this.shaderProgram),this.locations.pMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let a=s.mat4.create();a=s.mat4.multiply(a,r,t),i.uniformMatrix4fv(this.locations.pMatrix,!1,e),i.uniformMatrix4fv(this.locations.mvMatrix,!1,a)}}},3726:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPS=void 0;const s=r(4735),a=r(229),o=i(r(619)),n=i(r(2885)),h=i(r(2368));class l extends s.AbstractSkyEntity{_ancestorTiles;_allSkyTile;_descriptor;_format;_baseurl;_maxorder;_minorder;_visibleorder=3;_allSky=!0;samplerIdx=0;colorMapIdx=0;colorMap=o.default.native;_healpixGrid;get maxOrder(){return this._maxorder}get minOrder(){return this._minorder}get baseURL(){return this._baseurl}get format(){return this._format}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}constructor(e,t,r,i,s,o,l){super(e,t,r,i,s.surveyName,o,s.isGalactic),this._descriptor=s,this.initGL(o),this._healpixGrid=l,this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this),console.log("HiPS frame "+s.hipsFrame),console.log("HiPS minOrder "+s.minOrder),this._format=s.imgFormats[0],this._baseurl=s.url,this._maxorder=s.maxOrder,this._minorder=s.minOrder,this.initShaders();let c=a.fovHelper.getHiPSNorder(180);if(this._visibleorder=Math.min(c,this._maxorder),this._ancestorTiles=[],this._allSkyTile=null,this._allSky=!0,this._allSky)this._allSkyTile=new h.default(this,this._webgl,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram);else for(let e=0;e<12;e++)this._ancestorTiles.push(new n.default(e,0,this,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram,this._webgl))}getProperty(e){return this._descriptor.getProperty(e)}changeFormat(e){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=o.default.grayscale,super.hipsShaderProgram.setGrayscaleShader();break;case"planck":this.colorMapIdx=2,this.colorMap=o.default.planck,super.hipsShaderProgram.setColorMapShader();break;case"cmb":this.colorMapIdx=3,this.colorMap=o.default.cmb,super.hipsShaderProgram.setColorMapShader();break;case"rainbow":this.colorMapIdx=4,this.colorMap=o.default.rainbow,super.hipsShaderProgram.setColorMapShader();break;case"eosb":this.colorMapIdx=5,this.colorMap=o.default.eosb,super.hipsShaderProgram.setColorMapShader();break;case"cubehelix":this.colorMapIdx=6,this.colorMap=o.default.cubehelix,super.hipsShaderProgram.setColorMapShader();break;case"hot":this.colorMapIdx=7,this.colorMap=o.default.hot,super.hipsShaderProgram.setColorMapShader();break;case"gray":this.colorMapIdx=8,this.colorMap=o.default.gray,super.hipsShaderProgram.setColorMapShader();break;case"native":this.colorMapIdx=0,this.colorMap=o.default.native,super.hipsShaderProgram.setNativeShader();break;default:this.colorMapIdx=9,this.colorMap=e,super.hipsShaderProgram.setColorMapShader()}}initShaders(){super.hipsShaderProgram.enableProgram()}getCurrentHealpixOrder(){return this._visibleorder}getDebugStats(){const e=this._healpixGrid.visibleTilesManager.tileBuffer,t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;return{activeBaseLayer:"hips",hipsName:this._descriptor.surveyName,hipsUrl:this._baseurl,isGalactic:this.isGalacticHips,currentOrder:t.order,visibleTileCount:t.pixels.length,activeTileCount:e.activeTileCount,cachedTileCount:e.cachedTileCount,cacheSize:e.size,readyTileCount:e.readyTileCount,loadingTileCount:e.loadingTileCount}}refresh(e){const t=e.fovDeg??this._healpixGrid.getMinFoV(),r=Number.isFinite(t)&&t>0?t:1e-6;this._visibleorder=Math.min(a.fovHelper.getHiPSNorder(r,this._visibleorder),this._maxorder)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const r=e.pMatrix;if(!r)return;this.refresh(e);const i=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,r,t,i,this.colorMapIdx):this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.ancestorsMap,r,t,i,this.colorMapIdx));const s=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order:this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,a=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galAncestorsMap:this._healpixGrid.visibleTilesManager.ancestorsMap;this._ancestorTiles.forEach(e=>{e.draw(s,a,r,t,i,this.colorMapIdx)})}}t.HiPS=l},3956:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WMTSAdapter=void 0,t.WMTSAdapter=class{_config;constructor(e){this._config=e}toXYZLayerConfig(){const e=this.getInferredMaxZoom();return{urlTemplate:this._config.urlTemplate??this._config.baseUrl,minZoom:this._config.minZoom,maxZoom:e,segmentsPerSide:this._config.segmentsPerSide,tileSize:this._config.tileSize,maxCachedTiles:this._config.maxCachedTiles,subdomains:this._config.subdomains,attribution:this._config.attribution,flipY:this._config.flipY,urlResolver:e=>this.getTileUrl(e)}}getInferredMaxZoom(){const e=this._config.matrixLabels?.length??0,t=e>0?e-1:void 0;return null==t?this._config.maxZoom:null==this._config.maxZoom?t:Math.min(this._config.maxZoom,t)}getTileUrl(e){return"rest"===this._config.requestEncoding?this.buildRestUrl(e):this.buildKvpUrl(e)}buildRestUrl(e){var t,r;return(t=this._config.urlTemplate??this._config.baseUrl,r=this.getCommonTokenValues(e),Object.entries(r).reduce((e,[t,r])=>e.replace(new RegExp(`\\{${t}\\}`,"g"),r),t)).replace(/(?<!:)\/{2,}/g,"/")}buildKvpUrl(e){const t=new URL(this._config.baseUrl),r=this.getCommonTokenValues(e),i=t.searchParams;i.set("SERVICE","WMTS"),i.set("REQUEST","GetTile"),i.set("VERSION",this._config.version??"1.0.0"),i.set("LAYER",this._config.layer),i.set("STYLE",this._config.style??"default"),i.set("FORMAT",this._config.format??"image/png"),i.set("TILEMATRIXSET",this._config.tileMatrixSet),i.set("TILEMATRIX",r.TileMatrix),i.set("TILEROW",r.TileRow),i.set("TILECOL",r.TileCol);for(const[e,t]of Object.entries(this._config.dimensions??{}))i.set(e,t);return t.toString()}getCommonTokenValues(e){const t=2**e.z,r=this._config.flipY?t-1-e.y:e.y,i=this._config.matrixLabels?.[e.z]??String(e.z),s=this._config.format??"image/png",a=s.replace(/^image\//,"");return{Layer:this._config.layer,Style:this._config.style??"default",Time:this._config.time??"",TileMatrixSet:this._config.tileMatrixSet,TileMatrix:i,TileRow:String(r),TileCol:String(e.x),Format:a,TileFormat:s,TileFormatExtension:a,...Object.fromEntries(Object.entries(this._config.dimensions??{}).map(([e,t])=>[e,t]))}}}},4006:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TileBuffer=void 0;const s=i(r(8256));t.TileBuffer=class{_tiles;_cachedTiles;_activeHiPS;_galTiles;_galCachedTiles;_galActiveHiPS;_cacheAliveMilliSeconds;_cleanerId;_webgl;_visibleTileManager;_hipsShaderProgram;constructor(e=1,t,r,i){this._hipsShaderProgram=r,this._visibleTileManager=i,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 r of this._activeHiPS.keys())e>r.maxOrder||this.getTile(t,e,r)}addGalTile(e,t){for(const r of this._galActiveHiPS.keys())e>r.maxOrder||this.getGalTile(t,e,r)}getTile(e,t,r){const i=this.key(t,e,r.baseURL);if(!this._tiles.has(i))if(this._cachedTiles.has(i)){const e=this._cachedTiles.get(i);this._tiles.set(i,e),this._cachedTiles.delete(i),e.resetCacheTime0()}else{const a=new s.default(e,t,r,this,this._webgl,this._visibleTileManager);this._tiles.set(i,a)}return this._tiles.get(i)}getGalTile(e,t,r){const i=this.key(t,e,r.baseURL);if(!this._galTiles.has(i))if(this._galCachedTiles.has(i)){const e=this._galCachedTiles.get(i);this._galTiles.set(i,e),this._galCachedTiles.delete(i),e.resetCacheTime0()}else{const a=new s.default(e,t,r,this,this._webgl,this._visibleTileManager);this._galTiles.set(i,a)}return this._galTiles.get(i)}moveTileToCache(e,t,r){const i=this.key(t,e,r.baseURL);if(this._tiles.has(i)){const e=this._tiles.get(i);e.setCacheTime0(),this._cachedTiles.set(i,e),this._tiles.delete(i)}if(this._galTiles.has(i)){const e=this._galTiles.get(i);e.setCacheTime0(),this._galCachedTiles.set(i,e),this._galTiles.delete(i)}}cacheCleaner(){const e=Date.now();for(const[t,r]of this._cachedTiles){const i=r.cacheTime0;!r.inView&&void 0!==i&&e-i>this._cacheAliveMilliSeconds&&(r.destroyIntervals(),this._cachedTiles.delete(t))}for(const[t,r]of this._galCachedTiles){const i=r.cacheTime0;!r.inView&&void 0!==i&&e-i>this._cacheAliveMilliSeconds&&(r.destroyIntervals(),this._galCachedTiles.delete(t))}}key(e,t,r){return`${e}#${t}#${r}`}dispose(){window.clearInterval(this._cleanerId)}get size(){return this._tiles.size+this._cachedTiles.size+this._galTiles.size+this._galCachedTiles.size}get activeTileCount(){return this._tiles.size+this._galTiles.size}get cachedTileCount(){return this._cachedTiles.size+this._galCachedTiles.size}get readyTileCount(){let e=0;for(const t of this._tiles.values())t.getReadyState()&&e++;for(const t of this._galTiles.values())t.getReadyState()&&e++;for(const t of this._cachedTiles.values())t.getReadyState()&&e++;for(const t of this._galCachedTiles.values())t.getReadyState()&&e++;return e}get loadingTileCount(){let e=0;for(const t of this._tiles.values())t.isLoading()&&e++;for(const t of this._galTiles.values())t.isLoading()&&e++;for(const t of this._cachedTiles.values())t.isLoading()&&e++;for(const t of this._galCachedTiles.values())t.isLoading()&&e++;return e}}},4322:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OBJMeshParser=void 0;class r{static parse(e){const t=[],i=[],s=[],a=e.split(/\r\n|\n/);for(const e of a){const a=e.trim();if(a&&!a.startsWith("#")){if(a.startsWith("v ")){const e=a.split(/\s+/);if(e.length<4)continue;t.push(Number(e[1]),Number(e[2]),Number(e[3])),s.push(0,0,0);continue}if(a.startsWith("f ")){const e=a.slice(2).trim().split(/\s+/).map(e=>Number(e.split("/")[0])).filter(e=>Number.isInteger(e)&&0!==e);if(e.length<3)continue;const s=r.resolveIndex(e[0],t.length/3);for(let a=1;a<e.length-1;a++)i.push(s,r.resolveIndex(e[a],t.length/3),r.resolveIndex(e[a+1],t.length/3))}}}return r.computeVertexNormals(t,i,s),{positions:new Float32Array(t),normals:new Float32Array(s),indices:new Uint32Array(i)}}static computeVertexNormals(e,t,r){for(let i=0;i<t.length;i+=3){const s=t[i],a=t[i+1],o=t[i+2],n=e[3*s],h=e[3*s+1],l=e[3*s+2],c=e[3*a]-n,u=e[3*a+1]-h,d=e[3*a+2]-l,_=e[3*o]-n,f=e[3*o+1]-h,g=e[3*o+2]-l,p=u*g-d*f,m=d*_-c*g,M=c*f-u*_;r[3*s]+=p,r[3*s+1]+=m,r[3*s+2]+=M,r[3*a]+=p,r[3*a+1]+=m,r[3*a+2]+=M,r[3*o]+=p,r[3*o+1]+=m,r[3*o+2]+=M}for(let e=0;e<r.length;e+=3){const t=r[e],i=r[e+1],s=r[e+2],a=Math.hypot(t,i,s)||1;r[e]=t/a,r[e+1]=i/a,r[e+2]=s/a}}static resolveIndex(e,t){return e>0?e-1:t+e}}t.OBJMeshParser=r},4382:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(1138),s=r(2919),a=new class{_healpix;_selectionnside;_useCORSProxy;_corsProxyUrl;_maxDecimals;_debug;_insideSphere;_version;constructor(){this._useCORSProxy=s.bootSetup.useCORSProxy,this._corsProxyUrl=s.bootSetup.corsProxyUrl,this._maxDecimals=s.bootSetup.maxDecimals,this._debug=s.bootSetup.debug,this._insideSphere=s.bootSetup.insideView,this._version=s.bootSetup.version,this._healpix={},this._selectionnside=32}init(){console.log("Global.init()")}get version(){return this._version}set corsProxyUrl(e){this._corsProxyUrl=e}get corsProxyUrl(){return this._corsProxyUrl}get useCORSProxy(){return this._useCORSProxy}set useCORSProxy(e){this._useCORSProxy=e}get debug(){return this._debug}getHealpix(e){return void 0===this._healpix[e]&&(this._healpix[e]=new i.Healpix(Math.pow(2,e))),this._healpix[e]}get MAX_DECIMALS(){return this._maxDecimals}set insideSphere(e){this._insideSphere=e}get insideSphere(){return this._insideSphere}get nsideForSelection(){return this._selectionnside}};t.default=a},4396:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(1961),a=r(1138),o=i(r(4382)),n=r(7930);t.default=class{_xyz=null;_raDecDeg=null;_phiThetaDeg=null;raHMS;decDMS;constructor(e,t,r){null!=e&&(this._xyz=e),null!=t&&(this._raDecDeg=t),null!=r&&(this._phiThetaDeg=r),this._raDecDeg&&(this.raHMS=(0,n.raDegToHMS)(this._raDecDeg.ra),this.decDMS=(0,n.decDegToDMS)(this._raDecDeg.dec))}computeNpix(){if(!this._xyz)return null;const e=o.default.getHealpix(o.default.nsideForSelection),t=new a.Vec3(this._xyz[0],this._xyz[1],this._xyz[2]),r=new a.Pointing(t,!1);return e.ang2pix(r,!1)}update(e){const t=(r=e,Array.isArray(r)?s.vec3.fromValues(r[0],r[1],r[2]):r);var r;const i=(0,n.cartesianToSpherical)(t),a=(0,n.sphericalToAstroDeg)(i.phi,i.theta);this._xyz=[t[0],t[1],t[2]],this._phiThetaDeg=i,this._raDecDeg=a,this.raHMS=(0,n.raDegToHMS)(a.ra),this.decDMS=(0,n.decDegToDMS)(a.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}}},4595:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HealpixGrid=void 0;const s=r(4735),a=i(r(4382)),o=r(1961),n=r(229),h=r(8083),l=r(5803),c=r(8145),u=r(6553),d=i(r(4707)),_=i(r(2930)),f=i(r(5361)),g=r(7930),p=r(2056),m=r(2919);class M extends s.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_visibleorder=0;showGrid=!1;_shaderProgram;fragmentShader;vertexShader;defaultColor="#ec0acaff";gridText=new f.default("healpix");_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(M.RADIUS,M.INITIAL_POSITION,M.INITIAL_PhiRad,M.INITIAL_ThetaRad,"healpix-grid",e),this.init(),this._visibleTilesManager=new p.VisibleTilesManager(this._webgl,super.hipsShaderProgram,this),this._visibleTilesManager.init(m.bootSetup.insideSphere)}init(){console.log("HealpixGridSingleton.init()"),this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders();const e=n.fovHelper.getHiPSNorder(M.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 l.SphereFoV(super.webgl)}get fovObj(){return this._fovObj}get RADIUS(){return M.RADIUS}get INITIAL_POSITION(){return M.INITIAL_POSITION}get INITIAL_PhiRad(){return M.INITIAL_PhiRad}get INITIAL_ThetaRad(){return M.INITIAL_ThetaRad}refreshFoV(e,t){return this._fovObj.getFoV(a.default.insideSphere,this,e,t)}getFoV(){return this._fovObj}getMinFoV(){return this._fovObj.minFoV}initShaders(){const e=super.webgl,t=d.default.healpixGridFS();if(this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this.fragmentShader,t),e.compileShader(this.fragmentShader),!e.getShaderParameter(this.fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this.fragmentShader)||"Fragment shader compile error");const r=d.default.healpixGridVS();this.vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this.vertexShader,r),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 r=a.default.getHealpix(t),i=a.default.getHealpix(t+1),s=a.default.getHealpix(t+2);let o=0,n=0;this._indexes=new Uint32Array(17*e.length),this._vertexCataloguePosition=new Float32Array(48*e.length);for(let t=0;t<e.length;t++){const a=r.getBoundaries(e[t]),h=e[t]<<2,l=h+1,c=h+2,u=h+3,d=i.getBoundaries(h),_=i.getBoundaries(u),f=e=>{this._vertexCataloguePosition[o]=1*e.x,this._vertexCataloguePosition[o+1]=1*e.y,this._vertexCataloguePosition[o+2]=1*e.z,this._indexes[n]=Math.floor(o/3),n+=1,o+=3};f(a[0]);let g=3+(u<<2),p=s.getBoundaries(g);f(p[1]),f(_[1]);let m=2+(c<<2);p=s.getBoundaries(m),f(p[0]),f(a[1]),f(p[2]),f(d[1]);let M=h<<2;p=s.getBoundaries(M),f(p[1]),f(a[2]),f(p[3]),f(d[3]);let x=1+(l<<2);p=s.getBoundaries(x),f(p[2]),f(a[3]),f(p[0]),f(_[3]),p=s.getBoundaries(g),f(p[3]),this._indexes[n]=4294967295,this._nPrimitiveFlags+=1,n+=1}}refresh(e,t){this.refreshFoV(e,t);const r=this.getMinFoV();this._visibleorder=n.fovHelper.getHiPSNorder(r,this._visibleorder)}enableShader(e,t,r){const i=super.webgl;i.useProgram(this._shaderProgram);const s=i.getUniformLocation(this._shaderProgram,"uMVMatrix"),a=i.getUniformLocation(this._shaderProgram,"uPMatrix"),n=super.webgl.getUniformLocation(this._shaderProgram,"u_fragcolor");this._attribLocations.position=i.getAttribLocation(this._shaderProgram,"aCatPosition");let h=o.mat4.create();if(h=o.mat4.multiply(h,r,e),s&&i.uniformMatrix4fv(s,!1,h),a&&i.uniformMatrix4fv(a,!1,t),n){const e=(0,g.colorHex2RGB)(this.defaultColor);i.uniform4f(n,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}get visibleTilesManager(){return this._visibleTilesManager}draw(e){const t=super.webgl,r=this.getModelMatrix(),i=e.camera;if(!i)return;const s=i.getCameraMatrix(),l=e.pMatrix;if(!l)return;const d=e.fovDeg??this.getMinFoV(),f=Number.isFinite(d)&&d>0?d:1e-6;if(this._visibleorder=n.fovHelper.getHiPSNorder(f,this._visibleorder),!this.showGrid)return void this.gridText.resetDivSets();const g=this._visibleTilesManager.visibleTilesByOrder,p=g.pixels,m=g.order;this.initBuffers(p,m),this.enableShader(r,l,s),t.bindBuffer(t.ARRAY_BUFFER,this._vertexCataloguePositionBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexCataloguePosition,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,M.ELEM_SIZE,t.FLOAT,!1,M.BYTES_X_ELEM*M.ELEM_SIZE,0),t.enableVertexAttribArray(this._attribLocations.position),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indexes,t.STATIC_DRAW),t.drawElements(t.LINE_LOOP,this._vertexCataloguePosition.length/3+this._nPrimitiveFlags,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);let x=o.mat4.create();x=o.mat4.multiply(x,s,r);let v=o.mat4.create();v=o.mat4.multiply(v,l,x);const b=h.FoVUtils.getCenterJ2000(t.canvas,this,this._webgl,i,l),S=this.getMinFoV()*Math.PI/180/2;for(let e=0;e<p.length;e++){const r=a.default.getHealpix(this._visibleorder).pix2vec(p[e]),i=new u.Point({x:r.x,y:r.y,z:r.z},c.CoordsType.CARTESIAN);if(_.default.orthodromicDistance(b,i)<S){const i=[r.x,r.y,r.z,1],s=o.vec4.create();o.vec4.transformMat4(s,i,v),s[0]/=s[3],s[1]/=s[3];const a=t.canvas.getBoundingClientRect(),n=a.left+(.5*s[0]+.5)*a.width,h=a.top+(-.5*s[1]+.5)*a.height;this.gridText.addHPXDivSet(this._visibleorder+"/"+p[e],n,h)}}this.gridText.resetDivSets(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}get visibleorder(){return this._visibleorder}}t.HealpixGrid=M},4639:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(1961);class s{static lastNearestVisibleObjectIdx=-1;static getNearestVisibleObjectIdx(){return this.lastNearestVisibleObjectIdx}static getRayFromMouse(e,t,r,a,o){const n=a.canvas.getBoundingClientRect(),h=t,l=[2*e/n.width-1,1-2*h/n.height,-1,1],c=i.mat4.create();i.mat4.invert(c,r);const u=[0,0,0,0];s.mat4MultiplyVec4(c,l,u);const d=[u[0],u[1],-1,0],_=i.mat4.create();i.mat4.invert(_,o);const f=[0,0,0,0];s.mat4MultiplyVec4(_,d,f);const g=i.vec3.fromValues(f[0],f[1],f[2]);return i.vec3.normalize(g,g),g}static mat4MultiplyVec4(e,t,r){const i=t[0],s=t[1],a=t[2],o=t[3];return r[0]=e[0]*i+e[4]*s+e[8]*a+e[12]*o,r[1]=e[1]*i+e[5]*s+e[9]*a+e[13]*o,r[2]=e[2]*i+e[6]*s+e[10]*a+e[14]*o,r[3]=e[3]*i+e[7]*s+e[11]*a+e[15]*o,r}static raySphere(e,t,r){let s=-1;const a=i.vec3.create();i.vec3.subtract(a,e,r.center);const o=i.vec3.dot(t,a),n=o*o-(i.vec3.dot(a,a)-r.radius*r.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,r=-o-e;t<0&&r<0||(s=r<0?t:Math.min(t,r))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}static getIntersectionPointWithSingleModel(e,t,r,a,o,n){const h=o.getCameraMatrix(),l=s.getRayFromMouse(e,t,n,a,h),c=s.raySphere(o.getCameraPosition(),l,r);let u=[];if(c>=0){const e=i.vec3.create();i.vec3.scale(e,l,c),i.vec3.add(e,o.getCameraPosition(),e);const t=[e[0],e[1],e[2],1],a=[0,0,0,0];s.mat4MultiplyVec4(r.getModelMatrixInverse(),t,a),u=[a[0],a[1],a[2]]}return u}}t.default=s},4707:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static healpixGridVS(){return"#version 300 es\n in vec4 aCatPosition;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = 7.0;\n }"}static healpixGridFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n // fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n fragColor = u_fragcolor;\n }"}}},4723:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(2919),a=i(r(7734)),o=i(r(4639)),n=i(r(4382)),h=i(r(4396)),l=r(7930),c=r(3726),u=r(9685),d=r(6553),_=r(8083),f=r(9839),g=r(4595),p=r(8145),m=i(r(619)),M=r(5409),x=r(3956),v=r(8868),b=r(1741),S=r(6878),P=r(1961);class y{static MIN_WHEEL_SCALE=.85;static MAX_WHEEL_SCALE=1.8;_camera;_perspectiveMatrixManager;centralPoinCoords;mousePointCoords;canvas;_healpixGrid;_equatorialGrid;mouseHelper;mouseDown=!1;lastMouseX=null;lastMouseY=null;inertiaX=0;inertiaY=0;zoomInertia=0;pointerDownX=null;pointerDownY=null;pointerDownAt=0;_activeHiPS=null;_activeXYZ2=null;_activeMeshHiPS=null;_activeBaseLayer=null;startup=!0;fov;activeCatalogues=[];activeFootprintSets=[];_webgl;_selectedColorMap;_cameraStatusChanged=!1;lastCameraChangedAt=0;lastCameraMotionAt=0;lastHoveredSource=null;lastHoveredCatalogue=null;zoomSensitivity=1;lockedEastWestRaDeg=null;lockedNorthSouthDecDeg=null;keepCameraNorthUp=!0;constructor(e,t){console.log("[AstroSphere] new instance for canvas",e.id),this._webgl=t,this.mouseHelper=new h.default,this.canvas=e,this._selectedColorMap=m.default.native,n.default.insideSphere=s.bootSetup.insideSphere,this.initCamera(),this._healpixGrid=new g.HealpixGrid(this._webgl),this._perspectiveMatrixManager=new u.PerspectiveMatrixManager(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._equatorialGrid=new f.EquatorialGrid(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(){s.bootSetup.insideSphere?this._camera=new a.default([0,0,-.005],!0):this._camera=new a.default([0,0,4],!1)}setCamera(e){this._camera=e}setCameraRotationSensitivity(e){this._camera.setRotationSensitivity(e)}getCameraRotationSensitivity(){return this._camera.getRotationSensitivity()}get healpixGrid(){return this._healpixGrid}get equatorialGrid(){return this._equatorialGrid}updateCentralPoint(){const e=this.getPhiThetaDeg(this.canvas),t=(0,l.sphericalToAstroDeg)(e.phi,e.theta),r=(0,l.raDegToHMS)(t.ra),i=(0,l.decDegToDMS)(t.dec);return this.centralPoinCoords={astroDeg:t,sphericalDeg:e,raHMS:r,decDMS:i},this.centralPoinCoords}updateLastMousePoint(){const e={phi:this.mouseHelper.phi,theta:this.mouseHelper.theta},t={ra:this.mouseHelper.ra,dec:this.mouseHelper.dec},r=this.mouseHelper.raHMS,i=this.mouseHelper.decDMS;return this.mousePointCoords={astroDeg:t,sphericalDeg:e,raHMS:r,decDMS:i},this.mousePointCoords}clearLastMousePoint(){this.mousePointCoords=void 0}getCentralPointCoordinates(){return this.centralPoinCoords}getLastMousePointCoordinates(){return this.mousePointCoords}clamp(e,t,r){return Math.min(r,Math.max(t,e))}computeZoomStep(e,t){const r=t<0?-1:1,i=this.clamp(Math.abs(t)/120,y.MIN_WHEEL_SCALE,y.MAX_WHEEL_SCALE);return r*this.clamp(.0012+.0025*Math.sqrt(Math.max(e,0)),.0012,.04)*i*this.zoomSensitivity}setZoomSensitivity(e){this.zoomSensitivity=this.clamp(e,.2,3)}getZoomSensitivity(){return this.zoomSensitivity}filterRotationDeltaByAstroLocks(e,t){const r=this._camera.isRotationLockedY(),i=this._camera.isRotationLockedX();if(!r&&!i)return{deltaX:e,deltaY:t};const s=o.default.getIntersectionPointWithSingleModel(this.canvas.clientWidth/2,this.canvas.clientHeight/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!s||s.length<3)return{deltaX:e,deltaY:t};const a=P.vec3.normalize(P.vec3.create(),P.vec3.fromValues(s[0],s[1],s[2])),n=P.vec3.fromValues(0,0,1),h=P.vec3.cross(P.vec3.create(),n,a);P.vec3.length(h)<1e-6?P.vec3.set(h,1,0,0):P.vec3.normalize(h,h);const l=P.vec3.scale(P.vec3.create(),a,P.vec3.dot(n,a)),c=P.vec3.subtract(P.vec3.create(),n,l);P.vec3.length(c)<1e-6&&P.vec3.cross(c,a,h),P.vec3.normalize(c,c);const u=this.projectModelDirectionToScreen(a,h),d=this.projectModelDirectionToScreen(a,c);if(!u||!d)return{deltaX:e,deltaY:t};let _=e,f=t;if(r){const e=_*u.x+f*u.y;_-=e*u.x,f-=e*u.y}if(i){const e=_*d.x+f*d.y;_-=e*d.x,f-=e*d.y}return{deltaX:_,deltaY:f}}projectModelDirectionToScreen(e,t){const r=P.vec3.scaleAndAdd(P.vec3.create(),e,t,.01),i=this.projectModelPointToScreen(e),s=this.projectModelPointToScreen(r);if(!i||!s)return null;const a=s.x-i.x,o=s.y-i.y,n=Math.hypot(a,o);return n<1e-6?null:{x:a/n,y:o/n}}projectModelPointToScreen(e){const t=this._camera.getCameraMatrix(),r=this._healpixGrid.getModelMatrix(),i=P.mat4.create(),s=P.mat4.create();P.mat4.multiply(i,t,r),P.mat4.multiply(s,this._perspectiveMatrixManager.pMatrix,i);const a=P.vec4.fromValues(e[0],e[1],e[2],1);return P.vec4.transformMat4(a,a,s),Math.abs(a[3])<1e-6?null:{x:a[0]/a[3],y:-a[1]/a[3]}}enforceAstronomicalRotationLocks(){if(null==this.lockedEastWestRaDeg&&null==this.lockedNorthSouthDecDeg)return!1;const e=this.updateCentralPoint();if(!e)return!1;const t=this.lockedEastWestRaDeg??e.astroDeg.ra,r=this.lockedNorthSouthDecDeg??e.astroDeg.dec;return(Math.abs(t-e.astroDeg.ra)>1e-6||Math.abs(r-e.astroDeg.dec)>1e-6)&&(this._camera.goTo(t,r),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}enforceCameraNorthUp(){if(!this.keepCameraNorthUp)return!1;const e=this.updateCentralPoint();return!!e&&(this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}emitCameraChanged(e){if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid?.fovObj)return;const t=this.getCurrentStatus();t&&this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:t,bubbles:!0,composed:!0}))}addEventListeners(e){n.default.debug&&console.log("[AstroSphere::addEventListeners]");const t=e.getBoundingClientRect();this.lastMouseX=t.left,this.lastMouseY=t.top,console.log("[AstroSphere] registering pointer and wheel listeners on canvas"),e.onpointerdown=t=>{e.setPointerCapture(t.pointerId),this.mouseDown=!0;const r=e.getBoundingClientRect();this.lastMouseX=t.clientX-r.left,this.lastMouseY=t.clientY-r.top,this.pointerDownX=this.lastMouseX,this.pointerDownY=this.lastMouseY,this.pointerDownAt=Date.now();const i=o.default.getIntersectionPointWithSingleModel(this.lastMouseX,this.lastMouseY,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return i&&i.length>0?(this.mouseHelper.update(i),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 r=e.getBoundingClientRect(),i=t.clientX-r.left,s=t.clientY-r.top;this.lastMouseX=i,this.lastMouseY=s;const a=Math.hypot(i-(this.pointerDownX??i),s-(this.pointerDownY??s)),n=Date.now()-this.pointerDownAt;if(a<=4&&n<=250){const e=o.default.getIntersectionPointWithSingleModel(i,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(e&&e.length>0){this.mouseHelper.update(e),this.updateLastMousePoint();for(const e of this.activeCatalogues){const t=e.selectPrimarySourceFromClick(this.mouseHelper);t?.sources.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("source-clicked",{detail:{source:t.sources,selectionState:t.selectionState,catalogue:e},bubbles:!0,composed:!0}))}for(const e of this.activeFootprintSets){const t=e.selectPrimaryFootprintFromClick(this.mouseHelper);t?.footprints.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-clicked",{detail:{footprint:t.footprints,selectionState:t.selectionState,footprintSet:e},bubbles:!0,composed:!0}))}}}else this.clearLastMousePoint()},e.onpointermove=t=>{const r=e.getBoundingClientRect(),i=t.clientX-r.left,s=t.clientY-r.top,a=i,h=s;if(this._healpixGrid){if(this.mouseDown){document.body.style.cursor="grab";const t=n.default.insideSphere?-1:1,r=n.default.insideSphere?10:1,i=t*r*(a-(this.lastMouseX??a))*Math.PI/e.width,s=t*r*(h-(this.lastMouseY??h))*Math.PI/e.height,o=this.filterRotationDeltaByAstroLocks(i,s);this.inertiaX+=.1*o.deltaX,this.inertiaY+=.1*o.deltaY,this.updateCentralPoint()}else{const e=o.default.getIntersectionPointWithSingleModel(i,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);e&&e.length>0?(this.mouseHelper.update(e),this.updateLastMousePoint()):this.clearLastMousePoint()}this.centralPoinCoords||this.updateCentralPoint(),this.lastMouseX=a,this.lastMouseY=h,this._cameraStatusChanged=!0,t.preventDefault()}},e.onpointerleave=()=>{this.clearLastMousePoint(),this._cameraStatusChanged=!0,this.emitCameraChanged("pointerleave")},console.log("[AstroSphere] adding wheel event listener with passive: false"),e.addEventListener("wheel",e=>{const t=this._healpixGrid.getMinFoV(),r=this.computeZoomStep(t,e.deltaY);this.zoomInertia=0,this._camera.zoom(r),this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this._cameraStatusChanged=!0,this.emitCameraChanged("wheel"),e.preventDefault()},{passive:!1}),e.addEventListener("contextmenu",t=>{t.preventDefault();const r=e.getBoundingClientRect(),i=t.clientX-r.left,s=t.clientY-r.top,a=o.default.getIntersectionPointWithSingleModel(i,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!a||0===a.length)return!1;this.mouseHelper.update(a),this.updateLastMousePoint();for(const e of this.activeCatalogues){const r=e.getSourcesFromPointer(this.mouseHelper);if(r?.sources.length){this._webgl.canvas.dispatchEvent(new CustomEvent("source-contextmenu",{detail:{source:r.sources,catalogue:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}for(const e of this.activeFootprintSets){const r=e.getFootprintsFromPointer(this.mouseHelper);if(r?.footprints.length){this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-contextmenu",{detail:{footprint:r.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(),r=t.width,i=t.height,s=o.default.getIntersectionPointWithSingleModel(r/2,i/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return(0,l.cartesianToSpherical)(s)}collectViewportSphericalSamples(e=5){const t=this.canvas.getBoundingClientRect(),r=t.width,i=t.height,s=[];for(let t=0;t<e;t++){const a=1===e?r/2:t/(e-1)*r;for(let t=0;t<e;t++){const r=1===e?i/2:t/(e-1)*i,n=o.default.getIntersectionPointWithSingleModel(a,r,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);n&&n.length>0&&s.push((0,l.cartesianToSpherical)(n))}}return s}activateHiPS(e){this._activeHiPS=new c.HiPS(1,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="hips"}activateXYZ(e){this.activateXYZ2(new v.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver)),this._activeBaseLayer="xyz"}activateXYZ2(e){this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,e,this._webgl),this._activeBaseLayer="xyz"}activateMeshHiPS(e){this._activeMeshHiPS=new S.MeshHiPS(e.meshRadius,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="meships"}activateWMTS(e){const t=new x.WMTSAdapter(e).toXYZLayerConfig();this._activeXYZ2=new b.XYZMap(1,[0,0,0],0,0,new v.XYZMapDescriptor(e.layer?`WMTS ${e.layer}`:"WMTS Earth2 Layer",t.urlTemplate,t.minZoom??0,t.maxZoom??8,t.segmentsPerSide??48,t.maxCachedTiles??384,8,t.urlResolver),this._webgl),this._activeBaseLayer="xyz"}async showCatalogue(e){return e&&this.activeCatalogues.push(e),e}deleteCatalogue(e){this.activeCatalogues=this.activeCatalogues.filter(t=>t!==e)}async showFootprintSet(e){return e&&this.activeFootprintSets.push(e),e}deleteFootprintSet(e){this.activeFootprintSets=this.activeFootprintSets.filter(t=>t!==e)}getHoveredFootprints(){let e=[];return this.activeFootprintSets.forEach(t=>{e.push(t.hoveredFootprints)}),e}goTo(e,t){this._camera.goTo(e,t)}getActiveCoordinateMode(){return"xyz"===this._activeBaseLayer?"lonlat":"hips"===this._activeBaseLayer&&this._activeHiPS?.isGalacticHips?"galactic":"equatorial"}resetAxesOrientation(){const e=this.updateCentralPoint();e&&(this.inertiaX=0,this.inertiaY=0,this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),this._cameraStatusChanged=!0)}setKeepCameraNorthUp(e){this.keepCameraNorthUp=e,e&&this.resetAxesOrientation()}isKeepCameraNorthUp(){return this.keepCameraNorthUp}getFoV(){return"xyz"===this._activeBaseLayer&&this._activeXYZ2?this._activeXYZ2.getFoV():this.fov}getFoVPolygon(){if(null==this.healpixGrid)throw new Error(`healpixGrid is ${this.healpixGrid}`);return _.FoVUtils.getFoVPolygon(this._camera,this.canvas,this._healpixGrid,this._healpixGrid,this._webgl,this._perspectiveMatrixManager.pMatrix)}changeFoV(e){const t=this._healpixGrid.getFoV().computeDistanceFromAngle(e);this._camera.translate(t),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}changeFoV2(e){const t=this._healpixGrid.getFoV().computeCameraPositionForFoV(e);this._camera.setCameraPosition(t)}changeFoV3(e){const t=this._healpixGrid.getFoV().computeCameraPositionForAngularDiameter(e);this._camera.setCameraPosition(t),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,!1)}getInsideSphere(){return n.default.insideSphere}toggleInsideSphere(){const e=this.updateCentralPoint();this.inertiaX=0,this.inertiaY=0,this.zoomInertia=0,n.default.insideSphere=!n.default.insideSphere,this._camera.toggleInsideSphere(),this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.updateCentralPoint(),this.lastCameraMotionAt=performance.now(),this._cameraStatusChanged=!0,this.emitCameraChanged("inside-sphere-toggle"),requestAnimationFrame(()=>this.draw(this.canvas))}setCameraPosition(e){this._camera.setCameraPosition(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}setCameraMatrix(e){this._camera.setCameraMatrix(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}_refreshingStatus=!1;applyFullCameraState(e,t){this._refreshingStatus=!0,this._camera=e.camera,this._healpixGrid.setModelMatrix(e.mMatrix),this._perspectiveMatrixManager.pMatrix=e.pMatrix,this.setCameraMatrix(e.vMatrix),t&&this._activeHiPS?.changeColorMap(e.colorMap),this._refreshingStatus=!1}getCurrentStatus(){this.updateCentralPoint();const e=this.centralPoinCoords?.astroDeg.ra,t=this.centralPoinCoords?.astroDeg.dec;if(null==e||null==t)return null;let r=[];try{r=this.getFoVPolygon()}catch(e){console.warn("[AstroSphere] getCurrentStatus: FoV polygon is not available.",e)}return{fovDeg:this.fov.minFoV,fovXDeg:this.fov.xFoV,fovYDeg:this.fov.yFoV,position:this._camera.getCameraPosition(),vMatrix:this._camera.getCameraMatrix(),pMatrix:this._perspectiveMatrixManager.pMatrix,mMatrix:this._healpixGrid.getModelMatrix(),camera:this._camera,timestamp:performance.now(),centralPoint:new d.Point({raDeg:e,decDeg:t},p.CoordsType.ASTRO),mouseHoverPoint:this.mousePointCoords,colorMap:this._selectedColorMap,getFoVPolygon:r}}changeColorMap(e){(this._activeHiPS||this._activeXYZ2||this._activeMeshHiPS)&&(this._selectedColorMap=e,this._activeHiPS?.changeColorMap(e),this._activeXYZ2?.changeColorMap(e))}prevFov=0;prevCentralRaDeg=null;prevCentralDecDeg=null;get activeHiPS(){return this._activeHiPS}get activeXYZ(){return this._activeXYZ2}get activeMeshHiPS(){return this._activeMeshHiPS}isLonLatGridVisible(){return this._activeXYZ2?.isLonLatGridVisible()??!1}toggleLonLatGrid(){return this._activeXYZ2?.toggleLonLatGrid()??!1}setEastWestRotationLocked(e){this._camera.setRotationLock({y:e}),e&&(this.inertiaX=0),this.lockedEastWestRaDeg=e?this.updateCentralPoint()?.astroDeg.ra??null:null}isEastWestRotationLocked(){return this._camera.isRotationLockedY()}setNorthSouthRotationLocked(e){this._camera.setRotationLock({x:e}),e&&(this.inertiaY=0),this.lockedNorthSouthDecDeg=e?this.updateCentralPoint()?.astroDeg.dec??null:null}isNorthSouthRotationLocked(){return this._camera.isRotationLockedX()}getXYZDebugStats(){return{activeBaseLayer:this._activeBaseLayer,layer:this._activeXYZ2?.getDebugStats()??null,requests:M.xyzTileRequestScheduler.getDebugStats()}}getHiPSDebugStats(){return this._activeHiPS?this._activeHiPS.getDebugStats():null}getMeshHiPSDebugStats(){return this._activeMeshHiPS?this._activeMeshHiPS.getDebugStats():null}draw(e){if(this._refreshingStatus)return;if(!this._webgl)return;if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid||0===Object.keys(this._healpixGrid).length)return;if(void 0===this._healpixGrid.fovObj)return;this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);let t=!1,r=0,i=0;if(this._webgl.viewport(0,0,this._webgl.drawingBufferWidth,this._webgl.drawingBufferHeight),this._webgl.clear(this._webgl.COLOR_BUFFER_BIT|this._webgl.DEPTH_BUFFER_BIT),0!==this.zoomInertia&&(Math.abs(this.zoomInertia)>1e-4?(this._camera.zoom(this.zoomInertia),this.zoomInertia*=.95,this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.prevFov!==this.fov.minFoV&&(this.centralPoinCoords||(this.centralPoinCoords=this.updateCentralPoint()),this.prevFov=this.fov.minFoV)):this.zoomInertia=0,this._cameraStatusChanged=!0),this.mouseDown||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02){t=!0;const a=this.filterRotationDeltaByAstroLocks(this.inertiaX,this.inertiaY);i=a.deltaX,r=a.deltaY,this.inertiaX=.95*a.deltaX,this.inertiaY=.95*a.deltaY,this._camera.rotate(i,r),this.lastCameraMotionAt=performance.now(),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.enforceAstronomicalRotationLocks()||this.enforceCameraNorthUp()}else this.inertiaY=0,this.inertiaX=0;const a=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix);if(Number.isFinite(a.minFoV)&&a.minFoV>0&&(this.fov=a,this._camera.refreshFoV(this.fov.minFoV),this.prevFov=this.fov.minFoV),t){const e=this.updateCentralPoint(),t=e.astroDeg.ra,r=e.astroDeg.dec,i=null===this.prevCentralRaDeg||Math.abs(t-this.prevCentralRaDeg)>1e-5,s=null===this.prevCentralDecDeg||Math.abs(r-this.prevCentralDecDeg)>1e-5;(i||s)&&(this.prevCentralRaDeg=t,this.prevCentralDecDeg=r)}if(this._cameraStatusChanged){const e=performance.now(),t=!this.mouseDown||e-this.lastCameraChangedAt>100,r=t?this.getCurrentStatus():null;r&&(this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:r,bubbles:!0,composed:!0})),this.lastCameraChangedAt=e),!this.startup&&t&&(this._cameraStatusChanged=!1)}if(this._webgl.disable(this._webgl.DEPTH_TEST),this._webgl.enable(this._webgl.BLEND),this._webgl.enable(this._webgl.CULL_FACE),this._webgl.cullFace(n.default.insideSphere?this._webgl.FRONT:this._webgl.BACK),this._webgl.blendFunc(this._webgl.SRC_ALPHA,this._webgl.ONE_MINUS_SRC_ALPHA),"hips"===this._activeBaseLayer&&this._activeHiPS){const e=Math.min(this._healpixGrid.visibleorder,this._activeHiPS.maxOrder);this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}if("meships"===this._activeBaseLayer&&this._activeMeshHiPS){const e=this._activeMeshHiPS.refreshOrder(this.fov?.minFoV??this._healpixGrid.getMinFoV());this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}const o=this.fov?.minFoV??this._healpixGrid.getMinFoV(),h=performance.now(),c=this.mouseDown||Math.abs(this.zoomInertia)>1e-4||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02||h-this.lastCameraMotionAt<220,u={fovDeg:o,camera:this._camera,pMatrix:this._perspectiveMatrixManager.pMatrix,centerSphericalDeg:this.updateCentralPoint().sphericalDeg,fovPolygon:void 0,viewportSphericalSamples:void 0,cameraMoving:c};if("hips"===this._activeBaseLayer&&this._activeHiPS?.draw(u),"xyz"===this._activeBaseLayer&&this._activeXYZ2?.draw(u),"meships"===this._activeBaseLayer&&this._activeMeshHiPS?.draw(u),this._healpixGrid.draw(u),this._equatorialGrid.draw(u),this._webgl.enable(this._webgl.DEPTH_TEST),this._webgl.disable(this._webgl.CULL_FACE),this.startup){this.startup=!1;const t=this.getPhiThetaDeg(e),r=(0,l.sphericalToAstroDeg)(t.phi,t.theta),i=(0,l.raDegToHMS)(r.ra),s=(0,l.decDegToDMS)(r.dec);this.prevFov=this.fov?.minFoV??this._healpixGrid.getMinFoV(),this._cameraStatusChanged=!0,console.log("(startup coords)",{raDeg:r.ra,decDeg:r.dec,raHMS:i,decDMS:s})}this.activeCatalogues.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.emitHoveredSourceIfChanged(),this.activeFootprintSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)})}emitHoveredSourceIfChanged(){let e=null,t=null;for(const r of this.activeCatalogues){const i=r.getPrimaryHoveredSource();if(i){e=i,t=r;break}}e===this.lastHoveredSource&&t===this.lastHoveredCatalogue||(this.lastHoveredSource=e,this.lastHoveredCatalogue=t,this._webgl.canvas.dispatchEvent(new CustomEvent("source-hovered",{detail:{source:e,catalogue:t},bubbles:!0,composed:!0})))}}t.default=y},4735:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractSkyEntity=void 0;const i=r(1961),s=r(7786);t.AbstractSkyEntity=class{refreshMe=!1;fovX_deg=180;fovY_deg=180;xRad;yRad;prevFoV=this.fovX_deg;_name;center;radius;isGalacticHips;vertexTextureCoordBuffer=null;vertexPositionBuffer=null;vertexIndexBuffer=null;shaderProgram=null;T=i.mat4.create();R=i.mat4.create();modelMatrix=i.mat4.create();inverseModelMatrix=i.mat4.create();galacticMatrixInverted=i.mat4.create();_webgl;_hipsShaderProgram;constructor(e,t,r,a,o,n,h){this._webgl=n,this.xRad=r,this.yRad=a,this._name=o,this.center=i.vec3.clone(t),this.radius=e,this.isGalacticHips=!!h,i.mat4.set(this.galacticMatrixInverted,-.054875582456588745,-.8734370470046997,-.48383501172065735,0,.49410945177078247,-.4448296129703522,.7469822764396667,0,-.8676661849021912,-.19807636737823486,.4559837877750397,0,0,0,0,1),this._hipsShaderProgram=new s.HiPSShaderProgram(this._webgl)}get name(){return this._name}get hipsShaderProgram(){return this._hipsShaderProgram}get webgl(){return this._webgl}initGL(e){this.vertexTextureCoordBuffer=e.createBuffer(),this.vertexPositionBuffer=e.createBuffer(),this.vertexIndexBuffer=e.createBuffer(),this.shaderProgram=e.createProgram(),this.T=i.mat4.create(),this.R=i.mat4.create(),this.modelMatrix=i.mat4.create(),this.inverseModelMatrix=i.mat4.create(),this.translate(this.center),this.rotate(this.xRad,this.yRad)}translate(e){i.mat4.translate(this.T,this.T,e),this.refreshModelMatrix()}rotate(e,t){i.mat4.rotate(this.R,this.R,t,[0,0,1]),i.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshModelMatrix()}rotateFromZero(e,t){i.mat4.identity(this.R),i.mat4.rotate(this.R,this.R,e,[1,0,0]),i.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshModelMatrix()}refreshModelMatrix(){const e=i.mat4.create();i.mat4.invert(e,this.R),i.mat4.multiply(this.modelMatrix,this.T,e),this.isGalacticHips&&i.mat4.multiply(this.modelMatrix,this.modelMatrix,this.galacticMatrixInverted)}getModelMatrixInverse(){return i.mat4.identity(this.inverseModelMatrix),i.mat4.invert(this.inverseModelMatrix,this.modelMatrix),this.inverseModelMatrix}getModelMatrix(){return this.modelMatrix}setModelMatrix(e){this.modelMatrix=e}setGeometryNeedsToBeRefreshed(){this.refreshGeometryOnFoVChanged=!1}rotateX(e,t){const r=Math.cos(t),i=Math.sin(t),s=e[1],a=e[5],o=e[9];return e[1]=e[1]*r-e[2]*i,e[5]=e[5]*r-e[6]*i,e[9]=e[9]*r-e[10]*i,e[2]=e[2]*r+s*i,e[6]=e[6]*r+a*i,e[10]=e[10]*r+o*i,e}rotateY(e,t){const r=Math.cos(t),i=Math.sin(t),s=e[0],a=e[4],o=e[8];return e[0]=r*e[0]+i*e[2],e[4]=r*e[4]+i*e[6],e[8]=r*e[8]+i*e[10],e[2]=r*e[2]-i*s,e[6]=r*e[6]-i*a,e[10]=r*e[10]-i*o,e}}},5087:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSDescriptor=void 0,t.HiPSDescriptor=class{_minOrder=3;_imgformats=[];_datarange={min:void 0,max:void 0};_maxOrder;_tilewidth;_hipsFrame;_hipsName="NONAME";_hipsurl;_emMin;_emMax;_isGalctic=!1;_propertiesRawText;_propertiesMap=new Map;constructor(e,t){this._hipsurl=t,this._propertiesRawText=e;const r=e.split(/\r\n|\n/);for(const e of r){const t=e.trim();if(!t||t.startsWith("#"))continue;const r=t.slice(0,t.indexOf("=")).trim(),i=this.getValue(t);if(r&&void 0!==i&&this._propertiesMap.set(r,i),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,r]=e.split(/\s+/);this._datarange.min=parseFloat(t),this._datarange.max=parseFloat(r)}}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}}},5361:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class r{static layers=new Map;layer;constructor(e="equatorial"){this.layer=e,r.getLayerState(e)}initHtml(){r.getLayerState(this.layer)}resetDivSets(e=this.layer){const t=r.getLayerState(e);for(;t.divSetNdx<t.divSets.length;++t.divSetNdx)t.divSets[t.divSetNdx].style.display="none";t.divSetNdx=0}addHPXDivSet(e,t,r){this.addLabel("healpix",e,t+25,r,"hpx")}addEqDivSet(e,t,r,i){this.addLabel("equatorial",e,"ra"===i?t+25:t,"ra"===i?r:r+25,i)}addLonLatDivSet(e,t,r,i){this.addLabel("lonlat",e,"lon"===i?t+25:t,"lon"===i?r:r+25,i)}addLabel(e,t,i,s,a){const o=r.getLayerState(e);if(!o.container)return;let n=o.divSets[o.divSetNdx++];if(!n){const e=document.createElement("div"),t=document.createTextNode("");e.appendChild(t),o.container.appendChild(e),n={div:e,textNode:t,style:e.style},o.divSets.push(n)}n.div.className=this.classNameForKind(a),n.style.display="block",n.style.left=`${Math.floor(i)}px`,n.style.top=`${Math.floor(s)}px`,n.textNode.nodeValue=t}classNameForKind(e){switch(e){case"dec":return"floating-div-dec";case"lat":return"floating-div-lat";case"lon":return"floating-div-lon";default:return"floating-div-ra"}}static getLayerState(e){const t=r.layers.get(e);if(t)return t.container||(t.container=r.resolveContainer(e)),t;const i={container:r.resolveContainer(e),divSets:[],divSetNdx:0};return r.layers.set(e,i),i}static resolveContainer(e){return"healpix"===e?document.querySelector("#gridhpx"):document.querySelector("#gridcoords")}}t.default=r},5403:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataManager=void 0;const i=r(1072);t.MetadataManager=class{static STANDARD_SIZE="STANDARD_SIZE";static STANDARD_HUE="STANDARD_HUE";_outlineColumnList=[];_raColumnList=[];_decColumnList=[];_shapeColumnList=[];_hueColumnList=[];_selectedOutlineColumn;_selectedRaColumn;_selectedDecColumn;_selectedShapeColumn;_selectedHueColumn;_selectedNameColumn;_columns=[];constructor(e){e.forEach(e=>{e.columnType==i.ColumnType.NUMBER&&(this.addHueColumn(e),this.addShapeColumn(e)),e.columnType==i.ColumnType.GEOM_RA&&this.addRaColumn(e),e.columnType==i.ColumnType.GEOM_DEC&&this.addDecColumn(e),e.columnType==i.ColumnType.GEOM_FOOTPRINT&&this.addOutlineColumn(e),e.columnType==i.ColumnType.MAIN_NAME&&(this._selectedNameColumn=e),this._columns.push(e)})}addOutlineColumn(e){this._outlineColumnList.push(e),this._selectedOutlineColumn=e}addRaColumn(e){this._selectedRaColumn=this._selectedRaColumn||e,this._raColumnList.push(e)}addDecColumn(e){this._selectedDecColumn=this._selectedDecColumn||e,this._decColumnList.push(e)}addHueColumn(e){this._hueColumnList.push(e)}addShapeColumn(e){this._shapeColumnList.push(e)}get selectedRaColumn(){return this._selectedRaColumn}get selectedDecColumn(){return this._selectedDecColumn}get selectedHueColumn(){return this._selectedHueColumn}get selectedShapeColumn(){return this._selectedShapeColumn}get selectedOutlineColumn(){return this._selectedOutlineColumn}get selectedNameColumn(){return this._selectedNameColumn}get columns(){return this._columns}get raColumnList(){return this._raColumnList}get decColumnList(){return this._decColumnList}get outlineColumnList(){return this._outlineColumnList}get hueColumnList(){return this._hueColumnList}get shapeColumnList(){return this._shapeColumnList}set selectedRaColumn(e){this._selectedRaColumn=this._raColumnList.find(t=>t.name===e)||this._selectedRaColumn}set selectedDecColumn(e){this._selectedDecColumn=this._decColumnList.find(t=>t.name===e)||this._selectedDecColumn}set selectedOutlineColumn(e){this._selectedOutlineColumn=this._outlineColumnList.find(t=>t.name===e)||this._selectedOutlineColumn}set selectedHueColumn(e){this._selectedHueColumn=this._hueColumnList.find(t=>t.name===e)}set selectedShapeColumn(e){this._selectedShapeColumn=this._shapeColumnList.find(t=>t.name===e)}set selectedNameColumn(e){this._selectedNameColumn=this._columns.find(t=>t.name===e)}resetShapeColumn(){this._selectedShapeColumn=void 0}resetHueColumn(){this._selectedHueColumn=void 0}}},5409:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xyzTileRequestScheduler=t.XYZTileRequestScheduler=t.XYZTileRequestError=void 0;class r extends Error{cooldownMs;retryable;constructor(e,t,r=!0){super(e),this.name="XYZTileRequestError",this.cooldownMs=t,this.retryable=r}}t.XYZTileRequestError=r;class i{_maxConcurrent;_activeCount=0;_queue=[];_inflight=new Map;_hostBackoff=new Map;_sequence=0;constructor(e=4){this._maxConcurrent=e}setMaxConcurrent(e){this._maxConcurrent=Math.max(1,Math.floor(e)),this.pump()}getMaxConcurrent(){return this._maxConcurrent}getDebugStats(){const e=Date.now(),t=Array.from(this._hostBackoff.entries()).map(([t,r])=>({host:t,cooldownMs:Math.max(0,r.cooldownUntil-e),consecutiveFailures:r.consecutiveFailures})).filter(e=>e.cooldownMs>0||e.consecutiveFailures>0).sort((e,t)=>t.cooldownMs-e.cooldownMs);return{activeRequests:this._activeCount,queuedRequests:this._queue.length,inflightRequests:this._inflight.size,maxConcurrentRequests:this._maxConcurrent,highestQueuedPriority:this._queue[0]?.priority??null,hostsInBackoff:t}}load(e,t=0){const i=this._inflight.get(e);if(i)return i;const s=this.getHostCooldown(e),a=Date.now();if(s>a)return Promise.reject(new r(`Cooldown active for ${new URL(e).host}`,s-a));const o=new Promise((r,i)=>{this._queue.push({url:e,resolve:r,reject:i,priority:t,sequence:this._sequence++}),this._queue.sort((e,t)=>t.priority-e.priority||e.sequence-t.sequence),this.pump()}).finally(()=>{this._inflight.delete(e)});return this._inflight.set(e,o),o}pump(){for(;this._activeCount<this._maxConcurrent&&this._queue.length>0;){const e=this._queue.shift();if(!e)return;const t=this.getHostCooldown(e.url),i=Date.now();t>i?e.reject(new r(`Cooldown active for ${new URL(e.url).host}`,t-i)):(this._activeCount+=1,this.fetchBlob(e).then(e.resolve).catch(e.reject).finally(()=>{this._activeCount-=1,this.pump()}))}}async fetchBlob(e){try{const t=await fetch(e.url,{mode:"cors",cache:"force-cache"});if(!t.ok){const i=429===t.status||t.status>=500,s=this.registerFailure(e.url,i);throw new r(`HTTP ${t.status} loading ${e.url}`,i?s:3e5,i)}return this.registerSuccess(e.url),await t.blob()}catch(t){if(t instanceof r)throw t;const i=this.registerFailure(e.url,!1);throw new r(`Network/CORS failure loading ${e.url}`,i,!0)}}getHostCooldown(e){try{return this._hostBackoff.get(new URL(e).host)?.cooldownUntil??0}catch{return 0}}registerSuccess(e){try{const t=new URL(e).host;this._hostBackoff.set(t,{cooldownUntil:0,consecutiveFailures:0})}catch{}}registerFailure(e,t){if(!t)return 0;try{const t=new URL(e).host,r=(this._hostBackoff.get(t)??{cooldownUntil:0,consecutiveFailures:0}).consecutiveFailures+1,i=4e3,s=Math.min(12e4,i*2**Math.min(r-1,5));return this._hostBackoff.set(t,{cooldownUntil:Date.now()+s,consecutiveFailures:r}),s}catch{return 3e4}}}t.XYZTileRequestScheduler=i,t.xyzTileRequestScheduler=new i},5781:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPointSetGL=void 0;const i=r(1232);class s extends i.CatalogueGL{_kind="TerraPointSetGL"}t.TerraPointSetGL=s},5803:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SphereFoV=void 0;const i=r(1961),s=r(7930);class a{static MIN_FOV_DEG=1e-6;fovXDeg=180;fovYDeg=180;ratio=0;_minFoV=180;_webgl;_lastModel=null;_lastCamera=null;constructor(e){this._webgl=e}getFoV(e,t,r,i){this._lastModel=t,this._lastCamera=r;const s=this._webgl.canvas;if(!s)return this.fovXDeg=180,this.fovYDeg=180,this._minFoV=this.minFoV,this;const a=s.getBoundingClientRect(),o=a.width,n=a.height;return this.fovXDeg=this.computeAngle(0,n/2,e,t,r,i).angleDeg,this.fovYDeg=this.computeAngle(o/2,0,e,t,r,i).angleDeg,this._minFoV=this.minFoV,this.ratio=this.computeRatio(r),this}computeRatio(e){const t=e.getCameraPosition();return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])/this.fovYDeg}get minFoV(){const e=this.fovYDeg<=this.fovXDeg?this.fovYDeg:this.fovXDeg;return this._minFoV=Math.max(e,a.MIN_FOV_DEG),this._minFoV}get xFoV(){return this.fovXDeg}get yFoV(){return this.fovYDeg}computeDistanceFromAngle(e){return e*this.ratio}changeMinFov(e){this.fovYDeg<=this.fovXDeg?this.fovYDeg=e:this.fovXDeg=e,this.minFoV}computeCameraPositionForMinFoV(e){return this.computeCameraPositionForFoV(e)}computeCameraPositionForFoV(e){return this.computeCameraPositionForAngularDiameter(e)}computeCameraPositionForAngularDiameter(e){if(!this._lastModel||!this._lastCamera)return[0,0,0];const t=1e-6,r=Math.max(t,Math.min(180-t,e))*Math.PI/360,s=Math.sin(r);if(s<=0)return[0,0,0];const a=this._lastModel,o=this._lastCamera,n=Math.max(a.radius/s,a.radius+1e-4),h=o.getCameraPosition(),l=i.vec3.fromValues(h[0]-a.center[0],h[1]-a.center[1],h[2]-a.center[2]);return i.vec3.length(l)<t?i.vec3.set(l,0,0,1):i.vec3.normalize(l,l),[a.center[0]+l[0]*n,a.center[1]+l[1]*n,a.center[2]+l[2]*n]}computeAngle(e,t,r,i,s,a){const o=this._webgl.canvas.getBoundingClientRect(),n=this.getIntersectionPointWithModel(o.width/2,o.height/2,i,s,a),h=this.getIntersectionPointWithModel(e,t,i,s,a);return n&&h?{angleDeg:2*this.computeAngularDistanceDeg(n.point,h.point),distance:h.distance}:{angleDeg:180,distance:-1}}computeAngularDistanceDeg(e,t){const r=i.vec3.normalize(i.vec3.create(),e),a=i.vec3.normalize(i.vec3.create(),t),o=i.vec3.dot(r,a),n=i.vec3.cross(i.vec3.create(),r,a),h=Math.atan2(i.vec3.length(n),Math.min(1,Math.max(-1,o)));return(0,s.radToDeg)(h)}getIntersectionPointWithModel(e,t,r,s,a){const o=this.getRayFromMouse(e,t,a,s.getCameraMatrix()),n=this.raySphere(s.getCameraPosition(),o,r);if(n<0)return null;const h=i.vec3.create();i.vec3.scale(h,o,n),i.vec3.add(h,s.getCameraPosition(),h);const l=[h[0],h[1],h[2],1],c=[0,0,0,0];return this.mat4MultiplyVec4(r.getModelMatrixInverse(),l,c),{point:i.vec3.fromValues(c[0],c[1],c[2]),distance:n}}getRayFromMouse(e,t,r,s){const a=this._webgl.canvas.getBoundingClientRect(),o=[2*e/a.width-1,1-2*t/a.height,-1,1],n=i.mat4.create();i.mat4.invert(n,r);const h=[0,0,0,0];this.mat4MultiplyVec4(n,o,h);const l=[h[0],h[1],-1,0],c=i.mat4.create();i.mat4.invert(c,s);const u=[0,0,0,0];this.mat4MultiplyVec4(c,l,u);const d=i.vec3.fromValues(u[0],u[1],u[2]);return i.vec3.normalize(d,d),d}raySphere(e,t,r){let s=-1;const a=i.vec3.create();i.vec3.subtract(a,e,r.center);const o=i.vec3.dot(t,a),n=o*o-(i.vec3.dot(a,a)-r.radius*r.radius);if(n>0){const e=Math.sqrt(n),t=-o+e,r=-o-e;(t>=0||r>=0)&&(s=r<0?t:Math.min(t,r))}else if(0===n){const e=-o;e>=0&&(s=e)}return s}mat4MultiplyVec4(e,t,r){r[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],r[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],r[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],r[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3]}}t.SphereFoV=a},5947:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{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 }"}}},6553:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=r(1961),a=r(7930),o=r(8145),n=i(r(4382));class h{_x;_y;_z;_xyz;_raDeg;_decDeg;_raRad;_decRad;_raDecDeg;_lonLatDeg;constructor(e,t){this._xyz=[0,0,0],this._raDecDeg=[0,0];const r=n.default.MAX_DECIMALS??12;if(t===o.CoordsType.CARTESIAN){const{x:t,y:i,z:s}=e;this._x=Number(t.toFixed(r)),this._y=Number(i.toFixed(r)),this._z=Number(s.toFixed(r)),this._xyz=[this._x,this._y,this._z];const[a,o]=this.computeAstroCoords();this._raDeg=Number(a),this._decDeg=Number(o),this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180,this._raDecDeg=[this._raDeg,this._decDeg]}else if(t===o.CoordsType.ASTRO){const{raDeg:t,decDeg:i}=e;this._raDeg=Number(t),this._decDeg=Number(i),this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,a,o]=this.computeCartesianCoords();this._x=Number(s.toFixed(r)),this._y=Number(a.toFixed(r)),this._z=Number(o.toFixed(r)),this._xyz=[this._x,this._y,this._z]}else if(t===o.CoordsType.GEOGRAPHIC){const{lonDeg:t,latDeg:i}=e;this._lonLatDeg=[Number(t),Number(i)],this._raDeg=this._lonLatDeg[0],this._decDeg=this._lonLatDeg[1],this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,a,o]=this.computeCartesianCoords();this._x=Number(s.toFixed(r)),this._y=Number(a.toFixed(r)),this._z=Number(o.toFixed(r)),this._xyz=[this._x,this._y,this._z]}else t===o.CoordsType.SPHERICAL?(console.log(`${o.CoordsType.SPHERICAL} not implemented yet`),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0):(console.error("CoordsType "+String(t)+" not recognised."),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0)}computeAstroCoords(){const e=(0,a.cartesianToSpherical)(s.vec3.fromValues(this._xyz[0],this._xyz[1],this._xyz[2])),t=(0,a.sphericalToAstroDeg)(e.phi,e.theta);return[t.ra,t.dec]}computeCartesianCoords(){const e=(0,a.astroDegToSpherical)(this._raDeg,this._decDeg),[t,r,i]=(0,a.sphericalToCartesian)(e.phi,e.theta,1);return[t,r,i]}computeHealpixPhiTheta(){return(0,a.astroDegToSpherical)(this._raDeg,this._decDeg)}scale(e){return new h({x:this.x*e,y:this.y*e,z:this.z*e},o.CoordsType.CARTESIAN)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){return new h({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},o.CoordsType.CARTESIAN)}norm(){const e=1/this.length();return new h({x:this.x*e,y:this.y*e,z:this.z*e},o.CoordsType.CARTESIAN)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}subtract(e){return new h({x:this.x-e.x,y:this.y-e.y,z:this.z-e.z},o.CoordsType.CARTESIAN)}add(e){return new h({x:this.x+e.x,y:this.y+e.y,z:this.z+e.z},o.CoordsType.CARTESIAN)}get x(){return this._x}get y(){return this._y}get z(){return this._z}get xyz(){return this._xyz}get raDeg(){return this._raDeg}get decDeg(){return this._decDeg}get raDecDeg(){return this._raDecDeg}get lonDeg(){return this._lonLatDeg?.[0]??this._raDeg}get latDeg(){return this._lonLatDeg?.[1]??this._decDeg}get lonLatDeg(){return this._lonLatDeg??[this._raDeg,this._decDeg]}toADQL(){return`${this._raDecDeg[0]},${this._raDecDeg[1]}`}toString(){return`(raDeg, decDeg) => (${this._raDecDeg[0]},${this._raDecDeg[1]}) (x, y,z) => (${this._xyz[0]},${this._xyz[1]},${this._xyz[2]})`}}t.Point=h},6878:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPS=void 0;const i=r(4735),s=r(229),a=r(2257),o=r(8170);class n extends i.AbstractSkyEntity{_descriptor;_healpixGrid;_shaderProgram;_tiles=new Map;_currentOrder;_visibleTiles=[];_coverageTiles=[];constructor(e,t,r,i,s,o,n){super(e,t,r,i,s.name,o,!1),this._descriptor=s,this._healpixGrid=n,this.initGL(o),this._shaderProgram=new a.MeshHiPSShaderProgram(o),this._shaderProgram.enableProgram(),this._currentOrder=s.selectedOrder}get currentOrder(){return this._currentOrder}get maxOrder(){return this._descriptor.maxOrder}get minOrder(){return this._descriptor.minOrder}get baseURL(){return this._descriptor.baseUrl}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}getProperty(e){return this._descriptor.getProperty(e)}refreshOrder(e){if(this._descriptor.fixedOrder)return this._currentOrder=this._descriptor.selectedOrder,this._currentOrder;const t=Number.isFinite(e)&&e>0?e:this._healpixGrid.getMinFoV(),r=Number.isFinite(t)&&t>0?t:1e-6,i=s.fovHelper.getHiPSNorder(r,this._currentOrder);return this._currentOrder=Math.max(this._descriptor.minOrder,Math.min(this._descriptor.maxOrder,i)),this._currentOrder}draw(e){const t=e.camera.getCameraMatrix();if(!t||!e.pMatrix)return;this.refreshOrder(e.fovDeg),this._visibleTiles=this.resolveVisibleTiles(),this._coverageTiles=this.resolveCoverageTiles(this._visibleTiles),this.ensureTiles(this._coverageTiles),this.evictCached();const r=this._webgl,i=e.pMatrix,s=this.getModelMatrix(),a=r.isEnabled(r.CULL_FACE),o=r.isEnabled(r.DEPTH_TEST),n=r.getParameter(r.DEPTH_WRITEMASK),h=r.getParameter(r.DEPTH_FUNC);r.enable(r.DEPTH_TEST),r.depthMask(!0),r.depthFunc(r.LEQUAL),r.disable(r.CULL_FACE);const l=this.groupTilesByOrder(this._coverageTiles),c=Array.from(l.keys()).sort((e,t)=>e-t);for(const e of c)for(const r of l.get(e)??[])this._tiles.get(this.tileKey(r))?.draw(i,t,s,this._descriptor.color,this._descriptor.wireframe);a&&r.enable(r.CULL_FACE),o||r.disable(r.DEPTH_TEST),r.depthFunc(h),r.depthMask(n)}getDebugStats(){const e=Array.from(this._tiles.values());return{activeBaseLayer:"meships",meshHiPSName:this._descriptor.name,meshHiPSUrl:this._descriptor.baseUrl,currentOrder:this._currentOrder,visibleTileCount:this._visibleTiles.length,coverageTileCount:this._coverageTiles.length,cacheSize:this._tiles.size,readyTileCount:e.filter(e=>e.ready).length,loadingTileCount:e.filter(e=>e.loading).length,failedTileCount:e.filter(e=>e.failed).length}}resolveVisibleTiles(){const e=this._healpixGrid.visibleTilesManager,t=e?.visibleTilesByOrder,r=t?.order===this._currentOrder&&Array.isArray(t.pixels)?t.pixels:[];if(r.length>0)return r.map(e=>({order:this._currentOrder,ipix:e}));const i=12*4**this._currentOrder;return Array.from({length:i},(e,t)=>({order:this._currentOrder,ipix:t}))}resolveCoverageTiles(e){const t=new Map,r=e=>{e.order<this._descriptor.minOrder||e.order>this._descriptor.maxOrder||t.set(this.tileKey(e),e)};for(const t of e){r(t);for(let e=t.order-1;e>=this._descriptor.minOrder;e--){const i=2*(t.order-e);r({order:e,ipix:t.ipix>>i})}}const i=this._healpixGrid.visibleTilesManager,s=i?.ancestorsMap;if(s)for(const[e,t]of s)if(!(e<this._descriptor.minOrder||e>this._descriptor.maxOrder))for(const i of t)r({order:e,ipix:i});return Array.from(t.values())}groupTilesByOrder(e){const t=new Map;for(const r of e){const e=t.get(r.order)??[];e.push(r),t.set(r.order,e)}return t}ensureTiles(e){for(const t of e){const e=this.tileKey(t);this._tiles.has(e)||this._tiles.set(e,new o.MeshHiPSTile(t,this._descriptor.getTileUrl(t.order,t.ipix),this._webgl,this._shaderProgram))}}evictCached(){const e=this._descriptor.maxCachedTiles;if(this._tiles.size<=e)return;const t=new Set(this._coverageTiles.map(e=>this.tileKey(e))),r=Array.from(this._tiles.entries()).filter(([e])=>!t.has(e)).sort((e,t)=>e[1].lastUsedAt-t[1].lastUsedAt);for(;this._tiles.size>e&&r.length>0;){const[e,t]=r.shift();t.dispose(),this._tiles.delete(e)}}tileKey(e){return`${e.order}/${e.ipix}`}}t.MeshHiPS=n},6937:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XYZVisibleTilesManager=void 0;const s=i(r(2166));t.XYZVisibleTilesManager=class{_ancestorsMap=new Map;_visibleTilesMap=new Map;_visibleTiles=[];_selection={key:"0:",currentZoom:0,visibleTiles:[],visibleTilesMap:new Map,ancestorsMap:new Map};get ancestorsMap(){return this._ancestorsMap}get visibleTiles(){return this._visibleTiles}get visibleTilesMap(){return this._visibleTilesMap}get selection(){return this._selection}computeVisibleTiles(e,t,r,i,a,o=9,n=2){return this._visibleTiles=s.default.getVisibleTilesFromViewport(e,t,r,i,a,o,n),this._visibleTilesMap=this.buildTileMap(this._visibleTiles),this.refreshAncestorsMap(this._visibleTiles),this._selection={key:this.buildSelectionKey(e,this._visibleTiles),currentZoom:e,visibleTiles:this._visibleTiles,visibleTilesMap:this._visibleTilesMap,ancestorsMap:this._ancestorsMap},this._selection}refreshAncestorsMap(e){this._ancestorsMap.clear();for(const t of e)for(let e=t.z-1;e>=0;e--){const r=t.z-e,i={z:e,x:t.x>>r,y:t.y>>r};this._ancestorsMap.set(`${i.z}/${i.x}/${i.y}`,i)}}buildTileMap(e){const t=new Map;for(const r of e)t.set(this.key(r),r);return t}buildSelectionKey(e,t){return`${e}:${t.map(e=>`${e.x}/${e.y}`).join("|")}`}key(e){return`${e.z}/${e.x}/${e.y}`}}},7559:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}}},7734:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(1961),a=r(7930),o=i(r(4382));t.default=class{insideSphere=!1;cam_pos=s.vec3.create();cam_speed=1;vMatrix=s.mat4.create();T=s.mat4.create();R=s.mat4.create();FoV=180;previousFoV=180;move=s.vec3.create();phi=0;theta=0;rotationSensitivity=1;lockRotX=!1;lockRotY=!1;lockRotZ=!1;constructor(e,t){this.init(e,t)}init(e,t){this.insideSphere=t,this.cam_pos=s.vec3.clone(e),this.vMatrix=s.mat4.create(),this.T=s.mat4.create(),this.R=s.mat4.create(),s.mat4.translate(this.T,this.T,[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]),this.FoV=this.previousFoV=180,this.move=s.vec3.clone([0,0,0]),this.goTo(0,0)}goTo(e,t){this.goToPhiTheta((0,a.astroDegToSpherical)(e,t))}goToPhiTheta(e){const t=(0,a.sphericalToCartesian)(e.phi,e.theta,this.cam_pos[2]),r=s.vec3.normalize(s.vec3.create(),s.vec3.fromValues(t[0],t[1],t[2])),i=s.vec3.fromValues(0,0,1),o=s.vec3.scale(s.vec3.create(),r,s.vec3.dot(i,r)),n=s.vec3.subtract(s.vec3.create(),i,o);s.vec3.length(n)<1e-6?s.vec3.set(n,0,1,0):s.vec3.normalize(n,n);let h=s.mat4.create();h=s.mat4.translate(h,h,s.vec3.fromValues(t[0],t[1],t[2]));const l=[h[12],h[13],h[14]];h=s.mat4.targetTo(h,l,[0,0,0],n),this.R=s.mat4.clone(h),this.R[12]=0,this.R[13]=0,this.R[14]=0;const c=s.mat4.create();0!==this.cam_pos[2]&&s.mat4.invert(c,h),this.vMatrix=c}toggleInsideSphere(){this.insideSphere=o.default.insideSphere,o.default.insideSphere?(this.cam_pos[0]=0,this.cam_pos[1]=0,this.cam_pos[2]=-.005):this.cam_pos[2]=2+this.cam_pos[2],s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}zoom(e){if(this.move=s.vec3.clone([0,0,0]),this.move[2]+=this.cam_speed*e,o.default.insideSphere)this.cam_pos[2]+this.move[2]>=-.005&&e>0?(this.cam_pos[2]=-.005,e=0):this.cam_pos[2]+this.move[2]<=-.9885&&e<0?(this.cam_pos[2]=-.9885,e=0):this.cam_pos[2]+=this.move[2];else{const t=Math.max(this.cam_pos[2]-1,1e-6),r=Math.min(1,t/.3),i=.015+.985*Math.pow(r,1.2);this.move[2]*=i,this.cam_pos[2]+this.move[2]<=1.000001&&e<0?this.cam_pos[2]=1.000001:this.cam_pos[2]+=this.move[2]}const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}moveAlongView(e){const t=s.mat4.create();s.mat4.invert(t,this.R);const r=s.vec3.fromValues(0,0,-1),i=s.vec3.create();s.vec3.transformMat4(i,r,t);const a=Math.hypot(i[0],i[1],i[2]);a>0&&(i[0]/=a,i[1]/=a,i[2]/=a),this.cam_pos[0]+=i[0]*e,this.cam_pos[1]+=i[1]*e,this.cam_pos[2]+=i[2]*e;const o=s.mat4.create();s.mat4.translate(this.T,o,this.cam_pos),this.refreshViewMatrix()}translate(e){this.cam_pos[2]=e+1;const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}rotateX(e){if(this.lockRotX)return;const t=.01*e;this.theta+=t,s.mat4.rotate(this.R,this.R,t,[1,0,0]),this.refreshViewMatrix()}rotateY(e){if(this.lockRotY)return;const t=.01*e;this.phi+=t,s.mat4.rotate(this.R,this.R,t,[0,1,0]),this.refreshViewMatrix()}rotateZ(e){if(this.lockRotZ)return;const t=.01*e;s.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshViewMatrix()}rotateXRadian(e){this.lockRotX||(s.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshViewMatrix())}rotateYRadian(e){this.lockRotY||(this.phi+=e,s.mat4.rotate(this.R,this.R,e,[0,1,0]),this.refreshViewMatrix())}rotateZRadian(e){this.lockRotZ||(s.mat4.rotate(this.R,this.R,e,[0,0,1]),this.refreshViewMatrix())}rotate(e,t){if(this.lockRotZ)return;const r=Math.sqrt(e*e+t*t);if(0===r)return;const i=this.getCameraPosition(),a=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),o=Math.max(a-1,1e-6),n=Math.min(1,o/.45),h=.02+.98*Math.pow(n,1.55),l=Math.min(1,this.FoV/18),c=r*h*(.06+1.55*Math.pow(l,.52))/1.9*this.rotationSensitivity;let u=t,d=e;const _=Math.sqrt(u*u+d*d);0!==_&&(u/=_,d/=_,s.mat4.rotate(this.R,this.R,-c,[u,d,0]),this.refreshViewMatrix())}setRotationSensitivity(e){this.rotationSensitivity=Math.min(3,Math.max(.2,e))}getRotationSensitivity(){return this.rotationSensitivity}refreshViewMatrix(){const e=s.mat4.create(),t=s.mat4.create();s.mat4.invert(e,this.T),s.mat4.invert(t,this.R),s.mat4.multiply(this.vMatrix,e,t)}refreshFoV(e){this.previousFoV=this.FoV,this.FoV=e}getCameraMatrix(){return this.vMatrix}getCameraPosition(){const e=s.mat4.create();return s.mat4.invert(e,this.vMatrix)?[e[12],e[13],e[14]]:[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]}setCameraMatrix(e){this.vMatrix=e}setCameraPosition(e){this.cam_pos=s.vec3.fromValues(e[0],e[1],e[2]),s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}getCameraAngle(){const[e,t,r]=this.getCameraPosition(),i=s.vec3.fromValues(e,t,r),o=(0,a.cartesianToSpherical)(i);return console.log("[Camera::getCameraAngle]",o),o}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}}},7786:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSShaderProgram=void 0;const s=i(r(5947)),a=r(619);t.HiPSShaderProgram=class{_colorMapBlockIndex=null;_runtimeColorMap;_shaderProgram;_vertexShader;_fragmentShader;_UBO_colorMapBuffer=null;_UBO_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={sampler:"uSampler0",factor:"uFactor0",m_perspective:"uPMatrix",m_model:"uMMatrix",m_view:"uVMatrix",colormapIdx:"cmapIdx",colormap_red:"r",colormap_green:"g",colormap_blue:"b"},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=s.default.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 r=s.default.hipsVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),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=s.default.hipsGrayscaleFS();this.changeFSShader(e)}setNativeShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsNativeFS();this.changeFSShader(e)}setColorMapShader(){const e=this._webgl;e.detachShader(this.shaderProgram,this._fragmentShader);const t=s.default.hipsColorMapFS();this.changeFSShader(t);const r=e.getUniformBlockIndex(this.shaderProgram,"colormap");if(r===e.INVALID_INDEX)return console.warn('HiPSShaderProgram: uniform block "colormap" not found in hipsColorMapFS()'),this._colorMapBlockIndex=null,void(this._UBO_colorMapBuffer=null);this._colorMapBlockIndex=r;const i=["r_palette","g_palette","b_palette"],a=e.getUniformIndices(this.shaderProgram,i),o=e.getActiveUniforms(this.shaderProgram,a,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)}i.forEach((e,t)=>{this._UBO_colorMapVariableInfo[e]={index:a[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,r,i){const s=this._webgl;if(s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model),this.locations.vMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_view),this.locations.sampler=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.sampler),this.locations.textureAlpha=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.factor),this.locations.clorMapIdx=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.colormapIdx),s.uniform1i(this.locations.clorMapIdx,i),this.locations.sampler&&s.uniform1i(this.locations.sampler,0),this.locations.vertexPositionAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.textureCoordAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.text_coords),i>=2&&this._UBO_colorMapBuffer&&null!==this._colorMapBlockIndex){let e;if(s.uniformBlockBinding(this.shaderProgram,this._colorMapBlockIndex,0),s.bindBuffer(s.UNIFORM_BUFFER,this._UBO_colorMapBuffer),2===i?e={r:a.ColorMaps.planck.r,g:a.ColorMaps.planck.g,b:a.ColorMaps.planck.b}:3===i?e={r:a.ColorMaps.cmb.r,g:a.ColorMaps.cmb.g,b:a.ColorMaps.cmb.b}:4===i?e={r:a.ColorMaps.rainbow.r,g:a.ColorMaps.rainbow.g,b:a.ColorMaps.rainbow.b}:5===i?e={r:a.ColorMaps.eosb.r,g:a.ColorMaps.eosb.g,b:a.ColorMaps.eosb.b}:6===i?e={r:a.ColorMaps.cubehelix.r,g:a.ColorMaps.cubehelix.g,b:a.ColorMaps.cubehelix.b}:7===i?e={r:a.ColorMaps.hot.r,g:a.ColorMaps.hot.g,b:a.ColorMaps.hot.b}:8===i&&(e={r:a.ColorMaps.gray.r,g:a.ColorMaps.gray.g,b:a.ColorMaps.gray.b}),e||(e=this._runtimeColorMap),e){const t=this._UBO_colorMapVariableInfo;s.bufferSubData(s.UNIFORM_BUFFER,t.r_palette.offset,e.r,0),s.bufferSubData(s.UNIFORM_BUFFER,t.g_palette.offset,e.g,0),s.bufferSubData(s.UNIFORM_BUFFER,t.b_palette.offset,e.b,0)}s.bindBuffer(s.UNIFORM_BUFFER,null)}s.uniformMatrix4fv(this.locations.mMatrix,!1,r),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t)}}},7930:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cartesianToSpherical=function(e){const t=i.vec3.dot(e,e),r=Math.sqrt(t);let s=Math.acos(e[2]/r);s=a(s);let o=Math.atan2(e[1],e[0]);return o=a(o),o<0&&(o+=360),{phi:o,theta:s}},t.colorHex2RGB=function(e){const t=e.substring(1,3),r=e.substring(3,5),i=e.substring(5,7),s=parseInt(t,16),a=parseInt(r,16),o=parseInt(i,16),n=(s/255).toFixed(2),h=(a/255).toFixed(2),l=(o/255).toFixed(2);return[parseFloat(n),parseFloat(h),parseFloat(l)]},t.degToRad=s,t.radToDeg=a,t.sphericalToAstroDeg=function(e,t){let r=e;return r<0&&(r+=360),{ra:r,dec:90-t}},t.sphericalToCartesian=function(e,t,r=1){return[r*Math.sin(s(t))*Math.cos(s(e)),r*Math.sin(s(t))*Math.sin(s(e)),r*Math.cos(s(t))]},t.astroDegToSpherical=function(e,t){let r=e;return r<0&&(r+=360),{phi:r,theta:90-t}},t.raDegToHMS=function(e){const t=Math.floor(e/15),r=Math.floor(60*(e/15-t));return{h:t,m:r,s:3600*(e/15-t-r/60)}},t.decDegToDMS=function(e){let t=1;e<0&&(t=-1);const r=Math.abs(e);let i=Math.trunc(r);const s=Math.trunc(60*(r-i)),a=3600*(r-i-s/60);return i*=t,{d:i,m:s,s:a}};const i=r(1961);function s(e){return e/180*Math.PI}function a(e){return 180*e/Math.PI}},8083:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FoVUtils=void 0;const s=r(6553),a=i(r(4639)),o=r(8145),n=r(1961);class h{getMinFoV(){return this._fovY_deg<=this._fovX_deg?this._fovY_deg:this._fovX_deg}static getFoVPolygon(e,t,r,i,s,o){const l=e.getCameraMatrix(),c=r.getModelMatrix(),u=t.clientWidth,d=t.clientHeight;let _=[];if(a.default.getIntersectionPointWithSingleModel(0,0,i,s,e,o).length>0)_=h.getScreenCornersIntersection(o,e,t,i,s);else{let t=n.mat4.create();t=n.mat4.multiply(t,l,c),t=n.mat4.multiply(t,o,t);const r=[t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]],f=[t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]],g=[t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]],p=[t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]],m=a.default.getIntersectionPointWithSingleModel(u/2,0,i,s,e,o),M=a.default.getIntersectionPointWithSingleModel(u,d/2,i,s,e,o);if(0===m.length&&0===M.length){const e=h.getNearestSpherePoint(r),t=h.getNearestSpherePoint(f),i=h.getNearestSpherePoint(p),s=h.getNearestSpherePoint(g),a=h.computeMiddlePoint(i[0],e[0])[0],o=h.computeMiddlePoint(e[0],s[0])[0],n=h.computeMiddlePoint(s[0],t[0])[0],l=h.computeMiddlePoint(t[0],i[0])[0];_.push(e[0],o,s[0],n,t[0],l,i[0],a)}else if(0===m.length){const e=h.getNearestSpherePoint(r),i=h.getNearestSpherePoint(f),s=h.getFrustumIntersectionWithSphere(t,p,f,r),a=h.getFrustumIntersectionWithSphere(t,g,r,f),o=h.computeMiddlePoint(s[1],e[0])[0],n=h.computeMiddlePoint(e[0],a[0])[0],l=h.computeMiddlePoint(a[1],i[0])[0],c=h.computeMiddlePoint(i[0],s[0])[0];_.push(e[0],n,a[0],a[1],l,i[0],c,s[0],s[1],o)}else if(0===M.length){const e=h.getFrustumIntersectionWithSphere(t,r,p,g),i=h.getFrustumIntersectionWithSphere(t,f,g,p),s=h.getNearestSpherePoint(p),a=h.getNearestSpherePoint(g),o=h.computeMiddlePoint(s[0],e[0])[0],n=h.computeMiddlePoint(e[1],a[0])[0],l=h.computeMiddlePoint(a[0],i[0])[0],c=h.computeMiddlePoint(i[1],s[0])[0];_.push(e[0],e[1],n,a[0],l,i[0],i[1],c,s[0],o)}else{const e=h.getFrustumIntersectionWithSphere(t,r,p,g),i=h.getFrustumIntersectionWithSphere(t,f,g,p),s=h.getFrustumIntersectionWithSphere(t,p,f,r),a=h.getFrustumIntersectionWithSphere(t,g,r,f);_.push(e[0],e[1],a[0],a[1],i[0],i[1],s[0],s[1])}}return _}static getScreenCornersIntersection(e,t,r,i,n){const h=r.clientWidth,l=r.clientHeight,c=a.default.getIntersectionPointWithSingleModel(0,0,i,n,t,e),u=a.default.getIntersectionPointWithSingleModel(h/2,0,i,n,t,e),d=a.default.getIntersectionPointWithSingleModel(h,0,i,n,t,e),_=a.default.getIntersectionPointWithSingleModel(h,l/2,i,n,t,e),f=a.default.getIntersectionPointWithSingleModel(h,l,i,n,t,e),g=a.default.getIntersectionPointWithSingleModel(h/2,l,i,n,t,e),p=a.default.getIntersectionPointWithSingleModel(0,l,i,n,t,e),m=a.default.getIntersectionPointWithSingleModel(0,l/2,i,n,t,e),M=[],x=e=>{e.length>0&&M.push(new s.Point({x:e[0],y:e[1],z:e[2]},o.CoordsType.CARTESIAN))};return x(c),x(u),x(d),x(_),x(f),x(g),x(p),x(m),M}static getCenterJ2000(e,t,r,i,n){const h=e.clientWidth,l=e.clientHeight,c=a.default.getIntersectionPointWithSingleModel(h/2,l/2,t,r,i,n);if(c.length<=0)throw Error("Central point is null");return new s.Point({x:c[0],y:c[1],z:c[2]},o.CoordsType.CARTESIAN)}static computeMiddlePoint(e,t){const r=(e.x+t.x)/2,i=(e.y+t.y)/2,a=(e.z+t.z)/2,n=Math.hypot(r,i,a)||1,h=r/n,l=i/n,c=a/n;return[new s.Point({x:h,y:l,z:c},o.CoordsType.CARTESIAN)]}static getNearestSpherePoint(e){const[t,r,i,a]=e,n=1/Math.sqrt(t*t+r*r+i*i),h=1*n,l=-1*n,c=[t*h,r*h,i*h],u=[t*l,r*l,i*l],d=Math.sqrt(t*t+r*r+i*i)||1,_=Math.abs(t*c[0]+r*c[1]+i*c[2]+a)/d<=Math.abs(t*u[0]+r*u[1]+i*u[2]+a)/d?c:u;return[new s.Point({x:_[0],y:_[1],z:_[2]},o.CoordsType.CARTESIAN)]}static getFrustumIntersectionWithSphere(e,t,r,i){const[a,n,h,l]=t,c=a*a+n*n+h*h||1,u=-a*l/c,d=-n*l/c,_=-h*l/c,f=Math.abs(l)/Math.sqrt(c),g=[];if(1>f){const e=Math.sqrt(1-f*f),t=t=>{const[r,i,s,a]=t,o=1/Math.sqrt(r*r+i*i+s*s),n=e*o,h=-e*o,l=[u+r*n,d+i*n,_+s*n],c=[u+r*h,d+i*h,_+s*h],f=Math.sqrt(r*r+i*i+s*s)||1;return Math.abs(r*l[0]+i*l[1]+s*l[2]+a)/f<=Math.abs(r*c[0]+i*c[1]+s*c[2]+a)/f?l:c},a=t(r),n=t(i);g.push(new s.Point({x:a[0],y:a[1],z:a[2]},o.CoordsType.CARTESIAN),new s.Point({x:n[0],y:n[1],z:n[2]},o.CoordsType.CARTESIAN))}else 1===f&&g.push(new s.Point({x:u,y:d,z:_},o.CoordsType.CARTESIAN),new s.Point({x:u,y:d,z:_},o.CoordsType.CARTESIAN));return g}static getAstroFoVPolygon(e){return e.map(e=>e.toADQL()).join(",")}}t.FoVUtils=h},8124:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LatLonGrid=void 0;const s=r(1961),a=r(4735),o=r(8284),n=i(r(4707)),h=r(7930),l=r(5803),c=i(r(4382)),u=i(r(5361));class d extends a.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_shaderProgram;_vertexShader;_fragmentShader;_attribLocations={position:0};_lonVertexPositionBuffer;_latVertexPositionBuffer;_lonStep=10;_latStep=10;_segmentStep=1;_fovObj;_fovDeg=180;_showGrid=!0;_lonArray=[];_latArray=[];_bufferKey="";defaultColor="#41d4d4";gridText=new u.default("lonlat");constructor(e,t,r,i,s,a){super(e,t,r,i,s,a),this._fovObj=new l.SphereFoV(a),this.init()}init(){this.initGL(super.webgl);const e=super.webgl;this._shaderProgram=e.createProgram(),this.initShaders(),this._lonVertexPositionBuffer=e.createBuffer(),this._latVertexPositionBuffer=e.createBuffer(),this.initBuffers(this._fovDeg)}initShaders(){const e=super.webgl,t=n.default.healpixGridFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(t),void alert(t)}const r=n.default.healpixGridVS();if(this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),e.compileShader(this._vertexShader),!e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(t),void alert(t)}e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)}initBuffers(e,t,r=!1){const i=o.xyzFovHelper.getLonLatSteps(e,r);this._lonStep=i.lonStep,this._latStep=i.latStep,this._segmentStep=Math.max(Math.min(this._lonStep,this._latStep),.25),this._lonArray=[],this._latArray=[];const s=t?{lon:this.normalizeLon(t.phi>180?t.phi-360:t.phi),lat:90-t.theta}:null,a=!!s&&!r&&e<2,n=a?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._lonStep):this.buildLonRange(0,180,this._lonStep),h=a?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._latStep):this.buildLatRange(0,90,this._latStep),l=a&&s?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._segmentStep):this.buildLatRange(0,90,this._segmentStep),c=a&&s?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._segmentStep):this.buildLonRange(0,180,this._segmentStep);for(const e of n){const t=[];for(const r of l)t.push(...this.lonLatToCartesian(e,Math.min(r,90)));this._lonArray.push(new Float32Array(t))}for(const e of h){const t=[];if(!(e<=-90||e>=90)){for(const r of c)t.push(...this.lonLatToCartesian(Math.min(r,180),e));this._latArray.push(new Float32Array(t))}}}buildLonRange(e,t,r){const i=[],s=Math.floor((e-t)/r)*r,a=Math.ceil((e+t)/r)*r;for(let e=s;e<=a;e+=r)i.push(this.normalizeLon(e));return i}buildLatRange(e,t,r){const i=[],s=Math.max(-90,Math.floor((e-t)/r)*r),a=Math.min(90,Math.ceil((e+t)/r)*r);for(let e=s;e<=a;e+=r)i.push(e);return i}lonLatToCartesian(e,t){const r=(0,h.degToRad)(e),i=(0,h.degToRad)(t),s=Math.cos(i);return[s*Math.cos(r),s*Math.sin(r),Math.sin(i)]}refresh(e,t){const r=!!t.cameraMoving,i=o.xyzFovHelper.getLonLatSteps(e,r),s=t.centerSphericalDeg,a=!!s&&!r&&e<2,n=s?this.normalizeLon(s.phi>180?s.phi-360:s.phi):0,h=s?90-s.theta:0,l=a?`${this.roundToStep(n,Math.max(i.lonStep,e))}:${this.roundToStep(h,Math.max(i.latStep,e))}`:"global",c=`${r?"coarse":"settled"}:${i.lonStep}:${i.latStep}:${l}`;this._bufferKey!==c&&(this._fovDeg=e,this._bufferKey=c,this.initBuffers(this._fovDeg,t.centerSphericalDeg,r))}refreshFoV(e){return e.camera&&e.pMatrix?(this._fovObj.getFoV(c.default.insideSphere,this,e.camera,e.pMatrix),this.refresh(this._fovObj.minFoV,e),this._fovObj.minFoV):this._fovDeg}getMinFoVDeg(){return this._fovObj.minFoV}getFoV(){return this._fovObj}isVisible(){return this._showGrid}toggleShowGrid(){return this._showGrid=!this._showGrid,this._showGrid}setShowGrid(e){this._showGrid=e}enableShader(e,t,r){const i=super.webgl;i.useProgram(this._shaderProgram);const a=s.mat4.create();s.mat4.multiply(a,r,e);const o=i.getUniformLocation(this._shaderProgram,"uMVMatrix"),n=i.getUniformLocation(this._shaderProgram,"uPMatrix"),l=i.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=i.getAttribLocation(this._shaderProgram,"aCatPosition"),o&&i.uniformMatrix4fv(o,!1,a),n&&i.uniformMatrix4fv(n,!1,t),l){const e=(0,h.colorHex2RGB)(this.defaultColor);i.uniform4f(l,e[0],e[1],e[2],1)}}draw(e){if(!this._showGrid)return void this.gridText.resetDivSets();const t=super.webgl,r=e.camera;if(!r)return;const i=e.pMatrix;if(!i)return;this.refreshFoV(e);const s=r.getCameraMatrix();if(!s)return;const a=this.getModelMatrix();this.enableShader(a,i,s);for(const e of this._lonArray)t.bindBuffer(t.ARRAY_BUFFER,this._lonVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_STRIP,0,e.length/d.ELEM_SIZE);for(const e of this._latArray)t.bindBuffer(t.ARRAY_BUFFER,this._latVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_LOOP,0,e.length/d.ELEM_SIZE);this.drawLabels(e,a,i,s),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}drawLabels(e,t,r,i){const s=e.centerSphericalDeg;if(!s)return void this.gridText.resetDivSets();const a=this.normalizeLon(s.phi>180?s.phi-360:s.phi),o=90-s.theta,n=this.normalizeLon(this.roundToStep(a,this._lonStep)),h=Math.max(-90+this._latStep,Math.min(90-this._latStep,this.roundToStep(o,this._latStep))),l=this.lonLatToCartesian(n,Math.max(-80,Math.min(80,o))),c=this.lonLatToCartesian(a,h),u=this.projectPointToScreen(l,t,r,i);u&&this.gridText.addLonLatDivSet(`${n.toFixed(0)}° lon`,u.x,u.y,"lon");const d=this.projectPointToScreen(c,t,r,i);d&&this.gridText.addLonLatDivSet(`${h.toFixed(0)}° lat`,d.x,d.y,"lat"),this.gridText.resetDivSets()}projectPointToScreen(e,t,r,i){const a=s.mat4.create(),o=s.mat4.create();s.mat4.multiply(a,i,t),s.mat4.multiply(o,r,a);const n=s.vec4.fromValues(e[0],e[1],e[2],1);if(s.vec4.transformMat4(n,n,o),Math.abs(n[3])<1e-6)return null;if(n[0]/=n[3],n[1]/=n[3],n[0]<-1||n[0]>1||n[1]<-1||n[1]>1)return null;const h=super.webgl.canvas.getBoundingClientRect();return{x:h.left+(.5*n[0]+.5)*h.width,y:h.top+(-.5*n[1]+.5)*h.height}}roundToStep(e,t){return t<=0?e:Math.round(e/t)*t}normalizeLon(e){let t=e;for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}t.LatLonGrid=d},8145:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsType=void 0,function(e){e.CARTESIAN="cartesian",e.SPHERICAL="spherical",e.ASTRO="astro",e.GEOGRAPHIC="geographic"}(r||(t.CoordsType=r={}))},8170:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSTile=void 0;const i=r(4322);t.MeshHiPSTile=class{coord;_url;_webgl;_shaderProgram;_gpuMesh=null;_ready=!1;_loading=!1;_failed=!1;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,r,i){this.coord=e,this._url=t,this._webgl=r,this._shaderProgram=i,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}draw(e,t,r,i,s){if(this.touch(),!this._ready||!this._gpuMesh)return!1;const a=this._webgl;return this._shaderProgram.enableShaders(e,t,r,i),a.bindBuffer(a.ARRAY_BUFFER,this._gpuMesh.positionBuffer),a.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(a.bindBuffer(a.ARRAY_BUFFER,this._gpuMesh.normalBuffer),a.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,a.FLOAT,!1,0,0),a.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,s?this._gpuMesh.lineIndexBuffer:this._gpuMesh.indexBuffer),a.drawElements(s?a.LINES:a.TRIANGLES,s?this._gpuMesh.lineIndexCount:this._gpuMesh.indexCount,this._gpuMesh.indexType,0),a.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&a.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),!0}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._url);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._url}`);const t=i.OBJMeshParser.parse(await e.text());this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[MeshHiPSTile] load failed",this._url,e),this._failed=!0,this._ready=!1}finally{this._loading=!1}}}uploadMesh(e){const t=this._webgl,r=t.createBuffer(),i=t.createBuffer(),s=t.createBuffer(),a=t.createBuffer();if(!(r&&i&&s&&a))throw new Error(`Could not create MeshHiPS buffers for ${this.key}`);const o=this.buildLineIndices(e.indices);return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.bufferData(t.ELEMENT_ARRAY_BUFFER,o,t.STATIC_DRAW),{positionBuffer:r,normalBuffer:i,indexBuffer:s,lineIndexBuffer:a,indexCount:e.indices.length,lineIndexCount:o.length,indexType:t.UNSIGNED_INT}}buildLineIndices(e){const t=new Uint32Array(2*e.length);let r=0;for(let i=0;i<e.length;i+=3){const s=e[i],a=e[i+1],o=e[i+2];t[r++]=s,t[r++]=a,t[r++]=a,t[r++]=o,t[r++]=o,t[r++]=s}return t}get key(){return`${this.coord.order}/${this.coord.ipix}`}}},8256:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(4382)),a=r(229);t.default=class{_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,r,i,s,a){this._visibleTileManager=a,this._webgl=s,this._tileBuffer=i,this._hips=r,this._tileno=e,this._format=r.format,this._baseurl=r.baseURL,this._maxorder=r.maxOrder,this._isGalacticHips=r.isGalacticHips,this._order=t,this._amIStillInFoV_requsetID=window.setInterval(()=>{this.amIStillInFoV()},5e3),this.initImage()}destroyIntervals(){window.clearInterval(this._amIStillInFoV_requsetID)}getReadyState(){return this._ready}isLoading(){return!this._ready&&!this._abort}get cacheTime0(){return this._cacheTime0}resetCacheTime0(){this._cacheTime0=void 0}setCacheTime0(){this._cacheTime0=(new Date).getTime()}initImage(){if(this._order>this._maxorder)return this._ready=!1,this._abort=!0,this.destroyIntervals(),void console.warn(`[Tile] Skipping tile request above max order: requested order ${this._order}, max order ${this._maxorder}, url ${this._baseurl}`);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=a.fovHelper.getRefOrder(this._order),r=s.default.getHealpix(this._order).nest2xyf(this._tileno),i=t-this._order,o=r.ix<<i,n=(r.ix<<i)+(1<<i),h=r.iy<<i,l=(r.iy<<i)+(1<<i),c=s.default.getHealpix(t);this.setupPositionAndTexture4Quadrant2(o,o+(n-o)/2,h,h+(l-h)/2,0,c,i,r),this.setupPositionAndTexture4Quadrant2(o+(n-o)/2,n,h,h+(l-h)/2,1,c,i,r),this.setupPositionAndTexture4Quadrant2(o,o+(n-o)/2,h+(l-h)/2,l,2,c,i,r),this.setupPositionAndTexture4Quadrant2(o+(n-o)/2,n,h+(l-h)/2,l,3,c,i,r);const u=this.vertexPosition[0].length/20,d=this.computeVertexIndices(u);d.length>65535?this.vertexIndices=new Uint32Array(d):this.vertexIndices=new Uint16Array(d),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint32Array(6*e);let r=0;for(let i=0;i<e;i++){const e=r;t[6*i]=e,t[6*i+1]=e+1,t[6*i+2]=e+2,t[6*i+3]=e+2,t[6*i+4]=e+3,t[6*i+5]=e,r+=4}return t}setupPositionAndTexture4Quadrant2(e,t,r,i,s,a,o,n){const h=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(i-r));const l=1/(1<<o);let c=0;for(let h=e;h<t;h++)for(let e=r;e<i;e++){const t=a.getPointsForXyfNoStep(h,e,n.face),r=e-(n.iy<<o),i=h-(n.ix<<o);this.vertexPosition[s][20*c]=t[0].x,this.vertexPosition[s][20*c+1]=t[0].y,this.vertexPosition[s][20*c+2]=t[0].z,this.vertexPosition[s][20*c+3]=l+l*r+0,this.vertexPosition[s][20*c+4]=1-(l+l*i)-0,this.vertexPosition[s][20*c+5]=t[1].x,this.vertexPosition[s][20*c+6]=t[1].y,this.vertexPosition[s][20*c+7]=t[1].z,this.vertexPosition[s][20*c+8]=l+l*r+0,this.vertexPosition[s][20*c+9]=1-l*i+0,this.vertexPosition[s][20*c+10]=t[2].x,this.vertexPosition[s][20*c+11]=t[2].y,this.vertexPosition[s][20*c+12]=t[2].z,this.vertexPosition[s][20*c+13]=l*r-0,this.vertexPosition[s][20*c+14]=1-l*i+0,this.vertexPosition[s][20*c+15]=t[3].x,this.vertexPosition[s][20*c+16]=t[3].y,this.vertexPosition[s][20*c+17]=t[3].z,this.vertexPosition[s][20*c+18]=l*r-0,this.vertexPosition[s][20*c+19]=1-(l+l*i)-0,c++}this.vertexPositionBuffer[s]=h.createBuffer(),h.bindBuffer(h.ARRAY_BUFFER,this.vertexPositionBuffer[s]),h.bufferData(h.ARRAY_BUFFER,this.vertexPosition[s],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,r,i,s,a,o){if(!this._ready||this._abort)return;this._textureLoaded||this.textureLoaded(o);let n=new Set([0,1,2,3]);if(e>this._order&&this._order<this._maxorder){const h=this.drawChildren(e,t,r,i,s,a,o);h&&(n=h)}const h=this._webgl;o.enableShaders(r,i,s,a),h.enableVertexAttribArray(o.locations.vertexPositionAttribute),h.enableVertexAttribArray(o.locations.textureCoordAttribute),h.activeTexture(h.TEXTURE0+this._hipsShaderIndex),h.bindTexture(h.TEXTURE_2D,this._texture),h.uniform1f(o.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(o.locations.vertexPositionAttribute,3,h.FLOAT,!1,20,0),h.vertexAttribPointer(o.locations.textureCoordAttribute,2,h.FLOAT,!1,20,12),h.drawElements(h.TRIANGLES,l,c,0)}),h.disableVertexAttribArray(o.locations.vertexPositionAttribute),h.disableVertexAttribArray(o.locations.textureCoordAttribute)}drawChildren(e,t,r,i,s,a,o){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,r,i,s,a,o),l._ready&&n.delete(c-(this._tileno<<2))}}return n}}}},8284:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xyzFovHelper=void 0;class r{static LEVEL_HYSTERESIS=.12;static ZOOM_MIN_FOV={2:179,3:90,4:30,5:20,6:6,7:3.2,8:1.6,9:.85,10:.42,11:.21,12:.12,13:.06,14:.015,15:0};getZoom(e,t){const i=this.getRawZoom(e);if(void 0===t||t===i)return i;if(i>t){const i=r.ZOOM_MIN_FOV[t];if(i>0&&e>i*(1-r.LEVEL_HYSTERESIS))return t}else{const s=r.ZOOM_MIN_FOV[i];if(s>0&&e<s*(1+r.LEVEL_HYSTERESIS))return t}return i}getRawZoom(e){return e>=179?2:e>=90?3:e>=30?4:e>=20?5:e>=6?6:e>=3.2?7:e>=1.6?8:e>=.85?9:e>=.42?10:e>=.21?11:e>=.12?12:e>=.06?13:e>=.015?14:15}getLonLatSteps(e,t=!1){let r,i;return t&&e<.21||e>=179?(r=10,i=10):e>=25?(r=9,i=9):e>=12.5?(r=8,i=8):e>=6?(r=6,i=6):e>=3.2?(r=5,i=5):e>=1.6?(r=4,i=4):e>=.85?(r=3,i=3):e>=.42?(r=2,i=2):e>=.21?(r=1,i=1):e>=.12?(r=.5,i=.5):e>=.06?(r=.25,i=.25):(r=10,i=10),{lonStep:r,latStep:i}}}t.xyzFovHelper=new r,t.default=r},8755:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(8145),s=r(6553);class a{static isGeoJSON(e){if(!e||"object"!=typeof e)return!1;const t=e.type;return"FeatureCollection"===t||"Feature"===t||"Polygon"===t||"MultiPolygon"===t||"GeometryCollection"===t}static parseGeoJSON(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON root must be an object");const t=e;if("FeatureCollection"===t.type){if(!Array.isArray(t.features))throw new Error("GeoJSON FeatureCollection has no features array");return t.features.flatMap(e=>a.parseFeature(e))}if("Feature"===t.type)return a.parseFeature(t);if("Polygon"===t.type||"MultiPolygon"===t.type||"GeometryCollection"===t.type)return a.parseGeometry(t,{});throw new Error(`Unsupported GeoJSON type: ${t.type??"unknown"}`)}static parseFeature(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON feature must be an object");const t=e;if("Feature"!==t.type)throw new Error("GeoJSON feature has invalid type");return t.geometry?a.parseGeometry(t.geometry,t.properties??{},t.id):[]}static parseGeometry(e,t,r){return"Polygon"===e.type?[{id:r,geometryType:"Polygon",properties:t,polygons:a.parsePolygonCoordinates(e.coordinates)}]:"MultiPolygon"===e.type?[{id:r,geometryType:"MultiPolygon",properties:t,polygons:a.parseMultiPolygonCoordinates(e.coordinates)}]:"GeometryCollection"===e.type&&Array.isArray(e.geometries)?e.geometries.flatMap(e=>a.parseGeometry(e,t,r)):[]}static parseMultiPolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON MultiPolygon coordinates must be an array");return e.flatMap(e=>a.parsePolygonCoordinates(e))}static parsePolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON Polygon coordinates must be an array");return e.map(e=>a.parseLinearRing(e)).filter(e=>e.length>=3)}static parseLinearRing(e){if(!Array.isArray(e))throw new Error("GeoJSON linear ring must be an array");const t=e.map(e=>a.parsePosition(e));if(t.length>1){const e=t[0],r=t[t.length-1];e.lonDeg===r.lonDeg&&e.latDeg===r.latDeg&&t.pop()}return t}static parsePosition(e){if(!Array.isArray(e)||e.length<2)throw new Error("GeoJSON position must be [longitude, latitude]");const[t,r]=e;if(!Number.isFinite(t)||!Number.isFinite(r))throw new Error("GeoJSON position contains non-finite longitude/latitude");return new s.Point({lonDeg:t,latDeg:r},i.CoordsType.GEOGRAPHIC)}}t.default=a},8819:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMeshBuilder=void 0;const i=r(7930);function s(e){const t=Math.PI*(1-2*e);return 180*Math.atan(Math.sinh(t))/Math.PI}function a(e){return e<0?e+360:e}t.XYZMeshBuilder=class{buildTileMesh(e,t=16){const r=Math.max(1,Math.floor(t)),o=r+1,n=o*o,h=new Float32Array(3*n),l=new Float32Array(2*n),c=2**e.z;let u=0,d=0;for(let t=0;t<=r;t++){const o=t/r,n=(e.y+o)/c,_=90-Math.max(-85.0511287798066,Math.min(85.0511287798066,s(n)));for(let t=0;t<=r;t++){const s=t/r,n=a((e.x+s)/c*360-180),[f,g,p]=(0,i.sphericalToCartesian)(n,_,1);h[u++]=f,h[u++]=g,h[u++]=p,l[d++]=s,l[d++]=1-o}}const _=new Uint32Array(r*r*2*3);let f=0;for(let e=0;e<r;e++)for(let t=0;t<r;t++){const r=e*o+t,i=r+1,s=r+o,a=s+1;_[f++]=r,_[f++]=s,_[f++]=i,_[f++]=i,_[f++]=s,_[f++]=a}return{positions:h,uvs:l,indices:_.length>65535?_:new Uint16Array(_)}}buildAncestorMesh(e,t,r=16){const i=this.buildTileMesh(e,r),s=e.z-t.z,a=2**s,o=e.x-(t.x<<s),n=e.y-(t.y<<s),h=new Float32Array(i.uvs.length);for(let e=0;e<i.uvs.length;e+=2){const t=i.uvs[e]??0,r=1-(i.uvs[e+1]??0);h[e]=(o+t)/a,h[e+1]=1-(n+r)/a}return{positions:i.positions,uvs:h,indices:i.indices}}uploadMesh(e,t){const r=t.createBuffer(),i=t.createBuffer(),s=t.createBuffer(),a=e.indices instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT;return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.uvs,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:r,uvBuffer:i,indexBuffer:s,indexCount:e.indices.length,indexType:a}}}},8868:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMapDescriptor=void 0,t.XYZMapDescriptor=class{_name;_url;_urlResolver;_minZoom;_maxZoom;_segmentsPerSide;_tileSize;_maxCachedTiles;_interactionDebounceMs;_subdomains;_attribution;_flipY;_maxConcurrentLoads;constructor(e,t,r=0,i=8,s=16,a=384,o=8,n){this._name=e,this._url=t,this._urlResolver=n,this._minZoom=r,this._maxZoom=i,this._segmentsPerSide=s,this._maxCachedTiles=a,this._interactionDebounceMs=100,this._subdomains=["a","b","c"],this._attribution="",this._flipY=!1,this._maxConcurrentLoads=o}get url(){return this._url}get urlResolver(){return this._urlResolver}get name(){return this._name}get minZoom(){return this._minZoom}get maxZoom(){return this._maxZoom}get segmentsPerSide(){return this._segmentsPerSide}get maxCachedTiles(){return this._maxCachedTiles}get interactionDebounceMs(){return this._interactionDebounceMs}get subdomains(){return this._subdomains}get attribution(){return this._attribution}get flipY(){return this._flipY}get maxConcurrentLoads(){return this._maxConcurrentLoads}}},8909:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintShaderProgram=void 0;const s=r(1961),a=i(r(5947));t.FootprintShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix",point_size:"u_pointsize"},this.gl_attributes={vertex_pos:"aCatPosition"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,pointSize:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=a.default.footprintFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=a.default.footprintVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,r),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,r){const i=this._webgl;i.useProgram(this.shaderProgram),this.locations.pMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=i.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let a=s.mat4.create();a=s.mat4.multiply(a,r,t),i.uniformMatrix4fv(this.locations.pMatrix,!1,e),i.uniformMatrix4fv(this.locations.mvMatrix,!1,a)}}},9022:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TerraFootprintSetGL=void 0;const i=r(592),s=r(8145),a=r(2475),o=r(1072),n=r(5403),h=r(1072);class l extends i.FootprintSetGL{_kind="TerraFootprintSetGL";_coordsType=s.CoordsType.GEOGRAPHIC;addGeoJSONFeatures(e){this._ready=!1,this.clearFootprints(),this._metadataManager=new n.MetadataManager(this.createGeoJSONMetadataColumns(e));for(const t of e){const e=a.Footprint.fromPolygons(t.polygons,this.createGeoJSONDetails(t),s.CoordsType.GEOGRAPHIC);e.valid&&(this.addFootprint(e),this.totPoints+=e.totPoints,this.totConvexPoints+=e.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}createGeoJSONMetadataColumns(e){const t=new Set;return e.forEach(e=>Object.keys(e.properties).forEach(e=>t.add(e))),Array.from(t).map((t,r)=>{const i=e.map(e=>e.properties[t]).filter(e=>null!=e&&""!==e),s=i.length>0&&i.every(e=>"number"==typeof e||!Number.isNaN(Number(e))),a=/^name$|nome|denominazione|label|title/i.test(t);return new o.MetadataColumn({index:r,name:t,columnType:a?h.ColumnType.MAIN_NAME:s?h.ColumnType.NUMBER:h.ColumnType.STRING,unit:""})})}createGeoJSONDetails(e){return Object.entries(e.properties).map(([e,t])=>({key:e,value:"number"==typeof t?t:String(t??"")}))}}t.TerraFootprintSetGL=l},9665:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(6553),a=r(8145),o=i(r(4382));class n{static parseSTCS(e,t={}){const r=n.cleanStcs(e);return r.includes("POLYGON")?n.parsePolygon(r,t):r.includes("CIRCLE")?n.parseCircle(r,t):(console.warn("STCS not recognised"),{totpoints:0,polygons:[]})}static cleanStcs(e){let t=e.toUpperCase();return t=t.replace(/'ICRS'/g,"").replace(/\bICRS\b/g,"").replace(/\bJ2000\b/g,"").replace(/\bUNION\b/g,"").replace(/\bTOPOCENTER\b/g,""),t=t.replace(/[()]/g,""),t=t.replace(/ {2,}/g," ").trim(),t}static parsePolygon(e,t={}){let r=0;const i=[],n=o.default.MAX_DECIMALS??12,h=t.coordsType??a.CoordsType.ASTRO,l=e.split("POLYGON ");for(let e=1;e<l.length;e++){const t=[],o=l[e].trim().split(" "),c=Number(parseFloat(o[0]).toFixed(n)),u=Number(parseFloat(o[1]).toFixed(n)),d=Number(parseFloat(o[o.length-2]).toFixed(n)),_=Number(parseFloat(o[o.length-1]).toFixed(n));if(c===d&&u===_&&o.splice(o.length-2,2),o.length>2){for(let e=0;e<o.length-1;e+=2){const i=Number(parseFloat(o[e]).toFixed(n)),l=Number(parseFloat(o[e+1]).toFixed(n)),c=h===a.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:i,latDeg:l},a.CoordsType.GEOGRAPHIC):new s.Point({raDeg:i,decDeg:l},a.CoordsType.ASTRO);t.push(c),r+=1}i.push(t)}}return{totpoints:r,polygons:i}}static parseCircle(e,t={}){let r=0;const i=[],o=t.coordsType??a.CoordsType.ASTRO,n=e.split("CIRCLE ");for(let e=1;e<n.length;e++){const t=[],h=n[e].trim().split(" "),l=Number(h[0]),c=Number(h[1]),u=Number(h[2]),d=24,_=2*Math.PI/d;for(let e=d;e>0;e--){const i=u*Math.cos(e*_)+l,n=u*Math.sin(e*_)+c,h=o===a.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:i,latDeg:n},a.CoordsType.GEOGRAPHIC):new s.Point({raDeg:i,decDeg:n},a.CoordsType.ASTRO);t.push(h),r+=1}i.push(t)}return{totpoints:r,polygons:i}}}t.default=n},9685:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PerspectiveMatrixManager=void 0;const i=r(1961),s=r(2919);t.PerspectiveMatrixManager=class{_pMatrix;_aspectRatio=1;constructor(e,t,r,i=.1,s){this._pMatrix=this.computePerspectiveMatrix(e,t,r,i,s)}get pMatrix(){return this._pMatrix}set pMatrix(e){this._pMatrix=e}computePerspectiveMatrix(e,t,r,a=.1,o){this._aspectRatio=e.width/e.height;const n=i.mat4.create();let h;if(o)h=1.1;else{const e=t.getCameraMatrix(),r=-Number(e[14]),i=1,s=Math.sqrt(Math.max(r**2-i**2,0)),a=Math.atan2(s,i),o=s*Math.sin(a);h=o>0?o:i}const l=o?s.bootSetup.inside_camera_fov_deg:r,c=o?Math.max(a,.001):a;return i.mat4.perspective(n,l*Math.PI/180,this._aspectRatio,c,h),this._pMatrix=n,n}}},9839:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EquatorialGrid=void 0;const s=r(1961),a=r(229),o=r(7930),n=i(r(4707)),h=r(6553),l=r(8145),c=r(8083),u=i(r(5361)),d=r(4595),_=r(4735);class f extends _.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;showGrid=!1;_shaderProgram;_vertexShader;_fragmentShader;defaultColor="#41d421";gridText=new u.default("equatorial");_attribLocations={position:0,selected:1,pointSize:2,color:3};_phiVertexPositionBuffer;_thetaVertexPositionBuffer;_fov;_phiStep=0;_phiStepRad=0;_thetaStep=0;_thetaStepRad=0;_phiArray=[];_thetaArray=[];_bufferKey="";_dec4Labels=new Map;_ra4Labels=new Map;_healpixGrid;constructor(e,t){super(d.HealpixGrid.RADIUS,d.HealpixGrid.INITIAL_POSITION,d.HealpixGrid.INITIAL_PhiRad,d.HealpixGrid.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=n.default.healpixGridFS();if(this._fragmentShader=super.webgl.createShader(super.webgl.FRAGMENT_SHADER),super.webgl.shaderSource(this._fragmentShader,e),super.webgl.compileShader(this._fragmentShader),!super.webgl.getShaderParameter(this._fragmentShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(e),void alert(e)}const t=n.default.healpixGridVS();if(this._vertexShader=super.webgl.createShader(super.webgl.VERTEX_SHADER),super.webgl.shaderSource(this._vertexShader,t),super.webgl.compileShader(this._vertexShader),!super.webgl.getShaderParameter(this._vertexShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(e),void alert(e)}super.webgl.attachShader(this._shaderProgram,this._vertexShader),super.webgl.attachShader(this._shaderProgram,this._fragmentShader),super.webgl.linkProgram(this._shaderProgram),super.webgl.getProgramParameter(this._shaderProgram,super.webgl.LINK_STATUS)||alert("Could not initialise shaders"),super.webgl.useProgram(this._shaderProgram)}initBuffers(e,t=!1){const r=a.fovHelper.getRADegSteps(e,t),i=r.raStep,s=r.decStep;this._phiStep=i,this._phiStepRad=(0,o.degToRad)(i),this._thetaStep=s,this._thetaStepRad=(0,o.degToRad)(s),this._ra4Labels=new Map,this._dec4Labels=new Map,this._phiArray=[],this._thetaArray=[];for(let e=s;e<180;e+=s){const t=new Float32Array(360/i*3),r=(0,o.degToRad)(e);for(let e=0;e<360;e+=i){const s=(0,o.degToRad)(e),a=1*Math.sin(r)*Math.cos(s),n=1*Math.sin(r)*Math.sin(s),h=1*Math.cos(r),l=Math.floor(e/i);t[3*l+0]=a,t[3*l+1]=n,t[3*l+2]=h,this._dec4Labels.has(e)||this._dec4Labels.set(e,[]),this._dec4Labels.get(e).push([a,n,h])}this._phiArray.push(t)}for(let e=0;e<360;e+=i){const t=new Float32Array(360/s*3),r=(0,o.degToRad)(e);for(let e=0;e<360;e+=s){const i=(0,o.degToRad)(e),a=1*Math.sin(i)*Math.cos(r),n=1*Math.sin(i)*Math.sin(r),h=1*Math.cos(i),l=Math.floor(e/s);t[3*l+0]=a,t[3*l+1]=n,t[3*l+2]=h;const c=90-e;this._ra4Labels.has(c)||this._ra4Labels.set(c,[]),this._ra4Labels.get(c).push([a,n,h])}this._thetaArray.push(t)}}refresh(e,t=!1){const r=a.fovHelper.getRADegSteps(e,t),i=`${t?"coarse":"settled"}:${r.raStep}:${r.decStep}`;this._bufferKey!==i&&(this._fov=e,this._bufferKey=i,this.initBuffers(this._fov,t))}vectorDistance(e,t){const r=e.x-t.x,i=e.y-t.y,s=e.z-t.z;return Math.sqrt(r*r+i*i+s*s)}enableShader(e,t,r){const i=super.webgl;i.useProgram(this._shaderProgram);const a=s.mat4.create();s.mat4.multiply(a,r,e);const n=i.getUniformLocation(this._shaderProgram,"uMVMatrix"),h=i.getUniformLocation(this._shaderProgram,"uPMatrix"),l=i.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=i.getAttribLocation(this._shaderProgram,"aCatPosition"),n&&i.uniformMatrix4fv(n,!1,a),h&&i.uniformMatrix4fv(h,!1,t),l){const e=(0,o.colorHex2RGB)(this.defaultColor);i.uniform4f(l,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 r=super.webgl,i=this.getModelMatrix(),a=e.camera;if(!a)return;const n=a.getCameraMatrix(),u=e.pMatrix;if(!u)return;if(!n)return;if(0===this._thetaArray.length)return;if(this.refresh(t,!!e.cameraMoving),!this.showGrid)return void this.gridText.resetDivSets();this.enableShader(i,u,n);for(let e=0;e<this._phiArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._phiVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._phiArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._phiStep);for(let e=0;e<this._thetaArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._thetaVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._thetaArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._thetaStep);const d=c.FoVUtils.getCenterJ2000(r.canvas,this._healpixGrid,this._webgl,a,u),_=s.mat4.create();s.mat4.multiply(_,n,i);const f=s.mat4.create();s.mat4.multiply(f,u,_);for(const[e,t]of this._dec4Labels.entries())if(Math.abs(e-d.raDeg)<=this._phiStep)for(let e=0;e<t.length;e++){const[r,i,a]=t[e],o=[r,i,a,1],n=new h.Point({x:r,y:i,z:a},l.CoordsType.CARTESIAN).decDeg;if(Math.abs(n-d.decDeg)<60){const e=s.vec4.create();s.vec4.transformMat4(e,o,f),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),r=t.left+(.5*e[0]+.5)*t.width,i=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(n.toFixed(2),r,i,"dec")}}for(const[e,t]of this._ra4Labels.entries())if(Math.abs(e-d.decDeg)<=this._thetaStep)for(let e=0;e<t.length;e++){const[r,i,a]=t[e],n=[r,i,a,1],c=new h.Point({x:r,y:i,z:a},l.CoordsType.CARTESIAN),u=this.vectorDistance(c,d),_=c.raDeg;if(u<(0,o.degToRad)(50)){const e=s.vec4.create();s.vec4.transformMat4(e,n,f),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),r=t.left+(.5*e[0]+.5)*t.width,i=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(_.toFixed(2),r,i,"ra")}}this.gridText.resetDivSets(),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}t.EquatorialGrid=f}},t={};function r(i){var s=t[i];if(void 0!==s)return s.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports}return r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(1229)})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("astroviewer",[],t):"object"==typeof exports?exports.astroviewer=t():e.astroviewer=t()}(self,()=>(()=>{var e={3890(e,t,i){"use strict";i.d(t,{mat4:()=>r,vec3:()=>s,vec4:()=>o});var r={};i.r(r),i.d(r,{clone:()=>h,create:()=>l,fromValues:()=>c,identity:()=>d,invert:()=>g,multiply:()=>_,perspective:()=>m,rotate:()=>f,set:()=>u,targetTo:()=>x,translate:()=>p});var s={};i.r(s),i.d(s,{add:()=>y,clone:()=>S,create:()=>b,cross:()=>I,dot:()=>A,fromValues:()=>M,length:()=>v,normalize:()=>E,scale:()=>w,scaleAndAdd:()=>C,set:()=>T,subtract:()=>P,transformMat4:()=>F});var o={};i.r(o),i.d(o,{create:()=>L,fromValues:()=>D,transformMat4:()=>B});var a=1e-6,n="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI,Math.PI;function l(){var e=new n(16);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function h(e){var t=new n(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function c(e,t,i,r,s,o,a,l,h,c,u,d,g,_,p,f){var m=new n(16);return m[0]=e,m[1]=t,m[2]=i,m[3]=r,m[4]=s,m[5]=o,m[6]=a,m[7]=l,m[8]=h,m[9]=c,m[10]=u,m[11]=d,m[12]=g,m[13]=_,m[14]=p,m[15]=f,m}function u(e,t,i,r,s,o,a,n,l,h,c,u,d,g,_,p,f){return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e[4]=o,e[5]=a,e[6]=n,e[7]=l,e[8]=h,e[9]=c,e[10]=u,e[11]=d,e[12]=g,e[13]=_,e[14]=p,e[15]=f,e}function d(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function g(e,t){var i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],n=t[5],l=t[6],h=t[7],c=t[8],u=t[9],d=t[10],g=t[11],_=t[12],p=t[13],f=t[14],m=t[15],x=i*n-r*a,b=i*l-s*a,S=i*h-o*a,v=r*l-s*n,M=r*h-o*n,T=s*h-o*l,y=c*p-u*_,P=c*f-d*_,w=c*m-g*_,C=u*f-d*p,E=u*m-g*p,A=d*m-g*f,I=x*A-b*E+S*C+v*w-M*P+T*y;return I?(I=1/I,e[0]=(n*A-l*E+h*C)*I,e[1]=(s*E-r*A-o*C)*I,e[2]=(p*T-f*M+m*v)*I,e[3]=(d*M-u*T-g*v)*I,e[4]=(l*w-a*A-h*P)*I,e[5]=(i*A-s*w+o*P)*I,e[6]=(f*S-_*T-m*b)*I,e[7]=(c*T-d*S+g*b)*I,e[8]=(a*E-n*w+h*y)*I,e[9]=(r*w-i*E-o*y)*I,e[10]=(_*M-p*S+m*x)*I,e[11]=(u*S-c*M-g*x)*I,e[12]=(n*P-a*C-l*y)*I,e[13]=(i*C-r*P+s*y)*I,e[14]=(p*b-_*v-f*x)*I,e[15]=(c*v-u*b+d*x)*I,e):null}function _(e,t,i){var r=t[0],s=t[1],o=t[2],a=t[3],n=t[4],l=t[5],h=t[6],c=t[7],u=t[8],d=t[9],g=t[10],_=t[11],p=t[12],f=t[13],m=t[14],x=t[15],b=i[0],S=i[1],v=i[2],M=i[3];return e[0]=b*r+S*n+v*u+M*p,e[1]=b*s+S*l+v*d+M*f,e[2]=b*o+S*h+v*g+M*m,e[3]=b*a+S*c+v*_+M*x,b=i[4],S=i[5],v=i[6],M=i[7],e[4]=b*r+S*n+v*u+M*p,e[5]=b*s+S*l+v*d+M*f,e[6]=b*o+S*h+v*g+M*m,e[7]=b*a+S*c+v*_+M*x,b=i[8],S=i[9],v=i[10],M=i[11],e[8]=b*r+S*n+v*u+M*p,e[9]=b*s+S*l+v*d+M*f,e[10]=b*o+S*h+v*g+M*m,e[11]=b*a+S*c+v*_+M*x,b=i[12],S=i[13],v=i[14],M=i[15],e[12]=b*r+S*n+v*u+M*p,e[13]=b*s+S*l+v*d+M*f,e[14]=b*o+S*h+v*g+M*m,e[15]=b*a+S*c+v*_+M*x,e}function p(e,t,i){var r,s,o,a,n,l,h,c,u,d,g,_,p=i[0],f=i[1],m=i[2];return t===e?(e[12]=t[0]*p+t[4]*f+t[8]*m+t[12],e[13]=t[1]*p+t[5]*f+t[9]*m+t[13],e[14]=t[2]*p+t[6]*f+t[10]*m+t[14],e[15]=t[3]*p+t[7]*f+t[11]*m+t[15]):(r=t[0],s=t[1],o=t[2],a=t[3],n=t[4],l=t[5],h=t[6],c=t[7],u=t[8],d=t[9],g=t[10],_=t[11],e[0]=r,e[1]=s,e[2]=o,e[3]=a,e[4]=n,e[5]=l,e[6]=h,e[7]=c,e[8]=u,e[9]=d,e[10]=g,e[11]=_,e[12]=r*p+n*f+u*m+t[12],e[13]=s*p+l*f+d*m+t[13],e[14]=o*p+h*f+g*m+t[14],e[15]=a*p+c*f+_*m+t[15]),e}function f(e,t,i,r){var s,o,n,l,h,c,u,d,g,_,p,f,m,x,b,S,v,M,T,y,P,w,C,E,A=r[0],I=r[1],F=r[2],R=Math.sqrt(A*A+I*I+F*F);return R<a?null:(A*=R=1/R,I*=R,F*=R,s=Math.sin(i),n=1-(o=Math.cos(i)),l=t[0],h=t[1],c=t[2],u=t[3],d=t[4],g=t[5],_=t[6],p=t[7],f=t[8],m=t[9],x=t[10],b=t[11],S=A*A*n+o,v=I*A*n+F*s,M=F*A*n-I*s,T=A*I*n-F*s,y=I*I*n+o,P=F*I*n+A*s,w=A*F*n+I*s,C=I*F*n-A*s,E=F*F*n+o,e[0]=l*S+d*v+f*M,e[1]=h*S+g*v+m*M,e[2]=c*S+_*v+x*M,e[3]=u*S+p*v+b*M,e[4]=l*T+d*y+f*P,e[5]=h*T+g*y+m*P,e[6]=c*T+_*y+x*P,e[7]=u*T+p*y+b*P,e[8]=l*w+d*C+f*E,e[9]=h*w+g*C+m*E,e[10]=c*w+_*C+x*E,e[11]=u*w+p*C+b*E,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}var m=function(e,t,i,r,s){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=s&&s!==1/0){var a=1/(r-s);e[10]=(s+r)*a,e[14]=2*s*r*a}else e[10]=-1,e[14]=-2*r;return e};function x(e,t,i,r){var s=t[0],o=t[1],a=t[2],n=r[0],l=r[1],h=r[2],c=s-i[0],u=o-i[1],d=a-i[2],g=c*c+u*u+d*d;g>0&&(c*=g=1/Math.sqrt(g),u*=g,d*=g);var _=l*d-h*u,p=h*c-n*d,f=n*u-l*c;return(g=_*_+p*p+f*f)>0&&(_*=g=1/Math.sqrt(g),p*=g,f*=g),e[0]=_,e[1]=p,e[2]=f,e[3]=0,e[4]=u*f-d*p,e[5]=d*_-c*f,e[6]=c*p-u*_,e[7]=0,e[8]=c,e[9]=u,e[10]=d,e[11]=0,e[12]=s,e[13]=o,e[14]=a,e[15]=1,e}function b(){var e=new n(3);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function S(e){var t=new n(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function v(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function M(e,t,i){var r=new n(3);return r[0]=e,r[1]=t,r[2]=i,r}function T(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e}function y(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function P(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function w(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function C(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function E(e,t){var i=t[0],r=t[1],s=t[2],o=i*i+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function A(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function I(e,t,i){var r=t[0],s=t[1],o=t[2],a=i[0],n=i[1],l=i[2];return e[0]=s*l-o*n,e[1]=o*a-r*l,e[2]=r*n-s*a,e}function F(e,t,i){var r=t[0],s=t[1],o=t[2],a=i[3]*r+i[7]*s+i[11]*o+i[15];return a=a||1,e[0]=(i[0]*r+i[4]*s+i[8]*o+i[12])/a,e[1]=(i[1]*r+i[5]*s+i[9]*o+i[13])/a,e[2]=(i[2]*r+i[6]*s+i[10]*o+i[14])/a,e}var R;R=b();function L(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function D(e,t,i,r){var s=new n(4);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s}function B(e,t,i){var r=t[0],s=t[1],o=t[2],a=t[3];return e[0]=i[0]*r+i[4]*s+i[8]*o+i[12]*a,e[1]=i[1]*r+i[5]*s+i[9]*o+i[13]*a,e[2]=i[2]*r+i[6]*s+i[10]*o+i[14]*a,e[3]=i[3]*r+i[7]*s+i[11]*o+i[15]*a,e}!function(){var e=L()}()},4723(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(2919),o=r(i(7734)),a=r(i(4639)),n=r(i(4382)),l=r(i(4396)),h=i(7930),c=i(3726),u=i(9685),d=i(6553),g=i(8083),_=i(9839),p=i(4595),f=i(8145),m=r(i(619)),x=i(5409),b=i(3956),S=i(8868),v=i(1741),M=i(6878),T=i(3890);class y{static MIN_WHEEL_SCALE=.85;static MAX_WHEEL_SCALE=1.8;_camera;_perspectiveMatrixManager;centralPoinCoords;mousePointCoords;canvas;_healpixGrid;_equatorialGrid;mouseHelper;mouseDown=!1;lastMouseX=null;lastMouseY=null;inertiaX=0;inertiaY=0;zoomInertia=0;pointerDownX=null;pointerDownY=null;pointerDownAt=0;_activeHiPS=null;_activeXYZ2=null;_activeMeshHiPS=null;_activeBaseLayer=null;startup=!0;fov;activeCatalogues=[];activeFootprintSets=[];activePolylineSets=[];activeSensorCones=[];activeSatelliteObjects=[];_webgl;_selectedColorMap;_cameraStatusChanged=!1;lastCameraChangedAt=0;lastCameraMotionAt=0;lastHoveredSource=null;lastHoveredCatalogue=null;zoomSensitivity=1;lockedEastWestRaDeg=null;lockedNorthSouthDecDeg=null;keepCameraNorthUp=!0;gridLabelContainers;constructor(e,t,i={}){console.log("[AstroSphere] new instance for canvas",e.id),this._webgl=t,this.mouseHelper=new l.default,this.canvas=e,this.gridLabelContainers=i.gridLabelContainers;this._selectedColorMap=m.default.native,n.default.insideSphere=s.bootSetup.insideSphere,this.initCamera(),this._healpixGrid=new p.HealpixGrid(this._webgl,this.gridLabelContainers),this._perspectiveMatrixManager=new u.PerspectiveMatrixManager(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,s.bootSetup.insideSphere),this._equatorialGrid=new _.EquatorialGrid(this._webgl,this._healpixGrid,this.gridLabelContainers),this._equatorialGrid.init(this._healpixGrid.getMinFoV()),this.updateCentralPoint(),this.startup=!0,this.addEventListeners(e),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}initCamera(){s.bootSetup.insideSphere?this._camera=new o.default([0,0,-.005],!0):this._camera=new o.default([0,0,4],!1)}setCamera(e){this._camera=e}setCameraRotationSensitivity(e){this._camera.setRotationSensitivity(e)}getCameraRotationSensitivity(){return this._camera.getRotationSensitivity()}get healpixGrid(){return this._healpixGrid}get equatorialGrid(){return this._equatorialGrid}updateCentralPoint(){const e=this.getPhiThetaDeg(this.canvas),t=(0,h.sphericalToAstroDeg)(e.phi,e.theta),i=(0,h.raDegToHMS)(t.ra),r=(0,h.decDegToDMS)(t.dec);return this.centralPoinCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.centralPoinCoords}updateLastMousePoint(){const e={phi:this.mouseHelper.phi,theta:this.mouseHelper.theta},t={ra:this.mouseHelper.ra,dec:this.mouseHelper.dec},i=this.mouseHelper.raHMS,r=this.mouseHelper.decDMS;return this.mousePointCoords={astroDeg:t,sphericalDeg:e,raHMS:i,decDMS:r},this.mousePointCoords}clearLastMousePoint(){this.mousePointCoords=void 0}getCentralPointCoordinates(){return this.centralPoinCoords}getLastMousePointCoordinates(){return this.mousePointCoords}clamp(e,t,i){return Math.min(i,Math.max(t,e))}computeZoomStep(e,t){const i=t<0?-1:1,r=this.clamp(Math.abs(t)/120,y.MIN_WHEEL_SCALE,y.MAX_WHEEL_SCALE);return i*this.clamp(.0012+.0025*Math.sqrt(Math.max(e,0)),.0012,.04)*r*this.zoomSensitivity}setZoomSensitivity(e){this.zoomSensitivity=this.clamp(e,.2,3)}getZoomSensitivity(){return this.zoomSensitivity}filterRotationDeltaByAstroLocks(e,t){const i=this._camera.isRotationLockedY(),r=this._camera.isRotationLockedX();if(!i&&!r)return{deltaX:e,deltaY:t};const s=a.default.getIntersectionPointWithSingleModel(this.canvas.clientWidth/2,this.canvas.clientHeight/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!s||s.length<3)return{deltaX:e,deltaY:t};const o=T.vec3.normalize(T.vec3.create(),T.vec3.fromValues(s[0],s[1],s[2])),n=T.vec3.fromValues(0,0,1),l=T.vec3.cross(T.vec3.create(),n,o);T.vec3.length(l)<1e-6?T.vec3.set(l,1,0,0):T.vec3.normalize(l,l);const h=T.vec3.scale(T.vec3.create(),o,T.vec3.dot(n,o)),c=T.vec3.subtract(T.vec3.create(),n,h);T.vec3.length(c)<1e-6&&T.vec3.cross(c,o,l),T.vec3.normalize(c,c);const u=this.projectModelDirectionToScreen(o,l),d=this.projectModelDirectionToScreen(o,c);if(!u||!d)return{deltaX:e,deltaY:t};let g=e,_=t;if(i){const e=g*u.x+_*u.y;g-=e*u.x,_-=e*u.y}if(r){const e=g*d.x+_*d.y;g-=e*d.x,_-=e*d.y}return{deltaX:g,deltaY:_}}projectModelDirectionToScreen(e,t){const i=T.vec3.scaleAndAdd(T.vec3.create(),e,t,.01),r=this.projectModelPointToScreen(e),s=this.projectModelPointToScreen(i);if(!r||!s)return null;const o=s.x-r.x,a=s.y-r.y,n=Math.hypot(o,a);return n<1e-6?null:{x:o/n,y:a/n}}projectModelPointToScreen(e){const t=this._camera.getCameraMatrix(),i=this._healpixGrid.getModelMatrix(),r=T.mat4.create(),s=T.mat4.create();T.mat4.multiply(r,t,i),T.mat4.multiply(s,this._perspectiveMatrixManager.pMatrix,r);const o=T.vec4.fromValues(e[0],e[1],e[2],1);return T.vec4.transformMat4(o,o,s),Math.abs(o[3])<1e-6?null:{x:o[0]/o[3],y:-o[1]/o[3]}}enforceAstronomicalRotationLocks(){if(null==this.lockedEastWestRaDeg&&null==this.lockedNorthSouthDecDeg)return!1;const e=this.updateCentralPoint();if(!e)return!1;const t=this.lockedEastWestRaDeg??e.astroDeg.ra,i=this.lockedNorthSouthDecDeg??e.astroDeg.dec;return(Math.abs(t-e.astroDeg.ra)>1e-6||Math.abs(i-e.astroDeg.dec)>1e-6)&&(this._camera.goTo(t,i),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}enforceCameraNorthUp(){if(!this.keepCameraNorthUp)return!1;const e=this.updateCentralPoint();return!!e&&(this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),!0)}emitCameraChanged(e){if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid?.fovObj)return;const t=this.getCurrentStatus();t&&this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:t,bubbles:!0,composed:!0}))}addEventListeners(e){n.default.debug&&console.log("[AstroSphere::addEventListeners]");const t=e.getBoundingClientRect();this.lastMouseX=t.left,this.lastMouseY=t.top;console.log("[AstroSphere] registering pointer and wheel listeners on canvas"),e.onpointerdown=t=>{e.setPointerCapture(t.pointerId),this.mouseDown=!0;const i=e.getBoundingClientRect();this.lastMouseX=t.clientX-i.left,this.lastMouseY=t.clientY-i.top,this.pointerDownX=this.lastMouseX,this.pointerDownY=this.lastMouseY,this.pointerDownAt=Date.now();const r=a.default.getIntersectionPointWithSingleModel(this.lastMouseX,this.lastMouseY,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return r&&r.length>0?(this.mouseHelper.update(r),this.updateLastMousePoint()):this.clearLastMousePoint(),t.preventDefault(),!1},e.onpointerup=t=>{if(e.releasePointerCapture(t.pointerId),this.mouseDown=!1,document.body.style.cursor="auto",0!==t.button)return t.preventDefault(),!1;const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top;this.lastMouseX=r,this.lastMouseY=s;const o=Math.hypot(r-(this.pointerDownX??r),s-(this.pointerDownY??s)),n=Date.now()-this.pointerDownAt;if(o<=4&&n<=250){const e=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(e&&e.length>0){this.mouseHelper.update(e),this.updateLastMousePoint();for(const e of this.activeCatalogues){const t=e.selectPrimarySourceFromClick(this.mouseHelper);t?.sources.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("source-clicked",{detail:{source:t.sources,selectionState:t.selectionState,catalogue:e},bubbles:!0,composed:!0}))}for(const e of this.activeFootprintSets){const t=e.selectPrimaryFootprintFromClick(this.mouseHelper);t?.footprints.length&&this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-clicked",{detail:{footprint:t.footprints,selectionState:t.selectionState,footprintSet:e},bubbles:!0,composed:!0}))}}}else this.clearLastMousePoint()},e.onpointermove=t=>{const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,o=r,l=s;if(this._healpixGrid){if(this.mouseDown){document.body.style.cursor="grab";const t=n.default.insideSphere?-1:1,i=n.default.insideSphere?10:1,r=t*i*(o-(this.lastMouseX??o))*Math.PI/e.width,s=t*i*(l-(this.lastMouseY??l))*Math.PI/e.height,a=this.filterRotationDeltaByAstroLocks(r,s);this.inertiaX+=.1*a.deltaX,this.inertiaY+=.1*a.deltaY,this.updateCentralPoint()}else{const e=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);e&&e.length>0?(this.mouseHelper.update(e),this.updateLastMousePoint()):this.clearLastMousePoint()}this.centralPoinCoords||this.updateCentralPoint(),this.lastMouseX=o,this.lastMouseY=l,this._cameraStatusChanged=!0,t.preventDefault()}},e.onpointerleave=()=>{this.clearLastMousePoint(),this._cameraStatusChanged=!0,this.emitCameraChanged("pointerleave")},console.log("[AstroSphere] adding wheel event listener with passive: false"),e.addEventListener("wheel",e=>{const t=this._healpixGrid.getMinFoV(),i=this.computeZoomStep(t,e.deltaY);this.zoomInertia=0,this._camera.zoom(i),this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this._cameraStatusChanged=!0,this.emitCameraChanged("wheel"),e.preventDefault()},{passive:!1}),e.addEventListener("contextmenu",t=>{t.preventDefault();const i=e.getBoundingClientRect(),r=t.clientX-i.left,s=t.clientY-i.top,o=a.default.getIntersectionPointWithSingleModel(r,s,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);if(!o||0===o.length)return!1;this.mouseHelper.update(o),this.updateLastMousePoint();for(const e of this.activeCatalogues){const i=e.getSourcesFromPointer(this.mouseHelper);if(i?.sources.length){this._webgl.canvas.dispatchEvent(new CustomEvent("source-contextmenu",{detail:{source:i.sources,catalogue:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}for(const e of this.activeFootprintSets){const i=e.getFootprintsFromPointer(this.mouseHelper);if(i?.footprints.length){this._webgl.canvas.dispatchEvent(new CustomEvent("footprint-contextmenu",{detail:{footprint:i.footprints,footprintSet:e,clientX:t.clientX,clientY:t.clientY},bubbles:!0,composed:!0}));break}}return!1}),console.log("[AstroSphere] registering global keydown listener on document"),document.addEventListener("keydown",e=>{if(e.ctrlKey)switch(e.key){case"1":this._camera.clearRotationLock();break;case"2":this._camera.setRotationLock({x:!0,y:!1,z:!1});break;case"3":this._camera.setRotationLock({x:!1,y:!0,z:!1});break;case"4":this._camera.setRotationLock({x:!1,y:!1,z:!0})}},{capture:!0})}getPhiThetaDeg(e){const t=e.getBoundingClientRect(),i=t.width,r=t.height,s=a.default.getIntersectionPointWithSingleModel(i/2,r/2,this._healpixGrid,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix);return(0,h.cartesianToSpherical)(s)}changeHiPSFormat(e){if(!this._activeHiPS)throw new Error("No active HiPS.");this._activeHiPS.changeFormat(e)}activateHiPS(e){this._activeHiPS&&this._healpixGrid.visibleTilesManager.tileBuffer.removeHiPS(this._activeHiPS),this._activeHiPS=new c.HiPS(1,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="hips"}activateXYZ(e){this.activateXYZ2(new S.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver)),this._activeBaseLayer="xyz"}activateXYZ2(e){this._activeXYZ2=new v.XYZMap(1,[0,0,0],0,0,e,this._webgl,this.gridLabelContainers),this._activeBaseLayer="xyz"}activateMeshHiPS(e){this._activeMeshHiPS=new M.MeshHiPS(e.meshRadius,[0,0,0],0,0,e,this._webgl,this._healpixGrid),this._activeBaseLayer="meships"}activateWMTS(e){const t=new b.WMTSAdapter(e).toXYZLayerConfig();this._activeXYZ2=new v.XYZMap(1,[0,0,0],0,0,new S.XYZMapDescriptor(e.layer?`WMTS ${e.layer}`:"WMTS Earth2 Layer",t.urlTemplate,t.minZoom??0,t.maxZoom??8,t.segmentsPerSide??48,t.maxCachedTiles??384,8,t.urlResolver),this._webgl,this.gridLabelContainers),this._activeBaseLayer="xyz"}async showCatalogue(e){return e&&this.activeCatalogues.push(e),e}deleteCatalogue(e){this.activeCatalogues=this.activeCatalogues.filter(t=>t!==e)}async showFootprintSet(e){return e&&this.activeFootprintSets.push(e),e}deleteFootprintSet(e){this.activeFootprintSets=this.activeFootprintSets.filter(t=>t!==e)}async showPolylineSet(e){return e&&this.activePolylineSets.push(e),e}deletePolylineSet(e){this.activePolylineSets=this.activePolylineSets.filter(t=>t!==e),e.dispose()}async showSensorCone(e){return e&&this.activeSensorCones.push(e),e}deleteSensorCone(e){this.activeSensorCones=this.activeSensorCones.filter(t=>t!==e),e.dispose()}async showSatelliteObject(e){return e&&this.activeSatelliteObjects.push(e),e}deleteSatelliteObject(e){this.activeSatelliteObjects=this.activeSatelliteObjects.filter(t=>t!==e),e.dispose()}getHoveredFootprints(){let e=[];return this.activeFootprintSets.forEach(t=>{e.push(t.hoveredFootprints)}),e}goTo(e,t){this._camera.goTo(e,t)}getActiveCoordinateMode(){return"xyz"===this._activeBaseLayer?"lonlat":"hips"===this._activeBaseLayer&&this._activeHiPS?.isGalacticHips?"galactic":"equatorial"}resetAxesOrientation(){const e=this.updateCentralPoint();e&&(this.inertiaX=0,this.inertiaY=0,this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.updateCentralPoint(),this._cameraStatusChanged=!0)}setKeepCameraNorthUp(e){this.keepCameraNorthUp=e,e&&this.resetAxesOrientation()}isKeepCameraNorthUp(){return this.keepCameraNorthUp}getFoV(){return"xyz"===this._activeBaseLayer&&this._activeXYZ2?this._activeXYZ2.getFoV():this.fov}getFoVPolygon(){if(null==this.healpixGrid)throw new Error(`healpixGrid is ${this.healpixGrid}`);return g.FoVUtils.getFoVPolygon(this._camera,this.canvas,this._healpixGrid,this._healpixGrid,this._webgl,this._perspectiveMatrixManager.pMatrix)}changeFoV(e){const t=this._healpixGrid.getFoV().computeDistanceFromAngle(e);this._camera.translate(t),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV)}changeFoV2(e){const t=this._healpixGrid.getFoV().computeCameraPositionForFoV(e);this._camera.setCameraPosition(t)}changeFoV3(e){const t=this._healpixGrid.getFoV().computeCameraPositionForAngularDiameter(e);this._camera.setCameraPosition(t),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,!1)}getInsideSphere(){return n.default.insideSphere}toggleInsideSphere(){const e=this.updateCentralPoint();this.inertiaX=0,this.inertiaY=0,this.zoomInertia=0,n.default.insideSphere=!n.default.insideSphere,this._camera.toggleInsideSphere(),this._camera.goTo(e.astroDeg.ra,e.astroDeg.dec),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.updateCentralPoint(),this.lastCameraMotionAt=performance.now(),this._cameraStatusChanged=!0,this.emitCameraChanged("inside-sphere-toggle"),requestAnimationFrame(()=>this.draw(this.canvas))}setCameraPosition(e){this._camera.setCameraPosition(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}setCameraMatrix(e){this._camera.setCameraMatrix(e),this._perspectiveMatrixManager.computePerspectiveMatrix(this.canvas,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere)}_refreshingStatus=!1;applyFullCameraState(e,t){this._refreshingStatus=!0,this._camera=e.camera,this._healpixGrid.setModelMatrix(e.mMatrix),this._perspectiveMatrixManager.pMatrix=e.pMatrix,this.setCameraMatrix(e.vMatrix),t&&this._activeHiPS?.changeColorMap(e.colorMap),this._refreshingStatus=!1}getCurrentStatus(){this.updateCentralPoint();const e=this.centralPoinCoords?.astroDeg.ra,t=this.centralPoinCoords?.astroDeg.dec;if(null==e||null==t)return null;let i=[];try{i=this.getFoVPolygon()}catch(e){console.warn("[AstroSphere] getCurrentStatus: FoV polygon is not available.",e)}return{fovDeg:this.fov.minFoV,fovXDeg:this.fov.xFoV,fovYDeg:this.fov.yFoV,position:this._camera.getCameraPosition(),vMatrix:this._camera.getCameraMatrix(),pMatrix:this._perspectiveMatrixManager.pMatrix,mMatrix:this._healpixGrid.getModelMatrix(),camera:this._camera,timestamp:performance.now(),centralPoint:new d.Point({raDeg:e,decDeg:t},f.CoordsType.ASTRO),mouseHoverPoint:this.mousePointCoords,colorMap:this._selectedColorMap,getFoVPolygon:i}}changeColorMap(e){(this._activeHiPS||this._activeXYZ2||this._activeMeshHiPS)&&(this._selectedColorMap=e,this._activeHiPS?.changeColorMap(e),this._activeXYZ2?.changeColorMap(e))}prevFov=0;prevCentralRaDeg=null;prevCentralDecDeg=null;get activeHiPS(){return this._activeHiPS}get activeXYZ(){return this._activeXYZ2}get activeMeshHiPS(){return this._activeMeshHiPS}isLonLatGridVisible(){return this._activeXYZ2?.isLonLatGridVisible()??!1}toggleLonLatGrid(){return this._activeXYZ2?.toggleLonLatGrid()??!1}setEastWestRotationLocked(e){this._camera.setRotationLock({y:e}),e&&(this.inertiaX=0),this.lockedEastWestRaDeg=e?this.updateCentralPoint()?.astroDeg.ra??null:null}isEastWestRotationLocked(){return this._camera.isRotationLockedY()}setNorthSouthRotationLocked(e){this._camera.setRotationLock({x:e}),e&&(this.inertiaY=0),this.lockedNorthSouthDecDeg=e?this.updateCentralPoint()?.astroDeg.dec??null:null}isNorthSouthRotationLocked(){return this._camera.isRotationLockedX()}getXYZDebugStats(){return{activeBaseLayer:this._activeBaseLayer,layer:this._activeXYZ2?.getDebugStats()??null,requests:x.xyzTileRequestScheduler.getDebugStats()}}getHiPSDebugStats(){return this._activeHiPS?this._activeHiPS.getDebugStats():null}getMeshHiPSDebugStats(){return this._activeMeshHiPS?this._activeMeshHiPS.getDebugStats():null}draw(e){if(this._refreshingStatus)return;if(!this._webgl)return;if(!this._activeHiPS&&!this._activeXYZ2&&!this._activeMeshHiPS)return;if(!this._healpixGrid||0===Object.keys(this._healpixGrid).length)return;if(void 0===this._healpixGrid.fovObj)return;this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);let t=!1,i=0,r=0;if(this._webgl.viewport(0,0,this._webgl.drawingBufferWidth,this._webgl.drawingBufferHeight),this._webgl.clear(this._webgl.COLOR_BUFFER_BIT|this._webgl.DEPTH_BUFFER_BIT),0!==this.zoomInertia&&(Math.abs(this.zoomInertia)>1e-4?(this._camera.zoom(this.zoomInertia),this.zoomInertia*=.95,this.lastCameraMotionAt=performance.now(),this.fov=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix),this._camera.refreshFoV(this.fov.minFoV),this.prevFov!==this.fov.minFoV&&(this.centralPoinCoords||(this.centralPoinCoords=this.updateCentralPoint()),this.prevFov=this.fov.minFoV)):this.zoomInertia=0,this._cameraStatusChanged=!0),this.mouseDown||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02){t=!0;const o=this.filterRotationDeltaByAstroLocks(this.inertiaX,this.inertiaY);r=o.deltaX,i=o.deltaY,this.inertiaX=.95*o.deltaX,this.inertiaY=.95*o.deltaY,this._camera.rotate(r,i),this.lastCameraMotionAt=performance.now(),this._perspectiveMatrixManager.computePerspectiveMatrix(e,this._camera,s.bootSetup.camera_fov_deg,s.bootSetup.camera_near_plane,n.default.insideSphere);this.enforceAstronomicalRotationLocks()||this.enforceCameraNorthUp()}else this.inertiaY=0,this.inertiaX=0;const o=this._healpixGrid.refreshFoV(this._camera,this._perspectiveMatrixManager.pMatrix);if(Number.isFinite(o.minFoV)&&o.minFoV>0&&(this.fov=o,this._camera.refreshFoV(this.fov.minFoV),this.prevFov=this.fov.minFoV),t){const e=this.updateCentralPoint(),t=e.astroDeg.ra,i=e.astroDeg.dec,r=null===this.prevCentralRaDeg||Math.abs(t-this.prevCentralRaDeg)>1e-5,s=null===this.prevCentralDecDeg||Math.abs(i-this.prevCentralDecDeg)>1e-5;(r||s)&&(this.prevCentralRaDeg=t,this.prevCentralDecDeg=i)}if(this._cameraStatusChanged){const e=performance.now(),t=!this.mouseDown||e-this.lastCameraChangedAt>100,i=t?this.getCurrentStatus():null;i&&(this.canvas.dispatchEvent(new CustomEvent("camera-changed",{detail:i,bubbles:!0,composed:!0})),this.lastCameraChangedAt=e),!this.startup&&t&&(this._cameraStatusChanged=!1)}if(this._webgl.disable(this._webgl.DEPTH_TEST),this._webgl.enable(this._webgl.BLEND),this._webgl.enable(this._webgl.CULL_FACE),this._webgl.cullFace(n.default.insideSphere?this._webgl.FRONT:this._webgl.BACK),this._webgl.blendFunc(this._webgl.SRC_ALPHA,this._webgl.ONE_MINUS_SRC_ALPHA),"hips"===this._activeBaseLayer&&this._activeHiPS){const e=Math.min(this._healpixGrid.visibleorder,this._activeHiPS.maxOrder);this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}if("meships"===this._activeBaseLayer&&this._activeMeshHiPS){const e=this._activeMeshHiPS.refreshOrder(this.fov?.minFoV??this._healpixGrid.getMinFoV());this._healpixGrid.visibleTilesManager.computeVisiblePixels(e,this._webgl,this._camera,this._perspectiveMatrixManager.pMatrix)}const a=this.fov?.minFoV??this._healpixGrid.getMinFoV(),l=performance.now(),c=this.mouseDown||Math.abs(this.zoomInertia)>1e-4||Math.abs(this.inertiaX)>.02||Math.abs(this.inertiaY)>.02||l-this.lastCameraMotionAt<220,u={fovDeg:a,camera:this._camera,pMatrix:this._perspectiveMatrixManager.pMatrix,centerSphericalDeg:this.updateCentralPoint().sphericalDeg,fovPolygon:void 0,viewportSphericalSamples:void 0,cameraMoving:c};if("hips"===this._activeBaseLayer&&this._activeHiPS?.draw(u),"xyz"===this._activeBaseLayer&&this._activeXYZ2?.draw(u),"meships"===this._activeBaseLayer&&this._activeMeshHiPS?.draw(u),this._healpixGrid.draw(u),this._equatorialGrid.draw(u),this._webgl.enable(this._webgl.DEPTH_TEST),this._webgl.disable(this._webgl.CULL_FACE),this.startup){this.startup=!1;const t=this.getPhiThetaDeg(e),i=(0,h.sphericalToAstroDeg)(t.phi,t.theta),r=(0,h.raDegToHMS)(i.ra),s=(0,h.decDegToDMS)(i.dec);this.prevFov=this.fov?.minFoV??this._healpixGrid.getMinFoV(),this._cameraStatusChanged=!0,console.log("(startup coords)",{raDeg:i.ra,decDeg:i.dec,raHMS:r,decDMS:s})}this.activeCatalogues.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.emitHoveredSourceIfChanged(),this.activeFootprintSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.activePolylineSets.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(t,this.mouseHelper,this._camera.getCameraMatrix(),this._perspectiveMatrixManager.pMatrix)}),this.activeSensorCones.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(this._perspectiveMatrixManager.pMatrix,this._camera.getCameraMatrix(),t)}),this.activeSatelliteObjects.forEach(e=>{const t=this._activeHiPS?.getModelMatrix()??this._activeXYZ2?.getModelMatrix()??this._activeMeshHiPS?.getModelMatrix();t&&e.draw(this._perspectiveMatrixManager.pMatrix,this._camera.getCameraMatrix(),t)})}emitHoveredSourceIfChanged(){let e=null,t=null;for(const i of this.activeCatalogues){const r=i.getPrimaryHoveredSource();if(r){e=r,t=i;break}}e===this.lastHoveredSource&&t===this.lastHoveredCatalogue||(this.lastHoveredSource=e,this.lastHoveredCatalogue=t,this._webgl.canvas.dispatchEvent(new CustomEvent("source-hovered",{detail:{source:e,catalogue:t},bubbles:!0,composed:!0})))}}t.default=y},772(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AstroViewer=void 0;const s=r(i(4723)),o=i(5087),a=i(1232),n=i(592),l=i(2919),h=r(i(619)),c=i(5409),u=i(8868),d=i(5781),g=i(9022),_=i(3665),p=i(3603),f=i(3102),m=i(847);t.AstroViewer=class{astroSphere;canvas;webgl;rafId=null;webglContextList=new Map;viewfinderEl=null;viewfinderVisible=l.bootSetup.showViewfinder;viewfinderColor="rgba(75,148,226,0.68)";options={};run(){return this.tick()}createCatalogue(e,t,i,r){return new a.CatalogueGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showCatalogue(e){this.astroSphere.showCatalogue(e)}hideCatalogue(e,t){e.setIsVisible(t)}deleteCatalogue(e){this.astroSphere.deleteCatalogue(e)}changeCatalogueRA(e,t){return e.changeMetaRA(t),e}changeCatalogueDec(e,t){return e.changeMetaDec(t),e}changeCatalogueColor(e,t){return e.changeColor(t),e}setCatalogueShapeHue(e,t){return e.changeMetaShapeHue(t),e}setCatalogueShapeSize(e,t){return e.changeMetaShapeSize(t),e}createFootprintSet(e,t,i,r){return new n.FootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideFootprintSet(e,t){e.setIsVisible(t)}deleteFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPointSet(e,t,i,r){return new d.TerraPointSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPointSet(e){this.astroSphere.showCatalogue(e)}hideTerraPointSet(e,t){e.setIsVisible(t)}deleteTerraPointSet(e){this.astroSphere.deleteCatalogue(e)}createTerraFootprintSet(e,t,i,r){return new g.TerraFootprintSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraFootprintSet(e){this.astroSphere.showFootprintSet(e)}hideTerraFootprintSet(e,t){e.setIsVisible(t)}deleteTerraFootprintSet(e){this.astroSphere.deleteFootprintSet(e)}createTerraPolylineSet(e,t,i,r){return new _.TerraPolylineSetGL(e,t,i,r,this.webgl,this.astroSphere.healpixGrid.visibleTilesManager)}showTerraPolylineSet(e){this.astroSphere.showPolylineSet(e)}hideTerraPolylineSet(e,t){e.setIsVisible(t)}deleteTerraPolylineSet(e){this.astroSphere.deletePolylineSet(e)}changeTerraPolylineSetColor(e,t){return e.changeColor(t),e}createSensorCone(e){return new f.SensorConeGL(e,this.webgl)}showSensorCone(e){this.astroSphere.showSensorCone(e)}hideSensorCone(e,t){e.setIsVisible(t)}deleteSensorCone(e){this.astroSphere.deleteSensorCone(e)}createSatelliteObject(e){return new p.SatelliteObjectGL(e,this.webgl)}showSatelliteObject(e){this.astroSphere.showSatelliteObject(e)}hideSatelliteObject(e,t){e.setIsVisible(t)}deleteSatelliteObject(e){this.astroSphere.deleteSatelliteObject(e)}changeFootprintSetColor(e,t){e.changeColor(t)}getHoveredFootprints(){return this.astroSphere.getHoveredFootprints()}getDefaultHiPSURL(){return l.bootSetup.defaultHipsUrl}activateHiPS(e){this.astroSphere.activateHiPS(e)}activateXYZ(e){this.astroSphere.activateXYZ(e)}activateXYZ2(e){const t=new u.XYZMapDescriptor(e.name??"XYZ Earth2 Layer",e.urlTemplate,e.minZoom??0,e.maxZoom??8,e.segmentsPerSide??48,e.maxCachedTiles??384,8,e.urlResolver);this.astroSphere.activateXYZ2(t)}activateWMTS(e){this.astroSphere.activateWMTS(e)}activateMeshHiPS(e){this.astroSphere.activateMeshHiPS(new m.MeshHiPSDescriptor(e))}setXYZMaxConcurrentRequests(e){c.xyzTileRequestScheduler.setMaxConcurrent(e)}getXYZMaxConcurrentRequests(){return c.xyzTileRequestScheduler.getMaxConcurrent()}getXYZDebugStats(){return this.astroSphere.getXYZDebugStats()}getHiPSDebugStats(){return this.astroSphere.getHiPSDebugStats()}getMeshHiPSDebugStats(){return this.astroSphere.getMeshHiPSDebugStats()}async loadHiPS(e){const t=e.endsWith("/")?e:e+"/",i=await fetch(t+"properties");if(!i.ok)throw new Error(`HTTP ${i.status} fetching properties`);const r=await i.text(),s=new o.HiPSDescriptor(r,t);return this.astroSphere.activateHiPS(s),s.surveyName}async loadMeshHiPS(e,t={}){const i=e.endsWith("/")?e:e+"/";let r="";const s=await fetch(i+"properties");if(s.ok)r=await s.text();else{const e=await fetch(i+"properties.json");if(!e.ok)throw new Error(`HTTP ${e.status} fetching MeshHiPS properties`);const t=await e.json();r=Object.entries(t).map(([e,t])=>`${e}=${String(t)}`).join("\n")}const o=new m.MeshHiPSDescriptor({...t,baseUrl:i},r);return this.astroSphere.activateMeshHiPS(o),o.name}changeColorMap(e){const t=h.default[e];this.astroSphere.changeColorMap(t)}changeCustomColorMap(e){this.astroSphere.changeColorMap(e)}getActiveHiPS(){return this.astroSphere.activeHiPS}changeHiPSFormat(e){this.astroSphere.changeHiPSFormat(e)}getActiveHiPSFormats(){return this.astroSphere.activeHiPS?.availableFormats??[]}getActiveXYZ(){return this.astroSphere.activeXYZ}setCamera(e){this.astroSphere.setCamera(e)}setCameraPosition(e){this.astroSphere.setCameraPosition(e)}setCameraMatrix(e){this.astroSphere.setCameraMatrix(e)}restoreAstroViewerState(e,t){this.astroSphere.applyFullCameraState(e,t)}getCurrentAstroViewerStatus(){return this.astroSphere.getCurrentStatus()}goTo(e,t){this.astroSphere.goTo(e,t)}getActiveCoordinateMode(){return this.astroSphere.getActiveCoordinateMode()}getCenterCoordinates(){return this.astroSphere.getCentralPointCoordinates()}getCoordinatesFromMouse(){return this.astroSphere.getLastMousePointCoordinates()}setModelMatrix(e){this.astroSphere.healpixGrid.setModelMatrix(e)}toggleHealpixGrid(){this.astroSphere.healpixGrid.toggleShowGrid()}isHealpixGridVisible(){return this.astroSphere.healpixGrid.isVisible()}toggleEquatorialGrid(){return this.astroSphere.equatorialGrid.toggleShowGrid()}isEquatorialGridVisible(){return this.astroSphere.equatorialGrid.isVisible()}toggleLonLatGrid(){return this.astroSphere.toggleLonLatGrid()}isLonLatGridVisible(){return this.astroSphere.isLonLatGridVisible()}setEastWestRotationLocked(e){this.astroSphere.setEastWestRotationLocked(e)}isEastWestRotationLocked(){return this.astroSphere.isEastWestRotationLocked()}setNorthSouthRotationLocked(e){this.astroSphere.setNorthSouthRotationLocked(e)}isNorthSouthRotationLocked(){return this.astroSphere.isNorthSouthRotationLocked()}resetAxesOrientation(){this.astroSphere.resetAxesOrientation()}setKeepCameraNorthUp(e){this.astroSphere.setKeepCameraNorthUp(e)}isKeepCameraNorthUp(){return this.astroSphere.isKeepCameraNorthUp()}getFoV(){return this.astroSphere.getFoV()}getFoVPolygon(){return this.astroSphere.getFoVPolygon()}changeFoV(e){this.astroSphere.changeFoV(e)}changeFoV2(e){this.astroSphere.changeFoV2(e)}changeFoV3(e){this.astroSphere.changeFoV3(e)}getInsideSphere(){return this.astroSphere.getInsideSphere()}toggleInsideSphere(){this.astroSphere.toggleInsideSphere()}toggleViewfinder(){return this.viewfinderVisible=!this.viewfinderVisible,this.syncViewfinderVisibility(),this.viewfinderVisible}setViewfinderVisible(e){this.viewfinderVisible=e,this.syncViewfinderVisibility()}isViewfinderVisible(){return this.viewfinderVisible}setViewfinderColor(e){this.viewfinderColor=e,this.syncViewfinderColor()}getViewfinderColor(){return this.viewfinderColor}setRotationSensitivity(e){this.astroSphere.setCameraRotationSensitivity(e)}getRotationSensitivity(){return this.astroSphere.getCameraRotationSensitivity()}setZoomSensitivity(e){this.astroSphere.setZoomSensitivity(e)}getZoomSensitivity(){return this.astroSphere.getZoomSensitivity()}constructor(e,t={}){this.options=t,this.init(e),this.webglContextList=new Map}init(e){console.log("init webgl"),this.canvas=e,this.initViewfinder();const t=this.canvas.getContext("webgl2",{alpha:!1});if(!t)throw alert("Could not initialise WebGL, sorry :-("),new Error("WebGL2 not available");this.webgl=t;try{this.webgl.clearColor(0,.06274509792,50*.00392156862,.7)}catch(e){console.log("Error instantiating WebGL context")}this.initListeners(),this.astroSphere=new s.default(this.canvas,this.webgl,{gridLabelContainers:this.options.gridLabelContainers})}initViewfinder(){const e=this.canvas.parentElement;if(!e)return;"static"===window.getComputedStyle(e).position&&(e.style.position="relative");const t=document.createElement("div");t.setAttribute("data-astro-viewfinder","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.width="44px",t.style.height="44px",t.style.transform="translate(-50%, -50%)",t.style.pointerEvents="none",t.style.zIndex="1",t.style.boxSizing="border-box";const i=[{left:"50%",top:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"50%",bottom:"7px",width:"1px",height:"11px",transform:"translateX(-50%)"},{left:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"},{right:"7px",top:"50%",width:"11px",height:"1px",transform:"translateY(-50%)"}];for(const e of i){const i=document.createElement("div");i.style.position="absolute",i.style.left=e.left??"auto",i.style.right=e.right??"auto",i.style.top=e.top??"auto",i.style.bottom=e.bottom??"auto",i.style.width=e.width,i.style.height=e.height,i.style.transform=e.transform,i.style.background="currentColor",i.style.borderRadius="999px",i.style.boxShadow="0 0 0 1px rgba(0, 0, 0, 0.14)",t.appendChild(i)}e.appendChild(t),this.viewfinderEl=t,this.syncViewfinderVisibility(),this.syncViewfinderColor()}syncViewfinderVisibility(){this.viewfinderEl&&(this.viewfinderEl.style.display=this.viewfinderVisible?"block":"none")}syncViewfinderColor(){this.viewfinderEl&&(this.viewfinderEl.style.color=this.viewfinderColor)}initListeners(){console.log("inside initListeners");const e=()=>{console.log("[resizeCanvas]");const e=this.canvas.getBoundingClientRect(),t=window.devicePixelRatio||1,i=Math.max(1,Math.floor(e.width*t)),r=Math.max(1,Math.floor(e.height*t));this.canvas.width===i&&this.canvas.height===r||(this.canvas.width=i,this.canvas.height=r,this.webgl.viewport(0,0,this.canvas.width,this.canvas.height))};if("ResizeObserver"in window){new ResizeObserver(()=>{e()}).observe(this.canvas)}window.addEventListener("resize",e),this.canvas.addEventListener("webglcontextlost",e=>{console.log("[handleContextLost]"),e.preventDefault(),null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)},!1),this.canvas.addEventListener("webglcontextrestored",e=>{console.log("[handleContextRestored]"),this.webgl.clearColor(0,.06274509792,50*.00392156862,.7),this.webgl.enable(this.webgl.DEPTH_TEST),this.rafId=requestAnimationFrame(()=>this.tick())},!1),e()}tick(){return this.drawScene(),this.rafId=requestAnimationFrame(()=>this.tick()),this.rafId}drawScene(){this.astroSphere.draw(this.canvas)}}},7734(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(3890),o=i(7930),a=r(i(4382));t.default=class{insideSphere=!1;cam_pos=s.vec3.create();cam_speed=1;vMatrix=s.mat4.create();T=s.mat4.create();R=s.mat4.create();FoV=180;previousFoV=180;move=s.vec3.create();phi=0;theta=0;rotationSensitivity=1;lockRotX=!1;lockRotY=!1;lockRotZ=!1;constructor(e,t){this.init(e,t)}init(e,t){this.insideSphere=t,this.cam_pos=s.vec3.clone(e),this.vMatrix=s.mat4.create(),this.T=s.mat4.create(),this.R=s.mat4.create(),s.mat4.translate(this.T,this.T,[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]),this.FoV=this.previousFoV=180,this.move=s.vec3.clone([0,0,0]);this.goTo(0,0)}goTo(e,t){this.goToPhiTheta((0,o.astroDegToSpherical)(e,t))}goToPhiTheta(e){const t=(0,o.sphericalToCartesian)(e.phi,e.theta,this.cam_pos[2]),i=s.vec3.normalize(s.vec3.create(),s.vec3.fromValues(t[0],t[1],t[2])),r=s.vec3.fromValues(0,0,1),a=s.vec3.scale(s.vec3.create(),i,s.vec3.dot(r,i)),n=s.vec3.subtract(s.vec3.create(),r,a);s.vec3.length(n)<1e-6?s.vec3.set(n,0,1,0):s.vec3.normalize(n,n);let l=s.mat4.create();l=s.mat4.translate(l,l,s.vec3.fromValues(t[0],t[1],t[2]));const h=[l[12],l[13],l[14]];l=s.mat4.targetTo(l,h,[0,0,0],n),this.R=s.mat4.clone(l),this.R[12]=0,this.R[13]=0,this.R[14]=0;const c=s.mat4.create();0!==this.cam_pos[2]&&s.mat4.invert(c,l),this.vMatrix=c}toggleInsideSphere(){this.insideSphere=a.default.insideSphere,a.default.insideSphere?(this.cam_pos[0]=0,this.cam_pos[1]=0,this.cam_pos[2]=-.005):this.cam_pos[2]=2+this.cam_pos[2],s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}zoom(e){if(this.move=s.vec3.clone([0,0,0]),this.move[2]+=this.cam_speed*e,a.default.insideSphere)this.cam_pos[2]+this.move[2]>=-.005&&e>0?(this.cam_pos[2]=-.005,e=0):this.cam_pos[2]+this.move[2]<=-.9885&&e<0?(this.cam_pos[2]=-.9885,e=0):this.cam_pos[2]+=this.move[2];else{const t=Math.max(this.cam_pos[2]-1,1e-6),i=Math.min(1,t/.3),r=.015+.985*Math.pow(i,1.2);this.move[2]*=r,this.cam_pos[2]+this.move[2]<=1.000001&&e<0?this.cam_pos[2]=1.000001:this.cam_pos[2]+=this.move[2]}const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}moveAlongView(e){const t=s.mat4.create();s.mat4.invert(t,this.R);const i=s.vec3.fromValues(0,0,-1),r=s.vec3.create();s.vec3.transformMat4(r,i,t);const o=Math.hypot(r[0],r[1],r[2]);o>0&&(r[0]/=o,r[1]/=o,r[2]/=o),this.cam_pos[0]+=r[0]*e,this.cam_pos[1]+=r[1]*e,this.cam_pos[2]+=r[2]*e;const a=s.mat4.create();s.mat4.translate(this.T,a,this.cam_pos),this.refreshViewMatrix()}translate(e){this.cam_pos[2]=e+1;const t=s.mat4.create();s.mat4.translate(this.T,t,this.cam_pos),this.refreshViewMatrix()}rotateX(e){if(this.lockRotX)return;const t=.01*e;this.theta+=t,s.mat4.rotate(this.R,this.R,t,[1,0,0]),this.refreshViewMatrix()}rotateY(e){if(this.lockRotY)return;const t=.01*e;this.phi+=t,s.mat4.rotate(this.R,this.R,t,[0,1,0]),this.refreshViewMatrix()}rotateZ(e){if(this.lockRotZ)return;const t=.01*e;s.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshViewMatrix()}rotateXRadian(e){this.lockRotX||(s.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshViewMatrix())}rotateYRadian(e){this.lockRotY||(this.phi+=e,s.mat4.rotate(this.R,this.R,e,[0,1,0]),this.refreshViewMatrix())}rotateZRadian(e){this.lockRotZ||(s.mat4.rotate(this.R,this.R,e,[0,0,1]),this.refreshViewMatrix())}rotate(e,t){if(this.lockRotZ)return;const i=Math.sqrt(e*e+t*t);if(0===i)return;const r=this.getCameraPosition(),o=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),a=Math.max(o-1,1e-6),n=Math.min(1,a/.45),l=.02+.98*Math.pow(n,1.55),h=Math.min(1,this.FoV/18),c=i*l*(.06+1.55*Math.pow(h,.52))/1.9*this.rotationSensitivity;let u=t,d=e;const g=Math.sqrt(u*u+d*d);0!==g&&(u/=g,d/=g,s.mat4.rotate(this.R,this.R,-c,[u,d,0]),this.refreshViewMatrix())}setRotationSensitivity(e){this.rotationSensitivity=Math.min(3,Math.max(.2,e))}getRotationSensitivity(){return this.rotationSensitivity}refreshViewMatrix(){const e=s.mat4.create(),t=s.mat4.create();s.mat4.invert(e,this.T),s.mat4.invert(t,this.R),s.mat4.multiply(this.vMatrix,e,t)}refreshFoV(e){this.previousFoV=this.FoV,this.FoV=e}getCameraMatrix(){return this.vMatrix}getCameraPosition(){const e=s.mat4.create();return s.mat4.invert(e,this.vMatrix)?[e[12],e[13],e[14]]:[this.cam_pos[0],this.cam_pos[1],this.cam_pos[2]]}setCameraMatrix(e){this.vMatrix=e}setCameraPosition(e){this.cam_pos=s.vec3.fromValues(e[0],e[1],e[2]),s.mat4.translate(this.T,s.mat4.create(),this.cam_pos),this.refreshViewMatrix()}getCameraAngle(){const[e,t,i]=this.getCameraPosition(),r=s.vec3.fromValues(e,t,i),a=(0,o.cartesianToSpherical)(r);return console.log("[Camera::getCameraAngle]",a),a}setRotationLock(e){void 0!==e.x&&(this.lockRotX=e.x),void 0!==e.y&&(this.lockRotY=e.y),void 0!==e.z&&(this.lockRotZ=e.z)}clearRotationLock(){this.lockRotX=this.lockRotY=this.lockRotZ=!1}isRotationLockedX(){return this.lockRotX}isRotationLockedY(){return this.lockRotY}isRotationLockedZ(){return this.lockRotZ}}},2919(e,t){"use strict";t.bootSetup=void 0,t.bootSetup={insideSphere:!1,defaultHips:"",camera_fov_deg:34,camera_fov_rad:34*Math.PI/180,inside_camera_fov_deg:60,inside_camera_fov_rad:60*Math.PI/180,camera_near_plane:1e-5,camera_far_plane:2.5,corsProxyUrl:"http://localhost:4000/",useCORSProxy:!1,maxDecimals:15,defaultHipsUrl:"https://cdn.skies.esac.esa.int/DSSColor/",version:"Astrobrowser v1.0.0",debug:!1,insideView:!1,showViewfinder:!0}},4382(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(4851),s=i(2919);const o=new class{_healpix;_selectionnside;_useCORSProxy;_corsProxyUrl;_maxDecimals;_debug;_insideSphere;_version;constructor(){this._useCORSProxy=s.bootSetup.useCORSProxy,this._corsProxyUrl=s.bootSetup.corsProxyUrl,this._maxDecimals=s.bootSetup.maxDecimals,this._debug=s.bootSetup.debug,this._insideSphere=s.bootSetup.insideView,this._version=s.bootSetup.version,this._healpix={},this._selectionnside=32}init(){console.log("Global.init()")}get version(){return this._version}set corsProxyUrl(e){this._corsProxyUrl=e}get corsProxyUrl(){return this._corsProxyUrl}get useCORSProxy(){return this._useCORSProxy}set useCORSProxy(e){this._useCORSProxy=e}get debug(){return this._debug}getHealpix(e){return void 0===this._healpix[e]&&(this._healpix[e]=new r.Healpix(Math.pow(2,e))),this._healpix[e]}get MAX_DECIMALS(){return this._maxDecimals}set insideSphere(e){this._insideSphere=e}get insideSphere(){return this._insideSphere}get nsideForSelection(){return this._selectionnside}};t.default=o},1229(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=t.Source=t.MeshHiPSDescriptor=t.MeshHiPS=t.WMTSAdapter=t.XYZMap=t.HiPS=t.createColorMapFromSamples=t.COLOR_MAP_SAMPLE_COUNT=t.ColorMaps=t.GeoJSONParser=t.CoordsType=t.FoVUtils=t.CartesianOpts=t.PointInitOpts=t.AstroOpts=t.SphericalOpts=t.Point=t.ColumnType=t.MetadataInit=t.MetadataColumn=t.MetadataManager=t.ObservationTrackViewerAdapter=t.ObservationTrackTimeline=t.footprintToRing=t.createObservationTrackTimeline=t.SensorConeGL=t.SatelliteObjectGL=t.TerraPolylineSetGL=t.TerraFootprintSetGL=t.TerraPointSetGL=t.CatalogueGL=t.FootprintSetGL=t.HoveredFootprintDetail=t.SphereFoV=t.FoV=t.HiPSDescriptor=t.AstroViewer=void 0;var s=i(772);Object.defineProperty(t,"AstroViewer",{enumerable:!0,get:function(){return s.AstroViewer}});var o=i(5087);Object.defineProperty(t,"HiPSDescriptor",{enumerable:!0,get:function(){return o.HiPSDescriptor}});var a=i(5803);Object.defineProperty(t,"FoV",{enumerable:!0,get:function(){return a.SphereFoV}});var n=i(5803);Object.defineProperty(t,"SphereFoV",{enumerable:!0,get:function(){return n.SphereFoV}});var l=i(592);Object.defineProperty(t,"HoveredFootprintDetail",{enumerable:!0,get:function(){return l.HoveredFootprintDetail}}),Object.defineProperty(t,"FootprintSetGL",{enumerable:!0,get:function(){return l.FootprintSetGL}});var h=i(1232);Object.defineProperty(t,"CatalogueGL",{enumerable:!0,get:function(){return h.CatalogueGL}});var c=i(5781);Object.defineProperty(t,"TerraPointSetGL",{enumerable:!0,get:function(){return c.TerraPointSetGL}});var u=i(9022);Object.defineProperty(t,"TerraFootprintSetGL",{enumerable:!0,get:function(){return u.TerraFootprintSetGL}});var d=i(3665);Object.defineProperty(t,"TerraPolylineSetGL",{enumerable:!0,get:function(){return d.TerraPolylineSetGL}});var g=i(3603);Object.defineProperty(t,"SatelliteObjectGL",{enumerable:!0,get:function(){return g.SatelliteObjectGL}});var _=i(3102);Object.defineProperty(t,"SensorConeGL",{enumerable:!0,get:function(){return _.SensorConeGL}});var p=i(5866);Object.defineProperty(t,"createObservationTrackTimeline",{enumerable:!0,get:function(){return p.createObservationTrackTimeline}}),Object.defineProperty(t,"footprintToRing",{enumerable:!0,get:function(){return p.footprintToRing}}),Object.defineProperty(t,"ObservationTrackTimeline",{enumerable:!0,get:function(){return p.ObservationTrackTimeline}}),Object.defineProperty(t,"ObservationTrackViewerAdapter",{enumerable:!0,get:function(){return p.ObservationTrackViewerAdapter}});var f=i(5403);Object.defineProperty(t,"MetadataManager",{enumerable:!0,get:function(){return f.MetadataManager}});var m=i(1072);Object.defineProperty(t,"MetadataColumn",{enumerable:!0,get:function(){return m.MetadataColumn}}),Object.defineProperty(t,"MetadataInit",{enumerable:!0,get:function(){return m.MetadataInit}}),Object.defineProperty(t,"ColumnType",{enumerable:!0,get:function(){return m.ColumnType}});var x=i(6553);Object.defineProperty(t,"Point",{enumerable:!0,get:function(){return x.Point}}),Object.defineProperty(t,"SphericalOpts",{enumerable:!0,get:function(){return x.SphericalOpts}}),Object.defineProperty(t,"AstroOpts",{enumerable:!0,get:function(){return x.AstroOpts}}),Object.defineProperty(t,"PointInitOpts",{enumerable:!0,get:function(){return x.PointInitOpts}}),Object.defineProperty(t,"CartesianOpts",{enumerable:!0,get:function(){return x.CartesianOpts}});var b=i(8083);Object.defineProperty(t,"FoVUtils",{enumerable:!0,get:function(){return b.FoVUtils}});var S=i(8145);Object.defineProperty(t,"CoordsType",{enumerable:!0,get:function(){return S.CoordsType}});var v=i(8755);Object.defineProperty(t,"GeoJSONParser",{enumerable:!0,get:function(){return r(v).default}});var M=i(619);Object.defineProperty(t,"ColorMaps",{enumerable:!0,get:function(){return M.ColorMaps}}),Object.defineProperty(t,"COLOR_MAP_SAMPLE_COUNT",{enumerable:!0,get:function(){return M.COLOR_MAP_SAMPLE_COUNT}}),Object.defineProperty(t,"createColorMapFromSamples",{enumerable:!0,get:function(){return M.createColorMapFromSamples}});var T=i(3726);Object.defineProperty(t,"HiPS",{enumerable:!0,get:function(){return T.HiPS}});var y=i(1741);Object.defineProperty(t,"XYZMap",{enumerable:!0,get:function(){return y.XYZMap}});var P=i(3956);Object.defineProperty(t,"WMTSAdapter",{enumerable:!0,get:function(){return P.WMTSAdapter}});var w=i(6878);Object.defineProperty(t,"MeshHiPS",{enumerable:!0,get:function(){return w.MeshHiPS}});var C=i(847);Object.defineProperty(t,"MeshHiPSDescriptor",{enumerable:!0,get:function(){return C.MeshHiPSDescriptor}});var E=i(146);Object.defineProperty(t,"Source",{enumerable:!0,get:function(){return E.Source}});var A=i(2475);Object.defineProperty(t,"Footprint",{enumerable:!0,get:function(){return A.Footprint}}),console.log("astroviewer UMD loaded")},4735(e,t,i){"use strict";t.AbstractSkyEntity=void 0;const r=i(3890),s=i(7786);t.AbstractSkyEntity=class{refreshMe=!1;fovX_deg=180;fovY_deg=180;xRad;yRad;prevFoV=this.fovX_deg;_name;center;radius;isGalacticHips;vertexTextureCoordBuffer=null;vertexPositionBuffer=null;vertexIndexBuffer=null;shaderProgram=null;T=r.mat4.create();R=r.mat4.create();modelMatrix=r.mat4.create();inverseModelMatrix=r.mat4.create();galacticMatrixInverted=r.mat4.create();_webgl;_hipsShaderProgram;constructor(e,t,i,o,a,n,l){this._webgl=n,this.xRad=i,this.yRad=o,this._name=a,this.center=r.vec3.clone(t),this.radius=e,this.isGalacticHips=!!l,r.mat4.set(this.galacticMatrixInverted,-.054875582456588745,-.8734370470046997,-.48383501172065735,0,.49410945177078247,-.4448296129703522,.7469822764396667,0,-.8676661849021912,-.19807636737823486,.4559837877750397,0,0,0,0,1),this._hipsShaderProgram=new s.HiPSShaderProgram(this._webgl)}get name(){return this._name}get hipsShaderProgram(){return this._hipsShaderProgram}get webgl(){return this._webgl}initGL(e){this.vertexTextureCoordBuffer=e.createBuffer(),this.vertexPositionBuffer=e.createBuffer(),this.vertexIndexBuffer=e.createBuffer(),this.shaderProgram=e.createProgram(),this.T=r.mat4.create(),this.R=r.mat4.create(),this.modelMatrix=r.mat4.create(),this.inverseModelMatrix=r.mat4.create(),this.translate(this.center),this.rotate(this.xRad,this.yRad)}translate(e){r.mat4.translate(this.T,this.T,e),this.refreshModelMatrix()}rotate(e,t){r.mat4.rotate(this.R,this.R,t,[0,0,1]),r.mat4.rotate(this.R,this.R,e,[1,0,0]),this.refreshModelMatrix()}rotateFromZero(e,t){r.mat4.identity(this.R),r.mat4.rotate(this.R,this.R,e,[1,0,0]),r.mat4.rotate(this.R,this.R,t,[0,0,1]),this.refreshModelMatrix()}refreshModelMatrix(){const e=r.mat4.create();r.mat4.invert(e,this.R),r.mat4.multiply(this.modelMatrix,this.T,e),this.isGalacticHips&&r.mat4.multiply(this.modelMatrix,this.modelMatrix,this.galacticMatrixInverted)}getModelMatrixInverse(){return r.mat4.identity(this.inverseModelMatrix),r.mat4.invert(this.inverseModelMatrix,this.modelMatrix),this.inverseModelMatrix}getModelMatrix(){return this.modelMatrix}setModelMatrix(e){this.modelMatrix=e}setGeometryNeedsToBeRefreshed(){this.refreshGeometryOnFoVChanged=!1}rotateX(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[1],o=e[5],a=e[9];return e[1]=e[1]*i-e[2]*r,e[5]=e[5]*i-e[6]*r,e[9]=e[9]*i-e[10]*r,e[2]=e[2]*i+s*r,e[6]=e[6]*i+o*r,e[10]=e[10]*i+a*r,e}rotateY(e,t){const i=Math.cos(t),r=Math.sin(t),s=e[0],o=e[4],a=e[8];return e[0]=i*e[0]+r*e[2],e[4]=i*e[4]+r*e[6],e[8]=i*e[8]+r*e[10],e[2]=i*e[2]-r*s,e[6]=i*e[6]-r*o,e[10]=i*e[10]-r*a,e}}},619(e,t){"use strict";function i(e,i){if(!Array.isArray(i))throw new Error(`Channel "${e}" must be an array.`);if(i.length!==t.COLOR_MAP_SAMPLE_COUNT)throw new Error(`Channel "${e}" must contain exactly ${t.COLOR_MAP_SAMPLE_COUNT} samples.`);for(let t=0;t<i.length;t+=1){const r=i[t];if(!Number.isFinite(r))throw new Error(`Channel "${e}" contains a non-finite value at index ${t}.`);if(r<0||r>255)throw new Error(`Channel "${e}" contains an out-of-range value at index ${t}. Expected 0..255.`)}}function r(e){const i=new Float32Array(4*t.COLOR_MAP_SAMPLE_COUNT);for(let r=0;r<t.COLOR_MAP_SAMPLE_COUNT;r+=1)i[4*r]=e[r];return i}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorMaps=t.COLOR_MAP_SAMPLE_COUNT=void 0,t.createColorMapFromSamples=function(e,t){const s=e.trim();if(!s)throw new Error("Color map name must not be empty.");return i("r",t.r),i("g",t.g),i("b",t.b),{name:s,r:r(t.r),g:r(t.g),b:r(t.b)}},t.COLOR_MAP_SAMPLE_COUNT=256,t.ColorMaps={grayscale:{name:"grayscale",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},native:{name:"native",r:new Float32Array([]),g:new Float32Array([]),b:new Float32Array([])},planck:{name:"planck",r:new Float32Array([0,0,0,0,.769231,0,0,0,1.53846,0,0,0,2.30769,0,0,0,3.07692,0,0,0,3.84615,0,0,0,4.61538,0,0,0,5.38462,0,0,0,6.15385,0,0,0,6.92308,0,0,0,7.69231,0,0,0,8.46154,0,0,0,9.23077,0,0,0,10,0,0,0,11.5385,0,0,0,13.0769,0,0,0,14.6154,0,0,0,16.1538,0,0,0,17.6923,0,0,0,19.2308,0,0,0,20.7692,0,0,0,22.3077,0,0,0,23.8462,0,0,0,25.3846,0,0,0,26.9231,0,0,0,28.4615,0,0,0,30,0,0,0,33.8462,0,0,0,37.6923,0,0,0,41.5385,0,0,0,45.3846,0,0,0,49.2308,0,0,0,53.0769,0,0,0,56.9231,0,0,0,60.7692,0,0,0,64.6154,0,0,0,68.4615,0,0,0,72.3077,0,0,0,76.1538,0,0,0,80,0,0,0,88.5385,0,0,0,97.0769,0,0,0,105.615,0,0,0,114.154,0,0,0,122.692,0,0,0,131.231,0,0,0,139.769,0,0,0,148.308,0,0,0,156.846,0,0,0,165.385,0,0,0,173.923,0,0,0,182.462,0,0,0,191,0,0,0,193.846,0,0,0,196.692,0,0,0,199.538,0,0,0,202.385,0,0,0,205.231,0,0,0,208.077,0,0,0,210.923,0,0,0,213.769,0,0,0,216.615,0,0,0,219.462,0,0,0,222.308,0,0,0,225.154,0,0,0,228,0,0,0,229.182,0,0,0,230.364,0,0,0,231.545,0,0,0,232.727,0,0,0,233.909,0,0,0,235.091,0,0,0,236.273,0,0,0,237.455,0,0,0,238.636,0,0,0,239.818,0,0,0,241,0,0,0,241,0,0,0,241.364,0,0,0,241.727,0,0,0,242.091,0,0,0,242.455,0,0,0,242.818,0,0,0,243.182,0,0,0,243.545,0,0,0,243.909,0,0,0,244.273,0,0,0,244.636,0,0,0,245,0,0,0,245.231,0,0,0,245.462,0,0,0,245.692,0,0,0,245.923,0,0,0,246.154,0,0,0,246.385,0,0,0,246.615,0,0,0,246.846,0,0,0,247.077,0,0,0,247.308,0,0,0,247.538,0,0,0,247.769,0,0,0,248,0,0,0,248.146,0,0,0,248.292,0,0,0,248.438,0,0,0,248.585,0,0,0,248.731,0,0,0,248.877,0,0,0,249.023,0,0,0,249.169,0,0,0,249.315,0,0,0,249.462,0,0,0,249.608,0,0,0,249.754,0,0,0,249.9,0,0,0,249.312,0,0,0,248.723,0,0,0,248.135,0,0,0,247.546,0,0,0,246.958,0,0,0,246.369,0,0,0,245.781,0,0,0,245.192,0,0,0,244.604,0,0,0,244.015,0,0,0,243.427,0,0,0,242.838,0,0,0,242.25,0,0,0,239.308,0,0,0,236.365,0,0,0,233.423,0,0,0,230.481,0,0,0,227.538,0,0,0,224.596,0,0,0,221.654,0,0,0,218.712,0,0,0,215.769,0,0,0,212.827,0,0,0,209.885,0,0,0,206.942,0,0,0,204,0,0,0,201,0,0,0,198,0,0,0,195,0,0,0,192,0,0,0,189,0,0,0,186,0,0,0,183,0,0,0,180,0,0,0,177,0,0,0,174,0,0,0,171,0,0,0,168,0,0,0,165,0,0,0,161.077,0,0,0,157.154,0,0,0,153.231,0,0,0,149.308,0,0,0,145.385,0,0,0,141.462,0,0,0,137.538,0,0,0,133.615,0,0,0,129.692,0,0,0,125.769,0,0,0,121.846,0,0,0,117.923,0,0,0,114,0,0,0,115.038,0,0,0,116.077,0,0,0,117.115,0,0,0,118.154,0,0,0,119.192,0,0,0,120.231,0,0,0,121.269,0,0,0,122.308,0,0,0,123.346,0,0,0,124.385,0,0,0,125.423,0,0,0,126.462,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),g:new Float32Array([0,0,0,0,1.53846,0,0,0,3.07692,0,0,0,4.61538,0,0,0,6.15385,0,0,0,7.69231,0,0,0,9.23077,0,0,0,10.7692,0,0,0,12.3077,0,0,0,13.8462,0,0,0,15.3846,0,0,0,16.9231,0,0,0,18.4615,0,0,0,20,0,0,0,32.6154,0,0,0,45.2308,0,0,0,57.8462,0,0,0,70.4615,0,0,0,83.0769,0,0,0,95.6923,0,0,0,108.308,0,0,0,120.923,0,0,0,133.538,0,0,0,146.154,0,0,0,158.769,0,0,0,171.385,0,0,0,184,0,0,0,187.923,0,0,0,191.846,0,0,0,195.769,0,0,0,199.692,0,0,0,203.615,0,0,0,207.538,0,0,0,211.462,0,0,0,215.385,0,0,0,219.308,0,0,0,223.231,0,0,0,227.154,0,0,0,231.077,0,0,0,235,0,0,0,235.308,0,0,0,235.615,0,0,0,235.923,0,0,0,236.231,0,0,0,236.538,0,0,0,236.846,0,0,0,237.154,0,0,0,237.462,0,0,0,237.769,0,0,0,238.077,0,0,0,238.385,0,0,0,238.692,0,0,0,239,0,0,0,239.077,0,0,0,239.154,0,0,0,239.231,0,0,0,239.308,0,0,0,239.385,0,0,0,239.462,0,0,0,239.538,0,0,0,239.615,0,0,0,239.692,0,0,0,239.769,0,0,0,239.846,0,0,0,239.923,0,0,0,240,0,0,0,240.091,0,0,0,240.182,0,0,0,240.273,0,0,0,240.364,0,0,0,240.455,0,0,0,240.545,0,0,0,240.636,0,0,0,240.727,0,0,0,240.818,0,0,0,240.909,0,0,0,241,0,0,0,241,0,0,0,240.909,0,0,0,240.818,0,0,0,240.727,0,0,0,240.636,0,0,0,240.545,0,0,0,240.455,0,0,0,240.364,0,0,0,240.273,0,0,0,240.182,0,0,0,240.091,0,0,0,240,0,0,0,239.615,0,0,0,239.231,0,0,0,238.846,0,0,0,238.462,0,0,0,238.077,0,0,0,237.692,0,0,0,237.308,0,0,0,236.923,0,0,0,236.538,0,0,0,236.154,0,0,0,235.769,0,0,0,235.385,0,0,0,235,0,0,0,232.615,0,0,0,230.231,0,0,0,227.846,0,0,0,225.462,0,0,0,223.077,0,0,0,220.692,0,0,0,218.308,0,0,0,215.923,0,0,0,213.538,0,0,0,211.154,0,0,0,208.769,0,0,0,206.385,0,0,0,204,0,0,0,200.077,0,0,0,196.154,0,0,0,192.231,0,0,0,188.308,0,0,0,184.385,0,0,0,180.462,0,0,0,176.538,0,0,0,172.615,0,0,0,168.692,0,0,0,164.769,0,0,0,160.846,0,0,0,156.923,0,0,0,153,0,0,0,147.115,0,0,0,141.231,0,0,0,135.346,0,0,0,129.462,0,0,0,123.577,0,0,0,117.692,0,0,0,111.808,0,0,0,105.923,0,0,0,100.038,0,0,0,94.1538,0,0,0,88.2692,0,0,0,82.3846,0,0,0,76.5,0,0,0,73.0769,0,0,0,69.6538,0,0,0,66.2308,0,0,0,62.8077,0,0,0,59.3846,0,0,0,55.9615,0,0,0,52.5385,0,0,0,49.1154,0,0,0,45.6923,0,0,0,42.2692,0,0,0,38.8462,0,0,0,35.4231,0,0,0,32,0,0,0,29.5385,0,0,0,27.0769,0,0,0,24.6154,0,0,0,22.1538,0,0,0,19.6923,0,0,0,17.2308,0,0,0,14.7692,0,0,0,12.3077,0,0,0,9.84615,0,0,0,7.38462,0,0,0,4.92308,0,0,0,2.46154,0,0,0,0,0,0,0,9.80769,0,0,0,19.6154,0,0,0,29.4231,0,0,0,39.2308,0,0,0,49.0385,0,0,0,58.8462,0,0,0,68.6538,0,0,0,78.4615,0,0,0,88.2692,0,0,0,98.0769,0,0,0,107.885,0,0,0,117.692,0,0,0,127.5,0,0,0,131.423,0,0,0,135.346,0,0,0,139.269,0,0,0,143.192,0,0,0,147.115,0,0,0,151.038,0,0,0,154.962,0,0,0,158.885,0,0,0,162.808,0,0,0,166.731,0,0,0,170.654,0,0,0,174.577,0,0,0,178.5,0,0,0,180.462,0,0,0,182.423,0,0,0,184.385,0,0,0,186.346,0,0,0,188.308,0,0,0,190.269,0,0,0,192.231,0,0,0,194.192,0,0,0,196.154,0,0,0,198.115,0,0,0,200.077,0,0,0,202.038,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.642,0,0,0,243.035,0,0,0,243.427,0,0,0,243.819,0,0,0,244.212,0,0,0,244.604,0,0,0,244.996,0,0,0,245.388,0,0,0,245.781,0,0,0,246.173,0,0,0,246.565,0,0,0,246.958,0,0,0,247.35,0,0,0,247.814,0,0,0,248.277,0,0,0,248.741,0,0,0,249.205,0,0,0,249.668,0,0,0,250.132,0,0,0,250.595,0,0,0,251.059,0,0,0,251.523,0,0,0,251.986,0,0,0,252.45,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254.615,0,0,0,254.231,0,0,0,253.846,0,0,0,253.462,0,0,0,253.077,0,0,0,252.692,0,0,0,252.308,0,0,0,251.923,0,0,0,251.538,0,0,0,251.154,0,0,0,250.769,0,0,0,250.385,0,0,0,250,0,0,0,249.615,0,0,0,249.231,0,0,0,248.846,0,0,0,248.462,0,0,0,248.077,0,0,0,247.692,0,0,0,247.308,0,0,0,246.923,0,0,0,246.538,0,0,0,246.154,0,0,0,245.769,0,0,0,245.385,0,0,0,245,0,0,0,242,0,0,0,239,0,0,0,236,0,0,0,233,0,0,0,230,0,0,0,227,0,0,0,224,0,0,0,221,0,0,0,218,0,0,0,215,0,0,0,212,0,0,0,212,0,0,0,208.636,0,0,0,205.273,0,0,0,201.909,0,0,0,198.545,0,0,0,195.182,0,0,0,191.818,0,0,0,188.455,0,0,0,185.091,0,0,0,181.727,0,0,0,178.364,0,0,0,175,0,0,0,171.538,0,0,0,168.077,0,0,0,164.615,0,0,0,161.154,0,0,0,157.692,0,0,0,154.231,0,0,0,150.769,0,0,0,147.308,0,0,0,143.846,0,0,0,140.385,0,0,0,136.923,0,0,0,133.462,0,0,0,130,0,0,0,122.942,0,0,0,115.885,0,0,0,108.827,0,0,0,101.769,0,0,0,94.7115,0,0,0,87.6539,0,0,0,80.5962,0,0,0,73.5385,0,0,0,66.4808,0,0,0,59.4231,0,0,0,52.3654,0,0,0,45.3077,0,0,0,38.25,0,0,0,36.2885,0,0,0,34.3269,0,0,0,32.3654,0,0,0,30.4038,0,0,0,28.4423,0,0,0,26.4808,0,0,0,24.5192,0,0,0,22.5577,0,0,0,20.5962,0,0,0,18.6346,0,0,0,16.6731,0,0,0,14.7115,0,0,0,12.75,0,0,0,11.7692,0,0,0,10.7885,0,0,0,9.80769,0,0,0,8.82692,0,0,0,7.84615,0,0,0,6.86539,0,0,0,5.88461,0,0,0,4.90385,0,0,0,3.92308,0,0,0,2.94231,0,0,0,1.96154,0,0,0,.980769,0,0,0,0,0,0,0,2.46154,0,0,0,4.92308,0,0,0,7.38462,0,0,0,9.84616,0,0,0,12.3077,0,0,0,14.7692,0,0,0,17.2308,0,0,0,19.6923,0,0,0,22.1538,0,0,0,24.6154,0,0,0,27.0769,0,0,0,29.5385,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,32,0,0,0,41.3077,0,0,0,50.6154,0,0,0,59.9231,0,0,0,69.2308,0,0,0,78.5385,0,0,0,87.8462,0,0,0,97.1539,0,0,0,106.462,0,0,0,115.769,0,0,0,125.077,0,0,0,134.385,0,0,0,143.692,0,0,0,153,0,0,0,156.923,0,0,0,160.846,0,0,0,164.769,0,0,0,168.692,0,0,0,172.615,0,0,0,176.538,0,0,0,180.462,0,0,0,184.385,0,0,0,188.308,0,0,0,192.231,0,0,0,196.154,0,0,0,200.077,0,0,0,204,0,0,0,205.962,0,0,0,207.923,0,0,0,209.885,0,0,0,211.846,0,0,0,213.808,0,0,0,215.769,0,0,0,217.731,0,0,0,219.692,0,0,0,221.654,0,0,0,223.615,0,0,0,225.577,0,0,0,227.538,0,0,0,229.5,0,0,0,230.481,0,0,0,231.462,0,0,0,232.442,0,0,0,233.423,0,0,0,234.404,0,0,0,235.385,0,0,0,236.365,0,0,0,237.346,0,0,0,238.327,0,0,0,239.308,0,0,0,240.288,0,0,0,241.269,0,0,0,242.25,0,0,0,242.838,0,0,0,243.427,0,0,0,244.015,0,0,0,244.604,0,0,0,245.192,0,0,0,245.781,0,0,0,246.369,0,0,0,246.958,0,0,0,247.546,0,0,0,248.135,0,0,0,248.723,0,0,0,249.312,0,0,0,249.9,0,0,0,250.096,0,0,0,250.292,0,0,0,250.488,0,0,0,250.685,0,0,0,250.881,0,0,0,251.077,0,0,0,251.273,0,0,0,251.469,0,0,0,251.665,0,0,0,251.862,0,0,0,252.058,0,0,0,252.254,0,0,0,252.45,0,0,0,252.682,0,0,0,252.914,0,0,0,253.145,0,0,0,253.377,0,0,0,253.609,0,0,0,253.841,0,0,0,254.073,0,0,0,254.305,0,0,0,254.536,0,0,0,254.768,0,0,0,255,0,0,0])},cmb:{name:"cmb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,12,0,0,0,18,0,0,0,24,0,0,0,30,0,0,0,36,0,0,0,42,0,0,0,48,0,0,0,54,0,0,0,60,0,0,0,66,0,0,0,72,0,0,0,78,0,0,0,85,0,0,0,91,0,0,0,97,0,0,0,103,0,0,0,109,0,0,0,115,0,0,0,121,0,0,0,127,0,0,0,133,0,0,0,139,0,0,0,145,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,170,0,0,0,176,0,0,0,182,0,0,0,188,0,0,0,194,0,0,0,200,0,0,0,206,0,0,0,212,0,0,0,218,0,0,0,224,0,0,0,230,0,0,0,236,0,0,0,242,0,0,0,248,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,251,0,0,0,247,0,0,0,244,0,0,0,240,0,0,0,236,0,0,0,233,0,0,0,229,0,0,0,226,0,0,0,222,0,0,0,218,0,0,0,215,0,0,0,211,0,0,0,208,0,0,0,204,0,0,0,200,0,0,0,197,0,0,0,193,0,0,0,190,0,0,0,186,0,0,0,182,0,0,0,179,0,0,0,175,0,0,0,172,0,0,0,168,0,0,0,164,0,0,0,161,0,0,0,157,0,0,0,154,0,0,0,150,0,0,0,146,0,0,0,143,0,0,0,139,0,0,0,136,0,0,0,132,0,0,0,128,0,0,0,125,0,0,0,121,0,0,0,118,0,0,0,114,0,0,0,110,0,0,0,107,0,0,0,103,0,0,0,100,0,0,0]),g:new Float32Array([0,0,0,0,2,0,0,0,5,0,0,0,8,0,0,0,10,0,0,0,13,0,0,0,16,0,0,0,18,0,0,0,21,0,0,0,24,0,0,0,26,0,0,0,29,0,0,0,32,0,0,0,34,0,0,0,37,0,0,0,40,0,0,0,42,0,0,0,45,0,0,0,48,0,0,0,50,0,0,0,53,0,0,0,56,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,66,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,80,0,0,0,82,0,0,0,85,0,0,0,88,0,0,0,90,0,0,0,93,0,0,0,96,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,106,0,0,0,109,0,0,0,112,0,0,0,114,0,0,0,117,0,0,0,119,0,0,0,122,0,0,0,124,0,0,0,127,0,0,0,129,0,0,0,132,0,0,0,134,0,0,0,137,0,0,0,139,0,0,0,142,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,152,0,0,0,155,0,0,0,157,0,0,0,160,0,0,0,162,0,0,0,165,0,0,0,167,0,0,0,170,0,0,0,172,0,0,0,175,0,0,0,177,0,0,0,180,0,0,0,182,0,0,0,185,0,0,0,188,0,0,0,190,0,0,0,193,0,0,0,195,0,0,0,198,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,208,0,0,0,210,0,0,0,213,0,0,0,215,0,0,0,218,0,0,0,221,0,0,0,221,0,0,0,221,0,0,0,222,0,0,0,222,0,0,0,222,0,0,0,223,0,0,0,223,0,0,0,224,0,0,0,224,0,0,0,224,0,0,0,225,0,0,0,225,0,0,0,225,0,0,0,226,0,0,0,226,0,0,0,227,0,0,0,227,0,0,0,227,0,0,0,228,0,0,0,228,0,0,0,229,0,0,0,229,0,0,0,229,0,0,0,230,0,0,0,230,0,0,0,230,0,0,0,231,0,0,0,231,0,0,0,232,0,0,0,232,0,0,0,232,0,0,0,233,0,0,0,233,0,0,0,233,0,0,0,234,0,0,0,234,0,0,0,235,0,0,0,235,0,0,0,235,0,0,0,236,0,0,0,236,0,0,0,237,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,227,0,0,0,226,0,0,0,225,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,215,0,0,0,214,0,0,0,213,0,0,0,211,0,0,0,210,0,0,0,209,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,195,0,0,0,194,0,0,0,193,0,0,0,191,0,0,0,190,0,0,0,189,0,0,0,187,0,0,0,186,0,0,0,185,0,0,0,183,0,0,0,182,0,0,0,181,0,0,0,180,0,0,0,177,0,0,0,175,0,0,0,172,0,0,0,170,0,0,0,167,0,0,0,165,0,0,0,162,0,0,0,160,0,0,0,157,0,0,0,155,0,0,0,152,0,0,0,150,0,0,0,147,0,0,0,145,0,0,0,142,0,0,0,140,0,0,0,137,0,0,0,135,0,0,0,132,0,0,0,130,0,0,0,127,0,0,0,125,0,0,0,122,0,0,0,120,0,0,0,117,0,0,0,115,0,0,0,112,0,0,0,110,0,0,0,107,0,0,0,105,0,0,0,102,0,0,0,100,0,0,0,97,0,0,0,95,0,0,0,92,0,0,0,90,0,0,0,87,0,0,0,85,0,0,0,82,0,0,0,80,0,0,0,77,0,0,0,75,0,0,0,73,0,0,0,71,0,0,0,69,0,0,0,68,0,0,0,66,0,0,0,64,0,0,0,62,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,54,0,0,0,52,0,0,0,50,0,0,0,48,0,0,0,47,0,0,0,45,0,0,0,43,0,0,0,41,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,34,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,26,0,0,0,24,0,0,0,22,0,0,0,20,0,0,0,19,0,0,0,17,0,0,0,15,0,0,0,13,0,0,0,12,0,0,0,10,0,0,0,8,0,0,0,6,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0]),b:new Float32Array([255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,254,0,0,0,253,0,0,0,252,0,0,0,251,0,0,0,250,0,0,0,249,0,0,0,248,0,0,0,247,0,0,0,246,0,0,0,245,0,0,0,245,0,0,0,244,0,0,0,243,0,0,0,242,0,0,0,241,0,0,0,240,0,0,0,239,0,0,0,238,0,0,0,237,0,0,0,236,0,0,0,236,0,0,0,235,0,0,0,234,0,0,0,233,0,0,0,232,0,0,0,231,0,0,0,230,0,0,0,229,0,0,0,228,0,0,0,227,0,0,0,226,0,0,0,226,0,0,0,225,0,0,0,224,0,0,0,223,0,0,0,222,0,0,0,221,0,0,0,220,0,0,0,219,0,0,0,218,0,0,0,217,0,0,0,217,0,0,0,211,0,0,0,206,0,0,0,201,0,0,0,196,0,0,0,191,0,0,0,186,0,0,0,181,0,0,0,176,0,0,0,171,0,0,0,166,0,0,0,161,0,0,0,156,0,0,0,151,0,0,0,146,0,0,0,141,0,0,0,136,0,0,0,131,0,0,0,126,0,0,0,121,0,0,0,116,0,0,0,111,0,0,0,105,0,0,0,100,0,0,0,95,0,0,0,90,0,0,0,85,0,0,0,80,0,0,0,75,0,0,0,70,0,0,0,65,0,0,0,60,0,0,0,55,0,0,0,50,0,0,0,45,0,0,0,40,0,0,0,35,0,0,0,30,0,0,0,25,0,0,0,20,0,0,0,15,0,0,0,10,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},rainbow:{name:"rainbow",r:new Float32Array([0,0,0,0,4,0,0,0,9,0,0,0,13,0,0,0,18,0,0,0,22,0,0,0,27,0,0,0,31,0,0,0,36,0,0,0,40,0,0,0,45,0,0,0,50,0,0,0,54,0,0,0,58,0,0,0,61,0,0,0,64,0,0,0,68,0,0,0,69,0,0,0,72,0,0,0,74,0,0,0,77,0,0,0,79,0,0,0,80,0,0,0,82,0,0,0,83,0,0,0,85,0,0,0,84,0,0,0,86,0,0,0,87,0,0,0,88,0,0,0,86,0,0,0,87,0,0,0,87,0,0,0,87,0,0,0,85,0,0,0,84,0,0,0,84,0,0,0,84,0,0,0,83,0,0,0,79,0,0,0,78,0,0,0,77,0,0,0,76,0,0,0,71,0,0,0,70,0,0,0,68,0,0,0,66,0,0,0,60,0,0,0,58,0,0,0,55,0,0,0,53,0,0,0,46,0,0,0,43,0,0,0,40,0,0,0,36,0,0,0,33,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,12,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,33,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,80,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,101,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,123,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,153,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,169,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,212,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,21,0,0,0,25,0,0,0,29,0,0,0,38,0,0,0,42,0,0,0,46,0,0,0,51,0,0,0,55,0,0,0,63,0,0,0,67,0,0,0,72,0,0,0,76,0,0,0,84,0,0,0,89,0,0,0,93,0,0,0,97,0,0,0,106,0,0,0,110,0,0,0,114,0,0,0,119,0,0,0,127,0,0,0,131,0,0,0,135,0,0,0,140,0,0,0,144,0,0,0,152,0,0,0,157,0,0,0,161,0,0,0,165,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,195,0,0,0,199,0,0,0,203,0,0,0,208,0,0,0,216,0,0,0,220,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,242,0,0,0,246,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,250,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,221,0,0,0,216,0,0,0,212,0,0,0,208,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,161,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,119,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,85,0,0,0,80,0,0,0,76,0,0,0,72,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,51,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,29,0,0,0,21,0,0,0,17,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0]),b:new Float32Array([0,0,0,0,3,0,0,0,7,0,0,0,10,0,0,0,14,0,0,0,19,0,0,0,23,0,0,0,28,0,0,0,32,0,0,0,38,0,0,0,43,0,0,0,48,0,0,0,53,0,0,0,59,0,0,0,63,0,0,0,68,0,0,0,72,0,0,0,77,0,0,0,81,0,0,0,86,0,0,0,91,0,0,0,95,0,0,0,100,0,0,0,104,0,0,0,109,0,0,0,113,0,0,0,118,0,0,0,122,0,0,0,127,0,0,0,132,0,0,0,136,0,0,0,141,0,0,0,145,0,0,0,150,0,0,0,154,0,0,0,159,0,0,0,163,0,0,0,168,0,0,0,173,0,0,0,177,0,0,0,182,0,0,0,186,0,0,0,191,0,0,0,195,0,0,0,200,0,0,0,204,0,0,0,209,0,0,0,214,0,0,0,218,0,0,0,223,0,0,0,227,0,0,0,232,0,0,0,236,0,0,0,241,0,0,0,245,0,0,0,250,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,225,0,0,0,220,0,0,0,216,0,0,0,212,0,0,0,203,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,178,0,0,0,174,0,0,0,170,0,0,0,165,0,0,0,157,0,0,0,152,0,0,0,148,0,0,0,144,0,0,0,135,0,0,0,131,0,0,0,127,0,0,0,123,0,0,0,114,0,0,0,110,0,0,0,106,0,0,0,102,0,0,0,97,0,0,0,89,0,0,0,84,0,0,0,80,0,0,0,76,0,0,0,67,0,0,0,63,0,0,0,59,0,0,0,55,0,0,0,46,0,0,0,42,0,0,0,38,0,0,0,34,0,0,0,25,0,0,0,21,0,0,0,16,0,0,0,12,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},eosb:{name:"eosb",r:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,18,0,0,0,27,0,0,0,36,0,0,0,45,0,0,0,49,0,0,0,57,0,0,0,72,0,0,0,81,0,0,0,91,0,0,0,100,0,0,0,109,0,0,0,118,0,0,0,127,0,0,0,136,0,0,0,131,0,0,0,139,0,0,0,163,0,0,0,173,0,0,0,182,0,0,0,191,0,0,0,200,0,0,0,209,0,0,0,218,0,0,0,227,0,0,0,213,0,0,0,221,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,253,0,0,0,251,0,0,0,249,0,0,0,247,0,0,0,245,0,0,0,243,0,0,0,241,0,0,0,215,0,0,0,214,0,0,0,235,0,0,0,234,0,0,0,232,0,0,0,230,0,0,0,228,0,0,0,226,0,0,0,224,0,0,0,222,0,0,0,198,0,0,0,196,0,0,0,216,0,0,0,215,0,0,0,213,0,0,0,211,0,0,0,209,0,0,0,207,0,0,0,205,0,0,0,203,0,0,0,181,0,0,0,179,0,0,0,197,0,0,0,196,0,0,0,194,0,0,0,192,0,0,0,190,0,0,0,188,0,0,0,186,0,0,0,184,0,0,0,164,0,0,0,162,0,0,0,178,0,0,0,176,0,0,0,175,0,0,0,173,0,0,0,171,0,0,0,169,0,0,0,167,0,0,0,165,0,0,0,147,0,0,0,145,0,0,0,159,0,0,0,157,0,0,0,156,0,0,0,154,0,0,0,152,0,0,0,150,0,0,0,148,0,0,0,146,0,0,0,130,0,0,0,128,0,0,0,140,0,0,0,138,0,0,0,137,0,0,0,135,0,0,0,133,0,0,0,131,0,0,0,129,0,0,0,127,0,0,0,113,0,0,0,111,0,0,0,121,0,0,0,119,0,0,0,117,0,0,0,117,0,0,0]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,15,0,0,0,23,0,0,0,31,0,0,0,39,0,0,0,47,0,0,0,55,0,0,0,57,0,0,0,64,0,0,0,79,0,0,0,87,0,0,0,95,0,0,0,103,0,0,0,111,0,0,0,119,0,0,0,127,0,0,0,135,0,0,0,129,0,0,0,136,0,0,0,159,0,0,0,167,0,0,0,175,0,0,0,183,0,0,0,191,0,0,0,199,0,0,0,207,0,0,0,215,0,0,0,200,0,0,0,207,0,0,0,239,0,0,0,247,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,229,0,0,0,229,0,0,0,255,0,0,0,250,0,0,0,246,0,0,0,242,0,0,0,238,0,0,0,233,0,0,0,229,0,0,0,225,0,0,0,198,0,0,0,195,0,0,0,212,0,0,0,208,0,0,0,204,0,0,0,199,0,0,0,195,0,0,0,191,0,0,0,187,0,0,0,182,0,0,0,160,0,0,0,156,0,0,0,169,0,0,0,165,0,0,0,161,0,0,0,157,0,0,0,153,0,0,0,148,0,0,0,144,0,0,0,140,0,0,0,122,0,0,0,118,0,0,0,127,0,0,0,125,0,0,0,123,0,0,0,121,0,0,0,119,0,0,0,116,0,0,0,114,0,0,0,112,0,0,0,99,0,0,0,97,0,0,0,106,0,0,0,104,0,0,0,102,0,0,0,99,0,0,0,97,0,0,0,95,0,0,0,93,0,0,0,91,0,0,0,80,0,0,0,78,0,0,0,84,0,0,0,82,0,0,0,80,0,0,0,78,0,0,0,76,0,0,0,74,0,0,0,72,0,0,0,70,0,0,0,61,0,0,0,59,0,0,0,63,0,0,0,61,0,0,0,59,0,0,0,57,0,0,0,55,0,0,0,53,0,0,0,50,0,0,0,48,0,0,0,42,0,0,0,40,0,0,0,42,0,0,0,40,0,0,0,38,0,0,0,36,0,0,0,33,0,0,0,31,0,0,0,29,0,0,0,27,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,19,0,0,0,16,0,0,0,14,0,0,0,12,0,0,0,13,0,0,0,8,0,0,0,6,0,0,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),b:new Float32Array([116,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,136,0,0,0,140,0,0,0,144,0,0,0,148,0,0,0,153,0,0,0,157,0,0,0,145,0,0,0,149,0,0,0,170,0,0,0,174,0,0,0,178,0,0,0,182,0,0,0,187,0,0,0,191,0,0,0,195,0,0,0,199,0,0,0,183,0,0,0,187,0,0,0,212,0,0,0,216,0,0,0,221,0,0,0,225,0,0,0,229,0,0,0,233,0,0,0,238,0,0,0,242,0,0,0,221,0,0,0,225,0,0,0,255,0,0,0,247,0,0,0,239,0,0,0,231,0,0,0,223,0,0,0,215,0,0,0,207,0,0,0,199,0,0,0,172,0,0,0,164,0,0,0,175,0,0,0,167,0,0,0,159,0,0,0,151,0,0,0,143,0,0,0,135,0,0,0,127,0,0,0,119,0,0,0,100,0,0,0,93,0,0,0,95,0,0,0,87,0,0,0,79,0,0,0,71,0,0,0,63,0,0,0,55,0,0,0,47,0,0,0,39,0,0,0,28,0,0,0,21,0,0,0,15,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},cubehelix:{name:"cubehelix",r:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,24,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,26,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,25,0,0,0,24,0,0,0,24,0,0,0,24,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,23,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,20,0,0,0,20,0,0,0,20,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,21,0,0,0,22,0,0,0,22,0,0,0,22,0,0,0,23,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,27,0,0,0,28,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,35,0,0,0,36,0,0,0,38,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,49,0,0,0,51,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,60,0,0,0,62,0,0,0,65,0,0,0,67,0,0,0,70,0,0,0,72,0,0,0,75,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,89,0,0,0,92,0,0,0,95,0,0,0,98,0,0,0,101,0,0,0,104,0,0,0,107,0,0,0,110,0,0,0,113,0,0,0,116,0,0,0,120,0,0,0,123,0,0,0,126,0,0,0,129,0,0,0,132,0,0,0,135,0,0,0,138,0,0,0,141,0,0,0,144,0,0,0,147,0,0,0,150,0,0,0,153,0,0,0,155,0,0,0,158,0,0,0,161,0,0,0,164,0,0,0,166,0,0,0,169,0,0,0,171,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,181,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,199,0,0,0,201,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,207,0,0,0,208,0,0,0,209,0,0,0,209,0,0,0,210,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,212,0,0,0,211,0,0,0,211,0,0,0,211,0,0,0,210,0,0,0,210,0,0,0,210,0,0,0,209,0,0,0,208,0,0,0,208,0,0,0,207,0,0,0,207,0,0,0,206,0,0,0,205,0,0,0,205,0,0,0,204,0,0,0,203,0,0,0,203,0,0,0,202,0,0,0,201,0,0,0,201,0,0,0,200,0,0,0,199,0,0,0,199,0,0,0,198,0,0,0,197,0,0,0,197,0,0,0,196,0,0,0,196,0,0,0,195,0,0,0,195,0,0,0,194,0,0,0,194,0,0,0,194,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,193,0,0,0,194,0,0,0,194,0,0,0,195,0,0,0,195,0,0,0,196,0,0,0,196,0,0,0,197,0,0,0,198,0,0,0,199,0,0,0,200,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,204,0,0,0,205,0,0,0,206,0,0,0,208,0,0,0,209,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,217,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,223,0,0,0,225,0,0,0,227,0,0,0,229,0,0,0,231,0,0,0,232,0,0,0,234,0,0,0,236,0,0,0,238,0,0,0,240,0,0,0,242,0,0,0,244,0,0,0,245,0,0,0,247,0,0,0,249,0,0,0,251,0,0,0,253,0,0,0,255]),g:new Float32Array([0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,28,0,0,0,29,0,0,0,31,0,0,0,32,0,0,0,34,0,0,0,35,0,0,0,37,0,0,0,38,0,0,0,40,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,46,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,57,0,0,0,58,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,73,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,79,0,0,0,81,0,0,0,83,0,0,0,84,0,0,0,86,0,0,0,88,0,0,0,89,0,0,0,91,0,0,0,92,0,0,0,94,0,0,0,95,0,0,0,97,0,0,0,98,0,0,0,99,0,0,0,101,0,0,0,102,0,0,0,103,0,0,0,104,0,0,0,106,0,0,0,107,0,0,0,108,0,0,0,109,0,0,0,110,0,0,0,111,0,0,0,112,0,0,0,113,0,0,0,114,0,0,0,114,0,0,0,115,0,0,0,116,0,0,0,116,0,0,0,117,0,0,0,118,0,0,0,118,0,0,0,119,0,0,0,119,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,120,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,121,0,0,0,122,0,0,0,122,0,0,0,122,0,0,0,123,0,0,0,123,0,0,0,124,0,0,0,124,0,0,0,125,0,0,0,125,0,0,0,126,0,0,0,127,0,0,0,127,0,0,0,128,0,0,0,129,0,0,0,130,0,0,0,131,0,0,0,131,0,0,0,132,0,0,0,133,0,0,0,135,0,0,0,136,0,0,0,137,0,0,0,138,0,0,0,139,0,0,0,140,0,0,0,142,0,0,0,143,0,0,0,144,0,0,0,146,0,0,0,147,0,0,0,149,0,0,0,150,0,0,0,152,0,0,0,154,0,0,0,155,0,0,0,157,0,0,0,158,0,0,0,160,0,0,0,162,0,0,0,164,0,0,0,165,0,0,0,167,0,0,0,169,0,0,0,171,0,0,0,172,0,0,0,174,0,0,0,176,0,0,0,178,0,0,0,180,0,0,0,182,0,0,0,183,0,0,0,185,0,0,0,187,0,0,0,189,0,0,0,191,0,0,0,193,0,0,0,194,0,0,0,196,0,0,0,198,0,0,0,200,0,0,0,202,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,208,0,0,0,210,0,0,0,212,0,0,0,213,0,0,0,215,0,0,0,216,0,0,0,218,0,0,0,219,0,0,0,221,0,0,0,222,0,0,0,224,0,0,0,225,0,0,0,226,0,0,0,228,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,232,0,0,0,233,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,247,0,0,0,248,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,250,0,0,0,251,0,0,0,251,0,0,0,252,0,0,0,252,0,0,0,253,0,0,0,253,0,0,0,254,0,0,0,255,0,0,0]),b:new Float32Array([0,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,9,0,0,0,11,0,0,0,13,0,0,0,15,0,0,0,17,0,0,0,19,0,0,0,21,0,0,0,23,0,0,0,25,0,0,0,27,0,0,0,29,0,0,0,31,0,0,0,33,0,0,0,35,0,0,0,37,0,0,0,39,0,0,0,41,0,0,0,43,0,0,0,45,0,0,0,47,0,0,0,48,0,0,0,50,0,0,0,52,0,0,0,54,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,63,0,0,0,65,0,0,0,66,0,0,0,67,0,0,0,69,0,0,0,70,0,0,0,71,0,0,0,72,0,0,0,73,0,0,0,74,0,0,0,74,0,0,0,75,0,0,0,76,0,0,0,76,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,78,0,0,0,77,0,0,0,77,0,0,0,77,0,0,0,76,0,0,0,76,0,0,0,75,0,0,0,75,0,0,0,74,0,0,0,73,0,0,0,73,0,0,0,72,0,0,0,71,0,0,0,70,0,0,0,69,0,0,0,68,0,0,0,67,0,0,0,66,0,0,0,66,0,0,0,65,0,0,0,64,0,0,0,63,0,0,0,61,0,0,0,60,0,0,0,59,0,0,0,58,0,0,0,58,0,0,0,57,0,0,0,56,0,0,0,55,0,0,0,54,0,0,0,53,0,0,0,52,0,0,0,51,0,0,0,51,0,0,0,50,0,0,0,49,0,0,0,49,0,0,0,48,0,0,0,48,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,46,0,0,0,47,0,0,0,47,0,0,0,47,0,0,0,48,0,0,0,48,0,0,0,49,0,0,0,50,0,0,0,50,0,0,0,51,0,0,0,52,0,0,0,53,0,0,0,55,0,0,0,56,0,0,0,57,0,0,0,59,0,0,0,60,0,0,0,62,0,0,0,64,0,0,0,65,0,0,0,67,0,0,0,69,0,0,0,71,0,0,0,74,0,0,0,76,0,0,0,78,0,0,0,81,0,0,0,83,0,0,0,86,0,0,0,88,0,0,0,91,0,0,0,94,0,0,0,96,0,0,0,99,0,0,0,102,0,0,0,105,0,0,0,108,0,0,0,111,0,0,0,114,0,0,0,117,0,0,0,120,0,0,0,124,0,0,0,127,0,0,0,130,0,0,0,133,0,0,0,136,0,0,0,140,0,0,0,143,0,0,0,146,0,0,0,149,0,0,0,153,0,0,0,156,0,0,0,159,0,0,0,162,0,0,0,165,0,0,0,169,0,0,0,172,0,0,0,175,0,0,0,178,0,0,0,181,0,0,0,184,0,0,0,186,0,0,0,189,0,0,0,192,0,0,0,195,0,0,0,197,0,0,0,200,0,0,0,203,0,0,0,205,0,0,0,207,0,0,0,210,0,0,0,212,0,0,0,214,0,0,0,216,0,0,0,218,0,0,0,220,0,0,0,222,0,0,0,224,0,0,0,226,0,0,0,227,0,0,0,229,0,0,0,230,0,0,0,231,0,0,0,233,0,0,0,234,0,0,0,235,0,0,0,236,0,0,0,237,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,241,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,243,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,242,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,241,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,238,0,0,0,239,0,0,0,239,0,0,0,239,0,0,0,240,0,0,0,240,0,0,0,240,0,0,0,241,0,0,0,242,0,0,0,242,0,0,0,243,0,0,0,244,0,0,0,245,0,0,0,246,0,0,0,247,0,0,0,248,0,0,0,249,0,0,0,250,0,0,0,252,0,0,0,253,0,0,0,255,0,0,0])},hot:{name:"hot",r:new Float32Array([0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]),g:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.30769,4.61538,6.92308,9.23077,11.5385,13.8462,16.1538,18.4615,20.7692,23.0769,25.3846,27.6923,30,32.3077,34.6154,36.9231,39.2308,41.5385,43.8462,46.1538,48.4615,50.7692,53.0769,55.3846,57.6923,60,62.3077,64.6154,66.9231,69.2308,71.5385,73.8462,76.1538,78.4615,80.7692,83.0769,85.3846,87.6923,90,92.3077,94.6154,96.9231,99.2308,101.538,103.846,106.154,108.462,110.769,113.077,115.385,117.692,120,122.308,124.615,126.923,129.231,131.538,133.846,136.154,138.462,140.769,143.077,145.385,147.692,150,152.308,154.615,156.923,159.231,161.538,163.846,166.154,168.462,170.769,173.077,175.385,177.692,180,182.308,184.615,186.923,189.231,191.538,193.846,196.154,198.462,200.769,203.077,205.385,207.692,210,212.308,214.615,216.923,219.231,221.538,223.846,226.154,228.462,230.769,233.077,235.385,237.692,240,242.308,244.615,246.923,249.231,251.538,253.846,255,255,255,255,255,255,255]),b:new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.980769,1.96154,2.94231,3.92308,4.90385,5.88461,6.86539,7.84615,8.82692,9.80769,10.7885,11.7692,12.75,13.7308,14.7115,15.6923,16.6731,17.6538,18.6346,19.6154,20.5962,21.5769,22.5577,23.5385,24.5192,25.5,26.4808,27.4615,28.4423,29.4231,30.4038,31.3846,32.3654,33.3462,34.3269,35.3077,36.2885,37.2692,38.25,39.2308,40.2115,41.1923,42.1731,43.1538,44.1346,45.1154,46.0962,47.0769,48.0577,49.0385,50.0192,51,51.9808,52.9615,53.9423,54.9231,55.9038,56.8846,57.8654,58.8462,59.8269,60.8077,61.7885,62.7692,63.75,64.7308,65.7115,66.6923,67.6731,68.6538,69.6346,70.6154,71.5962,72.5769,73.5577,74.5385,75.5192,76.5,77.4808,78.4615,79.4423,80.4231,81.4038,82.3846,83.3654,84.3462,85.3269,86.3077,87.2885,88.2692,89.25,90.2308,91.2115,92.1923,93.1731,94.1538,95.1346,96.1154,97.0962,98.0769,99.0577,100.038,101.019,102,102.981,103.962,104.942,105.923,106.904,107.885,108.865,109.846,110.827,111.808,112.788,113.769,114.75,115.731,116.711,117.692,118.673,119.654,120.634,121.615,122.596,123.577,124.557,125.538,126.519,127.5])},gray:{name:"gray",r:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),g:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]),b:new Float32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255])}},t.default=t.ColorMaps},1072(e,t){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataColumn=t.ColumnType=void 0,function(e){e.STRING="STRING",e.NUMBER="NUMBER",e.GEOM_RA="GEOM_RA",e.GEOM_DEC="GEOM_DEC",e.GEOM_FOOTPRINT="GEOM_FOOTPRINT",e.MAIN_NAME="MAIN_NAME"}(i||(t.ColumnType=i={}));t.MetadataColumn=class{_index;_name;_description="";_columnType;_unit;_details=new Map;constructor(e){if(!e.name)throw new Error("No name column defined.");if(this._name=e.name,e.index<0||isNaN(e.index))throw new Error("No index column defined.");this._index=e.index,this._columnType=e.columnType??i.STRING,this._unit=e.unit??"",this._description=e.description??"",e.details&&(this._details=new Map(e.details))}get details(){return new Map(this._details)}getDetail(e,t){return this._details.has(e)?this._details.get(e):t}getString(e,t=""){const i=this._details.get(e);return"string"==typeof i?i:t}getNumber(e,t=NaN){const i=this._details.get(e);return"number"==typeof i?i:t}setDetail(e,t){this._details.set(e,t)}setDetails(e){const t=e instanceof Map?e.entries():Object.entries(e);for(const[e,i]of t)this._details.set(e,i)}detailKeys(){return Array.from(this._details.keys())}detailValues(){return Array.from(this._details.values())}detailEntries(){return Array.from(this._details.entries())}get name(){return this._name}get description(){return this._description}get columnType(){return this._columnType}get index(){return this._index}get unit(){return this._unit}toJSON(){return{name:this._name,description:this._description,columnType:this._columnType,index:this._index,unit:this._unit,details:Object.fromEntries(this._details)}}}},5403(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataManager=void 0;const r=i(1072);t.MetadataManager=class{static STANDARD_SIZE="STANDARD_SIZE";static STANDARD_HUE="STANDARD_HUE";_outlineColumnList=[];_raColumnList=[];_decColumnList=[];_shapeColumnList=[];_hueColumnList=[];_selectedOutlineColumn;_selectedRaColumn;_selectedDecColumn;_selectedShapeColumn;_selectedHueColumn;_selectedNameColumn;_columns=[];constructor(e){e.forEach(e=>{e.columnType==r.ColumnType.NUMBER&&(this.addHueColumn(e),this.addShapeColumn(e)),e.columnType==r.ColumnType.GEOM_RA&&this.addRaColumn(e),e.columnType==r.ColumnType.GEOM_DEC&&this.addDecColumn(e),e.columnType==r.ColumnType.GEOM_FOOTPRINT&&this.addOutlineColumn(e),e.columnType==r.ColumnType.MAIN_NAME&&(this._selectedNameColumn=e),this._columns.push(e)})}addOutlineColumn(e){this._outlineColumnList.push(e),this._selectedOutlineColumn=e}addRaColumn(e){this._selectedRaColumn=this._selectedRaColumn||e,this._raColumnList.push(e)}addDecColumn(e){this._selectedDecColumn=this._selectedDecColumn||e,this._decColumnList.push(e)}addHueColumn(e){this._hueColumnList.push(e)}addShapeColumn(e){this._shapeColumnList.push(e)}get selectedRaColumn(){return this._selectedRaColumn}get selectedDecColumn(){return this._selectedDecColumn}get selectedHueColumn(){return this._selectedHueColumn}get selectedShapeColumn(){return this._selectedShapeColumn}get selectedOutlineColumn(){return this._selectedOutlineColumn}get selectedNameColumn(){return this._selectedNameColumn}get columns(){return this._columns}get raColumnList(){return this._raColumnList}get decColumnList(){return this._decColumnList}get outlineColumnList(){return this._outlineColumnList}get hueColumnList(){return this._hueColumnList}get shapeColumnList(){return this._shapeColumnList}set selectedRaColumn(e){this._selectedRaColumn=this._raColumnList.find(t=>t.name===e)||this._selectedRaColumn}set selectedDecColumn(e){this._selectedDecColumn=this._decColumnList.find(t=>t.name===e)||this._selectedDecColumn}set selectedOutlineColumn(e){this._selectedOutlineColumn=this._outlineColumnList.find(t=>t.name===e)||this._selectedOutlineColumn}set selectedHueColumn(e){this._selectedHueColumn=this._hueColumnList.find(t=>t.name===e)}set selectedShapeColumn(e){this._selectedShapeColumn=this._shapeColumnList.find(t=>t.name===e)}set selectedNameColumn(e){this._selectedNameColumn=this._columns.find(t=>t.name===e)}resetShapeColumn(){this._selectedShapeColumn=void 0}resetHueColumn(){this._selectedHueColumn=void 0}}},6553(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=i(3890),o=i(7930),a=i(8145),n=r(i(4382));class l{_x;_y;_z;_xyz;_raDeg;_decDeg;_raRad;_decRad;_raDecDeg;_lonLatDeg;constructor(e,t){this._xyz=[0,0,0],this._raDecDeg=[0,0];const i=n.default.MAX_DECIMALS??12;if(t===a.CoordsType.CARTESIAN){const{x:t,y:r,z:s}=e;this._x=Number(t.toFixed(i)),this._y=Number(r.toFixed(i)),this._z=Number(s.toFixed(i)),this._xyz=[this._x,this._y,this._z];const[o,a]=this.computeAstroCoords();this._raDeg=Number(o),this._decDeg=Number(a),this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180,this._raDecDeg=[this._raDeg,this._decDeg]}else if(t===a.CoordsType.ASTRO){const{raDeg:t,decDeg:r}=e;this._raDeg=Number(t),this._decDeg=Number(r),this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,o,a]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(o.toFixed(i)),this._z=Number(a.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else if(t===a.CoordsType.GEOGRAPHIC){const{lonDeg:t,latDeg:r}=e;this._lonLatDeg=[Number(t),Number(r)],this._raDeg=this._lonLatDeg[0],this._decDeg=this._lonLatDeg[1],this._raDecDeg=[this._raDeg,this._decDeg],this._raRad=this._raDeg*Math.PI/180,this._decRad=this._decDeg*Math.PI/180;const[s,o,a]=this.computeCartesianCoords();this._x=Number(s.toFixed(i)),this._y=Number(o.toFixed(i)),this._z=Number(a.toFixed(i)),this._xyz=[this._x,this._y,this._z]}else t===a.CoordsType.SPHERICAL?(console.log(`${a.CoordsType.SPHERICAL} not implemented yet`),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0):(console.error("CoordsType "+String(t)+" not recognised."),this._x=0,this._y=0,this._z=0,this._raDeg=0,this._decDeg=0,this._raRad=0,this._decRad=0)}computeAstroCoords(){const e=(0,o.cartesianToSpherical)(s.vec3.fromValues(this._xyz[0],this._xyz[1],this._xyz[2])),t=(0,o.sphericalToAstroDeg)(e.phi,e.theta);return[t.ra,t.dec]}computeCartesianCoords(){const e=(0,o.astroDegToSpherical)(this._raDeg,this._decDeg),[t,i,r]=(0,o.sphericalToCartesian)(e.phi,e.theta,1);return[t,i,r]}computeHealpixPhiTheta(){return(0,o.astroDegToSpherical)(this._raDeg,this._decDeg)}scale(e){return new l({x:this.x*e,y:this.y*e,z:this.z*e},a.CoordsType.CARTESIAN)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e){return new l({x:this.y*e.z-e.y*this.z,y:this.z*e.x-e.z*this.x,z:this.x*e.y-e.x*this.y},a.CoordsType.CARTESIAN)}norm(){const e=1/this.length();return new l({x:this.x*e,y:this.y*e,z:this.z*e},a.CoordsType.CARTESIAN)}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}subtract(e){return new l({x:this.x-e.x,y:this.y-e.y,z:this.z-e.z},a.CoordsType.CARTESIAN)}add(e){return new l({x:this.x+e.x,y:this.y+e.y,z:this.z+e.z},a.CoordsType.CARTESIAN)}get x(){return this._x}get y(){return this._y}get z(){return this._z}get xyz(){return this._xyz}get raDeg(){return this._raDeg}get decDeg(){return this._decDeg}get raDecDeg(){return this._raDecDeg}get lonDeg(){return this._lonLatDeg?.[0]??this._raDeg}get latDeg(){return this._lonLatDeg?.[1]??this._decDeg}get lonLatDeg(){return this._lonLatDeg??[this._raDeg,this._decDeg]}toADQL(){return`${this._raDecDeg[0]},${this._raDecDeg[1]}`}toString(){return`(raDeg, decDeg) => (${this._raDecDeg[0]},${this._raDecDeg[1]}) (x, y,z) => (${this._xyz[0]},${this._xyz[1]},${this._xyz[2]})`}}t.Point=l},7559(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}}},146(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Source=void 0;const s=i(4851),o=r(i(4382));t.Source=class{_point;_name;_details;_h_pix;_shapesize;_brightnessFactor;constructor(e,t=[]){this._point=e,this._details=t,this._shapesize=16,this._brightnessFactor=-99,this.computeHealpixPixel()}getDetailByindex(e){if(!(e<0||e>=this._details.length))return this._details[e]}get details(){return this._details}computeHealpixPixel(){const e=o.default.getHealpix(o.default.nsideForSelection),t=new s.Vec3(this._point.x,this._point.y,this._point.z),i=new s.Pointing(t,!1);this._h_pix=e.ang2pix(i,!1)}get point(){return this._point}get name(){return this._name}get healpixPixel(){return this._h_pix}get shapeSize(){return this._shapesize}set shapeSize(e){this._shapesize=e}get brightnessFactor(){return this._brightnessFactor}set brightnessFactor(e){this._brightnessFactor=e}}},5803(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SphereFoV=void 0;const r=i(3890),s=i(7930);class o{static MIN_FOV_DEG=1e-6;fovXDeg=180;fovYDeg=180;ratio=0;_minFoV=180;_webgl;_lastModel=null;_lastCamera=null;constructor(e){this._webgl=e}getFoV(e,t,i,r){this._lastModel=t,this._lastCamera=i;const s=this._webgl.canvas;if(!s)return this.fovXDeg=180,this.fovYDeg=180,this._minFoV=this.minFoV,this;const o=s.getBoundingClientRect(),a=o.width,n=o.height;return this.fovXDeg=this.computeAngle(0,n/2,e,t,i,r).angleDeg,this.fovYDeg=this.computeAngle(a/2,0,e,t,i,r).angleDeg,this._minFoV=this.minFoV,this.ratio=this.computeRatio(i),this}computeRatio(e){const t=e.getCameraPosition();return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])/this.fovYDeg}get minFoV(){const e=this.fovYDeg<=this.fovXDeg?this.fovYDeg:this.fovXDeg;return this._minFoV=Math.max(e,o.MIN_FOV_DEG),this._minFoV}get xFoV(){return this.fovXDeg}get yFoV(){return this.fovYDeg}computeDistanceFromAngle(e){return e*this.ratio}changeMinFov(e){this.fovYDeg<=this.fovXDeg?this.fovYDeg=e:this.fovXDeg=e,this.minFoV}computeCameraPositionForMinFoV(e){return this.computeCameraPositionForFoV(e)}computeCameraPositionForFoV(e){return this.computeCameraPositionForAngularDiameter(e)}computeCameraPositionForAngularDiameter(e){if(!this._lastModel||!this._lastCamera)return[0,0,0];const t=1e-6,i=Math.max(t,Math.min(180-t,e))*Math.PI/360,s=Math.sin(i);if(s<=0)return[0,0,0];const o=this._lastModel,a=this._lastCamera,n=Math.max(o.radius/s,o.radius+1e-4),l=a.getCameraPosition(),h=r.vec3.fromValues(l[0]-o.center[0],l[1]-o.center[1],l[2]-o.center[2]);return r.vec3.length(h)<t?r.vec3.set(h,0,0,1):r.vec3.normalize(h,h),[o.center[0]+h[0]*n,o.center[1]+h[1]*n,o.center[2]+h[2]*n]}computeAngle(e,t,i,r,s,o){const a=this._webgl.canvas.getBoundingClientRect(),n=this.getIntersectionPointWithModel(a.width/2,a.height/2,r,s,o),l=this.getIntersectionPointWithModel(e,t,r,s,o);if(!n||!l)return{angleDeg:180,distance:-1};return{angleDeg:2*this.computeAngularDistanceDeg(n.point,l.point),distance:l.distance}}computeAngularDistanceDeg(e,t){const i=r.vec3.normalize(r.vec3.create(),e),o=r.vec3.normalize(r.vec3.create(),t),a=r.vec3.dot(i,o),n=r.vec3.cross(r.vec3.create(),i,o),l=Math.atan2(r.vec3.length(n),Math.min(1,Math.max(-1,a)));return(0,s.radToDeg)(l)}getIntersectionPointWithModel(e,t,i,s,o){const a=this.getRayFromMouse(e,t,o,s.getCameraMatrix()),n=this.raySphere(s.getCameraPosition(),a,i);if(n<0)return null;const l=r.vec3.create();r.vec3.scale(l,a,n),r.vec3.add(l,s.getCameraPosition(),l);const h=[l[0],l[1],l[2],1],c=[0,0,0,0];return this.mat4MultiplyVec4(i.getModelMatrixInverse(),h,c),{point:r.vec3.fromValues(c[0],c[1],c[2]),distance:n}}getRayFromMouse(e,t,i,s){const o=this._webgl.canvas.getBoundingClientRect(),a=[2*e/o.width-1,1-2*t/o.height,-1,1],n=r.mat4.create();r.mat4.invert(n,i);const l=[0,0,0,0];this.mat4MultiplyVec4(n,a,l);const h=[l[0],l[1],-1,0],c=r.mat4.create();r.mat4.invert(c,s);const u=[0,0,0,0];this.mat4MultiplyVec4(c,h,u);const d=r.vec3.fromValues(u[0],u[1],u[2]);return r.vec3.normalize(d,d),d}raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}mat4MultiplyVec4(e,t,i){i[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],i[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],i[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],i[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3]}}t.SphereFoV=o},1232(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueGL=void 0;const r=i(146),s=i(6553),o=i(8145),a=i(7930),n=i(3559),l=i(5403);class h{_kind="CatalogueGL";static ELEM_SIZE=6;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static STANDARD_SHAPE_SIZE=10;static STANDARD_SHAPE_HUE=3;_ready;_name;_description;_sources;vertexCataloguePositionBuffer=null;vertexhoveredCataloguePositionBuffer=null;vertexCataloguePosition;_bufferInitialised=!1;_webgl;hoveredIndexes;selectedIndexes;extHoveredIndexes;_oldMouseCoords;_metadataManager;_isVisible=!0;_shapeColor="#8F00FF";_healpixDensityMap;_providerUrl;_catalogueShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,o){this._webgl=s,this._ready=!1,this._visibleTilesManager=o,this.TYPE="SOURCE_CATALOGUE",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this._sources=[],this.vertexCataloguePosition=new Float32Array(0),this.hoveredIndexes=[],this.selectedIndexes=[],this.extHoveredIndexes=[],this._oldMouseCoords=null,this._healpixDensityMap=new Map,this._catalogueShaderProgram=new n.CatalogueShaderProgram(this._webgl),this._catalogueShaderProgram.shaderProgram,this._isVisible=!0}setIsVisible(e){this._isVisible=e}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get isVisible(){return this._isVisible}minMax(e){if(!this._sources.length)return{min:0,max:0};let t=this._sources[0].details[e];if(isNaN(Number(t)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain only number values`),{min:0,max:0};let i=t;for(const r of this._sources){const s=r.details[e];if(isNaN(Number(s)))return console.warn(`${this._metadataManager.columns[e].name} doesn't contain number only values`),{min:0,max:0};s<t&&(t=s),s>i&&(i=s)}return{min:Number(t),max:Number(i)}}get metadataManager(){return this._metadataManager}changeMetaRA(e){this._metadataManager.selectedRaColumn=e}changeMetaDec(e){this._metadataManager.selectedDecColumn=e}changeColor(e){this._shapeColor=e}changeMetaShapeSize(e){if(!this._webgl)return;if(e==l.MetadataManager.STANDARD_SIZE){this._metadataManager.resetShapeColumn();for(const e of this._sources){const t=h.STANDARD_SHAPE_SIZE;e.shapeSize=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedShapeColumn=e;const i=this._metadataManager.selectedShapeColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedShapeColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),o=Number(r.max),a=12*((t-s)/Math.max(1e-12,o-s))+8;e.shapeSize=a}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}changeMetaShapeHue(e){if(!this._webgl)return;if(e==l.MetadataManager.STANDARD_HUE){this._metadataManager.resetHueColumn();for(const e of this._sources){const t=h.STANDARD_SHAPE_HUE;e.brightnessFactor=t}return void(this._bufferInitialised=!1)}const t=this._metadataManager.selectedShapeColumn?.name;this._metadataManager.selectedHueColumn=e;const i=this._metadataManager.selectedHueColumn?.index??-1;if(i<0)return void(t&&(this._metadataManager.selectedHueColumn=t));const r=this.minMax(i);if(r.min!=r.max){for(const e of this._sources){const t=Number(e.getDetailByindex(i)),s=Number(r.min),o=Number(r.max),a=(t-s)/Math.max(1e-12,o-s);e.brightnessFactor=-(2*a-1)}this._bufferInitialised=!1}else console.warn(`${r} min and max are equals. No resizing will be applied.`)}get sources(){return this._sources}addSource(e){this._sources.push(e)}addSources(e,t){this._ready=!1,this._sources=[],this._metadataManager=new l.MetadataManager(t);const i=this._metadataManager.selectedRaColumn?.index??-1,a=this._metadataManager.selectedDecColumn?.index??-1;if(i<0||a<0)throw new Error(`(ra, dec) idx not defined (${i}, ${a}) `);for(let t=0;t<e.length;t++){const n=new s.Point({raDeg:e[t][i],decDeg:e[t][a]},o.CoordsType.ASTRO),l=new r.Source(n,e[t]);l.shapeSize=l.shapeSize??h.STANDARD_SHAPE_SIZE,l.brightnessFactor=3,this.addSource(l),this._metadataManager.selectedHueColumn?.name&&this.changeMetaShapeHue(this._metadataManager.selectedHueColumn.name),this._metadataManager.selectedShapeColumn?.name&&this.changeMetaShapeSize(this._metadataManager.selectedShapeColumn.name)}this._ready=!0,this._bufferInitialised=!1}clearSources(){this._sources=[],this.hoveredIndexes=[],this._healpixDensityMap.clear(),this.vertexCataloguePosition=new Float32Array(0)}sourceMatches(e,t){if(e===t)return!0;const i=e.point,r=t.point;if(i.raDeg!==r.raDeg||i.decDeg!==r.decDeg)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findSourceIndex(e){const t=this._sources.indexOf(e);return t>=0?t:this._sources.findIndex(t=>this.sourceMatches(t,e))}extHighlightSource(e,t){const i=this.findSourceIndex(e);if(i<0)return;const r=i*h.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&(this.hoveredIndexes.splice(e,1),this.vertexCataloguePosition[r+3]=0,this.vertexCataloguePosition[r+4]=this._sources[i]?.shapeSize??h.STANDARD_SHAPE_SIZE)}}extAddSources2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findSourceIndex(e);if(t<0)return;const i=t*h.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&(this.selectedIndexes.splice(e,1),this.vertexCataloguePosition[i+3]=0,this.vertexCataloguePosition[i+4]=this._sources[t]?.shapeSize??h.STANDARD_SHAPE_SIZE)}else this.selectedIndexes.push(t)}initBuffer(){this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.vertexhoveredCataloguePositionBuffer=this._webgl.createBuffer(),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer);const e=this._sources.length;this.vertexCataloguePosition=new Float32Array(e*h.ELEM_SIZE);let t=0;for(let i=0;i<e;i++){const e=this._sources[i],r=e.healpixPixel,s=this._healpixDensityMap.get(r);s?s.includes(i)||s.push(i):this._healpixDensityMap.set(r,[i]),this.vertexCataloguePosition[t+0]=e.point.x,this.vertexCataloguePosition[t+1]=e.point.y,this.vertexCataloguePosition[t+2]=e.point.z,this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=e.shapeSize??h.STANDARD_SHAPE_SIZE,this.vertexCataloguePosition[t+5]=e.brightnessFactor??0,t+=h.ELEM_SIZE}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._bufferInitialised=!0}getSelectionRadius(){switch(this._visibleTilesManager.getVisibleOrder()){case 0:case 1:case 2:return.01;case 3:case 4:case 5:return.005;case 6:case 7:case 8:return.001;case 9:return 5e-4;default:return 1e-4}}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkClicking: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const o=r[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,l=a.point.y-e.y,h=a.point.z-e.z;Math.sqrt(n*n+l*l+h*h)<=s&&t.push(o)}}return t}setSelectedIndexes(e){e.forEach(e=>{if(e<0||e>=this._sources.length)return;const t=e*h.ELEM_SIZE;t+4>=this.vertexCataloguePosition.length||(this.selectedIndexes.includes(e)?(this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1),this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??h.STANDARD_SHAPE_SIZE):(this.selectedIndexes.push(e),this.vertexCataloguePosition[t+3]=2,this.vertexCataloguePosition[t+4]=this._sources[e]?.shapeSize??h.STANDARD_SHAPE_SIZE))})}getSourcesFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{sources:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this._sources[e];t&&i.push(t)}),i.length?{sources:i,pickedIndexes:t}:null}selectPrimarySourceFromClick(e){const t=this.getSourcesFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{sources:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this._sources[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({source:t,selected:i}),s.push(t)}),s.length?{sources:s,selectionState:r}:null}getPrimaryHoveredSource(){if(!this.hoveredIndexes.length)return null;const e=this.hoveredIndexes[0];return this._sources[e]??null}checkHovering(e){if(null==e.x||null==e.y||null==e.z)return console.log("CatalogueGL.checkHovering: missing mouse coords"),[];const t=[],i=e.computeNpix();if(null!=i&&this._healpixDensityMap.has(i)){const r=this._healpixDensityMap.get(i),s=this.getSelectionRadius();for(let i=0;i<r.length;i++){const o=r[i],a=this._sources[o];if(!a)continue;const n=a.point.x-e.x,l=a.point.y-e.y,h=a.point.z-e.z;Math.sqrt(n*n+l*l+h*h)<=s&&t.push(o)}}return t}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;this._catalogueShaderProgram.enableShaders(r,e,i),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.position,3,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.position),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.hovered,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,3*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.hovered),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.pointSize,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,4*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.pointSize),this._webgl.vertexAttribPointer(this._catalogueShaderProgram.locations.brightness,1,this._webgl.FLOAT,!1,h.BYTES_X_ELEM*h.ELEM_SIZE,5*h.BYTES_X_ELEM),this._webgl.enableVertexAttribArray(this._catalogueShaderProgram.locations.brightness);const s=(0,a.colorHex2RGB)(this._shapeColor);this._catalogueShaderProgram.locations.color&&this._webgl.uniform4f(this._catalogueShaderProgram.locations.color,s[0],s[1],s[2],1);for(let e=0;e<this.selectedIndexes.length;e++){const t=this.selectedIndexes[e],i=t*h.ELEM_SIZE;this.vertexCataloguePosition[i+3]=2,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e]*h.ELEM_SIZE;this.vertexCataloguePosition[t+3]=0,this.vertexCataloguePosition[t+4]=this._sources[this.hoveredIndexes[e]].shapeSize}null!=t&&t.xyz!==this._oldMouseCoords&&(this.hoveredIndexes=this.checkHovering(t));for(let e=0;e<this.hoveredIndexes.length;e++){const t=this.hoveredIndexes[e],i=t*h.ELEM_SIZE;this.vertexCataloguePosition[i+3]=1,this.vertexCataloguePosition[i+4]=this._sources[t].shapeSize}this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW);const o=this.vertexCataloguePosition.length/h.ELEM_SIZE;this._webgl.drawArrays(this._webgl.POINTS,0,o),this._oldMouseCoords=t.xyz}}t.CatalogueGL=h},3956(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WMTSAdapter=void 0;t.WMTSAdapter=class{_config;constructor(e){this._config=e}toXYZLayerConfig(){const e=this.getInferredMaxZoom();return{urlTemplate:this._config.urlTemplate??this._config.baseUrl,minZoom:this._config.minZoom,maxZoom:e,segmentsPerSide:this._config.segmentsPerSide,tileSize:this._config.tileSize,maxCachedTiles:this._config.maxCachedTiles,subdomains:this._config.subdomains,attribution:this._config.attribution,flipY:this._config.flipY,urlResolver:e=>this.getTileUrl(e)}}getInferredMaxZoom(){const e=this._config.matrixLabels?.length??0,t=e>0?e-1:void 0;return null==t?this._config.maxZoom:null==this._config.maxZoom?t:Math.min(this._config.maxZoom,t)}getTileUrl(e){return"rest"===this._config.requestEncoding?this.buildRestUrl(e):this.buildKvpUrl(e)}buildRestUrl(e){const t=function(e,t){return Object.entries(t).reduce((e,[t,i])=>e.replace(new RegExp(`\\{${t}\\}`,"g"),i),e)}(this._config.urlTemplate??this._config.baseUrl,this.getCommonTokenValues(e));return t.replace(/(?<!:)\/{2,}/g,"/")}buildKvpUrl(e){const t=new URL(this._config.baseUrl),i=this.getCommonTokenValues(e),r=t.searchParams;r.set("SERVICE","WMTS"),r.set("REQUEST","GetTile"),r.set("VERSION",this._config.version??"1.0.0"),r.set("LAYER",this._config.layer),r.set("STYLE",this._config.style??"default"),r.set("FORMAT",this._config.format??"image/png"),r.set("TILEMATRIXSET",this._config.tileMatrixSet),r.set("TILEMATRIX",i.TileMatrix),r.set("TILEROW",i.TileRow),r.set("TILECOL",i.TileCol);for(const[e,t]of Object.entries(this._config.dimensions??{}))r.set(e,t);return t.toString()}getCommonTokenValues(e){const t=2**e.z,i=this._config.flipY?t-1-e.y:e.y,r=this._config.matrixLabels?.[e.z]??String(e.z),s=this._config.format??"image/png",o=s.replace(/^image\//,"");return{Layer:this._config.layer,Style:this._config.style??"default",Time:this._config.time??"",TileMatrixSet:this._config.tileMatrixSet,TileMatrix:r,TileRow:String(i),TileCol:String(e.x),Format:o,TileFormat:s,TileFormatExtension:o,...Object.fromEntries(Object.entries(this._config.dimensions??{}).map(([e,t])=>[e,t]))}}}},3174(e,t,i){"use strict";t.XYZAnchestorTile=void 0;const r=i(8819),s=i(1375);class o extends s.XYZTile{_ancestorMeshBuilder;_ancestorWebgl;_segmentsPerSide;_meshCache=new Map;constructor(e,t,i,s,o=new r.XYZMeshBuilder,a=16){super(e,t,i,s,o,a),this._ancestorMeshBuilder=o,this._ancestorWebgl=i,this._segmentsPerSide=a}draw(e,t,i,r,s,o,a){if("number"!=typeof e)return super.draw(e,t,i,r);if(!s||!o||void 0===a)return!1;const n=t,l=i,h=r;let c=!1;if(e<=this.coord.z)return super.draw(h,s,o,a);for(const e of n){if(!this.isAncestorOf(e))continue;const t=`${this.coord.z}/${this.coord.x}/${this.coord.y}`;if(!l.has(t))continue;const i=this.getRemappedMesh(e);c=super.drawRemapped(i,h,s,o,a)||c}return c}dispose(){for(const e of this._meshCache.values())e.positionBuffer&&this._ancestorWebgl.deleteBuffer(e.positionBuffer),e.uvBuffer&&this._ancestorWebgl.deleteBuffer(e.uvBuffer),e.indexBuffer&&this._ancestorWebgl.deleteBuffer(e.indexBuffer);this._meshCache.clear(),super.dispose()}getRemappedMesh(e){const t=`${e.z}/${e.x}/${e.y}->${this.coord.z}/${this.coord.x}/${this.coord.y}`,i=this._meshCache.get(t);if(i)return i;const r=this._ancestorMeshBuilder.buildAncestorMesh(e,this.coord,this._segmentsPerSide),s=this._ancestorMeshBuilder.uploadMesh(r,this._ancestorWebgl);return this._meshCache.set(t,s),s}isAncestorOf(e){if(e.z<=this.coord.z)return e.z===this.coord.z&&e.x===this.coord.x&&e.y===this.coord.y;const t=e.z-this.coord.z;return e.x>>t===this.coord.x&&e.y>>t===this.coord.y}}t.XYZAnchestorTile=o},8284(e,t){"use strict";t.xyzFovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static ZOOM_MIN_FOV={2:179,3:90,4:30,5:20,6:6,7:3.2,8:1.6,9:.85,10:.42,11:.21,12:.12,13:.06,14:.015,15:0};getZoom(e,t){const r=this.getRawZoom(e);if(void 0===t||t===r)return r;if(r>t){const r=i.ZOOM_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.ZOOM_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawZoom(e){return e>=179?2:e>=90?3:e>=30?4:e>=20?5:e>=6?6:e>=3.2?7:e>=1.6?8:e>=.85?9:e>=.42?10:e>=.21?11:e>=.12?12:e>=.06?13:e>=.015?14:15}getLonLatSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{lonStep:i,latStep:r}}}t.xyzFovHelper=new i},1741(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XYZMap=void 0;const r=i(4735),s=i(6937),o=i(8284),a=i(619),n=i(8124),l=i(149),h=i(2737),c=i(3174),u=i(8819);class d extends r.AbstractSkyEntity{_xyzShaderProgram;_descriptor;_visibleTilesManager;_tileBuffer;_meshBuilder;_baseurl;_zoom;_latLonGrid;_colorMapIdx=0;_colorMap=a.ColorMaps.native;constructor(e,t,i,r,a,c,d){super(e,t,i,r,a.name,c,!1),this._descriptor=a,this._xyzShaderProgram=new l.XYZShaderProgram(c),this._meshBuilder=new u.XYZMeshBuilder,this._tileBuffer=new h.XYZTileBuffer(1),this.initGL(c),this._latLonGrid=new n.LatLonGrid(e,t,i,r,"LatLonGrid",this._webgl,d),this._visibleTilesManager=new s.XYZVisibleTilesManager,this._baseurl=a.url,this.initShaders();this._zoom=o.xyzFovHelper.getZoom(180)}changeColorMap(e){switch(this._colorMap=e,e.name){case"grayscale":this._colorMapIdx=1,this._colorMap=a.ColorMaps.grayscale;break;case"planck":this._colorMapIdx=2,this._colorMap=a.ColorMaps.planck;break;case"cmb":this._colorMapIdx=3,this._colorMap=a.ColorMaps.cmb;break;case"rainbow":this._colorMapIdx=4,this._colorMap=a.ColorMaps.rainbow;break;case"eosb":this._colorMapIdx=5,this._colorMap=a.ColorMaps.eosb;break;case"cubehelix":this._colorMapIdx=6,this._colorMap=a.ColorMaps.cubehelix;break;case"hot":this._colorMapIdx=7,this._colorMap=a.ColorMaps.hot;break;case"gray":this._colorMapIdx=8,this._colorMap=a.ColorMaps.gray;break;case"native":this._colorMapIdx=0,this._colorMap=a.ColorMaps.native;break;default:this._colorMapIdx=9,this._colorMap=e}}initShaders(){this._xyzShaderProgram.enableProgram()}isLonLatGridVisible(){return this._latLonGrid.isVisible()}toggleLonLatGrid(){return this._latLonGrid.toggleShowGrid()}getFoV(){return this._latLonGrid.getFoV()}refresh(e){const t=this._latLonGrid.refreshFoV(e);this._zoom=o.xyzFovHelper.getZoom(t)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();this._xyzShaderProgram.setRuntimeColorMap(this._colorMap);const s=this._visibleTilesManager.computeVisibleTiles(this._zoom,this,this._webgl,e.camera,e.pMatrix),o=s.visibleTiles,a=s.ancestorsMap,n=this._tileBuffer.ensureTiles(this.getTilesToEnsure(o,a),e=>this.createTile(e));this._tileBuffer.evictCached(this._descriptor.maxCachedTiles);for(const e of n){const o=this._tileBuffer.getActiveTile(e);if(!o||o.coord.z!==s.currentZoom)continue;if(o.draw(i,t,r,this._colorMapIdx))continue;const n=this.findBestAvailableAncestor(o.coord);n?.draw(s.currentZoom,[o.coord],a,i,t,r,this._colorMapIdx)}this._latLonGrid.draw(e)}createTile(e){return new c.XYZAnchestorTile(e,this.resolveTileUrl(e),this._webgl,this._xyzShaderProgram,this._meshBuilder,this._descriptor.segmentsPerSide)}getTilesToEnsure(e,t){const i=new Map;for(const t of e)i.set(this.tileKey(t),t);for(const e of t.values())i.set(this.tileKey(e),e);return Array.from(i.values())}findBestAvailableAncestor(e){for(let t=e.z-1;t>=0;t--){const i=e.z-t,r={z:t,x:e.x>>i,y:e.y>>i},s=this._tileBuffer.getAnyTile(this.tileKey(r));if(s?.ready)return s}return null}resolveTileUrl(e){const t=this._descriptor.urlResolver;if(t)return t(e);const i=2**e.z,r=this._descriptor.flipY?i-1-e.y:e.y,s=this._descriptor.subdomains,o=s.length>0?s[Math.abs(e.x+e.y+e.z)%s.length]:"";return this._baseurl.replace(/\{z\}/g,String(e.z)).replace(/\{x\}/g,String(e.x)).replace(/\{y\}/g,String(r)).replace(/\{s\}/g,o??"")}getDebugStats(){const e=Array.from(this._tileBuffer.activeTiles.values(),e=>e.tile),t=Array.from(this._tileBuffer.cachedTiles.values(),e=>e.tile),i=[...e,...t],r=this._visibleTilesManager.selection;return{cacheSize:this._tileBuffer.size,visibleTileCount:r.visibleTiles.length,currentTileCount:e.filter(e=>e.coord.z===r.currentZoom).length,fallbackTileCount:r.ancestorsMap.size,coreTileCount:r.visibleTiles.length,coverageTileCount:r.visibleTiles.length,readyTileCount:i.filter(e=>e.ready).length,loadingTileCount:i.filter(e=>e.loading).length,coolingDownTileCount:0,currentZoom:r.currentZoom,tileSelectionKey:r.key,isSettling:!1,coarseTileCount:r.ancestorsMap.size,hasPendingSelection:!1,pendingSelectionKey:null}}tileKey(e){return`${e.z}/${e.x}/${e.y}`}}t.XYZMap=d},8868(e,t){"use strict";t.XYZMapDescriptor=void 0;t.XYZMapDescriptor=class{_name;_url;_urlResolver;_minZoom;_maxZoom;_segmentsPerSide;_tileSize;_maxCachedTiles;_interactionDebounceMs;_subdomains;_attribution;_flipY;_maxConcurrentLoads;constructor(e,t,i=0,r=8,s=16,o=384,a=8,n){this._name=e,this._url=t,this._urlResolver=n,this._minZoom=i,this._maxZoom=r,this._segmentsPerSide=s,this._maxCachedTiles=o,this._interactionDebounceMs=100,this._subdomains=["a","b","c"],this._attribution="",this._flipY=!1,this._maxConcurrentLoads=a}get url(){return this._url}get urlResolver(){return this._urlResolver}get name(){return this._name}get minZoom(){return this._minZoom}get maxZoom(){return this._maxZoom}get segmentsPerSide(){return this._segmentsPerSide}get maxCachedTiles(){return this._maxCachedTiles}get interactionDebounceMs(){return this._interactionDebounceMs}get subdomains(){return this._subdomains}get attribution(){return this._attribution}get flipY(){return this._flipY}get maxConcurrentLoads(){return this._maxConcurrentLoads}}},8819(e,t,i){"use strict";t.XYZMeshBuilder=void 0;const r=i(7930),s=85.0511287798066;function o(e){const t=Math.PI*(1-2*e);return 180*Math.atan(Math.sinh(t))/Math.PI}function a(e){return e<0?e+360:e}t.XYZMeshBuilder=class{buildTileMesh(e,t=16){const i=Math.max(1,Math.floor(t)),n=i+1,l=n*n,h=new Float32Array(3*l),c=new Float32Array(2*l),u=2**e.z;let d=0,g=0;for(let t=0;t<=i;t++){const n=t/i,l=(e.y+n)/u,_=90-Math.max(-85.0511287798066,Math.min(s,o(l)));for(let t=0;t<=i;t++){const s=t/i,o=a(360*((e.x+s)/u)-180),[l,p,f]=(0,r.sphericalToCartesian)(o,_,1);h[d++]=l,h[d++]=p,h[d++]=f,c[g++]=s,c[g++]=1-n}}const _=new Uint32Array(i*i*2*3);let p=0;for(let e=0;e<i;e++)for(let t=0;t<i;t++){const i=e*n+t,r=i+1,s=i+n,o=s+1;_[p++]=i,_[p++]=s,_[p++]=r,_[p++]=r,_[p++]=s,_[p++]=o}return{positions:h,uvs:c,indices:_.length>65535?_:new Uint16Array(_)}}buildAncestorMesh(e,t,i=16){const r=this.buildTileMesh(e,i),s=e.z-t.z,o=2**s,a=e.x-(t.x<<s),n=e.y-(t.y<<s),l=new Float32Array(r.uvs.length);for(let e=0;e<r.uvs.length;e+=2){const t=r.uvs[e]??0,i=1-(r.uvs[e+1]??0);l[e]=(a+t)/o,l[e+1]=1-(n+i)/o}return{positions:r.positions,uvs:l,indices:r.indices}}uploadMesh(e,t){const i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer(),o=e.indices instanceof Uint32Array?t.UNSIGNED_INT:t.UNSIGNED_SHORT;return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.uvs,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:i,uvBuffer:r,indexBuffer:s,indexCount:e.indices.length,indexType:o}}}},1375(e,t,i){"use strict";t.XYZTile=void 0;const r=i(8819);t.XYZTile=class{_coord;_url;_webgl;_shaderProgram;_meshBuilder;_gpuMesh;_texture=null;_image;_ready=!1;_loading=!1;_aborted=!1;_failedUntil=0;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,i,s,o=new r.XYZMeshBuilder,a=16){this._coord=e,this._url=t,this._webgl=i,this._shaderProgram=s,this._meshBuilder=o;const n=this._meshBuilder.buildTileMesh(e,a);this._gpuMesh=this._meshBuilder.uploadMesh(n,this._webgl),this.initImage()}get coord(){return this._coord}get ready(){return this._ready}get loading(){return this._loading}get failedUntil(){return this._failedUntil}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}initImage(){if(this._loading||this._ready||this._aborted)return;const e=Date.now();if(this._failedUntil>e)return;this._loading=!0;const t=new Image;this._image=t,t.crossOrigin="anonymous",t.onload=()=>this.imageLoaded(),t.onerror=()=>{this._ready=!1,this._loading=!1,this._failedUntil=Date.now()+3e4},t.src=this._url}imageLoaded(){this._image&&!this._aborted&&(this.textureLoaded(this._image),this._loading=!1,this._failedUntil=0,this._ready=!0)}textureLoaded(e){const t=this._webgl;this._shaderProgram.enableProgram();const i=t.createTexture();if(!i)throw new Error(`Could not create XYZ texture for ${this.key}`);this._texture=i,t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}draw(e,t,i,r){return this.touch(),!(!this._ready||!this._texture||this._aborted)&&(this.drawWithGpuMesh(this._gpuMesh,e,t,i,r),!0)}drawRemapped(e,t,i,r,s){return this.touch(),!(!this._ready||!this._texture||this._aborted)&&(this.drawWithGpuMesh(e,t,i,r,s),!0)}dispose(){const e=this._webgl;this._texture&&(e.deleteTexture(this._texture),this._texture=null),this._gpuMesh.positionBuffer&&(e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh.positionBuffer=null),this._gpuMesh.uvBuffer&&(e.deleteBuffer(this._gpuMesh.uvBuffer),this._gpuMesh.uvBuffer=null),this._gpuMesh.indexBuffer&&(e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh.indexBuffer=null),this._image=void 0,this._ready=!1,this._loading=!1,this._aborted=!0}drawWithGpuMesh(e,t,i,r,s){if(!this._texture)return;const o=this._webgl;this._shaderProgram.enableShaders(t,i,r,s),o.bindBuffer(o.ARRAY_BUFFER,e.positionBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),o.bindBuffer(o.ARRAY_BUFFER,e.uvBuffer),o.vertexAttribPointer(this._shaderProgram.locations.textureCoordAttribute,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._texture),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,e.indexBuffer),o.drawElements(o.TRIANGLES,e.indexCount,e.indexType,0),o.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),o.disableVertexAttribArray(this._shaderProgram.locations.textureCoordAttribute)}get key(){return`${this._coord.z}/${this._coord.x}/${this._coord.y}`}}},2737(e,t){"use strict";t.XYZTileBuffer=void 0;class i{_tiles=new Map;_cachedTiles=new Map;_cacheAliveMilliSeconds;_cleanerId;constructor(e=1){this._cacheAliveMilliSeconds=60*e*1e3,"undefined"!=typeof window&&(this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4))}get activeTiles(){return this._tiles}get cachedTiles(){return this._cachedTiles}get size(){return this._tiles.size+this._cachedTiles.size}ensureTiles(e,t){const i=[];for(const r of e){const e=this.getTile(r,t);this.touchTile(e),i.push(this.key(r))}return this.syncVisibleTiles(i),i}getTile(e,t){const i=this.key(e);if(this._tiles.has(i))return this._tiles.get(i).tile;if(this._cachedTiles.has(i)){const e=this._cachedTiles.get(i);return e.cacheTime0=void 0,this._tiles.set(i,e),this._cachedTiles.delete(i),e.tile}const r=t(e);return this._tiles.set(i,{tile:r}),r}getActiveTile(e){return this._tiles.get(e)?.tile??null}getAnyTile(e){return this._tiles.get(e)?.tile??this._cachedTiles.get(e)?.tile??null}getActiveTiles(){return Array.from(this._tiles.values(),e=>e.tile)}syncVisibleTiles(e){const t=new Set(e);for(const[e,i]of this._tiles)t.has(e)?this.touchTile(i.tile):(i.cacheTime0=Date.now(),this._cachedTiles.set(e,i),this._tiles.delete(e))}evictCached(e){if(this.size<=e)return;const t=Array.from(this._cachedTiles.entries()).sort((e,t)=>this.getTileAgeScore(e[1].tile)-this.getTileAgeScore(t[1].tile));for(const[i,r]of t){if(this.size<=e)break;r.tile.loading||(r.tile.dispose?.(),this._cachedTiles.delete(i))}}dispose(){void 0!==this._cleanerId&&"undefined"!=typeof window&&(window.clearInterval(this._cleanerId),this._cleanerId=void 0);for(const e of this._tiles.values())e.tile.dispose?.();for(const e of this._cachedTiles.values())e.tile.dispose?.();this._tiles.clear(),this._cachedTiles.clear()}key(e){return i.key(e)}static key(e){return`${e.z}/${e.x}/${e.y}`}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;void 0===r||e-r<=this._cacheAliveMilliSeconds||i.tile.loading||(i.tile.dispose?.(),this._cachedTiles.delete(t))}}touchTile(e){e.touch?.()}getTileAgeScore(e){const t=e.lastUsedAt??0,i=e.createdAt??t;return Math.min(t||i,i)}}t.XYZTileBuffer=i},5409(e,t){"use strict";t.xyzTileRequestScheduler=void 0;class i extends Error{cooldownMs;retryable;constructor(e,t,i=!0){super(e),this.name="XYZTileRequestError",this.cooldownMs=t,this.retryable=i}}class r{_maxConcurrent;_activeCount=0;_queue=[];_inflight=new Map;_hostBackoff=new Map;_sequence=0;constructor(e=4){this._maxConcurrent=e}setMaxConcurrent(e){this._maxConcurrent=Math.max(1,Math.floor(e)),this.pump()}getMaxConcurrent(){return this._maxConcurrent}getDebugStats(){const e=Date.now(),t=Array.from(this._hostBackoff.entries()).map(([t,i])=>({host:t,cooldownMs:Math.max(0,i.cooldownUntil-e),consecutiveFailures:i.consecutiveFailures})).filter(e=>e.cooldownMs>0||e.consecutiveFailures>0).sort((e,t)=>t.cooldownMs-e.cooldownMs);return{activeRequests:this._activeCount,queuedRequests:this._queue.length,inflightRequests:this._inflight.size,maxConcurrentRequests:this._maxConcurrent,highestQueuedPriority:this._queue[0]?.priority??null,hostsInBackoff:t}}load(e,t=0){const r=this._inflight.get(e);if(r)return r;const s=this.getHostCooldown(e),o=Date.now();if(s>o)return Promise.reject(new i(`Cooldown active for ${new URL(e).host}`,s-o));const a=new Promise((i,r)=>{this._queue.push({url:e,resolve:i,reject:r,priority:t,sequence:this._sequence++}),this._queue.sort((e,t)=>t.priority-e.priority||e.sequence-t.sequence),this.pump()}).finally(()=>{this._inflight.delete(e)});return this._inflight.set(e,a),a}pump(){for(;this._activeCount<this._maxConcurrent&&this._queue.length>0;){const e=this._queue.shift();if(!e)return;const t=this.getHostCooldown(e.url),r=Date.now();t>r?e.reject(new i(`Cooldown active for ${new URL(e.url).host}`,t-r)):(this._activeCount+=1,this.fetchBlob(e).then(e.resolve).catch(e.reject).finally(()=>{this._activeCount-=1,this.pump()}))}}async fetchBlob(e){try{const t=await fetch(e.url,{mode:"cors",cache:"force-cache"});if(!t.ok){const r=429===t.status||t.status>=500,s=this.registerFailure(e.url,r);throw new i(`HTTP ${t.status} loading ${e.url}`,r?s:3e5,r)}return this.registerSuccess(e.url),await t.blob()}catch(t){if(t instanceof i)throw t;const r=this.registerFailure(e.url,!1);throw new i(`Network/CORS failure loading ${e.url}`,r,!0)}}getHostCooldown(e){try{return this._hostBackoff.get(new URL(e).host)?.cooldownUntil??0}catch{return 0}}registerSuccess(e){try{const t=new URL(e).host;this._hostBackoff.set(t,{cooldownUntil:0,consecutiveFailures:0})}catch{}}registerFailure(e,t){if(!t)return 0;try{const t=new URL(e).host,i=(this._hostBackoff.get(t)??{cooldownUntil:0,consecutiveFailures:0}).consecutiveFailures+1,r=4e3,s=Math.min(12e4,r*2**Math.min(i-1,5));return this._hostBackoff.set(t,{cooldownUntil:Date.now()+s,consecutiveFailures:i}),s}catch{return 3e4}}}t.xyzTileRequestScheduler=new r},6937(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XYZVisibleTilesManager=void 0;const s=r(i(2166));t.XYZVisibleTilesManager=class{_ancestorsMap=new Map;_visibleTilesMap=new Map;_visibleTiles=[];_selection={key:"0:",currentZoom:0,visibleTiles:[],visibleTilesMap:new Map,ancestorsMap:new Map};get ancestorsMap(){return this._ancestorsMap}get visibleTiles(){return this._visibleTiles}get visibleTilesMap(){return this._visibleTilesMap}get selection(){return this._selection}computeVisibleTiles(e,t,i,r,o,a=9,n=2){return this._visibleTiles=s.default.getVisibleTilesFromViewport(e,t,i,r,o,a,n),this._visibleTilesMap=this.buildTileMap(this._visibleTiles),this.refreshAncestorsMap(this._visibleTiles),this._selection={key:this.buildSelectionKey(e,this._visibleTiles),currentZoom:e,visibleTiles:this._visibleTiles,visibleTilesMap:this._visibleTilesMap,ancestorsMap:this._ancestorsMap},this._selection}refreshAncestorsMap(e){this._ancestorsMap.clear();for(const t of e)for(let e=t.z-1;e>=0;e--){const i=t.z-e,r={z:e,x:t.x>>i,y:t.y>>i};this._ancestorsMap.set(`${r.z}/${r.x}/${r.y}`,r)}}buildTileMap(e){const t=new Map;for(const i of e)t.set(this.key(i),i);return t}buildSelectionKey(e,t){return`${e}:${t.map(e=>`${e.x}/${e.y}`).join("|")}`}key(e){return`${e.z}/${e.x}/${e.y}`}}},2475(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Footprint=void 0;const s=r(i(2930)),o=r(i(9665)),a=i(8145);class n{_polygons=[];_convexPolygons=[];_stcs;_valid=!1;_details;_totPoints=0;_totConvexPoints=0;_npix256;_footprintsPointsOrder;_coordsType;_selectionObj;_identifier;_center;constructor(e,t=[],i,r=a.CoordsType.ASTRO){this._coordsType=r,e?(this._stcs=e.toUpperCase(),this._details=t,this._totPoints=0,this._totConvexPoints=0,this._footprintsPointsOrder=i,this.computePoints(),this._selectionObj=this.computeSelectionObject(),this._valid=!0):this._details=[]}static fromPolygons(e,t=[],i=a.CoordsType.ASTRO){const r=new n(void 0,[],void 0,i);return r._polygons=e,r._details=t,r._totPoints=e.reduce((e,t)=>e+t.length,0),r._totConvexPoints=0,r._coordsType=i,r._selectionObj=r.computeSelectionObject(),r._valid=r._totPoints>0,r}computeSelectionObject(){return s.default.computeSelectionObject(this._polygons)}computePoints(){const e=o.default.parseSTCS(this._stcs,{coordsType:this._coordsType});this._polygons=e.polygons,this._totPoints=e.totpoints}get valid(){return this._valid}get totPoints(){return this._totPoints}get totConvexPoints(){return this._totConvexPoints}get polygons(){return this._polygons}get convexPolygons(){return this._convexPolygons}get identifier(){return this._identifier}get center(){return this._center}get pixels(){return this._npix256}get details(){return this._details}get selectionObj(){return this._selectionObj}}t.Footprint=n},592(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintSetGL=void 0;const s=i(2475),o=i(7930),a=i(8909),n=i(6553),l=r(i(2930)),h=i(8145),c=i(5403);class u{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;static CONVEXPOLY_ELEM_SIZE=3;_kind="FootprintSetGL";_ready;_name;_description;extHoveredIndexes;oldMouseCoords;healpixDensityMap;totConvexPoints;vertexCataloguePositionBuffer;indexBuffer;hoveredVertexPositionBuffer;hoveredIndexBuffer;selectedVertexPositionBuffer;selectedIndexBuffer;indexes;footprintPolygons=[];vertexCataloguePosition;totPoints;nPrimitiveFlags=0;hoveredIndexes;hoveredElementIndexes;_hoveredFootprints=[];hoveredVertexPosition;totHoveredPoints;nHoveredPrimitiveFlags=0;selectedIndexes;selectedElementIndexes;_selectedFootprints=[];selectedVertexPosition;totSelectedPoints;nSlectedPrimitiveFlags=0;_shapeColor="#00fff2ff";_coordsType=h.CoordsType.ASTRO;_bufferInitialised=!1;_webgl;_isVisible=!0;_metadataManager;_providerUrl;_footprintShaderProgram;_visibleTilesManager;constructor(e,t,i,r,s,o){this._webgl=s,this._ready=!1,this._visibleTilesManager=o,this.TYPE="FOOTPRINT_SET",this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=r,this.initFootprintArrays(),this.oldMouseCoords=null,this._footprintShaderProgram=new a.FootprintShaderProgram(this._webgl),this._footprintShaderProgram.shaderProgram}initFootprintArrays(){this.footprintPolygons=[],this.indexes=new Uint32Array,this.vertexCataloguePosition=new Float32Array,this.totPoints=0,this.totConvexPoints=0,this.extHoveredIndexes=new Uint32Array,this._hoveredFootprints=[],this.hoveredVertexPosition=new Float32Array,this.totHoveredPoints=0,this.hoveredIndexes=[],this.hoveredElementIndexes=new Uint32Array,this._selectedFootprints=[],this.selectedVertexPosition=new Float32Array,this.totSelectedPoints=0,this.selectedIndexes=[],this.selectedElementIndexes=new Uint32Array}initGLBuffers(){this._webgl&&(this.vertexCataloguePositionBuffer=this._webgl.createBuffer(),this.indexBuffer=this._webgl.createBuffer(),this.hoveredVertexPositionBuffer=this._webgl.createBuffer(),this.hoveredIndexBuffer=this._webgl.createBuffer(),this.selectedVertexPositionBuffer=this._webgl.createBuffer(),this.selectedIndexBuffer=this._webgl.createBuffer())}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}get shapeColor(){return this._shapeColor}get providerUrl(){return this._providerUrl}get name(){return this._name}get metadataManager(){return this._metadataManager}addFootprint(e){this.footprintPolygons.push(e)}addFootprints(e,t){this._ready=!1,this._metadataManager=new c.MetadataManager(t);const i=this._metadataManager.selectedOutlineColumn?.index??-1;if(i<0)throw new Error("geomColumn or its index is undefined in footprintsetProps");for(let t=0;t<e.length;t++)if(null!==e[t][i]){const r=new s.Footprint(e[t][i],e[t],void 0,this._coordsType);r._valid&&(this.addFootprint(r),this.totPoints+=r.totPoints,this.totConvexPoints+=r.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}clearFootprints(){this.initFootprintArrays()}initBuffer(){if(!this._webgl)return;this.initGLBuffers();const e=this.footprintPolygons.length;let t=e-1;for(let i=0;i<e;i++)t+=this.footprintPolygons[i].polygons.length-1;this.indexes=new Uint32Array(this.totPoints+t+1);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this.vertexCataloguePosition=new Float32Array(3*this.totPoints);let r=0,s=0;this.nPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this.footprintPolygons[t].polygons;t>0&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const t of e){t!==e[0]&&(this.indexes[s++]=i,this.nPrimitiveFlags++);for(const e of t)this.vertexCataloguePosition[r++]=1*e.x,this.vertexCataloguePosition[r++]=1*e.y,this.vertexCataloguePosition[r++]=1*e.z,this.indexes[s++]=Math.floor((r-1)/3)}}this.indexes[this.indexes.length-1]=i,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.vertexCataloguePosition,this._webgl.STATIC_DRAW),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexes,this._webgl.STATIC_DRAW),this._bufferInitialised=!0,console.log("Buffer initialized")}checkSelection(e){if(!e.x||!e.y||!e.z)return;if(!e.computeNpix())return;this._hoveredFootprints=[],this.totHoveredPoints=0;const t=new n.Point({x:e.x,y:e.y,z:e.z},h.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const i=this.footprintPolygons[e];if(i.selectionObj&&l.default.checkPointInsidePolygon5(i.selectionObj,t)){const e=[...i.details],t=this._metadataManager.selectedOutlineColumn?.index??-1;t>=0&&e.splice(t,1),this._hoveredFootprints.push(i),this.totHoveredPoints+=i.totPoints}}this.initHoveringBuffer()}get hoveredFootprints(){return{metadata:this._metadataManager,footprints:this._hoveredFootprints,tableName:this._name,description:this._description,provider:this._providerUrl}}get selectedFootprints(){return this._selectedFootprints}checkClicking(e){if(null==e.x||null==e.y||null==e.z)return[];const t=[],i=new n.Point({x:e.x,y:e.y,z:e.z},h.CoordsType.CARTESIAN);for(let e=0;e<this.footprintPolygons.length;e++){const r=this.footprintPolygons[e];r.selectionObj&&(l.default.checkPointInsidePolygon5(r.selectionObj,i)&&t.push(e))}return t}setSelectedIndexes(e){e.forEach(e=>{e<0||e>=this.footprintPolygons.length||(this.selectedIndexes.includes(e)?this.selectedIndexes.splice(this.selectedIndexes.indexOf(e),1):this.selectedIndexes.push(e))}),this.refreshSelectedFootprints()}refreshSelectedFootprints(){if(this._selectedFootprints=this.selectedIndexes.map(e=>this.footprintPolygons[e]).filter(e=>Boolean(e)),this.totSelectedPoints=this._selectedFootprints.reduce((e,t)=>e+t.totPoints,0),0===this._selectedFootprints.length)return this.selectedVertexPosition=new Float32Array,this.selectedElementIndexes=new Uint32Array,void(this.nSlectedPrimitiveFlags=0);this.initSelectionBuffer()}getFootprintsFromPointer(e){const t=this.checkClicking(e);if(!t.length)return{footprints:[],pickedIndexes:[]};const i=[];return t.forEach(e=>{const t=this.footprintPolygons[e];t&&i.push(t)}),i.length?{footprints:i,pickedIndexes:t}:null}selectPrimaryFootprintFromClick(e){const t=this.getFootprintsFromPointer(e),i=t?.pickedIndexes??[];if(this.setSelectedIndexes(i),!i.length)return{footprints:[],selectionState:[]};const r=[],s=[];return i.forEach(e=>{const t=this.footprintPolygons[e];if(!t)return;const i=this.selectedIndexes.includes(e);r.push({footprint:t,selected:i}),s.push(t)}),s.length?{footprints:s,selectionState:r}:null}FootprintPolygonMatches(e,t){if(e===t)return!0;const i=e.convexPolygons,r=t.convexPolygons;if(i!==r||i!==r)return!1;if(e.details.length!==t.details.length)return!1;for(let i=0;i<e.details.length;i++)if(!Object.is(e.details[i],t.details[i]))return!1;return!0}findFootprintPolygonIndex(e){const t=this.footprintPolygons.indexOf(e);return t>=0?t:this.footprintPolygons.findIndex(t=>this.FootprintPolygonMatches(t,e))}extHighlightFootprint(e,t){const i=this.findFootprintPolygonIndex(e);if(i<0)return;const r=i*u.ELEM_SIZE;if(t)this.hoveredIndexes.includes(i)||this.hoveredIndexes.push(i);else{if(r+4>=this.vertexCataloguePosition.length)return;const e=this.hoveredIndexes.indexOf(i);e>=0&&this.hoveredIndexes.splice(e,1)}}extAddPolygons2Selected(e){this._bufferInitialised||this.initBuffer();const t=this.findFootprintPolygonIndex(e);if(t<0)return;const i=t*u.ELEM_SIZE;if(this.selectedIndexes.includes(t)){if(i+4>=this.vertexCataloguePosition.length)return;const e=this.selectedIndexes.indexOf(t);e>=0&&this.selectedIndexes.splice(e,1)}else this.selectedIndexes.push(t);this.refreshSelectedFootprints()}initHoveringBuffer(){if(!this._webgl)return;if(0==this._hoveredFootprints.length)return;let e=this._hoveredFootprints.length,t=e-1;for(let i=0;i<e;i++)t+=this._hoveredFootprints[i].polygons.length-1;this.hoveredElementIndexes=new Uint32Array(this.totHoveredPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this.hoveredVertexPosition=new Float32Array(3*this.totHoveredPoints);let r=0,s=0;this.nHoveredPrimitiveFlags=0;for(let t=0;t<e;t++){let e=this._hoveredFootprints[t].polygons;t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.hoveredElementIndexes[s]=i,this.nHoveredPrimitiveFlags+=1,s+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.hoveredVertexPosition[r]=1*t.x,this.hoveredVertexPosition[r+1]=1*t.y,this.hoveredVertexPosition[r+2]=1*t.z,this.hoveredElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}initSelectionBuffer(){if(!this._webgl)return;if(0==this._selectedFootprints.length)return;const e=this._selectedFootprints.length;let t=e-1;for(let i=0;i<e;i++)t+=this._selectedFootprints[i].polygons.length-1;this.selectedElementIndexes=new Uint32Array(this.totSelectedPoints+t);const i=4294967295;this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this.selectedVertexPosition=new Float32Array(3*this.totSelectedPoints);let r=0,s=0;this.nSlectedPrimitiveFlags=0;for(let t=0;t<e;t++){const e=this._selectedFootprints[t].polygons;t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);for(let t=0;t<e.length;t++){t>0&&(this.selectedElementIndexes[s]=i,this.nSlectedPrimitiveFlags+=1,s+=1);const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];this.selectedVertexPosition[r]=1*t.x,this.selectedVertexPosition[r+1]=1*t.y,this.selectedVertexPosition[r+2]=1*t.z,this.selectedElementIndexes[s]=Math.floor(r/3),s+=1,r+=3}}}}changeColor(e){this._shapeColor=e}draw(e,t,i,r){if(!this.isVisible)return;if(!this._ready)return;if(!i)return;if(this._bufferInitialised||this.initBuffer(),!this._webgl)return;if(this._footprintShaderProgram.enableShaders(r,e,i),null!=t&&t.xyz!=this.oldMouseCoords&&this.checkSelection(t),this._hoveredFootprints.length>0){const e=(0,o.colorHex2RGB)("#00FF00"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.hoveredVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.hoveredVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.hoveredElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.hoveredVertexPosition.length/3+this.nHoveredPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}if(this._selectedFootprints.length>0){const e=(0,o.colorHex2RGB)("#ECB462"),t=1;this._webgl.uniform4f(this._footprintShaderProgram.locations.color,e[0],e[1],e[2],t),this._webgl.uniform1f(this._footprintShaderProgram.locations.pointSize,14),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.selectedVertexPositionBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,this.selectedVertexPosition,this._webgl.STATIC_DRAW),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedIndexBuffer),this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER,this.selectedElementIndexes,this._webgl.STATIC_DRAW),this._webgl.drawElements(this._webgl.LINE_LOOP,this.selectedVertexPosition.length/3+this.nSlectedPrimitiveFlags,this._webgl.UNSIGNED_INT,0)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this.vertexCataloguePositionBuffer),this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position,u.ELEM_SIZE,this._webgl.FLOAT,!1,u.BYTES_X_ELEM*u.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);const s=[...(0,o.colorHex2RGB)(this._shapeColor),1];this._webgl.uniform4f(this._footprintShaderProgram.locations.color,...s),this._webgl.drawElements(this._webgl.LINE_LOOP,this.indexes.length,this._webgl.UNSIGNED_INT,0),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null),this.oldMouseCoords=t.xyz}}t.FootprintSetGL=u},9839(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EquatorialGrid=void 0;const s=i(3890),o=i(229),a=i(7930),n=r(i(4707)),l=i(6553),h=i(8145),c=i(8083),u=r(i(5361)),d=i(4595),g=i(4735);class _ extends g.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;showGrid=!1;_shaderProgram;_vertexShader;_fragmentShader;defaultColor="#41d421";gridText;_attribLocations={position:0,selected:1,pointSize:2,color:3};_phiVertexPositionBuffer;_thetaVertexPositionBuffer;_fov;_phiStep=0;_phiStepRad=0;_thetaStep=0;_thetaStepRad=0;_phiArray=[];_thetaArray=[];_bufferKey="";_dec4Labels=new Map;_ra4Labels=new Map;_healpixGrid;constructor(e,t,i){super(d.HealpixGrid.RADIUS,d.HealpixGrid.INITIAL_POSITION,d.HealpixGrid.INITIAL_PhiRad,d.HealpixGrid.INITIAL_ThetaRad,"equatorial-grid",e),this._healpixGrid=t,this.gridText=new u.default("equatorial",i)}init(e){this._fov=e,this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders(),this._phiVertexPositionBuffer=super.webgl.createBuffer(),this._thetaVertexPositionBuffer=super.webgl.createBuffer(),this.initBuffers(this._fov)}initShaders(){const e=n.default.healpixGridFS();if(this._fragmentShader=super.webgl.createShader(super.webgl.FRAGMENT_SHADER),super.webgl.shaderSource(this._fragmentShader,e),super.webgl.compileShader(this._fragmentShader),!super.webgl.getShaderParameter(this._fragmentShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(e),void alert(e)}const t=n.default.healpixGridVS();if(this._vertexShader=super.webgl.createShader(super.webgl.VERTEX_SHADER),super.webgl.shaderSource(this._vertexShader,t),super.webgl.compileShader(this._vertexShader),!super.webgl.getShaderParameter(this._vertexShader,super.webgl.COMPILE_STATUS)){const e=super.webgl.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(e),void alert(e)}super.webgl.attachShader(this._shaderProgram,this._vertexShader),super.webgl.attachShader(this._shaderProgram,this._fragmentShader),super.webgl.linkProgram(this._shaderProgram),super.webgl.getProgramParameter(this._shaderProgram,super.webgl.LINK_STATUS)||alert("Could not initialise shaders"),super.webgl.useProgram(this._shaderProgram)}initBuffers(e,t=!1){const i=o.fovHelper.getRADegSteps(e,t),r=i.raStep,s=i.decStep;this._phiStep=r,this._phiStepRad=(0,a.degToRad)(r),this._thetaStep=s,this._thetaStepRad=(0,a.degToRad)(s),this._ra4Labels=new Map,this._dec4Labels=new Map,this._phiArray=[],this._thetaArray=[];for(let e=s;e<180;e+=s){const t=new Float32Array(360/r*3),i=(0,a.degToRad)(e);for(let e=0;e<360;e+=r){const s=(0,a.degToRad)(e),o=1*Math.sin(i)*Math.cos(s),n=1*Math.sin(i)*Math.sin(s),l=1*Math.cos(i),h=Math.floor(e/r);t[3*h+0]=o,t[3*h+1]=n,t[3*h+2]=l,this._dec4Labels.has(e)||this._dec4Labels.set(e,[]),this._dec4Labels.get(e).push([o,n,l])}this._phiArray.push(t)}for(let e=0;e<360;e+=r){const t=new Float32Array(360/s*3),i=(0,a.degToRad)(e);for(let e=0;e<360;e+=s){const r=(0,a.degToRad)(e),o=1*Math.sin(r)*Math.cos(i),n=1*Math.sin(r)*Math.sin(i),l=1*Math.cos(r),h=Math.floor(e/s);t[3*h+0]=o,t[3*h+1]=n,t[3*h+2]=l;const c=90-e;this._ra4Labels.has(c)||this._ra4Labels.set(c,[]),this._ra4Labels.get(c).push([o,n,l])}this._thetaArray.push(t)}}refresh(e,t=!1){const i=o.fovHelper.getRADegSteps(e,t),r=`${t?"coarse":"settled"}:${i.raStep}:${i.decStep}`;this._bufferKey!==r&&(this._fov=e,this._bufferKey=r,this.initBuffers(this._fov,t))}vectorDistance(e,t){const i=e.x-t.x,r=e.y-t.y,s=e.z-t.z;return Math.sqrt(i*i+r*r+s*s)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const o=s.mat4.create();s.mat4.multiply(o,i,e);const n=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),l=r.getUniformLocation(this._shaderProgram,"uPMatrix"),h=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),n&&r.uniformMatrix4fv(n,!1,o),l&&r.uniformMatrix4fv(l,!1,t),h){const e=(0,a.colorHex2RGB)(this.defaultColor);r.uniform4f(h,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}draw(e){const t=e.fovDeg;if(!t)return;const i=super.webgl,r=this.getModelMatrix(),o=e.camera;if(!o)return;const n=o.getCameraMatrix(),u=e.pMatrix;if(!u)return;if(!n)return;if(0===this._thetaArray.length)return;if(this.refresh(t,!!e.cameraMoving),!this.showGrid)return void this.gridText.resetDivSets();this.enableShader(r,u,n);for(let e=0;e<this._phiArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._phiVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._phiArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._phiStep);for(let e=0;e<this._thetaArray.length;e++)super.webgl.bindBuffer(super.webgl.ARRAY_BUFFER,this._thetaVertexPositionBuffer),super.webgl.bufferData(super.webgl.ARRAY_BUFFER,this._thetaArray[e],super.webgl.STATIC_DRAW),super.webgl.vertexAttribPointer(this._attribLocations.position,3,super.webgl.FLOAT,!1,0,0),super.webgl.enableVertexAttribArray(this._attribLocations.position),super.webgl.drawArrays(super.webgl.LINE_LOOP,0,360/this._thetaStep);const d=c.FoVUtils.getCenterJ2000(i.canvas,this._healpixGrid,this._webgl,o,u),g=s.mat4.create();s.mat4.multiply(g,n,r);const _=s.mat4.create();s.mat4.multiply(_,u,g);for(const[e,t]of this._dec4Labels.entries())if(Math.abs(e-d.raDeg)<=this._phiStep)for(let e=0;e<t.length;e++){const[i,r,o]=t[e],a=[i,r,o,1],n=new l.Point({x:i,y:r,z:o},h.CoordsType.CARTESIAN).decDeg;if(Math.abs(n-d.decDeg)<60){const e=s.vec4.create();s.vec4.transformMat4(e,a,_),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(n.toFixed(2),i,r,"dec")}}for(const[e,t]of this._ra4Labels.entries())if(Math.abs(e-d.decDeg)<=this._thetaStep)for(let e=0;e<t.length;e++){const[i,r,o]=t[e],n=[i,r,o,1],c=new l.Point({x:i,y:r,z:o},h.CoordsType.CARTESIAN),u=this.vectorDistance(c,d),g=c.raDeg;if(u<(0,a.degToRad)(50)){const e=s.vec4.create();s.vec4.transformMat4(e,n,_),e[0]/=e[3],e[1]/=e[3];const t=super.webgl.canvas.getBoundingClientRect(),i=t.left+(.5*e[0]+.5)*t.width,r=t.top+(-.5*e[1]+.5)*t.height;this.gridText.addEqDivSet(g.toFixed(2),i,r,"ra")}}this.gridText.resetDivSets(),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null)}}t.EquatorialGrid=_},5361(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{layer;state;containers;constructor(e="equatorial",t){this.layer=e,this.containers=t,this.state={container:this.resolveContainer(e),divSets:[],divSetNdx:0}}initHtml(){this.refreshContainer(this.layer,this.state)}resetDivSets(e=this.layer){const t=e===this.layer?this.state:{container:this.resolveContainer(e),divSets:[],divSetNdx:0};for(this.refreshContainer(e,t);t.divSetNdx<t.divSets.length;++t.divSetNdx)t.divSets[t.divSetNdx].style.display="none";t.divSetNdx=0}addHPXDivSet(e,t,i){this.addLabel("healpix",e,t+25,i,"hpx")}addEqDivSet(e,t,i,r){this.addLabel("equatorial",e,"ra"===r?t+25:t,"ra"===r?i:i+25,r)}addLonLatDivSet(e,t,i,r){this.addLabel("lonlat",e,"lon"===r?t+25:t,"lon"===r?i:i+25,r)}addLabel(e,t,i,r,s){const o=e===this.layer?this.state:{container:this.resolveContainer(e),divSets:[],divSetNdx:0};if(this.refreshContainer(e,o),!o.container)return;let a=o.divSets[o.divSetNdx++];if(!a){const e=document.createElement("div"),t=document.createTextNode("");e.appendChild(t),o.container.appendChild(e),a={div:e,textNode:t,style:e.style},o.divSets.push(a)}a.div.className=this.classNameForKind(s),a.style.display="block",a.style.position="absolute",a.style.zIndex="2",a.style.pointerEvents="none",a.style.font='12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',a.style.textShadow="0 1px 2px rgba(0, 0, 0, 0.7)",a.style.color=this.colorForKind(s);const n=o.container.getBoundingClientRect();a.style.left=`${Math.floor(i-n.left)}px`,a.style.top=`${Math.floor(r-n.top)}px`,a.textNode.nodeValue=t}colorForKind(e){switch(e){case"dec":return"#3fd35f";case"lat":return"#f6d35b";case"lon":return"#40c8ff";default:return"#5b7cff"}}classNameForKind(e){switch(e){case"dec":return"floating-div-dec";case"lat":return"floating-div-lat";case"lon":return"floating-div-lon";default:return"floating-div-ra"}}resolveContainer(e){if("healpix"===e){const e=this.containers?.resolveHealpix?.();return e||(this.containers?.healpix?this.containers.healpix:document.querySelector("#gridhpx"))}const t=this.containers?.resolveCoords?.();return t||(this.containers?.coords?this.containers.coords:document.querySelector("#gridcoords"))}refreshContainer(e,t){const i=this.resolveContainer(e);if(i!==t.container){for(const e of t.divSets)e.div.remove();t.container=i,t.divSets=[],t.divSetNdx=0}}}},4595(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HealpixGrid=void 0;const s=i(4735),o=r(i(4382)),a=i(3890),n=i(229),l=i(8083),h=i(5803),c=i(8145),u=i(6553),d=r(i(4707)),g=r(i(2930)),_=r(i(5361)),p=i(7930),f=i(2056),m=i(2919);class x extends s.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_visibleorder=0;showGrid=!1;_shaderProgram;fragmentShader;vertexShader;defaultColor="#ec0acaff";gridText;_attribLocations={position:0,selected:1,pointSize:2,color:3};_nPrimitiveFlags=0;_vertexCataloguePositionBuffer;_indexBuffer;_vertexCataloguePosition=new Float32Array(0);_indexes=new Uint32Array(0);_fovObj;static INITIAL_FOV=180;static RADIUS=1;static INITIAL_POSITION=[0,0,0];static INITIAL_PhiRad=0;static INITIAL_ThetaRad=0;_visibleTilesManager;constructor(e,t){super(x.RADIUS,x.INITIAL_POSITION,x.INITIAL_PhiRad,x.INITIAL_ThetaRad,"healpix-grid",e),this.gridText=new _.default("healpix",t),this.init(),this._visibleTilesManager=new f.VisibleTilesManager(this._webgl,super.hipsShaderProgram,this),this._visibleTilesManager.init(m.bootSetup.insideSphere)}init(){console.log("HealpixGridSingleton.init()"),this.initGL(super.webgl),this._shaderProgram=super.webgl.createProgram(),this.initShaders();const e=n.fovHelper.getHiPSNorder(x.INITIAL_FOV);this._visibleorder=e,this._nPrimitiveFlags=0,this._vertexCataloguePositionBuffer=super.webgl.createBuffer(),this._indexBuffer=super.webgl.createBuffer(),this._vertexCataloguePosition=new Float32Array(0),this._fovObj=new h.SphereFoV(super.webgl)}get fovObj(){return this._fovObj}get RADIUS(){return x.RADIUS}get INITIAL_POSITION(){return x.INITIAL_POSITION}get INITIAL_PhiRad(){return x.INITIAL_PhiRad}get INITIAL_ThetaRad(){return x.INITIAL_ThetaRad}refreshFoV(e,t){return this._fovObj.getFoV(o.default.insideSphere,this,e,t)}getFoV(){return this._fovObj}getMinFoV(){return this._fovObj.minFoV}initShaders(){const e=super.webgl,t=d.default.healpixGridFS();if(this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this.fragmentShader,t),e.compileShader(this.fragmentShader),!e.getShaderParameter(this.fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this.fragmentShader)||"Fragment shader compile error");const i=d.default.healpixGridVS();this.vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this.vertexShader,i),e.compileShader(this.vertexShader),e.getShaderParameter(this.vertexShader,e.COMPILE_STATUS)?(e.attachShader(this._shaderProgram,this.vertexShader),e.attachShader(this._shaderProgram,this.fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)):alert(e.getShaderInfoLog(this.vertexShader)||"Vertex shader compile error")}initBuffers(e,t){this._nPrimitiveFlags=0;const i=o.default.getHealpix(t),r=o.default.getHealpix(t+1),s=o.default.getHealpix(t+2);let a=0,n=0;this._indexes=new Uint32Array(17*e.length),this._vertexCataloguePosition=new Float32Array(48*e.length);for(let t=0;t<e.length;t++){const o=i.getBoundaries(e[t]),l=e[t]<<2,h=l+1,c=l+2,u=l+3,d=r.getBoundaries(l),g=r.getBoundaries(u),_=e=>{this._vertexCataloguePosition[a]=1*e.x,this._vertexCataloguePosition[a+1]=1*e.y,this._vertexCataloguePosition[a+2]=1*e.z,this._indexes[n]=Math.floor(a/3),n+=1,a+=3};_(o[0]);let p=(u<<2)+3,f=s.getBoundaries(p);_(f[1]),_(g[1]);let m=(c<<2)+2;f=s.getBoundaries(m),_(f[0]),_(o[1]),_(f[2]),_(d[1]);let x=l<<2;f=s.getBoundaries(x),_(f[1]),_(o[2]),_(f[3]),_(d[3]);let b=(h<<2)+1;f=s.getBoundaries(b),_(f[2]),_(o[3]),_(f[0]),_(g[3]),f=s.getBoundaries(p),_(f[3]),this._indexes[n]=4294967295,this._nPrimitiveFlags+=1,n+=1}}refresh(e,t){this.refreshFoV(e,t);const i=this.getMinFoV();this._visibleorder=n.fovHelper.getHiPSNorder(i,this._visibleorder)}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const s=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),o=r.getUniformLocation(this._shaderProgram,"uPMatrix"),n=super.webgl.getUniformLocation(this._shaderProgram,"u_fragcolor");this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition");let l=a.mat4.create();if(l=a.mat4.multiply(l,i,e),s&&r.uniformMatrix4fv(s,!1,l),o&&r.uniformMatrix4fv(o,!1,t),n){const e=(0,p.colorHex2RGB)(this.defaultColor);r.uniform4f(n,e[0],e[1],e[2],1)}}isVisible(){return this.showGrid}toggleShowGrid(){this.showGrid=!this.showGrid}get visibleTilesManager(){return this._visibleTilesManager}draw(e){const t=super.webgl,i=this.getModelMatrix(),r=e.camera;if(!r)return;const s=r.getCameraMatrix(),h=e.pMatrix;if(!h)return;const d=e.fovDeg??this.getMinFoV(),_=Number.isFinite(d)&&d>0?d:1e-6;if(this._visibleorder=n.fovHelper.getHiPSNorder(_,this._visibleorder),!this.showGrid)return void this.gridText.resetDivSets();const p=this._visibleTilesManager.visibleTilesByOrder,f=p.pixels,m=p.order;this.initBuffers(f,m),this.enableShader(i,h,s),t.bindBuffer(t.ARRAY_BUFFER,this._vertexCataloguePositionBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertexCataloguePosition,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,x.ELEM_SIZE,t.FLOAT,!1,x.BYTES_X_ELEM*x.ELEM_SIZE,0),t.enableVertexAttribArray(this._attribLocations.position),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this._indexes,t.STATIC_DRAW),t.drawElements(t.LINE_LOOP,this._vertexCataloguePosition.length/3+this._nPrimitiveFlags,t.UNSIGNED_INT,0),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);let b=a.mat4.create();b=a.mat4.multiply(b,s,i);let S=a.mat4.create();S=a.mat4.multiply(S,h,b);const v=l.FoVUtils.getCenterJ2000(t.canvas,this,this._webgl,r,h),M=this.getMinFoV()*Math.PI/180/2;for(let e=0;e<f.length;e++){const i=o.default.getHealpix(this._visibleorder).pix2vec(f[e]),r=new u.Point({x:i.x,y:i.y,z:i.z},c.CoordsType.CARTESIAN);if(g.default.orthodromicDistance(v,r)<M){const r=[i.x,i.y,i.z,1],s=a.vec4.create();a.vec4.transformMat4(s,r,S),s[0]/=s[3],s[1]/=s[3];const o=t.canvas.getBoundingClientRect(),n=o.left+(.5*s[0]+.5)*o.width,l=o.top+(-.5*s[1]+.5)*o.height;this.gridText.addHPXDivSet(this._visibleorder+"/"+f[e],n,l)}}this.gridText.resetDivSets(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}get visibleorder(){return this._visibleorder}}t.HealpixGrid=x},8124(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LatLonGrid=void 0;const s=i(3890),o=i(4735),a=i(8284),n=r(i(4707)),l=i(7930),h=i(5803),c=r(i(4382)),u=r(i(5361));class d extends o.AbstractSkyEntity{static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_shaderProgram;_vertexShader;_fragmentShader;_attribLocations={position:0};_lonVertexPositionBuffer;_latVertexPositionBuffer;_lonStep=10;_latStep=10;_segmentStep=1;_fovObj;_fovDeg=180;_showGrid=!0;_lonArray=[];_latArray=[];_bufferKey="";defaultColor="#41d4d4";gridText;constructor(e,t,i,r,s,o,a){super(e,t,i,r,s,o),this.gridText=new u.default("lonlat",a),this._fovObj=new h.SphereFoV(o),this.init()}init(){this.initGL(super.webgl);const e=super.webgl;this._shaderProgram=e.createProgram(),this.initShaders(),this._lonVertexPositionBuffer=e.createBuffer(),this._latVertexPositionBuffer=e.createBuffer(),this.initBuffers(this._fovDeg)}initShaders(){const e=super.webgl,t=n.default.healpixGridFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._fragmentShader)||"Unknown fragment shader error";return console.error(t),void alert(t)}const i=n.default.healpixGridVS();if(this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),!e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(this._vertexShader)||"Unknown vertex shader error";return console.error(t),void alert(t)}e.attachShader(this._shaderProgram,this._vertexShader),e.attachShader(this._shaderProgram,this._fragmentShader),e.linkProgram(this._shaderProgram),e.getProgramParameter(this._shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this._shaderProgram)}initBuffers(e,t,i=!1){const r=a.xyzFovHelper.getLonLatSteps(e,i);this._lonStep=r.lonStep,this._latStep=r.latStep,this._segmentStep=Math.max(Math.min(this._lonStep,this._latStep),.25),this._lonArray=[],this._latArray=[];const s=t?{lon:this.normalizeLon(t.phi>180?t.phi-360:t.phi),lat:90-t.theta}:null,o=!!s&&!i&&e<2,n=o?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._lonStep):this.buildLonRange(0,180,this._lonStep),l=o?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._latStep):this.buildLatRange(0,90,this._latStep),h=o&&s?this.buildLatRange(s.lat,Math.max(4*e,3*this._latStep),this._segmentStep):this.buildLatRange(0,90,this._segmentStep),c=o&&s?this.buildLonRange(s.lon,Math.max(4*e,3*this._lonStep),this._segmentStep):this.buildLonRange(0,180,this._segmentStep);for(const e of n){const t=[];for(const i of h)t.push(...this.lonLatToCartesian(e,Math.min(i,90)));this._lonArray.push(new Float32Array(t))}for(const e of l){const t=[];if(!(e<=-90||e>=90)){for(const i of c)t.push(...this.lonLatToCartesian(Math.min(i,180),e));this._latArray.push(new Float32Array(t))}}}buildLonRange(e,t,i){const r=[],s=Math.floor((e-t)/i)*i,o=Math.ceil((e+t)/i)*i;for(let e=s;e<=o;e+=i)r.push(this.normalizeLon(e));return r}buildLatRange(e,t,i){const r=[],s=Math.max(-90,Math.floor((e-t)/i)*i),o=Math.min(90,Math.ceil((e+t)/i)*i);for(let e=s;e<=o;e+=i)r.push(e);return r}lonLatToCartesian(e,t){const i=(0,l.degToRad)(e),r=(0,l.degToRad)(t),s=Math.cos(r);return[s*Math.cos(i),s*Math.sin(i),Math.sin(r)]}refresh(e,t){const i=!!t.cameraMoving,r=a.xyzFovHelper.getLonLatSteps(e,i),s=t.centerSphericalDeg,o=!!s&&!i&&e<2,n=s?this.normalizeLon(s.phi>180?s.phi-360:s.phi):0,l=s?90-s.theta:0,h=o?`${this.roundToStep(n,Math.max(r.lonStep,e))}:${this.roundToStep(l,Math.max(r.latStep,e))}`:"global",c=`${i?"coarse":"settled"}:${r.lonStep}:${r.latStep}:${h}`;this._bufferKey!==c&&(this._fovDeg=e,this._bufferKey=c,this.initBuffers(this._fovDeg,t.centerSphericalDeg,i))}refreshFoV(e){return e.camera&&e.pMatrix?(this._fovObj.getFoV(c.default.insideSphere,this,e.camera,e.pMatrix),this.refresh(this._fovObj.minFoV,e),this._fovObj.minFoV):this._fovDeg}getMinFoVDeg(){return this._fovObj.minFoV}getFoV(){return this._fovObj}isVisible(){return this._showGrid}toggleShowGrid(){return this._showGrid=!this._showGrid,this._showGrid}setShowGrid(e){this._showGrid=e}enableShader(e,t,i){const r=super.webgl;r.useProgram(this._shaderProgram);const o=s.mat4.create();s.mat4.multiply(o,i,e);const a=r.getUniformLocation(this._shaderProgram,"uMVMatrix"),n=r.getUniformLocation(this._shaderProgram,"uPMatrix"),h=r.getUniformLocation(this._shaderProgram,"u_fragcolor");if(this._attribLocations.position=r.getAttribLocation(this._shaderProgram,"aCatPosition"),a&&r.uniformMatrix4fv(a,!1,o),n&&r.uniformMatrix4fv(n,!1,t),h){const e=(0,l.colorHex2RGB)(this.defaultColor);r.uniform4f(h,e[0],e[1],e[2],1)}}draw(e){if(!this._showGrid)return void this.gridText.resetDivSets();const t=super.webgl,i=e.camera;if(!i)return;const r=e.pMatrix;if(!r)return;this.refreshFoV(e);const s=i.getCameraMatrix();if(!s)return;const o=this.getModelMatrix();this.enableShader(o,r,s);for(const e of this._lonArray)t.bindBuffer(t.ARRAY_BUFFER,this._lonVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_STRIP,0,e.length/d.ELEM_SIZE);for(const e of this._latArray)t.bindBuffer(t.ARRAY_BUFFER,this._latVertexPositionBuffer),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.vertexAttribPointer(this._attribLocations.position,d.ELEM_SIZE,t.FLOAT,!1,0,0),t.enableVertexAttribArray(this._attribLocations.position),t.drawArrays(t.LINE_LOOP,0,e.length/d.ELEM_SIZE);this.drawLabels(e,o,r,s),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}drawLabels(e,t,i,r){const s=e.centerSphericalDeg;if(!s)return void this.gridText.resetDivSets();const o=this.normalizeLon(s.phi>180?s.phi-360:s.phi),a=90-s.theta,n=this.normalizeLon(this.roundToStep(o,this._lonStep)),l=Math.max(-90+this._latStep,Math.min(90-this._latStep,this.roundToStep(a,this._latStep))),h=this.lonLatToCartesian(n,Math.max(-80,Math.min(80,a))),c=this.lonLatToCartesian(o,l),u=this.projectPointToScreen(h,t,i,r);u&&this.gridText.addLonLatDivSet(`${n.toFixed(0)}° lon`,u.x,u.y,"lon");const d=this.projectPointToScreen(c,t,i,r);d&&this.gridText.addLonLatDivSet(`${l.toFixed(0)}° lat`,d.x,d.y,"lat"),this.gridText.resetDivSets()}projectPointToScreen(e,t,i,r){const o=s.mat4.create(),a=s.mat4.create();s.mat4.multiply(o,r,t),s.mat4.multiply(a,i,o);const n=s.vec4.fromValues(e[0],e[1],e[2],1);if(s.vec4.transformMat4(n,n,a),Math.abs(n[3])<1e-6)return null;if(n[0]/=n[3],n[1]/=n[3],n[0]<-1||n[0]>1||n[1]<-1||n[1]>1)return null;const l=super.webgl.canvas.getBoundingClientRect();return{x:l.left+(.5*n[0]+.5)*l.width,y:l.top+(-.5*n[1]+.5)*l.height}}roundToStep(e,t){return t<=0?e:Math.round(e/t)*t}normalizeLon(e){let t=e;for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}t.LatLonGrid=d},2368(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(1399);t.default=class{_ready=!1;_hips;_format;_baseurl;_isGalacticHips;_order=3;opacity=1;_hipsShaderIndex=0;_texture=null;_image;_texurl;_fitsTile;_textureLoaded=!1;_maxTiles=0;_numFacesXTile=0;_numFaces=0;vertexPosition;vertexPositionBuffer;vertexIndexBuffer;vidx=0;_webgl;_tileBuffer;_hipsShaderProgram;constructor(e,t,i,r){this._tileBuffer=i,this._hips=e,this._webgl=t,this._format=e.format,this._baseurl=e.baseURL,this._isGalacticHips=e.isGalacticHips,this._hipsShaderProgram=r,this.initImage()}initImage(){this._texurl=`${this._baseurl}/Norder3/Allsky.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.setAttribute("crossorigin","anonymous"),this._image.src=this._texurl}async loadFits(){try{this._fitsTile=await(0,o.loadFitsTile)(this._texurl),this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}catch(e){console.error(`[AllSky] Unable to load FITS atlas ${this._texurl}`,e)}}imageLoaded(){this.textureLoaded(),this.initModelBuffer(),this._textureLoaded=!0,this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;if(this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),e.bindTexture(e.TEXTURE_2D,this._texture),"fits"===this._format){const t=this._fitsTile;if(!t)throw new Error(`FITS AllSky data not loaded: ${this._texurl}`);e.texImage2D(e.TEXTURE_2D,0,e.R32F,t.width,t.height,0,e.RED,e.FLOAT,t.pixels),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.generateMipmap(e.TEXTURE_2D);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.isTexture(this._texture)||console.log("error in texture")}getFitsDataRange(){const e=this._hips.dataRange;if(void 0!==e.min&&void 0!==e.max&&Number.isFinite(e.min)&&Number.isFinite(e.max)&&e.max>e.min)return{min:e.min,max:e.max};const t=this._fitsTile;return t&&null!==t.dataMin&&null!==t.dataMax&&Number.isFinite(t.dataMin)&&Number.isFinite(t.dataMax)&&t.dataMax>t.dataMin?{min:t.dataMin,max:t.dataMax}:null}initModelBuffer(){const e=this._webgl,t=this._order+1,i=s.default.getHealpix(this._order);this._maxTiles=i.getNPix();const r=s.default.getHealpix(t);this._numFacesXTile=4,this._numFaces=this._numFacesXTile*this._maxTiles,this.vertexPosition=new Float32Array(20*this._numFaces);let o=0,a=0;this.vidx=0;for(let e=0;e<this._maxTiles;e++){const t=i.nest2xyf(e),s=t.ix<<1,n=2+(t.ix<<1),l=t.iy<<1,h=2+(t.iy<<1);this.setupPositionAndTexture4Quadrant(o,a,s,s+(n-s)/2,l,l+(h-l)/2,r,t,0,0),this.setupPositionAndTexture4Quadrant(o,a,s+(n-s)/2,n,l,l+(h-l)/2,r,t,0,1),this.setupPositionAndTexture4Quadrant(o,a,s,s+(n-s)/2,l+(h-l)/2,h,r,t,1,0),this.setupPositionAndTexture4Quadrant(o,a,s+(n-s)/2,n,l+(h-l)/2,h,r,t,1,1),o++,27===o&&(a++,o=0)}const n=new Uint16Array(6*this._numFaces);let l=0;for(let e=0;e<this._numFaces;e++)n[6*e]=l,n[6*e+1]=l+1,n[6*e+2]=l+3,n[6*e+3]=l+1,n[6*e+4]=l+2,n[6*e+5]=l+3,l+=4;this.vertexPositionBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexPositionBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexPosition,e.STATIC_DRAW),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW)}setupPositionAndTexture4Quadrant(e,t,i,r,s,o,a,n,l,h){let c=[];const u=2**(a.order-3),d=1/(27*u),g=1/(29*u),_=d/64,p=g/64,f=u*d*e+d*l,m=u*g*t+g*h;for(let e=i;e<r;e++)for(let t=s;t<o;t++)c=a.getPointsForXyfNoStep(e,t,n.face),this.vertexPosition[20*this.vidx]=c[0].x,this.vertexPosition[20*this.vidx+1]=c[0].y,this.vertexPosition[20*this.vidx+2]=c[0].z,this.vertexPosition[20*this.vidx+3]=d+f-_,this.vertexPosition[20*this.vidx+4]=1-(g+m)+p,this.vertexPosition[20*this.vidx+5]=c[1].x,this.vertexPosition[20*this.vidx+6]=c[1].y,this.vertexPosition[20*this.vidx+7]=c[1].z,this.vertexPosition[20*this.vidx+8]=d+f-_,this.vertexPosition[20*this.vidx+9]=1-m-p,this.vertexPosition[20*this.vidx+10]=c[2].x,this.vertexPosition[20*this.vidx+11]=c[2].y,this.vertexPosition[20*this.vidx+12]=c[2].z,this.vertexPosition[20*this.vidx+13]=f+_,this.vertexPosition[20*this.vidx+14]=1-m-p,this.vertexPosition[20*this.vidx+15]=c[3].x,this.vertexPosition[20*this.vidx+16]=c[3].y,this.vertexPosition[20*this.vidx+17]=c[3].z,this.vertexPosition[20*this.vidx+18]=f+_,this.vertexPosition[20*this.vidx+19]=1-(g+m)+p,this.vidx++}draw(e,t,i,r,s,o){if(!this._ready)return!1;let a=[];if(e>=this._order){const n=this.drawChildren(e,t,i,r,s,o);n&&(a=n)}const n=this._webgl;if(this._hipsShaderProgram.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return console.error(`[AllSky] No display range available for FITS atlas ${this._texurl}`),!1;this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max)}else this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!1);n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture);const l=this._hipsShaderProgram.locations.textureAlpha[this._hipsShaderIndex];l&&n.uniform1f(l,this.opacity),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12);for(let e=0;e<this._maxTiles;e++)a.includes(e)||n.drawElements(n.TRIANGLES,6*this._numFacesXTile,n.UNSIGNED_SHORT,12*e*this._numFacesXTile);return n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,o){const a=this._order;if(!t.has(a))return;const n=t.get(a),l=[];for(let h=0;h<n.length;h++){const c=n[h],u=this._isGalacticHips?this._tileBuffer.getGalTile(c,a,this._hips):this._tileBuffer.getTile(c,a,this._hips);u.draw(e,t,i,r,s,o,this._hipsShaderProgram),u.getReadyState()&&l.push(c)}return l}}},2885(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(229),a=i(1399);t.default=class{_hips;_tileno;_baseurl;_order;_ready=!1;_format;_isGalacticHips;opacity=1;_hipsShaderIndex=0;_pixels=[];_texture=null;_image;_texurl="";_fitsTile;vertexPosition;vertexPositionBuffer;vertexIndices;vertexIndexBuffer;_tileBuffer;_hipsShaderProgram;_webgl;constructor(e,t,i,r,s,o){this._hipsShaderProgram=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._webgl=o,this._format=i.format,this._baseurl=i.baseURL,this._isGalacticHips=i.isGalacticHips,this._order=t,this.initImage()}destroyIntervals(){}initImage(){const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}async loadFits(){try{this._fitsTile=await(0,a.loadFitsTile)(this._texurl),this.textureLoaded();const e=this._fitsTile;if(!e)throw new Error(`FITS tile data not loaded: ${this._texurl}`);const t=this._webgl;t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.bindTexture(t.TEXTURE_2D,this._texture),t.texImage2D(t.TEXTURE_2D,0,t.R32F,e.width,e.height,0,t.RED,t.FLOAT,e.pixels),this.initModelBuffer(),this._ready=!0}catch(e){console.error(`[AncestorTile] Unable to load FITS tile ${this._texurl}`,e)}}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{console.error("File not found? %s",this._texurl)},this._image.crossOrigin="anonymous",this._image.src=this._texurl}imageLoaded(){this.textureLoaded(),this.initModelBuffer();const e=this._webgl;e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this._image),this._ready=!0}textureLoaded(){this._hipsShaderProgram.enableProgram();const e=this._webgl;this._texture=e.createTexture(),e.activeTexture(e.TEXTURE0+this._hipsShaderIndex),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),e.bindTexture(e.TEXTURE_2D,this._texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),"fits"===this._format?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR)),e.isTexture(this._texture)||console.log("error in texture")}getFitsDataRange(){const e=this._hips.dataRange;if(void 0!==e.min&&void 0!==e.max&&Number.isFinite(e.min)&&Number.isFinite(e.max)&&e.max>e.min)return{min:e.min,max:e.max};const t=this._fitsTile;return t&&null!==t.dataMin&&null!==t.dataMax&&Number.isFinite(t.dataMin)&&Number.isFinite(t.dataMax)&&t.dataMax>t.dataMin?{min:t.dataMin,max:t.dataMax}:null}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=o.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,a=i.ix<<r,n=(i.ix<<r)+(1<<r),l=i.iy<<r,h=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this._pixels=[],this.setupPositionAndTexture4Quadrant(a,n/2,l,h/2,0,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,l,h/2,1,c,r,i),this.setupPositionAndTexture4Quadrant(a,n/2,h/2,h,2,c,r,i),this.setupPositionAndTexture4Quadrant(n/2,n,h/2,h,3,c,r,i);const u=this.vertexPosition[0].length/20;this.vertexIndices=this.computeVertexIndices(u),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint16Array(6*e);let i=0;for(let r=0;r<e;r++)t[6*r]=i,t[6*r+1]=i+1,t[6*r+2]=i+2,t[6*r+3]=i+2,t[6*r+4]=i+3,t[6*r+5]=i,i+=4;return t}setupPositionAndTexture4Quadrant(e,t,i,r,s,o,a,n){const l=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const h=1/(1<<a);let c=0;for(let l=e;l<t;l++)for(let e=i;e<r;e++){const t=o.xyf2nest(l,e,n.face);this._pixels.push(t);const i=o.getBoundaries(t),r=e-(n.iy<<a),u=l-(n.ix<<a);this.vertexPosition[s][20*c]=i[0].x,this.vertexPosition[s][20*c+1]=i[0].y,this.vertexPosition[s][20*c+2]=i[0].z,this.vertexPosition[s][20*c+3]=h+h*r,this.vertexPosition[s][20*c+4]=1-(h+h*u),this.vertexPosition[s][20*c+5]=i[1].x,this.vertexPosition[s][20*c+6]=i[1].y,this.vertexPosition[s][20*c+7]=i[1].z,this.vertexPosition[s][20*c+8]=h+h*r,this.vertexPosition[s][20*c+9]=1-h*u,this.vertexPosition[s][20*c+10]=i[2].x,this.vertexPosition[s][20*c+11]=i[2].y,this.vertexPosition[s][20*c+12]=i[2].z,this.vertexPosition[s][20*c+13]=h*r,this.vertexPosition[s][20*c+14]=1-h*u,this.vertexPosition[s][20*c+15]=i[3].x,this.vertexPosition[s][20*c+16]=i[3].y,this.vertexPosition[s][20*c+17]=i[3].z,this.vertexPosition[s][20*c+18]=h*r,this.vertexPosition[s][20*c+19]=1-(h+h*u),c++}this.vertexPositionBuffer[s]=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[s]),l.bufferData(l.ARRAY_BUFFER,this.vertexPosition[s],l.STATIC_DRAW)}draw(e,t,i,r,s,o){if(!this._ready)return!1;let a=new Set([0,1,2,3]);if(e>this._order){const n=this.drawChildren(e,t,i,r,s,o);n&&(a=n)}if(this._hipsShaderProgram.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return console.error(`[AncestorTile] No display range available for FITS tile ${this._texurl}`),!1;this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max)}else this._hipsShaderProgram.setTextureDataMode(this._hipsShaderIndex,!1);const n=this._webgl;n.enableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.enableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),n.activeTexture(n.TEXTURE0+this._hipsShaderIndex),n.bindTexture(n.TEXTURE_2D,this._texture);const l=this._hipsShaderProgram.locations.textureAlpha[this._hipsShaderIndex];l&&n.uniform1f(l,this.opacity),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const h=this.vertexIndices.length;return a.forEach(e=>{n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer[e]),n.vertexAttribPointer(this._hipsShaderProgram.locations.vertexPositionAttribute,3,n.FLOAT,!1,20,0),n.vertexAttribPointer(this._hipsShaderProgram.locations.textureCoordAttribute,2,n.FLOAT,!1,20,12),n.drawElements(n.TRIANGLES,h,n.UNSIGNED_SHORT,0)}),n.disableVertexAttribArray(this._hipsShaderProgram.locations.vertexPositionAttribute),n.disableVertexAttribArray(this._hipsShaderProgram.locations.textureCoordAttribute),!0}drawChildren(e,t,i,r,s,o){const a=new Set([0,1,2,3]),n=this._order+1;if(t.has(n)){for(let l=0;l<4;l++){const h=(this._tileno<<2)+l;if(t.get(n).includes(h)){const c=this._isGalacticHips?this._tileBuffer.getGalTile(h,n,this._hips):this._tileBuffer.getTile(h,n,this._hips);c.draw(e,t,i,r,s,o,this._hipsShaderProgram),c.getReadyState()&&a.delete(l)}}return a}}}},1399(e,t,i){"use strict";t.loadFitsTile=async function(e){const t=await r.FITSParser.loadFITSFile(e);if(!t?.primaryHDU)throw new Error(`Unable to load FITS tile: ${e}`);const i=t.primaryHDU;if(2!==i.naxis)throw new Error(`Expected a 2D FITS tile, got NAXIS=${i.naxis}: ${e}`);const[o,a]=i.shape;if(!Number.isInteger(o)||!Number.isInteger(a)||o<=0||a<=0)throw new Error(`Invalid FITS tile dimensions: ${e}`);const n=i.typedData;if(!n||n.length!==o*a)throw new Error(`Invalid FITS tile payload: ${e}`);if(n instanceof BigInt64Array)throw new Error(`BITPIX=64 FITS tiles are not supported for HiPS rendering: ${e}`);const l=s(i.header,r.FITSHeaderManager.BSCALE)??1,h=s(i.header,r.FITSHeaderManager.BZERO)??0,c=s(i.header,r.FITSHeaderManager.BLANK),u=s(i.header,r.FITSHeaderManager.DATAMIN),d=s(i.header,r.FITSHeaderManager.DATAMAX),g=new Float32Array(n.length);for(let e=0;e<n.length;e++){const t=n[e];!Number.isFinite(t)||null!==c&&t===c?g[e]=Number.NaN:g[e]=t*l+h}return{width:o,height:a,pixels:g,dataMin:u,dataMax:d}};const r=i(1677);function s(e,t){const i=e.findById(t);if(!i)return null;const r=Number(i.value);return Number.isFinite(r)?r:null}},229(e,t){"use strict";t.fovHelper=void 0;class i{static LEVEL_HYSTERESIS=.12;static HIPS_ORDER_MIN_FOV={0:179,1:90,2:30,3:20,4:6,5:3.2,6:1.6,7:.85,8:.42,9:.21,10:.12,11:.06,12:.015,13:0};getHiPSNorder(e,t){const r=this.getRawHiPSNorder(e);if(void 0===t||t===r)return r;if(r>t){const r=i.HIPS_ORDER_MIN_FOV[t];if(r>0&&e>r*(1-i.LEVEL_HYSTERESIS))return t}else{const s=i.HIPS_ORDER_MIN_FOV[r];if(s>0&&e<s*(1+i.LEVEL_HYSTERESIS))return t}return r}getRawHiPSNorder(e){return e>=179?0:e>=90?1:e>=30?2:e>=20?3:e>=6?4:e>=3.2?5:e>=1.6?6:e>=.85?7:e>=.42?8:e>=.21?9:e>=.12?10:e>=.06?11:e>=.015?12:13}getRADegSteps(e,t=!1){let i,r;return t&&e<.21||e>=179?(i=10,r=10):e>=25?(i=9,r=9):e>=12.5?(i=8,r=8):e>=6?(i=6,r=6):e>=3.2?(i=5,r=5):e>=1.6?(i=4,r=4):e>=.85?(i=3,r=3):e>=.42?(i=2,r=2):e>=.21?(i=1,r=1):e>=.12?(i=.5,r=.5):e>=.06?(i=.25,r=.25):(i=10,r=10),{raStep:i,decStep:r}}getRefOrder(e){switch(e){case 0:case 1:case 2:case 3:return e+6;case 4:case 5:case 6:case 7:return e+5;case 8:return e+4;default:return e+3}}}t.fovHelper=new i},3726(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPS=void 0;const s=i(4735),o=i(229),a=r(i(619)),n=r(i(2885)),l=r(i(2368));class h extends s.AbstractSkyEntity{_ancestorTiles;_allSkyTile;_descriptor;_format;_baseurl;_maxorder;_minorder;_visibleorder=3;_allSky=!0;samplerIdx=0;colorMapIdx=0;colorMap=a.default.native;_healpixGrid;get maxOrder(){return this._maxorder}get minOrder(){return this._minorder}get baseURL(){return this._baseurl}get format(){return this._format}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}constructor(e,t,i,r,s,a,n){super(e,t,i,r,s.surveyName,a,s.isGalactic),this._descriptor=s,this.initGL(a),this._healpixGrid=n,this._format=this.selectDefaultFormat(s.imgFormats),this._baseurl=s.url,this._maxorder=s.maxOrder,this._minorder=s.minOrder,this.isGalacticHips?this._healpixGrid.visibleTilesManager.tileBuffer.addGalHiPS(this):this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this),console.log("HiPS frame "+s.hipsFrame),console.log("HiPS minOrder "+s.minOrder),this.initShaders();let l=o.fovHelper.getHiPSNorder(180);this._visibleorder=Math.min(l,this._maxorder),this._ancestorTiles=[],this._allSkyTile=null,this._allSky=!0,this.initBaseTiles()}initBaseTiles(){if(this._ancestorTiles=[],this._allSkyTile=null,this._allSky)this._allSkyTile=new l.default(this,this._webgl,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram);else for(let e=0;e<12;e++)this._ancestorTiles.push(new n.default(e,0,this,this._healpixGrid.visibleTilesManager.tileBuffer,super.hipsShaderProgram,this._webgl))}getProperty(e){return this._descriptor.getProperty(e)}changeFormat(e){const t=e.toLowerCase();if(!this._descriptor.imgFormats.includes(t))throw new Error(`HiPS format "${e}" is not supported. Available formats: ${this._descriptor.imgFormats.join(", ")}`);if(t===this._format.toLowerCase())return;this._healpixGrid.visibleTilesManager.tileBuffer.invalidateHiPS(this),this._format=t,this.initBaseTiles()}get availableFormats(){return this._descriptor.imgFormats}changeColorMap(e){switch(console.log("HiPS.changeColorMap -> shaderProgram",super.hipsShaderProgram.shaderProgram),this.colorMap=e,e.name){case"grayscale":this.colorMapIdx=1,this.colorMap=a.default.grayscale,super.hipsShaderProgram.setGrayscaleShader();break;case"planck":this.colorMapIdx=2,this.colorMap=a.default.planck,super.hipsShaderProgram.setColorMapShader();break;case"cmb":this.colorMapIdx=3,this.colorMap=a.default.cmb,super.hipsShaderProgram.setColorMapShader();break;case"rainbow":this.colorMapIdx=4,this.colorMap=a.default.rainbow,super.hipsShaderProgram.setColorMapShader();break;case"eosb":this.colorMapIdx=5,this.colorMap=a.default.eosb,super.hipsShaderProgram.setColorMapShader();break;case"cubehelix":this.colorMapIdx=6,this.colorMap=a.default.cubehelix,super.hipsShaderProgram.setColorMapShader();break;case"hot":this.colorMapIdx=7,this.colorMap=a.default.hot,super.hipsShaderProgram.setColorMapShader();break;case"gray":this.colorMapIdx=8,this.colorMap=a.default.gray,super.hipsShaderProgram.setColorMapShader();break;case"native":this.colorMapIdx=0,this.colorMap=a.default.native,super.hipsShaderProgram.setNativeShader();break;default:this.colorMapIdx=9,this.colorMap=e,super.hipsShaderProgram.setColorMapShader()}}initShaders(){super.hipsShaderProgram.enableProgram()}selectDefaultFormat(e){if(e.includes("png"))return"png";if(e.includes("jpg"))return"jpg";if(e.includes("fits"))return"fits";if(e.length>0)return e[0];throw new Error("HiPS descriptor does not define a tile format")}get dataRange(){return this._descriptor.dataRange}getCurrentHealpixOrder(){return this._visibleorder}getDebugStats(){const e=this._healpixGrid.visibleTilesManager.tileBuffer,t=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder:this._healpixGrid.visibleTilesManager.visibleTilesByOrder;return{activeBaseLayer:"hips",hipsName:this._descriptor.surveyName,hipsUrl:this._baseurl,isGalactic:this.isGalacticHips,currentOrder:t.order,visibleTileCount:t.pixels.length,activeTileCount:e.activeTileCount,cachedTileCount:e.cachedTileCount,cacheSize:e.size,readyTileCount:e.readyTileCount,loadingTileCount:e.loadingTileCount}}refresh(e){const t=e.fovDeg??this._healpixGrid.getMinFoV(),i=Number.isFinite(t)&&t>0?t:1e-6;this._visibleorder=Math.min(o.fovHelper.getHiPSNorder(i,this._visibleorder),this._maxorder)}draw(e){const t=e.camera.getCameraMatrix();if(!t)return;const i=e.pMatrix;if(!i)return;this.refresh(e);const r=this.getModelMatrix();if(super.hipsShaderProgram.setRuntimeColorMap(this.colorMap),this._allSky&&this._allSkyTile)return void(this.isGalacticHips?this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.galAncestorsMap,i,t,r,this.colorMapIdx):this._allSkyTile.draw(this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,this._healpixGrid.visibleTilesManager.ancestorsMap,i,t,r,this.colorMapIdx));const s=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order:this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order,o=this.isGalacticHips?this._healpixGrid.visibleTilesManager.galAncestorsMap:this._healpixGrid.visibleTilesManager.ancestorsMap;this._ancestorTiles.forEach(e=>{e.draw(s,o,i,t,r,this.colorMapIdx)})}}t.HiPS=h},5087(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSDescriptor=void 0;t.HiPSDescriptor=class{_minOrder=3;_imgformats=[];_datarange={min:void 0,max:void 0};_maxOrder;_tilewidth;_hipsFrame;_hipsName="NONAME";_hipsurl;_emMin;_emMax;_isGalctic=!1;_propertiesRawText;_propertiesMap=new Map;constructor(e,t){this._hipsurl=t,this._propertiesRawText=e;const i=e.split(/\r\n|\n/);for(const e of i){const t=e.trim();if(!t||t.startsWith("#"))continue;const i=t.slice(0,t.indexOf("=")).trim(),r=this.getValue(t);if(i&&void 0!==r&&this._propertiesMap.set(i,r),t.startsWith("hips_tile_format")||t.startsWith("format")){const e=this.getValue(t)?.replace(/jpeg/gi,"jpg")??"";this._imgformats=e.split(/\s+/).filter(Boolean)}else if(t.startsWith("hips_data_range")){const e=this.getValue(t);if(e){const[t,i]=e.split(/\s+/);this._datarange.min=parseFloat(t),this._datarange.max=parseFloat(i)}}else if(t.startsWith("hips_tile_width")){const e=Number(this.getValue(t));this._tilewidth=Number.isFinite(e)?e:void 0}else if(t.startsWith("hips_order_min")){const e=Number(this.getValue(t));this._minOrder=Number.isFinite(e)?e:this._minOrder}else if(t.startsWith("hips_order")||t.startsWith("maxOrder")){const e=Number(this.getValue(t));this._maxOrder=Number.isFinite(e)?e:this._maxOrder}else if(t.startsWith("hips_frame")||t.startsWith("frame"))this._hipsFrame=this.getValue(t);else if(t.startsWith("obs_collection")||t.startsWith("label"))this._hipsName=this.getValue(t)??this._hipsName;else if(t.startsWith("em_min")){const e=Number(this.getValue(t));this._emMin=Number.isFinite(e)?e:void 0}else if(t.startsWith("em_max")){const e=Number(this.getValue(t));this._emMax=Number.isFinite(e)?e:void 0}}if(this._hipsName||console.warn(`[HiPSDescriptor] hipsName not defined in properties of ${this._hipsurl}. Defaulting to 'NONAME'.`),this._hipsFrame||(console.warn(`[HiPSDescriptor] hips_frame not defined in properties of ${this._hipsurl}. Defaulting to 'equatorial'.`),this._hipsFrame="equatorial"),this._isGalctic=this._hipsFrame.toLowerCase().includes("gal"),void 0===this._maxOrder||0===this._imgformats.length)throw new Error(`[HiPSDescriptor] Invalid properties for ${this._hipsurl}. maxOrder=${this._maxOrder}, imgFormats.length=${this._imgformats.length}`)}getValue(e){const t=e.indexOf("=");if(!(t<0))return e.slice(t+1).trim()}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}getProperty(e){return this._propertiesMap.get(e)}get surveyName(){return this._hipsName}get url(){return this._hipsurl}get maxOrder(){return this._maxOrder}get minOrder(){return this._minOrder}get imgFormats(){return this._imgformats}get hipsFrame(){return this._hipsFrame}get isGalactic(){return this._isGalctic}get emMin(){return this._emMin}get emMax(){return this._emMax}get tileWidth(){return this._tilewidth}get dataRange(){return this._datarange}}},8256(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4382)),o=i(229),a=i(1399);t.default=class{_hips;_tileno;_baseurl;_order;_format;_maxorder;_isGalacticHips;_ready=!1;_abort=!1;_image;_textureLoaded=!1;_texture;_texurl="";_hipsShaderIndex=0;_fitsTile;_cacheTime0;_inView=!0;_amIStillInFoV_requsetID;vertexPosition=[];vertexPositionBuffer=[];vertexIndices=new Uint16Array;vertexIndexBuffer;_tileBuffer;opacity=1;_webgl;_visibleTileManager;constructor(e,t,i,r,s,o){this._visibleTileManager=o,this._webgl=s,this._tileBuffer=r,this._hips=i,this._tileno=e,this._format=i.format,this._baseurl=i.baseURL,this._maxorder=i.maxOrder,this._isGalacticHips=i.isGalacticHips,this._order=t,this._amIStillInFoV_requsetID=window.setInterval(()=>{this.amIStillInFoV()},5e3),this.initImage()}destroyIntervals(){window.clearInterval(this._amIStillInFoV_requsetID)}getReadyState(){return this._ready}isLoading(){return!this._ready&&!this._abort}get cacheTime0(){return this._cacheTime0}resetCacheTime0(){this._cacheTime0=void 0}setCacheTime0(){this._cacheTime0=(new Date).getTime()}initImage(){if(this._order>this._maxorder)return this._ready=!1,this._abort=!0,this.destroyIntervals(),void console.warn(`[Tile] Skipping tile request above max order: requested order ${this._order}, max order ${this._maxorder}, url ${this._baseurl}`);const e=1e4*Math.floor(this._tileno/1e4);this._texurl=`${this._baseurl}/Norder${this._order}/Dir${e}/Npix${this._tileno}.${this._format}`,"fits"!==this._format?this.loadImage():this.loadFits()}loadImage(){this._image=new Image,this._image.onload=()=>this.imageLoaded(),this._image.onerror=()=>{this._ready=!1,this._abort=!0,this.destroyIntervals()},this._image.crossOrigin="anonymous",this._image.src=this._texurl}async loadFits(){try{this._fitsTile=await(0,a.loadFitsTile)(this._texurl),this._ready=!0}catch(e){console.error(`[Tile] Unable to load FITS tile ${this._texurl}`,e),this._ready=!1,this._abort=!0,this.destroyIntervals()}}imageLoaded(){this._ready=!0}textureLoaded(e){e.enableProgram();const t=this._webgl;if(this._texture=t.createTexture(),t.activeTexture(t.TEXTURE0+this._hipsShaderIndex),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,"fits"!==this._format),t.bindTexture(t.TEXTURE_2D,this._texture),"fits"===this._format){const e=this._fitsTile;if(!e)throw new Error(`FITS tile data not loaded: ${this._texurl}`);t.texImage2D(t.TEXTURE_2D,0,t.R32F,e.width,e.height,0,t.RED,t.FLOAT,e.pixels),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)}else t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this._image),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this.initModelBuffer(),this._textureLoaded=!0}initModelBuffer(){const e=this._webgl;this.vertexPosition=[],this.vertexPositionBuffer=[],this.vertexIndices=new Uint16Array;const t=o.fovHelper.getRefOrder(this._order),i=s.default.getHealpix(this._order).nest2xyf(this._tileno),r=t-this._order,a=i.ix<<r,n=(i.ix<<r)+(1<<r),l=i.iy<<r,h=(i.iy<<r)+(1<<r),c=s.default.getHealpix(t);this.setupPositionAndTexture4Quadrant2(a,a+(n-a)/2,l,l+(h-l)/2,0,c,r,i),this.setupPositionAndTexture4Quadrant2(a+(n-a)/2,n,l,l+(h-l)/2,1,c,r,i),this.setupPositionAndTexture4Quadrant2(a,a+(n-a)/2,l+(h-l)/2,h,2,c,r,i),this.setupPositionAndTexture4Quadrant2(a+(n-a)/2,n,l+(h-l)/2,h,3,c,r,i);const u=this.vertexPosition[0].length/20,d=this.computeVertexIndices(u);d.length>65535?this.vertexIndices=new Uint32Array(d):this.vertexIndices=new Uint16Array(d),this.vertexIndexBuffer=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.vertexIndices,e.STATIC_DRAW)}computeVertexIndices(e){const t=new Uint32Array(6*e);let i=0;for(let r=0;r<e;r++){const e=i;t[6*r]=e,t[6*r+1]=e+1,t[6*r+2]=e+2,t[6*r+3]=e+2,t[6*r+4]=e+3,t[6*r+5]=e,i+=4}return t}setupPositionAndTexture4Quadrant2(e,t,i,r,s,o,a,n){const l=this._webgl;this.vertexPosition[s]=new Float32Array(20*(t-e)*(r-i));const h=1/(1<<a);let c=0;for(let l=e;l<t;l++)for(let e=i;e<r;e++){const t=o.getPointsForXyfNoStep(l,e,n.face),i=e-(n.iy<<a),r=l-(n.ix<<a);this.vertexPosition[s][20*c]=t[0].x,this.vertexPosition[s][20*c+1]=t[0].y,this.vertexPosition[s][20*c+2]=t[0].z,this.vertexPosition[s][20*c+3]=h+h*i+0,this.vertexPosition[s][20*c+4]=1-(h+h*r)-0,this.vertexPosition[s][20*c+5]=t[1].x,this.vertexPosition[s][20*c+6]=t[1].y,this.vertexPosition[s][20*c+7]=t[1].z,this.vertexPosition[s][20*c+8]=h+h*i+0,this.vertexPosition[s][20*c+9]=1-h*r+0,this.vertexPosition[s][20*c+10]=t[2].x,this.vertexPosition[s][20*c+11]=t[2].y,this.vertexPosition[s][20*c+12]=t[2].z,this.vertexPosition[s][20*c+13]=h*i-0,this.vertexPosition[s][20*c+14]=1-h*r+0,this.vertexPosition[s][20*c+15]=t[3].x,this.vertexPosition[s][20*c+16]=t[3].y,this.vertexPosition[s][20*c+17]=t[3].z,this.vertexPosition[s][20*c+18]=h*i-0,this.vertexPosition[s][20*c+19]=1-(h+h*r)-0,c++}this.vertexPositionBuffer[s]=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[s]),l.bufferData(l.ARRAY_BUFFER,this.vertexPosition[s],l.STATIC_DRAW)}getFitsDataRange(){const e=this._hips.dataRange;if(void 0!==e.min&&void 0!==e.max&&Number.isFinite(e.min)&&Number.isFinite(e.max)&&e.max>e.min)return{min:e.min,max:e.max};const t=this._fitsTile;return t&&null!==t.dataMin&&null!==t.dataMax&&Number.isFinite(t.dataMin)&&Number.isFinite(t.dataMax)&&t.dataMax>t.dataMin?{min:t.dataMin,max:t.dataMax}:null}get inView(){return this._inView}moveToCache(){this._tileBuffer.moveTileToCache(this._tileno,this._order,this._hips),this._inView=!1,this.destroyIntervals()}amIStillInFoV(){this._textureLoaded&&(this._ready=!0),this._isGalacticHips?(this._visibleTileManager.galAncestorsMap.has(this._order)&&(this._visibleTileManager.galAncestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.galVisibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache())):(this._visibleTileManager.ancestorsMap.has(this._order)&&(this._visibleTileManager.ancestorsMap.get(this._order).includes(this._tileno)?this._inView=!0:this.moveToCache()),this._order==this._visibleTileManager.visibleOrder&&(this._visibleTileManager.visibleTilesByOrder.pixels.includes(this._tileno)?this._inView=!0:this.moveToCache()))}draw(e,t,i,r,s,o,a){if(!this._ready||this._abort)return;this._textureLoaded||this.textureLoaded(a);let n=new Set([0,1,2,3]);if(e>this._order&&this._order<this._maxorder){const l=this.drawChildren(e,t,i,r,s,o,a);l&&(n=l)}const l=this._webgl;if(a.enableShaders(i,r,s,o),"fits"===this._format){const e=this.getFitsDataRange();if(!e)return void console.error(`[Tile] No display range available for FITS tile ${this._texurl}`);a.setTextureDataMode(this._hipsShaderIndex,!0,e.min,e.max)}else a.setTextureDataMode(this._hipsShaderIndex,!1);const h=a.locations;l.enableVertexAttribArray(h.vertexPositionAttribute),l.enableVertexAttribArray(h.textureCoordAttribute),l.activeTexture(l.TEXTURE0+this._hipsShaderIndex),l.bindTexture(l.TEXTURE_2D,this._texture);const c=h.textureAlpha[this._hipsShaderIndex];c&&l.uniform1f(c,this.opacity),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);const u=this.vertexIndices.length,d=this.vertexIndices instanceof Uint32Array?l.UNSIGNED_INT:l.UNSIGNED_SHORT;n.forEach(e=>{l.bindBuffer(l.ARRAY_BUFFER,this.vertexPositionBuffer[e]),l.vertexAttribPointer(h.vertexPositionAttribute,3,l.FLOAT,!1,20,0),l.vertexAttribPointer(h.textureCoordAttribute,2,l.FLOAT,!1,20,12),l.drawElements(l.TRIANGLES,u,d,0)}),l.disableVertexAttribArray(h.vertexPositionAttribute),l.disableVertexAttribArray(h.textureCoordAttribute)}drawChildren(e,t,i,r,s,o,a){const n=new Set([0,1,2,3]),l=this._order+1;if(t.has(l)){for(let h=0;h<4;h++){const c=(this._tileno<<2)+h;if(t.get(l).includes(c)){const u=this._isGalacticHips?this._tileBuffer.getGalTile(c,l,this._hips):this._tileBuffer.getTile(c,l,this._hips);u.draw(e,t,i,r,s,o,a),u.getReadyState()&&n.delete(h)}}return n}}}},4006(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TileBuffer=void 0;const s=r(i(8256));t.TileBuffer=class{_tiles;_cachedTiles;_activeHiPS;_galTiles;_galCachedTiles;_galActiveHiPS;_cacheAliveMilliSeconds;_cleanerId;_webgl;_visibleTileManager;_hipsShaderProgram;constructor(e=1,t,i,r){this._hipsShaderProgram=i,this._visibleTileManager=r,this._webgl=t,this._tiles=new Map,this._cachedTiles=new Map,this._activeHiPS=new Map,this._galTiles=new Map,this._galCachedTiles=new Map,this._galActiveHiPS=new Map,this._cacheAliveMilliSeconds=60*e*1e3,this._cleanerId=window.setInterval(()=>{this.cacheCleaner()},1e4)}addHiPS(e){this._activeHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._activeHiPS.set(e,new Map)}addGalHiPS(e){this._galActiveHiPS.has(e)?console.error("HiPS already present in TileBuffer"):this._galActiveHiPS.set(e,new Map)}addTile(e,t){for(const i of this._activeHiPS.keys())e>i.maxOrder||this.getTile(t,e,i)}addGalTile(e,t){for(const i of this._galActiveHiPS.keys())e>i.maxOrder||this.getGalTile(t,e,i)}getTile(e,t,i){const r=this.key(t,e,i);if(!this._tiles.has(r))if(this._cachedTiles.has(r)){const e=this._cachedTiles.get(r);this._tiles.set(r,e),this._cachedTiles.delete(r),e.resetCacheTime0()}else{const o=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._tiles.set(r,o)}return this._tiles.get(r)}getGalTile(e,t,i){const r=this.key(t,e,i);if(!this._galTiles.has(r))if(this._galCachedTiles.has(r)){const e=this._galCachedTiles.get(r);this._galTiles.set(r,e),this._galCachedTiles.delete(r),e.resetCacheTime0()}else{const o=new s.default(e,t,i,this,this._webgl,this._visibleTileManager);this._galTiles.set(r,o)}return this._galTiles.get(r)}moveTileToCache(e,t,i){const r=this.key(t,e,i);if(this._tiles.has(r)){const e=this._tiles.get(r);e.setCacheTime0(),this._cachedTiles.set(r,e),this._tiles.delete(r)}if(this._galTiles.has(r)){const e=this._galTiles.get(r);e.setCacheTime0(),this._galCachedTiles.set(r,e),this._galTiles.delete(r)}}cacheCleaner(){const e=Date.now();for(const[t,i]of this._cachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._cachedTiles.delete(t))}for(const[t,i]of this._galCachedTiles){const r=i.cacheTime0;!i.inView&&void 0!==r&&e-r>this._cacheAliveMilliSeconds&&(i.destroyIntervals(),this._galCachedTiles.delete(t))}}key(e,t,i){return`${e}#${t}#${i.baseURL}#${i.format}`}removeHiPS(e){this.invalidateHiPS(e),this._activeHiPS.delete(e),this._galActiveHiPS.delete(e)}invalidateHiPS(e){const t=t=>t.includes(`#${e.baseURL}#`),i=e=>{for(const[i,r]of e)t(i)&&(r.destroyIntervals(),e.delete(i))};i(this._tiles),i(this._cachedTiles),i(this._galTiles),i(this._galCachedTiles)}dispose(){window.clearInterval(this._cleanerId)}get size(){return this._tiles.size+this._cachedTiles.size+this._galTiles.size+this._galCachedTiles.size}get activeTileCount(){return this._tiles.size+this._galTiles.size}get cachedTileCount(){return this._cachedTiles.size+this._galCachedTiles.size}get readyTileCount(){let e=0;for(const t of this._tiles.values())t.getReadyState()&&e++;for(const t of this._galTiles.values())t.getReadyState()&&e++;for(const t of this._cachedTiles.values())t.getReadyState()&&e++;for(const t of this._galCachedTiles.values())t.getReadyState()&&e++;return e}get loadingTileCount(){let e=0;for(const t of this._tiles.values())t.isLoading()&&e++;for(const t of this._galTiles.values())t.isLoading()&&e++;for(const t of this._cachedTiles.values())t.isLoading()&&e++;for(const t of this._galCachedTiles.values())t.isLoading()&&e++;return e}}},2056(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VisibleTilesManager=void 0;const s=r(i(4382)),o=i(4851),a=r(i(4639)),n=i(4006),l=i(3890),h=i(2919);t.VisibleTilesManager=class{_visibleTilesByOrder;_ancestorsMap;initialised;_galVisibleTilesByOrder;_galAncestorsMap;_galacticMatrixInverted;_galacticMatrix;insideSphere=h.bootSetup.insideSphere;_tileBuffer;_healpixGrid;_webgl;constructor(e,t,i){this._webgl=e,this._healpixGrid=i,this._visibleTilesByOrder={pixels:[],order:0},this._ancestorsMap=new Map,this.initialised=!1,this._galVisibleTilesByOrder={pixels:[],order:0},this._galAncestorsMap=new Map,this._galacticMatrixInverted=l.mat4.create(),this._galacticMatrix=l.mat4.create(),l.mat4.set(this._galacticMatrixInverted,-.054876,-.873437,-.483835,0,.494109,-.44483,.746982,-0,-.867666,-.198076,.455984,0,0,0,0,1),l.mat4.invert(this._galacticMatrix,this._galacticMatrixInverted),this._tileBuffer=new n.TileBuffer(1,e,t,this)}get healpixGrid(){return this._healpixGrid}get tileBuffer(){return this._tileBuffer}init(e){this.initialised=!0,this.insideSphere=e}getVisibleOrder(){return this._healpixGrid.visibleorder}computeVisiblePixels(e,t,i,r){if(!this.initialised)return;s.default.insideSphere&&e<3&&(e=3),this._ancestorsMap.set(e,[]),this._galAncestorsMap.set(e,[]);let n=[],h=[];if(0===e){const t=s.default.getHealpix(0).getNPix();for(let i=0;i<t;i++)n.push(i),this._ancestorsMap.get(e).push(i),h.push(i),this._galAncestorsMap.get(e).push(i)}else{const c=s.default.getHealpix(e),u=t.canvas.width,d=t.canvas.height;for(let t=0;t<=u;t+=u/30)for(let s=0;s<=d;s+=d/30){const u=a.default.getIntersectionPointWithSingleModel(t,s,this._healpixGrid,this._webgl,i,r);if(u.length>0){const t=l.vec4.create();l.vec4.transformMat4(t,[u[0],u[1],u[2],1],this._galacticMatrix);const i=new o.Pointing(new o.Vec3(t[0],t[1],t[2])),r=c.ang2pix(i),s=new o.Pointing(new o.Vec3(u[0],u[1],u[2])),a=c.ang2pix(s);n.includes(a)||(n.push(a),this._ancestorsMap.get(e).push(a),this._tileBuffer.addTile(e,a)),h.includes(r)||(h.push(r),this._galAncestorsMap.get(e).push(r),this._tileBuffer.addGalTile(e,r))}}}this._visibleTilesByOrder={pixels:n,order:e},this._galVisibleTilesByOrder={pixels:h,order:e};for(let t=1;t<e;t++){const i=e-t,r=this._ancestorsMap.get(i)??[];this._ancestorsMap.set(i,r);for(let e=0;e<n.length;e++){const s=n[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addTile(i,s))}}for(let t=1;t<e;t++){const i=e-t,r=this._galAncestorsMap.get(i)??[];this._galAncestorsMap.set(i,r);for(let e=0;e<h.length;e++){const s=h[e]>>2*t;r.includes(s)||(r.push(s),this._tileBuffer.addGalTile(i,s))}}}get visibleTilesByOrder(){return this._visibleTilesByOrder}get ancestorsMap(){return this._ancestorsMap}get galVisibleTilesByOrder(){return this._galVisibleTilesByOrder}get galAncestorsMap(){return this._galAncestorsMap}get visibleOrder(){return this._visibleTilesByOrder.order}}},6878(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPS=void 0;const r=i(4735),s=i(229),o=i(2257),a=i(8170);class n extends r.AbstractSkyEntity{_descriptor;_healpixGrid;_shaderProgram;_tiles=new Map;_currentOrder;_visibleTiles=[];_coverageTiles=[];constructor(e,t,i,r,s,a,n){super(e,t,i,r,s.name,a,!1),this._descriptor=s,this._healpixGrid=n,this.initGL(a),this._shaderProgram=new o.MeshHiPSShaderProgram(a),this._shaderProgram.enableProgram(),this._currentOrder=s.selectedOrder}get currentOrder(){return this._currentOrder}get maxOrder(){return this._descriptor.maxOrder}get minOrder(){return this._descriptor.minOrder}get baseURL(){return this._descriptor.baseUrl}get propertiesRawText(){return this._descriptor.propertiesRawText}get properties(){return this._descriptor.properties}getProperty(e){return this._descriptor.getProperty(e)}refreshOrder(e){if(this._descriptor.fixedOrder)return this._currentOrder=this._descriptor.selectedOrder,this._currentOrder;const t=Number.isFinite(e)&&e>0?e:this._healpixGrid.getMinFoV(),i=Number.isFinite(t)&&t>0?t:1e-6,r=s.fovHelper.getHiPSNorder(i,this._currentOrder);return this._currentOrder=Math.max(this._descriptor.minOrder,Math.min(this._descriptor.maxOrder,r)),this._currentOrder}draw(e){const t=e.camera.getCameraMatrix();if(!t||!e.pMatrix)return;this.refreshOrder(e.fovDeg),this._visibleTiles=this.resolveVisibleTiles(),this._coverageTiles=this.resolveCoverageTiles(this._visibleTiles),this.ensureTiles(this._coverageTiles),this.evictCached();const i=this._webgl,r=e.pMatrix,s=this.getModelMatrix(),o=i.isEnabled(i.CULL_FACE),a=i.isEnabled(i.DEPTH_TEST),n=i.getParameter(i.DEPTH_WRITEMASK),l=i.getParameter(i.DEPTH_FUNC);i.enable(i.DEPTH_TEST),i.depthMask(!0),i.depthFunc(i.LEQUAL),i.disable(i.CULL_FACE);const h=this.groupTilesByOrder(this._coverageTiles),c=Array.from(h.keys()).sort((e,t)=>e-t);for(const e of c)for(const i of h.get(e)??[])this._tiles.get(this.tileKey(i))?.draw(r,t,s,this._descriptor.color,this._descriptor.wireframe);o&&i.enable(i.CULL_FACE),a||i.disable(i.DEPTH_TEST),i.depthFunc(l),i.depthMask(n)}getDebugStats(){const e=Array.from(this._tiles.values());return{activeBaseLayer:"meships",meshHiPSName:this._descriptor.name,meshHiPSUrl:this._descriptor.baseUrl,currentOrder:this._currentOrder,visibleTileCount:this._visibleTiles.length,coverageTileCount:this._coverageTiles.length,cacheSize:this._tiles.size,readyTileCount:e.filter(e=>e.ready).length,loadingTileCount:e.filter(e=>e.loading).length,failedTileCount:e.filter(e=>e.failed).length}}resolveVisibleTiles(){const e=this._healpixGrid.visibleTilesManager,t=e?.visibleTilesByOrder,i=t?.order===this._currentOrder&&Array.isArray(t.pixels)?t.pixels:[];if(i.length>0)return i.map(e=>({order:this._currentOrder,ipix:e}));const r=12*4**this._currentOrder;return Array.from({length:r},(e,t)=>({order:this._currentOrder,ipix:t}))}resolveCoverageTiles(e){const t=new Map,i=e=>{e.order<this._descriptor.minOrder||e.order>this._descriptor.maxOrder||t.set(this.tileKey(e),e)};for(const t of e){i(t);for(let e=t.order-1;e>=this._descriptor.minOrder;e--){const r=2*(t.order-e);i({order:e,ipix:t.ipix>>r})}}const r=this._healpixGrid.visibleTilesManager,s=r?.ancestorsMap;if(s)for(const[e,t]of s)if(!(e<this._descriptor.minOrder||e>this._descriptor.maxOrder))for(const r of t)i({order:e,ipix:r});return Array.from(t.values())}groupTilesByOrder(e){const t=new Map;for(const i of e){const e=t.get(i.order)??[];e.push(i),t.set(i.order,e)}return t}ensureTiles(e){for(const t of e){const e=this.tileKey(t);this._tiles.has(e)||this._tiles.set(e,new a.MeshHiPSTile(t,this._descriptor.getTileUrl(t.order,t.ipix),this._webgl,this._shaderProgram))}}evictCached(){const e=this._descriptor.maxCachedTiles;if(this._tiles.size<=e)return;const t=new Set(this._coverageTiles.map(e=>this.tileKey(e))),i=Array.from(this._tiles.entries()).filter(([e])=>!t.has(e)).sort((e,t)=>e[1].lastUsedAt-t[1].lastUsedAt);for(;this._tiles.size>e&&i.length>0;){const[e,t]=i.shift();t.dispose(),this._tiles.delete(e)}}tileKey(e){return`${e.order}/${e.ipix}`}}t.MeshHiPS=n},847(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MeshHiPSDescriptor=void 0;t.MeshHiPSDescriptor=class{_name="MeshHiPS";_baseUrl;_minOrder=0;_maxOrder=0;_selectedOrder;_fixedOrder=!1;_maxCachedTiles=384;_color=[.32,.34,.36,1];_wireframe=!1;_propertiesRawText="";_propertiesMap=new Map;_meshRadius=null;constructor(e,t=""){if(this._baseUrl=this.normalizeBaseUrl(e.baseUrl),this._propertiesRawText=t,this.parseProperties(t),this._name=e.name??this._propertiesMap.get("obs_collection")??this._propertiesMap.get("label")??this._name,this._minOrder=e.minOrder??this.readNumber("hips_order_min",this._minOrder),this._maxOrder=e.maxOrder??this.readNumber("hips_order",this.readNumber("hips_order_max",this._maxOrder)),this._fixedOrder=void 0!==e.order,this._selectedOrder=e.order??this._minOrder,this._maxCachedTiles=e.maxCachedTiles??this._maxCachedTiles,e.color)this._color=e.color;else if(this._propertiesMap.has("mesh_color")){const e=(this._propertiesMap.get("mesh_color")||"").split(/[,\s]+/).map(e=>Number(e)).filter(Number.isFinite);if(e.length>=3){let[t,i,r,s]=e;(t>1||i>1||r>1)&&(t/=255,i/=255,r/=255),Number.isFinite(s)||(s=1),this._color=[t,i,r,s]}}else this._color=this._color;if(this._wireframe=e.wireframe??this._wireframe,this._selectedOrder=this.clampOrder(this._selectedOrder),Number.isFinite(e.meshRadius))this._meshRadius=e.meshRadius;else{const e=this.readNumber("mesh_radius",NaN);if(!Number.isFinite(e))throw new Error('Missing mandatory property "mesh_radius" in MeshHiPS properties');this._meshRadius=e}}get name(){return this._name}get baseUrl(){return this._baseUrl}get minOrder(){return this._minOrder}get maxOrder(){return this._maxOrder}get selectedOrder(){return this._selectedOrder}get fixedOrder(){return this._fixedOrder}get maxCachedTiles(){return this._maxCachedTiles}get color(){return this._color}get wireframe(){return this._wireframe}get propertiesRawText(){return this._propertiesRawText}get properties(){return new Map(this._propertiesMap)}get meshRadius(){return this._meshRadius}getProperty(e){return this._propertiesMap.get(e)}getTileUrl(e,t){const i=1e4*Math.floor(t/1e4);return`${this._baseUrl}Norder${e}/Dir${i}/Npix${t}.obj`}parseProperties(e){const t=e.split(/\r\n|\n/);for(const e of t){const t=e.trim();if(!t||t.startsWith("#"))continue;const i=t.indexOf("=");i<0||this._propertiesMap.set(t.slice(0,i).trim(),t.slice(i+1).trim())}}readNumber(e,t){const i=Number(this._propertiesMap.get(e));return Number.isFinite(i)?i:t}clampOrder(e){return Math.max(this._minOrder,Math.min(this._maxOrder,e))}normalizeBaseUrl(e){return e.endsWith("/")?e:`${e}/`}}},8170(e,t,i){"use strict";t.MeshHiPSTile=void 0;const r=i(4322);t.MeshHiPSTile=class{coord;_url;_webgl;_shaderProgram;_gpuMesh=null;_ready=!1;_loading=!1;_failed=!1;_lastUsedAt=0;_createdAt=Date.now();constructor(e,t,i,r){this.coord=e,this._url=t,this._webgl=i,this._shaderProgram=r,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}get lastUsedAt(){return this._lastUsedAt}get createdAt(){return this._createdAt}touch(){this._lastUsedAt=Date.now()}draw(e,t,i,r,s){if(this.touch(),!this._ready||!this._gpuMesh)return!1;const o=this._webgl;return this._shaderProgram.enableShaders(e,t,i,r),o.bindBuffer(o.ARRAY_BUFFER,this._gpuMesh.positionBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(o.bindBuffer(o.ARRAY_BUFFER,this._gpuMesh.normalBuffer),o.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,o.FLOAT,!1,0,0),o.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,s?this._gpuMesh.lineIndexBuffer:this._gpuMesh.indexBuffer),o.drawElements(s?o.LINES:o.TRIANGLES,s?this._gpuMesh.lineIndexCount:this._gpuMesh.indexCount,this._gpuMesh.indexType,0),o.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&o.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),!0}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._url);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._url}`);const t=r.OBJMeshParser.parse(await e.text());this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[MeshHiPSTile] load failed",this._url,e),this._failed=!0,this._ready=!1}finally{this._loading=!1}}}uploadMesh(e){const t=this._webgl,i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer(),o=t.createBuffer();if(!(i&&r&&s&&o))throw new Error(`Could not create MeshHiPS buffers for ${this.key}`);const a=this.buildLineIndices(e.indices);return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o),t.bufferData(t.ELEMENT_ARRAY_BUFFER,a,t.STATIC_DRAW),{positionBuffer:i,normalBuffer:r,indexBuffer:s,lineIndexBuffer:o,indexCount:e.indices.length,lineIndexCount:a.length,indexType:t.UNSIGNED_INT}}buildLineIndices(e){const t=new Uint32Array(2*e.length);let i=0;for(let r=0;r<e.length;r+=3){const s=e[r],o=e[r+1],a=e[r+2];t[i++]=s,t[i++]=o,t[i++]=o,t[i++]=a,t[i++]=a,t[i++]=s}return t}get key(){return`${this.coord.order}/${this.coord.ipix}`}}},4322(e,t){"use strict";t.OBJMeshParser=void 0;class i{static parse(e,t={}){const r=t.preferFileNormals??!0,s=t.generatedNormals??"smooth",o=[],a=[],n=[],l=e.split(/\r\n|\n/);for(const e of l){const t=e.trim();if(t&&!t.startsWith("#")){if(t.startsWith("v ")){const e=t.split(/\s+/);if(e.length<4)continue;const i=Number(e[1]),r=Number(e[2]),s=Number(e[3]);if(![i,r,s].every(Number.isFinite))continue;o.push(i,r,s);continue}if(t.startsWith("vn ")){const e=t.split(/\s+/);if(e.length<4)continue;const i=Number(e[1]),r=Number(e[2]),s=Number(e[3]);if(![i,r,s].every(Number.isFinite))continue;const o=Math.hypot(i,r,s)||1;a.push(i/o,r/o,s/o);continue}if(t.startsWith("f ")){const e=t.slice(2).trim().split(/\s+/).map(e=>i.parseFaceToken(e,o.length/3,a.length/3)).filter(e=>null!==e);e.length>=3&&n.push(e)}}}const h=i.triangulateFaces(n);return r&&h.length>0&&h.every(e=>void 0!==e.normalIndex)?i.buildMeshWithFileNormals(o,a,h):"flat"===s?i.buildMeshWithFlatNormals(o,h):i.buildMeshWithSmoothNormals(o,h)}static parseFaceToken(e,t,r){const s=e.split("/"),o=i.parseIndex(s[0],t);if(null===o)return null;const a=s.length>=3?s[2]:void 0;return{positionIndex:o,normalIndex:(a?i.parseIndex(a,r):null)??void 0}}static parseIndex(e,t){if(!e)return null;const i=Number(e);if(!Number.isInteger(i)||0===i)return null;const r=i>0?i-1:t+i;return r>=0&&r<t?r:null}static triangulateFaces(e){const t=[];for(const i of e){const e=i[0];for(let r=1;r<i.length-1;r++)t.push(e,i[r],i[r+1])}return t}static buildMeshWithFileNormals(e,t,i){const r=[],s=[],o=[],a=new Map;for(const n of i){const i=n.normalIndex,l=`${n.positionIndex}/${i}`;let h=a.get(l);void 0===h&&(h=r.length/3,a.set(l,h),r.push(e[3*n.positionIndex],e[3*n.positionIndex+1],e[3*n.positionIndex+2]),s.push(t[3*i],t[3*i+1],t[3*i+2])),o.push(h)}return{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static buildMeshWithSmoothNormals(e,t){const r=[...e],s=new Array(r.length).fill(0),o=t.map(e=>e.positionIndex);return i.computeVertexNormals(r,o,s),{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static buildMeshWithFlatNormals(e,t){const r=[],s=[],o=[];for(let a=0;a<t.length;a+=3){const n=t[a],l=t[a+1],h=t[a+2];if(!n||!l||!h)continue;const c=i.computeFaceNormal(e,n.positionIndex,l.positionIndex,h.positionIndex);for(const t of[n,l,h])r.push(e[3*t.positionIndex],e[3*t.positionIndex+1],e[3*t.positionIndex+2]),s.push(c[0],c[1],c[2]),o.push(o.length)}return{positions:new Float32Array(r),normals:new Float32Array(s),indices:new Uint32Array(o)}}static computeVertexNormals(e,t,r){for(let s=0;s<t.length;s+=3){const o=t[s],a=t[s+1],n=t[s+2],l=i.computeRawFaceNormal(e,o,a,n);r[3*o]+=l[0],r[3*o+1]+=l[1],r[3*o+2]+=l[2],r[3*a]+=l[0],r[3*a+1]+=l[1],r[3*a+2]+=l[2],r[3*n]+=l[0],r[3*n+1]+=l[1],r[3*n+2]+=l[2]}for(let e=0;e<r.length;e+=3){const t=r[e],i=r[e+1],s=r[e+2],o=Math.hypot(t,i,s)||1;r[e]=t/o,r[e+1]=i/o,r[e+2]=s/o}}static computeFaceNormal(e,t,r,s){const[o,a,n]=i.computeRawFaceNormal(e,t,r,s),l=Math.hypot(o,a,n)||1;return[o/l,a/l,n/l]}static computeRawFaceNormal(e,t,i,r){const s=e[3*t],o=e[3*t+1],a=e[3*t+2],n=e[3*i]-s,l=e[3*i+1]-o,h=e[3*i+2]-a,c=e[3*r]-s,u=e[3*r+1]-o,d=e[3*r+2]-a;return[l*d-h*u,h*c-n*d,n*u-l*c]}}t.OBJMeshParser=i},8022(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackTimeline=void 0,t.createObservationTrackTimeline=function(e){return new i(e)},t.footprintToRing=s;class i{samples;startMs;endMs;currentMs;playing=!1;rafId=null;lastFrameNowMs=null;playbackRate;onFrame;onStop;constructor(e){if(this.samples=e.samples.map((e,t)=>({...e,index:t,timeMs:Date.parse(String(e.timestamp))})).filter(e=>Number.isFinite(e.timeMs)).sort((e,t)=>e.timeMs-t.timeMs),0===this.samples.length)throw new Error("ObservationTrackTimeline requires at least one timestamped sample.");this.startMs=this.samples[0].timeMs,this.endMs=this.samples[this.samples.length-1].timeMs,this.currentMs=this.startMs,this.playbackRate=e.playbackRate??1,this.onFrame=e.onFrame,this.onStop=e.onStop,this.emitFrame()}play(){this.playing||(this.playing=!0,this.lastFrameNowMs=null,this.rafId=requestAnimationFrame(e=>this.tick(e)))}pause(){this.playing&&(this.playing=!1,this.cancelPendingFrame(),this.onStop?.(this.getState()))}seek(e){const t=c(e);this.currentMs=this.startMs+(this.endMs-this.startMs)*t,this.emitFrame()}destroy(){this.playing=!1,this.cancelPendingFrame(),this.onStop?.(this.getState())}getState(){return{startMs:this.startMs,endMs:this.endMs,currentMs:this.currentMs,progress01:this.getProgress(),playing:this.playing}}tick(e){if(!this.playing)return;null===this.lastFrameNowMs&&(this.lastFrameNowMs=e);const t=e-this.lastFrameNowMs;if(this.lastFrameNowMs=e,this.currentMs+=t*this.playbackRate,this.currentMs>=this.endMs)return this.currentMs=this.endMs,this.emitFrame(),void this.pause();this.emitFrame(),this.rafId=requestAnimationFrame(e=>this.tick(e))}emitFrame(){const e=function(e,t){const i=e[0],s=e[e.length-1];if(t<=i.timeMs)return r(i,i,0);if(t>=s.timeMs)return r(s,s,0);for(let i=0;i<e.length-1;i++){const s=e[i],o=e[i+1];if(t>=s.timeMs&&t<=o.timeMs){return r(s,o,(t-s.timeMs)/(o.timeMs-s.timeMs))}}return r(s,s,0)}(this.samples,this.currentMs);this.onFrame?.({currentMs:this.currentMs,progress01:this.getProgress(),...e})}getProgress(){return this.endMs===this.startMs?0:c((this.currentMs-this.startMs)/(this.endMs-this.startMs))}cancelPendingFrame(){null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}function r(e,t,i){const r=function(e,t,i){const r=e.groundTrackPoint,s=t.groundTrackPoint,o=h(e.timeMs,t.timeMs,i);return{timestamp:new Date(o).toISOString(),longitudeDeg:n(r.longitudeDeg,s.longitudeDeg,i),latitudeDeg:h(r.latitudeDeg,s.latitudeDeg,i),altitudeKm:h(r.altitudeKm,s.altitudeKm,i)}}(e,t,i),l=i<.5?e:t,c=function(e,t,i,r){const l=o(s(e)),c=o(s(t));if(l.length<3||l.length!==c.length)return r;const u=l.map(([e,t],r)=>{const[s,o]=c[r];return[n(e,s,i),h(t,o,i)]});return function(e){if(0===e.length)return e;const t=e[0],i=e[e.length-1];return a(t,i)?e:[...e,[...t]]}(u)}(e.footprint,t.footprint,i,s(l.footprint));return{markerPoint:r,currentGroundPoint:r,currentFootprint:c,interpolationT:i,previousSample:e,nextSample:t,nearestSample:l,nearestSampleIndex:l.index}}function s(e){if(function(e){return!Array.isArray(e)&&"coordinates"in e}(e))return e.coordinates.map(e=>[e.longitudeDeg,e.latitudeDeg]);if(function(e){return!Array.isArray(e)&&"polygons"in e}(e)){const t=e.polygons[0];return t?s(t):[]}return Array.isArray(e)?e:[]}function o(e){if(!Array.isArray(e))return[];const t=[];for(const i of e){if(!Array.isArray(i)||i.length<2)return[];const e=Number(i[0]),r=Number(i[1]);if(!Number.isFinite(e)||!Number.isFinite(r)||r<-90||r>90)return[];t.push([l(e),r])}for(;t.length>1&&a(t[0],t[t.length-1]);)t.pop();return t}function a(e,t){return Math.abs(e[0]-t[0])<1e-9&&Math.abs(e[1]-t[1])<1e-9}function n(e,t,i){const r=l(t-e);return l(e+r*i)}function l(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}function h(e,t,i){return e+(t-e)*i}function c(e){return Math.max(0,Math.min(1,Number.isFinite(e)?e:0))}t.ObservationTrackTimeline=i},5772(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackViewerAdapter=void 0;const s=r(i(8755)),o=i(1072),a=i(5403),n=i(8022),l={showSatelliteModel:!0,showGroundTrack:!0,showFootprint:!0,showSensorCone:!0,showCurrentFootprintOnly:!1,showAllFootprints:!0},h={groundTrack:"#ffe066",footprints:"#00fff2",currentFootprint:"#ff4d4d",marker:"#ff4d4d",satelliteObject:[1,.84,.22,1],sensorCone:[0,1,.95,.68],target:"#ffb347"};t.ObservationTrackViewerAdapter=class{activeHandle=null;viewer;metadataManagerFactory;colors;onFrame;constructor(e){this.viewer=e.viewer,this.metadataManagerFactory=e.metadataManagerFactory??(()=>new a.MetadataManager([])),this.colors={...h,...e.colors},this.onFrame=e.onFrame}load(e){this.clear();const t=new c(this.viewer,e,this.metadataManagerFactory,this.colors,this.onFrame);return this.activeHandle=t,t}clear(){this.activeHandle?.dispose(),this.activeHandle=null}};class c{viewer;track;metadataManagerFactory;colors;onFrame;timeline;objects={target:null,groundTrack:null,footprints:null,currentFootprint:null,marker:null,satelliteObject:null,sensorCone:null};visualisation;currentFootprintIndex=-1;disposed=!1;constructor(e,t,i,r,s){this.viewer=e,this.track=t,this.metadataManagerFactory=i,this.colors=r,this.onFrame=s,function(e){if(!e.samples||0===e.samples.length)throw new Error("ObservationTrackViewerAdapter requires at least one sample.")}(t),this.visualisation={...l,...t.visualisation},this.createStaticObjects(),this.timeline=(0,n.createObservationTrackTimeline)({samples:t.samples,playbackRate:1,onFrame:e=>this.updateFrame(e)}),this.applyVisualisation()}play(){this.timeline.play()}pause(){this.timeline.pause()}seek(e){this.timeline.seek(e)}setVisualisation(e){this.visualisation={...this.visualisation,...e},this.applyVisualisation()}dispose(){this.disposed||(this.disposed=!0,this.timeline.destroy(),this.deleteObjects())}createStaticObjects(){this.objects.target=this.createTargetOverlay(),this.objects.footprints=this.createAllFootprintsOverlay(),this.objects.groundTrack=this.createGroundTrackOverlay(),this.objects.marker=this.createMarkerOverlay(),this.objects.satelliteObject=this.createSatelliteObject(),this.objects.sensorCone=this.createSensorCone()}createTargetOverlay(){const e=this.track.target?.geojson;if(!e)return null;const t=this.viewer.createTerraFootprintSet(this.track.target?.name??"Observation target","ObservationTrack target GeoJSON",this.track.target?.geojsonUrl??"ObservationTrack",this.metadataManagerFactory());return t.addGeoJSONFeatures(s.default.parseGeoJSON(e)),this.viewer.changeFootprintSetColor(t,this.colors.target),this.viewer.showTerraFootprintSet(t),t}createAllFootprintsOverlay(){const e={type:"FeatureCollection",features:this.track.samples.map((e,t)=>u(e,t))},t=this.viewer.createTerraFootprintSet(`${this.track.satellite?.name??"Satellite"} footprints`,"ObservationTrack sampled sensor footprints",this.track.id??"ObservationTrack",this.metadataManagerFactory());return t.addGeoJSONFeatures(s.default.parseGeoJSON(e)),this.viewer.changeFootprintSetColor(t,this.colors.footprints),this.viewer.showTerraFootprintSet(t),t}createGroundTrackOverlay(){const e=this.viewer.createTerraPolylineSet(`${this.track.satellite?.name??"Satellite"} ground track`,"ObservationTrack GroundTrackPoint[]",this.track.id??"ObservationTrack",this.metadataManagerFactory());return e.addGroundTrack(this.track.samples.map(e=>({...e.groundTrackPoint,timestamp:e.timestamp})),{name:`${this.track.satellite?.name??"Satellite"} ground track`}),this.viewer.changeTerraPolylineSetColor(e,this.colors.groundTrack),this.viewer.showTerraPolylineSet(e),e}createMarkerOverlay(){const e=this.viewer.createTerraPointSet(`${this.track.satellite?.name??"Satellite"} marker`,"ObservationTrack interpolated satellite marker",this.track.id??"ObservationTrack",new a.MetadataManager(_()));return this.viewer.changeCatalogueColor(e,this.colors.marker),this.viewer.showTerraPointSet(e),e}createSatelliteObject(){const e=this.track.satellite?.model?.objUrl;if(!e)return null;const t=this.viewer.createSatelliteObject({name:`${this.track.satellite?.name??"Satellite"} object`,objUrl:e,color:this.colors.satelliteObject,scale:this.track.satellite?.model?.visualScale});return this.viewer.showSatelliteObject(t),t}createSensorCone(){const e=this.viewer.createSensorCone({name:`${this.track.sensor?.name??"Sensor"} cone`,color:this.colors.sensorCone,wireframe:!0,filled:!1});return this.viewer.showSensorCone(e),e}updateFrame(e){this.disposed||(this.updateMarker(e.currentGroundPoint),this.updateSatelliteObject(e),this.updateSensorCone(e),this.updateCurrentFootprint(e),this.onFrame?.(e))}updateMarker(e){const t=this.objects.marker;t&&(t.clearSources(),t.addSources([[e.longitudeDeg,e.latitudeDeg,String(e.timestamp??""),e.altitudeKm]],_()))}updateSatelliteObject(e){const t=this.objects.satelliteObject;t&&t.setPosition(e.currentGroundPoint,e.previousSample?.groundTrackPoint??null,e.nextSample?.groundTrackPoint??null)}updateSensorCone(e){const t=this.objects.sensorCone;t&&t.setGeometry(e.currentGroundPoint,e.currentFootprint)}updateCurrentFootprint(e){e.nearestSampleIndex!==this.currentFootprintIndex&&(this.objects.currentFootprint&&this.viewer.deleteTerraFootprintSet(this.objects.currentFootprint),this.objects.currentFootprint=this.createCurrentFootprintOverlay(e.nearestSample),this.currentFootprintIndex=e.nearestSampleIndex,this.applyVisualisation())}createCurrentFootprintOverlay(e){const t={type:"FeatureCollection",features:[u(e,e.index,"Current footprint")]},i=this.viewer.createTerraFootprintSet(`${this.track.satellite?.name??"Satellite"} current footprint`,"ObservationTrack nearest sampled footprint",this.track.id??"ObservationTrack",this.metadataManagerFactory());return i.addGeoJSONFeatures(s.default.parseGeoJSON(t)),this.viewer.changeFootprintSetColor(i,this.colors.currentFootprint),this.viewer.showTerraFootprintSet(i),i}applyVisualisation(){const e=Boolean(this.visualisation.showFootprint),t=e&&Boolean(this.visualisation.showAllFootprints)&&!this.visualisation.showCurrentFootprintOnly,i=e&&(Boolean(this.visualisation.showCurrentFootprintOnly)||!t);this.objects.target&&this.viewer.hideTerraFootprintSet(this.objects.target,!0),this.objects.groundTrack&&this.viewer.hideTerraPolylineSet(this.objects.groundTrack,Boolean(this.visualisation.showGroundTrack)),this.objects.footprints&&this.viewer.hideTerraFootprintSet(this.objects.footprints,t),this.objects.currentFootprint&&this.viewer.hideTerraFootprintSet(this.objects.currentFootprint,i),this.objects.marker&&this.viewer.hideTerraPointSet(this.objects.marker,!0),this.objects.satelliteObject&&this.viewer.hideSatelliteObject(this.objects.satelliteObject,Boolean(this.visualisation.showSatelliteModel)),this.objects.sensorCone&&this.viewer.hideSensorCone(this.objects.sensorCone,Boolean(this.visualisation.showSensorCone))}deleteObjects(){this.objects.target&&this.viewer.deleteTerraFootprintSet(this.objects.target),this.objects.groundTrack&&this.viewer.deleteTerraPolylineSet(this.objects.groundTrack),this.objects.footprints&&this.viewer.deleteTerraFootprintSet(this.objects.footprints),this.objects.currentFootprint&&this.viewer.deleteTerraFootprintSet(this.objects.currentFootprint),this.objects.marker&&this.viewer.deleteTerraPointSet(this.objects.marker),this.objects.satelliteObject&&this.viewer.deleteSatelliteObject(this.objects.satelliteObject),this.objects.sensorCone&&this.viewer.deleteSensorCone(this.objects.sensorCone),this.objects.target=null,this.objects.groundTrack=null,this.objects.footprints=null,this.objects.currentFootprint=null,this.objects.marker=null,this.objects.satelliteObject=null,this.objects.sensorCone=null}}function u(e,t,i=`Footprint ${t+1}`){return{type:"Feature",properties:{name:i,timestamp:String(e.timestamp),intersectsTarget:String(Boolean(e.intersectsTarget??e.intersects))},geometry:d(e.footprint)}}function d(e){return!Array.isArray(e)&&"polygons"in e?{type:"MultiPolygon",coordinates:e.polygons.map(e=>[g((0,n.footprintToRing)(e))])}:{type:"Polygon",coordinates:[g((0,n.footprintToRing)(e))]}}function g(e){if(0===e.length)return e;const t=e[0],i=e[e.length-1];return Math.abs(t[0]-i[0])<1e-9&&Math.abs(t[1]-i[1])<1e-9?e:[...e,[t[0],t[1]]]}function _(){return[new o.MetadataColumn({index:0,name:"longitudeDeg",columnType:o.ColumnType.GEOM_RA,unit:"deg"}),new o.MetadataColumn({index:1,name:"latitudeDeg",columnType:o.ColumnType.GEOM_DEC,unit:"deg"}),new o.MetadataColumn({index:2,name:"timestamp",columnType:o.ColumnType.MAIN_NAME,unit:""}),new o.MetadataColumn({index:3,name:"altitudeKm",columnType:o.ColumnType.NUMBER,unit:"km"})]}},5866(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ObservationTrackViewerAdapter=t.ObservationTrackTimeline=t.footprintToRing=t.createObservationTrackTimeline=void 0;var r=i(8022);Object.defineProperty(t,"createObservationTrackTimeline",{enumerable:!0,get:function(){return r.createObservationTrackTimeline}}),Object.defineProperty(t,"footprintToRing",{enumerable:!0,get:function(){return r.footprintToRing}}),Object.defineProperty(t,"ObservationTrackTimeline",{enumerable:!0,get:function(){return r.ObservationTrackTimeline}});var s=i(5772);Object.defineProperty(t,"ObservationTrackViewerAdapter",{enumerable:!0,get:function(){return s.ObservationTrackViewerAdapter}})},3603(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SatelliteObjectGL=void 0;const r=i(3890),s=i(2257),o=i(4322),a=i(6553),n=i(8145);class l{_options;_webgl;static EARTH_RADIUS_KM=6371;_kind="SatelliteObjectGL";_gpuMesh=null;_shaderProgram;_modelMatrix=r.mat4.create();_isVisible=!0;_ready=!1;_loading=!1;_failed=!1;_color;_scale;constructor(e,t){this._options=e,this._webgl=t,this._shaderProgram=new s.MeshHiPSShaderProgram(this._webgl,{twoSidedLighting:!0,markerLighting:!0}),this._color=e.color??[1,.85,.25,1],this._scale=e.scale??.025,this.load()}get ready(){return this._ready}get loading(){return this._loading}get failed(){return this._failed}async load(){if(!this._loading&&!this._ready){this._loading=!0;try{const e=await fetch(this._options.objUrl);if(!e.ok)throw new Error(`HTTP ${e.status} fetching ${this._options.objUrl}`);const t=o.OBJMeshParser.parse(await e.text(),{preferFileNormals:!0,generatedNormals:"flat"});this._gpuMesh=this.uploadMesh(t),this._ready=!0,this._failed=!1}catch(e){console.warn("[SatelliteObjectGL] load failed",this._options.objUrl,e),this._ready=!1,this._failed=!0}finally{this._loading=!1}}}setIsVisible(e){this._isVisible=e}setColor(e){this._color=e}setScale(e){Number.isFinite(e)&&e>0&&(this._scale=e)}setPosition(e,t,i){if(!c(e))return;const s=h(e),o=r.vec3.normalize(r.vec3.create(),s),a=this.computeForward(e,s,o,t,i),n=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),a,o));if(r.vec3.length(n)<1e-6)return void this.setFallbackMatrix(s,o);const l=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),o,n));this.setMatrixFromBasis(s,n,l,o)}draw(e,t,i){if(!this._isVisible||!this._ready||!this._gpuMesh)return;const s=this._webgl,o=r.mat4.multiply(r.mat4.create(),i,this._modelMatrix);this._shaderProgram.enableShaders(e,t,o,this._color),s.bindBuffer(s.ARRAY_BUFFER,this._gpuMesh.positionBuffer),s.vertexAttribPointer(this._shaderProgram.locations.vertexPositionAttribute,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&(s.bindBuffer(s.ARRAY_BUFFER,this._gpuMesh.normalBuffer),s.vertexAttribPointer(this._shaderProgram.locations.vertexNormalAttribute,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute)),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this._gpuMesh.indexBuffer),s.drawElements(s.TRIANGLES,this._gpuMesh.indexCount,this._gpuMesh.indexType,0),s.disableVertexAttribArray(this._shaderProgram.locations.vertexPositionAttribute),this._shaderProgram.locations.vertexNormalAttribute>=0&&s.disableVertexAttribArray(this._shaderProgram.locations.vertexNormalAttribute),s.bindBuffer(s.ARRAY_BUFFER,null),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,null)}dispose(){const e=this._webgl;this._gpuMesh?.positionBuffer&&e.deleteBuffer(this._gpuMesh.positionBuffer),this._gpuMesh?.normalBuffer&&e.deleteBuffer(this._gpuMesh.normalBuffer),this._gpuMesh?.indexBuffer&&e.deleteBuffer(this._gpuMesh.indexBuffer),this._gpuMesh?.lineIndexBuffer&&e.deleteBuffer(this._gpuMesh.lineIndexBuffer),this._gpuMesh=null,this._ready=!1,this._loading=!1}computeForward(e,t,i,s,o){const a=s&&c(s)?h(s):null,n=o&&c(o)?h(o):null;let l=r.vec3.create();if(a&&n)r.vec3.subtract(l,n,a);else if(n)r.vec3.subtract(l,n,t);else{if(!a)return this.localEastFallback(e,i);r.vec3.subtract(l,t,a)}const u=r.vec3.scale(r.vec3.create(),i,r.vec3.dot(l,i));return r.vec3.subtract(l,l,u),r.vec3.length(l)<1e-6?this.localEastFallback(e,i):r.vec3.normalize(l,l)}localEastFallback(e,t){const i=h({...e,longitudeDeg:e.longitudeDeg+.01}),s=r.vec3.subtract(r.vec3.create(),i,h(e)),o=r.vec3.scale(r.vec3.create(),t,r.vec3.dot(s,t));return r.vec3.subtract(s,s,o),r.vec3.normalize(s,s)}setFallbackMatrix(e,t){const i=Math.abs(t[2])>.9?r.vec3.fromValues(1,0,0):r.vec3.fromValues(0,0,1),s=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),i,t)),o=r.vec3.normalize(r.vec3.create(),r.vec3.cross(r.vec3.create(),t,s));this.setMatrixFromBasis(e,s,o,t)}setMatrixFromBasis(e,t,i,s){const o=this._scale;this._modelMatrix=r.mat4.fromValues(t[0]*o,t[1]*o,t[2]*o,0,i[0]*o,i[1]*o,i[2]*o,0,s[0]*o,s[1]*o,s[2]*o,0,e[0],e[1],e[2],1)}uploadMesh(e){const t=this._webgl,i=t.createBuffer(),r=t.createBuffer(),s=t.createBuffer();if(!i||!r||!s)throw new Error(`Could not create SatelliteObjectGL buffers for ${this._options.name}`);return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e.positions,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,e.normals,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s),t.bufferData(t.ELEMENT_ARRAY_BUFFER,e.indices,t.STATIC_DRAW),{positionBuffer:i,normalBuffer:r,indexBuffer:s,lineIndexBuffer:null,indexCount:e.indices.length,lineIndexCount:0,indexType:t.UNSIGNED_INT}}}function h(e){const t=new a.Point({lonDeg:u(e.longitudeDeg),latDeg:e.latitudeDeg},n.CoordsType.GEOGRAPHIC),i=1+Math.max(0,e.altitudeKm??0)/l.EARTH_RADIUS_KM;return r.vec3.fromValues(t.x*i,t.y*i,t.z*i)}function c(e){return Number.isFinite(e.longitudeDeg)&&Number.isFinite(e.latitudeDeg)&&e.latitudeDeg>=-90&&e.latitudeDeg<=90}function u(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.SatelliteObjectGL=l},3102(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SensorConeGL=void 0;const r=i(8909),s=i(8145),o=i(6553);class a{_options;_webgl;static EARTH_RADIUS_KM=6371;static ELEM_SIZE=3;_kind="SensorConeGL";_lineBuffer=null;_lineVertexCount=0;_isVisible=!0;_shaderProgram;_color;constructor(e,t){this._options=e,this._webgl=t,this._shaderProgram=new r.FootprintShaderProgram(this._webgl),this._color=e.color??[0,1,.95,.68]}setGeometry(e,t){if(!h((i=e).longitudeDeg,i.latitudeDeg)||void 0!==i.altitudeKm&&!Number.isFinite(i.altitudeKm))return void this.clear();var i;const r=function(e){const t=[];for(const i of e){if(!Array.isArray(i)||i.length<2)return[];const e=Number(i[0]),r=Number(i[1]);if(!h(e,r))return[];t.push([u(e),r])}for(;t.length>1&&c(t[0],t[t.length-1]);)t.pop();const i=new Set(t.map(([e,t])=>`${e.toFixed(9)},${t.toFixed(9)}`));return i.size>=3?t:[]}(t);if(r.length<3||function(e){for(let t=0;t<e.length;t++){const i=e[t],r=e[(t+1)%e.length];if(Math.abs(u(r[0])-u(i[0]))>180)return!0}return!1}(r))return void this.clear();const s=n(e),o=r.map(([e,t])=>n({longitudeDeg:e,latitudeDeg:t,altitudeKm:0})),a=this.buildLineVertices(s,o);this.uploadLineVertices(a)}setIsVisible(e){this._isVisible=e}setColor(e){this._color=e}clear(){this._lineVertexCount=0,this._lineBuffer&&(this._webgl.deleteBuffer(this._lineBuffer),this._lineBuffer=null)}draw(e,t,i){if(!this._isVisible)return;if(!this._lineBuffer||0===this._lineVertexCount)return;const r=this._webgl,s=r.isEnabled(r.BLEND),o=r.isEnabled(r.DEPTH_TEST),n=r.isEnabled(r.CULL_FACE),l=r.getParameter(r.DEPTH_WRITEMASK),h=r.getParameter(r.DEPTH_FUNC),c=r.getParameter(r.BLEND_SRC_RGB),u=r.getParameter(r.BLEND_DST_RGB),d=r.getParameter(r.BLEND_SRC_ALPHA),g=r.getParameter(r.BLEND_DST_ALPHA);r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.enable(r.DEPTH_TEST),r.depthMask(!1),r.disable(r.CULL_FACE),this._shaderProgram.enableShaders(e,i,t),r.uniform4f(this._shaderProgram.locations.color,this._color[0],this._color[1],this._color[2],this._color[3]),r.bindBuffer(r.ARRAY_BUFFER,this._lineBuffer),r.vertexAttribPointer(this._shaderProgram.locations.position,a.ELEM_SIZE,r.FLOAT,!1,0,0),r.enableVertexAttribArray(this._shaderProgram.locations.position),r.drawArrays(r.LINES,0,this._lineVertexCount),r.disableVertexAttribArray(this._shaderProgram.locations.position),r.bindBuffer(r.ARRAY_BUFFER,null),r.depthMask(l),r.depthFunc(h),r.blendFuncSeparate(c,u,d,g),n?r.enable(r.CULL_FACE):r.disable(r.CULL_FACE),o?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),s?r.enable(r.BLEND):r.disable(r.BLEND)}dispose(){this.clear()}buildLineVertices(e,t){const i=4*t.length,r=new Float32Array(i*a.ELEM_SIZE);let s=0;for(const i of t)s=l(r,s,e),s=l(r,s,i);for(let e=0;e<t.length;e++){const i=t[e],o=t[(e+1)%t.length];s=l(r,s,i),s=l(r,s,o)}return r}uploadLineVertices(e){if(this._lineBuffer||(this._lineBuffer=this._webgl.createBuffer()),!this._lineBuffer)throw new Error(`Could not create SensorConeGL line buffer for ${this._options.name}`);this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,this._lineBuffer),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,e,this._webgl.DYNAMIC_DRAW),this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._lineVertexCount=e.length/a.ELEM_SIZE}}function n(e){const t=new o.Point({lonDeg:u(e.longitudeDeg),latDeg:e.latitudeDeg},s.CoordsType.GEOGRAPHIC),i=1+Math.max(0,e.altitudeKm??0)/a.EARTH_RADIUS_KM;return[t.x*i,t.y*i,t.z*i]}function l(e,t,i){return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],t+a.ELEM_SIZE}function h(e,t){return Number.isFinite(e)&&Number.isFinite(t)&&t>=-90&&t<=90}function c(e,t){return Math.abs(e[0]-t[0])<1e-9&&Math.abs(e[1]-t[1])<1e-9}function u(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.SensorConeGL=a},9022(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraFootprintSetGL=void 0;const r=i(592),s=i(8145),o=i(2475),a=i(1072),n=i(5403),l=i(1072);class h extends r.FootprintSetGL{_kind="TerraFootprintSetGL";_coordsType=s.CoordsType.GEOGRAPHIC;addGeoJSONFeatures(e){this._ready=!1,this.clearFootprints(),this._metadataManager=new n.MetadataManager(this.createGeoJSONMetadataColumns(e));for(const t of e){const e=o.Footprint.fromPolygons(t.polygons,this.createGeoJSONDetails(t),s.CoordsType.GEOGRAPHIC);e.valid&&(this.addFootprint(e),this.totPoints+=e.totPoints,this.totConvexPoints+=e.totConvexPoints)}this._ready=!0,this._bufferInitialised=!1}createGeoJSONMetadataColumns(e){const t=new Set;return e.forEach(e=>Object.keys(e.properties).forEach(e=>t.add(e))),Array.from(t).map((t,i)=>{const r=e.map(e=>e.properties[t]).filter(e=>null!=e&&""!==e),s=r.length>0&&r.every(e=>"number"==typeof e||!Number.isNaN(Number(e))),o=/^name$|nome|denominazione|label|title/i.test(t);return new a.MetadataColumn({index:i,name:t,columnType:o?l.ColumnType.MAIN_NAME:s?l.ColumnType.NUMBER:l.ColumnType.STRING,unit:""})})}createGeoJSONDetails(e){return Object.entries(e.properties).map(([e,t])=>({key:e,value:"number"==typeof t?t:String(t??"")}))}}t.TerraFootprintSetGL=h},5781(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPointSetGL=void 0;const r=i(1232);class s extends r.CatalogueGL{_kind="TerraPointSetGL"}t.TerraPointSetGL=s},3665(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerraPolylineSetGL=void 0;const r=i(8909),s=i(8145),o=i(7930),a=i(6553);class n{_name;_description;_providerUrl;_metadataManager;_webgl;_visibleTilesManager;static ELEM_SIZE=3;static BYTES_X_ELEM=(new Float32Array).BYTES_PER_ELEMENT;_kind="TerraPolylineSetGL";_isVisible=!0;_ready=!0;_shapeColor="#ffe066";_bufferInitialised=!1;paths=[];renderSegments=[];_polylineShaderProgram;constructor(e,t,i,s,o,a){this._name=e,this._description=t,this._providerUrl=i,this._metadataManager=s,this._webgl=o,this._visibleTilesManager=a,this._polylineShaderProgram=new r.FootprintShaderProgram(this._webgl)}addPath(e,t){this.paths.push({points:[...e],metadata:t}),this._ready=!0,this._bufferInitialised=!1}addGroundTrack(e,t){this.addPath(e,t)}clearPaths(){this.paths=[],this.disposeBuffers(),this.renderSegments=[],this._bufferInitialised=!1}setIsVisible(e){this._isVisible=e}get isVisible(){return this._isVisible}changeColor(e){this._shapeColor=e}dispose(){this.disposeBuffers(),this.renderSegments=[],this.paths=[],this._bufferInitialised=!1}draw(e,t,i,r){if(!this._isVisible)return;if(!this._ready)return;if(!i)return;if(!this._webgl)return;if(this._bufferInitialised||this.initBuffers(),0===this.renderSegments.length)return;this._polylineShaderProgram.enableShaders(r,e,i);const s=(0,o.colorHex2RGB)(this._shapeColor);this._webgl.uniform4f(this._polylineShaderProgram.locations.color,s[0],s[1],s[2],1);for(const e of this.renderSegments)!e.buffer||e.vertices.length<2*n.ELEM_SIZE||(this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,e.buffer),this._webgl.vertexAttribPointer(this._polylineShaderProgram.locations.position,n.ELEM_SIZE,this._webgl.FLOAT,!1,n.BYTES_X_ELEM*n.ELEM_SIZE,0),this._webgl.enableVertexAttribArray(this._polylineShaderProgram.locations.position),this._webgl.drawArrays(this._webgl.LINE_STRIP,0,e.vertices.length/n.ELEM_SIZE));this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER,null)}initBuffers(){this.disposeBuffers(),this.renderSegments=this.buildRenderSegments();for(const e of this.renderSegments){const t=this._webgl.createBuffer();e.buffer=t,this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,t),this._webgl.bufferData(this._webgl.ARRAY_BUFFER,e.vertices,this._webgl.STATIC_DRAW)}this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER,null),this._bufferInitialised=!0}buildRenderSegments(){const e=[];for(const t of this.paths)for(const i of this.splitPath(t.points)){if(i.length<2)continue;const t=new Float32Array(i.length*n.ELEM_SIZE);let r=0;for(const e of i){const i=new a.Point({lonDeg:c(e.longitudeDeg),latDeg:e.latitudeDeg},s.CoordsType.GEOGRAPHIC);t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z,r+=n.ELEM_SIZE}e.push({vertices:t,buffer:null})}return e}splitPath(e){const t=[];let i=[],r=null;for(const s of e)l(s)?(r&&h(r.longitudeDeg,s.longitudeDeg)&&(i.length>1&&t.push(i),i=[]),i.push(s),r=s):(i.length>1&&t.push(i),i=[],r=null);return i.length>1&&t.push(i),t}disposeBuffers(){for(const e of this.renderSegments)e.buffer&&(this._webgl.deleteBuffer(e.buffer),e.buffer=null)}}function l(e){return Number.isFinite(e.longitudeDeg)&&Number.isFinite(e.latitudeDeg)&&e.latitudeDeg>=-90&&e.latitudeDeg<=90}function h(e,t){return Math.abs(c(t)-c(e))>180}function c(e){const t=((e+180)%360+360)%360-180;return Object.is(t,-0)?0:t}t.TerraPolylineSetGL=n},3559(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CatalogueShaderProgram=void 0;const s=i(3890),o=r(i(5947));t.CatalogueShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix"},this.gl_attributes={vertex_pos:"aCatPosition",vertex_selected:"a_selected",point_size:"a_pointsize",point_hue:"a_brightness"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,hovered:-1,pointSize:-1,brightness:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=o.default.catalogueFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=o.default.catalogueVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.hovered=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_selected),this.locations.pointSize=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_size),this.locations.brightness=e.getAttribLocation(this.shaderProgram,this.gl_attributes.point_hue),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let o=s.mat4.create();o=s.mat4.multiply(o,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,o)}}},8909(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FootprintShaderProgram=void 0;const s=i(3890),o=r(i(5947));t.FootprintShaderProgram=class{_shaderProgram;_vertexShader;_fragmentShader;gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={vertex_color:"u_fragcolor",m_perspective:"uPMatrix",m_model_view:"uMVMatrix",point_size:"u_pointsize"},this.gl_attributes={vertex_pos:"aCatPosition"},this.locations={pMatrix:null,mvMatrix:null,color:null,position:-1,pointSize:-1}}get shaderProgram(){if(!this._shaderProgram){const e=this._webgl;this._shaderProgram=e.createProgram(),this.initShaders()}return this._shaderProgram}initShaders(){const e=this._webgl,t=o.default.footprintFS();if(this._fragmentShader=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(this._fragmentShader,t),e.compileShader(this._fragmentShader),console.log("FS log:",e.getShaderInfoLog(this._fragmentShader)||"ok"),!e.getShaderParameter(this._fragmentShader,e.COMPILE_STATUS))return void alert(e.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const i=o.default.footprintVS();this._vertexShader=e.createShader(e.VERTEX_SHADER),e.shaderSource(this._vertexShader,i),e.compileShader(this._vertexShader),console.log("VS log:",e.getShaderInfoLog(this._vertexShader)||"ok"),e.getShaderParameter(this._vertexShader,e.COMPILE_STATUS)?(e.attachShader(this.shaderProgram,this._vertexShader),e.attachShader(this.shaderProgram,this._fragmentShader),e.linkProgram(this.shaderProgram),e.getProgramParameter(this.shaderProgram,e.LINK_STATUS)||alert("Could not initialise shaders"),e.useProgram(this.shaderProgram),this.locations.position=e.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.pointSize=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.point_size),this.locations.color=e.getUniformLocation(this.shaderProgram,this.gl_uniforms.vertex_color)):alert(e.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableShaders(e,t,i){const r=this._webgl;r.useProgram(this.shaderProgram),this.locations.pMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mvMatrix=r.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model_view);let o=s.mat4.create();o=s.mat4.multiply(o,i,t),r.uniformMatrix4fv(this.locations.pMatrix,!1,e),r.uniformMatrix4fv(this.locations.mvMatrix,!1,o)}}},4707(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{static healpixGridVS(){return"#version 300 es\n in vec4 aCatPosition;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = 7.0;\n }"}static healpixGridFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n // fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n fragColor = u_fragcolor;\n }"}}},7786(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HiPSShaderProgram=void 0;const s=r(i(5947)),o=i(619);t.HiPSShaderProgram=class{_colorMapBlockIndex=null;_runtimeColorMap;_shaderProgram;_vertexShader;_fragmentShader;_UBO_colorMapBuffer=null;_UBO_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};gl_uniforms;gl_attributes;locations;_webgl;constructor(e){this._webgl=e,this.gl_uniforms={sampler:"uSampler0",factor:"uFactor0",m_perspective:"uPMatrix",m_model:"uMMatrix",m_view:"uVMatrix",colormapIdx:"cmapIdx",colormap_red:"r",colormap_green:"g",colormap_blue:"b",textureMode:"uTextureMode",dataMin:"uDataMin",dataMax:"uDataMax"},this.gl_attributes={vertex_pos:"aVertexPosition",text_coords:"aTextureCoord"},this.locations={pMatrix:null,mMatrix:null,vMatrix:null,samplers:new Array(8).fill(null),textureAlpha:new Array(8).fill(null),textureMode:new Array(8).fill(null),dataMin:new Array(8).fill(null),dataMax:new Array(8).fill(null),clorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();this._shaderProgram=t,this.initShaders(t)}return e.useProgram(this._shaderProgram),this._shaderProgram}setRuntimeColorMap(e){this._runtimeColorMap=e}initShaders(e){const t=this._webgl,i=s.default.hipsNativeFS();if(this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,i),t.compileShader(this._fragmentShader),!t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS))return void alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error");const r=s.default.hipsVS();this._vertexShader=t.createShader(t.VERTEX_SHADER),t.shaderSource(this._vertexShader,r),t.compileShader(this._vertexShader),t.getShaderParameter(this._vertexShader,t.COMPILE_STATUS)?(t.attachShader(e,this._vertexShader),t.attachShader(e,this._fragmentShader),t.linkProgram(e),t.getProgramParameter(e,t.LINK_STATUS)||alert("Could not initialise shaders")):alert(t.getShaderInfoLog(this._vertexShader)||"Vertex shader compile error")}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setGrayscaleShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsGrayscaleFS();this.changeFSShader(e)}setNativeShader(){this._webgl.detachShader(this.shaderProgram,this._fragmentShader);const e=s.default.hipsNativeFS();this.changeFSShader(e)}setColorMapShader(){const e=this._webgl;e.detachShader(this.shaderProgram,this._fragmentShader);const t=s.default.hipsColorMapFS();this.changeFSShader(t);const i=e.getUniformBlockIndex(this.shaderProgram,"colormap");if(i===e.INVALID_INDEX)return console.warn('HiPSShaderProgram: uniform block "colormap" not found in hipsColorMapFS()'),this._colorMapBlockIndex=null,void(this._UBO_colorMapBuffer=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],o=e.getUniformIndices(this.shaderProgram,r),a=e.getActiveUniforms(this.shaderProgram,o,e.UNIFORM_OFFSET);if(!this._UBO_colorMapBuffer){this._UBO_colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._UBO_colorMapBuffer);const t=12288;e.bufferData(e.UNIFORM_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._UBO_colorMapBuffer)}r.forEach((e,t)=>{this._UBO_colorMapVariableInfo[e]={index:o[t],offset:a[t]}})}changeFSShader(e){const t=this._webgl;this._fragmentShader=t.createShader(t.FRAGMENT_SHADER),t.shaderSource(this._fragmentShader,e),t.compileShader(this._fragmentShader),t.getShaderParameter(this._fragmentShader,t.COMPILE_STATUS)?(t.attachShader(this.shaderProgram,this._fragmentShader),t.linkProgram(this.shaderProgram),t.getProgramParameter(this.shaderProgram,t.LINK_STATUS)||alert("Could not initialise shaders"),t.useProgram(this.shaderProgram)):alert(t.getShaderInfoLog(this._fragmentShader)||"Fragment shader compile error")}setTextureDataMode(e,t,i,r){if(e<0||e>=8)throw new Error(`Invalid HiPS sampler index: ${e}`);const s=this._webgl,o=this.locations.textureMode[e];if(o&&s.uniform1i(o,t?1:0),!t)return;if(void 0===i||void 0===r||!Number.isFinite(i)||!Number.isFinite(r)||r<=i)throw new Error("Invalid FITS display range.");const a=this.locations.dataMin[e],n=this.locations.dataMax[e];a&&s.uniform1f(a,i),n&&s.uniform1f(n,r)}enableShaders(e,t,i,r){const s=this._webgl;s.useProgram(this.shaderProgram),this.locations.pMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_perspective),this.locations.mMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_model),this.locations.vMatrix=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.m_view),this.locations.clorMapIdx=s.getUniformLocation(this.shaderProgram,this.gl_uniforms.colormapIdx);for(let e=0;e<8;e++)this.locations.samplers[e]=s.getUniformLocation(this.shaderProgram,`uSampler${e}`),this.locations.textureAlpha[e]=s.getUniformLocation(this.shaderProgram,`uFactor${e}`),this.locations.textureMode[e]=s.getUniformLocation(this.shaderProgram,`uTextureMode${e}`),this.locations.dataMin[e]=s.getUniformLocation(this.shaderProgram,`uDataMin${e}`),this.locations.dataMax[e]=s.getUniformLocation(this.shaderProgram,`uDataMax${e}`),this.locations.samplers[e]&&s.uniform1i(this.locations.samplers[e],e);if(s.uniform1i(this.locations.clorMapIdx,r),this.locations.vertexPositionAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.vertex_pos),this.locations.textureCoordAttribute=s.getAttribLocation(this.shaderProgram,this.gl_attributes.text_coords),r>=2&&this._UBO_colorMapBuffer&&null!==this._colorMapBlockIndex){let e;if(s.uniformBlockBinding(this.shaderProgram,this._colorMapBlockIndex,0),s.bindBuffer(s.UNIFORM_BUFFER,this._UBO_colorMapBuffer),2===r?e={r:o.ColorMaps.planck.r,g:o.ColorMaps.planck.g,b:o.ColorMaps.planck.b}:3===r?e={r:o.ColorMaps.cmb.r,g:o.ColorMaps.cmb.g,b:o.ColorMaps.cmb.b}:4===r?e={r:o.ColorMaps.rainbow.r,g:o.ColorMaps.rainbow.g,b:o.ColorMaps.rainbow.b}:5===r?e={r:o.ColorMaps.eosb.r,g:o.ColorMaps.eosb.g,b:o.ColorMaps.eosb.b}:6===r?e={r:o.ColorMaps.cubehelix.r,g:o.ColorMaps.cubehelix.g,b:o.ColorMaps.cubehelix.b}:7===r?e={r:o.ColorMaps.hot.r,g:o.ColorMaps.hot.g,b:o.ColorMaps.hot.b}:8===r&&(e={r:o.ColorMaps.gray.r,g:o.ColorMaps.gray.g,b:o.ColorMaps.gray.b}),e||(e=this._runtimeColorMap),e){const t=this._UBO_colorMapVariableInfo;s.bufferSubData(s.UNIFORM_BUFFER,t.r_palette.offset,e.r,0),s.bufferSubData(s.UNIFORM_BUFFER,t.g_palette.offset,e.g,0),s.bufferSubData(s.UNIFORM_BUFFER,t.b_palette.offset,e.b,0)}s.bindBuffer(s.UNIFORM_BUFFER,null)}s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t)}}},2257(e,t){"use strict";t.MeshHiPSShaderProgram=void 0;t.MeshHiPSShaderProgram=class{_webgl;_options;locations;_shaderProgram;constructor(e,t={}){this._webgl=e,this._options=t,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,color:null,vertexPositionAttribute:-1,vertexNormalAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create MeshHiPS shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}enableShaders(e,t,i,r){const s=this._webgl,o=this.shaderProgram;s.useProgram(o),this.locations.pMatrix=s.getUniformLocation(o,"uPMatrix"),this.locations.vMatrix=s.getUniformLocation(o,"uVMatrix"),this.locations.mMatrix=s.getUniformLocation(o,"uMMatrix"),this.locations.color=s.getUniformLocation(o,"uColor"),this.locations.vertexPositionAttribute=s.getAttribLocation(o,"aVertexPosition"),this.locations.vertexNormalAttribute=s.getAttribLocation(o,"aVertexNormal"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniform4fv(this.locations.color,r)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n precision mediump float;\n in vec3 aVertexPosition;\n in vec3 aVertexNormal;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec3 vNormal;\n void main(void) {\n vec3 worldPos = (uMMatrix * vec4(aVertexPosition, 1.0)).xyz;\n vNormal = normalize((uMMatrix * vec4(aVertexNormal, 0.0)).xyz);\n gl_Position = uPMatrix * uVMatrix * vec4(worldPos, 1.0);\n }"),i=this.compileShader(e.FRAGMENT_SHADER,`#version 300 es\n precision mediump float;\n in vec3 vNormal;\n uniform vec4 uColor;\n out vec4 outColor;\n void main(void) {\n vec3 normal = normalize(vNormal);\n vec3 lightDir = normalize(vec3(0.45, 0.8, 0.35));\n float diffuse = ${this._options.twoSidedLighting?"abs(dot(normal, lightDir))":"max(dot(normal, lightDir), 0.0)"};\n float rim = pow(1.0 - max(dot(normal, vec3(0.0, 0.0, 1.0)), 0.0), 2.0);\n vec3 color = ${this._options.markerLighting?"uColor.rgb * (0.78 + diffuse * 0.18) + vec3(0.06, 0.08, 0.07) * rim":"uColor.rgb * (0.24 + diffuse * 0.78) + vec3(0.16, 0.24, 0.20) * rim"};\n outColor = vec4(color, uColor.a);\n }`);if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,i),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise MeshHiPS shaders")}compileShader(e,t){const i=this._webgl,r=i.createShader(e);if(!r)throw new Error("Could not create MeshHiPS shader");if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(r)||"MeshHiPS shader compile error");return r}}},5947(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class i{static catalogueVS(){return"#version 300 es\n in vec4 aCatPosition;\n in float a_selected;\n in float a_pointsize;\n in float a_brightness;\n\n out float v_selected;\n out float v_brightness;\n out lowp vec4 vColor; // not used\n\n uniform mat4 uPMatrix;\n uniform mat4 uMVMatrix;\n\n void main() {\n\n gl_Position = (uPMatrix * uMVMatrix * aCatPosition);\n gl_PointSize = a_pointsize;\n v_selected = a_selected;\n v_brightness = a_brightness;\n }"}static catalogueFS(){return"#version 300 es\n precision mediump float;\n \n #ifdef GL_OES_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n #endif\n\n // https://www.desultoryquest.com/blog/drawing-anti-aliased-circular-points-using-opengl-slash-webgl/\n\n // precision mediump float;\n\n in float v_selected;\n in float v_brightness;\n\n uniform vec4 u_fragcolor;\n\n out vec4 fragColor;\n\n // varying float v_selected;\n // varying float v_brightness;\n\n const float EPSILON = 1e-10;\n \n vec3 RGBtoHCV(in vec3 rgb) {\n // RGB [0..1] to Hue-Chroma-Value [0..1]\n // Based on work by Sam Hocevar and Emil Persson\n vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1., 2. / 3.) : vec4(rgb.gb, 0., -1. / 3.);\n vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);\n float c = q.x - min(q.w, q.y);\n float h = abs((q.w - q.y) / (6. * c + EPSILON) + q.z);\n return vec3(h, c, q.x);\n }\n\n vec3 RGBtoHSL(in vec3 rgb) {\n // RGB [0..1] to Hue-Saturation-Lightness [0..1]\n vec3 hcv = RGBtoHCV(rgb);\n //vec3 hcv = vec3(1., 1., 1.);\n float z = hcv.z - hcv.y * 0.5;\n float s = hcv.y / (1. - abs(z * 2. - 1.) + EPSILON);\n return vec3(hcv.x, s, z);\n }\n\n vec3 HUEtoRGB(in float hue){\n // Hue [0..1] to RGB [0..1]\n // See http://www.chilliant.com/rgb2hsv.html\n vec3 rgb = abs(hue * 6. - vec3(3, 2, 4)) * vec3(1, -1, -1) + vec3(-1, 2, 2);\n return clamp(rgb, 0., 1.);\n }\n\n vec3 HSLtoRGB(in vec3 hsl) {\n // Hue-Saturation-Lightness [0..1] to RGB [0..1]\n vec3 rgb = HUEtoRGB(hsl.x);\n float c = (1. - abs(2. * hsl.z - 1.)) * hsl.y;\n return (rgb - 0.5) * c + hsl.z;\n }\n \n void main() {\n\n float r = 0.0, delta = 0.0, alpha = 1.0;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n r = dot(cxy, cxy);\n if (r > 1.0) {\n discard;\n }\n\n #ifdef GL_OES_standard_derivatives\n delta = fwidth(r);\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n #endif\n\n if (v_selected == 1.0){\n // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 0.0, 0.0, 1.0) * (alpha);\n } else if (v_selected == 2.0){\n // gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n fragColor = vec4(1.0, 1.0, 0.0, 1.0) * (alpha);\n }else{\n if (r < 0.4) {\n discard;\n }\n if ( v_brightness >= -1.0 && v_brightness <= 1.0) {\n // Round-trip RGB->HSL->RGB with time-dependent lightness\n vec3 hsl = RGBtoHSL(vec3(u_fragcolor));\n //hsl.z = pow(hsl.z, sin(iTime) + 1.5);\n // hsl.z = pow(hsl.z, v_brightness + 1.5);\n hsl.z = pow(hsl.z, v_brightness + 1.5);\n vec3 hslcolor = HSLtoRGB(hsl);\n // gl_FragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n fragColor = vec4(hslcolor, u_fragcolor[3]) * (alpha);\n } else {\n // gl_FragColor = u_fragcolor * (alpha);\n fragColor = u_fragcolor * (alpha);\n }\n }\n }"}static footprintVS(){return"#version 300 es\n precision highp float;\n\n layout(location = 0) in vec4 aCatPosition;\n\n uniform float u_pointsize;\n uniform mat4 uMVMatrix;\n uniform mat4 uPMatrix;\n\n void main() {\n gl_Position = uPMatrix * uMVMatrix * aCatPosition;\n gl_PointSize = u_pointsize; // Works in WebGL2\n }"}static footprintFS(){return"#version 300 es\n precision mediump float;\n\n uniform vec4 u_fragcolor;\n out vec4 fragColor;\n\n void main() {\n fragColor = u_fragcolor;\n }"}static hipsVS(){return"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n\n uniform mat4 uMMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uPMatrix;\n\n out vec2 vTextureCoord;\n\n void main() {\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n vTextureCoord = aTextureCoord;\n }"}static hipsNativeFS(){return`#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n finalColor +=\n sampleHiPSTexture0(vTextureCoord).rgb * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n finalColor +=\n sampleHiPSTexture1(vTextureCoord).rgb * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n finalColor +=\n sampleHiPSTexture2(vTextureCoord).rgb * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n finalColor +=\n sampleHiPSTexture3(vTextureCoord).rgb * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n finalColor +=\n sampleHiPSTexture4(vTextureCoord).rgb * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n finalColor +=\n sampleHiPSTexture5(vTextureCoord).rgb * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n finalColor +=\n sampleHiPSTexture6(vTextureCoord).rgb * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n finalColor +=\n sampleHiPSTexture7(vTextureCoord).rgb * uFactor7;\n }\n\n fragColor = vec4(finalColor, 1.0);\n }`}static hipsGrayscaleFS(){return`#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n vec4 color0 = sampleHiPSTexture0(vTextureCoord);\n\n float gray =\n 0.21 * color0.r +\n 0.71 * color0.g +\n 0.07 * color0.b;\n\n finalColor =\n color0.rgb * (1.0 - uFactor0) +\n vec3(gray) * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n vec4 color1 = sampleHiPSTexture1(vTextureCoord);\n finalColor += color1.rgb * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n vec4 color2 = sampleHiPSTexture2(vTextureCoord);\n finalColor += color2.rgb * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n vec4 color3 = sampleHiPSTexture3(vTextureCoord);\n finalColor += color3.rgb * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n vec4 color4 = sampleHiPSTexture4(vTextureCoord);\n finalColor += color4.rgb * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n vec4 color5 = sampleHiPSTexture5(vTextureCoord);\n finalColor += color5.rgb * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n vec4 color6 = sampleHiPSTexture6(vTextureCoord);\n finalColor += color6.rgb * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n vec4 color7 = sampleHiPSTexture7(vTextureCoord);\n finalColor += color7.rgb * uFactor7;\n }\n\n fragColor = vec4(finalColor, 1.0);\n }`}static hipsColorMapFS(){return`#version 300 es\n precision mediump float;\n\n in vec2 vTextureCoord;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n uniform float uFactor0;\n uniform float uFactor1;\n uniform float uFactor2;\n uniform float uFactor3;\n uniform float uFactor4;\n uniform float uFactor5;\n uniform float uFactor6;\n uniform float uFactor7;\n\n ${i.hipsSamplersGLSL()}\n\n out vec4 fragColor;\n\n vec3 applyColorMap(vec4 color) {\n int x = int(clamp(color.r, 0.0, 1.0) * 255.0);\n int y = int(clamp(color.g, 0.0, 1.0) * 255.0);\n int z = int(clamp(color.b, 0.0, 1.0) * 255.0);\n\n float px = r_palette[x] / 256.0;\n float py = g_palette[y] / 256.0;\n float pz = b_palette[z] / 256.0;\n\n return vec3(px, py, pz);\n }\n\n void main() {\n vec3 finalColor = vec3(0.0);\n\n if (uFactor0 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture0(vTextureCoord)\n ) * uFactor0;\n }\n\n if (uFactor1 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture1(vTextureCoord)\n ) * uFactor1;\n }\n\n if (uFactor2 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture2(vTextureCoord)\n ) * uFactor2;\n }\n\n if (uFactor3 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture3(vTextureCoord)\n ) * uFactor3;\n }\n\n if (uFactor4 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture4(vTextureCoord)\n ) * uFactor4;\n }\n\n if (uFactor5 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture5(vTextureCoord)\n ) * uFactor5;\n }\n\n if (uFactor6 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture6(vTextureCoord)\n ) * uFactor6;\n }\n\n if (uFactor7 >= 0.0) {\n finalColor +=\n applyColorMap(\n sampleHiPSTexture7(vTextureCoord)\n ) * uFactor7;\n }\n\n fragColor = vec4(finalColor, 1.0);\n }`}static hipsSamplerGLSL(e){return`\n uniform sampler2D uSampler${e};\n uniform int uTextureMode${e};\n uniform float uDataMin${e};\n uniform float uDataMax${e};\n\n vec4 sampleHiPSTexture${e}(vec2 uv) {\n vec4 color = texture(uSampler${e}, uv);\n\n // JPG / PNG\n if (uTextureMode${e} == 0) {\n return color;\n }\n\n // FITS physical value stored in red channel\n float value = color.r;\n\n if (isnan(value)) {\n discard;\n }\n\n float normalized = clamp(\n (value - uDataMin${e}) /\n (uDataMax${e} - uDataMin${e}),\n 0.0,\n 1.0\n );\n\n return vec4(\n normalized,\n normalized,\n normalized,\n 1.0\n );\n }\n `}static hipsSamplersGLSL(){return Array.from({length:8},(e,t)=>i.hipsSamplerGLSL(t)).join("\n")}}t.default=i},149(e,t,i){"use strict";t.XYZShaderProgram=void 0;const r=i(619);t.XYZShaderProgram=class{locations;_webgl;_shaderProgram;_colorMapBlockIndex=null;_colorMapBuffer=null;_runtimeColorMap;_colorMapVariableInfo={r_palette:{index:0,offset:0},g_palette:{index:0,offset:0},b_palette:{index:0,offset:0}};constructor(e){this._webgl=e,this.locations={pMatrix:null,mMatrix:null,vMatrix:null,sampler:null,colorMapIdx:null,vertexPositionAttribute:-1,textureCoordAttribute:-1}}get shaderProgram(){const e=this._webgl;if(!this._shaderProgram){const t=e.createProgram();if(!t)throw new Error("Could not create XYZ shader program");this._shaderProgram=t,this.initShaders()}return e.useProgram(this._shaderProgram),this._shaderProgram}enableProgram(){this._webgl.useProgram(this.shaderProgram)}setRuntimeColorMap(e){this._runtimeColorMap=e}enableShaders(e,t,i,r=0){const s=this._webgl,o=this.shaderProgram;s.useProgram(o),this.locations.pMatrix=s.getUniformLocation(o,"uPMatrix"),this.locations.mMatrix=s.getUniformLocation(o,"uMMatrix"),this.locations.vMatrix=s.getUniformLocation(o,"uVMatrix"),this.locations.sampler=s.getUniformLocation(o,"uSampler"),this.locations.colorMapIdx=s.getUniformLocation(o,"cmapIdx"),this.locations.vertexPositionAttribute=s.getAttribLocation(o,"aVertexPosition"),this.locations.textureCoordAttribute=s.getAttribLocation(o,"aTextureCoord"),s.uniformMatrix4fv(this.locations.pMatrix,!1,e),s.uniformMatrix4fv(this.locations.vMatrix,!1,t),s.uniformMatrix4fv(this.locations.mMatrix,!1,i),s.uniform1i(this.locations.sampler,0),s.uniform1i(this.locations.colorMapIdx,r),r>=2&&this.uploadColorMap(r)}initShaders(){const e=this._webgl,t=this.compileShader(e.VERTEX_SHADER,"#version 300 es\n in vec3 aVertexPosition;\n in vec2 aTextureCoord;\n uniform mat4 uPMatrix;\n uniform mat4 uVMatrix;\n uniform mat4 uMMatrix;\n out vec2 vTextureCoord;\n void main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);\n }"),i=this.compileShader(e.FRAGMENT_SHADER,"#version 300 es\n precision mediump float;\n in vec2 vTextureCoord;\n uniform sampler2D uSampler;\n uniform int cmapIdx;\n\n layout (std140) uniform colormap {\n float r_palette[256];\n float g_palette[256];\n float b_palette[256];\n };\n\n out vec4 outColor;\n\n void main(void) {\n vec4 color = texture(uSampler, vTextureCoord);\n\n if (cmapIdx == 1) {\n float gray = 0.21 * color.r + 0.71 * color.g + 0.07 * color.b;\n outColor = vec4(vec3(gray), color.a);\n return;\n }\n\n if (cmapIdx >= 2) {\n int rIndex = int(clamp(color.r * 255.0, 0.0, 255.0));\n int gIndex = int(clamp(color.g * 255.0, 0.0, 255.0));\n int bIndex = int(clamp(color.b * 255.0, 0.0, 255.0));\n\n outColor = vec4(\n r_palette[rIndex] / 256.0,\n g_palette[gIndex] / 256.0,\n b_palette[bIndex] / 256.0,\n color.a\n );\n return;\n }\n\n outColor = color;\n }");if(e.attachShader(this._shaderProgram,t),e.attachShader(this._shaderProgram,i),e.linkProgram(this._shaderProgram),!e.getProgramParameter(this._shaderProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._shaderProgram)||"Could not initialise XYZ shaders");this.initColorMapBuffer()}compileShader(e,t){const i=this._webgl,r=i.createShader(e);if(!r)throw new Error("Could not create XYZ shader");if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(r)||"XYZ shader compile error");return r}initColorMapBuffer(){const e=this._webgl,t=this._shaderProgram,i=e.getUniformBlockIndex(t,"colormap");if(i===e.INVALID_INDEX)return void(this._colorMapBlockIndex=null);this._colorMapBlockIndex=i;const r=["r_palette","g_palette","b_palette"],s=e.getUniformIndices(t,r),o=e.getActiveUniforms(t,s,e.UNIFORM_OFFSET);r.forEach((e,t)=>{this._colorMapVariableInfo[e]={index:s[t],offset:o[t]}}),this._colorMapBuffer=e.createBuffer(),e.bindBuffer(e.UNIFORM_BUFFER,this._colorMapBuffer),e.bufferData(e.UNIFORM_BUFFER,12288,e.STATIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,0,this._colorMapBuffer),e.uniformBlockBinding(t,i,0)}uploadColorMap(e){if(!this._colorMapBuffer||null===this._colorMapBlockIndex)return;const t=this.getColorMap(e);if(!t)return;const i=this._webgl,r=this.shaderProgram;i.uniformBlockBinding(r,this._colorMapBlockIndex,0),i.bindBuffer(i.UNIFORM_BUFFER,this._colorMapBuffer);const s=this._colorMapVariableInfo;i.bufferSubData(i.UNIFORM_BUFFER,s.r_palette.offset,t.r,0),i.bufferSubData(i.UNIFORM_BUFFER,s.g_palette.offset,t.g,0),i.bufferSubData(i.UNIFORM_BUFFER,s.b_palette.offset,t.b,0),i.bindBuffer(i.UNIFORM_BUFFER,null)}getColorMap(e){switch(e){case 2:return r.ColorMaps.planck;case 3:return r.ColorMaps.cmb;case 4:return r.ColorMaps.rainbow;case 5:return r.ColorMaps.eosb;case 6:return r.ColorMaps.cubehelix;case 7:return r.ColorMaps.hot;case 8:return r.ColorMaps.gray;default:return this._runtimeColorMap}}}},8145(e,t){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsType=void 0,function(e){e.CARTESIAN="cartesian",e.SPHERICAL="spherical",e.ASTRO="astro",e.GEOGRAPHIC="geographic"}(i||(t.CoordsType=i={}))},8083(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FoVUtils=void 0;const s=i(6553),o=r(i(4639)),a=i(8145),n=i(3890);class l{getMinFoV(){return this._fovY_deg<=this._fovX_deg?this._fovY_deg:this._fovX_deg}static getFoVPolygon(e,t,i,r,s,a){const h=e.getCameraMatrix(),c=i.getModelMatrix(),u=t.clientWidth,d=t.clientHeight;let g=[];if(o.default.getIntersectionPointWithSingleModel(0,0,r,s,e,a).length>0){g=l.getScreenCornersIntersection(a,e,t,r,s)}else{let t=n.mat4.create();t=n.mat4.multiply(t,h,c),t=n.mat4.multiply(t,a,t);const i=[t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]],_=[t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]],p=[t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]],f=[t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]],m=o.default.getIntersectionPointWithSingleModel(u/2,0,r,s,e,a),x=o.default.getIntersectionPointWithSingleModel(u,d/2,r,s,e,a);if(0===m.length&&0===x.length){const e=l.getNearestSpherePoint(i),t=l.getNearestSpherePoint(_),r=l.getNearestSpherePoint(f),s=l.getNearestSpherePoint(p),o=l.computeMiddlePoint(r[0],e[0])[0],a=l.computeMiddlePoint(e[0],s[0])[0],n=l.computeMiddlePoint(s[0],t[0])[0],h=l.computeMiddlePoint(t[0],r[0])[0];g.push(e[0],a,s[0],n,t[0],h,r[0],o)}else if(0===m.length){const e=l.getNearestSpherePoint(i),r=l.getNearestSpherePoint(_),s=l.getFrustumIntersectionWithSphere(t,f,_,i),o=l.getFrustumIntersectionWithSphere(t,p,i,_),a=l.computeMiddlePoint(s[1],e[0])[0],n=l.computeMiddlePoint(e[0],o[0])[0],h=l.computeMiddlePoint(o[1],r[0])[0],c=l.computeMiddlePoint(r[0],s[0])[0];g.push(e[0],n,o[0],o[1],h,r[0],c,s[0],s[1],a)}else if(0===x.length){const e=l.getFrustumIntersectionWithSphere(t,i,f,p),r=l.getFrustumIntersectionWithSphere(t,_,p,f),s=l.getNearestSpherePoint(f),o=l.getNearestSpherePoint(p),a=l.computeMiddlePoint(s[0],e[0])[0],n=l.computeMiddlePoint(e[1],o[0])[0],h=l.computeMiddlePoint(o[0],r[0])[0],c=l.computeMiddlePoint(r[1],s[0])[0];g.push(e[0],e[1],n,o[0],h,r[0],r[1],c,s[0],a)}else{const e=l.getFrustumIntersectionWithSphere(t,i,f,p),r=l.getFrustumIntersectionWithSphere(t,_,p,f),s=l.getFrustumIntersectionWithSphere(t,f,_,i),o=l.getFrustumIntersectionWithSphere(t,p,i,_);g.push(e[0],e[1],o[0],o[1],r[0],r[1],s[0],s[1])}}return g}static getScreenCornersIntersection(e,t,i,r,n){const l=i.clientWidth,h=i.clientHeight,c=o.default.getIntersectionPointWithSingleModel(0,0,r,n,t,e),u=o.default.getIntersectionPointWithSingleModel(l/2,0,r,n,t,e),d=o.default.getIntersectionPointWithSingleModel(l,0,r,n,t,e),g=o.default.getIntersectionPointWithSingleModel(l,h/2,r,n,t,e),_=o.default.getIntersectionPointWithSingleModel(l,h,r,n,t,e),p=o.default.getIntersectionPointWithSingleModel(l/2,h,r,n,t,e),f=o.default.getIntersectionPointWithSingleModel(0,h,r,n,t,e),m=o.default.getIntersectionPointWithSingleModel(0,h/2,r,n,t,e),x=[],b=e=>{e.length>0&&x.push(new s.Point({x:e[0],y:e[1],z:e[2]},a.CoordsType.CARTESIAN))};return b(c),b(u),b(d),b(g),b(_),b(p),b(f),b(m),x}static getCenterJ2000(e,t,i,r,n){const l=e.clientWidth,h=e.clientHeight,c=o.default.getIntersectionPointWithSingleModel(l/2,h/2,t,i,r,n);if(c.length<=0)throw Error("Central point is null");return new s.Point({x:c[0],y:c[1],z:c[2]},a.CoordsType.CARTESIAN)}static computeMiddlePoint(e,t){const i=(e.x+t.x)/2,r=(e.y+t.y)/2,o=(e.z+t.z)/2,n=Math.hypot(i,r,o)||1,l=i/n,h=r/n,c=o/n;return[new s.Point({x:l,y:h,z:c},a.CoordsType.CARTESIAN)]}static getNearestSpherePoint(e){const[t,i,r,o]=e,n=1/Math.sqrt(t*t+i*i+r*r),l=1*n,h=-1*n,c=[t*l,i*l,r*l],u=[t*h,i*h,r*h],d=Math.sqrt(t*t+i*i+r*r)||1,g=Math.abs(t*c[0]+i*c[1]+r*c[2]+o)/d<=Math.abs(t*u[0]+i*u[1]+r*u[2]+o)/d?c:u;return[new s.Point({x:g[0],y:g[1],z:g[2]},a.CoordsType.CARTESIAN)]}static getFrustumIntersectionWithSphere(e,t,i,r){const[o,n,l,h]=t,c=o*o+n*n+l*l||1,u=-o*h/c,d=-n*h/c,g=-l*h/c,_=Math.abs(h)/Math.sqrt(c),p=[];if(1>_){const e=Math.sqrt(1-_*_),t=t=>{const[i,r,s,o]=t,a=1/Math.sqrt(i*i+r*r+s*s),n=e*a,l=-e*a,h=[u+i*n,d+r*n,g+s*n],c=[u+i*l,d+r*l,g+s*l],_=Math.sqrt(i*i+r*r+s*s)||1;return Math.abs(i*h[0]+r*h[1]+s*h[2]+o)/_<=Math.abs(i*c[0]+r*c[1]+s*c[2]+o)/_?h:c},o=t(i),n=t(r);p.push(new s.Point({x:o[0],y:o[1],z:o[2]},a.CoordsType.CARTESIAN),new s.Point({x:n[0],y:n[1],z:n[2]},a.CoordsType.CARTESIAN))}else 1===_&&p.push(new s.Point({x:u,y:d,z:g},a.CoordsType.CARTESIAN),new s.Point({x:u,y:d,z:g},a.CoordsType.CARTESIAN));return p}static getAstroFoVPolygon(e){return e.map(e=>e.toADQL()).join(",")}}t.FoVUtils=l},8755(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(8145),s=i(6553);class o{static isGeoJSON(e){if(!e||"object"!=typeof e)return!1;const t=e.type;return"FeatureCollection"===t||"Feature"===t||"Polygon"===t||"MultiPolygon"===t||"GeometryCollection"===t}static parseGeoJSON(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON root must be an object");const t=e;if("FeatureCollection"===t.type){if(!Array.isArray(t.features))throw new Error("GeoJSON FeatureCollection has no features array");return t.features.flatMap(e=>o.parseFeature(e))}if("Feature"===t.type)return o.parseFeature(t);if("Polygon"===t.type||"MultiPolygon"===t.type||"GeometryCollection"===t.type)return o.parseGeometry(t,{});throw new Error(`Unsupported GeoJSON type: ${t.type??"unknown"}`)}static parseFeature(e){if(!e||"object"!=typeof e)throw new Error("GeoJSON feature must be an object");const t=e;if("Feature"!==t.type)throw new Error("GeoJSON feature has invalid type");return t.geometry?o.parseGeometry(t.geometry,t.properties??{},t.id):[]}static parseGeometry(e,t,i){return"Polygon"===e.type?[{id:i,geometryType:"Polygon",properties:t,polygons:o.parsePolygonCoordinates(e.coordinates)}]:"MultiPolygon"===e.type?[{id:i,geometryType:"MultiPolygon",properties:t,polygons:o.parseMultiPolygonCoordinates(e.coordinates)}]:"GeometryCollection"===e.type&&Array.isArray(e.geometries)?e.geometries.flatMap(e=>o.parseGeometry(e,t,i)):[]}static parseMultiPolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON MultiPolygon coordinates must be an array");return e.flatMap(e=>o.parsePolygonCoordinates(e))}static parsePolygonCoordinates(e){if(!Array.isArray(e))throw new Error("GeoJSON Polygon coordinates must be an array");return e.map(e=>o.parseLinearRing(e)).filter(e=>e.length>=3)}static parseLinearRing(e){if(!Array.isArray(e))throw new Error("GeoJSON linear ring must be an array");const t=e.map(e=>o.parsePosition(e));if(t.length>1){const e=t[0],i=t[t.length-1];e.lonDeg===i.lonDeg&&e.latDeg===i.latDeg&&t.pop()}return t}static parsePosition(e){if(!Array.isArray(e)||e.length<2)throw new Error("GeoJSON position must be [longitude, latitude]");const[t,i]=e;if(!Number.isFinite(t)||!Number.isFinite(i))throw new Error("GeoJSON position contains non-finite longitude/latitude");return new s.Point({lonDeg:t,latDeg:i},r.CoordsType.GEOGRAPHIC)}}t.default=o},2930(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),o=r(i(7559)),a=i(8145);class n{static orthodromicDistance(e,t){return Math.acos(Math.sin(e.decDeg*Math.PI/180)*Math.sin(t.decDeg*Math.PI/180)+Math.cos(e.decDeg*Math.PI/180)*Math.cos(t.decDeg*Math.PI/180)*Math.cos((t.raDeg-e.raDeg)*Math.PI/180))}static computeSelectionObject(e){let t,i,r,s,a=[],l=0;let h=0;if(e[0][0].decDeg>=10?h=1:e[0][0].decDeg<=-10?h=-1:l=1,0===l){const o=n.projectIn2D(e[0][0]);t=r=o.x,i=s=o.y;for(const o of e){const e=[];for(const c of o){if(c.decDeg>10*h&&-1===h||c.decDeg<10*h&&1===h){l=1,a=[];break}const o=n.projectIn2D(c);e.push(o),o.x>t&&(t=o.x),o.y>i&&(i=o.y),o.x<r&&(r=o.x),o.y<s&&(s=o.y)}a.push(e)}}if(0===l)return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s};const c=180;let u=e[0][0].raDeg<c;t=r=e[0][0].raDeg,i=s=e[0][0].decDeg;for(const n of e){const e=[];for(const h of n){const n=new o.default(h.raDeg,h.decDeg);if(e.push(n),h.raDeg>t&&(t=h.raDeg),h.decDeg>i&&(i=h.decDeg),h.raDeg<r&&(r=h.raDeg),h.decDeg<s&&(s=h.decDeg),h.raDeg>=c&&u||h.raDeg<=c&&!u){l=2,a=[];break}}a.push(e)}if(1===l)return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s};let d=e[0][0].raDeg;t=d>=c?d-360:d,i=e[0][0].decDeg,r=t,s=i;for(const n of e){const e=[];for(const a of n){const n=a.raDeg>=c?a.raDeg-360:a.raDeg;n>t&&(t=n),a.decDeg>i&&(i=a.decDeg),n<r&&(r=n),a.decDeg<s&&(s=a.decDeg),e.push(new o.default(n,a.decDeg))}a.push(e)}return{poly4selection:a,flag:l,maxx:t,maxy:i,minx:r,miny:s}}static stereographic(e){const t=Number(e.xyz[0]),i=Number(e.xyz[1]),r=Number(e.xyz[2]);return{x:2*t/(1-r),y:2*i/(1-r)}}static projectIn2D(e){const t=n.stereographic(e);return new o.default(t.x,t.y)}static checkPointInsidePolygon5(e,t){let i;if(0===e.flag)i=n.projectIn2D(t);else if(1===e.flag)i=new o.default(t.raDeg,t.decDeg);else{const e=180,r=t.raDeg>=e?t.raDeg-360:t.raDeg;i=new o.default(r,t.decDeg)}const r=new o.default(i.x,i.y+2*Math.abs(e.maxy-e.miny));if(i.x>e.maxx||i.x<e.minx||i.y>e.maxy||i.y<e.miny)return!1;for(const t of e.poly4selection){let e=0;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],n=(a.y-o.y)*(r.x-i.x)-(a.x-o.x)*(r.y-i.y),l=(a.x-o.x)*(i.y-o.y)-(a.y-o.y)*(i.x-o.x),h=(r.x-i.x)*(i.y-o.y)-(r.y-i.y)*(i.x-o.x);if(0!==n){const t=l/n,i=h/n;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const s=t[t.length-1],o=t[0],a=(o.y-s.y)*(r.x-i.x)-(o.x-s.x)*(r.y-i.y),n=(o.x-s.x)*(i.y-s.y)-(o.y-s.y)*(i.x-s.x),l=(r.x-i.x)*(i.y-s.y)-(r.y-i.y)*(i.x-s.x);if(0!==a){const t=n/a,i=l/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}static checkPointInsidePolygon4(e,t){const i=n.projectIn2D(t);let r=t.raDeg+15;r>360&&(r=t.raDeg-15);const o=new s.Point({raDeg:r,decDeg:t.decDeg},a.CoordsType.ASTRO),l=n.projectIn2D(o);for(const t of e){let e=0;for(let r=0;r<t.length-1;r++){const s=n.projectIn2D(t[r]),o=n.projectIn2D(t[r+1]),a=(o.y-s.y)*(l.x-i.x)-(o.x-s.x)*(l.y-i.y),h=(o.x-s.x)*(i.y-s.y)-(o.y-s.y)*(i.x-s.x),c=(l.x-i.x)*(i.y-s.y)-(l.y-i.y)*(i.x-s.x);if(0!==a){const t=h/a,i=c/a;t>=0&&t<=1&&i>=0&&i<=1&&e++}}{const r=n.projectIn2D(t[t.length-1]),s=n.projectIn2D(t[0]),o=(s.y-r.y)*(l.x-i.x)-(s.x-r.x)*(l.y-i.y),a=(s.x-r.x)*(i.y-r.y)-(s.y-r.y)*(i.x-r.x),h=(l.x-i.x)*(i.y-r.y)-(l.y-i.y)*(i.x-r.x);if(0!==o){const t=a/o,i=h/o;t>=0&&t<=1&&i>=0&&i<=1&&e++}}if(e%2==1)return!0}return!1}}t.default=n},4396(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(3890),o=i(4851),a=r(i(4382)),n=i(7930);t.default=class{_xyz=null;_raDecDeg=null;_phiThetaDeg=null;raHMS;decDMS;constructor(e,t,i){null!=e&&(this._xyz=e),null!=t&&(this._raDecDeg=t),null!=i&&(this._phiThetaDeg=i),this._raDecDeg&&(this.raHMS=(0,n.raDegToHMS)(this._raDecDeg.ra),this.decDMS=(0,n.decDegToDMS)(this._raDecDeg.dec))}computeNpix(){if(!this._xyz)return null;const e=a.default.getHealpix(a.default.nsideForSelection),t=new o.Vec3(this._xyz[0],this._xyz[1],this._xyz[2]),i=new o.Pointing(t,!1);return e.ang2pix(i,!1)}update(e){const t=(i=e,Array.isArray(i)?s.vec3.fromValues(i[0],i[1],i[2]):i);var i;const r=(0,n.cartesianToSpherical)(t),o=(0,n.sphericalToAstroDeg)(r.phi,r.theta);this._xyz=[t[0],t[1],t[2]],this._phiThetaDeg=r,this._raDecDeg=o,this.raHMS=(0,n.raDegToHMS)(o.ra),this.decDMS=(0,n.decDegToDMS)(o.dec)}clear(){this._xyz=null,this._raDecDeg=null,this._phiThetaDeg=null,this.raHMS=void 0,this.decDMS=void 0}get xyz(){return this._xyz}get x(){return this._xyz?this._xyz[0]:null}get y(){return this._xyz?this._xyz[1]:null}get z(){return this._xyz?this._xyz[2]:null}get ra(){return this._raDecDeg?this._raDecDeg.ra:null}get dec(){return this._raDecDeg?this._raDecDeg.dec:null}get phi(){return this._phiThetaDeg?this._phiThetaDeg.phi:null}get theta(){return this._phiThetaDeg?this._phiThetaDeg.theta:null}get raDecDeg(){return this._raDecDeg}get phiThetaDeg(){return this._phiThetaDeg}}},9685(e,t,i){"use strict";t.PerspectiveMatrixManager=void 0;const r=i(3890),s=i(2919);t.PerspectiveMatrixManager=class{_pMatrix;_aspectRatio=1;constructor(e,t,i,r=.1,s){this._pMatrix=this.computePerspectiveMatrix(e,t,i,r,s)}get pMatrix(){return this._pMatrix}set pMatrix(e){this._pMatrix=e}computePerspectiveMatrix(e,t,i,o=.1,a){this._aspectRatio=e.width/e.height;const n=r.mat4.create();let l;if(a)l=1.1;else{const e=t.getCameraMatrix(),i=-Number(e[14]),r=1,s=Math.sqrt(Math.max(i**2-r**2,0)),o=Math.atan2(s,r),a=s*Math.sin(o);l=a>0?a:r}const h=a?s.bootSetup.inside_camera_fov_deg:i,c=a?Math.max(o,.001):o;return r.mat4.perspective(n,h*Math.PI/180,this._aspectRatio,c,l),this._pMatrix=n,n}}},4639(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(3890);class s{static lastNearestVisibleObjectIdx=-1;static getNearestVisibleObjectIdx(){return this.lastNearestVisibleObjectIdx}static getRayFromMouse(e,t,i,o,a){const n=o.canvas.getBoundingClientRect(),l=t,h=[2*e/n.width-1,1-2*l/n.height,-1,1],c=r.mat4.create();r.mat4.invert(c,i);const u=[0,0,0,0];s.mat4MultiplyVec4(c,h,u);const d=[u[0],u[1],-1,0],g=r.mat4.create();r.mat4.invert(g,a);const _=[0,0,0,0];s.mat4MultiplyVec4(g,d,_);const p=r.vec3.fromValues(_[0],_[1],_[2]);return r.vec3.normalize(p,p),p}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],o=t[2],a=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*o+e[12]*a,i[1]=e[1]*r+e[5]*s+e[9]*o+e[13]*a,i[2]=e[2]*r+e[6]*s+e[10]*o+e[14]*a,i[3]=e[3]*r+e[7]*s+e[11]*o+e[15]*a,i}static raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;t<0&&i<0||(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}static getIntersectionPointWithSingleModel(e,t,i,o,a,n){const l=a.getCameraMatrix(),h=s.getRayFromMouse(e,t,n,o,l),c=s.raySphere(a.getCameraPosition(),h,i);let u=[];if(c>=0){const e=r.vec3.create();r.vec3.scale(e,h,c),r.vec3.add(e,a.getCameraPosition(),e);const t=[e[0],e[1],e[2],1],o=[0,0,0,0];s.mat4MultiplyVec4(i.getModelMatrixInverse(),t,o),u=[o[0],o[1],o[2]]}return u}}t.default=s},9665(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(6553),o=i(8145),a=r(i(4382));class n{static parseSTCS(e,t={}){const i=n.cleanStcs(e);return i.includes("POLYGON")?n.parsePolygon(i,t):i.includes("CIRCLE")?n.parseCircle(i,t):(console.warn("STCS not recognised"),{totpoints:0,polygons:[]})}static cleanStcs(e){let t=e.toUpperCase();return t=t.replace(/'ICRS'/g,"").replace(/\bICRS\b/g,"").replace(/\bJ2000\b/g,"").replace(/\bUNION\b/g,"").replace(/\bTOPOCENTER\b/g,""),t=t.replace(/[()]/g,""),t=t.replace(/ {2,}/g," ").trim(),t}static parsePolygon(e,t={}){let i=0;const r=[],n=a.default.MAX_DECIMALS??12,l=t.coordsType??o.CoordsType.ASTRO,h=e.split("POLYGON ");for(let e=1;e<h.length;e++){const t=[],a=h[e].trim().split(" "),c=Number(parseFloat(a[0]).toFixed(n)),u=Number(parseFloat(a[1]).toFixed(n)),d=Number(parseFloat(a[a.length-2]).toFixed(n)),g=Number(parseFloat(a[a.length-1]).toFixed(n));if(c===d&&u===g&&a.splice(a.length-2,2),a.length>2){for(let e=0;e<a.length-1;e+=2){const r=Number(parseFloat(a[e]).toFixed(n)),h=Number(parseFloat(a[e+1]).toFixed(n)),c=l===o.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:h},o.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:h},o.CoordsType.ASTRO);t.push(c),i+=1}r.push(t)}}return{totpoints:i,polygons:r}}static parseCircle(e,t={}){let i=0;const r=[],a=t.coordsType??o.CoordsType.ASTRO,n=e.split("CIRCLE ");for(let e=1;e<n.length;e++){const t=[],l=n[e].trim().split(" "),h=Number(l[0]),c=Number(l[1]),u=Number(l[2]),d=4*6,g=2*Math.PI/d;for(let e=d;e>0;e--){const r=u*Math.cos(e*g)+h,n=u*Math.sin(e*g)+c,l=a===o.CoordsType.GEOGRAPHIC?new s.Point({lonDeg:r,latDeg:n},o.CoordsType.GEOGRAPHIC):new s.Point({raDeg:r,decDeg:n},o.CoordsType.ASTRO);t.push(l),i+=1}r.push(t)}return{totpoints:i,polygons:r}}}t.default=n},7930(e,t,i){"use strict";t.cartesianToSpherical=function(e){const t=r.vec3.dot(e,e),i=Math.sqrt(t);let s=Math.acos(e[2]/i);s=o(s);let a=Math.atan2(e[1],e[0]);a=o(a),a<0&&(a+=360);return{phi:a,theta:s}},t.colorHex2RGB=function(e){const t=e.substring(1,3),i=e.substring(3,5),r=e.substring(5,7),s=parseInt(t,16),o=parseInt(i,16),a=parseInt(r,16),n=(s/255).toFixed(2),l=(o/255).toFixed(2),h=(a/255).toFixed(2);return[parseFloat(n),parseFloat(l),parseFloat(h)]},t.degToRad=s,t.radToDeg=o,t.sphericalToAstroDeg=function(e,t){let i=e;i<0&&(i+=360);return{ra:i,dec:90-t}},t.sphericalToCartesian=function(e,t,i=1){const r=i*Math.sin(s(t))*Math.cos(s(e)),o=i*Math.sin(s(t))*Math.sin(s(e)),a=i*Math.cos(s(t));return[r,o,a]},t.astroDegToSpherical=function(e,t){let i=e;i<0&&(i+=360);return{phi:i,theta:90-t}},t.raDegToHMS=function(e){const t=Math.floor(e/15),i=Math.floor(60*(e/15-t));return{h:t,m:i,s:3600*(e/15-t-i/60)}},t.decDegToDMS=function(e){let t=1;e<0&&(t=-1);const i=Math.abs(e);let r=Math.trunc(i);const s=Math.trunc(60*(i-r)),o=3600*(i-r-s/60);return r*=t,{d:r,m:s,s:o}};const r=i(3890);function s(e){return e/180*Math.PI}function o(e){return 180*e/Math.PI}},2166(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(3890),s=85.0511287798066;class o{static getRayFromMouse(e,t,i,s,a){const n=s.canvas.getBoundingClientRect(),l=[2*e/n.width-1,1-2*t/n.height,-1,1],h=r.mat4.create();r.mat4.invert(h,i);const c=[0,0,0,0];o.mat4MultiplyVec4(h,l,c);const u=[c[0],c[1],-1,0],d=r.mat4.create();r.mat4.invert(d,a);const g=[0,0,0,0];o.mat4MultiplyVec4(d,u,g);const _=r.vec3.fromValues(g[0],g[1],g[2]);return r.vec3.normalize(_,_),_}static raySphere(e,t,i){let s=-1;const o=r.vec3.create();r.vec3.subtract(o,e,i.center);const a=r.vec3.dot(t,o),n=a*a-(r.vec3.dot(o,o)-i.radius*i.radius);if(n>0){const e=Math.sqrt(n),t=-a+e,i=-a-e;(t>=0||i>=0)&&(s=i<0?t:Math.min(t,i))}else if(0===n){const e=-a;e>=0&&(s=e)}return s}static getIntersectionPointWithModel(e,t,i,s,a,n){const l=a.getCameraMatrix(),h=o.getRayFromMouse(e,t,n,s,l),c=o.raySphere(a.getCameraPosition(),h,i);if(c<0)return null;const u=r.vec3.create();r.vec3.scale(u,h,c),r.vec3.add(u,a.getCameraPosition(),u);const d=[u[0],u[1],u[2],1],g=[0,0,0,0];return o.mat4MultiplyVec4(i.getModelMatrixInverse(),d,g),[g[0],g[1],g[2]]}static getLonLatFromMouse(e,t,i,r,s,a){const n=o.getIntersectionPointWithModel(e,t,i,r,s,a);return n?o.modelPointToLonLat(n):null}static getTileFromMouse(e,t,i,r,s,a,n){const l=o.getLonLatFromMouse(e,t,r,s,a,n);return l&&o.isMercatorLatitude(l.latDeg)?o.lonLatToTile(l.lonDeg,l.latDeg,i):null}static getVisibleTilesFromViewport(e,t,i,r,s,a=9,n=2){const l=i.canvas.getBoundingClientRect(),h=Math.max(2,Math.floor(a)),c=Math.max(2*h+1,21),u=Math.max(0,Math.floor(n)),d=[],g=(a,n)=>{const l=o.getTileFromMouse(a,n,e,t,i,r,s);l&&(d.push(l),d.push(...o.getNeighborTiles(l,u)))};for(let e=0;e<h;e++){const t=1===h?l.height/2:e/(h-1)*l.height;for(let e=0;e<h;e++){g(1===h?l.width/2:e/(h-1)*l.width,t)}}for(let e=0;e<c;e++){const t=1===c?.5:e/(c-1),i=t*l.width,r=t*l.height;g(i,0),g(i,l.height),g(0,r),g(l.width,r)}return o.fillSmallTileGaps(o.deduplicateTiles(d))}static modelPointToLonLat(e){const[t,i,r]=e,s=Math.hypot(t,i,r);if(!Number.isFinite(s)||0===s)return{lonDeg:0,latDeg:0};return{lonDeg:180*Math.atan2(i,t)/Math.PI,latDeg:180*Math.asin(Math.max(-1,Math.min(1,r/s)))/Math.PI}}static lonLatToTile(e,t,i){const r=Math.max(0,Math.floor(i)),s=2**r,a=Math.floor((e+180)/360*s),n=Math.floor(o.latToTileY(t,r));return{z:r,x:o.wrapTileX(a,s),y:o.clampTileY(n,s)}}static getNeighborTiles(e,t=1){const i=2**e.z,r=[],s=Math.max(0,Math.floor(t));for(let t=-s;t<=s;t++)for(let a=-s;a<=s;a++)r.push({z:e.z,x:o.wrapTileX(e.x+t,i),y:o.clampTileY(e.y+a,i)});return o.deduplicateTiles(r)}static deduplicateTiles(e){const t=new Map;for(const i of e)t.set(`${i.z}/${i.x}/${i.y}`,i);return Array.from(t.values())}static fillSmallTileGaps(e){if(0===e.length)return e;const t=e[0].z,i=2**t,r=new Map,s=e=>{r.set((e=>`${e.z}/${e.x}/${e.y}`)(e),e)},a=(e,s)=>s>=0&&s<i&&r.has(`${t}/${o.wrapTileX(e,i)}/${s}`);for(const t of e)s(t);for(const r of e){const e=r.x,n=r.y;a(e-2,n)&&!a(e-1,n)&&s({z:t,x:o.wrapTileX(e-1,i),y:n}),a(e+2,n)&&!a(e+1,n)&&s({z:t,x:o.wrapTileX(e+1,i),y:n}),a(e,n-2)&&!a(e,n-1)&&s({z:t,x:e,y:n-1}),a(e,n+2)&&!a(e,n+1)&&s({z:t,x:e,y:n+1})}return Array.from(r.values())}static latToTileY(e,t){const i=Math.max(-85.0511287798066,Math.min(s,e))*Math.PI/180,r=2**t;return(1-Math.asinh(Math.tan(i))/Math.PI)/2*r}static isMercatorLatitude(e){return Math.abs(e)<=s}static wrapTileX(e,t){return(e%t+t)%t}static clampTileY(e,t){return Math.max(0,Math.min(t-1,e))}static mat4MultiplyVec4(e,t,i){const r=t[0],s=t[1],o=t[2],a=t[3];return i[0]=e[0]*r+e[4]*s+e[8]*o+e[12]*a,i[1]=e[1]*r+e[5]*s+e[9]*o+e[13]*a,i[2]=e[2]*r+e[6]*s+e[10]*o+e[14]*a,i[3]=e[3]*r+e[7]*s+e[11]*o+e[15]*a,i}}t.default=o},7223(){},4851(e,t,i){"use strict";i.d(t,{Healpix:()=>m,Pointing:()=>s,Vec3:()=>r});class r{x;y;z;constructor(e,t,i){if(![e,t,i].every(Number.isFinite))throw new RangeError("Vec3 coordinates must be finite numbers.");this.x=e,this.y=t,this.z=i}getX(){return this.x}getY(){return this.y}getZ(){return this.z}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.lengthSquared())}normalize(){const e=this.length();if(0===e)throw new RangeError("Cannot normalize a zero-length vector.");return new r(this.x/e,this.y/e,this.z/e)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}}class s{theta;phi;constructor(e,t=!1,i,s){if(e){const i=new r(e.x,e.y,e.z).normalize();return this.theta=Math.atan2(Math.sqrt(i.x*i.x+i.y*i.y),i.z),void(this.phi=o(t?-Math.atan2(i.y,i.x):Math.atan2(i.y,i.x)))}if(!Number.isFinite(i)||!Number.isFinite(s))throw new RangeError("Pointing requires either a Vec3-like object or finite theta/phi radians.");this.theta=i,this.phi=o(s)}toVec3(){const e=Math.sin(this.theta);return new r(e*Math.cos(this.phi),e*Math.sin(this.phi),Math.cos(this.theta))}}function o(e){const t=2*Math.PI;return(e%t+t)%t}class a{r=[];append(e){this.appendRange(e,e+1)}appendRange(e,t){if(!Number.isInteger(e)||!Number.isInteger(t))throw new RangeError("RangeSet bounds must be integers.");if(!(e>=t))for(let i=e;i<t;i+=1)this.r.push(i)}toArray(){return[...this.r]}}const n=2/3,l=Math.PI/2,h=2*Math.PI,c=26,u=[2,2,2,2,3,3,3,3,4,4,4,4],d=[1,3,5,7,0,2,4,6,1,3,5,7],g=[-1,-1,0,1,1,1,0,-1],_=[0,1,1,1,0,-1,-1,-1],p=[[8,9,10,11,-1,-1,-1,-1,10,11,8,9],[5,6,7,4,8,9,10,11,9,10,11,8],[-1,-1,-1,-1,5,6,7,4,-1,-1,-1,-1],[4,5,6,7,11,8,9,10,11,8,9,10],[0,1,2,3,4,5,6,7,8,9,10,11],[1,2,3,0,0,1,2,3,5,6,7,4],[-1,-1,-1,-1,7,4,5,6,-1,-1,-1,-1],[3,0,1,2,3,0,1,2,4,5,6,7],[2,3,0,1,-1,-1,-1,-1,0,1,2,3]],f=[[0,0,3],[0,0,6],[0,0,0],[0,0,5],[0,0,0],[5,0,0],[0,0,0],[6,0,0],[3,0,0]];class m{nside;order;npix;constructor(e){if(!Number.isInteger(e)||e<=0)throw new RangeError("nside must be a positive integer.");const t=Math.log2(e);if(!Number.isInteger(t))throw new RangeError("nside must be a power of two.");if(t>c)throw new RangeError("nside order must be <= 26 for safe JavaScript integer arithmetic.");this.nside=e,this.order=t,this.npix=12*e*e}getNPix(){return this.npix}nside2order(e){if(!Number.isInteger(e)||e<=0)return-1;const t=Math.log2(e);return Number.isInteger(t)?t:-1}nest2xyf(e){this.assertPixel(e);const t=this.nside*this.nside,i=Math.floor(e/t),r=e%t;return{ix:b(r),iy:b(r>>1),face:i}}xyf2nest(e,t,i){if(!Number.isInteger(i)||i<0||i>=12)throw new RangeError("face must be an integer in [0, 11].");if(!Number.isInteger(e)||e<0||e>=this.nside)throw new RangeError("ix must be an integer in [0, nside).");if(!Number.isInteger(t)||t<0||t>=this.nside)throw new RangeError("iy must be an integer in [0, nside).");return i*this.nside*this.nside+x(e)+2*x(t)}ang2pix(e,t=!1){if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("pointing theta and phi must be finite radians.");if(e.theta<0||e.theta>Math.PI)throw new RangeError("pointing theta must be in [0, pi].");const i=Math.cos(e.theta),r=Math.abs(i),s=S(e.phi)/l;if(r<=n){const e=this.nside*(.5+s),t=this.nside*i*.75,r=Math.floor(e-t),o=Math.floor(e+t),a=Math.floor(r/this.nside),n=Math.floor(o/this.nside),l=a===n?4|a:a<n?a:n+8,h=v(o,this.nside),c=this.nside-v(r,this.nside)-1;return this.xyf2nest(h,c,l)}const o=Math.min(3,Math.floor(s)),a=s-o,h=Math.sin(e.theta),c=r<.99?this.nside*Math.sqrt(3*(1-r)):this.nside*h/Math.sqrt((1+r)/3),u=Math.min(this.nside-1,Math.floor(a*c)),d=Math.min(this.nside-1,Math.floor((1-a)*c));return i>=0?this.xyf2nest(this.nside-d-1,this.nside-u-1,o):this.xyf2nest(u,d,o+8)}pix2vec(e){return this.pix2ang(e).toVec3()}pix2ang(e,t=!1){const{z:i,phi:r}=this.pix2zphi(e),o=Math.acos(M(i,-1,1));return new s(null,t,o,r)}getBoundaries(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=.5/this.nside,o=(t+.5)/this.nside,a=(i+.5)/this.nside;return[this.faceLocalToVec3(o+s,a+s,r),this.faceLocalToVec3(o-s,a+s,r),this.faceLocalToVec3(o-s,a-s,r),this.faceLocalToVec3(o+s,a-s,r)]}getBoundariesWithStep(e,t){if(!Number.isInteger(t)||t<=0)throw new RangeError("step must be a positive integer.");const{ix:i,iy:r,face:s}=this.nest2xyf(e),o=.5/this.nside,a=(i+.5)/this.nside,n=(r+.5)/this.nside,l=1/(this.nside*t),h=new Array(4*t);for(let e=0;e<t;e+=1)h[e]=this.faceLocalToVec3(a+o-e*l,n+o,s),h[e+t]=this.faceLocalToVec3(a-o,n+o-e*l,s),h[e+2*t]=this.faceLocalToVec3(a-o+e*l,n-o,s),h[e+3*t]=this.faceLocalToVec3(a+o,n-o+e*l,s);return h}getPointsForXyfNoStep(e,t,i){this.assertXyf(e,t,i);const r=.5/this.nside,s=(e+.5)/this.nside,o=(t+.5)/this.nside;return[this.faceLocalToVec3(s+r,o+r,i),this.faceLocalToVec3(s-r,o+r,i),this.faceLocalToVec3(s-r,o-r,i),this.faceLocalToVec3(s+r,o-r,i)]}neighbours(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=new Int32Array(8),o=this.nside-1;if(t>0&&t<o&&i>0&&i<o)return s[0]=this.xyf2nest(t-1,i,r),s[1]=this.xyf2nest(t-1,i+1,r),s[2]=this.xyf2nest(t,i+1,r),s[3]=this.xyf2nest(t+1,i+1,r),s[4]=this.xyf2nest(t+1,i,r),s[5]=this.xyf2nest(t+1,i-1,r),s[6]=this.xyf2nest(t,i-1,r),s[7]=this.xyf2nest(t-1,i-1,r),s;for(let e=0;e<s.length;e+=1){let o=t+g[e],a=i+_[e],n=4;o<0?(o+=this.nside,n-=1):o>=this.nside&&(o-=this.nside,n+=1),a<0?(a+=this.nside,n-=3):a>=this.nside&&(a-=this.nside,n+=3);const l=p[n][r];if(l<0){s[e]=-1;continue}const h=f[n][Math.floor(r/4)];if((1&h)>0&&(o=this.nside-o-1),(2&h)>0&&(a=this.nside-a-1),(4&h)>0){const e=o;o=a,a=e}s[e]=this.xyf2nest(o,a,l)}return s}queryDiscInclusive(e,t,i){if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("pointing theta and phi must be finite radians.");if(!Number.isFinite(t)||t<0)throw new RangeError("radiusRad must be a non-negative finite number.");if(!Number.isInteger(i)||i<0||i>0&&!T(i))throw new RangeError("fact must be zero or a positive power of two.");const r=new a;if(t>=Math.PI)return r.appendRange(0,this.npix),r;const s=0!==i,o=s?Math.log2(i):0,n=Math.min(c,this.order+o),l=e.toVec3(),h=Math.cos(t),u=Math.sin(t),d=[],g=[],_=new Map,p=new Set,f=[];for(let e=0;e<=n;e+=1){const i=y(2**e),r=Math.cos(i),s=Math.sin(i);d[e]=t+i>Math.PI?-1:h*r-u*s,g[e]=t-i<0?1:h*r+u*s}for(let e=11;e>=0;e-=1)f.push({pixel:e,order:0});for(;f.length>0;){const e=f.pop();if(!e)break;let t=_.get(e.order);t||(t=e.order===this.order?this:new m(2**e.order),_.set(e.order,t));const i=t.pix2vec(e.pixel),r=l.dot(i);if(r+2e-7<=d[e.order])continue;const o=r<h?1:r<=g[e.order]?2:3;this.collectDiscPixel(e.order,n,o,e.pixel,s,f,p)}for(const e of[...p].sort((e,t)=>e-t))r.append(e);return r}queryPolygonInclusive(e,t){if(e.length<3)throw new RangeError("vertices must contain at least three points.");const i=e.map(e=>{if(!Number.isFinite(e.theta)||!Number.isFinite(e.phi))throw new RangeError("polygon vertex theta and phi must be finite radians.");return e.toVec3()}),r=[];let s=0,o=0;for(;o<i.length;){const e=i[o],t=i[(o+1)%i.length],a=i[(o+2)%i.length],n=I(A(e,t)),l=n.dot(a);if(0===o)s=l<0?-1:1;else if(s*l<0){i.splice((o+1)%i.length,1),r.splice(o,1),o=Math.max(0,o-1);continue}r[o]=E(n,s),o+=1}const a=new Array(r.length).fill(l);if(0!==t){const e=function(e){if(e.length<2)throw new RangeError("at least two points are required to find a containing circle.");let t=I(w(e[0],e[1])),i=e[0].dot(t);for(let r=2;r<e.length;r+=1)e[r].dot(t)<i&&({center:t,cosRadius:i}=F(e,r));return{center:t,cosRadius:i}}(i);r.push(e.center),a.push(Math.acos(M(e.cosRadius,-1,1)))}return this.queryMultiDisc(r,a,t)}queryMultiDisc(e,t,i){if(e.length!==t.length)throw new RangeError("normals and radiusRad must have the same length.");if(!Number.isInteger(i)||i<0||i>0&&!T(i))throw new RangeError("fact must be zero or a positive power of two.");const r=0!==i,s=r?Math.log2(i):0,o=Math.min(c,this.order+s),n=new a,l=new Set,h=[],u=new Map,d=[];for(const e of t)if(!Number.isFinite(e)||e<0)throw new RangeError("radiusRad values must be non-negative finite numbers.");for(let i=0;i<=o;i+=1){const r=y(2**i);d[i]=e.map((e,s)=>{const o=t[s];return[o+r>Math.PI?-1:Math.cos(o+r),0===i?Math.cos(o):d[0][s][1],o-r<0?1:Math.cos(o-r)]})}for(let e=11;e>=0;e-=1)h.push({pixel:e,order:0});for(;h.length>0;){const t=h.pop();if(!t)break;let i=u.get(t.order);i||(i=t.order===this.order?this:new m(2**t.order),u.set(t.order,i));const s=i.pix2vec(t.pixel);let a=3;for(let i=0;i<e.length&&a>0;i+=1){const r=s.dot(e[i]);for(let e=0;e<a;e+=1)r<d[t.order][i][e]&&(a=e)}a>0&&this.collectDiscPixel(t.order,o,a,t.pixel,r,h,l)}for(const e of[...l].sort((e,t)=>e-t))n.append(e);return n}assertPixel(e){if(!Number.isInteger(e)||e<0||e>=this.npix)throw new RangeError("pixel must be an integer in [0, npix).")}assertXyf(e,t,i){if(!Number.isInteger(i)||i<0||i>=12)throw new RangeError("face must be an integer in [0, 11].");if(!Number.isInteger(e)||e<0||e>=this.nside)throw new RangeError("x must be an integer in [0, nside).");if(!Number.isInteger(t)||t<0||t>=this.nside)throw new RangeError("y must be an integer in [0, nside).")}pix2zphi(e){const{ix:t,iy:i,face:r}=this.nest2xyf(e),s=1/(3*this.nside*this.nside),o=2/(3*this.nside),a=u[r]*this.nside-t-i-1;let n,h;a<this.nside?(n=a,h=1-n*n*s):a>3*this.nside?(n=4*this.nside-a,h=n*n*s-1):(n=this.nside,h=(2*this.nside-a)*o);const c=v(d[r]*n+t-i,8*n);return{z:h,phi:S(n===this.nside?.75*l*c*o:.5*l*c/n)}}faceLocalToVec3(e,t,i){const s=u[i]-e-t;let o,a;s<1?(o=s,a=1-o*o/3):s>3?(o=4-s,a=o*o/3-1):(o=1,a=(2-s)*n);const h=v(d[i]*o+e-t,8*o),c=o<=Number.EPSILON?0:.5*l*h/o,g=Math.sqrt(Math.max(0,(1-a)*(1+a)));return new r(g*Math.cos(c),g*Math.sin(c),a)}collectDiscPixel(e,t,i,r,s,o,a){if(0!==i)if(e<this.order)if(i>=3){const t=4**(this.order-e);for(let e=r*t;e<(r+1)*t;e+=1)a.add(e)}else P(o,r,e);else{if(e>this.order){const s=Math.floor(r/4**(e-this.order));return void(i>=2||e>=t?a.add(s):P(o,r,e))}i>=2?a.add(r):s&&(e<t?P(o,r,e):a.add(r))}}}function x(e){let t=0;for(let i=0;i<=c;i+=1)t+=Math.floor(e/2**i)%2*2**(2*i);return t}function b(e){let t=0;for(let i=0;i<=c;i+=1)t+=Math.floor(e/2**(2*i))%2*2**i;return t}function S(e){return(e%h+h)%h}function v(e,t){return(e%t+t)%t}function M(e,t,i){return Math.min(i,Math.max(t,e))}function T(e){return e>0&&2**Math.floor(Math.log2(e))===e}function y(e){const t=n,i=Math.PI/(4*e),s=Math.sqrt(.5555555555555556),o=new r(s*Math.cos(i),s*Math.sin(i),t),a=1-(1-1/e)**2/3,l=new r(Math.sqrt((1-a)*(1+a)),0,a);return Math.acos(M(o.dot(l),-1,1))}function P(e,t,i){for(let r=3;r>=0;r-=1)e.push({pixel:4*t+r,order:i+1})}function w(e,t){return new r(e.x+t.x,e.y+t.y,e.z+t.z)}function C(e,t){return new r(e.x-t.x,e.y-t.y,e.z-t.z)}function E(e,t){return new r(e.x*t,e.y*t,e.z*t)}function A(e,t){return new r(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)}function I(e){return e.normalize()}function F(e,t){let i=I(w(e[0],e[t])),r=e[0].dot(i);for(let s=1;s<t;s+=1)e[s].dot(i)<r&&({center:i,cosRadius:r}=R(e,s,t));return{center:i,cosRadius:r}}function R(e,t,i){let r=I(w(e[t],e[i])),s=e[t].dot(r);for(let o=0;o<t;o+=1)e[o].dot(r)<s&&(r=I(A(C(e[t],e[o]),C(e[i],e[o]))),s=e[o].dot(r),s<0&&(r=E(r,-1),s=-s));return{center:r,cosRadius:s}}},1677(e,t,i){"use strict";i.d(t,{FITSHeaderManager:()=>s,FITSParser:()=>b});class r{_key="";_value="";_comment="";constructor(e,t,i){this._key=e,this._value=t,this._comment=i}get key(){return this._key}get comment(){return this._comment}get value(){return this._value}}class s{static SIMPLE="SIMPLE";static BITPIX="BITPIX";static BZERO="BZERO";static BSCALE="BSCALE";static BLANK="BLANK";static NAXIS="NAXIS";static NAXIS1="NAXIS1";static NAXIS2="NAXIS2";static DATAMIN="DATAMIN";static DATAMAX="DATAMAX";static CRVAL1="CRVAL1";static CRVAL2="CRVAL2";static CTYPE1="CTYPE1";static CTYPE2="CTYPE2";static CRPIX1="CRPIX1";static CRPIX2="CRPIX2";static ORIGIN="ORIGIN";static COMMENT="COMMENT";static XTENSION="XTENSION";static PCOUNT="PCOUNT";static GCOUNT="GCOUNT";static TFIELDS="TFIELDS";static TFORM="TFORM";static TTYPE="TTYPE";static TUNIT="TUNIT";static TSCAL="TSCAL";static TZERO="TZERO";static TNULL="TNULL";static TBCOL="TBCOL";items=[];constructor(e=!0){e&&(this.items[0]=new r(s.SIMPLE,"T",""),this.items[1]=new r(s.BITPIX,"",""),this.items[2]=new r(s.NAXIS,2,""),this.items[3]=new r(s.NAXIS1,"",""),this.items[4]=new r(s.NAXIS2,"",""))}insert(e){e.key===s.SIMPLE?this.items[0]=e:e.key===s.BITPIX?this.items[1]=e:e.key===s.NAXIS?this.items[2]=e:e.key===s.NAXIS1?this.items[3]=e:e.key===s.NAXIS2?this.items[4]=e:this.items.push(e)}getItems(){return this.items}remove(e){this.items=this.items.filter(t=>t.key!==e)}findById(e){const t=this.items.find(t=>t.key===e);return t||null}static tableFieldKey(e,t){if(!Number.isInteger(t)||t<1)throw new RangeError(`FITS table field index must be >= 1, received ${t}.`);return`${e}${t}`}static naxisKey(e){if(!Number.isInteger(e)||e<1)throw new RangeError(`FITS axis must be a positive integer, received ${e}.`);return`NAXIS${e}`}static getFITSItemStringValue(e,t){const i=e.findById(t);return i?String(i.value).trim().replace(/^'/,"").replace(/'$/,"").trim():null}}var o=i(7223);class a{static BLOCK_SIZE=2880;static CARD_SIZE=80;static INTEGER_KEYWORDS=new Set(["BITPIX","NAXIS","PCOUNT","GCOUNT"]);static LOGICAL_KEYWORDS=new Set(["SIMPLE","EXTEND"]);static serialize(e,t){const i=e.getItems(),r=new Map(i.map(e=>[e.key.toUpperCase(),e])),s=[];return a.appendMandatoryCards(s,r,t),a.appendRemainingCards(s,i),s.push(a.card80("END")),a.encodeAndPad(s)}static appendMandatoryCards(e,t,i){if(i){const i=t.get("SIMPLE");if(!i)throw new Error("Missing mandatory SIMPLE card in Primary HDU");e.push(...a.makeKeywordWithComment("SIMPLE",i.value,i.comment))}else{const i=t.get("XTENSION");if(!i)throw new Error("Missing mandatory XTENSION card in extension HDU");e.push(...a.makeKeywordWithComment("XTENSION",i.value,i.comment))}const r=t.get("BITPIX");if(!r)throw new Error("Missing mandatory BITPIX card");e.push(...a.makeKeywordWithComment("BITPIX",r.value,r.comment));const s=t.get("NAXIS");if(!s)throw new Error("Missing mandatory NAXIS card");const o=Number(s.value);if(!Number.isInteger(o)||o<0)throw new Error(`Invalid NAXIS value: ${s.value}`);e.push(...a.makeKeywordWithComment("NAXIS",o,s.comment));for(let i=1;i<=o;i++){const r=`NAXIS${i}`,s=t.get(r);if(!s)throw new Error(`Missing mandatory ${r} card`);e.push(...a.makeKeywordWithComment(r,s.value,s.comment))}if(!i){const i=t.get("PCOUNT"),r=t.get("GCOUNT");if(!i)throw new Error("Missing mandatory PCOUNT card in extension HDU");if(!r)throw new Error("Missing mandatory GCOUNT card in extension HDU");e.push(...a.makeKeywordWithComment("PCOUNT",i.value,i.comment)),e.push(...a.makeKeywordWithComment("GCOUNT",r.value,r.comment))}if(i){const i=t.get("EXTEND");i&&e.push(...a.makeKeywordWithComment("EXTEND",i.value,i.comment))}}static appendRemainingCards(e,t){for(const i of t){const t=i.key.toUpperCase();"SIMPLE"===t||"XTENSION"===t||"BITPIX"===t||"NAXIS"===t||/^NAXIS\d+$/.test(t)||"PCOUNT"===t||"GCOUNT"===t||"EXTEND"===t||"END"===t||e.push(...a.makeKeywordWithComment(i.key,i.value,i.comment))}}static makeKeywordWithComment(e,t,i){const r=e.toUpperCase();if("END"===r)return[a.card80("END")];if("COMMENT"===r||"HISTORY"===r)return a.makeCommentCards(r,String(t??i??""));let s=a.keyword(r)+a.valueField20(r,t);if(!i||0===i.length)return[a.card80(s)];const o=` / ${i}`,n=a.CARD_SIZE-s.length;if(n<=0)return[a.card80(s),...a.makeCommentCards("COMMENT",i)];s+=o.slice(0,n);const l=o.slice(n).replace(/^\s*\/\s*/,"");return 0===l.length?[a.card80(s)]:[a.card80(s),...a.makeCommentCards("COMMENT",l)]}static makeCommentCards(e,t){const i=a.keyword(e),r=a.CARD_SIZE-i.length,s=String(t??"");if(0===s.length)return[a.card80(i)];const o=[];for(let e=0;e<s.length;e+=r)o.push(a.card80(i+s.slice(e,e+r)));return o}static valueField20(e,t){if(a.LOGICAL_KEYWORDS.has(e)){return`= ${(!0===t||"T"===t||"t"===t?"T":"F").padStart(20," ")}`}if(a.INTEGER_KEYWORDS.has(e)||/^NAXIS\d+$/.test(e)){const i=Number(t);if(!Number.isFinite(i)||!Number.isInteger(i))throw new Error(`FITS header: ${e} must be an integer, got ${t}`);return`= ${String(i).padStart(20," ")}`}if("number"==typeof t){let e=Number.isInteger(t)?String(t):t.toExponential(10).replace("e","E");return e.length>20&&(e=t.toExponential(8).replace("e","E")),`= ${e.padStart(20," ")}`}return"string"==typeof t?`= ${a.quoteFitsString(t)}`:""}static quoteFitsString(e){return`'${e.replace(/^'+|'+$/g,"").replace(/'/g,"''")}'`}static keyword(e){return(e??"").toUpperCase().padEnd(8," ").slice(0,8)}static card80(e){return e.length>=a.CARD_SIZE?e.slice(0,a.CARD_SIZE):e.padEnd(a.CARD_SIZE," ")}static encodeAndPad(e){let t=e.join("");const i=t.length%a.BLOCK_SIZE;return 0!==i&&(t+=" ".repeat(a.BLOCK_SIZE-i)),(new TextEncoder).encode(t)}}class n{static createFITS(e){const t=a.serialize(e.header,!0),i=this.createData(e.data,e.header),r=new Uint8Array(t.length+i.length);return r.set(t,0),r.set(i,t.length),r}static createHDU(e,t){const i=a.serialize(e.header,t),r=e.rawData??new Uint8Array(0);if(r.byteLength!==e.dataByteLength)throw new Error(`HDU payload length mismatch: rawData contains ${r.byteLength} bytes, but dataByteLength=${e.dataByteLength}.`);const s=n.padData(r),o=new Uint8Array(i.byteLength+s.byteLength);return o.set(i,0),o.set(s,i.byteLength),o}static padData(e){if(0===e.byteLength)return new Uint8Array(0);const t=e.byteLength%2880;if(0===t)return e.slice();const i=new Uint8Array(e.byteLength+(2880-t));return i.set(e),i}static createData(e,t){const i=e.reduce((e,t)=>e+t.length,0),r=Math.abs(Number(t.findById("BITPIX")?.value??0)),s=Number(t.findById("NAXIS")?.value??0);let o=1;for(let e=1;e<=s;e++)o*=Number(t.findById(`NAXIS${e}`)?.value??0);const a=s>0?o*(r/8):0;if(a&&a!==i)throw new Error(`Data length ${i} does not match header expectation ${a} (BITPIX=${r}, NAXIS=${s})`);let l=new Uint8Array(i),h=0;for(const t of e)l.set(t,h),h+=t.length;return n.padData(l)}static createFITSFile(e){if(0===e.length)throw new Error("Cannot write an empty FITSFile.");if(null===e.primaryHDU)throw new Error("FITSFile must start with a PrimaryHDU.");const t=e.hdus.map((e,t)=>n.createHDU(e,0===t)),i=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(i);let s=0;for(const e of t)r.set(e,s),s+=e.byteLength;return r}static writeFITSFileModel(e,t){const i=n.createFITSFile(e);o.writeFileSync(t,i)}static writeFITSFile(e,t){const i=n.createFITS(e);o.writeFileSync(t,i)}}class l{static CARD_SIZE=80;static BLOCK_SIZE=2880;static getFITSItemStringValue(e,t){const i=e.findById(t);return i?String(i.value).trim().replace(/^'/,"").replace(/'$/,"").trim():null}static getFITSItemValue(e,t){const i=e.findById(t);if(!i)return null;const r=Number(i.value);return Number.isNaN(r)?null:r}static getHeaderByteLength(e,t=0){const i=new TextDecoder("ascii");for(let r=t;r+l.CARD_SIZE<=e.byteLength;r+=l.CARD_SIZE){if("END"===i.decode(e.subarray(r,r+8)).trim()){const e=r+l.CARD_SIZE-t;return Math.ceil(e/l.BLOCK_SIZE)*l.BLOCK_SIZE}}throw new Error("Invalid FITS header: END card not found.")}static parse(e,t=0){const i=new TextDecoder("ascii"),o=l.getHeaderByteLength(e,t),a=new s(!1);for(let s=t;s<t+o;s+=l.CARD_SIZE){const t=i.decode(e.subarray(s,s+l.CARD_SIZE)),o=t.slice(0,8).trim();if("END"===o)break;if(!o)continue;let n,h="";const c=t.slice(10).trim().split("/")[0].trim();n=Number.isNaN(Number(c))?c:Number(c),t.includes("/")&&(h=t.slice(10).trim().split("/")[1]?.trim()??""),a.insert(new r(o,n,h))}return a}}class h{static getShape(e){const t=l.getFITSItemValue(e,s.NAXIS);if(null===t)throw new Error("NAXIS not defined.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid FITS NAXIS value: ${t}`);const i=[];for(let r=1;r<=t;r++){const t=l.getFITSItemValue(e,s.naxisKey(r));if(null===t)throw new Error(`NAXIS${r} not defined.`);i.push(t)}return i}static getElementCount(e){return 0===e.length?0:e.reduce((e,t)=>e*t,1)}}class c{static SUPPORTED_BITPIX=new Set([8,16,32,64,-32,-64]);static assertSupportedBITPIX(e){if(!c.SUPPORTED_BITPIX.has(e))throw new Error(`Unsupported FITS BITPIX value: ${e}`)}static extractPixelFromView(e,t,i){switch(i){case 8:return e.getUint8(t);case 16:return e.getInt16(t,!1);case 32:return e.getInt32(t,!1);case-32:return e.getFloat32(t,!1);case-64:return e.getFloat64(t,!1);case 64:{const i=e.getBigInt64(t,!1),r=Number(i);if(!Number.isSafeInteger(r))throw new RangeError(`BITPIX=64 value ${i} cannot be represented exactly as a JavaScript number.`);return r}default:throw new Error(`Unsupported FITS BITPIX value: ${i}`)}}static computePhysicalMinAndMax(e,t){const i=l.getFITSItemValue(e,s.BITPIX);if(null===i)return null;c.assertSupportedBITPIX(i);if(0===h.getShape(e).length||0===t.byteLength)return e;const o=e.findById(s.DATAMIN),a=e.findById(s.DATAMAX);if(null===o||null===a)try{const[i,n]=c.computePhysicalValues(t,e);null===o&&null!==i&&e.insert(new r(s.DATAMIN,i,"computed by jsfitsio")),null===a&&null!==n&&e.insert(new r(s.DATAMAX,n,"computed by jsfitsio"))}catch(t){if(64===i&&t instanceof RangeError)return e;throw t}return e}static createTypedArray(e,t){c.assertSupportedBITPIX(t);const i=Math.abs(t)/8;if(e.byteLength%i!==0)throw new Error(`Payload byte length ${e.byteLength} is not aligned with BITPIX=${t}.`);const r=e.byteLength/i,s=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case 8:return e.slice();case 16:{const e=new Int16Array(r);for(let t=0;t<r;t++)e[t]=s.getInt16(2*t,!1);return e}case 32:{const e=new Int32Array(r);for(let t=0;t<r;t++)e[t]=s.getInt32(4*t,!1);return e}case 64:{const e=new BigInt64Array(r);for(let t=0;t<r;t++)e[t]=s.getBigInt64(8*t,!1);return e}case-32:{const e=new Float32Array(r);for(let t=0;t<r;t++)e[t]=s.getFloat32(4*t,!1);return e}case-64:{const e=new Float64Array(r);for(let t=0;t<r;t++)e[t]=s.getFloat64(8*t,!1);return e}default:throw new Error(`Unsupported FITS BITPIX value: ${t}`)}}static computePhysicalValues(e,t){const i=l.getFITSItemValue(t,s.BITPIX);if(null===i)return[null,null];c.assertSupportedBITPIX(i);const r=h.getShape(t),o=h.getElementCount(r);if(0===o)return[null,null];const a=l.getFITSItemValue(t,s.BLANK),n=l.getFITSItemValue(t,s.BZERO)??0,u=l.getFITSItemValue(t,s.BSCALE)??1,d=Math.abs(i)/8,g=o*d;if(e.byteLength<g)throw new Error(`FITS payload is too short: expected ${g} bytes, received ${e.byteLength}.`);const _=new DataView(e.buffer,e.byteOffset,e.byteLength);let p=null,f=null;for(let e=0;e<o;e++){const t=c.extractPixelFromView(_,e*d,i);if(i>0&&null!==a&&t===a)continue;const r=c.pixel2physicalValue(t,u,n);Number.isNaN(r)||((null===p||r<p)&&(p=r),(null===f||r>f)&&(f=r))}return[p,f]}static pixel2physicalValue(e,t,i){if(null===i||null===t)throw new Error("Either BZERO or BSCALE is null");return i+t*e}static extractPixelValue(e,t,i){c.assertSupportedBITPIX(i);const r=new DataView(e.buffer,e.byteOffset,e.byteLength);return c.extractPixelFromView(r,t,i)}}class u{header;rawData;dataOffset;dataByteLength;constructor(e,t,i,r){this.header=e,this.rawData=t,this.dataOffset=i,this.dataByteLength=r}}class d extends u{bitpix;shape;typedData;type="IMAGE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.bitpix=s,this.shape=o,this.typedData=a}get naxis(){return this.shape.length}get elementCount(){return 0===this.shape.length?0:this.shape.reduce((e,t)=>e*t,1)}}class g extends d{type="PRIMARY";constructor(e,t,i,r,s,o,a){super(e,t,i,r,s,o,a)}}class _{_hdus;constructor(e=[]){this._hdus=[...e]}get hdus(){return this._hdus}get length(){return this._hdus.length}get primaryHDU(){const e=this._hdus[0];return e instanceof g?e:null}getHDU(e){return this._hdus[e]??null}addHDU(e){this._hdus.push(e)}}class p extends u{rowByteLength;rowCount;columns;type="BINTABLE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.rowByteLength=s,this.rowCount=o,this.columns=a}get columnCount(){return this.columns.length}getRowView(e){if(e<0||e>=this.rowCount)throw new RangeError(`Invalid row index ${e}.`);const t=e*this.rowByteLength;return new DataView(this.rawData.buffer,this.rawData.byteOffset+t,this.rowByteLength)}getRow(e){return this.columns.map((t,i)=>this.getCell(e,i))}getCell(e,t){const i=this.resolveColumn(t),r=this.getRowView(e),s=i.byteOffset,o=i.repeat;switch(i.type){case"CHAR":{const e=new Uint8Array(r.buffer,r.byteOffset+s,i.byteWidth);return new TextDecoder("ascii").decode(e).replace(/\s+$/,"")}case"LOGICAL":{const e=[];for(let t=0;t<o;t++){const i=String.fromCharCode(r.getUint8(s+t));e.push("T"===i)}return 1===o?e[0]:e}case"UINT8":{const e=[];for(let t=0;t<o;t++){const o=r.getUint8(s+t);e.push(this.applyNumericScaling(o,i.scale,i.zero))}return 1===o?e[0]:e}case"INT16":return this.readNumericColumn(r,s,o,2,(e,t)=>e.getInt16(t,!1),i.scale,i.zero,i.nullValue);case"INT32":return this.readNumericColumn(r,s,o,4,(e,t)=>e.getInt32(t,!1),i.scale,i.zero,i.nullValue);case"INT64":{const e=[];for(let t=0;t<o;t++){const i=r.getBigInt64(s+8*t,!1);e.push(i)}return 1===o?e[0]:e}case"FLOAT32":return this.readNumericColumn(r,s,o,4,(e,t)=>e.getFloat32(t,!1),i.scale,i.zero,null);case"FLOAT64":return this.readNumericColumn(r,s,o,8,(e,t)=>e.getFloat64(t,!1),i.scale,i.zero,null);case"COMPLEX64":{const e=[];for(let t=0;t<o;t++){const i=s+8*t;e.push({real:r.getFloat32(i,!1),imaginary:r.getFloat32(i+4,!1)})}return 1===o?e[0]:e}case"COMPLEX128":{const e=[];for(let t=0;t<o;t++){const i=s+16*t;e.push({real:r.getFloat64(i,!1),imaginary:r.getFloat64(i+8,!1)})}return 1===o?e[0]:e}case"BIT":return new Uint8Array(r.buffer,r.byteOffset+s,i.byteWidth).slice();default:throw new Error(`Unsupported BINTABLE column type: ${i.type}`)}}readNumericColumn(e,t,i,r,s,o,a,n){const l=[];for(let h=0;h<i;h++){const i=s(e,t+h*r);null===n||i!==n?l.push(this.applyNumericScaling(i,o,a)):l.push(null)}return 1===i?l[0]:l}applyNumericScaling(e,t,i){return i+t*e}resolveColumn(e){if("number"==typeof e){if(!Number.isInteger(e)||e<0||e>=this.columns.length)throw new RangeError(`Invalid column index ${e}.`);return this.columns[e]}const t=this.columns.find(t=>t.name===e);if(!t)throw new Error(`BINTABLE column '${e}' not found.`);return t}}class f{static parseTFORM(e){const t=e.trim().replace(/^'/,"").replace(/'$/,"").trim().toUpperCase().match(/^(\d*)([LXBIJKAEDCM])$/);if(!t)throw new Error(`Unsupported FITS TFORM value: ${e}`);const i=t[1]?Number(t[1]):1,r=t[2],s=f.bytesPerType(r);return{repeat:i,code:r,byteWidth:"X"===r?Math.ceil(i/8):i*s}}static bytesPerType(e){switch(e){case"L":case"B":case"A":return 1;case"I":return 2;case"J":case"E":return 4;case"K":case"D":case"C":return 8;case"M":return 16;case"X":return 0;default:throw new Error(`Unsupported FITS binary table type: ${e}`)}}}class m extends u{rowByteLength;rowCount;columns;type="TABLE";constructor(e,t,i,r,s,o,a){super(e,t,i,r),this.rowByteLength=s,this.rowCount=o,this.columns=a}get columnCount(){return this.columns.length}getRowView(e){if(!Number.isInteger(e)||e<0||e>=this.rowCount)throw new RangeError(`Invalid row index ${e}.`);const t=e*this.rowByteLength;return this.rawData.subarray(t,t+this.rowByteLength)}getRowText(e){return new TextDecoder("ascii").decode(this.getRowView(e))}resolveColumn(e){if("number"==typeof e){if(!Number.isInteger(e)||e<0||e>=this.columns.length)throw new RangeError(`Invalid column index ${e}.`);return this.columns[e]}const t=this.columns.find(t=>t.name===e);if(!t)throw new Error(`ASCII TABLE column '${e}' not found.`);return t}getCell(e,t){const i=this.resolveColumn(t),r=this.getRowView(e).subarray(i.byteOffset,i.byteOffset+i.width),s=new TextDecoder("ascii").decode(r),o=s.trim();if(0===o.length)return"CHAR"===i.type?"":null;switch(i.type){case"CHAR":return s.replace(/\s+$/,"");case"INTEGER":{const e=Number.parseInt(o,10);return Number.isNaN(e)?null:e}case"FLOAT":case"EXPONENTIAL":case"DOUBLE":{const e=o.replace(/[dD]/,"E"),t=Number.parseFloat(e);return Number.isNaN(t)?null:t}default:throw new Error(`Unsupported ASCII TABLE column type: ${i.type}`)}}getRow(e){return this.columns.map((t,i)=>this.getCell(e,i))}}class x{static parseTFORM(e){const t=e.trim().replace(/^'/,"").replace(/'$/,"").trim().toUpperCase().match(/^([AIFED])(\d+)(?:\.(\d+))?$/);if(!t)throw new Error(`Unsupported FITS ASCII table TFORM value: ${e}`);const i=t[1],r=Number(t[2]),s=void 0!==t[3]?Number(t[3]):null;if(!Number.isInteger(r)||r<=0)throw new Error(`Invalid FITS ASCII table field width: ${r}`);if("A"===i||"I"===i){if(null!==s)throw new Error(`TFORM ${e} must not specify decimal places.`)}else if(null===s)throw new Error(`TFORM ${e} requires decimal places.`);return{code:i,width:r,decimals:s}}}class b{static async loadFITS(e,t={}){const i=await b.loadFITSFile(e,t);if(null===i)return null;const r=i.primaryHDU;if(null===r||null===r.rawData)return null;if(2!==h.getShape(r.header).length)throw new Error("Legacy loadFITS() supports only 2D FITS images. Use loadFITSFile() for N-dimensional images.");return{header:r.header,data:b.createMatrix(r.rawData,r.header)}}static async loadFITSFile(e,t={}){const i=await b.getFile(e);return 0===i.byteLength?null:b.processFITSFile(i,t)}static processFITSFile(e,t){const i=new _;let r=0,s=0;for(;r<e.byteLength&&!b.isPaddingOnly(e,r);){const o=l.parse(e,r),a=r+l.getHeaderByteLength(e,r);switch(b.getHDUType(o,s)){case"PRIMARY":case"IMAGE":{const n=b.getImagePayloadByteLength(o);if(a+n>e.byteLength)throw new Error(`Invalid FITS HDU ${s}: expected ${n} payload bytes at offset ${a}, but only `+(e.byteLength-a)+" remain.");const l=e.subarray(a,a+n),h=b.createImageHDU(o,l,a,n,0===s,t);i.addHDU(h);r=a+b.getPaddedByteLength(n);break}case"BINTABLE":{const t=b.getBinaryTablePayloadByteLength(o);if(a+t>e.byteLength)throw new Error(`Invalid BINTABLE HDU ${s}.`);const n=e.subarray(a,a+t),l=b.createBinaryTableHDU(o,n,a,t);i.addHDU(l),r=a+b.getPaddedByteLength(t);break}case"TABLE":{const t=b.getAsciiTablePayloadByteLength(o);if(a+t>e.byteLength)throw new Error(`Invalid ASCII TABLE HDU ${s}: expected ${t} payload bytes at offset ${a}, but only `+(e.byteLength-a)+" remain.");const n=e.subarray(a,a+t),l=b.createAsciiTableHDU(o,n,a,t);i.addHDU(l),r=a+b.getPaddedByteLength(t);break}default:throw new Error(`Unsupported FITS HDU type at index ${s}.`)}s++}return i}static getPaddedByteLength(e){return 0===e?0:Math.ceil(e/l.BLOCK_SIZE)*l.BLOCK_SIZE}static isPaddingOnly(e,t){for(let i=t;i<e.byteLength;i++){const t=e[i];if(0!==t&&32!==t)return!1}return!0}static getHDUType(e,t){if(0===t)return"PRIMARY";const i=l.getFITSItemStringValue(e,s.XTENSION);if(null===i)return"UNKNOWN";switch(i.toUpperCase()){case"IMAGE":return"IMAGE";case"BINTABLE":return"BINTABLE";case"TABLE":return"TABLE";default:return"UNKNOWN"}}static createImageHDU(e,t,i,r,o,a){const n=a.computeDataMinMax?c.computePhysicalMinAndMax(e,t)??e:e,u=l.getFITSItemValue(n,s.BITPIX);if(null===u)throw new Error("BITPIX not defined.");const _=h.getShape(n),p=c.createTypedArray(t,u);return o?new g(n,t,i,r,u,_,p):new d(n,t,i,r,u,_,p)}static getImagePayloadByteLength(e){const t=l.getFITSItemValue(e,s.BITPIX);if(null===t)throw new Error("BITPIX not defined.");c.assertSupportedBITPIX(t);const i=h.getShape(e);if(0===i.length)return 0;return i.reduce((e,t)=>e*t,1)*(Math.abs(t)/8)}static getBinaryTablePayloadByteLength(e){const t=l.getFITSItemValue(e,s.NAXIS1),i=l.getFITSItemValue(e,s.NAXIS2),r=l.getFITSItemValue(e,s.PCOUNT)??0;if(null===t||null===i)throw new Error("BINTABLE requires NAXIS1 and NAXIS2.");return t*i+r}static getBinaryTableColumns(e){const t=l.getFITSItemValue(e,s.TFIELDS);if(null===t)throw new Error("BINTABLE requires TFIELDS.");const i=[];let r=0;for(let o=1;o<=t;o++){const t=l.getFITSItemStringValue(e,s.tableFieldKey("TFORM",o));if(null===t)throw new Error(`Missing TFORM${o}.`);const a=f.parseTFORM(t),n=l.getFITSItemStringValue(e,s.tableFieldKey("TTYPE",o)),h=l.getFITSItemStringValue(e,s.tableFieldKey("TUNIT",o));i.push({index:o,name:n,format:t,type:b.mapBinaryType(a.code),repeat:a.repeat,byteOffset:r,byteWidth:a.byteWidth,unit:h,scale:l.getFITSItemValue(e,s.tableFieldKey("TSCAL",o))??1,zero:l.getFITSItemValue(e,s.tableFieldKey("TZERO",o))??0,nullValue:l.getFITSItemValue(e,s.tableFieldKey("TNULL",o))}),r+=a.byteWidth}return i}static mapBinaryType(e){switch(e.toUpperCase()){case"L":return"LOGICAL";case"X":return"BIT";case"B":return"UINT8";case"I":return"INT16";case"J":return"INT32";case"K":return"INT64";case"A":return"CHAR";case"E":return"FLOAT32";case"D":return"FLOAT64";case"C":return"COMPLEX64";case"M":return"COMPLEX128";default:return"UNKNOWN"}}static createBinaryTableHDU(e,t,i,r){const o=l.getFITSItemValue(e,s.NAXIS1),a=l.getFITSItemValue(e,s.NAXIS2);if(null===o||null===a)throw new Error("Invalid BINTABLE header.");const n=b.getBinaryTableColumns(e),h=n.reduce((e,t)=>e+t.byteWidth,0);if(h!==o)throw new Error(`BINTABLE columns occupy ${h} bytes per row, but NAXIS1=${o}.`);return new p(e,t,i,r,o,a,n)}static getAsciiTablePayloadByteLength(e){const t=l.getFITSItemValue(e,s.NAXIS1),i=l.getFITSItemValue(e,s.NAXIS2);if(null===t||null===i)throw new Error("ASCII TABLE requires NAXIS1 and NAXIS2.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid ASCII TABLE NAXIS1=${t}.`);if(!Number.isInteger(i)||i<0)throw new Error(`Invalid ASCII TABLE NAXIS2=${i}.`);const r=l.getFITSItemValue(e,s.PCOUNT)??0;if(0!==r)throw new Error(`ASCII TABLE requires PCOUNT=0, received ${r}.`);return t*i}static mapAsciiType(e){switch(e.toUpperCase()){case"A":return"CHAR";case"I":return"INTEGER";case"F":return"FLOAT";case"E":return"EXPONENTIAL";case"D":return"DOUBLE";default:return"UNKNOWN"}}static getAsciiTableColumns(e){const t=l.getFITSItemValue(e,s.TFIELDS);if(null===t)throw new Error("ASCII TABLE requires TFIELDS.");if(!Number.isInteger(t)||t<0)throw new Error(`Invalid ASCII TABLE TFIELDS=${t}.`);const i=[];for(let r=1;r<=t;r++){const t=l.getFITSItemStringValue(e,s.tableFieldKey("TFORM",r));if(null===t)throw new Error(`Missing TFORM${r}.`);const o=l.getFITSItemValue(e,s.tableFieldKey("TBCOL",r));if(null===o)throw new Error(`Missing TBCOL${r}.`);if(!Number.isInteger(o)||o<1)throw new Error(`Invalid TBCOL${r}=${o}.`);const a=x.parseTFORM(t),n=l.getFITSItemStringValue(e,s.tableFieldKey("TTYPE",r)),h=l.getFITSItemStringValue(e,s.tableFieldKey("TUNIT",r));i.push({index:r,name:n,format:t,type:b.mapAsciiType(a.code),startColumn:o,byteOffset:o-1,width:a.width,decimals:a.decimals,unit:h})}return i}static validateAsciiTableColumns(e,t){for(const i of e){const e=i.byteOffset+i.width;if(e>t)throw new Error(`ASCII TABLE column ${i.index} extends to byte ${e}, but NAXIS1=${t}.`)}}static createAsciiTableHDU(e,t,i,r){const o=l.getFITSItemValue(e,s.NAXIS1),a=l.getFITSItemValue(e,s.NAXIS2);if(null===o||null===a)throw new Error("Invalid ASCII TABLE header.");const n=b.getAsciiTableColumns(e);return b.validateAsciiTableColumns(n,o),new m(e,t,i,r,o,a,n)}static createMatrix(e,t){const i=l.getFITSItemValue(t,s.NAXIS1);if(null===i)throw new Error("NAXIS1 not defined.");const r=l.getFITSItemValue(t,s.NAXIS2);if(null===r)throw new Error("NAXIS2 not defined.");const o=l.getFITSItemValue(t,s.BITPIX);if(null===o)throw new Error("BITPIX not defined.");const a=Math.abs(o/8),n=[];for(let t=0;t<r;t++)n.push(e.slice(t*i*a,(t+1)*i*a));return n}static saveFITSLocally(e,t){return n.writeFITSFile(e,t)}static async getFile(e){if(e.substring(0,5).toLowerCase().includes("http")){const t=await i.e(911).then(i.bind(i,1911)),r=await t.getFile(e);if(r?.byteLength){return new Uint8Array(r)}return new Uint8Array(0)}{const t=await i.e(64).then(i.bind(i,7064)),r=await t.getLocalFile(e);if(r?.length){return new Uint8Array(r)}return new Uint8Array(0)}}}}};const t={};function i(r){const s=t[r];if(void 0!==s)return s.exports;const o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,i),o.exports}return i.m=e,i.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var s=t[r++],o=t[r++];i.o(e,s)?0===o&&r++:0===o?Object.defineProperty(e,s,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,s,{enumerable:!0,get:o})}else for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>e+".astroviewer.min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e={},t="astroviewer:";i.l=(r,s,o,a)=>{if(e[r])return void e[r].push(s);let n,l;if(void 0!==o){const e=document.getElementsByTagName("script");for(var h=0;h<e.length;h++){const i=e[h];if(i.getAttribute("src")==r||i.getAttribute("data-webpack")==t+o){n=i;break}}}n||(l=!0,n=document.createElement("script"),n.charset="utf-8",i.nc&&n.setAttribute("nonce",i.nc),n.setAttribute("data-webpack",t+o),n.src=r),e[r]=[s];const c=(t,i)=>{n.onerror=n.onload=null,clearTimeout(u);const s=e[r];if(delete e[r],n.parentNode?.removeChild(n),s?.forEach(e=>e(i)),t)return t(i)},u=setTimeout(c.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=c.bind(null,n.onerror),n.onload=c.bind(null,n.onload),l&&document.head.appendChild(n)}})(),i.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{let e;i.g.importScripts&&(e=i.g.location+"");const t=i.g.document;if(!e&&t&&("SCRIPT"===t.currentScript?.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){const i=t.getElementsByTagName("script");if(i.length){let t=i.length-1;for(;t>-1&&(!e||!/^http(s?):/.test(e));)e=i[t--].src}}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{const e={792:0};i.f.j=(t,r)=>{let s=i.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else{const o=new Promise((i,r)=>s=e[t]=[i,r]);r.push(s[2]=o);const a=i.p+i.u(t),n=new Error,l=r=>{if(i.o(e,t)&&(s=e[t],0!==s&&(e[t]=void 0),s)){const e=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;n.message="Loading chunk "+t+" failed.\n("+e+": "+i+")",n.name="ChunkLoadError",n.type=e,n.request=i,n.event=r,s[1](n)}};i.l(a,l,"chunk-"+t,t)}};const t=(t,r)=>{let[s,o,a]=r;var n,l,h=0;if(s.some(t=>0!==e[t])){for(n in o)i.o(o,n)&&(i.m[n]=o[n]);if(a)a(i)}for(t&&t(r);h<s.length;h++)l=s[h],i.o(e,l)&&e[l]&&e[l][0](),e[l]=0},r=self.webpackChunkastroviewer=self.webpackChunkastroviewer||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),i(1229)})());
2
+ //# sourceMappingURL=astroviewer.min.js.map