@loaders.gl/tiles 5.0.0-alpha.11 → 5.0.0-alpha.13

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 (698) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +18 -72
  3. package/dist/dist.dev.js +5874 -23815
  4. package/dist/dist.min.js +3 -3
  5. package/dist/image-set.d.ts +1 -1
  6. package/dist/image-set.d.ts.map +1 -1
  7. package/dist/index.cjs +2803 -10209
  8. package/dist/index.cjs.map +3 -3
  9. package/dist/index.d.ts +4 -43
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -26
  12. package/dist/index.js.map +1 -1
  13. package/dist/mlt/bundled.d.ts +3 -0
  14. package/dist/mlt/bundled.d.ts.map +1 -0
  15. package/dist/mlt/bundled.js +5 -0
  16. package/dist/mlt/bundled.js.map +1 -0
  17. package/dist/mlt/index.cjs +3701 -0
  18. package/dist/mlt/index.cjs.map +6 -0
  19. package/dist/mlt/index.d.ts +10 -0
  20. package/dist/mlt/index.d.ts.map +1 -0
  21. package/dist/mlt/index.js +12 -0
  22. package/dist/mlt/index.js.map +1 -0
  23. package/dist/mlt/lib/encode-mlt-geometry.d.ts +6 -0
  24. package/dist/mlt/lib/encode-mlt-geometry.d.ts.map +1 -0
  25. package/dist/mlt/lib/encode-mlt-geometry.js +150 -0
  26. package/dist/mlt/lib/encode-mlt-geometry.js.map +1 -0
  27. package/dist/mlt/lib/encode-mlt-streams.d.ts +13 -0
  28. package/dist/mlt/lib/encode-mlt-streams.d.ts.map +1 -0
  29. package/dist/mlt/lib/encode-mlt-streams.js +57 -0
  30. package/dist/mlt/lib/encode-mlt-streams.js.map +1 -0
  31. package/dist/mlt/lib/encode-mlt.d.ts +6 -0
  32. package/dist/mlt/lib/encode-mlt.d.ts.map +1 -0
  33. package/dist/mlt/lib/encode-mlt.js +174 -0
  34. package/dist/mlt/lib/encode-mlt.js.map +1 -0
  35. package/dist/mlt/lib/parse-mlt.d.ts +11 -0
  36. package/dist/mlt/lib/parse-mlt.d.ts.map +1 -0
  37. package/dist/mlt/lib/parse-mlt.js +675 -0
  38. package/dist/mlt/lib/parse-mlt.js.map +1 -0
  39. package/dist/mlt/mlt-format.d.ts +14 -0
  40. package/dist/mlt/mlt-format.d.ts.map +1 -0
  41. package/dist/mlt/mlt-format.js +17 -0
  42. package/dist/mlt/mlt-format.js.map +1 -0
  43. package/dist/mlt/mlt-loader-with-parser.d.ts +91 -0
  44. package/dist/mlt/mlt-loader-with-parser.d.ts.map +1 -0
  45. package/dist/mlt/mlt-loader-with-parser.js +29 -0
  46. package/dist/mlt/mlt-loader-with-parser.js.map +1 -0
  47. package/dist/mlt/mlt-loader.d.ts +115 -0
  48. package/dist/mlt/mlt-loader.d.ts.map +1 -0
  49. package/dist/mlt/mlt-loader.js +38 -0
  50. package/dist/mlt/mlt-loader.js.map +1 -0
  51. package/dist/mlt/mlt-source-loader.d.ts +82 -0
  52. package/dist/mlt/mlt-source-loader.d.ts.map +1 -0
  53. package/dist/mlt/mlt-source-loader.js +179 -0
  54. package/dist/mlt/mlt-source-loader.js.map +1 -0
  55. package/dist/mlt/mlt-writer.d.ts +45 -0
  56. package/dist/mlt/mlt-writer.d.ts.map +1 -0
  57. package/dist/mlt/mlt-writer.js +21 -0
  58. package/dist/mlt/mlt-writer.js.map +1 -0
  59. package/dist/mlt/unbundled.d.ts +3 -0
  60. package/dist/mlt/unbundled.d.ts.map +1 -0
  61. package/dist/mlt/unbundled.js +5 -0
  62. package/dist/mlt/unbundled.js.map +1 -0
  63. package/dist/mvt/arrow-table-tile-source-loader-types.d.ts +36 -0
  64. package/dist/mvt/arrow-table-tile-source-loader-types.d.ts.map +1 -0
  65. package/dist/mvt/arrow-table-tile-source-loader-types.js +36 -0
  66. package/dist/mvt/arrow-table-tile-source-loader-types.js.map +1 -0
  67. package/dist/mvt/arrow-table-tile-source-loader.cjs +6343 -0
  68. package/dist/mvt/arrow-table-tile-source-loader.cjs.map +6 -0
  69. package/dist/mvt/arrow-table-tile-source-loader.d.ts +69 -0
  70. package/dist/mvt/arrow-table-tile-source-loader.d.ts.map +1 -0
  71. package/dist/mvt/arrow-table-tile-source-loader.js +216 -0
  72. package/dist/mvt/arrow-table-tile-source-loader.js.map +1 -0
  73. package/dist/mvt/arrow-table-tile-source-types.d.ts +21 -0
  74. package/dist/mvt/arrow-table-tile-source-types.d.ts.map +1 -0
  75. package/dist/mvt/arrow-table-tile-source-types.js +6 -0
  76. package/dist/mvt/arrow-table-tile-source-types.js.map +1 -0
  77. package/dist/mvt/bundled.d.ts +6 -0
  78. package/dist/mvt/bundled.d.ts.map +1 -0
  79. package/dist/mvt/bundled.js +7 -0
  80. package/dist/mvt/bundled.js.map +1 -0
  81. package/dist/mvt/dist.dev.js +46689 -0
  82. package/dist/mvt/dist.min.js +94 -0
  83. package/dist/mvt/index.cjs +10095 -0
  84. package/dist/mvt/index.cjs.map +6 -0
  85. package/dist/mvt/index.d.ts +28 -0
  86. package/dist/mvt/index.d.ts.map +1 -0
  87. package/dist/mvt/index.js +27 -0
  88. package/dist/mvt/index.js.map +1 -0
  89. package/dist/mvt/lib/encode-mvt-arrow.d.ts +6 -0
  90. package/dist/mvt/lib/encode-mvt-arrow.d.ts.map +1 -0
  91. package/dist/mvt/lib/encode-mvt-arrow.js +225 -0
  92. package/dist/mvt/lib/encode-mvt-arrow.js.map +1 -0
  93. package/dist/mvt/lib/encode-mvt.d.ts +30 -0
  94. package/dist/mvt/lib/encode-mvt.d.ts.map +1 -0
  95. package/dist/mvt/lib/encode-mvt.js +20 -0
  96. package/dist/mvt/lib/encode-mvt.js.map +1 -0
  97. package/dist/mvt/lib/get-schemas-from-tilejson.d.ts +4 -0
  98. package/dist/mvt/lib/get-schemas-from-tilejson.d.ts.map +1 -0
  99. package/dist/mvt/lib/get-schemas-from-tilejson.js +56 -0
  100. package/dist/mvt/lib/get-schemas-from-tilejson.js.map +1 -0
  101. package/dist/mvt/lib/is-longitude-latitude-crs.d.ts +3 -0
  102. package/dist/mvt/lib/is-longitude-latitude-crs.d.ts.map +1 -0
  103. package/dist/mvt/lib/is-longitude-latitude-crs.js +13 -0
  104. package/dist/mvt/lib/is-longitude-latitude-crs.js.map +1 -0
  105. package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.d.ts +25 -0
  106. package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.d.ts.map +1 -0
  107. package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.js +73 -0
  108. package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.js.map +1 -0
  109. package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.d.ts +52 -0
  110. package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.d.ts.map +1 -0
  111. package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.js +165 -0
  112. package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.js.map +1 -0
  113. package/dist/mvt/lib/mvt-pbf/mvt-constants.d.ts +116 -0
  114. package/dist/mvt/lib/mvt-pbf/mvt-constants.d.ts.map +1 -0
  115. package/dist/mvt/lib/mvt-pbf/mvt-constants.js +127 -0
  116. package/dist/mvt/lib/mvt-pbf/mvt-constants.js.map +1 -0
  117. package/dist/mvt/lib/mvt-pbf/mvt-types.d.ts +17 -0
  118. package/dist/mvt/lib/mvt-pbf/mvt-types.d.ts.map +1 -0
  119. package/dist/mvt/lib/mvt-pbf/mvt-types.js +5 -0
  120. package/dist/mvt/lib/mvt-pbf/mvt-types.js.map +1 -0
  121. package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.d.ts +77 -0
  122. package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.d.ts.map +1 -0
  123. package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.js +235 -0
  124. package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.js.map +1 -0
  125. package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.d.ts +25 -0
  126. package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.d.ts.map +1 -0
  127. package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.js +263 -0
  128. package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.js.map +1 -0
  129. package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.d.ts +4 -0
  130. package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.d.ts.map +1 -0
  131. package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.js +134 -0
  132. package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.js.map +1 -0
  133. package/dist/mvt/lib/mvt-worker-transport.d.ts +15 -0
  134. package/dist/mvt/lib/mvt-worker-transport.d.ts.map +1 -0
  135. package/dist/mvt/lib/mvt-worker-transport.js +54 -0
  136. package/dist/mvt/lib/mvt-worker-transport.js.map +1 -0
  137. package/dist/mvt/lib/parse-mvt-geojson.d.ts +6 -0
  138. package/dist/mvt/lib/parse-mvt-geojson.d.ts.map +1 -0
  139. package/dist/mvt/lib/parse-mvt-geojson.js +48 -0
  140. package/dist/mvt/lib/parse-mvt-geojson.js.map +1 -0
  141. package/dist/mvt/lib/parse-mvt.d.ts +14 -0
  142. package/dist/mvt/lib/parse-mvt.d.ts.map +1 -0
  143. package/dist/mvt/lib/parse-mvt.js +105 -0
  144. package/dist/mvt/lib/parse-mvt.js.map +1 -0
  145. package/dist/mvt/lib/parse-tilejson.d.ts +74 -0
  146. package/dist/mvt/lib/parse-tilejson.d.ts.map +1 -0
  147. package/dist/mvt/lib/parse-tilejson.js +267 -0
  148. package/dist/mvt/lib/parse-tilejson.js.map +1 -0
  149. package/dist/mvt/lib/resolve-table-tile-parameters.d.ts +4 -0
  150. package/dist/mvt/lib/resolve-table-tile-parameters.d.ts.map +1 -0
  151. package/dist/mvt/lib/resolve-table-tile-parameters.js +16 -0
  152. package/dist/mvt/lib/resolve-table-tile-parameters.js.map +1 -0
  153. package/dist/mvt/lib/types.d.ts +88 -0
  154. package/dist/mvt/lib/types.d.ts.map +1 -0
  155. package/dist/mvt/lib/types.js.map +1 -0
  156. package/dist/mvt/lib/utils/geometry-utils.d.ts +83 -0
  157. package/dist/mvt/lib/utils/geometry-utils.d.ts.map +1 -0
  158. package/dist/mvt/lib/utils/geometry-utils.js +211 -0
  159. package/dist/mvt/lib/utils/geometry-utils.js.map +1 -0
  160. package/dist/mvt/lib/vector-tile/vector-tile-feature.d.ts +72 -0
  161. package/dist/mvt/lib/vector-tile/vector-tile-feature.d.ts.map +1 -0
  162. package/dist/mvt/lib/vector-tile/vector-tile-feature.js +350 -0
  163. package/dist/mvt/lib/vector-tile/vector-tile-feature.js.map +1 -0
  164. package/dist/mvt/lib/vector-tile/vector-tile-layer.d.ts +29 -0
  165. package/dist/mvt/lib/vector-tile/vector-tile-layer.d.ts.map +1 -0
  166. package/dist/mvt/lib/vector-tile/vector-tile-layer.js +108 -0
  167. package/dist/mvt/lib/vector-tile/vector-tile-layer.js.map +1 -0
  168. package/dist/mvt/lib/vector-tile/vector-tile.d.ts +9 -0
  169. package/dist/mvt/lib/vector-tile/vector-tile.d.ts.map +1 -0
  170. package/dist/mvt/lib/vector-tile/vector-tile.js +28 -0
  171. package/dist/mvt/lib/vector-tile/vector-tile.js.map +1 -0
  172. package/dist/mvt/lib/vector-tiler/arrow-tile.d.ts +6 -0
  173. package/dist/mvt/lib/vector-tiler/arrow-tile.d.ts.map +1 -0
  174. package/dist/mvt/lib/vector-tiler/arrow-tile.js +84 -0
  175. package/dist/mvt/lib/vector-tiler/arrow-tile.js.map +1 -0
  176. package/dist/mvt/lib/vector-tiler/features/clip-features.d.ts +16 -0
  177. package/dist/mvt/lib/vector-tiler/features/clip-features.d.ts.map +1 -0
  178. package/dist/mvt/lib/vector-tiler/features/clip-features.js +211 -0
  179. package/dist/mvt/lib/vector-tiler/features/clip-features.js.map +1 -0
  180. package/dist/mvt/lib/vector-tiler/features/convert-feature.d.ts +18 -0
  181. package/dist/mvt/lib/vector-tiler/features/convert-feature.d.ts.map +1 -0
  182. package/dist/mvt/lib/vector-tiler/features/convert-feature.js +161 -0
  183. package/dist/mvt/lib/vector-tiler/features/convert-feature.js.map +1 -0
  184. package/dist/mvt/lib/vector-tiler/features/proto-feature.d.ts +30 -0
  185. package/dist/mvt/lib/vector-tiler/features/proto-feature.d.ts.map +1 -0
  186. package/dist/mvt/lib/vector-tiler/features/proto-feature.js +53 -0
  187. package/dist/mvt/lib/vector-tiler/features/proto-feature.js.map +1 -0
  188. package/dist/mvt/lib/vector-tiler/features/simplify-path.d.ts +10 -0
  189. package/dist/mvt/lib/vector-tiler/features/simplify-path.d.ts.map +1 -0
  190. package/dist/mvt/lib/vector-tiler/features/simplify-path.js +67 -0
  191. package/dist/mvt/lib/vector-tiler/features/simplify-path.js.map +1 -0
  192. package/dist/mvt/lib/vector-tiler/features/wrap-features.d.ts +17 -0
  193. package/dist/mvt/lib/vector-tiler/features/wrap-features.d.ts.map +1 -0
  194. package/dist/mvt/lib/vector-tiler/features/wrap-features.js +95 -0
  195. package/dist/mvt/lib/vector-tiler/features/wrap-features.js.map +1 -0
  196. package/dist/mvt/lib/vector-tiler/proto-tile.d.ts +40 -0
  197. package/dist/mvt/lib/vector-tiler/proto-tile.d.ts.map +1 -0
  198. package/dist/mvt/lib/vector-tiler/proto-tile.js +139 -0
  199. package/dist/mvt/lib/vector-tiler/proto-tile.js.map +1 -0
  200. package/dist/mvt/lib/vector-tiler/tile-to-geojson.d.ts +12 -0
  201. package/dist/mvt/lib/vector-tiler/tile-to-geojson.d.ts.map +1 -0
  202. package/dist/mvt/lib/vector-tiler/tile-to-geojson.js +81 -0
  203. package/dist/mvt/lib/vector-tiler/tile-to-geojson.js.map +1 -0
  204. package/dist/mvt/lib/vector-tiler/transform-tile.d.ts +7 -0
  205. package/dist/mvt/lib/vector-tiler/transform-tile.d.ts.map +1 -0
  206. package/dist/mvt/lib/vector-tiler/transform-tile.js +42 -0
  207. package/dist/mvt/lib/vector-tiler/transform-tile.js.map +1 -0
  208. package/dist/mvt/map-style-format.d.ts +13 -0
  209. package/dist/mvt/map-style-format.d.ts.map +1 -0
  210. package/dist/mvt/map-style-format.js +16 -0
  211. package/dist/mvt/map-style-format.js.map +1 -0
  212. package/dist/mvt/map-style-loader-with-parser.d.ts +26 -0
  213. package/dist/mvt/map-style-loader-with-parser.d.ts.map +1 -0
  214. package/dist/mvt/map-style-loader-with-parser.js +38 -0
  215. package/dist/mvt/map-style-loader-with-parser.js.map +1 -0
  216. package/dist/mvt/map-style-loader.d.ts +44 -0
  217. package/dist/mvt/map-style-loader.d.ts.map +1 -0
  218. package/dist/mvt/map-style-loader.js +25 -0
  219. package/dist/mvt/map-style-loader.js.map +1 -0
  220. package/dist/mvt/map-style-schema.d.ts +58 -0
  221. package/dist/mvt/map-style-schema.d.ts.map +1 -0
  222. package/dist/mvt/map-style-schema.js +47 -0
  223. package/dist/mvt/map-style-schema.js.map +1 -0
  224. package/dist/mvt/map-style.d.ts +110 -0
  225. package/dist/mvt/map-style.d.ts.map +1 -0
  226. package/dist/mvt/map-style.js +90 -0
  227. package/dist/mvt/map-style.js.map +1 -0
  228. package/dist/mvt/mvt-format.d.ts +14 -0
  229. package/dist/mvt/mvt-format.d.ts.map +1 -0
  230. package/dist/mvt/mvt-format.js +23 -0
  231. package/dist/mvt/mvt-format.js.map +1 -0
  232. package/dist/mvt/mvt-geojson-loader-types.d.ts +82 -0
  233. package/dist/mvt/mvt-geojson-loader-types.d.ts.map +1 -0
  234. package/dist/mvt/mvt-geojson-loader-types.js +34 -0
  235. package/dist/mvt/mvt-geojson-loader-types.js.map +1 -0
  236. package/dist/mvt/mvt-geojson-loader.cjs +1366 -0
  237. package/dist/mvt/mvt-geojson-loader.cjs.map +6 -0
  238. package/dist/mvt/mvt-geojson-loader.d.ts +32 -0
  239. package/dist/mvt/mvt-geojson-loader.d.ts.map +1 -0
  240. package/dist/mvt/mvt-geojson-loader.js +13 -0
  241. package/dist/mvt/mvt-geojson-loader.js.map +1 -0
  242. package/dist/mvt/mvt-loader-with-parser.d.ts +105 -0
  243. package/dist/mvt/mvt-loader-with-parser.d.ts.map +1 -0
  244. package/dist/mvt/mvt-loader-with-parser.js +21 -0
  245. package/dist/mvt/mvt-loader-with-parser.js.map +1 -0
  246. package/dist/mvt/mvt-loader.d.ts +129 -0
  247. package/dist/mvt/mvt-loader.d.ts.map +1 -0
  248. package/dist/mvt/mvt-loader.js +40 -0
  249. package/dist/mvt/mvt-loader.js.map +1 -0
  250. package/dist/mvt/mvt-source-loader.d.ts +102 -0
  251. package/dist/mvt/mvt-source-loader.d.ts.map +1 -0
  252. package/dist/mvt/mvt-source-loader.js +275 -0
  253. package/dist/mvt/mvt-source-loader.js.map +1 -0
  254. package/dist/mvt/mvt-writer.d.ts +28 -0
  255. package/dist/mvt/mvt-writer.d.ts.map +1 -0
  256. package/dist/mvt/mvt-writer.js +32 -0
  257. package/dist/mvt/mvt-writer.js.map +1 -0
  258. package/dist/mvt/table-tile-source-loader.d.ts +169 -0
  259. package/dist/mvt/table-tile-source-loader.d.ts.map +1 -0
  260. package/dist/mvt/table-tile-source-loader.js +478 -0
  261. package/dist/mvt/table-tile-source-loader.js.map +1 -0
  262. package/dist/mvt/tilejson-format.d.ts +13 -0
  263. package/dist/mvt/tilejson-format.d.ts.map +1 -0
  264. package/dist/mvt/tilejson-format.js +16 -0
  265. package/dist/mvt/tilejson-format.js.map +1 -0
  266. package/dist/mvt/tilejson-loader-with-parser.d.ts +13 -0
  267. package/dist/mvt/tilejson-loader-with-parser.d.ts.map +1 -0
  268. package/dist/mvt/tilejson-loader-with-parser.js +25 -0
  269. package/dist/mvt/tilejson-loader-with-parser.js.map +1 -0
  270. package/dist/mvt/tilejson-loader.d.ts +56 -0
  271. package/dist/mvt/tilejson-loader.d.ts.map +1 -0
  272. package/dist/mvt/tilejson-loader.js +28 -0
  273. package/dist/mvt/tilejson-loader.js.map +1 -0
  274. package/dist/mvt/tilejson-zod-schema.cjs +79 -0
  275. package/dist/mvt/tilejson-zod-schema.cjs.map +6 -0
  276. package/dist/mvt/tilejson-zod-schema.d.ts +218 -0
  277. package/dist/mvt/tilejson-zod-schema.d.ts.map +1 -0
  278. package/dist/mvt/tilejson-zod-schema.js +68 -0
  279. package/dist/mvt/tilejson-zod-schema.js.map +1 -0
  280. package/dist/mvt/tilejson.schema.json +197 -0
  281. package/dist/mvt/unbundled.d.ts +8 -0
  282. package/dist/mvt/unbundled.d.ts.map +1 -0
  283. package/dist/mvt/unbundled.js +8 -0
  284. package/dist/mvt/unbundled.js.map +1 -0
  285. package/dist/mvt/workers/mvt-worker-node.d.ts +2 -0
  286. package/dist/mvt/workers/mvt-worker-node.d.ts.map +1 -0
  287. package/dist/mvt/workers/mvt-worker-node.js +8 -0
  288. package/dist/mvt/workers/mvt-worker-node.js.map +1 -0
  289. package/dist/mvt/workers/mvt-worker.d.ts +2 -0
  290. package/dist/mvt/workers/mvt-worker.d.ts.map +1 -0
  291. package/dist/mvt/workers/mvt-worker.js +7 -0
  292. package/dist/mvt/workers/mvt-worker.js.map +1 -0
  293. package/dist/mvt-worker-node.js +72460 -0
  294. package/dist/mvt-worker-node.js.map +7 -0
  295. package/dist/mvt-worker.js +21239 -0
  296. package/dist/pmtiles/bundled.d.ts +3 -0
  297. package/dist/pmtiles/bundled.d.ts.map +1 -0
  298. package/dist/pmtiles/bundled.js +5 -0
  299. package/dist/pmtiles/bundled.js.map +1 -0
  300. package/dist/pmtiles/dist.dev.js +50530 -0
  301. package/dist/pmtiles/dist.min.js +94 -0
  302. package/dist/pmtiles/geoarrow.cjs +6718 -0
  303. package/dist/pmtiles/geoarrow.cjs.map +6 -0
  304. package/dist/pmtiles/geoarrow.d.ts +30 -0
  305. package/dist/pmtiles/geoarrow.d.ts.map +1 -0
  306. package/dist/pmtiles/geoarrow.js +143 -0
  307. package/dist/pmtiles/geoarrow.js.map +1 -0
  308. package/dist/pmtiles/index.cjs +8011 -0
  309. package/dist/pmtiles/index.cjs.map +6 -0
  310. package/dist/pmtiles/index.d.ts +14 -0
  311. package/dist/pmtiles/index.d.ts.map +1 -0
  312. package/dist/pmtiles/index.js +10 -0
  313. package/dist/pmtiles/index.js.map +1 -0
  314. package/dist/pmtiles/lib/blob-source.d.ts +14 -0
  315. package/dist/pmtiles/lib/blob-source.d.ts.map +1 -0
  316. package/dist/pmtiles/lib/blob-source.js +32 -0
  317. package/dist/pmtiles/lib/blob-source.js.map +1 -0
  318. package/dist/pmtiles/lib/encode-pmtiles.d.ts +8 -0
  319. package/dist/pmtiles/lib/encode-pmtiles.d.ts.map +1 -0
  320. package/dist/pmtiles/lib/encode-pmtiles.js +268 -0
  321. package/dist/pmtiles/lib/encode-pmtiles.js.map +1 -0
  322. package/dist/pmtiles/lib/parse-pmtiles.d.ts +52 -0
  323. package/dist/pmtiles/lib/parse-pmtiles.d.ts.map +1 -0
  324. package/dist/pmtiles/lib/parse-pmtiles.js +95 -0
  325. package/dist/pmtiles/lib/parse-pmtiles.js.map +1 -0
  326. package/dist/pmtiles/lib/range-request-source.d.ts +24 -0
  327. package/dist/pmtiles/lib/range-request-source.d.ts.map +1 -0
  328. package/dist/pmtiles/lib/range-request-source.js +45 -0
  329. package/dist/pmtiles/lib/range-request-source.js.map +1 -0
  330. package/dist/pmtiles/lib/version.d.ts +2 -0
  331. package/dist/pmtiles/lib/version.d.ts.map +1 -0
  332. package/dist/pmtiles/lib/version.js +8 -0
  333. package/dist/pmtiles/lib/version.js.map +1 -0
  334. package/dist/pmtiles/pmtiles-format.d.ts +14 -0
  335. package/dist/pmtiles/pmtiles-format.d.ts.map +1 -0
  336. package/dist/pmtiles/pmtiles-format.js +17 -0
  337. package/dist/pmtiles/pmtiles-format.js.map +1 -0
  338. package/dist/pmtiles/pmtiles-loader-with-parser.d.ts +30 -0
  339. package/dist/pmtiles/pmtiles-loader-with-parser.d.ts.map +1 -0
  340. package/dist/pmtiles/pmtiles-loader-with-parser.js +41 -0
  341. package/dist/pmtiles/pmtiles-loader-with-parser.js.map +1 -0
  342. package/dist/pmtiles/pmtiles-loader.d.ts +41 -0
  343. package/dist/pmtiles/pmtiles-loader.d.ts.map +1 -0
  344. package/dist/pmtiles/pmtiles-loader.js +20 -0
  345. package/dist/pmtiles/pmtiles-loader.js.map +1 -0
  346. package/dist/pmtiles/pmtiles-source-loader.d.ts +85 -0
  347. package/dist/pmtiles/pmtiles-source-loader.d.ts.map +1 -0
  348. package/dist/pmtiles/pmtiles-source-loader.js +239 -0
  349. package/dist/pmtiles/pmtiles-source-loader.js.map +1 -0
  350. package/dist/pmtiles/pmtiles-writer-types.d.ts +39 -0
  351. package/dist/pmtiles/pmtiles-writer-types.d.ts.map +1 -0
  352. package/dist/pmtiles/pmtiles-writer-types.js +5 -0
  353. package/dist/pmtiles/pmtiles-writer-types.js.map +1 -0
  354. package/dist/pmtiles/pmtiles-writer.d.ts +22 -0
  355. package/dist/pmtiles/pmtiles-writer.d.ts.map +1 -0
  356. package/dist/pmtiles/pmtiles-writer.js +15 -0
  357. package/dist/pmtiles/pmtiles-writer.js.map +1 -0
  358. package/dist/pmtiles/raster.cjs +1183 -0
  359. package/dist/pmtiles/raster.cjs.map +6 -0
  360. package/dist/pmtiles/raster.d.ts +30 -0
  361. package/dist/pmtiles/raster.d.ts.map +1 -0
  362. package/dist/pmtiles/raster.js +212 -0
  363. package/dist/pmtiles/raster.js.map +1 -0
  364. package/dist/pmtiles/source-info.d.ts +25 -0
  365. package/dist/pmtiles/source-info.d.ts.map +1 -0
  366. package/dist/{types.js → pmtiles/source-info.js} +1 -1
  367. package/dist/pmtiles/source-info.js.map +1 -0
  368. package/dist/pmtiles/unbundled.d.ts +3 -0
  369. package/dist/pmtiles/unbundled.d.ts.map +1 -0
  370. package/dist/pmtiles/unbundled.js +5 -0
  371. package/dist/pmtiles/unbundled.js.map +1 -0
  372. package/dist/raster-set.d.ts +1 -1
  373. package/dist/raster-set.d.ts.map +1 -1
  374. package/dist/raster-set.js +1 -1
  375. package/dist/raster-set.js.map +1 -1
  376. package/dist/tile-matrix.cjs +81 -0
  377. package/dist/tile-matrix.cjs.map +6 -0
  378. package/dist/tile-matrix.d.ts +52 -0
  379. package/dist/tile-matrix.d.ts.map +1 -0
  380. package/dist/tile-matrix.js +75 -0
  381. package/dist/tile-matrix.js.map +1 -0
  382. package/dist/tileset-2d/tile-2d-header.d.ts +2 -2
  383. package/dist/tileset-2d/tile-2d-header.d.ts.map +1 -1
  384. package/dist/tileset-2d/tile-2d-header.js +11 -11
  385. package/dist/tileset-2d/tile-2d-header.js.map +1 -1
  386. package/dist/tileset-2d/tileset-2d.d.ts +19 -10
  387. package/dist/tileset-2d/tileset-2d.d.ts.map +1 -1
  388. package/dist/tileset-2d/tileset-2d.js +69 -15
  389. package/dist/tileset-2d/tileset-2d.js.map +1 -1
  390. package/dist/tileset-2d.d.ts +2 -1
  391. package/dist/tileset-2d.d.ts.map +1 -1
  392. package/dist/tileset-2d.js +1 -1
  393. package/dist/tileset-2d.js.map +1 -1
  394. package/package.json +104 -16
  395. package/src/image-set.ts +1 -1
  396. package/src/index.ts +9 -123
  397. package/src/mlt/bundled.ts +9 -0
  398. package/src/mlt/index.ts +18 -0
  399. package/src/mlt/lib/encode-mlt-geometry.ts +162 -0
  400. package/src/mlt/lib/encode-mlt-streams.ts +66 -0
  401. package/src/mlt/lib/encode-mlt.ts +215 -0
  402. package/src/mlt/lib/parse-mlt.ts +906 -0
  403. package/src/mlt/libs/mlt-decoder.cjs +4552 -0
  404. package/src/mlt/mlt-format.ts +19 -0
  405. package/src/mlt/mlt-loader-with-parser.ts +57 -0
  406. package/src/mlt/mlt-loader.ts +64 -0
  407. package/src/mlt/mlt-source-loader.ts +266 -0
  408. package/src/mlt/mlt-writer.ts +47 -0
  409. package/src/mlt/unbundled.ts +6 -0
  410. package/src/mvt/arrow-table-tile-source-loader-types.ts +55 -0
  411. package/src/mvt/arrow-table-tile-source-loader.ts +307 -0
  412. package/src/mvt/arrow-table-tile-source-types.ts +32 -0
  413. package/src/mvt/bundled.ts +14 -0
  414. package/src/mvt/index.ts +67 -0
  415. package/src/mvt/lib/encode-mvt-arrow.ts +273 -0
  416. package/src/mvt/lib/encode-mvt.ts +46 -0
  417. package/src/mvt/lib/get-schemas-from-tilejson.ts +64 -0
  418. package/src/mvt/lib/is-longitude-latitude-crs.ts +15 -0
  419. package/src/mvt/lib/mapbox-vt-pbf/geojson-to-vt.ts.disabled +76 -0
  420. package/src/mvt/lib/mapbox-vt-pbf/geojson-wrapper.ts +89 -0
  421. package/src/mvt/lib/mapbox-vt-pbf/to-vector-tile.ts +230 -0
  422. package/src/mvt/lib/mvt-pbf/mvt-constants.ts +135 -0
  423. package/src/mvt/lib/mvt-pbf/mvt-types.ts +22 -0
  424. package/src/mvt/lib/mvt-pbf/parse-geometry-from-pbf.ts +285 -0
  425. package/src/mvt/lib/mvt-pbf/parse-mvt-from-pbf.ts +310 -0
  426. package/src/mvt/lib/mvt-pbf/write-mvt-to-pbf.ts +162 -0
  427. package/src/mvt/lib/mvt-worker-transport.ts +74 -0
  428. package/src/mvt/lib/parse-mvt-geojson.ts +65 -0
  429. package/src/mvt/lib/parse-mvt.ts +145 -0
  430. package/src/mvt/lib/parse-tilejson.ts +397 -0
  431. package/src/mvt/lib/resolve-table-tile-parameters.ts +23 -0
  432. package/src/mvt/lib/types.ts +90 -0
  433. package/src/mvt/lib/utils/geometry-utils.ts +238 -0
  434. package/src/mvt/lib/vector-tile/LICENSE.txt +31 -0
  435. package/src/mvt/lib/vector-tile/vector-tile-feature.ts +430 -0
  436. package/src/mvt/lib/vector-tile/vector-tile-layer.ts +130 -0
  437. package/src/mvt/lib/vector-tile/vector-tile.ts +32 -0
  438. package/src/mvt/lib/vector-tiler/LICENSE +19 -0
  439. package/src/mvt/lib/vector-tiler/arrow-tile.ts +93 -0
  440. package/src/mvt/lib/vector-tiler/features/clip-features.ts +250 -0
  441. package/src/mvt/lib/vector-tiler/features/convert-feature.ts +213 -0
  442. package/src/mvt/lib/vector-tiler/features/proto-feature.ts +104 -0
  443. package/src/mvt/lib/vector-tiler/features/simplify-path.ts +84 -0
  444. package/src/mvt/lib/vector-tiler/features/wrap-features.ts +125 -0
  445. package/src/mvt/lib/vector-tiler/proto-tile.ts +217 -0
  446. package/src/mvt/lib/vector-tiler/tile-to-geojson.ts +104 -0
  447. package/src/mvt/lib/vector-tiler/transform-tile.ts +57 -0
  448. package/src/mvt/map-style-format.ts +18 -0
  449. package/src/mvt/map-style-loader-with-parser.ts +62 -0
  450. package/src/mvt/map-style-loader.ts +31 -0
  451. package/src/mvt/map-style-schema.ts +53 -0
  452. package/src/mvt/map-style.ts +218 -0
  453. package/src/mvt/mvt-format.ts +25 -0
  454. package/src/mvt/mvt-geojson-loader-types.ts +60 -0
  455. package/src/mvt/mvt-geojson-loader.ts +20 -0
  456. package/src/mvt/mvt-loader-with-parser.ts +53 -0
  457. package/src/mvt/mvt-loader.ts +73 -0
  458. package/src/mvt/mvt-source-loader.ts +410 -0
  459. package/src/mvt/mvt-writer.ts +35 -0
  460. package/src/mvt/table-tile-source-loader.ts +672 -0
  461. package/src/mvt/tilejson-format.ts +18 -0
  462. package/src/mvt/tilejson-loader-with-parser.ts +38 -0
  463. package/src/mvt/tilejson-loader.ts +42 -0
  464. package/src/mvt/tilejson-zod-schema.ts +199 -0
  465. package/src/mvt/unbundled.ts +13 -0
  466. package/src/mvt/workers/mvt-worker-node.ts +9 -0
  467. package/src/mvt/workers/mvt-worker.ts +8 -0
  468. package/src/pmtiles/bundled.ts +6 -0
  469. package/src/pmtiles/geoarrow.ts +188 -0
  470. package/src/pmtiles/index.ts +27 -0
  471. package/src/pmtiles/lib/blob-source.ts +41 -0
  472. package/src/pmtiles/lib/encode-pmtiles.ts +322 -0
  473. package/src/pmtiles/lib/parse-pmtiles.ts +180 -0
  474. package/src/pmtiles/lib/range-request-source.ts +60 -0
  475. package/src/pmtiles/lib/version.ts +8 -0
  476. package/src/pmtiles/pmtiles-format.ts +19 -0
  477. package/src/pmtiles/pmtiles-loader-with-parser.ts +60 -0
  478. package/src/pmtiles/pmtiles-loader.ts +30 -0
  479. package/src/pmtiles/pmtiles-source-loader.ts +346 -0
  480. package/src/pmtiles/pmtiles-writer-types.ts +45 -0
  481. package/src/pmtiles/pmtiles-writer.ts +26 -0
  482. package/src/pmtiles/raster.ts +289 -0
  483. package/src/pmtiles/source-info.ts +25 -0
  484. package/src/pmtiles/unbundled.ts +6 -0
  485. package/src/raster-set.ts +2 -2
  486. package/src/tile-matrix.ts +138 -0
  487. package/src/tileset-2d/tile-2d-header.ts +14 -13
  488. package/src/tileset-2d/tileset-2d.ts +81 -19
  489. package/src/tileset-2d.ts +25 -1
  490. package/dist/constants.d.ts +0 -38
  491. package/dist/constants.d.ts.map +0 -1
  492. package/dist/constants.js +0 -39
  493. package/dist/constants.js.map +0 -1
  494. package/dist/point-cloud/point-cloud-tile.d.ts +0 -47
  495. package/dist/point-cloud/point-cloud-tile.d.ts.map +0 -1
  496. package/dist/point-cloud/point-cloud-tile.js +0 -70
  497. package/dist/point-cloud/point-cloud-tile.js.map +0 -1
  498. package/dist/point-cloud/point-cloud-tileset.d.ts +0 -135
  499. package/dist/point-cloud/point-cloud-tileset.d.ts.map +0 -1
  500. package/dist/point-cloud/point-cloud-tileset.js +0 -549
  501. package/dist/point-cloud/point-cloud-tileset.js.map +0 -1
  502. package/dist/point-cloud/types.d.ts +0 -81
  503. package/dist/point-cloud/types.d.ts.map +0 -1
  504. package/dist/point-cloud/types.js.map +0 -1
  505. package/dist/spatial/format-spatial-reference.d.ts +0 -68
  506. package/dist/spatial/format-spatial-reference.d.ts.map +0 -1
  507. package/dist/spatial/format-spatial-reference.js +0 -291
  508. package/dist/spatial/format-spatial-reference.js.map +0 -1
  509. package/dist/spatial/get-spatial-coordinate-frame.d.ts +0 -20
  510. package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +0 -1
  511. package/dist/spatial/get-spatial-coordinate-frame.js +0 -139
  512. package/dist/spatial/get-spatial-coordinate-frame.js.map +0 -1
  513. package/dist/spatial/i3s-elevation.d.ts +0 -20
  514. package/dist/spatial/i3s-elevation.d.ts.map +0 -1
  515. package/dist/spatial/i3s-elevation.js +0 -90
  516. package/dist/spatial/i3s-elevation.js.map +0 -1
  517. package/dist/spatial/i3s-spatial-transformer.d.ts +0 -205
  518. package/dist/spatial/i3s-spatial-transformer.d.ts.map +0 -1
  519. package/dist/spatial/i3s-spatial-transformer.js +0 -731
  520. package/dist/spatial/i3s-spatial-transformer.js.map +0 -1
  521. package/dist/spatial/normalize-crs-identifier.d.ts +0 -15
  522. package/dist/spatial/normalize-crs-identifier.d.ts.map +0 -1
  523. package/dist/spatial/normalize-crs-identifier.js +0 -22
  524. package/dist/spatial/normalize-crs-identifier.js.map +0 -1
  525. package/dist/spatial/spatial-coordinate-transformer.d.ts +0 -52
  526. package/dist/spatial/spatial-coordinate-transformer.d.ts.map +0 -1
  527. package/dist/spatial/spatial-coordinate-transformer.js +0 -295
  528. package/dist/spatial/spatial-coordinate-transformer.js.map +0 -1
  529. package/dist/spatial/spatial-resource-registry.d.ts +0 -47
  530. package/dist/spatial/spatial-resource-registry.d.ts.map +0 -1
  531. package/dist/spatial/spatial-resource-registry.js +0 -76
  532. package/dist/spatial/spatial-resource-registry.js.map +0 -1
  533. package/dist/spatial/spatial-types.d.ts +0 -190
  534. package/dist/spatial/spatial-types.d.ts.map +0 -1
  535. package/dist/spatial/spatial-types.js +0 -192
  536. package/dist/spatial/spatial-types.js.map +0 -1
  537. package/dist/spatial/tiles-3d-spatial-transformer.d.ts +0 -32
  538. package/dist/spatial/tiles-3d-spatial-transformer.d.ts.map +0 -1
  539. package/dist/spatial/tiles-3d-spatial-transformer.js +0 -163
  540. package/dist/spatial/tiles-3d-spatial-transformer.js.map +0 -1
  541. package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts +0 -60
  542. package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts.map +0 -1
  543. package/dist/tileset-3d/common/indexed-archive-tileset-source.js +0 -130
  544. package/dist/tileset-3d/common/indexed-archive-tileset-source.js.map +0 -1
  545. package/dist/tileset-3d/common/tile-3d-contracts.d.ts +0 -63
  546. package/dist/tileset-3d/common/tile-3d-contracts.d.ts.map +0 -1
  547. package/dist/tileset-3d/common/tile-3d-contracts.js +0 -51
  548. package/dist/tileset-3d/common/tile-3d-contracts.js.map +0 -1
  549. package/dist/tileset-3d/common/tile-3d.d.ts +0 -410
  550. package/dist/tileset-3d/common/tile-3d.d.ts.map +0 -1
  551. package/dist/tileset-3d/common/tile-3d.js +0 -1056
  552. package/dist/tileset-3d/common/tile-3d.js.map +0 -1
  553. package/dist/tileset-3d/common/tileset-3d.d.ts +0 -367
  554. package/dist/tileset-3d/common/tileset-3d.d.ts.map +0 -1
  555. package/dist/tileset-3d/common/tileset-3d.js +0 -879
  556. package/dist/tileset-3d/common/tileset-3d.js.map +0 -1
  557. package/dist/tileset-3d/common/tileset-cache.d.ts +0 -29
  558. package/dist/tileset-3d/common/tileset-cache.d.ts.map +0 -1
  559. package/dist/tileset-3d/common/tileset-cache.js +0 -82
  560. package/dist/tileset-3d/common/tileset-cache.js.map +0 -1
  561. package/dist/tileset-3d/common/tileset-content-traversal.d.ts +0 -37
  562. package/dist/tileset-3d/common/tileset-content-traversal.d.ts.map +0 -1
  563. package/dist/tileset-3d/common/tileset-content-traversal.js +0 -80
  564. package/dist/tileset-3d/common/tileset-content-traversal.js.map +0 -1
  565. package/dist/tileset-3d/common/tileset-observability.d.ts +0 -60
  566. package/dist/tileset-3d/common/tileset-observability.d.ts.map +0 -1
  567. package/dist/tileset-3d/common/tileset-observability.js +0 -39
  568. package/dist/tileset-3d/common/tileset-observability.js.map +0 -1
  569. package/dist/tileset-3d/common/tileset-source.d.ts +0 -228
  570. package/dist/tileset-3d/common/tileset-source.d.ts.map +0 -1
  571. package/dist/tileset-3d/common/tileset-source.js +0 -17
  572. package/dist/tileset-3d/common/tileset-source.js.map +0 -1
  573. package/dist/tileset-3d/common/tileset-traverser.d.ts +0 -88
  574. package/dist/tileset-3d/common/tileset-traverser.d.ts.map +0 -1
  575. package/dist/tileset-3d/common/tileset-traverser.js +0 -341
  576. package/dist/tileset-3d/common/tileset-traverser.js.map +0 -1
  577. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +0 -182
  578. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +0 -1
  579. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +0 -681
  580. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +0 -1
  581. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +0 -221
  582. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +0 -1
  583. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +0 -770
  584. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +0 -1
  585. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts +0 -111
  586. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts.map +0 -1
  587. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js +0 -339
  588. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
  589. package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.d.ts +0 -27
  590. package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.d.ts.map +0 -1
  591. package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.js +0 -45
  592. package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.js.map +0 -1
  593. package/dist/tileset-3d/format-i3s/i3s-source.d.ts +0 -116
  594. package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +0 -1
  595. package/dist/tileset-3d/format-i3s/i3s-source.js +0 -450
  596. package/dist/tileset-3d/format-i3s/i3s-source.js.map +0 -1
  597. package/dist/tileset-3d/format-i3s/i3s-tile-manager.d.ts +0 -34
  598. package/dist/tileset-3d/format-i3s/i3s-tile-manager.d.ts.map +0 -1
  599. package/dist/tileset-3d/format-i3s/i3s-tile-manager.js +0 -81
  600. package/dist/tileset-3d/format-i3s/i3s-tile-manager.js.map +0 -1
  601. package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.d.ts +0 -25
  602. package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.d.ts.map +0 -1
  603. package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js +0 -84
  604. package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js.map +0 -1
  605. package/dist/tileset-3d/helpers/3d-tiles-options.d.ts +0 -5
  606. package/dist/tileset-3d/helpers/3d-tiles-options.d.ts.map +0 -1
  607. package/dist/tileset-3d/helpers/3d-tiles-options.js +0 -9
  608. package/dist/tileset-3d/helpers/3d-tiles-options.js.map +0 -1
  609. package/dist/tileset-3d/helpers/bounding-volume.d.ts +0 -23
  610. package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +0 -1
  611. package/dist/tileset-3d/helpers/bounding-volume.js +0 -236
  612. package/dist/tileset-3d/helpers/bounding-volume.js.map +0 -1
  613. package/dist/tileset-3d/helpers/frame-state.d.ts +0 -93
  614. package/dist/tileset-3d/helpers/frame-state.d.ts.map +0 -1
  615. package/dist/tileset-3d/helpers/frame-state.js +0 -211
  616. package/dist/tileset-3d/helpers/frame-state.js.map +0 -1
  617. package/dist/tileset-3d/helpers/i3s-lod.d.ts +0 -20
  618. package/dist/tileset-3d/helpers/i3s-lod.d.ts.map +0 -1
  619. package/dist/tileset-3d/helpers/i3s-lod.js +0 -95
  620. package/dist/tileset-3d/helpers/i3s-lod.js.map +0 -1
  621. package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts +0 -17
  622. package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +0 -1
  623. package/dist/tileset-3d/helpers/s2-bounding-volume.js +0 -20
  624. package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +0 -1
  625. package/dist/tileset-3d/helpers/tiles-3d-lod.d.ts +0 -72
  626. package/dist/tileset-3d/helpers/tiles-3d-lod.d.ts.map +0 -1
  627. package/dist/tileset-3d/helpers/tiles-3d-lod.js +0 -257
  628. package/dist/tileset-3d/helpers/tiles-3d-lod.js.map +0 -1
  629. package/dist/tileset-3d/helpers/tiles-3d-request-priority.d.ts +0 -134
  630. package/dist/tileset-3d/helpers/tiles-3d-request-priority.d.ts.map +0 -1
  631. package/dist/tileset-3d/helpers/tiles-3d-request-priority.js +0 -179
  632. package/dist/tileset-3d/helpers/tiles-3d-request-priority.js.map +0 -1
  633. package/dist/tileset-3d/helpers/transform-utils.d.ts +0 -3
  634. package/dist/tileset-3d/helpers/transform-utils.d.ts.map +0 -1
  635. package/dist/tileset-3d/helpers/transform-utils.js +0 -86
  636. package/dist/tileset-3d/helpers/transform-utils.js.map +0 -1
  637. package/dist/tileset-3d/helpers/zoom.d.ts +0 -46
  638. package/dist/tileset-3d/helpers/zoom.d.ts.map +0 -1
  639. package/dist/tileset-3d/helpers/zoom.js +0 -86
  640. package/dist/tileset-3d/helpers/zoom.js.map +0 -1
  641. package/dist/types.d.ts +0 -48
  642. package/dist/types.d.ts.map +0 -1
  643. package/dist/types.js.map +0 -1
  644. package/dist/utils/doubly-linked-list-node.d.ts +0 -11
  645. package/dist/utils/doubly-linked-list-node.d.ts.map +0 -1
  646. package/dist/utils/doubly-linked-list-node.js +0 -20
  647. package/dist/utils/doubly-linked-list-node.js.map +0 -1
  648. package/dist/utils/doubly-linked-list.d.ts +0 -30
  649. package/dist/utils/doubly-linked-list.d.ts.map +0 -1
  650. package/dist/utils/doubly-linked-list.js +0 -93
  651. package/dist/utils/doubly-linked-list.js.map +0 -1
  652. package/dist/utils/managed-array.d.ts +0 -85
  653. package/dist/utils/managed-array.d.ts.map +0 -1
  654. package/dist/utils/managed-array.js +0 -152
  655. package/dist/utils/managed-array.js.map +0 -1
  656. package/src/constants.ts +0 -59
  657. package/src/point-cloud/point-cloud-tile.ts +0 -80
  658. package/src/point-cloud/point-cloud-tileset.ts +0 -767
  659. package/src/point-cloud/types.ts +0 -99
  660. package/src/spatial/format-spatial-reference.ts +0 -385
  661. package/src/spatial/get-spatial-coordinate-frame.ts +0 -169
  662. package/src/spatial/i3s-elevation.ts +0 -96
  663. package/src/spatial/i3s-spatial-transformer.ts +0 -1021
  664. package/src/spatial/normalize-crs-identifier.ts +0 -26
  665. package/src/spatial/spatial-coordinate-transformer.ts +0 -377
  666. package/src/spatial/spatial-resource-registry.ts +0 -90
  667. package/src/spatial/spatial-types.ts +0 -422
  668. package/src/spatial/tiles-3d-spatial-transformer.ts +0 -194
  669. package/src/tileset-3d/common/indexed-archive-tileset-source.ts +0 -205
  670. package/src/tileset-3d/common/tile-3d-contracts.ts +0 -115
  671. package/src/tileset-3d/common/tile-3d.ts +0 -1310
  672. package/src/tileset-3d/common/tileset-3d.ts +0 -1208
  673. package/src/tileset-3d/common/tileset-cache.ts +0 -111
  674. package/src/tileset-3d/common/tileset-content-traversal.ts +0 -114
  675. package/src/tileset-3d/common/tileset-observability.ts +0 -100
  676. package/src/tileset-3d/common/tileset-source.ts +0 -284
  677. package/src/tileset-3d/common/tileset-traverser.ts +0 -416
  678. package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +0 -1059
  679. package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +0 -1025
  680. package/src/tileset-3d/format-3d-tiles/tileset-3d-traverser.ts +0 -391
  681. package/src/tileset-3d/format-i3s/i3s-pending-tiles-register.ts +0 -48
  682. package/src/tileset-3d/format-i3s/i3s-source.ts +0 -557
  683. package/src/tileset-3d/format-i3s/i3s-tile-manager.ts +0 -105
  684. package/src/tileset-3d/format-i3s/i3s-tileset-traverser.ts +0 -102
  685. package/src/tileset-3d/helpers/3d-tiles-options.ts +0 -11
  686. package/src/tileset-3d/helpers/bounding-volume.ts +0 -281
  687. package/src/tileset-3d/helpers/frame-state.ts +0 -322
  688. package/src/tileset-3d/helpers/i3s-lod.ts +0 -109
  689. package/src/tileset-3d/helpers/s2-bounding-volume.ts +0 -35
  690. package/src/tileset-3d/helpers/tiles-3d-lod.ts +0 -370
  691. package/src/tileset-3d/helpers/tiles-3d-request-priority.ts +0 -301
  692. package/src/tileset-3d/helpers/transform-utils.ts +0 -109
  693. package/src/tileset-3d/helpers/zoom.ts +0 -120
  694. package/src/types.ts +0 -54
  695. package/src/utils/doubly-linked-list-node.ts +0 -22
  696. package/src/utils/doubly-linked-list.ts +0 -105
  697. package/src/utils/managed-array.ts +0 -174
  698. /package/dist/{point-cloud → mvt/lib}/types.js +0 -0
package/dist/dist.min.js CHANGED
@@ -4,8 +4,8 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var fd=Object.create;var pn=Object.defineProperty;var dd=Object.getOwnPropertyDescriptor;var md=Object.getOwnPropertyNames;var pd=Object.getPrototypeOf,gd=Object.prototype.hasOwnProperty;var Md=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},ao=(t,e)=>{for(var r in e)pn(t,r,{get:e[r],enumerable:!0})},mn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of md(e))!gd.call(t,i)&&i!==r&&pn(t,i,{get:()=>e[i],enumerable:!(n=dd(e,i))||n.enumerable});return t},gn=(t,e,r)=>(mn(t,e,"default"),r&&mn(r,e,"default")),yd=(t,e,r)=>(r=t!=null?fd(pd(t)):{},mn(e||!t||!t.__esModule?pn(r,"default",{value:t,enumerable:!0}):r,t)),xd=t=>mn(pn({},"__esModule",{value:!0}),t);var Oa=Md((SM,Na)=>{Na.exports=globalThis.loaders});var fn={};ao(fn,{I3SSource:()=>Zi,I3SSpatialTransformer:()=>gr,ImageSet:()=>Ji,IndexedArchiveTilesetSource:()=>hi,LOD_METRIC_TYPE:()=>Zt,PointCloudTile:()=>Mr,PointCloudTileset:()=>ro,RasterSet:()=>eo,STRATEGY_DEFAULT:()=>hn,STRATEGY_NEVER:()=>Ra,STRATEGY_REPLACE:()=>Ca,SharedTile2DHeader:()=>Dt,SpatialCoordinateTransformer:()=>We,TILESET_TYPE:()=>le,TILE_CONTENT_STATE:()=>he,TILE_REFINEMENT:()=>ne,TILE_TYPE:()=>tt,Tile3D:()=>Ne,Tiles3DSource:()=>$i,Tiles3DSpatialTransformer:()=>Pt,Tileset2D:()=>ln,Tileset3D:()=>si,TilesetCache:()=>Kt,TilesetTraverser:()=>rt,applyTilesetSpatialOptions:()=>It,calculateTransformProps:()=>Jn,convertS2BoundingVolumeToOBB:()=>Wi,createBoundingVolume:()=>er,createImplicitSubtreeReference:()=>Ea,createTilesetSpatialReference:()=>Ie,get3DTilesSpatialReference:()=>gi,getFrameState:()=>ei,getGeoidModel:()=>Ui,getI3SSpatialReference:()=>pi,getLodStatus:()=>di,getSpatialCoordinateFrame:()=>Ae,getTileset3DTraversalSnapshot:()=>ah,isTileset3DSource:()=>ii,markTilesetSpatialReferenceTransformed:()=>Jt,materializeImplicitSubtree:()=>Hi,registerGeoidModel:()=>ga,registerGeoidModelFromPgm:()=>x0,registerSpatialCrs:()=>M0,registerSpatialDatumGrid:()=>y0,replaceImplicitUrlTemplate:()=>cn,traverseTilesetContents:()=>ch});gn(fn,yd(Oa(),1));var j={};ao(j,{EPSILON1:()=>_d,EPSILON10:()=>Cd,EPSILON11:()=>Ad,EPSILON12:()=>Id,EPSILON13:()=>Nd,EPSILON14:()=>Mn,EPSILON15:()=>Od,EPSILON16:()=>Ld,EPSILON17:()=>Gd,EPSILON18:()=>zd,EPSILON19:()=>qd,EPSILON2:()=>wd,EPSILON20:()=>Fd,EPSILON3:()=>Sd,EPSILON4:()=>Ed,EPSILON5:()=>Td,EPSILON6:()=>bd,EPSILON7:()=>vd,EPSILON8:()=>Pd,EPSILON9:()=>Rd,PI:()=>Ut,PI_OVER_FOUR:()=>Dd,PI_OVER_SIX:()=>kd,PI_OVER_TWO:()=>Bd,TWO_PI:()=>yr});var _d=.1,wd=.01,Sd=.001,Ed=1e-4,Td=1e-5,bd=1e-6,vd=1e-7,Pd=1e-8,Rd=1e-9,Cd=1e-10,Ad=1e-11,Id=1e-12,Nd=1e-13,Mn=1e-14,Od=1e-15,Ld=1e-16,Gd=1e-17,zd=1e-18,qd=1e-19,Fd=1e-20,Bd=Math.PI/2,Dd=Math.PI/4,kd=Math.PI/6,Ut=Math.PI,yr=Math.PI*2;var Ud=1/Math.PI*180,Vd=1/180*Math.PI,jd={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...jd}};var X=globalThis.mathgl.config;function co(t,{precision:e=X.precision}={}){return t=Hd(t),`${parseFloat(t.toPrecision(e))}`}function Fe(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function lo(t){return yn(t)}function ho(t){return ye(t)}function yn(t,e){return fo(t,r=>r*Vd,e)}function ye(t,e){return fo(t,r=>r*Ud,e)}function La(t,e){return Math.sign(t)===Math.sign(e)&&Math.abs(t)<Math.abs(e)?t:(t%e+e)%e}function uo(t,e){switch(e){case"negative-pi-to-pi":return Wd(t);case"zero-to-two-pi":return Ga(t);default:return t}}function Ga(t){if(t>=0&&t<=yr)return t;let e=La(t,yr);return Math.abs(e)<1e-14&&Math.abs(t)>1e-14?yr:e}function Wd(t){return t>=-Ut&&t<=Ut?t:Ga(t+Ut)-Ut}function xr(t,e,r){return fo(t,n=>Math.max(e,Math.min(r,n)))}function Re(t,e,r){let n=X.EPSILON;r&&(X.EPSILON=r);try{if(t===e)return!0;if(Fe(t)&&Fe(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;++i)if(!Re(t[i],e[i]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=X.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{X.EPSILON=n}}function Hd(t){return Math.round(t/X.EPSILON)*X.EPSILON}function $d(t){return t.clone?t.clone():new Array(t.length)}function fo(t,e,r){if(Fe(t)){let n=t;r=r||$d(n);for(let i=0;i<r.length&&i<n.length;++i){let o=typeof t=="number"?t:t[i];r[i]=e(o,i,r)}return r}return e(t)}var gt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Fe(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toString(){return this.formatString(X)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+co(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Re(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let i=0;i<this.ELEMENTS;++i){let o=e[i],s=typeof r=="number"?r:r[i];this[i]=o+n*(s-o)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(X.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}};function Yd(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function H(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Vt(t,e,r=""){if(X.debug&&!Yd(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}var jt=class extends gt{toString(){let e="[";if(X.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=H(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let i=0;i<this.RANK;++i)r[i]=this[n+i];return r}setColumn(e,r){let n=e*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=r[i];return this}};function ae(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Wt=class extends gt{get x(){return this[0]}set x(e){this[0]=H(e)}get y(){return this[1]}set y(e){this[1]=H(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-e[n];r+=i*i}return H(r)}dot(e){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*e[n];return H(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return ae(e>=0&&e<this.ELEMENTS,"index is out of range"),H(this[e])}setComponent(e,r){return ae(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e[n]*r;return this.check()}};var xn=typeof Float32Array<"u"?Float32Array:Array;var FM=Math.PI/180;function za(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t}function qa(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t}function _n(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t}function wn(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t}function Sn(t,e,r){let n=e[0],i=e[1],o=r[3]*n+r[7]*i||1;return t[0]=(r[0]*n+r[4]*i)/o,t[1]=(r[1]*n+r[5]*i)/o,t}function En(t,e,r){let n=e[0],i=e[1],o=e[2],s=r[3]*n+r[7]*i+r[11]*o||1;return t[0]=(r[0]*n+r[4]*i+r[8]*o)/s,t[1]=(r[1]*n+r[5]*i+r[9]*o)/s,t[2]=(r[2]*n+r[6]*i+r[10]*o)/s,t}function Fa(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t[2]=e[2],t}function Ba(t,e,r){let n=e[0],i=e[1],o=e[2];return t[0]=r[0]*n+r[3]*i+r[6]*o,t[1]=r[1]*n+r[4]*i+r[7]*o,t[2]=r[2]*n+r[5]*i+r[8]*o,t[3]=e[3],t}var Be=class extends Wt{constructor(e=0,r=0){super(2),Fe(e)&&arguments.length===1?this.copy(e):(X.debug&&(H(e),H(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return X.debug&&(H(e.x),H(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return wn(this,this,e),this.check()}transformAsVector(e){return Sn(this,this,e),this.check()}transformByMatrix3(e){return _n(this,this,e),this.check()}transformByMatrix2x3(e){return qa(this,this,e),this.check()}transformByMatrix2(e){return za(this,this,e),this.check()}};function Da(){let t=new xn(3);return xn!==Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function mo(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function po(t,e,r){let n=new xn(3);return n[0]=t,n[1]=e,n[2]=r,n}function ka(t,e){let r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function wr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ht(t,e,r){let n=e[0],i=e[1],o=e[2],s=r[0],a=r[1],c=r[2];return t[0]=i*c-o*a,t[1]=o*s-n*c,t[2]=n*a-i*s,t}function Tn(t,e,r){let n=e[0],i=e[1],o=e[2],s=r[3]*n+r[7]*i+r[11]*o+r[15];return s=s||1,t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/s,t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/s,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/s,t}function bn(t,e,r){let n=e[0],i=e[1],o=e[2];return t[0]=n*r[0]+i*r[3]+o*r[6],t[1]=n*r[1]+i*r[4]+o*r[7],t[2]=n*r[2]+i*r[5]+o*r[8],t}function Ua(t,e,r){let n=r[0],i=r[1],o=r[2],s=r[3],a=e[0],c=e[1],l=e[2],h=i*l-o*c,u=o*a-n*l,f=n*c-i*a,d=i*f-o*u,m=o*h-n*f,p=n*u-i*h,g=s*2;return h*=g,u*=g,f*=g,d*=2,m*=2,p*=2,t[0]=a+h+d,t[1]=c+u+m,t[2]=l+f+p,t}function Va(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0],o[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),o[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function ja(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),o[1]=i[1],o[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Wa(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),o[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),o[2]=i[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Ha(t,e){let r=t[0],n=t[1],i=t[2],o=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+n*n+i*i)*(o*o+s*s+a*a)),l=c&&wr(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var $a=mo;var go=[0,0,0],vn,M=class t extends Wt{static get ZERO(){return vn||(vn=new t(0,0,0),Object.freeze(vn)),vn}constructor(e=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Fe(e)?this.copy(e):(X.debug&&(H(e),H(r),H(n)),this[0]=e,this[1]=r,this[2]=n)}set(e,r,n){return this[0]=e,this[1]=r,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return X.debug&&(H(e.x),H(e.y),H(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=H(e)}angle(e){return Ha(this,e)}cross(e){return Ht(this,this,e),this.check()}rotateX({radians:e,origin:r=go}){return Va(this,this,r,e),this.check()}rotateY({radians:e,origin:r=go}){return ja(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=go}){return Wa(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Tn(this,this,e),this.check()}transformAsVector(e){return En(this,this,e),this.check()}transformByMatrix3(e){return bn(this,this,e),this.check()}transformByMatrix2(e){return Fa(this,this,e),this.check()}transformByQuaternion(e){return Ua(this,this,e),this.check()}};function Ya(t,e){if(t===e){let r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function Xa(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=h*s-a*l,f=-h*o+a*c,d=l*o-s*c,m=r*u+n*f+i*d;return m?(m=1/m,t[0]=u*m,t[1]=(-h*n+i*l)*m,t[2]=(a*n-i*s)*m,t[3]=f*m,t[4]=(h*r-i*c)*m,t[5]=(-a*r+i*o)*m,t[6]=d*m,t[7]=(-l*r+n*c)*m,t[8]=(s*r-n*o)*m,t):null}function Ka(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],l=t[8];return e*(l*o-s*c)+r*(-l*i+s*a)+n*(c*i-o*a)}function Mo(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=r[0],d=r[1],m=r[2],p=r[3],g=r[4],y=r[5],x=r[6],w=r[7],_=r[8];return t[0]=f*n+d*s+m*l,t[1]=f*i+d*a+m*h,t[2]=f*o+d*c+m*u,t[3]=p*n+g*s+y*l,t[4]=p*i+g*a+y*h,t[5]=p*o+g*c+y*u,t[6]=x*n+w*s+_*l,t[7]=x*i+w*a+_*h,t[8]=x*o+w*c+_*u,t}function Za(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=r[0],d=r[1];return t[0]=n,t[1]=i,t[2]=o,t[3]=s,t[4]=a,t[5]=c,t[6]=f*n+d*s+l,t[7]=f*i+d*a+h,t[8]=f*o+d*c+u,t}function Qa(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=Math.sin(r),d=Math.cos(r);return t[0]=d*n+f*s,t[1]=d*i+f*a,t[2]=d*o+f*c,t[3]=d*s-f*n,t[4]=d*a-f*i,t[5]=d*c-f*o,t[6]=l,t[7]=h,t[8]=u,t}function yo(t,e,r){let n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function Ja(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r+r,a=n+n,c=i+i,l=r*s,h=n*s,u=n*a,f=i*s,d=i*a,m=i*c,p=o*s,g=o*a,y=o*c;return t[0]=1-u-m,t[3]=h-y,t[6]=f+g,t[1]=h+y,t[4]=1-l-m,t[7]=d-p,t[2]=f-g,t[5]=d+p,t[8]=1-l-u,t}var xo;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(xo||(xo={}));var Zd=Object.freeze([1,0,0,0,1,0,0,0,1]),$=class extends jt{static get IDENTITY(){return Jd()}static get ZERO(){return Qd()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return xo}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(Zd)}fromObject(e){return this.check()}fromQuaternion(e){return Ja(this,e),this.check()}fromMatrix4(e){return this.set(e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10])}set(e,r,n,i,o,s,a,c,l){return this[0]=e,this[1]=r,this[2]=n,this[3]=i,this[4]=o,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,n,i,o,s,a,c,l){return this[0]=e,this[1]=i,this[2]=a,this[3]=r,this[4]=o,this[5]=c,this[6]=n,this[7]=s,this[8]=l,this.check()}determinant(){return Ka(this)}transpose(){return Ya(this,this),this.check()}invert(){return Xa(this,this),this.check()}multiplyLeft(e){return Mo(this,e,this),this.check()}multiplyRight(e){return Mo(this,this,e),this.check()}rotate(e){return Qa(this,this,e),this.check()}scale(e){return Array.isArray(e)?yo(this,this,e):yo(this,this,[e,e]),this.check()}translate(e){return Za(this,this,e),this.check()}transform(e,r){let n;switch(e.length){case 2:n=_n(r||[-0,-0],e,this);break;case 3:n=bn(r||[-0,-0,-0],e,this);break;case 4:n=Ba(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Vt(n,e.length),n}},Pn,Rn=null;function Qd(){return Pn||(Pn=new $([0,0,0,0,0,0,0,0,0]),Object.freeze(Pn)),Pn}function Jd(){return Rn||(Rn=new $,Object.freeze(Rn)),Rn}function em(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ec(t,e){if(t===e){let r=e[1],n=e[2],i=e[3],o=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=i,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function tc(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],f=e[10],d=e[11],m=e[12],p=e[13],g=e[14],y=e[15],x=r*a-n*s,w=r*c-i*s,_=r*l-o*s,S=n*c-i*a,E=n*l-o*a,v=i*l-o*c,T=h*p-u*m,I=h*g-f*m,P=h*y-d*m,R=u*g-f*p,N=u*y-d*p,q=f*y-d*g,O=x*q-w*N+_*R+S*P-E*I+v*T;return O?(O=1/O,t[0]=(a*q-c*N+l*R)*O,t[1]=(i*N-n*q-o*R)*O,t[2]=(p*v-g*E+y*S)*O,t[3]=(f*E-u*v-d*S)*O,t[4]=(c*P-s*q-l*I)*O,t[5]=(r*q-i*P+o*I)*O,t[6]=(g*_-m*v-y*w)*O,t[7]=(h*v-f*_+d*w)*O,t[8]=(s*N-a*P+l*T)*O,t[9]=(n*P-r*N-o*T)*O,t[10]=(m*E-p*_+y*x)*O,t[11]=(u*_-h*E-d*x)*O,t[12]=(a*I-s*R-c*T)*O,t[13]=(r*R-n*I+i*T)*O,t[14]=(p*w-m*S-g*x)*O,t[15]=(h*S-u*w+f*x)*O,t):null}function rc(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],l=t[8],h=t[9],u=t[10],f=t[11],d=t[12],m=t[13],p=t[14],g=t[15],y=e*s-r*o,x=e*a-n*o,w=r*a-n*s,_=l*m-h*d,S=l*p-u*d,E=h*p-u*m,v=e*E-r*S+n*_,T=o*E-s*S+a*_,I=l*w-h*x+u*y,P=d*w-m*x+p*y;return c*v-i*T+g*I-f*P}function _o(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],m=e[11],p=e[12],g=e[13],y=e[14],x=e[15],w=r[0],_=r[1],S=r[2],E=r[3];return t[0]=w*n+_*a+S*u+E*p,t[1]=w*i+_*c+S*f+E*g,t[2]=w*o+_*l+S*d+E*y,t[3]=w*s+_*h+S*m+E*x,w=r[4],_=r[5],S=r[6],E=r[7],t[4]=w*n+_*a+S*u+E*p,t[5]=w*i+_*c+S*f+E*g,t[6]=w*o+_*l+S*d+E*y,t[7]=w*s+_*h+S*m+E*x,w=r[8],_=r[9],S=r[10],E=r[11],t[8]=w*n+_*a+S*u+E*p,t[9]=w*i+_*c+S*f+E*g,t[10]=w*o+_*l+S*d+E*y,t[11]=w*s+_*h+S*m+E*x,w=r[12],_=r[13],S=r[14],E=r[15],t[12]=w*n+_*a+S*u+E*p,t[13]=w*i+_*c+S*f+E*g,t[14]=w*o+_*l+S*d+E*y,t[15]=w*s+_*h+S*m+E*x,t}function nc(t,e,r){let n=r[0],i=r[1],o=r[2],s,a,c,l,h,u,f,d,m,p,g,y;return e===t?(t[12]=e[0]*n+e[4]*i+e[8]*o+e[12],t[13]=e[1]*n+e[5]*i+e[9]*o+e[13],t[14]=e[2]*n+e[6]*i+e[10]*o+e[14],t[15]=e[3]*n+e[7]*i+e[11]*o+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],h=e[4],u=e[5],f=e[6],d=e[7],m=e[8],p=e[9],g=e[10],y=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=h,t[5]=u,t[6]=f,t[7]=d,t[8]=m,t[9]=p,t[10]=g,t[11]=y,t[12]=s*n+h*i+m*o+e[12],t[13]=a*n+u*i+p*o+e[13],t[14]=c*n+f*i+g*o+e[14],t[15]=l*n+d*i+y*o+e[15]),t}function ic(t,e,r){let n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function oc(t,e,r,n){let i=n[0],o=n[1],s=n[2],a=Math.sqrt(i*i+o*o+s*s),c,l,h,u,f,d,m,p,g,y,x,w,_,S,E,v,T,I,P,R,N,q,O,k;return a<1e-6?null:(a=1/a,i*=a,o*=a,s*=a,l=Math.sin(r),c=Math.cos(r),h=1-c,u=e[0],f=e[1],d=e[2],m=e[3],p=e[4],g=e[5],y=e[6],x=e[7],w=e[8],_=e[9],S=e[10],E=e[11],v=i*i*h+c,T=o*i*h+s*l,I=s*i*h-o*l,P=i*o*h-s*l,R=o*o*h+c,N=s*o*h+i*l,q=i*s*h+o*l,O=o*s*h-i*l,k=s*s*h+c,t[0]=u*v+p*T+w*I,t[1]=f*v+g*T+_*I,t[2]=d*v+y*T+S*I,t[3]=m*v+x*T+E*I,t[4]=u*P+p*R+w*N,t[5]=f*P+g*R+_*N,t[6]=d*P+y*R+S*N,t[7]=m*P+x*R+E*N,t[8]=u*q+p*O+w*k,t[9]=f*q+g*O+_*k,t[10]=d*q+y*O+S*k,t[11]=m*q+x*O+E*k,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function sc(t,e,r){let n=Math.sin(r),i=Math.cos(r),o=e[4],s=e[5],a=e[6],c=e[7],l=e[8],h=e[9],u=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+l*n,t[5]=s*i+h*n,t[6]=a*i+u*n,t[7]=c*i+f*n,t[8]=l*i-o*n,t[9]=h*i-s*n,t[10]=u*i-a*n,t[11]=f*i-c*n,t}function ac(t,e,r){let n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],c=e[3],l=e[8],h=e[9],u=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-l*n,t[1]=s*i-h*n,t[2]=a*i-u*n,t[3]=c*i-f*n,t[8]=o*n+l*i,t[9]=s*n+h*i,t[10]=a*n+u*i,t[11]=c*n+f*i,t}function cc(t,e,r){let n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],c=e[3],l=e[4],h=e[5],u=e[6],f=e[7];return e!==t&&(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[0]=o*i+l*n,t[1]=s*i+h*n,t[2]=a*i+u*n,t[3]=c*i+f*n,t[4]=l*i-o*n,t[5]=h*i-s*n,t[6]=u*i-a*n,t[7]=f*i-c*n,t}function lc(t,e){let r=e[0],n=e[1],i=e[2],o=e[4],s=e[5],a=e[6],c=e[8],l=e[9],h=e[10];return t[0]=Math.sqrt(r*r+n*n+i*i),t[1]=Math.sqrt(o*o+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+h*h),t}function hc(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r+r,a=n+n,c=i+i,l=r*s,h=n*s,u=n*a,f=i*s,d=i*a,m=i*c,p=o*s,g=o*a,y=o*c;return t[0]=1-u-m,t[1]=h+y,t[2]=f-g,t[3]=0,t[4]=h-y,t[5]=1-l-m,t[6]=d+p,t[7]=0,t[8]=f+g,t[9]=d-p,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function uc(t,e,r,n,i,o,s){let a=1/(r-e),c=1/(i-n),l=1/(o-s);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(i+n)*c,t[10]=(s+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*l,t[15]=0,t}function tm(t,e,r,n,i){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){let s=1/(n-i);t[10]=(i+n)*s,t[14]=2*i*n*s}else t[10]=-1,t[14]=-2*n;return t}var fc=tm;function rm(t,e,r,n,i,o,s){let a=1/(e-r),c=1/(n-i),l=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(i+n)*c,t[14]=(s+o)*l,t[15]=1,t}var dc=rm;function mc(t,e,r,n){let i,o,s,a,c,l,h,u,f,d,m=e[0],p=e[1],g=e[2],y=n[0],x=n[1],w=n[2],_=r[0],S=r[1],E=r[2];return Math.abs(m-_)<1e-6&&Math.abs(p-S)<1e-6&&Math.abs(g-E)<1e-6?em(t):(u=m-_,f=p-S,d=g-E,i=1/Math.sqrt(u*u+f*f+d*d),u*=i,f*=i,d*=i,o=x*d-w*f,s=w*u-y*d,a=y*f-x*u,i=Math.sqrt(o*o+s*s+a*a),i?(i=1/i,o*=i,s*=i,a*=i):(o=0,s=0,a=0),c=f*a-d*s,l=d*o-u*a,h=u*s-f*o,i=Math.sqrt(c*c+l*l+h*h),i?(i=1/i,c*=i,l*=i,h*=i):(c=0,l=0,h=0),t[0]=o,t[1]=c,t[2]=u,t[3]=0,t[4]=s,t[5]=l,t[6]=f,t[7]=0,t[8]=a,t[9]=h,t[10]=d,t[11]=0,t[12]=-(o*m+s*p+a*g),t[13]=-(c*m+l*p+h*g),t[14]=-(u*m+f*p+d*g),t[15]=1,t)}function pc(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function gc(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function Mc(t){let e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}function yc(t){let e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}function xc(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r*r+n*n+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=o*s,t}function _c(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function wc(t,e,r,n){let i=e[0],o=e[1],s=e[2],a=e[3];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=s+n*(r[2]-s),t[3]=a+n*(r[3]-a),t}function Sc(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*o+r[12]*s,t[1]=r[1]*n+r[5]*i+r[9]*o+r[13]*s,t[2]=r[2]*n+r[6]*i+r[10]*o+r[14]*s,t[3]=r[3]*n+r[7]*i+r[11]*o+r[15]*s,t}var Eo;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Eo||(Eo={}));var im=45*Math.PI/180,om=1,wo=.1,So=500,sm=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),z=class extends jt{static get IDENTITY(){return cm()}static get ZERO(){return am()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Eo}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,i,o,s,a,c,l,h,u,f,d,m,p,g){return this[0]=e,this[1]=r,this[2]=n,this[3]=i,this[4]=o,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this[9]=h,this[10]=u,this[11]=f,this[12]=d,this[13]=m,this[14]=p,this[15]=g,this.check()}setRowMajor(e,r,n,i,o,s,a,c,l,h,u,f,d,m,p,g){return this[0]=e,this[1]=o,this[2]=l,this[3]=d,this[4]=r,this[5]=s,this[6]=h,this[7]=m,this[8]=n,this[9]=a,this[10]=u,this[11]=p,this[12]=i,this[13]=c,this[14]=f,this[15]=g,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(sm)}fromObject(e){return this.check()}fromQuaternion(e){return hc(this,e),this.check()}fromMatrix3(e){return this.set(e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1)}frustum(e){let{left:r,right:n,bottom:i,top:o,near:s=wo,far:a=So}=e;return a===1/0?lm(this,r,n,i,o,s):uc(this,r,n,i,o,s,a),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:i=[0,1,0]}=e;return mc(this,r,n,i),this.check()}ortho(e){let{left:r,right:n,bottom:i,top:o,near:s=wo,far:a=So}=e;return dc(this,r,n,i,o,s,a),this.check()}orthographic(e){let{fovy:r=im,aspect:n=om,focalDistance:i=1,near:o=wo,far:s=So}=e;Ec(r);let a=r/2,c=i*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:o,far:s})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:i=.1,far:o=500}=e;return Ec(r),fc(this,r,n,i,o),this.check()}determinant(){return rc(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],o=1/n[1],s=1/n[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*i,e[5]=this[5]*o,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*i,e[9]=this[9]*o,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],o=1/n[1],s=1/n[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*s,e[3]=this[4]*i,e[4]=this[5]*o,e[5]=this[6]*s,e[6]=this[8]*i,e[7]=this[9]*o,e[8]=this[10]*s,e}transpose(){return ec(this,this),this.check()}invert(){return tc(this,this),this.check()}multiplyLeft(e){return _o(this,e,this),this.check()}multiplyRight(e){return _o(this,this,e),this.check()}rotateX(e){return sc(this,this,e),this.check()}rotateY(e){return ac(this,this,e),this.check()}rotateZ(e){return cc(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return oc(this,this,e,r),this.check()}scale(e){return ic(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return nc(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Sc(r||[-0,-0,-0,-0],e,this),Vt(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,i;switch(n){case 2:i=wn(r||[-0,-0],e,this);break;case 3:i=Tn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Vt(i,e.length),i}transformAsVector(e,r){let n;switch(e.length){case 2:n=Sn(r||[-0,-0],e,this);break;case 3:n=En(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Vt(n,e.length),n}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},Cn,An;function am(){return Cn||(Cn=new z([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Cn)),Cn}function cm(){return An||(An=new z,Object.freeze(An)),An}function Ec(t){if(t>Math.PI*2)throw Error("expected radians")}function lm(t,e,r,n,i,o){let s=2*o/(r-e),a=2*o/(i-n),c=(r+e)/(r-e),l=(i+n)/(i-n),h=-1,u=-1,f=-2*o;return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=h,t[11]=u,t[12]=0,t[13]=0,t[14]=f,t[15]=0,t}function Tc(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function To(t,e,r){r=r*.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function bo(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=r[0],c=r[1],l=r[2],h=r[3];return t[0]=n*h+s*a+i*l-o*c,t[1]=i*h+s*c+o*a-n*l,t[2]=o*h+s*l+n*c-i*a,t[3]=s*h-n*a-i*c-o*l,t}function bc(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*a,t[1]=i*c+o*a,t[2]=o*c-i*a,t[3]=s*c-n*a,t}function vc(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-o*a,t[1]=i*c+s*a,t[2]=o*c+n*a,t[3]=s*c-i*a,t}function Pc(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=i*c-n*a,t[2]=o*c+s*a,t[3]=s*c-o*a,t}function Rc(t,e){let r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t}function Cc(t,e,r,n){let i=e[0],o=e[1],s=e[2],a=e[3],c=r[0],l=r[1],h=r[2],u=r[3],f,d,m,p,g;return f=i*c+o*l+s*h+a*u,f<0&&(f=-f,c=-c,l=-l,h=-h,u=-u),1-f>1e-6?(d=Math.acos(f),g=Math.sin(d),m=Math.sin((1-n)*d)/g,p=Math.sin(n*d)/g):(m=1-n,p=n),t[0]=m*i+p*c,t[1]=m*o+p*l,t[2]=m*s+p*h,t[3]=m*a+p*u,t}function Ac(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r*r+n*n+i*i+o*o,a=s?1/s:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-i*a,t[3]=o*a,t}function Ic(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function Nc(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let i=0;e[4]>e[0]&&(i=1),e[8]>e[i*3+i]&&(i=2);let o=(i+1)%3,s=(i+2)%3;n=Math.sqrt(e[i*3+i]-e[o*3+o]-e[s*3+s]+1),t[i]=.5*n,n=.5/n,t[3]=(e[o*3+s]-e[s*3+o])*n,t[o]=(e[o*3+i]+e[i*3+o])*n,t[s]=(e[s*3+i]+e[i*3+s])*n}return t}var Oc=pc;var Lc=gc,Gc=_c,zc=wc,qc=Mc;var Fc=yc;var hm=xc;var Bc=(function(){let t=Da(),e=po(1,0,0),r=po(0,1,0);return function(n,i,o){let s=wr(i,o);return s<-.999999?(Ht(t,e,i),$a(t)<1e-6&&Ht(t,r,i),ka(t,t),To(n,t,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Ht(t,i,o),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+s,hm(n,n))}})();var De=class extends gt{constructor(e=0,r=0,n=0,i=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,n,i)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,n,i){return this[0]=e,this[1]=r,this[2]=n,this[3]=i,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return Nc(this,e),this.check()}fromEuler(e){switch(this.identity(),e.order){case"xyz":return this.rotateX(e.x).rotateY(e.y).rotateZ(e.z);case"yxz":return this.rotateY(e.y).rotateX(e.x).rotateZ(e.z);case"zxy":return this.rotateZ(e.z).rotateX(e.x).rotateY(e.y);case"zyx":return this.rotateZ(e.z).rotateY(e.y).rotateX(e.x);case"yzx":return this.rotateY(e.y).rotateZ(e.z).rotateX(e.x);case"xzy":return this.rotateX(e.x).rotateZ(e.z).rotateY(e.y);default:throw new Error("Unknown Euler angle order")}}fromAxisRotation(e,r){return To(this,e,r),this.check()}identity(){return Tc(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=H(e)}get y(){return this[1]}set y(e){this[1]=H(e)}get z(){return this[2]}set z(e){this[2]=H(e)}get w(){return this[3]}set w(e){this[3]=H(e)}len(){return qc(this)}lengthSquared(){return Fc(this)}dot(e){return Gc(this,e)}rotationTo(e,r){return Bc(this,e,r),this.check()}add(e){return Oc(this,this,e),this.check()}calculateW(){return Rc(this,this),this.check()}conjugate(){return Ic(this,this),this.check()}invert(){return Ac(this,this),this.check()}lerp(e,r,n){return n===void 0?this.lerp(this,e,r):(zc(this,e,r,n),this.check())}multiplyRight(e){return bo(this,this,e),this.check()}multiplyLeft(e){return bo(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return bc(this,this,e),this.check()}rotateY(e){return vc(this,this,e),this.check()}rotateZ(e){return Pc(this,this,e),this.check()}scale(e){return Lc(this,this,e),this.check()}slerp(e,r,n){let i,o,s;return arguments.length===2?(i=this,o=e,s=r):(i=e,o=r,s=n),Cc(this,i,o,s),this.check()}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};function In(t,e,r=t){let n=t.x,i=t.y,o=t.z,{semiMajorAxis:s,semiMinorAxis:a,eccentricitySquared:c}=e,l=Math.sin(i),h=Math.cos(i),u=a/s,f=c<.9?s/Math.sqrt(1-c*l*l):s/Math.hypot(h,u*l),d=(f+o)*h*Math.cos(n),m=(f+o)*h*Math.sin(n),p=(f*(c<.9?1-c:u*u)+o)*l;return yt(r,d,m,p)}function Nn(t,e,r=t){let n=t.x,i=t.y,o=t.z,{semiMajorAxis:s,semiMinorAxis:a,eccentricitySquared:c}=e,l=Math.hypot(n,i),h=Math.hypot(n,i,o);if(!(h>0)||!Number.isFinite(h))return!1;if(c===0)return yt(r,l===0?0:Math.atan2(i,n),Math.atan2(o,l),h-s);if(l===0)return yt(r,0,Math.sign(o)*Math.PI/2,Math.abs(o)-a);let u=l/s,f=o/a;if(u*u+f*f<1-16*Number.EPSILON)return um(n,i,o,l,s,a,r);if(c>=.9)return Dc(n,i,o,l,s,a,r);let d=o/h,m=l/h,p=1/Math.sqrt(1-c*(2-c)*m*m),g=m*(1-c)*p,y=d*p;for(let x=0;x<30;x++){let w=s/Math.sqrt(1-c*y*y),_=l*g+o*y-w*(1-c*y*y),S=c*w/(w+_);p=1/Math.sqrt(1-S*(2-S)*m*m);let E=m*(1-S)*p,v=d*p;if(Math.abs(v*g-E*y)<=1e-12){if(!Number.isFinite(_)||!Number.isFinite(v)||!Number.isFinite(E))break;return yt(r,Math.atan2(i,n),Math.atan2(v,Math.abs(E)),_)}g=E,y=v}return Dc(n,i,o,l,s,a,r)}function um(t,e,r,n,i,o,s){let a=o/i,c=a*a,l=n/i,h=r/i,u=1-c;if(!(c>0)||a>1)return!1;if(r===0)return l<u?!1:yt(s,Math.atan2(e,t),0,n-i);let f=i*i,d=o*o,m=Number.isFinite(f)&&f>0?(d-c*f+Mt(o,o,d)-c*Mt(i,i,f)-Mt(c,f,c*f))/f:0,p=n*n,g=t*t,y=e*e,x=g+y,w=Number.isFinite(p)&&p>0?(x-p+vo(g,y,x)+Mt(t,t,g)+Mt(e,e,y)-Mt(n,n,p))/(2*n):0,_=i*c,S=n-i+_,E=w+vo(n-i,_,S)+Mt(i,c,_)+i*m,v=Math.abs(h)*a;if(!(v>0))return!1;let T=0,I=c,P=Math.max(v,l-u);P>T&&P<I||(P=I/2);for(let R=0;R<128;R++){let N=u+P,q=l/N,O=v/P,k=i*P,U=S-k,qe=(U+(vo(S,-k,U)+E-Mt(i,P,k)))/(i*N)*(q+1),re=qe+O*O;if(Math.abs(re)<=4*Number.EPSILON*(Math.abs(qe)+O*O)||I-T<=4*Number.EPSILON*P){let He=Math.atan2(h/P,l/N),Pe=Math.sin(He),dn=Math.cos(He);return yt(s,Math.atan2(e,t),He,n*dn+r*Pe-i*Math.hypot(dn,a*Pe))}re>0?T=P:I=P;let ct=-2*(q*q/N+O*O/P),Je=P-re/ct,kt=Number.isFinite(Je)&&Je>T&&Je<I?Je:T+(I-T)/2;if(kt===P){let He=Math.atan2(h/P,l/N);return yt(s,Math.atan2(e,t),He,n*Math.cos(He)+r*Math.sin(He)-i*Math.hypot(Math.cos(He),a*Math.sin(He)))}P=kt}return!1}function vo(t,e,r){let n=r-t;return t-(r-n)+(e-n)}function Mt(t,e,r){let n=134217729*t,i=134217729*e;if(!Number.isFinite(n)||!Number.isFinite(i))return 0;let o=n-(n-t),s=i-(i-e),a=t-o,c=e-s;return o*s-r+o*c+a*s+a*c}function Dc(t,e,r,n,i,o,s){let a=o/i,c=a*a,l=n/i,h=r/i,u=Math.hypot(l,r/o);if(!Number.isFinite(u)||u<1-8*Number.EPSILON||!(c>0))return!1;let f=0,d=Math.hypot(l,h*a);if(!Number.isFinite(d))return!1;let m=u<=1+8*Number.EPSILON?0:d/2;for(let p=0;p<96;p++){let g=1+m,y=c+m,x=l/g,w=h*a/y,_=Math.hypot(x,w),S=_-1;if(Math.abs(S)<=4*Number.EPSILON){let T=Math.atan2(h/y,l/g),I=Math.sin(T),P=Math.cos(T),R=n*P+r*I-i*Math.hypot(P,a*I);return yt(s,Math.atan2(e,t),T,R)}S>0?f=m:d=m;let E=-(x*x/g+w*w/y)/_,v=m-S/E;m=Number.isFinite(v)&&v>f&&v<d?v:(f+d)/2}return!1}function yt(t,e,r,n){return!Number.isFinite(e)||!Number.isFinite(r)||!Number.isFinite(n)?!1:(t.x=e,t.y=r,t.z=n,!0)}var lt=6356752314245179e-9,fm={radii:[6378137,6378137,lt],radiiSquared:[6378137*6378137,6378137*6378137,lt*lt],oneOverRadii:[1/6378137,1/6378137,1/lt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(lt*lt)],maximumRadius:Math.max(6378137,6378137,lt),centerToleranceSquared:.1};function Po(t){return t}var Wy=new M;function dm(t,e=[],r=Po){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Ro(t,e=[]){return dm(t,e,X._cartographicRadians?Po:lo)}function Co(t,e,r,n){let i=X._cartographicRadians?Po:ho,o=i(t),s=i(e);return"longitude"in n?(n.longitude=o,n.latitude=s,n.height=r):"x"in n?(n.x=o,n.y=s,n.z=r):(n[0]=o,n[1]=s,n[2]=r),n}function kc(){return{eastX:0,eastY:1,northZ:1,upX:1,upY:0,upZ:0}}function Uc(t,e,r){let n=t.x,i=t.y,o=t.z,s=e.x,a=e.y,c=e.z;return o!==0?!1:mm(r,n,i,s*i-a*n,s,a,c)}function Vc(t,e,r,n,i,o){let s=Ao(r),a=Ao(n),c=Ao(i),l=Math.abs(s),h=Math.abs(a),u=Math.abs(c);if(!l||!h||!u||l===h||l===u||h===u||(l%3+1===h?1:-1)*Math.sign(s*a*c)!==1||!Array.isArray(o)&&o.length<16)return!1;let d=t.eastX,m=t.eastY,p=t.northZ,g=t.upX,y=t.upY,x=t.upZ,w=-x*m,_=x*d,S=e.x,E=e.y,v=e.z,T=(l===1?d:l===2?w:g)*Math.sign(s),I=(l===1?m:l===2?_:y)*Math.sign(s),P=(l===1?0:l===2?p:x)*Math.sign(s),R=(h===1?d:h===2?w:g)*Math.sign(a),N=(h===1?m:h===2?_:y)*Math.sign(a),q=(h===1?0:h===2?p:x)*Math.sign(a),O=(u===1?d:u===2?w:g)*Math.sign(c),k=(u===1?m:u===2?_:y)*Math.sign(c),U=(u===1?0:u===2?p:x)*Math.sign(c);return!Number.isFinite(T)||!Number.isFinite(I)||!Number.isFinite(P)||!Number.isFinite(R)||!Number.isFinite(N)||!Number.isFinite(q)||!Number.isFinite(O)||!Number.isFinite(k)||!Number.isFinite(U)||!Number.isFinite(S)||!Number.isFinite(E)||!Number.isFinite(v)||o instanceof Float32Array&&(!Number.isFinite(Math.fround(T))||!Number.isFinite(Math.fround(I))||!Number.isFinite(Math.fround(P))||!Number.isFinite(Math.fround(R))||!Number.isFinite(Math.fround(N))||!Number.isFinite(Math.fround(q))||!Number.isFinite(Math.fround(O))||!Number.isFinite(Math.fround(k))||!Number.isFinite(Math.fround(U))||!Number.isFinite(Math.fround(S))||!Number.isFinite(Math.fround(E))||!Number.isFinite(Math.fround(v)))?!1:(o[0]=T,o[1]=I,o[2]=P,o[3]=0,o[4]=R,o[5]=N,o[6]=q,o[7]=0,o[8]=O,o[9]=k,o[10]=U,o[11]=0,o[12]=S,o[13]=E,o[14]=v,o[15]=1,!0)}function Ao(t){switch(t){case"east":return 1;case"west":return-1;case"north":return 2;case"south":return-2;case"up":return 3;case"down":return-3;default:return 0}}function mm(t,e,r,n,i,o,s){return!Number.isFinite(e)||!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(s)?!1:(t.eastX=e,t.eastY=r,t.northZ=n,t.upX=i,t.upY=o,t.upZ=s,!0)}var jc=1e-14,pm=new M,Wc=kc(),Hc={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Io={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},$t={east:new M,north:new M,up:new M,west:new M,south:new M,down:new M},gm=new M,Mm=new M,ym=new M;function No(t,e,r,n,i,o){let s=Hc[e]&&Hc[e][r];ae(s&&(!n||n===s));let a,c,l,h=pm.copy(i),u=Re(h.x,0,jc)&&Re(h.y,0,jc),f=t.radii;if(f.x===f.y&&f.x>0&&f.z>0&&f.z<=f.x&&(!u||h.z!==0)){let{east:I,up:P}=$t;if(u?(I.set(0,1,0),P.set(0,0,Math.sign(h.z))):(I.set(-h.y,h.x,0).normalize(),t.geodeticSurfaceNormal(h,P)),!Uc(I,P,Wc)||!Vc(Wc,h,e,r,n,o))throw new Error("Unsupported local frame");return o}if(u){let I=Math.sign(h.z);a=gm.fromArray(Io[e]),e!=="east"&&e!=="west"&&a.scale(I),c=Mm.fromArray(Io[r]),r!=="east"&&r!=="west"&&c.scale(I),l=ym.fromArray(Io[n]),n!=="east"&&n!=="west"&&l.scale(I)}else{let{up:I,east:P,north:R}=$t;P.set(-h.y,h.x,0).normalize(),t.geodeticSurfaceNormal(h,I),R.copy(I).cross(P);let{down:N,west:q,south:O}=$t;N.copy(I).scale(-1),q.copy(P).scale(-1),O.copy(R).scale(-1),a=$t[e],c=$t[r],l=$t[n]}let d=a.x,m=a.y,p=a.z,g=c.x,y=c.y,x=c.z,w=l.x,_=l.y,S=l.z,E=h.x,v=h.y,T=h.z;return o[0]=d,o[1]=m,o[2]=p,o[3]=0,o[4]=g,o[5]=y,o[6]=x,o[7]=0,o[8]=w,o[9]=_,o[10]=S,o[11]=0,o[12]=E,o[13]=v,o[14]=T,o[15]=1,o}var $c=new M,xm=new M,_m=new M;function Yc(t,e,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:i,centerToleranceSquared:o}=e,s=t,a="x"in t?s.x:t[0],c="x"in t?s.y:t[1],l="x"in t?s.z:t[2];if(!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(l))return;$c.set(a,c,l);let h=n.x,u=n.y,f=n.z,d=a*a*h*h,m=c*c*u*u,p=l*l*f*f,g=d+m+p,y=Math.sqrt(1/g);if(!Number.isFinite(y)||!Number.isFinite(g))return;let x=xm;if(x.set(a,c,l).scale(y),g<o)return On(r,x.x,x.y,x.z);let w=i.x,_=i.y,S=i.z,E=_m;E.set(x.x*w*2,x.y*_*2,x.z*S*2);let v=(1-y)*$c.len()/(.5*E.len()),T=0,I,P,R,N;for(let q=0;q<64;q++){v-=T,I=1/(1+v*w),P=1/(1+v*_),R=1/(1+v*S);let O=I*I,k=P*P,U=R*R,ve=O*I,qe=k*P,re=U*R;if(N=d*O+m*k+p*U-1,!Number.isFinite(N))return;if(Math.abs(N)<=j.EPSILON12)return On(r,a*I,c*P,l*R);let Je=-2*(d*ve*w+m*qe*_+p*re*S);if(!Number.isFinite(Je)||Je===0||(T=N/Je,!Number.isFinite(T)))return}}function On(t,e,r,n){if(Fe(t))t[0]=e,t[1]=r,t[2]=n;else{let i=t;i.x=e,i.y=r,i.z=n}return t}var xe={x:0,y:0,z:0},Ln=new M,Xc=new M,Em=new M,$e=new M,Tm=new M,Sr=new M,L=class t{static fromSpheroid(e){let{semiMajorAxis:r,semiMinorAxis:n}=e;return Kc(r,n),new t(r,r,n)}constructor(e=0,r=0,n=0){this.centerToleranceSquared=j.EPSILON1,ae(e>=0),ae(r>=0),ae(n>=0),this.radii=new M(e,r,n),this.radiiSquared=new M(e*e,r*r,n*n),this.radiiToTheFourth=new M(e*e*e*e,r*r*r*r,n*n*n*n),this.oneOverRadii=new M(e===0?0:1/e,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new M(e===0?0:1/(e*e),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(e,r,n),this.maximumRadius=Math.max(e,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),e===r&&n>0&&n<=e&&Number.isFinite(this.radiiSquared.x)&&this.radiiSquared.z>0&&(this.spheroidGeometry=Object.freeze({semiMajorAxis:e,semiMinorAxis:n,eccentricitySquared:1-this.radiiSquared.z/this.radiiSquared.x})),Object.freeze(this)}toSpheroid(){let{x:e,y:r,z:n}=this.radii;if(e!==r)throw new Error("Spheroid requires equal X/Y radii");return Kc(e,n),Object.freeze({semiMajorAxis:e,semiMinorAxis:n})}equals(e){return this===e||!!(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){if(this.spheroidGeometry){let a=Ro(e,Sr);return xe.x=a[0],xe.y=a[1],xe.z=a[2],In(xe,this.spheroidGeometry)?On(r,xe.x,xe.y,xe.z):void 0}let n=Xc,i=Em,[,,o]=e;this.geodeticSurfaceNormalCartographic(e,n),i.copy(this.radiiSquared).scale(n);let s=Math.sqrt(n.dot(i));return i.scale(1/s),n.scale(o),i.add(n),i.to(r)}cartesianToCartographic(e,r=[0,0,0]){let n=e,i="x"in e?n.x:e[0],o="x"in e?n.y:e[1],s="x"in e?n.z:e[2];if(!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(s))return;if(this.spheroidGeometry&&Number.isFinite(i*i+o*o+s*s)&&Number.isFinite(this.oneOverRadiiSquared.x)&&Number.isFinite(this.oneOverRadiiSquared.z)){if(xe.x=i,xe.y=o,xe.z=s,!Nn(xe,this.spheroidGeometry))return;let d=i===0&&o===0?Math.atan2(o,i):xe.x;return Co(d,xe.y,xe.z,r)}Sr.set(i,o,s);let a=this.scaleToGeodeticSurface(Sr,$e);if(!a)return;let c=this.geodeticSurfaceNormal(a,Xc),l=Tm;l.copy(Sr).subtract(a);let h=Math.atan2(c.y,c.x),u=Math.atan2(c.z,Math.hypot(c.x,c.y)),f=Math.sign(wr(l,Sr))*mo(l);return Co(h,u,f,r)}eastNorthUpToFixedFrame(e,r=new z){return No(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,n,i,o=new z){return No(this,e,r,n,i,o)}geocentricSurfaceNormal(e,r=[0,0,0]){return Ln.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let n=Ro(e),i=n[0],o=n[1],s=Math.cos(o);return Ln.set(s*Math.cos(i),s*Math.sin(i),Math.sin(o)).normalize(),Ln.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return Ln.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return Yc(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){$e.from(e);let n=$e.x,i=$e.y,o=$e.z,s=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*s.x+i*i*s.y+o*o*s.z);return $e.multiplyByScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return $e.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return $e.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,n=[0,0,0]){ae(Re(this.radii.x,this.radii.y,j.EPSILON15)),ae(this.radii.z>0),$e.from(e);let i=$e.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-r))return $e.set(0,0,i).to(n)}};L.WGS84=new L(6378137,6378137,lt);function Kc(t,e){if(!Number.isFinite(t)||!Number.isFinite(e)||t<=0||e<=0||e>t)throw new Error("Spheroid requires finite positive axes with semiMinorAxis <= semiMajorAxis")}var Oo;(function(t){t.OUTSIDE="outside",t.INTERSECTING="intersecting",t.INSIDE="inside"})(Oo||(Oo={}));var lx=new M,hx=new M;var Er=new M,Zc=new M,me=class t{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new M,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=Er.from(r),this.center=new M().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||!!e&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new t(this.center,this.radius)}union(e){let r=this.center,n=this.radius,i=e.center,o=e.radius,s=Er.copy(i).subtract(r),a=s.magnitude();if(n>=a+o)return this.clone();if(o>=a+n)return e.clone();let c=(n+a+o)*.5;return Zc.copy(s).scale((-n+c)/a).add(r),this.center.copy(Zc),this.radius=c,this}expand(e){let n=Er.from(e).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(e){this.center.transform(e);let r=lc(Er,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let n=Er.from(e).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(e){let r=this.center,n=this.radius,o=e.normal.dot(r)+e.distance;return o<-n?"outside":o<n?"intersecting":"inside"}};var bm=new M,vm=new M,Gn=new M,zn=new M,qn=new M,Pm=new M,Rm=new M,ht={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},et=class t{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new M().from(e),this.halfAxes=new $(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new M(e).len(),new M(r).len(),new M(n).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),i=new M(e).normalize(),o=new M(r).normalize(),s=new M(n).normalize();return new De().fromMatrix3(new $([...i,...o,...s]))}fromCenterHalfSizeQuaternion(e,r,n){let i=new De(n),o=new $().fromQuaternion(i);return o[0]=o[0]*r[0],o[1]=o[1]*r[0],o[2]=o[2]*r[0],o[3]=o[3]*r[1],o[4]=o[4]*r[1],o[5]=o[5]*r[1],o[6]=o[6]*r[2],o[7]=o[7]*r[2],o[8]=o[8]*r[2],this.center=new M().from(e),this.halfAxes=o,this}clone(){return new t(this.center,this.halfAxes)}equals(e){return this===e||!!e&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new me){let r=this.halfAxes,n=r.getColumn(0,Gn),i=r.getColumn(1,zn),o=r.getColumn(2,qn),s=bm.copy(n).add(i).add(o);return e.center.copy(this.center),e.radius=s.magnitude(),e}intersectPlane(e){let r=this.center,n=e.normal,i=this.halfAxes,o=n.x,s=n.y,a=n.z,c=Math.abs(o*i[ht.COLUMN0ROW0]+s*i[ht.COLUMN0ROW1]+a*i[ht.COLUMN0ROW2])+Math.abs(o*i[ht.COLUMN1ROW0]+s*i[ht.COLUMN1ROW1]+a*i[ht.COLUMN1ROW2])+Math.abs(o*i[ht.COLUMN2ROW0]+s*i[ht.COLUMN2ROW1]+a*i[ht.COLUMN2ROW2]),l=n.dot(r)+e.distance;return l<=-c?"outside":l>=c?"inside":"intersecting"}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=vm.from(e).subtract(this.center),n=this.halfAxes,i=n.getColumn(0,Gn),o=n.getColumn(1,zn),s=n.getColumn(2,qn),a=i.magnitude(),c=o.magnitude(),l=s.magnitude();i.normalize(),o.normalize(),s.normalize();let h=0,u;return u=Math.abs(r.dot(i))-a,u>0&&(h+=u*u),u=Math.abs(r.dot(o))-c,u>0&&(h+=u*u),u=Math.abs(r.dot(s))-l,u>0&&(h+=u*u),h}computePlaneDistances(e,r,n=[-0,-0]){let i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=this.center,a=this.halfAxes,c=a.getColumn(0,Gn),l=a.getColumn(1,zn),h=a.getColumn(2,qn),u=Pm.copy(c).add(l).add(h).add(s),f=Rm.copy(u).subtract(e),d=r.dot(f);return i=Math.min(d,i),o=Math.max(d,o),u.copy(s).add(c).add(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),u.copy(s).add(c).subtract(l).add(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),u.copy(s).add(c).subtract(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).add(l).add(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).add(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).subtract(l).add(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).subtract(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),n[0]=i,n[1]=o,n}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,Gn);r.transformAsPoint(e);let n=this.halfAxes.getColumn(1,zn);n.transformAsPoint(e);let i=this.halfAxes.getColumn(2,qn);return i.transformAsPoint(e),this.halfAxes=new $([...r,...n,...i]),this}getTransform(){throw new Error("not implemented")}};var Qc=new M,Jc=new M,ie=class t{constructor(e=[0,0,1],r=0){this.normal=new M,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return ae(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=Qc.from(e),this.normal.from(r).normalize();let n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,r,n,i){return this.normal.set(e,r,n),ae(Re(this.normal.len(),1)),this.distance=i,this}clone(){return new t(this.normal,this.distance)}equals(e){return Re(this.distance,e.distance)&&Re(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=Jc.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,r)}projectPointOntoPlane(e,r=[0,0,0]){let n=Qc.from(e),i=this.getPointDistance(n),o=Jc.copy(this.normal).scale(i);return n.subtract(o).to(r)}intersectWithRay(e,r=new M){let n=e.origin,i=e.direction,o=this.normal,s=o.dot(i);if(Math.abs(s)<j.EPSILON15)return;let a=(-this.distance-o.dot(n))/s;if(!(a<0))return r.copy(i).multiplyByScalar(a).add(n)}};var el=[new M([1,0,0]),new M([0,1,0]),new M([0,0,1])],tl=new M,Cm=new M,ce=class t{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*el.length;let r=e.center,n=e.radius,i=0;for(let o of el){let s=this.planes[i],a=this.planes[i+1];s||(s=this.planes[i]=new ie),a||(a=this.planes[i+1]=new ie);let c=tl.copy(o).scale(-n).add(r);s.fromPointNormal(c,o);let l=tl.copy(o).scale(n).add(r),h=Cm.copy(o).negate();a.fromPointNormal(l,h),i+=2}return this}computeVisibility(e){let r="inside";for(let n of this.planes)switch(e.intersectPlane(n)){case"outside":return"outside";case"intersecting":r="intersecting";break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(ae(Number.isFinite(r),"parentPlaneMask is required."),r===t.MASK_OUTSIDE||r===t.MASK_INSIDE)return r;let n=t.MASK_INSIDE,i=this.planes;for(let o=0;o<this.planes.length;++o){let s=o<31?1<<o:0;if(o<31&&(r&s)===0)continue;let a=i[o],c=e.intersectPlane(a);if(c==="outside")return t.MASK_OUTSIDE;c==="intersecting"&&(n|=s)}return n}};ce.MASK_OUTSIDE=4294967295;ce.MASK_INSIDE=0;ce.MASK_INDETERMINATE=2147483647;var kx=new M,Ux=new M,Vx=new M,jx=new M,Wx=new M;var Zx=new M,Qx=new M,Jx=new M,e_=new M,t_=new M,r_=new M,n_=new M,i_=new M,o_=new M,s_=new M,a_=new M,c_=new M;var u_=new $,f_=new $,d_=new $,m_=new $,p_=new $;var w_=new M,S_=new M,E_=new M,T_=new M,b_=new M,v_=new $,P_={diagonal:new $,unitary:new $};var Om=new M,Lo=new M,Lm=new z,Gm=new M,Tr=class{constructor(e,r=L.WGS84){let n=r.scaleToGeodeticSurface(e,Om),i=r.eastNorthUpToFixedFrame(n,Lm);this._origin=new M(n),this._xAxis=new M(Lo.from(i.getColumn(0))),this._yAxis=new M(Lo.from(i.getColumn(1)));let o=new M(Lo.from(i.getColumn(2)));this._plane=new ie().fromPointNormal(this._origin,o)}projectPointToNearestOnPlane(e,r){r||(r=new Be);let i=this._plane.projectPointOntoPlane(e,Gm).subtract(this._origin),o=this._xAxis.dot(i),s=this._yAxis.dot(i);return r.x=o,r.y=s,r}get plane(){return this._plane}get origin(){return this._origin}get xAxis(){return this._xAxis}get yAxis(){return this._yAxis}get zAxis(){return this._plane.normal}};var Yt=class{constructor(e,r,n,i){this.west=e,this.south=r,this.east=n,this.north=i}static center(e,r){r||(r=new M);let n=e.east,i=e.west;n<i&&(n+=j.TWO_PI);let o=uo((i+n)*.5,"negative-pi-to-pi"),s=(e.south+e.north)*.5;return r.x=o,r.y=s,r.z=0,r}get width(){let e=this.east,r=this.west;return e<r&&(e+=j.TWO_PI),e-r}};var zm=new M,qm=new M,Fm=new M,Bm=new M,Dm=new M,km=new M,Um=new M,Vm=new M,il=new M,jm=new M,ol=new M,Wm=new M,Hm=new Be,$m=new Be,Ym=new Be,Xm=new Be,Km=new Be,Zm=new ie,Qm=new M,Jm=new M,ep=new M,tp=new M,rp=new Be,np=new M,ip=new M,op=new M(1,0,0),sp=new M(0,0,1);function br(t,e=L.WGS84,r={}){if(!t||t.length!==6||t.some(x=>!Number.isFinite(x)))throw new Error("makeOBBFromRegion: region must contain exactly six finite numbers");let n=r.units==="degrees"?yn(1):1,[i,o,s,a,c,l]=t;if(c>l)throw new Error("makeOBBFromRegion: minimumHeight must not exceed maximumHeight");let h=o*n,u=a*n,f=sl(i*n),d=sl(s*n);s*n-i*n>=j.TWO_PI-1e-12&&(d=f+j.TWO_PI);let p=1e-12;if(h>u||h<-j.PI_OVER_TWO-p||u>j.PI_OVER_TWO+p)throw new Error("makeOBBFromRegion: latitude must be within [-\u03C0/2, \u03C0/2] and south \u2264 north");let g=Math.max(-j.PI_OVER_TWO,Math.min(j.PI_OVER_TWO,h)),y=Math.max(-j.PI_OVER_TWO,Math.min(j.PI_OVER_TWO,u));return ap([f,g,d,y,c,l],e,r.transform)}function sl(t){let e=((t+Math.PI)%j.TWO_PI+j.TWO_PI)%j.TWO_PI-Math.PI;return e===-Math.PI&&t>0?Math.PI:e}function ap(t,e,r){let n=new et,[i,o,s,a,c,l]=t,h=ye(a),u=ye(o),f,d,m,p,g,y,x,w=new Yt(i,o,s,a),_=Yt.center(w,qm),S=new M([ye(_.x),ye(_.y),0]),E=_.x,v=S.x;if(w.width<=j.PI){let kt=ye(i),He=e.cartographicToCartesian(S),Pe=new Tr(He,e),dn=u<0&&h>0?0:S.y,nd=Fm.copy([v,h,l]),no=Bm.copy([kt,h,l]),id=Dm.copy([kt,dn,l]),io=km.copy([kt,u,l]),od=Um.copy([v,u,l]),sd=e.cartographicToCartesian(nd,Vm),oo=e.cartographicToCartesian(no,il),ad=e.cartographicToCartesian(id,jm),so=e.cartographicToCartesian(io,ol),cd=e.cartographicToCartesian(od,Wm),ld=Pe.projectPointToNearestOnPlane(sd,Hm),Aa=Pe.projectPointToNearestOnPlane(oo,$m),hd=Pe.projectPointToNearestOnPlane(ad,Ym),Ia=Pe.projectPointToNearestOnPlane(so,Xm),ud=Pe.projectPointToNearestOnPlane(cd,Km);return p=Math.min(Aa.x,hd.x,Ia.x),f=-p,d=Math.max(Aa.y,ld.y),g=Math.min(Ia.y,ud.y),no.z=io.z=c,oo=e.cartographicToCartesian(no,il),so=e.cartographicToCartesian(io,ol),x=Pe.plane,y=Math.min(x.getPointDistance(oo),x.getPointDistance(so)),m=l,al(ll(Pe.origin,Pe.xAxis,Pe.yAxis,Pe.zAxis,p,f,g,d,y,m,n),r)}let T=ye(s),I=o>0,P=a<0,R=I?u:P?h:0,N=e.cartographicToCartesian([v,R,l],Qm);N.z=0;let O=Math.abs(N.x)<j.EPSILON10&&Math.abs(N.y)<j.EPSILON10?op:Jm.copy(N).normalize(),k=sp,U=ep.copy(O).cross(k);x=Zm.fromPointNormal(N,O);let ve=e.cartographicToCartesian([ye(E+j.PI_OVER_TWO),R,l],tp);f=x.projectPointOntoPlane(ve,rp).dot(U),p=-f;let re=P?c:l,ct=I?c:l;d=cl(e,h,re,!0),g=cl(e,u,ct,!1);let Je=e.cartographicToCartesian([T,R,l],ip);return y=x.getPointDistance(Je),m=0,al(ll(N,U,k,O,p,f,g,d,y,m,n),r)}function al(t,e){if(!e)return t;let r=[0,1,2].map(a=>t.halfAxes.getColumn(a,new M)),n=e.transformAsPoint(t.center),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a=0;a<8;a++){let c=new M(n);for(let l=0;l<3;l++){let h=e.transformAsVector(r[l]);c.add(new M(h).scale((a&1<<l)===0?-1:1))}for(let l=0;l<3;l++)i[l]=Math.min(i[l],c[l]),o[l]=Math.max(o[l],c[l])}t.center.copy(i).add(o).scale(.5);let s=new M(o).subtract(i).scale(.5);return t.halfAxes=new $().set(s.x,0,0,0,s.y,0,0,0,s.z),t}function cl(t,e,r,n){let i=n?-1/0:1/0;for(let o of[0,90,180,270]){let s=t.cartographicToCartesian([o,e,r],np).z;i=n?Math.max(i,s):Math.min(i,s)}return i}function ll(t,e,r,n,i,o,s,a,c,l,h){let u=h.center,f=h.halfAxes;f.setColumn(0,e),f.setColumn(1,r),f.setColumn(2,n);let d=zm.set((i+o)/2,(s+a)/2,(c+l)/2).transformByMatrix3(f),m=(o-i)/2,p=(a-s)/2,g=(l-c)/2;return f[0]*=m,f[1]*=m,f[2]*=m,f[3]*=p,f[4]*=p,f[5]*=p,f[6]*=g,f[7]*=g,f[8]*=g,u.copy(t).add(d),h}function vr(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Ct=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=vr(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(vr()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var ke=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,i=this.stats[r];return i||(e instanceof Ct?i=e:i=new Ct(r,n),this.stats[r]=i),i}};function Ye(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function Bn(t,e,r){let n=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(n).buffer}var lp="Queued Requests",hp="Active Requests",up="Cancelled Requests",fp="Queued Requests Ever",dp="Active Requests Ever",mp={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},ut=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...mp,...e},this.stats=new ke({id:this.props.id}),this.stats.get(lp),this.stats.get(hp),this.stats.get(up),this.stats.get(fp),this.stats.get(dp)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},i=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(e,i),this._issueNewRequests(),i}_issueRequest(e){let{handle:r,resolve:n}=e,i=!1,o=()=>{i||(i=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var pp=Number.POSITIVE_INFINITY,gp=Number.POSITIVE_INFINITY,Pr=class{maxEntries;maxBytes;getByteLength;onRemove;entries=new Map;retainedByteLength=0;constructor(e={}){this.maxEntries=hl(e.maxEntries,pp,"maxEntries"),this.maxBytes=hl(e.maxBytes,gp,"maxBytes"),this.getByteLength=e.getByteLength||(()=>0),this.onRemove=e.onRemove}get size(){return this.entries.size}get pendingSize(){let e=0;for(let r of this.entries.values())e+=r.pending?1:0;return e}get byteLength(){return this.retainedByteLength}get(e,r){let n=this.entries.get(e);if(n)return this.touch(e,n),this.waitForEntry(e,n,r)}has(e){return this.entries.has(e)}set(e,r){this.removeEntry(e,"replace");let n=ul(this.getByteLength(r)),i={promise:Promise.resolve(r),pending:!1,waiterCount:0,byteLength:n};return this.entries.set(e,i),this.retainedByteLength+=n,this.trim(),r}getOrLoad(e,r,n){let i=this.get(e,n);if(i)return i;if(n?.aborted)return Promise.reject(Go());let o=new AbortController,s,a,l={promise:new Promise((h,u)=>{s=h,a=u}),controller:o,pending:!0,waiterCount:0,byteLength:0};this.entries.set(e,l),l.promise.then(h=>this.handleLoadedValue(e,l,h),()=>this.handleLoadError(e,l));try{Promise.resolve(r(o.signal)).then(s,a)}catch(h){a(h)}return this.waitForEntry(e,l,n)}delete(e){return this.removeEntry(e,"delete")}clear(){for(let e of Array.from(this.entries.keys()))this.removeEntry(e,"clear")}handleLoadedValue(e,r,n){if(this.entries.get(e)===r){r.pending=!1,r.controller=void 0;try{r.byteLength=ul(this.getByteLength(n))}catch{this.removeEntry(e,"error");return}this.retainedByteLength+=r.byteLength,this.trim()}}handleLoadError(e,r){this.entries.get(e)===r&&this.removeEntry(e,r.controller?.signal.aborted?"abort":"error")}waitForEntry(e,r,n){return n?.aborted?Promise.reject(Go()):r.pending?(r.waiterCount++,new Promise((i,o)=>{let s=!0,a=()=>{s&&(s=!1,n?.removeEventListener("abort",c),r.waiterCount--)},c=()=>{s&&(a(),o(Go()),r.pending&&r.waiterCount===0&&this.entries.get(e)===r&&this.removeEntry(e,"abort"))};n?.addEventListener("abort",c,{once:!0}),r.promise.then(l=>{s&&(a(),i(l))},l=>{s&&(a(),o(l))})})):r.promise}touch(e,r){this.entries.delete(e),this.entries.set(e,r)}trim(){let e=this.entries.size-this.pendingSize;if(!(e<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)){for(let[r,n]of this.entries)if(n.pending||(this.removeEntry(r,"evict"),e--),e<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)break}}removeEntry(e,r){let n=this.entries.get(e);return n?(this.entries.delete(e),this.retainedByteLength-=n.byteLength,n.pending&&n.controller?.abort(),this.onRemove?.(e,r),!0):!1}};function Go(){let t=new Error("Request aborted");return t.name="AbortError",t}function hl(t,e,r){let n=t??e;if(n<0||Number.isNaN(n))throw new Error(`${r} must be a non-negative number`);return n}function ul(t){if(!Number.isFinite(t)||t<0)throw new Error("Request cache entry byte length must be a non-negative finite number");return t}var Y={logicalRanges:"Logical Range Requests",rangeBatches:"Range Request Batches",transportRanges:"Transport Ranges Created",completedTransportRanges:"Range Transport Requests Completed",coalescedRanges:"Coalesced Logical Ranges",requestedBytes:"Logical Range Request Bytes",transportBytes:"Range Transport Bytes Requested",responseBytes:"Range Response Bytes",networkTimeMs:"Range Network Time",overfetchBytes:"Range Overfetch Bytes",failedTransportRanges:"Range Transport Requests Failed",abortedLogicalRanges:"Aborted Logical Range Requests",fullResponseFallbacks:"Full Response Fallbacks"},zo={batchDelayMs:50,maxGapBytes:65536,rangeExpansionBytes:65536,maxMergedBytes:8388608,maxConcurrency:6,maxQueueSize:4096,maxRangeBytes:64*1024*1024,stats:ml("range-request-scheduler-default"),onEvent:()=>{}},Dn=class{props;stats;onEvent;pendingRequests=[];transportQueue=[];activeTransports=0;queuedRequests=0;logicalRequests=new Set;transportControllers=new Set;finalized=!1;flushTimer=null;constructor(e={}){let r=e.rangeExpansionBytes??e.maxGapBytes??zo.rangeExpansionBytes;this.props={batchDelayMs:e.batchDelayMs??zo.batchDelayMs,maxGapBytes:e.maxGapBytes??r,rangeExpansionBytes:r,maxMergedBytes:e.maxMergedBytes??zo.maxMergedBytes,maxConcurrency:e.maxConcurrency??6,maxQueueSize:e.maxQueueSize??4096,maxRangeBytes:e.maxRangeBytes??64*1024*1024};for(let n of[this.props.maxConcurrency,this.props.maxQueueSize,this.props.maxRangeBytes])if(!Number.isSafeInteger(n)||n<=0)throw new Error("Range scheduler limits must be positive integers");this.stats=e.stats||ml("range-request-scheduler"),this.onEvent=e.onEvent,pl(this.stats)}scheduleRequest(e){if(this.finalized)return Promise.reject(new Error("Range scheduler is finalized"));if(!Number.isSafeInteger(e.offset)||e.offset<0||!Number.isSafeInteger(e.length)||e.length>this.props.maxRangeBytes||!Number.isSafeInteger(e.offset+e.length))return Promise.reject(new Error("Invalid or oversized byte range"));if(this.queuedRequests>=this.props.maxQueueSize)return Promise.reject(new Error("Range scheduler queue limit exceeded"));if(e.length<0)return Promise.reject(new Error("Byte range length cannot be negative"));if(e.signal?.aborted)return Promise.reject(e.signal.reason??dl());if(e.length===0)return Promise.resolve(new ArrayBuffer(0));this.queuedRequests++;let r,n=new Promise((i,o)=>{r={...e,resolve:i,reject:o,settled:!1},this.logicalRequests.add(r),e.signal&&(r.abortListener=()=>{this.abortRequest(r),r.onAbort?.()},e.signal.addEventListener("abort",r.abortListener,{once:!0})),this.pendingRequests.push(r)});return this.trackEvent({type:"queued",sourceId:e.sourceId,offset:e.offset,length:e.length,logicalRequestCount:1,logicalBytes:e.length}),this.scheduleFlush(),n.finally(()=>{r.abortListener&&e.signal?.removeEventListener("abort",r.abortListener),this.queuedRequests--,this.logicalRequests.delete(r)})}fetch(e){let r=e.fetch||globalThis.fetch;return this.scheduleRequest({sourceId:e.sourceId||e.url,offset:e.offset,length:e.length,signal:e.signal,isolationKey:e.isolationKey??{},fetchRange:(n,i,o)=>yp({url:e.url,offset:n,length:i,signal:o,fetch:r,fetchOptions:e.fetchOptions})})}flush(){this.flushTimer!==null&&(clearTimeout(this.flushTimer),this.flushTimer=null);let e=this.pendingRequests;this.pendingRequests=[];let r=e.filter(i=>i.settled||i.signal?.aborted?(this.abortRequest(i),!1):!0),n=this.mergeRequests(r);r.length>0&&this.trackBatch(r,n),this.transportQueue.push(...n),this.startQueuedTransports()}finalize(){this.finalized=!0,this.flushTimer!==null&&clearTimeout(this.flushTimer),this.flushTimer=null;for(let e of this.logicalRequests)this.abortRequest(e),e.abortListener&&e.signal?.removeEventListener("abort",e.abortListener);for(let e of this.transportControllers)e.abort();this.transportQueue=[],this.pendingRequests=[],this.logicalRequests.clear()}startQueuedTransports(){for(;this.activeTransports<this.props.maxConcurrency&&this.transportQueue.length;){let e=this.transportQueue.shift();this.activeTransports++,this.fetchMergedRequest(e).finally(()=>{this.activeTransports--,this.startQueuedTransports()})}}scheduleFlush(){this.flushTimer===null&&(this.flushTimer=setTimeout(()=>this.flush(),this.props.batchDelayMs))}mergeRequests(e){e.sort((n,i)=>n.sourceId!==i.sourceId?n.sourceId<i.sourceId?-1:1:n.offset-i.offset);let r=[];for(let n of e){let i=n.offset+n.length,o=r[r.length-1];o&&xp(o,n,this.props)?(o.endOffset=Math.max(o.endOffset,i),o.requests.push(n)):r.push({sourceId:n.sourceId,isolationKey:n.isolationKey??n.sourceId,offset:n.offset,endOffset:i,fetchRange:n.fetchRange,requests:[n]})}return r}async fetchMergedRequest(e){let{offset:r,endOffset:n,fetchRange:i,requests:o}=e,s=new AbortController;this.transportControllers.add(s);let a=Rr(),c=()=>{o.every(l=>l.settled||l.signal?.aborted)&&s.abort()};try{for(let g of o)g.onAbort=c;if(c(),o.every(g=>g.settled))return;let l=qo(o),h=n-r;this.trackEvent({type:"request",sourceId:e.sourceId,offset:r,length:h,logicalRequestCount:o.length,logicalBytes:l,transportBytes:h,overfetchBytes:Math.max(h-l,0)});let u=_p(await i(r,h,s.signal)),{arrayBuffer:f}=u,d=u.fullResponse&&r===0&&f.byteLength<h,m=f.byteLength<h&&Number.isSafeInteger(u.sourceByteLength)&&r+f.byteLength===u.sourceByteLength;if(f.byteLength!==h&&!d&&!m)throw new Error(`Byte-range transport returned ${f.byteLength} bytes; expected ${h}`);let p=u.networkTimeMs??Rr()-a;this.trackEvent({type:"response",sourceId:e.sourceId,offset:r,length:h,logicalRequestCount:o.length,logicalBytes:l,transportBytes:h,responseBytes:u.transportBytes??f.byteLength,networkTimeMs:p,overfetchBytes:Math.max(h-l,0),status:u.status,fullResponse:u.fullResponse});for(let g of o){if(g.settled)continue;let y=g.offset-r;g.settled=!0,g.resolve(f.slice(y,y+g.length))}}catch(l){s.signal.aborted||this.trackEvent({type:"error",sourceId:e.sourceId,offset:r,length:n-r,logicalRequestCount:o.length,logicalBytes:qo(o),networkTimeMs:Rr()-a,error:l});for(let h of o)h.settled||(h.signal?.aborted?this.abortRequest(h):(h.settled=!0,h.reject(l)))}finally{this.transportControllers.delete(s);for(let l of o)l.abortListener&&l.signal?.removeEventListener("abort",l.abortListener),l.onAbort=void 0}}abortRequest(e){if(!e.settled){e.settled=!0,this.pendingRequests=this.pendingRequests.filter(r=>r!==e);for(let r of this.transportQueue)r.requests=r.requests.filter(n=>!n.settled),r.requests.length&&(r.offset=Math.min(...r.requests.map(n=>n.offset)),r.endOffset=Math.max(...r.requests.map(n=>n.offset+n.length)));this.transportQueue=this.transportQueue.filter(r=>r.requests.length>0),e.reject(e.signal?.reason??dl()),this.trackEvent({type:"abort",sourceId:e.sourceId,offset:e.offset,length:e.length,logicalRequestCount:1,logicalBytes:e.length})}}trackEvent(e){Mp(this.stats,e);try{this.onEvent?.(e)}catch{}}trackBatch(e,r){let n=qo(e),i=r.reduce((o,s)=>o+s.endOffset-s.offset,0);this.trackEvent({type:"batch",logicalRequestCount:e.length,transportRequestCount:r.length,logicalBytes:n,transportBytes:i,overfetchBytes:Math.max(i-n,0)})}};function Mp(t,e){switch((e.type==="response"||e.type==="error")&&e.networkTimeMs!==void 0&&t.get(Y.networkTimeMs,"time").addTime(e.networkTimeMs),e.type){case"queued":t.get(Y.logicalRanges,"count").incrementCount(),t.get(Y.requestedBytes,"count").addCount(e.logicalBytes||0);break;case"batch":t.get(Y.rangeBatches,"count").incrementCount(),t.get("Logical Ranges Batched","count").addCount(e.logicalRequestCount||0),t.get(Y.transportRanges,"count").addCount(e.transportRequestCount||0),t.get(Y.coalescedRanges,"count").addCount(Math.max((e.logicalRequestCount||0)-(e.transportRequestCount||0),0)),t.get(Y.transportBytes,"count").addCount(e.transportBytes||0),t.get(Y.overfetchBytes,"count").addCount(e.overfetchBytes||0);break;case"response":t.get(Y.completedTransportRanges,"count").incrementCount(),t.get(Y.responseBytes,"count").addCount(e.responseBytes||0),e.fullResponse&&t.get(Y.fullResponseFallbacks,"count").incrementCount();break;case"error":t.get(Y.failedTransportRanges,"count").incrementCount();break;case"abort":t.get(Y.abortedLogicalRanges,"count").incrementCount();break;default:}}function ml(t="range-request-scheduler"){let e=new ke({id:t});return pl(e),e}async function yp(t){let e=Tp(t.signal),r=Rr();try{let n=!1,i=await t.fetch(t.url,fl(t.fetchOptions,t.offset,t.length,e.signal));if(i.status===416&&t.offset===0){let c=Sp(i.headers.get("Content-Range"));if(!c)throw new Error("Missing content-length on 416 response");i=await t.fetch(t.url,fl(t.fetchOptions,0,c,e.signal)),n=!0}if(i.status===200)throw e.abort(),await bp(i),new Error("Byte-range request failed: server returned 200 instead of 206");if(i.status!==206&&!i.ok)throw new Error(`Bad response code: ${i.status}`);let o=await i.arrayBuffer(),s=i.headers.get("Content-Range"),a=Ep(s);if(s&&!a)throw new Error(`Invalid Content-Range header: ${s}`);if(a){let c=a.endOffset-a.offset+1,l=t.offset+t.length-1;if(a.offset!==t.offset||a.endOffset>l||c!==o.byteLength||a.sourceByteLength!==void 0&&a.endOffset>=a.sourceByteLength)throw new Error(`Content-Range does not match requested range: ${s}`)}return{arrayBuffer:o,status:i.status,sourceByteLength:a?.sourceByteLength,transportBytes:o.byteLength,networkTimeMs:Rr()-r,fullResponse:n}}finally{e.removeAbortListener()}}function xp(t,e,r){if(t.sourceId!==e.sourceId||t.isolationKey!==(e.isolationKey??e.sourceId))return!1;let n=e.offset+e.length,i=e.offset-t.endOffset,o=Math.max(t.endOffset,n)-t.offset;return i<=r.rangeExpansionBytes&&o<=r.maxMergedBytes}function pl(t){t.get(Y.logicalRanges,"count"),t.get(Y.requestedBytes,"count"),t.get(Y.rangeBatches,"count"),t.get("Logical Ranges Batched","count"),t.get(Y.transportRanges,"count"),t.get(Y.coalescedRanges,"count"),t.get(Y.transportBytes,"count"),t.get(Y.completedTransportRanges,"count"),t.get(Y.responseBytes,"count"),t.get(Y.networkTimeMs,"time"),t.get(Y.overfetchBytes,"count"),t.get(Y.fullResponseFallbacks,"count"),t.get(Y.failedTransportRanges,"count"),t.get(Y.abortedLogicalRanges,"count")}function qo(t){return t.reduce((e,r)=>e+r.length,0)}function _p(t){return t instanceof ArrayBuffer?{arrayBuffer:t}:t}function fl(t,e,r,n){return{...t,signal:n,headers:{...wp(t?.headers),Range:`bytes=${e}-${e+r-1}`}}}function wp(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):t:{}}function Sp(t){let e=t?.match(/^bytes \*\/(\d+)$/);return e?Number(e[1]):null}function Ep(t){let e=t?.match(/^bytes (\d+)-(\d+)\/(\d+|\*)$/);if(!e)return null;let r=Number(e[1]),n=Number(e[2]),i=e[3]==="*"?void 0:Number(e[3]);return!Number.isSafeInteger(r)||!Number.isSafeInteger(n)||r>n||i!==void 0&&!Number.isSafeInteger(i)?null:{offset:r,endOffset:n,sourceByteLength:i}}function Tp(t){let e=new AbortController,r=()=>e.abort(t?.reason);return t?.aborted?e.abort(t?.reason):t?.addEventListener("abort",r,{once:!0}),{signal:e.signal,abort:()=>e.abort(),removeAbortListener:()=>t?.removeEventListener("abort",r)}}async function bp(t){await t.body?.cancel().catch(()=>{})}function Rr(){return globalThis.performance?.now()??Date.now()}function dl(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let t=new Error("Request aborted");return t.name="AbortError",t}var Ce={};ao(Ce,{dirname:()=>Pp,filename:()=>vp,join:()=>Rp,resolve:()=>Cp});function gl(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=globalThis.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function vp(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function Pp(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function Rp(...t){return t=t.map((r,n)=>(n&&(r=r.replace(new RegExp("^/"),"")),n!==t.length-1&&(r=r.replace(new RegExp("/$"),"")),r)),t.join("/")}function Cp(...t){let e=[];for(let o=0;o<t.length;o++)e[o]=t[o];let r="",n=!1,i;for(let o=e.length-1;o>=-1&&!n;o--){let s;o>=0?s=e[o]:(i===void 0&&(i=gl()),s=i),s.length!==0&&(r=`${s}/${r}`,n=s.charCodeAt(0)===Cr)}return r=Ap(r,!n),n?`/${r}`:r.length>0?r:"."}var Cr=47,Fo=46;function Ap(t,e){let r="",n=-1,i=0,o,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)o=t.charCodeAt(a);else{if(o===Cr)break;o=Cr}if(o===Cr){if(!(n===a-1||i===1))if(n!==a-1&&i===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==Fo||r.charCodeAt(r.length-2)!==Fo){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Cr;--l);if(l!==c){r=l===-1?"":r.slice(0,l),n=a,i=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",n=a,i=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(n+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}n=a,i=0}else o===Fo&&i!==-1?++i:i=-1}return r}var Xt=class{handle;size;bigsize;url;constructor(e){this.handle=e instanceof ArrayBuffer?new Blob([e]):e,this.size=e instanceof ArrayBuffer?e.byteLength:e.size,this.bigsize=BigInt(this.size),this.url=e instanceof File?e.name:""}async close(){}async stat(){return{size:this.handle.size,bigsize:BigInt(this.handle.size),isDirectory:!1}}async read(e,r,n){if(n?.aborted)throw new Error("Request aborted");let i=await this.handle.slice(Number(e),Number(e)+Number(r)).arrayBuffer();if(n?.aborted)throw new Error("Request aborted");return i}};function kn(t,e){return e?e.aborted?(t.catch(()=>{}),Promise.reject(e.reason)):new Promise((r,n)=>{let i=()=>{e.removeEventListener("abort",i),n(e.reason)};e.addEventListener("abort",i,{once:!0}),t.then(o=>{e.removeEventListener("abort",i),r(o)},o=>{e.removeEventListener("abort",i),n(o)})}):t}function Un(t,e){let r=new AbortController,n=[],i=()=>{for(let[o,s]of n)o.removeEventListener("abort",s)};for(let o of e){if(!o)continue;let s=()=>r.abort(o.reason);n.push([o,s]),o.addEventListener("abort",s,{once:!0}),o.aborted&&s()}try{return r.signal.throwIfAborted(),kn(t(r.signal),r.signal).catch(o=>{throw r.abort(o),o}).finally(i)}catch(o){return r.abort(o),i(),Promise.reject(o)}}var Wn=class{url;fetchFunction;fetchOptions;consistency;identityHints;countedFailures=new WeakSet;telemetry={requestedBytes:0,downloadedBytes:0,requestCount:0,networkTimeMs:0,abortCount:0,errorCount:0};constructor(e,r){zp(r.byteLength),this.url=e,this.fetchFunction=r.fetch||((n,i)=>globalThis.fetch(n,i)),this.fetchOptions=r.fetchOptions?{...r.fetchOptions,headers:new Headers(r.fetchOptions.headers)}:void 0,this.consistency=r.consistency||"best-effort",this.identityHints={byteLength:r.byteLength,etag:$n(r.etag),lastModified:$n(r.lastModified)}}getInitialIdentity(){let{byteLength:e,etag:r,lastModified:n}=this.identityHints;return e!==void 0&&(r!==void 0||n!==void 0)?Hn(e,r,n):e===0&&this.consistency==="best-effort"?Hn(0):null}getTelemetry(){return Object.freeze({...this.telemetry})}trackFailure(e){if(typeof e=="object"&&e!==null){if(this.countedFailures.has(e))return;this.countedFailures.add(e)}_l(e)?this.telemetry.abortCount++:this.telemetry.errorCount++}async requestRange(e,r,n,i){let o=Vn(),s=qp(n,this.fetchOptions?.signal);this.telemetry.requestCount++,this.telemetry.requestedBytes+=r;try{let a=await this.fetchFunction(this.url,Ip(this.fetchOptions,e,r,s.signal));if(Np(a,e,r,i))return await this.readEmptyIdentityProbe(a,o);if(a.status!==206)throw await jn(a),new Error(`HTTP byte-range request expected 206, received ${a.status}`);let c=await Op(a),l=Ml(a,c.byteLength),h=xl(i,l,this.identityHints,this.consistency)||Gp(c,e,r);if(h)throw await jn(a),new Error(h);let u=await a.arrayBuffer();if(this.telemetry.downloadedBytes+=u.byteLength,u.byteLength!==r)throw new Error(`HTTP byte-range response contained ${u.byteLength} bytes; expected ${r}`);return{arrayBuffer:u,identity:yl(i,l,this.identityHints),status:a.status,transportBytes:u.byteLength,networkTimeMs:Vn()-o}}catch(a){throw(i===null||!_l(a))&&this.trackFailure(a),a}finally{s.removeAbortListeners(),this.telemetry.networkTimeMs+=Vn()-o}}async readEmptyIdentityProbe(e,r){let n=Ml(e,0),i=xl(null,n,this.identityHints,this.consistency);if(await jn(e),i)throw new Error(i);return{arrayBuffer:new ArrayBuffer(0),identity:yl(null,n,this.identityHints),status:e.status,transportBytes:0,networkTimeMs:Vn()-r}}};function Ip(t,e,r,n){let i=new Headers(t?.headers);return i.set("Range",`bytes=${e}-${e+r-1}`),{...t,method:"GET",body:void 0,headers:i,signal:n}}function Np(t,e,r,n){return t.status===416&&n===null&&e===0&&r===1&&/^bytes \*\/0$/i.test(t.headers.get("Content-Range")||"")}async function Op(t){try{return Lp(t.headers.get("Content-Range"))}catch(e){throw await jn(t),e}}function Lp(t){let e=t?.match(/^bytes (\d+)-(\d+)\/(\d+)$/);if(!e)throw new Error("HTTP byte-range response has an invalid Content-Range header");return{offset:Number(e[1]),endOffset:Number(e[2]),byteLength:Number(e[3])}}function Ml(t,e){return Hn(e,$n(t.headers.get("ETag")),$n(t.headers.get("Last-Modified")))}function yl(t,e,r){return t||Hn(e.byteLength,e.etag??r.etag,e.lastModified??r.lastModified)}function Gp(t,e,r){return!Number.isSafeInteger(t.offset)||!Number.isSafeInteger(t.endOffset)||!Number.isSafeInteger(t.byteLength)||t.offset<0||t.endOffset<t.offset||t.endOffset>=t.byteLength?"HTTP byte-range response has invalid range bounds":t.offset!==e||t.endOffset!==e+r-1?"HTTP byte-range response does not match the requested range":null}function xl(t,e,r,n){let i=t?.byteLength??r.byteLength;if(i!==void 0&&e.byteLength!==i)return"HTTP file length changed while the file was open";let o=t?.etag??r.etag,s=t?.lastModified??r.lastModified;return o?e.etag?o===e.etag?null:"HTTP file ETag changed while the file was open":n==="strict"?"HTTP byte-range response is missing the pinned ETag":s&&e.lastModified&&s!==e.lastModified?"HTTP file Last-Modified value changed while the file was open":null:s?e.lastModified&&s!==e.lastModified?"HTTP file Last-Modified value changed while the file was open":n==="strict"&&!e.lastModified?"HTTP byte-range response is missing the pinned Last-Modified value":null:n==="strict"&&!e.etag&&!e.lastModified?"HTTP byte-range response does not provide an ETag or Last-Modified validator":null}function Hn(t,e,r){return Object.freeze({byteLength:t,etag:e,lastModified:r})}function zp(t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))throw new Error("HttpFile byteLength must be a non-negative safe integer")}async function jn(t){await t.body?.cancel().catch(()=>{})}function $n(t){return t||void 0}function Vn(){return globalThis.performance?.now()??Date.now()}function _l(t){return t instanceof Error&&t.name==="AbortError"||t instanceof Error&&/aborted/i.test(t.message)}function qp(...t){let e=new AbortController,r=[...new Set(t.filter(i=>!!i))],n=()=>e.abort();for(let i of r)i.aborted?e.abort():i.addEventListener("abort",n,{once:!0});return{signal:e.signal,removeAbortListeners:()=>{for(let i of r)i.removeEventListener("abort",n)}}}var Ar=class t{handle;url;transport;rangeScheduler;schedulerIsolationKey={};suppliedByteLength;identity;openPromise=null;closed=!1;constructor(e,r={}){this.handle=e,this.url=e,this.transport=new Wn(e,r),this.rangeScheduler=r.rangeScheduler||new Dn({batchDelayMs:0,...r.rangeSchedulerProps}),this.suppliedByteLength=r.byteLength,this.identity=this.transport.getInitialIdentity()}static async open(e,r={},n){let i=new t(e,r);return await i.open(n),i}async open(e){if(this.assertOpen(),e?.aborted){let r=Sl();throw this.transport.trackFailure(r),r}return await this.getIdentity(e),this}get size(){return this.identity?.byteLength??this.suppliedByteLength??0}get bigsize(){return BigInt(this.size)}getIdentitySnapshot(){return this.identity}getTelemetry(){return this.transport.getTelemetry()}async close(){this.closed=!0}async stat(){this.assertOpen();let e=await this.getIdentity();return{size:e.byteLength,bigsize:BigInt(e.byteLength),isDirectory:!1}}async read(e=0,r=0,n){if(this.assertOpen(),n?.aborted){let s=Sl();throw this.transport.trackFailure(s),s}let i=await this.getIdentity(n),o=wl(e);if(Bp(o,r,i.byteLength),r===0)return new ArrayBuffer(0);try{return await this.rangeScheduler.scheduleRequest({sourceId:this.url,isolationKey:this.schedulerIsolationKey,offset:o,length:r,signal:n,fetchRange:this.fetchScheduledRange})}catch(s){throw this.transport.trackFailure(s),s}}async fetchRange(e,r,n){let i=wl(e),o=await this.read(i,r,n),s=Fp(this.identity,i,r);return new Response(o,{status:206,headers:s})}fetchScheduledRange=async(e,r,n)=>{let i=await this.getIdentity(n),o=await this.transport.requestRange(e,r,n,i);return{arrayBuffer:o.arrayBuffer,status:o.status,transportBytes:o.transportBytes,networkTimeMs:o.networkTimeMs}};getIdentity(e){if(this.identity)return Promise.resolve(this.identity);if(!this.openPromise){let n=this.probeIdentity().catch(i=>{throw this.openPromise===n&&(this.openPromise=null),i});this.openPromise=n}return kn(this.openPromise,e).catch(r=>{throw this.transport.trackFailure(r),r})}async probeIdentity(){try{let e=await this.transport.requestRange(0,1,void 0,null);return this.identity=e.identity,e.identity}catch(e){throw this.transport.trackFailure(e),e}}assertOpen(){if(this.closed)throw new Error("HttpFile is closed")}};function Fp(t,e,r){let n=new Headers;return r>0&&t&&n.set("Content-Range",`bytes ${e}-${e+r-1}/${t.byteLength}`),t?.etag&&n.set("ETag",t.etag),t?.lastModified&&n.set("Last-Modified",t.lastModified),n}function wl(t){let e=Number(t);if(!Number.isSafeInteger(e)||e<0)throw new Error("HTTP byte-range offset must be a non-negative safe integer");return e}function Bp(t,e,r){if(!Number.isSafeInteger(e)||e<0)throw new Error("HTTP byte-range length must be a non-negative safe integer");if(t+e>r)throw new Error("HTTP byte range extends beyond the end of the file")}function Sl(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let t=new Error("Request aborted");return t.name="AbortError",t}function Yn(t={}){if(t.coordinateEpoch!==void 0&&!Number.isFinite(t.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:El(t.crs||{state:"absent",provenance:"unknown"}),vertical:t.vertical?El(t.vertical):void 0,coordinateEpoch:t.coordinateEpoch,coordinateFrame:t.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...t.coordinateOrder||[]]),units:t.units?Object.freeze([...t.units]):void 0})}function _e(t){if(typeof t=="object")return"projjson";let e=t.trim();return/^[A-Z][A-Z0-9_]*\s*[\[(]/i.test(e)?"wkt":/(?:^|\s)\+?proj=/i.test(e)?"proj-string":/^[A-Z][A-Z0-9._-]*(?::[A-Z0-9._-]+)+$/i.test(e)||/^urn:ogc:def:crs:/i.test(e)||/^https?:\/\//i.test(e)||/^[A-Z][A-Z0-9._-]*$/i.test(e)?"identifier":"opaque"}function El(t){return t.state==="explicit"||t.state==="default"?Object.freeze({...t,definition:Tl(t.definition),alternatives:t.alternatives?Object.freeze(t.alternatives.map(e=>Object.freeze({...e,definition:Tl(e.definition)}))):void 0}):Object.freeze({...t})}function Tl(t){return typeof t=="string"?t:Bo(t)}function Bo(t){return Array.isArray(t)?Object.freeze(t.map(e=>Bo(e))):t&&typeof t=="object"?Object.freeze(Object.fromEntries(Object.entries(t).map(([e,r])=>[e,Bo(r)]))):t}var Xn=class extends SyntaxError{constructor(e,r,n){let i=Qp(r,n);super(`${e} at ${i.line}:${i.column}`),this.name="WKTCRSSyntaxError",this.offset=n,this.line=i.line,this.column=i.column}},Kn=class extends Error{constructor(e){super(e[0]?.message||"WKT validation failed"),this.name="WKTCRSValidationError",this.issues=e}},Dp=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?$/,kp=/^[A-Za-z][A-Za-z0-9_]*/,Ir=new Set(["COMPD_CS","CONCAT_MT","FITTED_CS","GEOCCS","GEOGCS","INVERSE_MT","LOCAL_CS","PARAM_MT","PASSTHROUGH_MT","PROJCS","VERT_CS"]),ko=new Set([...Ir,"AUTHORITY","AXIS","CONCAT_MT","DATUM","INVERSE_MT","LOCAL_DATUM","PARAMETER","PARAM_MT","PASSTHROUGH_MT","PRIMEM","PROJECTION","SPHEROID","TOWGS84","UNIT","VERT_DATUM"]),Up=new Set(Ir),Vp=new Set([...ko,"EXTENSION"]),jp=new Set([...Ir,"COMPDCS","LOCALCS","VERTCS"]),Wp=new Set([...ko,"COMPDCS","LOCALCS","VDATUM","VERTCS"]),bl=new Set(["BOUNDCRS","COMPOUNDCRS","COORDINATEOPERATION","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","PARAMETRICCRS","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"]),vl=new Set([...bl,"CONCATENATEDOPERATION","COORDINATEMETADATA","DERIVEDPROJCRS","GEOGCRS","GEOGRAPHICCRS","POINTMOTIONOPERATION"]),Pl=new Set([...vl,"ABRIDGEDTRANSFORMATION","ANCHOR","ANGLEUNIT","AREA","AXIS","BASEENGCRS","BASEGEODCRS","BASEGEOGCRS","BASEPARAMCRS","BASEPROJCRS","BASETIMECRS","BASEVERTCRS","BBOX","BEARING","CALENDAR","CITATION","CONVERSION","COORDEPOCH","CS","DATUM","DERIVINGCONVERSION","DYNAMIC","EDATUM","ELLIPSOID","ENGINEERINGDATUM","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEODETICDATUM","GEOIDMODEL","ID","INTERPOLATIONCRS","LENGTHUNIT","MEMBER","MERIDIAN","METHOD","MODEL","OPERATIONACCURACY","ORDER","PARAMETER","PARAMETERFILE","PARAMETRICDATUM","PARAMETRICUNIT","PDATUM","PRIMEM","PRIMEMERIDIAN","REMARK","SCALEUNIT","SCOPE","SOURCECRS","STEP","TARGETCRS","TDATUM","TEMPORALQUANTITY","TIMEEXTENT","TIMEORIGIN","TIMEUNIT","TIMEDATUM","TRIAXIAL","TRF","URI","USAGE","VDATUM","VERSION","VERTICALDATUM","VERTICALEXTENT","VELOCITYGRID","VRF"]),Hp=new Set(["BASEGEOGCRS","CALENDAR","CONCATENATEDOPERATION","COORDEPOCH","COORDINATEMETADATA","DERIVEDPROJCRS","DYNAMIC","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEOGCRS","GEOGRAPHICCRS","GEOIDMODEL","MEMBER","MODEL","POINTMOTIONOPERATION","STEP","TEMPORALQUANTITY","TRF","TRIAXIAL","VELOCITYGRID","VRF"]),$p=new Set([...Pl].filter(t=>!Hp.has(t))),Yp={wkt1:Ir,gdal:Up,esri:jp,"wkt2:2015":bl,"wkt2:2019":vl},Xp={wkt1:ko,gdal:Vp,esri:Wp,"wkt2:2015":$p,"wkt2:2019":Pl};function Nr(t,e){let n={type:"wkt-crs",root:new Do(t).parse()};if(e?.strict){let i=Rl(n,{profile:e.profile,allowExtensions:!1});if(i.length>0)throw new Kn(i)}return n}function Rl(t,e){if(!t||t.type!=="wkt-crs"||t.root?.type!=="node")throw new TypeError("validateWKTCRS expects a WKTCRSAst");let r=Kp(t.root.keyword,e?.profile||"auto"),n=Yp[r],i=Xp[r],o=[],s=t.root.keyword.toUpperCase();return n.has(s)||o.push({code:"invalid-root",message:`${t.root.keyword} is not a ${r} root keyword`,path:[],keyword:t.root.keyword}),Cl(t.root,[],a=>{let c=a.node.keyword.toUpperCase();!e?.allowExtensions&&!i.has(c)&&o.push({code:"unknown-keyword",message:`${a.node.keyword} is not defined by the ${r} profile`,path:a.path,keyword:a.node.keyword}),a.node.values.length===0&&o.push({code:"empty-node",message:`${a.node.keyword} must contain at least one value`,path:a.path,keyword:a.node.keyword});let l=Zp(a.node);l&&o.push({code:"invalid-value",message:l,path:a.path,keyword:a.node.keyword})}),o}var Do=class{constructor(e){this.offset=0,this.source=e}parse(){this.skipWhitespace();let e=this.parseNode();return this.skipWhitespace(),this.offset!==this.source.length&&this.fail("Unexpected content after WKT root"),e}parseNode(){let e=this.parseKeyword();return this.parseNodeAfterKeyword(e)}parseNodeAfterKeyword(e){this.skipWhitespace();let r=this.source[this.offset];r!=="["&&r!=="("&&this.fail(`Expected '[' or '(' after ${e}`),this.offset++;let n=r==="["?"bracket":"parenthesis",i=r==="["?"]":")",o=[];if(this.skipWhitespace(),this.source[this.offset]===i)return this.offset++,{type:"node",keyword:e,delimiter:n,values:o};for(;this.offset<this.source.length;){o.push(this.parseValue()),this.skipWhitespace();let s=this.source[this.offset];if(s===","){this.offset++,this.skipWhitespace(),this.source[this.offset]===i&&this.fail("Expected a WKT value after comma");continue}if(s===i)return this.offset++,{type:"node",keyword:e,delimiter:n,values:o};(s==="]"||s===")")&&this.fail(`Expected '${i}' to close ${e}`),this.fail(`Expected ',' or '${i}' in ${e}`)}this.fail(`Unterminated ${e} node`)}parseValue(){if(this.skipWhitespace(),this.source[this.offset]==='"')return this.parseString();let r=this.offset;for(;this.offset<this.source.length&&!/[\s,\[\]()"]/.test(this.source[this.offset]);)this.offset++;r===this.offset&&this.fail("Expected a WKT value");let n=this.source.slice(r,this.offset);return this.source[this.offset]==='"'&&this.fail("Unexpected quote in unquoted WKT value"),this.skipWhitespace(),this.source[this.offset]==="["||this.source[this.offset]==="("?(/^[A-Za-z][A-Za-z0-9_]*$/.test(n)||this.fail(`Invalid WKT keyword '${n}'`),this.parseNodeAfterKeyword(n)):Dp.test(n)?{type:"number",value:Number(n),raw:n}:{type:"enumeration",value:n}}parseKeyword(){let e=this.source.slice(this.offset).match(kp);return e||this.fail("Expected a WKT keyword"),this.offset+=e[0].length,e[0]}parseString(){this.offset++;let e="";for(;this.offset<this.source.length;){let r=this.source[this.offset++];if(r==='"'){if(this.source[this.offset]==='"'){e+='"',this.offset++;continue}return{type:"string",value:e}}e+=r}this.fail("Unterminated WKT string")}skipWhitespace(){for(;this.offset<this.source.length&&/\s/.test(this.source[this.offset]);)this.offset++}fail(e){throw new Xn(e,this.source,this.offset)}};function Kp(t,e){return e!=="auto"?e:Ir.has(t.toUpperCase())?"wkt1":"wkt2:2019"}function Zp(t){let e=t.keyword.toUpperCase(),r=t.values,n=(o,...s)=>!!(r[o]&&s.includes(r[o].type)),i=(o,...s)=>r.length===o&&s.every((a,c)=>n(c,a));if(["ANGLEUNIT","LENGTHUNIT","PARAMETRICUNIT","SCALEUNIT","TIMEUNIT","TEMPORALQUANTITY","UNIT"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${t.keyword} must start with a quoted name and numeric conversion factor`;if(e==="CS"&&!i(2,"enumeration","number"))return`${t.keyword} must contain a coordinate-system type and dimension`;if(e==="BBOX"&&!i(4,"number","number","number","number"))return`${t.keyword} must contain four numeric bounds`;if(["ENSEMBLEACCURACY","EPOCH","COORDEPOCH","FRAMEEPOCH","OPERATIONACCURACY","ORDER"].includes(e)&&!i(1,"number"))return`${t.keyword} must contain one number`;if(["ANCHOR","AREA","CALENDAR","CITATION","REMARK","SCOPE","URI","VERSION"].includes(e)&&!i(1,"string"))return`${t.keyword} must contain one quoted string`;if(["ELLIPSOID","SPHEROID","TRIAXIAL"].includes(e)&&!(r.length>=3&&n(0,"string")&&n(1,"number")&&n(2,"number")))return`${t.keyword} must start with a quoted name and numeric ellipsoid axes`;if(["PARAMETER"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${t.keyword} must start with a quoted name and numeric value`;if(e==="PARAMETERFILE"&&!i(2,"string","string"))return`${t.keyword} must contain a quoted name and file name`;if(["AUTHORITY","ID"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"string","number")))return`${t.keyword} must start with a quoted authority and identifier`;if(["AXIS"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"enumeration")))return`${t.keyword} must start with a quoted name and axis direction`;if(["METHOD","PROJECTION"].includes(e)&&!(r.length>=1&&n(0,"string")))return`${t.keyword} must start with a quoted name`;if(e==="TIMEEXTENT"){let o=s=>n(s,"enumeration","string");if(r.length!==2||!o(0)||!o(1))return`${t.keyword} must contain two date-time or quoted values`}if(e==="VERTICALEXTENT"&&(r.length<2||r.length>3||!n(0,"number")||!n(1,"number")||r.length===3&&!n(2,"node")))return`${t.keyword} must contain two numeric bounds and an optional unit`;if(e==="COORDINATEMETADATA"&&(r.length<1||r.length>2||!n(0,"node")||r.length===2&&(!n(1,"node")||!["EPOCH","COORDEPOCH"].includes(r[1].keyword.toUpperCase()))))return`${t.keyword} must contain a CRS and an optional coordinate epoch`;if(e==="BOUNDCRS"){let o=r.slice(0,3).map(s=>s.type==="node"?s.keyword.toUpperCase():"");if(o[0]!=="SOURCECRS"||o[1]!=="TARGETCRS"||o[2]!=="ABRIDGEDTRANSFORMATION")return`${t.keyword} must start with SOURCECRS, TARGETCRS, and ABRIDGEDTRANSFORMATION`}return["COMPOUNDCRS","CONCATENATEDOPERATION","COORDINATEOPERATION","DERIVEDPROJCRS","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","GEOGCRS","GEOGRAPHICCRS","PARAMETRICCRS","POINTMOTIONOPERATION","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"].includes(e)&&!n(0,"string")?`${t.keyword} must start with a quoted name`:null}function Cl(t,e,r){r({node:t,path:e});for(let n=0;n<t.values.length;n++){let i=t.values[n];i.type==="node"&&Cl(i,[...e,n],r)}}function Qp(t,e){let r=1,n=1;for(let i=0;i<e&&i<t.length;i++)t[i]===`
8
- `?(r++,n=1):n++;return{line:r,column:n}}var ft=class extends SyntaxError{constructor(e,r,n){let i=n1(r,n);super(`${e} at ${i.line}:${i.column}`),this.name="PROJStringSyntaxError",this.offset=n,this.line=i.line,this.column=i.column}};function Or(t){let e=t1(t);if(e.length===0)throw new ft("PROJ string is empty",t,0);return{type:"proj-string",parameters:e.map(n=>e1(n.raw,n.offset,t))}}var Jp=/^[+-]?\d+(?:\.\d*)?d(?:\d+(?:\.\d*)?'(?:\d+(?:\.\d*)?")?)?[NSEW]?$/i;function e1(t,e,r){let n=t.startsWith("+")?t.slice(1):t;if(!n)throw new ft("Expected a parameter after '+'",r,e);let i=n.indexOf("="),o=i<0?n:n.slice(0,i);if(!o||/[\s+=]/.test(o))throw new ft(`Invalid PROJ parameter name '${o}'`,r,e);if(i<0)return{type:"parameter",name:o};let s=n.slice(i+1),a=r1(s,r,e+i+1);return{type:"parameter",name:o,value:a,rawValue:s}}function t1(t){let e=[],r=0;for(;r<t.length;){for(;r<t.length&&/\s/.test(t[r]);)r++;if(r>=t.length)break;let n=r,i=null,o=!1;for(;r<t.length;){let s=t[r];if(o){o=!1,r++;continue}if(s==="\\"&&i){o=!0,r++;continue}if(i){s===i&&(i=null),r++;continue}if((s==='"'||s==="'")&&t[r-1]==="="){i=s,r++;continue}if(/\s/.test(s))break;r++}if(i)throw new ft("Unterminated quoted PROJ value",t,n);e.push({raw:t.slice(n,r),offset:n})}return e}function r1(t,e,r){if(!t)return"";let n=t[0];if(n!=='"'&&n!=="'"){if((t.includes('"')||t.includes("'"))&&!Jp.test(t))throw new ft("Quote must begin a PROJ parameter value",e,r);return t}if(t[t.length-1]!==n)throw new ft("Unterminated quoted PROJ value",e,r);let i="";for(let o=1;o<t.length-1;o++){let s=t[o];s==="\\"&&o+1<t.length-1?i+=t[++o]:i+=s}return i}function n1(t,e){let r=1,n=1;for(let i=0;i<e&&i<t.length;i++)t[i]===`
9
- `?(r++,n=1):n++;return{line:r,column:n}}var Zn=class{item;previous;next;constructor(e,r,n){this.item=e,this.previous=r,this.next=n}};var Qn=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new Zn(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let n=e.next;e.next=r,this.tail===e?this.tail=r:n.previous=r,r.next=n,r.previous=e,++this._length}};var Kt=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Qn,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(e,r))}unloadTile(e,r,n){let i=r._cacheNode;i&&(this._list.remove(i),r._cacheNode=null,n&&n(e,r))}unloadTiles(e,r){let n=this._trimTiles;this._trimTiles=!1;let i=this._list,o=this._sentinel,s=i.head;for(;s!==o&&(e.gpuMemoryUsageInBytes>e.cacheBytes||n);){let a=s.item;s=s.next,this.unloadTile(e,a,r)}}trim(){this._trimTiles=!0}};function Jn(t,e){Ye(t),Ye(e);let{rtcCenter:r,gltfUpAxis:n}=e,{computedTransform:i,boundingVolume:{center:o}}=t,s=new z(i);switch(r&&s.translate(r),n){case"Z":break;case"Y":let f=new z().rotateX(Math.PI/2);s=s.multiplyRight(f);break;case"X":let d=new z().rotateY(-Math.PI/2);s=s.multiplyRight(d);break;default:break}e.isQuantized&&s.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new M(o);e.cartesianModelMatrix=s,e.cartesianOrigin=a;let c=L.WGS84.cartesianToCartographic(a,new M),h=L.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=h.multiplyRight(s),e.cartographicOrigin=c;let u=o1(e);u&&(e.cartesianModelMatrix=new z(s).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=z.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var i1=1e6**2;function o1(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,i=e.scenes?.[r]?.nodes?.[0];if(!i?.matrix)return null;let o=i.matrix;return o[12]*o[12]+o[13]*o[13]+o[14]*o[14]<=i1?null:i}var Al=new M,Uo=new M,s1=1e-5,a1=1e-7,Vo=new ce([new ie,new ie,new ie,new ie,new ie,new ie]);function ei(t,e,r={}){let{cameraUp:n,height:i}=t,o=t.cameraDirection,{metersPerUnit:s}=t.distanceScales,a=Lr(t,t.center),c=L.WGS84.eastNorthUpToFixedFrame(a),l=t.unprojectPosition(t.cameraPosition),h=L.WGS84.cartographicToCartesian(l,new M),u;if(o)u=new M(c.transformAsVector(new M(o).scale(s))).normalize();else{let E=t.getFrustumPlanes().near,v=jo(E,t.cameraPosition),T=Lr(t,v);u=new M(T).subtract(h).normalize()}let f=new M(c.transformAsVector(new M(n).scale(s))).normalize();c1(t);let d=t.constructor,{longitude:m,latitude:p,width:g,bearing:y,zoom:x,position:w}=t,_=new d({longitude:m,latitude:p,height:i,width:g,bearing:y,zoom:x,position:w,pitch:0}),S=Number.isFinite(t.fovy)&&Number(t.fovy)>0&&Number(t.fovy)<180?Number(t.fovy)*Math.PI/180:Math.PI/3;return{camera:{position:h,direction:u,up:f,cartographicPosition:l,verticalFieldOfView:S,timeSinceMovement:r.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:t,topDownViewport:_,height:i,cullingVolume:Vo,clippingPlanes:t.clippingPlanes,frameNumber:e,sseDenominator:2*Math.tan(S/2),dynamicScreenSpaceErrorDensity:0}}function Il(t,e,r,n){let i=Array.from(e),o=Array.from(r),s=t?i.length!==t.position.length||i.some((l,h)=>Math.abs(l-t.position[h])>s1):!1,a=t?o.length!==t.direction.length||o.some((l,h)=>Math.abs(l-t.direction[h])>a1):!1,c=s||a?n:t?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:i,direction:o,lastMovementTime:c},timeSinceMovement:Math.max((n-c)/1e3,0)}}function Nl(t,e,r){if(r===0||t.length<=r)return[t,[]];let n=[],{longitude:i,latitude:o}=e.viewport;for(let[l,h]of t.entries()){let[u,f]=h.header.mbs,d=Math.abs(i-u),m=Math.abs(o-f),p=Math.sqrt(m*m+d*d);n.push([l,p])}let s=n.sort((l,h)=>l[1]-h[1]),a=[];for(let l=0;l<r;l++)a.push(t[s[l][0]]);let c=[];for(let l=r;l<s.length;l++)c.push(t[s[l][0]]);return[a,c]}function c1(t){let e=t.getFrustumPlanes(),r=jo(e.near,t.cameraPosition),n=Lr(t,r),i=Lr(t,t.cameraPosition,Uo),o=0;Vo.planes[o++].fromPointNormal(n,Al.copy(n).subtract(i));for(let s in e){if(s==="near")continue;let a=e[s],c=jo(a,r,Uo),l=Lr(t,c,Uo);Vo.planes[o++].fromPointNormal(l,Al.copy(n).subtract(l))}}function jo(t,e,r=new M){let n=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-n).add(e),r}function Lr(t,e,r=new M){let n=t.unprojectPosition(e);return L.WGS84.cartographicToCartesian(n,r)}var ql=new M,l1=new M,At=new M,Ol=new M,Gr=new M,Ll=new M,Gl=new M,zl=new M,ti=new De,h1=new M(0,0,1);function Fl(t,e){t._updateTransform(e)}function Bl(t,e,r){if(!Number.isFinite(r.dynamicScreenSpaceErrorDensity)||r.dynamicScreenSpaceErrorDensity<=0)return 0;let n=m1(t),i=n.region?p1(n.region,e):g1(t,n,e);if(!i)return 0;let o=xr(r.dynamicScreenSpaceErrorHeightFalloff,0,1),s=i.minimumHeight+(i.maximumHeight-i.minimumHeight)*o,a=i.maximumHeight-s,c=a>0?xr((i.cameraHeight-s)/a,0,1):i.cameraHeight>=i.maximumHeight?1:0,h=(1-xr(Math.abs(i.cameraDirection.dot(i.upDirection)),0,1))*(1-c);return r.dynamicScreenSpaceErrorDensity*h}function u1(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function f1(t,e,r){return e<=0||r<=0||!Number.isFinite(e)||!Number.isFinite(r)?0:u1(t,e)*r}function Dl(t,e,r,n=1){let i=t.tileset,o=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,s=r?o:t.lodMetricValue;if(s===0)return 0;let{viewDistanceScale:a}=i.options,c=a||1,l=Number.isFinite(n)?Math.max(n,0):1,h=d1(s,e,c,l);if(h!==null)return h;let u=Math.max(t._distanceToCamera,1e-7),{height:f,sseDenominator:d}=e,m=s*f*l*c/(u*d);return i.options.dynamicScreenSpaceError&&!e.viewport.orthographic&&(m-=f1(u,e.dynamicScreenSpaceErrorDensity,i.options.dynamicScreenSpaceErrorFactor)),m}function d1(t,e,r,n){let i=e.viewport;if(!i?.orthographic)return null;let o=i.metersPerPixel;return!Number.isFinite(o)||!o||o<=0?null:t*r*n/o}function m1(t){return t.header.content?.boundingVolume||t.header.boundingVolume}function p1(t,e){let r=ql.copy(e.camera.position).normalize(),n=Gr.copy(e.camera.direction).normalize();return{cameraHeight:e.camera.cartographicPosition[2],minimumHeight:t[4],maximumHeight:t[5],cameraDirection:n,upDirection:r}}function g1(t,e,r){let n=M1(e,At);if(n===null)return null;let i=new z(t.computedTransform).invert(),o=t.tileset.ellipsoid;if(Math.hypot(At[0],At[1],At[2])>o.minimumRadius){let a=o.cartesianToCartographic(At,l1),c=ql.copy(r.camera.position).normalize(),l=Gr.copy(r.camera.direction).normalize();return{cameraHeight:r.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:l,upDirection:c}}return i.transformAsPoint(r.camera.position,Ol),i.transformAsVector(r.camera.direction,Gr),Gr.normalize(),{cameraHeight:Ol[2],minimumHeight:At[2]-n,maximumHeight:At[2]+n,cameraDirection:Gr,upDirection:h1}}function M1(t,e){if(t.box){let r=t.box;return e.set(r[0],r[1],r[2]),y1(r)}if(t.sphere){let r=t.sphere;return e.set(r[0],r[1],r[2]),r[3]}return null}function y1(t){return t.length===10?(ti.fromArray(t,6),Ll.set(t[3],0,0).transformByQuaternion(ti),Gl.set(0,t[4],0).transformByQuaternion(ti),zl.set(0,0,t[5]).transformByQuaternion(ti),Math.abs(Ll[2])+Math.abs(Gl[2])+Math.abs(zl[2])):Math.abs(t[5])+Math.abs(t[8])+Math.abs(t[11])}var he={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},ne;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(ne||(ne={}));var tt;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(tt||(tt={}));var le;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(le||(le={}));var Zt;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Zt||(Zt={}));var kl={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};var Ul=1e4,x1=1e4,_1=1e8,w1=new me,Vl=new M,jl=new M,Wo=new M,ri=new M;function Ho(t,e,r){return t+(e-t)*r}function Wl(t,e){let r=t instanceof me?t:t.getBoundingSphere(w1),{center:n,radius:i}=r;Vl.copy(n).subtract(e.position);let o=Math.max(Vl.dot(e.direction),0);return jl.copy(e.direction).scale(o).add(e.position),Wo.copy(jl).subtract(n),Wo.magnitude()<=i||(ri.copy(Wo).normalize().scale(i).add(n).subtract(e.position),ri.magnitude()===0)?0:(ri.normalize(),Math.min(Math.max(1-ri.dot(e.direction),0),1))}function Hl(t,e,r,n){return!Number.isFinite(n)||n<=0||n>.5?!1:t>r?!0:e!==void 0&&e>r}function $l(t){let e=Number.isFinite(t.foveatedConeSize)?Math.min(Math.max(t.foveatedConeSize,0),1):1,r=t.refinement===ne.REPLACE;if(r&&!t.skipLevelOfDetail||!t.foveatedScreenSpaceError||e>=1||r&&t.skipLevelOfDetail&&t.priorityProgressiveResolution)return!1;let n=Number.isFinite(t.verticalFieldOfView)&&t.verticalFieldOfView>0?t.verticalFieldOfView:Math.PI/3,i=1-Math.cos(n*.5),o=e*i;if(t.foveatedFactor<=o||i<=o)return!1;let s=Math.min(Math.max((t.foveatedFactor-o)/(i-o),0),1),c=(typeof t.interpolationCallback=="function"?t.interpolationCallback:Ho)(t.minimumScreenSpaceErrorRelaxation,t.maximumScreenSpaceError,s),l=Number.isFinite(c)?Math.min(Math.max(c,0),t.maximumScreenSpaceError):0,h=t.screenSpaceError===0&&t.parentScreenSpaceError!==void 0?t.parentScreenSpaceError*.5:t.screenSpaceError;return t.maximumScreenSpaceError-l<=h}function Yl(t,e,r){return t&&Number.isFinite(e)&&Number.isFinite(r)&&r>0&&e<r}function Xl(t){let e=t.rootScreenSpaceError>0?Math.min(Math.max(t.reverseScreenSpaceError/t.rootScreenSpaceError,0),1):0,r=Math.floor(e*(Ul-1)),n=Number.isFinite(t.foveatedFactor)?Math.min(Math.max(t.foveatedFactor,0),1):0,i=Math.floor(n*(Ul-1))*x1;return(t.priorityProgressiveResolution?0:_1)+i+r}var Qt="EPSG:4326",ni="EPSG:4978";function zr(t){let e=t.trim().toUpperCase(),r=e.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return r?`${r[1]}:${r[2]}`:e}function Ae(t){if(typeof t=="string"){let r=_e(t);return r==="wkt"?S1(t):r==="proj-string"?E1(t):$o(t)||"projected"}let e=t;return e.type==="BoundCRS"&&e.source_crs?Ae(e.source_crs):e.type==="CompoundCRS"&&e.components?.[0]?Ae(e.components[0]):String(e.type).includes("Projected")?"projected":String(e.type).includes("Geographic")?"geographic":String(e.type).includes("Geodetic")?e.coordinate_system?.subtype==="Cartesian"?"geocentric":"geographic":"unknown"}function $o(t){if(typeof t!="string")return;let e=zr(t);if(e===ni)return"geocentric";if(e===Qt||e==="OGC:CRS84")return"geographic";let r=/^EPSG:(\d+)$/.exec(e);if(!r)return;let n=Number(r[1]);if(n===7789)return"geocentric";if(n===4490||n===4979)return"geographic";if(n===3857||n>=32601&&n<=32660||n>=32701&&n<=32760)return"projected"}function S1(t){let e;try{e=Nr(t).root}catch{return"unknown"}switch(e.keyword.toUpperCase()){case"GEOCCS":return"geocentric";case"GEOGCS":case"GEOGCRS":case"GEOGRAPHICCRS":case"GEOGRAPHIC2DCRS":case"GEOGRAPHIC3DCRS":return"geographic";case"PROJCS":case"PROJCRS":case"PROJECTEDCRS":return"projected";case"GEODCRS":case"GEODETICCRS":{let n=e.values.find(i=>i.type==="node"&&i.keyword.toUpperCase()==="CS")?.values[0];return n?.type!=="enumeration"&&n?.type!=="string"?"unknown":n.value.toUpperCase()==="CARTESIAN"?"geocentric":n.value.toUpperCase()==="ELLIPSOIDAL"?"geographic":"unknown"}default:return"unknown"}}function E1(t){try{let e=Or(t).parameters.find(r=>r.name.toLowerCase()==="proj")?.value;switch(e?.toLowerCase()){case"longlat":case"latlong":return"geographic";case"geocent":return"geocentric";default:return e?"projected":"unknown"}}catch{return"unknown"}}function Ie(t,e={}){let r=e.sourceCrs!==void 0,n=e.sourceCrs||t.sourceCrs,i=e.outputCoordinates||"auto",o=e.targetCrs||(i==="ecef"?"EPSG:4978":void 0),s=e.targetHeightReference||"native",a=t.verticalUnitScale??1,c=t.elevationUnitScale??1,l=t.elevationOffset||0,h=t.elevationMode==="onTheGround"||t.elevationMode==="relativeToGround"||t.elevationMode==="relativeToScene",u=t.elevationMode==="relativeToScene"?!!e.sceneElevationProvider:!h||!!e.terrainElevationProvider,f=a!==1||c!==1||t.elevationMode!==void 0&&(h||t.elevationMode==="absoluteHeight"&&l!==0),d=s!=="native"&&s!==t.heightReference,m=!!o||s!=="native"||i!=="auto"||f,p=i!=="target-crs"||!!o,g=!d||(t.heightReference||"unknown")!=="unknown",y=Number.isFinite(a)&&a>0&&Number.isFinite(c)&&c>0,x=!!n&&m&&p&&g&&y&&u&&i!=="local-enu",w=r?"caller-override":t.provenance||"unknown",_=r&&n?Ae(n):t.coordinateFrame,S=r?"explicit":t.sourceCrsState||(n?w==="format-default"?"default":"explicit":"absent"),E=Yn({crs:n?{state:S==="default"?"default":"explicit",definition:n,representation:!r&&t.sourceCrsRepresentation||_e(n),provenance:w,alternatives:r?void 0:t.sourceCrsAlternatives}:{state:S==="unknown"?"unknown":"absent",provenance:w},vertical:t.verticalCrs?{state:"explicit",definition:t.verticalCrs,representation:_e(t.verticalCrs),provenance:t.provenance||"metadata"}:void 0,coordinateEpoch:e.coordinateEpoch??t.coordinateEpoch,coordinateFrame:_,coordinateOrder:b1(t.axisOrder),units:r?void 0:t.units}),v=Yo(E.crs),T=E.vertical?Yo(E.vertical):void 0,I=o?T1(o):void 0;return Object.freeze({...E,sourceCrs:v,verticalCrs:T,verticalUnitScale:a,coordinateEpoch:e.coordinateEpoch??t.coordinateEpoch,heightReference:t.heightReference||"unknown",elevationMode:t.elevationMode,elevationOffset:t.elevationOffset,elevationUnit:t.elevationUnit,elevationUnitScale:c,coordinateFrame:_||"unknown",axisOrder:t.axisOrder||"unknown",provenance:w,targetCrs:I,targetHeightReference:s,outputCoordinates:i,status:m?x?"transformable":"unresolved":"native",warnings:Object.freeze([...t.warnings||[]])})}function It(t,e={}){return Ie({sourceCrs:t?.sourceCrs,sourceCrsState:t?.crs.state,sourceCrsRepresentation:t?.crs.state==="explicit"||t?.crs.state==="default"?t.crs.representation:void 0,sourceCrsAlternatives:t?.crs.state==="explicit"||t?.crs.state==="default"?t.crs.alternatives:void 0,verticalCrs:t?.verticalCrs,units:t?.units,verticalUnitScale:t?.verticalUnitScale,coordinateEpoch:t?.coordinateEpoch,heightReference:t?.heightReference,elevationMode:t?.elevationMode,elevationOffset:t?.elevationOffset,elevationUnit:t?.elevationUnit,elevationUnitScale:t?.elevationUnitScale,coordinateFrame:t?.coordinateFrame,axisOrder:t?.axisOrder,provenance:t?.provenance,warnings:t?.warnings},e)}function Yo(t){return t.state==="explicit"||t.state==="default"?t.definition:void 0}function T1(t){let e=Yn({crs:{state:"explicit",definition:t,representation:_e(t),provenance:"caller-override"}}),r=Yo(e.crs);if(!r)throw new Error("Failed to normalize a known target CRS definition");return r}function b1(t){switch(t){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function Jt(t){if(t.status!=="transformable"&&t.status!=="transformed")throw new Error("Only a transformable spatial reference can be marked as transformed");return Object.freeze({...t,status:"transformed"})}function ii(t){return!!(t&&typeof t=="object"&&"initialize"in t&&"getRootTileset"in t&&"initializeTileHeaders"in t&&"loadTileContent"in t)}var ai=1024*1024,oh=512*ai,sh=512*ai,v1=32*ai,P1=ai;function oi(t,e){if(!Number.isFinite(t)||t<0)throw new Error(`${e} must be a finite number greater than or equal to 0`);return t}function Kl(t,e){let r=t.cacheBytes??e;return oi(r,"cacheBytes")}function Zl(t,e){let r=t.maximumCacheOverflowBytes??e;return oi(r,"maximumCacheOverflowBytes")}var Xo={description:"",ellipsoid:L.WGS84,modelMatrix:new z,throttleRequests:!0,maxRequests:64,cacheBytes:oh,maximumCacheOverflowBytes:sh,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onSourceError:()=>{},onTilesetError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,progressiveResolutionHeightFraction:.3,foveatedScreenSpaceError:!0,foveatedConeSize:.1,foveatedMinimumScreenSpaceErrorRelaxation:0,foveatedInterpolationCallback:Ho,foveatedTimeDelay:.2,maximumScreenSpaceError:8,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:2e-4,dynamicScreenSpaceErrorFactor:24,dynamicScreenSpaceErrorHeightFalloff:.25,memoryAdjustedScreenSpaceError:!0,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{},spatial:{}},Ko="Tiles In Tileset(s)",Zo="Tiles In Memory",Ql="Tiles In View",Jl="Tiles To Render",eh="Tiles Loaded",Qo="Tiles Loading",th="Tiles Unloaded",rh="Failed Tile Loads",nh="Points/Vertices",Jo="Tile Memory Use",ih="Maximum Screen Space Error",si=class{options;loadOptions;source;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};schema=null;schemaUri=null;groups=[];metadata=null;statistics=null;spatialReference=Ie({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=oh;_maximumCacheOverflowBytes=sh;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new Kt;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){if(!ii(e))throw new Error("Tileset3D requires a Tileset3DSource instance");let n=r||{},i=e.type===le.TILES3D,o=i?Xo.cacheBytes:v1,s=i?Xo.maximumCacheOverflowBytes:P1,a=Kl(n,o),c=Zl(n,s);this.options={...Xo,...n,cacheBytes:a,maximumCacheOverflowBytes:c,skipLevelOfDetail:n.skipLevelOfDetail??e.type===le.TILES3D,memoryAdjustedScreenSpaceError:n.memoryAdjustedScreenSpaceError??i},this.loadOptions=this.options.loadOptions||{},this.source=e,this.tileset=null,this.loader=this.source.loader,this.type=this.source.type,this.url=this.source.url,this.basePath=this.source.basePath,this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType="",this.lodMetricValue=0,this.refine="",this.contentFormats=this.source.contentFormats,this._traverser=this._initializeTraverser(),this._requestScheduler=new ut({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=a,this._maximumCacheOverflowBytes=c;let l=this._getSourceMetadata();l&&(this.spatialReference=It(l.spatialReference,this.options.spatial)),this.stats=new ke({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet()}destroy(){this._clearDeferredTraversal(),this.source.destroy?.(),this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get requestedTiles(){return this._requestedTiles.slice()}get emptyTiles(){return this._emptyTiles.slice()}get cacheBytes(){return this._cacheBytes}set cacheBytes(e){this._cacheBytes=oi(e,"cacheBytes"),this.options.cacheBytes=this._cacheBytes}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(e){this._maximumCacheOverflowBytes=oi(e,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes}get queryParams(){let e=this.source.getTileUrl(this.url),r=e.indexOf("?");return r>=0?e.slice(r+1):""}setProps(e){let r=Kl(e,this.cacheBytes),n=Zl(e,this.maximumCacheOverflowBytes);this.options={...this.options,...e,cacheBytes:r,maximumCacheOverflowBytes:n},this._cacheBytes=r,this._maximumCacheOverflowBytes=n}getTileUrl(e){return this.source.getTileUrl(e)}hasExtension(e){return!!this.source.hasExtension?.(e)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this.cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this.cacheBytes+this.maximumCacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e],n=new Set(r.map(a=>a.id));for(let a of Object.keys(this.frameStateData))n.has(a)||delete this.frameStateData[a];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let i=Date.now(),o=Number.POSITIVE_INFINITY,s=[];for(let a of r){let c=a.id;this._needTraverse(c)?s.push(c):this.traverseCounter--}for(let a of r){let c=a.id;if(this.roots[c]||(this.roots[c]=this._initializeTileHeaders(this.tileset,null)),!s.includes(c))continue;let l=ei(a,this._frameNumber),h=this.roots[c],u=Il(this._cameraMotionStates[c],l.camera.position,l.camera.direction,i);this._cameraMotionStates[c]=u.state,l.camera.timeSinceMovement=u.timeSinceMovement,Fl(h,this.modelMatrix),l.dynamicScreenSpaceErrorDensity=this.type===le.TILES3D&&this.options.dynamicScreenSpaceError&&!l.viewport.orthographic?Bl(h,l,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=l.dynamicScreenSpaceErrorDensity,this._traverser.traverse(h,l,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(o=Math.min(o,Math.max(this.options.foveatedTimeDelay-u.timeSinceMovement,0)))}Number.isFinite(o)?this._scheduleDeferredTraversal(o):this._clearDeferredTraversal()}_scheduleDeferredTraversal(e){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(r=>{let n=r instanceof Error?r:new Error(String(r));this._onTilesetError(n)})},Math.max(e*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],i=Object.values(this._traverser.selectedTiles),[o,s]=Nl(i,e,this.options.maximumTilesSelected);n.selectedTiles=o;for(let a of s)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let o in this.frameStateData){let s=this.frameStateData[o];this.selectedTiles=this.selectedTiles.concat(s.selectedTiles),this._requestedTiles=this._requestedTiles.concat(s._requestedTiles),this._emptyTiles=this._emptyTiles.concat(s._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles),n=this.selectedTiles.some(o=>!o.tileDrawn),i=0;if(n){let o=new Set(Object.keys(this.frameStateData).map(a=>this.roots[a])),s=new Map;for(let a of this.selectedTiles)for(let c=a.parent;c;c=c.parent)s.set(c,(s.get(c)??!0)&&a.tileDrawn);for(let a of e)a.tileDrawn&&this._heldTiles.add(a);for(let a of this._heldTiles){let c=a;for(;c.parent;)c=c.parent;if(!o.has(c)){this._heldTiles.delete(a);continue}r.has(a)||(a.contentAvailable&&!this._hasDrawnReplacement(a,r,s)?(a._selectedFrame=this._frameNumber,this.selectedTiles.push(a),i++):this._heldTiles.delete(a))}}else this._heldTiles=r;i>0&&setTimeout(()=>{this.selectTiles()},0);for(let o of this.selectedTiles)this._tiles[o.id]=o;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_hasDrawnReplacement(e,r,n){for(let i=e.parent;i;i=i.parent)if(r.has(i))return i.tileDrawn;return n.get(e)===!0}_tilesChanged(e,r){if(e.length!==r.length)return!0;let n=new Set(e.map(s=>s.id)),i=new Set(r.map(s=>s.id)),o=e.some(s=>!i.has(s.id));return o=o||r.some(s=>!n.has(s.id)),o}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let e=0,r=0;for(let n of this.selectedTiles)if(n.contentAvailable&&n.content){e++;let i=n.contents.length?n.contents:[n.content];for(let o of i)o.pointCount?r+=o.pointCount:r+=o.vertexCount||0}this.stats.get(Ql).count=this.selectedTiles.length,this.stats.get(Jl).count=e,this.stats.get(nh).count=r,this.stats.get(ih).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let e=this.source.initialize(),r=this._getSourceMetadata();r&&this._syncSourceState(r),r?.tileset?.root&&typeof r.tileset.root.then!="function"&&(!this.source.prepareTileset||this.spatialReference?.status==="native")&&(this.root=this._initializeTileHeaders(r.tileset,null),this._applyViewState()),await e;let n=this.source.getMetadata();this._syncSourceState(n),await this.source.prepareTileset?.(this),this.root||(this.root=this._initializeTileHeaders(n.tileset,null)),this._applyViewState()}catch(e){let r=e instanceof Error?e:new Error(String(e));throw this._onSourceError(r,this.root),this._onTilesetError(r),r}}_initializeStats(){this.stats.get(Ko),this.stats.get(Qo),this.stats.get(Zo),this.stats.get(Ql),this.stats.get(Jl),this.stats.get(eh),this.stats.get(th),this.stats.get(rh),this.stats.get(nh),this.stats.get(Jo,"memory"),this.stats.get(ih)}_initializeTileHeaders(e,r){return this.source.initializeTileHeaders(this,e,r)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r=null;try{this._onStartTileLoading(),r=await e.loadContent()}catch(n){let i=n instanceof Error?n:new Error("load failed");this._onSourceError(i,e),this._onTileLoadError(e,i)}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}async _loadTileChildren(e,r){try{this._onStartTileLoading(),await e.loadChildren(r)}catch(n){let i=n instanceof Error?n:new Error("subtree load failed");this._onSourceError(i,e),this._onTileLoadError(e,i)}finally{this._onEndTileLoading()}}_onTileLoadError(e,r){this.stats.get(rh).incrementCount();let n=r.message||r.toString(),i=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,i)}_onSourceError(e,r=null){this.options.onSourceError(e,this.source,r)}_onTilesetError(e){this.options.onTilesetError(e,this)}_onTileLoad(e,r){if(!r?.loaded)return;e.content&&Jn(e,e.content),this.source.onTileLoaded?.(this,e,r),this._syncSourceState(this.source.getMetadata());let n=this.source.getTilesTotalCount?.();n&&(this.stats.get(Ko).reset(),this.stats.get(Ko).addCount(n)),this._addTileToCache(e),this.options.onTileLoad(e)}_onStartTileLoading(){this._pendingCount++,this.stats.get(Qo).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Qo).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(eh).incrementCount(),this.stats.get(Zo).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(Jo).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(Zo).decrementCount(),this.stats.get(th).incrementCount(),this.stats.get(Jo).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let n of r.children)e.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,n=[r];for(;n.length>0;){e=n.pop();for(let i of e.children)n.push(i);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_syncSourceState(e){this.tileset=e.tileset,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset;let r=e.tileset;this.schema=r.schema||null,this.schemaUri=r.schemaUri||null,this.groups=r.groups||[],this.metadata=r.metadata||null,this.statistics=r.statistics??null;let n=It(e.spatialReference,this.options.spatial);this.spatialReference=R1(this.spatialReference,n),this.properties=this.source.properties??this.properties,this.extras=this.source.extras??this.extras,this.options.attributions?.length?this.credits={attributions:this.options.attributions}:this.credits=this.source.credits||this.credits}_applyViewState(){let e=this.source.getViewState(this.root);this.asset=e.asset||this.source.asset||{},this.properties=e.properties??this.source.properties,this.extras=e.extras??this.source.extras??null,this.credits=e.credits||this.source.credits||this.credits||{attributions:this.options.attributions||[]},this.description=e.description||this.options.description||"",this.boundingVolume=e.boundingVolume||this.root?.boundingVolume||null,this.cartographicCenter=e.cartographicCenter||new M,this.cartesianCenter=e.cartesianCenter||null,this.zoom=e.zoom||1,this.geometricError=this.tileset?.geometricError||0}_getSourceMetadata(){try{return this.source.getMetadata()}catch{return null}}};function R1(t,e){return t?.status==="transformed"&&t.sourceCrs===e.sourceCrs&&t.targetCrs===e.targetCrs&&t.targetHeightReference===e.targetHeightReference&&t.outputCoordinates===e.outputCoordinates?t:e}function ah(t){let e=t.selectedTiles.slice(),r=t.requestedTiles.slice(),n=t.emptyTiles.slice(),i=c=>c.map(l=>String(l.id)).sort(),o=c=>{let l=t.stats.get(c).count;return typeof l=="number"&&Number.isFinite(l)?l:0},a=t.source.getImplicitTilingStats?.();return{frameNumber:t.frameNumber,selectedTileIds:i(e),requestedTileIds:i(r),emptyTileIds:i(n),visibleTileCount:e.length,renderableTileCount:e.filter(c=>c.contentAvailable&&!!c.content).length,loadingTileCount:o("Tiles Loading"),loadedTileCount:o("Tiles Loaded"),failedTileCount:o("Failed Tile Loads"),cachedTileCount:o("Tiles In Memory"),cacheBytes:t.gpuMemoryUsageInBytes,maximumScreenSpaceError:t.memoryAdjustedScreenSpaceError,...a?{implicitTiling:a}:{}}}async function*ch(t,e={}){if(await t.tilesetInitializationPromise,ci(e.signal),!t.root)throw new Error("Tileset initialization completed without a root tile");let r=[t.root],n=new Set;for(;r.length>0;){ci(e.signal);let i=r.pop();if(n.has(i))continue;if(n.add(i),i.header.implicitSubtree&&i.childrenState!=="ready"){let s=t.source.loadTileChildrenForTraversal;if(!s)throw new Error("Tileset source does not support camera-independent subtree loading");if(!(await s.call(t.source,i,e.signal)).loaded)throw new Error(`Unable to load implicit subtree for tile ${i.id}`);i.childrenState="ready"}if(t.type===le.I3S&&t.source.loadTileChildrenForTraversal&&!(await t.source.loadTileChildrenForTraversal(i,e.signal)).loaded)throw new Error(`Unable to load I3S child nodes for tile ${i.id}`);ci(e.signal);let o=i.contentUrls.length>0&&!i.content;try{if(o){let s=await i.loadContentForTraversal();if(ci(e.signal),!s.loaded)throw new Error(`Unable to load tile content for tile ${i.id}`);t.source.onTileLoaded?.(t,i,s)}yield{tile:i,contents:i.contentEntries}}finally{e.unloadContent&&o&&i.unloadContent()}for(let s=i.children.length-1;s>=0;s--)r.push(i.children[s])}}function ci(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted","AbortError")}var hi=class{sourceUrl;options;archivePromise;constructor(e){this.options=e,this.sourceUrl=C1(e.data,e.fallbackFilename)}async loadRoot(e,r,n){let i=this.options.rootPath?`${li(this.sourceUrl)}/${this.options.rootPath}`:e;return await this.parseArchiveResource(i,this.options.rootPath,r,n,this.options.rootMode)}async loadResource(e,r,n){let i=this.resolveArchivePath(e,e);return await this.parseArchiveResource(e,i,r,n)}async parseArchiveResource(e,r,n,i,o){let s=this.options.getCoreApi();if(!s)throw new Error(this.options.missingCoreApiMessage);let a=await this.loadFile(r,o),c=this.createArchiveFetch(e);return await s.parse(a,n,{...i,fetch:c},{url:e,fetch:c,_parse:s.parse,loaders:[n],coreApi:s})}createArchiveFetch(e){return async r=>{let n=typeof r=="string"?r:r instanceof URL?r.toString():r.url,i=this.resolveArchivePath(n,e),o=await this.loadFile(i);return new Response(o,{status:200})}}async loadFile(e,r){this.archivePromise||=this.openArchiveReadableFile().then(i=>this.options.parseArchive(i));let n=await this.archivePromise;return await this.options.getFile(n,e,r)}async openArchiveReadableFile(){let{data:e}=this.options;if(typeof e!="string")return new Xt(e);if(/^https?:\/\//i.test(e))return new Ar(e);let r=this.options.getCoreApi();if(!r)throw new Error(this.options.missingCoreApiMessage);let n=await r.fetchFile(e);return new Xt(await n.arrayBuffer())}resolveArchivePath(e,r){let n=li(e),i=li(this.sourceUrl),o=li(r),s=o===i?i:Ce.dirname(o),a=new RegExp(`\\.${this.options.archiveExtension}/(.*)$`,"i"),c=n.match(a);if(c?.[1])return c[1];let l=/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith("/"),h=n.startsWith(i)?n:o===i&&!l?`${i}/${n}`:/^[a-z][a-z0-9+.-]*:\/\//i.test(o)?new URL(n,o).href:Ce.resolve(s,n);return h===i?"":h.startsWith(`${i}/`)?h.slice(i.length+1):h.replace(/^\/+/,"")}};function C1(t,e){return typeof t=="string"?t:`memory://${"name"in t&&typeof t.name=="string"&&t.name?t.name:e}`}function li(t){return t.split(/[?#]/,1)[0]}function ui(t){let e=[],r=new Set,n=i=>{if(!i||typeof i!="object"||r.has(i))return;r.add(i);let o=i,s=o.extensions?.EXT_mesh_features?.featureIds;if(Array.isArray(s))for(let a of s){if(!a||typeof a!="object")continue;let c=a.texture?"texture":a.implicit?"implicit":a.attribute!==void 0?"attribute":a.propertyTable!==void 0?"property-table":"constant";e.push({source:c,attribute:a.attribute,propertyTable:a.propertyTable,constant:a.constant,texture:a.texture,implicit:a.implicit,values:a.values,details:a})}for(let a of Object.values(o))n(a)};return n(t),e}function uh(t){return t!=null}var pe=new M,fi=new M,lh=new z;function er(t,e,r,n=e){if(Ye(t,"3D Tile: boundingVolume must be defined"),t.box){let i=t.s2VolumeInfo?lh:e;return hh(t.box,i,r)}if(t.region){let i=br(t.region),o=e.equals(n)?lh:e.clone().multiplyRight(n.clone().invert());return hh([...i.center,...i.halfAxes],o,r)}if(t.sphere)return A1(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function fh(t,e,r=!1){if(t.box||t.region&&r)return I1(e);if(t.region){let[n,i,o,s,a,c]=t.region;return[[ye(n),ye(i),a],[ye(o),ye(s),c]]}if(t.sphere)return N1(e);throw new Error("Unkown boundingVolume type")}function hh(t,e,r){let n=new M(t[0],t[1],t[2]);e.transform(n,n);let i=[];if(t.length===10){let l=t.slice(3,6),h=new De;h.fromArray(t,6);let u=new M([1,0,0]),f=new M([0,1,0]),d=new M([0,0,1]);u.transformByQuaternion(h),u.scale(l[0]),f.transformByQuaternion(h),f.scale(l[1]),d.transformByQuaternion(h),d.scale(l[2]),i=[...u.toArray(),...f.toArray(),...d.toArray()]}else i=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let o=e.transformAsVector(i.slice(0,3)),s=e.transformAsVector(i.slice(3,6)),a=e.transformAsVector(i.slice(6,9)),c=new $([o[0],o[1],o[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return uh(r)?(r.center=n,r.halfAxes=c,r):new et(n,c)}function A1(t,e,r){let n=new M(t[0],t[1],t[2]);e.transform(n,n);let i=e.getScale(fi),o=Math.max(Math.max(i[0],i[1]),i[2]),s=t[3]*o;return uh(r)?(r.center=n,r.radius=s,r):new me(n,s)}function I1(t){let e=dh(),{halfAxes:r}=t,n=new M(r.getColumn(0)),i=new M(r.getColumn(1)),o=new M(r.getColumn(2));for(let s=0;s<2;s++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)pe.copy(t.center),pe.add(n),pe.add(i),pe.add(o),mh(e,pe),o.negate();i.negate()}n.negate()}return e}function N1(t){let e=dh(),{center:r,radius:n}=t,i=L.WGS84.scaleToGeodeticSurface(r,pe),o;i?o=L.WGS84.geodeticSurfaceNormal(i):o=new M(0,0,1);let s=new M(o[2],-o[1],0);s.len()>0?s.normalize():s=new M(0,1,0);let a=s.clone().cross(o);for(let c of[s,a,o]){fi.copy(c).scale(n);for(let l=0;l<2;l++)pe.copy(r),pe.add(fi),mh(e,pe),fi.negate()}return e}function dh(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function mh(t,e){L.WGS84.cartesianToCartographic(e,pe),t[0][0]=Math.min(t[0][0],pe[0]),t[0][1]=Math.min(t[0][1],pe[1]),t[0][2]=Math.min(t[0][2],pe[2]),t[1][0]=Math.max(t[1][0],pe[0]),t[1][1]=Math.max(t[1][1],pe[1]),t[1][2]=Math.max(t[1][2],pe[2])}var es=new M,ph=new M,xt=new M,gh=new M,O1=new M,ts=new z,Mh=new z;function di(t,e){if(t.lodMetricValue===0||Number.isNaN(t.lodMetricValue))return"DIG";let r=2*rs(t,e);if(r<2)return"OUT";if(!t.header.children)return"DRAW";switch(t.lodMetricType){case"screenSpaceRelative":{let n=e.topDownViewport.height||1;return r/n<=t.lodMetricValue?"DRAW":"DIG"}case"distanceRangeFromDefaultCamera":return t.distanceToTile(e)>=t.lodMetricValue?"DRAW":"DIG";case"maxScreenThresholdSQ":{let n=Math.sqrt(t.lodMetricValue/(Math.PI*.25));return r<=n?"DRAW":"DIG"}default:return r<=t.lodMetricValue?"DRAW":"DIG"}}function rs(t,e){let{topDownViewport:r}=e,n=t.header.i3sLodMbs||t.header.mbs,i=n[1],o=n[0],s=n[2],a=n[3],c=[...t.boundingVolume.center],l=r.unprojectPosition(r.cameraPosition);L.WGS84.cartographicToCartesian(l,es),ph.copy(es).subtract(c).normalize(),L.WGS84.eastNorthUpToFixedFrame(c,ts),Mh.copy(ts).invert(),xt.copy(es).transform(Mh);let h=Math.sqrt(xt[0]*xt[0]+xt[1]*xt[1]),u=h*h/xt[2];gh.copy([xt[0],xt[1],u]);let d=gh.transform(ts).subtract(c).normalize(),p=ph.cross(d).normalize().scale(a).add(c),g=L.WGS84.cartesianToCartographic(p),y=r.project([o,i,s]),x=r.project(g);return O1.copy(y).subtract(x).magnitude()}var qr=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return Ye(e<this._array.length),this._array[e]}set(e,r){Ye(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){Ye(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){Ye(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var L1={loadSiblings:!1,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},rt=class{options;disableSkipLevelOfDetail=!1;root=null;selectedTiles={};requestedTiles={};deferredTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new qr;_emptyTraversalStack=new qr;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...L1,...e}}isSkipLevelOfDetailEnabled(){return this.options.skipLevelOfDetail&&!this.disableSkipLevelOfDetail}traverse(e,r,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.deferredTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){let i=n.pop(),o=!1;this.canTraverse(i,r)&&(this.updateChildTiles(i,r),o=this.updateAndPushChildren(i,r,n,i.hasRenderContent?i._selectionDepth+1:i._selectionDepth));let s=i.parent,a=!!(!s||s._shouldRefine),c=!o;i.hasRenderContent?i.refine===ne.ADD?(this.loadTile(i,r),this.selectTile(i,r)):i.refine===ne.REPLACE&&(this.loadTile(i,r),(c||this.isSkipLevelOfDetailEnabled())&&this.selectTile(i,r)):(this.emptyTiles[i.id]=i,this.loadTile(i,r),c&&this.selectTile(i,r)),this.touchTile(i,r),i._shouldRefine=o&&a}this.completeTraversal(r)}completeTraversal(e){let r=new Date().getTime();(this.traversalFinished(e)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(e))}updateChildTiles(e,r){let n=e.children;for(let i of n)this.updateTile(i,r)}updateAndPushChildren(e,r,n,i){let{loadSiblings:o}=this.options,s=this.isSkipLevelOfDetailEnabled(),a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===ne.REPLACE&&e.hasRenderContent&&!s,l=!1,h=!0;for(let u of a)if(u._selectionDepth=i,u.isVisibleAndInRequestVolume?(n.find(u)&&n.delete(u),n.push(u),l=!0):(c||o)&&u._inRequestVolume&&(this.loadTile(u,r),this.touchTile(u,r)),c){let f;u._inRequestVolume?u.hasRenderContent?f=u.contentAvailable:f=this.executeEmptyTraversal(u,r):f=!1,h=h&&f}return l||(h=!1),h}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e,r)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){if(this.shouldLoadTile(e)){if(this.shouldDeferTileRequest(e)){this.deferredTiles[e.id]=e;return}e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e}}shouldDeferTileRequest(e){return e.priorityDeferred}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e,r){return e.contentAvailable&&e.contentVisibility(r)!=="outside"}shouldRefine(e,r,n=!1){let i=e._screenSpaceError;return n&&(i=e.getScreenSpaceError(r,!0)),i>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let n=[];if(this.options.viewportTraversersMap)for(let i in this.options.viewportTraversersMap)this.options.viewportTraversersMap[i]===r.viewport.id&&n.push(i);else n.push(r.viewport.id);e.updateVisibility(r,n)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let n=!1;for(let i of e.children)i.updateVisibility(r),n=n||i.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,r){let n=!0,i=!1,o=this._emptyTraversalStack;for(o.push(e);o.length>0;){let s=o.pop(),a=!s.hasRenderContent&&this.canTraverse(s,r),c=!s.hasRenderContent&&s.children.length===0;if(s.header.implicitSubtree&&(i=!0,n=!1),!a&&!s.contentAvailable&&!c&&(n=!1),this.updateTile(s,r),s.isVisibleAndInRequestVolume||(this.loadTile(s,r),this.touchTile(s,r)),a){let l=s.children;for(let h of l)o.push(h)}}return e.hasEmptyContent&&!i||n}};var ns=new M;function G1(t,e,r,n,i=[]){let o=t.length?t:[e],s=!1,a=!1;for(let c of o){let l="inside";if(n!==ce.MASK_INSIDE&&(l=r.computeVisibility(c),l==="outside"))continue;let h=!1;for(let u of i)if(c.intersectPlane(u)==="outside"){h=!0;break}h||(s=!0,a=a||l==="intersecting")}return s?a?"intersecting":"inside":"outside"}function yh(t){if(!t||typeof t!="object")return!1;let e=t;return e.shape==="tileset3d"||e.type==="tileset3d"||!!e.tileset}function z1(t){return t!=null}var Ne=class{tileset;header;id;url;parent;refine;type;contentUrl;contentUrls=[];lodMetricType="geometricError";lodMetricValue=0;_unscaledLodMetricValue=0;_scaleGeometricError=!0;boundingVolume=null;content=null;contents=[];contentEntries=[];metadataContext={};featureIdSets=[];vectorContent=null;metadata=null;contentMetadata=[];contentState=he.UNLOADED;gpuMemoryUsageInBytes=0;children=[];childrenState="ready";depth=0;viewportIds=[];transform=new z;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new rt({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_childrenPromise=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_screenSpaceErrorProgressiveResolution=0;_priorityProgressiveResolution=!1;_foveatedFactor=0;priorityDeferred=!1;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_contentBoundingVolumes=[];_contentBoundingVolumeHeaders=[];_viewerRequestVolume;get contentBoundingVolume(){return this._contentBoundingVolume}get contentBoundingVolumes(){return this._contentBoundingVolumes}get viewerRequestVolume(){return this._viewerRequestVolume}_initialTransform=new z;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,r,n,i=""){this.header=r,this.tileset=e,this.id=i||r.id,this.url=r.url,this.parent=n,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this.contentUrls=r.contentUrls||(r.contentUrl?[r.contentUrl]:[]),this._initializeMetadata(r),this.childrenState=r.implicitSubtree?"unloaded":"ready",this._initializeLodMetric(r),this._initializeTransforms(r),this._updateLodMetricScale(),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeContentEntries(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0||!!(this.header.implicitSubtree&&this.childrenState!=="ready")}get hasUnloadedChildren(){return!!(this.header.implicitSubtree&&(this.childrenState==="unloaded"||this.childrenState==="failed"))}get childrenLoading(){return this.childrenState==="loading"}get contentReady(){return this.contentState===he.READY||this.hasEmptyContent}get contentAvailable(){return!!(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===he.UNLOADED}get contentExpired(){return this.contentState===he.EXPIRED}get contentFailed(){return this.contentState===he.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=fh(this.header.boundingVolume,this.boundingVolume,!this.computedTransform.equals(this._initialTransform))),this._boundingBox}getScreenSpaceError(e,r,n=1){switch(this.tileset.type){case le.I3S:return rs(this,e);case le.TILES3D:return Dl(this,e,r,n);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return(this.contents.length?this.contents:[this.content]).reduce((r,n)=>r+(n?.gpuMemoryUsageInBytes||n?.byteLength||0),0)}_getPriority(){return this._calculateRequestPriority(!1)}_getChildrenPriority(){return this._calculateRequestPriority(!0)}_calculateRequestPriority(e){let r=this.tileset._traverser,n=r.options.skipLevelOfDetail&&!r.disableSkipLevelOfDetail,i=this.refine===ne.ADD||n;if(i&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.priorityDeferred||!e&&this.contentState===he.UNLOADED)return-1;let o=this.parent,a=o&&(!i||this._screenSpaceError===0||o.hasTilesetContent)?o._screenSpaceError:this._screenSpaceError,c=r.root?r.root._screenSpaceError:0,l=Math.max(c-a,0);return Xl({priorityProgressiveResolution:this._priorityProgressiveResolution,foveatedFactor:this._foveatedFactor,reverseScreenSpaceError:l,rootScreenSpaceError:c})}async loadContent(){if(this.hasEmptyContent)return{loaded:!1};if(this.content)return{loaded:!0};this.contentExpired&&(this._expireDate=null),this.contentState=he.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=he.UNLOADED,{loaded:!1};try{return await this._loadContentFromSource()}catch(n){throw this.contentState=he.FAILED,n}finally{r.done()}}async loadContentForTraversal(){if(this.hasEmptyContent)return{loaded:!1};if(this.content)return{loaded:!0,contents:this.contents};this.contentState=he.LOADING;try{return await this._loadContentFromSource()}catch(e){throw this.contentState=he.FAILED,e}}async _loadContentFromSource(){let e=await this.tileset.source.loadTileContent(this);return e.contents&&(this.contents=e.contents,this.content=this.contents[0]||null),this.vectorContent=this.contents.find(r=>!!r?.vectorContent)?.vectorContent||null,this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this.contentState=he.READY,this._onContentLoaded(),this._updateContentEntriesAfterLoad(e),e}async loadChildren(e){if(!this.header.implicitSubtree||this.childrenState==="ready")return{loaded:!1,tileCount:0,childSubtreeCount:0};if(this._childrenPromise)return await this._childrenPromise;if(!this.tileset.source.loadTileChildren)throw new Error("Tileset source does not support lazy tile children");this.childrenState="loading",this._childrenPromise=this._loadChildrenWithScheduler(e);try{return await this._childrenPromise}finally{this._childrenPromise=null}}async _loadChildrenWithScheduler(e){let r=await this.tileset._requestScheduler.scheduleRequest(`${this.id}:implicit-subtree`,this._getChildrenPriority.bind(this));if(!r)return this.childrenState="unloaded",{loaded:!1,tileCount:0,childSubtreeCount:0};try{let n=await this.tileset.source.loadTileChildren(this,e);return this.childrenState=n.loaded?"ready":"unloaded",n}catch(n){throw this.childrenState="failed",n}finally{r.done()}}applyImplicitSubtreeHeader(e){let r=this.header.transform,n=this.header.transformMatrix,i=e.transform!==void 0;this.header={...this.header,...e,transform:i?e.transform:r,transformMatrix:i?e.transformMatrix:n,implicitSubtree:void 0},i&&this._initializeTransforms(this.header),this.refine=this._getRefine(e.refine),this.type=e.type,this.contentUrl=e.contentUrl,this.contentUrls=e.contentUrls||(e.contentUrl?[e.contentUrl]:[]),this._initializeMetadata(this.header),this._initializeLodMetric(e),this._updateLodMetricScale(),this._initializeBoundingVolumes(this.header),this._boundingBox=void 0,this._initializeContent(this.header),this._initializeContentEntries(this.header)}_initializeMetadata(e){this.metadata=e.metadata||null;let r=Array.isArray(e.content)?e.content:[e.content];this.contentMetadata=r.filter(Boolean).map(a=>a.metadata||null);let i=(r.find(Boolean)||{}).group,o=typeof i=="number"?this.tileset.groups?.[i]||null:i||null,s={tileset:this.tileset.metadata||null,group:o,tile:this.metadata,content:this.contentMetadata[0]||null,subtree:e.implicitMetadata||null};this.tileset.groups&&(s.groups=this.tileset.groups),this.metadataContext=s}_updateContentEntriesAfterLoad(e){if(e.contentEntries){this.contentEntries=e.contentEntries.map((r,n)=>({...r,index:n,boundingVolume:r.boundingVolume||this._contentBoundingVolumes[n]||this.boundingVolume,payload:r.payload??this.contents[n]??null,featureIds:r.featureIds?.length?r.featureIds:ui(r.payload??this.contents[n]),renderable:!!(r.renderable!==!1&&(r.payload??this.contents[n])&&!yh(r.payload??this.contents[n]))})),this.featureIdSets=this.contentEntries.flatMap(r=>r.featureIds);return}this.contentEntries=this.contentEntries.map((r,n)=>({...r,payload:this.contents[n]??null,featureIds:ui(this.contents[n]),renderable:!!this.contents[n]&&!yh(this.contents[n])})),this.featureIdSets=this.contentEntries.flatMap(r=>r.featureIds)}getContentEntry(e){return this.contentEntries[e]||null}isContentRenderable(e){return!!this.contentEntries[e]?.renderable}_initializeContentEntries(e){let r=Array.isArray(e.content)?e.content:e.content?[e.content]:[];this.contentEntries=r.map((n,i)=>{let o=n||{};return{index:i,uri:this.contentUrls[i]||o.uri||o.url,group:o.group,type:o.type,payload:null,metadata:o.metadata||null,boundingVolume:this._contentBoundingVolumes[i]||this.boundingVolume,featureIds:this._getFeatureIdSets(o),renderable:!1}})}_getFeatureIdSets(e){return ui(e)}unloadContent(){for(let e of this.contents.length?this.contents:[this.content])e&&e.destroy&&e.destroy();return this.contents=[],this.content=null,this.vectorContent=null,this.contentEntries=this.contentEntries.map(e=>({...e,payload:null,renderable:!1})),this.featureIdSets=this.contentEntries.flatMap(e=>e.featureIds),this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=he.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let n=this.parent,i=n?n._visibilityPlaneMask:ce.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let o=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(o)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._updateRequestPriorityMetrics(e),this._visibilityPlaneMask=this.visibility(e,i),this._visible=this._visibilityPlaneMask!==ce.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}_updateRequestPriorityMetrics(e){if(this.tileset.type!==le.TILES3D){this._screenSpaceErrorProgressiveResolution=this._screenSpaceError,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1;return}let r=this.tileset.options,n=r.progressiveResolutionHeightFraction;if(this._screenSpaceErrorProgressiveResolution=this.getScreenSpaceError(e,!1,n),this._priorityProgressiveResolution=Hl(this._screenSpaceErrorProgressiveResolution,this.parent?._screenSpaceErrorProgressiveResolution,this.tileset.memoryAdjustedScreenSpaceError,n),!r.foveatedScreenSpaceError||e.viewport?.orthographic||!e.camera?.position||!e.camera?.direction){this._foveatedFactor=0,this.priorityDeferred=!1;return}this._foveatedFactor=Wl(this.boundingVolume,e.camera);let i=this.tileset._traverser,o=i.options.skipLevelOfDetail&&!i.disableSkipLevelOfDetail,s=$l({refinement:this.refine,skipLevelOfDetail:o,foveatedScreenSpaceError:r.foveatedScreenSpaceError,foveatedConeSize:r.foveatedConeSize,minimumScreenSpaceErrorRelaxation:r.foveatedMinimumScreenSpaceErrorRelaxation,interpolationCallback:r.foveatedInterpolationCallback,foveatedFactor:this._foveatedFactor,verticalFieldOfView:e.camera.verticalFieldOfView,screenSpaceError:this._screenSpaceError,parentScreenSpaceError:this.parent?._screenSpaceError,maximumScreenSpaceError:this.tileset.memoryAdjustedScreenSpaceError,priorityProgressiveResolution:this._priorityProgressiveResolution});this.priorityDeferred=Yl(s,e.camera.timeSinceMovement,r.foveatedTimeDelay)}visibility(e,r){let{cullingVolume:n}=e,{boundingVolume:i}=this;return n.computeVisibilityWithPlaneMask(i,r)}contentVisibility(e,r){let n=r===void 0?this._contentBoundingVolumes:this._contentBoundingVolumes[r]?[this._contentBoundingVolumes[r]]:[];return G1(n,this.boundingVolume,e.cullingVolume,this._visibilityPlaneMask,e.clippingPlanes)}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return ns.subVectors(r.center,e.position),e.direction.dot(ns)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(z1(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=he.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){this._scaleGeometricError=typeof e._scaleGeometricError=="boolean"?e._scaleGeometricError:this.parent?._scaleGeometricError??!0,"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this._unscaledLodMetricValue=e.lodMetricValue:(this._unscaledLodMetricValue=this.parent?this.parent._unscaledLodMetricValue:this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue")),this.lodMetricValue=this._unscaledLodMetricValue}_initializeTransforms(e){this.transform=e.transform?new z(e.transform):new z;let r=this.parent,n=this.tileset,i=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new z(i).multiplyRight(this.transform);let o=r&&r._initialTransform?r._initialTransform.clone():new z;this._initialTransform=new z(o).multiplyRight(this.transform)}_updateLodMetricScale(){if(this.lodMetricType!==Zt.GEOMETRIC_ERROR||!this._scaleGeometricError){this.lodMetricValue=this._unscaledLodMetricValue;return}let e=this.computedTransform.getScale(ns),r=Math.max(e[0],e[1],e[2]);this.lodMetricValue=this._unscaledLodMetricValue*r}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._contentBoundingVolumeHeaders=[],this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.contents=[],this.hasEmptyContent=!0,this.contentState=he.UNLOADED,this.hasTilesetContent=!1,(e.contentUrl||e.contentUrls?.length)&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._screenSpaceErrorProgressiveResolution=0,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1,this._visibilityPlaneMask=ce.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||ne.REPLACE}_isTileset(){return(this.contents.length?this.contents:[this.content]).some(e=>e?.shape==="tileset3d")}_onContentLoaded(){let e=this.contents.length?this.contents:[this.content];for(let r of e)switch(r&&r.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this._boundingBox=void 0,this.boundingVolume=er(e.boundingVolume,this.computedTransform,this.boundingVolume,this._initialTransform),e.viewerRequestVolume&&(this._viewerRequestVolume=er(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume,this._initialTransform));let r=e.content;r&&(this._contentBoundingVolumeHeaders=Array.isArray(r)?r:[r]);let n=r?Array.isArray(r)?r:[r]:this._contentBoundingVolumeHeaders;this._contentBoundingVolumes=n.length?n.map(i=>i?.boundingVolume?er(i.boundingVolume,this.computedTransform,void 0,this._initialTransform):this.boundingVolume):[this.boundingVolume],this._contentBoundingVolume=this._contentBoundingVolumes[0]||null}_updateTransform(e=new z){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateLodMetricScale(),this._updateBoundingVolume(this.header))}};var mi=class extends rt{pendingImplicitSubtrees=new Map;traversalFinished(e){let r=`${e.viewport.id}:`;for(let[n,i]of this.pendingImplicitSubtrees)if(n.startsWith(r)&&i===e.frameNumber)return!1;return!0}executeTraversal(e,r){if(!this.isSkipLevelOfDetailEnabled()){super.executeTraversal(e,r);return}this.executeSkipTraversal(e,r)}executeSkipTraversal(e,r){let n=[e];for(e._selectionDepth=e.parent?e.parent._selectionDepth:1;n.length>0;){let i=n.pop(),o=!i.parent||i.parent._shouldRefine,s=this.canTraverse(i,r)&&this.updateAndPushSkipChildren(i,r,n)&&o,a=!s&&o;i.hasRenderContent?i.refine===ne.ADD?(this.loadTile(i,r),this.selectDesiredTile(i,r)):i.refine===ne.REPLACE&&(this.isInBaseTraversal(i,r)?(this.loadTile(i,r),a&&this.selectDesiredTile(i,r)):a?(this.loadTile(i,r),this.selectDesiredTile(i,r)):this.hasReachedSkippingThreshold(i,r)&&this.loadTile(i,r)):(this.emptyTiles[i.id]=i,this.loadTile(i,r),a&&(!i.hasEmptyContent||i.hasChildren)&&this.selectDesiredTile(i,r)),this.touchTile(i,r),i._shouldRefine=s}this.completeTraversal(r)}updateAndPushSkipChildren(e,r,n){this.updateChildTiles(e,r),e.children.sort(this.compareDistanceToCamera.bind(this));let i=!1;for(let o of e.children)o._selectionDepth=e.hasRenderContent?e._selectionDepth+1:e._selectionDepth,o.isVisibleAndInRequestVolume?(n.push(o),i=!0):this.options.loadSiblings&&o._inRequestVolume&&(this.loadTile(o,r),this.touchTile(o,r));return i}isInBaseTraversal(e,r){if(this.options.immediatelyLoadDesiredLevelOfDetail)return!1;if(!this.findNearestRequestedOrLoadedAncestor(e,r))return!0;let n=Number.isFinite(this.options.baseScreenSpaceError)?Math.max(this.options.baseScreenSpaceError,0):1024,i=Math.max(n,e.tileset.memoryAdjustedScreenSpaceError);return e._screenSpaceError===0&&e.parent?e.parent._screenSpaceError>i:e._screenSpaceError>i}hasReachedSkippingThreshold(e,r){if(this.options.immediatelyLoadDesiredLevelOfDetail)return!1;if(e._priorityProgressiveResolution&&e._screenSpaceErrorProgressiveResolution<=e.tileset.memoryAdjustedScreenSpaceError&&!!(e.parent&&e.parent._screenSpaceErrorProgressiveResolution>e.tileset.memoryAdjustedScreenSpaceError))return!0;let i=this.findNearestRequestedOrLoadedAncestor(e,r);if(!i)return!1;let o=Number.isFinite(this.options.skipScreenSpaceErrorFactor)&&this.options.skipScreenSpaceErrorFactor>0?this.options.skipScreenSpaceErrorFactor:16,s=Number.isFinite(this.options.skipLevels)?Math.max(Math.floor(this.options.skipLevels),0):1;return e._screenSpaceError<i._screenSpaceError/o&&e.depth>i.depth+s}findNearestRequestedOrLoadedAncestor(e,r){let n=e.parent;for(;n;){if(n.hasRenderContent&&!n.contentFailed&&(!n.hasUnloadedContent||n._requestedFrame===r.frameNumber))return n;n=n.parent}return null}selectDesiredTile(e,r){let n=e;for(;n;){if(this.shouldSelectTile(n,r)){this.selectTile(n,r),n!==e&&this.selectLoadedDescendants(e,r,!0);return}n=n.parent}this.selectLoadedDescendants(e,r)}selectLoadedDescendants(e,r,n=!1){let i=[{tile:e,depth:0}];for(;i.length>0;){let{tile:o,depth:s}=i.pop();for(let a of o.children)this.updateTile(a,r),a.isVisibleAndInRequestVolume&&(this.shouldSelectTile(a,r)&&(!n||a.tileDrawn)?(this.selectTile(a,r),this.touchTile(a,r)):s<1&&i.push({tile:a,depth:s+1}))}}compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateChildTiles(e,r){let n=e.header.implicitSubtree?.coordinates.level===0;if(e.hasUnloadedChildren&&e.isVisibleAndInRequestVolume&&(n||this.shouldRefine(e,r))){let i=`${r.viewport.id}:${e.id}`;this.pendingImplicitSubtrees.has(i)||(this.pendingImplicitSubtrees.set(i,r.frameNumber),e.tileset._loadTileChildren(e,r).finally(()=>{this.handleImplicitSubtreeLoad(e,r,i)}))}super.updateChildTiles(e,r)}handleImplicitSubtreeLoad(e,r,n){this.pendingImplicitSubtrees.delete(n),this._frameNumber===r.frameNumber&&(e.childrenState==="ready"?this.executeTraversal(e,r):this.traversalFinished(r)&&this.options.onTraversalEnd(r))}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let n=e.children.length>0;if(e.hasTilesetContent&&n){let s=e.children[0];this.updateTileVisibility(s,r),e._visible=s._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let i=e.refine===ne.REPLACE,o=e._optimChildrenWithinParent===kl.USE_OPTIMIZATION;if(i&&o&&n&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:n}=e;return!n||n.hasTilesetContent||n.refine!==ne.ADD?!1:!this.shouldRefine(e,r,!0)}};var q1=6378137,F1=6378137,is=6356752314245179e-9,tr=new M;function xh(t,e){if(t instanceof et){let{halfAxes:r}=t,n=B1(r);return Math.log2(is/(n+e[2]))}else if(t instanceof me){let{radius:r}=t;return Math.log2(is/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:n}=t,i=Math.log2(q1/r),o=Math.log2(F1/n);return(i+o)/2}return 1}function os(t,e,r){L.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],tr);let n=Math.sqrt(Math.pow(tr[0]-r[0],2)+Math.pow(tr[1]-r[1],2)+Math.pow(tr[2]-r[2],2));return Math.log2(is/(n+e[2]))}function _h(t,e,r){let[n,i,o,s]=t;return os({xmin:n,xmax:o,ymin:i,ymax:s,zmin:0,zmax:0},e,r)}function B1(t){t.getColumn(0,tr);let e=t.getColumn(1),r=t.getColumn(2);return tr.add(e).add(r).len()}var D1=Object.freeze({meter:1,millimeter:.001,centimeter:.01,decimeter:.1,kilometer:1e3,foot:.3048,yard:.9144,mile:1609.344,"us-foot":.3048006096012192,"us-inch":.0254000508001016,"us-yard":.9144018288036576,"us-mile":1609.3472186944373,"clarke-foot":.3047972654,"clarke-yard":.9143917962,"clarke-link":.201166195164,"sears-yard":.914398414616,"sears-foot":.304799471539,"sears-chain":20.1167651216,"sears-1922-truncated-chain":20.116756,"benoit-1895-b-chain":20.1167824944,"indian-yard":.914398530744,"indian-1937-yard":.91439523,"gold-coast-foot":.304799710181}),k1=Object.freeze({m:"meter",metre:"meter",meters:"meter",metres:"meter",mm:"millimeter",millimetre:"millimeter",millimeters:"millimeter",millimetres:"millimeter",cm:"centimeter",centimetre:"centimeter",centimeters:"centimeter",centimetres:"centimeter",dm:"decimeter",decimetre:"decimeter",decimeters:"decimeter",decimetres:"decimeter",km:"kilometer",kilometre:"kilometer",kilometers:"kilometer",kilometres:"kilometer",ft:"foot",feet:"foot","us-survey-foot":"us-foot","us-survey-feet":"us-foot",yd:"yard",yards:"yard",mi:"mile",miles:"mile"});function Fr(t){if(!t)return;let e=t.trim().toLowerCase().replaceAll("_","-"),r=k1[e]||e;return D1[r]}function wh(t,e){return e!==void 0?Number.isFinite(e)&&e>0?e:void 0:t?Fr(t):1}function pi(t){let e=t.spatialReference||t.fullExtent?.spatialReference,r=H1(e),n=t.heightModelInfo?.vertCRS||$1(e),i=t.heightModelInfo?.heightModel,o=t.heightModelInfo?.heightUnit,s=wh(o,t.ZFactor),a=i==="ellipsoidal"?"ellipsoidal":i==="gravity_related_height"?"orthometric":"unknown",c=Th(e),l=c===void 0?r?Ae(r):"unknown":Ae(`EPSG:${c}`),h=U1(l,o,t.ZFactor),u=[],f=V1(t.elevationInfo?.mode),d=t.elevationInfo?t.elevationInfo.unit||"meter":void 0,m=Fr(d);return s===void 0&&u.push(t.ZFactor!==void 0?`I3S ZFactor ${t.ZFactor} is not a positive finite conversion factor`:`Unsupported I3S vertical unit ${o}`),t.elevationInfo&&m===void 0&&u.push(`Unsupported I3S elevation unit ${d}`),t.elevationInfo?.mode&&!f&&u.push(`Unsupported I3S elevation mode ${t.elevationInfo.mode}`),f&&f!=="absoluteHeight"&&u.push(`I3S elevation mode ${f} requires a terrain or scene elevation provider`),Ie({sourceCrs:r,sourceCrsRepresentation:c!==void 0?"identifier":r?"wkt":void 0,sourceCrsAlternatives:c!==void 0&&e?.wkt?[{definition:e.wkt,representation:"wkt"}]:void 0,verticalCrs:n,units:h,verticalUnitScale:s??Number.NaN,heightReference:a,elevationMode:f,elevationOffset:t.elevationInfo?.offset,elevationUnit:d,elevationUnitScale:t.elevationInfo?.mode&&!f?Number.NaN:m??(t.elevationInfo?Number.NaN:1),coordinateFrame:l,axisOrder:r?"xyz":"unknown",provenance:r?"metadata":"unknown",warnings:u})}function U1(t,e,r){if(t==="geocentric")return["meter","meter","meter"];if(t==="geographic"&&(e||r===void 0))return["degree","degree",e||"meter"]}function V1(t){switch(t){case"absoluteHeight":case"onTheGround":case"relativeToGround":case"relativeToScene":return t;default:return}}function gi(t){let e=j1(t);if(e)return e;let r=Sh(t,"TILESET_CRS_GEOCENTRIC"),n=Sh(t,"TILESET_CRS_COORDINATE_EPOCH"),i=[],o,s="unknown",a;typeof r=="string"&&r.toUpperCase()!=="UNKNOWN"?(o=r,s="metadata",a="explicit"):r!==void 0?(i.push("3D Tiles geocentric CRS is explicitly unknown"),s="metadata",a="unknown"):t.root?.boundingVolume?.region?(o="EPSG:4978",s="format-default",a="default"):t.schemaUri&&!t.schema&&i.push("External 3D Tiles metadata schema must be loaded before CRS semantics can resolve");let c=Eh(n);return n!==void 0&&c===void 0&&i.push("3D Tiles coordinate epoch is not a finite decimal year"),Ie({sourceCrs:o,sourceCrsState:a,sourceCrsRepresentation:o?"identifier":void 0,coordinateEpoch:c,heightReference:o?"ellipsoidal":"unknown",coordinateFrame:o?"geocentric":"unknown",axisOrder:o?"xyz":"unknown",provenance:s,warnings:i})}function j1(t){let e=t.extensions?.EXT_geospatial_crs;if(!e)return;let r=[],n,i,o,s;if(e.format==="wkid"){let h=e.extensions?.EXT_geospatial_crs_wkid;typeof h?.authority=="string"&&Number.isInteger(h.wkid)?(n=`${h.authority}:${h.wkid}`,s="identifier",Number.isInteger(h.vcsWkid)&&(i=`${h.authority}:${h.vcsWkid}`),o=Eh(h.epoch),h.epoch!==void 0&&o===void 0&&r.push("EXT_geospatial_crs_wkid epoch is not a finite decimal year")):r.push("EXT_geospatial_crs_wkid requires string authority and integer wkid")}else if(e.format==="wkt2"){let h=e.extensions?.EXT_geospatial_crs_wkt2;typeof h?.wkt2=="string"&&h.wkt2.trim()?(n=h.wkt2,s="wkt"):r.push("EXT_geospatial_crs_wkt2 requires a nonempty wkt2 string")}else r.push(`Unsupported EXT_geospatial_crs format ${String(e.format)}`);let a=s==="wkt"?Ae(n):$o(n)||"unknown",c=W1(i);i&&!c&&r.push(`Unsupported vertical CRS ${String(i)}; vertical unit and height reference are unknown`);let l=i?c?.unit:"meter";return Ie({sourceCrs:n,sourceCrsState:n?"explicit":"unknown",sourceCrsRepresentation:s,verticalCrs:i,coordinateEpoch:o,units:a==="geocentric"?["meter","meter","meter"]:a==="geographic"&&l?["degree","degree",l]:void 0,verticalUnitScale:i?c?.verticalUnitScale??Number.NaN:1,heightReference:i?c?.heightReference??"unknown":n?"ellipsoidal":"unknown",coordinateFrame:a,axisOrder:n?"xyz":"unknown",provenance:"metadata",warnings:r})}function W1(t){if(typeof t!="string")return;let e=/^EPSG:(\d+)$/i.exec(t);if(e)switch(Number(e[1])){case 5702:case 6360:return{unit:"us-foot",verticalUnitScale:1200/3937,heightReference:"orthometric"};case 5703:return{unit:"meter",verticalUnitScale:1,heightReference:"orthometric"};default:return}}function Eh(t){if(typeof t!="string"&&typeof t!="number"||typeof t=="string"&&!t.trim())return;let e=Number(t);return Number.isFinite(e)?e:void 0}function H1(t){let e=Th(t);return e!==void 0?`EPSG:${e}`:t?.wkt}function $1(t){let e=t?.latestVcsWkid??t?.vcsWkid;return e===void 0?void 0:`EPSG:${e}`}function Th(t){return t?.latestWkid??t?.wkid}function Sh(t,e){let r=t.metadata?.class;if(!r)return;let i=t.schema?.classes?.[r]?.properties,o=t.metadata?.properties;for(let[s,a]of Object.entries(i||{}))if(a.semantic===e)return o?.[s]}var Y1=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;function bh(t){return ArrayBuffer.isView(t)?Y1.call(t):void 0}function ss(t){return bh(t)==="Uint16Array"}var X1=240,K1=[9,-18,-88,0,96,90,0,0,-60,-20,-9,18,8,0,-96,30,0,0,60,-20,9,-88,-18,90,96,0,-20,-60,0,0,186,-42,-42,-150,-96,-150,60,60,60,60,54,162,-78,30,-24,-90,-60,60,-60,60,-9,-32,18,30,24,0,20,-60,0,0,-9,8,18,30,-96,0,-20,60,0,0,54,-78,162,-90,-24,30,60,-60,60,-60,-54,78,78,90,144,90,-60,-60,-60,-60,9,-8,-18,-30,-24,0,20,60,0,0,-9,18,-32,0,24,30,0,0,-60,20,9,-18,-8,0,-24,-30,0,0,60,20],Z1=372,Q1=[0,0,-131,0,138,144,0,0,-102,-31,0,0,7,0,-138,42,0,0,102,-31,62,0,-31,0,0,-62,0,0,0,31,124,0,-62,0,0,-124,0,0,0,62,124,0,-62,0,0,-124,0,0,0,62,62,0,-31,0,0,-62,0,0,0,31,0,0,45,0,-183,-9,0,93,18,0,0,0,216,0,33,87,0,-93,12,-93,0,0,156,0,153,99,0,-93,-12,-93,0,0,-45,0,-3,9,0,93,-18,0,0,0,-55,0,48,42,0,0,-84,31,0,0,-7,0,-48,-42,0,0,84,31],J1=372,eg=[18,-36,-122,0,120,135,0,0,-84,-31,-18,36,-2,0,-120,51,0,0,84,-31,36,-165,-27,93,147,-9,0,-93,18,0,210,45,-111,-93,-57,-192,0,93,12,93,162,141,-75,-93,-129,-180,0,93,-12,93,-36,-21,27,93,39,9,0,-93,-18,0,0,0,62,0,0,31,0,0,0,-31,0,0,124,0,0,62,0,0,0,-62,0,0,124,0,0,62,0,0,0,-62,0,0,62,0,0,31,0,0,0,-31,-18,36,-64,0,66,51,0,0,-102,31,18,-36,2,0,-66,-51,0,0,102,31],tg=12,as=20/2,rg=2,rr=class{constructor(e){this._v00=0,this._v01=0,this._v10=0,this._v11=0,this._t=[],this.options=e,this._ix=this.options._width,this._iy=this.options._height,this._hasUint16Data=ss(e.data)}getHeight(e,r){if(e=Math.abs(e)>90?NaN:e,Number.isNaN(e)||Number.isNaN(r))return NaN;let n=ng(r,360);r=n!==-180?n:180;let i=r*this.options._rlonres,o=-e*this.options._rlatres,s=Math.floor(i),a=Math.min(Math.round((this.options._height-1)/2-1),Math.floor(o));i-=s,o-=a,a+=(this.options._height-1)/2,s+=s<0?this.options._width:s>=this.options._width?-this.options._width:0;let c=0,l=0,h=0,u=0,f=new Array(as);if(s===this._ix&&a===this._iy)this.options.cubic?f=this._t:(c=this._v00,l=this._v01,h=this._v10,u=this._v11);else if(!this.options.cubic)c=this._rawval(s,a),l=this._rawval(s+1,a),h=this._rawval(s,a+1),u=this._rawval(s+1,a+1);else{let m=[this._rawval(s,a-1),this._rawval(s+1,a-1),this._rawval(s-1,a),this._rawval(s,a),this._rawval(s+1,a),this._rawval(s+2,a),this._rawval(s-1,a+1),this._rawval(s,a+1),this._rawval(s+1,a+1),this._rawval(s+2,a+1),this._rawval(s,a+2),this._rawval(s+1,a+2)],p=Q1;a!==0&&(p=a===this.options._height-2?eg:K1);let g=Z1;a!==0&&(g=a===this.options._height-2?J1:X1);for(let y=0;y<as;++y){f[y]=0;for(let x=0;x<tg;++x)f[y]+=m[x]*p[as*x+y];f[y]/=g}}if(!this.options.cubic){let m=(1-i)*c+i*l,p=(1-i)*h+i*u,g=(1-o)*m+o*p,y=this.options._offset+this.options._scale*g;return this._ix=s,this._iy=a,this._v00=c,this._v01=l,this._v10=h,this._v11=u,y}let d=f[0]+i*(f[1]+i*(f[3]+i*f[6]))+o*(f[2]+i*(f[4]+i*f[7])+o*(f[5]+i*f[8]+o*f[9]));return d=this.options._offset+this.options._scale*d,this._ix=s,this._iy=a,this._t=f,d}_rawval(e,r){e<0?e+=this.options._width:e>=this.options._width&&(e-=this.options._width),(r<0||r>=this.options._height)&&(r=r<0?-r:2*(this.options._height-1)-r,e+=(e<this.options._width/2?1:-1)*this.options._width/2);let n=r*this.options._swidth+e;if(this._hasUint16Data)return this.options.data[this.options._datastart+n];let i=this.options._datastart+rg*n,o=this.options.data[i],s=this.options.data[i+1];return o<<8|s}};function ng(t,e){e=Math.abs(e);let r=vh(t,e);return 2*Math.abs(r)===e?r-=vh(t,2*e)-r:2*Math.abs(r)>e&&(r+=r<0?e:-e),r}function vh(t,e){return t-Math.floor(t/e)*e}var ig=10,og=65535;function cs(t,e){let r=sg(t),n=r.next();if(n.done||n.value.line!=="P5")throw new Error("Geoid model file: File not in PGM format");let i=Number.MAX_VALUE,o=0,s=-1,a=-1,c="NONE",l="UNKNOWN",h=0,u=0,f=null,d=null;do{n=r.next();let y=n.value.line;if(y.length)if(y[0]==="#"){let x=y.split(" "),w=x[0],_=x[1];if(w!=="#"||!_)continue;let S=x.length>2?x.slice(2):[];if(_==="Description")c=S.join(" ");else if(_==="DateTime")l=S.join(" ");else if(_==="Offset"){if(!x[2])throw new Error("Geoid model file: Error reading offset");i=parseInt(x[2],10)}else if(_==="Scale"){if(!x[2])throw new Error("Geoid model file: Error reading scale");o=parseFloat(x[2])}else _===(e.cubic?"MaxCubicError":"MaxBilinearError")?isFinite(parseFloat(x[2]))&&(s=parseFloat(x[2])):_===(e.cubic?"RMSCubicError":"RMSBilinearError")&&isFinite(parseFloat(x[2]))&&(a=parseFloat(x[2]))}else{let x=y.split(" ");if(x=x.filter(w=>w!==""),h=parseInt(x[0],10),u=parseInt(x[1],10),!(h&&u))throw new Error("Geoid model file: Error reading raster size");break}}while(!n.done);n=r.next();let m=parseInt(n.value.line,10);if(n.done)throw new Error("Geoid model file: Error reading maxval");if(m!==og)throw new Error("Geoid model file: Incorrect value of maxval");if(f=n.value.offset,d=h,i===Number.MAX_VALUE)throw new Error("Geoid model file: Offset not set");if(o===0)throw new Error("Geoid model file: Scale not set");if(o<0)throw new Error("Geoid model file: Scale must be positive");if(u<2||h<2)throw new Error("Geoid model file: Raster size too small");if(h&1)throw new Error("Geoid model file: Raster width is odd");if(!(u&1))throw new Error("Geoid model file: Raster height is even");let p=h/360,g=(u-1)/180;return new rr({cubic:e.cubic,_width:h,_height:u,_rlonres:p,_rlatres:g,_offset:i,_scale:o,_swidth:d,_datastart:f,_maxerror:s,_rmserror:a,_description:c,_datetime:l,data:t})}function*sg(t){let e=0;do{let r=t.indexOf(ig,e);if(r!==-1){let n=t.subarray(e,r);e=r+1,yield{offset:e,line:Ph(n)}}else{let n=t.subarray(e,t.length);e=t.length,yield{offset:e,line:Ph(n)}}}while(e<t.length);return{offset:e,line:""}}function Ph(t){let e="";for(let r of t)e+=String.fromCharCode(r);return e}var ls=Symbol.for("@math.gl/projection/projection-implementations");function hs(){let t=globalThis;return t[ls]||(t[ls]=new WeakMap),t[ls]}function Rh(t){return"create"in t?t:hs().get(t)?.implementation}function Ch(t){if("create"in t)return Promise.resolve(t);let e=hs().get(t);if(e||(e={load:()=>t.preload()},hs().set(t,e)),e.implementation)return Promise.resolve(e.implementation);let r=e;return r.pending||(r.pending=Promise.resolve().then(r.load).then(n=>{let i=s=>s.toLowerCase().replace(/[\s_-]/g,""),o=new Set([n.name,...n.aliases||[]].map(i));if(typeof n.create!="function"||![t.name,...t.aliases||[]].every(s=>o.has(i(s))))throw new Error("Loaded projection does not match descriptor: "+t.name);return r.implementation=n,n}).catch(n=>{throw r.pending=void 0,n})),r.pending}function Ah(){return{x:0,y:0,z:0}}var _t=class{constructor(){this.point=Ah(),this.points=[this.point],this.active=0}get depth(){return this.active}acquire(){var e;let r=this.active++;return(e=this.points)[r]||(e[r]=Ah()),this.points[r]}release(e){this.active>0&&this.points[this.active-1]===e&&this.active--}};function Ue(t,e){let r=new _t,n=(i,o,s)=>{let a=r.acquire();try{return a.x=i,a.y=o,a.z=0,s(a),[a.x,a.y]}finally{r.release(a)}};return{forward(i,o){return n(i,o,t)},inverse(i,o){return n(i,o,e)},forwardInPlace:t,inverseInPlace:e}}function dt(t,e,r=!1){let n=e?t.inverseInPlace:t.forwardInPlace;if(n)return n.bind(t);if(r){let o=e?t.inverse3D:t.forward3D;return s=>{let a=o.call(t,[s.x,s.y,s.z]);s.x=a[0],s.y=a[1],s.z=a[2]}}let i=e?t.inverse:t.forward;return o=>{let s=i.call(t,o.x,o.y);o.x=s[0],o.y=s[1]}}var Mi=34028234663852886e22;function yi(t,e,r){if(!(Array.isArray(t)||t instanceof Float32Array||t instanceof Float64Array))throw new Error("Scalar input requires a number array, Float32Array or Float64Array");if(!(Array.isArray(e)||e instanceof Float32Array||e instanceof Float64Array)||e.length<r)throw new Error("Scalar output requires a preallocated number array, Float32Array or Float64Array with sufficient capacity");if(t===e||Array.isArray(t)||Array.isArray(e))return;let n=t,i=e,o=typeof SharedArrayBuffer<"u"&&n.buffer instanceof SharedArrayBuffer&&i.buffer instanceof SharedArrayBuffer;if((n.buffer===i.buffer||o)&&n.byteOffset<i.byteOffset+r*i.BYTES_PER_ELEMENT&&i.byteOffset<n.byteOffset+n.byteLength)throw new Error("Scalar input/output views overlap; use the same view for in-place projection")}function Ih(t,e,r,n){if(e instanceof Float32Array){if(Math.abs(r.x)>Mi||Math.abs(r.y)>Mi||n>=3&&Math.abs(r.z)>Mi)throw new Error("Projected coordinate exceeds Float32 range");for(let i=3;i<t.length;i++){let o=t[i];if(Number.isFinite(o)&&Math.abs(o)>Mi)throw new Error("Trailing ordinate exceeds Float32 range")}}for(let i=3;i<t.length;i++)e[i]=t[i];return e[0]=r.x,e[1]=r.y,n>=3&&(e[2]=r.z),e}var Nh,Oh=Symbol.for("@math.gl/projection/TypeScriptCRSError"),Oe=class t extends Error{static[(Nh=Oh,Symbol.hasInstance)](e){return this!==t?Function.prototype[Symbol.hasInstance].call(this,e):e instanceof Error&&e[Oh]===!0}constructor(e,r){super(r),this.reason=e,this[Nh]=!0,this.name="TypeScriptCRSError"}};function D(t){throw new Oe("missing-transform-stage",t)}function Lh(t,e){if(typeof t=="string"||"type"in t)return{definition:t,lossy:!1};let r=t,n="crs"in r?r:void 0,i="crs"in r?r.crs:r;if(i.state!=="explicit"&&i.state!=="default")throw new Oe("unknown-syntax","Cannot transform an "+i.state+" CRS reference");let o=!1;return n?.coordinateEpoch!==void 0&&D("Coordinate epochs require a time-dependent transformation"),n?.vertical&&n.vertical.state!=="absent"&&(e.mode!=="horizontal"&&D("A separately declared vertical CRS requires explicit horizontal extraction"),o=!0),{definition:i.definition,spatialReference:n,lossy:o}}function Gh(t,e){if(!e)return t;if(e.coordinateFrame!=="unknown"&&e.coordinateFrame!==t.kind)throw new Error("SpatialReference coordinate frame disagrees with its CRS");let r=e.coordinateOrder,n=t.kind==="geocentric"?{x:"e",y:"n",z:"u"}:{longitude:"e",lon:"e",latitude:"n",lat:"n",easting:"e",northing:"n",height:"u",altitude:"u",x:"e",y:"n",z:"u"},i;if(r.length&&(i=r.slice(0,3).map(o=>n[o.toLowerCase()]||"?").join(""),i.length===2&&(i+="u"),(i.length!==3||!i.includes("e")||!i.includes("n")||!i.includes("u"))&&D("Unsupported SpatialReference coordinate order"),(r.length>4||r.length>3&&!["m","measure"].includes(r[3]))&&D("Unsupported fourth coordinate component")),e.units?.length){let o={m:1,meter:1,metre:1,meters:1,metres:1,km:1e3,ft:.3048,"us-ft":.3048006096012192,degree:Math.PI/180,degrees:Math.PI/180,radian:1,radians:1,grad:Math.PI/200};for(let s=0;s<Math.min(e.units.length,3);s++){let a=(i||"enu")[s]==="u",c=t.kind==="geocentric"?t.toMeter:a?t.verticalUnit:t.kind==="geographic"?t.angularUnit:t.toMeter;(Math.abs((o[e.units[s]]??NaN)-c)>1e-12||o[e.units[s]]===void 0)&&D("SpatialReference units disagree with its CRS")}}return Object.freeze({...t,storedAxis:i})}var te=Math.PI/180;function G(t,e,r){if(!Object.prototype.hasOwnProperty.call(t,e))return r;let n=t[e];if(typeof n!="string"||!/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i.test(n))throw new Error(`Invalid numeric PROJ parameter: +${e}`);let i=Number(n);if(!Number.isFinite(i))throw new Error(`Invalid numeric PROJ parameter: +${e}`);return i}function Br(t,e){let r=G(t,e,0);if(Math.abs(r)>=90)throw new Error(`+${e} must be between -90 and 90 degrees`);return r*te}function Ve(t){if(Math.abs(t)<=Math.PI)return t;let e=2*Math.PI;return((t+Math.PI)%e+e)%e-Math.PI}var zh={towgs84:"0,0,0",ellipse:"WGS84"},qh={towgs84:"0,0,0",ellipse:"GRS80"},us={wgs84:zh,WGS84:zh,nad83:qh,North_American_Datum_1983:qh},Fh=new WeakMap,Nt=t=>t.toLowerCase().replace(/[\s_-]/g,"");function nr(t){if(!t.datumCatalogs?.length)return us;let e=Fh.get(t);if(e?.catalogs===t.datumCatalogs)return e.definitions;let r=Object.assign(Object.create(null),us),n=new Map(Object.entries(us).map(([i,o])=>[Nt(i),{definition:o,owner:-1}]));return t.datumCatalogs.forEach((i,o)=>{if(!i.name||!i.datums)throw new Error("Invalid datum catalogue plugin");for(let[s,a]of Object.entries(i.datums)){let c=Nt(s);if(!c||c==="none"||!a||["ellipse","towgs84","nadgrids"].some(h=>a[h]!==void 0&&typeof a[h]!="string"))throw new Error("Invalid datum definition: "+s);let l=n.get(c);if(l&&(l.owner!==o||l.definition.ellipse!==a.ellipse||l.definition.towgs84!==a.towgs84||l.definition.nadgrids!==a.nadgrids))throw new Error("Conflicting datum registration: "+s);n.set(c,{definition:a,owner:o}),r[s]=a}}),Fh.set(t,{catalogs:t.datumCatalogs,definitions:r}),r}var ag={MERIT:{a:6378137,rf:298.257,ellipseName:"MERIT 1983"},SGS85:{a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"},GRS80:{a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"},IAU76:{a:6378140,rf:298.257,ellipseName:"IAU 1976"},airy:{a:6377563396e-3,b:635625691e-2,ellipseName:"Airy 1830"},APL4:{a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"},NWL9D:{a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"},mod_airy:{a:6377340189e-3,b:6356034446e-3,ellipseName:"Modified Airy"},andrae:{a:637710443e-2,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"},aust_SA:{a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"},GRS67:{a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"},bessel:{a:6377397155e-3,rf:299.1528128,ellipseName:"Bessel 1841"},bess_nam:{a:6377483865e-3,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"},clrk66:{a:63782064e-1,b:63565838e-1,ellipseName:"Clarke 1866"},clrk80:{a:6378249145e-3,rf:293.4663,ellipseName:"Clarke 1880 mod."},clrk80ign:{a:63782492e-1,b:6356515,rf:293.4660213,ellipseName:"Clarke 1880 (IGN)"},clrk58:{a:6378293645208759e-9,rf:294.2606763692654,ellipseName:"Clarke 1858"},CPM:{a:63757387e-1,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"},delmbr:{a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"},engelis:{a:637813605e-2,rf:298.2566,ellipseName:"Engelis 1985"},evrst30:{a:6377276345e-3,rf:300.8017,ellipseName:"Everest 1830"},evrst48:{a:6377304063e-3,rf:300.8017,ellipseName:"Everest 1948"},evrst56:{a:6377301243e-3,rf:300.8017,ellipseName:"Everest 1956"},evrst69:{a:6377295664e-3,rf:300.8017,ellipseName:"Everest 1969"},evrstSS:{a:6377298556e-3,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"},fschr60:{a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"},fschr60m:{a:6378155,rf:298.3,ellipseName:"Fischer 1960"},fschr68:{a:6378150,rf:298.3,ellipseName:"Fischer 1968"},helmert:{a:6378200,rf:298.3,ellipseName:"Helmert 1906"},hough:{a:6378270,rf:297,ellipseName:"Hough"},intl:{a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"},kaula:{a:6378163,rf:298.24,ellipseName:"Kaula 1961"},lerch:{a:6378139,rf:298.257,ellipseName:"Lerch 1979"},mprts:{a:6397300,rf:191,ellipseName:"Maupertius 1738"},new_intl:{a:63781575e-1,b:63567722e-1,ellipseName:"New International 1967"},plessis:{a:6376523,b:6355863,ellipseName:"Plessis 1817 (France)"},krass:{a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"},SEasia:{a:6378155,b:63567733205e-4,ellipseName:"Southeast Asia"},walbeck:{a:6376896,b:63558348467e-4,ellipseName:"Walbeck"},WGS60:{a:6378165,rf:298.3,ellipseName:"WGS 60"},WGS66:{a:6378145,rf:298.25,ellipseName:"WGS 66"},WGS72:{a:6378135,rf:298.26,ellipseName:"WGS 72"},WGS84:{a:6378137,rf:298.257223563,ellipseName:"WGS 84"},sphere:{a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"}},Bh=ag;var we={};we.greenwich=0;we.lisbon=-9.131906111111;we.paris=2.337229166667;we.bogota=-74.080916666667;we.madrid=-3.687938888889;we.rome=12.452333333333;we.bern=7.439583333333;we.jakarta=106.807719444444;we.ferro=-17.666666666667;we.brussels=4.367975;we.stockholm=18.058277777778;we.athens=23.7163375;we.oslo=10.722916666667;var Dh=we;var kh={mm:{to_meter:.001},cm:{to_meter:.01},ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937},fath:{to_meter:1.8288},kmi:{to_meter:1852},"us-ch":{to_meter:20.1168402336805},"us-mi":{to_meter:1609.34721869444},km:{to_meter:1e3},"ind-ft":{to_meter:.30479841},"ind-yd":{to_meter:.91439523},mi:{to_meter:1609.344},yd:{to_meter:.9144},ch:{to_meter:20.1168},link:{to_meter:.201168},dm:{to_meter:.1},in:{to_meter:.0254},"ind-ch":{to_meter:20.11669506},"us-in":{to_meter:.025400050800101},"us-yd":{to_meter:.914401828803658}};var Uh={WGS84:"+proj=longlat +datum=WGS84","EPSG:4326":"+proj=longlat +datum=WGS84","EPSG:4269":"+proj=longlat +datum=NAD83","EPSG:4978":"+proj=geocent +datum=WGS84","EPSG:4979":"+proj=longlat +datum=WGS84","EPSG:3857":"+proj=merc +a=6378137 +b=6378137 +nadgrids=@null +units=m","EPSG:3785":"EPSG:3857",GOOGLE:"EPSG:3857","EPSG:900913":"EPSG:3857","EPSG:102113":"EPSG:3857"},xi=["proj","datum","ellps","a","b","rf","f","R","units","to_meter","vunits","vto_meter","no_defs","type","title","towgs84","nadgrids","geoidgrids","axis","pm","over","lon_wrap"],$h=["no_defs","over"],nt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Vh=t=>t.toLowerCase().replace(/[\s_-]/g,"");function fs(t,e){let r=Object.keys(t).find(n=>Vh(n)===Vh(e));return r===void 0?void 0:t[r]}function jh(t){if(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(t)){let r=Number(t);if(Number.isFinite(r))return r}if(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?r$/i.test(t)){let r=Number(t.slice(0,-1))/te;if(Number.isFinite(r))return r}let e=/^([+-]?)(\d+(?:\.\d*)?)(?:d(?:(\d+(?:\.\d*)?)'(?:(\d+(?:\.\d*)?)")?)?)?([NSEW])?$/i.exec(t);if(e&&(/d/i.test(t)||e[5])){let r=Number(e[3]||0),n=Number(e[4]||0);if(r<60&&n<60){let i=e[1]==="-"?-1:1,o=/[SW]/i.test(e[5]||"")?-1:1,s=i*o*(Number(e[2])+r/60+n/3600);if(Number.isFinite(s))return s}}throw new Error("Invalid angular parameter: "+t)}function Dr(t,e={}){let r=nr(e),n=Lh(t,e),i=n.definition,o=e.aliases||{},s=new Set;for(;typeof i=="string"&&(nt(o,i)||nt(Uh,i));){if(s.has(i))throw new Error("Circular CRS alias: "+i);s.add(i),i=nt(o,i)?o[i]:Uh[i]}if(typeof i=="string"){let R=/^EPSG:(326|327)(\d{2})$/.exec(i);R&&Number(R[2])>=1&&Number(R[2])<=60&&(i="+proj=utm +datum=WGS84 +zone="+Number(R[2])+(R[1]==="327"?" +south":"")),(i==="EPSG:5041"||i==="EPSG:5042")&&(i="+proj=stere +datum=WGS84 +lat_0="+(i==="EPSG:5041"?90:-90)+" +k_0=0.994 +x_0=2000000 +y_0=2000000")}let a;if(_e(i)==="proj-string"&&typeof i=="string"){let R=Object.create(null);for(let N of Or(i).parameters){if(nt(R,N.name))throw new Error("Duplicate PROJ parameter: +"+N.name);R[N.name]=N.value}a={parameters:R}}else{let R=e.parsers?.find(N=>N.canParse(i));if(!R){let N=["wkt","projjson"].includes(_e(i));throw new Oe(N?"missing-parser":"unknown-syntax","Unsupported CRS definition; register a WKT or PROJJSON parser for structured definitions")}a=R.parse(i,e)}let c={...a.parameters};for(let R of["lon_0","lat_0","lat_1","lat_2","lat_ts","lon_wrap","lon_1","lon_2","lonc","alpha","gamma","tilt","azi","o_alpha","o_lon_c","o_lat_c","o_lon_p","o_lat_p","o_lon_1","o_lat_1","o_lon_2","o_lat_2"])c[R]!==void 0&&(c[R]=String(jh(c[R])));let l=c.proj,h=l?.toLowerCase(),u=h==="geocentric"?"geocent":["longlat","latlong","latlon","lonlat","identity","geocent"].includes(h)?h:l;if(!u)throw new Error("CRS requires +proj");let f=["longlat","latlong","latlon","lonlat"].includes(u)?"geographic":u==="geocent"?"geocentric":u==="identity"?"identity":"projected",d=c.datum,m=d&&d!=="none"?fs(r,d):void 0;d&&d!=="none"&&!m&&D("Unknown datum: "+d+"; register a datumCatalogs plugin");let p=Hh(c,m?.ellipse),g=c.nadgrids??m?.nadgrids,y=g===void 0?void 0:g.split(",").map(R=>{let N=R.startsWith("@"),q=N?R.slice(1):R;if(!q||/\s/.test(q))throw new Error("Invalid datum grid name");return Object.freeze({name:q,optional:N})}),x=c.towgs84??m?.towgs84,w;if(x!==void 0&&(w=x.split(",").map(R=>G({value:R},"value",NaN)),![3,7].includes(w.length)||w.some(R=>!Number.isFinite(R))||w.length===7&&w[6]<=-1e6))throw new Error("+towgs84 requires three or seven finite values and positive scale");d==="none"&&(w=void 0),y&&d!=="none"&&(w=[0,0,0]);let _=g==="@null"||g==="null"?Hh({ellps:"WGS84"}):p,S=c.axis||"enu";if(S.length!==3||!/[ew]/.test(S)||!/[ns]/.test(S)||!/[ud]/.test(S))throw new Error("Invalid axis: "+S);let E=a.angularUnit??te;if(f==="geographic"&&(c.units&&c.units!=="degrees"||nt(c,"to_meter")))throw new Error("Geographic coordinates must use angular units");if(f!=="geographic"&&c.units==="degrees")throw new Error("Linear coordinates require linear units");let v=Wh(c,"units","to_meter"),T=a.verticalUnit??Wh(c,"vunits","vto_meter");if(!(T>0)||!Number.isFinite(T))throw new Error("Invalid vertical unit");if(!(E>0)||!Number.isFinite(E))throw new Error("Invalid angular unit");let I=c.pm,P=I===void 0?0:(fs(Dh,I)??jh(I))*te;return Gh(Object.freeze({kind:f,projection:u,parameters:Object.freeze(c),ellipsoid:p,datum:Object.freeze({ellipsoid:_,towgs84:w&&Object.freeze(w),grids:d==="none"||g==="@null"||g==="null"?void 0:y&&Object.freeze(y)}),angularUnit:E,toMeter:v,verticalUnit:T,primeMeridian:P,axis:S,longitudeWrap:c.lon_wrap===void 0?void 0:Number(c.lon_wrap)*te,lossy:!!(a.lossy||n.lossy)}),n.spatialReference)}function Wh(t,e,r){let n=t[e],i=kh;if(e==="vunits"&&n==="degrees")throw new Error("Height requires linear units");if(n&&!["m","degrees"].includes(n)&&!nt(i,n))throw new Error("Unsupported units: "+n);let o=G(t,r,n&&i[n]?i[n].to_meter:1);if(!(o>0))throw new Error("+"+r+" must be positive");return o}function Hh(t,e){let r=e||t.ellps||"WGS84",n=fs(Bh,r);if(!n)throw new Error("Unsupported ellipsoid: "+r);let i=G(t,"a",n.a),o=G(t,"f",NaN),s=G(t,"rf",Number.isNaN(o)?n.rf||0:o===0?0:1/o),a=G(t,"b",s?i*(1-1/s):nt(t,"f")||nt(t,"rf")||nt(t,"a")?i:n.b||i),c=G(t,"R",0);if(i<=0||a<=0||a>i||s<0||s>0&&s<=1||nt(t,"R")&&c<=0||!Number.isNaN(o)&&(o<0||o>=1))throw new Error("Invalid ellipsoid dimensions");return Object.freeze({semiMajorAxis:c||i,semiMinorAxis:c||a,eccentricitySquared:c?0:1-(a/i)**2})}var ds=Math.PI/(180*3600),_i={ellipsoid:{semiMajorAxis:6378137,semiMinorAxis:6356752314245179e-9,eccentricitySquared:.0066943799901413165},towgs84:[0,0,0]};function Si(t,e){if(Math.abs(t.y)>Math.PI/2)throw new Error("Latitude outside geocentric domain");if(!In(t,e))throw new Error("Geocentric coordinate must be finite")}function Ei(t,e){let r=t.x,n=t.y,i=t.z,{semiMajorAxis:o,semiMinorAxis:s,eccentricitySquared:a}=e;if(r===0&&n===0&&i===0)throw new Error("Geodetic coordinates are undefined at the Earth center");if(a!==0&&Math.abs(r)<1e-12*o&&Math.abs(n)<1e-12*o&&Math.hypot(r,n)<1e-12*o){if(!Number.isFinite(Math.hypot(r,n,i)))throw new Error("Geocentric radius must be finite");t.x=0,t.y=Math.sign(i)*Math.PI/2,t.z=Math.abs(i)-s;return}if(!Nn(t,e))throw Number.isFinite(Math.hypot(r,n,i))?new Error("Geocentric inverse did not converge"):new Error("Geocentric radius must be finite")}function Yh(t,e){let r=t[0],n=t[1],i=t[2],o=(t[3]||0)*ds,s=(t[4]||0)*ds,a=(t[5]||0)*ds,c=1+(t[6]||0)/1e6;return e?l=>{let h=(l.x-r)/c,u=(l.y-n)/c,f=(l.z-i)/c;l.x=h+a*u-s*f,l.y=-a*h+u+o*f,l.z=s*h-o*u+f}:l=>{let h=l.x,u=l.y,f=l.z;l.x=c*(h-a*u+s*f)+r,l.y=c*(a*h+u-o*f)+n,l.z=c*(-s*h+o*u+f)+i}}function wi(t){return!!t.towgs84?.some(e=>e!==0)}function ps(t,e){if(!(!t.towgs84||!e.towgs84)){if(t.grids||e.grids){if(t.grids&&e.grids&&t.ellipsoid.semiMajorAxis===e.ellipsoid.semiMajorAxis&&t.ellipsoid.eccentricitySquared===e.ellipsoid.eccentricitySquared&&t.grids.length===e.grids.length&&t.grids.every((n,i)=>n.name===e.grids[i].name&&n.optional===e.grids[i].optional&&n.grid===e.grids[i].grid))return;let r=ps(t.grids?_i:t,e.grids?_i:e);return n=>{t.grids&&Xh(n,t,!1),r?.(n),e.grids&&Xh(n,e,!0)}}if(wi(t)||wi(e)){let r=ms(t,_i),n=ms(_i,e);return i=>{r?.(i),n?.(i)}}return ms(t,e)}}function ms(t,e){if(!t.towgs84||!e.towgs84)return;let r=t.ellipsoid,n=e.ellipsoid,i=!0;for(let a=0;a<7;a++)(t.towgs84[a]||0)!==(e.towgs84[a]||0)&&(i=!1);if(r.semiMajorAxis===n.semiMajorAxis&&Math.abs(r.eccentricitySquared-n.eccentricitySquared)<=5e-11&&i)return;let o=wi(t)?Yh(t.towgs84,!1):void 0,s=wi(e)?Yh(e.towgs84,!0):void 0;return a=>{Si(a,r),o?.(a),s?.(a),Ei(a,n)}}function Xh(t,e,r){for(let n of e.grids){if(n.name==="null")return;if(!n.grid){if(n.optional)continue;throw new Error("Required datum grid is not registered: "+n.name)}let i=!1;if(n.grid.shiftInPlace)i=n.grid.shiftInPlace(t,r);else{let o=n.grid.shift(t.x,t.y,r);o&&(t.x=o[0],t.y=o[1],i=!0)}if(i){if(!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.y)>Math.PI/2)throw new Error("Datum grid produced a coordinate outside the geographic domain");return}}throw new Error("No datum grid covers coordinate: "+e.grids.map(n=>n.name).join(","))}function Kh(t,e){let r={x:t[0],y:t[1],z:t[2]};return Si(r,e),[r.x,r.y,r.z]}function Zh(t,e){let r={x:t[0],y:t[1],z:t[2]};return Ei(r,e),[r.x,r.y,r.z]}function Qh(t,e={}){if(t===void 0)return;let r=[];for(let n of t.split(",")){let i=n.startsWith("@"),o=i?n.slice(1):n;if(!o||/\s/.test(o))throw new Error("Invalid vertical grid name");if(o==="null"){r.push(null);break}let s=Object.prototype.hasOwnProperty.call(e,o)?e[o]:void 0;if(s){if(typeof s.getOffset!="function")throw new Error("Invalid vertical grid: "+o);r.push(s.getOffset.bind(s))}else i||D("Required vertical grid is not registered: "+o)}return(n,i)=>{for(let o of r){if(!o)return 0;let s=o(n,i);if(s!==void 0){if(!Number.isFinite(s))throw new Error("Vertical grid returned a non-finite offset");return s}}throw new Error("No vertical grid covers this coordinate")}}var kr=class t{static async create(e={}){let r=await Promise.all(Jh(e).map(Ch));return new t({...e,projections:r})}constructor(e={}){this.coordinateScratch=new _t;let r=e.projections||[],n=nu(r);if(r.some(i=>!("create"in i))){let i=Dr(e.from??"WGS84",e),o=Dr(e.to??"WGS84",e);this.lossy=i.lossy||o.lossy,this.deferred={options:{...e,projections:[...r]}}}else{let i=e,o=n,s=eu(i.from??"WGS84",o,i),a=eu(i.to??"WGS84",o,i);this.lossy=s.lossy||a.lossy,this.lossy&&(s.kind==="geocentric"||a.kind==="geocentric")&&D("Horizontal extraction cannot supply ellipsoidal height for geocentric coordinates"),this.lossy&&(s.verticalGrid||a.verticalGrid)&&D("Horizontal extraction cannot be combined with vertical grids"),this.forwardTransform=ru(s,a,!!e.enforceAxis),this.inverseTransform=ru(a,s,!!e.enforceAxis)}this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectTo=this.projectTo.bind(this),this.unprojectTo=this.unprojectTo.bind(this),this.projectToSync=this.projectToSync.bind(this),this.unprojectToSync=this.unprojectToSync.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this),this.projectSync=this.projectSync.bind(this),this.unprojectSync=this.unprojectSync.bind(this),this.projectFlatSync=this.projectFlatSync.bind(this),this.unprojectFlatSync=this.unprojectFlatSync.bind(this)}load(){let e=this.deferred;return e?e.implementation?Promise.resolve(e.implementation):(e.pending||(e.pending=t.create(e.options).then(r=>(e.implementation=r,r)).catch(r=>{throw e.pending=void 0,r})),e.pending):Promise.resolve(this)}loadSync(){let e=this.deferred;if(!e)return this;if(!e.implementation){let r=Jh(e.options).map(n=>{let i=Rh(n);if(!i)throw new Error("Projection is not preloaded: "+n.name+". Call preload() first.");return i});e.implementation=new t({...e.options,projections:r})}return e.implementation}projectSync(e){return this.deferred?this.loadSync().project(e):ir(e,this.forwardTransform,this.coordinateScratch)}unprojectSync(e){return this.deferred?this.loadSync().unproject(e):ir(e,this.inverseTransform,this.coordinateScratch)}projectFlatSync(e,r=2){return this.deferred?this.loadSync().projectFlat(e,r):Ti(e,r,this.forwardTransform,this.coordinateScratch)}unprojectFlatSync(e,r=2){return this.deferred?this.loadSync().unprojectFlat(e,r):Ti(e,r,this.inverseTransform,this.coordinateScratch)}async preload(){await this.load()}project(e){return this.deferred?this.projectLoaded(e,!1):ir(e,this.forwardTransform,this.coordinateScratch)}unproject(e){return this.deferred?this.projectLoaded(e,!0):ir(e,this.inverseTransform,this.coordinateScratch)}projectTo(e,r){return this.deferred?this.projectToLoaded(e,r,!1):this.projectToSync(e,r)}unprojectTo(e,r){return this.deferred?this.projectToLoaded(e,r,!0):this.unprojectToSync(e,r)}projectToSync(e,r){return this.deferred?this.loadSync().projectTo(e,r):(yi(e,r,Math.max(e.length,this.forwardTransform.geocentricOutput?3:2)),ir(e,this.forwardTransform,this.coordinateScratch,r))}unprojectToSync(e,r){return this.deferred?this.loadSync().unprojectTo(e,r):(yi(e,r,Math.max(e.length,this.inverseTransform.geocentricOutput?3:2)),ir(e,this.inverseTransform,this.coordinateScratch,r))}projectToLoaded(e,r,n){yi(e,r,e.length);let i=e.slice();return this.load().then(o=>n?o.unprojectTo(i,r):o.projectTo(i,r))}projectLoaded(e,r){let n=e.slice();return this.load().then(i=>r?i.unproject(n):i.project(n))}projectFlat(e,r=2){return this.deferred?this.load().then(i=>i.projectFlat(e,r)):Ti(e,r,this.forwardTransform,this.coordinateScratch)}unprojectFlat(e,r=2){return this.deferred?this.load().then(i=>i.unprojectFlat(e,r)):Ti(e,r,this.inverseTransform,this.coordinateScratch)}};function Jh(t){let e=nu(t.projections||[]),r=new Set;for(let n of[t.from??"WGS84",t.to??"WGS84"]){let i=Dr(n,t);if(["geographic","identity"].includes(i.kind))continue;let o=e.get(bi(i.projection));if(!o)throw new Oe("missing-plugin","Projection plugin is not registered: "+i.projection);r.add(o)}return[...r]}var bi=t=>t.toLowerCase().replace(/[\s_-]/g,"");function nu(t){let e=new Map;for(let r of t)for(let n of new Set([r.name,...r.aliases||[]].map(bi))){if(!n||["longlat","latlong","latlon","lonlat","identity"].includes(n)||e.has(n))throw new Error("Duplicate or reserved projection plugin: "+n);e.set(n,r)}return e}function eu(t,e,r){let n=Dr(t,r),i=e.get(bi(n.projection));if(!["geographic","identity"].includes(n.kind)&&!i)throw new Oe("missing-plugin","Projection plugin is not registered: "+n.projection);let o=new Set([...xi,...i?.parameters||[]]);for(let d of Object.keys(n.parameters)){if(!o.has(d))throw new Oe("missing-transform-stage","Unsupported PROJ parameter: +"+d);let m=$h.includes(d)||i?.flags?.includes(d);if(m&&n.parameters[d]!==void 0)throw new Error("Expected a flag without a value: +"+d);if(!m&&!n.parameters[d])throw new Error("PROJ parameter requires a value: +"+d)}if(n.parameters.type&&n.parameters.type!=="crs")throw new Error("Only +type=crs is supported");let s=bi(n.projection)==="fasttransversemercator"?Object.freeze({...n.parameters,approx:void 0}):n.parameters,a=i?.create({...n.ellipsoid,parameters:s});if(n.kind==="geocentric"&&(!a?.forward3D||!a?.inverse3D))throw new Error("Geocentric plugin must implement 3D operations");let c=n.datum.grids,l=c?.findIndex(d=>d.name==="null")??-1,h=c?.slice(0,l<0?void 0:l+1).map(d=>{let m=Object.prototype.hasOwnProperty.call(r.datumGrids||{},d.name)?r.datumGrids[d.name]:void 0;if(m&&typeof m.shift!="function")throw new Error("Invalid prepared datum grid: "+d.name);return Object.freeze({...d,grid:m})});for(let d of h||[]){if(d.name==="null")break;!d.optional&&!d.grid&&D("Required datum grid is not registered: "+d.name)}let u=h?Object.freeze({...n.datum,grids:Object.freeze(h)}):n.datum,f=Qh(n.parameters.geoidgrids,r.verticalGrids);return f&&(n.kind==="geocentric"||n.kind==="identity"||n.lossy)&&D("Vertical grids require a non-lossy geographic or projected CRS"),{...n,datum:u,implementation:a,verticalGrid:f}}function gs(t){return Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.z)}function tu(t,e){if(t==="enu")return;let r=[0,0,0],n=[0,0,0];for(let i=0;i<3;i++){let o=t[i],s="ew".includes(o)?0:"ns".includes(o)?1:2;r[e?i:s]=e?s:i,n[e?i:s]="wsd".includes(o)?-1:1}return i=>{let o=i.x,s=i.y,a=i.z;i.x=n[0]*(r[0]===0?o:r[0]===1?s:a),i.y=n[1]*(r[1]===0?o:r[1]===1?s:a),i.z=n[2]*(r[2]===0?o:r[2]===1?s:a)}}function ru(t,e,r){let n=t.storedAxis||(r?t.axis:"enu"),i=e.storedAxis||(r?e.axis:"enu"),o=tu(n,!1),s=tu(i,!0),a=t.implementation&&dt(t.implementation,!0,t.kind==="geocentric"),c=e.implementation&&dt(e.implementation,!1,e.kind==="geocentric"),l=ps(t.datum,e.datum),h=t.lossy||e.lossy,u=t.kind==="geocentric",f=t.kind==="geographic"?t.angularUnit:t.toMeter,d=e.kind==="geographic"?e.angularUnit:e.toMeter,m=u?1:t.verticalUnit,p=e.kind==="geocentric"?d:e.verticalUnit,g=t.primeMeridian,y=e.primeMeridian,x=e.kind==="geographic"?e.longitudeWrap:void 0,w;if(!l&&!t.verticalGrid&&!e.verticalGrid&&!h&&!o&&!s&&!g&&!y&&t.verticalUnit===1&&e.verticalUnit===1&&x===void 0){let _=Object.freeze({inputScale:f,outputScale:d});t.kind==="geographic"&&e.kind==="projected"&&(w=e.implementation?.createForwardFlat?.(_)),t.kind==="projected"&&e.kind==="geographic"&&(w=t.implementation?.createInverseFlat?.(_))}return{flat:w,requiresInputZ:!!(t.verticalGrid||e.verticalGrid)||t.kind==="geocentric"||/[ud]/.test(n.slice(0,2))||/[ud]/.test(i.slice(0,2)),geocentricOutput:e.kind==="geocentric",run(_){if(!gs(_))throw new Error("Coordinates must contain finite x, y and optional z values");o?.(_);let S=_.z;if(h&&(_.z=0),f!==1&&(_.x*=f,_.y*=f,u&&(_.z*=f)),a?.(_),m!==1&&(_.z*=m),Math.abs(_.y)>Math.PI/2||!gs(_))throw new Error("Coordinate is outside the geographic domain");if(_.x+=g,t.verticalGrid&&(_.z+=t.verticalGrid(_.x,_.y)),l?.(_),e.verticalGrid&&(_.z-=e.verticalGrid(_.x,_.y)),_.x-=y,x!==void 0&&(_.x=x+Ve(_.x-x)),c?.(_),d!==1&&(_.x/=d,_.y/=d),p!==1&&(_.z/=p),h&&(_.z=S),s?.(_),!gs(_))throw new Error("Projection produced non-finite coordinates")}}}function ir(t,e,r,n){if(t.length<2)throw new Error("Coordinates must contain finite x, y and optional z values");if(t.length<3&&e.requiresInputZ)throw new Error("This transform requires three ordinates");let i=Math.max(t.length,e.geocentricOutput?3:2),o=r.acquire();try{if(o.x=t[0],o.y=t[1],o.z=t.length>=3?t[2]:0,e.run(o),n)return Ih(t,n,o,i);let s=t.slice();return s[0]=o.x,s[1]=o.y,(t.length>=3||e.geocentricOutput)&&(s[2]=o.z),s}finally{r.release(o)}}function Ti(t,e,r,n){if(!(t instanceof Float32Array||t instanceof Float64Array))throw new Error("In-place projection requires a Float32Array or Float64Array");if(!Number.isSafeInteger(e)||e<2||t.length%e!==0)throw new Error("Dimension must be an integer >= 2 and divide the typed array length");if(e<3&&(r.requiresInputZ||r.geocentricOutput))throw new Error("This transform requires a dimension of at least 3");if(r.flat)return r.flat(t,e),t;let i=n.acquire();try{let o=t instanceof Float32Array;for(let s=0;s<t.length;s+=e){if(i.x=t[s],i.y=t[s+1],i.z=e>=3?t[s+2]:0,r.run(i),o&&(Math.abs(i.x)>34028234663852886e22||Math.abs(i.y)>34028234663852886e22||e>=3&&Math.abs(i.z)>34028234663852886e22))throw new Error("Projected coordinate exceeds Float32 range");t[s]=i.x,t[s+1]=i.y,e>=3&&(t[s+2]=i.z)}return t}finally{n.release(i)}}var vi=class{constructor(e={}){this.options=cg(e)}createProjection(e={}){return new kr({...this.options,...e})}async createProjectionAsync(e={}){return kr.create({...this.options,...e})}};function cg(t){return{...t,projections:t.projections&&[...t.projections],parsers:t.parsers&&[...t.parsers],datumCatalogs:t.datumCatalogs&&[...t.datumCatalogs],aliases:t.aliases&&JSON.parse(JSON.stringify(t.aliases)),datumGrids:t.datumGrids&&{...t.datumGrids},verticalGrids:t.verticalGrids&&{...t.verticalGrids}}}function Xe(t,e){return{...Ue(t,e),createForwardFlat(r){return this.forwardInPlace===t?iu(t,!1,r):void 0},createInverseFlat(r){return this.inverseInPlace===e?iu(e,!0,r):void 0}}}function iu(t,e,{inputScale:r,outputScale:n}){let i=new _t;return(o,s)=>{let a=i.acquire();try{let c=o instanceof Float32Array;for(let l=0;l<o.length;l+=s){if(a.x=o[l],a.y=o[l+1],a.z=s>=3?o[l+2]:0,!Number.isFinite(a.x)||!Number.isFinite(a.y)||!Number.isFinite(a.z))throw new Error("Coordinates must contain finite x, y and optional z values");if(r!==1&&(a.x*=r,a.y*=r),e&&t(a),Math.abs(a.y)>Math.PI/2||!Number.isFinite(a.x)||!Number.isFinite(a.y))throw new Error("Coordinate is outside the geographic domain");if(a.x+=0,a.x-=0,e||t(a),n!==1&&(a.x/=n,a.y/=n),!Number.isFinite(a.x)||!Number.isFinite(a.y))throw new Error("Projection produced non-finite coordinates");if(c&&(Math.abs(a.x)>34028234663852886e22||Math.abs(a.y)>34028234663852886e22))throw new Error("Projected coordinate exceeds Float32 range");o[l]=a.x,o[l+1]=a.y}}finally{i.release(a)}}}var Ms={name:"merc",aliases:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","Mercator_Variant_A"],parameters:["lon_0","lat_ts","k","k_0","x_0","y_0"],create({semiMajorAxis:t,eccentricitySquared:e,parameters:r}){let n=Math.sqrt(e),i=Object.prototype.hasOwnProperty.call(r,"over")?h=>h:Ve,o=G(r,"lon_0",0)*te,s=G(r,"x_0",0),a=G(r,"y_0",0),c=G(r,"k_0",G(r,"k",1));if(Object.prototype.hasOwnProperty.call(r,"lat_ts")){let h=Br(r,"lat_ts");c=Math.cos(h)/Math.sqrt(1-e*Math.sin(h)**2)}if(c<=0)throw new Error("Mercator scale must be positive");let l=t*c;return Xe(h=>{let u=h.x,f=h.y;if(Math.abs(f)>=Math.PI/2)throw new Error("Mercator is undefined at the poles");let d=Math.asinh(Math.tan(f));h.x=s+l*i(u-o),h.y=a+l*(n===0?d+0:d-n*Math.atanh(n*Math.sin(f)))},h=>{let u=h.x,d=(h.y-a)/l,m=Math.atan(Math.sinh(d));if(n===0){h.x=i(o+(u-s)/l),h.y=m+0;return}for(let p=0;p<30;p++){let g=Math.atan(Math.sinh(d+n*Math.atanh(n*Math.sin(m))));if(Math.abs(g-m)<1e-13){h.x=i(o+(u-s)/l),h.y=g;return}m=g}throw new Error("Mercator inverse did not converge")})}};var ys={name:"eqc",aliases:["Equirectangular","Equidistant_Cylindrical","Equidistant_Cylindrical_Spherical"],parameters:["lon_0","lat_0","lat_ts","x_0","y_0"],create({semiMajorAxis:t,parameters:e}){let r=Object.prototype.hasOwnProperty.call(e,"over")?c=>c:Ve,n=G(e,"lon_0",0)*te,i=Br(e,"lat_0"),o=Math.cos(Br(e,"lat_ts")),s=G(e,"x_0",0),a=G(e,"y_0",0);return Ue(c=>{c.x=s+t*o*r(c.x-n),c.y=a+t*(c.y-i)},c=>{c.x=r(n+(c.x-s)/(t*o)),c.y=i+(c.y-a)/t})}};var de=["lon_0","lat_0","x_0","y_0"],mt=["k","k_0"];function wt(t,e,r=0){let n=G(t,e,r);if(e!=="lon_0"&&Math.abs(n)>90)throw new Error("Latitude parameter must be between -90 and 90 degrees: +"+e);return n*te}function Ke(t,e){let r=Object.prototype.hasOwnProperty.call(t,e);if(r&&t[e]!==void 0)throw new Error("Expected a flag without a value: +"+e);return r}function ue({semiMajorAxis:t,eccentricitySquared:e,parameters:r}){let n=G(r,"k_0",G(r,"k",1));if(n<=0)throw new Error("Projection scale must be positive");return{a:t,b:t*Math.sqrt(1-e),es:e,e:Math.sqrt(e),ep2:e/(1-e),sphere:e===0,over:Ke(r,"over"),long0:wt(r,"lon_0"),lat0:wt(r,"lat_0"),lat1:wt(r,"lat_1"),lat2:wt(r,"lat_2",G(r,"lat_1",0)),lat_ts:wt(r,"lat_ts",NaN),x0:G(r,"x_0",0),y0:G(r,"y_0",0),k0:n}}function or(t,e){if(!Object.prototype.hasOwnProperty.call(e,"lat_1"))throw new Error("Conic projections require +lat_1");if(Math.abs(t.lat1+t.lat2)<1e-10||Math.abs(t.lat1)>=Math.PI/2||Math.abs(t.lat2)>=Math.PI/2)throw new Error("Conic standard parallels must not be opposite or at a pole")}function se(t,e,r,n,i=Ue){let o=(s,a)=>{let c=s(e,a);if(!c||typeof c!="object"||!Number.isFinite(c.x)||!Number.isFinite(c.y))throw new Error(t+": coordinate outside projection domain or inverse did not converge");a.x=c.x,a.y=c.y};return i(s=>o(r,s),s=>o(n,s))}function St(t,e){let r=dt(e,!1);return Ue(n=>{let i=n.x,o=n.y,s=Math.atan2(Math.sin(i-t.long0),Math.cos(i-t.long0)),a=Math.abs(Math.abs(t.lat0)-Math.PI/2)<1e-10;if(Math.abs(o+t.lat0)<1e-10&&(a||Math.abs(Math.abs(s)-Math.PI)<1e-10))throw new Error("Azimuthal projection is undefined at the antipode");r(n)},dt(e,!0))}function Se(t,e,r){var n=t*e;return r/Math.sqrt(1-n*n)}var b=Math.PI/2,V=Math.PI/4,Et=Math.PI*2,Z=3.14159265359,xs=Math.PI/180,_s=180/Math.PI,ws=Math.PI/(180*3600);function Le(t,e,r){var n=t*r,i=.5*t;return n=Math.pow((1-n)/(1+n),i),Math.tan(.5*(b-e))/n}function it(t){return t<0?-1:1}function C(t,e){return e||Math.abs(t)<=Z?t:t-it(t)*Et}function Ot(t,e){for(var r=.5*t,n,i,o=b-2*Math.atan(e),s=0;s<=15;s++)if(n=t*Math.sin(o),i=b-2*Math.atan(e*Math.pow((1-n)/(1+n),r))-o,o+=i,Math.abs(i)<=1e-10)return o;return-9999}function lg(t){if(t.k0||(t.k0=1),t.x0=t.x0||0,t.y0=t.y0||0,t.long0=t.long0||0,!(Math.abs(t.lat1+t.lat2)<1e-10)){var e=t.b/t.a;t.e=Math.sqrt(1-e*e);var r=Math.sin(t.lat1),n=Math.cos(t.lat1),i=Se(t.e,r,n),o=Le(t.e,t.lat1,r),s=Math.sin(t.lat2),a=Math.cos(t.lat2),c=Se(t.e,s,a),l=Le(t.e,t.lat2,s),h=Le(t.e,t.lat0,Math.sin(t.lat0));Math.abs(t.lat1-t.lat2)>1e-10?t.ns=Math.log(i/c)/Math.log(o/l):t.ns=r,Number.isNaN(t.ns)&&(t.ns=r),t.f0=i/(t.ns*Math.pow(o,t.ns)),t.rh=Math.abs(Math.abs(t.lat0)-b)<1e-10?0:t.a*t.f0*Math.pow(h,t.ns)}}function ou(t,e){var r=e.x,n=e.y;Math.abs(2*Math.abs(n)-Math.PI)<=1e-10&&(n=it(n)*(b-2*1e-10));var i=Math.abs(Math.abs(n)-b),o,s;if(i>1e-10)o=Le(t.e,n,Math.sin(n)),s=t.a*t.f0*Math.pow(o,t.ns);else{if(i=n*t.ns,i<=0)return null;s=0}var a=t.ns*C(r-t.long0,t.over);return e.x=t.k0*(s*Math.sin(a))+t.x0,e.y=t.k0*(t.rh-s*Math.cos(a))+t.y0,e}function su(t,e){var r,n,i,o,s,a=(e.x-t.x0)/t.k0,c=t.rh-(e.y-t.y0)/t.k0;t.ns>0?(r=Math.sqrt(a*a+c*c),n=1):(r=-Math.sqrt(a*a+c*c),n=-1);var l=0;if(r!==0&&(l=Math.atan2(n*a,n*c)),r!==0||t.ns>0){if(n=1/t.ns,i=Math.pow(r/(t.a*t.f0),n),o=Ot(t.e,i),o===-9999)return null}else o=-b;return s=C(l/t.ns+t.long0,t.over),e.x=s,e.y=o,e}function au(t){let e={...t,ns:0,f0:0,rh:0};return lg(e),e}var Ss={name:"lcc",aliases:["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_1SP","Lambert_Conformal_Conic_2SP","Lambert Conic Conformal (1SP)","Lambert Conic Conformal (2SP)"],parameters:[...de,...mt,"lat_1","lat_2"],create(t){let e=ue(t);or(e,t.parameters);let r=au(e),n=se("lcc",r,ou,su);return Xe(i=>{let o=i.y;if(Math.abs(o)===Math.PI/2&&o*r.ns<0)throw new Error("Lambert conformal conic is undefined at the opposite pole");n.forwardInPlace(i)},n.inverseInPlace)}};function Ee(t,e){var r;return t>1e-7?(r=t*e,(1-t*t)*(e/(1-r*r)-.5/t*Math.log((1-r)/(1+r)))):2*e}function Te(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}function hg(t){Math.abs(t.lat1+t.lat2)<1e-10||(t.temp=t.b/t.a,t.es=1-Math.pow(t.temp,2),t.e3=Math.sqrt(t.es),t.sin_po=Math.sin(t.lat1),t.cos_po=Math.cos(t.lat1),t.t1=t.sin_po,t.con=t.sin_po,t.ms1=Se(t.e3,t.sin_po,t.cos_po),t.qs1=Ee(t.e3,t.sin_po),t.sin_po=Math.sin(t.lat2),t.cos_po=Math.cos(t.lat2),t.t2=t.sin_po,t.ms2=Se(t.e3,t.sin_po,t.cos_po),t.qs2=Ee(t.e3,t.sin_po),t.sin_po=Math.sin(t.lat0),t.cos_po=Math.cos(t.lat0),t.t3=t.sin_po,t.qs0=Ee(t.e3,t.sin_po),Math.abs(t.lat1-t.lat2)>1e-10?t.ns0=(t.ms1*t.ms1-t.ms2*t.ms2)/(t.qs2-t.qs1):t.ns0=t.con,t.c=t.ms1*t.ms1+t.ns0*t.qs1,t.rh=t.a*Math.sqrt(t.c-t.ns0*t.qs0)/t.ns0)}function cu(t,e){var r=e.x,n=e.y;t.sin_phi=Math.sin(n),t.cos_phi=Math.cos(n);var i=Ee(t.e3,t.sin_phi),o=t.a*Math.sqrt(t.c-t.ns0*i)/t.ns0,s=t.ns0*C(r-t.long0,t.over),a=o*Math.sin(s)+t.x0,c=t.rh-o*Math.cos(s)+t.y0;return e.x=a,e.y=c,e}function lu(t,e){var r,n,i,o,s,a;return e.x-=t.x0,e.y=t.rh-e.y+t.y0,t.ns0>=0?(r=Math.sqrt(e.x*e.x+e.y*e.y),i=1):(r=-Math.sqrt(e.x*e.x+e.y*e.y),i=-1),o=0,r!==0&&(o=Math.atan2(i*e.x,i*e.y)),i=r*t.ns0/t.a,t.sphere?a=Math.asin((t.c-i*i)/(2*t.ns0)):(n=(t.c-i*i)/t.ns0,a=ug(t.e3,n)),s=C(o/t.ns0+t.long0,t.over),e.x=s,e.y=a,e}function ug(t,e){var r,n,i,o,s,a=Te(.5*e);if(t<1e-10)return a;for(var c=t*t,l=1;l<=25;l++)if(r=Math.sin(a),n=Math.cos(a),i=t*r,o=1-i*i,s=.5*o*o/n*(e/(1-c)-r/o+.5/t*Math.log((1-i)/(1+i))),a=a+s,Math.abs(s)<=1e-7)return a;return null}function hu(t){let e={...t,temp:0,e3:0,sin_po:0,cos_po:0,t1:0,con:0,ms1:0,qs1:0,t2:0,ms2:0,qs2:0,t3:0,qs0:0,ns0:0,c:0,rh:0,sin_phi:0,cos_phi:0};return hg(e),e}var Es={name:"aea",aliases:["Albers_Conic_Equal_Area","Albers_Equal_Area","Albers"],parameters:[...de,"lat_1","lat_2"],create(t){let e=ue(t);return or(e,t.parameters),se("aea",hu(e),cu,lu,Xe)}};var fg=1,dg=.25,uu=.046875,fu=.01953125,du=.01068115234375,mg=.75,pg=.46875,gg=.013020833333333334,Mg=.007120768229166667,yg=.3645833333333333,xg=.005696614583333333,_g=.3076171875;function ot(t){var e=[];e[0]=fg-t*(dg+t*(uu+t*(fu+t*du))),e[1]=t*(mg-t*(uu+t*(fu+t*du)));var r=t*t;return e[2]=r*(pg-t*(gg+t*Mg)),r*=t,e[3]=r*(yg-t*xg),e[4]=r*t*_g,e}function fe(t,e,r,n){return r*=e,e*=e,n[0]*t-r*(n[1]+e*(n[2]+e*(n[3]+e*n[4])))}var wg=20;function st(t,e,r){for(var n=1/(1-e),i=t,o=wg;o;--o){var s=Math.sin(i),a=1-e*s*s;if(a=(fe(i,s,Math.cos(i),r)-t)*(a*Math.sqrt(a))*n,i-=a,Math.abs(a)<1e-10)return i}return i}function Ze(t){return Math.abs(t)<b?t:t-it(t)*Math.PI}function Sg(t){Math.abs(t.lat1+t.lat2)<1e-10||(t.temp=t.b/t.a,t.es=1-Math.pow(t.temp,2),t.e=Math.sqrt(t.es),t.en=ot(t.es),t.sin_phi=Math.sin(t.lat1),t.cos_phi=Math.cos(t.lat1),t.ms1=Se(t.e,t.sin_phi,t.cos_phi),t.ml1=fe(t.lat1,Math.sin(t.lat1),Math.cos(t.lat1),t.en),Math.abs(t.lat1-t.lat2)<1e-10?t.ns=t.sin_phi:(t.sin_phi=Math.sin(t.lat2),t.cos_phi=Math.cos(t.lat2),t.ms2=Se(t.e,t.sin_phi,t.cos_phi),t.ml2=fe(t.lat2,Math.sin(t.lat2),Math.cos(t.lat2),t.en),t.ns=(t.ms1-t.ms2)/(t.ml2-t.ml1)),t.g=t.ml1+t.ms1/t.ns,t.ml0=fe(t.lat0,Math.sin(t.lat0),Math.cos(t.lat0),t.en),t.rh=t.a*(t.g-t.ml0))}function mu(t,e){var r=e.x,n=e.y,i;if(t.sphere)i=t.a*(t.g-n);else{var o=fe(n,Math.sin(n),Math.cos(n),t.en);i=t.a*(t.g-o)}var s=t.ns*C(r-t.long0,t.over),a=t.x0+i*Math.sin(s),c=t.y0+t.rh-i*Math.cos(s);return e.x=a,e.y=c,e}function pu(t,e){e.x-=t.x0,e.y=t.rh-e.y+t.y0;var r,n,i,o;t.ns>=0?(n=Math.sqrt(e.x*e.x+e.y*e.y),r=1):(n=-Math.sqrt(e.x*e.x+e.y*e.y),r=-1);var s=0;if(n!==0&&(s=Math.atan2(r*e.x,r*e.y)),t.sphere)return o=C(t.long0+s/t.ns,t.over),i=Ze(t.g-n/t.a),e.x=o,e.y=i,e;var a=t.g-n/t.a;return i=st(a,t.es,t.en),o=C(t.long0+s/t.ns,t.over),e.x=o,e.y=i,e}function gu(t){let e={...t,temp:0,en:[],sin_phi:0,cos_phi:0,ms1:0,ml1:0,ns:0,ms2:0,ml2:0,g:0,ml0:0,rh:0};return Sg(e),e}var Ts={name:"eqdc",aliases:["Equidistant_Conic"],parameters:[...de,"lat_1","lat_2"],create(t){let e=ue(t);return or(e,t.parameters),se("eqdc",gu(e),mu,pu,Xe)}};var Eg=.3333333333333333,Tg=.17222222222222222,bg=.10257936507936508,vg=.06388888888888888,Pg=.0664021164021164,Rg=.016415012942191543;function Ur(t){var e,r=[];return r[0]=t*Eg,e=t*t,r[0]+=e*Tg,r[1]=e*vg,e*=t,r[0]+=e*bg,r[1]+=e*Pg,r[2]=e*Rg,r}function Vr(t,e){var r=t+t;return t+e[0]*Math.sin(r)+e[1]*Math.sin(r+r)+e[2]*Math.sin(r+r+r)}var at=1,pt=2,je=3,Ge=4;function Cg(t){var e=Math.abs(t.lat0);if(Math.abs(e-b)<1e-10?t.mode=t.lat0<0?at:pt:Math.abs(e)<1e-10?t.mode=je:t.mode=Ge,t.es>0){var r;switch(t.qp=Ee(t.e,1),t.mmf=.5/(1-t.es),t.apa=Ur(t.es),t.mode){case pt:t.dd=1;break;case at:t.dd=1;break;case je:t.rq=Math.sqrt(.5*t.qp),t.dd=1/t.rq,t.xmf=1,t.ymf=.5*t.qp;break;case Ge:t.rq=Math.sqrt(.5*t.qp),r=Math.sin(t.lat0),t.sinb1=Ee(t.e,r)/t.qp,t.cosb1=Math.sqrt(1-t.sinb1*t.sinb1),t.dd=Math.cos(t.lat0)/(Math.sqrt(1-t.es*r*r)*t.rq*t.cosb1),t.xmf=t.rq,t.ymf=t.xmf/t.dd,t.xmf*=t.dd;break}}else t.mode===Ge&&(t.sinph0=Math.sin(t.lat0),t.cosph0=Math.cos(t.lat0))}function Mu(t,e){var r,n,i,o,s,a,c,l,h,u,f=e.x,d=e.y;if(f=C(f-t.long0,t.over),t.sphere){if(s=Math.sin(d),u=Math.cos(d),i=Math.cos(f),t.mode===Ge||t.mode===je){if(n=t.mode===je?1+u*i:1+t.sinph0*s+t.cosph0*u*i,n<=1e-10)return null;n=Math.sqrt(2/n),r=n*u*Math.sin(f),n*=t.mode===je?s:t.cosph0*s-t.sinph0*u*i}else if(t.mode===pt||t.mode===at){if(t.mode===pt&&(i=-i),Math.abs(d+t.lat0)<1e-10)return null;n=V-d*.5,n=2*(t.mode===at?Math.cos(n):Math.sin(n)),r=n*Math.sin(f),n*=i}}else{switch(c=0,l=0,h=0,i=Math.cos(f),o=Math.sin(f),s=Math.sin(d),a=Ee(t.e,s),(t.mode===Ge||t.mode===je)&&(c=a/t.qp,l=Math.sqrt(1-c*c)),t.mode){case Ge:h=1+t.sinb1*c+t.cosb1*l*i;break;case je:h=1+l*i;break;case pt:h=b+d,a=t.qp-a;break;case at:h=d-b,a=t.qp+a;break}if(Math.abs(h)<1e-10)return null;switch(t.mode){case Ge:case je:h=Math.sqrt(2/h),t.mode===Ge?n=t.ymf*h*(t.cosb1*c-t.sinb1*l*i):(h=Math.sqrt(2/(1+l*i)),n=h*c*t.ymf),r=t.xmf*h*l*o;break;case pt:case at:a>=0?(h=Math.sqrt(a),r=h*o,n=i*(t.mode===at?h:-h)):r=n=0;break}}return e.x=t.a*r+t.x0,e.y=t.a*n+t.y0,e}function yu(t,e){e.x-=t.x0,e.y-=t.y0;var r=e.x/t.a,n=e.y/t.a,i,o,s,a,c,l,h;if(t.sphere){var u=0,f,d=0;if(f=Math.sqrt(r*r+n*n),o=f*.5,o>1)return null;switch(o=2*Math.asin(o),(t.mode===Ge||t.mode===je)&&(d=Math.sin(o),u=Math.cos(o)),t.mode){case je:o=Math.abs(f)<=1e-10?0:Math.asin(n*d/f),r*=d,n=u*f;break;case Ge:o=Math.abs(f)<=1e-10?t.lat0:Math.asin(u*t.sinph0+n*d*t.cosph0/f),r*=d*t.cosph0,n=(u-Math.sin(o)*t.sinph0)*f;break;case pt:n=-n,o=b-o;break;case at:o-=b;break}i=n===0&&(t.mode===je||t.mode===Ge)?0:Math.atan2(r,n)}else{if(h=0,t.mode===Ge||t.mode===je){if(r/=t.dd,n*=t.dd,l=Math.sqrt(r*r+n*n),l<1e-10)return e.x=t.long0,e.y=t.lat0,e;a=2*Math.asin(.5*l/t.rq),s=Math.cos(a),r*=a=Math.sin(a),t.mode===Ge?(h=s*t.sinb1+n*a*t.cosb1/l,c=t.qp*h,n=l*t.cosb1*s-n*t.sinb1*a):(h=n*a/l,c=t.qp*h,n=l*s)}else if(t.mode===pt||t.mode===at){if(t.mode===pt&&(n=-n),c=r*r+n*n,!c)return e.x=t.long0,e.y=t.lat0,e;h=1-c/t.qp,t.mode===at&&(h=-h)}i=Math.atan2(r,n),o=Vr(Math.asin(h),t.apa)}return e.x=C(t.long0+i,t.over),e.y=o,e}function xu(t){let e={...t,mode:0,qp:0,mmf:0,apa:[],dd:0,rq:0,xmf:0,ymf:0,sinb1:0,cosb1:0,sinph0:0,cosph0:0};return Cg(e),e}var bs={name:"laea",aliases:["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area"],parameters:de,create(t){let e=ue(t);return St(e,se("laea",xu(e),Mu,yu))}};function _u(t,e,r){return e*=r,Math.tan(.5*(b+t))*Math.pow((1-e)/(1+e),.5*r)}function Ag(t){t.x0=t.x0||0,t.y0=t.y0||0,t.lat0=t.lat0||0,t.long0=t.long0||0,t.coslat0=Math.cos(t.lat0),t.sinlat0=Math.sin(t.lat0),t.sphere?!Number.isNaN(t.lat_ts)&&Math.abs(t.coslat0)<=1e-10&&(t.k0=.5*(1+it(t.lat0)*Math.sin(t.lat_ts))):(Math.abs(t.coslat0)<=1e-10&&(t.lat0>0?t.con=1:t.con=-1),t.cons=Math.sqrt(Math.pow(1+t.e,1+t.e)*Math.pow(1-t.e,1-t.e)),!Number.isNaN(t.lat_ts)&&Math.abs(t.coslat0)<=1e-10&&Math.abs(Math.cos(t.lat_ts))>1e-10&&(t.k0=.5*t.cons*Se(t.e,Math.sin(t.lat_ts),Math.cos(t.lat_ts))/Le(t.e,t.con*t.lat_ts,t.con*Math.sin(t.lat_ts))),t.ms1=Se(t.e,t.sinlat0,t.coslat0),t.X0=2*Math.atan(_u(t.lat0,t.sinlat0,t.e))-b,t.cosX0=Math.cos(t.X0),t.sinX0=Math.sin(t.X0))}function wu(t,e){var r=e.x,n=e.y,i=Math.sin(n),o=Math.cos(n),s,a,c,l,h,u,f=C(r-t.long0,t.over);return Math.abs(Math.abs(r-t.long0)-Math.PI)<=1e-10&&Math.abs(n+t.lat0)<=1e-10?(e.x=NaN,e.y=NaN,e):t.sphere?(s=2*t.k0/(1+t.sinlat0*i+t.coslat0*o*Math.cos(f)),e.x=t.a*s*o*Math.sin(f)+t.x0,e.y=t.a*s*(t.coslat0*i-t.sinlat0*o*Math.cos(f))+t.y0,e):(a=2*Math.atan(_u(n,i,t.e))-b,l=Math.cos(a),c=Math.sin(a),Math.abs(t.coslat0)<=1e-10?(h=Le(t.e,n*t.con,t.con*i),u=2*t.a*t.k0*h/t.cons,e.x=t.x0+u*Math.sin(r-t.long0),e.y=t.y0-t.con*u*Math.cos(r-t.long0),e):(Math.abs(t.sinlat0)<1e-10?(s=2*t.a*t.k0/(1+l*Math.cos(f)),e.y=s*c+t.y0):(s=2*t.a*t.k0*t.ms1/(t.cosX0*(1+t.sinX0*c+t.cosX0*l*Math.cos(f))),e.y=s*(t.cosX0*c-t.sinX0*l*Math.cos(f))+t.y0),e.x=s*l*Math.sin(f)+t.x0,e))}function Su(t,e){e.x-=t.x0,e.y-=t.y0;var r,n,i,o,s,a=Math.sqrt(e.x*e.x+e.y*e.y);if(t.sphere){var c=2*Math.atan(a/(2*t.a*t.k0));return r=t.long0,n=t.lat0,a<=1e-10?(e.x=r,e.y=n,e):(n=Math.asin(Math.cos(c)*t.sinlat0+e.y*Math.sin(c)*t.coslat0/a),Math.abs(t.coslat0)<1e-10?t.lat0>0?r=C(t.long0+Math.atan2(e.x,-1*e.y),t.over):r=C(t.long0+Math.atan2(e.x,e.y),t.over):r=C(t.long0+Math.atan2(e.x*Math.sin(c),a*t.coslat0*Math.cos(c)-e.y*t.sinlat0*Math.sin(c)),t.over),e.x=r,e.y=n,e)}else if(Math.abs(t.coslat0)<=1e-10){if(a<=1e-10)return n=t.lat0,r=t.long0,e.x=r,e.y=n,e;e.x*=t.con,e.y*=t.con,i=a*t.cons/(2*t.a*t.k0),n=t.con*Ot(t.e,i),r=t.con*C(t.con*t.long0+Math.atan2(e.x,-1*e.y),t.over)}else o=2*Math.atan(a*t.cosX0/(2*t.a*t.k0*t.ms1)),r=t.long0,a<=1e-10?s=t.X0:(s=Math.asin(Math.cos(o)*t.sinX0+e.y*Math.sin(o)*t.cosX0/a),r=C(t.long0+Math.atan2(e.x*Math.sin(o),a*t.cosX0*Math.cos(o)-e.y*t.sinX0*Math.sin(o)),t.over)),n=-1*Ot(t.e,Math.tan(.5*(b+s)));return e.x=r,e.y=n,e}function Eu(t){let e={...t,coslat0:0,sinlat0:0,con:0,cons:0,ms1:0,X0:0,cosX0:0,sinX0:0};return Ag(e),e}var vs={name:"stere",aliases:["Stereographic_South_Pole","Polar_Stereographic_variant_A","Polar_Stereographic_variant_B","Polar_Stereographic"],parameters:[...de,...mt,"lat_ts"],create(t){let e=ue(t);return St(e,se("stere",Eu(e),wu,Su))}};function Pi(t,e){return Math.pow((1-t)/(1+t),e)}var Ig=20;function Ng(t){var e=Math.sin(t.lat0),r=Math.cos(t.lat0);r*=r,t.rc=Math.sqrt(1-t.es)/(1-t.es*e*e),t.C=Math.sqrt(1+t.es*r*r/(1-t.es)),t.phic0=Math.asin(e/t.C),t.ratexp=.5*t.C*t.e,t.K=Math.tan(.5*t.phic0+V)/(Math.pow(Math.tan(.5*t.lat0+V),t.C)*Pi(t.e*e,t.ratexp))}function Tu(t,e){var r=e.x,n=e.y;return e.y=2*Math.atan(t.K*Math.pow(Math.tan(.5*n+V),t.C)*Pi(t.e*Math.sin(n),t.ratexp))-b,e.x=t.C*r,e}function bu(t,e){for(var r=1e-14,n=e.x/t.C,i=e.y,o=Math.pow(Math.tan(.5*i+V)/t.K,1/t.C),s=Ig;s>0&&(i=2*Math.atan(o*Pi(t.e*Math.sin(e.y),-.5*t.e))-b,!(Math.abs(i-e.y)<r));--s)e.y=i;return s?(e.x=n,e.y=i,e):null}function vu(t){let e={...t,rc:0,C:0,phic0:0,ratexp:0,K:0};return Ng(e),e}function oe(t,e){t=Math.abs(t),e=Math.abs(e);var r=Math.max(t,e),n=Math.min(t,e)/(r||1);return r*Math.sqrt(1+Math.pow(n,2))}function Og(t){t.rc&&(t.sinc0=Math.sin(t.phic0),t.cosc0=Math.cos(t.phic0),t.R2=2*t.rc)}function Pu(t,e){var r,n,i,o;return e.x=C(e.x-t.long0,t.over),Tu(t,e),r=Math.sin(e.y),n=Math.cos(e.y),i=Math.cos(e.x),o=t.k0*t.R2/(1+t.sinc0*r+t.cosc0*n*i),e.x=o*n*Math.sin(e.x),e.y=o*(t.cosc0*r-t.sinc0*n*i),e.x=t.a*e.x+t.x0,e.y=t.a*e.y+t.y0,e}function Ru(t,e){var r,n,i,o,s;if(e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,e.x/=t.k0,e.y/=t.k0,s=oe(e.x,e.y),s){var a=2*Math.atan2(s,t.R2);r=Math.sin(a),n=Math.cos(a),o=Math.asin(n*t.sinc0+e.y*r*t.cosc0/s),i=Math.atan2(e.x*r,s*t.cosc0*n-e.y*t.sinc0*r)}else o=t.phic0,i=0;if(e.x=i,e.y=o,!bu(t,e))throw new Error("Oblique stereographic inverse did not converge");return e.x=C(e.x+t.long0,t.over),e}function Cu(t){let e={...vu(t),sinc0:0,cosc0:0,R2:0};return Og(e),e}var Ps={name:"sterea",aliases:["Stereographic_North_Pole","Oblique_Stereographic","Oblique Stereographic Alternative","Double_Stereographic"],parameters:[...de,...mt],create(t){let e=ue(t);if(Math.abs(e.lat0)===Math.PI/2)throw new Error("sterea requires a non-polar origin; use stere at the poles");return St(e,se("sterea",Cu(e),Pu,Ru))}};function Rs(t,e){let r=1-t*Math.sin(e)**2;return(1-t)/(r*Math.sqrt(r))}function Ri(t,e,r,n){return Rs(t,e-r*n)+Rs(t,e+r*n)}function Lt(t,e,r,n){let i=(n-r)/8,o=0;for(let s=0;s<4;s++){let a=r+(2*s+1)*i;o+=i*(.362683783378362*Ri(e,a,i,.1834346424956498)+.3137066458778873*Ri(e,a,i,.525532409916329)+.2223810344533745*Ri(e,a,i,.7966664774136267)+.1012285362903763*Ri(e,a,i,.9602898564975363))}return t*o}function Cs(t,e,r){let n=Math.PI/2,i=Lt(t,e,0,n);if(!Number.isFinite(r)||Math.abs(r)>i)return NaN;let o=-n,s=n,a=r/i*n;for(let c=0;c<48;c++){let l=Lt(t,e,0,a)-r;if(Math.abs(l)<=8*Number.EPSILON*t)return a;l>0?s=a:o=a;let h=a-l/(t*Rs(e,a));a=h>o&&h<s?h:(o+s)/2}return NaN}function Au(t,e,r,n,i,o,s){let a=n-e,c=Math.atan((1-o)*Math.tan(t)),l=Math.atan((1-o)*Math.tan(r)),h=Math.sin(c),u=Math.cos(c),f=Math.sin(l),d=Math.cos(l),m=a,p,g=100,y,x,w,_,S,E,v,T,I,P,R,N,q,O;do{if(y=Math.sin(m),x=Math.cos(m),w=Math.sqrt(d*y*(d*y)+(u*f-h*d*x)*(u*f-h*d*x)),w===0){s.x=0,s.y=0;return}_=h*f+u*d*x,S=Math.atan2(w,_),E=u*d*y/w,v=1-E*E,T=v!==0?_-2*h*f/v:0,I=o/16*v*(4+o*(4-3*v)),p=m,m=a+(1-I)*o*E*(S+I*w*(T+I*_*(-1+2*T*T)))}while(Math.abs(m-p)>1e-12&&--g>0);if(g===0){s.x=NaN,s.y=NaN;return}P=v*(i*i-i*(1-o)*(i*(1-o)))/(i*(1-o)*(i*(1-o))),R=1+P/16384*(4096+P*(-768+P*(320-175*P))),N=P/1024*(256+P*(-128+P*(74-47*P))),q=N*w*(T+N/4*(_*(-1+2*T*T)-N/6*T*(-3+4*w*w)*(-3+4*T*T))),O=i*(1-o)*R*(S-q);let k=Math.atan2(d*y,u*f-h*d*x);s.x=k,s.y=O}function Iu(t,e,r,n,i,o,s){let a=Math.atan((1-o)*Math.tan(t)),c=Math.sin(a),l=Math.cos(a),h=Math.sin(r),u=Math.cos(r),f=Math.atan2(c,l*u),d=l*h,m=1-d*d,p=m*(i*i-i*(1-o)*(i*(1-o)))/(i*(1-o)*(i*(1-o))),g=1+p/16384*(4096+p*(-768+p*(320-175*p))),y=p/1024*(256+p*(-128+p*(74-47*p))),x=n/(i*(1-o)*g),w,_=100,S,E,v,T;do S=Math.cos(2*f+x),E=Math.sin(x),v=Math.cos(x),T=y*E*(S+y/4*(v*(-1+2*S*S)-y/6*S*(-3+4*E*E)*(-3+4*S*S))),w=x,x=n/(i*(1-o)*g)+T;while(Math.abs(x-w)>1e-12&&--_>0);if(_===0){s.x=NaN,s.y=NaN;return}let I=c*E-l*v*u,P=Math.atan2(c*v+l*E*u,(1-o)*Math.sqrt(d*d+I*I)),R=Math.atan2(E*h,l*v-c*E*u),N=o/16*m*(4+o*(4-3*m)),q=R-(1-N)*o*d*(x+N*E*(S+N*v*(-1+2*S*S))),O=e+q;s.x=O,s.y=P}function Lg(t){t.sin_p12=Math.sin(t.lat0),t.cos_p12=Math.cos(t.lat0),t.x0=t.x0||0,t.y0=t.y0||0,t.long0=t.long0||0,t.f=t.es/(1+Math.sqrt(1-t.es))}function Nu(t,e){var r=e.x,n=e.y,i=Math.sin(e.y),o=Math.cos(e.y),s=C(r-t.long0,t.over),a,c,l,h,u;if(t.sphere)return Math.abs(t.sin_p12-1)<=1e-10?(e.x=t.x0+t.a*(b-n)*Math.sin(s),e.y=t.y0-t.a*(b-n)*Math.cos(s),e):Math.abs(t.sin_p12+1)<=1e-10?(e.x=t.x0+t.a*(b+n)*Math.sin(s),e.y=t.y0+t.a*(b+n)*Math.cos(s),e):(h=t.sin_p12*i+t.cos_p12*o*Math.cos(s),c=Math.acos(h),l=c?c/Math.sin(c):1,e.x=t.x0+t.a*l*o*Math.sin(s),e.y=t.y0+t.a*l*(t.cos_p12*i-t.sin_p12*o*Math.cos(s)),e);if(Math.abs(t.sin_p12-1)<=1e-10)return a=Lt(t.a,t.es,n,b),e.x=t.x0+a*Math.sin(s),e.y=t.y0-a*Math.cos(s),e;if(Math.abs(t.sin_p12+1)<=1e-10)return a=Lt(t.a,t.es,-b,n),e.x=t.x0+a*Math.sin(s),e.y=t.y0+a*Math.cos(s),e;{if(Math.abs(s)<1e-10&&Math.abs(n-t.lat0)<1e-10)return e.x=t.x0,e.y=t.y0,e;Au(t.lat0,t.long0,n,r,t.a,t.f,e),u=e.x;let f=e.y;return e.x=t.x0+f*Math.sin(u),e.y=t.y0+f*Math.cos(u),e}}function Ou(t,e){e.x-=t.x0,e.y-=t.y0;var r,n,i,o,s,a,c,l,h,u,f;if(t.sphere){if(r=Math.sqrt(e.x*e.x+e.y*e.y),r>2*b*t.a)return null;if(n=r/t.a,i=Math.sin(n),o=Math.cos(n),s=t.long0,Math.abs(r)<=1e-10)a=t.lat0;else if(a=Te(o*t.sin_p12+e.y*i*t.cos_p12/r),c=Math.abs(t.lat0)-b,Math.abs(c)<=1e-10)if(t.lat0>=0){if(!Number.isFinite(a))return null;s=C(t.long0+Math.atan2(e.x,-e.y),t.over)}else s=C(t.long0-Math.atan2(-e.x,e.y),t.over);else s=C(t.long0+Math.atan2(e.x*i,r*t.cos_p12*o-e.y*t.sin_p12*i),t.over);return e.x=s,e.y=a,e}else return Math.abs(t.sin_p12-1)<=1e-10?(l=Lt(t.a,t.es,0,b),r=Math.sqrt(e.x*e.x+e.y*e.y),h=l-r,a=Cs(t.a,t.es,h),Number.isFinite(a)?(s=C(t.long0+Math.atan2(e.x,-1*e.y),t.over),e.x=s,e.y=a,e):null):Math.abs(t.sin_p12+1)<=1e-10?(l=Lt(t.a,t.es,0,b),r=Math.sqrt(e.x*e.x+e.y*e.y),h=r-l,a=Cs(t.a,t.es,h),Number.isFinite(a)?(s=C(t.long0+Math.atan2(e.x,e.y),t.over),e.x=s,e.y=a,e):null):(u=Math.atan2(e.x,e.y),f=Math.sqrt(e.x*e.x+e.y*e.y),Iu(t.lat0,t.long0,u,f,t.a,t.f,e),e)}function Lu(t){let e={...t,sin_p12:0,cos_p12:0,f:0};return Lg(e),e}var As={name:"aeqd",aliases:["Azimuthal_Equidistant"],parameters:de,create(t){let e=ue(t);return St(e,se("aeqd",Lu(e),Nu,Ou))}};function Gt(t){var e=Math.exp(t);return e=(e-1/e)/2,e}function Gu(t){var e=1+t,r=e-1;return r===0?t:t*Math.log(e)/r}function zu(t){var e=Math.abs(t);return e=Gu(e*(1+e/(oe(1,e)+1))),t<0?-e:e}function Ci(t,e){for(var r=2*Math.cos(2*e),n=t.length-1,i=t[n],o=0,s;--n>=0;)s=-o+r*i+t[n],o=i,i=s;return e+s*Math.sin(2*e)}function qu(t,e){for(var r=2*Math.cos(e),n=t.length-1,i=t[n],o=0,s;--n>=0;)s=-o+r*i+t[n],o=i,i=s;return Math.sin(e)*s}function jr(t){var e=Math.exp(t);return e=(e+1/e)/2,e}function Is(t,e,r,n){for(var i=Math.sin(e),o=Math.cos(e),s=Gt(r),a=jr(r),c=2*o*a,l=-2*i*s,h=t.length-1,u=t[h],f=0,d=0,m=0,p,g;--h>=0;)p=d,g=f,d=u,f=m,u=-p+c*d-l*f+t[h],m=-g+l*d+c*f;c=i*a,l=o*s,n.x=c*u-l*m,n.y=c*m+l*u}function Gg(t){t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.long0=t.long0!==void 0?t.long0:0,t.lat0=t.lat0!==void 0?t.lat0:0,t.k0=t.k0!==void 0?t.k0:1,t.cgb=[],t.cbg=[],t.utg=[],t.gtu=[];var e=t.es/(1+Math.sqrt(1-t.es)),r=e/(2-e),n=r;t.cgb[0]=r*(2+r*(-2/3+r*(-2+r*(116/45+r*(26/45+r*(-2854/675)))))),t.cbg[0]=r*(-2+r*(2/3+r*(4/3+r*(-82/45+r*(32/45+r*(4642/4725)))))),n=n*r,t.cgb[1]=n*(7/3+r*(-8/5+r*(-227/45+r*(2704/315+r*(2323/945))))),t.cbg[1]=n*(5/3+r*(-16/15+r*(-13/9+r*(904/315+r*(-1522/945))))),n=n*r,t.cgb[2]=n*(56/15+r*(-136/35+r*(-1262/105+r*(73814/2835)))),t.cbg[2]=n*(-26/15+r*(34/21+r*(8/5+r*(-12686/2835)))),n=n*r,t.cgb[3]=n*(4279/630+r*(-332/35+r*(-399572/14175))),t.cbg[3]=n*(1237/630+r*(-12/5+r*(-24832/14175))),n=n*r,t.cgb[4]=n*(4174/315+r*(-144838/6237)),t.cbg[4]=n*(-734/315+r*(109598/31185)),n=n*r,t.cgb[5]=n*(601676/22275),t.cbg[5]=n*(444337/155925),n=Math.pow(r,2),t.Qn=t.k0/(1+r)*(1+n*(1/4+n*(1/64+n/256))),t.utg[0]=r*(-.5+r*(2/3+r*(-37/96+r*(1/360+r*(81/512+r*(-96199/604800)))))),t.gtu[0]=r*(.5+r*(-2/3+r*(5/16+r*(41/180+r*(-127/288+r*(7891/37800)))))),t.utg[1]=n*(-1/48+r*(-1/15+r*(437/1440+r*(-46/105+r*(1118711/3870720))))),t.gtu[1]=n*(13/48+r*(-3/5+r*(557/1440+r*(281/630+r*(-1983433/1935360))))),n=n*r,t.utg[2]=n*(-17/480+r*(37/840+r*(209/4480+r*(-5569/90720)))),t.gtu[2]=n*(61/240+r*(-103/140+r*(15061/26880+r*(167603/181440)))),n=n*r,t.utg[3]=n*(-4397/161280+r*(11/504+r*(830251/7257600))),t.gtu[3]=n*(49561/161280+r*(-179/168+r*(6601661/7257600))),n=n*r,t.utg[4]=n*(-4583/161280+r*(108847/3991680)),t.gtu[4]=n*(34729/80640+r*(-3418889/1995840)),n=n*r,t.utg[5]=n*(-20648693/638668800),t.gtu[5]=n*(212378941/319334400);var i=Ci(t.cbg,t.lat0);t.Zb=-t.Qn*(i+qu(t.gtu,2*i))}function Fu(t,e){var r=C(e.x-t.long0,t.over),n=e.y;n=Ci(t.cbg,n);var i=Math.sin(n),o=Math.cos(n),s=Math.sin(r),a=Math.cos(r);n=Math.atan2(i,a*o),r=Math.atan2(s*o,oe(i,o*a)),r=zu(Math.tan(r)),Is(t.gtu,2*n,2*r,e),n=n+e.x,r=r+e.y;var c,l;return Math.abs(r)<=2.623395162778?(c=t.a*(t.Qn*r)+t.x0,l=t.a*(t.Qn*n+t.Zb)+t.y0):(c=1/0,l=1/0),e.x=c,e.y=l,e}function Bu(t,e){var r=(e.x-t.x0)*(1/t.a),n=(e.y-t.y0)*(1/t.a);n=(n-t.Zb)/t.Qn,r=r/t.Qn;var i,o;if(Math.abs(r)<=2.623395162778){Is(t.utg,2*n,2*r,e),n=n+e.x,r=r+e.y,r=Math.atan(Gt(r));var s=Math.sin(n),a=Math.cos(n),c=Math.sin(r),l=Math.cos(r);n=Math.atan2(s*l,oe(c,l*a)),r=Math.atan2(c,l*a),i=C(r+t.long0,t.over),o=Ci(t.cgb,n)}else i=1/0,o=1/0;return e.x=i,e.y=o,e}function Du(t){let e={...t,cgb:[],cbg:[],utg:[],gtu:[],Qn:0,Zb:0};return Gg(e),e}function zg(t){t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.long0=t.long0!==void 0?t.long0:0,t.lat0=t.lat0!==void 0?t.lat0:0,t.es&&(t.en=ot(t.es),t.ml0=fe(t.lat0,Math.sin(t.lat0),Math.cos(t.lat0),t.en))}function ku(t,e){var r=e.x,n=e.y,i=C(r-t.long0,t.over),o,s,a,c=Math.sin(n),l=Math.cos(n);if(t.es){var u=l*i,f=Math.pow(u,2),d=t.ep2*Math.pow(l,2),m=Math.pow(d,2),p=Math.abs(l)>1e-10?Math.tan(n):0,g=Math.pow(p,2),y=Math.pow(g,2);o=1-t.es*Math.pow(c,2),u=u/Math.sqrt(o);var x=fe(n,c,l,t.en);s=t.a*(t.k0*u*(1+f/6*(1-g+d+f/20*(5-18*g+y+14*d-58*g*d+f/42*(61+179*y-y*g-479*g)))))+t.x0,a=t.a*(t.k0*(x-t.ml0+c*i*u/2*(1+f/12*(5-g+9*d+4*m+f/30*(61+y-58*g+270*d-330*g*d+f/56*(1385+543*y-y*g-3111*g))))))+t.y0}else{var h=l*Math.sin(i);if(Math.abs(Math.abs(h)-1)<1e-10)return 93;if(s=.5*t.a*t.k0*Math.log((1+h)/(1-h))+t.x0,a=l*Math.cos(i)/Math.sqrt(1-Math.pow(h,2)),h=Math.abs(a),h>=1){if(h-1>1e-10)return 93;a=0}else a=Math.acos(a);n<0&&(a=-a),a=t.a*t.k0*(a-t.lat0)+t.y0}return e.x=s,e.y=a,e}function Uu(t,e){var r,n,i,o,s=(e.x-t.x0)*(1/t.a),a=(e.y-t.y0)*(1/t.a);if(t.es)if(r=t.ml0+a/t.k0,n=st(r,t.es,t.en),Math.abs(n)<b){var f=Math.sin(n),d=Math.cos(n),m=Math.abs(d)>1e-10?Math.tan(n):0,p=t.ep2*Math.pow(d,2),g=Math.pow(p,2),y=Math.pow(m,2),x=Math.pow(y,2);r=1-t.es*Math.pow(f,2);var w=s*Math.sqrt(r)/t.k0,_=Math.pow(w,2);r=r*m,i=n-r*_/(1-t.es)*.5*(1-_/12*(5+3*y-9*p*y+p-4*g-_/30*(61+90*y-252*p*y+45*x+46*p-_/56*(1385+3633*y+4095*x+1574*x*y)))),o=C(t.long0+w*(1-_/6*(1+2*y+p-_/20*(5+28*y+24*x+8*p*y+6*p-_/42*(61+662*y+1320*x+720*x*y))))/d,t.over)}else i=b*it(a),o=0;else{var c=Math.exp(s/t.k0),l=.5*(c-1/c),h=t.lat0+a/t.k0,u=Math.cos(h);r=Math.sqrt((1-Math.pow(u,2))/(1+Math.pow(l,2))),i=Math.asin(r),Math.sin(h)<0&&(i=-i),l===0&&u===0?o=0:o=C(Math.atan2(l,u)+t.long0,t.over)}return e.x=o,e.y=i,e}function Vu(t){let e={...t,en:[],ml0:0};return zg(e),e}function Ai(t){let e=ue(t);if(Ke(t.parameters,"approx"))return se("tmerc +approx",Vu(e),ku,Uu,Xe);if(e.sphere)throw new Error("Spherical transverse Mercator requires +approx");return se("etmerc",Du(e),Fu,Bu,Xe)}var Ns={name:"tmerc",aliases:["Fast_Transverse_Mercator","Fast Transverse Mercator","Transverse_Mercator","Transverse Mercator","Gauss Kruger","Gauss_Kruger"],parameters:[...de,...mt,"approx"],flags:["approx"],create:Ai},Os={name:"etmerc",aliases:["Extended_Transverse_Mercator","Extended Transverse Mercator"],parameters:[...de,...mt,"approx"],flags:["approx"],create:Ai};var Ls={name:"utm",aliases:["Universal Transverse Mercator System"],parameters:["zone","south","approx"],flags:["south","approx"],create(t){let e=G(t.parameters,"zone",NaN);if(!Number.isInteger(e)||e<1||e>60)throw new Error("UTM requires an integer +zone from 1 to 60");let r=Ke(t.parameters,"south");return Ai({...t,parameters:{...t.parameters,lat_0:"0",lon_0:String(6*e-183),x_0:"500000",y_0:r?"10000000":"0",k_0:"0.9996"}})}};var Gs={name:"geocent",aliases:["Geocentric","geocentric","Geocent"],parameters:[],create({semiMajorAxis:t,semiMinorAxis:e,eccentricitySquared:r}){let n={semiMajorAxis:t,eccentricitySquared:r,semiMinorAxis:e??t*Math.sqrt(1-r)};return{forward(){throw new Error("Geocentric projection requires the 3D pipeline")},inverse(){throw new Error("Geocentric projection requires the 3D pipeline")},forwardInPlace:i=>Si(i,n),inverseInPlace:i=>Ei(i,n),forward3D:i=>Kh(i,n),inverse3D:i=>Zh(i,n)}}};function F(t){let e=ue(t);return{...e,x0:0,y0:0,lat_ts:Number.isNaN(e.lat_ts)?0:e.lat_ts}}function B(t,e,r,n,i,o){let s=se(t,r,n,i),a=G(e.parameters,"x_0",0),c=G(e.parameters,"y_0",0);return Ue(l=>{o?.(l.x,l.y),s.forwardInPlace(l),l.x+=a,l.y+=c},l=>{l.x-=a,l.y-=c,s.inverseInPlace(l)})}function Tt(t,e=0,r=!1){return(n,i)=>{let o=Math.sin(t.lat0)*Math.sin(i)+Math.cos(t.lat0)*Math.cos(i)*Math.cos(n-t.long0);if(r?o<e-1e-14:o<=e+1e-14)throw new Error("Coordinate is outside the visible projection horizon")}}var Wr=1e-10;function qg(t){var e;if(t.phi1=t.lat1,Math.abs(t.phi1)<Wr)throw new Error;t.es?(t.en=ot(t.es),t.am1=Math.sin(t.phi1),e=Math.cos(t.phi1),t.m1=fe(t.phi1,t.am1,e,t.en),t.am1=e/(Math.sqrt(1-t.es*t.am1*t.am1)*t.am1)):Math.abs(t.phi1)+Wr>=b?t.cphi1=0:t.cphi1=1/Math.tan(t.phi1)}function Fg(t,e){var r=C(e.x-(t.long0||0),t.over),n=e.y,i,o,s;return o=Math.sin(n),s=Math.cos(n),i=t.am1+t.m1-fe(n,o,s,t.en),o=s*r/(i*Math.sqrt(1-t.es*o*o)),e.x=i*Math.sin(o),e.y=t.am1-i*Math.cos(o),e.x=t.a*e.x+(t.x0||0),e.y=t.a*e.y+(t.y0||0),e}function Bg(t,e){e.x=(e.x-(t.x0||0))/t.a,e.y=(e.y-(t.y0||0))/t.a;var r,n,i,o;if(e.y=t.am1-e.y,n=oe(e.x,e.y),t.phi1<0&&(n=-n),o=st(t.am1+t.m1-n,t.es,t.en),r=Math.abs(o),r<b)r=Math.sin(o),i=n*Math.atan2(Math.sign(t.phi1)*e.x,Math.sign(t.phi1)*e.y)*Math.sqrt(1-t.es*r*r)/Math.cos(o);else if(Math.abs(r-b)<=Wr)i=0;else throw new Error;return e.x=C(i+(t.long0||0),t.over),e.y=Ze(o),e}function Dg(t,e){var r=C(e.x-(t.long0||0),t.over),n=e.y,i,o;return o=t.cphi1+t.phi1-n,Math.abs(o)>Wr?(i=r*Math.cos(n)/o,e.x=o*Math.sin(i),e.y=t.cphi1-o*Math.cos(i)):e.x=e.y=0,e.x=t.a*e.x+(t.x0||0),e.y=t.a*e.y+(t.y0||0),e}function kg(t,e){e.x=(e.x-(t.x0||0))/t.a,e.y=(e.y-(t.y0||0))/t.a;var r,n;e.y=t.cphi1-e.y;var i=oe(e.x,e.y);if(t.phi1<0&&(i=-i),n=t.cphi1+t.phi1-i,Math.abs(n)>b)throw new Error;return Math.abs(Math.abs(n)-b)<=Wr?r=0:r=i*Math.atan2(Math.sign(t.phi1)*e.x,Math.sign(t.phi1)*e.y)/Math.cos(n),e.x=C(r+(t.long0||0),t.over),e.y=Ze(n),e}function ju(t,e){return t.es?Fg(t,e):Dg(t,e)}function Wu(t,e){return t.es?Bg(t,e):kg(t,e)}function Hu(t,e={}){let r={...t,phi1:0,en:[],m1:0,am1:0,cphi1:0,...e};return qg(r),r}var zs={name:"bonne",aliases:["Bonne (Werner lat_1=90)"],parameters:["lon_0","x_0","y_0","lat_1"],create(t){let e=F(t);if(!Object.prototype.hasOwnProperty.call(t.parameters,"lat_1")||Math.abs(e.lat1)<1e-10)throw new Error("Bonne requires a nonzero lat_1");let r=Hu(e);return B("bonne",t,r,ju,Wu)}};function Hr(t,e,r){var n=e*r;return t/Math.sqrt(1-n*n)}function Ug(t){t.sphere||(t.en=ot(t.es),t.ml0=t.a*fe(t.lat0,Math.sin(t.lat0),Math.cos(t.lat0),t.en))}function Fs(t,e){var r,n,i=e.x,o=e.y;if(i=C(i-t.long0,t.over),t.sphere)r=t.a*Math.asin(Math.cos(o)*Math.sin(i)),n=t.a*(Math.atan2(Math.tan(o),Math.cos(i))-t.lat0);else{var s=Math.sin(o),a=Math.cos(o),c=Hr(t.a,t.e,s),l=Math.tan(o)*Math.tan(o),h=i*Math.cos(o),u=h*h,f=t.es*a*a/(1-t.es),d=t.a*fe(o,s,a,t.en);r=c*h*(1-u*l*(1/6+(8-l+8*f)*u/120)),n=d-t.ml0+c*s/a*u*(.5+(5-l+6*f)*u/24)}return e.x=r+t.x0,e.y=n+t.y0,e}function $u(t,e){e.x-=t.x0,e.y-=t.y0;var r=e.x/t.a,n=e.y/t.a,i,o;if(t.sphere){var s=n+t.lat0;i=Math.asin(Math.sin(s)*Math.cos(r)),o=Math.atan2(Math.tan(r),Math.cos(s))}else{var a=t.ml0/t.a+n,c=st(a,t.es,t.en);if(Math.abs(Math.abs(c)-b)<=1e-10)return e.x=t.long0,e.y=Math.sign(c)*b,e;var l=Hr(t.a,t.e,Math.sin(c)),h=l*l*l/t.a/t.a*(1-t.es),u=Math.pow(Math.tan(c),2),f=r*t.a/l,d=f*f;i=c-l*Math.tan(c)/h*f*f*(.5-(1+3*u)*f*f/24),o=f*(1-d*(u/3-(1+3*u)*u*d/15))/Math.cos(c)}if(!t.sphere){let m=e.x+t.x0,p=e.y+t.y0,g=t.scratch,y=!1;for(let x=0;x<12;x++){qs(t,o,i);let w=g.x-m,_=g.y-p;if(Math.max(Math.abs(w),Math.abs(_))<1e-7){y=!0;break}let S=1e-7,E=i>b-S?-S:S,v=g.x,T=g.y;qs(t,o+S,i);let I=(g.x-v)/S,P=(g.y-T)/S;qs(t,o,i+E);let R=(g.x-v)/E,N=(g.y-T)/E,q=I*N-R*P;if(!Number.isFinite(q)||Math.abs(q)<1e-12||(o-=(N*w-R*_)/q,i-=(I*_-P*w)/q,!Number.isFinite(o)||Math.abs(i)>b))break}if(!y)throw new Error("Cassini inverse did not converge")}return e.x=C(o+t.long0,t.over),e.y=Ze(i),e}function qs(t,e,r){t.scratch.x=e+t.long0,t.scratch.y=r,Fs(t,t.scratch)}function Yu(t,e={}){let r={...t,en:[],scratch:{x:0,y:0},ml0:0,...e};return Ug(r),r}var Bs={name:"cass",aliases:["Cassini","Cassini_Soldner"],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=F(t),r=Yu(e);return B("cass",t,r,Fs,$u)}};function Xu(t,e){var r=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));let n=4*Number.EPSILON*r;if(Math.abs(e)>r+n)return NaN;if(Math.abs(Math.abs(e)-r)<=n)return e<0?-1*b:b;for(var i=Math.asin(.5*e),o,s,a,c,l=0;l<30;l++)if(s=Math.sin(i),a=Math.cos(i),c=t*s,o=Math.pow(1-c*c,2)/(2*a)*(e/(1-t*t)-s/(1-c*c)+.5/t*Math.log((1-c)/(1+c))),i+=o,Math.abs(o)<=1e-10)return i;return NaN}function Vg(t){t.sphere||(t.k0=Se(t.e,Math.sin(t.lat_ts),Math.cos(t.lat_ts)))}function Ku(t,e){var r=e.x,n=e.y,i,o,s=C(r-t.long0,t.over);if(t.sphere)i=t.x0+t.a*s*Math.cos(t.lat_ts),o=t.y0+t.a*Math.sin(n)/Math.cos(t.lat_ts);else{var a=Ee(t.e,Math.sin(n));i=t.x0+t.a*t.k0*s,o=t.y0+t.a*a*.5/t.k0}return e.x=i,e.y=o,e}function Zu(t,e){e.x-=t.x0,e.y-=t.y0;var r,n;return t.sphere?(r=C(t.long0+e.x/t.a/Math.cos(t.lat_ts),t.over),n=Math.asin(e.y/t.a*Math.cos(t.lat_ts))):(n=Xu(t.e,2*e.y*t.k0/t.a),r=C(t.long0+e.x/(t.a*t.k0),t.over)),e.x=r,e.y=n,e}function Qu(t,e={}){let r={...t,...e};return Vg(r),r}var Ds={name:"cea",aliases:[],parameters:["lon_0","x_0","y_0","lat_ts"],create(t){let e=F(t);if(Math.abs(e.lat_ts)>=Math.PI/2)throw new Error("CEA standard parallel must be away from the poles");let r=Qu(e);return B("cea",t,r,Ku,Zu)}};var jg=20;function Wg(t){t.long0=t.long0||0,t.sphere?(t.n=1,t.m=0,t.es=0,t.C_y=Math.sqrt((t.m+1)/t.n),t.C_x=t.C_y/(t.m+1)):t.en=ot(t.es)}function Ii(t,e){var r,n,i=e.x,o=e.y;if(i=C(i-t.long0,t.over),t.sphere){if(!t.m)o=t.n!==1?Math.asin(t.n*Math.sin(o)):o;else for(var s=t.n*Math.sin(o),a=jg;a;--a){var c=(t.m*o+Math.sin(o)-s)/(t.m+Math.cos(o));if(o-=c,Math.abs(c)<1e-10)break}r=t.a*t.C_x*i*(t.m+Math.cos(o)),n=t.a*t.C_y*o}else{var l=Math.sin(o),h=Math.cos(o);n=t.a*fe(o,l,h,t.en),r=t.a*i*h/Math.sqrt(1-t.es*l*l)}return e.x=r,e.y=n,e}function Ni(t,e){var r,n,i,o;return e.x-=t.x0,i=e.x/t.a,e.y-=t.y0,r=e.y/t.a,t.sphere?(r/=t.C_y,i=i/(t.C_x*(t.m+Math.cos(r))),t.m?r=Te((t.m*r+Math.sin(r))/t.n):t.n!==1&&(r=Te(Math.sin(r)/t.n)),i=C(i+t.long0,t.over),r=Ze(r)):(r=st(e.y/t.a,t.es,t.en),o=Math.abs(r),o<b?(o=Math.sin(r),n=t.long0+e.x*Math.sqrt(1-t.es*o*o)/(t.a*Math.cos(r)),i=C(n,t.over)):o-1e-10<b&&(i=t.long0)),e.x=i,e.y=r,e}function Ju(t,e={}){let r={...t,en:[],n:0,m:0,C_y:0,C_x:0,...e};return Wg(r),r}function Hg(t){t.sphere=!0,t.b=t.a,t.m=1,t.n=2.5707963267948966,t.es=0,t.C_y=Math.sqrt((t.m+1)/t.n),t.C_x=t.C_y/(t.m+1)}var ef=Ii,tf=Ni;function rf(t,e={}){let r={...t,m:0,n:0,C_y:0,C_x:0,en:[],...e};return Hg(r),r}var ks={name:"eck6",aliases:["Eckert_VI"],parameters:["lon_0","x_0","y_0"],create(t){let e=F(t),r=rf(e);return B("eck6",t,r,ef,tf)}};var $r=1.340264,Yr=-.081106,Xr=893e-6,Kr=.003796,Oi=Math.sqrt(3)/2;function $g(t){t.long0=t.long0!==void 0?t.long0:0,t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.es!==0&&(t.apa=Ur(t.es),t.qp=Ee(t.e,1),t.rqda=Math.sqrt(.5*t.qp))}function nf(t,e){var r=C(e.x-t.long0,t.over),n=e.y,i=Math.sin(n);t.es!==0&&(i=Ee(t.e,i)/t.qp);var o=Math.asin(Oi*i),s=o*o,a=s*s*s;return e.x=r*Math.cos(o)/(Oi*($r+3*Yr*s+a*(7*Xr+9*Kr*s))),e.y=o*($r+Yr*s+a*(Xr+Kr*s)),t.es!==0&&(e.x*=t.rqda,e.y*=t.rqda),e.x=t.a*e.x+t.x0,e.y=t.a*e.y+t.y0,e}function of(t,e){e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,t.es!==0&&(e.x/=t.rqda,e.y/=t.rqda);var r=1e-9,n=12,i=e.y,o,s,a,c,l,h;for(h=0;h<n&&(o=i*i,s=o*o*o,a=i*($r+Yr*o+s*(Xr+Kr*o))-e.y,c=$r+3*Yr*o+s*(7*Xr+9*Kr*o),i-=l=a/c,!(Math.abs(l)<r));++h);return o=i*i,s=o*o*o,e.x=Oi*e.x*($r+3*Yr*o+s*(7*Xr+9*Kr*o))/Math.cos(i),e.y=Math.asin(Math.sin(i)/Oi),t.es!==0&&(e.y=Vr(e.y,t.apa)),e.x=C(e.x+t.long0,t.over),e}function sf(t,e={}){let r={...t,apa:[],qp:0,rqda:0,...e};return $g(r),r}var Us={name:"eqearth",aliases:["Equal Earth","Equal_Earth"],parameters:["lon_0","x_0","y_0"],create(t){let e=F(t),r=sf(e);return B("eqearth",t,r,nf,of)}};function Yg(t){t.x0=t.x0||0,t.y0=t.y0||0,t.lat0=t.lat0||0,t.long0=t.long0||0}function af(t,e){var r=e.x,n=e.y,i=C(r-t.long0,t.over),o=t.x0+t.a*i*Math.cos(t.lat0),s=t.y0+t.a*n;return t.t1=o,t.t2=Math.cos(t.lat0),e.x=o,e.y=s,e}function cf(t,e){e.x-=t.x0,e.y-=t.y0;var r=e.y/t.a,n=C(t.long0+e.x/(t.a*Math.cos(t.lat0)),t.over);return e.x=n,e.y=r,e}function lf(t,e={}){let r={...t,t2:0,t1:0,...e};return Yg(r),r}var Vs={name:"equi",aliases:[],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=F(t);if(Math.abs(e.lat0)>=Math.PI/2)throw new Error("Equirectangular standard parallel must be away from the poles");let r=lf(e);return B("equi",t,r,af,cf)}};function Xg(t){if(t.flip_axis=t.sweep==="x"?1:0,t.h=Number(t.h),t.radius_g_1=t.h/t.a,t.radius_g_1<=0||t.radius_g_1>1e10)throw new Error;if(t.radius_g=1+t.radius_g_1,t.C=t.radius_g*t.radius_g-1,t.es!==0){var e=1-t.es,r=1/e;t.radius_p=Math.sqrt(e),t.radius_p2=e,t.radius_p_inv2=r,t.shape="ellipse"}else t.radius_p=1,t.radius_p2=1,t.radius_p_inv2=1,t.shape="sphere"}function hf(t,e){var r=e.x,n=e.y,i,o,s,a;if(r=r-t.long0,t.shape==="ellipse"){n=Math.atan(t.radius_p2*Math.tan(n));var c=t.radius_p/oe(t.radius_p*Math.cos(n),Math.sin(n));if(o=c*Math.cos(r)*Math.cos(n),s=c*Math.sin(r)*Math.cos(n),a=c*Math.sin(n),(t.radius_g-o)*o-s*s-a*a*t.radius_p_inv2<0)return e.x=Number.NaN,e.y=Number.NaN,e;i=t.radius_g-o,t.flip_axis?(e.x=t.radius_g_1*Math.atan(s/oe(a,i)),e.y=t.radius_g_1*Math.atan(a/i)):(e.x=t.radius_g_1*Math.atan(s/i),e.y=t.radius_g_1*Math.atan(a/oe(s,i)))}else t.shape==="sphere"&&(i=Math.cos(n),o=Math.cos(r)*i,s=Math.sin(r)*i,a=Math.sin(n),i=t.radius_g-o,t.flip_axis?(e.x=t.radius_g_1*Math.atan(s/oe(a,i)),e.y=t.radius_g_1*Math.atan(a/i)):(e.x=t.radius_g_1*Math.atan(s/i),e.y=t.radius_g_1*Math.atan(a/oe(s,i))));return e.x=e.x*t.a,e.y=e.y*t.a,e}function uf(t,e){var r=-1,n=0,i=0,o,s,a,c;if(e.x=e.x/t.a,e.y=e.y/t.a,t.shape==="ellipse"){t.flip_axis?(i=Math.tan(e.y/t.radius_g_1),n=Math.tan(e.x/t.radius_g_1)*oe(1,i)):(n=Math.tan(e.x/t.radius_g_1),i=Math.tan(e.y/t.radius_g_1)*oe(1,n));var l=i/t.radius_p;if(o=n*n+l*l+r*r,s=2*t.radius_g*r,a=s*s-4*o*t.C,a<0)return e.x=Number.NaN,e.y=Number.NaN,e;c=(-s-Math.sqrt(a))/(2*o),r=t.radius_g+c*r,n*=c,i*=c,e.x=Math.atan2(n,r),e.y=Math.atan(i*Math.cos(e.x)/r),e.y=Math.atan(t.radius_p_inv2*Math.tan(e.y))}else if(t.shape==="sphere"){if(t.flip_axis?(i=Math.tan(e.y/t.radius_g_1),n=Math.tan(e.x/t.radius_g_1)*Math.sqrt(1+i*i)):(n=Math.tan(e.x/t.radius_g_1),i=Math.tan(e.y/t.radius_g_1)*Math.sqrt(1+n*n)),o=n*n+i*i+r*r,s=2*t.radius_g*r,a=s*s-4*o*t.C,a<0)return e.x=Number.NaN,e.y=Number.NaN,e;c=(-s-Math.sqrt(a))/(2*o),r=t.radius_g+c*r,n*=c,i*=c,e.x=Math.atan2(n,r),e.y=Math.atan(i*Math.cos(e.x)/r)}return e.x=e.x+t.long0,e}function ff(t,e={}){let r={...t,flip_axis:0,sweep:"",h:0,radius_g_1:0,radius_g:0,C:0,radius_p:0,radius_p2:0,radius_p_inv2:0,shape:"",...e};return Xg(r),r}var js={name:"geos",aliases:["Geostationary Satellite View","Geostationary_Satellite"],parameters:["lon_0","x_0","y_0","h","sweep"],create(t){let e=F(t),r=G(t.parameters,"h",NaN);if(!Number.isFinite(r)||r<=0)throw new Error("Geostationary projection requires positive h");let n=t.parameters.sweep||"y";if(!["x","y"].includes(n))throw new Error("Geostationary sweep must be x or y");let i=ff(e,{h:r,sweep:n});return B("geos",t,i,hf,uf,e.sphere?Tt({...e,lat0:0},1/(1+r/e.a),!0):void 0)}};function Kg(t){t.sin_p14=Math.sin(t.lat0),t.cos_p14=Math.cos(t.lat0),t.infinity_dist=1e3*t.a,t.rc=1}function df(t,e){var r,n,i,o,s,a,c,l,h=e.x,u=e.y;return i=C(h-t.long0,t.over),r=Math.sin(u),n=Math.cos(u),o=Math.cos(i),a=t.sin_p14*r+t.cos_p14*n*o,s=1,a>0||Math.abs(a)<=1e-10?(c=t.x0+t.a*s*n*Math.sin(i)/a,l=t.y0+t.a*s*(t.cos_p14*r-t.sin_p14*n*o)/a):(c=t.x0+t.infinity_dist*n*Math.sin(i),l=t.y0+t.infinity_dist*(t.cos_p14*r-t.sin_p14*n*o)),e.x=c,e.y=l,e}function mf(t,e){var r,n,i,o,s,a;return e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,e.x/=t.k0,e.y/=t.k0,r=Math.sqrt(e.x*e.x+e.y*e.y),r?(o=Math.atan2(r,t.rc),n=Math.sin(o),i=Math.cos(o),a=Te(i*t.sin_p14+e.y*n*t.cos_p14/r),s=Math.atan2(e.x*n,r*t.cos_p14*i-e.y*t.sin_p14*n),s=C(t.long0+s,t.over)):(a=t.lat0,s=t.long0),e.x=s,e.y=a,e}function pf(t,e={}){let r={...t,sin_p14:0,cos_p14:0,infinity_dist:0,rc:0,phic0:0,...e};return Kg(r),r}var Ws={name:"gnom",aliases:[],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=F(t),r=pf(e);return B("gnom",t,r,df,mf,Tt(e))}};function sr(t,e,r){if(Math.abs(e)>b)return Number.NaN;if(e===b)return Number.POSITIVE_INFINITY;if(e===-1*b)return Number.NEGATIVE_INFINITY;var n=t*r;return Math.log(Math.tan((b+e)/2))+t*Math.log((1-n)/(1+n))/2}function Hs(t,e){return 2*Math.atan(t*Math.exp(e))-b}function gf(t,e){var r=Hs(1,e),n=0,i=0;let o=0;do{if(++o>50)throw new Error("Isometric latitude inverse did not converge");n=r,i=t*Math.sin(n),r=Hs(Math.exp(t*Math.log((1+i)/(1-i))/2),e)}while(Math.abs(r-n)>1e-12);return r}function Zg(t){t.k0||(t.k0=1);var e=t.b/t.a;t.e=Math.sqrt(1-e*e),t.lc=t.long0,t.rs=Math.sqrt(1+t.e*t.e*Math.pow(Math.cos(t.lat0),4)/(1-t.e*t.e));var r=Math.sin(t.lat0),n=Math.asin(r/t.rs),i=Math.sin(n);t.cp=sr(0,n,i)-t.rs*sr(t.e,t.lat0,r),t.n2=t.k0*t.a*Math.sqrt(1-t.e*t.e)/(1-t.e*t.e*r*r),t.xs=t.x0,t.ys=t.y0-t.n2*n}function Mf(t,e){var r=e.x,n=e.y,i=t.rs*(r-t.lc),o=t.cp+t.rs*sr(t.e,n,Math.sin(n)),s=Math.asin(Math.sin(i)/jr(o)),a=sr(0,s,Math.sin(s));return e.x=t.xs+t.n2*a,e.y=t.ys+t.n2*Math.atan(Gt(o)/Math.cos(i)),e}function yf(t,e){var r=e.x,n=e.y,i=Math.atan(Gt((r-t.xs)/t.n2)/Math.cos((n-t.ys)/t.n2)),o=Math.asin(Math.sin((n-t.ys)/t.n2)/jr((r-t.xs)/t.n2)),s=sr(0,o,Math.sin(o));return e.x=t.lc+i/t.rs,e.y=gf(t.e,(s-t.cp)/t.rs),e}function xf(t,e={}){let r={...t,lc:0,rs:0,cp:0,n2:0,xs:0,ys:0,...e};return Zg(r),r}var $s={name:"gstmerc",aliases:["gstmerg"],parameters:["lon_0","x_0","y_0","lat_0","k","k_0"],create(t){let e=F(t),r=xf(e);return B("gstmerc",t,r,Mf,yf)}};function Qg(t){t.a=6377397155e-3,t.es=.006674372230614,t.e=Math.sqrt(t.es),t.s45=.785398163397448,t.s90=2*t.s45,t.fi0=t.lat0,t.e2=t.es,t.e=Math.sqrt(t.e2),t.alfa=Math.sqrt(1+t.e2*Math.pow(Math.cos(t.fi0),4)/(1-t.e2)),t.uq=1.04216856380474,t.u0=Math.asin(Math.sin(t.fi0)/t.alfa),t.g=Math.pow((1+t.e*Math.sin(t.fi0))/(1-t.e*Math.sin(t.fi0)),t.alfa*t.e/2),t.k=Math.tan(t.u0/2+t.s45)/Math.pow(Math.tan(t.fi0/2+t.s45),t.alfa)*t.g,t.k1=t.k0,t.n0=t.a*Math.sqrt(1-t.e2)/(1-t.e2*Math.pow(Math.sin(t.fi0),2)),t.s0=1.37008346281555,t.n=Math.sin(t.s0),t.ro0=t.k1*t.n0/Math.tan(t.s0),t.ad=t.s90-t.uq}function _f(t,e){var r,n,i,o,s,a,c,l=e.x,h=e.y,u=C(l-t.long0,t.over);return r=Math.pow((1+t.e*Math.sin(h))/(1-t.e*Math.sin(h)),t.alfa*t.e/2),n=2*(Math.atan(t.k*Math.pow(Math.tan(h/2+t.s45),t.alfa)/r)-t.s45),i=-u*t.alfa,o=Math.asin(Math.cos(t.ad)*Math.sin(n)+Math.sin(t.ad)*Math.cos(n)*Math.cos(i)),s=Math.asin(Math.cos(n)*Math.sin(i)/Math.cos(o)),a=t.n*s,c=t.ro0*Math.pow(Math.tan(t.s0/2+t.s45),t.n)/Math.pow(Math.tan(o/2+t.s45),t.n),e.y=c*Math.cos(a)/1,e.x=c*Math.sin(a)/1,t.czech||(e.y*=-1,e.x*=-1),e}function wf(t,e){var r,n,i,o,s,a,c,l,h=e.x;e.x=e.y,e.y=h,t.czech||(e.y*=-1,e.x*=-1),a=Math.sqrt(e.x*e.x+e.y*e.y),s=Math.atan2(e.y,e.x),o=s/Math.sin(t.s0),i=2*(Math.atan(Math.pow(t.ro0/a,1/t.n)*Math.tan(t.s0/2+t.s45))-t.s45),r=Math.asin(Math.cos(t.ad)*Math.sin(i)-Math.sin(t.ad)*Math.cos(i)*Math.cos(o)),n=Math.asin(Math.cos(i)*Math.sin(o)/Math.cos(r)),e.x=t.long0-n/t.alfa,c=r,l=0;var u=0;do e.y=2*(Math.atan(Math.pow(t.k,-1/t.alfa)*Math.pow(Math.tan(r/2+t.s45),1/t.alfa)*Math.pow((1+t.e*Math.sin(c))/(1-t.e*Math.sin(c)),t.e/2))-t.s45),Math.abs(c-e.y)<1e-10&&(l=1),c=e.y,u+=1;while(l===0&&u<15);return u>=15?null:e}function Sf(t,e={}){let r={...t,s45:0,s90:0,fi0:0,e2:0,alfa:0,uq:0,u0:0,g:0,k:0,k1:0,n0:0,s0:0,n:0,ro0:0,ad:0,czech:!1,...e};return Qg(r),r}var Ys={name:"krovak",aliases:["Krovak","Krovak Modified","Krovak (North Orientated)","Krovak Modified (North Orientated)"],parameters:["lon_0","x_0","y_0","lat_0","k","k_0","czech","alpha","lat_ts"],flags:["czech"],create(t){let e=G(t.parameters,"alpha",30.28813972222222),r=G(t.parameters,"lat_ts",78.5);if(![30.28813972222222,30.28813975277778].some(o=>Math.abs(e-o)<=1e-10))throw new Error("Krovak requires its fixed cone-axis co-latitude");if(Math.abs(r-78.5)>1e-10)throw new Error("Krovak requires its fixed 78.5 degree pseudo standard parallel");let n=F(t);n.lat0=wt(t.parameters,"lat_0",49.5),n.long0=wt(t.parameters,"lon_0",24.83333333333333),n.k0=G(t.parameters,"k_0",G(t.parameters,"k",.9999));let i=Sf(n,{czech:Ke(t.parameters,"czech")});return B("krovak",t,i,_f,wf)}};function Ef(t,e){var r=e.x,n=e.y,i=C(r-t.long0,t.over),o=t.x0+t.a*i,s=t.y0+t.a*Math.log(Math.tan(Math.PI/4+n/2.5))*1.25;return e.x=o,e.y=s,e}function Tf(t,e){e.x-=t.x0,e.y-=t.y0;var r=C(t.long0+e.x/t.a,t.over),n=2.5*(Math.atan(Math.exp(.8*e.y/t.a))-Math.PI/4);return e.x=r,e.y=n,e}function bf(t,e={}){let r={...t,...e};return r}var Xs={name:"mill",aliases:["Miller_Cylindrical"],parameters:["lon_0","x_0","y_0"],create(t){let e=F(t),r=bf(e);return B("mill",t,r,Ef,Tf)}};function Jg(t){t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.long0=t.long0!==void 0?t.long0:0}function vf(t,e){var r=e.x,n=e.y,i=C(r-t.long0,t.over),o=n,s=Math.PI*Math.sin(n);for(let h=0;h<50;h++){if(Math.abs(Math.abs(n)-Math.PI/2)<1e-10){o=Math.sign(n)*Math.PI;break}var a=-(o+Math.sin(o)-s)/(1+Math.cos(o));if(o+=a,h===49)throw new Error("Mollweide forward did not converge");if(Math.abs(a)<1e-10)break}o/=2,Math.PI/2-Math.abs(n)<1e-10&&(i=0);var c=.900316316158*t.a*i*Math.cos(o)+t.x0,l=1.4142135623731*t.a*Math.sin(o)+t.y0;return e.x=c,e.y=l,e}function Pf(t,e){var r,n;e.x-=t.x0,e.y-=t.y0,n=e.y/(1.4142135623731*t.a),Math.abs(n)>.999999999999&&(n=Math.sign(n)*.999999999999),r=Math.asin(n);var i=C(t.long0+e.x/(.900316316158*t.a*Math.cos(r)),t.over);!t.over&&i<-Math.PI&&(i=-Math.PI),!t.over&&i>Math.PI&&(i=Math.PI),n=(2*r+Math.sin(2*r))/Math.PI,Math.abs(n)>1&&(n=Math.sign(n));var o=Math.asin(n);return e.x=i,e.y=o,e}function Rf(t,e={}){let r={...t,...e};return Jg(r),r}var Ks={name:"moll",aliases:["Mollweide"],parameters:["lon_0","x_0","y_0"],create(t){let e=F(t),r=Rf(e);return B("moll",t,r,vf,Pf)}};function e2(t){t.A=[],t.A[1]=.6399175073,t.A[2]=-.1358797613,t.A[3]=.063294409,t.A[4]=-.02526853,t.A[5]=.0117879,t.A[6]=-.0055161,t.A[7]=.0026906,t.A[8]=-.001333,t.A[9]=67e-5,t.A[10]=-34e-5,t.B_re=[],t.B_im=[],t.B_re[1]=.7557853228,t.B_im[1]=0,t.B_re[2]=.249204646,t.B_im[2]=.003371507,t.B_re[3]=-.001541739,t.B_im[3]=.04105856,t.B_re[4]=-.10162907,t.B_im[4]=.01727609,t.B_re[5]=-.26623489,t.B_im[5]=-.36249218,t.B_re[6]=-.6870983,t.B_im[6]=-1.1651967,t.C_re=[],t.C_im=[],t.C_re[1]=1.3231270439,t.C_im[1]=0,t.C_re[2]=-.577245789,t.C_im[2]=-.007809598,t.C_re[3]=.508307513,t.C_im[3]=-.112208952,t.C_re[4]=-.15094762,t.C_im[4]=.18200602,t.C_re[5]=1.01418179,t.C_im[5]=1.64497696,t.C_re[6]=1.9660549,t.C_im[6]=2.5127645,t.D=[],t.D[1]=1.5627014243,t.D[2]=.5185406398,t.D[3]=-.03333098,t.D[4]=-.1052906,t.D[5]=-.0368594,t.D[6]=.007317,t.D[7]=.0122,t.D[8]=.00394,t.D[9]=-.0013}function Cf(t,e){var r,n=e.x,i=e.y,o=i-t.lat0,s=n-t.long0,a=o/ws*1e-5,c=s,l=1,h=0;for(r=1;r<=10;r++)l=l*a,h=h+t.A[r]*l;var u=h,f=c,d=1,m=0,p,g,y=0,x=0;for(r=1;r<=6;r++)p=d*u-m*f,g=m*u+d*f,d=p,m=g,y=y+t.B_re[r]*d-t.B_im[r]*m,x=x+t.B_im[r]*d+t.B_re[r]*m;return e.x=x*t.a+t.x0,e.y=y*t.a+t.y0,e}function Af(t,e){var r,n=e.x,i=e.y,o=n-t.x0,s=i-t.y0,a=s/t.a,c=o/t.a,l=1,h=0,u,f,d=0,m=0;for(r=1;r<=6;r++)u=l*a-h*c,f=h*a+l*c,l=u,h=f,d=d+t.C_re[r]*l-t.C_im[r]*h,m=m+t.C_im[r]*l+t.C_re[r]*h;for(var p=0;p<t.iterations;p++){var g=d,y=m,x,w,_=a,S=c;for(r=2;r<=6;r++)x=g*d-y*m,w=y*d+g*m,g=x,y=w,_=_+(r-1)*(t.B_re[r]*g-t.B_im[r]*y),S=S+(r-1)*(t.B_im[r]*g+t.B_re[r]*y);g=1,y=0;var E=t.B_re[1],v=t.B_im[1];for(r=2;r<=6;r++)x=g*d-y*m,w=y*d+g*m,g=x,y=w,E=E+r*(t.B_re[r]*g-t.B_im[r]*y),v=v+r*(t.B_im[r]*g+t.B_re[r]*y);var T=E*E+v*v;d=(_*E+S*v)/T,m=(S*E-_*v)/T}var I=d,P=m,R=1,N=0;for(r=1;r<=9;r++)R=R*I,N=N+t.D[r]*R;var q=t.lat0+N*ws*1e5,O=t.long0+P;return e.x=O,e.y=q,e}function If(t,e={}){let r={...t,A:[],B_re:[],B_im:[],C_re:[],C_im:[],D:[],iterations:1,...e};return e2(r),r}var Zs={name:"nzmg",aliases:["New_Zealand_Map_Grid"],parameters:["lon_0","x_0","y_0","lat_0","iterations"],create(t){let e=F(t),r=G(t.parameters,"iterations",1);if(!Number.isInteger(r)||r<0||r>10)throw new Error("NZMG iterations must be an integer from 0 to 10");if(!Object.prototype.hasOwnProperty.call(t.parameters,"lat_0")||!Object.prototype.hasOwnProperty.call(t.parameters,"lon_0"))throw new Error("NZMG requires lat_0 and lon_0");let n=If(e,{iterations:r});return B("nzmg",t,n,Cf,Af)}};var ar=1e-7;function t2(t){return t.no_uoff||t.no_off||["hotineobliquemercator","hotineobliquemercatorvarianta","hotineobliquemercatorazimuthnaturalorigin"].includes(t.projName.toLowerCase().replace(/[ _-]/g,""))}function r2(t){var e,r,n,i,o,s,a,c,l,h,u=0,f,d=0,m=0,p=0,g=0,y=0,x=0;t.k0||(t.k0=1),t.no_off=t2(t),t.no_rot=t.no_rot;var w=!1;Number.isFinite(t.alpha)&&(w=!0);var _=!1;if(Number.isFinite(t.rectified_grid_angle)&&(_=!0),w&&(x=t.alpha),_&&(u=t.rectified_grid_angle,w||(x=0,w=!0)),w||_)d=t.longc;else if(m=t.long1,g=t.lat1,p=t.long2,y=t.lat2,Math.abs(g-y)<=ar||Math.abs(g)<=ar||Math.abs(Math.abs(g)-b)<=ar||Math.abs(Math.abs(t.lat0)-b)<=ar||Math.abs(Math.abs(y)-b)<=ar)throw new Error;var S=1-t.es;if(r=Math.sqrt(S),Math.abs(t.lat0)>1e-10?(c=Math.sin(t.lat0),n=Math.cos(t.lat0),e=1-t.es*c*c,t.B=n*n,t.B=Math.sqrt(1+t.es*t.B*t.B/S),t.A=t.B*t.k0*r/e,i=t.B*r/(n*Math.sqrt(e)),o=i*i-1,o<=0?o=0:(o=Math.sqrt(o),t.lat0<0&&(o=-o)),t.E=o+=i,t.E*=Math.pow(Le(t.e,t.lat0,c),t.B)):(t.B=1/r,t.A=t.k0,t.E=i=o=1),w||_){w?(f=Math.asin(Math.sin(x)/i),_||(u=x)):(f=u,x=Math.asin(i*Math.sin(f)));let E=.5*(o-1/o)*Math.tan(f);i>1&&Math.abs(Math.cos(x))<=8*Number.EPSILON?E=Math.sign(t.lat0)*Math.sign(Math.sin(x)):Math.abs(E)>1&&Math.abs(E)<=1+8*Number.EPSILON&&(E=Math.sign(E)),t.lam0=d-Math.asin(E)/t.B}else s=Math.pow(Le(t.e,g,Math.sin(g)),t.B),a=Math.pow(Le(t.e,y,Math.sin(y)),t.B),o=t.E/s,l=(a-s)/(a+s),h=t.E*t.E,h=(h-a*s)/(h+a*s),e=m-p,e<-Math.PI?p-=Et:e>Math.PI&&(p+=Et),t.lam0=C(.5*(m+p)-Math.atan(h*Math.tan(.5*t.B*(m-p))/l)/t.B,t.over),f=Math.atan(2*Math.sin(t.B*C(m-t.lam0,t.over))/(o-1/o)),u=x=Math.asin(i*Math.sin(f));t.singam=Math.sin(f),t.cosgam=Math.cos(f),t.sinrot=Math.sin(u),t.cosrot=Math.cos(u),t.rB=1/t.B,t.ArB=t.A*t.rB,t.BrA=1/t.ArB,t.no_off?t.u_0=0:(t.u_0=Math.abs(t.ArB*Math.atan(Math.sqrt(i*i-1)/Math.cos(x))),t.lat0<0&&(t.u_0=-t.u_0)),o=.5*f,t.v_pole_n=t.ArB*Math.log(Math.tan(V-o)),t.v_pole_s=t.ArB*Math.log(Math.tan(V+o))}function Nf(t,e){var r=e,n,i,o,s,a,c,l,h;if(e.x=e.x-t.lam0,Math.abs(Math.abs(e.y)-b)>1e-10){if(a=t.E/Math.pow(Le(t.e,e.y,Math.sin(e.y)),t.B),c=1/a,n=.5*(a-c),i=.5*(a+c),s=Math.sin(t.B*e.x),o=(n*t.singam-s*t.cosgam)/i,Math.abs(Math.abs(o)-1)<1e-10)throw new Error;h=.5*t.ArB*Math.log((1-o)/(1+o)),c=Math.cos(t.B*e.x),Math.abs(c)<ar?l=t.A*e.x:l=t.ArB*Math.atan2(n*t.cosgam+s*t.singam,c)}else h=e.y>0?t.v_pole_n:t.v_pole_s,l=t.ArB*e.y;return t.no_rot?(r.x=l,r.y=h):(l-=t.u_0,r.x=h*t.cosrot+l*t.sinrot,r.y=l*t.cosrot-h*t.sinrot),r.x=t.a*r.x+t.x0,r.y=t.a*r.y+t.y0,r}function Of(t,e){var r,n,i,o,s,a,c,l=e;if(e.x=(e.x-t.x0)*(1/t.a),e.y=(e.y-t.y0)*(1/t.a),t.no_rot?(n=e.y,r=e.x):(n=e.x*t.cosrot-e.y*t.sinrot,r=e.y*t.cosrot+e.x*t.sinrot+t.u_0),i=Math.exp(-t.BrA*n),o=.5*(i-1/i),s=.5*(i+1/i),a=Math.sin(t.BrA*r),c=(a*t.cosgam+o*t.singam)/s,Math.abs(Math.abs(c)-1)<1e-10)l.x=0,l.y=c<0?-b:b;else{if(l.y=t.E/Math.sqrt((1+c)/(1-c)),l.y=Ot(t.e,Math.pow(l.y,1/t.B)),l.y===1/0)throw new Error;l.x=-t.rB*Math.atan2(o*t.cosgam-a*t.singam,Math.cos(t.BrA*r))}return l.x+=t.lam0,l}function Lf(t,e={}){let r={...t,no_off:!1,no_rot:!1,alpha:NaN,rectified_grid_angle:NaN,longc:0,long1:0,long2:0,B:0,A:0,E:0,lam0:0,singam:0,cosgam:0,sinrot:0,cosrot:0,rB:0,ArB:0,BrA:0,u_0:0,v_pole_n:0,v_pole_s:0,no_uoff:!1,projName:"",...e};return r2(r),r}var Qs={name:"omerc",aliases:["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_variant_A","Hotine_Oblique_Mercator_Variant_B","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Two_Point_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","Oblique_Mercator"],parameters:["lon_0","x_0","y_0","lat_0","k","k_0","alpha","gamma","lonc","lon_1","lon_2","lat_1","lat_2","no_off","no_uoff","no_rot"],flags:["no_off","no_uoff","no_rot"],create(t){let e=F(t);if(Math.abs(e.lat0)>=Math.PI/2)throw new Error("Oblique Mercator origin must be away from the poles");let n=Object.prototype.hasOwnProperty.call(t.parameters,"alpha")||Object.prototype.hasOwnProperty.call(t.parameters,"gamma")?["lonc"]:["lon_1","lat_1","lon_2","lat_2"];for(let o of n)if(!Object.prototype.hasOwnProperty.call(t.parameters,o))throw new Error("Oblique Mercator requires "+o);let i=Lf(e,{projName:t.parameters.proj||"omerc",alpha:G(t.parameters,"alpha",NaN)*Math.PI/180,rectified_grid_angle:G(t.parameters,"gamma",NaN)*Math.PI/180,longc:G(t.parameters,"lonc",0)*Math.PI/180,long1:G(t.parameters,"lon_1",0)*Math.PI/180,long2:G(t.parameters,"lon_2",0)*Math.PI/180,no_off:Ke(t.parameters,"no_off"),no_uoff:Ke(t.parameters,"no_uoff"),no_rot:Ke(t.parameters,"no_rot")});return B("omerc",t,i,Nf,Of)}};function n2(t){t.sin_p14=Math.sin(t.lat0||0),t.cos_p14=Math.cos(t.lat0||0)}function Gf(t,e){var r,n,i,o,s,a,c,l,h=e.x,u=e.y;return i=C(h-(t.long0||0),t.over),r=Math.sin(u),n=Math.cos(u),o=Math.cos(i),a=t.sin_p14*r+t.cos_p14*n*o,s=1,(a>0||Math.abs(a)<=1e-10)&&(c=(t.x0||0)+t.a*s*n*Math.sin(i),l=(t.y0||0)+t.a*s*(t.cos_p14*r-t.sin_p14*n*o)),e.x=c,e.y=l,e}function zf(t,e){var r,n,i,o,s,a,c,l,h;if(e.x-=t.x0||0,e.y-=t.y0||0,r=Math.sqrt(e.x*e.x+e.y*e.y),r>t.a*(1+1e-14))throw new Error("Coordinate is outside the orthographic disk");return n=Te(r/t.a),i=Math.sin(n),o=Math.cos(n),l=t.long0||0,h=t.lat0||0,a=l,Math.abs(r)<=1e-10?(c=h,e.x=a,e.y=c,e):(c=Te(o*t.sin_p14+e.y*i*t.cos_p14/r),s=Math.abs(h)-b,Math.abs(s)<=1e-10?(h>=0?a=C(l+Math.atan2(e.x,-e.y),t.over):a=C(l-Math.atan2(-e.x,e.y),t.over),e.x=a,e.y=c,e):(a=C(l+Math.atan2(e.x*i,r*t.cos_p14*o-e.y*t.sin_p14*i),t.over),e.x=a,e.y=c,e))}function qf(t,e={}){let r={...t,sin_p14:0,cos_p14:0,...e};return n2(r),r}var Js={name:"ortho",aliases:[],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=F(t),r=qf(e);return B("ortho",t,r,Gf,zf,Tt(e,0,!0))}};function Ff(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function Bf(t){return .375*t*(1+.25*t*(1+.46875*t))}function Df(t){return .05859375*t*t*(1+.75*t)}function kf(t){return t*t*t*(35/3072)}function Li(t,e,r,n,i){return t*i-e*Math.sin(2*i)+r*Math.sin(4*i)-n*Math.sin(6*i)}var Uf=20;function i2(t){t.temp=t.b/t.a,t.es=1-Math.pow(t.temp,2),t.e=Math.sqrt(t.es),t.e0=Ff(t.es),t.e1=Bf(t.es),t.e2=Df(t.es),t.e3=kf(t.es),t.ml0=t.a*Li(t.e0,t.e1,t.e2,t.e3,t.lat0)}function Vf(t,e){var r=e.x,n=e.y,i,o,s,a=C(r-t.long0,t.over);if(s=a*Math.sin(n),t.sphere)Math.abs(n)<=1e-10?(i=t.a*a,o=-1*t.a*t.lat0):(i=t.a*Math.sin(s)/Math.tan(n),o=t.a*(Ze(n-t.lat0)+(1-Math.cos(s))/Math.tan(n)));else if(Math.abs(n)<=1e-10)i=t.a*a,o=-1*t.ml0;else{var c=Hr(t.a,t.e,Math.sin(n))/Math.tan(n);i=c*Math.sin(s),o=t.a*Li(t.e0,t.e1,t.e2,t.e3,n)-t.ml0+c*(1-Math.cos(s))}return e.x=i+t.x0,e.y=o+t.y0,e}function jf(t,e){var r,n,i,o,s,a,c,l,h;if(i=e.x-t.x0,o=e.y-t.y0,t.sphere)if(Math.abs(o+t.a*t.lat0)<=1e-10)r=C(i/t.a+t.long0,t.over),n=0;else{a=t.lat0+o/t.a,c=i*i/t.a/t.a+a*a,l=a;var u;for(s=Uf;s;--s)if(u=Math.tan(l),h=-1*(a*(l*u+1)-l-.5*(l*l+c)*u)/((l-a)/u-1),l+=h,Math.abs(h)<=1e-10){n=l;break}r=C(t.long0+Math.asin(i*Math.tan(l)/t.a)/Math.sin(n),t.over)}else if(Math.abs(o+t.ml0)<=1e-10)n=0,r=C(t.long0+i/t.a,t.over);else{a=(t.ml0+o)/t.a,c=i*i/t.a/t.a+a*a,l=a;var f,d,m,p,g;for(s=Uf;s;--s)if(g=t.e*Math.sin(l),f=Math.sqrt(1-g*g)*Math.tan(l),d=t.a*Li(t.e0,t.e1,t.e2,t.e3,l),m=t.e0-2*t.e1*Math.cos(2*l)+4*t.e2*Math.cos(4*l)-6*t.e3*Math.cos(6*l),p=d/t.a,h=(a*(f*p+1)-p-.5*f*(p*p+c))/(t.es*Math.sin(2*l)*(p*p+c-2*a*p)/(4*f)+(a-p)*(f*m-2/Math.sin(2*l))-m),l-=h,Math.abs(h)<=1e-10){n=l;break}f=Math.sqrt(1-t.es*Math.pow(Math.sin(n),2))*Math.tan(n),r=C(t.long0+Math.asin(i*f/t.a)/Math.sin(n),t.over)}return e.x=r,e.y=n,e}function Wf(t,e={}){let r={...t,temp:0,e0:0,e1:0,e2:0,e3:0,ml0:0,...e};return i2(r),r}var ea={name:"poly",aliases:["Polyconic","American_Polyconic"],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=F(t),r=Wf(e);return B("poly",t,r,Vf,jf)}};var Q={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},W={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function o2(t){t.x0=t.x0||0,t.y0=t.y0||0,t.lat0=t.lat0||0,t.long0=t.long0||0,t.lat_ts=t.lat_ts||0,t.lat0>=b-V/2?t.face=Q.TOP:t.lat0<=-(b-V/2)?t.face=Q.BOTTOM:Math.abs(t.long0)<=V?t.face=Q.FRONT:Math.abs(t.long0)<=b+V?t.face=t.long0>0?Q.RIGHT:Q.LEFT:t.face=Q.BACK,t.es!==0&&(t.one_minus_f=1-(t.a-t.b)/t.a,t.one_minus_f_squared=t.one_minus_f*t.one_minus_f)}function Hf(t,e){var r=e,n,i,o,s,a,c,l=0;if(e.x-=t.long0,t.es!==0?n=Math.atan(t.one_minus_f_squared*Math.tan(e.y)):n=e.y,i=e.x,t.face===Q.TOP)s=b-n,i>=V&&i<=b+V?(l=W.AREA_0,o=i-b):i>b+V||i<=-(b+V)?(l=W.AREA_1,o=i>0?i-Z:i+Z):i>-(b+V)&&i<=-V?(l=W.AREA_2,o=i+b):(l=W.AREA_3,o=i);else if(t.face===Q.BOTTOM)s=b+n,i>=V&&i<=b+V?(l=W.AREA_0,o=-i+b):i<V&&i>=-V?(l=W.AREA_1,o=-i):i<-V&&i>=-(b+V)?(l=W.AREA_2,o=-i-b):(l=W.AREA_3,o=i>0?-i+Z:-i-Z);else{var h,u,f,d,m,p,g;t.face===Q.RIGHT?i=cr(i,+b):t.face===Q.BACK?i=cr(i,+Z):t.face===Q.LEFT&&(i=cr(i,-b)),d=Math.sin(n),m=Math.cos(n),p=Math.sin(i),g=Math.cos(i),h=m*g,u=m*p,f=d,t.face===Q.FRONT?(s=Math.acos(h),o=Gi(s,f,u)):t.face===Q.RIGHT?(s=Math.acos(u),o=Gi(s,f,-h)):t.face===Q.BACK?(s=Math.acos(-h),o=Gi(s,f,-u)):t.face===Q.LEFT?(s=Math.acos(-u),o=Gi(s,f,h)):s=o=0,Math.abs(o)<=V?l=W.AREA_0:o>V&&o<=b+V?(l=W.AREA_1,o-=b):o>b+V||o<=-(b+V)?(l=W.AREA_2,o=o>=0?o-Z:o+Z):(l=W.AREA_3,o+=b)}return c=Math.atan(12/Z*(o+Math.acos(Math.sin(o)*Math.cos(V))-b)),a=Math.sqrt((1-Math.cos(s))/(Math.cos(c)*Math.cos(c))/(1-Math.cos(Math.atan(1/Math.cos(o))))),l===W.AREA_1?c+=b:l===W.AREA_2?c+=Z:l===W.AREA_3&&(c+=1.5*Z),r.x=a*Math.cos(c),r.y=a*Math.sin(c),r.x=r.x*t.a+t.x0,r.y=r.y*t.a+t.y0,e}function $f(t,e){var r=0,n=0,i,o,s,a,c,l,h,u,f,d=0;if(e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,o=Math.atan(Math.sqrt(e.x*e.x+e.y*e.y)),i=Math.atan2(e.y,e.x),e.x>=0&&e.x>=Math.abs(e.y)?d=W.AREA_0:e.y>=0&&e.y>=Math.abs(e.x)?(d=W.AREA_1,i-=b):e.x<0&&-e.x>=Math.abs(e.y)?(d=W.AREA_2,i=i<0?i+Z:i-Z):(d=W.AREA_3,i+=b),f=Z/12*Math.tan(i),c=Math.sin(f)/(Math.cos(f)-1/Math.sqrt(2)),l=Math.atan(c),s=Math.cos(i),a=Math.tan(o),h=1-s*s*a*a*(1-Math.cos(Math.atan(1/Math.cos(l)))),h<-1?h=-1:h>1&&(h=1),t.face===Q.TOP)u=Math.acos(h),n=b-u,d===W.AREA_0?r=l+b:d===W.AREA_1?r=l<0?l+Z:l-Z:d===W.AREA_2?r=l-b:r=l;else if(t.face===Q.BOTTOM)u=Math.acos(h),n=u-b,d===W.AREA_0?r=-l+b:d===W.AREA_1?r=-l:d===W.AREA_2?r=-l-b:r=l<0?-l-Z:-l+Z;else{var m,p,g;m=h,f=m*m,f>=1?g=0:g=Math.sqrt(1-f)*Math.sin(l),f+=g*g,f>=1?p=0:p=Math.sqrt(1-f),d===W.AREA_1?(f=p,p=-g,g=f):d===W.AREA_2?(p=-p,g=-g):d===W.AREA_3&&(f=p,p=g,g=-f),t.face===Q.RIGHT?(f=m,m=-p,p=f):t.face===Q.BACK?(m=-m,p=-p):t.face===Q.LEFT&&(f=m,m=p,p=-f),n=Math.acos(-g)-b,r=Math.atan2(p,m),t.face===Q.RIGHT?r=cr(r,-b):t.face===Q.BACK?r=cr(r,-Z):t.face===Q.LEFT&&(r=cr(r,+b))}if(t.es!==0){var y,x,w;y=n<0?1:0,x=Math.tan(n),w=t.b/Math.sqrt(x*x+t.one_minus_f_squared),n=Math.atan(Math.sqrt(t.a*t.a-w*w)/(t.one_minus_f*w)),y&&(n=-n)}return r+=t.long0,e.x=r,e.y=n,e}function Gi(t,e,r){return t<1e-10?0:Math.atan2(e,r)}function cr(t,e){var r=t+e;return r<-Z?r+=Et:r>+Z&&(r-=Et),r}function Yf(t,e={}){let r={...t,face:0,one_minus_f:0,one_minus_f_squared:0,...e};return o2(r),r}var ta={name:"qsc",aliases:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube"],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=F(t),r=Yf(e);return B("qsc",t,r,Hf,$f)}};var lr=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-986701e-12],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,18736e-12],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,934959e-12],[.7986,-.00755338,-500009e-10,935324e-12],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],bt=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-126793e-14,422642e-15],[.124,.0124,507171e-14,-160604e-14],[.186,.0123999,-190189e-13,600152e-14],[.248,.0124002,710039e-13,-224e-10],[.31,.0123992,-264997e-12,835986e-13],[.372,.0124029,988983e-12,-311994e-12],[.434,.0123893,-369093e-11,-435621e-12],[.4958,.0123198,-102252e-10,-345523e-12],[.5571,.0121916,-154081e-10,-582288e-12],[.6176,.0119938,-241424e-10,-525327e-12],[.6769,.011713,-320223e-10,-516405e-12],[.7346,.0113541,-397684e-10,-609052e-12],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-140374e-14],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]];lr=lr.map(t=>t.map(Math.fround));bt=bt.map(t=>t.map(Math.fround));var Xf=.8487,Kf=1.3523,Zf=_s/5,s2=1/Zf,zt=18,zi=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))},a2=function(t,e){return t[1]+e*(2*t[2]+e*3*t[3])};function c2(t,e,r,n,i){for(var o=r;i;--i){var s=(zi(t,o)-e)/a2(t,o);if(o-=s,Math.abs(s)<n)break}return o}function l2(t){t.x0=t.x0||0,t.y0=t.y0||0,t.long0=t.long0||0,t.es=0}function Qf(t,e){var r=C(e.x-t.long0,t.over),n=Math.abs(e.y),i=Math.floor(n*Zf+1e-15);i<0?i=0:i>=zt&&(i=zt),n=_s*(n-s2*i);var o=zi(lr[i],n)*r,s=zi(bt[i],n);return e.y<0&&(s=-s),e.x=o*t.a*Xf+t.x0,e.y=s*t.a*Kf+t.y0,e}function Jf(t,e){var r=e.y,n=e;n.x=(n.x-t.x0)/(t.a*Xf),n.y=Math.abs(r-t.y0)/(t.a*Kf);for(let a=0;a<=zt;a++)if(Math.abs(n.y-bt[a][0])<=8*Number.EPSILON)return n.x=C(n.x/lr[a][0]+t.long0,t.over),n.y=(r<t.y0?-1:1)*a*5*xs,n;if(n.y>=1)n.x/=lr[zt][0],n.y=r<0?-b:b;else{var i=Math.floor(n.y*zt);for(i<0?i=0:i>=zt&&(i=zt-1);;)if(bt[i][0]>n.y)--i;else if(bt[i+1][0]<=n.y)++i;else break;var o=bt[i],s=5*(n.y-o[0])/(bt[i+1][0]-o[0]);s=c2(o,n.y,s,1e-10,100),n.x/=zi(lr[i],s),n.y=(5*i+s)*xs,r<0&&(n.y=-n.y)}return n.x=C(n.x+t.long0,t.over),n}function e0(t,e={}){let r={...t,...e};return l2(r),r}var ra={name:"robin",aliases:["Robinson"],parameters:["lon_0","x_0","y_0"],create(t){let e=F(t),r=e0(e);return B("robin",t,r,Qf,Jf)}};var na={name:"sinu",aliases:["Sinusoidal"],parameters:["lon_0","x_0","y_0"],create(t){let e=F(t),r=Ju(e);return B("sinu",t,r,Ii,Ni)}};function h2(t){t.k0||(t.k0=1);var e=t.lat0;t.lambda0=t.long0;var r=Math.sin(e),n=t.a,i=t.rf,o=1/i,s=2*o-Math.pow(o,2);t.e=Math.sqrt(s);var a=t.e;t.R=t.k0*n*Math.sqrt(1-s)/(1-s*Math.pow(r,2)),t.alpha=Math.sqrt(1+s/(1-s)*Math.pow(Math.cos(e),4)),t.b0=Math.asin(r/t.alpha);var c=Math.log(Math.tan(Math.PI/4+t.b0/2)),l=Math.log(Math.tan(Math.PI/4+e/2)),h=Math.log((1+a*r)/(1-a*r));t.K=c-t.alpha*l+t.alpha*a/2*h}function t0(t,e){var r=Math.log(Math.tan(Math.PI/4-e.y/2)),n=t.e/2*Math.log((1+t.e*Math.sin(e.y))/(1-t.e*Math.sin(e.y))),i=-t.alpha*(r+n)+t.K,o=2*(Math.atan(Math.exp(i))-Math.PI/4),s=t.alpha*(e.x-t.lambda0),a=Math.atan(Math.sin(s)/(Math.sin(t.b0)*Math.tan(o)+Math.cos(t.b0)*Math.cos(s))),c=Math.asin(Math.cos(t.b0)*Math.sin(o)-Math.sin(t.b0)*Math.cos(o)*Math.cos(s));return e.y=t.R/2*Math.log((1+Math.sin(c))/(1-Math.sin(c)))+t.y0,e.x=t.R*a+t.x0,e}function r0(t,e){for(var r=e.x-t.x0,n=e.y-t.y0,i=r/t.R,o=2*(Math.atan(Math.exp(n/t.R))-Math.PI/4),s=Math.asin(Math.cos(t.b0)*Math.sin(o)+Math.sin(t.b0)*Math.cos(o)*Math.cos(i)),a=Math.atan(Math.sin(i)/(Math.cos(t.b0)*Math.cos(i)-Math.sin(t.b0)*Math.tan(o))),c=t.lambda0+a/t.alpha,l=0,h=s,u=-1e3,f=0;Math.abs(h-u)>1e-7;){if(++f>20)return;l=1/t.alpha*(Math.log(Math.tan(Math.PI/4+s/2))-t.K)+t.e*Math.log(Math.tan(Math.PI/4+Math.asin(t.e*Math.sin(h))/2)),u=h,h=2*Math.atan(Math.exp(l))-Math.PI/2}return e.x=c,e.y=h,e}function n0(t,e={}){let r={...t,lambda0:0,rf:0,R:0,alpha:0,b0:0,K:0,...e};return h2(r),r}var ia={name:"somerc",aliases:[],parameters:["lon_0","x_0","y_0","lat_0","k","k_0"],create(t){let e=F(t),r=n0(e,{rf:e.a===e.b?1/0:1/(1-e.b/e.a)});return B("somerc",t,r,t0,r0)}};var ge={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3};function u2(t){if(Math.abs(Math.abs(t.lat0)-b)<1e-10?t.mode=t.lat0<0?ge.S_POLE:ge.N_POLE:Math.abs(t.lat0)<1e-10?t.mode=ge.EQUIT:(t.mode=ge.OBLIQ,t.sinph0=Math.sin(t.lat0),t.cosph0=Math.cos(t.lat0)),t.pn1=t.h/t.a,t.pn1<=0||t.pn1>1e10)throw new Error("Invalid height");t.p=1+t.pn1,t.rp=1/t.p,t.h1=1/t.pn1,t.pfact=(t.p+1)*t.h1,t.es=0;var e=t.tilt,r=t.azi;t.cg=Math.cos(r),t.sg=Math.sin(r),t.cw=Math.cos(e),t.sw=Math.sin(e)}function i0(t,e){e.x-=t.long0;var r=Math.sin(e.y),n=Math.cos(e.y),i=Math.cos(e.x),o,s;switch(t.mode){case ge.OBLIQ:s=t.sinph0*r+t.cosph0*n*i;break;case ge.EQUIT:s=n*i;break;case ge.S_POLE:s=-r;break;case ge.N_POLE:s=r;break}switch(s=t.pn1/(t.p-s),o=s*n*Math.sin(e.x),t.mode){case ge.OBLIQ:s*=t.cosph0*r-t.sinph0*n*i;break;case ge.EQUIT:s*=r;break;case ge.N_POLE:s*=-(n*i);break;case ge.S_POLE:s*=n*i;break}var a,c;return a=s*t.cg+o*t.sg,c=1/(a*t.sw*t.h1+t.cw),o=(o*t.cg-s*t.sg)*t.cw*c,s=a*c,e.x=o*t.a,e.y=s*t.a,e}function o0(t,e){e.x/=t.a,e.y/=t.a;var r=e.x,n=e.y,i,o,s;s=1/(t.pn1-e.y*t.sw),i=t.pn1*e.x*s,o=t.pn1*e.y*t.cw*s,e.x=i*t.cg+o*t.sg,e.y=o*t.cg-i*t.sg;var a=oe(e.x,e.y);if(Math.abs(a)<1e-10)r=0,n=t.lat0;else{var c,l;switch(l=1-a*a*t.pfact,l=(t.p-Math.sqrt(l))/(t.pn1/a+a/t.pn1),c=Math.sqrt(1-l*l),t.mode){case ge.OBLIQ:n=Math.asin(c*t.sinph0+e.y*l*t.cosph0/a),e.y=(c-t.sinph0*Math.sin(n))*a,e.x*=l*t.cosph0;break;case ge.EQUIT:n=Math.asin(e.y*l/a),e.y=c*a,e.x*=l;break;case ge.N_POLE:n=Math.asin(c),e.y=-e.y;break;case ge.S_POLE:n=-Math.asin(c);break}r=Math.atan2(e.x,e.y)}return e.x=r+t.long0,e.y=n,e}function s0(t,e={}){let r={...t,mode:0,sinph0:0,cosph0:0,pn1:0,h:0,p:0,rp:0,h1:0,pfact:0,tilt:0,azi:0,cg:0,sg:0,cw:0,sw:0,...e};return u2(r),r}var oa={name:"tpers",aliases:["Tilted_Perspective"],parameters:["lon_0","x_0","y_0","lat_0","h","tilt","azi"],create(t){let e=F(t),r=G(t.parameters,"h",1e5),n=G(t.parameters,"tilt",0)*Math.PI/180,i=G(t.parameters,"azi",0)*Math.PI/180;if(Math.abs(n)>=Math.PI/2)throw new Error("Perspective tilt must be between -90 and 90 degrees");let o=s0(e,{h:r,tilt:n,azi:i});return B("tpers",t,o,i0,o0,Tt(e,1/(1+r/e.a)))}};function f2(t){t.R=t.a}function a0(t,e){var r=e.x,n=e.y,i=C(r-t.long0,t.over),o,s;if(Math.abs(n)<=1e-10)return o=t.x0+t.R*i,s=t.y0,e.x=o,e.y=s,e;var a=Te(2*Math.abs(n/Math.PI));if(Math.abs(i)<=1e-10||Math.abs(Math.abs(n)-b)<=1e-10)return o=t.x0,n>=0?s=t.y0+Math.PI*t.R*Math.tan(.5*a):s=t.y0+Math.PI*t.R*-Math.tan(.5*a),e.x=o,e.y=s,e;var c=.5*Math.abs(Math.PI/i-i/Math.PI),l=c*c,h=Math.sin(a),u=Math.cos(a),f=u/(h-2*Math.sin(a/2)**2),d=f*f,m=f*(2/h-1),p=m*m,g=Math.sqrt(l*(f-p)*(f-p)-(p+l)*(d-p)),y=Math.PI*t.R*(p-d)/(g-c*(f-p));i<0&&(y=-y),o=t.x0+y;var x=l+f;return y=Math.PI*t.R*(l*(2*f-1)+d)/(m*x+c*Math.sqrt((p+l)*(l+1)-x*x)),n>=0?s=t.y0+y:s=t.y0-y,e.x=o,e.y=s,e}function c0(t,e){var r,n,i,o,s,a,c,l,h,u,f,d,m;return e.x-=t.x0,e.y-=t.y0,Math.abs(e.y)<1e-10?(e.x=C(t.long0+e.x/t.R,t.over),e.y=0,e):(f=Math.PI*t.R,i=e.x/f,o=e.y/f,s=i*i+o*o,a=-Math.abs(o)*(1+s),c=a-2*o*o+i*i,l=-2*a+1+2*o*o+s*s,m=o*o/l+(2*c*c*c/l/l/l-9*a*c/l/l)/27,h=(a-c*c/3/l)/l,u=2*Math.sqrt(-h/3),f=3*m/h/u,Math.abs(f)>1&&(f>=0?f=1:f=-1),d=Math.acos(f)/3,e.y>=0?n=(-u*Math.cos(d+Math.PI/3)-c/3/l)*Math.PI:n=-(-u*Math.cos(d+Math.PI/3)-c/3/l)*Math.PI,Math.abs(i)<1e-10?r=t.long0:r=C(t.long0+2*Math.PI*i/(Math.sqrt(1+2*(i*i-o*o)+s*s)+1-s),t.over),e.x=r,e.y=n,e)}function l0(t,e={}){let r={...t,R:0,...e};return f2(r),r}var sa={name:"vandg",aliases:["Van_der_Grinten_I","VanDerGrinten","Van_der_Grinten"],parameters:["lon_0","x_0","y_0"],create(t){let e=F(t),r=l0(e);return B("vandg",t,r,a0,c0)}};var h0=["o_proj","o_alpha","o_lon_c","o_lat_c","o_lon_p","o_lat_p","o_lon_1","o_lat_1","o_lon_2","o_lat_2"],aa=t=>t.toLowerCase().replace(/[ _-]/g,""),ca=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Qe=(t,e)=>G(t,e,0)*Math.PI/180;function d2(t){let e=[["o_alpha","o_lon_c","o_lat_c"],["o_lat_p","o_lon_p"],["o_lon_1","o_lat_1","o_lon_2","o_lat_2"]],r=e.find(c=>c.some(l=>ca(t,l)));if(!r)throw new Error("Oblique transformation requires a rotation parameter set");for(let c of r){if(!ca(t,c))throw new Error("Oblique transformation requires "+c);if(c.includes("lat")&&Math.abs(Qe(t,c))>Math.PI/2)throw new Error("Invalid rotation latitude: "+c)}if(r===e[0]){let c=Qe(t,"o_alpha"),l=Qe(t,"o_lon_c"),h=Qe(t,"o_lat_c");if(Math.abs(h)>=Math.PI/2-1e-10)throw new Error("Rotation center must be away from the poles");return{lamp:l+Math.atan2(-Math.cos(c),-Math.sin(c)*Math.sin(h)),phip:Math.asin(Math.cos(h)*Math.sin(c))}}if(r===e[1])return{lamp:Qe(t,"o_lon_p"),phip:Qe(t,"o_lat_p")};let n=Qe(t,"o_lon_1"),i=Qe(t,"o_lat_1"),o=Qe(t,"o_lon_2"),s=Qe(t,"o_lat_2");if(Math.abs(i)>=Math.PI/2-1e-10||Math.abs(s)>=Math.PI/2-1e-10||Math.abs(i)<1e-10||Math.abs(i-s)<1e-10)throw new Error("Invalid new-equator reference points");let a=Math.atan2(Math.cos(i)*Math.sin(s)*Math.cos(n)-Math.sin(i)*Math.cos(s)*Math.cos(o),Math.sin(i)*Math.cos(s)*Math.sin(o)-Math.cos(i)*Math.sin(s)*Math.sin(n));return{lamp:a,phip:Math.atan(-Math.cos(a-n)/Math.tan(i))}}function qi(t){let e=t==="longlat";if(!e&&["obtran","geocent"].includes(aa(t.name)))throw new Error("Cannot wrap a composite or geocentric projection");return{name:"ob_tran",aliases:["General Oblique Transformation","General_Oblique_Transformation"],parameters:[...h0,"lon_0",...e?[]:t.parameters],flags:e?[]:t.flags,create(r){let{parameters:n}=r,i=n.o_proj,o=e?["longlat","latlong","lonlat","latlon","identity"]:[t.name,...t.aliases||[]];if(i&&!o.map(aa).includes(aa(i)))throw new Oe("missing-plugin","Oblique transformation dependency does not match +o_proj="+i);let{lamp:s,phip:a}=d2(n),c=Math.cos(a),l=Math.sin(a),h=Math.abs(a)>1e-10,u=Qe(n,"lon_0"),f=ca(n,"over"),d={...n,proj:e?"longlat":i||t.name,lon_0:"0"};for(let x of h0)delete d[x];let m=e?Ue(x=>{x.x*=180/Math.PI,x.y*=180/Math.PI},x=>{x.x*=Math.PI/180,x.y*=Math.PI/180}):t.create({...r,parameters:Object.freeze(d)}),p=dt(m,!1),g=dt(m,!0),y=x=>Math.asin(Math.max(-1,Math.min(1,x)));return Ue(x=>{let w=x.x,_=x.y,S=f?w-u:Ve(w-u),E=Math.cos(S),v=Math.sin(_),T=Math.cos(_),I=Ve(Math.atan2(T*Math.sin(S),h?l*T*E+c*v:v)+s),P=y(h?l*v-c*T*E:-T*E);x.x=I,x.y=P,p(x)},x=>{g(x);let w=x.x,_=x.y,S=w-s,E=Math.cos(S),v=Math.sin(_),T=Math.cos(_),I=Math.atan2(T*Math.sin(S),h?l*T*E-c*v:-v),P=y(h?l*v+c*T*E:T*E);x.x=Ve(I+u),x.y=P})}}}function J(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Expected a CRS object");return t}function Zr(t){return Array.isArray(t)?t:[]}function Me(t){return String(t||"").toLowerCase().replace(/[^a-z0-9]/g,"")}function ze(t){if(typeof t!="number"||!Number.isFinite(t))throw new Error("Expected a finite CRS parameter");return t}function be(t,e){if(t===void 0)return e;if(typeof t=="object"){let i=ze(J(t).conversion_factor);if(i<=0)throw new Error("Unit conversion factor must be positive");return i}let n={metre:1,meter:1,degree:te,radian:1,grad:Math.PI/200,gon:Math.PI/200,foot:.3048,ussurveyfoot:1200/3937,kilometre:1e3,arcsecond:te/3600,partspermillion:1e-6,unity:1}[Me(t)];return n||D("Unsupported CRS unit: "+String(t)),n}var m2={hotineobliquemercator:"omerc",hotineobliquemercatorvarianta:"omerc",hotineobliquemercatorvariantb:"omerc",hotineobliquemercatorazimuthnaturalorigin:"omerc",hotineobliquemercatorazimuthcenter:"omerc",obliquemercator:"omerc",krovak:"krovak",krovaknorthorientated:"krovak",quadrilateralizedsphericalcube:"qsc",transversemercator:"tmerc",transversemercatorsouthorientated:"unsupported-south-tmerc",mercator:"merc",mercator1sp:"merc",mercator2sp:"merc",mercatorvarianta:"merc",mercatorvariantb:"merc",mercatorauxiliarysphere:"webmerc",popularvisualisationpseudomercator:"webmerc",lambertconformalconic:"lcc",lambertconformalconic1sp:"lcc",lambertconformalconic2sp:"lcc",lambertconicconformal1sp:"lcc",lambertconicconformal2sp:"lcc",albers:"aea",albersconicequalarea:"aea",albersequalarea:"aea",equidistantconic:"eqdc",lambertazimuthalequalarea:"laea",stereographic:"stere",stereographicnorthpole:"sterea",stereographicsouthpole:"stere",polarstereographic:"stere",polarstereographicvarianta:"stere",polarstereographicvariantb:"stere",obliquestereographic:"sterea",doublestereographic:"sterea",azimuthalequidistant:"aeqd",modifiedazimuthalequidistant:"aeqd",equidistantcylindrical:"eqc",equidistantcylindricalspherical:"eqc",equirectangular:"eqc",platecarree:"eqc",bonne:"bonne",cassinisoldner:"cass",cassini:"cass",cylindricalequalarea:"cea",lambertcylindricalequalarea:"cea",eckertvi:"eck6",equalearth:"eqearth",millercylindrical:"mill",mollweide:"moll",robinson:"robin",sinusoidal:"sinu",vandergrinten:"vandg",vandergrinteni:"vandg",gnomonic:"gnom",orthographic:"ortho",polyconic:"poly",americanpolyconic:"poly",newzealandmapgrid:"nzmg",gaussschreibertransversemercator:"gstmerc"},p2={centralmeridian:"lon_0",longitudeoforigin:"lon_0",longitudeofcenter:"lon_0",longitudeofnaturalorigin:"lon_0",longitudeoffalseorigin:"lon_0",longitudeofprojectioncentre:"lon_0",straightverticalpolelongitude:"lon_0",longitudeoforiginmeridian:"lon_0",latitudeoforigin:"lat_0",latitudeofcenter:"lat_0",latitudeofnaturalorigin:"lat_0",latitudeoffalseorigin:"lat_0",latitudeofprojectioncentre:"lat_0",standardparallel1:"lat_1",latitudeof1ststandardparallel:"lat_1",standardparallel2:"lat_2",latitudeof2ndstandardparallel:"lat_2",latitudeofstandardparallel:"lat_ts",scalefactor:"k_0",scalefactoratnaturalorigin:"k_0",scalefactoratprojectionorigin:"k_0",falseeasting:"x_0",falsenorthing:"y_0",eastingatfalseorigin:"x_0",northingatfalseorigin:"y_0"},g2={omerc:{longitudeofcenter:"lonc",longitudeofprojectioncentre:"lonc",azimuth:"alpha",azimuthatprojectioncentre:"alpha",rectifiedgridangle:"gamma",anglefromrectifiedtoskewgrid:"gamma",scalefactoratprojectioncentre:"k_0",eastingatprojectioncentre:"x_0",northingatprojectioncentre:"y_0"},krovak:{azimuth:"alpha",colatitudeofconeaxis:"alpha",pseudostandardparallel1:"lat_ts",latitudeofpseudostandardparallel:"lat_ts",scalefactoronpseudostandardparallel:"k_0"}},M2={east:"e",west:"w",north:"n",south:"s",up:"u",down:"d",geocentricx:"e",geocentricy:"n",geocentricz:"u"};function qt(t,e){let r=String(t.type);if(r==="CompoundCRS"){e.mode!=="horizontal"&&D("CompoundCRS requires explicit horizontal extraction");let v=Zr(t.components).map(J).filter(T=>["ProjectedCRS","GeographicCRS","GeodeticCRS","BoundCRS"].includes(String(T.type)));if(v.length!==1)throw new Error("CompoundCRS requires exactly one horizontal component");return{...qt(v[0],e),lossy:!0}}if(r==="BoundCRS"){let v=qt(J(t.source_crs),e),T=qt(J(t.target_crs),e);(T.parameters.datum!=="WGS84"||!["longlat","geocent"].includes(T.parameters.proj)||Number(T.parameters.pm||0)!==0||T.parameters.towgs84||Number(T.parameters.a)!==6378137||!(Math.abs(Number(T.parameters.rf)-298.257223563)<=1e-9||Math.abs(Number(T.parameters.b)-6356752314245179e-9)<=1e-6))&&D("BoundCRS requires a WGS84 target");let I=J(t.transformation),P=Me(J(I.method).name),R=P==="geocentrictranslations"||/^geocentrictranslationsgeog[23]ddomain$/.test(P),N=/^positionvector(?:transformation)?(?:geog[23]ddomain|geocentricdomain)?$/.test(P),q=/^coordinateframe(?:rotation)?(?:geog[23]ddomain|geocentricdomain)?$/.test(P);!R&&!N&&!q&&D("Unsupported BoundCRS transformation: "+P);let O=["xaxistranslation","yaxistranslation","zaxistranslation","xaxisrotation","yaxisrotation","zaxisrotation","scaledifference"],k=new Array(R?3:7).fill(void 0);for(let ve of Zr(I.parameters)){let qe=J(ve),re=O.indexOf(Me(qe.name));(re<0||re>=k.length||k[re]!==void 0)&&D("Unsupported or duplicate Helmert parameter: "+String(qe.name));let ct=re<3?1:re<6?te/3600:1e-6;k[re]=ze(qe.value)*be(qe.unit,ct)/ct*(q&&re>=3&&re<6?-1:1)}if(k.some(ve=>ve===void 0))throw new Error("Incomplete BoundCRS Helmert transformation");let U={...v.parameters,towgs84:k.join(",")};return delete U.datum,{...v,parameters:U}}["ProjectedCRS","GeographicCRS","GeodeticCRS"].includes(r)||D("Unsupported CRS type: "+r);let n=r==="ProjectedCRS"?J(t.base_crs):t,i=J(n.datum||n.datum_ensemble);(i.type==="DynamicGeodeticReferenceFrame"||i.frame_reference_epoch!==void 0||t.coordinate_epoch!==void 0)&&D("Time-dependent datum transformations are not implemented");let o=J(i.ellipsoid),s=ze(o.semi_major_axis??o.radius),a={proj:"longlat",a:String(s*be(o.unit,1))};if(o.inverse_flattening!==void 0)a.rf=String(ze(o.inverse_flattening));else if(o.semi_minor_axis!==void 0)a.b=String(ze(o.semi_minor_axis)*be(o.unit,1));else if(o.radius!==void 0)a.b=a.a;else throw new Error("Ellipsoid requires inverse flattening or semi-minor axis");let c=nr(e),l=String(i.name||""),h=Me(l),u=Object.keys(c),f=u.find(v=>Nt(v)===Nt(l)),d=f?[f]:u.filter(v=>Me(v)===h||Me(v)===h.replace(/^d/,"")),m=d[0],p=c[m];if(p&&d.some(v=>{let T=c[v];return T.ellipse!==p.ellipse||T.towgs84!==p.towgs84||T.nadgrids!==p.nadgrids}))throw new Error("Ambiguous structured datum name: "+l);if(h&&(a.datum=m||l),m&&Nt(m)==="wgs84"&&(a.datum="WGS84"),m&&["nad83","northamericandatum1983"].includes(Nt(m))&&(a.datum="NAD83"),!m){["wgs84","worldgeodeticsystem1984","worldgeodeticsystem1984ensemble","dwgs1984","wgs1984"].includes(h)&&(a.datum="WGS84"),["nad83","northamericandatum1983","dnorthamerican1983"].includes(h)&&(a.datum="NAD83"),["nad27","northamericandatum1927","dnorthamerican1927"].includes(h)&&(a.datum="NAD27");let T={newzealand1949:"nzgd49",belge1972:"rnb72"}[h.replace(/^d/,"")];T&&(a.datum=T)}if(r==="ProjectedCRS"&&n.id){let v=J(n.id),T=String(v.authority)+"_"+String(v.code);Object.prototype.hasOwnProperty.call(c,T)&&(a.datum=T)}i.towgs84!==void 0&&(a.towgs84=Zr(i.towgs84).map(ze).join(","),delete a.datum);let g=t.coordinate_system?J(t.coordinate_system):{},y=Zr(g.axis).map(J),x=Me(g.subtype)==="cartesian"&&r==="GeodeticCRS";r!=="ProjectedCRS"&&!x&&g.subtype&&Me(g.subtype)!=="ellipsoidal"&&D("Unsupported coordinate system subtype"),x&&(a.proj="geocent");let w=be(n.angular_unit,te),_=be(y[0]?.unit,r==="ProjectedCRS"||x?1:w);y[1]&&be(y[1].unit,_)!==_&&D("Mixed horizontal axis units are not supported"),x&&y[2]&&be(y[2].unit,_)!==_&&D("Mixed geocentric axis units are not supported");let S=n.prime_meridian||i.prime_meridian;if(S){let v=J(S);a.pm=String(ze(v.longitude)*be(v.unit,w)/te)}if(r==="ProjectedCRS"){let v=J(t.conversion),T=Me(J(v.method).name),I=Zr(v.parameters).map(J),P=T==="stereographicnorthpole"&&!I.some(O=>Me(O.name).startsWith("scalefactor")),R=P?"stere":m2[T],N=I.filter(O=>["xscale","yscale","xyplanerotation"].includes(Me(O.name)));if(N.length){let O={xscale:-1,yscale:1,xyplanerotation:90};(R!=="krovak"||N.length!==3||new Set(N.map(k=>Me(k.name))).size!==3||N.some(k=>{let U=Me(k.name),ve=U==="xyplanerotation"?be(k.unit,w)/te:be(k.unit,1);return Math.abs(ze(k.value)*ve-O[U])>1e-10}))&&D("Unsupported ESRI Krovak axis adjustment")}(!R||R.startsWith("unsupported"))&&D("Unsupported projection method: "+String(J(v.method).name)),a.proj=R==="webmerc"?"merc":R;let q=!1;for(let O of I){let k=Me(O.name);if(N.includes(O)||k==="auxiliaryspheretype"&&R==="webmerc"&&O.value===0)continue;if(k==="semiminor"&&R==="webmerc"){if(q)throw new Error("Duplicate conversion parameter: semi_minor");q=!0;let ct=ze(O.value)*be(O.unit,1);Math.abs(ct-Number(a.a))>4*Number.EPSILON*Number(a.a)&&D("Pseudo-Mercator semi_minor must equal the semi-major axis");continue}let U=g2[R]?.[k]||p2[k];if(U||D("Unsupported conversion parameter: "+String(O.name)),U==="lat_1"&&T==="stereographicnorthpole"&&!P?U="lat_0":U==="lat_1"&&["merc","webmerc","eqc","stere","cea"].includes(R)&&(U="lat_ts"),a[U]!==void 0)throw new Error("Duplicate conversion parameter: "+U);if(["merc","webmerc"].includes(R)&&U==="lat_0"&&O.value===0)continue;let ve=U.startsWith("lat")||U.startsWith("lon")||U==="alpha"||U==="gamma",qe=U==="x_0"||U==="y_0",re=ze(O.value)*be(O.unit,ve?w:qe?_:1)/(ve?te:1);U.startsWith("lat")&&Math.abs(Math.abs(re)-90)<=4*Number.EPSILON*90&&(re=Math.sign(re)*90),a[U]=String(re)}if(R==="omerc"&&["hotineobliquemercator","hotineobliquemercatorvarianta","hotineobliquemercatorazimuthnaturalorigin"].includes(T)&&(a.no_uoff=void 0),R==="omerc"&&a.lon_0!==void 0&&a.lonc!==void 0&&(Math.abs(Number(a.lon_0)-Number(a.lonc))>1e-10&&D("Oblique Mercator central meridian conflicts with projection centre"),delete a.lon_0),T==="stereographicnorthpole"&&Math.abs(Number(a.lat_0))===90&&(a.proj="stere"),R==="lcc"&&a.lat_1===void 0&&(a.lat_1=a.lat_0),T==="polarstereographic"&&a.lat_0!==void 0){if(a.lat_ts!==void 0)throw new Error("Duplicate polar stereographic latitude of true scale");a.lat_ts=a.lat_0,delete a.lat_0}R==="stere"&&(T.includes("polar")||T==="stereographicsouthpole"||P)&&a.lat_0===void 0&&(a.lat_0=Number(a.lat_ts||90)<0?"-90":"90"),R==="webmerc"&&(a.b=a.a,delete a.rf,a.nadgrids="@null")}let E=y.map(v=>y2(v,a,r==="ProjectedCRS")).join("");return E.length===2&&(E+="u"),!x&&/[ud]/.test(E.slice(0,2))&&D("Structured CRS vertical-first axes require an explicit PROJ axis definition"),E&&(a.axis=E),(r==="ProjectedCRS"||x)&&(a.to_meter=String(_)),{parameters:a,angularUnit:r==="ProjectedCRS"||x?w:_,verticalUnit:x?1:be(y[2]?.unit,1)}}function y2(t,e,r){let n=String(t.direction),i=t.meridian,o=/^(north|south) along ([+-]?(?:\d+(?:\.\d*)?|\.\d+)) deg(?: (east|west))?$/i.exec(n);if(o){if(i!==void 0)throw new Error("Duplicate axis meridian");n=o[1],i={longitude:Number(o[2])*(o[3]?.toLowerCase()==="west"?-1:1)}}if(i!==void 0){let a=Number(e.lat_0),c=a===90;(!r||e.proj!=="stere"||Math.abs(a)!==90||Me(n)!==(c?"south":"north"))&&D("Axis meridians require an outward-facing polar stereographic axis");let l=J(i).longitude,h=typeof l=="number"?ze(l):ze(J(l).value)*be(J(l).unit,te)/te,u=ze((h-Number(e.lon_0||0))/90);Math.abs(u-Math.round(u))>1e-12&&D("Non-cardinal axis meridians require an orientation operation");let f=(Math.round(u)%4+4)%4;return(c?"senw":"nesw")[f]}let s=M2[Me(n)];return s||D("Unsupported axis direction: "+n),s}function Fi(t,...e){return t.values.filter(r=>r.type==="node"&&e.includes(r.keyword.toUpperCase()))}function K(t,...e){return Fi(t,...e)[0]}function ee(t,e=0){let r=t.values[e];return r&&r.type!=="node"?r.value:void 0}function Ft(t){return t?{name:ee(t),conversion_factor:ee(t,1)}:void 0}function x2(t,e){let r=ee(t,1);if(e&&String(r).toLowerCase()==="unknown"){let n=String(ee(t)).toLowerCase(),i=/^(easting|northing|westing|southing)(?:\s*\([a-z]\))?$/.exec(n);if(i)return{easting:"east",northing:"north",westing:"west",southing:"south"}[i[1]]}return r}function _2(t){let e=K(t,"MERIDIAN");if(e)return{longitude:{value:ee(e),unit:Ft(K(e,"ANGLEUNIT"))}}}function u0(t){let e=K(t,"METHOD","PROJECTION");if(!e)throw new Error("WKT conversion requires a METHOD or PROJECTION");return K(t,"PARAMETERFILE")&&D("Grid-based WKT operation is not implemented"),{method:{name:ee(e)},parameters:Fi(t,"PARAMETER").map(r=>({name:ee(r),value:ee(r,1),unit:Ft(K(r,"ANGLEUNIT","LENGTHUNIT","SCALEUNIT"))}))}}function Qr(t){let e=t.keyword.toUpperCase();if(e==="COMPD_CS"||e==="COMPOUNDCRS")return{type:"CompoundCRS",components:Fi(t,"PROJCS","PROJCRS","GEOGCS","GEOGCRS","GEODCRS","BOUNDCRS","VERT_CS","VERTCRS").map(Qr)};if(e==="BOUNDCRS"){let h=K(t,"SOURCECRS"),u=K(t,"TARGETCRS"),f=K(t,"ABRIDGEDTRANSFORMATION");if(!h||!u||!f)throw new Error("Incomplete WKT BoundCRS");let d=g=>{let y=g.values.find(x=>x.type==="node");if(!y)throw new Error("Missing bound CRS component");return y},m=u0(f),p=m.parameters;for(let g of p)String(g.name).toLowerCase()==="scale difference"&&g.unit===void 0&&(g.value=(Number(g.value)-1)*1e6);return{type:"BoundCRS",source_crs:Qr(d(h)),target_crs:Qr(d(u)),transformation:m}}if(["VERT_CS","VERTCRS"].includes(e))return{type:"VerticalCRS"};let r=["PROJCS","PROJCRS","PROJECTEDCRS"].includes(e),n=["GEOGCS","GEOGCRS","GEODCRS","GEODETICCRS","GEOGRAPHICCRS","BASEGEOGCRS","BASEGEODCRS","GEOCCS"].includes(e);!r&&!n&&D("Unsupported WKT CRS: "+e),K(t,"DYNAMIC","DERIVINGCONVERSION","VELOCITYGRID","EXTENSION")&&D("Unsupported WKT dynamic/extension operation");let i=K(t,"CS"),o=e==="GEOCCS"||String(ee(i||t)).toLowerCase()==="cartesian"&&!r,s=K(t,r||o?"LENGTHUNIT":"ANGLEUNIT","UNIT"),a=Fi(t,"AXIS").sort((h,u)=>Number(ee(K(h,"ORDER")||h))-Number(ee(K(u,"ORDER")||u))).map((h,u)=>({name:ee(h),direction:e==="GEOCCS"?["geocentricX","geocentricY","geocentricZ"][u]:x2(h,r),unit:Ft(K(h,"ANGLEUNIT","LENGTHUNIT")||(!o&&!r&&/^(up|down)$/i.test(String(ee(h,1)))?void 0:s)),meridian:_2(h)}));if(!a.length)for(let h of o?["geocentricX","geocentricY","geocentricZ"]:["east","north"])a.push({name:h,direction:h,unit:Ft(s),meridian:void 0});let c=e==="GEOGCS"?void 0:K(t,"ID"),l={type:r?"ProjectedCRS":o?"GeodeticCRS":"GeographicCRS",name:ee(t),id:c?{authority:ee(c),code:ee(c,1)}:void 0,coordinate_system:{subtype:r||o?"Cartesian":"ellipsoidal",axis:a}};if(r){let h=K(t,"GEOGCS","BASEGEOGCRS","BASEGEODCRS","GEODCRS","GEOGCRS");if(!h)throw new Error("Projected WKT requires a base geographic CRS");l.base_crs=Qr(h),l.conversion=u0(K(t,"CONVERSION")||t)}else{let h=K(t,"DATUM","GEODETICDATUM","ENSEMBLE");if(!h)throw new Error("WKT requires a geodetic datum");K(h,"EXTENSION","DYNAMIC")&&D("Unsupported datum extension");let u=K(h,"SPHEROID","ELLIPSOID");if(!u)throw new Error("WKT datum requires an ellipsoid");let f=K(h,"TOWGS84");l.datum={name:ee(h),ellipsoid:{name:ee(u),semi_major_axis:ee(u,1),inverse_flattening:ee(u,2),unit:Ft(K(u,"LENGTHUNIT"))},towgs84:f?.values.map((m,p)=>ee(f,p))};let d=K(t,"PRIMEM");d&&(l.prime_meridian={name:ee(d),longitude:ee(d,1),unit:Ft(K(d,"ANGLEUNIT")||(o?void 0:s))}),l.angular_unit=o?void 0:Ft(s)}return l}var la={name:"wkt",canParse:t=>_e(t)==="wkt",parse(t,e){if(typeof t!="string")throw new Error("Expected serialized WKT");return qt(Qr(Nr(t).root),e)}};var ha={name:"projjson",canParse:t=>_e(t)==="projjson",parse:(t,e)=>qt(J(t),e)};var ua=1e-12;function Bi(t,e,r,n,i=!1){let o=(e-t.origin[0])/t.step[0],s=(r-t.origin[1])/t.step[1],a=t.size[0],c=t.size[1];if(!i&&(o<-1e-10||s<-1e-10||o>a-1+1e-10||s>c-1+1e-10))return!1;o=Math.max(0,Math.min(a-1,o)),s=Math.max(0,Math.min(c-1,s));let l=Math.min(a-2,Math.floor(o)),h=Math.min(c-2,Math.floor(s)),u=o-l,f=s-h,d=0,m=0;for(let p=0;p<4;p++){let g=p%2,y=p>1,x=(g?u:1-u)*(y?f:1-f);if(x===0)continue;let w=((h+(y?1:0))*a+l+g)*2,_=t.shifts[w],S=t.shifts[w+1];if(!Number.isFinite(_)||!Number.isFinite(S))return!1;d+=x*_,m+=x*S}return n.x=d,n.y=m,!0}function w2(t,e,r,n,i){if(!n)return Bi(t,e,r,i)?(i.x+=e,i.y+=r,!0):!1;for(let a=0;a<2;a++){let c=a===0?e:r;if(c<t.origin[a]-t.maxShift[a]-ua||c>t.origin[a]+(t.size[a]-1)*t.step[a]+t.maxShift[a]+ua)return!1}if(!Bi(t,e,r,i,!0))return!1;let o=e-i.x,s=r-i.y;for(let a=0;a<20;a++){if(!Bi(t,o,s,i,!0))return!1;let c=e-o-i.x,l=r-s-i.y;if(o+=c,s+=l,Math.max(Math.abs(c),Math.abs(l))<=ua)return Bi(t,o,s,i)?(i.x=Ve(o),i.y=s,!0):!1}throw new Error("Inverse datum grid shift did not converge")}function f0(t){if(!t.length)throw new Error("Datum grid requires at least one subgrid");let e=t.map(i=>{let[o,s]=i.size;if(![o,s].every(c=>Number.isSafeInteger(c)&&c>=2)||o*s*2!==i.shifts.length||!i.origin.every(Number.isFinite)||!i.step.every(c=>Number.isFinite(c)&&c>0))throw new Error("Invalid datum subgrid geometry or node count");let a=[0,0];for(let c=0;c<i.shifts.length;c++){let l=i.shifts[c];Number.isFinite(l)&&(a[c%2]=Math.max(a[c%2],Math.abs(l)))}return{...i,maxShift:a}}),r=(i,o)=>{let s=i.x,a=i.y;if(!Number.isFinite(s)||!Number.isFinite(a))throw new Error("Grid coordinates must be finite");for(let c of e)if(w2(c,-s,a,o,i))return i.x=-i.x,!0;return i.x=s,i.y=a,!1},n={x:NaN,y:NaN};return Object.freeze({subgridCount:e.length,shiftInPlace:r,shift(i,o,s){return n.x=i,n.y=o,r(n,s)?[n.x,n.y]:void 0}})}var hr=Math.PI/648e3;function fa(t,e={}){let r=new DataView(t);if(r.byteLength<176)throw new Error("Truncated NTv2 overview header");let n=r.getInt32(8,!0)===11;if(!n&&r.getInt32(8,!1)!==11)throw new Error("Invalid NTv2 header or byte order");let i=u=>r.getInt32(u,n),o=u=>r.getFloat64(u,n),s=u=>String.fromCharCode(...new Uint8Array(t,u,8)).replace(/\0/g,"").trim();if(s(0)!=="NUM_OREC"||i(24)!==11||s(56)!=="SECONDS")throw new Error("Unsupported NTv2 header or shift units");let a=i(40),c=e.includeErrorFields===!1?8:16;if(a<1||a>Math.floor((r.byteLength-176)/(176+4*c)))throw new Error("Invalid NTv2 subgrid count");let l=176,h=[];for(let u=0;u<a;u++){if(l+176>r.byteLength)throw new Error("Truncated NTv2 subgrid header");let f=o(l+72),d=o(l+88),m=o(l+104),p=o(l+120),g=o(l+136),y=o(l+152),x=i(l+168),w=1+(p-m)/y,_=1+(d-f)/g;if(![w,_].every(T=>Number.isFinite(T)&&T>=2&&Math.abs(T-Math.round(T))<1e-7)||!(y>0&&g>0)||x!==Math.round(w)*Math.round(_))throw new Error("Invalid NTv2 subgrid dimensions");let S=l+176,E=S+x*c;if(E>r.byteLength)throw new Error("Truncated NTv2 node records");let v=new Float64Array(x*2);for(let T=0;T<x;T++)v[T*2]=r.getFloat32(S+T*c+4,n)*hr,v[T*2+1]=r.getFloat32(S+T*c,n)*hr;h.push({origin:[m*hr,f*hr],step:[y*hr,g*hr],size:[Math.round(w),Math.round(_)],shifts:v}),l=E}return f0(h)}var Di={ch1903:{towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},ggrs87:{towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},nad27:{nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},potsdam:{towgs84:"598.1,73.7,418.2,0.202,0.045,-2.455,6.7",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},carthage:{towgs84:"-263.0,6.0,431.0",ellipse:"clrk80ign",datumName:"Carthage 1934 Tunisia"},hermannskogel:{towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Hermannskogel"},mgi:{towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Militar-Geographische Institut"},osni52:{towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},ire65:{towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},rassadiran:{towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},nzgd49:{towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},osgb36:{towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Ordnance Survey of Great Britain 1936"},s_jtsk:{towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},beduaram:{towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},gunung_segara:{towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},rnb72:{towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"},EPSG_5451:{towgs84:"6.41,-49.05,-11.28,1.5657,0.5242,6.9718,-5.7649"},IGNF_LURESG:{towgs84:"-192.986,13.673,-39.309,-0.4099,-2.9332,2.6881,0.43"},EPSG_4614:{towgs84:"-119.4248,-303.65872,-11.00061,1.164298,0.174458,1.096259,3.657065"},EPSG_4615:{towgs84:"-494.088,-312.129,279.877,-1.423,-1.013,1.59,-0.748"},ESRI_37241:{towgs84:"-76.822,257.457,-12.817,2.136,-0.033,-2.392,-0.031"},ESRI_37249:{towgs84:"-440.296,58.548,296.265,1.128,10.202,4.559,-0.438"},ESRI_37245:{towgs84:"-511.151,-181.269,139.609,1.05,2.703,1.798,3.071"},EPSG_4178:{towgs84:"24.9,-126.4,-93.2,-0.063,-0.247,-0.041,1.01"},EPSG_4622:{towgs84:"-472.29,-5.63,-304.12,0.4362,-0.8374,0.2563,1.8984"},EPSG_4625:{towgs84:"126.93,547.94,130.41,-2.7867,5.1612,-0.8584,13.8227"},EPSG_5252:{towgs84:"0.023,0.036,-0.068,0.00176,0.00912,-0.01136,0.00439"},EPSG_4314:{towgs84:"597.1,71.4,412.1,0.894,0.068,-1.563,7.58"},EPSG_4282:{towgs84:"-178.3,-316.7,-131.5,5.278,6.077,10.979,19.166"},EPSG_4231:{towgs84:"-83.11,-97.38,-117.22,0.005693,-0.044698,0.044285,0.1218"},EPSG_4274:{towgs84:"-230.994,102.591,25.199,0.633,-0.239,0.9,1.95"},EPSG_4134:{towgs84:"-180.624,-225.516,173.919,-0.81,-1.898,8.336,16.71006"},EPSG_4254:{towgs84:"18.38,192.45,96.82,0.056,-0.142,-0.2,-0.0013"},EPSG_4159:{towgs84:"-194.513,-63.978,-25.759,-3.4027,3.756,-3.352,-0.9175"},EPSG_4687:{towgs84:"0.072,-0.507,-0.245,0.0183,-0.0003,0.007,-0.0093"},EPSG_4227:{towgs84:"-83.58,-397.54,458.78,-17.595,-2.847,4.256,3.225"},EPSG_4746:{towgs84:"599.4,72.4,419.2,-0.062,-0.022,-2.723,6.46"},EPSG_4745:{towgs84:"612.4,77,440.2,-0.054,0.057,-2.797,2.55"},EPSG_6311:{towgs84:"8.846,-4.394,-1.122,-0.00237,-0.146528,0.130428,0.783926"},EPSG_4289:{towgs84:"565.7381,50.4018,465.2904,-0.395026,0.330772,-1.876073,4.07244"},EPSG_4230:{towgs84:"-68.863,-134.888,-111.49,-0.53,-0.14,0.57,-3.4"},EPSG_4154:{towgs84:"-123.02,-158.95,-168.47"},EPSG_4156:{towgs84:"570.8,85.7,462.8,4.998,1.587,5.261,3.56"},EPSG_4299:{towgs84:"482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15"},EPSG_4179:{towgs84:"33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84"},EPSG_4313:{towgs84:"-106.8686,52.2978,-103.7239,0.3366,-0.457,1.8422,-1.2747"},EPSG_4194:{towgs84:"163.511,127.533,-159.789"},EPSG_4195:{towgs84:"105,326,-102.5"},EPSG_4196:{towgs84:"-45,417,-3.5"},EPSG_4611:{towgs84:"-162.619,-276.959,-161.764,0.067753,-2.243648,-1.158828,-1.094246"},EPSG_4633:{towgs84:"137.092,131.66,91.475,-1.9436,-11.5993,-4.3321,-7.4824"},EPSG_4641:{towgs84:"-408.809,366.856,-412.987,1.8842,-0.5308,2.1655,-121.0993"},EPSG_4643:{towgs84:"-480.26,-438.32,-643.429,16.3119,20.1721,-4.0349,-111.7002"},EPSG_4300:{towgs84:"482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15"},EPSG_4188:{towgs84:"482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15"},EPSG_4660:{towgs84:"982.6087,552.753,-540.873,6.681627,-31.611492,-19.848161,16.805"},EPSG_4662:{towgs84:"97.295,-263.247,310.882,-1.5999,0.8386,3.1409,13.3259"},EPSG_3906:{towgs84:"577.88891,165.22205,391.18289,4.9145,-0.94729,-13.05098,7.78664"},EPSG_4307:{towgs84:"-209.3622,-87.8162,404.6198,0.0046,3.4784,0.5805,-1.4547"},EPSG_6892:{towgs84:"-76.269,-16.683,68.562,-6.275,10.536,-4.286,-13.686"},EPSG_4690:{towgs84:"221.597,152.441,176.523,2.403,1.3893,0.884,11.4648"},EPSG_4691:{towgs84:"218.769,150.75,176.75,3.5231,2.0037,1.288,10.9817"},EPSG_4629:{towgs84:"72.51,345.411,79.241,-1.5862,-0.8826,-0.5495,1.3653"},EPSG_4630:{towgs84:"165.804,216.213,180.26,-0.6251,-0.4515,-0.0721,7.4111"},EPSG_4692:{towgs84:"217.109,86.452,23.711,0.0183,-0.0003,0.007,-0.0093"},EPSG_9333:{towgs84:"0,0,0,-0.008393,0.000749,-0.010276,0"},EPSG_9059:{towgs84:"0,0,0"},EPSG_4312:{towgs84:"601.705,84.263,485.227,4.7354,1.3145,5.393,-2.3887"},EPSG_4123:{towgs84:"-96.062,-82.428,-121.753,4.801,0.345,-1.376,1.496"},EPSG_4309:{towgs84:"-124.45,183.74,44.64,-0.4384,0.5446,-0.9706,-2.1365"},ESRI_104106:{towgs84:"-283.088,-70.693,117.445,-1.157,0.059,-0.652,-4.058"},EPSG_4281:{towgs84:"-219.247,-73.802,269.529"},EPSG_4322:{towgs84:"0,0,4.5"},EPSG_4324:{towgs84:"0,0,1.9"},EPSG_4284:{towgs84:"43.822,-108.842,-119.585,1.455,-0.761,0.737,0.549"},EPSG_4277:{towgs84:"446.448,-125.157,542.06,0.15,0.247,0.842,-20.489"},EPSG_4207:{towgs84:"-282.1,-72.2,120,-1.529,0.145,-0.89,-4.46"},EPSG_4688:{towgs84:"347.175,1077.618,2623.677,33.9058,-70.6776,9.4013,186.0647"},EPSG_4689:{towgs84:"410.793,54.542,80.501,-2.5596,-2.3517,-0.6594,17.3218"},EPSG_4720:{towgs84:"0,0,4.5"},EPSG_4273:{towgs84:"278.3,93,474.5,7.889,0.05,-6.61,6.21"},EPSG_4240:{towgs84:"204.64,834.74,293.8"},EPSG_4817:{towgs84:"278.3,93,474.5,7.889,0.05,-6.61,6.21"},ESRI_104131:{towgs84:"426.62,142.62,460.09,4.98,4.49,-12.42,-17.1"},EPSG_4265:{towgs84:"-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68"},EPSG_4263:{towgs84:"-111.92,-87.85,114.5,1.875,0.202,0.219,0.032"},EPSG_4298:{towgs84:"-689.5937,623.84046,-65.93566,-0.02331,1.17094,-0.80054,5.88536"},EPSG_4270:{towgs84:"-253.4392,-148.452,386.5267,0.15605,0.43,-0.1013,-0.0424"},EPSG_4229:{towgs84:"-121.8,98.1,-10.7"},EPSG_4220:{towgs84:"-55.5,-348,-229.2"},EPSG_4214:{towgs84:"12.646,-155.176,-80.863"},EPSG_4232:{towgs84:"-345,3,223"},EPSG_4238:{towgs84:"-1.977,-13.06,-9.993,0.364,0.254,0.689,-1.037"},EPSG_4168:{towgs84:"-170,33,326"},EPSG_4131:{towgs84:"199,931,318.9"},EPSG_4152:{towgs84:"-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0"},EPSG_5228:{towgs84:"572.213,85.334,461.94,4.9732,1.529,5.2484,3.5378"},EPSG_8351:{towgs84:"485.021,169.465,483.839,7.786342,4.397554,4.102655,0"},EPSG_4683:{towgs84:"-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06"},EPSG_4133:{towgs84:"0,0,0"},EPSG_7373:{towgs84:"0.819,-0.5762,-1.6446,-0.00378,-0.03317,0.00318,0.0693"},EPSG_9075:{towgs84:"-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0"},EPSG_9072:{towgs84:"-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0"},EPSG_9294:{towgs84:"1.16835,-1.42001,-2.24431,-0.00822,-0.05508,0.01818,0.23388"},EPSG_4212:{towgs84:"-267.434,173.496,181.814,-13.4704,8.7154,7.3926,14.7492"},EPSG_4191:{towgs84:"-44.183,-0.58,-38.489,2.3867,2.7072,-3.5196,-8.2703"},EPSG_4237:{towgs84:"52.684,-71.194,-13.975,-0.312,-0.1063,-0.3729,1.0191"},EPSG_4740:{towgs84:"-1.08,-0.27,-0.9"},EPSG_4124:{towgs84:"419.3836,99.3335,591.3451,0.850389,1.817277,-7.862238,-0.99496"},EPSG_5681:{towgs84:"584.9636,107.7175,413.8067,1.1155,0.2824,-3.1384,7.9922"},EPSG_4141:{towgs84:"23.772,17.49,17.859,-0.3132,-1.85274,1.67299,-5.4262"},EPSG_4204:{towgs84:"-85.645,-273.077,-79.708,2.289,-1.421,2.532,3.194"},EPSG_4319:{towgs84:"226.702,-193.337,-35.371,-2.229,-4.391,9.238,0.9798"},EPSG_4200:{towgs84:"24.82,-131.21,-82.66"},EPSG_4130:{towgs84:"0,0,0"},EPSG_4127:{towgs84:"-82.875,-57.097,-156.768,-2.158,1.524,-0.982,-0.359"},EPSG_4149:{towgs84:"674.374,15.056,405.346"},EPSG_4617:{towgs84:"-0.991,1.9072,0.5129,0.02579,0.00965,0.01166,0"},EPSG_4663:{towgs84:"-210.502,-66.902,-48.476,2.094,-15.067,-5.817,0.485"},EPSG_4664:{towgs84:"-211.939,137.626,58.3,-0.089,0.251,0.079,0.384"},EPSG_4665:{towgs84:"-105.854,165.589,-38.312,-0.003,-0.026,0.024,-0.048"},EPSG_4666:{towgs84:"631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43"},EPSG_4756:{towgs84:"-192.873,-39.382,-111.202,-0.00205,-0.0005,0.00335,0.0188"},EPSG_4723:{towgs84:"-179.483,-69.379,-27.584,-7.862,8.163,6.042,-13.925"},EPSG_4726:{towgs84:"8.853,-52.644,180.304,-0.393,-2.323,2.96,-24.081"},EPSG_4267:{towgs84:"-8.0,160.0,176.0"},EPSG_5365:{towgs84:"-0.16959,0.35312,0.51846,0.03385,-0.16325,0.03446,0.03693"},EPSG_4218:{towgs84:"304.5,306.5,-318.1"},EPSG_4242:{towgs84:"-33.722,153.789,94.959,-8.581,-4.478,4.54,8.95"},EPSG_4216:{towgs84:"-292.295,248.758,429.447,4.9971,2.99,6.6906,1.0289"},ESRI_104105:{towgs84:"631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43"},ESRI_104129:{towgs84:"0,0,0"},EPSG_4673:{towgs84:"174.05,-25.49,112.57"},EPSG_4202:{towgs84:"-124,-60,154"},EPSG_4203:{towgs84:"-117.763,-51.51,139.061,0.292,0.443,0.277,-0.191"},EPSG_3819:{towgs84:"595.48,121.69,515.35,4.115,-2.9383,0.853,-3.408"},EPSG_8694:{towgs84:"-93.799,-132.737,-219.073,-1.844,0.648,-6.37,-0.169"},EPSG_4145:{towgs84:"275.57,676.78,229.6"},EPSG_4283:{towgs84:"0.06155,-0.01087,-0.04019,0.039492,0.032722,0.032898,-0.009994"},EPSG_4317:{towgs84:"2.3287,-147.0425,-92.0802,-0.309248,0.324822,0.497299,5.689063"},EPSG_4272:{towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993"},EPSG_4248:{towgs84:"-307.7,265.3,-363.5"},EPSG_5561:{towgs84:"24,-121,-76"},EPSG_5233:{towgs84:"-0.293,766.95,87.713,0.195704,1.695068,3.473016,-0.039338"},ESRI_104130:{towgs84:"-86,-98,-119"},ESRI_104102:{towgs84:"682,-203,480"},ESRI_37207:{towgs84:"7,-10,-26"},EPSG_4675:{towgs84:"59.935,118.4,-10.871"},ESRI_104109:{towgs84:"-89.121,-348.182,260.871"},ESRI_104112:{towgs84:"-185.583,-230.096,281.361"},ESRI_104113:{towgs84:"25.1,-275.6,222.6"},IGNF_WGS72G:{towgs84:"0,12,6"},IGNF_NTFG:{towgs84:"-168,-60,320"},IGNF_EFATE57G:{towgs84:"-127,-769,472"},IGNF_PGP50G:{towgs84:"324.8,153.6,172.1"},IGNF_REUN47G:{towgs84:"94,-948,-1262"},IGNF_CSG67G:{towgs84:"-186,230,110"},IGNF_GUAD48G:{towgs84:"-467,-16,-300"},IGNF_TAHI51G:{towgs84:"162,117,154"},IGNF_TAHAAG:{towgs84:"65,342,77"},IGNF_NUKU72G:{towgs84:"84,274,65"},IGNF_PETRELS72G:{towgs84:"365,194,166"},IGNF_WALL78G:{towgs84:"253,-133,-127"},IGNF_MAYO50G:{towgs84:"-382,-59,-262"},IGNF_TANNAG:{towgs84:"-139,-967,436"},IGNF_IGN72G:{towgs84:"-13,-348,292"},IGNF_ATIGG:{towgs84:"1118,23,66"},IGNF_FANGA84G:{towgs84:"150.57,158.33,118.32"},IGNF_RUSAT84G:{towgs84:"202.13,174.6,-15.74"},IGNF_KAUE70G:{towgs84:"126.74,300.1,-75.49"},IGNF_MOP90G:{towgs84:"-10.8,-1.8,12.77"},IGNF_MHPF67G:{towgs84:"338.08,212.58,-296.17"},IGNF_TAHI79G:{towgs84:"160.61,116.05,153.69"},IGNF_ANAA92G:{towgs84:"1.5,3.84,4.81"},IGNF_MARQUI72G:{towgs84:"330.91,-13.92,58.56"},IGNF_APAT86G:{towgs84:"143.6,197.82,74.05"},IGNF_TUBU69G:{towgs84:"237.17,171.61,-77.84"},IGNF_STPM50G:{towgs84:"11.363,424.148,373.13"},EPSG_4150:{towgs84:"674.374,15.056,405.346"},EPSG_4754:{towgs84:"-208.4058,-109.8777,-2.5764"},ESRI_104101:{towgs84:"372.87,149.23,585.29"},EPSG_4693:{towgs84:"0,-0.15,0.68"},EPSG_6207:{towgs84:"293.17,726.18,245.36"},EPSG_4153:{towgs84:"-133.63,-157.5,-158.62"},EPSG_4132:{towgs84:"-241.54,-163.64,396.06"},EPSG_4221:{towgs84:"-154.5,150.7,100.4"},EPSG_4266:{towgs84:"-80.7,-132.5,41.1"},EPSG_4193:{towgs84:"-70.9,-151.8,-41.4"},EPSG_5340:{towgs84:"-0.41,0.46,-0.35"},EPSG_4246:{towgs84:"-294.7,-200.1,525.5"},EPSG_4318:{towgs84:"-3.2,-5.7,2.8"},EPSG_4121:{towgs84:"-199.87,74.79,246.62"},EPSG_4223:{towgs84:"-260.1,5.5,432.2"},EPSG_4158:{towgs84:"-0.465,372.095,171.736"},EPSG_4285:{towgs84:"-128.16,-282.42,21.93"},EPSG_4613:{towgs84:"-404.78,685.68,45.47"},EPSG_4607:{towgs84:"195.671,332.517,274.607"},EPSG_4475:{towgs84:"-381.788,-57.501,-256.673"},EPSG_4208:{towgs84:"-157.84,308.54,-146.6"},EPSG_4743:{towgs84:"70.995,-335.916,262.898"},EPSG_4710:{towgs84:"-323.65,551.39,-491.22"},EPSG_7881:{towgs84:"-0.077,0.079,0.086"},EPSG_4682:{towgs84:"283.729,735.942,261.143"},EPSG_4739:{towgs84:"-156,-271,-189"},EPSG_4679:{towgs84:"-80.01,253.26,291.19"},EPSG_4750:{towgs84:"-56.263,16.136,-22.856"},EPSG_4644:{towgs84:"-10.18,-350.43,291.37"},EPSG_4695:{towgs84:"-103.746,-9.614,-255.95"},EPSG_4292:{towgs84:"-355,21,72"},EPSG_4302:{towgs84:"-61.702,284.488,472.052"},EPSG_4143:{towgs84:"-124.76,53,466.79"},EPSG_4606:{towgs84:"-153,153,307"},EPSG_4699:{towgs84:"-770.1,158.4,-498.2"},EPSG_4247:{towgs84:"-273.5,110.6,-357.9"},EPSG_4160:{towgs84:"8.88,184.86,106.69"},EPSG_4161:{towgs84:"-233.43,6.65,173.64"},EPSG_9251:{towgs84:"-9.5,122.9,138.2"},EPSG_9253:{towgs84:"-78.1,101.6,133.3"},EPSG_4297:{towgs84:"-198.383,-240.517,-107.909"},EPSG_4269:{towgs84:"0,0,0"},EPSG_4301:{towgs84:"-147,506,687"},EPSG_4618:{towgs84:"-59,-11,-52"},EPSG_4612:{towgs84:"0,0,0"},EPSG_4678:{towgs84:"44.585,-131.212,-39.544"},EPSG_4250:{towgs84:"-130,29,364"},EPSG_4144:{towgs84:"214,804,268"},EPSG_4147:{towgs84:"-17.51,-108.32,-62.39"},EPSG_4259:{towgs84:"-254.1,-5.36,-100.29"},EPSG_4164:{towgs84:"-76,-138,67"},EPSG_4211:{towgs84:"-378.873,676.002,-46.255"},EPSG_4182:{towgs84:"-422.651,-172.995,84.02"},EPSG_4224:{towgs84:"-143.87,243.37,-33.52"},EPSG_4225:{towgs84:"-205.57,168.77,-4.12"},EPSG_5527:{towgs84:"-67.35,3.88,-38.22"},EPSG_4752:{towgs84:"98,390,-22"},EPSG_4310:{towgs84:"-30,190,89"},EPSG_9248:{towgs84:"-192.26,65.72,132.08"},EPSG_4680:{towgs84:"124.5,-63.5,-281"},EPSG_4701:{towgs84:"-79.9,-158,-168.9"},EPSG_4706:{towgs84:"-146.21,112.63,4.05"},EPSG_4805:{towgs84:"682,-203,480"},EPSG_4201:{towgs84:"-165,-11,206"},EPSG_4210:{towgs84:"-157,-2,-299"},EPSG_4183:{towgs84:"-104,167,-38"},EPSG_4139:{towgs84:"11,72,-101"},EPSG_4668:{towgs84:"-86,-98,-119"},EPSG_4717:{towgs84:"-2,151,181"},EPSG_4732:{towgs84:"102,52,-38"},EPSG_4280:{towgs84:"-377,681,-50"},EPSG_4209:{towgs84:"-138,-105,-289"},EPSG_4261:{towgs84:"31,146,47"},EPSG_4658:{towgs84:"-73,46,-86"},EPSG_4721:{towgs84:"265.025,384.929,-194.046"},EPSG_4222:{towgs84:"-136,-108,-292"},EPSG_4601:{towgs84:"-255,-15,71"},EPSG_4602:{towgs84:"725,685,536"},EPSG_4603:{towgs84:"72,213.7,93"},EPSG_4605:{towgs84:"9,183,236"},EPSG_4621:{towgs84:"137,248,-430"},EPSG_4657:{towgs84:"-28,199,5"},EPSG_4316:{towgs84:"103.25,-100.4,-307.19"},EPSG_4642:{towgs84:"-13,-348,292"},EPSG_4698:{towgs84:"145,-187,103"},EPSG_4192:{towgs84:"-206.1,-174.7,-87.7"},EPSG_4311:{towgs84:"-265,120,-358"},EPSG_4135:{towgs84:"58,-283,-182"},ESRI_104138:{towgs84:"198,-226,-347"},EPSG_4245:{towgs84:"-11,851,5"},EPSG_4142:{towgs84:"-125,53,467"},EPSG_4213:{towgs84:"-106,-87,188"},EPSG_4253:{towgs84:"-133,-77,-51"},EPSG_4129:{towgs84:"-132,-110,-335"},EPSG_4713:{towgs84:"-77,-128,142"},EPSG_4239:{towgs84:"217,823,299"},EPSG_4146:{towgs84:"295,736,257"},EPSG_4155:{towgs84:"-83,37,124"},EPSG_4165:{towgs84:"-173,253,27"},EPSG_4672:{towgs84:"175,-38,113"},EPSG_4236:{towgs84:"-637,-549,-203"},EPSG_4251:{towgs84:"-90,40,88"},EPSG_4271:{towgs84:"-2,374,172"},EPSG_4175:{towgs84:"-88,4,101"},EPSG_4716:{towgs84:"298,-304,-375"},EPSG_4315:{towgs84:"-23,259,-9"},EPSG_4744:{towgs84:"-242.2,-144.9,370.3"},EPSG_4244:{towgs84:"-97,787,86"},EPSG_4293:{towgs84:"616,97,-251"},EPSG_4714:{towgs84:"-127,-769,472"},EPSG_4736:{towgs84:"260,12,-147"},EPSG_6883:{towgs84:"-235,-110,393"},EPSG_6894:{towgs84:"-63,176,185"},EPSG_4205:{towgs84:"-43,-163,45"},EPSG_4256:{towgs84:"41,-220,-134"},EPSG_4262:{towgs84:"639,405,60"},EPSG_4604:{towgs84:"174,359,365"},EPSG_4169:{towgs84:"-115,118,426"},EPSG_4620:{towgs84:"-106,-129,165"},EPSG_4184:{towgs84:"-203,141,53"},EPSG_4616:{towgs84:"-289,-124,60"},EPSG_9403:{towgs84:"-307,-92,127"},EPSG_4684:{towgs84:"-133,-321,50"},EPSG_4708:{towgs84:"-491,-22,435"},EPSG_4707:{towgs84:"114,-116,-333"},EPSG_4709:{towgs84:"145,75,-272"},EPSG_4712:{towgs84:"-205,107,53"},EPSG_4711:{towgs84:"124,-234,-25"},EPSG_4718:{towgs84:"230,-199,-752"},EPSG_4719:{towgs84:"211,147,111"},EPSG_4724:{towgs84:"208,-435,-229"},EPSG_4725:{towgs84:"189,-79,-202"},EPSG_4735:{towgs84:"647,1777,-1124"},EPSG_4722:{towgs84:"-794,119,-298"},EPSG_4728:{towgs84:"-307,-92,127"},EPSG_4734:{towgs84:"-632,438,-609"},EPSG_4727:{towgs84:"912,-58,1227"},EPSG_4729:{towgs84:"185,165,42"},EPSG_4730:{towgs84:"170,42,84"},EPSG_4733:{towgs84:"276,-57,149"},ESRI_37218:{towgs84:"230,-199,-752"},ESRI_37240:{towgs84:"-7,215,225"},ESRI_37221:{towgs84:"252,-209,-751"},ESRI_4305:{towgs84:"-123,-206,219"},ESRI_104139:{towgs84:"-73,-247,227"},EPSG_4748:{towgs84:"51,391,-36"},EPSG_4219:{towgs84:"-384,664,-48"},EPSG_4255:{towgs84:"-333,-222,114"},EPSG_4257:{towgs84:"-587.8,519.75,145.76"},EPSG_4646:{towgs84:"-963,510,-359"},EPSG_6881:{towgs84:"-24,-203,268"},EPSG_6882:{towgs84:"-183,-15,273"},EPSG_4715:{towgs84:"-104,-129,239"},IGNF_RGF93GDD:{towgs84:"0,0,0"},IGNF_RGM04GDD:{towgs84:"0,0,0"},IGNF_RGSPM06GDD:{towgs84:"0,0,0"},IGNF_RGTAAF07GDD:{towgs84:"0,0,0"},IGNF_RGFG95GDD:{towgs84:"0,0,0"},IGNF_RGNCG:{towgs84:"0,0,0"},IGNF_RGPFGDD:{towgs84:"0,0,0"},IGNF_ETRS89G:{towgs84:"0,0,0"},IGNF_RGR92GDD:{towgs84:"0,0,0"},EPSG_4173:{towgs84:"0,0,0"},EPSG_4180:{towgs84:"0,0,0"},EPSG_4619:{towgs84:"0,0,0"},EPSG_4667:{towgs84:"0,0,0"},EPSG_4075:{towgs84:"0,0,0"},EPSG_6706:{towgs84:"0,0,0"},EPSG_7798:{towgs84:"0,0,0"},EPSG_4661:{towgs84:"0,0,0"},EPSG_4669:{towgs84:"0,0,0"},EPSG_8685:{towgs84:"0,0,0"},EPSG_4151:{towgs84:"0,0,0"},EPSG_9702:{towgs84:"0,0,0"},EPSG_4758:{towgs84:"0,0,0"},EPSG_4761:{towgs84:"0,0,0"},EPSG_4765:{towgs84:"0,0,0"},EPSG_8997:{towgs84:"0,0,0"},EPSG_4023:{towgs84:"0,0,0"},EPSG_4670:{towgs84:"0,0,0"},EPSG_4694:{towgs84:"0,0,0"},EPSG_4148:{towgs84:"0,0,0"},EPSG_4163:{towgs84:"0,0,0"},EPSG_4167:{towgs84:"0,0,0"},EPSG_4189:{towgs84:"0,0,0"},EPSG_4190:{towgs84:"0,0,0"},EPSG_4176:{towgs84:"0,0,0"},EPSG_4659:{towgs84:"0,0,0"},EPSG_3824:{towgs84:"0,0,0"},EPSG_3889:{towgs84:"0,0,0"},EPSG_4046:{towgs84:"0,0,0"},EPSG_4081:{towgs84:"0,0,0"},EPSG_4558:{towgs84:"0,0,0"},EPSG_4483:{towgs84:"0,0,0"},EPSG_5013:{towgs84:"0,0,0"},EPSG_5264:{towgs84:"0,0,0"},EPSG_5324:{towgs84:"0,0,0"},EPSG_5354:{towgs84:"0,0,0"},EPSG_5371:{towgs84:"0,0,0"},EPSG_5373:{towgs84:"0,0,0"},EPSG_5381:{towgs84:"0,0,0"},EPSG_5393:{towgs84:"0,0,0"},EPSG_5489:{towgs84:"0,0,0"},EPSG_5593:{towgs84:"0,0,0"},EPSG_6135:{towgs84:"0,0,0"},EPSG_6365:{towgs84:"0,0,0"},EPSG_5246:{towgs84:"0,0,0"},EPSG_7886:{towgs84:"0,0,0"},EPSG_8431:{towgs84:"0,0,0"},EPSG_8427:{towgs84:"0,0,0"},EPSG_8699:{towgs84:"0,0,0"},EPSG_8818:{towgs84:"0,0,0"},EPSG_4757:{towgs84:"0,0,0"},EPSG_9140:{towgs84:"0,0,0"},EPSG_8086:{towgs84:"0,0,0"},EPSG_4686:{towgs84:"0,0,0"},EPSG_4737:{towgs84:"0,0,0"},EPSG_4702:{towgs84:"0,0,0"},EPSG_4747:{towgs84:"0,0,0"},EPSG_4749:{towgs84:"0,0,0"},EPSG_4674:{towgs84:"0,0,0"},EPSG_4755:{towgs84:"0,0,0"},EPSG_4759:{towgs84:"0,0,0"},EPSG_4762:{towgs84:"0,0,0"},EPSG_4763:{towgs84:"0,0,0"},EPSG_4764:{towgs84:"0,0,0"},EPSG_4166:{towgs84:"0,0,0"},EPSG_4170:{towgs84:"0,0,0"},EPSG_5546:{towgs84:"0,0,0"},EPSG_7844:{towgs84:"0,0,0"},EPSG_4818:{towgs84:"589,76,480"},EPSG_10328:{towgs84:"0,0,0"},EPSG_9782:{towgs84:"0,0,0"},EPSG_9777:{towgs84:"0,0,0"},EPSG_10690:{towgs84:"0,0,0"},EPSG_10639:{towgs84:"0,0,0"},EPSG_10739:{towgs84:"0,0,0"},EPSG_7686:{towgs84:"0,0,0"},EPSG_8900:{towgs84:"0,0,0"},EPSG_5886:{towgs84:"0,0,0"},EPSG_7683:{towgs84:"0,0,0"},EPSG_6668:{towgs84:"0,0,0"},EPSG_20046:{towgs84:"0,0,0"},EPSG_10299:{towgs84:"0,0,0"},EPSG_10310:{towgs84:"0,0,0"},EPSG_10475:{towgs84:"0,0,0"},EPSG_4742:{towgs84:"0,0,0"},EPSG_10671:{towgs84:"0,0,0"},EPSG_10762:{towgs84:"0,0,0"},EPSG_10725:{towgs84:"0,0,0"},EPSG_10791:{towgs84:"0,0,0"},EPSG_10800:{towgs84:"0,0,0"},EPSG_10305:{towgs84:"0,0,0"},EPSG_10941:{towgs84:"0,0,0"},EPSG_10968:{towgs84:"0,0,0"},EPSG_10875:{towgs84:"0,0,0"},EPSG_6318:{towgs84:"0,0,0"},EPSG_10910:{towgs84:"0,0,0"}};for(let t in Di){let e=Di[t];e.datumName&&(Di[e.datumName]=e)}var d0=Di;var m0=Object.freeze({name:"regional-datums",datums:Object.freeze(d0)});function S2(t){return{...t,parse(e,r){let n=t.parse(e,r),i=n.parameters.datum,o=s=>s.toLowerCase().replace(/[\s_-]/g,"");if(i&&!Object.keys(nr(r)).some(s=>o(s)===o(i))){let s={...n.parameters};return delete s.datum,{...n,parameters:s}}return n}}}var E2=[la,ha].map(S2),ki;function T2(){if(ki)return ki;let t=[Ms,ys,Ss,Es,Ts,bs,vs,Ps,As,Ns,Os,Ls,Gs,zs,Bs,Ds,ks,Us,Vs,js,Ws,$s,Ys,Xs,Ks,Zs,Qs,Js,ea,ta,ra,na,ia,oa,sa],e=i=>i.toLowerCase().replace(/[\s_-]/g,""),r=qi("longlat"),n={name:r.name,aliases:r.aliases,parameters:[...new Set([...r.parameters,...t.flatMap(i=>i.parameters)])],flags:[...new Set(t.flatMap(i=>i.flags||[]))],create(i){let o=i.parameters.o_proj;if(!o)throw new Error("Oblique transformation requires +o_proj");let s=["longlat","latlong","latlon","lonlat","identity"].includes(e(o))?"longlat":t.find(l=>[l.name,...l.aliases||[]].some(h=>e(h)===e(o)));if(!s)throw new Error("Unknown oblique transformation projection: "+o);let a=qi(s),c=new Set([...xi,...a.parameters]);for(let l of Object.keys(i.parameters))if(!c.has(l))throw new Error("Unsupported PROJ parameter: +"+l);return a.create(i)}};return ki=[...t,n],ki}var vt=class extends vi{constructor(e={}){super({...e,projections:e.projections??T2(),parsers:e.parsers??E2,datumCatalogs:e.datumCatalogs??[m0]})}},b2=new vt;var p0=new Map,da={},ma={},pa=new vt;function g0(){return pa}function M0(t,e){Ma(t,"CRS"),da[t]=e,pa=new vt({aliases:da,datumGrids:ma})}function y0(t,e){Ma(t,"datum grid"),ma[t]=fa(e),pa=new vt({aliases:da,datumGrids:ma})}function ga(t,e){Ma(t,"geoid model"),p0.set(t,e)}function x0(t,e,r={}){let n=cs(e,r);return ga(t,n),n}function Ui(t){return p0.get(t)}function Ma(t,e){if(!t.trim())throw new Error(`${e} name must not be empty`)}var We=class{spatialReference;horizontalProjection;geographicProjection;heightOutputProjection;sourceIsGeocentric;outputIsGeocentric;sourceIsGeographic;outputIsGeographic;geoid;constructor(e,r={}){this.spatialReference=e;let n=g0();R2(e);let i=e.targetCrs||e.sourceCrs;if(this.sourceIsGeocentric=ya(e.sourceCrs),this.outputIsGeocentric=ya(i),this.sourceIsGeographic=_0(e.sourceCrs),this.outputIsGeographic=_0(i),e.sourceCrs&&e.targetCrs&&!this.sourceIsGeocentric&&!this.outputIsGeocentric&&(this.horizontalProjection=n.createProjection({from:Jr(e.sourceCrs),to:Jr(e.targetCrs),enforceAxis:!1})),(en(e)||this.sourceIsGeocentric||this.outputIsGeocentric)&&(!this.sourceIsGeographic&&!this.sourceIsGeocentric&&(this.geographicProjection=n.createProjection({from:Jr(e.sourceCrs),to:Qt,enforceAxis:!1})),!this.outputIsGeographic&&!this.outputIsGeocentric&&(this.heightOutputProjection=n.createProjection({from:Qt,to:Jr(i),enforceAxis:!1}))),en(e)&&(this.geoid=C2(r.geoidModel),!this.geoid)){let o=typeof r.geoidModel=="string"?` "${r.geoidModel}"`:"";throw new Error(`Height conversion requires a registered geoid model${o}; call registerGeoidModel() or pass a parsed Geoid instance`)}}transformPosition(e){if(e.length<2)throw new Error("A spatial coordinate must contain at least x and y components");let r=[...e];if(en(this.spatialReference)||this.sourceIsGeocentric||this.outputIsGeocentric){if(r.length<3||!Number.isFinite(r[2]))throw new Error("Three-dimensional CRS conversion requires a finite z coordinate");let n=this.toGeographic(r);if(en(this.spatialReference)){let o=this.geoid.getHeight(n[1],n[0]);n[2]=A2(n[2],o,this.spatialReference.heightReference,this.spatialReference.targetHeightReference)}let i=this.fromGeographic(n);return r.splice(0,i.length,...i),r}if(this.horizontalProjection){let n=this.horizontalProjection.projectSync(r.slice(0,3));r.splice(0,n.length,...n)}return r}transformPositions(e){if(e.length%3!==0)throw new Error("Packed spatial positions must contain a multiple of three components");let r=new Float64Array(e.length);for(let n=0;n<e.length;n+=3){let i=this.transformPosition([Number(e[n]),Number(e[n+1]),Number(e[n+2])]);r[n]=i[0],r[n+1]=i[1],r[n+2]=i[2]}return r}transformNormals(e,r){if(e.length!==r.length||e.length%3!==0)throw new Error("Spatial normals and positions must have matching xyz component counts");let n=new Float32Array(e.length),i=1e-5;for(let o=0;o<e.length;o+=3){let s=[Number(r[o]),Number(r[o+1]),Number(r[o+2])],a=[Number(e[o]),Number(e[o+1]),Number(e[o+2])],c=v2(this,s,i),l=P2(c,a),h=Math.hypot(...l);h>0&&Number.isFinite(h)?(n[o]=l[0]/h,n[o+1]=l[1]/h,n[o+2]=l[2]/h):(n[o]=a[0],n[o+1]=a[1],n[o+2]=a[2])}return n}toGeographic(e){return this.sourceIsGeocentric?Array.from(L.WGS84.cartesianToCartographic(new M(e))):this.sourceIsGeographic?e.slice(0,3):this.geographicProjection.projectSync(e.slice(0,3))}fromGeographic(e){return this.outputIsGeocentric?Array.from(L.WGS84.cartographicToCartesian(new M(e))):this.outputIsGeographic?e.slice(0,3):this.heightOutputProjection.projectSync(e.slice(0,3))}};function v2(t,e,r){let n=[];for(let i=0;i<3;i++){let o=e.slice(),s=e.slice();o[i]+=r,s[i]-=r;let a=t.transformPosition(o),c=t.transformPosition(s);n.push([(a[0]-c[0])/(2*r),(a[1]-c[1])/(2*r),(a[2]-c[2])/(2*r)])}return n}function P2(t,e){let[r,n,i]=t,o=r[0]*(n[1]*i[2]-n[2]*i[1])-n[0]*(r[1]*i[2]-r[2]*i[1])+i[0]*(r[1]*n[2]-r[2]*n[1]);return!Number.isFinite(o)||Math.abs(o)<1e-15?e:[[n[1]*i[2]-n[2]*i[1],r[2]*i[1]-r[1]*i[2],r[1]*n[2]-r[2]*n[1]],[n[2]*i[0]-n[0]*i[2],r[0]*i[2]-r[2]*i[0],r[2]*n[0]-r[0]*n[2]],[n[0]*i[1]-n[1]*i[0],r[1]*i[0]-r[0]*i[1],r[0]*n[1]-r[1]*n[0]]].map(a=>(a[0]*e[0]+a[1]*e[1]+a[2]*e[2])/o)}function Jr(t){if(!t)throw new Error("Cannot construct a projection because the CRS is unknown");if(typeof t!="string"&&t.type==="CompoundCRS"){let e=t.components.filter(r=>r.type!=="VerticalCRS");if(e.length!==1)throw new Error("CompoundCRS requires exactly one horizontal component");return Jr(e[0])}return t}function R2(t){if(t.outputCoordinates==="local-enu")throw new Error("local-enu output requires a dataset-derived local origin and must be created by a tileset source");if(t.outputCoordinates==="target-crs"&&!t.targetCrs)throw new Error("target-crs output requires targetCrs");if(!t.sourceCrs&&t.status==="unresolved")throw new Error("Cannot transform coordinates because the source CRS is unknown");if(en(t)&&t.heightReference==="unknown")throw new Error("Cannot convert heights because the source height reference is unknown");if(t.coordinateFrame==="geocentric"&&!ya(t.sourceCrs))throw new Error("Only EPSG:4978 geocentric coordinates are supported by the current spatial transformer");if(t.status==="unresolved")throw new Error("The requested spatial output cannot be resolved from the available metadata")}function ya(t){return typeof t=="string"&&zr(t)===ni}function _0(t){if(typeof t!="string")return!1;let e=zr(t);return e===Qt||e==="EPSG:4979"||e==="OGC:CRS84"}function en(t){let e=t.targetHeightReference;return e!=="native"&&e!==t.heightReference}function C2(t){return typeof t=="string"?Ui(t):t}function A2(t,e,r,n){if(r===n||n==="native")return t;if(r==="orthometric"&&n==="ellipsoidal")return t+e;if(r==="ellipsoidal"&&n==="orthometric")return t-e;throw new Error(`Unsupported height conversion from ${r} to ${n}`)}var Pt=class{spatialReference;coordinateTransformer;geographicCoordinateTransformer;constructor(e,r={}){this.coordinateTransformer=new We(e,r);let n={...e,sourceCrs:"EPSG:4326",targetCrs:e.targetCrs||e.sourceCrs,coordinateFrame:"geographic",axisOrder:"xy"};this.geographicCoordinateTransformer=new We(n,r),this.spatialReference=e}transformPositions(e){return this.coordinateTransformer.transformPositions(e)}transformNormals(e,r){return this.coordinateTransformer.transformNormals(e,r)}transformBoundingVolume(e,r){let n=r?new z(Array.from(r)):void 0,i=e.region?I2(e.region):N2(e).map(s=>n?Array.from(n.transformAsPoint(s)):s);if(!i.length)return e;let o=e.region?i.map(s=>this.transformRegionSample(s)):i.map(s=>this.coordinateTransformer.transformPosition(s));return{box:O2(o)}}transformRegionSample(e){return this.geographicCoordinateTransformer.transformPosition(e)}};function I2(t){if(t.length<6||t.some(u=>!Number.isFinite(u)))return[];let[e,r,n,i,o,s]=t,a=n<e?n+Math.PI*2:n,c=w0(e,a),l=w0(r,i),h=[];for(let u of c)for(let f of l)for(let d of[o,s])h.push([u*180/Math.PI,f*180/Math.PI,d]);return h}function w0(t,e){let r=[t,(t+e)/2,e],n=Math.PI/2,i=Math.ceil(t/n),o=Math.floor(e/n);for(let s=i;s<=o;s++)r.push(s*n);return r}function N2(t){if(t.box&&t.box.length>=12){let e=t.box.slice(0,3),r=[t.box.slice(3,6),t.box.slice(6,9),t.box.slice(9,12)],n=[];for(let i=0;i<=4;i++)for(let o=0;o<=4;o++)for(let s=0;s<=4;s++){let a=i/2-1,c=o/2-1,l=s/2-1;n.push([e[0]+a*r[0][0]+c*r[1][0]+l*r[2][0],e[1]+a*r[0][1]+c*r[1][1]+l*r[2][1],e[2]+a*r[0][2]+c*r[1][2]+l*r[2][2]])}return n}if(t.sphere&&t.sphere.length>=4){let[e,r,n,i]=t.sphere,o=[[e-i,r,n],[e+i,r,n],[e,r-i,n],[e,r+i,n],[e,r,n-i],[e,r,n+i]];for(let s=0;s<16;s++){let a=s*Math.PI*2/16;o.push([e+i*Math.cos(a),r+i*Math.sin(a),n])}return o}return[]}function O2(t){let e=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let o of t)for(let s=0;s<3;s++)e[s]=Math.min(e[s],o[s]),r[s]=Math.max(r[s],o[s]);let n=[Math.max((r[0]-e[0])*.01,1e-9),Math.max((r[1]-e[1])*.01,1e-9),Math.max((r[2]-e[2])*.01,1e-9)];return[...[(e[0]+r[0])/2,(e[1]+r[1])/2,(e[2]+r[2])/2],(r[0]-e[0])/2+n[0],0,0,0,(r[1]-e[1])/2+n[1],0,0,0,(r[2]-e[2])/2+n[2]]}function S0(t,e){let r=t.map(([c,l])=>[c,l]);if(r.length===0)return r;let n=1/0,i=-1/0;for(let[c]of t)n=Math.min(n,c),i=Math.max(i,c);if(i-n>=360)return r;let o=e??r[0][0];for(let c of r){let l=c[0]-o;l>180?c[0]-=360*Math.ceil((l-180)/360):l<-180&&(c[0]+=360*Math.ceil((-l-180)/360)),o=c[0]}let s=t[0],a=t[t.length-1];if(s[0]===a[0]&&s[1]===a[1]){if(Math.abs(r[r.length-1][0]-r[0][0])>180)return t.map(([c,l])=>[c,l]);r[r.length-1]=[...r[0]]}return r}function L2(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(let[o,s]of t)e=Math.min(e,o),r=Math.min(r,s),n=Math.max(n,o),i=Math.max(i,s);return[[e,r],[n,i]]}function E0(t){let e=(r,n)=>{let i=t.cellToBoundary(r);return n?.unwrap?S0(i,n.referenceLongitude):i};return{...t,cellToBoundary:e,cellToBoundaryFlat:(r,n)=>n?.unwrap?e(r,n).flat():t.cellToBoundaryFlat(r),cellToBounds:(r,n)=>{let i=t.cellToBounds(r);if(!n?.unwrap||i[1][0]-i[0][0]>=360)return i;let o=L2(e(r,n));return o[0][1]=i[0][1],o[1][1]=i[1][1],o}}}var G2=(1n<<64n)-1n,z2=0x1555555555555555n;function ur(t){if(t==="X")return 0n;if(!T0(t))throw new Error(`Invalid S2 token: ${t}`);let e=t.padEnd(16,"0");return BigInt(`0x${e}`)}function tn(t){if(t===0n)return"X";if(!fr(t))throw new Error(`Invalid S2 index: ${t}`);let e=q2(t),r=e%4;e=(e-r)/4;let n=e;e*=4;let o=(t>>BigInt(e)).toString(16).replace(/0+$/,"");return Array(17-n-o.length).join("0")+o}function fr(t){if(typeof t!="bigint"||t<=0n||t>G2)return!1;let e=t>>61n,r=t&-t;return e<6n&&(r&z2)!==0n}function T0(t){if(typeof t!="string"||!/^[0-9a-fA-F]{1,16}$/.test(t)||t.endsWith("0"))return!1;let e=t.padEnd(16,"0");return fr(BigInt(`0x${e}`))}function q2(t){let e=0;for(;t%2n===0n;)t/=2n,e++;return e}function dr(t){if(!fr(t))throw new Error(`Invalid S2 index: ${t}`);let e=U2(t);return k2(e)}var F2=3,xa=30,B2=2*xa+1,b0=180/Math.PI,D2={a:[[0,"d"],[1,"a"],[3,"b"],[2,"a"]],b:[[2,"b"],[1,"b"],[3,"a"],[0,"c"]],c:[[2,"c"],[3,"d"],[1,"c"],[0,"b"]],d:[[0,"a"],[3,"c"],[1,"d"],[2,"d"]]};function k2(t){if(!/^[0-5]\/[0-3]{0,30}$/.test(t))throw new Error(`Invalid S2 Hilbert quadkey: ${t}`);let e=t.split("/"),r=parseInt(e[0],10),n=e[1]||"",i=n.length,o=0,s=[0,0];for(let a=i-1;a>=0;a--){o=i-a;let c=n[a],l=0,h=0;c==="1"?h=1:c==="2"?(l=1,h=1):c==="3"&&(l=1);let u=Math.pow(2,o-1);V2(u,s,l,h),s[0]+=u*l,s[1]+=u*h}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:o}}function U2(t){if(!fr(t))throw new Error(`Invalid S2 index: ${t}`);let e=t.toString(2);for(;e.length<F2+B2;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),i=e.substring(3,r),o=i.length/2,s=BigInt(`0b${n}`).toString(10),a="";if(o!==0)for(a=BigInt(`0b${i}`).toString(4);a.length<o;)a="0"+a;return`${s}/${a}`}function P0(t){let{face:e,ij:r,level:n}=t;if(!Number.isInteger(e)||e<0||e>5)throw new Error(`Invalid S2 face: ${e}`);if(!Number.isInteger(n)||n<0||n>xa)throw new Error(`Invalid S2 level: ${n}`);let i=2**n;if(!Number.isInteger(r[0])||!Number.isInteger(r[1])||r[0]<0||r[1]<0||r[0]>=i||r[1]>=i)throw new Error(`Invalid S2 IJ coordinates: ${r[0]}, ${r[1]}`);let o=j2(r[0],r[1],n,e),s=BigInt(e)<<61n;for(let a=0;a<o.length;a++){let c=59-a*2;s|=BigInt(o[a])<<BigInt(c)}return s|=1n<<BigInt(60-n*2),s}function _a(t,e,r,n){let i=dr(t);if(!Number.isInteger(e)||e<0||i.level+e>xa)throw new Error(`Invalid S2 relative level: ${e}`);let o=2**e;if(!Number.isInteger(r)||!Number.isInteger(n)||r<0||n<0||r>=o||n>=o)throw new Error(`Invalid S2 descendant coordinates: ${r}, ${n}`);return P0({face:i.face,ij:[i.ij[0]*o+r,i.ij[1]*o+n],level:i.level+e})}function rn(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function v0(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function nn(t){return[v0(t[0]),v0(t[1])]}function on(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function sn([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*b0,n*b0]}function V2(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let i=e[0];e[0]=e[1],e[1]=i}}function j2(t,e,r,n){let i=n%2===1?"d":"a",o=[];for(let s=r-1;s>=0;s--){let a=1<<s,c=(t&a)!==0?1:0,l=(e&a)!==0?1:0,[h,u]=D2[i][c*2+l];o.push(h),i=u}return o}var W2=100;function R0(t){let e=dr(t);return H2(e)}function H2({face:t,ij:e,level:r}){let n=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(W2*Math.pow(2,-r))),o=new Float64Array(4*i*2+2),s=0,a=0;for(let c=0;c<4;c++){let l=n[c].slice(0),h=n[c+1],u=(h[0]-l[0])/i,f=(h[1]-l[1])/i;for(let d=0;d<i;d++){l[0]+=u,l[1]+=f;let m=rn(e,r,l),p=nn(m),g=on(t,p),y=sn(g);Math.abs(y[1])>89.999&&(y[0]=a);let x=y[0]-a;y[0]+=x>180?-360:x<-180?360:0,o[s++]=y[0],o[s++]=y[1],a=y[0]}}return o[s++]=o[0],o[s++]=o[1],o}var $2=E0({name:"s2",hasNumericRepresentation:!0,cellColumnNames:["s2","s2Token","s2_token","s2Cell","s2_cell","s2CellId","s2_cell_id"],tokenToCell:t=>ur(t),cellToToken:t=>tn(ji(t)),cellToLngLat:t=>C0(t),cellToBoundary:t=>Y2(t),cellToBoundaryFlat:t=>wa(t),cellToBounds:t=>Vi(t)});function C0(t){let e=ji(t),r=dr(e),n=rn(r.ij,r.level,[.5,.5]),i=nn(n),o=on(r.face,i);return sn(o)}function wa(t){let e=ji(t),r=R0(e);return Array.from(r)}function Y2(t){let e=wa(t),r=[];for(let n=0;n<e.length;n+=2)r.push([e[n],e[n+1]]);return r}function Vi(t){let e=dr(ji(t));if(e.level===0)return X2(e.face);let r=[[0,0],[0,1],[1,1],[1,0]],n=1/0,i=1/0,o=-1/0,s=-1/0,a;for(let l of r){let h=rn(e.ij,e.level,l),u=nn(h),[f,d,m]=on(e.face,u),[p,g]=sn([f,d,m]);if(f===0&&d===0&&a!==void 0&&(p=a),a!==void 0){let y=p-a;p+=y>180?-360:y<-180?360:0}a=p,n=Math.min(n,p),i=Math.min(i,g),o=Math.max(o,p),s=Math.max(s,g)}let c=2*Number.EPSILON*180/Math.PI;return[[n-c,Math.max(-90,i-c)],[o+c,Math.min(90,s+c)]]}function ji(t){return typeof t=="bigint"?t:ur(t)}function X2(t){let e=Math.asin(Math.sqrt(.3333333333333333))*180/Math.PI;switch(t){case 0:return[[-45,-45],[45,45]];case 1:return[[45,-45],[135,45]];case 2:return[[-180,e],[180,90]];case 3:return[[135,-45],[225,45]];case 4:return[[-135,-45],[-45,45]];case 5:return[[-180,-90],[180,-e]];default:throw new Error(`Invalid S2 face: ${t}`)}}function Wi(t){let[[e,r],[n,i]]=Vi(t.token),o=br([e,r,n,i,t.minimumHeight,t.maximumHeight],L.WGS84,{units:"degrees"});return[...o.center,...o.halfAxes]}var K2=4,Z2=8,A0=new WeakMap;function Ea(t,e){return{coordinates:e,subtreeUrl:cn(t.subtreesUrlTemplate,e),descriptor:t,resource:F0(t.resourceFiles,cn(t.subtreesUrlTemplate,e))}}function Hi(t,e){let{descriptor:r}=e;oM(r),Q2(t,r);let n={tileCount:0,childSubtreeCount:0},i=q0(t,e,{localLevel:0,mortonIndex:0},e.coordinates,n);if(!i)throw new Error(`Invalid 3D Tiles subtree: root tile is unavailable at ${e.subtreeUrl}`);return{root:i,...n}}function Q2(t,e){let r=U0(e.subdivisionScheme),n=(r**e.subtreeLevels-1)/(r-1),i=r**e.subtreeLevels;Sa(t.tileAvailability,n,"tile");let o=Array.isArray(t.contentAvailability)?t.contentAvailability:t.contentAvailability?[t.contentAvailability]:[];for(let c of o)Sa(c,n,"content");Sa(t.childSubtreeAvailability,i,"child subtree");let s=I0(t.tileAvailability,n),a=o[0]?I0(o[0],n):0;if(N0(t.tileAttributes,s,"tile"),N0(t.contentAttributes,a,"content"),t.tilePropertyRows&&t.tilePropertyRows.length!==s)throw new Error("3DTILES_subtree: tile property-table count does not match availability");if(t.contentPropertyRows&&t.contentPropertyRows.length!==a)throw new Error("3DTILES_subtree: content property-table count does not match availability")}function Sa(t,e,r){if(!(t.constant===0||t.constant===1)&&(!t.explicitBitstream||t.explicitBitstream.byteLength*8<e))throw new Error(`3DTILES_subtree: ${r} availability bitstream is too short`)}function I0(t,e){if(t.constant===1)return e;if(t.constant===0)return 0;let r=0;for(let n=0;n<e;n++)mr(t,n)&&r++;return r}function N0(t,e,r){let n={TILE_BOUNDING_BOX:16,TILE_BOUNDING_SPHERE:4,TILE_GEOMETRIC_ERROR:1,TILE_REFINE:1,TILE_TRANSFORM:16,CONTENT_BOUNDING_BOX:16,CONTENT_BOUNDING_SPHERE:4};for(let[i,o]of Object.entries(t||{})){let s=n[i];if(s&&o.length!==e*s)throw new Error(`3DTILES_subtree: ${r} attribute ${i} count does not match availability`)}}function cn(t,e,r={}){let n={level:e.level,x:e.x,y:e.y,z:e.z,...r};return t.replace(/{([^{}]+)}/g,(i,o)=>{let s=Object.hasOwn(n,o)?n[o]:n[o.toLowerCase()];return s===void 0?i:String(s)})}function q0(t,e,r,n,i){let{descriptor:o}=e,s=U0(o.subdivisionScheme),a=rM(s,r.localLevel)+r.mortonIndex;if(!mr(t.tileAvailability,a))return null;i.tileCount++;let c=tM(t.contentAvailability,a),l=[];if(n.level<o.maximumLevel)if(r.localLevel+1<o.subtreeLevels)for(let h=0;h<s;h++){let u=G0(n,h,o.subdivisionScheme),f=q0(t,e,{localLevel:r.localLevel+1,mortonIndex:r.mortonIndex*s+h},u,i);f&&l.push(f)}else for(let h=0;h<s;h++){let u=r.mortonIndex*s+h;if(mr(t.childSubtreeAvailability,u)){let f=G0(n,h,o.subdivisionScheme);l.push(J2(t,o,f)),i.childSubtreeCount++}}return eM(t,o,e,n,a,c,l)}function J2(t,e,r){let n=B0(e.resourceFiles,t.resourceFiles),i=n?{...e,resourceFiles:n}:e,o=Ea(i,r);return{id:k0(o,r),children:[],implicitSubtree:o,boundingVolume:V0(e.rootBoundingVolume,r,e.subdivisionScheme),geometricError:e.rootLodMetricValue/2**r.level,lodMetricType:e.lodMetricType,lodMetricValue:e.rootLodMetricValue/2**r.level,refine:e.refine,type:tt.EMPTY,implicitMetadata:D0(t),_scaleGeometricError:e.scaleGeometricError!==!1}}function O0(t,e,r){if(!t||e<0)return{};let n=an(t[r==="tile"?"TILE_BOUNDING_BOX":"CONTENT_BOUNDING_BOX"],e,16),i=an(t[r==="tile"?"TILE_BOUNDING_SPHERE":"CONTENT_BOUNDING_SPHERE"],e,4),o=n?{box:[n[12],n[13],n[14],n[0]/2,n[1]/2,n[2]/2,n[4]/2,n[5]/2,n[6]/2,n[8]/2,n[9]/2,n[10]/2]}:i?{sphere:i}:void 0;if(r==="content")return{boundingVolume:o};let s=an(t.TILE_GEOMETRIC_ERROR,e,1)?.[0];if(s!==void 0&&(!Number.isFinite(s)||s<0))throw new Error("3DTILES_subtree: TILE_GEOMETRIC_ERROR must be nonnegative");let a=an(t.TILE_REFINE,e,1)?.[0];if(a!==void 0&&a!==0&&a!==1)throw new Error("3DTILES_subtree: TILE_REFINE must be 0 or 1");return{boundingVolume:o,geometricError:s,refine:a===void 0?void 0:a===0?ne.ADD:ne.REPLACE,transform:an(t.TILE_TRANSFORM,e,16)}}function an(t,e,r){if(!t)return;let n=e*r;if(n+r>t.length)throw new Error("3DTILES_subtree: attribute accessor is shorter than availability");return Array.from({length:r},(i,o)=>Number(t[n+o]))}function L0(t,e){if(t.constant===1)return e;if(t.constant===0)return 0;let r=A0.get(t);if(!r){let n=(t.explicitBitstream?.byteLength||0)*8;r=new Uint32Array(n+1);for(let i=0;i<n;i++)r[i+1]=r[i]+Number(mr(t,i));A0.set(t,r)}return r[e]}function F0(t,e){if(!t?.length)return;let r=e.split("?")[0],n=/^gltf-package:\/\/[^/]+\/(.*)$/.exec(r)?.[1],i=t.findIndex(s=>{let a=s.originalUri||s.name;return s.uri===r||!!(a&&(r===a||n===a))});if(i>=0)return{fileIndex:i,files:t};let o=t.findIndex(s=>{let a=s.originalUri||s.name;return!!(a&&(r.endsWith(`/${a}`)||r.endsWith(`:${a}`)))});return o<0?void 0:{fileIndex:o,files:t}}function B0(t,e){if(!e?.length)return t;if(!t?.length)return e;let r=new Set(e.flatMap(n=>[n.uri,n.originalUri,n.name].filter(Boolean)));return[...e,...t.filter(n=>![n.uri,n.originalUri,n.name].some(i=>i&&r.has(i)))]}function eM(t,e,r,n,i,o,s){let a=L0(t.tileAvailability,i),c=t.tilePropertyRows?.[a],l=Array.isArray(t.contentAvailability)?t.contentAvailability[0]:t.contentAvailability,h=l&&mr(l,i)?L0(l,i):-1,u=t.contentPropertyRows?.[h],f=t.tileTemplatePropertyRows?.[a]||c,d=t.contentTemplatePropertyRows?.[h]||u,m={...f,...d},p=O0(t.tileAttributes,a,"tile"),g=O0(t.contentAttributes,h,"content"),x=(e.contentUrlTemplates?.length?e.contentUrlTemplates:[e.contentUrlTemplate]).map((P,R)=>{if(!o[R]||!P)return null;let N=cn(P,n,m);if(/{[^{}]+}/.test(N))throw new Error(`Implicit content URI has unresolved template values: ${N}`);return{contentIndex:R,contentUrl:N}}).filter(P=>!!P),w=x.map(P=>P.contentUrl),_=B0(e.resourceFiles,t.resourceFiles),S=x.map(({contentIndex:P,contentUrl:R})=>{let N=F0(_,R);return{...e.contentHeaders?.[P]||(P===0?e.contentHeader:{})||{},...g,uri:R,...u?{metadata:{properties:u}}:{},...N?{_resource:N}:{}}}),E=w[0],v=e.rootLodMetricValue/2**n.level,T=p.geometricError??v,I=V0(e.rootBoundingVolume,n,e.subdivisionScheme);return{id:k0(r,n),children:s,contentUrl:E,content:S.length>1?S:S[0],contents:e.useCanonicalContents&&S.length?S:void 0,contentUrls:w,refine:p.refine||e.refine,type:iM(E),lodMetricType:e.lodMetricType,lodMetricValue:T,geometricError:T,boundingVolume:p.boundingVolume||I,transform:p.transform,transformMatrix:p.transform,metadata:c?{properties:c}:void 0,implicitMetadata:D0(t,c,u),_scaleGeometricError:e.scaleGeometricError!==!1}}function D0(t,e,r){if(!(!t.propertyTables&&t.tileMetadata===void 0&&!t.contentMetadata&&t.subtreeMetadata===void 0&&!e&&!r))return{propertyTables:t.propertyTables,tileMetadata:t.tileMetadata,contentMetadata:t.contentMetadata,subtreeMetadata:t.subtreeMetadata,tileProperties:e,contentProperties:r}}function k0(t,e){return`${t.subtreeUrl}#implicit=${e.level}/${e.x}/${e.y}/${e.z}`}function mr(t,e){if(typeof t?.constant=="number")return!!t.constant;let r=t?.explicitBitstream;if(!r)return!1;let n=Math.floor(e/8),i=e%8;return!!(r[n]>>i&1)}function tM(t,e){return(Array.isArray(t)?t:[t]).map(n=>mr(n||{constant:0},e))}function rM(t,e){return(t**e-1)/(t-1)}function G0(t,e,r){return{level:t.level+1,x:t.x*2+(e&1),y:t.y*2+(e>>1&1),z:r==="OCTREE"?t.z*2+(e>>2&1):0}}function U0(t){return t==="OCTREE"?Z2:K2}function V0(t,e,r){if(t.region){let[n,i,o,s,a,c]=t.region,l=2**e.level,u=(o>=n?o-n:o+2*Math.PI-n)/l,f=(s-i)/l,d=z0(n+u*e.x),m=z0(n+u*(e.x+1)),p=i+f*e.y,g=a,y=c;if(r==="OCTREE"){let x=(c-a)/l;g=a+x*e.z,y=g+x}return{region:[d,p,m,p+f,g,y]}}if(t.box){if(t.s2VolumeInfo)return nM(t,e,r);if(t.extensions?.["3DTILES_shape_cylinder_region"])return{...t,box:[...t.box]};let n=t.box,i=2**e.level,o=-1+(2*e.x+1)/i,s=-1+(2*e.y+1)/i,a=-1+(2*e.z+1)/i,c=r==="OCTREE";return{box:[...[n[0]+n[3]*o+n[6]*s+(c?n[9]*a:0),n[1]+n[4]*o+n[7]*s+(c?n[10]*a:0),n[2]+n[5]*o+n[8]*s+(c?n[11]*a:0)],n[3]/i,n[4]/i,n[5]/i,n[6]/i,n[7]/i,n[8]/i,c?n[9]/i:n[9],c?n[10]/i:n[10],c?n[11]/i:n[11]]}}throw new Error(`Unsupported implicit 3D Tiles bounding volume: ${JSON.stringify(t)}`)}function nM(t,e,r){let n=t.s2VolumeInfo,i=ur(n.token),o=_a(i,e.level,e.x,e.y),s=2**e.level,a=(n.maximumHeight-n.minimumHeight)/s,c={token:tn(o),minimumHeight:n.minimumHeight+(r==="OCTREE"?a*e.z:0),maximumHeight:n.minimumHeight+(r==="OCTREE"?a*(e.z+1):a*s)},l=t.extensions?{...t.extensions}:void 0;return l?.["3DTILES_bounding_volume_S2"]&&(l["3DTILES_bounding_volume_S2"]=c),l?.["3DTILES_shape_s2"]&&(l["3DTILES_shape_s2"]=c),{...t,...l?{extensions:l}:{},s2VolumeInfo:c,box:Wi(c)}}function z0(t){let e=t;for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function iM(t){if(!t)return tt.EMPTY;let e=t.split("?")[0].split(".").pop()?.toLowerCase();switch(e){case"pnts":return tt.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return tt.SCENEGRAPH;default:return e||tt.EMPTY}}function oM(t){if(t.subdivisionScheme!=="QUADTREE"&&t.subdivisionScheme!=="OCTREE")throw new Error(`Unsupported implicit subdivision scheme: ${t.subdivisionScheme}`);if(!Number.isInteger(t.subtreeLevels)||t.subtreeLevels<1)throw new Error("Implicit subtreeLevels must be a positive integer");if(!Number.isInteger(t.maximumLevel)||t.maximumLevel<0)throw new Error("Implicit availableLevels must describe at least the root level")}var sM={draco:!1,meshopt:!1,dds:!1,ktx2:!1},aM=32,$i=class{type=le.TILES3D;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...sM};asset;properties;extras;credits;metadata;queryParams={};tileUrlCache=new Map;tileContentHeaders=new WeakMap;nestedTilesetRoots=new WeakMap;packageNamespaces=new WeakMap;nextPackageNamespace=0;implicitSubtreeCache;implicitTilingStats={requestedSubtrees:0,loadedSubtrees:0,cacheHits:0,materializedTiles:0};destroyed=!1;extensionsUsed=[];resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(e,r={}){let n=cM(e);this.rootTileset=W0(e)?null:e,this.tileset=this.rootTileset,this.loader=n.loader,this.url=n.url,this.basePath=n.basePath||Ce.dirname(n.url),this.resolver=n.resolver,this.coreApi=n.coreApi,this.loadOptions=r;let i=Number(r["3d-tiles"]?.maximumCachedSubtrees),o=Number.isFinite(i)?Math.max(0,Math.floor(i)):aM;this.implicitSubtreeCache=new Pr({maxEntries:o})}destroy(){this.destroyed=!0,this.tileUrlCache.clear(),this.implicitSubtreeCache.clear()}async initialize(){if(!this.rootTileset){let e=this.loadOptions[this.loader.id]||{};this.rootTileset=await this.loadRootData(this.url,{...this.loadOptions,[this.loader.id]:{...e,isTileset:!0}})}if(this.tileset=this.rootTileset,this.rootTileset.queryString){let e=new URLSearchParams(this.rootTileset.queryString);for(let[r,n]of e.entries())this.setQueryParameter(r,n)}if(this.asset=this.rootTileset.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.rootTileset.formatVersion!=="2.0-draft"&&this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version 0.0, 1.0, 1.1, or 2.0-draft.");"tilesetVersion"in this.asset&&this.setQueryParameter("v",this.asset.tilesetVersion),this.properties=this.rootTileset.properties,this.extras=this.rootTileset.extras,this.credits={attributions:[]},this.extensionsUsed.splice(0,this.extensionsUsed.length,...this.rootTileset.extensionsUsed||[]),this.metadata={type:this.type,loader:this.loader,url:this.url,basePath:this.basePath,tileset:this.rootTileset,lodMetricType:this.rootTileset.lodMetricType,lodMetricValue:this.rootTileset.lodMetricValue,refine:this.rootTileset.root?.refine,spatialReference:gi(this.rootTileset)}}getMetadata(){if(!this.metadata)throw new Error("Tiles3DSource has not been initialized");return this.metadata}async getRootTileset(){return this.getMetadata().tileset}async prepareTileset(e){let r=e.spatialReference;if(r.status==="unresolved")throw new Error(r.warnings[0]||"3D Tiles spatial operations cannot be resolved from the supplied metadata and options");r.status!=="transformable"&&r.status!=="transformed"||(this.spatialTransformer||=new Pt(r,e.options.spatial),e.spatialReference=Jt(r),this.preparedRootHeader=this.transformTileHeader(this.getMetadata().tileset.root,new z))}initializeTileHeaders(e,r,n){let i=n?r.root:this.preparedRootHeader||r.root,o=new Ne(e,i,n||void 0);n&&(n.children.push(o),o.depth=n.depth+1);let s=[o];for(;s.length>0;){let a=s.pop();e.stats.get("Tiles In Tileset(s)").incrementCount();let c=a.header.children||[];for(let l of c){let h=new Ne(e,l,a);if(h.contentUrl?.includes("?session=")){let f=new URL(h.contentUrl).searchParams.get("session");f&&this.setQueryParameter("session",f)}a.children.push(h),h.depth=a.depth+1,s.push(h)}}return o}createTraverser(e){return new mi(e)}async loadTileContent(e){let r=(e.contentUrls||[e.contentUrl]).filter(Boolean),n=this.tileContentHeaders.get(e),i=n||(Array.isArray(e.header?.content)?e.header.content:e.header?.content?[e.header.content]:[]);n||this.tileContentHeaders.set(e,i);let o=this.loadOptions[this.loader.id]||{},s={...this.loadOptions,[this.loader.id]:{...o,isTileset:"auto",assetGltfUpAxis:this.asset&&this.asset.gltfUpAxis||"Y",_tilesetOptions:{spatialReference:e.header?._spatialReference||e.tileset?.spatialReference,spatialOptions:e.tileset?.options.spatial,spatialTransform:e.header?._spatialTransform}}},a=await Promise.all(r.map((l,h)=>{let u=i[h]||{},f=u.extensions?.["3DTILES_content_gltf_vector"],d=u._vectorContent||(f?.vector===!0?{clip:f.clip===!0}:void 0),m=d?{...s,[this.loader.id]:{...s[this.loader.id],vectorContent:d}}:s;return this.loadContentResource(this.getTileUrl(l),u._resource,m)}));e.contents=a,e.content=a[0]||null;let c=a.filter(l=>l?.shape==="tileset3d");return{loaded:!0,contents:a,nestedTileset:c[0],nestedTilesets:c}}transformTileHeader(e,r=new z){return this.spatialTransformer?this.transformTileHeaderWithTransformer(e,this.spatialTransformer,r):e}transformTileHeaderWithTransformer(e,r,n,i){let o=e.transform?new z(e.transform):new z,s=new z(n).multiplyRight(o),a=Array.isArray(e.content)?e.content.map(c=>this.transformContentHeader(c,s,r)):e.content?this.transformContentHeader(e.content,s,r):e.content;return{...e,transform:void 0,boundingVolume:e.boundingVolume?r.transformBoundingVolume(e.boundingVolume,s):e.boundingVolume,_spatialReference:i,_spatialTransform:s.toArray(),content:a,children:Array.isArray(e.children)?e.children.map(c=>this.transformTileHeaderWithTransformer(c,r,s,i)):e.children}}transformContentHeader(e,r,n){return{...e,boundingVolume:e.boundingVolume?n.transformBoundingVolume(e.boundingVolume,r):e.boundingVolume}}async loadTileChildren(e,r){let n=e.header.implicitSubtree;if(!n)return{loaded:!1,tileCount:0,childSubtreeCount:0};let i=this.getTileUrl(n.subtreeUrl),o=await this.loadImplicitSubtreeResource(i,n.resource);if(this.destroyed||e.isDestroyed())return{loaded:!1,tileCount:0,childSubtreeCount:0};let s=Hi(o,{...n,subtreeUrl:i}),a=e.header._spatialReference,c=a?new Pt(a,e.tileset.options.spatial):this.spatialTransformer,l=c?this.transformTileHeaderWithTransformer(s.root,c,new z,a):s.root;e.applyImplicitSubtreeHeader(l);let h=this.initializeMaterializedChildren(e.tileset,e,l.children);return this.implicitTilingStats.loadedSubtrees++,this.implicitTilingStats.materializedTiles+=h,{loaded:!0,tileCount:s.tileCount,childSubtreeCount:s.childSubtreeCount}}async loadTileChildrenForTraversal(e,r){j0(r);let n=await this.loadTileChildren(e,{});return j0(r),n}getImplicitTilingStats(){return{...this.implicitTilingStats,cachedSubtrees:this.implicitSubtreeCache.size-this.implicitSubtreeCache.pendingSize,pendingSubtrees:this.implicitSubtreeCache.pendingSize}}getTileUrl(e){if(e.startsWith("data:"))return e;let r=this.tileUrlCache.get(e);if(r)return r;if(!Object.keys(this.queryParams).length)return this.tileUrlCache.set(e,e),e;let[n,i=""]=e.split("?"),o=new URLSearchParams(i);for(let[c,l]of Object.entries(this.queryParams))o.has(c)||o.set(c,l);let s=o.toString(),a=s?`${n}?${s}`:n;return this.tileUrlCache.set(e,a),a}setQueryParameter(e,r){this.queryParams[e]!==r&&(this.queryParams[e]=r,this.tileUrlCache.clear())}getViewState(e){if(!e)return{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits};let{center:r}=e.boundingVolume,n;return r&&(r[0]!==0||r[1]!==0||r[2]!==0)?(n=new M,L.WGS84.cartesianToCartographic(r,n)):n=new M(0,0,-L.WGS84.radii[0]),{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits,boundingVolume:e.boundingVolume,cartographicCenter:n,cartesianCenter:r,zoom:xh(e.boundingVolume,n)}}hasExtension(e){return this.extensionsUsed.includes(e)}onTileLoaded(e,r,n){let o=(r.contents.length?r.contents:[r.content]).flatMap(c=>c?.gltf?.extensionsRemoved||[]);o.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),o.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),o.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0);let s=n.nestedTilesets||(n.nestedTileset?[n.nestedTileset]:[]),a=this.nestedTilesetRoots.get(r)||[];for(let[c,l]of s.entries()){let h=a[c];if(h&&r.children.includes(h))continue;let u=a.slice(c+1).find(d=>r.children.includes(d)),f=e._initializeTileHeaders(this.prepareNestedTileset(e,l),r);u&&(r.children.splice(r.children.indexOf(f),1),r.children.splice(r.children.indexOf(u),0,f)),a[c]=f,this.nestedTilesetRoots.set(r,a)}}prepareNestedTileset(e,r){let n=r.spatialMetadata,i=e.spatialReference;if(n?.status==="unresolved"||n?.crs.state==="unknown")throw new Error(n.warnings[0]||"Nested 3D Tiles CRS is explicitly unresolved and cannot be placed in the parent frame");if(!n||!n.sourceCrs)return this.spatialTransformer&&(i.status==="transformable"||i.status==="transformed")?{...r,spatialMetadata:i,root:this.transformTileHeaderWithTransformer(r.root,this.spatialTransformer,new z,i)}:Ta(r,i);let o=i.coordinateEpoch,s=n.coordinateEpoch;if(o!==void 0&&s!==void 0&&o!==s)throw new Error(`Nested 3D Tiles coordinate epoch ${s} differs from parent epoch ${o}; epoch-aware transformation is unavailable`);let a=i.targetCrs||i.sourceCrs;if(!a)return Ta(r,n);let c=It(n,{...e.options.spatial,outputCoordinates:"target-crs",targetCrs:a});if(c.status==="unresolved")throw new Error(c.warnings[0]||"Nested 3D Tiles CRS cannot be resolved in the parent output frame");if(c.status==="native")return Ta(r,c);let l=new Pt(c,e.options.spatial);return{...r,spatialMetadata:c,root:this.transformTileHeaderWithTransformer(r.root,l,new z,c)}}async loadWithCoreApi(e,r,n=this.loader){if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to load tileset data");return await this.coreApi.load(e,n,r)}async loadRootData(e,r){return this.resolver?await this.resolver.loadRoot(e,this.loader,r):await this.loadWithCoreApi(e,r)}async loadResourceData(e,r,n=this.loader){return this.resolver?await this.resolver.loadResource(e,n,r):await this.loadWithCoreApi(e,r,n)}async loadContentResource(e,r,n){if(!r)return await this.loadResourceData(e,n);let i=r.files[r.fileIndex];if(!i)throw new Error(`3D Tiles package references missing file ${r.fileIndex}`);if(i.uri)return await this.loadResourceData(this.getTileUrl(i.uri),n);if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to parse embedded package data");let o=await this.getPackageFileData(i),a=`gltf-package://${this.getPackageNamespace(r.files)}/${r.fileIndex}`,c=i.name||"content",l=c.lastIndexOf("/"),h=l>=0?`${a}/${c.slice(0,l)}`:a;return await this.coreApi.parse(o,this.loader,n,{url:`${a}/${c}`,filename:c,baseUrl:h,loaders:[this.loader],coreApi:this.coreApi,_parse:this.coreApi.parse,_tiles3dPackageFiles:r.files,fetch:async(u,f)=>{let d=u.startsWith(`${a}/`)?u.slice(a.length+1):u,m=r.files.find(g=>g.name===d||g.originalUri===d);if(!m)throw new Error(`3D Tiles glTF package does not contain file ${d}`);if(m.uri)return await this.coreApi.fetchFile(this.getTileUrl(m.uri),f);let p=await this.getPackageFileData(m);return new Response(p,{headers:{"content-type":m.mimeType}})}})}getPackageNamespace(e){let r=this.packageNamespaces.get(e);if(r!==void 0)return r;let n=this.nextPackageNamespace++;return this.packageNamespaces.set(e,n),n}async getPackageFileData(e){if(e.data)return Bn(e.data,e.byteOffset,e.byteLength);if(e.bufferUri&&this.coreApi){let r=await this.coreApi.fetchFile(this.getTileUrl(e.bufferUri));if(!r.ok)throw new Error(`Failed to fetch 3D Tiles package buffer: HTTP ${r.status}`);let n=await r.arrayBuffer();return Bn(n,e.byteOffset,e.byteLength)}throw new Error("3D Tiles package file has no available byte source")}async loadImplicitSubtreeResource(e,r){let n=this.implicitSubtreeCache.get(e);if(n)return this.implicitTilingStats.cacheHits++,await n;this.implicitTilingStats.requestedSubtrees++;let i=this.loadOptions[this.loader.id]||{};return await this.implicitSubtreeCache.getOrLoad(e,async()=>{let o={...this.loadOptions,[this.loader.id]:{...i,isTileset:!1,isSubtree:!0}};return await(r?this.loadContentResource(e,r,o):this.loadResourceData(e,o))})}initializeMaterializedChildren(e,r,n){let i=0,o=[{parentTile:r,childHeaders:n}];for(;o.length>0;){let s=o.pop();for(let a of s.childHeaders){let c=new Ne(e,a,s.parentTile);s.parentTile.children.push(c),c.depth=s.parentTile.depth+1,e.stats.get("Tiles In Tileset(s)").incrementCount(),i++,a.children?.length&&o.push({parentTile:c,childHeaders:a.children})}}return i}};function j0(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted","AbortError")}function W0(t){return!!(t&&typeof t=="object"&&"url"in t&&"loader"in t&&!("type"in t))}function cM(t){return W0(t)?{...t,basePath:t.basePath||Ce.dirname(t.url)}:{url:t.url,loader:t.loader,basePath:t.basePath||Ce.dirname(t.url),resolver:t.resolver,coreApi:t.coreApi}}function Ta(t,e){let r=n=>({...n,_spatialReference:e,children:Array.isArray(n.children)?n.children.map(r):n.children});return{...t,spatialMetadata:e,root:r(t.root)}}var Yi=class{frameNumberMap=new Map;register(e,r){let n=this.frameNumberMap.get(e)||new Map,i=n.get(r)||0;n.set(r,i+1),this.frameNumberMap.set(e,n)}deregister(e,r){let n=this.frameNumberMap.get(e);if(!n)return;let i=n.get(r)||1;n.set(r,i-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var ba={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},Xi=class{_statusMap;pendingTilesRegister=new Yi;constructor(){this._statusMap={}}add(e,r,n,i){if(!this._statusMap[r]){let{frameNumber:o,viewport:{id:s}}=i;this._statusMap[r]={request:e,callback:n,key:r,frameState:i,status:ba.REQUESTED},this.pendingTilesRegister.register(s,o),e().then(a=>{this._statusMap[r].status=ba.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,i)}).catch(a=>{this._statusMap[r].status=ba.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),n(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:n,viewport:{id:i}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(i,n);let{frameNumber:o,viewport:{id:s}}=r;this.pendingTilesRegister.register(s,o),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var Ki=class extends rt{_tileManager;constructor(e){super(e),this._tileManager=new Xi}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=di(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let n=e.header.children||[],i=e.children;for(let o of n){let s=`${o.id}-${r.viewport.id}`,a=i&&i.find(c=>c.id===s||c.header?.id===o.id);if(a)a&&this.updateTile(a,r);else{let c=()=>this._loadTile(e,o.id,r);this._tileManager.find(s)?this._tileManager.update(s,r):this._tileManager.add(c,s,h=>this._onTileLoad(h,e,s),r)}}return!1}async _loadTile(e,r,n){if(!e.tileset.source.loadChildTileHeader)throw new Error("I3S source does not support child tile header loading");return await e.tileset.source.loadChildTileHeader(e,r,n)}_onTileLoad(e,r,n){if(e instanceof Error){r.tileset._onSourceError(e,r);return}let i=new Ne(r.tileset,e,r,n);r.children.push(i);let o=this._tileManager.find(i.id).frameState;this.updateTile(i,o),this._frameNumber===o.frameNumber&&(this.traversalFinished(o)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(i,o)}};var gr=class{spatialReference;targetCoordinateFrame;positionTransformer;sourceToGeographicTransformer;geographicToTargetTransformer;sourceCoordinateFrame;sourceVerticalUnitScale;elevationMode;elevationOffset;elevationProvider;providerUnitScale;providerHeightTransformer;constructor(e,r={}){if(e.status!=="transformable"&&e.status!=="transformed")throw new Error("I3SSpatialTransformer requires a requested, transformable spatial output");let n=e.targetCrs||e.sourceCrs;if(!n)throw new Error("I3S spatial transformation requires a target CRS");if(this.positionTransformer=new We(e,r),this.sourceCoordinateFrame=e.coordinateFrame,this.sourceVerticalUnitScale=e.verticalUnitScale,this.elevationMode=e.elevationMode,this.elevationOffset=(e.elevationOffset||0)*e.elevationUnitScale,this.elevationProvider=lM(this.elevationMode,r),this.elevationProvider&&(typeof this.elevationProvider.sampleElevations!="function"||typeof this.elevationProvider.getElevationRange!="function"))throw new Error("An I3S elevation provider must implement sampleElevations() and getElevationRange()");let i=Fr(this.elevationProvider?.unit||"meter");if(this.elevationProvider&&i===void 0)throw new Error(`Unsupported elevation-provider unit ${this.elevationProvider.unit}`);this.providerUnitScale=i||1,this.targetCoordinateFrame=Ae(n),this.spatialReference=Jt(e);let o=Ie({sourceCrs:e.sourceCrs,heightReference:e.heightReference,coordinateFrame:e.coordinateFrame,axisOrder:e.axisOrder,provenance:e.provenance},{targetCrs:"EPSG:4326"});if(this.sourceToGeographicTransformer=new We(o),pr(this.elevationMode)){if(!this.elevationProvider){let c=this.elevationMode==="relativeToScene"?"scene":"terrain";throw new Error(`I3S elevation mode ${this.elevationMode} requires a ${c} elevation provider`)}if(e.heightReference==="unknown")throw new Error(`I3S elevation mode ${this.elevationMode} requires a known source height reference`);let a=this.elevationProvider.heightReference||e.heightReference;if(a!==e.heightReference){if(e.heightReference!=="ellipsoidal"&&e.heightReference!=="orthometric")throw new Error("Converting elevation-provider heights requires an ellipsoidal or orthometric source height reference");let c=Ie({sourceCrs:"EPSG:4326",heightReference:a,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"caller-override"},{targetCrs:"EPSG:4326",targetHeightReference:e.heightReference,geoidModel:r.geoidModel});this.providerHeightTransformer=new We(c,r)}}let s=Ie({sourceCrs:"EPSG:4326",heightReference:e.heightReference,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"format-default"},{targetCrs:n,targetHeightReference:e.targetHeightReference,geoidModel:r.geoidModel});this.geographicToTargetTransformer=new We(s,r)}transformPosition(e){let r=this.placeSourcePositionsSync(e),n=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}async transformPositionAsync(e){let r=await this.placeSourcePositions(e),n=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}transformPlacedPosition(e){let r=this.positionTransformer.transformPosition([e[0],e[1],e[2]]);return[r[0],r[1],r[2]]}transformSourcePositionToGeographic(e){let r=this.placeSourcePositionsSync(e),n=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}async transformSourcePositionToGeographicAsync(e){let r=await this.placeSourcePositions(e),n=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}transformPositions(e,r){let n=this.placeSourcePositionsSync(e),i=this.placeSourcePositionsSync(r);return this.transformPlacedPositions(n,i)}async transformPositionsAsync(e,r){let n=new Float64Array(e.length+3);n.set(Array.from(e),0),n.set(Array.from(r).slice(0,3),e.length);let i=await this.placeSourcePositions(n);return this.transformPlacedPositions(i.subarray(0,e.length),i.subarray(e.length))}async transformGeometryAsync(e,r,n="earth-centered"){if(e.length%3||r&&r.length!==e.length)throw new Error("Conversion positions and normals must contain matching finite xyz triples");for(let o=0;o<e.length;o++)if(!Number.isFinite(e[o])||r&&!Number.isFinite(r[o]))throw new Error("Conversion positions and normals must contain matching finite xyz triples");if(!["earth-centered","vertex-reference-frame"].includes(n))throw new Error("Unsupported I3S normal reference frame");let i=await this.placeSourcePositions(e);return{positions:this.positionTransformer.transformPositions(i),normals:r?this.transformNormals(r,i,n):void 0}}transformPlacedPositions(e,r){let n=this.transformPlacedPosition(r),i=new Float32Array(e.length),o=Float64Array.from(e);for(let c=0;c<e.length;c+=3){let l=this.transformPlacedPosition([e[c],e[c+1],e[c+2]]);i[c]=l[0]-n[0],i[c+1]=l[1]-n[1],i[c+2]=l[2]-n[2]}let s=this.targetCoordinateFrame==="geographic",a=s?new z:new z().translate(n);return{positions:i,sourcePositions:o,origin:n,cartographicOrigin:s?n:[0,0,0],coordinateSystem:s?"lnglat-offsets":"cartesian",modelMatrix:a}}transformNormals(e,r,n="earth-centered"){if(e.length!==r.length||e.length%3)throw new Error("I3S normals and positions must have matching xyz component counts");let i=new Float32Array(e.length);if(n==="earth-centered"&&(this.spatialReference.targetCrs||this.spatialReference.sourceCrs)==="EPSG:4978"){for(let o=0;o<e.length;o+=3){let s=Math.hypot(e[o],e[o+1],e[o+2]);for(let a=0;a<3;a++)i[o+a]=s?e[o+a]/s:e[o+a]}return i}for(let o=0;o<e.length;o+=3){let s=this.sourceToGeographicTransformer.transformPosition([r[o],r[o+1],r[o+2]]),a=new M([e[o],e[o+1],e[o+2]]).normalize(),c=n==="earth-centered"?a:K0(a,s),l=this.transformEcefNormal(c,s);i.set(l,o)}return i}transformBoundingVolume(e){let n=this.getGeographicBoundSamples(e).map(i=>this.geographicToTargetTransformer.transformPosition(i));return this.targetCoordinateFrame==="geographic"?{region:Rt(n)}:{box:Bt(n)}}async transformBoundingVolumeAsync(e){let n=(await this.getGeographicBoundSamplesAsync(e)).map(i=>this.geographicToTargetTransformer.transformPosition(i));return this.targetCoordinateFrame==="geographic"?{region:Rt(n)}:{box:Bt(n)}}transformBoundingVolumeToGeographic(e){return{region:Rt(this.getGeographicBoundSamples(e))}}async transformBoundingVolumeToGeographicAsync(e){return{region:Rt(await this.getGeographicBoundSamplesAsync(e))}}transformBoundingVolumeToGeocentric(e){let r=this.getGeographicBoundSamples(e).map(n=>Array.from(L.WGS84.cartographicToCartesian(new M(n))));return{box:Bt(r)}}async transformBoundingVolumeToGeocentricAsync(e){let r=(await this.getGeographicBoundSamplesAsync(e)).map(n=>Array.from(L.WGS84.cartographicToCartesian(new M(n))));return{box:Bt(r)}}transformBoundingSphereToGeographic(e){let r=e.mbs?.length?Array.from(e.mbs).slice(0,3):e.obb?Array.from(e.obb.center).slice(0,3):null;if(!r)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let n=this.placeSourcePositionsSync(r),i=this.sourceToGeographicTransformer.transformPosition(Array.from(n)),o=e.mbs?.length?e.mbs[3]:Math.hypot(...Array.from(e.obb.halfSize).slice(0,3));return[i[0],i[1],i[2],o]}async transformBoundingSphereToGeographicAsync(e){return H0(await this.getGeographicBoundSamplesAsync(e))}async transformBoundsAsync(e){let r=await this.getGeographicBoundSamplesAsync(e),n=r.map(o=>Array.from(L.WGS84.cartographicToCartesian(new M(o)))),i=r.map(o=>this.geographicToTargetTransformer.transformPosition(o));return{boundingVolume:{box:Bt(n)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:Rt(i)}:{box:Bt(i)},i3sLodMbs:pr(this.elevationMode)?H0(r):this.transformBoundingSphereToGeographic(e)}}async transformPointCloudBoundsAsync(e){let r=await this.getGeographicBoundSamplesAsync(e),n=r.map(i=>this.geographicToTargetTransformer.transformPosition(i));return{boundingVolume:{region:Rt(r)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:Rt(n)}:{box:Bt(n)}}}getGeographicBoundSamples(e){let r=$0(e,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let n=this.placeSourcePositionsSync(r.flat(),!0),i=va(n);return this.sourceCoordinateFrame==="geographic"?i:i.map(o=>this.sourceToGeographicTransformer.transformPosition(o))}async getGeographicBoundSamplesAsync(e){let r=$0(e,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");if(pr(this.elevationMode)){let i=this.sourceCoordinateFrame==="geographic"?r:r.map(o=>this.sourceToGeographicTransformer.transformPosition(o));return await this.placeGeographicBoundSamples(i)}let n=va(await this.placeSourcePositions(r.flat(),!0));return this.sourceCoordinateFrame==="geographic"?n:n.map(i=>this.sourceToGeographicTransformer.transformPosition(i))}async placeGeographicBoundSamples(e){let n=await this.elevationProvider.getElevationRange(hM(e)),i=n.minimum*this.providerUnitScale,o=n.maximum*this.providerUnitScale;if(!Number.isFinite(i)||!Number.isFinite(o)||i>o)throw new Error("Elevation provider returned an invalid range; minimum and maximum must be finite and ordered");let s=e.map(h=>h[2]),a=Math.min(...s),c=Math.max(...s),l=[];for(let[h,u]of e){let f=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([h,u,i])[2]:i,d=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([h,u,o])[2]:o,m=Math.min(f,d),p=Math.max(f,d),g=this.elevationMode==="onTheGround"?m:m+a+this.elevationOffset,y=this.elevationMode==="onTheGround"?p:p+c+this.elevationOffset;l.push([h,u,g],[h,u,y])}return l}placeSourcePositionsSync(e,r=!1){if(pr(this.elevationMode))throw new Error(`I3S elevation mode ${this.elevationMode} requires asynchronous surface placement`);let n=Float64Array.from(e),i=this.elevationMode==="absoluteHeight"?this.elevationOffset:0;for(let o=2;o<n.length;o+=3)n[o]=n[o]*(r?1:this.sourceVerticalUnitScale)+i;return n}async placeSourcePositions(e,r=!1){if(!pr(this.elevationMode))return this.placeSourcePositionsSync(e,r);let n=Float64Array.from(e),i=va(n).map(s=>{let a=this.sourceToGeographicTransformer.transformPosition(s);return[a[0],a[1]]}),o=await this.elevationProvider.sampleElevations(i);if(o.length!==i.length)throw new Error(`Elevation provider returned ${o.length} heights for ${i.length} positions`);for(let s=0;s<i.length;s++){let a=o[s]*this.providerUnitScale;if(!Number.isFinite(a))throw new Error(`Elevation provider returned a non-finite height at index ${s}`);let[c,l]=i[s],h=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([c,l,a])[2]:a,u=n[s*3+2]*(r?1:this.sourceVerticalUnitScale);n[s*3+2]=this.elevationMode==="onTheGround"?h:h+u+this.elevationOffset}return n}transformEcefNormal(e,r){if(this.targetCoordinateFrame==="geocentric")return e.normalize();if(this.targetCoordinateFrame==="geographic")return fM(e,r).normalize();let n=L.WGS84.cartographicToCartesian(new M(r)),i=[];for(let s of uM()){let a=L.WGS84.cartesianToCartographic(new M(n).add(s)),c=L.WGS84.cartesianToCartographic(new M(n).subtract(s)),l=this.geographicToTargetTransformer.transformPosition(a),h=this.geographicToTargetTransformer.transformPosition(c);i.push((l[0]-h[0])/2,(l[1]-h[1])/2,(l[2]-h[2])/2)}let o=new $(i);if(Math.abs(o.determinant())<1e-12)throw new Error("Cannot transform an I3S normal through a singular local projection");return o.invert().transpose(),new M(e).transformByMatrix3(o).normalize()}};function lM(t,e){return t==="relativeToScene"?e.sceneElevationProvider:pr(t)?e.terrainElevationProvider:void 0}function pr(t){return t==="onTheGround"||t==="relativeToGround"||t==="relativeToScene"}function va(t){if(t.length%3!==0)throw new Error("I3S position arrays must contain complete XYZ tuples");let e=[];for(let r=0;r<t.length;r+=3)e.push([t[r],t[r+1],t[r+2]]);return e}function hM(t){let e=Rt(t);return{west:e[0]*180/Math.PI,south:e[1]*180/Math.PI,east:e[2]*180/Math.PI,north:e[3]*180/Math.PI}}function H0(t){if(!t.length)throw new Error("I3S spatial transformation requires at least one bound sample");let e=t.map(o=>L.WGS84.cartographicToCartesian(new M(o))),r=new M;for(let o of e)r.add(o);r.scale(1/e.length);let n=0;for(let o of e)n=Math.max(n,new M(o).subtract(r).magnitude());let i=L.WGS84.cartesianToCartographic(r);return[i[0],i[1],i[2],n]}function $0(t,e,r,n){let i=t.obb;if(i){let c=Array.from(i.center).slice(0,3);c[2]*=n;let l=Array.from(i.halfSize).slice(0,3),h=new De().fromArray(Array.from(i.quaternion)),u=[new M([l[0],0,0]).transformByQuaternion(h),new M([0,l[1],0]).transformByQuaternion(h),new M([0,0,l[2]]).transformByQuaternion(h)];if(e==="geographic"){let f=r.transformPosition(c),d=L.WGS84.cartographicToCartesian(new M(f)),m=t.normalReferenceFrame==="vertex-reference-frame"?u.map(p=>K0(p,f)):u;return Y0().map(p=>{let g=new M(d);for(let y=0;y<3;y++)g.add(new M(m[y]).scale(p[y]));return Array.from(L.WGS84.cartesianToCartographic(g))})}return Y0().map(f=>{let d=new M(c);for(let m=0;m<3;m++)d.add(new M(u[m]).scale(f[m]));return Array.from(d)})}let o=t.mbs?Array.from(t.mbs):[];if(o.length<4)return[];let s=o.slice(0,3);s[2]*=n;let a=o[3];if(e==="geographic"){let c=r.transformPosition(s),l=L.WGS84.cartographicToCartesian(new M(c));return X0().map(h=>Array.from(L.WGS84.cartesianToCartographic(new M(l).add(new M(h).scale(a)))))}return X0().map(c=>Array.from(new M(s).add(new M(c).scale(a))))}function Y0(){return[-1,1].flatMap(t=>[-1,1].flatMap(e=>[-1,1].map(r=>[t,e,r])))}function X0(){return[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]]}function uM(){return[new M([1,0,0]),new M([0,1,0]),new M([0,0,1])]}function K0(t,e){let r=e[0]*Math.PI/180,n=e[1]*Math.PI/180,i=new M([-Math.sin(r),Math.cos(r),0]),o=new M([-Math.sin(n)*Math.cos(r),-Math.sin(n)*Math.sin(r),Math.cos(n)]),s=new M([Math.cos(n)*Math.cos(r),Math.cos(n)*Math.sin(r),Math.sin(n)]);return i.scale(t[0]).add(o.scale(t[1])).add(s.scale(t[2]))}function fM(t,e){let r=e[0]*Math.PI/180,n=e[1]*Math.PI/180,i=new M([-Math.sin(r),Math.cos(r),0]),o=new M([-Math.sin(n)*Math.cos(r),-Math.sin(n)*Math.sin(r),Math.cos(n)]),s=new M([Math.cos(n)*Math.cos(r),Math.cos(n)*Math.sin(r),Math.sin(n)]);return new M([i.dot(t),o.dot(t),s.dot(t)])}function Bt(t){let e=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let o of t)for(let s=0;s<3;s++)e[s]=Math.min(e[s],o[s]),r[s]=Math.max(r[s],o[s]);let n=e.map((o,s)=>(o+r[s])/2),i=e.map((o,s)=>(r[s]-o)/2);return[n[0],n[1],n[2],i[0],0,0,0,i[1],0,0,0,i[2]]}function Rt(t){let e=t[0][0],r=1/0,n=-1/0,i=1/0,o=-1/0,s=1/0,a=-1/0;for(let c of t){let l=e+Pa(c[0]-e);r=Math.min(r,l),n=Math.max(n,l),i=Math.min(i,c[1]),o=Math.max(o,c[1]),s=Math.min(s,c[2]),a=Math.max(a,c[2])}return[Pa(r)*Math.PI/180,i*Math.PI/180,Pa(n)*Math.PI/180,o*Math.PI/180,s,a]}function Pa(t){return((t+180)%360+360)%360-180}var dM={draco:!1,meshopt:!1,dds:!1,ktx2:!1},Zi=class{type=le.I3S;loader;contentLoader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...dM};asset;properties;extras;credits;metadata;queryParams={};resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(e,r={}){let n=pM(e);this.rootTileset=Q0(e)?null:e,this.tileset=this.rootTileset,this.loader=n.loader,this.contentLoader=mM(n.loader),this.url=n.url,this.basePath=n.basePath||Ce.dirname(n.url),this.resolver=n.resolver,this.coreApi=n.coreApi,this.loadOptions=r,this.initializeQueryParams(r)}async initialize(){this.rootTileset||(this.rootTileset=await this.loadRootData(this.getTileUrl(this.url),{...this.loadOptions,i3s:{...this.loadOptions.i3s,isTileset:!0}})),this.tileset=this.rootTileset,this.rootTileset.root&&typeof this.rootTileset.root.then=="function"&&(this.rootTileset.root=await this.rootTileset.root),this.metadata={type:this.type,loader:this.loader,url:this.url,basePath:this.basePath,tileset:this.rootTileset,lodMetricType:this.rootTileset.lodMetricType,lodMetricValue:this.rootTileset.lodMetricValue,refine:this.rootTileset.root?.refine,spatialReference:pi(this.rootTileset)}}getMetadata(){if(!this.metadata)throw new Error("I3SSource has not been initialized");return this.metadata}async getRootTileset(){return this.getMetadata().tileset}async prepareTileset(e){let r=e.spatialReference;if(r.status==="unresolved")throw new Error(r.warnings[0]||"I3S spatial operations cannot be resolved from the supplied metadata and options");r.status!=="transformable"&&r.status!=="transformed"||(this.spatialTransformer||=new gr(r,e.options.spatial),e.spatialReference=this.spatialTransformer.spatialReference,this.preparedRootHeader=await this.transformTileHeader(this.getMetadata().tileset.root))}initializeTileHeaders(e,r,n){let i=n?r.root:this.preparedRootHeader||r.root;if(this.spatialTransformer&&!this.preparedRootHeader)throw new Error("I3S spatial root header was not prepared before tile initialization");let o=new Ne(e,i,n||void 0);return n&&(n.children.push(o),o.depth=n.depth+1),o}createTraverser(e){return new Ki(e)}async loadTileContent(e){let r=this.getTileUrl(e.contentUrl),n=this.loader.id,i=this.loadOptions[n]||{},o=this.getMetadata(),s={...this.loadOptions,[n]:{...i,...e.tileset.options.i3s,_tileOptions:{attributeUrls:e.header.attributeUrls,textureUrl:e.header.textureUrl,textureUrls:e.header.textureUrls,textureFormat:e.header.textureFormat,textureLoaderOptions:e.header.textureLoaderOptions,materialDefinition:e.header.materialDefinition,layerType:e.header.layerType,pointRenderer:e.header.pointRenderer,pointSymbol:e.header.pointSymbol,isDracoGeometry:e.header.isDracoGeometry,mbs:e.header.mbs},_tilesetOptions:{store:o.tileset.store,attributeStorageInfo:o.tileset.attributeStorageInfo,fields:o.tileset.fields,spatialReference:e.tileset.spatialReference,spatialOptions:e.tileset.options.spatial},isTileHeader:!1}};e.content=await this.loadResourceData(r,s,this.contentLoader);let a={index:0,uri:e.contentUrl,type:e.header.layerType,payload:e.content,metadata:e.header.metadata||null,boundingVolume:e.boundingVolume,featureIds:e.featureIdSets,renderable:!!e.content};return{loaded:!0,contents:[e.content],contentEntries:[a]}}async loadChildTileHeader(e,r,n){let i=this.getMetadata();if(i.tileset.nodePages||i.tileset.pointNodePages){let l=await i.tileset.nodePagesTile.formTileFromNodePages(r);return await this.transformTileHeader(l)}let o=this.getTileUrl(`${this.url}/nodes/${r}`),s=this.loadOptions.i3s&&typeof this.loadOptions.i3s=="object"?this.loadOptions.i3s:{},a={...this.loadOptions,i3s:{...s,isTileHeader:!0}},c=await this.loadResourceData(o,a);return await this.transformTileHeader(c)}async loadTileChildrenForTraversal(e,r){let n=e.header.children||[],i=0,o=[];for(let a of n){Z0(r);let c=a.id;if(typeof c!="string"&&typeof c!="number")throw new Error("I3S child header is missing its node ID");let l=e.children.find(f=>f.id===String(c)||f.header?.id===c);if(l){o.push(l);continue}let h=await this.loadChildTileHeader(e,String(c),null);Z0(r);let u=new Ne(e.tileset,h,e,String(c));o.push(u),i++}let s=new Set(o);return e.children=[...o,...e.children.filter(a=>!s.has(a))],{loaded:!0,tileCount:i,childSubtreeCount:0}}getTileUrl(e){if(e.startsWith("data:")||!Object.keys(this.queryParams).length)return e;let r=e.indexOf("#"),n=r>=0?e.slice(r):"",i=r>=0?e.slice(0,r):e,o=i.indexOf("?"),s=o===-1?i:i.slice(0,o),a=o===-1?"":i.slice(o+1),c=new URLSearchParams(a),l=new URLSearchParams;for(let[u,f]of Object.entries(this.queryParams))c.has(u)||l.set(u,f);let h=l.toString();return`${s}${a?`?${a}`:""}${h?`${a?"&":"?"}${h}`:""}${n}`}getViewState(e){if(this.spatialTransformer&&e){let o=new M(e.boundingVolume.center),s=new M(e.header.i3sLodMbs.slice(0,3));return this.spatialTransformer.targetCoordinateFrame==="geographic"?{boundingVolume:e.boundingVolume,cartographicCenter:s,cartesianCenter:o,zoom:1}:{boundingVolume:e.boundingVolume,cartographicCenter:s,cartesianCenter:o,zoom:1}}let r=this.getMetadata(),n=r.tileset.fullExtent;if(n){let{xmin:o,xmax:s,ymin:a,ymax:c,zmin:l,zmax:h}=n,u=new M(o+(s-o)/2,a+(c-a)/2,l+(h-l)/2),f=new M;return L.WGS84.cartographicToCartesian(u,f),{cartographicCenter:u,cartesianCenter:f,zoom:os(n,u,f)}}let i=r.tileset.store?.extent;if(i){let[o,s,a,c]=i,l=new M(o+(a-o)/2,s+(c-s)/2,0),h=new M;return L.WGS84.cartographicToCartesian(l,h),{cartographicCenter:l,cartesianCenter:h,zoom:_h(i,l,h)}}return console.warn("Extent is not defined in the tileset header"),{cartographicCenter:new M,zoom:1}}onTileLoaded(e,r){switch(r.header.isDracoGeometry&&(this.contentFormats.draco=!0),r.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}}getTilesTotalCount(){return this.getMetadata().tileset?.nodePagesTile?.nodesInNodePages||null}async loadWithCoreApi(e,r,n=this.loader){if(!this.coreApi)throw new Error("I3SSource requires an injected coreApi to load tileset data");return await this.coreApi.load(e,n,r)}async loadRootData(e,r){return this.resolver?await this.resolver.loadRoot(e,this.loader,r):await this.loadWithCoreApi(e,r)}initializeQueryParams(e){for(let[n,i]of Object.entries(e.searchParams||{}))this.queryParams[n]=String(i);let r=e.i3s;if(r&&typeof r=="object"&&"token"in r){let n=r.token;typeof n=="string"&&(this.queryParams.token=n)}}async loadResourceData(e,r,n=this.loader){return this.resolver?await this.resolver.loadResource(e,n,r):await this.loadWithCoreApi(e,r,n)}async transformTileHeader(e){if(!this.spatialTransformer)return e;let r={mbs:e.mbs,obb:e.obb,normalReferenceFrame:this.getMetadata().tileset.store?.normalReferenceFrame},n=await this.spatialTransformer.transformBoundsAsync(r);return{...e,boundingVolume:n.boundingVolume,spatialBoundingVolume:n.spatialBoundingVolume,i3sLodMbs:n.i3sLodMbs}}};function Z0(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted","AbortError")}function mM(t){return t.contentLoader||t}function Q0(t){return!!(t&&typeof t=="object"&&"url"in t&&"loader"in t&&!("type"in t))}function pM(t){return Q0(t)?{...t,basePath:t.basePath||Ce.dirname(t.url)}:{url:t.url,loader:t.loader,basePath:t.basePath||Ce.dirname(t.url),resolver:t.resolver,coreApi:t.coreApi}}var Dt=class{index;parent;children;content;error;id;zoom;userData;boundingBox;_abortController;_loader;_loaderId;_isLoaded;_isCancelled;_needsReload;_bbox;constructor(e){this.index=e,this.parent=null,this.children=[],this.content=null,this.error=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){let e=this._loader;return!this._isCancelled&&e!==void 0?e.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get hasError(){return!!this.error}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)?e:0}async _loadData({getData:e,requestScheduler:r,onLoad:n,onError:i}){let o=(g,y,x)=>{if(x===this._loaderId){if(this._loader=void 0,this.content=g,this.error=y?gM(y):null,this._isCancelled&&!g){this._isLoaded=!1;return}if(this._isLoaded=!0,this._isCancelled=!1,y){i(y,this);return}n(this)}},{index:s,id:a,bbox:c,userData:l,zoom:h}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:f}=this._abortController,d=await r.scheduleRequest(this,()=>1);if(!d){this._isCancelled=!0;return}if(this._isCancelled){d.done();return}let m=null,p;try{m=await e({index:s,id:a,bbox:c,userData:l,zoom:h,signal:f})}catch(g){p=g||!0}finally{d.done()}o(m,p,u)}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this.error=null,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};function gM(t){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error("Tile request failed")}var Ra="never",Ca="no-overlap",hn="best-available",J0={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:hn,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},ln=class t{stats;sourceMetadata=null;opts;_requestScheduler;_cache;_dirty;_tiles;_cacheByteSize;_unloadedTileCount;_listeners=new Set;_consumers=new Map;_explicitOptionKeys=new Set;_baseOpts={};_sourceMetadataOverrides={};_maxZoom;_minZoom;_lastTileContext=null;constructor(e){if(this.stats=new ke({id:"Tileset2D",stats:[{name:"Tiles In Cache"},{name:"Cache Size"},{name:"Visible Tiles"},{name:"Selected Tiles"},{name:"Loading Tiles"},{name:"Unloaded Tiles"},{name:"Consumers"}]}),this.opts={...J0,...e,getTileData:e.getTileData||(()=>null),tileSource:e.tileSource},this._requestScheduler=new ut({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._unloadedTileCount=0,!this.opts.tileSource&&!e.getTileData)throw new Error("Tileset2D requires either `getTileData` or `tileSource`.");this.setOptions(e),this._updateStats(),this.opts.tileSource&&this._initializeTileSource(this.opts.tileSource).catch(()=>{})}static fromTileSource(e,r={}){return new t({...r,tileSource:e})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let e=this._getVisibleTilesUnion();for(let r of this._getSelectedTilesUnion())e.add(r);return Array.from(e)}get loadingTiles(){return Array.from(this._cache.values()).filter(e=>e.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(e=>!e.isLoaded)}get maxZoom(){return this._maxZoom}get minZoom(){return this._minZoom}get refinementStrategy(){return this.opts.refinementStrategy||hn}get adapter(){return this.opts.adapter}subscribe(e){return this._listeners.add(e),()=>this._listeners.delete(e)}attachConsumer(e){this._consumers.set(e,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(e){this._consumers.delete(e),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(e){this._rememberExplicitOptions(e),this._baseOpts={...this._baseOpts,...e};let r=this.opts.maxRequests,n=this.opts.debounceTime;this._applyResolvedOptions(),(r!==this.opts.maxRequests||n!==this.opts.debounceTime)&&(this._requestScheduler=new ut({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}))}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._consumers.clear(),this._cacheByteSize=0,this._unloadedTileCount=0,this._updateStats()}reloadAll(){let e=this._getSelectedTilesUnion();for(let r of this._cache.keys()){let n=this._cache.get(r);n&&!e.has(n)?(this._cache.delete(r),this._handleTileUnload(n),this._dirty=!0):n&&n.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(e,r,n){this._consumers.set(e,{selectedTiles:new Set(r),visibleTiles:new Set(n)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:e,maxZoom:r,minZoom:n,zRange:i,modelMatrix:o,modelMatrixInverse:s}){let{adapter:a,tileSize:c,extent:l,zoomOffset:h}=this.opts;if(!a)throw new Error("Tileset2D requires an adapter before tile traversal can be used.");return this._lastTileContext={viewState:e,tileSize:c},a.getTileIndices({viewState:e,maxZoom:r,minZoom:n,zRange:i,tileSize:c,extent:MM(l),modelMatrix:o,modelMatrixInverse:s,zoomOffset:h})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){if(!this._lastTileContext)throw new Error("Tileset2D metadata requested before traversal context was set.");if(!this.opts.adapter)throw new Error("Tileset2D requires an adapter before tile metadata can be derived.");return{bbox:this.opts.adapter.getTileBoundingBox(this._lastTileContext,e)}}getParentIndex(e){return{x:Math.floor(e.x/2),y:Math.floor(e.y/2),z:e.z-1}}getTile(e,r){let n=this.getTileId(e),i=this._cache.get(n),o=!1;return!i&&r?(i=new Dt(e),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:n,zoom:this.getTileZoom(i.index)}),o=!0,this._cache.set(n,i),this._dirty=!0,this._updateStats()):i&&i.needsReload&&(o=!0),i&&this._touchTile(n,i),i&&o&&r&&(i.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),this._updateStats()),i}async _initializeTileSource(e){try{this.sourceMetadata=await e.getMetadata(),this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(r){let n=r instanceof Error?r:new Error(`TileSource metadata error: ${String(r)}`);this._notifyError(n)}}_rememberExplicitOptions(e){for(let r of Object.keys(e))this._explicitOptionKeys.add(r)}_applyResolvedOptions(){let e={...J0,...this._sourceMetadataOverrides,...this._baseOpts};if(e.tileSource){let r=e.tileSource;e.getTileData=n=>r.getTileData(n)}this.opts=e,this._maxZoom=typeof this.opts.maxZoom=="number"&&Number.isFinite(this.opts.maxZoom)?Math.floor(this.opts.maxZoom):void 0,this._minZoom=typeof this.opts.minZoom=="number"&&Number.isFinite(this.opts.minZoom)?Math.ceil(this.opts.minZoom):void 0}_getMetadataOverrides(e){if(!e)return{};let r={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(e.minZoom)&&(r.minZoom=e.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(e.maxZoom)&&(r.maxZoom=e.maxZoom),!this._explicitOptionKeys.has("extent")&&e.boundingBox&&(r.extent=[e.boundingBox[0][0],e.boundingBox[0][1],e.boundingBox[1][0],e.boundingBox[1][1]]),r}_handleTileLoad(e){this.opts.onTileLoad?.(e),this._cacheByteSize=this._getCacheByteSize(),this._resizeCache();for(let r of this._listeners)r.onTileLoad?.(e);this._updateStats()}_handleTileError(e,r){this.opts.onTileError?.(e,r);for(let n of this._listeners)n.onTileError?.(e,r);this._updateStats()}_handleTileUnload(e){this._unloadedTileCount++,this.opts.onTileUnload?.(e);for(let r of this._listeners)r.onTileUnload?.(e);this._updateStats()}_notifyUpdate(){for(let e of this._listeners)e.onUpdate?.()}_notifyError(e){for(let r of this._listeners)r.onError?.(e)}_updateStats(){this._setStatCount("Tiles In Cache",this._cache.size),this._setStatCount("Cache Size",this.cacheByteSize),this._setStatCount("Visible Tiles",this.visibleTiles.length),this._setStatCount("Selected Tiles",this.selectedTiles.length),this._setStatCount("Loading Tiles",this.loadingTiles.length),this._setStatCount("Unloaded Tiles",this._unloadedTileCount),this._setStatCount("Consumers",this._consumers.size);for(let e of this._listeners)e.onStatsChange?.(this.stats)}_setStatCount(e,r){this.stats.get(e).reset().addCount(r)}_getSelectedTilesUnion(){let e=new Set;for(let r of this._consumers.values())for(let n of r.selectedTiles)e.add(n);return e}_getVisibleTilesUnion(){let e=new Set;for(let r of this._consumers.values())for(let n of r.visibleTiles)e.add(n);return e}_touchTile(e,r){this._cache.delete(e),this._cache.set(e,r)}_getCacheByteSize(){let e=0;for(let r of this._cache.values())e+=r.byteLength;return e}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=this._getSelectedTilesUnion(),n=this._getVisibleTilesUnion(),i=[],o=0;for(let s of this._cache.values())s.isLoading&&(o++,!r.has(s)&&!n.has(s)&&i.push(s));for(;e>0&&o>e&&i.length>0;){let s=i.shift();s&&s.abort(),o--}}_rebuildTree(){for(let e of this._cache.values())e.parent=null,e.children&&(e.children.length=0);for(let e of this._cache.values()){let r=this._getNearestAncestor(e);e.parent=r,r?.children&&r.children.push(e)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((e,r)=>e.zoom-r.zoom)}_resizeCache(){let e=this.opts.maxCacheSize??100,r=this.opts.maxCacheByteSize??1/0,n=this._getVisibleTilesUnion(),i=this._getSelectedTilesUnion();if(this._cache.size>e||this._cacheByteSize>r){for(let[s,a]of this._cache)if(!n.has(a)&&!i.has(a)&&(this._cache.delete(s),this._cacheByteSize=this._getCacheByteSize(),this._handleTileUnload(a)),this._cache.size<=e&&this._cacheByteSize<=r)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(e){let{_minZoom:r=0}=this,n=e.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let i=this.getTile(n);if(i)return i}return null}};function MM(t){return t&&t.length===4?t:void 0}var Qi={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},Ji=class t{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(e){if(this._opts=this._normalizeOptions(e),!this._opts.imageSource&&(!e.getImage||!e.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(e,r={}){return new t({...r,imageSource:e})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get image(){return this._currentRequest?.image||null}get currentRequest(){return this._currentRequest}get imageSource(){return this._opts.imageSource}subscribe(e){return this._listeners.add(e),()=>this._listeners.delete(e)}setOptions(e){let r=this._opts.imageSource,n=this._normalizeOptions({...this._opts,...e}),i=r!==n.imageSource||this._opts.getImage!==n.getImage||this._opts.getMetadata!==n.getMetadata;this._opts=n,i&&(this._cancelScheduledImage(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let e=await this._opts.getMetadata();if(this._finalized)return e;this.metadata=e;for(let r of this._listeners)r.onMetadataLoad?.(e);return this._emitUpdate(),e}catch(e){let r=ed(e,"Image metadata request failed");if(!this._finalized)for(let n of this._listeners)n.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestImage(e,r=this._opts.debounceTime){let n=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(n,e)},r):this._loadImage(n,e),n}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(e,r){if(!this._finalized){this._startLoading();for(let n of this._listeners)n.onImageLoadStart?.(e,r);try{let n=new AbortController;this._abortController=n;let i=await this._opts.getImage({...r,signal:n.signal});if(this._finalized||e<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=e,this._currentRequest={requestId:e,parameters:r,image:i};for(let o of this._listeners)o.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(n){if(yM(n))return;let i=ed(n,"Image request failed");if(!this._finalized)for(let o of this._listeners)o.onImageLoadError?.(e,i,r)}finally{this._abortController?.signal===r.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(e){let r=e.imageSource||null;return{...Qi,...e,imageSource:r,getMetadata:e.getMetadata||(()=>r?r.getMetadata():Qi.getMetadata()),getImage:e.getImage||(n=>r?r.getImage(n):Qi.getImage(n)),debounceTime:e.debounceTime??Qi.debounceTime}}_emitUpdate(){for(let e of this._listeners)e.onUpdate?.()}_startLoading(){let e=this._loadCounter>0;this._loadCounter++,e||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let e=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),e&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(e){for(let r of this._listeners)r.onLoadingStateChange?.(e)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function yM(t){return t instanceof Error&&t.name==="AbortError"}function ed(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}var un={getMetadata:async()=>({width:0,height:0,bandCount:0,dtype:"uint8"}),getRaster:async()=>({data:new Uint8Array(0),width:0,height:0,bandCount:0,dtype:"uint8"}),debounceTime:0,shouldRefetch:()=>!0},eo=class t{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_metadataAbortController=null;_finalized=!1;_sourceGeneration=0;_metadataRequestId=0;constructor(e){if(this._opts=this._normalizeOptions(e),!this._opts.rasterSource&&(!e.getRaster||!e.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(e,r={}){return new t({...r,rasterSource:e})}static fromCallbacks(e){return new t(e)}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get raster(){return this._currentRequest?.raster||null}get currentRequest(){return this._currentRequest}get rasterSource(){return this._opts.rasterSource}subscribe(e){return this._listeners.add(e),()=>this._listeners.delete(e)}setOptions(e){let r=this._opts.rasterSource,n={...this._opts,...e};e.rasterSource&&e.rasterSource!==r&&(n.getRaster=e.getRaster,n.getMetadata=e.getMetadata);let i=this._normalizeOptions(n),o=r!==i.rasterSource||this._opts.getRaster!==i.getRaster||this._opts.getMetadata!==i.getMetadata;this._opts=i,o&&(this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._sourceGeneration++,this.metadata=null,this._currentRequest=null,this._emitUpdate())}async loadMetadata(e={}){if(this._finalized)throw new Error("RasterSet is finalized");e.signal?.throwIfAborted(),this._metadataAbortController?.abort();let r=new AbortController;this._metadataAbortController=r;let n=()=>r.abort(e.signal?.reason);e.signal?.addEventListener("abort",n,{once:!0});let i=++this._metadataRequestId,o=this._sourceGeneration;try{this._startLoading(),r.signal.throwIfAborted();let s=await Un(a=>this._opts.getMetadata({signal:a}),[r.signal]);if(r.signal.throwIfAborted(),this._finalized||o!==this._sourceGeneration||i!==this._metadataRequestId)return s;this.metadata=s;for(let a of this._listeners)a.onMetadataLoad?.(s);return this._emitUpdate(),s}catch(s){if(r.signal.aborted)throw r.signal.reason;if(rd(s))throw s;let a=td(s,"Raster metadata request failed");if(!this._finalized&&o===this._sourceGeneration&&i===this._metadataRequestId)for(let c of this._listeners)c.onMetadataLoadError?.(a);throw a}finally{e.signal?.removeEventListener("abort",n),this._metadataAbortController===r&&(this._metadataAbortController=null),this._finishLoading()}}requestRaster(e,r=this._opts.debounceTime){if(this._finalized)return-1;if(!this.shouldRefetchRaster(e))return this._cancelScheduledRaster(),this._abortActiveRequest(),this._nextRequestId++,this._currentRequest?.requestId??-1;let n=this._nextRequestId++;return this._cancelScheduledRaster(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(n,e)},r):this._loadRaster(n,e),n}shouldRefetchRaster(e){return this._opts.shouldRefetch({currentRequest:this._currentRequest,metadata:this.metadata,nextParameters:e})}finalize(){this._finalized=!0,this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._metadataAbortController=null,this._loadCounter=0,this._listeners.clear()}async _loadRaster(e,r){if(this._finalized)return;let n=r.signal;if(n?.aborted)return;let i=new AbortController;this._abortController=i;let o=()=>i.abort(n?.reason);n?.addEventListener("abort",o,{once:!0}),this._startLoading();try{i.signal.throwIfAborted();for(let a of this._listeners)a.onRasterLoadStart?.(e,r);i.signal.throwIfAborted();let s=await Un(a=>this._opts.getRaster(xM(r,a)),[i.signal]);if(this._finalized||i.signal.aborted||e!==this._nextRequestId-1)return;this._currentRequest={requestId:e,parameters:r,raster:s};for(let a of this._listeners)a.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(s){if(i.signal.aborted||rd(s))return;let a=td(s,"Raster request failed");if(!this._finalized&&e===this._nextRequestId-1)for(let c of this._listeners)c.onRasterLoadError?.(e,a,r)}finally{n?.removeEventListener("abort",o),this._abortController===i&&(this._abortController=null),this._finishLoading()}}_normalizeOptions(e){let r=e.rasterSource||null;return{...un,...e,rasterSource:r,getMetadata:e.getMetadata||(n=>r?r.getMetadata(n):un.getMetadata()),getRaster:e.getRaster||(n=>r?r.getRaster(n):un.getRaster(n)),debounceTime:e.debounceTime??un.debounceTime,shouldRefetch:e.shouldRefetch||(n=>un.shouldRefetch(n))}}_emitUpdate(){if(!this._finalized)for(let e of this._listeners)e.onUpdate?.()}_emitLoadingStateChange(e){if(!this._finalized)for(let r of this._listeners)r.onLoadingStateChange?.(e)}_startLoading(){let e=this._loadCounter>0;this._loadCounter++,e||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let e=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),e&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_cancelScheduledRaster(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function xM(t,e){let r=Object.getOwnPropertyDescriptors(t);delete r.signal;let n=Array.isArray(t)?Object.defineProperties(t.slice(),r):Object.create(Object.getPrototypeOf(t),r);return Object.defineProperty(n,"signal",{configurable:!0,enumerable:!0,value:e,writable:!0}),n}function td(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}function rd(t){return t instanceof Error&&t.name==="AbortError"}var Mr=class{header;parent;children=[];childrenLoaded=!1;childrenPromise=null;selected=!1;viewportIds=[];content=null;contentAvailable=!1;contentFailed=!1;isContentLoading=!1;constructor(e,r=null){this.header=e,this.parent=r}get id(){return this.header.id}get level(){return this.header.level}get pointCount(){return this.header.pointCount}get geometricError(){return this.header.geometricError}get boundingVolume(){return this.header.boundingVolume}setSelected(e){this.selected=!0,this.viewportIds.includes(e)||this.viewportIds.push(e)}clearSelection(){this.selected=!1,this.viewportIds=[]}};var _M={debounceTime:0,minimumNodePixelSize:150,maximumScreenSpaceError:1,lodSelectionMetricType:"maxScreenThresholdSQ",densityThreshold:1,pointBudget:2e6,maxDepth:Number.POSITIVE_INFINITY,onTileLoad:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{}},to=64,ro=class{dataSource;options;root=null;cartographicCenter=null;zoom=1;boundingVolume=null;visibleTilesCount=0;frameNumberValue=0;pendingCount=0;lastUpdatedViewports=null;updatePromise=null;tilesMap=new Map;constructor(e,r={}){this.dataSource=e,this.options={..._M,...r},this.tilesetInitializationPromise=this.initialize()}tilesetInitializationPromise;get isReady(){return this.dataSource.isReady}get frameNumber(){return this.frameNumberValue}get tiles(){return Array.from(this.tilesMap.values())}isLoaded(){return this.frameNumberValue>0&&this.pendingCount===0&&this.selectedTiles.every(e=>e.contentAvailable||e.contentFailed)}selectedTiles=[];update(e=null){this.selectTiles(e).catch(()=>{})}destroy(){this.selectedTiles=[],this.tilesMap.clear(),this.root=null,this.cartographicCenter=null,this.boundingVolume=null,this.visibleTilesCount=0,this.pendingCount=0,this.lastUpdatedViewports=null,this.updatePromise=null}async initialize(){await this.dataSource.initialize();let e=await this.dataSource.getRootTile();this.root=this.getOrCreateTile(e,null);let r=await this.dataSource.getViewState?.();this.boundingVolume=r?.boundingVolume||this.root.boundingVolume;let n=r?.cartographicCenter||this.root.boundingVolume.center;this.cartographicCenter=new M(n),this.zoom=r?.zoom||this.estimateZoom(this.boundingVolume)}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedViewports=e),this.updatePromise||(this.updatePromise=new Promise((r,n)=>{setTimeout(()=>{this.doSelectTiles().then(()=>r(this.frameNumberValue)).catch(n).finally(()=>{this.updatePromise=null})},this.options.debounceTime)})),this.updatePromise}async doSelectTiles(){if(!this.root||!this.lastUpdatedViewports)return;let e=new Set(this.selectedTiles.map(a=>a.id));for(let a of this.tilesMap.values())a.clearSelection();this.frameNumberValue++;let r=Array.isArray(this.lastUpdatedViewports)?this.lastUpdatedViewports:[this.lastUpdatedViewports],n=new Map,i=new Set,o=0;for(let a of r){let c=this.getTraversalContext(a);o=await this.traverseTiles(c,n,o,i)}this.visibleTilesCount=i.size,this.selectedTiles=this.options.onTraversalComplete(Array.from(n.values()));for(let a of this.selectedTiles)this.loadTile(a).catch(()=>{});let s=new Set(this.selectedTiles.map(a=>a.id));this.haveSameIds(e,s)||this.options.onUpdate()}async traverseTiles(e,r,n,i){if(!this.root)return n;let o=n,s=[{tile:this.root,weight:this.estimateScreenRadius(this.root,e.viewport)}];for(;s.length>0;){s.sort((u,f)=>f.weight-u.weight);let a=s.shift();if(!a)break;let{tile:c,weight:l}=a;if(!this.isVisible(c,e))continue;if(i.add(c.id),!r.has(c.id)&&c.pointCount>0){if(o>0&&o+c.pointCount>this.options.pointBudget)break;r.set(c.id,c),o+=c.pointCount}if(r.has(c.id)&&c.setSelected(e.viewport.id),!this.shouldRefine(c,l))continue;let h=await this.getVisibleChildren(c,e);h.length>0&&s.push(...h)}return o}shouldRefine(e,r){if(e.level<this.options.maxDepth&&Number.isFinite(r)&&(e.header.lodSelectionMetricType||this.options.lodSelectionMetricType)==="density-threshold"){let n=Math.max(1,Math.PI*r*r),i=e.pointCount/n,o=e.header.lodThreshold||this.options.densityThreshold;return i<o}return e.level<this.options.maxDepth&&Number.isFinite(r)&&r>=this.options.minimumNodePixelSize}getTraversalContext(e){let r=this.getCullingVolume(e);return{viewport:e,cullingVolume:this.shouldUseCullingVolume(e,r)?r:null}}isVisible(e,r){if(r.cullingVolume){let i=this.getCommonSpaceBoundingSphere(e.boundingVolume,r.viewport);if(i)return this.isBoundingSphereInsideCullingVolume(i,r.cullingVolume)}let n=this.getProjectedFootprint(e.boundingVolume,r.viewport);return n?this.isProjectedFootprintVisible(n,r.viewport):!1}shouldUseCullingVolume(e,r){if(!this.root||!r)return!1;let n=this.getCommonSpaceBoundingSphere(this.root.boundingVolume,e);if(!n)return!1;if(this.isBoundingSphereInsideCullingVolume(n,r))return!0;let i=this.getProjectedFootprint(this.root.boundingVolume,e);return!i||!this.isProjectedFootprintVisible(i,e)}isBoundingSphereInsideCullingVolume(e,r){return r.computeVisibilityWithPlaneMask(e,ce.MASK_INDETERMINATE)!==ce.MASK_OUTSIDE}isProjectedFootprintVisible(e,r){return!(e.x+e.radius<-to||e.x-e.radius>r.width+to||e.y+e.radius<-to||e.y-e.radius>r.height+to)}estimateScreenRadius(e,r){let n=this.getProjectedFootprint(e.boundingVolume,r);return n?n.radius:0}projectBounds(e,r){let n=this.getBoundingVolumeCorners(e),i=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;try{for(let c of n){let[l,h]=r.project(c);!Number.isFinite(l)||!Number.isFinite(h)||(i=Math.min(i,l),o=Math.min(o,h),s=Math.max(s,l),a=Math.max(a,h))}}catch{return null}return!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)?null:{minX:i,minY:o,maxX:s,maxY:a}}getProjectedFootprint(e,r){let n=Number.NaN,i=Number.NaN;try{[n,i]=r.project(e.center)}catch{return null}if(!Number.isFinite(n)||!Number.isFinite(i))return null;let o=this.getBoundingVolumeCorners(e),s=0;try{for(let a of o){let[c,l]=r.project(a);!Number.isFinite(c)||!Number.isFinite(l)||(s=Math.max(s,Math.hypot(c-n,l-i)))}}catch{return null}if(s===0){let a=this.projectBounds(e,r);a&&(s=Math.max(a.maxX-a.minX,a.maxY-a.minY)/2)}return{x:n,y:i,radius:s}}async getVisibleChildren(e,r){return e.level>=this.options.maxDepth?[]:(await this.getChildren(e)).map(i=>({tile:i,weight:this.estimateScreenRadius(i,r.viewport)})).filter(i=>this.isVisible(i.tile,r))}async getChildren(e){if(e.childrenLoaded)return e.children;if(!e.childrenPromise){let r=this.dataSource.getChildren(e.header).then(n=>n.map(i=>this.getOrCreateTile(i,e))).then(n=>(e.children=n,e.childrenLoaded=!0,n));e.childrenPromise=r.finally(()=>{e.childrenPromise===r&&(e.childrenPromise=null)})}return e.childrenPromise}getOrCreateTile(e,r){let n=this.tilesMap.get(e.id);if(n)return n.header=e,r&&n.parent!==r&&(n.parent=r),n;let i=new Mr(e,r);return this.tilesMap.set(e.id,i),r&&!r.children.find(o=>o.id===i.id)&&r.children.push(i),i}async loadTile(e){if(!(e.contentAvailable||e.isContentLoading||e.contentFailed)){e.isContentLoading=!0,this.pendingCount++;try{let r=await this.dataSource.loadTileContent(e.header);e.content=r,e.contentAvailable=!0,r&&this.options.onTileLoad(e)}catch(r){e.contentFailed=!0,this.options.onTileError(e,r)}finally{e.isContentLoading=!1,this.pendingCount--}}}estimateZoom(e){if(!e||e.coordinateFrame==="cartesian")return 1;let[r,n]=e.cartographicBounds,i=e.coversFullLongitude?360:e.wrapsDateline?360-Math.abs(n[0]-r[0]):Math.abs(n[0]-r[0]),o=Math.max(i,1e-6);return Math.max(1,Math.round(Math.log2(360/o)))}haveSameIds(e,r){if(e.size!==r.size)return!1;for(let n of e)if(!r.has(n))return!1;return!0}getBoundingVolumeCorners(e){let[r,n]=e.cartographicBounds,i=e.coversFullLongitude?[[-180,180]]:e.wrapsDateline?[[r[0],180],[-180,n[0]]]:[[r[0],n[0]]],o=[],s=360-Math.abs(n[0]-r[0]),a=r[0]+s/2;for(let[c,l]of i){let h=d=>{if(!e.wrapsDateline)return d;let m=d;for(;m-a>180;)m-=360;for(;m-a<-180;)m+=360;return m},u=h(c),f=h(l);o.push([u,r[1],r[2]||0],[u,r[1],n[2]||0],[u,n[1],r[2]||0],[u,n[1],n[2]||0],[f,r[1],r[2]||0],[f,r[1],n[2]||0],[f,n[1],r[2]||0],[f,n[1],n[2]||0])}return o}getCullingVolume(e){let r=e.getFrustumPlanes?.bind(e);if(!r)return null;let n=r(),i=["left","right","bottom","top","near","far"],o=[];for(let s of i){let a=n[s];if(!a)return null;o.push(new ie(a.normal,-a.distance))}return new ce(o)}getCommonSpaceBoundingSphere(e,r){let n=r.projectPosition?.bind(r);if(!n)return null;let i=this.getBoundingVolumeCorners(e),o=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;try{for(let u of i){let[f,d,m=0]=n(u);!Number.isFinite(f)||!Number.isFinite(d)||!Number.isFinite(m)||(o=Math.min(o,f),s=Math.min(s,d),a=Math.min(a,m),c=Math.max(c,f),l=Math.max(l,d),h=Math.max(h,m))}}catch{return null}return!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(l)||!Number.isFinite(h)?null:new me().fromCornerPoints([o,s,a],[c,l,h])}};return xd(fn);})();
7
+ "use strict";var __exports__=(()=>{var ii=Object.create;var zt=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var ci=Object.getPrototypeOf,li=Object.prototype.hasOwnProperty;var C=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var hi=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},mr=(e,t)=>{for(var r in t)zt(e,r,{get:t[r],enumerable:!0})},vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ai(t))!li.call(e,s)&&s!==r&&zt(e,s,{get:()=>t[s],enumerable:!(n=oi(t,s))||n.enumerable});return e},Dt=(e,t,r)=>(vt(e,t,"default"),r&&vt(r,t,"default")),fi=(e,t,r)=>(r=e!=null?ii(ci(e)):{},vt(t||!e||!e.__esModule?zt(r,"default",{value:e,enumerable:!0}):r,e)),ui=e=>vt(zt({},"__esModule",{value:!0}),e);var xr=hi((_a,pr)=>{pr.exports=globalThis.loaders});function qt(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var gr=C(()=>{"use strict"});function pt(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var me=C(()=>{});var it,pe=C(()=>{me();it=class{constructor(t,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=pt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(pt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var W,Tr=C(()=>{pe();W=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,r="count"){return this._getOrCreate({name:t,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let r of Object.values(this.stats))t(r)}getTable(){let t={};return this.forEach(r=>{t[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(r=>this._getOrCreate(r))}_getOrCreate(t){let{name:r,type:n}=t,s=this.stats[r];return s||(t instanceof it?s=t:s=new it(r,n),this.stats[r]=s),s}}});var Ft=C(()=>{Tr();pe();me()});var mi,pi,xi,gi,Ti,Si,j,Sr=C(()=>{"use strict";Ft();mi="Queued Requests",pi="Active Requests",xi="Cancelled Requests",gi="Queued Requests Ever",Ti="Active Requests Ever",Si={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},j=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...Si,...t},this.stats=new W({id:this.props.id}),this.stats.get(mi),this.stats.get(pi),this.stats.get(xi),this.stats.get(gi),this.stats.get(Ti)}setProps(t){t.throttleRequests!==void 0&&(this.props.throttleRequests=t.throttleRequests),t.maxRequests!==void 0&&(this.props.maxRequests=t.maxRequests),t.debounceTime!==void 0&&(this.props.debounceTime=t.debounceTime)}scheduleRequest(t,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let n={handle:t,priority:0,getPriority:r},s=new Promise(i=>(n.resolve=i,n));return this.requestQueue.push(n),this.requestMap.set(t,s),this._issueNewRequests(),s}_issueRequest(t){let{handle:r,resolve:n}=t,s=!1,i=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:i}):Promise.resolve({done:i})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let r=0;r<t;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let t=this.requestQueue;for(let r=0;r<t.length;++r){let n=t[r];this._updateRequest(n)||(t.splice(r,1),this.requestMap.delete(n.handle),r--)}t.sort((r,n)=>r.priority-n.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}}});function _r(e,t){return t?t.aborted?(e.catch(()=>{}),Promise.reject(t.reason)):new Promise((r,n)=>{let s=()=>{t.removeEventListener("abort",s),n(t.reason)};t.addEventListener("abort",s,{once:!0}),e.then(i=>{t.removeEventListener("abort",s),r(i)},i=>{t.removeEventListener("abort",s),n(i)})}):e}function kt(e,t){let r=new AbortController,n=[],s=()=>{for(let[i,o]of n)i.removeEventListener("abort",o)};for(let i of t){if(!i)continue;let o=()=>r.abort(i.reason);n.push([i,o]),i.addEventListener("abort",o,{once:!0}),i.aborted&&o()}try{return r.signal.throwIfAborted(),_r(e(r.signal),r.signal).catch(i=>{throw r.abort(i),i}).finally(s)}catch(i){return r.abort(i),s(),Promise.reject(i)}}var Mr=C(()=>{"use strict"});function Ut(e={}){if(e.coordinateEpoch!==void 0&&!Number.isFinite(e.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:Er(e.crs||{state:"absent",provenance:"unknown"}),vertical:e.vertical?Er(e.vertical):void 0,coordinateEpoch:e.coordinateEpoch,coordinateFrame:e.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...e.coordinateOrder||[]]),units:e.units?Object.freeze([...e.units]):void 0})}function ot(e){if(typeof e=="object")return"projjson";let t=e.trim();return/^[A-Z][A-Z0-9_]*\s*[\[(]/i.test(t)?"wkt":/(?:^|\s)\+?proj=/i.test(t)?"proj-string":/^[A-Z][A-Z0-9._-]*(?::[A-Z0-9._-]+)+$/i.test(t)||/^urn:ogc:def:crs:/i.test(t)||/^https?:\/\//i.test(t)||/^[A-Z][A-Z0-9._-]*$/i.test(t)?"identifier":"opaque"}function Er(e){return e.state==="explicit"||e.state==="default"?Object.freeze({...e,definition:Rr(e.definition),alternatives:e.alternatives?Object.freeze(e.alternatives.map(t=>Object.freeze({...t,definition:Rr(t.definition)}))):void 0}):Object.freeze({...e})}function Rr(e){return typeof e=="string"?e:xe(e)}function xe(e){return Array.isArray(e)?Object.freeze(e.map(t=>xe(t))):e&&typeof e=="object"?Object.freeze(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,xe(r)]))):e}var yr=C(()=>{});function Se(e,t){let n={type:"wkt-crs",root:new ge(e).parse()};if(t?.strict){let s=Ar(n,{profile:t.profile,allowExtensions:!1});if(s.length>0)throw new Gt(s)}return n}function Ar(e,t){if(!e||e.type!=="wkt-crs"||e.root?.type!=="node")throw new TypeError("validateWKTCRS expects a WKTCRSAst");let r=bi(e.root.keyword,t?.profile||"auto"),n=Ai[r],s=Ii[r],i=[],o=e.root.keyword.toUpperCase();return n.has(o)||i.push({code:"invalid-root",message:`${e.root.keyword} is not a ${r} root keyword`,path:[],keyword:e.root.keyword}),Ir(e.root,[],a=>{let c=a.node.keyword.toUpperCase();!t?.allowExtensions&&!s.has(c)&&i.push({code:"unknown-keyword",message:`${a.node.keyword} is not defined by the ${r} profile`,path:a.path,keyword:a.node.keyword}),a.node.values.length===0&&i.push({code:"empty-node",message:`${a.node.keyword} must contain at least one value`,path:a.path,keyword:a.node.keyword});let l=Ni(a.node);l&&i.push({code:"invalid-value",message:l,path:a.path,keyword:a.node.keyword})}),i}function bi(e,t){return t!=="auto"?t:xt.has(e.toUpperCase())?"wkt1":"wkt2:2019"}function Ni(e){let t=e.keyword.toUpperCase(),r=e.values,n=(i,...o)=>!!(r[i]&&o.includes(r[i].type)),s=(i,...o)=>r.length===i&&o.every((a,c)=>n(c,a));if(["ANGLEUNIT","LENGTHUNIT","PARAMETRICUNIT","SCALEUNIT","TIMEUNIT","TEMPORALQUANTITY","UNIT"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${e.keyword} must start with a quoted name and numeric conversion factor`;if(t==="CS"&&!s(2,"enumeration","number"))return`${e.keyword} must contain a coordinate-system type and dimension`;if(t==="BBOX"&&!s(4,"number","number","number","number"))return`${e.keyword} must contain four numeric bounds`;if(["ENSEMBLEACCURACY","EPOCH","COORDEPOCH","FRAMEEPOCH","OPERATIONACCURACY","ORDER"].includes(t)&&!s(1,"number"))return`${e.keyword} must contain one number`;if(["ANCHOR","AREA","CALENDAR","CITATION","REMARK","SCOPE","URI","VERSION"].includes(t)&&!s(1,"string"))return`${e.keyword} must contain one quoted string`;if(["ELLIPSOID","SPHEROID","TRIAXIAL"].includes(t)&&!(r.length>=3&&n(0,"string")&&n(1,"number")&&n(2,"number")))return`${e.keyword} must start with a quoted name and numeric ellipsoid axes`;if(["PARAMETER"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${e.keyword} must start with a quoted name and numeric value`;if(t==="PARAMETERFILE"&&!s(2,"string","string"))return`${e.keyword} must contain a quoted name and file name`;if(["AUTHORITY","ID"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"string","number")))return`${e.keyword} must start with a quoted authority and identifier`;if(["AXIS"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"enumeration")))return`${e.keyword} must start with a quoted name and axis direction`;if(["METHOD","PROJECTION"].includes(t)&&!(r.length>=1&&n(0,"string")))return`${e.keyword} must start with a quoted name`;if(t==="TIMEEXTENT"){let i=o=>n(o,"enumeration","string");if(r.length!==2||!i(0)||!i(1))return`${e.keyword} must contain two date-time or quoted values`}if(t==="VERTICALEXTENT"&&(r.length<2||r.length>3||!n(0,"number")||!n(1,"number")||r.length===3&&!n(2,"node")))return`${e.keyword} must contain two numeric bounds and an optional unit`;if(t==="COORDINATEMETADATA"&&(r.length<1||r.length>2||!n(0,"node")||r.length===2&&(!n(1,"node")||!["EPOCH","COORDEPOCH"].includes(r[1].keyword.toUpperCase()))))return`${e.keyword} must contain a CRS and an optional coordinate epoch`;if(t==="BOUNDCRS"){let i=r.slice(0,3).map(o=>o.type==="node"?o.keyword.toUpperCase():"");if(i[0]!=="SOURCECRS"||i[1]!=="TARGETCRS"||i[2]!=="ABRIDGEDTRANSFORMATION")return`${e.keyword} must start with SOURCECRS, TARGETCRS, and ABRIDGEDTRANSFORMATION`}return["COMPOUNDCRS","CONCATENATEDOPERATION","COORDINATEOPERATION","DERIVEDPROJCRS","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","GEOGCRS","GEOGRAPHICCRS","PARAMETRICCRS","POINTMOTIONOPERATION","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"].includes(t)&&!n(0,"string")?`${e.keyword} must start with a quoted name`:null}function Ir(e,t,r){r({node:e,path:t});for(let n=0;n<e.values.length;n++){let s=e.values[n];s.type==="node"&&Ir(s,[...t,n],r)}}function Pi(e,t){let r=1,n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
8
+ `?(r++,n=1):n++;return{line:r,column:n}}var Bt,Gt,_i,Mi,xt,Te,Ei,Ri,yi,Ci,Cr,wr,Or,wi,Oi,Ai,Ii,ge,br=C(()=>{Bt=class extends SyntaxError{constructor(t,r,n){let s=Pi(r,n);super(`${t} at ${s.line}:${s.column}`),this.name="WKTCRSSyntaxError",this.offset=n,this.line=s.line,this.column=s.column}},Gt=class extends Error{constructor(t){super(t[0]?.message||"WKT validation failed"),this.name="WKTCRSValidationError",this.issues=t}},_i=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?$/,Mi=/^[A-Za-z][A-Za-z0-9_]*/,xt=new Set(["COMPD_CS","CONCAT_MT","FITTED_CS","GEOCCS","GEOGCS","INVERSE_MT","LOCAL_CS","PARAM_MT","PASSTHROUGH_MT","PROJCS","VERT_CS"]),Te=new Set([...xt,"AUTHORITY","AXIS","CONCAT_MT","DATUM","INVERSE_MT","LOCAL_DATUM","PARAMETER","PARAM_MT","PASSTHROUGH_MT","PRIMEM","PROJECTION","SPHEROID","TOWGS84","UNIT","VERT_DATUM"]),Ei=new Set(xt),Ri=new Set([...Te,"EXTENSION"]),yi=new Set([...xt,"COMPDCS","LOCALCS","VERTCS"]),Ci=new Set([...Te,"COMPDCS","LOCALCS","VDATUM","VERTCS"]),Cr=new Set(["BOUNDCRS","COMPOUNDCRS","COORDINATEOPERATION","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","PARAMETRICCRS","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"]),wr=new Set([...Cr,"CONCATENATEDOPERATION","COORDINATEMETADATA","DERIVEDPROJCRS","GEOGCRS","GEOGRAPHICCRS","POINTMOTIONOPERATION"]),Or=new Set([...wr,"ABRIDGEDTRANSFORMATION","ANCHOR","ANGLEUNIT","AREA","AXIS","BASEENGCRS","BASEGEODCRS","BASEGEOGCRS","BASEPARAMCRS","BASEPROJCRS","BASETIMECRS","BASEVERTCRS","BBOX","BEARING","CALENDAR","CITATION","CONVERSION","COORDEPOCH","CS","DATUM","DERIVINGCONVERSION","DYNAMIC","EDATUM","ELLIPSOID","ENGINEERINGDATUM","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEODETICDATUM","GEOIDMODEL","ID","INTERPOLATIONCRS","LENGTHUNIT","MEMBER","MERIDIAN","METHOD","MODEL","OPERATIONACCURACY","ORDER","PARAMETER","PARAMETERFILE","PARAMETRICDATUM","PARAMETRICUNIT","PDATUM","PRIMEM","PRIMEMERIDIAN","REMARK","SCALEUNIT","SCOPE","SOURCECRS","STEP","TARGETCRS","TDATUM","TEMPORALQUANTITY","TIMEEXTENT","TIMEORIGIN","TIMEUNIT","TIMEDATUM","TRIAXIAL","TRF","URI","USAGE","VDATUM","VERSION","VERTICALDATUM","VERTICALEXTENT","VELOCITYGRID","VRF"]),wi=new Set(["BASEGEOGCRS","CALENDAR","CONCATENATEDOPERATION","COORDEPOCH","COORDINATEMETADATA","DERIVEDPROJCRS","DYNAMIC","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEOGCRS","GEOGRAPHICCRS","GEOIDMODEL","MEMBER","MODEL","POINTMOTIONOPERATION","STEP","TEMPORALQUANTITY","TRF","TRIAXIAL","VELOCITYGRID","VRF"]),Oi=new Set([...Or].filter(e=>!wi.has(e))),Ai={wkt1:xt,gdal:Ei,esri:yi,"wkt2:2015":Cr,"wkt2:2019":wr},Ii={wkt1:Te,gdal:Ri,esri:Ci,"wkt2:2015":Oi,"wkt2:2019":Or};ge=class{constructor(t){this.offset=0,this.source=t}parse(){this.skipWhitespace();let t=this.parseNode();return this.skipWhitespace(),this.offset!==this.source.length&&this.fail("Unexpected content after WKT root"),t}parseNode(){let t=this.parseKeyword();return this.parseNodeAfterKeyword(t)}parseNodeAfterKeyword(t){this.skipWhitespace();let r=this.source[this.offset];r!=="["&&r!=="("&&this.fail(`Expected '[' or '(' after ${t}`),this.offset++;let n=r==="["?"bracket":"parenthesis",s=r==="["?"]":")",i=[];if(this.skipWhitespace(),this.source[this.offset]===s)return this.offset++,{type:"node",keyword:t,delimiter:n,values:i};for(;this.offset<this.source.length;){i.push(this.parseValue()),this.skipWhitespace();let o=this.source[this.offset];if(o===","){this.offset++,this.skipWhitespace(),this.source[this.offset]===s&&this.fail("Expected a WKT value after comma");continue}if(o===s)return this.offset++,{type:"node",keyword:t,delimiter:n,values:i};(o==="]"||o===")")&&this.fail(`Expected '${s}' to close ${t}`),this.fail(`Expected ',' or '${s}' in ${t}`)}this.fail(`Unterminated ${t} node`)}parseValue(){if(this.skipWhitespace(),this.source[this.offset]==='"')return this.parseString();let r=this.offset;for(;this.offset<this.source.length&&!/[\s,\[\]()"]/.test(this.source[this.offset]);)this.offset++;r===this.offset&&this.fail("Expected a WKT value");let n=this.source.slice(r,this.offset);return this.source[this.offset]==='"'&&this.fail("Unexpected quote in unquoted WKT value"),this.skipWhitespace(),this.source[this.offset]==="["||this.source[this.offset]==="("?(/^[A-Za-z][A-Za-z0-9_]*$/.test(n)||this.fail(`Invalid WKT keyword '${n}'`),this.parseNodeAfterKeyword(n)):_i.test(n)?{type:"number",value:Number(n),raw:n}:{type:"enumeration",value:n}}parseKeyword(){let t=this.source.slice(this.offset).match(Mi);return t||this.fail("Expected a WKT keyword"),this.offset+=t[0].length,t[0]}parseString(){this.offset++;let t="";for(;this.offset<this.source.length;){let r=this.source[this.offset++];if(r==='"'){if(this.source[this.offset]==='"'){t+='"',this.offset++;continue}return{type:"string",value:t}}t+=r}this.fail("Unterminated WKT string")}skipWhitespace(){for(;this.offset<this.source.length&&/\s/.test(this.source[this.offset]);)this.offset++}fail(t){throw new Bt(t,this.source,this.offset)}}});function _e(e){let t=zi(e);if(t.length===0)throw new H("PROJ string is empty",e,0);return{type:"proj-string",parameters:t.map(n=>vi(n.raw,n.offset,e))}}function vi(e,t,r){let n=e.startsWith("+")?e.slice(1):e;if(!n)throw new H("Expected a parameter after '+'",r,t);let s=n.indexOf("="),i=s<0?n:n.slice(0,s);if(!i||/[\s+=]/.test(i))throw new H(`Invalid PROJ parameter name '${i}'`,r,t);if(s<0)return{type:"parameter",name:i};let o=n.slice(s+1),a=Di(o,r,t+s+1);return{type:"parameter",name:i,value:a,rawValue:o}}function zi(e){let t=[],r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;let n=r,s=null,i=!1;for(;r<e.length;){let o=e[r];if(i){i=!1,r++;continue}if(o==="\\"&&s){i=!0,r++;continue}if(s){o===s&&(s=null),r++;continue}if((o==='"'||o==="'")&&e[r-1]==="="){s=o,r++;continue}if(/\s/.test(o))break;r++}if(s)throw new H("Unterminated quoted PROJ value",e,n);t.push({raw:e.slice(n,r),offset:n})}return t}function Di(e,t,r){if(!e)return"";let n=e[0];if(n!=='"'&&n!=="'"){if((e.includes('"')||e.includes("'"))&&!Li.test(e))throw new H("Quote must begin a PROJ parameter value",t,r);return e}if(e[e.length-1]!==n)throw new H("Unterminated quoted PROJ value",t,r);let s="";for(let i=1;i<e.length-1;i++){let o=e[i];o==="\\"&&i+1<e.length-1?s+=e[++i]:s+=o}return s}function qi(e,t){let r=1,n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
9
+ `?(r++,n=1):n++;return{line:r,column:n}}var H,Li,Nr=C(()=>{H=class extends SyntaxError{constructor(t,r,n){let s=qi(r,n);super(`${t} at ${s.line}:${s.column}`),this.name="PROJStringSyntaxError",this.offset=n,this.line=s.line,this.column=s.column}};Li=/^[+-]?\d+(?:\.\d*)?d(?:\d+(?:\.\d*)?'(?:\d+(?:\.\d*)?")?)?[NSEW]?$/i});var Me=C(()=>{yr();br();Nr()});var K={};mr(K,{EPSILON1:()=>Fi,EPSILON10:()=>Zi,EPSILON11:()=>ji,EPSILON12:()=>Hi,EPSILON13:()=>Ki,EPSILON14:()=>Xi,EPSILON15:()=>Ji,EPSILON16:()=>Qi,EPSILON17:()=>to,EPSILON18:()=>eo,EPSILON19:()=>ro,EPSILON2:()=>ki,EPSILON20:()=>no,EPSILON3:()=>Ui,EPSILON4:()=>Bi,EPSILON5:()=>Gi,EPSILON6:()=>Vi,EPSILON7:()=>Wi,EPSILON8:()=>Yi,EPSILON9:()=>$i,PI:()=>ao,PI_OVER_FOUR:()=>io,PI_OVER_SIX:()=>oo,PI_OVER_TWO:()=>so,TWO_PI:()=>co});var Fi,ki,Ui,Bi,Gi,Vi,Wi,Yi,$i,Zi,ji,Hi,Ki,Xi,Ji,Qi,to,eo,ro,no,so,io,oo,ao,co,Pr=C(()=>{Fi=.1,ki=.01,Ui=.001,Bi=1e-4,Gi=1e-5,Vi=1e-6,Wi=1e-7,Yi=1e-8,$i=1e-9,Zi=1e-10,ji=1e-11,Hi=1e-12,Ki=1e-13,Xi=1e-14,Ji=1e-15,Qi=1e-16,to=1e-17,eo=1e-18,ro=1e-19,no=1e-20,so=Math.PI/2,io=Math.PI/4,oo=Math.PI/6,ao=Math.PI,co=Math.PI*2});function Ee(e,{precision:t=L.precision}={}){return e=uo(e),`${parseFloat(e.toPrecision(t))}`}function Y(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Re(e){return Lr(e)}function ye(e){return vr(e)}function Lr(e,t){return Ce(e,r=>r*ho,t)}function vr(e,t){return Ce(e,r=>r*lo,t)}function gt(e,t,r){return Ce(e,n=>Math.max(t,Math.min(r,n)))}function U(e,t,r){let n=L.EPSILON;r&&(L.EPSILON=r);try{if(e===t)return!0;if(Y(e)&&Y(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!U(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=L.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{L.EPSILON=n}}function uo(e){return Math.round(e/L.EPSILON)*L.EPSILON}function mo(e){return e.clone?e.clone():new Array(e.length)}function Ce(e,t,r){if(Y(e)){let n=e;r=r||mo(n);for(let s=0;s<r.length&&s<n.length;++s){let i=typeof e=="number"?e:e[s];r[s]=t(i,s,r)}return r}return t(e)}var lo,ho,fo,L,ct=C(()=>{lo=1/Math.PI*180,ho=1/180*Math.PI,fo={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...fo}};L=globalThis.mathgl.config});var et,Vt=C(()=>{ct();et=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+r];return this.check()}toArray(t=[],r=0){for(let n=0;n<this.ELEMENTS;++n)t[r+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Y(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(L)}formatString(t){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Ee(this[n],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!U(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,n){if(n===void 0)return this.lerp(this,t,r);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof r=="number"?r:r[s];this[s]=i+n*(o-i)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),r[n]);return this.check()}add(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(L.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}}});function po(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function v(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Wt(e,t,r=""){if(L.debug&&!po(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}var lt=C(()=>{ct()});var Yt,zr=C(()=>{Vt();lt();ct();Yt=class extends et{toString(){let t="[";if(L.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,n){return this[r*this.RANK+t]=v(n),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[n+s];return r}setColumn(t,r){let n=t*this.RANK;for(let s=0;s<this.RANK;++s)this[n+s]=r[s];return this}}});function D(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var we=C(()=>{});var $t,Dr=C(()=>{Vt();lt();we();$t=class extends et{get x(){return this[0]}set x(t){this[0]=v(t)}get y(){return this[1]}set y(t){this[1]=v(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let n=0;n<this.ELEMENTS;++n){let s=this[n]-t[n];r+=s*s}return v(r)}dot(t){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*t[n];return v(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return D(t>=0&&t<this.ELEMENTS,"index is out of range"),v(this[t])}setComponent(t,r){return D(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n]*r;return this.check()}}});var Zt,sc,qr=C(()=>{Zt=typeof Float32Array<"u"?Float32Array:Array,sc=Math.PI/180});function Fr(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[4]*s+r[12],e[1]=r[1]*n+r[5]*s+r[13],e}var kr=C(()=>{});function Ur(e,t,r){let n=t[0],s=t[1],i=r[3]*n+r[7]*s||1;return e[0]=(r[0]*n+r[4]*s)/i,e[1]=(r[1]*n+r[5]*s)/i,e}function jt(e,t,r){let n=t[0],s=t[1],i=t[2],o=r[3]*n+r[7]*s+r[11]*i||1;return e[0]=(r[0]*n+r[4]*s+r[8]*i)/o,e[1]=(r[1]*n+r[5]*s+r[9]*i)/o,e[2]=(r[2]*n+r[6]*s+r[10]*i)/o,e}function Br(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s,e[1]=r[1]*n+r[3]*s,e[2]=t[2],e}var Oe=C(()=>{});function Gr(){let e=new Zt(3);return Zt!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Ae(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function Ie(e,t,r){let n=new Zt(3);return n[0]=e,n[1]=t,n[2]=r,n}function Vr(e,t){let r=t[0],n=t[1],s=t[2],i=r*r+n*n+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function St(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ht(e,t,r){let n=t[0],s=t[1],i=t[2],o=r[0],a=r[1],c=r[2];return e[0]=s*c-i*a,e[1]=i*o-n*c,e[2]=n*a-s*o,e}function Ht(e,t,r){let n=t[0],s=t[1],i=t[2],o=r[3]*n+r[7]*s+r[11]*i+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*s+r[8]*i+r[12])/o,e[1]=(r[1]*n+r[5]*s+r[9]*i+r[13])/o,e[2]=(r[2]*n+r[6]*s+r[10]*i+r[14])/o,e}function Wr(e,t,r){let n=t[0],s=t[1],i=t[2];return e[0]=n*r[0]+s*r[3]+i*r[6],e[1]=n*r[1]+s*r[4]+i*r[7],e[2]=n*r[2]+s*r[5]+i*r[8],e}function Yr(e,t,r){let n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],c=t[1],l=t[2],h=s*l-i*c,f=i*a-n*l,u=n*c-s*a,d=s*u-i*f,m=i*h-n*u,p=n*f-s*h,g=o*2;return h*=g,f*=g,u*=g,d*=2,m*=2,p*=2,e[0]=a+h+d,e[1]=c+f+m,e[2]=l+u+p,e}function $r(e,t,r,n){let s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0],i[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),i[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Zr(e,t,r,n){let s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),i[1]=s[1],i[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function jr(e,t,r,n){let s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),i[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),i[2]=s[2],e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Hr(e,t){let r=e[0],n=e[1],s=e[2],i=t[0],o=t[1],a=t[2],c=Math.sqrt((r*r+n*n+s*s)*(i*i+o*o+a*a)),l=c&&St(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var Kr,_t=C(()=>{qr();Kr=Ae});var be,Kt,x,Xr=C(()=>{Dr();ct();lt();_t();Oe();be=[0,0,0],x=class e extends $t{static get ZERO(){return Kt||(Kt=new e(0,0,0),Object.freeze(Kt)),Kt}constructor(t=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Y(t)?this.copy(t):(L.debug&&(v(t),v(r),v(n)),this[0]=t,this[1]=r,this[2]=n)}set(t,r,n){return this[0]=t,this[1]=r,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return L.debug&&(v(t.x),v(t.y),v(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=v(t)}angle(t){return Hr(this,t)}cross(t){return ht(this,this,t),this.check()}rotateX({radians:t,origin:r=be}){return $r(this,this,r,t),this.check()}rotateY({radians:t,origin:r=be}){return Zr(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=be}){return jr(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ht(this,this,t),this.check()}transformAsVector(t){return jt(this,this,t),this.check()}transformByMatrix3(t){return Wr(this,this,t),this.check()}transformByMatrix2(t){return Br(this,this,t),this.check()}transformByQuaternion(t){return Yr(this,this,t),this.check()}}});function To(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 Jr(e,t){if(e===t){let r=t[1],n=t[2],s=t[3],i=t[6],o=t[7],a=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]=n,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}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 Qr(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],f=t[9],u=t[10],d=t[11],m=t[12],p=t[13],g=t[14],T=t[15],R=r*a-n*o,_=r*c-s*o,M=r*l-i*o,S=n*c-s*a,E=n*l-i*a,O=s*l-i*c,I=h*p-f*m,w=h*g-u*m,y=h*T-d*m,b=f*g-u*p,N=f*T-d*p,P=u*T-d*g,A=R*P-_*N+M*b+S*y-E*w+O*I;return A?(A=1/A,e[0]=(a*P-c*N+l*b)*A,e[1]=(s*N-n*P-i*b)*A,e[2]=(p*O-g*E+T*S)*A,e[3]=(u*E-f*O-d*S)*A,e[4]=(c*y-o*P-l*w)*A,e[5]=(r*P-s*y+i*w)*A,e[6]=(g*M-m*O-T*_)*A,e[7]=(h*O-u*M+d*_)*A,e[8]=(o*N-a*y+l*I)*A,e[9]=(n*y-r*N-i*I)*A,e[10]=(m*E-p*M+T*R)*A,e[11]=(f*M-h*E-d*R)*A,e[12]=(a*w-o*b-c*I)*A,e[13]=(r*b-n*w+s*I)*A,e[14]=(p*_-m*S-g*R)*A,e[15]=(h*S-f*_+u*R)*A,e):null}function tn(e){let t=e[0],r=e[1],n=e[2],s=e[3],i=e[4],o=e[5],a=e[6],c=e[7],l=e[8],h=e[9],f=e[10],u=e[11],d=e[12],m=e[13],p=e[14],g=e[15],T=t*o-r*i,R=t*a-n*i,_=r*a-n*o,M=l*m-h*d,S=l*p-f*d,E=h*p-f*m,O=t*E-r*S+n*M,I=i*E-o*S+a*M,w=l*_-h*R+f*T,y=d*_-m*R+p*T;return c*O-s*I+g*w-u*y}function Ne(e,t,r){let n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],f=t[8],u=t[9],d=t[10],m=t[11],p=t[12],g=t[13],T=t[14],R=t[15],_=r[0],M=r[1],S=r[2],E=r[3];return e[0]=_*n+M*a+S*f+E*p,e[1]=_*s+M*c+S*u+E*g,e[2]=_*i+M*l+S*d+E*T,e[3]=_*o+M*h+S*m+E*R,_=r[4],M=r[5],S=r[6],E=r[7],e[4]=_*n+M*a+S*f+E*p,e[5]=_*s+M*c+S*u+E*g,e[6]=_*i+M*l+S*d+E*T,e[7]=_*o+M*h+S*m+E*R,_=r[8],M=r[9],S=r[10],E=r[11],e[8]=_*n+M*a+S*f+E*p,e[9]=_*s+M*c+S*u+E*g,e[10]=_*i+M*l+S*d+E*T,e[11]=_*o+M*h+S*m+E*R,_=r[12],M=r[13],S=r[14],E=r[15],e[12]=_*n+M*a+S*f+E*p,e[13]=_*s+M*c+S*u+E*g,e[14]=_*i+M*l+S*d+E*T,e[15]=_*o+M*h+S*m+E*R,e}function en(e,t,r){let n=r[0],s=r[1],i=r[2],o,a,c,l,h,f,u,d,m,p,g,T;return t===e?(e[12]=t[0]*n+t[4]*s+t[8]*i+t[12],e[13]=t[1]*n+t[5]*s+t[9]*i+t[13],e[14]=t[2]*n+t[6]*s+t[10]*i+t[14],e[15]=t[3]*n+t[7]*s+t[11]*i+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],h=t[4],f=t[5],u=t[6],d=t[7],m=t[8],p=t[9],g=t[10],T=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=h,e[5]=f,e[6]=u,e[7]=d,e[8]=m,e[9]=p,e[10]=g,e[11]=T,e[12]=o*n+h*s+m*i+t[12],e[13]=a*n+f*s+p*i+t[13],e[14]=c*n+u*s+g*i+t[14],e[15]=l*n+d*s+T*i+t[15]),e}function rn(e,t,r){let n=r[0],s=r[1],i=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function nn(e,t,r,n){let s=n[0],i=n[1],o=n[2],a=Math.sqrt(s*s+i*i+o*o),c,l,h,f,u,d,m,p,g,T,R,_,M,S,E,O,I,w,y,b,N,P,A,q;return a<1e-6?null:(a=1/a,s*=a,i*=a,o*=a,l=Math.sin(r),c=Math.cos(r),h=1-c,f=t[0],u=t[1],d=t[2],m=t[3],p=t[4],g=t[5],T=t[6],R=t[7],_=t[8],M=t[9],S=t[10],E=t[11],O=s*s*h+c,I=i*s*h+o*l,w=o*s*h-i*l,y=s*i*h-o*l,b=i*i*h+c,N=o*i*h+s*l,P=s*o*h+i*l,A=i*o*h-s*l,q=o*o*h+c,e[0]=f*O+p*I+_*w,e[1]=u*O+g*I+M*w,e[2]=d*O+T*I+S*w,e[3]=m*O+R*I+E*w,e[4]=f*y+p*b+_*N,e[5]=u*y+g*b+M*N,e[6]=d*y+T*b+S*N,e[7]=m*y+R*b+E*N,e[8]=f*P+p*A+_*q,e[9]=u*P+g*A+M*q,e[10]=d*P+T*A+S*q,e[11]=m*P+R*A+E*q,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function sn(e,t,r){let n=Math.sin(r),s=Math.cos(r),i=t[4],o=t[5],a=t[6],c=t[7],l=t[8],h=t[9],f=t[10],u=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]=i*s+l*n,e[5]=o*s+h*n,e[6]=a*s+f*n,e[7]=c*s+u*n,e[8]=l*s-i*n,e[9]=h*s-o*n,e[10]=f*s-a*n,e[11]=u*s-c*n,e}function on(e,t,r){let n=Math.sin(r),s=Math.cos(r),i=t[0],o=t[1],a=t[2],c=t[3],l=t[8],h=t[9],f=t[10],u=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]=i*s-l*n,e[1]=o*s-h*n,e[2]=a*s-f*n,e[3]=c*s-u*n,e[8]=i*n+l*s,e[9]=o*n+h*s,e[10]=a*n+f*s,e[11]=c*n+u*s,e}function an(e,t,r){let n=Math.sin(r),s=Math.cos(r),i=t[0],o=t[1],a=t[2],c=t[3],l=t[4],h=t[5],f=t[6],u=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]=i*s+l*n,e[1]=o*s+h*n,e[2]=a*s+f*n,e[3]=c*s+u*n,e[4]=l*s-i*n,e[5]=h*s-o*n,e[6]=f*s-a*n,e[7]=u*s-c*n,e}function cn(e,t){let r=t[0],n=t[1],s=t[2],i=t[4],o=t[5],a=t[6],c=t[8],l=t[9],h=t[10];return e[0]=Math.sqrt(r*r+n*n+s*s),e[1]=Math.sqrt(i*i+o*o+a*a),e[2]=Math.sqrt(c*c+l*l+h*h),e}function ln(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=r+r,a=n+n,c=s+s,l=r*o,h=n*o,f=n*a,u=s*o,d=s*a,m=s*c,p=i*o,g=i*a,T=i*c;return e[0]=1-f-m,e[1]=h+T,e[2]=u-g,e[3]=0,e[4]=h-T,e[5]=1-l-m,e[6]=d+p,e[7]=0,e[8]=u+g,e[9]=d-p,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function hn(e,t,r,n,s,i,o){let a=1/(r-t),c=1/(s-n),l=1/(i-o);return e[0]=i*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(s+n)*c,e[10]=(o+i)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*l,e[15]=0,e}function So(e,t,r,n,s){let i=1/Math.tan(t/2);if(e[0]=i/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(n-s);e[10]=(s+n)*o,e[14]=2*s*n*o}else e[10]=-1,e[14]=-2*n;return e}function _o(e,t,r,n,s,i,o){let a=1/(t-r),c=1/(n-s),l=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*c,e[14]=(o+i)*l,e[15]=1,e}function dn(e,t,r,n){let s,i,o,a,c,l,h,f,u,d,m=t[0],p=t[1],g=t[2],T=n[0],R=n[1],_=n[2],M=r[0],S=r[1],E=r[2];return Math.abs(m-M)<1e-6&&Math.abs(p-S)<1e-6&&Math.abs(g-E)<1e-6?To(e):(f=m-M,u=p-S,d=g-E,s=1/Math.sqrt(f*f+u*u+d*d),f*=s,u*=s,d*=s,i=R*d-_*u,o=_*f-T*d,a=T*u-R*f,s=Math.sqrt(i*i+o*o+a*a),s?(s=1/s,i*=s,o*=s,a*=s):(i=0,o=0,a=0),c=u*a-d*o,l=d*i-f*a,h=f*o-u*i,s=Math.sqrt(c*c+l*l+h*h),s?(s=1/s,c*=s,l*=s,h*=s):(c=0,l=0,h=0),e[0]=i,e[1]=c,e[2]=f,e[3]=0,e[4]=o,e[5]=l,e[6]=u,e[7]=0,e[8]=a,e[9]=h,e[10]=d,e[11]=0,e[12]=-(i*m+o*p+a*g),e[13]=-(c*m+l*p+h*g),e[14]=-(f*m+u*p+d*g),e[15]=1,e)}var fn,un,Pe=C(()=>{fn=So;un=_o});function mn(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 pn(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 xn(e){let t=e[0],r=e[1],n=e[2],s=e[3];return Math.sqrt(t*t+r*r+n*n+s*s)}function gn(e){let t=e[0],r=e[1],n=e[2],s=e[3];return t*t+r*r+n*n+s*s}function Tn(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=s*o,e[3]=i*o,e}function Sn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function _n(e,t,r,n){let s=t[0],i=t[1],o=t[2],a=t[3];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e}function Mn(e,t,r){let n=t[0],s=t[1],i=t[2],o=t[3];return e[0]=r[0]*n+r[4]*s+r[8]*i+r[12]*o,e[1]=r[1]*n+r[5]*s+r[9]*i+r[13]*o,e[2]=r[2]*n+r[6]*s+r[10]*i+r[14]*o,e[3]=r[3]*n+r[7]*s+r[11]*i+r[15]*o,e}var Le=C(()=>{});function Co(){return Xt||(Xt=new z([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Xt)),Xt}function wo(){return Jt||(Jt=new z,Object.freeze(Jt)),Jt}function En(e){if(e>Math.PI*2)throw Error("expected radians")}function Oo(e,t,r,n,s,i){let o=2*i/(r-t),a=2*i/(s-n),c=(r+t)/(r-t),l=(s+n)/(s-n),h=-1,f=-1,u=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=h,e[11]=f,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}var De,Eo,Ro,ve,ze,yo,z,Xt,Jt,Rn=C(()=>{zr();lt();Oe();Pe();kr();_t();Le();(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(De||(De={}));Eo=45*Math.PI/180,Ro=1,ve=.1,ze=500,yo=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),z=class extends Yt{static get IDENTITY(){return wo()}static get ZERO(){return Co()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return De}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,n,s,i,o,a,c,l,h,f,u,d,m,p,g){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=h,this[10]=f,this[11]=u,this[12]=d,this[13]=m,this[14]=p,this[15]=g,this.check()}setRowMajor(t,r,n,s,i,o,a,c,l,h,f,u,d,m,p,g){return this[0]=t,this[1]=i,this[2]=l,this[3]=d,this[4]=r,this[5]=o,this[6]=h,this[7]=m,this[8]=n,this[9]=a,this[10]=f,this[11]=p,this[12]=s,this[13]=c,this[14]=u,this[15]=g,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(yo)}fromObject(t){return this.check()}fromQuaternion(t){return ln(this,t),this.check()}fromMatrix3(t){return this.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1)}frustum(t){let{left:r,right:n,bottom:s,top:i,near:o=ve,far:a=ze}=t;return a===1/0?Oo(this,r,n,s,i,o):hn(this,r,n,s,i,o,a),this.check()}lookAt(t){let{eye:r,center:n=[0,0,0],up:s=[0,1,0]}=t;return dn(this,r,n,s),this.check()}ortho(t){let{left:r,right:n,bottom:s,top:i,near:o=ve,far:a=ze}=t;return un(this,r,n,s,i,o,a),this.check()}orthographic(t){let{fovy:r=Eo,aspect:n=Ro,focalDistance:s=1,near:i=ve,far:o=ze}=t;En(r);let a=r/2,c=s*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:o})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:n=1,near:s=.1,far:i=500}=t;return En(r),fn(this,r,n,s,i),this.check()}determinant(){return tn(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],i=1/n[1],o=1/n[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],i=1/n[1],o=1/n[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return Jr(this,this),this.check()}invert(){return Qr(this,this),this.check()}multiplyLeft(t){return Ne(this,t,this),this.check()}multiplyRight(t){return Ne(this,this,t),this.check()}rotateX(t){return sn(this,this,t),this.check()}rotateY(t){return on(this,this,t),this.check()}rotateZ(t){return an(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return nn(this,this,t,r),this.check()}scale(t){return rn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return en(this,this,t),this.check()}transform(t,r){return t.length===4?(r=Mn(r||[-0,-0,-0,-0],t,this),Wt(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:n}=t,s;switch(n){case 2:s=Fr(r||[-0,-0],t,this);break;case 3:s=Ht(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Wt(s,t.length),s}transformAsVector(t,r){let n;switch(t.length){case 2:n=Ur(r||[-0,-0],t,this);break;case 3:n=jt(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Wt(n,t.length),n}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,n){return this.identity().translate([t,r,n])}}});function yn(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function qe(e,t,r){r=r*.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function Fe(e,t,r){let n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],c=r[1],l=r[2],h=r[3];return e[0]=n*h+o*a+s*l-i*c,e[1]=s*h+o*c+i*a-n*l,e[2]=i*h+o*l+n*c-s*a,e[3]=o*h-n*a-s*c-i*l,e}function Cn(e,t,r){r*=.5;let n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+o*a,e[1]=s*c+i*a,e[2]=i*c-s*a,e[3]=o*c-n*a,e}function wn(e,t,r){r*=.5;let n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c-i*a,e[1]=s*c+o*a,e[2]=i*c+n*a,e[3]=o*c-s*a,e}function On(e,t,r){r*=.5;let n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+s*a,e[1]=s*c-n*a,e[2]=i*c+o*a,e[3]=o*c-i*a,e}function An(e,t){let r=t[0],n=t[1],s=t[2];return e[0]=r,e[1]=n,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s)),e}function In(e,t,r,n){let s=t[0],i=t[1],o=t[2],a=t[3],c=r[0],l=r[1],h=r[2],f=r[3],u,d,m,p,g;return u=s*c+i*l+o*h+a*f,u<0&&(u=-u,c=-c,l=-l,h=-h,f=-f),1-u>1e-6?(d=Math.acos(u),g=Math.sin(d),m=Math.sin((1-n)*d)/g,p=Math.sin(n*d)/g):(m=1-n,p=n),e[0]=m*s+p*c,e[1]=m*i+p*l,e[2]=m*o+p*h,e[3]=m*a+p*f,e}function bn(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i,a=o?1/o:0;return e[0]=-r*a,e[1]=-n*a,e[2]=-s*a,e[3]=i*a,e}function Nn(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Pn(e,t){let r=t[0]+t[4]+t[8],n;if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;n=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*n,n=.5/n,e[3]=(t[i*3+o]-t[o*3+i])*n,e[i]=(t[i*3+s]+t[s*3+i])*n,e[o]=(t[o*3+s]+t[s*3+o])*n}return e}var Ln,vn,zn,Dn,qn,Fn,Ao,kn,Un=C(()=>{_t();Le();Ln=mn,vn=pn,zn=Sn,Dn=_n,qn=xn,Fn=gn,Ao=Tn,kn=(function(){let e=Gr(),t=Ie(1,0,0),r=Ie(0,1,0);return function(n,s,i){let o=St(s,i);return o<-.999999?(ht(e,t,s),Kr(e)<1e-6&&ht(e,r,s),Vr(e,e),qe(n,e,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(ht(e,s,i),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,Ao(n,n))}})()});var Mt,Bn=C(()=>{Vt();lt();Un();Mt=class extends et{constructor(t=0,r=0,n=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,r,n,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,r,n,s){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Pn(this,t),this.check()}fromEuler(t){switch(this.identity(),t.order){case"xyz":return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z);case"yxz":return this.rotateY(t.y).rotateX(t.x).rotateZ(t.z);case"zxy":return this.rotateZ(t.z).rotateX(t.x).rotateY(t.y);case"zyx":return this.rotateZ(t.z).rotateY(t.y).rotateX(t.x);case"yzx":return this.rotateY(t.y).rotateZ(t.z).rotateX(t.x);case"xzy":return this.rotateX(t.x).rotateZ(t.z).rotateY(t.y);default:throw new Error("Unknown Euler angle order")}}fromAxisRotation(t,r){return qe(this,t,r),this.check()}identity(){return yn(this),this.check()}setAxisAngle(t,r){return this.fromAxisRotation(t,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=v(t)}get y(){return this[1]}set y(t){this[1]=v(t)}get z(){return this[2]}set z(t){this[2]=v(t)}get w(){return this[3]}set w(t){this[3]=v(t)}len(){return qn(this)}lengthSquared(){return Fn(this)}dot(t){return zn(this,t)}rotationTo(t,r){return kn(this,t,r),this.check()}add(t){return Ln(this,this,t),this.check()}calculateW(){return An(this,this),this.check()}conjugate(){return Nn(this,this),this.check()}invert(){return bn(this,this),this.check()}lerp(t,r,n){return n===void 0?this.lerp(this,t,r):(Dn(this,t,r,n),this.check())}multiplyRight(t){return Fe(this,this,t),this.check()}multiplyLeft(t){return Fe(this,t,this),this.check()}normalize(){let t=this.len(),r=t>0?1/t:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,t===0&&(this[3]=1),this.check()}rotateX(t){return Cn(this,this,t),this.check()}rotateY(t){return wn(this,this,t),this.check()}rotateZ(t){return On(this,this,t),this.check()}scale(t){return vn(this,this,t),this.check()}slerp(t,r,n){let s,i,o;return arguments.length===2?(s=this,i=t,o=r):(s=t,i=r,o=n),In(this,s,i,o),this.check()}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,r){return this.setAxisAngle(t,r)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}}});var B=C(()=>{Xr();Rn();Bn();Pr();we();ct()});function Vn(e,t,r=e){let n=e.x,s=e.y,i=e.z,{semiMajorAxis:o,semiMinorAxis:a,eccentricitySquared:c}=t,l=Math.sin(s),h=Math.cos(s),f=a/o,u=c<.9?o/Math.sqrt(1-c*l*l):o/Math.hypot(h,f*l),d=(u+i)*h*Math.cos(n),m=(u+i)*h*Math.sin(n),p=(u*(c<.9?1-c:f*f)+i)*l;return nt(r,d,m,p)}function Wn(e,t,r=e){let n=e.x,s=e.y,i=e.z,{semiMajorAxis:o,semiMinorAxis:a,eccentricitySquared:c}=t,l=Math.hypot(n,s),h=Math.hypot(n,s,i);if(!(h>0)||!Number.isFinite(h))return!1;if(c===0)return nt(r,l===0?0:Math.atan2(s,n),Math.atan2(i,l),h-o);if(l===0)return nt(r,0,Math.sign(i)*Math.PI/2,Math.abs(i)-a);let f=l/o,u=i/a;if(f*f+u*u<1-16*Number.EPSILON)return Io(n,s,i,l,o,a,r);if(c>=.9)return Gn(n,s,i,l,o,a,r);let d=i/h,m=l/h,p=1/Math.sqrt(1-c*(2-c)*m*m),g=m*(1-c)*p,T=d*p;for(let R=0;R<30;R++){let _=o/Math.sqrt(1-c*T*T),M=l*g+i*T-_*(1-c*T*T),S=c*_/(_+M);p=1/Math.sqrt(1-S*(2-S)*m*m);let E=m*(1-S)*p,O=d*p;if(Math.abs(O*g-E*T)<=1e-12){if(!Number.isFinite(M)||!Number.isFinite(O)||!Number.isFinite(E))break;return nt(r,Math.atan2(s,n),Math.atan2(O,Math.abs(E)),M)}g=E,T=O}return Gn(n,s,i,l,o,a,r)}function Io(e,t,r,n,s,i,o){let a=i/s,c=a*a,l=n/s,h=r/s,f=1-c;if(!(c>0)||a>1)return!1;if(r===0)return l<f?!1:nt(o,Math.atan2(t,e),0,n-s);let u=s*s,d=i*i,m=Number.isFinite(u)&&u>0?(d-c*u+rt(i,i,d)-c*rt(s,s,u)-rt(c,u,c*u))/u:0,p=n*n,g=e*e,T=t*t,R=g+T,_=Number.isFinite(p)&&p>0?(R-p+ke(g,T,R)+rt(e,e,g)+rt(t,t,T)-rt(n,n,p))/(2*n):0,M=s*c,S=n-s+M,E=_+ke(n-s,M,S)+rt(s,c,M)+s*m,O=Math.abs(h)*a;if(!(O>0))return!1;let I=0,w=c,y=Math.max(O,l-f);y>I&&y<w||(y=w/2);for(let b=0;b<128;b++){let N=f+y,P=l/N,A=O/y,q=s*y,$=S-q,Lt=($+(ke(S,-q,$)+E-rt(s,y,q)))/(s*N)*(P+1),mt=Lt+A*A;if(Math.abs(mt)<=4*Number.EPSILON*(Math.abs(Lt)+A*A)||w-I<=4*Number.EPSILON*y){let Z=Math.atan2(h/y,l/N),ur=Math.sin(Z),dr=Math.cos(Z);return nt(o,Math.atan2(t,e),Z,n*dr+r*ur-s*Math.hypot(dr,a*ur))}mt>0?I=y:w=y;let hr=-2*(P*P/N+A*A/y),Q=y-mt/hr,fr=Number.isFinite(Q)&&Q>I&&Q<w?Q:I+(w-I)/2;if(fr===y){let Z=Math.atan2(h/y,l/N);return nt(o,Math.atan2(t,e),Z,n*Math.cos(Z)+r*Math.sin(Z)-s*Math.hypot(Math.cos(Z),a*Math.sin(Z)))}y=fr}return!1}function ke(e,t,r){let n=r-e;return e-(r-n)+(t-n)}function rt(e,t,r){let n=134217729*e,s=134217729*t;if(!Number.isFinite(n)||!Number.isFinite(s))return 0;let i=n-(n-e),o=s-(s-t),a=e-i,c=t-o;return i*o-r+i*c+a*o+a*c}function Gn(e,t,r,n,s,i,o){let a=i/s,c=a*a,l=n/s,h=r/s,f=Math.hypot(l,r/i);if(!Number.isFinite(f)||f<1-8*Number.EPSILON||!(c>0))return!1;let u=0,d=Math.hypot(l,h*a);if(!Number.isFinite(d))return!1;let m=f<=1+8*Number.EPSILON?0:d/2;for(let p=0;p<96;p++){let g=1+m,T=c+m,R=l/g,_=h*a/T,M=Math.hypot(R,_),S=M-1;if(Math.abs(S)<=4*Number.EPSILON){let I=Math.atan2(h/T,l/g),w=Math.sin(I),y=Math.cos(I),b=n*y+r*w-s*Math.hypot(y,a*w);return nt(o,Math.atan2(t,e),I,b)}S>0?u=m:d=m;let E=-(R*R/g+_*_/T)/M,O=m-S/E;m=Number.isFinite(O)&&O>u&&O<d?O:(u+d)/2}return!1}function nt(e,t,r,n){return!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(n)?!1:(e.x=t,e.y=r,e.z=n,!0)}var Yn=C(()=>{});var $n=C(()=>{_t()});var X,Hc,Zn=C(()=>{X=6356752314245179e-9,Hc={radii:[6378137,6378137,X],radiiSquared:[6378137*6378137,6378137*6378137,X*X],oneOverRadii:[1/6378137,1/6378137,1/X],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(X*X)],maximumRadius:Math.max(6378137,6378137,X),centerToleranceSquared:.1}});function Ue(e){return e}function No(e,t=[],r=Ue){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function Be(e,t=[]){return No(e,t,L._cartographicRadians?Ue:Re)}function Ge(e,t,r,n){let s=L._cartographicRadians?Ue:ye,i=s(e),o=s(t);return"longitude"in n?(n.longitude=i,n.latitude=o,n.height=r):"x"in n?(n.x=i,n.y=o,n.z=r):(n[0]=i,n[1]=o,n[2]=r),n}var Jc,jn=C(()=>{B();Jc=new x});function Hn(){return{eastX:0,eastY:1,northZ:1,upX:1,upY:0,upZ:0}}function Kn(e,t,r){let n=e.x,s=e.y,i=e.z,o=t.x,a=t.y,c=t.z;return i!==0?!1:Po(r,n,s,o*s-a*n,o,a,c)}function Xn(e,t,r,n,s,i){let o=Ve(r),a=Ve(n),c=Ve(s),l=Math.abs(o),h=Math.abs(a),f=Math.abs(c);if(!l||!h||!f||l===h||l===f||h===f||(l%3+1===h?1:-1)*Math.sign(o*a*c)!==1||!Array.isArray(i)&&i.length<16)return!1;let d=e.eastX,m=e.eastY,p=e.northZ,g=e.upX,T=e.upY,R=e.upZ,_=-R*m,M=R*d,S=t.x,E=t.y,O=t.z,I=(l===1?d:l===2?_:g)*Math.sign(o),w=(l===1?m:l===2?M:T)*Math.sign(o),y=(l===1?0:l===2?p:R)*Math.sign(o),b=(h===1?d:h===2?_:g)*Math.sign(a),N=(h===1?m:h===2?M:T)*Math.sign(a),P=(h===1?0:h===2?p:R)*Math.sign(a),A=(f===1?d:f===2?_:g)*Math.sign(c),q=(f===1?m:f===2?M:T)*Math.sign(c),$=(f===1?0:f===2?p:R)*Math.sign(c);return!Number.isFinite(I)||!Number.isFinite(w)||!Number.isFinite(y)||!Number.isFinite(b)||!Number.isFinite(N)||!Number.isFinite(P)||!Number.isFinite(A)||!Number.isFinite(q)||!Number.isFinite($)||!Number.isFinite(S)||!Number.isFinite(E)||!Number.isFinite(O)||i instanceof Float32Array&&(!Number.isFinite(Math.fround(I))||!Number.isFinite(Math.fround(w))||!Number.isFinite(Math.fround(y))||!Number.isFinite(Math.fround(b))||!Number.isFinite(Math.fround(N))||!Number.isFinite(Math.fround(P))||!Number.isFinite(Math.fround(A))||!Number.isFinite(Math.fround(q))||!Number.isFinite(Math.fround($))||!Number.isFinite(Math.fround(S))||!Number.isFinite(Math.fround(E))||!Number.isFinite(Math.fround(O)))?!1:(i[0]=I,i[1]=w,i[2]=y,i[3]=0,i[4]=b,i[5]=N,i[6]=P,i[7]=0,i[8]=A,i[9]=q,i[10]=$,i[11]=0,i[12]=S,i[13]=E,i[14]=O,i[15]=1,!0)}function Ve(e){switch(e){case"east":return 1;case"west":return-1;case"north":return 2;case"south":return-2;case"up":return 3;case"down":return-3;default:return 0}}function Po(e,t,r,n,s,i,o){return!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(o)?!1:(e.eastX=t,e.eastY=r,e.northZ=n,e.upX=s,e.upY=i,e.upZ=o,!0)}var Jn=C(()=>{});function Ye(e,t,r,n,s,i){let o=es[t]&&es[t][r];D(o&&(!n||n===o));let a,c,l,h=Lo.copy(s),f=U(h.x,0,Qn)&&U(h.y,0,Qn),u=e.radii;if(u.x===u.y&&u.x>0&&u.z>0&&u.z<=u.x&&(!f||h.z!==0)){let{east:w,up:y}=ft;if(f?(w.set(0,1,0),y.set(0,0,Math.sign(h.z))):(w.set(-h.y,h.x,0).normalize(),e.geodeticSurfaceNormal(h,y)),!Kn(w,y,ts)||!Xn(ts,h,t,r,n,i))throw new Error("Unsupported local frame");return i}if(f){let w=Math.sign(h.z);a=vo.fromArray(We[t]),t!=="east"&&t!=="west"&&a.scale(w),c=zo.fromArray(We[r]),r!=="east"&&r!=="west"&&c.scale(w),l=Do.fromArray(We[n]),n!=="east"&&n!=="west"&&l.scale(w)}else{let{up:w,east:y,north:b}=ft;y.set(-h.y,h.x,0).normalize(),e.geodeticSurfaceNormal(h,w),b.copy(w).cross(y);let{down:N,west:P,south:A}=ft;N.copy(w).scale(-1),P.copy(y).scale(-1),A.copy(b).scale(-1),a=ft[t],c=ft[r],l=ft[n]}let d=a.x,m=a.y,p=a.z,g=c.x,T=c.y,R=c.z,_=l.x,M=l.y,S=l.z,E=h.x,O=h.y,I=h.z;return i[0]=d,i[1]=m,i[2]=p,i[3]=0,i[4]=g,i[5]=T,i[6]=R,i[7]=0,i[8]=_,i[9]=M,i[10]=S,i[11]=0,i[12]=E,i[13]=O,i[14]=I,i[15]=1,i}var Qn,Lo,ts,es,We,ft,vo,zo,Do,rs=C(()=>{B();Jn();Qn=1e-14,Lo=new x,ts=Hn(),es={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},We={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},ft={east:new x,north:new x,up:new x,west:new x,south:new x,down:new x},vo=new x,zo=new x,Do=new x});function ss(e,t,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:s,centerToleranceSquared:i}=t,o=e,a="x"in e?o.x:e[0],c="x"in e?o.y:e[1],l="x"in e?o.z:e[2];if(!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(l))return;ns.set(a,c,l);let h=n.x,f=n.y,u=n.z,d=a*a*h*h,m=c*c*f*f,p=l*l*u*u,g=d+m+p,T=Math.sqrt(1/g);if(!Number.isFinite(T)||!Number.isFinite(g))return;let R=qo;if(R.set(a,c,l).scale(T),g<i)return Qt(r,R.x,R.y,R.z);let _=s.x,M=s.y,S=s.z,E=Fo;E.set(R.x*_*2,R.y*M*2,R.z*S*2);let O=(1-T)*ns.len()/(.5*E.len()),I=0,w,y,b,N;for(let P=0;P<64;P++){O-=I,w=1/(1+O*_),y=1/(1+O*M),b=1/(1+O*S);let A=w*w,q=y*y,$=b*b,lr=A*w,Lt=q*y,mt=$*b;if(N=d*A+m*q+p*$-1,!Number.isFinite(N))return;if(Math.abs(N)<=K.EPSILON12)return Qt(r,a*w,c*y,l*b);let Q=-2*(d*lr*_+m*Lt*M+p*mt*S);if(!Number.isFinite(Q)||Q===0||(I=N/Q,!Number.isFinite(I)))return}}function Qt(e,t,r,n){if(Y(e))e[0]=t,e[1]=r,e[2]=n;else{let s=e;s.x=t,s.y=r,s.z=n}return e}var ns,qo,Fo,is=C(()=>{B();ns=new x,qo=new x,Fo=new x});function as(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0||t>e)throw new Error("Spheroid requires finite positive axes with semiMinorAxis <= semiMajorAxis")}var F,te,os,Bo,V,Go,Et,k,cs=C(()=>{B();Yn();$n();Zn();jn();rs();is();F={x:0,y:0,z:0},te=new x,os=new x,Bo=new x,V=new x,Go=new x,Et=new x,k=class e{static fromSpheroid(t){let{semiMajorAxis:r,semiMinorAxis:n}=t;return as(r,n),new e(r,r,n)}constructor(t=0,r=0,n=0){this.centerToleranceSquared=K.EPSILON1,D(t>=0),D(r>=0),D(n>=0),this.radii=new x(t,r,n),this.radiiSquared=new x(t*t,r*r,n*n),this.radiiToTheFourth=new x(t*t*t*t,r*r*r*r,n*n*n*n),this.oneOverRadii=new x(t===0?0:1/t,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new x(t===0?0:1/(t*t),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(t,r,n),this.maximumRadius=Math.max(t,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),t===r&&n>0&&n<=t&&Number.isFinite(this.radiiSquared.x)&&this.radiiSquared.z>0&&(this.spheroidGeometry=Object.freeze({semiMajorAxis:t,semiMinorAxis:n,eccentricitySquared:1-this.radiiSquared.z/this.radiiSquared.x})),Object.freeze(this)}toSpheroid(){let{x:t,y:r,z:n}=this.radii;if(t!==r)throw new Error("Spheroid requires equal X/Y radii");return as(t,n),Object.freeze({semiMajorAxis:t,semiMinorAxis:n})}equals(t){return this===t||!!(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){if(this.spheroidGeometry){let a=Be(t,Et);return F.x=a[0],F.y=a[1],F.z=a[2],Vn(F,this.spheroidGeometry)?Qt(r,F.x,F.y,F.z):void 0}let n=os,s=Bo,[,,i]=t;this.geodeticSurfaceNormalCartographic(t,n),s.copy(this.radiiSquared).scale(n);let o=Math.sqrt(n.dot(s));return s.scale(1/o),n.scale(i),s.add(n),s.to(r)}cartesianToCartographic(t,r=[0,0,0]){let n=t,s="x"in t?n.x:t[0],i="x"in t?n.y:t[1],o="x"in t?n.z:t[2];if(!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(o))return;if(this.spheroidGeometry&&Number.isFinite(s*s+i*i+o*o)&&Number.isFinite(this.oneOverRadiiSquared.x)&&Number.isFinite(this.oneOverRadiiSquared.z)){if(F.x=s,F.y=i,F.z=o,!Wn(F,this.spheroidGeometry))return;let d=s===0&&i===0?Math.atan2(i,s):F.x;return Ge(d,F.y,F.z,r)}Et.set(s,i,o);let a=this.scaleToGeodeticSurface(Et,V);if(!a)return;let c=this.geodeticSurfaceNormal(a,os),l=Go;l.copy(Et).subtract(a);let h=Math.atan2(c.y,c.x),f=Math.atan2(c.z,Math.hypot(c.x,c.y)),u=Math.sign(St(l,Et))*Ae(l);return Ge(h,f,u,r)}eastNorthUpToFixedFrame(t,r=new z){return Ye(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,n,s,i=new z){return Ye(this,t,r,n,s,i)}geocentricSurfaceNormal(t,r=[0,0,0]){return te.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){let n=Be(t),s=n[0],i=n[1],o=Math.cos(i);return te.set(o*Math.cos(s),o*Math.sin(s),Math.sin(i)).normalize(),te.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return te.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return ss(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){V.from(t);let n=V.x,s=V.y,i=V.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*o.x+s*s*o.y+i*i*o.z);return V.multiplyByScalar(a).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return V.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return V.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,n=[0,0,0]){D(U(this.radii.x,this.radii.y,K.EPSILON15)),D(this.radii.z>0),V.from(t);let s=V.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-r))return V.set(0,0,s).to(n)}};k.WGS84=new k(6378137,6378137,X)});var ls=C(()=>{Pe()});var Rt,hs,yt,fs=C(()=>{B();ls();Rt=new x,hs=new x,yt=class e{constructor(t=[0,0,0],r=0){this.radius=-0,this.center=new x,this.fromCenterRadius(t,r)}fromCenterRadius(t,r){return this.center.from(t),this.radius=r,this}fromCornerPoints(t,r){return r=Rt.from(r),this.center=new x().from(t).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new e(this.center,this.radius)}union(t){let r=this.center,n=this.radius,s=t.center,i=t.radius,o=Rt.copy(s).subtract(r),a=o.magnitude();if(n>=a+i)return this.clone();if(i>=a+n)return t.clone();let c=(n+a+i)*.5;return hs.copy(o).scale((-n+c)/a).add(r),this.center.copy(hs),this.radius=c,this}expand(t){let n=Rt.from(t).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(t){this.center.transform(t);let r=cn(Rt,t);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(t){let r=this.distanceTo(t);return r*r}distanceTo(t){let n=Rt.from(t).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(t){let r=this.center,n=this.radius,i=t.normal.dot(r)+t.distance;return i<-n?"outside":i<n?"intersecting":"inside"}}});var us,ds,G,$e=C(()=>{B();us=new x,ds=new x,G=class e{constructor(t=[0,0,1],r=0){this.normal=new x,this.distance=-0,this.fromNormalDistance(t,r)}fromNormalDistance(t,r){return D(Number.isFinite(r)),this.normal.from(t).normalize(),this.distance=r,this}fromPointNormal(t,r){t=us.from(t),this.normal.from(r).normalize();let n=-this.normal.dot(t);return this.distance=n,this}fromCoefficients(t,r,n,s){return this.normal.set(t,r,n),D(U(this.normal.len(),1)),this.distance=s,this}clone(){return new e(this.normal,this.distance)}equals(t){return U(this.distance,t.distance)&&U(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let r=ds.copy(this.normal).transformAsVector(t).normalize(),n=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(n,r)}projectPointOntoPlane(t,r=[0,0,0]){let n=us.from(t),s=this.getPointDistance(n),i=ds.copy(this.normal).scale(s);return n.subtract(i).to(r)}intersectWithRay(t,r=new x){let n=t.origin,s=t.direction,i=this.normal,o=i.dot(s);if(Math.abs(o)<K.EPSILON15)return;let a=(-this.distance-i.dot(n))/o;if(!(a<0))return r.copy(s).multiplyByScalar(a).add(n)}}});var ms,ps,Wo,st,xs=C(()=>{B();$e();ms=[new x([1,0,0]),new x([0,1,0]),new x([0,0,1])],ps=new x,Wo=new x,st=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*ms.length;let r=t.center,n=t.radius,s=0;for(let i of ms){let o=this.planes[s],a=this.planes[s+1];o||(o=this.planes[s]=new G),a||(a=this.planes[s+1]=new G);let c=ps.copy(i).scale(-n).add(r);o.fromPointNormal(c,i);let l=ps.copy(i).scale(n).add(r),h=Wo.copy(i).negate();a.fromPointNormal(l,h),s+=2}return this}computeVisibility(t){let r="inside";for(let n of this.planes)switch(t.intersectPlane(n)){case"outside":return"outside";case"intersecting":r="intersecting";break;default:}return r}computeVisibilityWithPlaneMask(t,r){if(D(Number.isFinite(r),"parentPlaneMask is required."),r===e.MASK_OUTSIDE||r===e.MASK_INSIDE)return r;let n=e.MASK_INSIDE,s=this.planes;for(let i=0;i<this.planes.length;++i){let o=i<31?1<<i:0;if(i<31&&(r&o)===0)continue;let a=s[i],c=t.intersectPlane(a);if(c==="outside")return e.MASK_OUTSIDE;c==="intersecting"&&(n|=o)}return n}};st.MASK_OUTSIDE=4294967295;st.MASK_INSIDE=0;st.MASK_INDETERMINATE=2147483647});var Ze=C(()=>{fs();xs();$e()});var gs=C(()=>{cs()});var Ts=C(()=>{});function He(e){Yo(e)}function Yo(e){if(typeof e.id!="string"||!e.id||e.origin.length!==2||e.tileSize.length!==2||e.matrixSize.length!==2||!Number.isFinite(e.resolution)||e.resolution<=0||e.resolutionY!==void 0&&(!Number.isFinite(e.resolutionY)||e.resolutionY<=0)||!e.origin.every(Number.isFinite)||![...e.tileSize,...e.matrixSize].every(n=>Number.isSafeInteger(n)&&n>0)||!["topLeft","bottomLeft"].includes(e.cornerOfOrigin))throw new RangeError("Invalid tile matrix geometry");let t=[...e.variableMatrixWidths??[]].sort((n,s)=>n.minTileRow-s.minTileRow),r=-1;for(let n of t){if(!Number.isSafeInteger(n.coalesce)||n.coalesce<=1||e.matrixSize[0]%n.coalesce!==0||!Number.isSafeInteger(n.minTileRow)||!Number.isSafeInteger(n.maxTileRow)||n.minTileRow<=r||n.maxTileRow<n.minTileRow||n.maxTileRow>=e.matrixSize[1])throw new RangeError("Invalid variable matrix width");r=n.maxTileRow}for(let n=0;n<2;n++){let i=(n===1?e.resolutionY??e.resolution:e.resolution)*e.tileSize[n],o=i*e.matrixSize[n],a=n===1&&e.cornerOfOrigin==="topLeft"?-1:1,c=e.origin[n]+a*o;if(!Number.isFinite(o)||o<=0||!Number.isFinite(c)||e.origin[n]+a*i===e.origin[n]||c-a*i===c)throw new RangeError("Tile matrix extent must be finite")}return t}function Ke(e,t,r,n){return He(e),n&&Ms(e,n),Number.isSafeInteger(t)&&Number.isSafeInteger(r)&&t>=0&&r>=0&&t<e.matrixSize[0]&&r<e.matrixSize[1]&&(!n||t>=n.minTileColumn&&t<=n.maxTileColumn&&r>=n.minTileRow&&r<=n.maxTileRow)}function _s(e,t,r){if(!Ke(e,t,r))throw new RangeError("Tile index outside matrix");let n=e.resolution*e.tileSize[0],s=(e.resolutionY??e.resolution)*e.tileSize[1],i=Ho(e,r),o=Math.floor(t/i)*i,a=e.origin[0]+o*n,c=e.cornerOfOrigin==="topLeft"?e.origin[1]-(r+1)*s:e.origin[1]+r*s;return[a,c,e.origin[0]+(o+i)*n,e.cornerOfOrigin==="topLeft"?e.origin[1]-r*s:e.origin[1]+(r+1)*s]}function $o(e,t,r,n,s,i=1){let o=e+t*(n*r);return(t===1?s<e||s>=o:s>e||s<=o)?null:(je(e,t,r,n,s,!1,i)-1)*i}function je(e,t,r,n,s,i,o=1){let a=0,c=n/o;for(;a<c;){let l=a+Math.floor((c-a)/2),h=e+t*(l*o*r);(t===1?i?h<s:h<=s:i?h>s:h>=s)?a=l+1:c=l}return a}function Ms(e,t){if(![t.minTileColumn,t.maxTileColumn,t.minTileRow,t.maxTileRow].every(n=>Number.isSafeInteger(n)&&n>=0)||t.minTileColumn>t.maxTileColumn||t.minTileRow>t.maxTileRow||t.maxTileColumn>=e.matrixSize[0]||t.maxTileRow>=e.matrixSize[1])throw new RangeError("Invalid tile matrix limits")}function Zo(e,t,r){jo(t);let n=Ss(e.origin[0],1,e.resolution*e.tileSize[0],e.matrixSize[0],t[0],t[2]),s=e.cornerOfOrigin==="topLeft",i=Ss(e.origin[1],s?-1:1,(e.resolutionY??e.resolution)*e.tileSize[1],e.matrixSize[1],s?t[3]:t[1],s?t[1]:t[3]);if(!n||!i)return null;let o={minTileColumn:Math.max(n[0],r?.minTileColumn??0),maxTileColumn:Math.min(n[1],r?.maxTileColumn??e.matrixSize[0]-1),minTileRow:Math.max(i[0],r?.minTileRow??0),maxTileRow:Math.min(i[1],r?.maxTileRow??e.matrixSize[1]-1)};return o.minTileColumn>o.maxTileColumn||o.minTileRow>o.maxTileRow?null:o}function jo(e){if(e.length!==4||!e.every(Number.isFinite)||e[0]>e[2]||e[1]>e[3])throw new RangeError("Tile query bounds must be finite and ordered")}function Es(e,t,r){if(He(e),e.variableMatrixWidths?.length)throw new RangeError("Use getTileRanges for variable-width matrices");return r&&Ms(e,r),Zo(e,t,r)}function Ho(e,t){return e.variableMatrixWidths?.find(r=>t>=r.minTileRow&&t<=r.maxTileRow)?.coalesce??1}function Ss(e,t,r,n,s,i,o=1){if(s===i){let h=$o(e,t,r,n,s,o);return h===null?null:[h,h]}let a=e+t*(n*r),c=t===1?Math.max(s,e):Math.min(s,e),l=t===1?Math.min(i,a):Math.max(i,a);return(t===1?c>=l:c<=l)?null:[(je(e,t,r,n,c,!1,o)-1)*o,(je(e,t,r,n,l,!0,o)-1)*o]}function Rs(e,t){if(!Number.isFinite(t)||t<=0)throw new RangeError("Target resolution must be positive and finite");let r=null,n=null,s=-1/0,i=1/0,o=new Set;for(let a of e.matrices){if(He(a),o.has(a.id))throw new RangeError("Tile matrix identifiers must be unique");o.add(a.id);let c=Math.max(a.resolution,a.resolutionY??a.resolution);(!n||c<i)&&(n=a,i=c),c<=t&&(!r||c>s)&&(r=a,s=c)}return r??n}var ys=C(()=>{});var Cs=C(()=>{});var ee=C(()=>{gs();Ts();Cs()});var Ct=C(()=>{"use strict";gr();Sr();Mr()});var Pt={};mr(Pt,{ImageSet:()=>ie,LOD_METRIC_TYPE:()=>bt,RasterSet:()=>oe,STRATEGY_DEFAULT:()=>dt,STRATEGY_NEVER:()=>re,STRATEGY_REPLACE:()=>ne,SharedTile2DHeader:()=>tt,TILESET_TYPE:()=>J,TILE_TYPE:()=>It,Tileset2D:()=>ut,Tileset3D:()=>Nt,selectTileMatrixTiles:()=>si});Dt(Pt,fi(xr(),1));var tt=class{index;parent;children;content;error;id;zoom;userData;boundingBox;_abortController;_loader;_loaderId;_isLoaded;_isCancelled;_needsReload;_bbox;constructor(t){this.index=t,this.parent=null,this.children=[],this.content=null,this.error=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(t){this._bbox||(this._bbox=t,"west"in t?this.boundingBox=[[t.west,t.south],[t.east,t.north]]:this.boundingBox=[[t.left,t.top],[t.right,t.bottom]])}get data(){let t=this._loader;return!this._isCancelled&&t!==void 0?t.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get hasError(){return!!this.error}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let t=this.content?this.content.byteLength:0;return Number.isFinite(t)?t:0}async _loadData({getData:t,requestScheduler:r,onLoad:n,onError:s}){let i=(g,T,R)=>{if(!(R!==this._loaderId||this._isCancelled)){if(this._loader=void 0,this.content=g,this.error=T?di(T):null,this._isLoaded=!0,this._isCancelled=!1,T){s(T,this);return}n(this)}},{index:o,id:a,bbox:c,userData:l,zoom:h}=this,f=this._loaderId;this._abortController=new AbortController;let{signal:u}=this._abortController,d=await r.scheduleRequest({tile:this,loaderId:f},()=>f===this._loaderId&&!this._isCancelled?1:-1);if(this._isCancelled||f!==this._loaderId){d?.done();return}if(!d){this._isCancelled=!0;return}let m=null,p;try{m=await t({index:o,id:a,bbox:c,userData:l,zoom:h,signal:u})}catch(g){p=g||!0}finally{d.done()}i(m,p,f)}loadData(t){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this.error=null,this._loaderId++,this._loader=this._loadData(t),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._loaderId++,this._loader=void 0,this._abortController?.abort())}};function di(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}Ct();Ft();var re="never",ne="no-overlap",dt="best-available",ws={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:dt,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},ut=class e{stats;sourceMetadata=null;opts;_requestScheduler;_cache;_dirty;_tiles;_cacheByteSize;_unloadedTileCount;_listeners=new Set;_consumers=new Map;_explicitOptionKeys=new Set;_baseOpts={};_sourceMetadataOverrides={};_maxZoom;_minZoom;_lastTileContext=null;_statsUpdateScheduled=!1;_lifecycleVersion=0;constructor(t){if(this.stats=new W({id:"Tileset2D",stats:[{name:"Tiles In Cache"},{name:"Cache Size"},{name:"Visible Tiles"},{name:"Selected Tiles"},{name:"Loading Tiles"},{name:"Unloaded Tiles"},{name:"Consumers"}]}),this.opts={...ws,...t,getTileData:t.getTileData||(()=>null),tileSource:t.tileSource},this._requestScheduler=new j({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._unloadedTileCount=0,!this.opts.tileSource&&!t.getTileData)throw new Error("Tileset2D requires either `getTileData` or `tileSource`.");this.setOptions(t),this._updateStats(),this.opts.tileSource&&this._initializeTileSource(this.opts.tileSource).catch(()=>{})}static fromTileSource(t,r={}){return new e({...r,tileSource:t})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let t=this._getVisibleTilesUnion();for(let r of this._getSelectedTilesUnion())t.add(r);return Array.from(t)}get loadingTiles(){return Array.from(this._cache.values()).filter(t=>t.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(t=>!t.isLoaded)}get maxZoom(){return this._maxZoom}get minZoom(){return this._minZoom}get refinementStrategy(){return this.opts.refinementStrategy||dt}get adapter(){return this.opts.adapter}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}attachConsumer(t){this._consumers.set(t,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(t){this._consumers.delete(t),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(t){this._rememberExplicitOptions(t),this._baseOpts={...this._baseOpts,...t};let r=this.opts.maxRequests,n=this.opts.debounceTime;this._applyResolvedOptions(),(r!==this.opts.maxRequests||n!==this.opts.debounceTime)&&(this._requestScheduler=new j({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}))}finalize(){this._lifecycleVersion++;for(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._consumers.clear(),this._cacheByteSize=0,this._unloadedTileCount=0,this._updateStats()}reloadAll(){let t=this._getSelectedTilesUnion(),r=this._getVisibleTilesUnion();for(let n of this._cache.keys()){let s=this._cache.get(n);s&&!t.has(s)&&!r.has(s)?(this._cache.delete(n),this._handleTileUnload(s),this._dirty=!0):s&&s.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,r,n){this._consumers.set(t,{selectedTiles:new Set(r),visibleTiles:new Set(n)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:r,minZoom:n,zRange:s,modelMatrix:i,modelMatrixInverse:o}){let{adapter:a,tileSize:c,extent:l,zoomOffset:h}=this.opts;if(!a)throw new Error("Tileset2D requires an adapter before tile traversal can be used.");return this._lastTileContext={viewState:t,tileSize:c},a.getTileIndices({viewState:t,maxZoom:r,minZoom:n,zRange:s,tileSize:c,extent:Ko(l),modelMatrix:i,modelMatrixInverse:o,zoomOffset:h})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){if(!this._lastTileContext)throw new Error("Tileset2D metadata requested before traversal context was set.");if(!this.opts.adapter)throw new Error("Tileset2D requires an adapter before tile metadata can be derived.");return{bbox:this.opts.adapter.getTileBoundingBox(this._lastTileContext,t)}}getParentIndex(t){return{x:Math.floor(t.x/2),y:Math.floor(t.y/2),z:t.z-1}}getTile(t,r){let n=this.getTileId(t),s=this._cache.get(n),i=!1;if(!s&&r?(s=new tt(t),Object.assign(s,this.getTileMetadata(s.index)),Object.assign(s,{id:n,zoom:this.getTileZoom(s.index)}),i=!0,this._cache.set(n,s),this._dirty=!0,this._setStatCount("Tiles In Cache",this._cache.size),this._scheduleStatsUpdate()):s&&s.needsReload&&(i=!0),s&&this._touchTile(n,s),s&&i&&r){let o=s.isLoading;s.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),o||this.stats.get("Loading Tiles").incrementCount(),this._scheduleStatsUpdate()}return s}async _initializeTileSource(t){let r=this._lifecycleVersion;try{let n=await t.getMetadata();if(r!==this._lifecycleVersion)return;this.sourceMetadata=n,this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(n){if(r!==this._lifecycleVersion)return;let s=n instanceof Error?n:new Error(`TileSource metadata error: ${String(n)}`);this._notifyError(s)}}_rememberExplicitOptions(t){for(let r of Object.keys(t))this._explicitOptionKeys.add(r)}_applyResolvedOptions(){let t={...ws,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let r=t.tileSource;t.getTileData=n=>r.getTileData(n)}this.opts=t,this._maxZoom=typeof this.opts.maxZoom=="number"&&Number.isFinite(this.opts.maxZoom)?Math.floor(this.opts.maxZoom):void 0,this._minZoom=typeof this.opts.minZoom=="number"&&Number.isFinite(this.opts.minZoom)?Math.ceil(this.opts.minZoom):void 0}_getMetadataOverrides(t){if(!t)return{};let r={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(t.minZoom)&&(r.minZoom=t.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(t.maxZoom)&&(r.maxZoom=t.maxZoom),!this._explicitOptionKeys.has("extent")&&t.boundingBox&&(r.extent=[t.boundingBox[0][0],t.boundingBox[0][1],t.boundingBox[1][0],t.boundingBox[1][1]]),r}_handleTileLoad(t){let r=this._lifecycleVersion;if(this._cache.get(t.id)===t&&(this.opts.onTileLoad?.(t),this._cache.get(t.id)===t)){this._cacheByteSize=this._getCacheByteSize(),this._resizeCache(),this._updateStats();for(let n of this._listeners){if(r!==this._lifecycleVersion)return;n.onTileLoad?.(t)}}}_handleTileError(t,r){let n=this._lifecycleVersion;if(this._cache.get(r.id)===r&&(this.opts.onTileError?.(t,r),this._cache.get(r.id)===r)){this._cacheByteSize=this._getCacheByteSize(),this._resizeCache(),this._updateStats();for(let s of this._listeners){if(n!==this._lifecycleVersion)return;s.onTileError?.(t,r)}}}_handleTileUnload(t){t.abort(),this._unloadedTileCount++,this.opts.onTileUnload?.(t);for(let r of this._listeners)r.onTileUnload?.(t)}_notifyUpdate(){for(let t of this._listeners)t.onUpdate?.()}_notifyError(t){for(let r of this._listeners)r.onError?.(t)}_scheduleStatsUpdate(){this._statsUpdateScheduled||(this._statsUpdateScheduled=!0,queueMicrotask(()=>{this._statsUpdateScheduled&&this._updateStats()}))}_updateStats(){this._statsUpdateScheduled=!1,this._setStatCount("Tiles In Cache",this._cache.size),this._setStatCount("Cache Size",this.cacheByteSize),this._setStatCount("Visible Tiles",this.visibleTiles.length),this._setStatCount("Selected Tiles",this.selectedTiles.length),this._setStatCount("Loading Tiles",this.loadingTiles.length),this._setStatCount("Unloaded Tiles",this._unloadedTileCount),this._setStatCount("Consumers",this._consumers.size);for(let t of this._listeners)t.onStatsChange?.(this.stats)}_setStatCount(t,r){this.stats.get(t).reset().addCount(r)}_getSelectedTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let n of r.selectedTiles)t.add(n);return t}_getVisibleTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let n of r.visibleTiles)t.add(n);return t}_touchTile(t,r){this._cache.delete(t),this._cache.set(t,r)}_getCacheByteSize(){let t=0;for(let r of this._cache.values())t+=r.byteLength;return t}_pruneRequests(){let{maxRequests:t=0}=this.opts,r=this._getSelectedTilesUnion(),n=this._getVisibleTilesUnion(),s=[],i=0;for(let o of this._cache.values())o.isLoading&&(i++,!r.has(o)&&!n.has(o)&&s.push(o));for(;t>0&&i>t&&s.length>0;){let o=s.shift();o&&o.abort(),i--}}_rebuildTree(){for(let t of this._cache.values())t.parent=null,t.children&&(t.children.length=0);for(let t of this._cache.values()){let r=this._getNearestAncestor(t);t.parent=r,r?.children&&r.children.push(t)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((t,r)=>t.zoom-r.zoom)}_resizeCache(){let t=this.opts.maxCacheSize??100,r=this.opts.maxCacheByteSize??1/0,n=this._getVisibleTilesUnion(),s=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>r){for(let[o,a]of this._cache)if(!n.has(a)&&!s.has(a)&&(this._cache.delete(o),this._cacheByteSize-=a.byteLength,this._handleTileUnload(a)),this._cache.size<=t&&this._cacheByteSize<=r)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(t){let{_minZoom:r=0}=this,n=t.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let s=this._cache.get(this.getTileId(n));if(s)return s}return null}};function Ko(e){return e&&e.length===4?e:void 0}var se={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},ie=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.imageSource&&(!t.getImage||!t.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(t,r={}){return new e({...r,imageSource:t})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get image(){return this._currentRequest?.image||null}get currentRequest(){return this._currentRequest}get imageSource(){return this._opts.imageSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.imageSource,n=this._normalizeOptions({...this._opts,...t}),s=r!==n.imageSource||this._opts.getImage!==n.getImage||this._opts.getMetadata!==n.getMetadata;this._opts=n,s&&(this._cancelScheduledImage(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let t=await this._opts.getMetadata();if(this._finalized)return t;this.metadata=t;for(let r of this._listeners)r.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let r=Os(t,"Image metadata request failed");if(!this._finalized)for(let n of this._listeners)n.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestImage(t,r=this._opts.debounceTime){let n=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(n,t)},r):this._loadImage(n,t),n}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,r){if(!this._finalized){this._startLoading();for(let n of this._listeners)n.onImageLoadStart?.(t,r);try{let n=new AbortController;this._abortController=n;let s=await this._opts.getImage({...r,signal:n.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:r,image:s};for(let i of this._listeners)i.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(n){if(Xo(n))return;let s=Os(n,"Image request failed");if(!this._finalized)for(let i of this._listeners)i.onImageLoadError?.(t,s,r)}finally{this._abortController?.signal===r.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let r=t.imageSource||null;return{...se,...t,imageSource:r,getMetadata:t.getMetadata||(()=>r?r.getMetadata():se.getMetadata()),getImage:t.getImage||(n=>r?r.getImage(n):se.getImage(n)),debounceTime:t.debounceTime??se.debounceTime}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(t){for(let r of this._listeners)r.onLoadingStateChange?.(t)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function Xo(e){return e instanceof Error&&e.name==="AbortError"}function Os(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}Ct();var wt={getMetadata:async()=>({width:0,height:0,bandCount:0,dtype:"uint8"}),getRaster:async()=>({data:new Uint8Array(0),width:0,height:0,bandCount:0,dtype:"uint8"}),debounceTime:0,shouldRefetch:()=>!0},oe=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_metadataAbortController=null;_finalized=!1;_sourceGeneration=0;_metadataRequestId=0;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.rasterSource&&(!t.getRaster||!t.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(t,r={}){return new e({...r,rasterSource:t})}static fromCallbacks(t){return new e(t)}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get raster(){return this._currentRequest?.raster||null}get currentRequest(){return this._currentRequest}get rasterSource(){return this._opts.rasterSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.rasterSource,n={...this._opts,...t};t.rasterSource&&t.rasterSource!==r&&(n.getRaster=t.getRaster,n.getMetadata=t.getMetadata);let s=this._normalizeOptions(n),i=r!==s.rasterSource||this._opts.getRaster!==s.getRaster||this._opts.getMetadata!==s.getMetadata;this._opts=s,i&&(this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._sourceGeneration++,this.metadata=null,this._currentRequest=null,this._emitUpdate())}async loadMetadata(t={}){if(this._finalized)throw new Error("RasterSet is finalized");t.signal?.throwIfAborted(),this._metadataAbortController?.abort();let r=new AbortController;this._metadataAbortController=r;let n=()=>r.abort(t.signal?.reason);t.signal?.addEventListener("abort",n,{once:!0});let s=++this._metadataRequestId,i=this._sourceGeneration;try{this._startLoading(),r.signal.throwIfAborted();let o=await kt(a=>this._opts.getMetadata({signal:a}),[r.signal]);if(r.signal.throwIfAborted(),this._finalized||i!==this._sourceGeneration||s!==this._metadataRequestId)return o;this.metadata=o;for(let a of this._listeners)a.onMetadataLoad?.(o);return this._emitUpdate(),o}catch(o){if(r.signal.aborted)throw r.signal.reason;if(Is(o))throw o;let a=As(o,"Raster metadata request failed");if(!this._finalized&&i===this._sourceGeneration&&s===this._metadataRequestId)for(let c of this._listeners)c.onMetadataLoadError?.(a);throw a}finally{t.signal?.removeEventListener("abort",n),this._metadataAbortController===r&&(this._metadataAbortController=null),this._finishLoading()}}requestRaster(t,r=this._opts.debounceTime){if(this._finalized)return-1;if(!this.shouldRefetchRaster(t))return this._cancelScheduledRaster(),this._abortActiveRequest(),this._nextRequestId++,this._currentRequest?.requestId??-1;let n=this._nextRequestId++;return this._cancelScheduledRaster(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(n,t)},r):this._loadRaster(n,t),n}shouldRefetchRaster(t){return this._opts.shouldRefetch({currentRequest:this._currentRequest,metadata:this.metadata,nextParameters:t})}finalize(){this._finalized=!0,this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._metadataAbortController=null,this._loadCounter=0,this._listeners.clear()}async _loadRaster(t,r){if(this._finalized)return;let n=r.signal;if(n?.aborted)return;let s=new AbortController;this._abortController=s;let i=()=>s.abort(n?.reason);n?.addEventListener("abort",i,{once:!0}),this._startLoading();try{s.signal.throwIfAborted();for(let a of this._listeners)a.onRasterLoadStart?.(t,r);s.signal.throwIfAborted();let o=await kt(a=>this._opts.getRaster(Jo(r,a)),[s.signal]);if(this._finalized||s.signal.aborted||t!==this._nextRequestId-1)return;this._currentRequest={requestId:t,parameters:r,raster:o};for(let a of this._listeners)a.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(o){if(s.signal.aborted||Is(o))return;let a=As(o,"Raster request failed");if(!this._finalized&&t===this._nextRequestId-1)for(let c of this._listeners)c.onRasterLoadError?.(t,a,r)}finally{n?.removeEventListener("abort",i),this._abortController===s&&(this._abortController=null),this._finishLoading()}}_normalizeOptions(t){let r=t.rasterSource||null;return{...wt,...t,rasterSource:r,getMetadata:t.getMetadata||(n=>r?r.getMetadata(n):wt.getMetadata()),getRaster:t.getRaster||(n=>r?r.getRaster(n):wt.getRaster(n)),debounceTime:t.debounceTime??wt.debounceTime,shouldRefetch:t.shouldRefetch||(n=>wt.shouldRefetch(n))}}_emitUpdate(){if(!this._finalized)for(let t of this._listeners)t.onUpdate?.()}_emitLoadingStateChange(t){if(!this._finalized)for(let r of this._listeners)r.onLoadingStateChange?.(t)}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_cancelScheduledRaster(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function Jo(e,t){let r=Object.getOwnPropertyDescriptors(e);delete r.signal;let n=Array.isArray(e)?Object.defineProperties(e.slice(),r):Object.create(Object.getPrototypeOf(e),r);return Object.defineProperty(n,"signal",{configurable:!0,enumerable:!0,value:t,writable:!0}),n}function As(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function Is(e){return e instanceof Error&&e.name==="AbortError"}B();ee();Ft();Ct();var ae=class{item;previous;next;constructor(t,r,n){this.item=t,this.previous=r,this.next=n}};var ce=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let r=new ae(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){let n=t.next;t.next=r,this.tail===t?this.tail=r:n.previous=r,r.next=n,r.previous=t,++this._length}};var le=class{_list;_sentinel;_trimTiles;constructor(){this._list=new ce,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(t,r))}unloadTile(t,r,n){let s=r._cacheNode;s&&(this._list.remove(s),r._cacheNode=null,n&&n(t,r))}unloadTiles(t,r){let n=this._trimTiles;this._trimTiles=!1;let s=this._list,i=this._sentinel,o=s.head;for(;o!==i&&(t.gpuMemoryUsageInBytes>t.cacheBytes||n);){let a=o.item;o=o.next,this.unloadTile(t,a,r)}}trim(){this._trimTiles=!0}};ee();B();Ct();function bs(e,t){qt(e),qt(t);let{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:s,boundingVolume:{center:i}}=e,o=new z(s);switch(r&&o.translate(r),n){case"Z":break;case"Y":let u=new z().rotateX(Math.PI/2);o=o.multiplyRight(u);break;case"X":let d=new z().rotateY(-Math.PI/2);o=o.multiplyRight(d);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new x(i);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let c=k.WGS84.cartesianToCartographic(a,new x),h=k.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=h.multiplyRight(o),t.cartographicOrigin=c;let f=ta(t);f&&(t.cartesianModelMatrix=new z(o).multiplyRight(f.matrix),t.cartographicModelMatrix.multiplyRight(f.matrix),f.matrix=z.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Qo=1e6**2;function ta(e){let t=e.gltf;if(!t)return null;let r=typeof t.scene=="number"?t.scene:0,s=t.scenes?.[r]?.nodes?.[0];if(!s?.matrix)return null;let i=s.matrix;return i[12]*i[12]+i[13]*i[13]+i[14]*i[14]<=Qo?null:s}B();Ze();ee();var Ns=new x,Xe=new x,ea=1e-5,ra=1e-7,Je=new st([new G,new G,new G,new G,new G,new G]);function Ps(e,t,r={}){let{cameraUp:n,height:s}=e,i=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=Ot(e,e.center),c=k.WGS84.eastNorthUpToFixedFrame(a),l=e.unprojectPosition(e.cameraPosition),h=k.WGS84.cartographicToCartesian(l,new x),f;if(i)f=new x(c.transformAsVector(new x(i).scale(o))).normalize();else{let E=e.getFrustumPlanes().near,O=Qe(E,e.cameraPosition),I=Ot(e,O);f=new x(I).subtract(h).normalize()}let u=new x(c.transformAsVector(new x(n).scale(o))).normalize();na(e);let d=e.constructor,{longitude:m,latitude:p,width:g,bearing:T,zoom:R,position:_}=e,M=new d({longitude:m,latitude:p,height:s,width:g,bearing:T,zoom:R,position:_,pitch:0}),S=Number.isFinite(e.fovy)&&Number(e.fovy)>0&&Number(e.fovy)<180?Number(e.fovy)*Math.PI/180:Math.PI/3;return{camera:{position:h,direction:f,up:u,cartographicPosition:l,verticalFieldOfView:S,timeSinceMovement:r.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:e,topDownViewport:M,height:s,cullingVolume:Je,clippingPlanes:e.clippingPlanes,frameNumber:t,sseDenominator:2*Math.tan(S/2),dynamicScreenSpaceErrorDensity:0}}function Ls(e,t,r,n){let s=Array.from(t),i=Array.from(r),o=e?s.length!==e.position.length||s.some((l,h)=>Math.abs(l-e.position[h])>ea):!1,a=e?i.length!==e.direction.length||i.some((l,h)=>Math.abs(l-e.direction[h])>ra):!1,c=o||a?n:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:s,direction:i,lastMovementTime:c},timeSinceMovement:Math.max((n-c)/1e3,0)}}function vs(e,t,r){if(r===0||e.length<=r)return[e,[]];let n=[],{longitude:s,latitude:i}=t.viewport;for(let[l,h]of e.entries()){let[f,u]=h.header.mbs,d=Math.abs(s-f),m=Math.abs(i-u),p=Math.sqrt(m*m+d*d);n.push([l,p])}let o=n.sort((l,h)=>l[1]-h[1]),a=[];for(let l=0;l<r;l++)a.push(e[o[l][0]]);let c=[];for(let l=r;l<o.length;l++)c.push(e[o[l][0]]);return[a,c]}function na(e){let t=e.getFrustumPlanes(),r=Qe(t.near,e.cameraPosition),n=Ot(e,r),s=Ot(e,e.cameraPosition,Xe),i=0;Je.planes[i++].fromPointNormal(n,Ns.copy(n).subtract(s));for(let o in t){if(o==="near")continue;let a=t[o],c=Qe(a,r,Xe),l=Ot(e,c,Xe);Je.planes[i++].fromPointNormal(l,Ns.copy(n).subtract(l))}}function Qe(e,t,r=new x){let n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function Ot(e,t,r=new x){let n=e.unprojectPosition(t);return k.WGS84.cartographicToCartesian(n,r)}B();var ks=new x,sa=new x,at=new x,zs=new x,At=new x,Ds=new x,qs=new x,Fs=new x,he=new Mt,ia=new x(0,0,1);function Us(e,t){e._updateTransform(t)}function Bs(e,t,r){if(!Number.isFinite(r.dynamicScreenSpaceErrorDensity)||r.dynamicScreenSpaceErrorDensity<=0)return 0;let n=oa(e),s=n.region?aa(n.region,t):ca(e,n,t);if(!s)return 0;let i=gt(r.dynamicScreenSpaceErrorHeightFalloff,0,1),o=s.minimumHeight+(s.maximumHeight-s.minimumHeight)*i,a=s.maximumHeight-o,c=a>0?gt((s.cameraHeight-o)/a,0,1):s.cameraHeight>=s.maximumHeight?1:0,h=(1-gt(Math.abs(s.cameraDirection.dot(s.upDirection)),0,1))*(1-c);return r.dynamicScreenSpaceErrorDensity*h}function oa(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function aa(e,t){let r=ks.copy(t.camera.position).normalize(),n=At.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:n,upDirection:r}}function ca(e,t,r){let n=la(t,at);if(n===null)return null;let s=new z(e.computedTransform).invert(),i=e.tileset.ellipsoid;if(Math.hypot(at[0],at[1],at[2])>i.minimumRadius){let a=i.cartesianToCartographic(at,sa),c=ks.copy(r.camera.position).normalize(),l=At.copy(r.camera.direction).normalize();return{cameraHeight:r.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:l,upDirection:c}}return s.transformAsPoint(r.camera.position,zs),s.transformAsVector(r.camera.direction,At),At.normalize(),{cameraHeight:zs[2],minimumHeight:at[2]-n,maximumHeight:at[2]+n,cameraDirection:At,upDirection:ia}}function la(e,t){if(e.box){let r=e.box;return t.set(r[0],r[1],r[2]),ha(r)}if(e.sphere){let r=e.sphere;return t.set(r[0],r[1],r[2]),r[3]}return null}function ha(e){return e.length===10?(he.fromArray(e,6),Ds.set(e[3],0,0).transformByQuaternion(he),qs.set(0,e[4],0).transformByQuaternion(he),Fs.set(0,0,e[5]).transformByQuaternion(he),Math.abs(Ds[2])+Math.abs(qs[2])+Math.abs(Fs[2])):Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11])}B();Ze();var tr;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(tr||(tr={}));var It;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(It||(It={}));var J;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(J||(J={}));var bt;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(bt||(bt={}));var mh=new yt,ph=new x,xh=new x,gh=new x,Th=new x;function Gs(e,t,r){return e+(t-e)*r}Me();Me();var Vs="EPSG:4326",Ws="EPSG:4978";function Ys(e){let t=e.trim().toUpperCase(),r=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return r?`${r[1]}:${r[2]}`:t}function fe(e){if(typeof e=="string"){let r=ot(e);return r==="wkt"?ua(e):r==="proj-string"?da(e):fa(e)||"projected"}let t=e;return t.type==="BoundCRS"&&t.source_crs?fe(t.source_crs):t.type==="CompoundCRS"&&t.components?.[0]?fe(t.components[0]):String(t.type).includes("Projected")?"projected":String(t.type).includes("Geographic")?"geographic":String(t.type).includes("Geodetic")?t.coordinate_system?.subtype==="Cartesian"?"geocentric":"geographic":"unknown"}function fa(e){if(typeof e!="string")return;let t=Ys(e);if(t===Ws)return"geocentric";if(t===Vs||t==="OGC:CRS84")return"geographic";let r=/^EPSG:(\d+)$/.exec(t);if(!r)return;let n=Number(r[1]);if(n===7789)return"geocentric";if(n===4490||n===4979)return"geographic";if(n===3857||n>=32601&&n<=32660||n>=32701&&n<=32760)return"projected"}function ua(e){let t;try{t=Se(e).root}catch{return"unknown"}switch(t.keyword.toUpperCase()){case"GEOCCS":return"geocentric";case"GEOGCS":case"GEOGCRS":case"GEOGRAPHICCRS":case"GEOGRAPHIC2DCRS":case"GEOGRAPHIC3DCRS":return"geographic";case"PROJCS":case"PROJCRS":case"PROJECTEDCRS":return"projected";case"GEODCRS":case"GEODETICCRS":{let n=t.values.find(s=>s.type==="node"&&s.keyword.toUpperCase()==="CS")?.values[0];return n?.type!=="enumeration"&&n?.type!=="string"?"unknown":n.value.toUpperCase()==="CARTESIAN"?"geocentric":n.value.toUpperCase()==="ELLIPSOIDAL"?"geographic":"unknown"}default:return"unknown"}}function da(e){try{let t=_e(e).parameters.find(r=>r.name.toLowerCase()==="proj")?.value;switch(t?.toLowerCase()){case"longlat":case"latlong":return"geographic";case"geocent":return"geocentric";default:return t?"projected":"unknown"}}catch{return"unknown"}}function rr(e,t={}){let r=t.sourceCrs!==void 0,n=t.sourceCrs||e.sourceCrs,s=t.outputCoordinates||"auto",i=t.targetCrs||(s==="ecef"?"EPSG:4978":void 0),o=t.targetHeightReference||"native",a=e.verticalUnitScale??1,c=e.elevationUnitScale??1,l=e.elevationOffset||0,h=e.elevationMode==="onTheGround"||e.elevationMode==="relativeToGround"||e.elevationMode==="relativeToScene",f=e.elevationMode==="relativeToScene"?!!t.sceneElevationProvider:!h||!!t.terrainElevationProvider,u=a!==1||c!==1||e.elevationMode!==void 0&&(h||e.elevationMode==="absoluteHeight"&&l!==0),d=o!=="native"&&o!==e.heightReference,m=!!i||o!=="native"||s!=="auto"||u,p=s!=="target-crs"||!!i,g=!d||(e.heightReference||"unknown")!=="unknown",T=Number.isFinite(a)&&a>0&&Number.isFinite(c)&&c>0,R=!!n&&m&&p&&g&&T&&f&&s!=="local-enu",_=r?"caller-override":e.provenance||"unknown",M=r&&n?fe(n):e.coordinateFrame,S=r?"explicit":e.sourceCrsState||(n?_==="format-default"?"default":"explicit":"absent"),E=Ut({crs:n?{state:S==="default"?"default":"explicit",definition:n,representation:!r&&e.sourceCrsRepresentation||ot(n),provenance:_,alternatives:r?void 0:e.sourceCrsAlternatives}:{state:S==="unknown"?"unknown":"absent",provenance:_},vertical:e.verticalCrs?{state:"explicit",definition:e.verticalCrs,representation:ot(e.verticalCrs),provenance:e.provenance||"metadata"}:void 0,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,coordinateFrame:M,coordinateOrder:pa(e.axisOrder),units:r?void 0:e.units}),O=er(E.crs),I=E.vertical?er(E.vertical):void 0,w=i?ma(i):void 0;return Object.freeze({...E,sourceCrs:O,verticalCrs:I,verticalUnitScale:a,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,heightReference:e.heightReference||"unknown",elevationMode:e.elevationMode,elevationOffset:e.elevationOffset,elevationUnit:e.elevationUnit,elevationUnitScale:c,coordinateFrame:M||"unknown",axisOrder:e.axisOrder||"unknown",provenance:_,targetCrs:w,targetHeightReference:o,outputCoordinates:s,status:m?R?"transformable":"unresolved":"native",warnings:Object.freeze([...e.warnings||[]])})}function nr(e,t={}){return rr({sourceCrs:e?.sourceCrs,sourceCrsState:e?.crs.state,sourceCrsRepresentation:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.representation:void 0,sourceCrsAlternatives:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.alternatives:void 0,verticalCrs:e?.verticalCrs,units:e?.units,verticalUnitScale:e?.verticalUnitScale,coordinateEpoch:e?.coordinateEpoch,heightReference:e?.heightReference,elevationMode:e?.elevationMode,elevationOffset:e?.elevationOffset,elevationUnit:e?.elevationUnit,elevationUnitScale:e?.elevationUnitScale,coordinateFrame:e?.coordinateFrame,axisOrder:e?.axisOrder,provenance:e?.provenance,warnings:e?.warnings},t)}function er(e){return e.state==="explicit"||e.state==="default"?e.definition:void 0}function ma(e){let t=Ut({crs:{state:"explicit",definition:e,representation:ot(e),provenance:"caller-override"}}),r=er(t.crs);if(!r)throw new Error("Failed to normalize a known target CRS definition");return r}function pa(e){switch(e){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function $s(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var de=1024*1024,ri=512*de,ni=512*de,xa=32*de,ga=de;function ue(e,t){if(!Number.isFinite(e)||e<0)throw new Error(`${t} must be a finite number greater than or equal to 0`);return e}function Zs(e,t){let r=e.cacheBytes??t;return ue(r,"cacheBytes")}function js(e,t){let r=e.maximumCacheOverflowBytes??t;return ue(r,"maximumCacheOverflowBytes")}var sr={description:"",ellipsoid:k.WGS84,modelMatrix:new z,throttleRequests:!0,maxRequests:64,cacheBytes:ri,maximumCacheOverflowBytes:ni,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onSourceError:()=>{},onTilesetError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,progressiveResolutionHeightFraction:.3,foveatedScreenSpaceError:!0,foveatedConeSize:.1,foveatedMinimumScreenSpaceErrorRelaxation:0,foveatedInterpolationCallback:Gs,foveatedTimeDelay:.2,maximumScreenSpaceError:8,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:2e-4,dynamicScreenSpaceErrorFactor:24,dynamicScreenSpaceErrorHeightFalloff:.25,memoryAdjustedScreenSpaceError:!0,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{},spatial:{}},ir="Tiles In Tileset(s)",or="Tiles In Memory",Hs="Tiles In View",Ks="Tiles To Render",Xs="Tiles Loaded",ar="Tiles Loading",Js="Tiles Unloaded",Qs="Failed Tile Loads",ti="Points/Vertices",cr="Tile Memory Use",ei="Maximum Screen Space Error",Nt=class{options;loadOptions;source;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};schema=null;schemaUri=null;groups=[];metadata=null;statistics=null;spatialReference=rr({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=ri;_maximumCacheOverflowBytes=ni;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new le;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(t,r){if(!$s(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let n=r||{},s=t.type===J.TILES3D,i=s?sr.cacheBytes:xa,o=s?sr.maximumCacheOverflowBytes:ga,a=Zs(n,i),c=js(n,o);this.options={...sr,...n,cacheBytes:a,maximumCacheOverflowBytes:c,skipLevelOfDetail:n.skipLevelOfDetail??t.type===J.TILES3D,memoryAdjustedScreenSpaceError:n.memoryAdjustedScreenSpaceError??s},this.loadOptions=this.options.loadOptions||{},this.source=t,this.tileset=null,this.loader=this.source.loader,this.type=this.source.type,this.url=this.source.url,this.basePath=this.source.basePath,this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType="",this.lodMetricValue=0,this.refine="",this.contentFormats=this.source.contentFormats,this._traverser=this._initializeTraverser(),this._requestScheduler=new j({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=a,this._maximumCacheOverflowBytes=c;let l=this._getSourceMetadata();l&&(this.spatialReference=nr(l.spatialReference,this.options.spatial)),this.stats=new W({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet()}destroy(){this._clearDeferredTraversal(),this.source.destroy?.(),this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get requestedTiles(){return this._requestedTiles.slice()}get emptyTiles(){return this._emptyTiles.slice()}get cacheBytes(){return this._cacheBytes}set cacheBytes(t){this._cacheBytes=ue(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=ue(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes}get queryParams(){let t=this.source.getTileUrl(this.url),r=t.indexOf("?");return r>=0?t.slice(r+1):""}setProps(t){let r=Zs(t,this.cacheBytes),n=js(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:r,maximumCacheOverflowBytes:n},this._cacheBytes=r,this._maximumCacheOverflowBytes=n}getTileUrl(t){return this.source.getTileUrl(t)}hasExtension(t){return!!this.source.hasExtension?.(t)}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this.cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this.cacheBytes+this.maximumCacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=t instanceof Array?t:[t],n=new Set(r.map(a=>a.id));for(let a of Object.keys(this.frameStateData))n.has(a)||delete this.frameStateData[a];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let s=Date.now(),i=Number.POSITIVE_INFINITY,o=[];for(let a of r){let c=a.id;this._needTraverse(c)?o.push(c):this.traverseCounter--}for(let a of r){let c=a.id;if(this.roots[c]||(this.roots[c]=this._initializeTileHeaders(this.tileset,null)),!o.includes(c))continue;let l=Ps(a,this._frameNumber),h=this.roots[c],f=Ls(this._cameraMotionStates[c],l.camera.position,l.camera.direction,s);this._cameraMotionStates[c]=f.state,l.camera.timeSinceMovement=f.timeSinceMovement,Us(h,this.modelMatrix),l.dynamicScreenSpaceErrorDensity=this.type===J.TILES3D&&this.options.dynamicScreenSpaceError&&!l.viewport.orthographic?Bs(h,l,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=l.dynamicScreenSpaceErrorDensity,this._traverser.traverse(h,l,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(i=Math.min(i,Math.max(this.options.foveatedTimeDelay-f.timeSinceMovement,0)))}Number.isFinite(i)?this._scheduleDeferredTraversal(i):this._clearDeferredTraversal()}_scheduleDeferredTraversal(t){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(r=>{let n=r instanceof Error?r:new Error(String(r));this._onTilesetError(n)})},Math.max(t*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){let r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],s=Object.values(this._traverser.selectedTiles),[i,o]=vs(s,t,this.options.maximumTilesSelected);n.selectedTiles=i;for(let a of o)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let t=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let i in this.frameStateData){let o=this.frameStateData[i];this.selectedTiles=this.selectedTiles.concat(o.selectedTiles),this._requestedTiles=this._requestedTiles.concat(o._requestedTiles),this._emptyTiles=this._emptyTiles.concat(o._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles),n=this.selectedTiles.some(i=>!i.tileDrawn),s=0;if(n){let i=new Set(Object.keys(this.frameStateData).map(a=>this.roots[a])),o=new Map;for(let a of this.selectedTiles)for(let c=a.parent;c;c=c.parent)o.set(c,(o.get(c)??!0)&&a.tileDrawn);for(let a of t)a.tileDrawn&&this._heldTiles.add(a);for(let a of this._heldTiles){let c=a;for(;c.parent;)c=c.parent;if(!i.has(c)){this._heldTiles.delete(a);continue}r.has(a)||(a.contentAvailable&&!this._hasDrawnReplacement(a,r,o)?(a._selectedFrame=this._frameNumber,this.selectedTiles.push(a),s++):this._heldTiles.delete(a))}}else this._heldTiles=r;s>0&&setTimeout(()=>{this.selectTiles()},0);for(let i of this.selectedTiles)this._tiles[i.id]=i;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(t,this.selectedTiles)&&this.options.onUpdate()}_hasDrawnReplacement(t,r,n){for(let s=t.parent;s;s=s.parent)if(r.has(s))return s.tileDrawn;return n.get(t)===!0}_tilesChanged(t,r){if(t.length!==r.length)return!0;let n=new Set(t.map(o=>o.id)),s=new Set(r.map(o=>o.id)),i=t.some(o=>!s.has(o.id));return i=i||r.some(o=>!n.has(o.id)),i}_loadTiles(){this._requestedTiles.sort((t,r)=>t._priority-r._priority);for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let t=0,r=0;for(let n of this.selectedTiles)if(n.contentAvailable&&n.content){t++;let s=n.contents.length?n.contents:[n.content];for(let i of s)i.pointCount?r+=i.pointCount:r+=i.vertexCount||0}this.stats.get(Hs).count=this.selectedTiles.length,this.stats.get(Ks).count=t,this.stats.get(ti).count=r,this.stats.get(ei).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let t=this.source.initialize(),r=this._getSourceMetadata();r&&this._syncSourceState(r),r?.tileset?.root&&typeof r.tileset.root.then!="function"&&(!this.source.prepareTileset||this.spatialReference?.status==="native")&&(this.root=this._initializeTileHeaders(r.tileset,null),this._applyViewState()),await t;let n=this.source.getMetadata();this._syncSourceState(n),await this.source.prepareTileset?.(this),this.root||(this.root=this._initializeTileHeaders(n.tileset,null)),this._applyViewState()}catch(t){let r=t instanceof Error?t:new Error(String(t));throw this._onSourceError(r,this.root),this._onTilesetError(r),r}}_initializeStats(){this.stats.get(ir),this.stats.get(ar),this.stats.get(or),this.stats.get(Hs),this.stats.get(Ks),this.stats.get(Xs),this.stats.get(Js),this.stats.get(Qs),this.stats.get(ti),this.stats.get(cr,"memory"),this.stats.get(ei)}_initializeTileHeaders(t,r){return this.source.initializeTileHeaders(this,t,r)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r=null;try{this._onStartTileLoading(),r=await t.loadContent()}catch(n){let s=n instanceof Error?n:new Error("load failed");this._onSourceError(s,t),this._onTileLoadError(t,s)}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}async _loadTileChildren(t,r){try{this._onStartTileLoading(),await t.loadChildren(r)}catch(n){let s=n instanceof Error?n:new Error("subtree load failed");this._onSourceError(s,t),this._onTileLoadError(t,s)}finally{this._onEndTileLoading()}}_onTileLoadError(t,r){this.stats.get(Qs).incrementCount();let n=r.message||r.toString(),s=t.url;console.error(`A 3D tile failed to load: ${t.url} ${n}`),this.options.onTileError(t,n,s)}_onSourceError(t,r=null){this.options.onSourceError(t,this.source,r)}_onTilesetError(t){this.options.onTilesetError(t,this)}_onTileLoad(t,r){if(!r?.loaded)return;t.content&&bs(t,t.content),this.source.onTileLoaded?.(this,t,r),this._syncSourceState(this.source.getMetadata());let n=this.source.getTilesTotalCount?.();n&&(this.stats.get(ir).reset(),this.stats.get(ir).addCount(n)),this._addTileToCache(t),this.options.onTileLoad(t)}_onStartTileLoading(){this._pendingCount++,this.stats.get(ar).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(ar).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(Xs).incrementCount(),this.stats.get(or).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(cr).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(or).decrementCount(),this.stats.get(Js).incrementCount(),this.stats.get(cr).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let r=t.pop();for(let n of r.children)t.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(t){let r=t,n=[r];for(;n.length>0;){t=n.pop();for(let s of t.children)n.push(s);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_syncSourceState(t){this.tileset=t.tileset,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset;let r=t.tileset;this.schema=r.schema||null,this.schemaUri=r.schemaUri||null,this.groups=r.groups||[],this.metadata=r.metadata||null,this.statistics=r.statistics??null;let n=nr(t.spatialReference,this.options.spatial);this.spatialReference=Ta(this.spatialReference,n),this.properties=this.source.properties??this.properties,this.extras=this.source.extras??this.extras,this.options.attributions?.length?this.credits={attributions:this.options.attributions}:this.credits=this.source.credits||this.credits}_applyViewState(){let t=this.source.getViewState(this.root);this.asset=t.asset||this.source.asset||{},this.properties=t.properties??this.source.properties,this.extras=t.extras??this.source.extras??null,this.credits=t.credits||this.source.credits||this.credits||{attributions:this.options.attributions||[]},this.description=t.description||this.options.description||"",this.boundingVolume=t.boundingVolume||this.root?.boundingVolume||null,this.cartographicCenter=t.cartographicCenter||new x,this.cartesianCenter=t.cartesianCenter||null,this.zoom=t.zoom||1,this.geometricError=this.tileset?.geometricError||0}_getSourceMetadata(){try{return this.source.getMetadata()}catch{return null}}};function Ta(e,t){return e?.status==="transformed"&&e.sourceCrs===t.sourceCrs&&e.targetCrs===t.targetCrs&&e.targetHeightReference===t.targetHeightReference&&e.outputCoordinates===t.outputCoordinates?e:t}ys();function si(e,t,r={}){let n=e.tileMatrixSet;if(!n||!n.crs||t.crs!==n.crs)throw new Error("Tile selection requires complete geometry and a frame in the exact grid CRS.");if(t.extent.length!==4||!t.extent.every(Number.isFinite)||t.extent[0]>t.extent[2]||t.extent[1]>t.extent[3])throw new RangeError("Tile frame extent must be finite and ordered.");let s=r.maximumTileCount??4096;if(!Number.isSafeInteger(s)||s<0)throw new RangeError("maximumTileCount must be a nonnegative safe integer.");for(let u of n.matrices){let d=u.variableMatrixWidths;if(d!==void 0&&(!Array.isArray(d)||d.length>0))throw new Error("Regular-grid selection does not support variable-width rows.")}let i=Rs(n,t.resolution),o=new Map;for(let u of e.limits??[]){let d=n.matrices.find(m=>m.id===u.tileMatrix);if(!d||o.has(u.tileMatrix))throw new RangeError("Tile coverage must reference unique, known matrix ids.");Ke(d,u.minTileColumn,u.minTileRow,u),o.set(u.tileMatrix,u)}if(!i||e.limits!==void 0&&!o.has(i.id))return[];let a=Es(i,t.extent,o.get(i.id));if(!a)return[];let c=a.maxTileColumn-a.minTileColumn+1,l=a.maxTileRow-a.minTileRow+1;if(c>s/l)throw new RangeError("Tile selection exceeds maximumTileCount.");let h=n.matrices.indexOf(i),f=[];for(let u=a.minTileRow;u<=a.maxTileRow;u++)for(let d=a.minTileColumn;d<=a.maxTileColumn;d++){let[m,p,g,T]=_s(i,d,u);f.push({index:{x:d,y:u,z:h},tileMatrix:i.id,id:JSON.stringify([n.crs,i.id,d,u]),bbox:{left:m,bottom:p,right:g,top:T},crs:n.crs,tileSize:[i.tileSize[0],i.tileSize[1]]})}return f}return ui(Pt);})();
10
10
  return __exports__;
11
11
  });