@solid-labs/fab-one-widget 1.1.13 → 1.1.14

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,18 +1,18 @@
1
1
  import { jsxs as y, jsx as i, Fragment as _e } from "react/jsx-runtime";
2
- import { createContext as Wo, Component as Bo, useCallback as de, useMemo as te, useState as B, memo as $o, useEffect as Z, useRef as fe, forwardRef as To, createElement as Fn } from "react";
2
+ import { createContext as Wo, Component as $o, useCallback as de, useMemo as te, useState as $, memo as Bo, useEffect as Z, useRef as fe, forwardRef as To, createElement as Fn } from "react";
3
3
  import { useFrame as On, useThree as Hn, Canvas as Oo } from "@react-three/fiber";
4
4
  import { Html as Xe, Line as ve, OrbitControls as Nn } from "@react-three/drei";
5
5
  import * as U from "three";
6
- import { Plane as At, Vector3 as k, Box3 as Vn, Line3 as jn, Raycaster as Ho } from "three";
6
+ import { Plane as Mt, Vector3 as k, Box3 as Vn, Line3 as jn, Raycaster as Ho } from "three";
7
7
  import { create as No } from "zustand";
8
8
  import { OBJLoader as Gn } from "three/examples/jsm/loaders/OBJLoader.js";
9
9
  import { STLLoader as Xn } from "three/examples/jsm/loaders/STLLoader.js";
10
10
  import { unzipSync as Vo } from "three/examples/jsm/libs/fflate.module.js";
11
11
  import { PLYLoader as jo } from "three/examples/jsm/loaders/PLYLoader.js";
12
12
  import { MeshBVH as zt } from "three-mesh-bvh";
