@nebula-spatial/cad-loader 0.2.3 → 0.2.4

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.
package/dist/index.js CHANGED
@@ -6,12 +6,12 @@ var _r = (t, n, e) => n in t ? Or(t, n, { enumerable: !0, configurable: !0, writ
6
6
  var f = (t, n, e) => _r(t, typeof n != "symbol" ? n + "" : n, e), it = (t, n, e) => n.has(t) || sn("Cannot " + e);
7
7
  var g = (t, n, e) => (it(t, n, "read from private field"), e ? e.call(t) : n.get(t)), k = (t, n, e) => n.has(t) ? sn("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(t) : n.set(t, e), G = (t, n, e, r) => (it(t, n, "write to private field"), r ? r.call(t, e) : n.set(t, e), e), V = (t, n, e) => (it(t, n, "access private method"), e);
8
8
  import { CadPackError as U, normalizeGeometrySegments as Gr, normalizeViewportRect as Ft, cloneViewportRect as qe, mergeViewportRects as fe, readGroup as Ur, transformBBoxByInstance as Nr, parseBinStreaming as Ot, isStrictTextRoundtripEnabled as zr, assertStrictTextRoundtrip as Hr, computeViewportRectFromPositions as _e, expandViewportRect as Je, viewportRectEquals as qr, viewportRectIntersects as Kn, viewportRectContains as _t, transformViewportRect as Kr, readExternalVariantDependencyPlan as Ke, readExternalAnnotationManifest as Gt, readExternalBlockAnnotations as Ut, readSceneAnnotationSidecar as Wr, parseBinPayload as Xr, parseBinBounds as Yr, readExternalVariantManifest as Qr } from "./core/index.js";
9
- import { readBlockAnnotationSidecar as Xo } from "./core/index.js";
9
+ import { readBlockAnnotationSidecar as Yo } from "./core/index.js";
10
10
  import { BufferAttribute as $, RawShaderMaterial as $r, Color as Wn, Vector2 as Xn, DoubleSide as vt, BufferGeometry as Nt, LineSegments as zt, InstancedInterleavedBuffer as an, InstancedBufferGeometry as Yn, Float32BufferAttribute as Qn, InterleavedBufferAttribute as De, Mesh as Ht, Vector3 as st, Box3 as jr, Sphere as Zr, Object3D as Rt, InstancedBufferAttribute as de, Points as $n, Group as ee, PointsMaterial as on, LineBasicMaterial as ln, MeshBasicMaterial as dn } from "three";
11
- import { BatchedText as cn, Text as Jr, preloadFont as We } from "troika-three-text";
12
- import ei from "rbush";
13
- const qt = 16.7, Kt = 6, Wt = 128 * 1024 * 1024, Xt = 64 * 1024 * 1024, Yt = 2, Qt = 1, ti = 3e5, ni = 22e4, un = 2;
14
- function K(t, n = "CAD load aborted") {
11
+ import { BatchedText as cn, Text as Jr, configureTextBuilder as ei, preloadFont as We } from "troika-three-text";
12
+ import ti from "rbush";
13
+ const qt = 16.7, Kt = 6, Wt = 128 * 1024 * 1024, Xt = 64 * 1024 * 1024, Yt = 2, Qt = 1, ni = 3e5, ri = 22e4, un = 2;
14
+ function W(t, n = "CAD load aborted") {
15
15
  if (t instanceof Error && t.name === "AbortError") return t;
16
16
  const e = typeof t == "string" && t.length > 0 ? t : n, r = new Error(e, t === void 0 ? void 0 : { cause: t });
17
17
  return r.name = "AbortError", r;
@@ -26,9 +26,9 @@ function ue(t, n) {
26
26
  return t.addEventListener("abort", e, { once: !0 }), () => t.removeEventListener("abort", e);
27
27
  }
28
28
  function jn(t, n, e = "CAD load aborted") {
29
- return n.aborted ? Promise.reject(K(n.reason, e)) : new Promise((r, i) => {
29
+ return n.aborted ? Promise.reject(W(n.reason, e)) : new Promise((r, i) => {
30
30
  const s = () => {
31
- a(), i(K(n.reason, e));
31
+ a(), i(W(n.reason, e));
32
32
  }, a = () => n.removeEventListener("abort", s);
33
33
  n.addEventListener("abort", s, { once: !0 }), t.then(
34
34
  (o) => {
@@ -46,16 +46,16 @@ function et(t) {
46
46
  function hn(t) {
47
47
  return et(t) && typeof t.arrayBuffer == "function";
48
48
  }
49
- function ri(t) {
49
+ function ii(t) {
50
50
  return typeof URL == "function" && t instanceof URL;
51
51
  }
52
- function ii(t) {
52
+ function si(t) {
53
53
  return et(t) && typeof t.aborted == "boolean" && typeof t.addEventListener == "function" && typeof t.removeEventListener == "function";
54
54
  }
55
55
  function tt(t, n) {
56
56
  if (t instanceof ArrayBuffer)
57
57
  return { source: { kind: "buffer", buffer: t } };
58
- if (typeof t == "string" || ri(t)) {
58
+ if (typeof t == "string" || ii(t)) {
59
59
  const r = String(t);
60
60
  if (r.trim().length === 0)
61
61
  throw new U("E_SOURCE", "URL source must include a non-empty URL");
@@ -78,7 +78,7 @@ function tt(t, n) {
78
78
  case "url": {
79
79
  if (typeof e.url != "string" || e.url.trim().length === 0)
80
80
  throw new U("E_SOURCE", "URL source must include a non-empty URL");
81
- const r = ii(e.signal) ? e.signal : void 0;
81
+ const r = si(e.signal) ? e.signal : void 0;
82
82
  return {
83
83
  source: { kind: "url", url: e.url, signal: n },
84
84
  sourceSignal: r
@@ -88,7 +88,7 @@ function tt(t, n) {
88
88
  throw new U("E_SOURCE", `Unsupported CAD load source kind: ${String(e.kind)}`);
89
89
  }
90
90
  }
91
- function si(t) {
91
+ function ai(t) {
92
92
  if (!et(t) || typeof t.kind != "string")
93
93
  throw new U("E_SOURCE", "Geo source must be an object");
94
94
  tt(t, new AbortController().signal);
@@ -96,7 +96,7 @@ function si(t) {
96
96
  function Ae() {
97
97
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
98
98
  }
99
- function ai(t) {
99
+ function oi(t) {
100
100
  if (typeof queueMicrotask == "function") {
101
101
  queueMicrotask(t);
102
102
  return;
@@ -143,33 +143,26 @@ class Zn {
143
143
  }
144
144
  async function Xe(t) {
145
145
  const n = fn(), e = t.fetchImpl ?? fetch, r = new Map(
146
- t.entries.map((l) => [l.id, l])
147
- ), i = Array.from(new Set(t.requiredVariantIds)).sort((l, u) => l - u), s = /* @__PURE__ */ new Map(), a = oi(t.concurrency);
148
- let o = 0;
149
- async function d() {
150
- var l;
151
- for (; o < i.length; ) {
152
- const u = i[o++], c = r.get(u);
153
- if (!c)
154
- throw new Error(`External block ${u} is missing from manifest`);
155
- const h = new URL(c.href, t.baseUrl).href, y = await e(h, { signal: t.signal });
156
- if (!y.ok) {
157
- const m = "status" in y ? y.status : void 0, b = "statusText" in y ? y.statusText : void 0, v = [m, b].filter((I) => I !== void 0 && I !== "").join(" ");
158
- throw new Error(`External block ${u} fetch failed${v ? `: ${v}` : ""}`);
159
- }
160
- const p = await y.arrayBuffer();
161
- if (p.byteLength !== c.raw_size)
162
- throw new Error(
163
- `External block ${u} raw_size mismatch: manifest=${c.raw_size}, response=${p.byteLength}`
164
- );
165
- s.set(u, p), await ((l = t.onBuffer) == null ? void 0 : l.call(t, u, p));
146
+ t.entries.map((o) => [o.id, o])
147
+ ), i = Array.from(new Set(t.requiredVariantIds)).sort((o, l) => o - l), s = /* @__PURE__ */ new Map();
148
+ async function a(o) {
149
+ var h;
150
+ const l = r.get(o);
151
+ if (!l)
152
+ throw new Error(`External block ${o} is missing from manifest`);
153
+ const d = new URL(l.href, t.baseUrl).href, u = await e(d, { signal: t.signal });
154
+ if (!u.ok) {
155
+ const y = "status" in u ? u.status : void 0, x = "statusText" in u ? u.statusText : void 0, m = [y, x].filter((b) => b !== void 0 && b !== "").join(" ");
156
+ throw new Error(`External block ${o} fetch failed${m ? `: ${m}` : ""}`);
166
157
  }
158
+ const c = await u.arrayBuffer();
159
+ if (c.byteLength !== l.raw_size)
160
+ throw new Error(
161
+ `External block ${o} raw_size mismatch: manifest=${l.raw_size}, response=${c.byteLength}`
162
+ );
163
+ s.set(o, c), await ((h = t.onBuffer) == null ? void 0 : h.call(t, o, c));
167
164
  }
168
- return await Promise.all(Array.from({ length: Math.min(a, i.length) }, d)), { buffers: s, fetchMs: fn() - n };
169
- }
170
- function oi(t) {
171
- const n = Math.floor(t ?? 3);
172
- return Number.isFinite(n) ? Math.max(1, Math.min(n, 8)) : 3;
165
+ return await Promise.all(i.map(a)), { buffers: s, fetchMs: fn() - n };
173
166
  }
174
167
  function fn() {
175
168
  var t, n;
@@ -189,7 +182,7 @@ class li {
189
182
  if (r.count <= 0) continue;
190
183
  const i = At(r.layerIndex, r.lineweightPx);
191
184
  let s = g(this, te).get(i), a = r.pos, o = r.positionItemSize;
192
- const d = r.linePositionKind ?? null;
185
+ const l = r.linePositionKind ?? null;
193
186
  s ? s.positionItemSize !== o && (yn(s), o !== 3 && (a = er(a, r.count, o)), s.positionItemSize = 3, o = 3, s.linePositionKind = null) : (s = {
194
187
  layerIndex: r.layerIndex,
195
188
  ...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx },
@@ -197,17 +190,17 @@ class li {
197
190
  positionItemSize: o,
198
191
  colParts: [],
199
192
  colorRunParts: [],
200
- linePositionKind: d,
193
+ linePositionKind: l,
201
194
  count: 0,
202
195
  bbox: null
203
196
  }, g(this, te).set(i, s));
204
- const l = s.count > 0;
197
+ const d = s.count > 0;
205
198
  s.posParts.push(a), s.colParts.push(r.col);
206
199
  const u = mi(
207
200
  r.colorRuns ?? pi(r.col),
208
201
  s.count
209
202
  );
210
- s.colorRunParts.push(u), s.linePositionKind !== d && (s.linePositionKind = null), s.positionItemSize === 2 && s.linePositionKind === null && yn(s), s.count += r.count, s.bbox = l && s.bbox === null ? null : ci(s.bbox, r.bbox), e += r.count;
203
+ s.colorRunParts.push(u), s.linePositionKind !== l && (s.linePositionKind = null), s.positionItemSize === 2 && s.linePositionKind === null && yn(s), s.count += r.count, s.bbox = d && s.bbox === null ? null : ci(s.bbox, r.bbox), e += r.count;
211
204
  }
212
205
  return e;
213
206
  }
@@ -254,14 +247,14 @@ function he(t, n = {}) {
254
247
  const e = Gr(t), r = [], i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = n.markLinePositionXy === !0 || n.splitLineweight === !0;
255
248
  for (const m of e) {
256
249
  if (m.vertexCount <= 0) continue;
257
- const b = m.layerIndex, v = o ? m.lineweightPx : void 0, I = At(b, v), w = i.get(I);
258
- w === void 0 ? (i.set(I, m.vertexCount), s.set(I, b), a.set(I, v), r.push(I)) : i.set(I, w + m.vertexCount);
250
+ const b = m.layerIndex, R = o ? m.lineweightPx : void 0, I = At(b, R), w = i.get(I);
251
+ w === void 0 ? (i.set(I, m.vertexCount), s.set(I, b), a.set(I, R), r.push(I)) : i.set(I, w + m.vertexCount);
259
252
  }
260
- const d = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), h = n.markLinePositionXy === !0 ? "xy-zero-z" : void 0, y = h ? 2 : 3;
253
+ const l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), h = n.markLinePositionXy === !0 ? "xy-zero-z" : void 0, y = h ? 2 : 3;
261
254
  for (const m of r) {
262
- const b = s.get(m), v = a.get(m), I = i.get(m) ?? 0, w = {
255
+ const b = s.get(m), R = a.get(m), I = i.get(m) ?? 0, w = {
263
256
  layerIndex: b,
264
- ...v === void 0 ? {} : { lineweightPx: v },
257
+ ...R === void 0 ? {} : { lineweightPx: R },
265
258
  pos: new Float32Array(I * y),
266
259
  positionItemSize: y,
267
260
  col: new Uint8Array(I * 3),
@@ -269,13 +262,13 @@ function he(t, n = {}) {
269
262
  bbox: null,
270
263
  colorRuns: []
271
264
  };
272
- h && (w.linePositionKind = h), d.set(m, w), l.set(m, 0), u.set(m, null);
265
+ h && (w.linePositionKind = h), l.set(m, w), d.set(m, 0), u.set(m, null);
273
266
  }
274
267
  for (const m of e) {
275
268
  if (m.vertexCount <= 0) continue;
276
- const b = m.layerIndex, v = o ? m.lineweightPx : void 0, I = At(b, v), w = d.get(I), T = l.get(I), A = T, B = m.color[0], E = m.color[1], S = m.color[2];
269
+ const b = m.layerIndex, R = o ? m.lineweightPx : void 0, I = At(b, R), w = l.get(I), T = d.get(I), A = T, B = m.color[0], E = m.color[1], S = m.color[2];
277
270
  for (let P = 0; P < m.vertexCount; P += 1) {
278
- const O = m.startVertex + P, W = T + P, M = W * y, _ = W * 3, X = O * 2, N = t.pos[X], C = t.pos[X + 1];
271
+ const O = m.startVertex + P, K = T + P, M = K * y, _ = K * 3, X = O * 2, N = t.pos[X], C = t.pos[X + 1];
279
272
  w.pos[M] = N, w.pos[M + 1] = C, y === 3 && (w.pos[M + 2] = 0), w.col[_] = B, w.col[_ + 1] = E, w.col[_ + 2] = S;
280
273
  const L = u.get(I);
281
274
  !Number.isFinite(N) || !Number.isFinite(C) ? c.add(I) : L ? (N < L.minX && (L.minX = N), C < L.minY && (L.minY = C), N > L.maxX && (L.maxX = N), C > L.maxY && (L.maxY = C)) : u.set(I, { minX: N, minY: C, maxX: N, maxY: C });
@@ -284,14 +277,14 @@ function he(t, n = {}) {
284
277
  startVertex: A,
285
278
  vertexCount: m.vertexCount,
286
279
  color: [B, E, S]
287
- }), l.set(I, T + m.vertexCount);
280
+ }), d.set(I, T + m.vertexCount);
288
281
  }
289
- const p = [];
282
+ const x = [];
290
283
  for (const m of r) {
291
- const b = d.get(m);
292
- b && (b.bbox = c.has(m) ? null : Ft(u.get(m) ?? null), b.colorRuns = tr(b.colorRuns ?? []), p.push(b));
284
+ const b = l.get(m);
285
+ b && (b.bbox = c.has(m) ? null : Ft(u.get(m) ?? null), b.colorRuns = tr(b.colorRuns ?? []), x.push(b));
293
286
  }
294
- return p;
287
+ return x;
295
288
  }
296
289
  function At(t, n) {
297
290
  return n === void 0 ? `${t}:` : `${t}:${n}`;
@@ -364,13 +357,13 @@ function pi(t) {
364
357
  let r = 0;
365
358
  for (; r < n; ) {
366
359
  const i = r * 3, s = t[i] ?? 0, a = t[i + 1] ?? 0, o = t[i + 2] ?? 0;
367
- let d = r + 1;
368
- for (; d < n; ) {
369
- const l = d * 3;
370
- if (t[l] !== s || t[l + 1] !== a || t[l + 2] !== o) break;
371
- d += 1;
360
+ let l = r + 1;
361
+ for (; l < n; ) {
362
+ const d = l * 3;
363
+ if (t[d] !== s || t[d + 1] !== a || t[d + 2] !== o) break;
364
+ l += 1;
372
365
  }
373
- e.push({ startVertex: r, vertexCount: d - r, color: [s, a, o] }), r = d;
366
+ e.push({ startVertex: r, vertexCount: l - r, color: [s, a, o] }), r = l;
374
367
  }
375
368
  return e;
376
369
  }
@@ -437,16 +430,16 @@ function wi(t) {
437
430
  const n = t.insertRuntime;
438
431
  if (!n || n.instances.length === 0) return null;
439
432
  const e = [], r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
440
- for (const d of n.variants) {
441
- const l = gi(d), u = ot(l.line), c = ot(l.fill), h = ot(l.dot), y = u.length > 0 || c.length > 0 || h.length > 0;
442
- r.set(d.id, y ? Ii(l, null) : null), y && (i.add(d.id), e.push({
443
- variantId: d.id,
433
+ for (const l of n.variants) {
434
+ const d = gi(l), u = ot(d.line), c = ot(d.fill), h = ot(d.dot), y = u.length > 0 || c.length > 0 || h.length > 0;
435
+ r.set(l.id, y ? Ii(d, null) : null), y && (i.add(l.id), e.push({
436
+ variantId: l.id,
444
437
  line: u,
445
438
  fill: c,
446
439
  dot: h
447
440
  }));
448
441
  }
449
- const s = n.instances.filter((d) => i.has(d.variantId));
442
+ const s = n.instances.filter((l) => i.has(l.variantId));
450
443
  if (s.length === 0) return null;
451
444
  const a = Ri(s, r), o = Bi(e, a);
452
445
  return {
@@ -475,10 +468,10 @@ function vi(t) {
475
468
  function Ri(t, n) {
476
469
  const e = t.length, r = new Uint32Array(e * 3), i = new Float32Array(e * 6), s = new Float32Array(e * 4);
477
470
  for (let a = 0; a < e; a += 1) {
478
- const o = t[a], d = a * 3;
479
- r[d] = o.instanceId, r[d + 1] = o.variantId, r[d + 2] = o.insLayerIdx;
480
- const l = a * 6;
481
- i[l] = o.matA, i[l + 1] = o.matB, i[l + 2] = o.matC, i[l + 3] = o.matD, i[l + 4] = o.tx, i[l + 5] = o.ty;
471
+ const o = t[a], l = a * 3;
472
+ r[l] = o.instanceId, r[l + 1] = o.variantId, r[l + 2] = o.insLayerIdx;
473
+ const d = a * 6;
474
+ i[d] = o.matA, i[d + 1] = o.matB, i[d + 2] = o.matC, i[d + 3] = o.matD, i[d + 4] = o.tx, i[d + 5] = o.ty;
482
475
  const u = Nr(n.get(o.variantId) ?? null, o);
483
476
  Ai(s, a * 4, u);
484
477
  }
@@ -514,11 +507,11 @@ function Pi(t, n) {
514
507
  };
515
508
  }
516
509
  function Li(t) {
517
- const n = !!(t.hiddenInstanceIds && t.hiddenInstanceIds.size > 0), e = t.keepTextsForHiddenInstances === !0, r = t.loadBlocks !== !1, i = t.suppressExpandedInsertGeometry === !0, s = t.maxExpandedInstanceVertices, a = typeof s == "number" && Number.isFinite(s) && s >= 0, o = !!(t.externalVariantBuffers && t.externalVariantBuffers.size > 0), d = t.requiredExternalVariantIds !== void 0, l = t.externalVariantDeltaOnly === !0, u = t.deferExternalVariantGeometry === !0;
518
- if (!n && !e && r && !i && !a && !o && !d && !u && !l)
510
+ const n = !!(t.hiddenInstanceIds && t.hiddenInstanceIds.size > 0), e = t.keepTextsForHiddenInstances === !0, r = t.loadBlocks !== !1, i = t.suppressExpandedInsertGeometry === !0, s = t.maxExpandedInstanceVertices, a = typeof s == "number" && Number.isFinite(s) && s >= 0, o = !!(t.externalVariantBuffers && t.externalVariantBuffers.size > 0), l = t.requiredExternalVariantIds !== void 0, d = t.externalVariantDeltaOnly === !0, u = t.deferExternalVariantGeometry === !0;
511
+ if (!n && !e && r && !i && !a && !o && !l && !u && !d)
519
512
  return;
520
513
  const c = {};
521
- return n && (c.hiddenInstanceIds = t.hiddenInstanceIds), e && (c.keepTextsForHiddenInstances = !0), r || (c.loadBlocks = !1), i && (c.suppressExpandedInsertGeometry = !0), a && (c.maxExpandedInstanceVertices = s), o && (c.externalVariantBuffers = t.externalVariantBuffers), d && (c.requiredExternalVariantIds = t.requiredExternalVariantIds), u && (c.deferExternalVariantGeometry = !0), l && (c.externalVariantDeltaOnly = !0), c;
514
+ return n && (c.hiddenInstanceIds = t.hiddenInstanceIds), e && (c.keepTextsForHiddenInstances = !0), r || (c.loadBlocks = !1), i && (c.suppressExpandedInsertGeometry = !0), a && (c.maxExpandedInstanceVertices = s), o && (c.externalVariantBuffers = t.externalVariantBuffers), l && (c.requiredExternalVariantIds = t.requiredExternalVariantIds), u && (c.deferExternalVariantGeometry = !0), d && (c.externalVariantDeltaOnly = !0), c;
522
515
  }
523
516
  async function Mi(t) {
524
517
  if (!t.externalVariantFetchSource || !t.externalVariantGeometryFetchIds || t.externalVariantGeometryFetchIds.size === 0)
@@ -579,11 +572,11 @@ function $t() {
579
572
  completion: Promise.resolve().then(async () => {
580
573
  if (await Promise.resolve(), r()) return;
581
574
  const s = di(), a = [];
582
- let o = 0, d = !1;
575
+ let o = 0, l = !1;
583
576
  if (r()) return;
584
- const l = await Mi(t);
577
+ const d = await Mi(t);
585
578
  if (r()) return;
586
- const u = Ot(l.buffer, Li(l)), c = Pi(
579
+ const u = Ot(d.buffer, Li(d)), c = Pi(
587
580
  u.header,
588
581
  t.externalVariantDeltaOnly === !0
589
582
  );
@@ -591,7 +584,7 @@ function $t() {
591
584
  await n({ type: "header", header: u.header });
592
585
  const h = async () => {
593
586
  const m = await Fi(s, n, r);
594
- return o = 0, m > 0 && (d = !0), m;
587
+ return o = 0, m > 0 && (l = !0), m;
595
588
  };
596
589
  try {
597
590
  for (const m of u.chunks) {
@@ -605,19 +598,19 @@ function $t() {
605
598
  markLinePositionXy: m.kind === "line"
606
599
  });
607
600
  o += ui(s[m.kind], b);
608
- const v = d ? c.steady : c.initial;
609
- o >= v && await h();
601
+ const R = l ? c.steady : c.initial;
602
+ o >= R && await h();
610
603
  }
611
604
  } catch (m) {
612
605
  throw await h(), m;
613
606
  }
614
607
  await h(), await xn(a, n, r), r() || await n({ type: "done" });
615
- const y = Ae(), p = wi(u.header);
616
- p && !r() && await n({
608
+ const y = Ae(), x = wi(u.header);
609
+ x && !r() && await n({
617
610
  type: "insertModel",
618
- variants: p.variants,
619
- instances: p.instances,
620
- bytes: p.bytes,
611
+ variants: x.variants,
612
+ instances: x.instances,
613
+ bytes: x.bytes,
621
614
  planMs: Ae() - y
622
615
  });
623
616
  }),
@@ -644,7 +637,7 @@ function _i(t, n) {
644
637
  return t.hiddenInstanceIds && t.hiddenInstanceIds.size > 0 && (e.hiddenInstanceIds = Array.from(t.hiddenInstanceIds)), t.keepTextsForHiddenInstances === !0 && (e.keepTextsForHiddenInstances = !0), t.loadBlocks === !1 && (e.loadBlocks = !1), t.suppressExpandedInsertGeometry === !0 && (e.suppressExpandedInsertGeometry = !0), typeof t.maxExpandedInstanceVertices == "number" && Number.isFinite(t.maxExpandedInstanceVertices) && t.maxExpandedInstanceVertices >= 0 && (e.maxExpandedInstanceVertices = t.maxExpandedInstanceVertices), t.externalVariantFetchSource && (e.externalVariantFetchSource = t.externalVariantFetchSource), t.externalVariantBuffers && t.externalVariantBuffers.size > 0 && (e.externalVariantBuffers = Array.from(t.externalVariantBuffers, ([r, i]) => ({
645
638
  variantId: r,
646
639
  buffer: i
647
- }))), t.requiredExternalVariantIds !== void 0 && (e.requiredExternalVariantIds = Array.from(t.requiredExternalVariantIds)), t.externalVariantGeometryFetchIds !== void 0 && (e.externalVariantGeometryFetchIds = Array.from(t.externalVariantGeometryFetchIds)), t.deferExternalVariantGeometry === !0 && (e.deferExternalVariantGeometry = !0), t.externalVariantDeltaOnly === !0 && (e.externalVariantDeltaOnly = !0), e;
640
+ }))), t.requiredExternalVariantIds !== void 0 && (e.requiredExternalVariantIds = Array.from(t.requiredExternalVariantIds)), t.externalVariantGeometryFetchIds !== void 0 && (e.externalVariantGeometryFetchIds = Array.from(t.externalVariantGeometryFetchIds)), t.deferExternalVariantGeometry === !0 && (e.deferExternalVariantGeometry = !0), t.externalVariantDeltaOnly === !0 && (e.externalVariantDeltaOnly = !0), t.cacheDocument === !0 && (e.cacheDocument = !0), e;
648
641
  }
649
642
  function Gi(t, n) {
650
643
  const e = n ? [] : [t.buffer];
@@ -672,31 +665,31 @@ function Ni(t = {}) {
672
665
  function nr(t, n) {
673
666
  let e = null, r = !1, i = null, s = !1;
674
667
  const a = () => {
675
- var l;
668
+ var d;
676
669
  if (s)
677
670
  throw new Error("Geo prepare worker adapter is disposed");
678
671
  if (i)
679
672
  throw new Error("Geo prepare worker adapter already has an active run");
680
673
  if (n && e)
681
674
  return e;
682
- const d = ((l = t.workerFactory) == null ? void 0 : l.call(t)) ?? (t.workerUrl ? new Worker(t.workerUrl, { type: "module" }) : new Worker(new URL(
675
+ const l = ((d = t.workerFactory) == null ? void 0 : d.call(t)) ?? (t.workerUrl ? new Worker(t.workerUrl, { type: "module" }) : new Worker(new URL(
683
676
  /* @vite-ignore */
684
677
  "" + new URL("workers/geo-prepare.worker.js", import.meta.url).href,
685
678
  import.meta.url
686
679
  ), { type: "module" }));
687
- return n && (e = d, r = !1), d;
688
- }, o = (d, l) => {
689
- i = null, !(n && l && !s) && (e === d && (e = null, r = !1), d.terminate());
680
+ return n && (e = l, r = !1), l;
681
+ }, o = (l, d) => {
682
+ i = null, !(n && d && !s) && (e === l && (e = null, r = !1), l.terminate());
690
683
  };
691
684
  return {
692
685
  get mainBufferReuseReady() {
693
686
  return n && e !== null && r;
694
687
  },
695
- start(d, l) {
696
- const u = a(), c = n && d.externalVariantDeltaOnly === !0 && e === u && r;
697
- let h = !1, y = !1, p = !1, m = !1, b = Promise.resolve(), v, I, w, T;
688
+ start(l, d) {
689
+ const u = a(), c = n && l.externalVariantDeltaOnly === !0 && e === u && r;
690
+ let h = !1, y = !1, x = !1, m = !1, b = Promise.resolve(), R, I, w, T;
698
691
  const A = new Promise((C, L) => {
699
- v = C, I = L;
692
+ R = C, I = L;
700
693
  }), B = new Promise((C, L) => {
701
694
  w = C, T = L;
702
695
  });
@@ -707,26 +700,26 @@ function nr(t, n) {
707
700
  }, S = (C) => {
708
701
  m || (m = !0, E(), o(u, C));
709
702
  }, P = () => {
710
- h || (h = !0, v());
703
+ h || (h = !0, R());
711
704
  }, O = () => {
712
705
  y || (y = !0, w());
713
- }, W = (C) => {
706
+ }, K = (C) => {
714
707
  const L = gn(C);
715
- p = !1, h || (h = !0, I(L)), y || (y = !0, T(L));
708
+ x = !1, h || (h = !0, I(L)), y || (y = !0, T(L));
716
709
  }, M = async (C) => {
717
710
  if (!y) {
718
711
  if (C.type === "error")
719
712
  throw Ui(C);
720
713
  if (C.type === "complete") {
721
- p = !0, n && (r = !0), P(), O();
714
+ x = !0, n && (r = !0), P(), O();
722
715
  return;
723
716
  }
724
717
  if (C.type === "header") {
725
- await l({ type: "header", header: C.header });
718
+ await d({ type: "header", header: C.header });
726
719
  return;
727
720
  }
728
721
  if (C.type === "geometry") {
729
- await l({
722
+ await d({
730
723
  type: "geometry",
731
724
  kind: C.kind,
732
725
  layers: C.layers,
@@ -736,7 +729,7 @@ function nr(t, n) {
736
729
  return;
737
730
  }
738
731
  if (C.type === "insertModel") {
739
- await l({
732
+ await d({
740
733
  type: "insertModel",
741
734
  variants: C.variants,
742
735
  instances: C.instances,
@@ -746,7 +739,7 @@ function nr(t, n) {
746
739
  return;
747
740
  }
748
741
  if (C.type === "text") {
749
- await l({
742
+ await d({
750
743
  type: "text",
751
744
  texts: C.texts,
752
745
  cost: C.cost,
@@ -754,29 +747,29 @@ function nr(t, n) {
754
747
  });
755
748
  return;
756
749
  }
757
- await l({ type: "done" }), P();
750
+ await d({ type: "done" }), P();
758
751
  }
759
752
  }, _ = (C) => {
760
753
  b = b.then(() => M(C.data)), b.catch((L) => {
761
- W(L), S(!1);
754
+ K(L), S(!1);
762
755
  });
763
756
  }, X = (C) => {
764
- W(new Error(C.message || "Geo prepare worker failed")), S(!1);
757
+ K(new Error(C.message || "Geo prepare worker failed")), S(!1);
765
758
  }, N = () => {
766
- W(new Error("Geo prepare worker message decode failed")), S(!1);
759
+ K(new Error("Geo prepare worker message decode failed")), S(!1);
767
760
  };
768
761
  u.addEventListener("message", _), u.addEventListener("error", X), u.addEventListener("messageerror", N), i = {
769
762
  abort: () => {
770
- W(new Error("Geo prepare worker run aborted")), S(!1);
763
+ K(new Error("Geo prepare worker run aborted")), S(!1);
771
764
  }
772
765
  };
773
766
  try {
774
767
  u.postMessage(
775
- _i(d, c),
776
- Gi(d, c)
768
+ _i(l, c),
769
+ Gi(l, c)
777
770
  );
778
771
  } catch (C) {
779
- throw W(C), S(!1), gn(C);
772
+ throw K(C), S(!1), gn(C);
780
773
  }
781
774
  return {
782
775
  completion: A,
@@ -788,14 +781,14 @@ function nr(t, n) {
788
781
  y || (O(), u.postMessage({ type: "cancel" }));
789
782
  },
790
783
  dispose() {
791
- O(), S(p && y);
784
+ O(), S(x && y);
792
785
  }
793
786
  };
794
787
  },
795
788
  dispose() {
796
789
  s = !0, i == null || i.abort(), i = null;
797
- const d = e;
798
- e = null, r = !1, d == null || d.terminate();
790
+ const l = e;
791
+ e = null, r = !1, l == null || l.terminate();
799
792
  }
800
793
  };
801
794
  }
@@ -815,7 +808,7 @@ async function Zt(t) {
815
808
  try {
816
809
  return await zi(await fetch(t.url, { signal: t.signal }));
817
810
  } catch (e) {
818
- throw e instanceof U || e instanceof Error && e.name === "AbortError" ? e : (n = t.signal) != null && n.aborted ? K(t.signal.reason, "CAD pack request aborted") : new U("E_PACK_NETWORK", `Pack request failed: ${e.message}`);
811
+ throw e instanceof U || e instanceof Error && e.name === "AbortError" ? e : (n = t.signal) != null && n.aborted ? W(t.signal.reason, "CAD pack request aborted") : new U("E_PACK_NETWORK", `Pack request failed: ${e.message}`);
819
812
  }
820
813
  default: {
821
814
  const e = t;
@@ -949,10 +942,10 @@ function ji(t) {
949
942
  dot: t.dot.map(ut)
950
943
  };
951
944
  }
952
- var F, Be, Ve, Ee, xe, ne, q, ge, re, be, Se, Q, Ie, ke, Te, z, Pe, Le, R, rr, ir, sr, ce, Bt, ar, Re, Vt, Ge, Ue, Ne;
945
+ var F, Be, Ve, Ee, xe, ne, q, ge, re, be, Se, Q, Ie, ke, Te, z, Pe, Le, v, rr, ir, sr, ce, Bt, ar, Re, Vt, Ge, Ue, Ne;
953
946
  class Zi {
954
947
  constructor(n, e) {
955
- k(this, R);
948
+ k(this, v);
956
949
  f(this, "events");
957
950
  f(this, "ready");
958
951
  k(this, F);
@@ -975,25 +968,25 @@ class Zi {
975
968
  k(this, Le, Ae());
976
969
  G(this, F, e);
977
970
  const r = tt(n, g(this, Ee).signal);
978
- G(this, Be, r.source), G(this, Ve, r.sourceSignal), G(this, re, new Zn(Ki(e.flowControl))), G(this, q, new Hi((i) => V(this, R, ar).call(this, i))), this.events = g(this, q), this.ready = g(this, xe).promise, this.ready.catch(() => {
971
+ G(this, Be, r.source), G(this, Ve, r.sourceSignal), G(this, re, new Zn(Ki(e.flowControl))), G(this, q, new Hi((i) => V(this, v, ar).call(this, i))), this.events = g(this, q), this.ready = g(this, xe).promise, this.ready.catch(() => {
979
972
  }), g(this, ne).promise.catch(() => {
980
- }), V(this, R, Vt).call(this, e.signal), V(this, R, Vt).call(this, g(this, Ve)), g(this, z) || V(this, R, rr).call(this);
973
+ }), V(this, v, Vt).call(this, e.signal), V(this, v, Vt).call(this, g(this, Ve)), g(this, z) || V(this, v, rr).call(this);
981
974
  }
982
975
  abort(n) {
983
- g(this, z) || V(this, R, Ge).call(this, K(n, "CAD load session aborted"));
976
+ g(this, z) || V(this, v, Ge).call(this, W(n, "CAD load session aborted"));
984
977
  }
985
978
  dispose() {
986
979
  var n;
987
980
  if (!g(this, Pe)) {
988
981
  if (G(this, Pe, !0), !g(this, z)) {
989
- V(this, R, Ge).call(this, K("CAD load session disposed"));
982
+ V(this, v, Ge).call(this, W("CAD load session disposed"));
990
983
  return;
991
984
  }
992
- (n = g(this, Q)) == null || n.dispose(), g(this, q).clear(), V(this, R, Ne).call(this);
985
+ (n = g(this, Q)) == null || n.dispose(), g(this, q).clear(), V(this, v, Ne).call(this);
993
986
  }
994
987
  }
995
988
  }
996
- F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), xe = new WeakMap(), ne = new WeakMap(), q = new WeakMap(), ge = new WeakMap(), re = new WeakMap(), be = new WeakMap(), Se = new WeakMap(), Q = new WeakMap(), Ie = new WeakMap(), ke = new WeakMap(), Te = new WeakMap(), z = new WeakMap(), Pe = new WeakMap(), Le = new WeakMap(), R = new WeakSet(), rr = async function() {
989
+ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), xe = new WeakMap(), ne = new WeakMap(), q = new WeakMap(), ge = new WeakMap(), re = new WeakMap(), be = new WeakMap(), Se = new WeakMap(), Q = new WeakMap(), Ie = new WeakMap(), ke = new WeakMap(), Te = new WeakMap(), z = new WeakMap(), Pe = new WeakMap(), Le = new WeakMap(), v = new WeakSet(), rr = async function() {
997
990
  var n, e;
998
991
  try {
999
992
  const r = await Promise.race([
@@ -1002,7 +995,7 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1002
995
  ]);
1003
996
  if (g(this, z)) return;
1004
997
  G(this, ke, r.byteLength);
1005
- const s = V(this, R, ir).call(this).start({
998
+ const s = V(this, v, ir).call(this).start({
1006
999
  buffer: r,
1007
1000
  hiddenInstanceIds: ct(g(this, F).hiddenInstanceIds),
1008
1001
  keepTextsForHiddenInstances: g(this, F).keepTextsForHiddenInstances || void 0,
@@ -1013,10 +1006,10 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1013
1006
  externalVariantBuffers: g(this, F).externalVariantBuffers,
1014
1007
  requiredExternalVariantIds: ct(g(this, F).requiredExternalVariantIds),
1015
1008
  externalVariantGeometryFetchIds: ct(g(this, F).externalVariantGeometryFetchIds)
1016
- }, (o) => V(this, R, sr).call(this, o));
1009
+ }, (o) => V(this, v, sr).call(this, o));
1017
1010
  if (G(this, Q, s), s.completion.catch(() => {
1018
1011
  }), (n = s.backgroundCompletion) == null || n.catch(() => {
1019
- }), V(this, R, Re).call(this, g(this, re).takeInitialGrant()), await Promise.race([s.completion, g(this, ne).promise]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, g(this, ne).promise]), g(this, z)) return;
1012
+ }), V(this, v, Re).call(this, g(this, re).takeInitialGrant()), await Promise.race([s.completion, g(this, ne).promise]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, g(this, ne).promise]), g(this, z)) return;
1020
1013
  if (!g(this, Te))
1021
1014
  throw new Error("CAD loader adapter completed without a done event");
1022
1015
  if (!g(this, Ie))
@@ -1026,11 +1019,11 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1026
1019
  chunks: g(this, ge),
1027
1020
  rawBytes: g(this, ke)
1028
1021
  };
1029
- G(this, z, !0), g(this, q).push({ event: { type: "ready", document: a } }), g(this, q).close(), g(this, xe).resolve(a), V(this, R, Ne).call(this);
1022
+ G(this, z, !0), g(this, q).push({ event: { type: "ready", document: a } }), g(this, q).close(), g(this, xe).resolve(a), V(this, v, Ne).call(this);
1030
1023
  } catch (r) {
1031
- g(this, z) || V(this, R, Ge).call(this, qi(r));
1024
+ g(this, z) || V(this, v, Ge).call(this, qi(r));
1032
1025
  } finally {
1033
- (e = g(this, Q)) == null || e.dispose(), V(this, R, Ue).call(this);
1026
+ (e = g(this, Q)) == null || e.dispose(), V(this, v, Ue).call(this);
1034
1027
  }
1035
1028
  }, ir = function() {
1036
1029
  return g(this, F).preferWorker !== !1 && nt(g(this, F).workerFactory) ? jt({
@@ -1042,7 +1035,7 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1042
1035
  if (n.type === "header") {
1043
1036
  G(this, Ie, n.header), g(this, q).push({
1044
1037
  event: { type: "meta", meta: n.header, header: n.header }
1045
- }), await V(this, R, ce).call(this);
1038
+ }), await V(this, v, ce).call(this);
1046
1039
  return;
1047
1040
  }
1048
1041
  if (n.type === "geometry") {
@@ -1059,12 +1052,12 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1059
1052
  }
1060
1053
  };
1061
1054
  });
1062
- await V(this, R, Bt).call(this, e, "geometry", n.bytes), await V(this, R, ce).call(this);
1055
+ await V(this, v, Bt).call(this, e, "geometry", n.bytes), await V(this, v, ce).call(this);
1063
1056
  return;
1064
1057
  }
1065
1058
  if (n.type === "text") {
1066
1059
  const e = n.texts.map((r) => (g(this, ge).push({ kind: "text", payload: r }), { event: { type: "text", chunk: r } }));
1067
- await V(this, R, Bt).call(this, e, "text", n.bytes), await V(this, R, ce).call(this);
1060
+ await V(this, v, Bt).call(this, e, "text", n.bytes), await V(this, v, ce).call(this);
1068
1061
  return;
1069
1062
  }
1070
1063
  if (n.type === "insertModel") {
@@ -1074,10 +1067,10 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1074
1067
  instances: $i(n.instances),
1075
1068
  variants: n.variants.map(ji)
1076
1069
  }
1077
- }), await V(this, R, ce).call(this);
1070
+ }), await V(this, v, ce).call(this);
1078
1071
  return;
1079
1072
  }
1080
- G(this, Te, !0), await V(this, R, ce).call(this);
1073
+ G(this, Te, !0), await V(this, v, ce).call(this);
1081
1074
  }
1082
1075
  }, ce = async function() {
1083
1076
  const n = Math.max(0, (g(this, F).frameBudgetMs ?? qt) - (g(this, F).frameReserveMs ?? Kt));
@@ -1086,13 +1079,13 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1086
1079
  }), G(this, Le, performance.now()));
1087
1080
  }, Bt = function(n, e, r) {
1088
1081
  if (n.length === 0) {
1089
- V(this, R, Re).call(this, e === "geometry" ? { geometryCredits: 1, textCredits: 0 } : { geometryCredits: 0, textCredits: 1 });
1082
+ V(this, v, Re).call(this, e === "geometry" ? { geometryCredits: 1, textCredits: 0 } : { geometryCredits: 0, textCredits: 1 });
1090
1083
  return;
1091
1084
  }
1092
1085
  const i = { kind: e, bytes: Math.max(0, r), creditReplaced: !1 };
1093
1086
  g(this, re).onQueued(e, i.bytes);
1094
1087
  const s = g(this, re).onConsumed(e, 0);
1095
- if (i.creditReplaced = V(this, R, Re).call(this, s), n.forEach((a, o) => {
1088
+ if (i.creditReplaced = V(this, v, Re).call(this, s), n.forEach((a, o) => {
1096
1089
  g(this, q).push({
1097
1090
  ...a,
1098
1091
  batch: i,
@@ -1105,7 +1098,7 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1105
1098
  }, ar = function(n) {
1106
1099
  if (!n.batch || !n.accountsBatch) return;
1107
1100
  const e = g(this, re).onConsumed(n.batch.kind, n.batch.bytes);
1108
- n.batch.creditReplaced || (n.batch.creditReplaced = V(this, R, Re).call(this, e)), e.paused || V(this, R, Ue).call(this);
1101
+ n.batch.creditReplaced || (n.batch.creditReplaced = V(this, v, Re).call(this, e)), e.paused || V(this, v, Ue).call(this);
1109
1102
  }, Re = function(n) {
1110
1103
  var e;
1111
1104
  return !((e = g(this, Q)) != null && e.grant) || g(this, z) || n.geometryCredits <= 0 && n.textCredits <= 0 ? !1 : (g(this, Q).grant({
@@ -1122,7 +1115,7 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1122
1115
  n.addEventListener("abort", e, { once: !0 }), g(this, Se).push(() => n.removeEventListener("abort", e));
1123
1116
  }, Ge = function(n) {
1124
1117
  var e, r, i;
1125
- g(this, z) || (G(this, z, !0), g(this, Ee).abort(n), (r = (e = g(this, Q)) == null ? void 0 : e.cancel) == null || r.call(e), (i = g(this, Q)) == null || i.dispose(), g(this, ne).reject(n), g(this, xe).reject(n), g(this, q).push({ event: { type: "error", error: n } }), g(this, q).close(), V(this, R, Ue).call(this), V(this, R, Ne).call(this));
1118
+ g(this, z) || (G(this, z, !0), g(this, Ee).abort(n), (r = (e = g(this, Q)) == null ? void 0 : e.cancel) == null || r.call(e), (i = g(this, Q)) == null || i.dispose(), g(this, ne).reject(n), g(this, xe).reject(n), g(this, q).push({ event: { type: "error", error: n } }), g(this, q).close(), V(this, v, Ue).call(this), V(this, v, Ne).call(this));
1126
1119
  }, Ue = function() {
1127
1120
  for (const n of g(this, be)) n();
1128
1121
  g(this, be).clear();
@@ -1249,18 +1242,18 @@ async function ht(t) {
1249
1242
  async function or(t) {
1250
1243
  var tn, nn;
1251
1244
  const { node: n } = t, e = new ns(n), r = t.appendExternalVariantDelta === !0, i = new Ji(is(t.scheduler));
1252
- let s = null, a = !0, o = null, d = !1, l = !1, u = !1, c = null, h = !1, y = null, p = null, m = null, b = !1;
1253
- const v = [], I = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), T = () => {
1254
- var x;
1255
- b || (b = !0, (x = t.onFirstRenderableAppend) == null || x.call(t));
1256
- }, A = new Promise((x, D) => {
1245
+ let s = null, a = !0, o = null, l = !1, d = !1, u = !1, c = null, h = !1, y = null, x = null, m = null, b = !1;
1246
+ const R = [], I = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), T = () => {
1247
+ var p;
1248
+ b || (b = !0, (p = t.onFirstRenderableAppend) == null || p.call(t));
1249
+ }, A = new Promise((p, D) => {
1257
1250
  y = D;
1258
1251
  });
1259
1252
  A.catch(() => {
1260
1253
  });
1261
- const B = (x) => {
1254
+ const B = (p) => {
1262
1255
  var oe;
1263
- const D = In(x);
1256
+ const D = In(p);
1264
1257
  if (!u) {
1265
1258
  u = !0, (oe = s == null ? void 0 : s.cancel) == null || oe.call(s);
1266
1259
  for (const j of I)
@@ -1269,52 +1262,52 @@ async function or(t) {
1269
1262
  }), y == null || y(D);
1270
1263
  }
1271
1264
  return D;
1272
- }, E = (x) => (w.add(x), x.then(
1265
+ }, E = (p) => (w.add(p), p.then(
1273
1266
  () => {
1274
- w.delete(x);
1267
+ w.delete(p);
1275
1268
  },
1276
1269
  () => {
1277
- w.delete(x);
1270
+ w.delete(p);
1278
1271
  }
1279
- ), x.catch(() => {
1280
- }), x), S = (x) => ({
1281
- geometryCredits: x.geometryCredits,
1282
- textCredits: x.textCredits
1283
- }), P = (x, D) => {
1284
- u || !(s != null && s.grant) || D && x.geometryCredits <= 0 && x.textCredits <= 0 || s.grant(S(x));
1285
- }, O = (x) => {
1286
- !o || x.flowQueued || (o.onQueued(x.kind, x.bytes), x.flowQueued = !0);
1287
- }, W = () => {
1288
- for (const x of I)
1289
- O(x);
1290
- }, M = (x, D) => {
1291
- if (!x.settled) {
1292
- if (x.settled = !0, I.delete(x), D) {
1293
- x.reject(D);
1272
+ ), p.catch(() => {
1273
+ }), p), S = (p) => ({
1274
+ geometryCredits: p.geometryCredits,
1275
+ textCredits: p.textCredits
1276
+ }), P = (p, D) => {
1277
+ u || !(s != null && s.grant) || D && p.geometryCredits <= 0 && p.textCredits <= 0 || s.grant(S(p));
1278
+ }, O = (p) => {
1279
+ !o || p.flowQueued || (o.onQueued(p.kind, p.bytes), p.flowQueued = !0);
1280
+ }, K = () => {
1281
+ for (const p of I)
1282
+ O(p);
1283
+ }, M = (p, D) => {
1284
+ if (!p.settled) {
1285
+ if (p.settled = !0, I.delete(p), D) {
1286
+ p.reject(D);
1294
1287
  return;
1295
1288
  }
1296
- x.resolve();
1289
+ p.resolve();
1297
1290
  }
1298
1291
  }, _ = () => (h = !0, c || (c = Promise.resolve().then(async () => {
1299
1292
  for (; !u; ) {
1300
1293
  for (h = !1; !u && i.hasPending(); ) {
1301
- const x = await i.runFrame();
1302
- !u && x.exhausted && await ht(t.onYield);
1294
+ const p = await i.runFrame();
1295
+ !u && p.exhausted && await ht(t.onYield);
1303
1296
  }
1304
1297
  if (!h && !i.hasPending())
1305
1298
  break;
1306
1299
  }
1307
- }).catch((x) => {
1308
- throw B(x);
1300
+ }).catch((p) => {
1301
+ throw B(p);
1309
1302
  }).finally(() => {
1310
1303
  c = null, !u && h && i.hasPending() && _();
1311
1304
  }), c.catch(() => {
1312
- }), c)), X = (x, D, oe) => {
1305
+ }), c)), X = (p, D, oe) => {
1313
1306
  let j = null, rn = null;
1314
1307
  const le = new Promise((Me, rt) => {
1315
1308
  j = Me, rn = rt;
1316
1309
  }), Z = {
1317
- kind: x,
1310
+ kind: p,
1318
1311
  bytes: D,
1319
1312
  append: oe,
1320
1313
  flowQueued: !1,
@@ -1342,84 +1335,84 @@ async function or(t) {
1342
1335
  throw M(Z, rt), B(Me);
1343
1336
  }
1344
1337
  }), _(), le;
1345
- }, N = (x) => {
1346
- if (x.type === "geometry") {
1347
- e.appendGeometry(x.kind, x.layers);
1338
+ }, N = (p) => {
1339
+ if (p.type === "geometry") {
1340
+ e.appendGeometry(p.kind, p.layers);
1348
1341
  return;
1349
1342
  }
1350
- if (x.type === "text") {
1351
- e.appendText(x.texts);
1343
+ if (p.type === "text") {
1344
+ e.appendText(p.texts);
1352
1345
  return;
1353
1346
  }
1354
- if (x.type === "insertModel") {
1347
+ if (p.type === "insertModel") {
1355
1348
  e.appendInsertModel({
1356
- variants: x.variants,
1357
- instances: x.instances,
1358
- planMs: x.planMs
1349
+ variants: p.variants,
1350
+ instances: p.instances,
1351
+ planMs: p.planMs
1359
1352
  });
1360
1353
  return;
1361
1354
  }
1362
- }, C = (x) => X(x.type === "text" ? "text" : "geometry", x.bytes, () => {
1363
- if (l) {
1364
- N(x);
1355
+ }, C = (p) => X(p.type === "text" ? "text" : "geometry", p.bytes, () => {
1356
+ if (d) {
1357
+ N(p);
1365
1358
  return;
1366
1359
  }
1367
- v.push(x);
1368
- }), L = (x, D) => {
1360
+ R.push(p);
1361
+ }), L = (p, D) => {
1369
1362
  const oe = Promise.resolve().then(async () => {
1370
1363
  var j;
1371
- await ((j = t.beforeTextAppend) == null ? void 0 : j.call(t, x)), await D();
1364
+ await ((j = t.beforeTextAppend) == null ? void 0 : j.call(t, p)), await D();
1372
1365
  }).catch((j) => {
1373
1366
  throw B(j);
1374
1367
  });
1375
1368
  return E(oe);
1376
- }, Fr = (x) => {
1369
+ }, Fr = (p) => {
1377
1370
  if (!u) {
1378
- if (x.type === "header") {
1371
+ if (p.type === "header") {
1379
1372
  if (r) {
1380
- m = x.header;
1373
+ m = p.header;
1381
1374
  return;
1382
1375
  }
1383
- e.initFromHeader(x.header);
1376
+ e.initFromHeader(p.header);
1384
1377
  return;
1385
1378
  }
1386
- if (x.type === "geometry")
1379
+ if (p.type === "geometry")
1387
1380
  return r ? C({
1388
1381
  type: "geometry",
1389
- kind: x.kind,
1390
- layers: x.layers,
1391
- bytes: x.bytes
1392
- }) : X("geometry", x.bytes, () => {
1393
- e.appendGeometry(x.kind, x.layers), T();
1382
+ kind: p.kind,
1383
+ layers: p.layers,
1384
+ bytes: p.bytes
1385
+ }) : X("geometry", p.bytes, () => {
1386
+ e.appendGeometry(p.kind, p.layers), T();
1394
1387
  });
1395
- if (x.type === "text")
1396
- return r ? L(x.texts, () => C({
1388
+ if (p.type === "text")
1389
+ return r ? L(p.texts, () => C({
1397
1390
  type: "text",
1398
- texts: x.texts,
1399
- bytes: x.bytes
1400
- })) : L(x.texts, () => X("text", x.bytes, () => {
1401
- e.appendText(x.texts), T();
1391
+ texts: p.texts,
1392
+ bytes: p.bytes
1393
+ })) : L(p.texts, () => X("text", p.bytes, () => {
1394
+ e.appendText(p.texts), T();
1402
1395
  }));
1403
- if (x.type === "insertModel")
1396
+ if (p.type === "insertModel")
1404
1397
  return r ? C({
1405
1398
  type: "insertModel",
1406
- variants: x.variants,
1407
- instances: x.instances,
1408
- bytes: x.bytes,
1409
- planMs: x.planMs
1410
- }) : X("geometry", x.bytes, () => {
1399
+ variants: p.variants,
1400
+ instances: p.instances,
1401
+ bytes: p.bytes,
1402
+ planMs: p.planMs
1403
+ }) : X("geometry", p.bytes, () => {
1411
1404
  e.installInsertModel({
1412
- variants: x.variants,
1413
- instances: x.instances,
1414
- planMs: x.planMs
1405
+ variants: p.variants,
1406
+ instances: p.instances,
1407
+ planMs: p.planMs
1415
1408
  }), T();
1416
1409
  });
1417
- d = !0;
1410
+ l = !0;
1418
1411
  }
1419
1412
  };
1420
1413
  try {
1421
1414
  if ((tn = t.signal) != null && tn.aborted)
1422
- throw K(t.signal.reason);
1415
+ throw W(t.signal.reason);
1423
1416
  if (s = t.adapter.start(
1424
1417
  {
1425
1418
  buffer: t.buffer,
@@ -1433,42 +1426,43 @@ async function or(t) {
1433
1426
  requiredExternalVariantIds: t.requiredExternalVariantIds,
1434
1427
  externalVariantGeometryFetchIds: t.externalVariantGeometryFetchIds,
1435
1428
  deferExternalVariantGeometry: t.deferExternalVariantGeometry,
1436
- externalVariantDeltaOnly: t.externalVariantDeltaOnly
1429
+ externalVariantDeltaOnly: t.externalVariantDeltaOnly,
1430
+ cacheDocument: t.cacheDocument
1437
1431
  },
1438
1432
  Fr
1439
1433
  ), s.completion.catch(() => {
1440
1434
  }), t.signal) {
1441
- const x = t.signal, D = () => {
1442
- B(K(x.reason));
1435
+ const p = t.signal, D = () => {
1436
+ B(W(p.reason));
1443
1437
  };
1444
- x.addEventListener("abort", D, { once: !0 }), p = () => x.removeEventListener("abort", D), x.aborted && D();
1438
+ p.addEventListener("abort", D, { once: !0 }), x = () => p.removeEventListener("abort", D), p.aborted && D();
1445
1439
  }
1446
- if (s.grant && (o = new Zn(ss(t.flowControl)), W(), P(o.takeInitialGrant(), !1)), await Promise.race([s.completion, A]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, A]), await _(), await Promise.all(Array.from(w)), !d)
1440
+ if (s.grant && (o = new Zn(ss(t.flowControl)), K(), P(o.takeInitialGrant(), !1)), await Promise.race([s.completion, A]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, A]), await _(), await Promise.all(Array.from(w)), !l)
1447
1441
  throw new Error("Geo loader pipeline completed without done event");
1448
1442
  if (await ((nn = t.beforeFinalize) == null ? void 0 : nn.call(t)), r) {
1449
1443
  if (!m)
1450
1444
  throw new Error("Geo loader pipeline completed without delta header");
1451
1445
  n.appendExternalVariantDeltaHeader(m);
1452
- for (const x of v)
1453
- X(x.type === "text" ? "text" : "geometry", x.bytes, () => {
1454
- N(x);
1446
+ for (const p of R)
1447
+ X(p.type === "text" ? "text" : "geometry", p.bytes, () => {
1448
+ N(p);
1455
1449
  });
1456
1450
  await _(), await Promise.all(Array.from(w)), await n._finalizeIncrementally(() => ht(t.onYield));
1457
1451
  } else
1458
1452
  await e.finalize(() => ht(t.onYield));
1459
- if (l = !0, s.backgroundCompletion) {
1460
- const x = s;
1453
+ if (d = !0, s.backgroundCompletion) {
1454
+ const p = s;
1461
1455
  a = !1, s.backgroundCompletion.then(async () => {
1462
1456
  await _(), await Promise.all(Array.from(w));
1463
1457
  }).catch(() => {
1464
1458
  }).finally(() => {
1465
- x.dispose();
1459
+ p.dispose();
1466
1460
  });
1467
1461
  }
1468
- } catch (x) {
1469
- throw B(x);
1462
+ } catch (p) {
1463
+ throw B(p);
1470
1464
  } finally {
1471
- p == null || p(), a && (s == null || s.dispose());
1465
+ x == null || x(), a && (s == null || s.dispose());
1472
1466
  }
1473
1467
  }
1474
1468
  function lr(t) {
@@ -1486,16 +1480,16 @@ function ls() {
1486
1480
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
1487
1481
  }
1488
1482
  function dr(t = {}) {
1489
- var a, o, d, l, u, c, h;
1483
+ var a, o, l, d, u, c, h;
1490
1484
  const n = t.hiddenInstanceIds ? new Set(t.hiddenInstanceIds) : /* @__PURE__ */ new Set(), e = t.requiredExternalVariantIds !== void 0, r = e ? new Set(t.requiredExternalVariantIds) : /* @__PURE__ */ new Set(), i = t.externalVariantGeometryFetchIds !== void 0, s = i ? new Set(t.externalVariantGeometryFetchIds) : /* @__PURE__ */ new Set();
1491
1485
  return {
1492
1486
  scheduler: {
1493
1487
  frameBudgetMs: ((a = t.scheduler) == null ? void 0 : a.frameBudgetMs) ?? qt,
1494
1488
  reserveMs: ((o = t.scheduler) == null ? void 0 : o.reserveMs) ?? Kt,
1495
- now: ((d = t.scheduler) == null ? void 0 : d.now) ?? ls
1489
+ now: ((l = t.scheduler) == null ? void 0 : l.now) ?? ls
1496
1490
  },
1497
1491
  flowControl: {
1498
- highWatermarkBytes: ((l = t.flowControl) == null ? void 0 : l.highWatermarkBytes) ?? Wt,
1492
+ highWatermarkBytes: ((d = t.flowControl) == null ? void 0 : d.highWatermarkBytes) ?? Wt,
1499
1493
  lowWatermarkBytes: ((u = t.flowControl) == null ? void 0 : u.lowWatermarkBytes) ?? Xt,
1500
1494
  initialGeometryCredits: ((c = t.flowControl) == null ? void 0 : c.initialGeometryCredits) ?? Yt,
1501
1495
  initialTextCredits: ((h = t.flowControl) == null ? void 0 : h.initialTextCredits) ?? Qt
@@ -1518,6 +1512,7 @@ function dr(t = {}) {
1518
1512
  externalVariantGeometryFetchIds: i ? s : void 0,
1519
1513
  deferExternalVariantGeometry: t.deferExternalVariantGeometry === !0,
1520
1514
  externalVariantDeltaOnly: t.externalVariantDeltaOnly === !0,
1515
+ cacheDocument: t.cacheDocument === !0,
1521
1516
  onFirstRenderableAppend: t.onFirstRenderableAppend
1522
1517
  };
1523
1518
  }
@@ -1548,12 +1543,13 @@ async function cr(t, n, e, r = {}) {
1548
1543
  externalVariantGeometryFetchIds: i.externalVariantGeometryFetchIds,
1549
1544
  deferExternalVariantGeometry: i.deferExternalVariantGeometry,
1550
1545
  externalVariantDeltaOnly: i.externalVariantDeltaOnly,
1546
+ cacheDocument: i.cacheDocument,
1551
1547
  onFirstRenderableAppend: i.onFirstRenderableAppend
1552
1548
  });
1553
1549
  } catch (o) {
1554
- const d = lr(o);
1550
+ const l = lr(o);
1555
1551
  throw t.ready.catch(() => {
1556
- }), d;
1552
+ }), l;
1557
1553
  }
1558
1554
  }
1559
1555
  async function Et(t, n, e, r = {}) {
@@ -1564,11 +1560,11 @@ async function Et(t, n, e, r = {}) {
1564
1560
  }), s = i.hiddenInstanceIds ?? /* @__PURE__ */ new Set(), a = i.preferWorker && (i.workerAdapter !== void 0 || nt(i.workerFactory)), o = i.preferWorker && i.workerAdapter ? i.workerAdapter : a ? jt({
1565
1561
  workerUrl: i.workerUrl,
1566
1562
  workerFactory: i.workerFactory
1567
- }) : $t(), d = a && i.externalVariantDeltaOnly && ((c = i.workerAdapter) == null ? void 0 : c.mainBufferReuseReady) === !0, l = a && !d ? n.slice(0) : n, u = a ? os(i.externalVariantBuffers) : i.externalVariantBuffers;
1563
+ }) : $t(), l = a && i.externalVariantDeltaOnly && ((c = i.workerAdapter) == null ? void 0 : c.mainBufferReuseReady) === !0, d = a && !l ? n.slice(0) : n, u = a ? os(i.externalVariantBuffers) : i.externalVariantBuffers;
1568
1564
  try {
1569
1565
  await or({
1570
1566
  node: t,
1571
- buffer: l,
1567
+ buffer: d,
1572
1568
  adapter: o,
1573
1569
  scheduler: i.scheduler,
1574
1570
  flowControl: i.flowControl,
@@ -1683,19 +1679,19 @@ function yr(t, n, e) {
1683
1679
  }
1684
1680
  function xs(t, n) {
1685
1681
  const e = new Uint8Array(t.length), r = Math.floor(t.length / 3), i = /* @__PURE__ */ new Map();
1686
- let s = -1, a = [0, 0, 0], o = 0, d = 0, l = 0;
1682
+ let s = -1, a = [0, 0, 0], o = 0, l = 0, d = 0;
1687
1683
  for (let u = 0; u < r; u += 1) {
1688
- const c = u * 3, h = t[c] ?? 0, y = t[c + 1] ?? 0, p = t[c + 2] ?? 0, m = yr(h, y, p);
1684
+ const c = u * 3, h = t[c] ?? 0, y = t[c + 1] ?? 0, x = t[c + 2] ?? 0, m = yr(h, y, x);
1689
1685
  let b;
1690
1686
  if (m === s)
1691
- b = a, l += 1;
1687
+ b = a, d += 1;
1692
1688
  else {
1693
1689
  o += 1;
1694
- const v = i.get(m);
1695
- if (v)
1696
- b = v, d += 1;
1690
+ const R = i.get(m);
1691
+ if (R)
1692
+ b = R, l += 1;
1697
1693
  else {
1698
- const I = n([h, y, p]);
1694
+ const I = n([h, y, x]);
1699
1695
  b = [I[0], I[1], I[2]], i.set(m, b);
1700
1696
  }
1701
1697
  s = m, a = b;
@@ -1708,8 +1704,8 @@ function xs(t, n) {
1708
1704
  vertexCount: r,
1709
1705
  runCount: o,
1710
1706
  uniqueColorCount: i.size,
1711
- cacheHitCount: d,
1712
- repeatedRunVertexCount: l
1707
+ cacheHitCount: l,
1708
+ repeatedRunVertexCount: d
1713
1709
  }
1714
1710
  };
1715
1711
  }
@@ -1739,30 +1735,30 @@ function mr(t, n, e, r, i) {
1739
1735
  if (t.length !== s)
1740
1736
  throw new Error("Display color target must cover the vertex count exactly.");
1741
1737
  const a = /* @__PURE__ */ new Map();
1742
- let o = 0, d = 0;
1743
- for (const l of e) {
1744
- if (l.vertexCount <= 0) continue;
1745
- const u = l.color[0] ?? 0, c = l.color[1] ?? 0, h = l.color[2] ?? 0, y = yr(u, c, h);
1746
- let p = a.get(y);
1747
- if (p)
1738
+ let o = 0, l = 0;
1739
+ for (const d of e) {
1740
+ if (d.vertexCount <= 0) continue;
1741
+ const u = d.color[0] ?? 0, c = d.color[1] ?? 0, h = d.color[2] ?? 0, y = yr(u, c, h);
1742
+ let x = a.get(y);
1743
+ if (x)
1748
1744
  o += 1;
1749
1745
  else {
1750
1746
  const b = r([u, c, h]);
1751
- p = [b[0], b[1], b[2]], a.set(y, p);
1747
+ x = [b[0], b[1], b[2]], a.set(y, x);
1752
1748
  }
1753
- d += Math.max(0, l.vertexCount - 1);
1754
- const m = Math.min(n, l.startVertex + l.vertexCount);
1755
- for (let b = l.startVertex; b < m; b += 1) {
1756
- const v = b * 3;
1757
- t[v] = p[0] * i, t[v + 1] = p[1] * i, t[v + 2] = p[2] * i;
1749
+ l += Math.max(0, d.vertexCount - 1);
1750
+ const m = Math.min(n, d.startVertex + d.vertexCount);
1751
+ for (let b = d.startVertex; b < m; b += 1) {
1752
+ const R = b * 3;
1753
+ t[R] = x[0] * i, t[R + 1] = x[1] * i, t[R + 2] = x[2] * i;
1758
1754
  }
1759
1755
  }
1760
1756
  return {
1761
1757
  vertexCount: n,
1762
- runCount: e.filter((l) => l.vertexCount > 0).length,
1758
+ runCount: e.filter((d) => d.vertexCount > 0).length,
1763
1759
  uniqueColorCount: a.size,
1764
1760
  cacheHitCount: o,
1765
- repeatedRunVertexCount: d
1761
+ repeatedRunVertexCount: l
1766
1762
  };
1767
1763
  }
1768
1764
  const Is = {
@@ -1805,16 +1801,16 @@ function Rn(t, n) {
1805
1801
  const e = pr(n.theme), r = n.elementKind ?? "line", i = n.state ?? "normal", s = ze(t, n, 0);
1806
1802
  let a = Bs(s, e, r), o = s.kind === "aci" && xr(s.index) === 7;
1807
1803
  if (n.enhanceContrast) {
1808
- const l = vs(a, {
1804
+ const d = vs(a, {
1809
1805
  theme: n.theme,
1810
1806
  elementKind: r
1811
1807
  });
1812
- o || (o = !Es(a, l)), a = l;
1808
+ o || (o = !Es(a, d)), a = d;
1813
1809
  }
1814
- let d = r === "hatch" ? e.hatchOpacity : 1;
1815
- return i === "hidden" && (d = 0), i === "locked" && (d *= e.lockedOpacity), i === "xrefFaded" && (d *= e.xrefOpacity), i === "hover" && (a = e.hover, o = !0), i === "selected" && (a = e.selected, o = !0), {
1810
+ let l = r === "hatch" ? e.hatchOpacity : 1;
1811
+ return i === "hidden" && (l = 0), i === "locked" && (l *= e.lockedOpacity), i === "xrefFaded" && (l *= e.xrefOpacity), i === "hover" && (a = e.hover, o = !0), i === "selected" && (a = e.selected, o = !0), {
1816
1812
  rgb: a,
1817
- opacity: d,
1813
+ opacity: l,
1818
1814
  raw: t,
1819
1815
  resolvedRaw: s,
1820
1816
  adapted: o
@@ -1876,27 +1872,27 @@ function gr(t, n) {
1876
1872
  function Ss(t, n, e, r) {
1877
1873
  const i = ks(t);
1878
1874
  let s = 0, a = 1, o = Ce(t);
1879
- for (let d = 0; d < 16; d += 1) {
1880
- const l = (s + a) / 2, u = r === "light" ? i.l * (1 - l) : i.l + (1 - i.l) * l, c = Ts(i.h, i.s, u);
1881
- gr(c, n) >= e ? (o = c, a = l) : s = l;
1875
+ for (let l = 0; l < 16; l += 1) {
1876
+ const d = (s + a) / 2, u = r === "light" ? i.l * (1 - d) : i.l + (1 - i.l) * d, c = Ts(i.h, i.s, u);
1877
+ gr(c, n) >= e ? (o = c, a = d) : s = d;
1882
1878
  }
1883
1879
  return o;
1884
1880
  }
1885
1881
  function ks(t) {
1886
1882
  const n = Y(t[0]) / 255, e = Y(t[1]) / 255, r = Y(t[2]) / 255, i = Math.max(n, e, r), s = Math.min(n, e, r), a = (i + s) / 2;
1887
1883
  if (i === s) return { h: 0, s: 0, l: a };
1888
- const o = i - s, d = a > 0.5 ? o / (2 - i - s) : o / (i + s);
1889
- let l = 0;
1890
- return i === n ? l = (e - r) / o + (e < r ? 6 : 0) : i === e ? l = (r - n) / o + 2 : l = (n - e) / o + 4, l /= 6, { h: l, s: d, l: a };
1884
+ const o = i - s, l = a > 0.5 ? o / (2 - i - s) : o / (i + s);
1885
+ let d = 0;
1886
+ return i === n ? d = (e - r) / o + (e < r ? 6 : 0) : i === e ? d = (r - n) / o + 2 : d = (n - e) / o + 4, d /= 6, { h: d, s: l, l: a };
1891
1887
  }
1892
1888
  function Ts(t, n, e) {
1893
1889
  if (n === 0) {
1894
1890
  const a = Y(e * 255);
1895
1891
  return [a, a, a];
1896
1892
  }
1897
- const r = (a, o, d) => {
1898
- let l = d;
1899
- return l < 0 && (l += 1), l > 1 && (l -= 1), l < 1 / 6 ? a + (o - a) * 6 * l : l < 1 / 2 ? o : l < 2 / 3 ? a + (o - a) * (2 / 3 - l) * 6 : a;
1893
+ const r = (a, o, l) => {
1894
+ let d = l;
1895
+ return d < 0 && (d += 1), d > 1 && (d -= 1), d < 1 / 6 ? a + (o - a) * 6 * d : d < 1 / 2 ? o : d < 2 / 3 ? a + (o - a) * (2 / 3 - d) * 6 : a;
1900
1896
  }, i = e < 0.5 ? e * (1 + n) : e + n - e * n, s = 2 * e - i;
1901
1897
  return [
1902
1898
  Y(r(s, i, t + 1 / 3) * 255),
@@ -2128,9 +2124,9 @@ function yt(t, n) {
2128
2124
  if (r.count <= 0) continue;
2129
2125
  const i = r.bbox !== void 0 ? qs(r.bbox) : _e(r.pos, r.count, 3), s = zs(t);
2130
2126
  for (let a = 0; a < r.count; ) {
2131
- const o = Hs(a, r.count, s, Cr(t)), d = new Nt(), l = r.pos.subarray(a * 3, o * 3), u = r.col.subarray(a * 3, o * 3), c = o - a;
2132
- d.setAttribute("position", new $(l, 3)), d.setAttribute("color", new $(u, 3, !0)), e.push({
2133
- geometry: d,
2127
+ const o = Hs(a, r.count, s, Cr(t)), l = new Nt(), d = r.pos.subarray(a * 3, o * 3), u = r.col.subarray(a * 3, o * 3), c = o - a;
2128
+ l.setAttribute("position", new $(d, 3)), l.setAttribute("color", new $(u, 3, !0)), e.push({
2129
+ geometry: l,
2134
2130
  vertexCount: c,
2135
2131
  layerIndex: r.layerIndex ?? 0,
2136
2132
  ...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx },
@@ -2245,7 +2241,7 @@ function kt(t, n) {
2245
2241
  };
2246
2242
  }
2247
2243
  function Vn(t) {
2248
- const n = new ei();
2244
+ const n = new ti();
2249
2245
  if (t.length > 0) {
2250
2246
  const e = new Array(t.length);
2251
2247
  for (let r = 0; r < t.length; r++)
@@ -2282,10 +2278,10 @@ class En {
2282
2278
  this.removeVariantSlots(n.variantId);
2283
2279
  for (const [e, r] of n.byKind)
2284
2280
  for (const i of r) {
2285
- const s = this.initialCapacity, a = new Yn(), o = i.geometry.getAttribute("position"), d = i.geometry.getAttribute("color");
2286
- o && a.setAttribute("position", o), d && a.setAttribute("color", d), a.instanceCount = 0;
2287
- const l = new de(new Float32Array(s * 4), 4), u = new de(new Float32Array(s * 4), 4), c = new de(new Float32Array(s), 1);
2288
- a.setAttribute("promotedInstMatRow0", l), a.setAttribute("promotedInstMatRow1", u), a.setAttribute("promotedInstVisible", c);
2281
+ const s = this.initialCapacity, a = new Yn(), o = i.geometry.getAttribute("position"), l = i.geometry.getAttribute("color");
2282
+ o && a.setAttribute("position", o), l && a.setAttribute("color", l), a.instanceCount = 0;
2283
+ const d = new de(new Float32Array(s * 4), 4), u = new de(new Float32Array(s * 4), 4), c = new de(new Float32Array(s), 1);
2284
+ a.setAttribute("promotedInstMatRow0", d), a.setAttribute("promotedInstMatRow1", u), a.setAttribute("promotedInstVisible", c);
2289
2285
  const h = Ys(e, a, this.materialFactory(e));
2290
2286
  h.visible = !1, h.frustumCulled = !1, h.userData.kind = e, h.userData.variantId = n.variantId, h.userData.insertPresenterMesh = !0, h.userData.vertexCount = 0, this.slots.push({
2291
2287
  variantId: n.variantId,
@@ -2294,7 +2290,7 @@ class En {
2294
2290
  perVertexCount: i.vertexCount,
2295
2291
  localBBox: i.bbox,
2296
2292
  mesh: h,
2297
- matRow0Attr: l,
2293
+ matRow0Attr: d,
2298
2294
  matRow1Attr: u,
2299
2295
  visibleAttr: c,
2300
2296
  capacity: s
@@ -2315,15 +2311,15 @@ class En {
2315
2311
  const s = n ? Je(n, this.marginRatio) : null, a = !s, o = i === void 0 ? `signature:${Xs(r)}` : `revision:${i}`;
2316
2312
  if (this.cacheValid && this.lastLayerVersion === e.version && this.lastUserHiddenCacheKey === o && this.lastFilteredQueryAll === a && qr(this.lastFilteredQueryRect, s))
2317
2313
  return;
2318
- const d = this.resolveQueryHits(s), l = /* @__PURE__ */ new Map();
2319
- for (const c of d) {
2314
+ const l = this.resolveQueryHits(s), d = /* @__PURE__ */ new Map();
2315
+ for (const c of l) {
2320
2316
  if (s && !Kn(s, c.bbox) || r.has(c.instanceId)) continue;
2321
- let h = l.get(c.variantId);
2322
- h || (h = [], l.set(c.variantId, h)), h.push(c);
2317
+ let h = d.get(c.variantId);
2318
+ h || (h = [], d.set(c.variantId, h)), h.push(c);
2323
2319
  }
2324
2320
  let u = 0;
2325
2321
  for (const c of this.slots) {
2326
- const h = l.get(c.variantId), y = h == null ? void 0 : h.filter((p) => this.slotVisibleForRecord(c, p, e));
2322
+ const h = d.get(c.variantId), y = h == null ? void 0 : h.filter((x) => this.slotVisibleForRecord(c, x, e));
2327
2323
  if (!y || y.length === 0) {
2328
2324
  Sn(c.mesh, 0), c.mesh.userData.vertexCount = 0, c.mesh.visible = !1;
2329
2325
  continue;
@@ -2376,8 +2372,8 @@ class En {
2376
2372
  writeMatRows(n, e) {
2377
2373
  const r = n.matRow0Attr.array, i = n.matRow1Attr.array, s = n.visibleAttr.array;
2378
2374
  for (let o = 0; o < e.length; o += 1) {
2379
- const d = e[o], l = o * 4;
2380
- r[l] = d.matA, r[l + 1] = d.matC, r[l + 2] = d.tx, r[l + 3] = 0, i[l] = d.matB, i[l + 1] = d.matD, i[l + 2] = d.ty, i[l + 3] = 0, s[o] = 1;
2375
+ const l = e[o], d = o * 4;
2376
+ r[d] = l.matA, r[d + 1] = l.matC, r[d + 2] = l.tx, r[d + 3] = 0, i[d] = l.matB, i[d + 1] = l.matD, i[d + 2] = l.ty, i[d + 3] = 0, s[o] = 1;
2381
2377
  }
2382
2378
  const a = e.length * 4;
2383
2379
  n.matRow0Attr.clearUpdateRanges(), n.matRow1Attr.clearUpdateRanges(), n.visibleAttr.clearUpdateRanges(), n.matRow0Attr.addUpdateRange(0, a), n.matRow1Attr.addUpdateRange(0, a), n.visibleAttr.addUpdateRange(0, e.length), n.matRow0Attr.needsUpdate = !0, n.matRow1Attr.needsUpdate = !0, n.visibleAttr.needsUpdate = !0;
@@ -2410,20 +2406,20 @@ function Qs() {
2410
2406
  }
2411
2407
  async function $s(t, n = {}) {
2412
2408
  const e = Math.max(1, Math.floor(n.opsPerPass ?? vr) || 1), r = Math.max(0, n.frameBudgetMs ?? Rr), i = n.now ?? Qs, s = i();
2413
- let a = s, o = 0, d = 0, l = 0, u = 0;
2409
+ let a = s, o = 0, l = 0, d = 0, u = 0;
2414
2410
  for (let c = 0; c < t.length; c += 1) {
2415
2411
  const h = t[c];
2416
- d += 1, h.run() && (l += 1, o += 1), n.onYield && c < t.length - 1 && (o >= e || i() - a >= r) && (await n.onYield(), u += 1, a = i(), o = 0);
2412
+ l += 1, h.run() && (d += 1, o += 1), n.onYield && c < t.length - 1 && (o >= e || i() - a >= r) && (await n.onYield(), u += 1, a = i(), o = 0);
2417
2413
  }
2418
2414
  return {
2419
- visited: d,
2420
- compacted: l,
2415
+ visited: l,
2416
+ compacted: d,
2421
2417
  yielded: u,
2422
2418
  elapsedMs: i() - s
2423
2419
  };
2424
2420
  }
2425
2421
  function js(t, n) {
2426
- return n.zoom, t === "full" && n.visibleVertexCount >= ti ? "stress" : t === "stress" && n.visibleVertexCount <= ni ? "full" : t;
2422
+ return n.zoom, t === "full" && n.visibleVertexCount >= ni ? "stress" : t === "stress" && n.visibleVertexCount <= ri ? "full" : t;
2427
2423
  }
2428
2424
  function Zs(t, n, e) {
2429
2425
  return t === "full" || t === "stress" ? t : js(n, e);
@@ -2482,8 +2478,8 @@ function ra(t, n, e, r, i) {
2482
2478
  return;
2483
2479
  }
2484
2480
  for (let a = 0; a < n; a += 1) {
2485
- const o = a * 3, d = s + a * 2;
2486
- e[d] = t.xyz[o] ?? 0, e[d + 1] = t.xyz[o + 1] ?? 0;
2481
+ const o = a * 3, l = s + a * 2;
2482
+ e[l] = t.xyz[o] ?? 0, e[l + 1] = t.xyz[o + 1] ?? 0;
2487
2483
  }
2488
2484
  }
2489
2485
  function ia(t, n, e) {
@@ -2652,7 +2648,7 @@ function Ia(t, n) {
2652
2648
  o.instanceId,
2653
2649
  Ca(s.get(o.instanceId), o)
2654
2650
  );
2655
- const a = Array.from(s.values()).sort((o, d) => o.instanceId - d.instanceId);
2651
+ const a = Array.from(s.values()).sort((o, l) => o.instanceId - l.instanceId);
2656
2652
  e.set(r.variantId, {
2657
2653
  ...i,
2658
2654
  blockName: r.blockName || i.blockName,
@@ -2833,8 +2829,8 @@ function Ta(t, n) {
2833
2829
  };
2834
2830
  e[Br] = i;
2835
2831
  const s = t.onBeforeCompile;
2836
- t.onBeforeCompile = (d, l) => {
2837
- s == null || s(d, l), d.uniforms.uGeoPointWorldSize = i.uGeoPointWorldSize, d.uniforms.uGeoPointViewportHeight = i.uGeoPointViewportHeight, d.uniforms.uGeoPointMinVisiblePixelSize = i.uGeoPointMinVisiblePixelSize, d.vertexShader.includes("uGeoPointWorldSize") || (d.vertexShader = d.vertexShader.replace(
2832
+ t.onBeforeCompile = (l, d) => {
2833
+ s == null || s(l, d), l.uniforms.uGeoPointWorldSize = i.uGeoPointWorldSize, l.uniforms.uGeoPointViewportHeight = i.uGeoPointViewportHeight, l.uniforms.uGeoPointMinVisiblePixelSize = i.uGeoPointMinVisiblePixelSize, l.vertexShader.includes("uGeoPointWorldSize") || (l.vertexShader = l.vertexShader.replace(
2838
2834
  "#include <common>",
2839
2835
  [
2840
2836
  "#include <common>",
@@ -2980,13 +2976,13 @@ class ye extends ee {
2980
2976
  const i = this.layerStatesByIndex.get(e), s = this.layerGroupsByIndex.get(e), a = this.originalLayerColorsByIndex.get(e);
2981
2977
  if (!i || !s || !a) return;
2982
2978
  const o = r === null ? null : Aa(r);
2983
- o ? this.colorOverridesByIndex.set(e, H(o)) : this.colorOverridesByIndex.delete(e), this.displayHexMemo.clear(), i.color = H(o ?? a), this.layerStateRevision += 1, s.traverse((d) => {
2979
+ o ? this.colorOverridesByIndex.set(e, H(o)) : this.colorOverridesByIndex.delete(e), this.displayHexMemo.clear(), i.color = H(o ?? a), this.layerStateRevision += 1, s.traverse((l) => {
2984
2980
  var h;
2985
- const l = (h = d.userData) == null ? void 0 : h.kind;
2986
- if (l === "text" || l === "text-batch") return;
2987
- const u = d.material, c = Array.isArray(u) ? u : u ? [u] : [];
2981
+ const d = (h = l.userData) == null ? void 0 : h.kind;
2982
+ if (d === "text" || d === "text-batch") return;
2983
+ const u = l.material, c = Array.isArray(u) ? u : u ? [u] : [];
2988
2984
  for (const y of c)
2989
- gt(y) && (this.applyLayerColorState(y, o, this.displayElementKindForObject(d)), y.needsUpdate = !0);
2985
+ gt(y) && (this.applyLayerColorState(y, o, this.displayElementKindForObject(l)), y.needsUpdate = !0);
2990
2986
  }), this.applyCachedLineChunkColors(e, o), this.applyLayerTextColors(e, o), this.notifyInternalChange();
2991
2987
  }
2992
2988
  setRenderQuality(e) {
@@ -3126,18 +3122,18 @@ class ye extends ee {
3126
3122
  const o = new En({
3127
3123
  registry: r,
3128
3124
  table: Vn(i),
3129
- materialFactory: (l) => this.createInsertPresenterMaterial(l),
3125
+ materialFactory: (d) => this.createInsertPresenterMaterial(d),
3130
3126
  initialCapacity: Math.max(1, i.length),
3131
3127
  marginRatio: 0
3132
3128
  });
3133
3129
  if (o.attach(a), o.refresh(null, this.getLayerVisibility(), Pn, 0), o.currentVisibleVertexCount() <= 0)
3134
3130
  return o.dispose(), null;
3135
- let d = !1;
3131
+ let l = !1;
3136
3132
  return {
3137
3133
  object: a,
3138
3134
  bounds: s,
3139
3135
  dispose: () => {
3140
- d || (d = !0, o.dispose(), a.clear());
3136
+ l || (l = !0, o.dispose(), a.clear());
3141
3137
  }
3142
3138
  };
3143
3139
  }
@@ -3163,29 +3159,29 @@ class ye extends ee {
3163
3159
  if (!this.insertInstanceTable) return !1;
3164
3160
  const i = this.insertPresenterRecordKeysByInstanceId.get(e);
3165
3161
  if (!i || i.size === 0) return !1;
3166
- const s = r.rotation * Math.PI / 180, a = Math.cos(s), o = Math.sin(s), d = r.scaleX * a, l = r.scaleX * o, u = -r.scaleY * o, c = r.scaleY * a;
3162
+ const s = r.rotation * Math.PI / 180, a = Math.cos(s), o = Math.sin(s), l = r.scaleX * a, d = r.scaleX * o, u = -r.scaleY * o, c = r.scaleY * a;
3167
3163
  let h = !0;
3168
- for (const p of i) {
3169
- const m = this.insertPresenterRecordsByKey.get(p);
3164
+ for (const x of i) {
3165
+ const m = this.insertPresenterRecordsByKey.get(x);
3170
3166
  if (!m) continue;
3171
3167
  const b = {
3172
3168
  ...m,
3173
- matA: d,
3174
- matB: l,
3169
+ matA: l,
3170
+ matB: d,
3175
3171
  matC: u,
3176
3172
  matD: c,
3177
3173
  tx: r.tx,
3178
3174
  ty: r.ty,
3179
3175
  bbox: this.computeInsertPresenterWorldBBox(m.variantId, {
3180
- matA: d,
3181
- matB: l,
3176
+ matA: l,
3177
+ matB: d,
3182
3178
  matC: u,
3183
3179
  matD: c,
3184
3180
  tx: r.tx,
3185
3181
  ty: r.ty
3186
3182
  }) ?? m.bbox
3187
3183
  };
3188
- this.insertPresenterRecordsByKey.set(p, b), this.insertInstanceTable.replaceRecord(b) || (h = !1);
3184
+ this.insertPresenterRecordsByKey.set(x, b), this.insertInstanceTable.replaceRecord(b) || (h = !1);
3189
3185
  }
3190
3186
  return h ? (y = this.viewportInstancePresenter) == null || y.invalidateQueryCache() : this.rebuildViewportInsertPresenter([...this.insertPresenterRecordsByKey.values()]), this.refreshDefaultInsertPresenterIfUnmanaged(), this.notifyInternalChange(), !0;
3191
3187
  }
@@ -3213,8 +3209,8 @@ class ye extends ee {
3213
3209
  return this.traverse((a) => {
3214
3210
  const o = a.geometry;
3215
3211
  if (!o) return;
3216
- const d = o.userData.cadDisplaySourceColor, l = o.userData.cadDisplayColorRuns;
3217
- d instanceof Uint8Array ? (e += 1, r += d.byteLength) : l && l.length > 0 && (e += 1);
3212
+ const l = o.userData.cadDisplaySourceColor, d = o.userData.cadDisplayColorRuns;
3213
+ l instanceof Uint8Array ? (e += 1, r += l.byteLength) : d && d.length > 0 && (e += 1);
3218
3214
  const u = o.getAttribute("color");
3219
3215
  u instanceof $ && ArrayBuffer.isView(u.array) && (i += u.array.byteLength, u.array instanceof Float32Array && (s += u.array.byteLength));
3220
3216
  }), Object.freeze({
@@ -3240,8 +3236,8 @@ class ye extends ee {
3240
3236
  for (const [s, a] of this.annotationTextRecordsByOwnerKey) {
3241
3237
  const o = e.get(s);
3242
3238
  if (o === void 0) continue;
3243
- const d = r.get(o), l = a.map((u) => this.createInsertVisibilityHandleForAnnotationText(u));
3244
- d ? d.push(...l) : r.set(o, [...l]);
3239
+ const l = r.get(o), d = a.map((u) => this.createInsertVisibilityHandleForAnnotationText(u));
3240
+ l ? l.push(...d) : r.set(o, [...d]);
3245
3241
  }
3246
3242
  return r;
3247
3243
  }
@@ -3350,14 +3346,14 @@ class ye extends ee {
3350
3346
  const r = [], i = this.createInsertInstanceRecords(e.instances);
3351
3347
  let s = !1, a = !1;
3352
3348
  for (const o of e.variants) {
3353
- const d = this.createVariantGeometryInput(o);
3354
- this.insertPresenterVariantInputs.has(o.variantId) && (s = !0), this.insertPresenterVariantInputs.set(o.variantId, d), r.push(d);
3349
+ const l = this.createVariantGeometryInput(o);
3350
+ this.insertPresenterVariantInputs.has(o.variantId) && (s = !0), this.insertPresenterVariantInputs.set(o.variantId, l), r.push(l);
3355
3351
  }
3356
3352
  for (const o of i) {
3357
- const d = ca(o);
3358
- this.insertPresenterRecordsByKey.has(d) && (a = !0), this.insertPresenterRecordsByKey.set(d, o);
3359
- let l = this.insertPresenterRecordKeysByInstanceId.get(o.instanceId);
3360
- l || (l = /* @__PURE__ */ new Set(), this.insertPresenterRecordKeysByInstanceId.set(o.instanceId, l)), l.add(d);
3353
+ const l = ca(o);
3354
+ this.insertPresenterRecordsByKey.has(l) && (a = !0), this.insertPresenterRecordsByKey.set(l, o);
3355
+ let d = this.insertPresenterRecordKeysByInstanceId.get(o.instanceId);
3356
+ d || (d = /* @__PURE__ */ new Set(), this.insertPresenterRecordKeysByInstanceId.set(o.instanceId, d)), d.add(l);
3361
3357
  }
3362
3358
  return { variantInputs: r, records: i, replacedVariant: s, replacedRecord: a };
3363
3359
  }
@@ -3407,9 +3403,9 @@ class ye extends ee {
3407
3403
  const i = (o = this.blockGeometryRegistry) == null ? void 0 : o.getVariant(e);
3408
3404
  if (!i) return null;
3409
3405
  let s = null;
3410
- for (const d of i.byKind.values())
3411
- for (const l of d)
3412
- s = fe(s, l.bbox);
3406
+ for (const l of i.byKind.values())
3407
+ for (const d of l)
3408
+ s = fe(s, d.bbox);
3413
3409
  if (!s) return null;
3414
3410
  const a = Kr(s, r);
3415
3411
  return Tt(a) ? a : null;
@@ -3502,14 +3498,14 @@ class ye extends ee {
3502
3498
  sizeAttenuation: !1,
3503
3499
  depthTest: !1,
3504
3500
  depthWrite: !1
3505
- }), d = Ta(o, {
3501
+ }), l = Ta(o, {
3506
3502
  pointWorldSize: a,
3507
3503
  viewportHeight: this.lineResolution.height
3508
3504
  });
3509
- this.worldSizedPointUniforms.add(d);
3510
- const l = o.dispose.bind(o);
3505
+ this.worldSizedPointUniforms.add(l);
3506
+ const d = o.dispose.bind(o);
3511
3507
  return o.dispose = () => {
3512
- this.worldSizedPointUniforms.delete(d), l();
3508
+ this.worldSizedPointUniforms.delete(l), d();
3513
3509
  }, this.applyLayerColorState(o, r, i), o;
3514
3510
  }
3515
3511
  resolvePointWorldSize(e) {
@@ -3538,14 +3534,14 @@ class ye extends ee {
3538
3534
  layerIndex: e.li,
3539
3535
  ownerKey: a,
3540
3536
  insertVisible: !0
3541
- }, d = this.annotationTextRecordsByLayerIndex.get(e.li) ?? [];
3542
- if (d.push(o), this.annotationTextRecordsByLayerIndex.set(e.li, d), a) {
3537
+ }, l = this.annotationTextRecordsByLayerIndex.get(e.li) ?? [];
3538
+ if (l.push(o), this.annotationTextRecordsByLayerIndex.set(e.li, l), a) {
3543
3539
  const u = this.annotationTextRecordsByOwnerKey.get(a) ?? [];
3544
3540
  u.push(o), this.annotationTextRecordsByOwnerKey.set(a, u);
3545
3541
  }
3546
3542
  this.applyAnnotationTextRenderableVisibility(o);
3547
- const l = Number(r.userData.textCount || 0);
3548
- r.userData.textCount = l + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: H(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3543
+ const d = Number(r.userData.textCount || 0);
3544
+ r.userData.textCount = d + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: H(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3549
3545
  }
3550
3546
  getOrCreateTextBatch(e) {
3551
3547
  const r = this.textBatchByLayerIndex.get(e);
@@ -3577,7 +3573,7 @@ class ye extends ee {
3577
3573
  e && (e.userData[Fe] = !1);
3578
3574
  }
3579
3575
  scheduleTextBatchSync(e) {
3580
- this.pendingTextBatchSync.add(e), !this.textBatchSyncScheduled && (this.textBatchSyncScheduled = !0, ai(() => {
3576
+ this.pendingTextBatchSync.add(e), !this.textBatchSyncScheduled && (this.textBatchSyncScheduled = !0, oi(() => {
3581
3577
  if (this.textBatchSyncScheduled = !1, this.disposed) {
3582
3578
  this.pendingTextBatchSync.clear();
3583
3579
  return;
@@ -3588,22 +3584,22 @@ class ye extends ee {
3588
3584
  i.parent && i.sync();
3589
3585
  }));
3590
3586
  }
3591
- createRenderableChunk(e, r, i, s, a, o, d) {
3592
- const l = new Nt();
3593
- l.setAttribute("position", new Qn(i, 3)), this.registerGeometryDisplayColors(
3594
- l,
3587
+ createRenderableChunk(e, r, i, s, a, o, l) {
3588
+ const d = new Nt();
3589
+ d.setAttribute("position", new Qn(i, 3)), this.registerGeometryDisplayColors(
3590
+ d,
3595
3591
  s,
3596
3592
  r,
3597
3593
  e === "fill" ? "fill" : e === "dot" ? "dot" : "line",
3598
- d
3594
+ l
3599
3595
  );
3600
3596
  const u = this.colorOverridesByIndex.get(r) ?? null;
3601
3597
  let c;
3602
3598
  if (e === "line") {
3603
3599
  const y = new ln({ vertexColors: !0 });
3604
3600
  this.applyLayerColorState(y, u, e);
3605
- const p = new zt(l, y);
3606
- p.renderOrder = 1, c = p;
3601
+ const x = new zt(d, y);
3602
+ x.renderOrder = 1, c = x;
3607
3603
  } else if (e === "fill") {
3608
3604
  const y = new dn({
3609
3605
  vertexColors: !0,
@@ -3611,17 +3607,17 @@ class ye extends ee {
3611
3607
  depthWrite: !1
3612
3608
  });
3613
3609
  this.applyLayerColorState(y, u, e);
3614
- const p = new Ht(l, y);
3615
- p.renderOrder = 0, c = p;
3610
+ const x = new Ht(d, y);
3611
+ x.renderOrder = 0, c = x;
3616
3612
  } else {
3617
- const y = this.createPointMaterial(r, u, e), p = new $n(l, y);
3618
- p.renderOrder = 2, c = p;
3613
+ const y = this.createPointMaterial(r, u, e), x = new $n(d, y);
3614
+ x.renderOrder = 2, c = x;
3619
3615
  }
3620
3616
  c.name = `${e}-chunk`, c.userData.kind = e, c.userData.layerIndex = r, c.userData.vertexCount = a;
3621
3617
  const h = o === void 0 ? _e(i, Math.floor(i.length / 3), 3) : o;
3622
3618
  return c.userData.bbox = h, this.nonLineChunkStats.push({ layerIndex: r, vertexCount: a, bbox: h }), c;
3623
3619
  }
3624
- createRenderableLineChunk(e, r, i, s, a, o, d, l, u = 3, c) {
3620
+ createRenderableLineChunk(e, r, i, s, a, o, l, d, u = 3, c) {
3625
3621
  const h = this.makeLineChunkRecord(
3626
3622
  e,
3627
3623
  r,
@@ -3629,35 +3625,35 @@ class ye extends ee {
3629
3625
  s,
3630
3626
  a,
3631
3627
  o,
3632
- d,
3633
3628
  l,
3629
+ d,
3634
3630
  u,
3635
3631
  c
3636
3632
  );
3637
3633
  return this.registerLineChunkRecord(h), h.renderable;
3638
3634
  }
3639
- makeLineChunkRecord(e, r, i, s, a, o, d, l, u = 3, c) {
3640
- const h = this.resolveLineweightPx(r, c), y = a < 2 || a % 2 !== 0 || h <= 1, p = On(l, a), m = d === "xy-zero-z" || u === 2 ? ta(i, a, u) : ea(i, a), b = o === void 0 ? _e(i, a, u) : o, v = this.resolveInitialLineChunkVariant(r, a, y, c), I = this.buildLineRenderableViews(
3635
+ makeLineChunkRecord(e, r, i, s, a, o, l, d, u = 3, c) {
3636
+ const h = this.resolveLineweightPx(r, c), y = a < 2 || a % 2 !== 0 || h <= 1, x = On(d, a), m = l === "xy-zero-z" || u === 2 ? ta(i, a, u) : ea(i, a), b = o === void 0 ? _e(i, a, u) : o, R = this.resolveInitialLineChunkVariant(r, a, y, c), I = this.buildLineRenderableViews(
3641
3637
  r,
3642
3638
  m,
3643
3639
  s,
3644
3640
  a,
3645
3641
  y,
3646
3642
  b,
3647
- p,
3643
+ x,
3648
3644
  c
3649
- ), w = v === "fat" && I.fatRenderable ? I.fatRenderable : I.thinRenderable, T = {
3645
+ ), w = R === "fat" && I.fatRenderable ? I.fatRenderable : I.thinRenderable, T = {
3650
3646
  layerIndex: r,
3651
3647
  ...c === void 0 ? {} : { lineweightPx: c },
3652
3648
  parent: e,
3653
3649
  position: m,
3654
3650
  canonicalMemoryStats: ia(m, s, a),
3655
3651
  col: s,
3656
- colorRuns: p,
3652
+ colorRuns: x,
3657
3653
  vertexCount: a,
3658
3654
  bbox: b,
3659
3655
  forceThin: y,
3660
- activeVariant: v,
3656
+ activeVariant: R,
3661
3657
  renderable: w,
3662
3658
  thinRenderable: I.thinRenderable,
3663
3659
  fatRenderable: I.fatRenderable,
@@ -3702,20 +3698,20 @@ class ye extends ee {
3702
3698
  shouldUseThinLineVariant(e, r, i) {
3703
3699
  return i || r < 2 || r % 2 !== 0 ? !0 : this.lineModeSwitchingEnabled ? this.effectiveRenderQuality === "stress" && e < un : e < un;
3704
3700
  }
3705
- buildLineRenderableViews(e, r, i, s, a, o, d, l) {
3706
- const u = this.resolveLineweightPx(e, l), c = r.kind === "xy" ? r.xy : r.xyz, h = r.kind === "xy" ? 2 : 3, y = o ?? _e(c, s, h) ?? {
3701
+ buildLineRenderableViews(e, r, i, s, a, o, l, d) {
3702
+ const u = this.resolveLineweightPx(e, d), c = r.kind === "xy" ? r.xy : r.xyz, h = r.kind === "xy" ? 2 : 3, y = o ?? _e(c, s, h) ?? {
3707
3703
  minX: 0,
3708
3704
  minY: 0,
3709
3705
  maxX: 0,
3710
3706
  maxY: 0
3711
- }, p = i.slice(), m = _s({
3707
+ }, x = i.slice(), m = _s({
3712
3708
  position: c,
3713
3709
  positionItemSize: h,
3714
3710
  color: i,
3715
3711
  vertexCount: s,
3716
3712
  bbox: y
3717
3713
  });
3718
- this.finalizeCadLineRenderable(m, e, s, y, i, p, d);
3714
+ this.finalizeCadLineRenderable(m, e, s, y, i, x, l);
3719
3715
  let b = null;
3720
3716
  return !a && s >= 2 && s % 2 === 0 && (b = Gs({
3721
3717
  position: c,
@@ -3725,20 +3721,20 @@ class ye extends ee {
3725
3721
  linewidthPx: u,
3726
3722
  resolution: new Xn(this.lineResolution.width, this.lineResolution.height),
3727
3723
  bbox: y
3728
- }), this.finalizeCadLineRenderable(b, e, s, y, i, p, d)), {
3724
+ }), this.finalizeCadLineRenderable(b, e, s, y, i, x, l)), {
3729
3725
  thinRenderable: m,
3730
3726
  fatRenderable: b,
3731
3727
  thinMaterial: m.material,
3732
3728
  fatMaterial: (b == null ? void 0 : b.material) ?? null
3733
3729
  };
3734
3730
  }
3735
- finalizeCadLineRenderable(e, r, i, s, a, o, d) {
3731
+ finalizeCadLineRenderable(e, r, i, s, a, o, l) {
3736
3732
  e.name = "line-chunk", e.renderOrder = 1, e.userData.kind = "line", e.userData.layerIndex = r, e.userData.vertexCount = i, e.userData.bbox = s;
3737
- const l = e.geometry;
3738
- l.userData.cadDisplayColorTarget = {
3733
+ const d = e.geometry;
3734
+ d.userData.cadDisplayColorTarget = {
3739
3735
  array: a,
3740
- markNeedsUpdate: () => ft(l)
3741
- }, this.installGeometryDisplayColorMetadata(l, o, r, "line", d);
3736
+ markNeedsUpdate: () => ft(d)
3737
+ }, this.installGeometryDisplayColorMetadata(d, o, r, "line", l);
3742
3738
  const u = this.colorOverridesByIndex.get(r) ?? null;
3743
3739
  this.applyLayerColorState(e.material, u, "line"), e.material.needsUpdate = !0;
3744
3740
  }
@@ -3803,7 +3799,7 @@ class ye extends ee {
3803
3799
  }
3804
3800
  getOrCreateAnnotationKindGroup(e, r) {
3805
3801
  const i = this.getOrCreateAnnotationOverlayGroup(e), s = r === "text" ? "annotation-text" : `annotation-${r}`, a = i.children.find(
3806
- (d) => d instanceof ee && d.name === s
3802
+ (l) => l instanceof ee && l.name === s
3807
3803
  );
3808
3804
  if (a) return a;
3809
3805
  const o = new ee();
@@ -3855,14 +3851,14 @@ class ye extends ee {
3855
3851
  const a = new ee();
3856
3852
  if (a.name = r ?? `Layer ${e}`, a.visible = ((o = this.layerStatesByIndex.get(e)) == null ? void 0 : o.visible) ?? i, a.userData.layerIndex = e, this.layerGroupsByIndex.set(e, a), this.add(a), !this.layerStatesByIndex.has(e)) {
3857
3853
  this.layerOrder.push(e);
3858
- const d = [255, 255, 255];
3854
+ const l = [255, 255, 255];
3859
3855
  this.layerStatesByIndex.set(e, {
3860
3856
  index: e,
3861
3857
  name: a.name,
3862
- color: H(d),
3858
+ color: H(l),
3863
3859
  lw_px: 1,
3864
3860
  visible: i
3865
- }), this.originalLayerColorsByIndex.set(e, H(d)), this.layerStateRevision += 1;
3861
+ }), this.originalLayerColorsByIndex.set(e, H(l)), this.layerStateRevision += 1;
3866
3862
  }
3867
3863
  return a;
3868
3864
  }
@@ -3902,11 +3898,11 @@ class ye extends ee {
3902
3898
  return !1;
3903
3899
  const i = /* @__PURE__ */ new Set(), s = [];
3904
3900
  for (const o of r) {
3905
- let d = 0, l = null;
3901
+ let l = 0, d = null;
3906
3902
  for (const I of o.records)
3907
- d += I.vertexCount, l = fe(l, I.bbox);
3908
- const u = o.canonicalKind === "xy" ? 2 : 3, c = new Float32Array(d * u), h = new Uint8Array(d * 3), y = [];
3909
- let p = !0, m = 0;
3903
+ l += I.vertexCount, d = fe(d, I.bbox);
3904
+ const u = o.canonicalKind === "xy" ? 2 : 3, c = new Float32Array(l * u), h = new Uint8Array(l * 3), y = [];
3905
+ let x = !0, m = 0;
3910
3906
  for (const I of o.records)
3911
3907
  ra(
3912
3908
  I.position,
@@ -3914,22 +3910,22 @@ class ye extends ee {
3914
3910
  c,
3915
3911
  m,
3916
3912
  u
3917
- ), h.set(I.col, m * 3), I.colorRuns && I.colorRuns.length > 0 ? Fn(y, I.colorRuns, m) : p = !1, m += I.vertexCount;
3913
+ ), h.set(I.col, m * 3), I.colorRuns && I.colorRuns.length > 0 ? Fn(y, I.colorRuns, m) : x = !1, m += I.vertexCount;
3918
3914
  for (const I of o.records)
3919
3915
  i.add(I), this.subtractLineCanonicalStats(I), this.disposeLineChunkRecord(I);
3920
- const b = p ? Pt(y) : void 0, v = this.makeLineChunkRecord(
3916
+ const b = x ? Pt(y) : void 0, R = this.makeLineChunkRecord(
3921
3917
  o.parent,
3922
3918
  e,
3923
3919
  c,
3924
3920
  h,
3925
- d,
3926
3921
  l,
3922
+ d,
3927
3923
  u === 2 ? "xy-zero-z" : void 0,
3928
3924
  b,
3929
3925
  u,
3930
3926
  o.lineweightPx
3931
3927
  );
3932
- o.parent.add(v.renderable), this.addLineCanonicalStats(v), s.push(v);
3928
+ o.parent.add(R.renderable), this.addLineCanonicalStats(R), s.push(R);
3933
3929
  }
3934
3930
  const a = this.lineChunkRecords.filter((o) => !i.has(o));
3935
3931
  return this.lineChunkRecords.length = 0, this.lineChunkRecords.push(...a, ...s), !0;
@@ -3955,7 +3951,7 @@ class ye extends ee {
3955
3951
  this.compactNonLineChunksForSingleLayer(r, e);
3956
3952
  }
3957
3953
  compactNonLineChunksForSingleLayer(e, r) {
3958
- var v, I;
3954
+ var R, I;
3959
3955
  const i = this.findKindGroup(e, r);
3960
3956
  if (!i || i.children.length <= 1)
3961
3957
  return !1;
@@ -3963,27 +3959,27 @@ class ye extends ee {
3963
3959
  if (s.length <= 1)
3964
3960
  return !1;
3965
3961
  let a = 0, o = null;
3966
- const d = [], l = [], u = [];
3962
+ const l = [], d = [], u = [];
3967
3963
  let c = !0;
3968
3964
  for (const w of s) {
3969
3965
  const A = w.geometry;
3970
3966
  if (!A) continue;
3971
3967
  const B = A.getAttribute("position"), E = A.getAttribute("color");
3972
3968
  if (!(B instanceof $) || !(E instanceof $) || !(B.array instanceof Float32Array)) continue;
3973
- const S = Number(((v = w.userData) == null ? void 0 : v.vertexCount) || 0);
3969
+ const S = Number(((R = w.userData) == null ? void 0 : R.vertexCount) || 0);
3974
3970
  if (S <= 0) continue;
3975
3971
  const P = A.userData.cadDisplaySourceColor, O = A.userData.cadDisplayColorRuns;
3976
- O && O.length > 0 ? Fn(u, O, a) : c = !1, a += S, d.push(B.array), l.push(P instanceof Uint8Array ? P : ms(E)), o = fe(o, ((I = w.userData) == null ? void 0 : I.bbox) ?? null);
3972
+ O && O.length > 0 ? Fn(u, O, a) : c = !1, a += S, l.push(B.array), d.push(P instanceof Uint8Array ? P : ms(E)), o = fe(o, ((I = w.userData) == null ? void 0 : I.bbox) ?? null);
3977
3973
  }
3978
3974
  for (const w of s)
3979
3975
  i.remove(w), bt(w);
3980
3976
  if (a <= 0)
3981
3977
  return !1;
3982
3978
  const h = new Float32Array(a * 3), y = new Uint8Array(a * 3);
3983
- let p = 0;
3984
- for (let w = 0; w < d.length; w += 1) {
3985
- const T = Math.floor(d[w].length / 3), A = p * 3;
3986
- h.set(d[w], A), y.set(l[w], A), p += T;
3979
+ let x = 0;
3980
+ for (let w = 0; w < l.length; w += 1) {
3981
+ const T = Math.floor(l[w].length / 3), A = x * 3;
3982
+ h.set(l[w], A), y.set(d[w], A), x += T;
3987
3983
  }
3988
3984
  const m = c ? Pt(u) : void 0, b = this.createRenderableChunk(
3989
3985
  r,
@@ -4004,9 +4000,9 @@ class ye extends ee {
4004
4000
  for (const a of this.layerOrder) {
4005
4001
  const o = this.findKindGroup(a, s);
4006
4002
  if (o)
4007
- for (const d of o.children) {
4008
- const l = Number(((r = d.userData) == null ? void 0 : r.vertexCount) || 0), u = ((i = d.userData) == null ? void 0 : i.bbox) ?? null;
4009
- this.nonLineChunkStats.push({ layerIndex: a, vertexCount: l, bbox: u });
4003
+ for (const l of o.children) {
4004
+ const d = Number(((r = l.userData) == null ? void 0 : r.vertexCount) || 0), u = ((i = l.userData) == null ? void 0 : i.bbox) ?? null;
4005
+ this.nonLineChunkStats.push({ layerIndex: a, vertexCount: d, bbox: u });
4010
4006
  }
4011
4007
  }
4012
4008
  }
@@ -4039,9 +4035,9 @@ class ye extends ee {
4039
4035
  if (r === "text" || r === "text-batch") return;
4040
4036
  const i = e.geometry;
4041
4037
  i && this.applyDisplayColorsToGeometry(i);
4042
- const s = e.material, a = Number.isInteger((c = e.userData) == null ? void 0 : c.layerIndex) ? Number(e.userData.layerIndex) : null, o = a === null ? null : this.colorOverridesByIndex.get(a) ?? null, d = this.displayElementKindForObject(e), l = Array.isArray(s) ? s : s ? [s] : [];
4043
- for (const h of l)
4044
- gt(h) && (this.applyLayerColorState(h, o, d), h.needsUpdate = !0);
4038
+ const s = e.material, a = Number.isInteger((c = e.userData) == null ? void 0 : c.layerIndex) ? Number(e.userData.layerIndex) : null, o = a === null ? null : this.colorOverridesByIndex.get(a) ?? null, l = this.displayElementKindForObject(e), d = Array.isArray(s) ? s : s ? [s] : [];
4039
+ for (const h of d)
4040
+ gt(h) && (this.applyLayerColorState(h, o, l), h.needsUpdate = !0);
4045
4041
  });
4046
4042
  for (const e of this.layerOrder)
4047
4043
  this.applyLayerTextColors(e, this.colorOverridesByIndex.get(e) ?? null);
@@ -4057,25 +4053,25 @@ class ye extends ee {
4057
4053
  this.applyDisplayColorsToGeometry(o);
4058
4054
  }
4059
4055
  installGeometryDisplayColorMetadata(e, r, i, s, a) {
4060
- const o = e, d = Math.floor(r.length / 3), l = On(a, d);
4061
- return l ? (delete o.userData.cadDisplaySourceColor, o.userData.cadDisplayColorRuns = l) : (o.userData.cadDisplaySourceColor = fr(r).slice(), delete o.userData.cadDisplayColorRuns), o.userData.cadDisplayVertexCount = d, o.userData.cadDisplayLayerIndex = i, o.userData.cadDisplayElementKind = s, o;
4056
+ const o = e, l = Math.floor(r.length / 3), d = On(a, l);
4057
+ return d ? (delete o.userData.cadDisplaySourceColor, o.userData.cadDisplayColorRuns = d) : (o.userData.cadDisplaySourceColor = fr(r).slice(), delete o.userData.cadDisplayColorRuns), o.userData.cadDisplayVertexCount = l, o.userData.cadDisplayLayerIndex = i, o.userData.cadDisplayElementKind = s, o;
4062
4058
  }
4063
4059
  applyDisplayColorsToGeometry(e) {
4064
- const r = e, i = r.userData.cadDisplaySourceColor, s = r.userData.cadDisplayColorRuns, a = Number(r.userData.cadDisplayVertexCount ?? 0), o = Number(r.userData.cadDisplayLayerIndex ?? 0), d = r.userData.cadDisplayElementKind ?? "line", l = s && s.length > 0 && Ye(a, s), u = r.userData.cadDisplayColorTarget;
4060
+ const r = e, i = r.userData.cadDisplaySourceColor, s = r.userData.cadDisplayColorRuns, a = Number(r.userData.cadDisplayVertexCount ?? 0), o = Number(r.userData.cadDisplayLayerIndex ?? 0), l = r.userData.cadDisplayElementKind ?? "line", d = s && s.length > 0 && Ye(a, s), u = r.userData.cadDisplayColorTarget;
4065
4061
  if (u) {
4066
- if (l) {
4062
+ if (d) {
4067
4063
  const y = a * 3;
4068
4064
  if (u.array.length !== y)
4069
4065
  throw new Error(
4070
4066
  `CAD display color target length mismatch: expected ${y}, received ${u.array.length}`
4071
4067
  );
4072
- const p = St(
4068
+ const x = St(
4073
4069
  u.array,
4074
4070
  a,
4075
4071
  s,
4076
- (m) => this.resolveDisplayRgbForLegacyRgb(m, o, d)
4072
+ (m) => this.resolveDisplayRgbForLegacyRgb(m, o, l)
4077
4073
  );
4078
- this.recordDisplayColorBuildStats(p), u.markNeedsUpdate();
4074
+ this.recordDisplayColorBuildStats(x), u.markNeedsUpdate();
4079
4075
  return;
4080
4076
  }
4081
4077
  if (i instanceof Uint8Array && i.length > 0) {
@@ -4083,43 +4079,43 @@ class ye extends ee {
4083
4079
  throw new Error(
4084
4080
  `CAD display color target length mismatch: expected ${i.length}, received ${u.array.length}`
4085
4081
  );
4086
- const y = this.buildDisplayColorBytes(i, o, d);
4082
+ const y = this.buildDisplayColorBytes(i, o, l);
4087
4083
  u.array.set(y), u.markNeedsUpdate();
4088
4084
  return;
4089
4085
  }
4090
4086
  return;
4091
4087
  }
4092
- if (l && typeof r.setColors == "function") {
4088
+ if (d && typeof r.setColors == "function") {
4093
4089
  const y = gs(
4094
4090
  a,
4095
4091
  s,
4096
- (p) => this.resolveDisplayRgbForLegacyRgb(p, o, d)
4092
+ (x) => this.resolveDisplayRgbForLegacyRgb(x, o, l)
4097
4093
  );
4098
4094
  this.recordDisplayColorBuildStats(y.stats), r.setColors(y.color), r.getAttribute("instanceColorStart") && (r.getAttribute("instanceColorStart").needsUpdate = !0), r.getAttribute("instanceColorEnd") && (r.getAttribute("instanceColorEnd").needsUpdate = !0);
4099
4095
  return;
4100
4096
  }
4101
- if (l) {
4097
+ if (d) {
4102
4098
  const y = r.getAttribute("color");
4103
4099
  if (y instanceof $ && y.array instanceof Uint8Array && y.array.length === a * 3) {
4104
4100
  const m = St(
4105
4101
  y.array,
4106
4102
  a,
4107
4103
  s,
4108
- (b) => this.resolveDisplayRgbForLegacyRgb(b, o, d)
4104
+ (b) => this.resolveDisplayRgbForLegacyRgb(b, o, l)
4109
4105
  );
4110
4106
  this.recordDisplayColorBuildStats(m), y.normalized = !0, y.needsUpdate = !0;
4111
4107
  return;
4112
4108
  }
4113
- const p = vn(
4109
+ const x = vn(
4114
4110
  a,
4115
4111
  s,
4116
- (m) => this.resolveDisplayRgbForLegacyRgb(m, o, d)
4112
+ (m) => this.resolveDisplayRgbForLegacyRgb(m, o, l)
4117
4113
  );
4118
- this.recordDisplayColorBuildStats(p.stats), r.setAttribute("color", wn(p.color));
4114
+ this.recordDisplayColorBuildStats(x.stats), r.setAttribute("color", wn(x.color));
4119
4115
  return;
4120
4116
  }
4121
4117
  if (!(i instanceof Uint8Array) || i.length === 0) return;
4122
- const c = this.buildDisplayColorBytes(i, o, d);
4118
+ const c = this.buildDisplayColorBytes(i, o, l);
4123
4119
  if (typeof r.setColors == "function") {
4124
4120
  r.setColors(ys(c)), r.getAttribute("instanceColorStart") && (r.getAttribute("instanceColorStart").needsUpdate = !0), r.getAttribute("instanceColorEnd") && (r.getAttribute("instanceColorEnd").needsUpdate = !0);
4125
4121
  return;
@@ -4132,15 +4128,15 @@ class ye extends ee {
4132
4128
  r.setAttribute("color", wn(c));
4133
4129
  }
4134
4130
  buildDisplayColorBytes(e, r, i, s, a) {
4135
- const d = s && s.length > 0 && typeof a == "number" && Ye(a, s) ? vn(
4131
+ const l = s && s.length > 0 && typeof a == "number" && Ye(a, s) ? vn(
4136
4132
  a,
4137
4133
  s,
4138
- (l) => this.resolveDisplayRgbForLegacyRgb(l, r, i)
4134
+ (d) => this.resolveDisplayRgbForLegacyRgb(d, r, i)
4139
4135
  ) : xs(
4140
4136
  e,
4141
- (l) => this.resolveDisplayRgbForLegacyRgb(l, r, i)
4137
+ (d) => this.resolveDisplayRgbForLegacyRgb(d, r, i)
4142
4138
  );
4143
- return this.recordDisplayColorBuildStats(d.stats), d.color;
4139
+ return this.recordDisplayColorBuildStats(l.stats), l.color;
4144
4140
  }
4145
4141
  recordDisplayColorBuildStats(e) {
4146
4142
  this.colorRefreshStats.displayRefreshVertexTotal += e.vertexCount, this.colorRefreshStats.displayRefreshRunTotal += e.runCount, this.colorRefreshStats.displayRefreshUniqueColorTotal += e.uniqueColorCount, this.colorRefreshStats.displayRefreshCacheHitTotal += e.cacheHitCount, this.colorRefreshStats.displayRefreshRepeatedRunVertexTotal += e.repeatedRunVertexCount;
@@ -4165,28 +4161,28 @@ class ye extends ee {
4165
4161
  return r === "text-batch" ? "text" : r === "fill" || r === "dot" || r === "text" || r === "hatch" || r === "overlay" ? r : "line";
4166
4162
  }
4167
4163
  createInsertInstanceRecords(e) {
4168
- const r = [], { meta: i, mats: s, bboxes: a, count: o } = e, d = /* @__PURE__ */ new Map();
4169
- for (let l = 0; l < o; l += 1) {
4170
- const u = i[l * 3], c = i[l * 3 + 1], h = `${u}:${c}`, y = d.get(h) ?? 0;
4171
- d.set(h, y + 1);
4172
- const p = {
4173
- minX: a[l * 4],
4174
- minY: a[l * 4 + 1],
4175
- maxX: a[l * 4 + 2],
4176
- maxY: a[l * 4 + 3]
4164
+ const r = [], { meta: i, mats: s, bboxes: a, count: o } = e, l = /* @__PURE__ */ new Map();
4165
+ for (let d = 0; d < o; d += 1) {
4166
+ const u = i[d * 3], c = i[d * 3 + 1], h = `${u}:${c}`, y = l.get(h) ?? 0;
4167
+ l.set(h, y + 1);
4168
+ const x = {
4169
+ minX: a[d * 4],
4170
+ minY: a[d * 4 + 1],
4171
+ maxX: a[d * 4 + 2],
4172
+ maxY: a[d * 4 + 3]
4177
4173
  };
4178
- Tt(p) && r.push({
4174
+ Tt(x) && r.push({
4179
4175
  recordKey: Ar(u, c, y),
4180
4176
  instanceId: u,
4181
4177
  variantId: c,
4182
- layerIdx: i[l * 3 + 2],
4183
- matA: s[l * 6],
4184
- matB: s[l * 6 + 1],
4185
- matC: s[l * 6 + 2],
4186
- matD: s[l * 6 + 3],
4187
- tx: s[l * 6 + 4],
4188
- ty: s[l * 6 + 5],
4189
- bbox: p
4178
+ layerIdx: i[d * 3 + 2],
4179
+ matA: s[d * 6],
4180
+ matB: s[d * 6 + 1],
4181
+ matC: s[d * 6 + 2],
4182
+ matD: s[d * 6 + 3],
4183
+ tx: s[d * 6 + 4],
4184
+ ty: s[d * 6 + 5],
4185
+ bbox: x
4190
4186
  });
4191
4187
  }
4192
4188
  return r;
@@ -4356,19 +4352,19 @@ async function Pa(t, n, e, r, i) {
4356
4352
  entries: a.manifest,
4357
4353
  requiredVariantIds: a.requiredVariantIds,
4358
4354
  signal: i
4359
- }) : Promise.resolve({ buffers: /* @__PURE__ */ new Map(), fetchMs: 0 }), d = e.loadAnnotations === !1 ? null : Gt(n), [l, u] = await Promise.all([
4355
+ }) : Promise.resolve({ buffers: /* @__PURE__ */ new Map(), fetchMs: 0 }), l = e.loadAnnotations === !1 ? null : Gt(n), [d, u] = await Promise.all([
4360
4356
  o,
4361
- d != null && d.scene ? Er(s, d.scene, i) : Promise.resolve(null)
4357
+ l != null && l.scene ? Er(s, l.scene, i) : Promise.resolve(null)
4362
4358
  ]), c = [];
4363
4359
  if (je(u) && c.push(u), e.loadAnnotations !== !1 && e.loadBlocks !== !1) {
4364
4360
  const h = Ut(n, {
4365
- externalVariantBuffers: l.buffers,
4361
+ externalVariantBuffers: d.buffers,
4366
4362
  hiddenInstanceIds: r
4367
4363
  });
4368
4364
  je(h) && c.push(h);
4369
4365
  }
4370
4366
  return {
4371
- externalVariantBuffers: l.buffers,
4367
+ externalVariantBuffers: d.buffers,
4372
4368
  requiredExternalVariantIds: a.requiredVariantIds,
4373
4369
  externalVariantGeometryFetchIds: a.requiredVariantIds,
4374
4370
  annotations: c
@@ -4437,7 +4433,7 @@ function Fo(t, n) {
4437
4433
  };
4438
4434
  }
4439
4435
  function Oo(t) {
4440
- si(t);
4436
+ ai(t);
4441
4437
  }
4442
4438
  function Da(t) {
4443
4439
  return t instanceof Error ? t : typeof t == "string" ? new Error(t) : new Error(`Unknown geo load error: ${String(t)}`);
@@ -4456,11 +4452,11 @@ function _o(t, n = {}) {
4456
4452
  ue(r.sourceSignal, e)
4457
4453
  ];
4458
4454
  $e(i, () => {
4459
- e.abort(K("GeoNode disposed during CAD load"));
4455
+ e.abort(W("GeoNode disposed during CAD load"));
4460
4456
  });
4461
- const a = en(n.hiddenInstanceIds), o = ie(n.requiredExternalVariantIds), d = ie(n.externalVariantGeometryFetchIds);
4457
+ const a = en(n.hiddenInstanceIds), o = ie(n.requiredExternalVariantIds), l = ie(n.externalVariantGeometryFetchIds);
4462
4458
  return (async () => {
4463
- var l;
4459
+ var d;
4464
4460
  try {
4465
4461
  const u = await jn(
4466
4462
  Zt(r.source),
@@ -4476,15 +4472,15 @@ function _o(t, n = {}) {
4476
4472
  signal: e.signal,
4477
4473
  hiddenInstanceIds: a,
4478
4474
  requiredExternalVariantIds: o ?? ie(c.requiredExternalVariantIds),
4479
- externalVariantGeometryFetchIds: d ?? ie(c.externalVariantGeometryFetchIds),
4475
+ externalVariantGeometryFetchIds: l ?? ie(c.externalVariantGeometryFetchIds),
4480
4476
  beforeTextAppend: n.beforeTextAppend,
4481
4477
  beforeFinalize: async () => {
4482
4478
  var y;
4483
- for (const p of c.annotations)
4484
- await ((y = n.beforeTextAppend) == null ? void 0 : y.call(n, p.texts)), i.appendAnnotationOverlay(p);
4479
+ for (const x of c.annotations)
4480
+ await ((y = n.beforeTextAppend) == null ? void 0 : y.call(n, x.texts)), i.appendAnnotationOverlay(x);
4485
4481
  }
4486
4482
  };
4487
- n.loadBlocks === !1 && (h.loadBlocks = !1), typeof n.maxExpandedInstanceVertices == "number" && Number.isFinite(n.maxExpandedInstanceVertices) && n.maxExpandedInstanceVertices >= 0 && (h.maxExpandedInstanceVertices = n.maxExpandedInstanceVertices), n.preferWorker === !1 && (h.preferWorker = !1), n.workerUrl !== void 0 && (h.workerUrl = n.workerUrl), n.workerFactory && (h.workerFactory = n.workerFactory), n.externalVariantFetchSource && (h.externalVariantFetchSource = n.externalVariantFetchSource), n.externalVariantBuffers && n.externalVariantBuffers.size > 0 ? h.externalVariantBuffers = n.externalVariantBuffers : (l = c.externalVariantBuffers) != null && l.size && (h.externalVariantBuffers = c.externalVariantBuffers), await cr(i, u, void 0, {
4483
+ n.loadBlocks === !1 && (h.loadBlocks = !1), typeof n.maxExpandedInstanceVertices == "number" && Number.isFinite(n.maxExpandedInstanceVertices) && n.maxExpandedInstanceVertices >= 0 && (h.maxExpandedInstanceVertices = n.maxExpandedInstanceVertices), n.preferWorker === !1 && (h.preferWorker = !1), n.workerUrl !== void 0 && (h.workerUrl = n.workerUrl), n.workerFactory && (h.workerFactory = n.workerFactory), n.externalVariantFetchSource && (h.externalVariantFetchSource = n.externalVariantFetchSource), n.externalVariantBuffers && n.externalVariantBuffers.size > 0 ? h.externalVariantBuffers = n.externalVariantBuffers : (d = c.externalVariantBuffers) != null && d.size && (h.externalVariantBuffers = c.externalVariantBuffers), await cr(i, u, void 0, {
4488
4484
  ...h
4489
4485
  });
4490
4486
  } catch (u) {
@@ -4495,6 +4491,9 @@ function _o(t, n = {}) {
4495
4491
  }
4496
4492
  })(), i;
4497
4493
  }
4494
+ function Go(t) {
4495
+ ei(t);
4496
+ }
4498
4497
  const Fa = 40;
4499
4498
  function Sr(t) {
4500
4499
  return !!(t && Number.isFinite(t.minX) && Number.isFinite(t.minY) && Number.isFinite(t.maxX) && Number.isFinite(t.maxY) && t.maxX >= t.minX && t.maxY >= t.minY);
@@ -4505,7 +4504,7 @@ function Oa(t, n, e) {
4505
4504
  function _a(t, n) {
4506
4505
  return n.minX >= t.minX && n.maxX <= t.maxX && n.minY >= t.minY && n.maxY <= t.maxY;
4507
4506
  }
4508
- function Go(t, n) {
4507
+ function Uo(t, n) {
4509
4508
  return t.layerIndex === n.layerIndex && t.variantId === n.variantId && t.instanceId === n.instanceId;
4510
4509
  }
4511
4510
  function Ga(t, n, e = {}) {
@@ -4514,21 +4513,21 @@ function Ga(t, n, e = {}) {
4514
4513
  const r = Math.max(0, e.padding ?? Fa), i = t.getLayers();
4515
4514
  let s = null;
4516
4515
  for (let o = i.length - 1; o >= 0; o -= 1) {
4517
- const d = i[o];
4518
- if (!d || !d.visible) continue;
4519
- const l = t.getLayerBlockUsages(d.index);
4520
- for (let u = l.length - 1; u >= 0; u -= 1) {
4521
- const c = l[u];
4516
+ const l = i[o];
4517
+ if (!l || !l.visible) continue;
4518
+ const d = t.getLayerBlockUsages(l.index);
4519
+ for (let u = d.length - 1; u >= 0; u -= 1) {
4520
+ const c = d[u];
4522
4521
  for (let h = c.inserts.length - 1; h >= 0; h -= 1) {
4523
4522
  const y = c.inserts[h];
4524
4523
  if (!y.canHighlight || !Sr(y.bbox) || ((a = e.isInstanceVisible) == null ? void 0 : a.call(e, y.instanceId)) === !1 || !Oa(y.bbox, n, r)) continue;
4525
- const p = {
4524
+ const x = {
4526
4525
  kind: "insert",
4527
- layerIndex: d.index,
4526
+ layerIndex: l.index,
4528
4527
  variantId: c.variantId,
4529
4528
  instanceId: y.instanceId
4530
4529
  };
4531
- if (s || (s = p), !e.viewport || _a(e.viewport, y.bbox)) return p;
4530
+ if (s || (s = x), !e.viewport || _a(e.viewport, y.bbox)) return x;
4532
4531
  }
4533
4532
  }
4534
4533
  }
@@ -4561,8 +4560,8 @@ function Na(t) {
4561
4560
  return t.va === "middle" ? i = -e / 2 : t.va === "top" && (i = -e), { x0: r, y0: i, x1: r + n, y1: i + e };
4562
4561
  }
4563
4562
  function za(t, n, e) {
4564
- const r = t.x - n.x, i = t.y - n.y, s = (n.r || 0) * Math.PI / 180, a = Math.cos(-s), o = Math.sin(-s), d = r * a - i * o, l = r * o + i * a;
4565
- return d >= e.x0 && d <= e.x1 && l >= e.y0 && l <= e.y1;
4563
+ const r = t.x - n.x, i = t.y - n.y, s = (n.r || 0) * Math.PI / 180, a = Math.cos(-s), o = Math.sin(-s), l = r * a - i * o, d = r * o + i * a;
4564
+ return l >= e.x0 && l <= e.x1 && d >= e.y0 && d <= e.y1;
4566
4565
  }
4567
4566
  function Ha(t, n, e = {}) {
4568
4567
  if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) return null;
@@ -4570,8 +4569,8 @@ function Ha(t, n, e = {}) {
4570
4569
  if (r.length === 0) return null;
4571
4570
  const s = t.getLayers(), a = i === void 0 ? r.length - 1 : Math.min(r.length, Math.max(0, Math.floor(i))) - 1;
4572
4571
  for (let o = a; o >= 0; o -= 1) {
4573
- const d = r[o], l = s.find((u) => u.index === d.li);
4574
- if (!(l && l.visible === !1) && za(n, d, Na(d)))
4572
+ const l = r[o], d = s.find((u) => u.index === l.li);
4573
+ if (!(d && d.visible === !1) && za(n, l, Na(l)))
4575
4574
  return { kind: "text", textId: o };
4576
4575
  }
4577
4576
  return null;
@@ -4592,10 +4591,10 @@ function qa(t, n) {
4592
4591
  layerIndex: e.li
4593
4592
  };
4594
4593
  }
4595
- function Uo(t, n) {
4594
+ function No(t, n) {
4596
4595
  return (t == null ? void 0 : t.kind) === "text" && (n == null ? void 0 : n.kind) === "text" && t.textId === n.textId;
4597
4596
  }
4598
- const No = [
4597
+ const zo = [
4599
4598
  "created",
4600
4599
  "header-ready",
4601
4600
  "initial-loading",
@@ -4709,16 +4708,16 @@ function Ja(t) {
4709
4708
  for (const a of t.getLayers())
4710
4709
  for (const o of t.getLayerBlockUsages(a.index)) {
4711
4710
  n.add(o.variantId);
4712
- const d = e.get(o.variantId) ?? /* @__PURE__ */ new Set();
4713
- d.add(a.index), e.set(o.variantId, d);
4711
+ const l = e.get(o.variantId) ?? /* @__PURE__ */ new Set();
4712
+ l.add(a.index), e.set(o.variantId, l);
4714
4713
  for (const u of o.inserts) r.add(u.instanceId);
4715
- let l = i.get(o.variantId);
4716
- l || (l = {
4714
+ let d = i.get(o.variantId);
4715
+ d || (d = {
4717
4716
  variantId: o.variantId,
4718
4717
  blockName: o.blockName,
4719
4718
  instanceCount: 0,
4720
4719
  layers: /* @__PURE__ */ new Map()
4721
- }, i.set(o.variantId, l)), l.instanceCount += o.instanceCount, l.layers.set(a.index, a.name);
4720
+ }, i.set(o.variantId, d)), d.instanceCount += o.instanceCount, d.layers.set(a.index, a.name);
4722
4721
  }
4723
4722
  const s = [...i.values()].filter((a) => a.layers.size > 1).map((a) => ({
4724
4723
  variantId: a.variantId,
@@ -4744,26 +4743,26 @@ function eo(t) {
4744
4743
  r
4745
4744
  );
4746
4745
  }, o = (c, h) => {
4747
- var y, p, m, b, v, I, w, T;
4748
- return c !== null && ((y = c.documentRect) == null ? void 0 : y.minX) === ((p = h.documentRect) == null ? void 0 : p.minX) && ((m = c.documentRect) == null ? void 0 : m.minY) === ((b = h.documentRect) == null ? void 0 : b.minY) && ((v = c.documentRect) == null ? void 0 : v.maxX) === ((I = h.documentRect) == null ? void 0 : I.maxX) && ((w = c.documentRect) == null ? void 0 : w.maxY) === ((T = h.documentRect) == null ? void 0 : T.maxY) && c.viewportWidthPx === h.viewportWidthPx && c.viewportHeightPx === h.viewportHeightPx && c.devicePixelRatio === h.devicePixelRatio && c.worldUnitsPerPixel === h.worldUnitsPerPixel && c.viewMode === h.viewMode && c.quality === h.quality;
4749
- }, d = (c) => {
4746
+ var y, x, m, b, R, I, w, T;
4747
+ return c !== null && ((y = c.documentRect) == null ? void 0 : y.minX) === ((x = h.documentRect) == null ? void 0 : x.minX) && ((m = c.documentRect) == null ? void 0 : m.minY) === ((b = h.documentRect) == null ? void 0 : b.minY) && ((R = c.documentRect) == null ? void 0 : R.maxX) === ((I = h.documentRect) == null ? void 0 : I.maxX) && ((w = c.documentRect) == null ? void 0 : w.maxY) === ((T = h.documentRect) == null ? void 0 : T.maxY) && c.viewportWidthPx === h.viewportWidthPx && c.viewportHeightPx === h.viewportHeightPx && c.devicePixelRatio === h.devicePixelRatio && c.worldUnitsPerPixel === h.worldUnitsPerPixel && c.viewMode === h.viewMode && c.quality === h.quality;
4748
+ }, l = (c) => {
4750
4749
  var y;
4751
4750
  let h = !1;
4752
- for (const p of c) {
4753
- const m = Wa(p.insertId);
4754
- m !== null && (p.visible ? s.delete(m) && (h = !0) : s.has(m) || (s.add(m), h = !0));
4751
+ for (const x of c) {
4752
+ const m = Wa(x.insertId);
4753
+ m !== null && (x.visible ? s.delete(m) && (h = !0) : s.has(m) || (s.add(m), h = !0));
4755
4754
  }
4756
4755
  h && (r += 1, i.invalidateInsertPresenterQueryCache(), a(), t.onInsertVisibilityChange(), (y = i._notifyStructureChange) == null || y.call(i));
4757
- }, l = (c, h) => {
4756
+ }, d = (c, h) => {
4758
4757
  if (!h) return null;
4759
4758
  const y = i.getLayers();
4760
4759
  return y.length === 0 || y.some((m) => typeof c.layerVisible == "function" ? c.layerVisible(m.index) : c.layerVisible ? c.layerVisible.get(m.index) ?? m.visible : m.visible) ? h : null;
4761
4760
  }, u = (c) => {
4762
- var p;
4761
+ var x;
4763
4762
  const h = new Map(i.getLayers().map((m) => [m.index, m.visible]));
4764
4763
  let y = null;
4765
4764
  for (const m of i.getGeometryChunkStats())
4766
- !(typeof c.layerVisible == "function" ? c.layerVisible(m.layerIndex) : ((p = c.layerVisible) == null ? void 0 : p.get(m.layerIndex)) ?? h.get(m.layerIndex) ?? !0) || !m.bbox || (y = Un(y, He([
4765
+ !(typeof c.layerVisible == "function" ? c.layerVisible(m.layerIndex) : ((x = c.layerVisible) == null ? void 0 : x.get(m.layerIndex)) ?? h.get(m.layerIndex) ?? !0) || !m.bbox || (y = Un(y, He([
4767
4766
  m.bbox.minX,
4768
4767
  m.bbox.minY,
4769
4768
  m.bbox.maxX,
@@ -4779,16 +4778,16 @@ function eo(t) {
4779
4778
  return n;
4780
4779
  },
4781
4780
  getAuthoritativeBounds(c) {
4782
- return l(
4781
+ return d(
4783
4782
  c,
4784
4783
  Un(t.getHeaderBounds(), He(i.getBounds()))
4785
4784
  );
4786
4785
  },
4787
4786
  getMountedBounds(c) {
4788
- return u(c) ?? l(c, He(i.getBounds()));
4787
+ return u(c) ?? d(c, He(i.getBounds()));
4789
4788
  },
4790
4789
  getUnmountedExternalBounds(c) {
4791
- return c.includeUnmountedExternal === !1 ? null : l(c, t.getUnmountedBounds());
4790
+ return c.includeUnmountedExternal === !1 ? null : d(c, t.getUnmountedBounds());
4792
4791
  },
4793
4792
  appendContent(c) {
4794
4793
  return n += 1, a(), !0;
@@ -4806,10 +4805,10 @@ function eo(t) {
4806
4805
  i.setLayerColor(c, h);
4807
4806
  },
4808
4807
  setInsertVisible(c, h) {
4809
- d([{ insertId: c, visible: h }]);
4808
+ l([{ insertId: c, visible: h }]);
4810
4809
  },
4811
4810
  setInsertVisibleBatch(c) {
4812
- d(c);
4811
+ l(c);
4813
4812
  },
4814
4813
  createInsertPreview(c) {
4815
4814
  const h = i.createInsertPreviewResource(c);
@@ -4828,7 +4827,7 @@ function eo(t) {
4828
4827
  } : null;
4829
4828
  },
4830
4829
  getDiagnostics() {
4831
- const c = i.getMeta(), h = Xa(i), y = ja(i), p = Ja(i);
4830
+ const c = i.getMeta(), h = Xa(i), y = ja(i), x = Ja(i);
4832
4831
  return {
4833
4832
  entityCount: c.entityCount,
4834
4833
  lineCount: c.lineCount,
@@ -4838,7 +4837,7 @@ function eo(t) {
4838
4837
  lineRenderMode: i.getLineRenderMode(),
4839
4838
  ...h,
4840
4839
  ...y,
4841
- ...p
4840
+ ...x
4842
4841
  };
4843
4842
  },
4844
4843
  onChange(c) {
@@ -4874,12 +4873,12 @@ function ro(t) {
4874
4873
  var c;
4875
4874
  const a = ur(s), o = t.fontResolver;
4876
4875
  if (!o || r) return a;
4877
- const d = { family: void 0 }, l = "";
4878
- if (e.has(l)) return a;
4879
- let u = n.get(l);
4880
- return u || (u = { promise: o.resolve(d, t.signal).then((y) => (u && (u.resolved = y), y != null && y.fontUrl && ao(y.fontUrl, a.text, t.signal).catch((p) => {
4881
- t.onNonFatalError(p instanceof Error ? p : new Error(String(p)));
4882
- }), y)).catch((y) => (e.add(l), t.onNonFatalError(y instanceof Error ? y : new Error(String(y))), null)), resolved: null }, n.set(l, u)), (c = u.resolved) != null && c.fontUrl ? { ...a, fontUrl: u.resolved.fontUrl, kind: u.resolved.family } : a;
4876
+ const l = { family: void 0 }, d = "";
4877
+ if (e.has(d)) return a;
4878
+ let u = n.get(d);
4879
+ return u || (u = { promise: o.resolve(l, t.signal).then((y) => (u && (u.resolved = y), y != null && y.fontUrl && ao(y.fontUrl, a.text, t.signal).catch((x) => {
4880
+ t.onNonFatalError(x instanceof Error ? x : new Error(String(x)));
4881
+ }), y)).catch((y) => (e.add(d), t.onNonFatalError(y instanceof Error ? y : new Error(String(y))), null)), resolved: null }, n.set(d, u)), (c = u.resolved) != null && c.fontUrl ? { ...a, fontUrl: u.resolved.fontUrl, kind: u.resolved.family } : a;
4883
4882
  },
4884
4883
  dispose() {
4885
4884
  r = !0, n.clear();
@@ -4893,19 +4892,19 @@ function so(t) {
4893
4892
  function ao(t, n, e) {
4894
4893
  return typeof We != "function" || e.aborted ? Promise.resolve() : new Promise((r, i) => {
4895
4894
  let s = !1;
4896
- const a = (d) => {
4897
- s || (s = !0, globalThis.clearTimeout(o), d());
4895
+ const a = (l) => {
4896
+ s || (s = !0, globalThis.clearTimeout(o), l());
4898
4897
  }, o = globalThis.setTimeout(() => {
4899
4898
  a(() => i(new Error(`Troika font warmup timed out for ${t}`)));
4900
4899
  }, io);
4901
4900
  try {
4902
- const d = We({ font: t, characters: n }, () => a(r));
4903
- so(d) && d.then(
4901
+ const l = We({ font: t, characters: n }, () => a(r));
4902
+ so(l) && l.then(
4904
4903
  () => a(r),
4905
- (l) => a(() => i(l instanceof Error ? l : new Error(String(l))))
4904
+ (d) => a(() => i(d instanceof Error ? d : new Error(String(d))))
4906
4905
  );
4907
- } catch (d) {
4908
- a(() => i(d instanceof Error ? d : new Error(String(d))));
4906
+ } catch (l) {
4907
+ a(() => i(l instanceof Error ? l : new Error(String(l))));
4909
4908
  }
4910
4909
  });
4911
4910
  }
@@ -4923,9 +4922,9 @@ function yo() {
4923
4922
  return typeof globalThis.document < "u" && typeof We == "function";
4924
4923
  }
4925
4924
  function mo(t) {
4926
- var v, I, w, T;
4927
- const n = ((v = t.options) == null ? void 0 : v.idleDelayMs) ?? oo, e = ((I = t.options) == null ? void 0 : I.maxUniqueCharsPerFont) ?? lo, r = ((w = t.options) == null ? void 0 : w.timeoutMs) ?? co, i = ((T = t.options) == null ? void 0 : T.signatureCacheLimit) ?? uo, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
4928
- let d = null, l = !1;
4925
+ var R, I, w, T;
4926
+ const n = ((R = t.options) == null ? void 0 : R.idleDelayMs) ?? oo, e = ((I = t.options) == null ? void 0 : I.maxUniqueCharsPerFont) ?? lo, r = ((w = t.options) == null ? void 0 : w.timeoutMs) ?? co, i = ((T = t.options) == null ? void 0 : T.signatureCacheLimit) ?? uo, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
4927
+ let l = null, d = !1;
4929
4928
  const u = {
4930
4929
  scheduledTexts: 0,
4931
4930
  preloadCalls: 0,
@@ -4945,8 +4944,8 @@ function mo(t) {
4945
4944
  return new Promise((E, S) => {
4946
4945
  let P = !1;
4947
4946
  const O = (M) => {
4948
- P || (P = !0, globalThis.clearTimeout(W), M());
4949
- }, W = globalThis.setTimeout(() => {
4947
+ P || (P = !0, globalThis.clearTimeout(K), M());
4948
+ }, K = globalThis.setTimeout(() => {
4950
4949
  u.timedOutWarmups += 1, O(() => S(new Error(`Troika font warmup timed out for ${A}`)));
4951
4950
  }, r);
4952
4951
  try {
@@ -4978,15 +4977,15 @@ ${B}`;
4978
4977
  });
4979
4978
  return o.set(E, P), P;
4980
4979
  }
4981
- function p() {
4982
- if (d = null, l || s.size === 0) return;
4980
+ function x() {
4981
+ if (l = null, d || s.size === 0) return;
4983
4982
  const A = [...s.entries()];
4984
4983
  s.clear();
4985
4984
  for (const [B, E] of A)
4986
4985
  E.size !== 0 && y(B, ho([...E].join("")));
4987
4986
  }
4988
4987
  function m(A) {
4989
- if (!(l || A.length === 0) && yo() && !t.signal.aborted) {
4988
+ if (!(d || A.length === 0) && yo() && !t.signal.aborted) {
4990
4989
  u.scheduledTexts += A.length;
4991
4990
  for (const B of A) {
4992
4991
  const E = t.resolveTextFont(B);
@@ -4998,11 +4997,11 @@ ${B}`;
4998
4997
  S.add(P);
4999
4998
  }
5000
4999
  }
5001
- s.size === 0 || d !== null || (d = globalThis.setTimeout(p, n));
5000
+ s.size === 0 || l !== null || (l = globalThis.setTimeout(x, n));
5002
5001
  }
5003
5002
  }
5004
5003
  function b() {
5005
- l = !0, d !== null && (globalThis.clearTimeout(d), d = null), s.clear();
5004
+ d = !0, l !== null && (globalThis.clearTimeout(l), l = null), s.clear();
5006
5005
  }
5007
5006
  return {
5008
5007
  scheduleForTexts: m,
@@ -5055,13 +5054,13 @@ function Oe(t, n, e) {
5055
5054
  };
5056
5055
  }
5057
5056
  const Mt = /* @__PURE__ */ new WeakMap(), bo = 16;
5058
- function zo(t) {
5057
+ function Ho(t) {
5059
5058
  const n = Mt.get(t);
5060
5059
  if (!n)
5061
5060
  throw new Error("CAD document session has no render resource");
5062
5061
  return n;
5063
5062
  }
5064
- function Ho(t, n = {}) {
5063
+ function qo(t, n = {}) {
5065
5064
  return new Dt(t, n);
5066
5065
  }
5067
5066
  const Ze = class Ze {
@@ -5107,6 +5106,7 @@ const Ze = class Ze {
5107
5106
  f(this, "initialViewportDemand", null);
5108
5107
  f(this, "initialRequiredVariantIds", /* @__PURE__ */ new Set());
5109
5108
  f(this, "pendingInitialVariantIds", /* @__PURE__ */ new Set());
5109
+ f(this, "initialFirstVariantAppendStarted", !1);
5110
5110
  f(this, "initialVariantAppendTimer", null);
5111
5111
  f(this, "initialVariantAppendInFlight", null);
5112
5112
  f(this, "initialViewportSettled", !1);
@@ -5171,7 +5171,7 @@ const Ze = class Ze {
5171
5171
  ue(e.signal, this.sessionAbort),
5172
5172
  ue(r.sourceSignal, this.sessionAbort)
5173
5173
  ), $e(this.node, () => {
5174
- this.abort(K("GeoNode disposed during CAD load"));
5174
+ this.abort(W("GeoNode disposed during CAD load"));
5175
5175
  }), this.runLoad();
5176
5176
  }
5177
5177
  get loadTiming() {
@@ -5202,7 +5202,7 @@ const Ze = class Ze {
5202
5202
  return;
5203
5203
  }
5204
5204
  if (n.interaction === "active") {
5205
- this.abortAnnotations("viewport interaction active"), this.demandAbort.abort(K("viewport interaction active")), this.externalViewportQueued = !0, this.emitDemandProgress(!0);
5205
+ this.abortAnnotations("viewport interaction active"), this.externalViewportQueued = !0, this.emitDemandProgress(!0);
5206
5206
  return;
5207
5207
  }
5208
5208
  this.maybeRefreshExternalSidecars(), this.maybeLoadVisibleAnnotations(), this.maybeMarkInitialViewportSettled();
@@ -5284,13 +5284,13 @@ const Ze = class Ze {
5284
5284
  abort(n) {
5285
5285
  var r;
5286
5286
  if (this.disposed) return;
5287
- const e = K(n);
5287
+ const e = W(n);
5288
5288
  this.sessionAbort.abort(e), this.demandAbort.abort(e), this.annotationAbort.abort(e), (r = this.workerAdapter) == null || r.dispose(), !this.failed && this.fail(e);
5289
5289
  }
5290
5290
  dispose() {
5291
5291
  var e, r;
5292
5292
  if (this.disposed) return;
5293
- const n = K("CAD document session disposed");
5293
+ const n = W("CAD document session disposed");
5294
5294
  this.disposed = !0, this.sessionAbort.abort(n), this.demandAbort.abort(n), this.annotationAbort.abort(n), (e = this.workerAdapter) == null || e.dispose(), this.clearAnnotationTimer(), this.clearInitialVariantAppendTimer(), this.rejectHeader(n), this.rejectInitial(n), this.setPhase("disposed"), (r = this.textWarmup) == null || r.dispose(), this.fontRuntime.dispose(), this.listeners.clear();
5295
5295
  for (const i of this.signalCleanups) i();
5296
5296
  this.signalCleanups.length = 0, $e(this.node, null), this.node.ready.catch(() => {
@@ -5317,6 +5317,7 @@ const Ze = class Ze {
5317
5317
  hiddenInstanceIds: this.hiddenInstanceIds.size > 0 ? this.hiddenInstanceIds : void 0,
5318
5318
  requiredExternalVariantIds: a.requiredVariantIds,
5319
5319
  deferExternalVariantGeometry: a.requiredVariantIds.length > 0 && !!this.baseUrl,
5320
+ cacheDocument: this.workerAdapter !== null,
5320
5321
  onFirstRenderableAppend: () => this.markLoadTiming("firstRenderableReadyMs"),
5321
5322
  beforeTextAppend: this.handleBeforeTextAppend
5322
5323
  }), await this.node.ready, !this.isCurrent(n)) return;
@@ -5405,29 +5406,29 @@ const Ze = class Ze {
5405
5406
  signal: this.demandAbort.signal
5406
5407
  });
5407
5408
  if (!this.isCurrent(r)) return;
5408
- for (const [y, p] of h.buffers)
5409
- this.loadedSidecarBuffers.set(y, p), this.variantCoverage.set(y, "cached");
5409
+ for (const [y, x] of h.buffers)
5410
+ this.loadedSidecarBuffers.set(y, x), this.variantCoverage.set(y, "cached");
5410
5411
  }
5411
5412
  if (!this.isCurrent(r)) return;
5412
- const d = this.latestDemand;
5413
- if (!d || d.interaction === "active" || !go({
5413
+ const l = this.latestDemand;
5414
+ if (!l || l.interaction === "active" || !go({
5414
5415
  requestedViewport: n.documentRect,
5415
5416
  requestedWorldUnitsPerPixel: n.worldUnitsPerPixel,
5416
5417
  requestedHiddenSignature: e,
5417
- latestViewport: d.documentRect,
5418
- latestWorldUnitsPerPixel: d.worldUnitsPerPixel,
5418
+ latestViewport: l.documentRect,
5419
+ latestWorldUnitsPerPixel: l.worldUnitsPerPixel,
5419
5420
  latestHiddenSignature: wt(this.hiddenInstanceIds)
5420
5421
  })) {
5421
5422
  this.externalViewportQueued = !0, this.emitDemandProgress(!0);
5422
5423
  return;
5423
5424
  }
5424
- const l = a.filter((h) => !this.renderedRequiredVariantIds.has(h));
5425
- if (l.length === 0) {
5426
- this.lastCoverage = Oe(d.documentRect, d.worldUnitsPerPixel, e), this.emitDemandProgress(!0);
5425
+ const d = a.filter((h) => !this.renderedRequiredVariantIds.has(h));
5426
+ if (d.length === 0) {
5427
+ this.lastCoverage = Oe(l.documentRect, l.worldUnitsPerPixel, e), this.emitDemandProgress(!0);
5427
5428
  return;
5428
5429
  }
5429
5430
  const u = /* @__PURE__ */ new Map();
5430
- for (const h of l) {
5431
+ for (const h of d) {
5431
5432
  const y = this.loadedSidecarBuffers.get(h);
5432
5433
  if (!y)
5433
5434
  throw this.variantCoverage.set(h, "rejected"), new Error(`External block ${h} 尚未加载。`);
@@ -5440,13 +5441,13 @@ const Ze = class Ze {
5440
5441
  workerAdapter: this.workerAdapter ?? void 0,
5441
5442
  hiddenInstanceIds: this.hiddenInstanceIds,
5442
5443
  externalVariantBuffers: u,
5443
- requiredExternalVariantIds: l,
5444
+ requiredExternalVariantIds: d,
5444
5445
  beforeTextAppend: this.handleBeforeTextAppend
5445
5446
  }), !!this.isCurrent(r)) {
5446
- for (const h of l)
5447
+ for (const h of d)
5447
5448
  this.renderedRequiredVariantIds.add(h), this.variantCoverage.set(h, "loaded");
5448
- this.bumpContent("geometry"), this.lastCoverage = Oe(d.documentRect, d.worldUnitsPerPixel, e), this.emitDemandProgress(!0), l.some((h) => {
5449
- const y = this.variantManifest.find((p) => p.id === h);
5449
+ this.bumpContent("geometry"), this.lastCoverage = Oe(l.documentRect, l.worldUnitsPerPixel, e), this.emitDemandProgress(!0), d.some((h) => {
5450
+ const y = this.variantManifest.find((x) => x.id === h);
5450
5451
  return y ? Ct(y) : !1;
5451
5452
  }) && (this.blockAnnotationsLoaded = !1), this.maybeLoadVisibleAnnotations();
5452
5453
  }
@@ -5570,7 +5571,7 @@ const Ze = class Ze {
5570
5571
  return this.emitDemandProgress(!1), { requiredVariantIds: r.requiredVariantIds };
5571
5572
  }
5572
5573
  beginInitialExternalVariantLoad(n) {
5573
- !this.baseUrl || n.length === 0 || (this.replaceDemandAbort(), this.initialExternalLoading = !0, this.markLoadTiming("initialSidecarFetchStartedMs"), Xe({
5574
+ !this.baseUrl || n.length === 0 || (this.replaceDemandAbort(), this.initialExternalLoading = !0, this.initialFirstVariantAppendStarted = !1, this.markLoadTiming("initialSidecarFetchStartedMs"), Xe({
5574
5575
  baseUrl: this.baseUrl,
5575
5576
  entries: this.variantManifest,
5576
5577
  requiredVariantIds: n,
@@ -5593,49 +5594,56 @@ const Ze = class Ze {
5593
5594
  }));
5594
5595
  }
5595
5596
  scheduleInitialVariantAppend() {
5596
- !this.baseContentReady || this.initialExternalLoading || this.pendingInitialVariantIds.size === 0 || this.initialVariantAppendInFlight || this.initialVariantAppendTimer === null && (this.initialVariantAppendTimer = globalThis.setTimeout(() => {
5597
+ !this.baseContentReady || this.pendingInitialVariantIds.size === 0 || this.initialVariantAppendInFlight || this.initialFirstVariantAppendStarted && this.initialExternalLoading || this.initialVariantAppendTimer === null && (this.initialVariantAppendTimer = globalThis.setTimeout(() => {
5597
5598
  this.initialVariantAppendTimer = null, this.appendInitialVariantBatch();
5598
- }, bo));
5599
+ }, this.initialFirstVariantAppendStarted ? 0 : bo));
5599
5600
  }
5600
5601
  async appendInitialVariantBatch() {
5601
5602
  if (!this.baseContentReady || this.pendingInitialVariantIds.size === 0 || this.initialVariantAppendInFlight) return;
5602
- const n = Array.from(this.pendingInitialVariantIds).sort((r, i) => r - i);
5603
- n.forEach((r) => this.pendingInitialVariantIds.delete(r));
5604
- const e = /* @__PURE__ */ new Map();
5605
- for (const r of n) {
5606
- const i = this.loadedSidecarBuffers.get(r);
5607
- i && e.set(r, i);
5603
+ const n = !this.initialFirstVariantAppendStarted, e = Array.from(this.pendingInitialVariantIds).sort((i, s) => i - s);
5604
+ e.forEach((i) => this.pendingInitialVariantIds.delete(i));
5605
+ const r = /* @__PURE__ */ new Map();
5606
+ for (const i of e) {
5607
+ const s = this.loadedSidecarBuffers.get(i);
5608
+ s && r.set(i, s);
5608
5609
  }
5609
- if (e.size === 0) {
5610
+ if (r.size === 0) {
5610
5611
  this.scheduleInitialVariantAppend();
5611
5612
  return;
5612
5613
  }
5613
- this.initialVariantAppendInFlight = Et(this.node, this.mainBuffer, void 0, {
5614
+ this.initialFirstVariantAppendStarted = !0, this.initialVariantAppendInFlight = Et(this.node, this.mainBuffer, void 0, {
5614
5615
  signal: this.demandAbort.signal,
5615
5616
  workerUrl: this.workerUrl,
5616
5617
  workerFactory: this.workerFactory,
5617
5618
  workerAdapter: this.workerAdapter ?? void 0,
5618
5619
  hiddenInstanceIds: this.hiddenInstanceIds,
5619
- externalVariantBuffers: e,
5620
- requiredExternalVariantIds: n,
5620
+ externalVariantBuffers: r,
5621
+ requiredExternalVariantIds: e,
5621
5622
  beforeTextAppend: this.handleBeforeTextAppend
5622
5623
  }).then(() => {
5623
5624
  if (!this.isCurrent(this.sessionEpoch)) return;
5624
- for (const i of n)
5625
- this.renderedRequiredVariantIds.add(i), this.variantCoverage.set(i, "loaded");
5626
- this.initialRequiredVariantIds.size > 0 && Array.from(this.initialRequiredVariantIds).every((i) => this.renderedRequiredVariantIds.has(i)) && this.markLoadTiming("initialExternalContentReadyMs"), this.bumpContent("geometry");
5627
- const r = this.latestDemand ?? this.initialViewportDemand;
5628
- !this.initialExternalLoading && this.pendingInitialVariantIds.size === 0 && r && Array.from(this.initialRequiredVariantIds).every((i) => this.renderedRequiredVariantIds.has(i)) && (this.lastCoverage = Oe(
5629
- r.documentRect,
5630
- r.worldUnitsPerPixel,
5625
+ for (const s of e)
5626
+ this.renderedRequiredVariantIds.add(s), this.variantCoverage.set(s, "loaded");
5627
+ this.initialRequiredVariantIds.size > 0 && Array.from(this.initialRequiredVariantIds).every((s) => this.renderedRequiredVariantIds.has(s)) && this.markLoadTiming("initialExternalContentReadyMs"), this.bumpContent("geometry");
5628
+ const i = this.latestDemand ?? this.initialViewportDemand;
5629
+ !this.initialExternalLoading && this.pendingInitialVariantIds.size === 0 && i && Array.from(this.initialRequiredVariantIds).every((s) => this.renderedRequiredVariantIds.has(s)) && (this.lastCoverage = Oe(
5630
+ i.documentRect,
5631
+ i.worldUnitsPerPixel,
5631
5632
  wt(this.hiddenInstanceIds)
5632
5633
  )), this.emitDemandProgress(!this.initialExternalLoading && this.pendingInitialVariantIds.size === 0), this.maybeMarkInitialViewportSettled();
5633
- }).catch((r) => {
5634
- const i = ve(r);
5635
- if (i.name !== "AbortError") {
5636
- for (const s of n) this.variantCoverage.set(s, "rejected");
5637
- this.emit("non-fatal-error", { error: i }), this.emitDemandProgress(!this.initialExternalLoading && this.pendingInitialVariantIds.size === 0);
5634
+ }).catch((i) => {
5635
+ const s = ve(i);
5636
+ if (s.name === "AbortError") {
5637
+ if (this.isCurrent(this.sessionEpoch)) {
5638
+ this.replaceDemandAbort();
5639
+ for (const a of e)
5640
+ !this.renderedRequiredVariantIds.has(a) && this.loadedSidecarBuffers.has(a) && (this.pendingInitialVariantIds.add(a), this.variantCoverage.set(a, "cached"));
5641
+ n && (this.initialFirstVariantAppendStarted = !1), this.emitDemandProgress(!1);
5642
+ }
5643
+ return;
5638
5644
  }
5645
+ for (const a of e) this.variantCoverage.set(a, "rejected");
5646
+ this.emit("non-fatal-error", { error: s }), this.emitDemandProgress(!this.initialExternalLoading && this.pendingInitialVariantIds.size === 0);
5639
5647
  }).finally(() => {
5640
5648
  this.initialVariantAppendInFlight = null, this.scheduleInitialVariantAppend(), this.maybeMarkInitialViewportSettled(), this.externalViewportQueued && !this.initialExternalLoading && this.pendingInitialVariantIds.size === 0 && (this.externalViewportQueued = !1, this.maybeRefreshExternalSidecars());
5641
5649
  }), await this.initialVariantAppendInFlight;
@@ -5717,7 +5725,7 @@ const Ze = class Ze {
5717
5725
  this.annotationAbort.signal.aborted && (this.annotationAbort = new AbortController(), ue(this.sessionAbort.signal, this.annotationAbort));
5718
5726
  }
5719
5727
  abortAnnotations(n) {
5720
- this.clearAnnotationTimer(), this.annotationAbort.signal.aborted || this.annotationAbort.abort(K(n)), this.replaceAnnotationAbort();
5728
+ this.clearAnnotationTimer(), this.annotationAbort.signal.aborted || this.annotationAbort.abort(W(n)), this.replaceAnnotationAbort();
5721
5729
  }
5722
5730
  clearAnnotationTimer() {
5723
5731
  this.annotationTimer !== null && (globalThis.clearTimeout(this.annotationTimer), this.annotationTimer = null), this.annotationSeq += 1;
@@ -5742,26 +5750,27 @@ const Co = [
5742
5750
  "applyInsertTransform",
5743
5751
  "editBlock"
5744
5752
  ];
5745
- function qo(t) {
5753
+ function Ko(t) {
5746
5754
  return Co.includes(t);
5747
5755
  }
5748
5756
  export {
5749
5757
  Co as CAD_RENDER_NODE_EDIT_METHODS,
5750
- No as CAD_SESSION_PHASES,
5758
+ zo as CAD_SESSION_PHASES,
5751
5759
  la as GEO_NODE_STRUCTURE_CHANGE,
5752
5760
  Eo as GEO_NODE_VISUAL_CHANGE,
5753
5761
  U as GeoLoaderError,
5754
5762
  ye as GeoNode,
5755
5763
  So as appendExternalVariantDeltaToGeoNode,
5756
5764
  Oo as assertValidSourceOrThrow,
5757
- Go as cadInsertSelectionEquals,
5758
- Uo as cadTextSelectionEquals,
5759
- Ho as createCadDocumentSession,
5765
+ Uo as cadInsertSelectionEquals,
5766
+ No as cadTextSelectionEquals,
5767
+ Go as configureCadTextBuilder,
5768
+ qo as createCadDocumentSession,
5760
5769
  Vo as createLoadSession,
5761
5770
  Je as expandViewportRect,
5762
5771
  Ka as formatCadInsertId,
5763
- zo as getCadDocumentRenderResource,
5764
- qo as isCadRenderNodeEditMethod,
5772
+ Ho as getCadDocumentRenderResource,
5773
+ Ko as isCadRenderNodeEditMethod,
5765
5774
  Fo as loadExternalVariantDeltaFromBuffer,
5766
5775
  _o as loadGeo,
5767
5776
  fe as mergeViewportRects,
@@ -5772,7 +5781,7 @@ export {
5772
5781
  kr as parseCadInsertId,
5773
5782
  Ga as pickCadInsertAtPoint,
5774
5783
  Ha as pickCadTextAtPoint,
5775
- Xo as readBlockAnnotationSidecar,
5784
+ Yo as readBlockAnnotationSidecar,
5776
5785
  Mo as readBufferExternalAnnotationManifest,
5777
5786
  Do as readBufferExternalBlockAnnotations,
5778
5787
  Lo as readBufferExternalVariantDependencyPlan,