@nebula-spatial/studio 0.0.0-stage → 0.1.1

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 (262) hide show
  1. package/README.md +206 -3
  2. package/dist/ai/contract.d.ts +73 -0
  3. package/dist/ai/host.d.ts +28 -0
  4. package/dist/asset/dependency-scan.d.ts +78 -0
  5. package/dist/asset/intake.d.ts +84 -0
  6. package/dist/asset/layout-detect.d.ts +40 -0
  7. package/dist/asset/media-type.d.ts +10 -0
  8. package/dist/asset/model-inspection.d.ts +127 -0
  9. package/dist/asset/record.d.ts +35 -0
  10. package/dist/asset/remote-asset-resolver.d.ts +36 -0
  11. package/dist/asset/repairs.d.ts +53 -0
  12. package/dist/asset/resource-locator.d.ts +15 -0
  13. package/dist/asset/revision-diff.d.ts +33 -0
  14. package/dist/asset/source-contracts.d.ts +21 -0
  15. package/dist/asset/source-paths.d.ts +15 -0
  16. package/dist/asset/usd-inspection.d.ts +39 -0
  17. package/dist/asset/usd-source-metadata.d.ts +142 -0
  18. package/dist/asset/visual-intake.d.ts +27 -0
  19. package/dist/asset/visual-record.d.ts +22 -0
  20. package/dist/asset/web-intake.d.ts +46 -0
  21. package/dist/asset-source-BExlEcRt.js +444 -0
  22. package/dist/assets/openusd_three_loader-DLiqJWUM.js +13769 -0
  23. package/dist/assets/usd-export-worker-BRxTLqer.js +182 -0
  24. package/dist/assets/usd-worker-DekqMsQv.js +1392 -0
  25. package/dist/builders-BAXRR5o5.js +1854 -0
  26. package/dist/core/asset-task.d.ts +105 -0
  27. package/dist/core/context.d.ts +23 -0
  28. package/dist/core/host.d.ts +432 -0
  29. package/dist/core/persistence-controller.d.ts +58 -0
  30. package/dist/core/plugins.d.ts +139 -0
  31. package/dist/core/scene-tree.d.ts +62 -0
  32. package/dist/core/versions.d.ts +2 -0
  33. package/dist/core/when.d.ts +13 -0
  34. package/dist/core/write-policy.d.ts +29 -0
  35. package/dist/delivery/build-plan.d.ts +2 -0
  36. package/dist/delivery/contracts.d.ts +362 -0
  37. package/dist/delivery/digest.d.ts +3 -0
  38. package/dist/delivery/evidence.d.ts +10 -0
  39. package/dist/delivery/export-evidence.d.ts +3 -0
  40. package/dist/delivery/index.d.ts +9 -0
  41. package/dist/delivery/prim-name.d.ts +17 -0
  42. package/dist/delivery/profile.d.ts +4 -0
  43. package/dist/doc/builders.d.ts +99 -0
  44. package/dist/doc/command.d.ts +195 -0
  45. package/dist/doc/domain-extensions.d.ts +34 -0
  46. package/dist/doc/node-facts.d.ts +87 -0
  47. package/dist/doc/physics-facts.d.ts +74 -0
  48. package/dist/doc/placement-policy.d.ts +71 -0
  49. package/dist/doc/random-placement.d.ts +30 -0
  50. package/dist/doc/scene-graph.d.ts +80 -0
  51. package/dist/doc/scene-regions.d.ts +29 -0
  52. package/dist/doc/schema.d.ts +452 -0
  53. package/dist/doc/task.d.ts +71 -0
  54. package/dist/doc/validate.d.ts +68 -0
  55. package/dist/editor/asset-source.d.ts +15 -0
  56. package/dist/editor/editor.d.ts +246 -0
  57. package/dist/editor/index.d.ts +22 -0
  58. package/dist/editor/shortcuts.d.ts +2 -0
  59. package/dist/editor/types.d.ts +143 -0
  60. package/dist/editor/ui-plugins.d.ts +64 -0
  61. package/dist/editor.js +1755 -0
  62. package/dist/editorial-BkAFWfbg.js +83 -0
  63. package/dist/export-evidence-DMNRhgL9.js +2705 -0
  64. package/dist/generalization/domain.d.ts +10 -0
  65. package/dist/generalization/generalization.d.ts +371 -0
  66. package/dist/generalization/index.d.ts +11 -0
  67. package/dist/generalization.js +1659 -0
  68. package/dist/history/undo-stack.d.ts +74 -0
  69. package/dist/index.d.ts +91 -0
  70. package/dist/index.js +2840 -0
  71. package/dist/mjcf-visual-Bt4bUxd1.js +72 -0
  72. package/dist/mujoco-runtime-BYZnrvbR.js +467 -0
  73. package/dist/persist/content-addressed.d.ts +11 -0
  74. package/dist/persist/create-scene-package-from-host.d.ts +7 -0
  75. package/dist/persist/indexeddb-store.d.ts +69 -0
  76. package/dist/persist/scene-file.d.ts +52 -0
  77. package/dist/persist/scene-package.d.ts +8 -0
  78. package/dist/persist/snapshot.d.ts +5 -0
  79. package/dist/physics-facts-tfQYyNTD.js +337 -0
  80. package/dist/placement-policy-DY_FNRDu.js +405 -0
  81. package/dist/ports/asset-ingestor.d.ts +41 -0
  82. package/dist/ports/asset-source.d.ts +57 -0
  83. package/dist/ports/delivery.d.ts +13 -0
  84. package/dist/ports/persistence.d.ts +29 -0
  85. package/dist/project/asset-catalog.d.ts +21 -0
  86. package/dist/project/contracts.d.ts +272 -0
  87. package/dist/project/editorial.d.ts +16 -0
  88. package/dist/project/identity.d.ts +20 -0
  89. package/dist/project/index.d.ts +9 -0
  90. package/dist/project/scene-document.d.ts +5 -0
  91. package/dist/project/source-dependencies.d.ts +7 -0
  92. package/dist/remote-asset-resolver-Cb8cfNmw.js +136 -0
  93. package/dist/scene/index.d.ts +12 -0
  94. package/dist/scene-graph-DBLKAhxa.js +681 -0
  95. package/dist/scene-session-Cy6vDJ1l.js +21981 -0
  96. package/dist/scene.js +244 -0
  97. package/dist/session-BRBrCLdd.js +963 -0
  98. package/dist/session-DI5tPJxn.js +825 -0
  99. package/dist/session-q3uuG7OP.js +296 -0
  100. package/dist/studio/delivery-catalog.d.ts +28 -0
  101. package/dist/studio/in-memory-asset-source.d.ts +15 -0
  102. package/dist/studio/index.d.ts +31 -0
  103. package/dist/studio/indexeddb-asset-source.d.ts +32 -0
  104. package/dist/studio/indexeddb-persistence.d.ts +13 -0
  105. package/dist/studio/remote-asset-importer.d.ts +56 -0
  106. package/dist/studio/source-package.d.ts +9 -0
  107. package/dist/studio/usd-export-client.d.ts +13 -0
  108. package/dist/studio/usd-export-protocol.d.ts +98 -0
  109. package/dist/studio/usd-export-worker.d.ts +1 -0
  110. package/dist/studio/usd-zip-reader.d.ts +14 -0
  111. package/dist/studio/web-asset-ingestor.d.ts +10 -0
  112. package/dist/studio/web-host.d.ts +8 -0
  113. package/dist/studio.js +5545 -0
  114. package/dist/urdf-session-CQir2nb2.js +1230 -0
  115. package/dist/usd-session-DZJnEEOs.js +7385 -0
  116. package/dist/util/asset-facts.d.ts +3 -0
  117. package/dist/util/data.d.ts +17 -0
  118. package/dist/util/diagnostics.d.ts +38 -0
  119. package/dist/util/geometry.d.ts +11 -0
  120. package/dist/util/hash.d.ts +9 -0
  121. package/dist/util/ids.d.ts +20 -0
  122. package/dist/util/math.d.ts +47 -0
  123. package/dist/util/ply-metadata.d.ts +19 -0
  124. package/dist/util/studio-source.d.ts +23 -0
  125. package/dist/version.d.ts +5 -0
  126. package/dist/view/appearance.d.ts +13 -0
  127. package/dist/view/authoring-appearance.d.ts +25 -0
  128. package/dist/view/bounds-preview.d.ts +34 -0
  129. package/dist/view/bounds.d.ts +11 -0
  130. package/dist/view/camera-zoom.d.ts +3 -0
  131. package/dist/view/geometry-anchors.d.ts +20 -0
  132. package/dist/view/gizmo-appearance.d.ts +5 -0
  133. package/dist/view/gizmo.d.ts +81 -0
  134. package/dist/view/group-selection.d.ts +13 -0
  135. package/dist/view/node-features.d.ts +39 -0
  136. package/dist/view/picking.d.ts +49 -0
  137. package/dist/view/placement.d.ts +48 -0
  138. package/dist/view/region-editing.d.ts +25 -0
  139. package/dist/view/rotation-guide.d.ts +36 -0
  140. package/dist/view/runtime-capabilities.d.ts +22 -0
  141. package/dist/view/scene-session.d.ts +258 -0
  142. package/dist/view/screen-bounds.d.ts +17 -0
  143. package/dist/view/selection-transform.d.ts +20 -0
  144. package/dist/wasm-module-DZn2AM1W.js +13 -0
  145. package/dist/xacro-DLRXyk60.js +76 -0
  146. package/node_modules/@nebula-spatial/cad-loader/CHANGELOG.md +48 -0
  147. package/node_modules/@nebula-spatial/cad-loader/README.md +108 -0
  148. package/node_modules/@nebula-spatial/cad-loader/dist/core/cad-types.d.ts +26 -0
  149. package/node_modules/@nebula-spatial/cad-loader/dist/core/errors.d.ts +5 -0
  150. package/node_modules/@nebula-spatial/cad-loader/dist/core/index.d.ts +24 -0
  151. package/node_modules/@nebula-spatial/cad-loader/dist/core/index.js +2354 -0
  152. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/bin-group-reader.d.ts +9 -0
  153. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/bin-parser.d.ts +78 -0
  154. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/dxbs-sidecar.d.ts +24 -0
  155. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/geometry-segments.d.ts +20 -0
  156. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/text-roundtrip.d.ts +4 -0
  157. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/types.d.ts +81 -0
  158. package/node_modules/@nebula-spatial/cad-loader/dist/core/runtime-text-decoder.d.ts +8 -0
  159. package/node_modules/@nebula-spatial/cad-loader/dist/core/types.d.ts +153 -0
  160. package/node_modules/@nebula-spatial/cad-loader/dist/core/utils/insert-bbox.d.ts +10 -0
  161. package/node_modules/@nebula-spatial/cad-loader/dist/core/utils/viewport-rect.d.ts +21 -0
  162. package/node_modules/@nebula-spatial/cad-loader/dist/index.d.ts +36 -0
  163. package/node_modules/@nebula-spatial/cad-loader/dist/index.js +5829 -0
  164. package/node_modules/@nebula-spatial/cad-loader/dist/loader/geo-loader.d.ts +59 -0
  165. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/automatic-external-resources.d.ts +26 -0
  166. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/external-variant-sidecar-fetch.d.ts +13 -0
  167. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/flow-control.d.ts +29 -0
  168. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/frame-budget-scheduler.d.ts +21 -0
  169. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-compact-executor.d.ts +19 -0
  170. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-loader-local-adapter.d.ts +2 -0
  171. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-loader-pipeline.d.ts +92 -0
  172. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-loader-worker-adapter.d.ts +13 -0
  173. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-node-builder.d.ts +34 -0
  174. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-node-load-sink.d.ts +28 -0
  175. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-node.d.ts +304 -0
  176. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-prepare-worker-types.d.ts +94 -0
  177. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-prepare.d.ts +38 -0
  178. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-prepare.worker.d.ts +1 -0
  179. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/insert-model-builder.d.ts +10 -0
  180. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/insert-runtime-geometry.d.ts +15 -0
  181. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/line-canonical.d.ts +37 -0
  182. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/line-quality.d.ts +9 -0
  183. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/prepare-credit-gate.d.ts +20 -0
  184. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/transport.d.ts +2 -0
  185. package/node_modules/@nebula-spatial/cad-loader/dist/render-resource/cad-render-node.d.ts +80 -0
  186. package/node_modules/@nebula-spatial/cad-loader/dist/render-resource/geo-node-cad-render-node.d.ts +12 -0
  187. package/node_modules/@nebula-spatial/cad-loader/dist/scene/geo-cad-line-geometry.d.ts +28 -0
  188. package/node_modules/@nebula-spatial/cad-loader/dist/scene/geo-cad-line-material.d.ts +18 -0
  189. package/node_modules/@nebula-spatial/cad-loader/dist/scene/instancing/block-geometry-registry.d.ts +35 -0
  190. package/node_modules/@nebula-spatial/cad-loader/dist/scene/instancing/insert-instance-table.d.ts +23 -0
  191. package/node_modules/@nebula-spatial/cad-loader/dist/scene/instancing/viewport-instance-presenter.d.ts +66 -0
  192. package/node_modules/@nebula-spatial/cad-loader/dist/selection/cad-insert-selection.d.ts +35 -0
  193. package/node_modules/@nebula-spatial/cad-loader/dist/selection/cad-text-selection.d.ts +31 -0
  194. package/node_modules/@nebula-spatial/cad-loader/dist/session/annotation-idle-gate.d.ts +14 -0
  195. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-document-session.d.ts +187 -0
  196. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-font-runtime.d.ts +11 -0
  197. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-insert-id.d.ts +6 -0
  198. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-text-warmup.d.ts +38 -0
  199. package/node_modules/@nebula-spatial/cad-loader/dist/session/create-cad-document-session.d.ts +5 -0
  200. package/node_modules/@nebula-spatial/cad-loader/dist/session/load-session.d.ts +90 -0
  201. package/node_modules/@nebula-spatial/cad-loader/dist/session/viewport-coverage.d.ts +32 -0
  202. package/node_modules/@nebula-spatial/cad-loader/dist/shared/abort.d.ts +3 -0
  203. package/node_modules/@nebula-spatial/cad-loader/dist/shared/cad-display-color.d.ts +55 -0
  204. package/node_modules/@nebula-spatial/cad-loader/dist/shared/cad-load-source.d.ts +8 -0
  205. package/node_modules/@nebula-spatial/cad-loader/dist/shared/color-buffer.d.ts +6 -0
  206. package/node_modules/@nebula-spatial/cad-loader/dist/shared/constants.d.ts +11 -0
  207. package/node_modules/@nebula-spatial/cad-loader/dist/shared/display-color-buffer.d.ts +27 -0
  208. package/node_modules/@nebula-spatial/cad-loader/dist/shared/errors.d.ts +2 -0
  209. package/node_modules/@nebula-spatial/cad-loader/dist/shared/text-builder.d.ts +25 -0
  210. package/node_modules/@nebula-spatial/cad-loader/dist/shared/text-font.d.ts +12 -0
  211. package/node_modules/@nebula-spatial/cad-loader/dist/shared/types.d.ts +57 -0
  212. package/node_modules/@nebula-spatial/cad-loader/dist/shared/utils/insert-bbox.d.ts +1 -0
  213. package/node_modules/@nebula-spatial/cad-loader/dist/shared/utils/timing.d.ts +2 -0
  214. package/node_modules/@nebula-spatial/cad-loader/dist/shared/utils/viewport-rect.d.ts +1 -0
  215. package/node_modules/@nebula-spatial/cad-loader/dist/shared/viewer-theme.d.ts +2 -0
  216. package/node_modules/@nebula-spatial/cad-loader/dist/workers/geo-prepare.worker.js +2264 -0
  217. package/node_modules/@nebula-spatial/cad-loader/package.json +62 -0
  218. package/node_modules/@nebula-spatial/viewer/CHANGELOG.md +426 -0
  219. package/node_modules/@nebula-spatial/viewer/FBX-MATERIAL-CONVERSION.md +97 -0
  220. package/node_modules/@nebula-spatial/viewer/README.md +1056 -0
  221. package/node_modules/@nebula-spatial/viewer/USD-VISUAL-MATERIAL-SUPPORT.md +89 -0
  222. package/node_modules/@nebula-spatial/viewer/basis/basis_transcoder.js +19 -0
  223. package/node_modules/@nebula-spatial/viewer/basis/basis_transcoder.wasm +0 -0
  224. package/node_modules/@nebula-spatial/viewer/dist/asset-ir-DEOK9SqE.js +382 -0
  225. package/node_modules/@nebula-spatial/viewer/dist/assets/ground-grid.d.ts +6 -0
  226. package/node_modules/@nebula-spatial/viewer/dist/assets/source-types.d.ts +19 -0
  227. package/node_modules/@nebula-spatial/viewer/dist/assets/types.d.ts +393 -0
  228. package/node_modules/@nebula-spatial/viewer/dist/assets/usd-worker-Bom5cjz3.js +1392 -0
  229. package/node_modules/@nebula-spatial/viewer/dist/cad/text.d.ts +2 -0
  230. package/node_modules/@nebula-spatial/viewer/dist/cad/types.d.ts +368 -0
  231. package/node_modules/@nebula-spatial/viewer/dist/index-ByBlfVc0.js +12132 -0
  232. package/node_modules/@nebula-spatial/viewer/dist/index.d.ts +32 -0
  233. package/node_modules/@nebula-spatial/viewer/dist/index.js +26 -0
  234. package/node_modules/@nebula-spatial/viewer/dist/inspection/types.d.ts +112 -0
  235. package/node_modules/@nebula-spatial/viewer/dist/mjcf-visual-DVRa0w90.js +72 -0
  236. package/node_modules/@nebula-spatial/viewer/dist/mujoco-runtime-Dhx6Ua2u.js +463 -0
  237. package/node_modules/@nebula-spatial/viewer/dist/plugins.d.ts +179 -0
  238. package/node_modules/@nebula-spatial/viewer/dist/scene/instances.d.ts +36 -0
  239. package/node_modules/@nebula-spatial/viewer/dist/scene/types.d.ts +258 -0
  240. package/node_modules/@nebula-spatial/viewer/dist/session-B-j6KdA-.js +389 -0
  241. package/node_modules/@nebula-spatial/viewer/dist/session-B4AICTeJ.js +963 -0
  242. package/node_modules/@nebula-spatial/viewer/dist/session-BAG5cDYe.js +9153 -0
  243. package/node_modules/@nebula-spatial/viewer/dist/simulation/mujoco-runtime.d.ts +118 -0
  244. package/node_modules/@nebula-spatial/viewer/dist/simulation/mujoco-wasm-module.d.ts +11 -0
  245. package/node_modules/@nebula-spatial/viewer/dist/simulation/openusd-wasm-module.d.ts +10 -0
  246. package/node_modules/@nebula-spatial/viewer/dist/simulation/physics-runtime-state.d.ts +75 -0
  247. package/node_modules/@nebula-spatial/viewer/dist/simulation/types.d.ts +129 -0
  248. package/node_modules/@nebula-spatial/viewer/dist/simulation/usd-inspection.d.ts +66 -0
  249. package/node_modules/@nebula-spatial/viewer/dist/simulation/usd-query.d.ts +50 -0
  250. package/node_modules/@nebula-spatial/viewer/dist/simulation/usd-resource-policy.d.ts +28 -0
  251. package/node_modules/@nebula-spatial/viewer/dist/types.d.ts +278 -0
  252. package/node_modules/@nebula-spatial/viewer/dist/ui/types.d.ts +48 -0
  253. package/node_modules/@nebula-spatial/viewer/dist/urdf-session-kemAnBn8.js +3231 -0
  254. package/node_modules/@nebula-spatial/viewer/dist/usd-session-QtwGKI7v.js +6771 -0
  255. package/node_modules/@nebula-spatial/viewer/dist/version.d.ts +5 -0
  256. package/node_modules/@nebula-spatial/viewer/dist/viewer.d.ts +2 -0
  257. package/node_modules/@nebula-spatial/viewer/dist/xacro-CYTPS7mh.js +1537 -0
  258. package/node_modules/@nebula-spatial/viewer/openusd/openusd-runtime-manifest.json +15 -0
  259. package/node_modules/@nebula-spatial/viewer/openusd/openusd_probe.js +14 -0
  260. package/node_modules/@nebula-spatial/viewer/openusd/openusd_probe.wasm +0 -0
  261. package/node_modules/@nebula-spatial/viewer/package.json +66 -0
  262. package/package.json +87 -6
