@nebula-spatial/studio 0.1.0 → 0.1.2

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 (50) hide show
  1. package/README.md +2 -0
  2. package/dist/assets/openusd_three_loader-DLiqJWUM.js +13769 -0
  3. package/dist/assets/usd-export-worker-BRxTLqer.js +182 -0
  4. package/dist/assets/usd-worker-DekqMsQv.js +1392 -0
  5. package/dist/{builders-BAXRR5o5.js → builders-lydx4-Rh.js} +1 -1
  6. package/dist/core/session-persistence-controller.d.ts +55 -0
  7. package/dist/doc/placement-policy.d.ts +4 -0
  8. package/dist/editor/editor.d.ts +3 -1
  9. package/dist/editor/index.d.ts +2 -0
  10. package/dist/editor/session-persistence.d.ts +54 -0
  11. package/dist/editor.js +727 -490
  12. package/dist/export-evidence-z2Ne7Trf.js +2387 -0
  13. package/dist/generalization.js +2 -2
  14. package/dist/index.d.ts +4 -2
  15. package/dist/index.js +314 -306
  16. package/dist/mjcf-visual-IOy-ucto.js +72 -0
  17. package/dist/mujoco-runtime-BYZnrvbR.js +467 -0
  18. package/dist/persist/indexeddb-store.d.ts +22 -2
  19. package/dist/persist/session.d.ts +22 -0
  20. package/dist/persist/snapshot.d.ts +24 -0
  21. package/dist/{physics-facts-tfQYyNTD.js → physics-facts-D-URIBrt.js} +8 -7
  22. package/dist/{placement-policy-DY_FNRDu.js → placement-policy-C6dV6Tf-.js} +161 -141
  23. package/dist/ports/persistence.d.ts +45 -1
  24. package/dist/project/contracts.d.ts +3 -0
  25. package/dist/remote-asset-resolver-D-UeyDMD.js +311 -0
  26. package/dist/{scene-graph-DBLKAhxa.js → scene-graph-DVOXjMmp.js} +2 -2
  27. package/dist/scene-session-PhoFXFCY.js +22006 -0
  28. package/dist/scene.js +2 -2
  29. package/dist/session-2bp8YOA4.js +963 -0
  30. package/dist/session-B3WbC7Y2.js +296 -0
  31. package/dist/session-B9kEf4xN.js +915 -0
  32. package/dist/session-DYThdzLZ.js +825 -0
  33. package/dist/studio/index.d.ts +5 -0
  34. package/dist/studio/indexeddb-persistence.d.ts +2 -0
  35. package/dist/studio/indexeddb-session-persistence.d.ts +11 -0
  36. package/dist/studio/scene-package-asset-sources.d.ts +14 -0
  37. package/dist/studio.js +1423 -1220
  38. package/dist/urdf-session-CRXL4bHf.js +1230 -0
  39. package/dist/usd-session-CTzInpNy.js +7385 -0
  40. package/dist/version.d.ts +1 -1
  41. package/dist/view/scene-session.d.ts +5 -1
  42. package/dist/wasm-module-DZn2AM1W.js +13 -0
  43. package/dist/xacro-IpPHTMYs.js +76 -0
  44. package/package.json +1 -1
  45. package/dist/asset-source-BExlEcRt.js +0 -444
  46. package/dist/assets/usd-export-worker-BsGubtAE.js +0 -1
  47. package/dist/editorial-BkAFWfbg.js +0 -83
  48. package/dist/export-evidence-B_0zRmb8.js +0 -5027
  49. package/dist/remote-asset-resolver-Cb8cfNmw.js +0 -136
  50. package/dist/scene-session-BV1HnxNh.js +0 -3506
