@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,1854 @@
1
+ var Ge = Object.defineProperty;
2
+ var Be = (i, e, r) => e in i ? Ge(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
3
+ var J = (i, e, r) => Be(i, typeof e != "symbol" ? e + "" : e, r);
4
+ import { S as fe, A as qe, b as he, G as Ke, a as l, s as y, z as m, L as Ae, l as Ne, B as T, R as z, O as pe, H as ie, w as G, Q as Je, I as B, p as Ye, U as X, M as Ee, a8 as Xe, Y as We, m as Ze, k as oe, c as Qe, X as ei, r as ii } from "./scene-graph-DBLKAhxa.js";
5
+ const ve = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ri = 10, ni = 16;
6
+ let re = -1, Se = [];
7
+ function L(i = Date.now()) {
8
+ const e = Math.max(i, re), r = [];
9
+ let n = e;
10
+ for (let s = 0; s < ri; s += 1)
11
+ r.unshift(ve[n % 32]), n = Math.floor(n / 32);
12
+ const t = e === re ? ti(Se) : me();
13
+ return re = e, Se = t, r.join("") + t.map((s) => ve[s]).join("");
14
+ }
15
+ function ti(i) {
16
+ const e = [...i];
17
+ for (let r = e.length - 1; r >= 0; r -= 1) {
18
+ if (e[r] < 31)
19
+ return e[r] = e[r] + 1, e;
20
+ e[r] = 0;
21
+ }
22
+ return me();
23
+ }
24
+ function me() {
25
+ const i = [];
26
+ for (let e = 0; e < ni; e += 1)
27
+ i.push(Math.floor(Math.random() * 32));
28
+ return i;
29
+ }
30
+ function dr(i, e) {
31
+ return i.map((r, n) => ({ value: r, index: n })).sort((r, n) => {
32
+ const t = e(r.value, n.value);
33
+ return t !== 0 ? t : r.index - n.index;
34
+ }).map((r) => r.value);
35
+ }
36
+ function lr(i, e) {
37
+ return i < e ? -1 : i > e ? 1 : 0;
38
+ }
39
+ function cr(i, e = 6) {
40
+ if (!Number.isFinite(i)) return i;
41
+ const r = 10 ** e, n = Math.round(i * r) / r;
42
+ return Object.is(n, -0) ? 0 : n;
43
+ }
44
+ class _e {
45
+ constructor() {
46
+ J(this, "entries", []);
47
+ }
48
+ add(e) {
49
+ this.entries.push(e);
50
+ }
51
+ info(e, r, n) {
52
+ this.add({ code: e, level: "info", message: r, ...n ? { detail: n } : {} });
53
+ }
54
+ warn(e, r, n) {
55
+ this.add({ code: e, level: "warning", message: r, ...n ? { detail: n } : {} });
56
+ }
57
+ error(e, r, n) {
58
+ this.add({ code: e, level: "error", message: r, ...n ? { detail: n } : {} });
59
+ }
60
+ get size() {
61
+ return this.entries.length;
62
+ }
63
+ get hasErrors() {
64
+ return this.entries.some((e) => e.level === "error");
65
+ }
66
+ toArray() {
67
+ return this.entries.map((e) => ({ ...e }));
68
+ }
69
+ }
70
+ class ur extends Error {
71
+ constructor(r, n, t) {
72
+ super(n);
73
+ J(this, "code");
74
+ J(this, "detail");
75
+ this.name = "SimStudioError", this.code = r, t && (this.detail = t);
76
+ }
77
+ }
78
+ const si = new Uint32Array([
79
+ 1116352408,
80
+ 1899447441,
81
+ 3049323471,
82
+ 3921009573,
83
+ 961987163,
84
+ 1508970993,
85
+ 2453635748,
86
+ 2870763221,
87
+ 3624381080,
88
+ 310598401,
89
+ 607225278,
90
+ 1426881987,
91
+ 1925078388,
92
+ 2162078206,
93
+ 2614888103,
94
+ 3248222580,
95
+ 3835390401,
96
+ 4022224774,
97
+ 264347078,
98
+ 604807628,
99
+ 770255983,
100
+ 1249150122,
101
+ 1555081692,
102
+ 1996064986,
103
+ 2554220882,
104
+ 2821834349,
105
+ 2952996808,
106
+ 3210313671,
107
+ 3336571891,
108
+ 3584528711,
109
+ 113926993,
110
+ 338241895,
111
+ 666307205,
112
+ 773529912,
113
+ 1294757372,
114
+ 1396182291,
115
+ 1695183700,
116
+ 1986661051,
117
+ 2177026350,
118
+ 2456956037,
119
+ 2730485921,
120
+ 2820302411,
121
+ 3259730800,
122
+ 3345764771,
123
+ 3516065817,
124
+ 3600352804,
125
+ 4094571909,
126
+ 275423344,
127
+ 430227734,
128
+ 506948616,
129
+ 659060556,
130
+ 883997877,
131
+ 958139571,
132
+ 1322822218,
133
+ 1537002063,
134
+ 1747873779,
135
+ 1955562222,
136
+ 2024104815,
137
+ 2227730452,
138
+ 2361852424,
139
+ 2428436474,
140
+ 2756734187,
141
+ 3204031479,
142
+ 3329325298
143
+ ]);
144
+ function oi(i) {
145
+ if (!Number.isFinite(i)) throw new TypeError("Canonical JSON cannot contain a non-finite number.");
146
+ const e = Number(i.toFixed(12));
147
+ return Object.is(e, -0) ? 0 : e;
148
+ }
149
+ function $e(i) {
150
+ const e = /* @__PURE__ */ new Set(), r = (n) => {
151
+ if (n === null) return "null";
152
+ if (typeof n == "string") return JSON.stringify(n);
153
+ if (typeof n == "boolean") return n ? "true" : "false";
154
+ if (typeof n == "number") return String(oi(n));
155
+ if (typeof n != "object")
156
+ throw new TypeError(`Canonical JSON cannot contain ${typeof n} values.`);
157
+ if (e.has(n)) throw new TypeError("Canonical JSON cannot contain circular references.");
158
+ e.add(n);
159
+ let t;
160
+ if (Array.isArray(n))
161
+ t = `[${n.map((s) => r(s)).join(",")}]`;
162
+ else {
163
+ const s = Object.getPrototypeOf(n);
164
+ if (s !== Object.prototype && s !== null)
165
+ throw new TypeError("Canonical JSON only accepts plain objects.");
166
+ t = `{${Object.keys(n).sort((a, c) => a.localeCompare(c)).map((a) => {
167
+ const c = n[a];
168
+ if (c === void 0) throw new TypeError(`Canonical JSON cannot contain undefined at "${a}".`);
169
+ return `${JSON.stringify(a)}:${r(c)}`;
170
+ }).join(",")}}`;
171
+ }
172
+ return e.delete(n), t;
173
+ };
174
+ return r(i);
175
+ }
176
+ function Re(i) {
177
+ const e = typeof i == "string" ? new TextEncoder().encode(i) : i instanceof ArrayBuffer ? new Uint8Array(i) : new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
178
+ return ai(e);
179
+ }
180
+ function ai(i) {
181
+ const e = i.byteLength * 8, r = Math.ceil((i.byteLength + 9) / 64) * 64, n = new Uint8Array(r);
182
+ n.set(i), n[i.byteLength] = 128;
183
+ const t = new DataView(n.buffer), s = Math.floor(e / 4294967296), d = e >>> 0;
184
+ t.setUint32(r - 8, s), t.setUint32(r - 4, d);
185
+ const a = new Uint32Array([
186
+ 1779033703,
187
+ 3144134277,
188
+ 1013904242,
189
+ 2773480762,
190
+ 1359893119,
191
+ 2600822924,
192
+ 528734635,
193
+ 1541459225
194
+ ]), c = new Uint32Array(64);
195
+ for (let S = 0; S < r; S += 64) {
196
+ for (let A = 0; A < 16; A += 1) c[A] = t.getUint32(S + A * 4);
197
+ for (let A = 16; A < 64; A += 1) {
198
+ const j = c[A - 15], U = c[A - 2], K = V(j, 7) ^ V(j, 18) ^ j >>> 3, ee = V(U, 17) ^ V(U, 19) ^ U >>> 10;
199
+ c[A] = c[A - 16] + K + c[A - 7] + ee >>> 0;
200
+ }
201
+ let h = a[0], D = a[1], E = a[2], w = a[3], $ = a[4], C = a[5], g = a[6], P = a[7];
202
+ for (let A = 0; A < 64; A += 1) {
203
+ const j = V($, 6) ^ V($, 11) ^ V($, 25), U = $ & C ^ ~$ & g, K = P + j + U + si[A] + c[A] >>> 0, ee = V(h, 2) ^ V(h, 13) ^ V(h, 22), He = h & D ^ h & E ^ D & E, ze = ee + He >>> 0;
204
+ P = g, g = C, C = $, $ = w + K >>> 0, w = E, E = D, D = h, h = K + ze >>> 0;
205
+ }
206
+ a[0] = a[0] + h >>> 0, a[1] = a[1] + D >>> 0, a[2] = a[2] + E >>> 0, a[3] = a[3] + w >>> 0, a[4] = a[4] + $ >>> 0, a[5] = a[5] + C >>> 0, a[6] = a[6] + g >>> 0, a[7] = a[7] + P >>> 0;
207
+ }
208
+ return Array.from(a, (S) => S.toString(16).padStart(8, "0")).join("");
209
+ }
210
+ function V(i, e) {
211
+ return i >>> e | i << 32 - e;
212
+ }
213
+ function be(i) {
214
+ return Re($e(di(i)));
215
+ }
216
+ function De(i) {
217
+ const e = i, r = {
218
+ assetId: e.assetId,
219
+ label: e.label,
220
+ format: e.format,
221
+ entryResourceId: e.entryResourceId,
222
+ resources: Ve(e.resources),
223
+ capabilities: e.capabilities,
224
+ upAxis: e.upAxis,
225
+ suggestedScale: e.suggestedScale
226
+ };
227
+ return e.bounds !== void 0 && (r.bounds = e.bounds), e.metrics !== void 0 && (r.metrics = e.metrics), Re($e(r));
228
+ }
229
+ function di(i) {
230
+ const e = i, r = {
231
+ assetId: e.assetId,
232
+ slug: e.slug,
233
+ label: e.label,
234
+ layout: e.layout,
235
+ fileKind: e.fileKind,
236
+ entryResourceId: e.entryResourceId,
237
+ resources: Ve(e.resources),
238
+ variantSets: li(e.variantSets),
239
+ capabilities: e.capabilities
240
+ };
241
+ return e.bounds !== void 0 && (r.bounds = e.bounds), e.category !== void 0 && (r.category = e.category), e.hints !== void 0 && (r.hints = ci(e.hints)), e.metrics !== void 0 && (r.metrics = e.metrics), e.semantic !== void 0 && (r.semantic = e.semantic), r;
242
+ }
243
+ function Ve(i) {
244
+ return Array.isArray(i) ? i.filter(ae).map((e) => ({ ...e })).sort((e, r) => String(e.path).localeCompare(String(r.path)) || String(e.resourceId).localeCompare(String(r.resourceId))) : [];
245
+ }
246
+ function li(i) {
247
+ if (!Array.isArray(i)) return [];
248
+ const e = /* @__PURE__ */ new Map();
249
+ for (const r of i) {
250
+ if (!ae(r) || typeof r.name != "string") continue;
251
+ const n = Array.isArray(r.options) ? r.options.filter((d) => typeof d == "string") : [], t = e.get(r.name), s = [.../* @__PURE__ */ new Set([...(t == null ? void 0 : t.options) ?? [], ...n])].sort();
252
+ e.set(r.name, {
253
+ ...t,
254
+ ...r,
255
+ options: s,
256
+ ...t != null && t.authoredDefault || r.authoredDefault ? { authoredDefault: (t == null ? void 0 : t.authoredDefault) ?? r.authoredDefault } : {}
257
+ });
258
+ }
259
+ return [...e.values()].sort((r, n) => String(r.name).localeCompare(String(n.name)));
260
+ }
261
+ function ci(i) {
262
+ return ae(i) ? {
263
+ ...i.approximateSize ? { approximateSize: i.approximateSize } : {},
264
+ ...i.defaultRole ? { defaultRole: i.defaultRole } : {},
265
+ ...i.defaultPhysics ? { defaultPhysics: i.defaultPhysics } : {},
266
+ ...i.forwardAxis ? { forwardAxis: i.forwardAxis } : {},
267
+ ...Array.isArray(i.tags) ? { tags: [...new Set(i.tags.filter((e) => typeof e == "string"))].sort() } : {}
268
+ } : i;
269
+ }
270
+ function ae(i) {
271
+ return typeof i == "object" && i !== null && !Array.isArray(i);
272
+ }
273
+ const Me = "1.0", O = {
274
+ duplicateId: "STUDIO_DOMAIN_DUPLICATE_ID",
275
+ incompatibleApi: "STUDIO_DOMAIN_INCOMPATIBLE_API",
276
+ invalidVersion: "STUDIO_DOMAIN_INVALID_VERSION",
277
+ unsupportedVersion: "STUDIO_DOMAIN_UNSUPPORTED_VERSION",
278
+ validationFailed: "STUDIO_DOMAIN_VALIDATION_FAILED",
279
+ unregisteredPayload: "STUDIO_DOMAIN_UNREGISTERED_PAYLOAD",
280
+ unregisteredNode: "STUDIO_DOMAIN_UNREGISTERED_NODE"
281
+ };
282
+ function ui(i, e = [], r = "transaction") {
283
+ var d;
284
+ const n = [], t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
285
+ for (const a of e) {
286
+ const { id: c, apiVersion: S } = a.manifest;
287
+ if (t.has(c)) {
288
+ n.push(x(
289
+ O.duplicateId,
290
+ "error",
291
+ `Document domain "${c}" is registered more than once.`,
292
+ { domainId: c }
293
+ ));
294
+ continue;
295
+ }
296
+ t.add(c), s.set(c, a), fi(S) || n.push(x(
297
+ O.incompatibleApi,
298
+ "error",
299
+ `Document domain "${c}" requires API ${S}, but the host supports ${Me}.`,
300
+ { domainId: c, apiVersion: S }
301
+ ));
302
+ }
303
+ for (const [a, c] of Object.entries(i.domains ?? {})) {
304
+ const S = s.get(a);
305
+ if (!S) {
306
+ n.push(x(
307
+ O.unregisteredPayload,
308
+ r === "export" ? "error" : "warning",
309
+ r === "export" ? `Document domain "${a}" is not registered and blocks export.` : `Document domain "${a}" is preserved without semantic validation.`,
310
+ { domainId: a }
311
+ ));
312
+ continue;
313
+ }
314
+ if (c.dataVersion !== S.manifest.dataVersion) {
315
+ n.push(x(
316
+ O.unsupportedVersion,
317
+ "error",
318
+ `Document domain "${a}" data version ${c.dataVersion} is unsupported; expected ${S.manifest.dataVersion}.`,
319
+ {
320
+ domainId: a,
321
+ version: c.dataVersion,
322
+ expected: S.manifest.dataVersion
323
+ }
324
+ ));
325
+ continue;
326
+ }
327
+ for (const h of S.validate(i, c))
328
+ n.push({
329
+ ...h,
330
+ code: h.code || O.validationFailed,
331
+ detail: {
332
+ ...h.detail ?? {},
333
+ domainId: a
334
+ }
335
+ });
336
+ }
337
+ for (const a of pi(i)) {
338
+ const c = s.get(a.domainId);
339
+ if (!c) {
340
+ n.push(x(
341
+ O.unregisteredNode,
342
+ r === "export" ? "error" : "warning",
343
+ r === "export" ? `Domain node "${a.nodeId}" belongs to unregistered domain "${a.domainId}" and blocks export.` : `Domain node "${a.nodeId}" is preserved without runtime projection.`,
344
+ { domainId: a.domainId, nodeId: a.nodeId }
345
+ ));
346
+ continue;
347
+ }
348
+ if (a.dataVersion !== c.manifest.dataVersion) {
349
+ n.push(x(
350
+ O.unsupportedVersion,
351
+ "error",
352
+ `Domain node "${a.nodeId}" data version ${a.dataVersion} is unsupported; expected ${c.manifest.dataVersion}.`,
353
+ {
354
+ domainId: a.domainId,
355
+ nodeId: a.nodeId,
356
+ version: a.dataVersion,
357
+ expected: c.manifest.dataVersion
358
+ }
359
+ ));
360
+ continue;
361
+ }
362
+ for (const S of ((d = c.validateNode) == null ? void 0 : d.call(c, i, a)) ?? [])
363
+ n.push({
364
+ ...S,
365
+ code: S.code || O.validationFailed,
366
+ detail: {
367
+ ...S.detail ?? {},
368
+ domainId: a.domainId,
369
+ nodeId: a.nodeId
370
+ }
371
+ });
372
+ }
373
+ return n;
374
+ }
375
+ function fr(i, e = []) {
376
+ const r = new Map(e.map((s) => [s.manifest.id, s])), n = Object.fromEntries(
377
+ Object.entries(i.domains ?? {}).map(([s, d]) => {
378
+ const a = r.get(s);
379
+ return a != null && a.normalize ? [s, a.normalize(i, d)] : [s, d];
380
+ })
381
+ );
382
+ return {
383
+ ...i,
384
+ ...Object.keys(n).length > 0 ? { domains: n } : {},
385
+ root: Oe(i, i.root, r)
386
+ };
387
+ }
388
+ function fi(i) {
389
+ const e = Me.split(".")[0];
390
+ return i.split(".")[0] === e;
391
+ }
392
+ function pi(i) {
393
+ const e = [], r = (n) => {
394
+ n.nodeType === "domain" && e.push(n), n.nodeType === "group" && n.children.forEach(r);
395
+ };
396
+ return i.root.children.forEach(r), e;
397
+ }
398
+ function Oe(i, e, r) {
399
+ return {
400
+ ...e,
401
+ children: e.children.map((n) => {
402
+ var t, s;
403
+ return n.nodeType === "group" ? Oe(i, n, r) : n.nodeType !== "domain" ? n : ((s = (t = r.get(n.domainId)) == null ? void 0 : t.normalizeNode) == null ? void 0 : s.call(t, i, n)) ?? n;
404
+ })
405
+ };
406
+ }
407
+ function x(i, e, r, n) {
408
+ return { code: i, level: e, message: r, detail: n };
409
+ }
410
+ const o = {
411
+ unsupportedSchemaVersion: "SIM_SCENE_UNSUPPORTED_SCHEMA_VERSION",
412
+ invalidRoot: "SIM_SCENE_INVALID_ROOT",
413
+ unknownField: "SIM_SCENE_UNKNOWN_FIELD",
414
+ invalidSceneId: "SIM_SCENE_INVALID_SCENE_ID",
415
+ invalidMeta: "SIM_SCENE_INVALID_META",
416
+ invalidCoordinateSystem: "SIM_SCENE_INVALID_COORDINATE_SYSTEM",
417
+ invalidEnvironment: "SIM_SCENE_INVALID_ENVIRONMENT",
418
+ invalidAssets: "SIM_SCENE_INVALID_ASSETS",
419
+ invalidVisualAssets: "SIM_SCENE_INVALID_VISUAL_ASSETS",
420
+ duplicateAssetRevisionId: "SIM_SCENE_DUPLICATE_ASSET_REVISION_ID",
421
+ duplicateAssetResourceId: "SIM_SCENE_DUPLICATE_ASSET_RESOURCE_ID",
422
+ duplicateAssetResourcePath: "SIM_SCENE_DUPLICATE_ASSET_RESOURCE_PATH",
423
+ invalidAssetRevision: "SIM_SCENE_INVALID_ASSET_REVISION",
424
+ invalidVisualAssetRevision: "SIM_SCENE_INVALID_VISUAL_ASSET_REVISION",
425
+ invalidAssetResource: "SIM_SCENE_INVALID_ASSET_RESOURCE",
426
+ invalidAssetHash: "SIM_SCENE_INVALID_ASSET_HASH",
427
+ invalidAssetPath: "SIM_SCENE_INVALID_ASSET_PATH",
428
+ invalidVariantSet: "SIM_SCENE_INVALID_VARIANT_SET",
429
+ invalidSceneTree: "SIM_SCENE_INVALID_SCENE_TREE",
430
+ duplicateNodeId: "SIM_SCENE_DUPLICATE_NODE_ID",
431
+ invalidNodeId: "SIM_SCENE_INVALID_NODE_ID",
432
+ invalidNodeLabel: "SIM_SCENE_INVALID_NODE_LABEL",
433
+ invalidNodeType: "SIM_SCENE_INVALID_NODE_TYPE",
434
+ unknownAssetRevision: "SIM_SCENE_UNKNOWN_ASSET_REVISION",
435
+ unknownVisualAssetRevision: "SIM_SCENE_UNKNOWN_VISUAL_ASSET_REVISION",
436
+ invalidRole: "SIM_SCENE_INVALID_ROLE",
437
+ invalidVariantSelection: "SIM_SCENE_INVALID_VARIANT_SELECTION",
438
+ invalidTransform: "SIM_SCENE_INVALID_TRANSFORM",
439
+ invalidOrigin: "SIM_SCENE_INVALID_ORIGIN",
440
+ nonUnitQuaternion: "SIM_SCENE_NON_UNIT_QUATERNION",
441
+ nonPositiveScale: "SIM_SCENE_NON_POSITIVE_SCALE",
442
+ nonUniformGaussianScale: "SIM_SCENE_NON_UNIFORM_GAUSSIAN_SCALE",
443
+ invalidPhysics: "SIM_SCENE_INVALID_PHYSICS",
444
+ invalidPose: "SIM_SCENE_INVALID_POSE",
445
+ invalidAppearance: "SIM_SCENE_INVALID_APPEARANCE",
446
+ invalidExternalRef: "SIM_SCENE_INVALID_EXTERNAL_REF",
447
+ invalidSemantic: "SIM_SCENE_INVALID_SEMANTIC",
448
+ invalidDomains: "SIM_SCENE_INVALID_DOMAINS",
449
+ invalidDomainNode: "SIM_SCENE_INVALID_DOMAIN_NODE",
450
+ invalidExtensions: "SIM_SCENE_INVALID_EXTENSIONS",
451
+ invalidBounds: "SIM_SCENE_INVALID_BOUNDS"
452
+ }, Te = /* @__PURE__ */ new Set([
453
+ "schemaVersion",
454
+ "sceneId",
455
+ "meta",
456
+ "coordinateSystem",
457
+ "environment",
458
+ "assets",
459
+ "visualAssets",
460
+ "root",
461
+ "semantic",
462
+ "domains",
463
+ "extensions"
464
+ ]), we = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]), Ce = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9_-]*)+$/, vi = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9_-]*)+$/, de = /^[0-9a-f]{64}$/;
465
+ function ge(i, e = {}) {
466
+ const r = new _e();
467
+ if (!u(i))
468
+ return r.error(o.invalidRoot, "Scene document must be an object."), ne(r);
469
+ const n = i;
470
+ if (n.schemaVersion !== fe)
471
+ return r.error(
472
+ o.unsupportedSchemaVersion,
473
+ `Unsupported scene schemaVersion: ${String(n.schemaVersion)}. Expected ${fe}.`,
474
+ { found: typeof n.schemaVersion == "number" ? n.schemaVersion : null }
475
+ ), ne(r);
476
+ for (const d of Object.keys(i))
477
+ Te.has(d) || r.error(
478
+ o.unknownField,
479
+ `Unknown scene document field: ${d}.`,
480
+ { field: d }
481
+ );
482
+ I(n.sceneId) || r.error(o.invalidSceneId, "Scene sceneId must be a non-empty string."), Si(n.meta, r), Ii(n.coordinateSystem, r), yi(n.environment, r);
483
+ const t = hi(n.assets, r), s = Ai(n.visualAssets, r);
484
+ bi(n.root, t, s, r), n.semantic !== void 0 && Fi(n.semantic, n.root, r), n.domains !== void 0 && Gi(n.domains, r), n.extensions !== void 0 && zi(n.extensions, r);
485
+ for (const d of ui(
486
+ n,
487
+ e.domainExtensions
488
+ ))
489
+ r.add(d);
490
+ return ne(r);
491
+ }
492
+ function pr(i) {
493
+ const r = ge(i).diagnostics.find((n) => n.level === "error");
494
+ if (r) throw new Error(`${r.code}: ${r.message}`);
495
+ }
496
+ function ne(i) {
497
+ const e = i.toArray();
498
+ return { ok: !e.some((r) => r.level === "error"), diagnostics: e };
499
+ }
500
+ function Si(i, e) {
501
+ if (!u(i)) {
502
+ e.error(o.invalidMeta, "Scene meta must be an object.");
503
+ return;
504
+ }
505
+ typeof i.name != "string" && e.error(o.invalidMeta, "Scene meta.name must be a string."), i.description !== void 0 && typeof i.description != "string" && e.error(o.invalidMeta, "Scene meta.description must be a string when provided."), Ie(i.createdAt) || e.error(o.invalidMeta, "Scene meta.createdAt must be an ISO 8601 timestamp."), Ie(i.updatedAt) || e.error(o.invalidMeta, "Scene meta.updatedAt must be an ISO 8601 timestamp."), i.createdBy !== void 0 && (!u(i.createdBy) || !["human", "ai", "import"].includes(String(i.createdBy.kind))) && e.error(o.invalidMeta, "Scene meta.createdBy.kind must be human, ai or import.");
506
+ }
507
+ function Ii(i, e) {
508
+ if (!u(i)) {
509
+ e.error(o.invalidCoordinateSystem, "Scene coordinateSystem must be an object.");
510
+ return;
511
+ }
512
+ i.upAxis !== "Z" && e.error(o.invalidCoordinateSystem, 'Scene coordinateSystem.upAxis must be "Z".'), ["+X", "-X", "+Y", "-Y", "+Z", "-Z"].includes(String(i.forwardAxis)) || e.error(o.invalidCoordinateSystem, "Scene coordinateSystem.forwardAxis is invalid."), (!u(i.units) || i.units.length !== "m" || i.units.mass !== "kg") && e.error(o.invalidCoordinateSystem, "Scene coordinateSystem.units must be metres and kilograms."), _(i.origin) || e.error(o.invalidCoordinateSystem, "Scene coordinateSystem.origin must be a finite vec3.");
513
+ }
514
+ function yi(i, e) {
515
+ if (!u(i) || !u(i.rendering) || !u(i.physics)) {
516
+ e.error(o.invalidEnvironment, "Scene environment must define rendering and physics objects.");
517
+ return;
518
+ }
519
+ const r = i.rendering;
520
+ ["preset", "hdr", "unknown", "unsupported"].includes(String(r.kind)) || e.error(o.invalidEnvironment, "Scene environment.rendering.kind is invalid."), r.presetId !== void 0 && typeof r.presetId != "string" && e.error(o.invalidEnvironment, "Scene environment.rendering.presetId must be a string."), r.hdrResourceId !== void 0 && typeof r.hdrResourceId != "string" && e.error(o.invalidEnvironment, "Scene environment.rendering.hdrResourceId must be a string."), !u(r.background) || !["environment", "none", "color"].includes(String(r.background.kind)) ? e.error(o.invalidEnvironment, "Scene environment.rendering.background is invalid.") : r.background.kind === "color" && !ce(r.background.color) && e.error(o.invalidEnvironment, "Scene environment background color must be RGB within 0..1."), M(r.rotationRadians) || e.error(o.invalidEnvironment, "Scene environment.rendering.rotationRadians must be finite."), (!M(r.intensity) || r.intensity < 0) && e.error(o.invalidEnvironment, "Scene environment.rendering.intensity must be a non-negative finite number.");
521
+ const n = i.physics;
522
+ if (_(n.gravity) || e.error(o.invalidEnvironment, "Scene environment.physics.gravity must be a finite vec3."), (!M(n.timeStepSeconds) || n.timeStepSeconds <= 0) && e.error(o.invalidEnvironment, "Scene environment.physics.timeStepSeconds must be positive."), !u(n.solver) || !["mujoco", "physx", "unknown", "unsupported"].includes(String(n.solver.kind)))
523
+ e.error(o.invalidEnvironment, "Scene environment.physics.solver.kind is invalid.");
524
+ else {
525
+ n.solver.integrator !== void 0 && !["euler", "implicitfast", "rk4"].includes(String(n.solver.integrator)) && e.error(o.invalidEnvironment, "Scene environment.physics.solver.integrator is invalid.");
526
+ const t = n.solver.solverIterations;
527
+ t !== void 0 && (!Number.isInteger(t) || Number(t) <= 0) && e.error(o.invalidEnvironment, "Scene environment.physics.solver.solverIterations must be a positive integer.");
528
+ }
529
+ n.colliderVisibility !== void 0 && !["never", "selected", "always"].includes(String(n.colliderVisibility)) && e.error(o.invalidEnvironment, "Scene environment.physics.colliderVisibility is invalid.");
530
+ }
531
+ function hi(i, e) {
532
+ const r = /* @__PURE__ */ new Map();
533
+ if (!Array.isArray(i))
534
+ return e.error(o.invalidAssets, "Scene assets must be an array."), r;
535
+ for (const n of i) {
536
+ if (!u(n) || !I(n.revisionId)) {
537
+ e.error(o.invalidAssetRevision, "Every asset revision must have a non-empty revisionId.");
538
+ continue;
539
+ }
540
+ r.has(n.revisionId) ? e.error(o.duplicateAssetRevisionId, `Duplicate asset revisionId: ${n.revisionId}.`) : r.set(n.revisionId, n), Ei(n, e);
541
+ }
542
+ return r;
543
+ }
544
+ function Ai(i, e) {
545
+ const r = /* @__PURE__ */ new Map();
546
+ if (!Array.isArray(i))
547
+ return e.error(o.invalidVisualAssets, "Scene visualAssets must be an array."), r;
548
+ for (const n of i) {
549
+ if (!u(n) || !I(n.visualRevisionId)) {
550
+ e.error(
551
+ o.invalidVisualAssetRevision,
552
+ "Every visual asset revision must have a non-empty visualRevisionId."
553
+ );
554
+ continue;
555
+ }
556
+ r.has(n.visualRevisionId) ? e.error(
557
+ o.duplicateAssetRevisionId,
558
+ `Duplicate visual revisionId: ${n.visualRevisionId}.`
559
+ ) : r.set(n.visualRevisionId, n), Ni(n, e);
560
+ }
561
+ return r;
562
+ }
563
+ function Ni(i, e) {
564
+ const r = String(i.visualRevisionId);
565
+ I(i.assetId) || e.error(
566
+ o.invalidVisualAssetRevision,
567
+ `Visual revision ${r} needs a non-empty assetId.`
568
+ ), I(i.label) || e.error(
569
+ o.invalidVisualAssetRevision,
570
+ `Visual revision ${r} needs a label.`
571
+ ), qi(i.format) || e.error(
572
+ o.invalidVisualAssetRevision,
573
+ `Visual revision ${r} format is invalid.`
574
+ );
575
+ const n = typeof i.contentHash == "string" ? i.contentHash : null;
576
+ if (!n || !de.test(n) ? e.error(
577
+ o.invalidAssetHash,
578
+ `Visual revision ${r} contentHash must be a lower-case SHA-256.`
579
+ ) : De(i) !== n && e.error(
580
+ o.invalidAssetHash,
581
+ `Visual revision ${r} contentHash does not match its immutable facts.`
582
+ ), Pe(i, r, e), (!u(i.capabilities) || i.capabilities.renderable !== !0 || i.capabilities.collidable !== !1 || i.capabilities.rigidBody !== !1 || i.capabilities.articulated !== !1) && e.error(
583
+ o.invalidVisualAssetRevision,
584
+ `Visual revision ${r} capabilities must be renderable-only.`
585
+ ), i.upAxis !== "y" && i.upAxis !== "y-down" && i.upAxis !== "z" && e.error(
586
+ o.invalidVisualAssetRevision,
587
+ `Visual revision ${r} upAxis must be "y", "y-down" or "z".`
588
+ ), (!_(i.suggestedScale) || i.suggestedScale.some((t) => !Number.isFinite(t) || t <= 0)) && e.error(
589
+ o.invalidVisualAssetRevision,
590
+ `Visual revision ${r} suggestedScale must be a positive finite vec3.`
591
+ ), i.bounds !== void 0 && le(i.bounds, r, e), i.metrics !== void 0)
592
+ if (!u(i.metrics))
593
+ e.error(
594
+ o.invalidVisualAssetRevision,
595
+ `Visual revision ${r} metrics must be an object.`
596
+ );
597
+ else
598
+ for (const t of ["splatCount", "pointCount", "meshCount", "byteSize"]) {
599
+ const s = i.metrics[t];
600
+ s !== void 0 && (!Number.isInteger(s) || Number(s) < 0) && e.error(
601
+ o.invalidVisualAssetRevision,
602
+ `Visual revision ${r} metric ${t} must be a non-negative integer.`
603
+ );
604
+ }
605
+ (!u(i.provenance) || !["builtin", "user", "import", "fixture"].includes(String(i.provenance.source))) && e.error(
606
+ o.invalidVisualAssetRevision,
607
+ `Visual revision ${r} provenance is invalid.`
608
+ );
609
+ }
610
+ function Ei(i, e) {
611
+ const r = String(i.revisionId);
612
+ I(i.assetId) || e.error(o.invalidAssetRevision, `Asset revision ${r} needs a non-empty assetId.`), I(i.slug) || e.error(o.invalidAssetRevision, `Asset revision ${r} needs a non-empty slug.`);
613
+ const n = typeof i.contentHash == "string" ? i.contentHash : null;
614
+ !n || !de.test(n) ? e.error(o.invalidAssetHash, `Asset revision ${r} contentHash must be a lower-case SHA-256.`) : mi(i, n) || e.error(o.invalidAssetHash, `Asset revision ${r} contentHash does not match its immutable facts.`), I(i.label) || e.error(o.invalidAssetRevision, `Asset revision ${r} needs a label.`), ["simready-package", "usdz", "single-layer", "glb"].includes(String(i.layout)) || e.error(o.invalidAssetRevision, `Asset revision ${r} layout is invalid.`), ["usd", "glb"].includes(String(i.fileKind)) || e.error(o.invalidAssetRevision, `Asset revision ${r} fileKind is invalid.`), i.category !== void 0 && !qe.includes(i.category) && e.error(o.invalidAssetRevision, `Asset revision ${r} category is invalid.`), Pe(i, r, e), $i(i.variantSets, r, e), Ri(i.capabilities, r, e), i.bounds !== void 0 && le(i.bounds, r, e), i.semantic !== void 0 && q(i.semantic, r, e), !u(i.provenance) || !["builtin", "user", "import"].includes(String(i.provenance.source)) || !Array.isArray(i.provenance.repairs) ? e.error(o.invalidAssetRevision, `Asset revision ${r} provenance is invalid.`) : i.provenance.externalRef !== void 0 && xe(i.provenance.externalRef, r, e);
615
+ }
616
+ function mi(i, e) {
617
+ try {
618
+ return be(i) === e;
619
+ } catch {
620
+ return !1;
621
+ }
622
+ }
623
+ function Pe(i, e, r) {
624
+ if (!Array.isArray(i.resources) || i.resources.length === 0) {
625
+ r.error(o.invalidAssetResource, `Asset revision ${e} must define resources.`);
626
+ return;
627
+ }
628
+ const n = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
629
+ for (const s of i.resources) {
630
+ if (!u(s) || !I(s.resourceId)) {
631
+ r.error(o.invalidAssetResource, `Asset revision ${e} has an invalid resource id.`);
632
+ continue;
633
+ }
634
+ n.has(s.resourceId) && r.error(o.duplicateAssetResourceId, `Asset revision ${e} repeats resource id ${s.resourceId}.`), n.add(s.resourceId);
635
+ const d = _i(s.locator, e, r);
636
+ d && (t.has(d) && r.error(
637
+ o.duplicateAssetResourcePath,
638
+ `Asset revision ${e} repeats resource locator ${d}.`
639
+ ), t.add(d)), I(s.mediaType) || r.error(o.invalidAssetResource, `Asset resource ${s.resourceId} needs a mediaType.`), (!Number.isInteger(s.byteSize) || s.byteSize < 0) && r.error(o.invalidAssetResource, `Asset resource ${s.resourceId} byteSize must be a non-negative integer.`), (typeof s.sha256 != "string" || !de.test(s.sha256)) && r.error(o.invalidAssetHash, `Asset resource ${s.resourceId} sha256 must be a lower-case SHA-256.`);
640
+ }
641
+ (!I(i.entryResourceId) || !n.has(i.entryResourceId)) && r.error(o.invalidAssetResource, `Asset revision ${e} entryResourceId must reference a resource.`);
642
+ }
643
+ function _i(i, e, r) {
644
+ if (!u(i) || i.kind !== "package-path" && i.kind !== "remote-url")
645
+ return r.error(
646
+ o.invalidAssetPath,
647
+ `Asset revision ${e} resource locator is invalid.`
648
+ ), null;
649
+ if (i.kind === "package-path")
650
+ return Bi(i.path) ? `package:${i.path}` : (r.error(
651
+ o.invalidAssetPath,
652
+ `Asset revision ${e} package-path locator is not a normalised package-relative path.`
653
+ ), null);
654
+ if (typeof i.url != "string")
655
+ return r.error(
656
+ o.invalidAssetPath,
657
+ `Asset revision ${e} remote-url locator must be a string.`
658
+ ), null;
659
+ try {
660
+ const n = new URL(i.url);
661
+ if (n.protocol !== "http:" && n.protocol !== "https:" || n.username || n.password || n.search || n.hash || i.url !== `${n.origin}${n.pathname}`)
662
+ throw new Error("not canonical");
663
+ return `remote:${i.url}`;
664
+ } catch {
665
+ return r.error(
666
+ o.invalidAssetPath,
667
+ `Asset revision ${e} remote-url locator is not a queryless canonical HTTP(S) URL.`
668
+ ), null;
669
+ }
670
+ }
671
+ function $i(i, e, r) {
672
+ if (!Array.isArray(i)) {
673
+ r.error(o.invalidVariantSet, `Asset revision ${e} variantSets must be an array.`);
674
+ return;
675
+ }
676
+ const n = /* @__PURE__ */ new Set();
677
+ for (const t of i) {
678
+ if (!u(t) || !I(t.name) || !Q(t.options) || t.options.length === 0 || new Set(t.options).size !== t.options.length) {
679
+ r.error(o.invalidVariantSet, `Asset revision ${e} has an invalid variant set.`);
680
+ continue;
681
+ }
682
+ n.has(t.name) && r.error(o.invalidVariantSet, `Asset revision ${e} repeats variant set ${t.name}.`), n.add(t.name);
683
+ const s = t.options;
684
+ t.authoredDefault !== void 0 && (typeof t.authoredDefault != "string" || !s.includes(t.authoredDefault)) && r.error(o.invalidVariantSet, `Variant set ${t.name} authoredDefault is not an option.`);
685
+ }
686
+ }
687
+ function Ri(i, e, r) {
688
+ (!u(i) || !["supported", "unknown", "unsupported"].includes(String(i.rendering)) || !["authored", "none", "unknown"].includes(String(i.physics)) || typeof i.articulation != "boolean" || typeof i.rigidBody != "boolean" || typeof i.colliderGeometry != "boolean") && r.error(o.invalidAssetRevision, `Asset revision ${e} capabilities are invalid.`);
689
+ }
690
+ function bi(i, e, r, n) {
691
+ if (!u(i) || i.nodeType !== "group" || !I(i.nodeId)) {
692
+ n.error(o.invalidSceneTree, "Scene root must be a SceneGroupNode with a nodeId.");
693
+ return;
694
+ }
695
+ const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new WeakSet(), d = (a, c) => {
696
+ if (!u(a) || s.has(a)) {
697
+ n.error(o.invalidSceneTree, `Scene tree contains a cycle or invalid node at ${c}.`);
698
+ return;
699
+ }
700
+ if (s.add(a), Di(a, e, r, n), typeof a.nodeId == "string" && (t.has(a.nodeId) && n.error(o.duplicateNodeId, `Duplicate scene nodeId: ${a.nodeId}.`), t.add(a.nodeId)), a.nodeType === "group") {
701
+ if (!Array.isArray(a.children)) {
702
+ n.error(o.invalidSceneTree, `Scene group ${String(a.nodeId)} children must be an array.`);
703
+ return;
704
+ }
705
+ a.children.forEach((S, h) => d(S, `${c}/${h}`));
706
+ }
707
+ };
708
+ d(i, "root");
709
+ }
710
+ function Di(i, e, r, n) {
711
+ if (I(i.nodeId) || n.error(o.invalidNodeId, "Scene nodeId must be a non-empty string."), I(i.label) || n.error(o.invalidNodeLabel, `Scene node ${String(i.nodeId)} label must be non-empty.`), gi(i.localTransform, String(i.nodeId), n), i.origin !== void 0 && Pi(i.origin, String(i.nodeId), n), i.nodeType !== "group") {
712
+ if (i.nodeType === "asset") {
713
+ Oi(i, e, n);
714
+ return;
715
+ }
716
+ if (i.nodeType === "visual") {
717
+ Ti(i, r, n);
718
+ return;
719
+ }
720
+ if (i.nodeType === "placeholder") {
721
+ Mi(i, e, n);
722
+ return;
723
+ }
724
+ if (i.nodeType === "domain") {
725
+ Vi(i, n);
726
+ return;
727
+ }
728
+ n.error(o.invalidNodeType, `Scene node ${String(i.nodeId)} has an unsupported nodeType.`);
729
+ }
730
+ }
731
+ function Vi(i, e) {
732
+ const r = String(i.nodeId);
733
+ (!I(i.domainId) || !Ce.test(i.domainId)) && e.error(
734
+ o.invalidDomainNode,
735
+ `Scene domain node ${r} requires a namespaced domainId.`
736
+ ), (!Number.isInteger(i.dataVersion) || Number(i.dataVersion) <= 0) && e.error(
737
+ o.invalidDomainNode,
738
+ `Scene domain node ${r} dataVersion must be a positive integer.`
739
+ ), Z(i.payload) || e.error(
740
+ o.invalidDomainNode,
741
+ `Scene domain node ${r} payload must contain finite JSON data.`
742
+ ), typeof i.visible != "boolean" && e.error(o.invalidDomainNode, `Scene domain node ${r} visible must be a boolean.`), typeof i.selectable != "boolean" && e.error(o.invalidDomainNode, `Scene domain node ${r} selectable must be a boolean.`), i.bounds !== void 0 && le(i.bounds, r, e), i.semantic !== void 0 && q(i.semantic, r, e);
743
+ }
744
+ function Mi(i, e, r) {
745
+ const n = String(i.nodeId);
746
+ i.placeholderVersion !== 1 && r.error(o.invalidNodeType, `Scene placeholder ${n} must use placeholderVersion 1.`);
747
+ const t = i.size;
748
+ (!_(t) || t.some((s) => s <= 0)) && r.error(o.invalidNodeType, `Scene placeholder ${n} size must contain positive finite values.`), he.includes(i.role) || r.error(o.invalidRole, `Scene placeholder ${n} has an invalid role.`), typeof i.visible != "boolean" && r.error(o.invalidNodeType, `Scene placeholder ${n} visible must be a boolean.`), i.assetRevisionId !== void 0 && (!I(i.assetRevisionId) || !e.has(i.assetRevisionId)) && r.error(
749
+ o.unknownAssetRevision,
750
+ `Scene placeholder ${n} references an unknown bound asset revision.`,
751
+ { nodeId: n }
752
+ ), i.externalRef !== void 0 && xe(i.externalRef, n, r), i.semantic !== void 0 && q(i.semantic, n, r);
753
+ }
754
+ function Oi(i, e, r) {
755
+ const n = String(i.nodeId);
756
+ (!I(i.assetRevisionId) || !e.has(i.assetRevisionId)) && r.error(o.unknownAssetRevision, `Scene node ${n} references an unknown assetRevisionId.`, {
757
+ nodeId: n,
758
+ assetRevisionId: typeof i.assetRevisionId == "string" ? i.assetRevisionId : null
759
+ }), he.includes(i.role) || r.error(o.invalidRole, `Scene node ${n} has an invalid role.`), typeof i.visible != "boolean" && r.error(o.invalidNodeType, `Scene node ${n} visible must be a boolean.`), xi(i.physics, n, r), i.initialPose !== void 0 && ji(i.initialPose, n, r), i.appearance !== void 0 && Ui(i.appearance, n, r), i.semantic !== void 0 && q(i.semantic, n, r), Ci(i.variantSelections, e.get(String(i.assetRevisionId)), n, r);
760
+ }
761
+ function Ti(i, e, r) {
762
+ var s;
763
+ const n = String(i.nodeId), t = I(i.visualRevisionId) ? e.get(i.visualRevisionId) : void 0;
764
+ if (t || r.error(
765
+ o.unknownVisualAssetRevision,
766
+ `Scene visual node ${n} references an unknown visualRevisionId.`,
767
+ {
768
+ nodeId: n,
769
+ visualRevisionId: typeof i.visualRevisionId == "string" ? i.visualRevisionId : null
770
+ }
771
+ ), typeof i.visible != "boolean" && r.error(o.invalidNodeType, `Scene visual node ${n} visible must be a boolean.`), ["default", "foreground", "background"].includes(String(i.renderLayer)) || r.error(o.invalidNodeType, `Scene visual node ${n} renderLayer is invalid.`), ["bounds", "exact"].includes(String(i.selectionMode)) || r.error(o.invalidNodeType, `Scene visual node ${n} selectionMode is invalid.`), t && Ke.includes(t.format)) {
772
+ const d = (s = i.localTransform) == null ? void 0 : s.scale;
773
+ _(d) && (Math.abs(d[0] - d[1]) > 1e-6 || Math.abs(d[0] - d[2]) > 1e-6) && r.error(
774
+ o.nonUniformGaussianScale,
775
+ `Gaussian visual node ${n} requires uniform scale.`,
776
+ { nodeId: n, scale: d.join(",") }
777
+ );
778
+ }
779
+ i.appearance !== void 0 && wi(i.appearance, n, r), i.semantic !== void 0 && q(i.semantic, n, r);
780
+ }
781
+ function wi(i, e, r) {
782
+ if (!u(i)) {
783
+ r.error(o.invalidAppearance, `Visual node ${e} appearance must be an object.`);
784
+ return;
785
+ }
786
+ i.color !== void 0 && !ce(i.color) && r.error(o.invalidAppearance, `Visual node ${e} color must be RGB within 0..1.`), i.opacity !== void 0 && (!M(i.opacity) || i.opacity < 0 || i.opacity > 1) && r.error(o.invalidAppearance, `Visual node ${e} opacity must be within 0..1.`);
787
+ }
788
+ function Ci(i, e, r, n) {
789
+ var s;
790
+ if (!u(i)) {
791
+ n.error(o.invalidVariantSelection, `Scene node ${r} variantSelections must be an object.`);
792
+ return;
793
+ }
794
+ if (!e) return;
795
+ const t = new Map((e.variantSets ?? []).map((d) => [d.name, d.options]));
796
+ for (const [d, a] of Object.entries(i))
797
+ (typeof a != "string" || !((s = t.get(d)) != null && s.includes(a))) && n.error(
798
+ o.invalidVariantSelection,
799
+ `Scene node ${r} selects unknown variant ${d}=${String(a)}.`,
800
+ { nodeId: r, variantSet: d, option: typeof a == "string" ? a : null }
801
+ );
802
+ }
803
+ function gi(i, e, r) {
804
+ if (!u(i)) {
805
+ r.error(o.invalidTransform, `Scene node ${e} localTransform must be an object.`);
806
+ return;
807
+ }
808
+ const n = i;
809
+ _(n.position) || r.error(o.invalidTransform, `Scene node ${e} position must be a finite vec3.`), Ji(n.rotation) ? Math.abs(Ki(n.rotation) - 1) > 1e-4 && r.error(o.nonUnitQuaternion, `Scene node ${e} rotation must be a unit quaternion.`) : r.error(o.invalidTransform, `Scene node ${e} rotation must be a finite quaternion.`), _(n.scale) ? n.scale.some((t) => t <= 0) && r.error(o.nonPositiveScale, `Scene node ${e} scale components must be positive.`) : r.error(o.invalidTransform, `Scene node ${e} scale must be a finite vec3.`);
810
+ }
811
+ function Pi(i, e, r) {
812
+ if (!u(i)) {
813
+ r.error(o.invalidOrigin, `Scene node ${e} origin must be an object.`);
814
+ return;
815
+ }
816
+ _(i.local) || r.error(
817
+ o.invalidOrigin,
818
+ `Scene node ${e} origin.local must be a finite source-content vec3.`
819
+ );
820
+ }
821
+ function xi(i, e, r) {
822
+ if (!u(i) || !["static", "dynamic", "kinematic", "asset-authored"].includes(String(i.kind))) {
823
+ r.error(o.invalidPhysics, `Scene node ${e} physics kind is invalid.`);
824
+ return;
825
+ }
826
+ const n = i;
827
+ n.kind === "dynamic" && n.massKg !== void 0 && (!M(n.massKg) || n.massKg <= 0) && r.error(o.invalidPhysics, `Scene node ${e} dynamic massKg must be positive.`), n.kind !== "dynamic" && "massKg" in n && n.massKg !== void 0 && r.error(o.invalidPhysics, `Scene node ${e} massKg is only valid for dynamic physics.`), "centerOfMassM" in n && n.centerOfMassM !== void 0 && !_(n.centerOfMassM) && r.error(o.invalidPhysics, `Scene node ${e} centerOfMassM must be a finite vec3.`), n.colliderPrimPaths !== void 0 && (!Q(n.colliderPrimPaths) || !n.colliderPrimPaths.every(je)) && r.error(o.invalidPhysics, `Scene node ${e} colliderPrimPaths must be absolute prim paths.`), n.physicsMaterial !== void 0 && Li(n.physicsMaterial, e, r), n.jointOverrides !== void 0 && (Array.isArray(n.jointOverrides) ? n.jointOverrides.forEach((t) => ki(t, e, r)) : r.error(o.invalidPhysics, `Scene node ${e} jointOverrides must be an array.`));
828
+ }
829
+ function Li(i, e, r) {
830
+ if (!u(i)) {
831
+ r.error(o.invalidPhysics, `Scene node ${e} physicsMaterial must be an object.`);
832
+ return;
833
+ }
834
+ const n = i;
835
+ for (const [t, s] of Object.entries(n))
836
+ (!["densityKgPerM3", "staticFriction", "dynamicFriction", "restitution"].includes(t) || !M(s) || s < 0) && r.error(o.invalidPhysics, `Scene node ${e} physicsMaterial.${t} is invalid.`);
837
+ n.restitution !== void 0 && n.restitution > 1 && r.error(o.invalidPhysics, `Scene node ${e} restitution must be within 0..1.`);
838
+ }
839
+ function ki(i, e, r) {
840
+ if (!u(i) || !je(i.jointPrimPath) || i.driveType !== void 0 && !["position", "velocity"].includes(String(i.driveType))) {
841
+ r.error(o.invalidPhysics, `Scene node ${e} has an invalid joint override.`);
842
+ return;
843
+ }
844
+ for (const n of ["target", "stiffness", "damping", "maxForce"])
845
+ i[n] !== void 0 && !M(i[n]) && r.error(o.invalidPhysics, `Scene node ${e} joint override ${n} must be finite.`);
846
+ }
847
+ function ji(i, e, r) {
848
+ if (!u(i) || !u(i.joints)) {
849
+ r.error(o.invalidPose, `Scene node ${e} initialPose.joints must be an object.`);
850
+ return;
851
+ }
852
+ for (const [n, t] of Object.entries(i.joints))
853
+ (!n || !M(t)) && r.error(o.invalidPose, `Scene node ${e} joint ${n} must have a finite position.`);
854
+ }
855
+ function Ui(i, e, r) {
856
+ if (!u(i)) {
857
+ r.error(o.invalidAppearance, `Scene node ${e} appearance must be an object.`);
858
+ return;
859
+ }
860
+ i.color !== void 0 && !ce(i.color) && r.error(o.invalidAppearance, `Scene node ${e} appearance color must be RGB within 0..1.`);
861
+ for (const n of ["opacity", "metallic", "roughness"])
862
+ i[n] !== void 0 && (!M(i[n]) || i[n] < 0 || i[n] > 1) && r.error(o.invalidAppearance, `Scene node ${e} appearance ${n} must be within 0..1.`);
863
+ }
864
+ function xe(i, e, r) {
865
+ (!u(i) || !I(i.system) || !I(i.assetId) || i.versionId !== void 0 && !I(i.versionId)) && r.error(
866
+ o.invalidExternalRef,
867
+ `External asset ref for ${e} requires non-empty system and assetId, with an optional non-empty versionId.`
868
+ );
869
+ }
870
+ function q(i, e, r) {
871
+ if (!u(i) || !["authored", "imported", "annotated"].includes(String(i.source))) {
872
+ r.error(o.invalidSemantic, `Semantic owner ${e} must define a valid source.`);
873
+ return;
874
+ }
875
+ Le(i, e, r);
876
+ }
877
+ function Le(i, e, r) {
878
+ for (const n of ["labels", "taxonomy", "tags"])
879
+ i[n] !== void 0 && !Q(i[n]) && r.error(o.invalidSemantic, `Semantic owner ${e} ${n} must be a string array.`);
880
+ i.attributes !== void 0 && ke(i.attributes, e, r);
881
+ }
882
+ function ke(i, e, r) {
883
+ if (!u(i)) {
884
+ r.error(o.invalidSemantic, `Semantic owner ${e} attributes must be an object.`);
885
+ return;
886
+ }
887
+ const n = i;
888
+ for (const [t, s] of Object.entries(n))
889
+ (!t || we.has(t) || !(s === null || typeof s == "string" || typeof s == "boolean" || typeof s == "number" && Number.isFinite(s))) && r.error(o.invalidSemantic, `Semantic owner ${e} has an invalid attribute ${t}.`);
890
+ }
891
+ function Fi(i, e, r) {
892
+ if (!u(i) || !["authored", "imported", "annotated"].includes(String(i.source))) {
893
+ r.error(o.invalidSemantic, "Scene semantic must define a valid source.");
894
+ return;
895
+ }
896
+ if (Le(i, "scene", r), i.task !== void 0 && (!u(i.task) || i.task.label === void 0 || typeof i.task.label != "string" || !["authored", "imported", "annotated"].includes(String(i.task.source))) && r.error(o.invalidSemantic, "Scene task semantic is invalid."), i.annotations !== void 0) {
897
+ if (!Array.isArray(i.annotations)) {
898
+ r.error(o.invalidSemantic, "Scene annotations must be an array.");
899
+ return;
900
+ }
901
+ const n = Hi(e), t = /* @__PURE__ */ new Set();
902
+ for (const s of i.annotations) {
903
+ if (!u(s) || !I(s.annotationId) || !I(s.label) || !I(s.kind) || !Q(s.targetNodeIds) || s.targetNodeIds.length === 0 || !["authored", "imported", "annotated"].includes(String(s.source))) {
904
+ r.error(o.invalidSemantic, "Scene annotation is invalid.");
905
+ continue;
906
+ }
907
+ t.has(s.annotationId) && r.error(o.invalidSemantic, `Duplicate annotationId: ${s.annotationId}.`), t.add(s.annotationId);
908
+ for (const d of s.targetNodeIds)
909
+ n.has(d) || r.error(o.invalidSemantic, `Annotation ${s.annotationId} references unknown node ${d}.`);
910
+ s.attributes !== void 0 && ke(s.attributes, s.annotationId, r);
911
+ }
912
+ }
913
+ }
914
+ function Hi(i) {
915
+ const e = /* @__PURE__ */ new Set(), r = (n) => {
916
+ !u(n) || typeof n.nodeId != "string" || (e.add(n.nodeId), n.nodeType === "group" && Array.isArray(n.children) && n.children.forEach(r));
917
+ };
918
+ return r(i), e;
919
+ }
920
+ function zi(i, e) {
921
+ if (!u(i)) {
922
+ e.error(o.invalidExtensions, "Scene extensions must be an object.");
923
+ return;
924
+ }
925
+ for (const [r, n] of Object.entries(i))
926
+ (!vi.test(r) || Te.has(r)) && e.error(o.invalidExtensions, `Scene extension key "${r}" must be namespaced and may not shadow a core field.`), Z(n) || e.error(o.invalidExtensions, `Scene extension "${r}" must contain finite JSON data.`);
927
+ }
928
+ function Gi(i, e) {
929
+ if (!u(i)) {
930
+ e.error(o.invalidDomains, "Scene domains must be an object.");
931
+ return;
932
+ }
933
+ for (const [r, n] of Object.entries(i)) {
934
+ if (!Ce.test(r)) {
935
+ e.error(
936
+ o.invalidDomains,
937
+ `Scene domain id must be namespaced: ${r}.`
938
+ );
939
+ continue;
940
+ }
941
+ (!u(n) || !Number.isInteger(n.dataVersion) || Number(n.dataVersion) <= 0 || !Z(n.data)) && e.error(
942
+ o.invalidDomains,
943
+ `Scene domain ${r} requires a positive integer dataVersion and finite JSON data.`
944
+ );
945
+ }
946
+ }
947
+ function le(i, e, r) {
948
+ (!u(i) || !_(i.min) || !_(i.max) || !(i.max[0] > i.min[0] && i.max[1] > i.min[1] && i.max[2] >= i.min[2])) && r.error(o.invalidBounds, `Bounds for ${e} must be a finite min/max with max greater than min.`);
949
+ }
950
+ function Z(i, e = /* @__PURE__ */ new Set()) {
951
+ if (i === null || typeof i == "string" || typeof i == "boolean") return !0;
952
+ if (typeof i == "number") return Number.isFinite(i);
953
+ if (typeof i != "object" || e.has(i) || !Array.isArray(i) && Object.getPrototypeOf(i) !== Object.prototype && Object.getPrototypeOf(i) !== null) return !1;
954
+ e.add(i);
955
+ const r = Object.entries(i).every(([n, t]) => !we.has(n) && Z(t, e));
956
+ return e.delete(i), r;
957
+ }
958
+ function Bi(i) {
959
+ return typeof i == "string" && i.length > 0 && !i.includes("\\") && !i.startsWith("/") && !/^[a-z][a-z0-9+.-]*:/i.test(i) && !i.split("/").some((e) => !e || e === "." || e === "..");
960
+ }
961
+ function je(i) {
962
+ return typeof i == "string" && /^\/[A-Za-z0-9_]+(?:\/[A-Za-z0-9_]+)*$/.test(i);
963
+ }
964
+ function ce(i) {
965
+ return _(i) && i.every((e) => e >= 0 && e <= 1);
966
+ }
967
+ function M(i) {
968
+ return typeof i == "number" && Number.isFinite(i);
969
+ }
970
+ function qi(i) {
971
+ return [
972
+ "glb",
973
+ "gltf",
974
+ "fbx",
975
+ "ply-mesh",
976
+ "ply-point-cloud",
977
+ "gaussian-ply",
978
+ "gaussian-spz",
979
+ "gaussian-sog",
980
+ "gaussian-splat",
981
+ "gaussian-ksplat",
982
+ "gaussian-rad"
983
+ ].includes(String(i));
984
+ }
985
+ function Q(i) {
986
+ return Array.isArray(i) && i.every((e) => typeof e == "string");
987
+ }
988
+ function Ki(i) {
989
+ return Math.hypot(i[0], i[1], i[2], i[3]);
990
+ }
991
+ function u(i) {
992
+ return typeof i == "object" && i !== null && !Array.isArray(i);
993
+ }
994
+ function I(i) {
995
+ return typeof i == "string" && i.length > 0;
996
+ }
997
+ function _(i) {
998
+ return Array.isArray(i) && i.length === 3 && i.every((e) => typeof e == "number" && Number.isFinite(e));
999
+ }
1000
+ function Ji(i) {
1001
+ return Array.isArray(i) && i.length === 4 && i.every((e) => typeof e == "number" && Number.isFinite(e));
1002
+ }
1003
+ function Ie(i) {
1004
+ return typeof i == "string" && !Number.isNaN(Date.parse(i));
1005
+ }
1006
+ const f = {
1007
+ nodeNotFound: "SIM_COMMAND_NODE_NOT_FOUND",
1008
+ nodeExists: "SIM_COMMAND_NODE_EXISTS",
1009
+ parentNotFound: "SIM_COMMAND_PARENT_NOT_FOUND",
1010
+ parentNotGroup: "SIM_COMMAND_PARENT_NOT_GROUP",
1011
+ revisionNotFound: "SIM_COMMAND_REVISION_NOT_FOUND",
1012
+ revisionExists: "SIM_COMMAND_REVISION_EXISTS",
1013
+ revisionInUse: "SIM_COMMAND_REVISION_IN_USE",
1014
+ revisionHashMismatch: "SIM_COMMAND_REVISION_HASH_MISMATCH",
1015
+ payloadMismatch: "SIM_COMMAND_PAYLOAD_MISMATCH",
1016
+ invalidDomainId: "SIM_COMMAND_INVALID_DOMAIN_ID",
1017
+ invalidDomainData: "SIM_COMMAND_INVALID_DOMAIN_DATA",
1018
+ invalidResult: "SIM_COMMAND_INVALID_RESULT",
1019
+ emptyLabel: "SIM_COMMAND_EMPTY_LABEL"
1020
+ };
1021
+ function W(i, e, r = (/* @__PURE__ */ new Date()).toISOString()) {
1022
+ const n = new _e(), t = Yi(i, e, n, r);
1023
+ if (n.hasErrors || !t) return { doc: i, diagnostics: n.toArray() };
1024
+ const d = ge(t).diagnostics.filter((a) => a.level === "error");
1025
+ return d.length > 0 ? (d.forEach((a) => n.add(a)), { doc: i, diagnostics: n.toArray() }) : { doc: t, diagnostics: n.toArray() };
1026
+ }
1027
+ function Yi(i, e, r, n) {
1028
+ switch (e.type) {
1029
+ case "node.add": {
1030
+ if (m(i.root, e.node.nodeId)) return ye(r, e.node.nodeId);
1031
+ const t = m(i.root, e.parentNodeId);
1032
+ if (!t) return se(r, e.parentNodeId);
1033
+ if (t.nodeType !== "group")
1034
+ return r.error(f.parentNotGroup, `Parent node is not a group: ${e.parentNodeId}.`), null;
1035
+ const s = ie(i.root, l(e.node), e.parentNodeId);
1036
+ return s ? N(i, n, { root: s }) : null;
1037
+ }
1038
+ case "node.remove": {
1039
+ const t = T(i.root, e.nodeId);
1040
+ if (!t) return R(r, e.nodeId);
1041
+ if (t.parent.nodeId !== e.parentNodeId)
1042
+ return v(r, e.nodeId, "Node parent");
1043
+ if (!y(t.node, e.removed)) return v(r, e.nodeId, "Node removal");
1044
+ const s = pe(i.root, e.nodeId);
1045
+ return s.removed ? N(i, n, { root: s.root }) : null;
1046
+ }
1047
+ case "node.duplicate": {
1048
+ if (m(i.root, e.created.nodeId)) return ye(r, e.created.nodeId);
1049
+ const t = m(i.root, e.parentNodeId);
1050
+ if (!t) return se(r, e.parentNodeId);
1051
+ if (t.nodeType !== "group")
1052
+ return r.error(f.parentNotGroup, `Parent node is not a group: ${e.parentNodeId}.`), null;
1053
+ if (!m(i.root, e.nodeId)) return R(r, e.nodeId);
1054
+ const s = ie(i.root, l(e.created), e.parentNodeId);
1055
+ return s ? N(i, n, { root: s }) : null;
1056
+ }
1057
+ case "node.transform":
1058
+ return F(i, e.nodeId, r, n, (t) => y(t.localTransform, e.before) ? { ...t, localTransform: l(e.after) } : v(r, e.nodeId, "Transform"));
1059
+ case "node.setOrigin":
1060
+ return F(i, e.nodeId, r, n, (t) => {
1061
+ if (!y(t.origin ?? null, e.before))
1062
+ return v(r, e.nodeId, "Origin");
1063
+ if (!y(t.localTransform, e.beforeTransform))
1064
+ return v(r, e.nodeId, "Origin transform");
1065
+ const s = { ...t };
1066
+ return e.after === null ? delete s.origin : s.origin = l(e.after), {
1067
+ ...s,
1068
+ localTransform: l(e.afterTransform)
1069
+ };
1070
+ });
1071
+ case "node.reparent": {
1072
+ const t = T(i.root, e.nodeId);
1073
+ if (!t) return R(r, e.nodeId);
1074
+ if (t.parent.nodeId !== e.fromParentNodeId)
1075
+ return v(r, e.nodeId, "Node parent");
1076
+ if (!y(t.node.localTransform, e.before))
1077
+ return v(r, e.nodeId, "Reparent transform");
1078
+ const s = m(i.root, e.toParentNodeId);
1079
+ if (!s) return se(r, e.toParentNodeId);
1080
+ if (s.nodeType !== "group")
1081
+ return r.error(
1082
+ f.parentNotGroup,
1083
+ `Parent node is not a group: ${e.toParentNodeId}.`
1084
+ ), null;
1085
+ if (e.toParentNodeId === e.nodeId || t.node.nodeType === "group" && m(t.node, e.toParentNodeId))
1086
+ return r.error(
1087
+ f.invalidResult,
1088
+ `Cannot reparent ${e.nodeId} below itself or one of its descendants.`
1089
+ ), null;
1090
+ const d = pe(i.root, e.nodeId);
1091
+ if (!d.removed) return R(r, e.nodeId);
1092
+ const a = ie(
1093
+ d.root,
1094
+ { ...d.removed, localTransform: l(e.after) },
1095
+ e.toParentNodeId
1096
+ );
1097
+ return a ? N(i, n, { root: a }) : (r.error(
1098
+ f.invalidResult,
1099
+ `Could not reparent ${e.nodeId} below ${e.toParentNodeId}.`
1100
+ ), null);
1101
+ }
1102
+ case "node.rename":
1103
+ return F(i, e.nodeId, r, n, (t) => t.label !== e.before ? v(r, e.nodeId, "Rename") : e.after.trim().length === 0 ? (r.error(f.emptyLabel, "Scene node label must not be empty."), null) : { ...t, label: e.after });
1104
+ case "node.setRole":
1105
+ return H(i, e.nodeId, r, n, (t) => t.role !== e.before ? v(r, e.nodeId, "Role") : { ...t, role: e.after });
1106
+ case "node.setPhysics":
1107
+ return H(i, e.nodeId, r, n, (t) => y(t.physics, e.before) ? { ...t, physics: l(e.after) } : v(r, e.nodeId, "Physics"));
1108
+ case "node.setInitialPose":
1109
+ return H(i, e.nodeId, r, n, (t) => {
1110
+ var a;
1111
+ const s = ((a = t.initialPose) == null ? void 0 : a.joints) ?? null;
1112
+ if (!y(s, e.before)) return v(r, e.nodeId, "Initial pose");
1113
+ const d = { ...t };
1114
+ return e.after === null ? delete d.initialPose : d.initialPose = { joints: l(e.after) }, d;
1115
+ });
1116
+ case "node.setAppearance":
1117
+ return H(i, e.nodeId, r, n, (t) => {
1118
+ if (!y(t.appearance ?? null, e.before)) return v(r, e.nodeId, "Appearance");
1119
+ const s = { ...t };
1120
+ return e.after === null ? delete s.appearance : s.appearance = l(e.after), s;
1121
+ });
1122
+ case "node.setVisible":
1123
+ return F(i, e.nodeId, r, n, (t) => "visible" in t ? t.visible !== e.before ? v(r, e.nodeId, "Visibility") : { ...t, visible: e.after } : (r.error(f.invalidResult, `Visibility requires an asset or visual node: ${e.nodeId}.`), null));
1124
+ case "placeholder.bind":
1125
+ return Xi(i, e.nodeId, r, n, (t) => {
1126
+ if ((t.assetRevisionId ?? null) !== e.before)
1127
+ return v(r, e.nodeId, "Placeholder binding");
1128
+ if (e.after !== null && !i.assets.some((d) => d.revisionId === e.after))
1129
+ return r.error(
1130
+ f.revisionNotFound,
1131
+ `Placeholder binding references unknown asset revision: ${e.after}.`
1132
+ ), null;
1133
+ const s = { ...t };
1134
+ return e.after === null ? delete s.assetRevisionId : s.assetRevisionId = e.after, s;
1135
+ });
1136
+ case "node.replaceModel": {
1137
+ const t = T(i.root, e.nodeId);
1138
+ if (!t) return R(r, e.nodeId);
1139
+ if (t.parent.nodeId !== e.parentNodeId)
1140
+ return v(r, e.nodeId, "Model replacement parent");
1141
+ if (!y(t.node, e.before))
1142
+ return v(r, e.nodeId, "Model replacement");
1143
+ if (e.after.nodeId !== e.nodeId)
1144
+ return r.error(f.invalidResult, "Model replacement must preserve nodeId."), null;
1145
+ if (!y(e.after.localTransform.position, e.before.localTransform.position) || !y(e.after.localTransform.scale, e.before.localTransform.scale))
1146
+ return r.error(
1147
+ f.invalidResult,
1148
+ "Model replacement must preserve position and scale."
1149
+ ), null;
1150
+ const s = z(i.root, e.nodeId, () => l(e.after));
1151
+ return s.node ? N(i, n, { root: s.root }) : null;
1152
+ }
1153
+ case "node.setVariants":
1154
+ return H(i, e.nodeId, r, n, (t) => y(t.variantSelections, e.before) ? { ...t, variantSelections: l(e.after) } : v(r, e.nodeId, "Variants"));
1155
+ case "node.setSemantic":
1156
+ return F(i, e.nodeId, r, n, (t) => {
1157
+ if (t.nodeType === "group") return t;
1158
+ if (!y(t.semantic ?? null, e.before)) return v(r, e.nodeId, "Semantic");
1159
+ const s = { ...t };
1160
+ return e.after === null ? delete s.semantic : s.semantic = l(e.after), s;
1161
+ });
1162
+ case "node.setVisualAppearance":
1163
+ return te(i, e.nodeId, r, n, (t) => {
1164
+ if (!y(t.appearance ?? null, e.before))
1165
+ return v(r, e.nodeId, "Visual appearance");
1166
+ const s = { ...t };
1167
+ return e.after === null ? delete s.appearance : s.appearance = l(e.after), s;
1168
+ });
1169
+ case "node.setVisualSelectionMode":
1170
+ return te(i, e.nodeId, r, n, (t) => t.selectionMode !== e.before ? v(r, e.nodeId, "Visual selection mode") : { ...t, selectionMode: e.after });
1171
+ case "node.setVisualRenderLayer":
1172
+ return te(i, e.nodeId, r, n, (t) => t.renderLayer !== e.before ? v(r, e.nodeId, "Visual render layer") : { ...t, renderLayer: e.after });
1173
+ case "asset.add":
1174
+ return i.assets.some((t) => t.revisionId === e.revision.revisionId) ? (r.error(f.revisionExists, `Asset revision already exists: ${e.revision.revisionId}.`), null) : be(e.revision) !== e.revision.contentHash ? (r.error(f.revisionHashMismatch, `Asset revision contentHash does not match its facts: ${e.revision.revisionId}.`), null) : N(i, n, { assets: [...i.assets, l(e.revision)] });
1175
+ case "asset.remove": {
1176
+ const t = i.assets.findIndex((a) => a.revisionId === e.revisionId);
1177
+ if (t < 0)
1178
+ return r.error(f.revisionNotFound, `Asset revision not found: ${e.revisionId}.`), null;
1179
+ if (!y(i.assets[t], e.removed))
1180
+ return v(r, e.revisionId, "Asset removal");
1181
+ const s = Ne(i).filter((a) => a.assetRevisionId === e.revisionId);
1182
+ if (s.length > 0)
1183
+ return r.error(
1184
+ f.revisionInUse,
1185
+ `Asset revision ${e.revisionId} is used by ${s.length} scene node(s).`,
1186
+ { revisionId: e.revisionId, count: s.length }
1187
+ ), null;
1188
+ const d = [...i.assets];
1189
+ return d.splice(t, 1), N(i, n, { assets: d });
1190
+ }
1191
+ case "visualAsset.add":
1192
+ return i.visualAssets.some((t) => t.visualRevisionId === e.revision.visualRevisionId) ? (r.error(
1193
+ f.revisionExists,
1194
+ `Visual asset revision already exists: ${e.revision.visualRevisionId}.`
1195
+ ), null) : De(e.revision) !== e.revision.contentHash ? (r.error(
1196
+ f.revisionHashMismatch,
1197
+ `Visual asset contentHash does not match its facts: ${e.revision.visualRevisionId}.`
1198
+ ), null) : N(i, n, {
1199
+ visualAssets: [...i.visualAssets, l(e.revision)]
1200
+ });
1201
+ case "visualAsset.remove": {
1202
+ const t = i.visualAssets.findIndex((a) => a.visualRevisionId === e.visualRevisionId);
1203
+ if (t < 0)
1204
+ return r.error(
1205
+ f.revisionNotFound,
1206
+ `Visual asset revision not found: ${e.visualRevisionId}.`
1207
+ ), null;
1208
+ if (!y(i.visualAssets[t], e.removed))
1209
+ return v(r, e.visualRevisionId, "Visual asset removal");
1210
+ const s = Ae(i).filter((a) => a.visualRevisionId === e.visualRevisionId);
1211
+ if (s.length > 0)
1212
+ return r.error(
1213
+ f.revisionInUse,
1214
+ `Visual asset revision ${e.visualRevisionId} is used by ${s.length} scene node(s).`,
1215
+ { revisionId: e.visualRevisionId, count: s.length }
1216
+ ), null;
1217
+ const d = [...i.visualAssets];
1218
+ return d.splice(t, 1), N(i, n, { visualAssets: d });
1219
+ }
1220
+ case "meta.update": {
1221
+ const t = {
1222
+ ...e.after.name === void 0 ? {} : { name: i.meta.name },
1223
+ ...e.after.description === void 0 ? {} : { description: i.meta.description ?? null }
1224
+ };
1225
+ if (!y(t, e.before)) return v(r, "scene", "Metadata");
1226
+ const s = { ...i.meta, ...e.after.name === void 0 ? {} : { name: e.after.name } };
1227
+ return e.after.description !== void 0 && (e.after.description === null ? delete s.description : s.description = e.after.description), N(i, n, { meta: s });
1228
+ }
1229
+ case "coordinateSystem.update":
1230
+ return y(i.coordinateSystem, e.before) ? N(i, n, { coordinateSystem: l(e.after) }) : v(r, "scene", "Coordinate system");
1231
+ case "environment.update":
1232
+ return y(i.environment, e.before) ? N(i, n, { environment: l(e.after) }) : v(r, "scene", "Environment");
1233
+ case "semantic.update":
1234
+ if (!y(i.semantic ?? null, e.before)) return v(r, "scene", "Semantic");
1235
+ {
1236
+ const t = { ...i };
1237
+ return e.after === null ? delete t.semantic : t.semantic = l(e.after), N(t, n, {});
1238
+ }
1239
+ case "node.setDomainData": {
1240
+ if (!Y(e.after.payload) || !Number.isInteger(e.after.dataVersion) || e.after.dataVersion <= 0)
1241
+ return r.error(
1242
+ f.invalidDomainData,
1243
+ "Domain node data requires a positive integer version and finite JSON payload."
1244
+ ), null;
1245
+ const t = m(i.root, e.nodeId);
1246
+ return t ? t.nodeType !== "domain" ? (r.error(
1247
+ f.invalidResult,
1248
+ `Command requires a domain node: ${e.nodeId}.`
1249
+ ), null) : e.before.domainId !== t.domainId || e.after.domainId !== t.domainId ? (r.error(
1250
+ f.invalidResult,
1251
+ `Command cannot change the domain of node ${e.nodeId}.`
1252
+ ), null) : y(
1253
+ {
1254
+ domainId: t.domainId,
1255
+ dataVersion: t.dataVersion,
1256
+ payload: t.payload
1257
+ },
1258
+ e.before
1259
+ ) ? Wi(i, e.nodeId, r, n, (s) => ({
1260
+ ...s,
1261
+ dataVersion: e.after.dataVersion,
1262
+ payload: l(e.after.payload)
1263
+ })) : v(r, e.nodeId, "Domain node data") : R(r, e.nodeId);
1264
+ }
1265
+ case "domain.update": {
1266
+ if (!Qi.test(e.domainId))
1267
+ return r.error(
1268
+ f.invalidDomainId,
1269
+ `Document domain id must be namespaced: ${e.domainId}.`
1270
+ ), null;
1271
+ if (e.after !== null && (!Number.isInteger(e.after.dataVersion) || e.after.dataVersion <= 0 || !Y(e.after.data)))
1272
+ return r.error(
1273
+ f.invalidDomainData,
1274
+ `Document domain ${e.domainId} requires a positive integer version and finite JSON data.`
1275
+ ), null;
1276
+ const t = Object.prototype.hasOwnProperty.call(i.domains ?? {}, e.domainId) ? i.domains[e.domainId] : null;
1277
+ if (!y(t, e.before))
1278
+ return v(r, e.domainId, "Document domain");
1279
+ const s = { ...i.domains };
1280
+ return e.after === null ? delete s[e.domainId] : s[e.domainId] = l(e.after), N(i, n, Object.keys(s).length > 0 ? { domains: s } : { domains: void 0 });
1281
+ }
1282
+ case "extension.set": {
1283
+ if (!e.key.trim() || ["__proto__", "constructor", "prototype"].includes(e.key) || !Y(e.after))
1284
+ return r.error(f.invalidResult, "Scene extensions require a valid key and finite JSON data."), null;
1285
+ const t = Object.prototype.hasOwnProperty.call(i.extensions ?? {}, e.key) ? i.extensions[e.key] : null;
1286
+ if (!y(t, e.before)) return v(r, e.key, "Extension");
1287
+ const s = { ...i.extensions };
1288
+ return e.after === null ? delete s[e.key] : s[e.key] = l(e.after), N(i, n, { extensions: s });
1289
+ }
1290
+ default: {
1291
+ const t = e;
1292
+ return r.error(f.invalidResult, `Unsupported command: ${String(t.type)}`), null;
1293
+ }
1294
+ }
1295
+ }
1296
+ function F(i, e, r, n, t) {
1297
+ if (!m(i.root, e)) return R(r, e);
1298
+ const s = z(i.root, e, t);
1299
+ return s.node ? N(i, n, { root: s.root }) : null;
1300
+ }
1301
+ function H(i, e, r, n, t) {
1302
+ const s = Je(i.root, e, t);
1303
+ return s.node ? N(i, n, { root: s.root }) : G(i.root).some((a) => a.nodeId === e) ? (r.error(f.invalidResult, `Command requires an asset node: ${e}.`), null) : R(r, e);
1304
+ }
1305
+ function te(i, e, r, n, t) {
1306
+ var d;
1307
+ const s = z(i.root, e, (a) => a.nodeType === "visual" ? t(a) : a);
1308
+ return ((d = s.node) == null ? void 0 : d.nodeType) !== "visual" ? G(i.root).some((c) => c.nodeId === e) ? (r.error(f.invalidResult, `Command requires a visual node: ${e}.`), null) : R(r, e) : N(i, n, { root: s.root });
1309
+ }
1310
+ function Xi(i, e, r, n, t) {
1311
+ var d;
1312
+ const s = z(i.root, e, (a) => a.nodeType === "placeholder" ? t(a) : a);
1313
+ return ((d = s.node) == null ? void 0 : d.nodeType) !== "placeholder" ? G(i.root).some((c) => c.nodeId === e) ? (r.error(f.invalidResult, `Command requires a placeholder node: ${e}.`), null) : R(r, e) : N(i, n, { root: s.root });
1314
+ }
1315
+ function Wi(i, e, r, n, t) {
1316
+ var d;
1317
+ const s = z(i.root, e, (a) => a.nodeType === "domain" ? t(a) : a);
1318
+ return ((d = s.node) == null ? void 0 : d.nodeType) !== "domain" ? G(i.root).some((c) => c.nodeId === e) ? (r.error(f.invalidResult, `Command requires a domain node: ${e}.`), null) : R(r, e) : N(i, n, { root: s.root });
1319
+ }
1320
+ function R(i, e) {
1321
+ return i.error(f.nodeNotFound, `Scene node not found: ${e}.`, { nodeId: e }), null;
1322
+ }
1323
+ function ye(i, e) {
1324
+ return i.error(f.nodeExists, `Scene node already exists: ${e}.`, { nodeId: e }), null;
1325
+ }
1326
+ function se(i, e) {
1327
+ return i.error(f.parentNotFound, `Parent scene node not found: ${e}.`, { nodeId: e }), null;
1328
+ }
1329
+ function v(i, e, r) {
1330
+ return i.error(f.payloadMismatch, `${r} payload does not match ${e}.`, { nodeId: e }), null;
1331
+ }
1332
+ function N(i, e, r) {
1333
+ return l({
1334
+ ...i,
1335
+ ...r,
1336
+ meta: { ...r.meta ?? i.meta, updatedAt: e }
1337
+ });
1338
+ }
1339
+ function Zi(i, e) {
1340
+ const r = e.label.trim();
1341
+ if (r.length === 0) throw new Error("Command label must not be empty.");
1342
+ return {
1343
+ id: e.id ?? `cmd_${L()}`,
1344
+ batchId: e.batchId,
1345
+ type: i.type,
1346
+ payload: l(i),
1347
+ label: r,
1348
+ source: e.source ?? "human",
1349
+ at: e.now ?? (/* @__PURE__ */ new Date()).toISOString()
1350
+ };
1351
+ }
1352
+ function vr(i, e, r = (/* @__PURE__ */ new Date()).toISOString()) {
1353
+ let n = i;
1354
+ const t = [], s = [];
1355
+ for (const d of e) {
1356
+ const a = W(n, d.payload, r);
1357
+ if (s.push(...a.diagnostics), a.diagnostics.some((c) => c.level === "error"))
1358
+ return { doc: n, applied: t, diagnostics: s };
1359
+ n = a.doc, t.push(d);
1360
+ }
1361
+ return { doc: n, applied: t, diagnostics: s };
1362
+ }
1363
+ function Y(i, e = /* @__PURE__ */ new Set()) {
1364
+ if (i === null || typeof i == "string" || typeof i == "boolean") return !0;
1365
+ if (typeof i == "number") return Number.isFinite(i);
1366
+ if (typeof i != "object" || e.has(i) || !Array.isArray(i) && Object.getPrototypeOf(i) !== Object.prototype && Object.getPrototypeOf(i) !== null) return !1;
1367
+ e.add(i);
1368
+ const r = Object.entries(i).every(([n, t]) => !["__proto__", "constructor", "prototype"].includes(n) && Y(t, e));
1369
+ return e.delete(i), r;
1370
+ }
1371
+ const Qi = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9_-]*)+$/, Ue = {
1372
+ revisionMissing: "SIM_CREATE_NODE_REVISION_MISSING"
1373
+ };
1374
+ function Sr(i, e) {
1375
+ if (i.revisionId !== e.revisionId)
1376
+ throw new Error(`${Ue.revisionMissing}: revision id mismatch (${i.revisionId} vs ${e.revisionId})`);
1377
+ return Ze({
1378
+ nodeId: e.nodeId ?? `${B.node}${L()}`,
1379
+ label: e.label,
1380
+ assetRevisionId: i.revisionId,
1381
+ role: e.role,
1382
+ localTransform: l(e.localTransform ?? oe()),
1383
+ ...e.origin ? { origin: l(e.origin) } : {},
1384
+ visible: e.visible ?? !0,
1385
+ variantSelections: l(e.variantSelections ?? {}),
1386
+ ...e.appearance ? { appearance: l(e.appearance) } : {},
1387
+ physics: l(e.physics ?? er(i)),
1388
+ ...e.initialPose ? { initialPose: { joints: l(e.initialPose) } } : {},
1389
+ ...e.semantic ? { semantic: l(e.semantic) } : {}
1390
+ });
1391
+ }
1392
+ function er(i) {
1393
+ return i.capabilities.physics === "none" && i.capabilities.rigidBody === !1 && i.capabilities.articulation === !1 ? { kind: "static" } : { kind: "asset-authored" };
1394
+ }
1395
+ function Ir(i, e) {
1396
+ if (i.visualRevisionId !== e.visualRevisionId)
1397
+ throw new Error(
1398
+ `${Ue.revisionMissing}: visual revision id mismatch (${i.visualRevisionId} vs ${e.visualRevisionId})`
1399
+ );
1400
+ return ii({
1401
+ nodeId: e.nodeId ?? `${B.node}${L()}`,
1402
+ label: e.label,
1403
+ visualRevisionId: i.visualRevisionId,
1404
+ localTransform: l(e.localTransform ?? oe()),
1405
+ ...e.origin ? { origin: l(e.origin) } : {},
1406
+ visible: e.visible ?? !0,
1407
+ renderLayer: e.renderLayer ?? "default",
1408
+ selectionMode: e.selectionMode ?? "bounds",
1409
+ ...e.appearance ? { appearance: l(e.appearance) } : {},
1410
+ ...e.semantic ? { semantic: l(e.semantic) } : {}
1411
+ });
1412
+ }
1413
+ function yr(i, e, r) {
1414
+ return p({ type: "node.add", parentNodeId: e, node: i }, r);
1415
+ }
1416
+ function ir(i, e, r) {
1417
+ const n = b(i, e), t = T(i.root, e);
1418
+ if (!t) throw new Error(`Scene node not found: ${e}`);
1419
+ return p({ type: "node.remove", nodeId: e, parentNodeId: t.parent.nodeId, removed: n }, r);
1420
+ }
1421
+ function hr(i, e, r, n) {
1422
+ const t = b(i, e);
1423
+ return p({ type: "node.transform", nodeId: e, before: l(t.localTransform), after: l(r) }, n);
1424
+ }
1425
+ function Ar(i, e, r, n) {
1426
+ const t = b(i, e), s = (r == null ? void 0 : r.local) ?? [0, 0, 0], d = Xe(
1427
+ t.localTransform,
1428
+ We(t),
1429
+ s
1430
+ );
1431
+ return p({
1432
+ type: "node.setOrigin",
1433
+ nodeId: e,
1434
+ before: t.origin ? l(t.origin) : null,
1435
+ after: r ? l(r) : null,
1436
+ beforeTransform: l(t.localTransform),
1437
+ afterTransform: l(d)
1438
+ }, n);
1439
+ }
1440
+ function rr(i, e, r, n) {
1441
+ const t = T(i.root, e);
1442
+ if (!t) throw new Error(`Scene node not found: ${e}`);
1443
+ const s = m(i.root, r);
1444
+ if (!s || s.nodeType !== "group")
1445
+ throw new Error(`Scene group not found: ${r}`);
1446
+ const d = X(i.root, e), a = X(i.root, r), c = d && a ? Ee(d, a) : null;
1447
+ if (!c) throw new Error(`Cannot preserve world transform while reparenting ${e}.`);
1448
+ return p({
1449
+ type: "node.reparent",
1450
+ nodeId: e,
1451
+ fromParentNodeId: t.parent.nodeId,
1452
+ toParentNodeId: r,
1453
+ before: l(t.node.localTransform),
1454
+ after: c
1455
+ }, n);
1456
+ }
1457
+ function Nr(i, e, r, n) {
1458
+ const t = [...new Set(e)];
1459
+ if (t.length < 2) throw new Error("Grouping requires at least two scene nodes.");
1460
+ const s = m(i.root, r);
1461
+ if (!s || s.nodeType !== "group")
1462
+ throw new Error(`Scene group not found: ${r}`);
1463
+ const d = n.groupId ?? `${B.node}${L()}`, a = Ye({
1464
+ nodeId: d,
1465
+ label: n.groupLabel,
1466
+ localTransform: oe()
1467
+ }), c = [
1468
+ p({ type: "node.add", parentNodeId: r, node: a }, n)
1469
+ ], S = X(i.root, r);
1470
+ if (!S) throw new Error(`Scene group has no world transform: ${r}`);
1471
+ const h = W(i, c[0].payload);
1472
+ if (h.diagnostics.some((E) => E.level === "error"))
1473
+ throw new Error(h.diagnostics.map((E) => E.message).join(`
1474
+ `));
1475
+ let D = h.doc;
1476
+ for (const E of t) {
1477
+ const w = T(D.root, E);
1478
+ if (!w) throw new Error(`Scene node not found: ${E}`);
1479
+ const $ = X(D.root, E), C = $ ? Ee($, S) : null;
1480
+ if (!C) throw new Error(`Cannot preserve world transform while grouping ${E}.`);
1481
+ const g = p({
1482
+ type: "node.reparent",
1483
+ nodeId: E,
1484
+ fromParentNodeId: w.parent.nodeId,
1485
+ toParentNodeId: d,
1486
+ before: l(w.node.localTransform),
1487
+ after: C
1488
+ }, n);
1489
+ c.push(g);
1490
+ const P = W(D, g.payload);
1491
+ if (P.diagnostics.some((A) => A.level === "error"))
1492
+ throw new Error(P.diagnostics.map((A) => A.message).join(`
1493
+ `));
1494
+ D = P.doc;
1495
+ }
1496
+ return c;
1497
+ }
1498
+ function Er(i, e, r) {
1499
+ const n = T(i.root, e);
1500
+ if (!n || n.node.nodeType !== "group")
1501
+ throw new Error(`Scene group not found: ${e}`);
1502
+ const t = n.parent.nodeId, s = [];
1503
+ let d = i;
1504
+ for (const a of n.node.children.map((c) => c.nodeId)) {
1505
+ const c = rr(d, a, t, r);
1506
+ s.push(c);
1507
+ const S = W(d, c.payload);
1508
+ if (S.diagnostics.some((h) => h.level === "error"))
1509
+ throw new Error(S.diagnostics.map((h) => h.message).join(`
1510
+ `));
1511
+ d = S.doc;
1512
+ }
1513
+ return s.push(ir(d, e, r)), s;
1514
+ }
1515
+ function mr(i, e, r, n) {
1516
+ const t = b(i, e);
1517
+ return p({ type: "node.rename", nodeId: e, before: t.label, after: r }, n);
1518
+ }
1519
+ function _r(i, e, r, n) {
1520
+ const t = k(i, e);
1521
+ return p({ type: "node.setRole", nodeId: e, before: t.role, after: r }, n);
1522
+ }
1523
+ function $r(i, e, r, n) {
1524
+ const t = k(i, e);
1525
+ return p({ type: "node.setPhysics", nodeId: e, before: l(t.physics), after: l(r) }, n);
1526
+ }
1527
+ function Rr(i, e, r, n) {
1528
+ const t = k(i, e);
1529
+ return p({
1530
+ type: "node.setInitialPose",
1531
+ nodeId: e,
1532
+ before: t.initialPose ? l(t.initialPose.joints) : null,
1533
+ after: r ? l(r) : null
1534
+ }, n);
1535
+ }
1536
+ function br(i, e, r, n) {
1537
+ const t = k(i, e);
1538
+ return p({
1539
+ type: "node.setAppearance",
1540
+ nodeId: e,
1541
+ before: t.appearance ? l(t.appearance) : null,
1542
+ after: r ? l(r) : null
1543
+ }, n);
1544
+ }
1545
+ function Dr(i, e, r, n) {
1546
+ const t = b(i, e);
1547
+ if (!("visible" in t)) throw new Error(`Scene node does not support visibility: ${e}`);
1548
+ return p({ type: "node.setVisible", nodeId: e, before: t.visible, after: r }, n);
1549
+ }
1550
+ function Vr(i, e, r, n) {
1551
+ const t = nr(i, e);
1552
+ return p({
1553
+ type: "placeholder.bind",
1554
+ nodeId: e,
1555
+ before: t.assetRevisionId ?? null,
1556
+ after: r
1557
+ }, n);
1558
+ }
1559
+ function Mr(i, e, r, n) {
1560
+ const t = b(i, e);
1561
+ if (t.nodeType !== "asset" && t.nodeType !== "placeholder")
1562
+ throw new Error(`Scene node is not an asset or placeholder: ${e}`);
1563
+ if (r.nodeType !== "asset" && r.nodeType !== "placeholder")
1564
+ throw new Error("Model replacement must produce an asset or placeholder node.");
1565
+ if (r.nodeId !== e)
1566
+ throw new Error("Model replacement must preserve the nodeId.");
1567
+ const s = T(i.root, e);
1568
+ if (!s) throw new Error(`Scene node not found: ${e}`);
1569
+ return p({
1570
+ type: "node.replaceModel",
1571
+ nodeId: e,
1572
+ parentNodeId: s.parent.nodeId,
1573
+ before: l(t),
1574
+ after: l(r)
1575
+ }, n);
1576
+ }
1577
+ function Or(i) {
1578
+ const e = [
1579
+ i.dimensions.length,
1580
+ i.dimensions.width,
1581
+ i.dimensions.height
1582
+ ];
1583
+ if (e.some((n) => !Number.isFinite(n) || n <= 0))
1584
+ throw new Error("Bounding box dimensions must be positive finite values.");
1585
+ const r = i.localUpDirection ?? [0, 0, 1];
1586
+ if (r.some((n) => !Number.isFinite(n)))
1587
+ throw new Error("Local up direction must contain finite values.");
1588
+ return Qe({
1589
+ nodeId: i.nodeId,
1590
+ label: i.label,
1591
+ size: e,
1592
+ role: i.role,
1593
+ localTransform: {
1594
+ position: i.position ?? [0, 0, 0],
1595
+ rotation: ei(r),
1596
+ scale: [1, 1, 1]
1597
+ },
1598
+ visible: i.visible,
1599
+ ...i.assetRevisionId ? { assetRevisionId: i.assetRevisionId } : {},
1600
+ ...i.externalRef ? { externalRef: i.externalRef } : {},
1601
+ ...i.semantic ? { semantic: i.semantic } : {}
1602
+ });
1603
+ }
1604
+ function Tr(i, e, r, n) {
1605
+ const t = ue(i, e);
1606
+ return p({
1607
+ type: "node.setVisualAppearance",
1608
+ nodeId: e,
1609
+ before: t.appearance ? l(t.appearance) : null,
1610
+ after: r ? l(r) : null
1611
+ }, n);
1612
+ }
1613
+ function wr(i, e, r, n) {
1614
+ const t = ue(i, e);
1615
+ return p({
1616
+ type: "node.setVisualSelectionMode",
1617
+ nodeId: e,
1618
+ before: t.selectionMode,
1619
+ after: r
1620
+ }, n);
1621
+ }
1622
+ function Cr(i, e, r, n) {
1623
+ const t = ue(i, e);
1624
+ return p({
1625
+ type: "node.setVisualRenderLayer",
1626
+ nodeId: e,
1627
+ before: t.renderLayer,
1628
+ after: r
1629
+ }, n);
1630
+ }
1631
+ function gr(i, e, r, n) {
1632
+ const t = k(i, e);
1633
+ return p({
1634
+ type: "node.setVariants",
1635
+ nodeId: e,
1636
+ before: l(t.variantSelections),
1637
+ after: l(r)
1638
+ }, n);
1639
+ }
1640
+ function Pr(i, e, r, n) {
1641
+ const t = k(i, e);
1642
+ return p({
1643
+ type: "node.setSemantic",
1644
+ nodeId: e,
1645
+ before: t.semantic ? l(t.semantic) : null,
1646
+ after: r ? l(r) : null
1647
+ }, n);
1648
+ }
1649
+ function xr(i, e, r, n) {
1650
+ const t = b(i, e), s = Fe(
1651
+ t,
1652
+ n.nodeId ?? `${B.node}${L()}`,
1653
+ n.nodeLabel ?? sr(i, t.label)
1654
+ ), { nodeId: d, nodeLabel: a, ...c } = n;
1655
+ return p({ type: "node.duplicate", nodeId: e, parentNodeId: r, created: s }, c);
1656
+ }
1657
+ function Fe(i, e, r) {
1658
+ const n = {
1659
+ ...l(i),
1660
+ nodeId: e,
1661
+ label: r
1662
+ };
1663
+ return n.nodeType === "group" ? {
1664
+ ...n,
1665
+ children: n.children.map((t) => Fe(t, `${B.node}${L()}`, t.label))
1666
+ } : n;
1667
+ }
1668
+ function Lr(i, e) {
1669
+ return p({ type: "asset.add", revision: i }, e);
1670
+ }
1671
+ function kr(i, e) {
1672
+ return p({ type: "visualAsset.add", revision: i }, e);
1673
+ }
1674
+ function jr(i, e, r) {
1675
+ const n = i.assets.find((t) => t.revisionId === e);
1676
+ if (!n) throw new Error(`Asset revision not found: ${e}`);
1677
+ return p({ type: "asset.remove", revisionId: e, removed: l(n) }, r);
1678
+ }
1679
+ function Ur(i, e, r) {
1680
+ const n = i.visualAssets.find((t) => t.visualRevisionId === e);
1681
+ if (!n) throw new Error(`Visual asset revision not found: ${e}`);
1682
+ return p({
1683
+ type: "visualAsset.remove",
1684
+ visualRevisionId: e,
1685
+ removed: l(n)
1686
+ }, r);
1687
+ }
1688
+ function Fr(i, e, r) {
1689
+ const n = {
1690
+ ...e.name === void 0 ? {} : { name: i.meta.name },
1691
+ ...e.description === void 0 ? {} : { description: i.meta.description ?? null }
1692
+ };
1693
+ return p({ type: "meta.update", before: n, after: l(e) }, r);
1694
+ }
1695
+ function Hr(i, e, r) {
1696
+ return p({
1697
+ type: "coordinateSystem.update",
1698
+ before: l(i.coordinateSystem),
1699
+ after: l(e)
1700
+ }, r);
1701
+ }
1702
+ function zr(i, e, r) {
1703
+ return p({
1704
+ type: "environment.update",
1705
+ before: l(i.environment),
1706
+ after: l(e)
1707
+ }, r);
1708
+ }
1709
+ function Gr(i, e, r) {
1710
+ return p({
1711
+ type: "semantic.update",
1712
+ before: i.semantic ? l(i.semantic) : null,
1713
+ after: e ? l(e) : null
1714
+ }, r);
1715
+ }
1716
+ function Br(i, e, r, n) {
1717
+ var s;
1718
+ const t = ((s = i.domains) == null ? void 0 : s[e]) ?? null;
1719
+ return p({
1720
+ type: "domain.update",
1721
+ domainId: e,
1722
+ before: t ? l(t) : null,
1723
+ after: r ? l(r) : null
1724
+ }, n);
1725
+ }
1726
+ function qr(i, e, r, n) {
1727
+ const t = tr(i, e);
1728
+ if (t.domainId !== r.domainId)
1729
+ throw new Error(
1730
+ `Domain node ${e} belongs to ${t.domainId}, not ${r.domainId}.`
1731
+ );
1732
+ return p({
1733
+ type: "node.setDomainData",
1734
+ nodeId: e,
1735
+ before: {
1736
+ domainId: t.domainId,
1737
+ dataVersion: t.dataVersion,
1738
+ payload: l(t.payload)
1739
+ },
1740
+ after: {
1741
+ domainId: r.domainId,
1742
+ dataVersion: r.dataVersion,
1743
+ payload: l(r.payload)
1744
+ }
1745
+ }, n);
1746
+ }
1747
+ function Kr(i, e, r, n) {
1748
+ const t = Object.prototype.hasOwnProperty.call(i.extensions ?? {}, e) ? i.extensions[e] : null;
1749
+ return p({ type: "extension.set", key: e, before: l(t), after: l(r) }, n);
1750
+ }
1751
+ function p(i, e) {
1752
+ return Zi(i, e);
1753
+ }
1754
+ function b(i, e) {
1755
+ const r = m(i.root, e);
1756
+ if (!r || r.nodeId === i.root.nodeId) throw new Error(`Scene node not found: ${e}`);
1757
+ return r;
1758
+ }
1759
+ function k(i, e) {
1760
+ const r = b(i, e);
1761
+ if (r.nodeType !== "asset") throw new Error(`Scene node is not an asset node: ${e}`);
1762
+ return r;
1763
+ }
1764
+ function ue(i, e) {
1765
+ const r = b(i, e);
1766
+ if (r.nodeType !== "visual") throw new Error(`Scene node is not a visual node: ${e}`);
1767
+ return r;
1768
+ }
1769
+ function nr(i, e) {
1770
+ const r = b(i, e);
1771
+ if (r.nodeType !== "placeholder")
1772
+ throw new Error(`Scene node is not a placeholder node: ${e}`);
1773
+ return r;
1774
+ }
1775
+ function tr(i, e) {
1776
+ const r = b(i, e);
1777
+ if (r.nodeType !== "domain")
1778
+ throw new Error(`Scene node is not a domain node: ${e}`);
1779
+ return r;
1780
+ }
1781
+ function sr(i, e) {
1782
+ const r = new Set(G(i.root).map((a) => a.label)), n = e.match(/^(.*) \((\d+)\)$/), t = n ? n[1] : e;
1783
+ let s = n ? Number(n[2]) + 1 : 2, d = `${t} (${s})`;
1784
+ for (; r.has(d); ) d = `${t} (${++s})`;
1785
+ return d;
1786
+ }
1787
+ function Jr(i) {
1788
+ return [.../* @__PURE__ */ new Set([
1789
+ ...Ne(i).map((e) => e.assetRevisionId),
1790
+ ...Ae(i).map((e) => e.visualRevisionId)
1791
+ ])].sort();
1792
+ }
1793
+ export {
1794
+ er as $,
1795
+ rr as A,
1796
+ Mr as B,
1797
+ f as C,
1798
+ _e as D,
1799
+ Gr as E,
1800
+ br as F,
1801
+ qr as G,
1802
+ Kr as H,
1803
+ Rr as I,
1804
+ Ar as J,
1805
+ Pr as K,
1806
+ $r as L,
1807
+ Vr as M,
1808
+ _r as N,
1809
+ gr as O,
1810
+ Dr as P,
1811
+ Tr as Q,
1812
+ Cr as R,
1813
+ o as S,
1814
+ wr as T,
1815
+ hr as U,
1816
+ Er as V,
1817
+ be as W,
1818
+ lr as X,
1819
+ Sr as Y,
1820
+ Or as Z,
1821
+ Ir as _,
1822
+ L as a,
1823
+ sr as a0,
1824
+ fr as a1,
1825
+ Jr as a2,
1826
+ cr as a3,
1827
+ dr as a4,
1828
+ ui as a5,
1829
+ yr as b,
1830
+ De as c,
1831
+ vr as d,
1832
+ W as e,
1833
+ Zi as f,
1834
+ $e as g,
1835
+ Ue as h,
1836
+ Me as i,
1837
+ O as j,
1838
+ ur as k,
1839
+ pr as l,
1840
+ Lr as m,
1841
+ kr as n,
1842
+ Hr as o,
1843
+ Br as p,
1844
+ xr as q,
1845
+ zr as r,
1846
+ Re as s,
1847
+ Nr as t,
1848
+ Fr as u,
1849
+ ge as v,
1850
+ jr as w,
1851
+ ir as x,
1852
+ Ur as y,
1853
+ mr as z
1854
+ };