@@ -0,0 +1,1659 @@
1
+ import { s as oe, g as U, p as mn } from "./builders-BAXRR5o5.js";
2
+ import { a as D, l as ue, u as P, k as me, x as W, w as Pe, _ as pe, B as In, z as ze, s as fn } from "./scene-graph-DBLKAhxa.js";
3
+ const un = "sim-studio.generalization@1", he = "sim-studio.resolved-sample@1", H = "sim-studio.generalization", He = 1, dt = {
4
+ family: "family_",
5
+ region: "region_",
6
+ contract: "contract_",
7
+ term: "term_",
8
+ sample: "sample_"
9
+ }, re = {
10
+ "rigid-body.mass-kg": M("number", "kg", ["set", "scale", "offset"], ["scene-node", "family"], !0),
11
+ "rigid-body.center-of-mass": M("vector3", "m", ["set", "offset"], ["scene-node", "family"], !0),
12
+ "physics-material.static-friction": M("number", "unitless", ["set", "scale", "offset"], ["scene-node", "family"], !0),
13
+ "physics-material.dynamic-friction": M("number", "unitless", ["set", "scale", "offset"], ["scene-node", "family"], !0),
14
+ "physics-material.restitution": M("number", "unitless", ["set", "scale", "offset"], ["scene-node", "family"], !0),
15
+ "visual.color": M("color", "linear-rgb", ["set", "choice"], ["scene-node", "family"], !0),
16
+ "visual.opacity": M("number", "unitless", ["set", "offset"], ["scene-node", "family"], !0),
17
+ "visual.material-choice": M("choice", "variant-option", ["choice"], ["scene-node", "family"], !0),
18
+ "joint.position": M("number", "rad-or-m", ["set", "offset"], ["joint"], !0),
19
+ "joint.stiffness": M("number", "N-m/rad-or-N/m", ["set", "scale"], ["joint"], !1, "当前 SceneDocument 仅保存 Prim 路径驱动,尚无稳定 jointName 到 MuJoCo actuator 的安全映射。"),
20
+ "joint.damping": M("number", "N-m-s/rad-or-N-s/m", ["set", "scale"], ["joint"], !1, "当前 SceneDocument 仅保存 Prim 路径驱动,尚无稳定 jointName 到 MuJoCo actuator 的安全映射。"),
21
+ "environment.gravity": M("vector3", "m/s^2", ["set"], ["scene"], !0),
22
+ "environment.timestep": M("number", "s", ["set"], ["scene"], !0),
23
+ "environment.rendering-preset": M("choice", "preset-id", ["choice"], ["scene"], !1, "当前场景会话固定使用 Viewer RoomEnvironment,尚未把 rendering preset 接入运行时切换。"),
24
+ "layout.candidate": M("choice", "asset-revision-id", ["choice"], ["family"], !0),
25
+ "layout.placement": M("choice", "placement-region-id", ["choice"], ["family", "scene-node"], !0)
26
+ };
27
+ function pn() {
28
+ return { families: [], regions: [], contracts: [], samples: [] };
29
+ }
30
+ function T(e) {
31
+ var t;
32
+ const n = (t = e.domains) == null ? void 0 : t[H];
33
+ return n && typeof n.data == "object" && n.data !== null ? n.data : pn();
34
+ }
35
+ function Ne(e) {
36
+ return {
37
+ dataVersion: He,
38
+ data: D(e)
39
+ };
40
+ }
41
+ function lt(e, n) {
42
+ const t = { ...e.domains };
43
+ n === null ? delete t[H] : t[H] = Ne(n);
44
+ const s = { ...e };
45
+ return Object.keys(t).length > 0 ? { ...s, domains: t } : (delete s.domains, s);
46
+ }
47
+ function Fe(e) {
48
+ var s;
49
+ const n = e.candidates.map((i) => ({
50
+ ...D(i),
51
+ requiredCapabilities: D("requiredCapabilities" in i ? i.requiredCapabilities : ye())
52
+ })), t = e.selectionMode ?? "resolved-sample";
53
+ return {
54
+ familyId: e.familyId,
55
+ label: e.label,
56
+ semanticTag: e.semanticTag,
57
+ targetNodeIds: [...new Set(e.targetNodeIds)].sort(),
58
+ candidates: je(n),
59
+ selectionMode: t,
60
+ ...t === "fixed" ? { fixedRevisionId: e.fixedRevisionId ?? ((s = n[0]) == null ? void 0 : s.revisionId) ?? "" } : {}
61
+ };
62
+ }
63
+ function hn(e) {
64
+ return Be(e);
65
+ }
66
+ function Nn(e) {
67
+ return qe(e);
68
+ }
69
+ function mt(e, n, t, s = {}) {
70
+ var Se, Te, Oe, ke, we, be, Ge, De;
71
+ const i = ue(e), o = new Set(n), c = [
72
+ ...i.filter((f) => n.includes(f.nodeId)),
73
+ ...i.filter((f) => !o.has(f.nodeId) && n.length === 0)
74
+ ];
75
+ if (!c.length) return null;
76
+ const a = (f) => {
77
+ var B;
78
+ const g = (B = s.worldBoundsByNodeId) == null ? void 0 : B[f.nodeId];
79
+ if (g) return Ye(g);
80
+ const J = P(e, f.assetRevisionId);
81
+ return J ? Pn(J) : 0;
82
+ }, d = /* @__PURE__ */ new Map();
83
+ for (const f of c) {
84
+ const g = P(e, f.assetRevisionId);
85
+ if (!g) continue;
86
+ const J = g.category ?? ((Te = (Se = g.semantic) == null ? void 0 : Se.tags) == null ? void 0 : Te[0]) ?? ((ke = (Oe = g.semantic) == null ? void 0 : Oe.labels) == null ? void 0 : ke[0]) ?? "object", B = d.get(J) ?? { nodes: [], supportScore: 0 };
87
+ B.nodes.push(f), d.set(J, {
88
+ nodes: B.nodes,
89
+ supportScore: Math.max(B.supportScore, a(f))
90
+ });
91
+ }
92
+ const r = [...d.values()].sort((f, g) => g.supportScore - f.supportScore), p = r.length > 1 ? r[0] : null, m = r.length > 1 ? [...r.slice(1)].sort((f, g) => g.nodes.length - f.nodes.length || f.supportScore - g.supportScore)[0] : r[0];
93
+ if (!(m != null && m.nodes.length)) return null;
94
+ const l = m.nodes[0], u = P(e, l.assetRevisionId);
95
+ if (!u) return null;
96
+ const A = u.category ?? ((be = (we = u.semantic) == null ? void 0 : we.tags) == null ? void 0 : be[0]) ?? ((De = (Ge = u.semantic) == null ? void 0 : Ge.labels) == null ? void 0 : De[0]) ?? "object", N = m.nodes.filter((f) => {
97
+ const g = P(e, f.assetRevisionId);
98
+ return !!g && Xe(g, A);
99
+ }), h = N.length ? N : [l], y = [...new Map(h.map((f) => P(e, f.assetRevisionId)).filter((f) => !!f).map((f) => [f.revisionId, f])).values()];
100
+ if (!y.length) return null;
101
+ const E = new Set(h.map((f) => f.nodeId)), x = p == null ? void 0 : p.nodes.filter((f) => !E.has(f.nodeId)).sort((f, g) => a(g) - a(f))[0], _ = Math.max(...h.map((f) => a(f))), O = i.filter((f) => !E.has(f.nodeId)).map((f) => ({ node: f, score: a(f) })).filter((f) => !!f).sort((f, g) => g.score - f.score).find((f) => f.score > Math.max(0.45, _ * 2.5)), k = x ?? (O == null ? void 0 : O.node), Y = Fe({
102
+ familyId: t.familyId,
103
+ label: `${l.label} family`,
104
+ semanticTag: A,
105
+ targetNodeIds: h.map((f) => f.nodeId),
106
+ candidates: y.map((f) => ({
107
+ revisionId: f.revisionId,
108
+ label: f.label,
109
+ requiredCapabilities: ye()
110
+ })),
111
+ selectionMode: "resolved-sample"
112
+ }), Q = y.map((f) => f.bounds).filter((f) => !!f), en = Q.length ? Q.map((f) => f.max[0] - f.min[0]) : [1], nn = Q.length ? Q.map((f) => f.max[1] - f.min[1]) : [1], Me = (f) => {
113
+ var g;
114
+ return ((g = s.worldBoundsByNodeId) == null ? void 0 : g[f]) ?? K(e, f);
115
+ }, Z = k ? Me(k.nodeId) : null, Le = k ? b(e.root, k.nodeId) : null;
116
+ let ee = Z ? [
117
+ (Z.min[0] + Z.max[0]) / 2,
118
+ (Z.min[1] + Z.max[1]) / 2,
119
+ Z.max[2]
120
+ ] : null;
121
+ const tn = h.map((f) => Me(f.nodeId)).filter((f) => !!f), v = zn(tn);
122
+ !ee && v && (ee = [
123
+ (v.min[0] + v.max[0]) / 2,
124
+ (v.min[1] + v.max[1]) / 2,
125
+ v.min[2]
126
+ ]);
127
+ const X = Z ?? v, V = !!k && !!Le && !!ee && !!X, sn = V ? j(ie(Le), {
128
+ position: ee,
129
+ rotation: [0, 0, 0, 1],
130
+ scale: [1, 1, 1]
131
+ }).position : null, on = V ? sn : [0, 0, 0], rn = b(e.root, e.root.nodeId) ?? me(), an = j(ie(rn), {
132
+ position: v ? [
133
+ (v.min[0] + v.max[0]) / 2,
134
+ (v.min[1] + v.max[1]) / 2,
135
+ 0
136
+ ] : [0, 0, 0],
137
+ rotation: [0, 0, 0, 1],
138
+ scale: [1, 1, 1]
139
+ }), cn = V ? Math.max(0.1, (X.max[0] - X.min[0]) * 1.15) : Math.max(0.5, v ? (v.max[0] - v.min[0]) * 1.4 : Math.max(...en) * 1.4), dn = V ? Math.max(0.1, (X.max[1] - X.min[1]) * 1.15) : Math.max(0.5, v ? (v.max[1] - v.min[1]) * 1.4 : Math.max(...nn) * 1.4), xe = hn({
140
+ regionId: t.regionId,
141
+ label: V ? `${k.label} 支撑区域` : "地面工作区域",
142
+ parentNodeId: V ? k.nodeId : e.root.nodeId,
143
+ familyIds: [Y.familyId],
144
+ targetNodeIds: [],
145
+ frame: V ? { ...me(), position: on } : an,
146
+ shape: {
147
+ kind: "rectangle",
148
+ widthM: cn,
149
+ heightM: dn
150
+ },
151
+ normalAxis: "+Z",
152
+ semantic: V ? "support-surface" : "work-area",
153
+ constraints: {
154
+ anchor: V ? "parent-surface" : "grid",
155
+ upright: !0,
156
+ yawRadians: { min: -Math.PI, max: Math.PI },
157
+ marginM: 0.01,
158
+ maxStackLayers: 3
159
+ }
160
+ }), ce = { kind: "family", familyId: Y.familyId }, ln = [
161
+ de(e, "rigid-body.mass-kg", 1, t.termIds[0], ce),
162
+ de(e, "physics-material.static-friction", 2, t.termIds[1], ce),
163
+ de(e, "physics-material.dynamic-friction", 3, t.termIds[2], ce)
164
+ ], _e = Nn({
165
+ contractId: t.contractId,
166
+ label: `${l.label} 质量标准与摩擦`,
167
+ description: "由当前场景生成的质量、静摩擦和动摩擦泛化契约。",
168
+ terms: ln
169
+ });
170
+ return {
171
+ generalization: { families: [Y], regions: [xe], contracts: [_e], samples: [] },
172
+ family: Y,
173
+ region: xe,
174
+ contract: _e,
175
+ targetNodeIds: Y.targetNodeIds,
176
+ skippedNodeIds: c.filter((f) => !h.some((g) => g.nodeId === f.nodeId)).map((f) => f.nodeId)
177
+ };
178
+ }
179
+ function de(e, n, t, s, i) {
180
+ const o = xn(n);
181
+ return {
182
+ termId: s,
183
+ label: `${String(t).padStart(2, "0")} ${n}`,
184
+ kind: n,
185
+ target: i,
186
+ operation: o.operations[0] ?? "set",
187
+ domain: yn(e, n, i),
188
+ mode: "startup",
189
+ unit: o.unit,
190
+ constraints: n === "environment.timestep" ? [{ kind: "positive" }, { kind: "finite" }] : [{ kind: "finite" }],
191
+ backendCapability: {
192
+ backend: "mujoco-wasm",
193
+ capability: n,
194
+ status: o.supported ? "supported" : "unsupported",
195
+ ...o.reason ? { reason: o.reason } : {}
196
+ }
197
+ };
198
+ }
199
+ function yn(e, n, t) {
200
+ if (n === "rigid-body.center-of-mass" || n === "environment.gravity")
201
+ return {
202
+ kind: "vector3",
203
+ min: n === "environment.gravity" ? [-20, -20, -20] : [-0.5, -0.5, -0.5],
204
+ max: n === "environment.gravity" ? [20, 20, 20] : [0.5, 0.5, 0.5]
205
+ };
206
+ if (n === "visual.color")
207
+ return { kind: "color", options: [[1, 1, 1], [0.85, 0.25, 0.2], [0.2, 0.45, 0.85]] };
208
+ const s = T(e);
209
+ if (n === "layout.candidate") {
210
+ const c = t.kind === "family" ? s.families.find((a) => a.familyId === t.familyId) : void 0;
211
+ return {
212
+ kind: "choice",
213
+ options: (c == null ? void 0 : c.candidates.map((a) => ({
214
+ value: a.revisionId,
215
+ label: a.label,
216
+ source: "asset-revision"
217
+ }))) ?? []
218
+ };
219
+ }
220
+ return n === "layout.placement" ? {
221
+ kind: "choice",
222
+ options: s.regions.map((c) => ({
223
+ value: c.regionId,
224
+ label: c.label,
225
+ source: "placement-region"
226
+ }))
227
+ } : n === "visual.material-choice" ? {
228
+ kind: "choice",
229
+ options: (t.kind === "family" ? e.assets.filter((a) => {
230
+ var d;
231
+ return (d = s.families.find((r) => r.familyId === t.familyId)) == null ? void 0 : d.candidates.some((r) => r.revisionId === a.revisionId);
232
+ }) : t.kind === "scene-node" ? e.assets.filter((a) => {
233
+ var d;
234
+ return a.revisionId === ((d = W(e, t.sceneNodeId)) == null ? void 0 : d.assetRevisionId);
235
+ }) : []).flatMap((a) => a.variantSets.flatMap((d) => d.options.map((r) => ({
236
+ value: `${d.name}=${r}`,
237
+ label: `${a.label} · ${d.name}=${r}`,
238
+ source: "variant-set"
239
+ }))))
240
+ } : n === "environment.rendering-preset" ? {
241
+ kind: "choice",
242
+ options: [{ value: "studio-room", label: "Viewer RoomEnvironment", source: "rendering-preset" }]
243
+ } : { kind: "number", ...{
244
+ "rigid-body.mass-kg": { min: 0.1, max: 20, step: 0.1 },
245
+ "physics-material.static-friction": { min: 0, max: 2, step: 0.05 },
246
+ "physics-material.dynamic-friction": { min: 0, max: 2, step: 0.05 },
247
+ "physics-material.restitution": { min: 0, max: 1, step: 0.05 },
248
+ "visual.opacity": { min: 0, max: 1, step: 0.01 },
249
+ "joint.position": { min: -Math.PI, max: Math.PI, step: 0.01 },
250
+ "joint.stiffness": { min: 0, max: 1e4, step: 1 },
251
+ "joint.damping": { min: 0, max: 1e3, step: 0.1 },
252
+ "environment.timestep": { min: 1e-4, max: 0.02, step: 1e-4 }
253
+ }[n] ?? { min: 0, max: 1, step: 0.01 } };
254
+ }
255
+ function It(e, n) {
256
+ var m;
257
+ const t = T(e), s = [
258
+ ["family", t.families.map((l) => l.familyId)],
259
+ ["region", t.regions.map((l) => l.regionId)],
260
+ ["contract", t.contracts.map((l) => l.contractId)],
261
+ ["sample", t.samples.map((l) => l.sampleId)]
262
+ ], o = s.find(([, l]) => !!n.entityId && l.includes(n.entityId)) ?? s.find(([l]) => l === n.source);
263
+ if (o && n.entityId && o[1].includes(n.entityId))
264
+ return {
265
+ kind: o[0],
266
+ id: n.entityId,
267
+ ...n.sceneNodeId ? { sceneNodeId: n.sceneNodeId } : {}
268
+ };
269
+ const c = n.entityId ? t.contracts.find((l) => l.terms.some((u) => u.termId === n.entityId)) : void 0;
270
+ if (c)
271
+ return {
272
+ kind: "contract",
273
+ id: c.contractId,
274
+ ...n.sceneNodeId ? { sceneNodeId: n.sceneNodeId } : {}
275
+ };
276
+ const a = n.evidence;
277
+ for (const [l, u] of [
278
+ ["familyId", "family"],
279
+ ["regionId", "region"],
280
+ ["contractId", "contract"],
281
+ ["sampleId", "sample"]
282
+ ]) {
283
+ const A = a[l];
284
+ if (typeof A != "string") continue;
285
+ if ((m = s.find(([h]) => h === u)) == null ? void 0 : m[1].includes(A))
286
+ return {
287
+ kind: u,
288
+ id: A,
289
+ ...n.sceneNodeId ? { sceneNodeId: n.sceneNodeId } : {}
290
+ };
291
+ }
292
+ if (!n.sceneNodeId) return null;
293
+ const d = t.families.find((l) => l.targetNodeIds.includes(n.sceneNodeId));
294
+ if (d) return { kind: "family", id: d.familyId, sceneNodeId: n.sceneNodeId };
295
+ const r = t.regions.find((l) => l.targetNodeIds.includes(n.sceneNodeId) || l.parentNodeId === n.sceneNodeId);
296
+ if (r) return { kind: "region", id: r.regionId, sceneNodeId: n.sceneNodeId };
297
+ const p = t.contracts.find((l) => l.terms.some((u) => u.target.kind === "scene-node" && u.target.sceneNodeId === n.sceneNodeId || u.target.kind === "joint" && u.target.sceneNodeId === n.sceneNodeId));
298
+ return p ? { kind: "contract", id: p.contractId, sceneNodeId: n.sceneNodeId } : null;
299
+ }
300
+ function ye() {
301
+ return {
302
+ rigidBody: "optional",
303
+ articulation: "optional",
304
+ colliderGeometry: "optional",
305
+ physics: "any"
306
+ };
307
+ }
308
+ function ft(e) {
309
+ return Fe({
310
+ ...e,
311
+ candidates: e.candidates.map((n) => ({
312
+ ...n,
313
+ requiredCapabilities: ye()
314
+ }))
315
+ });
316
+ }
317
+ function ut(e, n, t) {
318
+ const s = S(e);
319
+ if (n === "family") {
320
+ const i = s.contracts.map((c) => ({
321
+ ...c,
322
+ terms: c.terms.filter((a) => !(a.target.kind === "family" && a.target.familyId === t))
323
+ })).filter((c) => c.terms.length > 0), o = new Set(i.map((c) => c.contractId));
324
+ return S({
325
+ ...s,
326
+ families: s.families.filter((c) => c.familyId !== t),
327
+ regions: s.regions.map((c) => ({
328
+ ...c,
329
+ familyIds: c.familyIds.filter((a) => a !== t)
330
+ })),
331
+ contracts: i,
332
+ samples: s.samples.filter((c) => o.has(c.contractId))
333
+ });
334
+ }
335
+ if (n === "region") {
336
+ const i = s.contracts.map((o) => {
337
+ const c = [];
338
+ for (const a of o.terms) {
339
+ if (a.domain.kind !== "choice") {
340
+ c.push(a);
341
+ continue;
342
+ }
343
+ const d = a.domain.options.filter((r) => !(r.source === "placement-region" && r.value === t));
344
+ d.length && c.push({ ...a, domain: { ...a.domain, options: d } });
345
+ }
346
+ return { ...o, terms: c };
347
+ }).filter((o) => o.terms.length > 0);
348
+ return S({
349
+ ...s,
350
+ regions: s.regions.filter((o) => o.regionId !== t),
351
+ contracts: i
352
+ });
353
+ }
354
+ return S(n === "contract" ? {
355
+ ...s,
356
+ contracts: s.contracts.filter((i) => i.contractId !== t),
357
+ samples: s.samples.filter((i) => i.contractId !== t)
358
+ } : {
359
+ ...s,
360
+ samples: s.samples.filter((i) => i.sampleId !== t)
361
+ });
362
+ }
363
+ function pt(e, n) {
364
+ const t = S(n), s = new Set(e.assets.map((m) => m.revisionId)), i = new Set(Pe(e.root).map((m) => m.nodeId)), o = t.families.map((m) => ({
365
+ ...m,
366
+ targetNodeIds: m.targetNodeIds.filter((l) => i.has(l)),
367
+ candidates: m.candidates.filter((l) => s.has(l.revisionId))
368
+ })).filter((m) => m.candidates.length > 0), c = new Set(o.map((m) => m.familyId)), a = t.regions.filter((m) => i.has(m.parentNodeId)).map((m) => ({
369
+ ...m,
370
+ familyIds: m.familyIds.filter((l) => c.has(l)),
371
+ targetNodeIds: m.targetNodeIds.filter((l) => i.has(l))
372
+ })), d = new Set(a.map((m) => m.regionId)), r = t.contracts.map((m) => {
373
+ const l = [];
374
+ for (const u of m.terms) {
375
+ if (!Je(u.target, c, s, i)) continue;
376
+ if (u.domain.kind !== "choice") {
377
+ l.push(u);
378
+ continue;
379
+ }
380
+ const A = u.domain.options.filter((N) => N.source === "asset-revision" ? s.has(N.value) : N.source === "placement-region" ? d.has(N.value) : !0);
381
+ A.length && l.push({ ...u, domain: { ...u.domain, options: A } });
382
+ }
383
+ return { ...m, terms: l };
384
+ }).filter((m) => m.terms.length > 0), p = new Set(r.map((m) => m.contractId));
385
+ return S({
386
+ families: o,
387
+ regions: a,
388
+ contracts: r,
389
+ samples: t.samples.filter((m) => p.has(m.contractId))
390
+ });
391
+ }
392
+ function S(e) {
393
+ const {
394
+ families: n,
395
+ regions: t,
396
+ contracts: s,
397
+ samples: i,
398
+ version: o,
399
+ ...c
400
+ } = e;
401
+ return {
402
+ ...D(c),
403
+ ...o === void 0 ? {} : { version: o },
404
+ families: [...n].map(_n).sort(G("familyId")),
405
+ regions: [...t].map(Be).sort(G("regionId")),
406
+ contracts: [...s].map(qe).sort(G("contractId")),
407
+ samples: [...i].map((a) => F(a)).sort(G("sampleId"))
408
+ };
409
+ }
410
+ function Ae(e) {
411
+ const n = S(T(e));
412
+ return oe(U({
413
+ families: n.families,
414
+ regions: n.regions,
415
+ contracts: n.contracts
416
+ }));
417
+ }
418
+ function ge(e) {
419
+ const n = { ...e.domains };
420
+ delete n[H];
421
+ const { domains: t, ...s } = e, { updatedAt: i, ...o } = s.meta;
422
+ return oe(U({
423
+ ...s,
424
+ meta: o,
425
+ assets: [...s.assets].sort(G("revisionId")),
426
+ ...Object.keys(n).length > 0 ? { domains: n } : {}
427
+ }));
428
+ }
429
+ function An(e) {
430
+ return oe(U(S(T(e))));
431
+ }
432
+ function Ee(e) {
433
+ const { sampleHash: n, ...t } = F(e, !0);
434
+ return oe(U(t));
435
+ }
436
+ function gn(e) {
437
+ const n = F({ ...e, sampleHash: "" }, !0), t = Ee(n);
438
+ return F({ ...n, sampleHash: t });
439
+ }
440
+ function ht(e) {
441
+ const n = S(T(e)), t = {
442
+ format: un,
443
+ kind: "generalization-contract-with-resolved-samples",
444
+ sceneId: e.sceneId,
445
+ sceneHash: ge(e),
446
+ contractHash: Ae(e),
447
+ contentHash: An(e),
448
+ contract: {
449
+ families: n.families,
450
+ regions: n.regions,
451
+ contracts: n.contracts
452
+ },
453
+ resolvedSamples: n.samples
454
+ };
455
+ return `${U(t)}
456
+ `;
457
+ }
458
+ function Nt(e) {
459
+ return `${U(F(e))}
460
+ `;
461
+ }
462
+ function yt(e, n = {}) {
463
+ let t;
464
+ try {
465
+ t = JSON.parse(e);
466
+ } catch (d) {
467
+ return $e("GENERALIZATION_SAMPLE_INVALID", `Resolved Sample 不是有效 JSON:${rt(d)}`, null);
468
+ }
469
+ const s = wn(t);
470
+ if (s.length) return { sample: null, diagnostics: s };
471
+ let i = F(t, !0);
472
+ const o = L(t) && typeof t.sampleHash == "string" ? t.sampleHash : null, c = Ee({ ...i, sampleHash: "" });
473
+ if (o && o !== c)
474
+ return $e(
475
+ "GENERALIZATION_SAMPLE_HASH",
476
+ "Resolved Sample sampleHash 与规范化内容不一致。",
477
+ i.sampleId,
478
+ { supplied: o, calculated: c }
479
+ );
480
+ i = { ...i, sampleHash: c }, i = F(i);
481
+ const a = [];
482
+ if (n.document) {
483
+ if (T(n.document).contracts.some((r) => r.contractId === i.contractId) || a.push(I(
484
+ "GENERALIZATION_SAMPLE_INVALID",
485
+ "error",
486
+ "contract",
487
+ i.sampleId,
488
+ `Resolved Sample 引用未知 contractId:${i.contractId}。`,
489
+ { contractId: i.contractId }
490
+ )), n.requireHashes !== !1) {
491
+ const r = Ae(n.document), p = ge(n.document);
492
+ i.contractHash !== r && a.push(I(
493
+ "GENERALIZATION_SAMPLE_CONTRACT_HASH",
494
+ "error",
495
+ "sample",
496
+ i.sampleId,
497
+ "Resolved Sample contractHash 与当前泛化契约不一致。",
498
+ { supplied: i.contractHash, calculated: r }
499
+ )), i.sceneHash !== p && a.push(I(
500
+ "GENERALIZATION_SAMPLE_SCENE_HASH",
501
+ "error",
502
+ "sample",
503
+ i.sampleId,
504
+ "Resolved Sample sceneHash 与当前基础场景不一致。",
505
+ { supplied: i.sceneHash, calculated: p }
506
+ ));
507
+ }
508
+ a.push(...ae(i, n.document, n.contractId));
509
+ }
510
+ return {
511
+ sample: a.some((d) => d.level === "error") ? null : i,
512
+ diagnostics: a
513
+ };
514
+ }
515
+ function Re(e) {
516
+ var i;
517
+ const n = [], t = (i = e.domains) == null ? void 0 : i[H];
518
+ if (t && !Gn(t.data))
519
+ return {
520
+ ok: !1,
521
+ diagnostics: [I(
522
+ "GENERALIZATION_INVALID_CONTRACT",
523
+ "error",
524
+ "scene",
525
+ null,
526
+ "generalization section 必须包含 families、regions、contracts、samples 四个数组,且条目结构可读。",
527
+ {}
528
+ )]
529
+ };
530
+ const s = T(e);
531
+ Sn(s, n), Tn(e, s, n), On(e, s, n), kn(e, s, n);
532
+ for (const o of s.samples)
533
+ n.push(...ae(o, e).map((c) => ({
534
+ ...c,
535
+ level: c.level === "error" ? "warning" : c.level,
536
+ message: `Stored sample 已与当前场景/契约不完全一致:${c.message}`
537
+ })));
538
+ return Zn(e, n), {
539
+ ok: !n.some((o) => o.level === "error"),
540
+ diagnostics: n
541
+ };
542
+ }
543
+ function At(e, n, t = {}) {
544
+ const i = ae(n, e, t.contractId).find((h) => h.level === "error");
545
+ if (i) throw new Error(`${i.code}: ${i.message}`);
546
+ const o = D(e), c = S(T(o)), a = c.contracts.find((h) => h.contractId === n.contractId);
547
+ if (!a) throw new Error(`Randomization contract not found: ${n.contractId}.`);
548
+ const d = new Map(ue(o).map((h) => [h.nodeId, D(h)])), r = new Map(c.families.map((h) => [h.familyId, h])), p = new Set(n.placements.map((h) => h.sceneNodeId));
549
+ for (const h of n.familyResolutions) {
550
+ const y = r.get(h.familyId);
551
+ if (!y) continue;
552
+ const E = y.targetNodeIds.filter((_) => p.has(_)), x = E.length ? E : y.targetNodeIds;
553
+ for (const _ of x) {
554
+ const O = d.get(_);
555
+ O && d.set(_, { ...O, assetRevisionId: h.assetRevisionId });
556
+ }
557
+ }
558
+ for (const h of n.placements) {
559
+ const y = d.get(h.sceneNodeId), E = h.regionId ? c.regions.find((x) => x.regionId === h.regionId) : null;
560
+ y && (E == null ? void 0 : E.parentNodeId) !== h.sceneNodeId && d.set(h.sceneNodeId, { ...y, localTransform: D(h.transform) });
561
+ }
562
+ const m = [], l = new Map(a.terms.map((h) => [h.termId, h]));
563
+ let u = o.environment;
564
+ for (const h of n.termValues) {
565
+ const y = l.get(h.termId);
566
+ if (!y) {
567
+ m.push({ termId: h.termId, applied: !1, reason: "contract term not found" });
568
+ continue;
569
+ }
570
+ if (y.backendCapability.status === "unsupported") {
571
+ m.push({
572
+ termId: y.termId,
573
+ applied: !1,
574
+ reason: y.backendCapability.reason ?? "MuJoCo Preview 不支持该参数"
575
+ });
576
+ continue;
577
+ }
578
+ const E = $n(y.target, c, d);
579
+ if (y.kind === "environment.gravity" || y.kind === "environment.timestep") {
580
+ if (y.kind === "environment.gravity" && h.value.kind === "vector3") {
581
+ u = {
582
+ ...u,
583
+ physics: { ...u.physics, gravity: [...h.value.value] }
584
+ }, m.push({ termId: y.termId, applied: !0 });
585
+ continue;
586
+ }
587
+ if (y.kind === "environment.timestep" && h.value.kind === "number") {
588
+ u = {
589
+ ...u,
590
+ physics: { ...u.physics, timeStepSeconds: h.value.value }
591
+ }, m.push({ termId: y.termId, applied: !0 });
592
+ continue;
593
+ }
594
+ m.push({ termId: y.termId, applied: !1, reason: "sample value type mismatch" });
595
+ continue;
596
+ }
597
+ if (y.kind === "layout.candidate" || y.kind === "layout.placement") {
598
+ m.push({
599
+ termId: y.termId,
600
+ applied: !0,
601
+ reason: y.kind === "layout.candidate" ? "已通过 familyResolutions 应用" : "已通过 placements 应用"
602
+ });
603
+ continue;
604
+ }
605
+ if (!E.length) {
606
+ m.push({ termId: y.termId, applied: !1, reason: "target node not found" });
607
+ continue;
608
+ }
609
+ let x = !0;
610
+ for (const _ of E) {
611
+ const O = d.get(_);
612
+ if (!O) {
613
+ x = !1;
614
+ continue;
615
+ }
616
+ const k = Vn(O, y, h.value);
617
+ k ? d.set(_, k) : x = !1;
618
+ }
619
+ m.push({
620
+ termId: y.termId,
621
+ applied: x,
622
+ ...x ? {} : { reason: "当前 SceneDocument/MuJoCo Preview 无法应用该值" }
623
+ });
624
+ }
625
+ const A = Cn(o.root, d);
626
+ return { document: {
627
+ ...o,
628
+ root: A,
629
+ environment: u,
630
+ meta: { ...o.meta, updatedAt: t.now ?? o.meta.updatedAt }
631
+ }, applications: m };
632
+ }
633
+ function gt(e, n) {
634
+ const t = Re(e).diagnostics.filter((N) => N.level === "error");
635
+ if (t.length) throw new Error(t.map((N) => N.message).join(`
636
+ `));
637
+ const s = S(T(e)), i = n.contractId ? s.contracts.find((N) => N.contractId === n.contractId) : s.contracts[0];
638
+ if (!i) throw new Error("生成随机预览前需要至少一个 Randomization Contract。");
639
+ const o = We(i), c = s.families.filter((N) => o.has(N.familyId)), a = Number.isFinite(n.seed) ? Math.trunc(n.seed) : 0, d = En(a), r = c.map((N) => {
640
+ if (N.selectionMode === "fixed")
641
+ return {
642
+ familyId: N.familyId,
643
+ assetRevisionId: N.fixedRevisionId ?? N.candidates[0].revisionId
644
+ };
645
+ const h = N.candidates[te(d, N.candidates.length)];
646
+ if (!h) throw new Error(`Family ${N.familyId} 没有可用候选。`);
647
+ return { familyId: N.familyId, assetRevisionId: h.revisionId };
648
+ }), p = [], m = /* @__PURE__ */ new Set();
649
+ for (const N of c)
650
+ for (const h of N.targetNodeIds) {
651
+ if (m.has(h)) continue;
652
+ const y = s.regions.filter((_) => {
653
+ if (_.parentNodeId === h || !_.familyIds.includes(N.familyId)) return !1;
654
+ const O = _.targetNodeIds.includes(h);
655
+ return !_.targetNodeIds.length || O;
656
+ }), E = y[te(d, y.length)];
657
+ if (!E) continue;
658
+ const x = vn(e, h, E, d);
659
+ x && (p.push({ sceneNodeId: h, regionId: E.regionId, transform: x }), m.add(h));
660
+ }
661
+ const l = i.terms.map((N) => ({
662
+ termId: N.termId,
663
+ value: Rn(N.domain, d)
664
+ })), u = gn({
665
+ format: he,
666
+ sampleId: `preview_${a}_${i.contractId}`,
667
+ contractId: i.contractId,
668
+ source: {
669
+ simulationTool: "Sim Studio Preview Generator",
670
+ sourceVersion: "preview-only@1"
671
+ },
672
+ createdAt: n.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
673
+ seed: a,
674
+ samplerVersion: "studio-preview@1",
675
+ contractHash: Ae(e),
676
+ sceneHash: ge(e),
677
+ familyResolutions: r,
678
+ placements: p,
679
+ termValues: l
680
+ }), A = ae(u, e).filter((N) => N.level === "error");
681
+ if (A.length) throw new Error(A.map((N) => N.message).join(`
682
+ `));
683
+ return { sample: u, seed: a, contractId: i.contractId };
684
+ }
685
+ function En(e) {
686
+ let n = e >>> 0;
687
+ return () => {
688
+ n = n + 1831565813 >>> 0;
689
+ let t = n;
690
+ return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
691
+ };
692
+ }
693
+ function te(e, n) {
694
+ return n > 0 ? Math.min(n - 1, Math.floor(e() * n)) : -1;
695
+ }
696
+ function w(e, n, t) {
697
+ return t <= n ? n : n + e() * (t - n);
698
+ }
699
+ function Rn(e, n) {
700
+ if (e.kind === "number") {
701
+ const s = w(n, e.min, e.max), i = e.step ? e.min + Math.round((s - e.min) / e.step) * e.step : s;
702
+ return {
703
+ kind: "number",
704
+ value: Math.min(e.max, Math.max(e.min, Number(i.toFixed(9))))
705
+ };
706
+ }
707
+ if (e.kind === "vector3")
708
+ return {
709
+ kind: "vector3",
710
+ value: [0, 1, 2].map((s) => w(n, e.min[s], e.max[s]))
711
+ };
712
+ if (e.kind === "color") {
713
+ const s = e.options[te(n, e.options.length)];
714
+ if (!s) throw new Error("Randomization color domain 没有可选项。");
715
+ return { kind: "color", value: [...s] };
716
+ }
717
+ const t = e.options[te(n, e.options.length)];
718
+ if (!t) throw new Error("Randomization choice domain 没有可选项。");
719
+ return { kind: "choice", value: t.value };
720
+ }
721
+ function vn(e, n, t, s) {
722
+ const i = W(e, n), o = Ie(e, t), c = In(e.root, n);
723
+ if (!i || !o || !c) return null;
724
+ let a = Mn(t, s);
725
+ t.constraints.anchor === "grid" && (a = a.map((u) => Math.round(u / 0.05) * 0.05));
726
+ const d = t.constraints.yawRadians ? w(s, t.constraints.yawRadians.min, t.constraints.yawRadians.max) : 0, r = [0, 0, Math.sin(d / 2), Math.cos(d / 2)], p = j(o, {
727
+ position: a,
728
+ rotation: r,
729
+ scale: [1, 1, 1]
730
+ }), m = b(e.root, c.parent.nodeId);
731
+ return m ? { ...j(ie(m), p), scale: [...i.localTransform.scale] } : null;
732
+ }
733
+ function Mn(e, n) {
734
+ const t = Math.max(0, e.constraints.marginM);
735
+ if (e.shape.kind === "rectangle") {
736
+ const d = Math.max(0, e.shape.widthM / 2 - t), r = Math.max(0, e.shape.heightM / 2 - t);
737
+ return [
738
+ w(n, -d, d),
739
+ w(n, -r, r),
740
+ 0
741
+ ];
742
+ }
743
+ if (e.shape.kind === "box") {
744
+ const d = Math.max(0, e.shape.widthM / 2 - t), r = Math.max(0, e.shape.depthM / 2 - t), p = Math.max(0, e.shape.heightM / 2 - t);
745
+ return [
746
+ w(n, -d, d),
747
+ w(n, -r, r),
748
+ w(n, -p, p)
749
+ ];
750
+ }
751
+ const s = Math.min(...e.shape.points.map((d) => d[0])) + t, i = Math.max(...e.shape.points.map((d) => d[0])) - t, o = Math.min(...e.shape.points.map((d) => d[1])) + t, c = Math.max(...e.shape.points.map((d) => d[1])) - t;
752
+ for (let d = 0; d < 128; d += 1) {
753
+ const r = [
754
+ w(n, Math.min(s, i), Math.max(s, i)),
755
+ w(n, Math.min(o, c), Math.max(o, c))
756
+ ];
757
+ if (Ln(r, e.shape.points)) return [r[0], r[1], 0];
758
+ }
759
+ const a = [
760
+ e.shape.points.reduce((d, r) => d + r[0], 0) / e.shape.points.length,
761
+ e.shape.points.reduce((d, r) => d + r[1], 0) / e.shape.points.length
762
+ ];
763
+ return [a[0], a[1], 0];
764
+ }
765
+ function Ln(e, n) {
766
+ let t = !1;
767
+ for (let s = 0, i = n.length - 1; s < n.length; i = s++) {
768
+ const o = n[s], c = n[i];
769
+ o[1] > e[1] != c[1] > e[1] && e[0] < (c[0] - o[0]) * (e[1] - o[1]) / (c[1] - o[1] || Number.EPSILON) + o[0] && (t = !t);
770
+ }
771
+ return t;
772
+ }
773
+ function Et(e, n) {
774
+ return Re(e).diagnostics.filter((t) => t.entityId === n);
775
+ }
776
+ function Rt() {
777
+ return Object.entries(re).filter(([, e]) => e.supported).map(([e]) => e);
778
+ }
779
+ function xn(e) {
780
+ return re[e];
781
+ }
782
+ function _n(e) {
783
+ var n;
784
+ return {
785
+ ...e,
786
+ targetNodeIds: se(e.targetNodeIds),
787
+ candidates: je(e.candidates),
788
+ ...e.selectionMode === "fixed" ? { fixedRevisionId: e.fixedRevisionId ?? ((n = e.candidates[0]) == null ? void 0 : n.revisionId) ?? "" } : {}
789
+ };
790
+ }
791
+ function je(e) {
792
+ return [...e].map((n) => ({
793
+ ...n,
794
+ requiredCapabilities: { ...n.requiredCapabilities },
795
+ ...n.constraints ? {
796
+ constraints: {
797
+ ...n.constraints,
798
+ ...n.constraints.maxSizeM ? { maxSizeM: [...n.constraints.maxSizeM] } : {},
799
+ ...n.constraints.allowedCategories ? { allowedCategories: se(n.constraints.allowedCategories) } : {}
800
+ }
801
+ } : {}
802
+ })).sort(G("revisionId"));
803
+ }
804
+ function Be(e) {
805
+ return {
806
+ ...D(e),
807
+ familyIds: se(e.familyIds),
808
+ targetNodeIds: se(e.targetNodeIds),
809
+ frame: Qe(e.frame),
810
+ shape: e.shape.kind === "polygon" ? {
811
+ ...e.shape,
812
+ points: [...e.shape.points].map((n) => [...n])
813
+ } : { ...e.shape },
814
+ constraints: {
815
+ ...e.constraints,
816
+ yawRadians: e.constraints.yawRadians ? { ...e.constraints.yawRadians } : null
817
+ }
818
+ };
819
+ }
820
+ function qe(e) {
821
+ return {
822
+ ...e,
823
+ terms: [...e.terms].map((n) => ({
824
+ ...D(n),
825
+ constraints: [...n.constraints].map((t) => ({ ...t }))
826
+ })).sort(G("termId"))
827
+ };
828
+ }
829
+ function F(e, n = !1) {
830
+ return {
831
+ format: he,
832
+ sampleId: e.sampleId,
833
+ contractId: e.contractId,
834
+ source: { ...e.source },
835
+ createdAt: e.createdAt,
836
+ seed: e.seed,
837
+ samplerVersion: e.samplerVersion,
838
+ contractHash: e.contractHash,
839
+ sceneHash: e.sceneHash,
840
+ familyResolutions: [...e.familyResolutions].map((t) => ({ ...t })).sort(G("familyId")),
841
+ placements: [...e.placements].map((t) => ({
842
+ ...t,
843
+ transform: Qe(t.transform)
844
+ })).sort(G("sceneNodeId")),
845
+ termValues: [...e.termValues].map((t) => ({ termId: t.termId, value: D(t.value) })).sort(G("termId")),
846
+ sampleHash: e.sampleHash ?? (n ? "" : Ee({ ...e, sampleHash: "" }))
847
+ };
848
+ }
849
+ function Sn(e, n) {
850
+ for (const [s, i] of [
851
+ ["family", e.families.map((o) => o.familyId)],
852
+ ["region", e.regions.map((o) => o.regionId)],
853
+ ["contract", e.contracts.map((o) => o.contractId)],
854
+ ["sample", e.samples.map((o) => o.sampleId)]
855
+ ])
856
+ for (const o of Ce(i))
857
+ n.push(I("GENERALIZATION_DUPLICATE_ID", "error", "scene", o, `重复的 ${s} ID:${o}。`, { kind: s, id: o }));
858
+ const t = e.contracts.flatMap((s) => s.terms.map((i) => i.termId));
859
+ for (const s of Ce(t))
860
+ n.push(I("GENERALIZATION_DUPLICATE_ID", "error", "contract", s, `重复的 termId:${s}。`, { id: s }));
861
+ }
862
+ function Tn(e, n, t) {
863
+ var i, o, c;
864
+ const s = new Map(e.assets.map((a) => [a.revisionId, a]));
865
+ for (const a of n.families) {
866
+ (!a.familyId || !a.label.trim() || !a.semanticTag.trim()) && t.push(I("GENERALIZATION_INVALID_FAMILY", "error", "contract", a.familyId, "Object Family 必须有 ID、label 和 semanticTag。", {})), a.candidates.length || t.push(I("GENERALIZATION_INVALID_FAMILY", "error", "contract", a.familyId, "Object Family 至少需要一个真实候选。", {}));
867
+ const d = /* @__PURE__ */ new Set();
868
+ for (const r of a.candidates) {
869
+ d.has(r.revisionId) && t.push(I("GENERALIZATION_INVALID_FAMILY", "error", "asset", r.revisionId, `候选重复:${r.revisionId}。`, { familyId: a.familyId })), d.add(r.revisionId);
870
+ const p = s.get(r.revisionId);
871
+ if (!p) {
872
+ t.push(I("GENERALIZATION_MISSING_REVISION", "error", "asset", r.revisionId, `候选引用不存在的 assetRevisionId:${r.revisionId}。`, { familyId: a.familyId }));
873
+ continue;
874
+ }
875
+ const m = Qn(p, r);
876
+ if (m.length && t.push(I(
877
+ "GENERALIZATION_CAPABILITY_MISMATCH",
878
+ "error",
879
+ "asset",
880
+ r.revisionId,
881
+ `候选 ${p.label} 不满足 Family 能力要求:${m.join(";")}。`,
882
+ { familyId: a.familyId, revisionId: p.revisionId, mismatch: m }
883
+ )), Xe(p, a.semanticTag) || t.push(I(
884
+ "GENERALIZATION_INVALID_FAMILY",
885
+ "error",
886
+ "asset",
887
+ r.revisionId,
888
+ `候选 ${p.label} 的真实分类/语义不匹配 Family tag "${a.semanticTag}"。`,
889
+ {
890
+ familyId: a.familyId,
891
+ revisionId: p.revisionId,
892
+ category: p.category ?? null,
893
+ semantic: p.semantic ?? null
894
+ }
895
+ )), (i = r.constraints) != null && i.maxSizeM && p.bounds) {
896
+ const l = Xn(p.bounds);
897
+ l.some((u, A) => u > r.constraints.maxSizeM[A] + 1e-6) && t.push(I(
898
+ "GENERALIZATION_INVALID_FAMILY",
899
+ "error",
900
+ "asset",
901
+ r.revisionId,
902
+ `候选 ${p.label} 尺寸 ${Ze(l)} 超过约束 ${Ze(r.constraints.maxSizeM)}。`,
903
+ { size: l, maxSizeM: r.constraints.maxSizeM }
904
+ ));
905
+ }
906
+ (c = (o = r.constraints) == null ? void 0 : o.allowedCategories) != null && c.length && (!p.category || !r.constraints.allowedCategories.includes(p.category)) && t.push(I(
907
+ "GENERALIZATION_INVALID_FAMILY",
908
+ "error",
909
+ "asset",
910
+ r.revisionId,
911
+ `候选 ${p.label} 分类不在允许范围内。`,
912
+ { category: p.category ?? null, allowed: r.constraints.allowedCategories }
913
+ ));
914
+ }
915
+ for (const r of a.targetNodeIds)
916
+ W(e, r) || t.push(I("GENERALIZATION_TARGET_INVALID", "error", "scene", a.familyId, `Family 目标节点不存在或不是 AssetNode:${r}。`, { nodeId: r }));
917
+ a.selectionMode === "fixed" && (!a.fixedRevisionId || !d.has(a.fixedRevisionId)) && t.push(I(
918
+ "GENERALIZATION_FIXED_SELECTION_INVALID",
919
+ "error",
920
+ "contract",
921
+ a.familyId,
922
+ "固定选择的 assetRevisionId 不在候选集中。",
923
+ { fixedRevisionId: a.fixedRevisionId ?? null }
924
+ ));
925
+ }
926
+ }
927
+ function On(e, n, t) {
928
+ const s = new Map(n.families.map((i) => [i.familyId, i]));
929
+ new Map(n.regions.map((i) => [i.regionId, i]));
930
+ for (const i of n.regions) {
931
+ (!i.regionId || !i.label.trim()) && t.push(I("GENERALIZATION_INVALID_REGION", "error", "region", i.regionId, "Placement Region 必须有 ID 和 label。", {})), et(i.shape) || t.push(I("GENERALIZATION_INVALID_REGION", "error", "region", i.regionId, "Placement Region 形状尺寸必须为正,polygon 至少需要三个不同点。", { shape: i.shape })), ve(i.frame) || t.push(I("GENERALIZATION_INVALID_REGION", "error", "region", i.regionId, "Placement Region frame 必须是有限的单位旋转和正缩放。", { frame: i.frame })), (i.constraints.maxStackLayers < 1 || i.constraints.maxStackLayers > 3) && t.push(I("GENERALIZATION_INVALID_REGION", "error", "region", i.regionId, "maxStackLayers 仅支持 1 到 3。", {})), i.constraints.marginM < 0 && t.push(I("GENERALIZATION_INVALID_REGION", "error", "region", i.regionId, "margin 不能为负。", {})), i.constraints.yawRadians && (i.constraints.yawRadians.min > i.constraints.yawRadians.max || i.constraints.yawRadians.min < -Math.PI - 1e-9 || i.constraints.yawRadians.max > Math.PI + 1e-9) && t.push(I("GENERALIZATION_INVALID_REGION", "error", "region", i.regionId, "yaw 范围必须位于 -π..π,且 min 不大于 max。", {}));
932
+ for (const r of i.familyIds)
933
+ s.has(r) || t.push(I("GENERALIZATION_TARGET_INVALID", "error", "region", i.regionId, `Region 引用未知 Family:${r}。`, { familyId: r }));
934
+ if (!ze(e.root, i.parentNodeId)) {
935
+ t.push(I("GENERALIZATION_REGION_PARENT_INVALID", "error", "region", i.regionId, `Region 父节点不存在:${i.parentNodeId}。`, { parentNodeId: i.parentNodeId }));
936
+ continue;
937
+ }
938
+ i.semantic === "support-surface" && i.normalAxis !== "+Z" && t.push(I("GENERALIZATION_REGION_SUPPORT", "error", "region", i.regionId, "support-surface 的 normalAxis 必须为 +Z。", { normalAxis: i.normalAxis }));
939
+ const c = b(e.root, i.parentNodeId), a = c ? j(c, i.frame) : null, d = K(e, i.parentNodeId);
940
+ a && d && !Un(a, i, d) && t.push(I(
941
+ "GENERALIZATION_REGION_SUPPORT",
942
+ "warning",
943
+ "region",
944
+ i.regionId,
945
+ "Region 中心未落在父节点包围盒附近,可能悬空。",
946
+ { parentBounds: d, regionPosition: a.position }
947
+ ));
948
+ for (const r of i.targetNodeIds) {
949
+ const p = W(e, r);
950
+ if (!p) {
951
+ t.push(I("GENERALIZATION_TARGET_INVALID", "error", "region", i.regionId, `Region 目标节点不存在:${r}。`, { nodeId: r }));
952
+ continue;
953
+ }
954
+ const m = i.familyIds.map((l) => s.get(l)).filter((l) => !!l);
955
+ if (m.length ? m.some((l) => l.targetNodeIds.includes(r)) || t.push(I(
956
+ "GENERALIZATION_REGION_TARGET",
957
+ "warning",
958
+ "region",
959
+ i.regionId,
960
+ `AssetNode 目标 ${p.label} 不属于当前 Region 关联的 Family,因此不会参与随机预览。`,
961
+ {
962
+ nodeId: r,
963
+ familyIds: m.map((l) => l.familyId)
964
+ },
965
+ r
966
+ )) : t.push(I(
967
+ "GENERALIZATION_REGION_TARGET",
968
+ "warning",
969
+ "region",
970
+ i.regionId,
971
+ "Region 的 AssetNode 目标只会缩窄已关联 Family;当前 Region 没有关联 Family,因此该目标不会参与随机预览。",
972
+ { nodeId: r },
973
+ r
974
+ )), r === i.parentNodeId && t.push(I(
975
+ "GENERALIZATION_REGION_TARGET",
976
+ "warning",
977
+ "region",
978
+ i.regionId,
979
+ "Region 的直接目标不能同时是自己的父节点;随机预览会跳过该 placement。",
980
+ { nodeId: r },
981
+ r
982
+ )), !!i.familyIds.length)
983
+ for (const l of i.familyIds) {
984
+ const u = s.get(l);
985
+ if (u)
986
+ for (const A of u.candidates) {
987
+ const N = P(e, A.revisionId);
988
+ if (!(N != null && N.bounds) || !a) continue;
989
+ const h = b(e.root, r);
990
+ if (!h) continue;
991
+ const y = Fn(
992
+ Hn(N.bounds, h),
993
+ a
994
+ ), E = ne(i.shape, i.constraints.marginM);
995
+ (i.semantic === "support-surface" || i.semantic === "work-area" ? qn(y, E) : Bn(y, E)) && t.push(I(
996
+ "GENERALIZATION_REGION_FIT",
997
+ "error",
998
+ "region",
999
+ i.regionId,
1000
+ `候选 ${N.label} 放不进 Region ${i.label}。`,
1001
+ { familyId: l, revisionId: N.revisionId, localBounds: y, envelope: E },
1002
+ r
1003
+ ));
1004
+ }
1005
+ }
1006
+ }
1007
+ }
1008
+ for (let i = 0; i < n.regions.length; i += 1)
1009
+ for (let o = i + 1; o < n.regions.length; o += 1) {
1010
+ const c = n.regions[i], a = n.regions[o];
1011
+ if (c.parentNodeId !== a.parentNodeId || c.semantic !== "work-area" || a.semantic !== "work-area") continue;
1012
+ const d = Ie(e, c), r = Ie(e, a);
1013
+ if (!d || !r) continue;
1014
+ const p = C(ne(c.shape, 0), d), m = C(ne(a.shape, 0), r);
1015
+ fe(p, m) > 1e-6 && t.push(I(
1016
+ "GENERALIZATION_REGION_OVERLAP",
1017
+ "warning",
1018
+ "region",
1019
+ c.regionId,
1020
+ `work-area Region ${c.regionId} 与 ${a.regionId} 初始范围重叠。`,
1021
+ { otherRegionId: a.regionId, overlapVolume: fe(p, m) }
1022
+ ));
1023
+ }
1024
+ }
1025
+ function kn(e, n, t) {
1026
+ var a;
1027
+ const s = new Set(n.families.map((d) => d.familyId)), i = new Set(n.regions.map((d) => d.regionId)), o = new Set(e.assets.map((d) => d.revisionId)), c = new Set(Pe(e.root).map((d) => d.nodeId));
1028
+ for (const d of n.contracts) {
1029
+ (!d.contractId || !d.label.trim() || !d.terms.length) && t.push(I("GENERALIZATION_INVALID_CONTRACT", "error", "contract", d.contractId, "Randomization Contract 必须有 ID、label 和至少一个 term。", {}));
1030
+ for (const r of d.terms) {
1031
+ const p = re[r.kind];
1032
+ if (!p) {
1033
+ t.push(I("GENERALIZATION_INVALID_CONTRACT", "error", "contract", r.termId, `未知 term kind:${String(r.kind)}。`, {}));
1034
+ continue;
1035
+ }
1036
+ if (p.operations.includes(r.operation) || t.push(I("GENERALIZATION_INVALID_CONTRACT", "error", "contract", r.termId, `${r.kind} 不支持 operation=${r.operation}。`, { allowed: p.operations })), r.domain.kind !== p.domain ? t.push(I("GENERALIZATION_DOMAIN_INVALID", "error", "contract", r.termId, `${r.kind} 需要 ${p.domain} domain。`, { actual: r.domain.kind })) : nt(r.domain) || t.push(I("GENERALIZATION_DOMAIN_INVALID", "error", "contract", r.termId, `${r.termId} 的 domain 范围非法。`, { domain: r.domain })), r.unit !== p.unit && t.push(I("GENERALIZATION_DOMAIN_INVALID", "error", "contract", r.termId, `${r.kind} unit 必须为 ${p.unit}。`, { actual: r.unit })), p.targets.includes(r.target.kind) || t.push(I("GENERALIZATION_TARGET_INVALID", "error", "contract", r.termId, `${r.kind} 不支持 target=${r.target.kind}。`, { allowed: p.targets })), Je(r.target, s, o, c) || t.push(I("GENERALIZATION_TARGET_INVALID", "error", "contract", r.termId, "term target selector 引用不存在的数据。", { target: r.target })), (!p.supported || r.backendCapability.status === "unsupported") && t.push(I(
1037
+ "GENERALIZATION_UNSUPPORTED_TERM",
1038
+ "warning",
1039
+ "mujoco",
1040
+ r.termId,
1041
+ `MuJoCo Preview 不支持 ${r.kind},导入 sample 时必须标记为未应用。`,
1042
+ { reason: r.backendCapability.reason ?? p.reason ?? "unsupported" }
1043
+ )), fn(r.backendCapability, Ve(r.kind)) || t.push(I(
1044
+ "GENERALIZATION_UNSUPPORTED_TERM",
1045
+ "warning",
1046
+ "mujoco",
1047
+ r.termId,
1048
+ "term backendCapability 与 Studio 当前能力表不一致。",
1049
+ { declared: r.backendCapability, expected: Ve(r.kind) }
1050
+ )), r.mode === "interval" && !r.constraints.some((m) => m.kind === "interval-seconds" && (m.value ?? 0) > 0) && t.push(I("GENERALIZATION_INVALID_CONTRACT", "error", "contract", r.termId, "interval mode 必须声明正 interval-seconds 约束。", {})), r.kind === "visual.material-choice" && r.domain.kind === "choice")
1051
+ for (const m of r.domain.options)
1052
+ tt(e, r.target, m.value) || t.push(I("GENERALIZATION_TARGET_INVALID", "error", "asset", r.termId, `材质选择 ${m.value} 不来自真实 variantSet。`, { option: m }));
1053
+ if (r.kind === "layout.candidate" && r.domain.kind === "choice") {
1054
+ const m = r.target.kind === "family" ? r.target.familyId : null, l = new Set(m ? ((a = n.families.find((u) => u.familyId === m)) == null ? void 0 : a.candidates.map((u) => u.revisionId)) ?? [] : []);
1055
+ for (const u of r.domain.options)
1056
+ l.has(u.value) || t.push(I("GENERALIZATION_DOMAIN_INVALID", "error", "contract", r.termId, `候选 option ${u.value} 不在目标 Family 中。`, {}));
1057
+ }
1058
+ if (r.kind === "layout.placement" && r.domain.kind === "choice")
1059
+ for (const m of r.domain.options)
1060
+ i.has(m.value) || t.push(I("GENERALIZATION_DOMAIN_INVALID", "error", "contract", r.termId, `区域 option ${m.value} 不存在。`, {}));
1061
+ }
1062
+ }
1063
+ }
1064
+ function ae(e, n, t = e.contractId) {
1065
+ const s = [], i = T(n), o = i.contracts.find((l) => l.contractId === t);
1066
+ if (!o)
1067
+ return s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `未知 contractId:${t}。`, {})), s;
1068
+ const c = new Map(i.families.map((l) => [l.familyId, l])), a = /* @__PURE__ */ new Set();
1069
+ for (const l of e.familyResolutions) {
1070
+ a.has(l.familyId) && s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `family 选择重复:${l.familyId}。`, {})), a.add(l.familyId);
1071
+ const u = c.get(l.familyId);
1072
+ if (!u) {
1073
+ s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `Sample 引用未知 family:${l.familyId}。`, {}));
1074
+ continue;
1075
+ }
1076
+ u.candidates.some((A) => A.revisionId === l.assetRevisionId) || s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `Family ${u.familyId} 选择了候选之外的 revision。`, { revisionId: l.assetRevisionId })), u.selectionMode === "fixed" && l.assetRevisionId !== u.fixedRevisionId && s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `Family ${u.familyId} 为固定选择,Sample 选择了其他候选。`, { expected: u.fixedRevisionId, actual: l.assetRevisionId }));
1077
+ }
1078
+ const d = We(o);
1079
+ for (const l of i.families)
1080
+ l.selectionMode === "resolved-sample" && !a.has(l.familyId) && d.has(l.familyId) && s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `Sample 缺少 Contract 引用的 Family ${l.familyId} 候选选择。`, { familyId: l.familyId }));
1081
+ const r = /* @__PURE__ */ new Set();
1082
+ for (const l of e.placements) {
1083
+ r.has(l.sceneNodeId) && s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `节点 placement 重复:${l.sceneNodeId}。`, {})), r.add(l.sceneNodeId), W(n, l.sceneNodeId) || s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `placement 引用未知 AssetNode:${l.sceneNodeId}。`, {}, l.sceneNodeId));
1084
+ const u = l.regionId ? i.regions.find((A) => A.regionId === l.regionId) : null;
1085
+ l.regionId && !u && s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `placement 引用未知 Region:${l.regionId}。`, {}, l.sceneNodeId)), (u == null ? void 0 : u.parentNodeId) === l.sceneNodeId && s.push(I(
1086
+ "GENERALIZATION_SAMPLE_INVALID",
1087
+ "warning",
1088
+ "sample",
1089
+ e.sampleId,
1090
+ "placement 的目标节点同时是 Region 父节点;预览会跳过该自引用移动。",
1091
+ { regionId: u.regionId },
1092
+ l.sceneNodeId
1093
+ )), ve(l.transform) || s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `placement transform 非法:${l.sceneNodeId}。`, {}, l.sceneNodeId));
1094
+ }
1095
+ const p = new Map(o.terms.map((l) => [l.termId, l])), m = /* @__PURE__ */ new Set();
1096
+ for (const l of e.termValues) {
1097
+ m.has(l.termId) && s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `term value 重复:${l.termId}。`, {})), m.add(l.termId);
1098
+ const u = p.get(l.termId);
1099
+ if (!u) {
1100
+ s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `Sample 引用契约外 term:${l.termId}。`, {}));
1101
+ continue;
1102
+ }
1103
+ const A = Dn(l.value, u.domain);
1104
+ A && s.push(I("GENERALIZATION_SAMPLE_RANGE", "error", "sample", e.sampleId, `${u.termId} 的 sample 值超出合法 domain:${A}`, { value: l.value, domain: u.domain })), u.mode === "interval" && s.push(I("GENERALIZATION_UNSUPPORTED_TERM", "warning", "mujoco", u.termId, "interval 采样由外部平台执行;Studio Preview 仅显示单帧参数。", {}));
1105
+ }
1106
+ for (const l of o.terms)
1107
+ m.has(l.termId) || s.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", e.sampleId, `Sample 缺少 term 值:${l.termId}。`, {}));
1108
+ return s;
1109
+ }
1110
+ function Ue(e, n) {
1111
+ const t = [];
1112
+ if (!L(e))
1113
+ return [I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", n, "Resolved Sample 必须是 JSON 对象。", {})];
1114
+ const s = q(e, [
1115
+ "format",
1116
+ "sampleId",
1117
+ "contractId",
1118
+ "source",
1119
+ "createdAt",
1120
+ "seed",
1121
+ "samplerVersion",
1122
+ "contractHash",
1123
+ "sceneHash",
1124
+ "familyResolutions",
1125
+ "placements",
1126
+ "termValues",
1127
+ "sampleHash"
1128
+ ]);
1129
+ if (s.length && t.push(I("GENERALIZATION_SAMPLE_UNKNOWN_FIELD", "error", "sample", n, `Resolved Sample 含未知字段:${s.join(", ")}。`, { unknown: s })), e.format !== he || !R(e.sampleId) || !R(e.contractId) || !L(e.source) || !R(e.source.simulationTool) || e.source.sourceVersion !== void 0 && typeof e.source.sourceVersion != "string" || !ot(e.createdAt) || !$(e.seed) || !Number.isInteger(e.seed) || !R(e.samplerVersion) || typeof e.contractHash != "string" || !le.test(e.contractHash) || typeof e.sceneHash != "string" || !le.test(e.sceneHash) || e.sampleHash !== void 0 && (typeof e.sampleHash != "string" || !le.test(e.sampleHash)) || !Array.isArray(e.familyResolutions) || !Array.isArray(e.placements) || !Array.isArray(e.termValues))
1130
+ return t.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", n, "Resolved Sample 顶层字段类型或格式非法。", {})), t;
1131
+ if (e.source && L(e.source)) {
1132
+ const i = q(e.source, ["simulationTool", "sourceVersion"]);
1133
+ i.length && t.push(I("GENERALIZATION_SAMPLE_UNKNOWN_FIELD", "error", "sample", n, `source 含未知字段:${i.join(", ")}。`, {}));
1134
+ }
1135
+ for (const [i, o] of e.familyResolutions.entries())
1136
+ (!L(o) || q(o, ["familyId", "assetRevisionId"]).length || !R(o.familyId) || !R(o.assetRevisionId)) && t.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", n, `familyResolutions[${i}] 非法。`, {}));
1137
+ for (const [i, o] of e.placements.entries()) {
1138
+ if (!L(o) || q(o, ["sceneNodeId", "regionId", "transform"]).length || !R(o.sceneNodeId) || o.regionId !== null && !R(o.regionId)) {
1139
+ t.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", n, `placements[${i}] 非法。`, {}));
1140
+ continue;
1141
+ }
1142
+ ve(o.transform) || t.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", n, `placements[${i}].transform 非法。`, {}));
1143
+ }
1144
+ for (const [i, o] of e.termValues.entries())
1145
+ (!L(o) || q(o, ["termId", "value"]).length || !R(o.termId) || !bn(o.value)) && t.push(I("GENERALIZATION_SAMPLE_INVALID", "error", "sample", n, `termValues[${i}] 非法或含未知字段。`, {}));
1146
+ return t;
1147
+ }
1148
+ function wn(e) {
1149
+ return Ue(e, L(e) && typeof e.sampleId == "string" ? e.sampleId : null);
1150
+ }
1151
+ function bn(e) {
1152
+ return !L(e) || !["number", "vector3", "color", "choice"].includes(String(e.kind)) || q(e, ["kind", "value"]).length ? !1 : e.kind === "number" ? $(e.value) : e.kind === "vector3" ? z(e.value) : e.kind === "color" ? z(e.value) && e.value.every((n) => n >= 0 && n <= 1) : typeof e.value == "string" && e.value.length > 0;
1153
+ }
1154
+ function Gn(e) {
1155
+ return e === void 0 ? !0 : !L(e) || !Array.isArray(e.families) || !Array.isArray(e.regions) || !Array.isArray(e.contracts) || !Array.isArray(e.samples) || !e.families.every((n) => L(n) && R(n.familyId) && R(n.label) && R(n.semanticTag) && Array.isArray(n.targetNodeIds) && Array.isArray(n.candidates)) || !e.regions.every((n) => L(n) && R(n.regionId) && R(n.label) && R(n.parentNodeId) && L(n.frame) && L(n.shape) && L(n.constraints)) || !e.contracts.every((n) => L(n) && R(n.contractId) && R(n.label) && Array.isArray(n.terms)) ? !1 : e.samples.every((n) => Ue(n, null).length === 0);
1156
+ }
1157
+ function Dn(e, n) {
1158
+ return n.kind === "number" ? e.kind === "number" && e.value >= n.min && e.value <= n.max ? null : `需要 number ∈ [${n.min}, ${n.max}]` : n.kind === "vector3" ? e.kind === "vector3" && e.value.every((t, s) => t >= n.min[s] && t <= n.max[s]) ? null : "需要 vector3 位于局部 domain" : n.kind === "color" ? e.kind === "color" && n.options.some((t) => it(t, e.value)) ? null : "需要 choice 中的一个真实颜色 option" : e.kind === "choice" && n.options.some((t) => t.value === e.value) ? null : "需要 domain 中的 choice option";
1159
+ }
1160
+ function Vn(e, n, t) {
1161
+ var s;
1162
+ if (n.kind.startsWith("rigid-body.")) {
1163
+ if (n.kind === "rigid-body.mass-kg" && t.kind === "number")
1164
+ return { ...e, physics: { ...e.physics, kind: "dynamic", massKg: t.value } };
1165
+ if (n.kind === "rigid-body.center-of-mass" && t.kind === "vector3")
1166
+ return { ...e, physics: { ...e.physics, kind: "dynamic", centerOfMassM: [...t.value] } };
1167
+ }
1168
+ if (n.kind.startsWith("physics-material.")) {
1169
+ if (t.kind !== "number") return null;
1170
+ const i = { ...e.physics.physicsMaterial ?? {} };
1171
+ return n.kind === "physics-material.static-friction" && (i.staticFriction = t.value), n.kind === "physics-material.dynamic-friction" && (i.dynamicFriction = t.value), n.kind === "physics-material.restitution" && (i.restitution = t.value), { ...e, physics: { ...e.physics, physicsMaterial: i } };
1172
+ }
1173
+ if (n.kind === "visual.color" && t.kind === "color")
1174
+ return { ...e, appearance: { ...e.appearance ?? {}, color: [...t.value] } };
1175
+ if (n.kind === "visual.opacity" && t.kind === "number")
1176
+ return { ...e, appearance: { ...e.appearance ?? {}, opacity: t.value } };
1177
+ if (n.kind === "visual.material-choice" && t.kind === "choice") {
1178
+ const i = Ke(t.value);
1179
+ return i ? {
1180
+ ...e,
1181
+ variantSelections: { ...e.variantSelections, [i.setName]: i.value }
1182
+ } : null;
1183
+ }
1184
+ return n.kind === "joint.position" && t.kind === "number" && n.target.kind === "joint" ? {
1185
+ ...e,
1186
+ initialPose: {
1187
+ joints: { ...((s = e.initialPose) == null ? void 0 : s.joints) ?? {}, [n.target.jointName]: t.value }
1188
+ }
1189
+ } : null;
1190
+ }
1191
+ function We(e) {
1192
+ return new Set(e.terms.flatMap((n) => n.target.kind === "family" ? [n.target.familyId] : []));
1193
+ }
1194
+ function $n(e, n, t) {
1195
+ var s;
1196
+ return e.kind === "scene-node" || e.kind === "joint" ? [e.sceneNodeId] : e.kind === "family" ? ((s = n.families.find((i) => i.familyId === e.familyId)) == null ? void 0 : s.targetNodeIds) ?? [] : e.kind === "asset-revision" ? [...t.values()].filter((i) => i.assetRevisionId === e.assetRevisionId).map((i) => i.nodeId).sort() : [];
1197
+ }
1198
+ function Cn(e, n) {
1199
+ const t = (s) => s.nodeType === "asset" ? n.get(s.nodeId) ?? s : s.nodeType === "group" ? { ...s, children: s.children.map(t) } : s;
1200
+ return t(e);
1201
+ }
1202
+ function Zn(e, n) {
1203
+ const t = ue(e), s = /* @__PURE__ */ new Map();
1204
+ for (const i of t) {
1205
+ i.physics.kind === "dynamic" && i.localTransform.scale.some((c, a, d) => Math.abs(c - d[0]) > 1e-6) && n.push(I(
1206
+ "GENERALIZATION_SCENE_SCALE",
1207
+ "error",
1208
+ "scene",
1209
+ i.nodeId,
1210
+ `动态对象 ${i.label} 使用非均匀缩放,MuJoCo 预览会拒绝该刚体语义。`,
1211
+ { scale: i.localTransform.scale },
1212
+ i.nodeId
1213
+ ));
1214
+ const o = K(e, i.nodeId);
1215
+ o && s.set(i.nodeId, o);
1216
+ }
1217
+ for (const i of t) {
1218
+ const o = s.get(i.nodeId);
1219
+ o && (o.min[2] < -1e-3 ? n.push(I(
1220
+ "GENERALIZATION_SCENE_GROUND",
1221
+ "error",
1222
+ "scene",
1223
+ i.nodeId,
1224
+ `${i.label} 初始包围盒穿透地面 ${Math.abs(o.min[2]).toFixed(4)} m。`,
1225
+ { bounds: o },
1226
+ i.nodeId
1227
+ )) : i.physics.kind === "dynamic" && o.min[2] > 1e-3 && (t.some((a) => {
1228
+ if (a.nodeId === i.nodeId) return !1;
1229
+ const d = s.get(a.nodeId);
1230
+ return !!d && Jn(o, d) && Math.abs(o.min[2] - d.max[2]) <= 3e-3;
1231
+ }) || n.push(I(
1232
+ "GENERALIZATION_SCENE_GROUND",
1233
+ "warning",
1234
+ "scene",
1235
+ i.nodeId,
1236
+ `${i.label} 初始状态悬空,未找到下方支撑面。`,
1237
+ { bounds: o },
1238
+ i.nodeId
1239
+ ))));
1240
+ }
1241
+ for (let i = 0; i < t.length; i += 1)
1242
+ for (let o = i + 1; o < t.length; o += 1) {
1243
+ const c = t[i], a = t[o];
1244
+ if (c.physics.kind === "static" && a.physics.kind === "static") continue;
1245
+ const d = s.get(c.nodeId), r = s.get(a.nodeId);
1246
+ if (!d || !r) continue;
1247
+ const p = fe(d, r);
1248
+ p > 1e-5 && n.push(I(
1249
+ "GENERALIZATION_SCENE_OVERLAP",
1250
+ "warning",
1251
+ "scene",
1252
+ c.nodeId,
1253
+ `${c.label} 与 ${a.label} 初始包围盒重叠 ${p.toFixed(6)} m³。`,
1254
+ { otherNodeId: a.nodeId, overlapVolume: p },
1255
+ c.nodeId
1256
+ ));
1257
+ }
1258
+ }
1259
+ function Pn(e) {
1260
+ return Ye(e.bounds);
1261
+ }
1262
+ function Ye(e) {
1263
+ if (!e) return 0;
1264
+ const n = e.max[0] - e.min[0], t = e.max[1] - e.min[1], s = e.max[2] - e.min[2];
1265
+ return n <= 0 || t <= 0 || s <= 0 || s > 2 ? 0 : n * t / Math.max(0.08, s);
1266
+ }
1267
+ function zn(e) {
1268
+ if (!e.length) return null;
1269
+ const n = [1 / 0, 1 / 0, 1 / 0], t = [-1 / 0, -1 / 0, -1 / 0];
1270
+ for (const s of e)
1271
+ for (let i = 0; i < 3; i += 1)
1272
+ n[i] = Math.min(n[i], s.min[i]), t[i] = Math.max(t[i], s.max[i]);
1273
+ return { min: n, max: t };
1274
+ }
1275
+ function b(e, n) {
1276
+ const t = (s, i) => {
1277
+ const o = j(i, s.localTransform);
1278
+ if (s.nodeId === n) return o;
1279
+ if (s.nodeType === "group")
1280
+ for (const c of s.children) {
1281
+ const a = t(c, o);
1282
+ if (a) return a;
1283
+ }
1284
+ return null;
1285
+ };
1286
+ return t(e, me());
1287
+ }
1288
+ function Ie(e, n) {
1289
+ const t = b(e.root, n.parentNodeId);
1290
+ return t ? j(t, n.frame) : null;
1291
+ }
1292
+ function K(e, n) {
1293
+ const t = ze(e.root, n);
1294
+ if (!t) return null;
1295
+ if (t.nodeType === "asset") {
1296
+ const i = P(e, t.assetRevisionId), o = b(e.root, n);
1297
+ return i != null && i.bounds && o ? C(i.bounds, o) : null;
1298
+ }
1299
+ if (t.nodeType === "visual") {
1300
+ const i = e.visualAssets.find((c) => c.visualRevisionId === t.visualRevisionId), o = b(e.root, n);
1301
+ return i != null && i.bounds && o ? C(i.bounds, o) : null;
1302
+ }
1303
+ if (t.nodeType === "placeholder") {
1304
+ const i = b(e.root, n);
1305
+ return i ? C({
1306
+ min: [-t.size[0] / 2, -t.size[1] / 2, -t.size[2] / 2],
1307
+ max: [t.size[0] / 2, t.size[1] / 2, t.size[2] / 2]
1308
+ }, i) : null;
1309
+ }
1310
+ if (t.nodeType === "domain") {
1311
+ const i = b(e.root, n);
1312
+ return t.bounds && i ? C(t.bounds, i) : null;
1313
+ }
1314
+ const s = t.children.flatMap((i) => {
1315
+ if (i.nodeType === "asset") {
1316
+ const c = K(e, i.nodeId);
1317
+ return c ? [c] : [];
1318
+ }
1319
+ const o = K(e, i.nodeId);
1320
+ return o ? [o] : [];
1321
+ });
1322
+ return Kn(s);
1323
+ }
1324
+ function Hn(e, n) {
1325
+ return C(e, n);
1326
+ }
1327
+ function C(e, n) {
1328
+ const t = Wn(e).map((s) => {
1329
+ const i = [
1330
+ s[0] * n.scale[0],
1331
+ s[1] * n.scale[1],
1332
+ s[2] * n.scale[2]
1333
+ ], o = pe(n.rotation, i);
1334
+ return [
1335
+ o[0] + n.position[0],
1336
+ o[1] + n.position[1],
1337
+ o[2] + n.position[2]
1338
+ ];
1339
+ });
1340
+ return Yn(t);
1341
+ }
1342
+ function Fn(e, n) {
1343
+ const t = ie(n);
1344
+ return C(e, t);
1345
+ }
1346
+ function ie(e) {
1347
+ const n = [-e.rotation[0], -e.rotation[1], -e.rotation[2], e.rotation[3]], t = [
1348
+ 1 / e.scale[0],
1349
+ 1 / e.scale[1],
1350
+ 1 / e.scale[2]
1351
+ ], s = pe(n, [
1352
+ -e.position[0],
1353
+ -e.position[1],
1354
+ -e.position[2]
1355
+ ]);
1356
+ return {
1357
+ position: [
1358
+ s[0] * t[0],
1359
+ s[1] * t[1],
1360
+ s[2] * t[2]
1361
+ ],
1362
+ rotation: n,
1363
+ scale: t
1364
+ };
1365
+ }
1366
+ function j(e, n) {
1367
+ const t = [
1368
+ n.position[0] * e.scale[0],
1369
+ n.position[1] * e.scale[1],
1370
+ n.position[2] * e.scale[2]
1371
+ ], s = pe(e.rotation, t), i = jn(e.rotation, n.rotation);
1372
+ return {
1373
+ position: [
1374
+ e.position[0] + s[0],
1375
+ e.position[1] + s[1],
1376
+ e.position[2] + s[2]
1377
+ ],
1378
+ rotation: i,
1379
+ scale: [
1380
+ e.scale[0] * n.scale[0],
1381
+ e.scale[1] * n.scale[1],
1382
+ e.scale[2] * n.scale[2]
1383
+ ]
1384
+ };
1385
+ }
1386
+ function jn(e, n) {
1387
+ const [t, s, i, o] = e, [c, a, d, r] = n;
1388
+ return [
1389
+ o * c + t * r + s * d - i * a,
1390
+ o * a - t * d + s * r + i * c,
1391
+ o * d + t * a - s * c + i * r,
1392
+ o * r - t * c - s * a - i * d
1393
+ ];
1394
+ }
1395
+ function ne(e, n) {
1396
+ const t = (e.kind === "polygon" ? Math.max(...e.points.map((o) => o[0])) - Math.min(...e.points.map((o) => o[0])) : e.widthM) / 2 - n, s = (e.kind === "polygon" ? Math.max(...e.points.map((o) => o[1])) - Math.min(...e.points.map((o) => o[1])) : e.kind === "rectangle" ? e.heightM : e.depthM) / 2 - n, i = (e.kind === "rectangle" ? 5e-3 : e.heightM / 2) - n;
1397
+ return {
1398
+ min: [-t, -s, -Math.max(i, 0)],
1399
+ max: [t, s, Math.max(i, 0)]
1400
+ };
1401
+ }
1402
+ function Bn(e, n, t = 1e-5) {
1403
+ return e.min.some((s, i) => s < n.min[i] - t) || e.max.some((s, i) => s > n.max[i] + t);
1404
+ }
1405
+ function qn(e, n, t = 1e-5) {
1406
+ return [0, 1].some((s) => e.min[s] < n.min[s] - t || e.max[s] > n.max[s] + t);
1407
+ }
1408
+ function Un(e, n, t) {
1409
+ const s = ne(n.shape, 0), i = [e.position[0], e.position[1], e.position[2]], o = {
1410
+ min: [
1411
+ t.min[0] - Math.max(s.max[0] - s.min[0], n.constraints.marginM),
1412
+ t.min[1] - Math.max(s.max[1] - s.min[1], n.constraints.marginM),
1413
+ t.min[2] - Math.max(s.max[2] - s.min[2], n.constraints.marginM)
1414
+ ],
1415
+ max: [
1416
+ t.max[0] + Math.max(s.max[0] - s.min[0], n.constraints.marginM),
1417
+ t.max[1] + Math.max(s.max[1] - s.min[1], n.constraints.marginM),
1418
+ t.max[2] + Math.max(s.max[2] - s.min[2], n.constraints.marginM)
1419
+ ]
1420
+ };
1421
+ return i.every((c, a) => c >= o.min[a] && c <= o.max[a]);
1422
+ }
1423
+ function Wn(e) {
1424
+ return [
1425
+ [e.min[0], e.min[1], e.min[2]],
1426
+ [e.min[0], e.min[1], e.max[2]],
1427
+ [e.min[0], e.max[1], e.min[2]],
1428
+ [e.min[0], e.max[1], e.max[2]],
1429
+ [e.max[0], e.min[1], e.min[2]],
1430
+ [e.max[0], e.min[1], e.max[2]],
1431
+ [e.max[0], e.max[1], e.min[2]],
1432
+ [e.max[0], e.max[1], e.max[2]]
1433
+ ];
1434
+ }
1435
+ function Yn(e) {
1436
+ return {
1437
+ min: [0, 1, 2].map((n) => Math.min(...e.map((t) => t[n]))),
1438
+ max: [0, 1, 2].map((n) => Math.max(...e.map((t) => t[n])))
1439
+ };
1440
+ }
1441
+ function Xn(e) {
1442
+ return [
1443
+ e.max[0] - e.min[0],
1444
+ e.max[1] - e.min[1],
1445
+ e.max[2] - e.min[2]
1446
+ ];
1447
+ }
1448
+ function fe(e, n) {
1449
+ const t = Math.min(e.max[0], n.max[0]) - Math.max(e.min[0], n.min[0]), s = Math.min(e.max[1], n.max[1]) - Math.max(e.min[1], n.min[1]), i = Math.min(e.max[2], n.max[2]) - Math.max(e.min[2], n.min[2]);
1450
+ return t > 0 && s > 0 && i > 0 ? t * s * i : 0;
1451
+ }
1452
+ function Jn(e, n) {
1453
+ return e.min[0] < n.max[0] && n.min[0] < e.max[0] && e.min[1] < n.max[1] && n.min[1] < e.max[1];
1454
+ }
1455
+ function Kn(e) {
1456
+ return e.length ? {
1457
+ min: [0, 1, 2].map((n) => Math.min(...e.map((t) => t.min[n]))),
1458
+ max: [0, 1, 2].map((n) => Math.max(...e.map((t) => t.max[n])))
1459
+ } : null;
1460
+ }
1461
+ function Qn(e, n) {
1462
+ const t = [];
1463
+ return n.requiredCapabilities.rigidBody === "required" && !e.capabilities.rigidBody && t.push("需要刚体"), n.requiredCapabilities.rigidBody === "forbidden" && e.capabilities.rigidBody && t.push("禁止刚体"), n.requiredCapabilities.articulation === "required" && !e.capabilities.articulation && t.push("需要关节"), n.requiredCapabilities.articulation === "forbidden" && e.capabilities.articulation && t.push("禁止关节"), n.requiredCapabilities.colliderGeometry === "required" && !e.capabilities.colliderGeometry && t.push("需要 authored 碰撞几何"), n.requiredCapabilities.colliderGeometry === "forbidden" && e.capabilities.colliderGeometry && t.push("禁止 authored 碰撞几何"), n.requiredCapabilities.physics !== "any" && e.capabilities.physics !== n.requiredCapabilities.physics && t.push(`需要 physics=${n.requiredCapabilities.physics}`), t;
1464
+ }
1465
+ function Xe(e, n) {
1466
+ var s, i, o, c, a;
1467
+ const t = n.trim().toLowerCase();
1468
+ return ((s = e.category) == null ? void 0 : s.toLowerCase()) === t || (((i = e.hints) == null ? void 0 : i.tags) ?? []).some((d) => d.toLowerCase() === t) || (((o = e.semantic) == null ? void 0 : o.labels) ?? []).some((d) => d.toLowerCase() === t) || (((c = e.semantic) == null ? void 0 : c.tags) ?? []).some((d) => d.toLowerCase() === t) || (((a = e.semantic) == null ? void 0 : a.taxonomy) ?? []).some((d) => d.toLowerCase() === t || d.toLowerCase().split("/").includes(t));
1469
+ }
1470
+ function et(e) {
1471
+ return e.kind === "rectangle" ? e.widthM > 0 && e.heightM > 0 : e.kind === "box" ? e.widthM > 0 && e.depthM > 0 && e.heightM > 0 : e.points.length >= 3 && e.heightM > 0 && new Set(e.points.map((n) => `${n[0]},${n[1]}`)).size >= 3 && e.points.every((n) => $(n[0]) && $(n[1]));
1472
+ }
1473
+ function ve(e) {
1474
+ return z(e.position) && st(e.rotation) && z(e.scale) && Math.abs(Math.hypot(...e.rotation) - 1) <= 1e-4 && e.scale.every((n) => n > 0);
1475
+ }
1476
+ function nt(e) {
1477
+ return e.kind === "number" ? $(e.min) && $(e.max) && e.min <= e.max && (e.step === void 0 || $(e.step) && e.step > 0) : e.kind === "vector3" ? z(e.min) && z(e.max) && e.min.every((n, t) => n <= e.max[t]) : e.kind === "color" ? e.options.length > 0 && e.options.every((n) => z(n) && n.every((t) => t >= 0 && t <= 1)) : e.options.length > 0 && e.options.every((n) => R(n.value) && R(n.label) && ["asset-revision", "variant-set", "placement-region", "rendering-preset"].includes(n.source));
1478
+ }
1479
+ function Ve(e) {
1480
+ const n = re[e];
1481
+ return {
1482
+ backend: "mujoco-wasm",
1483
+ capability: e,
1484
+ status: n.supported ? "supported" : "unsupported",
1485
+ ...n.reason ? { reason: n.reason } : {}
1486
+ };
1487
+ }
1488
+ function Je(e, n, t, s) {
1489
+ return e.kind === "scene" ? !0 : e.kind === "family" ? n.has(e.familyId) : e.kind === "asset-revision" ? t.has(e.assetRevisionId) : s.has(e.sceneNodeId);
1490
+ }
1491
+ function tt(e, n, t) {
1492
+ const s = Ke(t);
1493
+ return s ? (n.kind === "asset-revision" ? e.assets.filter((o) => o.revisionId === n.assetRevisionId) : n.kind === "scene-node" ? e.assets.filter((o) => {
1494
+ var c;
1495
+ return o.revisionId === ((c = W(e, n.sceneNodeId)) == null ? void 0 : c.assetRevisionId);
1496
+ }) : n.kind === "family" ? e.assets.filter((o) => {
1497
+ var c;
1498
+ return (c = T(e).families.find((a) => a.familyId === n.familyId)) == null ? void 0 : c.candidates.some((a) => a.revisionId === o.revisionId);
1499
+ }) : []).some((o) => o.variantSets.some((c) => c.name === s.setName && c.options.includes(s.value))) : !1;
1500
+ }
1501
+ function Ke(e) {
1502
+ const n = e.indexOf("=");
1503
+ return n <= 0 || n === e.length - 1 ? null : { setName: e.slice(0, n), value: e.slice(n + 1) };
1504
+ }
1505
+ function M(e, n, t, s, i, o) {
1506
+ return { domain: e, unit: n, operations: t, targets: s, supported: i, ...o ? { reason: o } : {} };
1507
+ }
1508
+ function Qe(e) {
1509
+ return {
1510
+ position: [...e.position],
1511
+ rotation: [...e.rotation],
1512
+ scale: [...e.scale]
1513
+ };
1514
+ }
1515
+ function $e(e, n, t, s = {}) {
1516
+ return {
1517
+ sample: null,
1518
+ diagnostics: [I(e, "error", "sample", t, n, s)]
1519
+ };
1520
+ }
1521
+ function I(e, n, t, s, i, o, c) {
1522
+ return {
1523
+ code: e,
1524
+ level: n,
1525
+ source: t,
1526
+ entityId: s,
1527
+ message: i,
1528
+ evidence: o,
1529
+ ...c ? { sceneNodeId: c } : {}
1530
+ };
1531
+ }
1532
+ function Ce(e) {
1533
+ const n = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
1534
+ for (const s of e)
1535
+ n.has(s) && t.add(s), n.add(s);
1536
+ return [...t].sort();
1537
+ }
1538
+ function q(e, n) {
1539
+ const t = new Set(n);
1540
+ return Object.keys(e).filter((s) => !t.has(s)).sort();
1541
+ }
1542
+ function G(e) {
1543
+ return (n, t) => n[e].localeCompare(t[e]);
1544
+ }
1545
+ function se(e) {
1546
+ return [...new Set(e)].sort();
1547
+ }
1548
+ function it(e, n) {
1549
+ return e[0] === n[0] && e[1] === n[1] && e[2] === n[2];
1550
+ }
1551
+ function Ze(e) {
1552
+ return e.map((n) => Number(n.toFixed(4))).join(" × ");
1553
+ }
1554
+ function z(e) {
1555
+ return Array.isArray(e) && e.length === 3 && e.every($);
1556
+ }
1557
+ function st(e) {
1558
+ return Array.isArray(e) && e.length === 4 && e.every($);
1559
+ }
1560
+ function $(e) {
1561
+ return typeof e == "number" && Number.isFinite(e);
1562
+ }
1563
+ function R(e) {
1564
+ return typeof e == "string" && e.trim().length > 0;
1565
+ }
1566
+ function ot(e) {
1567
+ return typeof e == "string" && !Number.isNaN(Date.parse(e));
1568
+ }
1569
+ function L(e) {
1570
+ return typeof e == "object" && e !== null && !Array.isArray(e);
1571
+ }
1572
+ function rt(e) {
1573
+ return e instanceof Error ? e.message : String(e);
1574
+ }
1575
+ const le = /^[0-9a-f]{64}$/, vt = Object.freeze({
1576
+ manifest: Object.freeze({
1577
+ id: H,
1578
+ version: "1.0.0",
1579
+ apiVersion: "1.0",
1580
+ dataVersion: He
1581
+ }),
1582
+ validate(e) {
1583
+ return Re(e).diagnostics.map((n) => ({
1584
+ code: n.code,
1585
+ level: n.level,
1586
+ message: n.message,
1587
+ ...n.sceneNodeId ? { instanceId: n.sceneNodeId } : {},
1588
+ detail: {
1589
+ entityId: n.entityId,
1590
+ source: n.source
1591
+ }
1592
+ }));
1593
+ },
1594
+ normalize(e, n) {
1595
+ return Ne(
1596
+ S(
1597
+ n.data
1598
+ )
1599
+ );
1600
+ }
1601
+ });
1602
+ function Mt(e, n, t) {
1603
+ return mn(
1604
+ e,
1605
+ H,
1606
+ n ? Ne(n) : null,
1607
+ t
1608
+ );
1609
+ }
1610
+ function Lt(e) {
1611
+ return T(e).regions.map((n) => ({
1612
+ regionId: n.regionId,
1613
+ label: n.label,
1614
+ parentNodeId: n.parentNodeId,
1615
+ frame: n.frame,
1616
+ shape: n.shape,
1617
+ normalAxis: n.normalAxis
1618
+ }));
1619
+ }
1620
+ export {
1621
+ He as GENERALIZATION_DOMAIN_DATA_VERSION,
1622
+ vt as GENERALIZATION_DOMAIN_EXTENSION,
1623
+ H as GENERALIZATION_DOMAIN_ID,
1624
+ un as GENERALIZATION_FORMAT,
1625
+ dt as GENERALIZATION_ID_PREFIX,
1626
+ he as RESOLVED_SAMPLE_FORMAT,
1627
+ At as applyResolvedSampleToPreview,
1628
+ Mt as buildGeneralizationUpdate,
1629
+ An as calculateGeneralizationContentHash,
1630
+ Ae as calculateGeneralizationContractHash,
1631
+ ge as calculateGeneralizationSceneHash,
1632
+ Ee as calculateSampleHash,
1633
+ de as createDefaultRandomizationTerm,
1634
+ pn as createEmptyGeneralization,
1635
+ Fe as createObjectFamily,
1636
+ hn as createPlacementRegion,
1637
+ Nn as createRandomizationContract,
1638
+ mt as createSceneGeneralizationTemplate,
1639
+ ye as defaultCandidateRequirements,
1640
+ yn as defaultRandomizationDomain,
1641
+ Et as findGeneralizationDiagnosticsForRegion,
1642
+ Ne as generalizationDomainPayload,
1643
+ Lt as generalizationRegionOverlays,
1644
+ gt as generateRandomPreviewVariant,
1645
+ S as normalizeGeneralization,
1646
+ yt as parseResolvedSample,
1647
+ T as readGeneralization,
1648
+ ft as relaxCandidateCapabilities,
1649
+ ut as removeGeneralizationEntity,
1650
+ pt as repairGeneralizationReferences,
1651
+ It as resolveGeneralizationDiagnosticLocation,
1652
+ gn as sealResolvedSample,
1653
+ ht as serializeGeneralizationExport,
1654
+ Nt as serializeResolvedSample,
1655
+ Rt as supportedTermKinds,
1656
+ xn as termSpec,
1657
+ Re as validateGeneralization,
1658
+ lt as withGeneralization
1659
+ };