@needle-tools/engine 4.7.1 → 4.7.2-alpha

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 (1072) hide show
  1. package/CHANGELOG.md +3782 -3782
  2. package/LICENSE.md +10 -10
  3. package/README.md +64 -64
  4. package/components.needle.json +1 -1
  5. package/dist/generateMeshBVH.worker-Cdfpaq5W.js +25 -0
  6. package/dist/gltf-progressive-YjtQYFa9.js +1052 -0
  7. package/dist/gltf-progressive-yOP1mp5W.min.js +8 -0
  8. package/dist/gltf-progressive-zdhlW609.umd.cjs +8 -0
  9. package/dist/{needle-engine.bundle-CN9UC6Ju.min.js → needle-engine.bundle-BhDF-YSv.min.js} +65 -65
  10. package/dist/{needle-engine.bundle-B7M9iBIa.umd.cjs → needle-engine.bundle-D2myV4E4.umd.cjs} +61 -61
  11. package/dist/{needle-engine.bundle-BpCihhaP.js → needle-engine.bundle-gp00DTS4.js} +641 -641
  12. package/dist/needle-engine.d.ts +129 -130
  13. package/dist/needle-engine.js +4 -4
  14. package/dist/needle-engine.min.js +1 -1
  15. package/dist/needle-engine.umd.cjs +1 -1
  16. package/dist/{postprocessing-CjW23fio.umd.cjs → postprocessing-8AQTeZsr.umd.cjs} +2 -2
  17. package/dist/{postprocessing-xYQWCHFu.min.js → postprocessing-BDScN9yu.min.js} +2 -2
  18. package/dist/{postprocessing-DYLNOL3W.js → postprocessing-BkxN_08g.js} +3 -3
  19. package/dist/{three-DuDKwKB8.min.js → three-Boa-jOq-.min.js} +33 -33
  20. package/dist/{three-DrqIzZTH.js → three-Bz6X1mrw.js} +4198 -4198
  21. package/dist/{three-B_hneGZr.umd.cjs → three-DMrv-4ar.umd.cjs} +4 -4
  22. package/dist/{three-examples-X3OadjXB.umd.cjs → three-examples-C7ryg8vN.umd.cjs} +3 -3
  23. package/dist/{three-examples-DaDLBuy6.min.js → three-examples-DuVhxqft.min.js} +14 -14
  24. package/dist/{three-examples-B50TT3Iu.js → three-examples-GggCDHv0.js} +5 -5
  25. package/dist/{three-mesh-ui-CxuWt7m-.js → three-mesh-ui-CLNOfsWn.js} +1 -1
  26. package/dist/{three-mesh-ui-B3p3gyUz.min.js → three-mesh-ui-CY6Izc7C.min.js} +1 -1
  27. package/dist/{three-mesh-ui-CQiIQIlA.umd.cjs → three-mesh-ui-CwlN0FUC.umd.cjs} +1 -1
  28. package/dist/{vendor-BmYIgaS1.js → vendor-BSD1RQIh.js} +3 -3
  29. package/dist/{vendor-Cavtu3CP.umd.cjs → vendor-DHr4aqIZ.umd.cjs} +3 -3
  30. package/dist/{vendor-BlSxe9JJ.min.js → vendor-zxXa3Dmr.min.js} +3 -3
  31. package/lib/asap/needle-asap.d.ts +1 -1
  32. package/lib/asap/needle-asap.js +95 -95
  33. package/lib/asap/sessiongranted.d.ts +3 -3
  34. package/lib/asap/sessiongranted.js +65 -65
  35. package/lib/asap/utils.d.ts +1 -1
  36. package/lib/asap/utils.js +3 -3
  37. package/lib/engine/analytics/index.d.ts +6 -6
  38. package/lib/engine/analytics/index.js +12 -12
  39. package/lib/engine/analytics/lcp.d.ts +3 -3
  40. package/lib/engine/analytics/lcp.js +34 -34
  41. package/lib/engine/api.d.ts +82 -82
  42. package/lib/engine/api.js +81 -81
  43. package/lib/engine/assets/index.d.ts +11 -11
  44. package/lib/engine/assets/index.js +47 -47
  45. package/lib/engine/assets/static.d.ts +1 -1
  46. package/lib/engine/assets/static.js +4 -4
  47. package/lib/engine/codegen/register_types.d.ts +1 -1
  48. package/lib/engine/codegen/register_types.js +300 -300
  49. package/lib/engine/debug/debug.d.ts +15 -15
  50. package/lib/engine/debug/debug.js +44 -44
  51. package/lib/engine/debug/debug_console.d.ts +2 -2
  52. package/lib/engine/debug/debug_console.js +307 -307
  53. package/lib/engine/debug/debug_overlay.d.ts +22 -22
  54. package/lib/engine/debug/debug_overlay.js +316 -316
  55. package/lib/engine/debug/debug_spatial_console.d.ts +2 -2
  56. package/lib/engine/debug/debug_spatial_console.js +390 -390
  57. package/lib/engine/debug/index.d.ts +2 -2
  58. package/lib/engine/debug/index.js +2 -2
  59. package/lib/engine/engine_addressables.d.ts +164 -164
  60. package/lib/engine/engine_addressables.js +601 -601
  61. package/lib/engine/engine_animation.d.ts +43 -43
  62. package/lib/engine/engine_animation.js +133 -133
  63. package/lib/engine/engine_application.d.ts +45 -45
  64. package/lib/engine/engine_application.js +104 -104
  65. package/lib/engine/engine_assetdatabase.d.ts +25 -25
  66. package/lib/engine/engine_assetdatabase.js +346 -346
  67. package/lib/engine/engine_audio.d.ts +4 -4
  68. package/lib/engine/engine_audio.js +23 -23
  69. package/lib/engine/engine_camera.d.ts +13 -13
  70. package/lib/engine/engine_camera.js +30 -30
  71. package/lib/engine/engine_components.d.ts +110 -110
  72. package/lib/engine/engine_components.js +374 -374
  73. package/lib/engine/engine_components_internal.d.ts +9 -9
  74. package/lib/engine/engine_components_internal.js +36 -36
  75. package/lib/engine/engine_constants.d.ts +10 -10
  76. package/lib/engine/engine_constants.js +41 -41
  77. package/lib/engine/engine_context.d.ts +475 -475
  78. package/lib/engine/engine_context.js +1673 -1673
  79. package/lib/engine/engine_context_registry.d.ts +71 -71
  80. package/lib/engine/engine_context_registry.js +117 -117
  81. package/lib/engine/engine_coroutine.d.ts +35 -35
  82. package/lib/engine/engine_coroutine.js +52 -52
  83. package/lib/engine/engine_create_objects.d.ts +119 -119
  84. package/lib/engine/engine_create_objects.js +320 -320
  85. package/lib/engine/engine_default_parameters.d.ts +2 -2
  86. package/lib/engine/engine_default_parameters.js +3 -3
  87. package/lib/engine/engine_editor-sync.d.ts +21 -21
  88. package/lib/engine/engine_editor-sync.js +4 -4
  89. package/lib/engine/engine_fileloader.d.ts +2 -2
  90. package/lib/engine/engine_fileloader.js +8 -8
  91. package/lib/engine/engine_gameobject.d.ts +68 -68
  92. package/lib/engine/engine_gameobject.js +619 -619
  93. package/lib/engine/engine_generic_utils.d.ts +1 -1
  94. package/lib/engine/engine_generic_utils.js +13 -13
  95. package/lib/engine/engine_gizmos.d.ts +149 -149
  96. package/lib/engine/engine_gizmos.js +530 -530
  97. package/lib/engine/engine_gltf.d.ts +12 -12
  98. package/lib/engine/engine_gltf.js +15 -15
  99. package/lib/engine/engine_gltf_builtin_components.d.ts +11 -11
  100. package/lib/engine/engine_gltf_builtin_components.js +341 -341
  101. package/lib/engine/engine_hot_reload.d.ts +8 -8
  102. package/lib/engine/engine_hot_reload.js +197 -197
  103. package/lib/engine/engine_input.d.ts +362 -362
  104. package/lib/engine/engine_input.js +1294 -1294
  105. package/lib/engine/engine_input_utils.d.ts +2 -2
  106. package/lib/engine/engine_input_utils.js +22 -22
  107. package/lib/engine/engine_instancing.d.ts +19 -19
  108. package/lib/engine/engine_instancing.js +39 -39
  109. package/lib/engine/engine_license.d.ts +11 -11
  110. package/lib/engine/engine_license.js +369 -369
  111. package/lib/engine/engine_lifecycle_api.d.ts +83 -83
  112. package/lib/engine/engine_lifecycle_api.js +106 -106
  113. package/lib/engine/engine_lifecycle_functions_internal.d.ts +32 -32
  114. package/lib/engine/engine_lifecycle_functions_internal.js +146 -146
  115. package/lib/engine/engine_lightdata.d.ts +23 -23
  116. package/lib/engine/engine_lightdata.js +101 -101
  117. package/lib/engine/engine_loaders.callbacks.d.ts +97 -97
  118. package/lib/engine/engine_loaders.callbacks.js +86 -86
  119. package/lib/engine/engine_loaders.d.ts +48 -48
  120. package/lib/engine/engine_loaders.gltf.d.ts +13 -13
  121. package/lib/engine/engine_loaders.gltf.js +62 -62
  122. package/lib/engine/engine_loaders.js +337 -337
  123. package/lib/engine/engine_lods.d.ts +35 -35
  124. package/lib/engine/engine_lods.js +160 -160
  125. package/lib/engine/engine_lods.js.map +1 -1
  126. package/lib/engine/engine_mainloop_utils.d.ts +32 -32
  127. package/lib/engine/engine_mainloop_utils.js +466 -466
  128. package/lib/engine/engine_math.d.ts +114 -114
  129. package/lib/engine/engine_math.js +247 -247
  130. package/lib/engine/engine_modules.d.ts +36 -36
  131. package/lib/engine/engine_modules.js +85 -85
  132. package/lib/engine/engine_networking.d.ts +260 -260
  133. package/lib/engine/engine_networking.js +764 -764
  134. package/lib/engine/engine_networking_auto.d.ts +24 -24
  135. package/lib/engine/engine_networking_auto.js +310 -310
  136. package/lib/engine/engine_networking_blob.d.ts +48 -48
  137. package/lib/engine/engine_networking_blob.js +228 -228
  138. package/lib/engine/engine_networking_files.d.ts +35 -35
  139. package/lib/engine/engine_networking_files.js +172 -172
  140. package/lib/engine/engine_networking_files_default_components.d.ts +6 -6
  141. package/lib/engine/engine_networking_files_default_components.js +42 -42
  142. package/lib/engine/engine_networking_instantiate.d.ts +100 -100
  143. package/lib/engine/engine_networking_instantiate.js +345 -345
  144. package/lib/engine/engine_networking_peer.d.ts +15 -15
  145. package/lib/engine/engine_networking_peer.js +132 -132
  146. package/lib/engine/engine_networking_streams.d.ts +123 -123
  147. package/lib/engine/engine_networking_streams.js +645 -645
  148. package/lib/engine/engine_networking_types.d.ts +22 -22
  149. package/lib/engine/engine_networking_types.js +7 -7
  150. package/lib/engine/engine_networking_utils.d.ts +2 -2
  151. package/lib/engine/engine_networking_utils.js +20 -20
  152. package/lib/engine/engine_networking_websocket.d.ts +1 -1
  153. package/lib/engine/engine_networking_websocket.js +2 -2
  154. package/lib/engine/engine_patcher.d.ts +10 -10
  155. package/lib/engine/engine_patcher.js +142 -142
  156. package/lib/engine/engine_physics.d.ts +152 -152
  157. package/lib/engine/engine_physics.js +645 -645
  158. package/lib/engine/engine_physics.types.d.ts +40 -40
  159. package/lib/engine/engine_physics.types.js +33 -33
  160. package/lib/engine/engine_physics_rapier.d.ts +147 -147
  161. package/lib/engine/engine_physics_rapier.js +1433 -1433
  162. package/lib/engine/engine_playerview.d.ts +26 -26
  163. package/lib/engine/engine_playerview.js +64 -64
  164. package/lib/engine/engine_scenelighting.d.ts +71 -71
  165. package/lib/engine/engine_scenelighting.js +226 -226
  166. package/lib/engine/engine_serialization.d.ts +3 -3
  167. package/lib/engine/engine_serialization.js +3 -3
  168. package/lib/engine/engine_serialization_builtin_serializer.d.ts +72 -72
  169. package/lib/engine/engine_serialization_builtin_serializer.js +403 -403
  170. package/lib/engine/engine_serialization_core.d.ts +94 -94
  171. package/lib/engine/engine_serialization_core.js +607 -607
  172. package/lib/engine/engine_serialization_decorator.d.ts +23 -23
  173. package/lib/engine/engine_serialization_decorator.js +66 -66
  174. package/lib/engine/engine_setup.d.ts +1 -1
  175. package/lib/engine/engine_setup.js +2 -2
  176. package/lib/engine/engine_shaders.d.ts +53 -53
  177. package/lib/engine/engine_shaders.js +252 -252
  178. package/lib/engine/engine_shims.d.ts +4 -4
  179. package/lib/engine/engine_shims.js +24 -24
  180. package/lib/engine/engine_test_utils.d.ts +39 -39
  181. package/lib/engine/engine_test_utils.js +83 -83
  182. package/lib/engine/engine_texture.d.ts +28 -28
  183. package/lib/engine/engine_texture.js +64 -64
  184. package/lib/engine/engine_three_utils.d.ts +204 -204
  185. package/lib/engine/engine_three_utils.js +788 -788
  186. package/lib/engine/engine_time.d.ts +51 -51
  187. package/lib/engine/engine_time.js +82 -82
  188. package/lib/engine/engine_time_utils.d.ts +88 -88
  189. package/lib/engine/engine_time_utils.js +215 -215
  190. package/lib/engine/engine_tonemapping.d.ts +6 -6
  191. package/lib/engine/engine_tonemapping.js +197 -197
  192. package/lib/engine/engine_types.d.ts +578 -578
  193. package/lib/engine/engine_types.js +95 -95
  194. package/lib/engine/engine_typestore.d.ts +28 -28
  195. package/lib/engine/engine_typestore.js +55 -55
  196. package/lib/engine/engine_util_decorator.d.ts +13 -13
  197. package/lib/engine/engine_util_decorator.js +116 -116
  198. package/lib/engine/engine_utils.d.ts +248 -248
  199. package/lib/engine/engine_utils.js +1012 -1012
  200. package/lib/engine/engine_utils_format.d.ts +24 -24
  201. package/lib/engine/engine_utils_format.js +239 -239
  202. package/lib/engine/engine_utils_screenshot.d.ts +159 -159
  203. package/lib/engine/engine_utils_screenshot.js +522 -522
  204. package/lib/engine/engine_utils_screenshot.xr.d.ts +5 -5
  205. package/lib/engine/engine_utils_screenshot.xr.js +90 -90
  206. package/lib/engine/engine_xr.d.ts +1 -1
  207. package/lib/engine/engine_xr.js +1 -1
  208. package/lib/engine/export/gltf/Writers.d.ts +19 -19
  209. package/lib/engine/export/gltf/Writers.js +24 -24
  210. package/lib/engine/export/gltf/index.d.ts +11 -11
  211. package/lib/engine/export/gltf/index.js +123 -123
  212. package/lib/engine/export/index.d.ts +2 -2
  213. package/lib/engine/export/index.js +2 -2
  214. package/lib/engine/export/state.d.ts +7 -7
  215. package/lib/engine/export/state.js +17 -17
  216. package/lib/engine/export/utils.d.ts +2 -2
  217. package/lib/engine/export/utils.js +7 -7
  218. package/lib/engine/extensions/EXT_texture_exr.d.ts +8 -8
  219. package/lib/engine/extensions/EXT_texture_exr.js +32 -32
  220. package/lib/engine/extensions/NEEDLE_animator_controller_model.d.ts +122 -122
  221. package/lib/engine/extensions/NEEDLE_animator_controller_model.js +95 -95
  222. package/lib/engine/extensions/NEEDLE_components.d.ts +35 -35
  223. package/lib/engine/extensions/NEEDLE_components.js +220 -220
  224. package/lib/engine/extensions/NEEDLE_gameobject_data.d.ts +10 -10
  225. package/lib/engine/extensions/NEEDLE_gameobject_data.js +57 -57
  226. package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +37 -37
  227. package/lib/engine/extensions/NEEDLE_lighting_settings.js +157 -157
  228. package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +18 -18
  229. package/lib/engine/extensions/NEEDLE_lightmaps.js +99 -99
  230. package/lib/engine/extensions/NEEDLE_persistent_assets.d.ts +11 -11
  231. package/lib/engine/extensions/NEEDLE_persistent_assets.js +63 -63
  232. package/lib/engine/extensions/NEEDLE_progressive.d.ts +1 -1
  233. package/lib/engine/extensions/NEEDLE_progressive.js +1 -1
  234. package/lib/engine/extensions/NEEDLE_render_objects.d.ts +13 -13
  235. package/lib/engine/extensions/NEEDLE_render_objects.js +159 -159
  236. package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +38 -38
  237. package/lib/engine/extensions/NEEDLE_techniques_webgl.js +564 -564
  238. package/lib/engine/extensions/extension_resolver.d.ts +4 -4
  239. package/lib/engine/extensions/extension_resolver.js +1 -1
  240. package/lib/engine/extensions/extension_utils.d.ts +12 -12
  241. package/lib/engine/extensions/extension_utils.js +152 -152
  242. package/lib/engine/extensions/extensions.d.ts +32 -32
  243. package/lib/engine/extensions/extensions.js +107 -107
  244. package/lib/engine/extensions/index.d.ts +6 -6
  245. package/lib/engine/extensions/index.js +6 -6
  246. package/lib/engine/extensions/usage_tracker.d.ts +13 -13
  247. package/lib/engine/extensions/usage_tracker.js +65 -65
  248. package/lib/engine/js-extensions/Camera.d.ts +1 -1
  249. package/lib/engine/js-extensions/Camera.js +39 -39
  250. package/lib/engine/js-extensions/ExtensionUtils.d.ts +9 -9
  251. package/lib/engine/js-extensions/ExtensionUtils.js +67 -67
  252. package/lib/engine/js-extensions/Layers.d.ts +6 -6
  253. package/lib/engine/js-extensions/Layers.js +22 -22
  254. package/lib/engine/js-extensions/Object3D.d.ts +120 -120
  255. package/lib/engine/js-extensions/Object3D.js +136 -136
  256. package/lib/engine/js-extensions/RGBAColor.d.ts +23 -23
  257. package/lib/engine/js-extensions/RGBAColor.js +111 -111
  258. package/lib/engine/js-extensions/Vector.d.ts +3 -3
  259. package/lib/engine/js-extensions/Vector.js +13 -13
  260. package/lib/engine/js-extensions/index.d.ts +5 -5
  261. package/lib/engine/js-extensions/index.js +5 -5
  262. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.d.ts +4 -4
  263. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +79 -79
  264. package/lib/engine/shaders/shaderData.d.ts +55 -55
  265. package/lib/engine/shaders/shaderData.js +58 -58
  266. package/lib/engine/tests/test_utils.d.ts +2 -2
  267. package/lib/engine/tests/test_utils.js +53 -53
  268. package/lib/engine/webcomponents/WebXRButtons.d.ts +56 -56
  269. package/lib/engine/webcomponents/WebXRButtons.js +230 -230
  270. package/lib/engine/webcomponents/api.d.ts +5 -5
  271. package/lib/engine/webcomponents/api.js +4 -4
  272. package/lib/engine/webcomponents/buttons.d.ts +51 -51
  273. package/lib/engine/webcomponents/buttons.js +264 -264
  274. package/lib/engine/webcomponents/fonts.d.ts +9 -9
  275. package/lib/engine/webcomponents/fonts.js +32 -32
  276. package/lib/engine/webcomponents/icons.d.ts +9 -9
  277. package/lib/engine/webcomponents/icons.js +52 -52
  278. package/lib/engine/webcomponents/index.d.ts +1 -1
  279. package/lib/engine/webcomponents/index.js +1 -1
  280. package/lib/engine/webcomponents/logo-element.d.ts +10 -10
  281. package/lib/engine/webcomponents/logo-element.js +67 -67
  282. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.d.ts +37 -37
  283. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +513 -513
  284. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +155 -155
  285. package/lib/engine/webcomponents/needle menu/needle-menu.js +1029 -1029
  286. package/lib/engine/webcomponents/needle-button.d.ts +34 -34
  287. package/lib/engine/webcomponents/needle-button.js +161 -161
  288. package/lib/engine/webcomponents/needle-engine.ar-overlay.d.ts +21 -21
  289. package/lib/engine/webcomponents/needle-engine.ar-overlay.js +166 -166
  290. package/lib/engine/webcomponents/needle-engine.attributes.d.ts +69 -69
  291. package/lib/engine/webcomponents/needle-engine.attributes.js +1 -1
  292. package/lib/engine/webcomponents/needle-engine.d.ts +116 -116
  293. package/lib/engine/webcomponents/needle-engine.extras.d.ts +6 -6
  294. package/lib/engine/webcomponents/needle-engine.extras.js +13 -13
  295. package/lib/engine/webcomponents/needle-engine.js +821 -821
  296. package/lib/engine/webcomponents/needle-engine.loading.d.ts +44 -44
  297. package/lib/engine/webcomponents/needle-engine.loading.js +341 -341
  298. package/lib/engine/xr/NeedleXRController.d.ts +313 -313
  299. package/lib/engine/xr/NeedleXRController.js +1007 -1007
  300. package/lib/engine/xr/NeedleXRSession.d.ts +340 -340
  301. package/lib/engine/xr/NeedleXRSession.js +1463 -1463
  302. package/lib/engine/xr/NeedleXRSync.d.ts +22 -22
  303. package/lib/engine/xr/NeedleXRSync.js +188 -188
  304. package/lib/engine/xr/SceneTransition.d.ts +18 -18
  305. package/lib/engine/xr/SceneTransition.js +69 -69
  306. package/lib/engine/xr/TempXRContext.d.ts +34 -34
  307. package/lib/engine/xr/TempXRContext.js +187 -187
  308. package/lib/engine/xr/XRRig.d.ts +7 -7
  309. package/lib/engine/xr/XRRig.js +1 -1
  310. package/lib/engine/xr/api.d.ts +6 -6
  311. package/lib/engine/xr/api.js +6 -6
  312. package/lib/engine/xr/events.d.ts +66 -66
  313. package/lib/engine/xr/events.js +93 -93
  314. package/lib/engine/xr/internal.d.ts +12 -12
  315. package/lib/engine/xr/internal.js +25 -25
  316. package/lib/engine/xr/usdz.d.ts +12 -12
  317. package/lib/engine/xr/usdz.js +29 -29
  318. package/lib/engine/xr/utils.d.ts +11 -11
  319. package/lib/engine/xr/utils.js +34 -34
  320. package/lib/engine-components/AlignmentConstraint.d.ts +10 -10
  321. package/lib/engine-components/AlignmentConstraint.js +39 -39
  322. package/lib/engine-components/Animation.d.ts +156 -156
  323. package/lib/engine-components/Animation.js +508 -508
  324. package/lib/engine-components/AnimationCurve.d.ts +40 -40
  325. package/lib/engine-components/AnimationCurve.js +159 -159
  326. package/lib/engine-components/AnimationUtils.d.ts +8 -8
  327. package/lib/engine-components/AnimationUtils.js +27 -27
  328. package/lib/engine-components/AnimationUtilsAutoplay.d.ts +1 -1
  329. package/lib/engine-components/AnimationUtilsAutoplay.js +39 -39
  330. package/lib/engine-components/Animator.d.ts +217 -217
  331. package/lib/engine-components/Animator.js +354 -354
  332. package/lib/engine-components/AnimatorController.d.ts +227 -227
  333. package/lib/engine-components/AnimatorController.js +1152 -1152
  334. package/lib/engine-components/AudioListener.d.ts +33 -33
  335. package/lib/engine-components/AudioListener.js +86 -86
  336. package/lib/engine-components/AudioSource.d.ts +217 -217
  337. package/lib/engine-components/AudioSource.js +635 -635
  338. package/lib/engine-components/AvatarLoader.d.ts +80 -80
  339. package/lib/engine-components/AvatarLoader.js +231 -231
  340. package/lib/engine-components/AxesHelper.d.ts +32 -32
  341. package/lib/engine-components/AxesHelper.js +67 -67
  342. package/lib/engine-components/BasicIKConstraint.d.ts +9 -9
  343. package/lib/engine-components/BasicIKConstraint.js +43 -43
  344. package/lib/engine-components/BoxCollider.d.ts +2 -2
  345. package/lib/engine-components/BoxCollider.js +2 -2
  346. package/lib/engine-components/BoxHelperComponent.d.ts +47 -47
  347. package/lib/engine-components/BoxHelperComponent.js +102 -102
  348. package/lib/engine-components/Camera.d.ts +231 -231
  349. package/lib/engine-components/Camera.js +700 -700
  350. package/lib/engine-components/CameraUtils.d.ts +1 -1
  351. package/lib/engine-components/CameraUtils.js +123 -123
  352. package/lib/engine-components/CharacterController.d.ts +55 -55
  353. package/lib/engine-components/CharacterController.js +236 -236
  354. package/lib/engine-components/Collider.d.ts +188 -188
  355. package/lib/engine-components/Collider.js +369 -369
  356. package/lib/engine-components/Component.d.ts +792 -792
  357. package/lib/engine-components/Component.js +920 -920
  358. package/lib/engine-components/ContactShadows.d.ts +94 -94
  359. package/lib/engine-components/ContactShadows.js +453 -453
  360. package/lib/engine-components/DeleteBox.d.ts +19 -19
  361. package/lib/engine-components/DeleteBox.js +58 -58
  362. package/lib/engine-components/DeviceFlag.d.ts +16 -16
  363. package/lib/engine-components/DeviceFlag.js +47 -47
  364. package/lib/engine-components/DragControls.d.ts +170 -170
  365. package/lib/engine-components/DragControls.js +1421 -1421
  366. package/lib/engine-components/DropListener.d.ts +215 -215
  367. package/lib/engine-components/DropListener.js +642 -642
  368. package/lib/engine-components/Duplicatable.d.ts +35 -35
  369. package/lib/engine-components/Duplicatable.js +202 -202
  370. package/lib/engine-components/EventList.d.ts +54 -54
  371. package/lib/engine-components/EventList.js +232 -232
  372. package/lib/engine-components/EventTrigger.d.ts +33 -33
  373. package/lib/engine-components/EventTrigger.js +75 -75
  374. package/lib/engine-components/EventType.d.ts +22 -22
  375. package/lib/engine-components/EventType.js +23 -23
  376. package/lib/engine-components/Fog.d.ts +22 -22
  377. package/lib/engine-components/Fog.js +61 -61
  378. package/lib/engine-components/Gizmos.d.ts +17 -17
  379. package/lib/engine-components/Gizmos.js +64 -64
  380. package/lib/engine-components/GridHelper.d.ts +20 -20
  381. package/lib/engine-components/GridHelper.js +54 -54
  382. package/lib/engine-components/GroundProjection.d.ts +67 -67
  383. package/lib/engine-components/GroundProjection.js +343 -343
  384. package/lib/engine-components/Interactable.d.ts +12 -12
  385. package/lib/engine-components/Interactable.js +12 -12
  386. package/lib/engine-components/Joints.d.ts +19 -19
  387. package/lib/engine-components/Joints.js +51 -51
  388. package/lib/engine-components/LODGroup.d.ts +35 -35
  389. package/lib/engine-components/LODGroup.js +152 -152
  390. package/lib/engine-components/Light.d.ts +180 -180
  391. package/lib/engine-components/Light.js +535 -535
  392. package/lib/engine-components/LookAtConstraint.d.ts +19 -19
  393. package/lib/engine-components/LookAtConstraint.js +35 -35
  394. package/lib/engine-components/NeedleMenu.d.ts +50 -50
  395. package/lib/engine-components/NeedleMenu.js +92 -92
  396. package/lib/engine-components/NestedGltf.d.ts +25 -25
  397. package/lib/engine-components/NestedGltf.js +88 -88
  398. package/lib/engine-components/Networking.d.ts +54 -54
  399. package/lib/engine-components/Networking.js +112 -112
  400. package/lib/engine-components/OffsetConstraint.d.ts +14 -14
  401. package/lib/engine-components/OffsetConstraint.js +65 -65
  402. package/lib/engine-components/OrbitControls.d.ts +268 -268
  403. package/lib/engine-components/OrbitControls.js +1015 -1015
  404. package/lib/engine-components/PlayerColor.d.ts +19 -19
  405. package/lib/engine-components/PlayerColor.js +94 -94
  406. package/lib/engine-components/ReflectionProbe.d.ts +28 -28
  407. package/lib/engine-components/ReflectionProbe.js +204 -204
  408. package/lib/engine-components/Renderer.d.ts +153 -153
  409. package/lib/engine-components/Renderer.js +834 -834
  410. package/lib/engine-components/RendererInstancing.d.ts +140 -140
  411. package/lib/engine-components/RendererInstancing.js +744 -744
  412. package/lib/engine-components/RendererInstancing.js.map +1 -1
  413. package/lib/engine-components/RendererLightmap.d.ts +24 -24
  414. package/lib/engine-components/RendererLightmap.js +182 -182
  415. package/lib/engine-components/RigidBody.d.ts +155 -155
  416. package/lib/engine-components/RigidBody.js +517 -517
  417. package/lib/engine-components/SceneSwitcher.d.ts +263 -263
  418. package/lib/engine-components/SceneSwitcher.js +971 -971
  419. package/lib/engine-components/ScreenCapture.d.ts +144 -144
  420. package/lib/engine-components/ScreenCapture.js +547 -547
  421. package/lib/engine-components/ShadowCatcher.d.ts +33 -33
  422. package/lib/engine-components/ShadowCatcher.js +166 -166
  423. package/lib/engine-components/Skybox.d.ts +88 -88
  424. package/lib/engine-components/Skybox.js +469 -469
  425. package/lib/engine-components/SmoothFollow.d.ts +34 -34
  426. package/lib/engine-components/SmoothFollow.js +82 -82
  427. package/lib/engine-components/SpatialTrigger.d.ts +102 -102
  428. package/lib/engine-components/SpatialTrigger.js +225 -225
  429. package/lib/engine-components/SpectatorCamera.d.ts +111 -111
  430. package/lib/engine-components/SpectatorCamera.js +715 -715
  431. package/lib/engine-components/SphereCollider.d.ts +2 -2
  432. package/lib/engine-components/SphereCollider.js +2 -2
  433. package/lib/engine-components/SpriteRenderer.d.ts +132 -132
  434. package/lib/engine-components/SpriteRenderer.js +472 -472
  435. package/lib/engine-components/SyncedCamera.d.ts +41 -41
  436. package/lib/engine-components/SyncedCamera.js +199 -199
  437. package/lib/engine-components/SyncedRoom.d.ts +106 -106
  438. package/lib/engine-components/SyncedRoom.js +371 -371
  439. package/lib/engine-components/SyncedTransform.d.ts +94 -94
  440. package/lib/engine-components/SyncedTransform.js +331 -331
  441. package/lib/engine-components/TestRunner.d.ts +16 -16
  442. package/lib/engine-components/TestRunner.js +102 -102
  443. package/lib/engine-components/TransformGizmo.d.ts +75 -75
  444. package/lib/engine-components/TransformGizmo.js +209 -209
  445. package/lib/engine-components/VideoPlayer.d.ts +184 -184
  446. package/lib/engine-components/VideoPlayer.js +978 -978
  447. package/lib/engine-components/Voip.d.ts +67 -67
  448. package/lib/engine-components/Voip.js +360 -360
  449. package/lib/engine-components/api.d.ts +51 -51
  450. package/lib/engine-components/api.js +50 -50
  451. package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +11 -11
  452. package/lib/engine-components/avatar/AvatarBlink_Simple.js +76 -76
  453. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +14 -14
  454. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +68 -68
  455. package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +29 -29
  456. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +121 -121
  457. package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +15 -15
  458. package/lib/engine-components/avatar/Avatar_MouthShapes.js +79 -79
  459. package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +9 -9
  460. package/lib/engine-components/avatar/Avatar_MustacheShake.js +29 -29
  461. package/lib/engine-components/codegen/components.d.ts +216 -216
  462. package/lib/engine-components/codegen/components.js +218 -218
  463. package/lib/engine-components/debug/LogStats.d.ts +5 -5
  464. package/lib/engine-components/debug/LogStats.js +18 -18
  465. package/lib/engine-components/export/gltf/GltfExport.d.ts +30 -30
  466. package/lib/engine-components/export/gltf/GltfExport.js +246 -246
  467. package/lib/engine-components/export/gltf/index.d.ts +1 -1
  468. package/lib/engine-components/export/gltf/index.js +1 -1
  469. package/lib/engine-components/export/index.d.ts +1 -1
  470. package/lib/engine-components/export/index.js +1 -1
  471. package/lib/engine-components/export/usdz/Extension.d.ts +22 -22
  472. package/lib/engine-components/export/usdz/Extension.js +1 -1
  473. package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +162 -162
  474. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +1789 -1789
  475. package/lib/engine-components/export/usdz/USDZExporter.d.ts +130 -130
  476. package/lib/engine-components/export/usdz/USDZExporter.js +663 -663
  477. package/lib/engine-components/export/usdz/extensions/Animation.d.ts +106 -106
  478. package/lib/engine-components/export/usdz/extensions/Animation.js +1071 -1071
  479. package/lib/engine-components/export/usdz/extensions/DocumentExtension.d.ts +5 -5
  480. package/lib/engine-components/export/usdz/extensions/DocumentExtension.js +6 -6
  481. package/lib/engine-components/export/usdz/extensions/NodeMaterialConverter.d.ts +10 -10
  482. package/lib/engine-components/export/usdz/extensions/NodeMaterialConverter.js +451 -451
  483. package/lib/engine-components/export/usdz/extensions/USDZText.d.ts +54 -54
  484. package/lib/engine-components/export/usdz/extensions/USDZText.js +203 -203
  485. package/lib/engine-components/export/usdz/extensions/USDZUI.d.ts +8 -8
  486. package/lib/engine-components/export/usdz/extensions/USDZUI.js +158 -158
  487. package/lib/engine-components/export/usdz/extensions/behavior/Actions.d.ts +30 -30
  488. package/lib/engine-components/export/usdz/extensions/behavior/Actions.js +88 -88
  489. package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.d.ts +10 -10
  490. package/lib/engine-components/export/usdz/extensions/behavior/AudioExtension.js +86 -86
  491. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +28 -28
  492. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +290 -290
  493. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +190 -190
  494. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +1060 -1060
  495. package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +135 -135
  496. package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +548 -548
  497. package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.d.ts +7 -7
  498. package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js +115 -115
  499. package/lib/engine-components/export/usdz/index.d.ts +3 -3
  500. package/lib/engine-components/export/usdz/index.js +2 -2
  501. package/lib/engine-components/export/usdz/utils/animationutils.d.ts +7 -7
  502. package/lib/engine-components/export/usdz/utils/animationutils.js +163 -163
  503. package/lib/engine-components/export/usdz/utils/quicklook.d.ts +2 -2
  504. package/lib/engine-components/export/usdz/utils/quicklook.js +43 -43
  505. package/lib/engine-components/particlesystem/ParticleSystem.d.ts +177 -177
  506. package/lib/engine-components/particlesystem/ParticleSystem.js +1176 -1176
  507. package/lib/engine-components/particlesystem/ParticleSystemModules.d.ts +526 -526
  508. package/lib/engine-components/particlesystem/ParticleSystemModules.js +1930 -1930
  509. package/lib/engine-components/particlesystem/ParticleSystemSubEmitter.d.ts +25 -25
  510. package/lib/engine-components/particlesystem/ParticleSystemSubEmitter.js +87 -87
  511. package/lib/engine-components/particlesystem/api.d.ts +2 -2
  512. package/lib/engine-components/particlesystem/api.js +2 -2
  513. package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +17 -17
  514. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +59 -59
  515. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +46 -46
  516. package/lib/engine-components/postprocessing/Effects/BloomEffect.js +113 -113
  517. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +11 -11
  518. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +39 -39
  519. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +23 -23
  520. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +111 -111
  521. package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +25 -25
  522. package/lib/engine-components/postprocessing/Effects/DepthOfField.js +104 -104
  523. package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +12 -12
  524. package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +18 -18
  525. package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +11 -11
  526. package/lib/engine-components/postprocessing/Effects/Pixelation.js +32 -32
  527. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +18 -18
  528. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +91 -91
  529. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +70 -70
  530. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +176 -176
  531. package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +18 -18
  532. package/lib/engine-components/postprocessing/Effects/Sharpening.js +127 -127
  533. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +17 -17
  534. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +70 -70
  535. package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +19 -19
  536. package/lib/engine-components/postprocessing/Effects/Tonemapping.js +94 -94
  537. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +13 -13
  538. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js +51 -51
  539. package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +15 -15
  540. package/lib/engine-components/postprocessing/Effects/Vignette.js +60 -60
  541. package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +90 -90
  542. package/lib/engine-components/postprocessing/PostProcessingEffect.js +168 -168
  543. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +42 -42
  544. package/lib/engine-components/postprocessing/PostProcessingHandler.js +494 -494
  545. package/lib/engine-components/postprocessing/Volume.d.ts +90 -90
  546. package/lib/engine-components/postprocessing/Volume.js +385 -385
  547. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +26 -26
  548. package/lib/engine-components/postprocessing/VolumeParameter.js +136 -136
  549. package/lib/engine-components/postprocessing/VolumeProfile.d.ts +15 -15
  550. package/lib/engine-components/postprocessing/VolumeProfile.js +60 -60
  551. package/lib/engine-components/postprocessing/index.d.ts +6 -6
  552. package/lib/engine-components/postprocessing/index.js +6 -6
  553. package/lib/engine-components/postprocessing/utils.d.ts +55 -55
  554. package/lib/engine-components/postprocessing/utils.js +119 -119
  555. package/lib/engine-components/timeline/PlayableDirector.d.ts +163 -163
  556. package/lib/engine-components/timeline/PlayableDirector.js +686 -686
  557. package/lib/engine-components/timeline/SignalAsset.d.ts +24 -24
  558. package/lib/engine-components/timeline/SignalAsset.js +130 -130
  559. package/lib/engine-components/timeline/TimelineModels.d.ts +89 -89
  560. package/lib/engine-components/timeline/TimelineModels.js +22 -22
  561. package/lib/engine-components/timeline/TimelineTracks.d.ts +110 -110
  562. package/lib/engine-components/timeline/TimelineTracks.js +879 -879
  563. package/lib/engine-components/timeline/index.d.ts +4 -4
  564. package/lib/engine-components/timeline/index.js +3 -3
  565. package/lib/engine-components/ui/BaseUIComponent.d.ts +48 -48
  566. package/lib/engine-components/ui/BaseUIComponent.js +170 -170
  567. package/lib/engine-components/ui/Button.d.ts +64 -64
  568. package/lib/engine-components/ui/Button.js +315 -315
  569. package/lib/engine-components/ui/Canvas.d.ts +74 -74
  570. package/lib/engine-components/ui/Canvas.js +407 -407
  571. package/lib/engine-components/ui/CanvasGroup.d.ts +19 -19
  572. package/lib/engine-components/ui/CanvasGroup.js +58 -58
  573. package/lib/engine-components/ui/EventSystem.d.ts +125 -125
  574. package/lib/engine-components/ui/EventSystem.js +765 -765
  575. package/lib/engine-components/ui/Graphic.d.ts +55 -55
  576. package/lib/engine-components/ui/Graphic.js +255 -255
  577. package/lib/engine-components/ui/Image.d.ts +35 -35
  578. package/lib/engine-components/ui/Image.js +116 -116
  579. package/lib/engine-components/ui/InputField.d.ts +42 -42
  580. package/lib/engine-components/ui/InputField.js +268 -268
  581. package/lib/engine-components/ui/Interfaces.d.ts +38 -38
  582. package/lib/engine-components/ui/Interfaces.js +12 -12
  583. package/lib/engine-components/ui/Layout.d.ts +84 -84
  584. package/lib/engine-components/ui/Layout.js +330 -330
  585. package/lib/engine-components/ui/Outline.d.ts +7 -7
  586. package/lib/engine-components/ui/Outline.js +20 -20
  587. package/lib/engine-components/ui/PointerEvents.d.ts +115 -115
  588. package/lib/engine-components/ui/PointerEvents.js +145 -145
  589. package/lib/engine-components/ui/RaycastUtils.d.ts +11 -11
  590. package/lib/engine-components/ui/RaycastUtils.js +67 -67
  591. package/lib/engine-components/ui/Raycaster.d.ts +30 -30
  592. package/lib/engine-components/ui/Raycaster.js +95 -95
  593. package/lib/engine-components/ui/RectTransform.d.ts +61 -61
  594. package/lib/engine-components/ui/RectTransform.js +356 -356
  595. package/lib/engine-components/ui/SpatialHtml.d.ts +8 -8
  596. package/lib/engine-components/ui/SpatialHtml.js +79 -79
  597. package/lib/engine-components/ui/Symbols.d.ts +1 -1
  598. package/lib/engine-components/ui/Symbols.js +1 -1
  599. package/lib/engine-components/ui/Text.d.ts +78 -78
  600. package/lib/engine-components/ui/Text.js +539 -539
  601. package/lib/engine-components/ui/Utils.d.ts +24 -24
  602. package/lib/engine-components/ui/Utils.js +90 -90
  603. package/lib/engine-components/ui/index.d.ts +1 -1
  604. package/lib/engine-components/ui/index.js +1 -1
  605. package/lib/engine-components/utils/EnvironmentScene.d.ts +5 -5
  606. package/lib/engine-components/utils/EnvironmentScene.js +205 -205
  607. package/lib/engine-components/utils/LookAt.d.ts +31 -31
  608. package/lib/engine-components/utils/LookAt.js +82 -82
  609. package/lib/engine-components/utils/OpenURL.d.ts +42 -42
  610. package/lib/engine-components/utils/OpenURL.js +119 -119
  611. package/lib/engine-components/webxr/Avatar.d.ts +25 -25
  612. package/lib/engine-components/webxr/Avatar.js +255 -255
  613. package/lib/engine-components/webxr/TeleportTarget.d.ts +7 -7
  614. package/lib/engine-components/webxr/TeleportTarget.js +7 -7
  615. package/lib/engine-components/webxr/WebARCameraBackground.d.ts +30 -30
  616. package/lib/engine-components/webxr/WebARCameraBackground.js +155 -155
  617. package/lib/engine-components/webxr/WebARSessionRoot.d.ts +98 -98
  618. package/lib/engine-components/webxr/WebARSessionRoot.js +770 -770
  619. package/lib/engine-components/webxr/WebXR.d.ts +232 -232
  620. package/lib/engine-components/webxr/WebXR.js +561 -561
  621. package/lib/engine-components/webxr/WebXRAvatar.d.ts +27 -27
  622. package/lib/engine-components/webxr/WebXRAvatar.js +44 -44
  623. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +86 -86
  624. package/lib/engine-components/webxr/WebXRImageTracking.js +471 -471
  625. package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +92 -92
  626. package/lib/engine-components/webxr/WebXRPlaneTracking.js +500 -500
  627. package/lib/engine-components/webxr/WebXRRig.d.ts +32 -32
  628. package/lib/engine-components/webxr/WebXRRig.js +72 -72
  629. package/lib/engine-components/webxr/XRFlag.d.ts +38 -38
  630. package/lib/engine-components/webxr/XRFlag.js +139 -139
  631. package/lib/engine-components/webxr/controllers/XRControllerFollow.d.ts +47 -47
  632. package/lib/engine-components/webxr/controllers/XRControllerFollow.js +120 -120
  633. package/lib/engine-components/webxr/controllers/XRControllerModel.d.ts +43 -43
  634. package/lib/engine-components/webxr/controllers/XRControllerModel.js +352 -352
  635. package/lib/engine-components/webxr/controllers/XRControllerMovement.d.ts +78 -78
  636. package/lib/engine-components/webxr/controllers/XRControllerMovement.js +506 -506
  637. package/lib/engine-components/webxr/index.d.ts +3 -3
  638. package/lib/engine-components/webxr/index.js +3 -3
  639. package/lib/engine-components/webxr/types.d.ts +3 -3
  640. package/lib/engine-components/webxr/types.js +1 -1
  641. package/lib/engine-components-experimental/Presentation.d.ts +6 -6
  642. package/lib/engine-components-experimental/Presentation.js +9 -9
  643. package/lib/engine-components-experimental/api.d.ts +4 -4
  644. package/lib/engine-components-experimental/api.js +4 -4
  645. package/lib/engine-components-experimental/networking/PlayerSync.d.ts +156 -156
  646. package/lib/engine-components-experimental/networking/PlayerSync.js +377 -377
  647. package/lib/engine-schemes/api.d.ts +12 -12
  648. package/lib/engine-schemes/api.js +12 -12
  649. package/lib/engine-schemes/schemes.d.ts +7 -7
  650. package/lib/engine-schemes/schemes.js +19 -19
  651. package/lib/engine-schemes/synced-camera-model.d.ts +25 -25
  652. package/lib/engine-schemes/synced-camera-model.js +67 -67
  653. package/lib/engine-schemes/synced-transform-model.d.ts +31 -31
  654. package/lib/engine-schemes/synced-transform-model.js +66 -66
  655. package/lib/engine-schemes/transform.d.ts +12 -12
  656. package/lib/engine-schemes/transform.js +39 -39
  657. package/lib/engine-schemes/vec2.d.ts +10 -10
  658. package/lib/engine-schemes/vec2.js +25 -25
  659. package/lib/engine-schemes/vec3.d.ts +11 -11
  660. package/lib/engine-schemes/vec3.js +29 -29
  661. package/lib/engine-schemes/vec4.d.ts +12 -12
  662. package/lib/engine-schemes/vec4.js +33 -33
  663. package/lib/engine-schemes/vr-user-state-buffer.d.ts +37 -37
  664. package/lib/engine-schemes/vr-user-state-buffer.js +110 -110
  665. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -6
  666. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +45 -45
  667. package/lib/needle-engine.d.ts +7 -7
  668. package/lib/needle-engine.js +64 -64
  669. package/package.json +2 -2
  670. package/plugins/common/buildinfo.js +64 -64
  671. package/plugins/common/cloud.js +1 -1
  672. package/plugins/common/config.cjs +31 -31
  673. package/plugins/common/config.js +35 -35
  674. package/plugins/common/files.js +31 -31
  675. package/plugins/common/generator.js +10 -10
  676. package/plugins/common/license.js +452 -452
  677. package/plugins/common/logger.js +327 -327
  678. package/plugins/common/npm.js +15 -15
  679. package/plugins/common/timers.js +7 -7
  680. package/plugins/common/version.js +37 -37
  681. package/plugins/gltf-packer.mjs +1 -1
  682. package/plugins/next/alias.cjs +39 -39
  683. package/plugins/next/license.cjs +24 -24
  684. package/plugins/next/meshbvhworker.cjs +18 -18
  685. package/plugins/next/next.js +141 -141
  686. package/plugins/types/index.d.ts +2 -2
  687. package/plugins/types/license.d.ts +24 -24
  688. package/plugins/types/needleConfig.d.ts +27 -27
  689. package/plugins/types/next.d.ts +2 -2
  690. package/plugins/types/userconfig.d.ts +124 -124
  691. package/plugins/types/vite.d.ts +13 -13
  692. package/plugins/types/webmanifest.d.ts +32 -32
  693. package/plugins/vite/alias.js +189 -189
  694. package/plugins/vite/asap.js +251 -251
  695. package/plugins/vite/build-pipeline.js +371 -371
  696. package/plugins/vite/build.js +19 -19
  697. package/plugins/vite/buildinfo.js +41 -41
  698. package/plugins/vite/config.js +106 -106
  699. package/plugins/vite/copyfiles.js +138 -138
  700. package/plugins/vite/defines.js +70 -70
  701. package/plugins/vite/dependencies.js +232 -232
  702. package/plugins/vite/dependency-watcher.js +237 -237
  703. package/plugins/vite/drop-client.js +76 -76
  704. package/plugins/vite/drop.js +87 -87
  705. package/plugins/vite/editor-connection.js +124 -124
  706. package/plugins/vite/facebook-instant-games.js +102 -102
  707. package/plugins/vite/gzip.js +5 -5
  708. package/plugins/vite/imports-logger.js +143 -143
  709. package/plugins/vite/index.js +147 -147
  710. package/plugins/vite/license.js +56 -56
  711. package/plugins/vite/local-files.js +440 -440
  712. package/plugins/vite/logger.client.js +272 -272
  713. package/plugins/vite/logger.js +100 -100
  714. package/plugins/vite/materialx.js +31 -31
  715. package/plugins/vite/meta.js +163 -163
  716. package/plugins/vite/npm.js +7 -7
  717. package/plugins/vite/peer.js +29 -29
  718. package/plugins/vite/poster-client.js +73 -73
  719. package/plugins/vite/poster.js +79 -79
  720. package/plugins/vite/pwa.js +604 -604
  721. package/plugins/vite/reload-client.js +15 -15
  722. package/plugins/vite/reload.js +351 -351
  723. package/plugins/vite/server.js +66 -66
  724. package/plugins/vite/transform-codegen.js +55 -55
  725. package/plugins/vite/transform.js +32 -32
  726. package/plugins/vite/vite-4.4-hack.js +31 -31
  727. package/src/asap/needle-asap.ts +111 -111
  728. package/src/asap/sessiongranted.ts +75 -75
  729. package/src/asap/utils.ts +4 -4
  730. package/src/engine/analytics/index.ts +10 -10
  731. package/src/engine/analytics/lcp.ts +35 -35
  732. package/src/engine/api.ts +82 -82
  733. package/src/engine/assets/index.ts +59 -59
  734. package/src/engine/assets/static.js +5 -5
  735. package/src/engine/codegen/register_types.ts +300 -300
  736. package/src/engine/debug/debug.ts +51 -51
  737. package/src/engine/debug/debug_console.ts +333 -333
  738. package/src/engine/debug/debug_overlay.ts +332 -332
  739. package/src/engine/debug/debug_spatial_console.ts +429 -429
  740. package/src/engine/debug/index.ts +1 -1
  741. package/src/engine/engine_addressables.ts +671 -671
  742. package/src/engine/engine_animation.ts +145 -145
  743. package/src/engine/engine_application.ts +113 -113
  744. package/src/engine/engine_assetdatabase.ts +389 -389
  745. package/src/engine/engine_audio.ts +24 -24
  746. package/src/engine/engine_camera.ts +39 -39
  747. package/src/engine/engine_components.ts +366 -366
  748. package/src/engine/engine_components_internal.ts +40 -40
  749. package/src/engine/engine_constants.ts +52 -52
  750. package/src/engine/engine_context.ts +1824 -1824
  751. package/src/engine/engine_context_registry.ts +129 -129
  752. package/src/engine/engine_coroutine.ts +54 -54
  753. package/src/engine/engine_create_objects.ts +411 -411
  754. package/src/engine/engine_default_parameters.ts +3 -3
  755. package/src/engine/engine_editor-sync.ts +28 -28
  756. package/src/engine/engine_fileloader.js +9 -9
  757. package/src/engine/engine_gameobject.ts +712 -712
  758. package/src/engine/engine_generic_utils.js +13 -13
  759. package/src/engine/engine_gizmos.ts +577 -577
  760. package/src/engine/engine_gltf.ts +29 -29
  761. package/src/engine/engine_gltf_builtin_components.ts +403 -403
  762. package/src/engine/engine_hot_reload.ts +210 -210
  763. package/src/engine/engine_input.ts +1500 -1500
  764. package/src/engine/engine_input_utils.ts +23 -23
  765. package/src/engine/engine_instancing.ts +45 -45
  766. package/src/engine/engine_license.ts +386 -386
  767. package/src/engine/engine_lifecycle_api.ts +113 -113
  768. package/src/engine/engine_lifecycle_functions_internal.ts +193 -193
  769. package/src/engine/engine_lightdata.ts +125 -125
  770. package/src/engine/engine_loaders.callbacks.ts +136 -136
  771. package/src/engine/engine_loaders.gltf.ts +82 -82
  772. package/src/engine/engine_loaders.ts +378 -378
  773. package/src/engine/engine_lods.ts +186 -186
  774. package/src/engine/engine_mainloop_utils.ts +472 -472
  775. package/src/engine/engine_math.ts +282 -282
  776. package/src/engine/engine_modules.ts +83 -83
  777. package/src/engine/engine_networking.ts +862 -862
  778. package/src/engine/engine_networking_auto.ts +352 -352
  779. package/src/engine/engine_networking_blob.ts +275 -275
  780. package/src/engine/engine_networking_files.ts +217 -217
  781. package/src/engine/engine_networking_files_default_components.ts +58 -58
  782. package/src/engine/engine_networking_instantiate.ts +419 -419
  783. package/src/engine/engine_networking_peer.ts +159 -159
  784. package/src/engine/engine_networking_streams.ts +713 -713
  785. package/src/engine/engine_networking_types.ts +24 -24
  786. package/src/engine/engine_networking_utils.ts +23 -23
  787. package/src/engine/engine_networking_websocket.ts +2 -2
  788. package/src/engine/engine_patcher.ts +199 -199
  789. package/src/engine/engine_physics.ts +783 -783
  790. package/src/engine/engine_physics.types.ts +46 -46
  791. package/src/engine/engine_physics_rapier.ts +1577 -1577
  792. package/src/engine/engine_playerview.ts +80 -80
  793. package/src/engine/engine_scenelighting.ts +294 -294
  794. package/src/engine/engine_serialization.ts +2 -2
  795. package/src/engine/engine_serialization_builtin_serializer.ts +473 -473
  796. package/src/engine/engine_serialization_core.ts +720 -720
  797. package/src/engine/engine_serialization_decorator.ts +80 -80
  798. package/src/engine/engine_setup.ts +1 -1
  799. package/src/engine/engine_shaders.ts +267 -267
  800. package/src/engine/engine_shims.ts +32 -32
  801. package/src/engine/engine_test_utils.ts +109 -109
  802. package/src/engine/engine_texture.ts +82 -82
  803. package/src/engine/engine_three_utils.ts +928 -928
  804. package/src/engine/engine_time.ts +94 -94
  805. package/src/engine/engine_time_utils.ts +237 -237
  806. package/src/engine/engine_tonemapping.ts +208 -208
  807. package/src/engine/engine_types.ts +730 -730
  808. package/src/engine/engine_typestore.ts +63 -63
  809. package/src/engine/engine_util_decorator.ts +136 -136
  810. package/src/engine/engine_utils.ts +1115 -1115
  811. package/src/engine/engine_utils_format.ts +273 -273
  812. package/src/engine/engine_utils_screenshot.ts +708 -708
  813. package/src/engine/engine_utils_screenshot.xr.ts +103 -103
  814. package/src/engine/export/gltf/Writers.ts +34 -34
  815. package/src/engine/export/gltf/index.ts +158 -158
  816. package/src/engine/export/index.ts +2 -2
  817. package/src/engine/export/state.ts +19 -19
  818. package/src/engine/export/utils.ts +9 -9
  819. package/src/engine/extensions/EXT_texture_exr.ts +50 -50
  820. package/src/engine/extensions/NEEDLE_animator_controller_model.ts +195 -195
  821. package/src/engine/extensions/NEEDLE_components.ts +268 -268
  822. package/src/engine/extensions/NEEDLE_gameobject_data.ts +81 -81
  823. package/src/engine/extensions/NEEDLE_lighting_settings.ts +185 -185
  824. package/src/engine/extensions/NEEDLE_lightmaps.ts +119 -119
  825. package/src/engine/extensions/NEEDLE_persistent_assets.ts +76 -76
  826. package/src/engine/extensions/NEEDLE_render_objects.ts +209 -209
  827. package/src/engine/extensions/NEEDLE_techniques_webgl.ts +640 -640
  828. package/src/engine/extensions/extension_resolver.ts +4 -4
  829. package/src/engine/extensions/extension_utils.ts +166 -166
  830. package/src/engine/extensions/extensions.ts +140 -140
  831. package/src/engine/extensions/index.ts +5 -5
  832. package/src/engine/extensions/usage_tracker.ts +100 -100
  833. package/src/engine/js-extensions/Camera.ts +37 -37
  834. package/src/engine/js-extensions/ExtensionUtils.ts +85 -85
  835. package/src/engine/js-extensions/Layers.ts +23 -23
  836. package/src/engine/js-extensions/Object3D.ts +296 -296
  837. package/src/engine/js-extensions/RGBAColor.ts +126 -126
  838. package/src/engine/js-extensions/Vector.ts +18 -18
  839. package/src/engine/js-extensions/index.ts +4 -4
  840. package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +125 -125
  841. package/src/engine/shaders/shaderData.ts +67 -67
  842. package/src/engine/tests/test_utils.ts +63 -63
  843. package/src/engine/webcomponents/WebXRButtons.ts +260 -260
  844. package/src/engine/webcomponents/api.ts +6 -6
  845. package/src/engine/webcomponents/buttons.ts +292 -292
  846. package/src/engine/webcomponents/fonts.ts +41 -41
  847. package/src/engine/webcomponents/icons.ts +57 -57
  848. package/src/engine/webcomponents/index.ts +1 -1
  849. package/src/engine/webcomponents/logo-element.ts +78 -78
  850. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +573 -573
  851. package/src/engine/webcomponents/needle menu/needle-menu.ts +1118 -1118
  852. package/src/engine/webcomponents/needle-button.ts +181 -181
  853. package/src/engine/webcomponents/needle-engine.ar-overlay.ts +186 -186
  854. package/src/engine/webcomponents/needle-engine.attributes.ts +82 -82
  855. package/src/engine/webcomponents/needle-engine.extras.ts +16 -16
  856. package/src/engine/webcomponents/needle-engine.loading.ts +373 -373
  857. package/src/engine/webcomponents/needle-engine.ts +860 -860
  858. package/src/engine/xr/NeedleXRController.ts +1125 -1125
  859. package/src/engine/xr/NeedleXRSession.ts +1624 -1624
  860. package/src/engine/xr/NeedleXRSync.ts +220 -220
  861. package/src/engine/xr/SceneTransition.ts +78 -78
  862. package/src/engine/xr/TempXRContext.ts +216 -216
  863. package/src/engine/xr/XRRig.ts +9 -9
  864. package/src/engine/xr/api.ts +5 -5
  865. package/src/engine/xr/events.ts +102 -102
  866. package/src/engine/xr/internal.ts +34 -34
  867. package/src/engine/xr/usdz.ts +30 -30
  868. package/src/engine/xr/utils.ts +39 -39
  869. package/src/engine-components/AlignmentConstraint.ts +36 -36
  870. package/src/engine-components/Animation.ts +557 -557
  871. package/src/engine-components/AnimationCurve.ts +150 -150
  872. package/src/engine-components/AnimationUtils.ts +28 -28
  873. package/src/engine-components/AnimationUtilsAutoplay.ts +43 -43
  874. package/src/engine-components/Animator.ts +397 -397
  875. package/src/engine-components/AnimatorController.ts +1293 -1293
  876. package/src/engine-components/AudioListener.ts +92 -92
  877. package/src/engine-components/AudioSource.ts +644 -644
  878. package/src/engine-components/AvatarLoader.ts +263 -263
  879. package/src/engine-components/AxesHelper.ts +59 -59
  880. package/src/engine-components/BasicIKConstraint.ts +54 -54
  881. package/src/engine-components/BoxCollider.ts +1 -1
  882. package/src/engine-components/BoxHelperComponent.ts +114 -114
  883. package/src/engine-components/Camera.ts +719 -719
  884. package/src/engine-components/CameraUtils.ts +138 -138
  885. package/src/engine-components/CharacterController.ts +253 -253
  886. package/src/engine-components/Collider.ts +374 -374
  887. package/src/engine-components/Component.ts +1297 -1297
  888. package/src/engine-components/ContactShadows.ts +506 -506
  889. package/src/engine-components/DeleteBox.ts +62 -62
  890. package/src/engine-components/DeviceFlag.ts +46 -46
  891. package/src/engine-components/DragControls.ts +1623 -1623
  892. package/src/engine-components/DropListener.ts +713 -713
  893. package/src/engine-components/Duplicatable.ts +198 -198
  894. package/src/engine-components/EventList.ts +266 -266
  895. package/src/engine-components/EventTrigger.ts +74 -74
  896. package/src/engine-components/EventType.ts +22 -22
  897. package/src/engine-components/Fog.ts +60 -60
  898. package/src/engine-components/Gizmos.ts +56 -56
  899. package/src/engine-components/GridHelper.ts +48 -48
  900. package/src/engine-components/GroundProjection.ts +356 -356
  901. package/src/engine-components/Interactable.ts +14 -14
  902. package/src/engine-components/Joints.ts +52 -52
  903. package/src/engine-components/LODGroup.ts +153 -153
  904. package/src/engine-components/Light.ts +558 -558
  905. package/src/engine-components/LookAtConstraint.ts +25 -25
  906. package/src/engine-components/NeedleMenu.ts +84 -84
  907. package/src/engine-components/NestedGltf.ts +86 -86
  908. package/src/engine-components/Networking.ts +114 -114
  909. package/src/engine-components/OffsetConstraint.ts +60 -60
  910. package/src/engine-components/OrbitControls.ts +1074 -1074
  911. package/src/engine-components/PlayerColor.ts +103 -103
  912. package/src/engine-components/ReflectionProbe.ts +220 -220
  913. package/src/engine-components/Renderer.ts +903 -903
  914. package/src/engine-components/RendererInstancing.ts +855 -855
  915. package/src/engine-components/RendererLightmap.ts +198 -198
  916. package/src/engine-components/RigidBody.ts +526 -526
  917. package/src/engine-components/SceneSwitcher.ts +1030 -1030
  918. package/src/engine-components/ScreenCapture.ts +592 -592
  919. package/src/engine-components/ShadowCatcher.ts +172 -172
  920. package/src/engine-components/Skybox.ts +475 -475
  921. package/src/engine-components/SmoothFollow.ts +76 -76
  922. package/src/engine-components/SpatialTrigger.ts +229 -229
  923. package/src/engine-components/SpectatorCamera.ts +787 -787
  924. package/src/engine-components/SphereCollider.ts +1 -1
  925. package/src/engine-components/SpriteRenderer.ts +468 -468
  926. package/src/engine-components/SyncedCamera.ts +220 -220
  927. package/src/engine-components/SyncedRoom.ts +380 -380
  928. package/src/engine-components/SyncedTransform.ts +383 -383
  929. package/src/engine-components/TestRunner.ts +118 -118
  930. package/src/engine-components/TransformGizmo.ts +219 -219
  931. package/src/engine-components/VideoPlayer.ts +1025 -1025
  932. package/src/engine-components/Voip.ts +363 -363
  933. package/src/engine-components/api.ts +60 -60
  934. package/src/engine-components/avatar/AvatarBlink_Simple.ts +69 -69
  935. package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +63 -63
  936. package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +139 -139
  937. package/src/engine-components/avatar/Avatar_MouthShapes.ts +83 -83
  938. package/src/engine-components/avatar/Avatar_MustacheShake.ts +31 -31
  939. package/src/engine-components/codegen/components.ts +217 -217
  940. package/src/engine-components/debug/LogStats.ts +21 -21
  941. package/src/engine-components/export/gltf/GltfExport.ts +265 -265
  942. package/src/engine-components/export/usdz/Extension.ts +24 -24
  943. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2426 -2426
  944. package/src/engine-components/export/usdz/USDZExporter.ts +705 -705
  945. package/src/engine-components/export/usdz/extensions/Animation.ts +1204 -1204
  946. package/src/engine-components/export/usdz/extensions/DocumentExtension.ts +9 -9
  947. package/src/engine-components/export/usdz/extensions/NodeMaterialConverter.ts +532 -532
  948. package/src/engine-components/export/usdz/extensions/USDZText.ts +240 -240
  949. package/src/engine-components/export/usdz/extensions/USDZUI.ts +189 -189
  950. package/src/engine-components/export/usdz/extensions/behavior/Actions.ts +99 -99
  951. package/src/engine-components/export/usdz/extensions/behavior/AudioExtension.ts +102 -102
  952. package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +320 -320
  953. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +1225 -1225
  954. package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +646 -646
  955. package/src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts +132 -132
  956. package/src/engine-components/export/usdz/index.ts +2 -2
  957. package/src/engine-components/export/usdz/utils/animationutils.ts +191 -191
  958. package/src/engine-components/export/usdz/utils/quicklook.ts +50 -50
  959. package/src/engine-components/particlesystem/ParticleSystem.ts +1287 -1287
  960. package/src/engine-components/particlesystem/ParticleSystemModules.ts +1765 -1765
  961. package/src/engine-components/particlesystem/ParticleSystemSubEmitter.ts +111 -111
  962. package/src/engine-components/particlesystem/api.ts +1 -1
  963. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +64 -64
  964. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +116 -116
  965. package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +37 -37
  966. package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +106 -106
  967. package/src/engine-components/postprocessing/Effects/DepthOfField.ts +103 -103
  968. package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +25 -25
  969. package/src/engine-components/postprocessing/Effects/Pixelation.ts +32 -32
  970. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +90 -90
  971. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +192 -192
  972. package/src/engine-components/postprocessing/Effects/Sharpening.ts +143 -143
  973. package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +61 -61
  974. package/src/engine-components/postprocessing/Effects/Tonemapping.ts +103 -103
  975. package/src/engine-components/postprocessing/Effects/Tonemapping.utils.ts +60 -60
  976. package/src/engine-components/postprocessing/Effects/Vignette.ts +59 -59
  977. package/src/engine-components/postprocessing/PostProcessingEffect.ts +192 -192
  978. package/src/engine-components/postprocessing/PostProcessingHandler.ts +572 -572
  979. package/src/engine-components/postprocessing/Volume.ts +426 -426
  980. package/src/engine-components/postprocessing/VolumeParameter.ts +158 -158
  981. package/src/engine-components/postprocessing/VolumeProfile.ts +61 -61
  982. package/src/engine-components/postprocessing/index.ts +5 -5
  983. package/src/engine-components/postprocessing/utils.ts +154 -154
  984. package/src/engine-components/timeline/PlayableDirector.ts +722 -722
  985. package/src/engine-components/timeline/SignalAsset.ts +144 -144
  986. package/src/engine-components/timeline/TimelineModels.ts +92 -92
  987. package/src/engine-components/timeline/TimelineTracks.ts +967 -967
  988. package/src/engine-components/timeline/index.ts +3 -3
  989. package/src/engine-components/ui/BaseUIComponent.ts +203 -203
  990. package/src/engine-components/ui/Button.ts +307 -307
  991. package/src/engine-components/ui/Canvas.ts +419 -419
  992. package/src/engine-components/ui/CanvasGroup.ts +54 -54
  993. package/src/engine-components/ui/EventSystem.ts +854 -854
  994. package/src/engine-components/ui/Graphic.ts +275 -275
  995. package/src/engine-components/ui/Image.ts +112 -112
  996. package/src/engine-components/ui/InputField.ts +321 -321
  997. package/src/engine-components/ui/Interfaces.ts +57 -57
  998. package/src/engine-components/ui/Layout.ts +334 -334
  999. package/src/engine-components/ui/Outline.ts +13 -13
  1000. package/src/engine-components/ui/PointerEvents.ts +206 -206
  1001. package/src/engine-components/ui/RaycastUtils.ts +69 -69
  1002. package/src/engine-components/ui/Raycaster.ts +102 -102
  1003. package/src/engine-components/ui/RectTransform.ts +375 -375
  1004. package/src/engine-components/ui/SpatialHtml.ts +79 -79
  1005. package/src/engine-components/ui/Symbols.ts +1 -1
  1006. package/src/engine-components/ui/Text.ts +578 -578
  1007. package/src/engine-components/ui/Utils.ts +113 -113
  1008. package/src/engine-components/utils/EnvironmentScene.ts +245 -245
  1009. package/src/engine-components/utils/LookAt.ts +88 -88
  1010. package/src/engine-components/utils/OpenURL.ts +114 -114
  1011. package/src/engine-components/webxr/Avatar.ts +265 -265
  1012. package/src/engine-components/webxr/TeleportTarget.ts +9 -9
  1013. package/src/engine-components/webxr/WebARCameraBackground.ts +175 -175
  1014. package/src/engine-components/webxr/WebARSessionRoot.ts +880 -880
  1015. package/src/engine-components/webxr/WebXR.ts +585 -585
  1016. package/src/engine-components/webxr/WebXRAvatar.ts +66 -66
  1017. package/src/engine-components/webxr/WebXRImageTracking.ts +519 -519
  1018. package/src/engine-components/webxr/WebXRPlaneTracking.ts +570 -570
  1019. package/src/engine-components/webxr/WebXRRig.ts +77 -77
  1020. package/src/engine-components/webxr/XRFlag.ts +147 -147
  1021. package/src/engine-components/webxr/controllers/XRControllerFollow.ts +118 -118
  1022. package/src/engine-components/webxr/controllers/XRControllerModel.ts +373 -373
  1023. package/src/engine-components/webxr/controllers/XRControllerMovement.ts +550 -550
  1024. package/src/engine-components/webxr/index.ts +2 -2
  1025. package/src/engine-components/webxr/types.ts +3 -3
  1026. package/src/engine-components-experimental/Presentation.ts +12 -12
  1027. package/src/engine-components-experimental/api.ts +4 -4
  1028. package/src/engine-components-experimental/networking/PlayerSync.ts +401 -401
  1029. package/src/engine-schemes/COMPILE_SCHEMES.bat +3 -3
  1030. package/src/engine-schemes/COMPILE_TS.bat +11 -11
  1031. package/src/engine-schemes/README.md +1 -1
  1032. package/src/engine-schemes/api.ts +12 -12
  1033. package/src/engine-schemes/dist/api.js +17 -0
  1034. package/src/engine-schemes/dist/api.js.meta +7 -0
  1035. package/src/engine-schemes/dist/schemes.js +25 -0
  1036. package/src/engine-schemes/dist/schemes.js.meta +7 -0
  1037. package/src/engine-schemes/dist/synced-camera-model.js +74 -0
  1038. package/src/engine-schemes/dist/synced-camera-model.js.meta +7 -0
  1039. package/src/engine-schemes/dist/synced-transform-model.js +73 -0
  1040. package/src/engine-schemes/dist/synced-transform-model.js.meta +7 -0
  1041. package/src/engine-schemes/dist/transform.js +46 -0
  1042. package/src/engine-schemes/dist/transform.js.meta +7 -0
  1043. package/src/engine-schemes/dist/vec2.js +32 -0
  1044. package/src/engine-schemes/dist/vec2.js.meta +7 -0
  1045. package/src/engine-schemes/dist/vec3.js +36 -0
  1046. package/src/engine-schemes/dist/vec3.js.meta +7 -0
  1047. package/src/engine-schemes/dist/vec4.js +40 -0
  1048. package/src/engine-schemes/dist/vec4.js.meta +7 -0
  1049. package/src/engine-schemes/dist/vr-user-state-buffer.js +110 -0
  1050. package/src/engine-schemes/dist/vr-user-state-buffer.js.meta +7 -0
  1051. package/src/engine-schemes/schemes.ts +28 -28
  1052. package/src/engine-schemes/synced-camera-model.ts +92 -92
  1053. package/src/engine-schemes/synced-transform-model.ts +90 -90
  1054. package/src/engine-schemes/syncedCamera.fbs +10 -10
  1055. package/src/engine-schemes/transform.ts +50 -50
  1056. package/src/engine-schemes/transforms.fbs +25 -25
  1057. package/src/engine-schemes/vec.fbs +19 -19
  1058. package/src/engine-schemes/vec2.ts +33 -33
  1059. package/src/engine-schemes/vec3.ts +38 -38
  1060. package/src/engine-schemes/vec4.ts +43 -43
  1061. package/src/engine-schemes/vr-user-state-buffer.ts +145 -145
  1062. package/src/engine-schemes/vrUserStateBuffer.fbs +17 -17
  1063. package/src/include/draco/draco_decoder.js +34 -34
  1064. package/src/include/ktx2/basis_transcoder.js +21 -21
  1065. package/src/include/needle/arial-msdf.json +1471 -1471
  1066. package/src/include/three/DragControls.js +231 -231
  1067. package/src/include/three/EXT_mesh_gpu_instancing_exporter.js +66 -66
  1068. package/src/needle-engine.ts +70 -70
  1069. package/dist/generateMeshBVH.worker-BaNp_Xtp.js +0 -25
  1070. package/dist/gltf-progressive-60Qk5ebF.min.js +0 -8
  1071. package/dist/gltf-progressive-DM5ZiecW.js +0 -1060
  1072. package/dist/gltf-progressive-wxtaVmio.umd.cjs +0 -8