13
- let xi, vt, ni, no, en;
13
+ let bi, vt, oi, no, en;
14
14
  let __tla = (async () => {
15
- let Go, Xo, Ko, Yo, Zo, Mt, Zt, St, Uo;
15
+ let Go, Xo, Yo, Ko, Zo, kt, Ut, St, Uo;
16
16
  Go = {
17
17
  showDragDrop: true,
18
18
  showStartOver: true,
@@ -33,7 +33,7 @@ let __tla = (async () => {
33
33
  showToolbar: false,
34
34
  showSaveButton: false
35
35
  };
36
- Ko = Wo(Go);
36
+ Yo = Wo(Go);
37
37
  en = No((e, o) => ({
38
38
  landmarkPoints: [],
39
39
  isAligned: false,
@@ -74,10 +74,10 @@ let __tla = (async () => {
74
74
  isCut: false
75
75
  })
76
76
  }));
77
- Yo = "1.1.13";
77
+ Ko = "1.1.14";
78
78
  Zo = 0.45;
79
- Mt = 3;
80
- Zt = 1e-3;
79
+ kt = 3;
80
+ Ut = 1e-3;
81
81
  St = 25.4;
82
82
  Uo = [
83
83
  0.25,
@@ -96,8 +96,8 @@ let __tla = (async () => {
96
96
  const a = d.trim().split(/\s+/);
97
97
  if (a.length >= 7) {
98
98
  n.push(parseFloat(a[1]), parseFloat(a[2]), parseFloat(a[3]));
99
- let r = parseFloat(a[4]), c = parseFloat(a[5]), p = parseFloat(a[6]);
100
- (r > 1 || c > 1 || p > 1) && (r /= 255, c /= 255, p /= 255), s.push(r, c, p), l = true;
99
+ let r = parseFloat(a[4]), c = parseFloat(a[5]), u = parseFloat(a[6]);
100
+ (r > 1 || c > 1 || u > 1) && (r /= 255, c /= 255, u /= 255), s.push(r, c, u), l = true;
101
101
  } else a.length >= 4 && (n.push(parseFloat(a[1]), parseFloat(a[2]), parseFloat(a[3])), s.push(0, 0, 0));
102
102
  }
103
103
  return l ? {
@@ -107,29 +107,29 @@ let __tla = (async () => {
107
107
  }
108
108
  function Jo(e, o, t, n) {
109
109
  const s = e.getAttribute("position"), l = s.count, d = new Float32Array(l * 3), a = o.length / 3;
110
- let r = 1 / 0, c = 1 / 0, p = 1 / 0, u = -1 / 0, f = -1 / 0, g = -1 / 0;
110
+ let r = 1 / 0, c = 1 / 0, u = 1 / 0, p = -1 / 0, f = -1 / 0, h = -1 / 0;
111
111
  for (let I = 0; I < a; I++) {
112
- const _ = o[I * 3] * n, $ = o[I * 3 + 1] * n, X = o[I * 3 + 2] * n;
113
- _ < r && (r = _), _ > u && (u = _), $ < c && (c = $), $ > f && (f = $), X < p && (p = X), X > g && (g = X);
112
+ const _ = o[I * 3] * n, B = o[I * 3 + 1] * n, X = o[I * 3 + 2] * n;
113
+ _ < r && (r = _), _ > p && (p = _), B < c && (c = B), B > f && (f = B), X < u && (u = X), X > h && (h = X);
114
114
  }
115
- const w = (r + u) * 0.5, h = (c + f) * 0.5, b = (p + g) * 0.5, A = u - r + 1e-6, v = f - c + 1e-6, x = g - p + 1e-6, F = A * 0.5, S = v * 0.5, C = x * 0.5, z = Math.min(128, Math.max(16, Math.round(Math.cbrt(a)))), R = A / z, W = v / z, N = x / z, P = /* @__PURE__ */ new Map();
115
+ const w = (r + p) * 0.5, g = (c + f) * 0.5, b = (u + h) * 0.5, A = p - r + 1e-6, v = f - c + 1e-6, x = h - u + 1e-6, F = A * 0.5, S = v * 0.5, C = x * 0.5, M = Math.min(128, Math.max(16, Math.round(Math.cbrt(a)))), E = A / M, W = v / M, N = x / M, P = /* @__PURE__ */ new Map();
116
116
  for (let I = 0; I < a; I++) {
117
- const _ = o[I * 3] * n - w, $ = o[I * 3 + 1] * n - h, X = o[I * 3 + 2] * n - b, oe = Math.min(z - 1, Math.max(0, Math.floor((_ + F) / R))), ce = Math.min(z - 1, Math.max(0, Math.floor(($ + S) / W))), se = Math.min(z - 1, Math.max(0, Math.floor((X + C) / N))), J = oe * z * z + ce * z + se;
117
+ const _ = o[I * 3] * n - w, B = o[I * 3 + 1] * n - g, X = o[I * 3 + 2] * n - b, oe = Math.min(M - 1, Math.max(0, Math.floor((_ + F) / E))), ce = Math.min(M - 1, Math.max(0, Math.floor((B + S) / W))), se = Math.min(M - 1, Math.max(0, Math.floor((X + C) / N))), J = oe * M * M + ce * M + se;
118
118
  let ae = P.get(J);
119
119
  ae || (ae = [], P.set(J, ae)), ae.push(I);
120
120
  }
121
121
  for (let I = 0; I < l; I++) {
122
- const _ = s.getX(I), $ = s.getY(I), X = s.getZ(I), oe = Math.min(z - 1, Math.max(0, Math.floor((_ + F) / R))), ce = Math.min(z - 1, Math.max(0, Math.floor(($ + S) / W))), se = Math.min(z - 1, Math.max(0, Math.floor((X + C) / N)));
122
+ const _ = s.getX(I), B = s.getY(I), X = s.getZ(I), oe = Math.min(M - 1, Math.max(0, Math.floor((_ + F) / E))), ce = Math.min(M - 1, Math.max(0, Math.floor((B + S) / W))), se = Math.min(M - 1, Math.max(0, Math.floor((X + C) / N)));
123
123
  let J = 1 / 0, ae = 0;
124
- for (let q = 0; q <= z && J > 0; q++) {
125
- for (let ge = -q; ge <= q; ge++) for (let re = -q; re <= q; re++) for (let E = -q; E <= q; E++) {
126
- if (q > 0 && Math.abs(ge) < q && Math.abs(re) < q && Math.abs(E) < q) continue;
127
- const H = oe + ge, ne = ce + re, Q = se + E;
128
- if (H < 0 || H >= z || ne < 0 || ne >= z || Q < 0 || Q >= z) continue;
129
- const j = P.get(H * z * z + ne * z + Q);
130
- if (j) for (const Y of j) {
131
- const ue = o[Y * 3] * n - w, ie = o[Y * 3 + 1] * n - h, pe = o[Y * 3 + 2] * n - b, he = (_ - ue) ** 2 + ($ - ie) ** 2 + (X - pe) ** 2;
132
- he < J && (J = he, ae = Y);
124
+ for (let q = 0; q <= M && J > 0; q++) {
125
+ for (let ge = -q; ge <= q; ge++) for (let re = -q; re <= q; re++) for (let R = -q; R <= q; R++) {
126
+ if (q > 0 && Math.abs(ge) < q && Math.abs(re) < q && Math.abs(R) < q) continue;
127
+ const H = oe + ge, ne = ce + re, Q = se + R;
128
+ if (H < 0 || H >= M || ne < 0 || ne >= M || Q < 0 || Q >= M) continue;
129
+ const j = P.get(H * M * M + ne * M + Q);
130
+ if (j) for (const K of j) {
131
+ const ue = o[K * 3] * n - w, ie = o[K * 3 + 1] * n - g, pe = o[K * 3 + 2] * n - b, he = (_ - ue) ** 2 + (B - ie) ** 2 + (X - pe) ** 2;
132
+ he < J && (J = he, ae = K);
133
133
  }
134
134
  }
135
135
  if (J < 1 / 0) break;
@@ -144,13 +144,13 @@ let __tla = (async () => {
144
144
  warn: 2,
145
145
  error: 3
146
146
  };
147
- let Kn = "warn", Yn = null;
147
+ let Yn = "warn", Kn = null;
148
148
  const xe = {
149
149
  setLevel(e) {
150
- Kn = e;
150
+ Yn = e;
151
151
  },
152
152
  setHandler(e) {
153
- Yn = e;
153
+ Kn = e;
154
154
  },
155
155
  debug(e, o, t) {
156
156
  yt("debug", e, o, t);
@@ -166,7 +166,7 @@ let __tla = (async () => {
166
166
  }
167
167
  };
168
168
  function yt(e, o, t, n) {
169
- if (Ln[e] < Ln[Kn]) return;
169
+ if (Ln[e] < Ln[Yn]) return;
170
170
  const s = `[${o}]`, l = n !== void 0 ? [
171
171
  s,
172
172
  t,
@@ -189,11 +189,11 @@ let __tla = (async () => {
189
189
  console.error(...l);
190
190
  break;
191
191
  }
192
- Yn == null ? void 0 : Yn(e, o, t, n);
192
+ Kn == null ? void 0 : Kn(e, o, t, n);
193
193
  }
194
- const Ut = "[fab-one]";
195
- function $e(e, o) {
196
- console.log(Ut, e);
194
+ const Ct = "[fab-one]";
195
+ function Ee(e, o) {
196
+ console.log(Ct, e);
197
197
  }
198
198
  function Qo() {
199
199
  try {
@@ -210,17 +210,28 @@ let __tla = (async () => {
210
210
  }
211
211
  function er(e) {
212
212
  const o = typeof window < "u" && window.__THREE__ !== void 0 && window.__THREE__ !== U.REVISION;
213
- $e(`widget version: ${Yo}`), $e(`three.js revision: ${U.REVISION}` + (typeof window < "u" ? ` (window.__THREE__=${window.__THREE__ ?? "unset"})` : "")), o && console.error(Ut, `MULTIPLE three.js instances detected. The host app bundles a different three.js revision (${window.__THREE__}) than the widget (${U.REVISION}). This corrupts geometry/BVH and renders broken meshes. Dedupe three.js to a single copy.`), $e(`wasm module: ${e ? "loaded" : "MISSING (JS fallback \u2014 no weld/hole-fill)"}`), e || console.warn(Ut, "WASM module not available. The widget will fall back to the raw OBJ loader, which skips welding and hole-filling and can render low-poly/broken. Check that geo_wasm_bg.wasm is served (correct path + 'application/wasm' MIME, not blocked by CSP).");
213
+ Ee(`widget version: ${Ko}`), Ee(`three.js revision: ${U.REVISION}` + (typeof window < "u" ? ` (window.__THREE__=${window.__THREE__ ?? "unset"})` : "")), o && console.error(Ct, `MULTIPLE three.js instances detected. The host app bundles a different three.js revision (${window.__THREE__}) than the widget (${U.REVISION}). This corrupts geometry/BVH and renders broken meshes. Dedupe three.js to a single copy.`), Ee(`wasm module: ${e ? "loaded" : "MISSING (JS fallback \u2014 no weld/hole-fill)"}`), e || console.warn(Ct, "WASM module not available. The widget will fall back to the raw OBJ loader, which skips welding and hole-filling and can render low-poly/broken. Check that geo_wasm_bg.wasm is served (correct path + 'application/wasm' MIME, not blocked by CSP).");
214
214
  const n = Qo();
215
- if ($e(`webgl: ${n ? `${n.renderer} | ${n.version}` : "UNAVAILABLE"}`), typeof navigator < "u") {
215
+ if (Ee(`webgl: ${n ? `${n.renderer} | ${n.version}` : "UNAVAILABLE"}`), typeof navigator < "u") {
216
216
  const s = navigator;
217
- $e(`browser: ${s.userAgent}`), $e(`device: cores=${s.hardwareConcurrency ?? "?"} memoryGB=${s.deviceMemory ?? "?"} dpr=${typeof window < "u" ? window.devicePixelRatio : "?"}`);
217
+ Ee(`browser: ${s.userAgent}`), Ee(`device: cores=${s.hardwareConcurrency ?? "?"} memoryGB=${s.deviceMemory ?? "?"} dpr=${typeof window < "u" ? window.devicePixelRatio : "?"}`);
218
218
  }
219
219
  }
220
220
  function Dn(e, o, t) {
221
- $e(`mesh @ ${e}: vertices=${o} triangles=${t}`);
221
+ Ee(`mesh @ ${e}: vertices=${o} triangles=${t}`);
222
222
  }
223
- function Ct(e) {
223
+ function tr(e) {
224
+ let o = 1 / 0, t = 1 / 0, n = 1 / 0, s = -1 / 0, l = -1 / 0, d = -1 / 0;
225
+ for (let u = 0; u < e.length; u += 3) {
226
+ const p = e[u], f = e[u + 1], h = e[u + 2];
227
+ p < o && (o = p), p > s && (s = p), f < t && (t = f), f > l && (l = f), h < n && (n = h), h > d && (d = h);
228
+ }
229
+ const a = (u) => u.toFixed(1);
230
+ Ee(`abs bounds: x[${a(o)}, ${a(s)}] y[${a(t)}, ${a(l)}] z[${a(n)}, ${a(d)}]`);
231
+ const r = Math.max(Math.abs(o), Math.abs(s), Math.abs(t), Math.abs(l), Math.abs(n), Math.abs(d)), c = r * Math.pow(2, -23);
232
+ Ee(`origin offset: max|coord|=${a(r)}mm \u2192 float32 resolution \u2248 ${c.toFixed(4)}mm`), c > 0.05 && console.warn(Ct, `Scan is positioned far from origin (max|coord|=${a(r)}mm). float32 resolution there is only ~${c.toFixed(3)}mm, which collapses fine geometry during welding. Re-export the scan centered on the origin to fix this.`);
233
+ }
234
+ function At(e) {
224
235
  const o = e.getAttribute("position"), t = new Float32Array(o.array), n = e.getIndex();
225
236
  if (n) return {
226
237
  positions: t,
@@ -237,7 +248,7 @@ let __tla = (async () => {
237
248
  const t = new U.BufferGeometry();
238
249
  return t.setAttribute("position", new U.Float32BufferAttribute(e, 3)), t.setIndex(new U.BufferAttribute(o, 1)), t.computeVertexNormals(), t;
239
250
  }
240
- async function tr(e, o, t) {
251
+ async function nr(e, o, t) {
241
252
  try {
242
253
  const n = qo(e);
243
254
  t == null ? void 0 : t("Parsing mesh...");
@@ -246,40 +257,40 @@ let __tla = (async () => {
246
257
  if (l.traverse((x) => {
247
258
  x.isMesh && !d && (d = x.geometry);
248
259
  }), !d) return null;
249
- const { positions: a, indices: r } = Ct(d);
250
- if (Dn("pre-wasm (parsed)", a.length / 3, r.length / 3), a.length < 9 || r.length < 3) return xe.warn("wasm", `Mesh too small: positions=${a.length} indices=${r.length}`), null;
260
+ const { positions: a, indices: r } = At(d);
261
+ if (Dn("pre-wasm (parsed)", a.length / 3, r.length / 3), tr(a), a.length < 9 || r.length < 3) return xe.warn("wasm", `Mesh too small: positions=${a.length} indices=${r.length}`), null;
251
262
  for (let x = 0; x < Math.min(a.length, 300); x++) if (!isFinite(a[x])) return xe.error("wasm", `Invalid position data: NaN/Infinity at index ${x}`), null;
252
263
  const c = a.length / 3;
253
264
  for (let x = 0; x < Math.min(r.length, 300); x++) if (r[x] >= c) return xe.error("wasm", `Out-of-bounds index: ${r[x]} >= ${c}`), null;
254
265
  t == null ? void 0 : t("Processing mesh (WASM)...");
255
- const p = o.preprocess_mesh(a, r, 10, 100, 1e-4, 500), u = p.positions(), f = p.indices(), g = p.unit_converted(), w = p.detected_unit(), h = p.log();
256
- xe.debug("wasm", "preprocess result", h);
266
+ const u = o.preprocess_mesh(a, r, 10, 100, 1e-4, 500), p = u.positions(), f = u.indices(), h = u.unit_converted(), w = u.detected_unit(), g = u.log();
267
+ xe.debug("wasm", "preprocess result", g);
257
268
  const b = r.length / 3, A = f.length / 3;
258
- if (Dn("post-wasm (welded)", u.length / 3, A), $e(`wasm preprocess: unit=${w} scaled=${g} | log: ${h}`), b > 0 && A < b * 0.5 && console.warn("[fab-one]", `Triangle count dropped >50% during weld (${b} -> ${A}). Likely unit misdetection or coordinate-precision collapse \u2014 this is what 'low-poly/broken' looks like.`), u.length === 0) return null;
269
+ if (Dn("post-wasm (welded)", p.length / 3, A), Ee(`wasm preprocess: unit=${w} scaled=${h} | log: ${g}`), b > 0 && A < b * 0.5 && console.warn("[fab-one]", `Triangle count dropped >50% during weld (${b} -> ${A}). Likely unit misdetection or coordinate-precision collapse \u2014 this is what 'low-poly/broken' looks like.`), p.length === 0) return null;
259
270
  t == null ? void 0 : t("Building geometry...");
260
- const v = Zn(u, f);
271
+ const v = Zn(p, f);
261
272
  if (n) {
262
273
  const x = w === "meter" ? 1e3 : w === "cm" ? 10 : 1;
263
274
  Jo(v, n.positions, n.colors, x);
264
275
  }
265
276
  return {
266
277
  geometry: v,
267
- wasScaled: g,
268
- unitConverted: g,
278
+ wasScaled: h,
279
+ unitConverted: h,
269
280
  detectedUnit: w
270
281
  };
271
282
  } catch (n) {
272
283
  return xe.error("wasm", "Processing failed", n), null;
273
284
  }
274
285
  }
275
- function nr(e) {
286
+ function or(e) {
276
287
  const t = new Gn().parse(e);
277
288
  let n = null;
278
289
  return t.traverse((s) => {
279
290
  s.isMesh && !n && (n = s.geometry);
280
291
  }), n;
281
292
  }
282
- function or(e) {
293
+ function rr(e) {
283
294
  if (e.byteLength < 84) return false;
284
295
  const t = new DataView(e).getUint32(80, true);
285
296
  return e.byteLength === 84 + t * 50;
@@ -296,15 +307,15 @@ let __tla = (async () => {
296
307
  `);
297
308
  }
298
309
  async function _n(e) {
299
- const o = await e.arrayBuffer(), t = or(o), n = new TextDecoder().decode(o.slice(0, 5)), l = new Xn().parse(o), d = l.getAttribute("position"), a = d ? d.count / 3 : 0;
300
- return $e(`STL parsed: ${(o.byteLength / 1024).toFixed(0)}KB, format=${t ? "binary" : "ascii"}, header="${n}", triangles=${a}`), t && n.toLowerCase() === "solid" && console.warn("[fab-one]", "Binary STL with 'solid' header \u2014 known STLLoader edge case; verify geometry parsed correctly."), qt(l);
310
+ const o = await e.arrayBuffer(), t = rr(o), n = new TextDecoder().decode(o.slice(0, 5)), l = new Xn().parse(o), d = l.getAttribute("position"), a = d ? d.count / 3 : 0;
311
+ return Ee(`STL parsed: ${(o.byteLength / 1024).toFixed(0)}KB, format=${t ? "binary" : "ascii"}, header="${n}", triangles=${a}`), t && n.toLowerCase() === "solid" && console.warn("[fab-one]", "Binary STL with 'solid' header \u2014 known STLLoader edge case; verify geometry parsed correctly."), qt(l);
301
312
  }
302
313
  const Jt = "aop";
303
- async function rr(e) {
314
+ async function ir(e) {
304
315
  const o = await e.arrayBuffer(), t = new Uint8Array(o);
305
- return t.length > 3 && t[0] === 80 && t[1] === 75 && (t[2] === 3 || t[2] === 5 || t[2] === 7) ? ir(t) : (xe.warn(Jt, "AOP payload is not a ZIP container \u2014 sniffing as a bare mesh"), Un(t, e.name));
316
+ return t.length > 3 && t[0] === 80 && t[1] === 75 && (t[2] === 3 || t[2] === 5 || t[2] === 7) ? sr(t) : (xe.warn(Jt, "AOP payload is not a ZIP container \u2014 sniffing as a bare mesh"), Un(t, e.name));
306
317
  }
307
- function ir(e) {
318
+ function sr(e) {
308
319
  let o;
309
320
  try {
310
321
  o = Vo(e);
@@ -335,11 +346,11 @@ let __tla = (async () => {
335
346
  const l = new Xn().parse(s);
336
347
  return qt(l);
337
348
  }
338
- function sr(e, o) {
349
+ function lr(e, o) {
339
350
  const t = 1 / o;
340
351
  return `${Math.round(e.x * t)}_${Math.round(e.y * t)}_${Math.round(e.z * t)}`;
341
352
  }
342
- function lr(e, o) {
353
+ function ar(e, o) {
343
354
  if (!e.length) return [];
344
355
  const t = [];
345
356
  for (const n of e) (t.length === 0 || t[t.length - 1].distanceTo(n) > o) && t.push(n.clone());
@@ -352,55 +363,55 @@ let __tla = (async () => {
352
363
  }
353
364
  function qn(e, o = 1e-3, t = false) {
354
365
  if (!e.length) return [];
355
- const n = /* @__PURE__ */ new Map(), s = (u) => {
356
- const f = sr(u, o);
357
- let g = n.get(f);
358
- return g || (g = u.clone(), n.set(f, g)), g;
359
- }, l = e.map((u) => ({
360
- a: s(u.a),
361
- b: s(u.b)
366
+ const n = /* @__PURE__ */ new Map(), s = (p) => {
367
+ const f = lr(p, o);
368
+ let h = n.get(f);
369
+ return h || (h = p.clone(), n.set(f, h)), h;
370
+ }, l = e.map((p) => ({
371
+ a: s(p.a),
372
+ b: s(p.b)
362
373
  })), d = [];
363
374
  for (; l.length; ) {
364
- const u = l.pop(), f = [
365
- u.a,
366
- u.b
375
+ const p = l.pop(), f = [
376
+ p.a,
377
+ p.b
367
378
  ];
368
- let g = true;
369
- for (; g; ) {
370
- g = false;
371
- for (let h = l.length - 1; h >= 0; h--) {
372
- const { a: b, b: A } = l[h];
379
+ let h = true;
380
+ for (; h; ) {
381
+ h = false;
382
+ for (let g = l.length - 1; g >= 0; g--) {
383
+ const { a: b, b: A } = l[g];
373
384
  if (b.equals(f[f.length - 1])) f.push(A);
374
385
  else if (A.equals(f[f.length - 1])) f.push(b);
375
386
  else if (b.equals(f[0])) f.unshift(A);
376
387
  else if (A.equals(f[0])) f.unshift(b);
377
388
  else continue;
378
- l.splice(h, 1), g = true;
389
+ l.splice(g, 1), h = true;
379
390
  }
380
391
  }
381
- const w = lr(f, o);
392
+ const w = ar(f, o);
382
393
  w.length > 1 && d.push(w);
383
394
  }
384
395
  if (!d.length) return [];
385
396
  if (t) {
386
- d.sort((g, w) => qe(w) - qe(g));
387
- const u = qe(d[0]), f = d.filter((g) => qe(g) >= u * 0.3);
397
+ d.sort((h, w) => qe(w) - qe(h));
398
+ const p = qe(d[0]), f = d.filter((h) => qe(h) >= p * 0.3);
388
399
  return f[f.length - 1] ?? d[0];
389
400
  }
390
- const a = d.filter((u) => u.length >= 3 && u[0].distanceTo(u[u.length - 1]) < o * 10), r = a.length > 0 ? a : d;
401
+ const a = d.filter((p) => p.length >= 3 && p[0].distanceTo(p[p.length - 1]) < o * 10), r = a.length > 0 ? a : d;
391
402
  if (r.length === 1) return r[0];
392
- let c = r[0], p = 1 / 0;
393
- for (const u of r) {
394
- let f = 0, g = 0;
395
- for (const h of u) f += h.x, g += h.z;
396
- f /= u.length, g /= u.length;
397
- const w = Math.sqrt(f * f + g * g);
398
- w < p && (p = w, c = u);
403
+ let c = r[0], u = 1 / 0;
404
+ for (const p of r) {
405
+ let f = 0, h = 0;
406
+ for (const g of p) f += g.x, h += g.z;
407
+ f /= p.length, h /= p.length;
408
+ const w = Math.sqrt(f * f + h * h);
409
+ w < u && (u = w, c = p);
399
410
  }
400
411
  return c;
401
412
  }
402
- function En(e, o, t, n = false) {
403
- const s = new At(new k(0, 1, 0), -t), l = [], d = new Vn();
413
+ function Rn(e, o, t, n = false) {
414
+ const s = new Mt(new k(0, 1, 0), -t), l = [], d = new Vn();
404
415
  d.setFromBufferAttribute(o.getAttribute("position"));
405
416
  const a = {
406
417
  linePoints: [],
@@ -410,63 +421,63 @@ let __tla = (async () => {
410
421
  if (!s.intersectsBox(d)) return a;
411
422
  const r = new jn(), c = new k();
412
423
  e.shapecast({
413
- intersectsBounds: (h) => s.intersectsBox(h),
414
- intersectsTriangle: (h) => {
424
+ intersectsBounds: (g) => s.intersectsBox(g),
425
+ intersectsTriangle: (g) => {
415
426
  const b = [];
416
- r.set(h.a, h.b), s.intersectLine(r, c) && b.push(c.clone()), r.set(h.b, h.c), s.intersectLine(r, c) && b.push(c.clone()), r.set(h.c, h.a), s.intersectLine(r, c) && b.push(c.clone()), b.length === 2 && l.push({
427
+ r.set(g.a, g.b), s.intersectLine(r, c) && b.push(c.clone()), r.set(g.b, g.c), s.intersectLine(r, c) && b.push(c.clone()), r.set(g.c, g.a), s.intersectLine(r, c) && b.push(c.clone()), b.length === 2 && l.push({
417
428
  a: b[0],
418
429
  b: b[1]
419
430
  });
420
431
  }
421
432
  });
422
- const p = qn(l, Zt, n);
423
- if (p.length < 2) return a;
424
- const u = qe(p);
425
- let f = -1 / 0, g = new k(0, t, 0);
426
- for (const h of p) h.x > f && (f = h.x, g = h.clone());
427
- const w = p.length > 2 && p[0].distanceTo(p[p.length - 1]) < Zt * 10;
433
+ const u = qn(l, Ut, n);
434
+ if (u.length < 2) return a;
435
+ const p = qe(u);
436
+ let f = -1 / 0, h = new k(0, t, 0);
437
+ for (const g of u) g.x > f && (f = g.x, h = g.clone());
438
+ const w = u.length > 2 && u[0].distanceTo(u[u.length - 1]) < Ut * 10;
428
439
  return {
429
- linePoints: p,
430
- lineLength: u,
431
- rightmostPoint: g,
440
+ linePoints: u,
441
+ lineLength: p,
442
+ rightmostPoint: h,
432
443
  isClosed: w
433
444
  };
434
445
  }
435
446
  function Ge(e, o, t, n = false) {
436
- const s = En(e, o, t, n);
447
+ const s = Rn(e, o, t, n);
437
448
  if (s.isClosed && s.linePoints.length >= 3) return s;
438
449
  xe.debug("slice", `y=${t.toFixed(2)} failed (pts=${s.linePoints.length}, closed=${s.isClosed}), retrying...`);
439
450
  let l = s;
440
451
  for (const d of Uo) {
441
- const a = En(e, o, t + d, n);
452
+ const a = Rn(e, o, t + d, n);
442
453
  if (a.isClosed && a.linePoints.length >= 3) return xe.debug("slice", `y=${t.toFixed(2)} recovered with offset ${d > 0 ? "+" : ""}${d}mm (pts=${a.linePoints.length}, len=${a.lineLength.toFixed(1)}mm)`), a;
443
454
  a.linePoints.length > l.linePoints.length && (l = a);
444
455
  }
445
456
  return xe.warn("slice", `y=${t.toFixed(2)} all retries exhausted (pts=${l.linePoints.length}, closed=${l.isClosed})`), l;
446
457
  }
447
- function ar(e, o, t, n) {
448
- const s = new At().setFromNormalAndCoplanarPoint(n.clone().normalize(), t), l = new Vn();
458
+ function cr(e, o, t, n) {
459
+ const s = new Mt().setFromNormalAndCoplanarPoint(n.clone().normalize(), t), l = new Vn();
449
460
  if (l.setFromBufferAttribute(o.getAttribute("position")), !s.intersectsBox(l)) return 0;
450
461
  const d = [], a = new jn(), r = new k();
451
462
  e.shapecast({
452
- intersectsBounds: (p) => s.intersectsBox(p),
453
- intersectsTriangle: (p) => {
454
- const u = [];
455
- a.set(p.a, p.b), s.intersectLine(a, r) && u.push(r.clone()), a.set(p.b, p.c), s.intersectLine(a, r) && u.push(r.clone()), a.set(p.c, p.a), s.intersectLine(a, r) && u.push(r.clone()), u.length === 2 && d.push({
456
- a: u[0],
457
- b: u[1]
463
+ intersectsBounds: (u) => s.intersectsBox(u),
464
+ intersectsTriangle: (u) => {
465
+ const p = [];
466
+ a.set(u.a, u.b), s.intersectLine(a, r) && p.push(r.clone()), a.set(u.b, u.c), s.intersectLine(a, r) && p.push(r.clone()), a.set(u.c, u.a), s.intersectLine(a, r) && p.push(r.clone()), p.length === 2 && d.push({
467
+ a: p[0],
468
+ b: p[1]
458
469
  });
459
470
  }
460
471
  });
461
- const c = qn(d, Zt);
472
+ const c = qn(d, Ut);
462
473
  return qe(c);
463
474
  }
464
475
  function Qt(e) {
465
476
  return new zt(e, {
466
- maxLeafTris: Mt
477
+ maxLeafTris: kt
467
478
  });
468
479
  }
469
- function cr(e, o, t, n) {
480
+ function dr(e, o, t, n) {
470
481
  const s = e.getIndex(), l = s ? s.count / 3 : 0;
471
482
  if (l < 10) return {
472
483
  valid: false,
@@ -482,7 +493,7 @@ let __tla = (async () => {
482
493
  reason: `Height too large (${d.toFixed(1)}mm > 1000mm)`
483
494
  };
484
495
  const a = new zt(e, {
485
- maxLeafTris: Mt
496
+ maxLeafTris: kt
486
497
  }), r = Ge(a, e, o);
487
498
  if (r.lineLength === 0) return {
488
499
  valid: false,
@@ -493,22 +504,22 @@ let __tla = (async () => {
493
504
  valid: true,
494
505
  reason: ""
495
506
  };
496
- const p = Ge(a, e, c);
497
- if (r.lineLength > 0 && p.lineLength > 0) {
498
- const f = r.lineLength / p.lineLength;
507
+ const u = Ge(a, e, c);
508
+ if (r.lineLength > 0 && u.lineLength > 0) {
509
+ const f = r.lineLength / u.lineLength;
499
510
  if (f < 0.5) return {
500
511
  valid: false,
501
512
  reason: `First circumference is too small relative to second (ratio ${f.toFixed(2)} < 0.5) \u2014 possible trimmed angle`
502
513
  };
503
514
  }
504
- const u = o - n * 2;
505
- if (u > t) {
506
- const f = Ge(a, e, u);
507
- if (p.lineLength > 0 && f.lineLength > 0) {
508
- const g = p.lineLength / f.lineLength;
509
- if (g < 0.5) return {
515
+ const p = o - n * 2;
516
+ if (p > t) {
517
+ const f = Ge(a, e, p);
518
+ if (u.lineLength > 0 && f.lineLength > 0) {
519
+ const h = u.lineLength / f.lineLength;
520
+ if (h < 0.5) return {
510
521
  valid: false,
511
- reason: `Second circumference is too small relative to third (ratio ${g.toFixed(2)} < 0.5) \u2014 possible trimmed angle`
522
+ reason: `Second circumference is too small relative to third (ratio ${h.toFixed(2)} < 0.5) \u2014 possible trimmed angle`
512
523
  };
513
524
  }
514
525
  }
@@ -518,17 +529,17 @@ let __tla = (async () => {
518
529
  };
519
530
  }
520
531
  const De = "pipeline";
521
- function dr(e, o, t, n) {
532
+ function fr(e, o, t, n) {
522
533
  var _a, _b, _c, _d;
523
534
  const s = e.geometry.clone(), l = o.map((a) => ({
524
535
  ...a
525
536
  })), d = n.wasmModule;
526
537
  try {
527
538
  let a = e.geometry, r = l.map((j) => new k(j.position.x, j.position.y, j.position.z));
528
- const c = r[0], p = r[1];
539
+ const c = r[0], u = r[1];
529
540
  if (!d) {
530
541
  n.onStatus("Aligning mesh (JS fallback)..."), xe.warn(De, "WASM not available, using JS fallback alignment");
531
- const j = new k(0, 1, 0), Y = new k().subVectors(p, c).normalize(), ue = Y.dot(j), ie = new k().crossVectors(Y, j);
542
+ const j = new k(0, 1, 0), K = new k().subVectors(u, c).normalize(), ue = K.dot(j), ie = new k().crossVectors(K, j);
532
543
  if (ie.length() > 1e-4) {
533
544
  ie.normalize();
534
545
  const T = new U.Quaternion().setFromAxisAngle(ie, Math.acos(Math.min(1, Math.max(-1, ue))));
@@ -567,30 +578,30 @@ let __tla = (async () => {
567
578
  a.computeBoundingBox(), a.boundingBox.getSize(Se), n.setModelSize(Math.max(Se.x, Se.y, Se.z)), s.dispose();
568
579
  return;
569
580
  }
570
- const { positions: u, indices: f } = Ct(a), g = new Float32Array([
581
+ const { positions: p, indices: f } = At(a), h = new Float32Array([
571
582
  c.x,
572
583
  c.y,
573
584
  c.z
574
585
  ]), w = new Float32Array([
575
- p.x,
576
- p.y,
577
- p.z
586
+ u.x,
587
+ u.y,
588
+ u.z
578
589
  ]);
579
590
  n.onStatus("Detecting shell type...");
580
- const h = d.detect_shell(u, f, w, 40), b = h.is_double_shell(), A = h.surface_normal();
581
- xe.info(De, `Shell: ${b ? "DOUBLE" : "SINGLE"}`, h.details()), (_a = n.setDoubleShell) == null ? void 0 : _a.call(n, b), n.onStatus("Finding cross-section plane...");
591
+ const g = d.detect_shell(p, f, w, 40), b = g.is_double_shell(), A = g.surface_normal();
592
+ xe.info(De, `Shell: ${b ? "DOUBLE" : "SINGLE"}`, g.details()), (_a = n.setDoubleShell) == null ? void 0 : _a.call(n, b), n.onStatus("Finding cross-section plane...");
582
593
  const v = new Float32Array([
583
594
  A[0],
584
595
  A[1],
585
596
  A[2]
586
- ]), x = d.find_min_cross_section(u, f, w, v, 10), F = x.plane_normal();
597
+ ]), x = d.find_min_cross_section(p, f, w, v, 10), F = x.plane_normal();
587
598
  xe.info(De, "Cross-section found", x.details()), n.onStatus("Aligning mesh...");
588
599
  const S = new Float32Array([
589
600
  F[0],
590
601
  F[1],
591
602
  F[2]
592
- ]), C = d.align_to_origin(u, g, w, S);
593
- let z = C.positions(), R = C.mpt(), W = C.origin();
603
+ ]), C = d.align_to_origin(p, h, w, S);
604
+ let M = C.positions(), E = C.mpt(), W = C.origin();
594
605
  const N = C.transform();
595
606
  xe.info(De, "Alignment complete", C.details());
596
607
  const P = [
@@ -609,33 +620,33 @@ let __tla = (async () => {
609
620
  P[6] * F[0] + P[7] * F[1] + P[8] * F[2]
610
621
  ]);
611
622
  n.onStatus("Generating measurement points...");
612
- const _ = d.subdivide_origin_to_plane(new Float32Array(W), new Float32Array(R), I);
623
+ const _ = d.subdivide_origin_to_plane(new Float32Array(W), new Float32Array(E), I);
613
624
  xe.debug(De, `Subdivide: ${_.count()} pts, spacing=${_.spacing().toFixed(1)}mm`);
614
- const $ = _.points(), X = _.count(), oe = 2, ce = 1, se = [];
615
- for (let j = oe; j < X - ce; j++) se.push($[j * 3 + 1]);
625
+ const B = _.points(), X = _.count(), oe = 2, ce = 1, se = [];
626
+ for (let j = oe; j < X - ce; j++) se.push(B[j * 3 + 1]);
616
627
  n.onStatus("Computing cross-sections...");
617
628
  let J = [];
618
629
  if (se.length >= 2) {
619
- const Y = (b ? d.batch_cross_sections_y_inner.bind(d) : d.batch_cross_sections_y.bind(d))(z, f, new Float32Array(se), 10);
620
- xe.debug(De, "Batch (subdivision)", Y.details());
621
- const ue = Y.all_loop_points(), ie = Y.offsets(), pe = Y.circumferences();
630
+ const K = (b ? d.batch_cross_sections_y_inner.bind(d) : d.batch_cross_sections_y.bind(d))(M, f, new Float32Array(se), 10);
631
+ xe.debug(De, "Batch (subdivision)", K.details());
632
+ const ue = K.all_loop_points(), ie = K.offsets(), pe = K.circumferences();
622
633
  for (let he = 0; he < ie.length - 1; he++) {
623
634
  const Se = ie[he], T = ie[he + 1];
624
635
  if (T <= Se || pe[he] <= 0) continue;
625
636
  const Le = (T - Se) / 3;
626
637
  if (Le < 3) continue;
627
- let Pe = 0, Ie = 0, ye = 0;
628
- for (let Fe = Se; Fe < T; Fe += 3) Pe += ue[Fe], Ie += ue[Fe + 1], ye += ue[Fe + 2];
629
- J.push(Pe / Le, Ie / Le, ye / Le);
638
+ let Pe = 0, We = 0, ye = 0;
639
+ for (let Fe = Se; Fe < T; Fe += 3) Pe += ue[Fe], We += ue[Fe + 1], ye += ue[Fe + 2];
640
+ J.push(Pe / Le, We / Le, ye / Le);
630
641
  }
631
642
  }
632
643
  if (J.length >= 6) {
633
644
  n.onStatus("Refining alignment...");
634
- const j = d.refine_alignment(new Float32Array(J), z, new Float32Array(W), new Float32Array(R));
635
- xe.info(De, "Refinement complete", j.details()), z = j.positions(), R = j.mpt(), W = j.origin();
645
+ const j = d.refine_alignment(new Float32Array(J), M, new Float32Array(W), new Float32Array(E));
646
+ xe.info(De, "Refinement complete", j.details()), M = j.positions(), E = j.mpt(), W = j.origin();
636
647
  }
637
- const ae = a.getAttribute("color"), q = Zn(z, f);
638
- ae && q.setAttribute("color", ae), a.dispose(), a = q, e.geometry = a, a.computeVertexNormals(), a.computeBoundingBox(), r[0] = new k(W[0], W[1], W[2]), r[1] = new k(R[0], R[1], R[2]), n.onStatus("Setting blue point...");
648
+ const ae = a.getAttribute("color"), q = Zn(M, f);
649
+ ae && q.setAttribute("color", ae), a.dispose(), a = q, e.geometry = a, a.computeVertexNormals(), a.computeBoundingBox(), r[0] = new k(W[0], W[1], W[2]), r[1] = new k(E[0], E[1], E[2]), n.onStatus("Setting blue point...");
639
650
  const ge = new k(r[0].x, r[0].y, r[0].z);
640
651
  r.push(ge), n.addLandmarkPoint({
641
652
  faceIndex: -1,
@@ -659,41 +670,41 @@ let __tla = (async () => {
659
670
  y: j.y,
660
671
  z: j.z
661
672
  }))), n.setAligned(true);
662
- const re = a.boundingBox, E = new k();
663
- re.getSize(E), n.setModelSize(Math.max(E.x, E.y, E.z)), n.setCut(true), n.setAdjustedStartY(null), n.setAdjustedEndY(null), n.setOriginalEndY(r[1].y + 2 * St), n.onStatus("Computing final measurements...");
673
+ const re = a.boundingBox, R = new k();
674
+ re.getSize(R), n.setModelSize(Math.max(R.x, R.y, R.z)), n.setCut(true), n.setAdjustedStartY(null), n.setAdjustedEndY(null), n.setOriginalEndY(r[1].y + 2 * St), n.onStatus("Computing final measurements...");
664
675
  {
665
- const j = Ct(a), Y = r[1].y, ue = r[0].y;
676
+ const j = At(a), K = r[1].y, ue = r[0].y;
666
677
  let ie = 1 / 0, pe = -1 / 0;
667
678
  const he = j.positions;
668
679
  for (let ye = 1; ye < he.length; ye += 3) he[ye] < ie && (ie = he[ye]), he[ye] > pe && (pe = he[ye]);
669
680
  const Se = 25.4, T = [];
670
- T.push(Y);
681
+ T.push(K);
671
682
  for (let ye = 1; ye <= 2; ye++) {
672
- const Fe = Y + ye * Se;
683
+ const Fe = K + ye * Se;
673
684
  Fe < pe - 1 && T.push(Fe);
674
685
  }
675
- for (let ye = Y - Se; ye > ue; ye -= Se) T.push(ye);
686
+ for (let ye = K - Se; ye > ue; ye -= Se) T.push(ye);
676
687
  T.sort((ye, Fe) => ye - Fe), xe.info(De, `Horizontal slices: ${T.length} Y planes, range ${(_b = T[0]) == null ? void 0 : _b.toFixed(1)} \u2192 ${(_c = T[T.length - 1]) == null ? void 0 : _c.toFixed(1)} mm`);
677
688
  const Pe = (b ? d.batch_cross_sections_y_inner.bind(d) : d.batch_cross_sections_y.bind(d))(j.positions, j.indices, new Float32Array(T), 10);
678
689
  xe.info(De, `Horizontal slices (${b ? "inner" : "outer"}): ${Pe.count()}/${T.length} valid`), xe.debug(De, "Slice details", Pe.details());
679
- const Ie = {
690
+ const We = {
680
691
  yValues: T,
681
692
  circumferences: Array.from(Pe.circumferences()),
682
693
  allLoopPoints: new Float32Array(Pe.all_loop_points()),
683
694
  offsets: new Uint32Array(Pe.offsets()),
684
- mptY: Y,
695
+ mptY: K,
685
696
  originY: ue
686
697
  };
687
- (_d = n.setWasmSlices) == null ? void 0 : _d.call(n, Ie);
698
+ (_d = n.setWasmSlices) == null ? void 0 : _d.call(n, We);
688
699
  }
689
700
  n.onStatus("Validating results...");
690
- const H = r[1].y, ne = r[0].y, Q = cr(a, H, ne, t);
701
+ const H = r[1].y, ne = r[0].y, Q = dr(a, H, ne, t);
691
702
  Q.valid || xe.warn(De, `Validation: ${Q.reason}`), n.setClippedReferenceGeometry ? (s.computeVertexNormals(), n.setClippedReferenceGeometry(s)) : s.dispose();
692
703
  } catch (a) {
693
704
  xe.error(De, "Processing failed", a), n.setError(a instanceof Error ? a.message : "Failed to process mesh."), s.dispose();
694
705
  }
695
706
  }
696
- class fr extends Bo {
707
+ class ur extends $o {
697
708
  constructor() {
698
709
  super(...arguments), this.state = {
699
710
  error: null
@@ -760,7 +771,7 @@ let __tla = (async () => {
760
771
  }) : this.props.children;
761
772
  }
762
773
  }
763
- const ur = ({ message: e, onDismiss: o }) => y("div", {
774
+ const pr = ({ message: e, onDismiss: o }) => y("div", {
764
775
  style: {
765
776
  position: "absolute",
766
777
  top: 16,
@@ -813,7 +824,7 @@ let __tla = (async () => {
813
824
  children: "x"
814
825
  })
815
826
  ]
816
- }), Rn = ({ message: e }) => y("div", {
827
+ }), En = ({ message: e }) => y("div", {
817
828
  style: {
818
829
  position: "absolute",
819
830
  top: 0,
@@ -851,42 +862,42 @@ let __tla = (async () => {
851
862
  })
852
863
  ]
853
864
  });
854
- function pr(e, o, t, n) {
855
- const s = new k().subVectors(t, o), l = new k().subVectors(n, o), d = new k().subVectors(e, o), a = s.dot(s), r = s.dot(l), c = s.dot(d), p = l.dot(l), u = l.dot(d), f = 1 / (a * p - r * r), g = (p * c - r * u) * f, w = (a * u - r * c) * f;
865
+ function hr(e, o, t, n) {
866
+ const s = new k().subVectors(t, o), l = new k().subVectors(n, o), d = new k().subVectors(e, o), a = s.dot(s), r = s.dot(l), c = s.dot(d), u = l.dot(l), p = l.dot(d), f = 1 / (a * u - r * r), h = (u * c - r * p) * f, w = (a * p - r * c) * f;
856
867
  return {
857
- u: 1 - g - w,
858
- v: g,
868
+ u: 1 - h - w,
869
+ v: h,
859
870
  w
860
871
  };
861
872
  }
862
- const hr = ({ mesh: e, maxPoints: o = 2, meshColor: t = "#c8c8c8", meshOpacity: n = 1, frontFaceOnly: s = false, doubleShellTransparency: l = false }) => {
863
- const { addLandmarkPoint: d, landmarkPoints: a } = en(), r = de((g) => {
873
+ const gr = ({ mesh: e, maxPoints: o = 2, meshColor: t = "#c8c8c8", meshOpacity: n = 1, frontFaceOnly: s = false, doubleShellTransparency: l = false }) => {
874
+ const { addLandmarkPoint: d, landmarkPoints: a } = en(), r = de((h) => {
864
875
  if (a.length >= o) return;
865
- g.stopPropagation();
866
- const w = g.intersections[0], h = w == null ? void 0 : w.faceIndex;
867
- if (!w || h == null) return;
876
+ h.stopPropagation();
877
+ const w = h.intersections[0], g = w == null ? void 0 : w.faceIndex;
878
+ if (!w || g == null) return;
868
879
  const b = e.geometry, A = b.index;
869
880
  let v;
870
881
  A ? v = [
871
- A.getX(h * 3),
872
- A.getX(h * 3 + 1),
873
- A.getX(h * 3 + 2)
882
+ A.getX(g * 3),
883
+ A.getX(g * 3 + 1),
884
+ A.getX(g * 3 + 2)
874
885
  ] : v = [
875
- h * 3,
876
- h * 3 + 1,
877
- h * 3 + 2
886
+ g * 3,
887
+ g * 3 + 1,
888
+ g * 3 + 2
878
889
  ];
879
890
  const x = b.getAttribute("position"), F = new k().fromBufferAttribute(x, v[0]), S = new k().fromBufferAttribute(x, v[1]), C = new k().fromBufferAttribute(x, v[2]);
880
891
  F.applyMatrix4(e.matrixWorld), S.applyMatrix4(e.matrixWorld), C.applyMatrix4(e.matrixWorld);
881
- const z = w.point, R = pr(z, F, S, C), W = {
882
- faceIndex: h,
892
+ const M = w.point, E = hr(M, F, S, C), W = {
893
+ faceIndex: g,
883
894
  vertexIndices: v,
884
895
  position: {
885
- x: z.x,
886
- y: z.y,
887
- z: z.z
896
+ x: M.x,
897
+ y: M.y,
898
+ z: M.z
888
899
  },
889
- barycentricCoords: R
900
+ barycentricCoords: E
890
901
  };
891
902
  d(W);
892
903
  }, [
@@ -896,19 +907,19 @@ let __tla = (async () => {
896
907
  o
897
908
  ]), c = te(() => !!e.geometry.getAttribute("color"), [
898
909
  e
899
- ]), p = l ? Math.min(n, 0.65) : n, u = p < 1, f = te(() => new U.MeshStandardMaterial({
910
+ ]), u = l ? Math.min(n, 0.65) : n, p = u < 1, f = te(() => new U.MeshStandardMaterial({
900
911
  color: c ? "#ffffff" : t,
901
912
  side: s ? U.FrontSide : U.DoubleSide,
902
913
  roughness: 0.6,
903
914
  metalness: 0.1,
904
- transparent: u,
905
- opacity: p,
915
+ transparent: p,
916
+ opacity: u,
906
917
  depthWrite: !l,
907
918
  vertexColors: c
908
919
  }), [
909
920
  t,
910
- p,
911
921
  u,
922
+ p,
912
923
  c,
913
924
  s,
914
925
  l
@@ -919,8 +930,8 @@ let __tla = (async () => {
919
930
  material: f,
920
931
  renderOrder: l ? 0 : void 0
921
932
  });
922
- }, gr = ({ point: e, index: o, markerSize: t, color: n, label: s }) => {
923
- const [l, d] = B(false);
933
+ }, mr = ({ point: e, index: o, markerSize: t, color: n, label: s }) => {
934
+ const [l, d] = $(false);
924
935
  return y("mesh", {
925
936
  position: [
926
937
  e.position.x,
@@ -961,7 +972,7 @@ let __tla = (async () => {
961
972
  })
962
973
  ]
963
974
  }, o);
964
- }, mr = ({ modelSize: e, labels: o }) => {
975
+ }, xr = ({ modelSize: e, labels: o }) => {
965
976
  const { landmarkPoints: t } = en(), n = e * 0.02, s = [
966
977
  "#44ff44",
967
978
  "#ff4444",
@@ -972,7 +983,7 @@ let __tla = (async () => {
972
983
  "Cut Plane"
973
984
  ];
974
985
  return i(_e, {
975
- children: t.map((a, r) => i(gr, {
986
+ children: t.map((a, r) => i(mr, {
976
987
  point: a,
977
988
  index: r,
978
989
  markerSize: n,
@@ -983,7 +994,7 @@ let __tla = (async () => {
983
994
  };
984
995
  function Jn(e) {
985
996
  return te(() => e ? new zt(e, {
986
- maxLeafTris: Mt
997
+ maxLeafTris: kt
987
998
  }) : null, [
988
999
  e
989
1000
  ]);
@@ -991,21 +1002,21 @@ let __tla = (async () => {
991
1002
  const In = (e, o) => {
992
1003
  const t = Math.abs(e - o);
993
1004
  return t <= 7 ? "#8BC34A" : t <= 20 ? "#FFC107" : "#FF5722";
994
- }, Wn = new U.Color("#8BC34A"), Bn = new U.Color("#FFC107"), xr = new U.Color("#FF5722"), br = (e) => {
1005
+ }, Wn = new U.Color("#8BC34A"), $n = new U.Color("#FFC107"), br = new U.Color("#FF5722"), yr = (e) => {
995
1006
  if (e <= 7) return Wn.clone();
996
1007
  if (e <= 20) {
997
1008
  const t = (e - 7) / 13;
998
- return Wn.clone().lerp(Bn, t);
1009
+ return Wn.clone().lerp($n, t);
999
1010
  }
1000
1011
  const o = Math.min((e - 20) / 20, 1);
1001
- return Bn.clone().lerp(xr, o);
1002
- }, yr = (e, o) => {
1012
+ return $n.clone().lerp(br, o);
1013
+ }, wr = (e, o) => {
1003
1014
  const t = e.length, n = new Float32Array(t * 2 * 3), s = new Float32Array(t * 2 * 3), l = [];
1004
1015
  for (let r = 0; r < t; r++) {
1005
- const c = e[r], p = o[r], u = c.distanceTo(p), f = br(u);
1006
- if (n[r * 6] = c.x, n[r * 6 + 1] = c.y, n[r * 6 + 2] = c.z, s[r * 6] = f.r, s[r * 6 + 1] = f.g, s[r * 6 + 2] = f.b, n[r * 6 + 3] = p.x, n[r * 6 + 4] = p.y, n[r * 6 + 5] = p.z, s[r * 6 + 3] = f.r, s[r * 6 + 4] = f.g, s[r * 6 + 5] = f.b, r < t - 1) {
1007
- const g = r * 2, w = g + 1, h = (r + 1) * 2, b = h + 1;
1008
- l.push(g, w, h, w, b, h);
1016
+ const c = e[r], u = o[r], p = c.distanceTo(u), f = yr(p);
1017
+ if (n[r * 6] = c.x, n[r * 6 + 1] = c.y, n[r * 6 + 2] = c.z, s[r * 6] = f.r, s[r * 6 + 1] = f.g, s[r * 6 + 2] = f.b, n[r * 6 + 3] = u.x, n[r * 6 + 4] = u.y, n[r * 6 + 5] = u.z, s[r * 6 + 3] = f.r, s[r * 6 + 4] = f.g, s[r * 6 + 5] = f.b, r < t - 1) {
1018
+ const h = r * 2, w = h + 1, g = (r + 1) * 2, b = g + 1;
1019
+ l.push(h, w, g, w, b, g);
1009
1020
  }
1010
1021
  }
1011
1022
  const d = new U.BufferGeometry();
@@ -1019,25 +1030,25 @@ let __tla = (async () => {
1019
1030
  depthWrite: false
1020
1031
  });
1021
1032
  return new U.Mesh(d, a);
1022
- }, wr = ({ bvh: e, geometry: o, yPosition: t, color: n = "#00ff00", labelX: s, onDataChange: l, displayUnit: d = "cm", useInnerSurface: a = false, formValue: r, lineWidth: c = 1.5, wasmLoopPoints: p, wasmCircumference: u }) => {
1023
- const f = te(() => p && u != null ? null : Ge(e, o, t, a), [
1033
+ }, vr = ({ bvh: e, geometry: o, yPosition: t, color: n = "#00ff00", labelX: s, onDataChange: l, displayUnit: d = "cm", useInnerSurface: a = false, formValue: r, lineWidth: c = 1.5, wasmLoopPoints: u, wasmCircumference: p }) => {
1034
+ const f = te(() => u && p != null ? null : Ge(e, o, t, a), [
1024
1035
  e,
1025
1036
  o,
1026
1037
  t,
1027
1038
  a,
1028
- p,
1029
- u
1030
- ]), g = p ?? (f == null ? void 0 : f.linePoints) ?? [], w = u ?? (f == null ? void 0 : f.lineLength) ?? 0, h = te(() => {
1031
- if (r == null || r === 0 || w <= 0 || g.length < 2) return null;
1032
- const x = r / w, F = g.reduce((C, z) => C + z.x, 0) / g.length, S = g.reduce((C, z) => C + z.z, 0) / g.length;
1033
- return g.map((C) => new k(F + (C.x - F) * x, C.y, S + (C.z - S) * x));
1039
+ u,
1040
+ p
1041
+ ]), h = u ?? (f == null ? void 0 : f.linePoints) ?? [], w = p ?? (f == null ? void 0 : f.lineLength) ?? 0, g = te(() => {
1042
+ if (r == null || r === 0 || w <= 0 || h.length < 2) return null;
1043
+ const x = r / w, F = h.reduce((C, M) => C + M.x, 0) / h.length, S = h.reduce((C, M) => C + M.z, 0) / h.length;
1044
+ return h.map((C) => new k(F + (C.x - F) * x, C.y, S + (C.z - S) * x));
1034
1045
  }, [
1035
- g,
1046
+ h,
1036
1047
  w,
1037
1048
  r
1038
- ]), b = te(() => !h || g.length < 2 ? null : yr(g, h), [
1039
- g,
1040
- h
1049
+ ]), b = te(() => !g || h.length < 2 ? null : wr(h, g), [
1050
+ h,
1051
+ g
1041
1052
  ]);
1042
1053
  Z(() => () => {
1043
1054
  b && (b.geometry.dispose(), b.material.dispose());
@@ -1070,27 +1081,27 @@ let __tla = (async () => {
1070
1081
  t,
1071
1082
  l
1072
1083
  ]), On(({ camera: x }) => {
1073
- if (!A.current || g.length < 2) return;
1084
+ if (!A.current || h.length < 2) return;
1074
1085
  const F = new k();
1075
1086
  x.getWorldDirection(F);
1076
1087
  const S = new k(F.x, 0, F.z);
1077
1088
  if (S.lengthSq() < 1e-8) return;
1078
1089
  S.normalize();
1079
1090
  const C = new k().crossVectors(S, new k(0, 1, 0)).normalize();
1080
- let z = -1 / 0, R = g[0];
1081
- for (const I of g) {
1091
+ let M = -1 / 0, E = h[0];
1092
+ for (const I of h) {
1082
1093
  const _ = C.x * I.x + C.z * I.z;
1083
- _ > z && (z = _, R = I);
1094
+ _ > M && (M = _, E = I);
1084
1095
  }
1085
- const W = s * 0.35, N = new k(R.x + C.x * W, t, R.z + C.z * W);
1096
+ const W = s * 0.35, N = new k(E.x + C.x * W, t, E.z + C.z * W);
1086
1097
  A.current.position.copy(N);
1087
1098
  const P = v.geometry.getAttribute("position");
1088
- P.setXYZ(0, R.x, R.y, R.z), P.setXYZ(1, N.x, N.y, N.z), P.needsUpdate = true;
1089
- }), g.length < 2 ? null : y("group", {
1099
+ P.setXYZ(0, E.x, E.y, E.z), P.setXYZ(1, N.x, N.y, N.z), P.needsUpdate = true;
1100
+ }), h.length < 2 ? null : y("group", {
1090
1101
  renderOrder: 10,
1091
1102
  children: [
1092
1103
  i(ve, {
1093
- points: g,
1104
+ points: h,
1094
1105
  color: n,
1095
1106
  lineWidth: c,
1096
1107
  depthTest: false,
@@ -1102,8 +1113,8 @@ let __tla = (async () => {
1102
1113
  object: b,
1103
1114
  renderOrder: 10
1104
1115
  }),
1105
- h && r != null && r !== 0 && i(ve, {
1106
- points: h,
1116
+ g && r != null && r !== 0 && i(ve, {
1117
+ points: g,
1107
1118
  color: In(w, r),
1108
1119
  lineWidth: 2.5,
1109
1120
  dashed: true,
@@ -1223,20 +1234,20 @@ let __tla = (async () => {
1223
1234
  })
1224
1235
  ]
1225
1236
  });
1226
- }, vr = $o(wr), Sr = ({ mesh: e, startY: o, endY: t, spacing: n, modelSize: s, onMeasurementsChange: l, reverseOrder: d = false, displayUnit: a = "cm", useInnerSurface: r = false, formMeasurements: c, originY: p, wasmSlices: u }) => {
1227
- const f = fe(/* @__PURE__ */ new Map()), g = e.geometry, w = Jn(g), h = te(() => {
1228
- if (u) {
1229
- let z = [
1230
- ...u.yValues
1237
+ }, Sr = Bo(vr), Cr = ({ mesh: e, startY: o, endY: t, spacing: n, modelSize: s, onMeasurementsChange: l, reverseOrder: d = false, displayUnit: a = "cm", useInnerSurface: r = false, formMeasurements: c, originY: u, wasmSlices: p }) => {
1238
+ const f = fe(/* @__PURE__ */ new Map()), h = e.geometry, w = Jn(h), g = te(() => {
1239
+ if (p) {
1240
+ let M = [
1241
+ ...p.yValues
1231
1242
  ];
1232
1243
  if (n > 25.4 + 0.1) {
1233
- const R = u.mptY;
1234
- z = z.filter((W) => {
1235
- const N = Math.abs(W - R);
1244
+ const E = p.mptY;
1245
+ M = M.filter((W) => {
1246
+ const N = Math.abs(W - E);
1236
1247
  return N < 0.5 || Math.abs(Math.round(N / n) * n - N) < 0.5;
1237
1248
  });
1238
1249
  }
1239
- return d ? z.sort((R, W) => W - R) : z.sort((R, W) => R - W), z;
1250
+ return d ? M.sort((E, W) => W - E) : M.sort((E, W) => E - W), M;
1240
1251
  }
1241
1252
  const S = [];
1242
1253
  if (d) for (let C = t; C >= o; C -= n) S.push(C);
@@ -1247,35 +1258,35 @@ let __tla = (async () => {
1247
1258
  t,
1248
1259
  n,
1249
1260
  d,
1250
- u
1261
+ p
1251
1262
  ]), b = te(() => {
1252
- if (!u) return null;
1253
- const S = /* @__PURE__ */ new Map(), { allLoopPoints: C, offsets: z, yValues: R } = u;
1254
- for (let W = 0; W < z.length - 1; W++) {
1255
- const N = z[W], P = z[W + 1];
1263
+ if (!p) return null;
1264
+ const S = /* @__PURE__ */ new Map(), { allLoopPoints: C, offsets: M, yValues: E } = p;
1265
+ for (let W = 0; W < M.length - 1; W++) {
1266
+ const N = M[W], P = M[W + 1];
1256
1267
  if (P <= N) continue;
1257
1268
  const I = [];
1258
1269
  for (let _ = N; _ < P; _ += 3) I.push(new k(C[_], C[_ + 1], C[_ + 2]));
1259
- I.length >= 3 && S.set(R[W], I);
1270
+ I.length >= 3 && S.set(E[W], I);
1260
1271
  }
1261
1272
  return S;
1262
1273
  }, [
1263
- u
1274
+ p
1264
1275
  ]), A = te(() => {
1265
- if (!u) return null;
1276
+ if (!p) return null;
1266
1277
  const S = /* @__PURE__ */ new Map();
1267
- for (let C = 0; C < u.yValues.length; C++) S.set(u.yValues[C], u.circumferences[C]);
1278
+ for (let C = 0; C < p.yValues.length; C++) S.set(p.yValues[C], p.circumferences[C]);
1268
1279
  return S;
1269
1280
  }, [
1270
- u
1281
+ p
1271
1282
  ]);
1272
1283
  Z(() => {
1273
1284
  f.current.clear();
1274
1285
  }, [
1275
- h
1286
+ g
1276
1287
  ]), Z(() => {
1277
1288
  if (!A || !l) return;
1278
- const S = h.filter((C) => (A.get(C) ?? 0) > 0).map((C) => ({
1289
+ const S = g.filter((C) => (A.get(C) ?? 0) > 0).map((C) => ({
1279
1290
  yPosition: C,
1280
1291
  originalValue: A.get(C) ?? 0,
1281
1292
  modifiedValue: null
@@ -1283,7 +1294,7 @@ let __tla = (async () => {
1283
1294
  l(S);
1284
1295
  }, [
1285
1296
  A,
1286
- h,
1297
+ g,
1287
1298
  l
1288
1299
  ]);
1289
1300
  const v = [
@@ -1291,7 +1302,7 @@ let __tla = (async () => {
1291
1302
  ], x = s * Zo, F = de((S) => {
1292
1303
  if (A) return;
1293
1304
  f.current.set(S.yPosition, S);
1294
- const C = Array.from(f.current.values()).sort((z, R) => d ? R.yPosition - z.yPosition : z.yPosition - R.yPosition);
1305
+ const C = Array.from(f.current.values()).sort((M, E) => d ? E.yPosition - M.yPosition : M.yPosition - E.yPosition);
1295
1306
  l == null ? void 0 : l(C);
1296
1307
  }, [
1297
1308
  l,
@@ -1299,56 +1310,56 @@ let __tla = (async () => {
1299
1310
  A
1300
1311
  ]);
1301
1312
  return w ? i(_e, {
1302
- children: h.map((S, C) => i(vr, {
1313
+ children: g.map((S, C) => i(Sr, {
1303
1314
  bvh: w,
1304
- geometry: g,
1315
+ geometry: h,
1305
1316
  yPosition: S,
1306
- color: p != null && Math.abs(S - p) < n * 0.5 ? "#44ff44" : v[C % v.length],
1317
+ color: u != null && Math.abs(S - u) < n * 0.5 ? "#44ff44" : v[C % v.length],
1307
1318
  labelX: x,
1308
1319
  onDataChange: F,
1309
1320
  displayUnit: a,
1310
1321
  useInnerSurface: r,
1311
1322
  formValue: c == null ? void 0 : c[C],
1312
- lineWidth: p != null && Math.abs(S - p) < n * 0.5 ? 4 : 1.5,
1323
+ lineWidth: u != null && Math.abs(S - u) < n * 0.5 ? 4 : 1.5,
1313
1324
  wasmLoopPoints: b == null ? void 0 : b.get(S),
1314
1325
  wasmCircumference: A == null ? void 0 : A.get(S)
1315
1326
  }, S))
1316
1327
  }) : null;
1317
- }, Cr = (e, o) => {
1328
+ }, Ar = (e, o) => {
1318
1329
  const t = Math.abs(e - o);
1319
1330
  return t <= 7 ? "#4caf50" : t <= 15 ? "#ff9800" : "#f44336";
1320
- }, Ar = ({ mesh: e, greenY: o, modelSize: t, displayUnit: n = "cm", bottomY: s, formHeight: l }) => {
1331
+ }, Mr = ({ mesh: e, greenY: o, modelSize: t, displayUnit: n = "cm", bottomY: s, formHeight: l }) => {
1321
1332
  var _a;
1322
1333
  const d = e.geometry;
1323
1334
  d.computeBoundingBox();
1324
- const a = s ?? ((_a = d.boundingBox) == null ? void 0 : _a.min.y) ?? 0, r = o - a, c = t * 0.4, p = t * 0.03, u = fe(null);
1335
+ const a = s ?? ((_a = d.boundingBox) == null ? void 0 : _a.min.y) ?? 0, r = o - a, c = t * 0.4, u = t * 0.03, p = fe(null);
1325
1336
  On(({ camera: C }) => {
1326
- if (!u.current) return;
1327
- const z = new k();
1328
- C.getWorldDirection(z);
1329
- const R = new k(z.x, 0, z.z);
1330
- if (R.lengthSq() < 1e-8) return;
1331
- R.normalize();
1332
- const W = new k().crossVectors(new k(0, 1, 0), R).normalize();
1333
- u.current.position.set(W.x * c, 0, W.z * c);
1334
- const N = C.position.x - u.current.position.x, P = C.position.z - u.current.position.z;
1335
- u.current.rotation.y = Math.atan2(N, P);
1337
+ if (!p.current) return;
1338
+ const M = new k();
1339
+ C.getWorldDirection(M);
1340
+ const E = new k(M.x, 0, M.z);
1341
+ if (E.lengthSq() < 1e-8) return;
1342
+ E.normalize();
1343
+ const W = new k().crossVectors(new k(0, 1, 0), E).normalize();
1344
+ p.current.position.set(W.x * c, 0, W.z * c);
1345
+ const N = C.position.x - p.current.position.x, P = C.position.z - p.current.position.z;
1346
+ p.current.rotation.y = Math.atan2(N, P);
1336
1347
  });
1337
- const f = new k(0, o, 0), g = new k(0, a, 0), w = new k(0, (o + a) / 2, 0), h = new k(-p, o, 0), b = new k(p, o, 0), A = new k(-p, a, 0), v = new k(p, a, 0), x = l != null && l > 0, F = x ? r - l : 0, S = x ? Cr(r, l) : "#fff";
1348
+ const f = new k(0, o, 0), h = new k(0, a, 0), w = new k(0, (o + a) / 2, 0), g = new k(-u, o, 0), b = new k(u, o, 0), A = new k(-u, a, 0), v = new k(u, a, 0), x = l != null && l > 0, F = x ? r - l : 0, S = x ? Ar(r, l) : "#fff";
1338
1349
  return y("group", {
1339
- ref: u,
1350
+ ref: p,
1340
1351
  children: [
1341
1352
  i(ve, {
1342
1353
  points: [
1343
1354
  f,
1344
- g
1355
+ h
1345
1356
  ],
1346
1357
  color: "#888888",
1347
1358
  lineWidth: 1.5
1348
1359
  }),
1349
1360
  i(ve, {
1350
1361
  points: [
1351
- h,
1362
+ g,
1352
1363
  b
1353
1364
  ],
1354
1365
  color: "#888888",
@@ -1453,36 +1464,36 @@ let __tla = (async () => {
1453
1464
  })
1454
1465
  ]
1455
1466
  });
1456
- }, zr = ({ modelSize: e, isAligned: o, isCut: t, mesh: n, viewMode: s, sliceY: l, landmarkCount: d = 0, measurementGeometry: a, fitYMin: r, fitYMax: c, resetCameraToFrontRef: p }) => {
1457
- const { set: u, size: f, camera: g, invalidate: w } = Hn(), h = fe(false), b = fe(s), A = fe(new k()), v = fe(null), x = fe(d), F = fe(o), S = fe(t), C = fe(a), z = fe({
1467
+ }, zr = ({ modelSize: e, isAligned: o, isCut: t, mesh: n, viewMode: s, sliceY: l, landmarkCount: d = 0, measurementGeometry: a, fitYMin: r, fitYMax: c, resetCameraToFrontRef: u }) => {
1468
+ const { set: p, size: f, camera: h, invalidate: w } = Hn(), g = fe(false), b = fe(s), A = fe(new k()), v = fe(null), x = fe(d), F = fe(o), S = fe(t), C = fe(a), M = fe({
1458
1469
  min: r,
1459
1470
  max: c
1460
- }), R = fe(0), W = de(() => {
1471
+ }), E = fe(0), W = de(() => {
1461
1472
  if (!n || e <= 0) return null;
1462
1473
  const P = a ?? n.geometry;
1463
1474
  P.computeBoundingBox();
1464
1475
  const I = P.boundingBox, _ = new k();
1465
1476
  I.getCenter(_);
1466
- const $ = new k();
1467
- I.getSize($);
1477
+ const B = new k();
1478
+ I.getSize(B);
1468
1479
  const X = r != null && c != null && c > r;
1469
1480
  if (X) {
1470
- const re = r, E = c, H = P.getAttribute("position");
1481
+ const re = r, R = c, H = P.getAttribute("position");
1471
1482
  if (H) {
1472
- const ne = H.array, Q = (E - re) * 0.08;
1473
- let j = 1 / 0, Y = -1 / 0, ue = re - Q, ie = E + Q, pe = false;
1483
+ const ne = H.array, Q = (R - re) * 0.08;
1484
+ let j = 1 / 0, K = -1 / 0, ue = re - Q, ie = R + Q, pe = false;
1474
1485
  for (let he = 0; he < H.count; he++) {
1475
1486
  const Se = ne[he * 3 + 1];
1476
- if (Se < re - Q || Se > E + Q) continue;
1487
+ if (Se < re - Q || Se > R + Q) continue;
1477
1488
  const T = ne[he * 3];
1478
- T < j && (j = T), T > Y && (Y = T), pe = true;
1489
+ T < j && (j = T), T > K && (K = T), pe = true;
1479
1490
  }
1480
- pe && (_.set((j + Y) / 2, (ue + ie) / 2, 0), $.set(Y - j, ie - ue, 0));
1491
+ pe && (_.set((j + K) / 2, (ue + ie) / 2, 0), B.set(K - j, ie - ue, 0));
1481
1492
  }
1482
1493
  }
1483
- A.current.copy($);
1484
- const oe = f.width / f.height, ce = 1.35, se = X ? 1.15 : 1.6, J = Math.max($.y * se, $.x * ce / oe), ae = J * oe, q = _.y - $.y * 0.05;
1485
- R.current = q;
1494
+ A.current.copy(B);
1495
+ const oe = f.width / f.height, ce = 1.35, se = X ? 1.15 : 1.6, J = Math.max(B.y * se, B.x * ce / oe), ae = J * oe, q = _.y - B.y * 0.05;
1496
+ E.current = q;
1486
1497
  const ge = new U.OrthographicCamera(-ae / 2, ae / 2, J / 2, -J / 2, 0.1, e * 10);
1487
1498
  return ge.position.set(0, q, e * 2), ge.lookAt(0, q, 0), ge;
1488
1499
  }, [
@@ -1494,56 +1505,56 @@ let __tla = (async () => {
1494
1505
  c
1495
1506
  ]);
1496
1507
  Z(() => {
1497
- if (p) return p.current = () => {
1508
+ if (u) return u.current = () => {
1498
1509
  const P = W();
1499
- P && (u({
1510
+ P && (p({
1500
1511
  camera: P
1501
1512
  }), w());
1502
1513
  }, () => {
1503
- p && (p.current = null);
1514
+ u && (u.current = null);
1504
1515
  };
1505
1516
  }, [
1506
- p,
1507
- W,
1508
1517
  u,
1518
+ W,
1519
+ p,
1509
1520
  w
1510
1521
  ]);
1511
1522
  const N = de((P) => {
1512
- const I = P.position.clone(), _ = I.length(), $ = Math.atan2(I.x, I.z), X = Math.acos(I.y / _), ce = $ + 0.02;
1523
+ const I = P.position.clone(), _ = I.length(), B = Math.atan2(I.x, I.z), X = Math.acos(I.y / _), ce = B + 0.02;
1513
1524
  P.position.set(_ * Math.sin(X) * Math.sin(ce), _ * Math.cos(X), _ * Math.sin(X) * Math.cos(ce)), P.lookAt(0, 0, 0), P.updateMatrixWorld(true), w();
1514
1525
  }, [
1515
1526
  w
1516
1527
  ]);
1517
1528
  return Z(() => {
1518
- if (e > 0 && !h.current && !o) {
1519
- h.current = true;
1529
+ if (e > 0 && !g.current && !o) {
1530
+ g.current = true;
1520
1531
  const P = new U.PerspectiveCamera(50, f.width / f.height, 0.1, e * 10);
1521
- P.position.set(e * 0.3, e * 0.2, e * 1.5), P.lookAt(0, 0, 0), u({
1532
+ P.position.set(e * 0.3, e * 0.2, e * 1.5), P.lookAt(0, 0, 0), p({
1522
1533
  camera: P
1523
1534
  }), requestAnimationFrame(() => N(P));
1524
1535
  }
1525
1536
  }, [
1526
1537
  e,
1527
1538
  f,
1528
- u,
1539
+ p,
1529
1540
  o,
1530
1541
  N
1531
1542
  ]), Z(() => {
1532
1543
  const P = x.current;
1533
- x.current = d, P === 0 && d === 1 && !o && requestAnimationFrame(() => N(g));
1544
+ x.current = d, P === 0 && d === 1 && !o && requestAnimationFrame(() => N(h));
1534
1545
  }, [
1535
1546
  d,
1536
1547
  o,
1537
- g,
1548
+ h,
1538
1549
  N
1539
1550
  ]), Z(() => {
1540
- const P = F.current !== o, I = S.current !== t, _ = !C.current && !!a, $ = (z.current.min == null || z.current.max == null) && r != null && c != null;
1541
- if (F.current = o, S.current = t, C.current = a, z.current = {
1551
+ const P = F.current !== o, I = S.current !== t, _ = !C.current && !!a, B = (M.current.min == null || M.current.max == null) && r != null && c != null;
1552
+ if (F.current = o, S.current = t, C.current = a, M.current = {
1542
1553
  min: r,
1543
1554
  max: c
1544
- }, !P && !I && !_ && !$ || !o || s !== "3D") return;
1555
+ }, !P && !I && !_ && !B || !o || s !== "3D") return;
1545
1556
  const X = W();
1546
- X && u({
1557
+ X && p({
1547
1558
  camera: X
1548
1559
  });
1549
1560
  }, [
@@ -1554,17 +1565,17 @@ let __tla = (async () => {
1554
1565
  r,
1555
1566
  c,
1556
1567
  W,
1557
- u
1568
+ p
1558
1569
  ]), Z(() => {
1559
1570
  if (b.current === s) return;
1560
1571
  const P = b.current;
1561
1572
  if (b.current = s, !(!o || !n || e <= 0)) {
1562
1573
  if (s === "2D" && l != null) {
1563
- v.current = g;
1564
- const I = n.geometry, _ = I.getAttribute("position"), $ = _.array, X = e * 0.15;
1574
+ v.current = h;
1575
+ const I = n.geometry, _ = I.getAttribute("position"), B = _.array, X = e * 0.15;
1565
1576
  let oe = 1 / 0, ce = -1 / 0, se = 1 / 0, J = -1 / 0, ae = false;
1566
- for (let ue = 0; ue < _.count; ue++) if (Math.abs($[ue * 3 + 1] - l) < X) {
1567
- const ie = $[ue * 3], pe = $[ue * 3 + 2];
1577
+ for (let ue = 0; ue < _.count; ue++) if (Math.abs(B[ue * 3 + 1] - l) < X) {
1578
+ const ie = B[ue * 3], pe = B[ue * 3 + 2];
1568
1579
  ie < oe && (oe = ie), ie > ce && (ce = ie), pe < se && (se = pe), pe > J && (J = pe), ae = true;
1569
1580
  }
1570
1581
  if (!ae) {
@@ -1572,19 +1583,19 @@ let __tla = (async () => {
1572
1583
  const ue = I.boundingBox;
1573
1584
  oe = ue.min.x, ce = ue.max.x, se = ue.min.z, J = ue.max.z;
1574
1585
  }
1575
- const q = (oe + ce) / 2, ge = (se + J) / 2, re = f.width / f.height, E = 1.4, H = (ce - oe) * E, ne = (J - se) * E;
1586
+ const q = (oe + ce) / 2, ge = (se + J) / 2, re = f.width / f.height, R = 1.4, H = (ce - oe) * R, ne = (J - se) * R;
1576
1587
  let Q, j;
1577
1588
  H / ne > re ? (Q = H, j = H / re) : (j = ne, Q = ne * re);
1578
- const Y = new U.OrthographicCamera(-Q / 2, Q / 2, j / 2, -j / 2, 0.1, e * 10);
1579
- Y.position.set(q, l + e * 2, ge), Y.up.set(0, 0, -1), Y.lookAt(q, l, ge), u({
1580
- camera: Y
1589
+ const K = new U.OrthographicCamera(-Q / 2, Q / 2, j / 2, -j / 2, 0.1, e * 10);
1590
+ K.position.set(q, l + e * 2, ge), K.up.set(0, 0, -1), K.lookAt(q, l, ge), p({
1591
+ camera: K
1581
1592
  });
1582
- } else if (P === "2D") if (v.current) u({
1593
+ } else if (P === "2D") if (v.current) p({
1583
1594
  camera: v.current
1584
1595
  }), v.current = null;
1585
1596
  else {
1586
1597
  const I = W();
1587
- I && u({
1598
+ I && p({
1588
1599
  camera: I
1589
1600
  });
1590
1601
  }
@@ -1596,42 +1607,42 @@ let __tla = (async () => {
1596
1607
  n,
1597
1608
  e,
1598
1609
  f,
1599
- u,
1600
- g,
1610
+ p,
1611
+ h,
1601
1612
  W
1602
1613
  ]), Z(() => {
1603
- if (!o || !g || !g.isOrthographicCamera) return;
1604
- const P = g;
1614
+ if (!o || !h || !h.isOrthographicCamera) return;
1615
+ const P = h;
1605
1616
  if (s === "2D") {
1606
1617
  if (!n || l == null) return;
1607
- const I = n.geometry, _ = I.getAttribute("position"), $ = _.array, X = e * 0.15;
1618
+ const I = n.geometry, _ = I.getAttribute("position"), B = _.array, X = e * 0.15;
1608
1619
  let oe = 1 / 0, ce = -1 / 0, se = 1 / 0, J = -1 / 0, ae = false;
1609
- for (let Q = 0; Q < _.count; Q++) if (Math.abs($[Q * 3 + 1] - l) < X) {
1610
- const j = $[Q * 3], Y = $[Q * 3 + 2];
1611
- j < oe && (oe = j), j > ce && (ce = j), Y < se && (se = Y), Y > J && (J = Y), ae = true;
1620
+ for (let Q = 0; Q < _.count; Q++) if (Math.abs(B[Q * 3 + 1] - l) < X) {
1621
+ const j = B[Q * 3], K = B[Q * 3 + 2];
1622
+ j < oe && (oe = j), j > ce && (ce = j), K < se && (se = K), K > J && (J = K), ae = true;
1612
1623
  }
1613
1624
  if (!ae) {
1614
1625
  I.computeBoundingBox();
1615
1626
  const Q = I.boundingBox;
1616
1627
  oe = Q.min.x, ce = Q.max.x, se = Q.min.z, J = Q.max.z;
1617
1628
  }
1618
- const q = f.width / f.height, ge = 1.4, re = (ce - oe) * ge, E = (J - se) * ge;
1629
+ const q = f.width / f.height, ge = 1.4, re = (ce - oe) * ge, R = (J - se) * ge;
1619
1630
  let H, ne;
1620
- re / E > q ? (H = re, ne = re / q) : (ne = E, H = E * q), P.left = -H / 2, P.right = H / 2, P.top = ne / 2, P.bottom = -ne / 2;
1631
+ re / R > q ? (H = re, ne = re / q) : (ne = R, H = R * q), P.left = -H / 2, P.right = H / 2, P.top = ne / 2, P.bottom = -ne / 2;
1621
1632
  } else {
1622
- const I = A.current, _ = f.width / f.height, $ = Math.max(I.y, I.x / _) * 1.6, X = $ * _;
1623
- P.left = -X / 2, P.right = X / 2, P.top = $ / 2, P.bottom = -$ / 2;
1633
+ const I = A.current, _ = f.width / f.height, B = Math.max(I.y, I.x / _) * 1.6, X = B * _;
1634
+ P.left = -X / 2, P.right = X / 2, P.top = B / 2, P.bottom = -B / 2;
1624
1635
  }
1625
1636
  P.updateProjectionMatrix();
1626
1637
  }, [
1627
1638
  f.width,
1628
1639
  f.height,
1629
1640
  o,
1630
- g,
1641
+ h,
1631
1642
  s,
1632
1643
  n
1633
1644
  ]), null;
1634
- }, Mr = ({ mesh: e, isDragging: o }) => {
1645
+ }, kr = ({ mesh: e, isDragging: o }) => {
1635
1646
  var _a;
1636
1647
  const t = e.geometry;
1637
1648
  t.computeBoundingBox();
@@ -1650,12 +1661,12 @@ let __tla = (async () => {
1650
1661
  n.z
1651
1662
  ]
1652
1663
  });
1653
- }, kr = {
1664
+ }, Pr = {
1654
1665
  meter: "Scan units detected as meters \u2014 auto-scaled to millimeters",
1655
1666
  cm: "Scan units detected as centimeters \u2014 auto-scaled to millimeters",
1656
1667
  mm: "Scan units detected as millimeters"
1657
- }, Pr = ({ detectedUnit: e, onDismiss: o }) => {
1658
- const t = e === "meter" || e === "cm", n = kr[e] ?? "Scan units could not be determined";
1668
+ }, Fr = ({ detectedUnit: e, onDismiss: o }) => {
1669
+ const t = e === "meter" || e === "cm", n = Pr[e] ?? "Scan units could not be determined";
1659
1670
  return y("div", {
1660
1671
  style: {
1661
1672
  position: "absolute",
@@ -1698,7 +1709,7 @@ let __tla = (async () => {
1698
1709
  })
1699
1710
  ]
1700
1711
  });
1701
- }, Fr = ({ isDoubleShell: e, onDismiss: o }) => (Z(() => {
1712
+ }, Lr = ({ isDoubleShell: e, onDismiss: o }) => (Z(() => {
1702
1713
  const t = setTimeout(o, 1e4);
1703
1714
  return () => clearTimeout(t);
1704
1715
  }, []), y("div", {
@@ -1742,30 +1753,30 @@ let __tla = (async () => {
1742
1753
  children: "X"
1743
1754
  })
1744
1755
  ]
1745
- })), $n = (e, o) => {
1756
+ })), Bn = (e, o) => {
1746
1757
  const t = Math.abs(e - o);
1747
1758
  return t <= 7 ? "#4caf50" : t <= 15 ? "#ff9800" : "#f44336";
1748
- }, Lr = ({ mesh: e, upperY: o, originY: t, modelSize: n, meshColor: s = "#c8c8c8", displayUnit: l = "cm", formML: d, formAP: a }) => {
1759
+ }, Dr = ({ mesh: e, upperY: o, originY: t, modelSize: n, meshColor: s = "#c8c8c8", displayUnit: l = "cm", formML: d, formAP: a }) => {
1749
1760
  const r = e.geometry, c = te(() => new zt(r, {
1750
- maxLeafTris: Mt
1761
+ maxLeafTris: kt
1751
1762
  }), [
1752
1763
  r
1753
- ]), p = te(() => Ge(c, r, t), [
1764
+ ]), u = te(() => Ge(c, r, t), [
1754
1765
  c,
1755
1766
  r,
1756
1767
  t
1757
- ]), u = te(() => new At(new k(0, -1, 0), o), [
1768
+ ]), p = te(() => new Mt(new k(0, -1, 0), o), [
1758
1769
  o
1759
- ]), { mlLine: f, apLine: g, mlWidth: w, apWidth: h } = te(() => {
1770
+ ]), { mlLine: f, apLine: h, mlWidth: w, apWidth: g } = te(() => {
1760
1771
  let v = null, x = null, F = 0, S = 0;
1761
- if (p.linePoints.length >= 2) {
1762
- let C = p.linePoints[0], z = p.linePoints[0], R = p.linePoints[0], W = p.linePoints[0];
1763
- for (const N of p.linePoints) N.x < C.x && (C = N), N.x > z.x && (z = N), N.z < R.z && (R = N), N.z > W.z && (W = N);
1772
+ if (u.linePoints.length >= 2) {
1773
+ let C = u.linePoints[0], M = u.linePoints[0], E = u.linePoints[0], W = u.linePoints[0];
1774
+ for (const N of u.linePoints) N.x < C.x && (C = N), N.x > M.x && (M = N), N.z < E.z && (E = N), N.z > W.z && (W = N);
1764
1775
  v = [
1765
1776
  new k(C.x, t, C.z),
1766
- new k(z.x, t, z.z)
1777
+ new k(M.x, t, M.z)
1767
1778
  ], x = [
1768
- new k(R.x, t, R.z),
1779
+ new k(E.x, t, E.z),
1769
1780
  new k(W.x, t, W.z)
1770
1781
  ], F = v[0].distanceTo(v[1]), S = x[0].distanceTo(x[1]);
1771
1782
  }
@@ -1776,7 +1787,7 @@ let __tla = (async () => {
1776
1787
  apWidth: S
1777
1788
  };
1778
1789
  }, [
1779
- p,
1790
+ u,
1780
1791
  t
1781
1792
  ]), b = (v) => l === "inch" ? (v / 25.4).toFixed(2) : (v / 10).toFixed(1), A = l === "inch" ? "in" : "cm";
1782
1793
  return y(_e, {
@@ -1790,12 +1801,12 @@ let __tla = (async () => {
1790
1801
  opacity: 0.15,
1791
1802
  depthWrite: false,
1792
1803
  clippingPlanes: [
1793
- u
1804
+ p
1794
1805
  ]
1795
1806
  })
1796
1807
  }),
1797
- p.linePoints.length >= 2 && i(ve, {
1798
- points: p.linePoints,
1808
+ u.linePoints.length >= 2 && i(ve, {
1809
+ points: u.linePoints,
1799
1810
  color: "#00ff00",
1800
1811
  lineWidth: 3,
1801
1812
  depthTest: false,
@@ -1851,7 +1862,7 @@ let __tla = (async () => {
1851
1862
  })
1852
1863
  }),
1853
1864
  d != null && d > 0 && (() => {
1854
- const v = w - d, x = $n(w, d), F = v > 0.5 ? "\u25B2" : v < -0.5 ? "\u25BC" : "";
1865
+ const v = w - d, x = Bn(w, d), F = v > 0.5 ? "\u25B2" : v < -0.5 ? "\u25BC" : "";
1855
1866
  return y("div", {
1856
1867
  style: {
1857
1868
  display: "flex",
@@ -1902,10 +1913,10 @@ let __tla = (async () => {
1902
1913
  })
1903
1914
  ]
1904
1915
  }),
1905
- g && y(_e, {
1916
+ h && y(_e, {
1906
1917
  children: [
1907
1918
  i(ve, {
1908
- points: g,
1919
+ points: h,
1909
1920
  color: "#ff00ff",
1910
1921
  lineWidth: 2,
1911
1922
  depthTest: false,
@@ -1914,9 +1925,9 @@ let __tla = (async () => {
1914
1925
  }),
1915
1926
  i(Xe, {
1916
1927
  position: [
1917
- Math.max(g[0].x, g[1].x) + n * 0.02,
1928
+ Math.max(h[0].x, h[1].x) + n * 0.02,
1918
1929
  t,
1919
- g[0].z > g[1].z ? g[0].z : g[1].z
1930
+ h[0].z > h[1].z ? h[0].z : h[1].z
1920
1931
  ],
1921
1932
  center: true,
1922
1933
  style: {
@@ -1944,14 +1955,14 @@ let __tla = (async () => {
1944
1955
  },
1945
1956
  children: [
1946
1957
  "AP ",
1947
- b(h),
1958
+ b(g),
1948
1959
  " ",
1949
1960
  A
1950
1961
  ]
1951
1962
  })
1952
1963
  }),
1953
1964
  a != null && a > 0 && (() => {
1954
- const v = h - a, x = $n(h, a), F = v > 0.5 ? "\u25B2" : v < -0.5 ? "\u25BC" : "";
1965
+ const v = g - a, x = Bn(g, a), F = v > 0.5 ? "\u25B2" : v < -0.5 ? "\u25BC" : "";
1955
1966
  return y("div", {
1956
1967
  style: {
1957
1968
  display: "flex",
@@ -2004,8 +2015,8 @@ let __tla = (async () => {
2004
2015
  })
2005
2016
  ]
2006
2017
  });
2007
- }, Dr = ({ mesh: e, yPosition: o, onYChange: t, minY: n, maxY: s, modelSize: l, color: d, hoverColor: a, dragColor: r, label: c, onDragStart: p, onDragEnd: u }) => {
2008
- const [f, g] = B(false), [w, h] = B(false), { camera: b, gl: A } = Hn(), v = fe(0), x = fe(null), F = e.geometry, S = Jn(F), C = te(() => S ? Ge(S, F, o) : {
2018
+ }, _r = ({ mesh: e, yPosition: o, onYChange: t, minY: n, maxY: s, modelSize: l, color: d, hoverColor: a, dragColor: r, label: c, onDragStart: u, onDragEnd: p }) => {
2019
+ const [f, h] = $(false), [w, g] = $(false), { camera: b, gl: A } = Hn(), v = fe(0), x = fe(null), F = e.geometry, S = Jn(F), C = te(() => S ? Ge(S, F, o) : {
2009
2020
  linePoints: [],
2010
2021
  lineLength: 0,
2011
2022
  rightmostPoint: new k()
@@ -2013,50 +2024,50 @@ let __tla = (async () => {
2013
2024
  S,
2014
2025
  F,
2015
2026
  o
2016
- ]), z = de((_, $, X) => {
2017
- const oe = A.domElement.getBoundingClientRect(), ce = (_ - oe.left) / oe.width * 2 - 1, se = -(($ - oe.top) / oe.height) * 2 + 1, J = new Ho();
2027
+ ]), M = de((_, B, X) => {
2028
+ const oe = A.domElement.getBoundingClientRect(), ce = (_ - oe.left) / oe.width * 2 - 1, se = -((B - oe.top) / oe.height) * 2 + 1, J = new Ho();
2018
2029
  J.setFromCamera(new U.Vector2(ce, se), b);
2019
2030
  const ae = new k();
2020
2031
  return J.ray.intersectPlane(X, ae) ? ae.y : null;
2021
2032
  }, [
2022
2033
  b,
2023
2034
  A
2024
- ]), R = de((_) => {
2025
- const $ = new k();
2026
- b.getWorldDirection($), $.y = 0, $.lengthSq() < 1e-6 && $.set(0, 0, 1), $.normalize();
2027
- const X = $.multiplyScalar(-1);
2028
- return new At().setFromNormalAndCoplanarPoint(X, new k(0, _, 0));
2035
+ ]), E = de((_) => {
2036
+ const B = new k();
2037
+ b.getWorldDirection(B), B.y = 0, B.lengthSq() < 1e-6 && B.set(0, 0, 1), B.normalize();
2038
+ const X = B.multiplyScalar(-1);
2039
+ return new Mt().setFromNormalAndCoplanarPoint(X, new k(0, _, 0));
2029
2040
  }, [
2030
2041
  b
2031
2042
  ]), W = de((_) => {
2032
- _.stopPropagation(), g(true), A.domElement.style.cursor = "ns-resize";
2033
- const $ = R(o);
2034
- x.current = $;
2035
- const X = z(_.clientX, _.clientY, $);
2036
- v.current = X != null ? o - X : 0, _.target.setPointerCapture(_.pointerId), p == null ? void 0 : p();
2043
+ _.stopPropagation(), h(true), A.domElement.style.cursor = "ns-resize";
2044
+ const B = E(o);
2045
+ x.current = B;
2046
+ const X = M(_.clientX, _.clientY, B);
2047
+ v.current = X != null ? o - X : 0, _.target.setPointerCapture(_.pointerId), u == null ? void 0 : u();
2037
2048
  }, [
2038
2049
  o,
2039
2050
  A,
2040
- R,
2041
- z,
2042
- p
2051
+ E,
2052
+ M,
2053
+ u
2043
2054
  ]), N = de((_) => {
2044
2055
  if (!f || !x.current) return;
2045
- const $ = z(_.clientX, _.clientY, x.current);
2046
- if ($ == null) return;
2047
- let X = $ + v.current;
2056
+ const B = M(_.clientX, _.clientY, x.current);
2057
+ if (B == null) return;
2058
+ let X = B + v.current;
2048
2059
  X = Math.max(n, Math.min(s, X)), t(X);
2049
2060
  }, [
2050
2061
  f,
2051
- z,
2062
+ M,
2052
2063
  t,
2053
2064
  n,
2054
2065
  s
2055
2066
  ]), P = de((_) => {
2056
- g(false), A.domElement.style.cursor = "auto", x.current = null, _.target.releasePointerCapture(_.pointerId), u == null ? void 0 : u();
2067
+ h(false), A.domElement.style.cursor = "auto", x.current = null, _.target.releasePointerCapture(_.pointerId), p == null ? void 0 : p();
2057
2068
  }, [
2058
2069
  A,
2059
- u
2070
+ p
2060
2071
  ]);
2061
2072
  if (C.linePoints.length < 2) return null;
2062
2073
  const I = f ? r : w ? a : d;
@@ -2075,10 +2086,10 @@ let __tla = (async () => {
2075
2086
  onPointerMove: N,
2076
2087
  onPointerUp: P,
2077
2088
  onPointerEnter: () => {
2078
- h(true), A.domElement.style.cursor = "ns-resize";
2089
+ g(true), A.domElement.style.cursor = "ns-resize";
2079
2090
  },
2080
2091
  onPointerLeave: () => {
2081
- f || (h(false), A.domElement.style.cursor = "auto");
2092
+ f || (g(false), A.domElement.style.cursor = "auto");
2082
2093
  }
2083
2094
  }),
2084
2095
  (w || f) && i("mesh", {
@@ -2106,7 +2117,7 @@ let __tla = (async () => {
2106
2117
  ]
2107
2118
  });
2108
2119
  };
2109
- function _r(e, o) {
2120
+ function Rr(e, o) {
2110
2121
  if (e == null) return {};
2111
2122
  var t = {}, n = Object.keys(e), s, l;
2112
2123
  for (l = 0; l < n.length; l++) s = n[l], !(o.indexOf(s) >= 0) && (t[s] = e[s]);
@@ -2114,8 +2125,8 @@ let __tla = (async () => {
2114
2125
  }
2115
2126
  var Er = [
2116
2127
  "color"
2117
- ], Rr = To(function(e, o) {
2118
- var t = e.color, n = t === void 0 ? "currentColor" : t, s = _r(e, Er);
2128
+ ], Ir = To(function(e, o) {
2129
+ var t = e.color, n = t === void 0 ? "currentColor" : t, s = Rr(e, Er);
2119
2130
  return Fn("svg", Object.assign({
2120
2131
  width: "15",
2121
2132
  height: "15",
@@ -2149,15 +2160,15 @@ let __tla = (async () => {
2149
2160
  outline: "none",
2150
2161
  boxSizing: "border-box",
2151
2162
  fontFamily: "system-ui, sans-serif"
2152
- }, Ir = ({ amputationType: e, spacingInches: o, scanMeasurements: t, scanFrontalHeight: n, scanTransverseML: s = 0, scanTransverseAP: l = 0, onSave: d, onSkip: a, onFormChange: r, onHeightChange: c, onTransverseMLChange: p, onTransverseAPChange: u, initialValues: f, initialFrontalHeight: g }) => {
2153
- const w = e === "AK" ? "Perineum" : "MPT", h = o, b = e === "AK" ? 18 : 9, A = te(() => {
2154
- const E = [];
2155
- if (e !== "AK") for (let H = 2; H >= 1; H -= h) E.push(`${H}\u2033 above ${w}`);
2156
- E.push(`At ${w}`);
2157
- for (let H = h; H <= b; H += h) E.push(`${H}\u2033 below ${w}`);
2158
- return E;
2163
+ }, Wr = ({ amputationType: e, spacingInches: o, scanMeasurements: t, scanFrontalHeight: n, scanTransverseML: s = 0, scanTransverseAP: l = 0, onSave: d, onSkip: a, onFormChange: r, onHeightChange: c, onTransverseMLChange: u, onTransverseAPChange: p, initialValues: f, initialFrontalHeight: h }) => {
2164
+ const w = e === "AK" ? "Perineum" : "MPT", g = o, b = e === "AK" ? 18 : 9, A = te(() => {
2165
+ const R = [];
2166
+ if (e !== "AK") for (let H = 2; H >= 1; H -= g) R.push(`${H}\u2033 above ${w}`);
2167
+ R.push(`At ${w}`);
2168
+ for (let H = g; H <= b; H += g) R.push(`${H}\u2033 below ${w}`);
2169
+ return R;
2159
2170
  }, [
2160
- h,
2171
+ g,
2161
2172
  w,
2162
2173
  b,
2163
2174
  e
@@ -2172,14 +2183,14 @@ let __tla = (async () => {
2172
2183
  ]), [
2173
2184
  e,
2174
2185
  w
2175
- ]), [x, F] = B(() => {
2186
+ ]), [x, F] = $(() => {
2176
2187
  if (!f) return {};
2177
- const E = {};
2188
+ const R = {};
2178
2189
  return A.forEach((H, ne) => {
2179
- f[ne] != null && f[ne] !== 0 && (E[H] = (f[ne] / 10).toFixed(1));
2180
- }), E;
2181
- }), [S, C] = B(g && g > 0 ? (g / 10).toFixed(1) : ""), [z, R] = B(""), [W, N] = B(""), [P, I] = B(""), [_, $] = B(""), X = e === "AK" ? "Perineum to Distal (Axial)" : "MPT to Distal (Axial)", oe = e === "AK" ? "M/L at Perineum" : "M/L at MPT", ce = e === "AK" ? "A/P at Perineum" : "A/P at MPT", se = te(() => A.map((E) => {
2182
- const H = x[E];
2190
+ f[ne] != null && f[ne] !== 0 && (R[H] = (f[ne] / 10).toFixed(1));
2191
+ }), R;
2192
+ }), [S, C] = $(h && h > 0 ? (h / 10).toFixed(1) : ""), [M, E] = $(""), [W, N] = $(""), [P, I] = $(""), [_, B] = $(""), X = e === "AK" ? "Perineum to Distal (Axial)" : "MPT to Distal (Axial)", oe = e === "AK" ? "M/L at Perineum" : "M/L at MPT", ce = e === "AK" ? "A/P at Perineum" : "A/P at MPT", se = te(() => A.map((R) => {
2193
+ const H = x[R];
2183
2194
  return H != null && H !== "" && !isNaN(parseFloat(H)) ? parseFloat(H) * 10 : 0;
2184
2195
  }), [
2185
2196
  A,
@@ -2191,29 +2202,29 @@ let __tla = (async () => {
2191
2202
  se,
2192
2203
  r
2193
2204
  ]), Z(() => {
2194
- const E = S !== "" && !isNaN(parseFloat(S)) ? parseFloat(S) * 10 : void 0;
2195
- c == null ? void 0 : c(E);
2205
+ const R = S !== "" && !isNaN(parseFloat(S)) ? parseFloat(S) * 10 : void 0;
2206
+ c == null ? void 0 : c(R);
2196
2207
  }, [
2197
2208
  S,
2198
2209
  c
2199
2210
  ]);
2200
- const J = e === "AK" ? z : P, ae = e === "AK" ? W : _;
2211
+ const J = e === "AK" ? M : P, ae = e === "AK" ? W : _;
2201
2212
  Z(() => {
2202
- const E = J !== "" && !isNaN(parseFloat(J)) ? parseFloat(J) * 10 : void 0;
2203
- p == null ? void 0 : p(E);
2213
+ const R = J !== "" && !isNaN(parseFloat(J)) ? parseFloat(J) * 10 : void 0;
2214
+ u == null ? void 0 : u(R);
2204
2215
  }, [
2205
2216
  J,
2206
- p
2217
+ u
2207
2218
  ]), Z(() => {
2208
- const E = ae !== "" && !isNaN(parseFloat(ae)) ? parseFloat(ae) * 10 : void 0;
2209
- u == null ? void 0 : u(E);
2219
+ const R = ae !== "" && !isNaN(parseFloat(ae)) ? parseFloat(ae) * 10 : void 0;
2220
+ p == null ? void 0 : p(R);
2210
2221
  }, [
2211
2222
  ae,
2212
- u
2223
+ p
2213
2224
  ]);
2214
2225
  const q = te(() => {
2215
- for (const E of v) {
2216
- const H = A.indexOf(E);
2226
+ for (const R of v) {
2227
+ const H = A.indexOf(R);
2217
2228
  if (H === -1) continue;
2218
2229
  if (se[H] === 0) return false;
2219
2230
  }
@@ -2225,40 +2236,40 @@ let __tla = (async () => {
2225
2236
  S
2226
2237
  ]), ge = de(() => {
2227
2238
  if (!q) return;
2228
- const E = (ne) => ne !== "" && !isNaN(parseFloat(ne)) ? parseFloat(ne) * 10 : void 0, H = E(S) ?? 0;
2239
+ const R = (ne) => ne !== "" && !isNaN(parseFloat(ne)) ? parseFloat(ne) * 10 : void 0, H = R(S) ?? 0;
2229
2240
  d({
2230
2241
  circumferences: se,
2231
2242
  frontalHeight: H,
2232
- perineumML: e === "AK" ? E(z) : void 0,
2233
- perineumAP: e === "AK" ? E(W) : void 0,
2234
- mptML: e === "BK" ? E(P) : void 0,
2235
- mptAP: e === "BK" ? E(_) : void 0
2243
+ perineumML: e === "AK" ? R(M) : void 0,
2244
+ perineumAP: e === "AK" ? R(W) : void 0,
2245
+ mptML: e === "BK" ? R(P) : void 0,
2246
+ mptAP: e === "BK" ? R(_) : void 0
2236
2247
  });
2237
2248
  }, [
2238
2249
  q,
2239
2250
  se,
2240
2251
  S,
2241
- z,
2252
+ M,
2242
2253
  W,
2243
2254
  P,
2244
2255
  _,
2245
2256
  e,
2246
2257
  d
2247
2258
  ]), re = de(() => {
2248
- const E = {};
2259
+ const R = {};
2249
2260
  if (A.forEach((H, ne) => {
2250
2261
  const Q = t[ne];
2251
2262
  if (Q) {
2252
2263
  const j = Q.modifiedValue ?? Q.originalValue;
2253
- E[H] = (j / 10).toFixed(1);
2264
+ R[H] = (j / 10).toFixed(1);
2254
2265
  }
2255
- }), F(E), n > 0 && C((n / 10).toFixed(1)), s > 0) {
2266
+ }), F(R), n > 0 && C((n / 10).toFixed(1)), s > 0) {
2256
2267
  const H = (s / 10).toFixed(1);
2257
- e === "AK" ? R(H) : I(H);
2268
+ e === "AK" ? E(H) : I(H);
2258
2269
  }
2259
2270
  if (l > 0) {
2260
2271
  const H = (l / 10).toFixed(1);
2261
- e === "AK" ? N(H) : $(H);
2272
+ e === "AK" ? N(H) : B(H);
2262
2273
  }
2263
2274
  }, [
2264
2275
  A,
@@ -2301,7 +2312,7 @@ let __tla = (async () => {
2301
2312
  2,
2302
2313
  3,
2303
2314
  4
2304
- ].map((E) => i("div", {
2315
+ ].map((R) => i("div", {
2305
2316
  style: {
2306
2317
  height: 4,
2307
2318
  flex: 1,
@@ -2309,7 +2320,7 @@ let __tla = (async () => {
2309
2320
  borderRadius: 2,
2310
2321
  backgroundColor: "rgb(12, 67, 173)"
2311
2322
  }
2312
- }, E)),
2323
+ }, R)),
2313
2324
  i("div", {
2314
2325
  style: {
2315
2326
  fontSize: 11,
@@ -2362,7 +2373,7 @@ let __tla = (async () => {
2362
2373
  },
2363
2374
  children: [
2364
2375
  "Enter the patient's hand measurements below to compare them against the scan. Values in cm, ",
2365
- h,
2376
+ g,
2366
2377
  "\u2033",
2367
2378
  " spacing. ",
2368
2379
  i("span", {
@@ -2409,7 +2420,7 @@ let __tla = (async () => {
2409
2420
  gap: 4
2410
2421
  },
2411
2422
  children: [
2412
- i(Rr, {
2423
+ i(Ir, {
2413
2424
  style: {
2414
2425
  width: 14,
2415
2426
  height: 14
@@ -2446,8 +2457,8 @@ let __tla = (async () => {
2446
2457
  gap: 10,
2447
2458
  marginBottom: 20
2448
2459
  },
2449
- children: A.map((E, H) => {
2450
- const ne = v.has(E), Q = !!x[E];
2460
+ children: A.map((R, H) => {
2461
+ const ne = v.has(R), Q = !!x[R];
2451
2462
  return y("div", {
2452
2463
  style: {
2453
2464
  display: "flex",
@@ -2466,9 +2477,9 @@ let __tla = (async () => {
2466
2477
  overflow: "hidden",
2467
2478
  textOverflow: "ellipsis"
2468
2479
  },
2469
- title: E,
2480
+ title: R,
2470
2481
  children: [
2471
- E,
2482
+ R,
2472
2483
  ne && i("span", {
2473
2484
  style: {
2474
2485
  color: "#e53935",
@@ -2481,10 +2492,10 @@ let __tla = (async () => {
2481
2492
  i("input", {
2482
2493
  type: "number",
2483
2494
  step: "0.1",
2484
- value: x[E] ?? "",
2485
- onChange: (j) => F((Y) => ({
2486
- ...Y,
2487
- [E]: j.target.value
2495
+ value: x[R] ?? "",
2496
+ onChange: (j) => F((K) => ({
2497
+ ...K,
2498
+ [R]: j.target.value
2488
2499
  })),
2489
2500
  style: {
2490
2501
  ...Ue,
@@ -2549,7 +2560,7 @@ let __tla = (async () => {
2549
2560
  type: "number",
2550
2561
  step: "0.1",
2551
2562
  value: S,
2552
- onChange: (E) => C(E.target.value),
2563
+ onChange: (R) => C(R.target.value),
2553
2564
  style: {
2554
2565
  ...Ue,
2555
2566
  padding: "6px 8px",
@@ -2587,13 +2598,13 @@ let __tla = (async () => {
2587
2598
  i("input", {
2588
2599
  type: "number",
2589
2600
  step: "0.1",
2590
- value: z,
2591
- onChange: (E) => R(E.target.value),
2601
+ value: M,
2602
+ onChange: (R) => E(R.target.value),
2592
2603
  style: {
2593
2604
  ...Ue,
2594
2605
  padding: "6px 8px",
2595
2606
  fontSize: 13,
2596
- borderColor: z ? "rgb(12, 67, 173)" : "#ccc",
2607
+ borderColor: M ? "rgb(12, 67, 173)" : "#ccc",
2597
2608
  borderWidth: 1
2598
2609
  },
2599
2610
  placeholder: "0.0"
@@ -2625,7 +2636,7 @@ let __tla = (async () => {
2625
2636
  type: "number",
2626
2637
  step: "0.1",
2627
2638
  value: W,
2628
- onChange: (E) => N(E.target.value),
2639
+ onChange: (R) => N(R.target.value),
2629
2640
  style: {
2630
2641
  ...Ue,
2631
2642
  padding: "6px 8px",
@@ -2665,7 +2676,7 @@ let __tla = (async () => {
2665
2676
  type: "number",
2666
2677
  step: "0.1",
2667
2678
  value: P,
2668
- onChange: (E) => I(E.target.value),
2679
+ onChange: (R) => I(R.target.value),
2669
2680
  style: {
2670
2681
  ...Ue,
2671
2682
  padding: "6px 8px",
@@ -2702,7 +2713,7 @@ let __tla = (async () => {
2702
2713
  type: "number",
2703
2714
  step: "0.1",
2704
2715
  value: _,
2705
- onChange: (E) => $(E.target.value),
2716
+ onChange: (R) => B(R.target.value),
2706
2717
  style: {
2707
2718
  ...Ue,
2708
2719
  padding: "6px 8px",
@@ -2748,7 +2759,7 @@ let __tla = (async () => {
2748
2759
  })
2749
2760
  ]
2750
2761
  });
2751
- }, Wr = [
2762
+ }, $r = [
2752
2763
  "Scan doesn't load properly",
2753
2764
  "Modified CAD",
2754
2765
  "I don't want to",
@@ -2772,18 +2783,18 @@ let __tla = (async () => {
2772
2783
  outline: "none",
2773
2784
  boxSizing: "border-box",
2774
2785
  fontFamily: "system-ui, sans-serif"
2775
- }, $r = ({ onSkip: e, onCancel: o }) => {
2776
- const [t, n] = B("confirm"), [s, l] = B(null), [d, a] = B(""), r = de(() => {
2786
+ }, Tr = ({ onSkip: e, onCancel: o }) => {
2787
+ const [t, n] = $("confirm"), [s, l] = $(null), [d, a] = $(""), r = de(() => {
2777
2788
  n("reasons");
2778
2789
  }, []), c = de(() => {
2779
2790
  t === "reasons" ? (n("confirm"), l(null), a("")) : o();
2780
2791
  }, [
2781
2792
  t,
2782
2793
  o
2783
- ]), p = s != null && (s !== "Other" || d.trim() !== ""), u = de(() => {
2784
- !p || !s || e(s === "Other" ? `Other: ${d.trim()}` : s);
2794
+ ]), u = s != null && (s !== "Other" || d.trim() !== ""), p = de(() => {
2795
+ !u || !s || e(s === "Other" ? `Other: ${d.trim()}` : s);
2785
2796
  }, [
2786
- p,
2797
+ u,
2787
2798
  s,
2788
2799
  d,
2789
2800
  e
@@ -2841,7 +2852,7 @@ let __tla = (async () => {
2841
2852
  },
2842
2853
  children: [
2843
2854
  [
2844
- ...Wr,
2855
+ ...$r,
2845
2856
  "Other"
2846
2857
  ].map((f) => y("label", {
2847
2858
  style: {
@@ -2885,7 +2896,7 @@ let __tla = (async () => {
2885
2896
  value: d,
2886
2897
  onChange: (f) => a(f.target.value),
2887
2898
  onKeyDown: (f) => {
2888
- f.key === "Enter" && u();
2899
+ f.key === "Enter" && p();
2889
2900
  },
2890
2901
  style: {
2891
2902
  ...Br,
@@ -2917,14 +2928,14 @@ let __tla = (async () => {
2917
2928
  children: "Cancel"
2918
2929
  }),
2919
2930
  i("button", {
2920
- onClick: u,
2921
- disabled: !p,
2931
+ onClick: p,
2932
+ disabled: !u,
2922
2933
  style: {
2923
2934
  ...wt,
2924
- backgroundColor: p ? "rgb(12, 67, 173)" : "#e0e0e0",
2935
+ backgroundColor: u ? "rgb(12, 67, 173)" : "#e0e0e0",
2925
2936
  border: "none",
2926
- color: p ? "#fff" : "#9e9e9e",
2927
- cursor: p ? "pointer" : "not-allowed"
2937
+ color: u ? "#fff" : "#9e9e9e",
2938
+ cursor: u ? "pointer" : "not-allowed"
2928
2939
  },
2929
2940
  children: "Submit"
2930
2941
  })
@@ -3011,9 +3022,9 @@ let __tla = (async () => {
3011
3022
  for (let b = 0; b < l; b++) {
3012
3023
  const A = o + b * d, v = o + (b + 1) * d;
3013
3024
  let x = 0, F = 0, S = 0, C = 0;
3014
- for (let z = 0; z < n.count; z++) {
3015
- const R = n.getY(z);
3016
- R >= A && R < v && (x += n.getX(z), F += R, S += n.getZ(z), C++);
3025
+ for (let M = 0; M < n.count; M++) {
3026
+ const E = n.getY(M);
3027
+ E >= A && E < v && (x += n.getX(M), F += E, S += n.getZ(M), C++);
3017
3028
  }
3018
3029
  C > 20 && a.push(new k(x / C, F / C, S / C));
3019
3030
  }
@@ -3021,20 +3032,20 @@ let __tla = (async () => {
3021
3032
  const r = new k();
3022
3033
  for (const b of a) r.add(b);
3023
3034
  r.divideScalar(a.length);
3024
- let c = 0, p = 0, u = 0, f = 0, g = 0, w = 0;
3035
+ let c = 0, u = 0, p = 0, f = 0, h = 0, w = 0;
3025
3036
  for (const b of a) {
3026
3037
  const A = b.x - r.x, v = b.y - r.y, x = b.z - r.z;
3027
- c += A * A, p += A * v, u += A * x, f += v * v, g += v * x, w += x * x;
3038
+ c += A * A, u += A * v, p += A * x, f += v * v, h += v * x, w += x * x;
3028
3039
  }
3029
- let h = new k(0.01, 1, 0.01).normalize();
3040
+ let g = new k(0.01, 1, 0.01).normalize();
3030
3041
  for (let b = 0; b < 30; b++) {
3031
- const A = c * h.x + p * h.y + u * h.z, v = p * h.x + f * h.y + g * h.z, x = u * h.x + g * h.y + w * h.z, F = new k(A, v, x), S = F.length();
3032
- if (S < 1e-10 || (F.divideScalar(S), h.distanceTo(F) < 1e-8)) break;
3033
- h = F;
3042
+ const A = c * g.x + u * g.y + p * g.z, v = u * g.x + f * g.y + h * g.z, x = p * g.x + h * g.y + w * g.z, F = new k(A, v, x), S = F.length();
3043
+ if (S < 1e-10 || (F.divideScalar(S), g.distanceTo(F) < 1e-8)) break;
3044
+ g = F;
3034
3045
  }
3035
- return h.y < 0 && h.negate(), h;
3046
+ return g.y < 0 && g.negate(), g;
3036
3047
  }
3037
- const Tr = {
3048
+ const Or = {
3038
3049
  pcaAxes: true,
3039
3050
  obb: true,
3040
3051
  obbAxis: true,
@@ -3044,22 +3055,22 @@ let __tla = (async () => {
3044
3055
  landmarkAxis: true,
3045
3056
  iterativePCA: false,
3046
3057
  fullRegionPCA: true
3047
- }, Or = [
3058
+ }, Hr = [
3048
3059
  "#ff4444",
3049
3060
  "#44cc44",
3050
3061
  "#4488ff"
3051
3062
  ];
3052
3063
  function eo(e) {
3053
3064
  const o = e.getAttribute("position"), t = o.count, n = new k();
3054
- for (let h = 0; h < t; h++) n.x += o.getX(h), n.y += o.getY(h), n.z += o.getZ(h);
3065
+ for (let g = 0; g < t; g++) n.x += o.getX(g), n.y += o.getY(g), n.z += o.getZ(g);
3055
3066
  n.divideScalar(t);
3056
3067
  let s = 0, l = 0, d = 0, a = 0, r = 0, c = 0;
3057
- for (let h = 0; h < t; h++) {
3058
- const b = o.getX(h) - n.x, A = o.getY(h) - n.y, v = o.getZ(h) - n.z;
3068
+ for (let g = 0; g < t; g++) {
3069
+ const b = o.getX(g) - n.x, A = o.getY(g) - n.y, v = o.getZ(g) - n.z;
3059
3070
  s += b * b, l += b * A, d += b * v, a += A * A, r += A * v, c += v * v;
3060
3071
  }
3061
3072
  s /= t, l /= t, d /= t, a /= t, r /= t, c /= t;
3062
- const p = [], u = [], f = [
3073
+ const u = [], p = [], f = [
3063
3074
  [
3064
3075
  s,
3065
3076
  l,
@@ -3076,8 +3087,8 @@ let __tla = (async () => {
3076
3087
  c
3077
3088
  ]
3078
3089
  ];
3079
- for (let h = 0; h < 3; h++) {
3080
- let b = new k(1 + h * 0.1, 1 - h * 0.1, 0.5 + h * 0.3).normalize(), A = 0;
3090
+ for (let g = 0; g < 3; g++) {
3091
+ let b = new k(1 + g * 0.1, 1 - g * 0.1, 0.5 + g * 0.3).normalize(), A = 0;
3081
3092
  for (let v = 0; v < 100; v++) {
3082
3093
  const x = f[0][0] * b.x + f[0][1] * b.y + f[0][2] * b.z, F = f[1][0] * b.x + f[1][1] * b.y + f[1][2] * b.z, S = f[2][0] * b.x + f[2][1] * b.y + f[2][2] * b.z, C = new k(x, F, S);
3083
3094
  if (A = C.length(), A < 1e-12) break;
@@ -3087,7 +3098,7 @@ let __tla = (async () => {
3087
3098
  }
3088
3099
  b = C;
3089
3100
  }
3090
- p.push(b.clone()), u.push(A);
3101
+ u.push(b.clone()), p.push(A);
3091
3102
  for (let v = 0; v < 3; v++) for (let x = 0; x < 3; x++) {
3092
3103
  const F = [
3093
3104
  b.x,
@@ -3101,31 +3112,31 @@ let __tla = (async () => {
3101
3112
  f[v][x] -= A * F * S;
3102
3113
  }
3103
3114
  }
3104
- const g = new k();
3105
- for (let h = 0; h < t; h++) g.x += o.getX(h), g.y += o.getY(h), g.z += o.getZ(h);
3106
- g.divideScalar(t);
3115
+ const h = new k();
3116
+ for (let g = 0; g < t; g++) h.x += o.getX(g), h.y += o.getY(g), h.z += o.getZ(g);
3117
+ h.divideScalar(t);
3107
3118
  const w = [
3108
3119
  0,
3109
3120
  0,
3110
3121
  0
3111
3122
  ];
3112
- for (let h = 0; h < 3; h++) {
3123
+ for (let g = 0; g < 3; g++) {
3113
3124
  let b = 1 / 0, A = -1 / 0;
3114
- const v = p[h];
3125
+ const v = u[g];
3115
3126
  for (let x = 0; x < t; x++) {
3116
- const F = o.getX(x) - g.x, S = o.getY(x) - g.y, C = o.getZ(x) - g.z, z = F * v.x + S * v.y + C * v.z;
3117
- z < b && (b = z), z > A && (A = z);
3127
+ const F = o.getX(x) - h.x, S = o.getY(x) - h.y, C = o.getZ(x) - h.z, M = F * v.x + S * v.y + C * v.z;
3128
+ M < b && (b = M), M > A && (A = M);
3118
3129
  }
3119
- w[h] = (A - b) / 2;
3130
+ w[g] = (A - b) / 2;
3120
3131
  }
3121
3132
  return {
3122
- axes: p,
3123
- eigenvalues: u,
3124
- center: g,
3133
+ axes: u,
3134
+ eigenvalues: p,
3135
+ center: h,
3125
3136
  halfExtents: w
3126
3137
  };
3127
3138
  }
3128
- function Hr({ pca: e }) {
3139
+ function Nr({ pca: e }) {
3129
3140
  return i("group", {
3130
3141
  children: e.axes.map((o, t) => {
3131
3142
  const n = e.center.clone().addScaledVector(o, e.halfExtents[t]), s = e.center.clone().addScaledVector(o, -e.halfExtents[t]);
@@ -3134,13 +3145,13 @@ let __tla = (async () => {
3134
3145
  s,
3135
3146
  n
3136
3147
  ],
3137
- color: Or[t],
3148
+ color: Hr[t],
3138
3149
  lineWidth: 2
3139
3150
  }, t);
3140
3151
  })
3141
3152
  });
3142
3153
  }
3143
- function Nr({ pca: e }) {
3154
+ function Vr({ pca: e }) {
3144
3155
  const o = te(() => {
3145
3156
  const { center: t, axes: n, halfExtents: s } = e, l = [];
3146
3157
  for (let a = -1; a <= 1; a += 2) for (let r = -1; r <= 1; r += 2) for (let c = -1; c <= 1; c += 2) l.push(t.clone().addScaledVector(n[0], a * s[0]).addScaledVector(n[1], r * s[1]).addScaledVector(n[2], c * s[2]));
@@ -3210,7 +3221,7 @@ let __tla = (async () => {
3210
3221
  }, n))
3211
3222
  });
3212
3223
  }
3213
- function Vr({ redPoint: e, greenPoint: o }) {
3224
+ function jr({ redPoint: e, greenPoint: o }) {
3214
3225
  const t = te(() => new k().subVectors(o, e).normalize(), [
3215
3226
  e,
3216
3227
  o
@@ -3263,19 +3274,19 @@ let __tla = (async () => {
3263
3274
  ]
3264
3275
  });
3265
3276
  }
3266
- function jr({ geometry: e, redY: o, greenY: t, modelSize: n }) {
3277
+ function Gr({ geometry: e, redY: o, greenY: t, modelSize: n }) {
3267
3278
  const l = n * 0.15, d = te(() => {
3268
3279
  const a = [];
3269
3280
  let r = t - 10;
3270
3281
  const c = new k(0, 1, 0);
3271
3282
  for (; r > o; ) {
3272
- const p = Math.min(r, t), u = Math.max(r, t), f = Qn(e, p, u);
3283
+ const u = Math.min(r, t), p = Math.max(r, t), f = Qn(e, u, p);
3273
3284
  if (f) {
3274
- const g = f.dot(c), w = Math.acos(Math.min(1, Math.abs(g))) * 180 / Math.PI;
3285
+ const h = f.dot(c), w = Math.acos(Math.min(1, Math.abs(h))) * 180 / Math.PI;
3275
3286
  a.push({
3276
3287
  axis: f,
3277
- regionMin: p,
3278
- regionMax: u,
3288
+ regionMin: u,
3289
+ regionMax: p,
3279
3290
  angleDeg: w
3280
3291
  });
3281
3292
  }
@@ -3289,13 +3300,13 @@ let __tla = (async () => {
3289
3300
  ]);
3290
3301
  return i("group", {
3291
3302
  children: d.map((a, r) => {
3292
- const c = (a.regionMin + a.regionMax) / 2, p = new k(0, c, 0), u = p.clone().addScaledVector(a.axis, l), f = p.clone().addScaledVector(a.axis, -l), g = r / Math.max(1, d.length - 1), w = a.angleDeg < 0.5 ? `hsl(${120 - g * 120}, 80%, 60%)` : `hsl(${40 - a.angleDeg * 2}, 90%, 55%)`;
3303
+ const c = (a.regionMin + a.regionMax) / 2, u = new k(0, c, 0), p = u.clone().addScaledVector(a.axis, l), f = u.clone().addScaledVector(a.axis, -l), h = r / Math.max(1, d.length - 1), w = a.angleDeg < 0.5 ? `hsl(${120 - h * 120}, 80%, 60%)` : `hsl(${40 - a.angleDeg * 2}, 90%, 55%)`;
3293
3304
  return y("group", {
3294
3305
  children: [
3295
3306
  i(ve, {
3296
3307
  points: [
3297
3308
  f,
3298
- u
3309
+ p
3299
3310
  ],
3300
3311
  color: w,
3301
3312
  lineWidth: 1.5,
@@ -3317,14 +3328,14 @@ let __tla = (async () => {
3317
3328
  })
3318
3329
  });
3319
3330
  }
3320
- function Gr({ geometry: e, redY: o, greenY: t, modelSize: n }) {
3331
+ function Xr({ geometry: e, redY: o, greenY: t, modelSize: n }) {
3321
3332
  const s = te(() => {
3322
- const u = Qn(e, o, t);
3323
- if (!u) return null;
3324
- const f = u.dot(new k(0, 1, 0)), g = Math.acos(Math.min(1, Math.abs(f))) * 180 / Math.PI;
3333
+ const p = Qn(e, o, t);
3334
+ if (!p) return null;
3335
+ const f = p.dot(new k(0, 1, 0)), h = Math.acos(Math.min(1, Math.abs(f))) * 180 / Math.PI;
3325
3336
  return {
3326
- axis: u,
3327
- angleDeg: g
3337
+ axis: p,
3338
+ angleDeg: h
3328
3339
  };
3329
3340
  }, [
3330
3341
  e,
@@ -3332,14 +3343,14 @@ let __tla = (async () => {
3332
3343
  t
3333
3344
  ]);
3334
3345
  if (!s) return null;
3335
- const l = (o + t) / 2, d = new k(0, l, 0), a = n * 0.4, r = d.clone().addScaledVector(s.axis, a), c = d.clone().addScaledVector(s.axis, -a), p = s.angleDeg < 0.5 ? "#00ffff" : s.angleDeg < 2 ? "#ffcc00" : "#ff6600";
3346
+ const l = (o + t) / 2, d = new k(0, l, 0), a = n * 0.4, r = d.clone().addScaledVector(s.axis, a), c = d.clone().addScaledVector(s.axis, -a), u = s.angleDeg < 0.5 ? "#00ffff" : s.angleDeg < 2 ? "#ffcc00" : "#ff6600";
3336
3347
  return i("group", {
3337
3348
  children: i(ve, {
3338
3349
  points: [
3339
3350
  c,
3340
3351
  r
3341
3352
  ],
3342
- color: p,
3353
+ color: u,
3343
3354
  lineWidth: 3,
3344
3355
  dashed: true,
3345
3356
  dashSize: 3,
@@ -3347,7 +3358,7 @@ let __tla = (async () => {
3347
3358
  })
3348
3359
  });
3349
3360
  }
3350
- function Xr({ pca: e, modelSize: o }) {
3361
+ function Yr({ pca: e, modelSize: o }) {
3351
3362
  const t = e.axes[0], n = o * 0.6, s = e.center.clone().addScaledVector(t, n), l = e.center.clone().addScaledVector(t, -n);
3352
3363
  return i(ve, {
3353
3364
  points: [
@@ -3363,22 +3374,22 @@ let __tla = (async () => {
3363
3374
  }
3364
3375
  function Kr({ geometry: e, redY: o, greenY: t, modelSize: n, measurementGeometry: s }) {
3365
3376
  const l = te(() => {
3366
- const p = s ?? e, u = Qt(p), f = new k(0, 1, 0), g = 5, h = t + 3 * 25.4, b = [];
3367
- for (let R = o + g; R < h; R += g) {
3368
- const W = ar(u, p, new k(0, R, 0), f);
3377
+ const u = s ?? e, p = Qt(u), f = new k(0, 1, 0), h = 5, g = t + 3 * 25.4, b = [];
3378
+ for (let E = o + h; E < g; E += h) {
3379
+ const W = cr(p, u, new k(0, E, 0), f);
3369
3380
  W > 0 && b.push({
3370
- y: R,
3381
+ y: E,
3371
3382
  circ: W
3372
3383
  });
3373
3384
  }
3374
3385
  if (b.length < 5) return null;
3375
- const A = t - o, v = o + A * 0.3, x = o + A * 0.7, F = b.filter((R) => R.y >= v && R.y <= x);
3386
+ const A = t - o, v = o + A * 0.3, x = o + A * 0.7, F = b.filter((E) => E.y >= v && E.y <= x);
3376
3387
  if (F.length < 3) return null;
3377
- const S = F.map((R) => R.circ).sort((R, W) => R - W), C = S[Math.floor(S.length / 2)], z = Math.max(...b.map((R) => R.circ));
3388
+ const S = F.map((E) => E.circ).sort((E, W) => E - W), C = S[Math.floor(S.length / 2)], M = Math.max(...b.map((E) => E.circ));
3378
3389
  return {
3379
3390
  circumferences: b,
3380
3391
  baseline: C,
3381
- maxCirc: z
3392
+ maxCirc: M
3382
3393
  };
3383
3394
  }, [
3384
3395
  e,
@@ -3389,12 +3400,12 @@ let __tla = (async () => {
3389
3400
  const { circumferences: d, baseline: a, maxCirc: r } = l, c = n * 0.3 / r;
3390
3401
  return y("group", {
3391
3402
  children: [
3392
- d.map(({ y: p, circ: u }, f) => {
3393
- const g = u / a, w = g > 1.6 ? "#ff4444" : g > 1.3 ? "#ffcc00" : "#22cc66", h = u * c;
3403
+ d.map(({ y: u, circ: p }, f) => {
3404
+ const h = p / a, w = h > 1.6 ? "#ff4444" : h > 1.3 ? "#ffcc00" : "#22cc66", g = p * c;
3394
3405
  return i(ve, {
3395
3406
  points: [
3396
- new k(-h, p, 0),
3397
- new k(h, p, 0)
3407
+ new k(-g, u, 0),
3408
+ new k(g, u, 0)
3398
3409
  ],
3399
3410
  color: w,
3400
3411
  lineWidth: 1.5,
@@ -3403,13 +3414,13 @@ let __tla = (async () => {
3403
3414
  }, f);
3404
3415
  }),
3405
3416
  (() => {
3406
- const p = a * 1.6 * c, u = d[0].y, f = d[d.length - 1].y;
3417
+ const u = a * 1.6 * c, p = d[0].y, f = d[d.length - 1].y;
3407
3418
  return y(_e, {
3408
3419
  children: [
3409
3420
  i(ve, {
3410
3421
  points: [
3411
- new k(-p, u, 0),
3412
- new k(-p, f, 0)
3422
+ new k(-u, p, 0),
3423
+ new k(-u, f, 0)
3413
3424
  ],
3414
3425
  color: "#ff4444",
3415
3426
  lineWidth: 1,
@@ -3421,8 +3432,8 @@ let __tla = (async () => {
3421
3432
  }),
3422
3433
  i(ve, {
3423
3434
  points: [
3424
- new k(p, u, 0),
3425
- new k(p, f, 0)
3435
+ new k(u, p, 0),
3436
+ new k(u, f, 0)
3426
3437
  ],
3427
3438
  color: "#ff4444",
3428
3439
  lineWidth: 1,
@@ -3438,7 +3449,7 @@ let __tla = (async () => {
3438
3449
  ]
3439
3450
  });
3440
3451
  }
3441
- function Yr({ componentDebug: e }) {
3452
+ function Zr({ componentDebug: e }) {
3442
3453
  return i("group", {
3443
3454
  children: e.geometries.map((o, t) => {
3444
3455
  const n = e.colors[t] ?? "#888888", s = t === e.innerIdx;
@@ -3502,14 +3513,14 @@ let __tla = (async () => {
3502
3513
  })
3503
3514
  });
3504
3515
  }
3505
- function Zr({ geometry: e, aoData: o }) {
3516
+ function Ur({ geometry: e, aoData: o }) {
3506
3517
  const t = te(() => {
3507
3518
  const n = e.toNonIndexed(), s = n.getAttribute("position"), l = o.length, d = s.count, a = new Float32Array(d * 3);
3508
3519
  for (let r = 0; r < l && r * 3 + 2 < d; r++) {
3509
- const c = o[r], p = c, u = c < 0.5 ? 0.8 - c * 1.2 : 0.2 * (1 - c), f = 1 - c;
3510
- for (let g = 0; g < 3; g++) {
3511
- const w = (r * 3 + g) * 3;
3512
- a[w] = p, a[w + 1] = u, a[w + 2] = f;
3520
+ const c = o[r], u = c, p = c < 0.5 ? 0.8 - c * 1.2 : 0.2 * (1 - c), f = 1 - c;
3521
+ for (let h = 0; h < 3; h++) {
3522
+ const w = (r * 3 + h) * 3;
3523
+ a[w] = u, a[w + 1] = p, a[w + 2] = f;
3513
3524
  }
3514
3525
  }
3515
3526
  return n.setAttribute("color", new U.Float32BufferAttribute(a, 3)), n;
@@ -3531,7 +3542,7 @@ let __tla = (async () => {
3531
3542
  })
3532
3543
  });
3533
3544
  }
3534
- function Ur({ mesh: e, layers: o, landmarkPoints: t, componentDebug: n, aoData: s, aoGeometry: l, measurementGeometry: d }) {
3545
+ function qr({ mesh: e, layers: o, landmarkPoints: t, componentDebug: n, aoData: s, aoGeometry: l, measurementGeometry: d }) {
3535
3546
  const a = e.geometry, r = te(() => a.getAttribute("position") ? eo(a) : null, [
3536
3547
  a
3537
3548
  ]), c = te(() => !t || t.length < 2 ? null : {
@@ -3542,20 +3553,20 @@ let __tla = (async () => {
3542
3553
  ]);
3543
3554
  return y("group", {
3544
3555
  children: [
3545
- o.pcaAxes && r && i(Hr, {
3556
+ o.pcaAxes && r && i(Nr, {
3546
3557
  pca: r
3547
3558
  }),
3548
- o.obb && r && i(Nr, {
3559
+ o.obb && r && i(Vr, {
3549
3560
  pca: r
3550
3561
  }),
3551
- o.obbAxis && r && i(Xr, {
3562
+ o.obbAxis && r && i(Yr, {
3552
3563
  pca: r,
3553
3564
  modelSize: r.halfExtents[0] ? Math.max(...r.halfExtents) * 2 : 100
3554
3565
  }),
3555
- o.shellComponents && n && i(Yr, {
3566
+ o.shellComponents && n && i(Zr, {
3556
3567
  componentDebug: n
3557
3568
  }),
3558
- o.ambientOcclusion && s && s.length > 0 && i(Zr, {
3569
+ o.ambientOcclusion && s && s.length > 0 && i(Ur, {
3559
3570
  geometry: l ?? a,
3560
3571
  aoData: s
3561
3572
  }),
@@ -3577,17 +3588,17 @@ let __tla = (async () => {
3577
3588
  depthWrite: false
3578
3589
  })
3579
3590
  }),
3580
- o.landmarkAxis && c && i(Vr, {
3591
+ o.landmarkAxis && c && i(jr, {
3581
3592
  redPoint: c.red,
3582
3593
  greenPoint: c.green
3583
3594
  }),
3584
- o.iterativePCA && c && i(jr, {
3595
+ o.iterativePCA && c && i(Gr, {
3585
3596
  geometry: a,
3586
3597
  redY: c.red.y,
3587
3598
  greenY: c.green.y,
3588
3599
  modelSize: (r == null ? void 0 : r.halfExtents[0]) ? Math.max(...r.halfExtents) * 2 : 100
3589
3600
  }),
3590
- o.fullRegionPCA && c && i(Gr, {
3601
+ o.fullRegionPCA && c && i(Xr, {
3591
3602
  geometry: a,
3592
3603
  redY: c.red.y,
3593
3604
  greenY: c.green.y,
@@ -3596,7 +3607,7 @@ let __tla = (async () => {
3596
3607
  ]
3597
3608
  });
3598
3609
  }
3599
- function qr({ mesh: e }) {
3610
+ function Jr({ mesh: e }) {
3600
3611
  const o = e.geometry, t = te(() => {
3601
3612
  if (!o.getAttribute("position")) return null;
3602
3613
  const l = eo(o), d = l.axes[0], a = l.halfExtents[0] * 1.3;
@@ -3682,10 +3693,10 @@ let __tla = (async () => {
3682
3693
  color: "#00ffff",
3683
3694
  group: "Alignment"
3684
3695
  }
3685
- ], Jr = [
3696
+ ], Qr = [
3686
3697
  ...new Set(to.map((e) => e.group))
3687
3698
  ];
3688
- function Qr({ layers: e, onToggleLayer: o, isDoubleShell: t }) {
3699
+ function ei({ layers: e, onToggleLayer: o, isDoubleShell: t }) {
3689
3700
  return y("div", {
3690
3701
  style: {
3691
3702
  position: "absolute",
@@ -3714,7 +3725,7 @@ let __tla = (async () => {
3714
3725
  },
3715
3726
  children: "Debug Layers"
3716
3727
  }),
3717
- Jr.map((n) => {
3728
+ Qr.map((n) => {
3718
3729
  const s = to.filter((l) => l.group === n && !(l.hideWhenDoubleShell && t));
3719
3730
  return s.length === 0 ? null : y("div", {
3720
3731
  children: [
@@ -3775,8 +3786,8 @@ let __tla = (async () => {
3775
3786
  ]
3776
3787
  });
3777
3788
  }
3778
- const ei = ({ config: e, spacingType: o, scanUrl: t, formMeasurements: n, onComplete: s, isDebugUser: l = false, onAnalyticsEvent: d, wasmModule: a, autoProcessOnTwoPoints: r = false }) => {
3779
- const [c, p] = B(null), [u, f] = B(0), [g, w] = B(false), [h, b] = B(false), [A, v] = B(""), [x, F] = B("3D"), [S, C] = B(o === "AK" ? 2 : 1), [z, R] = B(false), [W, N] = B(null), [P, I] = B(o ?? null), [_, $] = B("cm"), [X, oe] = B(false), [ce, se] = B(""), [J, ae] = B("mm"), [q, ge] = B(false), [re, E] = B(false), [H, ne] = B(false), [Q, j] = B(null), [Y, ue] = B(null), [ie, pe] = B(null), [he, Se] = B(false), [T, Le] = B([]), [Pe, Ie] = B(null), [ye, Fe] = B(null), [kt, Pt] = B(null), [it, tn] = B(null), [oo, nn] = B(false), [st, on] = B(null), [Ft, Ee] = B(null), [We, ro] = B(false), [rn, io] = B(Tr), [He, sn] = B("obj"), [ke, Lt] = B(n), [Ne, Dt] = B(true), [Ke, Je] = B(false), [_t, ln] = B(false), [lt, at] = B(false), Ye = fe(false), [so, an] = B(false), [Et, cn] = B(() => {
3789
+ const ti = ({ config: e, spacingType: o, scanUrl: t, formMeasurements: n, onComplete: s, isDebugUser: l = false, onAnalyticsEvent: d, wasmModule: a, autoProcessOnTwoPoints: r = false }) => {
3790
+ const [c, u] = $(null), [p, f] = $(0), [h, w] = $(false), [g, b] = $(false), [A, v] = $(""), [x, F] = $("3D"), [S, C] = $(o === "AK" ? 2 : 1), [M, E] = $(false), [W, N] = $(null), [P, I] = $(o ?? null), [_, B] = $("cm"), [X, oe] = $(false), [ce, se] = $(""), [J, ae] = $("mm"), [q, ge] = $(false), [re, R] = $(false), [H, ne] = $(false), [Q, j] = $(null), [K, ue] = $(null), [ie, pe] = $(null), [he, Se] = $(false), [T, Le] = $([]), [Pe, We] = $(null), [ye, Fe] = $(null), [Pt, Ft] = $(null), [it, tn] = $(null), [oo, nn] = $(false), [st, on] = $(null), [Lt, Re] = $(null), [$e, ro] = $(false), [rn, io] = $(Or), [He, sn] = $("obj"), [ke, Dt] = $(n), [Ne, _t] = $(true), [Ye, Je] = $(false), [Rt, ln] = $(false), [lt, at] = $(false), Ke = fe(false), [so, an] = $(false), [Et, cn] = $(() => {
3780
3791
  try {
3781
3792
  return localStorage.getItem("gm_helpTipDismissed") !== "1";
3782
3793
  } catch {
@@ -3802,81 +3813,81 @@ let __tla = (async () => {
3802
3813
  }, [
3803
3814
  q
3804
3815
  ]);
3805
- const Rt = fe(null), [Ve, lo] = B(0);
3816
+ const It = fe(null), [Ve, lo] = $(0);
3806
3817
  Z(() => {
3807
- if (!Rt.current) return;
3808
- const m = new ResizeObserver((M) => {
3809
- for (const D of M) lo(D.contentRect.width);
3818
+ if (!It.current) return;
3819
+ const m = new ResizeObserver((z) => {
3820
+ for (const D of z) lo(D.contentRect.width);
3810
3821
  });
3811
- return m.observe(Rt.current), () => m.disconnect();
3822
+ return m.observe(It.current), () => m.disconnect();
3812
3823
  }, []);
3813
- const [Ce, ao] = B(null), [co, fo] = B(void 0), [uo, po] = B(void 0), [ho, go] = B(void 0), [mo, xo] = B(void 0), [dn] = B("#c8c8c8"), [bo] = B(1), [Te, yo] = B(false), [It, fn] = B([]), ct = fe(null), je = fe(null), un = fe(false), dt = fe(false), wo = fe(null), Wt = fe(null), Bt = fe(null), Qe = de(async (m) => {
3824
+ const [Ce, ao] = $(null), [co, fo] = $(void 0), [uo, po] = $(void 0), [ho, go] = $(void 0), [mo, xo] = $(void 0), [dn] = $("#c8c8c8"), [bo] = $(1), [Te, yo] = $(false), [Wt, fn] = $([]), ct = fe(null), je = fe(null), un = fe(false), dt = fe(false), wo = fe(null), $t = fe(null), Bt = fe(null), Qe = de(async (m) => {
3814
3825
  if (!Bt.current) return;
3815
- const M = (m == null ? void 0 : m.restoreView) ?? true;
3826
+ const z = (m == null ? void 0 : m.restoreView) ?? true;
3816
3827
  try {
3817
3828
  const D = Bt.current, L = () => {
3818
3829
  const O = D.querySelector("canvas");
3819
3830
  if (!O) return;
3820
- const ee = D.getBoundingClientRect(), me = O.width, be = O.height, ze = me / ee.width, nt = be / ee.height, gt = document.createElement("canvas");
3831
+ const ee = D.getBoundingClientRect(), me = O.width, be = O.height, Me = me / ee.width, nt = be / ee.height, gt = document.createElement("canvas");
3821
3832
  gt.width = me, gt.height = be;
3822
- const Me = gt.getContext("2d");
3823
- return Me.drawImage(O, 0, 0), D.querySelectorAll("[style*='pointer-events']").forEach((Lo) => {
3833
+ const ze = gt.getContext("2d");
3834
+ return ze.drawImage(O, 0, 0), D.querySelectorAll("[style*='pointer-events']").forEach((Lo) => {
3824
3835
  const vn = Lo;
3825
3836
  if (vn.hasAttribute("data-finalizing-overlay")) return;
3826
3837
  const Sn = vn.querySelectorAll("div[style*='background']");
3827
3838
  Sn.length !== 0 && Sn.forEach((Ze) => {
3828
3839
  var _a;
3829
- const Re = Ze.getBoundingClientRect();
3830
- if (Re.width === 0 || Re.height === 0) return;
3831
- let Xt = 0, ot = Ze;
3840
+ const Ie = Ze.getBoundingClientRect();
3841
+ if (Ie.width === 0 || Ie.height === 0) return;
3842
+ let Yt = 0, ot = Ze;
3832
3843
  for (; ot && ot !== D; ) {
3833
3844
  const bt = (ot.style.transform || "").match(/rotate\((-?\d+)deg\)/);
3834
3845
  if (bt) {
3835
- Xt = parseFloat(bt[1]);
3846
+ Yt = parseFloat(bt[1]);
3836
3847
  break;
3837
3848
  }
3838
3849
  ot = ot.parentElement;
3839
3850
  }
3840
- const Cn = (Re.left + Re.width / 2 - ee.left) * ze, An = (Re.top + Re.height / 2 - ee.top) * nt, mt = Math.abs(Xt) > 1, zn = (mt ? Re.height : Re.width) * ze, Mn = (mt ? Re.width : Re.height) * nt;
3841
- Me.save(), Me.translate(Cn, An), mt && Me.rotate(Xt * Math.PI / 180);
3851
+ const Cn = (Ie.left + Ie.width / 2 - ee.left) * Me, An = (Ie.top + Ie.height / 2 - ee.top) * nt, mt = Math.abs(Yt) > 1, Mn = (mt ? Ie.height : Ie.width) * Me, zn = (mt ? Ie.width : Ie.height) * nt;
3852
+ ze.save(), ze.translate(Cn, An), mt && ze.rotate(Yt * Math.PI / 180);
3842
3853
  const Do = Ze.style.backgroundColor || "rgba(0,0,0,0.75)";
3843
- Me.fillStyle = Do;
3844
- const _o = 4 * ze;
3845
- Me.beginPath(), Me.roundRect(-zn / 2, -Mn / 2, zn, Mn, _o), Me.fill();
3854
+ ze.fillStyle = Do;
3855
+ const _o = 4 * Me;
3856
+ ze.beginPath(), ze.roundRect(-Mn / 2, -zn / 2, Mn, zn, _o), ze.fill();
3846
3857
  const kn = ((_a = Ze.textContent) == null ? void 0 : _a.trim()) || "";
3847
3858
  if (kn) {
3848
3859
  const xt = window.getComputedStyle(Ze), bt = parseFloat(xt.fontSize || "14") * nt;
3849
- Me.font = `${xt.fontWeight || "normal"} ${bt}px monospace`, Me.fillStyle = xt.color || "#fff", Me.textAlign = "center", Me.textBaseline = "middle";
3860
+ ze.font = `${xt.fontWeight || "normal"} ${bt}px monospace`, ze.fillStyle = xt.color || "#fff", ze.textAlign = "center", ze.textBaseline = "middle";
3850
3861
  const Pn = Ze.querySelectorAll("span");
3851
3862
  Pn.length > 0 && !mt ? Pn.forEach((Kt) => {
3852
3863
  const rt = Kt.getBoundingClientRect();
3853
3864
  if (rt.width === 0) return;
3854
- const Eo = (rt.left + rt.width / 2 - ee.left) * ze - Cn, Ro = (rt.top + rt.height / 2 - ee.top) * nt - An, Yt = window.getComputedStyle(Kt), Io = parseFloat(Yt.fontSize) * nt;
3855
- Me.font = `${Yt.fontWeight || "normal"} ${Io}px monospace`, Me.fillStyle = Yt.color || "#fff", Me.fillText(Kt.textContent || "", Eo, Ro);
3856
- }) : Me.fillText(kn, 0, 0);
3865
+ const Ro = (rt.left + rt.width / 2 - ee.left) * Me - Cn, Eo = (rt.top + rt.height / 2 - ee.top) * nt - An, Zt = window.getComputedStyle(Kt), Io = parseFloat(Zt.fontSize) * nt;
3866
+ ze.font = `${Zt.fontWeight || "normal"} ${Io}px monospace`, ze.fillStyle = Zt.color || "#fff", ze.fillText(Kt.textContent || "", Ro, Eo);
3867
+ }) : ze.fillText(kn, 0, 0);
3857
3868
  }
3858
- Me.restore();
3869
+ ze.restore();
3859
3870
  });
3860
3871
  }), gt.toDataURL("image/png");
3861
3872
  };
3862
- Wt.current && Wt.current(), await new Promise((O) => requestAnimationFrame(() => requestAnimationFrame(O)));
3863
- const K = L();
3873
+ $t.current && $t.current(), await new Promise((O) => requestAnimationFrame(() => requestAnimationFrame(O)));
3874
+ const Y = L();
3864
3875
  F("2D"), await new Promise((O) => setTimeout(O, 150)), await new Promise((O) => requestAnimationFrame(() => requestAnimationFrame(O)));
3865
3876
  const G = L();
3866
- return M && F("3D"), !K || !G ? void 0 : {
3867
- frontal_view_png: K,
3877
+ return z && F("3D"), !Y || !G ? void 0 : {
3878
+ frontal_view_png: Y,
3868
3879
  side_view_png: G
3869
3880
  };
3870
3881
  } catch {
3871
3882
  return;
3872
3883
  }
3873
3884
  }, []), Ae = de((m) => {
3874
- const M = /* @__PURE__ */ new Date(), D = `${String(M.getHours()).padStart(2, "0")}:${String(M.getMinutes()).padStart(2, "0")}:${String(M.getSeconds()).padStart(2, "0")}.${String(M.getMilliseconds()).padStart(3, "0")}`;
3885
+ const z = /* @__PURE__ */ new Date(), D = `${String(z.getHours()).padStart(2, "0")}:${String(z.getMinutes()).padStart(2, "0")}:${String(z.getSeconds()).padStart(2, "0")}.${String(z.getMilliseconds()).padStart(3, "0")}`;
3875
3886
  fn((L) => [
3876
3887
  ...L.slice(-200),
3877
3888
  `[${D}] ${m}`
3878
3889
  ]);
3879
- }, []), { landmarkPoints: V, clearLandmarkPoints: vo, addLandmarkPoint: pn, removeLandmarkPoint: hn, undoLastLandmarkPoint: $t, updateLandmarkPositions: ft, setAligned: gn, isAligned: le, setCut: mn, isCut: Tt, reset: ut } = en();
3890
+ }, []), { landmarkPoints: V, clearLandmarkPoints: vo, addLandmarkPoint: pn, removeLandmarkPoint: hn, undoLastLandmarkPoint: Tt, updateLandmarkPositions: ft, setAligned: gn, isAligned: le, setCut: mn, isCut: Ot, reset: ut } = en();
3880
3891
  Z(() => {
3881
3892
  ut();
3882
3893
  }, [
@@ -3898,32 +3909,32 @@ let __tla = (async () => {
3898
3909
  l,
3899
3910
  Ae
3900
3911
  ]), Z(() => {
3901
- const m = (M) => {
3912
+ const m = (z) => {
3902
3913
  var _a;
3903
- if (M.key !== "z" && M.key !== "Z" || !(M.ctrlKey || M.metaKey) || M.shiftKey || M.altKey) return;
3904
- const D = ((_a = M.composedPath) == null ? void 0 : _a.call(M)[0]) ?? M.target, L = D == null ? void 0 : D.tagName;
3905
- L === "INPUT" || L === "TEXTAREA" || (D == null ? void 0 : D.isContentEditable) || !c || le || V.length === 0 || (M.preventDefault(), $t(), Ae(`UNDO: removed landmark point ${V.length - 1}`));
3914
+ if (z.key !== "z" && z.key !== "Z" || !(z.ctrlKey || z.metaKey) || z.shiftKey || z.altKey) return;
3915
+ const D = ((_a = z.composedPath) == null ? void 0 : _a.call(z)[0]) ?? z.target, L = D == null ? void 0 : D.tagName;
3916
+ L === "INPUT" || L === "TEXTAREA" || (D == null ? void 0 : D.isContentEditable) || !c || le || V.length === 0 || (z.preventDefault(), Tt(), Ae(`UNDO: removed landmark point ${V.length - 1}`));
3906
3917
  };
3907
3918
  return document.addEventListener("keydown", m, true), () => document.removeEventListener("keydown", m, true);
3908
3919
  }, [
3909
3920
  c,
3910
3921
  le,
3911
3922
  V.length,
3912
- $t,
3923
+ Tt,
3913
3924
  Ae
3914
3925
  ]), Z(() => {
3915
- l && Tt && Ae("STATE: mesh cut");
3926
+ l && Ot && Ae("STATE: mesh cut");
3916
3927
  }, [
3917
- Tt,
3928
+ Ot,
3918
3929
  l,
3919
3930
  Ae
3920
3931
  ]);
3921
3932
  const So = de(() => {
3922
3933
  if (!c) return;
3923
3934
  const m = (L) => {
3924
- const K = L.clone();
3925
- K.scale(-1, 1, 1);
3926
- const G = K.getIndex();
3935
+ const Y = L.clone();
3936
+ Y.scale(-1, 1, 1);
3937
+ const G = Y.getIndex();
3927
3938
  if (G) {
3928
3939
  const O = G.array;
3929
3940
  for (let ee = 0; ee < O.length; ee += 3) {
@@ -3932,19 +3943,19 @@ let __tla = (async () => {
3932
3943
  }
3933
3944
  G.needsUpdate = true;
3934
3945
  } else {
3935
- const O = K.getAttribute("position"), ee = O.array;
3946
+ const O = Y.getAttribute("position"), ee = O.array;
3936
3947
  for (let me = 0; me < ee.length; me += 9) for (let be = 0; be < 3; be++) {
3937
- const ze = ee[me + be];
3938
- ee[me + be] = ee[me + 6 + be], ee[me + 6 + be] = ze;
3948
+ const Me = ee[me + be];
3949
+ ee[me + be] = ee[me + 6 + be], ee[me + 6 + be] = Me;
3939
3950
  }
3940
3951
  O.needsUpdate = true;
3941
3952
  }
3942
- return K.computeVertexNormals(), K.computeBoundingBox(), K.computeBoundingSphere(), K;
3943
- }, M = m(c.geometry), D = new U.Mesh(M, c.material);
3944
- if (p(D), ie && pe(m(ie)), Y && ue(m(Y)), Pe) {
3953
+ return Y.computeVertexNormals(), Y.computeBoundingBox(), Y.computeBoundingSphere(), Y;
3954
+ }, z = m(c.geometry), D = new U.Mesh(z, c.material);
3955
+ if (u(D), ie && pe(m(ie)), K && ue(m(K)), Pe) {
3945
3956
  const L = new Float32Array(Pe.allLoopPoints);
3946
- for (let K = 0; K < L.length; K += 3) L[K] = -L[K];
3947
- Ie({
3957
+ for (let Y = 0; Y < L.length; Y += 3) L[Y] = -L[Y];
3958
+ We({
3948
3959
  ...Pe,
3949
3960
  allLoopPoints: L
3950
3961
  });
@@ -3957,7 +3968,7 @@ let __tla = (async () => {
3957
3968
  }, [
3958
3969
  c,
3959
3970
  ie,
3960
- Y,
3971
+ K,
3961
3972
  Pe,
3962
3973
  V,
3963
3974
  ft,
@@ -3966,7 +3977,7 @@ let __tla = (async () => {
3966
3977
  Z(() => {
3967
3978
  ct.current && (ct.current.scrollTop = ct.current.scrollHeight);
3968
3979
  }, [
3969
- It
3980
+ Wt
3970
3981
  ]);
3971
3982
  const Oe = te(() => ie ? new U.Mesh(ie) : null, [
3972
3983
  ie
@@ -3980,19 +3991,19 @@ let __tla = (async () => {
3980
3991
  }, [
3981
3992
  ie
3982
3993
  ]), Z(() => () => {
3983
- Y && Y.dispose();
3994
+ K && K.dispose();
3984
3995
  }, [
3985
- Y
3996
+ K
3986
3997
  ]), Z(() => () => {
3987
3998
  W && W.geometry.dispose();
3988
3999
  }, [
3989
4000
  W
3990
4001
  ]), Z(() => {
3991
- n && Lt(n);
4002
+ n && Dt(n);
3992
4003
  }, [
3993
4004
  n
3994
4005
  ]), Z(() => {
3995
- n || Lt(void 0);
4006
+ n || Dt(void 0);
3996
4007
  }, [
3997
4008
  S
3998
4009
  ]);
@@ -4008,11 +4019,11 @@ let __tla = (async () => {
4008
4019
  measurement_source: "scan_derived",
4009
4020
  is_double_wall: re,
4010
4021
  is_unit_converted: false,
4011
- form_measurements: (ke == null ? void 0 : ke.filter((M) => M != null)) ?? null,
4012
- scan_measurements: T.map((M) => +(M.modifiedValue ?? M.originalValue).toFixed(1)),
4013
- measurement_variance: ke ? T.map((M, D) => {
4022
+ form_measurements: (ke == null ? void 0 : ke.filter((z) => z != null)) ?? null,
4023
+ scan_measurements: T.map((z) => +(z.modifiedValue ?? z.originalValue).toFixed(1)),
4024
+ measurement_variance: ke ? T.map((z, D) => {
4014
4025
  const L = ke[D];
4015
- return L == null ? null : +((M.modifiedValue ?? M.originalValue) - L).toFixed(1);
4026
+ return L == null ? null : +((z.modifiedValue ?? z.originalValue) - L).toFixed(1);
4016
4027
  }) : null,
4017
4028
  frontal_height: m !== null ? +m.toFixed(1) : null
4018
4029
  });
@@ -4024,58 +4035,58 @@ let __tla = (async () => {
4024
4035
  }, [
4025
4036
  a
4026
4037
  ]);
4027
- const et = de((m, M) => {
4038
+ const et = de((m, z) => {
4028
4039
  m.computeBoundingBox();
4029
4040
  const D = m.boundingBox, L = new k();
4030
4041
  D.getCenter(L), m.translate(-L.x, -L.y, -L.z), m.computeBoundingBox();
4031
- const K = m.boundingBox, G = new k();
4032
- K.getSize(G), f(Math.max(G.x, G.y, G.z));
4042
+ const Y = m.boundingBox, G = new k();
4043
+ Y.getSize(G), f(Math.max(G.x, G.y, G.z));
4033
4044
  const O = new U.Mesh(m, new U.MeshStandardMaterial({
4034
4045
  color: 8947848,
4035
4046
  side: U.DoubleSide
4036
4047
  }));
4037
- p(O), ae(M), ge(true), ne(false), dt.current = false;
4038
- }, []), Be = de(async (m, M) => {
4039
- Ee(null);
4040
- const D = M.toLowerCase(), L = D.endsWith(".stl"), K = D.endsWith(".obj"), G = D.endsWith(".aop");
4041
- if (!K && !L && !G) {
4042
- Ee("Unsupported file format. Please use OBJ, STL, or AOP.");
4048
+ u(O), ae(z), ge(true), ne(false), dt.current = false;
4049
+ }, []), Be = de(async (m, z) => {
4050
+ Re(null);
4051
+ const D = z.toLowerCase(), L = D.endsWith(".stl"), Y = D.endsWith(".obj"), G = D.endsWith(".aop");
4052
+ if (!Y && !L && !G) {
4053
+ Re("Unsupported file format. Please use OBJ, STL, or AOP.");
4043
4054
  return;
4044
4055
  }
4045
- sn(L ? "stl" : G ? "aop" : "obj"), b(true), v("Processing file..."), Ae(`FILE_LOAD: ${M} (${L ? "STL" : G ? "AOP" : "OBJ"})`);
4056
+ sn(L ? "stl" : G ? "aop" : "obj"), b(true), v("Processing file..."), Ae(`FILE_LOAD: ${z} (${L ? "STL" : G ? "AOP" : "OBJ"})`);
4046
4057
  try {
4047
4058
  let O;
4048
4059
  if (L) {
4049
4060
  v("Converting STL...");
4050
4061
  const be = new Blob([
4051
4062
  m
4052
- ]), ze = new File([
4063
+ ]), Me = new File([
4053
4064
  be
4054
- ], M);
4055
- O = await _n(ze);
4065
+ ], z);
4066
+ O = await _n(Me);
4056
4067
  } else if (G) {
4057
4068
  v("Extracting AOP...");
4058
4069
  const be = new Blob([
4059
4070
  m
4060
- ]), ze = new File([
4071
+ ]), Me = new File([
4061
4072
  be
4062
- ], M);
4063
- O = await rr(ze);
4073
+ ], z);
4074
+ O = await ir(Me);
4064
4075
  } else O = typeof m == "string" ? m : new TextDecoder().decode(m);
4065
- const ee = performance.now(), me = je.current ? await tr(O, je.current, (be) => {
4076
+ const ee = performance.now(), me = je.current ? await nr(O, je.current, (be) => {
4066
4077
  v(be), Ae(`PREPROCESS: ${be}`);
4067
4078
  }) : null;
4068
- if (me) Ae(`PREPROCESS: done in ${(performance.now() - ee).toFixed(0)}ms \u2014 unit=${me.detectedUnit}, scaled=${me.wasScaled}`), e.showAmputationModal && !o ? (N(me), R(true)) : et(me.geometry, me.detectedUnit);
4079
+ if (me) Ae(`PREPROCESS: done in ${(performance.now() - ee).toFixed(0)}ms \u2014 unit=${me.detectedUnit}, scaled=${me.wasScaled}`), e.showAmputationModal && !o ? (N(me), E(true)) : et(me.geometry, me.detectedUnit);
4069
4080
  else {
4070
4081
  console.warn("[fab-one]", "WASM processing returned no result \u2014 using raw OBJ fallback (no weld/hole-fill). Mesh may render low-poly/broken."), v("Using fallback loader...");
4071
- const be = nr(O);
4082
+ const be = or(O);
4072
4083
  be ? e.showAmputationModal && !o ? (N({
4073
4084
  geometry: be,
4074
4085
  detectedUnit: "mm"
4075
- }), R(true)) : et(be, "mm") : Ee("Failed to parse the mesh.");
4086
+ }), E(true)) : et(be, "mm") : Re("Failed to parse the mesh.");
4076
4087
  }
4077
4088
  } catch (O) {
4078
- Ee(O instanceof Error ? O.message : "Failed to process the mesh file.");
4089
+ Re(O instanceof Error ? O.message : "Failed to process the mesh file.");
4079
4090
  } finally {
4080
4091
  b(false), v("");
4081
4092
  }
@@ -4090,18 +4101,18 @@ let __tla = (async () => {
4090
4101
  (async () => {
4091
4102
  b(true), v("Loading scan...");
4092
4103
  try {
4093
- const M = await fetch(t);
4094
- if (!M.ok) throw new Error(`Failed to download scan: ${M.status}`);
4095
- const L = new URL(t).pathname.split("/").pop() || "scan.obj", K = L.toLowerCase();
4096
- if (K.endsWith(".stl") || K.endsWith(".aop")) {
4097
- const O = await M.arrayBuffer();
4104
+ const z = await fetch(t);
4105
+ if (!z.ok) throw new Error(`Failed to download scan: ${z.status}`);
4106
+ const L = new URL(t).pathname.split("/").pop() || "scan.obj", Y = L.toLowerCase();
4107
+ if (Y.endsWith(".stl") || Y.endsWith(".aop")) {
4108
+ const O = await z.arrayBuffer();
4098
4109
  await Be(O, L);
4099
4110
  } else {
4100
- const O = await M.text();
4111
+ const O = await z.text();
4101
4112
  await Be(O, L);
4102
4113
  }
4103
- } catch (M) {
4104
- Ee(M instanceof Error ? M.message : "Failed to load scan from URL."), b(false), v("");
4114
+ } catch (z) {
4115
+ Re(z instanceof Error ? z.message : "Failed to load scan from URL."), b(false), v("");
4105
4116
  }
4106
4117
  })();
4107
4118
  }, [
@@ -4112,36 +4123,36 @@ let __tla = (async () => {
4112
4123
  m.preventDefault(), w(true);
4113
4124
  }, []), Ao = de((m) => {
4114
4125
  m.preventDefault(), w(false);
4115
- }, []), zo = de(async (m) => {
4126
+ }, []), Mo = de(async (m) => {
4116
4127
  if (m.preventDefault(), w(false), !Te) {
4117
- Ee("WASM module is still loading. Please wait.");
4128
+ Re("WASM module is still loading. Please wait.");
4118
4129
  return;
4119
4130
  }
4120
- const M = m.dataTransfer.files[0];
4121
- if (!M) return;
4122
- const D = M.name.toLowerCase();
4131
+ const z = m.dataTransfer.files[0];
4132
+ if (!z) return;
4133
+ const D = z.name.toLowerCase();
4123
4134
  if (!D.endsWith(".obj") && !D.endsWith(".stl") && !D.endsWith(".aop")) {
4124
- Ee("Please drop an OBJ, STL, or AOP file.");
4135
+ Re("Please drop an OBJ, STL, or AOP file.");
4125
4136
  return;
4126
4137
  }
4127
- if (D.endsWith(".aop")) await Be(await M.arrayBuffer(), M.name);
4138
+ if (D.endsWith(".aop")) await Be(await z.arrayBuffer(), z.name);
4128
4139
  else if (D.endsWith(".stl")) {
4129
4140
  sn("stl"), b(true), v("Converting STL...");
4130
4141
  try {
4131
- const L = await _n(M);
4132
- await Be(L, M.name.replace(/\.stl$/i, ".obj"));
4142
+ const L = await _n(z);
4143
+ await Be(L, z.name.replace(/\.stl$/i, ".obj"));
4133
4144
  } catch (L) {
4134
- Ee(L instanceof Error ? L.message : "Failed to process STL file."), b(false), v("");
4145
+ Re(L instanceof Error ? L.message : "Failed to process STL file."), b(false), v("");
4135
4146
  }
4136
4147
  } else {
4137
- const L = await M.text();
4138
- await Be(L, M.name);
4148
+ const L = await z.text();
4149
+ await Be(L, z.name);
4139
4150
  }
4140
4151
  }, [
4141
4152
  Te,
4142
4153
  Be
4143
- ]), Mo = de((m) => {
4144
- I(m), C(m === "AK" ? 2 : 1), R(false), W && (et(W.geometry, W.detectedUnit), N(null)), d == null ? void 0 : d("file_loaded", {
4154
+ ]), zo = de((m) => {
4155
+ I(m), C(m === "AK" ? 2 : 1), E(false), W && (et(W.geometry, W.detectedUnit), N(null)), d == null ? void 0 : d("file_loaded", {
4145
4156
  spacing_type: m,
4146
4157
  file_format: He,
4147
4158
  is_double_wall: false
@@ -4155,28 +4166,28 @@ let __tla = (async () => {
4155
4166
  Z(() => {
4156
4167
  if (!c || V.length !== 1 || !je.current || dt.current) return;
4157
4168
  dt.current = true;
4158
- const m = V[0], M = je.current, D = c.geometry, { positions: L, indices: K } = Ct(D), G = new Float32Array([
4169
+ const m = V[0], z = je.current, D = c.geometry, { positions: L, indices: Y } = At(D), G = new Float32Array([
4159
4170
  m.position.x,
4160
4171
  m.position.y,
4161
4172
  m.position.z
4162
- ]), O = M.detect_shell(L, K, G, 40), ee = O.details(), me = O.is_double_shell();
4163
- Ae(`SHELL_DETECT: ${me ? "DOUBLE" : "SINGLE"} \u2014 ${ee}`), me && (E(true), Se(true), Ae(`SHELL_DETECT: double shell, thickness=${O.thickness().toFixed(1)}mm`));
4173
+ ]), O = z.detect_shell(L, Y, G, 40), ee = O.details(), me = O.is_double_shell();
4174
+ Ae(`SHELL_DETECT: ${me ? "DOUBLE" : "SINGLE"} \u2014 ${ee}`), me && (R(true), Se(true), Ae(`SHELL_DETECT: double shell, thickness=${O.thickness().toFixed(1)}mm`));
4164
4175
  }, [
4165
4176
  c,
4166
4177
  V,
4167
4178
  Ae
4168
4179
  ]);
4169
- const Ot = de(() => {
4180
+ const Ht = de(() => {
4170
4181
  if (!c || V.length < 2) return;
4171
4182
  oe(true), se("Please wait..."), Ae("PIPELINE: starting processing pipeline...");
4172
4183
  const m = performance.now();
4173
4184
  setTimeout(() => {
4174
- const M = [
4185
+ const z = [
4175
4186
  V[1],
4176
4187
  V[0],
4177
4188
  ...V.slice(2)
4178
4189
  ];
4179
- dr(c, M, St, {
4190
+ fr(c, z, St, {
4180
4191
  onStatus: (D) => {
4181
4192
  se(D), Ae(`PIPELINE: ${D}`);
4182
4193
  },
@@ -4195,17 +4206,17 @@ let __tla = (async () => {
4195
4206
  setModelSize: f,
4196
4207
  setOriginalEndY: tn,
4197
4208
  setAdjustedStartY: Fe,
4198
- setAdjustedEndY: Pt,
4199
- setError: Ee,
4209
+ setAdjustedEndY: Ft,
4210
+ setError: Re,
4200
4211
  setDoubleShell: (D) => {
4201
- E(D), Se(true);
4212
+ R(D), Se(true);
4202
4213
  },
4203
4214
  setAoData: (D, L) => {
4204
4215
  j(D), ue(L ?? null);
4205
4216
  },
4206
4217
  setInnerShellExtracted: ne,
4207
4218
  setMeasurementGeometry: pe,
4208
- setWasmSlices: Ie,
4219
+ setWasmSlices: We,
4209
4220
  wasmModule: je.current ?? void 0
4210
4221
  }), Ae(`PIPELINE: completed in ${(performance.now() - m).toFixed(0)}ms`), ht.current = false, oe(false);
4211
4222
  }, 50);
@@ -4218,31 +4229,31 @@ let __tla = (async () => {
4218
4229
  hn,
4219
4230
  mn,
4220
4231
  H
4221
- ]), Ht = fe(false);
4232
+ ]), Nt = fe(false);
4222
4233
  Z(() => {
4223
- r && (Ht.current || !c || le || X || V.length < 2 || (Ht.current = true, Ot()));
4234
+ r && (Nt.current || !c || le || X || V.length < 2 || (Nt.current = true, Ht()));
4224
4235
  }, [
4225
4236
  r,
4226
4237
  c,
4227
4238
  V.length,
4228
4239
  le,
4229
4240
  X,
4230
- Ot
4241
+ Ht
4231
4242
  ]), Z(() => {
4232
- V.length < 2 && (Ht.current = false);
4243
+ V.length < 2 && (Nt.current = false);
4233
4244
  }, [
4234
4245
  V.length
4235
4246
  ]);
4236
- const Nt = fe(false), ko = de(async () => {
4237
- if (ut(), Le([]), Ie(null), pe(null), Fe(null), Pt(null), on(null), tn(null), Je(false), ln(false), Dt(true), E(false), ne(false), dt.current = false, Nt.current = false, ht.current = false, F("3D"), t && Te) {
4238
- p(null);
4247
+ const Vt = fe(false), ko = de(async () => {
4248
+ if (ut(), Le([]), We(null), pe(null), Fe(null), Ft(null), on(null), tn(null), Je(false), ln(false), _t(true), R(false), ne(false), dt.current = false, Vt.current = false, ht.current = false, F("3D"), t && Te) {
4249
+ u(null);
4239
4250
  try {
4240
4251
  const m = await fetch(t);
4241
4252
  if (!m.ok) throw new Error(`Failed to download scan: ${m.status}`);
4242
4253
  const D = new URL(t).pathname.split("/").pop() || "scan.obj", L = D.toLowerCase();
4243
4254
  L.endsWith(".stl") || L.endsWith(".aop") ? await Be(await m.arrayBuffer(), D) : await Be(await m.text(), D);
4244
4255
  } catch (m) {
4245
- Ee(m instanceof Error ? m.message : "Failed to reload scan.");
4256
+ Re(m instanceof Error ? m.message : "Failed to reload scan.");
4246
4257
  }
4247
4258
  }
4248
4259
  }, [
@@ -4252,25 +4263,25 @@ let __tla = (async () => {
4252
4263
  ut
4253
4264
  ]);
4254
4265
  Z(() => {
4255
- le && T.length > 0 && !Nt.current && (Nt.current = true, Je(true));
4266
+ le && T.length > 0 && !Vt.current && (Vt.current = true, Je(true));
4256
4267
  }, [
4257
4268
  le,
4258
4269
  T.length
4259
4270
  ]);
4260
- const { scanTransverseML: Vt, scanTransverseAP: jt } = te(() => {
4271
+ const { scanTransverseML: jt, scanTransverseAP: Gt } = te(() => {
4261
4272
  if (!c || !le || V.length < 1) return {
4262
4273
  scanTransverseML: 0,
4263
4274
  scanTransverseAP: 0
4264
4275
  };
4265
4276
  try {
4266
- const m = (Oe ?? c).geometry, M = V[0].position.y, D = Qt(m), L = Ge(D, m, M);
4277
+ const m = (Oe ?? c).geometry, z = V[0].position.y, D = Qt(m), L = Ge(D, m, z);
4267
4278
  if (L.linePoints.length < 2) return {
4268
4279
  scanTransverseML: 0,
4269
4280
  scanTransverseAP: 0
4270
4281
  };
4271
- let K = L.linePoints[0], G = L.linePoints[0], O = L.linePoints[0], ee = L.linePoints[0];
4272
- for (const ze of L.linePoints) ze.x < K.x && (K = ze), ze.x > G.x && (G = ze), ze.z < O.z && (O = ze), ze.z > ee.z && (ee = ze);
4273
- const me = new k(K.x, M, K.z).distanceTo(new k(G.x, M, G.z)), be = new k(O.x, M, O.z).distanceTo(new k(ee.x, M, ee.z));
4282
+ let Y = L.linePoints[0], G = L.linePoints[0], O = L.linePoints[0], ee = L.linePoints[0];
4283
+ for (const Me of L.linePoints) Me.x < Y.x && (Y = Me), Me.x > G.x && (G = Me), Me.z < O.z && (O = Me), Me.z > ee.z && (ee = Me);
4284
+ const me = new k(Y.x, z, Y.z).distanceTo(new k(G.x, z, G.z)), be = new k(O.x, z, O.z).distanceTo(new k(ee.x, z, ee.z));
4274
4285
  return {
4275
4286
  scanTransverseML: me,
4276
4287
  scanTransverseAP: be
@@ -4291,22 +4302,22 @@ let __tla = (async () => {
4291
4302
  if (!c || V.length < 1) return 0;
4292
4303
  const m = c.geometry;
4293
4304
  m.computeBoundingBox();
4294
- const M = ((_a = m.boundingBox) == null ? void 0 : _a.min.y) ?? 0, D = V[0].position.y;
4305
+ const z = ((_a = m.boundingBox) == null ? void 0 : _a.min.y) ?? 0, D = V[0].position.y;
4295
4306
  if (re && V.length >= 3) {
4296
4307
  const L = Math.abs(D - V[2].position.y);
4297
4308
  if (L > 0.5) return L;
4298
4309
  }
4299
- return Math.abs(D - M);
4310
+ return Math.abs(D - z);
4300
4311
  }, [
4301
4312
  c,
4302
4313
  V,
4303
4314
  re
4304
4315
  ]), Po = de((m) => {
4305
- ao(m), Lt(m.circumferences), Dt(true), ln(true), Je(false);
4316
+ ao(m), Dt(m.circumferences), _t(true), ln(true), Je(false);
4306
4317
  }, []), we = (m) => m == null ? m : +(m / 10).toFixed(2), xn = de(async (m) => {
4307
- if (!s || Ye.current) return;
4308
- Ye.current = true, Je(false), an(false), at(true), await new Promise((D) => requestAnimationFrame(() => requestAnimationFrame(() => D())));
4309
- const M = c ? await Qe({
4318
+ if (!s || Ke.current) return;
4319
+ Ke.current = true, Je(false), an(false), at(true), await new Promise((D) => requestAnimationFrame(() => requestAnimationFrame(() => D())));
4320
+ const z = c ? await Qe({
4310
4321
  restoreView: false
4311
4322
  }).catch(() => {
4312
4323
  }) : void 0;
@@ -4330,11 +4341,11 @@ let __tla = (async () => {
4330
4341
  scanUrl: t,
4331
4342
  decision: "skip",
4332
4343
  skipReason: m,
4333
- screenshots: M,
4344
+ screenshots: z,
4334
4345
  alignedGeometry: c == null ? void 0 : c.geometry
4335
4346
  });
4336
4347
  } finally {
4337
- Ye.current = false, at(false);
4348
+ Ke.current = false, at(false);
4338
4349
  }
4339
4350
  }, [
4340
4351
  s,
@@ -4360,15 +4371,15 @@ let __tla = (async () => {
4360
4371
  le,
4361
4372
  Oe
4362
4373
  ]);
4363
- const Gt = de(async (m) => {
4364
- if (!s || !c || T.length === 0 || !P || Ye.current) return;
4365
- Ye.current = true, at(true), await new Promise((D) => requestAnimationFrame(() => requestAnimationFrame(() => D())));
4366
- const M = await Qe({
4374
+ const Xt = de(async (m) => {
4375
+ if (!s || !c || T.length === 0 || !P || Ke.current) return;
4376
+ Ke.current = true, at(true), await new Promise((D) => requestAnimationFrame(() => requestAnimationFrame(() => D())));
4377
+ const z = await Qe({
4367
4378
  restoreView: false
4368
4379
  }).catch(() => {
4369
4380
  });
4370
4381
  try {
4371
- const D = Vt, L = jt, K = Ce ? {
4382
+ const D = jt, L = Gt, Y = Ce ? {
4372
4383
  circumferences: Ce.circumferences.map((G) => we(G)),
4373
4384
  frontalHeight: we(Ce.frontalHeight),
4374
4385
  perineumML: we(Ce.perineumML),
@@ -4398,12 +4409,12 @@ let __tla = (async () => {
4398
4409
  mptAP: we(Ce == null ? void 0 : Ce.mptAP),
4399
4410
  scanUrl: t,
4400
4411
  decision: m,
4401
- userEnteredMeasurements: K,
4402
- screenshots: M,
4412
+ userEnteredMeasurements: Y,
4413
+ screenshots: z,
4403
4414
  alignedGeometry: (Oe ?? c).geometry
4404
4415
  });
4405
4416
  } finally {
4406
- Ye.current = false, at(false);
4417
+ Ke.current = false, at(false);
4407
4418
  }
4408
4419
  }, [
4409
4420
  s,
@@ -4418,25 +4429,25 @@ let __tla = (async () => {
4418
4429
  t,
4419
4430
  Ce,
4420
4431
  tt,
4421
- Vt,
4422
4432
  jt,
4433
+ Gt,
4423
4434
  Qe
4424
4435
  ]), Fo = te(() => {
4425
4436
  if (!ke || T.length === 0) return false;
4426
4437
  const m = Math.min(ke.length, T.length);
4427
4438
  if (m === 0) return false;
4428
- for (let M = 0; M < m; M++) {
4429
- const D = ke[M], L = T[M];
4439
+ for (let z = 0; z < m; z++) {
4440
+ const D = ke[z], L = T[z];
4430
4441
  if (!L || D == null || D === 0) continue;
4431
- const K = L.modifiedValue ?? L.originalValue;
4432
- if (Math.abs(K - D) > 7) return false;
4442
+ const Y = L.modifiedValue ?? L.originalValue;
4443
+ if (Math.abs(Y - D) > 7) return false;
4433
4444
  }
4434
4445
  return true;
4435
4446
  }, [
4436
4447
  ke,
4437
4448
  T
4438
4449
  ]), yn = Ve === 0 ? 320 : Ve < 520 ? Math.max(200, Math.round(Ve * 0.42)) : Ve < 900 ? 280 : Ve < 1400 ? 340 : 400, wn = Ve < 520 ? 16 : Ve < 900 ? 20 : 24;
4439
- return y(Ko.Provider, {
4450
+ return y(Yo.Provider, {
4440
4451
  value: e,
4441
4452
  children: [
4442
4453
  y("div", {
@@ -4477,7 +4488,7 @@ let __tla = (async () => {
4477
4488
  },
4478
4489
  children: [
4479
4490
  y("div", {
4480
- ref: Rt,
4491
+ ref: It,
4481
4492
  style: {
4482
4493
  flex: 1,
4483
4494
  display: "flex",
@@ -4486,7 +4497,7 @@ let __tla = (async () => {
4486
4497
  },
4487
4498
  children: [
4488
4499
  c && !le && (() => {
4489
- const m = V.length === 0 ? 1 : V.length === 1 ? 2 : 3, M = P === "AK" ? "Perineum" : "MPT", D = m === 1 ? `Place Point at ${M}` : m === 2 ? "Place Point at Distal Most Point" : "Ready to Continue", L = m === 1 ? `Click on the model to mark the ${M}.` : m === 2 ? "Click on the model to mark the Distal Most Point." : "Both points are placed. Click Continue to process the scan.", K = m === 1 ? "#2fbf4a" : m === 2 ? "#e53935" : "#2fbf4a", G = V.length >= 2;
4500
+ const m = V.length === 0 ? 1 : V.length === 1 ? 2 : 3, z = P === "AK" ? "Perineum" : "MPT", D = m === 1 ? `Place Point at ${z}` : m === 2 ? "Place Point at Distal Most Point" : "Ready to Continue", L = m === 1 ? `Click on the model to mark the ${z}.` : m === 2 ? "Click on the model to mark the Distal Most Point." : "Both points are placed. Click Continue to process the scan.", Y = m === 1 ? "#2fbf4a" : m === 2 ? "#e53935" : "#2fbf4a", G = V.length >= 2;
4490
4501
  return y("div", {
4491
4502
  style: {
4492
4503
  width: yn,
@@ -4642,9 +4653,9 @@ let __tla = (async () => {
4642
4653
  width: 12,
4643
4654
  height: 12,
4644
4655
  borderRadius: "50%",
4645
- backgroundColor: K,
4656
+ backgroundColor: Y,
4646
4657
  flexShrink: 0,
4647
- boxShadow: `0 0 0 3px ${K}22`
4658
+ boxShadow: `0 0 0 3px ${Y}22`
4648
4659
  }
4649
4660
  }),
4650
4661
  i("div", {
@@ -4668,7 +4679,7 @@ let __tla = (async () => {
4668
4679
  }),
4669
4680
  i("button", {
4670
4681
  disabled: !G,
4671
- onClick: Ot,
4682
+ onClick: Ht,
4672
4683
  style: {
4673
4684
  marginTop: 4,
4674
4685
  padding: "11px 14px",
@@ -4706,7 +4717,7 @@ let __tla = (async () => {
4706
4717
  ]
4707
4718
  });
4708
4719
  })(),
4709
- le && Ke && P && i("div", {
4720
+ le && Ye && P && i("div", {
4710
4721
  style: {
4711
4722
  width: yn,
4712
4723
  flexShrink: 0,
@@ -4730,13 +4741,13 @@ let __tla = (async () => {
4730
4741
  border: "1px solid rgba(0,0,0,0.06)",
4731
4742
  overflow: "hidden"
4732
4743
  },
4733
- children: i(Ir, {
4744
+ children: i(Wr, {
4734
4745
  amputationType: P,
4735
4746
  spacingInches: S,
4736
4747
  scanMeasurements: T,
4737
4748
  scanFrontalHeight: tt,
4738
- scanTransverseML: Vt,
4739
- scanTransverseAP: jt,
4749
+ scanTransverseML: jt,
4750
+ scanTransverseAP: Gt,
4740
4751
  onSave: Po,
4741
4752
  onSkip: xn,
4742
4753
  onFormChange: fo,
@@ -4758,9 +4769,9 @@ let __tla = (async () => {
4758
4769
  },
4759
4770
  onDragOver: e.showDragDrop ? Co : void 0,
4760
4771
  onDragLeave: e.showDragDrop ? Ao : void 0,
4761
- onDrop: e.showDragDrop ? zo : void 0,
4772
+ onDrop: e.showDragDrop ? Mo : void 0,
4762
4773
  children: [
4763
- e.showDragDrop && !c && !h && i("div", {
4774
+ e.showDragDrop && !c && !g && i("div", {
4764
4775
  style: {
4765
4776
  position: "absolute",
4766
4777
  inset: 16,
@@ -4809,7 +4820,7 @@ let __tla = (async () => {
4809
4820
  ]
4810
4821
  })
4811
4822
  }),
4812
- !e.showDragDrop && !c && !h && !Ft && i("div", {
4823
+ !e.showDragDrop && !c && !g && !Lt && i("div", {
4813
4824
  style: {
4814
4825
  position: "absolute",
4815
4826
  inset: 0,
@@ -4847,17 +4858,17 @@ let __tla = (async () => {
4847
4858
  ]
4848
4859
  })
4849
4860
  }),
4850
- h && i(Rn, {
4861
+ g && i(En, {
4851
4862
  message: A || "Processing mesh..."
4852
4863
  }),
4853
- X && i(Rn, {
4864
+ X && i(En, {
4854
4865
  message: ce
4855
4866
  }),
4856
- Ft && i(ur, {
4857
- message: Ft,
4858
- onDismiss: () => Ee(null)
4867
+ Lt && i(pr, {
4868
+ message: Lt,
4869
+ onDismiss: () => Re(null)
4859
4870
  }),
4860
- e.showAmputationModal && z && i("div", {
4871
+ e.showAmputationModal && M && i("div", {
4861
4872
  style: {
4862
4873
  position: "absolute",
4863
4874
  inset: 0,
@@ -4970,7 +4981,7 @@ let __tla = (async () => {
4970
4981
  children: [
4971
4982
  i("button", {
4972
4983
  onClick: () => {
4973
- R(false), N(null);
4984
+ E(false), N(null);
4974
4985
  },
4975
4986
  style: {
4976
4987
  padding: "6px 16px",
@@ -4988,7 +4999,7 @@ let __tla = (async () => {
4988
4999
  children: "Cancel"
4989
5000
  }),
4990
5001
  i("button", {
4991
- onClick: () => P && Mo(P),
5002
+ onClick: () => P && zo(P),
4992
5003
  disabled: !P,
4993
5004
  style: {
4994
5005
  padding: "6px 16px",
@@ -5010,7 +5021,7 @@ let __tla = (async () => {
5010
5021
  ]
5011
5022
  })
5012
5023
  }),
5013
- e.showDragDrop && g && i("div", {
5024
+ e.showDragDrop && h && i("div", {
5014
5025
  style: {
5015
5026
  position: "absolute",
5016
5027
  inset: 0,
@@ -5020,7 +5031,7 @@ let __tla = (async () => {
5020
5031
  zIndex: 10
5021
5032
  }
5022
5033
  }),
5023
- i(fr, {
5034
+ i(ur, {
5024
5035
  children: y(Oo, {
5025
5036
  camera: {
5026
5037
  position: [
@@ -5031,14 +5042,14 @@ let __tla = (async () => {
5031
5042
  },
5032
5043
  style: {
5033
5044
  display: c ? "block" : "none",
5034
- backgroundColor: We ? "#070611" : void 0
5045
+ backgroundColor: $e ? "#070611" : void 0
5035
5046
  },
5036
5047
  gl: {
5037
5048
  localClippingEnabled: true,
5038
5049
  preserveDrawingBuffer: true
5039
5050
  },
5040
5051
  scene: {
5041
- background: We ? new U.Color("#070611") : null
5052
+ background: $e ? new U.Color("#070611") : null
5042
5053
  },
5043
5054
  children: [
5044
5055
  i("ambientLight", {
@@ -5068,16 +5079,16 @@ let __tla = (async () => {
5068
5079
  ],
5069
5080
  intensity: 0.2
5070
5081
  }),
5071
- c && x === "3D" && i(hr, {
5082
+ c && x === "3D" && i(gr, {
5072
5083
  mesh: c,
5073
5084
  maxPoints: 2,
5074
5085
  meshColor: dn,
5075
- meshOpacity: We ? 0.3 : bo,
5086
+ meshOpacity: $e ? 0.3 : bo,
5076
5087
  frontFaceOnly: H,
5077
5088
  doubleShellTransparency: re && le
5078
5089
  }),
5079
- c && x === "3D" && i(mr, {
5080
- modelSize: u,
5090
+ c && x === "3D" && i(xr, {
5091
+ modelSize: p,
5081
5092
  labels: [
5082
5093
  P === "AK" ? "Perineum" : "MPT",
5083
5094
  "Distal Most Point",
@@ -5085,36 +5096,36 @@ let __tla = (async () => {
5085
5096
  ]
5086
5097
  }),
5087
5098
  i(zr, {
5088
- modelSize: u,
5099
+ modelSize: p,
5089
5100
  isAligned: le,
5090
- isCut: Tt,
5101
+ isCut: Ot,
5091
5102
  mesh: c,
5092
5103
  viewMode: x,
5093
- sliceY: le && V.length >= 2 ? kt ?? it ?? V[0].position.y : void 0,
5104
+ sliceY: le && V.length >= 2 ? Pt ?? it ?? V[0].position.y : void 0,
5094
5105
  landmarkCount: V.length,
5095
5106
  measurementGeometry: ie,
5096
- fitYMin: le && V.length >= 2 ? kt ?? it ?? void 0 : void 0,
5107
+ fitYMin: le && V.length >= 2 ? Pt ?? it ?? void 0 : void 0,
5097
5108
  fitYMax: le && V.length >= 2 ? st ?? V[0].position.y : void 0,
5098
- resetCameraToFrontRef: Wt
5109
+ resetCameraToFrontRef: $t
5099
5110
  }),
5100
5111
  !le && i(Nn, {
5101
5112
  enableDamping: false
5102
5113
  }),
5103
- le && T.length > 0 && c && x === "3D" && i(Mr, {
5114
+ le && T.length > 0 && c && x === "3D" && i(kr, {
5104
5115
  mesh: c,
5105
5116
  isDragging: oo
5106
5117
  }),
5107
5118
  c && le && V.length >= 3 && (() => {
5108
- const M = c.geometry.getIndex();
5109
- if (!M || M.count < 30) return null;
5110
- const D = V[2], L = V[0], K = ye ?? D.position.y, G = kt ?? it ?? L.position.y;
5119
+ const z = c.geometry.getIndex();
5120
+ if (!z || z.count < 30) return null;
5121
+ const D = V[2], L = V[0], Y = ye ?? D.position.y, G = Pt ?? it ?? L.position.y;
5111
5122
  if (x === "2D") {
5112
- const O = Ke ? ho : Ne ? P === "AK" ? Ce == null ? void 0 : Ce.perineumML : Ce == null ? void 0 : Ce.mptML : void 0, ee = Ke ? mo : Ne ? P === "AK" ? Ce == null ? void 0 : Ce.perineumAP : Ce == null ? void 0 : Ce.mptAP : void 0;
5113
- return i(Lr, {
5123
+ const O = Ye ? ho : Ne ? P === "AK" ? Ce == null ? void 0 : Ce.perineumML : Ce == null ? void 0 : Ce.mptML : void 0, ee = Ye ? mo : Ne ? P === "AK" ? Ce == null ? void 0 : Ce.perineumAP : Ce == null ? void 0 : Ce.mptAP : void 0;
5124
+ return i(Dr, {
5114
5125
  mesh: Oe ?? c,
5115
5126
  upperY: G,
5116
5127
  originY: L.position.y,
5117
- modelSize: u,
5128
+ modelSize: p,
5118
5129
  meshColor: dn,
5119
5130
  displayUnit: _,
5120
5131
  formML: O,
@@ -5123,39 +5134,39 @@ let __tla = (async () => {
5123
5134
  }
5124
5135
  return y(_e, {
5125
5136
  children: [
5126
- i(Sr, {
5137
+ i(Cr, {
5127
5138
  mesh: Oe ?? c,
5128
- startY: K,
5139
+ startY: Y,
5129
5140
  endY: G,
5130
5141
  spacing: pt,
5131
- modelSize: u,
5142
+ modelSize: p,
5132
5143
  onMeasurementsChange: Le,
5133
5144
  reverseOrder: true,
5134
5145
  displayUnit: _,
5135
5146
  useInnerSurface: re && !H,
5136
- formMeasurements: Ke ? co ?? ke : Ne ? ke : void 0,
5147
+ formMeasurements: Ye ? co ?? ke : Ne ? ke : void 0,
5137
5148
  originY: st ?? L.position.y,
5138
5149
  wasmSlices: Pe
5139
5150
  }),
5140
- i(Ar, {
5151
+ i(Mr, {
5141
5152
  mesh: c,
5142
5153
  greenY: st ?? L.position.y,
5143
- modelSize: u,
5154
+ modelSize: p,
5144
5155
  displayUnit: _,
5145
5156
  bottomY: re ? D.position.y : void 0,
5146
- formHeight: Ke ? uo : Ne ? Ce == null ? void 0 : Ce.frontalHeight : void 0
5157
+ formHeight: Ye ? uo : Ne ? Ce == null ? void 0 : Ce.frontalHeight : void 0
5147
5158
  }),
5148
- i(Dr, {
5159
+ i(_r, {
5149
5160
  mesh: c,
5150
5161
  yPosition: st ?? L.position.y,
5151
5162
  onYChange: (O) => {
5152
- on(O), Ie(null);
5163
+ on(O), We(null);
5153
5164
  const ee = O - L.position.y;
5154
- Pt((it ?? L.position.y + pt * 2) + ee);
5165
+ Ft((it ?? L.position.y + pt * 2) + ee);
5155
5166
  },
5156
5167
  minY: L.position.y - pt,
5157
5168
  maxY: L.position.y + pt,
5158
- modelSize: u,
5169
+ modelSize: p,
5159
5170
  color: "#44ff44",
5160
5171
  hoverColor: "#88ff88",
5161
5172
  dragColor: "#ffffff",
@@ -5166,23 +5177,23 @@ let __tla = (async () => {
5166
5177
  ]
5167
5178
  });
5168
5179
  })(),
5169
- c && le && x === "3D" && We && i(qr, {
5180
+ c && le && x === "3D" && $e && i(Jr, {
5170
5181
  mesh: c
5171
5182
  }),
5172
- c && e.showDebug && We && x === "3D" && i(Ur, {
5183
+ c && e.showDebug && $e && x === "3D" && i(qr, {
5173
5184
  mesh: c,
5174
- modelSize: u,
5185
+ modelSize: p,
5175
5186
  layers: rn,
5176
5187
  landmarkPoints: V,
5177
5188
  componentDebug: null,
5178
5189
  aoData: Q,
5179
- aoGeometry: Y,
5190
+ aoGeometry: K,
5180
5191
  measurementGeometry: ie
5181
5192
  }),
5182
- i(ti, {
5193
+ i(ni, {
5183
5194
  screenshotFnRef: wo,
5184
5195
  mesh: c,
5185
- modelSize: u,
5196
+ modelSize: p,
5186
5197
  measurementGeometry: ie
5187
5198
  })
5188
5199
  ]
@@ -5218,7 +5229,7 @@ let __tla = (async () => {
5218
5229
  !le && V.length >= 1 && y(_e, {
5219
5230
  children: [
5220
5231
  i("button", {
5221
- onClick: () => $t(),
5232
+ onClick: () => Tt(),
5222
5233
  title: "Undo last point (Ctrl+Z)",
5223
5234
  style: {
5224
5235
  padding: "6px 16px",
@@ -5254,7 +5265,7 @@ let __tla = (async () => {
5254
5265
  })
5255
5266
  ]
5256
5267
  }),
5257
- le && !_t && y(_e, {
5268
+ le && !Rt && y(_e, {
5258
5269
  children: [
5259
5270
  i("button", {
5260
5271
  onClick: ko,
@@ -5295,11 +5306,11 @@ let __tla = (async () => {
5295
5306
  })
5296
5307
  ]
5297
5308
  }),
5298
- e.showDebug && We && c && x === "3D" && i(Qr, {
5309
+ e.showDebug && $e && c && x === "3D" && i(ei, {
5299
5310
  layers: rn,
5300
- onToggleLayer: (m) => io((M) => ({
5301
- ...M,
5302
- [m]: !M[m]
5311
+ onToggleLayer: (m) => io((z) => ({
5312
+ ...z,
5313
+ [m]: !z[m]
5303
5314
  })),
5304
5315
  isDoubleShell: re
5305
5316
  }),
@@ -5363,7 +5374,7 @@ let __tla = (async () => {
5363
5374
  },
5364
5375
  children: [
5365
5376
  i("button", {
5366
- onClick: () => $("cm"),
5377
+ onClick: () => B("cm"),
5367
5378
  style: {
5368
5379
  padding: "6px 14px",
5369
5380
  fontSize: 13,
@@ -5377,7 +5388,7 @@ let __tla = (async () => {
5377
5388
  children: "cm"
5378
5389
  }),
5379
5390
  i("button", {
5380
- onClick: () => $("inch"),
5391
+ onClick: () => B("inch"),
5381
5392
  style: {
5382
5393
  padding: "6px 14px",
5383
5394
  fontSize: 13,
@@ -5442,7 +5453,7 @@ let __tla = (async () => {
5442
5453
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)"
5443
5454
  },
5444
5455
  children: i("button", {
5445
- onClick: () => Dt((m) => !m),
5456
+ onClick: () => _t((m) => !m),
5446
5457
  style: {
5447
5458
  padding: "6px 14px",
5448
5459
  fontSize: 13,
@@ -5468,11 +5479,11 @@ let __tla = (async () => {
5468
5479
  onClick: async () => {
5469
5480
  const m = await Qe();
5470
5481
  if (!m) return;
5471
- const M = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), D = (L, K) => {
5482
+ const z = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), D = (L, Y) => {
5472
5483
  const G = document.createElement("a");
5473
- G.href = L, G.download = K, G.click();
5484
+ G.href = L, G.download = Y, G.click();
5474
5485
  };
5475
- D(m.frontal_view_png, `measurements_front_${M}.png`), await new Promise((L) => setTimeout(L, 300)), D(m.side_view_png, `measurements_transverse_${M}.png`);
5486
+ D(m.frontal_view_png, `measurements_front_${z}.png`), await new Promise((L) => setTimeout(L, 300)), D(m.side_view_png, `measurements_transverse_${z}.png`);
5476
5487
  },
5477
5488
  style: {
5478
5489
  padding: "6px 14px",
@@ -5500,9 +5511,9 @@ let __tla = (async () => {
5500
5511
  style: {
5501
5512
  padding: "6px 14px",
5502
5513
  fontSize: 13,
5503
- fontWeight: We ? 600 : 400,
5504
- backgroundColor: We ? "#e65100" : "#fff",
5505
- color: We ? "#fff" : "#666",
5514
+ fontWeight: $e ? 600 : 400,
5515
+ backgroundColor: $e ? "#e65100" : "#fff",
5516
+ color: $e ? "#fff" : "#666",
5506
5517
  border: "none",
5507
5518
  cursor: "pointer",
5508
5519
  fontFamily: "system-ui, sans-serif"
@@ -5512,11 +5523,11 @@ let __tla = (async () => {
5512
5523
  })
5513
5524
  ]
5514
5525
  }),
5515
- c && q && i(Pr, {
5526
+ c && q && i(Fr, {
5516
5527
  detectedUnit: J,
5517
5528
  onDismiss: () => ge(false)
5518
5529
  }),
5519
- c && he && le && i(Fr, {
5530
+ c && he && le && i(Lr, {
5520
5531
  isDoubleShell: re,
5521
5532
  onDismiss: () => Se(false)
5522
5533
  }),
@@ -5570,28 +5581,28 @@ let __tla = (async () => {
5570
5581
  y("div", {
5571
5582
  className: "gm-btn-group",
5572
5583
  children: [
5573
- _t && !Ke && i("button", {
5584
+ Rt && !Ye && i("button", {
5574
5585
  className: "gm-btn gm-btn-secondary",
5575
5586
  onClick: () => Je(true),
5576
5587
  children: "Edit Measurements"
5577
5588
  }),
5578
- _t && (Fo ? i("button", {
5589
+ Rt && (Fo ? i("button", {
5579
5590
  className: "gm-btn gm-btn-primary",
5580
5591
  disabled: lt,
5581
- onClick: () => Gt("continue"),
5592
+ onClick: () => Xt("continue"),
5582
5593
  children: "Continue \u2192"
5583
5594
  }) : y(_e, {
5584
5595
  children: [
5585
5596
  i("button", {
5586
5597
  className: "gm-btn gm-btn-primary",
5587
5598
  disabled: lt,
5588
- onClick: () => Gt("use_scan"),
5599
+ onClick: () => Xt("use_scan"),
5589
5600
  children: "Go with Scan"
5590
5601
  }),
5591
5602
  i("button", {
5592
5603
  className: "gm-btn gm-btn-primary",
5593
5604
  disabled: lt,
5594
- onClick: () => Gt("use_form_measurements"),
5605
+ onClick: () => Xt("use_form_measurements"),
5595
5606
  children: "Go with Measurements"
5596
5607
  })
5597
5608
  ]
@@ -5644,7 +5655,7 @@ let __tla = (async () => {
5644
5655
  })
5645
5656
  ]
5646
5657
  }),
5647
- l && It.length > 0 && y("div", {
5658
+ l && Wt.length > 0 && y("div", {
5648
5659
  style: {
5649
5660
  height: 120,
5650
5661
  flexShrink: 0,
@@ -5726,29 +5737,29 @@ let __tla = (async () => {
5726
5737
  padding: "4px 10px",
5727
5738
  lineHeight: 1.6
5728
5739
  },
5729
- children: It.map((m, M) => {
5730
- const D = m.includes("ERROR") || m.includes("failed"), L = m.includes("warning") || m.includes("WARN"), K = m.includes("PIPELINE:"), G = m.includes("STATE:");
5740
+ children: Wt.map((m, z) => {
5741
+ const D = m.includes("ERROR") || m.includes("failed"), L = m.includes("warning") || m.includes("WARN"), Y = m.includes("PIPELINE:"), G = m.includes("STATE:");
5731
5742
  return i("div", {
5732
5743
  style: {
5733
- color: D ? "#f85149" : L ? "#d29922" : K ? "#58a6ff" : G ? "#3fb950" : "#8b949e",
5744
+ color: D ? "#f85149" : L ? "#d29922" : Y ? "#58a6ff" : G ? "#3fb950" : "#8b949e",
5734
5745
  whiteSpace: "pre"
5735
5746
  },
5736
5747
  children: m
5737
- }, M);
5748
+ }, z);
5738
5749
  })
5739
5750
  })
5740
5751
  ]
5741
5752
  })
5742
5753
  ]
5743
5754
  }),
5744
- so && i($r, {
5755
+ so && i(Tr, {
5745
5756
  onSkip: xn,
5746
5757
  onCancel: () => an(false)
5747
5758
  })
5748
5759
  ]
5749
5760
  });
5750
5761
  };
5751
- function ti({ screenshotFnRef: e }) {
5762
+ function ni({ screenshotFnRef: e }) {
5752
5763
  return Z(() => {
5753
5764
  e.current = null;
5754
5765
  }, [
@@ -5782,7 +5793,7 @@ let __tla = (async () => {
5782
5793
  }
5783
5794
  return n;
5784
5795
  };
5785
- ni = function(e, o) {
5796
+ oi = function(e, o) {
5786
5797
  if (!e) return;
5787
5798
  const n = no(o).map((s) => {
5788
5799
  const l = e[s];
@@ -5790,7 +5801,7 @@ let __tla = (async () => {
5790
5801
  });
5791
5802
  if (!n.every((s) => s == null)) return n;
5792
5803
  };
5793
- function oi(e) {
5804
+ function ri(e) {
5794
5805
  const o = e.getAttribute("position");
5795
5806
  if (!o) return "";
5796
5807
  const t = [
@@ -5811,7 +5822,7 @@ let __tla = (async () => {
5811
5822
  return t.join(`
5812
5823
  `);
5813
5824
  }
5814
- async function ri(e, o) {
5825
+ async function ii(e, o) {
5815
5826
  for (let t = 0; t < 3; t++) try {
5816
5827
  const n = await fetch(e, {
5817
5828
  method: "PUT",
@@ -5850,20 +5861,20 @@ let __tla = (async () => {
5850
5861
  error: "Upload failed after 3 attempts"
5851
5862
  };
5852
5863
  }
5853
- xi = ({ request: e, onComplete: o, wasmModule: t }) => {
5854
- const [n, s] = B(null);
5864
+ bi = ({ request: e, onComplete: o, wasmModule: t }) => {
5865
+ const [n, s] = $(null);
5855
5866
  Z(() => {
5856
5867
  if (t != null) return;
5857
5868
  let r = false;
5858
- const c = async (p) => {
5869
+ const c = async (u) => {
5859
5870
  try {
5860
- const u = await import("./geo_wasm-BBuWXukA.js");
5861
- await u.default(), r || s(u);
5862
- } catch (u) {
5863
- if (p < 2 && !r) {
5864
- const f = (p + 1) * 1e3 + p * 1e3;
5865
- if (console.warn(`[GirthManagerWidget] WASM load failed (attempt ${p + 1}/3), retrying in ${f}ms...`, u), await new Promise((g) => setTimeout(g, f)), !r) return c(p + 1);
5866
- } else console.error("[GirthManagerWidget] WASM load failed after 3 attempts:", u);
5871
+ const p = await import("./geo_wasm-BBuWXukA.js");
5872
+ await p.default(), r || s(p);
5873
+ } catch (p) {
5874
+ if (u < 2 && !r) {
5875
+ const f = (u + 1) * 1e3 + u * 1e3;
5876
+ if (console.warn(`[GirthManagerWidget] WASM load failed (attempt ${u + 1}/3), retrying in ${f}ms...`, p), await new Promise((h) => setTimeout(h, f)), !r) return c(u + 1);
5877
+ } else console.error("[GirthManagerWidget] WASM load failed after 3 attempts:", p);
5867
5878
  }
5868
5879
  };
5869
5880
  return c(0), () => {
@@ -5872,15 +5883,15 @@ let __tla = (async () => {
5872
5883
  }, [
5873
5884
  t
5874
5885
  ]);
5875
- const l = t !== void 0 ? t : n ?? void 0, d = te(() => ni(e.form_measurements, e.spacing_type), [
5886
+ const l = t !== void 0 ? t : n ?? void 0, d = te(() => oi(e.form_measurements, e.spacing_type), [
5876
5887
  e.form_measurements,
5877
5888
  e.spacing_type
5878
5889
  ]), a = async (r) => {
5879
5890
  var _a, _b;
5880
- const c = r.scanMeasurements.map((x) => +(x.modifiedValue ?? x.originalValue).toFixed(1)), p = vt(c, e.spacing_type);
5881
- let u, f;
5891
+ const c = r.scanMeasurements.map((x) => +(x.modifiedValue ?? x.originalValue).toFixed(1)), u = vt(c, e.spacing_type);
5892
+ let p, f;
5882
5893
  if (r.formMeasurements) {
5883
- u = vt(r.formMeasurements, e.spacing_type);
5894
+ p = vt(r.formMeasurements, e.spacing_type);
5884
5895
  const x = r.scanMeasurements.map((F, S) => {
5885
5896
  var _a2;
5886
5897
  const C = (_a2 = r.formMeasurements) == null ? void 0 : _a2[S];
@@ -5888,7 +5899,7 @@ let __tla = (async () => {
5888
5899
  });
5889
5900
  f = vt(x, e.spacing_type);
5890
5901
  }
5891
- const g = r.userEnteredMeasurements ? vt(r.userEnteredMeasurements.circumferences, e.spacing_type) : void 0, w = r.decision === "use_scan" || r.decision === "continue", h = w ? p : g ?? u ?? p, b = w ? +r.frontalHeight.toFixed(1) : +(((_a = r.userEnteredMeasurements) == null ? void 0 : _a.frontalHeight) ?? r.frontalHeight).toFixed(1);
5902
+ const h = r.userEnteredMeasurements ? vt(r.userEnteredMeasurements.circumferences, e.spacing_type) : void 0, w = r.decision === "use_scan" || r.decision === "continue", g = w ? u : h ?? p ?? u, b = w ? +r.frontalHeight.toFixed(1) : +(((_a = r.userEnteredMeasurements) == null ? void 0 : _a.frontalHeight) ?? r.frontalHeight).toFixed(1);
5892
5903
  let A;
5893
5904
  if (e.upload_url) if (!r.alignedGeometry) A = {
5894
5905
  success: false,
@@ -5896,9 +5907,9 @@ let __tla = (async () => {
5896
5907
  message: "No aligned geometry available \u2014 mesh processing may not have completed."
5897
5908
  };
5898
5909
  else try {
5899
- const x = oi(r.alignedGeometry), F = new Blob([
5910
+ const x = ri(r.alignedGeometry), F = new Blob([
5900
5911
  x
5901
- ]), S = await ri(e.upload_url, F);
5912
+ ]), S = await ii(e.upload_url, F);
5902
5913
  A = {
5903
5914
  ...S,
5904
5915
  url: e.upload_url,
@@ -5919,8 +5930,8 @@ let __tla = (async () => {
5919
5930
  measurement_source: r.formMeasurements ? "form_provided" : "scan_derived",
5920
5931
  is_double_wall: r.isDoubleWall,
5921
5932
  is_unit_converted: false,
5922
- form_measurements: u,
5923
- scan_measurements: p,
5933
+ form_measurements: p,
5934
+ scan_measurements: u,
5924
5935
  measurement_variance: f,
5925
5936
  scan_url: e.scan_url,
5926
5937
  frontal_height: +r.frontalHeight.toFixed(1),
@@ -5928,9 +5939,9 @@ let __tla = (async () => {
5928
5939
  transverse_ap: +r.transverseAP.toFixed(1),
5929
5940
  decision: r.decision,
5930
5941
  skip_reason: r.skipReason,
5931
- user_measurements: g,
5942
+ user_measurements: h,
5932
5943
  user_frontal_height: (_b = r.userEnteredMeasurements) == null ? void 0 : _b.frontalHeight,
5933
- final_measurements: h,
5944
+ final_measurements: g,
5934
5945
  final_frontal_height: b,
5935
5946
  final_transverse_ml: +r.transverseML.toFixed(1),
5936
5947
  final_transverse_ap: +r.transverseAP.toFixed(1),
@@ -5949,7 +5960,7 @@ let __tla = (async () => {
5949
5960
  height: "100%",
5950
5961
  display: "flex"
5951
5962
  },
5952
- children: i(ei, {
5963
+ children: i(ti, {
5953
5964
  config: Xo,
5954
5965
  spacingType: e.spacing_type,
5955
5966
  scanUrl: e.scan_url,
@@ -5961,10 +5972,10 @@ let __tla = (async () => {
5961
5972
  };
5962
5973
  })();
5963
5974
  export {
5964
- xi as G,
5975
+ bi as G,
5965
5976
  __tla,
5966
5977
  vt as a,
5967
- ni as c,
5978
+ oi as c,
5968
5979
  no as g,
5969
5980
  en as u
5970
5981
  };