brep-io-kernel 1.0.165 → 1.0.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apiExamples/BREP_Booleans.html +2 -2
- package/dist/apiExamples/BREP_Export.html +2 -2
- package/dist/apiExamples/BREP_Primitives.html +2 -2
- package/dist/apiExamples/BREP_Transforms.html +2 -2
- package/dist/apiExamples/Embeded_2D_Sketcher.html +2 -2
- package/dist/apiExamples/Embeded_CAD.html +2 -2
- package/dist/apiExamples/Embeded_CAD_Integration_Test.html +2 -2
- package/dist/assembly-constraint-capture.html +5 -5
- package/dist/assets/{AnnotationRegistry-CXzWv0O4.js → AnnotationRegistry-0p-JvbWc.js} +1 -1
- package/dist/assets/{AssemblyConstraintRegistry-B9zYtUPa.js → AssemblyConstraintRegistry-D_je-ie-.js} +1 -1
- package/dist/assets/{FeatureRegistry-C8QUptOR.js → FeatureRegistry-CbzxapvH.js} +3 -3
- package/dist/assets/{PartHistory-BT0SV2I5.js → PartHistory-CpTryl-X.js} +1 -1
- package/dist/assets/{Tube-OTYPNFqf.js → Tube-BXbVhwOj.js} +1 -1
- package/dist/assets/{annUtils-DooqNh7u.js → annUtils-DcxkV20w.js} +1 -1
- package/dist/assets/{apiExample_BREP_Booleans-DX0mDm5o.js → apiExample_BREP_Booleans-Bzu4TbBN.js} +1 -1
- package/dist/assets/{apiExample_BREP_Export-DbPRP7aB.js → apiExample_BREP_Export-CqSlAGR2.js} +1 -1
- package/dist/assets/{apiExample_BREP_Primitives-Ck5Bs5_N.js → apiExample_BREP_Primitives-BTFxPM-7.js} +1 -1
- package/dist/assets/{apiExample_BREP_Transforms-dRWUyTjs.js → apiExample_BREP_Transforms-OLb25wNp.js} +1 -1
- package/dist/assets/{apiExample_Embeded_2D_Sketcher-mq3UXNnH.js → apiExample_Embeded_2D_Sketcher-ioZryvFJ.js} +1 -1
- package/dist/assets/{apiExample_Embeded_CAD-DmG27xiK.js → apiExample_Embeded_CAD-enaf0P7w.js} +1 -1
- package/dist/assets/{apiExample_Embeded_CAD_Integration_Test-BkLtONsP.js → apiExample_Embeded_CAD_Integration_Test-qsIfYhe5.js} +1 -1
- package/dist/assets/{assemblyConstraintDialogs-Bp6JwQGM.js → assemblyConstraintDialogs-DOrF7vUw.js} +1 -1
- package/dist/assets/{brep-kernel-Cy1Y5Ou0.js → brep-kernel-CwgaO_st.js} +12 -12
- package/dist/assets/{browserTests-DyOFL-SK.js → browserTests-BUklfMO3.js} +12 -12
- package/dist/assets/{chamfer-CQEYwOuD.js → chamfer-DRqXmQEN.js} +1 -1
- package/dist/assets/{dialogCapturePageFactory-C8ZgGbz3.js → dialogCapturePageFactory-DHAJd9no.js} +1 -1
- package/dist/assets/{featureDialogs-CTxnmH67.js → featureDialogs-CDtV5J5B.js} +1 -1
- package/dist/assets/{featureDialogs-Dw07GP5f.js → featureDialogs-DEpvCr2m.js} +24 -24
- package/dist/assets/{fillet-C6-sxYCV.js → fillet-D-ZkRPFl.js} +1 -1
- package/dist/assets/{index.es-DgjLCvnw.js → index.es-Bj8hUP_M.js} +1 -1
- package/dist/assets/{javascript-CoXQsEOO.js → javascript-ClNCyVlO.js} +1 -1
- package/dist/assets/{main-cad-BxSaytVM.js → main-cad-IYyl4fag.js} +6 -6
- package/dist/assets/{pmiDialogs-BzGjz4Z4.js → pmiDialogs-CtAI9GYO.js} +1 -1
- package/dist/assets/{test-BubuSRs4.js → test-DDWa8W9C.js} +3 -3
- package/dist/cad.html +10 -10
- package/dist/feature-dialog-capture.html +7 -7
- package/dist/pmi-dialog-capture.html +5 -5
- package/dist/test.html +1 -1
- package/dist/viewer.html +10 -10
- package/dist-kernel/brep-kernel.js +4098 -4095
- package/package.json +1 -1
- package/src/BREP/SolidMethods/fillet.js +1 -1
- package/src/BREP/SolidMethods/transforms.js +8 -3
- package/src/BREP/fillets/fillet.js +4 -4
- package/src/tests/test_fillet_corner_bridge.js +16 -12
- package/src/tests/test_fillet_nonClosed.js +15 -14
- package/src/tests/test_sheetMetal_corner_fillet_compound_reference.js +11 -8
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<title>BREP API Example: Booleans</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/apiExample_BREP_Booleans-
|
|
8
|
+
<script type="module" crossorigin src="/assets/apiExample_BREP_Booleans-Bzu4TbBN.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-CwgaO_st.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<title>BREP API Example: Export</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/apiExample_BREP_Export-
|
|
8
|
+
<script type="module" crossorigin src="/assets/apiExample_BREP_Export-CqSlAGR2.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-CwgaO_st.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<title>BREP API Example: Primitives</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/apiExample_BREP_Primitives-
|
|
8
|
+
<script type="module" crossorigin src="/assets/apiExample_BREP_Primitives-BTFxPM-7.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-CwgaO_st.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<title>BREP API Example: Transforms</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/apiExample_BREP_Transforms-
|
|
8
|
+
<script type="module" crossorigin src="/assets/apiExample_BREP_Transforms-OLb25wNp.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-CwgaO_st.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<title>BREP API Example: Embeded 2D Sketcher</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/apiExample_Embeded_2D_Sketcher-
|
|
8
|
+
<script type="module" crossorigin src="/assets/apiExample_Embeded_2D_Sketcher-ioZryvFJ.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-CwgaO_st.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
background: #fff;
|
|
32
32
|
}
|
|
33
33
|
</style>
|
|
34
|
-
<script type="module" crossorigin src="/assets/apiExample_Embeded_CAD-
|
|
34
|
+
<script type="module" crossorigin src="/assets/apiExample_Embeded_CAD-enaf0P7w.js"></script>
|
|
35
35
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
36
36
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
37
|
-
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-
|
|
37
|
+
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-CwgaO_st.js">
|
|
38
38
|
<link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
|
|
39
39
|
</head>
|
|
40
40
|
<body>
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
</style>
|
|
95
|
-
<script type="module" crossorigin src="/assets/apiExample_Embeded_CAD_Integration_Test-
|
|
95
|
+
<script type="module" crossorigin src="/assets/apiExample_Embeded_CAD_Integration_Test-qsIfYhe5.js"></script>
|
|
96
96
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
97
97
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
98
|
-
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-
|
|
98
|
+
<link rel="modulepreload" crossorigin href="/assets/brep-kernel-CwgaO_st.js">
|
|
99
99
|
<link rel="stylesheet" crossorigin href="/assets/example-CoxINuWK.css">
|
|
100
100
|
</head>
|
|
101
101
|
<body>
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
background: #05070d;
|
|
14
14
|
}
|
|
15
15
|
</style>
|
|
16
|
-
<script type="module" crossorigin src="/assets/assemblyConstraintDialogs-
|
|
16
|
+
<script type="module" crossorigin src="/assets/assemblyConstraintDialogs-DOrF7vUw.js"></script>
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-BdX5DvLD.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-ZNr0Qq7Q.js">
|
|
19
19
|
<link rel="modulepreload" crossorigin href="/assets/browserStorage-CvgF8ovw.js">
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/featureDialogs-
|
|
21
|
-
<link rel="modulepreload" crossorigin href="/assets/annUtils-
|
|
22
|
-
<link rel="modulepreload" crossorigin href="/assets/AssemblyConstraintRegistry-
|
|
23
|
-
<link rel="modulepreload" crossorigin href="/assets/dialogCapturePageFactory-
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/featureDialogs-DEpvCr2m.js">
|
|
21
|
+
<link rel="modulepreload" crossorigin href="/assets/annUtils-DcxkV20w.js">
|
|
22
|
+
<link rel="modulepreload" crossorigin href="/assets/AssemblyConstraintRegistry-D_je-ie-.js">
|
|
23
|
+
<link rel="modulepreload" crossorigin href="/assets/dialogCapturePageFactory-DHAJd9no.js">
|
|
24
24
|
</head>
|
|
25
25
|
<body>
|
|
26
26
|
<div id="app"></div>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var lt=Object.defineProperty;var kt=(e,t,n)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var m=(e,t)=>lt(e,"name",{value:t,configurable:!0});var P=(e,t,n)=>kt(e,typeof t!="symbol"?t+"":t,n);import{d as we}from"./deepClone-Dj59xCHB.js";import{V as f,a as _,P as I,M as me,b as Pe,Q as V,I as Gt,J as Qt,f as Yt,K as Zt,B as vt}from"./featureDialogs-Dw07GP5f.js";import{s as q,i as Y,a as ne,o as E,m as Ve,g as ue,d as Je,j as Kt}from"./annUtils-DooqNh7u.js";function B(e,t,n,r=.01){const s=[];typeof t=="function"&&s.push(t),typeof n=="function"&&s.push(n);for(const o of s)try{const i=Number(o(e));if(Number.isFinite(i)&&i>0)return i}catch{}return r}m(B,"resolveScreenSizeWorld");function Jt(e){if(!e||e.lengthSq()===0)return new f(0,0,1);const t=Math.abs(e.dot(new f(0,0,1)))<.9?new f(0,0,1):new f(0,1,0),n=new f().crossVectors(e,t);return n.lengthSq()===0&&n.crossVectors(e,new f(1,0,0)),n.lengthSq()===0?new f(1,0,0):n.normalize()}m(Jt,"arbitraryPerpendicular3D");function ce(e){if(!e)return null;if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3)return new f(Number(e[0])||0,Number(e[1])||0,Number(e[2])||0);if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),r=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))return new f(t,n,r)}return null}m(ce,"vectorFromAny$2");function en(e){return e>1?1:e<-1?-1:e}m(en,"clampToUnit");function tn(e,t){const n=e.x*t.y-e.y*t.x,r=e.x*t.x+e.y*t.y;return Math.atan2(n,r)}m(tn,"signedAngle2D");function nn(e,t){const n=Math.cos(t),r=Math.sin(t);return new _(e.x*n-e.y*r,e.x*r+e.y*n)}m(nn,"rotate2D");function et(e,t){const n=e.clone().normalize();let r=(t?t.clone():new f(1,0,0)).projectOnPlane(n);r.lengthSq()<1e-12&&(r=Math.abs(n.z)<.9?new f(0,0,1).cross(n):new f(0,1,0).cross(n)),r.normalize();const s=new f().crossVectors(n,r).normalize();return{U:r,V:s,N:n}}m(et,"planeBasis");function Oe(e,t,n){const r=e.clone().sub(t);return new _(r.dot(n.U),r.dot(n.V))}m(Oe,"to2D");function De(e,t){return new _(e.dot(t.U),e.dot(t.V))}m(De,"dirTo2D");function J(e,t,n){return t.clone().add(n.U.clone().multiplyScalar(e.x)).add(n.V.clone().multiplyScalar(e.y))}m(J,"from2D");function rn(e,t,n,r){const s=t.x*r.y-t.y*r.x;if(Math.abs(s)<1e-12)return null;const o=new _().subVectors(n,e),i=(o.x*r.y-o.y*r.x)/s;return new _(e.x+t.x*i,e.y+t.y*i)}m(rn,"intersectLines2D");function on(e,t,n){const r=e.clone().sub(t).dot(n);return e.clone().sub(n.clone().multiplyScalar(r))}m(on,"projectPointToPlane");function be(e,t,n,r){const s=n?e.clone().multiplyScalar(-1):e.clone(),o=r?t.clone().multiplyScalar(-1):t.clone(),i=en(s.dot(o)),a=Math.acos(i),c=tn(s,o);return{A:s,B:o,angle:a,signedAngle:c}}m(be,"createAngleCombo");function Ft(e,t,n,r=!0){if(!e||!t)return null;const s=[be(e,t,!1,!1),be(e,t,!1,!0),be(e,t,!0,!1),be(e,t,!0,!0)],o=Math.PI/2,i=1e-6,a=m((c,l)=>c.length?c.slice().sort(l)[0]:null,"selectByAngle");if(n==="reflex"){const c=s[0],l=Math.abs(c.signedAngle),u=l<1e-6?0:2*Math.PI-l,p=-Math.sign(c.signedAngle||1),d=c.A.clone().add(c.B);return d.lengthSq()<1e-10&&d.set(-c.A.y,c.A.x),d.normalize().multiplyScalar(-1),{start:c.A.clone(),end:c.B.clone(),sweep:u,dirSign:p,angleRad:u,bisector:d,angleType:"reflex",signedAngle:c.signedAngle}}if(n==="acute"){if(!r){const d=s[0],h=d.A.clone().add(d.B);h.lengthSq()<1e-10&&h.set(-d.A.y,d.A.x),h.normalize();const g=Math.abs(d.signedAngle)<1e-8?1:Math.sign(d.signedAngle),b=Math.abs(d.signedAngle);return{start:d.A.clone(),end:d.B.clone(),sweep:b,dirSign:g,angleRad:b,bisector:h,angleType:"acute",signedAngle:d.signedAngle}}const c=s.filter(d=>d.angle<=o+i),l=a(c.length?c:s,(d,h)=>d.angle-h.angle);if(!l)return null;const u=l.A.clone().add(l.B);u.lengthSq()<1e-10&&u.set(-l.A.y,l.A.x),u.normalize();const p=Math.abs(l.signedAngle)<1e-8?1:Math.sign(l.signedAngle);return{start:l.A.clone(),end:l.B.clone(),sweep:l.angle,dirSign:p,angleRad:l.angle,bisector:u,angleType:"acute",signedAngle:l.signedAngle}}if(n==="obtuse"){const c=s.filter(d=>d.angle>=o-i);let l=a(c,(d,h)=>d.angle-h.angle);if(l||(l=a(s,(d,h)=>h.angle-d.angle)),!l)return null;const u=l.A.clone().add(l.B);u.lengthSq()<1e-10&&u.set(-l.A.y,l.A.x),u.normalize();const p=Math.abs(l.signedAngle)<1e-8?1:Math.sign(l.signedAngle);return{start:l.A.clone(),end:l.B.clone(),sweep:l.angle,dirSign:p,angleRad:l.angle,bisector:u,angleType:"obtuse",signedAngle:l.signedAngle}}return null}m(Ft,"resolveAngleOrientation2D");function sn({planePoint:e=null,planeNormal:t=null,basis:n=null,vertex2D:r=null,directionA2D:s=null,directionB2D:o=null,sweepRad:i=0,sweepDirection:a=1,bisector2D:c=null,labelWorld:l=null,screenSizeWorld:u=null,fallbackScreenSizeWorld:p=null,defaultRadiusPixels:d=60,minRadiusPixels:h=30,arcDensity:g=64,minArcSteps:b=48,extensionPixels:y=25,stubPixels:N=12,labelOffsetPixels:A=70,arrowLengthPixels:x=10,arrowWidthPixels:D=4}={}){if(!e||!t||!n||!r||!s||!o)return null;const w=r.clone(),S=s.clone(),z=o.clone();if(S.lengthSq()<=1e-12||z.lengthSq()<=1e-12)return null;S.normalize(),z.normalize();const M=t.clone().normalize();let T=null;const F=ce(l);if(F){const ie=on(F,e,M);T=Oe(ie,e,n).clone().sub(w).length()}(!Number.isFinite(T)||T<=0)&&(T=B(d,u,p,.02));const L=B(h,u,p,.01);T=Math.max(T,L);const R=[],Z=Math.max(0,Number(i)||0),ot=Number(a)||1;if(Z>1e-6){const ie=Math.max(b,Math.floor(Z*g));for(let K=0;K<=ie;K+=1){const Me=K/ie,Ee=ot*Z*Me,at=nn(S,Ee),Ht=new _(w.x+at.x*T,w.y+at.y*T);R.push(J(Ht,e,n))}}const he=B(x,u,p,.08),ye=B(D,u,p,.03),oe=[];if(R.length>=2){const ie=R[0].clone().sub(R[1]).normalize();oe.push({tip:R[0].clone(),direction:ie,length:he,width:ye});const K=R[R.length-1].clone(),Me=R[R.length-2].clone(),Ee=K.clone().sub(Me).normalize();oe.push({tip:K,direction:Ee,length:he,width:ye})}const se=T+B(y,u,p,.02),ge=B(N,u,p,.01),fe=J(w,e,n),Ct=J(new _(w.x+S.x*se,w.y+S.y*se),e,n),Bt=J(new _(w.x+z.x*se,w.y+z.y*se),e,n),jt=J(new _(w.x-S.x*ge,w.y-S.y*ge),e,n),It=J(new _(w.x-z.x*ge,w.y-z.y*ge),e,n),$t=[[fe.clone(),Ct],[fe.clone(),Bt],[fe.clone(),jt],[fe.clone(),It]];let pe=c?c.clone():new _().addVectors(S,z);pe.lengthSq()<1e-10&&pe.set(-S.y,S.x),pe.normalize();const st=B(A,u,p,.03),it=T>0?T+st*.3:st,Ut=new _(w.x+pe.x*it,w.y+pe.y*it),Xt=J(Ut,e,n);return{radius:T,arcPoints:R,arrowSpecs:oe,segments:$t,labelPosition:Xt,originWorld:fe}}m(sn,"buildAngleDimensionGeometry");function an({pointA:e=null,pointB:t=null,normal:n=null,offset:r=0,showExtensions:s=!0,labelWorld:o=null,screenSizeWorld:i=null,fallbackScreenSizeWorld:a=null,arrowLengthPixels:c=12,arrowWidthPixels:l=4,labelLiftPixels:u=6,labelLeaderThresholdPixels:p=6}={}){const d=ce(e),h=ce(t);if(!d||!h)return null;const g=h.clone().sub(d);if(g.lengthSq()<1e-8)return null;g.normalize();let b=ce(n);(!b||b.lengthSq()<1e-12)&&(b=new f(0,0,1)),b.normalize();let y=new f().crossVectors(b,g);if(y.lengthSq()<1e-12&&(y=Jt(g)),y.lengthSq()<1e-12)return null;y.normalize();let N=Number(r);Number.isFinite(N)||(N=B(20,i,a,.05));const A=d.clone().addScaledVector(y,N),x=h.clone().addScaledVector(y,N),D=[];s!==!1&&N!==0&&(D.push([d.clone(),A.clone()]),D.push([h.clone(),x.clone()])),D.push([A.clone(),x.clone()]);const w=B(c,i,a,.08),S=B(l,i,a,.03),z=[{tip:A.clone(),direction:g.clone().negate(),length:w,width:S},{tip:x.clone(),direction:g.clone(),length:w,width:S}],M=ce(o),T=new f().addVectors(A,x).multiplyScalar(.5),F=B(u,i,a,.02),L=M||T.addScaledVector(y,F);let R=null;if(M){const Z=A.distanceTo(x);if(Z>1e-6){const he=M.clone().sub(A).dot(g),ye=Math.max(0,Math.min(Z,he)),oe=A.clone().addScaledVector(g,ye),se=B(p,i,a,.02);M.distanceTo(oe)>se&&(R=[oe,M.clone()])}}return{direction:g,tangent:y,offset:N,offsetA:A,offsetB:x,segments:D,arrowSpecs:z,labelPosition:L,leaderSegment:R}}m(an,"buildLinearDimensionGeometry");const te=class te{constructor({id:t=null,history:n=null,registry:r=null}={}){this.entityType=this.constructor.entityType||this.constructor.type||"ENTITY",this.type=this.entityType,this.title=this.constructor.shortName,this.shortName=this.constructor.shortName||this.constructor.featureShortName||null,this.history=n||null,this.registry=r||null,this.id=null,this.inputParams={id:t},this.persistentData={},this.runtimeAttributes={},t!=null?this.setId(t):this.inputParams.type=this.entityType}setId(t){this.id=t??null,(!this.inputParams||typeof this.inputParams!="object")&&(this.inputParams={}),this.id!=null&&this.inputParams.id==null&&(this.inputParams.id=this.id),this.onIdChanged()}setParams(t={}){this.inputParams=we(t||{}),this.id!=null&&this.inputParams.id==null&&(this.inputParams.id=this.id),this.inputParams.type||(this.inputParams.type=this.entityType),this.onParamsChanged()}mergeParams(t={}){const n=we(t||{});this.inputParams={...this.inputParams,...n},this.id!=null&&this.inputParams.id==null&&(this.inputParams.id=this.id),this.inputParams.type||(this.inputParams.type=this.entityType),this.onParamsChanged()}setPersistentData(t={}){this.persistentData=we(t||{}),this.onPersistentDataChanged()}mergePersistentData(t={}){const n=we(t||{});this.persistentData={...this.persistentData,...n},this.onPersistentDataChanged()}run(t={}){throw new Error(`${this.constructor.name} must implement run(context)`)}};m(te,"ListEntityBase"),P(te,"entityType","ENTITY"),P(te,"shortName","ENT"),P(te,"longName","EntityBase"),P(te,"inputParamsSchema",{});let _e=te;const C=class C extends _e{constructor(t={}){super({history:t.history||null,registry:t.registry||null}),this.resultArtifacts=[]}static _normalizeSelectionItems(t){return Array.isArray(t)?t:[]}static _normalizeSelectionType(t){return String(t||"").toUpperCase()}static _isSelectionType(t,n){return!n||!n.size?!0:n.has(C._normalizeSelectionType(t?.type))}static _selectionRefName(t){return t?.name||t?.userData?.faceName||t?.userData?.edgeName||t?.userData?.vertexName||t?.userData?.solidName||t?.userData?.name||null}static _collectSelectionRefs(t,n=null){const r=C._normalizeSelectionItems(t),s=Array.isArray(n)?new Set(n.map(i=>C._normalizeSelectionType(i))):null,o=[];for(const i of r){if(!C._isSelectionType(i,s))continue;const a=C._selectionRefName(i);a&&o.push(a)}return o}async run(t){return console.warn(`BaseAnnotation.run() not implemented for ${this.constructor.name}`),[]}getScene(){return this.renderingContext?.pmimode?.viewer?.partHistory?.scene||null}getObjectByName(t){const n=this.getScene();return n?n.getObjectByName(t):null}static getSchema(t,n){const r={},s={},o=n||{};for(const i in this.inputParamsSchema){if(!Object.prototype.hasOwnProperty.call(this.inputParamsSchema,i))continue;const a=this.inputParamsSchema[i]||{},c={...a},l=Object.prototype.hasOwnProperty.call(o,i)?U(o[i]):U(a.default_value);c&&Object.prototype.hasOwnProperty.call(c,"default_value")&&(c.default_value=U(l)),r[i]=c,s[i]=l}return{schema:r,params:s}}static applyParams(t,n,r){const s=ln(this.inputParamsSchema,r,n);return Object.assign(n,s),{paramsPatch:{}}}static ensurePersistentData(t){return!t||typeof t!="object"?null:((!t.persistentData||typeof t.persistentData!="object")&&(t.persistentData={}),t.persistentData)}static dragLabelOnPlane(t,n,r={}){if(!n||typeof r.makePlane!="function")return;const s=r.makePlane();if(!s||!(s instanceof I)&&!s.isPlane)return;const o=r.eventTarget||window,i=t?.viewer,a=m(l=>{const u=n.raycastFromEvent?n.raycastFromEvent(l):null;if(!u)return;const p=new f;(n.intersectPlane?n.intersectPlane(u,s,p):u.intersectPlane(s,p))&&typeof r.onDrag=="function"&&r.onDrag(p,l,s)},"onMove"),c=m(l=>{try{o.removeEventListener("pointermove",a,!0)}catch{}try{o.removeEventListener("pointerup",c,!0)}catch{}if(r.suspendControls===!0)try{i?.controls&&(i.controls.enabled=!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}if(typeof r.onEnd=="function")try{r.onEnd(l)}catch{}if(r.preventDefault!==!1)try{l.preventDefault(),l.stopImmediatePropagation?.(),l.stopPropagation()}catch{}},"onUp");try{t?.showDragPlaneHelper?.(s)}catch{}if(r.suspendControls===!0)try{i?.controls&&(i.controls.enabled=!1)}catch{}try{o.addEventListener("pointermove",a,!0)}catch{}try{o.addEventListener("pointerup",c,!0)}catch{}}onIdChanged(){(!this.inputParams||typeof this.inputParams!="object")&&(this.inputParams={}),this.inputParams.id=this.id}onParamsChanged(){(!this.inputParams||typeof this.inputParams!="object")&&(this.inputParams={}),this.inputParams.id||(this.inputParams.id=this.id),this.inputParams.type||(this.inputParams.type=this.type||this.entityType||"annotation")}onPersistentDataChanged(){(!this.persistentData||typeof this.persistentData!="object")&&(this.persistentData={})}};m(C,"BaseAnnotation"),P(C,"entityType","annotation"),P(C,"shortName","ANN"),P(C,"longName","Annotation"),P(C,"inputParamsSchema",{});let v=C;function ln(e,t,n){const r={},s=t&&typeof t=="object"?t:{};for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o]||{};if(i.readOnly){n&&Object.prototype.hasOwnProperty.call(n,o)?r[o]=n[o]:r[o]=U(i.default_value);continue}const a=s[o],c=n&&Object.prototype.hasOwnProperty.call(n,o);if(a===void 0){r[o]=U(c?n[o]:i.default_value);continue}switch(i.type){case"number":{const l=Number(a);r[o]=Number.isFinite(l)?l:c&&Number.isFinite(n[o])?Number(n[o]):Number.isFinite(i.default_value)?i.default_value:0;break}case"boolean":r[o]=a==="false"?!1:!!a;break;case"options":{const l=Array.isArray(i.options)?i.options:[],u=a==null?"":String(a);l.includes(u)?r[o]=u:c&&l.includes(n[o])?r[o]=n[o]:r[o]=l.includes(i.default_value)?i.default_value:l[0]||"";break}case"reference_selection":{if(i.multiple){const l=Array.isArray(a)?a:a?[a]:[];r[o]=l.map(u=>u==null?"":String(u)).filter(u=>u.length),!r[o].length&&c&&Array.isArray(n[o])&&(r[o]=n[o].slice())}else r[o]=a==null?c?String(n[o]??""):"":String(a);break}case"textarea":case"string":r[o]=a==null?c?String(n[o]??""):"":String(a);break;case"object":r[o]=U(a&&typeof a=="object"?a:i.default_value);break;case"transform":r[o]=cn(a,i.default_value);break;case"vec3":r[o]=un(a,i.default_value);break;default:r[o]=U(a);break}}return r}m(ln,"sanitizeAnnotationParams");function cn(e,t){const n=e&&typeof e=="object"?e:t||{},r=m((s,o,i=3)=>{const a=Array.isArray(s)?s:o&&Array.isArray(o)?o:[],c=[];for(let l=0;l<i;l+=1){const u=a[l],p=Number(u);c[l]=Number.isFinite(p)?p:0}return c},"toArray");return{position:r(n.position,t?.position||[0,0,0]),rotationEuler:r(n.rotationEuler,t?.rotationEuler||[0,0,0]),scale:r(n.scale,t?.scale||[1,1,1])}}m(cn,"normalizeTransform");function un(e,t){const n=Array.isArray(e)?e:e&&typeof e=="object"?[e.x,e.y,e.z]:t;if(!Array.isArray(n))return[0,0,0];const r=[];for(let s=0;s<3;s+=1){const o=Number(n[s]);r[s]=Number.isFinite(o)?o:0}return r}m(un,"normalizeVec3");function U(e){if(e==null)return e;if(Array.isArray(e))return e.map(t=>U(t));if(typeof e=="object"){const t={};for(const n of Object.keys(e))t[n]=U(e[n]);return t}return e}m(U,"__cloneValue");const fn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the linear dimension"},targets:{type:"reference_selection",selectionFilter:["VERTEX","EDGE"],multiple:!0,default_value:[],label:"Targets",hint:"Select two vertices, or a vertex and an edge, or a single edge"},planeRefName:{type:"reference_selection",selectionFilter:["FACE","PLANE"],multiple:!1,default_value:"",label:"Face/Plane",hint:"Projection plane (optional)"},alignment:{type:"options",default_value:"view",options:["view","XY","YZ","ZX"],label:"Alignment",hint:"Dimension alignment mode"},offset:{type:"number",default_value:0,label:"Offset",hint:"Offset distance for the dimension line",step:"any"},showExt:{type:"boolean",default_value:!0,label:"Extension Lines",hint:"Draw extension lines from anchors to offset line"},isReference:{type:"boolean",default_value:!1,label:"Reference",hint:"Mark as reference dimension (parentheses)"},decimals:{type:"number",default_value:3,defaultResolver:m(({pmimode:e})=>{const t=Number.isFinite(e?._opts?.dimDecimals)?e._opts.dimDecimals|0:void 0;if(Number.isFinite(t))return Math.max(0,Math.min(8,t))},"defaultResolver"),label:"Decimals",hint:"Number of decimal places to display",min:0,max:8,step:1}},$=class $ extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["VERTEX","EDGE"]);return n.length?{params:{targets:n.slice(0,2)}}:!1}constructor(t={}){super(t)}uiFieldsTest(t){const n=this.inputParams?.planeRefName;return(Array.isArray(n)?n.length>0:!!String(n||"").trim())?["alignment"]:[]}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=ut(n,i),c=a&&a.p0&&a.p1?a.p0.distanceTo(a.p1):null,l=ct(c,i);if(i.value=l.display,!a||!a.p0||!a.p1)return[];(!i.persistentData||typeof i.persistentData!="object")&&(i.persistentData={});const u=i.persistentData;try{const d=o.alignNormal?o.alignNormal(i?.alignment||"view",i):new f(0,0,1),h=an({pointA:a.p0,pointB:a.p1,normal:d,offset:i?.offset,showExtensions:i?.showExt!==!1,labelWorld:u.labelWorld||i.labelWorld,screenSizeWorld:o.screenSizeWorld,fallbackScreenSizeWorld:m(x=>q(n?.viewer,x),"fallbackScreenSizeWorld")});if(!h)return[];for(const[x,D]of h.segments)r.add(Y(x,D,1096065));for(const x of h.arrowSpecs)ne(r,x.tip,x.direction,x.length,x.width,1096065);h.leaderSegment&&r.add(Y(h.leaderSegment[0],h.leaderSegment[1],1096065));const g=Number.isFinite(i.decimals)?i.decimals:n?._opts?.dimDecimals|0,b=a.p0.distanceTo(a.p1),y=ct(b,i,g);i.value=y.display;const N=o.formatReferenceLabel?o.formatReferenceLabel(i,y.raw):y.display,A=h.labelPosition;A&&o.updateLabel(s,N,A,i)}catch{}return[]}static onLabelPointerDown(t,n,r,s,o){try{if(!t.viewer?.camera)return;const c=ut(t,r);if(!c||!c.p0||!c.p1)return;const l=c.p0,u=c.p1,p=o.alignNormal?o.alignNormal(r?.alignment||"view",r):new f(0,0,1),d=new f().subVectors(u,l).normalize(),h=new f().crossVectors(p,d).normalize(),g=new f().addVectors(l,u).multiplyScalar(.5),b=new I().setFromNormalAndCoplanarPoint(p,g);$.dragLabelOnPlane(t,o,{makePlane:m(()=>b,"makePlane"),onDrag:m(y=>{const A=new f().subVectors(y,g).dot(h);r.offset=A;const x=[y.x,y.y,y.z];$.ensurePersistentData(r),r.persistentData.labelWorld=x,r.labelWorld=x,o.updateLabel(n,null,y,r),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m($,"LinearDimensionAnnotation"),P($,"entityType","linear"),P($,"type","linear"),P($,"shortName","DIM"),P($,"longName","Linear Dimension"),P($,"title","Linear"),P($,"inputParamsSchema",fn);let Ce=$;function ct(e,t,n){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const r=n!==void 0?n:Number(t?.decimals),s=Number.isFinite(r)?Math.max(0,Math.min(8,r|0)):3,o=`${e.toFixed(s)}`,i=t?.isReference?`(${o})`:o;return{raw:o,display:i}}m(ct,"formatLinearLabel");function ut(e,t){const n=Array.isArray(t?.targets);try{const r=e?.viewer?.partHistory?.scene,s=pn(n?t.targets:null);if(r&&s.length){const o=dn(r,s);if(o.length){const i=[],a=[];for(const l of o){const u=typeof l?.type=="string"?l.type.toUpperCase():"";u==="VERTEX"?i.push(l):u==="EDGE"&&a.push(l)}const c=e?.viewer;if(i.length>=2){const l=ve(c,i[0]),u=ve(c,i[1]);if(l&&u)return{p0:l,p1:u}}if(i.length===1&&a.length){const l=ve(c,i[0]),u=l?mn(a,l):null;if(l&&u)return{p0:l,p1:u}}if(!i.length&&a.length){if(a.length===1){const l=qt(a[0]);if(l)return{p0:l.a,p1:l.b}}else if(a.length>=2)return Rt(a[0],a[1])}}}}catch{}if(!n)try{const r=e?.viewer?.partHistory?.scene,s=t?.aRefName||null,o=t?.bRefName||null;if(r&&(s||o)){const i=s?r.getObjectByName(s):null,a=o?r.getObjectByName(o):null;if(i&&a)return hn(i,a);if(i&&!a){const c=E(e.viewer,i),l=xe(t.p1);if(c&&l)return{p0:c,p1:l}}if(!i&&a){const c=E(e.viewer,a),l=xe(t.p0);if(l&&c)return{p0:l,p1:c}}}}catch{}return{p0:xe(t?.p0)||new f(0,0,0),p1:xe(t?.p1)||new f(0,0,0)}}m(ut,"computeDimPoints");function pn(e){return Array.isArray(e)?e:e==null||e===""?[]:[e]}m(pn,"normalizeTargetList");function dn(e,t){if(!e||!Array.isArray(t))return[];const n=[],r=new Set;for(const s of t){let o=null;if(s&&typeof s=="object")s.isObject3D?o=s:s.name&&(o=e.getObjectByName(s.name));else if(s!=null){const a=String(s).trim();a&&(o=e.getObjectByName(a))}if(!o)continue;const i=o.uuid||o.id||o.name;if(i!=null){const a=String(i);if(r.has(a))continue;r.add(a)}n.push(o)}return n}m(dn,"resolveTargetObjects");function ve(e,t){const n=E(e,t);return n&&n.clone||n&&n.isVector3?n.clone():t?.getWorldPosition?t.getWorldPosition(new f):null}m(ve,"resolveVertexPoint");function mn(e,t){if(!Array.isArray(e)||!t)return null;let n=null,r=1/0;for(const s of e){const o=qt(s);if(o){const a=o.a.distanceToSquared(t);a<r&&(r=a,n=o.a);const c=o.b.distanceToSquared(t);c<r&&(r=c,n=o.b);continue}const i=Be(s,t);if(i){const a=i.distanceToSquared(t);a<r&&(r=a,n=i)}}return n?n.clone():null}m(mn,"closestEndpointToPoint");function qt(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}try{if(typeof e.points=="function"){const o=e.points(!0);if(Array.isArray(o)&&o.length>=2){const i=Se(o[0]),a=Se(o[o.length-1]);if(i&&a)return{a:i,b:a}}}}catch{}const t=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(t&&t.length>=2){const o=Se(t[0]),i=Se(t[t.length-1]);if(o&&i)return e.matrixWorld&&(o.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld)),{a:o,b:i}}const n=e?.geometry?.attributes?.instanceStart,r=e?.geometry?.attributes?.instanceEnd;if(n&&r&&n.count>=1){const o=new f(n.getX(0),n.getY(0),n.getZ(0)),i=new f(r.getX(0),r.getY(0),r.getZ(0));return e.matrixWorld&&(o.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld)),{a:o,b:i}}const s=e?.geometry?.getAttribute?.("position");if(s&&s.itemSize===3&&s.count>=2){const o=new f(s.getX(0),s.getY(0),s.getZ(0)),i=new f(s.getX(s.count-1),s.getY(s.count-1),s.getZ(s.count-1));return e.matrixWorld&&(o.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld)),{a:o,b:i}}return null}m(qt,"edgeEndpointsWorld");function hn(e,t){if(e?.type==="VERTEX"&&t?.type==="VERTEX")return{p0:e.getWorldPosition(new f),p1:t.getWorldPosition(new f)};if(e?.type==="EDGE"&&t?.type==="VERTEX"){const n=t.getWorldPosition(new f);return{p0:Be(e,n),p1:n}}if(e?.type==="VERTEX"&&t?.type==="EDGE"){const n=e.getWorldPosition(new f),r=Be(t,n);return{p0:n,p1:r}}return e?.type==="EDGE"&&t?.type==="EDGE"?Rt(e,t):{p0:E(null,e)||new f,p1:E(null,t)||new f}}m(hn,"closestPointsForObjects");function Be(e,t){try{const n=e.points(!0);if(!n||n.length<2)return e.getWorldPosition(new f);const r=t.clone();let s={d2:1/0,q:null};const o=new f,i=new f;for(let a=0;a<n.length-1;a++){o.set(n[a].x,n[a].y,n[a].z),i.set(n[a+1].x,n[a+1].y,n[a+1].z);const c=yn(o,i,r),l=c.distanceToSquared(r);l<s.d2&&(s={d2:l,q:c})}return s.q||e.getWorldPosition(new f)}catch{return e.getWorldPosition(new f)}}m(Be,"closestPointOnEdgeToPoint");function Rt(e,t){try{const n=e.points(!0),r=t.points(!0);if(!n||n.length<2||!r||r.length<2)return{p0:E(null,e)||new f,p1:E(null,t)||new f};const s=new f,o=new f,i=new f,a=new f;let c={d2:1/0,p:null,q:null};for(let l=0;l<n.length-1;l++){s.set(n[l].x,n[l].y,n[l].z),o.set(n[l+1].x,n[l+1].y,n[l+1].z);for(let u=0;u<r.length-1;u++){i.set(r[u].x,r[u].y,r[u].z),a.set(r[u+1].x,r[u+1].y,r[u+1].z);const{p,q:d}=gn(s,o,i,a),h=p.distanceToSquared(d);h<c.d2&&(c={d2:h,p,q:d})}}return{p0:c.p||E(null,e)||new f,p1:c.q||E(null,t)||new f}}catch{return{p0:E(null,e)||new f,p1:E(null,t)||new f}}}m(Rt,"closestPointsBetweenEdges");function yn(e,t,n){const r=t.clone().sub(e),s=Math.max(0,Math.min(1,r.dot(n.clone().sub(e))/(r.lengthSq()||1)));return e.clone().addScaledVector(r,s)}m(yn,"closestPointOnSegment");function gn(e,t,n,r){const s=t.clone().sub(e),o=r.clone().sub(n),i=e.clone().sub(n),a=s.dot(s),c=o.dot(o),l=o.dot(i);let u,p;const d=1e-12;if(a<=d&&c<=d)u=0,p=0;else if(a<=d)u=0,p=Math.max(0,Math.min(1,l/c));else{const b=s.dot(i);if(c<=d)p=0,u=Math.max(0,Math.min(1,-b/a));else{const y=s.dot(o),N=a*c-y*y;u=N!==0?Math.max(0,Math.min(1,(y*l-b*c)/N)):0,p=(y*u+l)/c,p<0?(p=0,u=Math.max(0,Math.min(1,-b/a))):p>1&&(p=1,u=Math.max(0,Math.min(1,(y-b)/a)))}}const h=e.clone().addScaledVector(s,u),g=n.clone().addScaledVector(o,p);return{p:h,q:g}}m(gn,"closestPointsOnSegments");function Se(e){return ce(e)}m(Se,"arrayToVector");function xe(e){return e?e instanceof f?e.clone():Array.isArray(e)?new f(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new f(e.x||0,e.y||0,e.z||0):null:null}m(xe,"vectorFromAnnotationPoint");const wn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the radial dimension"},cylindricalFaceRef:{type:"reference_selection",selectionFilter:["FACE"],multiple:!1,default_value:"",label:"Cylindrical Face",hint:"Select cylindrical face"},planeRef:{type:"reference_selection",selectionFilter:["FACE","PLANE"],multiple:!1,default_value:"",label:"Projection Plane",hint:"Optional plane used to project the dimension"},displayStyle:{type:"options",default_value:"radius",options:["radius","diameter"],label:"Display Style",hint:"Display as radius or diameter"},alignment:{type:"options",default_value:"view",options:["view","XY","YZ","ZX"],label:"Alignment",hint:"Dimension alignment mode"},offset:{type:"number",default_value:0,label:"Offset",hint:"Distance to offset the dimension line",step:"any"},isReference:{type:"boolean",default_value:!1,label:"Reference",hint:"Mark as reference dimension (parentheses)"},decimals:{type:"number",default_value:3,defaultResolver:m(({pmimode:e})=>{const t=Number.isFinite(e?._opts?.dimDecimals)?e._opts.dimDecimals|0:void 0;if(Number.isFinite(t))return Math.max(0,Math.min(8,t))},"defaultResolver"),label:"Decimals",hint:"Number of decimal places to display",min:0,max:8,step:1}},X=class X extends v{static showContexButton(t){const n=v._normalizeSelectionItems(t),r=new Set(["FACE"]);for(const s of n){if(!v._isSelectionType(s,r)||!bn(s))continue;const o=v._selectionRefName(s);if(o)return{params:{cylindricalFaceRef:o}}}return!1}constructor(t={}){super(t)}uiFieldsTest(t){const n=this.inputParams?.planeRef;return(Array.isArray(n)?n.length>0:!!String(n||"").trim())?["alignment"]:[]}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=Sn(n,i),c=ft(a,i);i.value=c.display,pt(i);try{const l=Ie(n,i,o);if(!l||!l.center||!l.radiusPoint)return[];const{center:u,radiusPoint:p,planeNormal:d,planePoint:h,radius:g}=l,b=16739125;let y=new f().subVectors(p,u);y.lengthSq()<1e-6&&y.set(1,0,0),y.normalize();let N=d;if(N||(N=o.alignNormal?o.alignNormal(i.alignment||"view",i):null),N&&N.lengthSq()>1e-6){const S=y.clone().projectOnPlane(N).normalize();S.lengthSq()>1e-6&&(y=S)}const A=o.screenSizeWorld?o.screenSizeWorld(12):q(n?.viewer,12),x=o.screenSizeWorld?o.screenSizeWorld(4):q(n?.viewer,4),D=i.displayStyle==="diameter",w=i.persistentData?.labelWorld?$e(i.persistentData.labelWorld):null;if(D){const S=w?w.clone().sub(u).normalize():y.clone(),z=w?u.clone().addScaledVector(S,w.clone().sub(u).length()):u.clone().addScaledVector(S,g+Math.abs(Number(i.offset)||o.screenSizeWorld?o.screenSizeWorld(50):q(n?.viewer,50))),M=u.clone().addScaledVector(S,-g),T=u.clone().addScaledVector(S,g),F=u.clone().addScaledVector(S,-g);r.add(Y(M,z,b)),ne(r,T,S.clone(),A,x,b),ne(r,F,S.clone().negate(),A,x,b);const L=Ve(o.screenSizeWorld?o.screenSizeWorld(6):q(n?.viewer,6),b);L.position.copy(u),r.add(L)}else{const S=w||Lt(n,i,u,p,d,h,o);let M=S.clone().sub(u).clone();M.lengthSq()||(M=y.clone()),M.normalize();const T=S;r.add(Y(u,T,b));const F=u.clone().addScaledVector(M,g);ne(r,F,M.clone(),A,x,b);const L=Ve(o.screenSizeWorld?o.screenSizeWorld(6):q(n?.viewer,6),b);L.position.copy(u),r.add(L)}if(typeof a=="number"){const S=ft(a,i);i.value=S.display;const z=o.formatReferenceLabel?o.formatReferenceLabel(i,S.raw):S.display,M=xn(n,i,u,p,d,h,o);M&&o.updateLabel(s,z,M,i)}}catch(l){console.warn("RadialDimensionAnnotation render error:",l)}return[]}static onLabelPointerDown(t,n,r,s,o){try{const i=Ie(t,r,o);if(!i||!i.center||!i.radiusPoint)return;const a=i.planeNormal&&i.planeNormal.lengthSq()>1e-6?i.planeNormal.clone().normalize():o.alignNormal?o.alignNormal(r.alignment||"view",r):new f(0,0,1),c=i.planePoint||i.radiusPoint,l=a&&c?new I().setFromNormalAndCoplanarPoint(a,c):null,u=new f().subVectors(i.radiusPoint,i.center).normalize();X.dragLabelOnPlane(t,o,{makePlane:m(()=>l,"makePlane"),onDrag:m(p=>{l.projectPoint(p,p),pt(r),r.persistentData.labelWorld=[p.x,p.y,p.z];const d=new f().subVectors(p,i.center);r.offset=d.dot(u)-i.radius,o.updateLabel(n,null,p,r),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m(X,"RadialDimensionAnnotation"),P(X,"entityType","radial"),P(X,"type","radial"),P(X,"shortName","RAD"),P(X,"longName","Radial Dimension"),P(X,"title","Radial"),P(X,"inputParamsSchema",wn);let je=X;function ft(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=t?.displayStyle==="diameter"?e*2:e,r=Number(t?.decimals),s=Number.isFinite(r)?Math.max(0,Math.min(8,r|0)):3,i=`${t?.displayStyle==="diameter"?"⌀":"R"}${n.toFixed(s)}`,a=`${i} (wu)`,c=t?.isReference?`(${a})`:a;return{raw:i,display:c}}m(ft,"formatRadialLabel");function pt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(pt,"ensurePersistent$2");function Ie(e,t,n){try{const r=e?.viewer?.partHistory?.scene;if(!r||!t.cylindricalFaceRef)return null;const s=r.getObjectByName(t.cylindricalFaceRef);if(!s)return null;let o=s;for(;o&&typeof o.getFaceMetadata!="function";)o=o.parent;let i=null,a=null,c=null,l=null,u=null;const p=new f;let d=null,h=null;if(o&&typeof o.getFaceMetadata=="function"&&(d=o.getFaceMetadata(t.cylindricalFaceRef),d&&(d.type==="cylindrical"||d.type==="conical")&&(d.type==="cylindrical"?(i=new f(d.center[0],d.center[1],d.center[2]),a=d.radius,c=new f(d.axis[0],d.axis[1],d.axis[2]).normalize()):Math.abs(d.radiusBottom-d.radiusTop)<1e-6&&(i=new f(d.center[0],d.center[1],d.center[2]),a=d.radiusBottom,c=new f(d.axis[0],d.axis[1],d.axis[2]).normalize()),i&&c&&(s.parent&&s.parent.matrixWorld&&(i.applyMatrix4(s.parent.matrixWorld),c.transformDirection(s.parent.matrixWorld).normalize()),u=new f,Math.abs(c.x)<.9?u.crossVectors(c,new f(1,0,0)).normalize():u.crossVectors(c,new f(0,1,0)).normalize(),l=i.clone().addScaledVector(u,a))),d&&typeof d=="object")){const y=d.pmiRadiusOverride??d.radiusOverride;Number.isFinite(y)&&y>0&&(h=Math.abs(y))}if((!i||!c||!Number.isFinite(a)||a<=0)&&o){const y=Pn(o,s);y&&(i=y.center,c=y.axis,a=y.radius,l=y.radiusPoint,u=y.perpendicular)}if(!i||!c||!Number.isFinite(a)||a<=0){const y=En(s);if(!y)return null;i=y.center,c=y.axis,a=y.radius,l=y.radiusPoint,u=new f().subVectors(l,i).normalize()}if(h&&i){let y=null;u&&u.lengthSq()>1e-12?y=u.clone().normalize():l&&(y=new f().subVectors(l,i),y.lengthSq()>1e-12&&y.normalize()),a=h,y&&(u=y.clone(),l=i.clone().addScaledVector(y,a))}p.copy(i);let g=null,b=null;if(t.planeRef){const y=r.getObjectByName(t.planeRef);y&&(g=ue(e.viewer,y),b=E(e.viewer,y))}if(g&&b&&g.lengthSq()>1e-6){const y=g.clone().normalize();g=y;const N=new I().setFromNormalAndCoplanarPoint(y,b),A=new f;N.projectPoint(i,A),i=A;let x=new f().subVectors(l,p);x.lengthSq()<1e-12&&(x=u.clone());let D=x.projectOnPlane(y);D.lengthSq()<1e-12&&(D=c.clone().cross(y),D.lengthSq()<1e-12&&(Math.abs(y.x)<.9?D=new f().crossVectors(y,new f(1,0,0)):D=new f().crossVectors(y,new f(0,1,0)))),D.normalize(),l=i.clone().addScaledVector(D,a)}return{center:i,radiusPoint:l,planeNormal:g,planePoint:b,axis:c,radius:a}}catch{return null}}m(Ie,"computeRadialPoints");function Fe(e){if(!e||typeof e!="object")return!1;const t=String(e.type||"").toLowerCase();if(t==="cylindrical"){const n=Number(e.radius);return Number.isFinite(n)&&n>0}if(t==="conical"){const n=Number(e.radiusBottom),r=Number(e.radiusTop);return!Number.isFinite(n)||!Number.isFinite(r)||Math.abs(n-r)>1e-6?!1:Math.max(n,r)>0}return!1}m(Fe,"isCylindricalMetadata");function qe(e){if(!e)return null;const t=e.userData||null;if(t?.metadata&&Fe(t.metadata))return t.metadata;if(typeof e.getMetadata=="function")try{const s=e.getMetadata();if(Fe(s))return s}catch{}const n=e?.name||t?.faceName||null;let r=e?.parentSolid||t?.parentSolid||e?.parent||null;for(;r;){if(n&&typeof r.getFaceMetadata=="function"){try{const s=r.getFaceMetadata(n);if(Fe(s))return s}catch{}break}r=r.parent||null}return null}m(qe,"readCylindricalMetadata");function bn(e){if(!e)return!1;if(qe(e))return!0;if(Array.isArray(e.faces)){for(const t of e.faces)if(qe(t))return!0}return!!(e.parent&&qe(e.parent))}m(bn,"hasCylindricalMetadata");function Sn(e,t){try{const n=Ie(e,t);return n&&typeof n.radius=="number"?n.radius:n&&n.center&&n.radiusPoint?n.center.distanceTo(n.radiusPoint):null}catch{return null}}m(Sn,"measureRadialValue");function xn(e,t,n,r,s,o,i){try{let a=null;return t.persistentData?.labelWorld?a=$e(t.persistentData.labelWorld):t.labelWorld&&(a=$e(t.labelWorld)),a||(a=Lt(e,t,n,r,s,o,i)),s&&o&&s.lengthSq()>1e-6&&a&&new I().setFromNormalAndCoplanarPoint(s.clone().normalize(),o).projectPoint(a,a),a}catch{return null}}m(xn,"resolveLabelPosition$1");function Lt(e,t,n,r,s,o,i){try{const a=new f().subVectors(r,n);if(a.lengthSq()<1e-12)return r.clone();a.normalize();let c=Number(t?.offset);(!Number.isFinite(c)||c===0)&&(c=i.screenSizeWorld?i.screenSizeWorld(50):q(e?.viewer,50));const l=n.distanceTo(r),u=n.clone().addScaledVector(a,l+Math.abs(c));return s&&o&&s.lengthSq()>1e-6&&new I().setFromNormalAndCoplanarPoint(s.clone().normalize(),o).projectPoint(u,u),u}catch{return r?r.clone():null}}m(Lt,"computeRadialLabelPosition");function Pn(e,t){try{if(!e||!t)return null;const n=Array.isArray(e._auxEdges)?e._auxEdges:null;if(!n||n.length===0)return null;const r=(t.name||t.userData?.faceName||"").trim();if(!r)return null;const s=Mn(r);if(!s)return null;const o=Nn(n,`${s}_PATH`);if(!o||!Array.isArray(o.points)||o.points.length<2)return null;e.updateMatrixWorld?.(!0),t.updateMatrixWorld?.(!0);const i=An(o,e);if(!i||i.length<2)return null;const a=Dn(t,16);if(!a.length)return null;let c=null;for(const l of a){const u=Tn(l,i,!!o.closedLoop);if(!u||!u.point)continue;const p=new f().subVectors(l,u.point),d=p.lengthSq();if(!(d>1e-10))continue;const h=Math.sqrt(d);p.normalize(),(!c||h>c.radius)&&(c={center:u.point.clone(),axis:u.direction?u.direction.clone():null,radius:h,radiusPoint:u.point.clone().addScaledVector(p,h),perpendicular:p.clone()})}return c?((!c.axis||c.axis.lengthSq()<1e-10)&&(c.axis=zn(i,c.center,!!o.closedLoop)||new f(0,1,0)),c):null}catch{return null}}m(Pn,"inferPipeFaceDataFromAuxEdges");function Nn(e,t){if(!Array.isArray(e)||!t)return null;for(const r of e)if(r?.name===t)return r;const n=t.toLowerCase();for(const r of e)if(typeof r?.name=="string"&&r.name.toLowerCase()===n)return r;return null}m(Nn,"findAuxEdgeByName");function An(e,t){try{const n=[],r=!e.polylineWorld&&t?.matrixWorld?t.matrixWorld:null,s=new f;for(const o of e.points){if(Array.isArray(o)&&o.length>=3)s.set(o[0],o[1],o[2]);else if(o&&typeof o=="object")s.set(Number(o.x)||0,Number(o.y)||0,Number(o.z)||0);else continue;r&&s.applyMatrix4(r),n.push(s.clone())}return n}catch{return null}}m(An,"buildAuxPolylineWorld");function Dn(e,t=16){try{const n=e?.geometry;if(!n)return[];const r=typeof n.getAttribute=="function"?n.getAttribute("position"):null,s=e.matrixWorld||new me,o=[],i=new f;if(r&&r.count>0){const a=Math.max(1,Math.floor(r.count/t));for(let c=0;c<r.count&&o.length<t;c+=a)i.set(r.getX(c),r.getY(c),r.getZ(c)).applyMatrix4(s),o.push(i.clone())}if(!o.length)try{n.computeBoundingSphere?.(),n.boundingSphere&&(i.copy(n.boundingSphere.center).applyMatrix4(s),o.push(i.clone()))}catch{}return o}catch{return[]}}m(Dn,"collectFaceSamplePoints");function Tn(e,t,n=!1){if(!e||!Array.isArray(t)||t.length<2)return null;const r=new f,s=new f,o=new f;let i=null,a=null,c=1/0;const l=t.length,u=n?l:l-1;for(let p=0;p<u;p++){const d=t[p],h=t[(p+1)%l];if(!d||!h)continue;s.copy(h).sub(d);const g=s.lengthSq();if(g<1e-14)continue;o.copy(e).sub(d);let b=o.dot(s)/g;b=Math.max(0,Math.min(1,b)),r.copy(d).addScaledVector(s,b);const y=r.distanceToSquared(e);y<c&&(c=y,i=r.clone(),a=s.clone().normalize())}return i?{point:i,direction:a,distanceSq:c}:null}m(Tn,"closestPointOnPolyline");function zn(e,t,n=!1){if(!Array.isArray(e)||e.length<2||!t)return null;let r=null,s=1/0;const o=new f,i=new f,a=e.length,c=n?a:a-1;for(let l=0;l<c;l++){const u=e[l],p=e[(l+1)%a];if(!u||!p)continue;o.copy(u).add(p).multiplyScalar(.5);const d=o.distanceToSquared(t);d<s&&(s=d,i.copy(p).sub(u),r=i.lengthSq()>1e-14?i.clone().normalize():null)}return r}m(zn,"estimatePolylineTangent");function Mn(e){const t=/^(.*?)(_Outer|_Inner|_CapStart|_CapEnd)$/i.exec(e);return t?t[1]:null}m(Mn,"pipeFaceBaseName");function En(e){try{const t=e?.geometry;if(!t||!t.getAttribute)return null;const n=t.getAttribute("position");if(!n||n.count<6)return null;const r=e.matrixWorld||new me,s=[],o=new f;for(let w=0;w<n.count;w++)o.set(n.getX(w),n.getY(w),n.getZ(w)).applyMatrix4(r),s.push(o.clone());if(!s.length)return null;const i=new f;for(const w of s)i.add(w);i.divideScalar(s.length);const a=new Float64Array(9),c=new f;for(const w of s)c.copy(w).sub(i),a[0]+=c.x*c.x,a[1]+=c.x*c.y,a[2]+=c.x*c.z,a[4]+=c.y*c.y,a[5]+=c.y*c.z,a[8]+=c.z*c.z;a[3]=a[1],a[6]=a[2],a[7]=a[5];const l=new f(1,0,0);for(let w=0;w<20;w++){const S=a[0]*l.x+a[1]*l.y+a[2]*l.z,z=a[1]*l.x+a[4]*l.y+a[5]*l.z,M=a[2]*l.x+a[5]*l.y+a[8]*l.z;l.set(S,z,M);const T=l.length();if(T<1e-12){l.set(0,1,0);break}l.divideScalar(T)}l.lengthSq()<1e-12&&l.set(0,1,0);let u=1/0,p=-1/0,d=0,h=0;const g=new f,b=new f,y=new f;for(const w of s){c.copy(w).sub(i);const S=c.dot(l);S<u&&(u=S),S>p&&(p=S),b.copy(l).multiplyScalar(S),g.copy(c).sub(b);const z=g.length();z>1e-6&&(h===0&&y.copy(g).normalize(),d+=z,h++)}if(!h)return null;const N=d/h,A=i.clone().add(l.clone().multiplyScalar((u+p)*.5)),x=y.lengthSq()>1e-12?y.clone():new f().crossVectors(l,new f(1,0,0)).normalize();x.lengthSq()<1e-12&&x.set(0,1,0).cross(l).normalize();const D=A.clone().addScaledVector(x,N);return{center:A,axis:l.normalize(),radius:N,radiusPoint:D}}catch{return null}}m(En,"inferCylinderFromGeometry");function $e(e){return e?e instanceof f?e.clone():Array.isArray(e)?new f(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new f(e.x||0,e.y||0,e.z||0):null:null}m($e,"vectorFromAny$1");const vn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the angle dimension"},decimals:{type:"number",default_value:1,defaultResolver:m(({pmimode:e})=>{const t=Number.isFinite(e?._opts?.angleDecimals)?e._opts.angleDecimals|0:void 0;if(Number.isFinite(t))return Math.max(0,Math.min(3,t))},"defaultResolver"),label:"Decimals",hint:"Number of decimal places to display",min:0,max:3,step:1},targets:{type:"reference_selection",selectionFilter:["FACE","EDGE"],multiple:!0,default_value:[],label:"Elements",hint:"Select two edges/faces to define the angle",minSelections:2,maxSelections:2},planeRefName:{type:"reference_selection",selectionFilter:["FACE","PLANE"],multiple:!1,default_value:"",label:"Projection Plane",hint:"Override projection plane (optional)"},reverseElementOrder:{type:"boolean",default_value:!1,label:"Reverse Selection Order",hint:"Swap Element A and Element B to flip the measured side"},isReference:{type:"boolean",default_value:!1,label:"Reference",hint:"Mark as reference dimension (parentheses)"},angleType:{type:"options",default_value:"acute",options:["acute","obtuse","reflex"],label:"Angle Type",hint:"Choose which angle (acute, obtuse, or reflex) to display"}},Q=class Q extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["FACE","EDGE"]);return n.length<2?!1:{params:{targets:n.slice(0,2)}}}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=qn(n,i),c=mt(a,i);i.value=c.display,dt(i);try{const l=ht(n,i,o);if(!l||!l.__2d)return[];const u=16096779,{N:p,P:d,A_d:h,B_d:g,V2:b,basis:y,sweep:N=0,dirSign:A=1,bisector:x=null}=l.__2d,D=sn({planePoint:d,planeNormal:p,basis:y,vertex2D:b,directionA2D:h,directionB2D:g,sweepRad:N,sweepDirection:A,bisector2D:x,labelWorld:i.persistentData?.labelWorld,screenSizeWorld:o.screenSizeWorld,fallbackScreenSizeWorld:m(w=>q(n?.viewer,w),"fallbackScreenSizeWorld")});if(!D)return[];for(let w=0;w<D.arcPoints.length-1;w+=1)r.add(Y(D.arcPoints[w],D.arcPoints[w+1],u));for(const[w,S]of D.segments)r.add(Y(w,S,u));for(const w of D.arrowSpecs)ne(r,w.tip,w.direction,w.length,w.width,u);if(typeof a=="number"){const w=mt(a,i),S=w.raw;i.value=w.display;const z=o.formatReferenceLabel?o.formatReferenceLabel(i,S):w.display,M=D.labelPosition;M&&o.updateLabel(s,z,M,i)}}catch{}return[]}static onLabelPointerDown(t,n,r,s,o){try{const i=ht(t,r,o);if(!i)return;const a=nt(t,r,i,o),c=a?.n||new f(0,0,1),l=a?.p||new f,u=new I().setFromNormalAndCoplanarPoint(c,l);try{t?.showDragPlaneHelper?.(u)}catch{}const p=m(h=>{const g=o.raycastFromEvent?o.raycastFromEvent(h):null;if(!g)return;const b=new f;(o.intersectPlane?o.intersectPlane(g,u,b):g.intersectPlane(u,b))&&(dt(r),r.persistentData.labelWorld=[b.x,b.y,b.z],o.updateLabel(n,null,b,r),t.refreshAnnotationsUI?.())},"onMove"),d=m(h=>{try{window.removeEventListener("pointermove",p,!0),window.removeEventListener("pointerup",d,!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}try{t.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}try{h.preventDefault(),h.stopImmediatePropagation?.(),h.stopPropagation()}catch{}},"onUp");window.addEventListener("pointermove",p,!0),window.addEventListener("pointerup",d,!0)}catch{}}};m(Q,"AngleDimensionAnnotation"),P(Q,"entityType","angle"),P(Q,"type","angle"),P(Q,"shortName","ANG"),P(Q,"longName","Angle Dimension"),P(Q,"title","Angle"),P(Q,"inputParamsSchema",vn);let Ue=Q;function dt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(dt,"ensurePersistent$1");function Fn(e){const t=Array.isArray(e)?e:e==null||e===""?[]:[e],n=[],r=new Set;for(const s of t){let o="";s&&typeof s=="object"?typeof s.name=="string"?o=s.name:s.id!=null&&(o=String(s.id)):s!=null&&(o=String(s)),o=o.trim(),!(!o||r.has(o))&&(r.add(o),n.push(o))}return n}m(Fn,"normalizeTargetNames");function tt(e){const t=Array.isArray(e?.targets),n=Fn(t?e.targets:null);let r="",s="";return n.length?(r=n[0]||"",s=n[1]||""):t||(r=e?.elementARefName||"",s=e?.elementBRefName||""),e?.reverseElementOrder?{elementARefName:s,elementBRefName:r}:{elementARefName:r,elementBRefName:s}}m(tt,"resolveElementRefNames");function Wt(e){const t=e?.angleType;return t==="acute"||t==="obtuse"||t==="reflex"?t:e?.useReflexAngle?"reflex":"acute"}m(Wt,"resolveAngleType");function Vt(e){return!e||typeof e!="object"||!Object.prototype.hasOwnProperty.call(e,"angleType")?!1:e.angleType==="acute"||e.angleType==="obtuse"||e.angleType==="reflex"}m(Vt,"isAngleTypeExplicit");function mt(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=Number(t?.decimals),r=Number.isFinite(n)?Math.max(0,Math.min(3,n|0)):1,s=`${e.toFixed(r)}°`,o=t?.isReference?`(${s})`:s;return{raw:s,display:o}}m(mt,"formatAngleLabel");function qn(e,t){try{const n=Ot(e,t),r=nt(e,t,n);if(!r)return null;const{elementARefName:s,elementBRefName:o}=tt(t),i=Te(e,s,r.n,r.p),a=Te(e,o,r.n,r.p);if(!i||!a)return null;const c=et(r.n,i.d),l=De(i.d,c).normalize(),u=De(a.d,c).normalize(),p=Wt(t),d=Vt(t)||!!t?.useReflexAngle,h=Ft(l,u,p,d);return h?Pe.radToDeg(h.angleRad):null}catch{return null}}m(qn,"measureAngleValue");function Ot(e,t){try{const n=e?.viewer?.partHistory?.scene;if(!n)return null;const{elementARefName:r,elementBRefName:s}=tt(t),o=r?n.getObjectByName(r):null,i=s?n.getObjectByName(s):null;if(!o||!i)return null;const a=ue(e.viewer,o),c=ue(e.viewer,i),l=E(e.viewer,o),u=E(e.viewer,i);let p=null;if(t.planeRefName){const d=n.getObjectByName(t.planeRefName);d&&(p=ue(e.viewer,d))}return{dirA:a,dirB:c,pointA:l,pointB:u,plane:p}}catch{return null}}m(Ot,"computeAngleElements");function ht(e,t,n){try{const r=Ot(e,t);if(!r||!r.dirA||!r.dirB)return null;const s=nt(e,t,r,n);if(!s)return null;const{elementARefName:o,elementBRefName:i}=tt(t),a=Te(e,o,s.n,s.p),c=Te(e,i,s.n,s.p);if(!a||!c)return null;const l=et(s.n,a.d),u=Oe(a.p,s.p,l),p=Oe(c.p,s.p,l);let d=De(a.d,l).normalize(),h=De(c.d,l).normalize();t?.reverseElementOrder&&(d=d.multiplyScalar(-1),h=h.multiplyScalar(-1));const g=Wt(t),b=Vt(t)||!!t?.useReflexAngle,y=Ft(d,h,g,b);if(!y)return null;const N=y.start.clone(),A=y.end.clone();let x=rn(u,N,p,A);if(x){const D=Math.max(1e-6,u.distanceTo(p));Math.max(x.distanceTo(u),x.distanceTo(p))>D*8&&(x=null)}return x||(x=new _().addVectors(u,p).multiplyScalar(.5)),{...r,__2d:{N:s.n,P:s.p,basis:l,A_p:u,B_p:p,A_d:N,B_d:A,V2:x,sweep:y.sweep,dirSign:y.dirSign,angleRad:y.angleRad,angleType:y.angleType,bisector:y.bisector}}}catch{return null}}m(ht,"computeAngleElementsWithGeometry");function nt(e,t,n,r){try{if(t?.planeRefName){const a=e.viewer?.partHistory?.scene?.getObjectByName(t.planeRefName);if(a){const c=ue(e.viewer,a)||new f(0,0,1);if(c.lengthSq()>1e-12){const l=E(e.viewer,a)||new f;return{n:c.clone().normalize(),p:l}}}}if(n?.dirA&&n?.dirB){const a=new f().crossVectors(n.dirA,n.dirB);if(a.lengthSq()>1e-12){const c=n.pointA&&n.pointB?new f().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n.pointA||n.pointB||new f;return{n:a.normalize(),p:c}}}const o=(r?.alignNormal?r.alignNormal("view",t):null)||n?.plane||new f(0,0,1),i=n?.pointA&&n?.pointB?new f().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n?.pointA||n?.pointB||new f;return{n:o.clone().normalize(),p:i}}catch{return{n:new f(0,0,1),p:new f}}}m(nt,"resolveAnglePlane");function Te(e,t,n,r){try{if(!t)return null;const s=e?.viewer?.partHistory?.scene;if(!s)return null;const o=s.getObjectByName(t);if(!o)return null;const i=n&&n.lengthSq()>1e-12?n.clone().normalize():new f(0,0,1),a=E(e.viewer,o)||r||new f,c=r||a,l=new I().setFromNormalAndCoplanarPoint(i,c),u=ue(e.viewer,o),p=u?u.clone().normalize():null,d=o?.userData||{},h=String(o?.type||"").toUpperCase(),g=String(d.type||d.brepType||"").toUpperCase(),y=h==="FACE"||h==="PLANE"||!(h==="FACE"||h==="EDGE"||h==="PLANE")&&(g==="FACE"||g==="PLANE");if(h==="EDGE"||!y&&(g==="EDGE"||o?.isLine||o?.isLine2||o?.isLineSegments||o?.isLineLoop)){const w=Rn(o,l,c);if(w)return w}if(y&&p&&p.lengthSq()>1e-12){const w=p.clone().normalize(),S=new f().crossVectors(w,i),z=S.lengthSq();if(z>1e-12){const M=w.dot(a),T=i.dot(c),F=new f().crossVectors(i,S).multiplyScalar(M),L=new f().crossVectors(S,w).multiplyScalar(T),R=F.add(L).divideScalar(z);return{p:l.projectPoint(R,R.clone()),d:S.normalize()}}}let A=a.clone();if(p&&p.lengthSq()>1e-12){const w=p.dot(i);if(Math.abs(w)>1e-9){const z=c.clone().clone().sub(a).dot(i)/w;A=a.clone().addScaledVector(p,z)}}const x=l.projectPoint(A,A.clone());let D=p?p.clone().projectOnPlane(i):null;return(!D||D.lengthSq()<1e-12)&&(D=et(i).U.clone()),D.normalize(),{p:x,d:D}}catch{return null}}m(Te,"lineInPlaneForElement");function Rn(e,t,n){const r=Ln(e);if(!Array.isArray(r)||r.length<2)return null;const s=[];for(const u of r)u&&s.push(t.projectPoint(u,u.clone()));if(s.length<2)return null;let o=0,i=1,a=0;for(let u=0;u<s.length;u++)for(let p=u+1;p<s.length;p++){const d=s[u].distanceToSquared(s[p]);d>a&&(a=d,o=u,i=p)}if(a<=1e-12)return null;const c=s[i].clone().sub(s[o]).normalize();let l=s[o].clone();if(n){let u=l.distanceToSquared(n);for(let p=0;p<s.length;p++){const d=s[p].distanceToSquared(n);d<u&&(u=d,l=s[p].clone())}}return{p:l,d:c}}m(Rn,"edgeLineInPlane");function Ln(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}const t=e.matrixWorld||null,n=[],r=m(c=>{const l=yt(c);if(!l)return;const u=n[n.length-1];u&&u.distanceToSquared(l)<=1e-14||n.push(l)},"pushUnique");try{if(typeof e.points=="function"){const c=e.points(!0);if(Array.isArray(c))for(const l of c)r(l);if(n.length>=2)return n;n.length=0}}catch{}const s=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(s){for(const c of s){const l=yt(c);l&&(t&&l.applyMatrix4(t),r(l))}if(n.length>=2)return n;n.length=0}const o=e?.geometry?.attributes?.instanceStart,i=e?.geometry?.attributes?.instanceEnd;if(o&&i){const c=Math.min(o.count||0,i.count||0);for(let l=0;l<c;l++){const u=new f(o.getX(l),o.getY(l),o.getZ(l)),p=new f(i.getX(l),i.getY(l),i.getZ(l));t&&(u.applyMatrix4(t),p.applyMatrix4(t)),r(u),r(p)}if(n.length>=2)return n;n.length=0}const a=e?.geometry?.getAttribute?.("position");if(a&&a.itemSize===3&&a.count>=2){for(let c=0;c<a.count;c++){const l=new f(a.getX(c),a.getY(c),a.getZ(c));t&&l.applyMatrix4(t),r(l)}if(n.length>=2)return n}return null}m(Ln,"getEdgeWorldPoints");function yt(e){if(!e)return null;if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3)return new f(e[0]||0,e[1]||0,e[2]||0);if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),r=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))return new f(t,n,r)}return null}m(yt,"pointFromAny");const Wn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the leader"},target:{type:"reference_selection",selectionFilter:["VERTEX"],multiple:!0,default_value:"",label:"Target Point",hint:"Select target point"},text:{type:"textarea",default_value:"TEXT HERE",defaultResolver:m(({pmimode:e})=>{const t=e?._opts?.leaderText;return typeof t=="string"&&t.length?t:void 0},"defaultResolver"),label:"Text",hint:"Leader text content",rows:3},anchorPosition:{type:"options",default_value:"Right Middle",options:["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"],label:"Anchor Position",hint:"Preferred label alignment relative to anchor"},endStyle:{type:"options",default_value:"arrow",options:["arrow","dot"],label:"Leader End",hint:"Choose arrowhead or dot for end marker"}},H=class H extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["VERTEX"]);return n.length?{params:{target:n}}:!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams||{},a=Je();gt(i),i.anchorPosition=wt(i.anchorPosition??i.anchorSide),delete i.anchorSide;const c=n?.viewer,l=c?.partHistory?.scene,u=bt(c,l,i),p=St(n,i,u,o),d=o?.formatReferenceLabel?o.formatReferenceLabel(i,Re(i.text)):Re(i.text);if(i.value=d,p&&o?.updateLabel?.(s,d,p,i),!u.length||!p)return[];const h=a.lineColor??9684477,g=He(n,c),b=ke(u)||p,y=On(p,b,g),N=Math.max(o?.screenSizeWorld?o.screenSizeWorld(18):q(c,18),1e-4),A=Math.max(o?.screenSizeWorld?o.screenSizeWorld(36):q(c,36),1e-4),x=_n(u,g,p),D=(x.length-1)*.5;return x.forEach(({point:w,order:S})=>{const z=(S-D)*N,M=p.clone().addScaledVector(y,-A).addScaledVector(g.up,z);if(r.add(Y(w,M,h)),r.add(Y(M,p,h)),i.endStyle==="dot"){const T=a.leaderDotRadiusPx??6,F=o?.screenSizeWorld?o.screenSizeWorld(T):q(c,T),L=Ve(Math.max(F,1e-4),a.dotColor??h);L.position.copy(w),r.add(L)}else{const T=w.clone().sub(M);T.lengthSq()||T.copy(y),T.normalize();const F=a.arrowLengthPx??12,L=a.arrowWidthPx??4,R=o?.screenSizeWorld?o.screenSizeWorld(F):q(c,F),Z=o?.screenSizeWorld?o.screenSizeWorld(L):q(c,L);ne(r,w,T,R,Z,a.arrowColor??h)}}),[]}static applyParams(t,n,r){return super.applyParams(t,n,r),n.text=Re(n.text),Array.isArray(n.target)||(n.target=n.target?[String(n.target)]:[]),n.anchorPosition=wt(n.anchorPosition??n.anchorSide),delete n.anchorSide,n.endStyle=Vn(n.endStyle),{paramsPatch:{}}}static onLabelPointerDown(t,n,r,s,o){try{const i=t?.viewer,a=bt(i,i?.partHistory?.scene,r),c=St(t,r,a,o)||new f,u=He(t,i,r).forward,p=a&&a.length&&a[0]?a[0]:ke(a)||c;if(!o?.raycastFromEvent)return;const d=new I().setFromNormalAndCoplanarPoint(u,p);H.dragLabelOnPlane(t,o,{makePlane:m(()=>d,"makePlane"),onDrag:m(h=>{gt(r),r.persistentData.labelWorld=[h.x,h.y,h.z],o.updateLabel(n,null,h,r),t?.refreshAnnotationsUI?.()},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m(H,"LeaderAnnotation"),P(H,"entityType","leader"),P(H,"type","leader"),P(H,"shortName","LEAD"),P(H,"longName","Leader"),P(H,"title","Leader"),P(H,"inputParamsSchema",Wn);let Xe=H;function gt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(gt,"ensurePersistentData$1");function Re(e){return typeof e=="string"?e:e==null?"":String(e)}m(Re,"sanitizeText$1");function wt(e){const t=new Set(["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"]);if(typeof e=="string"){const n=e.trim();if(t.has(n))return n;const r=n.toLowerCase();if(r==="left")return"Left Middle";if(r==="right")return"Right Middle";if(r==="left-top"||r==="lefttop")return"Left Top";if(r==="left-bottom"||r==="leftbottom")return"Left Bottom";if(r==="right-top"||r==="righttop")return"Right Top";if(r==="right-bottom"||r==="rightbottom")return"Right Bottom"}if(e&&typeof e=="object"){const n=String(e.label||e.value||e.name||"").trim();if(t.has(n))return n}return"Right Middle"}m(wt,"normalizeAnchorPosition$1");function Vn(e){return e==="dot"?"dot":"arrow"}m(Vn,"normalizeEndStyle");function bt(e,t,n){const r=Array.isArray(n?.target)?n.target:[];if(!r.length||!t)return[];const s=[],o=new Set;for(const i of r){const a=typeof i=="string"?i:String(i??"");if(!(!a||o.has(a))){o.add(a);try{const c=t.getObjectByName?.(a);if(!c)continue;let l=E(e,c);!l&&typeof c.getWorldPosition=="function"&&(l=c.getWorldPosition(new f)),l&&s.push(l.clone())}catch{}}}return s}m(bt,"resolveTargetPoints");function St(e,t,n,r){const s=e?.viewer,o=He(e,s),i=n&&n.length&&n[0]?n[0].clone():ke(n)||new f,a=o?.forward&&o.forward.lengthSq()?o.forward.clone():new f(0,0,1),c=new I().setFromNormalAndCoplanarPoint(a,i),l=jn(t?.persistentData?.labelWorld);if(l){const b=l.clone();return c.projectPoint(b,b),b}const u=Math.max(r?.screenSizeWorld?r.screenSizeWorld(90):q(s,90),1e-4),p=Math.max(r?.screenSizeWorld?r.screenSizeWorld(36):q(s,36),1e-4),d=o?.right&&o.right.lengthSq()?o.right.clone():new f(1,0,0),h=o?.up&&o.up.lengthSq()?o.up.clone():new f(0,1,0),g=i.clone().addScaledVector(d,u).addScaledVector(h,p);return c.projectPoint(g,g),g}m(St,"resolveLabelPosition");function He(e,t,n){const r=Cn(e?.viewEntry?.camera);if(r)return r;const s=new f(0,0,-1),o=new f(0,1,0);try{t?.camera?.getWorldDirection&&(t.camera.getWorldDirection(s),s.normalize()),t?.camera?.up&&o.copy(t.camera.up).normalize()}catch{}s.lengthSq()||s.set(0,0,-1),o.lengthSq()||o.set(0,1,0);const i=new f().crossVectors(s,o);i.lengthSq()||(Math.abs(s.z)<.9?o.set(0,0,1):o.set(1,0,0),i.crossVectors(s,o)),i.normalize();const a=new f().crossVectors(i,s);a.lengthSq()||a.copy(o.lengthSq()?o:new f(0,1,0)),a.normalize();const c=s.clone().normalize();return{right:i,up:a,forward:c}}m(He,"computeViewBasis$1");function On(e,t,n){try{const s=e.clone().sub(t||new f);if(s.lengthSq()>1e-10)return s.normalize()}catch{}const r=n?.right?.clone?.()||new f(1,0,0);return r.lengthSq()||r.set(1,0,0),r.normalize()}m(On,"computeShoulderDirection");function _n(e,t,n){if(!e.length)return[];const r=t?.up&&t.up.lengthSq()?t.up:new f(0,1,0),s=e.map((o,i)=>{const c=o.clone().sub(n||new f).dot(r);return{point:o,metric:c,index:i}});return s.sort((o,i)=>o.metric-i.metric),s.map((o,i)=>({point:o.point,order:i}))}m(_n,"sortTargetsByViewUp");function Cn(e){if(!e||typeof e!="object")return null;const t=Bn(e);if(!t)return null;const n=new f(0,0,-1).applyQuaternion(t);if(!n.lengthSq())return null;const r=new f(0,1,0).applyQuaternion(t);let s=new f().crossVectors(n,r);s.lengthSq()||(s=new f().crossVectors(n,new f(0,1,0))),s.lengthSq()||s.set(1,0,0),s.normalize();const o=new f().crossVectors(s,n);o.lengthSq()||o.copy(r.lengthSq()?r:new f(0,1,0)),o.normalize();const i=n.clone().normalize();return{right:s,up:o,forward:i}}m(Cn,"basisFromSavedCamera");function Bn(e){const t=e?.quaternion||e?.camera?.quaternion;if(Array.isArray(t)&&t.length>=4){const[s,o,i,a]=t;if([s,o,i,a].every(c=>Number.isFinite(c)))return new V(s,o,i,a).normalize()}if(t&&typeof t=="object"){const s=Number(t.x),o=Number(t.y),i=Number(t.z),a=Number(t.w);if([s,o,i,a].every(c=>Number.isFinite(c)))return new V(s,o,i,a).normalize()}const n=e?.worldMatrix||e?.cameraMatrix||e?.matrix,r=Array.isArray(n?.elements)?n.elements:n;if(Array.isArray(r)&&r.length===16){const s=new me().fromArray(r),o=new f,i=new V,a=new f;return s.decompose(o,i,a),i.normalize()}return null}m(Bn,"quaternionFromSnapshot");function jn(e){if(!e&&e!==0)return null;if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3){const[t,n,r]=e;return[t,n,r].some(s=>typeof s!="number"||!Number.isFinite(s))?null:new f(t,n,r)}if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),r=Number(e.z);if([t,n,r].every(s=>Number.isFinite(s)))return new f(t,n,r)}return null}m(jn,"vectorFromAny");function ke(e){if(!e||!e.length)return null;const t=new f;return e.forEach(n=>t.add(n)),t.multiplyScalar(1/e.length)}m(ke,"averageTargets");const In={id:{type:"string",default_value:null,hint:"unique identifier for the note"},text:{type:"string",default_value:"",defaultResolver:m(({pmimode:e})=>{const t=e?._opts?.noteText;return typeof t=="string"?t:void 0},"defaultResolver"),hint:"Note text content"},position:{type:"object",default_value:null,hint:"3D position of the note marker"}},k=class k extends v{static showContexButton(t){const n=v._normalizeSelectionItems(t);if(!n.length)return!1;const r=n[0],s=E(null,r);return s?{params:{position:{x:s.x,y:s.y,z:s.z}}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=Je(),c=new f(i.position?.x||0,i.position?.y||0,i.position?.z||0),l=new Gt(a.noteDotRadius??.08,16,12),u=new Qt({color:a.noteDotColor??a.dotColor??9684477,depthTest:!1,depthWrite:!1,transparent:!0}),p=new Yt(l,u);p.position.copy(c),r.add(p);const d=String(i.text||"");if(!d)return[];let h=null;if(i.labelWorld)h=new f(i.labelWorld.x,i.labelWorld.y,i.labelWorld.z);else{const g=o.alignNormal("view",i),b=new f,y=new f(0,1,0);try{n.viewer?.camera?.getWorldDirection?.(b),b.crossVectors(g,y).normalize()}catch{b.set(1,0,0)}const N=o.screenSizeWorld(16);h=c.clone().addScaledVector(b,N).addScaledVector(g,N*.25)}return o.updateLabel(s,d,h,i),[]}static getSchema(t,n){const r={text:{type:"string",label:"Text",default_value:n.text||""}},s={text:r.text.default_value};return{schema:r,params:s}}static applyParams(t,n,r){return super.applyParams(t,n,r),n.text=$n(n.text),{paramsPatch:{}}}static onLabelPointerDown(t,n,r,s,o){try{if(!t.viewer?.camera)return;const c=o.alignNormal?o.alignNormal(r.alignment||"view",r):new f(0,0,1),l=r.labelWorld?new f(r.labelWorld.x,r.labelWorld.y,r.labelWorld.z):new f(r.position?.x||0,r.position?.y||0,r.position?.z||0),u=new I().setFromNormalAndCoplanarPoint(c,l);k.dragLabelOnPlane(t,o,{makePlane:m(()=>u,"makePlane"),onDrag:m(p=>{r.labelWorld={x:p.x,y:p.y,z:p.z};try{o.updateLabel(n,null,p,r)}catch{}},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m(k,"NoteAnnotation"),P(k,"entityType","note"),P(k,"type","note"),P(k,"shortName","NOTE"),P(k,"longName","Note"),P(k,"title","Note"),P(k,"inputParamsSchema",In);let Ge=k;function $n(e){return typeof e=="string"?e:e==null?"":String(e)}m($n,"sanitizeText");const Un={id:{type:"string",default_value:null,hint:"unique identifier for the view transform"},targets:{type:"reference_selection",multiple:!0,default_value:[],label:"Target Objects",selectionFilter:["SOLID","COMPONENT"],hint:"Choose the solids or components to reposition in this view"},transform:{type:"transform",label:"Transform",hint:"Translation and rotation applied relative to the reference point"},showTraceLine:{type:"boolean",default_value:!0,label:"Show trace lines",hint:"Draw a line from the original position to the transformed position"}},W=class W extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["SOLID","COMPONENT"]);return n.length?{params:{targets:n}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:r}=t;if(!n||!r)return[];const s=this.inputParams||{};xt(s),s.transform=Le(s.transform);const o=W._resolveSolidReferences(s,n,!0);if(!o.length)return[];const i=W._ensureOriginalSnapshots(s,o,!1,n?.viewer),a=s.showTraceLine!==!1;let c=n?.__explodeTraceState;c instanceof Map||(c=new Map,n&&(n.__explodeTraceState=c));const l=O(s.transform.position,new f(0,0,0)),u=Dt(s.transform.rotationEuler),p=O(s.transform.scale,new f(1,1,1));return o.forEach(d=>{try{const h=i.get(d.uuid),g=O(h?.centerLocal)||_t(d),b=c?.get(d.uuid)?.clone()||Qn(h),y=zt(b,g)||O(h?.centerWorld)||O(h?.worldPosition),N=Yn(b,l,u,p),A=zt(N,g)||Gn(d);Tt(y)&&Tt(A)&&y.distanceToSquared(A)>=1e-8&&a&&r.add(Kt(y,A,16098596,{viewer:n?.viewer})),c?.set(d.uuid,N)}catch{}}),[]}static _resolveSolidReferences(t,n,r=!1){if(!t||!n)return[];const s=n.viewer,o=s?.partHistory?.scene||s?.scene;if(!o)return[];if(!r&&Array.isArray(t.__resolvedSolids)&&t.__resolvedSolids.length){const c=t.__resolvedSolids.filter(l=>l&&l.isObject3D);return ae(t,"__resolvedSolids",c),ae(t,"solids",c),c}const i=Array.isArray(t.targets)?t.targets:[],a=[];return i.forEach(c=>{const l=Hn(c,o);l&&l.isObject3D&&a.push(l)}),ae(t,"__resolvedSolids",a),ae(t,"solids",a),a}static _ensureOriginalSnapshots(t,n,r=!1,s=null){xt(t);let o=t.__originalSnapshots;return o instanceof Map||(o=At(t.persistentData?.originalTransforms)),o instanceof Map||(o=new Map),(Array.isArray(n)?n:[]).forEach(a=>{!a||!a.uuid||(r||!o.has(a.uuid))&&o.set(a.uuid,Nt(a,s))}),ae(t,"__originalSnapshots",o),t.persistentData.originalTransforms=kn(o),o}static getOriginalSnapshotMap(t){if(!t)return new Map;if(t.__originalSnapshots instanceof Map)return t.__originalSnapshots;const n=At(t?.persistentData?.originalTransforms);return ae(t,"__originalSnapshots",n instanceof Map?n:new Map),t.__originalSnapshots}static applyTransformsToSolids(t,n,r={}){if(!t||!n)return;const s=W._resolveSolidReferences(t,n,!0);if(!s.length)return;const o=r&&r.startSnapshots instanceof Map?r.startSnapshots:W.getOriginalSnapshotMap(t),i=r?.cumulativeState instanceof Map?r.cumulativeState:null,a=Le(t.transform);t.transform=a;const c=O(a.position,new f(0,0,0)),l=Dt(a.rotationEuler),u=O(a.scale,new f(1,1,1));s.forEach(p=>{if(!p||!p.uuid)return;const d=o.get(p.uuid)||W.getOriginalSnapshotMap(t).get(p.uuid)||Nt(p,n?.viewer);if(!d)return;const h=O(d.position,new f(0,0,0)),g=Ye(d.quaternion,new V),b=O(d.scale,new f(1,1,1)),y=h.clone().add(c),N=g.clone().multiply(l),A=b.clone().multiply(u);if(p.position.copy(y),p.quaternion.copy(N),p.scale.copy(A),p.updateMatrixWorld(!0),i){const x=p.getWorldPosition(new f);i.set(p.uuid,{position:y.toArray(),quaternion:N.toArray(),scale:A.toArray(),worldPosition:x.toArray()})}})}static restoreOriginalTransforms(t,n){if(!t||!n)return;const r=W._resolveSolidReferences(t,n,!0);if(!r.length)return;const s=W.getOriginalSnapshotMap(t);r.forEach(o=>{if(!o||!o.uuid)return;const i=s.get(o.uuid);if(!i)return;const a=O(i.position,new f(0,0,0)),c=Ye(i.quaternion,new V),l=O(i.scale,new f(1,1,1));o.position.copy(a),o.quaternion.copy(c),o.scale.copy(l),o.updateMatrixWorld(!0)})}static applyParams(t,n,r){super.applyParams(t,n,r),n.targets=Xn(n.targets),n.transform=Le(n.transform),n.showTraceLine=n.showTraceLine!==!1;try{t&&typeof t.applyViewTransformsSequential=="function"&&t.applyViewTransformsSequential()}catch{}return{paramsPatch:{}}}};m(W,"ExplodeBodyAnnotation"),P(W,"entityType","exp"),P(W,"type","exp"),P(W,"shortName","EXP"),P(W,"longName","Explode Body"),P(W,"title","Explode Body"),P(W,"inputParamsSchema",Un),P(W,"aliases",["viewTransform"]);let Qe=W;function xt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(xt,"ensurePersistent");function ae(e,t,n){if(!(!e||typeof e!="object"))try{Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!1,writable:!0})}catch{e[t]=n}}m(ae,"setHiddenProperty");function Le(e){const t=e&&typeof e=="object"?e:{},n=m((r,s)=>{if(!Array.isArray(r))return s.slice();const o=s.slice();for(let i=0;i<o.length;i+=1){const a=Number(r[i]);o[i]=Number.isFinite(a)?a:o[i]}return o},"sanitizeArray");return{position:n(t.position,[0,0,0]),rotationEuler:n(t.rotationEuler,[0,0,0]),scale:n(t.scale,[1,1,1])}}m(Le,"sanitizeTransform");function Xn(e){return Array.isArray(e)?e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length):[]}m(Xn,"arrayOfStrings");function Hn(e,t){if(!t||!e&&e!==0)return null;let n=null;if(typeof e=="string"&&e.trim().length){const s=e.trim();if(s[0]==="{")try{n=JSON.parse(s)}catch{n={name:s}}else n={name:s}}else typeof e=="object"&&(n={...e});if(!n)return null;const r=[];n.name&&typeof n.name=="string"&&r.push(n.name.trim()),Array.isArray(n.path)&&n.path.length&&r.push(String(n.path[n.path.length-1]));for(const s of r){if(!s)continue;const o=t.getObjectByName(s);if(o&&o.type==="SOLID"||o)return o}if(typeof n.uuid=="string"){const s=t.getObjectByProperty("uuid",n.uuid);if(s)return s;const o=Pt(t,i=>i?.userData?.__pmiExportSourceUuid===n.uuid);if(o)return o}if(Number.isInteger(n.id)){try{const o=t.getObjectById(n.id);if(o)return o}catch{}const s=Pt(t,o=>o?.userData?.__pmiExportSourceId===n.id);if(s)return s}return null}m(Hn,"resolveSolidObject");function Pt(e,t){if(!e?.traverse||typeof t!="function")return null;let n=null;return e.traverse(r=>{if(!(n||!r?.isObject3D))try{t(r)&&(n=r)}catch{}}),n}m(Pt,"findExportCloneMatch");function Nt(e,t=null){try{e.updateMatrixWorld(!0)}catch{}const n=e.position.clone(),r=e.quaternion.clone(),s=e.scale.clone(),o=e.getWorldPosition(new f),i=_t(e),a=i.clone().applyMatrix4(new me().compose(n.clone(),r.clone(),s.clone()));return{position:n.toArray(),quaternion:r.toArray(),scale:s.toArray(),worldPosition:o.toArray(),centerWorld:a.toArray(),centerLocal:i.toArray()}}m(Nt,"captureSnapshot");function At(e){if(!Array.isArray(e))return new Map;const t=new Map;return e.forEach(n=>{!n||typeof n!="object"||!n.uuid||t.set(n.uuid,{position:j(n.position,[0,0,0]),quaternion:j(n.quaternion,[0,0,0,1]),scale:j(n.scale,[1,1,1]),worldPosition:j(n.worldPosition,null),centerWorld:j(n.centerWorld,null),centerLocal:j(n.centerLocal,null)})}),t}m(At,"snapshotArrayToMap");function kn(e){if(!(e instanceof Map))return[];const t=[];return e.forEach((n,r)=>{r&&t.push({uuid:r,position:j(n.position,[0,0,0]),quaternion:j(n.quaternion,[0,0,0,1]),scale:j(n.scale,[1,1,1]),worldPosition:j(n.worldPosition,null),centerWorld:j(n.centerWorld,null),centerLocal:j(n.centerLocal,null)})}),t}m(kn,"snapshotMapToArray");function j(e,t){if(Array.isArray(e))return e.slice();if(e&&typeof e=="object"&&typeof e.length=="number"){const n=[];for(let r=0;r<e.length;r+=1)n.push(Number(e[r]));return n}return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"?typeof e.w=="number"?[e.x,e.y,e.z,e.w]:[e.x,e.y,e.z]:t&&t.slice()}m(j,"toArray");function O(e,t){if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3){const n=Number(e[0]),r=Number(e[1]),s=Number(e[2]);if([n,r,s].every(o=>Number.isFinite(o)))return new f(n,r,s)}return e&&typeof e=="object"&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)?new f(e.x,e.y,e.z):t&&t.isVector3?t.clone():new f}m(O,"vectorFromArray");function Ye(e,t){if(Array.isArray(e)&&e.length>=4){const n=Number(e[0]),r=Number(e[1]),s=Number(e[2]),o=Number(e[3]);if([n,r,s,o].every(i=>Number.isFinite(i)))return new V(n,r,s,o)}return e&&typeof e=="object"&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)&&Number.isFinite(e.w)?new V(e.x,e.y,e.z,e.w):t&&t.isQuaternion?t.clone():new V}m(Ye,"quaternionFromArray");function Dt(e){const t=Array.isArray(e)?e:[0,0,0],n=Number(t[0])||0,r=Number(t[1])||0,s=Number(t[2])||0;try{return new V().setFromEuler(new Zt(Pe.degToRad(n),Pe.degToRad(r),Pe.degToRad(s),"XYZ"))}catch{return new V}}m(Dt,"quaternionFromEuler");function _t(e){try{if(!e)return new f;e.updateMatrixWorld?.(!0);const t=new vt().setFromObject(e);if(!t.isEmpty()){const r=t.getCenter(new f).clone();return e.worldToLocal(r),r}}catch{}return new f}m(_t,"getSolidLocalCenter");function Gn(e){try{if(!e)return new f;e.updateMatrixWorld?.(!0);const t=new vt().setFromObject(e);if(!t.isEmpty())return t.getCenter(new f)}catch{}try{return e.getWorldPosition(new f)}catch{return new f}}m(Gn,"getSolidWorldCenter");function Tt(e){return!e||!e.isVector3?!1:Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}m(Tt,"isFiniteVec3");function Qn(e){if(!e||typeof e!="object")return de(new f,new V,new f(1,1,1));const t=O(e.position,new f),n=Ye(e.quaternion,new V),r=O(e.scale,new f(1,1,1));return de(t,n,r)}m(Qn,"transformEntryFromSnapshot");function Yn(e,t,n,r){const s=e||de(new f,new V,new f(1,1,1)),o=s.position.clone().add(t||new f),i=s.quaternion.clone().multiply(n||new V),a=s.scale.clone().multiply(r||new f(1,1,1));return de(o,i,a)}m(Yn,"composeTransformEntry");function zt(e,t){if(!e||!t||!t.isVector3)return null;const n=new me().compose(e.position.clone(),e.quaternion.clone(),e.scale.clone());return t.clone().applyMatrix4(n)}m(zt,"applyTransformEntryToPoint");function de(e,t,n){return{position:e.clone(),quaternion:t.clone(),scale:n.clone(),clone(){return de(this.position,this.quaternion,this.scale)}}}m(de,"makeTransformEntry");const Zn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the hole callout"},target:{type:"reference_selection",selectionFilter:["VERTEX","EDGE","FACE"],multiple:!1,default_value:"",label:"Target",hint:"Pick the hole edge/vertex/face to call out"},quantity:{type:"number",default_value:0,label:"Quantity",hint:"Number of identical holes this callout represents (0 = auto from feature)",min:0},showQuantity:{type:"boolean",default_value:!0,label:"Show Quantity",hint:"Include the hole count in the callout label"},beforeText:{type:"string",default_value:"",label:"Text Before",hint:"Optional text to show before the callout"},afterText:{type:"string",default_value:"",label:"Text After",hint:"Optional text to show after the callout"},anchorPosition:{type:"options",default_value:"Right Top",options:["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"],label:"Anchor Position",hint:"Preferred label alignment relative to anchor"}},G=class G extends v{static showContexButton(t){const n=v._normalizeSelectionItems(t),r=new Set(["VERTEX","EDGE","FACE"]);for(const s of n){if(!v._isSelectionType(s,r)||!er(s))continue;const o=v._selectionRefName(s);if(o)return{params:{target:o}}}return!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams||{},a=n?.viewer,c=a?.partHistory?.scene,l=Mt(a,i.target),u=E(c,l),p=Kn(a?.partHistory,l,u,i.target),d=p?.center?Ne(p.center):u;if(!d)return[];const h=ar(i,p,a?.partHistory),g=p?tr(p,h,{showQuantity:i.showQuantity!==!1,beforeText:i.beforeText,afterText:i.afterText}):"";i.value=g;const b=Et(a),y=o?.screenSizeWorld?o.screenSizeWorld(80):q(a,80),N=o?.screenSizeWorld?o.screenSizeWorld(30):q(a,30),x=Ne(i?.persistentData?.labelWorld)||d.clone().addScaledVector(b.right,nr(i.anchorPosition||"Right Top")*y).addScaledVector(b.up,rr(i.anchorPosition||"Right Top")*N);o?.updateLabel&&o.updateLabel(s,g,x,i);const D=Je(),w=D.lineColor??16771584;r.add(Y(x,d,w));const S=D.arrowLengthPx??12,z=D.arrowWidthPx??4,M=o?.screenSizeWorld?o.screenSizeWorld(S):q(a,S),T=o?.screenSizeWorld?o.screenSizeWorld(z):q(a,z),F=d.clone().sub(x);return F.lengthSq()>1e-12&&(F.normalize(),ne(r,d,F,M,T,D.arrowColor??w)),[]}static applyParams(t,n,r){super.applyParams(t,n,r);const s=Number(n?.quantity);return n.quantity=Number.isFinite(s)?Math.max(0,Math.round(s)):1,n.showQuantity=n.showQuantity!==!1,n.beforeText=ze(n.beforeText),n.afterText=ze(n.afterText),n.anchorPosition=or(n.anchorPosition),{paramsPatch:{}}}static onLabelPointerDown(t,n,r,s,o){const i=t?.viewer,a=Mt(i,r.target),c=i?.partHistory?.scene,l=E(c,a)||Ne(r?.persistentData?.labelWorld);if(!l)return;const p=Et(i).forward;if(!o?.raycastFromEvent)return;const d=new I().setFromNormalAndCoplanarPoint(p,l);G.dragLabelOnPlane(t,o,{makePlane:m(()=>d,"makePlane"),suspendControls:!0,onDrag:m(h=>{ir(r),r.persistentData.labelWorld=[h.x,h.y,h.z],o.updateLabel(n,null,h,r),t?.refreshAnnotationsUI?.()},"onDrag")})}};m(G,"HoleCalloutAnnotation"),P(G,"entityType","holeCallout"),P(G,"type","holeCallout"),P(G,"shortName","HOLE"),P(G,"longName","Hole Callout"),P(G,"title","Hole Callout"),P(G,"inputParamsSchema",Zn);let Ze=G;function Mt(e,t){if(!e||!t)return null;const n=e.partHistory?.scene;if(!n)return null;if(typeof t=="string"){const r=n.getObjectByName?.(t);if(r)return r;const s=Ae(t);for(const i of s){const a=n.getObjectByName?.(i);if(a)return a}let o=null;try{n.traverse(i=>{if(o)return;const a=i?.name?String(i.name):"";if(a){for(const c of s)if(c&&(a===c||a.endsWith(c)||a.includes(c))){o=i;return}}})}catch{}if(o)return o}return typeof t=="object"?t:n.getObjectByName?.(String(t))||null}m(Mt,"resolveTargetObject");function Kn(e,t,n,r=null){const s=Array.isArray(e?.features)?e.features:[],o=[];for(const u of s){const p=Array.isArray(u?.persistentData?.holes)?u.persistentData.holes:[];for(const d of p)o.push(d)}if(!o.length)return null;const i=t?.userData?.hole||t?.userData?.metadata?.hole;if(i)return i;if(t?.parent){const u=t.parent.userData?.hole||t.parent.userData?.metadata?.hole;if(u)return u}const a=t?.uuid||t?.id||t?.name||null,c=Ae(r,a);if(t?.name)for(const u of Ae(t.name))c.add(u);const l=o.filter(u=>{const p=u?.sourceName?String(u.sourceName):null,d=u?.featureId?String(u.featureId):null,h=u?.targetId?String(u.targetId):null;return p&&c.has(p)||d&&c.has(d)||h&&c.has(h)});if(l.length===1)return l[0];if(l.length>1&&n){const u=ee(l,n);if(u)return u}if(a){const u=o.filter(p=>p?.targetId&&String(p.targetId)===String(a));if(u.length===1)return u[0];if(u.length>1&&n){const p=ee(u,n);if(p)return p}}if(r){const u=String(r),p=o.filter(d=>{const h=d?.featureId?String(d.featureId):"",g=d?.sourceName?String(d.sourceName):"";return h&&u.includes(h)||g&&u.includes(g)});if(p.length===1)return p[0];if(p.length>1&&n){const d=ee(p,n);if(d)return d}}if(c.size){const u=o.filter(p=>{const d=p?.featureId?String(p.featureId):"",h=p?.sourceName?String(p.sourceName):"",g=p?.targetId?String(p.targetId):"";return c.has(d)||c.has(h)||c.has(g)});if(u.length===1)return u[0];if(u.length>1&&n){const p=ee(u,n);if(p)return p}}if(n){const u=ee(o,n);if(u)return u}if(t?.parent){const u=Ae(t.parent.name),p=o.filter(d=>{const h=d?.featureId?String(d.featureId):"",g=d?.sourceName?String(d.sourceName):"",b=d?.targetId?String(d.targetId):"";return u.has(h)||u.has(g)||u.has(b)});if(p.length===1)return p[0];if(p.length>1&&n){const d=ee(p,n);if(d)return d}}if(n){const u=ee(o,n);if(u)return u}return o[0]}m(Kn,"findHoleDescriptor");function Jn(e){if(!e)return null;const t=e.userData||null;if(t?.hole)return t.hole;if(t?.metadata?.hole)return t.metadata.hole;if(typeof e.getMetadata=="function")try{const s=e.getMetadata();if(s?.hole)return s.hole;if(s?.metadata?.hole)return s.metadata.hole}catch{}const n=e?.name||t?.faceName||null,r=e?.parentSolid||t?.parentSolid||null;if(n&&r&&typeof r.getFaceMetadata=="function")try{const s=r.getFaceMetadata(n);if(s?.hole)return s.hole}catch{}return null}m(Jn,"readHoleMetadata");function er(e){if(!e)return!1;const t=[e],n=new Set,r=m(s=>Object.prototype.hasOwnProperty.call(s,"faces"),"hasOwnFaces");for(;t.length;){const s=t.shift();if(!(!s||n.has(s))){if(n.add(s),Jn(s))return!0;if(r(s)&&Array.isArray(s.faces))for(const o of s.faces)t.push(o);else if(s.type==="SOLID"||s.type==="COMPONENT"){const o=Array.isArray(s.children)?s.children:[];for(const i of o)i&&i.type==="FACE"&&t.push(i)}s.parent&&t.push(s.parent)}}return!1}m(er,"hasHoleMetadata");function tr(e,t=1,n={}){if(!e)return"";const r=[],s=ze(n.beforeText);s&&r.push(s);const i=n.showQuantity!==!1&&t>1?`${t}× `:"",a=Number(e.totalDepth??e.straightDepth),c=!e.throughAll&&a>0?` ↧ ${le(a)}`:e.throughAll?" THRU ALL":"";r.push(`${i}⌀${le(e.diameter)}${c}`),e.type==="COUNTERSINK"?r.push(`⌵ ⌀${le(e.countersinkDiameter)} × ${le(e.countersinkAngle,0)}°`):e.type==="COUNTERBORE"&&r.push(`⌴ ⌀${le(e.counterboreDiameter)} ↧ ${le(e.counterboreDepth)}`);const l=sr(e?.thread);l&&r.push(l);const u=ze(n.afterText);return u&&r.push(u),r.join(`
|
|
1
|
+
var lt=Object.defineProperty;var kt=(e,t,n)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var m=(e,t)=>lt(e,"name",{value:t,configurable:!0});var P=(e,t,n)=>kt(e,typeof t!="symbol"?t+"":t,n);import{d as we}from"./deepClone-Dj59xCHB.js";import{V as f,a as _,P as I,M as me,b as Pe,Q as V,I as Gt,J as Qt,f as Yt,K as Zt,B as vt}from"./featureDialogs-DEpvCr2m.js";import{s as q,i as Y,a as ne,o as E,m as Ve,g as ue,d as Je,j as Kt}from"./annUtils-DcxkV20w.js";function B(e,t,n,r=.01){const s=[];typeof t=="function"&&s.push(t),typeof n=="function"&&s.push(n);for(const o of s)try{const i=Number(o(e));if(Number.isFinite(i)&&i>0)return i}catch{}return r}m(B,"resolveScreenSizeWorld");function Jt(e){if(!e||e.lengthSq()===0)return new f(0,0,1);const t=Math.abs(e.dot(new f(0,0,1)))<.9?new f(0,0,1):new f(0,1,0),n=new f().crossVectors(e,t);return n.lengthSq()===0&&n.crossVectors(e,new f(1,0,0)),n.lengthSq()===0?new f(1,0,0):n.normalize()}m(Jt,"arbitraryPerpendicular3D");function ce(e){if(!e)return null;if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3)return new f(Number(e[0])||0,Number(e[1])||0,Number(e[2])||0);if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),r=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))return new f(t,n,r)}return null}m(ce,"vectorFromAny$2");function en(e){return e>1?1:e<-1?-1:e}m(en,"clampToUnit");function tn(e,t){const n=e.x*t.y-e.y*t.x,r=e.x*t.x+e.y*t.y;return Math.atan2(n,r)}m(tn,"signedAngle2D");function nn(e,t){const n=Math.cos(t),r=Math.sin(t);return new _(e.x*n-e.y*r,e.x*r+e.y*n)}m(nn,"rotate2D");function et(e,t){const n=e.clone().normalize();let r=(t?t.clone():new f(1,0,0)).projectOnPlane(n);r.lengthSq()<1e-12&&(r=Math.abs(n.z)<.9?new f(0,0,1).cross(n):new f(0,1,0).cross(n)),r.normalize();const s=new f().crossVectors(n,r).normalize();return{U:r,V:s,N:n}}m(et,"planeBasis");function Oe(e,t,n){const r=e.clone().sub(t);return new _(r.dot(n.U),r.dot(n.V))}m(Oe,"to2D");function De(e,t){return new _(e.dot(t.U),e.dot(t.V))}m(De,"dirTo2D");function J(e,t,n){return t.clone().add(n.U.clone().multiplyScalar(e.x)).add(n.V.clone().multiplyScalar(e.y))}m(J,"from2D");function rn(e,t,n,r){const s=t.x*r.y-t.y*r.x;if(Math.abs(s)<1e-12)return null;const o=new _().subVectors(n,e),i=(o.x*r.y-o.y*r.x)/s;return new _(e.x+t.x*i,e.y+t.y*i)}m(rn,"intersectLines2D");function on(e,t,n){const r=e.clone().sub(t).dot(n);return e.clone().sub(n.clone().multiplyScalar(r))}m(on,"projectPointToPlane");function be(e,t,n,r){const s=n?e.clone().multiplyScalar(-1):e.clone(),o=r?t.clone().multiplyScalar(-1):t.clone(),i=en(s.dot(o)),a=Math.acos(i),c=tn(s,o);return{A:s,B:o,angle:a,signedAngle:c}}m(be,"createAngleCombo");function Ft(e,t,n,r=!0){if(!e||!t)return null;const s=[be(e,t,!1,!1),be(e,t,!1,!0),be(e,t,!0,!1),be(e,t,!0,!0)],o=Math.PI/2,i=1e-6,a=m((c,l)=>c.length?c.slice().sort(l)[0]:null,"selectByAngle");if(n==="reflex"){const c=s[0],l=Math.abs(c.signedAngle),u=l<1e-6?0:2*Math.PI-l,p=-Math.sign(c.signedAngle||1),d=c.A.clone().add(c.B);return d.lengthSq()<1e-10&&d.set(-c.A.y,c.A.x),d.normalize().multiplyScalar(-1),{start:c.A.clone(),end:c.B.clone(),sweep:u,dirSign:p,angleRad:u,bisector:d,angleType:"reflex",signedAngle:c.signedAngle}}if(n==="acute"){if(!r){const d=s[0],h=d.A.clone().add(d.B);h.lengthSq()<1e-10&&h.set(-d.A.y,d.A.x),h.normalize();const g=Math.abs(d.signedAngle)<1e-8?1:Math.sign(d.signedAngle),b=Math.abs(d.signedAngle);return{start:d.A.clone(),end:d.B.clone(),sweep:b,dirSign:g,angleRad:b,bisector:h,angleType:"acute",signedAngle:d.signedAngle}}const c=s.filter(d=>d.angle<=o+i),l=a(c.length?c:s,(d,h)=>d.angle-h.angle);if(!l)return null;const u=l.A.clone().add(l.B);u.lengthSq()<1e-10&&u.set(-l.A.y,l.A.x),u.normalize();const p=Math.abs(l.signedAngle)<1e-8?1:Math.sign(l.signedAngle);return{start:l.A.clone(),end:l.B.clone(),sweep:l.angle,dirSign:p,angleRad:l.angle,bisector:u,angleType:"acute",signedAngle:l.signedAngle}}if(n==="obtuse"){const c=s.filter(d=>d.angle>=o-i);let l=a(c,(d,h)=>d.angle-h.angle);if(l||(l=a(s,(d,h)=>h.angle-d.angle)),!l)return null;const u=l.A.clone().add(l.B);u.lengthSq()<1e-10&&u.set(-l.A.y,l.A.x),u.normalize();const p=Math.abs(l.signedAngle)<1e-8?1:Math.sign(l.signedAngle);return{start:l.A.clone(),end:l.B.clone(),sweep:l.angle,dirSign:p,angleRad:l.angle,bisector:u,angleType:"obtuse",signedAngle:l.signedAngle}}return null}m(Ft,"resolveAngleOrientation2D");function sn({planePoint:e=null,planeNormal:t=null,basis:n=null,vertex2D:r=null,directionA2D:s=null,directionB2D:o=null,sweepRad:i=0,sweepDirection:a=1,bisector2D:c=null,labelWorld:l=null,screenSizeWorld:u=null,fallbackScreenSizeWorld:p=null,defaultRadiusPixels:d=60,minRadiusPixels:h=30,arcDensity:g=64,minArcSteps:b=48,extensionPixels:y=25,stubPixels:N=12,labelOffsetPixels:A=70,arrowLengthPixels:x=10,arrowWidthPixels:D=4}={}){if(!e||!t||!n||!r||!s||!o)return null;const w=r.clone(),S=s.clone(),z=o.clone();if(S.lengthSq()<=1e-12||z.lengthSq()<=1e-12)return null;S.normalize(),z.normalize();const M=t.clone().normalize();let T=null;const F=ce(l);if(F){const ie=on(F,e,M);T=Oe(ie,e,n).clone().sub(w).length()}(!Number.isFinite(T)||T<=0)&&(T=B(d,u,p,.02));const L=B(h,u,p,.01);T=Math.max(T,L);const R=[],Z=Math.max(0,Number(i)||0),ot=Number(a)||1;if(Z>1e-6){const ie=Math.max(b,Math.floor(Z*g));for(let K=0;K<=ie;K+=1){const Me=K/ie,Ee=ot*Z*Me,at=nn(S,Ee),Ht=new _(w.x+at.x*T,w.y+at.y*T);R.push(J(Ht,e,n))}}const he=B(x,u,p,.08),ye=B(D,u,p,.03),oe=[];if(R.length>=2){const ie=R[0].clone().sub(R[1]).normalize();oe.push({tip:R[0].clone(),direction:ie,length:he,width:ye});const K=R[R.length-1].clone(),Me=R[R.length-2].clone(),Ee=K.clone().sub(Me).normalize();oe.push({tip:K,direction:Ee,length:he,width:ye})}const se=T+B(y,u,p,.02),ge=B(N,u,p,.01),fe=J(w,e,n),Ct=J(new _(w.x+S.x*se,w.y+S.y*se),e,n),Bt=J(new _(w.x+z.x*se,w.y+z.y*se),e,n),jt=J(new _(w.x-S.x*ge,w.y-S.y*ge),e,n),It=J(new _(w.x-z.x*ge,w.y-z.y*ge),e,n),$t=[[fe.clone(),Ct],[fe.clone(),Bt],[fe.clone(),jt],[fe.clone(),It]];let pe=c?c.clone():new _().addVectors(S,z);pe.lengthSq()<1e-10&&pe.set(-S.y,S.x),pe.normalize();const st=B(A,u,p,.03),it=T>0?T+st*.3:st,Ut=new _(w.x+pe.x*it,w.y+pe.y*it),Xt=J(Ut,e,n);return{radius:T,arcPoints:R,arrowSpecs:oe,segments:$t,labelPosition:Xt,originWorld:fe}}m(sn,"buildAngleDimensionGeometry");function an({pointA:e=null,pointB:t=null,normal:n=null,offset:r=0,showExtensions:s=!0,labelWorld:o=null,screenSizeWorld:i=null,fallbackScreenSizeWorld:a=null,arrowLengthPixels:c=12,arrowWidthPixels:l=4,labelLiftPixels:u=6,labelLeaderThresholdPixels:p=6}={}){const d=ce(e),h=ce(t);if(!d||!h)return null;const g=h.clone().sub(d);if(g.lengthSq()<1e-8)return null;g.normalize();let b=ce(n);(!b||b.lengthSq()<1e-12)&&(b=new f(0,0,1)),b.normalize();let y=new f().crossVectors(b,g);if(y.lengthSq()<1e-12&&(y=Jt(g)),y.lengthSq()<1e-12)return null;y.normalize();let N=Number(r);Number.isFinite(N)||(N=B(20,i,a,.05));const A=d.clone().addScaledVector(y,N),x=h.clone().addScaledVector(y,N),D=[];s!==!1&&N!==0&&(D.push([d.clone(),A.clone()]),D.push([h.clone(),x.clone()])),D.push([A.clone(),x.clone()]);const w=B(c,i,a,.08),S=B(l,i,a,.03),z=[{tip:A.clone(),direction:g.clone().negate(),length:w,width:S},{tip:x.clone(),direction:g.clone(),length:w,width:S}],M=ce(o),T=new f().addVectors(A,x).multiplyScalar(.5),F=B(u,i,a,.02),L=M||T.addScaledVector(y,F);let R=null;if(M){const Z=A.distanceTo(x);if(Z>1e-6){const he=M.clone().sub(A).dot(g),ye=Math.max(0,Math.min(Z,he)),oe=A.clone().addScaledVector(g,ye),se=B(p,i,a,.02);M.distanceTo(oe)>se&&(R=[oe,M.clone()])}}return{direction:g,tangent:y,offset:N,offsetA:A,offsetB:x,segments:D,arrowSpecs:z,labelPosition:L,leaderSegment:R}}m(an,"buildLinearDimensionGeometry");const te=class te{constructor({id:t=null,history:n=null,registry:r=null}={}){this.entityType=this.constructor.entityType||this.constructor.type||"ENTITY",this.type=this.entityType,this.title=this.constructor.shortName,this.shortName=this.constructor.shortName||this.constructor.featureShortName||null,this.history=n||null,this.registry=r||null,this.id=null,this.inputParams={id:t},this.persistentData={},this.runtimeAttributes={},t!=null?this.setId(t):this.inputParams.type=this.entityType}setId(t){this.id=t??null,(!this.inputParams||typeof this.inputParams!="object")&&(this.inputParams={}),this.id!=null&&this.inputParams.id==null&&(this.inputParams.id=this.id),this.onIdChanged()}setParams(t={}){this.inputParams=we(t||{}),this.id!=null&&this.inputParams.id==null&&(this.inputParams.id=this.id),this.inputParams.type||(this.inputParams.type=this.entityType),this.onParamsChanged()}mergeParams(t={}){const n=we(t||{});this.inputParams={...this.inputParams,...n},this.id!=null&&this.inputParams.id==null&&(this.inputParams.id=this.id),this.inputParams.type||(this.inputParams.type=this.entityType),this.onParamsChanged()}setPersistentData(t={}){this.persistentData=we(t||{}),this.onPersistentDataChanged()}mergePersistentData(t={}){const n=we(t||{});this.persistentData={...this.persistentData,...n},this.onPersistentDataChanged()}run(t={}){throw new Error(`${this.constructor.name} must implement run(context)`)}};m(te,"ListEntityBase"),P(te,"entityType","ENTITY"),P(te,"shortName","ENT"),P(te,"longName","EntityBase"),P(te,"inputParamsSchema",{});let _e=te;const C=class C extends _e{constructor(t={}){super({history:t.history||null,registry:t.registry||null}),this.resultArtifacts=[]}static _normalizeSelectionItems(t){return Array.isArray(t)?t:[]}static _normalizeSelectionType(t){return String(t||"").toUpperCase()}static _isSelectionType(t,n){return!n||!n.size?!0:n.has(C._normalizeSelectionType(t?.type))}static _selectionRefName(t){return t?.name||t?.userData?.faceName||t?.userData?.edgeName||t?.userData?.vertexName||t?.userData?.solidName||t?.userData?.name||null}static _collectSelectionRefs(t,n=null){const r=C._normalizeSelectionItems(t),s=Array.isArray(n)?new Set(n.map(i=>C._normalizeSelectionType(i))):null,o=[];for(const i of r){if(!C._isSelectionType(i,s))continue;const a=C._selectionRefName(i);a&&o.push(a)}return o}async run(t){return console.warn(`BaseAnnotation.run() not implemented for ${this.constructor.name}`),[]}getScene(){return this.renderingContext?.pmimode?.viewer?.partHistory?.scene||null}getObjectByName(t){const n=this.getScene();return n?n.getObjectByName(t):null}static getSchema(t,n){const r={},s={},o=n||{};for(const i in this.inputParamsSchema){if(!Object.prototype.hasOwnProperty.call(this.inputParamsSchema,i))continue;const a=this.inputParamsSchema[i]||{},c={...a},l=Object.prototype.hasOwnProperty.call(o,i)?U(o[i]):U(a.default_value);c&&Object.prototype.hasOwnProperty.call(c,"default_value")&&(c.default_value=U(l)),r[i]=c,s[i]=l}return{schema:r,params:s}}static applyParams(t,n,r){const s=ln(this.inputParamsSchema,r,n);return Object.assign(n,s),{paramsPatch:{}}}static ensurePersistentData(t){return!t||typeof t!="object"?null:((!t.persistentData||typeof t.persistentData!="object")&&(t.persistentData={}),t.persistentData)}static dragLabelOnPlane(t,n,r={}){if(!n||typeof r.makePlane!="function")return;const s=r.makePlane();if(!s||!(s instanceof I)&&!s.isPlane)return;const o=r.eventTarget||window,i=t?.viewer,a=m(l=>{const u=n.raycastFromEvent?n.raycastFromEvent(l):null;if(!u)return;const p=new f;(n.intersectPlane?n.intersectPlane(u,s,p):u.intersectPlane(s,p))&&typeof r.onDrag=="function"&&r.onDrag(p,l,s)},"onMove"),c=m(l=>{try{o.removeEventListener("pointermove",a,!0)}catch{}try{o.removeEventListener("pointerup",c,!0)}catch{}if(r.suspendControls===!0)try{i?.controls&&(i.controls.enabled=!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}if(typeof r.onEnd=="function")try{r.onEnd(l)}catch{}if(r.preventDefault!==!1)try{l.preventDefault(),l.stopImmediatePropagation?.(),l.stopPropagation()}catch{}},"onUp");try{t?.showDragPlaneHelper?.(s)}catch{}if(r.suspendControls===!0)try{i?.controls&&(i.controls.enabled=!1)}catch{}try{o.addEventListener("pointermove",a,!0)}catch{}try{o.addEventListener("pointerup",c,!0)}catch{}}onIdChanged(){(!this.inputParams||typeof this.inputParams!="object")&&(this.inputParams={}),this.inputParams.id=this.id}onParamsChanged(){(!this.inputParams||typeof this.inputParams!="object")&&(this.inputParams={}),this.inputParams.id||(this.inputParams.id=this.id),this.inputParams.type||(this.inputParams.type=this.type||this.entityType||"annotation")}onPersistentDataChanged(){(!this.persistentData||typeof this.persistentData!="object")&&(this.persistentData={})}};m(C,"BaseAnnotation"),P(C,"entityType","annotation"),P(C,"shortName","ANN"),P(C,"longName","Annotation"),P(C,"inputParamsSchema",{});let v=C;function ln(e,t,n){const r={},s=t&&typeof t=="object"?t:{};for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o]||{};if(i.readOnly){n&&Object.prototype.hasOwnProperty.call(n,o)?r[o]=n[o]:r[o]=U(i.default_value);continue}const a=s[o],c=n&&Object.prototype.hasOwnProperty.call(n,o);if(a===void 0){r[o]=U(c?n[o]:i.default_value);continue}switch(i.type){case"number":{const l=Number(a);r[o]=Number.isFinite(l)?l:c&&Number.isFinite(n[o])?Number(n[o]):Number.isFinite(i.default_value)?i.default_value:0;break}case"boolean":r[o]=a==="false"?!1:!!a;break;case"options":{const l=Array.isArray(i.options)?i.options:[],u=a==null?"":String(a);l.includes(u)?r[o]=u:c&&l.includes(n[o])?r[o]=n[o]:r[o]=l.includes(i.default_value)?i.default_value:l[0]||"";break}case"reference_selection":{if(i.multiple){const l=Array.isArray(a)?a:a?[a]:[];r[o]=l.map(u=>u==null?"":String(u)).filter(u=>u.length),!r[o].length&&c&&Array.isArray(n[o])&&(r[o]=n[o].slice())}else r[o]=a==null?c?String(n[o]??""):"":String(a);break}case"textarea":case"string":r[o]=a==null?c?String(n[o]??""):"":String(a);break;case"object":r[o]=U(a&&typeof a=="object"?a:i.default_value);break;case"transform":r[o]=cn(a,i.default_value);break;case"vec3":r[o]=un(a,i.default_value);break;default:r[o]=U(a);break}}return r}m(ln,"sanitizeAnnotationParams");function cn(e,t){const n=e&&typeof e=="object"?e:t||{},r=m((s,o,i=3)=>{const a=Array.isArray(s)?s:o&&Array.isArray(o)?o:[],c=[];for(let l=0;l<i;l+=1){const u=a[l],p=Number(u);c[l]=Number.isFinite(p)?p:0}return c},"toArray");return{position:r(n.position,t?.position||[0,0,0]),rotationEuler:r(n.rotationEuler,t?.rotationEuler||[0,0,0]),scale:r(n.scale,t?.scale||[1,1,1])}}m(cn,"normalizeTransform");function un(e,t){const n=Array.isArray(e)?e:e&&typeof e=="object"?[e.x,e.y,e.z]:t;if(!Array.isArray(n))return[0,0,0];const r=[];for(let s=0;s<3;s+=1){const o=Number(n[s]);r[s]=Number.isFinite(o)?o:0}return r}m(un,"normalizeVec3");function U(e){if(e==null)return e;if(Array.isArray(e))return e.map(t=>U(t));if(typeof e=="object"){const t={};for(const n of Object.keys(e))t[n]=U(e[n]);return t}return e}m(U,"__cloneValue");const fn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the linear dimension"},targets:{type:"reference_selection",selectionFilter:["VERTEX","EDGE"],multiple:!0,default_value:[],label:"Targets",hint:"Select two vertices, or a vertex and an edge, or a single edge"},planeRefName:{type:"reference_selection",selectionFilter:["FACE","PLANE"],multiple:!1,default_value:"",label:"Face/Plane",hint:"Projection plane (optional)"},alignment:{type:"options",default_value:"view",options:["view","XY","YZ","ZX"],label:"Alignment",hint:"Dimension alignment mode"},offset:{type:"number",default_value:0,label:"Offset",hint:"Offset distance for the dimension line",step:"any"},showExt:{type:"boolean",default_value:!0,label:"Extension Lines",hint:"Draw extension lines from anchors to offset line"},isReference:{type:"boolean",default_value:!1,label:"Reference",hint:"Mark as reference dimension (parentheses)"},decimals:{type:"number",default_value:3,defaultResolver:m(({pmimode:e})=>{const t=Number.isFinite(e?._opts?.dimDecimals)?e._opts.dimDecimals|0:void 0;if(Number.isFinite(t))return Math.max(0,Math.min(8,t))},"defaultResolver"),label:"Decimals",hint:"Number of decimal places to display",min:0,max:8,step:1}},$=class $ extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["VERTEX","EDGE"]);return n.length?{params:{targets:n.slice(0,2)}}:!1}constructor(t={}){super(t)}uiFieldsTest(t){const n=this.inputParams?.planeRefName;return(Array.isArray(n)?n.length>0:!!String(n||"").trim())?["alignment"]:[]}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=ut(n,i),c=a&&a.p0&&a.p1?a.p0.distanceTo(a.p1):null,l=ct(c,i);if(i.value=l.display,!a||!a.p0||!a.p1)return[];(!i.persistentData||typeof i.persistentData!="object")&&(i.persistentData={});const u=i.persistentData;try{const d=o.alignNormal?o.alignNormal(i?.alignment||"view",i):new f(0,0,1),h=an({pointA:a.p0,pointB:a.p1,normal:d,offset:i?.offset,showExtensions:i?.showExt!==!1,labelWorld:u.labelWorld||i.labelWorld,screenSizeWorld:o.screenSizeWorld,fallbackScreenSizeWorld:m(x=>q(n?.viewer,x),"fallbackScreenSizeWorld")});if(!h)return[];for(const[x,D]of h.segments)r.add(Y(x,D,1096065));for(const x of h.arrowSpecs)ne(r,x.tip,x.direction,x.length,x.width,1096065);h.leaderSegment&&r.add(Y(h.leaderSegment[0],h.leaderSegment[1],1096065));const g=Number.isFinite(i.decimals)?i.decimals:n?._opts?.dimDecimals|0,b=a.p0.distanceTo(a.p1),y=ct(b,i,g);i.value=y.display;const N=o.formatReferenceLabel?o.formatReferenceLabel(i,y.raw):y.display,A=h.labelPosition;A&&o.updateLabel(s,N,A,i)}catch{}return[]}static onLabelPointerDown(t,n,r,s,o){try{if(!t.viewer?.camera)return;const c=ut(t,r);if(!c||!c.p0||!c.p1)return;const l=c.p0,u=c.p1,p=o.alignNormal?o.alignNormal(r?.alignment||"view",r):new f(0,0,1),d=new f().subVectors(u,l).normalize(),h=new f().crossVectors(p,d).normalize(),g=new f().addVectors(l,u).multiplyScalar(.5),b=new I().setFromNormalAndCoplanarPoint(p,g);$.dragLabelOnPlane(t,o,{makePlane:m(()=>b,"makePlane"),onDrag:m(y=>{const A=new f().subVectors(y,g).dot(h);r.offset=A;const x=[y.x,y.y,y.z];$.ensurePersistentData(r),r.persistentData.labelWorld=x,r.labelWorld=x,o.updateLabel(n,null,y,r),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m($,"LinearDimensionAnnotation"),P($,"entityType","linear"),P($,"type","linear"),P($,"shortName","DIM"),P($,"longName","Linear Dimension"),P($,"title","Linear"),P($,"inputParamsSchema",fn);let Ce=$;function ct(e,t,n){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const r=n!==void 0?n:Number(t?.decimals),s=Number.isFinite(r)?Math.max(0,Math.min(8,r|0)):3,o=`${e.toFixed(s)}`,i=t?.isReference?`(${o})`:o;return{raw:o,display:i}}m(ct,"formatLinearLabel");function ut(e,t){const n=Array.isArray(t?.targets);try{const r=e?.viewer?.partHistory?.scene,s=pn(n?t.targets:null);if(r&&s.length){const o=dn(r,s);if(o.length){const i=[],a=[];for(const l of o){const u=typeof l?.type=="string"?l.type.toUpperCase():"";u==="VERTEX"?i.push(l):u==="EDGE"&&a.push(l)}const c=e?.viewer;if(i.length>=2){const l=ve(c,i[0]),u=ve(c,i[1]);if(l&&u)return{p0:l,p1:u}}if(i.length===1&&a.length){const l=ve(c,i[0]),u=l?mn(a,l):null;if(l&&u)return{p0:l,p1:u}}if(!i.length&&a.length){if(a.length===1){const l=qt(a[0]);if(l)return{p0:l.a,p1:l.b}}else if(a.length>=2)return Rt(a[0],a[1])}}}}catch{}if(!n)try{const r=e?.viewer?.partHistory?.scene,s=t?.aRefName||null,o=t?.bRefName||null;if(r&&(s||o)){const i=s?r.getObjectByName(s):null,a=o?r.getObjectByName(o):null;if(i&&a)return hn(i,a);if(i&&!a){const c=E(e.viewer,i),l=xe(t.p1);if(c&&l)return{p0:c,p1:l}}if(!i&&a){const c=E(e.viewer,a),l=xe(t.p0);if(l&&c)return{p0:l,p1:c}}}}catch{}return{p0:xe(t?.p0)||new f(0,0,0),p1:xe(t?.p1)||new f(0,0,0)}}m(ut,"computeDimPoints");function pn(e){return Array.isArray(e)?e:e==null||e===""?[]:[e]}m(pn,"normalizeTargetList");function dn(e,t){if(!e||!Array.isArray(t))return[];const n=[],r=new Set;for(const s of t){let o=null;if(s&&typeof s=="object")s.isObject3D?o=s:s.name&&(o=e.getObjectByName(s.name));else if(s!=null){const a=String(s).trim();a&&(o=e.getObjectByName(a))}if(!o)continue;const i=o.uuid||o.id||o.name;if(i!=null){const a=String(i);if(r.has(a))continue;r.add(a)}n.push(o)}return n}m(dn,"resolveTargetObjects");function ve(e,t){const n=E(e,t);return n&&n.clone||n&&n.isVector3?n.clone():t?.getWorldPosition?t.getWorldPosition(new f):null}m(ve,"resolveVertexPoint");function mn(e,t){if(!Array.isArray(e)||!t)return null;let n=null,r=1/0;for(const s of e){const o=qt(s);if(o){const a=o.a.distanceToSquared(t);a<r&&(r=a,n=o.a);const c=o.b.distanceToSquared(t);c<r&&(r=c,n=o.b);continue}const i=Be(s,t);if(i){const a=i.distanceToSquared(t);a<r&&(r=a,n=i)}}return n?n.clone():null}m(mn,"closestEndpointToPoint");function qt(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}try{if(typeof e.points=="function"){const o=e.points(!0);if(Array.isArray(o)&&o.length>=2){const i=Se(o[0]),a=Se(o[o.length-1]);if(i&&a)return{a:i,b:a}}}}catch{}const t=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(t&&t.length>=2){const o=Se(t[0]),i=Se(t[t.length-1]);if(o&&i)return e.matrixWorld&&(o.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld)),{a:o,b:i}}const n=e?.geometry?.attributes?.instanceStart,r=e?.geometry?.attributes?.instanceEnd;if(n&&r&&n.count>=1){const o=new f(n.getX(0),n.getY(0),n.getZ(0)),i=new f(r.getX(0),r.getY(0),r.getZ(0));return e.matrixWorld&&(o.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld)),{a:o,b:i}}const s=e?.geometry?.getAttribute?.("position");if(s&&s.itemSize===3&&s.count>=2){const o=new f(s.getX(0),s.getY(0),s.getZ(0)),i=new f(s.getX(s.count-1),s.getY(s.count-1),s.getZ(s.count-1));return e.matrixWorld&&(o.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld)),{a:o,b:i}}return null}m(qt,"edgeEndpointsWorld");function hn(e,t){if(e?.type==="VERTEX"&&t?.type==="VERTEX")return{p0:e.getWorldPosition(new f),p1:t.getWorldPosition(new f)};if(e?.type==="EDGE"&&t?.type==="VERTEX"){const n=t.getWorldPosition(new f);return{p0:Be(e,n),p1:n}}if(e?.type==="VERTEX"&&t?.type==="EDGE"){const n=e.getWorldPosition(new f),r=Be(t,n);return{p0:n,p1:r}}return e?.type==="EDGE"&&t?.type==="EDGE"?Rt(e,t):{p0:E(null,e)||new f,p1:E(null,t)||new f}}m(hn,"closestPointsForObjects");function Be(e,t){try{const n=e.points(!0);if(!n||n.length<2)return e.getWorldPosition(new f);const r=t.clone();let s={d2:1/0,q:null};const o=new f,i=new f;for(let a=0;a<n.length-1;a++){o.set(n[a].x,n[a].y,n[a].z),i.set(n[a+1].x,n[a+1].y,n[a+1].z);const c=yn(o,i,r),l=c.distanceToSquared(r);l<s.d2&&(s={d2:l,q:c})}return s.q||e.getWorldPosition(new f)}catch{return e.getWorldPosition(new f)}}m(Be,"closestPointOnEdgeToPoint");function Rt(e,t){try{const n=e.points(!0),r=t.points(!0);if(!n||n.length<2||!r||r.length<2)return{p0:E(null,e)||new f,p1:E(null,t)||new f};const s=new f,o=new f,i=new f,a=new f;let c={d2:1/0,p:null,q:null};for(let l=0;l<n.length-1;l++){s.set(n[l].x,n[l].y,n[l].z),o.set(n[l+1].x,n[l+1].y,n[l+1].z);for(let u=0;u<r.length-1;u++){i.set(r[u].x,r[u].y,r[u].z),a.set(r[u+1].x,r[u+1].y,r[u+1].z);const{p,q:d}=gn(s,o,i,a),h=p.distanceToSquared(d);h<c.d2&&(c={d2:h,p,q:d})}}return{p0:c.p||E(null,e)||new f,p1:c.q||E(null,t)||new f}}catch{return{p0:E(null,e)||new f,p1:E(null,t)||new f}}}m(Rt,"closestPointsBetweenEdges");function yn(e,t,n){const r=t.clone().sub(e),s=Math.max(0,Math.min(1,r.dot(n.clone().sub(e))/(r.lengthSq()||1)));return e.clone().addScaledVector(r,s)}m(yn,"closestPointOnSegment");function gn(e,t,n,r){const s=t.clone().sub(e),o=r.clone().sub(n),i=e.clone().sub(n),a=s.dot(s),c=o.dot(o),l=o.dot(i);let u,p;const d=1e-12;if(a<=d&&c<=d)u=0,p=0;else if(a<=d)u=0,p=Math.max(0,Math.min(1,l/c));else{const b=s.dot(i);if(c<=d)p=0,u=Math.max(0,Math.min(1,-b/a));else{const y=s.dot(o),N=a*c-y*y;u=N!==0?Math.max(0,Math.min(1,(y*l-b*c)/N)):0,p=(y*u+l)/c,p<0?(p=0,u=Math.max(0,Math.min(1,-b/a))):p>1&&(p=1,u=Math.max(0,Math.min(1,(y-b)/a)))}}const h=e.clone().addScaledVector(s,u),g=n.clone().addScaledVector(o,p);return{p:h,q:g}}m(gn,"closestPointsOnSegments");function Se(e){return ce(e)}m(Se,"arrayToVector");function xe(e){return e?e instanceof f?e.clone():Array.isArray(e)?new f(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new f(e.x||0,e.y||0,e.z||0):null:null}m(xe,"vectorFromAnnotationPoint");const wn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the radial dimension"},cylindricalFaceRef:{type:"reference_selection",selectionFilter:["FACE"],multiple:!1,default_value:"",label:"Cylindrical Face",hint:"Select cylindrical face"},planeRef:{type:"reference_selection",selectionFilter:["FACE","PLANE"],multiple:!1,default_value:"",label:"Projection Plane",hint:"Optional plane used to project the dimension"},displayStyle:{type:"options",default_value:"radius",options:["radius","diameter"],label:"Display Style",hint:"Display as radius or diameter"},alignment:{type:"options",default_value:"view",options:["view","XY","YZ","ZX"],label:"Alignment",hint:"Dimension alignment mode"},offset:{type:"number",default_value:0,label:"Offset",hint:"Distance to offset the dimension line",step:"any"},isReference:{type:"boolean",default_value:!1,label:"Reference",hint:"Mark as reference dimension (parentheses)"},decimals:{type:"number",default_value:3,defaultResolver:m(({pmimode:e})=>{const t=Number.isFinite(e?._opts?.dimDecimals)?e._opts.dimDecimals|0:void 0;if(Number.isFinite(t))return Math.max(0,Math.min(8,t))},"defaultResolver"),label:"Decimals",hint:"Number of decimal places to display",min:0,max:8,step:1}},X=class X extends v{static showContexButton(t){const n=v._normalizeSelectionItems(t),r=new Set(["FACE"]);for(const s of n){if(!v._isSelectionType(s,r)||!bn(s))continue;const o=v._selectionRefName(s);if(o)return{params:{cylindricalFaceRef:o}}}return!1}constructor(t={}){super(t)}uiFieldsTest(t){const n=this.inputParams?.planeRef;return(Array.isArray(n)?n.length>0:!!String(n||"").trim())?["alignment"]:[]}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=Sn(n,i),c=ft(a,i);i.value=c.display,pt(i);try{const l=Ie(n,i,o);if(!l||!l.center||!l.radiusPoint)return[];const{center:u,radiusPoint:p,planeNormal:d,planePoint:h,radius:g}=l,b=16739125;let y=new f().subVectors(p,u);y.lengthSq()<1e-6&&y.set(1,0,0),y.normalize();let N=d;if(N||(N=o.alignNormal?o.alignNormal(i.alignment||"view",i):null),N&&N.lengthSq()>1e-6){const S=y.clone().projectOnPlane(N).normalize();S.lengthSq()>1e-6&&(y=S)}const A=o.screenSizeWorld?o.screenSizeWorld(12):q(n?.viewer,12),x=o.screenSizeWorld?o.screenSizeWorld(4):q(n?.viewer,4),D=i.displayStyle==="diameter",w=i.persistentData?.labelWorld?$e(i.persistentData.labelWorld):null;if(D){const S=w?w.clone().sub(u).normalize():y.clone(),z=w?u.clone().addScaledVector(S,w.clone().sub(u).length()):u.clone().addScaledVector(S,g+Math.abs(Number(i.offset)||o.screenSizeWorld?o.screenSizeWorld(50):q(n?.viewer,50))),M=u.clone().addScaledVector(S,-g),T=u.clone().addScaledVector(S,g),F=u.clone().addScaledVector(S,-g);r.add(Y(M,z,b)),ne(r,T,S.clone(),A,x,b),ne(r,F,S.clone().negate(),A,x,b);const L=Ve(o.screenSizeWorld?o.screenSizeWorld(6):q(n?.viewer,6),b);L.position.copy(u),r.add(L)}else{const S=w||Lt(n,i,u,p,d,h,o);let M=S.clone().sub(u).clone();M.lengthSq()||(M=y.clone()),M.normalize();const T=S;r.add(Y(u,T,b));const F=u.clone().addScaledVector(M,g);ne(r,F,M.clone(),A,x,b);const L=Ve(o.screenSizeWorld?o.screenSizeWorld(6):q(n?.viewer,6),b);L.position.copy(u),r.add(L)}if(typeof a=="number"){const S=ft(a,i);i.value=S.display;const z=o.formatReferenceLabel?o.formatReferenceLabel(i,S.raw):S.display,M=xn(n,i,u,p,d,h,o);M&&o.updateLabel(s,z,M,i)}}catch(l){console.warn("RadialDimensionAnnotation render error:",l)}return[]}static onLabelPointerDown(t,n,r,s,o){try{const i=Ie(t,r,o);if(!i||!i.center||!i.radiusPoint)return;const a=i.planeNormal&&i.planeNormal.lengthSq()>1e-6?i.planeNormal.clone().normalize():o.alignNormal?o.alignNormal(r.alignment||"view",r):new f(0,0,1),c=i.planePoint||i.radiusPoint,l=a&&c?new I().setFromNormalAndCoplanarPoint(a,c):null,u=new f().subVectors(i.radiusPoint,i.center).normalize();X.dragLabelOnPlane(t,o,{makePlane:m(()=>l,"makePlane"),onDrag:m(p=>{l.projectPoint(p,p),pt(r),r.persistentData.labelWorld=[p.x,p.y,p.z];const d=new f().subVectors(p,i.center);r.offset=d.dot(u)-i.radius,o.updateLabel(n,null,p,r),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m(X,"RadialDimensionAnnotation"),P(X,"entityType","radial"),P(X,"type","radial"),P(X,"shortName","RAD"),P(X,"longName","Radial Dimension"),P(X,"title","Radial"),P(X,"inputParamsSchema",wn);let je=X;function ft(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=t?.displayStyle==="diameter"?e*2:e,r=Number(t?.decimals),s=Number.isFinite(r)?Math.max(0,Math.min(8,r|0)):3,i=`${t?.displayStyle==="diameter"?"⌀":"R"}${n.toFixed(s)}`,a=`${i} (wu)`,c=t?.isReference?`(${a})`:a;return{raw:i,display:c}}m(ft,"formatRadialLabel");function pt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(pt,"ensurePersistent$2");function Ie(e,t,n){try{const r=e?.viewer?.partHistory?.scene;if(!r||!t.cylindricalFaceRef)return null;const s=r.getObjectByName(t.cylindricalFaceRef);if(!s)return null;let o=s;for(;o&&typeof o.getFaceMetadata!="function";)o=o.parent;let i=null,a=null,c=null,l=null,u=null;const p=new f;let d=null,h=null;if(o&&typeof o.getFaceMetadata=="function"&&(d=o.getFaceMetadata(t.cylindricalFaceRef),d&&(d.type==="cylindrical"||d.type==="conical")&&(d.type==="cylindrical"?(i=new f(d.center[0],d.center[1],d.center[2]),a=d.radius,c=new f(d.axis[0],d.axis[1],d.axis[2]).normalize()):Math.abs(d.radiusBottom-d.radiusTop)<1e-6&&(i=new f(d.center[0],d.center[1],d.center[2]),a=d.radiusBottom,c=new f(d.axis[0],d.axis[1],d.axis[2]).normalize()),i&&c&&(s.parent&&s.parent.matrixWorld&&(i.applyMatrix4(s.parent.matrixWorld),c.transformDirection(s.parent.matrixWorld).normalize()),u=new f,Math.abs(c.x)<.9?u.crossVectors(c,new f(1,0,0)).normalize():u.crossVectors(c,new f(0,1,0)).normalize(),l=i.clone().addScaledVector(u,a))),d&&typeof d=="object")){const y=d.pmiRadiusOverride??d.radiusOverride;Number.isFinite(y)&&y>0&&(h=Math.abs(y))}if((!i||!c||!Number.isFinite(a)||a<=0)&&o){const y=Pn(o,s);y&&(i=y.center,c=y.axis,a=y.radius,l=y.radiusPoint,u=y.perpendicular)}if(!i||!c||!Number.isFinite(a)||a<=0){const y=En(s);if(!y)return null;i=y.center,c=y.axis,a=y.radius,l=y.radiusPoint,u=new f().subVectors(l,i).normalize()}if(h&&i){let y=null;u&&u.lengthSq()>1e-12?y=u.clone().normalize():l&&(y=new f().subVectors(l,i),y.lengthSq()>1e-12&&y.normalize()),a=h,y&&(u=y.clone(),l=i.clone().addScaledVector(y,a))}p.copy(i);let g=null,b=null;if(t.planeRef){const y=r.getObjectByName(t.planeRef);y&&(g=ue(e.viewer,y),b=E(e.viewer,y))}if(g&&b&&g.lengthSq()>1e-6){const y=g.clone().normalize();g=y;const N=new I().setFromNormalAndCoplanarPoint(y,b),A=new f;N.projectPoint(i,A),i=A;let x=new f().subVectors(l,p);x.lengthSq()<1e-12&&(x=u.clone());let D=x.projectOnPlane(y);D.lengthSq()<1e-12&&(D=c.clone().cross(y),D.lengthSq()<1e-12&&(Math.abs(y.x)<.9?D=new f().crossVectors(y,new f(1,0,0)):D=new f().crossVectors(y,new f(0,1,0)))),D.normalize(),l=i.clone().addScaledVector(D,a)}return{center:i,radiusPoint:l,planeNormal:g,planePoint:b,axis:c,radius:a}}catch{return null}}m(Ie,"computeRadialPoints");function Fe(e){if(!e||typeof e!="object")return!1;const t=String(e.type||"").toLowerCase();if(t==="cylindrical"){const n=Number(e.radius);return Number.isFinite(n)&&n>0}if(t==="conical"){const n=Number(e.radiusBottom),r=Number(e.radiusTop);return!Number.isFinite(n)||!Number.isFinite(r)||Math.abs(n-r)>1e-6?!1:Math.max(n,r)>0}return!1}m(Fe,"isCylindricalMetadata");function qe(e){if(!e)return null;const t=e.userData||null;if(t?.metadata&&Fe(t.metadata))return t.metadata;if(typeof e.getMetadata=="function")try{const s=e.getMetadata();if(Fe(s))return s}catch{}const n=e?.name||t?.faceName||null;let r=e?.parentSolid||t?.parentSolid||e?.parent||null;for(;r;){if(n&&typeof r.getFaceMetadata=="function"){try{const s=r.getFaceMetadata(n);if(Fe(s))return s}catch{}break}r=r.parent||null}return null}m(qe,"readCylindricalMetadata");function bn(e){if(!e)return!1;if(qe(e))return!0;if(Array.isArray(e.faces)){for(const t of e.faces)if(qe(t))return!0}return!!(e.parent&&qe(e.parent))}m(bn,"hasCylindricalMetadata");function Sn(e,t){try{const n=Ie(e,t);return n&&typeof n.radius=="number"?n.radius:n&&n.center&&n.radiusPoint?n.center.distanceTo(n.radiusPoint):null}catch{return null}}m(Sn,"measureRadialValue");function xn(e,t,n,r,s,o,i){try{let a=null;return t.persistentData?.labelWorld?a=$e(t.persistentData.labelWorld):t.labelWorld&&(a=$e(t.labelWorld)),a||(a=Lt(e,t,n,r,s,o,i)),s&&o&&s.lengthSq()>1e-6&&a&&new I().setFromNormalAndCoplanarPoint(s.clone().normalize(),o).projectPoint(a,a),a}catch{return null}}m(xn,"resolveLabelPosition$1");function Lt(e,t,n,r,s,o,i){try{const a=new f().subVectors(r,n);if(a.lengthSq()<1e-12)return r.clone();a.normalize();let c=Number(t?.offset);(!Number.isFinite(c)||c===0)&&(c=i.screenSizeWorld?i.screenSizeWorld(50):q(e?.viewer,50));const l=n.distanceTo(r),u=n.clone().addScaledVector(a,l+Math.abs(c));return s&&o&&s.lengthSq()>1e-6&&new I().setFromNormalAndCoplanarPoint(s.clone().normalize(),o).projectPoint(u,u),u}catch{return r?r.clone():null}}m(Lt,"computeRadialLabelPosition");function Pn(e,t){try{if(!e||!t)return null;const n=Array.isArray(e._auxEdges)?e._auxEdges:null;if(!n||n.length===0)return null;const r=(t.name||t.userData?.faceName||"").trim();if(!r)return null;const s=Mn(r);if(!s)return null;const o=Nn(n,`${s}_PATH`);if(!o||!Array.isArray(o.points)||o.points.length<2)return null;e.updateMatrixWorld?.(!0),t.updateMatrixWorld?.(!0);const i=An(o,e);if(!i||i.length<2)return null;const a=Dn(t,16);if(!a.length)return null;let c=null;for(const l of a){const u=Tn(l,i,!!o.closedLoop);if(!u||!u.point)continue;const p=new f().subVectors(l,u.point),d=p.lengthSq();if(!(d>1e-10))continue;const h=Math.sqrt(d);p.normalize(),(!c||h>c.radius)&&(c={center:u.point.clone(),axis:u.direction?u.direction.clone():null,radius:h,radiusPoint:u.point.clone().addScaledVector(p,h),perpendicular:p.clone()})}return c?((!c.axis||c.axis.lengthSq()<1e-10)&&(c.axis=zn(i,c.center,!!o.closedLoop)||new f(0,1,0)),c):null}catch{return null}}m(Pn,"inferPipeFaceDataFromAuxEdges");function Nn(e,t){if(!Array.isArray(e)||!t)return null;for(const r of e)if(r?.name===t)return r;const n=t.toLowerCase();for(const r of e)if(typeof r?.name=="string"&&r.name.toLowerCase()===n)return r;return null}m(Nn,"findAuxEdgeByName");function An(e,t){try{const n=[],r=!e.polylineWorld&&t?.matrixWorld?t.matrixWorld:null,s=new f;for(const o of e.points){if(Array.isArray(o)&&o.length>=3)s.set(o[0],o[1],o[2]);else if(o&&typeof o=="object")s.set(Number(o.x)||0,Number(o.y)||0,Number(o.z)||0);else continue;r&&s.applyMatrix4(r),n.push(s.clone())}return n}catch{return null}}m(An,"buildAuxPolylineWorld");function Dn(e,t=16){try{const n=e?.geometry;if(!n)return[];const r=typeof n.getAttribute=="function"?n.getAttribute("position"):null,s=e.matrixWorld||new me,o=[],i=new f;if(r&&r.count>0){const a=Math.max(1,Math.floor(r.count/t));for(let c=0;c<r.count&&o.length<t;c+=a)i.set(r.getX(c),r.getY(c),r.getZ(c)).applyMatrix4(s),o.push(i.clone())}if(!o.length)try{n.computeBoundingSphere?.(),n.boundingSphere&&(i.copy(n.boundingSphere.center).applyMatrix4(s),o.push(i.clone()))}catch{}return o}catch{return[]}}m(Dn,"collectFaceSamplePoints");function Tn(e,t,n=!1){if(!e||!Array.isArray(t)||t.length<2)return null;const r=new f,s=new f,o=new f;let i=null,a=null,c=1/0;const l=t.length,u=n?l:l-1;for(let p=0;p<u;p++){const d=t[p],h=t[(p+1)%l];if(!d||!h)continue;s.copy(h).sub(d);const g=s.lengthSq();if(g<1e-14)continue;o.copy(e).sub(d);let b=o.dot(s)/g;b=Math.max(0,Math.min(1,b)),r.copy(d).addScaledVector(s,b);const y=r.distanceToSquared(e);y<c&&(c=y,i=r.clone(),a=s.clone().normalize())}return i?{point:i,direction:a,distanceSq:c}:null}m(Tn,"closestPointOnPolyline");function zn(e,t,n=!1){if(!Array.isArray(e)||e.length<2||!t)return null;let r=null,s=1/0;const o=new f,i=new f,a=e.length,c=n?a:a-1;for(let l=0;l<c;l++){const u=e[l],p=e[(l+1)%a];if(!u||!p)continue;o.copy(u).add(p).multiplyScalar(.5);const d=o.distanceToSquared(t);d<s&&(s=d,i.copy(p).sub(u),r=i.lengthSq()>1e-14?i.clone().normalize():null)}return r}m(zn,"estimatePolylineTangent");function Mn(e){const t=/^(.*?)(_Outer|_Inner|_CapStart|_CapEnd)$/i.exec(e);return t?t[1]:null}m(Mn,"pipeFaceBaseName");function En(e){try{const t=e?.geometry;if(!t||!t.getAttribute)return null;const n=t.getAttribute("position");if(!n||n.count<6)return null;const r=e.matrixWorld||new me,s=[],o=new f;for(let w=0;w<n.count;w++)o.set(n.getX(w),n.getY(w),n.getZ(w)).applyMatrix4(r),s.push(o.clone());if(!s.length)return null;const i=new f;for(const w of s)i.add(w);i.divideScalar(s.length);const a=new Float64Array(9),c=new f;for(const w of s)c.copy(w).sub(i),a[0]+=c.x*c.x,a[1]+=c.x*c.y,a[2]+=c.x*c.z,a[4]+=c.y*c.y,a[5]+=c.y*c.z,a[8]+=c.z*c.z;a[3]=a[1],a[6]=a[2],a[7]=a[5];const l=new f(1,0,0);for(let w=0;w<20;w++){const S=a[0]*l.x+a[1]*l.y+a[2]*l.z,z=a[1]*l.x+a[4]*l.y+a[5]*l.z,M=a[2]*l.x+a[5]*l.y+a[8]*l.z;l.set(S,z,M);const T=l.length();if(T<1e-12){l.set(0,1,0);break}l.divideScalar(T)}l.lengthSq()<1e-12&&l.set(0,1,0);let u=1/0,p=-1/0,d=0,h=0;const g=new f,b=new f,y=new f;for(const w of s){c.copy(w).sub(i);const S=c.dot(l);S<u&&(u=S),S>p&&(p=S),b.copy(l).multiplyScalar(S),g.copy(c).sub(b);const z=g.length();z>1e-6&&(h===0&&y.copy(g).normalize(),d+=z,h++)}if(!h)return null;const N=d/h,A=i.clone().add(l.clone().multiplyScalar((u+p)*.5)),x=y.lengthSq()>1e-12?y.clone():new f().crossVectors(l,new f(1,0,0)).normalize();x.lengthSq()<1e-12&&x.set(0,1,0).cross(l).normalize();const D=A.clone().addScaledVector(x,N);return{center:A,axis:l.normalize(),radius:N,radiusPoint:D}}catch{return null}}m(En,"inferCylinderFromGeometry");function $e(e){return e?e instanceof f?e.clone():Array.isArray(e)?new f(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new f(e.x||0,e.y||0,e.z||0):null:null}m($e,"vectorFromAny$1");const vn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the angle dimension"},decimals:{type:"number",default_value:1,defaultResolver:m(({pmimode:e})=>{const t=Number.isFinite(e?._opts?.angleDecimals)?e._opts.angleDecimals|0:void 0;if(Number.isFinite(t))return Math.max(0,Math.min(3,t))},"defaultResolver"),label:"Decimals",hint:"Number of decimal places to display",min:0,max:3,step:1},targets:{type:"reference_selection",selectionFilter:["FACE","EDGE"],multiple:!0,default_value:[],label:"Elements",hint:"Select two edges/faces to define the angle",minSelections:2,maxSelections:2},planeRefName:{type:"reference_selection",selectionFilter:["FACE","PLANE"],multiple:!1,default_value:"",label:"Projection Plane",hint:"Override projection plane (optional)"},reverseElementOrder:{type:"boolean",default_value:!1,label:"Reverse Selection Order",hint:"Swap Element A and Element B to flip the measured side"},isReference:{type:"boolean",default_value:!1,label:"Reference",hint:"Mark as reference dimension (parentheses)"},angleType:{type:"options",default_value:"acute",options:["acute","obtuse","reflex"],label:"Angle Type",hint:"Choose which angle (acute, obtuse, or reflex) to display"}},Q=class Q extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["FACE","EDGE"]);return n.length<2?!1:{params:{targets:n.slice(0,2)}}}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=qn(n,i),c=mt(a,i);i.value=c.display,dt(i);try{const l=ht(n,i,o);if(!l||!l.__2d)return[];const u=16096779,{N:p,P:d,A_d:h,B_d:g,V2:b,basis:y,sweep:N=0,dirSign:A=1,bisector:x=null}=l.__2d,D=sn({planePoint:d,planeNormal:p,basis:y,vertex2D:b,directionA2D:h,directionB2D:g,sweepRad:N,sweepDirection:A,bisector2D:x,labelWorld:i.persistentData?.labelWorld,screenSizeWorld:o.screenSizeWorld,fallbackScreenSizeWorld:m(w=>q(n?.viewer,w),"fallbackScreenSizeWorld")});if(!D)return[];for(let w=0;w<D.arcPoints.length-1;w+=1)r.add(Y(D.arcPoints[w],D.arcPoints[w+1],u));for(const[w,S]of D.segments)r.add(Y(w,S,u));for(const w of D.arrowSpecs)ne(r,w.tip,w.direction,w.length,w.width,u);if(typeof a=="number"){const w=mt(a,i),S=w.raw;i.value=w.display;const z=o.formatReferenceLabel?o.formatReferenceLabel(i,S):w.display,M=D.labelPosition;M&&o.updateLabel(s,z,M,i)}}catch{}return[]}static onLabelPointerDown(t,n,r,s,o){try{const i=ht(t,r,o);if(!i)return;const a=nt(t,r,i,o),c=a?.n||new f(0,0,1),l=a?.p||new f,u=new I().setFromNormalAndCoplanarPoint(c,l);try{t?.showDragPlaneHelper?.(u)}catch{}const p=m(h=>{const g=o.raycastFromEvent?o.raycastFromEvent(h):null;if(!g)return;const b=new f;(o.intersectPlane?o.intersectPlane(g,u,b):g.intersectPlane(u,b))&&(dt(r),r.persistentData.labelWorld=[b.x,b.y,b.z],o.updateLabel(n,null,b,r),t.refreshAnnotationsUI?.())},"onMove"),d=m(h=>{try{window.removeEventListener("pointermove",p,!0),window.removeEventListener("pointerup",d,!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}try{t.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}try{h.preventDefault(),h.stopImmediatePropagation?.(),h.stopPropagation()}catch{}},"onUp");window.addEventListener("pointermove",p,!0),window.addEventListener("pointerup",d,!0)}catch{}}};m(Q,"AngleDimensionAnnotation"),P(Q,"entityType","angle"),P(Q,"type","angle"),P(Q,"shortName","ANG"),P(Q,"longName","Angle Dimension"),P(Q,"title","Angle"),P(Q,"inputParamsSchema",vn);let Ue=Q;function dt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(dt,"ensurePersistent$1");function Fn(e){const t=Array.isArray(e)?e:e==null||e===""?[]:[e],n=[],r=new Set;for(const s of t){let o="";s&&typeof s=="object"?typeof s.name=="string"?o=s.name:s.id!=null&&(o=String(s.id)):s!=null&&(o=String(s)),o=o.trim(),!(!o||r.has(o))&&(r.add(o),n.push(o))}return n}m(Fn,"normalizeTargetNames");function tt(e){const t=Array.isArray(e?.targets),n=Fn(t?e.targets:null);let r="",s="";return n.length?(r=n[0]||"",s=n[1]||""):t||(r=e?.elementARefName||"",s=e?.elementBRefName||""),e?.reverseElementOrder?{elementARefName:s,elementBRefName:r}:{elementARefName:r,elementBRefName:s}}m(tt,"resolveElementRefNames");function Wt(e){const t=e?.angleType;return t==="acute"||t==="obtuse"||t==="reflex"?t:e?.useReflexAngle?"reflex":"acute"}m(Wt,"resolveAngleType");function Vt(e){return!e||typeof e!="object"||!Object.prototype.hasOwnProperty.call(e,"angleType")?!1:e.angleType==="acute"||e.angleType==="obtuse"||e.angleType==="reflex"}m(Vt,"isAngleTypeExplicit");function mt(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=Number(t?.decimals),r=Number.isFinite(n)?Math.max(0,Math.min(3,n|0)):1,s=`${e.toFixed(r)}°`,o=t?.isReference?`(${s})`:s;return{raw:s,display:o}}m(mt,"formatAngleLabel");function qn(e,t){try{const n=Ot(e,t),r=nt(e,t,n);if(!r)return null;const{elementARefName:s,elementBRefName:o}=tt(t),i=Te(e,s,r.n,r.p),a=Te(e,o,r.n,r.p);if(!i||!a)return null;const c=et(r.n,i.d),l=De(i.d,c).normalize(),u=De(a.d,c).normalize(),p=Wt(t),d=Vt(t)||!!t?.useReflexAngle,h=Ft(l,u,p,d);return h?Pe.radToDeg(h.angleRad):null}catch{return null}}m(qn,"measureAngleValue");function Ot(e,t){try{const n=e?.viewer?.partHistory?.scene;if(!n)return null;const{elementARefName:r,elementBRefName:s}=tt(t),o=r?n.getObjectByName(r):null,i=s?n.getObjectByName(s):null;if(!o||!i)return null;const a=ue(e.viewer,o),c=ue(e.viewer,i),l=E(e.viewer,o),u=E(e.viewer,i);let p=null;if(t.planeRefName){const d=n.getObjectByName(t.planeRefName);d&&(p=ue(e.viewer,d))}return{dirA:a,dirB:c,pointA:l,pointB:u,plane:p}}catch{return null}}m(Ot,"computeAngleElements");function ht(e,t,n){try{const r=Ot(e,t);if(!r||!r.dirA||!r.dirB)return null;const s=nt(e,t,r,n);if(!s)return null;const{elementARefName:o,elementBRefName:i}=tt(t),a=Te(e,o,s.n,s.p),c=Te(e,i,s.n,s.p);if(!a||!c)return null;const l=et(s.n,a.d),u=Oe(a.p,s.p,l),p=Oe(c.p,s.p,l);let d=De(a.d,l).normalize(),h=De(c.d,l).normalize();t?.reverseElementOrder&&(d=d.multiplyScalar(-1),h=h.multiplyScalar(-1));const g=Wt(t),b=Vt(t)||!!t?.useReflexAngle,y=Ft(d,h,g,b);if(!y)return null;const N=y.start.clone(),A=y.end.clone();let x=rn(u,N,p,A);if(x){const D=Math.max(1e-6,u.distanceTo(p));Math.max(x.distanceTo(u),x.distanceTo(p))>D*8&&(x=null)}return x||(x=new _().addVectors(u,p).multiplyScalar(.5)),{...r,__2d:{N:s.n,P:s.p,basis:l,A_p:u,B_p:p,A_d:N,B_d:A,V2:x,sweep:y.sweep,dirSign:y.dirSign,angleRad:y.angleRad,angleType:y.angleType,bisector:y.bisector}}}catch{return null}}m(ht,"computeAngleElementsWithGeometry");function nt(e,t,n,r){try{if(t?.planeRefName){const a=e.viewer?.partHistory?.scene?.getObjectByName(t.planeRefName);if(a){const c=ue(e.viewer,a)||new f(0,0,1);if(c.lengthSq()>1e-12){const l=E(e.viewer,a)||new f;return{n:c.clone().normalize(),p:l}}}}if(n?.dirA&&n?.dirB){const a=new f().crossVectors(n.dirA,n.dirB);if(a.lengthSq()>1e-12){const c=n.pointA&&n.pointB?new f().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n.pointA||n.pointB||new f;return{n:a.normalize(),p:c}}}const o=(r?.alignNormal?r.alignNormal("view",t):null)||n?.plane||new f(0,0,1),i=n?.pointA&&n?.pointB?new f().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n?.pointA||n?.pointB||new f;return{n:o.clone().normalize(),p:i}}catch{return{n:new f(0,0,1),p:new f}}}m(nt,"resolveAnglePlane");function Te(e,t,n,r){try{if(!t)return null;const s=e?.viewer?.partHistory?.scene;if(!s)return null;const o=s.getObjectByName(t);if(!o)return null;const i=n&&n.lengthSq()>1e-12?n.clone().normalize():new f(0,0,1),a=E(e.viewer,o)||r||new f,c=r||a,l=new I().setFromNormalAndCoplanarPoint(i,c),u=ue(e.viewer,o),p=u?u.clone().normalize():null,d=o?.userData||{},h=String(o?.type||"").toUpperCase(),g=String(d.type||d.brepType||"").toUpperCase(),y=h==="FACE"||h==="PLANE"||!(h==="FACE"||h==="EDGE"||h==="PLANE")&&(g==="FACE"||g==="PLANE");if(h==="EDGE"||!y&&(g==="EDGE"||o?.isLine||o?.isLine2||o?.isLineSegments||o?.isLineLoop)){const w=Rn(o,l,c);if(w)return w}if(y&&p&&p.lengthSq()>1e-12){const w=p.clone().normalize(),S=new f().crossVectors(w,i),z=S.lengthSq();if(z>1e-12){const M=w.dot(a),T=i.dot(c),F=new f().crossVectors(i,S).multiplyScalar(M),L=new f().crossVectors(S,w).multiplyScalar(T),R=F.add(L).divideScalar(z);return{p:l.projectPoint(R,R.clone()),d:S.normalize()}}}let A=a.clone();if(p&&p.lengthSq()>1e-12){const w=p.dot(i);if(Math.abs(w)>1e-9){const z=c.clone().clone().sub(a).dot(i)/w;A=a.clone().addScaledVector(p,z)}}const x=l.projectPoint(A,A.clone());let D=p?p.clone().projectOnPlane(i):null;return(!D||D.lengthSq()<1e-12)&&(D=et(i).U.clone()),D.normalize(),{p:x,d:D}}catch{return null}}m(Te,"lineInPlaneForElement");function Rn(e,t,n){const r=Ln(e);if(!Array.isArray(r)||r.length<2)return null;const s=[];for(const u of r)u&&s.push(t.projectPoint(u,u.clone()));if(s.length<2)return null;let o=0,i=1,a=0;for(let u=0;u<s.length;u++)for(let p=u+1;p<s.length;p++){const d=s[u].distanceToSquared(s[p]);d>a&&(a=d,o=u,i=p)}if(a<=1e-12)return null;const c=s[i].clone().sub(s[o]).normalize();let l=s[o].clone();if(n){let u=l.distanceToSquared(n);for(let p=0;p<s.length;p++){const d=s[p].distanceToSquared(n);d<u&&(u=d,l=s[p].clone())}}return{p:l,d:c}}m(Rn,"edgeLineInPlane");function Ln(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}const t=e.matrixWorld||null,n=[],r=m(c=>{const l=yt(c);if(!l)return;const u=n[n.length-1];u&&u.distanceToSquared(l)<=1e-14||n.push(l)},"pushUnique");try{if(typeof e.points=="function"){const c=e.points(!0);if(Array.isArray(c))for(const l of c)r(l);if(n.length>=2)return n;n.length=0}}catch{}const s=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(s){for(const c of s){const l=yt(c);l&&(t&&l.applyMatrix4(t),r(l))}if(n.length>=2)return n;n.length=0}const o=e?.geometry?.attributes?.instanceStart,i=e?.geometry?.attributes?.instanceEnd;if(o&&i){const c=Math.min(o.count||0,i.count||0);for(let l=0;l<c;l++){const u=new f(o.getX(l),o.getY(l),o.getZ(l)),p=new f(i.getX(l),i.getY(l),i.getZ(l));t&&(u.applyMatrix4(t),p.applyMatrix4(t)),r(u),r(p)}if(n.length>=2)return n;n.length=0}const a=e?.geometry?.getAttribute?.("position");if(a&&a.itemSize===3&&a.count>=2){for(let c=0;c<a.count;c++){const l=new f(a.getX(c),a.getY(c),a.getZ(c));t&&l.applyMatrix4(t),r(l)}if(n.length>=2)return n}return null}m(Ln,"getEdgeWorldPoints");function yt(e){if(!e)return null;if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3)return new f(e[0]||0,e[1]||0,e[2]||0);if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),r=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))return new f(t,n,r)}return null}m(yt,"pointFromAny");const Wn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the leader"},target:{type:"reference_selection",selectionFilter:["VERTEX"],multiple:!0,default_value:"",label:"Target Point",hint:"Select target point"},text:{type:"textarea",default_value:"TEXT HERE",defaultResolver:m(({pmimode:e})=>{const t=e?._opts?.leaderText;return typeof t=="string"&&t.length?t:void 0},"defaultResolver"),label:"Text",hint:"Leader text content",rows:3},anchorPosition:{type:"options",default_value:"Right Middle",options:["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"],label:"Anchor Position",hint:"Preferred label alignment relative to anchor"},endStyle:{type:"options",default_value:"arrow",options:["arrow","dot"],label:"Leader End",hint:"Choose arrowhead or dot for end marker"}},H=class H extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["VERTEX"]);return n.length?{params:{target:n}}:!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams||{},a=Je();gt(i),i.anchorPosition=wt(i.anchorPosition??i.anchorSide),delete i.anchorSide;const c=n?.viewer,l=c?.partHistory?.scene,u=bt(c,l,i),p=St(n,i,u,o),d=o?.formatReferenceLabel?o.formatReferenceLabel(i,Re(i.text)):Re(i.text);if(i.value=d,p&&o?.updateLabel?.(s,d,p,i),!u.length||!p)return[];const h=a.lineColor??9684477,g=He(n,c),b=ke(u)||p,y=On(p,b,g),N=Math.max(o?.screenSizeWorld?o.screenSizeWorld(18):q(c,18),1e-4),A=Math.max(o?.screenSizeWorld?o.screenSizeWorld(36):q(c,36),1e-4),x=_n(u,g,p),D=(x.length-1)*.5;return x.forEach(({point:w,order:S})=>{const z=(S-D)*N,M=p.clone().addScaledVector(y,-A).addScaledVector(g.up,z);if(r.add(Y(w,M,h)),r.add(Y(M,p,h)),i.endStyle==="dot"){const T=a.leaderDotRadiusPx??6,F=o?.screenSizeWorld?o.screenSizeWorld(T):q(c,T),L=Ve(Math.max(F,1e-4),a.dotColor??h);L.position.copy(w),r.add(L)}else{const T=w.clone().sub(M);T.lengthSq()||T.copy(y),T.normalize();const F=a.arrowLengthPx??12,L=a.arrowWidthPx??4,R=o?.screenSizeWorld?o.screenSizeWorld(F):q(c,F),Z=o?.screenSizeWorld?o.screenSizeWorld(L):q(c,L);ne(r,w,T,R,Z,a.arrowColor??h)}}),[]}static applyParams(t,n,r){return super.applyParams(t,n,r),n.text=Re(n.text),Array.isArray(n.target)||(n.target=n.target?[String(n.target)]:[]),n.anchorPosition=wt(n.anchorPosition??n.anchorSide),delete n.anchorSide,n.endStyle=Vn(n.endStyle),{paramsPatch:{}}}static onLabelPointerDown(t,n,r,s,o){try{const i=t?.viewer,a=bt(i,i?.partHistory?.scene,r),c=St(t,r,a,o)||new f,u=He(t,i,r).forward,p=a&&a.length&&a[0]?a[0]:ke(a)||c;if(!o?.raycastFromEvent)return;const d=new I().setFromNormalAndCoplanarPoint(u,p);H.dragLabelOnPlane(t,o,{makePlane:m(()=>d,"makePlane"),onDrag:m(h=>{gt(r),r.persistentData.labelWorld=[h.x,h.y,h.z],o.updateLabel(n,null,h,r),t?.refreshAnnotationsUI?.()},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m(H,"LeaderAnnotation"),P(H,"entityType","leader"),P(H,"type","leader"),P(H,"shortName","LEAD"),P(H,"longName","Leader"),P(H,"title","Leader"),P(H,"inputParamsSchema",Wn);let Xe=H;function gt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(gt,"ensurePersistentData$1");function Re(e){return typeof e=="string"?e:e==null?"":String(e)}m(Re,"sanitizeText$1");function wt(e){const t=new Set(["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"]);if(typeof e=="string"){const n=e.trim();if(t.has(n))return n;const r=n.toLowerCase();if(r==="left")return"Left Middle";if(r==="right")return"Right Middle";if(r==="left-top"||r==="lefttop")return"Left Top";if(r==="left-bottom"||r==="leftbottom")return"Left Bottom";if(r==="right-top"||r==="righttop")return"Right Top";if(r==="right-bottom"||r==="rightbottom")return"Right Bottom"}if(e&&typeof e=="object"){const n=String(e.label||e.value||e.name||"").trim();if(t.has(n))return n}return"Right Middle"}m(wt,"normalizeAnchorPosition$1");function Vn(e){return e==="dot"?"dot":"arrow"}m(Vn,"normalizeEndStyle");function bt(e,t,n){const r=Array.isArray(n?.target)?n.target:[];if(!r.length||!t)return[];const s=[],o=new Set;for(const i of r){const a=typeof i=="string"?i:String(i??"");if(!(!a||o.has(a))){o.add(a);try{const c=t.getObjectByName?.(a);if(!c)continue;let l=E(e,c);!l&&typeof c.getWorldPosition=="function"&&(l=c.getWorldPosition(new f)),l&&s.push(l.clone())}catch{}}}return s}m(bt,"resolveTargetPoints");function St(e,t,n,r){const s=e?.viewer,o=He(e,s),i=n&&n.length&&n[0]?n[0].clone():ke(n)||new f,a=o?.forward&&o.forward.lengthSq()?o.forward.clone():new f(0,0,1),c=new I().setFromNormalAndCoplanarPoint(a,i),l=jn(t?.persistentData?.labelWorld);if(l){const b=l.clone();return c.projectPoint(b,b),b}const u=Math.max(r?.screenSizeWorld?r.screenSizeWorld(90):q(s,90),1e-4),p=Math.max(r?.screenSizeWorld?r.screenSizeWorld(36):q(s,36),1e-4),d=o?.right&&o.right.lengthSq()?o.right.clone():new f(1,0,0),h=o?.up&&o.up.lengthSq()?o.up.clone():new f(0,1,0),g=i.clone().addScaledVector(d,u).addScaledVector(h,p);return c.projectPoint(g,g),g}m(St,"resolveLabelPosition");function He(e,t,n){const r=Cn(e?.viewEntry?.camera);if(r)return r;const s=new f(0,0,-1),o=new f(0,1,0);try{t?.camera?.getWorldDirection&&(t.camera.getWorldDirection(s),s.normalize()),t?.camera?.up&&o.copy(t.camera.up).normalize()}catch{}s.lengthSq()||s.set(0,0,-1),o.lengthSq()||o.set(0,1,0);const i=new f().crossVectors(s,o);i.lengthSq()||(Math.abs(s.z)<.9?o.set(0,0,1):o.set(1,0,0),i.crossVectors(s,o)),i.normalize();const a=new f().crossVectors(i,s);a.lengthSq()||a.copy(o.lengthSq()?o:new f(0,1,0)),a.normalize();const c=s.clone().normalize();return{right:i,up:a,forward:c}}m(He,"computeViewBasis$1");function On(e,t,n){try{const s=e.clone().sub(t||new f);if(s.lengthSq()>1e-10)return s.normalize()}catch{}const r=n?.right?.clone?.()||new f(1,0,0);return r.lengthSq()||r.set(1,0,0),r.normalize()}m(On,"computeShoulderDirection");function _n(e,t,n){if(!e.length)return[];const r=t?.up&&t.up.lengthSq()?t.up:new f(0,1,0),s=e.map((o,i)=>{const c=o.clone().sub(n||new f).dot(r);return{point:o,metric:c,index:i}});return s.sort((o,i)=>o.metric-i.metric),s.map((o,i)=>({point:o.point,order:i}))}m(_n,"sortTargetsByViewUp");function Cn(e){if(!e||typeof e!="object")return null;const t=Bn(e);if(!t)return null;const n=new f(0,0,-1).applyQuaternion(t);if(!n.lengthSq())return null;const r=new f(0,1,0).applyQuaternion(t);let s=new f().crossVectors(n,r);s.lengthSq()||(s=new f().crossVectors(n,new f(0,1,0))),s.lengthSq()||s.set(1,0,0),s.normalize();const o=new f().crossVectors(s,n);o.lengthSq()||o.copy(r.lengthSq()?r:new f(0,1,0)),o.normalize();const i=n.clone().normalize();return{right:s,up:o,forward:i}}m(Cn,"basisFromSavedCamera");function Bn(e){const t=e?.quaternion||e?.camera?.quaternion;if(Array.isArray(t)&&t.length>=4){const[s,o,i,a]=t;if([s,o,i,a].every(c=>Number.isFinite(c)))return new V(s,o,i,a).normalize()}if(t&&typeof t=="object"){const s=Number(t.x),o=Number(t.y),i=Number(t.z),a=Number(t.w);if([s,o,i,a].every(c=>Number.isFinite(c)))return new V(s,o,i,a).normalize()}const n=e?.worldMatrix||e?.cameraMatrix||e?.matrix,r=Array.isArray(n?.elements)?n.elements:n;if(Array.isArray(r)&&r.length===16){const s=new me().fromArray(r),o=new f,i=new V,a=new f;return s.decompose(o,i,a),i.normalize()}return null}m(Bn,"quaternionFromSnapshot");function jn(e){if(!e&&e!==0)return null;if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3){const[t,n,r]=e;return[t,n,r].some(s=>typeof s!="number"||!Number.isFinite(s))?null:new f(t,n,r)}if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),r=Number(e.z);if([t,n,r].every(s=>Number.isFinite(s)))return new f(t,n,r)}return null}m(jn,"vectorFromAny");function ke(e){if(!e||!e.length)return null;const t=new f;return e.forEach(n=>t.add(n)),t.multiplyScalar(1/e.length)}m(ke,"averageTargets");const In={id:{type:"string",default_value:null,hint:"unique identifier for the note"},text:{type:"string",default_value:"",defaultResolver:m(({pmimode:e})=>{const t=e?._opts?.noteText;return typeof t=="string"?t:void 0},"defaultResolver"),hint:"Note text content"},position:{type:"object",default_value:null,hint:"3D position of the note marker"}},k=class k extends v{static showContexButton(t){const n=v._normalizeSelectionItems(t);if(!n.length)return!1;const r=n[0],s=E(null,r);return s?{params:{position:{x:s.x,y:s.y,z:s.z}}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams,a=Je(),c=new f(i.position?.x||0,i.position?.y||0,i.position?.z||0),l=new Gt(a.noteDotRadius??.08,16,12),u=new Qt({color:a.noteDotColor??a.dotColor??9684477,depthTest:!1,depthWrite:!1,transparent:!0}),p=new Yt(l,u);p.position.copy(c),r.add(p);const d=String(i.text||"");if(!d)return[];let h=null;if(i.labelWorld)h=new f(i.labelWorld.x,i.labelWorld.y,i.labelWorld.z);else{const g=o.alignNormal("view",i),b=new f,y=new f(0,1,0);try{n.viewer?.camera?.getWorldDirection?.(b),b.crossVectors(g,y).normalize()}catch{b.set(1,0,0)}const N=o.screenSizeWorld(16);h=c.clone().addScaledVector(b,N).addScaledVector(g,N*.25)}return o.updateLabel(s,d,h,i),[]}static getSchema(t,n){const r={text:{type:"string",label:"Text",default_value:n.text||""}},s={text:r.text.default_value};return{schema:r,params:s}}static applyParams(t,n,r){return super.applyParams(t,n,r),n.text=$n(n.text),{paramsPatch:{}}}static onLabelPointerDown(t,n,r,s,o){try{if(!t.viewer?.camera)return;const c=o.alignNormal?o.alignNormal(r.alignment||"view",r):new f(0,0,1),l=r.labelWorld?new f(r.labelWorld.x,r.labelWorld.y,r.labelWorld.z):new f(r.position?.x||0,r.position?.y||0,r.position?.z||0),u=new I().setFromNormalAndCoplanarPoint(c,l);k.dragLabelOnPlane(t,o,{makePlane:m(()=>u,"makePlane"),onDrag:m(p=>{r.labelWorld={x:p.x,y:p.y,z:p.z};try{o.updateLabel(n,null,p,r)}catch{}},"onDrag"),onEnd:m(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};m(k,"NoteAnnotation"),P(k,"entityType","note"),P(k,"type","note"),P(k,"shortName","NOTE"),P(k,"longName","Note"),P(k,"title","Note"),P(k,"inputParamsSchema",In);let Ge=k;function $n(e){return typeof e=="string"?e:e==null?"":String(e)}m($n,"sanitizeText");const Un={id:{type:"string",default_value:null,hint:"unique identifier for the view transform"},targets:{type:"reference_selection",multiple:!0,default_value:[],label:"Target Objects",selectionFilter:["SOLID","COMPONENT"],hint:"Choose the solids or components to reposition in this view"},transform:{type:"transform",label:"Transform",hint:"Translation and rotation applied relative to the reference point"},showTraceLine:{type:"boolean",default_value:!0,label:"Show trace lines",hint:"Draw a line from the original position to the transformed position"}},W=class W extends v{static showContexButton(t){const n=v._collectSelectionRefs(t,["SOLID","COMPONENT"]);return n.length?{params:{targets:n}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:r}=t;if(!n||!r)return[];const s=this.inputParams||{};xt(s),s.transform=Le(s.transform);const o=W._resolveSolidReferences(s,n,!0);if(!o.length)return[];const i=W._ensureOriginalSnapshots(s,o,!1,n?.viewer),a=s.showTraceLine!==!1;let c=n?.__explodeTraceState;c instanceof Map||(c=new Map,n&&(n.__explodeTraceState=c));const l=O(s.transform.position,new f(0,0,0)),u=Dt(s.transform.rotationEuler),p=O(s.transform.scale,new f(1,1,1));return o.forEach(d=>{try{const h=i.get(d.uuid),g=O(h?.centerLocal)||_t(d),b=c?.get(d.uuid)?.clone()||Qn(h),y=zt(b,g)||O(h?.centerWorld)||O(h?.worldPosition),N=Yn(b,l,u,p),A=zt(N,g)||Gn(d);Tt(y)&&Tt(A)&&y.distanceToSquared(A)>=1e-8&&a&&r.add(Kt(y,A,16098596,{viewer:n?.viewer})),c?.set(d.uuid,N)}catch{}}),[]}static _resolveSolidReferences(t,n,r=!1){if(!t||!n)return[];const s=n.viewer,o=s?.partHistory?.scene||s?.scene;if(!o)return[];if(!r&&Array.isArray(t.__resolvedSolids)&&t.__resolvedSolids.length){const c=t.__resolvedSolids.filter(l=>l&&l.isObject3D);return ae(t,"__resolvedSolids",c),ae(t,"solids",c),c}const i=Array.isArray(t.targets)?t.targets:[],a=[];return i.forEach(c=>{const l=Hn(c,o);l&&l.isObject3D&&a.push(l)}),ae(t,"__resolvedSolids",a),ae(t,"solids",a),a}static _ensureOriginalSnapshots(t,n,r=!1,s=null){xt(t);let o=t.__originalSnapshots;return o instanceof Map||(o=At(t.persistentData?.originalTransforms)),o instanceof Map||(o=new Map),(Array.isArray(n)?n:[]).forEach(a=>{!a||!a.uuid||(r||!o.has(a.uuid))&&o.set(a.uuid,Nt(a,s))}),ae(t,"__originalSnapshots",o),t.persistentData.originalTransforms=kn(o),o}static getOriginalSnapshotMap(t){if(!t)return new Map;if(t.__originalSnapshots instanceof Map)return t.__originalSnapshots;const n=At(t?.persistentData?.originalTransforms);return ae(t,"__originalSnapshots",n instanceof Map?n:new Map),t.__originalSnapshots}static applyTransformsToSolids(t,n,r={}){if(!t||!n)return;const s=W._resolveSolidReferences(t,n,!0);if(!s.length)return;const o=r&&r.startSnapshots instanceof Map?r.startSnapshots:W.getOriginalSnapshotMap(t),i=r?.cumulativeState instanceof Map?r.cumulativeState:null,a=Le(t.transform);t.transform=a;const c=O(a.position,new f(0,0,0)),l=Dt(a.rotationEuler),u=O(a.scale,new f(1,1,1));s.forEach(p=>{if(!p||!p.uuid)return;const d=o.get(p.uuid)||W.getOriginalSnapshotMap(t).get(p.uuid)||Nt(p,n?.viewer);if(!d)return;const h=O(d.position,new f(0,0,0)),g=Ye(d.quaternion,new V),b=O(d.scale,new f(1,1,1)),y=h.clone().add(c),N=g.clone().multiply(l),A=b.clone().multiply(u);if(p.position.copy(y),p.quaternion.copy(N),p.scale.copy(A),p.updateMatrixWorld(!0),i){const x=p.getWorldPosition(new f);i.set(p.uuid,{position:y.toArray(),quaternion:N.toArray(),scale:A.toArray(),worldPosition:x.toArray()})}})}static restoreOriginalTransforms(t,n){if(!t||!n)return;const r=W._resolveSolidReferences(t,n,!0);if(!r.length)return;const s=W.getOriginalSnapshotMap(t);r.forEach(o=>{if(!o||!o.uuid)return;const i=s.get(o.uuid);if(!i)return;const a=O(i.position,new f(0,0,0)),c=Ye(i.quaternion,new V),l=O(i.scale,new f(1,1,1));o.position.copy(a),o.quaternion.copy(c),o.scale.copy(l),o.updateMatrixWorld(!0)})}static applyParams(t,n,r){super.applyParams(t,n,r),n.targets=Xn(n.targets),n.transform=Le(n.transform),n.showTraceLine=n.showTraceLine!==!1;try{t&&typeof t.applyViewTransformsSequential=="function"&&t.applyViewTransformsSequential()}catch{}return{paramsPatch:{}}}};m(W,"ExplodeBodyAnnotation"),P(W,"entityType","exp"),P(W,"type","exp"),P(W,"shortName","EXP"),P(W,"longName","Explode Body"),P(W,"title","Explode Body"),P(W,"inputParamsSchema",Un),P(W,"aliases",["viewTransform"]);let Qe=W;function xt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(xt,"ensurePersistent");function ae(e,t,n){if(!(!e||typeof e!="object"))try{Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!1,writable:!0})}catch{e[t]=n}}m(ae,"setHiddenProperty");function Le(e){const t=e&&typeof e=="object"?e:{},n=m((r,s)=>{if(!Array.isArray(r))return s.slice();const o=s.slice();for(let i=0;i<o.length;i+=1){const a=Number(r[i]);o[i]=Number.isFinite(a)?a:o[i]}return o},"sanitizeArray");return{position:n(t.position,[0,0,0]),rotationEuler:n(t.rotationEuler,[0,0,0]),scale:n(t.scale,[1,1,1])}}m(Le,"sanitizeTransform");function Xn(e){return Array.isArray(e)?e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length):[]}m(Xn,"arrayOfStrings");function Hn(e,t){if(!t||!e&&e!==0)return null;let n=null;if(typeof e=="string"&&e.trim().length){const s=e.trim();if(s[0]==="{")try{n=JSON.parse(s)}catch{n={name:s}}else n={name:s}}else typeof e=="object"&&(n={...e});if(!n)return null;const r=[];n.name&&typeof n.name=="string"&&r.push(n.name.trim()),Array.isArray(n.path)&&n.path.length&&r.push(String(n.path[n.path.length-1]));for(const s of r){if(!s)continue;const o=t.getObjectByName(s);if(o&&o.type==="SOLID"||o)return o}if(typeof n.uuid=="string"){const s=t.getObjectByProperty("uuid",n.uuid);if(s)return s;const o=Pt(t,i=>i?.userData?.__pmiExportSourceUuid===n.uuid);if(o)return o}if(Number.isInteger(n.id)){try{const o=t.getObjectById(n.id);if(o)return o}catch{}const s=Pt(t,o=>o?.userData?.__pmiExportSourceId===n.id);if(s)return s}return null}m(Hn,"resolveSolidObject");function Pt(e,t){if(!e?.traverse||typeof t!="function")return null;let n=null;return e.traverse(r=>{if(!(n||!r?.isObject3D))try{t(r)&&(n=r)}catch{}}),n}m(Pt,"findExportCloneMatch");function Nt(e,t=null){try{e.updateMatrixWorld(!0)}catch{}const n=e.position.clone(),r=e.quaternion.clone(),s=e.scale.clone(),o=e.getWorldPosition(new f),i=_t(e),a=i.clone().applyMatrix4(new me().compose(n.clone(),r.clone(),s.clone()));return{position:n.toArray(),quaternion:r.toArray(),scale:s.toArray(),worldPosition:o.toArray(),centerWorld:a.toArray(),centerLocal:i.toArray()}}m(Nt,"captureSnapshot");function At(e){if(!Array.isArray(e))return new Map;const t=new Map;return e.forEach(n=>{!n||typeof n!="object"||!n.uuid||t.set(n.uuid,{position:j(n.position,[0,0,0]),quaternion:j(n.quaternion,[0,0,0,1]),scale:j(n.scale,[1,1,1]),worldPosition:j(n.worldPosition,null),centerWorld:j(n.centerWorld,null),centerLocal:j(n.centerLocal,null)})}),t}m(At,"snapshotArrayToMap");function kn(e){if(!(e instanceof Map))return[];const t=[];return e.forEach((n,r)=>{r&&t.push({uuid:r,position:j(n.position,[0,0,0]),quaternion:j(n.quaternion,[0,0,0,1]),scale:j(n.scale,[1,1,1]),worldPosition:j(n.worldPosition,null),centerWorld:j(n.centerWorld,null),centerLocal:j(n.centerLocal,null)})}),t}m(kn,"snapshotMapToArray");function j(e,t){if(Array.isArray(e))return e.slice();if(e&&typeof e=="object"&&typeof e.length=="number"){const n=[];for(let r=0;r<e.length;r+=1)n.push(Number(e[r]));return n}return e&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"?typeof e.w=="number"?[e.x,e.y,e.z,e.w]:[e.x,e.y,e.z]:t&&t.slice()}m(j,"toArray");function O(e,t){if(e instanceof f)return e.clone();if(Array.isArray(e)&&e.length>=3){const n=Number(e[0]),r=Number(e[1]),s=Number(e[2]);if([n,r,s].every(o=>Number.isFinite(o)))return new f(n,r,s)}return e&&typeof e=="object"&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)?new f(e.x,e.y,e.z):t&&t.isVector3?t.clone():new f}m(O,"vectorFromArray");function Ye(e,t){if(Array.isArray(e)&&e.length>=4){const n=Number(e[0]),r=Number(e[1]),s=Number(e[2]),o=Number(e[3]);if([n,r,s,o].every(i=>Number.isFinite(i)))return new V(n,r,s,o)}return e&&typeof e=="object"&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)&&Number.isFinite(e.w)?new V(e.x,e.y,e.z,e.w):t&&t.isQuaternion?t.clone():new V}m(Ye,"quaternionFromArray");function Dt(e){const t=Array.isArray(e)?e:[0,0,0],n=Number(t[0])||0,r=Number(t[1])||0,s=Number(t[2])||0;try{return new V().setFromEuler(new Zt(Pe.degToRad(n),Pe.degToRad(r),Pe.degToRad(s),"XYZ"))}catch{return new V}}m(Dt,"quaternionFromEuler");function _t(e){try{if(!e)return new f;e.updateMatrixWorld?.(!0);const t=new vt().setFromObject(e);if(!t.isEmpty()){const r=t.getCenter(new f).clone();return e.worldToLocal(r),r}}catch{}return new f}m(_t,"getSolidLocalCenter");function Gn(e){try{if(!e)return new f;e.updateMatrixWorld?.(!0);const t=new vt().setFromObject(e);if(!t.isEmpty())return t.getCenter(new f)}catch{}try{return e.getWorldPosition(new f)}catch{return new f}}m(Gn,"getSolidWorldCenter");function Tt(e){return!e||!e.isVector3?!1:Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}m(Tt,"isFiniteVec3");function Qn(e){if(!e||typeof e!="object")return de(new f,new V,new f(1,1,1));const t=O(e.position,new f),n=Ye(e.quaternion,new V),r=O(e.scale,new f(1,1,1));return de(t,n,r)}m(Qn,"transformEntryFromSnapshot");function Yn(e,t,n,r){const s=e||de(new f,new V,new f(1,1,1)),o=s.position.clone().add(t||new f),i=s.quaternion.clone().multiply(n||new V),a=s.scale.clone().multiply(r||new f(1,1,1));return de(o,i,a)}m(Yn,"composeTransformEntry");function zt(e,t){if(!e||!t||!t.isVector3)return null;const n=new me().compose(e.position.clone(),e.quaternion.clone(),e.scale.clone());return t.clone().applyMatrix4(n)}m(zt,"applyTransformEntryToPoint");function de(e,t,n){return{position:e.clone(),quaternion:t.clone(),scale:n.clone(),clone(){return de(this.position,this.quaternion,this.scale)}}}m(de,"makeTransformEntry");const Zn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the hole callout"},target:{type:"reference_selection",selectionFilter:["VERTEX","EDGE","FACE"],multiple:!1,default_value:"",label:"Target",hint:"Pick the hole edge/vertex/face to call out"},quantity:{type:"number",default_value:0,label:"Quantity",hint:"Number of identical holes this callout represents (0 = auto from feature)",min:0},showQuantity:{type:"boolean",default_value:!0,label:"Show Quantity",hint:"Include the hole count in the callout label"},beforeText:{type:"string",default_value:"",label:"Text Before",hint:"Optional text to show before the callout"},afterText:{type:"string",default_value:"",label:"Text After",hint:"Optional text to show after the callout"},anchorPosition:{type:"options",default_value:"Right Top",options:["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"],label:"Anchor Position",hint:"Preferred label alignment relative to anchor"}},G=class G extends v{static showContexButton(t){const n=v._normalizeSelectionItems(t),r=new Set(["VERTEX","EDGE","FACE"]);for(const s of n){if(!v._isSelectionType(s,r)||!er(s))continue;const o=v._selectionRefName(s);if(o)return{params:{target:o}}}return!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:r,idx:s,ctx:o}=t,i=this.inputParams||{},a=n?.viewer,c=a?.partHistory?.scene,l=Mt(a,i.target),u=E(c,l),p=Kn(a?.partHistory,l,u,i.target),d=p?.center?Ne(p.center):u;if(!d)return[];const h=ar(i,p,a?.partHistory),g=p?tr(p,h,{showQuantity:i.showQuantity!==!1,beforeText:i.beforeText,afterText:i.afterText}):"";i.value=g;const b=Et(a),y=o?.screenSizeWorld?o.screenSizeWorld(80):q(a,80),N=o?.screenSizeWorld?o.screenSizeWorld(30):q(a,30),x=Ne(i?.persistentData?.labelWorld)||d.clone().addScaledVector(b.right,nr(i.anchorPosition||"Right Top")*y).addScaledVector(b.up,rr(i.anchorPosition||"Right Top")*N);o?.updateLabel&&o.updateLabel(s,g,x,i);const D=Je(),w=D.lineColor??16771584;r.add(Y(x,d,w));const S=D.arrowLengthPx??12,z=D.arrowWidthPx??4,M=o?.screenSizeWorld?o.screenSizeWorld(S):q(a,S),T=o?.screenSizeWorld?o.screenSizeWorld(z):q(a,z),F=d.clone().sub(x);return F.lengthSq()>1e-12&&(F.normalize(),ne(r,d,F,M,T,D.arrowColor??w)),[]}static applyParams(t,n,r){super.applyParams(t,n,r);const s=Number(n?.quantity);return n.quantity=Number.isFinite(s)?Math.max(0,Math.round(s)):1,n.showQuantity=n.showQuantity!==!1,n.beforeText=ze(n.beforeText),n.afterText=ze(n.afterText),n.anchorPosition=or(n.anchorPosition),{paramsPatch:{}}}static onLabelPointerDown(t,n,r,s,o){const i=t?.viewer,a=Mt(i,r.target),c=i?.partHistory?.scene,l=E(c,a)||Ne(r?.persistentData?.labelWorld);if(!l)return;const p=Et(i).forward;if(!o?.raycastFromEvent)return;const d=new I().setFromNormalAndCoplanarPoint(p,l);G.dragLabelOnPlane(t,o,{makePlane:m(()=>d,"makePlane"),suspendControls:!0,onDrag:m(h=>{ir(r),r.persistentData.labelWorld=[h.x,h.y,h.z],o.updateLabel(n,null,h,r),t?.refreshAnnotationsUI?.()},"onDrag")})}};m(G,"HoleCalloutAnnotation"),P(G,"entityType","holeCallout"),P(G,"type","holeCallout"),P(G,"shortName","HOLE"),P(G,"longName","Hole Callout"),P(G,"title","Hole Callout"),P(G,"inputParamsSchema",Zn);let Ze=G;function Mt(e,t){if(!e||!t)return null;const n=e.partHistory?.scene;if(!n)return null;if(typeof t=="string"){const r=n.getObjectByName?.(t);if(r)return r;const s=Ae(t);for(const i of s){const a=n.getObjectByName?.(i);if(a)return a}let o=null;try{n.traverse(i=>{if(o)return;const a=i?.name?String(i.name):"";if(a){for(const c of s)if(c&&(a===c||a.endsWith(c)||a.includes(c))){o=i;return}}})}catch{}if(o)return o}return typeof t=="object"?t:n.getObjectByName?.(String(t))||null}m(Mt,"resolveTargetObject");function Kn(e,t,n,r=null){const s=Array.isArray(e?.features)?e.features:[],o=[];for(const u of s){const p=Array.isArray(u?.persistentData?.holes)?u.persistentData.holes:[];for(const d of p)o.push(d)}if(!o.length)return null;const i=t?.userData?.hole||t?.userData?.metadata?.hole;if(i)return i;if(t?.parent){const u=t.parent.userData?.hole||t.parent.userData?.metadata?.hole;if(u)return u}const a=t?.uuid||t?.id||t?.name||null,c=Ae(r,a);if(t?.name)for(const u of Ae(t.name))c.add(u);const l=o.filter(u=>{const p=u?.sourceName?String(u.sourceName):null,d=u?.featureId?String(u.featureId):null,h=u?.targetId?String(u.targetId):null;return p&&c.has(p)||d&&c.has(d)||h&&c.has(h)});if(l.length===1)return l[0];if(l.length>1&&n){const u=ee(l,n);if(u)return u}if(a){const u=o.filter(p=>p?.targetId&&String(p.targetId)===String(a));if(u.length===1)return u[0];if(u.length>1&&n){const p=ee(u,n);if(p)return p}}if(r){const u=String(r),p=o.filter(d=>{const h=d?.featureId?String(d.featureId):"",g=d?.sourceName?String(d.sourceName):"";return h&&u.includes(h)||g&&u.includes(g)});if(p.length===1)return p[0];if(p.length>1&&n){const d=ee(p,n);if(d)return d}}if(c.size){const u=o.filter(p=>{const d=p?.featureId?String(p.featureId):"",h=p?.sourceName?String(p.sourceName):"",g=p?.targetId?String(p.targetId):"";return c.has(d)||c.has(h)||c.has(g)});if(u.length===1)return u[0];if(u.length>1&&n){const p=ee(u,n);if(p)return p}}if(n){const u=ee(o,n);if(u)return u}if(t?.parent){const u=Ae(t.parent.name),p=o.filter(d=>{const h=d?.featureId?String(d.featureId):"",g=d?.sourceName?String(d.sourceName):"",b=d?.targetId?String(d.targetId):"";return u.has(h)||u.has(g)||u.has(b)});if(p.length===1)return p[0];if(p.length>1&&n){const d=ee(p,n);if(d)return d}}if(n){const u=ee(o,n);if(u)return u}return o[0]}m(Kn,"findHoleDescriptor");function Jn(e){if(!e)return null;const t=e.userData||null;if(t?.hole)return t.hole;if(t?.metadata?.hole)return t.metadata.hole;if(typeof e.getMetadata=="function")try{const s=e.getMetadata();if(s?.hole)return s.hole;if(s?.metadata?.hole)return s.metadata.hole}catch{}const n=e?.name||t?.faceName||null,r=e?.parentSolid||t?.parentSolid||null;if(n&&r&&typeof r.getFaceMetadata=="function")try{const s=r.getFaceMetadata(n);if(s?.hole)return s.hole}catch{}return null}m(Jn,"readHoleMetadata");function er(e){if(!e)return!1;const t=[e],n=new Set,r=m(s=>Object.prototype.hasOwnProperty.call(s,"faces"),"hasOwnFaces");for(;t.length;){const s=t.shift();if(!(!s||n.has(s))){if(n.add(s),Jn(s))return!0;if(r(s)&&Array.isArray(s.faces))for(const o of s.faces)t.push(o);else if(s.type==="SOLID"||s.type==="COMPONENT"){const o=Array.isArray(s.children)?s.children:[];for(const i of o)i&&i.type==="FACE"&&t.push(i)}s.parent&&t.push(s.parent)}}return!1}m(er,"hasHoleMetadata");function tr(e,t=1,n={}){if(!e)return"";const r=[],s=ze(n.beforeText);s&&r.push(s);const i=n.showQuantity!==!1&&t>1?`${t}× `:"",a=Number(e.totalDepth??e.straightDepth),c=!e.throughAll&&a>0?` ↧ ${le(a)}`:e.throughAll?" THRU ALL":"";r.push(`${i}⌀${le(e.diameter)}${c}`),e.type==="COUNTERSINK"?r.push(`⌵ ⌀${le(e.countersinkDiameter)} × ${le(e.countersinkAngle,0)}°`):e.type==="COUNTERBORE"&&r.push(`⌴ ⌀${le(e.counterboreDiameter)} ↧ ${le(e.counterboreDepth)}`);const l=sr(e?.thread);l&&r.push(l);const u=ze(n.afterText);return u&&r.push(u),r.join(`
|
|
2
2
|
`)}m(tr,"formatHoleCallout");function Et(e){const t=e?.camera,n=new f;t?.getWorldDirection?t.getWorldDirection(n):n.set(0,0,-1),n.normalize();const r=t?.up?t.up.clone():new f(0,1,0),s=new f().crossVectors(n,r).normalize(),o=new f().crossVectors(s,n).normalize();return{forward:n,right:s,up:o}}m(Et,"computeViewBasis");function nr(e){return String(e).startsWith("Left")?-1:1}m(nr,"anchorSign");function rr(e){return e.includes("Bottom")?-1:e.includes("Middle")?0:1}m(rr,"anchorVertical");function or(e){return new Set(["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"]).has(e)?e:"Right Top"}m(or,"normalizeAnchorPosition");function le(e,t=2){const n=Number(e);return Number.isFinite(n)?n.toFixed(t):""}m(le,"fmt");function sr(e){if(!e||!e.designation)return"";let t=String(e.designation).replace(/\s+/g,"").toUpperCase();const n=e.series?String(e.series).toUpperCase():"";return n&&!t.includes(n)&&(t+=n),`THREAD ${t}`}m(sr,"formatThreadLine");function Ne(e){if(!Array.isArray(e)||e.length<3)return null;const[t,n,r]=e;return[t,n,r].every(s=>Number.isFinite(Number(s)))?new f(Number(t),Number(n),Number(r)):null}m(Ne,"arrToVec");function ir(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}m(ir,"ensurePersistentData");function ze(e){if(e==null)return"";const t=String(e).trim();return t.length?t:""}m(ze,"normalizeAddonText");function Ae(e,t=null){const n=new Set,r=m(s=>{if(s==null)return;const o=String(s);if(!o)return;n.add(o);const i=o.match(/\[(.*?)\]/);if(i&&i[1]){const c=i[1];n.add(c);const l=c.replace(/_AXIS_\d+$/,"");l&&l!==c&&n.add(l)}const a=o.replace(/_AXIS_\d+$/,"");a&&a!==o&&n.add(a)},"push");return r(e),r(t),n}m(Ae,"normalizeTargetTokens");function ee(e,t){if(!Array.isArray(e)||!e.length||!t)return null;let n=null,r=1/0;for(const s of e){const o=Ne(s?.center);if(!o)continue;const i=o.distanceToSquared(t);i<r&&(r=i,n=s)}return n}m(ee,"nearestDescriptor");function ar(e,t,n){const r=Number(e?.quantity),s=Number.isFinite(r)?Math.round(r):1;if(s>0)return s;const o=lr(n,t);return Number.isFinite(o)&&o>0?o:1}m(ar,"resolveHoleQuantity");function lr(e,t){if(!e||!t)return null;const n=Array.isArray(e.features)?e.features:[],r=t.featureId||null;let s=null;for(const o of n){const i=Array.isArray(o?.persistentData?.holes)?o.persistentData.holes:[];if(!i.length)continue;if(i.includes(t))return i.length;const a=cr(o);r&&a&&String(a)===String(r)&&(s=i.length)}return s}m(lr,"countFeatureHoles");function cr(e){if(!e||typeof e!="object")return null;const t=e.inputParams||{};return e.id??t.id??t.featureID??null}m(cr,"resolveFeatureId");const We=m(e=>!e&&e!==0?"":String(e).trim().toLowerCase(),"normalizeKey"),rt=class rt{constructor(){this._map=new Map,this._aliases=new Map}register(t){if(!t)return;if(typeof t=="function"){const r=t;r.shortName||(r.shortName=r.featureShortName||r.name||r.type||"ANN"),r.longName||(r.longName=r.featureName||r.name||r.shortName||r.type||"Annotation"),typeof r.showContexButton!="function"&&(r.showContexButton=()=>!1)}const n=We(t.type||t.shortName||t.featureShortName||t.name||t.longName||t.featureName);if(n&&(this._map.set(n,t),Array.isArray(t.aliases)))for(const r of t.aliases){const s=We(r);s&&this._aliases.set(s,t)}}get(t){const n=We(t);if(!n)throw new Error("Annotation type must be a non-empty string");const r=this._map.get(n)||this._aliases.get(n);if(!r)throw new Error(`Annotation type "${t}" is not registered.`);return r}getSafe(t){try{return this.get(t)}catch{return null}}has(t){return!!this.getSafe(t)}list(){return Array.from(this._map.values())}};m(rt,"AnnotationRegistry");let Ke=rt;const re=new Ke;re.register(Ce);re.register(je);re.register(Ue);re.register(Xe);re.register(Ge);re.register(Qe);re.register(Ze);export{sn as a,an as b,re as c,De as d,rn as i,et as p,Ft as r,Oe as t};
|