@@ -1,4 +1,4 @@
1
- import{PlaneGeometry as gs,ShaderChunk as Fa,Object3D as vs,Layers as hi,MeshBasicMaterial as _s,DoubleSide as sn,AdditiveBlending as bs,InstancedBufferAttribute as Ct,DynamicDrawUsage as ge,InstancedBufferGeometry as La,Uniform$1 as Le,ShaderMaterial as on,BufferGeometry as ar,BufferAttribute as Te,Mesh as an,MeshStandardMaterial as Va,MeshPhysicalMaterial as ja,Triangle as Pt,Vector3 as I,Plane as xs,Line3 as ht,Vector2 as Vt,Sphere as Ss,Matrix4 as Ve,Box3 as Ye,BackSide as Ja,REVISION as Ga,FrontSide as ws,BatchedMesh as Wa,Ray as Xa,Matrix3 as qa,Vector4 as cn}from"./three-DuDKwKB8.min.js";const ne={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function Ms(n){const e=await fetch(n);if(e.ok)return e.json();throw new Error(e.statusText)}async function Ha(n){return await Ms(`${n}/profilesList.json`)}async function Ya(n,e,t=null,r=!0){if(!n)throw new Error("No xrInputSource supplied");const i=await Ha(e);let s;if(n.profiles.some(c=>{const l=i[c];return l&&(s={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!t)throw new Error("No matching profile name found");const c=i[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);s={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const a=await Ms(s.profilePath);let o;if(r){let c;if(n.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[n.handedness],!c)throw new Error(`No matching handedness, ${n.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const Za={xAxis:0,yAxis:0,button:0,state:ne.ComponentState.DEFAULT};function Qa(n=0,e=0){let t=n,r=e;if(Math.sqrt(n*n+e*e)>1){const i=Math.atan2(e,n);t=Math.cos(i),r=Math.sin(i)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:r*.5+.5}}class Ka{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===ne.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Za)}updateFromComponent({xAxis:e,yAxis:t,button:r,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=Qa(e,t);switch(this.componentProperty){case ne.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case ne.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case ne.ComponentProperty.BUTTON:this.value=this.states.includes(i)?r:0;break;case ne.ComponentProperty.STATE:this.valueNodeProperty===ne.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class $a{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(r=>{const i=new Ka(t.visualResponses[r]);this.visualResponses[r]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:ne.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=ne.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=ne.ComponentState.PRESSED:(t.touched||this.values.button>ne.ButtonTouchThreshold)&&(this.values.state=ne.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===ne.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>ne.AxisTouchThreshold&&(this.values.state=ne.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===ne.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>ne.AxisTouchThreshold&&(this.values.state=ne.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class ec{constructor(e,t,r){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=r,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(i=>{const s=this.layoutDescription.components[i];this.components[i]=new $a(i,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const ln=2,Ze=4,ut=4,Ts=4,gt=new Int32Array(2),Cs=new Float32Array(gt.buffer),Ps=new Float64Array(gt.buffer),ui=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class yt{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?yt.ZERO:new yt(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}yt.ZERO=new yt(0,0);var hn;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(hn||(hn={}));class Or{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new Or(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new yt(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new yt(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return gt[0]=this.readInt32(e),Cs[0]}readFloat64(e){return gt[ui?0:1]=this.readInt32(e),gt[ui?1:0]=this.readInt32(e+4),Ps[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)}writeUint64(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)}writeFloat32(e,t){Cs[0]=t,this.writeInt32(e,gt[0])}writeFloat64(e,t){Ps[0]=t,this.writeInt32(e,gt[ui?0:1]),this.writeInt32(e+4,gt[ui?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Ze+ut)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<ut;t++)e+=String.fromCharCode(this.readInt8(this.position_+Ze+t));return e}__offset(e,t){const r=e-this.readInt32(e);return t<this.readInt16(r)?this.readInt16(r+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);const r=this.readInt32(e);let i="",s=0;if(e+=Ze,t===hn.UTF8_BYTES)return this.bytes_.subarray(e,e+r);for(;s<r;){let a;const o=this.readUint8(e+s++);if(o<192)a=o;else{const c=this.readUint8(e+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(e+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const h=this.readUint8(e+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|h&63}}}a<65536?i+=String.fromCharCode(a):(a-=65536,i+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return i}__union_with_string(e,t){return typeof e=="string"?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+Ze}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=ut)throw new Error("FlatBuffers: file identifier must be length "+ut);for(let t=0;t<ut;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+Ze+t))return!1;return!0}createLong(e,t){return yt.create(e,t)}createScalarList(e,t){const r=[];for(let i=0;i<t;++i)e(i)!==null&&r.push(e(i));return r}createObjList(e,t){const r=[];for(let i=0;i<t;++i){const s=e(i);s!==null&&r.push(s.unpack())}return r}}class ms{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let t;e?t=e:t=1024,this.bb=Or.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,t){e>this.minalign&&(this.minalign=e);const r=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space<r+e+t;){const i=this.bb.capacity();this.bb=ms.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,r){(this.force_defaults||t!=r)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,r){(this.force_defaults||t!=r)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,r){(this.force_defaults||t!=r)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,r){(this.force_defaults||!t.equals(r))&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,r){(this.force_defaults||t!=r)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,r){(this.force_defaults||t!=r)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,r){(this.force_defaults||t!=r)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,r){t!=r&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const t=e.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=t<<1,i=Or.allocate(r);return i.setPosition(r-t),i.bytes().set(e.bytes(),r-t),i}addOffset(e){this.prep(Ze,0),this.writeInt32(this.offset()-e+Ze)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);const r=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const i=2;this.addInt16(e-this.object_start);const s=(r+i)*ln;this.addInt16(s);let a=0;const o=this.space;e:for(t=0;t<this.vtables.length;t++){const c=this.bb.capacity()-this.vtables[t];if(s==this.bb.readInt16(c)){for(let l=ln;l<s;l+=ln)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue e;a=this.vtables[t];break}}return a?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,a-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,r){const i=r?Ts:0;if(t){const s=t;if(this.prep(this.minalign,Ze+ut+i),s.length!=ut)throw new Error("FlatBuffers: file identifier must be length "+ut);for(let a=ut-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,Ze+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(this.bb.readInt16(i+t)==0)throw new Error("FlatBuffers: field "+t+" must be set")}startVector(e,t,r){this.notNested(),this.vector_num_elems=t,this.prep(Ze,e*t),this.prep(r,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(!e)return 0;let t;if(e instanceof Uint8Array)t=e;else{t=[];let r=0;for(;r<e.length;){let i;const s=e.charCodeAt(r++);if(s<55296||s>=56320)i=s;else{const a=e.charCodeAt(r++);i=(s<<10)+a+-56613888}i<128?t.push(i):(i<2048?t.push(i>>6&31|192):(i<65536?t.push(i>>12&15|224):t.push(i>>18&7|240,i>>12&63|128),t.push(i>>6&63|128)),t.push(i&63|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);for(let r=0,i=this.space,s=this.bb.bytes();r<t.length;r++)s[i++]=t[r];return this.endVector()}createLong(e,t){return yt.create(e,t)}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const t=[];for(let r=0;r<e.length;++r){const i=e[r];if(i!==null)t.push(this.createObjectOffset(i));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e),this.endVector()}}function di(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Es={exports:{}},ks;function As(){return ks||(ks=1,function(n){var e={};e.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),e.useArrayBufferView=!e.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),n.exports.binaryFeatures=e;var t=n.exports.BlobBuilder;typeof window<"u"&&(t=n.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function r(){this._pieces=[],this._parts=[]}r.prototype.append=function(i){typeof i=="number"?this._pieces.push(i):(this.flush(),this._parts.push(i))},r.prototype.flush=function(){if(this._pieces.length>0){var i=new Uint8Array(this._pieces);e.useArrayBufferView||(i=i.buffer),this._parts.push(i),this._pieces=[]}},r.prototype.getBuffer=function(){if(this.flush(),e.useBlobBuilder){for(var i=new t,s=0,a=this._parts.length;s<a;s++)i.append(this._parts[s]);return i.getBlob()}else return new Blob(this._parts)},n.exports.BufferBuilder=r}(Es)),Es.exports}var un,Rs;function tc(){if(Rs)return un;Rs=1;var n=As().BufferBuilder,e=As().binaryFeatures,t={unpack:function(o){var c=new r(o);return c.unpack()},pack:function(o){var c=new i;c.pack(o);var l=c.getBuffer();return l}};un=t;function r(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}r.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},r.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},r.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},r.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},r.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},r.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},r.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},r.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},r.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},r.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},r.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,h="",u,d;l<o;)u=c[l],u<128?(h+=String.fromCharCode(u),l++):(u^192)<32?(d=(u^192)<<6|c[l+1]&63,h+=String.fromCharCode(d),l+=2):(d=(u&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,h+=String.fromCharCode(d),l+=3);return this.index+=o,h},r.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},r.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var h=this.unpack(),u=this.unpack();c[h]=u}return c},r.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,h=o&8388607|8388608;return(c===0?1:-1)*h*Math.pow(2,l-23)},r.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,h=(o>>20&2047)-1023,u=o&1048575|1048576,d=u*Math.pow(2,h-20)+c*Math.pow(2,h-52);return(l===0?1:-1)*d},r.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function i(){this.bufferBuilder=new n}i.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},i.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)e.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)e.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},i.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},i.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},i.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),h=o/Math.pow(2,l)-1,u=Math.floor(h*Math.pow(2,52)),d=Math.pow(2,32),p=c<<31|l+1023<<20|u/d&1048575,y=u%d;this.bufferBuilder.append(203),this.pack_int32(p),this.pack_int32(y)},i.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var h in o)o.hasOwnProperty(h)&&(this.pack(h),this.pack(o[h]))},i.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},i.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},i.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},i.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},i.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return un}var rc=tc();const Os=di(rc);let zs=!0,Bs=!0;function cr(n,e,t){const r=n.match(e);return r&&r.length>=t&&parseInt(r[t],10)}function jt(n,e,t){if(!n.RTCPeerConnection)return;const r=n.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(a,o){if(a!==e)return i.apply(this,arguments);const c=l=>{const h=t(l);h&&(o.handleEvent?o.handleEvent(h):o(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),i.apply(this,[a,c])};const s=r.removeEventListener;r.removeEventListener=function(a,o){if(a!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(o))return s.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}function ic(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(zs=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function nc(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Bs=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function dn(){if(typeof window=="object"){if(zs)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function pi(n,e){Bs&&console.warn(n+" is deprecated, please use "+e+" instead.")}function sc(n){const e={browser:null,version:null};if(typeof n>"u"||!n.navigator)return e.browser="Not a browser.",e;const{navigator:t}=n;if(t.mozGetUserMedia)e.browser="firefox",e.version=cr(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||n.isSecureContext===!1&&n.webkitRTCPeerConnection&&!n.RTCIceGatherer)e.browser="chrome",e.version=cr(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=cr(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(n.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=cr(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=n.RTCRtpTransceiver&&"currentDirection"in n.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function Is(n){return Object.prototype.toString.call(n)==="[object Object]"}function Us(n){return Is(n)?Object.keys(n).reduce(function(e,t){const r=Is(n[t]),i=r?Us(n[t]):n[t],s=r&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):n}function pn(n,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?pn(n,n.get(e[r]),t):r.endsWith("Ids")&&e[r].forEach(i=>{pn(n,n.get(i),t)})}))}function Ns(n,e,t){const r=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return n.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{n.forEach(o=>{o.type===r&&o.trackId===a.id&&pn(n,o,i)})}),i}const Ds=dn;function Fs(n,e){const t=n&&n.navigator;if(!t.mediaDevices)return;const r=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const h=typeof o[l]=="object"?o[l]:{ideal:o[l]};h.exact!==void 0&&typeof h.exact=="number"&&(h.min=h.max=h.exact);const u=function(d,p){return d?d+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(h.ideal!==void 0){c.optional=c.optional||[];let d={};typeof h.ideal=="number"?(d[u("min",l)]=h.ideal,c.optional.push(d),d={},d[u("max",l)]=h.ideal,c.optional.push(d)):(d[u("",l)]=h.ideal,c.optional.push(d))}h.exact!==void 0&&typeof h.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[u("",l)]=h.exact):["min","max"].forEach(d=>{h[d]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[u(d,l)]=h[d])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},i=function(o,c){if(e.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(h,u,d){u in h&&!(d in h)&&(h[d]=h[u],delete h[u])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=r(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const h=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!h)){delete o.video.facingMode;let u;if(l.exact==="environment"||l.ideal==="environment"?u=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(u=["front"]),u)return t.mediaDevices.enumerateDevices().then(d=>{d=d.filter(y=>y.kind==="videoinput");let p=d.find(y=>u.some(g=>y.label.toLowerCase().includes(g)));return!p&&d.length&&u.includes("back")&&(p=d[d.length-1]),p&&(o.video.deviceId=l.exact?{exact:p.deviceId}:{ideal:p.deviceId}),o.video=r(o.video),Ds("chrome: "+JSON.stringify(o)),c(o)})}o.video=r(o.video)}return Ds("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){i(o,h=>{t.webkitGetUserMedia(h,c,u=>{l&&l(s(u))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(c){return i(c,l=>o(l).then(h=>{if(l.audio&&!h.getAudioTracks().length||l.video&&!h.getVideoTracks().length)throw h.getTracks().forEach(u=>{u.stop()}),new DOMException("","NotFoundError");return h},h=>Promise.reject(s(h))))}}}function oc(n,e){if(!(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices)&&n.navigator.mediaDevices){if(typeof e!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}n.navigator.mediaDevices.getDisplayMedia=function(t){return e(t).then(r=>{const i=t.video&&t.video.width,s=t.video&&t.video.height,a=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:a||3}},i&&(t.video.mandatory.maxWidth=i),s&&(t.video.mandatory.maxHeight=s),n.navigator.mediaDevices.getUserMedia(t)})}}}function Ls(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function Vs(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let i;n.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===r.track.id):i={track:r.track};const s=new Event("track");s.track=r.track,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)}),t.stream.getTracks().forEach(r=>{let i;n.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===r.id):i={track:r};const s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else jt(n,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function js(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(a,o){let c=i.apply(this,arguments);return c||(c=e(this,a),this._senders.push(c)),c};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(a){s.apply(this,arguments);const o=this._senders.indexOf(a);o!==-1&&this._senders.splice(o,1)}}const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],t.apply(this,[i]),i.getTracks().forEach(s=>{this._senders.push(e(this,s))})};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(s=>{const a=this._senders.find(o=>o.track===s);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const t=e.apply(this,[]);return t.forEach(r=>r._pc=this),t},Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Js(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[t,r,i]=arguments;if(arguments.length>0&&typeof t=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof t!="function"))return e.apply(this,[]);const s=function(o){const c={};return o.result().forEach(l=>{const h={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(u=>{h[u]=l.stat(u)}),c[h.id]=h}),c},a=function(o){return new Map(Object.keys(o).map(c=>[c,o[c]]))};if(arguments.length>=2){const o=function(c){r(a(s(c)))};return e.apply(this,[o,t])}return new Promise((o,c)=>{e.apply(this,[function(l){o(a(s(l)))},c])}).then(r,i)}}function Gs(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i});const r=n.RTCPeerConnection.prototype.addTrack;r&&(n.RTCPeerConnection.prototype.addTrack=function(){const i=r.apply(this,arguments);return i._pc=this,i}),n.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>Ns(s,i.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=t.apply(this,[]);return r.forEach(i=>i._pc=this),r}),jt(n,"track",r=>(r.receiver._pc=r.srcElement,r)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>Ns(i,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype&&"getStats"in n.RTCRtpReceiver.prototype))return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const t=arguments[0];let r,i,s;return this.getSenders().forEach(a=>{a.track===t&&(r?s=!0:r=a)}),this.getReceivers().forEach(a=>(a.track===t&&(i?s=!0:i=a),a.track===t)),s||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Ws(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(s,a){if(!a)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const o=e.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(o)===-1&&this._shimmedLocalStreams[a.id].push(o):this._shimmedLocalStreams[a.id]=[a,o],o};const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(c=>{if(this.getSenders().find(l=>l.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const a=this.getSenders();t.apply(this,arguments);const o=this.getSenders().filter(c=>a.indexOf(c)===-1);this._shimmedLocalStreams[s.id]=[s].concat(o)};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],r.apply(this,arguments)};const i=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(a=>{const o=this._shimmedLocalStreams[a].indexOf(s);o!==-1&&this._shimmedLocalStreams[a].splice(o,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),i.apply(this,arguments)}}function Xs(n,e){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Ws(n);const t=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const r=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(u=>u.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const h=new n.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}r.apply(this,[l])};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},n.RTCPeerConnection.prototype.addTrack=function(l,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const u=[].slice.call(arguments,1);if(u.length!==1||!u[0].getTracks().find(p=>p===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(p=>p.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const d=this._streams[h.id];if(d)d.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const p=new n.MediaStream([l]);this._streams[h.id]=p,this._reverseStreams[p.id]=h,this.addStream(p)}return this.getSenders().find(p=>p.track===l)};function s(l,h){let u=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(d=>{const p=l._reverseStreams[d],y=l._streams[p.id];u=u.replace(new RegExp(y.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:u})}function a(l,h){let u=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(d=>{const p=l._reverseStreams[d],y=l._streams[p.id];u=u.replace(new RegExp(p.id,"g"),y.id)}),new RTCSessionDescription({type:h.type,sdp:u})}["createOffer","createAnswer"].forEach(function(l){const h=n.RTCPeerConnection.prototype[l],u={[l](){const d=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[p=>{const y=s(this,p);d[0].apply(null,[y])},p=>{d[1]&&d[1].apply(null,p)},arguments[2]]):h.apply(this,arguments).then(p=>s(this,p))}};n.RTCPeerConnection.prototype[l]=u[l]});const o=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),n.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let h;Object.keys(this._streams).forEach(u=>{this._streams[u].getTracks().find(d=>l.track===d)&&(h=this._streams[u])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function fn(n,e){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const r=n.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};n.RTCPeerConnection.prototype[t]=i[t]})}function qs(n,e){jt(n,"negotiationneeded",t=>{const r=t.target;if(!((e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")&&r.signalingState!=="stable"))return t})}const Hs=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:qs,shimAddTrackRemoveTrack:Xs,shimAddTrackRemoveTrackWithNative:Ws,shimGetDisplayMedia:oc,shimGetSendersWithDtmf:js,shimGetStats:Js,shimGetUserMedia:Fs,shimMediaStream:Ls,shimOnTrack:Vs,shimPeerConnection:fn,shimSenderReceiverGetStats:Gs},Symbol.toStringTag,{value:"Module"}));function ac(n,e){let t=!1;return n=JSON.parse(JSON.stringify(n)),n.filter(r=>{if(r&&(r.urls||r.url)){let i=r.urls||r.url;r.url&&!r.urls&&pi("RTCIceServer.url","RTCIceServer.urls");const s=typeof i=="string";return s&&(i=[i]),i=i.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!t?(t=!0,!0):o&&!t}),delete r.url,r.urls=s?i[0]:i,!!i.length}})}var Ys={exports:{}},Zs;function Qs(){return Zs||(Zs=1,function(n){var e={};e.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
1
+ import{PlaneGeometry as gs,ShaderChunk as Fa,Object3D as vs,Layers as hi,MeshBasicMaterial as _s,DoubleSide as sn,AdditiveBlending as bs,InstancedBufferAttribute as Ct,DynamicDrawUsage as ge,InstancedBufferGeometry as La,Uniform$1 as Le,ShaderMaterial as on,BufferGeometry as ar,BufferAttribute as Te,Mesh as an,MeshStandardMaterial as Va,MeshPhysicalMaterial as ja,Triangle as Pt,Vector3 as I,Plane as xs,Line3 as ht,Vector2 as Vt,Sphere as Ss,Matrix4 as Ve,Box3 as Ye,BackSide as Ja,REVISION as Ga,FrontSide as ws,BatchedMesh as Wa,Ray as Xa,Matrix3 as qa,Vector4 as cn}from"./three-Boa-jOq-.min.js";const ne={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function Ms(n){const e=await fetch(n);if(e.ok)return e.json();throw new Error(e.statusText)}async function Ha(n){return await Ms(`${n}/profilesList.json`)}async function Ya(n,e,t=null,r=!0){if(!n)throw new Error("No xrInputSource supplied");const i=await Ha(e);let s;if(n.profiles.some(c=>{const l=i[c];return l&&(s={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!t)throw new Error("No matching profile name found");const c=i[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);s={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const a=await Ms(s.profilePath);let o;if(r){let c;if(n.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[n.handedness],!c)throw new Error(`No matching handedness, ${n.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const Za={xAxis:0,yAxis:0,button:0,state:ne.ComponentState.DEFAULT};function Qa(n=0,e=0){let t=n,r=e;if(Math.sqrt(n*n+e*e)>1){const i=Math.atan2(e,n);t=Math.cos(i),r=Math.sin(i)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:r*.5+.5}}class Ka{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===ne.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Za)}updateFromComponent({xAxis:e,yAxis:t,button:r,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=Qa(e,t);switch(this.componentProperty){case ne.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case ne.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case ne.ComponentProperty.BUTTON:this.value=this.states.includes(i)?r:0;break;case ne.ComponentProperty.STATE:this.valueNodeProperty===ne.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class $a{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(r=>{const i=new Ka(t.visualResponses[r]);this.visualResponses[r]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:ne.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=ne.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=ne.ComponentState.PRESSED:(t.touched||this.values.button>ne.ButtonTouchThreshold)&&(this.values.state=ne.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===ne.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>ne.AxisTouchThreshold&&(this.values.state=ne.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===ne.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>ne.AxisTouchThreshold&&(this.values.state=ne.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class ec{constructor(e,t,r){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=r,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(i=>{const s=this.layoutDescription.components[i];this.components[i]=new $a(i,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const ln=2,Ze=4,ut=4,Ts=4,gt=new Int32Array(2),Cs=new Float32Array(gt.buffer),Ps=new Float64Array(gt.buffer),ui=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class yt{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?yt.ZERO:new yt(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}yt.ZERO=new yt(0,0);var hn;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(hn||(hn={}));class Or{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new Or(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new yt(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new yt(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return gt[0]=this.readInt32(e),Cs[0]}readFloat64(e){return gt[ui?0:1]=this.readInt32(e),gt[ui?1:0]=this.readInt32(e+4),Ps[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)}writeUint64(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)}writeFloat32(e,t){Cs[0]=t,this.writeInt32(e,gt[0])}writeFloat64(e,t){Ps[0]=t,this.writeInt32(e,gt[ui?0:1]),this.writeInt32(e+4,gt[ui?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Ze+ut)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<ut;t++)e+=String.fromCharCode(this.readInt8(this.position_+Ze+t));return e}__offset(e,t){const r=e-this.readInt32(e);return t<this.readInt16(r)?this.readInt16(r+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);const r=this.readInt32(e);let i="",s=0;if(e+=Ze,t===hn.UTF8_BYTES)return this.bytes_.subarray(e,e+r);for(;s<r;){let a;const o=this.readUint8(e+s++);if(o<192)a=o;else{const c=this.readUint8(e+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(e+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const h=this.readUint8(e+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|h&63}}}a<65536?i+=String.fromCharCode(a):(a-=65536,i+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return i}__union_with_string(e,t){return typeof e=="string"?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+Ze}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=ut)throw new Error("FlatBuffers: file identifier must be length "+ut);for(let t=0;t<ut;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+Ze+t))return!1;return!0}createLong(e,t){return yt.create(e,t)}createScalarList(e,t){const r=[];for(let i=0;i<t;++i)e(i)!==null&&r.push(e(i));return r}createObjList(e,t){const r=[];for(let i=0;i<t;++i){const s=e(i);s!==null&&r.push(s.unpack())}return r}}class ms{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let t;e?t=e:t=1024,this.bb=Or.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,t){e>this.minalign&&(this.minalign=e);const r=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space<r+e+t;){const i=this.bb.capacity();this.bb=ms.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,r){(this.force_defaults||t!=r)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,r){(this.force_defaults||t!=r)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,r){(this.force_defaults||t!=r)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,r){(this.force_defaults||!t.equals(r))&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,r){(this.force_defaults||t!=r)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,r){(this.force_defaults||t!=r)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,r){(this.force_defaults||t!=r)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,r){t!=r&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const t=e.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=t<<1,i=Or.allocate(r);return i.setPosition(r-t),i.bytes().set(e.bytes(),r-t),i}addOffset(e){this.prep(Ze,0),this.writeInt32(this.offset()-e+Ze)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);const r=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const i=2;this.addInt16(e-this.object_start);const s=(r+i)*ln;this.addInt16(s);let a=0;const o=this.space;e:for(t=0;t<this.vtables.length;t++){const c=this.bb.capacity()-this.vtables[t];if(s==this.bb.readInt16(c)){for(let l=ln;l<s;l+=ln)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue e;a=this.vtables[t];break}}return a?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,a-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,r){const i=r?Ts:0;if(t){const s=t;if(this.prep(this.minalign,Ze+ut+i),s.length!=ut)throw new Error("FlatBuffers: file identifier must be length "+ut);for(let a=ut-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,Ze+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(this.bb.readInt16(i+t)==0)throw new Error("FlatBuffers: field "+t+" must be set")}startVector(e,t,r){this.notNested(),this.vector_num_elems=t,this.prep(Ze,e*t),this.prep(r,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(!e)return 0;let t;if(e instanceof Uint8Array)t=e;else{t=[];let r=0;for(;r<e.length;){let i;const s=e.charCodeAt(r++);if(s<55296||s>=56320)i=s;else{const a=e.charCodeAt(r++);i=(s<<10)+a+-56613888}i<128?t.push(i):(i<2048?t.push(i>>6&31|192):(i<65536?t.push(i>>12&15|224):t.push(i>>18&7|240,i>>12&63|128),t.push(i>>6&63|128)),t.push(i&63|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);for(let r=0,i=this.space,s=this.bb.bytes();r<t.length;r++)s[i++]=t[r];return this.endVector()}createLong(e,t){return yt.create(e,t)}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const t=[];for(let r=0;r<e.length;++r){const i=e[r];if(i!==null)t.push(this.createObjectOffset(i));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e),this.endVector()}}function di(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Es={exports:{}},ks;function As(){return ks||(ks=1,function(n){var e={};e.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),e.useArrayBufferView=!e.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),n.exports.binaryFeatures=e;var t=n.exports.BlobBuilder;typeof window<"u"&&(t=n.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function r(){this._pieces=[],this._parts=[]}r.prototype.append=function(i){typeof i=="number"?this._pieces.push(i):(this.flush(),this._parts.push(i))},r.prototype.flush=function(){if(this._pieces.length>0){var i=new Uint8Array(this._pieces);e.useArrayBufferView||(i=i.buffer),this._parts.push(i),this._pieces=[]}},r.prototype.getBuffer=function(){if(this.flush(),e.useBlobBuilder){for(var i=new t,s=0,a=this._parts.length;s<a;s++)i.append(this._parts[s]);return i.getBlob()}else return new Blob(this._parts)},n.exports.BufferBuilder=r}(Es)),Es.exports}var un,Rs;function tc(){if(Rs)return un;Rs=1;var n=As().BufferBuilder,e=As().binaryFeatures,t={unpack:function(o){var c=new r(o);return c.unpack()},pack:function(o){var c=new i;c.pack(o);var l=c.getBuffer();return l}};un=t;function r(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}r.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},r.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},r.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},r.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},r.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},r.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},r.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},r.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},r.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},r.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},r.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,h="",u,d;l<o;)u=c[l],u<128?(h+=String.fromCharCode(u),l++):(u^192)<32?(d=(u^192)<<6|c[l+1]&63,h+=String.fromCharCode(d),l+=2):(d=(u&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,h+=String.fromCharCode(d),l+=3);return this.index+=o,h},r.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},r.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var h=this.unpack(),u=this.unpack();c[h]=u}return c},r.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,h=o&8388607|8388608;return(c===0?1:-1)*h*Math.pow(2,l-23)},r.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,h=(o>>20&2047)-1023,u=o&1048575|1048576,d=u*Math.pow(2,h-20)+c*Math.pow(2,h-52);return(l===0?1:-1)*d},r.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function i(){this.bufferBuilder=new n}i.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},i.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)e.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)e.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},i.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},i.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},i.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),h=o/Math.pow(2,l)-1,u=Math.floor(h*Math.pow(2,52)),d=Math.pow(2,32),p=c<<31|l+1023<<20|u/d&1048575,y=u%d;this.bufferBuilder.append(203),this.pack_int32(p),this.pack_int32(y)},i.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var h in o)o.hasOwnProperty(h)&&(this.pack(h),this.pack(o[h]))},i.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},i.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},i.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},i.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},i.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return un}var rc=tc();const Os=di(rc);let zs=!0,Bs=!0;function cr(n,e,t){const r=n.match(e);return r&&r.length>=t&&parseInt(r[t],10)}function jt(n,e,t){if(!n.RTCPeerConnection)return;const r=n.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(a,o){if(a!==e)return i.apply(this,arguments);const c=l=>{const h=t(l);h&&(o.handleEvent?o.handleEvent(h):o(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),i.apply(this,[a,c])};const s=r.removeEventListener;r.removeEventListener=function(a,o){if(a!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(o))return s.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}function ic(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(zs=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function nc(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(Bs=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function dn(){if(typeof window=="object"){if(zs)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function pi(n,e){Bs&&console.warn(n+" is deprecated, please use "+e+" instead.")}function sc(n){const e={browser:null,version:null};if(typeof n>"u"||!n.navigator)return e.browser="Not a browser.",e;const{navigator:t}=n;if(t.mozGetUserMedia)e.browser="firefox",e.version=cr(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||n.isSecureContext===!1&&n.webkitRTCPeerConnection&&!n.RTCIceGatherer)e.browser="chrome",e.version=cr(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=cr(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(n.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=cr(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=n.RTCRtpTransceiver&&"currentDirection"in n.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function Is(n){return Object.prototype.toString.call(n)==="[object Object]"}function Us(n){return Is(n)?Object.keys(n).reduce(function(e,t){const r=Is(n[t]),i=r?Us(n[t]):n[t],s=r&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):n}function pn(n,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?pn(n,n.get(e[r]),t):r.endsWith("Ids")&&e[r].forEach(i=>{pn(n,n.get(i),t)})}))}function Ns(n,e,t){const r=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return n.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{n.forEach(o=>{o.type===r&&o.trackId===a.id&&pn(n,o,i)})}),i}const Ds=dn;function Fs(n,e){const t=n&&n.navigator;if(!t.mediaDevices)return;const r=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const h=typeof o[l]=="object"?o[l]:{ideal:o[l]};h.exact!==void 0&&typeof h.exact=="number"&&(h.min=h.max=h.exact);const u=function(d,p){return d?d+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(h.ideal!==void 0){c.optional=c.optional||[];let d={};typeof h.ideal=="number"?(d[u("min",l)]=h.ideal,c.optional.push(d),d={},d[u("max",l)]=h.ideal,c.optional.push(d)):(d[u("",l)]=h.ideal,c.optional.push(d))}h.exact!==void 0&&typeof h.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[u("",l)]=h.exact):["min","max"].forEach(d=>{h[d]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[u(d,l)]=h[d])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},i=function(o,c){if(e.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(h,u,d){u in h&&!(d in h)&&(h[d]=h[u],delete h[u])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=r(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const h=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!h)){delete o.video.facingMode;let u;if(l.exact==="environment"||l.ideal==="environment"?u=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(u=["front"]),u)return t.mediaDevices.enumerateDevices().then(d=>{d=d.filter(y=>y.kind==="videoinput");let p=d.find(y=>u.some(g=>y.label.toLowerCase().includes(g)));return!p&&d.length&&u.includes("back")&&(p=d[d.length-1]),p&&(o.video.deviceId=l.exact?{exact:p.deviceId}:{ideal:p.deviceId}),o.video=r(o.video),Ds("chrome: "+JSON.stringify(o)),c(o)})}o.video=r(o.video)}return Ds("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){i(o,h=>{t.webkitGetUserMedia(h,c,u=>{l&&l(s(u))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(c){return i(c,l=>o(l).then(h=>{if(l.audio&&!h.getAudioTracks().length||l.video&&!h.getVideoTracks().length)throw h.getTracks().forEach(u=>{u.stop()}),new DOMException("","NotFoundError");return h},h=>Promise.reject(s(h))))}}}function oc(n,e){if(!(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices)&&n.navigator.mediaDevices){if(typeof e!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}n.navigator.mediaDevices.getDisplayMedia=function(t){return e(t).then(r=>{const i=t.video&&t.video.width,s=t.video&&t.video.height,a=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:a||3}},i&&(t.video.mandatory.maxWidth=i),s&&(t.video.mandatory.maxHeight=s),n.navigator.mediaDevices.getUserMedia(t)})}}}function Ls(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function Vs(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let i;n.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===r.track.id):i={track:r.track};const s=new Event("track");s.track=r.track,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)}),t.stream.getTracks().forEach(r=>{let i;n.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===r.id):i={track:r};const s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else jt(n,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function js(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(a,o){let c=i.apply(this,arguments);return c||(c=e(this,a),this._senders.push(c)),c};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(a){s.apply(this,arguments);const o=this._senders.indexOf(a);o!==-1&&this._senders.splice(o,1)}}const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],t.apply(this,[i]),i.getTracks().forEach(s=>{this._senders.push(e(this,s))})};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(s=>{const a=this._senders.find(o=>o.track===s);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const t=e.apply(this,[]);return t.forEach(r=>r._pc=this),t},Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Js(n){if(!n.RTCPeerConnection)return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[t,r,i]=arguments;if(arguments.length>0&&typeof t=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof t!="function"))return e.apply(this,[]);const s=function(o){const c={};return o.result().forEach(l=>{const h={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(u=>{h[u]=l.stat(u)}),c[h.id]=h}),c},a=function(o){return new Map(Object.keys(o).map(c=>[c,o[c]]))};if(arguments.length>=2){const o=function(c){r(a(s(c)))};return e.apply(this,[o,t])}return new Promise((o,c)=>{e.apply(this,[function(l){o(a(s(l)))},c])}).then(r,i)}}function Gs(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i});const r=n.RTCPeerConnection.prototype.addTrack;r&&(n.RTCPeerConnection.prototype.addTrack=function(){const i=r.apply(this,arguments);return i._pc=this,i}),n.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>Ns(s,i.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=t.apply(this,[]);return r.forEach(i=>i._pc=this),r}),jt(n,"track",r=>(r.receiver._pc=r.srcElement,r)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>Ns(i,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype&&"getStats"in n.RTCRtpReceiver.prototype))return;const e=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const t=arguments[0];let r,i,s;return this.getSenders().forEach(a=>{a.track===t&&(r?s=!0:r=a)}),this.getReceivers().forEach(a=>(a.track===t&&(i?s=!0:i=a),a.track===t)),s||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Ws(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const e=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(s,a){if(!a)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const o=e.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(o)===-1&&this._shimmedLocalStreams[a.id].push(o):this._shimmedLocalStreams[a.id]=[a,o],o};const t=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(c=>{if(this.getSenders().find(l=>l.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const a=this.getSenders();t.apply(this,arguments);const o=this.getSenders().filter(c=>a.indexOf(c)===-1);this._shimmedLocalStreams[s.id]=[s].concat(o)};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],r.apply(this,arguments)};const i=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(a=>{const o=this._shimmedLocalStreams[a].indexOf(s);o!==-1&&this._shimmedLocalStreams[a].splice(o,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),i.apply(this,arguments)}}function Xs(n,e){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Ws(n);const t=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const r=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(u=>u.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const h=new n.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}r.apply(this,[l])};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},n.RTCPeerConnection.prototype.addTrack=function(l,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const u=[].slice.call(arguments,1);if(u.length!==1||!u[0].getTracks().find(p=>p===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(p=>p.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const d=this._streams[h.id];if(d)d.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const p=new n.MediaStream([l]);this._streams[h.id]=p,this._reverseStreams[p.id]=h,this.addStream(p)}return this.getSenders().find(p=>p.track===l)};function s(l,h){let u=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(d=>{const p=l._reverseStreams[d],y=l._streams[p.id];u=u.replace(new RegExp(y.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:u})}function a(l,h){let u=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(d=>{const p=l._reverseStreams[d],y=l._streams[p.id];u=u.replace(new RegExp(p.id,"g"),y.id)}),new RTCSessionDescription({type:h.type,sdp:u})}["createOffer","createAnswer"].forEach(function(l){const h=n.RTCPeerConnection.prototype[l],u={[l](){const d=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[p=>{const y=s(this,p);d[0].apply(null,[y])},p=>{d[1]&&d[1].apply(null,p)},arguments[2]]):h.apply(this,arguments).then(p=>s(this,p))}};n.RTCPeerConnection.prototype[l]=u[l]});const o=n.RTCPeerConnection.prototype.setLocalDescription;n.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),n.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let h;Object.keys(this._streams).forEach(u=>{this._streams[u].getTracks().find(d=>l.track===d)&&(h=this._streams[u])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function fn(n,e){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const r=n.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};n.RTCPeerConnection.prototype[t]=i[t]})}function qs(n,e){jt(n,"negotiationneeded",t=>{const r=t.target;if(!((e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")&&r.signalingState!=="stable"))return t})}const Hs=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:qs,shimAddTrackRemoveTrack:Xs,shimAddTrackRemoveTrackWithNative:Ws,shimGetDisplayMedia:oc,shimGetSendersWithDtmf:js,shimGetStats:Js,shimGetUserMedia:Fs,shimMediaStream:Ls,shimOnTrack:Vs,shimPeerConnection:fn,shimSenderReceiverGetStats:Gs},Symbol.toStringTag,{value:"Module"}));function ac(n,e){let t=!1;return n=JSON.parse(JSON.stringify(n)),n.filter(r=>{if(r&&(r.urls||r.url)){let i=r.urls||r.url;r.url&&!r.urls&&pi("RTCIceServer.url","RTCIceServer.urls");const s=typeof i=="string";return s&&(i=[i]),i=i.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!t?(t=!0,!0):o&&!t}),delete r.url,r.urls=s?i[0]:i,!!i.length}})}var Ys={exports:{}},Zs;function Qs(){return Zs||(Zs=1,function(n){var e={};e.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
2
2
  `).map(function(r){return r.trim()})},e.splitSections=function(t){var r=t.split(`
3
3
  m=`);return r.map(function(i,s){return(s>0?"m="+i:i).trim()+`\r
4
4
  `})},e.getDescription=function(t){var r=e.splitSections(t);return r&&r[0]},e.getMediaSections=function(t){var r=e.splitSections(t);return r.shift(),r},e.matchPrefix=function(t,r){return e.splitLines(t).filter(function(i){return i.indexOf(r)===0})},e.parseCandidate=function(t){var r;t.indexOf("a=candidate:")===0?r=t.substring(12).split(" "):r=t.substring(10).split(" ");for(var i={foundation:r[0],component:parseInt(r[1],10),protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]},s=8;s<r.length;s+=2)switch(r[s]){case"raddr":i.relatedAddress=r[s+1];break;case"rport":i.relatedPort=parseInt(r[s+1],10);break;case"tcptype":i.tcpType=r[s+1];break;case"ufrag":i.ufrag=r[s+1],i.usernameFragment=r[s+1];break;default:i[r[s]]=r[s+1];break}return i},e.writeCandidate=function(t){var r=[];r.push(t.foundation),r.push(t.component),r.push(t.protocol.toUpperCase()),r.push(t.priority),r.push(t.address||t.ip),r.push(t.port);var i=t.type;return r.push("typ"),r.push(i),i!=="host"&&t.relatedAddress&&t.relatedPort&&(r.push("raddr"),r.push(t.relatedAddress),r.push("rport"),r.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(r.push("ufrag"),r.push(t.usernameFragment||t.ufrag)),"candidate:"+r.join(" ")},e.parseIceOptions=function(t){return t.substr(14).split(" ")},e.parseRtpMap=function(t){var r=t.substr(9).split(" "),i={payloadType:parseInt(r.shift(),10)};return r=r[0].split("/"),i.name=r[0],i.clockRate=parseInt(r[1],10),i.channels=r.length===3?parseInt(r[2],10):1,i.numChannels=i.channels,i},e.writeRtpMap=function(t){var r=t.payloadType;t.preferredPayloadType!==void 0&&(r=t.preferredPayloadType);var i=t.channels||t.numChannels||1;return"a=rtpmap:"+r+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
@@ -15,7 +15,7 @@ a=ice-pwd:`+t.password+`\r
15
15
  `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
16
16
  `,r.codecs.forEach(function(a){i+=e.writeRtpMap(a),i+=e.writeFmtp(a),i+=e.writeRtcpFb(a)});var s=0;return r.codecs.forEach(function(a){a.maxptime>s&&(s=a.maxptime)}),s>0&&(i+="a=maxptime:"+s+`\r
17
17
  `),i+=`a=rtcp-mux\r
18
- `,r.headerExtensions&&r.headerExtensions.forEach(function(a){i+=e.writeExtmap(a)}),i},e.parseRtpEncodingParameters=function(t){var r=[],i=e.parseRtpParameters(t),s=i.fecMechanisms.indexOf("RED")!==-1,a=i.fecMechanisms.indexOf("ULPFEC")!==-1,o=e.matchPrefix(t,"a=ssrc:").map(function(d){return e.parseSsrcMedia(d)}).filter(function(d){return d.attribute==="cname"}),c=o.length>0&&o[0].ssrc,l,h=e.matchPrefix(t,"a=ssrc-group:FID").map(function(d){var p=d.substr(17).split(" ");return p.map(function(y){return parseInt(y,10)})});h.length>0&&h[0].length>1&&h[0][0]===c&&(l=h[0][1]),i.codecs.forEach(function(d){if(d.name.toUpperCase()==="RTX"&&d.parameters.apt){var p={ssrc:c,codecPayloadType:parseInt(d.parameters.apt,10)};c&&l&&(p.rtx={ssrc:l}),r.push(p),s&&(p=JSON.parse(JSON.stringify(p)),p.fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(p))}}),r.length===0&&c&&r.push({ssrc:c});var u=e.matchPrefix(t,"b=");return u.length&&(u[0].indexOf("b=TIAS:")===0?u=parseInt(u[0].substr(7),10):u[0].indexOf("b=AS:")===0?u=parseInt(u[0].substr(5),10)*1e3*.95-2e3*8:u=void 0,r.forEach(function(d){d.maxBitrate=u})),r},e.parseRtcpParameters=function(t){var r={},i=e.matchPrefix(t,"a=ssrc:").map(function(o){return e.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var s=e.matchPrefix(t,"a=rtcp-rsize");r.reducedSize=s.length>0,r.compound=s.length===0;var a=e.matchPrefix(t,"a=rtcp-mux");return r.mux=a.length>0,r},e.parseMsid=function(t){var r,i=e.matchPrefix(t,"a=msid:");if(i.length===1)return r=i[0].substr(7).split(" "),{stream:r[0],track:r[1]};var s=e.matchPrefix(t,"a=ssrc:").map(function(a){return e.parseSsrcMedia(a)}).filter(function(a){return a.attribute==="msid"});if(s.length>0)return r=s[0].value.split(" "),{stream:r[0],track:r[1]}},e.parseSctpDescription=function(t){var r=e.parseMLine(t),i=e.matchPrefix(t,"a=max-message-size:"),s;i.length>0&&(s=parseInt(i[0].substr(19),10)),isNaN(s)&&(s=65536);var a=e.matchPrefix(t,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:r.fmt,maxMessageSize:s};var o=e.matchPrefix(t,"a=sctpmap:");if(o.length>0){var c=e.matchPrefix(t,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:s}}},e.writeSctpDescription=function(t,r){var i=[];return t.protocol!=="DTLS/SCTP"?i=["m="+t.kind+" 9 "+t.protocol+" "+r.protocol+`\r
18
+ `,r.headerExtensions&&r.headerExtensions.forEach(function(a){i+=e.writeExtmap(a)}),i},e.parseRtpEncodingParameters=function(t){var r=[],i=e.parseRtpParameters(t),s=i.fecMechanisms.indexOf("RED")!==-1,a=i.fecMechanisms.indexOf("ULPFEC")!==-1,o=e.matchPrefix(t,"a=ssrc:").map(function(d){return e.parseSsrcMedia(d)}).filter(function(d){return d.attribute==="cname"}),c=o.length>0&&o[0].ssrc,l,h=e.matchPrefix(t,"a=ssrc-group:FID").map(function(d){var p=d.substr(17).split(" ");return p.map(function(y){return parseInt(y,10)})});h.length>0&&h[0].length>1&&h[0][0]===c&&(l=h[0][1]),i.codecs.forEach(function(d){if(d.name.toUpperCase()==="RTX"&&d.parameters.apt){var p={ssrc:c,codecPayloadType:parseInt(d.parameters.apt,10)};c&&l&&(p.rtx={ssrc:l}),r.push(p),s&&(p=JSON.parse(JSON.stringify(p)),p.fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(p))}}),r.length===0&&c&&r.push({ssrc:c});var u=e.matchPrefix(t,"b=");return u.length&&(u[0].indexOf("b=TIAS:")===0?u=parseInt(u[0].substr(7),10):u[0].indexOf("b=AS:")===0?u=parseInt(u[0].substr(5),10)*1e3*.95-50*40*8:u=void 0,r.forEach(function(d){d.maxBitrate=u})),r},e.parseRtcpParameters=function(t){var r={},i=e.matchPrefix(t,"a=ssrc:").map(function(o){return e.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var s=e.matchPrefix(t,"a=rtcp-rsize");r.reducedSize=s.length>0,r.compound=s.length===0;var a=e.matchPrefix(t,"a=rtcp-mux");return r.mux=a.length>0,r},e.parseMsid=function(t){var r,i=e.matchPrefix(t,"a=msid:");if(i.length===1)return r=i[0].substr(7).split(" "),{stream:r[0],track:r[1]};var s=e.matchPrefix(t,"a=ssrc:").map(function(a){return e.parseSsrcMedia(a)}).filter(function(a){return a.attribute==="msid"});if(s.length>0)return r=s[0].value.split(" "),{stream:r[0],track:r[1]}},e.parseSctpDescription=function(t){var r=e.parseMLine(t),i=e.matchPrefix(t,"a=max-message-size:"),s;i.length>0&&(s=parseInt(i[0].substr(19),10)),isNaN(s)&&(s=65536);var a=e.matchPrefix(t,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:r.fmt,maxMessageSize:s};var o=e.matchPrefix(t,"a=sctpmap:");if(o.length>0){var c=e.matchPrefix(t,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:s}}},e.writeSctpDescription=function(t,r){var i=[];return t.protocol!=="DTLS/SCTP"?i=["m="+t.kind+" 9 "+t.protocol+" "+r.protocol+`\r
19
19
  `,`c=IN IP4 0.0.0.0\r
20
20
  `,"a=sctp-port:"+r.port+`\r
21
21
  `]:i=["m="+t.kind+" 9 "+t.protocol+" "+r.port+`\r
@@ -1118,4 +1118,4 @@ void main() {
1118
1118
  vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
1119
1119
 
1120
1120
  #include <fog_vertex>
1121
- }`;class rh extends ca{constructor(e){super(e),this.vector_=new z,this.vector2_=new z,this.vector3_=new z,this.quaternion_=new j,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new ar,this.indexBuffer=new Te(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(ge),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new Te(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(ge),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new Te(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(ge),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new Te(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(ge),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new Te(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(ge),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new Te(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(ge),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new Te(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(ge),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new Te(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(ge),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new tr(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=jn(this.settings.material.map.channel),e.map=new Le(this.settings.material.map),e.mapTransform=new Le(new tt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===A.Trail)this.material=new on({uniforms:e,defines:t,vertexShader:th,fragmentShader:eh,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||bs,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,r=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)r+=i.particles[s].previous.length*2}),r>this.maxParticles&&this.expandBuffers(r),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,h=this.settings.uTileCount,u=this.settings.vTileCount,d=1/h,p=1/u;for(let y=0;y<l;y++){const g=c[y],f=g.uvTile%u,m=Math.floor(g.uvTile/u+.001),v=g.previous.values();let _=v.next(),b=_.value,x=b;_.done||(_=v.next());let S;_.value!==void 0?S=_.value:S=x;for(let w=0;w<g.previous.length;w++,e+=2){if(this.positionBuffer.setXYZ(e,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(e+1,x.position.x,x.position.y,x.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(e+1,x.position.x,x.position.y,x.position.z)):(g.parentMatrix?this.vector_.copy(x.position).applyMatrix4(g.parentMatrix):this.vector_.copy(x.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,b.position.x,b.position.y,b.position.z),this.previousBuffer.setXYZ(e+1,b.position.x,b.position.y,b.position.z)):(g.parentMatrix?this.vector_.copy(b.position).applyMatrix4(g.parentMatrix):this.vector_.copy(b.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,S.position.x,S.position.y,S.position.z),this.nextBuffer.setXYZ(e+1,S.position.x,S.position.y,S.position.z)):(g.parentMatrix?this.vector_.copy(S.position).applyMatrix4(g.parentMatrix):this.vector_.copy(S.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,x.size),this.widthBuffer.setX(e+1,x.size);else if(g.parentMatrix)this.widthBuffer.setX(e,x.size),this.widthBuffer.setX(e+1,x.size);else{const C=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,x.size*C),this.widthBuffer.setX(e+1,x.size*C)}this.uvBuffer.setXY(e,(w/g.previous.length+f)*d,(u-m-1)*p),this.uvBuffer.setXY(e+1,(w/g.previous.length+f)*d,(u-m)*p),this.colorBuffer.setXYZW(e,x.color.x,x.color.y,x.color.z,x.color.w),this.colorBuffer.setXYZW(e+1,x.color.x,x.color.y,x.color.z,x.color.w),w+1<g.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),b=x,x=S,_.done||(_=v.next(),_.value!==void 0&&(S=_.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class li{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new Pt;this._triangleIndexToArea.length=0;let r=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),r+=t.getArea(),this._triangleIndexToArea.push(r);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new I,this._tempB=new I,this._tempC=new I,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const r=this._triangleIndexToArea.length-1;let i=0,s=r;const a=Math.random()*this._triangleIndexToArea[r];for(;i+1<s;){const p=Math.floor((i+s)/2);a<this._triangleIndexToArea[p]?s=p:i=p}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],h=t.getIndex().array[i*3+1],u=t.getIndex().array[i*3+2],d=t.getAttribute("position");this._tempA.fromBufferAttribute(d,l),this._tempB.fromBufferAttribute(d,h),this._tempC.fromBufferAttribute(d,u),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new li(t.geometries[e.geometry])}clone(){return new li(this._geometry)}update(e,t){}}zl({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:li,loadJSON:li.fromJSON}],behaviors:[]});class ys extends vs{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(ys.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let r;switch(t.renderMode){case A.Trail:r=new rh(t);break;case A.Mesh:case A.BillBoard:case A.VerticalBillBoard:case A.HorizontalBillBoard:case A.StretchedBillBoard:r=new $l(t);break}this.depthTexture&&r.applyDepthTexture(this.depthTexture),r.addSystem(e),this.batches.push(r),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(r)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,r)=>{r.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const ih=ys;jl(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const ha=Math.sqrt(5),nh=(ha-1)/4,he=(5-ha)/20,Ri=n=>Math.floor(n)|0,Oi=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function sh(n=Math.random){const e=oh(n),t=new Float64Array(e).map(a=>Oi[a%32*4]),r=new Float64Array(e).map(a=>Oi[a%32*4+1]),i=new Float64Array(e).map(a=>Oi[a%32*4+2]),s=new Float64Array(e).map(a=>Oi[a%32*4+3]);return function(a,o,c,l){let h,u,d,p,y;const g=(a+o+c+l)*nh,f=Ri(a+g),m=Ri(o+g),v=Ri(c+g),_=Ri(l+g),b=(f+m+v+_)*he,x=f-b,S=m-b,w=v-b,C=_-b,M=a-x,T=o-S,E=c-w,P=l-C;let k=0,R=0,U=0,N=0;M>T?k++:R++,M>E?k++:U++,M>P?k++:N++,T>E?R++:U++,T>P?R++:N++,E>P?U++:N++;const G=k>=3?1:0,B=R>=3?1:0,oe=U>=3?1:0,Q=N>=3?1:0,re=k>=2?1:0,$=R>=2?1:0,me=U>=2?1:0,ye=N>=2?1:0,ie=k>=1?1:0,H=R>=1?1:0,W=U>=1?1:0,rt=N>=1?1:0,ze=M-G+he,Xe=T-B+he,qe=E-oe+he,be=P-Q+he,Be=M-re+2*he,xe=T-$+2*he,it=E-me+2*he,nt=P-ye+2*he,Y=M-ie+3*he,He=T-H+3*he,st=E-W+3*he,Tt=P-rt+3*he,ot=M-1+4*he,at=T-1+4*he,ct=E-1+4*he,lt=P-1+4*he,Ie=f&255,Ue=m&255,Ne=v&255,De=_&255;let Fe=.6-M*M-T*T-E*E-P*P;if(Fe<0)h=0;else{const q=Ie+e[Ue+e[Ne+e[De]]];Fe*=Fe,h=Fe*Fe*(t[q]*M+r[q]*T+i[q]*E+s[q]*P)}let V=.6-ze*ze-Xe*Xe-qe*qe-be*be;if(V<0)u=0;else{const q=Ie+G+e[Ue+B+e[Ne+oe+e[De+Q]]];V*=V,u=V*V*(t[q]*ze+r[q]*Xe+i[q]*qe+s[q]*be)}let nr=.6-Be*Be-xe*xe-it*it-nt*nt;if(nr<0)d=0;else{const q=Ie+re+e[Ue+$+e[Ne+me+e[De+ye]]];nr*=nr,d=nr*nr*(t[q]*Be+r[q]*xe+i[q]*it+s[q]*nt)}let sr=.6-Y*Y-He*He-st*st-Tt*Tt;if(sr<0)p=0;else{const q=Ie+ie+e[Ue+H+e[Ne+W+e[De+rt]]];sr*=sr,p=sr*sr*(t[q]*Y+r[q]*He+i[q]*st+s[q]*Tt)}let or=.6-ot*ot-at*at-ct*ct-lt*lt;if(or<0)y=0;else{const q=Ie+1+e[Ue+1+e[Ne+1+e[De+1]]];or*=or,y=or*or*(t[q]*ot+r[q]*at+i[q]*ct+s[q]*lt)}return 27*(h+u+d+p+y)}}function oh(n){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const r=t+~~(n()*(256-t)),i=e[t];e[t]=e[r],e[r]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}class ah{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var J;(function(n){n.open="open",n.close="close",n.error="error",n.message="message",n.retry="retry",n.reconnect="reconnect"})(J||(J={}));class ua{constructor(e,t,r){var i,s,a,o,c,l,h,u,d,p,y,g,f,m,v;this._closedByUser=!1,this.handleOpenEvent=_=>this.handleEvent(J.open,_),this.handleErrorEvent=_=>this.handleEvent(J.error,_),this.handleCloseEvent=_=>this.handleEvent(J.close,_),this.handleMessageEvent=_=>this.handleEvent(J.message,_),this._url=e,this._protocols=t,this._options={buffer:r?.buffer,retry:{maxRetries:(i=r?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=r?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=r?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=r?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(h=(l=r?.listeners)===null||l===void 0?void 0:l.close)!==null&&h!==void 0?h:[]],error:[...(d=(u=r?.listeners)===null||u===void 0?void 0:u.error)!==null&&d!==void 0?d:[]],message:[...(y=(p=r?.listeners)===null||p===void 0?void 0:p.message)!==null&&y!==void 0?y:[]],retry:[...(f=(g=r?.listeners)===null||g===void 0?void 0:g.retry)!==null&&f!==void 0?f:[]],reconnect:[...(v=(m=r?.listeners)===null||m===void 0?void 0:m.reconnect)!==null&&v!==void 0?v:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,r){this._options.listeners[e].push({listener:t,options:r})}removeEventListener(e,t,r){const i=s=>s.listener!==t||s.options!==r;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(J.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(J.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(J.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(J.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(J.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(J.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(J.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(J.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const r=this._options.listeners[e],i=[];r.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case J.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case J.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const r={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(J.reconnect,{detail:r});this.dispatchEvent(J.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case J.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=r=>{const i=new CustomEvent(J.retry,{detail:r});this.handleEvent(J.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class ch{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(J.open,e,t),this}onClose(e,t){return this.addListener(J.close,e,t),this}onError(e,t){return this.addListener(J.error,e,t),this}onMessage(e,t){return this.addListener(J.message,e,t),this}onRetry(e,t){return this.addListener(J.retry,e,t),this}onReconnect(e,t){return this.addListener(J.reconnect,e,t),this}build(){return new ua(this._url,this._protocols,this._options)}addListener(e,t,r){var i,s,a,o,c,l,h,u,d,p,y,g,f,m,v,_,b,x,S,w,C;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(d=(u=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||u===void 0?void 0:u.error)!==null&&d!==void 0?d:[],message:(g=(y=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||y===void 0?void 0:y.message)!==null&&g!==void 0?g:[],retry:(v=(m=(f=this._options)===null||f===void 0?void 0:f.listeners)===null||m===void 0?void 0:m.retry)!==null&&v!==void 0?v:[],reconnect:(x=(b=(_=this._options)===null||_===void 0?void 0:_.listeners)===null||b===void 0?void 0:b.reconnect)!==null&&x!==void 0?x:[],[e]:[...(C=(w=(S=this._options)===null||S===void 0?void 0:S.listeners)===null||w===void 0?void 0:w[e])!==null&&C!==void 0?C:[],{listener:t,options:r}]}}),this}}const lh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:ah,Websocket:ua,WebsocketBuilder:ch,get WebsocketEvent(){return J}},Symbol.toStringTag,{value:"Module"})),Jn=0,da=1,pa=2,Gn=2,Wn=1.25,fa=1,br=32,zi=65535,hh=Math.pow(2,-24),Xn=Symbol("SKIP_GENERATION");function uh(n){return n.index?n.index.count:n.attributes.position.count}function Xt(n){return uh(n)/3}function dh(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function ph(n,e){if(!n.index){const t=n.attributes.position.count,r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=dh(t,r);n.setIndex(new Te(i,1));for(let s=0;s<t;s++)i[s]=s}}function ma(n,e){const t=Xt(n),r=e||n.drawRange,i=r.start/3,s=(r.start+r.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function ya(n,e){if(!n.groups||!n.groups.length)return ma(n,e);const t=[],r=new Set,i=e||n.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of n.groups){const l=c.start/3,h=(c.start+c.count)/3;r.add(Math.max(s,l)),r.add(Math.min(a,h))}const o=Array.from(r.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],h=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(h-l)})}return t}function fh(n,e){const t=Xt(n),r=ya(n,e).sort((a,o)=>a.offset-o.offset),i=r[r.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return r.forEach(({count:a})=>s+=a),t!==s}function qn(n,e,t,r,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,h=-1/0,u=1/0,d=1/0,p=1/0,y=-1/0,g=-1/0,f=-1/0;for(let m=e*6,v=(e+t)*6;m<v;m+=6){const _=n[m+0],b=n[m+1],x=_-b,S=_+b;x<s&&(s=x),S>c&&(c=S),_<u&&(u=_),_>y&&(y=_);const w=n[m+2],C=n[m+3],M=w-C,T=w+C;M<a&&(a=M),T>l&&(l=T),w<d&&(d=w),w>g&&(g=w);const E=n[m+4],P=n[m+5],k=E-P,R=E+P;k<o&&(o=k),R>h&&(h=R),E<p&&(p=E),E>f&&(f=E)}r[0]=s,r[1]=a,r[2]=o,r[3]=c,r[4]=l,r[5]=h,i[0]=u,i[1]=d,i[2]=p,i[3]=y,i[4]=g,i[5]=f}function mh(n,e=null,t=null,r=null){const i=n.attributes.position,s=n.index?n.index.array:null,a=Xt(n),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,r=a):(c=e,t=t||0,r=r||a);const l=i.array,h=i.offset||0;let u=3;i.isInterleavedBufferAttribute&&(u=i.data.stride);const d=["getX","getY","getZ"];for(let p=t;p<t+r;p++){const y=p*3,g=p*6;let f=y+0,m=y+1,v=y+2;s&&(f=s[f],m=s[m],v=s[v]),o||(f=f*u+h,m=m*u+h,v=v*u+h);for(let _=0;_<3;_++){let b,x,S;o?(b=i[d[_]](f),x=i[d[_]](m),S=i[d[_]](v)):(b=l[f+_],x=l[m+_],S=l[v+_]);let w=b;x<w&&(w=x),S<w&&(w=S);let C=b;x>C&&(C=x),S>C&&(C=S);const M=(C-w)/2,T=_*2;c[g+T+0]=w+M,c[g+T+1]=M+(Math.abs(w)+M)*hh}}return c}function Z(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function ga(n){let e=-1,t=-1/0;for(let r=0;r<3;r++){const i=n[r+3]-n[r];i>t&&(t=i,e=r)}return e}function va(n,e){e.set(n)}function _a(n,e,t){let r,i;for(let s=0;s<3;s++){const a=s+3;r=n[s],i=e[s],t[s]=r<i?r:i,r=n[a],i=e[a],t[a]=r>i?r:i}}function Bi(n,e,t){for(let r=0;r<3;r++){const i=e[n+2*r],s=e[n+2*r+1],a=i-s,o=i+s;a<t[r]&&(t[r]=a),o>t[r+3]&&(t[r+3]=o)}}function xr(n){const e=n[3]-n[0],t=n[4]-n[1],r=n[5]-n[2];return 2*(e*t+t*r+r*e)}const ft=32,yh=(n,e)=>n.candidate-e.candidate,bt=new Array(ft).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ii=new Float32Array(6);function gh(n,e,t,r,i,s){let a=-1,o=0;if(s===Jn)a=ga(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===da)a=ga(n),a!==-1&&(o=vh(t,r,i,a));else if(s===pa){const c=xr(n);let l=Wn*i;const h=r*6,u=(r+i)*6;for(let d=0;d<3;d++){const p=e[d],y=(e[d+3]-p)/ft;if(i<ft/4){const g=[...bt];g.length=i;let f=0;for(let v=h;v<u;v+=6,f++){const _=g[f];_.candidate=t[v+2*d],_.count=0;const{bounds:b,leftCacheBounds:x,rightCacheBounds:S}=_;for(let w=0;w<3;w++)S[w]=1/0,S[w+3]=-1/0,x[w]=1/0,x[w+3]=-1/0,b[w]=1/0,b[w+3]=-1/0;Bi(v,t,b)}g.sort(yh);let m=i;for(let v=0;v<m;v++){const _=g[v];for(;v+1<m&&g[v+1].candidate===_.candidate;)g.splice(v+1,1),m--}for(let v=h;v<u;v+=6){const _=t[v+2*d];for(let b=0;b<m;b++){const x=g[b];_>=x.candidate?Bi(v,t,x.rightCacheBounds):(Bi(v,t,x.leftCacheBounds),x.count++)}}for(let v=0;v<m;v++){const _=g[v],b=_.count,x=i-_.count,S=_.leftCacheBounds,w=_.rightCacheBounds;let C=0;b!==0&&(C=xr(S)/c);let M=0;x!==0&&(M=xr(w)/c);const T=fa+Wn*(C*b+M*x);T<l&&(a=d,l=T,o=_.candidate)}}else{for(let m=0;m<ft;m++){const v=bt[m];v.count=0,v.candidate=p+y+m*y;const _=v.bounds;for(let b=0;b<3;b++)_[b]=1/0,_[b+3]=-1/0}for(let m=h;m<u;m+=6){let v=~~((t[m+2*d]-p)/y);v>=ft&&(v=ft-1);const _=bt[v];_.count++,Bi(m,t,_.bounds)}const g=bt[ft-1];va(g.bounds,g.rightCacheBounds);for(let m=ft-2;m>=0;m--){const v=bt[m],_=bt[m+1];_a(v.bounds,_.rightCacheBounds,v.rightCacheBounds)}let f=0;for(let m=0;m<ft-1;m++){const v=bt[m],_=v.count,b=v.bounds,x=bt[m+1].rightCacheBounds;_!==0&&(f===0?va(b,Ii):_a(b,Ii,Ii)),f+=_;let S=0,w=0;f!==0&&(S=xr(Ii)/c);const C=i-f;C!==0&&(w=xr(x)/c);const M=fa+Wn*(S*f+w*C);M<l&&(a=d,l=M,o=v.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function vh(n,e,t,r){let i=0;for(let s=e,a=e+t;s<a;s++)i+=n[s*6+r*2];return i/t}class Hn{constructor(){this.boundingData=new Float32Array(6)}}function _h(n,e,t,r,i,s){let a=r,o=r+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let h=0;h<3;h++){let u=e[a*3+h];e[a*3+h]=e[o*3+h],e[o*3+h]=u}for(let h=0;h<6;h++){let u=t[a*6+h];t[a*6+h]=t[o*6+h],t[o*6+h]=u}a++,o--}else return a}}function bh(n,e,t,r,i,s){let a=r,o=r+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let h=n[a];n[a]=n[o],n[o]=h;for(let u=0;u<6;u++){let d=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=d}a++,o--}else return a}}function we(n,e){return e[n+15]===65535}function Pe(n,e){return e[n+6]}function Ee(n,e){return e[n+14]}function ke(n){return n+8}function Ae(n,e){return e[n+6]}function ba(n,e){return e[n+7]}let xa,Sr,Ui,Sa;const xh=Math.pow(2,32);function Yn(n){return"count"in n?1:1+Yn(n.left)+Yn(n.right)}function Sh(n,e,t){return xa=new Float32Array(t),Sr=new Uint32Array(t),Ui=new Uint16Array(t),Sa=new Uint8Array(t),Zn(n,e)}function Zn(n,e){const t=n/4,r=n/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)xa[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;Sa.set(new Uint8Array(a),n);for(let o=n,c=n+a.byteLength;o<c;o+=br){const l=o/2;we(l,Ui)||(Sr[o/4+6]+=t)}return n+a.byteLength}else{const a=e.offset,o=e.count;return Sr[t+6]=a,Ui[r+14]=o,Ui[r+15]=zi,n+br}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=Zn(n+br,a),l/4>xh)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Sr[t+6]=l/4,l=Zn(l,o),Sr[t+7]=c,l}}function wh(n,e){const t=(n.index?n.index.count:n.attributes.position.count)/3,r=t>2**16,i=r?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),a=r?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Mh(n,e,t,r,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:h}=i,u=n._indirectBuffer,d=n.geometry,p=d.index?d.index.array:null,y=h?bh:_h,g=Xt(d),f=new Float32Array(6);let m=!1;const v=new Hn;return qn(e,t,r,v.boundingData,f),b(v,t,r,f),v;function _(x){l&&l(x/g)}function b(x,S,w,C=null,M=0){if(!m&&M>=s&&(m=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),w<=o||M>=s)return _(S+w),x.offset=S,x.count=w,x;const T=gh(x.boundingData,C,e,S,w,c);if(T.axis===-1)return _(S+w),x.offset=S,x.count=w,x;const E=y(u,p,e,S,w,T);if(E===S||E===S+w)_(S+w),x.offset=S,x.count=w;else{x.splitAxis=T.axis;const P=new Hn,k=S,R=E-S;x.left=P,qn(e,k,R,P.boundingData,f),b(P,k,R,f,M+1);const U=new Hn,N=E,G=w-R;x.right=U,qn(e,N,G,U.boundingData,f),b(U,N,G,f,M+1)}return x}}function Th(n,e){const t=n.geometry;e.indirect&&(n._indirectBuffer=wh(t,e.useSharedArrayBuffer),fh(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),n._indirectBuffer||ph(t,e);const r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=mh(t),s=e.indirect?ma(t,e.range):ya(t,e.range);n._roots=s.map(a=>{const o=Mh(n,i,a.offset,a.count,e),c=Yn(o),l=new r(br*c);return Sh(0,o,l),l})}class mt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let r=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s][t];r=o<r?o:r,i=o>i?o:i}this.min=r,this.max=i}setFromPoints(e,t){let r=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);r=c<r?c:r,i=c>i?c:i}this.min=r,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}mt.prototype.setFromBox=function(){const n=new I;return function(e,t){const r=t.min,i=t.max;let s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){n.x=r.x*o+i.x*(1-o),n.y=r.y*c+i.y*(1-c),n.z=r.z*l+i.z*(1-l);const h=e.dot(n);s=Math.min(h,s),a=Math.max(h,a)}this.min=s,this.max=a}}();const Ch=function(){const n=new I,e=new I,t=new I;return function(r,i,s){const a=r.start,o=n,c=i.start,l=e;t.subVectors(a,c),n.subVectors(r.end,r.start),e.subVectors(i.end,i.start);const h=t.dot(l),u=l.dot(o),d=l.dot(l),p=t.dot(o),y=o.dot(o)*d-u*u;let g,f;y!==0?g=(h*u-p*d)/y:g=0,f=(h+g*u)/d,s.x=g,s.y=f}}(),Qn=function(){const n=new Vt,e=new I,t=new I;return function(r,i,s,a){Ch(r,i,n);let o=n.x,c=n.y;if(o>=0&&o<=1&&c>=0&&c<=1){r.at(o,s),i.at(c,a);return}else if(o>=0&&o<=1){c<0?i.at(0,a):i.at(1,a),r.closestPointToPoint(a,!0,s);return}else if(c>=0&&c<=1){o<0?r.at(0,s):r.at(1,s),i.closestPointToPoint(s,!0,a);return}else{let l;o<0?l=r.start:l=r.end;let h;c<0?h=i.start:h=i.end;const u=e,d=t;if(r.closestPointToPoint(h,!0,e),i.closestPointToPoint(l,!0,t),u.distanceToSquared(h)<=d.distanceToSquared(l)){s.copy(u),a.copy(h);return}else{s.copy(l),a.copy(d);return}}}}(),Ph=function(){const n=new I,e=new I,t=new xs,r=new ht;return function(i,s){const{radius:a,center:o}=i,{a:c,b:l,c:h}=s;if(r.start=c,r.end=l,r.closestPointToPoint(o,!0,n).distanceTo(o)<=a||(r.start=c,r.end=h,r.closestPointToPoint(o,!0,n).distanceTo(o)<=a)||(r.start=l,r.end=h,r.closestPointToPoint(o,!0,n).distanceTo(o)<=a))return!0;const u=s.getPlane(t);if(Math.abs(u.distanceToPoint(o))<=a){const d=u.projectPoint(o,e);if(s.containsPoint(d))return!0}return!1}}(),Eh=1e-15;function Kn(n){return Math.abs(n)<Eh}class Re extends Pt{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new mt),this.points=[this.a,this.b,this.c],this.sphere=new Ss,this.plane=new xs,this.needsUpdate=!0}intersectsSphere(e){return Ph(e,this)}update(){const e=this.a,t=this.b,r=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,i);const u=s[2],d=a[2];u.subVectors(t,r),d.setFromPoints(u,i);const p=s[3],y=a[3];p.subVectors(r,e),y.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Re.prototype.closestPointToSegment=function(){const n=new I,e=new I,t=new ht;return function(r,i=null,s=null){const{start:a,end:o}=r,c=this.points;let l,h=1/0;for(let u=0;u<3;u++){const d=(u+1)%3;t.start.copy(c[u]),t.end.copy(c[d]),Qn(t,r,n,e),l=n.distanceToSquared(e),l<h&&(h=l,i&&i.copy(n),s&&s.copy(e))}return this.closestPointToPoint(a,n),l=a.distanceToSquared(n),l<h&&(h=l,i&&i.copy(n),s&&s.copy(a)),this.closestPointToPoint(o,n),l=o.distanceToSquared(n),l<h&&(h=l,i&&i.copy(n),s&&s.copy(o)),Math.sqrt(h)}}(),Re.prototype.intersectsTriangle=function(){const n=new Re,e=new Array(3),t=new Array(3),r=new mt,i=new mt,s=new I,a=new I,o=new I,c=new I,l=new I,h=new ht,u=new ht,d=new ht,p=new I;function y(g,f,m){const v=g.points;let _=0,b=-1;for(let x=0;x<3;x++){const{start:S,end:w}=h;S.copy(v[x]),w.copy(v[(x+1)%3]),h.delta(a);const C=Kn(f.distanceToPoint(S));if(Kn(f.normal.dot(a))&&C){m.copy(h),_=2;break}const M=f.intersectLine(h,p);if(!M&&C&&p.copy(S),(M||C)&&!Kn(p.distanceTo(w))){if(_<=1)(_===1?m.start:m.end).copy(p),C&&(b=_);else if(_>=2){(b===1?m.start:m.end).copy(p),_=2;break}if(_++,_===2&&b===-1)break}}return _}return function(g,f=null,m=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(n.copy(g),n.update(),g=n);const v=this.plane,_=g.plane;if(Math.abs(v.normal.dot(_.normal))>1-1e-10){const b=this.satBounds,x=this.satAxes;t[0]=g.a,t[1]=g.b,t[2]=g.c;for(let C=0;C<4;C++){const M=b[C],T=x[C];if(r.setFromPoints(T,t),M.isSeparated(r))return!1}const S=g.satBounds,w=g.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const M=S[C],T=w[C];if(r.setFromPoints(T,e),M.isSeparated(r))return!1}for(let C=0;C<4;C++){const M=x[C];for(let T=0;T<4;T++){const E=w[T];if(s.crossVectors(M,E),r.setFromPoints(s,e),i.setFromPoints(s,t),r.isSeparated(i))return!1}}return f&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),f.start.set(0,0,0),f.end.set(0,0,0)),!0}else{const b=y(this,_,u);if(b===1&&g.containsPoint(u.end))return f&&(f.start.copy(u.end),f.end.copy(u.end)),!0;if(b!==2)return!1;const x=y(g,v,d);if(x===1&&this.containsPoint(d.end))return f&&(f.start.copy(d.end),f.end.copy(d.end)),!0;if(x!==2)return!1;if(u.delta(o),d.delta(c),o.dot(c)<0){let P=d.start;d.start=d.end,d.end=P}const S=u.start.dot(o),w=u.end.dot(o),C=d.start.dot(o),M=d.end.dot(o),T=w<C,E=S<M;return S!==M&&C!==w&&T===E?!1:(f&&(l.subVectors(u.start,d.start),l.dot(o)>0?f.start.copy(u.start):f.start.copy(d.start),l.subVectors(u.end,d.end),l.dot(o)<0?f.end.copy(u.end):f.end.copy(d.end)),!0)}}}(),Re.prototype.distanceToPoint=function(){const n=new I;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}(),Re.prototype.distanceToTriangle=function(){const n=new I,e=new I,t=["a","b","c"],r=new ht,i=new ht;return function(s,a=null,o=null){const c=a||o?r:null;if(this.intersectsTriangle(s,c))return(a||o)&&(a&&c.getCenter(a),o&&c.getCenter(o)),0;let l=1/0;for(let h=0;h<3;h++){let u;const d=t[h],p=s[d];this.closestPointToPoint(p,n),u=p.distanceToSquared(n),u<l&&(l=u,a&&a.copy(n),o&&o.copy(p));const y=this[d];s.closestPointToPoint(y,n),u=y.distanceToSquared(n),u<l&&(l=u,a&&a.copy(y),o&&o.copy(n))}for(let h=0;h<3;h++){const u=t[h],d=t[(h+1)%3];r.set(this[u],this[d]);for(let p=0;p<3;p++){const y=t[p],g=t[(p+1)%3];i.set(s[y],s[g]),Qn(r,i,n,e);const f=n.distanceToSquared(e);f<l&&(l=f,a&&a.copy(n),o&&o.copy(e))}}return Math.sqrt(l)}}();class fe{constructor(e,t,r){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new Ve,this.invMatrix=new Ve,this.points=new Array(8).fill().map(()=>new I),this.satAxes=new Array(3).fill().map(()=>new I),this.satBounds=new Array(3).fill().map(()=>new mt),this.alignedSatBounds=new Array(3).fill().map(()=>new mt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),r&&this.matrix.copy(r)}set(e,t,r){this.min.copy(e),this.max.copy(t),this.matrix.copy(r),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}fe.prototype.update=function(){return function(){const n=this.matrix,e=this.min,t=this.max,r=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){const u=1*c|2*l|4*h,d=r[u];d.x=c?t.x:e.x,d.y=l?t.y:e.y,d.z=h?t.z:e.z,d.applyMatrix4(n)}const i=this.satBounds,s=this.satAxes,a=r[0];for(let c=0;c<3;c++){const l=s[c],h=i[c],u=1<<c,d=r[u];l.subVectors(a,d),h.setFromPoints(l,r)}const o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),fe.prototype.intersectsBox=function(){const n=new mt;return function(e){this.needsUpdate&&this.update();const t=e.min,r=e.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(n.min=t.x,n.max=r.x,a[0].isSeparated(n)||(n.min=t.y,n.max=r.y,a[1].isSeparated(n))||(n.min=t.z,n.max=r.z,a[2].isSeparated(n)))return!1;for(let o=0;o<3;o++){const c=s[o],l=i[o];if(n.setFromBox(c,e),l.isSeparated(n))return!1}return!0}}(),fe.prototype.intersectsTriangle=function(){const n=new Re,e=new Array(3),t=new mt,r=new mt,i=new I;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(n.copy(s),n.update(),s=n);const a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let u=0;u<3;u++){const d=a[u],p=o[u];if(t.setFromPoints(p,e),d.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,h=this.points;for(let u=0;u<3;u++){const d=c[u],p=l[u];if(t.setFromPoints(p,h),d.isSeparated(t))return!1}for(let u=0;u<3;u++){const d=o[u];for(let p=0;p<4;p++){const y=l[p];if(i.crossVectors(d,y),t.setFromPoints(i,e),r.setFromPoints(i,h),t.isSeparated(r))return!1}}return!0}}(),fe.prototype.closestPointToPoint=function(){return function(n,e){return this.needsUpdate&&this.update(),e.copy(n).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),fe.prototype.distanceToPoint=function(){const n=new I;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}(),fe.prototype.distanceToBox=function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new ht),t=new Array(12).fill().map(()=>new ht),r=new I,i=new I;return function(s,a=0,o=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||c)&&(s.getCenter(i),this.closestPointToPoint(i,r),s.closestPointToPoint(r,i),o&&o.copy(r),c&&c.copy(i)),0;const l=a*a,h=s.min,u=s.max,d=this.points;let p=1/0;for(let g=0;g<8;g++){const f=d[g];i.copy(f).clamp(h,u);const m=f.distanceToSquared(i);if(m<p&&(p=m,o&&o.copy(f),c&&c.copy(i),m<l))return Math.sqrt(m)}let y=0;for(let g=0;g<3;g++)for(let f=0;f<=1;f++)for(let m=0;m<=1;m++){const v=(g+1)%3,_=(g+2)%3,b=f<<v|m<<_,x=1<<g|f<<v|m<<_,S=d[b],w=d[x];e[y].set(S,w);const C=n[g],M=n[v],T=n[_],E=t[y],P=E.start,k=E.end;P[C]=h[C],P[M]=f?h[M]:u[M],P[T]=m?h[T]:u[M],k[C]=u[C],k[M]=f?h[M]:u[M],k[T]=m?h[T]:u[M],y++}for(let g=0;g<=1;g++)for(let f=0;f<=1;f++)for(let m=0;m<=1;m++){i.x=g?u.x:h.x,i.y=f?u.y:h.y,i.z=m?u.z:h.z,this.closestPointToPoint(i,r);const v=i.distanceToSquared(r);if(v<p&&(p=v,o&&o.copy(r),c&&c.copy(i),v<l))return Math.sqrt(v)}for(let g=0;g<12;g++){const f=e[g];for(let m=0;m<12;m++){const v=t[m];Qn(f,v,r,i);const _=r.distanceToSquared(i);if(_<p&&(p=_,o&&o.copy(r),c&&c.copy(i),_<l))return Math.sqrt(_)}}return Math.sqrt(p)}}();class $n{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class kh extends $n{constructor(){super(()=>new Re)}}const Oe=new kh;class Ah{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=r=>{t&&e.push(t),t=r,this.float32Array=new Float32Array(r),this.uint16Array=new Uint16Array(r),this.uint32Array=new Uint32Array(r)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const X=new Ah;let xt,qt;const Ht=[],Ni=new $n(()=>new Ye);function Rh(n,e,t,r,i,s){xt=Ni.getPrimitive(),qt=Ni.getPrimitive(),Ht.push(xt,qt),X.setBuffer(n._roots[e]);const a=es(0,n.geometry,t,r,i,s);X.clearBuffer(),Ni.releasePrimitive(xt),Ni.releasePrimitive(qt),Ht.pop(),Ht.pop();const o=Ht.length;return o>0&&(qt=Ht[o-1],xt=Ht[o-2]),a}function es(n,e,t,r,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=X;let h=n*2;if(we(h,c)){const u=Pe(n,l),d=Ee(h,c);return Z(n,o,xt),r(u,d,!1,a,s+n,xt)}else{let u=function(E){const{uint16Array:P,uint32Array:k}=X;let R=E*2;for(;!we(R,P);)E=ke(E),R=E*2;return Pe(E,k)},d=function(E){const{uint16Array:P,uint32Array:k}=X;let R=E*2;for(;!we(R,P);)E=Ae(E,k),R=E*2;return Pe(E,k)+Ee(R,P)};const p=ke(n),y=Ae(n,l);let g=p,f=y,m,v,_,b;if(i&&(_=xt,b=qt,Z(g,o,_),Z(f,o,b),m=i(_),v=i(b),v<m)){g=y,f=p;const E=m;m=v,v=E,_=b}_||(_=xt,Z(g,o,_));const x=we(g*2,c),S=t(_,x,m,a+1,s+g);let w;if(S===Gn){const E=u(g),P=d(g)-E;w=r(E,P,!0,a+1,s+g,_)}else w=S&&es(g,e,t,r,i,s,a+1);if(w)return!0;b=qt,Z(f,o,b);const C=we(f*2,c),M=t(b,C,v,a+1,s+f);let T;if(M===Gn){const E=u(f),P=d(f)-E;T=r(E,P,!0,a+1,s+f,b)}else T=M&&es(f,e,t,r,i,s,a+1);return!!T}}const wr=new I,ts=new I;function Oh(n,e,t={},r=0,i=1/0){const s=r*r,a=i*i;let o=1/0,c=null;if(n.shapecast({boundsTraverseOrder:h=>(wr.copy(e).clamp(h.min,h.max),wr.distanceToSquared(e)),intersectsBounds:(h,u,d)=>d<o&&d<a,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,wr);const d=e.distanceToSquared(wr);return d<o&&(ts.copy(wr),o=d,c=u),d<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(ts):t.point=ts.clone(),t.distance=l,t.faceIndex=c,t}const zh=parseInt(Ga)>=169,At=new I,Rt=new I,Ot=new I,Di=new Vt,Fi=new Vt,Li=new Vt,wa=new I,Ma=new I,Ta=new I,Mr=new I;function Bh(n,e,t,r,i,s,a,o){let c;if(s===Ja?c=n.intersectTriangle(r,t,e,!0,i):c=n.intersectTriangle(e,t,r,s!==sn,i),c===null)return null;const l=n.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function Ih(n,e,t,r,i,s,a,o,c,l,h){At.fromBufferAttribute(e,s),Rt.fromBufferAttribute(e,a),Ot.fromBufferAttribute(e,o);const u=Bh(n,At,Rt,Ot,Mr,c,l,h);if(u){const d=new I;Pt.getBarycoord(Mr,At,Rt,Ot,d),r&&(Di.fromBufferAttribute(r,s),Fi.fromBufferAttribute(r,a),Li.fromBufferAttribute(r,o),u.uv=Pt.getInterpolation(Mr,At,Rt,Ot,Di,Fi,Li,new Vt)),i&&(Di.fromBufferAttribute(i,s),Fi.fromBufferAttribute(i,a),Li.fromBufferAttribute(i,o),u.uv1=Pt.getInterpolation(Mr,At,Rt,Ot,Di,Fi,Li,new Vt)),t&&(wa.fromBufferAttribute(t,s),Ma.fromBufferAttribute(t,a),Ta.fromBufferAttribute(t,o),u.normal=Pt.getInterpolation(Mr,At,Rt,Ot,wa,Ma,Ta,new I),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const p={a:s,b:a,c:o,normal:new I,materialIndex:0};Pt.getNormal(At,Rt,Ot,p.normal),u.face=p,u.faceIndex=s,zh&&(u.barycoord=d)}return u}function Vi(n,e,t,r,i,s,a){const o=r*3;let c=o+0,l=o+1,h=o+2;const u=n.index;n.index&&(c=u.getX(c),l=u.getX(l),h=u.getX(h));const{position:d,normal:p,uv:y,uv1:g}=n.attributes,f=Ih(t,d,p,y,g,c,l,h,e,s,a);return f?(f.faceIndex=r,i&&i.push(f),f):null}function te(n,e,t,r){const i=n.a,s=n.b,a=n.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=r.getX(o),i.y=r.getY(o),i.z=r.getZ(o),s.x=r.getX(c),s.y=r.getY(c),s.z=r.getZ(c),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l)}function Uh(n,e,t,r,i,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let h=r,u=r+i;h<u;h++)Vi(c,e,t,h,s,a,o)}function Nh(n,e,t,r,i,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,h=null;for(let u=r,d=r+i;u<d;u++){let p;p=Vi(o,e,t,u,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function Dh(n,e,t,r,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=n,u=e+n;h<u;h++){let d;if(d=h,te(a,d*3,c,l),a.needsUpdate=!0,r(a,d,i,s))return!0}return!1}function Fh(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,r=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=n._roots;for(let d=0,p=h.length;d<p;d++)s=h[d],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),u(0,l),l+=s.byteLength;function u(d,p,y=!1){const g=d*2;if(o[g+15]===zi){const f=a[d+6],m=o[g+14];let v=1/0,_=1/0,b=1/0,x=-1/0,S=-1/0,w=-1/0;for(let C=3*f,M=3*(f+m);C<M;C++){let T=r[C];const E=i.getX(T),P=i.getY(T),k=i.getZ(T);E<v&&(v=E),E>x&&(x=E),P<_&&(_=P),P>S&&(S=P),k<b&&(b=k),k>w&&(w=k)}return c[d+0]!==v||c[d+1]!==_||c[d+2]!==b||c[d+3]!==x||c[d+4]!==S||c[d+5]!==w?(c[d+0]=v,c[d+1]=_,c[d+2]=b,c[d+3]=x,c[d+4]=S,c[d+5]=w,!0):!1}else{const f=d+8,m=a[d+6],v=f+p,_=m+p;let b=y,x=!1,S=!1;e?b||(x=e.has(v),S=e.has(_),b=!x&&!S):(x=!0,S=!0);const w=b||x,C=b||S;let M=!1;w&&(M=u(f,p,b));let T=!1;C&&(T=u(m,p,b));const E=M||T;if(E)for(let P=0;P<3;P++){const k=f+P,R=m+P,U=c[k],N=c[k+3],G=c[R],B=c[R+3];c[d+P]=U<G?U:G,c[d+P+3]=N>B?N:B}return E}}}function St(n,e,t,r,i){let s,a,o,c,l,h;const u=1/t.direction.x,d=1/t.direction.y,p=1/t.direction.z,y=t.origin.x,g=t.origin.y,f=t.origin.z;let m=e[n],v=e[n+3],_=e[n+1],b=e[n+3+1],x=e[n+2],S=e[n+3+2];return u>=0?(s=(m-y)*u,a=(v-y)*u):(s=(v-y)*u,a=(m-y)*u),d>=0?(o=(_-g)*d,c=(b-g)*d):(o=(b-g)*d,c=(_-g)*d),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),p>=0?(l=(x-f)*p,h=(S-f)*p):(l=(S-f)*p,h=(x-f)*p),s>h||l>a)?!1:((l>s||s!==s)&&(s=l),(h<a||a!==a)&&(a=h),s<=i&&a>=r)}function Lh(n,e,t,r,i,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let h=r,u=r+i;h<u;h++){let d=l?l[h]:h;Vi(c,e,t,d,s,a,o)}}function Vh(n,e,t,r,i,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,h=null;for(let u=r,d=r+i;u<d;u++){let p;p=Vi(o,e,t,c?c[u]:u,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function jh(n,e,t,r,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=n,u=e+n;h<u;h++){let d;if(d=t.resolveTriangleIndex(h),te(a,d*3,c,l),a.needsUpdate=!0,r(a,d,i,s))return!0}return!1}function Jh(n,e,t,r,i,s,a){X.setBuffer(n._roots[e]),rs(0,n,t,r,i,s,a),X.clearBuffer()}function rs(n,e,t,r,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=X,h=n*2;if(we(h,c)){const u=Pe(n,l),d=Ee(h,c);Uh(e,t,r,u,d,i,s,a)}else{const u=ke(n);St(u,o,r,s,a)&&rs(u,e,t,r,i,s,a);const d=Ae(n,l);St(d,o,r,s,a)&&rs(d,e,t,r,i,s,a)}}const Gh=["x","y","z"];function Wh(n,e,t,r,i,s){X.setBuffer(n._roots[e]);const a=is(0,n,t,r,i,s);return X.clearBuffer(),a}function is(n,e,t,r,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=X;let l=n*2;if(we(l,o)){const h=Pe(n,c),u=Ee(l,o);return Nh(e,t,r,h,u,i,s)}else{const h=ba(n,c),u=Gh[h],d=r.direction[u]>=0;let p,y;d?(p=ke(n),y=Ae(n,c)):(p=Ae(n,c),y=ke(n));const g=St(p,a,r,i,s)?is(p,e,t,r,i,s):null;if(g){const m=g.point[u];if(d?m<=a[y+h]:m>=a[y+h+3])return g}const f=St(y,a,r,i,s)?is(y,e,t,r,i,s):null;return g&&f?g.distance<=f.distance?g:f:g||f||null}}const ji=new Ye,Yt=new Re,Zt=new Re,Tr=new Ve,Ca=new fe,Ji=new fe;function Xh(n,e,t,r){X.setBuffer(n._roots[e]);const i=ns(0,n,t,r);return X.clearBuffer(),i}function ns(n,e,t,r,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=X;let c=n*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Ca.set(t.boundingBox.min,t.boundingBox.max,r),i=Ca),we(c,a)){const l=e.geometry,h=l.index,u=l.attributes.position,d=t.index,p=t.attributes.position,y=Pe(n,o),g=Ee(c,a);if(Tr.copy(r).invert(),t.boundsTree)return Z(n,s,Ji),Ji.matrix.copy(Tr),Ji.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:f=>Ji.intersectsBox(f),intersectsTriangle:f=>{f.a.applyMatrix4(r),f.b.applyMatrix4(r),f.c.applyMatrix4(r),f.needsUpdate=!0;for(let m=y*3,v=(g+y)*3;m<v;m+=3)if(te(Zt,m,h,u),Zt.needsUpdate=!0,f.intersectsTriangle(Zt))return!0;return!1}});for(let f=y*3,m=(g+y)*3;f<m;f+=3){te(Yt,f,h,u),Yt.a.applyMatrix4(Tr),Yt.b.applyMatrix4(Tr),Yt.c.applyMatrix4(Tr),Yt.needsUpdate=!0;for(let v=0,_=d.count;v<_;v+=3)if(te(Zt,v,d,p),Zt.needsUpdate=!0,Yt.intersectsTriangle(Zt))return!0}}else{const l=n+8,h=o[n+6];return Z(l,s,ji),!!(i.intersectsBox(ji)&&ns(l,e,t,r,i)||(Z(h,s,ji),i.intersectsBox(ji)&&ns(h,e,t,r,i)))}}const Gi=new Ve,ss=new fe,Cr=new fe,qh=new I,Hh=new I,Yh=new I,Zh=new I;function Qh(n,e,t,r={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ss.set(e.boundingBox.min,e.boundingBox.max,t),ss.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,u=e.index,d=Oe.getPrimitive(),p=Oe.getPrimitive();let y=qh,g=Hh,f=null,m=null;i&&(f=Yh,m=Zh);let v=1/0,_=null,b=null;return Gi.copy(t).invert(),Cr.matrix.copy(Gi),n.shapecast({boundsTraverseOrder:x=>ss.distanceToBox(x),intersectsBounds:(x,S,w)=>w<v&&w<a?(S&&(Cr.min.copy(x.min),Cr.max.copy(x.max),Cr.needsUpdate=!0),!0):!1,intersectsRange:(x,S)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:w=>Cr.distanceToBox(w),intersectsBounds:(w,C,M)=>M<v&&M<a,intersectsRange:(w,C)=>{for(let M=w,T=w+C;M<T;M++){te(p,3*M,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=x,P=x+S;E<P;E++){te(d,3*E,l,c),d.needsUpdate=!0;const k=d.distanceToTriangle(p,y,f);if(k<v&&(g.copy(y),m&&m.copy(f),v=k,_=E,b=M),k<s)return!0}}}});{const w=Xt(e);for(let C=0,M=w;C<M;C++){te(p,3*C,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let T=x,E=x+S;T<E;T++){te(d,3*T,l,c),d.needsUpdate=!0;const P=d.distanceToTriangle(p,y,f);if(P<v&&(g.copy(y),m&&m.copy(f),v=P,_=T,b=C),P<s)return!0}}}}}),Oe.releasePrimitive(d),Oe.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(g):r.point=g.clone(),r.distance=v,r.faceIndex=_,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Gi),g.applyMatrix4(Gi),i.distance=g.sub(i.point).length(),i.faceIndex=b),r)}function Kh(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,r=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=n._roots;for(let d=0,p=h.length;d<p;d++)s=h[d],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),u(0,l),l+=s.byteLength;function u(d,p,y=!1){const g=d*2;if(o[g+15]===zi){const f=a[d+6],m=o[g+14];let v=1/0,_=1/0,b=1/0,x=-1/0,S=-1/0,w=-1/0;for(let C=f,M=f+m;C<M;C++){const T=3*n.resolveTriangleIndex(C);for(let E=0;E<3;E++){let P=T+E;P=r?r[P]:P;const k=i.getX(P),R=i.getY(P),U=i.getZ(P);k<v&&(v=k),k>x&&(x=k),R<_&&(_=R),R>S&&(S=R),U<b&&(b=U),U>w&&(w=U)}}return c[d+0]!==v||c[d+1]!==_||c[d+2]!==b||c[d+3]!==x||c[d+4]!==S||c[d+5]!==w?(c[d+0]=v,c[d+1]=_,c[d+2]=b,c[d+3]=x,c[d+4]=S,c[d+5]=w,!0):!1}else{const f=d+8,m=a[d+6],v=f+p,_=m+p;let b=y,x=!1,S=!1;e?b||(x=e.has(v),S=e.has(_),b=!x&&!S):(x=!0,S=!0);const w=b||x,C=b||S;let M=!1;w&&(M=u(f,p,b));let T=!1;C&&(T=u(m,p,b));const E=M||T;if(E)for(let P=0;P<3;P++){const k=f+P,R=m+P,U=c[k],N=c[k+3],G=c[R],B=c[R+3];c[d+P]=U<G?U:G,c[d+P+3]=N>B?N:B}return E}}}function $h(n,e,t,r,i,s,a){X.setBuffer(n._roots[e]),os(0,n,t,r,i,s,a),X.clearBuffer()}function os(n,e,t,r,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=X,h=n*2;if(we(h,c)){const u=Pe(n,l),d=Ee(h,c);Lh(e,t,r,u,d,i,s,a)}else{const u=ke(n);St(u,o,r,s,a)&&os(u,e,t,r,i,s,a);const d=Ae(n,l);St(d,o,r,s,a)&&os(d,e,t,r,i,s,a)}}const eu=["x","y","z"];function tu(n,e,t,r,i,s){X.setBuffer(n._roots[e]);const a=as(0,n,t,r,i,s);return X.clearBuffer(),a}function as(n,e,t,r,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=X;let l=n*2;if(we(l,o)){const h=Pe(n,c),u=Ee(l,o);return Vh(e,t,r,h,u,i,s)}else{const h=ba(n,c),u=eu[h],d=r.direction[u]>=0;let p,y;d?(p=ke(n),y=Ae(n,c)):(p=Ae(n,c),y=ke(n));const g=St(p,a,r,i,s)?as(p,e,t,r,i,s):null;if(g){const m=g.point[u];if(d?m<=a[y+h]:m>=a[y+h+3])return g}const f=St(y,a,r,i,s)?as(y,e,t,r,i,s):null;return g&&f?g.distance<=f.distance?g:f:g||f||null}}const Wi=new Ye,Qt=new Re,Kt=new Re,Pr=new Ve,Pa=new fe,Xi=new fe;function ru(n,e,t,r){X.setBuffer(n._roots[e]);const i=cs(0,n,t,r);return X.clearBuffer(),i}function cs(n,e,t,r,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=X;let c=n*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Pa.set(t.boundingBox.min,t.boundingBox.max,r),i=Pa),we(c,a)){const l=e.geometry,h=l.index,u=l.attributes.position,d=t.index,p=t.attributes.position,y=Pe(n,o),g=Ee(c,a);if(Pr.copy(r).invert(),t.boundsTree)return Z(n,s,Xi),Xi.matrix.copy(Pr),Xi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:f=>Xi.intersectsBox(f),intersectsTriangle:f=>{f.a.applyMatrix4(r),f.b.applyMatrix4(r),f.c.applyMatrix4(r),f.needsUpdate=!0;for(let m=y,v=g+y;m<v;m++)if(te(Kt,3*e.resolveTriangleIndex(m),h,u),Kt.needsUpdate=!0,f.intersectsTriangle(Kt))return!0;return!1}});for(let f=y,m=g+y;f<m;f++){const v=e.resolveTriangleIndex(f);te(Qt,3*v,h,u),Qt.a.applyMatrix4(Pr),Qt.b.applyMatrix4(Pr),Qt.c.applyMatrix4(Pr),Qt.needsUpdate=!0;for(let _=0,b=d.count;_<b;_+=3)if(te(Kt,_,d,p),Kt.needsUpdate=!0,Qt.intersectsTriangle(Kt))return!0}}else{const l=n+8,h=o[n+6];return Z(l,s,Wi),!!(i.intersectsBox(Wi)&&cs(l,e,t,r,i)||(Z(h,s,Wi),i.intersectsBox(Wi)&&cs(h,e,t,r,i)))}}const qi=new Ve,ls=new fe,Er=new fe,iu=new I,nu=new I,su=new I,ou=new I;function au(n,e,t,r={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ls.set(e.boundingBox.min,e.boundingBox.max,t),ls.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,u=e.index,d=Oe.getPrimitive(),p=Oe.getPrimitive();let y=iu,g=nu,f=null,m=null;i&&(f=su,m=ou);let v=1/0,_=null,b=null;return qi.copy(t).invert(),Er.matrix.copy(qi),n.shapecast({boundsTraverseOrder:x=>ls.distanceToBox(x),intersectsBounds:(x,S,w)=>w<v&&w<a?(S&&(Er.min.copy(x.min),Er.max.copy(x.max),Er.needsUpdate=!0),!0):!1,intersectsRange:(x,S)=>{if(e.boundsTree){const w=e.boundsTree;return w.shapecast({boundsTraverseOrder:C=>Er.distanceToBox(C),intersectsBounds:(C,M,T)=>T<v&&T<a,intersectsRange:(C,M)=>{for(let T=C,E=C+M;T<E;T++){const P=w.resolveTriangleIndex(T);te(p,3*P,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let k=x,R=x+S;k<R;k++){const U=n.resolveTriangleIndex(k);te(d,3*U,l,c),d.needsUpdate=!0;const N=d.distanceToTriangle(p,y,f);if(N<v&&(g.copy(y),m&&m.copy(f),v=N,_=k,b=T),N<s)return!0}}}})}else{const w=Xt(e);for(let C=0,M=w;C<M;C++){te(p,3*C,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let T=x,E=x+S;T<E;T++){const P=n.resolveTriangleIndex(T);te(d,3*P,l,c),d.needsUpdate=!0;const k=d.distanceToTriangle(p,y,f);if(k<v&&(g.copy(y),m&&m.copy(f),v=k,_=T,b=C),k<s)return!0}}}}}),Oe.releasePrimitive(d),Oe.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(g):r.point=g.clone(),r.distance=v,r.faceIndex=_,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(qi),g.applyMatrix4(qi),i.distance=g.sub(i.point).length(),i.faceIndex=b),r)}function cu(){return typeof SharedArrayBuffer<"u"}const kr=new X.constructor,Hi=new X.constructor,wt=new $n(()=>new Ye),$t=new Ye,er=new Ye,hs=new Ye,us=new Ye;let ds=!1;function lu(n,e,t,r){if(ds)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ds=!0;const i=n._roots,s=e._roots;let a,o=0,c=0;const l=new Ve().copy(t).invert();for(let h=0,u=i.length;h<u;h++){kr.setBuffer(i[h]),c=0;const d=wt.getPrimitive();Z(0,kr.float32Array,d),d.applyMatrix4(l);for(let p=0,y=s.length;p<y&&(Hi.setBuffer(s[p]),a=Ge(0,0,t,l,r,o,c,0,0,d),Hi.clearBuffer(),c+=s[p].length,!a);p++);if(wt.releasePrimitive(d),kr.clearBuffer(),o+=i[h].length,a)break}return ds=!1,a}function Ge(n,e,t,r,i,s=0,a=0,o=0,c=0,l=null,h=!1){let u,d;h?(u=Hi,d=kr):(u=kr,d=Hi);const p=u.float32Array,y=u.uint32Array,g=u.uint16Array,f=d.float32Array,m=d.uint32Array,v=d.uint16Array,_=n*2,b=e*2,x=we(_,g),S=we(b,v);let w=!1;if(S&&x)h?w=i(Pe(e,m),Ee(e*2,v),Pe(n,y),Ee(n*2,g),c,a+e,o,s+n):w=i(Pe(n,y),Ee(n*2,g),Pe(e,m),Ee(e*2,v),o,s+n,c,a+e);else if(S){const C=wt.getPrimitive();Z(e,f,C),C.applyMatrix4(t);const M=ke(n),T=Ae(n,y);Z(M,p,$t),Z(T,p,er);const E=C.intersectsBox($t),P=C.intersectsBox(er);w=E&&Ge(e,M,r,t,i,a,s,c,o+1,C,!h)||P&&Ge(e,T,r,t,i,a,s,c,o+1,C,!h),wt.releasePrimitive(C)}else{const C=ke(e),M=Ae(e,m);Z(C,f,hs),Z(M,f,us);const T=l.intersectsBox(hs),E=l.intersectsBox(us);if(T&&E)w=Ge(n,C,t,r,i,s,a,o,c+1,l,h)||Ge(n,M,t,r,i,s,a,o,c+1,l,h);else if(T)if(x)w=Ge(n,C,t,r,i,s,a,o,c+1,l,h);else{const P=wt.getPrimitive();P.copy(hs).applyMatrix4(t);const k=ke(n),R=Ae(n,y);Z(k,p,$t),Z(R,p,er);const U=P.intersectsBox($t),N=P.intersectsBox(er);w=U&&Ge(C,k,r,t,i,a,s,c,o+1,P,!h)||N&&Ge(C,R,r,t,i,a,s,c,o+1,P,!h),wt.releasePrimitive(P)}else if(E)if(x)w=Ge(n,M,t,r,i,s,a,o,c+1,l,h);else{const P=wt.getPrimitive();P.copy(us).applyMatrix4(t);const k=ke(n),R=Ae(n,y);Z(k,p,$t),Z(R,p,er);const U=P.intersectsBox($t),N=P.intersectsBox(er);w=U&&Ge(M,k,r,t,i,a,s,c,o+1,P,!h)||N&&Ge(M,R,r,t,i,a,s,c,o+1,P,!h),wt.releasePrimitive(P)}}return w}const Yi=new fe,Ea=new Ye,hu={strategy:Jn,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class zr{static serialize(e,t={}){t={cloneBuffers:!0,...t};const r=e.geometry,i=e._roots,s=e._indirectBuffer,a=r.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,r={}){r={setIndex:!0,indirect:!!e.indirectBuffer,...r};const{index:i,roots:s,indirectBuffer:a}=e,o=new zr(t,{...r,[Xn]:!0});if(o._roots=s,o._indirectBuffer=a||null,r.setIndex){const c=t.getIndex();if(c===null){const l=new Te(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...hu,[Xn]:!1},t),t.useSharedArrayBuffer&&!cu())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Xn]||(Th(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ye))),this.resolveTriangleIndex=t.indirect?r=>this._indirectBuffer[r]:r=>r}refit(e=null){return(this.indirect?Kh:Fh)(this,e)}traverse(e,t=0){const r=this._roots[t],i=new Uint32Array(r),s=new Uint16Array(r);a(0);function a(o,c=0){const l=o*2,h=s[l+15]===zi;if(h){const u=i[o+6],d=s[l+14];e(c,h,new Float32Array(r,o*4,6),u,d)}else{const u=o+br/4,d=i[o+6],p=i[o+7];e(c,h,new Float32Array(r,o*4,6),p)||(a(u,c+1),a(d,c+1))}}}raycast(e,t=ws,r=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),h=a.groups,u=c?t.side:t,d=this.indirect?$h:Jh;for(let p=0,y=s.length;p<y;p++){const g=l?t[h[p].materialIndex].side:u,f=o.length;if(d(this,p,g,e,o,r,i),l){const m=h[p].materialIndex;for(let v=f,_=o.length;v<_;v++)o[v].face.materialIndex=m}}return o}raycastFirst(e,t=ws,r=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const h=a.groups,u=o?t.side:t,d=this.indirect?tu:Wh;for(let p=0,y=s.length;p<y;p++){const g=c?t[h[p].materialIndex].side:u,f=d(this,p,g,e,r,i);f!=null&&(l==null||f.distance<l.distance)&&(l=f,c&&(f.face.materialIndex=h[p].materialIndex))}return l}intersectsGeometry(e,t){let r=!1;const i=this._roots,s=this.indirect?ru:Xh;for(let a=0,o=i.length;a<o&&(r=s(this,a,e,t),!r);a++);return r}shapecast(e){const t=Oe.getPrimitive(),r=this.indirect?jh:Dh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const u=a;a=(d,p,y,g,f)=>u(d,p,y,g,f)?!0:r(d,p,this,o,y,g,t)}else a||(o?a=(u,d,p,y)=>r(u,d,this,o,p,y,t):a=(u,d,p)=>p);let c=!1,l=0;const h=this._roots;for(let u=0,d=h.length;u<d;u++){const p=h[u];if(c=Rh(this,u,s,a,i,l),c)break;l+=p.byteLength}return Oe.releasePrimitive(t),c}bvhcast(e,t,r){let{intersectsRanges:i,intersectsTriangles:s}=r;const a=Oe.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?y=>{const g=this.resolveTriangleIndex(y);te(a,g*3,o,c)}:y=>{te(a,y*3,o,c)},h=Oe.getPrimitive(),u=e.geometry.index,d=e.geometry.attributes.position,p=e.indirect?y=>{const g=e.resolveTriangleIndex(y);te(h,g*3,u,d)}:y=>{te(h,y*3,u,d)};if(s){const y=(g,f,m,v,_,b,x,S)=>{for(let w=m,C=m+v;w<C;w++){p(w),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let M=g,T=g+f;M<T;M++)if(l(M),a.needsUpdate=!0,s(a,h,M,w,_,b,x,S))return!0}return!1};if(i){const g=i;i=function(f,m,v,_,b,x,S,w){return g(f,m,v,_,b,x,S,w)?!0:y(f,m,v,_,b,x,S,w)}}else i=y}return lu(this,e,t,i)}intersectsBox(e,t){return Yi.set(e.min,e.max,t),Yi.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Yi.intersectsBox(r),intersectsTriangle:r=>Yi.intersectsTriangle(r)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,r={},i={},s=0,a=1/0){return(this.indirect?au:Qh)(this,e,t,r,i,s,a)}closestPointToPoint(e,t={},r=0,i=1/0){return Oh(this,e,t,r,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Z(0,new Float32Array(t),Ea),e.union(Ea)}),e}}function ka(n,e,t){return n===null?null:(n.point.applyMatrix4(e.matrixWorld),n.distance=n.point.distanceTo(t.ray.origin),n.object=e,n)}const Zi=new Xa,Aa=new I,Ra=new Ve,uu=an.prototype.raycast,du=Wa.prototype.raycast,Oa=new I,ue=new an,Qi=[];function pu(n,e){this.isBatchedMesh?fu.call(this,n,e):mu.call(this,n,e)}function fu(n,e){if(this.boundsTrees){const t=this.boundsTrees,r=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;ue.material=this.material,ue.geometry=this.geometry;const a=ue.geometry.boundsTree,o=ue.geometry.drawRange;ue.geometry.boundingSphere===null&&(ue.geometry.boundingSphere=new Ss);for(let c=0,l=r.length;c<l;c++){if(!this.getVisibleAt(c))continue;const h=r[c].geometryIndex;if(ue.geometry.boundsTree=t[h],this.getMatrixAt(c,ue.matrixWorld).premultiply(s),!ue.geometry.boundsTree){this.getBoundingBoxAt(h,ue.geometry.boundingBox),this.getBoundingSphereAt(h,ue.geometry.boundingSphere);const u=i[h];ue.geometry.setDrawRange(u.start,u.count)}ue.raycast(n,Qi);for(let u=0,d=Qi.length;u<d;u++){const p=Qi[u];p.object=this,p.batchId=c,e.push(p)}Qi.length=0}ue.geometry.boundsTree=a,ue.geometry.drawRange=o,ue.material=null,ue.geometry=null}else du.call(this,n,e)}function mu(n,e){if(this.geometry.boundsTree){if(this.material===void 0)return;Ra.copy(this.matrixWorld).invert(),Zi.copy(n.ray).applyMatrix4(Ra),Oa.setFromMatrixScale(this.matrixWorld),Aa.copy(Zi.direction).multiply(Oa);const t=Aa.length(),r=n.near/t,i=n.far/t,s=this.geometry.boundsTree;if(n.firstHitOnly===!0){const a=ka(s.raycastFirst(Zi,this.material,r,i),this,n);a&&e.push(a)}else{const a=s.raycast(Zi,this.material,r,i);for(let o=0,c=a.length;o<c;o++){const l=ka(a[o],this,n);l&&e.push(l)}}}else uu.call(this,n,e)}function yu(n={}){return this.boundsTree=new zr(this,n),this.boundsTree}const zt=new I,Bt=new I,It=new I,za=new cn,Ki=new I,ps=new I,Ba=new cn,Ia=new cn,$i=new Ve,Ua=new Ve;function Ar(n,e){if(!n&&!e)return;const t=n.count===e.count,r=n.normalized===e.normalized,i=n.array.constructor===e.array.constructor,s=n.itemSize===e.itemSize;if(!t||!r||!i||!s)throw new Error}function Rr(n,e=null){const t=n.array.constructor,r=n.normalized,i=n.itemSize,s=e===null?n.count:e;return new Te(new t(i*s),i,r)}function Na(n,e,t=0){if(n.isInterleavedBufferAttribute){const r=n.itemSize;for(let i=0,s=n.count;i<s;i++){const a=i+t;e.setX(a,n.getX(i)),r>=2&&e.setY(a,n.getY(i)),r>=3&&e.setZ(a,n.getZ(i)),r>=4&&e.setW(a,n.getW(i))}}else{const r=e.array,i=r.constructor,s=r.BYTES_PER_ELEMENT*n.itemSize*t;new i(r.buffer,s,n.array.length).set(n.array)}}function gu(n,e,t){const r=n.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)r[s]+=i[s]*t}function Da(n,e,t){const r=n.skeleton,i=n.geometry,s=r.bones,a=r.boneInverses;Ba.fromBufferAttribute(i.attributes.skinIndex,e),Ia.fromBufferAttribute(i.attributes.skinWeight,e),$i.elements.fill(0);for(let o=0;o<4;o++){const c=Ia.getComponent(o);if(c!==0){const l=Ba.getComponent(o);Ua.multiplyMatrices(s[l].matrixWorld,a[l]),gu($i,Ua,c)}}return $i.multiply(n.bindMatrix).premultiply(n.bindMatrixInverse),t.transformDirection($i),t}function fs(n,e,t,r,i){Ki.set(0,0,0);for(let s=0,a=n.length;s<a;s++){const o=e[s],c=n[s];o!==0&&(ps.fromBufferAttribute(c,r),t?Ki.addScaledVector(ps,o):Ki.addScaledVector(ps.sub(i),o))}i.add(Ki)}function vu(n,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new ar){const r=n[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(n[0].attributes)),c={};let l=0;t.clearGroups();for(let h=0;h<n.length;++h){const u=n[h];let d=0;if(r!==(u.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const p in u.attributes){if(!o.has(p))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.');c[p]===void 0&&(c[p]=[]),c[p].push(u.attributes[p]),d++}if(d!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let p;if(r)p=u.index.count;else if(u.attributes.position!==void 0)p=u.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,p,h),l+=p}}if(r){let h=!1;if(!t.index){let u=0;for(let d=0;d<n.length;++d)u+=n[d].index.count;t.setIndex(new Te(new Uint32Array(u),1,!1)),h=!0}if(s||h){const u=t.index;let d=0,p=0;for(let y=0;y<n.length;++y){const g=n[y],f=g.index;if(a[y]!==!0)for(let m=0;m<f.count;++m)u.setX(d,f.getX(m)+p),d++;p+=g.attributes.position.count}}}for(const h in c){const u=c[h];if(!(h in t.attributes)){let y=0;for(const g in u)y+=u[g].count;t.setAttribute(h,Rr(c[h][0],y))}const d=t.attributes[h];let p=0;for(let y=0,g=u.length;y<g;y++){const f=u[y];a[y]!==!0&&Na(f,d,p),p+=f.count}}return t}function _u(n,e){if(n===null||e===null)return n===e;if(n.length!==e.length)return!1;for(let t=0,r=n.length;t<r;t++)if(n[t]!==e[t])return!1;return!0}function bu(n){const{index:e,attributes:t}=n;if(e)for(let r=0,i=e.count;r<i;r+=3){const s=e.getX(r),a=e.getX(r+2);e.setX(r,a),e.setX(r+2,s)}else for(const r in t){const i=t[r],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),h=i.getComponent(a+2,c);i.setComponent(a,c,h),i.setComponent(a+2,c,l)}}return n}class xu{constructor(e){this.matrixWorld=new Ve,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,r=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,r){r.boneTexture||r.computeBoneTexture(),r.update();const s=r.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,r=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&_u(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===r)}}class Su{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(r=>{r.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new ar),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new ar){let t=[];const{meshes:r,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=r.length;o<c;o++){const l=r[o],h=s[o],u=a.get(l);!u||u.didChange(l)?(this._convertToStaticGeometry(l,h),t.push(!1),u?u.update():a.set(l,new xu(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new Te(new Float32Array(0),4,!1))}else vu(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new ar){const r=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=r.attributes,c=t.attributes;!t.index&&r.index&&(t.index=r.index.clone()),c.position||t.setAttribute("position",Rr(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",Rr(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",Rr(o.tangent)),Ar(r.index,t.index),Ar(o.position,c.position),s&&Ar(o.normal,c.normal),a&&Ar(o.tangent,c.tangent);const l=o.position,h=s?o.normal:null,u=a?o.tangent:null,d=r.morphAttributes.position,p=r.morphAttributes.normal,y=r.morphAttributes.tangent,g=r.morphTargetsRelative,f=e.morphTargetInfluences,m=new qa;m.getNormalMatrix(e.matrixWorld),r.index&&t.index.array.set(r.index.array);for(let v=0,_=o.position.count;v<_;v++)zt.fromBufferAttribute(l,v),h&&Bt.fromBufferAttribute(h,v),u&&(za.fromBufferAttribute(u,v),It.fromBufferAttribute(u,v)),f&&(d&&fs(d,f,g,v,zt),p&&fs(p,f,g,v,Bt),y&&fs(y,f,g,v,It)),e.isSkinnedMesh&&(e.applyBoneTransform(v,zt),h&&Da(e,v,Bt),u&&Da(e,v,It)),i&&zt.applyMatrix4(e.matrixWorld),c.position.setXYZ(v,zt.x,zt.y,zt.z),h&&(i&&Bt.applyNormalMatrix(m),c.normal.setXYZ(v,Bt.x,Bt.y,Bt.z)),u&&(i&&It.transformDirection(e.matrixWorld),c.tangent.setXYZW(v,It.x,It.y,It.z,za.w));for(const v in this.attributes){const _=this.attributes[v];_==="position"||_==="tangent"||_==="normal"||!(_ in o)||(c[_]||t.setAttribute(_,Rr(o[_])),Ar(o[_],c[_]),Na(o[_],c[_]))}return e.matrixWorld.determinant()<0&&bu(t),t}}const wu=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:da,CENTER:Jn,CONTAINED:Gn,ExtendedTriangle:Re,MeshBVH:zr,OrientedBox:fe,SAH:pa,StaticGeometryGenerator:Su,acceleratedRaycast:pu,computeBoundsTree:yu},Symbol.toStringTag,{value:"Module"}));class Mu{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}export{jo as $70d766613f57b014$export$2e2bcd8739ae039,ih as BatchedParticleRenderer,ms as Builder,Or as ByteBuffer,Nt as ConstantColor,L as ConstantValue,We as Matrix4,zr as MeshBVH,ec as MotionController,nn as ParticleSystem,A as RenderMode,Ts as SIZE_PREFIX_LENGTH,ki as TrailParticle,Me as Vector4,Mu as WorkerBase,Oc as bundler,sh as createNoise4D,Ya as fetchProfile,lh as index,wu as index$1,Hc as md5,Jc as v5};
1121
+ }`;class rh extends ca{constructor(e){super(e),this.vector_=new z,this.vector2_=new z,this.vector3_=new z,this.quaternion_=new j,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new ar,this.indexBuffer=new Te(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(ge),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new Te(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(ge),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new Te(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(ge),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new Te(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(ge),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new Te(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(ge),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new Te(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(ge),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new Te(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(ge),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new Te(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(ge),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new tr(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=jn(this.settings.material.map.channel),e.map=new Le(this.settings.material.map),e.mapTransform=new Le(new tt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===A.Trail)this.material=new on({uniforms:e,defines:t,vertexShader:th,fragmentShader:eh,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||bs,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,r=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)r+=i.particles[s].previous.length*2}),r>this.maxParticles&&this.expandBuffers(r),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,h=this.settings.uTileCount,u=this.settings.vTileCount,d=1/h,p=1/u;for(let y=0;y<l;y++){const g=c[y],f=g.uvTile%u,m=Math.floor(g.uvTile/u+.001),v=g.previous.values();let _=v.next(),b=_.value,x=b;_.done||(_=v.next());let S;_.value!==void 0?S=_.value:S=x;for(let w=0;w<g.previous.length;w++,e+=2){if(this.positionBuffer.setXYZ(e,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(e+1,x.position.x,x.position.y,x.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(e+1,x.position.x,x.position.y,x.position.z)):(g.parentMatrix?this.vector_.copy(x.position).applyMatrix4(g.parentMatrix):this.vector_.copy(x.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,b.position.x,b.position.y,b.position.z),this.previousBuffer.setXYZ(e+1,b.position.x,b.position.y,b.position.z)):(g.parentMatrix?this.vector_.copy(b.position).applyMatrix4(g.parentMatrix):this.vector_.copy(b.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,S.position.x,S.position.y,S.position.z),this.nextBuffer.setXYZ(e+1,S.position.x,S.position.y,S.position.z)):(g.parentMatrix?this.vector_.copy(S.position).applyMatrix4(g.parentMatrix):this.vector_.copy(S.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,x.size),this.widthBuffer.setX(e+1,x.size);else if(g.parentMatrix)this.widthBuffer.setX(e,x.size),this.widthBuffer.setX(e+1,x.size);else{const C=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,x.size*C),this.widthBuffer.setX(e+1,x.size*C)}this.uvBuffer.setXY(e,(w/g.previous.length+f)*d,(u-m-1)*p),this.uvBuffer.setXY(e+1,(w/g.previous.length+f)*d,(u-m)*p),this.colorBuffer.setXYZW(e,x.color.x,x.color.y,x.color.z,x.color.w),this.colorBuffer.setXYZW(e+1,x.color.x,x.color.y,x.color.z,x.color.w),w+1<g.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),b=x,x=S,_.done||(_=v.next(),_.value!==void 0&&(S=_.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class li{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new Pt;this._triangleIndexToArea.length=0;let r=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),r+=t.getArea(),this._triangleIndexToArea.push(r);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new I,this._tempB=new I,this._tempC=new I,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const r=this._triangleIndexToArea.length-1;let i=0,s=r;const a=Math.random()*this._triangleIndexToArea[r];for(;i+1<s;){const p=Math.floor((i+s)/2);a<this._triangleIndexToArea[p]?s=p:i=p}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],h=t.getIndex().array[i*3+1],u=t.getIndex().array[i*3+2],d=t.getAttribute("position");this._tempA.fromBufferAttribute(d,l),this._tempB.fromBufferAttribute(d,h),this._tempC.fromBufferAttribute(d,u),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new li(t.geometries[e.geometry])}clone(){return new li(this._geometry)}update(e,t){}}zl({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:li,loadJSON:li.fromJSON}],behaviors:[]});class ys extends vs{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(ys.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let r;switch(t.renderMode){case A.Trail:r=new rh(t);break;case A.Mesh:case A.BillBoard:case A.VerticalBillBoard:case A.HorizontalBillBoard:case A.StretchedBillBoard:r=new $l(t);break}this.depthTexture&&r.applyDepthTexture(this.depthTexture),r.addSystem(e),this.batches.push(r),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(r)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,r)=>{r.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const ih=ys;jl(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const ha=Math.sqrt(5),nh=(ha-1)/4,he=(5-ha)/20,Ri=n=>Math.floor(n)|0,Oi=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function sh(n=Math.random){const e=oh(n),t=new Float64Array(e).map(a=>Oi[a%32*4]),r=new Float64Array(e).map(a=>Oi[a%32*4+1]),i=new Float64Array(e).map(a=>Oi[a%32*4+2]),s=new Float64Array(e).map(a=>Oi[a%32*4+3]);return function(a,o,c,l){let h,u,d,p,y;const g=(a+o+c+l)*nh,f=Ri(a+g),m=Ri(o+g),v=Ri(c+g),_=Ri(l+g),b=(f+m+v+_)*he,x=f-b,S=m-b,w=v-b,C=_-b,M=a-x,T=o-S,E=c-w,P=l-C;let k=0,R=0,U=0,N=0;M>T?k++:R++,M>E?k++:U++,M>P?k++:N++,T>E?R++:U++,T>P?R++:N++,E>P?U++:N++;const G=k>=3?1:0,B=R>=3?1:0,oe=U>=3?1:0,Q=N>=3?1:0,re=k>=2?1:0,$=R>=2?1:0,me=U>=2?1:0,ye=N>=2?1:0,ie=k>=1?1:0,H=R>=1?1:0,W=U>=1?1:0,rt=N>=1?1:0,ze=M-G+he,Xe=T-B+he,qe=E-oe+he,be=P-Q+he,Be=M-re+2*he,xe=T-$+2*he,it=E-me+2*he,nt=P-ye+2*he,Y=M-ie+3*he,He=T-H+3*he,st=E-W+3*he,Tt=P-rt+3*he,ot=M-1+4*he,at=T-1+4*he,ct=E-1+4*he,lt=P-1+4*he,Ie=f&255,Ue=m&255,Ne=v&255,De=_&255;let Fe=.6-M*M-T*T-E*E-P*P;if(Fe<0)h=0;else{const q=Ie+e[Ue+e[Ne+e[De]]];Fe*=Fe,h=Fe*Fe*(t[q]*M+r[q]*T+i[q]*E+s[q]*P)}let V=.6-ze*ze-Xe*Xe-qe*qe-be*be;if(V<0)u=0;else{const q=Ie+G+e[Ue+B+e[Ne+oe+e[De+Q]]];V*=V,u=V*V*(t[q]*ze+r[q]*Xe+i[q]*qe+s[q]*be)}let nr=.6-Be*Be-xe*xe-it*it-nt*nt;if(nr<0)d=0;else{const q=Ie+re+e[Ue+$+e[Ne+me+e[De+ye]]];nr*=nr,d=nr*nr*(t[q]*Be+r[q]*xe+i[q]*it+s[q]*nt)}let sr=.6-Y*Y-He*He-st*st-Tt*Tt;if(sr<0)p=0;else{const q=Ie+ie+e[Ue+H+e[Ne+W+e[De+rt]]];sr*=sr,p=sr*sr*(t[q]*Y+r[q]*He+i[q]*st+s[q]*Tt)}let or=.6-ot*ot-at*at-ct*ct-lt*lt;if(or<0)y=0;else{const q=Ie+1+e[Ue+1+e[Ne+1+e[De+1]]];or*=or,y=or*or*(t[q]*ot+r[q]*at+i[q]*ct+s[q]*lt)}return 27*(h+u+d+p+y)}}function oh(n){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const r=t+~~(n()*(256-t)),i=e[t];e[t]=e[r],e[r]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}class ah{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var J;(function(n){n.open="open",n.close="close",n.error="error",n.message="message",n.retry="retry",n.reconnect="reconnect"})(J||(J={}));class ua{constructor(e,t,r){var i,s,a,o,c,l,h,u,d,p,y,g,f,m,v;this._closedByUser=!1,this.handleOpenEvent=_=>this.handleEvent(J.open,_),this.handleErrorEvent=_=>this.handleEvent(J.error,_),this.handleCloseEvent=_=>this.handleEvent(J.close,_),this.handleMessageEvent=_=>this.handleEvent(J.message,_),this._url=e,this._protocols=t,this._options={buffer:r?.buffer,retry:{maxRetries:(i=r?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=r?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=r?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=r?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(h=(l=r?.listeners)===null||l===void 0?void 0:l.close)!==null&&h!==void 0?h:[]],error:[...(d=(u=r?.listeners)===null||u===void 0?void 0:u.error)!==null&&d!==void 0?d:[]],message:[...(y=(p=r?.listeners)===null||p===void 0?void 0:p.message)!==null&&y!==void 0?y:[]],retry:[...(f=(g=r?.listeners)===null||g===void 0?void 0:g.retry)!==null&&f!==void 0?f:[]],reconnect:[...(v=(m=r?.listeners)===null||m===void 0?void 0:m.reconnect)!==null&&v!==void 0?v:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,r){this._options.listeners[e].push({listener:t,options:r})}removeEventListener(e,t,r){const i=s=>s.listener!==t||s.options!==r;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(J.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(J.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(J.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(J.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(J.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(J.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(J.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(J.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const r=this._options.listeners[e],i=[];r.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case J.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case J.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const r={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(J.reconnect,{detail:r});this.dispatchEvent(J.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case J.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=r=>{const i=new CustomEvent(J.retry,{detail:r});this.handleEvent(J.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class ch{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(J.open,e,t),this}onClose(e,t){return this.addListener(J.close,e,t),this}onError(e,t){return this.addListener(J.error,e,t),this}onMessage(e,t){return this.addListener(J.message,e,t),this}onRetry(e,t){return this.addListener(J.retry,e,t),this}onReconnect(e,t){return this.addListener(J.reconnect,e,t),this}build(){return new ua(this._url,this._protocols,this._options)}addListener(e,t,r){var i,s,a,o,c,l,h,u,d,p,y,g,f,m,v,_,b,x,S,w,C;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(d=(u=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||u===void 0?void 0:u.error)!==null&&d!==void 0?d:[],message:(g=(y=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||y===void 0?void 0:y.message)!==null&&g!==void 0?g:[],retry:(v=(m=(f=this._options)===null||f===void 0?void 0:f.listeners)===null||m===void 0?void 0:m.retry)!==null&&v!==void 0?v:[],reconnect:(x=(b=(_=this._options)===null||_===void 0?void 0:_.listeners)===null||b===void 0?void 0:b.reconnect)!==null&&x!==void 0?x:[],[e]:[...(C=(w=(S=this._options)===null||S===void 0?void 0:S.listeners)===null||w===void 0?void 0:w[e])!==null&&C!==void 0?C:[],{listener:t,options:r}]}}),this}}const lh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:ah,Websocket:ua,WebsocketBuilder:ch,get WebsocketEvent(){return J}},Symbol.toStringTag,{value:"Module"})),Jn=0,da=1,pa=2,Gn=2,Wn=1.25,fa=1,br=6*4+4+4,zi=65535,hh=Math.pow(2,-24),Xn=Symbol("SKIP_GENERATION");function uh(n){return n.index?n.index.count:n.attributes.position.count}function Xt(n){return uh(n)/3}function dh(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function ph(n,e){if(!n.index){const t=n.attributes.position.count,r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=dh(t,r);n.setIndex(new Te(i,1));for(let s=0;s<t;s++)i[s]=s}}function ma(n,e){const t=Xt(n),r=e||n.drawRange,i=r.start/3,s=(r.start+r.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function ya(n,e){if(!n.groups||!n.groups.length)return ma(n,e);const t=[],r=new Set,i=e||n.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of n.groups){const l=c.start/3,h=(c.start+c.count)/3;r.add(Math.max(s,l)),r.add(Math.min(a,h))}const o=Array.from(r.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],h=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(h-l)})}return t}function fh(n,e){const t=Xt(n),r=ya(n,e).sort((a,o)=>a.offset-o.offset),i=r[r.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return r.forEach(({count:a})=>s+=a),t!==s}function qn(n,e,t,r,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,h=-1/0,u=1/0,d=1/0,p=1/0,y=-1/0,g=-1/0,f=-1/0;for(let m=e*6,v=(e+t)*6;m<v;m+=6){const _=n[m+0],b=n[m+1],x=_-b,S=_+b;x<s&&(s=x),S>c&&(c=S),_<u&&(u=_),_>y&&(y=_);const w=n[m+2],C=n[m+3],M=w-C,T=w+C;M<a&&(a=M),T>l&&(l=T),w<d&&(d=w),w>g&&(g=w);const E=n[m+4],P=n[m+5],k=E-P,R=E+P;k<o&&(o=k),R>h&&(h=R),E<p&&(p=E),E>f&&(f=E)}r[0]=s,r[1]=a,r[2]=o,r[3]=c,r[4]=l,r[5]=h,i[0]=u,i[1]=d,i[2]=p,i[3]=y,i[4]=g,i[5]=f}function mh(n,e=null,t=null,r=null){const i=n.attributes.position,s=n.index?n.index.array:null,a=Xt(n),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,r=a):(c=e,t=t||0,r=r||a);const l=i.array,h=i.offset||0;let u=3;i.isInterleavedBufferAttribute&&(u=i.data.stride);const d=["getX","getY","getZ"];for(let p=t;p<t+r;p++){const y=p*3,g=p*6;let f=y+0,m=y+1,v=y+2;s&&(f=s[f],m=s[m],v=s[v]),o||(f=f*u+h,m=m*u+h,v=v*u+h);for(let _=0;_<3;_++){let b,x,S;o?(b=i[d[_]](f),x=i[d[_]](m),S=i[d[_]](v)):(b=l[f+_],x=l[m+_],S=l[v+_]);let w=b;x<w&&(w=x),S<w&&(w=S);let C=b;x>C&&(C=x),S>C&&(C=S);const M=(C-w)/2,T=_*2;c[g+T+0]=w+M,c[g+T+1]=M+(Math.abs(w)+M)*hh}}return c}function Z(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function ga(n){let e=-1,t=-1/0;for(let r=0;r<3;r++){const i=n[r+3]-n[r];i>t&&(t=i,e=r)}return e}function va(n,e){e.set(n)}function _a(n,e,t){let r,i;for(let s=0;s<3;s++){const a=s+3;r=n[s],i=e[s],t[s]=r<i?r:i,r=n[a],i=e[a],t[a]=r>i?r:i}}function Bi(n,e,t){for(let r=0;r<3;r++){const i=e[n+2*r],s=e[n+2*r+1],a=i-s,o=i+s;a<t[r]&&(t[r]=a),o>t[r+3]&&(t[r+3]=o)}}function xr(n){const e=n[3]-n[0],t=n[4]-n[1],r=n[5]-n[2];return 2*(e*t+t*r+r*e)}const ft=32,yh=(n,e)=>n.candidate-e.candidate,bt=new Array(ft).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ii=new Float32Array(6);function gh(n,e,t,r,i,s){let a=-1,o=0;if(s===Jn)a=ga(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===da)a=ga(n),a!==-1&&(o=vh(t,r,i,a));else if(s===pa){const c=xr(n);let l=Wn*i;const h=r*6,u=(r+i)*6;for(let d=0;d<3;d++){const p=e[d],y=(e[d+3]-p)/ft;if(i<ft/4){const g=[...bt];g.length=i;let f=0;for(let v=h;v<u;v+=6,f++){const _=g[f];_.candidate=t[v+2*d],_.count=0;const{bounds:b,leftCacheBounds:x,rightCacheBounds:S}=_;for(let w=0;w<3;w++)S[w]=1/0,S[w+3]=-1/0,x[w]=1/0,x[w+3]=-1/0,b[w]=1/0,b[w+3]=-1/0;Bi(v,t,b)}g.sort(yh);let m=i;for(let v=0;v<m;v++){const _=g[v];for(;v+1<m&&g[v+1].candidate===_.candidate;)g.splice(v+1,1),m--}for(let v=h;v<u;v+=6){const _=t[v+2*d];for(let b=0;b<m;b++){const x=g[b];_>=x.candidate?Bi(v,t,x.rightCacheBounds):(Bi(v,t,x.leftCacheBounds),x.count++)}}for(let v=0;v<m;v++){const _=g[v],b=_.count,x=i-_.count,S=_.leftCacheBounds,w=_.rightCacheBounds;let C=0;b!==0&&(C=xr(S)/c);let M=0;x!==0&&(M=xr(w)/c);const T=fa+Wn*(C*b+M*x);T<l&&(a=d,l=T,o=_.candidate)}}else{for(let m=0;m<ft;m++){const v=bt[m];v.count=0,v.candidate=p+y+m*y;const _=v.bounds;for(let b=0;b<3;b++)_[b]=1/0,_[b+3]=-1/0}for(let m=h;m<u;m+=6){let v=~~((t[m+2*d]-p)/y);v>=ft&&(v=ft-1);const _=bt[v];_.count++,Bi(m,t,_.bounds)}const g=bt[ft-1];va(g.bounds,g.rightCacheBounds);for(let m=ft-2;m>=0;m--){const v=bt[m],_=bt[m+1];_a(v.bounds,_.rightCacheBounds,v.rightCacheBounds)}let f=0;for(let m=0;m<ft-1;m++){const v=bt[m],_=v.count,b=v.bounds,x=bt[m+1].rightCacheBounds;_!==0&&(f===0?va(b,Ii):_a(b,Ii,Ii)),f+=_;let S=0,w=0;f!==0&&(S=xr(Ii)/c);const C=i-f;C!==0&&(w=xr(x)/c);const M=fa+Wn*(S*f+w*C);M<l&&(a=d,l=M,o=v.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function vh(n,e,t,r){let i=0;for(let s=e,a=e+t;s<a;s++)i+=n[s*6+r*2];return i/t}class Hn{constructor(){this.boundingData=new Float32Array(6)}}function _h(n,e,t,r,i,s){let a=r,o=r+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let h=0;h<3;h++){let u=e[a*3+h];e[a*3+h]=e[o*3+h],e[o*3+h]=u}for(let h=0;h<6;h++){let u=t[a*6+h];t[a*6+h]=t[o*6+h],t[o*6+h]=u}a++,o--}else return a}}function bh(n,e,t,r,i,s){let a=r,o=r+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let h=n[a];n[a]=n[o],n[o]=h;for(let u=0;u<6;u++){let d=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=d}a++,o--}else return a}}function we(n,e){return e[n+15]===65535}function Pe(n,e){return e[n+6]}function Ee(n,e){return e[n+14]}function ke(n){return n+8}function Ae(n,e){return e[n+6]}function ba(n,e){return e[n+7]}let xa,Sr,Ui,Sa;const xh=Math.pow(2,32);function Yn(n){return"count"in n?1:1+Yn(n.left)+Yn(n.right)}function Sh(n,e,t){return xa=new Float32Array(t),Sr=new Uint32Array(t),Ui=new Uint16Array(t),Sa=new Uint8Array(t),Zn(n,e)}function Zn(n,e){const t=n/4,r=n/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)xa[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;Sa.set(new Uint8Array(a),n);for(let o=n,c=n+a.byteLength;o<c;o+=br){const l=o/2;we(l,Ui)||(Sr[o/4+6]+=t)}return n+a.byteLength}else{const a=e.offset,o=e.count;return Sr[t+6]=a,Ui[r+14]=o,Ui[r+15]=zi,n+br}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=Zn(n+br,a),l/4>xh)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Sr[t+6]=l/4,l=Zn(l,o),Sr[t+7]=c,l}}function wh(n,e){const t=(n.index?n.index.count:n.attributes.position.count)/3,r=t>2**16,i=r?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),a=r?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Mh(n,e,t,r,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:h}=i,u=n._indirectBuffer,d=n.geometry,p=d.index?d.index.array:null,y=h?bh:_h,g=Xt(d),f=new Float32Array(6);let m=!1;const v=new Hn;return qn(e,t,r,v.boundingData,f),b(v,t,r,f),v;function _(x){l&&l(x/g)}function b(x,S,w,C=null,M=0){if(!m&&M>=s&&(m=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),w<=o||M>=s)return _(S+w),x.offset=S,x.count=w,x;const T=gh(x.boundingData,C,e,S,w,c);if(T.axis===-1)return _(S+w),x.offset=S,x.count=w,x;const E=y(u,p,e,S,w,T);if(E===S||E===S+w)_(S+w),x.offset=S,x.count=w;else{x.splitAxis=T.axis;const P=new Hn,k=S,R=E-S;x.left=P,qn(e,k,R,P.boundingData,f),b(P,k,R,f,M+1);const U=new Hn,N=E,G=w-R;x.right=U,qn(e,N,G,U.boundingData,f),b(U,N,G,f,M+1)}return x}}function Th(n,e){const t=n.geometry;e.indirect&&(n._indirectBuffer=wh(t,e.useSharedArrayBuffer),fh(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),n._indirectBuffer||ph(t,e);const r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=mh(t),s=e.indirect?ma(t,e.range):ya(t,e.range);n._roots=s.map(a=>{const o=Mh(n,i,a.offset,a.count,e),c=Yn(o),l=new r(br*c);return Sh(0,o,l),l})}class mt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let r=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s][t];r=o<r?o:r,i=o>i?o:i}this.min=r,this.max=i}setFromPoints(e,t){let r=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);r=c<r?c:r,i=c>i?c:i}this.min=r,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}mt.prototype.setFromBox=function(){const n=new I;return function(e,t){const r=t.min,i=t.max;let s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){n.x=r.x*o+i.x*(1-o),n.y=r.y*c+i.y*(1-c),n.z=r.z*l+i.z*(1-l);const h=e.dot(n);s=Math.min(h,s),a=Math.max(h,a)}this.min=s,this.max=a}}();const Ch=function(){const n=new I,e=new I,t=new I;return function(r,i,s){const a=r.start,o=n,c=i.start,l=e;t.subVectors(a,c),n.subVectors(r.end,r.start),e.subVectors(i.end,i.start);const h=t.dot(l),u=l.dot(o),d=l.dot(l),p=t.dot(o),y=o.dot(o)*d-u*u;let g,f;y!==0?g=(h*u-p*d)/y:g=0,f=(h+g*u)/d,s.x=g,s.y=f}}(),Qn=function(){const n=new Vt,e=new I,t=new I;return function(r,i,s,a){Ch(r,i,n);let o=n.x,c=n.y;if(o>=0&&o<=1&&c>=0&&c<=1){r.at(o,s),i.at(c,a);return}else if(o>=0&&o<=1){c<0?i.at(0,a):i.at(1,a),r.closestPointToPoint(a,!0,s);return}else if(c>=0&&c<=1){o<0?r.at(0,s):r.at(1,s),i.closestPointToPoint(s,!0,a);return}else{let l;o<0?l=r.start:l=r.end;let h;c<0?h=i.start:h=i.end;const u=e,d=t;if(r.closestPointToPoint(h,!0,e),i.closestPointToPoint(l,!0,t),u.distanceToSquared(h)<=d.distanceToSquared(l)){s.copy(u),a.copy(h);return}else{s.copy(l),a.copy(d);return}}}}(),Ph=function(){const n=new I,e=new I,t=new xs,r=new ht;return function(i,s){const{radius:a,center:o}=i,{a:c,b:l,c:h}=s;if(r.start=c,r.end=l,r.closestPointToPoint(o,!0,n).distanceTo(o)<=a||(r.start=c,r.end=h,r.closestPointToPoint(o,!0,n).distanceTo(o)<=a)||(r.start=l,r.end=h,r.closestPointToPoint(o,!0,n).distanceTo(o)<=a))return!0;const u=s.getPlane(t);if(Math.abs(u.distanceToPoint(o))<=a){const d=u.projectPoint(o,e);if(s.containsPoint(d))return!0}return!1}}(),Eh=1e-15;function Kn(n){return Math.abs(n)<Eh}class Re extends Pt{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new mt),this.points=[this.a,this.b,this.c],this.sphere=new Ss,this.plane=new xs,this.needsUpdate=!0}intersectsSphere(e){return Ph(e,this)}update(){const e=this.a,t=this.b,r=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,i);const u=s[2],d=a[2];u.subVectors(t,r),d.setFromPoints(u,i);const p=s[3],y=a[3];p.subVectors(r,e),y.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Re.prototype.closestPointToSegment=function(){const n=new I,e=new I,t=new ht;return function(r,i=null,s=null){const{start:a,end:o}=r,c=this.points;let l,h=1/0;for(let u=0;u<3;u++){const d=(u+1)%3;t.start.copy(c[u]),t.end.copy(c[d]),Qn(t,r,n,e),l=n.distanceToSquared(e),l<h&&(h=l,i&&i.copy(n),s&&s.copy(e))}return this.closestPointToPoint(a,n),l=a.distanceToSquared(n),l<h&&(h=l,i&&i.copy(n),s&&s.copy(a)),this.closestPointToPoint(o,n),l=o.distanceToSquared(n),l<h&&(h=l,i&&i.copy(n),s&&s.copy(o)),Math.sqrt(h)}}(),Re.prototype.intersectsTriangle=function(){const n=new Re,e=new Array(3),t=new Array(3),r=new mt,i=new mt,s=new I,a=new I,o=new I,c=new I,l=new I,h=new ht,u=new ht,d=new ht,p=new I;function y(g,f,m){const v=g.points;let _=0,b=-1;for(let x=0;x<3;x++){const{start:S,end:w}=h;S.copy(v[x]),w.copy(v[(x+1)%3]),h.delta(a);const C=Kn(f.distanceToPoint(S));if(Kn(f.normal.dot(a))&&C){m.copy(h),_=2;break}const M=f.intersectLine(h,p);if(!M&&C&&p.copy(S),(M||C)&&!Kn(p.distanceTo(w))){if(_<=1)(_===1?m.start:m.end).copy(p),C&&(b=_);else if(_>=2){(b===1?m.start:m.end).copy(p),_=2;break}if(_++,_===2&&b===-1)break}}return _}return function(g,f=null,m=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(n.copy(g),n.update(),g=n);const v=this.plane,_=g.plane;if(Math.abs(v.normal.dot(_.normal))>1-1e-10){const b=this.satBounds,x=this.satAxes;t[0]=g.a,t[1]=g.b,t[2]=g.c;for(let C=0;C<4;C++){const M=b[C],T=x[C];if(r.setFromPoints(T,t),M.isSeparated(r))return!1}const S=g.satBounds,w=g.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const M=S[C],T=w[C];if(r.setFromPoints(T,e),M.isSeparated(r))return!1}for(let C=0;C<4;C++){const M=x[C];for(let T=0;T<4;T++){const E=w[T];if(s.crossVectors(M,E),r.setFromPoints(s,e),i.setFromPoints(s,t),r.isSeparated(i))return!1}}return f&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),f.start.set(0,0,0),f.end.set(0,0,0)),!0}else{const b=y(this,_,u);if(b===1&&g.containsPoint(u.end))return f&&(f.start.copy(u.end),f.end.copy(u.end)),!0;if(b!==2)return!1;const x=y(g,v,d);if(x===1&&this.containsPoint(d.end))return f&&(f.start.copy(d.end),f.end.copy(d.end)),!0;if(x!==2)return!1;if(u.delta(o),d.delta(c),o.dot(c)<0){let P=d.start;d.start=d.end,d.end=P}const S=u.start.dot(o),w=u.end.dot(o),C=d.start.dot(o),M=d.end.dot(o),T=w<C,E=S<M;return S!==M&&C!==w&&T===E?!1:(f&&(l.subVectors(u.start,d.start),l.dot(o)>0?f.start.copy(u.start):f.start.copy(d.start),l.subVectors(u.end,d.end),l.dot(o)<0?f.end.copy(u.end):f.end.copy(d.end)),!0)}}}(),Re.prototype.distanceToPoint=function(){const n=new I;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}(),Re.prototype.distanceToTriangle=function(){const n=new I,e=new I,t=["a","b","c"],r=new ht,i=new ht;return function(s,a=null,o=null){const c=a||o?r:null;if(this.intersectsTriangle(s,c))return(a||o)&&(a&&c.getCenter(a),o&&c.getCenter(o)),0;let l=1/0;for(let h=0;h<3;h++){let u;const d=t[h],p=s[d];this.closestPointToPoint(p,n),u=p.distanceToSquared(n),u<l&&(l=u,a&&a.copy(n),o&&o.copy(p));const y=this[d];s.closestPointToPoint(y,n),u=y.distanceToSquared(n),u<l&&(l=u,a&&a.copy(y),o&&o.copy(n))}for(let h=0;h<3;h++){const u=t[h],d=t[(h+1)%3];r.set(this[u],this[d]);for(let p=0;p<3;p++){const y=t[p],g=t[(p+1)%3];i.set(s[y],s[g]),Qn(r,i,n,e);const f=n.distanceToSquared(e);f<l&&(l=f,a&&a.copy(n),o&&o.copy(e))}}return Math.sqrt(l)}}();class fe{constructor(e,t,r){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new Ve,this.invMatrix=new Ve,this.points=new Array(8).fill().map(()=>new I),this.satAxes=new Array(3).fill().map(()=>new I),this.satBounds=new Array(3).fill().map(()=>new mt),this.alignedSatBounds=new Array(3).fill().map(()=>new mt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),r&&this.matrix.copy(r)}set(e,t,r){this.min.copy(e),this.max.copy(t),this.matrix.copy(r),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}fe.prototype.update=function(){return function(){const n=this.matrix,e=this.min,t=this.max,r=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){const u=1*c|2*l|4*h,d=r[u];d.x=c?t.x:e.x,d.y=l?t.y:e.y,d.z=h?t.z:e.z,d.applyMatrix4(n)}const i=this.satBounds,s=this.satAxes,a=r[0];for(let c=0;c<3;c++){const l=s[c],h=i[c],u=1<<c,d=r[u];l.subVectors(a,d),h.setFromPoints(l,r)}const o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),fe.prototype.intersectsBox=function(){const n=new mt;return function(e){this.needsUpdate&&this.update();const t=e.min,r=e.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(n.min=t.x,n.max=r.x,a[0].isSeparated(n)||(n.min=t.y,n.max=r.y,a[1].isSeparated(n))||(n.min=t.z,n.max=r.z,a[2].isSeparated(n)))return!1;for(let o=0;o<3;o++){const c=s[o],l=i[o];if(n.setFromBox(c,e),l.isSeparated(n))return!1}return!0}}(),fe.prototype.intersectsTriangle=function(){const n=new Re,e=new Array(3),t=new mt,r=new mt,i=new I;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(n.copy(s),n.update(),s=n);const a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let u=0;u<3;u++){const d=a[u],p=o[u];if(t.setFromPoints(p,e),d.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,h=this.points;for(let u=0;u<3;u++){const d=c[u],p=l[u];if(t.setFromPoints(p,h),d.isSeparated(t))return!1}for(let u=0;u<3;u++){const d=o[u];for(let p=0;p<4;p++){const y=l[p];if(i.crossVectors(d,y),t.setFromPoints(i,e),r.setFromPoints(i,h),t.isSeparated(r))return!1}}return!0}}(),fe.prototype.closestPointToPoint=function(){return function(n,e){return this.needsUpdate&&this.update(),e.copy(n).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),fe.prototype.distanceToPoint=function(){const n=new I;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}(),fe.prototype.distanceToBox=function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new ht),t=new Array(12).fill().map(()=>new ht),r=new I,i=new I;return function(s,a=0,o=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||c)&&(s.getCenter(i),this.closestPointToPoint(i,r),s.closestPointToPoint(r,i),o&&o.copy(r),c&&c.copy(i)),0;const l=a*a,h=s.min,u=s.max,d=this.points;let p=1/0;for(let g=0;g<8;g++){const f=d[g];i.copy(f).clamp(h,u);const m=f.distanceToSquared(i);if(m<p&&(p=m,o&&o.copy(f),c&&c.copy(i),m<l))return Math.sqrt(m)}let y=0;for(let g=0;g<3;g++)for(let f=0;f<=1;f++)for(let m=0;m<=1;m++){const v=(g+1)%3,_=(g+2)%3,b=f<<v|m<<_,x=1<<g|f<<v|m<<_,S=d[b],w=d[x];e[y].set(S,w);const C=n[g],M=n[v],T=n[_],E=t[y],P=E.start,k=E.end;P[C]=h[C],P[M]=f?h[M]:u[M],P[T]=m?h[T]:u[M],k[C]=u[C],k[M]=f?h[M]:u[M],k[T]=m?h[T]:u[M],y++}for(let g=0;g<=1;g++)for(let f=0;f<=1;f++)for(let m=0;m<=1;m++){i.x=g?u.x:h.x,i.y=f?u.y:h.y,i.z=m?u.z:h.z,this.closestPointToPoint(i,r);const v=i.distanceToSquared(r);if(v<p&&(p=v,o&&o.copy(r),c&&c.copy(i),v<l))return Math.sqrt(v)}for(let g=0;g<12;g++){const f=e[g];for(let m=0;m<12;m++){const v=t[m];Qn(f,v,r,i);const _=r.distanceToSquared(i);if(_<p&&(p=_,o&&o.copy(r),c&&c.copy(i),_<l))return Math.sqrt(_)}}return Math.sqrt(p)}}();class $n{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class kh extends $n{constructor(){super(()=>new Re)}}const Oe=new kh;class Ah{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=r=>{t&&e.push(t),t=r,this.float32Array=new Float32Array(r),this.uint16Array=new Uint16Array(r),this.uint32Array=new Uint32Array(r)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const X=new Ah;let xt,qt;const Ht=[],Ni=new $n(()=>new Ye);function Rh(n,e,t,r,i,s){xt=Ni.getPrimitive(),qt=Ni.getPrimitive(),Ht.push(xt,qt),X.setBuffer(n._roots[e]);const a=es(0,n.geometry,t,r,i,s);X.clearBuffer(),Ni.releasePrimitive(xt),Ni.releasePrimitive(qt),Ht.pop(),Ht.pop();const o=Ht.length;return o>0&&(qt=Ht[o-1],xt=Ht[o-2]),a}function es(n,e,t,r,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=X;let h=n*2;if(we(h,c)){const u=Pe(n,l),d=Ee(h,c);return Z(n,o,xt),r(u,d,!1,a,s+n,xt)}else{let u=function(E){const{uint16Array:P,uint32Array:k}=X;let R=E*2;for(;!we(R,P);)E=ke(E),R=E*2;return Pe(E,k)},d=function(E){const{uint16Array:P,uint32Array:k}=X;let R=E*2;for(;!we(R,P);)E=Ae(E,k),R=E*2;return Pe(E,k)+Ee(R,P)};const p=ke(n),y=Ae(n,l);let g=p,f=y,m,v,_,b;if(i&&(_=xt,b=qt,Z(g,o,_),Z(f,o,b),m=i(_),v=i(b),v<m)){g=y,f=p;const E=m;m=v,v=E,_=b}_||(_=xt,Z(g,o,_));const x=we(g*2,c),S=t(_,x,m,a+1,s+g);let w;if(S===Gn){const E=u(g),P=d(g)-E;w=r(E,P,!0,a+1,s+g,_)}else w=S&&es(g,e,t,r,i,s,a+1);if(w)return!0;b=qt,Z(f,o,b);const C=we(f*2,c),M=t(b,C,v,a+1,s+f);let T;if(M===Gn){const E=u(f),P=d(f)-E;T=r(E,P,!0,a+1,s+f,b)}else T=M&&es(f,e,t,r,i,s,a+1);return!!T}}const wr=new I,ts=new I;function Oh(n,e,t={},r=0,i=1/0){const s=r*r,a=i*i;let o=1/0,c=null;if(n.shapecast({boundsTraverseOrder:h=>(wr.copy(e).clamp(h.min,h.max),wr.distanceToSquared(e)),intersectsBounds:(h,u,d)=>d<o&&d<a,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,wr);const d=e.distanceToSquared(wr);return d<o&&(ts.copy(wr),o=d,c=u),d<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(ts):t.point=ts.clone(),t.distance=l,t.faceIndex=c,t}const zh=parseInt(Ga)>=169,At=new I,Rt=new I,Ot=new I,Di=new Vt,Fi=new Vt,Li=new Vt,wa=new I,Ma=new I,Ta=new I,Mr=new I;function Bh(n,e,t,r,i,s,a,o){let c;if(s===Ja?c=n.intersectTriangle(r,t,e,!0,i):c=n.intersectTriangle(e,t,r,s!==sn,i),c===null)return null;const l=n.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function Ih(n,e,t,r,i,s,a,o,c,l,h){At.fromBufferAttribute(e,s),Rt.fromBufferAttribute(e,a),Ot.fromBufferAttribute(e,o);const u=Bh(n,At,Rt,Ot,Mr,c,l,h);if(u){const d=new I;Pt.getBarycoord(Mr,At,Rt,Ot,d),r&&(Di.fromBufferAttribute(r,s),Fi.fromBufferAttribute(r,a),Li.fromBufferAttribute(r,o),u.uv=Pt.getInterpolation(Mr,At,Rt,Ot,Di,Fi,Li,new Vt)),i&&(Di.fromBufferAttribute(i,s),Fi.fromBufferAttribute(i,a),Li.fromBufferAttribute(i,o),u.uv1=Pt.getInterpolation(Mr,At,Rt,Ot,Di,Fi,Li,new Vt)),t&&(wa.fromBufferAttribute(t,s),Ma.fromBufferAttribute(t,a),Ta.fromBufferAttribute(t,o),u.normal=Pt.getInterpolation(Mr,At,Rt,Ot,wa,Ma,Ta,new I),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const p={a:s,b:a,c:o,normal:new I,materialIndex:0};Pt.getNormal(At,Rt,Ot,p.normal),u.face=p,u.faceIndex=s,zh&&(u.barycoord=d)}return u}function Vi(n,e,t,r,i,s,a){const o=r*3;let c=o+0,l=o+1,h=o+2;const u=n.index;n.index&&(c=u.getX(c),l=u.getX(l),h=u.getX(h));const{position:d,normal:p,uv:y,uv1:g}=n.attributes,f=Ih(t,d,p,y,g,c,l,h,e,s,a);return f?(f.faceIndex=r,i&&i.push(f),f):null}function te(n,e,t,r){const i=n.a,s=n.b,a=n.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=r.getX(o),i.y=r.getY(o),i.z=r.getZ(o),s.x=r.getX(c),s.y=r.getY(c),s.z=r.getZ(c),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l)}function Uh(n,e,t,r,i,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let h=r,u=r+i;h<u;h++)Vi(c,e,t,h,s,a,o)}function Nh(n,e,t,r,i,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,h=null;for(let u=r,d=r+i;u<d;u++){let p;p=Vi(o,e,t,u,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function Dh(n,e,t,r,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=n,u=e+n;h<u;h++){let d;if(d=h,te(a,d*3,c,l),a.needsUpdate=!0,r(a,d,i,s))return!0}return!1}function Fh(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,r=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=n._roots;for(let d=0,p=h.length;d<p;d++)s=h[d],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),u(0,l),l+=s.byteLength;function u(d,p,y=!1){const g=d*2;if(o[g+15]===zi){const f=a[d+6],m=o[g+14];let v=1/0,_=1/0,b=1/0,x=-1/0,S=-1/0,w=-1/0;for(let C=3*f,M=3*(f+m);C<M;C++){let T=r[C];const E=i.getX(T),P=i.getY(T),k=i.getZ(T);E<v&&(v=E),E>x&&(x=E),P<_&&(_=P),P>S&&(S=P),k<b&&(b=k),k>w&&(w=k)}return c[d+0]!==v||c[d+1]!==_||c[d+2]!==b||c[d+3]!==x||c[d+4]!==S||c[d+5]!==w?(c[d+0]=v,c[d+1]=_,c[d+2]=b,c[d+3]=x,c[d+4]=S,c[d+5]=w,!0):!1}else{const f=d+8,m=a[d+6],v=f+p,_=m+p;let b=y,x=!1,S=!1;e?b||(x=e.has(v),S=e.has(_),b=!x&&!S):(x=!0,S=!0);const w=b||x,C=b||S;let M=!1;w&&(M=u(f,p,b));let T=!1;C&&(T=u(m,p,b));const E=M||T;if(E)for(let P=0;P<3;P++){const k=f+P,R=m+P,U=c[k],N=c[k+3],G=c[R],B=c[R+3];c[d+P]=U<G?U:G,c[d+P+3]=N>B?N:B}return E}}}function St(n,e,t,r,i){let s,a,o,c,l,h;const u=1/t.direction.x,d=1/t.direction.y,p=1/t.direction.z,y=t.origin.x,g=t.origin.y,f=t.origin.z;let m=e[n],v=e[n+3],_=e[n+1],b=e[n+3+1],x=e[n+2],S=e[n+3+2];return u>=0?(s=(m-y)*u,a=(v-y)*u):(s=(v-y)*u,a=(m-y)*u),d>=0?(o=(_-g)*d,c=(b-g)*d):(o=(b-g)*d,c=(_-g)*d),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),p>=0?(l=(x-f)*p,h=(S-f)*p):(l=(S-f)*p,h=(x-f)*p),s>h||l>a)?!1:((l>s||s!==s)&&(s=l),(h<a||a!==a)&&(a=h),s<=i&&a>=r)}function Lh(n,e,t,r,i,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let h=r,u=r+i;h<u;h++){let d=l?l[h]:h;Vi(c,e,t,d,s,a,o)}}function Vh(n,e,t,r,i,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,h=null;for(let u=r,d=r+i;u<d;u++){let p;p=Vi(o,e,t,c?c[u]:u,null,s,a),p&&p.distance<l&&(h=p,l=p.distance)}return h}function jh(n,e,t,r,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let h=n,u=e+n;h<u;h++){let d;if(d=t.resolveTriangleIndex(h),te(a,d*3,c,l),a.needsUpdate=!0,r(a,d,i,s))return!0}return!1}function Jh(n,e,t,r,i,s,a){X.setBuffer(n._roots[e]),rs(0,n,t,r,i,s,a),X.clearBuffer()}function rs(n,e,t,r,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=X,h=n*2;if(we(h,c)){const u=Pe(n,l),d=Ee(h,c);Uh(e,t,r,u,d,i,s,a)}else{const u=ke(n);St(u,o,r,s,a)&&rs(u,e,t,r,i,s,a);const d=Ae(n,l);St(d,o,r,s,a)&&rs(d,e,t,r,i,s,a)}}const Gh=["x","y","z"];function Wh(n,e,t,r,i,s){X.setBuffer(n._roots[e]);const a=is(0,n,t,r,i,s);return X.clearBuffer(),a}function is(n,e,t,r,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=X;let l=n*2;if(we(l,o)){const h=Pe(n,c),u=Ee(l,o);return Nh(e,t,r,h,u,i,s)}else{const h=ba(n,c),u=Gh[h],d=r.direction[u]>=0;let p,y;d?(p=ke(n),y=Ae(n,c)):(p=Ae(n,c),y=ke(n));const g=St(p,a,r,i,s)?is(p,e,t,r,i,s):null;if(g){const m=g.point[u];if(d?m<=a[y+h]:m>=a[y+h+3])return g}const f=St(y,a,r,i,s)?is(y,e,t,r,i,s):null;return g&&f?g.distance<=f.distance?g:f:g||f||null}}const ji=new Ye,Yt=new Re,Zt=new Re,Tr=new Ve,Ca=new fe,Ji=new fe;function Xh(n,e,t,r){X.setBuffer(n._roots[e]);const i=ns(0,n,t,r);return X.clearBuffer(),i}function ns(n,e,t,r,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=X;let c=n*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Ca.set(t.boundingBox.min,t.boundingBox.max,r),i=Ca),we(c,a)){const l=e.geometry,h=l.index,u=l.attributes.position,d=t.index,p=t.attributes.position,y=Pe(n,o),g=Ee(c,a);if(Tr.copy(r).invert(),t.boundsTree)return Z(n,s,Ji),Ji.matrix.copy(Tr),Ji.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:f=>Ji.intersectsBox(f),intersectsTriangle:f=>{f.a.applyMatrix4(r),f.b.applyMatrix4(r),f.c.applyMatrix4(r),f.needsUpdate=!0;for(let m=y*3,v=(g+y)*3;m<v;m+=3)if(te(Zt,m,h,u),Zt.needsUpdate=!0,f.intersectsTriangle(Zt))return!0;return!1}});for(let f=y*3,m=(g+y)*3;f<m;f+=3){te(Yt,f,h,u),Yt.a.applyMatrix4(Tr),Yt.b.applyMatrix4(Tr),Yt.c.applyMatrix4(Tr),Yt.needsUpdate=!0;for(let v=0,_=d.count;v<_;v+=3)if(te(Zt,v,d,p),Zt.needsUpdate=!0,Yt.intersectsTriangle(Zt))return!0}}else{const l=n+8,h=o[n+6];return Z(l,s,ji),!!(i.intersectsBox(ji)&&ns(l,e,t,r,i)||(Z(h,s,ji),i.intersectsBox(ji)&&ns(h,e,t,r,i)))}}const Gi=new Ve,ss=new fe,Cr=new fe,qh=new I,Hh=new I,Yh=new I,Zh=new I;function Qh(n,e,t,r={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ss.set(e.boundingBox.min,e.boundingBox.max,t),ss.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,u=e.index,d=Oe.getPrimitive(),p=Oe.getPrimitive();let y=qh,g=Hh,f=null,m=null;i&&(f=Yh,m=Zh);let v=1/0,_=null,b=null;return Gi.copy(t).invert(),Cr.matrix.copy(Gi),n.shapecast({boundsTraverseOrder:x=>ss.distanceToBox(x),intersectsBounds:(x,S,w)=>w<v&&w<a?(S&&(Cr.min.copy(x.min),Cr.max.copy(x.max),Cr.needsUpdate=!0),!0):!1,intersectsRange:(x,S)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:w=>Cr.distanceToBox(w),intersectsBounds:(w,C,M)=>M<v&&M<a,intersectsRange:(w,C)=>{for(let M=w,T=w+C;M<T;M++){te(p,3*M,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=x,P=x+S;E<P;E++){te(d,3*E,l,c),d.needsUpdate=!0;const k=d.distanceToTriangle(p,y,f);if(k<v&&(g.copy(y),m&&m.copy(f),v=k,_=E,b=M),k<s)return!0}}}});{const w=Xt(e);for(let C=0,M=w;C<M;C++){te(p,3*C,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let T=x,E=x+S;T<E;T++){te(d,3*T,l,c),d.needsUpdate=!0;const P=d.distanceToTriangle(p,y,f);if(P<v&&(g.copy(y),m&&m.copy(f),v=P,_=T,b=C),P<s)return!0}}}}}),Oe.releasePrimitive(d),Oe.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(g):r.point=g.clone(),r.distance=v,r.faceIndex=_,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Gi),g.applyMatrix4(Gi),i.distance=g.sub(i.point).length(),i.faceIndex=b),r)}function Kh(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,r=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const h=n._roots;for(let d=0,p=h.length;d<p;d++)s=h[d],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),u(0,l),l+=s.byteLength;function u(d,p,y=!1){const g=d*2;if(o[g+15]===zi){const f=a[d+6],m=o[g+14];let v=1/0,_=1/0,b=1/0,x=-1/0,S=-1/0,w=-1/0;for(let C=f,M=f+m;C<M;C++){const T=3*n.resolveTriangleIndex(C);for(let E=0;E<3;E++){let P=T+E;P=r?r[P]:P;const k=i.getX(P),R=i.getY(P),U=i.getZ(P);k<v&&(v=k),k>x&&(x=k),R<_&&(_=R),R>S&&(S=R),U<b&&(b=U),U>w&&(w=U)}}return c[d+0]!==v||c[d+1]!==_||c[d+2]!==b||c[d+3]!==x||c[d+4]!==S||c[d+5]!==w?(c[d+0]=v,c[d+1]=_,c[d+2]=b,c[d+3]=x,c[d+4]=S,c[d+5]=w,!0):!1}else{const f=d+8,m=a[d+6],v=f+p,_=m+p;let b=y,x=!1,S=!1;e?b||(x=e.has(v),S=e.has(_),b=!x&&!S):(x=!0,S=!0);const w=b||x,C=b||S;let M=!1;w&&(M=u(f,p,b));let T=!1;C&&(T=u(m,p,b));const E=M||T;if(E)for(let P=0;P<3;P++){const k=f+P,R=m+P,U=c[k],N=c[k+3],G=c[R],B=c[R+3];c[d+P]=U<G?U:G,c[d+P+3]=N>B?N:B}return E}}}function $h(n,e,t,r,i,s,a){X.setBuffer(n._roots[e]),os(0,n,t,r,i,s,a),X.clearBuffer()}function os(n,e,t,r,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=X,h=n*2;if(we(h,c)){const u=Pe(n,l),d=Ee(h,c);Lh(e,t,r,u,d,i,s,a)}else{const u=ke(n);St(u,o,r,s,a)&&os(u,e,t,r,i,s,a);const d=Ae(n,l);St(d,o,r,s,a)&&os(d,e,t,r,i,s,a)}}const eu=["x","y","z"];function tu(n,e,t,r,i,s){X.setBuffer(n._roots[e]);const a=as(0,n,t,r,i,s);return X.clearBuffer(),a}function as(n,e,t,r,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=X;let l=n*2;if(we(l,o)){const h=Pe(n,c),u=Ee(l,o);return Vh(e,t,r,h,u,i,s)}else{const h=ba(n,c),u=eu[h],d=r.direction[u]>=0;let p,y;d?(p=ke(n),y=Ae(n,c)):(p=Ae(n,c),y=ke(n));const g=St(p,a,r,i,s)?as(p,e,t,r,i,s):null;if(g){const m=g.point[u];if(d?m<=a[y+h]:m>=a[y+h+3])return g}const f=St(y,a,r,i,s)?as(y,e,t,r,i,s):null;return g&&f?g.distance<=f.distance?g:f:g||f||null}}const Wi=new Ye,Qt=new Re,Kt=new Re,Pr=new Ve,Pa=new fe,Xi=new fe;function ru(n,e,t,r){X.setBuffer(n._roots[e]);const i=cs(0,n,t,r);return X.clearBuffer(),i}function cs(n,e,t,r,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=X;let c=n*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Pa.set(t.boundingBox.min,t.boundingBox.max,r),i=Pa),we(c,a)){const l=e.geometry,h=l.index,u=l.attributes.position,d=t.index,p=t.attributes.position,y=Pe(n,o),g=Ee(c,a);if(Pr.copy(r).invert(),t.boundsTree)return Z(n,s,Xi),Xi.matrix.copy(Pr),Xi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:f=>Xi.intersectsBox(f),intersectsTriangle:f=>{f.a.applyMatrix4(r),f.b.applyMatrix4(r),f.c.applyMatrix4(r),f.needsUpdate=!0;for(let m=y,v=g+y;m<v;m++)if(te(Kt,3*e.resolveTriangleIndex(m),h,u),Kt.needsUpdate=!0,f.intersectsTriangle(Kt))return!0;return!1}});for(let f=y,m=g+y;f<m;f++){const v=e.resolveTriangleIndex(f);te(Qt,3*v,h,u),Qt.a.applyMatrix4(Pr),Qt.b.applyMatrix4(Pr),Qt.c.applyMatrix4(Pr),Qt.needsUpdate=!0;for(let _=0,b=d.count;_<b;_+=3)if(te(Kt,_,d,p),Kt.needsUpdate=!0,Qt.intersectsTriangle(Kt))return!0}}else{const l=n+8,h=o[n+6];return Z(l,s,Wi),!!(i.intersectsBox(Wi)&&cs(l,e,t,r,i)||(Z(h,s,Wi),i.intersectsBox(Wi)&&cs(h,e,t,r,i)))}}const qi=new Ve,ls=new fe,Er=new fe,iu=new I,nu=new I,su=new I,ou=new I;function au(n,e,t,r={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ls.set(e.boundingBox.min,e.boundingBox.max,t),ls.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,h=e.attributes.position,u=e.index,d=Oe.getPrimitive(),p=Oe.getPrimitive();let y=iu,g=nu,f=null,m=null;i&&(f=su,m=ou);let v=1/0,_=null,b=null;return qi.copy(t).invert(),Er.matrix.copy(qi),n.shapecast({boundsTraverseOrder:x=>ls.distanceToBox(x),intersectsBounds:(x,S,w)=>w<v&&w<a?(S&&(Er.min.copy(x.min),Er.max.copy(x.max),Er.needsUpdate=!0),!0):!1,intersectsRange:(x,S)=>{if(e.boundsTree){const w=e.boundsTree;return w.shapecast({boundsTraverseOrder:C=>Er.distanceToBox(C),intersectsBounds:(C,M,T)=>T<v&&T<a,intersectsRange:(C,M)=>{for(let T=C,E=C+M;T<E;T++){const P=w.resolveTriangleIndex(T);te(p,3*P,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let k=x,R=x+S;k<R;k++){const U=n.resolveTriangleIndex(k);te(d,3*U,l,c),d.needsUpdate=!0;const N=d.distanceToTriangle(p,y,f);if(N<v&&(g.copy(y),m&&m.copy(f),v=N,_=k,b=T),N<s)return!0}}}})}else{const w=Xt(e);for(let C=0,M=w;C<M;C++){te(p,3*C,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let T=x,E=x+S;T<E;T++){const P=n.resolveTriangleIndex(T);te(d,3*P,l,c),d.needsUpdate=!0;const k=d.distanceToTriangle(p,y,f);if(k<v&&(g.copy(y),m&&m.copy(f),v=k,_=T,b=C),k<s)return!0}}}}}),Oe.releasePrimitive(d),Oe.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(g):r.point=g.clone(),r.distance=v,r.faceIndex=_,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(qi),g.applyMatrix4(qi),i.distance=g.sub(i.point).length(),i.faceIndex=b),r)}function cu(){return typeof SharedArrayBuffer<"u"}const kr=new X.constructor,Hi=new X.constructor,wt=new $n(()=>new Ye),$t=new Ye,er=new Ye,hs=new Ye,us=new Ye;let ds=!1;function lu(n,e,t,r){if(ds)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ds=!0;const i=n._roots,s=e._roots;let a,o=0,c=0;const l=new Ve().copy(t).invert();for(let h=0,u=i.length;h<u;h++){kr.setBuffer(i[h]),c=0;const d=wt.getPrimitive();Z(0,kr.float32Array,d),d.applyMatrix4(l);for(let p=0,y=s.length;p<y&&(Hi.setBuffer(s[p]),a=Ge(0,0,t,l,r,o,c,0,0,d),Hi.clearBuffer(),c+=s[p].length,!a);p++);if(wt.releasePrimitive(d),kr.clearBuffer(),o+=i[h].length,a)break}return ds=!1,a}function Ge(n,e,t,r,i,s=0,a=0,o=0,c=0,l=null,h=!1){let u,d;h?(u=Hi,d=kr):(u=kr,d=Hi);const p=u.float32Array,y=u.uint32Array,g=u.uint16Array,f=d.float32Array,m=d.uint32Array,v=d.uint16Array,_=n*2,b=e*2,x=we(_,g),S=we(b,v);let w=!1;if(S&&x)h?w=i(Pe(e,m),Ee(e*2,v),Pe(n,y),Ee(n*2,g),c,a+e,o,s+n):w=i(Pe(n,y),Ee(n*2,g),Pe(e,m),Ee(e*2,v),o,s+n,c,a+e);else if(S){const C=wt.getPrimitive();Z(e,f,C),C.applyMatrix4(t);const M=ke(n),T=Ae(n,y);Z(M,p,$t),Z(T,p,er);const E=C.intersectsBox($t),P=C.intersectsBox(er);w=E&&Ge(e,M,r,t,i,a,s,c,o+1,C,!h)||P&&Ge(e,T,r,t,i,a,s,c,o+1,C,!h),wt.releasePrimitive(C)}else{const C=ke(e),M=Ae(e,m);Z(C,f,hs),Z(M,f,us);const T=l.intersectsBox(hs),E=l.intersectsBox(us);if(T&&E)w=Ge(n,C,t,r,i,s,a,o,c+1,l,h)||Ge(n,M,t,r,i,s,a,o,c+1,l,h);else if(T)if(x)w=Ge(n,C,t,r,i,s,a,o,c+1,l,h);else{const P=wt.getPrimitive();P.copy(hs).applyMatrix4(t);const k=ke(n),R=Ae(n,y);Z(k,p,$t),Z(R,p,er);const U=P.intersectsBox($t),N=P.intersectsBox(er);w=U&&Ge(C,k,r,t,i,a,s,c,o+1,P,!h)||N&&Ge(C,R,r,t,i,a,s,c,o+1,P,!h),wt.releasePrimitive(P)}else if(E)if(x)w=Ge(n,M,t,r,i,s,a,o,c+1,l,h);else{const P=wt.getPrimitive();P.copy(us).applyMatrix4(t);const k=ke(n),R=Ae(n,y);Z(k,p,$t),Z(R,p,er);const U=P.intersectsBox($t),N=P.intersectsBox(er);w=U&&Ge(M,k,r,t,i,a,s,c,o+1,P,!h)||N&&Ge(M,R,r,t,i,a,s,c,o+1,P,!h),wt.releasePrimitive(P)}}return w}const Yi=new fe,Ea=new Ye,hu={strategy:Jn,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class zr{static serialize(e,t={}){t={cloneBuffers:!0,...t};const r=e.geometry,i=e._roots,s=e._indirectBuffer,a=r.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,r={}){r={setIndex:!0,indirect:!!e.indirectBuffer,...r};const{index:i,roots:s,indirectBuffer:a}=e,o=new zr(t,{...r,[Xn]:!0});if(o._roots=s,o._indirectBuffer=a||null,r.setIndex){const c=t.getIndex();if(c===null){const l=new Te(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...hu,[Xn]:!1},t),t.useSharedArrayBuffer&&!cu())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Xn]||(Th(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ye))),this.resolveTriangleIndex=t.indirect?r=>this._indirectBuffer[r]:r=>r}refit(e=null){return(this.indirect?Kh:Fh)(this,e)}traverse(e,t=0){const r=this._roots[t],i=new Uint32Array(r),s=new Uint16Array(r);a(0);function a(o,c=0){const l=o*2,h=s[l+15]===zi;if(h){const u=i[o+6],d=s[l+14];e(c,h,new Float32Array(r,o*4,6),u,d)}else{const u=o+br/4,d=i[o+6],p=i[o+7];e(c,h,new Float32Array(r,o*4,6),p)||(a(u,c+1),a(d,c+1))}}}raycast(e,t=ws,r=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),h=a.groups,u=c?t.side:t,d=this.indirect?$h:Jh;for(let p=0,y=s.length;p<y;p++){const g=l?t[h[p].materialIndex].side:u,f=o.length;if(d(this,p,g,e,o,r,i),l){const m=h[p].materialIndex;for(let v=f,_=o.length;v<_;v++)o[v].face.materialIndex=m}}return o}raycastFirst(e,t=ws,r=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const h=a.groups,u=o?t.side:t,d=this.indirect?tu:Wh;for(let p=0,y=s.length;p<y;p++){const g=c?t[h[p].materialIndex].side:u,f=d(this,p,g,e,r,i);f!=null&&(l==null||f.distance<l.distance)&&(l=f,c&&(f.face.materialIndex=h[p].materialIndex))}return l}intersectsGeometry(e,t){let r=!1;const i=this._roots,s=this.indirect?ru:Xh;for(let a=0,o=i.length;a<o&&(r=s(this,a,e,t),!r);a++);return r}shapecast(e){const t=Oe.getPrimitive(),r=this.indirect?jh:Dh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const u=a;a=(d,p,y,g,f)=>u(d,p,y,g,f)?!0:r(d,p,this,o,y,g,t)}else a||(o?a=(u,d,p,y)=>r(u,d,this,o,p,y,t):a=(u,d,p)=>p);let c=!1,l=0;const h=this._roots;for(let u=0,d=h.length;u<d;u++){const p=h[u];if(c=Rh(this,u,s,a,i,l),c)break;l+=p.byteLength}return Oe.releasePrimitive(t),c}bvhcast(e,t,r){let{intersectsRanges:i,intersectsTriangles:s}=r;const a=Oe.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?y=>{const g=this.resolveTriangleIndex(y);te(a,g*3,o,c)}:y=>{te(a,y*3,o,c)},h=Oe.getPrimitive(),u=e.geometry.index,d=e.geometry.attributes.position,p=e.indirect?y=>{const g=e.resolveTriangleIndex(y);te(h,g*3,u,d)}:y=>{te(h,y*3,u,d)};if(s){const y=(g,f,m,v,_,b,x,S)=>{for(let w=m,C=m+v;w<C;w++){p(w),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let M=g,T=g+f;M<T;M++)if(l(M),a.needsUpdate=!0,s(a,h,M,w,_,b,x,S))return!0}return!1};if(i){const g=i;i=function(f,m,v,_,b,x,S,w){return g(f,m,v,_,b,x,S,w)?!0:y(f,m,v,_,b,x,S,w)}}else i=y}return lu(this,e,t,i)}intersectsBox(e,t){return Yi.set(e.min,e.max,t),Yi.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Yi.intersectsBox(r),intersectsTriangle:r=>Yi.intersectsTriangle(r)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,r={},i={},s=0,a=1/0){return(this.indirect?au:Qh)(this,e,t,r,i,s,a)}closestPointToPoint(e,t={},r=0,i=1/0){return Oh(this,e,t,r,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Z(0,new Float32Array(t),Ea),e.union(Ea)}),e}}function ka(n,e,t){return n===null?null:(n.point.applyMatrix4(e.matrixWorld),n.distance=n.point.distanceTo(t.ray.origin),n.object=e,n)}const Zi=new Xa,Aa=new I,Ra=new Ve,uu=an.prototype.raycast,du=Wa.prototype.raycast,Oa=new I,ue=new an,Qi=[];function pu(n,e){this.isBatchedMesh?fu.call(this,n,e):mu.call(this,n,e)}function fu(n,e){if(this.boundsTrees){const t=this.boundsTrees,r=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;ue.material=this.material,ue.geometry=this.geometry;const a=ue.geometry.boundsTree,o=ue.geometry.drawRange;ue.geometry.boundingSphere===null&&(ue.geometry.boundingSphere=new Ss);for(let c=0,l=r.length;c<l;c++){if(!this.getVisibleAt(c))continue;const h=r[c].geometryIndex;if(ue.geometry.boundsTree=t[h],this.getMatrixAt(c,ue.matrixWorld).premultiply(s),!ue.geometry.boundsTree){this.getBoundingBoxAt(h,ue.geometry.boundingBox),this.getBoundingSphereAt(h,ue.geometry.boundingSphere);const u=i[h];ue.geometry.setDrawRange(u.start,u.count)}ue.raycast(n,Qi);for(let u=0,d=Qi.length;u<d;u++){const p=Qi[u];p.object=this,p.batchId=c,e.push(p)}Qi.length=0}ue.geometry.boundsTree=a,ue.geometry.drawRange=o,ue.material=null,ue.geometry=null}else du.call(this,n,e)}function mu(n,e){if(this.geometry.boundsTree){if(this.material===void 0)return;Ra.copy(this.matrixWorld).invert(),Zi.copy(n.ray).applyMatrix4(Ra),Oa.setFromMatrixScale(this.matrixWorld),Aa.copy(Zi.direction).multiply(Oa);const t=Aa.length(),r=n.near/t,i=n.far/t,s=this.geometry.boundsTree;if(n.firstHitOnly===!0){const a=ka(s.raycastFirst(Zi,this.material,r,i),this,n);a&&e.push(a)}else{const a=s.raycast(Zi,this.material,r,i);for(let o=0,c=a.length;o<c;o++){const l=ka(a[o],this,n);l&&e.push(l)}}}else uu.call(this,n,e)}function yu(n={}){return this.boundsTree=new zr(this,n),this.boundsTree}const zt=new I,Bt=new I,It=new I,za=new cn,Ki=new I,ps=new I,Ba=new cn,Ia=new cn,$i=new Ve,Ua=new Ve;function Ar(n,e){if(!n&&!e)return;const t=n.count===e.count,r=n.normalized===e.normalized,i=n.array.constructor===e.array.constructor,s=n.itemSize===e.itemSize;if(!t||!r||!i||!s)throw new Error}function Rr(n,e=null){const t=n.array.constructor,r=n.normalized,i=n.itemSize,s=e===null?n.count:e;return new Te(new t(i*s),i,r)}function Na(n,e,t=0){if(n.isInterleavedBufferAttribute){const r=n.itemSize;for(let i=0,s=n.count;i<s;i++){const a=i+t;e.setX(a,n.getX(i)),r>=2&&e.setY(a,n.getY(i)),r>=3&&e.setZ(a,n.getZ(i)),r>=4&&e.setW(a,n.getW(i))}}else{const r=e.array,i=r.constructor,s=r.BYTES_PER_ELEMENT*n.itemSize*t;new i(r.buffer,s,n.array.length).set(n.array)}}function gu(n,e,t){const r=n.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)r[s]+=i[s]*t}function Da(n,e,t){const r=n.skeleton,i=n.geometry,s=r.bones,a=r.boneInverses;Ba.fromBufferAttribute(i.attributes.skinIndex,e),Ia.fromBufferAttribute(i.attributes.skinWeight,e),$i.elements.fill(0);for(let o=0;o<4;o++){const c=Ia.getComponent(o);if(c!==0){const l=Ba.getComponent(o);Ua.multiplyMatrices(s[l].matrixWorld,a[l]),gu($i,Ua,c)}}return $i.multiply(n.bindMatrix).premultiply(n.bindMatrixInverse),t.transformDirection($i),t}function fs(n,e,t,r,i){Ki.set(0,0,0);for(let s=0,a=n.length;s<a;s++){const o=e[s],c=n[s];o!==0&&(ps.fromBufferAttribute(c,r),t?Ki.addScaledVector(ps,o):Ki.addScaledVector(ps.sub(i),o))}i.add(Ki)}function vu(n,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new ar){const r=n[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(n[0].attributes)),c={};let l=0;t.clearGroups();for(let h=0;h<n.length;++h){const u=n[h];let d=0;if(r!==(u.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const p in u.attributes){if(!o.has(p))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.');c[p]===void 0&&(c[p]=[]),c[p].push(u.attributes[p]),d++}if(d!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let p;if(r)p=u.index.count;else if(u.attributes.position!==void 0)p=u.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,p,h),l+=p}}if(r){let h=!1;if(!t.index){let u=0;for(let d=0;d<n.length;++d)u+=n[d].index.count;t.setIndex(new Te(new Uint32Array(u),1,!1)),h=!0}if(s||h){const u=t.index;let d=0,p=0;for(let y=0;y<n.length;++y){const g=n[y],f=g.index;if(a[y]!==!0)for(let m=0;m<f.count;++m)u.setX(d,f.getX(m)+p),d++;p+=g.attributes.position.count}}}for(const h in c){const u=c[h];if(!(h in t.attributes)){let y=0;for(const g in u)y+=u[g].count;t.setAttribute(h,Rr(c[h][0],y))}const d=t.attributes[h];let p=0;for(let y=0,g=u.length;y<g;y++){const f=u[y];a[y]!==!0&&Na(f,d,p),p+=f.count}}return t}function _u(n,e){if(n===null||e===null)return n===e;if(n.length!==e.length)return!1;for(let t=0,r=n.length;t<r;t++)if(n[t]!==e[t])return!1;return!0}function bu(n){const{index:e,attributes:t}=n;if(e)for(let r=0,i=e.count;r<i;r+=3){const s=e.getX(r),a=e.getX(r+2);e.setX(r,a),e.setX(r+2,s)}else for(const r in t){const i=t[r],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),h=i.getComponent(a+2,c);i.setComponent(a,c,h),i.setComponent(a+2,c,l)}}return n}class xu{constructor(e){this.matrixWorld=new Ve,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,r=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,r){r.boneTexture||r.computeBoneTexture(),r.update();const s=r.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,r=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&_u(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===r)}}class Su{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(r=>{r.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new ar),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new ar){let t=[];const{meshes:r,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=r.length;o<c;o++){const l=r[o],h=s[o],u=a.get(l);!u||u.didChange(l)?(this._convertToStaticGeometry(l,h),t.push(!1),u?u.update():a.set(l,new xu(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new Te(new Float32Array(0),4,!1))}else vu(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new ar){const r=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=r.attributes,c=t.attributes;!t.index&&r.index&&(t.index=r.index.clone()),c.position||t.setAttribute("position",Rr(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",Rr(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",Rr(o.tangent)),Ar(r.index,t.index),Ar(o.position,c.position),s&&Ar(o.normal,c.normal),a&&Ar(o.tangent,c.tangent);const l=o.position,h=s?o.normal:null,u=a?o.tangent:null,d=r.morphAttributes.position,p=r.morphAttributes.normal,y=r.morphAttributes.tangent,g=r.morphTargetsRelative,f=e.morphTargetInfluences,m=new qa;m.getNormalMatrix(e.matrixWorld),r.index&&t.index.array.set(r.index.array);for(let v=0,_=o.position.count;v<_;v++)zt.fromBufferAttribute(l,v),h&&Bt.fromBufferAttribute(h,v),u&&(za.fromBufferAttribute(u,v),It.fromBufferAttribute(u,v)),f&&(d&&fs(d,f,g,v,zt),p&&fs(p,f,g,v,Bt),y&&fs(y,f,g,v,It)),e.isSkinnedMesh&&(e.applyBoneTransform(v,zt),h&&Da(e,v,Bt),u&&Da(e,v,It)),i&&zt.applyMatrix4(e.matrixWorld),c.position.setXYZ(v,zt.x,zt.y,zt.z),h&&(i&&Bt.applyNormalMatrix(m),c.normal.setXYZ(v,Bt.x,Bt.y,Bt.z)),u&&(i&&It.transformDirection(e.matrixWorld),c.tangent.setXYZW(v,It.x,It.y,It.z,za.w));for(const v in this.attributes){const _=this.attributes[v];_==="position"||_==="tangent"||_==="normal"||!(_ in o)||(c[_]||t.setAttribute(_,Rr(o[_])),Ar(o[_],c[_]),Na(o[_],c[_]))}return e.matrixWorld.determinant()<0&&bu(t),t}}const wu=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:da,CENTER:Jn,CONTAINED:Gn,ExtendedTriangle:Re,MeshBVH:zr,OrientedBox:fe,SAH:pa,StaticGeometryGenerator:Su,acceleratedRaycast:pu,computeBoundsTree:yu},Symbol.toStringTag,{value:"Module"}));class Mu{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}export{jo as $70d766613f57b014$export$2e2bcd8739ae039,ih as BatchedParticleRenderer,ms as Builder,Or as ByteBuffer,Nt as ConstantColor,L as ConstantValue,We as Matrix4,zr as MeshBVH,ec as MotionController,nn as ParticleSystem,A as RenderMode,Ts as SIZE_PREFIX_LENGTH,ki as TrailParticle,Me as Vector4,Mu as WorkerBase,Oc as bundler,sh as createNoise4D,Ya as fetchProfile,lh as index,wu as index$1,Hc as md5,Jc as v5};