@volter/game-editor 0.5.154 → 0.5.155

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 (294) hide show
  1. package/BUNDLED_NOTICES +22 -22
  2. package/catalog/entries/blender.json +2 -2
  3. package/catalog/entries/music.json +2 -2
  4. package/dist/.vite/manifest.json +2129 -2129
  5. package/dist/assets/{AssetBudgetPanel-VWgpnuIc.js → AssetBudgetPanel-B2Wb7-b1.js} +3 -3
  6. package/dist/assets/{AudioViewer-DfHCf1lW.js → AudioViewer-gge--M-h.js} +1 -1
  7. package/dist/assets/{CanvasBoardDocument-CX4PNJyw.js → CanvasBoardDocument-CyGiXrEJ.js} +1 -1
  8. package/dist/assets/{CanvasSceneViewport-CQfbmxpt.js → CanvasSceneViewport-ChG9oRS8.js} +1 -1
  9. package/dist/assets/{ColorInput-BlrT435I.js → ColorInput-Dzpqy-J3.js} +1 -1
  10. package/dist/assets/{ColorPicker-Cd-YIyWU.js → ColorPicker-CqJPBHlh.js} +1 -1
  11. package/dist/assets/{EntityModelDocument-BmKOcswo.js → EntityModelDocument-D7XDf6uB.js} +1 -1
  12. package/dist/assets/{EnvironmentAssetDocument-BEuthcGj.js → EnvironmentAssetDocument-BgO7Hl3g.js} +1 -1
  13. package/dist/assets/{GameplaySessionTimeline-BN2umpRb.js → GameplaySessionTimeline-BBmwHCKA.js} +1 -1
  14. package/dist/assets/{ImageViewer-D9hKvFKP.js → ImageViewer-BjxoscVa.js} +1 -1
  15. package/dist/assets/InspectorObjectPreview-C87CasN_.js +1 -0
  16. package/dist/assets/{JsonAssetDocument-DMhiFUNl.js → JsonAssetDocument-D81JuRAm.js} +1 -1
  17. package/dist/assets/{LiveModuleDocument-ChrbfWzt.js → LiveModuleDocument-bgStMiU1.js} +1 -1
  18. package/dist/assets/{LutAssetDocument-D5cdrT07.js → LutAssetDocument-cl9Jq0Zw.js} +1 -1
  19. package/dist/assets/{ModelAssetDocument-Dh2Yp-5_.js → ModelAssetDocument-CYCLKpxJ.js} +1 -1
  20. package/dist/assets/{NonThreeAuthoringBootstrap-5lJjd2ul.js → NonThreeAuthoringBootstrap-DhHjvD5d.js} +1 -1
  21. package/dist/assets/{Object3DDocumentToolbar-DVNZXciL.js → Object3DDocumentToolbar-CQbARBIW.js} +1 -1
  22. package/dist/assets/Object3DDocumentViewport-BpiyRQ5p.js +2 -0
  23. package/dist/assets/{Object3DPreview-hnWxlKV2.js → Object3DPreview-BOZYzjz_.js} +1 -1
  24. package/dist/assets/{OnlineAssetDetail-TlMhKqz-.js → OnlineAssetDetail-DdKHHjxg.js} +1 -1
  25. package/dist/assets/{PlayBar-YdSOe6Mn.js → PlayBar-CAarfEOh.js} +1 -1
  26. package/dist/assets/{QuarksAssetDocument-CmVrkxb8.js → QuarksAssetDocument-GTbawoy7.js} +1 -1
  27. package/dist/assets/{ReactCanvasControls-Co3jjBJY.js → ReactCanvasControls-DIFkxeKv.js} +1 -1
  28. package/dist/assets/{RootSelectionOverlay-DRjJypx0.js → RootSelectionOverlay-Dv_w1D9s.js} +1 -1
  29. package/dist/assets/{ShaderAssetDocument-Bm1FTj5L.js → ShaderAssetDocument-OA-nshNN.js} +1 -1
  30. package/dist/assets/{ShadowEditor-Ah6UaoTL.js → ShadowEditor-Cp1QVCo9.js} +1 -1
  31. package/dist/assets/{SourceAssetViewer-CRp-jbVU.js → SourceAssetViewer-CGGHBzgL.js} +1 -1
  32. package/dist/assets/{StageHost-j9meef5x.js → StageHost-BMgCrIPG.js} +2 -2
  33. package/dist/assets/{StoryPreviewMount-ChfzCbJ3.js → StoryPreviewMount-CyF7FwI7.js} +1 -1
  34. package/dist/assets/{ThreeBoardDocument-DAGUbLlA.js → ThreeBoardDocument-DCJkLWU8.js} +2 -2
  35. package/dist/assets/{ThreeIsolationSceneContent-D48zPEk7.js → ThreeIsolationSceneContent-CxsM-QHW.js} +1 -1
  36. package/dist/assets/{ToolObject3DPreview-DgLF_qu6.js → ToolObject3DPreview-lsAoRxtr.js} +1 -1
  37. package/dist/assets/{Toolbar-B9tUYMZc.js → Toolbar-yvFlRv8R.js} +1 -1
  38. package/dist/assets/{TransientHint-DXKNt-QA.js → TransientHint-Bslncm_l.js} +1 -1
  39. package/dist/assets/{VideoViewer-Bi0Wh21M.js → VideoViewer-Ba-e91kP.js} +1 -1
  40. package/dist/assets/{ViewportShadingMenu-Csmdi4hc.js → ViewportShadingMenu-CgbuQ0e-.js} +1 -1
  41. package/dist/assets/{active-ingest-CmyN258P.js → active-ingest-CJ2U5L1O.js} +2 -2
  42. package/dist/assets/{animation-clock-BC2sWdly.js → animation-clock-CVpGQSVj.js} +1 -1
  43. package/dist/assets/{animation-mixers.service-DQX6SNau.js → animation-mixers.service-CI0K1tfi.js} +1 -1
  44. package/dist/assets/{animation-timeline.utility-CKWv5WpM.js → animation-timeline.utility-Wg6WxkxK.js} +1 -1
  45. package/dist/assets/{asset-budget-asset.menu-Cb9YAl0T.js → asset-budget-asset.menu-BbCBxjLY.js} +1 -1
  46. package/dist/assets/{asset-budget.action-Cgtt8vU9.js → asset-budget.action-CK8h0v1A.js} +1 -1
  47. package/dist/assets/{asset-budget.document-BVkKAZy5.js → asset-budget.document-CYVcDLvH.js} +1 -1
  48. package/dist/assets/{asset-budget.menu-DNkA4on_.js → asset-budget.menu-BcTijQ2R.js} +1 -1
  49. package/dist/assets/{asset-editor-persistence-BBd80LM5.js → asset-editor-persistence-DWp0E8cc.js} +1 -1
  50. package/dist/assets/{asset-loaders-BcvaZp8m.js → asset-loaders-Bo91oPiL.js} +1 -1
  51. package/dist/assets/{asset-preview-DmWBo3u0.js → asset-preview-BUpxsHNd.js} +1 -1
  52. package/dist/assets/{audio-unlock.service-DdLpyfa_.js → audio-unlock.service-CyiXe5qk.js} +1 -1
  53. package/dist/assets/{audio.utility-Py14n_vZ.js → audio.utility-BN4mANCx.js} +1 -1
  54. package/dist/assets/autoplay.service-CKBqjozr.js +1 -0
  55. package/dist/assets/{babylon-authoring-adapter-rHojeSh-.js → babylon-authoring-adapter-C-EAsfMr.js} +1 -1
  56. package/dist/assets/{binding-resolver-4nTdtOpk.js → binding-resolver-DoOAFM2m.js} +2 -2
  57. package/dist/assets/{blender-node-editor.document-GUoOIqO0.js → blender-node-editor.document-BzkGPs0i.js} +1 -1
  58. package/dist/assets/{blender-properties-tab-DFdr0HH9.js → blender-properties-tab-B1ggqOYB.js} +1 -1
  59. package/dist/assets/{blender-runtime-host-B63tuG7j.js → blender-runtime-host-MJZEPwHA.js} +1 -1
  60. package/dist/assets/{blender-runtime-skin-CPgzavkZ.js → blender-runtime-skin-hw-op7Nt.js} +34 -34
  61. package/dist/assets/{blender-runtime.document-BXMq3aHl.js → blender-runtime.document-CvTyAou8.js} +1 -1
  62. package/dist/assets/{blender-screenshot.menu-eE85nOyL.js → blender-screenshot.menu-C4VXpXVa.js} +1 -1
  63. package/dist/assets/{blender-timeline.document-pcpWfAfg.js → blender-timeline.document-BRFDd7JZ.js} +1 -1
  64. package/dist/assets/{blender-uv-editor.document-BALjSW5I.js → blender-uv-editor.document-CM09ITWu.js} +1 -1
  65. package/dist/assets/{blender-version.status-Iy8VtIIH.js → blender-version.status-CPyc_-kA.js} +1 -1
  66. package/dist/assets/{blender.command-B7a7jadi.js → blender.command-ktKz-2Zi.js} +1 -1
  67. package/dist/assets/{board-guides-Cnfvv0uu.js → board-guides-CCiyx8cT.js} +1 -1
  68. package/dist/assets/{bridge.command-BgMolZm1.js → bridge.command-tP5j6w72.js} +3 -3
  69. package/dist/assets/{browserAll-DNmYiuy_.js → browserAll-BSQVVrNG.js} +1 -1
  70. package/dist/assets/{build-player.document-C0_bEcCK.js → build-player.document-BwbBXtF5.js} +1 -1
  71. package/dist/assets/{build-profiles.document-DT2a6gH1.js → build-profiles.document-UiF_BsjE.js} +1 -1
  72. package/dist/assets/{build-progress.status-ycndNYab.js → build-progress.status-Bf5KpnxC.js} +1 -1
  73. package/dist/assets/{build-session-Bhmr1BX8.js → build-session-C4jVDt-u.js} +1 -1
  74. package/dist/assets/{build.action-DxTFOUGG.js → build.action-DP2d1Uhj.js} +1 -1
  75. package/dist/assets/{build.command-DpKOQydG.js → build.command-D5pyNcoj.js} +1 -1
  76. package/dist/assets/{build.header-zCX7El5x.js → build.header-DupBIAOw.js} +1 -1
  77. package/dist/assets/{build.menu-Y4MQiX4G.js → build.menu-DWrKtdoV.js} +1 -1
  78. package/dist/assets/{build.service-DHiSV5PL.js → build.service-qnz73gSX.js} +1 -1
  79. package/dist/assets/{camera-DI8pqzQ3.js → camera-C74U5X7o.js} +1 -1
  80. package/dist/assets/{camera-runtime.inspector-eJ8cyMzk.js → camera-runtime.inspector-B2l34Xhl.js} +1 -1
  81. package/dist/assets/{canvas-design-mount-CAFDbAPl.js → canvas-design-mount-D4M3E1AX.js} +3 -3
  82. package/dist/assets/{canvas-entry-runtime-CgJkCzp_.js → canvas-entry-runtime-CLOuJcgT.js} +2 -2
  83. package/dist/assets/{canvas-preview-frames-DMZo3rqI.js → canvas-preview-frames-CSCcu2sG.js} +1 -1
  84. package/dist/assets/{canvas-story-capture.service-CHnbQ9OT.js → canvas-story-capture.service-onD_xSpQ.js} +2 -2
  85. package/dist/assets/{capability-coverage-BMuTFU_9.js → capability-coverage-EnZ99FoT.js} +1 -1
  86. package/dist/assets/{collaboration-presence-Dqfb6e2Y.js → collaboration-presence-1_UMOAkw.js} +1 -1
  87. package/dist/assets/{collider-WqTqi5FX.js → collider-C6R1tHfa.js} +1 -1
  88. package/dist/assets/{component-board.service-DJYpMxt6.js → component-board.service-BX_2bwX3.js} +2 -2
  89. package/dist/assets/{component-board.service-RgOavG9Y.js → component-board.service-Ckl-5tA4.js} +2 -2
  90. package/dist/assets/{component-board.service-C-ukHwAR.js → component-board.service-Cuf_SXeA.js} +2 -2
  91. package/dist/assets/{component-contracts.service-B-uhvD4S.js → component-contracts.service-rI-rbvDG.js} +1 -1
  92. package/dist/assets/{component-instance-root-Ctbx3vOO.js → component-instance-root-wO1p-rLr.js} +1 -1
  93. package/dist/assets/{component-verbs.command-C07COqiF.js → component-verbs.command-O2bwqmK3.js} +1 -1
  94. package/dist/assets/{component-verbs.service-EKWGRKJg.js → component-verbs.service-BiiQMtJt.js} +1 -1
  95. package/dist/assets/{config-Bzq-GFuV.js → config-dVnV1cxW.js} +2 -2
  96. package/dist/assets/{configurations-BICGR-Zc.js → configurations-8qaUqMH7.js} +1 -1
  97. package/dist/assets/{connection.status-BMAWlexm.js → connection.status-vH9WCDDg.js} +1 -1
  98. package/dist/assets/{constraints.inspector-DQdAuWx-.js → constraints.inspector-C7UjUxPR.js} +1 -1
  99. package/dist/assets/{content-bounds-D_jbMNmm.js → content-bounds-Dl5Y3LLv.js} +1 -1
  100. package/dist/assets/{contract-system-adapters-D8SzcuZo.js → contract-system-adapters-BDUpDoKd.js} +1 -1
  101. package/dist/assets/{coverage.service-DZ4GmnS6.js → coverage.service-IS7Oklo8.js} +1 -1
  102. package/dist/assets/{create-runtime-BKAyWS74.js → create-runtime-Bucz0XVU.js} +1 -1
  103. package/dist/assets/{curve-DNYPUZIO.js → curve-D0Q6TczG.js} +1 -1
  104. package/dist/assets/{data-asset-LAsOyoML.js → data-asset-B0a1y8M-.js} +1 -1
  105. package/dist/assets/{data-ref-CbopN4AX.js → data-ref-dRt2Wi5L.js} +1 -1
  106. package/dist/assets/{debug-bridge-Cx3PFUcu.js → debug-bridge-EhDkhrLX.js} +1 -1
  107. package/dist/assets/{debug-registry-CcTdmLf3.js → debug-registry-B2THKz1v.js} +1 -1
  108. package/dist/assets/{deferred-ingest-play-DsV_qXEP.js → deferred-ingest-play-To3ZratW.js} +2 -2
  109. package/dist/assets/{design-time-canvas-mount-BGmhI2sv.js → design-time-canvas-mount-BnSaRAbS.js} +2 -2
  110. package/dist/assets/{design-time-layers-CyFYxvKE.js → design-time-layers-OMAIxOrv.js} +1 -1
  111. package/dist/assets/{design-time-mount.service-CeT_SfZi.js → design-time-mount.service-Bgr_nCDs.js} +2 -2
  112. package/dist/assets/{design-time-mount.service-Dui8o0rU.js → design-time-mount.service-RFkiqPIn.js} +2 -2
  113. package/dist/assets/{design-time-react-mount-3LQxFo0f.js → design-time-react-mount-BsSBoX7J.js} +1 -1
  114. package/dist/assets/{document-preview-three-BiKoHIJ7.js → document-preview-three-Qni0oVBw.js} +1 -1
  115. package/dist/assets/{dom-authoring-adapter-DBtypFqH.js → dom-authoring-adapter-DsUgOtQy.js} +1 -1
  116. package/dist/assets/{draco3d-CTue-r-D.js → draco3d-DyZllcka.js} +1 -1
  117. package/dist/assets/{edit-mode-audio.service-4vq1g0yL.js → edit-mode-audio.service-CjXNAZEs.js} +1 -1
  118. package/dist/assets/{edit-mode-authoring-CIXoejcH.js → edit-mode-authoring-BDgZD47j.js} +1 -1
  119. package/dist/assets/{edit-mode-networking.service-vseafVn2.js → edit-mode-networking.service-3dUr2g_0.js} +1 -1
  120. package/dist/assets/{editor-api-BboLGD_u.js → editor-api-DTrNJMXL.js} +1 -1
  121. package/dist/assets/{editor-layers-CYVQVJ5O.js → editor-layers-DwaX5UFy.js} +1 -1
  122. package/dist/assets/{editor-shell-store-B76wIXvV.js → editor-shell-store-aKHbAoCV.js} +1 -1
  123. package/dist/assets/{entity-object-C6hm5vYx.js → entity-object-BLJ-I8XT.js} +1 -1
  124. package/dist/assets/{extend-BUAnZzoH.js → extend-6LrR7eSL.js} +1 -1
  125. package/dist/assets/{fork-menu-D9wqdfzJ.js → fork-menu-V-FM6YuY.js} +1 -1
  126. package/dist/assets/{frame-debugger-store-BnZFxjhV.js → frame-debugger-store-DwDC0wAm.js} +1 -1
  127. package/dist/assets/{game-contract-seams-CzlxJGC2.js → game-contract-seams-C22a4B79.js} +1 -1
  128. package/dist/assets/{game-css-scope-transform-DhimYh-2.js → game-css-scope-transform-Wv0ZdTsR.js} +1 -1
  129. package/dist/assets/{game-document.service-CPeo8J5j.js → game-document.service-BzvFIWCc.js} +1 -1
  130. package/dist/assets/{game-eval.command-Zj-0kehE.js → game-eval.command-DpQn_nY8.js} +1 -1
  131. package/dist/assets/{game-module-access-B2UMV47n.js → game-module-access-BI6oBa8Y.js} +1 -1
  132. package/dist/assets/{game-network-Bof-cN2R.js → game-network-Deo8lcPw.js} +3 -3
  133. package/dist/assets/{gameplay-export-Bq4t4aCy.js → gameplay-export-BOLhxmII.js} +1 -1
  134. package/dist/assets/{gameplay-replay-DP08m8Vv.js → gameplay-replay-Dkvmv6hf.js} +1 -1
  135. package/dist/assets/{gameplay.command-Del3_mAr.js → gameplay.command-DCKqLv7C.js} +1 -1
  136. package/dist/assets/{generation-jobs-Mfqth2Xe.js → generation-jobs-6D562vMB.js} +1 -1
  137. package/dist/assets/{generation.service-CUJTwwYl.js → generation.service-BFRoLb7y.js} +1 -1
  138. package/dist/assets/{generations-CJUKodbu.js → generations-HwV1btKK.js} +1 -1
  139. package/dist/assets/{generations.status-mer9NXCK.js → generations.status-BLiDcKsg.js} +1 -1
  140. package/dist/assets/{hierarchy-marks-sMK9R4NU.js → hierarchy-marks-DeG4E4Ke.js} +1 -1
  141. package/dist/assets/{hosted-asset-materialization-BSvRWupx.js → hosted-asset-materialization-Bod7CEMF.js} +1 -1
  142. package/dist/assets/{index-Com2cl89.js → index-4hL3-0yz.js} +1 -1
  143. package/dist/assets/{index-DUA0RF9E.js → index-CHOT9sYh.js} +2 -2
  144. package/dist/assets/{index-DHFPVxsm.js → index-CLUA6PYq.js} +1 -1
  145. package/dist/assets/{index---JtxLq2.js → index-CdLhNxor.js} +1 -1
  146. package/dist/assets/{index-Cjv2Ynte.js → index-ClgrFOcX.js} +7 -7
  147. package/dist/assets/{index-ICvy7jWw.js → index-CyLPQ8pY.js} +1 -1
  148. package/dist/assets/{index-uTZA4wRW.js → index-DkYeh000.js} +1 -1
  149. package/dist/assets/{index-BpfZiKqX.js → index-KIR4Has5.js} +1 -1
  150. package/dist/assets/{index-CCOqpqGv.js → index-jS3rfNkZ.js} +1 -1
  151. package/dist/assets/{inference-diagnostics-DE1P5w14.js → inference-diagnostics-BmZ5ggEK.js} +1 -1
  152. package/dist/assets/{ingest-boot-viewport-Dynh3g5V.js → ingest-boot-viewport-CipkFljr.js} +1 -1
  153. package/dist/assets/{ingest-siblings-BsIV1T53.js → ingest-siblings-CEwYp-xg.js} +1 -1
  154. package/dist/assets/{ingest-source-persistence-BNek6mSi.js → ingest-source-persistence-CVU1rTj0.js} +1 -1
  155. package/dist/assets/{ingest.service-C0M-0EwA.js → ingest.service-bNqvcqoK.js} +1 -1
  156. package/dist/assets/{inspect-xUKvX80V.js → inspect-BunjdqX7.js} +1 -1
  157. package/dist/assets/instances.command-DzcXdKuG.js +1 -0
  158. package/dist/assets/{json-history-resource-C1pGwXuI.js → json-history-resource-CDEoQe1R.js} +1 -1
  159. package/dist/assets/{layered-pick-ASc-_oGG.js → layered-pick-guh6WlA7.js} +1 -1
  160. package/dist/assets/{light-CHiYAJQ0.js → light-BPZivpCK.js} +1 -1
  161. package/dist/assets/{live-project-verbs-D_8wWaCB.js → live-project-verbs-Bqmxbr2o.js} +1 -1
  162. package/dist/assets/{machine.document-CnvC2j0i.js → machine.document-CAFPFq5K.js} +1 -1
  163. package/dist/assets/{machines.finder-x38pLZFO.js → machines.finder-CbUWReMp.js} +1 -1
  164. package/dist/assets/{material-factory-wvMjnOTo.js → material-factory-BkyOzJ7B.js} +1 -1
  165. package/dist/assets/{material-B9iSj5st.js → material-huG6lNEK.js} +1 -1
  166. package/dist/assets/{mesh-C64nd8qK.js → mesh-CjCfRcFK.js} +1 -1
  167. package/dist/assets/{model-asset-sections.service-UsTToAYb.js → model-asset-sections.service-Dt4V2K2v.js} +1 -1
  168. package/dist/assets/{model-inspection-ae_w8T6s.js → model-inspection-BDA5jikL.js} +1 -1
  169. package/dist/assets/{model-thumbnail-ClOTX_JF.js → model-thumbnail-CF3qGQWb.js} +1 -1
  170. package/dist/assets/{models.finder-Bl6i3QOW.js → models.finder-yh4YeGrA.js} +1 -1
  171. package/dist/assets/{module-mode-CRBEidVP.js → module-mode-D8en13PD.js} +2 -2
  172. package/dist/assets/{mount-canvas-ingest-root-BFKVZ_nn.js → mount-canvas-ingest-root-JOkm2Ypj.js} +2 -2
  173. package/dist/assets/{mount-dom-ingest-root-CUBVJcU_.js → mount-dom-ingest-root-CVXFnJZb.js} +2 -2
  174. package/dist/assets/{mount-ingest-root-CyZae-B7.js → mount-ingest-root-C3o0o28C.js} +2 -2
  175. package/dist/assets/{mount-manifest-BMD5D62M.js → mount-manifest-d7WQ9MYp.js} +1 -1
  176. package/dist/assets/{mount-three-ingest-root-BgBc58nU.js → mount-three-ingest-root-Dqd4XWP1.js} +1 -1
  177. package/dist/assets/{mounted-authoring-DQ0-LgR6.js → mounted-authoring-B697dYuN.js} +1 -1
  178. package/dist/assets/{mounted-story-viewport-source-BsbduGue.js → mounted-story-viewport-source-BvNZ3QQn.js} +1 -1
  179. package/dist/assets/{native-debug-module-BUPFKtBc.js → native-debug-module-iX2-V5kg.js} +1 -1
  180. package/dist/assets/{navigation-DN3By10F.js → navigation-CIl9OY1F.js} +1 -1
  181. package/dist/assets/{navmesh.menu-BkB8EXHu.js → navmesh.menu-DrMoj7Ag.js} +1 -1
  182. package/dist/assets/{navmesh.service-C75Hdd7h.js → navmesh.service-CTr1NVfz.js} +1 -1
  183. package/dist/assets/network-observer.service-DyzpGKA7.js +1 -0
  184. package/dist/assets/{network.utility-C_lQVcOt.js → network.utility-Btexm5ao.js} +1 -1
  185. package/dist/assets/{object3d-document-session-registry-D8XSoEpf.js → object3d-document-session-registry-CADiW-LP.js} +2 -2
  186. package/dist/assets/{oid-transform-CvzWDfCe.js → oid-transform-Ca1oU_Ei.js} +1 -1
  187. package/dist/assets/{particles-JKSmSdCW.js → particles-D1oPwNJh.js} +1 -1
  188. package/dist/assets/{pixi-authoring-adapter-CAS5Elnh.js → pixi-authoring-adapter-B1BBfTju.js} +1 -1
  189. package/dist/assets/{pixi-live-write-target-BO-cO1Gl.js → pixi-live-write-target-BcUhtqmJ.js} +1 -1
  190. package/dist/assets/{play.command-Czxm8cvG.js → play.command-ScnwcvJr.js} +2 -2
  191. package/dist/assets/{presentation-xDN53iEZ.js → presentation-DPfnCjNA.js} +1 -1
  192. package/dist/assets/{product-mtU_pRkY.js → product-D_9saRiZ.js} +1 -1
  193. package/dist/assets/{profiler.action-Beoiw4ON.js → profiler.action-PXTw93E5.js} +1 -1
  194. package/dist/assets/{profiler.menu-BvuSldBS.js → profiler.menu-DPFV6QQD.js} +1 -1
  195. package/dist/assets/{profiler.utility-3qST7Ixj.js → profiler.utility-eDooJGnI.js} +1 -1
  196. package/dist/assets/{project-authoring-session-DAcbPWsU.js → project-authoring-session-BmeutotA.js} +2 -2
  197. package/dist/assets/{properties-bone-constraints.inspector-8yqXfdtn.js → properties-bone-constraints.inspector-BW0V1WXQ.js} +1 -1
  198. package/dist/assets/{properties-bone.inspector-CQ41MY4S.js → properties-bone.inspector-DIvTZhY8.js} +1 -1
  199. package/dist/assets/{properties-collection.inspector-Bdk09XCE.js → properties-collection.inspector-Dbt5XMhs.js} +1 -1
  200. package/dist/assets/{properties-constraints.inspector-CrNnu6jW.js → properties-constraints.inspector-5SvB0GDC.js} +1 -1
  201. package/dist/assets/{properties-data.inspector-84938huJ.js → properties-data.inspector-C-SngIsI.js} +1 -1
  202. package/dist/assets/{properties-material.inspector-BarvuWEj.js → properties-material.inspector-CYAWsvsX.js} +1 -1
  203. package/dist/assets/{properties-modifiers.inspector-Cm2y4Vb6.js → properties-modifiers.inspector-XN6BL-Ll.js} +1 -1
  204. package/dist/assets/{properties-object.inspector-Bf0eY0kG.js → properties-object.inspector-CfryU0kN.js} +1 -1
  205. package/dist/assets/{properties-output.inspector-D_NFrDmS.js → properties-output.inspector-COfgmFUW.js} +1 -1
  206. package/dist/assets/{properties-particles.inspector-BZaLS0X7.js → properties-particles.inspector-BCh0vFr6.js} +1 -1
  207. package/dist/assets/{properties-physics.inspector-BIwFNf1B.js → properties-physics.inspector-B6to1u6U.js} +1 -1
  208. package/dist/assets/{properties-render.inspector-BahRi3z3.js → properties-render.inspector-C4hVfo7j.js} +1 -1
  209. package/dist/assets/{properties-scene.inspector-C9p2pucf.js → properties-scene.inspector-dKta4xn5.js} +1 -1
  210. package/dist/assets/{properties-texture.inspector-J_6EK4f-.js → properties-texture.inspector-ZlNhW25m.js} +1 -1
  211. package/dist/assets/{properties-view-layer.inspector-BgniFnwR.js → properties-view-layer.inspector-CIxHmkDR.js} +1 -1
  212. package/dist/assets/{properties-world.inspector-CzcRcbOY.js → properties-world.inspector-Ce0q2dmK.js} +1 -1
  213. package/dist/assets/{r3f-design-session-C5_NQltq.js → r3f-design-session-1riISktt.js} +2 -2
  214. package/dist/assets/{r3f-physics-binding-BRcBDERW.js → r3f-physics-binding-DuG97FR9.js} +1 -1
  215. package/dist/assets/{r3f-source-authoring-adapter-N_d4ivmu.js → r3f-source-authoring-adapter-B8qqrdwk.js} +1 -1
  216. package/dist/assets/{react-canvas-navigation-BWgmHmpc.js → react-canvas-navigation-CxBm8iw8.js} +1 -1
  217. package/dist/assets/{react-inspector.service-C0telKKC.js → react-inspector.service-BcdePwno.js} +1 -1
  218. package/dist/assets/{react-story-board-CGF1vFuk.js → react-story-board-CMvkLAkF.js} +1 -1
  219. package/dist/assets/{react-three-rapier.esm-C8iL26_6.js → react-three-rapier.esm-D5svf-ME.js} +1 -1
  220. package/dist/assets/{react-world-authoring-adapter-CTCp7U6C.js → react-world-authoring-adapter-Dq8NqvWu.js} +1 -1
  221. package/dist/assets/{realm-services-CbgTofeT.js → realm-services-CqjVBanw.js} +1 -1
  222. package/dist/assets/{reflection-probe-capture.inspector-Dp3WN9X2.js → reflection-probe-capture.inspector-uEvyppEj.js} +1 -1
  223. package/dist/assets/{registry-DPYQgPRv.js → registry-D7lFIA8c.js} +1 -1
  224. package/dist/assets/{relative-import-specifier-CPSPKQKY.js → relative-import-specifier-CA9mSNXO.js} +1 -1
  225. package/dist/assets/{render-env-FpydFP_z.js → render-env-BHasp-z3.js} +1 -1
  226. package/dist/assets/{render-features-BYgh328X.js → render-features-sSb1-c5x.js} +1 -1
  227. package/dist/assets/{render-settings-DeBS5HzD.js → render-settings-CUbo4Sw5.js} +1 -1
  228. package/dist/assets/{resolve-three-BUKYgCMY.js → resolve-three-TQ367RQD.js} +3 -3
  229. package/dist/assets/{root-seam-contract-B33VsC6Z.js → root-seam-contract-CneTgNww.js} +1 -1
  230. package/dist/assets/{run-selection-BdsJXY3k.js → run-selection-CNsOQTEG.js} +1 -1
  231. package/dist/assets/{scene-capture-CMwvLaW9.js → scene-capture-KbdRgsD3.js} +1 -1
  232. package/dist/assets/{scene-document.service-DqReOF6t.js → scene-document.service-CmPSUocW.js} +2 -2
  233. package/dist/assets/{scene-framing-Dq-okRQ_.js → scene-framing-B5JC4NeG.js} +1 -1
  234. package/dist/assets/{seeded-random-BVi4_fs4.js → seeded-random-B6zqGkWP.js} +1 -1
  235. package/dist/assets/{setup-renderer-Cdx_0C3T.js → setup-renderer-efjIBSGF.js} +1 -1
  236. package/dist/assets/{source-object3d-authoring-adapter-CRQ5Iruy.js → source-object3d-authoring-adapter-DeeboYub.js} +1 -1
  237. package/dist/assets/{source-persistence-backend-BMbXR_WB.js → source-persistence-backend-Cwy93SmQ.js} +1 -1
  238. package/dist/assets/{stage-keyboard-ntaDc3sd.js → stage-keyboard-GNCaTXLA.js} +1 -1
  239. package/dist/assets/{stage-overlay-set-CmvMTUuj.js → stage-overlay-set-DV3SCzJb.js} +1 -1
  240. package/dist/assets/{stage-presence-markers--CsmPxKk.js → stage-presence-markers-CBEU1Kzo.js} +1 -1
  241. package/dist/assets/{stage-transform-tools-eaq_pmiw.js → stage-transform-tools-C9nNDW6n.js} +1 -1
  242. package/dist/assets/{standard-viewport-dressing-DaBfL3HV.js → standard-viewport-dressing-BJkGwiNT.js} +1 -1
  243. package/dist/assets/{state-watch.action-BBeD9rI6.js → state-watch.action-Doz_jrzS.js} +1 -1
  244. package/dist/assets/{state-watch.menu-BtjTGcSx.js → state-watch.menu-Dj4DUUxN.js} +1 -1
  245. package/dist/assets/{state-watch.utility-CLrBmLch.js → state-watch.utility-COPa8xpV.js} +1 -1
  246. package/dist/assets/{story-capture-DvMpONUV.js → story-capture-stRSY4PQ.js} +1 -1
  247. package/dist/assets/{story-documents-C1h5_Fvv.js → story-documents-CYzWYY1o.js} +1 -1
  248. package/dist/assets/{story-documents.service-BvSI6xU7.js → story-documents.service-C5r8KFEG.js} +1 -1
  249. package/dist/assets/{story-documents.service-e4GgOiBP.js → story-documents.service-DJBu4rve.js} +1 -1
  250. package/dist/assets/{story-media-presence-UYdQuwtq.js → story-media-presence-D4AIsAtK.js} +1 -1
  251. package/dist/assets/{story-pixi-preview-BVXZsJAe.js → story-pixi-preview-mPo3OFOd.js} +1 -1
  252. package/dist/assets/{story-presentation-CU1g5VGf.js → story-presentation-Dw4Vw65P.js} +1 -1
  253. package/dist/assets/{story-three-preview-DdduzS7D.js → story-three-preview-CWM0Rj7x.js} +2 -2
  254. package/dist/assets/{studio-environment-DZOr5iAy.js → studio-environment-Bw9zMFE8.js} +1 -1
  255. package/dist/assets/{surface-state-C0NqVDj5.js → surface-state-b_H4iOCJ.js} +1 -1
  256. package/dist/assets/{syntactic-prop-specs--oEbzaCI.js → syntactic-prop-specs-BCdwWi-T.js} +1 -1
  257. package/dist/assets/{team-playtest.service-DTvCDmka.js → team-playtest.service-CnxdTghn.js} +1 -1
  258. package/dist/assets/{three-CAVY58Dv.js → three-DWy0sZom.js} +1 -1
  259. package/dist/assets/{three-authoring-adapter-BDMrB8fC.js → three-authoring-adapter-9LcUBPaU.js} +1 -1
  260. package/dist/assets/three-authoring.service-DdTMF4A2.js +2 -0
  261. package/dist/assets/{three-ingest-runtime-BPTa3ryG.js → three-ingest-runtime-x9nLmUl-.js} +1 -1
  262. package/dist/assets/{three-integration-CJIrJnlD.js → three-integration-DB-xQHD5.js} +2 -2
  263. package/dist/assets/three-integration.service-DwToRGIc.js +1 -0
  264. package/dist/assets/{three-projection-core-BnoDtdZY.js → three-projection-core-IUovHgg_.js} +1 -1
  265. package/dist/assets/{three-state-_BZo8PPs.js → three-state-_ImCbP87.js} +1 -1
  266. package/dist/assets/{three-story-capture.service-CzIciMHs.js → three-story-capture.service-wKwfSnqA.js} +2 -2
  267. package/dist/assets/{three-story-model-BZAqoEDw.js → three-story-model-BxWKcl9d.js} +1 -1
  268. package/dist/assets/{three-viewport-presentation-DsFI1PyU.js → three-viewport-presentation-Bg86EsDJ.js} +1 -1
  269. package/dist/assets/{transform-mode-request-ROdyyd8M.js → transform-mode-request-BnV8FSnx.js} +1 -1
  270. package/dist/assets/{transport-strip-DAasOTBr.js → transport-strip-BZQnaxFN.js} +1 -1
  271. package/dist/assets/transport.header-1SF4ZbEd.js +1 -0
  272. package/dist/assets/{tuples-BFQG7BqZ.js → tuples-DR33sMq6.js} +1 -1
  273. package/dist/assets/{ui-board-document-C-DxG3Lj.js → ui-board-document-VJMvm6Ks.js} +2 -2
  274. package/dist/assets/{user-data-DxeJHxTz.js → user-data-DL6HsBPf.js} +1 -1
  275. package/dist/assets/{utility-view-state-CGlE9NdF.js → utility-view-state-ghWXsYXq.js} +1 -1
  276. package/dist/assets/{viewport-door-CTspfOX-.js → viewport-door-BV_lf5uK.js} +1 -1
  277. package/dist/assets/{viewport-root-presentation-Co7zteuS.js → viewport-root-presentation-CKqhX3mt.js} +1 -1
  278. package/dist/assets/{viewport-surface-status-P6QST-xH.js → viewport-surface-status-D7M2L2lI.js} +1 -1
  279. package/dist/assets/{webworkerAll-BH-WTk1P.js → webworkerAll-DDbFvxgB.js} +1 -1
  280. package/dist/assets/{workspace-arrangement-Bq8u7HUK.js → workspace-arrangement-86_8Kk5K.js} +1 -1
  281. package/dist/assets/{world-documents-DP1Ifjck.js → world-documents-DeNJUefV.js} +1 -1
  282. package/dist/assets/{world-root-stage-binding-1BOYY3z-.js → world-root-stage-binding-VOrldLB4.js} +1 -1
  283. package/dist/assets/{xstate-animation-binding-GsfnPsLk.js → xstate-animation-binding-747CfEeB.js} +1 -1
  284. package/dist/assets/{xstate-animation-meta-BS3q6oQo.js → xstate-animation-meta-DNMlMnr-.js} +1 -1
  285. package/dist-node/cli.js +16 -16
  286. package/package.json +16 -16
  287. package/dist/assets/InspectorObjectPreview-Bc9QgcaX.js +0 -1
  288. package/dist/assets/Object3DDocumentViewport-S-0l2Ppm.js +0 -2
  289. package/dist/assets/autoplay.service-BxNf_ohc.js +0 -1
  290. package/dist/assets/instances.command-Cc9TSete.js +0 -1
  291. package/dist/assets/network-observer.service-AzK_SzI2.js +0 -1
  292. package/dist/assets/three-authoring.service-DbhfcSSn.js +0 -2
  293. package/dist/assets/three-integration.service-DTBYyabq.js +0 -1
  294. package/dist/assets/transport.header-QMchTQhw.js +0 -1