package/dist/editor.js CHANGED
@@ -1,40 +1,39 @@
1
- var we = Object.defineProperty;
2
- var ye = (l, e, t) => e in l ? we(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var I = (l, e, t) => ye(l, typeof e != "symbol" ? e + "" : e, t);
4
- import { a as A, Y as ce, b as le, d as Ee, U as B, J as Ae, P as Te, L as Ne, I as Oe, q as Pe, f as _e, x as De, t as Re, V as Ve, e as Ce } from "./builders-BAXRR5o5.js";
5
- import { z as y, d as Q, a as q, V as X, s as x, E as Le, w as V, W as k, Z as de, k as xe, U as he, M as G, N as $, X as Me, _ as Fe, $ as Ue, a0 as j, a1 as Be, B as H, a2 as ue, a3 as ke } from "./scene-graph-DBLKAhxa.js";
6
- import { p as Ge, q as $e } from "./asset-source-BExlEcRt.js";
7
- import { v as je, D as We, n as Ye, q as pe, h as me } from "./placement-policy-DY_FNRDu.js";
8
- import { e as W, g as Ke, f as ze } from "./physics-facts-tfQYyNTD.js";
9
- import { c as Xe, t as He } from "./scene-session-BV1HnxNh.js";
10
- import { S as ge, i as Ze } from "./remote-asset-resolver-Cb8cfNmw.js";
11
- import { c as Je, a as Qe } from "./editorial-BkAFWfbg.js";
12
- const M = (l) => l !== null && typeof l == "object" && !Array.isArray(l) ? l : null, Y = (l) => Array.isArray(l) ? l.map(M).filter((e) => e !== null) : null, qe = (l, e) => Array.isArray(l) && l.length === e && l.every((t) => typeof t == "number" && Number.isFinite(t)), et = (l) => typeof l == "number" && Number.isFinite(l) && l > 0;
13
- function E(l, e, t, s, o = !1) {
14
- return { present: l, available: e, canVisualize: o, source: t, reason: s };
1
+ var Pe = Object.defineProperty;
2
+ var Oe = (r, e, t) => e in r ? Pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var I = (r, e, t) => Oe(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { a as T, Y as me, b as fe, d as _e, Z as Re, U as j, J as De, P as Ve, L as Ce, I as Le, q as Me, f as xe, x as Fe, t as Be, V as Ue, e as ke } from "./builders-lydx4-Rh.js";
5
+ import { z as w, d as ie, a as ne, V as X, s as x, E as Ge, w as R, W as F, Z, U as J, _ as ge, M as B, k as ve, N as W, X as $e, $ as je, a0 as K, a1 as We, B as Q, a2 as Se, a3 as Ke } from "./scene-graph-DVOXjMmp.js";
6
+ import { A as Ye, J as ze, q as He, c as Xe, k as we, K as Ze } from "./session-B9kEf4xN.js";
7
+ import { v as Je, D as Qe, n as qe, q, r as ee, h as U, t as Ie } from "./placement-policy-C6dV6Tf-.js";
8
+ import { e as C, g as et, f as tt } from "./physics-facts-D-URIBrt.js";
9
+ import { c as st, t as ot } from "./scene-session-PhoFXFCY.js";
10
+ import { S as ye, i as it, a as nt } from "./remote-asset-resolver-D-UeyDMD.js";
11
+ const k = (r) => r !== null && typeof r == "object" && !Array.isArray(r) ? r : null, Y = (r) => Array.isArray(r) ? r.map(k).filter((e) => e !== null) : null, rt = (r, e) => Array.isArray(r) && r.length === e && r.every((t) => typeof t == "number" && Number.isFinite(t)), at = (r) => typeof r == "number" && Number.isFinite(r) && r > 0;
12
+ function A(r, e, t, s, o = !1) {
13
+ return { present: r, available: e, canVisualize: o, source: t, reason: s };
15
14
  }
16
- function K(l, e, t, s = !1) {
17
- if (!l) return null;
18
- const n = l.map((a) => {
15
+ function z(r, e, t, s = !1) {
16
+ if (!r) return null;
17
+ const n = r.map((l) => {
19
18
  var i;
20
- return t === "authored" ? (i = M(a.mass)) == null ? void 0 : i[e] : a[e];
21
- }).filter((a) => a != null);
19
+ return t === "authored" ? (i = k(l.mass)) == null ? void 0 : i[e] : l[e];
20
+ }).filter((l) => l != null);
22
21
  if (!n.length) return null;
23
- const d = n.every((a) => qe(a, 3) && (e === "centerOfMass" || a.every((i) => i > 0)));
24
- return E(!0, d, t, d ? s ? "Finite body data is available and the mounted runtime can display its inspection guide." : "Finite body data is available; the mounted runtime does not expose a viewport overlay for it." : "The feature is declared, but its values are incomplete or invalid.", d && s);
22
+ const h = n.every((l) => rt(l, 3) && (e === "centerOfMass" || l.every((i) => i > 0)));
23
+ return A(!0, h, t, h ? s ? "Finite body data is available and the mounted runtime can display its inspection guide." : "Finite body data is available; the mounted runtime does not expose a viewport overlay for it." : "The feature is declared, but its values are incomplete or invalid.", h && s);
25
24
  }
26
- function tt(l, e, t) {
27
- var se, oe, ie, ne, re;
28
- const s = y(l.root, e);
25
+ function ct(r, e, t) {
26
+ var ce, le, de, he, ue;
27
+ const s = w(r.root, e);
29
28
  if (!s) return null;
30
- const o = s.nodeType === "asset" ? l.assets.find((w) => w.revisionId === s.assetRevisionId) : void 0, n = s.nodeType === "visual" ? l.visualAssets.find((w) => w.visualRevisionId === s.visualRevisionId) : void 0, d = s.nodeType !== "asset" || (o == null ? void 0 : o.fileKind) === "glb" || (o == null ? void 0 : o.capabilities.physics) === "none", a = M((se = t == null ? void 0 : t.visualDiagnostics) == null ? void 0 : se.usd), i = M(a == null ? void 0 : a.stage), c = M(a == null ? void 0 : a.physics), h = Y(c == null ? void 0 : c.colliders), u = Y(c == null ? void 0 : c.rigidBodies), p = Y(c == null ? void 0 : c.joints), v = t != null && t.physicsRuntime ? t.physicsRuntime.bodies.filter((w) => {
31
- var ae;
32
- return ((ae = t.physicsRuntime) == null ? void 0 : ae.worldKind) !== "scene-unified" || w.instanceId === e;
33
- }) : null, S = Y((oe = t == null ? void 0 : t.physicsProperties) == null ? void 0 : oe.bodies), r = v != null && v.length ? v.map((w) => ({ centerOfMass: w.centerOfMass, inertia: w.inertia })) : S, f = t == null ? void 0 : t.inspectionOverlays, m = (w) => d || c ? E(!1, !1, "none", `${w} is not present in this node's inspected data.`) : E(null, !1, "unknown", `${w} has not been established; source inspection is unavailable.`), T = ((ie = t == null ? void 0 : t.capabilities) == null ? void 0 : ie.canToggleCollision) === !0 ? E(!0, !0, "runtime", "The mounted instance supports collision geometry display.", !0) : h ? h.length ? E(!0, !1, "authored", "Collision geometry is authored, but the mounted instance cannot currently display it.") : E(!1, !1, "none", "The inspected asset has no authored collision geometry.") : o != null && o.capabilities.colliderGeometry ? E(!0, !1, "authored", "The asset declares collision geometry; its runtime display is not ready.") : m("Collision geometry"), _ = typeof (i == null ? void 0 : i.upAxis) == "string" ? i.upAxis.toUpperCase() : null, D = _ === "X" || _ === "Y" || _ === "Z" ? _ : null, N = D ?? (n ? n.upAxis === "y-down" ? "-Y" : n.upAxis.toUpperCase() : null) ?? ((o == null ? void 0 : o.fileKind) === "glb" ? "Y" : null), F = et(i == null ? void 0 : i.metersPerUnit) ? i.metersPerUnit : (o == null ? void 0 : o.fileKind) === "glb" || (n == null ? void 0 : n.format) === "glb" || (n == null ? void 0 : n.format) === "gltf" ? 1 : null, R = D || n ? "authored" : (o == null ? void 0 : o.fileKind) === "glb" ? "format" : "unknown", z = {
34
- ...E(
29
+ const o = s.nodeType === "asset" ? r.assets.find((E) => E.revisionId === s.assetRevisionId) : void 0, n = s.nodeType === "visual" ? r.visualAssets.find((E) => E.visualRevisionId === s.visualRevisionId) : void 0, h = s.nodeType !== "asset" || (o == null ? void 0 : o.fileKind) === "glb" || (o == null ? void 0 : o.capabilities.physics) === "none", l = k((ce = t == null ? void 0 : t.visualDiagnostics) == null ? void 0 : ce.usd), i = k(l == null ? void 0 : l.stage), a = k(l == null ? void 0 : l.physics), d = Y(a == null ? void 0 : a.colliders), u = Y(a == null ? void 0 : a.rigidBodies), m = Y(a == null ? void 0 : a.joints), v = t != null && t.physicsRuntime ? t.physicsRuntime.bodies.filter((E) => {
30
+ var pe;
31
+ return ((pe = t.physicsRuntime) == null ? void 0 : pe.worldKind) !== "scene-unified" || E.instanceId === e;
32
+ }) : null, S = Y((le = t == null ? void 0 : t.physicsProperties) == null ? void 0 : le.bodies), c = v != null && v.length ? v.map((E) => ({ centerOfMass: E.centerOfMass, inertia: E.inertia })) : S, f = t == null ? void 0 : t.inspectionOverlays, p = (E) => h || a ? A(!1, !1, "none", `${E} is not present in this node's inspected data.`) : A(null, !1, "unknown", `${E} has not been established; source inspection is unavailable.`), y = ((de = t == null ? void 0 : t.capabilities) == null ? void 0 : de.canToggleCollision) === !0 ? A(!0, !0, "runtime", "The mounted instance supports collision geometry display.", !0) : d ? d.length ? A(!0, !1, "authored", "Collision geometry is authored, but the mounted instance cannot currently display it.") : A(!1, !1, "none", "The inspected asset has no authored collision geometry.") : o != null && o.capabilities.colliderGeometry ? A(!0, !1, "authored", "The asset declares collision geometry; its runtime display is not ready.") : p("Collision geometry"), O = typeof (i == null ? void 0 : i.upAxis) == "string" ? i.upAxis.toUpperCase() : null, D = O === "X" || O === "Y" || O === "Z" ? O : null, N = D ?? (n ? n.upAxis === "y-down" ? "-Y" : n.upAxis.toUpperCase() : null) ?? ((o == null ? void 0 : o.fileKind) === "glb" ? "Y" : null), G = at(i == null ? void 0 : i.metersPerUnit) ? i.metersPerUnit : (o == null ? void 0 : o.fileKind) === "glb" || (n == null ? void 0 : n.format) === "glb" || (n == null ? void 0 : n.format) === "gltf" ? 1 : null, V = D || n ? "authored" : (o == null ? void 0 : o.fileKind) === "glb" ? "format" : "unknown", H = {
33
+ ...A(
35
34
  N ? !0 : s.nodeType === "asset" ? null : !0,
36
35
  !0,
37
- R,
36
+ V,
38
37
  N ? "Source axis and the scene coordinate convention are available. Scene transforms use the scene convention." : "The scene coordinate convention is available; the source asset axis has not been established.",
39
38
  // Coordinate axes are drawn by Sim Studio's authoring overlay rather
40
39
  // than by a format/runtime inspection session. They are therefore
@@ -42,44 +41,44 @@ function tt(l, e, t) {
42
41
  // a pre-mount request is reported as `pending` by the session API.
43
42
  s.nodeType !== "domain"
44
43
  ),
45
- scene: l.coordinateSystem,
44
+ scene: r.coordinateSystem,
46
45
  sourceUpAxis: N,
47
- sourceMetersPerUnit: F
48
- }, C = (p == null ? void 0 : p.filter((w) => w.axis !== void 0 && w.axis !== null)) ?? [], O = C.length ? E(
46
+ sourceMetersPerUnit: G
47
+ }, L = (m == null ? void 0 : m.filter((E) => E.axis !== void 0 && E.axis !== null)) ?? [], P = L.length ? A(
49
48
  !0,
50
- C.every((w) => typeof w.axis == "string" && /^[XYZ]$/i.test(w.axis)),
49
+ L.every((E) => typeof E.axis == "string" && /^[XYZ]$/i.test(E.axis)),
51
50
  "authored",
52
51
  (f == null ? void 0 : f.jointAxis) === !0 ? "Joint axis declarations and the mounted runtime inspection guide are available." : "Joint axis declarations can be inspected; the mounted runtime does not expose a joint-axis viewport overlay.",
53
52
  (f == null ? void 0 : f.jointAxis) === !0
54
- ) : (f == null ? void 0 : f.jointAxis) === !0 ? E(!0, !0, "runtime", "The mounted URDF inspection runtime can display joint-axis guides.", !0) : m("Joint axes"), U = K(r, "centerOfMass", "runtime", (f == null ? void 0 : f.centerOfMass) === !0) ?? K(u, "centerOfMass", "authored", (f == null ? void 0 : f.centerOfMass) === !0) ?? ((f == null ? void 0 : f.centerOfMass) === !0 ? E(!0, !0, "runtime", "The mounted URDF inspection runtime can display center-of-mass guides.", !0) : null) ?? m("Center of mass"), Ie = K(r, "inertia", "runtime", (f == null ? void 0 : f.inertia) === !0) ?? K(u, "diagonalInertia", "authored", (f == null ? void 0 : f.inertia) === !0) ?? ((f == null ? void 0 : f.inertia) === !0 ? E(!0, !0, "runtime", "The mounted URDF inspection runtime can display inertia guides.", !0) : null) ?? m("Inertia"), P = t == null ? void 0 : t.physics, L = P == null ? void 0 : P.status, Se = (o == null ? void 0 : o.capabilities.physics) === "authored", te = ((ne = t == null ? void 0 : t.capabilities) == null ? void 0 : ne.hasPhysics) === !0 || Se, be = L === "unavailable" ? E(te ? !0 : null, !1, "runtime", (P == null ? void 0 : P.status) === "unavailable" ? P.issue.message : "Physics runtime is unavailable.") : L === "initializing" ? E(!0, !1, "runtime", "The physics runtime is still initializing.") : L === "not-authored" ? E(!1, !1, "none", "The mounted instance has no authored simulation physics.") : L === "ready" || L === "available" || ((re = t == null ? void 0 : t.capabilities) == null ? void 0 : re.hasPhysics) === !0 && t.capabilities.canPlay === !0 ? E(!0, !0, "runtime", "The mounted instance supports physics simulation.") : te ? E(!0, !1, "authored", "Physics is authored, but the runtime is not ready.") : m("Simulation physics");
55
- return Q(q({ nodeId: e, nodeType: s.nodeType, collider: T, coordinateSystem: z, jointAxes: O, centerOfMass: U, inertia: Ie, simulation: be }));
53
+ ) : (f == null ? void 0 : f.jointAxis) === !0 ? A(!0, !0, "runtime", "The mounted URDF inspection runtime can display joint-axis guides.", !0) : p("Joint axes"), $ = z(c, "centerOfMass", "runtime", (f == null ? void 0 : f.centerOfMass) === !0) ?? z(u, "centerOfMass", "authored", (f == null ? void 0 : f.centerOfMass) === !0) ?? ((f == null ? void 0 : f.centerOfMass) === !0 ? A(!0, !0, "runtime", "The mounted URDF inspection runtime can display center-of-mass guides.", !0) : null) ?? p("Center of mass"), Ae = z(c, "inertia", "runtime", (f == null ? void 0 : f.inertia) === !0) ?? z(u, "diagonalInertia", "authored", (f == null ? void 0 : f.inertia) === !0) ?? ((f == null ? void 0 : f.inertia) === !0 ? A(!0, !0, "runtime", "The mounted URDF inspection runtime can display inertia guides.", !0) : null) ?? p("Inertia"), _ = t == null ? void 0 : t.physics, M = _ == null ? void 0 : _.status, Te = (o == null ? void 0 : o.capabilities.physics) === "authored", ae = ((he = t == null ? void 0 : t.capabilities) == null ? void 0 : he.hasPhysics) === !0 || Te, Ne = M === "unavailable" ? A(ae ? !0 : null, !1, "runtime", (_ == null ? void 0 : _.status) === "unavailable" ? _.issue.message : "Physics runtime is unavailable.") : M === "initializing" ? A(!0, !1, "runtime", "The physics runtime is still initializing.") : M === "not-authored" ? A(!1, !1, "none", "The mounted instance has no authored simulation physics.") : M === "ready" || M === "available" || ((ue = t == null ? void 0 : t.capabilities) == null ? void 0 : ue.hasPhysics) === !0 && t.capabilities.canPlay === !0 ? A(!0, !0, "runtime", "The mounted instance supports physics simulation.") : ae ? A(!0, !1, "authored", "Physics is authored, but the runtime is not ready.") : p("Simulation physics");
54
+ return ie(ne({ nodeId: e, nodeType: s.nodeType, collider: y, coordinateSystem: H, jointAxes: P, centerOfMass: $, inertia: Ae, simulation: Ne }));
56
55
  }
57
- async function ve(l, e, t = {}) {
58
- var d;
59
- if (l.kind === "local-package")
56
+ async function Ee(r, e, t = {}) {
57
+ var h;
58
+ if (r.kind === "local-package")
60
59
  return {
61
60
  source: {
62
61
  kind: "files",
63
- entry: l.entryPath,
64
- files: l.files.map((a) => {
65
- const i = Ge(a.locator);
62
+ entry: r.entryPath,
63
+ files: r.files.map((l) => {
64
+ const i = Ye(l.locator);
66
65
  if (!i) throw new Error("Local asset source contains a remote resource.");
67
- return { path: i, file: a.blob };
66
+ return { path: i, file: l.blob };
68
67
  })
69
68
  },
70
- filename: l.entryPath,
69
+ filename: r.entryPath,
71
70
  ...e.length ? { openOptions: { usdVariantSelections: e } } : {}
72
71
  };
73
- const s = t.remoteResolver ?? new ge(l), o = await s.entryBlob(t.signal), n = new URL(l.entryUrl).pathname.split("/").pop() || "root.usda";
72
+ const s = t.remoteResolver ?? new ye(r), o = await s.entryBlob(t.signal), n = new URL(r.entryUrl).pathname.split("/").pop() || "root.usda";
74
73
  return {
75
74
  source: {
76
75
  kind: "remote-entry",
77
76
  entryPath: n,
78
- entryUrl: l.entryUrl,
77
+ entryUrl: r.entryUrl,
79
78
  entry: o,
80
- ...(d = t.resourcePaths) != null && d.length ? { resourcePaths: [...new Set(t.resourcePaths)] } : {},
79
+ ...(h = t.resourcePaths) != null && h.length ? { resourcePaths: [...new Set(t.resourcePaths)] } : {},
81
80
  resourceResolver: {
82
- resolve: (a, i) => s.resolve(a, i)
81
+ resolve: (l, i) => s.resolve(l, i)
83
82
  }
84
83
  },
85
84
  filename: n,
@@ -89,8 +88,8 @@ async function ve(l, e, t = {}) {
89
88
  }
90
89
  };
91
90
  }
92
- async function st(l, e, t, s = {}) {
93
- const o = await ve(l, [], s);
91
+ async function lt(r, e, t, s = {}) {
92
+ const o = await Ee(r, [], s);
94
93
  return {
95
94
  ...o,
96
95
  openOptions: {
@@ -106,23 +105,23 @@ async function st(l, e, t, s = {}) {
106
105
  }
107
106
  };
108
107
  }
109
- function ot(l, e) {
110
- const t = l.ownerDocument;
111
- if (!(t != null && t.addEventListener) || !l.addEventListener) return () => {
108
+ function dt(r, e) {
109
+ const t = r.ownerDocument;
110
+ if (!(t != null && t.addEventListener) || !r.addEventListener) return () => {
112
111
  };
113
- const s = l.getAttribute("tabindex");
114
- s === null && (l.tabIndex = 0);
115
- const o = l.closest("[data-viewer-layout-host]") ?? l.parentElement ?? l, n = (a) => {
116
- const i = a.composedPath()[0], c = typeof (i == null ? void 0 : i.closest) == "function" && i.closest('input,textarea,select,button,a[href],[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="button"],[data-studio-ui-plugin],dialog');
117
- i === l || i && !c && o.contains(i) ? l.focus({ preventScroll: !0 }) : l.getRootNode().activeElement === l && l.blur();
118
- }, d = (a) => {
119
- const i = l.getRootNode();
120
- if (a.defaultPrevented || a.isComposing || i.activeElement !== l) return;
121
- const c = a.composedPath();
122
- !c.includes(l) || c.some((h) => h === l || typeof h.matches != "function" ? !1 : h.matches('input,textarea,select,button,a[href],[contenteditable]:not([contenteditable="false"]),[role="textbox"],[data-studio-ui-plugin],dialog')) || e(a) && (a.preventDefault(), a.stopPropagation());
112
+ const s = r.getAttribute("tabindex");
113
+ s === null && (r.tabIndex = 0);
114
+ const o = r.closest("[data-viewer-layout-host]") ?? r.parentElement ?? r, n = (l) => {
115
+ const i = l.composedPath()[0], a = typeof (i == null ? void 0 : i.closest) == "function" && i.closest('input,textarea,select,button,a[href],[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="button"],[data-studio-ui-plugin],dialog');
116
+ i === r || i && !a && o.contains(i) ? r.focus({ preventScroll: !0 }) : r.getRootNode().activeElement === r && r.blur();
117
+ }, h = (l) => {
118
+ const i = r.getRootNode();
119
+ if (l.defaultPrevented || l.isComposing || i.activeElement !== r) return;
120
+ const a = l.composedPath();
121
+ !a.includes(r) || a.some((d) => d === r || typeof d.matches != "function" ? !1 : d.matches('input,textarea,select,button,a[href],[contenteditable]:not([contenteditable="false"]),[role="textbox"],[data-studio-ui-plugin],dialog')) || e(l) && (l.preventDefault(), l.stopPropagation());
123
122
  };
124
- return t.addEventListener("pointerdown", n, !0), t.addEventListener("keydown", d), () => {
125
- t.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown", d), s === null && l.getAttribute("tabindex") === "0" && l.removeAttribute("tabindex");
123
+ return t.addEventListener("pointerdown", n, !0), t.addEventListener("keydown", h), () => {
124
+ t.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown", h), s === null && r.getAttribute("tabindex") === "0" && r.removeAttribute("tabindex");
126
125
  };
127
126
  }
128
127
  class g extends Error {
@@ -130,7 +129,7 @@ class g extends Error {
130
129
  super(t), this.code = e, this.name = "StudioEditorError";
131
130
  }
132
131
  }
133
- class it {
132
+ class ht {
134
133
  constructor(e, t = {}) {
135
134
  I(this, "host");
136
135
  I(this, "session");
@@ -153,14 +152,14 @@ class it {
153
152
  I(this, "actionControllers", /* @__PURE__ */ new Map());
154
153
  I(this, "remoteResolvers", /* @__PURE__ */ new Map());
155
154
  I(this, "coreActionBusy", /* @__PURE__ */ new Set());
156
- I(this, "sceneSessionId", `session_${A()}`);
155
+ I(this, "sceneSessionId", `session_${T()}`);
157
156
  I(this, "selectionVersion", 0);
158
157
  I(this, "contextVersion", 0);
159
158
  I(this, "overlaySequence", 0);
160
159
  I(this, "mode", "translate");
161
160
  I(this, "snap", !1);
162
161
  I(this, "transactionBounds", /* @__PURE__ */ new Map());
163
- I(this, "placementPolicy", We);
162
+ I(this, "placementPolicy", Qe);
164
163
  I(this, "transformSpace", "world");
165
164
  I(this, "actionVisibility", /* @__PURE__ */ new Map());
166
165
  I(this, "transformOrigins", /* @__PURE__ */ new Map());
@@ -178,7 +177,7 @@ class it {
178
177
  I(this, "disposal", null);
179
178
  I(this, "syncEpoch", 0);
180
179
  I(this, "releaseShortcuts");
181
- var o, n, d, a;
180
+ var o, n, h, l;
182
181
  this.options = e, this.host = e.host, this.writePolicy = {
183
182
  check: (i) => {
184
183
  var u;
@@ -214,162 +213,166 @@ class it {
214
213
  code: "GESTURE_ACTIVE",
215
214
  message: "Finish or cancel the active gesture before writing the scene."
216
215
  };
217
- const c = i.kind === "editorial" ? void 0 : i.targetNodeIds.find((p) => X(
216
+ const a = i.kind === "editorial" ? void 0 : i.targetNodeIds.find((m) => X(
218
217
  this.host.document.root,
219
- p,
218
+ m,
220
219
  this.host.getSnapshot().editorial
221
220
  ));
222
- if (c)
221
+ if (a)
223
222
  return {
224
223
  allowed: !1,
225
224
  code: "NODE_LOCKED",
226
- message: `Scene node is locked: ${c}`
225
+ message: `Scene node is locked: ${a}`
227
226
  };
228
- const h = i.nextDocument;
229
- if (h)
227
+ const d = i.nextDocument;
228
+ if (d)
230
229
  try {
231
- this.assertProjectionRepresentable(h.root);
232
- } catch (p) {
233
- if (p instanceof g)
234
- return { allowed: !1, code: p.code, message: p.message };
235
- throw p;
230
+ this.assertProjectionRepresentable(d.root);
231
+ } catch (m) {
232
+ if (m instanceof g)
233
+ return { allowed: !1, code: m.code, message: m.message };
234
+ throw m;
236
235
  }
237
- if (h && this.placementPolicy.preventOverlap) {
238
- const p = je(
236
+ if (d && this.placementPolicy.preventOverlap) {
237
+ const m = Je(
239
238
  this.host.document,
240
- h,
239
+ d,
241
240
  this.placementPolicy,
242
241
  (v) => {
243
- var m;
242
+ var p, b, y;
244
243
  const S = this.transactionBounds.get(v.nodeId);
245
244
  if (S) return S;
246
- const r = y(this.host.document.root, v.nodeId);
247
- return !r || r.nodeType !== v.nodeType || v.nodeType === "asset" && (r.nodeType !== "asset" || v.assetRevisionId !== r.assetRevisionId) || v.nodeType === "visual" && (r.nodeType !== "visual" || v.visualRevisionId !== r.visualRevisionId) || !x(
248
- W(this.host.document, r),
249
- W(h, v)
250
- ) ? null : ((m = this.session.getNodeFrame(v.nodeId)) == null ? void 0 : m.localBounds) ?? null;
245
+ if (v.nodeType === "asset") {
246
+ const O = (b = (p = this.session).getMeasuredAssetBounds) == null ? void 0 : b.call(p, v.assetRevisionId);
247
+ if (O) return O;
248
+ }
249
+ const c = w(this.host.document.root, v.nodeId);
250
+ return !c || c.nodeType !== v.nodeType || v.nodeType === "asset" && (c.nodeType !== "asset" || v.assetRevisionId !== c.assetRevisionId) || v.nodeType === "visual" && (c.nodeType !== "visual" || v.visualRevisionId !== c.visualRevisionId) || !x(
251
+ C(this.host.document, c),
252
+ C(d, v)
253
+ ) ? null : ((y = this.session.getNodeFrame(v.nodeId)) == null ? void 0 : y.localBounds) ?? null;
251
254
  },
252
255
  new Set(i.allowOverlapNodeIds ?? []),
253
256
  i.supportContacts
254
257
  );
255
- if (p.length)
258
+ if (m.length)
256
259
  return {
257
260
  allowed: !1,
258
- code: p[0].code,
259
- message: p.map((v) => v.message).join("; ")
261
+ code: m[0].code,
262
+ message: m.map((v) => v.message).join("; ")
260
263
  };
261
264
  }
262
265
  return { allowed: !0 };
263
266
  }
264
- }, this.releaseWritePolicy = Ze(this.host, this.writePolicy), this.installBuiltInActions();
267
+ }, this.releaseWritePolicy = it(this.host, this.writePolicy), this.installBuiltInActions();
265
268
  const s = e.sessionOptions ?? {};
266
- this.session = (t.createSession ?? Xe)({
269
+ this.session = (t.createSession ?? st)({
267
270
  ...s,
268
271
  viewport: e.viewport,
269
272
  canvas: e.canvas,
270
- resolveSource: e.resolveSource ?? (async (i, c, h, u) => {
273
+ resolveSource: e.resolveSource ?? (async (i, a, d, u) => {
271
274
  u == null || u.stage("resolving-source", "正在解析资产来源...");
272
- const p = await this.host.resolveAssetSource(i, { signal: h }), v = Object.entries((c == null ? void 0 : c.variantSelections) ?? {}).map(([f, m]) => ({ primPath: "/", setName: f, selection: m }));
273
- if (!p) return null;
275
+ const m = await this.host.resolveAssetSource(i, { signal: d }), v = Object.entries((a == null ? void 0 : a.variantSelections) ?? {}).map(([f, p]) => ({ primPath: "/", setName: f, selection: p }));
276
+ if (!m) return null;
274
277
  u == null || u.stage("downloading", "正在读取资产入口...");
275
- const S = this.remoteResourcePathsFor(i), r = await ve(p, v, {
276
- ...h ? { signal: h } : {},
278
+ const S = this.remoteResourcePathsFor(i), c = await Ee(m, v, {
279
+ ...d ? { signal: d } : {},
277
280
  ...S.length ? { resourcePaths: S } : {},
278
- ...p.kind === "remote-entry" ? { remoteResolver: this.remoteResolverFor(p) } : {}
281
+ ...m.kind === "remote-entry" ? { remoteResolver: this.remoteResolverFor(m) } : {}
279
282
  });
280
- return u == null || u.stage("validating", "正在校验资产入口..."), r;
283
+ return u == null || u.stage("validating", "正在校验资产入口..."), c;
281
284
  }),
282
- resolveVisualSource: e.resolveVisualSource ?? (async (i, c, h, u) => {
285
+ resolveVisualSource: e.resolveVisualSource ?? (async (i, a, d, u) => {
283
286
  u == null || u.stage("resolving-source", "正在解析视觉资产来源...");
284
- const [p, v] = await Promise.all([
285
- this.host.resolveVisualAssetSource(i, { signal: h }),
286
- Promise.resolve(Le(this.host.document, i))
287
+ const [m, v] = await Promise.all([
288
+ this.host.resolveVisualAssetSource(i, { signal: d }),
289
+ Promise.resolve(Ge(this.host.document, i))
287
290
  ]);
288
- if (!p || !v) return null;
291
+ if (!m || !v) return null;
289
292
  u == null || u.stage("downloading", "正在读取视觉资产入口...");
290
- const S = await st(p, v, c, {
291
- ...h ? { signal: h } : {},
292
- ...p.kind === "remote-entry" ? { remoteResolver: this.remoteResolverFor(p) } : {}
293
+ const S = await lt(m, v, a, {
294
+ ...d ? { signal: d } : {},
295
+ ...m.kind === "remote-entry" ? { remoteResolver: this.remoteResolverFor(m) } : {}
293
296
  });
294
297
  return u == null || u.stage("validating", "正在校验视觉资产入口..."), S;
295
298
  }),
296
- onPick: (i, c, h) => {
299
+ onPick: (i, a, d) => {
297
300
  var u;
298
301
  if (!this.disposed && !this.previewDocument && (!this.previewMode || this.previewSelection === "inspect")) {
299
- const p = this.host.getSelection(), v = i === null ? [] : c ? p.instanceIds.includes(i) ? p.instanceIds.filter((S) => S !== i) : [...p.instanceIds, i] : [i];
300
- this.select(v, i && v.includes(i) ? i : void 0), (u = s.onPick) == null || u.call(s, i, c, h);
302
+ const m = this.host.getSelection(), v = i === null ? [] : a ? m.instanceIds.includes(i) ? m.instanceIds.filter((S) => S !== i) : [...m.instanceIds, i] : [i];
303
+ this.select(v, i && v.includes(i) ? i : void 0), (u = s.onPick) == null || u.call(s, i, a, d);
301
304
  }
302
305
  },
303
- onBoxSelect: (i, c) => {
304
- var h;
305
- this.disposed || !this.previewDocument && (!this.previewMode || this.previewSelection === "inspect") && (this.select(c ? [...this.host.getSelection().instanceIds, ...i] : i), (h = s.onBoxSelect) == null || h.call(s, i, c));
306
+ onBoxSelect: (i, a) => {
307
+ var d;
308
+ this.disposed || !this.previewDocument && (!this.previewMode || this.previewSelection === "inspect") && (this.select(a ? [...this.host.getSelection().instanceIds, ...i] : i), (d = s.onBoxSelect) == null || d.call(s, i, a));
306
309
  },
307
- onTransform: (i, c, h) => {
310
+ onTransform: (i, a, d) => {
308
311
  var u;
309
312
  if (!this.disposed)
310
313
  try {
311
- this.commitTransform(i, c, !0, h), (u = s.onTransform) == null || u.call(s, i, c);
312
- } catch (p) {
313
- this.report(p), this.sync().catch((v) => this.report(v));
314
+ this.commitTransform(i, a, !0, d), (u = s.onTransform) == null || u.call(s, i, a);
315
+ } catch (m) {
316
+ this.report(m), this.sync().catch((v) => this.report(v));
314
317
  }
315
318
  },
316
- onNodeOriginChange: (i, c) => {
317
- var h;
319
+ onNodeOriginChange: (i, a) => {
320
+ var d;
318
321
  if (!this.disposed)
319
322
  try {
320
- this.setNodeOrigin(i, { local: c }), (h = s.onNodeOriginChange) == null || h.call(s, i, c);
323
+ this.setNodeOrigin(i, { local: a }), (d = s.onNodeOriginChange) == null || d.call(s, i, a);
321
324
  } catch (u) {
322
- this.report(u), this.sync().catch((p) => this.report(p));
325
+ this.report(u), this.sync().catch((m) => this.report(m));
323
326
  }
324
327
  },
325
- onRegionTransform: (i, c) => {
326
- var h;
327
- this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (h = s.onRegionTransform) == null || h.call(s, i, c);
328
+ onRegionTransform: (i, a) => {
329
+ var d;
330
+ this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (d = s.onRegionTransform) == null || d.call(s, i, a);
328
331
  },
329
- onRegionShapeChange: (i, c) => {
330
- var h;
331
- this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (h = s.onRegionShapeChange) == null || h.call(s, i, c);
332
+ onRegionShapeChange: (i, a) => {
333
+ var d;
334
+ this.disposed || this.previewDocument || this.previewMode || !this.editingEnabled || (d = s.onRegionShapeChange) == null || d.call(s, i, a);
332
335
  },
333
336
  onStatus: (i) => {
334
- var c;
335
- this.disposed || (this.sceneStatus = i, this.contextVersion += 1, this.emit("status.change"), this.emit("toolbar.change"), (c = s.onStatus) == null || c.call(s, i));
337
+ var a;
338
+ this.disposed || (this.sceneStatus = i, this.contextVersion += 1, this.emit("status.change"), this.emit("toolbar.change"), (a = s.onStatus) == null || a.call(s, i));
336
339
  },
337
340
  onAssetLoadStatus: (i) => {
338
- var c;
339
- this.disposed || (c = s.onAssetLoadStatus) == null || c.call(s, i);
341
+ var a;
342
+ this.disposed || (a = s.onAssetLoadStatus) == null || a.call(s, i);
340
343
  },
341
344
  onSelectionOverlayChange: (i) => {
342
- var c;
345
+ var a;
343
346
  if (!this.disposed) {
344
347
  if (!x(this.overlay, i)) {
345
- const h = this.overlay.transforming !== i.transforming || this.overlay.hiddenReason === "selecting" != (i.hiddenReason === "selecting");
346
- this.overlay = i, this.overlaySequence += 1, this.emit("overlay.change"), h && this.changed();
348
+ const d = this.overlay.transforming !== i.transforming || this.overlay.hiddenReason === "selecting" != (i.hiddenReason === "selecting");
349
+ this.overlay = i, this.overlaySequence += 1, this.emit("overlay.change"), d && this.changed();
347
350
  }
348
- (c = s.onSelectionOverlayChange) == null || c.call(s, i);
351
+ (a = s.onSelectionOverlayChange) == null || a.call(s, i);
349
352
  }
350
353
  },
351
354
  onError: (i) => {
352
- var c;
353
- this.report(new Error(i)), (c = s.onError) == null || c.call(s, i);
355
+ var a;
356
+ this.report(new Error(i)), (a = s.onError) == null || a.call(s, i);
354
357
  }
355
358
  }), this.unsubscribeHost = this.host.subscribe((i) => {
356
- var c, h;
359
+ var a, d;
357
360
  if (!this.disposed) {
358
361
  if (i.type === "selection.change")
359
362
  this.selectionVersion += 1, this.overlay = { x: 0, y: 0, visible: !1, transforming: !1, hiddenReason: i.selection.instanceIds.length ? "anchor-unavailable" : "no-selection" }, this.overlaySequence += 1, this.session.select(i.selection.instanceIds, i.selection.primaryId);
360
363
  else if (i.type === "document.change" || i.type === "asset.loaded") {
361
364
  if (i.type === "document.change" && (i.origin === "open" || i.origin === "replace")) {
362
- this.sceneSessionId = `session_${A()}`, this.selectionVersion = 0, this.overlaySequence = 0, this.previewDocument = null;
365
+ this.sceneSessionId = `session_${T()}`, this.selectionVersion = 0, this.overlaySequence = 0, this.previewDocument = null;
363
366
  for (const u of this.transformOrigins.keys())
364
- (h = (c = this.session).setTransformOrigin) == null || h.call(c, u, null);
367
+ (d = (a = this.session).setTransformOrigin) == null || d.call(a, u, null);
365
368
  this.transformOrigins.clear(), this.syncInteractionMode(), this.overlay = { x: 0, y: 0, visible: !1, transforming: !1, hiddenReason: "no-selection" };
366
369
  }
367
370
  this.sync().catch((u) => this.report(u));
368
371
  } else i.type === "editorial.change" && (this.session.setEditorial(i.snapshot.editorial), this.session.select(i.snapshot.selection.instanceIds, i.snapshot.selection.primaryId));
369
372
  this.contextVersion += 1, this.emit("toolbar.change"), this.emitEvent({ type: "host.change", snapshot: this.getSnapshot(), event: i });
370
373
  }
371
- }), (n = (o = this.session).setSurfaceSnap) == null || n.call(o, this.placementPolicy.surfaceSnap), (a = (d = this.session).setOverlapPrevention) == null || a.call(d, this.placementPolicy.preventOverlap), this.releaseShortcuts = e.shortcuts === !1 ? () => {
372
- } : ot(e.canvas, (i) => this.handleShortcut(i)), this.ready = this.host.ready().then(async () => {
374
+ }), (n = (o = this.session).setSurfaceSnap) == null || n.call(o, this.placementPolicy.surfaceSnap), (l = (h = this.session).setOverlapPrevention) == null || l.call(h, this.placementPolicy.preventOverlap), this.releaseShortcuts = e.shortcuts === !1 ? () => {
375
+ } : dt(e.canvas, (i) => this.handleShortcut(i)), this.ready = this.host.ready().then(async () => {
373
376
  this.disposed || await this.sync();
374
377
  }).catch((i) => {
375
378
  if (!this.disposed) throw i;
@@ -412,16 +415,16 @@ class it {
412
415
  * feature that is present but whose visualization is not mounted.
413
416
  */
414
417
  getNodeFeatures(e) {
415
- return this.assertActive(), tt(this.host.document, e, this.session.getRuntime(e));
418
+ return this.assertActive(), ct(this.host.document, e, this.session.getRuntime(e));
416
419
  }
417
420
  getAssetLoadStatus(e) {
418
421
  return this.assertActive(), this.session.getAssetLoadStatus(e);
419
422
  }
420
423
  remoteResolverFor(e) {
421
- const t = $e(e), s = this.remoteResolvers.get(e.revisionId);
424
+ const t = ze(e), s = this.remoteResolvers.get(e.revisionId);
422
425
  if ((s == null ? void 0 : s.fingerprint) === t && s.request === e.request)
423
426
  return s.resolver;
424
- const o = this.host.getAsset(e.revisionId) ?? this.host.getVisualAsset(e.revisionId) ?? void 0, n = new ge(e, o);
427
+ const o = this.host.getAsset(e.revisionId) ?? this.host.getVisualAsset(e.revisionId) ?? void 0, n = new ye(e, o);
425
428
  return this.remoteResolvers.set(e.revisionId, {
426
429
  fingerprint: t,
427
430
  request: e.request,
@@ -435,15 +438,15 @@ class it {
435
438
  captureEditorialState() {
436
439
  this.assertActive();
437
440
  const e = this.host.getSnapshot(), t = this.session.getCameraState();
438
- return Je({
441
+ return He({
439
442
  document: this.host.document,
440
443
  editorial: e.editorial,
441
444
  selection: e.selection,
442
- camera: t ? rt(t) : null
445
+ camera: t ? pt(t) : null
443
446
  });
444
447
  }
445
448
  applyEditorialState(e) {
446
- this.assertActive(), this.assertEditable(), Qe(e, this.host.document), this.session.cancelActiveGesture();
449
+ this.assertActive(), this.assertEditable(), Xe(e, this.host.document), this.session.cancelActiveGesture();
447
450
  const t = Object.fromEntries(e.nodeStates.map((s) => [
448
451
  s.nodeId,
449
452
  { hidden: s.hidden, locked: s.locked }
@@ -477,7 +480,7 @@ class it {
477
480
  (s = (t = this.actionDefinitions.get(e)) == null ? void 0 : t.cancel) == null || s.call(t), (o = this.actionControllers.get(e)) == null || o.abort(), this.actionControllers.delete(e), this.coreActionBusy.delete(e), this.changed();
478
481
  }
479
482
  async sync() {
480
- var o, n, d, a, i, c;
483
+ var o, n, h, l, i, a;
481
484
  this.assertActive();
482
485
  const e = ++this.syncEpoch, t = this.previewDocument ?? this.host.document;
483
486
  try {
@@ -486,17 +489,17 @@ class it {
486
489
  this.host.getSnapshot().editorial,
487
490
  ((n = (o = this.options).resolveRegionOverlays) == null ? void 0 : n.call(o, t)) ?? []
488
491
  );
489
- } catch (h) {
492
+ } catch (d) {
490
493
  if (this.disposed) return;
491
- throw h;
494
+ throw d;
492
495
  }
493
496
  if (this.disposed || e !== this.syncEpoch) return;
494
- for (const [h, u] of this.transformOrigins)
495
- y(t.root, h) && ((a = (d = this.session).setTransformOrigin) == null || a.call(d, h, [...u]));
497
+ for (const [d, u] of this.transformOrigins)
498
+ w(t.root, d) && ((l = (h = this.session).setTransformOrigin) == null || l.call(h, d, [...u]));
496
499
  if (!this.previewDocument) {
497
- const h = new Set(V(this.host.document.root).map((u) => u.nodeId));
500
+ const d = new Set(R(this.host.document.root).map((u) => u.nodeId));
498
501
  for (const u of this.transformOrigins.keys())
499
- h.has(u) || (this.transformOrigins.delete(u), (c = (i = this.session).setTransformOrigin) == null || c.call(i, u, null));
502
+ d.has(u) || (this.transformOrigins.delete(u), (a = (i = this.session).setTransformOrigin) == null || a.call(i, u, null));
500
503
  }
501
504
  const s = this.host.getSelection();
502
505
  this.session.select(s.instanceIds, s.primaryId);
@@ -520,7 +523,7 @@ class it {
520
523
  if (this.placementPreviewActive = !1, this.changed(), !s) return null;
521
524
  const o = this.host.getAsset(e.revisionId);
522
525
  if (!o) throw new g("ASSET_NOT_FOUND", `Asset revision not found: ${e.revisionId}`);
523
- const n = ce(o, {
526
+ const n = me(o, {
524
527
  revisionId: o.revisionId,
525
528
  label: e.label,
526
529
  role: e.role,
@@ -530,10 +533,10 @@ class it {
530
533
  ...e.physics ? { physics: e.physics } : {}
531
534
  });
532
535
  return this.host.commit({
533
- commands: [le(n, e.parentNodeId ?? t.document.root.nodeId, {
536
+ commands: [fe(n, e.parentNodeId ?? t.document.root.nodeId, {
534
537
  label: `Place ${n.label}`,
535
538
  source: "human",
536
- batchId: `batch_${A()}`
539
+ batchId: `batch_${T()}`
537
540
  })],
538
541
  expectedDocumentVersion: t.documentVersion,
539
542
  expectedSceneEpoch: t.sceneEpoch
@@ -557,19 +560,19 @@ class it {
557
560
  this.assertEditable(t);
558
561
  const n = Array.isArray(e) ? e : [e];
559
562
  for (const i of n) {
560
- const c = i.payload;
561
- if (!("nodeId" in c)) continue;
562
- const u = (c.type === "node.remove" || c.type === "node.duplicate" || c.type === "node.transform" ? ee(y(this.host.document.root, c.nodeId)) : [c.nodeId]).find((p) => this.host.getEditorialState(p).locked);
563
+ const a = i.payload;
564
+ if (!("nodeId" in a)) continue;
565
+ const u = (a.type === "node.remove" || a.type === "node.duplicate" || a.type === "node.transform" ? re(w(this.host.document.root, a.nodeId)) : [a.nodeId]).find((m) => this.host.getEditorialState(m).locked);
563
566
  if (u)
564
567
  throw new g("NODE_LOCKED", `Scene node is locked: ${u}`);
565
568
  }
566
- const d = Ee(this.host.document, n);
567
- d.diagnostics.some((i) => i.level === "error") || this.assertProjectionRepresentable(d.doc.root);
568
- const a = this.host.getSnapshot();
569
+ const h = _e(this.host.document, n);
570
+ h.diagnostics.some((i) => i.level === "error") || this.assertProjectionRepresentable(h.doc.root);
571
+ const l = this.host.getSnapshot();
569
572
  return this.host.commit({
570
573
  commands: n,
571
- expectedDocumentVersion: a.documentVersion,
572
- expectedSceneEpoch: a.sceneEpoch,
574
+ expectedDocumentVersion: l.documentVersion,
575
+ expectedSceneEpoch: l.sceneEpoch,
573
576
  ...t ? { gestureCommit: !0 } : {},
574
577
  ...s.length ? { allowOverlapNodeIds: s } : {},
575
578
  ...o.length ? { supportContacts: o } : {}
@@ -589,7 +592,113 @@ class it {
589
592
  }
590
593
  setPlacementPolicy(e) {
591
594
  var t, s, o, n;
592
- this.assertActive(), this.placementPolicy = Ye(e, this.placementPolicy), (s = (t = this.session).setSurfaceSnap) == null || s.call(t, this.placementPolicy.surfaceSnap), (n = (o = this.session).setOverlapPrevention) == null || n.call(o, this.placementPolicy.preventOverlap), this.changed();
595
+ this.assertActive(), this.placementPolicy = qe(e, this.placementPolicy), (s = (t = this.session).setSurfaceSnap) == null || s.call(t, this.placementPolicy.surfaceSnap), (n = (o = this.session).setOverlapPrevention) == null || n.call(o, this.placementPolicy.preventOverlap), this.changed();
596
+ }
597
+ addBoundingBoxPlaceholder(e) {
598
+ var v;
599
+ this.assertEditable();
600
+ const t = this.host.getSnapshot(), s = e.parentNodeId ?? t.document.root.nodeId;
601
+ if (((v = w(t.document.root, s)) == null ? void 0 : v.nodeType) !== "group")
602
+ throw new g(
603
+ "PLACEMENT_PARENT_INVALID",
604
+ "Placeholder parent must be a scene group."
605
+ );
606
+ const o = Re({
607
+ nodeId: "node_placeholder_placement_probe",
608
+ label: e.label,
609
+ dimensions: e.dimensions,
610
+ ...e.localUpDirection ? { localUpDirection: e.localUpDirection } : {},
611
+ ...e.position ? { position: e.position } : {},
612
+ ...e.role ? { role: e.role } : {},
613
+ ...e.visible !== void 0 ? { visible: e.visible } : {},
614
+ ...e.assetRevisionId ? { assetRevisionId: e.assetRevisionId } : {},
615
+ ...e.externalRef ? { externalRef: e.externalRef } : {},
616
+ ...e.semantic ? { semantic: e.semantic } : {}
617
+ }), n = C(t.document, o);
618
+ if (!n)
619
+ throw new g(
620
+ "PLACEMENT_BOUNDS_UNAVAILABLE",
621
+ "Placeholder placement requires known bounds."
622
+ );
623
+ const h = R(t.document.root).filter((S) => q(S) && F(t.document.root, S.nodeId, {})).map((S) => {
624
+ var c, f, p;
625
+ return {
626
+ nodeId: S.nodeId,
627
+ bounds: ((c = this.getNodeFrame(S.nodeId)) == null ? void 0 : c.localBounds) ?? (S.nodeType === "asset" ? (p = (f = this.session).getMeasuredAssetBounds) == null ? void 0 : p.call(f, S.assetRevisionId) : null) ?? C(t.document, S),
628
+ transform: Z(t.document.root, S.nodeId),
629
+ container: ee(t.document, S)
630
+ };
631
+ });
632
+ if (this.placementPolicy.preventOverlap && h.some((S) => !S.bounds))
633
+ throw new g(
634
+ "PLACEMENT_BOUNDS_UNAVAILABLE",
635
+ "Overlap prevention requires known obstacle bounds."
636
+ );
637
+ const l = J(t.document.root, s);
638
+ if (!l)
639
+ throw new g(
640
+ "TRANSFORM_NOT_REPRESENTABLE",
641
+ "Placeholder placement cannot be expressed below this parent."
642
+ );
643
+ const i = ge(l, o.localTransform);
644
+ if (!i)
645
+ throw new g(
646
+ "TRANSFORM_NOT_REPRESENTABLE",
647
+ "Placeholder placement cannot be expressed below this parent."
648
+ );
649
+ const a = {
650
+ ...this.placementPolicy,
651
+ gridStepM: 0,
652
+ adaptiveGridSnap: !1,
653
+ surfaceSnap: !1,
654
+ alignToSurface: !1
655
+ }, d = h.flatMap((S) => S.bounds ? [{ ...S, bounds: S.bounds }] : []);
656
+ let u = U({
657
+ bounds: n,
658
+ transform: i,
659
+ policy: a,
660
+ obstacles: d
661
+ });
662
+ if (a.preventOverlap && u.reason === "PLACEMENT_OVERLAP")
663
+ for (const S of Ie(
664
+ n,
665
+ u.transform,
666
+ a.clearanceM
667
+ )) {
668
+ const c = U({
669
+ bounds: n,
670
+ transform: {
671
+ ...i,
672
+ position: [
673
+ i.position[0] + S[0],
674
+ i.position[1] + S[1],
675
+ i.position[2] + S[2]
676
+ ]
677
+ },
678
+ policy: a,
679
+ obstacles: d
680
+ });
681
+ if (c.valid) {
682
+ u = c;
683
+ break;
684
+ }
685
+ }
686
+ if (!u.valid)
687
+ throw new g(
688
+ u.reason ?? "PLACEMENT_INVALID",
689
+ "The placeholder placement violates the active policy."
690
+ );
691
+ const m = B(u.transform, l);
692
+ if (!m)
693
+ throw new g(
694
+ "TRANSFORM_NOT_REPRESENTABLE",
695
+ "Placeholder placement cannot be expressed below this parent."
696
+ );
697
+ return this.host.addBoundingBoxPlaceholder({
698
+ ...e,
699
+ parentNodeId: s,
700
+ position: m.position
701
+ });
593
702
  }
594
703
  async prepareAssetPlacement(e) {
595
704
  var v, S;
@@ -597,7 +706,7 @@ class it {
597
706
  const t = this.host.getSnapshot();
598
707
  if (!this.host.getAsset(e.revisionId))
599
708
  throw new g("ASSET_NOT_FOUND", "Asset revision is not registered.");
600
- const s = e.parentNodeId ?? t.document.root.nodeId, o = y(t.document.root, s);
709
+ const s = e.parentNodeId ?? t.document.root.nodeId, o = w(t.document.root, s);
601
710
  if ((o == null ? void 0 : o.nodeType) !== "group")
602
711
  throw new g(
603
712
  "PLACEMENT_PARENT_INVALID",
@@ -606,46 +715,75 @@ class it {
606
715
  const n = await this.session.measureAssetBounds(e.revisionId);
607
716
  if ((S = e.signal) == null || S.throwIfAborted(), this.assertActive(), this.host.getSnapshot().sceneEpoch !== t.sceneEpoch || this.host.getSnapshot().documentVersion !== t.documentVersion)
608
717
  throw new g("CONTEXT_STALE", "Scene changed while measuring placement.");
609
- const d = V(t.document.root).filter(
610
- (r) => r.nodeType !== "group" && k(t.document.root, r.nodeId, {})
611
- ).map((r) => {
612
- var f;
718
+ const h = R(t.document.root).filter(
719
+ (c) => q(c) && F(t.document.root, c.nodeId, {})
720
+ ).map((c) => {
721
+ var f, p, b;
613
722
  return {
614
- nodeId: r.nodeId,
615
- bounds: ((f = this.getNodeFrame(r.nodeId)) == null ? void 0 : f.localBounds) ?? W(t.document, r),
616
- transform: de(t.document.root, r.nodeId),
617
- container: pe(t.document, r)
723
+ nodeId: c.nodeId,
724
+ bounds: ((f = this.getNodeFrame(c.nodeId)) == null ? void 0 : f.localBounds) ?? (c.nodeType === "asset" ? (b = (p = this.session).getMeasuredAssetBounds) == null ? void 0 : b.call(p, c.assetRevisionId) : null) ?? C(t.document, c),
725
+ transform: Z(t.document.root, c.nodeId),
726
+ container: ee(t.document, c)
618
727
  };
619
- }), a = e.allowOverlap ? { ...this.placementPolicy, preventOverlap: !1 } : this.placementPolicy;
620
- if (a.preventOverlap && d.some((r) => !r.bounds))
728
+ }), l = e.allowOverlap ? { ...this.placementPolicy, preventOverlap: !1 } : this.placementPolicy;
729
+ if (l.preventOverlap && h.some((c) => !c.bounds))
621
730
  throw new g(
622
731
  "PLACEMENT_BOUNDS_UNAVAILABLE",
623
732
  "Overlap prevention requires known obstacle bounds."
624
733
  );
625
- const i = !e.surface && (!!e.point || !e.worldTransform), c = e.surface ?? (i ? { nodeId: null, point: e.point ?? [0, 0, 0], normal: [0, 0, 1] } : null), h = me({
734
+ const i = !e.surface && (!!e.point || !e.worldTransform), a = e.surface ?? (i ? { nodeId: null, point: e.point ?? [0, 0, 0], normal: [0, 0, 1] } : null);
735
+ let d = U({
626
736
  bounds: n,
627
- transform: e.worldTransform ?? xe(),
628
- surface: c,
629
- policy: i ? { ...a, surfaceSnap: !0, alignToSurface: !1 } : a,
630
- obstacles: d.flatMap(
631
- (r) => r.bounds ? [{ ...r, bounds: r.bounds }] : []
737
+ transform: e.worldTransform ?? ve(),
738
+ surface: a,
739
+ policy: i ? { ...l, surfaceSnap: !0, alignToSurface: !1 } : l,
740
+ obstacles: h.flatMap(
741
+ (c) => c.bounds ? [{ ...c, bounds: c.bounds }] : []
632
742
  )
633
- }), u = he(t.document.root, s), p = u ? G(h.transform, u) : null;
634
- if (!p)
743
+ });
744
+ if (e.autoAvoidOverlap && !e.allowOverlap && a && d.reason === "PLACEMENT_OVERLAP")
745
+ for (const c of Ie(
746
+ n,
747
+ d.transform,
748
+ l.clearanceM
749
+ )) {
750
+ const f = U({
751
+ bounds: n,
752
+ transform: e.worldTransform ?? ve(),
753
+ surface: {
754
+ ...a,
755
+ point: [
756
+ a.point[0] + c[0],
757
+ a.point[1] + c[1],
758
+ a.point[2] + c[2]
759
+ ]
760
+ },
761
+ policy: i ? { ...l, surfaceSnap: !0, alignToSurface: !1 } : l,
762
+ obstacles: h.flatMap(
763
+ (p) => p.bounds ? [{ ...p, bounds: p.bounds }] : []
764
+ )
765
+ });
766
+ if (f.valid) {
767
+ d = f;
768
+ break;
769
+ }
770
+ }
771
+ const u = J(t.document.root, s), m = u ? B(d.transform, u) : null;
772
+ if (!m)
635
773
  throw new g(
636
774
  "TRANSFORM_NOT_REPRESENTABLE",
637
775
  "Placement requires shear below this parent."
638
776
  );
639
- return Q(
640
- q({
777
+ return ie(
778
+ ne({
641
779
  revisionId: e.revisionId,
642
780
  parentNodeId: s,
643
781
  sceneEpoch: t.sceneEpoch,
644
782
  documentVersion: t.documentVersion,
645
783
  policy: this.placementPolicy,
646
784
  sourceBounds: n,
647
- evaluation: h,
648
- localTransform: p
785
+ evaluation: d,
786
+ localTransform: m
649
787
  })
650
788
  );
651
789
  }
@@ -661,7 +799,7 @@ class it {
661
799
  );
662
800
  const o = this.host.getAsset(e.revisionId);
663
801
  if (!o) throw new g("ASSET_NOT_FOUND", "Asset revision not found.");
664
- const n = ce(o, {
802
+ const n = me(o, {
665
803
  revisionId: o.revisionId,
666
804
  label: t.label,
667
805
  role: t.role,
@@ -671,14 +809,14 @@ class it {
671
809
  this.transactionBounds.set(n.nodeId, e.sourceBounds);
672
810
  try {
673
811
  return this.applyCommands(
674
- le(n, e.parentNodeId, {
812
+ fe(n, e.parentNodeId, {
675
813
  label: "Place " + t.label,
676
814
  source: "human",
677
- batchId: "batch_" + A()
815
+ batchId: "batch_" + T()
678
816
  }),
679
817
  !1,
680
818
  [],
681
- Z(
819
+ te(
682
820
  n.nodeId,
683
821
  e.evaluation.supportNodeId,
684
822
  e.evaluation.supportSurfaceZ
@@ -691,50 +829,50 @@ class it {
691
829
  prepareNodePlacement(e) {
692
830
  var u;
693
831
  this.assertEditable();
694
- const t = this.host.getSnapshot(), s = y(t.document.root, e.nodeId), o = (u = this.getNodeFrame(e.nodeId)) == null ? void 0 : u.localBounds;
832
+ const t = this.host.getSnapshot(), s = w(t.document.root, e.nodeId), o = (u = this.getNodeFrame(e.nodeId)) == null ? void 0 : u.localBounds;
695
833
  if (!s || !o)
696
834
  throw new g(
697
835
  "PLACEMENT_BOUNDS_UNAVAILABLE",
698
836
  "Placement requires known source bounds."
699
837
  );
700
- const n = new Set(ee(s)), d = V(t.document.root).filter(
701
- (p) => p.nodeType !== "group" && !n.has(p.nodeId) && k(t.document.root, p.nodeId, {})
702
- ).map((p) => {
838
+ const n = new Set(re(s)), h = R(t.document.root).filter(
839
+ (m) => q(m) && !n.has(m.nodeId) && F(t.document.root, m.nodeId, {})
840
+ ).map((m) => {
703
841
  var v;
704
842
  return {
705
- nodeId: p.nodeId,
706
- bounds: ((v = this.getNodeFrame(p.nodeId)) == null ? void 0 : v.localBounds) ?? W(t.document, p),
707
- transform: de(t.document.root, p.nodeId),
708
- container: pe(t.document, p)
843
+ nodeId: m.nodeId,
844
+ bounds: ((v = this.getNodeFrame(m.nodeId)) == null ? void 0 : v.localBounds) ?? C(t.document, m),
845
+ transform: Z(t.document.root, m.nodeId),
846
+ container: ee(t.document, m)
709
847
  };
710
- }), a = e.allowOverlap ? { ...this.placementPolicy, preventOverlap: !1 } : this.placementPolicy;
711
- if (a.preventOverlap && d.some((p) => !p.bounds))
848
+ }), l = e.allowOverlap ? { ...this.placementPolicy, preventOverlap: !1 } : this.placementPolicy;
849
+ if (l.preventOverlap && h.some((m) => !m.bounds))
712
850
  throw new g(
713
851
  "PLACEMENT_BOUNDS_UNAVAILABLE",
714
852
  "An obstacle has no known source bounds."
715
853
  );
716
- const i = me({
854
+ const i = U({
717
855
  bounds: o,
718
856
  transform: e.worldTransform,
719
857
  surface: e.surface,
720
- policy: a,
721
- obstacles: d.flatMap(
722
- (p) => p.bounds ? [{ ...p, bounds: p.bounds }] : []
858
+ policy: l,
859
+ obstacles: h.flatMap(
860
+ (m) => m.bounds ? [{ ...m, bounds: m.bounds }] : []
723
861
  )
724
- }), c = $(t.document.root, e.nodeId), h = c ? G(i.transform, c) : null;
725
- if (!h)
862
+ }), a = W(t.document.root, e.nodeId), d = a ? B(i.transform, a) : null;
863
+ if (!d)
726
864
  throw new g(
727
865
  "TRANSFORM_NOT_REPRESENTABLE",
728
866
  "Placement cannot be expressed below this parent."
729
867
  );
730
- return Q(
731
- q({
868
+ return ie(
869
+ ne({
732
870
  nodeId: e.nodeId,
733
871
  sceneEpoch: t.sceneEpoch,
734
872
  documentVersion: t.documentVersion,
735
873
  policy: this.placementPolicy,
736
874
  evaluation: i,
737
- localTransform: h
875
+ localTransform: d
738
876
  })
739
877
  );
740
878
  }
@@ -749,14 +887,14 @@ class it {
749
887
  "The placement violates the active policy."
750
888
  );
751
889
  return this.applyCommands(
752
- B(t.document, e.nodeId, e.localTransform, {
890
+ j(t.document, e.nodeId, e.localTransform, {
753
891
  label: "Place node",
754
892
  source: "human",
755
- batchId: "batch_" + A()
893
+ batchId: "batch_" + T()
756
894
  }),
757
895
  !1,
758
896
  [],
759
- Z(
897
+ te(
760
898
  e.nodeId,
761
899
  e.evaluation.supportNodeId,
762
900
  e.evaluation.supportSurfaceZ
@@ -787,7 +925,7 @@ class it {
787
925
  }
788
926
  setTransformOrigin(e, t) {
789
927
  var o, n;
790
- if (this.assertActive(), !y(this.host.document.root, e) || !t && t !== null || t && (t.length !== 3 || t.some((d) => !Number.isFinite(d)))) return !1;
928
+ if (this.assertActive(), !w(this.host.document.root, e) || !t && t !== null || t && (t.length !== 3 || t.some((h) => !Number.isFinite(h)))) return !1;
791
929
  if (this.assertEditable(!0), X(this.host.document.root, e, this.host.getSnapshot().editorial))
792
930
  throw new g("NODE_LOCKED", `Scene node is locked: ${e}`);
793
931
  return t ? this.transformOrigins.set(e, [...t]) : this.transformOrigins.delete(e), (n = (o = this.session).setTransformOrigin) == null || n.call(o, e, t ? [...t] : null), !0;
@@ -797,39 +935,39 @@ class it {
797
935
  return ((t = this.getNodeFrame(e)) == null ? void 0 : t.orientation) ?? null;
798
936
  }
799
937
  setNodeOrigin(e, t) {
800
- this.assertEditable(), t && nt(t);
801
- const s = y(this.host.document.root, e);
938
+ this.assertEditable(), t && ut(t);
939
+ const s = w(this.host.document.root, e);
802
940
  if (!s) throw new g("NODE_NOT_FOUND", `Scene node not found: ${e}`);
803
941
  if (s.nodeId === this.host.document.root.nodeId)
804
942
  throw new g("ORIGIN_NOT_EDITABLE", "The scene root does not expose a transform origin.");
805
943
  return this.dispatch(
806
- Ae(this.host.document, e, t, {
944
+ De(this.host.document, e, t, {
807
945
  label: "Set node origin",
808
946
  source: "human",
809
- batchId: "batch_" + A()
947
+ batchId: "batch_" + T()
810
948
  })
811
949
  );
812
950
  }
813
951
  setNodeUpDirection(e, t) {
814
952
  this.assertEditable();
815
953
  const s = Math.hypot(...t);
816
- if (t.length !== 3 || t.some((a) => !Number.isFinite(a)) || !Number.isFinite(s) || s <= 1e-12)
954
+ if (t.length !== 3 || t.some((l) => !Number.isFinite(l)) || !Number.isFinite(s) || s <= 1e-12)
817
955
  throw new g(
818
956
  "ORIENTATION_DIRECTION_INVALID",
819
957
  "Orientation direction must be a finite, non-zero three-component vector."
820
958
  );
821
- const o = y(this.host.document.root, e);
959
+ const o = w(this.host.document.root, e);
822
960
  if (!o) throw new g("NODE_NOT_FOUND", `Scene node not found: ${e}`);
823
- const n = t.map((a) => a / s), d = Me(n);
961
+ const n = t.map((l) => l / s), h = $e(n);
824
962
  return this.changeTransform(
825
963
  e,
826
- { ...o.localTransform, rotation: d },
964
+ { ...o.localTransform, rotation: h },
827
965
  { space: "local", scope: "node" }
828
966
  );
829
967
  }
830
968
  getAssetDimensions(e) {
831
969
  var t;
832
- return this.assertActive(), Ke(
970
+ return this.assertActive(), et(
833
971
  this.host.document,
834
972
  e,
835
973
  (t = this.session.getNodeFrame(e)) == null ? void 0 : t.localBounds
@@ -852,48 +990,48 @@ class it {
852
990
  this.session.setTransformSpace(e), this.transformSpace = e, this.changed();
853
991
  }
854
992
  setNodeDimensions(e, t, s = {}) {
855
- var i, c;
993
+ var i, a;
856
994
  this.assertEditable();
857
- const o = this.getAssetDimensions(e), n = y(this.host.document.root, e);
995
+ const o = this.getAssetDimensions(e), n = w(this.host.document.root, e);
858
996
  if (!n || !(o != null && o.editable) || !o.sourceDimensions)
859
997
  throw new g(
860
998
  (o == null ? void 0 : o.reason) ?? "NODE_NOT_FOUND",
861
999
  "Node dimensions cannot be edited: " + e
862
1000
  );
863
- if (t.length !== 3 || t.some((h) => !Number.isFinite(h) || h <= 0))
1001
+ if (t.length !== 3 || t.some((d) => !Number.isFinite(d) || d <= 0))
864
1002
  throw new g(
865
1003
  "DIMENSIONS_INVALID",
866
1004
  "Dimensions must be three positive finite metre values."
867
1005
  );
868
1006
  if (s.anchor && s.anchor !== "node-origin" && s.anchor !== "bounds-center")
869
1007
  throw new g("DIMENSIONS_ANCHOR_INVALID", "Unknown dimensions anchor.");
870
- const d = t.map(
871
- (h, u) => h / o.sourceDimensions[u]
1008
+ const h = t.map(
1009
+ (d, u) => d / o.sourceDimensions[u]
872
1010
  );
873
- let a = n.localTransform.position;
1011
+ let l = n.localTransform.position;
874
1012
  if (s.anchor === "bounds-center") {
875
- const h = (i = this.getNodeFrame(e)) == null ? void 0 : i.localBounds;
876
- if (!h)
1013
+ const d = (i = this.getNodeFrame(e)) == null ? void 0 : i.localBounds;
1014
+ if (!d)
877
1015
  throw new g(
878
1016
  "BOUNDS_UNAVAILABLE",
879
1017
  "A bounds center requires source bounds."
880
1018
  );
881
- const u = ze(h), p = ((c = n.origin) == null ? void 0 : c.local) ?? [0, 0, 0], v = u.map(
882
- (r, f) => r - p[f]
883
- ), S = Fe(
1019
+ const u = tt(d), m = ((a = n.origin) == null ? void 0 : a.local) ?? [0, 0, 0], v = u.map(
1020
+ (c, f) => c - m[f]
1021
+ ), S = je(
884
1022
  n.localTransform.rotation,
885
1023
  v.map(
886
- (r, f) => r * (n.localTransform.scale[f] - d[f])
1024
+ (c, f) => c * (n.localTransform.scale[f] - h[f])
887
1025
  )
888
1026
  );
889
- a = a.map((r, f) => r + S[f]);
1027
+ l = l.map((c, f) => c + S[f]);
890
1028
  }
891
1029
  return this.dispatch(
892
- B(
1030
+ j(
893
1031
  this.host.document,
894
1032
  e,
895
- { ...n.localTransform, position: a, scale: d },
896
- { label: "Set node dimensions", source: "human", batchId: "batch_" + A() }
1033
+ { ...n.localTransform, position: l, scale: h },
1034
+ { label: "Set node dimensions", source: "human", batchId: "batch_" + T() }
897
1035
  )
898
1036
  );
899
1037
  }
@@ -902,16 +1040,16 @@ class it {
902
1040
  throw new g("VISIBILITY_INVALID", "Authored visibility must be boolean.");
903
1041
  const s = /* @__PURE__ */ new Map();
904
1042
  for (const n of e) {
905
- const d = y(this.host.document.root, n);
906
- if (!d || n === this.host.document.root.nodeId)
1043
+ const h = w(this.host.document.root, n);
1044
+ if (!h || n === this.host.document.root.nodeId)
907
1045
  throw new g("NODE_NOT_FOUND", "Scene node not found: " + n);
908
- for (const a of d.nodeType === "group" ? V(d) : [d])
909
- "visible" in a && s.set(a.nodeId, a);
1046
+ for (const l of h.nodeType === "group" ? R(h) : [h])
1047
+ "visible" in l && s.set(l.nodeId, l);
910
1048
  }
911
- const o = "batch_" + A();
1049
+ const o = "batch_" + T();
912
1050
  return this.dispatch(
913
1051
  [...s.values()].filter((n) => "visible" in n && n.visible !== t).map(
914
- (n) => Te(this.host.document, n.nodeId, t, {
1052
+ (n) => Ve(this.host.document, n.nodeId, t, {
915
1053
  label: "Set authored visibility",
916
1054
  source: "human",
917
1055
  batchId: o
@@ -952,19 +1090,19 @@ class it {
952
1090
  }
953
1091
  setNodePhysics(e, t) {
954
1092
  return this.dispatch(
955
- Ne(this.host.document, e, t, {
1093
+ Ce(this.host.document, e, t, {
956
1094
  label: "Set node physics",
957
1095
  source: "human",
958
- batchId: "batch_" + A()
1096
+ batchId: "batch_" + T()
959
1097
  })
960
1098
  );
961
1099
  }
962
1100
  setNodeInitialPose(e, t) {
963
1101
  return this.dispatch(
964
- Oe(this.host.document, e, t, {
1102
+ Le(this.host.document, e, t, {
965
1103
  label: "Set initial joint pose",
966
1104
  source: "human",
967
- batchId: "batch_" + A()
1105
+ batchId: "batch_" + T()
968
1106
  })
969
1107
  );
970
1108
  }
@@ -989,68 +1127,68 @@ class it {
989
1127
  if (s.space && s.space !== "local" && s.space !== "world" || s.scope && s.scope !== "node" && s.scope !== "selection")
990
1128
  throw new g("TRANSFORM_OPTIONS_INVALID", "Invalid transform space or scope.");
991
1129
  if (s.scope === "node") {
992
- const n = $(this.host.document.root, e), d = s.space === "local" ? t : n ? G(t, n) : null;
993
- if (!d)
1130
+ const n = W(this.host.document.root, e), h = s.space === "local" ? t : n ? B(t, n) : null;
1131
+ if (!h)
994
1132
  throw new g(
995
1133
  "TRANSFORM_NOT_REPRESENTABLE",
996
1134
  "Transform cannot be expressed below this parent."
997
1135
  );
998
1136
  return this.dispatch(
999
- B(this.host.document, e, d, {
1137
+ j(this.host.document, e, h, {
1000
1138
  label: "Transform node",
1001
1139
  source: "human",
1002
- batchId: "batch_" + A()
1140
+ batchId: "batch_" + T()
1003
1141
  })
1004
1142
  );
1005
1143
  }
1006
- const o = s.space === "local" ? Ue($(this.host.document.root, e), t) : t;
1144
+ const o = s.space === "local" ? ge(W(this.host.document.root, e), t) : t;
1007
1145
  if (!o)
1008
1146
  throw new g("TRANSFORM_NOT_REPRESENTABLE", "Transform requires shear.");
1009
1147
  return this.commitTransform(e, o, !1);
1010
1148
  }
1011
1149
  commitTransform(e, t, s, o = {}) {
1012
- if (this.assertEditable(s), !y(this.host.document.root, e) || j(
1150
+ if (this.assertEditable(s), !w(this.host.document.root, e) || K(
1013
1151
  this.host.document.root,
1014
1152
  e,
1015
1153
  this.host.getSnapshot().editorial
1016
1154
  ))
1017
1155
  throw new g("NODE_NOT_EDITABLE", `Scene node is not editable: ${e}`);
1018
- const d = this.host.getSelection(), a = /* @__PURE__ */ new Set([e, ...d.instanceIds]), i = this.sceneInstances().filter((r) => a.has(r.nodeId)).map((r) => ({
1019
- ...r,
1020
- visible: k(
1156
+ const h = this.host.getSelection(), l = /* @__PURE__ */ new Set([e, ...h.instanceIds]), i = this.sceneInstances().filter((c) => l.has(c.nodeId)).map((c) => ({
1157
+ ...c,
1158
+ visible: F(
1021
1159
  this.host.document.root,
1022
- r.nodeId,
1160
+ c.nodeId,
1023
1161
  this.host.getSnapshot().editorial
1024
1162
  ),
1025
- localTransform: he(this.host.document.root, r.nodeId) ?? r.localTransform
1026
- })), c = Object.fromEntries(i.map((r) => [
1027
- r.nodeId,
1028
- Be(
1163
+ localTransform: J(this.host.document.root, c.nodeId) ?? c.localTransform
1164
+ })), a = Object.fromEntries(i.map((c) => [
1165
+ c.nodeId,
1166
+ We(
1029
1167
  this.host.document.root,
1030
- r.nodeId,
1168
+ c.nodeId,
1031
1169
  this.host.getSnapshot().editorial
1032
1170
  )
1033
- ])), h = new Set(this.selectionClosure([...a]).map((r) => r.nodeId)), u = He(i, e, t, c).filter((r) => h.has(r.nodeId)).flatMap((r) => {
1034
- const f = $(this.host.document.root, r.nodeId), m = f ? G(r.localTransform, f) : null;
1035
- if (!m)
1171
+ ])), d = new Set(this.selectionClosure([...l]).map((c) => c.nodeId)), u = ot(i, e, t, a).filter((c) => d.has(c.nodeId)).flatMap((c) => {
1172
+ const f = W(this.host.document.root, c.nodeId), p = f ? B(c.localTransform, f) : null;
1173
+ if (!p)
1036
1174
  throw new g(
1037
1175
  "TRANSFORM_NOT_REPRESENTABLE",
1038
- `World transform cannot be represented below the parent of ${r.nodeId}.`
1176
+ `World transform cannot be represented below the parent of ${c.nodeId}.`
1039
1177
  );
1040
- const b = y(this.host.document.root, r.nodeId);
1041
- return b && !x(b.localTransform, m) ? [{ nodeId: r.nodeId, localTransform: m }] : [];
1042
- }), p = `batch_${A()}`, v = o.supportNodeId, S = o.supportSurfaceZ;
1178
+ const b = w(this.host.document.root, c.nodeId);
1179
+ return b && !x(b.localTransform, p) ? [{ nodeId: c.nodeId, localTransform: p }] : [];
1180
+ }), m = `batch_${T()}`, v = o.supportNodeId, S = o.supportSurfaceZ;
1043
1181
  return this.applyCommands(
1044
- u.map((r) => B(
1182
+ u.map((c) => j(
1045
1183
  this.host.document,
1046
- r.nodeId,
1047
- r.localTransform,
1048
- { label: "Transform selection", source: "human", batchId: p }
1184
+ c.nodeId,
1185
+ c.localTransform,
1186
+ { label: "Transform selection", source: "human", batchId: m }
1049
1187
  )),
1050
1188
  s,
1051
- o.allowOverlap === !0 ? [e, ...d.instanceIds] : [],
1052
- v && Number.isFinite(S) ? u.flatMap((r) => Z(
1053
- r.nodeId,
1189
+ o.allowOverlap === !0 ? [e, ...h.instanceIds] : [],
1190
+ v && Number.isFinite(S) ? u.flatMap((c) => te(
1191
+ c.nodeId,
1054
1192
  v,
1055
1193
  S
1056
1194
  )) : []
@@ -1058,34 +1196,34 @@ class it {
1058
1196
  }
1059
1197
  duplicateSelection(e = this.host.getSelection().instanceIds) {
1060
1198
  this.assertEditable();
1061
- const t = this.editableTargets(e), s = `batch_${A()}`, o = [], n = t.map((a) => {
1199
+ const t = this.editableTargets(e), s = `batch_${T()}`, o = [], n = t.map((l) => {
1062
1200
  var u;
1063
- const i = ((u = H(this.host.document.root, a.nodeId)) == null ? void 0 : u.parent.nodeId) ?? this.host.document.root.nodeId, c = Pe(this.host.document, a.nodeId, i, { label: "Duplicate selection", source: "human", batchId: s });
1064
- if (c.payload.type !== "node.duplicate") throw new Error("Invalid duplicate command");
1065
- const h = c.payload.created;
1066
- return o.push(h.nodeId), _e({ ...c.payload, created: { ...h, localTransform: {
1067
- ...h.localTransform,
1068
- position: [h.localTransform.position[0] + 0.25, h.localTransform.position[1] + 0.25, h.localTransform.position[2]]
1201
+ const i = ((u = Q(this.host.document.root, l.nodeId)) == null ? void 0 : u.parent.nodeId) ?? this.host.document.root.nodeId, a = Me(this.host.document, l.nodeId, i, { label: "Duplicate selection", source: "human", batchId: s });
1202
+ if (a.payload.type !== "node.duplicate") throw new Error("Invalid duplicate command");
1203
+ const d = a.payload.created;
1204
+ return o.push(d.nodeId), xe({ ...a.payload, created: { ...d, localTransform: {
1205
+ ...d.localTransform,
1206
+ position: [d.localTransform.position[0] + 0.25, d.localTransform.position[1] + 0.25, d.localTransform.position[2]]
1069
1207
  } } }, { label: "Duplicate selection", source: "human", batchId: s });
1070
- }), d = this.dispatch(n);
1071
- return d.changed && this.select(o), d;
1208
+ }), h = this.dispatch(n);
1209
+ return h.changed && this.select(o), h;
1072
1210
  }
1073
1211
  deleteSelection(e = this.host.getSelection().instanceIds) {
1074
1212
  this.assertEditable();
1075
- const t = `batch_${A()}`;
1076
- return this.dispatch(this.editableTargets(e).map((s) => De(this.host.document, s.nodeId, { label: "Delete selection", source: "human", batchId: t })));
1213
+ const t = `batch_${T()}`;
1214
+ return this.dispatch(this.editableTargets(e).map((s) => Fe(this.host.document, s.nodeId, { label: "Delete selection", source: "human", batchId: t })));
1077
1215
  }
1078
1216
  groupSelection(e = this.host.getSelection().instanceIds) {
1079
1217
  this.assertEditable();
1080
1218
  const t = this.editableTargets(e);
1081
1219
  if (t.length < 2) throw new g("GROUP_REQUIRES_MULTIPLE", "Grouping requires at least two editable nodes.");
1082
- const s = new Set(t.map((d) => {
1083
- var a;
1084
- return ((a = H(this.host.document.root, d.nodeId)) == null ? void 0 : a.parent.nodeId) ?? this.host.document.root.nodeId;
1085
- })), o = s.size === 1 ? [...s][0] : this.host.document.root.nodeId, n = `batch_${A()}`;
1086
- return this.dispatch(Re(
1220
+ const s = new Set(t.map((h) => {
1221
+ var l;
1222
+ return ((l = Q(this.host.document.root, h.nodeId)) == null ? void 0 : l.parent.nodeId) ?? this.host.document.root.nodeId;
1223
+ })), o = s.size === 1 ? [...s][0] : this.host.document.root.nodeId, n = `batch_${T()}`;
1224
+ return this.dispatch(Be(
1087
1225
  this.host.document,
1088
- t.map((d) => d.nodeId),
1226
+ t.map((h) => h.nodeId),
1089
1227
  o,
1090
1228
  {
1091
1229
  label: "Group selection",
@@ -1098,30 +1236,30 @@ class it {
1098
1236
  ungroupSelection(e = this.host.getSelection().instanceIds) {
1099
1237
  this.assertEditable();
1100
1238
  const t = this.removableGroupIds(
1101
- this.editableTargets(e).map((d) => d.nodeId)
1239
+ this.editableTargets(e).map((h) => h.nodeId)
1102
1240
  );
1103
1241
  if (t.length === 0)
1104
1242
  throw new g(
1105
1243
  "NO_PARENT_GROUP",
1106
1244
  "The selection does not contain an editable group or child of one."
1107
1245
  );
1108
- const s = `batch_${A()}`, o = [];
1246
+ const s = `batch_${T()}`, o = [];
1109
1247
  let n = this.host.document;
1110
- for (const d of t) {
1111
- const a = Ve(n, d, {
1248
+ for (const h of t) {
1249
+ const l = Ue(n, h, {
1112
1250
  label: "Ungroup selection",
1113
1251
  source: "human",
1114
1252
  batchId: s
1115
1253
  });
1116
- o.push(...a), n = a.reduce((i, c) => {
1117
- const h = Ce(i, c.payload);
1118
- if (h.diagnostics.some((u) => u.level === "error"))
1254
+ o.push(...l), n = l.reduce((i, a) => {
1255
+ const d = ke(i, a.payload);
1256
+ if (d.diagnostics.some((u) => u.level === "error"))
1119
1257
  throw new g(
1120
1258
  "UNGROUP_REJECTED",
1121
- h.diagnostics.map((u) => u.message).join(`
1259
+ d.diagnostics.map((u) => u.message).join(`
1122
1260
  `)
1123
1261
  );
1124
- return h.doc;
1262
+ return d.doc;
1125
1263
  }, n);
1126
1264
  }
1127
1265
  return this.dispatch(o);
@@ -1210,48 +1348,48 @@ class it {
1210
1348
  return this.syncInteractionMode(), this.changed(), e || t;
1211
1349
  }
1212
1350
  getNodeActions(e) {
1213
- const t = [...new Set(e)], s = this.selectionClosure(t), o = s.map((m) => m.nodeId), n = this.editableTargets(o).map((m) => m.nodeId), d = new Set(n), a = o.filter((m) => !d.has(m)).map((m) => ({
1214
- nodeId: m,
1215
- reasonCode: j(
1351
+ const t = [...new Set(e)], s = this.selectionClosure(t), o = s.map((p) => p.nodeId), n = this.editableTargets(o).map((p) => p.nodeId), h = new Set(n), l = o.filter((p) => !h.has(p)).map((p) => ({
1352
+ nodeId: p,
1353
+ reasonCode: K(
1216
1354
  this.host.document.root,
1217
- m,
1355
+ p,
1218
1356
  this.host.getSnapshot().editorial
1219
1357
  ) ? "NODE_LOCKED" : "NODE_NOT_EDITABLE"
1220
- })), i = s.length > 0, c = this.editingEnabled && !this.previewMode && !this.previewDocument, h = this.overlay.transforming || this.overlay.hiddenReason === "selecting", u = this.session.isSimulationRunning(), p = (m, b, T = {}) => ({
1221
- id: m,
1358
+ })), i = s.length > 0, a = this.editingEnabled && !this.previewMode && !this.previewDocument, d = this.overlay.transforming || this.overlay.hiddenReason === "selecting", u = this.session.isSimulationRunning(), m = (p, b, y = {}) => ({
1359
+ id: p,
1222
1360
  scope: "selection",
1223
1361
  visible: i,
1224
- enabled: b && c && !h && !u,
1362
+ enabled: b && a && !d && !u,
1225
1363
  busy: !1,
1226
1364
  targetIds: n,
1227
1365
  execution: "eligible-subset",
1228
- ...a.length ? { excludedTargets: a } : {},
1229
- ...u ? { reason: { code: "SIMULATION_RUNNING" } } : c ? h ? { reason: { code: "GESTURE_ACTIVE" } } : b ? {} : { reason: { code: "NO_EDITABLE_TARGETS", nodeIds: o } } : { reason: { code: this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : "EDITING_DISABLED" } },
1230
- ...T
1231
- }), v = this.host.getSnapshot().editorial, S = i && s.every((m) => j(this.host.document.root, m.nodeId, v)), r = s.some((m) => j(this.host.document.root, m.nodeId, v));
1366
+ ...l.length ? { excludedTargets: l } : {},
1367
+ ...u ? { reason: { code: "SIMULATION_RUNNING" } } : a ? d ? { reason: { code: "GESTURE_ACTIVE" } } : b ? {} : { reason: { code: "NO_EDITABLE_TARGETS", nodeIds: o } } : { reason: { code: this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : "EDITING_DISABLED" } },
1368
+ ...y
1369
+ }), v = this.host.getSnapshot().editorial, S = i && s.every((p) => K(this.host.document.root, p.nodeId, v)), c = s.some((p) => K(this.host.document.root, p.nodeId, v));
1232
1370
  return [
1233
1371
  ...[
1234
- ...["translate", "rotate", "scale"].map((m) => p(`tools.${m}`, n.length > 0, { active: this.mode === m })),
1235
- p("nodes.duplicate", n.length > 0),
1236
- p("nodes.remove", n.length > 0),
1237
- p("nodes.group", n.length >= 2),
1238
- p("nodes.ungroup", this.removableGroupIds(n).length > 0),
1239
- p("nodes.hide", i, { targetIds: s.map((m) => m.nodeId) }),
1240
- p("nodes.visibility", i, { targetIds: s.map((m) => m.nodeId), valueState: s.every((m) => !("visible" in m) || m.visible) ? "on" : s.every((m) => "visible" in m && !m.visible) ? "off" : "mixed" }),
1241
- p("camera.focus", i, { enabled: i, targetIds: s.map((m) => m.nodeId) }),
1242
- p("nodes.lock", i, { targetIds: s.map((m) => m.nodeId), execution: "atomic", excludedTargets: [], active: S, valueState: S ? "on" : r ? "mixed" : "off" })
1243
- ].filter((m) => {
1372
+ ...["translate", "rotate", "scale"].map((p) => m(`tools.${p}`, n.length > 0, { active: this.mode === p })),
1373
+ m("nodes.duplicate", n.length > 0),
1374
+ m("nodes.remove", n.length > 0),
1375
+ m("nodes.group", n.length >= 2),
1376
+ m("nodes.ungroup", this.removableGroupIds(n).length > 0),
1377
+ m("nodes.hide", i, { targetIds: s.map((p) => p.nodeId) }),
1378
+ m("nodes.visibility", i, { targetIds: s.map((p) => p.nodeId), valueState: s.every((p) => !("visible" in p) || p.visible) ? "on" : s.every((p) => "visible" in p && !p.visible) ? "off" : "mixed" }),
1379
+ m("camera.focus", i, { enabled: i, targetIds: s.map((p) => p.nodeId) }),
1380
+ m("nodes.lock", i, { targetIds: s.map((p) => p.nodeId), execution: "atomic", excludedTargets: [], active: S, valueState: S ? "on" : c ? "mixed" : "off" })
1381
+ ].filter((p) => {
1244
1382
  var b;
1245
- return ((b = this.actionDefinitions.get(m.id)) == null ? void 0 : b.scope) === "selection";
1383
+ return ((b = this.actionDefinitions.get(p.id)) == null ? void 0 : b.scope) === "selection";
1246
1384
  }),
1247
1385
  ...this.registeredToolbarActions("selection", o),
1248
1386
  ...this.coreToolbarActions("selection", o)
1249
- ].map((m) => this.projectActionVisibility(m));
1387
+ ].map((p) => this.projectActionVisibility(p));
1250
1388
  }
1251
1389
  getToolbarState() {
1252
- var c, h, u;
1253
- const e = this.host.getSelection(), t = e.instanceIds.length, s = (p, v, S = {}) => ({
1254
- id: p,
1390
+ var a, d, u;
1391
+ const e = this.host.getSelection(), t = e.instanceIds.length, s = (m, v, S = {}) => ({
1392
+ id: m,
1255
1393
  scope: "scene",
1256
1394
  visible: !0,
1257
1395
  enabled: v && !this.gestureActive(),
@@ -1259,10 +1397,10 @@ class it {
1259
1397
  targetIds: [],
1260
1398
  execution: "atomic",
1261
1399
  ...this.gestureActive() ? { reason: { code: "GESTURE_ACTIVE" } } : v ? {} : { reason: {
1262
- code: p === "camera.fit" ? "SCENE_EMPTY" : this.session.isSimulationRunning() ? "SIMULATION_RUNNING" : this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : this.editingEnabled ? p.startsWith("history.") ? "HISTORY_EMPTY" : "CAPABILITY_UNAVAILABLE" : "EDITING_DISABLED"
1400
+ code: m === "camera.fit" ? "SCENE_EMPTY" : this.session.isSimulationRunning() ? "SIMULATION_RUNNING" : this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : this.editingEnabled ? m.startsWith("history.") ? "HISTORY_EMPTY" : "CAPABILITY_UNAVAILABLE" : "EDITING_DISABLED"
1263
1401
  } },
1264
1402
  ...S
1265
- }), o = this.host.getHistoryState(), n = ((c = this.sceneStatus) == null ? void 0 : c.physics.status) === "ready", d = this.session.isSimulationRunning(), a = this.editingEnabled && !this.previewMode && !this.previewDocument && !d, i = {
1403
+ }), o = this.host.getHistoryState(), n = ((a = this.sceneStatus) == null ? void 0 : a.physics.status) === "ready", h = this.session.isSimulationRunning(), l = this.editingEnabled && !this.previewMode && !this.previewDocument && !h, i = {
1266
1404
  sceneSessionId: this.sceneSessionId,
1267
1405
  selectionVersion: this.selectionVersion,
1268
1406
  sequence: this.overlaySequence,
@@ -1281,23 +1419,23 @@ class it {
1281
1419
  typeCounts: this.selectionTypeCounts(e.instanceIds)
1282
1420
  },
1283
1421
  scene: { visible: !0, actions: [
1284
- s("selection.click", a, { active: !this.boxSelectionEnabled }),
1285
- s("selection.box", a, { active: this.boxSelectionEnabled }),
1286
- s("camera.fit", (((h = this.sceneStatus) == null ? void 0 : h.instances.length) ?? 0) > 0),
1287
- s("tools.snap", a, { active: this.snap, valueState: this.snap ? "on" : "off" }),
1422
+ s("selection.click", l, { active: !this.boxSelectionEnabled }),
1423
+ s("selection.box", l, { active: this.boxSelectionEnabled }),
1424
+ s("camera.fit", (((d = this.sceneStatus) == null ? void 0 : d.instances.length) ?? 0) > 0),
1425
+ s("tools.snap", l, { active: this.snap, valueState: this.snap ? "on" : "off" }),
1288
1426
  s("viewport.ground", !0, { active: this.groundVisible, valueState: this.groundVisible ? "on" : "off" }),
1289
- s("history.undo", a && o.canUndo),
1290
- s("history.redo", a && o.canRedo),
1427
+ s("history.undo", l && o.canUndo),
1428
+ s("history.redo", l && o.canRedo),
1291
1429
  s("viewport.collision", !0, { active: this.collisionVisible, valueState: this.collisionVisible ? "on" : "off" }),
1292
- s("simulation.play", n && !d, { active: d }),
1293
- s("simulation.pause", n && d, { active: !d && n }),
1294
- s("simulation.step", n && !d),
1430
+ s("simulation.play", n && !h, { active: h }),
1431
+ s("simulation.pause", n && h, { active: !h && n }),
1432
+ s("simulation.step", n && !h),
1295
1433
  s("simulation.reset", n),
1296
- s("simulation.stop", n && (d || (((u = this.sceneStatus) == null ? void 0 : u.instances.length) ?? 0) > 0))
1297
- ].filter((p) => {
1434
+ s("simulation.stop", n && (h || (((u = this.sceneStatus) == null ? void 0 : u.instances.length) ?? 0) > 0))
1435
+ ].filter((m) => {
1298
1436
  var v;
1299
- return ((v = this.actionDefinitions.get(p.id)) == null ? void 0 : v.scope) === "scene";
1300
- }).concat(this.registeredToolbarActions("scene", [])).concat(this.coreToolbarActions("scene", [])).map((p) => this.projectActionVisibility(p)) },
1437
+ return ((v = this.actionDefinitions.get(m.id)) == null ? void 0 : v.scope) === "scene";
1438
+ }).concat(this.registeredToolbarActions("scene", [])).concat(this.coreToolbarActions("scene", [])).map((m) => this.projectActionVisibility(m)) },
1301
1439
  object: { actions: this.getNodeActions(e.instanceIds), overlay: i }
1302
1440
  };
1303
1441
  }
@@ -1307,7 +1445,7 @@ class it {
1307
1445
  if (e.expectedSceneSessionId !== t.sceneSessionId)
1308
1446
  throw new g("CONTEXT_STALE", "The scene session has changed.");
1309
1447
  const s = [...t.scene.actions, ...t.object.actions].find(
1310
- (a) => a.id === e.actionId
1448
+ (l) => l.id === e.actionId
1311
1449
  );
1312
1450
  if (s != null && s.busy)
1313
1451
  throw new g("ACTION_BUSY", "Action is already running: " + e.actionId);
@@ -1318,7 +1456,7 @@ class it {
1318
1456
  );
1319
1457
  if (s.scope === "selection" && e.expectedSelectionVersion !== t.selection.version)
1320
1458
  throw new g("CONTEXT_STALE", "The selection has changed.");
1321
- if (!J(e.targetIds, s.targetIds))
1459
+ if (!se(e.targetIds, s.targetIds))
1322
1460
  throw new g("CONTEXT_STALE", "The action targets have changed.");
1323
1461
  const o = this.actionDefinitions.get(e.actionId);
1324
1462
  if (o) {
@@ -1327,23 +1465,23 @@ class it {
1327
1465
  "ACTION_SCOPE_MISMATCH",
1328
1466
  `Action scope changed: ${e.actionId}`
1329
1467
  );
1330
- const a = new AbortController();
1331
- this.actionControllers.set(e.actionId, a), this.changed();
1468
+ const l = new AbortController();
1469
+ this.actionControllers.set(e.actionId, l), this.changed();
1332
1470
  const i = this.getSnapshot();
1333
- let c = !1;
1471
+ let a = !1;
1334
1472
  try {
1335
1473
  return await o.execute(
1336
1474
  {
1337
1475
  editor: this.actionReader,
1338
1476
  snapshot: i,
1339
- signal: a.signal,
1340
- commit: (h) => {
1341
- if (this.assertEditable(), a.signal.aborted || this.actionControllers.get(e.actionId) !== a)
1477
+ signal: l.signal,
1478
+ commit: (d) => {
1479
+ if (this.assertEditable(), l.signal.aborted || this.actionControllers.get(e.actionId) !== l)
1342
1480
  throw new g(
1343
1481
  "ACTION_CANCELLED",
1344
1482
  "The action has been cancelled or unloaded."
1345
1483
  );
1346
- if (c)
1484
+ if (a)
1347
1485
  throw new g(
1348
1486
  "ACTION_ALREADY_COMMITTED",
1349
1487
  "An action commits one atomic transaction."
@@ -1351,49 +1489,49 @@ class it {
1351
1489
  const u = this.host.getSnapshot();
1352
1490
  if (u.sceneEpoch !== i.host.sceneEpoch || u.documentVersion !== i.host.documentVersion)
1353
1491
  throw new g("CONTEXT_STALE", "Action document context changed.");
1354
- if (s.scope === "selection" && (u.selectionVersion !== i.host.selectionVersion || !J(
1492
+ if (s.scope === "selection" && (u.selectionVersion !== i.host.selectionVersion || !se(
1355
1493
  this.host.getSelection().instanceIds,
1356
1494
  i.host.selection.instanceIds
1357
1495
  )))
1358
1496
  throw new g("CONTEXT_STALE", "Action selection changed.");
1359
- const p = this.host.commit({
1360
- commands: h,
1497
+ const m = this.host.commit({
1498
+ commands: d,
1361
1499
  expectedSceneEpoch: i.host.sceneEpoch,
1362
1500
  expectedDocumentVersion: i.host.documentVersion,
1363
1501
  ...s.scope === "selection" ? { expectedSelectionVersion: i.host.selectionVersion } : {}
1364
1502
  });
1365
- return c = p.changed, p;
1503
+ return a = m.changed, m;
1366
1504
  }
1367
1505
  },
1368
1506
  e
1369
1507
  );
1370
1508
  } finally {
1371
- this.actionControllers.get(e.actionId) === a && this.actionControllers.delete(e.actionId), this.changed();
1509
+ this.actionControllers.get(e.actionId) === l && this.actionControllers.delete(e.actionId), this.changed();
1372
1510
  }
1373
1511
  }
1374
- if (!this.host.getActions().find((a) => a.id === e.actionId && a.scope === s.scope))
1512
+ if (!this.host.getActions().find((l) => l.id === e.actionId && l.scope === s.scope))
1375
1513
  throw new g("ACTION_UNKNOWN", `Unknown action: ${e.actionId}`);
1376
- const d = new AbortController();
1377
- this.actionControllers.set(e.actionId, d), this.coreActionBusy.add(e.actionId), this.changed();
1514
+ const h = new AbortController();
1515
+ this.actionControllers.set(e.actionId, h), this.coreActionBusy.add(e.actionId), this.changed();
1378
1516
  try {
1379
- const a = this.getToolbarState(), i = [...a.scene.actions, ...a.object.actions].find(
1380
- (h) => h.id === e.actionId
1517
+ const l = this.getToolbarState(), i = [...l.scene.actions, ...l.object.actions].find(
1518
+ (d) => d.id === e.actionId
1381
1519
  );
1382
- if (!(i != null && i.enabled) || a.sceneSessionId !== e.expectedSceneSessionId || i.scope === "selection" && a.selection.version !== e.expectedSelectionVersion || !J(i.targetIds, e.targetIds))
1520
+ if (!(i != null && i.enabled) || l.sceneSessionId !== e.expectedSceneSessionId || i.scope === "selection" && l.selection.version !== e.expectedSelectionVersion || !se(i.targetIds, e.targetIds))
1383
1521
  throw new g(
1384
1522
  "CONTEXT_STALE",
1385
1523
  "The action context changed before execution."
1386
1524
  );
1387
- const c = this.getSnapshot().host;
1525
+ const a = this.getSnapshot().host;
1388
1526
  return await this.host.runAction(e.actionId, e, {
1389
- signal: d.signal,
1390
- expectedDocumentVersion: c.documentVersion,
1391
- expectedSceneEpoch: c.sceneEpoch,
1392
- expectedSelectionVersion: c.selectionVersion,
1527
+ signal: h.signal,
1528
+ expectedDocumentVersion: a.documentVersion,
1529
+ expectedSceneEpoch: a.sceneEpoch,
1530
+ expectedSelectionVersion: a.selectionVersion,
1393
1531
  targetIds: i.targetIds
1394
1532
  });
1395
1533
  } finally {
1396
- this.actionControllers.get(e.actionId) === d && this.actionControllers.delete(e.actionId), this.coreActionBusy.delete(e.actionId), this.changed();
1534
+ this.actionControllers.get(e.actionId) === h && this.actionControllers.delete(e.actionId), this.coreActionBusy.delete(e.actionId), this.changed();
1397
1535
  }
1398
1536
  }
1399
1537
  dispose() {
@@ -1424,10 +1562,10 @@ class it {
1424
1562
  }
1425
1563
  editableTargets(e) {
1426
1564
  const t = this.host.getSnapshot().editorial;
1427
- return this.selectionClosure(e).filter((s) => k(this.host.document.root, s.nodeId, t) && !X(this.host.document.root, s.nodeId, t));
1565
+ return this.selectionClosure(e).filter((s) => F(this.host.document.root, s.nodeId, t) && !X(this.host.document.root, s.nodeId, t));
1428
1566
  }
1429
1567
  assertProjectionRepresentable(e) {
1430
- const t = new Set(ue(this.host.document.root).map(fe)), s = ue(e).find((o) => !t.has(fe(o)));
1568
+ const t = new Set(Se(this.host.document.root).map(be)), s = Se(e).find((o) => !t.has(be(o)));
1431
1569
  if (s)
1432
1570
  throw new g(
1433
1571
  "TRANSFORM_NOT_REPRESENTABLE",
@@ -1436,29 +1574,29 @@ class it {
1436
1574
  }
1437
1575
  selectionClosure(e) {
1438
1576
  const t = [...new Set(e)], s = new Set(t);
1439
- return t.map((o) => y(this.host.document.root, o)).filter((o) => o !== null).filter((o) => !ke(this.host.document.root, o.nodeId).slice(0, -1).some((n) => s.has(n.nodeId)));
1577
+ return t.map((o) => w(this.host.document.root, o)).filter((o) => o !== null).filter((o) => !Ke(this.host.document.root, o.nodeId).slice(0, -1).some((n) => s.has(n.nodeId)));
1440
1578
  }
1441
1579
  removableGroupIds(e) {
1442
1580
  var s;
1443
1581
  const t = /* @__PURE__ */ new Set();
1444
1582
  for (const o of e) {
1445
- const n = y(this.host.document.root, o);
1583
+ const n = w(this.host.document.root, o);
1446
1584
  if ((n == null ? void 0 : n.nodeType) === "group") {
1447
1585
  t.add(o);
1448
1586
  continue;
1449
1587
  }
1450
- const d = (s = H(this.host.document.root, o)) == null ? void 0 : s.parent;
1451
- d && d.nodeId !== this.host.document.root.nodeId && d.nodeType === "group" && t.add(d.nodeId);
1588
+ const h = (s = Q(this.host.document.root, o)) == null ? void 0 : s.parent;
1589
+ h && h.nodeId !== this.host.document.root.nodeId && h.nodeType === "group" && t.add(h.nodeId);
1452
1590
  }
1453
1591
  return [...t];
1454
1592
  }
1455
1593
  sceneInstances() {
1456
- return V(this.host.document.root);
1594
+ return R(this.host.document.root);
1457
1595
  }
1458
1596
  selectionTypeCounts(e) {
1459
1597
  const t = {};
1460
1598
  for (const s of e) {
1461
- const o = y(this.host.document.root, s);
1599
+ const o = w(this.host.document.root, s);
1462
1600
  if (!o) continue;
1463
1601
  const n = o.nodeType === "group" ? "group" : o.nodeType === "visual" ? "visual-instance" : o.nodeType === "placeholder" ? "placeholder" : o.nodeType === "domain" ? "domain-instance" : "asset-instance";
1464
1602
  t[n] = (t[n] ?? 0) + 1;
@@ -1474,8 +1612,8 @@ class it {
1474
1612
  };
1475
1613
  e("tools.translate", "selection", () => this.setMode("translate")), e("tools.rotate", "selection", () => this.setMode("rotate")), e("tools.scale", "selection", () => this.setMode("scale")), e("nodes.duplicate", "selection", (t, s) => this.duplicateSelection(s.targetIds)), e("nodes.remove", "selection", (t, s) => this.deleteSelection(s.targetIds)), e("nodes.group", "selection", (t, s) => this.groupSelection(s.targetIds)), e("nodes.ungroup", "selection", (t, s) => this.ungroupSelection(s.targetIds)), e("nodes.hide", "selection", (t, s) => this.hideNodes(s.targetIds)), e("nodes.visibility", "selection", (t, s) => {
1476
1614
  const o = s.targetIds.flatMap((n) => {
1477
- const d = y(this.host.document.root, n);
1478
- return (d == null ? void 0 : d.nodeType) === "group" ? V(d) : d ? [d] : [];
1615
+ const h = w(this.host.document.root, n);
1616
+ return (h == null ? void 0 : h.nodeType) === "group" ? R(h) : h ? [h] : [];
1479
1617
  });
1480
1618
  return this.setNodesVisible(s.targetIds, !o.filter((n) => "visible" in n).every((n) => "visible" in n && n.visible));
1481
1619
  }), e("camera.focus", "selection", (t, s) => this.session.focusNodes(s.targetIds)), e("nodes.lock", "selection", (t, s) => {
@@ -1494,10 +1632,10 @@ class it {
1494
1632
  gestureActive: this.gestureActive()
1495
1633
  };
1496
1634
  return [...this.actionDefinitions.values()].filter((o) => o.scope === e && o.getState).map((o) => {
1497
- const n = o.getState(s), d = e === "selection" ? this.selectionClosure(n.targetIds).map((a) => a.nodeId) : n.targetIds;
1635
+ const n = o.getState(s), h = e === "selection" ? this.selectionClosure(n.targetIds).map((l) => l.nodeId) : n.targetIds;
1498
1636
  return {
1499
1637
  ...n,
1500
- targetIds: d,
1638
+ targetIds: h,
1501
1639
  busy: n.busy || this.actionControllers.has(o.id)
1502
1640
  };
1503
1641
  }).filter((o) => o.scope === e);
@@ -1505,16 +1643,16 @@ class it {
1505
1643
  coreToolbarActions(e, t) {
1506
1644
  const s = this.editingEnabled && !this.previewMode && !this.previewDocument, o = this.gestureActive();
1507
1645
  return this.host.getActions().filter((n) => n.scope === e).map((n) => {
1508
- const d = e === "selection" ? [...t] : [], a = s && !o && (e === "scene" || d.length > 0);
1646
+ const h = e === "selection" ? [...t] : [], l = s && !o && (e === "scene" || h.length > 0);
1509
1647
  return {
1510
1648
  id: n.id,
1511
1649
  scope: e,
1512
1650
  visible: !0,
1513
- enabled: a,
1651
+ enabled: l,
1514
1652
  busy: this.coreActionBusy.has(n.id),
1515
- targetIds: d,
1653
+ targetIds: h,
1516
1654
  execution: n.scope === "selection" ? "eligible-subset" : "atomic",
1517
- ...a ? {} : {
1655
+ ...l ? {} : {
1518
1656
  reason: {
1519
1657
  code: this.previewMode || this.previewDocument ? "PREVIEW_READ_ONLY" : this.editingEnabled ? o ? "GESTURE_ACTIVE" : "NO_EDITABLE_TARGETS" : "EDITING_DISABLED"
1520
1658
  }
@@ -1570,186 +1708,285 @@ class it {
1570
1708
  }
1571
1709
  }
1572
1710
  }
1573
- function ee(l) {
1574
- return l ? l.nodeType === "group" ? [l.nodeId, ...l.children.flatMap((e) => ee(e))] : [l.nodeId] : [];
1711
+ function re(r) {
1712
+ return r ? r.nodeType === "group" ? [r.nodeId, ...r.children.flatMap((e) => re(e))] : [r.nodeId] : [];
1575
1713
  }
1576
- function nt(l) {
1577
- if (!Array.isArray(l.local) || l.local.length !== 3 || l.local.some((e) => !Number.isFinite(e)))
1714
+ function ut(r) {
1715
+ if (!Array.isArray(r.local) || r.local.length !== 3 || r.local.some((e) => !Number.isFinite(e)))
1578
1716
  throw new g(
1579
1717
  "ORIGIN_OFFSET_INVALID",
1580
1718
  "Node origin.local must contain three finite source-content metre values."
1581
1719
  );
1582
1720
  }
1583
- function Z(l, e, t) {
1584
- return e && Number.isFinite(t) ? [{ movedNodeId: l, supportNodeId: e, surfaceZ: t }] : [];
1721
+ function te(r, e, t) {
1722
+ return e && Number.isFinite(t) ? [{ movedNodeId: r, supportNodeId: e, surfaceZ: t }] : [];
1585
1723
  }
1586
- function fe(l) {
1587
- return `${l.parentNodeId}\0${l.nodeId}`;
1724
+ function be(r) {
1725
+ return `${r.parentNodeId}\0${r.nodeId}`;
1588
1726
  }
1589
- function J(l, e) {
1590
- const t = new Set(l), s = new Set(e);
1727
+ function se(r, e) {
1728
+ const t = new Set(r), s = new Set(e);
1591
1729
  return t.size === s.size && [...t].every((o) => s.has(o));
1592
1730
  }
1593
- function vt(l, e) {
1594
- return new it(l, e);
1731
+ function Tt(r, e) {
1732
+ return new ht(r, e);
1595
1733
  }
1596
- function rt(l) {
1734
+ function pt(r) {
1597
1735
  return {
1598
1736
  schemaVersion: 1,
1599
- viewMode: l.viewMode,
1600
- ...l.orbit ? { orbit: { ...l.orbit } } : {},
1601
- ...l.orthographic ? { orthographic: { ...l.orthographic } } : {}
1737
+ viewMode: r.viewMode,
1738
+ ...r.orbit ? { orbit: { ...r.orbit } } : {},
1739
+ ...r.orthographic ? { orthographic: { ...r.orthographic } } : {}
1602
1740
  };
1603
1741
  }
1604
- const at = 1;
1605
- function It(l) {
1606
- const { editor: e } = l, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1607
- let o = !1, n = !1, d, a = 0;
1608
- function i(r) {
1742
+ function oe(r, e, t = {}) {
1743
+ var o;
1744
+ const s = r.createStateSnapshot();
1745
+ return {
1746
+ format: "sim-studio.session@1",
1747
+ schemaVersion: 1,
1748
+ documentText: s.documentText,
1749
+ documentHash: s.documentHash,
1750
+ editorial: e.captureEditorialState(),
1751
+ assetClosure: ((o = t.assetClosure) == null ? void 0 : o.call(t)) ?? null
1752
+ };
1753
+ }
1754
+ async function mt(r, e, t, s = {}) {
1755
+ var n, h;
1756
+ we(t), await r.ready(), await e.ready, (n = s.signal) == null || n.throwIfAborted();
1757
+ const o = await r.openSceneText(
1758
+ t.documentText,
1759
+ s.sources ?? [],
1760
+ s.signal ? { signal: s.signal } : {}
1761
+ );
1762
+ if (!o.ok)
1763
+ throw new Error(o.diagnostics.map((l) => l.message).join(`
1764
+ `));
1765
+ (h = s.signal) == null || h.throwIfAborted(), await e.sync(), e.applyEditorialState(t.editorial);
1766
+ }
1767
+ function Nt(r) {
1768
+ let e = null, t = !1, s = null;
1769
+ const o = {
1770
+ adapter: r.adapter,
1771
+ capture: () => oe(r.host, r.editor, {
1772
+ ...r.assetClosure ? { assetClosure: r.assetClosure } : {}
1773
+ }),
1774
+ currentSignature: () => Ze(
1775
+ oe(r.host, r.editor, {
1776
+ ...r.assetClosure ? { assetClosure: r.assetClosure } : {}
1777
+ })
1778
+ ),
1779
+ ...r.autosaveDelayMs !== void 0 ? { autosaveDelayMs: r.autosaveDelayMs } : {},
1780
+ ...r.now ? { now: r.now } : {},
1781
+ ...r.createId ? { createId: r.createId } : {},
1782
+ ...r.onState ? { onState: r.onState } : {}
1783
+ }, n = new nt(o), h = () => {
1784
+ e || r.trackEditorChanges === !1 || (e = r.editor.subscribe((a) => {
1785
+ a.type === "host.change" && ft(a.event) && n.scheduleAutosave();
1786
+ }));
1787
+ }, l = async (a = {}) => {
1788
+ var m;
1789
+ await r.editor.ready;
1790
+ const d = await r.adapter.load(
1791
+ a.signal ? { signal: a.signal } : {}
1792
+ );
1793
+ if (!d)
1794
+ return n.restoreBaseline(null), null;
1795
+ we(d.snapshot);
1796
+ const u = a.sources ?? await ((m = r.resolveSources) == null ? void 0 : m.call(r, d, {
1797
+ ...a.signal ? { signal: a.signal } : {}
1798
+ })) ?? [];
1799
+ return await mt(r.host, r.editor, d.snapshot, {
1800
+ ...a.signal ? { signal: a.signal } : {},
1801
+ sources: u
1802
+ }), n.restoreBaseline(d), d;
1803
+ }, i = (async () => {
1804
+ let a = null;
1805
+ return r.autoRestore !== !1 ? a = await l() : await r.editor.ready, h(), t = !0, a;
1806
+ })();
1807
+ return {
1808
+ controller: n,
1809
+ ready: i,
1810
+ capture: () => oe(r.host, r.editor, {
1811
+ ...r.assetClosure ? { assetClosure: r.assetClosure } : {}
1812
+ }),
1813
+ async restore(a) {
1814
+ return await i, l(a);
1815
+ },
1816
+ scheduleAutosave: () => n.scheduleAutosave(),
1817
+ markDirty: () => n.markDirty(),
1818
+ async save(a) {
1819
+ return await i, n.save(a);
1820
+ },
1821
+ async flush(a) {
1822
+ return await i, n.flush(a);
1823
+ },
1824
+ async retry(a) {
1825
+ return await i, n.retry(a);
1826
+ },
1827
+ async dispose(a = {}) {
1828
+ return s || (s = (async () => {
1829
+ e == null || e(), e = null, await i.catch(() => {
1830
+ }), t || n.restoreBaseline(null), await n.dispose(a.closeAdapter ?? !0);
1831
+ })(), s);
1832
+ }
1833
+ };
1834
+ }
1835
+ function ft(r) {
1836
+ return r.type === "document.change" || r.type === "selection.change" || r.type === "editorial.change";
1837
+ }
1838
+ const gt = 1;
1839
+ function Pt(r) {
1840
+ const { editor: e } = r, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1841
+ let o = !1, n = !1, h, l = 0;
1842
+ function i(c) {
1609
1843
  try {
1610
- l.onError ? l.onError(r) : console.error(`[sim-studio UI plugin ${r.pluginId}] ${r.phase}`, r.error);
1844
+ r.onError ? r.onError(c) : console.error(`[sim-studio UI plugin ${c.pluginId}] ${c.phase}`, c.error);
1611
1845
  } catch {
1612
1846
  }
1613
1847
  }
1614
- function c() {
1848
+ function a() {
1615
1849
  if (n) throw new Error("The Studio UI plugin host has been disposed.");
1616
1850
  }
1617
- function h(r, f, m) {
1851
+ function d(c, f, p) {
1618
1852
  try {
1619
1853
  f();
1620
1854
  } catch (b) {
1621
- i({ pluginId: r.plugin.id, viewId: m, phase: "dispose", error: b });
1855
+ i({ pluginId: c.plugin.id, viewId: p, phase: "dispose", error: b });
1622
1856
  }
1623
1857
  }
1624
- function u(r) {
1625
- if (!r.removed) {
1626
- r.removed = !0, r.active = !1, r.listeners.clear();
1627
- for (const f of [...r.cleanups].reverse()) h(r, f);
1628
- r.cleanups.clear(), t.get(r.plugin.id) === r && t.delete(r.plugin.id);
1858
+ function u(c) {
1859
+ if (!c.removed) {
1860
+ c.removed = !0, c.active = !1, c.listeners.clear();
1861
+ for (const f of [...c.cleanups].reverse()) d(c, f);
1862
+ c.cleanups.clear(), t.get(c.plugin.id) === c && t.delete(c.plugin.id);
1629
1863
  }
1630
1864
  }
1631
- function p(r, f) {
1632
- var C;
1633
- if (r.removed) throw new Error(`Plugin ${r.plugin.id} has been removed.`);
1865
+ function m(c, f) {
1866
+ var L;
1867
+ if (c.removed) throw new Error(`Plugin ${c.plugin.id} has been removed.`);
1634
1868
  if (!f.id.trim()) throw new Error("UI view IDs must be non-empty.");
1635
- const m = JSON.stringify([r.plugin.id, f.id]);
1636
- if (s.has(m)) throw new Error(`Duplicate UI view ${m}.`);
1637
- const b = l.slots[f.slot];
1869
+ const p = JSON.stringify([c.plugin.id, f.id]);
1870
+ if (s.has(p)) throw new Error(`Duplicate UI view ${p}.`);
1871
+ const b = r.slots[f.slot];
1638
1872
  if (!b) throw new Error(`No frontend container provided for UI slot ${f.slot}.`);
1639
- const T = b.ownerDocument.createElement("div");
1640
- T.dataset.studioUiPlugin = r.plugin.id, T.dataset.studioUiView = f.id, T.dataset.studioUiSlot = f.slot;
1641
- const _ = a++, D = [...s.values()].filter((O) => O.contribution.slot === f.slot).sort((O, U) => (O.contribution.order ?? 0) - (U.contribution.order ?? 0) || O.sequence - U.sequence).find((O) => (O.contribution.order ?? 0) > (f.order ?? 0));
1642
- b.insertBefore(T, (D == null ? void 0 : D.container) ?? null);
1873
+ const y = b.ownerDocument.createElement("div");
1874
+ y.dataset.studioUiPlugin = c.plugin.id, y.dataset.studioUiView = f.id, y.dataset.studioUiSlot = f.slot;
1875
+ const O = l++, D = [...s.values()].filter((P) => P.contribution.slot === f.slot).sort((P, $) => (P.contribution.order ?? 0) - ($.contribution.order ?? 0) || P.sequence - $.sequence).find((P) => (P.contribution.order ?? 0) > (f.order ?? 0));
1876
+ b.insertBefore(y, (D == null ? void 0 : D.container) ?? null);
1643
1877
  let N;
1644
1878
  try {
1645
- N = f.mount(T, { editor: e, snapshot: e.getSnapshot() });
1646
- } catch (O) {
1647
- throw T.remove(), i({ pluginId: r.plugin.id, viewId: f.id, phase: "mount", error: O }), O;
1879
+ N = f.mount(y, { editor: e, snapshot: e.getSnapshot() });
1880
+ } catch (P) {
1881
+ throw y.remove(), i({ pluginId: c.plugin.id, viewId: f.id, phase: "mount", error: P }), P;
1648
1882
  }
1649
- let F = !1;
1650
- const R = () => {
1651
- if (!F) {
1652
- F = !0, s.delete(m), r.cleanups.delete(R);
1883
+ let G = !1;
1884
+ const V = () => {
1885
+ if (!G) {
1886
+ G = !0, s.delete(p), c.cleanups.delete(V);
1653
1887
  try {
1654
1888
  typeof N == "function" ? N() : N == null || N.dispose();
1655
1889
  } finally {
1656
- T.remove();
1890
+ y.remove();
1657
1891
  }
1658
1892
  }
1659
- }, z = {
1660
- owner: r,
1893
+ }, H = {
1894
+ owner: c,
1661
1895
  contribution: f,
1662
- container: T,
1663
- sequence: _,
1664
- update: typeof N == "object" && N ? (C = N.update) == null ? void 0 : C.bind(N) : void 0,
1665
- dispose: R
1896
+ container: y,
1897
+ sequence: O,
1898
+ update: typeof N == "object" && N ? (L = N.update) == null ? void 0 : L.bind(N) : void 0,
1899
+ dispose: V
1666
1900
  };
1667
- return s.set(m, z), r.cleanups.add(R), () => h(r, R, f.id);
1901
+ return s.set(p, H), c.cleanups.add(V), () => d(c, V, f.id);
1668
1902
  }
1669
- function v(r) {
1670
- if (!(r.active || r.removed)) {
1671
- r.active = !0;
1903
+ function v(c) {
1904
+ if (!(c.active || c.removed)) {
1905
+ c.active = !0;
1672
1906
  try {
1673
- const f = r.plugin.activate({
1907
+ const f = c.plugin.activate({
1674
1908
  editor: e,
1675
- contributions: { addView: (m) => p(r, m) },
1909
+ contributions: { addView: (p) => m(c, p) },
1676
1910
  events: {
1677
- subscribe(m) {
1678
- if (r.removed) throw new Error(`Plugin ${r.plugin.id} has been removed.`);
1679
- return r.listeners.add(m), () => {
1680
- r.listeners.delete(m);
1911
+ subscribe(p) {
1912
+ if (c.removed) throw new Error(`Plugin ${c.plugin.id} has been removed.`);
1913
+ return c.listeners.add(p), () => {
1914
+ c.listeners.delete(p);
1681
1915
  };
1682
1916
  }
1683
1917
  }
1684
1918
  });
1685
- f && r.cleanups.add(f);
1919
+ f && c.cleanups.add(f);
1686
1920
  } catch (f) {
1687
- throw u(r), i({ pluginId: r.plugin.id, phase: "activate", error: f }), f;
1921
+ throw u(c), i({ pluginId: c.plugin.id, phase: "activate", error: f }), f;
1688
1922
  }
1689
1923
  }
1690
1924
  }
1691
- function S(r) {
1925
+ function S(c) {
1692
1926
  if (n) return;
1693
1927
  const f = e.getSnapshot();
1694
- for (const m of [...s.values()])
1695
- if (!(m.owner.removed || !m.update))
1928
+ for (const p of [...s.values()])
1929
+ if (!(p.owner.removed || !p.update))
1696
1930
  try {
1697
- m.update({ editor: e, snapshot: f });
1931
+ p.update({ editor: e, snapshot: f });
1698
1932
  } catch (b) {
1699
- i({ pluginId: m.owner.plugin.id, viewId: m.contribution.id, phase: "update", error: b }), h(m.owner, m.dispose, m.contribution.id);
1933
+ i({ pluginId: p.owner.plugin.id, viewId: p.contribution.id, phase: "update", error: b }), d(p.owner, p.dispose, p.contribution.id);
1700
1934
  }
1701
- for (const m of [...t.values()])
1702
- if (!(!m.active || m.removed))
1703
- for (const b of [...m.listeners]) {
1704
- if (m.removed) break;
1935
+ for (const p of [...t.values()])
1936
+ if (!(!p.active || p.removed))
1937
+ for (const b of [...p.listeners]) {
1938
+ if (p.removed) break;
1705
1939
  try {
1706
- b(r);
1707
- } catch (T) {
1708
- i({ pluginId: m.plugin.id, phase: "event", error: T });
1940
+ b(c);
1941
+ } catch (y) {
1942
+ i({ pluginId: p.plugin.id, phase: "event", error: y });
1709
1943
  }
1710
1944
  }
1711
1945
  }
1712
1946
  return {
1713
- register(r) {
1714
- if (c(), !r.id.trim()) throw new Error("UI plugin IDs must be non-empty.");
1715
- if (r.apiVersion !== at)
1716
- throw new Error(`Unsupported UI plugin API version for ${r.id}: ${r.apiVersion}.`);
1717
- if (t.has(r.id)) throw new Error(`Duplicate UI plugin ${r.id}.`);
1947
+ register(c) {
1948
+ if (a(), !c.id.trim()) throw new Error("UI plugin IDs must be non-empty.");
1949
+ if (c.apiVersion !== gt)
1950
+ throw new Error(`Unsupported UI plugin API version for ${c.id}: ${c.apiVersion}.`);
1951
+ if (t.has(c.id)) throw new Error(`Duplicate UI plugin ${c.id}.`);
1718
1952
  const f = {
1719
- plugin: r,
1953
+ plugin: c,
1720
1954
  cleanups: /* @__PURE__ */ new Set(),
1721
1955
  listeners: /* @__PURE__ */ new Set(),
1722
1956
  active: !1,
1723
1957
  removed: !1
1724
1958
  };
1725
- return t.set(r.id, f), o && v(f), () => u(f);
1959
+ return t.set(c.id, f), o && v(f), () => u(f);
1726
1960
  },
1727
1961
  start() {
1728
- if (c(), o) return;
1962
+ if (a(), o) return;
1729
1963
  o = !0;
1730
- const r = [];
1964
+ const c = [];
1731
1965
  for (const f of [...t.values()])
1732
1966
  try {
1733
1967
  v(f);
1734
- } catch (m) {
1735
- r.push(m);
1968
+ } catch (p) {
1969
+ c.push(p);
1736
1970
  }
1737
- if (d = e.subscribe(S), r.length) throw new AggregateError(r, "One or more Studio UI plugins failed to activate.");
1971
+ if (h = e.subscribe(S), c.length) throw new AggregateError(c, "One or more Studio UI plugins failed to activate.");
1738
1972
  },
1739
1973
  dispose() {
1740
1974
  if (!n) {
1741
- n = !0, d == null || d(), d = void 0;
1742
- for (const r of [...t.values()].reverse()) u(r);
1975
+ n = !0, h == null || h(), h = void 0;
1976
+ for (const c of [...t.values()].reverse()) u(c);
1743
1977
  }
1744
1978
  }
1745
1979
  };
1746
1980
  }
1747
1981
  export {
1748
- at as STUDIO_UI_PLUGIN_API_VERSION,
1749
- it as StudioEditor,
1982
+ gt as STUDIO_UI_PLUGIN_API_VERSION,
1983
+ ht as StudioEditor,
1750
1984
  g as StudioEditorError,
1751
- vt as createStudioEditor,
1752
- It as createStudioUiPluginHost,
1753
- ve as sceneSourceFromResolution,
1754
- st as visualSceneSourceFromResolution
1985
+ oe as captureStudioSessionSnapshot,
1986
+ Tt as createStudioEditor,
1987
+ Nt as createStudioSessionPersistence,
1988
+ Pt as createStudioUiPluginHost,
1989
+ mt as restoreStudioSessionSnapshot,
1990
+ Ee as sceneSourceFromResolution,
1991
+ lt as visualSceneSourceFromResolution
1755
1992
  };