@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,2705 @@
1
+ var ft = Object.defineProperty;
2
+ var pt = (e, t, s) => t in e ? ft(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var k = (e, t, s) => pt(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { W as mt, s as N, a1 as ht, v as Ve, g as C, e as te, X as w, a4 as re, a3 as M } from "./builders-BAXRR5o5.js";
5
+ import { n as R, a as m, b as Fe, m as yt, u as gt, p as It, D as vt, r as St, t as B } from "./asset-source-BExlEcRt.js";
6
+ import { S as K, a as je, d as V, Y as bt, u as Et, E as At } from "./scene-graph-DBLKAhxa.js";
7
+ function Rt(e) {
8
+ const t = [...e.resources].map((i) => ({
9
+ ...i,
10
+ locator: R(i.locator)
11
+ })).sort((i, l) => m(i.locator).localeCompare(m(l.locator)) || i.resourceId.localeCompare(l.resourceId)), s = /* @__PURE__ */ new Map();
12
+ for (const i of e.variantSets ?? []) {
13
+ const l = s.get(i.name);
14
+ if (!l) {
15
+ s.set(i.name, {
16
+ ...i,
17
+ options: [...new Set(i.options)].sort()
18
+ });
19
+ continue;
20
+ }
21
+ s.set(i.name, {
22
+ ...l,
23
+ options: [.../* @__PURE__ */ new Set([...l.options, ...i.options])].sort(),
24
+ ...l.authoredDefault ?? i.authoredDefault ? { authoredDefault: l.authoredDefault ?? i.authoredDefault } : {}
25
+ });
26
+ }
27
+ const r = [...s.values()].sort((i, l) => i.name.localeCompare(l.name)), o = {
28
+ assetId: e.assetId,
29
+ slug: e.slug,
30
+ label: e.label,
31
+ layout: e.layout,
32
+ fileKind: e.fileKind,
33
+ entryResourceId: e.entryResourceId,
34
+ resources: t,
35
+ variantSets: r,
36
+ capabilities: e.capabilities,
37
+ ...e.bounds ? { bounds: e.bounds } : {},
38
+ ...e.category ? { category: e.category } : {},
39
+ ...e.hints ? { hints: _t(e.hints) } : {},
40
+ ...e.metrics ? { metrics: e.metrics } : {},
41
+ ...e.semantic ? { semantic: e.semantic } : {}
42
+ }, n = mt(o);
43
+ return {
44
+ revisionId: `rev_${n.slice(0, 24)}`,
45
+ ...o,
46
+ contentHash: n,
47
+ provenance: e.provenance ?? { source: "user", repairs: [] }
48
+ };
49
+ }
50
+ function ir(e) {
51
+ const t = e.resources.find((s) => s.resourceId === e.entryResourceId);
52
+ if (!t) throw new Error(`Asset revision ${e.revisionId} has no entry resource.`);
53
+ return t;
54
+ }
55
+ function cr(e, t) {
56
+ const s = m(t);
57
+ return e.resources.find((r) => m(r.locator) === s) ?? null;
58
+ }
59
+ function lr(e) {
60
+ return e.resources.map((t) => m(t.locator));
61
+ }
62
+ function ur(e) {
63
+ if (e.variantSets.length === 0) return null;
64
+ const t = {};
65
+ for (const s of e.variantSets) {
66
+ const r = s.authoredDefault ?? s.options[0];
67
+ r && (t[s.name] = r);
68
+ }
69
+ return Object.keys(t).length > 0 ? t : null;
70
+ }
71
+ function dr(e) {
72
+ return e.layout === "glb" || e.fileKind === "glb";
73
+ }
74
+ function _t(e) {
75
+ return {
76
+ ...e.approximateSize ? { approximateSize: e.approximateSize } : {},
77
+ ...e.defaultRole ? { defaultRole: e.defaultRole } : {},
78
+ ...e.defaultPhysics ? { defaultPhysics: e.defaultPhysics } : {},
79
+ ...e.forwardAxis ? { forwardAxis: e.forwardAxis } : {},
80
+ ...e.tags ? { tags: [...new Set(e.tags)].sort() } : {}
81
+ };
82
+ }
83
+ function T(e) {
84
+ return e.kind === "package-path" ? e.path : e.url;
85
+ }
86
+ function Pt(e) {
87
+ return T(e.entryLocator);
88
+ }
89
+ const Dt = [".mdl"];
90
+ function Be(e) {
91
+ const t = e.split(/[?#]/, 1)[0] ?? e;
92
+ return Dt.some((s) => t.toLowerCase().endsWith(s));
93
+ }
94
+ const pe = /@(?<target>[^@\r\n]+)@(?:\s*<(?<prim>[^>]*)>)?/g, Ke = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//;
95
+ function he(e, t) {
96
+ const s = [], r = [];
97
+ for (const n of [...e].sort((i, l) => i.path.localeCompare(l.path))) {
98
+ const i = wt(n.path, n.text, t);
99
+ i.length > 0 && r.push(n.path), s.push(...i);
100
+ }
101
+ s.sort((n, i) => n.fromPath.localeCompare(i.fromPath) || n.target.localeCompare(i.target));
102
+ const o = s.filter((n) => n.kind === "asset");
103
+ return {
104
+ references: s,
105
+ missing: o.filter((n) => !n.external && n.resolvedPath === null),
106
+ external: o.filter((n) => n.external),
107
+ unanchored: o.filter((n) => !n.external && !n.anchored),
108
+ materialModules: s.filter((n) => n.kind === "material-module"),
109
+ layers: r
110
+ };
111
+ }
112
+ function fr(e, t) {
113
+ const s = t.map(R), r = new Set(s.map(m)), o = [], n = [], i = [...e].sort((u, c) => T(u.locator).localeCompare(
114
+ T(c.locator)
115
+ ));
116
+ for (const u of i) {
117
+ const c = R(u.locator), d = T(c), a = [];
118
+ for (const f of Ye(u.text)) {
119
+ const g = Be(f.target) ? "material-module" : "asset", h = Fe(
120
+ c,
121
+ f.target,
122
+ s
123
+ ), p = h && r.has(m(h)) ? T(h) : null, I = g === "asset" && h === null && Ke.test(f.target);
124
+ a.push({
125
+ fromPath: d,
126
+ target: f.target,
127
+ resolvedPath: p,
128
+ external: I,
129
+ anchored: c.kind === "remote-url" ? !0 : f.target.startsWith("./") || f.target.startsWith("../"),
130
+ primPath: f.primPath,
131
+ kind: g
132
+ });
133
+ }
134
+ a.length > 0 && n.push(d), o.push(...a);
135
+ }
136
+ o.sort((u, c) => u.fromPath.localeCompare(c.fromPath) || u.target.localeCompare(c.target));
137
+ const l = o.filter((u) => u.kind === "asset");
138
+ return {
139
+ references: o,
140
+ missing: l.filter((u) => !u.external && u.resolvedPath === null),
141
+ external: l.filter((u) => u.external),
142
+ unanchored: l.filter((u) => !u.external && !u.anchored),
143
+ materialModules: o.filter((u) => u.kind === "material-module"),
144
+ layers: n
145
+ };
146
+ }
147
+ function wt(e, t, s) {
148
+ const r = [];
149
+ for (const o of Ye(t)) {
150
+ const { target: n } = o, i = Ke.test(n), l = Be(n) ? "material-module" : "asset", u = n.startsWith("./") || n.startsWith("../"), c = i ? null : $t(e, n, s);
151
+ r.push({
152
+ fromPath: e,
153
+ target: n,
154
+ resolvedPath: c,
155
+ external: i,
156
+ anchored: u,
157
+ primPath: o.primPath,
158
+ kind: l
159
+ });
160
+ }
161
+ return r;
162
+ }
163
+ function Ye(e) {
164
+ var r, o, n, i;
165
+ const t = [], s = /* @__PURE__ */ new Set();
166
+ pe.lastIndex = 0;
167
+ for (let l = pe.exec(e); l !== null; l = pe.exec(e)) {
168
+ const u = ((o = (r = l.groups) == null ? void 0 : r.target) == null ? void 0 : o.trim()) ?? "";
169
+ if (!u) continue;
170
+ const c = ((i = (n = l.groups) == null ? void 0 : n.prim) == null ? void 0 : i.trim()) || null, d = `${u}\0${c ?? ""}`;
171
+ s.has(d) || (s.add(d), t.push({ target: u, primPath: c }));
172
+ }
173
+ return t;
174
+ }
175
+ function $t(e, t, s) {
176
+ if (t.startsWith("/")) {
177
+ const o = oe(t.slice(1));
178
+ return s.has(o) ? o : null;
179
+ }
180
+ const r = e.split("/");
181
+ r.pop();
182
+ for (let o = r.length; o >= 0; o -= 1) {
183
+ const n = r.slice(0, o).join("/"), i = oe(n ? `${n}/${t}` : t);
184
+ if (s.has(i)) return i;
185
+ }
186
+ return null;
187
+ }
188
+ function oe(e) {
189
+ const t = [];
190
+ for (const s of e.replace(/\\/g, "/").split("/"))
191
+ if (!(!s || s === ".")) {
192
+ if (s === "..") {
193
+ t.pop();
194
+ continue;
195
+ }
196
+ t.push(s);
197
+ }
198
+ return t.join("/");
199
+ }
200
+ function We(e) {
201
+ return e.toLowerCase().endsWith(".usda");
202
+ }
203
+ const Nt = "#usda", Tt = ["PXR-USDC", "PXR-USDA"];
204
+ function ve(e, t) {
205
+ if (!t || t.byteLength === 0) return We(e);
206
+ if (e.toLowerCase().endsWith(".usdc")) return !1;
207
+ const s = new TextDecoder("utf-8", { fatal: !1 }).decode(t.subarray(0, 16));
208
+ return Tt.some((r) => s.startsWith(r)) ? !1 : s.trimStart().startsWith(Nt);
209
+ }
210
+ function pr(e) {
211
+ const t = Ht(e), s = t ? ne(t, "customLayerData") : null, r = s ? ne(s, "SimReady_Metadata") : null, o = b(t, "defaultPrim"), n = kt(e, o);
212
+ return {
213
+ creator: b(t, "creator"),
214
+ startTimeCode: X(t, "startTimeCode"),
215
+ endTimeCode: X(t, "endTimeCode"),
216
+ timeCodesPerSecond: X(t, "timeCodesPerSecond"),
217
+ rootPrim: n,
218
+ simReady: r || s ? {
219
+ assetName: b(r, "asset_name") ?? b(s, "asset_name"),
220
+ assetType: b(r, "asset_type") ?? b(s, "asset_type"),
221
+ category: b(r, "category"),
222
+ author: b(r, "author"),
223
+ license: b(r, "asset_license"),
224
+ sourceFile: b(r, "source_file") ?? b(s, "source_file"),
225
+ generatedDate: b(r, "usd_date_generated") ?? b(s, "usd_date_generated"),
226
+ qcode: b(r, "qcode"),
227
+ mass: X(r, "mass"),
228
+ extents: Zt(r, "asset_extents"),
229
+ rigidBodyCount: Xt(r, "rigid_body_count"),
230
+ validation: Gt(r)
231
+ } : null,
232
+ variantSets: Ct(e)
233
+ };
234
+ }
235
+ async function mr(e) {
236
+ const t = e.find((a) => L(a.path).endsWith("/com.nvidia.simready.packaging.json") || L(a.path) === "com.nvidia.simready.packaging.json"), s = e.find((a) => /(?:^|\/)[^/]+_validation\.json$/i.test(L(a.path))), r = e.find((a) => /(?:^|\/)[^/]+_benchmark\.json$/i.test(L(a.path))), o = e.find((a) => L(a.path).endsWith("/com.nvidia.simready.packaging.bom.json") || L(a.path) === "com.nvidia.simready.packaging.bom.json");
237
+ if (!t && !s && !r) return null;
238
+ const [n, i, l, u] = await Promise.all([
239
+ t ? se(t.blob) : null,
240
+ s ? se(s.blob) : null,
241
+ r ? se(r.blob) : null,
242
+ o ? se(o.blob) : null
243
+ ]), c = Array.isArray(S(u, "items")) ? S(u, "items").filter(D) : [], d = Array.isArray(S(n, "metadata")) ? S(n, "metadata").filter(D) : [];
244
+ return {
245
+ formatVersion: E(S(n, "format_version")),
246
+ bomFormatVersion: E(S(u, "format_version")),
247
+ packageId: E(S(n, "package_id")),
248
+ license: E(S(n, "license")),
249
+ contentSha256: E(S(S(n, "content_hash"), "sha256")),
250
+ packageSha256: E(S(S(n, "package_hash"), "sha256")),
251
+ metadataFileCount: d.length,
252
+ metadataNames: d.map((a) => E(S(a, "name"))).filter((a) => !!a),
253
+ loadedFileCount: e.length,
254
+ loadedTotalBytes: e.reduce((a, f) => a + f.blob.size, 0),
255
+ bomFileCount: c.length,
256
+ bomTotalBytes: c.reduce((a, f) => a + (qt(S(f, "size")) ?? 0), 0),
257
+ validation: Yt(i),
258
+ benchmark: Wt(l)
259
+ };
260
+ }
261
+ async function hr(e) {
262
+ const t = [];
263
+ for (const a of e) {
264
+ if (!/\.(?:usda|usd)$/i.test(a.path)) continue;
265
+ const f = new Uint8Array(await a.blob.arrayBuffer());
266
+ ve(a.path, f) && t.push({
267
+ path: L(a.path),
268
+ text: new TextDecoder("utf-8").decode(f)
269
+ });
270
+ }
271
+ if (!t.length) return null;
272
+ const s = /* @__PURE__ */ new Map();
273
+ let r = 0;
274
+ for (const a of t)
275
+ for (const f of xt(a.text)) {
276
+ r += 1;
277
+ const g = Lt(f.header), h = Mt(f.source), p = s.get(f.path) ?? {
278
+ path: f.path,
279
+ typeName: f.typeName,
280
+ layers: /* @__PURE__ */ new Set(),
281
+ apiSchemas: /* @__PURE__ */ new Set(),
282
+ properties: /* @__PURE__ */ new Map(),
283
+ hasDriveAttributes: !1,
284
+ hasMimicAttributes: !1
285
+ };
286
+ p.typeName === "unknown" && f.typeName !== "unknown" && (p.typeName = f.typeName), p.layers.add(a.path);
287
+ for (const I of g) p.apiSchemas.add(I);
288
+ for (const I of h) {
289
+ const A = p.properties.get(I.name) ?? /* @__PURE__ */ new Map(), P = A.get(I.value) ?? /* @__PURE__ */ new Set();
290
+ P.add(a.path), A.set(I.value, P), p.properties.set(I.name, A);
291
+ }
292
+ p.hasDriveAttributes || (p.hasDriveAttributes = h.some((I) => I.name.startsWith("drive:"))), p.hasMimicAttributes || (p.hasMimicAttributes = h.some((I) => /mimic/i.test(I.name))), s.set(f.path, p);
293
+ }
294
+ const o = [...s.values()].map((a) => ({
295
+ path: a.path,
296
+ typeName: a.typeName,
297
+ layers: [...a.layers].sort(),
298
+ apiSchemas: [...a.apiSchemas].filter(Vt).sort(),
299
+ properties: [...a.properties.entries()].map(([f, g]) => ({
300
+ name: f,
301
+ values: [...g.entries()].map(([h, p]) => ({
302
+ value: h,
303
+ layers: [...p].sort()
304
+ })).sort((h, p) => h.value.localeCompare(p.value))
305
+ })).sort((f, g) => f.name.localeCompare(g.name)),
306
+ hasDriveAttributes: a.hasDriveAttributes,
307
+ hasMimicAttributes: a.hasMimicAttributes
308
+ })).filter((a) => a.apiSchemas.length > 0 || Ce(a) || a.typeName === "MjcActuator" || a.typeName === "PhysicsScene"), n = /* @__PURE__ */ new Map();
309
+ for (const a of o)
310
+ for (const f of a.apiSchemas)
311
+ n.set(f, (n.get(f) ?? 0) + 1);
312
+ const i = (a) => [...a].sort((f, g) => f.path.localeCompare(g.path)), l = o.filter((a) => a.apiSchemas.some(Ft)), u = o.filter((a) => a.apiSchemas.some(jt)), c = o.filter((a) => a.apiSchemas.some(Bt)), d = o.filter(Ce);
313
+ return {
314
+ scannedLayerCount: t.length,
315
+ scannedLayers: t.map((a) => a.path).sort(),
316
+ scannedPrimCount: r,
317
+ physicsPrimCount: o.length,
318
+ apiSchemaCounts: [...n.entries()].map(([a, f]) => ({ schema: a, primCount: f })).sort((a, f) => f.primCount - a.primCount || a.schema.localeCompare(f.schema)),
319
+ colliderApproximationCounts: zt(l, "physics:approximation"),
320
+ physicsPrims: i(o),
321
+ rigidBodyPrims: i(u),
322
+ colliderPrims: i(l),
323
+ articulationRootPrims: i(c),
324
+ jointPrims: i(d),
325
+ massPrims: i(o.filter((a) => a.apiSchemas.some((f) => /^(?:Physics|Physx|Newton)MassAPI/.test(f)))),
326
+ materialPrims: i(o.filter((a) => a.apiSchemas.some((f) => /^PhysicsMaterialAPI/.test(f)))),
327
+ scenePrims: i(o.filter((a) => a.typeName === "PhysicsScene")),
328
+ actuatorPrims: i(o.filter((a) => a.typeName === "MjcActuator")),
329
+ driveAttributePrimCount: o.filter((a) => a.hasDriveAttributes).length,
330
+ mimicPrimCount: o.filter((a) => a.hasMimicAttributes).length
331
+ };
332
+ }
333
+ function Ct(e) {
334
+ const t = Kt(e), s = [], r = /\bvariantSet\s+"([^"]+)"\s*=\s*\{/g;
335
+ for (let o = r.exec(e); o; o = r.exec(e)) {
336
+ const n = o[1], i = ae(e, e.indexOf("{", o.index));
337
+ if (!i) continue;
338
+ const l = [...i.matchAll(/^\s*"([^"]+)"(?:\s*\([^)]*\))?\s*\{/gm)].map((c) => c[1]).filter((c, d, a) => a.indexOf(c) === d);
339
+ if (!l.length) continue;
340
+ const u = t[n];
341
+ s.push({
342
+ name: n,
343
+ options: l,
344
+ ...u && l.includes(u) ? { authoredDefault: u } : {}
345
+ }), r.lastIndex += i.length;
346
+ }
347
+ return s;
348
+ }
349
+ function kt(e, t) {
350
+ const s = He(e), o = [...e.slice((s == null ? void 0 : s.end) ?? 0).matchAll(
351
+ /^(?:def|over|class)\s+(?:([A-Za-z0-9_:]+)\s+)?"([^"]+)"/gm
352
+ )], n = t ? o.find((a) => a[2] === t) : o[0];
353
+ if (!n) return null;
354
+ const i = ((s == null ? void 0 : s.end) ?? 0) + n.index, l = e.indexOf("{", i), u = l >= 0 ? e.slice(i, l) : n[0], c = [...u.matchAll(/\bapiSchemas\s*=\s*\[([^\]]*)\]/g)].flatMap((a) => [...a[1].matchAll(/"([^"]+)"/g)].map((f) => f[1])), d = n[2];
355
+ return {
356
+ path: t ? `/${t.replace(/^\/+/, "")}` : `/${d}`,
357
+ name: d,
358
+ typeName: n[1] ?? "unknown",
359
+ kind: b(u, "kind"),
360
+ apiSchemas: [...new Set(c)].sort()
361
+ };
362
+ }
363
+ function xt(e) {
364
+ const t = [], s = (r, o, n) => {
365
+ const i = /\b(?:def|over|class)\s+(?:([A-Za-z0-9_:]+)\s+)?"([^"]+)"/g;
366
+ for (i.lastIndex = r; i.lastIndex < o; ) {
367
+ const l = i.exec(e);
368
+ if (!l || l.index >= o) break;
369
+ const u = Ge(e, i.lastIndex, o);
370
+ if (u < 0) continue;
371
+ const c = ie(e, u, "{", "}");
372
+ if (c < 0) break;
373
+ const d = l[2], a = Ot(n, d), f = e.slice(l.index, c + 1);
374
+ t.push({
375
+ path: a,
376
+ typeName: l[1] ?? "unknown",
377
+ header: e.slice(l.index, u),
378
+ source: f
379
+ }), s(u + 1, c, a), i.lastIndex = c + 1;
380
+ }
381
+ };
382
+ return s(0, e.length, ""), t;
383
+ }
384
+ function Ot(e, t) {
385
+ return t.startsWith("/") ? `/${t.replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/")}` : `${e}/${t}`.replace(/\/+/g, "/");
386
+ }
387
+ function Ge(e, t, s) {
388
+ let r = 0, o = !1, n = !1;
389
+ for (let i = t; i < s; i += 1) {
390
+ const l = e[i];
391
+ if (n) {
392
+ l === `
393
+ ` && (n = !1);
394
+ continue;
395
+ }
396
+ if (l === "#" && !o) {
397
+ n = !0;
398
+ continue;
399
+ }
400
+ if (l === '"' && e[i - 1] !== "\\" && (o = !o), !o) {
401
+ if (l === "(") r += 1;
402
+ else if (l === ")") r = Math.max(0, r - 1);
403
+ else if (l === "{" && r === 0) return i;
404
+ }
405
+ }
406
+ return -1;
407
+ }
408
+ function Lt(e) {
409
+ const t = /* @__PURE__ */ new Set();
410
+ for (const s of e.matchAll(/\bapiSchemas\s*=\s*\[([^\]]*)\]/g)) {
411
+ const r = e.slice(Math.max(0, (s.index ?? 0) - 16), s.index);
412
+ if (!/\bdelete\s*$/.test(r))
413
+ for (const o of s[1].matchAll(/"([^"]+)"|([A-Za-z][A-Za-z0-9_:]*)/g)) {
414
+ const n = o[1] ?? o[2];
415
+ n && t.add(n);
416
+ }
417
+ }
418
+ return [...t];
419
+ }
420
+ function Mt(e) {
421
+ const t = Ut(e), s = [], r = /^\s*(?:(?:custom|uniform|varying|rel|append|prepend|delete)\s+)*(?:(?:[A-Za-z][A-Za-z0-9_:]*(?:\[\])?)\s+)?((?:physics|physx|newton|mjc|drive|state):[A-Za-z0-9_:]+)\s*=\s*(.+?)\s*$/gm;
422
+ for (const o of t.matchAll(r)) {
423
+ const n = o[1], i = o[2].replace(/\s+#.*$/, "").replace(/\s+/g, " ").trim();
424
+ i && s.push({ name: n, value: i });
425
+ }
426
+ return s;
427
+ }
428
+ function Ut(e) {
429
+ const t = e.indexOf("{"), s = e.lastIndexOf("}");
430
+ if (t < 0 || s <= t) return "";
431
+ let r = e.slice(t + 1, s);
432
+ const o = /\b(?:def|over|class)\s+(?:[A-Za-z0-9_:]+\s+)?"[^"]+"/g;
433
+ for (; o.lastIndex < r.length; ) {
434
+ const n = o.exec(r);
435
+ if (!n) break;
436
+ const i = Ge(r, o.lastIndex, r.length);
437
+ if (i < 0) break;
438
+ const l = ie(r, i, "{", "}");
439
+ if (l < 0) break;
440
+ r = `${r.slice(0, n.index)}${" ".repeat(l - n.index + 1)}${r.slice(l + 1)}`, o.lastIndex = l + 1;
441
+ }
442
+ return r;
443
+ }
444
+ function zt(e, t) {
445
+ const s = /* @__PURE__ */ new Map();
446
+ for (const r of e) {
447
+ const o = r.properties.find((n) => n.name === t);
448
+ if (o)
449
+ for (const n of o.values)
450
+ s.set(n.value, (s.get(n.value) ?? 0) + 1);
451
+ }
452
+ return [...s.entries()].map(([r, o]) => ({ value: r, primCount: o })).sort((r, o) => o.primCount - r.primCount || r.value.localeCompare(o.value));
453
+ }
454
+ function Vt(e) {
455
+ return /(?:Physics|Physx|Newton|Mjc)/.test(e);
456
+ }
457
+ function Ft(e) {
458
+ return /^(?:PhysicsCollisionAPI|PhysxCollisionAPI|NewtonCollisionAPI|MjcCollisionAPI)/.test(e);
459
+ }
460
+ function jt(e) {
461
+ return /^(?:PhysicsRigidBodyAPI|PhysxRigidBodyAPI|NewtonRigidBodyAPI)/.test(e);
462
+ }
463
+ function Bt(e) {
464
+ return /^(?:PhysicsArticulationRootAPI|PhysxArticulationAPI|NewtonArticulationRootAPI)/.test(e);
465
+ }
466
+ function Ce(e) {
467
+ return e.typeName.endsWith("Joint") || e.apiSchemas.some((t) => /^(?:MjcJointAPI|PhysicsJointStateAPI|PhysxJointStateAPI|NewtonJointStateAPI)/.test(t));
468
+ }
469
+ function Kt(e) {
470
+ const t = /\bvariants\s*=\s*\{/.exec(e);
471
+ if (!t) return {};
472
+ const s = ae(e, e.indexOf("{", t.index));
473
+ return s ? Object.fromEntries([...s.matchAll(
474
+ /\b(?:string|token)\s+([A-Za-z0-9_:]+)\s*=\s*"([^"]+)"/g
475
+ )].map((r) => [r[1], r[2]])) : {};
476
+ }
477
+ function Yt(e) {
478
+ const t = D(e) ? Object.entries(e).find(([, c]) => D(c) && D(S(c, "features_summary"))) ?? null : null, s = (t == null ? void 0 : t[1]) ?? null, r = S(s, "features_summary");
479
+ if (!D(r)) return null;
480
+ const o = Object.entries(r).filter((c) => D(c[1])), n = o.filter(([, c]) => c.blocking_failure === !0 && c.passed !== !0).map(([c]) => c), i = o.filter(([, c]) => c.passed !== !0).map(([c]) => c), l = S(s, "tier_versions"), u = o.filter(([, c]) => c.passed === !0).length;
481
+ return {
482
+ entryPath: (t == null ? void 0 : t[0]) ?? null,
483
+ profileId: E(S(s, "profile_id")),
484
+ profileVersion: E(S(s, "profile_version")),
485
+ validatorVersion: E(S(s, "simready_validate_version")),
486
+ totalFeatures: o.length,
487
+ passedFeatures: u,
488
+ blockingFailures: n.length,
489
+ blockingFeatureIds: n,
490
+ failedFeatureIds: i,
491
+ tierVersions: D(l) ? Object.fromEntries(Object.entries(l).flatMap(([c, d]) => typeof d == "string" && d ? [[c, d]] : [])) : {},
492
+ status: n.length ? "fail" : o.length === 0 ? "unknown" : u === o.length ? "pass" : "partial"
493
+ };
494
+ }
495
+ function Wt(e) {
496
+ if (!D(e)) return null;
497
+ const t = Array.isArray(e.results) ? e.results.filter((o) => D(o)) : [], s = [...new Set(t.flatMap((o) => {
498
+ const n = E(o.engine), i = E(o.engine_version);
499
+ return n ? [`${n}${i ? ` ${i}` : ""}`] : [];
500
+ }))].sort(), r = t.filter((o) => o.status === "fail").map((o) => ({
501
+ testName: E(o.test_name) ?? "unnamed-test",
502
+ engine: E(o.engine) ?? "unknown-engine",
503
+ message: E(o.message) ?? ""
504
+ }));
505
+ return {
506
+ schemaVersion: E(e.schema_version),
507
+ assetName: E(e.asset),
508
+ passed: typeof e.passed == "boolean" ? e.passed : null,
509
+ runTimestamp: E(e.run_timestamp),
510
+ testCount: t.length,
511
+ passedCount: t.filter((o) => o.status === "pass").length,
512
+ failedCount: r.length,
513
+ skippedCount: t.filter((o) => o.status === "skipped").length,
514
+ failedTests: r,
515
+ engines: s
516
+ };
517
+ }
518
+ function Gt(e) {
519
+ const t = ne(e, "validation");
520
+ if (!t) return null;
521
+ const s = ne(t, "validated_features") ?? "", r = [...new Set(
522
+ [...s.matchAll(/dictionary\s+"(\d{4}-\d{2}-\d{2})"\s*=/g)].map((c) => c[1])
523
+ )].sort(), o = /* @__PURE__ */ new Map(), n = /\bdictionary\s+(?:"([^"]+)"|([A-Za-z0-9_:]+))\s*(?:=\s*)?\{/g;
524
+ for (let c = n.exec(s); c; c = n.exec(s)) {
525
+ const d = c[1] ?? c[2];
526
+ if (!d.startsWith("FET_")) continue;
527
+ const a = ae(s, s.indexOf("{", c.index));
528
+ a && o.set(d, a);
529
+ }
530
+ const i = [...o.values()], l = i.filter((c) => me(c, "passed") === !0).length, u = i.filter((c) => me(c, "blocking_failure") === !0 && me(c, "passed") !== !0).length;
531
+ return !r.length && !o.size && !b(t, "profile") ? null : {
532
+ profileId: b(t, "profile"),
533
+ profileVersion: b(t, "profile_version"),
534
+ validatedDates: r,
535
+ featureCount: o.size,
536
+ passedFeatureCount: l,
537
+ blockingFailureCount: u
538
+ };
539
+ }
540
+ async function se(e) {
541
+ try {
542
+ return JSON.parse(await e.text());
543
+ } catch {
544
+ return null;
545
+ }
546
+ }
547
+ function Ht(e) {
548
+ const t = He(e);
549
+ return t ? e.slice(t.start, t.end + 1) : null;
550
+ }
551
+ function He(e) {
552
+ const t = /#usda\s+\S+\s*\(/m.exec(e);
553
+ if (!t) return null;
554
+ const s = e.indexOf("(", t.index), r = ie(e, s, "(", ")");
555
+ return r >= 0 ? { start: s, end: r } : null;
556
+ }
557
+ function ne(e, t) {
558
+ if (!e) return null;
559
+ const s = new RegExp(`(?:\\bdictionary\\s+)?\\b${J(t)}\\s*=\\s*\\{`).exec(e);
560
+ return s ? ae(e, e.indexOf("{", s.index)) : null;
561
+ }
562
+ function ae(e, t) {
563
+ if (t < 0 || e[t] !== "{") return null;
564
+ const s = ie(e, t, "{", "}");
565
+ return s >= 0 ? e.slice(t, s + 1) : null;
566
+ }
567
+ function ie(e, t, s, r) {
568
+ if (e[t] !== s) return -1;
569
+ let o = 0, n = !1, i = !1;
570
+ for (let l = t; l < e.length; l += 1) {
571
+ const u = e[l];
572
+ if (i) {
573
+ u === `
574
+ ` && (i = !1);
575
+ continue;
576
+ }
577
+ if (u === "#" && !n) {
578
+ i = !0;
579
+ continue;
580
+ }
581
+ if (u === '"' && e[l - 1] !== "\\" && (n = !n), !n) {
582
+ if (u === s) o += 1;
583
+ else if (u === r && (o -= 1, o === 0))
584
+ return l;
585
+ }
586
+ }
587
+ return -1;
588
+ }
589
+ function b(e, t) {
590
+ var s;
591
+ return e ? ((s = new RegExp(`\\b(?:string|token)?\\s*${J(t)}\\s*=\\s*"([^"]*)"`).exec(e)) == null ? void 0 : s[1]) ?? null : null;
592
+ }
593
+ function X(e, t) {
594
+ var r;
595
+ if (!e) return null;
596
+ const s = (r = new RegExp(`\\b(?:float|double|int)?\\s*${J(t)}\\s*=\\s*([0-9.eE+-]+)`).exec(e)) == null ? void 0 : r[1];
597
+ return s !== void 0 && Number.isFinite(Number(s)) ? Number(s) : null;
598
+ }
599
+ function Xt(e, t) {
600
+ const s = X(e, t);
601
+ return s !== null && Number.isInteger(s) ? s : null;
602
+ }
603
+ function me(e, t) {
604
+ var r, o;
605
+ if (!e) return null;
606
+ const s = (o = (r = new RegExp(`\\bbool\\s+${J(t)}\\s*=\\s*(0|1|true|false)\\b`, "i").exec(e)) == null ? void 0 : r[1]) == null ? void 0 : o.toLowerCase();
607
+ return s === void 0 ? null : s === "1" || s === "true";
608
+ }
609
+ function Zt(e, t) {
610
+ var o;
611
+ if (!e) return null;
612
+ const s = (o = new RegExp(`\\bfloat3\\s+${J(t)}\\s*=\\s*\\(([^)]+)\\)`).exec(e)) == null ? void 0 : o[1], r = (s == null ? void 0 : s.trim().split(/\s*,\s*|\s+/).map(Number)) ?? [];
613
+ return r.length === 3 && r.every(Number.isFinite) ? [r[0], r[1], r[2]] : null;
614
+ }
615
+ function S(e, t) {
616
+ return D(e) ? e[t] : null;
617
+ }
618
+ function qt(e) {
619
+ return typeof e == "number" && Number.isFinite(e) ? e : null;
620
+ }
621
+ function E(e) {
622
+ return typeof e == "string" && e ? e : null;
623
+ }
624
+ function D(e) {
625
+ return !!e && typeof e == "object" && !Array.isArray(e);
626
+ }
627
+ function L(e) {
628
+ return e.replaceAll("\\", "/").replace(/^\.?\//, "");
629
+ }
630
+ function J(e) {
631
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
632
+ }
633
+ const Jt = [".usd", ".usda", ".usdc", ".usdz"], Xe = [".glb", ".gltf"], Ze = ["simready_usd", "asset", "usd"], qe = ["com.nvidia.simready.packaging.json", "manifest.json"];
634
+ function U(e) {
635
+ const t = e.lastIndexOf(".");
636
+ return t < 0 ? "" : e.slice(t).toLowerCase();
637
+ }
638
+ function W(e) {
639
+ return Jt.includes(U(e));
640
+ }
641
+ function Qt(e, t) {
642
+ const s = es(e);
643
+ if (t === void 0) return s;
644
+ const r = e.files.find((o) => o.path === t && (W(o.path) || Xe.includes(U(o.path))));
645
+ return r ? { ...s, entryPath: r.path, reason: `${s.reason}; explicit entry ${r.path}` } : s;
646
+ }
647
+ function es(e) {
648
+ var l;
649
+ const t = e.files.filter((u) => W(u.path)), s = t.find((u) => U(u.path) === ".usdz");
650
+ if (s)
651
+ return {
652
+ layout: "usdz",
653
+ entryPath: s.path,
654
+ reason: "self-contained .usdz archive"
655
+ };
656
+ const r = e.files.find((u) => qe.some((c) => u.path === c || u.path.endsWith(`/${c}`))), o = e.files.filter((u) => /(^|\/)payloads\//.test(u.path) && W(u.path)), n = Ze.some((u) => e.files.some((c) => c.path.startsWith(`${u}/`)));
657
+ if (t.length > 1 && (n || o.length > 0)) {
658
+ const u = ke(t, e);
659
+ return {
660
+ layout: "simready-package",
661
+ entryPath: (u == null ? void 0 : u.path) ?? null,
662
+ reason: n ? "multi-layer package with a SimReady content directory" : "multi-layer package with payloads/"
663
+ };
664
+ }
665
+ if (t.length === 1)
666
+ return {
667
+ layout: "single-layer",
668
+ entryPath: t[0].path,
669
+ reason: r ? "single USD entry with a package manifest" : "single USD file"
670
+ };
671
+ const i = e.files.find((u) => Xe.includes(U(u.path)));
672
+ return i ? {
673
+ layout: "glb",
674
+ entryPath: i.path,
675
+ // A glTF/GLB has no USD representation yet; export must compile it first.
676
+ reason: "glTF/GLB source needs compilation to USD before export"
677
+ } : t.length > 1 ? {
678
+ layout: "simready-package",
679
+ entryPath: ((l = ke(t, e)) == null ? void 0 : l.path) ?? null,
680
+ reason: "multi-layer USD package without a SimReady marker"
681
+ } : { layout: "single-layer", entryPath: null, reason: "no USD or glTF entry found" };
682
+ }
683
+ function ke(e, t) {
684
+ var u;
685
+ const s = e.filter((c) => U(c.path) !== ".usdc"), r = s.length > 0 ? s : e, o = (c) => /(^|\/)(payloads|meshes|materials|physics|textures|variants)\//.test(c), n = r.filter((c) => !o(c.path)), i = t.rootName.toLowerCase(), l = (n.length > 0 ? n : r).map((c) => {
686
+ let a = c.path.split("/").length - 1;
687
+ return Ze.some((f) => c.path.startsWith(`${f}/`)) && (a -= 2), c.path.toLowerCase().includes(i) && (a -= 3), U(c.path) === ".usda" && (a -= 1), { file: c, score: a };
688
+ });
689
+ return l.sort((c, d) => c.score - d.score || c.file.path.localeCompare(d.file.path)), ((u = l[0]) == null ? void 0 : u.file) ?? null;
690
+ }
691
+ function yr(e) {
692
+ const t = e.find((s) => qe.some((r) => s.path === r || s.path.endsWith(`/${r}`)));
693
+ return t != null && t.bytes ? new TextDecoder("utf-8").decode(t.bytes) : null;
694
+ }
695
+ function ts(e, t, s) {
696
+ const r = /* @__PURE__ */ new Map(), o = [], n = /* @__PURE__ */ new Map();
697
+ for (const i of t) {
698
+ const l = n.get(i.fromPath) ?? [];
699
+ l.push(i), n.set(i.fromPath, l);
700
+ }
701
+ for (const i of e) {
702
+ const l = n.get(i.path);
703
+ if (!l || l.length === 0) continue;
704
+ let u = i.text;
705
+ for (const c of l) {
706
+ const d = `./${c.target}`;
707
+ u = ns(u, c.target, d), o.push({
708
+ kind: "anchored-mdl-path",
709
+ detail: `${c.fromPath}: @${c.target}@ rewritten as @${d}@`,
710
+ at: s.now()
711
+ });
712
+ }
713
+ u !== i.text && r.set(i.path, u);
714
+ }
715
+ return { rewrites: r, repairs: o, unresolved: [] };
716
+ }
717
+ function ss(e, t, s) {
718
+ const r = /* @__PURE__ */ new Map(), o = [], n = [], i = /* @__PURE__ */ new Map();
719
+ for (const l of t) {
720
+ const u = i.get(l.fromPath) ?? [];
721
+ u.push(l), i.set(l.fromPath, u);
722
+ }
723
+ for (const l of e) {
724
+ const u = i.get(l.path);
725
+ if (!u || u.length === 0) continue;
726
+ let c = l.text;
727
+ for (const d of u) {
728
+ const a = c;
729
+ if (c = rs(c, d.target), c === a) {
730
+ n.push(d);
731
+ continue;
732
+ }
733
+ o.push({
734
+ kind: "stripped-external-uri",
735
+ detail: `${d.fromPath}: removed external reference ${d.target}`,
736
+ at: s.now()
737
+ });
738
+ }
739
+ c !== l.text && r.set(l.path, c);
740
+ }
741
+ return { rewrites: r, repairs: o, unresolved: n };
742
+ }
743
+ function rs(e, t) {
744
+ const s = Je(`@${t}@`), r = new RegExp(s), o = e.split(/\r?\n/), n = [];
745
+ let i = !1;
746
+ for (const l of o) {
747
+ if (!r.test(l)) {
748
+ n.push(l);
749
+ continue;
750
+ }
751
+ if (!os(l, s)) {
752
+ n.push(l);
753
+ continue;
754
+ }
755
+ i = !0;
756
+ }
757
+ return i ? n.join(`
758
+ `) : e;
759
+ }
760
+ function os(e, t) {
761
+ const s = e.trim().replace(/,$/, "");
762
+ return new RegExp(
763
+ `^[A-Za-z_:.]*\\s*(?:prepend|append|add|delete|reorder)?\\s*[A-Za-z_:.]*\\s*=\\s*${t}(?:\\s*<[^>]*>)?\\s*(?:#.*)?$`
764
+ ).test(s);
765
+ }
766
+ function ns(e, t, s) {
767
+ const r = new RegExp(`@\\s*${Je(t)}\\s*@`, "g");
768
+ return e.replace(r, `@${s}@`);
769
+ }
770
+ function gr(e, t, s) {
771
+ return { kind: e, detail: t, at: s() };
772
+ }
773
+ function as(e) {
774
+ return [...e].sort((t, s) => t.kind.localeCompare(s.kind) || t.detail.localeCompare(s.detail) || t.at.localeCompare(s.at));
775
+ }
776
+ function Je(e) {
777
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
778
+ }
779
+ const _ = {
780
+ entryMissing: "ASSET_INTAKE_ENTRY_MISSING",
781
+ entryNotUsd: "ASSET_INTAKE_ENTRY_NOT_USD",
782
+ dependencyMissing: "ASSET_INTAKE_DEPENDENCY_MISSING",
783
+ externalReference: "ASSET_INTAKE_EXTERNAL_REFERENCE",
784
+ unanchoredReference: "ASSET_INTAKE_UNANCHORED_REFERENCE",
785
+ repairApplied: "ASSET_INTAKE_REPAIR_APPLIED",
786
+ annotationMissing: "ASSET_INTAKE_ANNOTATION_MISSING",
787
+ glbNeedsCompilation: "ASSET_INTAKE_GLB_NEEDS_COMPILATION",
788
+ physicsUnknown: "ASSET_INTAKE_PHYSICS_UNKNOWN",
789
+ materialModuleReference: "ASSET_INTAKE_MATERIAL_MODULE",
790
+ resourceBytesMissing: "ASSET_INTAKE_RESOURCE_BYTES_MISSING"
791
+ };
792
+ function Ir(e, t, s = {}) {
793
+ var _e, Pe, De, we, $e;
794
+ const r = s.now ?? (() => (/* @__PURE__ */ new Date()).toISOString()), o = [], n = [], i = Qt(e, s.entryPath);
795
+ if (o.push({
796
+ code: "ASSET_INTAKE_LAYOUT",
797
+ level: "info",
798
+ message: `Detected layout ${i.layout}: ${i.reason}`
799
+ }), !i.entryPath)
800
+ return o.push({
801
+ code: _.entryMissing,
802
+ level: "error",
803
+ message: `No openable entry found in ${e.rootName}.`
804
+ }), { status: "blocked", record: null, rewrites: /* @__PURE__ */ new Map(), diagnostics: o };
805
+ const l = cs(e), u = new Set(e.files.map((y) => oe(y.path))), c = he(l, u), d = is(
806
+ i.entryPath,
807
+ c,
808
+ u,
809
+ l.some((y) => y.path === i.entryPath)
810
+ );
811
+ let a = l;
812
+ const f = /* @__PURE__ */ new Map();
813
+ if (c.unanchored.length > 0)
814
+ for (const y of c.unanchored)
815
+ o.push({
816
+ code: _.unanchoredReference,
817
+ level: "warning",
818
+ message: `${y.fromPath}: @${y.target}@ is not anchored; USD resolves it via a search path.`
819
+ });
820
+ const g = c.references.filter((y) => !y.external && !y.anchored), h = ts(a, g, { now: r });
821
+ Oe(f, h.rewrites), n.push(...h.repairs), a = xe(a, h.rewrites);
822
+ for (const y of c.materialModules)
823
+ o.push({
824
+ code: _.materialModuleReference,
825
+ level: "info",
826
+ message: `${y.fromPath}: material module ${y.target} resolves from the host MDL search path, not the package.`
827
+ });
828
+ const p = ss(a, c.external, { now: r });
829
+ Oe(f, p.rewrites), n.push(...p.repairs), a = xe(a, p.rewrites);
830
+ for (const y of c.external)
831
+ o.push({
832
+ code: _.externalReference,
833
+ level: p.unresolved.some((H) => H === y) ? "error" : "warning",
834
+ message: `${y.fromPath}: external reference ${y.target} cannot ship inside the package.`
835
+ });
836
+ const I = he(a, u), A = I.missing;
837
+ for (const y of A)
838
+ o.push({
839
+ code: _.dependencyMissing,
840
+ level: "error",
841
+ message: `${y.fromPath}: referenced file ${y.target} is not in the package.`
842
+ });
843
+ const P = A.length > 0 || p.unresolved.length > 0 || I.external.length > 0;
844
+ P && s.strict === !1 && o.push({
845
+ code: "ASSET_INTAKE_BLOCKING_OVERRIDDEN",
846
+ level: "warning",
847
+ message: "Structural problems were ignored because strict mode is off."
848
+ });
849
+ for (const y of n)
850
+ o.push({
851
+ code: _.repairApplied,
852
+ level: "info",
853
+ message: y.detail
854
+ });
855
+ i.layout === "glb" && o.push({
856
+ code: _.glbNeedsCompilation,
857
+ level: "warning",
858
+ message: "glTF/GLB assets must be compiled to USD before they can be exported."
859
+ });
860
+ const $ = s.annotations ?? {}, ue = $.slug ?? us(e.rootName);
861
+ $.slug || o.push({
862
+ code: _.annotationMissing,
863
+ level: "info",
864
+ message: `slug defaulted to "${ue}"; confirm it before publishing.`
865
+ }), $.category || o.push({
866
+ code: _.annotationMissing,
867
+ level: "info",
868
+ message: "category is not inferable from file contents and must be annotated."
869
+ });
870
+ const z = (t == null ? void 0 : t.capability) ?? { hasPhysics: !1, hasArticulation: !1, hasColliderGeometry: !1, source: "none" };
871
+ if (t || o.push({
872
+ code: _.physicsUnknown,
873
+ level: "warning",
874
+ message: "No physics probe was supplied; the asset is recorded as carrying no physics."
875
+ }), P && s.strict !== !1)
876
+ return { status: "blocked", record: null, rewrites: f, diagnostics: o };
877
+ const Ee = [.../* @__PURE__ */ new Set([i.entryPath, ...d])].sort(), lt = new Map(e.files.map((y) => [oe(y.path), y])), Q = [];
878
+ for (const y of Ee) {
879
+ const H = lt.get(y), Ne = f.get(y), fe = Ne === void 0 ? H == null ? void 0 : H.bytes : new TextEncoder().encode(Ne);
880
+ if (!fe) {
881
+ o.push({
882
+ code: _.resourceBytesMissing,
883
+ level: "error",
884
+ message: `${y}: resource bytes are required to calculate the immutable content hash.`
885
+ });
886
+ continue;
887
+ }
888
+ const Te = N(fe);
889
+ Q.push({
890
+ resourceId: gt({ kind: "package-path", path: y }, Te),
891
+ locator: { kind: "package-path", path: y },
892
+ mediaType: yt(y),
893
+ byteSize: fe.byteLength,
894
+ sha256: Te
895
+ });
896
+ }
897
+ if (Q.length !== Ee.length)
898
+ return { status: "blocked", record: null, rewrites: f, diagnostics: o };
899
+ const Ae = Q.find((y) => It(y.locator) === i.entryPath);
900
+ if (!Ae)
901
+ return o.push({
902
+ code: _.resourceBytesMissing,
903
+ level: "error",
904
+ message: `${i.entryPath}: entry resource bytes are unavailable.`
905
+ }), { status: "blocked", record: null, rewrites: f, diagnostics: o };
906
+ const de = $.category ?? "other", Re = $.label ?? e.rootName, ee = [], ut = $.category || $.label || $.slug ? "annotated" : "imported", dt = Rt({
907
+ assetId: `asset_${ue}`,
908
+ slug: ue,
909
+ label: Re,
910
+ layout: i.layout,
911
+ fileKind: ls(i.entryPath) ? "glb" : "usd",
912
+ entryResourceId: Ae.resourceId,
913
+ resources: Q,
914
+ variantSets: (t == null ? void 0 : t.variantSets) ?? [],
915
+ capabilities: {
916
+ rendering: "supported",
917
+ physics: z.source === "usd-authored" ? "authored" : z.source === "none" ? "none" : "unknown",
918
+ articulation: z.hasArticulation,
919
+ rigidBody: z.hasPhysics || z.hasRigidBody === !0,
920
+ colliderGeometry: z.hasColliderGeometry
921
+ },
922
+ ...(_e = t == null ? void 0 : t.measured) != null && _e.bounds ? { bounds: t.measured.bounds } : {},
923
+ category: de,
924
+ hints: {
925
+ ...t != null && t.approximateSize ? { approximateSize: t.approximateSize } : {},
926
+ ...t != null && t.forwardAxis ? { forwardAxis: t.forwardAxis } : {},
927
+ ...ee.length > 0 ? { tags: ee } : {}
928
+ },
929
+ ...((Pe = t == null ? void 0 : t.measured) == null ? void 0 : Pe.jointCount) !== void 0 || ((De = t == null ? void 0 : t.measured) == null ? void 0 : De.meshCount) !== void 0 ? {
930
+ metrics: {
931
+ ...((we = t.measured) == null ? void 0 : we.jointCount) !== void 0 ? { jointCount: t.measured.jointCount } : {},
932
+ ...(($e = t.measured) == null ? void 0 : $e.meshCount) !== void 0 ? { meshCount: t.measured.meshCount } : {}
933
+ }
934
+ } : {},
935
+ semantic: {
936
+ source: ut,
937
+ labels: [Re],
938
+ taxonomy: [de],
939
+ ...ee.length > 0 ? { tags: ee } : {},
940
+ category: de
941
+ },
942
+ provenance: {
943
+ source: s.origin ?? "builtin",
944
+ sourceLabel: e.rootName,
945
+ ...s.origin === "user" || s.origin === "import" ? { importedAt: r() } : {},
946
+ ...$.externalRef ? { externalRef: { ...$.externalRef } } : {},
947
+ repairs: as(n)
948
+ }
949
+ });
950
+ return {
951
+ status: n.length > 0 ? "ready-with-repairs" : "ready",
952
+ record: dt,
953
+ rewrites: f,
954
+ diagnostics: o
955
+ };
956
+ }
957
+ function is(e, t, s, r) {
958
+ const o = /* @__PURE__ */ new Map();
959
+ for (const l of t.references) {
960
+ if (l.resolvedPath === null) continue;
961
+ const u = o.get(l.fromPath) ?? [];
962
+ u.push(l.resolvedPath), o.set(l.fromPath, u);
963
+ }
964
+ const n = /* @__PURE__ */ new Set(), i = [e];
965
+ for (; i.length > 0; ) {
966
+ const l = i.pop();
967
+ for (const u of o.get(l) ?? [])
968
+ n.has(u) || !s.has(u) || (n.add(u), i.push(u));
969
+ }
970
+ if (W(e) && !r) {
971
+ for (const l of s)
972
+ l !== e && n.add(l);
973
+ return [...n].sort();
974
+ }
975
+ for (const l of s)
976
+ W(l) && !We(l) && l !== e && n.add(l);
977
+ return [...n].sort();
978
+ }
979
+ function cs(e) {
980
+ const t = [];
981
+ for (const s of [...e.files].sort((r, o) => r.path.localeCompare(o.path)))
982
+ W(s.path) && ve(s.path, s.bytes) && s.bytes && t.push({ path: s.path, text: new TextDecoder("utf-8").decode(s.bytes) });
983
+ return t;
984
+ }
985
+ function xe(e, t) {
986
+ return e.map((s) => {
987
+ const r = t.get(s.path);
988
+ return r === void 0 ? s : { path: s.path, text: r };
989
+ });
990
+ }
991
+ function Oe(e, t) {
992
+ for (const [s, r] of t) e.set(s, r);
993
+ }
994
+ function ls(e) {
995
+ const t = U(e);
996
+ return t === ".glb" || t === ".gltf";
997
+ }
998
+ function us(e) {
999
+ return Array.from(e.normalize("NFKD")).map((s) => /[A-Za-z0-9]/.test(s) ? s.toLowerCase() : "-").join("").replace(/-+/g, "-").replace(/^-+|-+$/g, "") || "asset";
1000
+ }
1001
+ const vr = "document.json", Sr = "sim-studio.document@7", F = {
1002
+ notJson: "SCENE_FILE_NOT_JSON",
1003
+ unsupportedFormat: "SCENE_FILE_UNSUPPORTED_FORMAT",
1004
+ unsupportedVersion: "SCENE_FILE_UNSUPPORTED_VERSION",
1005
+ migrated: "SCENE_FILE_MIGRATED",
1006
+ invalidDocument: "SCENE_FILE_INVALID_DOCUMENT"
1007
+ };
1008
+ function Se(e, t = {}) {
1009
+ const s = {
1010
+ schemaVersion: K,
1011
+ sceneId: e.sceneId,
1012
+ meta: { ...e.meta },
1013
+ coordinateSystem: {
1014
+ ...e.coordinateSystem,
1015
+ units: { ...e.coordinateSystem.units },
1016
+ origin: e.coordinateSystem.origin
1017
+ },
1018
+ environment: gs(e.environment),
1019
+ assets: [...e.assets].map(ys).sort((r, o) => r.revisionId.localeCompare(o.revisionId)),
1020
+ visualAssets: [...e.visualAssets].map(hs).sort((r, o) => r.visualRevisionId.localeCompare(o.visualRevisionId)),
1021
+ root: Qe(e.root),
1022
+ ...e.semantic ? { semantic: Is(e.semantic) } : {},
1023
+ ...e.domains ? { domains: ms(e.domains) } : {},
1024
+ ...e.extensions ? { extensions: q(e.extensions) } : {}
1025
+ };
1026
+ return ht(s, t.domainExtensions);
1027
+ }
1028
+ function ye(e, t = {}) {
1029
+ return ds(e, K, t);
1030
+ }
1031
+ function ds(e, t, s = {}) {
1032
+ const r = Se(e, s), o = {
1033
+ ...r,
1034
+ schemaVersion: t
1035
+ }, { updatedAt: n, ...i } = r.meta, l = {
1036
+ ...o,
1037
+ meta: i
1038
+ };
1039
+ return N(C(l));
1040
+ }
1041
+ function fs(e, t = {}) {
1042
+ const s = Se(e, t), r = Ve(s, t);
1043
+ return r.ok ? {
1044
+ text: `${C(s)}
1045
+ `,
1046
+ contentHash: ye(s, t),
1047
+ diagnostics: r.diagnostics
1048
+ } : {
1049
+ text: "",
1050
+ contentHash: ye(s, t),
1051
+ diagnostics: [
1052
+ {
1053
+ code: F.invalidDocument,
1054
+ level: "error",
1055
+ message: `Scene document does not satisfy schema version ${K}.`
1056
+ },
1057
+ ...r.diagnostics
1058
+ ]
1059
+ };
1060
+ }
1061
+ const br = fs;
1062
+ function ps(e, t = {}) {
1063
+ let s;
1064
+ try {
1065
+ s = JSON.parse(e);
1066
+ } catch (n) {
1067
+ return {
1068
+ document: null,
1069
+ contentHash: null,
1070
+ migratedFrom: null,
1071
+ diagnostics: [{
1072
+ code: F.notJson,
1073
+ level: "error",
1074
+ message: `Scene document is not valid JSON: ${n instanceof Error ? n.message : String(n)}`
1075
+ }]
1076
+ };
1077
+ }
1078
+ if (!bs(s))
1079
+ return {
1080
+ document: null,
1081
+ contentHash: null,
1082
+ migratedFrom: null,
1083
+ diagnostics: [{
1084
+ code: F.invalidDocument,
1085
+ level: "error",
1086
+ message: "Scene document must be a JSON object."
1087
+ }]
1088
+ };
1089
+ if ("fileVersion" in s || "doc" in s || "assets" in s && !("schemaVersion" in s))
1090
+ return {
1091
+ document: null,
1092
+ contentHash: null,
1093
+ migratedFrom: null,
1094
+ diagnostics: [{
1095
+ code: F.unsupportedFormat,
1096
+ level: "error",
1097
+ message: "The legacy SceneFile envelope is unsupported. Export it once with the explicit migration tool before opening."
1098
+ }]
1099
+ };
1100
+ if (s.schemaVersion !== K)
1101
+ return {
1102
+ document: null,
1103
+ contentHash: null,
1104
+ migratedFrom: null,
1105
+ diagnostics: [{
1106
+ code: F.unsupportedVersion,
1107
+ level: "error",
1108
+ message: `Scene schema version ${String(s.schemaVersion)} is unsupported; expected ${K}.`
1109
+ }]
1110
+ };
1111
+ const r = Ve(s, t);
1112
+ if (!r.ok)
1113
+ return {
1114
+ document: null,
1115
+ contentHash: null,
1116
+ migratedFrom: null,
1117
+ diagnostics: [
1118
+ {
1119
+ code: F.invalidDocument,
1120
+ level: "error",
1121
+ message: `Scene document does not satisfy schema version ${K}.`
1122
+ },
1123
+ ...r.diagnostics
1124
+ ]
1125
+ };
1126
+ const o = Se(
1127
+ s,
1128
+ t
1129
+ );
1130
+ return {
1131
+ document: o,
1132
+ contentHash: ye(o, t),
1133
+ migratedFrom: null,
1134
+ diagnostics: r.diagnostics
1135
+ };
1136
+ }
1137
+ const Er = ps;
1138
+ function Qe(e) {
1139
+ const t = {
1140
+ nodeId: e.nodeId,
1141
+ label: e.label,
1142
+ localTransform: {
1143
+ position: e.localTransform.position,
1144
+ rotation: e.localTransform.rotation,
1145
+ scale: e.localTransform.scale
1146
+ },
1147
+ ...e.origin ? { origin: { local: e.origin.local } } : {}
1148
+ };
1149
+ return e.nodeType === "group" ? {
1150
+ ...t,
1151
+ nodeType: "group",
1152
+ children: [...e.children].map(Qe).sort((s, r) => s.nodeId.localeCompare(r.nodeId))
1153
+ } : e.nodeType === "visual" ? {
1154
+ ...t,
1155
+ nodeType: "visual",
1156
+ visualRevisionId: e.visualRevisionId,
1157
+ visible: e.visible,
1158
+ renderLayer: e.renderLayer,
1159
+ selectionMode: e.selectionMode,
1160
+ ...e.appearance ? {
1161
+ appearance: {
1162
+ ...e.appearance,
1163
+ ...e.appearance.color ? { color: e.appearance.color } : {}
1164
+ }
1165
+ } : {},
1166
+ ...e.semantic ? { semantic: j(e.semantic) } : {}
1167
+ } : e.nodeType === "placeholder" ? {
1168
+ ...t,
1169
+ nodeType: "placeholder",
1170
+ placeholderVersion: 1,
1171
+ size: e.size,
1172
+ role: e.role,
1173
+ visible: e.visible,
1174
+ ...e.assetRevisionId ? { assetRevisionId: e.assetRevisionId } : {},
1175
+ ...e.externalRef ? { externalRef: { ...e.externalRef } } : {},
1176
+ ...e.semantic ? { semantic: j(e.semantic) } : {}
1177
+ } : e.nodeType === "domain" ? {
1178
+ ...t,
1179
+ nodeType: "domain",
1180
+ domainId: e.domainId,
1181
+ dataVersion: e.dataVersion,
1182
+ payload: je(e.payload),
1183
+ visible: e.visible,
1184
+ selectable: e.selectable,
1185
+ ...e.bounds ? { bounds: { min: e.bounds.min, max: e.bounds.max } } : {},
1186
+ ...e.semantic ? { semantic: j(e.semantic) } : {}
1187
+ } : {
1188
+ ...t,
1189
+ nodeType: "asset",
1190
+ assetRevisionId: e.assetRevisionId,
1191
+ role: e.role,
1192
+ visible: e.visible,
1193
+ variantSelections: q(e.variantSelections),
1194
+ ...e.appearance ? { appearance: { ...e.appearance } } : {},
1195
+ physics: Ss(e.physics),
1196
+ ...e.initialPose ? { initialPose: { joints: q(e.initialPose.joints) } } : {},
1197
+ ...e.semantic ? { semantic: j(e.semantic) } : {}
1198
+ };
1199
+ }
1200
+ function ms(e) {
1201
+ return Object.fromEntries(
1202
+ Object.entries(e).sort(([t], [s]) => t.localeCompare(s)).map(([t, s]) => [
1203
+ t,
1204
+ {
1205
+ dataVersion: s.dataVersion,
1206
+ data: je(s.data)
1207
+ }
1208
+ ])
1209
+ );
1210
+ }
1211
+ function hs(e) {
1212
+ return {
1213
+ ...e,
1214
+ resources: [...e.resources].map((t) => ({
1215
+ ...t,
1216
+ locator: R(t.locator)
1217
+ })).sort((t, s) => m(t.locator).localeCompare(m(s.locator)) || t.resourceId.localeCompare(s.resourceId)),
1218
+ suggestedScale: e.suggestedScale,
1219
+ ...e.bounds ? { bounds: { min: e.bounds.min, max: e.bounds.max } } : {},
1220
+ ...e.metrics ? { metrics: { ...e.metrics } } : {},
1221
+ provenance: { ...e.provenance }
1222
+ };
1223
+ }
1224
+ function ys(e) {
1225
+ return {
1226
+ ...e,
1227
+ resources: [...e.resources].map((t) => ({
1228
+ ...t,
1229
+ locator: R(t.locator)
1230
+ })).sort((t, s) => m(t.locator).localeCompare(m(s.locator)) || t.resourceId.localeCompare(s.resourceId)),
1231
+ variantSets: [...e.variantSets].map((t) => ({
1232
+ ...t,
1233
+ options: [...new Set(t.options)].sort()
1234
+ })).sort((t, s) => t.name.localeCompare(s.name)),
1235
+ ...e.hints ? {
1236
+ hints: {
1237
+ ...e.hints,
1238
+ ...e.hints.tags ? { tags: [...new Set(e.hints.tags)].sort() } : {}
1239
+ }
1240
+ } : {},
1241
+ ...e.semantic ? { semantic: j(e.semantic) } : {},
1242
+ provenance: {
1243
+ ...e.provenance,
1244
+ ...e.provenance.externalRef ? { externalRef: { ...e.provenance.externalRef } } : {},
1245
+ repairs: [...e.provenance.repairs].sort((t, s) => t.at.localeCompare(s.at) || t.kind.localeCompare(s.kind) || t.detail.localeCompare(s.detail))
1246
+ }
1247
+ };
1248
+ }
1249
+ function gs(e) {
1250
+ return {
1251
+ rendering: {
1252
+ ...e.rendering,
1253
+ background: { ...e.rendering.background }
1254
+ },
1255
+ physics: {
1256
+ ...e.physics,
1257
+ gravity: e.physics.gravity,
1258
+ solver: { ...e.physics.solver }
1259
+ }
1260
+ };
1261
+ }
1262
+ function j(e) {
1263
+ return {
1264
+ ...e,
1265
+ ...e.labels ? { labels: Y(e.labels) } : {},
1266
+ ...e.taxonomy ? { taxonomy: Y(e.taxonomy) } : {},
1267
+ ...e.tags ? { tags: Y(e.tags) } : {},
1268
+ ...e.attributes ? { attributes: q(e.attributes) } : {}
1269
+ };
1270
+ }
1271
+ function Is(e) {
1272
+ return {
1273
+ ...j(e),
1274
+ ...e.task ? {
1275
+ task: {
1276
+ ...e.task,
1277
+ ...e.task.tags ? { tags: Y(e.task.tags) } : {}
1278
+ }
1279
+ } : {},
1280
+ ...e.annotations ? { annotations: [...e.annotations].map(vs).sort((t, s) => t.annotationId.localeCompare(s.annotationId)) } : {}
1281
+ };
1282
+ }
1283
+ function vs(e) {
1284
+ return {
1285
+ ...e,
1286
+ targetNodeIds: Y(e.targetNodeIds),
1287
+ ...e.attributes ? { attributes: q(e.attributes) } : {}
1288
+ };
1289
+ }
1290
+ function Ss(e) {
1291
+ return {
1292
+ ...e,
1293
+ ...e.colliderPrimPaths ? { colliderPrimPaths: Y(e.colliderPrimPaths) } : {},
1294
+ ...e.physicsMaterial ? { physicsMaterial: { ...e.physicsMaterial } } : {},
1295
+ ...e.jointOverrides ? {
1296
+ jointOverrides: [...e.jointOverrides].map((t) => ({ ...t })).sort((t, s) => t.jointPrimPath.localeCompare(s.jointPrimPath))
1297
+ } : {}
1298
+ };
1299
+ }
1300
+ function Y(e) {
1301
+ return [...new Set(e)].sort();
1302
+ }
1303
+ function q(e) {
1304
+ return Object.fromEntries(Object.entries(e).sort(([t], [s]) => t.localeCompare(s)));
1305
+ }
1306
+ function bs(e) {
1307
+ return typeof e == "object" && e !== null && !Array.isArray(e);
1308
+ }
1309
+ class Ar {
1310
+ constructor(t, s = {}) {
1311
+ k(this, "undoStack", []);
1312
+ k(this, "redoStack", []);
1313
+ k(this, "limit");
1314
+ k(this, "mergeWindowMs");
1315
+ k(this, "now");
1316
+ k(this, "timestamp");
1317
+ k(this, "doc");
1318
+ this.doc = V(t), this.limit = Math.max(1, s.limit ?? 200), this.mergeWindowMs = s.mergeWindowMs ?? 600, this.now = s.now ?? (() => Date.now()), this.timestamp = s.timestamp ?? (() => (/* @__PURE__ */ new Date()).toISOString());
1319
+ }
1320
+ get document() {
1321
+ return this.doc;
1322
+ }
1323
+ /** Current `meta.updatedAt` stamp, shared by every apply path. */
1324
+ stamp() {
1325
+ return this.timestamp();
1326
+ }
1327
+ getState() {
1328
+ const t = this.undoStack[this.undoStack.length - 1], s = this.redoStack[this.redoStack.length - 1];
1329
+ return {
1330
+ canUndo: this.undoStack.length > 0,
1331
+ canRedo: this.redoStack.length > 0,
1332
+ undoLabel: (t == null ? void 0 : t.label) ?? null,
1333
+ redoLabel: (s == null ? void 0 : s.label) ?? null,
1334
+ depth: this.undoStack.length
1335
+ };
1336
+ }
1337
+ /**
1338
+ * Applies a command and records it. A rejected command leaves both the
1339
+ * document and the history untouched.
1340
+ */
1341
+ apply(t) {
1342
+ const s = te(this.doc, t.payload, this.stamp());
1343
+ return s.diagnostics.some((r) => r.level === "error") ? { doc: this.doc, diagnostics: s.diagnostics, changed: !1 } : (this.doc = V(s.doc), this.redoStack.length = 0, this.record(t), { doc: this.doc, diagnostics: [], changed: !0 });
1344
+ }
1345
+ /** Applies several commands as one atomic step. */
1346
+ applyAll(t) {
1347
+ if (t.length === 0) return { doc: this.doc, diagnostics: [], changed: !1 };
1348
+ let s = this.doc;
1349
+ for (const o of t) {
1350
+ const n = te(s, o.payload, this.stamp());
1351
+ if (n.diagnostics.length > 0)
1352
+ return { doc: this.doc, diagnostics: n.diagnostics, changed: !1 };
1353
+ s = n.doc;
1354
+ }
1355
+ this.doc = V(s), this.redoStack.length = 0;
1356
+ const r = t[0].batchId;
1357
+ return this.undoStack.push({
1358
+ batchId: r,
1359
+ label: t[0].label,
1360
+ commands: [...t],
1361
+ at: this.now()
1362
+ }), this.trim(), { doc: this.doc, diagnostics: [], changed: !0 };
1363
+ }
1364
+ undo() {
1365
+ const t = this.undoStack.pop();
1366
+ if (!t) return { doc: this.doc, diagnostics: [], changed: !1 };
1367
+ let s = this.doc;
1368
+ for (const r of [...t.commands].reverse()) {
1369
+ const o = Es(r);
1370
+ if (!o)
1371
+ return this.undoStack.push(t), {
1372
+ doc: this.doc,
1373
+ diagnostics: [{
1374
+ code: "HISTORY_NOT_INVERTIBLE",
1375
+ level: "error",
1376
+ message: `Command ${r.type} cannot be undone.`
1377
+ }],
1378
+ changed: !1
1379
+ };
1380
+ const n = te(s, o, this.stamp());
1381
+ if (n.diagnostics.length > 0)
1382
+ return this.undoStack.push(t), { doc: this.doc, diagnostics: n.diagnostics, changed: !1 };
1383
+ s = n.doc;
1384
+ }
1385
+ return this.doc = V(s), this.redoStack.push(t), { doc: this.doc, diagnostics: [], changed: !0 };
1386
+ }
1387
+ redo() {
1388
+ const t = this.redoStack.pop();
1389
+ if (!t) return { doc: this.doc, diagnostics: [], changed: !1 };
1390
+ let s = this.doc;
1391
+ for (const r of t.commands) {
1392
+ const o = te(s, r.payload, this.stamp());
1393
+ if (o.diagnostics.length > 0)
1394
+ return this.redoStack.push(t), { doc: this.doc, diagnostics: o.diagnostics, changed: !1 };
1395
+ s = o.doc;
1396
+ }
1397
+ return this.doc = V(s), this.undoStack.push(t), this.trim(), { doc: this.doc, diagnostics: [], changed: !0 };
1398
+ }
1399
+ clear() {
1400
+ this.undoStack.length = 0, this.redoStack.length = 0;
1401
+ }
1402
+ record(t) {
1403
+ V(t);
1404
+ const s = this.now(), r = this.undoStack[this.undoStack.length - 1];
1405
+ if (r && r.batchId === t.batchId && t.type === "node.transform" && r.commands.every((o) => o.type === "node.transform") && s - r.at <= this.mergeWindowMs) {
1406
+ this.undoStack[this.undoStack.length - 1] = {
1407
+ ...r,
1408
+ commands: [...r.commands, t],
1409
+ at: s
1410
+ };
1411
+ return;
1412
+ }
1413
+ this.undoStack.push({ batchId: t.batchId, label: t.label, commands: [t], at: s }), this.trim();
1414
+ }
1415
+ trim() {
1416
+ const t = this.undoStack.length - this.limit;
1417
+ t > 0 && this.undoStack.splice(0, t);
1418
+ }
1419
+ }
1420
+ function Es(e) {
1421
+ const t = e.payload;
1422
+ switch (t.type) {
1423
+ case "node.add":
1424
+ return {
1425
+ type: "node.remove",
1426
+ nodeId: t.node.nodeId,
1427
+ parentNodeId: t.parentNodeId,
1428
+ removed: t.node
1429
+ };
1430
+ case "node.remove":
1431
+ return {
1432
+ type: "node.add",
1433
+ parentNodeId: t.parentNodeId,
1434
+ node: t.removed
1435
+ };
1436
+ case "node.transform":
1437
+ return { type: "node.transform", nodeId: t.nodeId, before: t.after, after: t.before };
1438
+ case "node.setOrigin":
1439
+ return {
1440
+ type: "node.setOrigin",
1441
+ nodeId: t.nodeId,
1442
+ before: t.after,
1443
+ after: t.before,
1444
+ beforeTransform: t.afterTransform,
1445
+ afterTransform: t.beforeTransform
1446
+ };
1447
+ case "node.reparent":
1448
+ return {
1449
+ type: "node.reparent",
1450
+ nodeId: t.nodeId,
1451
+ fromParentNodeId: t.toParentNodeId,
1452
+ toParentNodeId: t.fromParentNodeId,
1453
+ before: t.after,
1454
+ after: t.before
1455
+ };
1456
+ case "node.rename":
1457
+ return { type: "node.rename", nodeId: t.nodeId, before: t.after, after: t.before };
1458
+ case "node.setRole":
1459
+ return { type: "node.setRole", nodeId: t.nodeId, before: t.after, after: t.before };
1460
+ case "node.setPhysics":
1461
+ return { type: "node.setPhysics", nodeId: t.nodeId, before: t.after, after: t.before };
1462
+ case "node.setInitialPose":
1463
+ return { type: "node.setInitialPose", nodeId: t.nodeId, before: t.after, after: t.before };
1464
+ case "node.setAppearance":
1465
+ return { type: "node.setAppearance", nodeId: t.nodeId, before: t.after, after: t.before };
1466
+ case "node.setVisible":
1467
+ return { type: "node.setVisible", nodeId: t.nodeId, before: t.after, after: t.before };
1468
+ case "placeholder.bind":
1469
+ return {
1470
+ type: "placeholder.bind",
1471
+ nodeId: t.nodeId,
1472
+ before: t.after,
1473
+ after: t.before
1474
+ };
1475
+ case "node.replaceModel":
1476
+ return {
1477
+ type: "node.replaceModel",
1478
+ nodeId: t.nodeId,
1479
+ parentNodeId: t.parentNodeId,
1480
+ before: t.after,
1481
+ after: t.before
1482
+ };
1483
+ case "node.setVariants":
1484
+ return { type: "node.setVariants", nodeId: t.nodeId, before: t.after, after: t.before };
1485
+ case "node.setSemantic":
1486
+ return { type: "node.setSemantic", nodeId: t.nodeId, before: t.after, after: t.before };
1487
+ case "node.setDomainData":
1488
+ return {
1489
+ type: "node.setDomainData",
1490
+ nodeId: t.nodeId,
1491
+ before: t.after,
1492
+ after: t.before
1493
+ };
1494
+ case "node.duplicate":
1495
+ return {
1496
+ type: "node.remove",
1497
+ nodeId: t.created.nodeId,
1498
+ parentNodeId: t.parentNodeId,
1499
+ removed: t.created
1500
+ };
1501
+ case "asset.add":
1502
+ return { type: "asset.remove", revisionId: t.revision.revisionId, removed: t.revision };
1503
+ case "asset.remove":
1504
+ return { type: "asset.add", revision: t.removed };
1505
+ case "meta.update":
1506
+ return { type: "meta.update", before: t.after, after: t.before };
1507
+ case "coordinateSystem.update":
1508
+ return { type: "coordinateSystem.update", before: t.after, after: t.before };
1509
+ case "environment.update":
1510
+ return { type: "environment.update", before: t.after, after: t.before };
1511
+ case "semantic.update":
1512
+ return { type: "semantic.update", before: t.after, after: t.before };
1513
+ case "domain.update":
1514
+ return {
1515
+ type: "domain.update",
1516
+ domainId: t.domainId,
1517
+ before: t.after,
1518
+ after: t.before
1519
+ };
1520
+ case "extension.set":
1521
+ return { type: "extension.set", key: t.key, before: t.after, after: t.before };
1522
+ default:
1523
+ return null;
1524
+ }
1525
+ }
1526
+ const As = /^[a-f0-9]{64}$/;
1527
+ function et(e) {
1528
+ var c;
1529
+ const t = e.files.map((d) => ({
1530
+ locator: R(d.locator),
1531
+ sha256: d.sha256.toLowerCase(),
1532
+ mediaType: d.mediaType,
1533
+ byteSize: d.byteSize
1534
+ })).sort((d, a) => m(d.locator).localeCompare(m(a.locator))), s = R(e.entryLocator), r = m(s);
1535
+ if (!t.some((d) => m(d.locator) === r))
1536
+ throw new Error(`Source entry is missing from its file set: ${r}`);
1537
+ if (t.some((d) => !As.test(d.sha256)))
1538
+ throw new Error("Source file SHA-256 values must be lower-case 64-character hashes.");
1539
+ const o = new Set(t.map((d) => m(d.locator))), n = /* @__PURE__ */ new Map();
1540
+ for (const d of e.dependencies ?? []) {
1541
+ const a = {
1542
+ from: R(d.from),
1543
+ to: R(d.to),
1544
+ kind: d.kind
1545
+ };
1546
+ n.set(
1547
+ `${m(a.from)}\0${m(a.to)}\0${a.kind}`,
1548
+ a
1549
+ );
1550
+ }
1551
+ const i = [...n.values()].sort(_s);
1552
+ for (const d of i) {
1553
+ const a = m(d.from), f = m(d.to);
1554
+ if (!o.has(a) || !o.has(f))
1555
+ throw new Error(`Source dependency edge references an unknown file: ${a} -> ${f}`);
1556
+ }
1557
+ const l = ((c = e.declaredSubresource) == null ? void 0 : c.trim()) || r;
1558
+ return {
1559
+ sourceRevisionId: N(C({
1560
+ sourceFormat: e.sourceFormat,
1561
+ entryLocator: s,
1562
+ files: t,
1563
+ dependencies: i,
1564
+ declaredSubresource: l
1565
+ })),
1566
+ sourceFormat: e.sourceFormat,
1567
+ entryLocator: s,
1568
+ files: t,
1569
+ dependencies: i,
1570
+ declaredSubresource: l
1571
+ };
1572
+ }
1573
+ function tt(e) {
1574
+ const t = Rs(e.runtimeRevision);
1575
+ return {
1576
+ interpretationRevisionId: N(C({
1577
+ sourceRevisionId: e.sourceRevisionId,
1578
+ adapter: e.adapter,
1579
+ normalization: e.normalization,
1580
+ facts: t,
1581
+ variantPayloads: Le(e.variantPayloads)
1582
+ })),
1583
+ adapter: e.adapter,
1584
+ normalization: e.normalization,
1585
+ runtimeRevision: e.runtimeRevision,
1586
+ variantPayloads: Le(e.variantPayloads)
1587
+ };
1588
+ }
1589
+ function Z(e) {
1590
+ const t = e.replaceAll("\\", "/");
1591
+ if (!t || t.startsWith("/") || /^[a-zA-Z]:\//.test(t))
1592
+ throw new Error(`Package paths must be relative: ${e}`);
1593
+ const s = [];
1594
+ for (const r of t.split("/"))
1595
+ if (!(!r || r === ".")) {
1596
+ if (r === "..") throw new Error(`Package paths must not escape their root: ${e}`);
1597
+ s.push(r);
1598
+ }
1599
+ if (s.length === 0) throw new Error(`Package path is empty: ${e}`);
1600
+ return s.join("/");
1601
+ }
1602
+ function Rr(e) {
1603
+ return N(C(e));
1604
+ }
1605
+ function Rs(e) {
1606
+ return "visualRevisionId" in e ? {
1607
+ format: e.format,
1608
+ capabilities: e.capabilities,
1609
+ upAxis: e.upAxis,
1610
+ suggestedScale: e.suggestedScale,
1611
+ bounds: e.bounds ?? null,
1612
+ metrics: e.metrics ?? null
1613
+ } : {
1614
+ layout: e.layout,
1615
+ fileKind: e.fileKind,
1616
+ capabilities: e.capabilities,
1617
+ variantSets: e.variantSets,
1618
+ bounds: e.bounds ?? null,
1619
+ metrics: e.metrics ?? null,
1620
+ category: e.category ?? null,
1621
+ semantic: e.semantic ?? null
1622
+ };
1623
+ }
1624
+ function Le(e) {
1625
+ return Object.fromEntries(
1626
+ Object.entries(e ?? {}).sort(([t], [s]) => t.localeCompare(s)).map(([t, s]) => [
1627
+ t,
1628
+ Object.fromEntries(
1629
+ Object.entries(s).sort(([r], [o]) => r.localeCompare(o)).map(([r, o]) => [r, [...new Set(o)].sort()])
1630
+ )
1631
+ ])
1632
+ );
1633
+ }
1634
+ function _s(e, t) {
1635
+ return m(e.from).localeCompare(m(t.from)) || m(e.to).localeCompare(m(t.to)) || e.kind.localeCompare(t.kind);
1636
+ }
1637
+ async function Ps(e, t = {}) {
1638
+ var d;
1639
+ const s = await Promise.all(e.files.map(async (a) => ({
1640
+ locator: R(a.locator),
1641
+ path: T(a.locator),
1642
+ bytes: new Uint8Array(await a.blob.arrayBuffer())
1643
+ }))), r = new Map(s.map((a) => [a.path, a])), o = Pt(e);
1644
+ if (!r.has(o))
1645
+ throw new Error(`Source entry is missing from its file set: ${o}`);
1646
+ const n = new Map(
1647
+ s.filter((a) => ve(a.path, a.bytes)).map((a) => [a.path, new TextDecoder("utf-8").decode(a.bytes)])
1648
+ ), i = he(
1649
+ [...n].map(([a, f]) => ({ path: a, text: f })),
1650
+ new Set(r.keys())
1651
+ ), l = /* @__PURE__ */ new Map(), u = s.map((a) => a.locator);
1652
+ for (const a of i.references) {
1653
+ if (a.kind === "material-module") continue;
1654
+ const f = r.get(a.fromPath);
1655
+ if (!f) continue;
1656
+ const g = Fe(
1657
+ f.locator,
1658
+ a.target,
1659
+ u
1660
+ );
1661
+ if (!g)
1662
+ throw new Error(
1663
+ `USD source has an unresolved or external reference: ${a.fromPath} -> ${a.target}`
1664
+ );
1665
+ const h = s.find((p) => m(p.locator) === m(g));
1666
+ if (!h)
1667
+ throw new Error(
1668
+ `USD source has an unresolved or external reference: ${a.fromPath} -> ${a.target}`
1669
+ );
1670
+ Me(l, {
1671
+ from: f.locator,
1672
+ to: h.locator,
1673
+ kind: ws(a, n.get(a.fromPath) ?? "")
1674
+ });
1675
+ }
1676
+ const c = r.get(o);
1677
+ if (c && !n.has(o) && s.length > 1 && $s(o) && (((d = t.explicitDependencies) == null ? void 0 : d.length) ?? 0) === 0)
1678
+ for (const a of s)
1679
+ a.path !== o && Me(l, {
1680
+ from: c.locator,
1681
+ to: a.locator,
1682
+ kind: "other"
1683
+ });
1684
+ return [...l.values()].sort(Ns);
1685
+ }
1686
+ function Ds(e, t) {
1687
+ const s = new Set(e.map(ge)), r = t.filter((o) => !s.has(ge(o)));
1688
+ if (r.length > 0)
1689
+ throw new Error(
1690
+ `Explicit source dependencies omit scanned USD topology: ${r.map((o) => `${m(o.from)} -> ${m(o.to)} (${o.kind})`).join(", ")}`
1691
+ );
1692
+ }
1693
+ function Me(e, t) {
1694
+ e.set(ge(t), t);
1695
+ }
1696
+ function ws(e, t) {
1697
+ if (e.kind === "material-module") return "material-module";
1698
+ const s = `@${e.target}@`, r = t.indexOf(s);
1699
+ if (r < 0) return "other";
1700
+ const o = t.slice(Math.max(0, r - 180), r);
1701
+ return /\bsubLayers\s*=\s*\[[^\]]*$/is.test(o) ? "sublayer" : /\bpayload\s*=\s*(?:\[[^\]]*)?$/is.test(o) ? "payload" : /\b(?:inputs:file|sourceAsset)\s*=\s*$/is.test(o) ? "texture" : /\breferences\s*=\s*(?:\[[^\]]*)?$/is.test(o) ? "reference" : "other";
1702
+ }
1703
+ function ge(e) {
1704
+ return `${m(e.from)}\0${m(e.to)}\0${e.kind}`;
1705
+ }
1706
+ function $s(e) {
1707
+ return /\.(?:usd|usda|usdc|usdz)$/i.test(e);
1708
+ }
1709
+ function Ns(e, t) {
1710
+ return m(e.from).localeCompare(m(t.from)) || m(e.to).localeCompare(m(t.to)) || e.kind.localeCompare(t.kind);
1711
+ }
1712
+ const Ts = /^[a-f0-9]{64}$/;
1713
+ async function _r(e) {
1714
+ const t = [];
1715
+ for (const s of e.assets) {
1716
+ const r = [];
1717
+ for (const c of s.source.files) {
1718
+ const d = new Uint8Array(await c.blob.arrayBuffer());
1719
+ r.push({
1720
+ locator: R(c.locator),
1721
+ sha256: N(d),
1722
+ mediaType: St(
1723
+ T(c.locator),
1724
+ c.blob.type
1725
+ ) ?? vt,
1726
+ byteSize: d.byteLength
1727
+ });
1728
+ }
1729
+ const o = await Ps(s.source, {
1730
+ explicitDependencies: s.dependencies
1731
+ });
1732
+ s.dependencies !== void 0 && Ds(
1733
+ s.dependencies,
1734
+ o
1735
+ );
1736
+ const n = et({
1737
+ sourceFormat: s.sourceFormat ?? Cs(s.asset),
1738
+ entryLocator: s.source.entryLocator,
1739
+ files: r,
1740
+ dependencies: s.dependencies ?? o,
1741
+ declaredSubresource: s.declaredSubresource
1742
+ }), i = s.adapter ?? {
1743
+ id: "sim-studio.m1.source-facts",
1744
+ version: "1"
1745
+ }, l = s.normalization ?? {
1746
+ upAxis: "visualRevisionId" in s.asset ? s.asset.upAxis : "z",
1747
+ unitScale: 1,
1748
+ originPolicy: "source"
1749
+ }, u = tt({
1750
+ sourceRevisionId: n.sourceRevisionId,
1751
+ adapter: i,
1752
+ normalization: l,
1753
+ runtimeRevision: s.asset,
1754
+ variantPayloads: s.variantPayloads
1755
+ });
1756
+ t.push({
1757
+ assetId: s.asset.assetId,
1758
+ label: s.asset.label,
1759
+ kind: "visualRevisionId" in s.asset ? "visual" : "usd",
1760
+ source: n,
1761
+ interpretation: u,
1762
+ deliveryArtifacts: [...s.deliveryArtifacts ?? []]
1763
+ });
1764
+ }
1765
+ return {
1766
+ format: "sim-studio.asset-catalog@3",
1767
+ schemaVersion: 3,
1768
+ entries: t.sort((s, r) => s.assetId.localeCompare(r.assetId) || s.source.sourceRevisionId.localeCompare(r.source.sourceRevisionId)),
1769
+ deliveryLocks: [...e.deliveryLocks ?? []].sort((s, r) => s.assetId.localeCompare(r.assetId) || s.profileId.localeCompare(r.profileId) || s.artifactId.localeCompare(r.artifactId))
1770
+ };
1771
+ }
1772
+ function Pr(e) {
1773
+ if (!x(e) || e.format !== "sim-studio.asset-catalog@3" || e.schemaVersion !== 3 || !Array.isArray(e.entries) || !Array.isArray(e.deliveryLocks))
1774
+ throw new Error("Asset catalog format or structure is invalid.");
1775
+ const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
1776
+ for (const r of e.entries) {
1777
+ if (!x(r) || typeof r.assetId != "string" || r.assetId.length === 0 || typeof r.label != "string" || r.kind !== "usd" && r.kind !== "visual" || !x(r.source) || typeof r.source.sourceFormat != "string" || r.source.sourceFormat.length === 0 || !x(r.source.entryLocator) || typeof r.source.declaredSubresource != "string" || !Array.isArray(r.source.files) || !Array.isArray(r.source.dependencies) || !x(r.interpretation) || !x(r.interpretation.runtimeRevision) || !Array.isArray(r.deliveryArtifacts))
1778
+ throw new Error("Asset catalog entry structure is invalid.");
1779
+ const o = r;
1780
+ for (const a of o.source.files)
1781
+ if (!x(a) || !x(a.locator) || typeof a.sha256 != "string" || !Ts.test(a.sha256) || typeof a.mediaType != "string" || a.mediaType.length === 0 || typeof a.byteSize != "number" || !Number.isInteger(a.byteSize) || a.byteSize < 0)
1782
+ throw new Error(`Asset catalog source file facts are invalid: ${o.assetId}.`);
1783
+ let n;
1784
+ try {
1785
+ n = et({
1786
+ sourceFormat: o.source.sourceFormat,
1787
+ entryLocator: o.source.entryLocator,
1788
+ files: o.source.files,
1789
+ dependencies: o.source.dependencies,
1790
+ declaredSubresource: o.source.declaredSubresource
1791
+ });
1792
+ } catch (a) {
1793
+ throw new Error(
1794
+ `Asset catalog source is invalid for ${o.assetId}: ${ks(a)}`
1795
+ );
1796
+ }
1797
+ if (n.sourceRevisionId !== o.source.sourceRevisionId)
1798
+ throw new Error(`Asset catalog sourceRevisionId does not match its source facts: ${o.assetId}.`);
1799
+ if (s.has(o.source.sourceRevisionId))
1800
+ throw new Error(
1801
+ `Asset catalog repeats sourceRevisionId ${o.source.sourceRevisionId}; node references would be ambiguous.`
1802
+ );
1803
+ s.add(o.source.sourceRevisionId);
1804
+ const i = o.interpretation.runtimeRevision, l = "visualRevisionId" in i ? "visual" : "usd", u = "visualRevisionId" in i ? i.visualRevisionId : i.revisionId;
1805
+ if (o.kind !== l || typeof u != "string" || u.length === 0 || i.assetId !== o.assetId)
1806
+ throw new Error(`Asset catalog runtime revision is inconsistent: ${o.assetId}.`);
1807
+ const c = `${l}\0${u}`;
1808
+ if (t.has(c))
1809
+ throw new Error(`Asset catalog repeats runtime revision ${u}.`);
1810
+ if (t.add(c), tt({
1811
+ sourceRevisionId: o.source.sourceRevisionId,
1812
+ adapter: o.interpretation.adapter,
1813
+ normalization: o.interpretation.normalization,
1814
+ runtimeRevision: i,
1815
+ variantPayloads: o.interpretation.variantPayloads
1816
+ }).interpretationRevisionId !== o.interpretation.interpretationRevisionId)
1817
+ throw new Error(
1818
+ `Asset catalog interpretationRevisionId does not match its interpretation facts: ${o.assetId}.`
1819
+ );
1820
+ }
1821
+ }
1822
+ function Dr(e, t) {
1823
+ return e.entries.find((s) => {
1824
+ const r = s.interpretation.runtimeRevision;
1825
+ return "visualRevisionId" in t ? "visualRevisionId" in r && r.visualRevisionId === t.visualRevisionId : "revisionId" in r && r.revisionId === t.revisionId;
1826
+ }) ?? null;
1827
+ }
1828
+ function Cs(e) {
1829
+ return "visualRevisionId" in e ? e.format : e.fileKind;
1830
+ }
1831
+ function x(e) {
1832
+ return typeof e == "object" && e !== null && !Array.isArray(e);
1833
+ }
1834
+ function ks(e) {
1835
+ return e instanceof Error ? e.message : String(e);
1836
+ }
1837
+ const wr = Object.freeze({
1838
+ format: "sim-studio.delivery-profile@1",
1839
+ schemaVersion: 1,
1840
+ profileId: "isaac-sim",
1841
+ profileVersion: "m1",
1842
+ target: "isaac-sim",
1843
+ stage: {
1844
+ upAxis: "Z",
1845
+ metersPerUnit: 1,
1846
+ kilogramsPerUnit: 1,
1847
+ defaultPrim: "World"
1848
+ },
1849
+ variants: {
1850
+ preferred: Object.freeze({ Physics: "physx" }),
1851
+ conflictPolicy: "block",
1852
+ fallbackPolicy: "source-authored-default"
1853
+ },
1854
+ visualArtifactPolicy: "require-resolved-artifact"
1855
+ });
1856
+ function xs(e) {
1857
+ return st(e), N(C(e));
1858
+ }
1859
+ function st(e) {
1860
+ if (e.format !== "sim-studio.delivery-profile@1" || e.schemaVersion !== 1)
1861
+ throw new Error("Unsupported delivery profile format.");
1862
+ if (e.target !== "isaac-sim") throw new Error(`Unsupported delivery target: ${e.target}.`);
1863
+ if (e.stage.upAxis !== "Z" || e.stage.metersPerUnit !== 1 || e.stage.kilogramsPerUnit !== 1 || e.stage.defaultPrim !== "World")
1864
+ throw new Error("M1 delivery profile requires Z-up metres/kilograms and World defaultPrim.");
1865
+ if (e.variants.conflictPolicy !== "block")
1866
+ throw new Error("M1 variant conflict policy must be block.");
1867
+ if (e.variants.fallbackPolicy !== "source-authored-default")
1868
+ throw new Error("M1 variant fallback policy must preserve the source-authored default.");
1869
+ if (e.visualArtifactPolicy !== "require-resolved-artifact")
1870
+ throw new Error("M1 visual nodes require resolved delivery artifacts.");
1871
+ }
1872
+ const Os = /^[A-Za-z_][A-Za-z0-9_]*$/;
1873
+ function Ls(e) {
1874
+ const t = [...e].sort((i, l) => w(i.instanceId, l.instanceId)), s = /* @__PURE__ */ new Set(["World", "PhysicsScene"]), r = /* @__PURE__ */ new Map(), o = [];
1875
+ let n = 0;
1876
+ for (const i of t) {
1877
+ const l = G(i.label), u = l === null, c = l ?? `Instance${n += 1}`, d = Ms(c, s);
1878
+ s.add(d), r.set(i.instanceId, d), d !== i.label && o.push({ instanceId: i.instanceId, from: i.label, to: d, fallback: u });
1879
+ }
1880
+ return { byInstanceId: r, renames: o };
1881
+ }
1882
+ function G(e) {
1883
+ const t = Array.from(e.normalize("NFKC")).map((r) => /[A-Za-z0-9_]/.test(r) ? r : "_").join("").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
1884
+ if (!t) return null;
1885
+ const s = /^[0-9]/.test(t) ? `_${t}` : t;
1886
+ return Os.test(s) ? s : null;
1887
+ }
1888
+ function rt(e, t) {
1889
+ const s = Array.from(e.normalize("NFKC")).map((o) => /[A-Za-z0-9]/.test(o) ? o.toLowerCase() : "-").join("").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
1890
+ return s && /[a-z]/.test(s) ? s : `asset-${t.replace(/[^a-zA-Z0-9]/g, "").toLowerCase().replace(/^asset/, "") || "item"}`;
1891
+ }
1892
+ function Ms(e, t) {
1893
+ if (!t.has(e)) return e;
1894
+ let s = 2;
1895
+ for (; t.has(`${e}_${s}`); ) s += 1;
1896
+ return `${e}_${s}`;
1897
+ }
1898
+ const Us = "sim-studio.usd-delivery-plan@4", Ue = /^[a-f0-9]{64}$/;
1899
+ function ot(e) {
1900
+ nt(e);
1901
+ const { planDigest: t, ...s } = e;
1902
+ return N(C(s));
1903
+ }
1904
+ function $r(e) {
1905
+ if (nt(e), !Ue.test(e.planDigest))
1906
+ throw Object.assign(
1907
+ new Error("USD delivery plan digest must be a lowercase SHA-256 value."),
1908
+ { code: "USD_DELIVERY_PLAN_DIGEST_INVALID" }
1909
+ );
1910
+ const t = ot(e);
1911
+ if (e.planDigest !== t)
1912
+ throw Object.assign(
1913
+ new Error("USD delivery plan content does not match planDigest."),
1914
+ {
1915
+ code: "USD_DELIVERY_PLAN_DIGEST_MISMATCH",
1916
+ detail: {
1917
+ expectedDigest: t,
1918
+ actualDigest: e.planDigest
1919
+ }
1920
+ }
1921
+ );
1922
+ if (!Array.isArray(e.resources))
1923
+ throw O("USD delivery plan resources must be an array.");
1924
+ const s = /* @__PURE__ */ new Map();
1925
+ for (const r of e.resources) {
1926
+ if (!r || typeof r != "object" || typeof r.outputPath != "string" || !Ue.test(String(r.sourceSha256)) || !Number.isSafeInteger(r.sourceByteSize) || r.sourceByteSize < 0)
1927
+ throw O("USD delivery plan contains invalid resource facts.");
1928
+ const o = r.outputPath;
1929
+ if (!zs(o))
1930
+ throw O(`USD delivery plan contains unsafe resource path: ${o}.`);
1931
+ const n = o.toLowerCase(), i = s.get(n);
1932
+ if (i !== void 0)
1933
+ throw Object.assign(
1934
+ new Error(
1935
+ i === o ? `USD delivery plan repeats resource output path: ${o}.` : `USD delivery plan has a case-insensitive resource path collision: ${i}, ${o}.`
1936
+ ),
1937
+ { code: "USD_DELIVERY_PLAN_RESOURCE_PATH_CONFLICT" }
1938
+ );
1939
+ s.set(n, o);
1940
+ const l = r.outputTransform;
1941
+ if (!l || typeof l != "object" || l.kind !== "identity" && l.kind !== "canonicalize-usdz")
1942
+ throw O(
1943
+ `USD delivery plan contains an invalid outputTransform for resource: ${o}.`
1944
+ );
1945
+ if (o.toLowerCase().endsWith(".usdz") && l.kind !== "canonicalize-usdz")
1946
+ throw O(
1947
+ `USD delivery plan must canonicalize nested USDZ resource: ${o}.`
1948
+ );
1949
+ if (!o.toLowerCase().endsWith(".usdz") && l.kind === "canonicalize-usdz")
1950
+ throw O(
1951
+ `USD delivery plan cannot canonicalize a non-USDZ resource: ${o}.`
1952
+ );
1953
+ }
1954
+ if (e.outcome !== "blocked" && Array.isArray(e.diagnostics) && e.diagnostics.some((r) => r.severity === "error"))
1955
+ throw O("A supported or degraded USD delivery plan cannot contain error diagnostics.");
1956
+ }
1957
+ function nt(e) {
1958
+ if (!e || typeof e != "object" || !("format" in e) || e.format !== Us || !("schemaVersion" in e) || e.schemaVersion !== 4)
1959
+ throw Object.assign(
1960
+ new Error("USD delivery plan must use format sim-studio.usd-delivery-plan@4 schemaVersion 4."),
1961
+ { code: "UNSUPPORTED_USD_DELIVERY_PLAN_FORMAT" }
1962
+ );
1963
+ }
1964
+ function zs(e) {
1965
+ return !e || e.startsWith("/") || e.includes("\\") || /^[A-Za-z]:/.test(e) || e.includes("\0") || e.includes("?") || e.includes("#") ? !1 : e.split("/").every((t) => t.length > 0 && t !== "." && t !== "..");
1966
+ }
1967
+ function O(e) {
1968
+ return Object.assign(new Error(e), {
1969
+ code: "USD_DELIVERY_PLAN_CONTRACT_INVALID"
1970
+ });
1971
+ }
1972
+ function Nr(e) {
1973
+ st(e.profile);
1974
+ const t = [], s = /* @__PURE__ */ new Map(), r = new Map(e.assetCatalog.entries.map((a) => [
1975
+ a.source.sourceRevisionId,
1976
+ a
1977
+ ])), o = re(
1978
+ Ie(e.document.root).filter((a) => a.nodeType === "group" || a.nodeType === "asset" || a.nodeType === "visual"),
1979
+ (a, f) => w(a.nodeId, f.nodeId)
1980
+ ), n = Ls(o.filter((a) => a.nodeId !== e.document.root.nodeId).map((a) => ({
1981
+ instanceId: a.nodeId,
1982
+ label: a.label
1983
+ })));
1984
+ for (const a of Ie(e.document.root))
1985
+ a.nodeType === "placeholder" ? t.push(v(
1986
+ "USD_DELIVERY_PLACEHOLDER_BLOCKED",
1987
+ "error",
1988
+ `Placeholder ${a.label} cannot enter a resolved USD delivery plan.`,
1989
+ a.nodeId
1990
+ )) : a.nodeType === "domain" && t.push(v(
1991
+ "USD_DELIVERY_DOMAIN_BLOCKED",
1992
+ "error",
1993
+ `Domain node ${a.label} has no M1 USD delivery adapter for ${a.domainId}.`,
1994
+ a.nodeId
1995
+ ));
1996
+ const l = ((a, f, g = !1) => {
1997
+ const p = `/${g ? e.profile.stage.defaultPrim : n.byInstanceId.get(a.nodeId) ?? G(a.label) ?? "Group"}`, I = re(
1998
+ a.children.filter((A) => A.nodeType === "group" || A.nodeType === "asset" || A.nodeType === "visual"),
1999
+ (A, P) => w(A.nodeId, P.nodeId)
2000
+ ).flatMap((A) => at(A, p, e, t, s, r, n.byInstanceId));
2001
+ return {
2002
+ nodeId: a.nodeId,
2003
+ primPath: p,
2004
+ nodeKind: "group",
2005
+ typeName: "Xform",
2006
+ attributes: ce(a.localTransform),
2007
+ ...le(a),
2008
+ visible: !0,
2009
+ children: I
2010
+ };
2011
+ })(e.document.root, "/", !0);
2012
+ Hs(r, s, t), Gs(s, t);
2013
+ const u = tr(t), c = Bs(e.document.environment.physics.gravity), d = {
2014
+ format: "sim-studio.usd-delivery-plan@4",
2015
+ schemaVersion: 4,
2016
+ sourcePackageDigest: e.sourcePackageDigest,
2017
+ profileDigest: xs(e.profile),
2018
+ profile: {
2019
+ profileId: e.profile.profileId,
2020
+ profileVersion: e.profile.profileVersion
2021
+ },
2022
+ stage: {
2023
+ defaultPrim: l.primPath.slice(1),
2024
+ upAxis: e.profile.stage.upAxis,
2025
+ metersPerUnit: e.profile.stage.metersPerUnit,
2026
+ kilogramsPerUnit: e.profile.stage.kilogramsPerUnit,
2027
+ physicsScene: c
2028
+ },
2029
+ nodes: [l],
2030
+ resources: re([...s.values()], (a, f) => w(a.outputPath, f.outputPath) || w(a.sourceSha256, f.sourceSha256)),
2031
+ diagnostics: sr(t),
2032
+ outcome: u
2033
+ };
2034
+ return {
2035
+ ...d,
2036
+ planDigest: ot(d)
2037
+ };
2038
+ }
2039
+ function at(e, t, s, r, o, n, i) {
2040
+ const l = `/${s.profile.stage.defaultPrim}/PhysicsScene`, u = i.get(e.nodeId) ?? G(e.label);
2041
+ if ((t === "/" ? `/${u ?? "Node"}` : `${t}/${u ?? "Node"}`) === l && r.push(v(
2042
+ "USD_EXPORT_PHYSICS_SCENE_NAME_CONFLICT",
2043
+ "error",
2044
+ `Node ${e.label} collides with the required root PhysicsScene prim.`,
2045
+ e.nodeId
2046
+ )), e.nodeType === "group") {
2047
+ const d = i.get(e.nodeId) ?? G(e.label) ?? "Group", a = t === "/" ? `/${d}` : `${t}/${d}`;
2048
+ return [{
2049
+ nodeId: e.nodeId,
2050
+ primPath: a,
2051
+ nodeKind: "group",
2052
+ typeName: "Xform",
2053
+ attributes: ce(e.localTransform),
2054
+ ...le(e),
2055
+ visible: !0,
2056
+ children: e.children.flatMap((f) => at(f, a, s, r, o, n, i))
2057
+ }];
2058
+ }
2059
+ return e.nodeType === "asset" ? Vs(
2060
+ e,
2061
+ t,
2062
+ s,
2063
+ r,
2064
+ o,
2065
+ n,
2066
+ i
2067
+ ) : e.nodeType === "visual" ? Fs(
2068
+ e,
2069
+ t,
2070
+ s,
2071
+ r,
2072
+ o,
2073
+ n,
2074
+ i
2075
+ ) : [];
2076
+ }
2077
+ function Vs(e, t, s, r, o, n, i) {
2078
+ const l = Et(s.document, e.assetRevisionId), u = l ? it(s.assetCatalog, l) : null;
2079
+ if (!l || !u)
2080
+ return r.push(v(
2081
+ "USD_DELIVERY_ASSET_SOURCE_MISSING",
2082
+ "error",
2083
+ `Asset node ${e.label} has no matching AssetCatalog source.`,
2084
+ e.nodeId,
2085
+ e.assetRevisionId
2086
+ )), [];
2087
+ const c = Ws(e, u, s.profile.variants.preferred, r);
2088
+ if (!c.ok) return [];
2089
+ const d = i.get(e.nodeId) ?? G(e.label) ?? "Asset", a = t === "/" ? `/${d}` : `${t}/${d}`;
2090
+ ct(e, a, r);
2091
+ const f = Ks(e, a, u, r);
2092
+ if (!f) return [];
2093
+ const g = R(u.source.entryLocator);
2094
+ if (g.kind === "remote-url")
2095
+ return r.push(v(
2096
+ "USD_EXPORT_REMOTE_NATIVE_REFERENCE_BLOCKED",
2097
+ "error",
2098
+ `Asset node ${e.label} uses a remote native USD source. Offline USD export requires a closed local resource set.`,
2099
+ e.nodeId,
2100
+ u.assetId
2101
+ )), [];
2102
+ const h = `assets/${rt(u.label, u.assetId)}/${u.source.sourceRevisionId.slice(0, 16)}`, p = qs(u, g), I = `${h}/${p}`, A = m(g);
2103
+ for (const P of u.source.files)
2104
+ Qs(
2105
+ o,
2106
+ u,
2107
+ P,
2108
+ `${h}/${m(P.locator) === A ? p : B(P.locator)}`
2109
+ );
2110
+ return [{
2111
+ nodeId: e.nodeId,
2112
+ primPath: a,
2113
+ nodeKind: "reference",
2114
+ typeName: "Xform",
2115
+ assetId: u.assetId,
2116
+ sourceRevisionId: u.source.sourceRevisionId,
2117
+ reference: {
2118
+ assetPath: `./${I}`,
2119
+ ...c.selections ? { variantSelections: c.selections } : {}
2120
+ },
2121
+ attributes: ce(e.localTransform),
2122
+ ...le(e),
2123
+ visible: e.visible,
2124
+ classification: "native-usd",
2125
+ materialBinding: "source-authored",
2126
+ physics: f
2127
+ }];
2128
+ }
2129
+ function Fs(e, t, s, r, o, n, i) {
2130
+ const l = At(s.document, e.visualRevisionId), u = l ? it(s.assetCatalog, l) : null;
2131
+ if (!l || !u)
2132
+ return r.push(v(
2133
+ "USD_DELIVERY_VISUAL_SOURCE_MISSING",
2134
+ "error",
2135
+ `Visual node ${e.label} has no matching AssetCatalog source.`,
2136
+ e.nodeId,
2137
+ e.visualRevisionId
2138
+ )), [];
2139
+ const c = Js(
2140
+ s.assetCatalog,
2141
+ u,
2142
+ s.profile.profileId,
2143
+ s.profile.profileVersion
2144
+ );
2145
+ if (!c)
2146
+ return r.push(v(
2147
+ "USD_DELIVERY_VISUAL_ARTIFACT_MISSING",
2148
+ "error",
2149
+ `Visual node ${e.label} requires a resolved delivery artifact for ${s.profile.profileId}@${s.profile.profileVersion}.`,
2150
+ e.nodeId,
2151
+ u.assetId
2152
+ )), [];
2153
+ if (r.push(...c.artifact.diagnostics), c.artifact.outcome === "blocked") return [];
2154
+ const d = js(
2155
+ u,
2156
+ c.artifact,
2157
+ e,
2158
+ r
2159
+ );
2160
+ if (!d) return [];
2161
+ const a = i.get(e.nodeId) ?? G(e.label) ?? "Visual", f = t === "/" ? `/${a}` : `${t}/${a}`;
2162
+ ct(e, f, r);
2163
+ const g = `assets/${rt(u.label, u.assetId)}/${u.source.sourceRevisionId.slice(0, 16)}`, h = `${g}/${Z(c.artifact.entryOutputPath)}`;
2164
+ for (const p of d)
2165
+ er(
2166
+ o,
2167
+ u,
2168
+ c.artifact,
2169
+ p,
2170
+ `${g}/${B(p.locator)}`
2171
+ );
2172
+ return c.artifact.outcome === "degraded" && !r.some((p) => p.nodeId === e.nodeId && p.severity === "warning") && r.push(v(
2173
+ "USD_DELIVERY_VISUAL_ARTIFACT_DEGRADED",
2174
+ "warning",
2175
+ `Visual node ${e.label} uses a degraded delivery artifact.`,
2176
+ e.nodeId,
2177
+ u.assetId
2178
+ )), [{
2179
+ nodeId: e.nodeId,
2180
+ primPath: f,
2181
+ nodeKind: "reference",
2182
+ typeName: "Xform",
2183
+ assetId: u.assetId,
2184
+ sourceRevisionId: u.source.sourceRevisionId,
2185
+ artifactId: c.artifact.artifactId,
2186
+ reference: { assetPath: `./${h}` },
2187
+ attributes: ce(e.localTransform),
2188
+ ...le(e),
2189
+ visible: e.visible,
2190
+ classification: "visual-only",
2191
+ materialBinding: "visual-artifact",
2192
+ physics: { kind: "none", policy: "visual-only" }
2193
+ }];
2194
+ }
2195
+ function js(e, t, s, r) {
2196
+ const o = (c) => (r.push(v(
2197
+ "USD_DELIVERY_VISUAL_ARTIFACT_INVALID",
2198
+ "error",
2199
+ c,
2200
+ s.nodeId,
2201
+ e.assetId
2202
+ )), null);
2203
+ if (t.sourceRevisionId !== e.source.sourceRevisionId)
2204
+ return o(
2205
+ `Delivery artifact ${t.artifactId} is bound to ${t.sourceRevisionId}, not ${e.source.sourceRevisionId}.`
2206
+ );
2207
+ let n;
2208
+ try {
2209
+ n = Z(t.entryOutputPath);
2210
+ } catch {
2211
+ return o(`Delivery artifact ${t.artifactId} has an invalid entry path: ${t.entryOutputPath}.`);
2212
+ }
2213
+ const i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = [];
2214
+ for (const c of t.resources) {
2215
+ const d = R(c.locator);
2216
+ if (!c.resourceId || l.has(c.resourceId))
2217
+ return o(`Delivery artifact ${t.artifactId} has a missing or duplicate resource id: ${c.resourceId}.`);
2218
+ if (!/^[a-f0-9]{64}$/.test(c.sha256) || !c.mediaType || !Number.isInteger(c.byteSize) || c.byteSize < 0)
2219
+ return o(`Delivery artifact ${t.artifactId} has invalid resource facts: ${m(c.locator)}.`);
2220
+ const a = B(d);
2221
+ if (i.has(a))
2222
+ return o(`Delivery artifact ${t.artifactId} repeats resource path ${a}.`);
2223
+ i.add(a), l.add(c.resourceId), u.push({ ...c, locator: d });
2224
+ }
2225
+ return i.has(n) ? u.sort((c, d) => B(c.locator).localeCompare(
2226
+ B(d.locator)
2227
+ ) || c.resourceId.localeCompare(d.resourceId)) : o(
2228
+ `Delivery artifact ${t.artifactId} entry ${n} is missing from its resources.`
2229
+ );
2230
+ }
2231
+ function it(e, t) {
2232
+ return e.entries.find((s) => {
2233
+ const r = s.interpretation.runtimeRevision;
2234
+ return "visualRevisionId" in t ? "visualRevisionId" in r && r.visualRevisionId === t.visualRevisionId : "revisionId" in r && r.revisionId === t.revisionId;
2235
+ }) ?? null;
2236
+ }
2237
+ function Bs(e) {
2238
+ const t = Math.hypot(...e);
2239
+ if (!Number.isFinite(t))
2240
+ throw new Error("Scene gravity must contain finite values.");
2241
+ return t <= 1e-12 ? { gravityDirection: [0, 0, -1], gravityMagnitude: 0 } : {
2242
+ gravityDirection: e.map((s) => M(s / t, 12)),
2243
+ gravityMagnitude: M(t, 12)
2244
+ };
2245
+ }
2246
+ function ct(e, t, s) {
2247
+ var r, o, n, i;
2248
+ e.nodeType === "asset" ? (e.initialPose && s.push(v(
2249
+ "USD_EXPORT_INITIAL_POSE_UNSUPPORTED",
2250
+ "error",
2251
+ `Asset node ${e.label} declares an initial joint pose. OpenUSD has no lossless generic initial-joint-state contract, so the export is blocked.`,
2252
+ e.nodeId,
2253
+ e.assetRevisionId
2254
+ )), (r = e.appearance) != null && r.color && s.push(v(
2255
+ "USD_EXPORT_COLOR_OVERRIDE_NOT_ENCODED",
2256
+ "warning",
2257
+ `Asset node ${e.label} has a color override that is not authored in this physics-preserving native USD delivery.`,
2258
+ e.nodeId,
2259
+ e.assetRevisionId
2260
+ )), ((o = e.appearance) == null ? void 0 : o.opacity) !== void 0 && s.push(v(
2261
+ "USD_EXPORT_OPACITY_OVERRIDE_NOT_ENCODED",
2262
+ "warning",
2263
+ `Asset node ${e.label} has an opacity override that is not authored in this delivery.`,
2264
+ e.nodeId,
2265
+ e.assetRevisionId
2266
+ )), e.semantic && s.push(v(
2267
+ "USD_EXPORT_SEMANTIC_NOT_ENCODED",
2268
+ "warning",
2269
+ `Asset node ${e.label} has semantic annotations that are not authored into the USD stage.`,
2270
+ e.nodeId,
2271
+ e.assetRevisionId
2272
+ ))) : e.nodeType === "visual" && ((n = e.appearance) != null && n.color && s.push(v(
2273
+ "USD_EXPORT_COLOR_OVERRIDE_NOT_ENCODED",
2274
+ "warning",
2275
+ `Visual node ${e.label} has a color override that is not authored in this delivery.`,
2276
+ e.nodeId,
2277
+ e.visualRevisionId
2278
+ )), ((i = e.appearance) == null ? void 0 : i.opacity) !== void 0 && s.push(v(
2279
+ "USD_EXPORT_OPACITY_OVERRIDE_NOT_ENCODED",
2280
+ "warning",
2281
+ `Visual node ${e.label} has an opacity override that is not authored in this delivery.`,
2282
+ e.nodeId,
2283
+ e.visualRevisionId
2284
+ )), e.semantic && s.push(v(
2285
+ "USD_EXPORT_SEMANTIC_NOT_ENCODED",
2286
+ "warning",
2287
+ `Visual node ${e.label} has semantic annotations that are not authored into the USD stage.`,
2288
+ e.nodeId,
2289
+ e.visualRevisionId
2290
+ )));
2291
+ }
2292
+ function Ks(e, t, s, r) {
2293
+ var f, g, h, p;
2294
+ const o = e.physics, n = (f = o.colliderPrimPaths) == null ? void 0 : f.map((I) => ze(t, I)), i = (g = o.jointOverrides) == null ? void 0 : g.map((I) => ({
2295
+ ...I,
2296
+ jointPrimPath: ze(t, I.jointPrimPath)
2297
+ })), l = o.physicsMaterial ? Ys(o.physicsMaterial) : void 0;
2298
+ if (i != null && i.length)
2299
+ return r.push(v(
2300
+ "USD_EXPORT_JOINT_DRIVE_UNITS_NOT_VERIFIED",
2301
+ "error",
2302
+ `Asset node ${e.label} requests joint drive overrides, but OpenUSD core does not define the target PhysX angle, stiffness, damping, and max-force units.`,
2303
+ e.nodeId,
2304
+ e.assetRevisionId
2305
+ )), null;
2306
+ const u = !!(n != null && n.length || l), c = s.interpretation.runtimeRevision, d = !!((h = c.capabilities) != null && h.colliderGeometry), a = !!((p = c.capabilities) != null && p.rigidBody);
2307
+ if (o.kind === "static" || o.kind === "kinematic" || o.kind === "dynamic") {
2308
+ if (!(n != null && n.length) && !d)
2309
+ return r.push(v(
2310
+ "USD_EXPORT_COLLIDER_GEOMETRY_REQUIRED",
2311
+ "error",
2312
+ `Asset node ${e.label} requests ${o.kind} physics, but neither source collider geometry nor colliderPrimPaths are available.`,
2313
+ e.nodeId,
2314
+ e.assetRevisionId
2315
+ )), null;
2316
+ if (o.kind === "static" && a)
2317
+ return r.push(v(
2318
+ "USD_EXPORT_STATIC_OVERRIDE_CANNOT_REMOVE_RIGID_BODY",
2319
+ "error",
2320
+ `Asset node ${e.label} requests static physics, but its source-authored PhysicsRigidBodyAPI cannot be removed losslessly by core OpenUSD composition.`,
2321
+ e.nodeId,
2322
+ e.assetRevisionId
2323
+ )), null;
2324
+ }
2325
+ return o.kind === "asset-authored" ? {
2326
+ kind: "asset-authored",
2327
+ policy: u ? "preserve-with-overrides" : "preserve-source",
2328
+ ...n != null && n.length ? { colliderPrimPaths: n } : {},
2329
+ ...l ? { physicsMaterial: l } : {}
2330
+ } : o.kind === "dynamic" ? {
2331
+ kind: "dynamic",
2332
+ policy: "preserve-with-overrides",
2333
+ ...o.massKg !== void 0 ? { massKg: o.massKg } : {},
2334
+ ...o.centerOfMassM ? { centerOfMassM: o.centerOfMassM.map((I) => M(I, 6)) } : {},
2335
+ ...n != null && n.length ? { colliderPrimPaths: n } : {},
2336
+ ...l ? { physicsMaterial: l } : {}
2337
+ } : {
2338
+ kind: o.kind,
2339
+ policy: "preserve-with-overrides",
2340
+ ...n != null && n.length ? { colliderPrimPaths: n } : {},
2341
+ ...l ? { physicsMaterial: l } : {}
2342
+ };
2343
+ }
2344
+ function Ys(e) {
2345
+ return {
2346
+ ...e.densityKgPerM3 !== void 0 ? { densityKgPerM3: e.densityKgPerM3 } : {},
2347
+ ...e.staticFriction !== void 0 ? { staticFriction: e.staticFriction } : {},
2348
+ ...e.dynamicFriction !== void 0 ? { dynamicFriction: e.dynamicFriction } : {},
2349
+ ...e.restitution !== void 0 ? { restitution: e.restitution } : {}
2350
+ };
2351
+ }
2352
+ function ze(e, t) {
2353
+ if (!t.startsWith("/"))
2354
+ return `${e}/${t}`.replaceAll("//", "/");
2355
+ if (t === e || t.startsWith(`${e}/`))
2356
+ return t;
2357
+ const s = t.split("/").filter(Boolean);
2358
+ return s.length <= 1 ? e : `${e}/${s.slice(1).join("/")}`;
2359
+ }
2360
+ function Ws(e, t, s, r) {
2361
+ var l, u;
2362
+ const o = t.interpretation.runtimeRevision, n = new Map(
2363
+ "variantSets" in o ? o.variantSets.map((c) => [c.name, c]) : []
2364
+ ), i = {};
2365
+ for (const [c, d] of Object.entries(s).sort(([a], [f]) => a.localeCompare(f))) {
2366
+ const a = e.variantSelections[c], f = n.get(c);
2367
+ if (!f) {
2368
+ r.push(v(
2369
+ "DELIVERY_VARIANT_SET_NOT_DECLARED",
2370
+ "info",
2371
+ `Asset ${t.label} does not declare ${c}; its source-authored default is preserved.`,
2372
+ e.nodeId,
2373
+ t.assetId
2374
+ ));
2375
+ continue;
2376
+ }
2377
+ if (!f.options.includes(d)) {
2378
+ r.push(v(
2379
+ "DELIVERY_PREFERRED_VARIANT_UNAVAILABLE",
2380
+ "info",
2381
+ `Asset ${t.label} has no ${c}=${d} branch; resolution follows the authored node selection or source-authored default.`,
2382
+ e.nodeId,
2383
+ t.assetId
2384
+ ));
2385
+ continue;
2386
+ }
2387
+ if (a !== void 0 && a !== d)
2388
+ return r.push(v(
2389
+ "DELIVERY_VARIANT_CONFLICT",
2390
+ "error",
2391
+ `Node ${e.label} selects ${c}=${a}, but profile prefers ${c}=${d}.`,
2392
+ e.nodeId,
2393
+ t.assetId
2394
+ )), { ok: !1 };
2395
+ const g = ((l = t.interpretation.variantPayloads[c]) == null ? void 0 : l[d]) ?? [];
2396
+ if (g.length === 0) {
2397
+ r.push(v(
2398
+ "DELIVERY_PREFERRED_VARIANT_UNAVAILABLE",
2399
+ "info",
2400
+ `Asset ${t.label} declares ${c}=${d}, but its variant payload is incomplete; resolution follows the authored node selection or source-authored default.`,
2401
+ e.nodeId,
2402
+ t.assetId
2403
+ ));
2404
+ continue;
2405
+ }
2406
+ const h = new Set(t.source.files.map((I) => T(I.locator))), p = g.filter((I) => !h.has(I));
2407
+ if (p.length > 0) {
2408
+ r.push(v(
2409
+ "DELIVERY_PREFERRED_VARIANT_UNAVAILABLE",
2410
+ "info",
2411
+ `Variant ${c}=${d} references missing payloads: ${p.join(", ")}; resolution follows the authored node selection or source-authored default.`,
2412
+ e.nodeId,
2413
+ t.assetId
2414
+ ));
2415
+ continue;
2416
+ }
2417
+ i[c] = d;
2418
+ }
2419
+ for (const [c, d] of Object.entries(e.variantSelections).sort(([a], [f]) => a.localeCompare(f))) {
2420
+ if (i[c] !== void 0) continue;
2421
+ const a = n.get(c);
2422
+ if (!a || !a.options.includes(d))
2423
+ return r.push(v(
2424
+ "DELIVERY_VARIANT_UNKNOWN",
2425
+ "error",
2426
+ `Node ${e.label} selects unknown variant ${c}=${d}.`,
2427
+ e.nodeId,
2428
+ t.assetId
2429
+ )), { ok: !1 };
2430
+ if (s[c] === d)
2431
+ return r.push(v(
2432
+ "DELIVERY_EXPLICIT_VARIANT_PAYLOAD_MISSING",
2433
+ "error",
2434
+ `Node ${e.label} explicitly selects ${c}=${d}, but its variant payload is incomplete.`,
2435
+ e.nodeId,
2436
+ t.assetId
2437
+ )), { ok: !1 };
2438
+ const f = ((u = t.interpretation.variantPayloads[c]) == null ? void 0 : u[d]) ?? [];
2439
+ if (f.length === 0)
2440
+ return r.push(v(
2441
+ "DELIVERY_EXPLICIT_VARIANT_PAYLOAD_MISSING",
2442
+ "error",
2443
+ `Node ${e.label} explicitly selects ${c}=${d}, but its variant payload is incomplete.`,
2444
+ e.nodeId,
2445
+ t.assetId
2446
+ )), { ok: !1 };
2447
+ const g = new Set(t.source.files.map((p) => T(p.locator))), h = f.filter((p) => !g.has(p));
2448
+ if (h.length > 0)
2449
+ return r.push(v(
2450
+ "DELIVERY_EXPLICIT_VARIANT_PAYLOAD_MISSING",
2451
+ "error",
2452
+ `Node ${e.label} explicitly selects ${c}=${d}, but its payloads are missing: ${h.join(", ")}.`,
2453
+ e.nodeId,
2454
+ t.assetId
2455
+ )), { ok: !1 };
2456
+ i[c] = d;
2457
+ }
2458
+ return { ok: !0, selections: Object.keys(i).length > 0 ? i : null };
2459
+ }
2460
+ function Gs(e, t) {
2461
+ const s = /* @__PURE__ */ new Map();
2462
+ for (const r of e.values()) {
2463
+ const o = r.outputPath.toLocaleLowerCase("en-US"), n = s.get(o);
2464
+ if (n === void 0) {
2465
+ s.set(o, r.outputPath);
2466
+ continue;
2467
+ }
2468
+ t.push(v(
2469
+ n === r.outputPath ? "USD_EXPORT_RESOURCE_PATH_DUPLICATE" : "USD_EXPORT_RESOURCE_PATH_CASE_CONFLICT",
2470
+ "error",
2471
+ n === r.outputPath ? `USD delivery repeats resource output path ${r.outputPath}.` : `USD delivery resource paths case-collide: ${n}, ${r.outputPath}.`
2472
+ ));
2473
+ }
2474
+ }
2475
+ function Hs(e, t, s) {
2476
+ const r = new Map(
2477
+ [...t.values()].map((n) => [
2478
+ n.outputPath.toLocaleLowerCase("en-US"),
2479
+ n
2480
+ ])
2481
+ ), o = [...e.values()].flatMap((n) => Xs(n)).sort((n, i) => w(n.outputPath, i.outputPath) || w(n.sourceSha256, i.sourceSha256) || w(n.resourceId, i.resourceId));
2482
+ for (const n of o) {
2483
+ const i = n.outputPath.toLocaleLowerCase("en-US"), l = r.get(i);
2484
+ if (l) {
2485
+ l.sourceSha256 !== n.sourceSha256 && s.push(v(
2486
+ "USD_EXPORT_RELATIVE_TEXTURE_ALIAS_CONFLICT",
2487
+ "error",
2488
+ `Texture alias ${n.outputPath} is required by different source bytes (${l.outputPath} and ${n.resourceId}).`,
2489
+ void 0,
2490
+ n.sourceRevisionId
2491
+ ));
2492
+ continue;
2493
+ }
2494
+ r.set(i, n), t.set(
2495
+ `relative-texture-alias\0${n.resourceId}`,
2496
+ n
2497
+ );
2498
+ }
2499
+ }
2500
+ function Xs(e) {
2501
+ if (e.source.entryLocator.kind !== "package-path") return [];
2502
+ const t = Z(e.source.entryLocator.path);
2503
+ if (!/\.(?:usd|usda|usdc|usdz)$/i.test(t)) return [];
2504
+ const s = t.lastIndexOf("/"), r = s >= 0 ? t.slice(0, s) : "", o = r ? `${r}/` : "", n = [];
2505
+ for (const i of e.source.files)
2506
+ if (!(i.locator.kind !== "package-path" || !Zs(i.locator.path)))
2507
+ try {
2508
+ const l = Z(i.locator.path);
2509
+ if (!l.startsWith(o)) continue;
2510
+ const u = Z(l.slice(o.length));
2511
+ n.push({
2512
+ resourceId: `relative-texture-alias/${e.source.sourceRevisionId}/${m(i.locator)}`,
2513
+ sourceRevisionId: e.source.sourceRevisionId,
2514
+ outputPath: u,
2515
+ sourceLocator: i.locator,
2516
+ sourceSha256: i.sha256,
2517
+ mediaType: i.mediaType,
2518
+ sourceByteSize: i.byteSize,
2519
+ outputTransform: be(u, i.mediaType)
2520
+ });
2521
+ } catch {
2522
+ }
2523
+ return n;
2524
+ }
2525
+ function Zs(e) {
2526
+ return /\.(?:png|jpe?g|webp|exr|ktx2)$/i.test(e);
2527
+ }
2528
+ function qs(e, t) {
2529
+ var o;
2530
+ const s = B(t);
2531
+ if (!/[^\x20-\x7e]/.test(s) || e.source.files.length !== 1) return s;
2532
+ const r = ((o = /(\.[A-Za-z0-9]+)$/.exec(s)) == null ? void 0 : o[1]) ?? "";
2533
+ return `entry-${e.source.sourceRevisionId.slice(0, 16)}${r.toLowerCase()}`;
2534
+ }
2535
+ function Js(e, t, s, r) {
2536
+ const o = e.deliveryLocks.find((i) => i.assetId === t.assetId && i.sourceRevisionId === t.source.sourceRevisionId && i.profileId === s && i.profileVersion === r), n = o ? t.deliveryArtifacts.find((i) => i.artifactId === o.artifactId) : t.deliveryArtifacts.find((i) => i.profileId === s && i.profileVersion === r);
2537
+ return n ? { artifact: n, ...o ? { lock: o } : {} } : null;
2538
+ }
2539
+ function Qs(e, t, s, r, o) {
2540
+ const n = `${t.source.sourceRevisionId}\0${m(s.locator)}\0`;
2541
+ e.has(n) || e.set(n, {
2542
+ resourceId: `${t.source.sourceRevisionId}/${m(s.locator)}`,
2543
+ sourceRevisionId: t.source.sourceRevisionId,
2544
+ outputPath: r,
2545
+ sourceLocator: s.locator,
2546
+ sourceSha256: s.sha256,
2547
+ mediaType: s.mediaType,
2548
+ sourceByteSize: s.byteSize,
2549
+ outputTransform: be(r, s.mediaType)
2550
+ });
2551
+ }
2552
+ function er(e, t, s, r, o) {
2553
+ const n = `${t.source.sourceRevisionId}\0${s.artifactId}\0${r.resourceId}\0${m(r.locator)}`;
2554
+ e.has(n) || e.set(n, {
2555
+ resourceId: `${s.artifactId}/${r.resourceId}`,
2556
+ sourceRevisionId: t.source.sourceRevisionId,
2557
+ artifactId: s.artifactId,
2558
+ outputPath: o,
2559
+ sourceLocator: r.locator,
2560
+ sourceSha256: r.sha256,
2561
+ mediaType: r.mediaType,
2562
+ sourceByteSize: r.byteSize,
2563
+ outputTransform: be(o, r.mediaType)
2564
+ });
2565
+ }
2566
+ function be(e, t) {
2567
+ return t.toLowerCase() === "model/vnd.usdz+zip" || e.toLowerCase().endsWith(".usdz") ? { kind: "canonicalize-usdz" } : { kind: "identity" };
2568
+ }
2569
+ function ce(e) {
2570
+ return {
2571
+ "xformOp:translate": {
2572
+ type: "double3",
2573
+ value: e.position.map((t) => M(t, 6))
2574
+ },
2575
+ "xformOp:orient": {
2576
+ type: "quatf",
2577
+ value: e.rotation.map((t) => M(t, 6))
2578
+ },
2579
+ "xformOp:scale": {
2580
+ type: "float3",
2581
+ value: e.scale.map((t) => M(t, 6))
2582
+ },
2583
+ xformOpOrder: {
2584
+ type: "token[]",
2585
+ value: ["xformOp:translate", "xformOp:orient", "xformOp:scale"]
2586
+ }
2587
+ };
2588
+ }
2589
+ function le(e) {
2590
+ const t = bt(e);
2591
+ return t.every((s) => Math.abs(s) <= 1e-12) ? {} : {
2592
+ contentAttributes: {
2593
+ "xformOp:translate": {
2594
+ type: "double3",
2595
+ value: t.map((s) => M(-s, 6))
2596
+ },
2597
+ xformOpOrder: {
2598
+ type: "token[]",
2599
+ value: ["xformOp:translate"]
2600
+ }
2601
+ }
2602
+ };
2603
+ }
2604
+ function Ie(e) {
2605
+ return [e, ...e.children.flatMap((t) => t.nodeType === "group" ? Ie(t) : [t])];
2606
+ }
2607
+ function v(e, t, s, r, o) {
2608
+ return {
2609
+ code: e,
2610
+ severity: t,
2611
+ message: s,
2612
+ ...r ? { nodeId: r } : {},
2613
+ ...o ? { assetId: o } : {}
2614
+ };
2615
+ }
2616
+ function tr(e) {
2617
+ return e.some((t) => t.severity === "error") ? "blocked" : e.some((t) => t.severity === "warning") ? "degraded" : "supported";
2618
+ }
2619
+ function sr(e) {
2620
+ return re(e, (t, s) => w(t.code, s.code) || w(t.nodeId ?? "", s.nodeId ?? "") || w(t.message, s.message));
2621
+ }
2622
+ function Tr(e) {
2623
+ return N(C(e.map((t) => ({
2624
+ path: t.path,
2625
+ sha256: t.sha256,
2626
+ byteSize: t.bytes.byteLength
2627
+ })).sort((t, s) => t.path.localeCompare(s.path))));
2628
+ }
2629
+ function Cr(e) {
2630
+ const t = {
2631
+ format: "sim-studio.usd-export-evidence@3",
2632
+ schemaVersion: 3,
2633
+ ...e
2634
+ };
2635
+ return {
2636
+ ...t,
2637
+ evidenceDigest: N(C(t))
2638
+ };
2639
+ }
2640
+ export {
2641
+ lr as $,
2642
+ _r as A,
2643
+ tt as B,
2644
+ Rt as C,
2645
+ Cr as D,
2646
+ Ps as E,
2647
+ Qt as F,
2648
+ U as G,
2649
+ wt as H,
2650
+ _ as I,
2651
+ Dr as J,
2652
+ Ir as K,
2653
+ Es as L,
2654
+ We as M,
2655
+ W as N,
2656
+ gr as O,
2657
+ Se as P,
2658
+ et as Q,
2659
+ ps as R,
2660
+ vr as S,
2661
+ yr as T,
2662
+ Er as U,
2663
+ rs as V,
2664
+ ns as W,
2665
+ dr as X,
2666
+ ur as Y,
2667
+ $t as Z,
2668
+ cr as _,
2669
+ fr as a,
2670
+ G as a0,
2671
+ fs as a1,
2672
+ us as a2,
2673
+ as as a3,
2674
+ ss as a4,
2675
+ rt as a5,
2676
+ st as a6,
2677
+ br as a7,
2678
+ ds as a8,
2679
+ Ct as a9,
2680
+ he as b,
2681
+ T as c,
2682
+ mr as d,
2683
+ hr as e,
2684
+ xs as f,
2685
+ Pr as g,
2686
+ Z as h,
2687
+ ve as i,
2688
+ wr as j,
2689
+ Sr as k,
2690
+ F as l,
2691
+ Ar as m,
2692
+ oe as n,
2693
+ ts as o,
2694
+ pr as p,
2695
+ Ds as q,
2696
+ ir as r,
2697
+ Pt as s,
2698
+ $r as t,
2699
+ Ls as u,
2700
+ Nr as v,
2701
+ ye as w,
2702
+ ot as x,
2703
+ Tr as y,
2704
+ Rr as z
2705
+ };