@@ -1 +1 @@
1
- import{m as Q}from"./capability-coverage-BMuTFU_9.js";import{Z as h,az as X,aB as Y,kv as ee,kw as E,kx as D,ky as te,aC as O,kz as re,kA as oe,kB as ne,kC as se,bZ as ie,c2 as ae,b$ as ce,c0 as de,c1 as ue}from"./index-Cjv2Ynte.js";import{A as le,G as me,B as pe,C as fe,D as v,E as W,F as he,H as ge,I as ye,J as we,K as M,L as be,s as ve,c as Se,M as Ie,j as ke,k as Re,l as Ee,N as $e,u as Ce,y as Me,z as Pe,O as Le,r as Ge,P as Ae,Q as Te,p as De,o as Oe}from"./active-ingest-CmyN258P.js";import{p as We}from"./scene-framing-Dq-okRQ_.js";import{w as je,c as F,h as _e,i as ze,a as xe,b as Fe,r as He,e as Ue}from"./resolve-three-BUKYgCMY.js";import{b as Be}from"./component-instance-root-Ctbx3vOO.js";import{s as Ve}from"./ingest-source-persistence-BNek6mSi.js";import{a as j}from"./json-history-resource-C1pGwXuI.js";import{r as Ne}from"./three-ingest-runtime-BPTa3ryG.js";import{describeMountFailure as qe}from"./mount-readiness-DyAd17pe.js";import{formatLoopGateMessage as Je}from"./loop-gate-report-N52EWFGD.js";import{a as Ke,s as Ze}from"./three-authoring-adapter-BDMrB8fC.js";import{i as Qe}from"./renderer-ownership-BovSEcLv.js";import{installSceneCapture as Xe}from"./scene-capture-CMwvLaW9.js";import{s as Ye}from"./mount-ingest-root-CyZae-B7.js";import{m as et}from"./game-surface-defaults-D8S4cRxi.js";import{landIngestBootInEdit as tt}from"./ingest-boot-viewport-Dynh3g5V.js";import{b as rt,c as _,e as ot,g as H}from"./registry-DPYQgPRv.js";import"./game-contract-seams-CzlxJGC2.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";import"./contract-system-adapters-D8SzcuZo.js";import"./editor-layers-CYVQVJ5O.js";import"./workspace-arrangement-Bq8u7HUK.js";import"./three.core-3arARmh6.js";import"./dom-authoring-adapter-DBtypFqH.js";import"./react-world-authoring-adapter-CTCp7U6C.js";import"./board-guides-Cnfvv0uu.js";import"./relative-import-specifier-CPSPKQKY.js";import"./story-arg-descriptors-Ek86ExX7.js";import"./inspect-xUKvX80V.js";import"./inference-diagnostics-DE1P5w14.js";import"./writer-tw6EcuVO.js";import"./debug-registry-CcTdmLf3.js";import"./webgl-frame-capture-DdJkM2mi.js";import"./user-data-DxeJHxTz.js";import"./three.module-BLhyNg0e.js";import"./EffectComposer-BEAt0PtQ.js";import"./CopyShader-BzTUYzf6.js";import"./ShaderPass-DTnDQXm0.js";import"./Pass-D1MRT672.js";import"./CSS3DRenderer-BsAqfavI.js";import"./source-persistence-backend-BMbXR_WB.js";import"./three-projection-core-BnoDtdZY.js";import"./three-CAVY58Dv.js";import"./entity-object-C6hm5vYx.js";import"./three-contract-Dkt6PmWY.js";import"./viewport-editor-controls-BYaAZ_Ku.js";import"./body-marks-C1LxJtQb.js";import"./user-data-CODoGZqA.js";import"./object-marks-BnvSuCTt.js";import"./structural-ids-BOo2BRoY.js";import"./object3d-authoring-subject-XccsO0xG.js";import"./rapier-physics-adapter-CaZqWLu0.js";import"./r3f-physics-binding-BRcBDERW.js";import"./three-state-_BZo8PPs.js";import"./editor-shell-store-B76wIXvV.js";import"./output-pass-HurwNl0G.js";const nt="contract-hierarchy:group:",I="contract-hierarchy:render-tree";function U(t){return`${nt}${encodeURIComponent(t)}`}function z(t){return{id:U(t.id),label:t.label,secondaryLabel:`${t.count} ${t.count===1?"item":"items"}`,role:"folder",kind:"group",parentId:null,childIds:[]}}function st(t){if(!Array.isArray(t))throw new Error("hierarchy() did not return an array");const e=new Set;for(const o of t){if(typeof o!="object"||o===null||typeof o.id!="string"||o.id.trim().length===0||typeof o.label!="string"||o.label.trim().length===0||typeof o.count!="number"||!Number.isInteger(o.count)||o.count<0)throw new Error("hierarchy() returned an invalid { id, label, count } group");if(e.has(o.id))throw new Error(`hierarchy() returned duplicate id "${o.id}"`);e.add(o.id)}return t}function it(t,e){if(!e)return t;let o=!1;const n=()=>{try{return st(e())}catch(i){return o||(o=!0,h.warn(`Ignored invalid game-contract hierarchy: ${i instanceof Error?i.message:String(i)}`,"ingest")),[]}},r=()=>{const i=n(),a=t.hierarchy.roots();return i.length===0?a:[...i.map(z),{id:I,label:"Rendered objects",secondaryLabel:"live tree",role:"folder",kind:"group",parentId:null,childIds:a.map(d=>d.id)}]},s=i=>{const a=n(),d=a.find(w=>U(w.id)===i);if(d)return z(d);if(a.length>0&&i===I){const w=t.hierarchy.roots();return{id:I,label:"Rendered objects",secondaryLabel:"live tree",role:"folder",kind:"group",parentId:null,childIds:w.map(g=>g.id)}}const f=t.hierarchy.node(i);return a.length>0&&f?.parentId===null?{...f,parentId:I}:f},l=new Proxy(t.hierarchy,{get(i,a){if(a==="roots")return r;if(a==="node")return s;const d=Reflect.get(i,a,i);return typeof d=="function"?d.bind(i):d}}),m=i=>{const a=t.subscribe?.(i),d=e.subscribe?.(i);return()=>{a?.(),d?.()}};return new Proxy(t,{get(i,a){if(a==="hierarchy")return l;if(a==="subscribe")return m;const d=Reflect.get(i,a,i);return typeof d=="function"?d.bind(i):d}})}const at="volterDomStub";let x=null;function B(t){for(const e of le())if(e.surface.contains(t))return e;return null}function ct(){if(x!==null||typeof Element>"u")return;const t=Element.prototype,e=t.requestPointerLock;typeof e=="function"&&(x=e,t.requestPointerLock=function(o){const n=B(this);return n&&!n.gate()?(console.error("Ingested game requested pointer lock while its input gate is closed — refused. A game only captures the mouse while play is running AND the Game tab is active (the same predicate that gates its keyboard listeners); the editor viewport owns pointer lock otherwise. See packages/editor/src/ingest/game-pointer-lock.ts."),Promise.reject(new Error("pointer lock refused: game input gate is closed"))):e.call(this,o)})}function V(){if(typeof document>"u")return;const t=document.pointerLockElement;t&&B(t)&&document.exitPointerLock()}function dt(t,e,o,n,r={}){let s=null;return{setPaused(l){if(!l){n.resume(),r.realmGate?.release();return}n.pause(),r.realmGate?.hold(),ye({gate:r.realmGate??null,progress:()=>e.info?.render.frame??t.getDrawCount(),...r.verifyWindowMs!==void 0?{windowMs:r.verifyWindowMs}:{},...r.sleep!==void 0?{sleep:r.sleep}:{}}).then(m=>{s=m,r.onVerdict?.(m),m.loop!=="gated"&&console.warn(Je({worldId:o,reason:t.getAnimationLoop(e)?m.reason:`${m.reason} (this game also never called renderer.setAnimationLoop)`}))})},lastVerdict:()=>s}}function ut(t){let e=0;return t.traverse(o=>{Be(o)!==void 0&&e++}),e}async function lt(t,e=2500,o=n=>new Promise(r=>setTimeout(r,n))){const n=performance.now();for(;;){const r=ut(t);if(r>0)return r;if(performance.now()-n>=e)return 0;await o(100)}}function mt(t,e){const o=e.replace(/\\/g,"/"),n=o.startsWith("/")?"":t.replace(/\\/g,"/"),r=[];for(const s of`${n}/${o}`.split("/"))s===""||s==="."||(s===".."?r.pop():r.push(s));return`/${r.join("/")}`}function pt(t,e){if(!t)return[];const o=t.replace(/\\/g,"/").replace(/\/+$/,""),n=new Set([o]);for(const r of e??[]){const s=mt(o,r),l=s.slice(0,s.lastIndexOf("/"));l&&n.add(l)}return[...n]}function ft(t,e){if(!t||e.length===0)return!1;for(const o of Object.values(t)){const n=o?.file;if(typeof n!="string")continue;const r=n.replace(/\\/g,"/");if(e.some(s=>r===s||r.startsWith(`${s}/`)))return!0}return!1}function ht(t){return t.servedStampedSource||t.graphStamps>0?"oid-source":"structural"}async function gt(){if(!await re())return null;try{return await oe().index?.()??null}catch{return null}}function yt(t){return h.getEntries().filter(e=>e.level==="error"&&e.source==="runtime"&&e.timestamp>=t).slice(-10).map(e=>e.count>1?`${e.message} (×${e.count})`:e.message)}async function wt(t,e,o){if(o)try{return await o(),"declared"}catch(n){h.error(`Ingest game "${t}" declared \`window.volterGame.ready\` and it REJECTED (${String(n)}) — the world was already captured, so the host fell back to the measured settle wait. This root now reports readiness as measured.`,"ingest")}return await bt(e),"measured"}async function bt(t,e=5e3){const o=performance.now();let n=-1,r=0;return new Promise(s=>{const l=()=>{const m=t.children.length;if(r=m===n?r+1:0,n=m,r>=3||performance.now()-o>e)return s();setTimeout(l,120)};l()})}function vt(t,e){const o=ge(),n=v()?.root??o.__volterGameRoot,r=n instanceof HTMLElement&&n.contains(e)?n:e;return r.contains(t)?t:(r.parentElement!==t&&t.contains(r)||(F(r),r.parentElement!==t&&t.appendChild(r)),r)}async function St(t,e,o,n={}){const r=document.createElement("div");r.id="container",r.style.cssText=`position:absolute;inset:0;width:100%;height:100%;overflow:hidden;${me}`,et(r),o.appendChild(r);const s=pe(r);X(r);const l=O();l&&await Y(l.rootPath);const m=[];for(const c of e.domStubs??[]){if(document.getElementById(c))continue;const p=document.createElement("div");p.id=c,p.style.display="none",p.dataset[at]="",r.appendChild(p),m.push(p)}const i=await Ne(),a=i.three,d=Xe(a,i.EffectComposer,{isHostRenderer:Qe,additionalRendererCtors:[i.CSS3DRenderer],declaredScene:()=>{const c=be(v());return c.malformed!==null&&h.error(`Ingest game "${e.id}" ${c.malformed} — falling back to the MEASURED first-render adoption.`,"ingest"),c.world},onWorldAdoption:ee(e.id)});if(e.assets){const c=e.assets;a.DefaultLoadingManager.setURLModifier(p=>{for(const y of Object.keys(c))if(p.includes(y))return c[y];return p})}window.__volterMountCold=!0;const f=Date.now();await e.load();const w=n.captureTimeoutMs??1e4,g=fe(v());g.malformed!==null&&h.error(`Ingest game "${e.id}" ${g.malformed} — the host is measuring readiness instead.`,"ingest");const b=g.ready===null?"measured":"declared";E({rootId:e.id,mechanism:g.ready===null?"measured-wait":"contract-ready",source:b,state:"waiting"});let u;try{u=await d.waitForCapture({timeoutMs:w,onWait:c=>Ye(e.id,c)})}catch(c){d.uninstall(),a.DefaultLoadingManager.setURLModifier(y=>y);for(const y of m)y.remove();W(),r.remove(),D(e.id);const p=qe({gameId:e.id,timeoutMs:w,readinessSource:b,pageErrors:yt(f),cause:String(c)});throw E({rootId:e.id,mechanism:g.ready===null?"measured-wait":"contract-ready",source:b,state:"failed",failure:p.kind}),new Error(p.message)}const k=vt(r,u.renderer.domElement),S=he(v());S.malformed!==null&&h.error(`Ingest game "${e.id}" ${S.malformed} — the host is using the captured renderer’s canvas instead.`,"ingest"),te(e.id,S.canvas??u.renderer.domElement,S.canvas?"declared":"measured"),ct();const P=await wt(e.id,u.scene,g.ready);E({rootId:e.id,mechanism:P==="declared"?"contract-ready":"measured-wait",source:P,state:"ready"});const R={pause:()=>u.renderer.setAnimationLoop?.(null),resume:()=>{const c=d.getAnimationLoop(u.renderer);c&&u.renderer.setAnimationLoop?.(c)}};Ve(e.dataWriter??null);const q=pt(O()?.rootPath,e.sourceModules),L=ft(await gt(),q),J=L?0:await lt(u.scene),G=ht({servedStampedSource:L,graphStamps:J})==="oid-source"?Ke(t,u.scene,{worldId:e.id,loop:R,camera:u.camera,journal:j(e.id)}):Ze(t,u.scene,{loop:R,camera:u.camera,journal:j(e.id)}),A=dt(d,u.renderer,e.id,R,{realmGate:M(),onVerdict:()=>t.shell.notifyIngestEdit()}),{systems:T,renderDebug:K,debugCollisions:Z}=je({contractSystems:v()?.systems,surface:"three",runtime:u,setRenderPassHooks:c=>d.setRenderPassHooks(c)});for(const c of Z)h.error(`Ingest game "${e.id}" — ${c}; it will refuse`,"ingest");return{game:{kind:"three",scene:u.scene,camera:u.camera,drivesOwnLoop:!0,...Object.keys(T).length>0?{systems:T}:{},setPaused:c=>A.setPaused(c),resize:(c,p)=>{if(s.gameResizesItself){s.dispatchResize();return}const y=_e(c,p);u.renderer.setSize(y.width,y.height,!1),d.resizeComposers(y.width,y.height),F(k)},dispose:()=>{d.setRenderPassHooks(null),we(),K?.dispose();try{u.renderer.setAnimationLoop?.(null),u.renderer.dispose?.()}catch{}d.uninstall(),a.DefaultLoadingManager.setURLModifier(c=>c);for(const c of m)c.remove();V(),W(),ne(e.id),se(e.id),D(e.id),r.remove()},authoring:G},authoring:G,hostEl:r,capture:d,scene:u.scene,realmLoopVerdict:()=>A.lastVerdict()}}function It(t,e){const o={};for(const[n,r]of Object.entries(e)){const s=H(t,r),l=_[s];if(!l)throw new Error(`ingest discovery: "${t}"'s asset "${r}" did not match any served asset (looked for glob key "${s}" — available: ${Object.keys(_).join(", ")})`);o[n]=l}return o}function $(t,e){const o=H(t,e),n=ot[o];if(!n)throw new Error(`ingest discovery: "${t}"'s module "${e}" did not match any game module (looked for glob key "${o}").`);return n}function kt({folderId:t,manifest:e,root:o}){const{adapter:n}=o;if(!o.entry)throw new Error(`ingest discovery: "${t}" has no \`entry\` — an ingest root mounts the game's own entry module.`);return{...{id:o.id,name:e.name,description:o.description??"",gameVersion:e.version,sourceModules:xe(o.entry,o.world?.entry),...ze(n.dataWriter,s=>$(t,s)),...n.assets!==void 0?{assets:It(t,n.assets)}:{},...n.domStubs!==void 0?{domStubs:n.domStubs}:{},...n.captureTimeoutMs!==void 0?{captureTimeoutMs:n.captureTimeoutMs}:{}},load:Fe($(t,o.entry),n.contractShim===void 0?void 0:$(t,n.contractShim))}}let C=null;function Rt(){return C||(C=rt("three").map(kt).sort((t,e)=>t.id.localeCompare(e.id))),C}function Et(t){return Rt().find(e=>e.id===t)}function $t(t){return t==="devtools-observer"?"this game runs its OWN copy of three; the host reached its renderer through three's `__THREE_DEVTOOLS__` observation seam":"this game imports the host's three directly, in the editor's own realm"}function Ct(t){const{store:e,session:o,sessionId:n}=t,r=o.mount;if(!r)return;const s=r.authoring,l=Pe(),m=it(s,l?.systems?.hierarchy),i=Ue({primary:m,worldId:n,hostEl:r.hostEl,...l?.root?{declaredRoot:l.root}:{},store:e}),a=r.scene,d=new ResizeObserver(()=>{const u=t.gameContainer.getBoundingClientRect();u.width>0&&u.height>0&&r.game.resize?.(u.width,u.height)});d.observe(t.gameContainer),o.resizeObserver=d;const f=s.refresh(),w=s.measureWriteReach();h.log(`Captured live scene (${a.children.length} top-level children, ${r.capture.getDrawCount()} draws); ingested ${f.count} objects (${f.meshes} meshes, ${f.lights} lights`+(f.instancedMeshes>0?`, incl. ${f.instancedMeshes} InstancedMesh drawing ${f.instances} units`:"")+`); ${w.addressable} of ${w.total} have a source address — edits go to ${w.destination}`,"ingest"),Le(n,r.realmLoopVerdict?.()??void 0),ce(i),de(r.game.systems??{}),e.enterPlayScene(a,void 0,s.objectMapSnapshot()),e.focusOnScene(()=>We(r.capture.captured?.camera,a)),tt(),e.shell.notifyIngestEdit(),ue();const g=Q({authoring:i});Ge({reach:g,reachMechanism:$t(r.capture.capturedVia),loop:()=>Ae(r),writeReach:()=>s.measureWriteReach()});const b={gameId:n,...Oe(i),drawCount:()=>r.capture.getDrawCount(),get reflected(){return s.refresh()},get sceneChildren(){return a.children.length},reach:g,resize:(u,k)=>r.game.resize?.(u,k),...o.lifecycle.setPaused?{setPaused:o.lifecycle.setPaused}:{}};Te(b,r),De("__volterIngest",b)}async function Mt(t,e,o){Se(),Ie(o),await ie();const n=ae();if(!n){h.error("Game container not mounted — cannot ingest","ingest");return}t.shell.setPlayState("playing"),h.log(`Ingesting unmodified game: ${e.name}`,"ingest");const r=()=>t.shell.playState==="playing"&&t.shell.activeViewportTab==="play";try{const s={captureTimeoutMs:e.captureTimeoutMs},l=await St(t,e,n,s),m=l.game.setPaused,i={store:t,mount:l,lifecycle:ke(m?{setPaused:a=>m(a),step:()=>M()?.step(1),canStep:()=>l.realmLoopVerdict?.()?.loop==="gated"&&M()!==null}:{pauseGap:"the captured Three root exposes no mounted setPaused capability"})};Re({kind:"three",session:i,siblings:[],worldId:o}),Ee(r),i.inputGateUnsubscribe=t.shell.subscribe(()=>{r()||V()}),$e(Ce()),Ct({store:t,session:i,gameContainer:n,sessionId:o})}catch(s){throw h.error(`Ingest failed: ${s}`,"ingest"),Me(),s}}function N(t,e,o){return ve(()=>Mt(t,e,o))}async function xr(t,e){const o=Et(e);if(!o){h.error(`Unknown ingest game: ${e}`,"ingest");return}return N(t,o,e)}async function Fr(t,e,o){const n=He(e,o);return N(t,n,e.id)}export{N as mountThreeIngestRoot,xr as mountThreeIngestRootById,Fr as mountThreeIngestRootFromManifest};
1
+ import{m as Q}from"./capability-coverage-EnZ99FoT.js";import{Z as h,az as X,aB as Y,kv as ee,kw as E,kx as D,ky as te,aC as O,kz as re,kA as oe,kB as ne,kC as se,bZ as ie,c2 as ae,b$ as ce,c0 as de,c1 as ue}from"./index-ClgrFOcX.js";import{A as le,G as me,B as pe,C as fe,D as v,E as W,F as he,H as ge,I as ye,J as we,K as M,L as be,s as ve,c as Se,M as Ie,j as ke,k as Re,l as Ee,N as $e,u as Ce,y as Me,z as Pe,O as Le,r as Ge,P as Ae,Q as Te,p as De,o as Oe}from"./active-ingest-CJ2U5L1O.js";import{p as We}from"./scene-framing-B5JC4NeG.js";import{w as je,c as F,h as _e,i as ze,a as xe,b as Fe,r as He,e as Ue}from"./resolve-three-TQ367RQD.js";import{b as Be}from"./component-instance-root-wO1p-rLr.js";import{s as Ve}from"./ingest-source-persistence-CVU1rTj0.js";import{a as j}from"./json-history-resource-CDEoQe1R.js";import{r as Ne}from"./three-ingest-runtime-x9nLmUl-.js";import{describeMountFailure as qe}from"./mount-readiness-DyAd17pe.js";import{formatLoopGateMessage as Je}from"./loop-gate-report-N52EWFGD.js";import{a as Ke,s as Ze}from"./three-authoring-adapter-9LcUBPaU.js";import{i as Qe}from"./renderer-ownership-BovSEcLv.js";import{installSceneCapture as Xe}from"./scene-capture-KbdRgsD3.js";import{s as Ye}from"./mount-ingest-root-C3o0o28C.js";import{m as et}from"./game-surface-defaults-D8S4cRxi.js";import{landIngestBootInEdit as tt}from"./ingest-boot-viewport-CipkFljr.js";import{b as rt,c as _,e as ot,g as H}from"./registry-D7lFIA8c.js";import"./game-contract-seams-C22a4B79.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";import"./contract-system-adapters-BDUpDoKd.js";import"./editor-layers-DwaX5UFy.js";import"./workspace-arrangement-86_8Kk5K.js";import"./three.core-3arARmh6.js";import"./dom-authoring-adapter-DsUgOtQy.js";import"./react-world-authoring-adapter-Dq8NqvWu.js";import"./board-guides-CCiyx8cT.js";import"./relative-import-specifier-CA9mSNXO.js";import"./story-arg-descriptors-Ek86ExX7.js";import"./inspect-BunjdqX7.js";import"./inference-diagnostics-BmZ5ggEK.js";import"./writer-tw6EcuVO.js";import"./debug-registry-B2THKz1v.js";import"./webgl-frame-capture-DdJkM2mi.js";import"./user-data-DL6HsBPf.js";import"./three.module-BLhyNg0e.js";import"./EffectComposer-BEAt0PtQ.js";import"./CopyShader-BzTUYzf6.js";import"./ShaderPass-DTnDQXm0.js";import"./Pass-D1MRT672.js";import"./CSS3DRenderer-BsAqfavI.js";import"./source-persistence-backend-Cwy93SmQ.js";import"./three-projection-core-IUovHgg_.js";import"./three-DWy0sZom.js";import"./entity-object-BLJ-I8XT.js";import"./three-contract-Dkt6PmWY.js";import"./viewport-editor-controls-BYaAZ_Ku.js";import"./body-marks-C1LxJtQb.js";import"./user-data-CODoGZqA.js";import"./object-marks-BnvSuCTt.js";import"./structural-ids-BOo2BRoY.js";import"./object3d-authoring-subject-XccsO0xG.js";import"./rapier-physics-adapter-CaZqWLu0.js";import"./r3f-physics-binding-DuG97FR9.js";import"./three-state-_ImCbP87.js";import"./editor-shell-store-aKHbAoCV.js";import"./output-pass-HurwNl0G.js";const nt="contract-hierarchy:group:",I="contract-hierarchy:render-tree";function U(t){return`${nt}${encodeURIComponent(t)}`}function z(t){return{id:U(t.id),label:t.label,secondaryLabel:`${t.count} ${t.count===1?"item":"items"}`,role:"folder",kind:"group",parentId:null,childIds:[]}}function st(t){if(!Array.isArray(t))throw new Error("hierarchy() did not return an array");const e=new Set;for(const o of t){if(typeof o!="object"||o===null||typeof o.id!="string"||o.id.trim().length===0||typeof o.label!="string"||o.label.trim().length===0||typeof o.count!="number"||!Number.isInteger(o.count)||o.count<0)throw new Error("hierarchy() returned an invalid { id, label, count } group");if(e.has(o.id))throw new Error(`hierarchy() returned duplicate id "${o.id}"`);e.add(o.id)}return t}function it(t,e){if(!e)return t;let o=!1;const n=()=>{try{return st(e())}catch(i){return o||(o=!0,h.warn(`Ignored invalid game-contract hierarchy: ${i instanceof Error?i.message:String(i)}`,"ingest")),[]}},r=()=>{const i=n(),a=t.hierarchy.roots();return i.length===0?a:[...i.map(z),{id:I,label:"Rendered objects",secondaryLabel:"live tree",role:"folder",kind:"group",parentId:null,childIds:a.map(d=>d.id)}]},s=i=>{const a=n(),d=a.find(w=>U(w.id)===i);if(d)return z(d);if(a.length>0&&i===I){const w=t.hierarchy.roots();return{id:I,label:"Rendered objects",secondaryLabel:"live tree",role:"folder",kind:"group",parentId:null,childIds:w.map(g=>g.id)}}const f=t.hierarchy.node(i);return a.length>0&&f?.parentId===null?{...f,parentId:I}:f},l=new Proxy(t.hierarchy,{get(i,a){if(a==="roots")return r;if(a==="node")return s;const d=Reflect.get(i,a,i);return typeof d=="function"?d.bind(i):d}}),m=i=>{const a=t.subscribe?.(i),d=e.subscribe?.(i);return()=>{a?.(),d?.()}};return new Proxy(t,{get(i,a){if(a==="hierarchy")return l;if(a==="subscribe")return m;const d=Reflect.get(i,a,i);return typeof d=="function"?d.bind(i):d}})}const at="volterDomStub";let x=null;function B(t){for(const e of le())if(e.surface.contains(t))return e;return null}function ct(){if(x!==null||typeof Element>"u")return;const t=Element.prototype,e=t.requestPointerLock;typeof e=="function"&&(x=e,t.requestPointerLock=function(o){const n=B(this);return n&&!n.gate()?(console.error("Ingested game requested pointer lock while its input gate is closed — refused. A game only captures the mouse while play is running AND the Game tab is active (the same predicate that gates its keyboard listeners); the editor viewport owns pointer lock otherwise. See packages/editor/src/ingest/game-pointer-lock.ts."),Promise.reject(new Error("pointer lock refused: game input gate is closed"))):e.call(this,o)})}function V(){if(typeof document>"u")return;const t=document.pointerLockElement;t&&B(t)&&document.exitPointerLock()}function dt(t,e,o,n,r={}){let s=null;return{setPaused(l){if(!l){n.resume(),r.realmGate?.release();return}n.pause(),r.realmGate?.hold(),ye({gate:r.realmGate??null,progress:()=>e.info?.render.frame??t.getDrawCount(),...r.verifyWindowMs!==void 0?{windowMs:r.verifyWindowMs}:{},...r.sleep!==void 0?{sleep:r.sleep}:{}}).then(m=>{s=m,r.onVerdict?.(m),m.loop!=="gated"&&console.warn(Je({worldId:o,reason:t.getAnimationLoop(e)?m.reason:`${m.reason} (this game also never called renderer.setAnimationLoop)`}))})},lastVerdict:()=>s}}function ut(t){let e=0;return t.traverse(o=>{Be(o)!==void 0&&e++}),e}async function lt(t,e=2500,o=n=>new Promise(r=>setTimeout(r,n))){const n=performance.now();for(;;){const r=ut(t);if(r>0)return r;if(performance.now()-n>=e)return 0;await o(100)}}function mt(t,e){const o=e.replace(/\\/g,"/"),n=o.startsWith("/")?"":t.replace(/\\/g,"/"),r=[];for(const s of`${n}/${o}`.split("/"))s===""||s==="."||(s===".."?r.pop():r.push(s));return`/${r.join("/")}`}function pt(t,e){if(!t)return[];const o=t.replace(/\\/g,"/").replace(/\/+$/,""),n=new Set([o]);for(const r of e??[]){const s=mt(o,r),l=s.slice(0,s.lastIndexOf("/"));l&&n.add(l)}return[...n]}function ft(t,e){if(!t||e.length===0)return!1;for(const o of Object.values(t)){const n=o?.file;if(typeof n!="string")continue;const r=n.replace(/\\/g,"/");if(e.some(s=>r===s||r.startsWith(`${s}/`)))return!0}return!1}function ht(t){return t.servedStampedSource||t.graphStamps>0?"oid-source":"structural"}async function gt(){if(!await re())return null;try{return await oe().index?.()??null}catch{return null}}function yt(t){return h.getEntries().filter(e=>e.level==="error"&&e.source==="runtime"&&e.timestamp>=t).slice(-10).map(e=>e.count>1?`${e.message} (×${e.count})`:e.message)}async function wt(t,e,o){if(o)try{return await o(),"declared"}catch(n){h.error(`Ingest game "${t}" declared \`window.volterGame.ready\` and it REJECTED (${String(n)}) — the world was already captured, so the host fell back to the measured settle wait. This root now reports readiness as measured.`,"ingest")}return await bt(e),"measured"}async function bt(t,e=5e3){const o=performance.now();let n=-1,r=0;return new Promise(s=>{const l=()=>{const m=t.children.length;if(r=m===n?r+1:0,n=m,r>=3||performance.now()-o>e)return s();setTimeout(l,120)};l()})}function vt(t,e){const o=ge(),n=v()?.root??o.__volterGameRoot,r=n instanceof HTMLElement&&n.contains(e)?n:e;return r.contains(t)?t:(r.parentElement!==t&&t.contains(r)||(F(r),r.parentElement!==t&&t.appendChild(r)),r)}async function St(t,e,o,n={}){const r=document.createElement("div");r.id="container",r.style.cssText=`position:absolute;inset:0;width:100%;height:100%;overflow:hidden;${me}`,et(r),o.appendChild(r);const s=pe(r);X(r);const l=O();l&&await Y(l.rootPath);const m=[];for(const c of e.domStubs??[]){if(document.getElementById(c))continue;const p=document.createElement("div");p.id=c,p.style.display="none",p.dataset[at]="",r.appendChild(p),m.push(p)}const i=await Ne(),a=i.three,d=Xe(a,i.EffectComposer,{isHostRenderer:Qe,additionalRendererCtors:[i.CSS3DRenderer],declaredScene:()=>{const c=be(v());return c.malformed!==null&&h.error(`Ingest game "${e.id}" ${c.malformed} — falling back to the MEASURED first-render adoption.`,"ingest"),c.world},onWorldAdoption:ee(e.id)});if(e.assets){const c=e.assets;a.DefaultLoadingManager.setURLModifier(p=>{for(const y of Object.keys(c))if(p.includes(y))return c[y];return p})}window.__volterMountCold=!0;const f=Date.now();await e.load();const w=n.captureTimeoutMs??1e4,g=fe(v());g.malformed!==null&&h.error(`Ingest game "${e.id}" ${g.malformed} — the host is measuring readiness instead.`,"ingest");const b=g.ready===null?"measured":"declared";E({rootId:e.id,mechanism:g.ready===null?"measured-wait":"contract-ready",source:b,state:"waiting"});let u;try{u=await d.waitForCapture({timeoutMs:w,onWait:c=>Ye(e.id,c)})}catch(c){d.uninstall(),a.DefaultLoadingManager.setURLModifier(y=>y);for(const y of m)y.remove();W(),r.remove(),D(e.id);const p=qe({gameId:e.id,timeoutMs:w,readinessSource:b,pageErrors:yt(f),cause:String(c)});throw E({rootId:e.id,mechanism:g.ready===null?"measured-wait":"contract-ready",source:b,state:"failed",failure:p.kind}),new Error(p.message)}const k=vt(r,u.renderer.domElement),S=he(v());S.malformed!==null&&h.error(`Ingest game "${e.id}" ${S.malformed} — the host is using the captured renderer’s canvas instead.`,"ingest"),te(e.id,S.canvas??u.renderer.domElement,S.canvas?"declared":"measured"),ct();const P=await wt(e.id,u.scene,g.ready);E({rootId:e.id,mechanism:P==="declared"?"contract-ready":"measured-wait",source:P,state:"ready"});const R={pause:()=>u.renderer.setAnimationLoop?.(null),resume:()=>{const c=d.getAnimationLoop(u.renderer);c&&u.renderer.setAnimationLoop?.(c)}};Ve(e.dataWriter??null);const q=pt(O()?.rootPath,e.sourceModules),L=ft(await gt(),q),J=L?0:await lt(u.scene),G=ht({servedStampedSource:L,graphStamps:J})==="oid-source"?Ke(t,u.scene,{worldId:e.id,loop:R,camera:u.camera,journal:j(e.id)}):Ze(t,u.scene,{loop:R,camera:u.camera,journal:j(e.id)}),A=dt(d,u.renderer,e.id,R,{realmGate:M(),onVerdict:()=>t.shell.notifyIngestEdit()}),{systems:T,renderDebug:K,debugCollisions:Z}=je({contractSystems:v()?.systems,surface:"three",runtime:u,setRenderPassHooks:c=>d.setRenderPassHooks(c)});for(const c of Z)h.error(`Ingest game "${e.id}" — ${c}; it will refuse`,"ingest");return{game:{kind:"three",scene:u.scene,camera:u.camera,drivesOwnLoop:!0,...Object.keys(T).length>0?{systems:T}:{},setPaused:c=>A.setPaused(c),resize:(c,p)=>{if(s.gameResizesItself){s.dispatchResize();return}const y=_e(c,p);u.renderer.setSize(y.width,y.height,!1),d.resizeComposers(y.width,y.height),F(k)},dispose:()=>{d.setRenderPassHooks(null),we(),K?.dispose();try{u.renderer.setAnimationLoop?.(null),u.renderer.dispose?.()}catch{}d.uninstall(),a.DefaultLoadingManager.setURLModifier(c=>c);for(const c of m)c.remove();V(),W(),ne(e.id),se(e.id),D(e.id),r.remove()},authoring:G},authoring:G,hostEl:r,capture:d,scene:u.scene,realmLoopVerdict:()=>A.lastVerdict()}}function It(t,e){const o={};for(const[n,r]of Object.entries(e)){const s=H(t,r),l=_[s];if(!l)throw new Error(`ingest discovery: "${t}"'s asset "${r}" did not match any served asset (looked for glob key "${s}" — available: ${Object.keys(_).join(", ")})`);o[n]=l}return o}function $(t,e){const o=H(t,e),n=ot[o];if(!n)throw new Error(`ingest discovery: "${t}"'s module "${e}" did not match any game module (looked for glob key "${o}").`);return n}function kt({folderId:t,manifest:e,root:o}){const{adapter:n}=o;if(!o.entry)throw new Error(`ingest discovery: "${t}" has no \`entry\` — an ingest root mounts the game's own entry module.`);return{...{id:o.id,name:e.name,description:o.description??"",gameVersion:e.version,sourceModules:xe(o.entry,o.world?.entry),...ze(n.dataWriter,s=>$(t,s)),...n.assets!==void 0?{assets:It(t,n.assets)}:{},...n.domStubs!==void 0?{domStubs:n.domStubs}:{},...n.captureTimeoutMs!==void 0?{captureTimeoutMs:n.captureTimeoutMs}:{}},load:Fe($(t,o.entry),n.contractShim===void 0?void 0:$(t,n.contractShim))}}let C=null;function Rt(){return C||(C=rt("three").map(kt).sort((t,e)=>t.id.localeCompare(e.id))),C}function Et(t){return Rt().find(e=>e.id===t)}function $t(t){return t==="devtools-observer"?"this game runs its OWN copy of three; the host reached its renderer through three's `__THREE_DEVTOOLS__` observation seam":"this game imports the host's three directly, in the editor's own realm"}function Ct(t){const{store:e,session:o,sessionId:n}=t,r=o.mount;if(!r)return;const s=r.authoring,l=Pe(),m=it(s,l?.systems?.hierarchy),i=Ue({primary:m,worldId:n,hostEl:r.hostEl,...l?.root?{declaredRoot:l.root}:{},store:e}),a=r.scene,d=new ResizeObserver(()=>{const u=t.gameContainer.getBoundingClientRect();u.width>0&&u.height>0&&r.game.resize?.(u.width,u.height)});d.observe(t.gameContainer),o.resizeObserver=d;const f=s.refresh(),w=s.measureWriteReach();h.log(`Captured live scene (${a.children.length} top-level children, ${r.capture.getDrawCount()} draws); ingested ${f.count} objects (${f.meshes} meshes, ${f.lights} lights`+(f.instancedMeshes>0?`, incl. ${f.instancedMeshes} InstancedMesh drawing ${f.instances} units`:"")+`); ${w.addressable} of ${w.total} have a source address — edits go to ${w.destination}`,"ingest"),Le(n,r.realmLoopVerdict?.()??void 0),ce(i),de(r.game.systems??{}),e.enterPlayScene(a,void 0,s.objectMapSnapshot()),e.focusOnScene(()=>We(r.capture.captured?.camera,a)),tt(),e.shell.notifyIngestEdit(),ue();const g=Q({authoring:i});Ge({reach:g,reachMechanism:$t(r.capture.capturedVia),loop:()=>Ae(r),writeReach:()=>s.measureWriteReach()});const b={gameId:n,...Oe(i),drawCount:()=>r.capture.getDrawCount(),get reflected(){return s.refresh()},get sceneChildren(){return a.children.length},reach:g,resize:(u,k)=>r.game.resize?.(u,k),...o.lifecycle.setPaused?{setPaused:o.lifecycle.setPaused}:{}};Te(b,r),De("__volterIngest",b)}async function Mt(t,e,o){Se(),Ie(o),await ie();const n=ae();if(!n){h.error("Game container not mounted — cannot ingest","ingest");return}t.shell.setPlayState("playing"),h.log(`Ingesting unmodified game: ${e.name}`,"ingest");const r=()=>t.shell.playState==="playing"&&t.shell.activeViewportTab==="play";try{const s={captureTimeoutMs:e.captureTimeoutMs},l=await St(t,e,n,s),m=l.game.setPaused,i={store:t,mount:l,lifecycle:ke(m?{setPaused:a=>m(a),step:()=>M()?.step(1),canStep:()=>l.realmLoopVerdict?.()?.loop==="gated"&&M()!==null}:{pauseGap:"the captured Three root exposes no mounted setPaused capability"})};Re({kind:"three",session:i,siblings:[],worldId:o}),Ee(r),i.inputGateUnsubscribe=t.shell.subscribe(()=>{r()||V()}),$e(Ce()),Ct({store:t,session:i,gameContainer:n,sessionId:o})}catch(s){throw h.error(`Ingest failed: ${s}`,"ingest"),Me(),s}}function N(t,e,o){return ve(()=>Mt(t,e,o))}async function xr(t,e){const o=Et(e);if(!o){h.error(`Unknown ingest game: ${e}`,"ingest");return}return N(t,o,e)}async function Fr(t,e,o){const n=He(e,o);return N(t,n,e.id)}export{N as mountThreeIngestRoot,xr as mountThreeIngestRootById,Fr as mountThreeIngestRootFromManifest};
@@ -1 +1 @@
1
- import{s as o}from"./entity-object-C6hm5vYx.js";function l(t,s){if(t.selection)return t;const i={get:()=>[...s.shell.selectedEntityIds],set:e=>s.shell.selectMultiple(e)};return new Proxy(t,{get(e,n){if(n==="selection")return i;const c=Reflect.get(e,n,e);return typeof c=="function"?c.bind(e):c}})}function f(t,s){const i=s.hierarchy.idForObject3D;i&&t.traverse(e=>{const n=i(e);n&&o(e,n)})}export{f as s,l as w};
1
+ import{s as o}from"./entity-object-BLJ-I8XT.js";function l(t,s){if(t.selection)return t;const i={get:()=>[...s.shell.selectedEntityIds],set:e=>s.shell.selectMultiple(e)};return new Proxy(t,{get(e,n){if(n==="selection")return i;const c=Reflect.get(e,n,e);return typeof c=="function"?c.bind(e):c}})}function f(t,s){const i=s.hierarchy.idForObject3D;i&&t.traverse(e=>{const n=i(e);n&&o(e,n)})}export{f as s,l as w};
@@ -1 +1 @@
1
- import{disposeStoryObject3D as l}from"./story-three-preview-DdduzS7D.js";function u(e){let o=!1,r=!1,t=0;const s=()=>{!o||t!==0||r||(r=!0,l(e))};return{build:()=>{if(r)throw new Error("This story source has already been released.");t++;let i=!1;return{root:e.root,hierarchyRoots:[...e.root.children],update:a=>e.advance(a),dispose:()=>{i||(i=!0,t--,s())}}},dispose:()=>{o=!0,s()}}}export{u as m};
1
+ import{disposeStoryObject3D as l}from"./story-three-preview-CWM0Rj7x.js";function u(e){let o=!1,r=!1,t=0;const s=()=>{!o||t!==0||r||(r=!0,l(e))};return{build:()=>{if(r)throw new Error("This story source has already been released.");t++;let i=!1;return{root:e.root,hierarchyRoots:[...e.root.children],update:a=>e.advance(a),dispose:()=>{i||(i=!0,t--,s())}}},dispose:()=>{o=!0,s()}}}export{u as m};
@@ -1 +1 @@
1
- import{NATIVE_INPUT_VALUE_TYPES as l}from"./native-entry-surface-BE8LJNdu.js";import{g as E,D as h}from"./debug-registry-CcTdmLf3.js";import{p as T,C as A}from"./contract-system-adapters-D8SzcuZo.js";function p(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function g(t,n,o){const e=Object.keys(t).filter(r=>!n.includes(r));if(e.length>0)throw new Error(`${o} has unknown ${e.length===1?"key":"keys"}: ${e.join(", ")}`)}function y(t,n){if(!p(t))throw new Error(`${n} must be an object of named functions.`);const o={};for(const[e,r]of Object.entries(t)){if(!e)throw new Error(`${n} contains an empty name.`);if(typeof r!="function")throw new Error(`${n}.${e} must be a function.`);o[e]=r}return o}function j(t){if(!p(t))throw new Error("debug.input.actions must be an object mapping action names to value types.");const n={};for(const[o,e]of Object.entries(t)){if(!o)throw new Error("debug.input.actions contains an empty action name.");if(!l.includes(e))throw new Error(`debug.input.actions.${o} must be one of ${l.join(", ")}.`);n[o]=e}return n}function $(t){if(!p(t))throw new Error("debug.input must be an object.");if(g(t,["actions","set","clear","tap","scheduleAtTick"],"debug.input"),typeof t.actions=="function"){const s=t.set,m=t.clear;if(typeof s!="function")throw new Error("debug.input.set must be a function.");if(typeof m!="function")throw new Error("debug.input.clear must be a function.");return t}const n=t.set,o=t.clear,e=t.tap,r=t.scheduleAtTick;if(typeof n!="function")throw new Error("debug.input.set must be a function.");if(typeof o!="function")throw new Error("debug.input.clear must be a function.");if(e!==void 0&&typeof e!="function")throw new Error("debug.input.tap must be a function when provided.");if(r!==void 0&&typeof r!="function")throw new Error("debug.input.scheduleAtTick must be a function when provided.");return{actions:j(t.actions),set:n,clear:o,...typeof e=="function"?{tap:e}:{},...typeof r=="function"?{scheduleAtTick:r}:{}}}function x(t,n){if(!p(n)||n.debug===void 0)return null;if(!p(n.debug))throw new Error(`Root "${t}" exports \`debug\`, but it is not an object.`);const o=n.debug;g(o,["commands","state","input","events","settled"],`Root "${t}" debug export`);const e=(u,i)=>{if(u!==void 0)return typeof u=="function"?u:y(u,i)},s=((u,i)=>{if(u!==void 0){if(typeof u=="function")return u;if(!p(u))throw new Error(`${i} must be an object of named commands.`);return u}})(o.commands,"debug.commands"),m=e(o.state,"debug.state"),f=o.input===void 0?void 0:$(o.input),c=o.events===void 0?void 0:N(o.events),d=o.settled;if(d!==void 0&&typeof d!="function")throw new Error("debug.settled must be a function returning a boolean.");if(!s&&!m&&!f&&!c&&!d)throw new Error(`Root "${t}" exports an empty \`debug\` object.`);return{rootId:t,debug:{...s?{commands:s}:{},...m?{state:m}:{},...f?{input:f}:{},...c?{events:c}:{},...d?{settled:d}:{}}}}function N(t){if(!p(t)||typeof t.subscribe!="function")throw new Error("debug.events must be an object with a subscribe(listener) function.");return t}function I(t,n){if(t===void 0)return{};const o=typeof t=="function"?t():t;if(!p(o))throw new Error(`${n} must be an object of named commands.`);for(const[e,r]of Object.entries(o)){if(!e)throw new Error(`${n} contains an empty name.`);if(!(typeof r=="function"||p(r)&&typeof r.run=="function"))throw new Error(`${n}.${e} must be a function or { description?, run }.`)}return o}function P(t,n){return t===void 0?{}:typeof t=="function"?y(t(),n):t}function R(t,n){return t==="digital"?typeof n=="boolean":t==="scalar"?typeof n=="number"&&Number.isFinite(n):typeof n=="object"&&n!==null&&typeof n.x=="number"&&Number.isFinite(n.x)&&typeof n.y=="number"&&Number.isFinite(n.y)}function S(t,n,o,e){const r=[];let s=!1;const m=()=>typeof e.actions=="function"?e.actions():e.actions,f=(i,a)=>{const w=m(),b=w[i];if(!b)throw new h("INPUT_ACTION_NOT_FOUND",`Native input has no action named "${i}".`,{registered:Object.keys(w)});if(!R(b,a))throw new h("INPUT_ACTION_VALUE_TYPE",`Native input action "${i}" expects ${b}, not ${typeof a}.`,{action:i,expected:b});return b},c=(i,a,w)=>{f(i,a),e.set(i,a),s&&r.push({tick:w,action:i,value:a})},d=i=>{throw new h("NATIVE_INPUT_SOURCE_UNSUPPORTED",`${i} addresses an engine test source, but this game exposes an app-owned action store. Drive it by action name instead.`)},u={setVirtualAction(i,a){return c(i,a,n.getGameTick()),{delivered:!0}},tapVirtualAction(i){if(!e.tap)throw new h("NATIVE_INPUT_TAP_UNSUPPORTED",`Native input for root "${o.rootId}" does not export tap(); use setVirtualAction through the app-owned store.`);return f(i,!0),e.tap(i),{delivered:!0}},clearVirtualActions(){e.clear()},scheduleActionAtTick(i,a,w){const b=n.getGameTick();if(!Number.isInteger(i)||i<b)throw new h("TICK_ALREADY_PASSED",`Cannot schedule native input for tick ${i}; current tick is ${b}.`,{tick:i,currentTick:b});if(f(a,w),!e.scheduleAtTick)throw new h("NATIVE_INPUT_SCHEDULE_UNSUPPORTED",`Native input for root "${o.rootId}" does not export scheduleAtTick(); the adapter will not create a host scheduler for it.`);e.scheduleAtTick(i,a,w)},startInputRecording(){r.length=0,s=!0},stopInputRecording(){s=!1},isInputRecording(){return s},injectAxis(){d("injectAxis")},injectVector2(){d("injectVector2")},injectPointerDelta(){d("injectPointerDelta")},injectPointerPosition(){d("injectPointerPosition")}};n.setInputActionsSource(o.rootId,()=>Object.entries(m()).map(([i,a])=>({name:i,valueType:a}))),n.setInputTraceSource(o.rootId,()=>({version:1,seed:null,fixedDt:t.loop.fixedDt,ticks:[...r]})),n.setVirtualInputTarget(o.rootId,u)}function D(t,n){if(n.length===0)return;const o=E(t);if(!o)throw new Error("Cannot install native debug bindings: mounted Game has no debug registry.");for(const e of n){if(!t.world(e.rootId))throw new Error(`Native debug binding names unmounted root "${e.rootId}".`);const r=o.forRoot(e.rootId),s=P(e.debug.state,`Root "${e.rootId}" debug.state`);for(const[f,c]of Object.entries(s))r.registerStateProvider(f,c,{tier:"assisted"});const m=I(e.debug.commands,`Root "${e.rootId}" debug.commands`);for(const[f,c]of Object.entries(m)){const d=typeof c=="function"?c:c.run,u=typeof c=="function"?void 0:c.description;r.registerCommand(f,{locus:"client",...u===void 0?{}:{description:u}},d)}e.debug.input&&S(t,o,e,e.debug.input),e.debug.events?.subscribe((f,c)=>r.emit(f,c)),e.debug.settled&&o.registerWorldSettledProbe(e.debug.settled)}}function U(t,n,o){if(!p(n)||n.systems===void 0)return null;const e=n.systems;if(!p(e))throw new Error(`Root "${t}" exports \`systems\`, but it is not an object.`);g(e,A,`Root "${t}" systems export`);const r=T({systemAdapters:e},o);if(r.malformed.length>0)throw new Error(`Root "${t}" systems export is malformed: `+r.malformed.map(s=>`${s.slot} — ${s.reason}`).join("; "));if(Object.keys(r.bound).length===0&&r.empty.length===0)throw new Error(`Root "${t}" exports an empty \`systems\` object.`);return{rootId:t,slots:r.bound,absent:r.empty}}function C(t,n){if(n.length===0)return;const o=t.installDeclaredSystemAdapters;if(!o)throw new Error("Cannot install native systems bindings: this Game does not implement installDeclaredSystemAdapters.");for(const e of n)Object.keys(e.slots).length===0&&e.absent.length===0||o.call(t,e.rootId,e.slots,e.absent.map(r=>({rootId:e.rootId,slot:r.slot,reason:r.evidence})))}export{U as a,C as b,D as i,x as n};
1
+ import{NATIVE_INPUT_VALUE_TYPES as l}from"./native-entry-surface-BE8LJNdu.js";import{g as E,D as h}from"./debug-registry-B2THKz1v.js";import{p as T,C as A}from"./contract-system-adapters-BDUpDoKd.js";function p(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function g(t,n,o){const e=Object.keys(t).filter(r=>!n.includes(r));if(e.length>0)throw new Error(`${o} has unknown ${e.length===1?"key":"keys"}: ${e.join(", ")}`)}function y(t,n){if(!p(t))throw new Error(`${n} must be an object of named functions.`);const o={};for(const[e,r]of Object.entries(t)){if(!e)throw new Error(`${n} contains an empty name.`);if(typeof r!="function")throw new Error(`${n}.${e} must be a function.`);o[e]=r}return o}function j(t){if(!p(t))throw new Error("debug.input.actions must be an object mapping action names to value types.");const n={};for(const[o,e]of Object.entries(t)){if(!o)throw new Error("debug.input.actions contains an empty action name.");if(!l.includes(e))throw new Error(`debug.input.actions.${o} must be one of ${l.join(", ")}.`);n[o]=e}return n}function $(t){if(!p(t))throw new Error("debug.input must be an object.");if(g(t,["actions","set","clear","tap","scheduleAtTick"],"debug.input"),typeof t.actions=="function"){const s=t.set,m=t.clear;if(typeof s!="function")throw new Error("debug.input.set must be a function.");if(typeof m!="function")throw new Error("debug.input.clear must be a function.");return t}const n=t.set,o=t.clear,e=t.tap,r=t.scheduleAtTick;if(typeof n!="function")throw new Error("debug.input.set must be a function.");if(typeof o!="function")throw new Error("debug.input.clear must be a function.");if(e!==void 0&&typeof e!="function")throw new Error("debug.input.tap must be a function when provided.");if(r!==void 0&&typeof r!="function")throw new Error("debug.input.scheduleAtTick must be a function when provided.");return{actions:j(t.actions),set:n,clear:o,...typeof e=="function"?{tap:e}:{},...typeof r=="function"?{scheduleAtTick:r}:{}}}function x(t,n){if(!p(n)||n.debug===void 0)return null;if(!p(n.debug))throw new Error(`Root "${t}" exports \`debug\`, but it is not an object.`);const o=n.debug;g(o,["commands","state","input","events","settled"],`Root "${t}" debug export`);const e=(u,i)=>{if(u!==void 0)return typeof u=="function"?u:y(u,i)},s=((u,i)=>{if(u!==void 0){if(typeof u=="function")return u;if(!p(u))throw new Error(`${i} must be an object of named commands.`);return u}})(o.commands,"debug.commands"),m=e(o.state,"debug.state"),f=o.input===void 0?void 0:$(o.input),c=o.events===void 0?void 0:N(o.events),d=o.settled;if(d!==void 0&&typeof d!="function")throw new Error("debug.settled must be a function returning a boolean.");if(!s&&!m&&!f&&!c&&!d)throw new Error(`Root "${t}" exports an empty \`debug\` object.`);return{rootId:t,debug:{...s?{commands:s}:{},...m?{state:m}:{},...f?{input:f}:{},...c?{events:c}:{},...d?{settled:d}:{}}}}function N(t){if(!p(t)||typeof t.subscribe!="function")throw new Error("debug.events must be an object with a subscribe(listener) function.");return t}function I(t,n){if(t===void 0)return{};const o=typeof t=="function"?t():t;if(!p(o))throw new Error(`${n} must be an object of named commands.`);for(const[e,r]of Object.entries(o)){if(!e)throw new Error(`${n} contains an empty name.`);if(!(typeof r=="function"||p(r)&&typeof r.run=="function"))throw new Error(`${n}.${e} must be a function or { description?, run }.`)}return o}function P(t,n){return t===void 0?{}:typeof t=="function"?y(t(),n):t}function R(t,n){return t==="digital"?typeof n=="boolean":t==="scalar"?typeof n=="number"&&Number.isFinite(n):typeof n=="object"&&n!==null&&typeof n.x=="number"&&Number.isFinite(n.x)&&typeof n.y=="number"&&Number.isFinite(n.y)}function S(t,n,o,e){const r=[];let s=!1;const m=()=>typeof e.actions=="function"?e.actions():e.actions,f=(i,a)=>{const w=m(),b=w[i];if(!b)throw new h("INPUT_ACTION_NOT_FOUND",`Native input has no action named "${i}".`,{registered:Object.keys(w)});if(!R(b,a))throw new h("INPUT_ACTION_VALUE_TYPE",`Native input action "${i}" expects ${b}, not ${typeof a}.`,{action:i,expected:b});return b},c=(i,a,w)=>{f(i,a),e.set(i,a),s&&r.push({tick:w,action:i,value:a})},d=i=>{throw new h("NATIVE_INPUT_SOURCE_UNSUPPORTED",`${i} addresses an engine test source, but this game exposes an app-owned action store. Drive it by action name instead.`)},u={setVirtualAction(i,a){return c(i,a,n.getGameTick()),{delivered:!0}},tapVirtualAction(i){if(!e.tap)throw new h("NATIVE_INPUT_TAP_UNSUPPORTED",`Native input for root "${o.rootId}" does not export tap(); use setVirtualAction through the app-owned store.`);return f(i,!0),e.tap(i),{delivered:!0}},clearVirtualActions(){e.clear()},scheduleActionAtTick(i,a,w){const b=n.getGameTick();if(!Number.isInteger(i)||i<b)throw new h("TICK_ALREADY_PASSED",`Cannot schedule native input for tick ${i}; current tick is ${b}.`,{tick:i,currentTick:b});if(f(a,w),!e.scheduleAtTick)throw new h("NATIVE_INPUT_SCHEDULE_UNSUPPORTED",`Native input for root "${o.rootId}" does not export scheduleAtTick(); the adapter will not create a host scheduler for it.`);e.scheduleAtTick(i,a,w)},startInputRecording(){r.length=0,s=!0},stopInputRecording(){s=!1},isInputRecording(){return s},injectAxis(){d("injectAxis")},injectVector2(){d("injectVector2")},injectPointerDelta(){d("injectPointerDelta")},injectPointerPosition(){d("injectPointerPosition")}};n.setInputActionsSource(o.rootId,()=>Object.entries(m()).map(([i,a])=>({name:i,valueType:a}))),n.setInputTraceSource(o.rootId,()=>({version:1,seed:null,fixedDt:t.loop.fixedDt,ticks:[...r]})),n.setVirtualInputTarget(o.rootId,u)}function D(t,n){if(n.length===0)return;const o=E(t);if(!o)throw new Error("Cannot install native debug bindings: mounted Game has no debug registry.");for(const e of n){if(!t.world(e.rootId))throw new Error(`Native debug binding names unmounted root "${e.rootId}".`);const r=o.forRoot(e.rootId),s=P(e.debug.state,`Root "${e.rootId}" debug.state`);for(const[f,c]of Object.entries(s))r.registerStateProvider(f,c,{tier:"assisted"});const m=I(e.debug.commands,`Root "${e.rootId}" debug.commands`);for(const[f,c]of Object.entries(m)){const d=typeof c=="function"?c:c.run,u=typeof c=="function"?void 0:c.description;r.registerCommand(f,{locus:"client",...u===void 0?{}:{description:u}},d)}e.debug.input&&S(t,o,e,e.debug.input),e.debug.events?.subscribe((f,c)=>r.emit(f,c)),e.debug.settled&&o.registerWorldSettledProbe(e.debug.settled)}}function U(t,n,o){if(!p(n)||n.systems===void 0)return null;const e=n.systems;if(!p(e))throw new Error(`Root "${t}" exports \`systems\`, but it is not an object.`);g(e,A,`Root "${t}" systems export`);const r=T({systemAdapters:e},o);if(r.malformed.length>0)throw new Error(`Root "${t}" systems export is malformed: `+r.malformed.map(s=>`${s.slot} — ${s.reason}`).join("; "));if(Object.keys(r.bound).length===0&&r.empty.length===0)throw new Error(`Root "${t}" exports an empty \`systems\` object.`);return{rootId:t,slots:r.bound,absent:r.empty}}function C(t,n){if(n.length===0)return;const o=t.installDeclaredSystemAdapters;if(!o)throw new Error("Cannot install native systems bindings: this Game does not implement installDeclaredSystemAdapters.");for(const e of n)Object.keys(e.slots).length===0&&e.absent.length===0||o.call(t,e.rootId,e.slots,e.absent.map(r=>({rootId:e.rootId,slot:r.slot,reason:r.evidence})))}export{U as a,C as b,D as i,x as n};
@@ -1 +1 @@
1
- import{_ as Ge}from"./index-Cjv2Ynte.js";import"./three.module-BLhyNg0e.js";import{cW as ke,N as Ve,cp as We,co as j,M as ie,fo as Ye,_ as Qe,cm as ne,bu as Xe}from"./three.core-3arARmh6.js";import{DEFAULTS as le}from"./defaults-DKiBJCPN.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";const $e=["Recast","Detour","DetourNavMeshBuilder","DetourTileCacheBuilder","NavMeshImporter","NavMeshExporter","CrowdUtils","ChunkyTriMeshUtils","RecastDebugDraw","DetourDebugDraw"],qe=["rcConfig","rcContext","dtNavMeshParams","dtNavMeshCreateParams","RecastLinearAllocator","RecastFastLZCompressor","rcChunkyTriMesh","dtTileCacheParams","dtTileCacheLayerHeader","Vec3","BoolRef","IntRef","UnsignedIntRef","UnsignedCharRef","UnsignedShortRef","FloatRef","IntArray","UnsignedIntArray","UnsignedCharArray","UnsignedShortArray","FloatArray"],s={isNull:a=>s.Module.getPointer(a)===0,destroy:a=>{s.Module.destroy(a)}},g={},f={},Ke=async a=>{if(s.Module===void 0){{const e=(await Ge(async()=>{const{default:t}=await import("./recast-navigation.wasm-compat-Dsoa_MD-.js");return{default:t}},[])).default;s.Module=await e()}for(const e of $e)s[e]=new s.Module[e];for(const e of qe)s[e]=s.Module[e];g.RC_BORDER_REG=s.Recast.BORDER_REG,g.RC_MULTIPLE_REGS=s.Recast.MULTIPLE_REGS,g.RC_BORDER_VERTEX=s.Recast.BORDER_VERTEX,g.RC_AREA_BORDER=s.Recast.AREA_BORDER,g.RC_CONTOUR_REG_MASK=s.Recast.CONTOUR_REG_MASK,g.RC_MESH_NULL_IDX=s.Recast.MESH_NULL_IDX,g.RC_NULL_AREA=s.Recast.NULL_AREA,g.RC_WALKABLE_AREA=s.Recast.WALKABLE_AREA,g.RC_NOT_CONNECTED=s.Recast.NOT_CONNECTED,g.RC_CONTOUR_TESS_WALL_EDGES=s.Module.RC_CONTOUR_TESS_WALL_EDGES,g.RC_CONTOUR_TESS_AREA_EDGES=s.Module.RC_CONTOUR_TESS_AREA_EDGES,g.RC_LOG_PROGRESS=s.Module.RC_LOG_PROGRESS,g.RC_LOG_WARNING=s.Module.RC_LOG_WARNING,g.RC_LOG_ERROR=s.Module.RC_LOG_ERROR,g.RC_TIMER_TOTAL=s.Module.RC_TIMER_TOTAL,g.RC_TIMER_TEMP=s.Module.RC_TIMER_TEMP,g.RC_TIMER_RASTERIZE_TRIANGLES=s.Module.RC_TIMER_RASTERIZE_TRIANGLES,g.RC_TIMER_BUILD_COMPACTHEIGHTFIELD=s.Module.RC_TIMER_BUILD_COMPACTHEIGHTFIELD,g.RC_TIMER_BUILD_CONTOURS=s.Module.RC_TIMER_BUILD_CONTOURS,g.RC_TIMER_BUILD_CONTOURS_TRACE=s.Module.RC_TIMER_BUILD_CONTOURS_TRACE,g.RC_TIMER_BUILD_CONTOURS_SIMPLIFY=s.Module.RC_TIMER_BUILD_CONTOURS_SIMPLIFY,g.RC_TIMER_FILTER_BORDER=s.Module.RC_TIMER_FILTER_BORDER,g.RC_TIMER_FILTER_WALKABLE=s.Module.RC_TIMER_FILTER_WALKABLE,g.RC_TIMER_MEDIAN_AREA=s.Module.RC_TIMER_MEDIAN_AREA,g.RC_TIMER_FILTER_LOW_OBSTACLES=s.Module.RC_TIMER_FILTER_LOW_OBSTACLES,g.RC_TIMER_BUILD_POLYMESH=s.Module.RC_TIMER_BUILD_POLYMESH,g.RC_TIMER_MERGE_POLYMESH=s.Module.RC_TIMER_MERGE_POLYMESH,g.RC_TIMER_ERODE_AREA=s.Module.RC_TIMER_ERODE_AREA,g.RC_TIMER_MARK_BOX_AREA=s.Module.RC_TIMER_MARK_BOX_AREA,g.RC_TIMER_MARK_CYLINDER_AREA=s.Module.RC_TIMER_MARK_CYLINDER_AREA,g.RC_TIMER_MARK_CONVEXPOLY_AREA=s.Module.RC_TIMER_MARK_CONVEXPOLY_AREA,g.RC_TIMER_BUILD_DISTANCEFIELD=s.Module.RC_TIMER_BUILD_DISTANCEFIELD,g.RC_TIMER_BUILD_DISTANCEFIELD_DIST=s.Module.RC_TIMER_BUILD_DISTANCEFIELD_DIST,g.RC_TIMER_BUILD_DISTANCEFIELD_BLUR=s.Module.RC_TIMER_BUILD_DISTANCEFIELD_BLUR,g.RC_TIMER_BUILD_REGIONS=s.Module.RC_TIMER_BUILD_REGIONS,g.RC_TIMER_BUILD_REGIONS_WATERSHED=s.Module.RC_TIMER_BUILD_REGIONS_WATERSHED,g.RC_TIMER_BUILD_REGIONS_EXPAND=s.Module.RC_TIMER_BUILD_REGIONS_EXPAND,g.RC_TIMER_BUILD_REGIONS_FLOOD=s.Module.RC_TIMER_BUILD_REGIONS_FLOOD,g.RC_TIMER_BUILD_REGIONS_FILTER=s.Module.RC_TIMER_BUILD_REGIONS_FILTER,g.RC_TIMER_BUILD_LAYERS=s.Module.RC_TIMER_BUILD_LAYERS,g.RC_TIMER_BUILD_POLYMESHDETAIL=s.Module.RC_TIMER_BUILD_POLYMESHDETAIL,g.RC_TIMER_MERGE_POLYMESHDETAIL=s.Module.RC_TIMER_MERGE_POLYMESHDETAIL,g.RC_MAX_TIMERS=s.Module.RC_MAX_TIMERS,f.DT_FAILURE=s.Detour.FAILURE,f.DT_SUCCESS=s.Detour.SUCCESS,f.DT_IN_PROGRESS=s.Detour.IN_PROGRESS,f.DT_STATUS_DETAIL_MASK=s.Detour.STATUS_DETAIL_MASK,f.DT_WRONG_MAGIC=s.Detour.WRONG_MAGIC,f.DT_WRONG_VERSION=s.Detour.WRONG_VERSION,f.DT_OUT_OF_MEMORY=s.Detour.OUT_OF_MEMORY,f.DT_INVALID_PARAM=s.Detour.INVALID_PARAM,f.DT_BUFFER_TOO_SMALL=s.Detour.BUFFER_TOO_SMALL,f.DT_OUT_OF_NODES=s.Detour.OUT_OF_NODES,f.DT_PARTIAL_RESULT=s.Detour.PARTIAL_RESULT,f.DT_ALREADY_OCCUPIED=s.Detour.ALREADY_OCCUPIED,f.DT_VERTS_PER_POLYGON=s.Detour.VERTS_PER_POLYGON,f.DT_NAVMESH_MAGIC=s.Detour.NAVMESH_MAGIC,f.DT_NAVMESH_VERSION=s.Detour.NAVMESH_VERSION,f.DT_NAVMESH_STATE_MAGIC=s.Detour.NAVMESH_STATE_MAGIC,f.DT_NAVMESH_STATE_VERSION=s.Detour.NAVMESH_STATE_VERSION,f.DT_TILECACHE_MAGIC=s.Detour.TILECACHE_MAGIC,f.DT_TILECACHE_VERSION=s.Detour.TILECACHE_VERSION,f.DT_TILECACHE_NULL_AREA=s.Detour.TILECACHE_NULL_AREA,f.DT_TILECACHE_WALKABLE_AREA=s.Detour.TILECACHE_WALKABLE_AREA,f.DT_TILECACHE_NULL_IDX=s.Detour.TILECACHE_NULL_IDX,f.DT_NULL_LINK=s.Detour.NULL_LINK,f.DT_NULL_LINK=s.Detour.NULL_LINK,f.DT_EXT_LINK=s.Detour.EXT_LINK,f.DT_OFFMESH_CON_BIDIR=s.Detour.OFFMESH_CON_BIDIR,f.DT_STRAIGHTPATH_START=s.Module.DT_STRAIGHTPATH_START,f.DT_STRAIGHTPATH_END=s.Module.DT_STRAIGHTPATH_END,f.DT_STRAIGHTPATH_OFFMESH_CONNECTION=s.Module.DT_STRAIGHTPATH_OFFMESH_CONNECTION,f.DT_STRAIGHTPATH_AREA_CROSSINGS=s.Module.DT_STRAIGHTPATH_AREA_CROSSINGS,f.DT_STRAIGHTPATH_ALL_CROSSINGS=s.Module.DT_STRAIGHTPATH_ALL_CROSSINGS,f.DT_FINDPATH_ANY_ANGLE=s.Module.DT_FINDPATH_ANY_ANGLE,f.DT_RAYCAST_USE_COSTS=s.Module.DT_RAYCAST_USE_COSTS,f.DT_CROWDAGENT_STATE_INVALID=s.Module.DT_CROWDAGENT_STATE_INVALID,f.DT_CROWDAGENT_STATE_WALKING=s.Module.DT_CROWDAGENT_STATE_WALKING,f.DT_CROWDAGENT_STATE_OFFMESH=s.Module.DT_CROWDAGENT_STATE_OFFMESH,f.DT_CROWDAGENT_TARGET_NONE=s.Module.DT_CROWDAGENT_TARGET_NONE,f.DT_CROWDAGENT_TARGET_FAILED=s.Module.DT_CROWDAGENT_TARGET_FAILED,f.DT_CROWDAGENT_TARGET_VALID=s.Module.DT_CROWDAGENT_TARGET_VALID,f.DT_CROWDAGENT_TARGET_REQUESTING=s.Module.DT_CROWDAGENT_TARGET_REQUESTING,f.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE=s.Module.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE,f.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH=s.Module.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH,f.DT_CROWDAGENT_TARGET_VELOCITY=s.Module.DT_CROWDAGENT_TARGET_VELOCITY,f.DT_COMPRESSEDTILE_FREE_DATA=s.Module.DT_COMPRESSEDTILE_FREE_DATA,f.DT_TILE_FREE_DATA=s.Module.DT_TILE_FREE_DATA}};class K{get size(){return this.raw.size}constructor(e){this.raw=e}get(e){return this.raw.get(e)}set(e,t){this.raw.set(e,t)}resize(e){this.raw.resize(e)}copy(e){this.raw.resize(e.length),this.getHeapView().set(e)}destroy(){s.destroy(this.raw)}getHeapView(){const e=this.getHeap();return new this.ArrayConstructor(e.buffer,this.raw.getDataPointer(),this.size)}toTypedArray(){const e=this.getHeapView(),t=new this.ArrayConstructor(new ArrayBuffer(this.size*e.BYTES_PER_ELEMENT),0,this.size);return t.set(e),t}}class W extends K{ArrayConstructor=Int32Array;constructor(e){super(e??new s.Module.IntArray)}getHeap(){return s.Module.HEAP32}static fromRaw(e){return new W(e)}}class z extends K{ArrayConstructor=Uint32Array;constructor(e){super(e??new s.Module.UnsignedIntArray)}getHeap(){return s.Module.HEAPU32}static fromRaw(e){return new z(e)}}class Y extends K{ArrayConstructor=Uint8Array;constructor(e){super(e??new s.Module.UnsignedCharArray)}getHeap(){return s.Module.HEAPU8}static fromRaw(e){return new Y(e)}}class k extends K{ArrayConstructor=Float32Array;constructor(e){super(e??new s.Module.FloatArray)}getHeap(){return s.Module.HEAPF32}static fromRaw(e){return new k(e)}}const ue=k,ce=W,Z=Y,je=W,m={toRaw:({x:a,y:e,z:t},r)=>r?(r.x=a,r.y=e,r.z=t,r):new s.Module.Vec3(a,e,t),fromRaw:a=>{const{x:e,y:t,z:r}=a;return{x:e,y:t,z:r}},fromArray:([a,e,t])=>({x:a,y:e,z:t}),toArray:({x:a,y:e,z:t})=>[a,e,t],lerp:(a,e,t,r={x:0,y:0,z:0})=>{r.x=a.x+(e.x-a.x)*t,r.y=a.y+(e.y-a.y)*t,r.z=a.z+(e.z-a.z)*t},copy:(a,e={x:0,y:0,z:0})=>{e.x=a.x,e.y=a.y,e.z=a.z}},v=(a,e)=>{const t=[];for(let r=0;r<e;r++)t.push(a(r));return t},L=a=>s.Detour.statusSucceed(a),Ze=a=>s.Detour.statusFailed(a),Je=a=>{if(s.Detour.statusSucceed(a))return"success";if(s.Detour.statusInProgress(a))return"in progress";if(s.Detour.statusFailed(a)){let e;const t={DT_WRONG_MAGIC:f.DT_WRONG_MAGIC,DT_WRONG_VERSION:f.DT_WRONG_VERSION,DT_OUT_OF_MEMORY:f.DT_OUT_OF_MEMORY,DT_INVALID_PARAM:f.DT_INVALID_PARAM,DT_BUFFER_TOO_SMALL:f.DT_BUFFER_TOO_SMALL,DT_OUT_OF_NODES:f.DT_OUT_OF_NODES,DT_PARTIAL_RESULT:f.DT_PARTIAL_RESULT,DT_ALREADY_OCCUPIED:f.DT_ALREADY_OCCUPIED};for(const[r,i]of Object.entries(t))if(s.Detour.statusDetail(a,i)){e=r;break}return e?`failed - ${e}`:"failed - unknown"}return"unknown"};class et{constructor(e){this.raw=e}vertBase(){return this.raw.vertBase}triBase(){return this.raw.triBase}vertCount(){return this.raw.vertCount}triCount(){return this.raw.triCount}}class tt{constructor(e){this.raw=e}ref(){return this.raw.ref}next(){return this.raw.next}edge(){return this.raw.edge}side(){return this.raw.side}bmin(){return this.raw.bmin}bmax(){return this.raw.bmax}}class rt{constructor(e){this.raw=e}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}i(){return this.raw.i}}class he{constructor(e){this.raw=e}pos(e){return this.raw.get_pos(e)}rad(){return this.raw.rad}poly(){return this.raw.poly}flags(){return this.raw.flags}side(){return this.raw.side}userId(){return this.raw.userId}}class st{constructor(e){this.raw=e}magic(){return this.raw.magic}version(){return this.raw.version}x(){return this.raw.x}y(){return this.raw.y}layer(){return this.raw.layer}userId(){return this.raw.userId}polyCount(){return this.raw.polyCount}vertCount(){return this.raw.vertCount}maxLinkCount(){return this.raw.maxLinkCount}detailMeshCount(){return this.raw.detailMeshCount}detailVertCount(){return this.raw.detailVertCount}detailTriCount(){return this.raw.detailTriCount}bvNodeCount(){return this.raw.bvNodeCount}offMeshConCount(){return this.raw.offMeshConCount}offMeshBase(){return this.raw.offMeshBase}walkableHeight(){return this.raw.walkableHeight}walkableRadius(){return this.raw.walkableRadius}walkableClimb(){return this.raw.walkableClimb}bmin(e){return this.raw.get_bmin(e)}bmax(e){return this.raw.get_bmax(e)}bvQuantFactor(){return this.raw.bvQuantFactor}}class J{constructor(e){this.raw=e}firstLink(){return this.raw.firstLink}verts(e){return this.raw.get_verts(e)}neis(e){return this.raw.get_neis(e)}flags(){return this.raw.flags}vertCount(){return this.raw.vertCount}areaAndType(){return this.raw.get_areaAndtype()}getType(){return this.raw.getType()}}class B{constructor(e){this.raw=e}salt(){return this.raw.salt}linksFreeList(){return this.raw.linksFreeList}header(){return s.isNull(this.raw.header)?null:new st(this.raw.header)}polys(e){return new J(this.raw.get_polys(e))}verts(e){return this.raw.get_verts(e)}links(e){return new tt(this.raw.get_links(e))}detailMeshes(e){return new et(this.raw.get_detailMeshes(e))}detailVerts(e){return this.raw.get_detailVerts(e)}detailTris(e){return this.raw.get_detailTris(e)}bvTree(e){return new rt(this.raw.get_bvTree(e))}offMeshCons(e){return new he(this.raw.get_offMeshCons(e))}data(e){return this.raw.get_data(e)}dataSize(){return this.raw.dataSize}flags(){return this.raw.flags}next(){return new B(this.raw.next)}}const de=a=>{const e=s.DetourNavMeshBuilder.createNavMeshData(a.raw);return{success:e.success,navMeshData:Y.fromRaw(e.navMeshData)}};class we{constructor(e){this.raw=e??new s.Module.dtNavMeshCreateParams}setPolyMeshCreateParams(e){s.DetourNavMeshBuilder.setPolyMeshCreateParams(this.raw,e.raw)}setPolyMeshDetailCreateParams(e){s.DetourNavMeshBuilder.setPolyMeshDetailCreateParams(this.raw,e.raw)}setOffMeshConnections(e){if(e.length<=0)return;const t=[],r=[],i=[],o=[],l=[],n=[];for(let u=0;u<e.length;u++){const d=e[u];t.push(d.startPosition.x,d.startPosition.y,d.startPosition.z),t.push(d.endPosition.x,d.endPosition.y,d.endPosition.z),r.push(d.radius),i.push(d.bidirectional?1:0),o.push(d.area??0),l.push(d.flags??1),n.push(d.userId??1e3+u)}s.DetourNavMeshBuilder.setOffMeshConnections(this.raw,e.length,t,r,i,o,l,n)}verts(e){return this.raw.get_verts(e)}setVerts(e,t){this.raw.set_verts(e,t)}vertCount(){return this.raw.vertCount}polys(e){return this.raw.get_polys(e)}setPolys(e,t){this.raw.set_polys(e,t)}polyAreas(e){return this.raw.get_polyAreas(e)}setPolyAreas(e,t){this.raw.set_polyAreas(e,t)}polyFlags(e){return this.raw.get_polyFlags(e)}setPolyFlags(e,t){this.raw.set_polyFlags(e,t)}polyCount(){return this.raw.polyCount}nvp(){return this.raw.nvp}setNvp(e){this.raw.nvp=e}detailMeshes(e){return this.raw.get_detailMeshes(e)}setDetailMeshes(e,t){this.raw.set_detailMeshes(e,t)}detailVerts(e){return this.raw.get_detailVerts(e)}setDetailVerts(e,t){this.raw.set_detailVerts(e,t)}detailVertsCount(){return this.raw.detailVertsCount}detailTris(e){return this.raw.get_detailTris(e)}setDetailTris(e,t){this.raw.set_detailTris(e,t)}detailTriCount(){return this.raw.detailTriCount}offMeshConVerts(e){return this.raw.get_offMeshConVerts(e)}offMeshConRad(e){return this.raw.get_offMeshConRad(e)}offMeshConDir(e){return this.raw.get_offMeshConDir(e)}offMeshConAreas(e){return this.raw.get_offMeshConAreas(e)}offMeshConFlags(e){return this.raw.get_offMeshConFlags(e)}offMeshConUserID(e){return this.raw.get_offMeshConUserID(e)}offMeshConCount(){return this.raw.offMeshConCount}userId(){return this.raw.userId}tileX(){return this.raw.tileX}setTileX(e){this.raw.tileX=e}tileY(){return this.raw.tileY}setTileY(e){this.raw.tileY=e}tileLayer(){return this.raw.tileLayer}setTileLayer(e){this.raw.tileLayer=e}boundsMin(){return v(e=>this.raw.get_bmin(e),3)}setBoundsMin(e){this.raw.set_bmin(0,e[0]),this.raw.set_bmin(1,e[1]),this.raw.set_bmin(2,e[2])}boundsMax(){return v(e=>this.raw.get_bmax(e),3)}setBoundsMax(e){this.raw.set_bmax(0,e[0]),this.raw.set_bmax(1,e[1]),this.raw.set_bmax(2,e[2])}walkableHeight(){return this.raw.walkableHeight}setWalkableHeight(e){this.raw.walkableHeight=e}walkableRadius(){return this.raw.walkableRadius}setWalkableRadius(e){this.raw.walkableRadius=e}walkableClimb(){return this.raw.walkableClimb}setWalkableClimb(e){this.raw.walkableClimb=e}cellSize(){return this.raw.cs}setCellSize(e){this.raw.cs=e}cellHeight(){return this.raw.ch}setCellHeight(e){this.raw.ch=e}buildBvTree(){return this.raw.buildBvTree}setBuildBvTree(e){this.raw.buildBvTree=e}}class ge{get includeFlags(){return this.raw.getIncludeFlags()}set includeFlags(e){this.raw.setIncludeFlags(e)}get excludeFlags(){return this.raw.getExcludeFlags()}set excludeFlags(e){this.raw.setExcludeFlags(e)}constructor(e){this.raw=e??new s.Module.dtQueryFilter}getAreaCost(e){return this.raw.getAreaCost(e)}setAreaCost(e,t){this.raw.setAreaCost(e,t)}}class ee{defaultQueryHalfExtents={x:1,y:1,z:1};constructor(e,t){e instanceof s.Module.NavMeshQuery?this.raw=e:(this.raw=new s.Module.NavMeshQuery,this.raw.init(e.raw,t?.maxNodes??2048)),t?.defaultQueryFilter?this.defaultFilter=t.defaultQueryFilter:(this.defaultFilter=new ge,this.defaultFilter.includeFlags=65535,this.defaultFilter.excludeFlags=0)}findNearestPoly(e,t){const r=new s.UnsignedIntRef,i=new s.Vec3,o=new s.BoolRef,l=this.raw.findNearestPoly(m.toArray(e),m.toArray(t?.halfExtents??this.defaultQueryHalfExtents),t?.filter?.raw??this.defaultFilter.raw,r,i,o),n=m.fromRaw(i);s.destroy(i);const u=r.value;s.destroy(r);const d=o.value;return s.destroy(o),{success:L(l),status:l,nearestRef:u,nearestPoint:n,isOverPoly:d}}findPolysAroundCircle(e,t,r,i){const o=i?.filter??this.defaultFilter,l=i?.maxPolys??256,n=new z,u=new z,d=new k;n.resize(l),u.resize(l),d.resize(l);const _=new s.IntRef,c=this.raw.findPolysAroundCircle(e,m.toArray(t),r,o.raw,n.raw,u.raw,d.raw,_,l),y=[...n.getHeapView()];n.destroy();const M=[...u.getHeapView()];u.destroy();const p=[...d.getHeapView()];d.destroy();const C=_.value;return s.destroy(_),{success:L(c),status:c,resultRefs:y,resultParents:M,resultCost:p,resultCount:C}}queryPolygons(e,t,r){const i=r?.filter??this.defaultFilter,o=r?.maxPolys??256,l=new z;l.resize(o);const n=new s.IntRef,u=this.raw.queryPolygons(m.toArray(e),m.toArray(t),i.raw,l.raw,n,o),d=n.value;s.destroy(n);const _=[...l.getHeapView()].slice(0,d);return l.destroy(),{success:L(u),status:u,polyRefs:_}}closestPointOnPoly(e,t){const r=new s.Vec3,i=new s.BoolRef,o=this.raw.closestPointOnPoly(e,m.toArray(t),r,i),l=m.fromRaw(r);s.destroy(r);const n=i.value;return s.destroy(i),{success:L(o),status:o,closestPoint:l,isPointOverPoly:n}}findClosestPoint(e,t){const r=t?.filter??this.defaultFilter,i=t?.halfExtents??this.defaultQueryHalfExtents,o=new s.UnsignedIntRef,l=new s.Vec3,n=new s.BoolRef,u=this.raw.findClosestPoint(m.toArray(e),m.toArray(i),r.raw,o,l,n),d=o.value;s.destroy(o);const _=m.fromRaw(l);s.destroy(l);const c=n.value;return s.destroy(n),{success:L(u),status:u,polyRef:d,point:_,isPointOverPoly:c}}findRandomPointAroundCircle(e,t,r){const i=r?.filter??this.defaultFilter,o=r?.halfExtents??this.defaultQueryHalfExtents;let l;if(r?.startRef)l=r.startRef;else{const y=this.findNearestPoly(e,{filter:i,halfExtents:o});if(!y.success)return{success:!1,status:y.status,randomPolyRef:0,randomPoint:{x:0,y:0,z:0}};l=y.nearestRef}const n=new s.UnsignedIntRef,u=new s.Vec3,d=this.raw.findRandomPointAroundCircle(l,m.toArray(e),t,i.raw,n,u),_=n.value;s.destroy(n);const c=m.fromRaw(u);return s.destroy(u),{success:L(d),status:d,randomPolyRef:_,randomPoint:c}}moveAlongSurface(e,t,r,i){const o=i?.maxVisitedSize??256,l=new s.Vec3,n=new z,u=i?.filter?.raw??this.defaultFilter.raw,d=this.raw.moveAlongSurface(e,m.toArray(t),m.toArray(r),u,l,n.raw,o),_=m.fromRaw(l);s.destroy(l);const c=[...n.getHeapView()];return n.destroy(),{success:L(d),status:d,resultPosition:_,visited:c}}findRandomPoint(e){const t=new s.UnsignedIntRef,r=new s.Vec3,i=this.raw.findRandomPoint(e?.filter?.raw??this.defaultFilter.raw,t,r),o=t.value;s.destroy(t);const l=m.fromRaw(r);return s.destroy(r),{success:L(i),status:i,randomPolyRef:o,randomPoint:l}}getPolyHeight(e,t){const r=new s.FloatRef,i=this.raw.getPolyHeight(e,m.toArray(t),r),o=r.value;return s.destroy(r),{success:L(i),status:i,height:o}}computePath(e,t,r){const i=r?.filter??this.defaultFilter,o=r?.halfExtents??this.defaultQueryHalfExtents,l=this.findNearestPoly(e,{filter:i,halfExtents:o});if(!l.success)return{success:!1,error:{name:"findNearestPoly for start position failed",status:l.status},path:[]};const n=this.findNearestPoly(t,{filter:i,halfExtents:o});if(!n.success)return{success:!1,error:{name:"findNearestPoly for end position failed",status:n.status},path:[]};const u=l.nearestRef,d=n.nearestRef,_=r?.maxPathPolys??256,c=this.findPath(u,d,e,t,{filter:i,maxPathPolys:_});if(!c.success)return{success:!1,error:{name:"findPath unsuccessful",status:c.status},path:[]};if(c.polys.size<=0)return{success:!1,error:{name:"no polygon path found"},path:[]};const y=c.polys.get(c.polys.size-1);let M={x:t.x,y:t.y,z:t.z};if(y!==d){const A=this.closestPointOnPoly(y,t);if(!A.success)return{success:!1,error:{name:"no closest point on last polygon found",status:A.status},path:[]};M=A.closestPoint}const p=r?.maxStraightPathPoints,C=this.findStraightPath(e,M,c.polys,{maxStraightPathPoints:p});if(!C.success)return{success:!1,error:{name:"findStraightPath unsuccessful",status:C.status},path:[]};const{straightPath:I,straightPathCount:w}=C,P=[];for(let A=0;A<w;A++)P.push({x:I.get(A*3),y:I.get(A*3+1),z:I.get(A*3+2)});return c.polys.destroy(),C.straightPath.destroy(),C.straightPathFlags.destroy(),C.straightPathRefs.destroy(),{success:!0,path:P}}findPath(e,t,r,i,o){const l=o?.filter??this.defaultFilter,n=o?.maxPathPolys??256,u=new z;u.resize(n);const d=this.raw.findPath(e,t,m.toArray(r),m.toArray(i),l.raw,u.raw,n);return{success:L(d),status:d,polys:u}}findStraightPath(e,t,r,i){const o=i?.maxStraightPathPoints??256,l=i?.straightPathOptions??0;let n;Array.isArray(r)?(n=new z,n.copy(r)):n=r;const u=new k;u.resize(o*3);const d=new Y;d.resize(o);const _=new z;_.resize(o);const c=new s.IntRef,y=this.raw.findStraightPath(m.toArray(e),m.toArray(t),n.raw,u.raw,d.raw,_.raw,c,o,l),M=c.value;return s.destroy(c),Array.isArray(r)&&n.destroy(),{success:L(y),status:y,straightPath:u,straightPathFlags:d,straightPathRefs:_,straightPathCount:M}}raycast(e,t,r,i){const o=new s.Module.dtRaycastHit,l=i?.raycastOptions??0,n=i?.prevRef??0,u=i?.filter?.raw??this.defaultFilter.raw,d=this.raw.raycast(e,m.toArray(t),m.toArray(r),u,l,o,n),_={success:L(d),status:d,t:o.t,hitNormal:m.fromArray(v(c=>o.get_hitNormal(c),3)),hitEdgeIndex:o.hitEdgeIndex,path:v(c=>o.get_path(c),o.pathCount),maxPath:o.maxPath,pathCost:o.pathCost};return s.destroy(o),_}destroy(){this.raw.destroy()}}const _e={radius:.5,height:1,maxAcceleration:20,maxSpeed:6,collisionQueryRange:2.5,pathOptimizationRange:0,separationWeight:0,updateFlags:7,obstacleAvoidanceType:0,queryFilterType:0,userData:0};class at{get radius(){return this.raw.params.radius}set radius(e){this.raw.params.radius=e}get height(){return this.raw.params.height}set height(e){this.raw.params.height=e}get maxAcceleration(){return this.raw.params.maxAcceleration}set maxAcceleration(e){this.raw.params.maxAcceleration=e}get maxSpeed(){return this.raw.params.maxSpeed}set maxSpeed(e){this.raw.params.maxSpeed=e}get collisionQueryRange(){return this.raw.params.collisionQueryRange}set collisionQueryRange(e){this.raw.params.collisionQueryRange=e}get pathOptimizationRange(){return this.raw.params.pathOptimizationRange}set pathOptimizationRange(e){this.raw.params.pathOptimizationRange=e}get separationWeight(){return this.raw.params.separationWeight}set separationWeight(e){this.raw.params.separationWeight=e}get updateFlags(){return this.raw.params.updateFlags}set updateFlags(e){this.raw.params.updateFlags=e}get obstacleAvoidanceType(){return this.raw.params.obstacleAvoidanceType}set obstacleAvoidanceType(e){this.raw.params.obstacleAvoidanceType=e}get queryFilterType(){return this.raw.params.queryFilterType}set queryFilterType(e){this.raw.params.queryFilterType=e}get userData(){return this.raw.params.userData}set userData(e){this.raw.params.userData=e}interpolatedPosition={x:0,y:0,z:0};constructor(e,t){this.crowd=e,this.agentIndex=t,this.raw=e.raw.getEditableAgent(t),this.interpolatedPosition=this.position()}requestMoveTarget(e){const{nearestPoint:t,nearestRef:r}=this.crowd.navMeshQuery.findNearestPoly(e,{halfExtents:this.crowd.navMeshQuery.defaultQueryHalfExtents,filter:this.crowd.navMeshQuery.defaultFilter});return this.crowd.raw.requestMoveTarget(this.agentIndex,r,m.toArray(t))}requestMoveVelocity(e){return this.crowd.raw.requestMoveVelocity(this.agentIndex,m.toArray(e))}resetMoveTarget(){this.crowd.raw.resetMoveTarget(this.agentIndex)}teleport(e){s.CrowdUtils.agentTeleport(this.crowd.raw,this.agentIndex,m.toArray(e),m.toArray(this.crowd.navMeshQuery.defaultQueryHalfExtents),this.crowd.navMeshQuery.defaultFilter.raw),m.copy(e,this.interpolatedPosition)}position(){return{x:this.raw.get_npos(0),y:this.raw.get_npos(1),z:this.raw.get_npos(2)}}velocity(){return{x:this.raw.get_vel(0),y:this.raw.get_vel(1),z:this.raw.get_vel(2)}}desiredVelocity(){return{x:this.raw.get_dvel(0),y:this.raw.get_dvel(1),z:this.raw.get_dvel(2)}}desiredVelocityObstacleAdjusted(){return{x:this.raw.get_nvel(0),y:this.raw.get_nvel(1),z:this.raw.get_nvel(2)}}state(){return this.raw.state}target(){return{x:this.raw.get_targetPos(0),y:this.raw.get_targetPos(1),z:this.raw.get_targetPos(2)}}nextTargetInPath(){return{x:this.raw.get_cornerVerts(0),y:this.raw.get_cornerVerts(1),z:this.raw.get_cornerVerts(2)}}corners(){const e=[];for(let t=0;t<this.raw.ncorners;t++)e.push({x:this.raw.get_cornerVerts(t*3),y:this.raw.get_cornerVerts(t*3+1),z:this.raw.get_cornerVerts(t*3+2)});return e}parameters(){const{params:e}=this.raw;return{radius:e.radius,height:e.height,maxAcceleration:e.maxAcceleration,maxSpeed:e.maxSpeed,collisionQueryRange:e.collisionQueryRange,pathOptimizationRange:e.pathOptimizationRange,separationWeight:e.separationWeight,updateFlags:e.updateFlags,obstacleAvoidanceType:e.obstacleAvoidanceType,queryFilterType:e.queryFilterType,userData:e.userData}}updateParameters(e){const t={...this.parameters(),...e};this.setParameters(t)}setParameters(e){const t={..._e,...e},r=new s.Module.dtCrowdAgentParams;r.radius=t.radius,r.height=t.height,r.maxAcceleration=t.maxAcceleration,r.maxSpeed=t.maxSpeed,r.collisionQueryRange=t.collisionQueryRange,r.pathOptimizationRange=t.pathOptimizationRange,r.separationWeight=t.separationWeight,r.updateFlags=t.updateFlags,r.obstacleAvoidanceType=t.obstacleAvoidanceType,r.queryFilterType=t.queryFilterType,r.userData=t.userData,this.crowd.raw.updateAgentParameters(this.agentIndex,r)}overOffMeshConnection(){return s.CrowdUtils.overOffMeshConnection(this.crowd.raw,this.agentIndex)}}class it{agents={};accumulator=0;constructor(e,{maxAgents:t,maxAgentRadius:r}){this.navMesh=e,this.raw=s.Detour.allocCrowd(),this.raw.init(t,r,e.raw.getNavMesh()),this.navMeshQuery=new ee(new s.Module.NavMeshQuery(this.raw.getNavMeshQuery()))}update(e,t,r=10){if(t===void 0)this.raw.update(e,void 0);else{this.accumulator+=t;let i=0;for(;this.accumulator>=e&&i<r;)this.raw.update(e,void 0),this.accumulator-=e,i++;const o=this.accumulator%e/e,l=this.getAgents();for(const n of l)m.lerp(n.interpolatedPosition,n.position(),o,n.interpolatedPosition)}}addAgent(e,t){const r={..._e,...t},i=new s.Module.dtCrowdAgentParams;i.radius=r.radius,i.height=r.height,i.maxAcceleration=r.maxAcceleration,i.maxSpeed=r.maxSpeed,i.collisionQueryRange=r.collisionQueryRange,i.pathOptimizationRange=r.pathOptimizationRange,i.separationWeight=r.separationWeight,i.updateFlags=r.updateFlags,i.obstacleAvoidanceType=r.obstacleAvoidanceType,i.queryFilterType=r.queryFilterType,i.userData=r.userData;const o=this.raw.addAgent(m.toArray(e),i),l=new at(this,o);return this.agents[o]=l,l}getAgent(e){const t=this.agents[e];return t||null}removeAgent(e){const t=typeof e=="number"?e:e.agentIndex;this.raw.removeAgent(t),delete this.agents[t]}getAgentCount(){return this.raw.getAgentCount()}getActiveAgentCount(){return s.CrowdUtils.getActiveAgentCount(this.raw)}getAgents(){return Object.values(this.agents)}getFilter(e){return new ge(this.raw.getEditableFilter(e))}destroy(){s.Detour.freeCrowd(this.raw)}}class nt{constructor(e){this.raw=e}tiles(e){return new B(this.raw.get_tiles(e))}tileCount(){return this.raw.tileCount}}class ot{constructor(e){this.raw=e}data(){return v(e=>this.raw.get_data(e),this.raw.dataSize)}dataSize(){return this.raw.dataSize}}class lt{constructor(e){this.raw=e}tileX(){return this.raw.tileX}tileY(){return this.raw.tileY}}class ut{constructor(e){this.raw=e}data(){return v(e=>this.raw.get_data(e),this.raw.dataSize)}dataSize(){return this.raw.dataSize}}class Q{constructor(e){this.raw=e}static create(e){const t=new s.Module.dtNavMeshParams;return t.set_orig(0,e.orig.x),t.set_orig(1,e.orig.y),t.set_orig(2,e.orig.z),t.tileWidth=e.tileWidth,t.tileHeight=e.tileHeight,t.maxTiles=e.maxTiles,t.maxPolys=e.maxPolys,new Q(t)}clone(){return Q.create({orig:{x:this.raw.get_orig(0),y:this.raw.get_orig(1),z:this.raw.get_orig(2)},tileWidth:this.raw.tileWidth,tileHeight:this.raw.tileHeight,maxTiles:this.raw.maxTiles,maxPolys:this.raw.maxPolys})}}class te{constructor(e){this.raw=e??new s.Module.NavMesh}initSolo(e){return this.raw.initSolo(e.raw)}initTiled(e){return this.raw.initTiled(e.raw)}addTile(e,t,r){const i=new s.UnsignedIntRef,o=this.raw.addTile(e.raw,t,r,i),l=i.value;return s.destroy(i),{status:o,tileRef:l}}decodePolyId(e){const t=new s.UnsignedIntRef,r=new s.UnsignedIntRef,i=new s.UnsignedIntRef;this.raw.decodePolyId(e,t,r,i);const o=t.value;s.destroy(t);const l=r.value;s.destroy(r);const n=i.value;return s.destroy(i),{tileSalt:o,tileIndex:l,tilePolygonIndex:n}}encodePolyId(e,t,r){return this.raw.encodePolyId(e,t,r)}removeTile(e){return new ot(this.raw.removeTile(e))}calcTileLoc(e){return new lt(this.raw.calcTileLoc(m.toArray(e)))}getTileAt(e,t,r){const i=this.raw.getTileAt(e,t,r);return s.isNull(i)?null:new B(i)}getTilesAt(e,t,r){return new nt(this.raw.getTilesAt(e,t,r))}getTileRefAt(e,t,r){return this.raw.getTileRefAt(e,t,r)}getTileRef(e){return this.raw.getTileRef(e.raw)}getTileByRef(e){const t=this.raw.getTileByRef(e);return s.isNull(t)?null:new B(t)}getMaxTiles(){return this.raw.getMaxTiles()}getTile(e){return new B(this.raw.getTile(e))}getTileAndPolyByRef(e){const t=this.raw.getTileAndPolyByRef(e),r=new B(t.tile),i=new J(t.poly);return{success:L(t.status),status:t.status,tile:r,poly:i}}getTileAndPolyByRefUnsafe(e){const t=this.raw.getTileAndPolyByRef(e),r=new B(t.tile),i=new J(t.poly);return{tile:r,poly:i}}isValidPolyRef(e){return this.raw.isValidPolyRef(e)}getPolyRefBase(e){return this.raw.getPolyRefBase(e.raw)}getOffMeshConnectionPolyEndPoints(e,t){const r=new s.Vec3,i=new s.Vec3,o=this.raw.getOffMeshConnectionPolyEndPoints(e,t,r,i),l=m.fromRaw(r);s.destroy(r);const n=m.fromRaw(i);return s.destroy(i),{success:L(o),status:o,start:l,end:n}}getOffMeshConnectionByRef(e){return new he(this.raw.getOffMeshConnectionByRef(e))}setPolyFlags(e,t){return this.raw.setPolyFlags(e,t)}getPolyFlags(e){const t=new s.UnsignedShortRef,r=this.raw.getPolyFlags(e,t),i=t.value;return s.destroy(t),{status:r,flags:i}}setPolyArea(e,t){return this.raw.setPolyArea(e,t)}getPolyArea(e){const t=new s.UnsignedCharRef,r=this.raw.getPolyArea(e,t),i=t.value;return s.destroy(t),{status:r,area:i}}getTileStateSize(e){return this.raw.getTileStateSize(e.raw)}storeTileState(e,t){return new ut(this.raw.storeTileState(e.raw,t))}restoreTileState(e,t,r){return this.raw.restoreTileState(e.raw,t,r)}destroy(){this.raw.destroy(),s.Module.destroy(this.raw)}}const ct=(a,e)=>{const t=[],r=[];let i=0;const o=a.getMaxTiles();for(let l=0;l<o;l++){const n=a.getTile(l),u=n.header();if(!u)continue;const d=u.polyCount();for(let _=0;_<d;++_){const c=n.polys(_);if(c.getType()===1)continue;const y=c.vertCount(),M=n.detailMeshes(_),p=M.triBase(),C=M.triCount();for(let I=0;I<C;++I){const w=(p+I)*4;for(let P=0;P<3;++P){if(n.detailTris(w+P)<y){const A=c.verts(n.detailTris(w+P))*3;t.push(n.verts(A),n.verts(A+1),n.verts(A+2))}else{const A=(M.vertBase()+n.detailTris(w+P)-c.vertCount())*3;t.push(n.detailVerts(A),n.detailVerts(A+1),n.detailVerts(A+2))}r.push(i++)}}}}return[t,r]},re={borderSize:0,tileSize:0,cs:.2,ch:.2,walkableSlopeAngle:60,walkableHeight:2,walkableClimb:2,walkableRadius:.5,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1},fe=a=>{const e={...re,...a},t=new s.Module.rcConfig;return t.borderSize=e.borderSize,t.tileSize=e.tileSize,t.cs=e.cs,t.ch=e.ch,t.walkableSlopeAngle=e.walkableSlopeAngle,t.walkableHeight=e.walkableHeight,t.walkableClimb=e.walkableClimb,t.walkableRadius=e.walkableRadius,t.maxEdgeLen=e.maxEdgeLen,t.maxSimplificationError=e.maxSimplificationError,t.minRegionArea=e.minRegionArea,t.mergeRegionArea=e.mergeRegionArea,t.maxVertsPerPoly=e.maxVertsPerPoly,t.detailSampleDist=e.detailSampleDist,t.detailSampleMaxError=e.detailSampleMaxError,t},ht=a=>{const e=new s.Module.rcConfig;return e.set_bmin(0,a.get_bmin(0)),e.set_bmin(1,a.get_bmin(1)),e.set_bmin(2,a.get_bmin(2)),e.set_bmax(0,a.get_bmax(0)),e.set_bmax(1,a.get_bmax(1)),e.set_bmax(2,a.get_bmax(2)),e.width=a.width,e.height=a.height,e.borderSize=a.borderSize,e.tileSize=a.tileSize,e.cs=a.cs,e.ch=a.ch,e.walkableSlopeAngle=a.walkableSlopeAngle,e.walkableHeight=a.walkableHeight,e.walkableClimb=a.walkableClimb,e.walkableRadius=a.walkableRadius,e.maxEdgeLen=a.maxEdgeLen,e.maxSimplificationError=a.maxSimplificationError,e.minRegionArea=a.minRegionArea,e.mergeRegionArea=a.mergeRegionArea,e.maxVertsPerPoly=a.maxVertsPerPoly,e.detailSampleDist=a.detailSampleDist,e.detailSampleMaxError=a.detailSampleMaxError,e};class se{logs=[];startTimes={};accumulatedTimes={};constructor(e=!0){const t=new s.Module.RecastBuildContextJsImpl;t.log=(r,i,o)=>{if(!this.raw.logEnabled())return;const l=i,n=new Uint8Array(s.Module.HEAPU8.buffer,l,o),u=new Uint8Array(o);u.set(n);const d=new TextDecoder().decode(u);this.log(r,d)},t.resetLog=()=>{this.resetLog()},t.startTimer=r=>{this.raw.timerEnabled()&&this.startTimer(r)},t.stopTimer=r=>{this.raw.timerEnabled()&&this.stopTimer(r)},t.getAccumulatedTime=r=>this.raw.timerEnabled()?this.getAccumulatedTime(r):-1,t.resetTimers=()=>{this.raw.timerEnabled()&&(this.startTimes={},this.accumulatedTimes={})},this.raw=new s.Module.RecastBuildContext(t),this.raw.enableTimer(e),this.raw.enableLog(e),this.resetTimers()}log(e,t){this.logs.push({category:e,msg:t})}resetLog(){this.logs=[]}startTimer(e){this.startTimes[e]=performance.now()}stopTimer(e){const r=performance.now()-this.startTimes[e];this.accumulatedTimes[e]===-1?this.accumulatedTimes[e]=r:this.accumulatedTimes[e]+=r}getAccumulatedTime(e){return this.accumulatedTimes[e]}resetTimers(){for(let e=0;e<g.RC_MAX_TIMERS;e++)this.startTimes[e]=-1,this.accumulatedTimes[e]=-1}}class dt{constructor(e){this.raw=e??new s.rcChunkyTriMesh}init(e,t,r,i){return s.ChunkyTriMeshUtils.createChunkyTriMesh(e.raw,t.raw,r,i,this.raw)}getChunksOverlappingRect(e,t,r,i){return s.ChunkyTriMeshUtils.getChunksOverlappingRect(this.raw,e,t,r.raw,i)}getNodeTris(e){return W.fromRaw(s.ChunkyTriMeshUtils.getChunkyTriMeshNodeTris(this.raw,e))}nodes(e){return this.raw.get_nodes(e)}maxTrisPerChunk(){return this.raw.maxTrisPerChunk}}class V{constructor(e){this.raw=e}smin(){return this.raw.smin}smax(){return this.raw.smax}area(){return this.raw.area}next(){return s.isNull(this.raw.next)?null:new V(this.raw.next)}}class ae{constructor(e){this.raw=e}next(){return s.isNull(this.raw.next)?null:new ae(this.raw.next)}items(e){return new V(this.raw.get_items(e))}}class wt{constructor(e){this.raw=e}width(){return this.raw.width}height(){return this.raw.height}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}spans(e){return new V(this.raw.get_spans(e))}pools(e){return new ae(this.raw.get_pools(e))}freelist(e){return new V(this.raw.get_freelist(e))}}class gt{constructor(e){this.raw=e}index(){return this.raw.get_index()}count(){return this.raw.get_count()}}class _t{constructor(e){this.raw=e}y(){return this.raw.get_y()}reg(){return this.raw.get_reg()}con(){return this.raw.get_con()}h(){return this.raw.get_h()}}class ft{constructor(e){this.raw=e}width(){return this.raw.width}height(){return this.raw.height}spanCount(){return this.raw.spanCount}walkableHeight(){return this.raw.walkableHeight}walkableClimb(){return this.raw.walkableClimb}borderSize(){return this.raw.borderSize}maxDistance(){return this.raw.maxDistance}maxRegions(){return this.raw.maxRegions}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}cells(e){return new gt(this.raw.get_cells(e))}spans(e){return new _t(this.raw.get_spans(e))}dist(e){return this.raw.get_dist(e)}areas(e){return this.raw.get_areas(e)}}class Rt{constructor(e){this.raw=e}verts(e){return this.raw.get_verts(e)}nverts(){return this.raw.nverts}rverts(e){return this.raw.get_rverts(e)}nrverts(){return this.raw.nrverts}reg(){return this.raw.reg}area(){return this.raw.area}}class Tt{constructor(e){this.raw=e}conts(e){return new Rt(this.raw.get_conts(e))}nconts(){return this.raw.nconts}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}width(){return this.raw.width}height(){return this.raw.height}borderSize(){return this.raw.borderSize}maxError(){return this.raw.maxError}}class mt{constructor(e){this.raw=e}verts(e){return this.raw.get_verts(e)}polys(e){return this.raw.get_polys(e)}regs(e){return this.raw.get_regs(e)}flags(e){return this.raw.get_flags(e)}setFlags(e,t){this.raw.set_flags(e,t)}areas(e){return this.raw.get_areas(e)}setAreas(e,t){this.raw.set_areas(e,t)}nverts(){return this.raw.nverts}npolys(){return this.raw.npolys}maxpolys(){return this.raw.maxpolys}nvp(){return this.raw.nvp}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}borderSize(){return this.raw.borderSize}maxEdgeError(){return this.raw.maxEdgeError}}class yt{constructor(e){this.raw=e}meshes(e){return this.raw.get_meshes(e)}verts(e){return this.raw.get_verts(e)}tris(e){return this.raw.get_tris(e)}nmeshes(){return this.raw.nmeshes}nverts(){return this.raw.nverts}ntris(){return this.raw.ntris}}const Re=(a,e,t)=>s.Recast.calcGridSize(a,e,t),Te=(a,e,t,r,i,o,l,n)=>s.Recast.createHeightfield(a.raw,e.raw,t,r,i,o,l,n),me=(a,e,t,r,i,o,l)=>s.Recast.markWalkableTriangles(a.raw,e,t.raw,r,i.raw,o,l.raw),ye=(a,e,t,r,i,o,l,n=1)=>s.Recast.rasterizeTriangles(a.raw,e.raw,t,r.raw,i.raw,o,l.raw,n),Ae=(a,e,t)=>s.Recast.filterLowHangingWalkableObstacles(a.raw,e,t.raw),Me=(a,e,t,r)=>s.Recast.filterLedgeSpans(a.raw,e,t,r.raw),Ee=(a,e,t)=>s.Recast.filterWalkableLowHeightSpans(a.raw,e,t.raw),pe=(a,e,t,r,i)=>s.Recast.buildCompactHeightfield(a.raw,e,t,r.raw,i.raw),Ce=(a,e,t)=>s.Recast.erodeWalkableArea(a.raw,e,t.raw),Se=(a,e)=>s.Recast.buildDistanceField(a.raw,e.raw),Ie=(a,e,t,r,i)=>s.Recast.buildRegions(a.raw,e.raw,t,r,i),De=(a,e,t,r,i,o=g.RC_CONTOUR_TESS_WALL_EDGES)=>s.Recast.buildContours(a.raw,e.raw,t,r,i.raw,o),be=(a,e,t,r)=>s.Recast.buildPolyMesh(a.raw,e.raw,t,r.raw),Pe=(a,e,t,r,i,o)=>s.Recast.buildPolyMeshDetail(a.raw,e.raw,t.raw,r,i,o.raw),xe=()=>new wt(s.Recast.allocHeightfield()),X=a=>s.Recast.freeHeightfield(a.raw),ve=()=>new ft(s.Recast.allocCompactHeightfield()),$=a=>s.Recast.freeCompactHeightfield(a.raw),Ne=()=>new Tt(s.Recast.allocContourSet()),q=a=>s.Recast.freeContourSet(a.raw),Oe=()=>new mt(s.Recast.allocPolyMesh()),Le=a=>s.Recast.freePolyMesh(a.raw),Fe=()=>new yt(s.Recast.allocPolyMeshDetail()),He=a=>s.Recast.freePolyMeshDetail(a.raw),At=(a,e)=>{const t=s.NavMeshExporter.exportNavMesh(a.raw,e?.raw),r=new Uint8Array(s.Module.HEAPU8.buffer,t.dataPointer,t.size),i=new Uint8Array(t.size);return i.set(r),s.NavMeshExporter.freeNavMeshExport(t),i},Mt=a=>At(a),Et=a=>{const e=a.length*a.BYTES_PER_ELEMENT,t=s.Module._malloc(e),r=new Uint8Array(s.Module.HEAPU8.buffer,t,e);r.set(a);const i=new s.Module.NavMeshExport;return i.dataPointer=r.byteOffset,i.size=a.length,{navMeshExport:i,dataHeap:r}},pt=a=>{const{navMeshExport:e,dataHeap:t}=Et(a),r=s.NavMeshImporter.importNavMesh(e,void 0);return s.Module._free(t.byteOffset),{navMesh:new te(r.navMesh)}},ze=(a,e)=>{const t={x:1/0,y:1/0,z:1/0},r={x:-1/0,y:-1/0,z:-1/0};for(let i=0;i<e.length;i++){const o=e[i],l=a[o*3],n=a[o*3+1],u=a[o*3+2];t.x=Math.min(t.x,l),t.y=Math.min(t.y,n),t.z=Math.min(t.z,u),r.x=Math.max(r.x,l),r.y=Math.max(r.y,n),r.z=Math.max(r.z,u)}return{bbMin:m.toArray(t),bbMax:m.toArray(r)}},Ct=a=>{let e=0,t=0;return e=+(a>65535)<<4,a>>=e,t=+(a>255)<<3,a>>=t,e|=t,t=+(a>15)<<2,a>>=t,e|=t,t=+(a>3)<<1,a>>=t,e|=t,e|=a>>1,e},St=a=>(a--,a|=a>>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a++,a),It={...re,buildBvTree:!0},Dt=(a,e,t={},r=!1)=>{const i=new se,o={type:"solo",buildContext:i},l=()=>{r||(o.heightfield&&(X(o.heightfield),o.heightfield=void 0),o.compactHeightfield&&($(o.compactHeightfield),o.compactHeightfield=void 0),o.contourSet&&(q(o.contourSet),o.contourSet=void 0),o.polyMesh&&(Le(o.polyMesh),o.polyMesh=void 0),o.polyMeshDetail&&(He(o.polyMeshDetail),o.polyMeshDetail=void 0))},n=T=>(l(),{navMeshData:void 0,success:!1,intermediates:o,error:T}),u=a,d=e.length,_=new ue;_.copy(u);const c=e,y=e.length/3,M=new ce;M.copy(c);let p,C;if(t.bounds)p=t.bounds[0],C=t.bounds[1];else{const T=ze(a,e);p=T.bbMin,C=T.bbMax}const I={...It,...t},w=fe(I);w.minRegionArea=w.minRegionArea*w.minRegionArea,w.mergeRegionArea=w.mergeRegionArea*w.mergeRegionArea,w.detailSampleDist=w.detailSampleDist<.9?0:w.cs*w.detailSampleDist,w.detailSampleMaxError=w.ch*w.detailSampleMaxError;const P=Re(p,C,w.cs);w.width=P.width,w.height=P.height;const A=xe();if(o.heightfield=A,!Te(i,A,w.width,w.height,p,C,w.cs,w.ch))return n("Could not create heightfield");const E=new Z;if(E.resize(y),me(i,w.walkableSlopeAngle,_,d,M,y,E),!ye(i,_,d,M,E,y,A,w.walkableClimb))return n("Could not rasterize triangles");E.destroy(),_.destroy(),M.destroy(),Ae(i,w.walkableClimb,A),Me(i,w.walkableHeight,w.walkableClimb,A),Ee(i,w.walkableHeight,A);const D=ve();if(o.compactHeightfield=D,!pe(i,w.walkableHeight,w.walkableClimb,A,D))return n("Failed to build compact data");if(r||(X(A),o.heightfield=void 0),!Ce(i,w.walkableRadius,D))return n("Failed to erode walkable area");if(!Se(i,D))return n("Failed to build distance field");if(!Ie(i,D,w.borderSize,w.minRegionArea,w.mergeRegionArea))return n("Failed to build regions");const b=Ne();if(o.contourSet=b,!De(i,D,w.maxSimplificationError,w.maxEdgeLen,b,g.RC_CONTOUR_TESS_WALL_EDGES))return n("Failed to create contours");const S=Oe();if(o.polyMesh=S,!be(i,b,w.maxVertsPerPoly,S))return n("Failed to triangulate contours");const N=Fe();if(o.polyMeshDetail=N,!Pe(i,S,D,w.detailSampleDist,w.detailSampleMaxError,N))return n("Failed to build detail mesh");r||($(D),o.compactHeightfield=void 0,q(b),o.contourSet=void 0);for(let T=0;T<S.npolys();T++)S.areas(T)===g.RC_WALKABLE_AREA&&S.setAreas(T,0),S.areas(T)===0&&S.setFlags(T,1);const h=new we;h.setPolyMeshCreateParams(S),h.setPolyMeshDetailCreateParams(N),h.setWalkableHeight(w.walkableHeight*w.ch),h.setWalkableRadius(w.walkableRadius*w.cs),h.setWalkableClimb(w.walkableClimb*w.ch),h.setCellSize(w.cs),h.setCellHeight(w.ch),h.setBuildBvTree(I.buildBvTree),t.offMeshConnections&&h.setOffMeshConnections(t.offMeshConnections);const R=de(h);return R.success?(l(),{navMeshData:R.navMeshData,success:!0,intermediates:o}):n("Failed to create Detour navmesh data")},bt=(a,e,t={},r=!1)=>{if(!s.Module)throw new Error('"init" must be called before using any recast-navigation-js APIs. See: https://github.com/isaac-mason/recast-navigation-js?tab=readme-ov-file#initialization');const i=Dt(a,e,t,r);if(!i.success)return{navMesh:void 0,success:!1,intermediates:i.intermediates,error:i.error};const{navMeshData:o}=i,l=new te;return l.initSolo(o)?{success:!0,navMesh:l,intermediates:i.intermediates}:(o.destroy(),{navMesh:void 0,success:!1,intermediates:i.intermediates,error:"Failed to initialize solo NavMesh"})},Pt=({recastConfig:a,navMeshBounds:[e,t]})=>{const r=fe(a),i=Re(e,t,r.cs);r.width=i.width,r.height=i.height,r.minRegionArea=r.minRegionArea*r.minRegionArea,r.mergeRegionArea=r.mergeRegionArea*r.mergeRegionArea,r.tileSize=Math.floor(r.tileSize),r.borderSize=r.walkableRadius+3,r.width=r.tileSize+r.borderSize*2,r.height=r.tileSize+r.borderSize*2,r.detailSampleDist=r.detailSampleDist<.9?0:r.cs*r.detailSampleDist,r.detailSampleMaxError=r.ch*r.detailSampleMaxError;const o=Math.floor(r.tileSize),l=Math.floor((i.width+o-1)/o),n=Math.floor((i.height+o-1)/o),u=r.tileSize*r.cs,d=m.fromArray(e);let _=Math.min(Math.floor(Ct(St(l*n))),14);_>14&&(_=14);const c=22-_,y=1<<_,M=1<<c;return{config:r,gridSize:i,tileSize:o,tileWidth:l,tileHeight:n,tcs:u,orig:d,maxTiles:y,maxPolysPerTile:M}},Be={...re,chunkyTriMeshTrisPerChunk:256,buildBvTree:!0},xt=(a,e,t,r,i,o={},l=!1,n=new se)=>{const u={x:i.x,y:i.y},d=()=>{l||(u.compactHeightfield&&($(u.compactHeightfield),u.compactHeightfield=void 0),u.heightfield&&(X(u.heightfield),u.heightfield=void 0),u.contourSet&&(q(u.contourSet),u.contourSet=void 0),u.polyMesh&&(Le(u.polyMesh),u.polyMesh=void 0),u.polyMeshDetail&&(He(u.polyMeshDetail),u.polyMeshDetail=void 0))},_=T=>(n.log(g.RC_LOG_ERROR,T),d(),{success:!1,error:T,intermediates:u}),c=ht(t),y=[...i.bmin],M=[...i.bmax];y[0]-=c.borderSize*c.cs,y[2]-=c.borderSize*c.cs,M[0]+=c.borderSize*c.cs,M[2]+=c.borderSize*c.cs,c.set_bmin(0,y[0]),c.set_bmin(1,y[1]),c.set_bmin(2,y[2]),c.set_bmax(0,M[0]),c.set_bmax(1,M[1]),c.set_bmax(2,M[2]),n.resetTimers(),n.startTimer(g.RC_TIMER_TOTAL),n.log(g.RC_LOG_PROGRESS,`Building tile at x: ${i.x}, y: ${i.y}`),n.log(g.RC_LOG_PROGRESS,` - ${c.width} x ${c.height} cells`),n.log(g.RC_LOG_PROGRESS,` - ${a.size/3/1e3}K verts, ${e.size/3/1e3}K tris`);const p=xe();if(u.heightfield=p,!Te(n,p,c.width,c.height,y,M,c.cs,c.ch))return _("Could not create heightfield");new Z().resize(r.maxTrisPerChunk());const I=[y[0],y[2]],w=[M[0],M[2]],P=512,A=new je;A.resize(P);const E=r.getChunksOverlappingRect(I,w,A,P);if(E===0)return{success:!0,intermediates:u};for(let T=0;T<E;++T){const x=A.get(T),H=r.nodes(x).n,U=r.getNodeTris(x),F=new Z;F.resize(H),me(n,c.walkableSlopeAngle,a,e.size,U,H,F);const G=ye(n,a,e.size,U,F,H,p,c.walkableClimb);if(F.destroy(),!G)return _("Could not rasterize triangles")}Ae(n,c.walkableClimb,p),Me(n,c.walkableHeight,c.walkableClimb,p),Ee(n,c.walkableHeight,p);const D=ve();if(u.compactHeightfield=D,!pe(n,c.walkableHeight,c.walkableClimb,p,D))return _("Could not build compact heightfield");if(l||(X(u.heightfield),u.heightfield=void 0),!Ce(n,c.walkableRadius,D))return _("Could not erode walkable area");if(!Se(n,D))return _("Failed to build distance field");if(!Ie(n,D,c.borderSize,c.minRegionArea,c.mergeRegionArea))return _("Failed to build regions");const b=Ne();if(u.contourSet=b,!De(n,D,c.maxSimplificationError,c.maxEdgeLen,b,g.RC_CONTOUR_TESS_WALL_EDGES))return _("Failed to create contours");const S=Oe();if(u.polyMesh=S,!be(n,b,c.maxVertsPerPoly,S))return _("Failed to triangulate contours");const N=Fe();if(u.polyMeshDetail=N,!Pe(n,S,D,c.detailSampleDist,c.detailSampleMaxError,N))return _("Failed to build detail mesh");l||($(D),u.compactHeightfield=void 0,q(b),u.contourSet=void 0);for(let T=0;T<S.npolys();T++)S.areas(T)===g.RC_WALKABLE_AREA&&S.setAreas(T,0),S.areas(T)===0&&S.setFlags(T,1);const h=new we;h.setPolyMeshCreateParams(S),h.setPolyMeshDetailCreateParams(N),h.setWalkableHeight(c.walkableHeight*c.ch),h.setWalkableRadius(c.walkableRadius*c.cs),h.setWalkableClimb(c.walkableClimb*c.ch),h.setCellSize(c.cs),h.setCellHeight(c.ch),h.setBuildBvTree(o.buildBvTree??Be.buildBvTree),o.offMeshConnections&&h.setOffMeshConnections(o.offMeshConnections),h.setTileX(i.x),h.setTileY(i.y);const R=de(h);return R.success?(n.log(g.RC_LOG_PROGRESS,`>> Polymesh: ${S.nverts()} vertices ${S.npolys()} polygons`),{success:!0,data:R.navMeshData,intermediates:u}):_("Failed to create Detour navmesh data")},vt=(a,e,t={},r=!1)=>{if(!s.Module)throw new Error('"init" must be called before using any recast-navigation-js APIs. See: https://github.com/isaac-mason/recast-navigation-js?tab=readme-ov-file#initialization');const i=new se,o={type:"tiled",buildContext:i,chunkyTriMesh:void 0,tileIntermediates:[]},l=new te,n=a,u=new ue;u.copy(n);const d=e,_=e.length/3,c=new ce;c.copy(d);const y=()=>{u.destroy(),c.destroy(),!r&&o.chunkyTriMesh&&(o.chunkyTriMesh=void 0)},M=x=>(y(),l.destroy(),{success:!1,navMesh:void 0,intermediates:o,error:x}),p={...Be,...t};let C,I;if(t.bounds)C=t.bounds[0],I=t.bounds[1];else{const x=ze(a,e);C=x.bbMin,I=x.bbMax}const{config:w,tileWidth:P,tileHeight:A,tcs:E,orig:D,maxTiles:b,maxPolysPerTile:S}=Pt({recastConfig:p,navMeshBounds:[C,I]}),N=Q.create({orig:D,tileWidth:p.tileSize*p.cs,tileHeight:p.tileSize*p.cs,maxTiles:b,maxPolys:S});if(!l.initTiled(N))return M("Could not init nav mesh for tiled use");const h=new dt;if(o.chunkyTriMesh=h,!h.init(u,c,_,p.chunkyTriMeshTrisPerChunk))return M("Failed to build chunky triangle mesh");i.startTimer(g.RC_TIMER_TEMP);const R=[0,0,0],T=[0,0,0];for(let x=0;x<A;x++)for(let O=0;O<P;O++){R[0]=C[0]+O*E,R[1]=C[1],R[2]=C[2]+x*E,T[0]=C[0]+(O+1)*E,T[1]=I[1],T[2]=C[2]+(x+1)*E;const H={x:O,y:x,bmin:R,bmax:T},U={offMeshConnections:p.offMeshConnections,buildBvTree:p.buildBvTree},F=xt(u,c,w,h,H,U,r,i);if(o.tileIntermediates.push(F.intermediates),F.success&&F.data){l.removeTile(l.getTileRefAt(O,x,0));const G=l.addTile(F.data,f.DT_TILE_FREE_DATA,0);Ze(G.status)&&(i.log(g.RC_LOG_WARNING,`Failed to add tile to nav mesh tx: ${O}, ty: ${x}, status: ${Je(G.status)} (${G.status})`),F.data.destroy())}}return i.stopTimer(g.RC_TIMER_TEMP),r||y(),{success:!0,navMesh:l,intermediates:o}},Nt=a=>{const e=[],t=[],r={};let i=0;for(const{positions:o,indices:l}of a)for(let n=0;n<l.length;n++){const u=l[n]*3,d=o[u],_=o[u+1],c=o[u+2],y=`${d}_${_}_${c}`;let M=r[y];M||(r[y]=M=i,e.push(d,_,c),i++),t.push(M)}return[Float32Array.from(e),Uint32Array.from(t)]};new Qe;class Ot extends ke{constructor(e,t){super(),this.navMesh=e,this.navMeshGeometry=new Ve,this.navMeshMaterial=t?.navMeshMaterial?t.navMeshMaterial:new We({color:"orange",transparent:!0,opacity:.7,depthWrite:!1}),this.update(),this.mesh=new j(this.navMeshGeometry,this.navMeshMaterial),this.add(this.mesh)}update(){const[e,t]=ct(this.navMesh);this.navMeshGeometry.setAttribute("position",new ie(Float32Array.from(e),3)),this.navMeshGeometry.setIndex(new ie(Uint32Array.from(t),1)),this.navMeshGeometry.computeVertexNormals()}}const Lt=new Ye,Ue=a=>{const e=[];for(const t of a){const r=t.geometry.attributes.position;if(!r||r.itemSize!==3)continue;t.updateMatrixWorld();const i=new Float32Array(r.array);for(let l=0;l<i.length;l+=3){const n=Lt.set(i[l],i[l+1],i[l+2]);t.localToWorld(n),i[l]=n.x,i[l+1]=n.y,i[l+2]=n.z}let o=t.geometry.getIndex()?.array;if(o===void 0){const l=[];for(let n=0;n<r.count;n++)l.push(n);o=l}e.push({positions:i,indices:o})}return Nt(e)},Ft=(a,e={},t=!1)=>{const[r,i]=Ue(a);return bt(r,i,e,t)},Ht=(a,e={},t=!1)=>{const[r,i]=Ue(a);return vt(r,i,e,t)},zt=["invalid","walking","offmesh"];let oe=!1;async function nr(){oe||(await Ke(),oe=!0)}function Bt(a){const e=a.getIndex();if(e===null){const t=a.getAttribute("position").clone();for(let r=0;r+2<t.count;r+=3)for(let i=0;i<t.itemSize;i+=1){const o=t.getComponent(r+1,i);t.setComponent(r+1,i,t.getComponent(r+2,i)),t.setComponent(r+2,i,o)}a.setAttribute("position",t);return}for(let t=0;t+2<e.count;t+=3){const r=e.getX(t+1);e.setX(t+1,e.getX(t+2)),e.setX(t+2,r)}e.needsUpdate=!0}function Ut(a){const e=a.getAttribute("position"),t=a.getIndex(),r=l=>t?.getX(l)??l;let i=0;const o=t?.count??e.count;for(let l=0;l+2<o;l+=3){const n=r(l),u=r(l+1),d=r(l+2),_=e.getX(u)-e.getX(n),c=e.getZ(u)-e.getZ(n),y=e.getX(d)-e.getX(n),M=e.getZ(d)-e.getZ(n);i+=c*y-_*M}return i}function Gt(a){const e=[],t=(l,n)=>{if(n.determinant()<0){const d=l.clone().applyMatrix4(n);return Ut(d)<0&&Bt(d),e.push(d),new j(d)}const u=new j(l);return u.matrixAutoUpdate=!1,u.matrix.copy(n),u.matrixWorldNeedsUpdate=!0,u},r=[],i=new ne,o=new ne;for(const l of a){if(l.updateWorldMatrix(!0,!1),l instanceof Xe){for(let n=0;n<l.count;n+=1)l.getMatrixAt(n,i),o.multiplyMatrices(l.matrixWorld,i),r.push(t(l.geometry,o));continue}r.push(l.matrixWorld.determinant()>=0?l:t(l.geometry,l.matrixWorld))}return{meshes:r,temporaryGeometries:e}}const kt=1297302868,Vt=1,Wt=1145979222,Yt=7;function Qt(a){let e=1;for(;e<a;)e*=2;return e}function Xt(a,e){const t=a.vertices.length,r=a.polygons.length;if(t===0||r===0)throw new Error("NavMeshManager.buildFromPolygons: vertices and polygons must be non-empty");if(t>65535)throw new Error(`NavMeshManager.buildFromPolygons: ${t} vertices exceed Detour's uint16 tile index`);if(a.detailMeshes.length!==r)throw new Error(`NavMeshManager.buildFromPolygons: ${r} polygons require the same number of detail rows`);const i=a.polygons.map(h=>h.vertices.map(()=>0)),o=new Map;let l=0;for(let h=0;h<r;h+=1){const R=a.polygons[h];if(R.vertices.length<3||R.vertices.length>6)throw new Error(`NavMeshManager.buildFromPolygons: polygon ${h} has ${R.vertices.length} vertices; Detour permits 3..6`);l+=R.vertices.length;for(let T=0;T<R.vertices.length;T+=1){const x=R.vertices[T],O=R.vertices[(T+1)%R.vertices.length];if(!Number.isInteger(x)||!Number.isInteger(O)||x<0||O<0||x>=t||O>=t)throw new Error(`NavMeshManager.buildFromPolygons: polygon ${h} references an invalid vertex`);const H=`${x},${O}`;if(o.has(H))throw new Error(`NavMeshManager.buildFromPolygons: directed edge ${H} occurs more than once`);const U=o.get(`${O},${x}`);if(U===void 0)o.set(H,[h,T]);else{const[F,G]=U;i[h][T]=F+1,i[F][G]=h+1}}}for(let h=0;h<r;h+=1){const R=a.detailMeshes[h];if(R.vertexBase<0||R.vertexCount<0||R.vertexBase+R.vertexCount>a.detailVertices.length||R.triangleBase<0||R.triangleCount<0||R.triangleBase+R.triangleCount>a.detailTriangles.length||R.vertexCount>255||R.triangleCount>255)throw new Error(`NavMeshManager.buildFromPolygons: polygon ${h} has an invalid detail row`)}for(const h of a.detailTriangles)if(h.some(R=>!Number.isInteger(R)||R<0||R>255))throw new Error("NavMeshManager.buildFromPolygons: detail triangles must contain uint8 values");const n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],u=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const h of[...a.vertices,...a.detailVertices])for(let R=0;R<3;R+=1){const T=h[R];if(!Number.isFinite(T))throw new Error("NavMeshManager.buildFromPolygons: every vertex component must be finite");n[R]=Math.min(n[R],T),u[R]=Math.max(u[R],T)}const d=100,_=32,c=12,p=d+t*12+r*_+l*c+r*12+a.detailVertices.length*12+a.detailTriangles.length*4,C=new Uint8Array(48+p),I=new DataView(C.buffer);let w=0;const P=h=>{I.setUint8(w,h),w+=1},A=h=>{I.setUint16(w,h,!0),w+=2},E=h=>{I.setUint32(w,h,!0),w+=4},D=h=>{I.setInt32(w,h,!0),w+=4},b=h=>{I.setFloat32(w,h,!0),w+=4},S=Qt(r);E(kt),E(Vt),E(1);for(const h of n)b(h);b(Math.max(u[0]-n[0],Number.EPSILON)),b(Math.max(u[2]-n[2],Number.EPSILON)),E(1),E(S),E(S),E(p),E(Wt),E(Yt),D(0),D(0),D(0),E(0),E(r),E(t),E(l),E(r),E(a.detailVertices.length),E(a.detailTriangles.length),E(0),E(0),E(r);const N=le.navigation;b(e?.walkableHeight??N.walkableHeight),b(e?.walkableRadius??N.walkableRadius),b(e?.walkableClimb??N.walkableClimb);for(const h of n)b(h);for(const h of u)b(h);b(1/(e?.cellSize??N.cellSize));for(const h of a.vertices)for(const R of h)b(R);for(let h=0;h<r;h+=1){const R=a.polygons[h];E(4294967295);for(let T=0;T<6;T+=1)A(R.vertices[T]??0);for(let T=0;T<6;T+=1)A(i[h]?.[T]??0);A(R.flags??1),P(R.vertices.length),P((R.area??0)&63)}w+=l*c;for(const h of a.detailMeshes)E(h.vertexBase),E(h.triangleBase),P(h.vertexCount),P(h.triangleCount),A(0);for(const h of a.detailVertices)for(const R of h)b(R);for(const h of a.detailTriangles)for(const R of h)P(R);if(w!==C.length)throw new Error(`NavMeshManager.buildFromPolygons: encoded ${w} bytes into a ${C.length}-byte allocation`);return C}class or{navMesh=null;query=null;crowd=null;helper=null;buildFromMeshes(e,t){const r=le.navigation,i=Gt(e),o=i.meshes.reduce((u,d)=>{const _=d.geometry.getIndex(),c=d.geometry.getAttribute("position").count;return u+Math.floor((_?.count??c)/3)},0),l={cs:t?.cellSize??r.cellSize,ch:t?.cellHeight??r.cellHeight,walkableSlopeAngle:t?.walkableSlopeAngle??r.walkableSlopeAngle,walkableHeight:t?.walkableHeight??r.walkableHeight,walkableClimb:t?.walkableClimb??r.walkableClimb,walkableRadius:t?.walkableRadius??r.walkableRadius,maxEdgeLen:t?.maxEdgeLen??r.maxEdgeLen,maxSimplificationError:t?.maxSimplificationError??r.maxSimplificationError,minRegionArea:t?.minRegionArea??r.minRegionArea,mergeRegionArea:t?.mergeRegionArea??r.mergeRegionArea,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};let n;try{n=t?.tiled===!0||i.meshes.length>256||o>1e4?Ht(i.meshes,{...l,tileSize:t?.tileSize??256}):Ft(i.meshes,l)}finally{for(const u of i.temporaryGeometries)u.dispose()}return!n.success||!n.navMesh?!1:(this.destroyRecast(),this.navMesh=n.navMesh,this.query=new ee(this.navMesh),!0)}buildFromPolygons(e,t){try{return this.loadFromData(Xt(e,t)),!0}catch{return!1}}destroyRecast(){this.helper&&(this.helper.parent?.remove(this.helper),this.helper.dispose?.(),this.helper=null),this.crowd&&(this.crowd.destroy(),this.crowd=null),this.query&&(this.query.destroy(),this.query=null),this.navMesh&&(this.navMesh.destroy(),this.navMesh=null)}hasNavMesh(){return this.navMesh!==null}findPath(e,t){if(!this.query)throw new Error("NavMeshManager.findPath: no navmesh has been built, so no path can be queried. Build one first (buildFromMeshes/importNavMesh) — gate on hasNavMesh() if the caller can run before a bake.");const r=this.query.computePath(e,t);if(!r.success&&r.error)throw new Error(`NavMeshManager.findPath: recast could not complete the query (${r.error.name}${r.error.status===void 0?"":`, status ${r.error.status}`}).`);return r.path}createCrowd(e){if(!this.navMesh)throw new Error("Build navmesh first");return this.crowd=new it(this.navMesh,{maxAgents:e,maxAgentRadius:.6}),this.crowd}updateCrowd(e){this.crowd?.update(e)}getCrowdAgents(){return this.crowd?this.crowd.getAgents().map(e=>{const t=e.interpolatedPosition,r=e.velocity(),i=e.target(),o=zt[e.state()]??"invalid",l=o==="invalid"?[]:e.corners().map(n=>({x:n.x,y:n.y,z:n.z}));return{position:{x:t.x,y:t.y,z:t.z},velocity:{x:r.x,y:r.y,z:r.z},radius:e.radius,height:e.height,state:o,target:{x:i.x,y:i.y,z:i.z},corners:l}}):[]}getDebugMesh(e){return this.navMesh?(this.helper||(this.helper=new Ot(this.navMesh),e.add(this.helper)),this.helper):null}exportData(){if(!this.navMesh)throw new Error("No navmesh to export");return Mt(this.navMesh)}loadFromData(e){const{navMesh:t}=pt(e);this.destroyRecast(),this.navMesh=t,this.query=new ee(this.navMesh)}dispose(e){this.helper&&e.remove(this.helper),this.destroyRecast()}}export{or as NavMeshManager,nr as initNavigation};
1
+ import{_ as Ge}from"./index-ClgrFOcX.js";import"./three.module-BLhyNg0e.js";import{cW as ke,N as Ve,cp as We,co as j,M as ie,fo as Ye,_ as Qe,cm as ne,bu as Xe}from"./three.core-3arARmh6.js";import{DEFAULTS as le}from"./defaults-DKiBJCPN.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";const $e=["Recast","Detour","DetourNavMeshBuilder","DetourTileCacheBuilder","NavMeshImporter","NavMeshExporter","CrowdUtils","ChunkyTriMeshUtils","RecastDebugDraw","DetourDebugDraw"],qe=["rcConfig","rcContext","dtNavMeshParams","dtNavMeshCreateParams","RecastLinearAllocator","RecastFastLZCompressor","rcChunkyTriMesh","dtTileCacheParams","dtTileCacheLayerHeader","Vec3","BoolRef","IntRef","UnsignedIntRef","UnsignedCharRef","UnsignedShortRef","FloatRef","IntArray","UnsignedIntArray","UnsignedCharArray","UnsignedShortArray","FloatArray"],s={isNull:a=>s.Module.getPointer(a)===0,destroy:a=>{s.Module.destroy(a)}},g={},f={},Ke=async a=>{if(s.Module===void 0){{const e=(await Ge(async()=>{const{default:t}=await import("./recast-navigation.wasm-compat-Dsoa_MD-.js");return{default:t}},[])).default;s.Module=await e()}for(const e of $e)s[e]=new s.Module[e];for(const e of qe)s[e]=s.Module[e];g.RC_BORDER_REG=s.Recast.BORDER_REG,g.RC_MULTIPLE_REGS=s.Recast.MULTIPLE_REGS,g.RC_BORDER_VERTEX=s.Recast.BORDER_VERTEX,g.RC_AREA_BORDER=s.Recast.AREA_BORDER,g.RC_CONTOUR_REG_MASK=s.Recast.CONTOUR_REG_MASK,g.RC_MESH_NULL_IDX=s.Recast.MESH_NULL_IDX,g.RC_NULL_AREA=s.Recast.NULL_AREA,g.RC_WALKABLE_AREA=s.Recast.WALKABLE_AREA,g.RC_NOT_CONNECTED=s.Recast.NOT_CONNECTED,g.RC_CONTOUR_TESS_WALL_EDGES=s.Module.RC_CONTOUR_TESS_WALL_EDGES,g.RC_CONTOUR_TESS_AREA_EDGES=s.Module.RC_CONTOUR_TESS_AREA_EDGES,g.RC_LOG_PROGRESS=s.Module.RC_LOG_PROGRESS,g.RC_LOG_WARNING=s.Module.RC_LOG_WARNING,g.RC_LOG_ERROR=s.Module.RC_LOG_ERROR,g.RC_TIMER_TOTAL=s.Module.RC_TIMER_TOTAL,g.RC_TIMER_TEMP=s.Module.RC_TIMER_TEMP,g.RC_TIMER_RASTERIZE_TRIANGLES=s.Module.RC_TIMER_RASTERIZE_TRIANGLES,g.RC_TIMER_BUILD_COMPACTHEIGHTFIELD=s.Module.RC_TIMER_BUILD_COMPACTHEIGHTFIELD,g.RC_TIMER_BUILD_CONTOURS=s.Module.RC_TIMER_BUILD_CONTOURS,g.RC_TIMER_BUILD_CONTOURS_TRACE=s.Module.RC_TIMER_BUILD_CONTOURS_TRACE,g.RC_TIMER_BUILD_CONTOURS_SIMPLIFY=s.Module.RC_TIMER_BUILD_CONTOURS_SIMPLIFY,g.RC_TIMER_FILTER_BORDER=s.Module.RC_TIMER_FILTER_BORDER,g.RC_TIMER_FILTER_WALKABLE=s.Module.RC_TIMER_FILTER_WALKABLE,g.RC_TIMER_MEDIAN_AREA=s.Module.RC_TIMER_MEDIAN_AREA,g.RC_TIMER_FILTER_LOW_OBSTACLES=s.Module.RC_TIMER_FILTER_LOW_OBSTACLES,g.RC_TIMER_BUILD_POLYMESH=s.Module.RC_TIMER_BUILD_POLYMESH,g.RC_TIMER_MERGE_POLYMESH=s.Module.RC_TIMER_MERGE_POLYMESH,g.RC_TIMER_ERODE_AREA=s.Module.RC_TIMER_ERODE_AREA,g.RC_TIMER_MARK_BOX_AREA=s.Module.RC_TIMER_MARK_BOX_AREA,g.RC_TIMER_MARK_CYLINDER_AREA=s.Module.RC_TIMER_MARK_CYLINDER_AREA,g.RC_TIMER_MARK_CONVEXPOLY_AREA=s.Module.RC_TIMER_MARK_CONVEXPOLY_AREA,g.RC_TIMER_BUILD_DISTANCEFIELD=s.Module.RC_TIMER_BUILD_DISTANCEFIELD,g.RC_TIMER_BUILD_DISTANCEFIELD_DIST=s.Module.RC_TIMER_BUILD_DISTANCEFIELD_DIST,g.RC_TIMER_BUILD_DISTANCEFIELD_BLUR=s.Module.RC_TIMER_BUILD_DISTANCEFIELD_BLUR,g.RC_TIMER_BUILD_REGIONS=s.Module.RC_TIMER_BUILD_REGIONS,g.RC_TIMER_BUILD_REGIONS_WATERSHED=s.Module.RC_TIMER_BUILD_REGIONS_WATERSHED,g.RC_TIMER_BUILD_REGIONS_EXPAND=s.Module.RC_TIMER_BUILD_REGIONS_EXPAND,g.RC_TIMER_BUILD_REGIONS_FLOOD=s.Module.RC_TIMER_BUILD_REGIONS_FLOOD,g.RC_TIMER_BUILD_REGIONS_FILTER=s.Module.RC_TIMER_BUILD_REGIONS_FILTER,g.RC_TIMER_BUILD_LAYERS=s.Module.RC_TIMER_BUILD_LAYERS,g.RC_TIMER_BUILD_POLYMESHDETAIL=s.Module.RC_TIMER_BUILD_POLYMESHDETAIL,g.RC_TIMER_MERGE_POLYMESHDETAIL=s.Module.RC_TIMER_MERGE_POLYMESHDETAIL,g.RC_MAX_TIMERS=s.Module.RC_MAX_TIMERS,f.DT_FAILURE=s.Detour.FAILURE,f.DT_SUCCESS=s.Detour.SUCCESS,f.DT_IN_PROGRESS=s.Detour.IN_PROGRESS,f.DT_STATUS_DETAIL_MASK=s.Detour.STATUS_DETAIL_MASK,f.DT_WRONG_MAGIC=s.Detour.WRONG_MAGIC,f.DT_WRONG_VERSION=s.Detour.WRONG_VERSION,f.DT_OUT_OF_MEMORY=s.Detour.OUT_OF_MEMORY,f.DT_INVALID_PARAM=s.Detour.INVALID_PARAM,f.DT_BUFFER_TOO_SMALL=s.Detour.BUFFER_TOO_SMALL,f.DT_OUT_OF_NODES=s.Detour.OUT_OF_NODES,f.DT_PARTIAL_RESULT=s.Detour.PARTIAL_RESULT,f.DT_ALREADY_OCCUPIED=s.Detour.ALREADY_OCCUPIED,f.DT_VERTS_PER_POLYGON=s.Detour.VERTS_PER_POLYGON,f.DT_NAVMESH_MAGIC=s.Detour.NAVMESH_MAGIC,f.DT_NAVMESH_VERSION=s.Detour.NAVMESH_VERSION,f.DT_NAVMESH_STATE_MAGIC=s.Detour.NAVMESH_STATE_MAGIC,f.DT_NAVMESH_STATE_VERSION=s.Detour.NAVMESH_STATE_VERSION,f.DT_TILECACHE_MAGIC=s.Detour.TILECACHE_MAGIC,f.DT_TILECACHE_VERSION=s.Detour.TILECACHE_VERSION,f.DT_TILECACHE_NULL_AREA=s.Detour.TILECACHE_NULL_AREA,f.DT_TILECACHE_WALKABLE_AREA=s.Detour.TILECACHE_WALKABLE_AREA,f.DT_TILECACHE_NULL_IDX=s.Detour.TILECACHE_NULL_IDX,f.DT_NULL_LINK=s.Detour.NULL_LINK,f.DT_NULL_LINK=s.Detour.NULL_LINK,f.DT_EXT_LINK=s.Detour.EXT_LINK,f.DT_OFFMESH_CON_BIDIR=s.Detour.OFFMESH_CON_BIDIR,f.DT_STRAIGHTPATH_START=s.Module.DT_STRAIGHTPATH_START,f.DT_STRAIGHTPATH_END=s.Module.DT_STRAIGHTPATH_END,f.DT_STRAIGHTPATH_OFFMESH_CONNECTION=s.Module.DT_STRAIGHTPATH_OFFMESH_CONNECTION,f.DT_STRAIGHTPATH_AREA_CROSSINGS=s.Module.DT_STRAIGHTPATH_AREA_CROSSINGS,f.DT_STRAIGHTPATH_ALL_CROSSINGS=s.Module.DT_STRAIGHTPATH_ALL_CROSSINGS,f.DT_FINDPATH_ANY_ANGLE=s.Module.DT_FINDPATH_ANY_ANGLE,f.DT_RAYCAST_USE_COSTS=s.Module.DT_RAYCAST_USE_COSTS,f.DT_CROWDAGENT_STATE_INVALID=s.Module.DT_CROWDAGENT_STATE_INVALID,f.DT_CROWDAGENT_STATE_WALKING=s.Module.DT_CROWDAGENT_STATE_WALKING,f.DT_CROWDAGENT_STATE_OFFMESH=s.Module.DT_CROWDAGENT_STATE_OFFMESH,f.DT_CROWDAGENT_TARGET_NONE=s.Module.DT_CROWDAGENT_TARGET_NONE,f.DT_CROWDAGENT_TARGET_FAILED=s.Module.DT_CROWDAGENT_TARGET_FAILED,f.DT_CROWDAGENT_TARGET_VALID=s.Module.DT_CROWDAGENT_TARGET_VALID,f.DT_CROWDAGENT_TARGET_REQUESTING=s.Module.DT_CROWDAGENT_TARGET_REQUESTING,f.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE=s.Module.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE,f.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH=s.Module.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH,f.DT_CROWDAGENT_TARGET_VELOCITY=s.Module.DT_CROWDAGENT_TARGET_VELOCITY,f.DT_COMPRESSEDTILE_FREE_DATA=s.Module.DT_COMPRESSEDTILE_FREE_DATA,f.DT_TILE_FREE_DATA=s.Module.DT_TILE_FREE_DATA}};class K{get size(){return this.raw.size}constructor(e){this.raw=e}get(e){return this.raw.get(e)}set(e,t){this.raw.set(e,t)}resize(e){this.raw.resize(e)}copy(e){this.raw.resize(e.length),this.getHeapView().set(e)}destroy(){s.destroy(this.raw)}getHeapView(){const e=this.getHeap();return new this.ArrayConstructor(e.buffer,this.raw.getDataPointer(),this.size)}toTypedArray(){const e=this.getHeapView(),t=new this.ArrayConstructor(new ArrayBuffer(this.size*e.BYTES_PER_ELEMENT),0,this.size);return t.set(e),t}}class W extends K{ArrayConstructor=Int32Array;constructor(e){super(e??new s.Module.IntArray)}getHeap(){return s.Module.HEAP32}static fromRaw(e){return new W(e)}}class z extends K{ArrayConstructor=Uint32Array;constructor(e){super(e??new s.Module.UnsignedIntArray)}getHeap(){return s.Module.HEAPU32}static fromRaw(e){return new z(e)}}class Y extends K{ArrayConstructor=Uint8Array;constructor(e){super(e??new s.Module.UnsignedCharArray)}getHeap(){return s.Module.HEAPU8}static fromRaw(e){return new Y(e)}}class k extends K{ArrayConstructor=Float32Array;constructor(e){super(e??new s.Module.FloatArray)}getHeap(){return s.Module.HEAPF32}static fromRaw(e){return new k(e)}}const ue=k,ce=W,Z=Y,je=W,m={toRaw:({x:a,y:e,z:t},r)=>r?(r.x=a,r.y=e,r.z=t,r):new s.Module.Vec3(a,e,t),fromRaw:a=>{const{x:e,y:t,z:r}=a;return{x:e,y:t,z:r}},fromArray:([a,e,t])=>({x:a,y:e,z:t}),toArray:({x:a,y:e,z:t})=>[a,e,t],lerp:(a,e,t,r={x:0,y:0,z:0})=>{r.x=a.x+(e.x-a.x)*t,r.y=a.y+(e.y-a.y)*t,r.z=a.z+(e.z-a.z)*t},copy:(a,e={x:0,y:0,z:0})=>{e.x=a.x,e.y=a.y,e.z=a.z}},v=(a,e)=>{const t=[];for(let r=0;r<e;r++)t.push(a(r));return t},L=a=>s.Detour.statusSucceed(a),Ze=a=>s.Detour.statusFailed(a),Je=a=>{if(s.Detour.statusSucceed(a))return"success";if(s.Detour.statusInProgress(a))return"in progress";if(s.Detour.statusFailed(a)){let e;const t={DT_WRONG_MAGIC:f.DT_WRONG_MAGIC,DT_WRONG_VERSION:f.DT_WRONG_VERSION,DT_OUT_OF_MEMORY:f.DT_OUT_OF_MEMORY,DT_INVALID_PARAM:f.DT_INVALID_PARAM,DT_BUFFER_TOO_SMALL:f.DT_BUFFER_TOO_SMALL,DT_OUT_OF_NODES:f.DT_OUT_OF_NODES,DT_PARTIAL_RESULT:f.DT_PARTIAL_RESULT,DT_ALREADY_OCCUPIED:f.DT_ALREADY_OCCUPIED};for(const[r,i]of Object.entries(t))if(s.Detour.statusDetail(a,i)){e=r;break}return e?`failed - ${e}`:"failed - unknown"}return"unknown"};class et{constructor(e){this.raw=e}vertBase(){return this.raw.vertBase}triBase(){return this.raw.triBase}vertCount(){return this.raw.vertCount}triCount(){return this.raw.triCount}}class tt{constructor(e){this.raw=e}ref(){return this.raw.ref}next(){return this.raw.next}edge(){return this.raw.edge}side(){return this.raw.side}bmin(){return this.raw.bmin}bmax(){return this.raw.bmax}}class rt{constructor(e){this.raw=e}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}i(){return this.raw.i}}class he{constructor(e){this.raw=e}pos(e){return this.raw.get_pos(e)}rad(){return this.raw.rad}poly(){return this.raw.poly}flags(){return this.raw.flags}side(){return this.raw.side}userId(){return this.raw.userId}}class st{constructor(e){this.raw=e}magic(){return this.raw.magic}version(){return this.raw.version}x(){return this.raw.x}y(){return this.raw.y}layer(){return this.raw.layer}userId(){return this.raw.userId}polyCount(){return this.raw.polyCount}vertCount(){return this.raw.vertCount}maxLinkCount(){return this.raw.maxLinkCount}detailMeshCount(){return this.raw.detailMeshCount}detailVertCount(){return this.raw.detailVertCount}detailTriCount(){return this.raw.detailTriCount}bvNodeCount(){return this.raw.bvNodeCount}offMeshConCount(){return this.raw.offMeshConCount}offMeshBase(){return this.raw.offMeshBase}walkableHeight(){return this.raw.walkableHeight}walkableRadius(){return this.raw.walkableRadius}walkableClimb(){return this.raw.walkableClimb}bmin(e){return this.raw.get_bmin(e)}bmax(e){return this.raw.get_bmax(e)}bvQuantFactor(){return this.raw.bvQuantFactor}}class J{constructor(e){this.raw=e}firstLink(){return this.raw.firstLink}verts(e){return this.raw.get_verts(e)}neis(e){return this.raw.get_neis(e)}flags(){return this.raw.flags}vertCount(){return this.raw.vertCount}areaAndType(){return this.raw.get_areaAndtype()}getType(){return this.raw.getType()}}class B{constructor(e){this.raw=e}salt(){return this.raw.salt}linksFreeList(){return this.raw.linksFreeList}header(){return s.isNull(this.raw.header)?null:new st(this.raw.header)}polys(e){return new J(this.raw.get_polys(e))}verts(e){return this.raw.get_verts(e)}links(e){return new tt(this.raw.get_links(e))}detailMeshes(e){return new et(this.raw.get_detailMeshes(e))}detailVerts(e){return this.raw.get_detailVerts(e)}detailTris(e){return this.raw.get_detailTris(e)}bvTree(e){return new rt(this.raw.get_bvTree(e))}offMeshCons(e){return new he(this.raw.get_offMeshCons(e))}data(e){return this.raw.get_data(e)}dataSize(){return this.raw.dataSize}flags(){return this.raw.flags}next(){return new B(this.raw.next)}}const de=a=>{const e=s.DetourNavMeshBuilder.createNavMeshData(a.raw);return{success:e.success,navMeshData:Y.fromRaw(e.navMeshData)}};class we{constructor(e){this.raw=e??new s.Module.dtNavMeshCreateParams}setPolyMeshCreateParams(e){s.DetourNavMeshBuilder.setPolyMeshCreateParams(this.raw,e.raw)}setPolyMeshDetailCreateParams(e){s.DetourNavMeshBuilder.setPolyMeshDetailCreateParams(this.raw,e.raw)}setOffMeshConnections(e){if(e.length<=0)return;const t=[],r=[],i=[],o=[],l=[],n=[];for(let u=0;u<e.length;u++){const d=e[u];t.push(d.startPosition.x,d.startPosition.y,d.startPosition.z),t.push(d.endPosition.x,d.endPosition.y,d.endPosition.z),r.push(d.radius),i.push(d.bidirectional?1:0),o.push(d.area??0),l.push(d.flags??1),n.push(d.userId??1e3+u)}s.DetourNavMeshBuilder.setOffMeshConnections(this.raw,e.length,t,r,i,o,l,n)}verts(e){return this.raw.get_verts(e)}setVerts(e,t){this.raw.set_verts(e,t)}vertCount(){return this.raw.vertCount}polys(e){return this.raw.get_polys(e)}setPolys(e,t){this.raw.set_polys(e,t)}polyAreas(e){return this.raw.get_polyAreas(e)}setPolyAreas(e,t){this.raw.set_polyAreas(e,t)}polyFlags(e){return this.raw.get_polyFlags(e)}setPolyFlags(e,t){this.raw.set_polyFlags(e,t)}polyCount(){return this.raw.polyCount}nvp(){return this.raw.nvp}setNvp(e){this.raw.nvp=e}detailMeshes(e){return this.raw.get_detailMeshes(e)}setDetailMeshes(e,t){this.raw.set_detailMeshes(e,t)}detailVerts(e){return this.raw.get_detailVerts(e)}setDetailVerts(e,t){this.raw.set_detailVerts(e,t)}detailVertsCount(){return this.raw.detailVertsCount}detailTris(e){return this.raw.get_detailTris(e)}setDetailTris(e,t){this.raw.set_detailTris(e,t)}detailTriCount(){return this.raw.detailTriCount}offMeshConVerts(e){return this.raw.get_offMeshConVerts(e)}offMeshConRad(e){return this.raw.get_offMeshConRad(e)}offMeshConDir(e){return this.raw.get_offMeshConDir(e)}offMeshConAreas(e){return this.raw.get_offMeshConAreas(e)}offMeshConFlags(e){return this.raw.get_offMeshConFlags(e)}offMeshConUserID(e){return this.raw.get_offMeshConUserID(e)}offMeshConCount(){return this.raw.offMeshConCount}userId(){return this.raw.userId}tileX(){return this.raw.tileX}setTileX(e){this.raw.tileX=e}tileY(){return this.raw.tileY}setTileY(e){this.raw.tileY=e}tileLayer(){return this.raw.tileLayer}setTileLayer(e){this.raw.tileLayer=e}boundsMin(){return v(e=>this.raw.get_bmin(e),3)}setBoundsMin(e){this.raw.set_bmin(0,e[0]),this.raw.set_bmin(1,e[1]),this.raw.set_bmin(2,e[2])}boundsMax(){return v(e=>this.raw.get_bmax(e),3)}setBoundsMax(e){this.raw.set_bmax(0,e[0]),this.raw.set_bmax(1,e[1]),this.raw.set_bmax(2,e[2])}walkableHeight(){return this.raw.walkableHeight}setWalkableHeight(e){this.raw.walkableHeight=e}walkableRadius(){return this.raw.walkableRadius}setWalkableRadius(e){this.raw.walkableRadius=e}walkableClimb(){return this.raw.walkableClimb}setWalkableClimb(e){this.raw.walkableClimb=e}cellSize(){return this.raw.cs}setCellSize(e){this.raw.cs=e}cellHeight(){return this.raw.ch}setCellHeight(e){this.raw.ch=e}buildBvTree(){return this.raw.buildBvTree}setBuildBvTree(e){this.raw.buildBvTree=e}}class ge{get includeFlags(){return this.raw.getIncludeFlags()}set includeFlags(e){this.raw.setIncludeFlags(e)}get excludeFlags(){return this.raw.getExcludeFlags()}set excludeFlags(e){this.raw.setExcludeFlags(e)}constructor(e){this.raw=e??new s.Module.dtQueryFilter}getAreaCost(e){return this.raw.getAreaCost(e)}setAreaCost(e,t){this.raw.setAreaCost(e,t)}}class ee{defaultQueryHalfExtents={x:1,y:1,z:1};constructor(e,t){e instanceof s.Module.NavMeshQuery?this.raw=e:(this.raw=new s.Module.NavMeshQuery,this.raw.init(e.raw,t?.maxNodes??2048)),t?.defaultQueryFilter?this.defaultFilter=t.defaultQueryFilter:(this.defaultFilter=new ge,this.defaultFilter.includeFlags=65535,this.defaultFilter.excludeFlags=0)}findNearestPoly(e,t){const r=new s.UnsignedIntRef,i=new s.Vec3,o=new s.BoolRef,l=this.raw.findNearestPoly(m.toArray(e),m.toArray(t?.halfExtents??this.defaultQueryHalfExtents),t?.filter?.raw??this.defaultFilter.raw,r,i,o),n=m.fromRaw(i);s.destroy(i);const u=r.value;s.destroy(r);const d=o.value;return s.destroy(o),{success:L(l),status:l,nearestRef:u,nearestPoint:n,isOverPoly:d}}findPolysAroundCircle(e,t,r,i){const o=i?.filter??this.defaultFilter,l=i?.maxPolys??256,n=new z,u=new z,d=new k;n.resize(l),u.resize(l),d.resize(l);const _=new s.IntRef,c=this.raw.findPolysAroundCircle(e,m.toArray(t),r,o.raw,n.raw,u.raw,d.raw,_,l),y=[...n.getHeapView()];n.destroy();const M=[...u.getHeapView()];u.destroy();const p=[...d.getHeapView()];d.destroy();const C=_.value;return s.destroy(_),{success:L(c),status:c,resultRefs:y,resultParents:M,resultCost:p,resultCount:C}}queryPolygons(e,t,r){const i=r?.filter??this.defaultFilter,o=r?.maxPolys??256,l=new z;l.resize(o);const n=new s.IntRef,u=this.raw.queryPolygons(m.toArray(e),m.toArray(t),i.raw,l.raw,n,o),d=n.value;s.destroy(n);const _=[...l.getHeapView()].slice(0,d);return l.destroy(),{success:L(u),status:u,polyRefs:_}}closestPointOnPoly(e,t){const r=new s.Vec3,i=new s.BoolRef,o=this.raw.closestPointOnPoly(e,m.toArray(t),r,i),l=m.fromRaw(r);s.destroy(r);const n=i.value;return s.destroy(i),{success:L(o),status:o,closestPoint:l,isPointOverPoly:n}}findClosestPoint(e,t){const r=t?.filter??this.defaultFilter,i=t?.halfExtents??this.defaultQueryHalfExtents,o=new s.UnsignedIntRef,l=new s.Vec3,n=new s.BoolRef,u=this.raw.findClosestPoint(m.toArray(e),m.toArray(i),r.raw,o,l,n),d=o.value;s.destroy(o);const _=m.fromRaw(l);s.destroy(l);const c=n.value;return s.destroy(n),{success:L(u),status:u,polyRef:d,point:_,isPointOverPoly:c}}findRandomPointAroundCircle(e,t,r){const i=r?.filter??this.defaultFilter,o=r?.halfExtents??this.defaultQueryHalfExtents;let l;if(r?.startRef)l=r.startRef;else{const y=this.findNearestPoly(e,{filter:i,halfExtents:o});if(!y.success)return{success:!1,status:y.status,randomPolyRef:0,randomPoint:{x:0,y:0,z:0}};l=y.nearestRef}const n=new s.UnsignedIntRef,u=new s.Vec3,d=this.raw.findRandomPointAroundCircle(l,m.toArray(e),t,i.raw,n,u),_=n.value;s.destroy(n);const c=m.fromRaw(u);return s.destroy(u),{success:L(d),status:d,randomPolyRef:_,randomPoint:c}}moveAlongSurface(e,t,r,i){const o=i?.maxVisitedSize??256,l=new s.Vec3,n=new z,u=i?.filter?.raw??this.defaultFilter.raw,d=this.raw.moveAlongSurface(e,m.toArray(t),m.toArray(r),u,l,n.raw,o),_=m.fromRaw(l);s.destroy(l);const c=[...n.getHeapView()];return n.destroy(),{success:L(d),status:d,resultPosition:_,visited:c}}findRandomPoint(e){const t=new s.UnsignedIntRef,r=new s.Vec3,i=this.raw.findRandomPoint(e?.filter?.raw??this.defaultFilter.raw,t,r),o=t.value;s.destroy(t);const l=m.fromRaw(r);return s.destroy(r),{success:L(i),status:i,randomPolyRef:o,randomPoint:l}}getPolyHeight(e,t){const r=new s.FloatRef,i=this.raw.getPolyHeight(e,m.toArray(t),r),o=r.value;return s.destroy(r),{success:L(i),status:i,height:o}}computePath(e,t,r){const i=r?.filter??this.defaultFilter,o=r?.halfExtents??this.defaultQueryHalfExtents,l=this.findNearestPoly(e,{filter:i,halfExtents:o});if(!l.success)return{success:!1,error:{name:"findNearestPoly for start position failed",status:l.status},path:[]};const n=this.findNearestPoly(t,{filter:i,halfExtents:o});if(!n.success)return{success:!1,error:{name:"findNearestPoly for end position failed",status:n.status},path:[]};const u=l.nearestRef,d=n.nearestRef,_=r?.maxPathPolys??256,c=this.findPath(u,d,e,t,{filter:i,maxPathPolys:_});if(!c.success)return{success:!1,error:{name:"findPath unsuccessful",status:c.status},path:[]};if(c.polys.size<=0)return{success:!1,error:{name:"no polygon path found"},path:[]};const y=c.polys.get(c.polys.size-1);let M={x:t.x,y:t.y,z:t.z};if(y!==d){const A=this.closestPointOnPoly(y,t);if(!A.success)return{success:!1,error:{name:"no closest point on last polygon found",status:A.status},path:[]};M=A.closestPoint}const p=r?.maxStraightPathPoints,C=this.findStraightPath(e,M,c.polys,{maxStraightPathPoints:p});if(!C.success)return{success:!1,error:{name:"findStraightPath unsuccessful",status:C.status},path:[]};const{straightPath:I,straightPathCount:w}=C,P=[];for(let A=0;A<w;A++)P.push({x:I.get(A*3),y:I.get(A*3+1),z:I.get(A*3+2)});return c.polys.destroy(),C.straightPath.destroy(),C.straightPathFlags.destroy(),C.straightPathRefs.destroy(),{success:!0,path:P}}findPath(e,t,r,i,o){const l=o?.filter??this.defaultFilter,n=o?.maxPathPolys??256,u=new z;u.resize(n);const d=this.raw.findPath(e,t,m.toArray(r),m.toArray(i),l.raw,u.raw,n);return{success:L(d),status:d,polys:u}}findStraightPath(e,t,r,i){const o=i?.maxStraightPathPoints??256,l=i?.straightPathOptions??0;let n;Array.isArray(r)?(n=new z,n.copy(r)):n=r;const u=new k;u.resize(o*3);const d=new Y;d.resize(o);const _=new z;_.resize(o);const c=new s.IntRef,y=this.raw.findStraightPath(m.toArray(e),m.toArray(t),n.raw,u.raw,d.raw,_.raw,c,o,l),M=c.value;return s.destroy(c),Array.isArray(r)&&n.destroy(),{success:L(y),status:y,straightPath:u,straightPathFlags:d,straightPathRefs:_,straightPathCount:M}}raycast(e,t,r,i){const o=new s.Module.dtRaycastHit,l=i?.raycastOptions??0,n=i?.prevRef??0,u=i?.filter?.raw??this.defaultFilter.raw,d=this.raw.raycast(e,m.toArray(t),m.toArray(r),u,l,o,n),_={success:L(d),status:d,t:o.t,hitNormal:m.fromArray(v(c=>o.get_hitNormal(c),3)),hitEdgeIndex:o.hitEdgeIndex,path:v(c=>o.get_path(c),o.pathCount),maxPath:o.maxPath,pathCost:o.pathCost};return s.destroy(o),_}destroy(){this.raw.destroy()}}const _e={radius:.5,height:1,maxAcceleration:20,maxSpeed:6,collisionQueryRange:2.5,pathOptimizationRange:0,separationWeight:0,updateFlags:7,obstacleAvoidanceType:0,queryFilterType:0,userData:0};class at{get radius(){return this.raw.params.radius}set radius(e){this.raw.params.radius=e}get height(){return this.raw.params.height}set height(e){this.raw.params.height=e}get maxAcceleration(){return this.raw.params.maxAcceleration}set maxAcceleration(e){this.raw.params.maxAcceleration=e}get maxSpeed(){return this.raw.params.maxSpeed}set maxSpeed(e){this.raw.params.maxSpeed=e}get collisionQueryRange(){return this.raw.params.collisionQueryRange}set collisionQueryRange(e){this.raw.params.collisionQueryRange=e}get pathOptimizationRange(){return this.raw.params.pathOptimizationRange}set pathOptimizationRange(e){this.raw.params.pathOptimizationRange=e}get separationWeight(){return this.raw.params.separationWeight}set separationWeight(e){this.raw.params.separationWeight=e}get updateFlags(){return this.raw.params.updateFlags}set updateFlags(e){this.raw.params.updateFlags=e}get obstacleAvoidanceType(){return this.raw.params.obstacleAvoidanceType}set obstacleAvoidanceType(e){this.raw.params.obstacleAvoidanceType=e}get queryFilterType(){return this.raw.params.queryFilterType}set queryFilterType(e){this.raw.params.queryFilterType=e}get userData(){return this.raw.params.userData}set userData(e){this.raw.params.userData=e}interpolatedPosition={x:0,y:0,z:0};constructor(e,t){this.crowd=e,this.agentIndex=t,this.raw=e.raw.getEditableAgent(t),this.interpolatedPosition=this.position()}requestMoveTarget(e){const{nearestPoint:t,nearestRef:r}=this.crowd.navMeshQuery.findNearestPoly(e,{halfExtents:this.crowd.navMeshQuery.defaultQueryHalfExtents,filter:this.crowd.navMeshQuery.defaultFilter});return this.crowd.raw.requestMoveTarget(this.agentIndex,r,m.toArray(t))}requestMoveVelocity(e){return this.crowd.raw.requestMoveVelocity(this.agentIndex,m.toArray(e))}resetMoveTarget(){this.crowd.raw.resetMoveTarget(this.agentIndex)}teleport(e){s.CrowdUtils.agentTeleport(this.crowd.raw,this.agentIndex,m.toArray(e),m.toArray(this.crowd.navMeshQuery.defaultQueryHalfExtents),this.crowd.navMeshQuery.defaultFilter.raw),m.copy(e,this.interpolatedPosition)}position(){return{x:this.raw.get_npos(0),y:this.raw.get_npos(1),z:this.raw.get_npos(2)}}velocity(){return{x:this.raw.get_vel(0),y:this.raw.get_vel(1),z:this.raw.get_vel(2)}}desiredVelocity(){return{x:this.raw.get_dvel(0),y:this.raw.get_dvel(1),z:this.raw.get_dvel(2)}}desiredVelocityObstacleAdjusted(){return{x:this.raw.get_nvel(0),y:this.raw.get_nvel(1),z:this.raw.get_nvel(2)}}state(){return this.raw.state}target(){return{x:this.raw.get_targetPos(0),y:this.raw.get_targetPos(1),z:this.raw.get_targetPos(2)}}nextTargetInPath(){return{x:this.raw.get_cornerVerts(0),y:this.raw.get_cornerVerts(1),z:this.raw.get_cornerVerts(2)}}corners(){const e=[];for(let t=0;t<this.raw.ncorners;t++)e.push({x:this.raw.get_cornerVerts(t*3),y:this.raw.get_cornerVerts(t*3+1),z:this.raw.get_cornerVerts(t*3+2)});return e}parameters(){const{params:e}=this.raw;return{radius:e.radius,height:e.height,maxAcceleration:e.maxAcceleration,maxSpeed:e.maxSpeed,collisionQueryRange:e.collisionQueryRange,pathOptimizationRange:e.pathOptimizationRange,separationWeight:e.separationWeight,updateFlags:e.updateFlags,obstacleAvoidanceType:e.obstacleAvoidanceType,queryFilterType:e.queryFilterType,userData:e.userData}}updateParameters(e){const t={...this.parameters(),...e};this.setParameters(t)}setParameters(e){const t={..._e,...e},r=new s.Module.dtCrowdAgentParams;r.radius=t.radius,r.height=t.height,r.maxAcceleration=t.maxAcceleration,r.maxSpeed=t.maxSpeed,r.collisionQueryRange=t.collisionQueryRange,r.pathOptimizationRange=t.pathOptimizationRange,r.separationWeight=t.separationWeight,r.updateFlags=t.updateFlags,r.obstacleAvoidanceType=t.obstacleAvoidanceType,r.queryFilterType=t.queryFilterType,r.userData=t.userData,this.crowd.raw.updateAgentParameters(this.agentIndex,r)}overOffMeshConnection(){return s.CrowdUtils.overOffMeshConnection(this.crowd.raw,this.agentIndex)}}class it{agents={};accumulator=0;constructor(e,{maxAgents:t,maxAgentRadius:r}){this.navMesh=e,this.raw=s.Detour.allocCrowd(),this.raw.init(t,r,e.raw.getNavMesh()),this.navMeshQuery=new ee(new s.Module.NavMeshQuery(this.raw.getNavMeshQuery()))}update(e,t,r=10){if(t===void 0)this.raw.update(e,void 0);else{this.accumulator+=t;let i=0;for(;this.accumulator>=e&&i<r;)this.raw.update(e,void 0),this.accumulator-=e,i++;const o=this.accumulator%e/e,l=this.getAgents();for(const n of l)m.lerp(n.interpolatedPosition,n.position(),o,n.interpolatedPosition)}}addAgent(e,t){const r={..._e,...t},i=new s.Module.dtCrowdAgentParams;i.radius=r.radius,i.height=r.height,i.maxAcceleration=r.maxAcceleration,i.maxSpeed=r.maxSpeed,i.collisionQueryRange=r.collisionQueryRange,i.pathOptimizationRange=r.pathOptimizationRange,i.separationWeight=r.separationWeight,i.updateFlags=r.updateFlags,i.obstacleAvoidanceType=r.obstacleAvoidanceType,i.queryFilterType=r.queryFilterType,i.userData=r.userData;const o=this.raw.addAgent(m.toArray(e),i),l=new at(this,o);return this.agents[o]=l,l}getAgent(e){const t=this.agents[e];return t||null}removeAgent(e){const t=typeof e=="number"?e:e.agentIndex;this.raw.removeAgent(t),delete this.agents[t]}getAgentCount(){return this.raw.getAgentCount()}getActiveAgentCount(){return s.CrowdUtils.getActiveAgentCount(this.raw)}getAgents(){return Object.values(this.agents)}getFilter(e){return new ge(this.raw.getEditableFilter(e))}destroy(){s.Detour.freeCrowd(this.raw)}}class nt{constructor(e){this.raw=e}tiles(e){return new B(this.raw.get_tiles(e))}tileCount(){return this.raw.tileCount}}class ot{constructor(e){this.raw=e}data(){return v(e=>this.raw.get_data(e),this.raw.dataSize)}dataSize(){return this.raw.dataSize}}class lt{constructor(e){this.raw=e}tileX(){return this.raw.tileX}tileY(){return this.raw.tileY}}class ut{constructor(e){this.raw=e}data(){return v(e=>this.raw.get_data(e),this.raw.dataSize)}dataSize(){return this.raw.dataSize}}class Q{constructor(e){this.raw=e}static create(e){const t=new s.Module.dtNavMeshParams;return t.set_orig(0,e.orig.x),t.set_orig(1,e.orig.y),t.set_orig(2,e.orig.z),t.tileWidth=e.tileWidth,t.tileHeight=e.tileHeight,t.maxTiles=e.maxTiles,t.maxPolys=e.maxPolys,new Q(t)}clone(){return Q.create({orig:{x:this.raw.get_orig(0),y:this.raw.get_orig(1),z:this.raw.get_orig(2)},tileWidth:this.raw.tileWidth,tileHeight:this.raw.tileHeight,maxTiles:this.raw.maxTiles,maxPolys:this.raw.maxPolys})}}class te{constructor(e){this.raw=e??new s.Module.NavMesh}initSolo(e){return this.raw.initSolo(e.raw)}initTiled(e){return this.raw.initTiled(e.raw)}addTile(e,t,r){const i=new s.UnsignedIntRef,o=this.raw.addTile(e.raw,t,r,i),l=i.value;return s.destroy(i),{status:o,tileRef:l}}decodePolyId(e){const t=new s.UnsignedIntRef,r=new s.UnsignedIntRef,i=new s.UnsignedIntRef;this.raw.decodePolyId(e,t,r,i);const o=t.value;s.destroy(t);const l=r.value;s.destroy(r);const n=i.value;return s.destroy(i),{tileSalt:o,tileIndex:l,tilePolygonIndex:n}}encodePolyId(e,t,r){return this.raw.encodePolyId(e,t,r)}removeTile(e){return new ot(this.raw.removeTile(e))}calcTileLoc(e){return new lt(this.raw.calcTileLoc(m.toArray(e)))}getTileAt(e,t,r){const i=this.raw.getTileAt(e,t,r);return s.isNull(i)?null:new B(i)}getTilesAt(e,t,r){return new nt(this.raw.getTilesAt(e,t,r))}getTileRefAt(e,t,r){return this.raw.getTileRefAt(e,t,r)}getTileRef(e){return this.raw.getTileRef(e.raw)}getTileByRef(e){const t=this.raw.getTileByRef(e);return s.isNull(t)?null:new B(t)}getMaxTiles(){return this.raw.getMaxTiles()}getTile(e){return new B(this.raw.getTile(e))}getTileAndPolyByRef(e){const t=this.raw.getTileAndPolyByRef(e),r=new B(t.tile),i=new J(t.poly);return{success:L(t.status),status:t.status,tile:r,poly:i}}getTileAndPolyByRefUnsafe(e){const t=this.raw.getTileAndPolyByRef(e),r=new B(t.tile),i=new J(t.poly);return{tile:r,poly:i}}isValidPolyRef(e){return this.raw.isValidPolyRef(e)}getPolyRefBase(e){return this.raw.getPolyRefBase(e.raw)}getOffMeshConnectionPolyEndPoints(e,t){const r=new s.Vec3,i=new s.Vec3,o=this.raw.getOffMeshConnectionPolyEndPoints(e,t,r,i),l=m.fromRaw(r);s.destroy(r);const n=m.fromRaw(i);return s.destroy(i),{success:L(o),status:o,start:l,end:n}}getOffMeshConnectionByRef(e){return new he(this.raw.getOffMeshConnectionByRef(e))}setPolyFlags(e,t){return this.raw.setPolyFlags(e,t)}getPolyFlags(e){const t=new s.UnsignedShortRef,r=this.raw.getPolyFlags(e,t),i=t.value;return s.destroy(t),{status:r,flags:i}}setPolyArea(e,t){return this.raw.setPolyArea(e,t)}getPolyArea(e){const t=new s.UnsignedCharRef,r=this.raw.getPolyArea(e,t),i=t.value;return s.destroy(t),{status:r,area:i}}getTileStateSize(e){return this.raw.getTileStateSize(e.raw)}storeTileState(e,t){return new ut(this.raw.storeTileState(e.raw,t))}restoreTileState(e,t,r){return this.raw.restoreTileState(e.raw,t,r)}destroy(){this.raw.destroy(),s.Module.destroy(this.raw)}}const ct=(a,e)=>{const t=[],r=[];let i=0;const o=a.getMaxTiles();for(let l=0;l<o;l++){const n=a.getTile(l),u=n.header();if(!u)continue;const d=u.polyCount();for(let _=0;_<d;++_){const c=n.polys(_);if(c.getType()===1)continue;const y=c.vertCount(),M=n.detailMeshes(_),p=M.triBase(),C=M.triCount();for(let I=0;I<C;++I){const w=(p+I)*4;for(let P=0;P<3;++P){if(n.detailTris(w+P)<y){const A=c.verts(n.detailTris(w+P))*3;t.push(n.verts(A),n.verts(A+1),n.verts(A+2))}else{const A=(M.vertBase()+n.detailTris(w+P)-c.vertCount())*3;t.push(n.detailVerts(A),n.detailVerts(A+1),n.detailVerts(A+2))}r.push(i++)}}}}return[t,r]},re={borderSize:0,tileSize:0,cs:.2,ch:.2,walkableSlopeAngle:60,walkableHeight:2,walkableClimb:2,walkableRadius:.5,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1},fe=a=>{const e={...re,...a},t=new s.Module.rcConfig;return t.borderSize=e.borderSize,t.tileSize=e.tileSize,t.cs=e.cs,t.ch=e.ch,t.walkableSlopeAngle=e.walkableSlopeAngle,t.walkableHeight=e.walkableHeight,t.walkableClimb=e.walkableClimb,t.walkableRadius=e.walkableRadius,t.maxEdgeLen=e.maxEdgeLen,t.maxSimplificationError=e.maxSimplificationError,t.minRegionArea=e.minRegionArea,t.mergeRegionArea=e.mergeRegionArea,t.maxVertsPerPoly=e.maxVertsPerPoly,t.detailSampleDist=e.detailSampleDist,t.detailSampleMaxError=e.detailSampleMaxError,t},ht=a=>{const e=new s.Module.rcConfig;return e.set_bmin(0,a.get_bmin(0)),e.set_bmin(1,a.get_bmin(1)),e.set_bmin(2,a.get_bmin(2)),e.set_bmax(0,a.get_bmax(0)),e.set_bmax(1,a.get_bmax(1)),e.set_bmax(2,a.get_bmax(2)),e.width=a.width,e.height=a.height,e.borderSize=a.borderSize,e.tileSize=a.tileSize,e.cs=a.cs,e.ch=a.ch,e.walkableSlopeAngle=a.walkableSlopeAngle,e.walkableHeight=a.walkableHeight,e.walkableClimb=a.walkableClimb,e.walkableRadius=a.walkableRadius,e.maxEdgeLen=a.maxEdgeLen,e.maxSimplificationError=a.maxSimplificationError,e.minRegionArea=a.minRegionArea,e.mergeRegionArea=a.mergeRegionArea,e.maxVertsPerPoly=a.maxVertsPerPoly,e.detailSampleDist=a.detailSampleDist,e.detailSampleMaxError=a.detailSampleMaxError,e};class se{logs=[];startTimes={};accumulatedTimes={};constructor(e=!0){const t=new s.Module.RecastBuildContextJsImpl;t.log=(r,i,o)=>{if(!this.raw.logEnabled())return;const l=i,n=new Uint8Array(s.Module.HEAPU8.buffer,l,o),u=new Uint8Array(o);u.set(n);const d=new TextDecoder().decode(u);this.log(r,d)},t.resetLog=()=>{this.resetLog()},t.startTimer=r=>{this.raw.timerEnabled()&&this.startTimer(r)},t.stopTimer=r=>{this.raw.timerEnabled()&&this.stopTimer(r)},t.getAccumulatedTime=r=>this.raw.timerEnabled()?this.getAccumulatedTime(r):-1,t.resetTimers=()=>{this.raw.timerEnabled()&&(this.startTimes={},this.accumulatedTimes={})},this.raw=new s.Module.RecastBuildContext(t),this.raw.enableTimer(e),this.raw.enableLog(e),this.resetTimers()}log(e,t){this.logs.push({category:e,msg:t})}resetLog(){this.logs=[]}startTimer(e){this.startTimes[e]=performance.now()}stopTimer(e){const r=performance.now()-this.startTimes[e];this.accumulatedTimes[e]===-1?this.accumulatedTimes[e]=r:this.accumulatedTimes[e]+=r}getAccumulatedTime(e){return this.accumulatedTimes[e]}resetTimers(){for(let e=0;e<g.RC_MAX_TIMERS;e++)this.startTimes[e]=-1,this.accumulatedTimes[e]=-1}}class dt{constructor(e){this.raw=e??new s.rcChunkyTriMesh}init(e,t,r,i){return s.ChunkyTriMeshUtils.createChunkyTriMesh(e.raw,t.raw,r,i,this.raw)}getChunksOverlappingRect(e,t,r,i){return s.ChunkyTriMeshUtils.getChunksOverlappingRect(this.raw,e,t,r.raw,i)}getNodeTris(e){return W.fromRaw(s.ChunkyTriMeshUtils.getChunkyTriMeshNodeTris(this.raw,e))}nodes(e){return this.raw.get_nodes(e)}maxTrisPerChunk(){return this.raw.maxTrisPerChunk}}class V{constructor(e){this.raw=e}smin(){return this.raw.smin}smax(){return this.raw.smax}area(){return this.raw.area}next(){return s.isNull(this.raw.next)?null:new V(this.raw.next)}}class ae{constructor(e){this.raw=e}next(){return s.isNull(this.raw.next)?null:new ae(this.raw.next)}items(e){return new V(this.raw.get_items(e))}}class wt{constructor(e){this.raw=e}width(){return this.raw.width}height(){return this.raw.height}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}spans(e){return new V(this.raw.get_spans(e))}pools(e){return new ae(this.raw.get_pools(e))}freelist(e){return new V(this.raw.get_freelist(e))}}class gt{constructor(e){this.raw=e}index(){return this.raw.get_index()}count(){return this.raw.get_count()}}class _t{constructor(e){this.raw=e}y(){return this.raw.get_y()}reg(){return this.raw.get_reg()}con(){return this.raw.get_con()}h(){return this.raw.get_h()}}class ft{constructor(e){this.raw=e}width(){return this.raw.width}height(){return this.raw.height}spanCount(){return this.raw.spanCount}walkableHeight(){return this.raw.walkableHeight}walkableClimb(){return this.raw.walkableClimb}borderSize(){return this.raw.borderSize}maxDistance(){return this.raw.maxDistance}maxRegions(){return this.raw.maxRegions}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}cells(e){return new gt(this.raw.get_cells(e))}spans(e){return new _t(this.raw.get_spans(e))}dist(e){return this.raw.get_dist(e)}areas(e){return this.raw.get_areas(e)}}class Rt{constructor(e){this.raw=e}verts(e){return this.raw.get_verts(e)}nverts(){return this.raw.nverts}rverts(e){return this.raw.get_rverts(e)}nrverts(){return this.raw.nrverts}reg(){return this.raw.reg}area(){return this.raw.area}}class Tt{constructor(e){this.raw=e}conts(e){return new Rt(this.raw.get_conts(e))}nconts(){return this.raw.nconts}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}width(){return this.raw.width}height(){return this.raw.height}borderSize(){return this.raw.borderSize}maxError(){return this.raw.maxError}}class mt{constructor(e){this.raw=e}verts(e){return this.raw.get_verts(e)}polys(e){return this.raw.get_polys(e)}regs(e){return this.raw.get_regs(e)}flags(e){return this.raw.get_flags(e)}setFlags(e,t){this.raw.set_flags(e,t)}areas(e){return this.raw.get_areas(e)}setAreas(e,t){this.raw.set_areas(e,t)}nverts(){return this.raw.nverts}npolys(){return this.raw.npolys}maxpolys(){return this.raw.maxpolys}nvp(){return this.raw.nvp}bmin(){return m.fromArray(v(e=>this.raw.get_bmin(e),3))}bmax(){return m.fromArray(v(e=>this.raw.get_bmax(e),3))}cs(){return this.raw.cs}ch(){return this.raw.ch}borderSize(){return this.raw.borderSize}maxEdgeError(){return this.raw.maxEdgeError}}class yt{constructor(e){this.raw=e}meshes(e){return this.raw.get_meshes(e)}verts(e){return this.raw.get_verts(e)}tris(e){return this.raw.get_tris(e)}nmeshes(){return this.raw.nmeshes}nverts(){return this.raw.nverts}ntris(){return this.raw.ntris}}const Re=(a,e,t)=>s.Recast.calcGridSize(a,e,t),Te=(a,e,t,r,i,o,l,n)=>s.Recast.createHeightfield(a.raw,e.raw,t,r,i,o,l,n),me=(a,e,t,r,i,o,l)=>s.Recast.markWalkableTriangles(a.raw,e,t.raw,r,i.raw,o,l.raw),ye=(a,e,t,r,i,o,l,n=1)=>s.Recast.rasterizeTriangles(a.raw,e.raw,t,r.raw,i.raw,o,l.raw,n),Ae=(a,e,t)=>s.Recast.filterLowHangingWalkableObstacles(a.raw,e,t.raw),Me=(a,e,t,r)=>s.Recast.filterLedgeSpans(a.raw,e,t,r.raw),Ee=(a,e,t)=>s.Recast.filterWalkableLowHeightSpans(a.raw,e,t.raw),pe=(a,e,t,r,i)=>s.Recast.buildCompactHeightfield(a.raw,e,t,r.raw,i.raw),Ce=(a,e,t)=>s.Recast.erodeWalkableArea(a.raw,e,t.raw),Se=(a,e)=>s.Recast.buildDistanceField(a.raw,e.raw),Ie=(a,e,t,r,i)=>s.Recast.buildRegions(a.raw,e.raw,t,r,i),De=(a,e,t,r,i,o=g.RC_CONTOUR_TESS_WALL_EDGES)=>s.Recast.buildContours(a.raw,e.raw,t,r,i.raw,o),be=(a,e,t,r)=>s.Recast.buildPolyMesh(a.raw,e.raw,t,r.raw),Pe=(a,e,t,r,i,o)=>s.Recast.buildPolyMeshDetail(a.raw,e.raw,t.raw,r,i,o.raw),xe=()=>new wt(s.Recast.allocHeightfield()),X=a=>s.Recast.freeHeightfield(a.raw),ve=()=>new ft(s.Recast.allocCompactHeightfield()),$=a=>s.Recast.freeCompactHeightfield(a.raw),Ne=()=>new Tt(s.Recast.allocContourSet()),q=a=>s.Recast.freeContourSet(a.raw),Oe=()=>new mt(s.Recast.allocPolyMesh()),Le=a=>s.Recast.freePolyMesh(a.raw),Fe=()=>new yt(s.Recast.allocPolyMeshDetail()),He=a=>s.Recast.freePolyMeshDetail(a.raw),At=(a,e)=>{const t=s.NavMeshExporter.exportNavMesh(a.raw,e?.raw),r=new Uint8Array(s.Module.HEAPU8.buffer,t.dataPointer,t.size),i=new Uint8Array(t.size);return i.set(r),s.NavMeshExporter.freeNavMeshExport(t),i},Mt=a=>At(a),Et=a=>{const e=a.length*a.BYTES_PER_ELEMENT,t=s.Module._malloc(e),r=new Uint8Array(s.Module.HEAPU8.buffer,t,e);r.set(a);const i=new s.Module.NavMeshExport;return i.dataPointer=r.byteOffset,i.size=a.length,{navMeshExport:i,dataHeap:r}},pt=a=>{const{navMeshExport:e,dataHeap:t}=Et(a),r=s.NavMeshImporter.importNavMesh(e,void 0);return s.Module._free(t.byteOffset),{navMesh:new te(r.navMesh)}},ze=(a,e)=>{const t={x:1/0,y:1/0,z:1/0},r={x:-1/0,y:-1/0,z:-1/0};for(let i=0;i<e.length;i++){const o=e[i],l=a[o*3],n=a[o*3+1],u=a[o*3+2];t.x=Math.min(t.x,l),t.y=Math.min(t.y,n),t.z=Math.min(t.z,u),r.x=Math.max(r.x,l),r.y=Math.max(r.y,n),r.z=Math.max(r.z,u)}return{bbMin:m.toArray(t),bbMax:m.toArray(r)}},Ct=a=>{let e=0,t=0;return e=+(a>65535)<<4,a>>=e,t=+(a>255)<<3,a>>=t,e|=t,t=+(a>15)<<2,a>>=t,e|=t,t=+(a>3)<<1,a>>=t,e|=t,e|=a>>1,e},St=a=>(a--,a|=a>>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a++,a),It={...re,buildBvTree:!0},Dt=(a,e,t={},r=!1)=>{const i=new se,o={type:"solo",buildContext:i},l=()=>{r||(o.heightfield&&(X(o.heightfield),o.heightfield=void 0),o.compactHeightfield&&($(o.compactHeightfield),o.compactHeightfield=void 0),o.contourSet&&(q(o.contourSet),o.contourSet=void 0),o.polyMesh&&(Le(o.polyMesh),o.polyMesh=void 0),o.polyMeshDetail&&(He(o.polyMeshDetail),o.polyMeshDetail=void 0))},n=T=>(l(),{navMeshData:void 0,success:!1,intermediates:o,error:T}),u=a,d=e.length,_=new ue;_.copy(u);const c=e,y=e.length/3,M=new ce;M.copy(c);let p,C;if(t.bounds)p=t.bounds[0],C=t.bounds[1];else{const T=ze(a,e);p=T.bbMin,C=T.bbMax}const I={...It,...t},w=fe(I);w.minRegionArea=w.minRegionArea*w.minRegionArea,w.mergeRegionArea=w.mergeRegionArea*w.mergeRegionArea,w.detailSampleDist=w.detailSampleDist<.9?0:w.cs*w.detailSampleDist,w.detailSampleMaxError=w.ch*w.detailSampleMaxError;const P=Re(p,C,w.cs);w.width=P.width,w.height=P.height;const A=xe();if(o.heightfield=A,!Te(i,A,w.width,w.height,p,C,w.cs,w.ch))return n("Could not create heightfield");const E=new Z;if(E.resize(y),me(i,w.walkableSlopeAngle,_,d,M,y,E),!ye(i,_,d,M,E,y,A,w.walkableClimb))return n("Could not rasterize triangles");E.destroy(),_.destroy(),M.destroy(),Ae(i,w.walkableClimb,A),Me(i,w.walkableHeight,w.walkableClimb,A),Ee(i,w.walkableHeight,A);const D=ve();if(o.compactHeightfield=D,!pe(i,w.walkableHeight,w.walkableClimb,A,D))return n("Failed to build compact data");if(r||(X(A),o.heightfield=void 0),!Ce(i,w.walkableRadius,D))return n("Failed to erode walkable area");if(!Se(i,D))return n("Failed to build distance field");if(!Ie(i,D,w.borderSize,w.minRegionArea,w.mergeRegionArea))return n("Failed to build regions");const b=Ne();if(o.contourSet=b,!De(i,D,w.maxSimplificationError,w.maxEdgeLen,b,g.RC_CONTOUR_TESS_WALL_EDGES))return n("Failed to create contours");const S=Oe();if(o.polyMesh=S,!be(i,b,w.maxVertsPerPoly,S))return n("Failed to triangulate contours");const N=Fe();if(o.polyMeshDetail=N,!Pe(i,S,D,w.detailSampleDist,w.detailSampleMaxError,N))return n("Failed to build detail mesh");r||($(D),o.compactHeightfield=void 0,q(b),o.contourSet=void 0);for(let T=0;T<S.npolys();T++)S.areas(T)===g.RC_WALKABLE_AREA&&S.setAreas(T,0),S.areas(T)===0&&S.setFlags(T,1);const h=new we;h.setPolyMeshCreateParams(S),h.setPolyMeshDetailCreateParams(N),h.setWalkableHeight(w.walkableHeight*w.ch),h.setWalkableRadius(w.walkableRadius*w.cs),h.setWalkableClimb(w.walkableClimb*w.ch),h.setCellSize(w.cs),h.setCellHeight(w.ch),h.setBuildBvTree(I.buildBvTree),t.offMeshConnections&&h.setOffMeshConnections(t.offMeshConnections);const R=de(h);return R.success?(l(),{navMeshData:R.navMeshData,success:!0,intermediates:o}):n("Failed to create Detour navmesh data")},bt=(a,e,t={},r=!1)=>{if(!s.Module)throw new Error('"init" must be called before using any recast-navigation-js APIs. See: https://github.com/isaac-mason/recast-navigation-js?tab=readme-ov-file#initialization');const i=Dt(a,e,t,r);if(!i.success)return{navMesh:void 0,success:!1,intermediates:i.intermediates,error:i.error};const{navMeshData:o}=i,l=new te;return l.initSolo(o)?{success:!0,navMesh:l,intermediates:i.intermediates}:(o.destroy(),{navMesh:void 0,success:!1,intermediates:i.intermediates,error:"Failed to initialize solo NavMesh"})},Pt=({recastConfig:a,navMeshBounds:[e,t]})=>{const r=fe(a),i=Re(e,t,r.cs);r.width=i.width,r.height=i.height,r.minRegionArea=r.minRegionArea*r.minRegionArea,r.mergeRegionArea=r.mergeRegionArea*r.mergeRegionArea,r.tileSize=Math.floor(r.tileSize),r.borderSize=r.walkableRadius+3,r.width=r.tileSize+r.borderSize*2,r.height=r.tileSize+r.borderSize*2,r.detailSampleDist=r.detailSampleDist<.9?0:r.cs*r.detailSampleDist,r.detailSampleMaxError=r.ch*r.detailSampleMaxError;const o=Math.floor(r.tileSize),l=Math.floor((i.width+o-1)/o),n=Math.floor((i.height+o-1)/o),u=r.tileSize*r.cs,d=m.fromArray(e);let _=Math.min(Math.floor(Ct(St(l*n))),14);_>14&&(_=14);const c=22-_,y=1<<_,M=1<<c;return{config:r,gridSize:i,tileSize:o,tileWidth:l,tileHeight:n,tcs:u,orig:d,maxTiles:y,maxPolysPerTile:M}},Be={...re,chunkyTriMeshTrisPerChunk:256,buildBvTree:!0},xt=(a,e,t,r,i,o={},l=!1,n=new se)=>{const u={x:i.x,y:i.y},d=()=>{l||(u.compactHeightfield&&($(u.compactHeightfield),u.compactHeightfield=void 0),u.heightfield&&(X(u.heightfield),u.heightfield=void 0),u.contourSet&&(q(u.contourSet),u.contourSet=void 0),u.polyMesh&&(Le(u.polyMesh),u.polyMesh=void 0),u.polyMeshDetail&&(He(u.polyMeshDetail),u.polyMeshDetail=void 0))},_=T=>(n.log(g.RC_LOG_ERROR,T),d(),{success:!1,error:T,intermediates:u}),c=ht(t),y=[...i.bmin],M=[...i.bmax];y[0]-=c.borderSize*c.cs,y[2]-=c.borderSize*c.cs,M[0]+=c.borderSize*c.cs,M[2]+=c.borderSize*c.cs,c.set_bmin(0,y[0]),c.set_bmin(1,y[1]),c.set_bmin(2,y[2]),c.set_bmax(0,M[0]),c.set_bmax(1,M[1]),c.set_bmax(2,M[2]),n.resetTimers(),n.startTimer(g.RC_TIMER_TOTAL),n.log(g.RC_LOG_PROGRESS,`Building tile at x: ${i.x}, y: ${i.y}`),n.log(g.RC_LOG_PROGRESS,` - ${c.width} x ${c.height} cells`),n.log(g.RC_LOG_PROGRESS,` - ${a.size/3/1e3}K verts, ${e.size/3/1e3}K tris`);const p=xe();if(u.heightfield=p,!Te(n,p,c.width,c.height,y,M,c.cs,c.ch))return _("Could not create heightfield");new Z().resize(r.maxTrisPerChunk());const I=[y[0],y[2]],w=[M[0],M[2]],P=512,A=new je;A.resize(P);const E=r.getChunksOverlappingRect(I,w,A,P);if(E===0)return{success:!0,intermediates:u};for(let T=0;T<E;++T){const x=A.get(T),H=r.nodes(x).n,U=r.getNodeTris(x),F=new Z;F.resize(H),me(n,c.walkableSlopeAngle,a,e.size,U,H,F);const G=ye(n,a,e.size,U,F,H,p,c.walkableClimb);if(F.destroy(),!G)return _("Could not rasterize triangles")}Ae(n,c.walkableClimb,p),Me(n,c.walkableHeight,c.walkableClimb,p),Ee(n,c.walkableHeight,p);const D=ve();if(u.compactHeightfield=D,!pe(n,c.walkableHeight,c.walkableClimb,p,D))return _("Could not build compact heightfield");if(l||(X(u.heightfield),u.heightfield=void 0),!Ce(n,c.walkableRadius,D))return _("Could not erode walkable area");if(!Se(n,D))return _("Failed to build distance field");if(!Ie(n,D,c.borderSize,c.minRegionArea,c.mergeRegionArea))return _("Failed to build regions");const b=Ne();if(u.contourSet=b,!De(n,D,c.maxSimplificationError,c.maxEdgeLen,b,g.RC_CONTOUR_TESS_WALL_EDGES))return _("Failed to create contours");const S=Oe();if(u.polyMesh=S,!be(n,b,c.maxVertsPerPoly,S))return _("Failed to triangulate contours");const N=Fe();if(u.polyMeshDetail=N,!Pe(n,S,D,c.detailSampleDist,c.detailSampleMaxError,N))return _("Failed to build detail mesh");l||($(D),u.compactHeightfield=void 0,q(b),u.contourSet=void 0);for(let T=0;T<S.npolys();T++)S.areas(T)===g.RC_WALKABLE_AREA&&S.setAreas(T,0),S.areas(T)===0&&S.setFlags(T,1);const h=new we;h.setPolyMeshCreateParams(S),h.setPolyMeshDetailCreateParams(N),h.setWalkableHeight(c.walkableHeight*c.ch),h.setWalkableRadius(c.walkableRadius*c.cs),h.setWalkableClimb(c.walkableClimb*c.ch),h.setCellSize(c.cs),h.setCellHeight(c.ch),h.setBuildBvTree(o.buildBvTree??Be.buildBvTree),o.offMeshConnections&&h.setOffMeshConnections(o.offMeshConnections),h.setTileX(i.x),h.setTileY(i.y);const R=de(h);return R.success?(n.log(g.RC_LOG_PROGRESS,`>> Polymesh: ${S.nverts()} vertices ${S.npolys()} polygons`),{success:!0,data:R.navMeshData,intermediates:u}):_("Failed to create Detour navmesh data")},vt=(a,e,t={},r=!1)=>{if(!s.Module)throw new Error('"init" must be called before using any recast-navigation-js APIs. See: https://github.com/isaac-mason/recast-navigation-js?tab=readme-ov-file#initialization');const i=new se,o={type:"tiled",buildContext:i,chunkyTriMesh:void 0,tileIntermediates:[]},l=new te,n=a,u=new ue;u.copy(n);const d=e,_=e.length/3,c=new ce;c.copy(d);const y=()=>{u.destroy(),c.destroy(),!r&&o.chunkyTriMesh&&(o.chunkyTriMesh=void 0)},M=x=>(y(),l.destroy(),{success:!1,navMesh:void 0,intermediates:o,error:x}),p={...Be,...t};let C,I;if(t.bounds)C=t.bounds[0],I=t.bounds[1];else{const x=ze(a,e);C=x.bbMin,I=x.bbMax}const{config:w,tileWidth:P,tileHeight:A,tcs:E,orig:D,maxTiles:b,maxPolysPerTile:S}=Pt({recastConfig:p,navMeshBounds:[C,I]}),N=Q.create({orig:D,tileWidth:p.tileSize*p.cs,tileHeight:p.tileSize*p.cs,maxTiles:b,maxPolys:S});if(!l.initTiled(N))return M("Could not init nav mesh for tiled use");const h=new dt;if(o.chunkyTriMesh=h,!h.init(u,c,_,p.chunkyTriMeshTrisPerChunk))return M("Failed to build chunky triangle mesh");i.startTimer(g.RC_TIMER_TEMP);const R=[0,0,0],T=[0,0,0];for(let x=0;x<A;x++)for(let O=0;O<P;O++){R[0]=C[0]+O*E,R[1]=C[1],R[2]=C[2]+x*E,T[0]=C[0]+(O+1)*E,T[1]=I[1],T[2]=C[2]+(x+1)*E;const H={x:O,y:x,bmin:R,bmax:T},U={offMeshConnections:p.offMeshConnections,buildBvTree:p.buildBvTree},F=xt(u,c,w,h,H,U,r,i);if(o.tileIntermediates.push(F.intermediates),F.success&&F.data){l.removeTile(l.getTileRefAt(O,x,0));const G=l.addTile(F.data,f.DT_TILE_FREE_DATA,0);Ze(G.status)&&(i.log(g.RC_LOG_WARNING,`Failed to add tile to nav mesh tx: ${O}, ty: ${x}, status: ${Je(G.status)} (${G.status})`),F.data.destroy())}}return i.stopTimer(g.RC_TIMER_TEMP),r||y(),{success:!0,navMesh:l,intermediates:o}},Nt=a=>{const e=[],t=[],r={};let i=0;for(const{positions:o,indices:l}of a)for(let n=0;n<l.length;n++){const u=l[n]*3,d=o[u],_=o[u+1],c=o[u+2],y=`${d}_${_}_${c}`;let M=r[y];M||(r[y]=M=i,e.push(d,_,c),i++),t.push(M)}return[Float32Array.from(e),Uint32Array.from(t)]};new Qe;class Ot extends ke{constructor(e,t){super(),this.navMesh=e,this.navMeshGeometry=new Ve,this.navMeshMaterial=t?.navMeshMaterial?t.navMeshMaterial:new We({color:"orange",transparent:!0,opacity:.7,depthWrite:!1}),this.update(),this.mesh=new j(this.navMeshGeometry,this.navMeshMaterial),this.add(this.mesh)}update(){const[e,t]=ct(this.navMesh);this.navMeshGeometry.setAttribute("position",new ie(Float32Array.from(e),3)),this.navMeshGeometry.setIndex(new ie(Uint32Array.from(t),1)),this.navMeshGeometry.computeVertexNormals()}}const Lt=new Ye,Ue=a=>{const e=[];for(const t of a){const r=t.geometry.attributes.position;if(!r||r.itemSize!==3)continue;t.updateMatrixWorld();const i=new Float32Array(r.array);for(let l=0;l<i.length;l+=3){const n=Lt.set(i[l],i[l+1],i[l+2]);t.localToWorld(n),i[l]=n.x,i[l+1]=n.y,i[l+2]=n.z}let o=t.geometry.getIndex()?.array;if(o===void 0){const l=[];for(let n=0;n<r.count;n++)l.push(n);o=l}e.push({positions:i,indices:o})}return Nt(e)},Ft=(a,e={},t=!1)=>{const[r,i]=Ue(a);return bt(r,i,e,t)},Ht=(a,e={},t=!1)=>{const[r,i]=Ue(a);return vt(r,i,e,t)},zt=["invalid","walking","offmesh"];let oe=!1;async function nr(){oe||(await Ke(),oe=!0)}function Bt(a){const e=a.getIndex();if(e===null){const t=a.getAttribute("position").clone();for(let r=0;r+2<t.count;r+=3)for(let i=0;i<t.itemSize;i+=1){const o=t.getComponent(r+1,i);t.setComponent(r+1,i,t.getComponent(r+2,i)),t.setComponent(r+2,i,o)}a.setAttribute("position",t);return}for(let t=0;t+2<e.count;t+=3){const r=e.getX(t+1);e.setX(t+1,e.getX(t+2)),e.setX(t+2,r)}e.needsUpdate=!0}function Ut(a){const e=a.getAttribute("position"),t=a.getIndex(),r=l=>t?.getX(l)??l;let i=0;const o=t?.count??e.count;for(let l=0;l+2<o;l+=3){const n=r(l),u=r(l+1),d=r(l+2),_=e.getX(u)-e.getX(n),c=e.getZ(u)-e.getZ(n),y=e.getX(d)-e.getX(n),M=e.getZ(d)-e.getZ(n);i+=c*y-_*M}return i}function Gt(a){const e=[],t=(l,n)=>{if(n.determinant()<0){const d=l.clone().applyMatrix4(n);return Ut(d)<0&&Bt(d),e.push(d),new j(d)}const u=new j(l);return u.matrixAutoUpdate=!1,u.matrix.copy(n),u.matrixWorldNeedsUpdate=!0,u},r=[],i=new ne,o=new ne;for(const l of a){if(l.updateWorldMatrix(!0,!1),l instanceof Xe){for(let n=0;n<l.count;n+=1)l.getMatrixAt(n,i),o.multiplyMatrices(l.matrixWorld,i),r.push(t(l.geometry,o));continue}r.push(l.matrixWorld.determinant()>=0?l:t(l.geometry,l.matrixWorld))}return{meshes:r,temporaryGeometries:e}}const kt=1297302868,Vt=1,Wt=1145979222,Yt=7;function Qt(a){let e=1;for(;e<a;)e*=2;return e}function Xt(a,e){const t=a.vertices.length,r=a.polygons.length;if(t===0||r===0)throw new Error("NavMeshManager.buildFromPolygons: vertices and polygons must be non-empty");if(t>65535)throw new Error(`NavMeshManager.buildFromPolygons: ${t} vertices exceed Detour's uint16 tile index`);if(a.detailMeshes.length!==r)throw new Error(`NavMeshManager.buildFromPolygons: ${r} polygons require the same number of detail rows`);const i=a.polygons.map(h=>h.vertices.map(()=>0)),o=new Map;let l=0;for(let h=0;h<r;h+=1){const R=a.polygons[h];if(R.vertices.length<3||R.vertices.length>6)throw new Error(`NavMeshManager.buildFromPolygons: polygon ${h} has ${R.vertices.length} vertices; Detour permits 3..6`);l+=R.vertices.length;for(let T=0;T<R.vertices.length;T+=1){const x=R.vertices[T],O=R.vertices[(T+1)%R.vertices.length];if(!Number.isInteger(x)||!Number.isInteger(O)||x<0||O<0||x>=t||O>=t)throw new Error(`NavMeshManager.buildFromPolygons: polygon ${h} references an invalid vertex`);const H=`${x},${O}`;if(o.has(H))throw new Error(`NavMeshManager.buildFromPolygons: directed edge ${H} occurs more than once`);const U=o.get(`${O},${x}`);if(U===void 0)o.set(H,[h,T]);else{const[F,G]=U;i[h][T]=F+1,i[F][G]=h+1}}}for(let h=0;h<r;h+=1){const R=a.detailMeshes[h];if(R.vertexBase<0||R.vertexCount<0||R.vertexBase+R.vertexCount>a.detailVertices.length||R.triangleBase<0||R.triangleCount<0||R.triangleBase+R.triangleCount>a.detailTriangles.length||R.vertexCount>255||R.triangleCount>255)throw new Error(`NavMeshManager.buildFromPolygons: polygon ${h} has an invalid detail row`)}for(const h of a.detailTriangles)if(h.some(R=>!Number.isInteger(R)||R<0||R>255))throw new Error("NavMeshManager.buildFromPolygons: detail triangles must contain uint8 values");const n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],u=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const h of[...a.vertices,...a.detailVertices])for(let R=0;R<3;R+=1){const T=h[R];if(!Number.isFinite(T))throw new Error("NavMeshManager.buildFromPolygons: every vertex component must be finite");n[R]=Math.min(n[R],T),u[R]=Math.max(u[R],T)}const d=100,_=32,c=12,p=d+t*12+r*_+l*c+r*12+a.detailVertices.length*12+a.detailTriangles.length*4,C=new Uint8Array(48+p),I=new DataView(C.buffer);let w=0;const P=h=>{I.setUint8(w,h),w+=1},A=h=>{I.setUint16(w,h,!0),w+=2},E=h=>{I.setUint32(w,h,!0),w+=4},D=h=>{I.setInt32(w,h,!0),w+=4},b=h=>{I.setFloat32(w,h,!0),w+=4},S=Qt(r);E(kt),E(Vt),E(1);for(const h of n)b(h);b(Math.max(u[0]-n[0],Number.EPSILON)),b(Math.max(u[2]-n[2],Number.EPSILON)),E(1),E(S),E(S),E(p),E(Wt),E(Yt),D(0),D(0),D(0),E(0),E(r),E(t),E(l),E(r),E(a.detailVertices.length),E(a.detailTriangles.length),E(0),E(0),E(r);const N=le.navigation;b(e?.walkableHeight??N.walkableHeight),b(e?.walkableRadius??N.walkableRadius),b(e?.walkableClimb??N.walkableClimb);for(const h of n)b(h);for(const h of u)b(h);b(1/(e?.cellSize??N.cellSize));for(const h of a.vertices)for(const R of h)b(R);for(let h=0;h<r;h+=1){const R=a.polygons[h];E(4294967295);for(let T=0;T<6;T+=1)A(R.vertices[T]??0);for(let T=0;T<6;T+=1)A(i[h]?.[T]??0);A(R.flags??1),P(R.vertices.length),P((R.area??0)&63)}w+=l*c;for(const h of a.detailMeshes)E(h.vertexBase),E(h.triangleBase),P(h.vertexCount),P(h.triangleCount),A(0);for(const h of a.detailVertices)for(const R of h)b(R);for(const h of a.detailTriangles)for(const R of h)P(R);if(w!==C.length)throw new Error(`NavMeshManager.buildFromPolygons: encoded ${w} bytes into a ${C.length}-byte allocation`);return C}class or{navMesh=null;query=null;crowd=null;helper=null;buildFromMeshes(e,t){const r=le.navigation,i=Gt(e),o=i.meshes.reduce((u,d)=>{const _=d.geometry.getIndex(),c=d.geometry.getAttribute("position").count;return u+Math.floor((_?.count??c)/3)},0),l={cs:t?.cellSize??r.cellSize,ch:t?.cellHeight??r.cellHeight,walkableSlopeAngle:t?.walkableSlopeAngle??r.walkableSlopeAngle,walkableHeight:t?.walkableHeight??r.walkableHeight,walkableClimb:t?.walkableClimb??r.walkableClimb,walkableRadius:t?.walkableRadius??r.walkableRadius,maxEdgeLen:t?.maxEdgeLen??r.maxEdgeLen,maxSimplificationError:t?.maxSimplificationError??r.maxSimplificationError,minRegionArea:t?.minRegionArea??r.minRegionArea,mergeRegionArea:t?.mergeRegionArea??r.mergeRegionArea,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};let n;try{n=t?.tiled===!0||i.meshes.length>256||o>1e4?Ht(i.meshes,{...l,tileSize:t?.tileSize??256}):Ft(i.meshes,l)}finally{for(const u of i.temporaryGeometries)u.dispose()}return!n.success||!n.navMesh?!1:(this.destroyRecast(),this.navMesh=n.navMesh,this.query=new ee(this.navMesh),!0)}buildFromPolygons(e,t){try{return this.loadFromData(Xt(e,t)),!0}catch{return!1}}destroyRecast(){this.helper&&(this.helper.parent?.remove(this.helper),this.helper.dispose?.(),this.helper=null),this.crowd&&(this.crowd.destroy(),this.crowd=null),this.query&&(this.query.destroy(),this.query=null),this.navMesh&&(this.navMesh.destroy(),this.navMesh=null)}hasNavMesh(){return this.navMesh!==null}findPath(e,t){if(!this.query)throw new Error("NavMeshManager.findPath: no navmesh has been built, so no path can be queried. Build one first (buildFromMeshes/importNavMesh) — gate on hasNavMesh() if the caller can run before a bake.");const r=this.query.computePath(e,t);if(!r.success&&r.error)throw new Error(`NavMeshManager.findPath: recast could not complete the query (${r.error.name}${r.error.status===void 0?"":`, status ${r.error.status}`}).`);return r.path}createCrowd(e){if(!this.navMesh)throw new Error("Build navmesh first");return this.crowd=new it(this.navMesh,{maxAgents:e,maxAgentRadius:.6}),this.crowd}updateCrowd(e){this.crowd?.update(e)}getCrowdAgents(){return this.crowd?this.crowd.getAgents().map(e=>{const t=e.interpolatedPosition,r=e.velocity(),i=e.target(),o=zt[e.state()]??"invalid",l=o==="invalid"?[]:e.corners().map(n=>({x:n.x,y:n.y,z:n.z}));return{position:{x:t.x,y:t.y,z:t.z},velocity:{x:r.x,y:r.y,z:r.z},radius:e.radius,height:e.height,state:o,target:{x:i.x,y:i.y,z:i.z},corners:l}}):[]}getDebugMesh(e){return this.navMesh?(this.helper||(this.helper=new Ot(this.navMesh),e.add(this.helper)),this.helper):null}exportData(){if(!this.navMesh)throw new Error("No navmesh to export");return Mt(this.navMesh)}loadFromData(e){const{navMesh:t}=pt(e);this.destroyRecast(),this.navMesh=t,this.query=new ee(this.navMesh)}dispose(e){this.helper&&e.remove(this.helper),this.destroyRecast()}}export{or as NavMeshManager,nr as initNavigation};
@@ -1 +1 @@
1
- import{ab as e}from"./index-Cjv2Ynte.js";import{d as t,a as i,n as a,b as s}from"./navmesh-workflow-store-Cmnm57TB.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";const l="workspace.menu",k={menu:"debug",items:[{id:"navmesh-bake",label:()=>s()?"Rebake NavMesh":"Bake NavMesh",testId:"navmesh-bake",disabled:()=>a()||!e().navigation?.bake,execute:t},{id:"navmesh-clear",label:"Clear NavMesh",testId:"navmesh-clear",disabled:()=>a()||!s()||!e().navigation?.clear,execute:i}]};export{k as menu,l as point};
1
+ import{ab as e}from"./index-ClgrFOcX.js";import{d as t,a as i,n as a,b as s}from"./navmesh-workflow-store-Cmnm57TB.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";const l="workspace.menu",k={menu:"debug",items:[{id:"navmesh-bake",label:()=>s()?"Rebake NavMesh":"Bake NavMesh",testId:"navmesh-bake",disabled:()=>a()||!e().navigation?.bake,execute:t},{id:"navmesh-clear",label:"Clear NavMesh",testId:"navmesh-clear",disabled:()=>a()||!s()||!e().navigation?.clear,execute:i}]};export{k as menu,l as point};
@@ -1 +1 @@
1
- import{r as n,ab as u}from"./index-Cjv2Ynte.js";import{getUserData as H}from"./user-data-CODoGZqA.js";import{N as B,c as A,e as $,f as s,m as L,r as f,n as S}from"./navmesh-workflow-store-Cmnm57TB.js";import{b as h}from"./three-contract-Dkt6PmWY.js";import{h as T}from"./host-hierarchy-objects-BV3WqU2w.js";import{a as m,s as g}from"./viewport-door-CTspfOX-.js";import{cp as V,el as R}from"./three.core-3arARmh6.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";import"./object-marks-BnvSuCTt.js";function _(){let l=null;const p=new V({color:3900150,transparent:!0,opacity:.5,depthWrite:!1});function b(a){a.traverse(e=>{e.isMesh&&(e.material=p)})}function w(a){const e=new Set;for(const[o,r]of T()?.objects()??new Map)H(r,"navRole")===a&&e.add(o);return e}function v(){g("navmesh",null)}function k(){const a=u().navigation,e=a?h(a):null;if(e!==l&&(l=e,v()),!e){f();return}let o=!1;try{o=e.hasNavMesh()}catch(c){n().console.error(`Navigation adapter failed to report its state: ${c}`,"navigation")}if(!o){f();return}L();const r=m()?.scene;if(!r)return;let i=null;try{i=e.debugMesh(r)}catch(c){n().console.error(`Navigation adapter failed to create its debug mesh: ${c}`,"navigation")}i&&(b(i),g("navmesh",i))}const N=async()=>{if(S())return;$(),await new Promise(t=>requestAnimationFrame(()=>t(null)));const a=u().navigation,e=a?h(a):void 0;if(!e){const t="The mounted game has no NavigationAdapter";n().console.warn(`${t} — nothing can be baked`,"navigation"),s(t);return}if(!e.bake){const t="The mounted NavigationAdapter is inspect-only and does not support baking";n().console.warn(t,"navigation"),s(t);return}const o=w("walkable");if(o.size===0){n().console.warn("No walkable meshes found — give the floors `userData={{ navRole: 'walkable' }}` (and blockers `'obstacle'`) where they are written","navigation"),s("No walkable-tagged entities in the scene");return}const r=[];for(const t of[...o,...w("obstacle")]){const y=(T()?.objects()??new Map).get(t);y&&y.traverse(E=>{E.isMesh&&r.push(E)})}if(r.length===0){n().console.error("NavMesh bake failed: the walkable-tagged entities have no meshes","navigation"),s("Walkable entities have no meshes");return}let i=!1;try{i=e.bake(r)}catch(t){n().console.error(`NavMesh bake failed: ${t}`,"navigation"),s(`Bake failed: ${t}`);return}if(!i){n().console.error("NavMesh bake failed","navigation"),s("Bake failed (recast rejected the input geometry)");return}l=e;const c=m()?.scene,d=c?e.debugMesh(c):null;d&&(b(d),g("navmesh",d)),s(null)},M=()=>{const a=u().navigation,e=a?h(a):void 0;if(!e){n().console.warn("The mounted game has no NavigationAdapter to clear","navigation");return}if(!e.clear){n().console.warn("The mounted NavigationAdapter is inspect-only and does not support clearing","navigation");return}try{e.clear(m()?.scene??new R)}catch(o){n().console.error(`NavMesh clear failed: ${o}`,"navigation");return}v(),f()};window.addEventListener(B,N),window.addEventListener(A,M);const j=n().systems.subscribe(k);return k(),()=>{window.removeEventListener(B,N),window.removeEventListener(A,M),j(),v(),p.dispose()}}const Y="workspace.service";function Z(){return _()}export{Y as point,Z as start};
1
+ import{r as n,ab as u}from"./index-ClgrFOcX.js";import{getUserData as H}from"./user-data-CODoGZqA.js";import{N as B,c as A,e as $,f as s,m as L,r as f,n as S}from"./navmesh-workflow-store-Cmnm57TB.js";import{b as h}from"./three-contract-Dkt6PmWY.js";import{h as T}from"./host-hierarchy-objects-BV3WqU2w.js";import{a as m,s as g}from"./viewport-door-BV_lf5uK.js";import{cp as V,el as R}from"./three.core-3arARmh6.js";import"./index-nmcBqr7Y.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";import"./object-marks-BnvSuCTt.js";function _(){let l=null;const p=new V({color:3900150,transparent:!0,opacity:.5,depthWrite:!1});function b(a){a.traverse(e=>{e.isMesh&&(e.material=p)})}function w(a){const e=new Set;for(const[o,r]of T()?.objects()??new Map)H(r,"navRole")===a&&e.add(o);return e}function v(){g("navmesh",null)}function k(){const a=u().navigation,e=a?h(a):null;if(e!==l&&(l=e,v()),!e){f();return}let o=!1;try{o=e.hasNavMesh()}catch(c){n().console.error(`Navigation adapter failed to report its state: ${c}`,"navigation")}if(!o){f();return}L();const r=m()?.scene;if(!r)return;let i=null;try{i=e.debugMesh(r)}catch(c){n().console.error(`Navigation adapter failed to create its debug mesh: ${c}`,"navigation")}i&&(b(i),g("navmesh",i))}const N=async()=>{if(S())return;$(),await new Promise(t=>requestAnimationFrame(()=>t(null)));const a=u().navigation,e=a?h(a):void 0;if(!e){const t="The mounted game has no NavigationAdapter";n().console.warn(`${t} — nothing can be baked`,"navigation"),s(t);return}if(!e.bake){const t="The mounted NavigationAdapter is inspect-only and does not support baking";n().console.warn(t,"navigation"),s(t);return}const o=w("walkable");if(o.size===0){n().console.warn("No walkable meshes found — give the floors `userData={{ navRole: 'walkable' }}` (and blockers `'obstacle'`) where they are written","navigation"),s("No walkable-tagged entities in the scene");return}const r=[];for(const t of[...o,...w("obstacle")]){const y=(T()?.objects()??new Map).get(t);y&&y.traverse(E=>{E.isMesh&&r.push(E)})}if(r.length===0){n().console.error("NavMesh bake failed: the walkable-tagged entities have no meshes","navigation"),s("Walkable entities have no meshes");return}let i=!1;try{i=e.bake(r)}catch(t){n().console.error(`NavMesh bake failed: ${t}`,"navigation"),s(`Bake failed: ${t}`);return}if(!i){n().console.error("NavMesh bake failed","navigation"),s("Bake failed (recast rejected the input geometry)");return}l=e;const c=m()?.scene,d=c?e.debugMesh(c):null;d&&(b(d),g("navmesh",d)),s(null)},M=()=>{const a=u().navigation,e=a?h(a):void 0;if(!e){n().console.warn("The mounted game has no NavigationAdapter to clear","navigation");return}if(!e.clear){n().console.warn("The mounted NavigationAdapter is inspect-only and does not support clearing","navigation");return}try{e.clear(m()?.scene??new R)}catch(o){n().console.error(`NavMesh clear failed: ${o}`,"navigation");return}v(),f()};window.addEventListener(B,N),window.addEventListener(A,M);const j=n().systems.subscribe(k);return k(),()=>{window.removeEventListener(B,N),window.removeEventListener(A,M),j(),v(),p.dispose()}}const Y="workspace.service";function Z(){return _()}export{Y as point,Z as start};
@@ -0,0 +1 @@
1
+ import{i as t}from"./game-network-Deo8lcPw.js";import"./index-OZVqp6xS.js";import"./index-Da9JhEvW.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-ClgrFOcX.js";import"./index-nmcBqr7Y.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-FUuS4qwW.js";import"./client-DNXj_opT.js";import"./native-debug-module-iX2-V5kg.js";import"./native-entry-surface-BE8LJNdu.js";import"./debug-registry-B2THKz1v.js";import"./contract-system-adapters-BDUpDoKd.js";import"./game-contract-seams-C22a4B79.js";import"./seeded-random-B6zqGkWP.js";import"./game-audio-BeCyd0Ha.js";import"./rapier-physics-adapter-CaZqWLu0.js";import"./events-156d8d12.esm-DmeaOP4r.js";import"./three.module-BLhyNg0e.js";import"./three.core-3arARmh6.js";import"./index-DzuOGwVB.js";import"./live-project-verbs-Bqmxbr2o.js";import"./capability-coverage-EnZ99FoT.js";import"./edit-mode-authoring-BDgZD47j.js";import"./json-history-resource-CDEoQe1R.js";import"./binding-resolver-DoOAFM2m.js";import"./adapter-surface-Y37Nzcyw.js";import"./structural-signature-Dc7skRiy.js";import"./webgl-frame-capture-DdJkM2mi.js";import"./realm-services-CqjVBanw.js";import"./canvas-entry-runtime-CLOuJcgT.js";import"./three-ingest-runtime-x9nLmUl-.js";import"./EffectComposer-BEAt0PtQ.js";import"./CopyShader-BzTUYzf6.js";import"./ShaderPass-DTnDQXm0.js";import"./Pass-D1MRT672.js";import"./CSS3DRenderer-BsAqfavI.js";import"./relative-path-guard-GiM7Lsz8.js";import"./react-root-BHA-cdrW.js";import"./editor-presentation-activity-CqJH4G9t.js";import"./active-ingest-CJ2U5L1O.js";import"./ingest-source-persistence-CVU1rTj0.js";import"./pixi-story-model-DNkfnWUV.js";import"./surface-content-Dg9Kkazf.js";import"./viewport-root-presentation-CKqhX3mt.js";import"./mounted-authoring-B697dYuN.js";import"./entity-object-BLJ-I8XT.js";import"./user-data-DL6HsBPf.js";import"./workspace-arrangement-86_8Kk5K.js";import"./three-contract-Dkt6PmWY.js";import"./three-DWy0sZom.js";import"./editor-layers-DwaX5UFy.js";import"./component-instance-root-wO1p-rLr.js";import"./viewport-editor-controls-BYaAZ_Ku.js";import"./three-authoring-adapter-9LcUBPaU.js";import"./source-persistence-backend-Cwy93SmQ.js";import"./three-projection-core-IUovHgg_.js";import"./body-marks-C1LxJtQb.js";import"./user-data-CODoGZqA.js";import"./object-marks-BnvSuCTt.js";import"./structural-ids-BOo2BRoY.js";import"./object3d-authoring-subject-XccsO0xG.js";import"./r3f-physics-binding-DuG97FR9.js";import"./deferred-ingest-play-To3ZratW.js";import"./rrweb-Cd2ifIRP.js";import"./react-world-authoring-adapter-Dq8NqvWu.js";import"./board-guides-CCiyx8cT.js";import"./relative-import-specifier-CA9mSNXO.js";import"./story-arg-descriptors-Ek86ExX7.js";import"./inspect-BunjdqX7.js";import"./inference-diagnostics-BmZ5ggEK.js";import"./writer-tw6EcuVO.js";import"./three-state-_ImCbP87.js";import"./editor-shell-store-aKHbAoCV.js";import"./output-pass-HurwNl0G.js";import"./viewport-door-BV_lf5uK.js";import"./game-surface-defaults-D8S4cRxi.js";const zt="workspace.service";function At(){t()}export{zt as point,At as start};