@flyfish-dev/cad-viewer 0.5.3 → 0.6.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,47 +1,44 @@
1
- var Jt = Object.defineProperty;
2
- var te = (e, t, r) => t in e ? Jt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var u = (e, t, r) => te(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { unzipSync as ee } from "fflate";
5
- async function et(e) {
1
+ var jt = Object.defineProperty;
2
+ var Gt = (e, t, r) => t in e ? jt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var d = (e, t, r) => Gt(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { openDwfDocument as Zt, DwfViewer as qt } from "dwf-viewer";
5
+ async function _(e) {
6
6
  if (e.buffer instanceof Uint8Array) return e.buffer;
7
7
  if (e.buffer instanceof ArrayBuffer) return new Uint8Array(e.buffer);
8
8
  if (e.file) return new Uint8Array(await e.file.arrayBuffer());
9
9
  throw new Error("CadLoadInput requires a File, ArrayBuffer, or Uint8Array.");
10
10
  }
11
- function re(e) {
11
+ function Kt(e) {
12
12
  return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
13
13
  }
14
- function Y(e) {
14
+ function L(e) {
15
15
  var i;
16
16
  const t = e.fileName ?? ((i = e.file) == null ? void 0 : i.name) ?? "", r = t.lastIndexOf(".");
17
17
  return r >= 0 ? t.slice(r + 1).toLowerCase() : "";
18
18
  }
19
- function rt(e, t) {
20
- const r = Y(e);
19
+ function B(e, t) {
20
+ const r = L(e);
21
21
  if (r === "dwg") return "dwg";
22
22
  if (r === "dxf") return "dxf";
23
23
  if (r === "dwfx") return "dwfx";
24
24
  if (r === "xps") return "xps";
25
25
  if (r === "dwf") return "dwf";
26
26
  if (t && t.byteLength >= 6) {
27
- const i = vt(t.slice(0, 6));
27
+ const i = pt(t.slice(0, 6));
28
28
  if (/^AC10/.test(i)) return "dwg";
29
29
  if (t[0] === 80 && t[1] === 75) return "dwfx";
30
- const s = vt(t.slice(0, Math.min(t.byteLength, 2048))).toUpperCase();
30
+ const s = pt(t.slice(0, Math.min(t.byteLength, 2048))).toUpperCase();
31
31
  if (s.includes("SECTION") && s.includes("ENTITIES")) return "dxf";
32
32
  if (s.includes("DWF")) return "dwf";
33
33
  }
34
34
  return "unknown";
35
35
  }
36
- function vt(e) {
36
+ function pt(e) {
37
37
  return Array.from(e, (t) => t >= 32 && t <= 126 ? String.fromCharCode(t) : " ").join("");
38
38
  }
39
- function wt(e) {
40
- return new TextDecoder("utf-8").decode(e);
41
- }
42
- class ie {
39
+ class Jt {
43
40
  constructor(t = []) {
44
- u(this, "loaders", []);
41
+ d(this, "loaders", []);
45
42
  for (const r of t) this.register(r);
46
43
  }
47
44
  register(t) {
@@ -56,7 +53,7 @@ class ie {
56
53
  return [...this.loaders];
57
54
  }
58
55
  async detect(t) {
59
- const r = await et(t), i = rt(t, r), s = this.loaders.find((o) => o.formats.includes(i) && o.accepts(t, r));
56
+ const r = await _(t), i = B(t, r), s = this.loaders.find((o) => o.formats.includes(i) && o.accepts(t, r));
60
57
  if (s) return { loader: s, bytes: r, format: i };
61
58
  const n = this.loaders.find((o) => o.accepts(t, r));
62
59
  if (n) return { loader: n, bytes: r, format: i };
@@ -67,27 +64,27 @@ class ie {
67
64
  return i.load({ ...t, buffer: s }, r);
68
65
  }
69
66
  }
70
- class se {
67
+ class Qt {
71
68
  constructor() {
72
- u(this, "worker");
73
- u(this, "sequence", 0);
74
- u(this, "pending", /* @__PURE__ */ new Map());
69
+ d(this, "worker");
70
+ d(this, "sequence", 0);
71
+ d(this, "pending", /* @__PURE__ */ new Map());
75
72
  }
76
73
  load(t, r, i = {}) {
77
- var l, h;
74
+ var h, l;
78
75
  if (!ht()) throw new Error("Web Worker is not available in this runtime.");
79
- const s = this.ensureWorker(i), n = ++this.sequence, o = Math.max(0, Number(i.workerTimeoutMs ?? 0)), a = i.fileName ?? r.fileName ?? ((l = r.file) == null ? void 0 : l.name), c = oe(t, r, i);
80
- return (h = i.onProgress) == null || h.call(i, { phase: "worker-start", format: "dwg", message: "Dispatching DWG parse to worker…", total: t.byteLength }), new Promise((f, d) => {
81
- var g;
82
- if ((g = i.signal) != null && g.aborted) {
83
- d(U());
76
+ const s = this.ensureWorker(i), n = ++this.sequence, o = Math.max(0, Number(i.workerTimeoutMs ?? 0)), a = i.fileName ?? r.fileName ?? ((h = r.file) == null ? void 0 : h.name), c = ee(t, r, i);
77
+ return (l = i.onProgress) == null || l.call(i, { phase: "worker-start", format: "dwg", message: "Dispatching DWG parse to worker…", total: t.byteLength }), new Promise((f, u) => {
78
+ var v;
79
+ if ((v = i.signal) != null && v.aborted) {
80
+ u($());
84
81
  return;
85
82
  }
86
- const p = { resolve: f, reject: d, onProgress: i.onProgress, signal: i.signal };
83
+ const p = { resolve: f, reject: u, onProgress: i.onProgress, signal: i.signal };
87
84
  o > 0 && (p.timer = setTimeout(() => {
88
- this.pending.delete(n), this.resetWorker(), d(new Error(`DWG worker timed out after ${o} ms.`));
85
+ this.pending.delete(n), this.resetWorker(), u(new Error(`DWG worker timed out after ${o} ms.`));
89
86
  }, o)), i.signal && (p.abortHandler = () => {
90
- this.pending.delete(n), this.resetWorker(), d(U());
87
+ this.pending.delete(n), this.resetWorker(), u($());
91
88
  }, i.signal.addEventListener("abort", p.abortHandler, { once: !0 })), this.pending.set(n, p);
92
89
  try {
93
90
  s.postMessage({
@@ -95,10 +92,10 @@ class se {
95
92
  requestId: n,
96
93
  bytes: c,
97
94
  fileName: a,
98
- options: Ct(i)
95
+ options: gt(i)
99
96
  }, [c]);
100
97
  } catch (S) {
101
- this.pending.delete(n), _(p), d(S instanceof Error ? S : new Error(String(S)));
98
+ this.pending.delete(n), V(p), u(S instanceof Error ? S : new Error(String(S)));
102
99
  }
103
100
  });
104
101
  }
@@ -107,9 +104,9 @@ class se {
107
104
  if (!ht()) return Promise.reject(new Error("Web Worker is not available in this runtime."));
108
105
  const r = this.ensureWorker(t), i = ++this.sequence, s = Math.max(0, Number(t.workerTimeoutMs ?? 0));
109
106
  return (n = t.onProgress) == null || n.call(t, { phase: "worker-start", format: "dwg", message: "Starting DWG worker warmup…" }), new Promise((o, a) => {
110
- var l;
111
- if ((l = t.signal) != null && l.aborted) {
112
- a(U());
107
+ var h;
108
+ if ((h = t.signal) != null && h.aborted) {
109
+ a($());
113
110
  return;
114
111
  }
115
112
  const c = {
@@ -121,12 +118,12 @@ class se {
121
118
  s > 0 && (c.timer = setTimeout(() => {
122
119
  this.pending.delete(i), this.resetWorker(), a(new Error(`DWG worker warmup timed out after ${s} ms.`));
123
120
  }, s)), t.signal && (c.abortHandler = () => {
124
- this.pending.delete(i), this.resetWorker(), a(U());
121
+ this.pending.delete(i), this.resetWorker(), a($());
125
122
  }, t.signal.addEventListener("abort", c.abortHandler, { once: !0 })), this.pending.set(i, c);
126
123
  try {
127
- r.postMessage({ type: "warmup", requestId: i, options: Ct(t) });
128
- } catch (h) {
129
- this.pending.delete(i), _(c), a(h instanceof Error ? h : new Error(String(h)));
124
+ r.postMessage({ type: "warmup", requestId: i, options: gt(t) });
125
+ } catch (l) {
126
+ this.pending.delete(i), V(c), a(l instanceof Error ? l : new Error(String(l)));
130
127
  }
131
128
  });
132
129
  }
@@ -134,7 +131,7 @@ class se {
134
131
  this.resetWorker();
135
132
  }
136
133
  ensureWorker(t) {
137
- return this.worker || (this.worker = ne(t), this.worker.onmessage = (r) => this.handleMessage(r.data), this.worker.onerror = (r) => {
134
+ return this.worker || (this.worker = te(t), this.worker.onmessage = (r) => this.handleMessage(r.data), this.worker.onerror = (r) => {
138
135
  const i = r.message || "DWG worker failed.";
139
136
  this.rejectAll(new Error(i)), this.resetWorker(!1);
140
137
  }, this.worker.onmessageerror = () => {
@@ -150,7 +147,7 @@ class se {
150
147
  (s = r.onProgress) == null || s.call(r, t.progress);
151
148
  return;
152
149
  }
153
- if (this.pending.delete(t.requestId), _(r), t.type === "result") {
150
+ if (this.pending.delete(t.requestId), V(r), t.type === "result") {
154
151
  r.resolve(t.result);
155
152
  return;
156
153
  }
@@ -163,7 +160,7 @@ class se {
163
160
  }
164
161
  rejectAll(t) {
165
162
  for (const [, r] of this.pending)
166
- _(r), r.reject(t);
163
+ V(r), r.reject(t);
167
164
  this.pending.clear();
168
165
  }
169
166
  resetWorker(t = !0) {
@@ -174,66 +171,66 @@ class se {
174
171
  function ht() {
175
172
  return typeof Worker < "u" && typeof URL < "u";
176
173
  }
177
- function ne(e) {
174
+ function te(e) {
178
175
  return e.workerFactory ? e.workerFactory() : e.workerUrl ? new Worker(e.workerUrl, { type: "module", name: "lightweight-cad-dwg-loader" }) : new Worker(new URL(
179
176
  /* @vite-ignore */
180
177
  "/assets/DwgWorker-CuZJ5EUe.js",
181
178
  import.meta.url
182
179
  ), { type: "module", name: "lightweight-cad-dwg-loader" });
183
180
  }
184
- function Ct(e) {
181
+ function gt(e) {
185
182
  return {
186
183
  // Resolve the asset directory on the UI thread. Relative paths such as
187
184
  // './wasm' must be relative to the document URL, not to the generated
188
185
  // worker chunk URL. Otherwise the worker may request /assets/wasm/... and
189
186
  // receive the app's HTML fallback instead of libredwg-web.wasm.
190
- wasmPath: ae(e.wasmPath),
187
+ wasmPath: re(e.wasmPath),
191
188
  includePaperSpace: e.includePaperSpace,
192
189
  maxInsertDepth: e.maxInsertDepth,
193
190
  keepRaw: !!e.keepRaw
194
191
  };
195
192
  }
196
- function oe(e, t, r) {
197
- return !!t.file || r.transferInputBuffer === !0 ? re(e) : e.slice().buffer;
193
+ function ee(e, t, r) {
194
+ return !!t.file || r.transferInputBuffer === !0 ? Kt(e) : e.slice().buffer;
198
195
  }
199
- function _(e) {
196
+ function V(e) {
200
197
  e.timer && clearTimeout(e.timer), e.signal && e.abortHandler && e.signal.removeEventListener("abort", e.abortHandler);
201
198
  }
202
- function U() {
199
+ function $() {
203
200
  if (typeof DOMException < "u") return new DOMException("DWG loading was aborted.", "AbortError");
204
201
  const e = new Error("DWG loading was aborted.");
205
202
  return e.name = "AbortError", e;
206
203
  }
207
- function ae(e) {
204
+ function re(e) {
208
205
  const t = ((e == null ? void 0 : e.trim()) || "/wasm").replace(/\/+$/, "");
209
- return t === "" ? Pt() : ce(t) ? t : t.startsWith("/") ? `${Pt()}${t}` : new URL(t, zt()).href.replace(/\/+$/, "");
206
+ return t === "" ? bt() : ie(t) ? t : t.startsWith("/") ? `${bt()}${t}` : new URL(t, Wt()).href.replace(/\/+$/, "");
210
207
  }
211
- function zt() {
208
+ function Wt() {
212
209
  return typeof document < "u" && document.baseURI ? document.baseURI : typeof location < "u" && location.href ? location.href : "http://localhost/";
213
210
  }
214
- function Pt() {
215
- return typeof location < "u" && location.origin ? location.origin : new URL(zt()).origin;
211
+ function bt() {
212
+ return typeof location < "u" && location.origin ? location.origin : new URL(Wt()).origin;
216
213
  }
217
- function ce(e) {
214
+ function ie(e) {
218
215
  return /^[a-z][a-z0-9+.-]*:/i.test(e);
219
216
  }
220
- class le {
217
+ class se {
221
218
  constructor(t = {}) {
222
- u(this, "id", "dwg");
223
- u(this, "label", "DWG / LibreDWG WebAssembly");
224
- u(this, "formats", ["dwg"]);
225
- u(this, "defaults");
226
- u(this, "workerClient", new se());
219
+ d(this, "id", "dwg");
220
+ d(this, "label", "DWG / LibreDWG WebAssembly");
221
+ d(this, "formats", ["dwg"]);
222
+ d(this, "defaults");
223
+ d(this, "workerClient", new Qt());
227
224
  this.defaults = { useWorker: !0, ...t };
228
225
  }
229
226
  accepts(t, r) {
230
- return Y(t) === "dwg" ? !0 : rt(t, r) === "dwg";
227
+ return L(t) === "dwg" ? !0 : B(t, r) === "dwg";
231
228
  }
232
229
  async load(t, r = {}) {
233
230
  var o, a;
234
231
  const i = { ...this.defaults, ...r };
235
232
  (o = i.onProgress) == null || o.call(i, { phase: "read", format: "dwg", message: "Reading DWG bytes…" });
236
- const s = await et(t), n = t.fileName ?? ((a = t.file) == null ? void 0 : a.name);
233
+ const s = await _(t), n = t.fileName ?? ((a = t.file) == null ? void 0 : a.name);
237
234
  if (i.useWorker === !1)
238
235
  throw new Error("DWG main-thread parsing is intentionally not bundled by the default viewer. Keep useWorker enabled, or register a custom DWG loader for non-browser runtimes.");
239
236
  if (!ht())
@@ -241,7 +238,7 @@ class le {
241
238
  try {
242
239
  return await this.workerClient.load(s, t, { ...i, fileName: n });
243
240
  } catch (c) {
244
- throw he(c) ? c : fe(c);
241
+ throw ne(c) ? c : oe(c);
245
242
  }
246
243
  }
247
244
  terminateWorker() {
@@ -252,14 +249,14 @@ class le {
252
249
  return r.useWorker === !1 ? Promise.reject(new Error("DWG preload requires worker mode in the default viewer.")) : this.workerClient.preload(r);
253
250
  }
254
251
  }
255
- function he(e) {
252
+ function ne(e) {
256
253
  return e instanceof Error && e.name === "AbortError";
257
254
  }
258
- function fe(e) {
255
+ function oe(e) {
259
256
  const t = e instanceof Error ? e.message : String(e);
260
257
  return new Error(`${t} If the worker asset cannot be resolved by your bundler/CDN, pass workerUrl or workerFactory to CadViewer.`);
261
258
  }
262
- function Xt(e) {
259
+ function Rt(e) {
263
260
  return {
264
261
  format: e.format,
265
262
  sourceName: e.sourceName,
@@ -274,7 +271,7 @@ function Xt(e) {
274
271
  raw: e.raw
275
272
  };
276
273
  }
277
- function O(e) {
274
+ function R(e) {
278
275
  switch (String(e ?? "").toUpperCase()) {
279
276
  case "LINE":
280
277
  return "line";
@@ -325,19 +322,19 @@ function O(e) {
325
322
  return "unsupported";
326
323
  }
327
324
  }
328
- function de(e, t, r = {}) {
329
- const i = t ?? String(e.type ?? e.entityType ?? e.objectName ?? "UNKNOWN").toUpperCase(), s = r.includeUnknownProperties === !1 ? { type: i, kind: O(i) } : { ...e, type: i, kind: O(i) };
330
- r.keepRaw && (s.raw = e), s.handle = P(e.handle ?? e.id), s.layer = P(e.layer ?? e.layerName), s.lineType = P(e.lineType ?? e.linetype);
331
- const n = r.numericColorMode ?? "auto", o = x(e.color), a = x(e.colorIndex ?? e.colorNumber ?? e.aci ?? e.aciColor ?? e.color_index);
325
+ function ae(e, t, r = {}) {
326
+ const i = t ?? String(e.type ?? e.entityType ?? e.objectName ?? "UNKNOWN").toUpperCase(), s = r.includeUnknownProperties === !1 ? { type: i, kind: R(i) } : { ...e, type: i, kind: R(i) };
327
+ r.keepRaw && (s.raw = e), s.handle = C(e.handle ?? e.id), s.layer = C(e.layer ?? e.layerName), s.lineType = C(e.lineType ?? e.linetype);
328
+ const n = r.numericColorMode ?? "auto", o = y(e.color), a = y(e.colorIndex ?? e.colorNumber ?? e.aci ?? e.aciColor ?? e.color_index);
332
329
  s.colorIndex = a ?? (n !== "rgb" && o !== void 0 && Math.abs(o) <= 257 ? o : void 0);
333
- const c = e.trueColor ?? e.true_color ?? e.truecolor ?? e.colorRGB ?? e.colorRgb ?? e.rgbColor ?? e.rgb, l = o !== void 0 && o >= 0 && o <= 16777215 && (n === "rgb" || n === "auto" && Math.abs(o) > 257);
334
- s.trueColor = c ?? (l ? o : void 0), (typeof e.color == "string" || typeof e.color == "number") && (s.color = e.color), s.colorNumber = x(e.colorNumber) ?? s.colorNumber, s.colorName = P(e.colorName ?? e.color_name) ?? s.colorName, s.fillColor = e.fillColor ?? e.fill_color, s.fillColorIndex = x(e.fillColorIndex ?? e.fill_color_index ?? e.fillColorNumber) ?? s.fillColorIndex, s.opacity = x(e.opacity ?? e.alpha) ?? s.opacity, s.lineweight = x(e.lineweight ?? e.lineWeight), s.isVisible = !(e.isVisible === !1 || e.visible === !1), s.startPoint = k(e.startPoint ?? e.start ?? e.p0 ?? e.from) ?? s.startPoint, s.endPoint = k(e.endPoint ?? e.end ?? e.p1 ?? e.to) ?? s.endPoint, s.center = k(e.center ?? e.centerPoint) ?? s.center, s.insertionPoint = k(e.insertionPoint ?? e.position ?? e.location ?? e.point ?? e.basePoint) ?? s.insertionPoint, s.radius = x(e.radius) ?? s.radius, s.startAngle = x(e.startAngle ?? e.start_angle) ?? s.startAngle, s.endAngle = x(e.endAngle ?? e.end_angle) ?? s.endAngle, s.majorAxisEndPoint = k(e.majorAxisEndPoint ?? e.majorAxis ?? e.major) ?? s.majorAxisEndPoint, s.axisRatio = x(e.axisRatio ?? e.ratio) ?? s.axisRatio, s.height = x(e.height ?? e.textHeight) ?? s.height, s.textHeight = x(e.textHeight ?? e.height) ?? s.textHeight, s.rotation = x(e.rotation ?? e.angle) ?? s.rotation, s.text = P(e.text ?? e.value ?? e.string ?? e.contents) ?? s.text, s.name = P(e.name ?? e.blockName) ?? s.name, s.blockName = P(e.blockName ?? e.name) ?? s.blockName;
335
- const h = it(e.vertices ?? e.points);
336
- h.length > 0 && (s.vertices = h);
337
- const f = it(e.controlPoints ?? e.control_points);
330
+ const c = e.trueColor ?? e.true_color ?? e.truecolor ?? e.colorRGB ?? e.colorRgb ?? e.rgbColor ?? e.rgb, h = o !== void 0 && o >= 0 && o <= 16777215 && (n === "rgb" || n === "auto" && Math.abs(o) > 257);
331
+ s.trueColor = c ?? (h ? o : void 0), (typeof e.color == "string" || typeof e.color == "number") && (s.color = e.color), s.colorNumber = y(e.colorNumber) ?? s.colorNumber, s.colorName = C(e.colorName ?? e.color_name) ?? s.colorName, s.fillColor = e.fillColor ?? e.fill_color, s.fillColorIndex = y(e.fillColorIndex ?? e.fill_color_index ?? e.fillColorNumber) ?? s.fillColorIndex, s.opacity = y(e.opacity ?? e.alpha) ?? s.opacity, s.lineweight = y(e.lineweight ?? e.lineWeight), s.isVisible = !(e.isVisible === !1 || e.visible === !1), s.startPoint = k(e.startPoint ?? e.start ?? e.p0 ?? e.from) ?? s.startPoint, s.endPoint = k(e.endPoint ?? e.end ?? e.p1 ?? e.to) ?? s.endPoint, s.center = k(e.center ?? e.centerPoint) ?? s.center, s.insertionPoint = k(e.insertionPoint ?? e.position ?? e.location ?? e.point ?? e.basePoint) ?? s.insertionPoint, s.radius = y(e.radius) ?? s.radius, s.startAngle = y(e.startAngle ?? e.start_angle) ?? s.startAngle, s.endAngle = y(e.endAngle ?? e.end_angle) ?? s.endAngle, s.majorAxisEndPoint = k(e.majorAxisEndPoint ?? e.majorAxis ?? e.major) ?? s.majorAxisEndPoint, s.axisRatio = y(e.axisRatio ?? e.ratio) ?? s.axisRatio, s.height = y(e.height ?? e.textHeight) ?? s.height, s.textHeight = y(e.textHeight ?? e.height) ?? s.textHeight, s.rotation = y(e.rotation ?? e.angle) ?? s.rotation, s.text = C(e.text ?? e.value ?? e.string ?? e.contents) ?? s.text, s.name = C(e.name ?? e.blockName) ?? s.name, s.blockName = C(e.blockName ?? e.name) ?? s.blockName;
332
+ const l = tt(e.vertices ?? e.points);
333
+ l.length > 0 && (s.vertices = l);
334
+ const f = tt(e.controlPoints ?? e.control_points);
338
335
  f.length > 0 && (s.controlPoints = f);
339
- const d = it(e.fitPoints ?? e.fit_points);
340
- return d.length > 0 && (s.fitPoints = d), s;
336
+ const u = tt(e.fitPoints ?? e.fit_points);
337
+ return u.length > 0 && (s.fitPoints = u), s;
341
338
  }
342
339
  function k(e) {
343
340
  if (!e || typeof e != "object") return;
@@ -345,22 +342,22 @@ function k(e) {
345
342
  if (!(!Number.isFinite(r) || !Number.isFinite(i)))
346
343
  return Number.isFinite(n) ? { x: r, y: i, z: n } : { x: r, y: i };
347
344
  }
348
- function it(e) {
345
+ function tt(e) {
349
346
  if (!Array.isArray(e)) return [];
350
347
  const t = [];
351
348
  for (const r of e) {
352
349
  const i = k(r);
353
350
  if (!i) continue;
354
- const s = r, n = i, o = x(s.bulge);
351
+ const s = r, n = i, o = y(s.bulge);
355
352
  o !== void 0 && (n.bulge = o);
356
- const a = x(s.startWidth ?? s.start_width);
353
+ const a = y(s.startWidth ?? s.start_width);
357
354
  a !== void 0 && (n.startWidth = a);
358
- const c = x(s.endWidth ?? s.end_width);
355
+ const c = y(s.endWidth ?? s.end_width);
359
356
  c !== void 0 && (n.endWidth = c), t.push(n);
360
357
  }
361
358
  return t;
362
359
  }
363
- function kt(e) {
360
+ function j(e) {
364
361
  var r;
365
362
  const t = {};
366
363
  for (const i of e.entities) {
@@ -378,124 +375,124 @@ function kt(e) {
378
375
  warnings: [...e.warnings]
379
376
  };
380
377
  }
381
- function St(e, t) {
378
+ function vt(e, t) {
382
379
  t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
383
380
  }
384
- function ue(e, t) {
381
+ function ce(e, t) {
385
382
  t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
386
383
  }
387
- function me(e) {
384
+ function he(e) {
388
385
  return e != null && e.length ? e.flatMap((t) => t.entities.map((r) => ({ ...r, pageIndex: t.index }))) : [];
389
386
  }
390
- function x(e) {
387
+ function y(e) {
391
388
  const t = Number(e);
392
389
  return Number.isFinite(t) ? t : void 0;
393
390
  }
394
- function P(e) {
391
+ function C(e) {
395
392
  if (typeof e != "string" && typeof e != "number") return;
396
393
  const t = String(e);
397
394
  return t.length > 0 ? t : void 0;
398
395
  }
399
- function N() {
396
+ function M() {
400
397
  return { minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
401
398
  }
402
- function R(e) {
399
+ function D(e) {
403
400
  return Number.isFinite(e.minX) && Number.isFinite(e.minY) && Number.isFinite(e.maxX) && Number.isFinite(e.maxY) && e.maxX >= e.minX && e.maxY >= e.minY;
404
401
  }
405
- function y(e, t) {
402
+ function b(e, t) {
406
403
  m(t) && (e.minX = Math.min(e.minX, t.x), e.minY = Math.min(e.minY, t.y), e.maxX = Math.max(e.maxX, t.x), e.maxY = Math.max(e.maxY, t.y));
407
404
  }
408
- function Yt(e, t, r) {
405
+ function Dt(e, t, r) {
409
406
  if (!m(t) || !Number.isFinite(r)) return;
410
407
  const i = Math.abs(r);
411
- y(e, { x: t.x - i, y: t.y - i }), y(e, { x: t.x + i, y: t.y + i });
408
+ b(e, { x: t.x - i, y: t.y - i }), b(e, { x: t.x + i, y: t.y + i });
412
409
  }
413
- function Ht(e, t = 0.02, r = 1e-6) {
414
- if (!R(e)) return { minX: -10, minY: -10, maxX: 10, maxY: 10 };
410
+ function Ot(e, t = 0.02, r = 1e-6) {
411
+ if (!D(e)) return { minX: -10, minY: -10, maxX: 10, maxY: 10 };
415
412
  const i = Math.max((e.maxX - e.minX) * t, r), s = Math.max((e.maxY - e.minY) * t, r);
416
413
  return { minX: e.minX - i, minY: e.minY - s, maxX: e.maxX + i, maxY: e.maxY + s };
417
414
  }
418
415
  function m(e) {
419
416
  return !!e && typeof e == "object" && Number.isFinite(e.x) && Number.isFinite(e.y);
420
417
  }
421
- function v(e) {
418
+ function x(e) {
422
419
  return { x: e.x, y: e.y };
423
420
  }
424
- function A(e) {
421
+ function E(e) {
425
422
  return e * Math.PI / 180;
426
423
  }
427
- function G(e, t, r, i, s = !0, n = 64) {
424
+ function Z(e, t, r, i, s = !0, n = 64) {
428
425
  if (!m(e) || !Number.isFinite(t)) return [];
429
426
  let o = r, a = i;
430
427
  if (!Number.isFinite(o) || !Number.isFinite(a)) return [];
431
- (Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o = A(o), a = A(a)), s && a < o && (a += Math.PI * 2), !s && o < a && (o += Math.PI * 2);
432
- const c = a - o, l = Math.max(8, Math.min(256, Math.ceil(Math.abs(c) / (Math.PI * 2) * n))), h = [];
433
- for (let f = 0; f <= l; f++) {
434
- const d = o + c * (f / l);
435
- h.push({ x: e.x + Math.cos(d) * t, y: e.y + Math.sin(d) * t });
428
+ (Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o = E(o), a = E(a)), s && a < o && (a += Math.PI * 2), !s && o < a && (o += Math.PI * 2);
429
+ const c = a - o, h = Math.max(8, Math.min(256, Math.ceil(Math.abs(c) / (Math.PI * 2) * n))), l = [];
430
+ for (let f = 0; f <= h; f++) {
431
+ const u = o + c * (f / h);
432
+ l.push({ x: e.x + Math.cos(u) * t, y: e.y + Math.sin(u) * t });
436
433
  }
437
- return h;
434
+ return l;
438
435
  }
439
- function Z(e, t, r = 1, i = 0, s = Math.PI * 2, n = 96) {
436
+ function q(e, t, r = 1, i = 0, s = Math.PI * 2, n = 96) {
440
437
  if (!m(e) || !m(t)) return [];
441
438
  const o = Math.hypot(t.x, t.y);
442
439
  if (!Number.isFinite(o) || o <= 0) return [];
443
440
  const a = o * (Number.isFinite(r) && r > 0 ? r : 1), c = Math.atan2(t.y, t.x);
444
- let l = Number.isFinite(i) ? i : 0, h = Number.isFinite(s) ? s : Math.PI * 2;
445
- (Math.abs(l) > Math.PI * 2 + 1e-6 || Math.abs(h) > Math.PI * 2 + 1e-6) && (l = A(l), h = A(h)), h < l && (h += Math.PI * 2);
446
- const f = Math.max(12, Math.min(256, Math.ceil(Math.abs(h - l) / (Math.PI * 2) * n))), d = [], p = Math.cos(c), g = Math.sin(c);
441
+ let h = Number.isFinite(i) ? i : 0, l = Number.isFinite(s) ? s : Math.PI * 2;
442
+ (Math.abs(h) > Math.PI * 2 + 1e-6 || Math.abs(l) > Math.PI * 2 + 1e-6) && (h = E(h), l = E(l)), l < h && (l += Math.PI * 2);
443
+ const f = Math.max(12, Math.min(256, Math.ceil(Math.abs(l - h) / (Math.PI * 2) * n))), u = [], p = Math.cos(c), v = Math.sin(c);
447
444
  for (let S = 0; S <= f; S++) {
448
- const M = l + (h - l) * (S / f), yt = Math.cos(M) * o, xt = Math.sin(M) * a;
449
- d.push({ x: e.x + yt * p - xt * g, y: e.y + yt * g + xt * p });
445
+ const O = h + (l - h) * (S / f), z = Math.cos(O) * o, Y = Math.sin(O) * a;
446
+ u.push({ x: e.x + z * p - Y * v, y: e.y + z * v + Y * p });
450
447
  }
451
- return d;
448
+ return u;
452
449
  }
453
- function _t(e, t, r = 0, i = 16) {
454
- if (!Number.isFinite(r) || Math.abs(r) < 1e-12) return [v(e), v(t)];
450
+ function zt(e, t, r = 0, i = 16) {
451
+ if (!Number.isFinite(r) || Math.abs(r) < 1e-12) return [x(e), x(t)];
455
452
  const s = Math.hypot(t.x - e.x, t.y - e.y);
456
- if (s <= 1e-12) return [v(e), v(t)];
457
- const n = 4 * Math.atan(r), o = Math.abs(s / (2 * Math.sin(n / 2))), a = { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }, c = (t.x - e.x) / s, l = (t.y - e.y) / s, h = r >= 0 ? 1 : -1, f = Math.sqrt(Math.max(o * o - (s / 2) ** 2, 0)), d = { x: a.x - h * l * f, y: a.y + h * c * f }, p = Math.atan2(e.y - d.y, e.x - d.x), g = Math.atan2(t.y - d.y, t.x - d.x);
458
- return G(d, o, p, g, r >= 0, i);
453
+ if (s <= 1e-12) return [x(e), x(t)];
454
+ const n = 4 * Math.atan(r), o = Math.abs(s / (2 * Math.sin(n / 2))), a = { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }, c = (t.x - e.x) / s, h = (t.y - e.y) / s, l = r >= 0 ? 1 : -1, f = Math.sqrt(Math.max(o * o - (s / 2) ** 2, 0)), u = { x: a.x - l * h * f, y: a.y + l * c * f }, p = Math.atan2(e.y - u.y, e.x - u.x), v = Math.atan2(t.y - u.y, t.x - u.x);
455
+ return Z(u, o, p, v, r >= 0, i);
459
456
  }
460
- function Ut(e) {
457
+ function Yt(e) {
461
458
  return e.replace(/\\P/g, `
462
459
  `).replace(/\\~|\\ /g, " ").replace(/\\[A-Za-z][^;]*;/g, "").replace(/[{}]/g, "").replace(/\\[A-Za-z]/g, "").trim();
463
460
  }
464
- function B(e, t, r) {
461
+ function T(e, t, r) {
465
462
  return Math.min(r, Math.max(t, e));
466
463
  }
467
- class pe {
464
+ class le {
468
465
  constructor(t = {}) {
469
- u(this, "id", "dxf");
470
- u(this, "label", "DXF / JavaScript parser");
471
- u(this, "formats", ["dxf"]);
472
- u(this, "defaults");
466
+ d(this, "id", "dxf");
467
+ d(this, "label", "DXF / JavaScript parser");
468
+ d(this, "formats", ["dxf"]);
469
+ d(this, "defaults");
473
470
  this.defaults = t;
474
471
  }
475
472
  accepts(t, r) {
476
- return Y(t) === "dxf" || rt(t, r) === "dxf";
473
+ return L(t) === "dxf" || B(t, r) === "dxf";
477
474
  }
478
475
  async load(t, r = {}) {
479
- var h;
476
+ var l;
480
477
  ({ ...this.defaults, ...r });
481
- const i = performance.now(), s = await et(t), n = Pe(s), o = [];
478
+ const i = performance.now(), s = await _(t), n = ve(s), o = [];
482
479
  let a;
483
480
  try {
484
- a = await ge(n);
481
+ a = await fe(n);
485
482
  } catch (f) {
486
- o.push(`dxf-parser failed, using built-in fallback parser: ${f instanceof Error ? f.message : String(f)}`), a = ke(n);
483
+ o.push(`dxf-parser failed, using built-in fallback parser: ${f instanceof Error ? f.message : String(f)}`), a = ye(n);
487
484
  }
488
- const c = be(a, t.fileName ?? ((h = t.file) == null ? void 0 : h.name), o), l = performance.now() - i;
489
- return { document: c, raw: a, bytes: s.byteLength, elapsedMs: l, format: "dxf", warnings: c.warnings };
485
+ const c = de(a, t.fileName ?? ((l = t.file) == null ? void 0 : l.name), o), h = performance.now() - i;
486
+ return { document: c, raw: a, bytes: s.byteLength, elapsedMs: h, format: "dxf", warnings: c.warnings };
490
487
  }
491
488
  }
492
- async function ge(e) {
489
+ async function fe(e) {
493
490
  const t = await import("dxf-parser"), r = t.default ?? t.DxfParser;
494
491
  if (!r) throw new Error("dxf-parser did not expose a parser constructor.");
495
492
  return new r().parseSync(e);
496
493
  }
497
- function be(e, t, r = []) {
498
- const i = e && typeof e == "object" ? e : {}, s = ye(i), n = xe(i), a = (Array.isArray(i.entities) ? i.entities : []).filter((l) => !!l && typeof l == "object").map((l) => gt(l)), c = Xt({
494
+ function de(e, t, r = []) {
495
+ const i = e && typeof e == "object" ? e : {}, s = ue(i), n = me(i), a = (Array.isArray(i.entities) ? i.entities : []).filter((h) => !!h && typeof h == "object").map((h) => mt(h)), c = Rt({
499
496
  format: "dxf",
500
497
  sourceName: t,
501
498
  header: i.header && typeof i.header == "object" ? i.header : {},
@@ -508,66 +505,66 @@ function be(e, t, r = []) {
508
505
  });
509
506
  return a.length === 0 && c.warnings.push("DXF file did not expose any ENTITIES."), c;
510
507
  }
511
- function gt(e) {
512
- const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(), r = de(e, t), i = x(e.colorIndex ?? e.colorNumber ?? e.aci), s = x(e.color);
513
- if (r.colorIndex = i ?? (s !== void 0 && Math.abs(s) <= 257 ? s : void 0), r.trueColor = e.trueColor ?? e.true_color ?? e.colorRGB ?? e.trueColorValue ?? (s !== void 0 && Math.abs(s) > 257 ? s : void 0), r.layer = P(e.layer ?? e.layerName) ?? "0", r.isClosed = !!(e.shape ?? e.closed ?? e.isClosed) || (Number(e.flag ?? e.flags ?? 0) & 1) === 1, t === "LINE" && (r.startPoint = k(e.startPoint ?? { x: e.x1 ?? e.x, y: e.y1 ?? e.y, z: e.z1 ?? e.z }) ?? r.startPoint, r.endPoint = k(e.endPoint ?? { x: e.x2, y: e.y2, z: e.z2 }) ?? r.endPoint), (t === "TEXT" || t === "MTEXT" || t === "ATTRIB" || t === "ATTDEF") && (r.insertionPoint = k(e.startPoint ?? e.position ?? e.insertionPoint) ?? r.insertionPoint, r.text = P(e.text ?? e.string ?? e.value) ?? r.text, r.textHeight = x(e.textHeight ?? e.height) ?? r.textHeight, r.rotation = Nt(e.rotation ?? e.angle)), (t === "ARC" || t === "ELLIPSE") && (r.startAngle = Et(e.startAngle ?? e.start_angle), r.endAngle = Et(e.endAngle ?? e.end_angle)), t === "INSERT") {
514
- r.blockName = P(e.name ?? e.blockName) ?? r.blockName, r.insertionPoint = k(e.position ?? e.insertionPoint ?? e.point) ?? r.insertionPoint;
515
- const n = x(e.xScale ?? e.scaleX ?? e.xscale), o = x(e.yScale ?? e.scaleY ?? e.yscale), a = x(e.zScale ?? e.scaleZ ?? e.zscale);
516
- (n !== void 0 || o !== void 0 || a !== void 0) && (r.scale = { x: n ?? 1, y: o ?? n ?? 1, z: a ?? 1 }), r.rotation = Nt(e.rotation ?? e.angle);
508
+ function mt(e) {
509
+ const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(), r = ae(e, t), i = y(e.colorIndex ?? e.colorNumber ?? e.aci), s = y(e.color);
510
+ if (r.colorIndex = i ?? (s !== void 0 && Math.abs(s) <= 257 ? s : void 0), r.trueColor = e.trueColor ?? e.true_color ?? e.colorRGB ?? e.trueColorValue ?? (s !== void 0 && Math.abs(s) > 257 ? s : void 0), r.layer = C(e.layer ?? e.layerName) ?? "0", r.isClosed = !!(e.shape ?? e.closed ?? e.isClosed) || (Number(e.flag ?? e.flags ?? 0) & 1) === 1, t === "LINE" && (r.startPoint = k(e.startPoint ?? { x: e.x1 ?? e.x, y: e.y1 ?? e.y, z: e.z1 ?? e.z }) ?? r.startPoint, r.endPoint = k(e.endPoint ?? { x: e.x2, y: e.y2, z: e.z2 }) ?? r.endPoint), (t === "TEXT" || t === "MTEXT" || t === "ATTRIB" || t === "ATTDEF") && (r.insertionPoint = k(e.startPoint ?? e.position ?? e.insertionPoint) ?? r.insertionPoint, r.text = C(e.text ?? e.string ?? e.value) ?? r.text, r.textHeight = y(e.textHeight ?? e.height) ?? r.textHeight, r.rotation = xt(e.rotation ?? e.angle)), (t === "ARC" || t === "ELLIPSE") && (r.startAngle = wt(e.startAngle ?? e.start_angle), r.endAngle = wt(e.endAngle ?? e.end_angle)), t === "INSERT") {
511
+ r.blockName = C(e.name ?? e.blockName) ?? r.blockName, r.insertionPoint = k(e.position ?? e.insertionPoint ?? e.point) ?? r.insertionPoint;
512
+ const n = y(e.xScale ?? e.scaleX ?? e.xscale), o = y(e.yScale ?? e.scaleY ?? e.yscale), a = y(e.zScale ?? e.scaleZ ?? e.zscale);
513
+ (n !== void 0 || o !== void 0 || a !== void 0) && (r.scale = { x: n ?? 1, y: o ?? n ?? 1, z: a ?? 1 }), r.rotation = xt(e.rotation ?? e.angle);
517
514
  }
518
515
  if (t === "SPLINE") {
519
- const n = q(e.controlPoints ?? e.control_points ?? e.points);
516
+ const n = K(e.controlPoints ?? e.control_points ?? e.points);
520
517
  n.length && (r.controlPoints = n);
521
- const o = q(e.fitPoints ?? e.fit_points);
518
+ const o = K(e.fitPoints ?? e.fit_points);
522
519
  o.length && (r.fitPoints = o);
523
520
  }
524
- return t === "HATCH" && (r.loops = Ce(e), r.fillColorIndex = r.colorIndex), (t === "SOLID" || t === "TRACE" || t === "3DFACE") && (r.vertices = we(e), r.fillColorIndex = r.colorIndex), r;
521
+ return t === "HATCH" && (r.loops = be(e), r.fillColorIndex = r.colorIndex), (t === "SOLID" || t === "TRACE" || t === "3DFACE") && (r.vertices = ge(e), r.fillColorIndex = r.colorIndex), r;
525
522
  }
526
- function ye(e) {
527
- const t = {}, r = e.tables, i = e.layers ?? (r == null ? void 0 : r.layer) ?? (r == null ? void 0 : r.LAYER) ?? (r == null ? void 0 : r.layers), s = ve(i);
523
+ function ue(e) {
524
+ const t = {}, r = e.tables, i = e.layers ?? (r == null ? void 0 : r.layer) ?? (r == null ? void 0 : r.LAYER) ?? (r == null ? void 0 : r.layers), s = pe(i);
528
525
  for (const n of s) {
529
- const o = n, a = P(o.name ?? o.layerName);
530
- a && St(t, {
526
+ const o = n, a = C(o.name ?? o.layerName);
527
+ a && vt(t, {
531
528
  name: a,
532
529
  color: o.color ?? o.colorNumber ?? o.colorIndex,
533
- colorIndex: x(o.colorNumber ?? o.colorIndex ?? o.color),
534
- lineType: P(o.lineType ?? o.linetype),
530
+ colorIndex: y(o.colorNumber ?? o.colorIndex ?? o.color),
531
+ lineType: C(o.lineType ?? o.linetype),
535
532
  isVisible: Number(o.colorNumber ?? o.colorIndex ?? o.color ?? 1) >= 0,
536
533
  isFrozen: !!o.frozen,
537
534
  isLocked: !!o.locked,
538
535
  raw: o
539
536
  });
540
537
  }
541
- return t[0] || St(t, { name: "0", colorIndex: 7, isVisible: !0 }), t;
538
+ return t[0] || vt(t, { name: "0", colorIndex: 7, isVisible: !0 }), t;
542
539
  }
543
- function xe(e) {
540
+ function me(e) {
544
541
  const t = {}, r = e.blocks;
545
542
  if (!r || typeof r != "object") return t;
546
543
  if (Array.isArray(r))
547
- for (const i of r) Mt(t, i);
544
+ for (const i of r) yt(t, i);
548
545
  else
549
- for (const [i, s] of Object.entries(r)) Mt(t, s, i);
546
+ for (const [i, s] of Object.entries(r)) yt(t, s, i);
550
547
  return t;
551
548
  }
552
- function Mt(e, t, r) {
549
+ function yt(e, t, r) {
553
550
  if (!t || typeof t != "object") return;
554
- const i = t, s = P(i.name ?? i.blockName ?? r);
551
+ const i = t, s = C(i.name ?? i.blockName ?? r);
555
552
  if (!s) return;
556
- const o = (Array.isArray(i.entities) ? i.entities : []).filter((a) => !!a && typeof a == "object").map((a) => gt(a));
557
- ue(e, { name: s, basePoint: k(i.basePoint ?? i.position) ?? { x: 0, y: 0 }, entities: o, raw: i });
553
+ const o = (Array.isArray(i.entities) ? i.entities : []).filter((a) => !!a && typeof a == "object").map((a) => mt(a));
554
+ ce(e, { name: s, basePoint: k(i.basePoint ?? i.position) ?? { x: 0, y: 0 }, entities: o, raw: i });
558
555
  }
559
- function ve(e) {
556
+ function pe(e) {
560
557
  if (!e) return [];
561
558
  if (Array.isArray(e)) return e;
562
559
  if (typeof e != "object") return [];
563
560
  const t = e;
564
561
  return Array.isArray(t.entries) ? t.entries : Array.isArray(t.records) ? t.records : Array.isArray(t.layers) ? t.layers : Object.values(t).filter((r) => r && typeof r == "object");
565
562
  }
566
- function q(e) {
563
+ function K(e) {
567
564
  return Array.isArray(e) ? e.map(k).filter((t) => !!t) : [];
568
565
  }
569
- function we(e) {
570
- const t = q(e.vertices ?? e.points);
566
+ function ge(e) {
567
+ const t = K(e.vertices ?? e.points);
571
568
  if (t.length) return t;
572
569
  const r = [];
573
570
  for (let i = 0; i < 4; i++) {
@@ -576,51 +573,51 @@ function we(e) {
576
573
  }
577
574
  return r;
578
575
  }
579
- function Ce(e) {
576
+ function be(e) {
580
577
  const t = e.boundaryLoops ?? e.loops ?? e.paths;
581
578
  if (Array.isArray(t))
582
579
  return t.map((r) => {
583
580
  const i = r;
584
- return { vertices: q(i.vertices ?? i.points), isClosed: !0 };
581
+ return { vertices: K(i.vertices ?? i.points), isClosed: !0 };
585
582
  }).filter((r) => r.vertices && r.vertices.length > 0);
586
583
  }
587
- function Nt(e) {
588
- const t = x(e);
584
+ function xt(e) {
585
+ const t = y(e);
589
586
  if (t !== void 0)
590
- return Math.abs(t) > Math.PI * 2 + 1e-6 ? A(t) : t;
587
+ return Math.abs(t) > Math.PI * 2 + 1e-6 ? E(t) : t;
591
588
  }
592
- function Et(e) {
593
- const t = x(e);
589
+ function wt(e) {
590
+ const t = y(e);
594
591
  if (t !== void 0)
595
- return Math.abs(t) > Math.PI * 2 + 1e-6 ? A(t) : t;
592
+ return Math.abs(t) > Math.PI * 2 + 1e-6 ? E(t) : t;
596
593
  }
597
- function Pe(e) {
594
+ function ve(e) {
598
595
  const t = new TextDecoder("utf-8", { fatal: !1 }).decode(e);
599
596
  return t.includes("SECTION") ? t : new TextDecoder("iso-8859-1", { fatal: !1 }).decode(e);
600
597
  }
601
- function ke(e) {
602
- var l, h;
598
+ function ye(e) {
599
+ var h, l;
603
600
  const t = e.replace(/\r\n/g, `
604
601
  `).replace(/\r/g, `
605
602
  `).split(`
606
603
  `), r = [];
607
604
  for (let f = 0; f < t.length - 1; f += 2) {
608
- const d = Number((l = t[f]) == null ? void 0 : l.trim()), p = t[f + 1] ?? "";
609
- Number.isFinite(d) && r.push({ code: d, value: p.trimEnd() });
605
+ const u = Number((h = t[f]) == null ? void 0 : h.trim()), p = t[f + 1] ?? "";
606
+ Number.isFinite(u) && r.push({ code: u, value: p.trimEnd() });
610
607
  }
611
608
  const i = [], s = {};
612
609
  let n = "", o = [], a;
613
610
  for (let f = 0; f < r.length; f++) {
614
- const d = r[f];
615
- if (d.code === 0 && d.value === "SECTION") {
616
- n = ((h = r[f + 1]) == null ? void 0 : h.code) === 2 ? r[f + 1].value.toUpperCase() : "", f++;
611
+ const u = r[f];
612
+ if (u.code === 0 && u.value === "SECTION") {
613
+ n = ((l = r[f + 1]) == null ? void 0 : l.code) === 2 ? r[f + 1].value.toUpperCase() : "", f++;
617
614
  continue;
618
615
  }
619
- if (d.code === 0 && d.value === "ENDSEC") {
616
+ if (u.code === 0 && u.value === "ENDSEC") {
620
617
  c(), n = "";
621
618
  continue;
622
619
  }
623
- n === "ENTITIES" && (d.code === 0 ? (c(), o = [d]) : o.push(d));
620
+ n === "ENTITIES" && (u.code === 0 ? (c(), o = [u]) : o.push(u));
624
621
  }
625
622
  return c(), { header: {}, tables: {}, entities: i, blocks: s };
626
623
  function c() {
@@ -628,8 +625,8 @@ function ke(e) {
628
625
  if (!o.length) return;
629
626
  const f = (p = o[0]) == null ? void 0 : p.value.toUpperCase();
630
627
  if (f === "VERTEX" && a) {
631
- const g = C(o, 10, 20, 30);
632
- g && (a.vertices ?? (a.vertices = [])).push({ ...g, bulge: b(o, 42) }), o = [];
628
+ const v = w(o, 10, 20, 30);
629
+ v && (a.vertices ?? (a.vertices = [])).push({ ...v, bulge: g(o, 42) }), o = [];
633
630
  return;
634
631
  }
635
632
  if (f === "SEQEND") {
@@ -640,85 +637,85 @@ function ke(e) {
640
637
  o = [];
641
638
  return;
642
639
  }
643
- const d = Se(f, o);
644
- f === "POLYLINE" ? a = d : i.push(d), o = [];
640
+ const u = xe(f, o);
641
+ f === "POLYLINE" ? a = u : i.push(u), o = [];
645
642
  }
646
643
  }
647
- function Se(e, t) {
644
+ function xe(e, t) {
648
645
  const r = {
649
646
  type: e,
650
- handle: z(t, 5),
651
- layer: z(t, 8) ?? "0",
652
- colorIndex: b(t, 62),
653
- trueColor: b(t, 420),
654
- lineType: z(t, 6),
655
- lineweight: b(t, 370)
647
+ handle: H(t, 5),
648
+ layer: H(t, 8) ?? "0",
649
+ colorIndex: g(t, 62),
650
+ trueColor: g(t, 420),
651
+ lineType: H(t, 6),
652
+ lineweight: g(t, 370)
656
653
  };
657
654
  switch (e) {
658
655
  case "LINE":
659
- Object.assign(r, { startPoint: C(t, 10, 20, 30), endPoint: C(t, 11, 21, 31) });
656
+ Object.assign(r, { startPoint: w(t, 10, 20, 30), endPoint: w(t, 11, 21, 31) });
660
657
  break;
661
658
  case "CIRCLE":
662
- Object.assign(r, { center: C(t, 10, 20, 30), radius: b(t, 40) });
659
+ Object.assign(r, { center: w(t, 10, 20, 30), radius: g(t, 40) });
663
660
  break;
664
661
  case "ARC":
665
- Object.assign(r, { center: C(t, 10, 20, 30), radius: b(t, 40), startAngle: V(b(t, 50)), endAngle: V(b(t, 51)) });
662
+ Object.assign(r, { center: w(t, 10, 20, 30), radius: g(t, 40), startAngle: G(g(t, 50)), endAngle: G(g(t, 51)) });
666
663
  break;
667
664
  case "POINT":
668
- Object.assign(r, { point: C(t, 10, 20, 30) });
665
+ Object.assign(r, { point: w(t, 10, 20, 30) });
669
666
  break;
670
667
  case "TEXT":
671
668
  case "MTEXT":
672
- Object.assign(r, { insertionPoint: C(t, 10, 20, 30), text: Ee(t), textHeight: b(t, 40), rotation: V(b(t, 50)) });
669
+ Object.assign(r, { insertionPoint: w(t, 10, 20, 30), text: ke(t), textHeight: g(t, 40), rotation: G(g(t, 50)) });
673
670
  break;
674
671
  case "LWPOLYLINE":
675
- Object.assign(r, { vertices: Ne(t), flag: b(t, 70), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
672
+ Object.assign(r, { vertices: Ce(t), flag: g(t, 70), isClosed: (Number(g(t, 70) ?? 0) & 1) === 1 });
676
673
  break;
677
674
  case "POLYLINE":
678
- Object.assign(r, { vertices: [], flag: b(t, 70), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
675
+ Object.assign(r, { vertices: [], flag: g(t, 70), isClosed: (Number(g(t, 70) ?? 0) & 1) === 1 });
679
676
  break;
680
677
  case "ELLIPSE":
681
- Object.assign(r, { center: C(t, 10, 20, 30), majorAxisEndPoint: C(t, 11, 21, 31), axisRatio: b(t, 40), startAngle: b(t, 41), endAngle: b(t, 42) });
678
+ Object.assign(r, { center: w(t, 10, 20, 30), majorAxisEndPoint: w(t, 11, 21, 31), axisRatio: g(t, 40), startAngle: g(t, 41), endAngle: g(t, 42) });
682
679
  break;
683
680
  case "SPLINE":
684
- Object.assign(r, { controlPoints: Me(t, 10, 20, 30), degree: b(t, 71), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
681
+ Object.assign(r, { controlPoints: we(t, 10, 20, 30), degree: g(t, 71), isClosed: (Number(g(t, 70) ?? 0) & 1) === 1 });
685
682
  break;
686
683
  case "INSERT":
687
- Object.assign(r, { name: z(t, 2), blockName: z(t, 2), insertionPoint: C(t, 10, 20, 30), rotation: V(b(t, 50)), scale: { x: b(t, 41) ?? 1, y: b(t, 42) ?? b(t, 41) ?? 1, z: b(t, 43) ?? 1 } });
684
+ Object.assign(r, { name: H(t, 2), blockName: H(t, 2), insertionPoint: w(t, 10, 20, 30), rotation: G(g(t, 50)), scale: { x: g(t, 41) ?? 1, y: g(t, 42) ?? g(t, 41) ?? 1, z: g(t, 43) ?? 1 } });
688
685
  break;
689
686
  case "SOLID":
690
687
  case "TRACE":
691
688
  case "3DFACE":
692
- Object.assign(r, { vertices: [C(t, 10, 20, 30), C(t, 11, 21, 31), C(t, 12, 22, 32), C(t, 13, 23, 33)].filter(Boolean) });
689
+ Object.assign(r, { vertices: [w(t, 10, 20, 30), w(t, 11, 21, 31), w(t, 12, 22, 32), w(t, 13, 23, 33)].filter(Boolean) });
693
690
  break;
694
691
  }
695
- return gt(r);
692
+ return mt(r);
696
693
  }
697
- function b(e, t) {
694
+ function g(e, t) {
698
695
  var s;
699
696
  const r = (s = e.find((n) => n.code === t)) == null ? void 0 : s.value, i = Number(r);
700
697
  return Number.isFinite(i) ? i : void 0;
701
698
  }
702
- function z(e, t) {
699
+ function H(e, t) {
703
700
  var i;
704
701
  const r = (i = e.find((s) => s.code === t)) == null ? void 0 : i.value;
705
702
  return r && r.length > 0 ? r : void 0;
706
703
  }
707
- function C(e, t, r, i) {
708
- const s = b(e, t), n = b(e, r), o = b(e, i);
704
+ function w(e, t, r, i) {
705
+ const s = g(e, t), n = g(e, r), o = g(e, i);
709
706
  if (!(s === void 0 || n === void 0))
710
707
  return o === void 0 ? { x: s, y: n } : { x: s, y: n, z: o };
711
708
  }
712
- function Me(e, t, r, i) {
709
+ function we(e, t, r, i) {
713
710
  const s = [];
714
711
  for (let n = 0; n < e.length; n++) {
715
712
  if (e[n].code !== t) continue;
716
- const o = Number(e[n].value), a = e.slice(n + 1).find((f) => f.code === r), c = e.slice(n + 1).find((f) => f.code === i), l = Number(a == null ? void 0 : a.value), h = Number(c == null ? void 0 : c.value);
717
- Number.isFinite(o) && Number.isFinite(l) && s.push(Number.isFinite(h) ? { x: o, y: l, z: h } : { x: o, y: l });
713
+ const o = Number(e[n].value), a = e.slice(n + 1).find((f) => f.code === r), c = e.slice(n + 1).find((f) => f.code === i), h = Number(a == null ? void 0 : a.value), l = Number(c == null ? void 0 : c.value);
714
+ Number.isFinite(o) && Number.isFinite(h) && s.push(Number.isFinite(l) ? { x: o, y: h, z: l } : { x: o, y: h });
718
715
  }
719
716
  return s;
720
717
  }
721
- function Ne(e) {
718
+ function Ce(e) {
722
719
  const t = [];
723
720
  for (let r = 0; r < e.length; r++) {
724
721
  if (e[r].code !== 10) continue;
@@ -730,14 +727,247 @@ function Ne(e) {
730
727
  }
731
728
  return t;
732
729
  }
733
- function Ee(e) {
730
+ function ke(e) {
734
731
  const t = e.filter((r) => r.code === 1 || r.code === 3).map((r) => r.value);
735
732
  return t.length ? t.join("") : void 0;
736
733
  }
737
- function V(e) {
738
- return typeof e == "number" && Number.isFinite(e) ? A(e) : void 0;
734
+ function G(e) {
735
+ return typeof e == "number" && Number.isFinite(e) ? E(e) : void 0;
736
+ }
737
+ class Pe {
738
+ constructor(t = {}) {
739
+ d(this, "id", "dwf");
740
+ d(this, "label", "DWF/DWFx native viewer powered by dwf-viewer");
741
+ d(this, "formats", ["dwf", "dwfx", "xps"]);
742
+ d(this, "nativeRenderer", !0);
743
+ d(this, "defaults");
744
+ d(this, "native");
745
+ d(this, "host");
746
+ d(this, "lastStats");
747
+ this.defaults = t;
748
+ }
749
+ accepts(t, r) {
750
+ const i = L(t);
751
+ if (i === "dwf" || i === "dwfx" || i === "xps") return !0;
752
+ const s = B(t, r);
753
+ return s === "dwf" || s === "dwfx" || s === "xps";
754
+ }
755
+ async load(t, r = {}) {
756
+ var f, u, p, v;
757
+ const i = { ...this.defaults, ...r }, s = performance.now(), n = t.fileName ?? ((f = t.file) == null ? void 0 : f.name), o = await _(t), a = Pt(B(t, o), L(t));
758
+ (u = i.onProgress) == null || u.call(i, { phase: "parse", format: a, message: "Opening DWF/DWFx with dwf-viewer…", percent: 48 });
759
+ const c = await Zt(o, { fileName: n });
760
+ (p = i.onProgress) == null || p.call(i, { phase: "normalize", format: a, message: "Reading DWF pages, sheets and model metadata…", percent: 76 });
761
+ const h = Ct(c, n, a, i.keepRaw === !0), l = performance.now() - s;
762
+ return (v = i.onProgress) == null || v.call(i, { phase: "done", format: h.format, message: "DWF/DWFx document ready.", percent: 100, elapsedMs: l }), { document: h, raw: i.keepRaw ? c : void 0, bytes: o.byteLength, elapsedMs: l, format: h.format, warnings: h.warnings };
763
+ }
764
+ async mount(t, r, i = {}) {
765
+ var v, S, O, z, Y;
766
+ const s = { ...this.defaults, ...i }, n = performance.now(), o = t.fileName ?? ((v = t.file) == null ? void 0 : v.name), a = await _(t), c = Pt(B(t, a), L(t)), h = Ie(s), l = St(s);
767
+ (S = s.onProgress) == null || S.call(s, { phase: "native-render", format: c, message: "Mounting native DWF renderer…", percent: 28 }), this.unmount(), this.host = r, r.replaceChildren(), this.native = new qt(r, {
768
+ wasmUrl: h,
769
+ preferWebgl: s.dwfPreferWebgl ?? !0,
770
+ preferWasm: s.dwfPreferWasm ?? !0,
771
+ background: l,
772
+ maxDevicePixelRatio: s.dwfMaxDevicePixelRatio ?? 2,
773
+ maxCanvasPixels: s.dwfMaxCanvasPixels ?? 16777216,
774
+ maxGpuCacheBytes: s.dwfMaxGpuCacheBytes ?? 160 * 1024 * 1024,
775
+ maxCachedScenes: s.dwfMaxCachedScenes ?? 2
776
+ }), (O = s.onProgress) == null || O.call(s, { phase: "parse", format: c, message: "Parsing DWF package and page streams…", percent: 58 }), await this.native.load(a, {
777
+ fileName: o,
778
+ wasmUrl: h,
779
+ preferWebgl: s.dwfPreferWebgl ?? !0,
780
+ preferWasm: s.dwfPreferWasm ?? !0,
781
+ background: l,
782
+ maxGpuCacheBytes: s.dwfMaxGpuCacheBytes ?? 160 * 1024 * 1024,
783
+ maxCachedScenes: s.dwfMaxCachedScenes ?? 2
784
+ }), (z = s.onProgress) == null || z.call(s, { phase: "render", format: c, message: "Rendering DWF/DWFx with dwf-viewer…", percent: 88 }), this.lastStats = await this.native.render();
785
+ const f = this.native.getDocument(), u = Ct(f, o, c, s.keepRaw === !0);
786
+ u.metadata.loaderMode = "Native DWF", u.metadata.nativeRenderer = "dwf-viewer", u.metadata.nativeRenderStats = this.lastStats ? { ...this.lastStats, warnings: this.lastStats.warnings.length } : void 0;
787
+ const p = performance.now() - n;
788
+ return (Y = s.onProgress) == null || Y.call(s, { phase: "done", format: u.format, message: "DWF/DWFx rendered.", percent: 100, elapsedMs: p }), { document: u, raw: s.keepRaw ? f : void 0, bytes: a.byteLength, elapsedMs: p, format: u.format, warnings: u.warnings };
789
+ }
790
+ unmount() {
791
+ var t;
792
+ (t = this.native) == null || t.dispose(), this.native = void 0, this.lastStats = void 0, this.host && this.host.replaceChildren();
793
+ }
794
+ fit() {
795
+ var t;
796
+ (t = this.native) == null || t.fit();
797
+ }
798
+ zoomIn() {
799
+ var r;
800
+ const t = (r = this.native) == null ? void 0 : r.zoomInButton;
801
+ t == null || t.click();
802
+ }
803
+ zoomOut() {
804
+ var r;
805
+ const t = (r = this.native) == null ? void 0 : r.zoomOutButton;
806
+ t == null || t.click();
807
+ }
808
+ resize() {
809
+ var t;
810
+ (t = this.native) == null || t.render();
811
+ }
812
+ setNativeOptions(t) {
813
+ var i, s, n;
814
+ const r = this.native;
815
+ if (r) {
816
+ if (typeof t.dwfBackground == "string") r.background = t.dwfBackground;
817
+ else {
818
+ const o = St(t);
819
+ o && (r.background = o);
820
+ }
821
+ typeof t.dwfPreferWebgl == "boolean" && ((i = r.setPreferWebgl) == null || i.call(r, t.dwfPreferWebgl)), typeof t.dwfPreferWasm == "boolean" && ((s = r.setPreferWasm) == null || s.call(r, t.dwfPreferWasm)), (n = r.render) == null || n.call(r);
822
+ }
823
+ }
824
+ getLastNativeStats() {
825
+ return this.lastStats;
826
+ }
827
+ }
828
+ function Ct(e, t, r, i) {
829
+ var a, c;
830
+ const s = kt((e == null ? void 0 : e.diagnostics) ?? []), n = ((e == null ? void 0 : e.pageData) ?? []).map((h, l) => Se(h, l));
831
+ for (const h of (e == null ? void 0 : e.pageData) ?? []) s.push(...kt(h.diagnostics));
832
+ const o = {
833
+ parser: "dwf-viewer",
834
+ nativeRenderer: "dwf-viewer",
835
+ dwfKind: e == null ? void 0 : e.kind,
836
+ packageEntries: ((a = e == null ? void 0 : e.packageEntries) == null ? void 0 : a.length) ?? 0,
837
+ resources: ((c = e == null ? void 0 : e.resources) == null ? void 0 : c.length) ?? 0,
838
+ pageKinds: Be(((e == null ? void 0 : e.pageData) ?? []).map((h) => h.kind)),
839
+ pageNames: ((e == null ? void 0 : e.pages) ?? []).map((h) => h.name)
840
+ };
841
+ return Rt({
842
+ format: r,
843
+ sourceName: t,
844
+ layers: {},
845
+ blocks: {},
846
+ pages: n,
847
+ entities: he(n),
848
+ metadata: o,
849
+ warnings: Ae(s),
850
+ raw: i ? e : void 0
851
+ });
852
+ }
853
+ function Se(e, t) {
854
+ const r = Me(e, t);
855
+ return {
856
+ index: t,
857
+ name: e.name || e.sourcePath || `${t + 1}`,
858
+ width: e.width || 1e3,
859
+ height: e.height || 1e3,
860
+ entities: r
861
+ };
862
+ }
863
+ function Me(e, t) {
864
+ return e.kind === "w2d-text" ? e.primitives.flatMap((r, i) => Ne(r, t, i)) : e.kind === "image" ? [{ type: "DWF_IMAGE_PAGE", kind: "image", pageIndex: t, width: e.width, height: e.height, imageSource: e.sourcePath }] : e.kind === "w3d-model" ? e.model.meshes.map((r, i) => ({
865
+ id: r.id,
866
+ type: "W3D_MESH",
867
+ kind: "solid",
868
+ pageIndex: t,
869
+ color: r.color ? Le(r.color) : void 0,
870
+ name: r.name || `mesh-${i + 1}`,
871
+ raw: { vertexCount: r.vertexCount, triangleCount: r.triangleCount, materialId: r.materialId }
872
+ })) : e.kind === "xps-fixed-page" ? [{ type: "XPS_FIXED_PAGE", kind: "viewport", pageIndex: t, width: e.width, height: e.height, raw: { sourcePath: e.sourcePath } }] : [{ type: "DWF_PAGE", kind: "viewport", pageIndex: t, width: e.width, height: e.height, raw: { sourcePath: e.sourcePath } }];
873
+ }
874
+ function Ne(e, t, r) {
875
+ const i = {
876
+ id: `dwf-${t}-${r}`,
877
+ pageIndex: t,
878
+ color: e.stroke,
879
+ fillColor: e.fill,
880
+ lineweight: e.lineWidth,
881
+ raw: { matrix: e.matrix }
882
+ };
883
+ if (e.type === "polyline" || e.type === "polygon")
884
+ return [{
885
+ ...i,
886
+ type: e.type === "polygon" ? "DWF_POLYGON" : "DWF_POLYLINE",
887
+ kind: "polyline",
888
+ vertices: Ee(e.points),
889
+ isClosed: e.type === "polygon"
890
+ }];
891
+ if (e.type === "path")
892
+ return [{ ...i, type: "DWF_PATH", kind: "path", commands: e.commands }];
893
+ if (e.type === "text")
894
+ return [{
895
+ ...i,
896
+ type: "DWF_TEXT",
897
+ kind: "text",
898
+ insertionPoint: { x: e.x, y: e.y, z: 0 },
899
+ text: e.text,
900
+ textHeight: e.size
901
+ }];
902
+ if (e.type === "rect") {
903
+ const s = e.x, n = e.y, o = e.width, a = e.height;
904
+ return [{
905
+ ...i,
906
+ type: "DWF_RECT",
907
+ kind: "polyline",
908
+ isClosed: !0,
909
+ vertices: [
910
+ { x: s, y: n, z: 0 },
911
+ { x: s + o, y: n, z: 0 },
912
+ { x: s + o, y: n + a, z: 0 },
913
+ { x: s, y: n + a, z: 0 }
914
+ ]
915
+ }];
916
+ }
917
+ return [];
918
+ }
919
+ function Ee(e) {
920
+ const t = [];
921
+ for (let r = 0; r + 1 < e.length; r += 2) t.push({ x: e[r], y: e[r + 1], z: 0 });
922
+ return t;
923
+ }
924
+ function kt(e) {
925
+ return e.filter((t) => t.level !== "info").map((t) => `${t.code}: ${t.message}${t.source ? ` (${t.source})` : ""}`);
926
+ }
927
+ function Pt(e, t) {
928
+ return t === "dwf" || t === "dwfx" || t === "xps" ? t : e === "dwf" || e === "dwfx" || e === "xps" ? e : "dwf";
929
+ }
930
+ function Ie(e) {
931
+ if (e.dwfWasmUrl) return e.dwfWasmUrl;
932
+ if (typeof document > "u") return;
933
+ const t = e.wasmPath ? new URL(Te(e.wasmPath), document.baseURI).href : new URL("wasm/", document.baseURI).href;
934
+ return new URL("dwfv-render.wasm", t).href;
935
+ }
936
+ function St(e) {
937
+ if (e.dwfBackground) return e.dwfBackground;
938
+ const t = e.canvasOptions;
939
+ return (t == null ? void 0 : t.background) ?? "#05070d";
940
+ }
941
+ function Te(e) {
942
+ return e.endsWith("/") ? e : `${e}/`;
739
943
  }
740
- const Ie = {
944
+ function Le(e) {
945
+ const [t, r, i] = e.map((s) => Math.max(0, Math.min(255, Math.round(s * 255))));
946
+ return `#${et(t)}${et(r)}${et(i)}`;
947
+ }
948
+ function et(e) {
949
+ return e.toString(16).padStart(2, "0");
950
+ }
951
+ function Be(e) {
952
+ const t = {};
953
+ for (const r of e) t[r] = (t[r] ?? 0) + 1;
954
+ return t;
955
+ }
956
+ function Ae(e) {
957
+ return Array.from(new Set(e));
958
+ }
959
+ function Fe(e = {}) {
960
+ return new Jt([
961
+ new se(e),
962
+ new le(e),
963
+ new Pe(e)
964
+ ]);
965
+ }
966
+ function We(e) {
967
+ const t = e;
968
+ return t.nativeRenderer === !0 && typeof t.mount == "function";
969
+ }
970
+ const Re = {
741
971
  1: "#ff0000",
742
972
  2: "#ffff00",
743
973
  3: "#00ff00",
@@ -993,19 +1223,19 @@ const Ie = {
993
1223
  254: "#bebebe",
994
1224
  255: "#ffffff"
995
1225
  };
996
- function T(e, t = "#ffffff", r = t) {
1226
+ function N(e, t = "#ffffff", r = t) {
997
1227
  if (typeof e != "number" || Number.isNaN(e)) return t;
998
1228
  const i = Math.abs(Math.trunc(e));
999
- return i === 0 || i === 256 || i === 257 ? t : i === 7 ? r : Ie[i] ?? t;
1229
+ return i === 0 || i === 256 || i === 257 ? t : i === 7 ? r : Re[i] ?? t;
1000
1230
  }
1001
- function H(e, t = "rgb") {
1231
+ function U(e, t = "rgb") {
1002
1232
  const r = Math.max(0, Math.trunc(e)) & 16777215, i = r >> 16 & 255, s = r >> 8 & 255, n = r & 255;
1003
1233
  return `rgb(${t === "rgb" ? i : n}, ${s}, ${t === "rgb" ? n : i})`;
1004
1234
  }
1005
- function F(e) {
1235
+ function A(e) {
1006
1236
  if (typeof e == "string") {
1007
1237
  const t = e.trim();
1008
- return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ? K(t) ?? t : {
1238
+ return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ? De(t) ?? t : {
1009
1239
  red: "#ff0000",
1010
1240
  yellow: "#ffff00",
1011
1241
  green: "#00ff00",
@@ -1024,111 +1254,111 @@ function F(e) {
1024
1254
  return Number.isFinite(n) && n >= 0 && n < 1 ? `rgba(${r}, ${i}, ${s}, ${n})` : `rgb(${r}, ${i}, ${s})`;
1025
1255
  }
1026
1256
  }
1027
- function K(e) {
1257
+ function De(e) {
1028
1258
  if (!e) return;
1029
1259
  const t = e.trim();
1030
1260
  if (/^#[0-9a-f]{8}$/i.test(t)) {
1031
1261
  const r = parseInt(t.slice(1, 3), 16) / 255, i = parseInt(t.slice(3, 5), 16), s = parseInt(t.slice(5, 7), 16), n = parseInt(t.slice(7, 9), 16);
1032
- return r >= 0.999 ? `rgb(${i}, ${s}, ${n})` : `rgba(${i}, ${s}, ${n}, ${ut(r)})`;
1262
+ return r >= 0.999 ? `rgb(${i}, ${s}, ${n})` : `rgba(${i}, ${s}, ${n}, ${dt(r)})`;
1033
1263
  }
1034
1264
  if (/^#[0-9a-f]{6}$/i.test(t) || /^#[0-9a-f]{3}$/i.test(t)) return t;
1035
1265
  if (/^sc#/i.test(t)) {
1036
1266
  const r = t.slice(3).split(",").map((a) => Number(a.trim())), [i, s, n, o] = r.length === 4 ? r : [1, ...r];
1037
- if ([i, s, n, o].every(Number.isFinite)) return `rgba(${Math.round(s * 255)}, ${Math.round(n * 255)}, ${Math.round(o * 255)}, ${ut(i)})`;
1267
+ if ([i, s, n, o].every(Number.isFinite)) return `rgba(${Math.round(s * 255)}, ${Math.round(n * 255)}, ${Math.round(o * 255)}, ${dt(i)})`;
1038
1268
  }
1039
1269
  }
1040
- function D(e, t, r = {}) {
1270
+ function F(e, t, r = {}) {
1041
1271
  const i = r.foreground ?? "#ffffff", s = i;
1042
1272
  let n;
1043
- const o = F(e.trueColor) ?? F(e.color) ?? F(e.colorName);
1273
+ const o = A(e.trueColor) ?? A(e.color) ?? A(e.colorName);
1044
1274
  if (o && (n = o), !n) {
1045
- const a = De(e, ["trueColor", "true_color", "truecolor", "colorRGB", "colorRgb", "rgbColor", "rgb"]);
1046
- typeof a == "number" && a >= 0 && a <= 16777215 && (n = H(a, r.trueColorByteOrder ?? "rgb"));
1275
+ const a = _e(e, ["trueColor", "true_color", "truecolor", "colorRGB", "colorRgb", "rgbColor", "rgb"]);
1276
+ typeof a == "number" && a >= 0 && a <= 16777215 && (n = U(a, r.trueColorByteOrder ?? "rgb"));
1047
1277
  }
1048
1278
  if (!n) {
1049
- const a = Gt(e.colorIndex, e.colorNumber, e.aci);
1050
- typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (n = T(a, s, i));
1279
+ const a = Ut(e.colorIndex, e.colorNumber, e.aci);
1280
+ typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (n = N(a, s, i));
1051
1281
  }
1052
1282
  if (!n && typeof e.color == "number") {
1053
1283
  const a = Number(e.color);
1054
- Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (n = T(a, s, i)) : n = H(a, r.trueColorByteOrder ?? "rgb");
1284
+ Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (n = N(a, s, i)) : n = U(a, r.trueColorByteOrder ?? "rgb");
1055
1285
  }
1056
1286
  if (!n) {
1057
- const a = Fe(t, e.layer);
1058
- n = Ae(a, r);
1287
+ const a = Xe(t, e.layer);
1288
+ n = ze(a, r);
1059
1289
  }
1060
- return Vt(n ?? s, r);
1290
+ return Ht(n ?? s, r);
1061
1291
  }
1062
- function ft(e, t, r = {}) {
1292
+ function lt(e, t, r = {}) {
1063
1293
  let i;
1064
- const s = F(e.fillColor);
1294
+ const s = A(e.fillColor);
1065
1295
  if (s && (i = s), !i && typeof e.fillColor == "number") {
1066
1296
  const n = e.fillColor;
1067
- i = Math.abs(n) <= 257 ? T(n, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff") : H(n, r.trueColorByteOrder ?? "rgb");
1297
+ i = Math.abs(n) <= 257 ? N(n, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff") : U(n, r.trueColorByteOrder ?? "rgb");
1068
1298
  }
1069
- return !i && typeof e.fillColorIndex == "number" && (i = T(e.fillColorIndex, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff")), i ? Vt(i, r) : void 0;
1299
+ return !i && typeof e.fillColorIndex == "number" && (i = N(e.fillColorIndex, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff")), i ? Ht(i, r) : void 0;
1070
1300
  }
1071
- function Vt(e, t = {}) {
1301
+ function Ht(e, t = {}) {
1072
1302
  if (t.contrastMode !== "adaptive") return e;
1073
1303
  const r = t.background ?? "#0b1020", i = t.foreground ?? "#ffffff";
1074
- return Te(e, r, i, t.minColorContrast ?? 2.4);
1304
+ return Oe(e, r, i, t.minColorContrast ?? 2.4);
1075
1305
  }
1076
- function Te(e, t, r, i = 2.4) {
1077
- const s = st(r) ?? { r: 255, g: 255, b: 255, a: 1 }, n = st(t) ?? { r: 11, g: 16, b: 32, a: 1 }, o = st(e);
1306
+ function Oe(e, t, r, i = 2.4) {
1307
+ const s = rt(r) ?? { r: 255, g: 255, b: 255, a: 1 }, n = rt(t) ?? { r: 11, g: 16, b: 32, a: 1 }, o = rt(e);
1078
1308
  if (!o) return e;
1079
- const a = It(o, n);
1080
- if (nt(a, n) >= i) return e;
1081
- const c = dt(n), l = c < 0.5 ? { r: 255, g: 255, b: 255, a: o.a } : { r: 0, g: 0, b: 0, a: o.a };
1082
- for (const h of [0.25, 0.4, 0.55, 0.7, 0.85, 1]) {
1083
- const f = We(o, l, h);
1084
- if (nt(It(f, n), n) >= i) return Tt(f);
1309
+ const a = Mt(o, n);
1310
+ if (it(a, n) >= i) return e;
1311
+ const c = ft(n), h = c < 0.5 ? { r: 255, g: 255, b: 255, a: o.a } : { r: 0, g: 0, b: 0, a: o.a };
1312
+ for (const l of [0.25, 0.4, 0.55, 0.7, 0.85, 1]) {
1313
+ const f = Ue(o, h, l);
1314
+ if (it(Mt(f, n), n) >= i) return Nt(f);
1085
1315
  }
1086
- return nt(s, n) >= i ? Tt(s) : c < 0.5 ? "#ffffff" : "#000000";
1316
+ return it(s, n) >= i ? Nt(s) : c < 0.5 ? "#ffffff" : "#000000";
1087
1317
  }
1088
- function $t(e) {
1318
+ function Xt(e) {
1089
1319
  return e ? e.isVisible !== !1 && e.isFrozen !== !0 : !0;
1090
1320
  }
1091
- function Ae(e, t) {
1321
+ function ze(e, t) {
1092
1322
  if (!e) return;
1093
- const r = t.foreground ?? "#ffffff", i = F(e.trueColor);
1323
+ const r = t.foreground ?? "#ffffff", i = A(e.trueColor);
1094
1324
  if (i) return i;
1095
- if (typeof e.trueColor == "number" && e.trueColor >= 0 && e.trueColor <= 16777215) return H(e.trueColor, t.trueColorByteOrder ?? "rgb");
1096
- const s = F(e.color);
1325
+ if (typeof e.trueColor == "number" && e.trueColor >= 0 && e.trueColor <= 16777215) return U(e.trueColor, t.trueColorByteOrder ?? "rgb");
1326
+ const s = A(e.color);
1097
1327
  if (s) return s;
1098
- if (Be(e.colorIndex)) return T(e.colorIndex, r, r);
1328
+ if (He(e.colorIndex)) return N(e.colorIndex, r, r);
1099
1329
  if (typeof e.color == "number") {
1100
1330
  const n = Number(e.color);
1101
- return Math.abs(n) <= 257 ? T(n, r, r) : H(n, t.trueColorByteOrder ?? "rgb");
1331
+ return Math.abs(n) <= 257 ? N(n, r, r) : U(n, t.trueColorByteOrder ?? "rgb");
1102
1332
  }
1103
- if (typeof e.colorIndex == "number") return T(e.colorIndex, r, r);
1333
+ if (typeof e.colorIndex == "number") return N(e.colorIndex, r, r);
1104
1334
  }
1105
- function Le(e) {
1106
- return Gt(e.colorIndex, e.colorNumber, e.aci) === 0 ? !0 : e.trueColor === void 0 && e.color === 0;
1335
+ function Ye(e) {
1336
+ return Ut(e.colorIndex, e.colorNumber, e.aci) === 0 ? !0 : e.trueColor === void 0 && e.color === 0;
1107
1337
  }
1108
- function jt(e, t, r, i = {}) {
1109
- if (!Le(e)) return e;
1110
- const s = D(t, r, i);
1338
+ function _t(e, t, r, i = {}) {
1339
+ if (!Ye(e)) return e;
1340
+ const s = F(t, r, i);
1111
1341
  return { ...e, color: s, trueColor: void 0, colorIndex: void 0, colorNumber: void 0 };
1112
1342
  }
1113
- function Be(e) {
1343
+ function He(e) {
1114
1344
  return typeof e == "number" && Number.isFinite(e) && Math.abs(Math.trunc(e)) >= 1 && Math.abs(Math.trunc(e)) <= 255;
1115
1345
  }
1116
- function Fe(e, t) {
1346
+ function Xe(e, t) {
1117
1347
  if (!(!e || !t))
1118
1348
  return e.layers[t] ?? e.layers[t.toLowerCase()] ?? Object.values(e.layers).find((r) => r.name.toLowerCase() === t.toLowerCase());
1119
1349
  }
1120
- function Gt(...e) {
1350
+ function Ut(...e) {
1121
1351
  for (const t of e)
1122
1352
  if (typeof t == "number" && Number.isFinite(t)) return t;
1123
1353
  }
1124
- function De(e, t) {
1354
+ function _e(e, t) {
1125
1355
  const r = e;
1126
1356
  for (const i of t) {
1127
1357
  const s = r[i];
1128
1358
  if (typeof s == "number" && Number.isFinite(s)) return s;
1129
1359
  }
1130
1360
  }
1131
- function st(e) {
1361
+ function rt(e) {
1132
1362
  const t = e.trim().toLowerCase();
1133
1363
  if (/^#[0-9a-f]{3}$/i.test(t))
1134
1364
  return {
@@ -1158,7 +1388,7 @@ function st(e) {
1158
1388
  }
1159
1389
  }
1160
1390
  }
1161
- function It(e, t) {
1391
+ function Mt(e, t) {
1162
1392
  const r = e.a + t.a * (1 - e.a);
1163
1393
  return r <= 0 ? { r: 0, g: 0, b: 0, a: 0 } : {
1164
1394
  r: (e.r * e.a + t.r * t.a * (1 - e.a)) / r,
@@ -1167,7 +1397,7 @@ function It(e, t) {
1167
1397
  a: r
1168
1398
  };
1169
1399
  }
1170
- function We(e, t, r) {
1400
+ function Ue(e, t, r) {
1171
1401
  const i = Math.max(0, Math.min(1, r));
1172
1402
  return {
1173
1403
  r: e.r + (t.r - e.r) * i,
@@ -1176,29 +1406,28 @@ function We(e, t, r) {
1176
1406
  a: e.a
1177
1407
  };
1178
1408
  }
1179
- function dt(e) {
1409
+ function ft(e) {
1180
1410
  const t = [e.r, e.g, e.b].map((r) => {
1181
1411
  const i = r / 255;
1182
1412
  return i <= 0.03928 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
1183
1413
  });
1184
1414
  return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
1185
1415
  }
1186
- function nt(e, t) {
1187
- const r = dt(e), i = dt(t), s = Math.max(r, i), n = Math.min(r, i);
1416
+ function it(e, t) {
1417
+ const r = ft(e), i = ft(t), s = Math.max(r, i), n = Math.min(r, i);
1188
1418
  return (s + 0.05) / (n + 0.05);
1189
1419
  }
1190
- function Tt(e) {
1420
+ function Nt(e) {
1191
1421
  const t = W(e.r), r = W(e.g), i = W(e.b);
1192
- return e.a < 0.999 ? `rgba(${t}, ${r}, ${i}, ${ut(e.a)})` : `rgb(${t}, ${r}, ${i})`;
1422
+ return e.a < 0.999 ? `rgba(${t}, ${r}, ${i}, ${dt(e.a)})` : `rgb(${t}, ${r}, ${i})`;
1193
1423
  }
1194
1424
  function W(e) {
1195
1425
  return Math.max(0, Math.min(255, Math.round(e)));
1196
1426
  }
1197
- function ut(e) {
1427
+ function dt(e) {
1198
1428
  return Math.round(e * 1e3) / 1e3;
1199
1429
  }
1200
- const At = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
1201
- function j(e, t) {
1430
+ function st(e, t) {
1202
1431
  return {
1203
1432
  a: e.a * t.a + e.c * t.b,
1204
1433
  b: e.b * t.a + e.d * t.b,
@@ -1208,313 +1437,50 @@ function j(e, t) {
1208
1437
  f: e.b * t.e + e.d * t.f + e.f
1209
1438
  };
1210
1439
  }
1211
- function Lt(e, t) {
1440
+ function Et(e, t) {
1212
1441
  return { a: 1, b: 0, c: 0, d: 1, e, f: t };
1213
1442
  }
1214
- function Oe(e) {
1443
+ function Ve(e) {
1215
1444
  const t = Math.cos(e), r = Math.sin(e);
1216
1445
  return { a: t, b: r, c: -r, d: t, e: 0, f: 0 };
1217
1446
  }
1218
- function Re(e, t = e) {
1447
+ function $e(e, t = e) {
1219
1448
  return { a: e, b: 0, c: 0, d: t, e: 0, f: 0 };
1220
1449
  }
1221
- function w(e, t) {
1450
+ function P(e, t) {
1222
1451
  return {
1223
1452
  x: e.x * t.a + e.y * t.c + t.e,
1224
1453
  y: e.x * t.b + e.y * t.d + t.f,
1225
1454
  z: "z" in e ? e.z : void 0
1226
1455
  };
1227
1456
  }
1228
- function Bt(e, t) {
1457
+ function It(e, t) {
1229
1458
  if (e)
1230
- return e.map((r) => ({ cmd: r.cmd, points: r.points.map((i) => w(i, t)) }));
1459
+ return e.map((r) => ({ cmd: r.cmd, points: r.points.map((i) => P(i, t)) }));
1231
1460
  }
1232
- function Q(e, t = { x: 0, y: 0 }) {
1461
+ function J(e, t = { x: 0, y: 0 }) {
1233
1462
  const r = e.insertionPoint ?? { x: 0, y: 0 }, i = e.scale, s = Number(typeof i == "object" && i ? i.x ?? 1 : e.scaleX ?? 1), n = Number(typeof i == "object" && i ? i.y ?? s : e.scaleY ?? s), o = Number(e.rotation ?? 0);
1234
- let a = Lt(r.x, r.y);
1235
- return a = j(a, Oe(Number.isFinite(o) ? o : 0)), a = j(a, Re(Number.isFinite(s) ? s : 1, Number.isFinite(n) ? n : 1)), a = j(a, Lt(-t.x, -t.y)), a;
1463
+ let a = Et(r.x, r.y);
1464
+ return a = st(a, Ve(Number.isFinite(o) ? o : 0)), a = st(a, $e(Number.isFinite(s) ? s : 1, Number.isFinite(n) ? n : 1)), a = st(a, Et(-t.x, -t.y)), a;
1236
1465
  }
1237
- function J(e, t) {
1466
+ function Q(e, t) {
1238
1467
  const r = { ...e, raw: e.raw ?? e };
1239
- if (e.startPoint && (r.startPoint = w(e.startPoint, t)), e.endPoint && (r.endPoint = w(e.endPoint, t)), e.center && (r.center = w(e.center, t)), e.insertionPoint && (r.insertionPoint = w(e.insertionPoint, t)), e.majorAxisEndPoint) {
1240
- const s = w({ x: 0, y: 0 }, t), n = w(e.majorAxisEndPoint, t);
1468
+ if (e.startPoint && (r.startPoint = P(e.startPoint, t)), e.endPoint && (r.endPoint = P(e.endPoint, t)), e.center && (r.center = P(e.center, t)), e.insertionPoint && (r.insertionPoint = P(e.insertionPoint, t)), e.majorAxisEndPoint) {
1469
+ const s = P({ x: 0, y: 0 }, t), n = P(e.majorAxisEndPoint, t);
1241
1470
  r.majorAxisEndPoint = { x: n.x - s.x, y: n.y - s.y, z: n.z };
1242
1471
  }
1243
- e.vertices && (r.vertices = e.vertices.map((s) => ({ ...w(s, t), bulge: s.bulge, startWidth: s.startWidth, endWidth: s.endWidth }))), e.points && (r.points = e.points.map((s) => w(s, t))), e.controlPoints && (r.controlPoints = e.controlPoints.map((s) => w(s, t))), e.fitPoints && (r.fitPoints = e.fitPoints.map((s) => w(s, t))), e.commands && (r.commands = Bt(e.commands, t)), e.loops && (r.loops = e.loops.map((s) => {
1472
+ e.vertices && (r.vertices = e.vertices.map((s) => ({ ...P(s, t), bulge: s.bulge, startWidth: s.startWidth, endWidth: s.endWidth }))), e.points && (r.points = e.points.map((s) => P(s, t))), e.controlPoints && (r.controlPoints = e.controlPoints.map((s) => P(s, t))), e.fitPoints && (r.fitPoints = e.fitPoints.map((s) => P(s, t))), e.commands && (r.commands = It(e.commands, t)), e.loops && (r.loops = e.loops.map((s) => {
1244
1473
  var n;
1245
1474
  return {
1246
1475
  ...s,
1247
- vertices: (n = s.vertices) == null ? void 0 : n.map((o) => w(o, t)),
1248
- commands: Bt(s.commands, t)
1476
+ vertices: (n = s.vertices) == null ? void 0 : n.map((o) => P(o, t)),
1477
+ commands: It(s.commands, t)
1249
1478
  };
1250
1479
  }));
1251
1480
  const i = Math.sqrt(Math.abs(t.a * t.d - t.b * t.c));
1252
1481
  return typeof e.radius == "number" && Number.isFinite(i) && (r.radius = e.radius * i), r;
1253
1482
  }
1254
- function tt(e) {
1255
- var c;
1256
- if (!e) return;
1257
- const t = ((c = e.match(/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g)) == null ? void 0 : c.map(Number)) ?? [];
1258
- if (t.length < 6) return;
1259
- const [r, i, s, n, o, a] = t;
1260
- return { a: r, b: i, c: s, d: n, e: o, f: a };
1261
- }
1262
- class mt extends Error {
1263
- constructor(r) {
1264
- super(r);
1265
- u(this, "format", "dwf");
1266
- this.name = "DwfUnsupportedError";
1267
- }
1268
- }
1269
- class ze {
1270
- constructor(t = {}) {
1271
- u(this, "id", "dwf");
1272
- u(this, "label", "DWFx/XPS 2D package loader");
1273
- u(this, "formats", ["dwf", "dwfx", "xps"]);
1274
- u(this, "defaults");
1275
- this.defaults = t;
1276
- }
1277
- accepts(t, r) {
1278
- const i = Y(t);
1279
- if (i === "dwf" || i === "dwfx" || i === "xps") return !0;
1280
- const s = rt(t, r);
1281
- return s === "dwf" || s === "dwfx" || s === "xps";
1282
- }
1283
- async load(t, r = {}) {
1284
- var d;
1285
- ({ ...this.defaults, ...r });
1286
- const i = performance.now(), s = await et(t), n = t.fileName ?? ((d = t.file) == null ? void 0 : d.name), o = Y(t), a = Xe(s), c = Ye(a, n);
1287
- if (c.length === 0) {
1288
- const p = Object.keys(a), g = p.some((M) => /\.(w2d|w3d|whip)$/i.test(M)), S = p.some((M) => /manifest|descriptor|eplot/i.test(M));
1289
- throw g || o === "dwf" || S ? new mt("Classic DWF packages usually store geometry in WHIP/W2D/W3D streams. This browser build detects them but does not decode the full classic DWF graphics stream without a DWF Toolkit/WASM implementation. DWFx/XPS 2D pages are supported.") : new mt("No FixedPage/XPS content found in this DWF/DWFx package.");
1290
- }
1291
- const l = [];
1292
- o === "dwf" && l.push("This .dwf package contained XPS/FixedPage-compatible content and was rendered through the DWFx loader path. Classic WHIP/W2D streams are not decoded.");
1293
- const h = Xt({
1294
- format: o === "dwf" ? "dwf" : o === "xps" ? "xps" : "dwfx",
1295
- sourceName: n,
1296
- layers: {},
1297
- blocks: {},
1298
- pages: c,
1299
- entities: me(c),
1300
- metadata: {
1301
- parser: "cad-viewer DWFx/XPS loader",
1302
- packageEntries: Object.keys(a).length
1303
- },
1304
- warnings: l,
1305
- raw: { entries: Object.keys(a) }
1306
- }), f = performance.now() - i;
1307
- return { document: h, raw: h.raw, bytes: s.byteLength, elapsedMs: f, format: h.format, warnings: h.warnings };
1308
- }
1309
- }
1310
- function Xe(e) {
1311
- if (!(e[0] === 80 && e[1] === 75))
1312
- throw new mt("DWF/DWFx loader expects a ZIP/OPC package. Non-ZIP classic DWF streams require a dedicated WHIP decoder.");
1313
- return ee(e);
1314
- }
1315
- function Ye(e, t) {
1316
- const r = Object.entries(e).filter(([s, n]) => /\.fpage$/i.test(s) || wt(n.slice(0, Math.min(512, n.byteLength))).includes("<FixedPage")).sort(([s], [n]) => s.localeCompare(n)), i = [];
1317
- for (const [s, n] of r) {
1318
- const o = wt(n);
1319
- if (!o.includes("<FixedPage")) continue;
1320
- const a = He(o, i.length, s, e, t);
1321
- a && i.push(a);
1322
- }
1323
- return i;
1324
- }
1325
- function He(e, t, r, i, s) {
1326
- if (typeof DOMParser > "u")
1327
- throw new Error("DWFx/XPS parsing requires DOMParser. Use it in a browser environment or provide a DOMParser polyfill.");
1328
- const o = new DOMParser().parseFromString(e, "application/xml").documentElement;
1329
- if (!o || !/FixedPage$/i.test(o.nodeName)) return;
1330
- const a = I(o, "Width") ?? 1e3, c = I(o, "Height") ?? 1e3, l = [];
1331
- return Zt(o, At, (h, f) => {
1332
- const d = j(f, Ge(h) ?? At), p = qt(h.nodeName);
1333
- if (p === "Path") {
1334
- const g = _e(h, d, c, t);
1335
- g && l.push(g);
1336
- } else if (p === "Glyphs") {
1337
- const g = Ue(h, d, c, t);
1338
- g && l.push(g);
1339
- } else if (p !== "Canvas") {
1340
- if (p === "ImageBrush") {
1341
- const g = Ve(h, d, c, t, r, i);
1342
- g && l.push(g);
1343
- }
1344
- }
1345
- return d;
1346
- }), { index: t, name: s ? `${s} / ${r}` : r, width: a, height: c, entities: l };
1347
- }
1348
- function Zt(e, t, r) {
1349
- const i = r(e, t);
1350
- for (const s of Array.from(e.children)) Zt(s, i, r);
1351
- }
1352
- function _e(e, t, r, i) {
1353
- const s = e.getAttribute("Data") ?? je(e);
1354
- if (!s) return;
1355
- const n = $e(s).map((l) => ({
1356
- cmd: l.cmd,
1357
- points: l.points.map((h) => bt(w(h, t), r))
1358
- }));
1359
- if (!n.length) return;
1360
- const o = K(e.getAttribute("Stroke") ?? void 0), a = K(e.getAttribute("Fill") ?? void 0), c = I(e, "Opacity");
1361
- return {
1362
- type: "XPS_PATH",
1363
- kind: "path",
1364
- commands: n,
1365
- color: o ?? a ?? "#ffffff",
1366
- fillColor: a,
1367
- lineweight: I(e, "StrokeThickness") ?? 1,
1368
- opacity: c,
1369
- pageIndex: i,
1370
- raw: e.outerHTML
1371
- };
1372
- }
1373
- function Ue(e, t, r, i) {
1374
- const s = e.getAttribute("UnicodeString") ?? e.getAttribute("Indices") ?? "";
1375
- if (!s) return;
1376
- const n = { x: I(e, "OriginX") ?? 0, y: I(e, "OriginY") ?? 0 };
1377
- return {
1378
- type: "DWF_TEXT",
1379
- kind: "text",
1380
- insertionPoint: bt(w(n, t), r),
1381
- text: s,
1382
- textHeight: I(e, "FontRenderingEmSize") ?? 12,
1383
- color: K(e.getAttribute("Fill") ?? void 0) ?? "#ffffff",
1384
- opacity: I(e, "Opacity"),
1385
- pageIndex: i,
1386
- raw: e.outerHTML
1387
- };
1388
- }
1389
- function Ve(e, t, r, i, s, n) {
1390
- var S, M;
1391
- const o = e.getAttribute("ImageSource");
1392
- if (!o) return;
1393
- const a = ((M = (S = e.getAttribute("Viewport")) == null ? void 0 : S.match(/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g)) == null ? void 0 : M.map(Number)) ?? [], c = a[0] ?? 0, l = a[1] ?? 0, h = a[2] ?? 32, f = a[3] ?? 32, d = bt(w({ x: c, y: l }, t), r), p = Ze(s, o), g = n[p.replace(/^\//, "")] ?? n[p];
1394
- return {
1395
- type: "DWF_IMAGE",
1396
- kind: "image",
1397
- insertionPoint: d,
1398
- width: h,
1399
- height: f,
1400
- imageSource: o,
1401
- imageDataUrl: g ? qe(g, p) : void 0,
1402
- pageIndex: i,
1403
- raw: e.outerHTML
1404
- };
1405
- }
1406
- function $e(e) {
1407
- const t = e.match(/[AaCcHhLlMmQqSsVvZz]|-?\d*\.?\d+(?:[eE][+-]?\d+)?/g) ?? [], r = [];
1408
- let i = 0, s = "", n = { x: 0, y: 0 }, o = { x: 0, y: 0 };
1409
- const a = (l) => /^[A-Za-z]$/.test(l), c = () => Number(t[i++]);
1410
- for (; i < t.length && (a(t[i]) && (s = t[i++]), !!s); ) {
1411
- const l = s === s.toLowerCase(), h = s.toUpperCase();
1412
- if (h === "Z") {
1413
- r.push({ cmd: "Z", points: [] }), n = { ...o }, s = "";
1414
- continue;
1415
- }
1416
- if (h === "M") {
1417
- const f = c(), d = c();
1418
- if (!Number.isFinite(f) || !Number.isFinite(d)) break;
1419
- n = E(f, d, l, n), o = { ...n }, r.push({ cmd: "M", points: [n] }), s = l ? "l" : "L";
1420
- continue;
1421
- }
1422
- if (h === "L") {
1423
- const f = c(), d = c();
1424
- if (!Number.isFinite(f) || !Number.isFinite(d)) break;
1425
- n = E(f, d, l, n), r.push({ cmd: "L", points: [n] });
1426
- continue;
1427
- }
1428
- if (h === "H") {
1429
- const f = c();
1430
- if (!Number.isFinite(f)) break;
1431
- n = { x: l ? n.x + f : f, y: n.y }, r.push({ cmd: "L", points: [n] });
1432
- continue;
1433
- }
1434
- if (h === "V") {
1435
- const f = c();
1436
- if (!Number.isFinite(f)) break;
1437
- n = { x: n.x, y: l ? n.y + f : f }, r.push({ cmd: "L", points: [n] });
1438
- continue;
1439
- }
1440
- if (h === "C") {
1441
- const f = E(c(), c(), l, n), d = E(c(), c(), l, n), p = E(c(), c(), l, n);
1442
- if (![f.x, f.y, d.x, d.y, p.x, p.y].every(Number.isFinite)) break;
1443
- n = p, r.push({ cmd: "C", points: [f, d, p] });
1444
- continue;
1445
- }
1446
- if (h === "Q" || h === "S") {
1447
- const f = E(c(), c(), l, n), d = E(c(), c(), l, n);
1448
- if (![f.x, f.y, d.x, d.y].every(Number.isFinite)) break;
1449
- n = d, r.push({ cmd: "Q", points: [f, d] });
1450
- continue;
1451
- }
1452
- if (h === "A") {
1453
- c(), c(), c(), c(), c();
1454
- const f = E(c(), c(), l, n);
1455
- if (![f.x, f.y].every(Number.isFinite)) break;
1456
- n = f, r.push({ cmd: "L", points: [f] });
1457
- continue;
1458
- }
1459
- break;
1460
- }
1461
- return r;
1462
- }
1463
- function E(e, t, r, i) {
1464
- return r ? { x: i.x + e, y: i.y + t } : { x: e, y: t };
1465
- }
1466
- function bt(e, t) {
1467
- return { x: e.x, y: t - e.y };
1468
- }
1469
- function je(e) {
1470
- for (const t of Array.from(e.children))
1471
- if (/PathGeometry$/i.test(t.nodeName)) {
1472
- const r = t.getAttribute("Figures");
1473
- if (r) return r;
1474
- }
1475
- }
1476
- function Ge(e) {
1477
- return tt(e.getAttribute("RenderTransform")) ?? tt(e.getAttribute("Transform")) ?? $(e, "RenderTransform") ?? $(e, "Canvas.RenderTransform") ?? $(e, "Path.RenderTransform") ?? $(e, "Glyphs.RenderTransform");
1478
- }
1479
- function $(e, t) {
1480
- for (const r of Array.from(e.children)) {
1481
- if (qt(r.nodeName) !== t && r.nodeName !== t) continue;
1482
- const i = r.textContent ? tt(r.textContent) : void 0;
1483
- if (i) return i;
1484
- for (const s of Array.from(r.children)) {
1485
- const n = tt(s.getAttribute("Matrix") ?? s.textContent ?? void 0);
1486
- if (n) return n;
1487
- }
1488
- }
1489
- }
1490
- function I(e, t) {
1491
- const r = e.getAttribute(t), i = r === null ? NaN : Number(r);
1492
- return Number.isFinite(i) ? i : void 0;
1493
- }
1494
- function qt(e) {
1495
- return e.includes(":") ? e.split(":").pop() ?? e : e;
1496
- }
1497
- function Ze(e, t) {
1498
- if (t.startsWith("/")) return t.slice(1);
1499
- const i = `${e.includes("/") ? e.slice(0, e.lastIndexOf("/") + 1) : ""}${t}`.split("/"), s = [];
1500
- for (const n of i)
1501
- !n || n === "." || (n === ".." ? s.pop() : s.push(n));
1502
- return s.join("/");
1503
- }
1504
- function qe(e, t) {
1505
- const r = /\.jpe?g$/i.test(t) ? "image/jpeg" : /\.webp$/i.test(t) ? "image/webp" : "image/png";
1506
- let i = "";
1507
- for (const s of e) i += String.fromCharCode(s);
1508
- return `data:${r};base64,${btoa(i)}`;
1509
- }
1510
- function Ke(e = {}) {
1511
- return new ie([
1512
- new le(e),
1513
- new pe(e),
1514
- new ze(e)
1515
- ]);
1516
- }
1517
- const Qe = {
1483
+ const je = {
1518
1484
  background: "#0b1020",
1519
1485
  foreground: "#ffffff",
1520
1486
  showUnsupportedMarkers: !1,
@@ -1537,33 +1503,33 @@ const Qe = {
1537
1503
  preserveDrawingBuffer: !1,
1538
1504
  enableSpatialIndex: !0
1539
1505
  };
1540
- class Ft {
1506
+ class Tt {
1541
1507
  constructor(t, r = {}) {
1542
- u(this, "canvas");
1543
- u(this, "ctx");
1544
- u(this, "opts");
1545
- u(this, "document");
1546
- u(this, "bounds", N());
1547
- u(this, "view", { centerX: 0, centerY: 0, scale: 1 });
1548
- u(this, "fitScale", 1);
1549
- u(this, "dpr", 1);
1550
- u(this, "isDragging", !1);
1551
- u(this, "lastPointer");
1552
- u(this, "resizeObserver");
1553
- u(this, "imageCache", /* @__PURE__ */ new Map());
1554
- u(this, "stats", { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: 0, backend: "canvas2d" });
1555
- u(this, "onStats");
1556
- u(this, "onViewChange");
1508
+ d(this, "canvas");
1509
+ d(this, "ctx");
1510
+ d(this, "opts");
1511
+ d(this, "document");
1512
+ d(this, "bounds", M());
1513
+ d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
1514
+ d(this, "fitScale", 1);
1515
+ d(this, "dpr", 1);
1516
+ d(this, "isDragging", !1);
1517
+ d(this, "lastPointer");
1518
+ d(this, "resizeObserver");
1519
+ d(this, "imageCache", /* @__PURE__ */ new Map());
1520
+ d(this, "stats", { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: 0, backend: "canvas2d" });
1521
+ d(this, "onStats");
1522
+ d(this, "onViewChange");
1557
1523
  const i = t.getContext("2d");
1558
1524
  if (!i) throw new Error("Canvas 2D context is not available.");
1559
- this.canvas = t, this.ctx = i, this.opts = { ...Qe, ...r }, this.canvas.classList.add("cad-viewer-canvas"), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
1525
+ this.canvas = t, this.ctx = i, this.opts = { ...je, ...r }, this.canvas.classList.add("cad-viewer-canvas"), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
1560
1526
  }
1561
1527
  destroy() {
1562
1528
  var t;
1563
1529
  (t = this.resizeObserver) == null || t.disconnect();
1564
1530
  }
1565
1531
  clear() {
1566
- this.document = void 0, this.bounds = N(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
1532
+ this.document = void 0, this.bounds = M(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
1567
1533
  }
1568
1534
  setDocument(t) {
1569
1535
  this.document = t, this.bounds = this.computeBounds(t), this.fitToView();
@@ -1578,7 +1544,7 @@ class Ft {
1578
1544
  return { ...this.opts };
1579
1545
  }
1580
1546
  fitToView(t = 0.92) {
1581
- if (!R(this.bounds)) {
1547
+ if (!D(this.bounds)) {
1582
1548
  this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
1583
1549
  return;
1584
1550
  }
@@ -1621,7 +1587,7 @@ class Ft {
1621
1587
  return { ...this.bounds };
1622
1588
  }
1623
1589
  getStats() {
1624
- return Je(this.stats);
1590
+ return Ge(this.stats);
1625
1591
  }
1626
1592
  getZoomRatio() {
1627
1593
  return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
@@ -1689,14 +1655,14 @@ class Ft {
1689
1655
  const i = String(t.type ?? "UNKNOWN").toUpperCase();
1690
1656
  this.stats.byType[i] = (this.stats.byType[i] ?? 0) + 1;
1691
1657
  const s = this.lookupLayer(t.layer);
1692
- if (t.isVisible === !1 || !$t(s)) {
1658
+ if (t.isVisible === !1 || !Xt(s)) {
1693
1659
  this.stats.skipped++;
1694
1660
  return;
1695
1661
  }
1696
1662
  this.drawEntity(t, i, r);
1697
1663
  }
1698
1664
  drawEntity(t, r, i) {
1699
- switch (t.kind ?? O(r)) {
1665
+ switch (t.kind ?? R(r)) {
1700
1666
  case "line":
1701
1667
  return this.drawLine(t);
1702
1668
  case "circle":
@@ -1732,8 +1698,8 @@ class Ft {
1732
1698
  beginStyledPath(t, r = !1) {
1733
1699
  const i = this.ctx;
1734
1700
  i.save(), i.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
1735
- const s = D(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), n = ft(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }) ?? s;
1736
- i.strokeStyle = s, i.fillStyle = r ? n : s, i.globalAlpha = B(Number(t.opacity ?? 1), 0, 1), i.lineCap = "round", i.lineJoin = "round";
1701
+ const s = F(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), n = lt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }) ?? s;
1702
+ i.strokeStyle = s, i.fillStyle = r ? n : s, i.globalAlpha = T(Number(t.opacity ?? 1), 0, 1), i.lineCap = "round", i.lineJoin = "round";
1737
1703
  const o = typeof t.lineweight == "number" && t.lineweight > 0 ? t.lineweight : 0;
1738
1704
  i.lineWidth = Math.max(1, Math.min(12, o > 0 ? o / 30 : 1)), i.beginPath();
1739
1705
  }
@@ -1758,7 +1724,7 @@ class Ft {
1758
1724
  drawArc(t) {
1759
1725
  const r = t.center, i = Number(t.radius), s = Number(t.startAngle), n = Number(t.endAngle);
1760
1726
  if (!m(r) || !Number.isFinite(i) || !Number.isFinite(s) || !Number.isFinite(n)) return this.markSkipped("ARC");
1761
- this.strokeWorldPolyline(t, G(v(r), i, s, n, !0), !1);
1727
+ this.strokeWorldPolyline(t, Z(x(r), i, s, n, !0), !1);
1762
1728
  }
1763
1729
  drawPolyline(t) {
1764
1730
  const r = t.vertices ?? t.points;
@@ -1767,15 +1733,15 @@ class Ft {
1767
1733
  for (let o = 0; o < n; o++) {
1768
1734
  const a = r[o], c = r[(o + 1) % r.length];
1769
1735
  if (!m(a) || !m(c)) continue;
1770
- const l = _t(a, c, Number(a.bulge ?? 0));
1771
- s.length > 0 && l.shift(), s.push(...l);
1736
+ const h = zt(a, c, Number(a.bulge ?? 0));
1737
+ s.length > 0 && h.shift(), s.push(...h);
1772
1738
  }
1773
1739
  this.strokeWorldPolyline(t, s, i);
1774
1740
  }
1775
1741
  drawEllipse(t) {
1776
1742
  const r = t.center, i = t.majorAxisEndPoint, s = Number(t.axisRatio ?? 1);
1777
1743
  if (!m(r) || !m(i)) return this.markSkipped("ELLIPSE");
1778
- const n = Z(r, i, s, Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2)), o = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
1744
+ const n = q(r, i, s, Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2)), o = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
1779
1745
  this.strokeWorldPolyline(t, n, o);
1780
1746
  }
1781
1747
  drawPoint(t) {
@@ -1785,17 +1751,17 @@ class Ft {
1785
1751
  this.beginStyledPath(t), this.ctx.moveTo(i.x - 3, i.y), this.ctx.lineTo(i.x + 3, i.y), this.ctx.moveTo(i.x, i.y - 3), this.ctx.lineTo(i.x, i.y + 3), this.finishStroke();
1786
1752
  }
1787
1753
  drawText(t) {
1788
- const r = t.insertionPoint ?? t.startPoint ?? t.center, i = Ut(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
1754
+ const r = t.insertionPoint ?? t.startPoint ?? t.center, i = Yt(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
1789
1755
  if (!m(r) || !i) return this.markSkipped(String(t.type));
1790
1756
  this.drawTextAt(t, r, i, s, Number(t.rotation ?? 0));
1791
1757
  }
1792
1758
  drawInsert(t, r) {
1793
1759
  const i = this.lookupBlock(t.blockName ?? t.name);
1794
1760
  if (i && r < this.opts.maxInsertDepth) {
1795
- const a = Q(t, i.basePoint ?? { x: 0, y: 0 });
1761
+ const a = J(t, i.basePoint ?? { x: 0, y: 0 });
1796
1762
  for (const c of i.entities) {
1797
- const l = jt(c, t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast });
1798
- this.drawEntityTracked(J(l, a), r + 1);
1763
+ const h = _t(c, t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast });
1764
+ this.drawEntityTracked(Q(h, a), r + 1);
1799
1765
  }
1800
1766
  return;
1801
1767
  }
@@ -1835,7 +1801,7 @@ class Ft {
1835
1801
  }
1836
1802
  this.ctx.closePath();
1837
1803
  }
1838
- this.finishFillStroke(!!ft(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }));
1804
+ this.finishFillStroke(!!lt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }));
1839
1805
  }
1840
1806
  drawSpline(t) {
1841
1807
  var i;
@@ -1867,17 +1833,17 @@ class Ft {
1867
1833
  drawImage(t) {
1868
1834
  const r = t.insertionPoint;
1869
1835
  if (!m(r)) return this.markSkipped(String(t.type));
1870
- const i = Number(t.width ?? 32), s = Number(t.height ?? 32), n = this.worldToScreen(r), o = this.worldToScreen({ x: r.x + i, y: r.y - s }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), l = Math.abs(o.x - n.x), h = Math.abs(o.y - n.y), f = t.imageDataUrl;
1836
+ const i = Number(t.width ?? 32), s = Number(t.height ?? 32), n = this.worldToScreen(r), o = this.worldToScreen({ x: r.x + i, y: r.y - s }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), h = Math.abs(o.x - n.x), l = Math.abs(o.y - n.y), f = t.imageDataUrl;
1871
1837
  if (f) {
1872
- const d = this.getImage(f);
1873
- if (d.complete && d.naturalWidth > 0) {
1874
- this.ctx.save(), this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), this.ctx.drawImage(d, a, c, l, h), this.ctx.restore(), this.stats.drawn++;
1838
+ const u = this.getImage(f);
1839
+ if (u.complete && u.naturalWidth > 0) {
1840
+ this.ctx.save(), this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), this.ctx.drawImage(u, a, c, h, l), this.ctx.restore(), this.stats.drawn++;
1875
1841
  return;
1876
1842
  }
1877
- d.onload = () => this.render();
1843
+ u.onload = () => this.render();
1878
1844
  }
1879
1845
  if (!this.opts.showImagePlaceholders) return this.markSkipped(String(t.type));
1880
- this.beginStyledPath(t), this.ctx.rect(a, c, l, h), this.ctx.moveTo(a, c), this.ctx.lineTo(a + l, c + h), this.ctx.moveTo(a + l, c), this.ctx.lineTo(a, c + h), this.finishStroke();
1846
+ this.beginStyledPath(t), this.ctx.rect(a, c, h, l), this.ctx.moveTo(a, c), this.ctx.lineTo(a + h, c + l), this.ctx.moveTo(a + h, c), this.ctx.lineTo(a, c + l), this.finishStroke();
1881
1847
  }
1882
1848
  getImage(t) {
1883
1849
  let r = this.imageCache.get(t);
@@ -1893,8 +1859,8 @@ class Ft {
1893
1859
  const o = this.ctx, a = this.worldToScreen(r);
1894
1860
  o.save(), o.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), o.translate(a.x, a.y), o.rotate(-n);
1895
1861
  const c = Math.max(4, Math.min(256, Math.abs(s) * this.view.scale));
1896
- o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle = D(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), o.globalAlpha = B(Number(t.opacity ?? 1), 0, 1), o.textBaseline = "alphabetic";
1897
- for (const [l, h] of i.split(/\r?\n/g).entries()) o.fillText(h, 0, l * c * 1.22);
1862
+ o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle = F(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), o.globalAlpha = T(Number(t.opacity ?? 1), 0, 1), o.textBaseline = "alphabetic";
1863
+ for (const [h, l] of i.split(/\r?\n/g).entries()) o.fillText(l, 0, h * c * 1.22);
1898
1864
  o.restore(), this.stats.drawn++;
1899
1865
  }
1900
1866
  strokeWorldPolyline(t, r, i) {
@@ -1915,51 +1881,51 @@ class Ft {
1915
1881
  entityAnchor(t) {
1916
1882
  for (const r of ["startPoint", "insertionPoint", "center", "point", "location"]) {
1917
1883
  const i = t[r];
1918
- if (m(i)) return v(i);
1884
+ if (m(i)) return x(i);
1919
1885
  }
1920
- if (Array.isArray(t.vertices) && m(t.vertices[0])) return v(t.vertices[0]);
1886
+ if (Array.isArray(t.vertices) && m(t.vertices[0])) return x(t.vertices[0]);
1921
1887
  if (Array.isArray(t.commands) && t.commands.length) {
1922
1888
  const r = t.commands.find((i) => i.points.length > 0);
1923
- if (r) return v(r.points[0]);
1889
+ if (r) return x(r.points[0]);
1924
1890
  }
1925
1891
  }
1926
1892
  computeBounds(t) {
1927
1893
  var i;
1928
- const r = N();
1894
+ const r = M();
1929
1895
  if ((i = t.pages) != null && i.length)
1930
1896
  for (const s of t.pages)
1931
- y(r, { x: 0, y: 0 }), y(r, { x: s.width, y: s.height });
1897
+ b(r, { x: 0, y: 0 }), b(r, { x: s.width, y: s.height });
1932
1898
  for (const s of t.entities) this.includeEntityBounds(r, s, 0);
1933
- return Ht(r);
1899
+ return Ot(r);
1934
1900
  }
1935
1901
  includeEntityBounds(t, r, i) {
1936
- const s = String(r.type ?? "").toUpperCase(), n = r.kind ?? O(s);
1902
+ const s = String(r.type ?? "").toUpperCase(), n = r.kind ?? R(s);
1937
1903
  if (n === "insert") {
1938
1904
  const o = this.lookupBlock(r.blockName ?? r.name);
1939
1905
  if (o && i < this.opts.maxInsertDepth) {
1940
- const a = Q(r, o.basePoint ?? { x: 0, y: 0 });
1941
- for (const c of o.entities) this.includeEntityBounds(t, J(c, a), i + 1);
1906
+ const a = J(r, o.basePoint ?? { x: 0, y: 0 });
1907
+ for (const c of o.entities) this.includeEntityBounds(t, Q(c, a), i + 1);
1942
1908
  return;
1943
1909
  }
1944
1910
  }
1945
1911
  if (n === "line")
1946
- m(r.startPoint) && y(t, r.startPoint), m(r.endPoint) && y(t, r.endPoint);
1912
+ m(r.startPoint) && b(t, r.startPoint), m(r.endPoint) && b(t, r.endPoint);
1947
1913
  else if (n === "circle" || n === "arc")
1948
- m(r.center) && Number.isFinite(r.radius) && Yt(t, r.center, Number(r.radius));
1914
+ m(r.center) && Number.isFinite(r.radius) && Dt(t, r.center, Number(r.radius));
1949
1915
  else if (n === "polyline" || n === "solid" || n === "spline")
1950
- for (const o of [...r.vertices ?? [], ...r.points ?? [], ...r.controlPoints ?? [], ...r.fitPoints ?? []]) m(o) && y(t, o);
1916
+ for (const o of [...r.vertices ?? [], ...r.points ?? [], ...r.controlPoints ?? [], ...r.fitPoints ?? []]) m(o) && b(t, o);
1951
1917
  else if (n === "ellipse")
1952
- m(r.center) && m(r.majorAxisEndPoint) && Z(r.center, r.majorAxisEndPoint, Number(r.axisRatio ?? 1), Number(r.startAngle ?? 0), Number(r.endAngle ?? Math.PI * 2)).forEach((o) => y(t, o));
1918
+ m(r.center) && m(r.majorAxisEndPoint) && q(r.center, r.majorAxisEndPoint, Number(r.axisRatio ?? 1), Number(r.startAngle ?? 0), Number(r.endAngle ?? Math.PI * 2)).forEach((o) => b(t, o));
1953
1919
  else if (n === "path")
1954
- for (const o of r.commands ?? []) for (const a of o.points) y(t, a);
1920
+ for (const o of r.commands ?? []) for (const a of o.points) b(t, a);
1955
1921
  else if (n === "hatch")
1956
1922
  for (const o of r.loops ?? []) {
1957
- for (const a of o.vertices ?? []) y(t, a);
1958
- for (const a of o.commands ?? []) for (const c of a.points) y(t, c);
1923
+ for (const a of o.vertices ?? []) b(t, a);
1924
+ for (const a of o.commands ?? []) for (const c of a.points) b(t, c);
1959
1925
  }
1960
1926
  else {
1961
1927
  const o = this.entityAnchor(r);
1962
- o && y(t, o);
1928
+ o && b(t, o);
1963
1929
  }
1964
1930
  }
1965
1931
  lookupLayer(t) {
@@ -1984,7 +1950,7 @@ class Ft {
1984
1950
  });
1985
1951
  }
1986
1952
  }
1987
- function Je(e) {
1953
+ function Ge(e) {
1988
1954
  return {
1989
1955
  total: e.total,
1990
1956
  drawn: e.drawn,
@@ -2000,7 +1966,7 @@ function Je(e) {
2000
1966
  buildElapsedMs: e.buildElapsedMs
2001
1967
  };
2002
1968
  }
2003
- const tr = {
1969
+ const Ze = {
2004
1970
  background: "#0b1020",
2005
1971
  foreground: "#ffffff",
2006
1972
  showUnsupportedMarkers: !1,
@@ -2023,54 +1989,54 @@ const tr = {
2023
1989
  preserveDrawingBuffer: !1,
2024
1990
  enableSpatialIndex: !0
2025
1991
  };
2026
- class Dt {
1992
+ class Lt {
2027
1993
  constructor(t, r = {}) {
2028
- u(this, "canvas");
2029
- u(this, "backend", "webgl");
2030
- u(this, "gl");
2031
- u(this, "program");
2032
- u(this, "eventController", new AbortController());
2033
- u(this, "imageCache", /* @__PURE__ */ new Map());
2034
- u(this, "opts");
2035
- u(this, "document");
2036
- u(this, "bounds", N());
2037
- u(this, "view", { centerX: 0, centerY: 0, scale: 1 });
2038
- u(this, "fitScale", 1);
2039
- u(this, "dpr", 1);
2040
- u(this, "isDragging", !1);
2041
- u(this, "lastPointer");
2042
- u(this, "resizeObserver");
2043
- u(this, "overlayCanvas");
2044
- u(this, "overlayCtx");
2045
- u(this, "scene");
2046
- u(this, "stats", { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: 0, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 });
2047
- u(this, "rafHandle", 0);
2048
- u(this, "onStats");
2049
- u(this, "onViewChange");
2050
- const i = er(t, r);
1994
+ d(this, "canvas");
1995
+ d(this, "backend", "webgl");
1996
+ d(this, "gl");
1997
+ d(this, "program");
1998
+ d(this, "eventController", new AbortController());
1999
+ d(this, "imageCache", /* @__PURE__ */ new Map());
2000
+ d(this, "opts");
2001
+ d(this, "document");
2002
+ d(this, "bounds", M());
2003
+ d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
2004
+ d(this, "fitScale", 1);
2005
+ d(this, "dpr", 1);
2006
+ d(this, "isDragging", !1);
2007
+ d(this, "lastPointer");
2008
+ d(this, "resizeObserver");
2009
+ d(this, "overlayCanvas");
2010
+ d(this, "overlayCtx");
2011
+ d(this, "scene");
2012
+ d(this, "stats", { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: 0, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 });
2013
+ d(this, "rafHandle", 0);
2014
+ d(this, "onStats");
2015
+ d(this, "onViewChange");
2016
+ const i = qe(t, r);
2051
2017
  if (!i) throw new Error('WebGL is not available. Use renderer: "canvas2d" to force the Canvas2D fallback.');
2052
- this.canvas = t, this.gl = i, this.program = rr(i), this.opts = { ...tr, ...r }, this.canvas.classList.add("cad-viewer-canvas", "cad-viewer-webgl-canvas"), this.createOverlayCanvas(), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
2018
+ this.canvas = t, this.gl = i, this.program = Ke(i), this.opts = { ...Ze, ...r }, this.canvas.classList.add("cad-viewer-canvas", "cad-viewer-webgl-canvas"), this.createOverlayCanvas(), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
2053
2019
  }
2054
2020
  static isSupported() {
2055
- return Kt();
2021
+ return Vt();
2056
2022
  }
2057
2023
  destroy() {
2058
2024
  var t, r;
2059
2025
  this.eventController.abort(), (t = this.resizeObserver) == null || t.disconnect(), this.cancelScheduledRender(), this.disposeScene(), (r = this.overlayCanvas) == null || r.remove();
2060
2026
  }
2061
2027
  clear() {
2062
- this.document = void 0, this.bounds = N(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.disposeScene(), this.render(), this.emitViewChange();
2028
+ this.document = void 0, this.bounds = M(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.disposeScene(), this.render(), this.emitViewChange();
2063
2029
  }
2064
2030
  setDocument(t) {
2065
- this.document = t, this.bounds = cr(t, this.opts), this.disposeScene();
2066
- const r = sr(t, this.opts, this.bounds);
2067
- this.scene = ir(this.gl, r), this.stats = fr(this.scene, 0), this.fitToView();
2031
+ this.document = t, this.bounds = ir(t, this.opts), this.disposeScene();
2032
+ const r = Qe(t, this.opts, this.bounds);
2033
+ this.scene = Je(this.gl, r), this.stats = or(this.scene, 0), this.fitToView();
2068
2034
  }
2069
2035
  getDocument() {
2070
2036
  return this.document;
2071
2037
  }
2072
2038
  setOptions(t) {
2073
- const r = hr(this.opts, t);
2039
+ const r = nr(this.opts, t);
2074
2040
  if (this.opts = { ...this.opts, ...t }, r && this.document) {
2075
2041
  this.setDocument(this.document);
2076
2042
  return;
@@ -2081,7 +2047,7 @@ class Dt {
2081
2047
  return { ...this.opts };
2082
2048
  }
2083
2049
  fitToView(t = 0.92) {
2084
- if (!R(this.bounds)) {
2050
+ if (!D(this.bounds)) {
2085
2051
  this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
2086
2052
  return;
2087
2053
  }
@@ -2124,7 +2090,7 @@ class Dt {
2124
2090
  return { ...this.bounds };
2125
2091
  }
2126
2092
  getStats() {
2127
- return dr(this.stats);
2093
+ return ar(this.stats);
2128
2094
  }
2129
2095
  getZoomRatio() {
2130
2096
  return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
@@ -2148,31 +2114,31 @@ class Dt {
2148
2114
  return this.cancelScheduledRender(), this.renderNow();
2149
2115
  }
2150
2116
  renderNow() {
2151
- var l;
2117
+ var h;
2152
2118
  const t = performance.now(), r = this.gl;
2153
2119
  r.viewport(0, 0, this.canvas.width, this.canvas.height);
2154
- const i = pt(this.opts.background, [11, 16, 32, 255]);
2120
+ const i = ut(this.opts.background, [11, 16, 32, 255]);
2155
2121
  r.clearColor(i[0] / 255, i[1] / 255, i[2] / 255, i[3] / 255), r.clear(r.COLOR_BUFFER_BIT), r.disable(r.DEPTH_TEST), r.enable(r.BLEND), r.blendFunc(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA);
2156
2122
  let s = 0, n = 0;
2157
2123
  const o = this.scene, a = this.visibleWorldBounds();
2158
2124
  if (o) {
2159
2125
  r.useProgram(this.program.program), r.uniform2f(this.program.uViewCenter, this.view.centerX - o.origin.x, this.view.centerY - o.origin.y), r.uniform1f(this.program.uScale, this.view.scale * this.dpr), r.uniform2f(this.program.uViewport, this.canvas.width, this.canvas.height), r.uniform1f(this.program.uPointSize, Math.max(2, Math.min(12, 4 * this.dpr)));
2160
- const h = this.drawBatches(o.lineBatches, r.LINES, a);
2161
- s += h.visible, n += h.culled;
2126
+ const l = this.drawBatches(o.lineBatches, r.LINES, a);
2127
+ s += l.visible, n += l.culled;
2162
2128
  const f = this.drawBatches(o.triangleBatches, r.TRIANGLES, a);
2163
2129
  s += f.visible, n += f.culled;
2164
- const d = this.drawBatches(o.pointBatches, r.POINTS, a);
2165
- s += d.visible, n += d.culled;
2130
+ const u = this.drawBatches(o.pointBatches, r.POINTS, a);
2131
+ s += u.visible, n += u.culled;
2166
2132
  }
2167
2133
  this.renderOverlay(a);
2168
2134
  const c = performance.now() - t;
2169
- return this.stats = o ? { ...o.stats, renderElapsedMs: c, backend: "webgl", primitiveCount: o.primitiveCount, visiblePrimitiveCount: s, culledPrimitiveCount: n, gpuMemoryBytes: o.gpuMemoryBytes, buildElapsedMs: o.buildElapsedMs } : { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: c, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 }, (l = this.onStats) == null || l.call(this, this.getStats()), this.getStats();
2135
+ return this.stats = o ? { ...o.stats, renderElapsedMs: c, backend: "webgl", primitiveCount: o.primitiveCount, visiblePrimitiveCount: s, culledPrimitiveCount: n, gpuMemoryBytes: o.gpuMemoryBytes, buildElapsedMs: o.buildElapsedMs } : { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: c, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 }, (h = this.onStats) == null || h.call(this, this.getStats()), this.getStats();
2170
2136
  }
2171
2137
  drawBatches(t, r, i) {
2172
2138
  const s = this.gl;
2173
2139
  let n = 0, o = 0;
2174
2140
  for (const a of t) {
2175
- if (!ct(a.bounds, i)) {
2141
+ if (!at(a.bounds, i)) {
2176
2142
  o += a.primitiveCount;
2177
2143
  continue;
2178
2144
  }
@@ -2209,32 +2175,32 @@ class Dt {
2209
2175
  let n = 0;
2210
2176
  for (const o of r) {
2211
2177
  if (n >= s) break;
2212
- if (!ct(o.bounds, i)) continue;
2178
+ if (!at(o.bounds, i)) continue;
2213
2179
  const a = Math.abs(o.height) * this.view.scale;
2214
2180
  if (a < this.opts.textMinPixelHeight) continue;
2215
2181
  const c = this.worldToScreen(o.point);
2216
2182
  if (c.x < -512 || c.y < -512 || c.x > this.cssWidth + 512 || c.y > this.cssHeight + 512) continue;
2217
2183
  t.save(), t.translate(c.x, c.y), t.rotate(-o.rotation);
2218
- const l = Math.max(4, Math.min(256, a));
2219
- t.font = `${l}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, t.fillStyle = o.color, t.globalAlpha = o.opacity, t.textBaseline = "alphabetic";
2220
- for (const [h, f] of o.text.split(/\r?\n/g).entries()) t.fillText(f, 0, h * l * 1.22);
2184
+ const h = Math.max(4, Math.min(256, a));
2185
+ t.font = `${h}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, t.fillStyle = o.color, t.globalAlpha = o.opacity, t.textBaseline = "alphabetic";
2186
+ for (const [l, f] of o.text.split(/\r?\n/g).entries()) t.fillText(f, 0, l * h * 1.22);
2221
2187
  t.restore(), n++;
2222
2188
  }
2223
2189
  }
2224
2190
  drawImagesOverlay(t, r, i) {
2225
2191
  for (const s of r) {
2226
- if (!ct(s.bounds, i)) continue;
2227
- const n = this.worldToScreen(s.point), o = this.worldToScreen({ x: s.point.x + s.width, y: s.point.y - s.height }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), l = Math.abs(o.x - n.x), h = Math.abs(o.y - n.y);
2228
- if (!(l < 1 || h < 1)) {
2192
+ if (!at(s.bounds, i)) continue;
2193
+ const n = this.worldToScreen(s.point), o = this.worldToScreen({ x: s.point.x + s.width, y: s.point.y - s.height }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), h = Math.abs(o.x - n.x), l = Math.abs(o.y - n.y);
2194
+ if (!(h < 1 || l < 1)) {
2229
2195
  if (s.source) {
2230
2196
  const f = this.getImage(s.source);
2231
2197
  if (f.complete && f.naturalWidth > 0) {
2232
- t.save(), t.globalAlpha = s.opacity, t.drawImage(f, a, c, l, h), t.restore();
2198
+ t.save(), t.globalAlpha = s.opacity, t.drawImage(f, a, c, h, l), t.restore();
2233
2199
  continue;
2234
2200
  }
2235
2201
  f.onload = () => this.scheduleRender();
2236
2202
  }
2237
- this.opts.showImagePlaceholders && (t.save(), t.strokeStyle = s.color, t.globalAlpha = s.opacity, t.lineWidth = 1, t.strokeRect(a, c, l, h), t.beginPath(), t.moveTo(a, c), t.lineTo(a + l, c + h), t.moveTo(a + l, c), t.lineTo(a, c + h), t.stroke(), t.restore());
2203
+ this.opts.showImagePlaceholders && (t.save(), t.strokeStyle = s.color, t.globalAlpha = s.opacity, t.lineWidth = 1, t.strokeRect(a, c, h, l), t.beginPath(), t.moveTo(a, c), t.lineTo(a + h, c + l), t.moveTo(a + h, c), t.lineTo(a, c + l), t.stroke(), t.restore());
2238
2204
  }
2239
2205
  }
2240
2206
  }
@@ -2308,12 +2274,12 @@ class Dt {
2308
2274
  });
2309
2275
  }
2310
2276
  }
2311
- function Kt() {
2277
+ function Vt() {
2312
2278
  if (typeof document > "u") return !1;
2313
2279
  const e = document.createElement("canvas");
2314
2280
  return !!(e.getContext("webgl2") ?? e.getContext("webgl") ?? e.getContext("experimental-webgl"));
2315
2281
  }
2316
- function er(e, t) {
2282
+ function qe(e, t) {
2317
2283
  const r = {
2318
2284
  alpha: !1,
2319
2285
  antialias: t.antialias ?? !0,
@@ -2324,7 +2290,7 @@ function er(e, t) {
2324
2290
  };
2325
2291
  return e.getContext("webgl2", r) ?? e.getContext("webgl", r) ?? e.getContext("experimental-webgl", r) ?? void 0;
2326
2292
  }
2327
- function rr(e) {
2293
+ function Ke(e) {
2328
2294
  const t = `
2329
2295
  attribute vec2 a_position;
2330
2296
  attribute vec4 a_color;
@@ -2349,15 +2315,15 @@ function rr(e) {
2349
2315
  void main() {
2350
2316
  gl_FragColor = v_color;
2351
2317
  }
2352
- `, i = Wt(e, e.VERTEX_SHADER, t), s = Wt(e, e.FRAGMENT_SHADER, r), n = e.createProgram();
2318
+ `, i = Bt(e, e.VERTEX_SHADER, t), s = Bt(e, e.FRAGMENT_SHADER, r), n = e.createProgram();
2353
2319
  if (!n) throw new Error("Failed to create WebGL program.");
2354
2320
  if (e.attachShader(n, i), e.attachShader(n, s), e.linkProgram(n), !e.getProgramParameter(n, e.LINK_STATUS)) {
2355
- const h = e.getProgramInfoLog(n) ?? "Unknown WebGL program link error.";
2356
- throw e.deleteProgram(n), new Error(h);
2321
+ const l = e.getProgramInfoLog(n) ?? "Unknown WebGL program link error.";
2322
+ throw e.deleteProgram(n), new Error(l);
2357
2323
  }
2358
2324
  e.deleteShader(i), e.deleteShader(s);
2359
- const o = e.getUniformLocation(n, "u_viewCenter"), a = e.getUniformLocation(n, "u_scale"), c = e.getUniformLocation(n, "u_viewport"), l = e.getUniformLocation(n, "u_pointSize");
2360
- if (!o || !a || !c || !l) throw new Error("Failed to resolve WebGL shader uniforms.");
2325
+ const o = e.getUniformLocation(n, "u_viewCenter"), a = e.getUniformLocation(n, "u_scale"), c = e.getUniformLocation(n, "u_viewport"), h = e.getUniformLocation(n, "u_pointSize");
2326
+ if (!o || !a || !c || !h) throw new Error("Failed to resolve WebGL shader uniforms.");
2361
2327
  return {
2362
2328
  program: n,
2363
2329
  aPosition: e.getAttribLocation(n, "a_position"),
@@ -2365,10 +2331,10 @@ function rr(e) {
2365
2331
  uViewCenter: o,
2366
2332
  uScale: a,
2367
2333
  uViewport: c,
2368
- uPointSize: l
2334
+ uPointSize: h
2369
2335
  };
2370
2336
  }
2371
- function Wt(e, t, r) {
2337
+ function Bt(e, t, r) {
2372
2338
  const i = e.createShader(t);
2373
2339
  if (!i) throw new Error("Failed to create WebGL shader.");
2374
2340
  if (e.shaderSource(i, r), e.compileShader(i), !e.getShaderParameter(i, e.COMPILE_STATUS)) {
@@ -2377,13 +2343,13 @@ function Wt(e, t, r) {
2377
2343
  }
2378
2344
  return i;
2379
2345
  }
2380
- function ir(e, t) {
2346
+ function Je(e, t) {
2381
2347
  let r = 0;
2382
2348
  const i = (a) => a.map((c) => {
2383
- const l = Ot(e, c.positions), h = Ot(e, c.colors), f = c.positions.byteLength + c.colors.byteLength;
2349
+ const h = At(e, c.positions), l = At(e, c.colors), f = c.positions.byteLength + c.colors.byteLength;
2384
2350
  return r += f, {
2385
- positionBuffer: l,
2386
- colorBuffer: h,
2351
+ positionBuffer: h,
2352
+ colorBuffer: l,
2387
2353
  vertexCount: c.positions.length / 2,
2388
2354
  primitiveCount: c.primitiveCount,
2389
2355
  bounds: c.bounds,
@@ -2403,30 +2369,30 @@ function ir(e, t) {
2403
2369
  buildElapsedMs: t.buildElapsedMs
2404
2370
  };
2405
2371
  }
2406
- function Ot(e, t) {
2372
+ function At(e, t) {
2407
2373
  const r = e.createBuffer();
2408
2374
  if (!r) throw new Error("Failed to create WebGL buffer.");
2409
2375
  return e.bindBuffer(e.ARRAY_BUFFER, r), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), r;
2410
2376
  }
2411
- function sr(e, t, r) {
2412
- const i = performance.now(), s = R(r) ? { x: (r.minX + r.maxX) / 2, y: (r.minY + r.maxY) / 2 } : { x: 0, y: 0 }, n = new nr(e, t, r, s);
2377
+ function Qe(e, t, r) {
2378
+ const i = performance.now(), s = D(r) ? { x: (r.minX + r.maxX) / 2, y: (r.minY + r.maxY) / 2 } : { x: 0, y: 0 }, n = new tr(e, t, r, s);
2413
2379
  for (const a of e.entities) n.addEntityTracked(a, 0);
2414
2380
  const o = n.finalize();
2415
2381
  return o.buildElapsedMs = performance.now() - i, o;
2416
2382
  }
2417
- class nr {
2383
+ class tr {
2418
2384
  constructor(t, r, i, s) {
2419
- u(this, "lineBuckets", /* @__PURE__ */ new Map());
2420
- u(this, "triangleBuckets", /* @__PURE__ */ new Map());
2421
- u(this, "pointBuckets", /* @__PURE__ */ new Map());
2422
- u(this, "textItems", []);
2423
- u(this, "imageItems", []);
2424
- u(this, "stats", { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 });
2425
- u(this, "tileSize");
2426
- u(this, "maxVerticesPerBatch");
2427
- u(this, "primitiveCount", 0);
2385
+ d(this, "lineBuckets", /* @__PURE__ */ new Map());
2386
+ d(this, "triangleBuckets", /* @__PURE__ */ new Map());
2387
+ d(this, "pointBuckets", /* @__PURE__ */ new Map());
2388
+ d(this, "textItems", []);
2389
+ d(this, "imageItems", []);
2390
+ d(this, "stats", { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 });
2391
+ d(this, "tileSize");
2392
+ d(this, "maxVerticesPerBatch");
2393
+ d(this, "primitiveCount", 0);
2428
2394
  this.document = t, this.opts = r, this.bounds = i, this.origin = s;
2429
- const n = R(i) ? Math.max(i.maxX - i.minX, i.maxY - i.minY, 1e-9) : 1;
2395
+ const n = D(i) ? Math.max(i.maxX - i.minX, i.maxY - i.minY, 1e-9) : 1;
2430
2396
  this.tileSize = r.enableSpatialIndex ? n / Math.max(8, r.spatialIndexCellCount) : Number.POSITIVE_INFINITY, this.maxVerticesPerBatch = Math.max(4096, Math.floor(r.maxVerticesPerBatch));
2431
2397
  }
2432
2398
  addEntityTracked(t, r) {
@@ -2434,14 +2400,14 @@ class nr {
2434
2400
  const i = String(t.type ?? "UNKNOWN").toUpperCase();
2435
2401
  this.stats.byType[i] = (this.stats.byType[i] ?? 0) + 1;
2436
2402
  const s = this.lookupLayer(t.layer);
2437
- if (t.isVisible === !1 || !$t(s)) {
2403
+ if (t.isVisible === !1 || !Xt(s)) {
2438
2404
  this.stats.skipped++;
2439
2405
  return;
2440
2406
  }
2441
2407
  this.addEntity(t, i, r);
2442
2408
  }
2443
2409
  finalize() {
2444
- const t = ot(this.lineBuckets, this.maxVerticesPerBatch), r = ot(this.triangleBuckets, this.maxVerticesPerBatch), i = ot(this.pointBuckets, this.maxVerticesPerBatch);
2410
+ const t = nt(this.lineBuckets, this.maxVerticesPerBatch), r = nt(this.triangleBuckets, this.maxVerticesPerBatch), i = nt(this.pointBuckets, this.maxVerticesPerBatch);
2445
2411
  return this.stats.primitiveCount = this.primitiveCount, {
2446
2412
  origin: this.origin,
2447
2413
  lineBatches: t,
@@ -2455,7 +2421,7 @@ class nr {
2455
2421
  };
2456
2422
  }
2457
2423
  addEntity(t, r, i) {
2458
- switch (t.kind ?? O(r)) {
2424
+ switch (t.kind ?? R(r)) {
2459
2425
  case "line":
2460
2426
  return this.addLineEntity(t);
2461
2427
  case "circle":
@@ -2495,13 +2461,13 @@ class nr {
2495
2461
  addCircleEntity(t) {
2496
2462
  const r = t.center, i = Number(t.radius);
2497
2463
  if (!m(r) || !Number.isFinite(i)) return this.markSkipped("CIRCLE");
2498
- const s = Math.max(16, Math.min(this.opts.maxCurveSegments, Math.ceil(Math.sqrt(Math.abs(i)) * 12))), n = G(r, i, 0, Math.PI * 2, !0, s);
2464
+ const s = Math.max(16, Math.min(this.opts.maxCurveSegments, Math.ceil(Math.sqrt(Math.abs(i)) * 12))), n = Z(r, i, 0, Math.PI * 2, !0, s);
2499
2465
  this.addPolyline(n, !0, this.strokeBytes(t)), this.stats.drawn++;
2500
2466
  }
2501
2467
  addArcEntity(t) {
2502
2468
  const r = t.center, i = Number(t.radius), s = Number(t.startAngle), n = Number(t.endAngle);
2503
2469
  if (!m(r) || !Number.isFinite(i) || !Number.isFinite(s) || !Number.isFinite(n)) return this.markSkipped("ARC");
2504
- this.addPolyline(G(r, i, s, n, !0, this.opts.maxCurveSegments), !1, this.strokeBytes(t)), this.stats.drawn++;
2470
+ this.addPolyline(Z(r, i, s, n, !0, this.opts.maxCurveSegments), !1, this.strokeBytes(t)), this.stats.drawn++;
2505
2471
  }
2506
2472
  addPolylineEntity(t) {
2507
2473
  const r = t.vertices ?? t.points;
@@ -2510,28 +2476,28 @@ class nr {
2510
2476
  for (let o = 0; o < n; o++) {
2511
2477
  const a = r[o], c = r[(o + 1) % r.length];
2512
2478
  if (!m(a) || !m(c)) continue;
2513
- const l = _t(a, c, Number(a.bulge ?? 0), Math.max(4, Math.min(24, this.opts.maxCurveSegments / 4)));
2514
- s.length > 0 && l.shift(), s.push(...l);
2479
+ const h = zt(a, c, Number(a.bulge ?? 0), Math.max(4, Math.min(24, this.opts.maxCurveSegments / 4)));
2480
+ s.length > 0 && h.shift(), s.push(...h);
2515
2481
  }
2516
2482
  if (s.length < 2) return this.markSkipped(String(t.type));
2517
2483
  this.addPolyline(s, i, this.strokeBytes(t)), this.stats.drawn++;
2518
2484
  }
2519
2485
  addEllipseEntity(t) {
2520
2486
  if (!m(t.center) || !m(t.majorAxisEndPoint)) return this.markSkipped("ELLIPSE");
2521
- const r = Z(t.center, t.majorAxisEndPoint, Number(t.axisRatio ?? 1), Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2), this.opts.maxCurveSegments), i = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
2487
+ const r = q(t.center, t.majorAxisEndPoint, Number(t.axisRatio ?? 1), Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2), this.opts.maxCurveSegments), i = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
2522
2488
  this.addPolyline(r, i, this.strokeBytes(t)), this.stats.drawn++;
2523
2489
  }
2524
2490
  addTextEntity(t) {
2525
- const r = t.insertionPoint ?? t.startPoint ?? t.center, i = Ut(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
2491
+ const r = t.insertionPoint ?? t.startPoint ?? t.center, i = Yt(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
2526
2492
  if (!m(r) || !i || !Number.isFinite(s)) return this.markSkipped(String(t.type));
2527
- const n = v(r), o = Math.max(1, i.split(/\r?\n/g).reduce((c, l) => Math.max(c, l.length), 0)) * Math.abs(s) * 0.62, a = Math.max(1, i.split(/\r?\n/g).length) * Math.abs(s) * 1.22;
2493
+ const n = x(r), o = Math.max(1, i.split(/\r?\n/g).reduce((c, h) => Math.max(c, h.length), 0)) * Math.abs(s) * 0.62, a = Math.max(1, i.split(/\r?\n/g).length) * Math.abs(s) * 1.22;
2528
2494
  this.textItems.push({
2529
2495
  point: n,
2530
2496
  text: i,
2531
2497
  height: s,
2532
2498
  rotation: Number(t.rotation ?? 0),
2533
- color: D(t, this.document, this.colorOptions()),
2534
- opacity: B(Number(t.opacity ?? 1), 0, 1),
2499
+ color: F(t, this.document, this.colorOptions()),
2500
+ opacity: T(Number(t.opacity ?? 1), 0, 1),
2535
2501
  bounds: { minX: n.x - o * 0.1, minY: n.y - a, maxX: n.x + o, maxY: n.y + a }
2536
2502
  }), this.stats.drawn++;
2537
2503
  }
@@ -2543,10 +2509,10 @@ class nr {
2543
2509
  addInsertEntity(t, r) {
2544
2510
  const i = this.lookupBlock(t.blockName ?? t.name);
2545
2511
  if (i && r < this.opts.maxInsertDepth) {
2546
- const n = Q(t, i.basePoint ?? { x: 0, y: 0 });
2512
+ const n = J(t, i.basePoint ?? { x: 0, y: 0 });
2547
2513
  for (const o of i.entities) {
2548
- const a = jt(o, t, this.document, this.colorOptions());
2549
- this.addEntityTracked(J(a, n), r + 1);
2514
+ const a = _t(o, t, this.document, this.colorOptions());
2515
+ this.addEntityTracked(Q(a, n), r + 1);
2550
2516
  }
2551
2517
  return;
2552
2518
  }
@@ -2558,7 +2524,7 @@ class nr {
2558
2524
  addSolidEntity(t) {
2559
2525
  const r = t.vertices ?? t.points;
2560
2526
  if (!Array.isArray(r) || r.length < 3) return this.markSkipped(String(t.type));
2561
- const i = r.filter(m).map(v);
2527
+ const i = r.filter(m).map(x);
2562
2528
  if (i.length < 3) return this.markSkipped(String(t.type));
2563
2529
  const s = this.fillBytes(t) ?? this.strokeBytes(t);
2564
2530
  this.addTriangleFan(i, s), this.addPolyline(i, !0, this.strokeBytes(t)), this.stats.drawn++;
@@ -2570,7 +2536,7 @@ class nr {
2570
2536
  const i = this.strokeBytes(t), s = this.fillBytes(t);
2571
2537
  let n = !1;
2572
2538
  for (const a of r) {
2573
- const c = (o = a.commands) != null && o.length ? Rt(a.commands, this.opts.maxCurveSegments) : (a.vertices ?? []).filter(m).map(v);
2539
+ const c = (o = a.commands) != null && o.length ? Ft(a.commands, this.opts.maxCurveSegments) : (a.vertices ?? []).filter(m).map(x);
2574
2540
  c.length < 2 || (this.addPolyline(c, !0, i), s && c.length >= 3 && this.addTriangleFan(c, s), n = !0);
2575
2541
  }
2576
2542
  if (!n) return this.markSkipped("HATCH");
@@ -2580,12 +2546,12 @@ class nr {
2580
2546
  var i;
2581
2547
  const r = (i = t.fitPoints) != null && i.length ? t.fitPoints : t.controlPoints;
2582
2548
  if (!r || r.length < 2) return this.markSkipped("SPLINE");
2583
- this.addPolyline(r.filter(m).map(v), !!t.isClosed, this.strokeBytes(t)), this.stats.drawn++;
2549
+ this.addPolyline(r.filter(m).map(x), !!t.isClosed, this.strokeBytes(t)), this.stats.drawn++;
2584
2550
  }
2585
2551
  addPathEntity(t) {
2586
2552
  var s;
2587
2553
  if (!((s = t.commands) != null && s.length)) return this.markSkipped(String(t.type));
2588
- const r = Rt(t.commands, this.opts.maxCurveSegments);
2554
+ const r = Ft(t.commands, this.opts.maxCurveSegments);
2589
2555
  if (r.length < 2) return this.markSkipped(String(t.type));
2590
2556
  this.addPolyline(r, !1, this.strokeBytes(t));
2591
2557
  const i = this.fillBytes(t);
@@ -2596,15 +2562,15 @@ class nr {
2596
2562
  if (!m(r)) return this.markSkipped(String(t.type));
2597
2563
  const i = Number(t.width ?? 32), s = Number(t.height ?? 32);
2598
2564
  if (!Number.isFinite(i) || !Number.isFinite(s)) return this.markSkipped(String(t.type));
2599
- const n = v(r), o = at([n, { x: n.x + i, y: n.y - s }]);
2600
- this.imageItems.push({ point: n, width: i, height: s, source: t.imageDataUrl ?? t.imageSource, color: D(t, this.document, this.colorOptions()), opacity: B(Number(t.opacity ?? 1), 0, 1), bounds: o }), this.stats.drawn++;
2565
+ const n = x(r), o = ot([n, { x: n.x + i, y: n.y - s }]);
2566
+ this.imageItems.push({ point: n, width: i, height: s, source: t.imageDataUrl ?? t.imageSource, color: F(t, this.document, this.colorOptions()), opacity: T(Number(t.opacity ?? 1), 0, 1), bounds: o }), this.stats.drawn++;
2601
2567
  }
2602
2568
  addUnsupportedMarker(t) {
2603
- const r = Qt(t);
2569
+ const r = $t(t);
2604
2570
  r && this.addPoint(r, this.strokeBytes(t));
2605
2571
  }
2606
2572
  addPolyline(t, r, i) {
2607
- const s = t.filter(m).map(v);
2573
+ const s = t.filter(m).map(x);
2608
2574
  if (!(s.length < 2)) {
2609
2575
  for (let n = 0; n < s.length - 1; n++) this.addSegment(s[n], s[n + 1], i);
2610
2576
  r && this.addSegment(s[s.length - 1], s[0], i);
@@ -2612,24 +2578,24 @@ class nr {
2612
2578
  }
2613
2579
  addSegment(t, r, i) {
2614
2580
  if (!m(t) || !m(r) || Math.hypot(t.x - r.x, t.y - r.y) <= 1e-14) return;
2615
- const s = this.batchFor(this.lineBuckets, at([t, r]));
2616
- L(s, t, i, this.origin), L(s, r, i, this.origin), s.primitiveCount++, this.primitiveCount++;
2581
+ const s = this.batchFor(this.lineBuckets, ot([t, r]));
2582
+ I(s, t, i, this.origin), I(s, r, i, this.origin), s.primitiveCount++, this.primitiveCount++;
2617
2583
  }
2618
2584
  addPoint(t, r) {
2619
- const i = this.batchFor(this.pointBuckets, lr(t));
2620
- L(i, t, r, this.origin), i.primitiveCount++, this.primitiveCount++;
2585
+ const i = this.batchFor(this.pointBuckets, sr(t));
2586
+ I(i, t, r, this.origin), i.primitiveCount++, this.primitiveCount++;
2621
2587
  }
2622
2588
  addTriangleFan(t, r) {
2623
- const i = t.filter(m).map(v);
2589
+ const i = t.filter(m).map(x);
2624
2590
  if (i.length < 3) return;
2625
- const s = at(i), n = this.batchFor(this.triangleBuckets, s);
2591
+ const s = ot(i), n = this.batchFor(this.triangleBuckets, s);
2626
2592
  for (let o = 1; o < i.length - 1; o++)
2627
- L(n, i[0], r, this.origin), L(n, i[o], r, this.origin), L(n, i[o + 1], r, this.origin), n.primitiveCount++, this.primitiveCount++;
2593
+ I(n, i[0], r, this.origin), I(n, i[o], r, this.origin), I(n, i[o + 1], r, this.origin), n.primitiveCount++, this.primitiveCount++;
2628
2594
  }
2629
2595
  batchFor(t, r) {
2630
2596
  const i = this.bucketKey(r);
2631
2597
  let s = t.get(i);
2632
- return s || (s = or(), t.set(i, s)), y(s.bounds, { x: r.minX, y: r.minY }), y(s.bounds, { x: r.maxX, y: r.maxY }), s;
2598
+ return s || (s = er(), t.set(i, s)), b(s.bounds, { x: r.minX, y: r.minY }), b(s.bounds, { x: r.maxX, y: r.maxY }), s;
2633
2599
  }
2634
2600
  bucketKey(t) {
2635
2601
  if (!Number.isFinite(this.tileSize)) return "all";
@@ -2637,11 +2603,11 @@ class nr {
2637
2603
  return `${s}:${n}`;
2638
2604
  }
2639
2605
  strokeBytes(t) {
2640
- return pt(D(t, this.document, this.colorOptions()), [255, 255, 255, 255], B(Number(t.opacity ?? 1), 0, 1));
2606
+ return ut(F(t, this.document, this.colorOptions()), [255, 255, 255, 255], T(Number(t.opacity ?? 1), 0, 1));
2641
2607
  }
2642
2608
  fillBytes(t) {
2643
- const r = ft(t, this.document, this.colorOptions());
2644
- return r ? pt(r, [255, 255, 255, 255], B(Number(t.opacity ?? 1), 0, 1)) : void 0;
2609
+ const r = lt(t, this.document, this.colorOptions());
2610
+ return r ? ut(r, [255, 255, 255, 255], T(Number(t.opacity ?? 1), 0, 1)) : void 0;
2645
2611
  }
2646
2612
  colorOptions() {
2647
2613
  return { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast };
@@ -2658,134 +2624,134 @@ class nr {
2658
2624
  return this.document.blocks[t] ?? this.document.blocks[t.toLowerCase()] ?? Object.values(this.document.blocks).find((r) => r.name.toLowerCase() === t.toLowerCase());
2659
2625
  }
2660
2626
  }
2661
- function or() {
2662
- return { positions: [], colors: [], bounds: N(), primitiveCount: 0 };
2627
+ function er() {
2628
+ return { positions: [], colors: [], bounds: M(), primitiveCount: 0 };
2663
2629
  }
2664
- function L(e, t, r, i) {
2630
+ function I(e, t, r, i) {
2665
2631
  e.positions.push(t.x - i.x, t.y - i.y), e.colors.push(r[0], r[1], r[2], r[3]);
2666
2632
  }
2667
- function ot(e, t) {
2633
+ function nt(e, t) {
2668
2634
  const r = [];
2669
2635
  for (const i of e.values()) {
2670
2636
  const s = i.positions.length / 2;
2671
- if (s <= 0 || !R(i.bounds)) continue;
2637
+ if (s <= 0 || !D(i.bounds)) continue;
2672
2638
  if (s <= t) {
2673
2639
  r.push({ positions: new Float32Array(i.positions), colors: new Uint8Array(i.colors), bounds: { ...i.bounds }, primitiveCount: i.primitiveCount });
2674
2640
  continue;
2675
2641
  }
2676
- const n = ar(i), o = Math.max(n, Math.floor(t / n) * n);
2642
+ const n = rr(i), o = Math.max(n, Math.floor(t / n) * n);
2677
2643
  for (let a = 0; a < s; a += o) {
2678
- const c = Math.min(s, a + o), l = i.positions.slice(a * 2, c * 2), h = i.colors.slice(a * 4, c * 4), f = N();
2679
- for (let d = 0; d < l.length; d += 2) y(f, { x: l[d], y: l[d + 1] });
2680
- r.push({ positions: new Float32Array(l), colors: new Uint8Array(h), bounds: { ...i.bounds }, primitiveCount: Math.floor((c - a) / n) });
2644
+ const c = Math.min(s, a + o), h = i.positions.slice(a * 2, c * 2), l = i.colors.slice(a * 4, c * 4), f = M();
2645
+ for (let u = 0; u < h.length; u += 2) b(f, { x: h[u], y: h[u + 1] });
2646
+ r.push({ positions: new Float32Array(h), colors: new Uint8Array(l), bounds: { ...i.bounds }, primitiveCount: Math.floor((c - a) / n) });
2681
2647
  }
2682
2648
  }
2683
2649
  return r;
2684
2650
  }
2685
- function ar(e) {
2651
+ function rr(e) {
2686
2652
  const t = e.positions.length / 2;
2687
2653
  return t === e.primitiveCount ? 1 : t === e.primitiveCount * 3 ? 3 : 2;
2688
2654
  }
2689
- function cr(e, t) {
2655
+ function ir(e, t) {
2690
2656
  var n;
2691
- const r = N();
2657
+ const r = M();
2692
2658
  if ((n = e.pages) != null && n.length)
2693
2659
  for (const o of e.pages)
2694
- y(r, { x: 0, y: 0 }), y(r, { x: o.width, y: o.height });
2660
+ b(r, { x: 0, y: 0 }), b(r, { x: o.width, y: o.height });
2695
2661
  const i = (o) => {
2696
2662
  if (o)
2697
2663
  return e.blocks[o] ?? e.blocks[o.toLowerCase()] ?? Object.values(e.blocks).find((a) => a.name.toLowerCase() === o.toLowerCase());
2698
2664
  }, s = (o, a) => {
2699
- const c = String(o.type ?? "").toUpperCase(), l = o.kind ?? O(c);
2700
- if (l === "insert") {
2701
- const h = i(o.blockName ?? o.name);
2702
- if (h && a < t.maxInsertDepth) {
2703
- const f = Q(o, h.basePoint ?? { x: 0, y: 0 });
2704
- for (const d of h.entities) s(J(d, f), a + 1);
2665
+ const c = String(o.type ?? "").toUpperCase(), h = o.kind ?? R(c);
2666
+ if (h === "insert") {
2667
+ const l = i(o.blockName ?? o.name);
2668
+ if (l && a < t.maxInsertDepth) {
2669
+ const f = J(o, l.basePoint ?? { x: 0, y: 0 });
2670
+ for (const u of l.entities) s(Q(u, f), a + 1);
2705
2671
  return;
2706
2672
  }
2707
2673
  }
2708
- if (l === "line")
2709
- m(o.startPoint) && y(r, o.startPoint), m(o.endPoint) && y(r, o.endPoint);
2710
- else if (l === "circle" || l === "arc")
2711
- m(o.center) && Number.isFinite(o.radius) && Yt(r, o.center, Number(o.radius));
2712
- else if (l === "polyline" || l === "solid" || l === "spline")
2713
- for (const h of [...o.vertices ?? [], ...o.points ?? [], ...o.controlPoints ?? [], ...o.fitPoints ?? []]) m(h) && y(r, h);
2714
- else if (l === "ellipse")
2715
- m(o.center) && m(o.majorAxisEndPoint) && Z(o.center, o.majorAxisEndPoint, Number(o.axisRatio ?? 1), Number(o.startAngle ?? 0), Number(o.endAngle ?? Math.PI * 2), t.maxCurveSegments).forEach((h) => y(r, h));
2716
- else if (l === "path")
2717
- for (const h of o.commands ?? []) for (const f of h.points) y(r, f);
2718
- else if (l === "hatch")
2719
- for (const h of o.loops ?? []) {
2720
- for (const f of h.vertices ?? []) y(r, f);
2721
- for (const f of h.commands ?? []) for (const d of f.points) y(r, d);
2674
+ if (h === "line")
2675
+ m(o.startPoint) && b(r, o.startPoint), m(o.endPoint) && b(r, o.endPoint);
2676
+ else if (h === "circle" || h === "arc")
2677
+ m(o.center) && Number.isFinite(o.radius) && Dt(r, o.center, Number(o.radius));
2678
+ else if (h === "polyline" || h === "solid" || h === "spline")
2679
+ for (const l of [...o.vertices ?? [], ...o.points ?? [], ...o.controlPoints ?? [], ...o.fitPoints ?? []]) m(l) && b(r, l);
2680
+ else if (h === "ellipse")
2681
+ m(o.center) && m(o.majorAxisEndPoint) && q(o.center, o.majorAxisEndPoint, Number(o.axisRatio ?? 1), Number(o.startAngle ?? 0), Number(o.endAngle ?? Math.PI * 2), t.maxCurveSegments).forEach((l) => b(r, l));
2682
+ else if (h === "path")
2683
+ for (const l of o.commands ?? []) for (const f of l.points) b(r, f);
2684
+ else if (h === "hatch")
2685
+ for (const l of o.loops ?? []) {
2686
+ for (const f of l.vertices ?? []) b(r, f);
2687
+ for (const f of l.commands ?? []) for (const u of f.points) b(r, u);
2722
2688
  }
2723
2689
  else {
2724
- const h = Qt(o);
2725
- h && y(r, h);
2690
+ const l = $t(o);
2691
+ l && b(r, l);
2726
2692
  }
2727
2693
  };
2728
2694
  for (const o of e.entities) s(o, 0);
2729
- return Ht(r);
2695
+ return Ot(r);
2730
2696
  }
2731
- function Rt(e, t) {
2697
+ function Ft(e, t) {
2732
2698
  const r = [];
2733
2699
  let i, s;
2734
2700
  const n = (o) => {
2735
- (!r.length || Math.hypot(r[r.length - 1].x - o.x, r[r.length - 1].y - o.y) > 1e-12) && r.push(v(o)), i = v(o);
2701
+ (!r.length || Math.hypot(r[r.length - 1].x - o.x, r[r.length - 1].y - o.y) > 1e-12) && r.push(x(o)), i = x(o);
2736
2702
  };
2737
2703
  for (const o of e)
2738
2704
  if (o.cmd === "M")
2739
- i = v(o.points[0]), s = i, n(i);
2705
+ i = x(o.points[0]), s = i, n(i);
2740
2706
  else if (o.cmd === "L")
2741
2707
  n(o.points[0]);
2742
2708
  else if (o.cmd === "Q" && i && o.points.length >= 2) {
2743
- const a = i, [c, l] = o.points, h = Math.max(4, Math.min(t, 24));
2744
- for (let f = 1; f <= h; f++) {
2745
- const d = f / h, p = 1 - d;
2746
- n({ x: p * p * a.x + 2 * p * d * c.x + d * d * l.x, y: p * p * a.y + 2 * p * d * c.y + d * d * l.y });
2709
+ const a = i, [c, h] = o.points, l = Math.max(4, Math.min(t, 24));
2710
+ for (let f = 1; f <= l; f++) {
2711
+ const u = f / l, p = 1 - u;
2712
+ n({ x: p * p * a.x + 2 * p * u * c.x + u * u * h.x, y: p * p * a.y + 2 * p * u * c.y + u * u * h.y });
2747
2713
  }
2748
2714
  } else if (o.cmd === "C" && i && o.points.length >= 3) {
2749
- const a = i, [c, l, h] = o.points, f = Math.max(6, Math.min(t, 32));
2750
- for (let d = 1; d <= f; d++) {
2751
- const p = d / f, g = 1 - p;
2715
+ const a = i, [c, h, l] = o.points, f = Math.max(6, Math.min(t, 32));
2716
+ for (let u = 1; u <= f; u++) {
2717
+ const p = u / f, v = 1 - p;
2752
2718
  n({
2753
- x: g ** 3 * a.x + 3 * g * g * p * c.x + 3 * g * p * p * l.x + p ** 3 * h.x,
2754
- y: g ** 3 * a.y + 3 * g * g * p * c.y + 3 * g * p * p * l.y + p ** 3 * h.y
2719
+ x: v ** 3 * a.x + 3 * v * v * p * c.x + 3 * v * p * p * h.x + p ** 3 * l.x,
2720
+ y: v ** 3 * a.y + 3 * v * v * p * c.y + 3 * v * p * p * h.y + p ** 3 * l.y
2755
2721
  });
2756
2722
  }
2757
2723
  } else o.cmd === "Z" && s && n(s);
2758
2724
  return r;
2759
2725
  }
2760
- function Qt(e) {
2726
+ function $t(e) {
2761
2727
  for (const t of ["startPoint", "insertionPoint", "center", "point", "location"]) {
2762
2728
  const r = e[t];
2763
- if (m(r)) return v(r);
2729
+ if (m(r)) return x(r);
2764
2730
  }
2765
- if (Array.isArray(e.vertices) && m(e.vertices[0])) return v(e.vertices[0]);
2731
+ if (Array.isArray(e.vertices) && m(e.vertices[0])) return x(e.vertices[0]);
2766
2732
  if (Array.isArray(e.commands) && e.commands.length) {
2767
2733
  const t = e.commands.find((r) => r.points.length > 0);
2768
- if (t) return v(t.points[0]);
2734
+ if (t) return x(t.points[0]);
2769
2735
  }
2770
2736
  }
2771
- function at(e) {
2772
- const t = N();
2773
- for (const r of e) y(t, r);
2737
+ function ot(e) {
2738
+ const t = M();
2739
+ for (const r of e) b(t, r);
2774
2740
  return t;
2775
2741
  }
2776
- function lr(e) {
2742
+ function sr(e) {
2777
2743
  return { minX: e.x, minY: e.y, maxX: e.x, maxY: e.y };
2778
2744
  }
2779
- function ct(e, t) {
2745
+ function at(e, t) {
2780
2746
  return e.minX <= t.maxX && e.maxX >= t.minX && e.minY <= t.maxY && e.maxY >= t.minY;
2781
2747
  }
2782
- function hr(e, t) {
2748
+ function nr(e, t) {
2783
2749
  return t.trueColorByteOrder !== void 0 && t.trueColorByteOrder !== e.trueColorByteOrder || t.contrastMode !== void 0 && t.contrastMode !== e.contrastMode || t.minColorContrast !== void 0 && t.minColorContrast !== e.minColorContrast || t.foreground !== void 0 && t.foreground !== e.foreground || t.background !== void 0 && t.background !== e.background || t.maxInsertDepth !== void 0 && t.maxInsertDepth !== e.maxInsertDepth || t.maxCurveSegments !== void 0 && t.maxCurveSegments !== e.maxCurveSegments || t.spatialIndexCellCount !== void 0 && t.spatialIndexCellCount !== e.spatialIndexCellCount || t.maxVerticesPerBatch !== void 0 && t.maxVerticesPerBatch !== e.maxVerticesPerBatch || t.enableSpatialIndex !== void 0 && t.enableSpatialIndex !== e.enableSpatialIndex;
2784
2750
  }
2785
- function fr(e, t) {
2751
+ function or(e, t) {
2786
2752
  return { ...e.stats, renderElapsedMs: t, backend: "webgl", primitiveCount: e.primitiveCount, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: e.gpuMemoryBytes, buildElapsedMs: e.buildElapsedMs };
2787
2753
  }
2788
- function dr(e) {
2754
+ function ar(e) {
2789
2755
  return {
2790
2756
  total: e.total,
2791
2757
  drawn: e.drawn,
@@ -2801,7 +2767,7 @@ function dr(e) {
2801
2767
  buildElapsedMs: e.buildElapsedMs
2802
2768
  };
2803
2769
  }
2804
- function pt(e, t, r = 1) {
2770
+ function ut(e, t, r = 1) {
2805
2771
  const i = e.trim().toLowerCase();
2806
2772
  let s;
2807
2773
  if (/^#[0-9a-f]{3}$/i.test(i))
@@ -2811,8 +2777,8 @@ function pt(e, t, r = 1) {
2811
2777
  else {
2812
2778
  const o = i.match(/^rgba?\(([^)]+)\)$/i);
2813
2779
  if (o) {
2814
- const a = o[1].split(/[\s,\/]+/).filter(Boolean), c = a.slice(0, 3).some((h) => h.includes("%")), l = a.map((h) => Number(h.replace("%", "")));
2815
- l.length >= 3 && l.slice(0, 3).every(Number.isFinite) && (s = [X(c ? l[0] * 2.55 : l[0]), X(c ? l[1] * 2.55 : l[1]), X(c ? l[2] * 2.55 : l[2]), X((Number.isFinite(l[3]) ? l[3] : 1) * 255)]);
2780
+ const a = o[1].split(/[\s,\/]+/).filter(Boolean), c = a.slice(0, 3).some((l) => l.includes("%")), h = a.map((l) => Number(l.replace("%", "")));
2781
+ h.length >= 3 && h.slice(0, 3).every(Number.isFinite) && (s = [X(c ? h[0] * 2.55 : h[0]), X(c ? h[1] * 2.55 : h[1]), X(c ? h[2] * 2.55 : h[2]), X((Number.isFinite(h[3]) ? h[3] : 1) * 255)]);
2816
2782
  }
2817
2783
  }
2818
2784
  const n = s ?? t;
@@ -2821,60 +2787,52 @@ function pt(e, t, r = 1) {
2821
2787
  function X(e) {
2822
2788
  return Math.max(0, Math.min(255, Math.round(e)));
2823
2789
  }
2824
- class ur {
2790
+ class cr {
2825
2791
  constructor(t = {}) {
2826
- u(this, "canvas");
2827
- u(this, "renderer");
2828
- u(this, "registry");
2829
- u(this, "options");
2830
- u(this, "lastResult");
2831
- if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ?? Ke(t), t.loaders) for (const r of t.loaders) this.registry.register(r);
2832
- this.canvas = t.canvas ?? document.createElement("canvas"), this.canvas.classList.add("cad-viewer-canvas"), !t.canvas && t.container && (this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", t.container.appendChild(this.canvas)), this.renderer = mr(t.renderer ?? "auto", this.canvas, t.canvasOptions), this.renderer.onStats = (r) => {
2833
- var i, s;
2834
- return (s = (i = this.options).onRenderStats) == null ? void 0 : s.call(i, r);
2835
- }, this.renderer.onViewChange = (r) => {
2836
- var i, s;
2837
- return (s = (i = this.options).onViewChange) == null ? void 0 : s.call(i, r);
2792
+ d(this, "canvas");
2793
+ d(this, "renderer");
2794
+ d(this, "registry");
2795
+ d(this, "nativeHost");
2796
+ d(this, "options");
2797
+ d(this, "lastResult");
2798
+ d(this, "activeNativeLoader");
2799
+ var r;
2800
+ if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ?? Fe(t), t.loaders) for (const i of t.loaders) this.registry.register(i);
2801
+ if (this.canvas = t.canvas ?? document.createElement("canvas"), this.canvas.classList.add("cad-viewer-canvas"), t.container)
2802
+ t.container.classList.add("cad-viewer-container"), t.canvas || (this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", t.container.appendChild(this.canvas)), this.nativeHost = t.nativeHost ?? document.createElement("div"), this.nativeHost.classList.add("cad-viewer-native-host"), t.nativeHost || t.container.appendChild(this.nativeHost);
2803
+ else if (t.nativeHost)
2804
+ this.nativeHost = t.nativeHost, this.nativeHost.classList.add("cad-viewer-native-host");
2805
+ else if ((r = t.canvas) != null && r.parentElement) {
2806
+ t.canvas.parentElement.classList.add("cad-viewer-container");
2807
+ const i = document.createElement("div");
2808
+ i.classList.add("cad-viewer-native-host"), t.canvas.parentElement.appendChild(i), this.nativeHost = i;
2809
+ }
2810
+ this.renderer = lr(t.renderer ?? "auto", this.canvas, t.canvasOptions), this.renderer.onStats = (i) => {
2811
+ var s, n;
2812
+ return (n = (s = this.options).onRenderStats) == null ? void 0 : n.call(s, i);
2813
+ }, this.renderer.onViewChange = (i) => {
2814
+ var s, n;
2815
+ return (n = (s = this.options).onViewChange) == null ? void 0 : n.call(s, i);
2838
2816
  };
2839
2817
  }
2840
2818
  registerLoader(t) {
2841
2819
  return this.registry.register(t), this;
2842
2820
  }
2843
2821
  async loadFile(t, r = {}) {
2844
- var i, s, n, o;
2845
- (s = (i = this.options).onLoadStart) == null || s.call(i, t);
2846
- try {
2847
- const a = await this.registry.load({ file: t, fileName: t.name }, this.mergeLoadOptions(r));
2848
- return this.applyLoadResult(a, t.name);
2849
- } catch (a) {
2850
- const c = lt(a);
2851
- throw (o = (n = this.options).onError) == null || o.call(n, c), c;
2852
- }
2822
+ var i, s;
2823
+ return (s = (i = this.options).onLoadStart) == null || s.call(i, t), this.loadThroughRegistry({ file: t, fileName: t.name }, r, t.name);
2853
2824
  }
2854
2825
  async loadBuffer(t, r, i = {}) {
2855
- var s, n, o, a;
2856
- (n = (s = this.options).onLoadStart) == null || n.call(s, t);
2857
- try {
2858
- const c = await this.registry.load({ buffer: t, fileName: r }, this.mergeLoadOptions(i));
2859
- return this.applyLoadResult(c, r);
2860
- } catch (c) {
2861
- const l = lt(c);
2862
- throw (a = (o = this.options).onError) == null || a.call(o, l), l;
2863
- }
2826
+ var s, n;
2827
+ return (n = (s = this.options).onLoadStart) == null || n.call(s, t), this.loadThroughRegistry({ buffer: t, fileName: r }, i, r);
2864
2828
  }
2865
2829
  async load(t, r = {}) {
2866
- var i, s, n, o, a;
2867
- (s = (i = this.options).onLoadStart) == null || s.call(i, t);
2868
- try {
2869
- const c = await this.registry.load(t, this.mergeLoadOptions(r));
2870
- return this.applyLoadResult(c, t.fileName ?? ((n = t.file) == null ? void 0 : n.name));
2871
- } catch (c) {
2872
- const l = lt(c);
2873
- throw (a = (o = this.options).onError) == null || a.call(o, l), l;
2874
- }
2830
+ var i, s, n;
2831
+ return (s = (i = this.options).onLoadStart) == null || s.call(i, t), this.loadThroughRegistry(t, r, t.fileName ?? ((n = t.file) == null ? void 0 : n.name));
2875
2832
  }
2876
2833
  setDocument(t, r) {
2877
2834
  var s, n;
2835
+ this.deactivateNativeRenderer();
2878
2836
  const i = {
2879
2837
  document: t,
2880
2838
  raw: t.raw,
@@ -2882,25 +2840,33 @@ class ur {
2882
2840
  elapsedMs: 0,
2883
2841
  format: t.format,
2884
2842
  warnings: t.warnings,
2885
- summary: kt(t),
2843
+ summary: j(t),
2886
2844
  fileName: r
2887
2845
  };
2888
2846
  return this.renderer.setDocument(t), this.options.autoFit || this.renderer.render(), this.lastResult = i, (n = (s = this.options).onLoad) == null || n.call(s, i), i;
2889
2847
  }
2890
2848
  fit() {
2891
- this.renderer.fitToView();
2849
+ var t, r;
2850
+ this.activeNativeLoader ? (r = (t = this.activeNativeLoader).fit) == null || r.call(t) : this.renderer.fitToView();
2892
2851
  }
2893
2852
  zoomIn() {
2894
- this.renderer.zoomIn();
2853
+ var t, r;
2854
+ this.activeNativeLoader ? (r = (t = this.activeNativeLoader).zoomIn) == null || r.call(t) : this.renderer.zoomIn();
2895
2855
  }
2896
2856
  zoomOut() {
2897
- this.renderer.zoomOut();
2857
+ var t, r;
2858
+ this.activeNativeLoader ? (r = (t = this.activeNativeLoader).zoomOut) == null || r.call(t) : this.renderer.zoomOut();
2898
2859
  }
2899
2860
  resize() {
2900
- this.renderer.resize();
2861
+ var t, r;
2862
+ this.activeNativeLoader ? (r = (t = this.activeNativeLoader).resize) == null || r.call(t) : this.renderer.resize();
2901
2863
  }
2902
2864
  setCanvasOptions(t) {
2903
- this.renderer.setOptions(t);
2865
+ var r, i;
2866
+ this.options.canvasOptions = { ...this.options.canvasOptions ?? {}, ...t }, this.renderer.setOptions(t), this.activeNativeLoader && ((i = (r = this.activeNativeLoader).setNativeOptions) == null || i.call(r, {
2867
+ ...this.mergeLoadOptions({}),
2868
+ dwfBackground: t.background ?? this.options.dwfBackground
2869
+ }));
2904
2870
  }
2905
2871
  async preloadDwg(t = {}) {
2906
2872
  const r = this.registry.list().find((i) => i.id === "dwg");
@@ -2908,13 +2874,14 @@ class ur {
2908
2874
  return r.preload(this.mergeLoadOptions(t));
2909
2875
  }
2910
2876
  clear() {
2911
- this.lastResult = void 0, this.renderer.clear();
2877
+ this.lastResult = void 0, this.deactivateNativeRenderer(), this.renderer.clear();
2912
2878
  }
2913
2879
  destroy() {
2914
- var t, r;
2915
- for (const i of this.registry.list()) {
2916
- const s = i;
2917
- (t = s.terminateWorker) == null || t.call(s), (r = s.destroy) == null || r.call(s);
2880
+ var t, r, i;
2881
+ this.deactivateNativeRenderer();
2882
+ for (const s of this.registry.list()) {
2883
+ const n = s;
2884
+ (t = n.terminateWorker) == null || t.call(n), (r = n.unmount) == null || r.call(n), (i = n.destroy) == null || i.call(n);
2918
2885
  }
2919
2886
  this.renderer.destroy();
2920
2887
  }
@@ -2922,21 +2889,84 @@ class ur {
2922
2889
  return this.lastResult;
2923
2890
  }
2924
2891
  getDocument() {
2925
- return this.renderer.getDocument();
2892
+ var t;
2893
+ return this.activeNativeLoader ? (t = this.lastResult) == null ? void 0 : t.document : this.renderer.getDocument();
2926
2894
  }
2927
2895
  getZoomPercent() {
2928
- return this.renderer.getZoomPercent();
2896
+ return this.activeNativeLoader ? 100 : this.renderer.getZoomPercent();
2897
+ }
2898
+ isNativeRendererActive() {
2899
+ return !!this.activeNativeLoader;
2900
+ }
2901
+ async loadThroughRegistry(t, r, i) {
2902
+ var s, n;
2903
+ try {
2904
+ const o = this.mergeLoadOptions(r);
2905
+ ct(o.signal);
2906
+ const a = await this.registry.detect(t), c = { ...t, buffer: a.bytes };
2907
+ if (We(a.loader))
2908
+ return await this.applyNativeLoadResult(a.loader, c, o, i);
2909
+ const h = await a.loader.load(c, o);
2910
+ return this.applyLoadResult(h, i);
2911
+ } catch (o) {
2912
+ const a = hr(o);
2913
+ throw (n = (s = this.options).onError) == null || n.call(s, a), a;
2914
+ }
2929
2915
  }
2930
2916
  applyLoadResult(t, r) {
2931
2917
  var s, n, o, a;
2932
- (n = (s = this.options).onLoadProgress) == null || n.call(s, { phase: "render", format: t.format, message: "Rendering normalized CAD scene…", percent: 96 }), this.renderer.setDocument(t.document), this.options.autoFit || this.renderer.render();
2918
+ this.deactivateNativeRenderer(), (n = (s = this.options).onLoadProgress) == null || n.call(s, { phase: "render", format: t.format, message: "Rendering normalized CAD scene…", percent: 96 }), this.renderer.setDocument(t.document), this.options.autoFit || this.renderer.render();
2933
2919
  const i = {
2934
2920
  ...t,
2935
2921
  fileName: r,
2936
- summary: kt(t.document)
2922
+ summary: j(t.document)
2937
2923
  };
2938
2924
  return this.lastResult = i, (a = (o = this.options).onLoad) == null || a.call(o, i), i;
2939
2925
  }
2926
+ async applyNativeLoadResult(t, r, i, s) {
2927
+ var n, o, a;
2928
+ if (!this.nativeHost)
2929
+ throw new Error("Native DWF rendering requires CadViewerOptions.container, nativeHost, or a canvas parent element.");
2930
+ ct(i.signal), this.renderer.clear(), (n = this.activeNativeLoader) == null || n.unmount(), this.activeNativeLoader = t, this.canvas.style.display = "none", this.nativeHost.classList.add("is-active");
2931
+ try {
2932
+ const c = await t.mount(r, this.nativeHost, i);
2933
+ ct(i.signal);
2934
+ const h = {
2935
+ ...c,
2936
+ fileName: s,
2937
+ summary: j(c.document)
2938
+ };
2939
+ return this.lastResult = h, this.emitNativeRenderStats(c), (a = (o = this.options).onLoad) == null || a.call(o, h), h;
2940
+ } catch (c) {
2941
+ throw this.deactivateNativeRenderer(), c;
2942
+ }
2943
+ }
2944
+ deactivateNativeRenderer() {
2945
+ var t, r;
2946
+ if (!this.activeNativeLoader && !((t = this.nativeHost) != null && t.classList.contains("is-active"))) {
2947
+ this.canvas.style.display = "";
2948
+ return;
2949
+ }
2950
+ (r = this.activeNativeLoader) == null || r.unmount(), this.activeNativeLoader = void 0, this.nativeHost && (this.nativeHost.classList.remove("is-active"), this.nativeHost.replaceChildren()), this.canvas.style.display = "";
2951
+ }
2952
+ emitNativeRenderStats(t) {
2953
+ var o, a, c, h;
2954
+ const r = t.document.metadata, i = Number(((o = r.nativeRenderStats) == null ? void 0 : o.commands) ?? t.document.entities.length ?? 0), n = String(((a = r.nativeRenderStats) == null ? void 0 : a.backend) ?? "webgl").includes("webgl") ? "webgl" : "canvas2d";
2955
+ (h = (c = this.options).onRenderStats) == null || h.call(c, {
2956
+ total: i,
2957
+ drawn: i,
2958
+ skipped: 0,
2959
+ byType: j(t.document).byType,
2960
+ unsupported: {},
2961
+ renderElapsedMs: t.elapsedMs,
2962
+ backend: n,
2963
+ primitiveCount: i,
2964
+ visiblePrimitiveCount: i,
2965
+ culledPrimitiveCount: 0,
2966
+ gpuMemoryBytes: void 0,
2967
+ buildElapsedMs: t.elapsedMs
2968
+ });
2969
+ }
2940
2970
  mergeLoadOptions(t) {
2941
2971
  const r = this.options.onProgress, i = t.onProgress;
2942
2972
  return {
@@ -2949,44 +2979,48 @@ class ur {
2949
2979
  };
2950
2980
  }
2951
2981
  }
2952
- function br(e = {}) {
2953
- return new ur(e);
2982
+ function ur(e = {}) {
2983
+ return new cr(e);
2954
2984
  }
2955
- function lt(e) {
2985
+ function hr(e) {
2956
2986
  return e instanceof Error ? e : new Error(String(e));
2957
2987
  }
2958
- function mr(e, t, r = {}) {
2959
- if (e === "canvas2d") return new Ft(t, r);
2960
- if (e === "webgl") return new Dt(t, r);
2961
- if (Kt())
2988
+ function ct(e) {
2989
+ if (e != null && e.aborted)
2990
+ throw new DOMException("Loading cancelled.", "AbortError");
2991
+ }
2992
+ function lr(e, t, r = {}) {
2993
+ if (e === "canvas2d") return new Tt(t, r);
2994
+ if (e === "webgl") return new Lt(t, r);
2995
+ if (Vt())
2962
2996
  try {
2963
- return new Dt(t, r);
2997
+ return new Lt(t, r);
2964
2998
  } catch {
2965
2999
  }
2966
- return new Ft(t, r);
3000
+ return new Tt(t, r);
2967
3001
  }
2968
3002
  export {
2969
- Ft as CadCanvasRenderer,
2970
- ie as CadLoaderRegistry,
2971
- ur as CadViewer,
2972
- Dt as CadWebGLRenderer,
2973
- ze as DwfLoader,
2974
- mt as DwfUnsupportedError,
2975
- le as DwgLoader,
2976
- se as DwgWorkerClient,
2977
- pe as DxfLoader,
2978
- T as colorFromAci,
2979
- H as colorFromTrueColor,
2980
- Xt as createCadDocument,
2981
- br as createCadViewer,
2982
- Ke as createDefaultLoaderRegistry,
2983
- rt as detectCadFormat,
2984
- O as inferEntityKind,
2985
- Kt as isWebGLAvailable,
2986
- de as normalizeCadEntity,
2987
- et as readInputBytes,
2988
- D as resolveCadColor,
2989
- kt as summarizeCadDocument,
3003
+ Tt as CadCanvasRenderer,
3004
+ Jt as CadLoaderRegistry,
3005
+ cr as CadViewer,
3006
+ Lt as CadWebGLRenderer,
3007
+ Pe as DwfLoader,
3008
+ se as DwgLoader,
3009
+ Qt as DwgWorkerClient,
3010
+ le as DxfLoader,
3011
+ N as colorFromAci,
3012
+ U as colorFromTrueColor,
3013
+ Rt as createCadDocument,
3014
+ ur as createCadViewer,
3015
+ Fe as createDefaultLoaderRegistry,
3016
+ B as detectCadFormat,
3017
+ R as inferEntityKind,
3018
+ We as isCadNativeRenderableLoader,
3019
+ Vt as isWebGLAvailable,
3020
+ ae as normalizeCadEntity,
3021
+ _ as readInputBytes,
3022
+ F as resolveCadColor,
3023
+ j as summarizeCadDocument,
2990
3024
  ht as supportsDwgWorker
2991
3025
  };
2992
3026
  //# sourceMappingURL=cad-viewer.es.js.map