@nebula-spatial/viewer 0.5.16 → 0.5.17

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.
@@ -1,31 +1,31 @@
1
- function Pe(e, t) {
2
- return /^https?:$/.test(t.protocol) && e.origin === t.origin && !e.username && !e.password && pe(e.pathname).startsWith(pe(new URL(".", t).pathname));
1
+ function Ie(e, t) {
2
+ return /^https?:$/.test(t.protocol) && e.origin === t.origin && !e.username && !e.password && ge(e.pathname).startsWith(ge(new URL(".", t).pathname));
3
3
  }
4
- function pe(e) {
4
+ function ge(e) {
5
5
  return e.endsWith("/") ? e : e.slice(0, e.lastIndexOf("/") + 1);
6
6
  }
7
- function Ve(e, t) {
8
- for (const n of e) for (const o of n.shaders) for (const i of Object.values(o.inputs)) {
9
- if (!i || typeof i != "object" || Array.isArray(i)) continue;
10
- const s = i, r = [s.path, s.url, s.resolvedPath].find((c) => typeof c == "string" && c);
11
- !r || /^(?:data|blob):/i.test(r) || /\.mdl(?:[?#].*)?$/i.test(r) || t(s, r);
7
+ function Be(e, t) {
8
+ for (const n of e) for (const s of n.shaders) for (const a of Object.values(s.inputs)) {
9
+ if (!a || typeof a != "object" || Array.isArray(a)) continue;
10
+ const o = a, r = [o.path, o.url, o.resolvedPath].find((c) => typeof c == "string" && c);
11
+ !r || /^(?:data|blob):/i.test(r) || /\.mdl(?:[?#].*)?$/i.test(r) || t(o, r);
12
12
  }
13
13
  }
14
- function Ge(e, t, n) {
15
- const o = [];
14
+ function Fe(e, t, n) {
15
+ const s = [];
16
16
  try {
17
- return Ve(e, (i, s) => {
18
- if (t(s)) return;
17
+ return Be(e, (a, o) => {
18
+ if (t(o)) return;
19
19
  const r = {};
20
20
  for (const c of ["path", "resolvedPath", "url"])
21
- c in i && (r[c] = i[c], delete i[c]);
22
- o.push({ asset: i, values: r });
21
+ c in a && (r[c] = a[c], delete a[c]);
22
+ s.push({ asset: a, values: r });
23
23
  }), n();
24
24
  } finally {
25
- for (const { asset: i, values: s } of o) Object.assign(i, s);
25
+ for (const { asset: a, values: o } of s) Object.assign(a, o);
26
26
  }
27
27
  }
28
- const Be = "E_ASSET_RESOURCE_NOT_FOUND", Ie = "E_ASSET_RESOURCE_INVALID", Fe = "E_ASSET_FETCH", ze = "E_ASSET_EXTERNAL_DENIED", He = "E_ASSET_AUTH", We = /* @__PURE__ */ new Set([
28
+ const ze = "E_ASSET_RESOURCE_NOT_FOUND", Ae = "E_ASSET_RESOURCE_INVALID", We = "E_ASSET_FETCH", He = "E_ASSET_EXTERNAL_DENIED", Xe = "E_ASSET_AUTH", Je = /* @__PURE__ */ new Set([
29
29
  "png",
30
30
  "jpg",
31
31
  "jpeg",
@@ -38,82 +38,82 @@ const Be = "E_ASSET_RESOURCE_NOT_FOUND", Ie = "E_ASSET_RESOURCE_INVALID", Fe = "
38
38
  "hdr",
39
39
  "exr",
40
40
  "ktx2"
41
- ]), Je = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
42
- function Xe(e) {
41
+ ]), qe = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
42
+ function Ze(e) {
43
43
  var n;
44
44
  return ((n = (e.split(/[?#]/, 1)[0] ?? e).split(".").pop()) == null ? void 0 : n.toLowerCase()) ?? "";
45
45
  }
46
- function qe(e) {
47
- const t = Xe(e);
48
- return We.has(t) && !Je.has(t);
46
+ function Ye(e) {
47
+ const t = Ze(e);
48
+ return Je.has(t) && !qe.has(t);
49
49
  }
50
- function Ze(e, t) {
50
+ function Ke(e, t) {
51
51
  return Object.assign(new Error(e), { code: t });
52
52
  }
53
- function Ye(e) {
54
- var o;
53
+ function Qe(e) {
54
+ var s;
55
55
  if (e instanceof Error && e.name === "AbortError") return "aborted";
56
56
  const t = e == null ? void 0 : e.code;
57
- if (t === Be) return "missing";
58
- if (t === Ie) return "invalid";
59
- if (t === Fe) return "unavailable";
60
- if (t === He || t === ze) return "denied";
61
- const n = (o = /\((\d{3})\)/.exec(e instanceof Error ? e.message : "")) == null ? void 0 : o[1];
57
+ if (t === ze) return "missing";
58
+ if (t === Ae) return "invalid";
59
+ if (t === We) return "unavailable";
60
+ if (t === Xe || t === He) return "denied";
61
+ const n = (s = /\((\d{3})\)/.exec(e instanceof Error ? e.message : "")) == null ? void 0 : s[1];
62
62
  return n === "404" || n === "410" ? "missing" : n === "401" || n === "403" ? "denied" : n != null && n.startsWith("5") ? "unavailable" : "unknown";
63
63
  }
64
- function Ke(e) {
65
- const t = Ye(e);
64
+ function et(e) {
65
+ const t = Qe(e);
66
66
  return t === "missing" || t === "invalid" || t === "unavailable";
67
67
  }
68
- function Qe(e, t) {
68
+ function tt(e, t) {
69
69
  return e && /\bhtml\b/i.test(e) ? `返回 HTML 页面(${e})` : e && !/^text\//i.test(e) ? null : /^\uFEFF?\s*(?:<!doctype\s+html|<html|<\?xml[^>]*\bhtml)/i.test(t) ? "返回 HTML 兜底页" : null;
70
70
  }
71
- function et(e, t) {
72
- return t.byteLength ? Qe(e, new TextDecoder().decode(t.subarray(0, 512))) : "响应内容为空";
73
- }
74
- const tt = /<UDIM>/i;
75
71
  function nt(e, t) {
76
- const n = ge(e).replaceAll("\\", "/");
77
- if (!tt.test(n)) return null;
78
- const o = me(n), i = o.split("/").at(-1);
79
- if (!i) return { paths: [], tiles: [] };
80
- const s = rt(i);
81
- if (!s) return { paths: [], tiles: [] };
72
+ return t.byteLength ? tt(e, new TextDecoder().decode(t.subarray(0, 512))) : "响应内容为空";
73
+ }
74
+ const rt = /<UDIM>/i;
75
+ function st(e, t) {
76
+ const n = me(e).replaceAll("\\", "/");
77
+ if (!rt.test(n)) return null;
78
+ const s = we(n), a = s.split("/").at(-1);
79
+ if (!a) return { paths: [], tiles: [] };
80
+ const o = ot(a);
81
+ if (!o) return { paths: [], tiles: [] };
82
82
  const r = [];
83
83
  for (const l of new Set(t)) {
84
- const p = ge(l).replaceAll("\\", "/"), g = me(p), u = g.split("/").at(-1);
84
+ const p = me(l).replaceAll("\\", "/"), g = we(p), u = g.split("/").at(-1);
85
85
  if (!u) continue;
86
- const f = s.exec(u);
86
+ const f = o.exec(u);
87
87
  if (!f) continue;
88
88
  const h = Number(f[1]);
89
89
  !Number.isInteger(h) || h < 1001 || h > 9999 || r.push({
90
90
  path: l,
91
91
  tile: h,
92
- score: st(o, g)
92
+ score: at(s, g)
93
93
  });
94
94
  }
95
95
  if (!r.length) return { paths: [], tiles: [] };
96
- const c = Math.max(...r.map((l) => l.score)), a = r.filter((l) => l.score === c).sort((l, p) => l.tile - p.tile || l.path.localeCompare(p.path));
96
+ const c = Math.max(...r.map((l) => l.score)), i = r.filter((l) => l.score === c).sort((l, p) => l.tile - p.tile || l.path.localeCompare(p.path));
97
97
  return {
98
- paths: a.map((l) => l.path),
99
- tiles: a.map((l) => l.tile)
98
+ paths: i.map((l) => l.path),
99
+ tiles: i.map((l) => l.tile)
100
100
  };
101
101
  }
102
- function rt(e) {
102
+ function ot(e) {
103
103
  const t = e.split(/<UDIM>/i);
104
- return t.length !== 2 ? null : new RegExp(`^${we(t[0])}(\\d{4})${we(t[1])}$`, "i");
105
- }
106
- function st(e, t) {
107
- const n = e.split("/").slice(0, -1).filter(Boolean), o = t.split("/").slice(0, -1).filter(Boolean);
108
- let i = 0;
109
- for (; i < n.length && i < o.length; ) {
110
- const s = n.at(-1 - i), r = o.at(-1 - i);
111
- if ((s == null ? void 0 : s.toLowerCase()) !== (r == null ? void 0 : r.toLowerCase())) break;
112
- i += 1;
104
+ return t.length !== 2 ? null : new RegExp(`^${ye(t[0])}(\\d{4})${ye(t[1])}$`, "i");
105
+ }
106
+ function at(e, t) {
107
+ const n = e.split("/").slice(0, -1).filter(Boolean), s = t.split("/").slice(0, -1).filter(Boolean);
108
+ let a = 0;
109
+ for (; a < n.length && a < s.length; ) {
110
+ const o = n.at(-1 - a), r = s.at(-1 - a);
111
+ if ((o == null ? void 0 : o.toLowerCase()) !== (r == null ? void 0 : r.toLowerCase())) break;
112
+ a += 1;
113
113
  }
114
- return i;
114
+ return a;
115
115
  }
116
- function ge(e) {
116
+ function me(e) {
117
117
  const t = e.replace(/%3CUDIM%3E/gi, "<UDIM>");
118
118
  try {
119
119
  return decodeURIComponent(t);
@@ -121,101 +121,101 @@ function ge(e) {
121
121
  return t;
122
122
  }
123
123
  }
124
- function me(e) {
124
+ function we(e) {
125
125
  const t = e.search(/[?#]/);
126
126
  return t < 0 ? e : e.slice(0, t);
127
127
  }
128
- function we(e) {
128
+ function ye(e) {
129
129
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
130
130
  }
131
- const ot = 67324752, at = 33639248, it = 101010256, ie = 4294967295, ct = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "webp"]);
132
- function ut(e) {
131
+ const it = 67324752, ct = 33639248, ut = 101010256, ie = 4294967295, lt = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "webp"]);
132
+ function ft(e) {
133
133
  return e.length > 3 && e[0] === 80 && e[1] === 75;
134
134
  }
135
- async function lt(e, t = {}) {
136
- const n = new DataView(e.buffer, e.byteOffset, e.byteLength), o = mt(n);
137
- if (o < 0) throw new Error("Not a zip package: end of central directory not found.");
138
- const i = n.getUint16(o + 10, !0);
139
- let s = n.getUint32(o + 16, !0);
140
- if (i === 65535 || s === ie) throw new Error("ZIP64 usdz packages are not supported.");
135
+ async function dt(e, t = {}) {
136
+ const n = new DataView(e.buffer, e.byteOffset, e.byteLength), s = yt(n);
137
+ if (s < 0) throw new Error("Not a zip package: end of central directory not found.");
138
+ const a = n.getUint16(s + 10, !0);
139
+ let o = n.getUint32(s + 16, !0);
140
+ if (a === 65535 || o === ie) throw new Error("ZIP64 usdz packages are not supported.");
141
141
  const r = /* @__PURE__ */ new Map(), c = [];
142
- for (let a = 0; a < i; a += 1) {
143
- if (s + 46 > n.byteLength || n.getUint32(s, !0) !== at)
144
- throw new Error(`Corrupt zip central directory at entry ${a}.`);
145
- const l = n.getUint16(s + 10, !0), p = n.getUint32(s + 20, !0), g = n.getUint16(s + 28, !0), u = n.getUint16(s + 30, !0), f = n.getUint16(s + 32, !0), h = n.getUint32(s + 42, !0);
142
+ for (let i = 0; i < a; i += 1) {
143
+ if (o + 46 > n.byteLength || n.getUint32(o, !0) !== ct)
144
+ throw new Error(`Corrupt zip central directory at entry ${i}.`);
145
+ const l = n.getUint16(o + 10, !0), p = n.getUint32(o + 20, !0), g = n.getUint16(o + 28, !0), u = n.getUint16(o + 30, !0), f = n.getUint16(o + 32, !0), h = n.getUint32(o + 42, !0);
146
146
  if (p === ie || h === ie)
147
147
  throw new Error("ZIP64 usdz packages are not supported.");
148
- const y = new TextDecoder().decode(e.subarray(s + 46, s + 46 + g));
149
- s += 46 + g + u + f, !y.endsWith("/") && (t.include && !t.include(y) || c.push(dt(e, n, h, p, l).then((w) => ({ name: y, data: w }))));
148
+ const y = new TextDecoder().decode(e.subarray(o + 46, o + 46 + g));
149
+ o += 46 + g + u + f, !y.endsWith("/") && (t.include && !t.include(y) || c.push(pt(e, n, h, p, l).then((w) => ({ name: y, data: w }))));
150
150
  }
151
- for (const { name: a, data: l } of await Promise.all(c)) r.set(a, l);
151
+ for (const { name: i, data: l } of await Promise.all(c)) r.set(i, l);
152
152
  return r;
153
153
  }
154
- function ft(e) {
154
+ function ht(e) {
155
155
  if (typeof URL > "u" || typeof URL.createObjectURL != "function") return null;
156
- const t = new Map([...e].filter(([r]) => Ae(r)));
156
+ const t = new Map([...e].filter(([r]) => Re(r)));
157
157
  if (t.size === 0) return null;
158
158
  const n = /* @__PURE__ */ new Map();
159
159
  for (const r of t.keys()) {
160
160
  const c = r.split("/").pop() ?? r;
161
161
  n.set(c, n.has(c) ? null : r);
162
162
  }
163
- const o = /* @__PURE__ */ new Map(), i = (r) => {
164
- let c = o.get(r);
163
+ const s = /* @__PURE__ */ new Map(), a = (r) => {
164
+ let c = s.get(r);
165
165
  if (!c) {
166
- const a = t.get(r);
167
- c = URL.createObjectURL(new Blob([new Uint8Array(a)], { type: gt(r) })), o.set(r, c);
166
+ const i = t.get(r);
167
+ c = URL.createObjectURL(new Blob([new Uint8Array(i)], { type: wt(r) })), s.set(r, c);
168
168
  }
169
169
  return c;
170
- }, s = (r) => {
170
+ }, o = (r) => {
171
171
  if (!r) return null;
172
- const c = pt(ht(r));
172
+ const c = mt(gt(r));
173
173
  if (!c) return null;
174
- if (t.has(c)) return i(c);
175
- const a = [...t.keys()].filter((g) => g.endsWith(`/${c}`));
176
- if (a.length === 1) return i(a[0]);
174
+ if (t.has(c)) return a(c);
175
+ const i = [...t.keys()].filter((g) => g.endsWith(`/${c}`));
176
+ if (i.length === 1) return a(i[0]);
177
177
  const l = [...t.keys()].filter((g) => c.endsWith(`/${g}`));
178
- if (l.length === 1) return i(l[0]);
178
+ if (l.length === 1) return a(l[0]);
179
179
  const p = n.get(c.split("/").pop() ?? "");
180
- return p ? i(p) : null;
180
+ return p ? a(p) : null;
181
181
  };
182
- for (const r of t.keys()) i(r);
182
+ for (const r of t.keys()) a(r);
183
183
  return {
184
- urls: o,
185
- resolve: (r) => s(r.resolvedPath) ?? s(r.path) ?? s(r.url) ?? null,
184
+ urls: s,
185
+ resolve: (r) => o(r.resolvedPath) ?? o(r.path) ?? o(r.url) ?? null,
186
186
  dispose: () => {
187
- for (const r of o.values()) URL.revokeObjectURL(r);
188
- o.clear();
187
+ for (const r of s.values()) URL.revokeObjectURL(r);
188
+ s.clear();
189
189
  }
190
190
  };
191
191
  }
192
- function Ae(e) {
193
- return ct.has(Re(e));
194
- }
195
- async function dt(e, t, n, o, i) {
196
- if (t.getUint32(n, !0) !== ot) throw new Error("Corrupt zip local file header.");
197
- const s = t.getUint16(n + 26, !0), r = t.getUint16(n + 28, !0), c = n + 30 + s + r, a = e.subarray(c, c + o);
198
- if (i === 0) return a.slice();
199
- if (i !== 8) throw new Error(`Unsupported zip compression method ${i}.`);
200
- const l = new Blob([new Uint8Array(a)]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
192
+ function Re(e) {
193
+ return lt.has(Me(e));
194
+ }
195
+ async function pt(e, t, n, s, a) {
196
+ if (t.getUint32(n, !0) !== it) throw new Error("Corrupt zip local file header.");
197
+ const o = t.getUint16(n + 26, !0), r = t.getUint16(n + 28, !0), c = n + 30 + o + r, i = e.subarray(c, c + s);
198
+ if (a === 0) return i.slice();
199
+ if (a !== 8) throw new Error(`Unsupported zip compression method ${a}.`);
200
+ const l = new Blob([new Uint8Array(i)]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
201
201
  return new Uint8Array(await new Response(l).arrayBuffer());
202
202
  }
203
- function ht(e) {
203
+ function gt(e) {
204
204
  const t = e.indexOf("[");
205
205
  return t >= 0 && e.endsWith("]") ? e.slice(t + 1, -1) : e;
206
206
  }
207
- function pt(e) {
207
+ function mt(e) {
208
208
  const t = [];
209
209
  for (const n of e.replaceAll("\\", "/").split("/"))
210
210
  !n || n === "." || (n === ".." ? t.pop() : t.push(n));
211
211
  return t.join("/");
212
212
  }
213
- function Re(e) {
213
+ function Me(e) {
214
214
  const t = e.split(/[?#]/)[0] ?? e, n = t.lastIndexOf(".");
215
215
  return n < 0 ? "" : t.slice(n + 1).toLowerCase();
216
216
  }
217
- function gt(e) {
218
- switch (Re(e)) {
217
+ function wt(e) {
218
+ switch (Me(e)) {
219
219
  case "png":
220
220
  return "image/png";
221
221
  case "jpg":
@@ -227,30 +227,30 @@ function gt(e) {
227
227
  return "application/octet-stream";
228
228
  }
229
229
  }
230
- function mt(e) {
230
+ function yt(e) {
231
231
  const t = Math.max(0, e.byteLength - 65535 - 22);
232
232
  for (let n = e.byteLength - 22; n >= t; n -= 1)
233
- if (e.getUint32(n, !0) === it) return n;
233
+ if (e.getUint32(n, !0) === ut) return n;
234
234
  return -1;
235
235
  }
236
- const wt = 1, yt = 5, _t = "6f5df5c5901df72d6c87", St = {
236
+ const _t = 1, St = 5, bt = "6f5df5c5901df72d6c87", Et = {
237
237
  file: "openusd_probe.js",
238
238
  sha256: "f89019f6a03661e6aa6403e8b6b694fa00c92ba1c0c7e09620e25ea8efbe6bc2",
239
239
  bytes: 97833
240
- }, bt = {
240
+ }, Ut = {
241
241
  file: "openusd_probe.wasm",
242
242
  sha256: "1170d1ae548f51e5e9d65931df001d8fcd627e8b69b85d9447494c24402893f7",
243
243
  bytes: 10744656
244
244
  };
245
- var Et = {
246
- schemaVersion: wt,
247
- apiVersion: yt,
248
- runtimeId: _t,
249
- js: St,
250
- wasm: bt
245
+ var vt = {
246
+ schemaVersion: _t,
247
+ apiVersion: St,
248
+ runtimeId: bt,
249
+ js: Et,
250
+ wasm: Ut
251
251
  };
252
- const Ut = vt(Et);
253
- function vt(e) {
252
+ const Pt = It(vt);
253
+ function It(e) {
254
254
  if (!e || typeof e != "object") throw new Error("OpenUSD runtime manifest is missing.");
255
255
  const t = e;
256
256
  if (t.schemaVersion !== 1 || !Number.isInteger(t.apiVersion) || Number(t.apiVersion) < 1 || typeof t.runtimeId != "string" || !/^[0-9a-f]{20}$/.test(t.runtimeId))
@@ -259,11 +259,11 @@ function vt(e) {
259
259
  schemaVersion: t.schemaVersion,
260
260
  apiVersion: Number(t.apiVersion),
261
261
  runtimeId: t.runtimeId,
262
- js: ye(t.js, "openusd_probe.js"),
263
- wasm: ye(t.wasm, "openusd_probe.wasm")
262
+ js: _e(t.js, "openusd_probe.js"),
263
+ wasm: _e(t.wasm, "openusd_probe.wasm")
264
264
  });
265
265
  }
266
- function ye(e, t) {
266
+ function _e(e, t) {
267
267
  if (!e || typeof e != "object") throw new Error(`OpenUSD runtime manifest omits ${t}.`);
268
268
  const n = e;
269
269
  if (n.file !== t || typeof n.sha256 != "string" || !/^[0-9a-f]{64}$/.test(n.sha256) || !Number.isInteger(n.bytes) || Number(n.bytes) < 1)
@@ -274,28 +274,28 @@ function ye(e, t) {
274
274
  bytes: Number(n.bytes)
275
275
  });
276
276
  }
277
- function Pt(e, t, n) {
277
+ function At(e, t, n) {
278
278
  return WebAssembly.instantiate(e, t).then(
279
- (o) => n(o, e),
280
- (o) => {
279
+ (s) => n(s, e),
280
+ (s) => {
281
281
  setTimeout(() => {
282
- throw o;
282
+ throw s;
283
283
  });
284
284
  }
285
285
  ), {};
286
286
  }
287
287
  function Ne(e, t) {
288
- const n = async (s, r) => {
289
- var a;
290
- const c = e.GetPrimAtPath(s);
288
+ const n = async (o, r) => {
289
+ var i;
290
+ const c = e.GetPrimAtPath(o);
291
291
  try {
292
292
  return r(c);
293
293
  } finally {
294
- (a = c == null ? void 0 : c.delete) == null || a.call(c);
294
+ (i = c == null ? void 0 : c.delete) == null || i.call(c);
295
295
  }
296
- }, o = (s, r) => {
297
- var a, l, p, g;
298
- const c = (a = s == null ? void 0 : s.GetAttribute) == null ? void 0 : a.call(s, r);
296
+ }, s = (o, r) => {
297
+ var i, l, p, g;
298
+ const c = (i = o == null ? void 0 : o.GetAttribute) == null ? void 0 : i.call(o, r);
299
299
  if (!c) return [];
300
300
  try {
301
301
  return ((l = c.IsValid) == null ? void 0 : l.call(c)) !== !0 ? [] : (((p = c.GetConnections) == null ? void 0 : p.call(c)) ?? []).map((u) => {
@@ -307,9 +307,9 @@ function Ne(e, t) {
307
307
  } finally {
308
308
  (g = c.delete) == null || g.call(c);
309
309
  }
310
- }, i = (s) => {
310
+ }, a = (o) => {
311
311
  var c;
312
- const r = s && ((c = t.UsdShade) != null && c.ComputeBoundMaterialPath) ? t.UsdShade.ComputeBoundMaterialPath(s) : null;
312
+ const r = o && ((c = t.UsdShade) != null && c.ComputeBoundMaterialPath) ? t.UsdShade.ComputeBoundMaterialPath(o) : null;
313
313
  return r ? {
314
314
  found: !0,
315
315
  materialPath: String(r.materialPath ?? ""),
@@ -318,103 +318,103 @@ function Ne(e, t) {
318
318
  } : { found: !1, materialPath: "", resolvedTargetPath: "", bindingRelationshipPath: "" };
319
319
  };
320
320
  return {
321
- async stageMetadata(s) {
321
+ async stageMetadata(o) {
322
322
  var c;
323
323
  const r = e.GetPseudoRoot();
324
324
  try {
325
- const a = r.GetMetadata(s);
326
- return { valid: !0, found: a != null, value: a };
325
+ const i = r.GetMetadata(o);
326
+ return { valid: !0, found: i != null, value: i };
327
327
  } finally {
328
328
  (c = r.delete) == null || c.call(r);
329
329
  }
330
330
  },
331
- async primInfo(s) {
332
- return n(s, (r) => {
333
- var c, a, l, p;
331
+ async primInfo(o) {
332
+ return n(o, (r) => {
333
+ var c, i, l, p;
334
334
  return {
335
335
  valid: !!r && ((c = r.IsValid) == null ? void 0 : c.call(r)) !== !1,
336
- name: String(((a = r.GetName) == null ? void 0 : a.call(r)) ?? s.split("/").pop() ?? ""),
337
- path: s,
336
+ name: String(((i = r.GetName) == null ? void 0 : i.call(r)) ?? o.split("/").pop() ?? ""),
337
+ path: o,
338
338
  typeName: String(((l = r.GetTypeName) == null ? void 0 : l.call(r)) ?? ""),
339
339
  instance: ((p = r.IsInstance) == null ? void 0 : p.call(r)) === !0
340
340
  };
341
341
  });
342
342
  },
343
- async primChildren(s) {
344
- return n(s, (r) => {
343
+ async primChildren(o) {
344
+ return n(o, (r) => {
345
345
  var c;
346
- return (((c = r.GetChildren) == null ? void 0 : c.call(r)) ?? []).map((a) => {
346
+ return (((c = r.GetChildren) == null ? void 0 : c.call(r)) ?? []).map((i) => {
347
347
  var p, g;
348
- const l = String(a.__path ?? ((p = a.GetPath) == null ? void 0 : p.call(a)) ?? "");
349
- return (g = a.delete) == null || g.call(a), l;
348
+ const l = String(i.__path ?? ((p = i.GetPath) == null ? void 0 : p.call(i)) ?? "");
349
+ return (g = i.delete) == null || g.call(i), l;
350
350
  });
351
351
  });
352
352
  },
353
- async primDescendants(s, r = "") {
353
+ async primDescendants(o, r = "") {
354
354
  var c;
355
- return (((c = e.GetDescendants) == null ? void 0 : c.call(e, s, r)) ?? []).map(String);
355
+ return (((c = e.GetDescendants) == null ? void 0 : c.call(e, o, r)) ?? []).map(String);
356
356
  },
357
- async primAttributes(s) {
358
- return n(s, (r) => {
357
+ async primAttributes(o) {
358
+ return n(o, (r) => {
359
359
  var c;
360
- return (((c = r.GetAttributes) == null ? void 0 : c.call(r)) ?? []).map((a) => {
360
+ return (((c = r.GetAttributes) == null ? void 0 : c.call(r)) ?? []).map((i) => {
361
361
  var p, g;
362
- const l = String(((p = a.GetName) == null ? void 0 : p.call(a)) ?? "");
363
- return (g = a.delete) == null || g.call(a), l;
362
+ const l = String(((p = i.GetName) == null ? void 0 : p.call(i)) ?? "");
363
+ return (g = i.delete) == null || g.call(i), l;
364
364
  });
365
365
  });
366
366
  },
367
- async primMetadata(s, r) {
368
- return n(s, (c) => {
367
+ async primMetadata(o, r) {
368
+ return n(o, (c) => {
369
369
  var p;
370
- const a = (p = c == null ? void 0 : c.GetMetadata) == null ? void 0 : p.call(c, r), l = typeof a == "string" ? a : a && typeof a == "object" && typeof a.string == "string" ? String(a.string) : void 0;
370
+ const i = (p = c == null ? void 0 : c.GetMetadata) == null ? void 0 : p.call(c, r), l = typeof i == "string" ? i : i && typeof i == "object" && typeof i.string == "string" ? String(i.string) : void 0;
371
371
  return {
372
372
  valid: !0,
373
- found: a != null,
374
- ...a != null ? { value: a } : {},
373
+ found: i != null,
374
+ ...i != null ? { value: i } : {},
375
375
  ...l !== void 0 ? { text: l } : {}
376
376
  };
377
377
  });
378
378
  },
379
- async relationshipTargets(s, r) {
380
- return n(s, (c) => {
379
+ async relationshipTargets(o, r) {
380
+ return n(o, (c) => {
381
381
  var l, p, g;
382
- const a = (l = c == null ? void 0 : c.GetRelationship) == null ? void 0 : l.call(c, r);
383
- if (!a) return [];
382
+ const i = (l = c == null ? void 0 : c.GetRelationship) == null ? void 0 : l.call(c, r);
383
+ if (!i) return [];
384
384
  try {
385
- return (((p = a.GetTargets) == null ? void 0 : p.call(a)) ?? []).map((u) => {
385
+ return (((p = i.GetTargets) == null ? void 0 : p.call(i)) ?? []).map((u) => {
386
386
  var f;
387
387
  return typeof u == "string" ? u : String(((f = u.GetString) == null ? void 0 : f.call(u)) ?? u.path ?? "");
388
388
  }).filter(Boolean);
389
389
  } finally {
390
- (g = a.delete) == null || g.call(a);
390
+ (g = i.delete) == null || g.call(i);
391
391
  }
392
392
  });
393
393
  },
394
- async attributeValue(s, r) {
395
- return n(s, (c) => {
394
+ async attributeValue(o, r) {
395
+ return n(o, (c) => {
396
396
  var l, p, g, u;
397
- const a = (l = c == null ? void 0 : c.GetAttribute) == null ? void 0 : l.call(c, r);
398
- if (!a) return { valid: !1, authored: !1, value: null };
397
+ const i = (l = c == null ? void 0 : c.GetAttribute) == null ? void 0 : l.call(c, r);
398
+ if (!i) return { valid: !1, authored: !1, value: null };
399
399
  try {
400
- const f = ((p = a.IsValid) == null ? void 0 : p.call(a)) === !0;
400
+ const f = ((p = i.IsValid) == null ? void 0 : p.call(i)) === !0;
401
401
  return {
402
402
  valid: f,
403
- authored: f && ((g = a.HasAuthoredValue) == null ? void 0 : g.call(a)) === !0,
404
- value: f ? a.Get() : null
403
+ authored: f && ((g = i.HasAuthoredValue) == null ? void 0 : g.call(i)) === !0,
404
+ value: f ? i.Get() : null
405
405
  };
406
406
  } finally {
407
- (u = a.delete) == null || u.call(a);
407
+ (u = i.delete) == null || u.call(i);
408
408
  }
409
409
  });
410
410
  },
411
- async attributeValues(s) {
411
+ async attributeValues(o) {
412
412
  const r = {};
413
- for (const c of s)
414
- r[c.path] = await n(c.path, (a) => Object.fromEntries(
413
+ for (const c of o)
414
+ r[c.path] = await n(c.path, (i) => Object.fromEntries(
415
415
  c.names.map((l) => {
416
416
  var g, u, f, h;
417
- const p = (g = a == null ? void 0 : a.GetAttribute) == null ? void 0 : g.call(a, l);
417
+ const p = (g = i == null ? void 0 : i.GetAttribute) == null ? void 0 : g.call(i, l);
418
418
  if (!p) return [l, { valid: !1, authored: !1, value: null }];
419
419
  try {
420
420
  const y = ((u = p.IsValid) == null ? void 0 : u.call(p)) === !0;
@@ -430,10 +430,10 @@ function Ne(e, t) {
430
430
  ));
431
431
  return r;
432
432
  },
433
- async attributeMetadata(s, r, c) {
434
- return n(s, (a) => {
433
+ async attributeMetadata(o, r, c) {
434
+ return n(o, (i) => {
435
435
  var p, g, u;
436
- const l = (p = a == null ? void 0 : a.GetAttribute) == null ? void 0 : p.call(a, r);
436
+ const l = (p = i == null ? void 0 : i.GetAttribute) == null ? void 0 : p.call(i, r);
437
437
  if (!l) return { valid: !1, found: !1 };
438
438
  try {
439
439
  if (((g = l.IsValid) == null ? void 0 : g.call(l)) !== !0) return { valid: !1, found: !1 };
@@ -448,58 +448,58 @@ function Ne(e, t) {
448
448
  }
449
449
  });
450
450
  },
451
- async attributeConnections(s, r) {
452
- return n(s, (c) => o(c, r));
451
+ async attributeConnections(o, r) {
452
+ return n(o, (c) => s(c, r));
453
453
  },
454
- async boundMaterial(s) {
455
- return n(s, i);
454
+ async boundMaterial(o) {
455
+ return n(o, a);
456
456
  }
457
457
  };
458
458
  }
459
- const It = /^physics$/i, At = /^(newton|mjc|mujoco)(?:[_-]|$)/i, Rt = /^(physx|newton|mjc|mujoco)(?:[_-]|)/i;
460
- function Nt(e, t = []) {
461
- const n = new Set(t.map(_e)), o = [];
462
- for (const i of e) {
463
- if (!It.test(i.setName) || n.has(_e(i))) continue;
464
- const s = i.variantNames.map((a, l) => ({ selection: a, index: l, rank: Dt(a) })).filter((a) => a.rank !== null);
465
- if (s.length === 0 || i.selection && At.test(i.selection)) continue;
466
- const r = ce(i.selection), c = [...s].sort((a, l) => {
467
- const p = r !== null && ce(a.selection) === r, g = r !== null && ce(l.selection) === r;
468
- return Number(g) - Number(p) || a.rank - l.rank || a.index - l.index;
459
+ const Rt = /^physics$/i, Mt = /^(newton|mjc|mujoco)(?:[_-]|$)/i, Nt = /^(physx|newton|mjc|mujoco)(?:[_-]|)/i;
460
+ function Dt(e, t = []) {
461
+ const n = new Set(t.map(Se)), s = [];
462
+ for (const a of e) {
463
+ if (!Rt.test(a.setName) || n.has(Se(a))) continue;
464
+ const o = a.variantNames.map((i, l) => ({ selection: i, index: l, rank: kt(i) })).filter((i) => i.rank !== null);
465
+ if (o.length === 0 || a.selection && Mt.test(a.selection)) continue;
466
+ const r = ce(a.selection), c = [...o].sort((i, l) => {
467
+ const p = r !== null && ce(i.selection) === r, g = r !== null && ce(l.selection) === r;
468
+ return Number(g) - Number(p) || i.rank - l.rank || i.index - l.index;
469
469
  })[0];
470
- o.push({
471
- primPath: i.primPath,
472
- setName: i.setName,
470
+ s.push({
471
+ primPath: a.primPath,
472
+ setName: a.setName,
473
473
  selection: c.selection
474
474
  });
475
475
  }
476
- return o;
476
+ return s;
477
477
  }
478
- function Dt(e) {
478
+ function kt(e) {
479
479
  return /^newton(?:[_-]|$)/i.test(e) ? 0 : /^mjc(?:[_-]|$)/i.test(e) ? 1 : /^mujoco(?:[_-]|$)/i.test(e) ? 2 : null;
480
480
  }
481
481
  function ce(e) {
482
- return e && e.replace(Rt, "").toLowerCase() || null;
482
+ return e && e.replace(Nt, "").toLowerCase() || null;
483
483
  }
484
- function _e(e) {
484
+ function Se(e) {
485
485
  return `${e.primPath}\0${e.setName}`;
486
486
  }
487
- function Mt(e) {
487
+ function xt(e) {
488
488
  let t = 0;
489
489
  const n = () => {
490
490
  for (; t < e.length; ) {
491
- const a = e[t];
492
- if (/\s/.test(a)) {
491
+ const i = e[t];
492
+ if (/\s/.test(i)) {
493
493
  t++;
494
494
  continue;
495
495
  }
496
- if (a === "#") {
496
+ if (i === "#") {
497
497
  for (; t < e.length && e[t] !== `
498
498
  `; ) t++;
499
499
  continue;
500
500
  }
501
- if (a === '"' || a === "@" || a === "<") {
502
- const p = a === "<" ? ">" : a, g = a === '"' && e.slice(t, t + 3) === '"""';
501
+ if (i === '"' || i === "@" || i === "<") {
502
+ const p = i === "<" ? ">" : i, g = i === '"' && e.slice(t, t + 3) === '"""';
503
503
  t += g ? 3 : 1;
504
504
  const u = t;
505
505
  for (; t < e.length; ) {
@@ -509,14 +509,14 @@ function Mt(e) {
509
509
  }
510
510
  if (g ? e.slice(t, t + 3) === '"""' : e[t] === p) {
511
511
  const f = e.slice(u, t);
512
- return t += g ? 3 : 1, { kind: a === "<" ? "path" : "string", value: f };
512
+ return t += g ? 3 : 1, { kind: i === "<" ? "path" : "string", value: f };
513
513
  }
514
514
  t++;
515
515
  }
516
516
  throw new Error("Unterminated USDA string or path");
517
517
  }
518
- if ("{}()[]=,".includes(a))
519
- return t++, { kind: "symbol", value: a };
518
+ if ("{}()[]=,".includes(i))
519
+ return t++, { kind: "symbol", value: i };
520
520
  const l = t;
521
521
  for (; t < e.length && !/[\s{}()\[\]=,<>"@#]/.test(e[t]); ) t++;
522
522
  if (l === t) {
@@ -525,21 +525,21 @@ function Mt(e) {
525
525
  }
526
526
  return { kind: "word", value: e.slice(l, t) };
527
527
  }
528
- }, o = () => {
529
- let a = 1, l;
530
- for (; a && (l = n()); )
531
- l.value === "[" && l.kind === "symbol" ? a++ : l.value === "]" && l.kind === "symbol" && a--;
532
- if (a) throw new Error("Unterminated USDA list");
533
- }, i = () => {
534
- let a = 1, l;
535
- for (; a && (l = n()); )
536
- l.value === "{" && l.kind === "symbol" ? a++ : l.value === "}" && l.kind === "symbol" && a--;
537
- if (a) throw new Error("Unterminated USDA dictionary");
538
- }, s = /* @__PURE__ */ new Map(), r = [];
528
+ }, s = () => {
529
+ let i = 1, l;
530
+ for (; i && (l = n()); )
531
+ l.value === "[" && l.kind === "symbol" ? i++ : l.value === "]" && l.kind === "symbol" && i--;
532
+ if (i) throw new Error("Unterminated USDA list");
533
+ }, a = () => {
534
+ let i = 1, l;
535
+ for (; i && (l = n()); )
536
+ l.value === "{" && l.kind === "symbol" ? i++ : l.value === "}" && l.kind === "symbol" && i--;
537
+ if (i) throw new Error("Unterminated USDA dictionary");
538
+ }, o = /* @__PURE__ */ new Map(), r = [];
539
539
  let c;
540
540
  for (; c = n(); ) {
541
541
  if (c.kind !== "word") {
542
- c.kind === "symbol" && c.value === "[" ? o() : c.kind === "symbol" && c.value === "{" ? i() : c.kind === "symbol" && c.value === "}" && r.pop();
542
+ c.kind === "symbol" && c.value === "[" ? s() : c.kind === "symbol" && c.value === "{" ? a() : c.kind === "symbol" && c.value === "}" && r.pop();
543
543
  continue;
544
544
  }
545
545
  if (["def", "over", "class"].includes(c.value)) {
@@ -551,7 +551,7 @@ function Mt(e) {
551
551
  if (d.kind === "symbol" && d.value === "(") m++;
552
552
  else if (d.kind === "symbol" && d.value === ")") m--;
553
553
  else if (d.kind === "symbol" && d.value === "{") {
554
- i();
554
+ a();
555
555
  continue;
556
556
  }
557
557
  if (d.kind === "word" && d.value === "apiSchemas") {
@@ -562,15 +562,15 @@ function Mt(e) {
562
562
  for (; (d = n()) && d.value !== "]"; )
563
563
  d.kind === "string" && d.value.startsWith("PhysxMimicJointAPI:") && w.schemas.push(d.value);
564
564
  if (!d) throw new Error("Unterminated USDA apiSchemas");
565
- } else d.value === "[" && d.kind === "symbol" && o();
565
+ } else d.value === "[" && d.kind === "symbol" && s();
566
566
  }
567
567
  if (!d) throw new Error("Unterminated USDA prim header");
568
- s.set(y, w), r.push({ path: y, prim: w });
568
+ o.set(y, w), r.push({ path: y, prim: w });
569
569
  continue;
570
570
  }
571
571
  if (c.value !== "rel" || !r.at(-1)) continue;
572
- const a = n();
573
- if (!a || a.kind !== "word" || !/^physxMimicJoint:[^:]+:referenceJoint$/.test(a.value)) continue;
572
+ const i = n();
573
+ if (!i || i.kind !== "word" || !/^physxMimicJoint:[^:]+:referenceJoint$/.test(i.value)) continue;
574
574
  const l = n(), p = n();
575
575
  if ((l == null ? void 0 : l.value) !== "=" || !p) continue;
576
576
  const g = [];
@@ -580,11 +580,11 @@ function Mt(e) {
580
580
  for (; (u = n()) && u.value !== "]"; ) u.kind === "path" && g.push(u.value);
581
581
  if (!u) throw new Error("Unterminated USDA relationship");
582
582
  }
583
- r.at(-1).prim.relationships.set(a.value, g);
583
+ r.at(-1).prim.relationships.set(i.value, g);
584
584
  }
585
- return new Map([...s].filter(([, a]) => a.schemas.length || a.relationships.size));
585
+ return new Map([...o].filter(([, i]) => i.schemas.length || i.relationships.size));
586
586
  }
587
- const kt = [
587
+ const Ot = [
588
588
  1,
589
589
  0,
590
590
  0,
@@ -602,102 +602,102 @@ const kt = [
602
602
  0,
603
603
  1
604
604
  ];
605
- function xt(e) {
606
- const t = new Map(e.map((s) => [s.path, s])), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), i = (s) => {
607
- const r = n.get(s.path);
605
+ function Tt(e) {
606
+ const t = new Map(e.map((o) => [o.path, o])), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), a = (o) => {
607
+ const r = n.get(o.path);
608
608
  if (r) return r;
609
- if (o.has(s.path)) return Se(s.localMatrix);
610
- o.add(s.path);
611
- const c = Se(s.localMatrix), a = s.parentPath ? t.get(s.parentPath) : void 0, l = !a || s.resetsXformStack ? c : be(c, i(a));
612
- return o.delete(s.path), n.set(s.path, l), l;
609
+ if (s.has(o.path)) return be(o.localMatrix);
610
+ s.add(o.path);
611
+ const c = be(o.localMatrix), i = o.parentPath ? t.get(o.parentPath) : void 0, l = !i || o.resetsXformStack ? c : Ee(c, a(i));
612
+ return s.delete(o.path), n.set(o.path, l), l;
613
613
  };
614
- return e.map((s) => {
615
- if (!s.resetsXformStack || !s.parentPath) return s;
616
- const r = t.get(s.parentPath);
617
- if (!r) return s;
618
- const c = i(r), a = Tt(c);
619
- return a ? {
620
- ...s,
621
- localMatrix: be(i(s), a)
622
- } : s;
614
+ return e.map((o) => {
615
+ if (!o.resetsXformStack || !o.parentPath) return o;
616
+ const r = t.get(o.parentPath);
617
+ if (!r) return o;
618
+ const c = a(r), i = Lt(c);
619
+ return i ? {
620
+ ...o,
621
+ localMatrix: Ee(a(o), i)
622
+ } : o;
623
623
  });
624
624
  }
625
- function Se(e) {
626
- return Ot(e) ? e : kt;
625
+ function be(e) {
626
+ return $t(e) ? e : Ot;
627
627
  }
628
- function Ot(e) {
628
+ function $t(e) {
629
629
  return (e == null ? void 0 : e.length) === 16 && e.every(Number.isFinite);
630
630
  }
631
- function be(e, t) {
631
+ function Ee(e, t) {
632
632
  const n = new Array(16);
633
- for (let o = 0; o < 4; o++)
634
- for (let i = 0; i < 4; i++) {
635
- let s = 0;
633
+ for (let s = 0; s < 4; s++)
634
+ for (let a = 0; a < 4; a++) {
635
+ let o = 0;
636
636
  for (let r = 0; r < 4; r++)
637
- s += e[o * 4 + r] * t[r * 4 + i];
638
- n[o * 4 + i] = s;
637
+ o += e[s * 4 + r] * t[r * 4 + a];
638
+ n[s * 4 + a] = o;
639
639
  }
640
640
  return n;
641
641
  }
642
- function Tt(e) {
642
+ function Lt(e) {
643
643
  const [
644
644
  t,
645
645
  n,
646
- o,
647
- ,
648
- i,
649
646
  s,
647
+ ,
648
+ a,
649
+ o,
650
650
  r,
651
651
  ,
652
652
  c,
653
- a,
653
+ i,
654
654
  l,
655
655
  ,
656
656
  p,
657
657
  g,
658
658
  u
659
- ] = e, f = s * l - r * a, h = o * a - n * l, y = n * r - o * s, w = t * f + i * h + c * y, d = Math.max(
660
- Math.abs(t * s * l),
661
- Math.abs(t * r * a),
662
- Math.abs(n * i * l),
659
+ ] = e, f = o * l - r * i, h = s * i - n * l, y = n * r - s * o, w = t * f + a * h + c * y, d = Math.max(
660
+ Math.abs(t * o * l),
661
+ Math.abs(t * r * i),
662
+ Math.abs(n * a * l),
663
663
  Math.abs(n * r * c),
664
- Math.abs(o * i * a),
665
- Math.abs(o * s * c),
664
+ Math.abs(s * a * i),
665
+ Math.abs(s * o * c),
666
666
  1
667
667
  );
668
668
  if (!Number.isFinite(w) || Math.abs(w) <= Number.EPSILON * d * 16)
669
669
  return null;
670
- const m = 1 / w, S = f * m, _ = h * m, O = y * m, F = (r * c - i * l) * m, j = (t * l - o * c) * m, z = (o * i - t * r) * m, W = (i * a - s * c) * m, J = (n * c - t * a) * m, V = (t * s - n * i) * m;
670
+ const m = 1 / w, S = f * m, _ = h * m, O = y * m, B = (r * c - a * l) * m, j = (t * l - s * c) * m, F = (s * a - t * r) * m, H = (a * i - o * c) * m, J = (n * c - t * i) * m, V = (t * o - n * a) * m;
671
671
  return [
672
672
  S,
673
673
  _,
674
674
  O,
675
675
  0,
676
- F,
676
+ B,
677
677
  j,
678
- z,
678
+ F,
679
679
  0,
680
- W,
680
+ H,
681
681
  J,
682
682
  V,
683
683
  0,
684
- -(p * S + g * F + u * W),
684
+ -(p * S + g * B + u * H),
685
685
  -(p * _ + g * j + u * J),
686
- -(p * O + g * z + u * V),
686
+ -(p * O + g * F + u * V),
687
687
  1
688
688
  ];
689
689
  }
690
- function $t(e, t = []) {
690
+ function Ct(e, t = []) {
691
691
  return {
692
692
  stage: e.stage,
693
693
  view: {
694
694
  ...e.view,
695
- prims: xt(e.view.prims)
695
+ prims: Tt(e.view.prims)
696
696
  },
697
697
  elements: e.elements,
698
698
  materials: e.materials,
699
699
  materialAliases: e.materialAliases,
700
- physics: Ct(),
700
+ physics: Vt(),
701
701
  joints: [],
702
702
  cameras: [],
703
703
  lights: [],
@@ -706,10 +706,10 @@ function $t(e, t = []) {
706
706
  variants: t
707
707
  };
708
708
  }
709
- function Lt(e, t) {
709
+ function jt(e, t) {
710
710
  e.physics = t.physics, e.joints = t.joints;
711
711
  }
712
- function Ct() {
712
+ function Vt() {
713
713
  return {
714
714
  scenes: [],
715
715
  rigidBodies: [],
@@ -718,17 +718,17 @@ function Ct() {
718
718
  articulationRoots: []
719
719
  };
720
720
  }
721
- const jt = /^(Warning|Error|Fatal|Info|Runtime Error|Coding Error):\s+in\s+(\S+)\s+at line \d+ of .*?\s+--\s+([\s\S]*)$/s, Vt = /(^|[\s(\[])(?:[A-Za-z]:[\\/]|\/)(?:[^ \t\r\n()'"]+[\\/])*[^ \t\r\n()'"]+\.(?:cpp|cxx|cc|hpp|c|h|mjs|js|ts)(?::\d+)*/gi, Gt = /<0x[0-9a-f]+>/gi, Bt = /* @__PURE__ */ new Set([
721
+ const Gt = /^(Warning|Error|Fatal|Info|Runtime Error|Coding Error):\s+in\s+(\S+)\s+at line \d+ of .*?\s+--\s+([\s\S]*)$/s, Bt = /(^|[\s(\[])(?:[A-Za-z]:[\\/]|\/)(?:[^ \t\r\n()'"]+[\\/])*[^ \t\r\n()'"]+\.(?:cpp|cxx|cc|hpp|c|h|mjs|js|ts)(?::\d+)*/gi, Ft = /<0x[0-9a-f]+>/gi, zt = /* @__PURE__ */ new Set([
722
722
  "USD_MATERIAL_BINDING_API_MISSING",
723
723
  "USD_EXTERNAL_REFERENCE_UNRESOLVED"
724
724
  ]);
725
- function Ft(e) {
726
- const t = jt.exec(e);
727
- return (t ? `${t[1]}: ${t[2]} -- ${t[3]}` : e).replace(Vt, "$1<OpenUSD source>").replace(Gt, "<stage>").trim();
725
+ function Wt(e) {
726
+ const t = Gt.exec(e);
727
+ return (t ? `${t[1]}: ${t[2]} -- ${t[3]}` : e).replace(Bt, "$1<OpenUSD source>").replace(Ft, "<stage>").trim();
728
728
  }
729
- function zt(e) {
729
+ function Ht(e) {
730
730
  if (!e || /^(?:Info|Status):/.test(e)) return null;
731
- const t = Ft(e);
731
+ const t = Wt(e);
732
732
  if (!t) return null;
733
733
  if (/Found material bindings on prim at path .* but MaterialBindingAPI is not applied/.test(t))
734
734
  return { severity: "warning", code: "USD_MATERIAL_BINDING_API_MISSING", message: t };
@@ -748,63 +748,87 @@ function zt(e) {
748
748
  message: t
749
749
  };
750
750
  }
751
- function Ee(e = {}) {
752
- const t = e.console ?? console, n = /* @__PURE__ */ new Set(), o = Math.max(1, e.maxUniqueDiagnostics ?? 64);
753
- let i = !1;
754
- const s = (r) => {
755
- var a;
751
+ function Ue(e = {}) {
752
+ const t = e.console ?? console, n = /* @__PURE__ */ new Set(), s = Math.max(1, e.maxUniqueDiagnostics ?? 64);
753
+ let a = !1;
754
+ const o = (r) => {
755
+ var i;
756
756
  const c = r.code === "USD_MATERIAL_BINDING_API_MISSING" ? r.code : `${r.code}\0${r.message}`;
757
757
  if (!n.has(c)) {
758
- if (n.size >= o) {
759
- i || (i = !0, t.warn(
760
- `[openusd] further runtime diagnostics suppressed after ${o} unique messages`
758
+ if (n.size >= s) {
759
+ a || (a = !0, t.warn(
760
+ `[openusd] further runtime diagnostics suppressed after ${s} unique messages`
761
761
  ));
762
762
  return;
763
763
  }
764
- n.add(c), (a = e.onDiagnostic) == null || a.call(e, r), !e.onDiagnostic && (Bt.has(r.code) || (r.severity === "error" ? t.error(r.message) : t.warn(r.message)));
764
+ n.add(c), (i = e.onDiagnostic) == null || i.call(e, r), !e.onDiagnostic && (zt.has(r.code) || (r.severity === "error" ? t.error(r.message) : t.warn(r.message)));
765
765
  }
766
766
  };
767
767
  return (r) => {
768
768
  const c = String(r ?? "");
769
- for (const a of c.split(/\r?\n/)) {
770
- const l = zt(a.trim());
771
- l && s(l);
769
+ for (const i of c.split(/\r?\n/)) {
770
+ const l = Ht(i.trim());
771
+ l && o(l);
772
+ }
773
+ };
774
+ }
775
+ const ue = "[USD material] ", Xt = /* @__PURE__ */ new WeakMap();
776
+ function Jt(e) {
777
+ const t = [], n = console.warn;
778
+ console.warn = (...s) => {
779
+ const a = s.length === 1 && typeof s[0] == "string" && s[0].startsWith(ue) ? s[0].slice(ue.length) : null;
780
+ if (a !== null) {
781
+ t.push(a);
782
+ return;
772
783
  }
784
+ n(...s);
773
785
  };
786
+ try {
787
+ return { value: e(), warnings: Object.freeze(t) };
788
+ } catch (s) {
789
+ for (const a of t)
790
+ n(`${ue}${a}`);
791
+ throw s;
792
+ } finally {
793
+ console.warn = n;
794
+ }
774
795
  }
775
- const Ht = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
776
- async function Wt(e) {
796
+ function qt(e, t) {
797
+ t.length && Xt.set(e, Object.freeze([...t]));
798
+ }
799
+ const Zt = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
800
+ async function Yt(e) {
777
801
  const t = await import(
778
802
  /* @vite-ignore */
779
803
  e.moduleUrl
780
- ), n = t.default ?? t.createOpenUsdProbe, o = e.wasmModule ? {
781
- printErr: Ee({ onDiagnostic: e.onRuntimeDiagnostic }),
804
+ ), n = t.default ?? t.createOpenUsdProbe, s = e.wasmModule ? {
805
+ printErr: Ue({ onDiagnostic: e.onRuntimeDiagnostic }),
782
806
  instantiateWasm(w, d) {
783
- return Pt(e.wasmModule, w, d);
807
+ return At(e.wasmModule, w, d);
784
808
  }
785
809
  } : {
786
- printErr: Ee({ onDiagnostic: e.onRuntimeDiagnostic }),
787
- wasmBinary: await (typeof e.wasmBinary == "function" ? e.wasmBinary() : e.wasmBinary ?? tn(e.wasmUrl))
788
- }, i = await n(o), s = e.apiVersion ?? Ut.apiVersion, r = Number(i.ccall("usd_probe_api_version", "number", [], []));
789
- if (r !== s)
810
+ printErr: Ue({ onDiagnostic: e.onRuntimeDiagnostic }),
811
+ wasmBinary: await (typeof e.wasmBinary == "function" ? e.wasmBinary() : e.wasmBinary ?? an(e.wasmUrl))
812
+ }, a = await n(s), o = e.apiVersion ?? Pt.apiVersion, r = Number(a.ccall("usd_probe_api_version", "number", [], []));
813
+ if (r !== o)
790
814
  throw Object.assign(
791
- new Error(`OpenUSD runtime API mismatch: expected ${s}, received ${r}.`),
815
+ new Error(`OpenUSD runtime API mismatch: expected ${o}, received ${r}.`),
792
816
  { code: "E_USD_RUNTIME_VERSION" }
793
817
  );
794
- const c = e.memfsRoot ?? "/asset", a = e.fetchBytes ?? (async (w) => {
818
+ const c = e.memfsRoot ?? "/asset", i = e.fetchBytes ?? (async (w) => {
795
819
  const d = await fetch(w);
796
820
  if (!d.ok) throw Object.assign(new Error(`USD resource request failed (${d.status}): ${w}`), {
797
821
  code: d.status === 401 || d.status === 403 ? "E_ASSET_AUTH" : "E_ASSET_FETCH"
798
822
  });
799
- const m = new Uint8Array(await d.arrayBuffer()), S = et(d.headers.get("content-type"), m);
800
- if (S) throw Ze(`USD resource is not usable (${S}): ${w}`, Ie);
823
+ const m = new Uint8Array(await d.arrayBuffer()), S = nt(d.headers.get("content-type"), m);
824
+ if (S) throw Ke(`USD resource is not usable (${S}): ${w}`, Ae);
801
825
  return m;
802
- }), l = (w, d, m) => JSON.parse(i.ccall(w, "string", d, m)), p = /* @__PURE__ */ new Set(), g = Ue(i);
826
+ }), l = (w, d, m) => JSON.parse(a.ccall(w, "string", d, m)), p = /* @__PURE__ */ new Set(), g = ve(a);
803
827
  let u = 0, f = null;
804
828
  async function h() {
805
829
  return f || (f = (async () => {
806
830
  const w = `${c}/__viewer_warmup__`, d = `${w}/empty.usda`;
807
- i.FS.mkdirTree(w), i.FS.writeFile(d, new TextEncoder().encode(`#usda 1.0
831
+ a.FS.mkdirTree(w), a.FS.writeFile(d, new TextEncoder().encode(`#usda 1.0
808
832
  `));
809
833
  let m;
810
834
  try {
@@ -813,82 +837,82 @@ async function Wt(e) {
813
837
  throw new Error(S.error ?? "Failed to initialize the USD Stage runtime.");
814
838
  m = S.stageId;
815
839
  } finally {
816
- m !== void 0 && l("usd_probe_stage_release", ["number"], [m]), i.FS.analyzePath(d, !0).exists && i.FS.unlink(d);
840
+ m !== void 0 && l("usd_probe_stage_release", ["number"], [m]), a.FS.analyzePath(d, !0).exists && a.FS.unlink(d);
817
841
  }
818
842
  })(), f);
819
843
  }
820
844
  async function y(w, d) {
821
- const m = new URL(d.sourcePath, "file:///"), S = `${c}/load-${++u}`, _ = X(m.href, S), O = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map(), z = d.readTextureBytes ?? !0, W = d.collectTextureUrls ?? !z, J = W || z ? Me : Qt, V = /* @__PURE__ */ new Map();
822
- let b, N = null, U = null;
845
+ const m = new URL(d.sourcePath, "file:///"), S = `${c}/load-${++u}`, _ = q(m.href, S), O = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map(), F = d.readTextureBytes ?? !0, H = d.collectTextureUrls ?? !F, J = H || F ? ke : sn, V = /* @__PURE__ */ new Map();
846
+ let b, M = null, U = null;
823
847
  const R = () => {
824
- b !== void 0 && p.delete(b) && l("usd_probe_stage_release", ["number"], [b]), N == null || N.dispose(), Le(i.FS, S);
848
+ b !== void 0 && p.delete(b) && l("usd_probe_stage_release", ["number"], [b]), M == null || M.dispose(), Ce(a.FS, S);
825
849
  };
826
850
  try {
827
- const A = await ve(w);
828
- le(i, _, A, O), F.set(_, J(A));
851
+ const A = await Pe(w);
852
+ fe(a, _, A, O), B.set(_, J(A));
829
853
  for (const [E, $] of Object.entries(d.files ?? {})) {
830
- const B = X(new URL(E, m).href, S), re = await ve($);
831
- O.has(B) || F.set(B, J(re)), le(i, B, re, O);
854
+ const X = q(new URL(E, m).href, S), W = await Pe($);
855
+ O.has(X) || B.set(X, J(W)), fe(a, X, W, O);
832
856
  }
833
857
  const k = new Set(O);
834
858
  for (const E of d.packagePaths ?? [])
835
- k.add(X(new URL(E, m).href, S));
836
- const v = d.externalReferenceMode ?? "complete", I = ut(A) ? await lt(A, { include: Ae }) : null;
837
- let P = {}, M, D;
859
+ k.add(q(new URL(E, m).href, S));
860
+ const v = d.externalReferenceMode ?? "complete", I = ft(A) ? await dt(A, { include: Re }) : null;
861
+ let P = {}, D, N;
838
862
  if (!I && d.autoResolveAssets !== !1) {
839
- const E = d.resolveBytes ?? ((B) => a(B)), $ = await Zt(
840
- i,
863
+ const E = d.resolveBytes ?? ((X) => i(X)), $ = await tn(
864
+ a,
841
865
  m,
842
866
  S,
843
867
  E,
844
868
  l,
845
869
  O,
846
870
  V,
847
- W ? j : null,
848
- F,
871
+ H ? j : null,
872
+ B,
849
873
  d.maxFiles ?? 1024,
850
874
  d.maxDepth ?? 8,
851
875
  d.maxConcurrency ?? 1,
852
876
  v,
853
877
  k,
854
- z,
878
+ F,
855
879
  d,
856
880
  d.onReferenceSkipped,
857
881
  d.onResourceFailed
858
882
  );
859
- P = $.mappings, M = $.opened, D = $.variantConfiguration;
883
+ P = $.mappings, D = $.opened, N = $.variantConfiguration;
860
884
  } else {
861
- if (M = Object.keys(P).length > 0 ? l("usd_probe_stage_open_mapped", ["string", "string"], [_, JSON.stringify(P)]) : l("usd_probe_stage_open", ["string"], [_]), !M.ok) throw new Error(M.error ?? `Failed to open ${_}`);
862
- D = De(i, M, d, !0);
885
+ if (D = Object.keys(P).length > 0 ? l("usd_probe_stage_open_mapped", ["string", "string"], [_, JSON.stringify(P)]) : l("usd_probe_stage_open", ["string"], [_]), !D.ok) throw new Error(D.error ?? `Failed to open ${_}`);
886
+ N = De(a, D, d, !0);
863
887
  }
864
- N = I ? ft(I) : null;
865
- const x = d.textureResolver || N ? (E) => {
888
+ M = I ? ht(I) : null;
889
+ const x = d.textureResolver || M ? (E) => {
866
890
  var $;
867
- return (($ = d.textureResolver) == null ? void 0 : $.call(d, E)) ?? (N == null ? void 0 : N.resolve(E)) ?? null;
891
+ return (($ = d.textureResolver) == null ? void 0 : $.call(d, E)) ?? (M == null ? void 0 : M.resolve(E)) ?? null;
868
892
  } : void 0;
869
- b = M.stageId, p.add(M.stageId);
870
- const { discoveredVariants: T, selections: H } = D, G = Ue(i, V, _), L = G.openStage(M.stageId), oe = await Jt(i, M.stageId, _, {
893
+ b = D.stageId, p.add(D.stageId);
894
+ const { discoveredVariants: T, selections: z } = N, G = ve(a, V, _), L = G.openStage(D.stageId), oe = await Kt(a, D.stageId, _, {
871
895
  batchSize: d.geometryBatchSize,
872
896
  onProgress: d.onGeometryProgress
873
897
  });
874
- $e(oe.materials, V, m), Te(oe.materials, V);
875
- const Ce = new Map(H.map((E) => [
898
+ Le(oe.materials, V, m), $e(oe.materials, V);
899
+ const je = new Map(z.map((E) => [
876
900
  `${E.primPath}\0${E.setName}`,
877
901
  E.selection
878
- ])), je = T.map((E) => ({
902
+ ])), Ve = T.map((E) => ({
879
903
  ...E,
880
- selection: Ce.get(`${E.primPath}\0${E.setName}`) ?? E.selection
881
- })), ae = $t(oe, je), fe = d.isTextureAllowed ?? (v === "package" ? (E) => {
904
+ selection: je.get(`${E.primPath}\0${E.setName}`) ?? E.selection
905
+ })), ae = Ct(oe, Ve), de = d.isTextureAllowed ?? (v === "package" ? (E) => {
882
906
  const $ = new URL(E, m);
883
- return k.has(X($.href, S)) || Pe($, m);
884
- } : void 0), de = I ? void 0 : fe ? (E) => j.has(E) || fe(E) : j.size > 0 ? (E) => j.has(E) : void 0;
907
+ return k.has(q($.href, S)) || Ie($, m);
908
+ } : void 0), he = I ? void 0 : de ? (E) => j.has(E) || de(E) : j.size > 0 ? (E) => j.has(E) : void 0;
885
909
  return {
886
910
  data: ae,
887
911
  pxr: G,
888
912
  stage: L,
889
913
  entryPath: _,
890
914
  textureURLs: j,
891
- ...N ? { packageTextures: N } : {},
915
+ ...M ? { packageTextures: M } : {},
892
916
  buildModel: async () => {
893
917
  const { createUSDLoadedModel: E } = await import("@openusd-wasm/three-loader"), $ = () => E(
894
918
  ae,
@@ -910,25 +934,27 @@ async function Wt(e) {
910
934
  {
911
935
  // Keep package texture identities on the model so the visual adapter
912
936
  // can resolve textures referenced by unsupported-but-known MDL nodes.
913
- usdzTextureURLs: (N == null ? void 0 : N.urls) ?? /* @__PURE__ */ new Map(),
937
+ usdzTextureURLs: (M == null ? void 0 : M.urls) ?? /* @__PURE__ */ new Map(),
914
938
  autoTextureURLs: /* @__PURE__ */ new Map()
915
939
  }
916
- ), B = de ? Ge(ae.materials, de, $) : $();
917
- B.usdQuery = Ne(L, G);
918
- const re = B.dispose.bind(B);
919
- let he = !1;
920
- return B.dispose = () => {
921
- he || (he = !0, re(), R());
922
- }, B;
940
+ ), X = Jt(
941
+ () => he ? Fe(ae.materials, he, $) : $()
942
+ ), W = X.value;
943
+ qt(W, X.warnings), W.usdQuery = Ne(L, G);
944
+ const Ge = W.dispose.bind(W);
945
+ let pe = !1;
946
+ return W.dispose = () => {
947
+ pe || (pe = !0, Ge(), R());
948
+ }, W;
923
949
  },
924
950
  readPhysics() {
925
951
  return U || (U = (async () => {
926
- if (typeof i._usd_probe_scene_physics != "function")
952
+ if (typeof a._usd_probe_scene_physics != "function")
927
953
  throw Object.assign(
928
954
  new Error("USD physics phase requires the matching packaged openusd_probe runtime."),
929
955
  { code: "E_USD_RUNTIME_VERSION" }
930
956
  );
931
- const E = l("usd_probe_scene_physics", ["number"], [M.stageId]);
957
+ const E = l("usd_probe_scene_physics", ["number"], [D.stageId]);
932
958
  if (E.ok !== !0) throw new Error(String(E.error ?? "Failed to extract USD physics."));
933
959
  return E;
934
960
  })(), U);
@@ -940,13 +966,13 @@ async function Wt(e) {
940
966
  }
941
967
  }
942
968
  return {
943
- runtime: i,
969
+ runtime: a,
944
970
  pxr: g,
945
971
  warmup: h,
946
972
  async parseAsync(w, d) {
947
973
  const m = await y(w, d);
948
974
  try {
949
- return Lt(m.data, await m.readPhysics()), await m.buildModel();
975
+ return jt(m.data, await m.readPhysics()), await m.buildModel();
950
976
  } catch (S) {
951
977
  throw m.release(), S;
952
978
  }
@@ -956,9 +982,9 @@ async function Wt(e) {
956
982
  }
957
983
  };
958
984
  }
959
- function Ue(e, t = /* @__PURE__ */ new Map(), n) {
960
- const o = (u, f, h) => JSON.parse(e.ccall(u, "string", f, h));
961
- class i {
985
+ function ve(e, t = /* @__PURE__ */ new Map(), n) {
986
+ const s = (u, f, h) => JSON.parse(e.ccall(u, "string", f, h));
987
+ class a {
962
988
  constructor(f) {
963
989
  this.path = f;
964
990
  }
@@ -968,29 +994,29 @@ function Ue(e, t = /* @__PURE__ */ new Map(), n) {
968
994
  delete() {
969
995
  }
970
996
  }
971
- let s;
997
+ let o;
972
998
  const r = /* @__PURE__ */ new Map(), c = (u, f) => {
973
- if (!s) {
999
+ if (!o) {
974
1000
  const S = e._usd_probe_flatten_stage;
975
1001
  if (n && typeof S == "function") {
976
1002
  const _ = e.ccall("usd_probe_flatten_stage", "string", ["string"], [n]);
977
1003
  if (typeof _ != "string" || !_.startsWith("#usda")) throw new Error("Unable to read flattened USD joint metadata");
978
- s = Mt(_);
1004
+ o = xt(_);
979
1005
  } else
980
- s = /* @__PURE__ */ new Map();
1006
+ o = /* @__PURE__ */ new Map();
981
1007
  }
982
- const h = s.get(f);
1008
+ const h = o.get(f);
983
1009
  if (h || r.has(f)) return h ?? r.get(f);
984
1010
  const y = ["rotX", "rotY", "rotZ", "transX", "transY", "transZ", "X", "Y", "Z"], w = [], d = /* @__PURE__ */ new Map();
985
1011
  for (const S of y) {
986
- const _ = `physxMimicJoint:${S}:referenceJoint`, O = o("usd_probe_relationship_targets", ["number", "string", "string"], [u, f, _]).paths ?? [];
1012
+ const _ = `physxMimicJoint:${S}:referenceJoint`, O = s("usd_probe_relationship_targets", ["number", "string", "string"], [u, f, _]).paths ?? [];
987
1013
  O.length && (w.push(`PhysxMimicJointAPI:${S}`), d.set(_, O));
988
1014
  }
989
1015
  const m = w.length ? { schemas: w, relationships: d } : void 0;
990
1016
  return m && r.set(f, m), m;
991
- }, a = (u, f, h) => {
1017
+ }, i = (u, f, h) => {
992
1018
  let y = null;
993
- const w = () => y ?? (y = o(
1019
+ const w = () => y ?? (y = s(
994
1020
  "usd_probe_attribute_value",
995
1021
  ["number", "string", "string"],
996
1022
  [u, f, h]
@@ -1004,22 +1030,22 @@ function Ue(e, t = /* @__PURE__ */ new Map(), n) {
1004
1030
  HasAuthoredValue: () => w().authored === !0,
1005
1031
  GetName: () => h,
1006
1032
  GetMetadata: (d) => {
1007
- const m = o("usd_probe_attribute_metadata", ["number", "string", "string", "string"], [u, f, h, d]);
1033
+ const m = s("usd_probe_attribute_metadata", ["number", "string", "string", "string"], [u, f, h, d]);
1008
1034
  return m.valid === !0 && m.found === !0 ? m.value ?? null : null;
1009
1035
  },
1010
1036
  // The viewer accepts either plain strings or objects with GetString().
1011
- GetConnections: () => o("usd_probe_attribute_connections", ["number", "string", "string"], [u, f, h]).paths ?? [],
1037
+ GetConnections: () => s("usd_probe_attribute_connections", ["number", "string", "string"], [u, f, h]).paths ?? [],
1012
1038
  delete: () => {
1013
1039
  }
1014
1040
  };
1015
1041
  }, l = (u, f) => ({
1016
1042
  __path: f,
1017
1043
  __stageId: u,
1018
- IsValid: () => o("usd_probe_prim_info", ["number", "string"], [u, f]).valid === !0,
1044
+ IsValid: () => s("usd_probe_prim_info", ["number", "string"], [u, f]).valid === !0,
1019
1045
  GetName: () => String(f.split("/").pop() ?? ""),
1020
- GetPath: () => new i(f),
1021
- GetTypeName: () => String(o("usd_probe_prim_info", ["number", "string"], [u, f]).typeName ?? ""),
1022
- IsInstance: () => o("usd_probe_prim_info", ["number", "string"], [u, f]).instance === !0,
1046
+ GetPath: () => new a(f),
1047
+ GetTypeName: () => String(s("usd_probe_prim_info", ["number", "string"], [u, f]).typeName ?? ""),
1048
+ IsInstance: () => s("usd_probe_prim_info", ["number", "string"], [u, f]).instance === !0,
1023
1049
  GetAppliedSchemas: () => {
1024
1050
  var h;
1025
1051
  return ((h = c(u, f)) == null ? void 0 : h.schemas) ?? [];
@@ -1028,29 +1054,29 @@ function Ue(e, t = /* @__PURE__ */ new Map(), n) {
1028
1054
  var h;
1029
1055
  return [...((h = c(u, f)) == null ? void 0 : h.relationships) ?? []].map(([y, w]) => ({
1030
1056
  GetName: () => y,
1031
- GetTargets: () => w.map((d) => new i(d)),
1057
+ GetTargets: () => w.map((d) => new a(d)),
1032
1058
  delete: () => {
1033
1059
  }
1034
1060
  }));
1035
1061
  },
1036
- GetAttribute: (h) => a(u, f, h),
1037
- GetAttributes: () => (o("usd_probe_prim_attributes", ["number", "string"], [u, f]).names ?? []).map((h) => a(u, f, h)),
1038
- GetChildren: () => (o("usd_probe_prim_children", ["number", "string"], [u, f]).paths ?? []).map((h) => l(u, h)),
1062
+ GetAttribute: (h) => i(u, f, h),
1063
+ GetAttributes: () => (s("usd_probe_prim_attributes", ["number", "string"], [u, f]).names ?? []).map((h) => i(u, f, h)),
1064
+ GetChildren: () => (s("usd_probe_prim_children", ["number", "string"], [u, f]).paths ?? []).map((h) => l(u, h)),
1039
1065
  GetRelationship: (h) => {
1040
- const y = o(
1066
+ const y = s(
1041
1067
  "usd_probe_relationship_targets",
1042
1068
  ["number", "string", "string"],
1043
1069
  [u, f, h]
1044
1070
  ).paths ?? [];
1045
1071
  return {
1046
1072
  GetName: () => h,
1047
- GetTargets: () => y.map((w) => new i(w)),
1073
+ GetTargets: () => y.map((w) => new a(w)),
1048
1074
  delete: () => {
1049
1075
  }
1050
1076
  };
1051
1077
  },
1052
1078
  GetMetadata: (h) => {
1053
- const y = o("usd_probe_prim_metadata", ["number", "string", "string"], [u, f, h]);
1079
+ const y = s("usd_probe_prim_metadata", ["number", "string", "string"], [u, f, h]);
1054
1080
  return y.valid !== !0 ? null : typeof y.text == "string" ? y.text : y.found === !0 ? y.value : null;
1055
1081
  },
1056
1082
  delete: () => {
@@ -1061,13 +1087,13 @@ function Ue(e, t = /* @__PURE__ */ new Map(), n) {
1061
1087
  // Stage-level metadata (metersPerUnit, upAxis, defaultPrim) is authored on
1062
1088
  // the layer, not composed onto the pseudo-root prim.
1063
1089
  GetMetadata: (f) => {
1064
- const h = o("usd_probe_stage_metadata", ["number", "string"], [u, f]);
1090
+ const h = s("usd_probe_stage_metadata", ["number", "string"], [u, f]);
1065
1091
  return h.found === !0 ? h.value : null;
1066
1092
  },
1067
1093
  GetName: () => "",
1068
1094
  IsValid: () => !0
1069
1095
  }),
1070
- GetDescendants: (f, h = "") => o(
1096
+ GetDescendants: (f, h = "") => s(
1071
1097
  "usd_probe_prim_descendants",
1072
1098
  ["number", "string", "string"],
1073
1099
  [u, f, h]
@@ -1087,12 +1113,12 @@ function Ue(e, t = /* @__PURE__ */ new Map(), n) {
1087
1113
  deleteFile: (u) => g.unlink(u),
1088
1114
  deleteDir: (u) => g.rmdir(u)
1089
1115
  },
1090
- Sdf: { Path: i },
1116
+ Sdf: { Path: a },
1091
1117
  Usd: { TimeCode: { Default: () => ({ delete: () => {
1092
1118
  } }) } },
1093
1119
  UsdShade: {
1094
1120
  ComputeBoundMaterialPath: (u) => {
1095
- const f = o("usd_probe_bound_material", ["number", "string"], [u.__stageId, u.__path]);
1121
+ const f = s("usd_probe_bound_material", ["number", "string"], [u.__stageId, u.__path]);
1096
1122
  return f.found !== !0 ? null : {
1097
1123
  materialPath: String(f.materialPath ?? ""),
1098
1124
  resolvedTargetPath: String(f.resolvedTargetPath ?? ""),
@@ -1101,28 +1127,28 @@ function Ue(e, t = /* @__PURE__ */ new Map(), n) {
1101
1127
  }
1102
1128
  },
1103
1129
  UsdUtils: {
1104
- ExtractSanitizedExternalReferences: (u) => o("usd_probe_external_references", ["string"], [u]).paths ?? []
1130
+ ExtractSanitizedExternalReferences: (u) => s("usd_probe_external_references", ["string"], [u]).paths ?? []
1105
1131
  },
1106
1132
  openStage: p
1107
1133
  };
1108
1134
  }
1109
- async function Jt(e, t, n, o = {}) {
1135
+ async function Kt(e, t, n, s = {}) {
1110
1136
  var c;
1111
1137
  if (typeof e._usd_probe_scene_visual != "function" || typeof e._usd_probe_scene_geometry != "function" || typeof e._usd_probe_scene_geometry_end != "function")
1112
1138
  throw Object.assign(
1113
1139
  new Error("USD visual phases require the matching packaged openusd_probe runtime."),
1114
1140
  { code: "E_USD_RUNTIME_VERSION" }
1115
1141
  );
1116
- const i = JSON.parse(e.ccall(
1142
+ const a = JSON.parse(e.ccall(
1117
1143
  "usd_probe_scene_visual",
1118
1144
  "string",
1119
1145
  ["number", "string"],
1120
1146
  [t, n]
1121
1147
  ));
1122
- if (i.error) throw new Error(i.error);
1123
- const s = i, r = Math.max(1, Math.floor(o.batchSize ?? 8));
1148
+ if (a.error) throw new Error(a.error);
1149
+ const o = a, r = Math.max(1, Math.floor(s.batchSize ?? 8));
1124
1150
  try {
1125
- for (const [a, l] of s.elements.entries()) {
1151
+ for (const [i, l] of o.elements.entries()) {
1126
1152
  const g = l.geometry.streamIndex;
1127
1153
  if (!Number.isInteger(g))
1128
1154
  throw new Error(`USD scene geometry is missing a stream index for ${l.path}`);
@@ -1134,24 +1160,24 @@ async function Jt(e, t, n, o = {}) {
1134
1160
  ));
1135
1161
  if (!u.ok) throw new Error(u.error ?? `Failed to stream USD geometry for ${l.path}`);
1136
1162
  l.geometry = Object.fromEntries(
1137
- Object.entries(u.geometry ?? {}).map(([f, h]) => [f, qt(e, h)])
1138
- ), (c = o.onProgress) == null || c.call(o, a + 1, s.elements.length, l.path), (a + 1) % r === 0 && await Xt();
1163
+ Object.entries(u.geometry ?? {}).map(([f, h]) => [f, en(e, h)])
1164
+ ), (c = s.onProgress) == null || c.call(s, i + 1, o.elements.length, l.path), (i + 1) % r === 0 && await Qt();
1139
1165
  }
1140
1166
  } finally {
1141
1167
  e.ccall("usd_probe_scene_geometry_end", "string", ["number"], [t]);
1142
1168
  }
1143
- return s;
1169
+ return o;
1144
1170
  }
1145
- function Xt() {
1171
+ function Qt() {
1146
1172
  return new Promise((e) => setTimeout(e, 0));
1147
1173
  }
1148
- function qt(e, t) {
1174
+ function en(e, t) {
1149
1175
  if (!t || typeof t != "object") return t ?? null;
1150
- const { ptr: n, length: o, kind: i } = t;
1151
- return typeof n != "number" ? t : o ? (i === "i32" ? new Int32Array(e.HEAP32.buffer, n, o) : new Float32Array(e.HEAPF32.buffer, n, o)).slice() : i === "i32" ? new Int32Array() : new Float32Array();
1176
+ const { ptr: n, length: s, kind: a } = t;
1177
+ return typeof n != "number" ? t : s ? (a === "i32" ? new Int32Array(e.HEAP32.buffer, n, s) : new Float32Array(e.HEAPF32.buffer, n, s)).slice() : a === "i32" ? new Int32Array() : new Float32Array();
1152
1178
  }
1153
- function De(e, t, n, o) {
1154
- const i = (u, f, h) => JSON.parse(e.ccall(u, "string", f, h)), s = [...n.variantSelections ?? []];
1179
+ function De(e, t, n, s) {
1180
+ const a = (u, f, h) => JSON.parse(e.ccall(u, "string", f, h)), o = [...n.variantSelections ?? []];
1155
1181
  let r = [];
1156
1182
  if (n.selectMuJoCoPhysicsVariant !== !1) {
1157
1183
  if (typeof e._usd_probe_stage_variants != "function")
@@ -1159,44 +1185,44 @@ function De(e, t, n, o) {
1159
1185
  new Error("USD variant discovery requires the matching packaged openusd_probe runtime."),
1160
1186
  { code: "E_USD_RUNTIME_VERSION" }
1161
1187
  );
1162
- const u = i("usd_probe_stage_variants", ["number"], [t.stageId]);
1188
+ const u = a("usd_probe_stage_variants", ["number"], [t.stageId]);
1163
1189
  if (u.ok !== !0)
1164
1190
  throw new Error(String(u.error ?? "Failed to enumerate USD variants."));
1165
1191
  r = u.variants ?? [];
1166
1192
  }
1167
- const c = new Set(r.map(q)), a = o || r.length === 0 ? s : s.filter((u) => c.has(q(u))), l = n.selectMuJoCoPhysicsVariant === !1 ? [] : Nt(r, a), p = /* @__PURE__ */ new Map();
1168
- for (const u of [...a, ...l])
1169
- p.set(q(u), u);
1193
+ const c = new Set(r.map(Z)), i = s || r.length === 0 ? o : o.filter((u) => c.has(Z(u))), l = n.selectMuJoCoPhysicsVariant === !1 ? [] : Dt(r, i), p = /* @__PURE__ */ new Map();
1194
+ for (const u of [...i, ...l])
1195
+ p.set(Z(u), u);
1170
1196
  let g = [];
1171
1197
  for (const u of p.values()) {
1172
- const f = i(
1198
+ const f = a(
1173
1199
  "usd_probe_stage_set_variant",
1174
1200
  ["number", "string", "string", "string"],
1175
1201
  [t.stageId, u.primPath, u.setName, u.selection]
1176
1202
  );
1177
1203
  if (f.ok === !0)
1178
1204
  g.push(u);
1179
- else if (o)
1205
+ else if (s)
1180
1206
  throw new Error(String(f.error ?? `Failed to select USD variant ${u.primPath}:${u.setName}=${u.selection}`));
1181
1207
  }
1182
1208
  if (n.selectMuJoCoPhysicsVariant !== !1) {
1183
- const u = new Set(a.map(q)), f = /* @__PURE__ */ new Set();
1209
+ const u = new Set(i.map(Z)), f = /* @__PURE__ */ new Set();
1184
1210
  for (const h of g) {
1185
- const y = q(h);
1211
+ const y = Z(h);
1186
1212
  if (u.has(y)) continue;
1187
1213
  const w = r.find((S) => S.primPath === h.primPath && S.setName === h.setName);
1188
1214
  if (!(w != null && w.selection) || w.selection === h.selection) continue;
1189
- const d = i(
1215
+ const d = a(
1190
1216
  "usd_probe_prim_descendants",
1191
1217
  ["number", "string", "string"],
1192
1218
  [t.stageId, h.primPath, "MjcActuator"]
1193
1219
  );
1194
1220
  if (d.ok !== !0) {
1195
- if (o) throw new Error(String(d.error ?? "Failed to inspect USD variants."));
1221
+ if (s) throw new Error(String(d.error ?? "Failed to inspect USD variants."));
1196
1222
  continue;
1197
1223
  }
1198
1224
  if ((d.paths ?? []).length === 0) continue;
1199
- const m = i(
1225
+ const m = a(
1200
1226
  "usd_probe_stage_set_variant",
1201
1227
  ["number", "string", "string", "string"],
1202
1228
  [t.stageId, h.primPath, h.setName, w.selection]
@@ -1205,50 +1231,50 @@ function De(e, t, n, o) {
1205
1231
  throw new Error(String(m.error ?? `Failed to restore authored USD variant ${h.primPath}:${h.setName}=${w.selection}`));
1206
1232
  f.add(y);
1207
1233
  }
1208
- f.size > 0 && (g = g.filter((h) => !f.has(q(h))));
1234
+ f.size > 0 && (g = g.filter((h) => !f.has(Z(h))));
1209
1235
  }
1210
1236
  return { discoveredVariants: r, selections: g };
1211
1237
  }
1212
- async function Zt(e, t, n, o, i, s, r, c, a, l, p, g, u, f, h, y, w, d) {
1213
- const m = {}, S = [...f], _ = X(t.href, n), O = xe(t.href, t), F = /* @__PURE__ */ new Set([O]), j = /* @__PURE__ */ new Map([[_, 0]]), z = /* @__PURE__ */ new Set([_]);
1238
+ async function tn(e, t, n, s, a, o, r, c, i, l, p, g, u, f, h, y, w, d) {
1239
+ const m = {}, S = [...f], _ = q(t.href, n), O = Oe(t.href, t), B = /* @__PURE__ */ new Set([O]), j = /* @__PURE__ */ new Map([[_, 0]]), F = /* @__PURE__ */ new Set([_]);
1214
1240
  r.set(_, O);
1215
- const W = /* @__PURE__ */ new Set(), J = () => {
1241
+ const H = /* @__PURE__ */ new Set(), J = () => {
1216
1242
  const b = Object.keys(m).length > 0;
1217
1243
  if (b && typeof e._usd_probe_stage_open_mapped != "function")
1218
1244
  throw Object.assign(
1219
1245
  new Error("USD dependency mapping requires the matching packaged openusd_probe.js and .wasm runtime."),
1220
1246
  { code: "E_USD_RUNTIME_VERSION" }
1221
1247
  );
1222
- return b ? i("usd_probe_stage_open_mapped", ["string", "string"], [_, JSON.stringify(m)]) : i("usd_probe_stage_open", ["string"], [_]);
1248
+ return b ? a("usd_probe_stage_open_mapped", ["string", "string"], [_, JSON.stringify(m)]) : a("usd_probe_stage_open", ["string"], [_]);
1223
1249
  }, V = (b) => {
1224
- var H, G;
1225
- const N = r.get(b.layer);
1226
- if (N === void 0)
1250
+ var z, G;
1251
+ const M = r.get(b.layer);
1252
+ if (M === void 0)
1227
1253
  throw new Error(`Missing USD layer identity for ${b.layer}`);
1228
- const U = ((H = Object.entries(m[b.layer] ?? {}).find(([, L]) => L === b.path)) == null ? void 0 : H[0]) ?? b.path;
1254
+ const U = ((z = Object.entries(m[b.layer] ?? {}).find(([, L]) => L === b.path)) == null ? void 0 : z[0]) ?? b.path;
1229
1255
  if (!U || /^(?:data|blob):/i.test(U) || /\.mdl(?:[?#].*)?$/i.test(U))
1230
1256
  return null;
1231
- const R = Oe(U, N, t);
1257
+ const R = Te(U, M, t);
1232
1258
  if (!R) return null;
1233
- const { resolved: A, absolute: k, childIdentifier: v } = R, I = X(A.href, n), P = nt(I, S), M = (P == null ? void 0 : P.paths.length) === 1 ? P.paths[0] : null, D = M ?? I, x = b.kind !== "resource" || Kt(A.pathname), T = (j.get(b.layer) ?? 0) + 1;
1234
- if (M && r.set(M, v), m[G = b.layer] ?? (m[G] = {}), b.kind === "resource" && u === "package" && P && P.paths.length > 1) {
1259
+ const { resolved: A, absolute: k, childIdentifier: v } = R, I = q(A.href, n), P = st(I, S), D = (P == null ? void 0 : P.paths.length) === 1 ? P.paths[0] : null, N = D ?? I, x = b.kind !== "resource" || rn(A.pathname), T = (j.get(b.layer) ?? 0) + 1;
1260
+ if (D && r.set(D, v), m[G = b.layer] ?? (m[G] = {}), b.kind === "resource" && u === "package" && P && P.paths.length > 1) {
1235
1261
  const L = `${n}/__deferred_udim__/${encodeURIComponent(v)}`;
1236
1262
  return m[b.layer][U] = L, r.set(L, v), null;
1237
1263
  }
1238
- if (u === "package" && !f.has(D) && !Pe(A, t)) {
1264
+ if (u === "package" && !f.has(N) && !Ie(A, t)) {
1239
1265
  const L = `${n}/__skipped__/${encodeURIComponent(v)}`;
1240
- return m[b.layer][U] = L, r.set(L, v), W.has(v) || (W.add(v), w == null || w(v)), null;
1266
+ return m[b.layer][U] = L, r.set(L, v), H.has(v) || (H.add(v), w == null || w(v)), null;
1241
1267
  }
1242
1268
  if (!x && c && (c.set(v, A.href), c.set(U, A.href)), !x && !h)
1243
- return m[b.layer][U] = D, r.set(D, v), null;
1244
- if (m[b.layer][U] = D, s.has(D))
1245
- return r.set(D, v), j.set(D, T), x && z.add(D), null;
1246
- if (F.has(v)) return null;
1269
+ return m[b.layer][U] = N, r.set(N, v), null;
1270
+ if (m[b.layer][U] = N, o.has(N))
1271
+ return r.set(N, v), j.set(N, T), x && F.add(N), null;
1272
+ if (B.has(v)) return null;
1247
1273
  if (T > p)
1248
1274
  throw new Error(`USD dependency depth limit exceeded (${p}): ${v}`);
1249
- if (F.size >= l)
1275
+ if (B.size >= l)
1250
1276
  throw new Error(`USD dependency limit exceeded (${l}).`);
1251
- return F.add(v), j.set(D, T), {
1277
+ return B.add(v), j.set(N, T), {
1252
1278
  item: {
1253
1279
  url: A,
1254
1280
  depth: T,
@@ -1263,14 +1289,14 @@ async function Zt(e, t, n, o, i, s, r, c, a, l, p, g, u, f, h, y, w, d) {
1263
1289
  for (; ; ) {
1264
1290
  const b = J();
1265
1291
  if (!b.ok) throw new Error(b.error ?? `Failed to open ${_}`);
1266
- let N, U = [];
1292
+ let M, U = [];
1267
1293
  try {
1268
- if (N = De(e, b, y, !1), typeof e._usd_probe_stage_external_references != "function")
1294
+ if (M = De(e, b, y, !1), typeof e._usd_probe_stage_external_references != "function")
1269
1295
  throw Object.assign(
1270
1296
  new Error("Variant-aware USD dependency discovery requires the matching packaged openusd_probe runtime."),
1271
1297
  { code: "E_USD_RUNTIME_VERSION" }
1272
1298
  );
1273
- const R = i("usd_probe_stage_external_references", ["number"], [b.stageId]);
1299
+ const R = a("usd_probe_stage_external_references", ["number"], [b.stageId]);
1274
1300
  if (R.ok !== !0)
1275
1301
  throw new Error(String(R.error ?? "Failed to enumerate active USD dependencies."));
1276
1302
  const A = R.dependencies ?? [], k = /* @__PURE__ */ new Set();
@@ -1282,88 +1308,88 @@ async function Zt(e, t, n, o, i, s, r, c, a, l, p, g, u, f, h, y, w, d) {
1282
1308
  }
1283
1309
  if (U.length === 0) {
1284
1310
  const v = /* @__PURE__ */ new Map();
1285
- for (const I of z) {
1286
- if (a.get(I) === !1) continue;
1287
- const P = i("usd_probe_external_references", ["string"], [I]);
1311
+ for (const I of F) {
1312
+ if (i.get(I) === !1) continue;
1313
+ const P = a("usd_probe_external_references", ["string"], [I]);
1288
1314
  if (v.set(I, P), P.hasVariantSets !== !1) continue;
1289
- const M = new Set(
1315
+ const D = new Set(
1290
1316
  P.compositionPaths ?? []
1291
1317
  );
1292
1318
  for (const x of P.subLayers ?? []) {
1293
1319
  if (!x) continue;
1294
1320
  const T = V({ kind: "sublayer", layer: I, path: x });
1295
- T && !U.some((H) => H.identifier === T.identifier) && U.push(T);
1321
+ T && !U.some((z) => z.identifier === T.identifier) && U.push(T);
1296
1322
  }
1297
- const D = [
1323
+ const N = [
1298
1324
  ["reference", P.references],
1299
1325
  ["payload", P.payloads]
1300
1326
  ];
1301
- for (const [x, T] of D)
1302
- for (const H of T ?? []) {
1303
- if (!H || !M.has(H)) continue;
1304
- const G = V({ kind: x, layer: I, path: H });
1327
+ for (const [x, T] of N)
1328
+ for (const z of T ?? []) {
1329
+ if (!z || !D.has(z)) continue;
1330
+ const G = V({ kind: x, layer: I, path: z });
1305
1331
  G && !U.some((L) => L.identifier === G.identifier) && U.push(G);
1306
1332
  }
1307
1333
  }
1308
1334
  if (U.length === 0)
1309
1335
  for (const [I, P] of v) {
1310
- const M = new Set(
1336
+ const D = new Set(
1311
1337
  P.compositionPaths ?? []
1312
1338
  );
1313
- for (const D of P.paths ?? []) {
1314
- if (!D || M.has(D)) continue;
1315
- const x = V({ kind: "resource", layer: I, path: D });
1339
+ for (const N of P.paths ?? []) {
1340
+ if (!N || D.has(N)) continue;
1341
+ const x = V({ kind: "resource", layer: I, path: N });
1316
1342
  x && !U.some((T) => T.identifier === x.identifier) && U.push(x);
1317
1343
  }
1318
1344
  }
1319
1345
  }
1320
1346
  } catch (R) {
1321
- throw i("usd_probe_stage_release", ["number"], [b.stageId]), R;
1347
+ throw a("usd_probe_stage_release", ["number"], [b.stageId]), R;
1322
1348
  }
1323
1349
  if (U.length === 0)
1324
- return { mappings: m, opened: b, variantConfiguration: N };
1325
- i("usd_probe_stage_release", ["number"], [b.stageId]), await Yt(
1350
+ return { mappings: m, opened: b, variantConfiguration: M };
1351
+ a("usd_probe_stage_release", ["number"], [b.stageId]), await nn(
1326
1352
  U,
1327
1353
  Math.max(1, g),
1328
1354
  async ({ item: R, identifier: A }) => {
1329
1355
  if (!R.recurse && !h) return;
1330
- const k = X(R.url.href, n);
1356
+ const k = q(R.url.href, n);
1331
1357
  let v;
1332
1358
  try {
1333
- v = await o(R.url, A);
1359
+ v = await s(R.url, A);
1334
1360
  } catch (I) {
1335
- if (!R.resource || !qe(A) || !Ke(I))
1361
+ if (!R.resource || !Ye(A) || !et(I))
1336
1362
  throw I;
1337
1363
  const P = `${n}/__unavailable__/${encodeURIComponent(A)}`;
1338
1364
  R.owner && (m[R.owner.path][R.owner.reference] = P), r.set(P, A), d == null || d(A, I);
1339
1365
  return;
1340
1366
  }
1341
- a.set(k, Me(v)), le(e, k, v, s), r.set(k, A), R.recurse && (m[k] ?? (m[k] = {}), z.add(k));
1367
+ i.set(k, ke(v)), fe(e, k, v, o), r.set(k, A), R.recurse && (m[k] ?? (m[k] = {}), F.add(k));
1342
1368
  }
1343
1369
  );
1344
1370
  }
1345
1371
  }
1346
- async function Yt(e, t, n) {
1347
- const o = new Array(e.length);
1348
- let i = 0;
1349
- const s = Array.from({ length: Math.min(t, e.length) }, async () => {
1350
- for (; i < e.length; ) {
1351
- const r = i++;
1352
- o[r] = await n(e[r]);
1372
+ async function nn(e, t, n) {
1373
+ const s = new Array(e.length);
1374
+ let a = 0;
1375
+ const o = Array.from({ length: Math.min(t, e.length) }, async () => {
1376
+ for (; a < e.length; ) {
1377
+ const r = a++;
1378
+ s[r] = await n(e[r]);
1353
1379
  }
1354
1380
  });
1355
- return await Promise.all(s), o;
1381
+ return await Promise.all(o), s;
1356
1382
  }
1357
- function Kt(e) {
1358
- var n, o;
1359
- const t = (o = (n = e.split(/[?#]/, 1)[0]) == null ? void 0 : n.split(".").pop()) == null ? void 0 : o.toLowerCase();
1360
- return t != null && Ht.has(t);
1383
+ function rn(e) {
1384
+ var n, s;
1385
+ const t = (s = (n = e.split(/[?#]/, 1)[0]) == null ? void 0 : n.split(".").pop()) == null ? void 0 : s.toLowerCase();
1386
+ return t != null && Zt.has(t);
1361
1387
  }
1362
- function Me(e) {
1363
- return ke(e) ? e.includes(64) : !0;
1388
+ function ke(e) {
1389
+ return xe(e) ? e.includes(64) : !0;
1364
1390
  }
1365
- function Qt(e) {
1366
- return ke(e) ? en(e, [
1391
+ function sn(e) {
1392
+ return xe(e) ? on(e, [
1367
1393
  "subLayers",
1368
1394
  "references",
1369
1395
  "payload",
@@ -1371,174 +1397,174 @@ function Qt(e) {
1371
1397
  "clipAssetPaths"
1372
1398
  ]) : !0;
1373
1399
  }
1374
- function ke(e) {
1400
+ function xe(e) {
1375
1401
  let t = e[0] === 239 && e[1] === 187 && e[2] === 191 ? 3 : 0;
1376
1402
  for (; t < e.length && t < 64 && /\s/.test(String.fromCharCode(e[t])); ) t += 1;
1377
1403
  return e[t] === 35 && e[t + 1] === 117 && e[t + 2] === 115 && e[t + 3] === 100 && e[t + 4] === 97;
1378
1404
  }
1379
- function en(e, t) {
1405
+ function on(e, t) {
1380
1406
  const n = /* @__PURE__ */ new Map();
1381
- let o = 1;
1382
- for (const s of t) {
1383
- const r = s.charCodeAt(0);
1384
- n.set(r, [...n.get(r) ?? [], s]), o = Math.max(o, s.length);
1407
+ let s = 1;
1408
+ for (const o of t) {
1409
+ const r = o.charCodeAt(0);
1410
+ n.set(r, [...n.get(r) ?? [], o]), s = Math.max(s, o.length);
1385
1411
  }
1386
- const i = e.length - o;
1387
- for (let s = 0; s <= i; ++s) {
1388
- const r = n.get(e[s]);
1412
+ const a = e.length - s;
1413
+ for (let o = 0; o <= a; ++o) {
1414
+ const r = n.get(e[o]);
1389
1415
  if (r)
1390
1416
  for (const c of r) {
1391
- let a = !0;
1417
+ let i = !0;
1392
1418
  for (let l = 1; l < c.length; ++l)
1393
- if (e[s + l] !== c.charCodeAt(l)) {
1394
- a = !1;
1419
+ if (e[o + l] !== c.charCodeAt(l)) {
1420
+ i = !1;
1395
1421
  break;
1396
1422
  }
1397
- if (a) return !0;
1423
+ if (i) return !0;
1398
1424
  }
1399
1425
  }
1400
1426
  return !1;
1401
1427
  }
1402
- function xe(e, t) {
1428
+ function Oe(e, t) {
1403
1429
  const n = new URL(e);
1404
1430
  if (n.protocol !== t.protocol || n.host !== t.host) return n.href;
1405
- const o = new URL(".", t).pathname.split("/").filter(Boolean), i = n.pathname.split("/").filter(Boolean);
1406
- let s = 0;
1407
- for (; s < o.length && o[s] === i[s]; ) s++;
1408
- const r = [...o.slice(s).map(() => ".."), ...i.slice(s)].join("/");
1431
+ const s = new URL(".", t).pathname.split("/").filter(Boolean), a = n.pathname.split("/").filter(Boolean);
1432
+ let o = 0;
1433
+ for (; o < s.length && s[o] === a[o]; ) o++;
1434
+ const r = [...s.slice(o).map(() => ".."), ...a.slice(o)].join("/");
1409
1435
  return decodeURIComponent(r) + n.search + n.hash;
1410
1436
  }
1411
- function Oe(e, t, n) {
1412
- let o;
1437
+ function Te(e, t, n) {
1438
+ let s;
1413
1439
  try {
1414
- o = new URL(e, new URL(t, n));
1440
+ s = new URL(e, new URL(t, n));
1415
1441
  } catch {
1416
1442
  return null;
1417
1443
  }
1418
- const i = /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(t), s = /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(e), r = i || s;
1444
+ const a = /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(t), o = /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(e), r = a || o;
1419
1445
  return {
1420
- resolved: o,
1446
+ resolved: s,
1421
1447
  absolute: r,
1422
- childIdentifier: r ? o.href : xe(o.href, n)
1448
+ childIdentifier: r ? s.href : Oe(s.href, n)
1423
1449
  };
1424
1450
  }
1425
- function X(e, t) {
1426
- const n = new URL(e), o = encodeURIComponent(`${n.protocol}//${n.host}`);
1427
- let i = n.pathname.split("/").map((s) => decodeURIComponent(s).replaceAll("/", "%2F").replaceAll("\\", "%5C")).join("/");
1451
+ function q(e, t) {
1452
+ const n = new URL(e), s = encodeURIComponent(`${n.protocol}//${n.host}`);
1453
+ let a = n.pathname.split("/").map((o) => decodeURIComponent(o).replaceAll("/", "%2F").replaceAll("\\", "%5C")).join("/");
1428
1454
  if (n.search || n.hash) {
1429
- const s = i.lastIndexOf("."), r = s > i.lastIndexOf("/") ? s : i.length;
1430
- i = `${i.slice(0, r)}.__url_${encodeURIComponent(n.search + n.hash)}${i.slice(r)}`;
1455
+ const o = a.lastIndexOf("."), r = o > a.lastIndexOf("/") ? o : a.length;
1456
+ a = `${a.slice(0, r)}.__url_${encodeURIComponent(n.search + n.hash)}${a.slice(r)}`;
1431
1457
  }
1432
- return `${t}/${o}${i}`;
1458
+ return `${t}/${s}${a}`;
1433
1459
  }
1434
- function Te(e, t) {
1460
+ function $e(e, t) {
1435
1461
  if (!e || typeof e != "object" || ArrayBuffer.isView(e)) return;
1436
1462
  const n = e;
1437
1463
  if (typeof n.path == "string" && typeof n.resolvedPath == "string") {
1438
- for (const o of ["path", "resolvedPath"]) {
1439
- const i = n[o];
1440
- n[o] = t.get(i) ?? i;
1464
+ for (const s of ["path", "resolvedPath"]) {
1465
+ const a = n[s];
1466
+ n[s] = t.get(a) ?? a;
1441
1467
  }
1442
1468
  return;
1443
1469
  }
1444
- for (const o of Object.values(e)) Te(o, t);
1470
+ for (const s of Object.values(e)) $e(s, t);
1445
1471
  }
1446
- function $e(e, t, n) {
1472
+ function Le(e, t, n) {
1447
1473
  if (!e || typeof e != "object" || ArrayBuffer.isView(e)) return;
1448
- const o = e;
1449
- if (typeof o.path == "string" && typeof o.ownerLayer == "string") {
1450
- const i = t.get(o.path);
1451
- if (i)
1452
- o.path = i, o.resolvedPath = i;
1474
+ const s = e;
1475
+ if (typeof s.path == "string" && typeof s.ownerLayer == "string") {
1476
+ const a = t.get(s.path);
1477
+ if (a)
1478
+ s.path = a, s.resolvedPath = a;
1453
1479
  else {
1454
- const s = t.get(o.ownerLayer);
1455
- if (s) {
1456
- const r = Oe(o.path, s, n);
1457
- r && (o.path = r.childIdentifier, o.resolvedPath = r.childIdentifier);
1480
+ const o = t.get(s.ownerLayer);
1481
+ if (o) {
1482
+ const r = Te(s.path, o, n);
1483
+ r && (s.path = r.childIdentifier, s.resolvedPath = r.childIdentifier);
1458
1484
  }
1459
1485
  }
1460
- delete o.ownerLayer;
1486
+ delete s.ownerLayer;
1461
1487
  return;
1462
1488
  }
1463
- for (const i of Object.values(e)) $e(i, t, n);
1489
+ for (const a of Object.values(e)) Le(a, t, n);
1464
1490
  }
1465
- function Le(e, t) {
1491
+ function Ce(e, t) {
1466
1492
  if (e.analyzePath(t).exists) {
1467
1493
  for (const n of e.readdir(t)) {
1468
1494
  if (n === "." || n === "..") continue;
1469
- const o = `${t}/${n}`;
1470
- e.isDir(e.stat(o).mode) ? Le(e, o) : e.unlink(o);
1495
+ const s = `${t}/${n}`;
1496
+ e.isDir(e.stat(s).mode) ? Ce(e, s) : e.unlink(s);
1471
1497
  }
1472
1498
  e.rmdir(t);
1473
1499
  }
1474
1500
  }
1475
- function le(e, t, n, o) {
1476
- o.has(t) || (e.FS.mkdirTree(t.split("/").slice(0, -1).join("/") || "/"), e.FS.writeFile(t, n), o.add(t));
1501
+ function fe(e, t, n, s) {
1502
+ s.has(t) || (e.FS.mkdirTree(t.split("/").slice(0, -1).join("/") || "/"), e.FS.writeFile(t, n), s.add(t));
1477
1503
  }
1478
- function q(e) {
1504
+ function Z(e) {
1479
1505
  return `${e.primPath}\0${e.setName}`;
1480
1506
  }
1481
- async function ve(e) {
1507
+ async function Pe(e) {
1482
1508
  return typeof e == "string" ? new TextEncoder().encode(e) : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(await e.arrayBuffer());
1483
1509
  }
1484
- async function tn(e) {
1510
+ async function an(e) {
1485
1511
  if (!e) throw new Error("createSingleThreadUsd needs wasmUrl or wasmBinary.");
1486
1512
  return (await fetch(e)).arrayBuffer();
1487
1513
  }
1488
- function nn(e) {
1514
+ function cn(e) {
1489
1515
  if (e.length < 30) return null;
1490
- const t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = (o, i) => {
1491
- for (let s = 0; s < i.length; s += 1)
1492
- if (e[o + s] !== i.charCodeAt(s)) return !1;
1516
+ const t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = (s, a) => {
1517
+ for (let o = 0; o < a.length; o += 1)
1518
+ if (e[s + o] !== a.charCodeAt(o)) return !1;
1493
1519
  return !0;
1494
1520
  };
1495
1521
  if (e[0] === 137 && n(1, "PNG") && n(12, "IHDR"))
1496
- return Y(t.getUint32(16), t.getUint32(20));
1522
+ return K(t.getUint32(16), t.getUint32(20));
1497
1523
  if (e[0] === 255 && e[1] === 216) {
1498
- let o = 2;
1499
- for (; o + 9 < e.length; ) {
1500
- if (e[o] !== 255) return null;
1501
- const i = e[o + 1], s = e[o + 2] << 8 | e[o + 3];
1502
- if (i >= 192 && i <= 207 && i !== 196 && i !== 200 && i !== 204)
1503
- return Y(
1504
- e[o + 7] << 8 | e[o + 8],
1505
- e[o + 5] << 8 | e[o + 6]
1524
+ let s = 2;
1525
+ for (; s + 9 < e.length; ) {
1526
+ if (e[s] !== 255) return null;
1527
+ const a = e[s + 1], o = e[s + 2] << 8 | e[s + 3];
1528
+ if (a >= 192 && a <= 207 && a !== 196 && a !== 200 && a !== 204)
1529
+ return K(
1530
+ e[s + 7] << 8 | e[s + 8],
1531
+ e[s + 5] << 8 | e[s + 6]
1506
1532
  );
1507
- if (s < 2) return null;
1508
- o += 2 + s;
1533
+ if (o < 2) return null;
1534
+ s += 2 + o;
1509
1535
  }
1510
1536
  return null;
1511
1537
  }
1512
1538
  if (n(0, "RIFF") && n(8, "WEBP")) {
1513
1539
  if (n(12, "VP8 "))
1514
- return Y(
1540
+ return K(
1515
1541
  t.getUint16(26, !0) & 16383,
1516
1542
  t.getUint16(28, !0) & 16383
1517
1543
  );
1518
1544
  if (n(12, "VP8L")) {
1519
- const o = t.getUint32(21, !0);
1520
- return Y((o & 16383) + 1, (o >>> 14 & 16383) + 1);
1545
+ const s = t.getUint32(21, !0);
1546
+ return K((s & 16383) + 1, (s >>> 14 & 16383) + 1);
1521
1547
  }
1522
1548
  if (n(12, "VP8X")) {
1523
- const o = (i) => e[i] | e[i + 1] << 8 | e[i + 2] << 16;
1524
- return Y(o(24) + 1, o(27) + 1);
1549
+ const s = (a) => e[a] | e[a + 1] << 8 | e[a + 2] << 16;
1550
+ return K(s(24) + 1, s(27) + 1);
1525
1551
  }
1526
1552
  }
1527
1553
  return null;
1528
1554
  }
1529
- function rn(e, t) {
1555
+ function un(e, t) {
1530
1556
  const n = Math.max(e.width, e.height);
1531
1557
  if (t <= 0 || n <= t) return e;
1532
- const o = t / n;
1558
+ const s = t / n;
1533
1559
  return {
1534
- width: Math.max(1, Math.round(e.width * o)),
1535
- height: Math.max(1, Math.round(e.height * o))
1560
+ width: Math.max(1, Math.round(e.width * s)),
1561
+ height: Math.max(1, Math.round(e.height * s))
1536
1562
  };
1537
1563
  }
1538
- function Y(e, t) {
1564
+ function K(e, t) {
1539
1565
  return e > 0 && t > 0 ? { width: e, height: t } : null;
1540
1566
  }
1541
- function Z(e) {
1567
+ function Y(e) {
1542
1568
  return e instanceof Error ? {
1543
1569
  name: e.name,
1544
1570
  message: e.message,
@@ -1546,55 +1572,55 @@ function Z(e) {
1546
1572
  ...e.stack ? { stack: e.stack } : {}
1547
1573
  } : { name: "Error", message: String(e) };
1548
1574
  }
1549
- const Q = globalThis;
1550
- let te = null, K = null, ne = null, se = null, ue = !1, sn = 1;
1551
- const ee = /* @__PURE__ */ new Map();
1575
+ const ee = globalThis;
1576
+ let ne = null, Q = null, re = null, se = null, le = !1, ln = 1;
1577
+ const te = /* @__PURE__ */ new Map();
1552
1578
  function C(e, t) {
1553
- Q.postMessage(e, t);
1579
+ ee.postMessage(e, t);
1554
1580
  }
1555
- function on(e, t) {
1556
- const n = sn++;
1557
- return new Promise((o, i) => {
1558
- ee.set(n, { resolve: o, reject: i }), C({ type: "resource-request", id: n, url: e.href, identifier: t });
1581
+ function fn(e, t) {
1582
+ const n = ln++;
1583
+ return new Promise((s, a) => {
1584
+ te.set(n, { resolve: s, reject: a }), C({ type: "resource-request", id: n, url: e.href, identifier: t });
1559
1585
  });
1560
1586
  }
1561
- function an(e) {
1562
- return te ?? (te = Wt(e)), te;
1587
+ function dn(e) {
1588
+ return ne ?? (ne = Yt(e)), ne;
1563
1589
  }
1564
- function cn(e) {
1590
+ function hn(e) {
1565
1591
  const t = /* @__PURE__ */ new Set();
1566
1592
  for (const n of e.elements)
1567
- for (const o of Object.values(n.geometry ?? {}))
1568
- ArrayBuffer.isView(o) && t.add(o.buffer);
1593
+ for (const s of Object.values(n.geometry ?? {}))
1594
+ ArrayBuffer.isView(s) && t.add(s.buffer);
1569
1595
  return [...t];
1570
1596
  }
1571
- async function un(e) {
1572
- if (!ne) throw new Error("USD worker has no live stage");
1573
- const t = ne[e.method];
1574
- return { type: "query-result", id: e.id, value: await t.apply(ne, e.args) };
1597
+ async function pn(e) {
1598
+ if (!re) throw new Error("USD worker has no live stage");
1599
+ const t = re[e.method];
1600
+ return { type: "query-result", id: e.id, value: await t.apply(re, e.args) };
1575
1601
  }
1576
- async function ln(e, t) {
1602
+ async function gn(e, t) {
1577
1603
  if (typeof createImageBitmap != "function")
1578
1604
  throw new Error("This browser cannot decode USD textures in a worker.");
1579
1605
  const n = await fetch(e);
1580
1606
  if (!n.ok) throw new Error(`HTTP ${n.status} for ${e}`);
1581
- const o = new Uint8Array(await n.arrayBuffer()), i = nn(o), s = {
1607
+ const s = new Uint8Array(await n.arrayBuffer()), a = cn(s), o = {
1582
1608
  imageOrientation: "flipY",
1583
1609
  premultiplyAlpha: "none",
1584
1610
  colorSpaceConversion: "none"
1585
1611
  };
1586
- if (i) {
1587
- const r = t > 0 ? rn(i, t) : i;
1588
- (r.width !== i.width || r.height !== i.height) && (s.resizeWidth = r.width, s.resizeHeight = r.height, s.resizeQuality = "high");
1612
+ if (a) {
1613
+ const r = t > 0 ? un(a, t) : a;
1614
+ (r.width !== a.width || r.height !== a.height) && (o.resizeWidth = r.width, o.resizeHeight = r.height, o.resizeQuality = "high");
1589
1615
  }
1590
- return createImageBitmap(new Blob([o]), s);
1616
+ return createImageBitmap(new Blob([s]), o);
1591
1617
  }
1592
- Q.onmessage = async (e) => {
1618
+ ee.onmessage = async (e) => {
1593
1619
  const t = e.data;
1594
1620
  if (t.type === "resource-result") {
1595
- const n = ee.get(t.id);
1621
+ const n = te.get(t.id);
1596
1622
  if (!n) return;
1597
- ee.delete(t.id), t.error ? n.reject(Object.assign(new Error(t.error.message), {
1623
+ te.delete(t.id), t.error ? n.reject(Object.assign(new Error(t.error.message), {
1598
1624
  name: t.error.name,
1599
1625
  ...t.error.code ? { code: t.error.code } : {}
1600
1626
  })) : n.resolve(t.bytes ?? new Uint8Array());
@@ -1602,15 +1628,15 @@ Q.onmessage = async (e) => {
1602
1628
  }
1603
1629
  if (t.type === "query") {
1604
1630
  try {
1605
- C(await un(t));
1631
+ C(await pn(t));
1606
1632
  } catch (n) {
1607
- C({ type: "error", id: t.id, error: Z(n) });
1633
+ C({ type: "error", id: t.id, error: Y(n) });
1608
1634
  }
1609
1635
  return;
1610
1636
  }
1611
1637
  if (t.type === "decode-texture") {
1612
1638
  try {
1613
- const n = await ln(t.url, t.maxDimension);
1639
+ const n = await gn(t.url, t.maxDimension);
1614
1640
  C({
1615
1641
  type: "texture-decoded",
1616
1642
  id: t.id,
@@ -1619,55 +1645,55 @@ Q.onmessage = async (e) => {
1619
1645
  height: n.height
1620
1646
  }, [n]);
1621
1647
  } catch (n) {
1622
- C({ type: "error", id: t.id, error: Z(n) });
1648
+ C({ type: "error", id: t.id, error: Y(n) });
1623
1649
  }
1624
1650
  return;
1625
1651
  }
1626
1652
  if (t.type === "dispose") {
1627
- for (const n of ee.values()) n.reject(new Error("USD worker disposed"));
1628
- ee.clear(), K == null || K(), ne = null, se = null, ue = !1, te = null, K = null, Q.close();
1653
+ for (const n of te.values()) n.reject(new Error("USD worker disposed"));
1654
+ te.clear(), Q == null || Q(), re = null, se = null, le = !1, ne = null, Q = null, ee.close();
1629
1655
  return;
1630
1656
  }
1631
1657
  if (t.type === "extract-physics") {
1632
- if (ue || !se) return;
1633
- ue = !0;
1658
+ if (le || !se) return;
1659
+ le = !0;
1634
1660
  try {
1635
1661
  C({ type: "physics-ready", phase: await se() });
1636
1662
  } catch (n) {
1637
- C({ type: "physics-failed", error: Z(n) });
1663
+ C({ type: "physics-failed", error: Y(n) });
1638
1664
  }
1639
1665
  return;
1640
1666
  }
1641
1667
  if (t.type === "prepare") {
1642
1668
  try {
1643
- const n = await an(t.runtime);
1669
+ const n = await dn(t.runtime);
1644
1670
  t.warmup && await n.warmup(), C({ type: "worker-ready" });
1645
1671
  } catch (n) {
1646
- C({ type: "error", error: Z(n) }), Q.close();
1672
+ C({ type: "error", error: Y(n) }), ee.close();
1647
1673
  }
1648
1674
  return;
1649
1675
  }
1650
1676
  try {
1651
- if (!te) throw new Error("USD worker was not prepared before load");
1652
- const o = await (await te).parseVisualSceneAsync(t.input, {
1677
+ if (!ne) throw new Error("USD worker was not prepared before load");
1678
+ const s = await (await ne).parseVisualSceneAsync(t.input, {
1653
1679
  ...t.options,
1654
1680
  packagePaths: t.options.packagePaths,
1655
1681
  readTextureBytes: t.options.readTextureBytes ?? !1,
1656
1682
  loadTextures: !1,
1657
1683
  convertZUp: !1,
1658
1684
  loadLights: !1,
1659
- resolveBytes: on,
1685
+ resolveBytes: fn,
1660
1686
  onReferenceSkipped: (r) => C({ type: "event", event: "reference-skipped", identifier: r }),
1661
- onResourceFailed: (r, c) => C({ type: "event", event: "resource-failed", identifier: r, error: Z(c) })
1687
+ onResourceFailed: (r, c) => C({ type: "event", event: "resource-failed", identifier: r, error: Y(c) })
1662
1688
  });
1663
- K = o.release, ne = Ne(o.stage, o.pxr), se = o.readPhysics;
1664
- const i = o.data, s = cn(i);
1689
+ Q = s.release, re = Ne(s.stage, s.pxr), se = s.readPhysics;
1690
+ const a = s.data, o = hn(a);
1665
1691
  C({
1666
1692
  type: "visual-ready",
1667
- data: i,
1668
- textureURLs: [...o.textureURLs ?? []]
1669
- }, s);
1693
+ data: a,
1694
+ textureURLs: [...s.textureURLs ?? []]
1695
+ }, o);
1670
1696
  } catch (n) {
1671
- C({ type: "error", error: Z(n) }), Q.close();
1697
+ C({ type: "error", error: Y(n) }), ee.close();
1672
1698
  }
1673
1699
  };