@nebula-spatial/cad-loader 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,149 +1,149 @@
1
- var ae = Object.defineProperty;
2
- var ie = (t, n, e) => n in t ? ae(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
- var mn = (t, n, e) => ie(t, typeof n != "symbol" ? n + "" : n, e);
4
- class l extends Error {
1
+ var xe = Object.defineProperty;
2
+ var ge = (t, n, e) => n in t ? xe(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var gn = (t, n, e) => ge(t, typeof n != "symbol" ? n + "" : n, e);
4
+ class u extends Error {
5
5
  constructor(e, o) {
6
6
  super(o);
7
- mn(this, "code");
7
+ gn(this, "code");
8
8
  this.name = "GeoLoaderError", this.code = e;
9
9
  }
10
10
  }
11
- const Lt = 4096;
12
- function To(t, n, e, o, a = "u8") {
11
+ const Yt = 4096;
12
+ function Oo(t, n, e, o, i = "u8") {
13
13
  return {
14
14
  count: o,
15
15
  raw: new Uint8Array(t, n, e - n).slice(),
16
- groupLayerEncoding: a
16
+ groupLayerEncoding: i
17
17
  };
18
18
  }
19
- function Wt(t) {
19
+ function Qt(t) {
20
20
  return t >= 6 ? "u16_lw" : t >= 5 ? "u8_lw" : t >= 4 ? "u16" : "u8";
21
21
  }
22
- function In(t) {
22
+ function bn(t) {
23
23
  return t === "u16_lw" ? 13 : t === "u8_lw" ? 12 : t === "u16" ? 9 : 8;
24
24
  }
25
- function Gn(t, n, e) {
25
+ function Bn(t, n, e) {
26
26
  return e === "u16" || e === "u16_lw" ? t.getUint16(n + 7, !0) : t.getUint8(n + 7);
27
27
  }
28
- function se(t) {
28
+ function he(t) {
29
29
  return t === "u16" || t === "u16_lw" ? 2 : 1;
30
30
  }
31
- function Vn(t, n, e) {
31
+ function Un(t, n, e) {
32
32
  if (!(e !== "u8_lw" && e !== "u16_lw"))
33
- return t.getFloat32(n + 7 + se(e), !0);
34
- }
35
- function lt(t, n, e, o, a = t.byteLength, r = "u8") {
36
- if (e > a || a > t.byteLength)
37
- throw new l("E_GROUP_RANGE", "Group byte range exceeds payload length");
38
- let i = e;
39
- const c = o * 2, s = c * 4;
40
- if (i + s > a)
41
- throw new l("E_GROUP_RANGE", "Group position bytes exceed payload length");
42
- let u;
43
- if (c > 0) {
44
- const w = new Uint8Array(t, i, s), y = new Uint8Array(s), m = c;
45
- for (let x = 0; x < c; x++)
46
- y[x * 4] = w[x], y[x * 4 + 1] = w[m + x], y[x * 4 + 2] = w[m * 2 + x], y[x * 4 + 3] = w[m * 3 + x];
47
- u = new Float32Array(y.buffer);
33
+ return t.getFloat32(n + 7 + he(e), !0);
34
+ }
35
+ function ft(t, n, e, o, i = t.byteLength, r = "u8") {
36
+ if (e > i || i > t.byteLength)
37
+ throw new u("E_GROUP_RANGE", "Group byte range exceeds payload length");
38
+ let s = e;
39
+ const l = o * 2, a = l * 4;
40
+ if (s + a > i)
41
+ throw new u("E_GROUP_RANGE", "Group position bytes exceed payload length");
42
+ let c;
43
+ if (l > 0) {
44
+ const A = new Uint8Array(t, s, a), y = new Uint8Array(a), x = l;
45
+ for (let h = 0; h < l; h++)
46
+ y[h * 4] = A[h], y[h * 4 + 1] = A[x + h], y[h * 4 + 2] = A[x * 2 + h], y[h * 4 + 3] = A[x * 3 + h];
47
+ c = new Float32Array(y.buffer);
48
48
  } else
49
- u = new Float32Array(0);
50
- if (i += s, i + 4 > a)
51
- throw new l("E_GROUP_RANGE", "Missing seg_count field for group");
52
- const h = n.getUint32(i, !0);
53
- i += 4;
54
- const d = [];
55
- let _ = 0;
56
- const f = In(r);
57
- for (let w = 0; w < h; w++) {
58
- if (i + f > a)
59
- throw new l("E_GROUP_RANGE", "Segment record exceeds payload length");
60
- const y = n.getUint32(i, !0), m = n.getUint8(i + 4), x = n.getUint8(i + 5), G = n.getUint8(i + 6), N = Gn(n, i, r), R = Vn(n, i, r);
61
- if (_ + y > o)
62
- throw new l("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
63
- d.push({
64
- startVertex: _,
49
+ c = new Float32Array(0);
50
+ if (s += a, s + 4 > i)
51
+ throw new u("E_GROUP_RANGE", "Missing seg_count field for group");
52
+ const _ = n.getUint32(s, !0);
53
+ s += 4;
54
+ const f = [];
55
+ let d = 0;
56
+ const m = bn(r);
57
+ for (let A = 0; A < _; A++) {
58
+ if (s + m > i)
59
+ throw new u("E_GROUP_RANGE", "Segment record exceeds payload length");
60
+ const y = n.getUint32(s, !0), x = n.getUint8(s + 4), h = n.getUint8(s + 5), R = n.getUint8(s + 6), w = Bn(n, s, r), p = Un(n, s, r);
61
+ if (d + y > o)
62
+ throw new u("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
63
+ f.push({
64
+ startVertex: d,
65
65
  vertexCount: y,
66
- color: [m, x, G],
67
- layerIndex: N,
68
- ...R === void 0 ? {} : { lineweightPx: R }
69
- }), i += f;
70
- const P = _ * 2;
66
+ color: [x, h, R],
67
+ layerIndex: w,
68
+ ...p === void 0 ? {} : { lineweightPx: p }
69
+ }), s += m;
70
+ const v = d * 2;
71
71
  if (y > 1) {
72
- let B = u[P], D = u[P + 1];
73
- for (let C = 1; C < y; C++) {
74
- const $ = P + C * 2;
75
- B += u[$], D += u[$ + 1], u[$] = B, u[$ + 1] = D;
72
+ let U = c[v], D = c[v + 1];
73
+ for (let $ = 1; $ < y; $++) {
74
+ const M = v + $ * 2;
75
+ U += c[M], D += c[M + 1], c[M] = U, c[M + 1] = D;
76
76
  }
77
77
  }
78
- _ += y;
78
+ d += y;
79
79
  }
80
- if (_ !== o)
81
- throw new l("E_SEGMENT_SUM", `Segment vertex_count sum ${_} does not match group count ${o}`);
80
+ if (d !== o)
81
+ throw new u("E_SEGMENT_SUM", `Segment vertex_count sum ${d} does not match group count ${o}`);
82
82
  return {
83
- chunk: { pos: u, count: o, segments: d },
84
- offset: i
83
+ chunk: { pos: c, count: o, segments: f },
84
+ offset: s
85
85
  };
86
86
  }
87
- function ce(t, n, e, o, a = "u8") {
88
- const r = o * 2, i = r * 4;
89
- if (e + i > t.byteLength)
90
- throw new l("E_GROUP_RANGE", "Group position bytes exceed payload length");
91
- const c = new Uint8Array(t, e, i);
92
- let s = e + i;
93
- if (s + 4 > t.byteLength)
94
- throw new l("E_GROUP_RANGE", "Missing seg_count field for group");
95
- const u = n.getUint32(s, !0);
96
- s += 4;
97
- const h = [];
98
- let d = 0;
99
- const _ = In(a);
100
- for (let f = 0; f < u; f++) {
101
- if (s + _ > t.byteLength)
102
- throw new l("E_GROUP_RANGE", "Segment record exceeds payload length");
103
- const w = n.getUint32(s, !0), y = n.getUint8(s + 4), m = n.getUint8(s + 5), x = n.getUint8(s + 6), G = Gn(n, s, a), N = Vn(n, s, a);
104
- if (s += _, d + w > o)
105
- throw new l("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
106
- h.push({
107
- startVertex: d,
108
- vertexCount: w,
109
- color: [y, m, x],
110
- layerIndex: G,
111
- ...N === void 0 ? {} : { lineweightPx: N }
112
- }), d += w;
87
+ function ye(t, n, e, o, i = "u8") {
88
+ const r = o * 2, s = r * 4;
89
+ if (e + s > t.byteLength)
90
+ throw new u("E_GROUP_RANGE", "Group position bytes exceed payload length");
91
+ const l = new Uint8Array(t, e, s);
92
+ let a = e + s;
93
+ if (a + 4 > t.byteLength)
94
+ throw new u("E_GROUP_RANGE", "Missing seg_count field for group");
95
+ const c = n.getUint32(a, !0);
96
+ a += 4;
97
+ const _ = [];
98
+ let f = 0;
99
+ const d = bn(i);
100
+ for (let m = 0; m < c; m++) {
101
+ if (a + d > t.byteLength)
102
+ throw new u("E_GROUP_RANGE", "Segment record exceeds payload length");
103
+ const A = n.getUint32(a, !0), y = n.getUint8(a + 4), x = n.getUint8(a + 5), h = n.getUint8(a + 6), R = Bn(n, a, i), w = Un(n, a, i);
104
+ if (a += d, f + A > o)
105
+ throw new u("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
106
+ _.push({
107
+ startVertex: f,
108
+ vertexCount: A,
109
+ color: [y, x, h],
110
+ layerIndex: R,
111
+ ...w === void 0 ? {} : { lineweightPx: w }
112
+ }), f += A;
113
113
  }
114
- if (d !== o)
115
- throw new l("E_SEGMENT_SUM", `Segment vertex_count sum ${d} does not match group count ${o}`);
114
+ if (f !== o)
115
+ throw new u("E_SEGMENT_SUM", `Segment vertex_count sum ${f} does not match group count ${o}`);
116
116
  return {
117
- shuffled: c,
117
+ shuffled: l,
118
118
  plane: r,
119
- segments: h,
120
- offset: s
119
+ segments: _,
120
+ offset: a
121
121
  };
122
122
  }
123
- function le(t, n, e, o) {
123
+ function we(t, n, e, o) {
124
124
  if (o === 0)
125
125
  return new Float32Array(0);
126
- const a = new Uint8Array(o * 4);
126
+ const i = new Uint8Array(o * 4);
127
127
  for (let r = 0; r < o; r++)
128
- a[r * 4] = t[e + r], a[r * 4 + 1] = t[n + e + r], a[r * 4 + 2] = t[n * 2 + e + r], a[r * 4 + 3] = t[n * 3 + e + r];
129
- return new Float32Array(a.buffer);
128
+ i[r * 4] = t[e + r], i[r * 4 + 1] = t[n + e + r], i[r * 4 + 2] = t[n * 2 + e + r], i[r * 4 + 3] = t[n * 3 + e + r];
129
+ return new Float32Array(i.buffer);
130
130
  }
131
- function ue(t, n, e, o, a) {
132
- const r = le(
131
+ function Ae(t, n, e, o, i) {
132
+ const r = we(
133
133
  t.shuffled,
134
134
  t.plane,
135
135
  (n.startVertex + e) * 2,
136
136
  o * 2
137
137
  );
138
- let i = (a == null ? void 0 : a[0]) ?? 0, c = (a == null ? void 0 : a[1]) ?? 0;
138
+ let s = (i == null ? void 0 : i[0]) ?? 0, l = (i == null ? void 0 : i[1]) ?? 0;
139
139
  if (o > 0) {
140
- e === 0 ? (i = r[0], c = r[1]) : (i += r[0], c += r[1], r[0] = i, r[1] = c);
141
- for (let u = 1; u < o; u++) {
142
- const h = u * 2;
143
- i += r[h], c += r[h + 1], r[h] = i, r[h + 1] = c;
140
+ e === 0 ? (s = r[0], l = r[1]) : (s += r[0], l += r[1], r[0] = s, r[1] = l);
141
+ for (let c = 1; c < o; c++) {
142
+ const _ = c * 2;
143
+ s += r[_], l += r[_ + 1], r[_] = s, r[_ + 1] = l;
144
144
  }
145
145
  }
146
- const s = o > 0 ? [{
146
+ const a = o > 0 ? [{
147
147
  startVertex: 0,
148
148
  vertexCount: o,
149
149
  color: [n.color[0], n.color[1], n.color[2]],
@@ -151,30 +151,30 @@ function ue(t, n, e, o, a) {
151
151
  ...n.lineweightPx === void 0 ? {} : { lineweightPx: n.lineweightPx }
152
152
  }] : [];
153
153
  return {
154
- chunk: { pos: r, count: o, segments: s },
155
- lastPoint: o > 0 ? [i, c] : a
154
+ chunk: { pos: r, count: o, segments: a },
155
+ lastPoint: o > 0 ? [s, l] : i
156
156
  };
157
157
  }
158
- function* de(t, n, e, o, a = "u8") {
159
- const r = ce(t, n, e, o, a);
158
+ function* Re(t, n, e, o, i = "u8") {
159
+ const r = ye(t, n, e, o, i);
160
160
  if (o === 0)
161
161
  return yield { pos: new Float32Array(0), count: 0, segments: [] }, r.offset;
162
- for (const i of r.segments) {
163
- let c = null;
164
- for (let s = 0; s < i.vertexCount; s += Lt) {
165
- const u = Math.min(Lt, i.vertexCount - s), h = ue(r, i, s, u, c);
166
- c = h.lastPoint, yield h.chunk;
162
+ for (const s of r.segments) {
163
+ let l = null;
164
+ for (let a = 0; a < s.vertexCount; a += Yt) {
165
+ const c = Math.min(Yt, s.vertexCount - a), _ = Ae(r, s, a, c, l);
166
+ l = _.lastPoint, yield _.chunk;
167
167
  }
168
168
  }
169
169
  return r.offset;
170
170
  }
171
- function Tn() {
171
+ function Sn() {
172
172
  const t = globalThis.TextDecoder;
173
173
  if (!t)
174
- throw new l("E_HEADER_JSON", "TextDecoder is required to parse CAD pack metadata");
174
+ throw new u("E_HEADER_JSON", "TextDecoder is required to parse CAD pack metadata");
175
175
  return new t();
176
176
  }
177
- function Yt(t) {
177
+ function Ft(t) {
178
178
  return t ? {
179
179
  minX: t.minX,
180
180
  minY: t.minY,
@@ -182,73 +182,73 @@ function Yt(t) {
182
182
  maxY: t.maxY
183
183
  } : null;
184
184
  }
185
- function Ft(t) {
185
+ function zt(t) {
186
186
  return !!t && Number.isFinite(t.minX) && Number.isFinite(t.minY) && Number.isFinite(t.maxX) && Number.isFinite(t.maxY);
187
187
  }
188
- function fe(t) {
189
- return Ft(t) ? Yt(t) : null;
188
+ function Ne(t) {
189
+ return zt(t) ? Ft(t) : null;
190
190
  }
191
- function me(t, n) {
192
- const e = Ft(t) ? t : null, o = Ft(n) ? n : null;
191
+ function pe(t, n) {
192
+ const e = zt(t) ? t : null, o = zt(n) ? n : null;
193
193
  return e ? o ? {
194
194
  minX: Math.min(e.minX, o.minX),
195
195
  minY: Math.min(e.minY, o.minY),
196
196
  maxX: Math.max(e.maxX, o.maxX),
197
197
  maxY: Math.max(e.maxY, o.maxY)
198
- } : Yt(e) : Yt(o);
198
+ } : Ft(e) : Ft(o);
199
199
  }
200
- function bn(t, n) {
200
+ function Cn(t, n) {
201
201
  return !(n.maxX < t.minX || n.minX > t.maxX || n.maxY < t.minY || n.minY > t.maxY);
202
202
  }
203
- function bo(t, n) {
203
+ function $o(t, n) {
204
204
  return t.minX <= n.minX && t.minY <= n.minY && t.maxX >= n.maxX && t.maxY >= n.maxY;
205
205
  }
206
- function Bo(t, n) {
206
+ function Mo(t, n) {
207
207
  return t === n ? !0 : !t || !n ? !1 : t.minX === n.minX && t.minY === n.minY && t.maxX === n.maxX && t.maxY === n.maxY;
208
208
  }
209
- function _e(t, n) {
210
- return bn(t, n) ? {
209
+ function Ie(t, n) {
210
+ return Cn(t, n) ? {
211
211
  minX: Math.max(t.minX, n.minX),
212
212
  minY: Math.max(t.minY, n.minY),
213
213
  maxX: Math.min(t.maxX, n.maxX),
214
214
  maxY: Math.min(t.maxY, n.maxY)
215
215
  } : null;
216
216
  }
217
- function he(t, n) {
218
- const e = Number.isFinite(n) ? Math.max(0, n) : 0, o = Math.max(0, t.maxX - t.minX), a = Math.max(0, t.maxY - t.minY), r = o * e, i = a * e;
217
+ function Ve(t, n) {
218
+ const e = Number.isFinite(n) ? Math.max(0, n) : 0, o = Math.max(0, t.maxX - t.minX), i = Math.max(0, t.maxY - t.minY), r = o * e, s = i * e;
219
219
  return {
220
220
  minX: t.minX - r,
221
- minY: t.minY - i,
221
+ minY: t.minY - s,
222
222
  maxX: t.maxX + r,
223
- maxY: t.maxY + i
223
+ maxY: t.maxY + s
224
224
  };
225
225
  }
226
- function Ee(t, n, e, o = 0, a = 1) {
226
+ function Ge(t, n, e, o = 0, i = 1) {
227
227
  if (n <= 0 || e <= 0) return null;
228
- let r = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, c = Number.NEGATIVE_INFINITY, s = Number.NEGATIVE_INFINITY, u = !1;
229
- for (let h = 0; h < n; h += 1) {
230
- const d = h * e, _ = t[d + o], f = t[d + a];
231
- !Number.isFinite(_) || !Number.isFinite(f) || (_ < r && (r = _), f < i && (i = f), _ > c && (c = _), f > s && (s = f), u = !0);
228
+ let r = Number.POSITIVE_INFINITY, s = Number.POSITIVE_INFINITY, l = Number.NEGATIVE_INFINITY, a = Number.NEGATIVE_INFINITY, c = !1;
229
+ for (let _ = 0; _ < n; _ += 1) {
230
+ const f = _ * e, d = t[f + o], m = t[f + i];
231
+ !Number.isFinite(d) || !Number.isFinite(m) || (d < r && (r = d), m < s && (s = m), d > l && (l = d), m > a && (a = m), c = !0);
232
232
  }
233
- return u ? { minX: r, minY: i, maxX: c, maxY: s } : null;
233
+ return c ? { minX: r, minY: s, maxX: l, maxY: a } : null;
234
234
  }
235
- function Bn(t, n) {
236
- const e = t.minX, o = t.minY, a = t.maxX, r = t.maxY, { matA: i, matB: c, matC: s, matD: u, tx: h, ty: d } = n;
237
- let _ = i * e + s * o + h, f = c * e + u * o + d, w = _, y = f, m = _, x = f;
238
- return _ = i * e + s * r + h, f = c * e + u * r + d, _ < w && (w = _), f < y && (y = f), _ > m && (m = _), f > x && (x = f), _ = i * a + s * o + h, f = c * a + u * o + d, _ < w && (w = _), f < y && (y = f), _ > m && (m = _), f > x && (x = f), _ = i * a + s * r + h, f = c * a + u * r + d, _ < w && (w = _), f < y && (y = f), _ > m && (m = _), f > x && (x = f), { minX: w, minY: y, maxX: m, maxY: x };
235
+ function On(t, n) {
236
+ const e = t.minX, o = t.minY, i = t.maxX, r = t.maxY, { matA: s, matB: l, matC: a, matD: c, tx: _, ty: f } = n;
237
+ let d = s * e + a * o + _, m = l * e + c * o + f, A = d, y = m, x = d, h = m;
238
+ return d = s * e + a * r + _, m = l * e + c * r + f, d < A && (A = d), m < y && (y = m), d > x && (x = d), m > h && (h = m), d = s * i + a * o + _, m = l * i + c * o + f, d < A && (A = d), m < y && (y = m), d > x && (x = d), m > h && (h = m), d = s * i + a * r + _, m = l * i + c * r + f, d < A && (A = d), m < y && (y = m), d > x && (x = d), m > h && (h = m), { minX: A, minY: y, maxX: x, maxY: h };
239
239
  }
240
- function xe(t) {
240
+ function Te(t) {
241
241
  return Math.hypot(t.maxX - t.minX, t.maxY - t.minY);
242
242
  }
243
- function ge(t, n) {
244
- const e = (t.minX + t.maxX) / 2, o = (t.minY + t.maxY) / 2, a = (n.minX + n.maxX) / 2, r = (n.minY + n.maxY) / 2;
245
- return Math.hypot(e - a, o - r);
243
+ function be(t, n) {
244
+ const e = (t.minX + t.maxX) / 2, o = (t.minY + t.maxY) / 2, i = (n.minX + n.maxX) / 2, r = (n.minY + n.maxY) / 2;
245
+ return Math.hypot(e - i, o - r);
246
246
  }
247
- const ye = {};
248
- function _n(t) {
247
+ const Be = {};
248
+ function hn(t) {
249
249
  return typeof t == "object" && t !== null;
250
250
  }
251
- function gt(t, n) {
251
+ function yt(t, n) {
252
252
  return Object.prototype.hasOwnProperty.call(t, n);
253
253
  }
254
254
  function J(t) {
@@ -263,10 +263,10 @@ function J(t) {
263
263
  }
264
264
  return n;
265
265
  }
266
- function hn(t, n, e, o) {
267
- return new l("E_TEXT_ROUNDTRIP", `Text roundtrip mismatch at stage=${t} index=${n} path=${e}: ${o}`);
266
+ function yn(t, n, e, o) {
267
+ return new u("E_TEXT_ROUNDTRIP", `Text roundtrip mismatch at stage=${t} index=${n} path=${e}: ${o}`);
268
268
  }
269
- function kt(t, n, e) {
269
+ function Ht(t, n, e) {
270
270
  if (Object.is(t, n)) return null;
271
271
  if (Array.isArray(t)) {
272
272
  if (!Array.isArray(n))
@@ -274,211 +274,211 @@ function kt(t, n, e) {
274
274
  if (t.length !== n.length)
275
275
  return { path: J([...e, "length"]), reason: `array length ${t.length} !== ${n.length}` };
276
276
  for (let o = 0; o < t.length; o += 1) {
277
- const a = kt(t[o], n[o], [...e, o]);
278
- if (a) return a;
277
+ const i = Ht(t[o], n[o], [...e, o]);
278
+ if (i) return i;
279
279
  }
280
280
  return null;
281
281
  }
282
- if (_n(t)) {
283
- if (!_n(n) || Array.isArray(n))
282
+ if (hn(t)) {
283
+ if (!hn(n) || Array.isArray(n))
284
284
  return { path: J(e), reason: `expected object but found ${Array.isArray(n) ? "array" : typeof n}` };
285
- const o = Object.keys(t), a = Object.keys(n);
286
- if (o.length !== a.length) {
287
- const r = o.find((c) => !gt(n, c));
285
+ const o = Object.keys(t), i = Object.keys(n);
286
+ if (o.length !== i.length) {
287
+ const r = o.find((l) => !yt(n, l));
288
288
  if (r !== void 0)
289
289
  return {
290
290
  path: J([...e, r]),
291
291
  reason: "missing key on actual"
292
292
  };
293
- const i = a.find((c) => !gt(t, c));
294
- if (i !== void 0)
293
+ const s = i.find((l) => !yt(t, l));
294
+ if (s !== void 0)
295
295
  return {
296
- path: J([...e, i]),
296
+ path: J([...e, s]),
297
297
  reason: "extra key on actual"
298
298
  };
299
299
  }
300
300
  for (const r of o) {
301
- if (!gt(n, r))
301
+ if (!yt(n, r))
302
302
  return { path: J([...e, r]), reason: "missing key on actual" };
303
- const i = kt(t[r], n[r], [...e, r]);
304
- if (i) return i;
303
+ const s = Ht(t[r], n[r], [...e, r]);
304
+ if (s) return s;
305
305
  }
306
- for (const r of a)
307
- if (!gt(t, r))
306
+ for (const r of i)
307
+ if (!yt(t, r))
308
308
  return { path: J([...e, r]), reason: "extra key on actual" };
309
309
  return null;
310
310
  }
311
311
  return { path: J(e), reason: `expected ${String(t)} but found ${String(n)}` };
312
312
  }
313
- function we(t, n) {
314
- return kt(t, n, []);
313
+ function Ue(t, n) {
314
+ return Ht(t, n, []);
315
315
  }
316
- function En(t) {
316
+ function wn(t) {
317
317
  if (t === !0 || t === "1" || t === "true") return !0;
318
318
  if (t === !1 || t === "0" || t === "false") return !1;
319
319
  }
320
- function Ae() {
321
- var a, r;
322
- const t = globalThis.process, n = En(
323
- ((a = t == null ? void 0 : t.env) == null ? void 0 : a.DXF_STRICT_TEXT_ROUNDTRIP) ?? ((r = t == null ? void 0 : t.env) == null ? void 0 : r.VITE_DXF_STRICT_TEXT_ROUNDTRIP)
320
+ function Se() {
321
+ var i, r;
322
+ const t = globalThis.process, n = wn(
323
+ ((i = t == null ? void 0 : t.env) == null ? void 0 : i.DXF_STRICT_TEXT_ROUNDTRIP) ?? ((r = t == null ? void 0 : t.env) == null ? void 0 : r.VITE_DXF_STRICT_TEXT_ROUNDTRIP)
324
324
  );
325
325
  if (n !== void 0) return n;
326
- const e = ye, o = En(e == null ? void 0 : e.VITE_DXF_STRICT_TEXT_ROUNDTRIP);
326
+ const e = Be, o = wn(e == null ? void 0 : e.VITE_DXF_STRICT_TEXT_ROUNDTRIP);
327
327
  return o !== void 0 ? o : !1;
328
328
  }
329
- function Uo(t) {
329
+ function vo(t) {
330
330
  return t;
331
331
  }
332
- function Ne(t, n, e) {
332
+ function Ce(t, n, e) {
333
333
  if (n.length !== e.length)
334
- throw hn(t, Math.min(n.length, e.length), "$length", `text count ${n.length} !== ${e.length}`);
334
+ throw yn(t, Math.min(n.length, e.length), "$length", `text count ${n.length} !== ${e.length}`);
335
335
  for (let o = 0; o < n.length; o += 1) {
336
- const a = we(n[o], e[o]);
337
- if (a)
338
- throw hn(t, o, a.path, a.reason);
336
+ const i = Ue(n[o], e[o]);
337
+ if (i)
338
+ throw yn(t, o, i.path, i.reason);
339
339
  }
340
340
  }
341
- const Re = Tn(), pe = ["left", "center", "right"], Ie = ["top", "middle", "bottom", "alphabetic"];
342
- function xn(t, n) {
341
+ const Oe = Sn(), $e = ["left", "center", "right"], Me = ["top", "middle", "bottom", "alphabetic"];
342
+ function An(t, n) {
343
343
  if (t > BigInt(Number.MAX_SAFE_INTEGER))
344
- throw new l("E_GROUP_RANGE", `${n} exceeds safe integer range`);
344
+ throw new u("E_GROUP_RANGE", `${n} exceeds safe integer range`);
345
345
  return Number(t);
346
346
  }
347
- function zt(t, n, e, o) {
347
+ function jt(t, n, e, o) {
348
348
  if (!Number.isInteger(t) || !Number.isInteger(n) || t < 0 || n < 0 || t + n > e)
349
- throw new l("E_GROUP_RANGE", `${o} exceeds payload length`);
349
+ throw new u("E_GROUP_RANGE", `${o} exceeds payload length`);
350
350
  }
351
- function Ge(t) {
351
+ function ve(t) {
352
352
  if (t.byteLength < 4) return !1;
353
353
  const n = new Uint8Array(t, 0, 4);
354
354
  return n[0] === 68 && n[1] === 88 && n[2] === 66 && n[3] === 83;
355
355
  }
356
- function Jt(t) {
356
+ function tn(t) {
357
357
  if (t.byteLength < 20)
358
- throw new l("E_HEADER", "DXBS payload too small: missing container header");
359
- if (!Ge(t))
360
- throw new l("E_HEADER", "DXBS payload missing magic");
361
- const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), a = n.getUint16(8, !0), r = n.getUint16(10, !0), i = n.getUint16(12, !0), c = n.getUint16(14, !0), s = n.getUint32(16, !0);
358
+ throw new u("E_HEADER", "DXBS payload too small: missing container header");
359
+ if (!ve(t))
360
+ throw new u("E_HEADER", "DXBS payload missing magic");
361
+ const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), i = n.getUint16(8, !0), r = n.getUint16(10, !0), s = n.getUint16(12, !0), l = n.getUint16(14, !0), a = n.getUint32(16, !0);
362
362
  if (e !== 3 || o < 3 || o > 6)
363
- throw new l("E_GROUP_RANGE", `Unsupported DXBS version: ${e}.${o}`);
364
- if (a !== 0)
365
- throw new l("E_GROUP_RANGE", `Unsupported DXBS sidecar kind: ${a}`);
366
- if (c !== 0)
367
- throw new l("E_GROUP_RANGE", `Invalid DXBS reserved field: ${c}`);
363
+ throw new u("E_GROUP_RANGE", `Unsupported DXBS version: ${e}.${o}`);
364
+ if (i !== 0)
365
+ throw new u("E_GROUP_RANGE", `Unsupported DXBS sidecar kind: ${i}`);
366
+ if (l !== 0)
367
+ throw new u("E_GROUP_RANGE", `Invalid DXBS reserved field: ${l}`);
368
368
  if (r < 24)
369
- throw new l("E_GROUP_RANGE", `Invalid DXBS directory entry size: ${r}`);
370
- if (s !== r * i)
371
- throw new l("E_GROUP_RANGE", "DXBS directory byte size mismatch");
372
- const u = 20;
373
- zt(u, s, t.byteLength, "DXBS section directory");
374
- const h = /* @__PURE__ */ new Map();
375
- for (let d = 0; d < i; d += 1) {
376
- const _ = u + d * r, f = n.getUint16(_, !0), w = n.getUint16(_ + 2, !0), y = n.getUint32(_ + 4, !0), m = xn(n.getBigUint64(_ + 8, !0), "DXBS section offset"), x = xn(n.getBigUint64(_ + 16, !0), "DXBS section length");
377
- if (w !== 0)
378
- throw new l("E_GROUP_RANGE", `Unsupported DXBS section flags for type ${f}: ${w}`);
369
+ throw new u("E_GROUP_RANGE", `Invalid DXBS directory entry size: ${r}`);
370
+ if (a !== r * s)
371
+ throw new u("E_GROUP_RANGE", "DXBS directory byte size mismatch");
372
+ const c = 20;
373
+ jt(c, a, t.byteLength, "DXBS section directory");
374
+ const _ = /* @__PURE__ */ new Map();
375
+ for (let f = 0; f < s; f += 1) {
376
+ const d = c + f * r, m = n.getUint16(d, !0), A = n.getUint16(d + 2, !0), y = n.getUint32(d + 4, !0), x = An(n.getBigUint64(d + 8, !0), "DXBS section offset"), h = An(n.getBigUint64(d + 16, !0), "DXBS section length");
377
+ if (A !== 0)
378
+ throw new u("E_GROUP_RANGE", `Unsupported DXBS section flags for type ${m}: ${A}`);
379
379
  if (y !== 0)
380
- throw new l("E_GROUP_RANGE", `Invalid DXBS section reserved field for type ${f}: ${y}`);
381
- zt(m, x, t.byteLength, `DXBS section ${f}`), h.set(f, { type: f, flags: w, offset: m, length: x });
380
+ throw new u("E_GROUP_RANGE", `Invalid DXBS section reserved field for type ${m}: ${y}`);
381
+ jt(x, h, t.byteLength, `DXBS section ${m}`), _.set(m, { type: m, flags: A, offset: x, length: h });
382
382
  }
383
- return { versionMajor: e, versionMinor: o, sections: h };
383
+ return { versionMajor: e, versionMinor: o, sections: _ };
384
384
  }
385
- function et(t, n, e) {
385
+ function ot(t, n, e) {
386
386
  const o = t.sections.get(n);
387
387
  if (!o)
388
- throw new l("E_GROUP_RANGE", `Missing DXBS section ${e}`);
388
+ throw new u("E_GROUP_RANGE", `Missing DXBS section ${e}`);
389
389
  return o;
390
390
  }
391
- function Ve(t, n, e, o) {
392
- return zt(n, e, t.byteLength, o), Re.decode(t.subarray(n, n + e));
391
+ function Pe(t, n, e, o) {
392
+ return jt(n, e, t.byteLength, o), Oe.decode(t.subarray(n, n + e));
393
393
  }
394
- function Ut(t, n, e, o, a, r) {
394
+ function Ct(t, n, e, o, i, r) {
395
395
  if (e + 4 > o)
396
- throw new l("E_GROUP_RANGE", `Missing ${a} vertex_count`);
397
- const i = n.getUint32(e, !0), c = lt(t, n, e + 4, i, o, r);
398
- if (c.offset > o)
399
- throw new l("E_GROUP_RANGE", `${a} exceeds section bounds`);
400
- return c;
401
- }
402
- function Un(t, n, e, o) {
403
- const a = new DataView(t), r = e.offset + e.length, i = Wt(n.versionMinor), c = Ut(t, a, e.offset, r, `${o} line`, i), s = Ut(t, a, c.offset, r, `${o} fill`, i), u = Ut(t, a, s.offset, r, `${o} dot`, i);
404
- if (u.offset !== r)
405
- throw new l("E_GROUP_RANGE", `${o} has trailing bytes`);
406
- return { line: c.chunk, fill: s.chunk, dot: u.chunk };
407
- }
408
- function Te(t, n, e) {
409
- const o = t.getUint32(n, !0), a = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), i = t.getUint8(n + 43), c = t.getFloat32(n + 24, !0), s = t.getFloat32(n + 28, !0);
396
+ throw new u("E_GROUP_RANGE", `Missing ${i} vertex_count`);
397
+ const s = n.getUint32(e, !0), l = ft(t, n, e + 4, s, o, r);
398
+ if (l.offset > o)
399
+ throw new u("E_GROUP_RANGE", `${i} exceeds section bounds`);
400
+ return l;
401
+ }
402
+ function $n(t, n, e, o) {
403
+ const i = new DataView(t), r = e.offset + e.length, s = Qt(n.versionMinor), l = Ct(t, i, e.offset, r, `${o} line`, s), a = Ct(t, i, l.offset, r, `${o} fill`, s), c = Ct(t, i, a.offset, r, `${o} dot`, s);
404
+ if (c.offset !== r)
405
+ throw new u("E_GROUP_RANGE", `${o} has trailing bytes`);
406
+ return { line: l.chunk, fill: a.chunk, dot: c.chunk };
407
+ }
408
+ function De(t, n, e) {
409
+ const o = t.getUint32(n, !0), i = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), s = t.getUint8(n + 43), l = t.getFloat32(n + 24, !0), a = t.getFloat32(n + 28, !0);
410
410
  return {
411
- t: Ve(e, o, a, "DXBS text value"),
411
+ t: Pe(e, o, i, "DXBS text value"),
412
412
  x: t.getFloat32(n + 8, !0),
413
413
  y: t.getFloat32(n + 12, !0),
414
414
  h: t.getFloat32(n + 16, !0),
415
415
  r: t.getFloat32(n + 20, !0),
416
416
  c: [t.getUint8(n + 36), t.getUint8(n + 37), t.getUint8(n + 38)],
417
417
  li: t.getUint16(n + 40, !0),
418
- ha: pe[r & 3] ?? "left",
419
- va: Ie[r >> 2 & 3] ?? "alphabetic",
418
+ ha: $e[r & 3] ?? "left",
419
+ va: Me[r >> 2 & 3] ?? "alphabetic",
420
420
  lh: t.getFloat32(n + 32, !0),
421
- ...c ? { w: c } : {},
422
- ...s !== 1 ? { wf: s } : {},
423
- ...i & 1 ? { mx: !0 } : {},
424
- ...i & 2 ? { my: !0 } : {}
421
+ ...l ? { w: l } : {},
422
+ ...a !== 1 ? { wf: a } : {},
423
+ ...s & 1 ? { mx: !0 } : {},
424
+ ...s & 2 ? { my: !0 } : {}
425
425
  };
426
426
  }
427
- function Sn(t, n, e, o) {
427
+ function Mn(t, n, e, o) {
428
428
  if (n.length % 44 !== 0)
429
- throw new l("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
430
- const a = new Uint8Array(t, e.offset, e.length), r = [], i = new DataView(t);
431
- for (let c = n.offset; c < n.offset + n.length; c += 44)
432
- r.push(Te(i, c, a));
429
+ throw new u("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
430
+ const i = new Uint8Array(t, e.offset, e.length), r = [], s = new DataView(t);
431
+ for (let l = n.offset; l < n.offset + n.length; l += 44)
432
+ r.push(De(s, l, i));
433
433
  return r;
434
434
  }
435
- function So(t) {
436
- const n = Jt(t), e = et(n, 513, "SCENE_ANNOTATION_GEOMETRY"), o = et(n, 514, "SCENE_ANNOTATION_TEXT_TABLE"), a = et(n, 515, "SCENE_ANNOTATION_STRING_TABLE");
435
+ function Po(t) {
436
+ const n = tn(t), e = ot(n, 513, "SCENE_ANNOTATION_GEOMETRY"), o = ot(n, 514, "SCENE_ANNOTATION_TEXT_TABLE"), i = ot(n, 515, "SCENE_ANNOTATION_STRING_TABLE");
437
437
  return {
438
- ...Un(t, n, e, "SCENE_ANNOTATION_GEOMETRY"),
439
- texts: Sn(t, o, a, "SCENE_ANNOTATION_TEXT_TABLE")
438
+ ...$n(t, n, e, "SCENE_ANNOTATION_GEOMETRY"),
439
+ texts: Mn(t, o, i, "SCENE_ANNOTATION_TEXT_TABLE")
440
440
  };
441
441
  }
442
- function be(t) {
443
- const n = Jt(t), e = et(n, 258, "BLOCK_ANNOTATION_GEOMETRY"), o = et(n, 259, "BLOCK_ANNOTATION_TEXT_TABLE"), a = et(n, 260, "BLOCK_ANNOTATION_STRING_TABLE");
442
+ function Xe(t) {
443
+ const n = tn(t), e = ot(n, 258, "BLOCK_ANNOTATION_GEOMETRY"), o = ot(n, 259, "BLOCK_ANNOTATION_TEXT_TABLE"), i = ot(n, 260, "BLOCK_ANNOTATION_STRING_TABLE");
444
444
  return {
445
- ...Un(t, n, e, "BLOCK_ANNOTATION_GEOMETRY"),
446
- texts: Sn(t, o, a, "BLOCK_ANNOTATION_TEXT_TABLE")
445
+ ...$n(t, n, e, "BLOCK_ANNOTATION_GEOMETRY"),
446
+ texts: Mn(t, o, i, "BLOCK_ANNOTATION_TEXT_TABLE")
447
447
  };
448
448
  }
449
- function It() {
449
+ function Vt() {
450
450
  return {
451
451
  pos: new Float32Array(0),
452
452
  count: 0,
453
453
  segments: []
454
454
  };
455
455
  }
456
- function ot(t) {
456
+ function rt(t) {
457
457
  if (t.segments && t.segments.length > 0)
458
- return Se(t.segments, t.count), t.segments;
458
+ return Ye(t.segments, t.count), t.segments;
459
459
  if (t.count <= 0) return [];
460
460
  if (!t.col || !t.lay)
461
- throw new l("E_GROUP_RANGE", "Geometry chunk is missing segment or expanded color/layer metadata");
462
- return Ue(t.col, t.lay, t.count);
461
+ throw new u("E_GROUP_RANGE", "Geometry chunk is missing segment or expanded color/layer metadata");
462
+ return ke(t.col, t.lay, t.count);
463
463
  }
464
- function Be(t) {
464
+ function Le(t) {
465
465
  if (t.col && t.lay)
466
466
  return { col: t.col, lay: t.lay };
467
- const n = ot(t), e = new Uint8Array(t.count * 3);
467
+ const n = rt(t), e = new Uint8Array(t.count * 3);
468
468
  let o = 0;
469
469
  for (const r of n)
470
470
  r.layerIndex > o && (o = r.layerIndex);
471
- const a = o > 255 ? new Uint16Array(t.count) : new Uint8Array(t.count);
471
+ const i = o > 255 ? new Uint16Array(t.count) : new Uint8Array(t.count);
472
472
  for (const r of n) {
473
- const i = r.startVertex + r.vertexCount;
474
- for (let c = r.startVertex; c < i; c += 1) {
475
- const s = c * 3;
476
- e[s] = r.color[0], e[s + 1] = r.color[1], e[s + 2] = r.color[2], a[c] = r.layerIndex;
473
+ const s = r.startVertex + r.vertexCount;
474
+ for (let l = r.startVertex; l < s; l += 1) {
475
+ const a = l * 3;
476
+ e[a] = r.color[0], e[a + 1] = r.color[1], e[a + 2] = r.color[2], i[l] = r.layerIndex;
477
477
  }
478
478
  }
479
- return { col: e, lay: a };
479
+ return { col: e, lay: i };
480
480
  }
481
- function Ht(t, n) {
481
+ function qt(t, n) {
482
482
  return t.map((e) => ({
483
483
  startVertex: e.startVertex + n,
484
484
  vertexCount: e.vertexCount,
@@ -487,7 +487,7 @@ function Ht(t, n) {
487
487
  ...e.lineweightPx === void 0 ? {} : { lineweightPx: e.lineweightPx }
488
488
  }));
489
489
  }
490
- function Cn(t, n) {
490
+ function vn(t, n) {
491
491
  return t.map((e) => ({
492
492
  startVertex: e.startVertex,
493
493
  vertexCount: e.vertexCount,
@@ -496,21 +496,21 @@ function Cn(t, n) {
496
496
  ...e.lineweightPx === void 0 ? {} : { lineweightPx: e.lineweightPx }
497
497
  }));
498
498
  }
499
- function Co(t, n, e) {
500
- const o = n + e, a = [];
499
+ function Do(t, n, e) {
500
+ const o = n + e, i = [];
501
501
  for (const r of t) {
502
- const i = r.startVertex, c = r.startVertex + r.vertexCount, s = Math.max(n, i), u = Math.min(o, c);
503
- s >= u || a.push({
504
- startVertex: s - n,
505
- vertexCount: u - s,
502
+ const s = r.startVertex, l = r.startVertex + r.vertexCount, a = Math.max(n, s), c = Math.min(o, l);
503
+ a >= c || i.push({
504
+ startVertex: a - n,
505
+ vertexCount: c - a,
506
506
  color: Gt(r),
507
507
  layerIndex: r.layerIndex,
508
508
  ...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx }
509
509
  });
510
510
  }
511
- return dt(a);
511
+ return mt(i);
512
512
  }
513
- function dt(t) {
513
+ function mt(t) {
514
514
  const n = [];
515
515
  for (const e of t) {
516
516
  const o = n[n.length - 1];
@@ -531,60 +531,60 @@ function dt(t) {
531
531
  }
532
532
  return n;
533
533
  }
534
- function Ue(t, n, e) {
534
+ function ke(t, n, e) {
535
535
  if (t.length < e * 3 || n.length < e)
536
- throw new l("E_GROUP_RANGE", "Expanded color/layer metadata is shorter than geometry count");
536
+ throw new u("E_GROUP_RANGE", "Expanded color/layer metadata is shorter than geometry count");
537
537
  const o = [];
538
- let a = 0;
539
- for (; a < e; ) {
540
- const r = a * 3, i = t[r] ?? 0, c = t[r + 1] ?? 0, s = t[r + 2] ?? 0, u = n[a] ?? 0;
541
- let h = a + 1;
542
- for (; h < e; ) {
543
- const d = h * 3;
544
- if (n[h] !== u || t[d] !== i || t[d + 1] !== c || t[d + 2] !== s)
538
+ let i = 0;
539
+ for (; i < e; ) {
540
+ const r = i * 3, s = t[r] ?? 0, l = t[r + 1] ?? 0, a = t[r + 2] ?? 0, c = n[i] ?? 0;
541
+ let _ = i + 1;
542
+ for (; _ < e; ) {
543
+ const f = _ * 3;
544
+ if (n[_] !== c || t[f] !== s || t[f + 1] !== l || t[f + 2] !== a)
545
545
  break;
546
- h += 1;
546
+ _ += 1;
547
547
  }
548
548
  o.push({
549
- startVertex: a,
550
- vertexCount: h - a,
551
- color: [i, c, s],
552
- layerIndex: u
553
- }), a = h;
549
+ startVertex: i,
550
+ vertexCount: _ - i,
551
+ color: [s, l, a],
552
+ layerIndex: c
553
+ }), i = _;
554
554
  }
555
555
  return o;
556
556
  }
557
- function Se(t, n) {
557
+ function Ye(t, n) {
558
558
  let e = 0;
559
559
  for (const o of t) {
560
560
  if (o.vertexCount < 0 || o.startVertex !== e)
561
- throw new l("E_SEGMENT_SUM", "Geometry segments must be contiguous and non-negative");
561
+ throw new u("E_SEGMENT_SUM", "Geometry segments must be contiguous and non-negative");
562
562
  e += o.vertexCount;
563
563
  }
564
564
  if (e !== n)
565
- throw new l("E_SEGMENT_SUM", `Geometry segment vertex sum ${e} does not match count ${n}`);
565
+ throw new u("E_SEGMENT_SUM", `Geometry segment vertex sum ${e} does not match count ${n}`);
566
566
  }
567
567
  function Gt(t) {
568
568
  return [t.color[0], t.color[1], t.color[2]];
569
569
  }
570
- const Ce = 8e6, Oe = 0.25, $e = 5, Me = 4, Pe = 2048, Zt = Tn(), De = ["left", "center", "right"], ve = ["top", "middle", "bottom", "alphabetic"];
571
- function At(t, n, e) {
570
+ const Fe = 8e6, ze = 0.25, He = 5, je = 4, qe = 2048, nn = Sn(), Ke = ["left", "center", "right"], We = ["top", "middle", "bottom", "alphabetic"];
571
+ function Rt(t, n, e) {
572
572
  for (const o of t)
573
573
  e(o);
574
574
  for (const o of n)
575
575
  e(o);
576
576
  }
577
- const gn = /* @__PURE__ */ new WeakMap();
578
- function ct(t) {
577
+ const Rn = /* @__PURE__ */ new WeakMap(), Pn = /* @__PURE__ */ new WeakSet();
578
+ function ut(t) {
579
579
  return typeof t == "object" && t !== null;
580
580
  }
581
- function Xe(t) {
581
+ function Je(t) {
582
582
  return Array.isArray(t) ? "array" : t === null ? "null" : typeof t;
583
583
  }
584
- function Le(t) {
585
- return !(!ct(t) || Array.isArray(t) || typeof t.t != "string" || typeof t.x != "number" || typeof t.y != "number" || typeof t.h != "number" || typeof t.r != "number" || !Array.isArray(t.c) || t.c.length !== 3 || !t.c.every((n) => typeof n == "number") || typeof t.li != "number" || t.ha !== "left" && t.ha !== "center" && t.ha !== "right" || t.va !== "top" && t.va !== "middle" && t.va !== "bottom" && t.va !== "alphabetic" || typeof t.lh != "number" || t.w !== void 0 && typeof t.w != "number" || t.wf !== void 0 && typeof t.wf != "number" || t.iv !== void 0 && typeof t.iv != "number" || t.io !== void 0 && typeof t.io != "number" || t.mx !== void 0 && t.mx !== !0 || t.my !== void 0 && t.my !== !0);
584
+ function Ze(t) {
585
+ return !(!ut(t) || Array.isArray(t) || typeof t.t != "string" || typeof t.x != "number" || typeof t.y != "number" || typeof t.h != "number" || typeof t.r != "number" || !Array.isArray(t.c) || t.c.length !== 3 || !t.c.every((n) => typeof n == "number") || typeof t.li != "number" || t.ha !== "left" && t.ha !== "center" && t.ha !== "right" || t.va !== "top" && t.va !== "middle" && t.va !== "bottom" && t.va !== "alphabetic" || typeof t.lh != "number" || t.w !== void 0 && typeof t.w != "number" || t.wf !== void 0 && typeof t.wf != "number" || t.iv !== void 0 && typeof t.iv != "number" || t.io !== void 0 && typeof t.io != "number" || t.mx !== void 0 && t.mx !== !0 || t.my !== void 0 && t.my !== !0);
586
586
  }
587
- function Ye(t) {
587
+ function Qe(t) {
588
588
  return t.map((n, e) => ({
589
589
  index: e,
590
590
  name: n.name,
@@ -593,26 +593,27 @@ function Ye(t) {
593
593
  visible: n.visible ?? !0
594
594
  }));
595
595
  }
596
- function Qt(t) {
597
- const n = t.texts, e = Array.isArray(n) ? n : [], o = e.filter(Le), a = Ae();
598
- if (a && n !== void 0 && !Array.isArray(n))
599
- throw new l(
596
+ function en(t) {
597
+ const n = t.texts, e = Array.isArray(n) ? n : [], o = e.filter(Ze), i = Se();
598
+ if (i && n !== void 0 && !Array.isArray(n))
599
+ throw new u(
600
600
  "E_TEXT_ROUNDTRIP",
601
- `Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${Xe(n)}`
601
+ `Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${Je(n)}`
602
602
  );
603
- return a && Ne("Boundary-2:header->stream", e, o), {
603
+ return i && Ce("Boundary-2:header->stream", e, o), {
604
604
  bounds: [...t.bounds],
605
605
  entityCount: Number(t.entity_count || 0),
606
606
  lineCount: Number(t.line_count || 0),
607
607
  fillCount: Number(t.fill_count || 0),
608
608
  dotCount: Number(t.dot_count || 0),
609
609
  textCount: o.length,
610
- layers: Ye(t.layers ?? []),
611
- texts: o
610
+ layers: Qe(t.layers ?? []),
611
+ texts: o,
612
+ units: t.units
612
613
  };
613
614
  }
614
- function On(t) {
615
- const n = t == null ? void 0 : t.maxExpandedInstanceVertices, e = typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.floor(n) : Ce;
615
+ function Dn(t) {
616
+ const n = t == null ? void 0 : t.maxExpandedInstanceVertices, e = typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.floor(n) : Fe;
616
617
  return {
617
618
  hiddenInstanceIds: t != null && t.hiddenInstanceIds ? new Set(t.hiddenInstanceIds) : /* @__PURE__ */ new Set(),
618
619
  keepTextsForHiddenInstances: (t == null ? void 0 : t.keepTextsForHiddenInstances) === !0,
@@ -623,281 +624,282 @@ function On(t) {
623
624
  externalVariantBuffers: t == null ? void 0 : t.externalVariantBuffers,
624
625
  requiredExternalVariantIds: t == null ? void 0 : t.requiredExternalVariantIds,
625
626
  externalVariantDeltaOnly: (t == null ? void 0 : t.externalVariantDeltaOnly) === !0,
626
- deferExternalVariantGeometry: (t == null ? void 0 : t.deferExternalVariantGeometry) === !0
627
+ deferExternalVariantGeometry: (t == null ? void 0 : t.deferExternalVariantGeometry) === !0,
628
+ cacheDocument: (t == null ? void 0 : t.cacheDocument) === !0
627
629
  };
628
630
  }
629
- function Fe(t) {
631
+ function to(t) {
630
632
  return t.loadBlocks && !t.suppressExpandedInsertGeometry;
631
633
  }
632
634
  function Nt(t, n) {
633
- return Fe(n) && !n.hiddenInstanceIds.has(t);
635
+ return to(n) && !n.hiddenInstanceIds.has(t);
634
636
  }
635
- function $n(t, n, e) {
637
+ function Xn(t, n, e) {
636
638
  if (e <= 0)
637
639
  return;
638
640
  const o = t.expandedInstanceVertices + e;
639
641
  if (o > t.maxExpandedInstanceVertices)
640
- throw new l(
642
+ throw new u(
641
643
  "E_EXPANSION_BUDGET",
642
644
  `CPU-expanded ${n} instance vertices exceed budget: ${o}/${t.maxExpandedInstanceVertices}. Disable block loading or raise maxExpandedInstanceVertices.`
643
645
  );
644
646
  t.expandedInstanceVertices = o;
645
647
  }
646
- function ke(t, n, e) {
648
+ function no(t, n, e) {
647
649
  return e.loadBlocks ? e.hiddenInstanceIds.size === 0 || e.keepTextsForHiddenInstances ? t : t.filter((o) => {
648
650
  if (!Number.isInteger(o.iv) || !Number.isInteger(o.io))
649
651
  return !0;
650
- const a = n.get(`${o.iv}:${o.io}`);
651
- return a === void 0 || !e.hiddenInstanceIds.has(a);
652
+ const i = n.get(`${o.iv}:${o.io}`);
653
+ return i === void 0 || !e.hiddenInstanceIds.has(i);
652
654
  }) : t.filter((o) => !Number.isInteger(o.iv) || !Number.isInteger(o.io));
653
655
  }
654
- function ze(t, n) {
656
+ function eo(t, n) {
655
657
  const e = /* @__PURE__ */ new Map();
656
- return t.forEach((o, a) => {
658
+ return t.forEach((o, i) => {
657
659
  if (!Number.isInteger(o.iv) || !Number.isInteger(o.io))
658
660
  return;
659
661
  const r = n.get(`${o.iv}:${o.io}`);
660
662
  if (r === void 0)
661
663
  return;
662
- const i = e.get(r);
663
- i ? i.push(a) : e.set(r, [a]);
664
+ const s = e.get(r);
665
+ s ? s.push(i) : e.set(r, [i]);
664
666
  }), e;
665
667
  }
666
- function He(t, n, e, o, a, r, i) {
667
- const c = n.map((s, u) => ({
668
- id: s.id,
669
- blockName: Mn(s, u),
670
- line: e[u].line,
671
- fill: e[u].fill,
672
- dot: e[u].dot,
673
- texts: o.get(s.id) ?? []
668
+ function oo(t, n, e, o, i, r, s) {
669
+ const l = n.map((a, c) => ({
670
+ id: a.id,
671
+ blockName: Ln(a, c),
672
+ line: e[c].line,
673
+ fill: e[c].fill,
674
+ dot: e[c].dot,
675
+ texts: o.get(a.id) ?? []
674
676
  }));
675
677
  return {
676
678
  layer0Index: t,
677
- variants: c,
678
- instances: a,
679
- textIndexesByInstanceId: ze(r, i),
680
- ownerInstanceIdByVariantOrdinal: i
679
+ variants: l,
680
+ instances: i,
681
+ textIndexesByInstanceId: eo(r, s),
682
+ ownerInstanceIdByVariantOrdinal: s
681
683
  };
682
684
  }
683
- function je(t) {
685
+ function ro(t) {
684
686
  if (t.byteLength < 4)
685
- throw new l("E_HEADER", "Payload too small: missing header length");
686
- const n = new DataView(t), e = n.getUint32(0, !0), o = 4, a = o + e;
687
- if (a > t.byteLength)
688
- throw new l("E_HEADER", "Header length exceeds payload length");
687
+ throw new u("E_HEADER", "Payload too small: missing header length");
688
+ const n = new DataView(t), e = n.getUint32(0, !0), o = 4, i = o + e;
689
+ if (i > t.byteLength)
690
+ throw new u("E_HEADER", "Header length exceeds payload length");
689
691
  let r;
690
692
  try {
691
- r = JSON.parse(Zt.decode(new Uint8Array(t, o, e)));
692
- } catch (i) {
693
- throw new l("E_HEADER_JSON", `Invalid JSON header: ${i.message}`);
693
+ r = JSON.parse(nn.decode(new Uint8Array(t, o, e)));
694
+ } catch (s) {
695
+ throw new u("E_HEADER_JSON", `Invalid JSON header: ${s.message}`);
694
696
  }
695
697
  return {
696
698
  meta: r,
697
- header: Qt(r),
698
- dataOffset: a,
699
+ header: en(r),
700
+ dataOffset: i,
699
701
  view: n
700
702
  };
701
703
  }
702
- function Mn(t, n) {
703
- var r, i, c;
704
+ function Ln(t, n) {
705
+ var r, s, l;
704
706
  const e = (r = t.name) == null ? void 0 : r.trim();
705
707
  if (e)
706
708
  return e;
707
- const o = (i = t.block_name) == null ? void 0 : i.trim();
709
+ const o = (s = t.block_name) == null ? void 0 : s.trim();
708
710
  if (o)
709
711
  return o;
710
- const a = (c = t.blockName) == null ? void 0 : c.trim();
711
- return a || `block_${n}`;
712
+ const i = (l = t.blockName) == null ? void 0 : l.trim();
713
+ return i || `block_${n}`;
712
714
  }
713
- function qe(t) {
715
+ function io(t) {
714
716
  const n = Number(t.version ?? 1), e = String(t.encoding ?? "").toLowerCase();
715
717
  if (n === 2) {
716
718
  const o = e ? ` ${e}` : "";
717
- throw new l(
719
+ throw new u(
718
720
  "E_UNSUPPORTED_PACK_VERSION",
719
721
  `当前文件是 V2${o} pack,前端不再兼容解析;请升级到最新版本后再打开。`
720
722
  );
721
723
  }
722
724
  }
723
- function tn(t) {
724
- const n = je(t);
725
- return qe(n.meta), n;
725
+ function on(t) {
726
+ const n = ro(t);
727
+ return io(n.meta), n;
726
728
  }
727
- function rt(t) {
729
+ function Q(t) {
728
730
  if (t.byteLength < 4)
729
731
  return !1;
730
732
  const n = new Uint8Array(t, 0, 4);
731
733
  return n[0] === 68 && n[1] === 88 && n[2] === 66 && n[3] === 51;
732
734
  }
733
- function yn(t, n) {
735
+ function Nn(t, n) {
734
736
  if (t > BigInt(Number.MAX_SAFE_INTEGER))
735
- throw new l("E_GROUP_RANGE", `${n} exceeds safe integer range`);
737
+ throw new u("E_GROUP_RANGE", `${n} exceeds safe integer range`);
736
738
  return Number(t);
737
739
  }
738
- function ft(t, n, e, o) {
740
+ function _t(t, n, e, o) {
739
741
  if (!Number.isInteger(t) || !Number.isInteger(n) || t < 0 || n < 0 || t + n > e)
740
- throw new l("E_GROUP_RANGE", `${o} exceeds payload length`);
742
+ throw new u("E_GROUP_RANGE", `${o} exceeds payload length`);
741
743
  }
742
- function mt(t) {
744
+ function Et(t) {
743
745
  if (t.byteLength < 20)
744
- throw new l("E_HEADER", "V3 payload too small: missing container header");
745
- const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), a = n.getUint32(8, !0), r = n.getUint16(12, !0), i = n.getUint16(14, !0), c = n.getUint32(16, !0);
746
+ throw new u("E_HEADER", "V3 payload too small: missing container header");
747
+ const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), i = n.getUint32(8, !0), r = n.getUint16(12, !0), s = n.getUint16(14, !0), l = n.getUint32(16, !0);
746
748
  if (e !== 3 || o > 6)
747
- throw new l("E_GROUP_RANGE", `Unsupported V3 version: ${e}.${o}`);
748
- if (a !== 0)
749
- throw new l("E_GROUP_RANGE", `Unsupported V3 file flags: ${a}`);
749
+ throw new u("E_GROUP_RANGE", `Unsupported V3 version: ${e}.${o}`);
750
+ if (i !== 0)
751
+ throw new u("E_GROUP_RANGE", `Unsupported V3 file flags: ${i}`);
750
752
  if (r < 24)
751
- throw new l("E_GROUP_RANGE", `Invalid V3 directory entry size: ${r}`);
752
- if (c !== r * i)
753
- throw new l("E_GROUP_RANGE", "V3 directory byte size mismatch");
754
- const s = 20;
755
- ft(s, c, t.byteLength, "V3 section directory");
756
- const u = /* @__PURE__ */ new Map();
757
- for (let h = 0; h < i; h += 1) {
758
- const d = s + h * r, _ = n.getUint16(d, !0), f = n.getUint16(d + 2, !0), w = n.getUint32(d + 4, !0), y = yn(n.getBigUint64(d + 8, !0), "V3 section offset"), m = yn(n.getBigUint64(d + 16, !0), "V3 section length");
759
- if (f !== 0)
760
- throw new l("E_GROUP_RANGE", `Unsupported V3 section flags for type ${_}: ${f}`);
761
- if (w !== 0)
762
- throw new l("E_GROUP_RANGE", `Invalid V3 section reserved field for type ${_}: ${w}`);
763
- ft(y, m, t.byteLength, `V3 section ${_}`), u.set(_, { type: _, flags: f, offset: y, length: m });
753
+ throw new u("E_GROUP_RANGE", `Invalid V3 directory entry size: ${r}`);
754
+ if (l !== r * s)
755
+ throw new u("E_GROUP_RANGE", "V3 directory byte size mismatch");
756
+ const a = 20;
757
+ _t(a, l, t.byteLength, "V3 section directory");
758
+ const c = /* @__PURE__ */ new Map();
759
+ for (let _ = 0; _ < s; _ += 1) {
760
+ const f = a + _ * r, d = n.getUint16(f, !0), m = n.getUint16(f + 2, !0), A = n.getUint32(f + 4, !0), y = Nn(n.getBigUint64(f + 8, !0), "V3 section offset"), x = Nn(n.getBigUint64(f + 16, !0), "V3 section length");
761
+ if (m !== 0)
762
+ throw new u("E_GROUP_RANGE", `Unsupported V3 section flags for type ${d}: ${m}`);
763
+ if (A !== 0)
764
+ throw new u("E_GROUP_RANGE", `Invalid V3 section reserved field for type ${d}: ${A}`);
765
+ _t(y, x, t.byteLength, `V3 section ${d}`), c.set(d, { type: d, flags: m, offset: y, length: x });
764
766
  }
765
- return { versionMinor: o, sections: u };
767
+ return { versionMinor: o, sections: c };
766
768
  }
767
- function X(t, n, e) {
769
+ function P(t, n, e) {
768
770
  const o = t.get(n);
769
771
  if (!o)
770
- throw new l("E_GROUP_RANGE", `Missing V3 section ${e}`);
772
+ throw new u("E_GROUP_RANGE", `Missing V3 section ${e}`);
771
773
  return o;
772
774
  }
773
- function ut(t, n) {
775
+ function dt(t, n) {
774
776
  return t.get(n) ?? { type: n, flags: 0, offset: 0, length: 0 };
775
777
  }
776
- function _t(t, n, e) {
778
+ function xt(t, n, e) {
777
779
  try {
778
- return JSON.parse(Zt.decode(new Uint8Array(t, n.offset, n.length)));
780
+ return JSON.parse(nn.decode(new Uint8Array(t, n.offset, n.length)));
779
781
  } catch (o) {
780
- throw new l("E_HEADER_JSON", `Invalid V3 ${e} JSON: ${o.message}`);
782
+ throw new u("E_HEADER_JSON", `Invalid V3 ${e} JSON: ${o.message}`);
781
783
  }
782
784
  }
783
- function nn(t) {
785
+ function rn(t) {
784
786
  const n = String(t.encoding ?? "").toLowerCase();
785
787
  return n === "nested_instanced_external" || n === "nested_instanced_external_annotations";
786
788
  }
787
- function en(t) {
789
+ function sn(t) {
788
790
  return String(t.encoding ?? "").toLowerCase() === "nested_instanced_external_annotations";
789
791
  }
790
- function Ke(t, n, e) {
791
- const o = t.features, a = o && typeof o == "object" && !Array.isArray(o) ? { ...o } : {};
792
- return n && (a.has_external_variant_geometry = !0), e && (a.has_external_annotations = !0), Object.keys(a).length ? a : void 0;
792
+ function so(t, n, e) {
793
+ const o = t.features, i = o && typeof o == "object" && !Array.isArray(o) ? { ...o } : {};
794
+ return n && (i.has_external_variant_geometry = !0), e && (i.has_external_annotations = !0), Object.keys(i).length ? i : void 0;
793
795
  }
794
- function q(t, n) {
796
+ function K(t, n) {
795
797
  if (!Number.isInteger(t) || Number(t) < 0)
796
- throw new l("E_HEADER", `${n} must be a non-negative integer`);
798
+ throw new u("E_HEADER", `${n} must be a non-negative integer`);
797
799
  return Number(t);
798
800
  }
799
- function Pn(t, n) {
801
+ function kn(t, n) {
800
802
  if (typeof t != "string" || !t.trim())
801
- throw new l("E_HEADER", `${n} must be a non-empty string`);
803
+ throw new u("E_HEADER", `${n} must be a non-empty string`);
802
804
  return t;
803
805
  }
804
- function wn(t, n) {
806
+ function pn(t, n) {
805
807
  if (t == null)
806
808
  return null;
807
809
  if (!Array.isArray(t) || t.length !== 4 || t.some((e) => typeof e != "number" || !Number.isFinite(e)))
808
- throw new l("E_HEADER", `${n} must be null or [minX, minY, maxX, maxY]`);
810
+ throw new u("E_HEADER", `${n} must be null or [minX, minY, maxX, maxY]`);
809
811
  return [t[0], t[1], t[2], t[3]];
810
812
  }
811
- function jt(t, n) {
812
- if (!ct(t) || Array.isArray(t))
813
- throw new l("E_HEADER", `${n} must be an object`);
813
+ function Kt(t, n) {
814
+ if (!ut(t) || Array.isArray(t))
815
+ throw new u("E_HEADER", `${n} must be an object`);
814
816
  return {
815
- line_count: q(t.line_count, `${n}.line_count`),
816
- fill_count: q(t.fill_count, `${n}.fill_count`),
817
- dot_count: q(t.dot_count, `${n}.dot_count`),
818
- bbox: wn(t.bbox, `${n}.bbox`),
819
- own_bbox: wn(t.own_bbox, `${n}.own_bbox`)
817
+ line_count: K(t.line_count, `${n}.line_count`),
818
+ fill_count: K(t.fill_count, `${n}.fill_count`),
819
+ dot_count: K(t.dot_count, `${n}.dot_count`),
820
+ bbox: pn(t.bbox, `${n}.bbox`),
821
+ own_bbox: pn(t.own_bbox, `${n}.own_bbox`)
820
822
  };
821
823
  }
822
- function We(t) {
824
+ function ao(t) {
823
825
  return t ? { minX: t[0], minY: t[1], maxX: t[2], maxY: t[3] } : null;
824
826
  }
825
- function Vt(t, n) {
827
+ function Tt(t, n) {
826
828
  const e = t.external_variants;
827
829
  if (!Array.isArray(e))
828
- throw new l("E_HEADER", "V3 external SCENE_META.external_variants must be an array");
830
+ throw new u("E_HEADER", "V3 external SCENE_META.external_variants must be an array");
829
831
  if (e.length !== n)
830
- throw new l(
832
+ throw new u(
831
833
  "E_GROUP_RANGE",
832
834
  `V3 external variant manifest count mismatch: manifest=${e.length}, table=${n}`
833
835
  );
834
- return e.map((o, a) => {
835
- if (!ct(o) || Array.isArray(o))
836
- throw new l("E_HEADER", `V3 external_variants[${a}] must be an object`);
837
- const r = q(o.id, `V3 external_variants[${a}].id`);
838
- if (r !== a)
839
- throw new l("E_GROUP_RANGE", `V3 external_variants[${a}].id must equal ${a}, found ${r}`);
840
- const i = Pn(o.href, `V3 external_variants[${a}].href`), c = q(o.raw_size, `V3 external_variants[${a}].raw_size`);
836
+ return e.map((o, i) => {
837
+ if (!ut(o) || Array.isArray(o))
838
+ throw new u("E_HEADER", `V3 external_variants[${i}] must be an object`);
839
+ const r = K(o.id, `V3 external_variants[${i}].id`);
840
+ if (r !== i)
841
+ throw new u("E_GROUP_RANGE", `V3 external_variants[${i}].id must equal ${i}, found ${r}`);
842
+ const s = kn(o.href, `V3 external_variants[${i}].href`), l = K(o.raw_size, `V3 external_variants[${i}].raw_size`);
841
843
  if ("normal" in o || "annotation" in o) {
842
- const s = jt(o.annotation, `V3 external_variants[${a}].annotation`);
844
+ const a = Kt(o.annotation, `V3 external_variants[${i}].annotation`);
843
845
  return {
844
846
  id: r,
845
- href: i,
846
- raw_size: c,
847
- normal: jt(o.normal, `V3 external_variants[${a}].normal`),
847
+ href: s,
848
+ raw_size: l,
849
+ normal: Kt(o.normal, `V3 external_variants[${i}].normal`),
848
850
  annotation: {
849
- ...s,
850
- text_count: q(
851
- ct(o.annotation) && !Array.isArray(o.annotation) ? o.annotation.text_count : void 0,
852
- `V3 external_variants[${a}].annotation.text_count`
851
+ ...a,
852
+ text_count: K(
853
+ ut(o.annotation) && !Array.isArray(o.annotation) ? o.annotation.text_count : void 0,
854
+ `V3 external_variants[${i}].annotation.text_count`
853
855
  )
854
856
  }
855
857
  };
856
858
  }
857
859
  return {
858
860
  id: r,
859
- href: i,
860
- raw_size: c,
861
- line_count: q(o.line_count, `V3 external_variants[${a}].line_count`),
862
- fill_count: q(o.fill_count, `V3 external_variants[${a}].fill_count`),
863
- dot_count: q(o.dot_count, `V3 external_variants[${a}].dot_count`)
861
+ href: s,
862
+ raw_size: l,
863
+ line_count: K(o.line_count, `V3 external_variants[${i}].line_count`),
864
+ fill_count: K(o.fill_count, `V3 external_variants[${i}].fill_count`),
865
+ dot_count: K(o.dot_count, `V3 external_variants[${i}].dot_count`)
864
866
  };
865
867
  });
866
868
  }
867
- function Dn(t) {
869
+ function Yn(t) {
868
870
  const n = t.external_annotations;
869
871
  if (n == null) return null;
870
- if (!ct(n) || Array.isArray(n))
871
- throw new l("E_HEADER", "V3 external_annotations must be an object");
872
+ if (!ut(n) || Array.isArray(n))
873
+ throw new u("E_HEADER", "V3 external_annotations must be an object");
872
874
  const e = n.scene;
873
875
  if (e == null) return {};
874
- if (!ct(e) || Array.isArray(e))
875
- throw new l("E_HEADER", "V3 external_annotations.scene must be an object");
876
- const o = jt(e, "V3 external_annotations.scene");
876
+ if (!ut(e) || Array.isArray(e))
877
+ throw new u("E_HEADER", "V3 external_annotations.scene must be an object");
878
+ const o = Kt(e, "V3 external_annotations.scene");
877
879
  return {
878
880
  scene: {
879
- href: Pn(e.href, "V3 external_annotations.scene.href"),
880
- raw_size: q(e.raw_size, "V3 external_annotations.scene.raw_size"),
881
+ href: kn(e.href, "V3 external_annotations.scene.href"),
882
+ raw_size: K(e.raw_size, "V3 external_annotations.scene.raw_size"),
881
883
  ...o,
882
- text_count: q(e.text_count, "V3 external_annotations.scene.text_count")
884
+ text_count: K(e.text_count, "V3 external_annotations.scene.text_count")
883
885
  }
884
886
  };
885
887
  }
886
- function vn(t) {
887
- const { sections: n } = mt(t), e = X(n, 1, "SCENE_META");
888
- return _t(t, e, "SCENE_META");
888
+ function Fn(t) {
889
+ const { sections: n } = Et(t), e = P(n, 1, "SCENE_META");
890
+ return xt(t, e, "SCENE_META");
889
891
  }
890
- function Oo(t) {
891
- if (!rt(t))
892
+ function Xo(t) {
893
+ if (!Q(t))
892
894
  return [];
893
- const { sections: n } = mt(t), e = X(n, 1, "SCENE_META"), o = X(n, 5, "VARIANT_TABLE"), a = _t(t, e, "SCENE_META");
894
- if (!nn(a))
895
+ const { sections: n } = Et(t), e = P(n, 1, "SCENE_META"), o = P(n, 5, "VARIANT_TABLE"), i = xt(t, e, "SCENE_META");
896
+ if (!rn(i))
895
897
  return [];
896
898
  if (o.length % 60 !== 0)
897
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
898
- return Vt(a, o.length / 60);
899
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
900
+ return Tt(i, o.length / 60);
899
901
  }
900
- function An() {
902
+ function In() {
901
903
  return {
902
904
  manifest: [],
903
905
  requiredVariantIds: [],
@@ -906,288 +908,288 @@ function An() {
906
908
  skippedVariantIds: []
907
909
  };
908
910
  }
909
- function Je(t, n) {
910
- return he(t, n);
911
+ function lo(t, n) {
912
+ return Ve(t, n);
911
913
  }
912
- function qt(t, n) {
913
- return bn(t, n);
914
+ function Wt(t, n) {
915
+ return Cn(t, n);
914
916
  }
915
- function Ze(t, n) {
916
- return _e(t, n);
917
+ function uo(t, n) {
918
+ return Ie(t, n);
917
919
  }
918
- function Qe(t, n, e, o) {
920
+ function co(t, n, e, o) {
919
921
  if (!n || e === void 0 || !Number.isFinite(e) || e <= 0 || !Number.isFinite(o) || o <= 0) return !1;
920
- const a = Ze(n, t);
921
- if (!a) return !0;
922
- const r = Math.max(0, a.maxX - a.minX) / e, i = Math.max(0, a.maxY - a.minY) / e;
923
- return r < o && i < o;
922
+ const i = uo(n, t);
923
+ if (!i) return !0;
924
+ const r = Math.max(0, i.maxX - i.minX) / e, s = Math.max(0, i.maxY - i.minY) / e;
925
+ return r < o && s < o;
924
926
  }
925
- function Xn(t) {
926
- const n = Math.min(t.minX, t.maxX), e = Math.max(t.minX, t.maxX), o = Math.min(t.minY, t.maxY), a = Math.max(t.minY, t.maxY);
927
- return [n, e, o, a].every(Number.isFinite) ? { minX: n, minY: o, maxX: e, maxY: a } : null;
927
+ function zn(t) {
928
+ const n = Math.min(t.minX, t.maxX), e = Math.max(t.minX, t.maxX), o = Math.min(t.minY, t.maxY), i = Math.max(t.minY, t.maxY);
929
+ return [n, e, o, i].every(Number.isFinite) ? { minX: n, minY: o, maxX: e, maxY: i } : null;
928
930
  }
929
- function to(t) {
931
+ function fo(t) {
930
932
  return Math.max(1, Math.abs(t.maxX - t.minX), Math.abs(t.maxY - t.minY));
931
933
  }
932
- function Ln(t, n) {
934
+ function Hn(t, n) {
933
935
  return `${t}:${n}`;
934
936
  }
935
- function no(t) {
936
- const n = t.map((o) => o.worldBBox && !o.unknownBBox ? to(o.worldBBox) : 0).filter((o) => Number.isFinite(o) && o > 0).sort((o, a) => o - a), e = n.length > 0 ? n[Math.floor(n.length / 2)] : 1;
937
- return Math.max(1, e * Me);
937
+ function mo(t) {
938
+ const n = t.map((o) => o.worldBBox && !o.unknownBBox ? fo(o.worldBBox) : 0).filter((o) => Number.isFinite(o) && o > 0).sort((o, i) => o - i), e = n.length > 0 ? n[Math.floor(n.length / 2)] : 1;
939
+ return Math.max(1, e * je);
938
940
  }
939
- function eo(t, n) {
940
- const e = t.map((i, c) => {
941
- const s = n(i), u = s.worldBBox ? Xn(s.worldBBox) : null;
941
+ function _o(t, n) {
942
+ const e = t.map((s, l) => {
943
+ const a = n(s), c = a.worldBBox ? zn(a.worldBBox) : null;
942
944
  return {
943
- sceneInstanceId: c,
944
- sceneInstance: i,
945
- worldBBox: u,
946
- unknownBBox: s.unknownBBox || !u
945
+ sceneInstanceId: l,
946
+ sceneInstance: s,
947
+ worldBBox: c,
948
+ unknownBBox: a.unknownBBox || !c
947
949
  };
948
- }), o = no(e), a = /* @__PURE__ */ new Map(), r = [];
949
- for (const i of e) {
950
- if (i.unknownBBox || !i.worldBBox) {
951
- r.push(i);
950
+ }), o = mo(e), i = /* @__PURE__ */ new Map(), r = [];
951
+ for (const s of e) {
952
+ if (s.unknownBBox || !s.worldBBox) {
953
+ r.push(s);
952
954
  continue;
953
955
  }
954
- const c = Math.floor(i.worldBBox.minX / o), s = Math.floor(i.worldBBox.maxX / o), u = Math.floor(i.worldBBox.minY / o), h = Math.floor(i.worldBBox.maxY / o), d = (s - c + 1) * (h - u + 1);
955
- if (!Number.isFinite(d) || d > Pe) {
956
- r.push(i);
956
+ const l = Math.floor(s.worldBBox.minX / o), a = Math.floor(s.worldBBox.maxX / o), c = Math.floor(s.worldBBox.minY / o), _ = Math.floor(s.worldBBox.maxY / o), f = (a - l + 1) * (_ - c + 1);
957
+ if (!Number.isFinite(f) || f > qe) {
958
+ r.push(s);
957
959
  continue;
958
960
  }
959
- for (let _ = c; _ <= s; _ += 1)
960
- for (let f = u; f <= h; f += 1) {
961
- const w = Ln(_, f), y = a.get(w);
962
- y ? y.push(i) : a.set(w, [i]);
961
+ for (let d = l; d <= a; d += 1)
962
+ for (let m = c; m <= _; m += 1) {
963
+ const A = Hn(d, m), y = i.get(A);
964
+ y ? y.push(s) : i.set(A, [s]);
963
965
  }
964
966
  }
965
- return { cellSize: o, cells: a, overflow: r, records: e };
967
+ return { cellSize: o, cells: i, overflow: r, records: e };
966
968
  }
967
- function oo(t, n, e) {
968
- const o = gn.get(t);
969
+ function Eo(t, n, e) {
970
+ const o = Rn.get(t);
969
971
  if (o && o.records.length === n.length)
970
972
  return o;
971
- const a = eo(n, e);
972
- return gn.set(t, a), a;
973
+ const i = _o(n, e);
974
+ return Rn.set(t, i), i;
973
975
  }
974
- function ro(t, n) {
975
- const e = Xn(n);
976
+ function xo(t, n) {
977
+ const e = zn(n);
976
978
  if (!e)
977
979
  return t.records;
978
- const o = /* @__PURE__ */ new Set(), a = Math.floor(e.minX / t.cellSize), r = Math.floor(e.maxX / t.cellSize), i = Math.floor(e.minY / t.cellSize), c = Math.floor(e.maxY / t.cellSize);
979
- for (let s = a; s <= r; s += 1)
980
- for (let u = i; u <= c; u += 1) {
981
- const h = t.cells.get(Ln(s, u));
982
- if (h)
983
- for (const d of h)
984
- d.worldBBox && qt(e, d.worldBBox) && o.add(d);
980
+ const o = /* @__PURE__ */ new Set(), i = Math.floor(e.minX / t.cellSize), r = Math.floor(e.maxX / t.cellSize), s = Math.floor(e.minY / t.cellSize), l = Math.floor(e.maxY / t.cellSize);
981
+ for (let a = i; a <= r; a += 1)
982
+ for (let c = s; c <= l; c += 1) {
983
+ const _ = t.cells.get(Hn(a, c));
984
+ if (_)
985
+ for (const f of _)
986
+ f.worldBBox && Wt(e, f.worldBBox) && o.add(f);
985
987
  }
986
- for (const s of t.overflow)
987
- (!s.worldBBox || qt(e, s.worldBBox)) && o.add(s);
988
- return Array.from(o).sort((s, u) => s.sceneInstanceId - u.sceneInstanceId);
989
- }
990
- function $o(t, n = {}) {
991
- if (!rt(t))
992
- return An();
993
- const e = new DataView(t), { sections: o } = mt(t), a = X(o, 1, "SCENE_META"), r = _t(t, a, "SCENE_META");
994
- if (!nn(r))
995
- return An();
996
- const i = X(o, 5, "VARIANT_TABLE");
997
- if (i.length % 60 !== 0)
998
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
999
- const c = i.length / 60, s = Vt(r, c), u = s.reduce((A, E) => A + E.raw_size, 0), h = n.viewport === void 0 ? void 0 : n.viewport, d = (A, E) => {
1000
- const p = Array.from(A).sort((U, V) => U - V), b = s.map((U) => U.id).filter((U) => !A.has(U)).sort((U, V) => U - V), S = p.reduce((U, V) => {
1001
- var k;
1002
- return U + (((k = s[V]) == null ? void 0 : k.raw_size) ?? 0);
1003
- }, 0), M = {
1004
- manifest: s,
1005
- requiredVariantIds: p,
1006
- requiredNormalBytes: S,
1007
- totalManifestBytes: u,
1008
- skippedVariantIds: b,
988
+ for (const a of t.overflow)
989
+ (!a.worldBBox || Wt(e, a.worldBBox)) && o.add(a);
990
+ return Array.from(o).sort((a, c) => a.sceneInstanceId - c.sceneInstanceId);
991
+ }
992
+ function Lo(t, n = {}) {
993
+ if (!Q(t))
994
+ return In();
995
+ const e = new DataView(t), { sections: o } = Et(t), i = P(o, 1, "SCENE_META"), r = xt(t, i, "SCENE_META");
996
+ if (!rn(r))
997
+ return In();
998
+ const s = P(o, 5, "VARIANT_TABLE");
999
+ if (s.length % 60 !== 0)
1000
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1001
+ const l = s.length / 60, a = Tt(r, l), c = a.reduce((N, E) => N + E.raw_size, 0), _ = n.viewport === void 0 ? void 0 : n.viewport, f = (N, E) => {
1002
+ const V = Array.from(N).sort((B, O) => B - O), T = a.map((B) => B.id).filter((B) => !N.has(B)).sort((B, O) => B - O), C = V.reduce((B, O) => {
1003
+ var j;
1004
+ return B + (((j = a[O]) == null ? void 0 : j.raw_size) ?? 0);
1005
+ }, 0), b = {
1006
+ manifest: a,
1007
+ requiredVariantIds: V,
1008
+ requiredNormalBytes: C,
1009
+ totalManifestBytes: c,
1010
+ skippedVariantIds: T,
1009
1011
  includedSceneInstanceIds: [...E]
1010
1012
  };
1011
- return h === void 0 ? M : { ...M, viewport: h };
1013
+ return _ === void 0 ? b : { ...b, viewport: _ };
1012
1014
  };
1013
1015
  if (n.loadBlocks === !1)
1014
- return d(/* @__PURE__ */ new Set(), []);
1015
- const _ = X(o, 7, "SCENE_INSTANCE_TABLE"), f = ut(o, 8), w = Z(t, _, "V3 SCENE_INSTANCE_TABLE"), y = Z(t, f, "V3 NESTED_INSTANCE_TABLE");
1016
- if (Number(r.variant_count ?? c) !== c)
1017
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1018
- if (Number(r.scene_instance_count ?? w.length) !== w.length)
1019
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1016
+ return f(/* @__PURE__ */ new Set(), []);
1017
+ const d = P(o, 7, "SCENE_INSTANCE_TABLE"), m = dt(o, 8), A = Z(t, d, "V3 SCENE_INSTANCE_TABLE"), y = Z(t, m, "V3 NESTED_INSTANCE_TABLE");
1018
+ if (Number(r.variant_count ?? l) !== l)
1019
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1020
+ if (Number(r.scene_instance_count ?? A.length) !== A.length)
1021
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1020
1022
  if (Number(r.nested_instance_count ?? y.length) !== y.length)
1021
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1022
- const m = /* @__PURE__ */ new Map(), x = [];
1023
- for (let A = 0; A < c; A += 1) {
1024
- const E = i.offset + A * 60, p = e.getUint32(E + 32, !0), b = e.getUint32(E + 36, !0);
1025
- if (p + b > y.length)
1026
- throw new l("E_GROUP_RANGE", `V3 variant ${A} nested range exceeds table`);
1027
- const S = s[A], M = rn(S);
1028
- x[A] = {
1029
- id: A,
1030
- nestedStart: p,
1031
- nestedCount: b,
1023
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1024
+ const x = /* @__PURE__ */ new Map(), h = [];
1025
+ for (let N = 0; N < l; N += 1) {
1026
+ const E = s.offset + N * 60, V = e.getUint32(E + 32, !0), T = e.getUint32(E + 36, !0);
1027
+ if (V + T > y.length)
1028
+ throw new u("E_GROUP_RANGE", `V3 variant ${N} nested range exceeds table`);
1029
+ const C = a[N], b = Ut(C);
1030
+ h[N] = {
1031
+ id: N,
1032
+ nestedStart: V,
1033
+ nestedCount: T,
1032
1034
  precisionOriginX: e.getFloat32(E + 48, !0),
1033
1035
  precisionOriginY: e.getFloat32(E + 52, !0),
1034
- bbox: M,
1035
- ownBBox: M
1036
+ bbox: b,
1037
+ ownBBox: b
1036
1038
  };
1037
- const U = [];
1038
- for (let V = 0; V < b; V += 1)
1039
- U.push(y[p + V].variantId);
1040
- m.set(A, U);
1039
+ const B = [];
1040
+ for (let O = 0; O < T; O += 1)
1041
+ B.push(y[V + O].variantId);
1042
+ x.set(N, B);
1041
1043
  }
1042
- At(w, y, (A) => {
1043
- if (!s[A.variantId])
1044
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${A.variantId}`);
1044
+ Rt(A, y, (N) => {
1045
+ if (!a[N.variantId])
1046
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${N.variantId}`);
1045
1047
  });
1046
- const G = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set(), R = (A, E, p) => {
1048
+ const R = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), p = (N, E, V) => {
1047
1049
  if (E > 64)
1048
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1049
- if (p.has(A))
1050
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${A}`);
1051
- if (!s[A])
1052
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${A}`);
1053
- if (!N.has(A)) {
1054
- G.add(A), p.add(A);
1055
- for (const b of m.get(A) ?? [])
1056
- R(b, E + 1, p);
1057
- p.delete(A), N.add(A);
1050
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1051
+ if (V.has(N))
1052
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${N}`);
1053
+ if (!a[N])
1054
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${N}`);
1055
+ if (!w.has(N)) {
1056
+ R.add(N), V.add(N);
1057
+ for (const T of x.get(N) ?? [])
1058
+ p(T, E + 1, V);
1059
+ V.delete(N), w.add(N);
1058
1060
  }
1059
- }, P = n.hiddenInstanceIds ?? /* @__PURE__ */ new Set(), B = n.viewport == null ? null : Je(
1061
+ }, v = n.hiddenInstanceIds ?? /* @__PURE__ */ new Set(), U = n.viewport == null ? null : lo(
1060
1062
  n.viewport,
1061
- n.viewportPaddingRatio ?? Oe
1062
- ), D = n.minViewportPixelSize ?? $e, C = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Set(), O = (A, E, p) => {
1063
+ n.viewportPaddingRatio ?? ze
1064
+ ), D = n.minViewportPixelSize ?? He, $ = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Set(), Y = (N, E, V) => {
1063
1065
  if (E > 64)
1064
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1065
- if (p.has(A))
1066
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${A}`);
1067
- if (C.has(A))
1068
- return C.get(A) ?? null;
1069
- const b = x[A];
1070
- if (!b)
1071
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${A}`);
1072
- p.add(A);
1073
- let S = b.ownBBox, M = !1;
1074
- for (let U = 0; U < b.nestedCount; U += 1) {
1075
- const V = y[b.nestedStart + U], k = x[V.variantId];
1076
- if (!k)
1077
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${V.variantId}`);
1078
- const z = O(V.variantId, E + 1, p);
1079
- if ((!z || $.has(V.variantId)) && (M = !0), !z)
1066
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1067
+ if (V.has(N))
1068
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${N}`);
1069
+ if ($.has(N))
1070
+ return $.get(N) ?? null;
1071
+ const T = h[N];
1072
+ if (!T)
1073
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${N}`);
1074
+ V.add(N);
1075
+ let C = T.ownBBox, b = !1;
1076
+ for (let B = 0; B < T.nestedCount; B += 1) {
1077
+ const O = y[T.nestedStart + B], j = h[O.variantId];
1078
+ if (!j)
1079
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${O.variantId}`);
1080
+ const H = Y(O.variantId, E + 1, V);
1081
+ if ((!H || M.has(O.variantId)) && (b = !0), !H)
1080
1082
  continue;
1081
- const H = an(V, b, k);
1082
- S = Rt(S, pt(z, H));
1083
+ const X = ln(O, T, j);
1084
+ C = pt(C, It(H, X));
1083
1085
  }
1084
- return p.delete(A), C.set(A, S), (!S || M) && $.add(A), S;
1085
- }, v = [], K = (A, E, p) => {
1086
- P.has(E) || B && p && (!qt(B, p) || Qe(
1087
- p,
1086
+ return V.delete(N), $.set(N, C), (!C || b) && M.add(N), C;
1087
+ }, z = [], S = (N, E, V) => {
1088
+ v.has(E) || U && V && (!Wt(U, V) || co(
1089
+ V,
1088
1090
  n.viewport ?? null,
1089
1091
  n.worldUnitsPerPixel,
1090
1092
  D
1091
- )) || (v.push(E), R(A.variantId, 0, /* @__PURE__ */ new Set()));
1093
+ )) || (z.push(E), p(N.variantId, 0, /* @__PURE__ */ new Set()));
1092
1094
  };
1093
- if (B) {
1094
- const A = oo(t, w, (E) => {
1095
- const p = O(E.variantId, 0, /* @__PURE__ */ new Set()), b = !p || $.has(E.variantId);
1095
+ if (U) {
1096
+ const N = Eo(t, A, (E) => {
1097
+ const V = Y(E.variantId, 0, /* @__PURE__ */ new Set()), T = !V || M.has(E.variantId);
1096
1098
  return {
1097
- worldBBox: p ? pt(p, E) : null,
1098
- unknownBBox: b
1099
+ worldBBox: V ? It(V, E) : null,
1100
+ unknownBBox: T
1099
1101
  };
1100
1102
  });
1101
- for (const E of ro(A, B))
1102
- K(E.sceneInstance, E.sceneInstanceId, E.unknownBBox ? null : E.worldBBox);
1103
+ for (const E of xo(N, U))
1104
+ S(E.sceneInstance, E.sceneInstanceId, E.unknownBBox ? null : E.worldBBox);
1103
1105
  } else
1104
- w.forEach((A, E) => {
1105
- K(A, E, null);
1106
+ A.forEach((N, E) => {
1107
+ S(N, E, null);
1106
1108
  });
1107
- return d(G, v);
1109
+ return f(R, z);
1108
1110
  }
1109
- function Mo(t) {
1110
- if (!rt(t))
1111
+ function ko(t) {
1112
+ if (!Q(t))
1111
1113
  return null;
1112
- const n = vn(t);
1113
- return en(n) ? Dn(n) : null;
1114
+ const n = Fn(t);
1115
+ return sn(n) ? Yn(n) : null;
1114
1116
  }
1115
- function ao(t, n) {
1117
+ function go(t, n) {
1116
1118
  if (!Array.isArray(t) || t.length !== 4)
1117
- throw new l("E_HEADER", `${n} must be a four-number array`);
1119
+ throw new u("E_HEADER", `${n} must be a four-number array`);
1118
1120
  const e = t.map(Number);
1119
1121
  if (!e.every(Number.isFinite))
1120
- throw new l("E_HEADER", `${n} must contain finite numbers`);
1122
+ throw new u("E_HEADER", `${n} must contain finite numbers`);
1121
1123
  return [e[0], e[1], e[2], e[3]];
1122
1124
  }
1123
- function Tt(t, n, e, o) {
1124
- return ft(n, e, t.byteLength, o), Zt.decode(t.subarray(n, n + e));
1125
+ function bt(t, n, e, o) {
1126
+ return _t(n, e, t.byteLength, o), nn.decode(t.subarray(n, n + e));
1125
1127
  }
1126
- function Yn(t, n, e) {
1128
+ function jn(t, n, e) {
1127
1129
  if (n.length % 20 !== 0)
1128
- throw new l("E_GROUP_RANGE", "V3 LAYER_TABLE length must be a multiple of 20");
1129
- const o = new DataView(t), a = [];
1130
+ throw new u("E_GROUP_RANGE", "V3 LAYER_TABLE length must be a multiple of 20");
1131
+ const o = new DataView(t), i = [];
1130
1132
  for (let r = n.offset; r < n.offset + n.length; r += 20) {
1131
- const i = o.getUint32(r, !0), c = o.getUint32(r + 4, !0);
1132
- a.push({
1133
- name: Tt(e, i, c, "V3 layer name"),
1133
+ const s = o.getUint32(r, !0), l = o.getUint32(r + 4, !0);
1134
+ i.push({
1135
+ name: bt(e, s, l, "V3 layer name"),
1134
1136
  color: [o.getUint8(r + 8), o.getUint8(r + 9), o.getUint8(r + 10)],
1135
1137
  visible: o.getUint8(r + 11) !== 0,
1136
1138
  lw_px: o.getFloat32(r + 12, !0)
1137
1139
  });
1138
1140
  }
1139
- return a;
1141
+ return i;
1140
1142
  }
1141
- function yt(t, n, e, o, a, r) {
1143
+ function wt(t, n, e, o, i, r) {
1142
1144
  if (e + 4 > o)
1143
- throw new l("E_GROUP_RANGE", `Missing ${a} vertex_count`);
1144
- const i = n.getUint32(e, !0), c = e + 4, s = lt(t, n, c, i, o, r);
1145
- if (s.offset > o)
1146
- throw new l("E_GROUP_RANGE", `${a} exceeds section bounds`);
1145
+ throw new u("E_GROUP_RANGE", `Missing ${i} vertex_count`);
1146
+ const s = n.getUint32(e, !0), l = e + 4, a = ft(t, n, l, s, o, r);
1147
+ if (a.offset > o)
1148
+ throw new u("E_GROUP_RANGE", `${i} exceeds section bounds`);
1147
1149
  return {
1148
- chunk: s.chunk,
1149
- offset: s.offset
1150
+ chunk: a.chunk,
1151
+ offset: a.offset
1150
1152
  };
1151
1153
  }
1152
- function Fn(t, n, e, o, a, r) {
1153
- const i = yt(t, n, e, o, a, r), c = e + 4;
1154
+ function qn(t, n, e, o, i, r) {
1155
+ const s = wt(t, n, e, o, i, r), l = e + 4;
1154
1156
  return {
1155
- chunk: i.chunk,
1157
+ chunk: s.chunk,
1156
1158
  snapshot: {
1157
- count: i.chunk.count,
1158
- raw: new Uint8Array(t, c, i.offset - c).slice(),
1159
+ count: s.chunk.count,
1160
+ raw: new Uint8Array(t, l, s.offset - l).slice(),
1159
1161
  groupLayerEncoding: r
1160
1162
  },
1161
- offset: i.offset
1163
+ offset: s.offset
1162
1164
  };
1163
1165
  }
1164
- function wt(t = "u8") {
1166
+ function At(t = "u8") {
1165
1167
  return {
1166
1168
  chunk: { pos: new Float32Array(0), col: new Uint8Array(0), lay: new Uint8Array(0), count: 0 },
1167
1169
  snapshot: { count: 0, raw: new Uint8Array(0), groupLayerEncoding: t }
1168
1170
  };
1169
1171
  }
1170
- function io(t = "u8") {
1172
+ function Kn(t = "u8") {
1171
1173
  return {
1172
- line: wt(t),
1173
- fill: wt(t),
1174
- dot: wt(t)
1174
+ line: At(t),
1175
+ fill: At(t),
1176
+ dot: At(t)
1175
1177
  };
1176
1178
  }
1177
- function so(t, n, e) {
1179
+ function Wn(t, n, e) {
1178
1180
  var o;
1179
1181
  return !!(n && e && t.deferExternalVariantGeometry && !((o = t.externalVariantBuffers) != null && o.has(n.id)));
1180
1182
  }
1181
- function St(t, n, e, o, a, r, i) {
1182
- if (a === 0)
1183
- return wt(i);
1184
- ft(o, a, e.length, r);
1185
- const c = e.offset + o, s = c + a, u = Fn(t, n, c, s, r, i);
1186
- if (u.offset !== s)
1187
- throw new l("E_GROUP_RANGE", `${r} has trailing bytes`);
1188
- return { chunk: u.chunk, snapshot: u.snapshot };
1183
+ function Ot(t, n, e, o, i, r, s) {
1184
+ if (i === 0)
1185
+ return At(s);
1186
+ _t(o, i, e.length, r);
1187
+ const l = e.offset + o, a = l + i, c = qn(t, n, l, a, r, s);
1188
+ if (c.offset !== a)
1189
+ throw new u("E_GROUP_RANGE", `${r} has trailing bytes`);
1190
+ return { chunk: c.chunk, snapshot: c.snapshot };
1189
1191
  }
1190
- function kn(t, n, e) {
1192
+ function an(t, n, e) {
1191
1193
  if ([
1192
1194
  t.getUint32(n + 8, !0),
1193
1195
  t.getUint32(n + 12, !0),
@@ -1195,206 +1197,233 @@ function kn(t, n, e) {
1195
1197
  t.getUint32(n + 20, !0),
1196
1198
  t.getUint32(n + 24, !0),
1197
1199
  t.getUint32(n + 28, !0)
1198
- ].some((a) => a !== 0))
1199
- throw new l("E_GROUP_RANGE", `V3 external variant ${e} must use zero inline geometry offsets`);
1200
+ ].some((i) => i !== 0))
1201
+ throw new u("E_GROUP_RANGE", `V3 external variant ${e} must use zero inline geometry offsets`);
1200
1202
  }
1201
- function st(t, n, e, o, a, r) {
1202
- const i = Fn(t, n, e, t.byteLength, a, r);
1203
- if (i.chunk.count !== o)
1204
- throw new l(
1203
+ function lt(t, n, e, o, i, r) {
1204
+ const s = qn(t, n, e, t.byteLength, i, r);
1205
+ if (s.chunk.count !== o)
1206
+ throw new u(
1205
1207
  "E_GROUP_RANGE",
1206
- `${a} vertex_count mismatch: manifest=${o}, sidecar=${i.chunk.count}`
1208
+ `${i} vertex_count mismatch: manifest=${o}, sidecar=${s.chunk.count}`
1207
1209
  );
1208
- return i;
1210
+ return s;
1209
1211
  }
1210
- function on(t) {
1212
+ function Bt(t) {
1211
1213
  return "normal" in t ? t.normal : t;
1212
1214
  }
1213
- function co(t, n, e) {
1214
- const o = on(t), a = new DataView(n);
1215
+ function ho(t, n, e) {
1216
+ const o = Bt(t), i = new DataView(n);
1215
1217
  let r = 0;
1216
- const i = st(n, a, r, o.line_count, `V3 external variant ${t.id} line blob`, e);
1217
- r = i.offset;
1218
- const c = st(n, a, r, o.fill_count, `V3 external variant ${t.id} fill blob`, e);
1219
- r = c.offset;
1220
- const s = st(n, a, r, o.dot_count, `V3 external variant ${t.id} dot blob`, e);
1221
- if (r = s.offset, r !== n.byteLength)
1222
- throw new l("E_GROUP_RANGE", `V3 external variant ${t.id} sidecar has trailing bytes`);
1218
+ const s = lt(n, i, r, o.line_count, `V3 external variant ${t.id} line blob`, e);
1219
+ r = s.offset;
1220
+ const l = lt(n, i, r, o.fill_count, `V3 external variant ${t.id} fill blob`, e);
1221
+ r = l.offset;
1222
+ const a = lt(n, i, r, o.dot_count, `V3 external variant ${t.id} dot blob`, e);
1223
+ if (r = a.offset, r !== n.byteLength)
1224
+ throw new u("E_GROUP_RANGE", `V3 external variant ${t.id} sidecar has trailing bytes`);
1223
1225
  return {
1224
- line: { chunk: i.chunk, snapshot: i.snapshot },
1225
- fill: { chunk: c.chunk, snapshot: c.snapshot },
1226
- dot: { chunk: s.chunk, snapshot: s.snapshot }
1226
+ line: { chunk: s.chunk, snapshot: s.snapshot },
1227
+ fill: { chunk: l.chunk, snapshot: l.snapshot },
1228
+ dot: { chunk: a.chunk, snapshot: a.snapshot }
1227
1229
  };
1228
1230
  }
1229
- function lo(t, n) {
1230
- const e = Jt(n), o = et(e, 257, "BLOCK_NORMAL_GEOMETRY"), a = new DataView(n);
1231
+ function yo(t, n) {
1232
+ const e = tn(n), o = ot(e, 257, "BLOCK_NORMAL_GEOMETRY"), i = new DataView(n);
1231
1233
  let r = o.offset;
1232
- const i = o.offset + o.length, c = Wt(e.versionMinor), s = st(n, a, r, t.normal.line_count, `V3.3 external variant ${t.id} normal line blob`, c);
1233
- r = s.offset;
1234
- const u = st(n, a, r, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, c);
1235
- r = u.offset;
1236
- const h = st(n, a, r, t.normal.dot_count, `V3.3 external variant ${t.id} normal dot blob`, c);
1237
- if (r = h.offset, r !== i)
1238
- throw new l("E_GROUP_RANGE", `V3.3 external variant ${t.id} normal geometry section has trailing bytes`);
1234
+ const s = o.offset + o.length, l = Qt(e.versionMinor), a = lt(n, i, r, t.normal.line_count, `V3.3 external variant ${t.id} normal line blob`, l);
1235
+ r = a.offset;
1236
+ const c = lt(n, i, r, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, l);
1237
+ r = c.offset;
1238
+ const _ = lt(n, i, r, t.normal.dot_count, `V3.3 external variant ${t.id} normal dot blob`, l);
1239
+ if (r = _.offset, r !== s)
1240
+ throw new u("E_GROUP_RANGE", `V3.3 external variant ${t.id} normal geometry section has trailing bytes`);
1239
1241
  return {
1240
- line: { chunk: s.chunk, snapshot: s.snapshot },
1241
- fill: { chunk: u.chunk, snapshot: u.snapshot },
1242
- dot: { chunk: h.chunk, snapshot: h.snapshot }
1242
+ line: { chunk: a.chunk, snapshot: a.snapshot },
1243
+ fill: { chunk: c.chunk, snapshot: c.snapshot },
1244
+ dot: { chunk: _.chunk, snapshot: _.snapshot }
1243
1245
  };
1244
1246
  }
1245
- function uo(t, n, e = "u8") {
1247
+ function wo(t, n, e = "u8") {
1246
1248
  if (n.byteLength !== t.raw_size)
1247
- throw new l(
1249
+ throw new u(
1248
1250
  "E_GROUP_RANGE",
1249
1251
  `V3 external variant ${t.id} raw_size mismatch: manifest=${t.raw_size}, sidecar=${n.byteLength}`
1250
1252
  );
1251
- return "normal" in t ? lo(t, n) : co(t, n, e);
1253
+ return "normal" in t ? yo(t, n) : ho(t, n, e);
1252
1254
  }
1253
- function fo(t, n, e) {
1255
+ function Jn(t, n, e) {
1254
1256
  const o = n == null ? void 0 : n.get(t.id);
1255
1257
  if (!o)
1256
- throw new l("E_GROUP_RANGE", `Missing V3 external sidecar buffer for variant ${t.id}`);
1257
- return uo(t, o, e);
1258
+ throw new u("E_GROUP_RANGE", `Missing V3 external sidecar buffer for variant ${t.id}`);
1259
+ return wo(t, o, e);
1258
1260
  }
1259
- function Ct(t, n, e, o, a) {
1261
+ function $t(t, n, e, o, i) {
1260
1262
  if (o === 0)
1261
1263
  return 0;
1262
- if (ft(e, o, n.length, a), o < 4)
1263
- throw new l("E_GROUP_RANGE", `Missing ${a} vertex_count`);
1264
+ if (_t(e, o, n.length, i), o < 4)
1265
+ throw new u("E_GROUP_RANGE", `Missing ${i} vertex_count`);
1264
1266
  return t.getUint32(n.offset + e, !0);
1265
1267
  }
1266
- function mo(t, n, e, o) {
1267
- const a = e.offset + e.length;
1268
+ function Ao(t, n, e, o) {
1269
+ const i = e.offset + e.length;
1268
1270
  let r = e.offset;
1269
- const i = yt(t, n, r, a, "V3 BASE_GEOMETRY line", o);
1270
- r = i.offset;
1271
- const c = yt(t, n, r, a, "V3 BASE_GEOMETRY fill", o);
1272
- r = c.offset;
1273
- const s = yt(t, n, r, a, "V3 BASE_GEOMETRY dot", o);
1274
- if (r = s.offset, r !== a)
1275
- throw new l("E_GROUP_RANGE", "V3 BASE_GEOMETRY has trailing bytes");
1271
+ const s = wt(t, n, r, i, "V3 BASE_GEOMETRY line", o);
1272
+ r = s.offset;
1273
+ const l = wt(t, n, r, i, "V3 BASE_GEOMETRY fill", o);
1274
+ r = l.offset;
1275
+ const a = wt(t, n, r, i, "V3 BASE_GEOMETRY dot", o);
1276
+ if (r = a.offset, r !== i)
1277
+ throw new u("E_GROUP_RANGE", "V3 BASE_GEOMETRY has trailing bytes");
1276
1278
  return {
1277
- line: i.chunk,
1278
- fill: c.chunk,
1279
- dot: s.chunk
1279
+ line: s.chunk,
1280
+ fill: l.chunk,
1281
+ dot: a.chunk
1280
1282
  };
1281
1283
  }
1282
- function Ot(t) {
1283
- return Ee(t.pos, t.count, 2);
1284
+ function Mt(t) {
1285
+ return Ge(t.pos, t.count, 2);
1284
1286
  }
1285
- function _o(t, n, e) {
1286
- return Rt(Rt(Ot(t), Ot(n)), Ot(e));
1287
+ function Zn(t, n, e) {
1288
+ return pt(pt(Mt(t), Mt(n)), Mt(e));
1287
1289
  }
1288
- function rn(t) {
1289
- return "normal" in t ? We(t.normal.bbox ?? t.normal.own_bbox ?? null) : null;
1290
+ function Ut(t) {
1291
+ return "normal" in t ? ao(t.normal.bbox ?? t.normal.own_bbox ?? null) : null;
1290
1292
  }
1291
- function ho(t, n, e, o, a, r, i, c) {
1293
+ function Ro(t, n, e, o, i, r, s, l) {
1292
1294
  if (e.length % 60 !== 0)
1293
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1294
- const s = [], u = /* @__PURE__ */ new Map(), h = [], d = e.length / 60;
1295
- for (let _ = 0; _ < d; _ += 1) {
1296
- const f = e.offset + _ * 60, w = n.getUint32(f, !0), y = n.getUint32(f + 4, !0), m = (r == null ? void 0 : r[_]) ?? null, x = !m || !c.requiredExternalVariantIds || c.requiredExternalVariantIds.has(_), G = so(c, m, x), N = m ? (kn(n, f, _), !x || G ? io(i) : fo(m, c.externalVariantBuffers, i)) : {
1297
- line: St(
1295
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1296
+ const a = [], c = /* @__PURE__ */ new Map(), _ = [], f = e.length / 60;
1297
+ for (let d = 0; d < f; d += 1) {
1298
+ const m = e.offset + d * 60, A = n.getUint32(m, !0), y = n.getUint32(m + 4, !0), x = (r == null ? void 0 : r[d]) ?? null, h = !x || !l.requiredExternalVariantIds || l.requiredExternalVariantIds.has(d), R = Wn(l, x, h), w = x ? (an(n, m, d), !h || R ? Kn(s) : Jn(x, l.externalVariantBuffers, s)) : {
1299
+ line: Ot(
1298
1300
  t,
1299
1301
  n,
1300
1302
  o,
1301
- n.getUint32(f + 8, !0),
1302
- n.getUint32(f + 12, !0),
1303
- `V3 variant ${_} line blob`,
1304
- i
1303
+ n.getUint32(m + 8, !0),
1304
+ n.getUint32(m + 12, !0),
1305
+ `V3 variant ${d} line blob`,
1306
+ s
1305
1307
  ),
1306
- fill: St(
1308
+ fill: Ot(
1307
1309
  t,
1308
1310
  n,
1309
1311
  o,
1310
- n.getUint32(f + 16, !0),
1311
- n.getUint32(f + 20, !0),
1312
- `V3 variant ${_} fill blob`,
1313
- i
1312
+ n.getUint32(m + 16, !0),
1313
+ n.getUint32(m + 20, !0),
1314
+ `V3 variant ${d} fill blob`,
1315
+ s
1314
1316
  ),
1315
- dot: St(
1317
+ dot: Ot(
1316
1318
  t,
1317
1319
  n,
1318
1320
  o,
1319
- n.getUint32(f + 24, !0),
1320
- n.getUint32(f + 28, !0),
1321
- `V3 variant ${_} dot blob`,
1322
- i
1321
+ n.getUint32(m + 24, !0),
1322
+ n.getUint32(m + 28, !0),
1323
+ `V3 variant ${d} dot blob`,
1324
+ s
1323
1325
  )
1324
- }, R = m ? on(m) : null, P = (R == null ? void 0 : R.line_count) ?? N.line.chunk.count, B = (R == null ? void 0 : R.fill_count) ?? N.fill.chunk.count, D = (R == null ? void 0 : R.dot_count) ?? N.dot.chunk.count, C = m && (!x || G) ? rn(m) : _o(N.line.chunk, N.fill.chunk, N.dot.chunk), $ = {
1325
- id: _,
1326
- name: Tt(a, w, y, `V3 variant ${_} name`),
1327
- line_count: G ? P : N.line.chunk.count,
1328
- fill_count: G ? B : N.fill.chunk.count,
1329
- dot_count: G ? D : N.dot.chunk.count,
1330
- sourceLineCount: P,
1331
- sourceFillCount: B,
1326
+ }, p = x ? Bt(x) : null, v = (p == null ? void 0 : p.line_count) ?? w.line.chunk.count, U = (p == null ? void 0 : p.fill_count) ?? w.fill.chunk.count, D = (p == null ? void 0 : p.dot_count) ?? w.dot.chunk.count, $ = x && (!h || R) ? Ut(x) : Zn(w.line.chunk, w.fill.chunk, w.dot.chunk), M = {
1327
+ id: d,
1328
+ name: bt(i, A, y, `V3 variant ${d} name`),
1329
+ line_count: R ? v : w.line.chunk.count,
1330
+ fill_count: R ? U : w.fill.chunk.count,
1331
+ dot_count: R ? D : w.dot.chunk.count,
1332
+ sourceLineCount: v,
1333
+ sourceFillCount: U,
1332
1334
  sourceDotCount: D,
1333
- nestedStart: n.getUint32(f + 32, !0),
1334
- nestedCount: n.getUint32(f + 36, !0),
1335
- textStart: n.getUint32(f + 40, !0),
1336
- textCount: n.getUint32(f + 44, !0),
1337
- precisionOriginX: n.getFloat32(f + 48, !0),
1338
- precisionOriginY: n.getFloat32(f + 52, !0),
1339
- lineSnapshot: N.line.snapshot,
1340
- fillSnapshot: N.fill.snapshot,
1341
- dotSnapshot: N.dot.snapshot,
1342
- bbox: C
1335
+ nestedStart: n.getUint32(m + 32, !0),
1336
+ nestedCount: n.getUint32(m + 36, !0),
1337
+ textStart: n.getUint32(m + 40, !0),
1338
+ textCount: n.getUint32(m + 44, !0),
1339
+ precisionOriginX: n.getFloat32(m + 48, !0),
1340
+ precisionOriginY: n.getFloat32(m + 52, !0),
1341
+ lineSnapshot: w.line.snapshot,
1342
+ fillSnapshot: w.fill.snapshot,
1343
+ dotSnapshot: w.dot.snapshot,
1344
+ bbox: $
1343
1345
  };
1344
- s.push($), u.set(_, { line: N.line.chunk, fill: N.fill.chunk, dot: N.dot.chunk }), h.push({ line: N.line.snapshot, fill: N.fill.snapshot, dot: N.dot.snapshot });
1346
+ a.push(M), c.set(d, { line: w.line.chunk, fill: w.fill.chunk, dot: w.dot.chunk }), _.push({ line: w.line.snapshot, fill: w.fill.snapshot, dot: w.dot.snapshot });
1345
1347
  }
1346
- return { variantsById: s, variants: u, snapshots: h };
1348
+ return { variantsById: a, variants: c, snapshots: _ };
1347
1349
  }
1348
- function zn(t, n, e, o, a) {
1350
+ function Jt(t, n, e, o, i) {
1349
1351
  if (n.length % 60 !== 0)
1350
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1351
- const r = [], i = n.length / 60;
1352
- for (let c = 0; c < i; c += 1) {
1353
- const s = n.offset + c * 60, u = t.getUint32(s, !0), h = t.getUint32(s + 4, !0), d = (a == null ? void 0 : a[c]) ?? null;
1354
- d && kn(t, s, c);
1355
- const _ = d ? on(d) : null, f = t.getFloat32(s + 48, !0), w = t.getFloat32(s + 52, !0);
1352
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1353
+ const r = [], s = n.length / 60;
1354
+ for (let l = 0; l < s; l += 1) {
1355
+ const a = n.offset + l * 60, c = t.getUint32(a, !0), _ = t.getUint32(a + 4, !0), f = (i == null ? void 0 : i[l]) ?? null;
1356
+ f && an(t, a, l);
1357
+ const d = f ? Bt(f) : null, m = t.getFloat32(a + 48, !0), A = t.getFloat32(a + 52, !0);
1356
1358
  r.push({
1357
- id: c,
1358
- name: Tt(o, u, h, `V3 variant ${c} name`),
1359
- line_count: d ? _.line_count : Ct(
1359
+ id: l,
1360
+ name: bt(o, c, _, `V3 variant ${l} name`),
1361
+ line_count: f ? d.line_count : $t(
1360
1362
  t,
1361
1363
  e,
1362
- t.getUint32(s + 8, !0),
1363
- t.getUint32(s + 12, !0),
1364
- `V3 variant ${c} line blob`
1364
+ t.getUint32(a + 8, !0),
1365
+ t.getUint32(a + 12, !0),
1366
+ `V3 variant ${l} line blob`
1365
1367
  ),
1366
- fill_count: d ? _.fill_count : Ct(
1368
+ fill_count: f ? d.fill_count : $t(
1367
1369
  t,
1368
1370
  e,
1369
- t.getUint32(s + 16, !0),
1370
- t.getUint32(s + 20, !0),
1371
- `V3 variant ${c} fill blob`
1371
+ t.getUint32(a + 16, !0),
1372
+ t.getUint32(a + 20, !0),
1373
+ `V3 variant ${l} fill blob`
1372
1374
  ),
1373
- dot_count: d ? _.dot_count : Ct(
1375
+ dot_count: f ? d.dot_count : $t(
1374
1376
  t,
1375
1377
  e,
1376
- t.getUint32(s + 24, !0),
1377
- t.getUint32(s + 28, !0),
1378
- `V3 variant ${c} dot blob`
1378
+ t.getUint32(a + 24, !0),
1379
+ t.getUint32(a + 28, !0),
1380
+ `V3 variant ${l} dot blob`
1379
1381
  ),
1380
- nestedStart: t.getUint32(s + 32, !0),
1381
- nestedCount: t.getUint32(s + 36, !0),
1382
- textStart: t.getUint32(s + 40, !0),
1383
- textCount: t.getUint32(s + 44, !0),
1384
- precisionOriginX: f,
1385
- precisionOriginY: w,
1386
- bbox: d ? rn(d) : null
1382
+ nestedStart: t.getUint32(a + 32, !0),
1383
+ nestedCount: t.getUint32(a + 36, !0),
1384
+ textStart: t.getUint32(a + 40, !0),
1385
+ textCount: t.getUint32(a + 44, !0),
1386
+ precisionOriginX: m,
1387
+ precisionOriginY: A,
1388
+ bbox: f ? Ut(f) : null
1387
1389
  });
1388
1390
  }
1389
1391
  return r;
1390
1392
  }
1393
+ function No(t, n, e) {
1394
+ var l;
1395
+ const o = new DataView(t), i = [], r = /* @__PURE__ */ new Map(), s = [];
1396
+ for (const a of n.variantHeaders) {
1397
+ const c = ((l = n.externalVariants) == null ? void 0 : l[a.id]) ?? null, _ = !c || !e.requiredExternalVariantIds || e.requiredExternalVariantIds.has(a.id), f = Wn(e, c, _), d = c ? (() => {
1398
+ const w = n.sections.get(5).offset + a.id * 60;
1399
+ return an(o, w, a.id), !_ || f ? Kn(n.groupLayerEncoding) : Jn(c, e.externalVariantBuffers, n.groupLayerEncoding);
1400
+ })() : n.internalVariants.get(a.id);
1401
+ if (!d)
1402
+ throw new u("E_GROUP_RANGE", `Missing cached V3 variant geometry for variant ${a.id}`);
1403
+ const m = c ? Bt(c) : null, A = (m == null ? void 0 : m.line_count) ?? d.line.chunk.count, y = (m == null ? void 0 : m.fill_count) ?? d.fill.chunk.count, x = (m == null ? void 0 : m.dot_count) ?? d.dot.chunk.count, h = c && (!_ || f) ? Ut(c) : Zn(d.line.chunk, d.fill.chunk, d.dot.chunk), R = {
1404
+ ...a,
1405
+ line_count: f ? A : d.line.chunk.count,
1406
+ fill_count: f ? y : d.fill.chunk.count,
1407
+ dot_count: f ? x : d.dot.chunk.count,
1408
+ sourceLineCount: A,
1409
+ sourceFillCount: y,
1410
+ sourceDotCount: x,
1411
+ lineSnapshot: d.line.snapshot,
1412
+ fillSnapshot: d.fill.snapshot,
1413
+ dotSnapshot: d.dot.snapshot,
1414
+ bbox: h
1415
+ };
1416
+ i.push(R), r.set(a.id, { line: d.line.chunk, fill: d.fill.chunk, dot: d.dot.chunk }), s.push({ line: d.line.snapshot, fill: d.fill.snapshot, dot: d.dot.snapshot });
1417
+ }
1418
+ return { variantsById: i, variants: r, snapshots: s };
1419
+ }
1391
1420
  function Z(t, n, e) {
1392
1421
  if (n.length % 32 !== 0)
1393
- throw new l("E_GROUP_RANGE", `${e} length must be a multiple of 32`);
1394
- const o = new DataView(t), a = [];
1422
+ throw new u("E_GROUP_RANGE", `${e} length must be a multiple of 32`);
1423
+ const o = new DataView(t), i = [];
1395
1424
  for (let r = n.offset; r < n.offset + n.length; r += 32) {
1396
- const i = o.getUint16(r + 30, !0);
1397
- Ao(i), a.push({
1425
+ const s = o.getUint16(r + 30, !0);
1426
+ bo(s), i.push({
1398
1427
  variantId: o.getUint32(r, !0),
1399
1428
  matA: o.getFloat32(r + 4, !0),
1400
1429
  matB: o.getFloat32(r + 8, !0),
@@ -1403,44 +1432,44 @@ function Z(t, n, e) {
1403
1432
  tx: o.getFloat32(r + 20, !0),
1404
1433
  ty: o.getFloat32(r + 24, !0),
1405
1434
  insLayerIdx: o.getUint16(r + 28, !0),
1406
- flags: i
1435
+ flags: s
1407
1436
  });
1408
1437
  }
1409
- return a;
1438
+ return i;
1410
1439
  }
1411
- function Eo(t, n, e) {
1412
- const o = t.getUint32(n, !0), a = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), i = t.getUint8(n + 43), c = t.getFloat32(n + 24, !0), s = t.getFloat32(n + 28, !0);
1440
+ function po(t, n, e) {
1441
+ const o = t.getUint32(n, !0), i = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), s = t.getUint8(n + 43), l = t.getFloat32(n + 24, !0), a = t.getFloat32(n + 28, !0);
1413
1442
  return {
1414
- t: Tt(e, o, a, "V3 text value"),
1443
+ t: bt(e, o, i, "V3 text value"),
1415
1444
  x: t.getFloat32(n + 8, !0),
1416
1445
  y: t.getFloat32(n + 12, !0),
1417
1446
  h: t.getFloat32(n + 16, !0),
1418
1447
  r: t.getFloat32(n + 20, !0),
1419
1448
  c: [t.getUint8(n + 36), t.getUint8(n + 37), t.getUint8(n + 38)],
1420
1449
  li: t.getUint16(n + 40, !0),
1421
- ha: De[r & 3] ?? "left",
1422
- va: ve[r >> 2 & 3] ?? "alphabetic",
1450
+ ha: Ke[r & 3] ?? "left",
1451
+ va: We[r >> 2 & 3] ?? "alphabetic",
1423
1452
  lh: t.getFloat32(n + 32, !0),
1424
- ...c ? { w: c } : {},
1425
- ...s !== 1 ? { wf: s } : {},
1426
- ...i & 1 ? { mx: !0 } : {},
1427
- ...i & 2 ? { my: !0 } : {}
1453
+ ...l ? { w: l } : {},
1454
+ ...a !== 1 ? { wf: a } : {},
1455
+ ...s & 1 ? { mx: !0 } : {},
1456
+ ...s & 2 ? { my: !0 } : {}
1428
1457
  };
1429
1458
  }
1430
- function $t(t, n, e, o) {
1459
+ function vt(t, n, e, o) {
1431
1460
  if (n.length % 44 !== 0)
1432
- throw new l("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
1433
- const a = [], r = new DataView(t);
1434
- for (let i = n.offset; i < n.offset + n.length; i += 44)
1435
- a.push(Eo(r, i, e));
1436
- return a;
1461
+ throw new u("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
1462
+ const i = [], r = new DataView(t);
1463
+ for (let s = n.offset; s < n.offset + n.length; s += 44)
1464
+ i.push(po(r, s, e));
1465
+ return i;
1437
1466
  }
1438
- function xo(t, n) {
1467
+ function Io(t, n) {
1439
1468
  if (t.length % 44 !== 0)
1440
- throw new l("E_GROUP_RANGE", `${n} length must be a multiple of 44`);
1469
+ throw new u("E_GROUP_RANGE", `${n} length must be a multiple of 44`);
1441
1470
  return t.length / 44;
1442
1471
  }
1443
- function Hn(t, n, e, o) {
1472
+ function Qn(t, n, e, o) {
1444
1473
  return {
1445
1474
  instanceId: e,
1446
1475
  variantId: n.variantId,
@@ -1453,187 +1482,189 @@ function Hn(t, n, e, o) {
1453
1482
  insLayerIdx: o
1454
1483
  };
1455
1484
  }
1456
- function jn(t, n, e, o) {
1485
+ function te(t, n, e, o) {
1457
1486
  var y;
1458
- const a = ((y = o[n.insLayerIdx]) == null ? void 0 : y.visible) === !1, r = n.matA * t.x + n.matC * t.y + n.tx, i = n.matB * t.x + n.matD * t.y + n.ty, c = Math.hypot(n.matA, n.matB), s = Math.hypot(n.matC, n.matD), u = s > 1e-12 ? s : c > 1e-12 ? c : 1, h = c > 1e-12 && u > 1e-12 ? c / u : 1, d = go(t, n), { mx: _, my: f, ...w } = t;
1487
+ const i = ((y = o[n.insLayerIdx]) == null ? void 0 : y.visible) === !1, r = n.matA * t.x + n.matC * t.y + n.tx, s = n.matB * t.x + n.matD * t.y + n.ty, l = Math.hypot(n.matA, n.matB), a = Math.hypot(n.matC, n.matD), c = a > 1e-12 ? a : l > 1e-12 ? l : 1, _ = l > 1e-12 && c > 1e-12 ? l / c : 1, f = Vo(t, n), { mx: d, my: m, ...A } = t;
1459
1488
  return {
1460
- ...w,
1489
+ ...A,
1461
1490
  x: r,
1462
- y: i,
1463
- h: t.h * u,
1464
- w: t.w === void 0 ? void 0 : t.w * u,
1465
- wf: (t.wf ?? 1) * h,
1466
- r: d.r,
1467
- ...d.mx ? { mx: !0 } : {},
1468
- ...d.my ? { my: !0 } : {},
1469
- li: a || t.li === e ? n.insLayerIdx : t.li
1491
+ y: s,
1492
+ h: t.h * c,
1493
+ w: t.w === void 0 ? void 0 : t.w * c,
1494
+ wf: (t.wf ?? 1) * _,
1495
+ r: f.r,
1496
+ ...f.mx ? { mx: !0 } : {},
1497
+ ...f.my ? { my: !0 } : {},
1498
+ li: i || t.li === e ? n.insLayerIdx : t.li
1470
1499
  };
1471
1500
  }
1472
- function go(t, n) {
1473
- const e = t.r * Math.PI / 180, o = Math.cos(e), a = Math.sin(e), r = t.mx ? -1 : 1, i = t.my ? -1 : 1, c = r * (n.matA * o + n.matC * a), s = r * (n.matB * o + n.matD * a), u = i * (n.matC * o - n.matA * a), h = i * (n.matD * o - n.matB * a), d = c * h - s * u, _ = Math.atan2(s, c) * 180 / Math.PI;
1474
- return d < 0 ? { r: Math.atan2(-s, -c) * 180 / Math.PI, mx: !0 } : { r: _ };
1501
+ function Vo(t, n) {
1502
+ const e = t.r * Math.PI / 180, o = Math.cos(e), i = Math.sin(e), r = t.mx ? -1 : 1, s = t.my ? -1 : 1, l = r * (n.matA * o + n.matC * i), a = r * (n.matB * o + n.matD * i), c = s * (n.matC * o - n.matA * i), _ = s * (n.matD * o - n.matB * i), f = l * _ - a * c, d = Math.atan2(a, l) * 180 / Math.PI;
1503
+ return f < 0 ? { r: Math.atan2(-a, -l) * 180 / Math.PI, mx: !0 } : { r: d };
1475
1504
  }
1476
- function Mt(t, n, e, o) {
1477
- var c;
1505
+ function Pt(t, n, e, o) {
1506
+ var l;
1478
1507
  if (t.count === 0)
1479
- return It();
1480
- const a = new Float32Array(t.count * 2);
1481
- for (let s = 0; s < t.count; s += 1) {
1482
- const u = s * 2, h = t.pos[u], d = t.pos[u + 1];
1483
- a[u] = n.matA * h + n.matC * d + n.tx, a[u + 1] = n.matB * h + n.matD * d + n.ty;
1508
+ return Vt();
1509
+ const i = new Float32Array(t.count * 2);
1510
+ for (let a = 0; a < t.count; a += 1) {
1511
+ const c = a * 2, _ = t.pos[c], f = t.pos[c + 1];
1512
+ i[c] = n.matA * _ + n.matC * f + n.tx, i[c + 1] = n.matB * _ + n.matD * f + n.ty;
1484
1513
  }
1485
- const r = ((c = o[n.insLayerIdx]) == null ? void 0 : c.visible) === !1, i = Cn(
1486
- ot(t),
1487
- (s) => r || s === e ? n.insLayerIdx : s
1514
+ const r = ((l = o[n.insLayerIdx]) == null ? void 0 : l.visible) === !1, s = vn(
1515
+ rt(t),
1516
+ (a) => r || a === e ? n.insLayerIdx : a
1488
1517
  );
1489
- return { pos: a, count: t.count, segments: i };
1518
+ return { pos: i, count: t.count, segments: s };
1490
1519
  }
1491
- function Pt(t) {
1492
- const n = t.reduce((r, i) => r + i.count, 0);
1520
+ function Dt(t) {
1521
+ const n = t.reduce((r, s) => r + s.count, 0);
1493
1522
  if (n === 0)
1494
- return It();
1523
+ return Vt();
1495
1524
  const e = new Float32Array(n * 2), o = [];
1496
- let a = 0;
1525
+ let i = 0;
1497
1526
  for (const r of t)
1498
- e.set(r.pos, a * 2), o.push(...Ht(ot(r), a)), a += r.count;
1499
- return { pos: e, count: n, segments: dt(o) };
1527
+ e.set(r.pos, i * 2), o.push(...qt(rt(r), i)), i += r.count;
1528
+ return { pos: e, count: n, segments: mt(o) };
1500
1529
  }
1501
- function qn(t, n) {
1530
+ function ne(t, n) {
1502
1531
  return t === n ? n : t;
1503
1532
  }
1504
- function Kn(t, n, e) {
1533
+ function ee(t, n, e) {
1505
1534
  return t === e ? n : t;
1506
1535
  }
1507
- function Wn(t, n) {
1508
- const e = new DataView(t), { versionMinor: o, sections: a } = mt(t), r = Wt(o), i = X(a, 1, "SCENE_META"), c = X(a, 2, "LAYER_TABLE"), s = X(a, 3, "STRING_TABLE"), u = X(a, 4, "BASE_GEOMETRY"), h = X(a, 5, "VARIANT_TABLE"), d = X(a, 6, "VARIANT_GEOMETRY"), _ = X(a, 7, "SCENE_INSTANCE_TABLE"), f = ut(a, 8), w = ut(a, 9), y = ut(a, 10), m = _t(t, i, "SCENE_META"), x = nn(m) ? Vt(m, h.length / 60) : null, G = en(m), N = G ? Dn(m) : null, R = Ke(m, x, G), P = G ? "nested_instanced_external_annotations" : x ? "nested_instanced_external" : "nested_instanced", B = new Uint8Array(t, s.offset, s.length), D = Yn(t, c, B), C = Number(m.layer0_index ?? 0), $ = Qt({
1509
- bounds: m.bounds ?? [0, 0, 0, 0],
1510
- entity_count: Number(m.entity_count ?? 0),
1511
- line_count: Number(m.base_line_count ?? 0),
1512
- fill_count: Number(m.base_fill_count ?? 0),
1513
- dot_count: Number(m.base_dot_count ?? 0),
1514
- layers: D,
1536
+ function oe(t, n, e) {
1537
+ const o = new DataView(t), i = e ? void 0 : Et(t), r = (e == null ? void 0 : e.versionMinor) ?? i.versionMinor, s = (e == null ? void 0 : e.sections) ?? i.sections, l = (e == null ? void 0 : e.groupLayerEncoding) ?? Qt(r), a = e ? e.sections.get(1) : P(s, 1, "SCENE_META"), c = e ? e.sections.get(2) : P(s, 2, "LAYER_TABLE"), _ = e ? e.sections.get(3) : P(s, 3, "STRING_TABLE"), f = e ? e.sections.get(4) : P(s, 4, "BASE_GEOMETRY"), d = e ? e.sections.get(5) : P(s, 5, "VARIANT_TABLE"), m = e ? e.sections.get(6) : P(s, 6, "VARIANT_GEOMETRY"), A = e ? e.sections.get(7) : P(s, 7, "SCENE_INSTANCE_TABLE"), y = (e == null ? void 0 : e.sections.get(8)) ?? dt(s, 8), x = (e == null ? void 0 : e.sections.get(9)) ?? dt(s, 9), h = (e == null ? void 0 : e.sections.get(10)) ?? dt(s, 10), R = (e == null ? void 0 : e.sceneMeta) ?? xt(t, a, "SCENE_META"), w = (e == null ? void 0 : e.externalVariants) ?? (rn(R) ? Tt(R, d.length / 60) : null), p = sn(R), v = (e == null ? void 0 : e.externalAnnotations) ?? (p ? Yn(R) : null), U = (e == null ? void 0 : e.geoMetaFeatures) ?? so(R, w, p), D = (e == null ? void 0 : e.geoMetaEncoding) ?? (p ? "nested_instanced_external_annotations" : w ? "nested_instanced_external" : "nested_instanced"), $ = (e == null ? void 0 : e.stringTable) ?? new Uint8Array(t, _.offset, _.length), M = e != null && e.layers ? [...e.layers] : jn(t, c, $), Y = (e == null ? void 0 : e.layer0Index) ?? Number(R.layer0_index ?? 0), z = (e == null ? void 0 : e.headerForValidation) ?? en({
1538
+ bounds: R.bounds ?? [0, 0, 0, 0],
1539
+ entity_count: Number(R.entity_count ?? 0),
1540
+ line_count: Number(R.base_line_count ?? 0),
1541
+ fill_count: Number(R.base_fill_count ?? 0),
1542
+ dot_count: Number(R.base_dot_count ?? 0),
1543
+ layers: M,
1515
1544
  texts: []
1516
1545
  });
1517
- Zn(C, $.layers);
1518
- const O = mo(t, e, u, r);
1546
+ ie(Y, z.layers);
1547
+ const S = (e == null ? void 0 : e.baseGeometry) ?? Ao(t, o, f, l);
1519
1548
  if (!n.loadBlocks) {
1520
- const g = zn(e, h, d, B, x), I = Z(t, _, "V3 SCENE_INSTANCE_TABLE"), F = Z(t, f, "V3 NESTED_INSTANCE_TABLE"), L = $t(t, w, B, "V3 SCENE_TEXT_TABLE"), Y = xo(y, "V3 VARIANT_TEXT_TABLE");
1521
- if (Number(m.variant_count ?? g.length) !== g.length)
1522
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1523
- if (Number(m.scene_instance_count ?? I.length) !== I.length)
1524
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1525
- if (Number(m.nested_instance_count ?? F.length) !== F.length)
1526
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1527
- if (Number(m.scene_text_count ?? L.length) !== L.length)
1528
- throw new l("E_GROUP_RANGE", "V3 scene text count mismatch");
1529
- if (Number(m.variant_text_count ?? Y) !== Y)
1530
- throw new l("E_GROUP_RANGE", "V3 variant text count mismatch");
1531
- for (const T of g) {
1532
- if (T.nestedStart + T.nestedCount > F.length)
1533
- throw new l("E_GROUP_RANGE", `V3 variant ${T.id} nested range exceeds table`);
1534
- if (T.textStart + T.textCount > Y)
1535
- throw new l("E_GROUP_RANGE", `V3 variant ${T.id} text range exceeds table`);
1549
+ const g = (e == null ? void 0 : e.variantHeaders) ?? Jt(o, d, m, $, w), I = (e == null ? void 0 : e.sceneInstances) ?? Z(t, A, "V3 SCENE_INSTANCE_TABLE"), k = (e == null ? void 0 : e.nestedInstances) ?? Z(t, y, "V3 NESTED_INSTANCE_TABLE"), L = (e == null ? void 0 : e.sceneTexts) ?? vt(t, x, $, "V3 SCENE_TEXT_TABLE"), F = (e == null ? void 0 : e.variantTextCount) ?? Io(h, "V3 VARIANT_TEXT_TABLE");
1550
+ if (Number(R.variant_count ?? g.length) !== g.length)
1551
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1552
+ if (Number(R.scene_instance_count ?? I.length) !== I.length)
1553
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1554
+ if (Number(R.nested_instance_count ?? k.length) !== k.length)
1555
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1556
+ if (Number(R.scene_text_count ?? L.length) !== L.length)
1557
+ throw new u("E_GROUP_RANGE", "V3 scene text count mismatch");
1558
+ if (Number(R.variant_text_count ?? F) !== F)
1559
+ throw new u("E_GROUP_RANGE", "V3 variant text count mismatch");
1560
+ for (const G of g) {
1561
+ if (G.nestedStart + G.nestedCount > k.length)
1562
+ throw new u("E_GROUP_RANGE", `V3 variant ${G.id} nested range exceeds table`);
1563
+ if (G.textStart + G.textCount > F)
1564
+ throw new u("E_GROUP_RANGE", `V3 variant ${G.id} text range exceeds table`);
1536
1565
  }
1537
- return At(I, F, (T) => {
1538
- if (!g[T.variantId])
1539
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${T.variantId}`);
1540
- Kt(T.insLayerIdx, D.length);
1566
+ return Rt(I, k, (G) => {
1567
+ if (!g[G.variantId])
1568
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${G.variantId}`);
1569
+ Zt(G.insLayerIdx, M.length);
1541
1570
  }), {
1542
1571
  meta: {
1543
- bounds: m.bounds ?? [0, 0, 0, 0],
1544
- entity_count: Number(m.entity_count ?? 0),
1545
- line_count: O.line.count,
1546
- fill_count: O.fill.count,
1547
- dot_count: O.dot.count,
1572
+ bounds: R.bounds ?? [0, 0, 0, 0],
1573
+ entity_count: Number(R.entity_count ?? 0),
1574
+ line_count: S.line.count,
1575
+ fill_count: S.fill.count,
1576
+ dot_count: S.dot.count,
1548
1577
  version: 3,
1549
- version_minor: o,
1550
- encoding: P,
1551
- ...R ? { features: R } : {},
1552
- ...x ? { external_variants: [...x] } : {},
1553
- ...N ? { external_annotations: N } : {},
1554
- layer0_index: C,
1555
- block_variants: g.map((T) => ({
1556
- id: T.id,
1557
- name: T.name,
1558
- line_count: T.line_count,
1559
- fill_count: T.fill_count,
1560
- dot_count: T.dot_count
1578
+ version_minor: r,
1579
+ encoding: D,
1580
+ ...U ? { features: U } : {},
1581
+ ...w ? { external_variants: [...w] } : {},
1582
+ ...v ? { external_annotations: v } : {},
1583
+ layer0_index: Y,
1584
+ block_variants: g.map((G) => ({
1585
+ id: G.id,
1586
+ name: G.name,
1587
+ line_count: G.line_count,
1588
+ fill_count: G.fill_count,
1589
+ dot_count: G.dot_count
1561
1590
  })),
1562
1591
  instance_count: I.length,
1563
- layers: D,
1592
+ layers: M,
1564
1593
  texts: L
1565
1594
  },
1566
1595
  header: {
1567
- ...$,
1568
- lineCount: O.line.count,
1569
- fillCount: O.fill.count,
1570
- dotCount: O.dot.count,
1596
+ ...z,
1597
+ lineCount: S.line.count,
1598
+ fillCount: S.fill.count,
1599
+ dotCount: S.dot.count,
1571
1600
  textCount: L.length,
1572
1601
  texts: L
1573
1602
  },
1574
1603
  decoded: {
1575
- baseLine: O.line,
1576
- baseFill: O.fill,
1577
- baseDot: O.dot,
1604
+ baseLine: S.line,
1605
+ baseFill: S.fill,
1606
+ baseDot: S.dot,
1578
1607
  variants: /* @__PURE__ */ new Map(),
1579
1608
  instances: [],
1580
1609
  instanceIdByVariantOrdinal: /* @__PURE__ */ new Map()
1581
1610
  }
1582
1611
  };
1583
1612
  }
1584
- const { variantsById: v, variants: K, snapshots: A } = ho(
1613
+ const N = e ? No(t, e, n) : Ro(
1585
1614
  t,
1586
- e,
1587
- h,
1615
+ o,
1588
1616
  d,
1589
- B,
1590
- x,
1591
- r,
1617
+ m,
1618
+ $,
1619
+ w,
1620
+ l,
1592
1621
  n
1593
- ), E = Z(t, _, "V3 SCENE_INSTANCE_TABLE"), p = Z(t, f, "V3 NESTED_INSTANCE_TABLE"), b = $t(t, w, B, "V3 SCENE_TEXT_TABLE"), S = $t(t, y, B, "V3 VARIANT_TEXT_TABLE");
1594
- if (Number(m.variant_count ?? v.length) !== v.length)
1595
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1596
- if (Number(m.scene_instance_count ?? E.length) !== E.length)
1597
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1598
- if (Number(m.nested_instance_count ?? p.length) !== p.length)
1599
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1600
- if (Number(m.scene_text_count ?? b.length) !== b.length)
1601
- throw new l("E_GROUP_RANGE", "V3 scene text count mismatch");
1602
- if (Number(m.variant_text_count ?? S.length) !== S.length)
1603
- throw new l("E_GROUP_RANGE", "V3 variant text count mismatch");
1604
- for (const g of v) {
1605
- if (g.nestedStart + g.nestedCount > p.length)
1606
- throw new l("E_GROUP_RANGE", `V3 variant ${g.id} nested range exceeds table`);
1607
- if (g.textStart + g.textCount > S.length)
1608
- throw new l("E_GROUP_RANGE", `V3 variant ${g.id} text range exceeds table`);
1622
+ ), { variantsById: E, variants: V, snapshots: T } = N, C = (e == null ? void 0 : e.sceneInstances) ?? Z(t, A, "V3 SCENE_INSTANCE_TABLE"), b = (e == null ? void 0 : e.nestedInstances) ?? Z(t, y, "V3 NESTED_INSTANCE_TABLE"), B = (e == null ? void 0 : e.sceneTexts) ?? vt(t, x, $, "V3 SCENE_TEXT_TABLE"), O = (e == null ? void 0 : e.variantTexts) ?? vt(t, h, $, "V3 VARIANT_TEXT_TABLE");
1623
+ if (Number(R.variant_count ?? E.length) !== E.length)
1624
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1625
+ if (Number(R.scene_instance_count ?? C.length) !== C.length)
1626
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1627
+ if (Number(R.nested_instance_count ?? b.length) !== b.length)
1628
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1629
+ if (Number(R.scene_text_count ?? B.length) !== B.length)
1630
+ throw new u("E_GROUP_RANGE", "V3 scene text count mismatch");
1631
+ if (Number(R.variant_text_count ?? O.length) !== O.length)
1632
+ throw new u("E_GROUP_RANGE", "V3 variant text count mismatch");
1633
+ for (const g of E) {
1634
+ if (g.nestedStart + g.nestedCount > b.length)
1635
+ throw new u("E_GROUP_RANGE", `V3 variant ${g.id} nested range exceeds table`);
1636
+ if (g.textStart + g.textCount > O.length)
1637
+ throw new u("E_GROUP_RANGE", `V3 variant ${g.id} text range exceeds table`);
1609
1638
  }
1610
- At(E, p, (g) => {
1611
- if (!v[g.variantId])
1612
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${g.variantId}`);
1613
- Kt(g.insLayerIdx, D.length);
1639
+ Rt(C, b, (g) => {
1640
+ if (!E[g.variantId])
1641
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${g.variantId}`);
1642
+ Zt(g.insLayerIdx, M.length);
1614
1643
  });
1615
- const M = /* @__PURE__ */ new Map();
1616
- for (const g of v)
1617
- M.set(
1618
- g.id,
1619
- S.slice(g.textStart, g.textStart + g.textCount)
1620
- );
1621
- const U = [], V = n.externalVariantDeltaOnly, k = V ? [] : [...b], z = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map(), ht = /* @__PURE__ */ new Map(), bt = (g, I) => {
1622
- z.set(g, Rt(z.get(g) ?? null, I));
1623
- }, Et = (g, I, F, L, Y, Q) => {
1624
- var fn;
1625
- if (Y > 64)
1626
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1627
- if (Q.has(g))
1628
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${g}`);
1629
- const T = v[g];
1630
- if (!T)
1631
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${g}`);
1632
- Q.add(g);
1633
- const tt = !n.requiredExternalVariantIds || n.requiredExternalVariantIds.has(g), W = V ? ((fn = n.requiredExternalVariantIds) == null ? void 0 : fn.has(g)) === !0 : tt;
1634
- let j = !1;
1635
- const dn = !!(T.line_count || T.fill_count || T.dot_count), ne = T.textCount > 0;
1636
- if (W && (dn || ne) && (U.push({
1644
+ const j = (e == null ? void 0 : e.variantTextsByVariantId) ?? (() => {
1645
+ const g = /* @__PURE__ */ new Map();
1646
+ for (const I of E)
1647
+ g.set(
1648
+ I.id,
1649
+ O.slice(I.textStart, I.textStart + I.textCount)
1650
+ );
1651
+ return g;
1652
+ })(), H = [], X = n.externalVariantDeltaOnly, gt = X ? [] : [...B], ct = /* @__PURE__ */ new Map(), it = /* @__PURE__ */ new Map(), un = /* @__PURE__ */ new Map(), le = (g, I) => {
1653
+ ct.set(g, pt(ct.get(g) ?? null, I));
1654
+ }, cn = (g, I, k, L, F, tt) => {
1655
+ var xn;
1656
+ if (F > 64)
1657
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1658
+ if (tt.has(g))
1659
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${g}`);
1660
+ const G = E[g];
1661
+ if (!G)
1662
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${g}`);
1663
+ tt.add(g);
1664
+ const nt = !n.requiredExternalVariantIds || n.requiredExternalVariantIds.has(g), W = X ? ((xn = n.requiredExternalVariantIds) == null ? void 0 : xn.has(g)) === !0 : nt;
1665
+ let q = !1;
1666
+ const En = !!(G.line_count || G.fill_count || G.dot_count), de = G.textCount > 0;
1667
+ if (W && (En || de) && (H.push({
1637
1668
  instanceId: I.instanceId,
1638
1669
  variantId: g,
1639
1670
  matA: I.matA,
@@ -1643,29 +1674,29 @@ function Wn(t, n) {
1643
1674
  tx: I.tx,
1644
1675
  ty: I.ty,
1645
1676
  insLayerIdx: I.insLayerIdx
1646
- }), dn && bt(I.instanceId, T.bbox ? Jn(T.bbox, I) : null), j = !0), W) {
1647
- T.textCount > 0 && (j = !0);
1648
- for (let nt = 0; nt < T.textCount; nt += 1) {
1649
- const at = jn(S[T.textStart + nt], I, C, $.layers);
1650
- k.push({
1651
- ...at,
1652
- iv: F,
1677
+ }), En && le(I.instanceId, G.bbox ? re(G.bbox, I) : null), q = !0), W) {
1678
+ G.textCount > 0 && (q = !0);
1679
+ for (let et = 0; et < G.textCount; et += 1) {
1680
+ const st = te(O[G.textStart + et], I, Y, z.layers);
1681
+ gt.push({
1682
+ ...st,
1683
+ iv: k,
1653
1684
  io: L
1654
1685
  });
1655
1686
  }
1656
1687
  }
1657
- for (let nt = 0; nt < T.nestedCount; nt += 1) {
1658
- const at = p[T.nestedStart + nt], ee = Kn(at.insLayerIdx, I.insLayerIdx, C), oe = an(at, T, v[at.variantId]), re = Hn(I, oe, I.instanceId, ee);
1659
- j = Et(at.variantId, re, F, L, Y + 1, Q) || j;
1688
+ for (let et = 0; et < G.nestedCount; et += 1) {
1689
+ const st = b[G.nestedStart + et], me = ee(st.insLayerIdx, I.insLayerIdx, Y), _e = ln(st, G, E[st.variantId]), Ee = Qn(I, _e, I.instanceId, me);
1690
+ q = cn(st.variantId, Ee, k, L, F + 1, tt) || q;
1660
1691
  }
1661
- return Q.delete(g), j;
1662
- }, Bt = /* @__PURE__ */ new Map();
1663
- E.forEach((g, I) => {
1664
- if (!v[g.variantId])
1665
- throw new l("E_GROUP_RANGE", `Unknown V3 scene variantId ${g.variantId}`);
1666
- const L = ht.get(g.variantId) ?? 0;
1667
- ht.set(g.variantId, L + 1), H.set(`${g.variantId}:${L}`, I);
1668
- const Y = qn(g.insLayerIdx, C), Q = {
1692
+ return tt.delete(g), q;
1693
+ }, St = /* @__PURE__ */ new Map();
1694
+ C.forEach((g, I) => {
1695
+ if (!E[g.variantId])
1696
+ throw new u("E_GROUP_RANGE", `Unknown V3 scene variantId ${g.variantId}`);
1697
+ const L = un.get(g.variantId) ?? 0;
1698
+ un.set(g.variantId, L + 1), it.set(`${g.variantId}:${L}`, I);
1699
+ const F = ne(g.insLayerIdx, Y), tt = {
1669
1700
  instanceId: I,
1670
1701
  variantId: g.variantId,
1671
1702
  matA: g.matA,
@@ -1674,207 +1705,247 @@ function Wn(t, n) {
1674
1705
  matD: g.matD,
1675
1706
  tx: g.tx,
1676
1707
  ty: g.ty,
1677
- insLayerIdx: Y
1678
- }, T = Et(g.variantId, Q, g.variantId, L, 0, /* @__PURE__ */ new Set());
1679
- if (V && !T)
1708
+ insLayerIdx: F
1709
+ }, G = cn(g.variantId, tt, g.variantId, L, 0, /* @__PURE__ */ new Set());
1710
+ if (X && !G)
1680
1711
  return;
1681
- let tt = Bt.get(Y);
1682
- tt || (tt = /* @__PURE__ */ new Map(), Bt.set(Y, tt));
1683
- let W = tt.get(g.variantId);
1684
- W || (W = { count: 0, bboxes: [], inserts: [] }, tt.set(g.variantId, W)), W.count += 1;
1685
- const j = z.get(I) ?? null;
1686
- j && W.bboxes.push(j), W.inserts.push({
1712
+ let nt = St.get(F);
1713
+ nt || (nt = /* @__PURE__ */ new Map(), St.set(F, nt));
1714
+ let W = nt.get(g.variantId);
1715
+ W || (W = { count: 0, bboxes: [], inserts: [] }, nt.set(g.variantId, W)), W.count += 1;
1716
+ const q = ct.get(I) ?? null;
1717
+ q && W.bboxes.push(q), W.inserts.push({
1687
1718
  instanceId: I,
1688
1719
  variantId: g.variantId,
1689
1720
  label: `#${I + 1} (${g.tx.toFixed(1)}, ${g.ty.toFixed(1)})`,
1690
1721
  tx: g.tx,
1691
1722
  ty: g.ty,
1692
- canHighlight: j !== null,
1693
- ...j ? { bbox: j } : {}
1723
+ canHighlight: q !== null,
1724
+ ...q ? { bbox: q } : {}
1694
1725
  });
1695
1726
  });
1696
- const sn = /* @__PURE__ */ new Map();
1697
- for (const [g, I] of Bt) {
1698
- const F = [];
1699
- for (const [L, Y] of I)
1700
- F.push({
1727
+ const fn = /* @__PURE__ */ new Map();
1728
+ for (const [g, I] of St) {
1729
+ const k = [];
1730
+ for (const [L, F] of I)
1731
+ k.push({
1701
1732
  variantId: L,
1702
- blockName: Mn(v[L], L),
1703
- instanceCount: Y.count,
1704
- bboxes: Y.bboxes,
1705
- inserts: Y.inserts
1733
+ blockName: Ln(E[L], L),
1734
+ instanceCount: F.count,
1735
+ bboxes: F.bboxes,
1736
+ inserts: F.inserts
1706
1737
  });
1707
- F.sort((L, Y) => Y.instanceCount - L.instanceCount), sn.set(g, F);
1738
+ k.sort((L, F) => F.instanceCount - L.instanceCount), fn.set(g, k);
1708
1739
  }
1709
- let cn = V ? 0 : O.line.count, ln = V ? 0 : O.fill.count, un = V ? 0 : O.dot.count;
1710
- for (const g of U) {
1711
- const I = v[g.variantId];
1712
- n.deferExternalVariantGeometry && I.lineSnapshot.count === 0 && I.fillSnapshot.count === 0 && I.dotSnapshot.count === 0 || !Nt(g.instanceId, n) || (cn += I.line_count, ln += I.fill_count, un += I.dot_count);
1740
+ let dn = X ? 0 : S.line.count, mn = X ? 0 : S.fill.count, _n = X ? 0 : S.dot.count;
1741
+ for (const g of H) {
1742
+ const I = E[g.variantId];
1743
+ n.deferExternalVariantGeometry && I.lineSnapshot.count === 0 && I.fillSnapshot.count === 0 && I.dotSnapshot.count === 0 || !Nt(g.instanceId, n) || (dn += I.line_count, mn += I.fill_count, _n += I.dot_count);
1713
1744
  }
1714
- const xt = ke(k, H, n), Qn = {
1715
- bounds: m.bounds ?? [0, 0, 0, 0],
1716
- entity_count: V ? 0 : Number(m.entity_count ?? 0),
1717
- line_count: O.line.count,
1718
- fill_count: O.fill.count,
1719
- dot_count: O.dot.count,
1745
+ const ht = no(gt, it, n), ue = {
1746
+ bounds: R.bounds ?? [0, 0, 0, 0],
1747
+ entity_count: X ? 0 : Number(R.entity_count ?? 0),
1748
+ line_count: S.line.count,
1749
+ fill_count: S.fill.count,
1750
+ dot_count: S.dot.count,
1720
1751
  version: 3,
1721
- version_minor: o,
1722
- encoding: P,
1723
- ...R ? { features: R } : {},
1724
- ...x ? { external_variants: [...x] } : {},
1725
- ...N ? { external_annotations: N } : {},
1726
- layer0_index: C,
1727
- block_variants: v.map((g) => ({
1752
+ version_minor: r,
1753
+ encoding: D,
1754
+ ...U ? { features: U } : {},
1755
+ ...w ? { external_variants: [...w] } : {},
1756
+ ...v ? { external_annotations: v } : {},
1757
+ layer0_index: Y,
1758
+ block_variants: E.map((g) => ({
1728
1759
  id: g.id,
1729
1760
  name: g.name,
1730
1761
  line_count: g.sourceLineCount,
1731
1762
  fill_count: g.sourceFillCount,
1732
1763
  dot_count: g.sourceDotCount
1733
1764
  })),
1734
- instance_count: E.length,
1735
- layers: D,
1736
- texts: xt
1737
- }, te = {
1738
- ...$,
1739
- entityCount: V ? 0 : $.entityCount,
1740
- lineCount: cn,
1741
- fillCount: ln,
1742
- dotCount: un,
1743
- textCount: xt.length,
1744
- texts: xt,
1765
+ instance_count: C.length,
1766
+ layers: M,
1767
+ texts: ht
1768
+ }, ce = {
1769
+ ...z,
1770
+ entityCount: X ? 0 : z.entityCount,
1771
+ lineCount: dn,
1772
+ fillCount: mn,
1773
+ dotCount: _n,
1774
+ textCount: ht.length,
1775
+ texts: ht,
1745
1776
  ...n.loadBlocks ? {
1746
- layerBlockUsages: sn,
1747
- insertRuntime: He(
1748
- C,
1749
- v,
1750
- A,
1751
- M,
1752
- U,
1753
- xt,
1754
- H
1777
+ layerBlockUsages: fn,
1778
+ insertRuntime: oo(
1779
+ Y,
1780
+ E,
1781
+ T,
1782
+ j,
1783
+ H,
1784
+ ht,
1785
+ it
1755
1786
  )
1756
1787
  } : {}
1757
- };
1788
+ }, fe = e ?? (n.cacheDocument ? (() => {
1789
+ const g = /* @__PURE__ */ new Map();
1790
+ for (const [I, k] of V)
1791
+ w != null && w[I] || g.set(I, {
1792
+ line: { chunk: k.line, snapshot: T[I].line },
1793
+ fill: { chunk: k.fill, snapshot: T[I].fill },
1794
+ dot: { chunk: k.dot, snapshot: T[I].dot }
1795
+ });
1796
+ return {
1797
+ kind: "dxb3-v3",
1798
+ buffer: t,
1799
+ versionMinor: r,
1800
+ sections: s,
1801
+ groupLayerEncoding: l,
1802
+ sceneMeta: R,
1803
+ externalVariants: w,
1804
+ externalAnnotations: v,
1805
+ geoMetaFeatures: U,
1806
+ geoMetaEncoding: D,
1807
+ stringTable: $,
1808
+ layers: M,
1809
+ layer0Index: Y,
1810
+ headerForValidation: z,
1811
+ baseGeometry: S,
1812
+ variantHeaders: Jt(
1813
+ o,
1814
+ d,
1815
+ m,
1816
+ $,
1817
+ w
1818
+ ),
1819
+ internalVariants: g,
1820
+ sceneInstances: C,
1821
+ nestedInstances: b,
1822
+ sceneTexts: B,
1823
+ variantTexts: O,
1824
+ variantTextCount: O.length,
1825
+ variantTextsByVariantId: j
1826
+ };
1827
+ })() : void 0);
1758
1828
  return {
1759
- meta: Qn,
1760
- header: te,
1829
+ meta: ue,
1830
+ header: ce,
1831
+ documentCache: fe,
1761
1832
  decoded: {
1762
- baseLine: V ? Xt() : O.line,
1763
- baseFill: V ? Xt() : O.fill,
1764
- baseDot: V ? Xt() : O.dot,
1765
- variants: K,
1766
- instances: U,
1767
- instanceIdByVariantOrdinal: H
1833
+ baseLine: X ? kt() : S.line,
1834
+ baseFill: X ? kt() : S.fill,
1835
+ baseDot: X ? kt() : S.dot,
1836
+ variants: V,
1837
+ instances: H,
1838
+ instanceIdByVariantOrdinal: it
1768
1839
  }
1769
1840
  };
1770
1841
  }
1771
- function Nn(t) {
1842
+ function Vn(t) {
1772
1843
  return "annotation" in t && (t.annotation.line_count > 0 || t.annotation.fill_count > 0 || t.annotation.dot_count > 0 || t.annotation.text_count > 0);
1773
1844
  }
1774
- function yo(t, n) {
1845
+ function Go(t, n) {
1775
1846
  if (n.line.count !== t.annotation.line_count || n.fill.count !== t.annotation.fill_count || n.dot.count !== t.annotation.dot_count || n.texts.length !== t.annotation.text_count)
1776
- throw new l(
1847
+ throw new u(
1777
1848
  "E_GROUP_RANGE",
1778
1849
  `V3.3 external variant ${t.id} annotation count mismatch`
1779
1850
  );
1780
1851
  }
1781
- function wo(t, n, e, o, a, r) {
1852
+ function To(t, n, e, o, i, r) {
1782
1853
  return {
1783
- line: Mt(t.line, n, e, o),
1784
- fill: Mt(t.fill, n, e, o),
1785
- dot: Mt(t.dot, n, e, o),
1786
- texts: t.texts.map((i) => ({
1787
- ...jn(i, n, e, o),
1788
- iv: a,
1854
+ line: Pt(t.line, n, e, o),
1855
+ fill: Pt(t.fill, n, e, o),
1856
+ dot: Pt(t.dot, n, e, o),
1857
+ texts: t.texts.map((s) => ({
1858
+ ...te(s, n, e, o),
1859
+ iv: i,
1789
1860
  io: r
1790
1861
  }))
1791
1862
  };
1792
1863
  }
1793
- function Po(t, n) {
1794
- if (!rt(t))
1864
+ function Yo(t, n) {
1865
+ if (!Q(t))
1795
1866
  return null;
1796
- const e = new DataView(t), { sections: o } = mt(t), a = X(o, 1, "SCENE_META"), r = X(o, 2, "LAYER_TABLE"), i = X(o, 3, "STRING_TABLE"), c = X(o, 5, "VARIANT_TABLE"), s = X(o, 6, "VARIANT_GEOMETRY"), u = X(o, 7, "SCENE_INSTANCE_TABLE"), h = ut(o, 8), d = _t(t, a, "SCENE_META");
1797
- if (!en(d))
1867
+ const e = new DataView(t), { sections: o } = Et(t), i = P(o, 1, "SCENE_META"), r = P(o, 2, "LAYER_TABLE"), s = P(o, 3, "STRING_TABLE"), l = P(o, 5, "VARIANT_TABLE"), a = P(o, 6, "VARIANT_GEOMETRY"), c = P(o, 7, "SCENE_INSTANCE_TABLE"), _ = dt(o, 8), f = xt(t, i, "SCENE_META");
1868
+ if (!sn(f))
1798
1869
  return null;
1799
- const _ = Vt(d, c.length / 60);
1800
- if (!_.some(Nn))
1870
+ const d = Tt(f, l.length / 60);
1871
+ if (!d.some(Vn))
1801
1872
  return null;
1802
- const f = new Uint8Array(t, i.offset, i.length), w = Yn(t, r, f), y = Number(d.layer0_index ?? 0), m = Qt({
1803
- bounds: d.bounds ?? [0, 0, 0, 0],
1804
- entity_count: Number(d.entity_count ?? 0),
1805
- line_count: Number(d.base_line_count ?? 0),
1806
- fill_count: Number(d.base_fill_count ?? 0),
1807
- dot_count: Number(d.base_dot_count ?? 0),
1808
- layers: w,
1873
+ const m = new Uint8Array(t, s.offset, s.length), A = jn(t, r, m), y = Number(f.layer0_index ?? 0), x = en({
1874
+ bounds: f.bounds ?? [0, 0, 0, 0],
1875
+ entity_count: Number(f.entity_count ?? 0),
1876
+ line_count: Number(f.base_line_count ?? 0),
1877
+ fill_count: Number(f.base_fill_count ?? 0),
1878
+ dot_count: Number(f.base_dot_count ?? 0),
1879
+ layers: A,
1809
1880
  texts: []
1810
1881
  });
1811
- Zn(y, m.layers);
1812
- const x = zn(e, c, s, f, _), G = Z(t, u, "V3 SCENE_INSTANCE_TABLE"), N = Z(t, h, "V3 NESTED_INSTANCE_TABLE");
1813
- if (Number(d.variant_count ?? x.length) !== x.length)
1814
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1815
- if (Number(d.scene_instance_count ?? G.length) !== G.length)
1816
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1817
- if (Number(d.nested_instance_count ?? N.length) !== N.length)
1818
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1819
- for (const E of x)
1820
- if (E.nestedStart + E.nestedCount > N.length)
1821
- throw new l("E_GROUP_RANGE", `V3 variant ${E.id} nested range exceeds table`);
1822
- At(G, N, (E) => {
1823
- if (!x[E.variantId])
1824
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${E.variantId}`);
1825
- Kt(E.insLayerIdx, w.length);
1882
+ ie(y, x.layers);
1883
+ const h = Jt(e, l, a, m, d), R = Z(t, c, "V3 SCENE_INSTANCE_TABLE"), w = Z(t, _, "V3 NESTED_INSTANCE_TABLE");
1884
+ if (Number(f.variant_count ?? h.length) !== h.length)
1885
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1886
+ if (Number(f.scene_instance_count ?? R.length) !== R.length)
1887
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1888
+ if (Number(f.nested_instance_count ?? w.length) !== w.length)
1889
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1890
+ for (const E of h)
1891
+ if (E.nestedStart + E.nestedCount > w.length)
1892
+ throw new u("E_GROUP_RANGE", `V3 variant ${E.id} nested range exceeds table`);
1893
+ Rt(R, w, (E) => {
1894
+ if (!h[E.variantId])
1895
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${E.variantId}`);
1896
+ Zt(E.insLayerIdx, A.length);
1826
1897
  });
1827
- const R = /* @__PURE__ */ new Map(), P = (E) => {
1828
- var U;
1829
- const p = _[E];
1830
- if (!p || !Nn(p))
1898
+ const p = /* @__PURE__ */ new Map(), v = (E) => {
1899
+ var B;
1900
+ const V = d[E];
1901
+ if (!V || !Vn(V))
1831
1902
  return null;
1832
- const b = R.get(E);
1833
- if (b)
1834
- return b;
1835
- const S = (U = n == null ? void 0 : n.externalVariantBuffers) == null ? void 0 : U.get(p.id);
1836
- if (!S)
1903
+ const T = p.get(E);
1904
+ if (T)
1905
+ return T;
1906
+ const C = (B = n == null ? void 0 : n.externalVariantBuffers) == null ? void 0 : B.get(V.id);
1907
+ if (!C)
1837
1908
  return null;
1838
- if (S.byteLength !== p.raw_size)
1839
- throw new l(
1909
+ if (C.byteLength !== V.raw_size)
1910
+ throw new u(
1840
1911
  "E_GROUP_RANGE",
1841
- `V3.3 annotation sidecar ${p.id} raw_size mismatch: manifest=${p.raw_size}, sidecar=${S.byteLength}`
1912
+ `V3.3 annotation sidecar ${V.id} raw_size mismatch: manifest=${V.raw_size}, sidecar=${C.byteLength}`
1842
1913
  );
1843
- const M = be(S);
1844
- return yo(p, M), R.set(E, M), M;
1845
- }, B = [], D = [], C = [], $ = [], O = (n == null ? void 0 : n.hiddenInstanceIds) ?? /* @__PURE__ */ new Set(), v = (E, p, b, S) => {
1846
- const M = wo(
1914
+ const b = Xe(C);
1915
+ return Go(V, b), p.set(E, b), b;
1916
+ }, U = [], D = [], $ = [], M = [], Y = (n == null ? void 0 : n.hiddenInstanceIds) ?? /* @__PURE__ */ new Set(), z = (E, V, T, C) => {
1917
+ const b = To(
1847
1918
  E,
1848
- p,
1919
+ V,
1849
1920
  y,
1850
- m.layers,
1851
- b,
1852
- S
1921
+ x.layers,
1922
+ T,
1923
+ C
1853
1924
  );
1854
- B.push(M.line), D.push(M.fill), C.push(M.dot), $.push(...M.texts);
1855
- }, K = (E, p, b, S, M, U) => {
1856
- if (M > 64)
1857
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1858
- if (U.has(E))
1859
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${E}`);
1860
- const V = x[E];
1861
- if (!V)
1862
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${E}`);
1863
- U.add(E);
1864
- const k = P(E);
1865
- k && v(k, p, b, S);
1866
- for (let z = 0; z < V.nestedCount; z += 1) {
1867
- const H = N[V.nestedStart + z], ht = Kn(H.insLayerIdx, p.insLayerIdx, y), bt = an(H, V, x[H.variantId]), Et = Hn(p, bt, p.instanceId, ht);
1868
- K(H.variantId, Et, b, S, M + 1, U);
1925
+ U.push(b.line), D.push(b.fill), $.push(b.dot), M.push(...b.texts);
1926
+ }, S = (E, V, T, C, b, B) => {
1927
+ if (b > 64)
1928
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1929
+ if (B.has(E))
1930
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${E}`);
1931
+ const O = h[E];
1932
+ if (!O)
1933
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${E}`);
1934
+ B.add(E);
1935
+ const j = v(E);
1936
+ j && z(j, V, T, C);
1937
+ for (let H = 0; H < O.nestedCount; H += 1) {
1938
+ const X = w[O.nestedStart + H], gt = ee(X.insLayerIdx, V.insLayerIdx, y), ct = ln(X, O, h[X.variantId]), it = Qn(V, ct, V.instanceId, gt);
1939
+ S(X.variantId, it, T, C, b + 1, B);
1869
1940
  }
1870
- U.delete(E);
1871
- }, A = /* @__PURE__ */ new Map();
1872
- return G.forEach((E, p) => {
1873
- const b = A.get(E.variantId) ?? 0;
1874
- if (A.set(E.variantId, b + 1), O.has(p))
1941
+ B.delete(E);
1942
+ }, N = /* @__PURE__ */ new Map();
1943
+ return R.forEach((E, V) => {
1944
+ const T = N.get(E.variantId) ?? 0;
1945
+ if (N.set(E.variantId, T + 1), Y.has(V))
1875
1946
  return;
1876
- const S = qn(E.insLayerIdx, y), M = {
1877
- instanceId: p,
1947
+ const C = ne(E.insLayerIdx, y), b = {
1948
+ instanceId: V,
1878
1949
  variantId: E.variantId,
1879
1950
  matA: E.matA,
1880
1951
  matB: E.matB,
@@ -1882,30 +1953,30 @@ function Po(t, n) {
1882
1953
  matD: E.matD,
1883
1954
  tx: E.tx,
1884
1955
  ty: E.ty,
1885
- insLayerIdx: S
1956
+ insLayerIdx: C
1886
1957
  };
1887
- K(E.variantId, M, E.variantId, b, 0, /* @__PURE__ */ new Set());
1888
- }), B.every((E) => E.count === 0) && D.every((E) => E.count === 0) && C.every((E) => E.count === 0) && $.length === 0 ? null : {
1889
- line: Pt(B),
1890
- fill: Pt(D),
1891
- dot: Pt(C),
1892
- texts: $
1958
+ S(E.variantId, b, E.variantId, T, 0, /* @__PURE__ */ new Set());
1959
+ }), U.every((E) => E.count === 0) && D.every((E) => E.count === 0) && $.every((E) => E.count === 0) && M.length === 0 ? null : {
1960
+ line: Dt(U),
1961
+ fill: Dt(D),
1962
+ dot: Dt($),
1963
+ texts: M
1893
1964
  };
1894
1965
  }
1895
- function Rt(t, n) {
1896
- return me(t, n);
1966
+ function pt(t, n) {
1967
+ return pe(t, n);
1897
1968
  }
1898
- function Jn(t, n) {
1899
- return Bn(t, n);
1969
+ function re(t, n) {
1970
+ return On(t, n);
1900
1971
  }
1901
- function Rn(t) {
1902
- return xe(t);
1972
+ function Gn(t) {
1973
+ return Te(t);
1903
1974
  }
1904
- function pn(t, n) {
1905
- return ge(t, n);
1975
+ function Tn(t, n) {
1976
+ return be(t, n);
1906
1977
  }
1907
- function pt(t, n) {
1908
- return Jn(t, {
1978
+ function It(t, n) {
1979
+ return re(t, {
1909
1980
  variantId: n.variantId,
1910
1981
  matA: n.matA,
1911
1982
  matB: n.matB,
@@ -1916,168 +1987,168 @@ function pt(t, n) {
1916
1987
  insLayerIdx: n.insLayerIdx
1917
1988
  });
1918
1989
  }
1919
- function an(t, n, e) {
1990
+ function ln(t, n, e) {
1920
1991
  if (!(e != null && e.bbox) || !n.bbox)
1921
1992
  return t;
1922
- const o = n.precisionOriginX, a = n.precisionOriginY;
1923
- if (!Number.isFinite(o) || !Number.isFinite(a) || o === 0 && a === 0)
1993
+ const o = n.precisionOriginX, i = n.precisionOriginY;
1994
+ if (!Number.isFinite(o) || !Number.isFinite(i) || o === 0 && i === 0)
1924
1995
  return t;
1925
1996
  const r = {
1926
1997
  ...t,
1927
1998
  tx: t.tx - o,
1928
- ty: t.ty - a
1929
- }, i = pt(e.bbox, t), c = pt(e.bbox, r), s = Math.max(Rn(n.bbox), Rn(e.bbox), 1), u = Math.hypot(o, a), h = Math.hypot(t.tx, t.ty), d = Math.hypot(r.tx, r.ty);
1930
- if (u <= s * 16 || h <= s * 16)
1999
+ ty: t.ty - i
2000
+ }, s = It(e.bbox, t), l = It(e.bbox, r), a = Math.max(Gn(n.bbox), Gn(e.bbox), 1), c = Math.hypot(o, i), _ = Math.hypot(t.tx, t.ty), f = Math.hypot(r.tx, r.ty);
2001
+ if (c <= a * 16 || _ <= a * 16)
1931
2002
  return t;
1932
- const _ = pn(n.bbox, i), f = pn(n.bbox, c);
1933
- return _ > s * 16 && f * 4 < _ && d * 4 < h ? r : t;
2003
+ const d = Tn(n.bbox, s), m = Tn(n.bbox, l);
2004
+ return d > a * 16 && m * 4 < d && f * 4 < _ ? r : t;
1934
2005
  }
1935
- function Kt(t, n) {
2006
+ function Zt(t, n) {
1936
2007
  if (t >= n)
1937
- throw new l("E_GROUP_RANGE", `Instance layer index ${t} exceeds layer count ${n}`);
2008
+ throw new u("E_GROUP_RANGE", `Instance layer index ${t} exceeds layer count ${n}`);
1938
2009
  }
1939
- function Zn(t, n) {
2010
+ function ie(t, n) {
1940
2011
  if (!Number.isInteger(t) || t < 0 || t >= n.length)
1941
- throw new l("E_GROUP_RANGE", `layer0_index out of range: ${t}`);
2012
+ throw new u("E_GROUP_RANGE", `layer0_index out of range: ${t}`);
1942
2013
  if (n[t].name !== "0")
1943
- throw new l("E_GROUP_RANGE", `layer0_index must reference layer "0": ${t}`);
2014
+ throw new u("E_GROUP_RANGE", `layer0_index must reference layer "0": ${t}`);
1944
2015
  }
1945
- function Ao(t) {
2016
+ function bo(t) {
1946
2017
  if (t !== 0)
1947
- throw new l("E_GROUP_RANGE", `Instance flags must be zero for Stage 1, found ${t}`);
2018
+ throw new u("E_GROUP_RANGE", `Instance flags must be zero for Stage 1, found ${t}`);
1948
2019
  }
1949
- function* No(t, n, e, o, a) {
2020
+ function* Bo(t, n, e, o, i) {
1950
2021
  let r = e;
1951
- const i = [
2022
+ const s = [
1952
2023
  { kind: "line", count: o.lineCount },
1953
2024
  { kind: "fill", count: o.fillCount },
1954
2025
  { kind: "dot", count: o.dotCount }
1955
2026
  ];
1956
- for (const c of i) {
1957
- const s = de(t, n, r, c.count);
2027
+ for (const l of s) {
2028
+ const a = Re(t, n, r, l.count);
1958
2029
  for (; ; ) {
1959
- const u = s.next();
1960
- if (u.done) {
1961
- r = u.value;
2030
+ const c = a.next();
2031
+ if (c.done) {
2032
+ r = c.value;
1962
2033
  break;
1963
2034
  }
1964
- yield { kind: c.kind, payload: u.value };
2035
+ yield { kind: l.kind, payload: c.value };
1965
2036
  }
1966
2037
  }
1967
2038
  if (r !== t.byteLength)
1968
- throw new l("E_GROUP_RANGE", `Trailing bytes detected: offset=${r}, size=${t.byteLength}`);
1969
- for (const c of o.texts)
1970
- yield { kind: "text", payload: c };
2039
+ throw new u("E_GROUP_RANGE", `Trailing bytes detected: offset=${r}, size=${t.byteLength}`);
2040
+ for (const l of o.texts)
2041
+ yield { kind: "text", payload: l };
1971
2042
  }
1972
- function* Ro(t, n, e, o) {
1973
- yield* No(t, n, e, o);
2043
+ function* Uo(t, n, e, o) {
2044
+ yield* Bo(t, n, e, o);
1974
2045
  }
1975
- function Dt(t, n, e, o, a, r, i) {
1976
- let c = t.count, s = 0;
1977
- for (const f of e) {
1978
- if (!Nt(f.instanceId, i))
2046
+ function Xt(t, n, e, o, i, r, s) {
2047
+ let l = t.count, a = 0;
2048
+ for (const m of e) {
2049
+ if (!Nt(m.instanceId, s))
1979
2050
  continue;
1980
- const w = n.get(f.variantId);
1981
- if (!w)
1982
- throw new l("E_GROUP_RANGE", `Unknown variantId ${f.variantId}`);
1983
- const y = w[o].count;
1984
- s += y, c += y;
2051
+ const A = n.get(m.variantId);
2052
+ if (!A)
2053
+ throw new u("E_GROUP_RANGE", `Unknown variantId ${m.variantId}`);
2054
+ const y = A[o].count;
2055
+ a += y, l += y;
1985
2056
  }
1986
- if ($n(i, o, s), c === 0)
1987
- return It();
1988
- const u = new Float32Array(c * 2), h = [];
1989
- let d = 0;
1990
- ((f) => {
1991
- u.set(f.pos, d * 2), h.push(...Ht(ot(f), d)), d += f.count;
2057
+ if (Xn(s, o, a), l === 0)
2058
+ return Vt();
2059
+ const c = new Float32Array(l * 2), _ = [];
2060
+ let f = 0;
2061
+ ((m) => {
2062
+ c.set(m.pos, f * 2), _.push(...qt(rt(m), f)), f += m.count;
1992
2063
  })(t);
1993
- for (const f of e) {
1994
- if (!Nt(f.instanceId, i))
2064
+ for (const m of e) {
2065
+ if (!Nt(m.instanceId, s))
1995
2066
  continue;
1996
- const w = n.get(f.variantId);
1997
- if (!w)
1998
- throw new l("E_GROUP_RANGE", `Unknown variantId ${f.variantId}`);
1999
- const y = w[o], m = r[f.insLayerIdx].visible === !1;
2000
- for (let x = 0; x < y.count; x += 1) {
2001
- const G = x * 2, R = (d + x) * 2, P = y.pos[G], B = y.pos[G + 1];
2002
- u[R] = f.matA * P + f.matC * B + f.tx, u[R + 1] = f.matB * P + f.matD * B + f.ty;
2067
+ const A = n.get(m.variantId);
2068
+ if (!A)
2069
+ throw new u("E_GROUP_RANGE", `Unknown variantId ${m.variantId}`);
2070
+ const y = A[o], x = r[m.insLayerIdx].visible === !1;
2071
+ for (let h = 0; h < y.count; h += 1) {
2072
+ const R = h * 2, p = (f + h) * 2, v = y.pos[R], U = y.pos[R + 1];
2073
+ c[p] = m.matA * v + m.matC * U + m.tx, c[p + 1] = m.matB * v + m.matD * U + m.ty;
2003
2074
  }
2004
- h.push(...Ht(
2005
- Cn(
2006
- ot(y),
2007
- (x) => m || x === a ? f.insLayerIdx : x
2075
+ _.push(...qt(
2076
+ vn(
2077
+ rt(y),
2078
+ (h) => x || h === i ? m.insLayerIdx : h
2008
2079
  ),
2009
- d
2010
- )), d += y.count;
2080
+ f
2081
+ )), f += y.count;
2011
2082
  }
2012
- return { pos: u, count: c, segments: dt(h) };
2083
+ return { pos: c, count: l, segments: mt(_) };
2013
2084
  }
2014
- function* vt(t, n, e, o, a, r, i, c) {
2015
- if ($n(c, t, Math.max(0, n - e.count)), n === 0) {
2016
- yield { kind: t, payload: It() };
2085
+ function* Lt(t, n, e, o, i, r, s, l) {
2086
+ if (Xn(l, t, Math.max(0, n - e.count)), n === 0) {
2087
+ yield { kind: t, payload: Vt() };
2017
2088
  return;
2018
2089
  }
2019
- const s = Lt;
2020
- let u = new Float32Array(s * 2), h = [], d = 0, _ = 0;
2021
- const f = function* () {
2022
- if (d <= 0)
2090
+ const a = Yt;
2091
+ let c = new Float32Array(a * 2), _ = [], f = 0, d = 0;
2092
+ const m = function* () {
2093
+ if (f <= 0)
2023
2094
  return;
2024
- const m = d === s ? { pos: u, count: d, segments: dt(h) } : { pos: u.slice(0, d * 2), count: d, segments: dt(h) };
2025
- yield { kind: t, payload: m }, _ += d, d = 0, u = new Float32Array(s * 2), h = [];
2026
- }, w = (m, x, G, N) => {
2027
- if (m <= 0)
2095
+ const x = f === a ? { pos: c, count: f, segments: mt(_) } : { pos: c.slice(0, f * 2), count: f, segments: mt(_) };
2096
+ yield { kind: t, payload: x }, d += f, f = 0, c = new Float32Array(a * 2), _ = [];
2097
+ }, A = (x, h, R, w) => {
2098
+ if (x <= 0)
2028
2099
  return;
2029
- const R = h[h.length - 1];
2030
- if (R && R.startVertex + R.vertexCount === d && R.layerIndex === G && R.color[0] === x[0] && R.color[1] === x[1] && R.color[2] === x[2] && R.lineweightPx === N) {
2031
- h[h.length - 1] = {
2032
- ...R,
2033
- vertexCount: R.vertexCount + m
2100
+ const p = _[_.length - 1];
2101
+ if (p && p.startVertex + p.vertexCount === f && p.layerIndex === R && p.color[0] === h[0] && p.color[1] === h[1] && p.color[2] === h[2] && p.lineweightPx === w) {
2102
+ _[_.length - 1] = {
2103
+ ...p,
2104
+ vertexCount: p.vertexCount + x
2034
2105
  };
2035
2106
  return;
2036
2107
  }
2037
- h.push({
2038
- startVertex: d,
2039
- vertexCount: m,
2040
- color: [x[0], x[1], x[2]],
2041
- layerIndex: G,
2042
- ...N === void 0 ? {} : { lineweightPx: N }
2108
+ _.push({
2109
+ startVertex: f,
2110
+ vertexCount: x,
2111
+ color: [h[0], h[1], h[2]],
2112
+ layerIndex: R,
2113
+ ...w === void 0 ? {} : { lineweightPx: w }
2043
2114
  });
2044
2115
  };
2045
2116
  yield* function* () {
2046
- for (const m of ot(e)) {
2047
- let x = m.startVertex;
2048
- const G = m.startVertex + m.vertexCount;
2049
- for (; x < G; ) {
2050
- const N = Math.min(s - d, G - x), R = x * 2, P = d * 2;
2051
- u.set(e.pos.subarray(R, R + N * 2), P), w(N, m.color, m.layerIndex, m.lineweightPx), x += N, d += N, d === s && (yield* f());
2117
+ for (const x of rt(e)) {
2118
+ let h = x.startVertex;
2119
+ const R = x.startVertex + x.vertexCount;
2120
+ for (; h < R; ) {
2121
+ const w = Math.min(a - f, R - h), p = h * 2, v = f * 2;
2122
+ c.set(e.pos.subarray(p, p + w * 2), v), A(w, x.color, x.layerIndex, x.lineweightPx), h += w, f += w, f === a && (yield* m());
2052
2123
  }
2053
2124
  }
2054
2125
  }();
2055
- for (const m of a) {
2056
- if (!Nt(m.instanceId, c))
2126
+ for (const x of i) {
2127
+ if (!Nt(x.instanceId, l))
2057
2128
  continue;
2058
- const x = o.get(m.variantId);
2059
- if (!x)
2060
- throw new l("E_GROUP_RANGE", `Unknown variantId ${m.variantId}`);
2061
- const G = x[t], N = i[m.insLayerIdx].visible === !1;
2062
- for (const R of ot(G)) {
2063
- const P = N || R.layerIndex === r ? m.insLayerIdx : R.layerIndex;
2064
- let B = R.startVertex;
2065
- const D = R.startVertex + R.vertexCount;
2066
- for (; B < D; ) {
2067
- const C = Math.min(s - d, D - B);
2068
- for (let $ = 0; $ < C; $ += 1) {
2069
- const O = (B + $) * 2, v = (d + $) * 2, K = G.pos[O], A = G.pos[O + 1];
2070
- u[v] = m.matA * K + m.matC * A + m.tx, u[v + 1] = m.matB * K + m.matD * A + m.ty;
2129
+ const h = o.get(x.variantId);
2130
+ if (!h)
2131
+ throw new u("E_GROUP_RANGE", `Unknown variantId ${x.variantId}`);
2132
+ const R = h[t], w = s[x.insLayerIdx].visible === !1;
2133
+ for (const p of rt(R)) {
2134
+ const v = w || p.layerIndex === r ? x.insLayerIdx : p.layerIndex;
2135
+ let U = p.startVertex;
2136
+ const D = p.startVertex + p.vertexCount;
2137
+ for (; U < D; ) {
2138
+ const $ = Math.min(a - f, D - U);
2139
+ for (let M = 0; M < $; M += 1) {
2140
+ const Y = (U + M) * 2, z = (f + M) * 2, S = R.pos[Y], N = R.pos[Y + 1];
2141
+ c[z] = x.matA * S + x.matC * N + x.tx, c[z + 1] = x.matB * S + x.matD * N + x.ty;
2071
2142
  }
2072
- w(C, R.color, P, R.lineweightPx), B += C, d += C, d === s && (yield* f());
2143
+ A($, p.color, v, p.lineweightPx), U += $, f += $, f === a && (yield* m());
2073
2144
  }
2074
2145
  }
2075
2146
  }
2076
- if (yield* f(), _ !== n)
2077
- throw new l("E_GROUP_RANGE", `Expanded ${t} count mismatch: header=${n}, emitted=${_}`);
2147
+ if (yield* m(), d !== n)
2148
+ throw new u("E_GROUP_RANGE", `Expanded ${t} count mismatch: header=${n}, emitted=${d}`);
2078
2149
  }
2079
- function* po(t, n, e, o) {
2080
- yield* vt(
2150
+ function* So(t, n, e, o) {
2151
+ yield* Lt(
2081
2152
  "line",
2082
2153
  n.lineCount,
2083
2154
  t.baseLine,
@@ -2086,7 +2157,7 @@ function* po(t, n, e, o) {
2086
2157
  e.layer0_index,
2087
2158
  n.layers,
2088
2159
  o
2089
- ), yield* vt(
2160
+ ), yield* Lt(
2090
2161
  "fill",
2091
2162
  n.fillCount,
2092
2163
  t.baseFill,
@@ -2095,7 +2166,7 @@ function* po(t, n, e, o) {
2095
2166
  e.layer0_index,
2096
2167
  n.layers,
2097
2168
  o
2098
- ), yield* vt(
2169
+ ), yield* Lt(
2099
2170
  "dot",
2100
2171
  n.dotCount,
2101
2172
  t.baseDot,
@@ -2105,44 +2176,48 @@ function* po(t, n, e, o) {
2105
2176
  n.layers,
2106
2177
  o
2107
2178
  );
2108
- for (const a of n.texts)
2109
- yield { kind: "text", payload: a };
2110
- }
2111
- function Io(t, n) {
2112
- const e = On(n), o = Wn(t, e);
2113
- return {
2114
- header: o.header,
2115
- chunks: po(
2116
- o.decoded,
2117
- o.header,
2118
- { layer0_index: o.meta.layer0_index ?? 0 },
2119
- e
2179
+ for (const i of n.texts)
2180
+ yield { kind: "text", payload: i };
2181
+ }
2182
+ function se(t, n, e) {
2183
+ const o = Dn(n), i = oe(t, o, e);
2184
+ return i.documentCache && Pn.add(i.documentCache), {
2185
+ header: i.header,
2186
+ ...i.documentCache ? { documentCache: i.documentCache } : {},
2187
+ chunks: So(
2188
+ i.decoded,
2189
+ i.header,
2190
+ { layer0_index: i.meta.layer0_index ?? 0 },
2191
+ o
2120
2192
  )
2121
2193
  };
2122
2194
  }
2123
- function Go(t, n) {
2124
- if (rt(t))
2125
- return Io(t, n);
2126
- const e = tn(t);
2195
+ function ae(t, n) {
2196
+ if (Q(t))
2197
+ return se(t, n);
2198
+ const e = on(t);
2127
2199
  return {
2128
2200
  header: e.header,
2129
- chunks: Ro(t, e.view, e.dataOffset, e.header)
2201
+ chunks: Uo(t, e.view, e.dataOffset, e.header)
2130
2202
  };
2131
2203
  }
2132
- function Do(t) {
2133
- if (rt(t)) {
2134
- const n = vn(t);
2135
- return ao(n.bounds, "V3 SCENE_META bounds");
2204
+ function Fo(t, n, e) {
2205
+ return n.kind !== "dxb3-v3" || n.buffer !== t || !Pn.has(n) || !Q(t) ? ae(t, e) : se(t, e, n);
2206
+ }
2207
+ function zo(t) {
2208
+ if (Q(t)) {
2209
+ const n = Fn(t);
2210
+ return go(n.bounds, "V3 SCENE_META bounds");
2136
2211
  }
2137
- return tn(t).header.bounds;
2212
+ return on(t).header.bounds;
2138
2213
  }
2139
- function* vo(t, n) {
2140
- const e = Go(t, n);
2214
+ function* Ho(t, n) {
2215
+ const e = ae(t, n);
2141
2216
  for (const o of e.chunks)
2142
2217
  yield o;
2143
2218
  return e.header;
2144
2219
  }
2145
- function Xt() {
2220
+ function kt() {
2146
2221
  return {
2147
2222
  pos: new Float32Array(0),
2148
2223
  col: new Uint8Array(0),
@@ -2150,8 +2225,8 @@ function Xt() {
2150
2225
  count: 0
2151
2226
  };
2152
2227
  }
2153
- function it(t) {
2154
- const n = Be(t);
2228
+ function at(t) {
2229
+ const n = Le(t);
2155
2230
  return {
2156
2231
  pos: t.pos,
2157
2232
  col: n.col,
@@ -2159,104 +2234,105 @@ function it(t) {
2159
2234
  count: t.count
2160
2235
  };
2161
2236
  }
2162
- function Xo(t, n) {
2163
- if (rt(t)) {
2164
- const c = On(n), s = Wn(t, c), u = Dt(
2165
- s.decoded.baseLine,
2166
- s.decoded.variants,
2167
- s.decoded.instances,
2237
+ function jo(t, n) {
2238
+ if (Q(t)) {
2239
+ const l = Dn(n), a = oe(t, l), c = Xt(
2240
+ a.decoded.baseLine,
2241
+ a.decoded.variants,
2242
+ a.decoded.instances,
2168
2243
  "line",
2169
- s.meta.layer0_index ?? 0,
2170
- s.header.layers,
2171
- c
2172
- ), h = Dt(
2173
- s.decoded.baseFill,
2174
- s.decoded.variants,
2175
- s.decoded.instances,
2244
+ a.meta.layer0_index ?? 0,
2245
+ a.header.layers,
2246
+ l
2247
+ ), _ = Xt(
2248
+ a.decoded.baseFill,
2249
+ a.decoded.variants,
2250
+ a.decoded.instances,
2176
2251
  "fill",
2177
- s.meta.layer0_index ?? 0,
2178
- s.header.layers,
2179
- c
2180
- ), d = Dt(
2181
- s.decoded.baseDot,
2182
- s.decoded.variants,
2183
- s.decoded.instances,
2252
+ a.meta.layer0_index ?? 0,
2253
+ a.header.layers,
2254
+ l
2255
+ ), f = Xt(
2256
+ a.decoded.baseDot,
2257
+ a.decoded.variants,
2258
+ a.decoded.instances,
2184
2259
  "dot",
2185
- s.meta.layer0_index ?? 0,
2186
- s.header.layers,
2187
- c
2260
+ a.meta.layer0_index ?? 0,
2261
+ a.header.layers,
2262
+ l
2188
2263
  );
2189
2264
  return {
2190
- meta: s.meta,
2191
- line: it(u),
2192
- fill: it(h),
2193
- dot: it(d),
2265
+ meta: a.meta,
2266
+ line: at(c),
2267
+ fill: at(_),
2268
+ dot: at(f),
2194
2269
  rawBytes: t.byteLength
2195
2270
  };
2196
2271
  }
2197
- const e = tn(t);
2272
+ const e = on(t);
2198
2273
  let o = e.dataOffset;
2199
- const a = lt(t, e.view, o, e.header.lineCount);
2200
- o = a.offset;
2201
- const r = lt(t, e.view, o, e.header.fillCount);
2274
+ const i = ft(t, e.view, o, e.header.lineCount);
2275
+ o = i.offset;
2276
+ const r = ft(t, e.view, o, e.header.fillCount);
2202
2277
  o = r.offset;
2203
- const i = lt(t, e.view, o, e.header.dotCount);
2204
- if (o = i.offset, o !== t.byteLength)
2205
- throw new l("E_GROUP_RANGE", `Trailing bytes detected: offset=${o}, size=${t.byteLength}`);
2278
+ const s = ft(t, e.view, o, e.header.dotCount);
2279
+ if (o = s.offset, o !== t.byteLength)
2280
+ throw new u("E_GROUP_RANGE", `Trailing bytes detected: offset=${o}, size=${t.byteLength}`);
2206
2281
  return {
2207
2282
  meta: e.meta,
2208
- line: it(a.chunk),
2209
- fill: it(r.chunk),
2210
- dot: it(i.chunk),
2283
+ line: at(i.chunk),
2284
+ fill: at(r.chunk),
2285
+ dot: at(s.chunk),
2211
2286
  rawBytes: t.byteLength
2212
2287
  };
2213
2288
  }
2214
- function Lo(t, n) {
2215
- return t ? fe(Bn(t, n)) : null;
2289
+ function qo(t, n) {
2290
+ return t ? Ne(On(t, n)) : null;
2216
2291
  }
2217
2292
  export {
2218
- l as CadPackError,
2219
- l as GeoLoaderError,
2220
- Lt as STREAM_VERTEX_WINDOW,
2221
- Ne as assertStrictTextRoundtrip,
2222
- To as captureGroupSnapshot,
2223
- Yt as cloneViewportRect,
2224
- Ee as computeViewportRectFromPositions,
2225
- It as emptyGeometryChunk,
2226
- Be as expandGeometryChunkMetadata,
2227
- he as expandViewportRect,
2228
- et as getDxbsSection,
2229
- Wt as groupLayerEncodingForV3Minor,
2230
- _e as intersectViewportRects,
2231
- Ge as isDxbsPayload,
2232
- Ae as isStrictTextRoundtripEnabled,
2233
- dt as mergeAdjacentSegments,
2234
- me as mergeViewportRects,
2235
- ot as normalizeGeometrySegments,
2236
- fe as normalizeViewportRect,
2237
- Ht as offsetGeometrySegments,
2238
- Do as parseBinBounds,
2239
- Xo as parseBinPayload,
2240
- Go as parseBinStreaming,
2241
- vo as parseBinToChunks,
2242
- be as readBlockAnnotationSidecar,
2243
- Jt as readDxbsContainer,
2244
- Mo as readExternalAnnotationManifest,
2245
- Po as readExternalBlockAnnotations,
2246
- $o as readExternalVariantDependencyPlan,
2247
- uo as readExternalVariantGeometrySidecar,
2248
- Oo as readExternalVariantManifest,
2249
- lt as readGroup,
2250
- So as readSceneAnnotationSidecar,
2251
- Cn as remapGeometrySegmentLayers,
2252
- Uo as shouldAssertStrictTextRoundtrip,
2253
- Co as sliceGeometrySegments,
2254
- de as streamGroupChunks,
2255
- Lo as transformBBoxByInstance,
2256
- Bn as transformViewportRect,
2257
- ge as viewportRectCenterDistance,
2258
- bo as viewportRectContains,
2259
- xe as viewportRectDiagonal,
2260
- Bo as viewportRectEquals,
2261
- bn as viewportRectIntersects
2293
+ u as CadPackError,
2294
+ u as GeoLoaderError,
2295
+ Yt as STREAM_VERTEX_WINDOW,
2296
+ Ce as assertStrictTextRoundtrip,
2297
+ Oo as captureGroupSnapshot,
2298
+ Ft as cloneViewportRect,
2299
+ Ge as computeViewportRectFromPositions,
2300
+ Vt as emptyGeometryChunk,
2301
+ Le as expandGeometryChunkMetadata,
2302
+ Ve as expandViewportRect,
2303
+ ot as getDxbsSection,
2304
+ Qt as groupLayerEncodingForV3Minor,
2305
+ Ie as intersectViewportRects,
2306
+ ve as isDxbsPayload,
2307
+ Se as isStrictTextRoundtripEnabled,
2308
+ mt as mergeAdjacentSegments,
2309
+ pe as mergeViewportRects,
2310
+ rt as normalizeGeometrySegments,
2311
+ Ne as normalizeViewportRect,
2312
+ qt as offsetGeometrySegments,
2313
+ zo as parseBinBounds,
2314
+ jo as parseBinPayload,
2315
+ ae as parseBinStreaming,
2316
+ Fo as parseBinStreamingWithCache,
2317
+ Ho as parseBinToChunks,
2318
+ Xe as readBlockAnnotationSidecar,
2319
+ tn as readDxbsContainer,
2320
+ ko as readExternalAnnotationManifest,
2321
+ Yo as readExternalBlockAnnotations,
2322
+ Lo as readExternalVariantDependencyPlan,
2323
+ wo as readExternalVariantGeometrySidecar,
2324
+ Xo as readExternalVariantManifest,
2325
+ ft as readGroup,
2326
+ Po as readSceneAnnotationSidecar,
2327
+ vn as remapGeometrySegmentLayers,
2328
+ vo as shouldAssertStrictTextRoundtrip,
2329
+ Do as sliceGeometrySegments,
2330
+ Re as streamGroupChunks,
2331
+ qo as transformBBoxByInstance,
2332
+ On as transformViewportRect,
2333
+ be as viewportRectCenterDistance,
2334
+ $o as viewportRectContains,
2335
+ Te as viewportRectDiagonal,
2336
+ Mo as viewportRectEquals,
2337
+ Cn as viewportRectIntersects
2262
2338
  };