brep-io-kernel 1.0.275 → 1.0.276

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.
Files changed (39) hide show
  1. package/dist/apiExamples/BREP_Booleans.html +2 -2
  2. package/dist/apiExamples/BREP_Export.html +2 -2
  3. package/dist/apiExamples/BREP_Primitives.html +2 -2
  4. package/dist/apiExamples/BREP_Transforms.html +2 -2
  5. package/dist/apiExamples/Embeded_2D_Sketcher.html +2 -2
  6. package/dist/apiExamples/Embeded_CAD.html +2 -2
  7. package/dist/apiExamples/Embeded_CAD_Integration_Test.html +2 -2
  8. package/dist/assembly-constraint-capture.html +5 -5
  9. package/dist/assets/{AnnotationRegistry-D4Wu78S5.js → AnnotationRegistry-DmCAaMWU.js} +1 -1
  10. package/dist/assets/{AssemblyConstraintRegistry-Dv9m5HQZ.js → AssemblyConstraintRegistry-CMGYi26o.js} +1 -1
  11. package/dist/assets/{FeatureRegistry-BiMzIqqI.js → FeatureRegistry-CtngJUEe.js} +3 -3
  12. package/dist/assets/{PartHistory-oDnLIAaB.js → PartHistory-C7IhfKVf.js} +1 -1
  13. package/dist/assets/{annUtils-BrwNyUEy.js → annUtils-DGfVy9U3.js} +1 -1
  14. package/dist/assets/{apiExample_BREP_Booleans-BwiMtDIS.js → apiExample_BREP_Booleans-DyTcZZ5m.js} +1 -1
  15. package/dist/assets/{apiExample_BREP_Export-BU6JEsXr.js → apiExample_BREP_Export-CHV-v_5k.js} +1 -1
  16. package/dist/assets/{apiExample_BREP_Primitives-LgL-6abq.js → apiExample_BREP_Primitives-DvNqBEVv.js} +1 -1
  17. package/dist/assets/{apiExample_BREP_Transforms-t9BF6JOw.js → apiExample_BREP_Transforms-DzINm9Jd.js} +1 -1
  18. package/dist/assets/{apiExample_Embeded_2D_Sketcher-ChBmbcOk.js → apiExample_Embeded_2D_Sketcher-DNTtuz8d.js} +1 -1
  19. package/dist/assets/{apiExample_Embeded_CAD-wxO1n_Eq.js → apiExample_Embeded_CAD-BnQhzp-z.js} +1 -1
  20. package/dist/assets/{apiExample_Embeded_CAD_Integration_Test-CxQJRkqD.js → apiExample_Embeded_CAD_Integration_Test-CV2Ykzja.js} +1 -1
  21. package/dist/assets/{assemblyConstraintDialogs-CH_Gbz82.js → assemblyConstraintDialogs-C2rw8l6x.js} +1 -1
  22. package/dist/assets/{brep-kernel-xxpt9ldE.js → brep-kernel-UtrTyG6Q.js} +1 -1
  23. package/dist/assets/{browserTests-CRiysi-p.js → browserTests-Cyi6X6Cb.js} +3 -3
  24. package/dist/assets/{dialogCapturePageFactory-DjJjYM48.js → dialogCapturePageFactory-DVhrYqMv.js} +1 -1
  25. package/dist/assets/{featureDialogs-Chs09ZCV.js → featureDialogs-DkPbRjYq.js} +1 -1
  26. package/dist/assets/{featureDialogs-91F4s17y.js → featureDialogs-E0PjzXk0.js} +1 -1
  27. package/dist/assets/{index.es-xZ7picbN.js → index.es-CGVK-qun.js} +1 -1
  28. package/dist/assets/{javascript-lY5XZvCd.js → javascript-DpdHQnSD.js} +1 -1
  29. package/dist/assets/{main-cad-CPA3rCIJ.js → main-cad-Cc83gQHn.js} +6 -6
  30. package/dist/assets/{pmiDialogs-BTJYTb0b.js → pmiDialogs-D5R54K47.js} +1 -1
  31. package/dist/assets/{test-CN0ogjpZ.js → test-CEMdQ45d.js} +3 -3
  32. package/dist/cad.html +7 -7
  33. package/dist/feature-dialog-capture.html +4 -4
  34. package/dist/pmi-dialog-capture.html +5 -5
  35. package/dist/test.html +1 -1
  36. package/dist/viewer.html +7 -7
  37. package/dist-kernel/brep-kernel.js +48 -5
  38. package/package.json +1 -1
  39. package/src/UI/FloatingWindow.js +72 -0
@@ -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-BwiMtDIS.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Booleans-DyTcZZ5m.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-xxpt9ldE.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-UtrTyG6Q.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-BU6JEsXr.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Export-CHV-v_5k.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-xxpt9ldE.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-UtrTyG6Q.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-LgL-6abq.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Primitives-DvNqBEVv.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-xxpt9ldE.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-UtrTyG6Q.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-t9BF6JOw.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_BREP_Transforms-DzINm9Jd.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-xxpt9ldE.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-UtrTyG6Q.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-ChBmbcOk.js"></script>
8
+ <script type="module" crossorigin src="/assets/apiExample_Embeded_2D_Sketcher-DNTtuz8d.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-xxpt9ldE.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-UtrTyG6Q.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-wxO1n_Eq.js"></script>
34
+ <script type="module" crossorigin src="/assets/apiExample_Embeded_CAD-BnQhzp-z.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-xxpt9ldE.js">
37
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-UtrTyG6Q.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-CxQJRkqD.js"></script>
95
+ <script type="module" crossorigin src="/assets/apiExample_Embeded_CAD_Integration_Test-CV2Ykzja.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-xxpt9ldE.js">
98
+ <link rel="modulepreload" crossorigin href="/assets/brep-kernel-UtrTyG6Q.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-CH_Gbz82.js"></script>
16
+ <script type="module" crossorigin src="/assets/assemblyConstraintDialogs-C2rw8l6x.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-Chs09ZCV.js">
21
- <link rel="modulepreload" crossorigin href="/assets/annUtils-BrwNyUEy.js">
22
- <link rel="modulepreload" crossorigin href="/assets/AssemblyConstraintRegistry-Dv9m5HQZ.js">
23
- <link rel="modulepreload" crossorigin href="/assets/dialogCapturePageFactory-DjJjYM48.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/featureDialogs-DkPbRjYq.js">
21
+ <link rel="modulepreload" crossorigin href="/assets/annUtils-DGfVy9U3.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/AssemblyConstraintRegistry-CMGYi26o.js">
23
+ <link rel="modulepreload" crossorigin href="/assets/dialogCapturePageFactory-DVhrYqMv.js">
24
24
  </head>
25
25
  <body>
26
26
  <div id="app"></div>
@@ -1,2 +1,2 @@
1
- var yt=Object.defineProperty;var on=(e,t,n)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var d=(e,t)=>yt(e,"name",{value:t,configurable:!0});var A=(e,t,n)=>on(e,typeof t!="symbol"?t+"":t,n);import{L as sn}from"./ListEntityBase-DIaWtqmZ.js";import{a6 as B,V as p,a as C,M as pe,B as qe,b as Ee,Q as V,u as an,s as ln,f as cn,af as un}from"./featureDialogs-Chs09ZCV.js";import{b as L,i as Y,d as oe,o as v,c as ie,m as Oe,g as st,j as fn}from"./annUtils-BrwNyUEy.js";const I=class I extends sn{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(I._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 o=I._normalizeSelectionItems(t),i=Array.isArray(n)?new Set(n.map(s=>I._normalizeSelectionType(s))):null,r=[];for(const s of o){if(!I._isSelectionType(s,i))continue;const a=I._selectionRefName(s);a&&r.push(a)}return r}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 o={},i={},r=n||{};for(const s in this.inputParamsSchema){if(!Object.prototype.hasOwnProperty.call(this.inputParamsSchema,s))continue;const a=this.inputParamsSchema[s]||{},l={...a},c=Object.prototype.hasOwnProperty.call(r,s)?U(r[s]):U(a.default_value);l&&Object.prototype.hasOwnProperty.call(l,"default_value")&&(l.default_value=U(c)),o[s]=l,i[s]=c}return{schema:o,params:i}}static applyParams(t,n,o){const i=pn(this.inputParamsSchema,o,n);return Object.assign(n,i),{paramsPatch:{}}}static ensurePersistentData(t){return!t||typeof t!="object"?null:((!t.persistentData||typeof t.persistentData!="object")&&(t.persistentData={}),t.persistentData)}static dragLabelOnPlane(t,n,o={}){if(!n||typeof o.makePlane!="function")return;const i=o.makePlane();if(!i||!(i instanceof B)&&!i.isPlane)return;const r=o.eventTarget||window,s=t?.viewer,a=d(c=>{const u=n.raycastFromEvent?n.raycastFromEvent(c):null;if(!u)return;const f=new p;(n.intersectPlane?n.intersectPlane(u,i,f):u.intersectPlane(i,f))&&typeof o.onDrag=="function"&&o.onDrag(f,c,i)},"onMove"),l=d(c=>{try{r.removeEventListener("pointermove",a,!0)}catch{}try{r.removeEventListener("pointerup",l,!0)}catch{}if(o.suspendControls===!0)try{s?.controls&&(s.controls.enabled=!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}if(typeof o.onEnd=="function")try{o.onEnd(c)}catch{}if(o.preventDefault!==!1)try{c.preventDefault(),c.stopImmediatePropagation?.(),c.stopPropagation()}catch{}},"onUp");try{t?.showDragPlaneHelper?.(i)}catch{}if(o.suspendControls===!0)try{s?.controls&&(s.controls.enabled=!1)}catch{}try{r.addEventListener("pointermove",a,!0)}catch{}try{r.addEventListener("pointerup",l,!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={})}};d(I,"BaseAnnotation"),A(I,"entityType","annotation"),A(I,"shortName","ANN"),A(I,"longName","Annotation"),A(I,"inputParamsSchema",{});let F=I;function pn(e,t,n){const o={},i=t&&typeof t=="object"?t:{};for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const s=e[r]||{};if(s.readOnly){n&&Object.prototype.hasOwnProperty.call(n,r)?o[r]=n[r]:o[r]=U(s.default_value);continue}const a=i[r],l=n&&Object.prototype.hasOwnProperty.call(n,r);if(a===void 0){o[r]=U(l?n[r]:s.default_value);continue}switch(s.type){case"number":{const c=Number(a);o[r]=Number.isFinite(c)?c:l&&Number.isFinite(n[r])?Number(n[r]):Number.isFinite(s.default_value)?s.default_value:0;break}case"boolean":o[r]=a==="false"?!1:!!a;break;case"options":{const c=Array.isArray(s.options)?s.options:[],u=a==null?"":String(a);c.includes(u)?o[r]=u:l&&c.includes(n[r])?o[r]=n[r]:o[r]=c.includes(s.default_value)?s.default_value:c[0]||"";break}case"reference_selection":{if(s.multiple){const c=Array.isArray(a)?a:a?[a]:[];o[r]=c.map(f=>f==null?"":String(f)).filter(f=>f.length);const u=dn(s.maxSelections);u!==null&&o[r].length>u&&(o[r]=o[r].slice(0,u)),!o[r].length&&l&&Array.isArray(n[r])&&(o[r]=n[r].slice(),u!==null&&o[r].length>u&&(o[r]=o[r].slice(0,u)))}else o[r]=a==null?l?String(n[r]??""):"":String(a);break}case"textarea":case"string":o[r]=a==null?l?String(n[r]??""):"":String(a);break;case"object":o[r]=U(a&&typeof a=="object"?a:s.default_value);break;case"transform":o[r]=mn(a,s.default_value);break;case"vec3":o[r]=yn(a,s.default_value);break;default:o[r]=U(a);break}}return o}d(pn,"sanitizeAnnotationParams");function dn(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.floor(t)):null}d(dn,"normalizeSelectionBound");function mn(e,t){const n=e&&typeof e=="object"?e:t||{},o=d((i,r,s=3)=>{const a=Array.isArray(i)?i:r&&Array.isArray(r)?r:[],l=[];for(let c=0;c<s;c+=1){const u=a[c],f=Number(u);l[c]=Number.isFinite(f)?f:0}return l},"toArray");return{position:o(n.position,t?.position||[0,0,0]),rotationEuler:o(n.rotationEuler,t?.rotationEuler||[0,0,0]),scale:o(n.scale,t?.scale||[1,1,1])}}d(mn,"normalizeTransform");function yn(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 o=[];for(let i=0;i<3;i+=1){const r=Number(n[i]);o[i]=Number.isFinite(r)?r:0}return o}d(yn,"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}d(U,"__cloneValue");function O(e,t,n,o=.01){const i=[];typeof t=="function"&&i.push(t),typeof n=="function"&&i.push(n);for(const r of i)try{const s=Number(r(e));if(Number.isFinite(s)&&s>0)return s}catch{}return o}d(O,"resolveScreenSizeWorld");function hn(e){if(!e||e.lengthSq()===0)return new p(0,0,1);const t=Math.abs(e.dot(new p(0,0,1)))<.9?new p(0,0,1):new p(0,1,0),n=new p().crossVectors(e,t);return n.lengthSq()===0&&n.crossVectors(e,new p(1,0,0)),n.lengthSq()===0?new p(1,0,0):n.normalize()}d(hn,"arbitraryPerpendicular3D");function Z(e){if(!e)return null;if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3)return new p(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),o=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(o))return new p(t,n,o)}return null}d(Z,"vectorFromAny$2");function gn(e){return e>1?1:e<-1?-1:e}d(gn,"clampToUnit");function wn(e,t){const n=e.x*t.y-e.y*t.x,o=e.x*t.x+e.y*t.y;return Math.atan2(n,o)}d(wn,"signedAngle2D");function bn(e,t){const n=Math.cos(t),o=Math.sin(t);return new C(e.x*n-e.y*o,e.x*o+e.y*n)}d(bn,"rotate2D");function at(e,t){const n=e.clone().normalize();let o=(t?t.clone():new p(1,0,0)).projectOnPlane(n);o.lengthSq()<1e-12&&(o=Math.abs(n.z)<.9?new p(0,0,1).cross(n):new p(0,1,0).cross(n)),o.normalize();const i=new p().crossVectors(n,o).normalize();return{U:o,V:i,N:n}}d(at,"planeBasis");function je(e,t,n){const o=e.clone().sub(t);return new C(o.dot(n.U),o.dot(n.V))}d(je,"to2D");function ze(e,t){return new C(e.dot(t.U),e.dot(t.V))}d(ze,"dirTo2D");function ne(e,t,n){return t.clone().add(n.U.clone().multiplyScalar(e.x)).add(n.V.clone().multiplyScalar(e.y))}d(ne,"from2D");function Sn(e,t,n,o){const i=t.x*o.y-t.y*o.x;if(Math.abs(i)<1e-12)return null;const r=new C().subVectors(n,e),s=(r.x*o.y-r.y*o.x)/i;return new C(e.x+t.x*s,e.y+t.y*s)}d(Sn,"intersectLines2D");function xn(e,t,n){const o=e.clone().sub(t).dot(n);return e.clone().sub(n.clone().multiplyScalar(o))}d(xn,"projectPointToPlane");function Ae(e,t,n,o){const i=n?e.clone().multiplyScalar(-1):e.clone(),r=o?t.clone().multiplyScalar(-1):t.clone(),s=gn(i.dot(r)),a=Math.acos(s),l=wn(i,r);return{A:i,B:r,angle:a,signedAngle:l}}d(Ae,"createAngleCombo");function Ct(e,t,n,o=!0){if(!e||!t)return null;const i=[Ae(e,t,!1,!1),Ae(e,t,!1,!0),Ae(e,t,!0,!1),Ae(e,t,!0,!0)],r=Math.PI/2,s=1e-6,a=d((l,c)=>l.length?l.slice().sort(c)[0]:null,"selectByAngle");if(n==="reflex"){const l=i[0],c=Math.abs(l.signedAngle),u=c<1e-6?0:2*Math.PI-c,f=-Math.sign(l.signedAngle||1),m=l.A.clone().add(l.B);return m.lengthSq()<1e-10&&m.set(-l.A.y,l.A.x),m.normalize().multiplyScalar(-1),{start:l.A.clone(),end:l.B.clone(),sweep:u,dirSign:f,angleRad:u,bisector:m,angleType:"reflex",signedAngle:l.signedAngle}}if(n==="acute"){if(!o){const m=i[0],y=m.A.clone().add(m.B);y.lengthSq()<1e-10&&y.set(-m.A.y,m.A.x),y.normalize();const g=Math.abs(m.signedAngle)<1e-8?1:Math.sign(m.signedAngle),b=Math.abs(m.signedAngle);return{start:m.A.clone(),end:m.B.clone(),sweep:b,dirSign:g,angleRad:b,bisector:y,angleType:"acute",signedAngle:m.signedAngle}}const l=i.filter(m=>m.angle<=r+s),c=a(l.length?l:i,(m,y)=>m.angle-y.angle);if(!c)return null;const u=c.A.clone().add(c.B);u.lengthSq()<1e-10&&u.set(-c.A.y,c.A.x),u.normalize();const f=Math.abs(c.signedAngle)<1e-8?1:Math.sign(c.signedAngle);return{start:c.A.clone(),end:c.B.clone(),sweep:c.angle,dirSign:f,angleRad:c.angle,bisector:u,angleType:"acute",signedAngle:c.signedAngle}}if(n==="obtuse"){const l=i.filter(m=>m.angle>=r-s);let c=a(l,(m,y)=>m.angle-y.angle);if(c||(c=a(i,(m,y)=>y.angle-m.angle)),!c)return null;const u=c.A.clone().add(c.B);u.lengthSq()<1e-10&&u.set(-c.A.y,c.A.x),u.normalize();const f=Math.abs(c.signedAngle)<1e-8?1:Math.sign(c.signedAngle);return{start:c.A.clone(),end:c.B.clone(),sweep:c.angle,dirSign:f,angleRad:c.angle,bisector:u,angleType:"obtuse",signedAngle:c.signedAngle}}return null}d(Ct,"resolveAngleOrientation2D");function An({planePoint:e=null,planeNormal:t=null,basis:n=null,vertex2D:o=null,directionA2D:i=null,directionB2D:r=null,sweepRad:s=0,sweepDirection:a=1,bisector2D:l=null,labelWorld:c=null,screenSizeWorld:u=null,fallbackScreenSizeWorld:f=null,defaultRadiusPixels:m=60,minRadiusPixels:y=30,arcDensity:g=64,minArcSteps:b=48,extensionPixels:h=25,stubPixels:P=12,labelOffsetPixels:D=70,arrowLengthPixels:S=10,arrowWidthPixels:N=4}={}){if(!e||!t||!n||!o||!i||!r)return null;const w=o.clone(),x=i.clone(),T=r.clone();if(x.lengthSq()<=1e-12||T.lengthSq()<=1e-12)return null;x.normalize(),T.normalize();const M=t.clone().normalize();let E=null;const z=Z(c);if(z){const le=xn(z,e,M);E=je(le,e,n).clone().sub(w).length()}(!Number.isFinite(E)||E<=0)&&(E=O(m,u,f,.02));const q=O(y,u,f,.01);E=Math.max(E,q);const R=[],K=Math.max(0,Number(s)||0),xe=Number(a)||1;if(K>1e-6){const le=Math.max(b,Math.floor(K*g));for(let te=0;te<=le;te+=1){const Ve=te/le,_e=xe*K*Ve,mt=bn(x,_e),rn=new C(w.x+mt.x*E,w.y+mt.y*E);R.push(ne(rn,e,n))}}const de=O(S,u,f,.08),We=O(N,u,f,.03),me=[];if(R.length>=2){const le=R[0].clone().sub(R[1]).normalize();me.push({tip:R[0].clone(),direction:le,length:de,width:We});const te=R[R.length-1].clone(),Ve=R[R.length-2].clone(),_e=te.clone().sub(Ve).normalize();me.push({tip:te,direction:_e,length:de,width:We})}const ae=E+O(h,u,f,.02),J=O(P,u,f,.01),ee=ne(w,e,n),Yt=ne(new C(w.x+x.x*ae,w.y+x.y*ae),e,n),Zt=ne(new C(w.x+T.x*ae,w.y+T.y*ae),e,n),Kt=ne(new C(w.x-x.x*J,w.y-x.y*J),e,n),Jt=ne(new C(w.x-T.x*J,w.y-T.y*J),e,n),en=[[ee.clone(),Yt],[ee.clone(),Zt],[ee.clone(),Kt],[ee.clone(),Jt]];let ye=l?l.clone():new C().addVectors(x,T);ye.lengthSq()<1e-10&&ye.set(-x.y,x.x),ye.normalize();const pt=O(D,u,f,.03),dt=E>0?E+pt*.3:pt,tn=new C(w.x+ye.x*dt,w.y+ye.y*dt),nn=ne(tn,e,n);return{radius:E,arcPoints:R,arrowSpecs:me,segments:en,labelPosition:nn,originWorld:ee}}d(An,"buildAngleDimensionGeometry");function Nn({pointA:e=null,pointB:t=null,extensionAnchorA:n=null,extensionAnchorB:o=null,normal:i=null,offset:r=0,showExtensions:s=!0,labelWorld:a=null,screenSizeWorld:l=null,fallbackScreenSizeWorld:c=null,arrowLengthPixels:u=12,arrowWidthPixels:f=4,labelLiftPixels:m=6,labelLeaderThresholdPixels:y=6}={}){const g=Z(e),b=Z(t);if(!g||!b)return null;const h=b.clone().sub(g);if(h.lengthSq()<1e-8)return null;h.normalize();let P=Z(i);(!P||P.lengthSq()<1e-12)&&(P=new p(0,0,1)),P.normalize();let D=new p().crossVectors(P,h);if(D.lengthSq()<1e-12&&(D=hn(h)),D.lengthSq()<1e-12)return null;D.normalize();let S=Number(r);Number.isFinite(S)||(S=O(20,l,c,.05));const N=g.clone().addScaledVector(D,S),w=b.clone().addScaledVector(D,S),x=[];s!==!1&&(x.push(...ht(n,g,N)),x.push(...ht(o,b,w))),x.push([N.clone(),w.clone()]);const T=O(u,l,c,.08),M=O(f,l,c,.03),E=[{tip:N.clone(),direction:h.clone().negate(),length:T,width:M},{tip:w.clone(),direction:h.clone(),length:T,width:M}],z=Z(a),q=new p().addVectors(N,w).multiplyScalar(.5),R=O(m,l,c,.02),K=z||q.addScaledVector(D,R);let xe=null;if(z){const de=N.distanceTo(w);if(de>1e-6){const me=z.clone().sub(N).dot(h),ae=Math.max(0,Math.min(de,me)),J=N.clone().addScaledVector(h,ae),ee=O(y,l,c,.02);z.distanceTo(J)>ee&&(xe=[J,z.clone()])}}return{direction:h,tangent:D,offset:S,offsetA:N,offsetB:w,segments:x,arrowSpecs:E,labelPosition:K,leaderSegment:xe}}d(Nn,"buildLinearDimensionGeometry");function ht(e,t,n){const o=[],i=Z(e)||t,r=1e-12;return i.distanceToSquared(t)>r&&o.push([i.clone(),t.clone()]),t.distanceToSquared(n)>r&&o.push([t.clone(),n.clone()]),o}d(ht,"buildLinearExtensionSegments");const Pn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the linear dimension"},targets:{type:"reference_selection",selectionFilter:["VERTEX","EDGE","FACE"],multiple:!0,default_value:[],label:"Targets",hint:"Select vertices, edges, or a planar face/linear edge and target",minSelections:1,maxSelections:2},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:d(({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 F{static showContexButton(t){const n=F._collectSelectionRefs(t,["VERTEX","EDGE","FACE"]);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:o,idx:i,ctx:r}=t,s=this.inputParams,a=Ue(n,s),l=a&&a.p0&&a.p1?a.p0.distanceTo(a.p1):null,c=gt(l,s);if(s.value=c.display,!a||!a.p0||!a.p1)return r?.reportAnnotationError?.("Linear dimension could not resolve two measurement points."),[];(!s.persistentData||typeof s.persistentData!="object")&&(s.persistentData={});const u=s.persistentData;try{const m=r.alignNormal?r.alignNormal(s?.alignment||"view",s):new p(0,0,1),y=Nn({pointA:a.p0,pointB:a.p1,extensionAnchorA:a.extensionAnchorA,extensionAnchorB:a.extensionAnchorB,normal:m,offset:s?.offset,showExtensions:s?.showExt!==!1,labelWorld:u.labelWorld||s.labelWorld,screenSizeWorld:r.screenSizeWorld,fallbackScreenSizeWorld:d(S=>L(n?.viewer,S),"fallbackScreenSizeWorld")});if(!y)return r?.reportAnnotationError?.("Linear dimension geometry could not be generated from the selected targets."),[];for(const[S,N]of y.segments)o.add(Y(S,N,1096065));for(const S of y.arrowSpecs)oe(o,S.tip,S.direction,S.length,S.width,1096065);y.leaderSegment&&o.add(Y(y.leaderSegment[0],y.leaderSegment[1],1096065));const g=Number.isFinite(s.decimals)?s.decimals:n?._opts?.dimDecimals|0,b=a.p0.distanceTo(a.p1),h=gt(b,s,g);s.value=h.display;const P=r.formatReferenceLabel?r.formatReferenceLabel(s,h.raw):h.display,D=y.labelPosition;D&&r.updateLabel(i,P,D,s)}catch(f){r?.reportAnnotationError?.(f,"Linear dimension failed to render.")}return[]}static onLabelPointerDown(t,n,o,i,r){try{if(!t.viewer?.camera)return;const l=Ue(t,o);if(!l||!l.p0||!l.p1)return;const c=l.p0,u=l.p1,f=r.alignNormal?r.alignNormal(o?.alignment||"view",o):new p(0,0,1),m=new p().subVectors(u,c).normalize(),y=Vn(f,m),g=new p().addVectors(c,u).multiplyScalar(.5),b=new B().setFromNormalAndCoplanarPoint(f,g);$.dragLabelOnPlane(t,r,{makePlane:d(()=>b,"makePlane"),onDrag:d(h=>{const D=new p().subVectors(h,g).dot(y);o.offset=D;const S=[h.x,h.y,h.z];$.ensurePersistentData(o),o.persistentData.labelWorld=S,o.labelWorld=S,r.updateLabel(n,null,h,o),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d($,"LinearDimensionAnnotation"),A($,"entityType","linear"),A($,"type","linear"),A($,"shortName","DIM"),A($,"longName","Linear Dimension"),A($,"title","Linear"),A($,"inputParamsSchema",Pn);let $e=$;function gt(e,t,n){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const o=n!==void 0?n:Number(t?.decimals),i=Number.isFinite(o)?Math.max(0,Math.min(8,o|0)):3,r=`${e.toFixed(i)}`,s=t?.isReference?`(${r})`:r;return{raw:r,display:s}}d(gt,"formatLinearLabel");function Ue(e,t){const n=Array.isArray(t?.targets);try{const o=e?.viewer?.partHistory?.scene,i=Dn(n?t.targets:null);if(o&&i.length){const r=En(o,i);if(r.length){const s=[],a=[],l=[];for(const y of r){const g=typeof y?.type=="string"?y.type.toUpperCase():"";g==="VERTEX"?s.push(y):g==="EDGE"?a.push(y):(g==="FACE"||g==="PLANE")&&l.push(y)}const c=r[0]||null,u=l.length>0||r.some(y=>fe(y)),f=a.length>0||r.some(y=>be(y));if(fe(c)){const y=Xe(e,r);if(y)return y}if(be(c)&&r.length>=2){const y=He(e,r);if(y)return y}if(u){const y=Xe(e,r);if(y)return y}if(f&&r.length>=2){const y=He(e,r);if(y)return y}const m=e?.viewer;if(s.length>=2){const y=ge(m,s[0]),g=ge(m,s[1]);if(y&&g)return{p0:y,p1:g}}if(s.length===1&&a.length){const y=ge(m,s[0]),g=y?_n(a,y):null;if(y&&g)return{p0:y,p1:g}}if(!s.length&&a.length){if(a.length===1){const y=lt(a[0]);if(y)return{p0:y.a,p1:y.b}}else if(a.length>=2)return It(a[0],a[1])}}return null}}catch{}if(!n)try{const o=e?.viewer?.partHistory?.scene,i=t?.aRefName||null,r=t?.bRefName||null;if(o&&(i||r)){const s=i?o.getObjectByName(i):null,a=r?o.getObjectByName(r):null;if(s&&a)return Cn(s,a);if(s&&!a){const l=v(e.viewer,s),c=Pe(t.p1);if(l&&c)return{p0:l,p1:c}}if(!s&&a){const l=v(e.viewer,a),c=Pe(t.p0);if(c&&l)return{p0:c,p1:l}}}}catch{}return{p0:Pe(t?.p0)||new p(0,0,0),p1:Pe(t?.p1)||new p(0,0,0)}}d(Ue,"computeDimPoints");function Xe(e,t){const n=e?.viewer,o=Array.isArray(t)?t.filter(Boolean):[],i=o.findIndex(y=>fe(y));if(i<0)return null;const r=o[i],s=Re(n,r);if(!s)return null;const a=o.find((y,g)=>g!==i&&y);if(!a)return null;const l=Mn(n,a,s);if(!l?.point)return null;const c=l.point.clone().sub(s.point).dot(s.normal),u=l.point.clone().addScaledVector(s.normal,-c),f=u.clone().addScaledVector(s.normal,c),m=s.anchor||s.point;return u.distanceToSquared(f)<=1e-12?null:{p0:u,p1:f,extensionAnchorA:m,extensionAnchorB:l.anchor||l.point,measurementNormal:s.normal.clone(),measurementMode:"faceNormal"}}d(Xe,"computeFaceNormalDimPoints");function He(e,t){const n=e?.viewer,o=Array.isArray(t)?t.filter(Boolean):[],i=o.findIndex(f=>be(f));if(i<0||o.length<2)return null;const r=Bt(o[i]);if(!r)return null;const s=o.find((f,m)=>m!==i&&f);if(!s)return null;const a=zn(n,s,r);if(!a?.point)return null;const l=qn(a.point,r.point,r.direction);if(!l)return null;const c=l,u=a.point.clone();return c.distanceToSquared(u)<=1e-12?null:{p0:c,p1:u,extensionAnchorA:r.anchor.clone(),extensionAnchorB:a.anchor||a.point,measurementMode:"edgeNormal",referenceDirection:r.direction.clone()}}d(He,"computeEdgeNormalDimPoints");function Dn(e){return Array.isArray(e)?e.slice(0,2):e==null||e===""?[]:[e]}d(Dn,"normalizeTargetList");function En(e,t){if(!e||!Array.isArray(t))return[];const n=[],o=new Set;for(const i of t){let r=null;if(i&&typeof i=="object")i.isObject3D?r=i:i.name&&(r=e.getObjectByName(i.name));else if(i!=null){const a=String(i).trim();a&&(r=e.getObjectByName(a))}if(!r)continue;const s=r.uuid||r.id||r.name;if(s!=null){const a=String(s);if(o.has(a))continue;o.add(a)}n.push(r)}return n}d(En,"resolveTargetObjects");function ge(e,t){const n=v(e,t);return n&&n.clone||n&&n.isVector3?n.clone():t?.getWorldPosition?t.getWorldPosition(new p):null}d(ge,"resolveVertexPoint");function fe(e){if(!e)return!1;const t=String(e.type||"").toUpperCase(),n=String(e.userData?.type||e.userData?.brepType||"").toUpperCase();return t==="FACE"||t==="PLANE"||n==="FACE"||n==="PLANE"}d(fe,"isFaceLikeObject");function be(e){if(!e)return!1;const t=String(e.type||"").toUpperCase(),n=String(e.userData?.type||e.userData?.brepType||"").toUpperCase();return t==="EDGE"||n==="EDGE"||e.isLine||e.isLine2||e.isLineSegments||e.isLineLoop}d(be,"isEdgeLikeObject");function Re(e,t){try{if(!fe(t))return null;const n=ie(e,t);if(!n||n.lengthSq()<=1e-12)return null;n.normalize();const o=v(e,t);if(!o)return null;const i=new B().setFromNormalAndCoplanarPoint(n,o),r=i.projectPoint(o,o.clone());return Tn(t,i)?{point:r,normal:n,anchor:r.clone()}:null}catch{return null}}d(Re,"resolvePlanarFacePlane");function Tn(e,t){try{if(String(e?.type||"").toUpperCase()==="PLANE")return!0;const o=e?.geometry?.getAttribute?.("position");if(!o||!Number.isFinite(o.count)||o.count<3)return!0;e.updateMatrixWorld?.(!0);const i=e.matrixWorld||new pe,r=new p,s=new qe;let a=0;for(let u=0;u<o.count;u+=1)r.set(o.getX(u),o.getY(u),o.getZ(u)).applyMatrix4(i),s.expandByPoint(r),a=Math.max(a,Math.abs(t.distanceToPoint(r)));const l=s.getSize(new p),c=Math.max(l.length(),1);return a<=Math.max(1e-5,c*1e-5)}catch{return!0}}d(Tn,"isPlanarFaceGeometry");function Mn(e,t,n){if(!t||!n)return null;if(fe(t)){const r=Re(e,t);if(r)return Math.abs(r.normal.dot(n.normal))>1-1e-5?{point:r.point.clone(),anchor:r.anchor.clone()}:{point:r.point.clone(),anchor:r.anchor.clone()}}if(String(t?.type||"").toUpperCase()==="VERTEX"){const r=ge(e,t);return r?{point:r,anchor:r.clone()}:null}if(be(t)){const r=Wn(t);if(r)return{point:r,anchor:r.clone()}}const i=v(e,t);return i?{point:i.clone(),anchor:i.clone()}:null}d(Mn,"resolveFaceNormalTargetPoint");function zn(e,t,n){if(!t||!n)return null;if(be(t)){const r=Bt(t);if(r){const s=Rn(n.point,n.direction,r.point,r.direction);return s?{point:s.targetPoint,anchor:r.anchor.clone()}:{point:r.anchor.clone(),anchor:r.anchor.clone()}}}if(fe(t)){const r=Re(e,t);if(r)return{point:r.point.clone(),anchor:r.anchor.clone()}}if(String(t?.type||"").toUpperCase()==="VERTEX"){const r=ge(e,t);return r?{point:r,anchor:r.clone()}:null}const i=v(e,t);return i?{point:i.clone(),anchor:i.clone()}:null}d(zn,"resolveEdgeNormalTargetPoint");function Bt(e){const t=vn(e);if(!Array.isArray(t)||t.length<2)return null;const n=t[0];let o=null;for(let s=t.length-1;s>=1;s-=1)if(t[s]?.distanceToSquared(n)>1e-12){o=t[s];break}if(!o)return null;const i=o.clone().sub(n);if(i.lengthSq()<=1e-12||(i.normalize(),!Fn(t,n,i)))return null;const r=Ln(t)||n.clone().add(o).multiplyScalar(.5);return{point:n.clone(),direction:i,anchor:r,points:t}}d(Bt,"resolveLinearEdgeLine");function vn(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}const t=e.matrixWorld||null,n=[],o=d((l,c=!1)=>{const u=Z(l);if(!u)return;c&&t&&u.applyMatrix4(t);const f=n[n.length-1];f&&f.distanceToSquared(u)<=1e-14||n.push(u)},"push");try{if(typeof e.points=="function"){const l=e.points(!0);if(Array.isArray(l))for(const c of l)o(c,!1);if(n.length>=2)return n;n.length=0}}catch{}const i=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(i){for(const l of i)o(l,!0);if(n.length>=2)return n;n.length=0}const r=e?.geometry?.attributes?.instanceStart,s=e?.geometry?.attributes?.instanceEnd;if(r&&s){const l=Math.min(r.count||0,s.count||0);for(let c=0;c<l;c+=1){const u=new p(r.getX(c),r.getY(c),r.getZ(c)),f=new p(s.getX(c),s.getY(c),s.getZ(c));t&&(u.applyMatrix4(t),f.applyMatrix4(t)),o(u,!1),o(f,!1)}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 l=0;l<a.count;l+=1){const c=new p(a.getX(l),a.getY(l),a.getZ(l));t&&c.applyMatrix4(t),o(c,!1)}if(n.length>=2)return n}return null}d(vn,"edgeWorldPoints");function Fn(e,t,n){if(!Array.isArray(e)||e.length<2||!t||!n)return!1;const o=new qe;for(const l of e)l&&o.expandByPoint(l);const i=Math.max(o.getSize(new p).length(),1),r=Math.max(1e-6,i*1e-5),s=new p,a=new p;for(const l of e){if(!l)continue;s.copy(l).sub(t);const c=s.dot(n);if(a.copy(n).multiplyScalar(c),s.sub(a).length()>r)return!1}return!0}d(Fn,"pointsAreCollinear");function Ln(e){if(!Array.isArray(e)||!e.length)return null;const t=new p;let n=0;for(const o of e)o&&(t.add(o),n+=1);return n?t.multiplyScalar(1/n):null}d(Ln,"averagePoints");function qn(e,t,n){if(!e||!t||!n||n.lengthSq()<=1e-12)return null;const o=n.clone().normalize(),i=e.clone().sub(t).dot(o);return t.clone().addScaledVector(o,i)}d(qn,"projectPointOnLine");function Rn(e,t,n,o){if(!e||!t||!n||!o)return null;const i=t.clone(),r=o.clone();if(i.lengthSq()<=1e-12||r.lengthSq()<=1e-12)return null;i.normalize(),r.normalize();const s=e.clone().sub(n),a=i.dot(r),l=i.dot(s),c=r.dot(s),u=1-a*a;if(Math.abs(u)<=1e-10)return null;const f=(a*c-l)/u,m=(c-a*l)/u;return{basePoint:e.clone().addScaledVector(i,f),targetPoint:n.clone().addScaledVector(r,m)}}d(Rn,"closestPointsBetweenInfiniteLines");function Wn(e){const t=lt(e);return t?.a&&t?.b?new p().addVectors(t.a,t.b).multiplyScalar(.5):null}d(Wn,"edgeMidpointWorld");function Vn(e,t){const n=e?.clone?.()||new p(0,0,1);n.lengthSq()||n.set(0,0,1),n.normalize();const o=t?.clone?.()||new p(1,0,0);o.lengthSq()||o.set(1,0,0),o.normalize();const i=new p().crossVectors(n,o);if(i.lengthSq()>1e-12)return i.normalize();const r=Math.abs(o.z)<.9?new p(0,0,1):new p(0,1,0);return i.crossVectors(o,r),i.lengthSq()>1e-12?i.normalize():new p(1,0,0)}d(Vn,"safeDimensionTangent");function _n(e,t){if(!Array.isArray(e)||!t)return null;let n=null,o=1/0;for(const i of e){const r=lt(i);if(r){const a=r.a.distanceToSquared(t);a<o&&(o=a,n=r.a);const l=r.b.distanceToSquared(t);l<o&&(o=l,n=r.b);continue}const s=ke(i,t);if(s){const a=s.distanceToSquared(t);a<o&&(o=a,n=s)}}return n?n.clone():null}d(_n,"closestEndpointToPoint");function lt(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}try{if(typeof e.points=="function"){const r=e.points(!0);if(Array.isArray(r)&&r.length>=2){const s=Ne(r[0]),a=Ne(r[r.length-1]);if(s&&a)return{a:s,b:a}}}}catch{}const t=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(t&&t.length>=2){const r=Ne(t[0]),s=Ne(t[t.length-1]);if(r&&s)return e.matrixWorld&&(r.applyMatrix4(e.matrixWorld),s.applyMatrix4(e.matrixWorld)),{a:r,b:s}}const n=e?.geometry?.attributes?.instanceStart,o=e?.geometry?.attributes?.instanceEnd;if(n&&o&&n.count>=1){const r=new p(n.getX(0),n.getY(0),n.getZ(0)),s=new p(o.getX(0),o.getY(0),o.getZ(0));return e.matrixWorld&&(r.applyMatrix4(e.matrixWorld),s.applyMatrix4(e.matrixWorld)),{a:r,b:s}}const i=e?.geometry?.getAttribute?.("position");if(i&&i.itemSize===3&&i.count>=2){const r=new p(i.getX(0),i.getY(0),i.getZ(0)),s=new p(i.getX(i.count-1),i.getY(i.count-1),i.getZ(i.count-1));return e.matrixWorld&&(r.applyMatrix4(e.matrixWorld),s.applyMatrix4(e.matrixWorld)),{a:r,b:s}}return null}d(lt,"edgeEndpointsWorld");function Cn(e,t){if(e?.type==="VERTEX"&&t?.type==="VERTEX")return{p0:e.getWorldPosition(new p),p1:t.getWorldPosition(new p)};if(e?.type==="EDGE"&&t?.type==="VERTEX"){const n=t.getWorldPosition(new p);return{p0:ke(e,n),p1:n}}if(e?.type==="VERTEX"&&t?.type==="EDGE"){const n=e.getWorldPosition(new p),o=ke(t,n);return{p0:n,p1:o}}return e?.type==="EDGE"&&t?.type==="EDGE"?It(e,t):{p0:v(null,e)||new p,p1:v(null,t)||new p}}d(Cn,"closestPointsForObjects");function ke(e,t){try{const n=e.points(!0);if(!n||n.length<2)return e.getWorldPosition(new p);const o=t.clone();let i={d2:1/0,q:null};const r=new p,s=new p;for(let a=0;a<n.length-1;a++){r.set(n[a].x,n[a].y,n[a].z),s.set(n[a+1].x,n[a+1].y,n[a+1].z);const l=Bn(r,s,o),c=l.distanceToSquared(o);c<i.d2&&(i={d2:c,q:l})}return i.q||e.getWorldPosition(new p)}catch{return e.getWorldPosition(new p)}}d(ke,"closestPointOnEdgeToPoint");function It(e,t){try{const n=e.points(!0),o=t.points(!0);if(!n||n.length<2||!o||o.length<2)return{p0:v(null,e)||new p,p1:v(null,t)||new p};const i=new p,r=new p,s=new p,a=new p;let l={d2:1/0,p:null,q:null};for(let c=0;c<n.length-1;c++){i.set(n[c].x,n[c].y,n[c].z),r.set(n[c+1].x,n[c+1].y,n[c+1].z);for(let u=0;u<o.length-1;u++){s.set(o[u].x,o[u].y,o[u].z),a.set(o[u+1].x,o[u+1].y,o[u+1].z);const{p:f,q:m}=In(i,r,s,a),y=f.distanceToSquared(m);y<l.d2&&(l={d2:y,p:f,q:m})}}return{p0:l.p||v(null,e)||new p,p1:l.q||v(null,t)||new p}}catch{return{p0:v(null,e)||new p,p1:v(null,t)||new p}}}d(It,"closestPointsBetweenEdges");function Bn(e,t,n){const o=t.clone().sub(e),i=Math.max(0,Math.min(1,o.dot(n.clone().sub(e))/(o.lengthSq()||1)));return e.clone().addScaledVector(o,i)}d(Bn,"closestPointOnSegment");function In(e,t,n,o){const i=t.clone().sub(e),r=o.clone().sub(n),s=e.clone().sub(n),a=i.dot(i),l=r.dot(r),c=r.dot(s);let u,f;const m=1e-12;if(a<=m&&l<=m)u=0,f=0;else if(a<=m)u=0,f=Math.max(0,Math.min(1,c/l));else{const b=i.dot(s);if(l<=m)f=0,u=Math.max(0,Math.min(1,-b/a));else{const h=i.dot(r),P=a*l-h*h;u=P!==0?Math.max(0,Math.min(1,(h*c-b*l)/P)):0,f=(h*u+c)/l,f<0?(f=0,u=Math.max(0,Math.min(1,-b/a))):f>1&&(f=1,u=Math.max(0,Math.min(1,(h-b)/a)))}}const y=e.clone().addScaledVector(i,u),g=n.clone().addScaledVector(r,f);return{p:y,q:g}}d(In,"closestPointsOnSegments");function Ne(e){return Z(e)}d(Ne,"arrayToVector");function Pe(e){return e?e instanceof p?e.clone():Array.isArray(e)?new p(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new p(e.x||0,e.y||0,e.z||0):null:null}d(Pe,"vectorFromAnnotationPoint");const Vr={computeDimPoints:Ue,computeEdgeNormalDimPoints:He,computeFaceNormalDimPoints:Xe,resolvePlanarFacePlane:Re},On={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:"Radial Face",hint:"Select cylindrical, pipe, or fillet 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:d(({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 F{static showContexButton(t){const n=F._normalizeSelectionItems(t),o=new Set(["FACE"]);for(const i of n){if(!F._isSelectionType(i,o)||!Ot(i))continue;const r=F._selectionRefName(i);if(r)return{params:{cylindricalFaceRef:r}}}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:o,idx:i,ctx:r}=t,s=this.inputParams,a=jt(n,s),l=wt(a,s);s.value=l.display,bt(s);try{const c=ve(n,s,r);if(!c||!c.center||!c.radiusPoint)return r?.reportAnnotationError?.("Radial dimension could not resolve a radial face and center/radius geometry."),[];const{center:u,radiusPoint:f,planeNormal:m,planePoint:y,radius:g}=c,b=16739125;let h=new p().subVectors(f,u);h.lengthSq()<1e-6&&h.set(1,0,0),h.normalize();let P=m;if(P||(P=r.alignNormal?r.alignNormal(s.alignment||"view",s):null),P&&P.lengthSq()>1e-6){const x=h.clone().projectOnPlane(P).normalize();x.lengthSq()>1e-6&&(h=x)}const D=r.screenSizeWorld?r.screenSizeWorld(12):L(n?.viewer,12),S=r.screenSizeWorld?r.screenSizeWorld(4):L(n?.viewer,4),N=s.displayStyle==="diameter",w=s.persistentData?.labelWorld?Ye(s.persistentData.labelWorld):null;if(N){const x=w?w.clone().sub(u).normalize():h.clone(),T=w?u.clone().addScaledVector(x,w.clone().sub(u).length()):u.clone().addScaledVector(x,g+Math.abs(Number(s.offset)||r.screenSizeWorld?r.screenSizeWorld(50):L(n?.viewer,50))),M=u.clone().addScaledVector(x,-g),E=u.clone().addScaledVector(x,g),z=u.clone().addScaledVector(x,-g);o.add(Y(M,T,b)),oe(o,E,x.clone(),D,S,b),oe(o,z,x.clone().negate(),D,S,b);const q=Oe(r.screenSizeWorld?r.screenSizeWorld(6):L(n?.viewer,6),b);q.position.copy(u),o.add(q)}else{const x=w||$t(n,s,u,f,m,y,r);let M=x.clone().sub(u).clone();M.lengthSq()||(M=h.clone()),M.normalize();const E=x;o.add(Y(u,E,b));const z=u.clone().addScaledVector(M,g);oe(o,z,M.clone(),D,S,b);const q=Oe(r.screenSizeWorld?r.screenSizeWorld(6):L(n?.viewer,6),b);q.position.copy(u),o.add(q)}if(typeof a=="number"){const x=wt(a,s);s.value=x.display;const T=r.formatReferenceLabel?r.formatReferenceLabel(s,x.raw):x.display,M=$n(n,s,u,f,m,y,r);M&&r.updateLabel(i,T,M,s)}}catch(c){r?.reportAnnotationError?.(c,"Radial dimension failed to render."),console.warn("RadialDimensionAnnotation render error:",c)}return[]}static onLabelPointerDown(t,n,o,i,r){try{const s=ve(t,o,r);if(!s||!s.center||!s.radiusPoint)return;const a=s.planeNormal&&s.planeNormal.lengthSq()>1e-6?s.planeNormal.clone().normalize():r.alignNormal?r.alignNormal(o.alignment||"view",o):new p(0,0,1),l=s.planePoint||s.radiusPoint,c=a&&l?new B().setFromNormalAndCoplanarPoint(a,l):null,u=new p().subVectors(s.radiusPoint,s.center).normalize();X.dragLabelOnPlane(t,r,{makePlane:d(()=>c,"makePlane"),onDrag:d(f=>{c.projectPoint(f,f),bt(o),o.persistentData.labelWorld=[f.x,f.y,f.z];const m=new p().subVectors(f,s.center);o.offset=m.dot(u)-s.radius,r.updateLabel(n,null,f,o),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d(X,"RadialDimensionAnnotation"),A(X,"entityType","radial"),A(X,"type","radial"),A(X,"shortName","RAD"),A(X,"longName","Radial Dimension"),A(X,"title","Radial"),A(X,"inputParamsSchema",On);let Ge=X;function wt(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=t?.displayStyle==="diameter"?e*2:e,o=Number(t?.decimals),i=Number.isFinite(o)?Math.max(0,Math.min(8,o|0)):3,s=`${t?.displayStyle==="diameter"?"⌀":"R"}${n.toFixed(i)}`,a=`${s} (wu)`,l=t?.isReference?`(${a})`:a;return{raw:s,display:l}}d(wt,"formatRadialLabel");function bt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(bt,"ensurePersistent$2");function ve(e,t,n){try{const o=e?.viewer?.partHistory?.scene;if(!o||!t.cylindricalFaceRef)return null;const i=o.getObjectByName(t.cylindricalFaceRef);if(!i)return null;let r=i;for(;r&&typeof r.getFaceMetadata!="function";)r=r.parent;let s=null,a=null,l=null,c=null,u=null;const f=new p;let m=we(i),y=null;if(r&&typeof r.getFaceMetadata=="function"){const h=r.getFaceMetadata(t.cylindricalFaceRef);h&&typeof h=="object"&&Object.keys(h).length>0&&(m=h),m&&(m.type==="cylindrical"||m.type==="conical")&&(m.type==="cylindrical"?(s=new p(m.center[0],m.center[1],m.center[2]),a=m.radius,l=new p(m.axis[0],m.axis[1],m.axis[2]).normalize()):Math.abs(m.radiusBottom-m.radiusTop)<1e-6&&(s=new p(m.center[0],m.center[1],m.center[2]),a=m.radiusBottom,l=new p(m.axis[0],m.axis[1],m.axis[2]).normalize()),s&&l&&(i.parent&&i.parent.matrixWorld&&(s.applyMatrix4(i.parent.matrixWorld),l.transformDirection(i.parent.matrixWorld).normalize()),u=new p,Math.abs(l.x)<.9?u.crossVectors(l,new p(1,0,0)).normalize():u.crossVectors(l,new p(0,1,0)).normalize(),c=s.clone().addScaledVector(u,a)))}if(m&&typeof m=="object"&&(y=Qe(m.pmiRadiusOverride??m.radiusOverride??m.offsetShellRadius)),(!s||!l||!Number.isFinite(a)||a<=0)&&r){const h=Un(r,i,m);h&&(s=h.center,l=h.axis,a=h.radius,c=h.radiusPoint,u=h.perpendicular)}if(!s||!l||!Number.isFinite(a)||a<=0){const h=Zn(i);if(!h)return null;s=h.center,l=h.axis,a=h.radius,c=h.radiusPoint,u=new p().subVectors(c,s).normalize()}if(y&&s){let h=null;u&&u.lengthSq()>1e-12?h=u.clone().normalize():c&&(h=new p().subVectors(c,s),h.lengthSq()>1e-12&&h.normalize()),a=y,h&&(u=h.clone(),c=s.clone().addScaledVector(h,a))}f.copy(s);let g=null,b=null;if(t.planeRef){const h=o.getObjectByName(t.planeRef);h&&(g=ie(e.viewer,h),b=v(e.viewer,h))}if(g&&b&&g.lengthSq()>1e-6){const h=g.clone().normalize();g=h;const P=new B().setFromNormalAndCoplanarPoint(h,b),D=new p;P.projectPoint(s,D),s=D;let S=new p().subVectors(c,f);S.lengthSq()<1e-12&&(S=u.clone());let N=S.projectOnPlane(h);N.lengthSq()<1e-12&&(N=l.clone().cross(h),N.lengthSq()<1e-12&&(Math.abs(h.x)<.9?N=new p().crossVectors(h,new p(1,0,0)):N=new p().crossVectors(h,new p(0,1,0)))),N.normalize(),c=s.clone().addScaledVector(N,a)}return{center:s,radiusPoint:c,planeNormal:g,planePoint:b,axis:l,radius:a}}catch{return null}}d(ve,"computeRadialPoints");function De(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),o=Number(e.radiusTop);return!Number.isFinite(n)||!Number.isFinite(o)||Math.abs(n-o)>1e-6?!1:Math.max(n,o)>0}return!1}d(De,"isCylindricalMetadata");function he(e){if(!e||typeof e!="object")return!1;const t=String(e.type||"").toLowerCase();if(t!=="pipe"&&t!=="rounded_pipe")return!1;const n=Qe(e.pmiRadiusOverride??e.radiusOverride),o=Qe(e.inflatedRadius??e.radius);if(Number.isFinite(n)||Number.isFinite(o))return!0;const i=String(e.offsetShellFaceRole||e.faceRole||"").toLowerCase();return e.offsetShellRoundedPipe===!0||i==="rounded_pipe"}d(he,"isPipeMetadata");function Qe(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.abs(t):null}d(Qe,"readPositiveNumber");function jn(e){if(!e)return null;const t=e.userData||null;if(De(t))return t;if(t?.metadata&&De(t.metadata))return t.metadata;if(typeof e.getMetadata=="function")try{const i=e.getMetadata();if(De(i))return i}catch{}const n=e?.name||t?.faceName||null;let o=e?.parentSolid||t?.parentSolid||e?.parent||null;for(;o;){if(n&&typeof o.getFaceMetadata=="function"){try{const i=o.getFaceMetadata(n);if(De(i))return i}catch{}break}o=o.parent||null}return null}d(jn,"readCylindricalMetadata");function we(e){const t=jn(e);if(t)return t;if(!e)return null;const n=e.userData||null;if(he(n))return n;if(n?.metadata&&he(n.metadata))return n.metadata;if(typeof e.getMetadata=="function")try{const r=e.getMetadata();if(he(r))return r}catch{}const o=e?.name||n?.faceName||null;let i=e?.parentSolid||n?.parentSolid||e?.parent||null;for(;i;){if(o&&typeof i.getFaceMetadata=="function"){try{const r=i.getFaceMetadata(o);if(he(r))return r}catch{}break}i=i.parent||null}return null}d(we,"readRadialFaceMetadata");function Ot(e){if(!e)return!1;if(we(e)||St(e))return!0;if(Array.isArray(e.faces)){for(const t of e.faces)if(we(t)||St(t))return!0}return!!(e.parent&&we(e.parent))}d(Ot,"hasRadialFaceData");function St(e){try{if(!e)return!1;const t=(e.name||e.userData?.faceName||"").trim(),n=Xt(t),o=we(e);let i=e.parentSolid||e.userData?.parentSolid||e.parent||null;for(;i;){const r=Array.isArray(i._auxEdges)?i._auxEdges:null;if(r&&Ut(r,t,o))return!0;if(!n&&!o)return!1;i=i.parent||null}}catch{}return!1}d(St,"hasPipeFaceAuxPath");function jt(e,t){try{const n=ve(e,t);return n&&typeof n.radius=="number"?n.radius:n&&n.center&&n.radiusPoint?n.center.distanceTo(n.radiusPoint):null}catch{return null}}d(jt,"measureRadialValue");function $n(e,t,n,o,i,r,s){try{let a=null;return t.persistentData?.labelWorld?a=Ye(t.persistentData.labelWorld):t.labelWorld&&(a=Ye(t.labelWorld)),a||(a=$t(e,t,n,o,i,r,s)),i&&r&&i.lengthSq()>1e-6&&a&&new B().setFromNormalAndCoplanarPoint(i.clone().normalize(),r).projectPoint(a,a),a}catch{return null}}d($n,"resolveLabelPosition$1");function $t(e,t,n,o,i,r,s){try{const a=new p().subVectors(o,n);if(a.lengthSq()<1e-12)return o.clone();a.normalize();let l=Number(t?.offset);(!Number.isFinite(l)||l===0)&&(l=s.screenSizeWorld?s.screenSizeWorld(50):L(e?.viewer,50));const c=n.distanceTo(o),u=n.clone().addScaledVector(a,c+Math.abs(l));return i&&r&&i.lengthSq()>1e-6&&new B().setFromNormalAndCoplanarPoint(i.clone().normalize(),r).projectPoint(u,u),u}catch{return o?o.clone():null}}d($t,"computeRadialLabelPosition");function Un(e,t,n=null){try{if(!e||!t)return null;const o=Array.isArray(e._auxEdges)?e._auxEdges:null;if(!o||o.length===0)return null;const i=(t.name||t.userData?.faceName||"").trim();if(!i)return null;const r=Ut(o,i,n);if(!r||!Array.isArray(r.points)||r.points.length<2)return null;e.updateMatrixWorld?.(!0),t.updateMatrixWorld?.(!0);const s=kn(r,e);if(!s||s.length<2)return null;const a=Gn(t,16);if(!a.length)return null;let l=null;for(const c of a){const u=Qn(c,s,!!r.closedLoop);if(!u||!u.point)continue;const f=new p().subVectors(c,u.point),m=f.lengthSq();if(!(m>1e-10))continue;const y=Math.sqrt(m);f.normalize(),(!l||y>l.radius)&&(l={center:u.point.clone(),axis:u.direction?u.direction.clone():null,radius:y,radiusPoint:u.point.clone().addScaledVector(f,y),perpendicular:f.clone()})}return l?((!l.axis||l.axis.lengthSq()<1e-10)&&(l.axis=Yn(s,l.center,!!r.closedLoop)||new p(0,1,0)),l):null}catch{return null}}d(Un,"inferPipeFaceDataFromAuxEdges");function Ut(e,t,n=null){if(!Array.isArray(e)||!t)return null;const o=Xn(t,n);for(const r of o){const s=Hn(e,r);if(s)return s}const i=String(n?.sourceFeatureId||n?.featureID||n?.featureId||"").trim();if(i){const r=`${i}_ROUND_PIPE`;for(const s of e){const a=String(s?.name||"").trim();if(s?.centerline&&a.startsWith(r)&&a.endsWith("_PATH"))return s}}return null}d(Ut,"findPipeCenterlineAuxEdge");function Xn(e,t=null){const n=[],o=d(r=>{const s=String(r||"").trim();s&&!n.includes(s)&&n.push(s)},"add");o(t?.pmiCenterlineAuxName),o(t?.centerlineAuxName),o(t?.pathName),o(t?.auxEdgeName),o(t?.centerlineName);const i=Xt(e);return i&&o(`${i}_PATH`),n}d(Xn,"pipeCenterlineNameCandidates");function Hn(e,t){if(!Array.isArray(e)||!t)return null;for(const o of e)if(o?.name===t)return o;const n=t.toLowerCase();for(const o of e)if(typeof o?.name=="string"&&o.name.toLowerCase()===n)return o;return null}d(Hn,"findAuxEdgeByName");function kn(e,t){try{const n=[],o=!e.polylineWorld&&t?.matrixWorld?t.matrixWorld:null,i=new p;for(const r of e.points){if(Array.isArray(r)&&r.length>=3)i.set(r[0],r[1],r[2]);else if(r&&typeof r=="object")i.set(Number(r.x)||0,Number(r.y)||0,Number(r.z)||0);else continue;o&&i.applyMatrix4(o),n.push(i.clone())}return n}catch{return null}}d(kn,"buildAuxPolylineWorld");function Gn(e,t=16){try{const n=e?.geometry;if(!n)return[];const o=typeof n.getAttribute=="function"?n.getAttribute("position"):null,i=e.matrixWorld||new pe,r=[],s=new p;if(o&&o.count>0){const a=Math.max(1,Math.floor(o.count/t));for(let l=0;l<o.count&&r.length<t;l+=a)s.set(o.getX(l),o.getY(l),o.getZ(l)).applyMatrix4(i),r.push(s.clone())}if(!r.length)try{n.computeBoundingSphere?.(),n.boundingSphere&&(s.copy(n.boundingSphere.center).applyMatrix4(i),r.push(s.clone()))}catch{}return r}catch{return[]}}d(Gn,"collectFaceSamplePoints");function Qn(e,t,n=!1){if(!e||!Array.isArray(t)||t.length<2)return null;const o=new p,i=new p,r=new p;let s=null,a=null,l=1/0;const c=t.length,u=n?c:c-1;for(let f=0;f<u;f++){const m=t[f],y=t[(f+1)%c];if(!m||!y)continue;i.copy(y).sub(m);const g=i.lengthSq();if(g<1e-14)continue;r.copy(e).sub(m);let b=r.dot(i)/g;b=Math.max(0,Math.min(1,b)),o.copy(m).addScaledVector(i,b);const h=o.distanceToSquared(e);h<l&&(l=h,s=o.clone(),a=i.clone().normalize())}return s?{point:s,direction:a,distanceSq:l}:null}d(Qn,"closestPointOnPolyline");function Yn(e,t,n=!1){if(!Array.isArray(e)||e.length<2||!t)return null;let o=null,i=1/0;const r=new p,s=new p,a=e.length,l=n?a:a-1;for(let c=0;c<l;c++){const u=e[c],f=e[(c+1)%a];if(!u||!f)continue;r.copy(u).add(f).multiplyScalar(.5);const m=r.distanceToSquared(t);m<i&&(i=m,s.copy(f).sub(u),o=s.lengthSq()>1e-14?s.clone().normalize():null)}return o}d(Yn,"estimatePolylineTangent");function Xt(e){const t=/^(.*?)(_Outer|_Inner|_CapStart|_CapEnd)(?:_\d+)?$/i.exec(e);return t?t[1]:null}d(Xt,"pipeFaceBaseName");function Zn(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 o=e.matrixWorld||new pe,i=[],r=new p;for(let w=0;w<n.count;w++)r.set(n.getX(w),n.getY(w),n.getZ(w)).applyMatrix4(o),i.push(r.clone());if(!i.length)return null;const s=new p;for(const w of i)s.add(w);s.divideScalar(i.length);const a=new Float64Array(9),l=new p;for(const w of i)l.copy(w).sub(s),a[0]+=l.x*l.x,a[1]+=l.x*l.y,a[2]+=l.x*l.z,a[4]+=l.y*l.y,a[5]+=l.y*l.z,a[8]+=l.z*l.z;a[3]=a[1],a[6]=a[2],a[7]=a[5];const c=new p(1,0,0);for(let w=0;w<20;w++){const x=a[0]*c.x+a[1]*c.y+a[2]*c.z,T=a[1]*c.x+a[4]*c.y+a[5]*c.z,M=a[2]*c.x+a[5]*c.y+a[8]*c.z;c.set(x,T,M);const E=c.length();if(E<1e-12){c.set(0,1,0);break}c.divideScalar(E)}c.lengthSq()<1e-12&&c.set(0,1,0);let u=1/0,f=-1/0,m=0,y=0;const g=new p,b=new p,h=new p;for(const w of i){l.copy(w).sub(s);const x=l.dot(c);x<u&&(u=x),x>f&&(f=x),b.copy(c).multiplyScalar(x),g.copy(l).sub(b);const T=g.length();T>1e-6&&(y===0&&h.copy(g).normalize(),m+=T,y++)}if(!y)return null;const P=m/y,D=s.clone().add(c.clone().multiplyScalar((u+f)*.5)),S=h.lengthSq()>1e-12?h.clone():new p().crossVectors(c,new p(1,0,0)).normalize();S.lengthSq()<1e-12&&S.set(0,1,0).cross(c).normalize();const N=D.clone().addScaledVector(S,P);return{center:D,axis:c.normalize(),radius:P,radiusPoint:N}}catch{return null}}d(Zn,"inferCylinderFromGeometry");function Ye(e){return e?e instanceof p?e.clone():Array.isArray(e)?new p(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new p(e.x||0,e.y||0,e.z||0):null:null}d(Ye,"vectorFromAny$1");const _r={computeRadialPoints:ve,hasRadialFaceData:Ot,isPipeMetadata:he,measureRadialValue:jt},Kn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the angle dimension"},decimals:{type:"number",default_value:1,defaultResolver:d(({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 F{static showContexButton(t){const n=F._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:o,idx:i,ctx:r}=t,s=this.inputParams,a=er(n,s),l=At(a,s);s.value=l.display,xt(s);try{const c=Nt(n,s,r);if(!c||!c.__2d)return r?.reportAnnotationError?.("Angle dimension could not resolve two measurable elements."),[];const u=16096779,{N:f,P:m,A_d:y,B_d:g,V2:b,basis:h,sweep:P=0,dirSign:D=1,bisector:S=null}=c.__2d,N=An({planePoint:m,planeNormal:f,basis:h,vertex2D:b,directionA2D:y,directionB2D:g,sweepRad:P,sweepDirection:D,bisector2D:S,labelWorld:s.persistentData?.labelWorld,screenSizeWorld:r.screenSizeWorld,fallbackScreenSizeWorld:d(w=>L(n?.viewer,w),"fallbackScreenSizeWorld")});if(!N)return r?.reportAnnotationError?.("Angle dimension geometry could not be generated from the selected elements."),[];for(let w=0;w<N.arcPoints.length-1;w+=1)o.add(Y(N.arcPoints[w],N.arcPoints[w+1],u));for(const[w,x]of N.segments)o.add(Y(w,x,u));for(const w of N.arrowSpecs)oe(o,w.tip,w.direction,w.length,w.width,u);if(typeof a=="number"){const w=At(a,s),x=w.raw;s.value=w.display;const T=r.formatReferenceLabel?r.formatReferenceLabel(s,x):w.display,M=N.labelPosition;M&&r.updateLabel(i,T,M,s)}}catch(c){r?.reportAnnotationError?.(c,"Angle dimension failed to render.")}return[]}static onLabelPointerDown(t,n,o,i,r){try{const s=Nt(t,o,r);if(!s)return;const a=ut(t,o,s,r),l=a?.n||new p(0,0,1),c=a?.p||new p,u=new B().setFromNormalAndCoplanarPoint(l,c);try{t?.showDragPlaneHelper?.(u)}catch{}const f=d(y=>{const g=r.raycastFromEvent?r.raycastFromEvent(y):null;if(!g)return;const b=new p;(r.intersectPlane?r.intersectPlane(g,u,b):g.intersectPlane(u,b))&&(xt(o),o.persistentData.labelWorld=[b.x,b.y,b.z],r.updateLabel(n,null,b,o),t.refreshAnnotationsUI?.())},"onMove"),m=d(y=>{try{window.removeEventListener("pointermove",f,!0),window.removeEventListener("pointerup",m,!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}try{t.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}try{y.preventDefault(),y.stopImmediatePropagation?.(),y.stopPropagation()}catch{}},"onUp");window.addEventListener("pointermove",f,!0),window.addEventListener("pointerup",m,!0)}catch{}}};d(Q,"AngleDimensionAnnotation"),A(Q,"entityType","angle"),A(Q,"type","angle"),A(Q,"shortName","ANG"),A(Q,"longName","Angle Dimension"),A(Q,"title","Angle"),A(Q,"inputParamsSchema",Kn);let Ze=Q;function xt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(xt,"ensurePersistent$1");function Jn(e){const t=Array.isArray(e)?e:e==null||e===""?[]:[e],n=[],o=new Set;for(const i of t){let r="";i&&typeof i=="object"?typeof i.name=="string"?r=i.name:i.id!=null&&(r=String(i.id)):i!=null&&(r=String(i)),r=r.trim(),!(!r||o.has(r))&&(o.add(r),n.push(r))}return n}d(Jn,"normalizeTargetNames");function ct(e){const t=Array.isArray(e?.targets),n=Jn(t?e.targets:null);let o="",i="";return n.length?(o=n[0]||"",i=n[1]||""):t||(o=e?.elementARefName||"",i=e?.elementBRefName||""),e?.reverseElementOrder?{elementARefName:i,elementBRefName:o}:{elementARefName:o,elementBRefName:i}}d(ct,"resolveElementRefNames");function Ht(e){const t=e?.angleType;return t==="acute"||t==="obtuse"||t==="reflex"?t:e?.useReflexAngle?"reflex":"acute"}d(Ht,"resolveAngleType");function kt(e){return!e||typeof e!="object"||!Object.prototype.hasOwnProperty.call(e,"angleType")?!1:e.angleType==="acute"||e.angleType==="obtuse"||e.angleType==="reflex"}d(kt,"isAngleTypeExplicit");function At(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=Number(t?.decimals),o=Number.isFinite(n)?Math.max(0,Math.min(3,n|0)):1,i=`${e.toFixed(o)}°`,r=t?.isReference?`(${i})`:i;return{raw:i,display:r}}d(At,"formatAngleLabel");function er(e,t){try{const n=Gt(e,t),o=ut(e,t,n);if(!o)return null;const{elementARefName:i,elementBRefName:r}=ct(t),s=Fe(e,i,o.n,o.p),a=Fe(e,r,o.n,o.p);if(!s||!a)return null;const l=at(o.n,s.d),c=ze(s.d,l).normalize(),u=ze(a.d,l).normalize(),f=Ht(t),m=kt(t)||!!t?.useReflexAngle,y=Ct(c,u,f,m);return y?Ee.radToDeg(y.angleRad):null}catch{return null}}d(er,"measureAngleValue");function Gt(e,t){try{const n=e?.viewer?.partHistory?.scene;if(!n)return null;const{elementARefName:o,elementBRefName:i}=ct(t),r=o?n.getObjectByName(o):null,s=i?n.getObjectByName(i):null;if(!r||!s)return null;const a=ie(e.viewer,r),l=ie(e.viewer,s),c=v(e.viewer,r),u=v(e.viewer,s);let f=null;if(t.planeRefName){const m=n.getObjectByName(t.planeRefName);m&&(f=ie(e.viewer,m))}return{dirA:a,dirB:l,pointA:c,pointB:u,plane:f}}catch{return null}}d(Gt,"computeAngleElements");function Nt(e,t,n){try{const o=Gt(e,t);if(!o||!o.dirA||!o.dirB)return null;const i=ut(e,t,o,n);if(!i)return null;const{elementARefName:r,elementBRefName:s}=ct(t),a=Fe(e,r,i.n,i.p),l=Fe(e,s,i.n,i.p);if(!a||!l)return null;const c=at(i.n,a.d),u=je(a.p,i.p,c),f=je(l.p,i.p,c);let m=ze(a.d,c).normalize(),y=ze(l.d,c).normalize();t?.reverseElementOrder&&(m=m.multiplyScalar(-1),y=y.multiplyScalar(-1));const g=Ht(t),b=kt(t)||!!t?.useReflexAngle,h=Ct(m,y,g,b);if(!h)return null;const P=h.start.clone(),D=h.end.clone();let S=Sn(u,P,f,D);if(S){const N=Math.max(1e-6,u.distanceTo(f));Math.max(S.distanceTo(u),S.distanceTo(f))>N*8&&(S=null)}return S||(S=new C().addVectors(u,f).multiplyScalar(.5)),{...o,__2d:{N:i.n,P:i.p,basis:c,A_p:u,B_p:f,A_d:P,B_d:D,V2:S,sweep:h.sweep,dirSign:h.dirSign,angleRad:h.angleRad,angleType:h.angleType,bisector:h.bisector}}}catch{return null}}d(Nt,"computeAngleElementsWithGeometry");function ut(e,t,n,o){try{if(t?.planeRefName){const a=e.viewer?.partHistory?.scene?.getObjectByName(t.planeRefName);if(a){const l=ie(e.viewer,a)||new p(0,0,1);if(l.lengthSq()>1e-12){const c=v(e.viewer,a)||new p;return{n:l.clone().normalize(),p:c}}}}if(n?.dirA&&n?.dirB){const a=new p().crossVectors(n.dirA,n.dirB);if(a.lengthSq()>1e-12){const l=n.pointA&&n.pointB?new p().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n.pointA||n.pointB||new p;return{n:a.normalize(),p:l}}}const r=(o?.alignNormal?o.alignNormal("view",t):null)||n?.plane||new p(0,0,1),s=n?.pointA&&n?.pointB?new p().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n?.pointA||n?.pointB||new p;return{n:r.clone().normalize(),p:s}}catch{return{n:new p(0,0,1),p:new p}}}d(ut,"resolveAnglePlane");function Fe(e,t,n,o){try{if(!t)return null;const i=e?.viewer?.partHistory?.scene;if(!i)return null;const r=i.getObjectByName(t);if(!r)return null;const s=n&&n.lengthSq()>1e-12?n.clone().normalize():new p(0,0,1),a=v(e.viewer,r)||o||new p,l=o||a,c=new B().setFromNormalAndCoplanarPoint(s,l),u=ie(e.viewer,r),f=u?u.clone().normalize():null,m=r?.userData||{},y=String(r?.type||"").toUpperCase(),g=String(m.type||m.brepType||"").toUpperCase(),h=y==="FACE"||y==="PLANE"||!(y==="FACE"||y==="EDGE"||y==="PLANE")&&(g==="FACE"||g==="PLANE");if(y==="EDGE"||!h&&(g==="EDGE"||r?.isLine||r?.isLine2||r?.isLineSegments||r?.isLineLoop)){const w=tr(r,c,l);if(w)return w}if(h&&f&&f.lengthSq()>1e-12){const w=f.clone().normalize(),x=new p().crossVectors(w,s),T=x.lengthSq();if(T>1e-12){const M=w.dot(a),E=s.dot(l),z=new p().crossVectors(s,x).multiplyScalar(M),q=new p().crossVectors(x,w).multiplyScalar(E),R=z.add(q).divideScalar(T);return{p:c.projectPoint(R,R.clone()),d:x.normalize()}}}let D=a.clone();if(f&&f.lengthSq()>1e-12){const w=f.dot(s);if(Math.abs(w)>1e-9){const T=l.clone().clone().sub(a).dot(s)/w;D=a.clone().addScaledVector(f,T)}}const S=c.projectPoint(D,D.clone());let N=f?f.clone().projectOnPlane(s):null;return(!N||N.lengthSq()<1e-12)&&(N=at(s).U.clone()),N.normalize(),{p:S,d:N}}catch{return null}}d(Fe,"lineInPlaneForElement");function tr(e,t,n){const o=nr(e);if(!Array.isArray(o)||o.length<2)return null;const i=[];for(const u of o)u&&i.push(t.projectPoint(u,u.clone()));if(i.length<2)return null;let r=0,s=1,a=0;for(let u=0;u<i.length;u++)for(let f=u+1;f<i.length;f++){const m=i[u].distanceToSquared(i[f]);m>a&&(a=m,r=u,s=f)}if(a<=1e-12)return null;const l=i[s].clone().sub(i[r]).normalize();let c=i[r].clone();if(n){let u=c.distanceToSquared(n);for(let f=0;f<i.length;f++){const m=i[f].distanceToSquared(n);m<u&&(u=m,c=i[f].clone())}}return{p:c,d:l}}d(tr,"edgeLineInPlane");function nr(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}const t=e.matrixWorld||null,n=[],o=d(l=>{const c=Pt(l);if(!c)return;const u=n[n.length-1];u&&u.distanceToSquared(c)<=1e-14||n.push(c)},"pushUnique");try{if(typeof e.points=="function"){const l=e.points(!0);if(Array.isArray(l))for(const c of l)o(c);if(n.length>=2)return n;n.length=0}}catch{}const i=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(i){for(const l of i){const c=Pt(l);c&&(t&&c.applyMatrix4(t),o(c))}if(n.length>=2)return n;n.length=0}const r=e?.geometry?.attributes?.instanceStart,s=e?.geometry?.attributes?.instanceEnd;if(r&&s){const l=Math.min(r.count||0,s.count||0);for(let c=0;c<l;c++){const u=new p(r.getX(c),r.getY(c),r.getZ(c)),f=new p(s.getX(c),s.getY(c),s.getZ(c));t&&(u.applyMatrix4(t),f.applyMatrix4(t)),o(u),o(f)}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 l=0;l<a.count;l++){const c=new p(a.getX(l),a.getY(l),a.getZ(l));t&&c.applyMatrix4(t),o(c)}if(n.length>=2)return n}return null}d(nr,"getEdgeWorldPoints");function Pt(e){if(!e)return null;if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3)return new p(e[0]||0,e[1]||0,e[2]||0);if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),o=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(o))return new p(t,n,o)}return null}d(Pt,"pointFromAny");const rr={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:d(({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 F{static showContexButton(t){const n=F._collectSelectionRefs(t,["VERTEX"]);return n.length?{params:{target:n}}:!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:o,idx:i,ctx:r}=t,s=this.inputParams||{},a=st();Dt(s),s.anchorPosition=Et(s.anchorPosition??s.anchorSide),delete s.anchorSide;const l=n?.viewer,c=l?.partHistory?.scene,u=Tt(l,c,s),f=Mt(n,s,u,r),m=r?.formatReferenceLabel?r.formatReferenceLabel(s,Ce(s.text)):Ce(s.text);if(s.value=m,f&&r?.updateLabel?.(i,m,f,s),!u.length||!f)return u.length?r?.reportAnnotationError?.("Leader annotation could not resolve a label position."):r?.reportAnnotationError?.("Leader annotation could not resolve any selected targets."),[];const y=a.lineColor??9684477,g=Je(n,l),b=et(u)||f,h=ir(f,b,g),P=Math.max(r?.screenSizeWorld?r.screenSizeWorld(18):L(l,18),1e-4),D=Math.max(r?.screenSizeWorld?r.screenSizeWorld(36):L(l,36),1e-4),S=sr(u,g,f),N=(S.length-1)*.5;return S.forEach(({point:w,order:x})=>{const T=(x-N)*P,M=f.clone().addScaledVector(h,-D).addScaledVector(g.up,T);if(o.add(Y(w,M,y)),o.add(Y(M,f,y)),s.endStyle==="dot"){const E=a.leaderDotRadiusPx??6,z=r?.screenSizeWorld?r.screenSizeWorld(E):L(l,E),q=Oe(Math.max(z,1e-4),a.dotColor??y);q.position.copy(w),o.add(q)}else{const E=w.clone().sub(M);E.lengthSq()||E.copy(h),E.normalize();const z=a.arrowLengthPx??12,q=a.arrowWidthPx??4,R=r?.screenSizeWorld?r.screenSizeWorld(z):L(l,z),K=r?.screenSizeWorld?r.screenSizeWorld(q):L(l,q);oe(o,w,E,R,K,a.arrowColor??y)}}),[]}static applyParams(t,n,o){return super.applyParams(t,n,o),n.text=Ce(n.text),Array.isArray(n.target)||(n.target=n.target?[String(n.target)]:[]),n.anchorPosition=Et(n.anchorPosition??n.anchorSide),delete n.anchorSide,n.endStyle=or(n.endStyle),{paramsPatch:{}}}static onLabelPointerDown(t,n,o,i,r){try{const s=t?.viewer,a=Tt(s,s?.partHistory?.scene,o),l=Mt(t,o,a,r)||new p,u=Je(t,s,o).forward,f=a&&a.length&&a[0]?a[0]:et(a)||l;if(!r?.raycastFromEvent)return;const m=new B().setFromNormalAndCoplanarPoint(u,f);H.dragLabelOnPlane(t,r,{makePlane:d(()=>m,"makePlane"),onDrag:d(y=>{Dt(o),o.persistentData.labelWorld=[y.x,y.y,y.z],r.updateLabel(n,null,y,o),t?.refreshAnnotationsUI?.()},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d(H,"LeaderAnnotation"),A(H,"entityType","leader"),A(H,"type","leader"),A(H,"shortName","LEAD"),A(H,"longName","Leader"),A(H,"title","Leader"),A(H,"inputParamsSchema",rr);let Ke=H;function Dt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(Dt,"ensurePersistentData$1");function Ce(e){return typeof e=="string"?e:e==null?"":String(e)}d(Ce,"sanitizeText$1");function Et(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 o=n.toLowerCase();if(o==="left")return"Left Middle";if(o==="right")return"Right Middle";if(o==="left-top"||o==="lefttop")return"Left Top";if(o==="left-bottom"||o==="leftbottom")return"Left Bottom";if(o==="right-top"||o==="righttop")return"Right Top";if(o==="right-bottom"||o==="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"}d(Et,"normalizeAnchorPosition$1");function or(e){return e==="dot"?"dot":"arrow"}d(or,"normalizeEndStyle");function Tt(e,t,n){const o=Array.isArray(n?.target)?n.target:[];if(!o.length||!t)return[];const i=[],r=new Set;for(const s of o){const a=typeof s=="string"?s:String(s??"");if(!(!a||r.has(a))){r.add(a);try{const l=t.getObjectByName?.(a);if(!l)continue;let c=v(e,l);!c&&typeof l.getWorldPosition=="function"&&(c=l.getWorldPosition(new p)),c&&i.push(c.clone())}catch{}}}return i}d(Tt,"resolveTargetPoints");function Mt(e,t,n,o){const i=e?.viewer,r=Je(e,i),s=n&&n.length&&n[0]?n[0].clone():et(n)||new p,a=r?.forward&&r.forward.lengthSq()?r.forward.clone():new p(0,0,1),l=new B().setFromNormalAndCoplanarPoint(a,s),c=cr(t?.persistentData?.labelWorld);if(c){const b=c.clone();return l.projectPoint(b,b),b}const u=Math.max(o?.screenSizeWorld?o.screenSizeWorld(90):L(i,90),1e-4),f=Math.max(o?.screenSizeWorld?o.screenSizeWorld(36):L(i,36),1e-4),m=r?.right&&r.right.lengthSq()?r.right.clone():new p(1,0,0),y=r?.up&&r.up.lengthSq()?r.up.clone():new p(0,1,0),g=s.clone().addScaledVector(m,u).addScaledVector(y,f);return l.projectPoint(g,g),g}d(Mt,"resolveLabelPosition");function Je(e,t,n){const o=ar(e?.viewEntry?.camera);if(o)return o;const i=new p(0,0,-1),r=new p(0,1,0);try{t?.camera?.getWorldDirection&&(t.camera.getWorldDirection(i),i.normalize()),t?.camera?.up&&r.copy(t.camera.up).normalize()}catch{}i.lengthSq()||i.set(0,0,-1),r.lengthSq()||r.set(0,1,0);const s=new p().crossVectors(i,r);s.lengthSq()||(Math.abs(i.z)<.9?r.set(0,0,1):r.set(1,0,0),s.crossVectors(i,r)),s.normalize();const a=new p().crossVectors(s,i);a.lengthSq()||a.copy(r.lengthSq()?r:new p(0,1,0)),a.normalize();const l=i.clone().normalize();return{right:s,up:a,forward:l}}d(Je,"computeViewBasis$1");function ir(e,t,n){try{const i=e.clone().sub(t||new p);if(i.lengthSq()>1e-10)return i.normalize()}catch{}const o=n?.right?.clone?.()||new p(1,0,0);return o.lengthSq()||o.set(1,0,0),o.normalize()}d(ir,"computeShoulderDirection");function sr(e,t,n){if(!e.length)return[];const o=t?.up&&t.up.lengthSq()?t.up:new p(0,1,0),i=e.map((r,s)=>{const l=r.clone().sub(n||new p).dot(o);return{point:r,metric:l,index:s}});return i.sort((r,s)=>r.metric-s.metric),i.map((r,s)=>({point:r.point,order:s}))}d(sr,"sortTargetsByViewUp");function ar(e){if(!e||typeof e!="object")return null;const t=lr(e);if(!t)return null;const n=new p(0,0,-1).applyQuaternion(t);if(!n.lengthSq())return null;const o=new p(0,1,0).applyQuaternion(t);let i=new p().crossVectors(n,o);i.lengthSq()||(i=new p().crossVectors(n,new p(0,1,0))),i.lengthSq()||i.set(1,0,0),i.normalize();const r=new p().crossVectors(i,n);r.lengthSq()||r.copy(o.lengthSq()?o:new p(0,1,0)),r.normalize();const s=n.clone().normalize();return{right:i,up:r,forward:s}}d(ar,"basisFromSavedCamera");function lr(e){const t=e?.quaternion||e?.camera?.quaternion;if(Array.isArray(t)&&t.length>=4){const[i,r,s,a]=t;if([i,r,s,a].every(l=>Number.isFinite(l)))return new V(i,r,s,a).normalize()}if(t&&typeof t=="object"){const i=Number(t.x),r=Number(t.y),s=Number(t.z),a=Number(t.w);if([i,r,s,a].every(l=>Number.isFinite(l)))return new V(i,r,s,a).normalize()}const n=e?.worldMatrix||e?.cameraMatrix||e?.matrix,o=Array.isArray(n?.elements)?n.elements:n;if(Array.isArray(o)&&o.length===16){const i=new pe().fromArray(o),r=new p,s=new V,a=new p;return i.decompose(r,s,a),s.normalize()}return null}d(lr,"quaternionFromSnapshot");function cr(e){if(!e&&e!==0)return null;if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3){const[t,n,o]=e;return[t,n,o].some(i=>typeof i!="number"||!Number.isFinite(i))?null:new p(t,n,o)}if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),o=Number(e.z);if([t,n,o].every(i=>Number.isFinite(i)))return new p(t,n,o)}return null}d(cr,"vectorFromAny");function et(e){if(!e||!e.length)return null;const t=new p;return e.forEach(n=>t.add(n)),t.multiplyScalar(1/e.length)}d(et,"averageTargets");const ur={id:{type:"string",default_value:null,hint:"unique identifier for the note"},text:{type:"string",default_value:"",defaultResolver:d(({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 F{static showContexButton(t){const n=F._normalizeSelectionItems(t);if(!n.length)return!1;const o=n[0],i=v(null,o);return i?{params:{position:{x:i.x,y:i.y,z:i.z}}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:o,idx:i,ctx:r}=t,s=this.inputParams,a=st(),l=new p(s.position?.x||0,s.position?.y||0,s.position?.z||0),c=new an(a.noteDotRadius??.08,16,12),u=new ln({color:a.noteDotColor??a.dotColor??9684477,depthTest:!1,depthWrite:!1,transparent:!0}),f=new cn(c,u);f.position.copy(l),o.add(f);const m=String(s.text||"");if(!m)return[];let y=null;if(s.labelWorld)y=new p(s.labelWorld.x,s.labelWorld.y,s.labelWorld.z);else{const g=r.alignNormal("view",s),b=new p,h=new p(0,1,0);try{n.viewer?.camera?.getWorldDirection?.(b),b.crossVectors(g,h).normalize()}catch{b.set(1,0,0)}const P=r.screenSizeWorld(16);y=l.clone().addScaledVector(b,P).addScaledVector(g,P*.25)}return r.updateLabel(i,m,y,s),[]}static getSchema(t,n){const o={text:{type:"string",label:"Text",default_value:n.text||""}},i={text:o.text.default_value};return{schema:o,params:i}}static applyParams(t,n,o){return super.applyParams(t,n,o),n.text=fr(n.text),{paramsPatch:{}}}static onLabelPointerDown(t,n,o,i,r){try{if(!t.viewer?.camera)return;const l=r.alignNormal?r.alignNormal(o.alignment||"view",o):new p(0,0,1),c=o.labelWorld?new p(o.labelWorld.x,o.labelWorld.y,o.labelWorld.z):new p(o.position?.x||0,o.position?.y||0,o.position?.z||0),u=new B().setFromNormalAndCoplanarPoint(l,c);k.dragLabelOnPlane(t,r,{makePlane:d(()=>u,"makePlane"),onDrag:d(f=>{o.labelWorld={x:f.x,y:f.y,z:f.z};try{r.updateLabel(n,null,f,o)}catch{}},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d(k,"NoteAnnotation"),A(k,"entityType","note"),A(k,"type","note"),A(k,"shortName","NOTE"),A(k,"longName","Note"),A(k,"title","Note"),A(k,"inputParamsSchema",ur);let tt=k;function fr(e){return typeof e=="string"?e:e==null?"":String(e)}d(fr,"sanitizeText");const pr={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 F{static showContexButton(t){const n=F._collectSelectionRefs(t,["SOLID","COMPONENT"]);return n.length?{params:{targets:n}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:o,ctx:i}=t;if(!n||!o)return i?.reportAnnotationError?.("Explode annotation could not access the PMI render context."),[];const r=this.inputParams||{};zt(r),r.transform=Be(r.transform);const s=W._resolveSolidReferences(r,n,!0);if(!s.length)return i?.reportAnnotationError?.("Explode annotation could not resolve any target solids."),[];const a=W._ensureOriginalSnapshots(r,s,!1,n?.viewer),l=r.showTraceLine!==!1;let c=n?.__explodeTraceState;c instanceof Map||(c=new Map,n&&(n.__explodeTraceState=c));const u=_(r.transform.position,new p(0,0,0)),f=qt(r.transform.rotationEuler),m=_(r.transform.scale,new p(1,1,1));return s.forEach(y=>{try{const g=a.get(y.uuid),b=_(g?.centerLocal)||Qt(y),h=c?.get(y.uuid)?.clone()||gr(g),P=Wt(h,b)||_(g?.centerWorld)||_(g?.worldPosition),D=wr(h,u,f,m),S=Wt(D,b)||hr(y);Rt(P)&&Rt(S)&&P.distanceToSquared(S)>=1e-8&&l&&o.add(fn(P,S,16098596,{viewer:n?.viewer})),c?.set(y.uuid,D)}catch{}}),[]}static _resolveSolidReferences(t,n,o=!1){if(!t||!n)return[];const i=n.viewer,r=i?.partHistory?.scene||i?.scene;if(!r)return[];if(!o&&Array.isArray(t.__resolvedSolids)&&t.__resolvedSolids.length){const l=t.__resolvedSolids.filter(c=>c&&c.isObject3D);return ce(t,"__resolvedSolids",l),ce(t,"solids",l),l}const s=Array.isArray(t.targets)?t.targets:[],a=[];return s.forEach(l=>{const c=mr(l,r);c&&c.isObject3D&&a.push(c)}),ce(t,"__resolvedSolids",a),ce(t,"solids",a),a}static _ensureOriginalSnapshots(t,n,o=!1,i=null){zt(t);let r=t.__originalSnapshots;return r instanceof Map||(r=Lt(t.persistentData?.originalTransforms)),r instanceof Map||(r=new Map),(Array.isArray(n)?n:[]).forEach(a=>{!a||!a.uuid||(o||!r.has(a.uuid))&&r.set(a.uuid,Ft(a,i))}),ce(t,"__originalSnapshots",r),t.persistentData.originalTransforms=yr(r),r}static getOriginalSnapshotMap(t){if(!t)return new Map;if(t.__originalSnapshots instanceof Map)return t.__originalSnapshots;const n=Lt(t?.persistentData?.originalTransforms);return ce(t,"__originalSnapshots",n instanceof Map?n:new Map),t.__originalSnapshots}static applyTransformsToSolids(t,n,o={}){if(!t||!n)return;const i=W._resolveSolidReferences(t,n,!0);if(!i.length)return;const r=o&&o.startSnapshots instanceof Map?o.startSnapshots:W.getOriginalSnapshotMap(t),s=o?.cumulativeState instanceof Map?o.cumulativeState:null,a=Be(t.transform);t.transform=a;const l=_(a.position,new p(0,0,0)),c=qt(a.rotationEuler),u=_(a.scale,new p(1,1,1));i.forEach(f=>{if(!f||!f.uuid)return;const m=r.get(f.uuid)||W.getOriginalSnapshotMap(t).get(f.uuid)||Ft(f,n?.viewer);if(!m)return;const y=_(m.position,new p(0,0,0)),g=rt(m.quaternion,new V),b=_(m.scale,new p(1,1,1)),h=y.clone().add(l),P=g.clone().multiply(c),D=b.clone().multiply(u);if(f.position.copy(h),f.quaternion.copy(P),f.scale.copy(D),f.updateMatrixWorld(!0),s){const S=f.getWorldPosition(new p);s.set(f.uuid,{position:h.toArray(),quaternion:P.toArray(),scale:D.toArray(),worldPosition:S.toArray()})}})}static restoreOriginalTransforms(t,n){if(!t||!n)return;const o=W._resolveSolidReferences(t,n,!0);if(!o.length)return;const i=W.getOriginalSnapshotMap(t);o.forEach(r=>{if(!r||!r.uuid)return;const s=i.get(r.uuid);if(!s)return;const a=_(s.position,new p(0,0,0)),l=rt(s.quaternion,new V),c=_(s.scale,new p(1,1,1));r.position.copy(a),r.quaternion.copy(l),r.scale.copy(c),r.updateMatrixWorld(!0)})}static applyParams(t,n,o){super.applyParams(t,n,o),n.targets=dr(n.targets),n.transform=Be(n.transform),n.showTraceLine=n.showTraceLine!==!1;try{t&&typeof t.applyViewTransformsSequential=="function"&&t.applyViewTransformsSequential()}catch{}return{paramsPatch:{}}}};d(W,"ExplodeBodyAnnotation"),A(W,"entityType","exp"),A(W,"type","exp"),A(W,"shortName","EXP"),A(W,"longName","Explode Body"),A(W,"title","Explode Body"),A(W,"inputParamsSchema",pr),A(W,"aliases",["viewTransform"]);let nt=W;function zt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(zt,"ensurePersistent");function ce(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}}d(ce,"setHiddenProperty");function Be(e){const t=e&&typeof e=="object"?e:{},n=d((o,i)=>{if(!Array.isArray(o))return i.slice();const r=i.slice();for(let s=0;s<r.length;s+=1){const a=Number(o[s]);r[s]=Number.isFinite(a)?a:r[s]}return r},"sanitizeArray");return{position:n(t.position,[0,0,0]),rotationEuler:n(t.rotationEuler,[0,0,0]),scale:n(t.scale,[1,1,1])}}d(Be,"sanitizeTransform");function dr(e){return Array.isArray(e)?e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length):[]}d(dr,"arrayOfStrings");function mr(e,t){if(!t||!e&&e!==0)return null;let n=null;if(typeof e=="string"&&e.trim().length){const i=e.trim();if(i[0]==="{")try{n=JSON.parse(i)}catch{n={name:i}}else n={name:i}}else typeof e=="object"&&(n={...e});if(!n)return null;const o=[];n.name&&typeof n.name=="string"&&o.push(n.name.trim()),Array.isArray(n.path)&&n.path.length&&o.push(String(n.path[n.path.length-1]));for(const i of o){if(!i)continue;const r=t.getObjectByName(i);if(r&&r.type==="SOLID"||r)return r}if(typeof n.uuid=="string"){const i=t.getObjectByProperty("uuid",n.uuid);if(i)return i;const r=vt(t,s=>s?.userData?.__pmiExportSourceUuid===n.uuid);if(r)return r}if(Number.isInteger(n.id)){try{const r=t.getObjectById(n.id);if(r)return r}catch{}const i=vt(t,r=>r?.userData?.__pmiExportSourceId===n.id);if(i)return i}return null}d(mr,"resolveSolidObject");function vt(e,t){if(!e?.traverse||typeof t!="function")return null;let n=null;return e.traverse(o=>{if(!(n||!o?.isObject3D))try{t(o)&&(n=o)}catch{}}),n}d(vt,"findExportCloneMatch");function Ft(e,t=null){try{e.updateMatrixWorld(!0)}catch{}const n=e.position.clone(),o=e.quaternion.clone(),i=e.scale.clone(),r=e.getWorldPosition(new p),s=Qt(e),a=s.clone().applyMatrix4(new pe().compose(n.clone(),o.clone(),i.clone()));return{position:n.toArray(),quaternion:o.toArray(),scale:i.toArray(),worldPosition:r.toArray(),centerWorld:a.toArray(),centerLocal:s.toArray()}}d(Ft,"captureSnapshot");function Lt(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}d(Lt,"snapshotArrayToMap");function yr(e){if(!(e instanceof Map))return[];const t=[];return e.forEach((n,o)=>{o&&t.push({uuid:o,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}d(yr,"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 o=0;o<e.length;o+=1)n.push(Number(e[o]));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()}d(j,"toArray");function _(e,t){if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3){const n=Number(e[0]),o=Number(e[1]),i=Number(e[2]);if([n,o,i].every(r=>Number.isFinite(r)))return new p(n,o,i)}return e&&typeof e=="object"&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)?new p(e.x,e.y,e.z):t&&t.isVector3?t.clone():new p}d(_,"vectorFromArray");function rt(e,t){if(Array.isArray(e)&&e.length>=4){const n=Number(e[0]),o=Number(e[1]),i=Number(e[2]),r=Number(e[3]);if([n,o,i,r].every(s=>Number.isFinite(s)))return new V(n,o,i,r)}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}d(rt,"quaternionFromArray");function qt(e){const t=Array.isArray(e)?e:[0,0,0],n=Number(t[0])||0,o=Number(t[1])||0,i=Number(t[2])||0;try{return new V().setFromEuler(new un(Ee.degToRad(n),Ee.degToRad(o),Ee.degToRad(i),"XYZ"))}catch{return new V}}d(qt,"quaternionFromEuler");function Qt(e){try{if(!e)return new p;e.updateMatrixWorld?.(!0);const t=new qe().setFromObject(e);if(!t.isEmpty()){const o=t.getCenter(new p).clone();return e.worldToLocal(o),o}}catch{}return new p}d(Qt,"getSolidLocalCenter");function hr(e){try{if(!e)return new p;e.updateMatrixWorld?.(!0);const t=new qe().setFromObject(e);if(!t.isEmpty())return t.getCenter(new p)}catch{}try{return e.getWorldPosition(new p)}catch{return new p}}d(hr,"getSolidWorldCenter");function Rt(e){return!e||!e.isVector3?!1:Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}d(Rt,"isFiniteVec3");function gr(e){if(!e||typeof e!="object")return Se(new p,new V,new p(1,1,1));const t=_(e.position,new p),n=rt(e.quaternion,new V),o=_(e.scale,new p(1,1,1));return Se(t,n,o)}d(gr,"transformEntryFromSnapshot");function wr(e,t,n,o){const i=e||Se(new p,new V,new p(1,1,1)),r=i.position.clone().add(t||new p),s=i.quaternion.clone().multiply(n||new V),a=i.scale.clone().multiply(o||new p(1,1,1));return Se(r,s,a)}d(wr,"composeTransformEntry");function Wt(e,t){if(!e||!t||!t.isVector3)return null;const n=new pe().compose(e.position.clone(),e.quaternion.clone(),e.scale.clone());return t.clone().applyMatrix4(n)}d(Wt,"applyTransformEntryToPoint");function Se(e,t,n){return{position:e.clone(),quaternion:t.clone(),scale:n.clone(),clone(){return Se(this.position,this.quaternion,this.scale)}}}d(Se,"makeTransformEntry");const br={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 F{static showContexButton(t){const n=F._normalizeSelectionItems(t),o=new Set(["VERTEX","EDGE","FACE"]);for(const i of n){if(!F._isSelectionType(i,o)||!Ar(i))continue;const r=F._selectionRefName(i);if(r)return{params:{target:r}}}return!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:o,idx:i,ctx:r}=t,s=this.inputParams||{},a=n?.viewer,l=a?.partHistory?.scene,c=Vt(a,s.target),u=v(l,c),f=Sr(a?.partHistory,c,u,s.target),m=f?.center?Te(f.center):u;if(!m)return r?.reportAnnotationError?.("Hole callout could not resolve the selected target."),[];if(!f)return r?.reportAnnotationError?.("Hole callout could not identify hole metadata for the selected target."),[];const y=zr(s,f,a?.partHistory),g=f?Nr(f,y,{showQuantity:s.showQuantity!==!1,beforeText:s.beforeText,afterText:s.afterText}):"";s.value=g;const b=_t(a),h=r?.screenSizeWorld?r.screenSizeWorld(80):L(a,80),P=r?.screenSizeWorld?r.screenSizeWorld(30):L(a,30),S=Te(s?.persistentData?.labelWorld)||m.clone().addScaledVector(b.right,Pr(s.anchorPosition||"Right Top")*h).addScaledVector(b.up,Dr(s.anchorPosition||"Right Top")*P);r?.updateLabel&&r.updateLabel(i,g,S,s);const N=st(),w=N.lineColor??16771584;o.add(Y(S,m,w));const x=N.arrowLengthPx??12,T=N.arrowWidthPx??4,M=r?.screenSizeWorld?r.screenSizeWorld(x):L(a,x),E=r?.screenSizeWorld?r.screenSizeWorld(T):L(a,T),z=m.clone().sub(S);return z.lengthSq()>1e-12&&(z.normalize(),oe(o,m,z,M,E,N.arrowColor??w)),[]}static applyParams(t,n,o){super.applyParams(t,n,o);const i=Number(n?.quantity);return n.quantity=Number.isFinite(i)?Math.max(0,Math.round(i)):1,n.showQuantity=n.showQuantity!==!1,n.beforeText=Le(n.beforeText),n.afterText=Le(n.afterText),n.anchorPosition=Er(n.anchorPosition),{paramsPatch:{}}}static onLabelPointerDown(t,n,o,i,r){const s=t?.viewer,a=Vt(s,o.target),l=s?.partHistory?.scene,c=v(l,a)||Te(o?.persistentData?.labelWorld);if(!c)return;const f=_t(s).forward;if(!r?.raycastFromEvent)return;const m=new B().setFromNormalAndCoplanarPoint(f,c);G.dragLabelOnPlane(t,r,{makePlane:d(()=>m,"makePlane"),suspendControls:!0,onDrag:d(y=>{Mr(o),o.persistentData.labelWorld=[y.x,y.y,y.z],r.updateLabel(n,null,y,o),t?.refreshAnnotationsUI?.()},"onDrag")})}};d(G,"HoleCalloutAnnotation"),A(G,"entityType","holeCallout"),A(G,"type","holeCallout"),A(G,"shortName","HOLE"),A(G,"longName","Hole Callout"),A(G,"title","Hole Callout"),A(G,"inputParamsSchema",br);let ot=G;function Vt(e,t){if(!e||!t)return null;const n=e.partHistory?.scene;if(!n)return null;if(typeof t=="string"){const o=n.getObjectByName?.(t);if(o)return o;const i=Me(t);for(const s of i){const a=n.getObjectByName?.(s);if(a)return a}let r=null;try{n.traverse(s=>{if(r)return;const a=s?.name?String(s.name):"";if(a){for(const l of i)if(l&&(a===l||a.endsWith(l)||a.includes(l))){r=s;return}}})}catch{}if(r)return r}return typeof t=="object"?t:n.getObjectByName?.(String(t))||null}d(Vt,"resolveTargetObject");function Sr(e,t,n,o=null){const i=Array.isArray(e?.features)?e.features:[],r=[];for(const u of i){const f=Array.isArray(u?.persistentData?.holes)?u.persistentData.holes:[];for(const m of f)r.push(m)}if(!r.length)return null;const s=t?.userData?.hole||t?.userData?.metadata?.hole;if(s)return s;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,l=Me(o,a);if(t?.name)for(const u of Me(t.name))l.add(u);const c=r.filter(u=>{const f=u?.sourceName?String(u.sourceName):null,m=u?.featureId?String(u.featureId):null,y=u?.targetId?String(u.targetId):null;return f&&l.has(f)||m&&l.has(m)||y&&l.has(y)});if(c.length===1)return c[0];if(c.length>1&&n){const u=re(c,n);if(u)return u}if(a){const u=r.filter(f=>f?.targetId&&String(f.targetId)===String(a));if(u.length===1)return u[0];if(u.length>1&&n){const f=re(u,n);if(f)return f}}if(o){const u=String(o),f=r.filter(m=>{const y=m?.featureId?String(m.featureId):"",g=m?.sourceName?String(m.sourceName):"";return y&&u.includes(y)||g&&u.includes(g)});if(f.length===1)return f[0];if(f.length>1&&n){const m=re(f,n);if(m)return m}}if(l.size){const u=r.filter(f=>{const m=f?.featureId?String(f.featureId):"",y=f?.sourceName?String(f.sourceName):"",g=f?.targetId?String(f.targetId):"";return l.has(m)||l.has(y)||l.has(g)});if(u.length===1)return u[0];if(u.length>1&&n){const f=re(u,n);if(f)return f}}if(n){const u=re(r,n);if(u)return u}if(t?.parent){const u=Me(t.parent.name),f=r.filter(m=>{const y=m?.featureId?String(m.featureId):"",g=m?.sourceName?String(m.sourceName):"",b=m?.targetId?String(m.targetId):"";return u.has(y)||u.has(g)||u.has(b)});if(f.length===1)return f[0];if(f.length>1&&n){const m=re(f,n);if(m)return m}}if(n){const u=re(r,n);if(u)return u}return r[0]}d(Sr,"findHoleDescriptor");function xr(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 i=e.getMetadata();if(i?.hole)return i.hole;if(i?.metadata?.hole)return i.metadata.hole}catch{}const n=e?.name||t?.faceName||null,o=e?.parentSolid||t?.parentSolid||null;if(n&&o&&typeof o.getFaceMetadata=="function")try{const i=o.getFaceMetadata(n);if(i?.hole)return i.hole}catch{}return null}d(xr,"readHoleMetadata");function Ar(e){if(!e)return!1;const t=[e],n=new Set,o=d(i=>Object.prototype.hasOwnProperty.call(i,"faces"),"hasOwnFaces");for(;t.length;){const i=t.shift();if(!(!i||n.has(i))){if(n.add(i),xr(i))return!0;if(o(i)&&Array.isArray(i.faces))for(const r of i.faces)t.push(r);else if(i.type==="SOLID"||i.type==="COMPONENT"){const r=Array.isArray(i.children)?i.children:[];for(const s of r)s&&s.type==="FACE"&&t.push(s)}i.parent&&t.push(i.parent)}}return!1}d(Ar,"hasHoleMetadata");function Nr(e,t=1,n={}){if(!e)return"";const o=[],i=Le(n.beforeText);i&&o.push(i);const s=n.showQuantity!==!1&&t>1?`${t}× `:"",a=Number(e.totalDepth??e.straightDepth),l=!e.throughAll&&a>0?` ↧ ${ue(a)}`:e.throughAll?" THRU ALL":"";o.push(`${s}⌀${ue(e.diameter)}${l}`),e.type==="COUNTERSINK"?o.push(`⌵ ⌀${ue(e.countersinkDiameter)} × ${ue(e.countersinkAngle,0)}°`):e.type==="COUNTERBORE"&&o.push(`⌴ ⌀${ue(e.counterboreDiameter)} ↧ ${ue(e.counterboreDepth)}`);const c=Tr(e?.thread);c&&o.push(c);const u=Le(n.afterText);return u&&o.push(u),o.join(`
1
+ var yt=Object.defineProperty;var on=(e,t,n)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var d=(e,t)=>yt(e,"name",{value:t,configurable:!0});var A=(e,t,n)=>on(e,typeof t!="symbol"?t+"":t,n);import{L as sn}from"./ListEntityBase-DIaWtqmZ.js";import{a6 as B,V as p,a as C,M as pe,B as qe,b as Ee,Q as V,u as an,s as ln,f as cn,af as un}from"./featureDialogs-DkPbRjYq.js";import{b as L,i as Y,d as oe,o as v,c as ie,m as Oe,g as st,j as fn}from"./annUtils-DGfVy9U3.js";const I=class I extends sn{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(I._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 o=I._normalizeSelectionItems(t),i=Array.isArray(n)?new Set(n.map(s=>I._normalizeSelectionType(s))):null,r=[];for(const s of o){if(!I._isSelectionType(s,i))continue;const a=I._selectionRefName(s);a&&r.push(a)}return r}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 o={},i={},r=n||{};for(const s in this.inputParamsSchema){if(!Object.prototype.hasOwnProperty.call(this.inputParamsSchema,s))continue;const a=this.inputParamsSchema[s]||{},l={...a},c=Object.prototype.hasOwnProperty.call(r,s)?U(r[s]):U(a.default_value);l&&Object.prototype.hasOwnProperty.call(l,"default_value")&&(l.default_value=U(c)),o[s]=l,i[s]=c}return{schema:o,params:i}}static applyParams(t,n,o){const i=pn(this.inputParamsSchema,o,n);return Object.assign(n,i),{paramsPatch:{}}}static ensurePersistentData(t){return!t||typeof t!="object"?null:((!t.persistentData||typeof t.persistentData!="object")&&(t.persistentData={}),t.persistentData)}static dragLabelOnPlane(t,n,o={}){if(!n||typeof o.makePlane!="function")return;const i=o.makePlane();if(!i||!(i instanceof B)&&!i.isPlane)return;const r=o.eventTarget||window,s=t?.viewer,a=d(c=>{const u=n.raycastFromEvent?n.raycastFromEvent(c):null;if(!u)return;const f=new p;(n.intersectPlane?n.intersectPlane(u,i,f):u.intersectPlane(i,f))&&typeof o.onDrag=="function"&&o.onDrag(f,c,i)},"onMove"),l=d(c=>{try{r.removeEventListener("pointermove",a,!0)}catch{}try{r.removeEventListener("pointerup",l,!0)}catch{}if(o.suspendControls===!0)try{s?.controls&&(s.controls.enabled=!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}if(typeof o.onEnd=="function")try{o.onEnd(c)}catch{}if(o.preventDefault!==!1)try{c.preventDefault(),c.stopImmediatePropagation?.(),c.stopPropagation()}catch{}},"onUp");try{t?.showDragPlaneHelper?.(i)}catch{}if(o.suspendControls===!0)try{s?.controls&&(s.controls.enabled=!1)}catch{}try{r.addEventListener("pointermove",a,!0)}catch{}try{r.addEventListener("pointerup",l,!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={})}};d(I,"BaseAnnotation"),A(I,"entityType","annotation"),A(I,"shortName","ANN"),A(I,"longName","Annotation"),A(I,"inputParamsSchema",{});let F=I;function pn(e,t,n){const o={},i=t&&typeof t=="object"?t:{};for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const s=e[r]||{};if(s.readOnly){n&&Object.prototype.hasOwnProperty.call(n,r)?o[r]=n[r]:o[r]=U(s.default_value);continue}const a=i[r],l=n&&Object.prototype.hasOwnProperty.call(n,r);if(a===void 0){o[r]=U(l?n[r]:s.default_value);continue}switch(s.type){case"number":{const c=Number(a);o[r]=Number.isFinite(c)?c:l&&Number.isFinite(n[r])?Number(n[r]):Number.isFinite(s.default_value)?s.default_value:0;break}case"boolean":o[r]=a==="false"?!1:!!a;break;case"options":{const c=Array.isArray(s.options)?s.options:[],u=a==null?"":String(a);c.includes(u)?o[r]=u:l&&c.includes(n[r])?o[r]=n[r]:o[r]=c.includes(s.default_value)?s.default_value:c[0]||"";break}case"reference_selection":{if(s.multiple){const c=Array.isArray(a)?a:a?[a]:[];o[r]=c.map(f=>f==null?"":String(f)).filter(f=>f.length);const u=dn(s.maxSelections);u!==null&&o[r].length>u&&(o[r]=o[r].slice(0,u)),!o[r].length&&l&&Array.isArray(n[r])&&(o[r]=n[r].slice(),u!==null&&o[r].length>u&&(o[r]=o[r].slice(0,u)))}else o[r]=a==null?l?String(n[r]??""):"":String(a);break}case"textarea":case"string":o[r]=a==null?l?String(n[r]??""):"":String(a);break;case"object":o[r]=U(a&&typeof a=="object"?a:s.default_value);break;case"transform":o[r]=mn(a,s.default_value);break;case"vec3":o[r]=yn(a,s.default_value);break;default:o[r]=U(a);break}}return o}d(pn,"sanitizeAnnotationParams");function dn(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.floor(t)):null}d(dn,"normalizeSelectionBound");function mn(e,t){const n=e&&typeof e=="object"?e:t||{},o=d((i,r,s=3)=>{const a=Array.isArray(i)?i:r&&Array.isArray(r)?r:[],l=[];for(let c=0;c<s;c+=1){const u=a[c],f=Number(u);l[c]=Number.isFinite(f)?f:0}return l},"toArray");return{position:o(n.position,t?.position||[0,0,0]),rotationEuler:o(n.rotationEuler,t?.rotationEuler||[0,0,0]),scale:o(n.scale,t?.scale||[1,1,1])}}d(mn,"normalizeTransform");function yn(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 o=[];for(let i=0;i<3;i+=1){const r=Number(n[i]);o[i]=Number.isFinite(r)?r:0}return o}d(yn,"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}d(U,"__cloneValue");function O(e,t,n,o=.01){const i=[];typeof t=="function"&&i.push(t),typeof n=="function"&&i.push(n);for(const r of i)try{const s=Number(r(e));if(Number.isFinite(s)&&s>0)return s}catch{}return o}d(O,"resolveScreenSizeWorld");function hn(e){if(!e||e.lengthSq()===0)return new p(0,0,1);const t=Math.abs(e.dot(new p(0,0,1)))<.9?new p(0,0,1):new p(0,1,0),n=new p().crossVectors(e,t);return n.lengthSq()===0&&n.crossVectors(e,new p(1,0,0)),n.lengthSq()===0?new p(1,0,0):n.normalize()}d(hn,"arbitraryPerpendicular3D");function Z(e){if(!e)return null;if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3)return new p(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),o=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(o))return new p(t,n,o)}return null}d(Z,"vectorFromAny$2");function gn(e){return e>1?1:e<-1?-1:e}d(gn,"clampToUnit");function wn(e,t){const n=e.x*t.y-e.y*t.x,o=e.x*t.x+e.y*t.y;return Math.atan2(n,o)}d(wn,"signedAngle2D");function bn(e,t){const n=Math.cos(t),o=Math.sin(t);return new C(e.x*n-e.y*o,e.x*o+e.y*n)}d(bn,"rotate2D");function at(e,t){const n=e.clone().normalize();let o=(t?t.clone():new p(1,0,0)).projectOnPlane(n);o.lengthSq()<1e-12&&(o=Math.abs(n.z)<.9?new p(0,0,1).cross(n):new p(0,1,0).cross(n)),o.normalize();const i=new p().crossVectors(n,o).normalize();return{U:o,V:i,N:n}}d(at,"planeBasis");function je(e,t,n){const o=e.clone().sub(t);return new C(o.dot(n.U),o.dot(n.V))}d(je,"to2D");function ze(e,t){return new C(e.dot(t.U),e.dot(t.V))}d(ze,"dirTo2D");function ne(e,t,n){return t.clone().add(n.U.clone().multiplyScalar(e.x)).add(n.V.clone().multiplyScalar(e.y))}d(ne,"from2D");function Sn(e,t,n,o){const i=t.x*o.y-t.y*o.x;if(Math.abs(i)<1e-12)return null;const r=new C().subVectors(n,e),s=(r.x*o.y-r.y*o.x)/i;return new C(e.x+t.x*s,e.y+t.y*s)}d(Sn,"intersectLines2D");function xn(e,t,n){const o=e.clone().sub(t).dot(n);return e.clone().sub(n.clone().multiplyScalar(o))}d(xn,"projectPointToPlane");function Ae(e,t,n,o){const i=n?e.clone().multiplyScalar(-1):e.clone(),r=o?t.clone().multiplyScalar(-1):t.clone(),s=gn(i.dot(r)),a=Math.acos(s),l=wn(i,r);return{A:i,B:r,angle:a,signedAngle:l}}d(Ae,"createAngleCombo");function Ct(e,t,n,o=!0){if(!e||!t)return null;const i=[Ae(e,t,!1,!1),Ae(e,t,!1,!0),Ae(e,t,!0,!1),Ae(e,t,!0,!0)],r=Math.PI/2,s=1e-6,a=d((l,c)=>l.length?l.slice().sort(c)[0]:null,"selectByAngle");if(n==="reflex"){const l=i[0],c=Math.abs(l.signedAngle),u=c<1e-6?0:2*Math.PI-c,f=-Math.sign(l.signedAngle||1),m=l.A.clone().add(l.B);return m.lengthSq()<1e-10&&m.set(-l.A.y,l.A.x),m.normalize().multiplyScalar(-1),{start:l.A.clone(),end:l.B.clone(),sweep:u,dirSign:f,angleRad:u,bisector:m,angleType:"reflex",signedAngle:l.signedAngle}}if(n==="acute"){if(!o){const m=i[0],y=m.A.clone().add(m.B);y.lengthSq()<1e-10&&y.set(-m.A.y,m.A.x),y.normalize();const g=Math.abs(m.signedAngle)<1e-8?1:Math.sign(m.signedAngle),b=Math.abs(m.signedAngle);return{start:m.A.clone(),end:m.B.clone(),sweep:b,dirSign:g,angleRad:b,bisector:y,angleType:"acute",signedAngle:m.signedAngle}}const l=i.filter(m=>m.angle<=r+s),c=a(l.length?l:i,(m,y)=>m.angle-y.angle);if(!c)return null;const u=c.A.clone().add(c.B);u.lengthSq()<1e-10&&u.set(-c.A.y,c.A.x),u.normalize();const f=Math.abs(c.signedAngle)<1e-8?1:Math.sign(c.signedAngle);return{start:c.A.clone(),end:c.B.clone(),sweep:c.angle,dirSign:f,angleRad:c.angle,bisector:u,angleType:"acute",signedAngle:c.signedAngle}}if(n==="obtuse"){const l=i.filter(m=>m.angle>=r-s);let c=a(l,(m,y)=>m.angle-y.angle);if(c||(c=a(i,(m,y)=>y.angle-m.angle)),!c)return null;const u=c.A.clone().add(c.B);u.lengthSq()<1e-10&&u.set(-c.A.y,c.A.x),u.normalize();const f=Math.abs(c.signedAngle)<1e-8?1:Math.sign(c.signedAngle);return{start:c.A.clone(),end:c.B.clone(),sweep:c.angle,dirSign:f,angleRad:c.angle,bisector:u,angleType:"obtuse",signedAngle:c.signedAngle}}return null}d(Ct,"resolveAngleOrientation2D");function An({planePoint:e=null,planeNormal:t=null,basis:n=null,vertex2D:o=null,directionA2D:i=null,directionB2D:r=null,sweepRad:s=0,sweepDirection:a=1,bisector2D:l=null,labelWorld:c=null,screenSizeWorld:u=null,fallbackScreenSizeWorld:f=null,defaultRadiusPixels:m=60,minRadiusPixels:y=30,arcDensity:g=64,minArcSteps:b=48,extensionPixels:h=25,stubPixels:P=12,labelOffsetPixels:D=70,arrowLengthPixels:S=10,arrowWidthPixels:N=4}={}){if(!e||!t||!n||!o||!i||!r)return null;const w=o.clone(),x=i.clone(),T=r.clone();if(x.lengthSq()<=1e-12||T.lengthSq()<=1e-12)return null;x.normalize(),T.normalize();const M=t.clone().normalize();let E=null;const z=Z(c);if(z){const le=xn(z,e,M);E=je(le,e,n).clone().sub(w).length()}(!Number.isFinite(E)||E<=0)&&(E=O(m,u,f,.02));const q=O(y,u,f,.01);E=Math.max(E,q);const R=[],K=Math.max(0,Number(s)||0),xe=Number(a)||1;if(K>1e-6){const le=Math.max(b,Math.floor(K*g));for(let te=0;te<=le;te+=1){const Ve=te/le,_e=xe*K*Ve,mt=bn(x,_e),rn=new C(w.x+mt.x*E,w.y+mt.y*E);R.push(ne(rn,e,n))}}const de=O(S,u,f,.08),We=O(N,u,f,.03),me=[];if(R.length>=2){const le=R[0].clone().sub(R[1]).normalize();me.push({tip:R[0].clone(),direction:le,length:de,width:We});const te=R[R.length-1].clone(),Ve=R[R.length-2].clone(),_e=te.clone().sub(Ve).normalize();me.push({tip:te,direction:_e,length:de,width:We})}const ae=E+O(h,u,f,.02),J=O(P,u,f,.01),ee=ne(w,e,n),Yt=ne(new C(w.x+x.x*ae,w.y+x.y*ae),e,n),Zt=ne(new C(w.x+T.x*ae,w.y+T.y*ae),e,n),Kt=ne(new C(w.x-x.x*J,w.y-x.y*J),e,n),Jt=ne(new C(w.x-T.x*J,w.y-T.y*J),e,n),en=[[ee.clone(),Yt],[ee.clone(),Zt],[ee.clone(),Kt],[ee.clone(),Jt]];let ye=l?l.clone():new C().addVectors(x,T);ye.lengthSq()<1e-10&&ye.set(-x.y,x.x),ye.normalize();const pt=O(D,u,f,.03),dt=E>0?E+pt*.3:pt,tn=new C(w.x+ye.x*dt,w.y+ye.y*dt),nn=ne(tn,e,n);return{radius:E,arcPoints:R,arrowSpecs:me,segments:en,labelPosition:nn,originWorld:ee}}d(An,"buildAngleDimensionGeometry");function Nn({pointA:e=null,pointB:t=null,extensionAnchorA:n=null,extensionAnchorB:o=null,normal:i=null,offset:r=0,showExtensions:s=!0,labelWorld:a=null,screenSizeWorld:l=null,fallbackScreenSizeWorld:c=null,arrowLengthPixels:u=12,arrowWidthPixels:f=4,labelLiftPixels:m=6,labelLeaderThresholdPixels:y=6}={}){const g=Z(e),b=Z(t);if(!g||!b)return null;const h=b.clone().sub(g);if(h.lengthSq()<1e-8)return null;h.normalize();let P=Z(i);(!P||P.lengthSq()<1e-12)&&(P=new p(0,0,1)),P.normalize();let D=new p().crossVectors(P,h);if(D.lengthSq()<1e-12&&(D=hn(h)),D.lengthSq()<1e-12)return null;D.normalize();let S=Number(r);Number.isFinite(S)||(S=O(20,l,c,.05));const N=g.clone().addScaledVector(D,S),w=b.clone().addScaledVector(D,S),x=[];s!==!1&&(x.push(...ht(n,g,N)),x.push(...ht(o,b,w))),x.push([N.clone(),w.clone()]);const T=O(u,l,c,.08),M=O(f,l,c,.03),E=[{tip:N.clone(),direction:h.clone().negate(),length:T,width:M},{tip:w.clone(),direction:h.clone(),length:T,width:M}],z=Z(a),q=new p().addVectors(N,w).multiplyScalar(.5),R=O(m,l,c,.02),K=z||q.addScaledVector(D,R);let xe=null;if(z){const de=N.distanceTo(w);if(de>1e-6){const me=z.clone().sub(N).dot(h),ae=Math.max(0,Math.min(de,me)),J=N.clone().addScaledVector(h,ae),ee=O(y,l,c,.02);z.distanceTo(J)>ee&&(xe=[J,z.clone()])}}return{direction:h,tangent:D,offset:S,offsetA:N,offsetB:w,segments:x,arrowSpecs:E,labelPosition:K,leaderSegment:xe}}d(Nn,"buildLinearDimensionGeometry");function ht(e,t,n){const o=[],i=Z(e)||t,r=1e-12;return i.distanceToSquared(t)>r&&o.push([i.clone(),t.clone()]),t.distanceToSquared(n)>r&&o.push([t.clone(),n.clone()]),o}d(ht,"buildLinearExtensionSegments");const Pn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the linear dimension"},targets:{type:"reference_selection",selectionFilter:["VERTEX","EDGE","FACE"],multiple:!0,default_value:[],label:"Targets",hint:"Select vertices, edges, or a planar face/linear edge and target",minSelections:1,maxSelections:2},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:d(({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 F{static showContexButton(t){const n=F._collectSelectionRefs(t,["VERTEX","EDGE","FACE"]);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:o,idx:i,ctx:r}=t,s=this.inputParams,a=Ue(n,s),l=a&&a.p0&&a.p1?a.p0.distanceTo(a.p1):null,c=gt(l,s);if(s.value=c.display,!a||!a.p0||!a.p1)return r?.reportAnnotationError?.("Linear dimension could not resolve two measurement points."),[];(!s.persistentData||typeof s.persistentData!="object")&&(s.persistentData={});const u=s.persistentData;try{const m=r.alignNormal?r.alignNormal(s?.alignment||"view",s):new p(0,0,1),y=Nn({pointA:a.p0,pointB:a.p1,extensionAnchorA:a.extensionAnchorA,extensionAnchorB:a.extensionAnchorB,normal:m,offset:s?.offset,showExtensions:s?.showExt!==!1,labelWorld:u.labelWorld||s.labelWorld,screenSizeWorld:r.screenSizeWorld,fallbackScreenSizeWorld:d(S=>L(n?.viewer,S),"fallbackScreenSizeWorld")});if(!y)return r?.reportAnnotationError?.("Linear dimension geometry could not be generated from the selected targets."),[];for(const[S,N]of y.segments)o.add(Y(S,N,1096065));for(const S of y.arrowSpecs)oe(o,S.tip,S.direction,S.length,S.width,1096065);y.leaderSegment&&o.add(Y(y.leaderSegment[0],y.leaderSegment[1],1096065));const g=Number.isFinite(s.decimals)?s.decimals:n?._opts?.dimDecimals|0,b=a.p0.distanceTo(a.p1),h=gt(b,s,g);s.value=h.display;const P=r.formatReferenceLabel?r.formatReferenceLabel(s,h.raw):h.display,D=y.labelPosition;D&&r.updateLabel(i,P,D,s)}catch(f){r?.reportAnnotationError?.(f,"Linear dimension failed to render.")}return[]}static onLabelPointerDown(t,n,o,i,r){try{if(!t.viewer?.camera)return;const l=Ue(t,o);if(!l||!l.p0||!l.p1)return;const c=l.p0,u=l.p1,f=r.alignNormal?r.alignNormal(o?.alignment||"view",o):new p(0,0,1),m=new p().subVectors(u,c).normalize(),y=Vn(f,m),g=new p().addVectors(c,u).multiplyScalar(.5),b=new B().setFromNormalAndCoplanarPoint(f,g);$.dragLabelOnPlane(t,r,{makePlane:d(()=>b,"makePlane"),onDrag:d(h=>{const D=new p().subVectors(h,g).dot(y);o.offset=D;const S=[h.x,h.y,h.z];$.ensurePersistentData(o),o.persistentData.labelWorld=S,o.labelWorld=S,r.updateLabel(n,null,h,o),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d($,"LinearDimensionAnnotation"),A($,"entityType","linear"),A($,"type","linear"),A($,"shortName","DIM"),A($,"longName","Linear Dimension"),A($,"title","Linear"),A($,"inputParamsSchema",Pn);let $e=$;function gt(e,t,n){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const o=n!==void 0?n:Number(t?.decimals),i=Number.isFinite(o)?Math.max(0,Math.min(8,o|0)):3,r=`${e.toFixed(i)}`,s=t?.isReference?`(${r})`:r;return{raw:r,display:s}}d(gt,"formatLinearLabel");function Ue(e,t){const n=Array.isArray(t?.targets);try{const o=e?.viewer?.partHistory?.scene,i=Dn(n?t.targets:null);if(o&&i.length){const r=En(o,i);if(r.length){const s=[],a=[],l=[];for(const y of r){const g=typeof y?.type=="string"?y.type.toUpperCase():"";g==="VERTEX"?s.push(y):g==="EDGE"?a.push(y):(g==="FACE"||g==="PLANE")&&l.push(y)}const c=r[0]||null,u=l.length>0||r.some(y=>fe(y)),f=a.length>0||r.some(y=>be(y));if(fe(c)){const y=Xe(e,r);if(y)return y}if(be(c)&&r.length>=2){const y=He(e,r);if(y)return y}if(u){const y=Xe(e,r);if(y)return y}if(f&&r.length>=2){const y=He(e,r);if(y)return y}const m=e?.viewer;if(s.length>=2){const y=ge(m,s[0]),g=ge(m,s[1]);if(y&&g)return{p0:y,p1:g}}if(s.length===1&&a.length){const y=ge(m,s[0]),g=y?_n(a,y):null;if(y&&g)return{p0:y,p1:g}}if(!s.length&&a.length){if(a.length===1){const y=lt(a[0]);if(y)return{p0:y.a,p1:y.b}}else if(a.length>=2)return It(a[0],a[1])}}return null}}catch{}if(!n)try{const o=e?.viewer?.partHistory?.scene,i=t?.aRefName||null,r=t?.bRefName||null;if(o&&(i||r)){const s=i?o.getObjectByName(i):null,a=r?o.getObjectByName(r):null;if(s&&a)return Cn(s,a);if(s&&!a){const l=v(e.viewer,s),c=Pe(t.p1);if(l&&c)return{p0:l,p1:c}}if(!s&&a){const l=v(e.viewer,a),c=Pe(t.p0);if(c&&l)return{p0:c,p1:l}}}}catch{}return{p0:Pe(t?.p0)||new p(0,0,0),p1:Pe(t?.p1)||new p(0,0,0)}}d(Ue,"computeDimPoints");function Xe(e,t){const n=e?.viewer,o=Array.isArray(t)?t.filter(Boolean):[],i=o.findIndex(y=>fe(y));if(i<0)return null;const r=o[i],s=Re(n,r);if(!s)return null;const a=o.find((y,g)=>g!==i&&y);if(!a)return null;const l=Mn(n,a,s);if(!l?.point)return null;const c=l.point.clone().sub(s.point).dot(s.normal),u=l.point.clone().addScaledVector(s.normal,-c),f=u.clone().addScaledVector(s.normal,c),m=s.anchor||s.point;return u.distanceToSquared(f)<=1e-12?null:{p0:u,p1:f,extensionAnchorA:m,extensionAnchorB:l.anchor||l.point,measurementNormal:s.normal.clone(),measurementMode:"faceNormal"}}d(Xe,"computeFaceNormalDimPoints");function He(e,t){const n=e?.viewer,o=Array.isArray(t)?t.filter(Boolean):[],i=o.findIndex(f=>be(f));if(i<0||o.length<2)return null;const r=Bt(o[i]);if(!r)return null;const s=o.find((f,m)=>m!==i&&f);if(!s)return null;const a=zn(n,s,r);if(!a?.point)return null;const l=qn(a.point,r.point,r.direction);if(!l)return null;const c=l,u=a.point.clone();return c.distanceToSquared(u)<=1e-12?null:{p0:c,p1:u,extensionAnchorA:r.anchor.clone(),extensionAnchorB:a.anchor||a.point,measurementMode:"edgeNormal",referenceDirection:r.direction.clone()}}d(He,"computeEdgeNormalDimPoints");function Dn(e){return Array.isArray(e)?e.slice(0,2):e==null||e===""?[]:[e]}d(Dn,"normalizeTargetList");function En(e,t){if(!e||!Array.isArray(t))return[];const n=[],o=new Set;for(const i of t){let r=null;if(i&&typeof i=="object")i.isObject3D?r=i:i.name&&(r=e.getObjectByName(i.name));else if(i!=null){const a=String(i).trim();a&&(r=e.getObjectByName(a))}if(!r)continue;const s=r.uuid||r.id||r.name;if(s!=null){const a=String(s);if(o.has(a))continue;o.add(a)}n.push(r)}return n}d(En,"resolveTargetObjects");function ge(e,t){const n=v(e,t);return n&&n.clone||n&&n.isVector3?n.clone():t?.getWorldPosition?t.getWorldPosition(new p):null}d(ge,"resolveVertexPoint");function fe(e){if(!e)return!1;const t=String(e.type||"").toUpperCase(),n=String(e.userData?.type||e.userData?.brepType||"").toUpperCase();return t==="FACE"||t==="PLANE"||n==="FACE"||n==="PLANE"}d(fe,"isFaceLikeObject");function be(e){if(!e)return!1;const t=String(e.type||"").toUpperCase(),n=String(e.userData?.type||e.userData?.brepType||"").toUpperCase();return t==="EDGE"||n==="EDGE"||e.isLine||e.isLine2||e.isLineSegments||e.isLineLoop}d(be,"isEdgeLikeObject");function Re(e,t){try{if(!fe(t))return null;const n=ie(e,t);if(!n||n.lengthSq()<=1e-12)return null;n.normalize();const o=v(e,t);if(!o)return null;const i=new B().setFromNormalAndCoplanarPoint(n,o),r=i.projectPoint(o,o.clone());return Tn(t,i)?{point:r,normal:n,anchor:r.clone()}:null}catch{return null}}d(Re,"resolvePlanarFacePlane");function Tn(e,t){try{if(String(e?.type||"").toUpperCase()==="PLANE")return!0;const o=e?.geometry?.getAttribute?.("position");if(!o||!Number.isFinite(o.count)||o.count<3)return!0;e.updateMatrixWorld?.(!0);const i=e.matrixWorld||new pe,r=new p,s=new qe;let a=0;for(let u=0;u<o.count;u+=1)r.set(o.getX(u),o.getY(u),o.getZ(u)).applyMatrix4(i),s.expandByPoint(r),a=Math.max(a,Math.abs(t.distanceToPoint(r)));const l=s.getSize(new p),c=Math.max(l.length(),1);return a<=Math.max(1e-5,c*1e-5)}catch{return!0}}d(Tn,"isPlanarFaceGeometry");function Mn(e,t,n){if(!t||!n)return null;if(fe(t)){const r=Re(e,t);if(r)return Math.abs(r.normal.dot(n.normal))>1-1e-5?{point:r.point.clone(),anchor:r.anchor.clone()}:{point:r.point.clone(),anchor:r.anchor.clone()}}if(String(t?.type||"").toUpperCase()==="VERTEX"){const r=ge(e,t);return r?{point:r,anchor:r.clone()}:null}if(be(t)){const r=Wn(t);if(r)return{point:r,anchor:r.clone()}}const i=v(e,t);return i?{point:i.clone(),anchor:i.clone()}:null}d(Mn,"resolveFaceNormalTargetPoint");function zn(e,t,n){if(!t||!n)return null;if(be(t)){const r=Bt(t);if(r){const s=Rn(n.point,n.direction,r.point,r.direction);return s?{point:s.targetPoint,anchor:r.anchor.clone()}:{point:r.anchor.clone(),anchor:r.anchor.clone()}}}if(fe(t)){const r=Re(e,t);if(r)return{point:r.point.clone(),anchor:r.anchor.clone()}}if(String(t?.type||"").toUpperCase()==="VERTEX"){const r=ge(e,t);return r?{point:r,anchor:r.clone()}:null}const i=v(e,t);return i?{point:i.clone(),anchor:i.clone()}:null}d(zn,"resolveEdgeNormalTargetPoint");function Bt(e){const t=vn(e);if(!Array.isArray(t)||t.length<2)return null;const n=t[0];let o=null;for(let s=t.length-1;s>=1;s-=1)if(t[s]?.distanceToSquared(n)>1e-12){o=t[s];break}if(!o)return null;const i=o.clone().sub(n);if(i.lengthSq()<=1e-12||(i.normalize(),!Fn(t,n,i)))return null;const r=Ln(t)||n.clone().add(o).multiplyScalar(.5);return{point:n.clone(),direction:i,anchor:r,points:t}}d(Bt,"resolveLinearEdgeLine");function vn(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}const t=e.matrixWorld||null,n=[],o=d((l,c=!1)=>{const u=Z(l);if(!u)return;c&&t&&u.applyMatrix4(t);const f=n[n.length-1];f&&f.distanceToSquared(u)<=1e-14||n.push(u)},"push");try{if(typeof e.points=="function"){const l=e.points(!0);if(Array.isArray(l))for(const c of l)o(c,!1);if(n.length>=2)return n;n.length=0}}catch{}const i=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(i){for(const l of i)o(l,!0);if(n.length>=2)return n;n.length=0}const r=e?.geometry?.attributes?.instanceStart,s=e?.geometry?.attributes?.instanceEnd;if(r&&s){const l=Math.min(r.count||0,s.count||0);for(let c=0;c<l;c+=1){const u=new p(r.getX(c),r.getY(c),r.getZ(c)),f=new p(s.getX(c),s.getY(c),s.getZ(c));t&&(u.applyMatrix4(t),f.applyMatrix4(t)),o(u,!1),o(f,!1)}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 l=0;l<a.count;l+=1){const c=new p(a.getX(l),a.getY(l),a.getZ(l));t&&c.applyMatrix4(t),o(c,!1)}if(n.length>=2)return n}return null}d(vn,"edgeWorldPoints");function Fn(e,t,n){if(!Array.isArray(e)||e.length<2||!t||!n)return!1;const o=new qe;for(const l of e)l&&o.expandByPoint(l);const i=Math.max(o.getSize(new p).length(),1),r=Math.max(1e-6,i*1e-5),s=new p,a=new p;for(const l of e){if(!l)continue;s.copy(l).sub(t);const c=s.dot(n);if(a.copy(n).multiplyScalar(c),s.sub(a).length()>r)return!1}return!0}d(Fn,"pointsAreCollinear");function Ln(e){if(!Array.isArray(e)||!e.length)return null;const t=new p;let n=0;for(const o of e)o&&(t.add(o),n+=1);return n?t.multiplyScalar(1/n):null}d(Ln,"averagePoints");function qn(e,t,n){if(!e||!t||!n||n.lengthSq()<=1e-12)return null;const o=n.clone().normalize(),i=e.clone().sub(t).dot(o);return t.clone().addScaledVector(o,i)}d(qn,"projectPointOnLine");function Rn(e,t,n,o){if(!e||!t||!n||!o)return null;const i=t.clone(),r=o.clone();if(i.lengthSq()<=1e-12||r.lengthSq()<=1e-12)return null;i.normalize(),r.normalize();const s=e.clone().sub(n),a=i.dot(r),l=i.dot(s),c=r.dot(s),u=1-a*a;if(Math.abs(u)<=1e-10)return null;const f=(a*c-l)/u,m=(c-a*l)/u;return{basePoint:e.clone().addScaledVector(i,f),targetPoint:n.clone().addScaledVector(r,m)}}d(Rn,"closestPointsBetweenInfiniteLines");function Wn(e){const t=lt(e);return t?.a&&t?.b?new p().addVectors(t.a,t.b).multiplyScalar(.5):null}d(Wn,"edgeMidpointWorld");function Vn(e,t){const n=e?.clone?.()||new p(0,0,1);n.lengthSq()||n.set(0,0,1),n.normalize();const o=t?.clone?.()||new p(1,0,0);o.lengthSq()||o.set(1,0,0),o.normalize();const i=new p().crossVectors(n,o);if(i.lengthSq()>1e-12)return i.normalize();const r=Math.abs(o.z)<.9?new p(0,0,1):new p(0,1,0);return i.crossVectors(o,r),i.lengthSq()>1e-12?i.normalize():new p(1,0,0)}d(Vn,"safeDimensionTangent");function _n(e,t){if(!Array.isArray(e)||!t)return null;let n=null,o=1/0;for(const i of e){const r=lt(i);if(r){const a=r.a.distanceToSquared(t);a<o&&(o=a,n=r.a);const l=r.b.distanceToSquared(t);l<o&&(o=l,n=r.b);continue}const s=ke(i,t);if(s){const a=s.distanceToSquared(t);a<o&&(o=a,n=s)}}return n?n.clone():null}d(_n,"closestEndpointToPoint");function lt(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}try{if(typeof e.points=="function"){const r=e.points(!0);if(Array.isArray(r)&&r.length>=2){const s=Ne(r[0]),a=Ne(r[r.length-1]);if(s&&a)return{a:s,b:a}}}}catch{}const t=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(t&&t.length>=2){const r=Ne(t[0]),s=Ne(t[t.length-1]);if(r&&s)return e.matrixWorld&&(r.applyMatrix4(e.matrixWorld),s.applyMatrix4(e.matrixWorld)),{a:r,b:s}}const n=e?.geometry?.attributes?.instanceStart,o=e?.geometry?.attributes?.instanceEnd;if(n&&o&&n.count>=1){const r=new p(n.getX(0),n.getY(0),n.getZ(0)),s=new p(o.getX(0),o.getY(0),o.getZ(0));return e.matrixWorld&&(r.applyMatrix4(e.matrixWorld),s.applyMatrix4(e.matrixWorld)),{a:r,b:s}}const i=e?.geometry?.getAttribute?.("position");if(i&&i.itemSize===3&&i.count>=2){const r=new p(i.getX(0),i.getY(0),i.getZ(0)),s=new p(i.getX(i.count-1),i.getY(i.count-1),i.getZ(i.count-1));return e.matrixWorld&&(r.applyMatrix4(e.matrixWorld),s.applyMatrix4(e.matrixWorld)),{a:r,b:s}}return null}d(lt,"edgeEndpointsWorld");function Cn(e,t){if(e?.type==="VERTEX"&&t?.type==="VERTEX")return{p0:e.getWorldPosition(new p),p1:t.getWorldPosition(new p)};if(e?.type==="EDGE"&&t?.type==="VERTEX"){const n=t.getWorldPosition(new p);return{p0:ke(e,n),p1:n}}if(e?.type==="VERTEX"&&t?.type==="EDGE"){const n=e.getWorldPosition(new p),o=ke(t,n);return{p0:n,p1:o}}return e?.type==="EDGE"&&t?.type==="EDGE"?It(e,t):{p0:v(null,e)||new p,p1:v(null,t)||new p}}d(Cn,"closestPointsForObjects");function ke(e,t){try{const n=e.points(!0);if(!n||n.length<2)return e.getWorldPosition(new p);const o=t.clone();let i={d2:1/0,q:null};const r=new p,s=new p;for(let a=0;a<n.length-1;a++){r.set(n[a].x,n[a].y,n[a].z),s.set(n[a+1].x,n[a+1].y,n[a+1].z);const l=Bn(r,s,o),c=l.distanceToSquared(o);c<i.d2&&(i={d2:c,q:l})}return i.q||e.getWorldPosition(new p)}catch{return e.getWorldPosition(new p)}}d(ke,"closestPointOnEdgeToPoint");function It(e,t){try{const n=e.points(!0),o=t.points(!0);if(!n||n.length<2||!o||o.length<2)return{p0:v(null,e)||new p,p1:v(null,t)||new p};const i=new p,r=new p,s=new p,a=new p;let l={d2:1/0,p:null,q:null};for(let c=0;c<n.length-1;c++){i.set(n[c].x,n[c].y,n[c].z),r.set(n[c+1].x,n[c+1].y,n[c+1].z);for(let u=0;u<o.length-1;u++){s.set(o[u].x,o[u].y,o[u].z),a.set(o[u+1].x,o[u+1].y,o[u+1].z);const{p:f,q:m}=In(i,r,s,a),y=f.distanceToSquared(m);y<l.d2&&(l={d2:y,p:f,q:m})}}return{p0:l.p||v(null,e)||new p,p1:l.q||v(null,t)||new p}}catch{return{p0:v(null,e)||new p,p1:v(null,t)||new p}}}d(It,"closestPointsBetweenEdges");function Bn(e,t,n){const o=t.clone().sub(e),i=Math.max(0,Math.min(1,o.dot(n.clone().sub(e))/(o.lengthSq()||1)));return e.clone().addScaledVector(o,i)}d(Bn,"closestPointOnSegment");function In(e,t,n,o){const i=t.clone().sub(e),r=o.clone().sub(n),s=e.clone().sub(n),a=i.dot(i),l=r.dot(r),c=r.dot(s);let u,f;const m=1e-12;if(a<=m&&l<=m)u=0,f=0;else if(a<=m)u=0,f=Math.max(0,Math.min(1,c/l));else{const b=i.dot(s);if(l<=m)f=0,u=Math.max(0,Math.min(1,-b/a));else{const h=i.dot(r),P=a*l-h*h;u=P!==0?Math.max(0,Math.min(1,(h*c-b*l)/P)):0,f=(h*u+c)/l,f<0?(f=0,u=Math.max(0,Math.min(1,-b/a))):f>1&&(f=1,u=Math.max(0,Math.min(1,(h-b)/a)))}}const y=e.clone().addScaledVector(i,u),g=n.clone().addScaledVector(r,f);return{p:y,q:g}}d(In,"closestPointsOnSegments");function Ne(e){return Z(e)}d(Ne,"arrayToVector");function Pe(e){return e?e instanceof p?e.clone():Array.isArray(e)?new p(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new p(e.x||0,e.y||0,e.z||0):null:null}d(Pe,"vectorFromAnnotationPoint");const Vr={computeDimPoints:Ue,computeEdgeNormalDimPoints:He,computeFaceNormalDimPoints:Xe,resolvePlanarFacePlane:Re},On={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:"Radial Face",hint:"Select cylindrical, pipe, or fillet 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:d(({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 F{static showContexButton(t){const n=F._normalizeSelectionItems(t),o=new Set(["FACE"]);for(const i of n){if(!F._isSelectionType(i,o)||!Ot(i))continue;const r=F._selectionRefName(i);if(r)return{params:{cylindricalFaceRef:r}}}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:o,idx:i,ctx:r}=t,s=this.inputParams,a=jt(n,s),l=wt(a,s);s.value=l.display,bt(s);try{const c=ve(n,s,r);if(!c||!c.center||!c.radiusPoint)return r?.reportAnnotationError?.("Radial dimension could not resolve a radial face and center/radius geometry."),[];const{center:u,radiusPoint:f,planeNormal:m,planePoint:y,radius:g}=c,b=16739125;let h=new p().subVectors(f,u);h.lengthSq()<1e-6&&h.set(1,0,0),h.normalize();let P=m;if(P||(P=r.alignNormal?r.alignNormal(s.alignment||"view",s):null),P&&P.lengthSq()>1e-6){const x=h.clone().projectOnPlane(P).normalize();x.lengthSq()>1e-6&&(h=x)}const D=r.screenSizeWorld?r.screenSizeWorld(12):L(n?.viewer,12),S=r.screenSizeWorld?r.screenSizeWorld(4):L(n?.viewer,4),N=s.displayStyle==="diameter",w=s.persistentData?.labelWorld?Ye(s.persistentData.labelWorld):null;if(N){const x=w?w.clone().sub(u).normalize():h.clone(),T=w?u.clone().addScaledVector(x,w.clone().sub(u).length()):u.clone().addScaledVector(x,g+Math.abs(Number(s.offset)||r.screenSizeWorld?r.screenSizeWorld(50):L(n?.viewer,50))),M=u.clone().addScaledVector(x,-g),E=u.clone().addScaledVector(x,g),z=u.clone().addScaledVector(x,-g);o.add(Y(M,T,b)),oe(o,E,x.clone(),D,S,b),oe(o,z,x.clone().negate(),D,S,b);const q=Oe(r.screenSizeWorld?r.screenSizeWorld(6):L(n?.viewer,6),b);q.position.copy(u),o.add(q)}else{const x=w||$t(n,s,u,f,m,y,r);let M=x.clone().sub(u).clone();M.lengthSq()||(M=h.clone()),M.normalize();const E=x;o.add(Y(u,E,b));const z=u.clone().addScaledVector(M,g);oe(o,z,M.clone(),D,S,b);const q=Oe(r.screenSizeWorld?r.screenSizeWorld(6):L(n?.viewer,6),b);q.position.copy(u),o.add(q)}if(typeof a=="number"){const x=wt(a,s);s.value=x.display;const T=r.formatReferenceLabel?r.formatReferenceLabel(s,x.raw):x.display,M=$n(n,s,u,f,m,y,r);M&&r.updateLabel(i,T,M,s)}}catch(c){r?.reportAnnotationError?.(c,"Radial dimension failed to render."),console.warn("RadialDimensionAnnotation render error:",c)}return[]}static onLabelPointerDown(t,n,o,i,r){try{const s=ve(t,o,r);if(!s||!s.center||!s.radiusPoint)return;const a=s.planeNormal&&s.planeNormal.lengthSq()>1e-6?s.planeNormal.clone().normalize():r.alignNormal?r.alignNormal(o.alignment||"view",o):new p(0,0,1),l=s.planePoint||s.radiusPoint,c=a&&l?new B().setFromNormalAndCoplanarPoint(a,l):null,u=new p().subVectors(s.radiusPoint,s.center).normalize();X.dragLabelOnPlane(t,r,{makePlane:d(()=>c,"makePlane"),onDrag:d(f=>{c.projectPoint(f,f),bt(o),o.persistentData.labelWorld=[f.x,f.y,f.z];const m=new p().subVectors(f,s.center);o.offset=m.dot(u)-s.radius,r.updateLabel(n,null,f,o),t.refreshAnnotationsUI?.()},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d(X,"RadialDimensionAnnotation"),A(X,"entityType","radial"),A(X,"type","radial"),A(X,"shortName","RAD"),A(X,"longName","Radial Dimension"),A(X,"title","Radial"),A(X,"inputParamsSchema",On);let Ge=X;function wt(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=t?.displayStyle==="diameter"?e*2:e,o=Number(t?.decimals),i=Number.isFinite(o)?Math.max(0,Math.min(8,o|0)):3,s=`${t?.displayStyle==="diameter"?"⌀":"R"}${n.toFixed(i)}`,a=`${s} (wu)`,l=t?.isReference?`(${a})`:a;return{raw:s,display:l}}d(wt,"formatRadialLabel");function bt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(bt,"ensurePersistent$2");function ve(e,t,n){try{const o=e?.viewer?.partHistory?.scene;if(!o||!t.cylindricalFaceRef)return null;const i=o.getObjectByName(t.cylindricalFaceRef);if(!i)return null;let r=i;for(;r&&typeof r.getFaceMetadata!="function";)r=r.parent;let s=null,a=null,l=null,c=null,u=null;const f=new p;let m=we(i),y=null;if(r&&typeof r.getFaceMetadata=="function"){const h=r.getFaceMetadata(t.cylindricalFaceRef);h&&typeof h=="object"&&Object.keys(h).length>0&&(m=h),m&&(m.type==="cylindrical"||m.type==="conical")&&(m.type==="cylindrical"?(s=new p(m.center[0],m.center[1],m.center[2]),a=m.radius,l=new p(m.axis[0],m.axis[1],m.axis[2]).normalize()):Math.abs(m.radiusBottom-m.radiusTop)<1e-6&&(s=new p(m.center[0],m.center[1],m.center[2]),a=m.radiusBottom,l=new p(m.axis[0],m.axis[1],m.axis[2]).normalize()),s&&l&&(i.parent&&i.parent.matrixWorld&&(s.applyMatrix4(i.parent.matrixWorld),l.transformDirection(i.parent.matrixWorld).normalize()),u=new p,Math.abs(l.x)<.9?u.crossVectors(l,new p(1,0,0)).normalize():u.crossVectors(l,new p(0,1,0)).normalize(),c=s.clone().addScaledVector(u,a)))}if(m&&typeof m=="object"&&(y=Qe(m.pmiRadiusOverride??m.radiusOverride??m.offsetShellRadius)),(!s||!l||!Number.isFinite(a)||a<=0)&&r){const h=Un(r,i,m);h&&(s=h.center,l=h.axis,a=h.radius,c=h.radiusPoint,u=h.perpendicular)}if(!s||!l||!Number.isFinite(a)||a<=0){const h=Zn(i);if(!h)return null;s=h.center,l=h.axis,a=h.radius,c=h.radiusPoint,u=new p().subVectors(c,s).normalize()}if(y&&s){let h=null;u&&u.lengthSq()>1e-12?h=u.clone().normalize():c&&(h=new p().subVectors(c,s),h.lengthSq()>1e-12&&h.normalize()),a=y,h&&(u=h.clone(),c=s.clone().addScaledVector(h,a))}f.copy(s);let g=null,b=null;if(t.planeRef){const h=o.getObjectByName(t.planeRef);h&&(g=ie(e.viewer,h),b=v(e.viewer,h))}if(g&&b&&g.lengthSq()>1e-6){const h=g.clone().normalize();g=h;const P=new B().setFromNormalAndCoplanarPoint(h,b),D=new p;P.projectPoint(s,D),s=D;let S=new p().subVectors(c,f);S.lengthSq()<1e-12&&(S=u.clone());let N=S.projectOnPlane(h);N.lengthSq()<1e-12&&(N=l.clone().cross(h),N.lengthSq()<1e-12&&(Math.abs(h.x)<.9?N=new p().crossVectors(h,new p(1,0,0)):N=new p().crossVectors(h,new p(0,1,0)))),N.normalize(),c=s.clone().addScaledVector(N,a)}return{center:s,radiusPoint:c,planeNormal:g,planePoint:b,axis:l,radius:a}}catch{return null}}d(ve,"computeRadialPoints");function De(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),o=Number(e.radiusTop);return!Number.isFinite(n)||!Number.isFinite(o)||Math.abs(n-o)>1e-6?!1:Math.max(n,o)>0}return!1}d(De,"isCylindricalMetadata");function he(e){if(!e||typeof e!="object")return!1;const t=String(e.type||"").toLowerCase();if(t!=="pipe"&&t!=="rounded_pipe")return!1;const n=Qe(e.pmiRadiusOverride??e.radiusOverride),o=Qe(e.inflatedRadius??e.radius);if(Number.isFinite(n)||Number.isFinite(o))return!0;const i=String(e.offsetShellFaceRole||e.faceRole||"").toLowerCase();return e.offsetShellRoundedPipe===!0||i==="rounded_pipe"}d(he,"isPipeMetadata");function Qe(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.abs(t):null}d(Qe,"readPositiveNumber");function jn(e){if(!e)return null;const t=e.userData||null;if(De(t))return t;if(t?.metadata&&De(t.metadata))return t.metadata;if(typeof e.getMetadata=="function")try{const i=e.getMetadata();if(De(i))return i}catch{}const n=e?.name||t?.faceName||null;let o=e?.parentSolid||t?.parentSolid||e?.parent||null;for(;o;){if(n&&typeof o.getFaceMetadata=="function"){try{const i=o.getFaceMetadata(n);if(De(i))return i}catch{}break}o=o.parent||null}return null}d(jn,"readCylindricalMetadata");function we(e){const t=jn(e);if(t)return t;if(!e)return null;const n=e.userData||null;if(he(n))return n;if(n?.metadata&&he(n.metadata))return n.metadata;if(typeof e.getMetadata=="function")try{const r=e.getMetadata();if(he(r))return r}catch{}const o=e?.name||n?.faceName||null;let i=e?.parentSolid||n?.parentSolid||e?.parent||null;for(;i;){if(o&&typeof i.getFaceMetadata=="function"){try{const r=i.getFaceMetadata(o);if(he(r))return r}catch{}break}i=i.parent||null}return null}d(we,"readRadialFaceMetadata");function Ot(e){if(!e)return!1;if(we(e)||St(e))return!0;if(Array.isArray(e.faces)){for(const t of e.faces)if(we(t)||St(t))return!0}return!!(e.parent&&we(e.parent))}d(Ot,"hasRadialFaceData");function St(e){try{if(!e)return!1;const t=(e.name||e.userData?.faceName||"").trim(),n=Xt(t),o=we(e);let i=e.parentSolid||e.userData?.parentSolid||e.parent||null;for(;i;){const r=Array.isArray(i._auxEdges)?i._auxEdges:null;if(r&&Ut(r,t,o))return!0;if(!n&&!o)return!1;i=i.parent||null}}catch{}return!1}d(St,"hasPipeFaceAuxPath");function jt(e,t){try{const n=ve(e,t);return n&&typeof n.radius=="number"?n.radius:n&&n.center&&n.radiusPoint?n.center.distanceTo(n.radiusPoint):null}catch{return null}}d(jt,"measureRadialValue");function $n(e,t,n,o,i,r,s){try{let a=null;return t.persistentData?.labelWorld?a=Ye(t.persistentData.labelWorld):t.labelWorld&&(a=Ye(t.labelWorld)),a||(a=$t(e,t,n,o,i,r,s)),i&&r&&i.lengthSq()>1e-6&&a&&new B().setFromNormalAndCoplanarPoint(i.clone().normalize(),r).projectPoint(a,a),a}catch{return null}}d($n,"resolveLabelPosition$1");function $t(e,t,n,o,i,r,s){try{const a=new p().subVectors(o,n);if(a.lengthSq()<1e-12)return o.clone();a.normalize();let l=Number(t?.offset);(!Number.isFinite(l)||l===0)&&(l=s.screenSizeWorld?s.screenSizeWorld(50):L(e?.viewer,50));const c=n.distanceTo(o),u=n.clone().addScaledVector(a,c+Math.abs(l));return i&&r&&i.lengthSq()>1e-6&&new B().setFromNormalAndCoplanarPoint(i.clone().normalize(),r).projectPoint(u,u),u}catch{return o?o.clone():null}}d($t,"computeRadialLabelPosition");function Un(e,t,n=null){try{if(!e||!t)return null;const o=Array.isArray(e._auxEdges)?e._auxEdges:null;if(!o||o.length===0)return null;const i=(t.name||t.userData?.faceName||"").trim();if(!i)return null;const r=Ut(o,i,n);if(!r||!Array.isArray(r.points)||r.points.length<2)return null;e.updateMatrixWorld?.(!0),t.updateMatrixWorld?.(!0);const s=kn(r,e);if(!s||s.length<2)return null;const a=Gn(t,16);if(!a.length)return null;let l=null;for(const c of a){const u=Qn(c,s,!!r.closedLoop);if(!u||!u.point)continue;const f=new p().subVectors(c,u.point),m=f.lengthSq();if(!(m>1e-10))continue;const y=Math.sqrt(m);f.normalize(),(!l||y>l.radius)&&(l={center:u.point.clone(),axis:u.direction?u.direction.clone():null,radius:y,radiusPoint:u.point.clone().addScaledVector(f,y),perpendicular:f.clone()})}return l?((!l.axis||l.axis.lengthSq()<1e-10)&&(l.axis=Yn(s,l.center,!!r.closedLoop)||new p(0,1,0)),l):null}catch{return null}}d(Un,"inferPipeFaceDataFromAuxEdges");function Ut(e,t,n=null){if(!Array.isArray(e)||!t)return null;const o=Xn(t,n);for(const r of o){const s=Hn(e,r);if(s)return s}const i=String(n?.sourceFeatureId||n?.featureID||n?.featureId||"").trim();if(i){const r=`${i}_ROUND_PIPE`;for(const s of e){const a=String(s?.name||"").trim();if(s?.centerline&&a.startsWith(r)&&a.endsWith("_PATH"))return s}}return null}d(Ut,"findPipeCenterlineAuxEdge");function Xn(e,t=null){const n=[],o=d(r=>{const s=String(r||"").trim();s&&!n.includes(s)&&n.push(s)},"add");o(t?.pmiCenterlineAuxName),o(t?.centerlineAuxName),o(t?.pathName),o(t?.auxEdgeName),o(t?.centerlineName);const i=Xt(e);return i&&o(`${i}_PATH`),n}d(Xn,"pipeCenterlineNameCandidates");function Hn(e,t){if(!Array.isArray(e)||!t)return null;for(const o of e)if(o?.name===t)return o;const n=t.toLowerCase();for(const o of e)if(typeof o?.name=="string"&&o.name.toLowerCase()===n)return o;return null}d(Hn,"findAuxEdgeByName");function kn(e,t){try{const n=[],o=!e.polylineWorld&&t?.matrixWorld?t.matrixWorld:null,i=new p;for(const r of e.points){if(Array.isArray(r)&&r.length>=3)i.set(r[0],r[1],r[2]);else if(r&&typeof r=="object")i.set(Number(r.x)||0,Number(r.y)||0,Number(r.z)||0);else continue;o&&i.applyMatrix4(o),n.push(i.clone())}return n}catch{return null}}d(kn,"buildAuxPolylineWorld");function Gn(e,t=16){try{const n=e?.geometry;if(!n)return[];const o=typeof n.getAttribute=="function"?n.getAttribute("position"):null,i=e.matrixWorld||new pe,r=[],s=new p;if(o&&o.count>0){const a=Math.max(1,Math.floor(o.count/t));for(let l=0;l<o.count&&r.length<t;l+=a)s.set(o.getX(l),o.getY(l),o.getZ(l)).applyMatrix4(i),r.push(s.clone())}if(!r.length)try{n.computeBoundingSphere?.(),n.boundingSphere&&(s.copy(n.boundingSphere.center).applyMatrix4(i),r.push(s.clone()))}catch{}return r}catch{return[]}}d(Gn,"collectFaceSamplePoints");function Qn(e,t,n=!1){if(!e||!Array.isArray(t)||t.length<2)return null;const o=new p,i=new p,r=new p;let s=null,a=null,l=1/0;const c=t.length,u=n?c:c-1;for(let f=0;f<u;f++){const m=t[f],y=t[(f+1)%c];if(!m||!y)continue;i.copy(y).sub(m);const g=i.lengthSq();if(g<1e-14)continue;r.copy(e).sub(m);let b=r.dot(i)/g;b=Math.max(0,Math.min(1,b)),o.copy(m).addScaledVector(i,b);const h=o.distanceToSquared(e);h<l&&(l=h,s=o.clone(),a=i.clone().normalize())}return s?{point:s,direction:a,distanceSq:l}:null}d(Qn,"closestPointOnPolyline");function Yn(e,t,n=!1){if(!Array.isArray(e)||e.length<2||!t)return null;let o=null,i=1/0;const r=new p,s=new p,a=e.length,l=n?a:a-1;for(let c=0;c<l;c++){const u=e[c],f=e[(c+1)%a];if(!u||!f)continue;r.copy(u).add(f).multiplyScalar(.5);const m=r.distanceToSquared(t);m<i&&(i=m,s.copy(f).sub(u),o=s.lengthSq()>1e-14?s.clone().normalize():null)}return o}d(Yn,"estimatePolylineTangent");function Xt(e){const t=/^(.*?)(_Outer|_Inner|_CapStart|_CapEnd)(?:_\d+)?$/i.exec(e);return t?t[1]:null}d(Xt,"pipeFaceBaseName");function Zn(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 o=e.matrixWorld||new pe,i=[],r=new p;for(let w=0;w<n.count;w++)r.set(n.getX(w),n.getY(w),n.getZ(w)).applyMatrix4(o),i.push(r.clone());if(!i.length)return null;const s=new p;for(const w of i)s.add(w);s.divideScalar(i.length);const a=new Float64Array(9),l=new p;for(const w of i)l.copy(w).sub(s),a[0]+=l.x*l.x,a[1]+=l.x*l.y,a[2]+=l.x*l.z,a[4]+=l.y*l.y,a[5]+=l.y*l.z,a[8]+=l.z*l.z;a[3]=a[1],a[6]=a[2],a[7]=a[5];const c=new p(1,0,0);for(let w=0;w<20;w++){const x=a[0]*c.x+a[1]*c.y+a[2]*c.z,T=a[1]*c.x+a[4]*c.y+a[5]*c.z,M=a[2]*c.x+a[5]*c.y+a[8]*c.z;c.set(x,T,M);const E=c.length();if(E<1e-12){c.set(0,1,0);break}c.divideScalar(E)}c.lengthSq()<1e-12&&c.set(0,1,0);let u=1/0,f=-1/0,m=0,y=0;const g=new p,b=new p,h=new p;for(const w of i){l.copy(w).sub(s);const x=l.dot(c);x<u&&(u=x),x>f&&(f=x),b.copy(c).multiplyScalar(x),g.copy(l).sub(b);const T=g.length();T>1e-6&&(y===0&&h.copy(g).normalize(),m+=T,y++)}if(!y)return null;const P=m/y,D=s.clone().add(c.clone().multiplyScalar((u+f)*.5)),S=h.lengthSq()>1e-12?h.clone():new p().crossVectors(c,new p(1,0,0)).normalize();S.lengthSq()<1e-12&&S.set(0,1,0).cross(c).normalize();const N=D.clone().addScaledVector(S,P);return{center:D,axis:c.normalize(),radius:P,radiusPoint:N}}catch{return null}}d(Zn,"inferCylinderFromGeometry");function Ye(e){return e?e instanceof p?e.clone():Array.isArray(e)?new p(e[0]||0,e[1]||0,e[2]||0):typeof e=="object"?new p(e.x||0,e.y||0,e.z||0):null:null}d(Ye,"vectorFromAny$1");const _r={computeRadialPoints:ve,hasRadialFaceData:Ot,isPipeMetadata:he,measureRadialValue:jt},Kn={id:{type:"string",default_value:null,label:"ID",hint:"unique identifier for the angle dimension"},decimals:{type:"number",default_value:1,defaultResolver:d(({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 F{static showContexButton(t){const n=F._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:o,idx:i,ctx:r}=t,s=this.inputParams,a=er(n,s),l=At(a,s);s.value=l.display,xt(s);try{const c=Nt(n,s,r);if(!c||!c.__2d)return r?.reportAnnotationError?.("Angle dimension could not resolve two measurable elements."),[];const u=16096779,{N:f,P:m,A_d:y,B_d:g,V2:b,basis:h,sweep:P=0,dirSign:D=1,bisector:S=null}=c.__2d,N=An({planePoint:m,planeNormal:f,basis:h,vertex2D:b,directionA2D:y,directionB2D:g,sweepRad:P,sweepDirection:D,bisector2D:S,labelWorld:s.persistentData?.labelWorld,screenSizeWorld:r.screenSizeWorld,fallbackScreenSizeWorld:d(w=>L(n?.viewer,w),"fallbackScreenSizeWorld")});if(!N)return r?.reportAnnotationError?.("Angle dimension geometry could not be generated from the selected elements."),[];for(let w=0;w<N.arcPoints.length-1;w+=1)o.add(Y(N.arcPoints[w],N.arcPoints[w+1],u));for(const[w,x]of N.segments)o.add(Y(w,x,u));for(const w of N.arrowSpecs)oe(o,w.tip,w.direction,w.length,w.width,u);if(typeof a=="number"){const w=At(a,s),x=w.raw;s.value=w.display;const T=r.formatReferenceLabel?r.formatReferenceLabel(s,x):w.display,M=N.labelPosition;M&&r.updateLabel(i,T,M,s)}}catch(c){r?.reportAnnotationError?.(c,"Angle dimension failed to render.")}return[]}static onLabelPointerDown(t,n,o,i,r){try{const s=Nt(t,o,r);if(!s)return;const a=ut(t,o,s,r),l=a?.n||new p(0,0,1),c=a?.p||new p,u=new B().setFromNormalAndCoplanarPoint(l,c);try{t?.showDragPlaneHelper?.(u)}catch{}const f=d(y=>{const g=r.raycastFromEvent?r.raycastFromEvent(y):null;if(!g)return;const b=new p;(r.intersectPlane?r.intersectPlane(g,u,b):g.intersectPlane(u,b))&&(xt(o),o.persistentData.labelWorld=[b.x,b.y,b.z],r.updateLabel(n,null,b,o),t.refreshAnnotationsUI?.())},"onMove"),m=d(y=>{try{window.removeEventListener("pointermove",f,!0),window.removeEventListener("pointerup",m,!0)}catch{}try{t?.hideDragPlaneHelper?.()}catch{}try{t.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}try{y.preventDefault(),y.stopImmediatePropagation?.(),y.stopPropagation()}catch{}},"onUp");window.addEventListener("pointermove",f,!0),window.addEventListener("pointerup",m,!0)}catch{}}};d(Q,"AngleDimensionAnnotation"),A(Q,"entityType","angle"),A(Q,"type","angle"),A(Q,"shortName","ANG"),A(Q,"longName","Angle Dimension"),A(Q,"title","Angle"),A(Q,"inputParamsSchema",Kn);let Ze=Q;function xt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(xt,"ensurePersistent$1");function Jn(e){const t=Array.isArray(e)?e:e==null||e===""?[]:[e],n=[],o=new Set;for(const i of t){let r="";i&&typeof i=="object"?typeof i.name=="string"?r=i.name:i.id!=null&&(r=String(i.id)):i!=null&&(r=String(i)),r=r.trim(),!(!r||o.has(r))&&(o.add(r),n.push(r))}return n}d(Jn,"normalizeTargetNames");function ct(e){const t=Array.isArray(e?.targets),n=Jn(t?e.targets:null);let o="",i="";return n.length?(o=n[0]||"",i=n[1]||""):t||(o=e?.elementARefName||"",i=e?.elementBRefName||""),e?.reverseElementOrder?{elementARefName:i,elementBRefName:o}:{elementARefName:o,elementBRefName:i}}d(ct,"resolveElementRefNames");function Ht(e){const t=e?.angleType;return t==="acute"||t==="obtuse"||t==="reflex"?t:e?.useReflexAngle?"reflex":"acute"}d(Ht,"resolveAngleType");function kt(e){return!e||typeof e!="object"||!Object.prototype.hasOwnProperty.call(e,"angleType")?!1:e.angleType==="acute"||e.angleType==="obtuse"||e.angleType==="reflex"}d(kt,"isAngleTypeExplicit");function At(e,t){if(typeof e!="number"||!Number.isFinite(e))return{raw:"-",display:"-"};const n=Number(t?.decimals),o=Number.isFinite(n)?Math.max(0,Math.min(3,n|0)):1,i=`${e.toFixed(o)}°`,r=t?.isReference?`(${i})`:i;return{raw:i,display:r}}d(At,"formatAngleLabel");function er(e,t){try{const n=Gt(e,t),o=ut(e,t,n);if(!o)return null;const{elementARefName:i,elementBRefName:r}=ct(t),s=Fe(e,i,o.n,o.p),a=Fe(e,r,o.n,o.p);if(!s||!a)return null;const l=at(o.n,s.d),c=ze(s.d,l).normalize(),u=ze(a.d,l).normalize(),f=Ht(t),m=kt(t)||!!t?.useReflexAngle,y=Ct(c,u,f,m);return y?Ee.radToDeg(y.angleRad):null}catch{return null}}d(er,"measureAngleValue");function Gt(e,t){try{const n=e?.viewer?.partHistory?.scene;if(!n)return null;const{elementARefName:o,elementBRefName:i}=ct(t),r=o?n.getObjectByName(o):null,s=i?n.getObjectByName(i):null;if(!r||!s)return null;const a=ie(e.viewer,r),l=ie(e.viewer,s),c=v(e.viewer,r),u=v(e.viewer,s);let f=null;if(t.planeRefName){const m=n.getObjectByName(t.planeRefName);m&&(f=ie(e.viewer,m))}return{dirA:a,dirB:l,pointA:c,pointB:u,plane:f}}catch{return null}}d(Gt,"computeAngleElements");function Nt(e,t,n){try{const o=Gt(e,t);if(!o||!o.dirA||!o.dirB)return null;const i=ut(e,t,o,n);if(!i)return null;const{elementARefName:r,elementBRefName:s}=ct(t),a=Fe(e,r,i.n,i.p),l=Fe(e,s,i.n,i.p);if(!a||!l)return null;const c=at(i.n,a.d),u=je(a.p,i.p,c),f=je(l.p,i.p,c);let m=ze(a.d,c).normalize(),y=ze(l.d,c).normalize();t?.reverseElementOrder&&(m=m.multiplyScalar(-1),y=y.multiplyScalar(-1));const g=Ht(t),b=kt(t)||!!t?.useReflexAngle,h=Ct(m,y,g,b);if(!h)return null;const P=h.start.clone(),D=h.end.clone();let S=Sn(u,P,f,D);if(S){const N=Math.max(1e-6,u.distanceTo(f));Math.max(S.distanceTo(u),S.distanceTo(f))>N*8&&(S=null)}return S||(S=new C().addVectors(u,f).multiplyScalar(.5)),{...o,__2d:{N:i.n,P:i.p,basis:c,A_p:u,B_p:f,A_d:P,B_d:D,V2:S,sweep:h.sweep,dirSign:h.dirSign,angleRad:h.angleRad,angleType:h.angleType,bisector:h.bisector}}}catch{return null}}d(Nt,"computeAngleElementsWithGeometry");function ut(e,t,n,o){try{if(t?.planeRefName){const a=e.viewer?.partHistory?.scene?.getObjectByName(t.planeRefName);if(a){const l=ie(e.viewer,a)||new p(0,0,1);if(l.lengthSq()>1e-12){const c=v(e.viewer,a)||new p;return{n:l.clone().normalize(),p:c}}}}if(n?.dirA&&n?.dirB){const a=new p().crossVectors(n.dirA,n.dirB);if(a.lengthSq()>1e-12){const l=n.pointA&&n.pointB?new p().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n.pointA||n.pointB||new p;return{n:a.normalize(),p:l}}}const r=(o?.alignNormal?o.alignNormal("view",t):null)||n?.plane||new p(0,0,1),s=n?.pointA&&n?.pointB?new p().addVectors(n.pointA,n.pointB).multiplyScalar(.5):n?.pointA||n?.pointB||new p;return{n:r.clone().normalize(),p:s}}catch{return{n:new p(0,0,1),p:new p}}}d(ut,"resolveAnglePlane");function Fe(e,t,n,o){try{if(!t)return null;const i=e?.viewer?.partHistory?.scene;if(!i)return null;const r=i.getObjectByName(t);if(!r)return null;const s=n&&n.lengthSq()>1e-12?n.clone().normalize():new p(0,0,1),a=v(e.viewer,r)||o||new p,l=o||a,c=new B().setFromNormalAndCoplanarPoint(s,l),u=ie(e.viewer,r),f=u?u.clone().normalize():null,m=r?.userData||{},y=String(r?.type||"").toUpperCase(),g=String(m.type||m.brepType||"").toUpperCase(),h=y==="FACE"||y==="PLANE"||!(y==="FACE"||y==="EDGE"||y==="PLANE")&&(g==="FACE"||g==="PLANE");if(y==="EDGE"||!h&&(g==="EDGE"||r?.isLine||r?.isLine2||r?.isLineSegments||r?.isLineLoop)){const w=tr(r,c,l);if(w)return w}if(h&&f&&f.lengthSq()>1e-12){const w=f.clone().normalize(),x=new p().crossVectors(w,s),T=x.lengthSq();if(T>1e-12){const M=w.dot(a),E=s.dot(l),z=new p().crossVectors(s,x).multiplyScalar(M),q=new p().crossVectors(x,w).multiplyScalar(E),R=z.add(q).divideScalar(T);return{p:c.projectPoint(R,R.clone()),d:x.normalize()}}}let D=a.clone();if(f&&f.lengthSq()>1e-12){const w=f.dot(s);if(Math.abs(w)>1e-9){const T=l.clone().clone().sub(a).dot(s)/w;D=a.clone().addScaledVector(f,T)}}const S=c.projectPoint(D,D.clone());let N=f?f.clone().projectOnPlane(s):null;return(!N||N.lengthSq()<1e-12)&&(N=at(s).U.clone()),N.normalize(),{p:S,d:N}}catch{return null}}d(Fe,"lineInPlaneForElement");function tr(e,t,n){const o=nr(e);if(!Array.isArray(o)||o.length<2)return null;const i=[];for(const u of o)u&&i.push(t.projectPoint(u,u.clone()));if(i.length<2)return null;let r=0,s=1,a=0;for(let u=0;u<i.length;u++)for(let f=u+1;f<i.length;f++){const m=i[u].distanceToSquared(i[f]);m>a&&(a=m,r=u,s=f)}if(a<=1e-12)return null;const l=i[s].clone().sub(i[r]).normalize();let c=i[r].clone();if(n){let u=c.distanceToSquared(n);for(let f=0;f<i.length;f++){const m=i[f].distanceToSquared(n);m<u&&(u=m,c=i[f].clone())}}return{p:c,d:l}}d(tr,"edgeLineInPlane");function nr(e){if(!e)return null;try{e.updateMatrixWorld?.(!0)}catch{}const t=e.matrixWorld||null,n=[],o=d(l=>{const c=Pt(l);if(!c)return;const u=n[n.length-1];u&&u.distanceToSquared(c)<=1e-14||n.push(c)},"pushUnique");try{if(typeof e.points=="function"){const l=e.points(!0);if(Array.isArray(l))for(const c of l)o(c);if(n.length>=2)return n;n.length=0}}catch{}const i=Array.isArray(e?.userData?.polylineLocal)?e.userData.polylineLocal:null;if(i){for(const l of i){const c=Pt(l);c&&(t&&c.applyMatrix4(t),o(c))}if(n.length>=2)return n;n.length=0}const r=e?.geometry?.attributes?.instanceStart,s=e?.geometry?.attributes?.instanceEnd;if(r&&s){const l=Math.min(r.count||0,s.count||0);for(let c=0;c<l;c++){const u=new p(r.getX(c),r.getY(c),r.getZ(c)),f=new p(s.getX(c),s.getY(c),s.getZ(c));t&&(u.applyMatrix4(t),f.applyMatrix4(t)),o(u),o(f)}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 l=0;l<a.count;l++){const c=new p(a.getX(l),a.getY(l),a.getZ(l));t&&c.applyMatrix4(t),o(c)}if(n.length>=2)return n}return null}d(nr,"getEdgeWorldPoints");function Pt(e){if(!e)return null;if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3)return new p(e[0]||0,e[1]||0,e[2]||0);if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),o=Number(e.z);if(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(o))return new p(t,n,o)}return null}d(Pt,"pointFromAny");const rr={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:d(({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 F{static showContexButton(t){const n=F._collectSelectionRefs(t,["VERTEX"]);return n.length?{params:{target:n}}:!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:o,idx:i,ctx:r}=t,s=this.inputParams||{},a=st();Dt(s),s.anchorPosition=Et(s.anchorPosition??s.anchorSide),delete s.anchorSide;const l=n?.viewer,c=l?.partHistory?.scene,u=Tt(l,c,s),f=Mt(n,s,u,r),m=r?.formatReferenceLabel?r.formatReferenceLabel(s,Ce(s.text)):Ce(s.text);if(s.value=m,f&&r?.updateLabel?.(i,m,f,s),!u.length||!f)return u.length?r?.reportAnnotationError?.("Leader annotation could not resolve a label position."):r?.reportAnnotationError?.("Leader annotation could not resolve any selected targets."),[];const y=a.lineColor??9684477,g=Je(n,l),b=et(u)||f,h=ir(f,b,g),P=Math.max(r?.screenSizeWorld?r.screenSizeWorld(18):L(l,18),1e-4),D=Math.max(r?.screenSizeWorld?r.screenSizeWorld(36):L(l,36),1e-4),S=sr(u,g,f),N=(S.length-1)*.5;return S.forEach(({point:w,order:x})=>{const T=(x-N)*P,M=f.clone().addScaledVector(h,-D).addScaledVector(g.up,T);if(o.add(Y(w,M,y)),o.add(Y(M,f,y)),s.endStyle==="dot"){const E=a.leaderDotRadiusPx??6,z=r?.screenSizeWorld?r.screenSizeWorld(E):L(l,E),q=Oe(Math.max(z,1e-4),a.dotColor??y);q.position.copy(w),o.add(q)}else{const E=w.clone().sub(M);E.lengthSq()||E.copy(h),E.normalize();const z=a.arrowLengthPx??12,q=a.arrowWidthPx??4,R=r?.screenSizeWorld?r.screenSizeWorld(z):L(l,z),K=r?.screenSizeWorld?r.screenSizeWorld(q):L(l,q);oe(o,w,E,R,K,a.arrowColor??y)}}),[]}static applyParams(t,n,o){return super.applyParams(t,n,o),n.text=Ce(n.text),Array.isArray(n.target)||(n.target=n.target?[String(n.target)]:[]),n.anchorPosition=Et(n.anchorPosition??n.anchorSide),delete n.anchorSide,n.endStyle=or(n.endStyle),{paramsPatch:{}}}static onLabelPointerDown(t,n,o,i,r){try{const s=t?.viewer,a=Tt(s,s?.partHistory?.scene,o),l=Mt(t,o,a,r)||new p,u=Je(t,s,o).forward,f=a&&a.length&&a[0]?a[0]:et(a)||l;if(!r?.raycastFromEvent)return;const m=new B().setFromNormalAndCoplanarPoint(u,f);H.dragLabelOnPlane(t,r,{makePlane:d(()=>m,"makePlane"),onDrag:d(y=>{Dt(o),o.persistentData.labelWorld=[y.x,y.y,y.z],r.updateLabel(n,null,y,o),t?.refreshAnnotationsUI?.()},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d(H,"LeaderAnnotation"),A(H,"entityType","leader"),A(H,"type","leader"),A(H,"shortName","LEAD"),A(H,"longName","Leader"),A(H,"title","Leader"),A(H,"inputParamsSchema",rr);let Ke=H;function Dt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(Dt,"ensurePersistentData$1");function Ce(e){return typeof e=="string"?e:e==null?"":String(e)}d(Ce,"sanitizeText$1");function Et(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 o=n.toLowerCase();if(o==="left")return"Left Middle";if(o==="right")return"Right Middle";if(o==="left-top"||o==="lefttop")return"Left Top";if(o==="left-bottom"||o==="leftbottom")return"Left Bottom";if(o==="right-top"||o==="righttop")return"Right Top";if(o==="right-bottom"||o==="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"}d(Et,"normalizeAnchorPosition$1");function or(e){return e==="dot"?"dot":"arrow"}d(or,"normalizeEndStyle");function Tt(e,t,n){const o=Array.isArray(n?.target)?n.target:[];if(!o.length||!t)return[];const i=[],r=new Set;for(const s of o){const a=typeof s=="string"?s:String(s??"");if(!(!a||r.has(a))){r.add(a);try{const l=t.getObjectByName?.(a);if(!l)continue;let c=v(e,l);!c&&typeof l.getWorldPosition=="function"&&(c=l.getWorldPosition(new p)),c&&i.push(c.clone())}catch{}}}return i}d(Tt,"resolveTargetPoints");function Mt(e,t,n,o){const i=e?.viewer,r=Je(e,i),s=n&&n.length&&n[0]?n[0].clone():et(n)||new p,a=r?.forward&&r.forward.lengthSq()?r.forward.clone():new p(0,0,1),l=new B().setFromNormalAndCoplanarPoint(a,s),c=cr(t?.persistentData?.labelWorld);if(c){const b=c.clone();return l.projectPoint(b,b),b}const u=Math.max(o?.screenSizeWorld?o.screenSizeWorld(90):L(i,90),1e-4),f=Math.max(o?.screenSizeWorld?o.screenSizeWorld(36):L(i,36),1e-4),m=r?.right&&r.right.lengthSq()?r.right.clone():new p(1,0,0),y=r?.up&&r.up.lengthSq()?r.up.clone():new p(0,1,0),g=s.clone().addScaledVector(m,u).addScaledVector(y,f);return l.projectPoint(g,g),g}d(Mt,"resolveLabelPosition");function Je(e,t,n){const o=ar(e?.viewEntry?.camera);if(o)return o;const i=new p(0,0,-1),r=new p(0,1,0);try{t?.camera?.getWorldDirection&&(t.camera.getWorldDirection(i),i.normalize()),t?.camera?.up&&r.copy(t.camera.up).normalize()}catch{}i.lengthSq()||i.set(0,0,-1),r.lengthSq()||r.set(0,1,0);const s=new p().crossVectors(i,r);s.lengthSq()||(Math.abs(i.z)<.9?r.set(0,0,1):r.set(1,0,0),s.crossVectors(i,r)),s.normalize();const a=new p().crossVectors(s,i);a.lengthSq()||a.copy(r.lengthSq()?r:new p(0,1,0)),a.normalize();const l=i.clone().normalize();return{right:s,up:a,forward:l}}d(Je,"computeViewBasis$1");function ir(e,t,n){try{const i=e.clone().sub(t||new p);if(i.lengthSq()>1e-10)return i.normalize()}catch{}const o=n?.right?.clone?.()||new p(1,0,0);return o.lengthSq()||o.set(1,0,0),o.normalize()}d(ir,"computeShoulderDirection");function sr(e,t,n){if(!e.length)return[];const o=t?.up&&t.up.lengthSq()?t.up:new p(0,1,0),i=e.map((r,s)=>{const l=r.clone().sub(n||new p).dot(o);return{point:r,metric:l,index:s}});return i.sort((r,s)=>r.metric-s.metric),i.map((r,s)=>({point:r.point,order:s}))}d(sr,"sortTargetsByViewUp");function ar(e){if(!e||typeof e!="object")return null;const t=lr(e);if(!t)return null;const n=new p(0,0,-1).applyQuaternion(t);if(!n.lengthSq())return null;const o=new p(0,1,0).applyQuaternion(t);let i=new p().crossVectors(n,o);i.lengthSq()||(i=new p().crossVectors(n,new p(0,1,0))),i.lengthSq()||i.set(1,0,0),i.normalize();const r=new p().crossVectors(i,n);r.lengthSq()||r.copy(o.lengthSq()?o:new p(0,1,0)),r.normalize();const s=n.clone().normalize();return{right:i,up:r,forward:s}}d(ar,"basisFromSavedCamera");function lr(e){const t=e?.quaternion||e?.camera?.quaternion;if(Array.isArray(t)&&t.length>=4){const[i,r,s,a]=t;if([i,r,s,a].every(l=>Number.isFinite(l)))return new V(i,r,s,a).normalize()}if(t&&typeof t=="object"){const i=Number(t.x),r=Number(t.y),s=Number(t.z),a=Number(t.w);if([i,r,s,a].every(l=>Number.isFinite(l)))return new V(i,r,s,a).normalize()}const n=e?.worldMatrix||e?.cameraMatrix||e?.matrix,o=Array.isArray(n?.elements)?n.elements:n;if(Array.isArray(o)&&o.length===16){const i=new pe().fromArray(o),r=new p,s=new V,a=new p;return i.decompose(r,s,a),s.normalize()}return null}d(lr,"quaternionFromSnapshot");function cr(e){if(!e&&e!==0)return null;if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3){const[t,n,o]=e;return[t,n,o].some(i=>typeof i!="number"||!Number.isFinite(i))?null:new p(t,n,o)}if(typeof e=="object"){const t=Number(e.x),n=Number(e.y),o=Number(e.z);if([t,n,o].every(i=>Number.isFinite(i)))return new p(t,n,o)}return null}d(cr,"vectorFromAny");function et(e){if(!e||!e.length)return null;const t=new p;return e.forEach(n=>t.add(n)),t.multiplyScalar(1/e.length)}d(et,"averageTargets");const ur={id:{type:"string",default_value:null,hint:"unique identifier for the note"},text:{type:"string",default_value:"",defaultResolver:d(({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 F{static showContexButton(t){const n=F._normalizeSelectionItems(t);if(!n.length)return!1;const o=n[0],i=v(null,o);return i?{params:{position:{x:i.x,y:i.y,z:i.z}}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:o,idx:i,ctx:r}=t,s=this.inputParams,a=st(),l=new p(s.position?.x||0,s.position?.y||0,s.position?.z||0),c=new an(a.noteDotRadius??.08,16,12),u=new ln({color:a.noteDotColor??a.dotColor??9684477,depthTest:!1,depthWrite:!1,transparent:!0}),f=new cn(c,u);f.position.copy(l),o.add(f);const m=String(s.text||"");if(!m)return[];let y=null;if(s.labelWorld)y=new p(s.labelWorld.x,s.labelWorld.y,s.labelWorld.z);else{const g=r.alignNormal("view",s),b=new p,h=new p(0,1,0);try{n.viewer?.camera?.getWorldDirection?.(b),b.crossVectors(g,h).normalize()}catch{b.set(1,0,0)}const P=r.screenSizeWorld(16);y=l.clone().addScaledVector(b,P).addScaledVector(g,P*.25)}return r.updateLabel(i,m,y,s),[]}static getSchema(t,n){const o={text:{type:"string",label:"Text",default_value:n.text||""}},i={text:o.text.default_value};return{schema:o,params:i}}static applyParams(t,n,o){return super.applyParams(t,n,o),n.text=fr(n.text),{paramsPatch:{}}}static onLabelPointerDown(t,n,o,i,r){try{if(!t.viewer?.camera)return;const l=r.alignNormal?r.alignNormal(o.alignment||"view",o):new p(0,0,1),c=o.labelWorld?new p(o.labelWorld.x,o.labelWorld.y,o.labelWorld.z):new p(o.position?.x||0,o.position?.y||0,o.position?.z||0),u=new B().setFromNormalAndCoplanarPoint(l,c);k.dragLabelOnPlane(t,r,{makePlane:d(()=>u,"makePlane"),onDrag:d(f=>{o.labelWorld={x:f.x,y:f.y,z:f.z};try{r.updateLabel(n,null,f,o)}catch{}},"onDrag"),onEnd:d(()=>{try{t?.viewer?.controls&&(t.viewer.controls.enabled=!0)}catch{}},"onEnd")})}catch{}}};d(k,"NoteAnnotation"),A(k,"entityType","note"),A(k,"type","note"),A(k,"shortName","NOTE"),A(k,"longName","Note"),A(k,"title","Note"),A(k,"inputParamsSchema",ur);let tt=k;function fr(e){return typeof e=="string"?e:e==null?"":String(e)}d(fr,"sanitizeText");const pr={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 F{static showContexButton(t){const n=F._collectSelectionRefs(t,["SOLID","COMPONENT"]);return n.length?{params:{targets:n}}:!1}constructor(t={}){super(t)}async run(t){const{pmimode:n,group:o,ctx:i}=t;if(!n||!o)return i?.reportAnnotationError?.("Explode annotation could not access the PMI render context."),[];const r=this.inputParams||{};zt(r),r.transform=Be(r.transform);const s=W._resolveSolidReferences(r,n,!0);if(!s.length)return i?.reportAnnotationError?.("Explode annotation could not resolve any target solids."),[];const a=W._ensureOriginalSnapshots(r,s,!1,n?.viewer),l=r.showTraceLine!==!1;let c=n?.__explodeTraceState;c instanceof Map||(c=new Map,n&&(n.__explodeTraceState=c));const u=_(r.transform.position,new p(0,0,0)),f=qt(r.transform.rotationEuler),m=_(r.transform.scale,new p(1,1,1));return s.forEach(y=>{try{const g=a.get(y.uuid),b=_(g?.centerLocal)||Qt(y),h=c?.get(y.uuid)?.clone()||gr(g),P=Wt(h,b)||_(g?.centerWorld)||_(g?.worldPosition),D=wr(h,u,f,m),S=Wt(D,b)||hr(y);Rt(P)&&Rt(S)&&P.distanceToSquared(S)>=1e-8&&l&&o.add(fn(P,S,16098596,{viewer:n?.viewer})),c?.set(y.uuid,D)}catch{}}),[]}static _resolveSolidReferences(t,n,o=!1){if(!t||!n)return[];const i=n.viewer,r=i?.partHistory?.scene||i?.scene;if(!r)return[];if(!o&&Array.isArray(t.__resolvedSolids)&&t.__resolvedSolids.length){const l=t.__resolvedSolids.filter(c=>c&&c.isObject3D);return ce(t,"__resolvedSolids",l),ce(t,"solids",l),l}const s=Array.isArray(t.targets)?t.targets:[],a=[];return s.forEach(l=>{const c=mr(l,r);c&&c.isObject3D&&a.push(c)}),ce(t,"__resolvedSolids",a),ce(t,"solids",a),a}static _ensureOriginalSnapshots(t,n,o=!1,i=null){zt(t);let r=t.__originalSnapshots;return r instanceof Map||(r=Lt(t.persistentData?.originalTransforms)),r instanceof Map||(r=new Map),(Array.isArray(n)?n:[]).forEach(a=>{!a||!a.uuid||(o||!r.has(a.uuid))&&r.set(a.uuid,Ft(a,i))}),ce(t,"__originalSnapshots",r),t.persistentData.originalTransforms=yr(r),r}static getOriginalSnapshotMap(t){if(!t)return new Map;if(t.__originalSnapshots instanceof Map)return t.__originalSnapshots;const n=Lt(t?.persistentData?.originalTransforms);return ce(t,"__originalSnapshots",n instanceof Map?n:new Map),t.__originalSnapshots}static applyTransformsToSolids(t,n,o={}){if(!t||!n)return;const i=W._resolveSolidReferences(t,n,!0);if(!i.length)return;const r=o&&o.startSnapshots instanceof Map?o.startSnapshots:W.getOriginalSnapshotMap(t),s=o?.cumulativeState instanceof Map?o.cumulativeState:null,a=Be(t.transform);t.transform=a;const l=_(a.position,new p(0,0,0)),c=qt(a.rotationEuler),u=_(a.scale,new p(1,1,1));i.forEach(f=>{if(!f||!f.uuid)return;const m=r.get(f.uuid)||W.getOriginalSnapshotMap(t).get(f.uuid)||Ft(f,n?.viewer);if(!m)return;const y=_(m.position,new p(0,0,0)),g=rt(m.quaternion,new V),b=_(m.scale,new p(1,1,1)),h=y.clone().add(l),P=g.clone().multiply(c),D=b.clone().multiply(u);if(f.position.copy(h),f.quaternion.copy(P),f.scale.copy(D),f.updateMatrixWorld(!0),s){const S=f.getWorldPosition(new p);s.set(f.uuid,{position:h.toArray(),quaternion:P.toArray(),scale:D.toArray(),worldPosition:S.toArray()})}})}static restoreOriginalTransforms(t,n){if(!t||!n)return;const o=W._resolveSolidReferences(t,n,!0);if(!o.length)return;const i=W.getOriginalSnapshotMap(t);o.forEach(r=>{if(!r||!r.uuid)return;const s=i.get(r.uuid);if(!s)return;const a=_(s.position,new p(0,0,0)),l=rt(s.quaternion,new V),c=_(s.scale,new p(1,1,1));r.position.copy(a),r.quaternion.copy(l),r.scale.copy(c),r.updateMatrixWorld(!0)})}static applyParams(t,n,o){super.applyParams(t,n,o),n.targets=dr(n.targets),n.transform=Be(n.transform),n.showTraceLine=n.showTraceLine!==!1;try{t&&typeof t.applyViewTransformsSequential=="function"&&t.applyViewTransformsSequential()}catch{}return{paramsPatch:{}}}};d(W,"ExplodeBodyAnnotation"),A(W,"entityType","exp"),A(W,"type","exp"),A(W,"shortName","EXP"),A(W,"longName","Explode Body"),A(W,"title","Explode Body"),A(W,"inputParamsSchema",pr),A(W,"aliases",["viewTransform"]);let nt=W;function zt(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(zt,"ensurePersistent");function ce(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}}d(ce,"setHiddenProperty");function Be(e){const t=e&&typeof e=="object"?e:{},n=d((o,i)=>{if(!Array.isArray(o))return i.slice();const r=i.slice();for(let s=0;s<r.length;s+=1){const a=Number(o[s]);r[s]=Number.isFinite(a)?a:r[s]}return r},"sanitizeArray");return{position:n(t.position,[0,0,0]),rotationEuler:n(t.rotationEuler,[0,0,0]),scale:n(t.scale,[1,1,1])}}d(Be,"sanitizeTransform");function dr(e){return Array.isArray(e)?e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length):[]}d(dr,"arrayOfStrings");function mr(e,t){if(!t||!e&&e!==0)return null;let n=null;if(typeof e=="string"&&e.trim().length){const i=e.trim();if(i[0]==="{")try{n=JSON.parse(i)}catch{n={name:i}}else n={name:i}}else typeof e=="object"&&(n={...e});if(!n)return null;const o=[];n.name&&typeof n.name=="string"&&o.push(n.name.trim()),Array.isArray(n.path)&&n.path.length&&o.push(String(n.path[n.path.length-1]));for(const i of o){if(!i)continue;const r=t.getObjectByName(i);if(r&&r.type==="SOLID"||r)return r}if(typeof n.uuid=="string"){const i=t.getObjectByProperty("uuid",n.uuid);if(i)return i;const r=vt(t,s=>s?.userData?.__pmiExportSourceUuid===n.uuid);if(r)return r}if(Number.isInteger(n.id)){try{const r=t.getObjectById(n.id);if(r)return r}catch{}const i=vt(t,r=>r?.userData?.__pmiExportSourceId===n.id);if(i)return i}return null}d(mr,"resolveSolidObject");function vt(e,t){if(!e?.traverse||typeof t!="function")return null;let n=null;return e.traverse(o=>{if(!(n||!o?.isObject3D))try{t(o)&&(n=o)}catch{}}),n}d(vt,"findExportCloneMatch");function Ft(e,t=null){try{e.updateMatrixWorld(!0)}catch{}const n=e.position.clone(),o=e.quaternion.clone(),i=e.scale.clone(),r=e.getWorldPosition(new p),s=Qt(e),a=s.clone().applyMatrix4(new pe().compose(n.clone(),o.clone(),i.clone()));return{position:n.toArray(),quaternion:o.toArray(),scale:i.toArray(),worldPosition:r.toArray(),centerWorld:a.toArray(),centerLocal:s.toArray()}}d(Ft,"captureSnapshot");function Lt(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}d(Lt,"snapshotArrayToMap");function yr(e){if(!(e instanceof Map))return[];const t=[];return e.forEach((n,o)=>{o&&t.push({uuid:o,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}d(yr,"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 o=0;o<e.length;o+=1)n.push(Number(e[o]));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()}d(j,"toArray");function _(e,t){if(e instanceof p)return e.clone();if(Array.isArray(e)&&e.length>=3){const n=Number(e[0]),o=Number(e[1]),i=Number(e[2]);if([n,o,i].every(r=>Number.isFinite(r)))return new p(n,o,i)}return e&&typeof e=="object"&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)?new p(e.x,e.y,e.z):t&&t.isVector3?t.clone():new p}d(_,"vectorFromArray");function rt(e,t){if(Array.isArray(e)&&e.length>=4){const n=Number(e[0]),o=Number(e[1]),i=Number(e[2]),r=Number(e[3]);if([n,o,i,r].every(s=>Number.isFinite(s)))return new V(n,o,i,r)}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}d(rt,"quaternionFromArray");function qt(e){const t=Array.isArray(e)?e:[0,0,0],n=Number(t[0])||0,o=Number(t[1])||0,i=Number(t[2])||0;try{return new V().setFromEuler(new un(Ee.degToRad(n),Ee.degToRad(o),Ee.degToRad(i),"XYZ"))}catch{return new V}}d(qt,"quaternionFromEuler");function Qt(e){try{if(!e)return new p;e.updateMatrixWorld?.(!0);const t=new qe().setFromObject(e);if(!t.isEmpty()){const o=t.getCenter(new p).clone();return e.worldToLocal(o),o}}catch{}return new p}d(Qt,"getSolidLocalCenter");function hr(e){try{if(!e)return new p;e.updateMatrixWorld?.(!0);const t=new qe().setFromObject(e);if(!t.isEmpty())return t.getCenter(new p)}catch{}try{return e.getWorldPosition(new p)}catch{return new p}}d(hr,"getSolidWorldCenter");function Rt(e){return!e||!e.isVector3?!1:Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}d(Rt,"isFiniteVec3");function gr(e){if(!e||typeof e!="object")return Se(new p,new V,new p(1,1,1));const t=_(e.position,new p),n=rt(e.quaternion,new V),o=_(e.scale,new p(1,1,1));return Se(t,n,o)}d(gr,"transformEntryFromSnapshot");function wr(e,t,n,o){const i=e||Se(new p,new V,new p(1,1,1)),r=i.position.clone().add(t||new p),s=i.quaternion.clone().multiply(n||new V),a=i.scale.clone().multiply(o||new p(1,1,1));return Se(r,s,a)}d(wr,"composeTransformEntry");function Wt(e,t){if(!e||!t||!t.isVector3)return null;const n=new pe().compose(e.position.clone(),e.quaternion.clone(),e.scale.clone());return t.clone().applyMatrix4(n)}d(Wt,"applyTransformEntryToPoint");function Se(e,t,n){return{position:e.clone(),quaternion:t.clone(),scale:n.clone(),clone(){return Se(this.position,this.quaternion,this.scale)}}}d(Se,"makeTransformEntry");const br={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 F{static showContexButton(t){const n=F._normalizeSelectionItems(t),o=new Set(["VERTEX","EDGE","FACE"]);for(const i of n){if(!F._isSelectionType(i,o)||!Ar(i))continue;const r=F._selectionRefName(i);if(r)return{params:{target:r}}}return!1}constructor(t={}){super(t)}async run(t){this.renderingContext=t;const{pmimode:n,group:o,idx:i,ctx:r}=t,s=this.inputParams||{},a=n?.viewer,l=a?.partHistory?.scene,c=Vt(a,s.target),u=v(l,c),f=Sr(a?.partHistory,c,u,s.target),m=f?.center?Te(f.center):u;if(!m)return r?.reportAnnotationError?.("Hole callout could not resolve the selected target."),[];if(!f)return r?.reportAnnotationError?.("Hole callout could not identify hole metadata for the selected target."),[];const y=zr(s,f,a?.partHistory),g=f?Nr(f,y,{showQuantity:s.showQuantity!==!1,beforeText:s.beforeText,afterText:s.afterText}):"";s.value=g;const b=_t(a),h=r?.screenSizeWorld?r.screenSizeWorld(80):L(a,80),P=r?.screenSizeWorld?r.screenSizeWorld(30):L(a,30),S=Te(s?.persistentData?.labelWorld)||m.clone().addScaledVector(b.right,Pr(s.anchorPosition||"Right Top")*h).addScaledVector(b.up,Dr(s.anchorPosition||"Right Top")*P);r?.updateLabel&&r.updateLabel(i,g,S,s);const N=st(),w=N.lineColor??16771584;o.add(Y(S,m,w));const x=N.arrowLengthPx??12,T=N.arrowWidthPx??4,M=r?.screenSizeWorld?r.screenSizeWorld(x):L(a,x),E=r?.screenSizeWorld?r.screenSizeWorld(T):L(a,T),z=m.clone().sub(S);return z.lengthSq()>1e-12&&(z.normalize(),oe(o,m,z,M,E,N.arrowColor??w)),[]}static applyParams(t,n,o){super.applyParams(t,n,o);const i=Number(n?.quantity);return n.quantity=Number.isFinite(i)?Math.max(0,Math.round(i)):1,n.showQuantity=n.showQuantity!==!1,n.beforeText=Le(n.beforeText),n.afterText=Le(n.afterText),n.anchorPosition=Er(n.anchorPosition),{paramsPatch:{}}}static onLabelPointerDown(t,n,o,i,r){const s=t?.viewer,a=Vt(s,o.target),l=s?.partHistory?.scene,c=v(l,a)||Te(o?.persistentData?.labelWorld);if(!c)return;const f=_t(s).forward;if(!r?.raycastFromEvent)return;const m=new B().setFromNormalAndCoplanarPoint(f,c);G.dragLabelOnPlane(t,r,{makePlane:d(()=>m,"makePlane"),suspendControls:!0,onDrag:d(y=>{Mr(o),o.persistentData.labelWorld=[y.x,y.y,y.z],r.updateLabel(n,null,y,o),t?.refreshAnnotationsUI?.()},"onDrag")})}};d(G,"HoleCalloutAnnotation"),A(G,"entityType","holeCallout"),A(G,"type","holeCallout"),A(G,"shortName","HOLE"),A(G,"longName","Hole Callout"),A(G,"title","Hole Callout"),A(G,"inputParamsSchema",br);let ot=G;function Vt(e,t){if(!e||!t)return null;const n=e.partHistory?.scene;if(!n)return null;if(typeof t=="string"){const o=n.getObjectByName?.(t);if(o)return o;const i=Me(t);for(const s of i){const a=n.getObjectByName?.(s);if(a)return a}let r=null;try{n.traverse(s=>{if(r)return;const a=s?.name?String(s.name):"";if(a){for(const l of i)if(l&&(a===l||a.endsWith(l)||a.includes(l))){r=s;return}}})}catch{}if(r)return r}return typeof t=="object"?t:n.getObjectByName?.(String(t))||null}d(Vt,"resolveTargetObject");function Sr(e,t,n,o=null){const i=Array.isArray(e?.features)?e.features:[],r=[];for(const u of i){const f=Array.isArray(u?.persistentData?.holes)?u.persistentData.holes:[];for(const m of f)r.push(m)}if(!r.length)return null;const s=t?.userData?.hole||t?.userData?.metadata?.hole;if(s)return s;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,l=Me(o,a);if(t?.name)for(const u of Me(t.name))l.add(u);const c=r.filter(u=>{const f=u?.sourceName?String(u.sourceName):null,m=u?.featureId?String(u.featureId):null,y=u?.targetId?String(u.targetId):null;return f&&l.has(f)||m&&l.has(m)||y&&l.has(y)});if(c.length===1)return c[0];if(c.length>1&&n){const u=re(c,n);if(u)return u}if(a){const u=r.filter(f=>f?.targetId&&String(f.targetId)===String(a));if(u.length===1)return u[0];if(u.length>1&&n){const f=re(u,n);if(f)return f}}if(o){const u=String(o),f=r.filter(m=>{const y=m?.featureId?String(m.featureId):"",g=m?.sourceName?String(m.sourceName):"";return y&&u.includes(y)||g&&u.includes(g)});if(f.length===1)return f[0];if(f.length>1&&n){const m=re(f,n);if(m)return m}}if(l.size){const u=r.filter(f=>{const m=f?.featureId?String(f.featureId):"",y=f?.sourceName?String(f.sourceName):"",g=f?.targetId?String(f.targetId):"";return l.has(m)||l.has(y)||l.has(g)});if(u.length===1)return u[0];if(u.length>1&&n){const f=re(u,n);if(f)return f}}if(n){const u=re(r,n);if(u)return u}if(t?.parent){const u=Me(t.parent.name),f=r.filter(m=>{const y=m?.featureId?String(m.featureId):"",g=m?.sourceName?String(m.sourceName):"",b=m?.targetId?String(m.targetId):"";return u.has(y)||u.has(g)||u.has(b)});if(f.length===1)return f[0];if(f.length>1&&n){const m=re(f,n);if(m)return m}}if(n){const u=re(r,n);if(u)return u}return r[0]}d(Sr,"findHoleDescriptor");function xr(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 i=e.getMetadata();if(i?.hole)return i.hole;if(i?.metadata?.hole)return i.metadata.hole}catch{}const n=e?.name||t?.faceName||null,o=e?.parentSolid||t?.parentSolid||null;if(n&&o&&typeof o.getFaceMetadata=="function")try{const i=o.getFaceMetadata(n);if(i?.hole)return i.hole}catch{}return null}d(xr,"readHoleMetadata");function Ar(e){if(!e)return!1;const t=[e],n=new Set,o=d(i=>Object.prototype.hasOwnProperty.call(i,"faces"),"hasOwnFaces");for(;t.length;){const i=t.shift();if(!(!i||n.has(i))){if(n.add(i),xr(i))return!0;if(o(i)&&Array.isArray(i.faces))for(const r of i.faces)t.push(r);else if(i.type==="SOLID"||i.type==="COMPONENT"){const r=Array.isArray(i.children)?i.children:[];for(const s of r)s&&s.type==="FACE"&&t.push(s)}i.parent&&t.push(i.parent)}}return!1}d(Ar,"hasHoleMetadata");function Nr(e,t=1,n={}){if(!e)return"";const o=[],i=Le(n.beforeText);i&&o.push(i);const s=n.showQuantity!==!1&&t>1?`${t}× `:"",a=Number(e.totalDepth??e.straightDepth),l=!e.throughAll&&a>0?` ↧ ${ue(a)}`:e.throughAll?" THRU ALL":"";o.push(`${s}⌀${ue(e.diameter)}${l}`),e.type==="COUNTERSINK"?o.push(`⌵ ⌀${ue(e.countersinkDiameter)} × ${ue(e.countersinkAngle,0)}°`):e.type==="COUNTERBORE"&&o.push(`⌴ ⌀${ue(e.counterboreDiameter)} ↧ ${ue(e.counterboreDepth)}`);const c=Tr(e?.thread);c&&o.push(c);const u=Le(n.afterText);return u&&o.push(u),o.join(`
2
2
  `)}d(Nr,"formatHoleCallout");function _t(e){const t=e?.camera,n=new p;t?.getWorldDirection?t.getWorldDirection(n):n.set(0,0,-1),n.normalize();const o=t?.up?t.up.clone():new p(0,1,0),i=new p().crossVectors(n,o).normalize(),r=new p().crossVectors(i,n).normalize();return{forward:n,right:i,up:r}}d(_t,"computeViewBasis");function Pr(e){return String(e).startsWith("Left")?-1:1}d(Pr,"anchorSign");function Dr(e){return e.includes("Bottom")?-1:e.includes("Middle")?0:1}d(Dr,"anchorVertical");function Er(e){return new Set(["Left Top","Left Middle","Left Bottom","Right Top","Right Middle","Right Bottom"]).has(e)?e:"Right Top"}d(Er,"normalizeAnchorPosition");function ue(e,t=2){const n=Number(e);return Number.isFinite(n)?n.toFixed(t):""}d(ue,"fmt");function Tr(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}`}d(Tr,"formatThreadLine");function Te(e){if(!Array.isArray(e)||e.length<3)return null;const[t,n,o]=e;return[t,n,o].every(i=>Number.isFinite(Number(i)))?new p(Number(t),Number(n),Number(o)):null}d(Te,"arrToVec");function Mr(e){(!e.persistentData||typeof e.persistentData!="object")&&(e.persistentData={})}d(Mr,"ensurePersistentData");function Le(e){if(e==null)return"";const t=String(e).trim();return t.length?t:""}d(Le,"normalizeAddonText");function Me(e,t=null){const n=new Set,o=d(i=>{if(i==null)return;const r=String(i);if(!r)return;n.add(r);const s=r.match(/\[(.*?)\]/);if(s&&s[1]){const l=s[1];n.add(l);const c=l.replace(/_AXIS_\d+$/,"");c&&c!==l&&n.add(c)}const a=r.replace(/_AXIS_\d+$/,"");a&&a!==r&&n.add(a)},"push");return o(e),o(t),n}d(Me,"normalizeTargetTokens");function re(e,t){if(!Array.isArray(e)||!e.length||!t)return null;let n=null,o=1/0;for(const i of e){const r=Te(i?.center);if(!r)continue;const s=r.distanceToSquared(t);s<o&&(o=s,n=i)}return n}d(re,"nearestDescriptor");function zr(e,t,n){const o=Number(e?.quantity),i=Number.isFinite(o)?Math.round(o):1;if(i>0)return i;const r=vr(n,t);return Number.isFinite(r)&&r>0?r:1}d(zr,"resolveHoleQuantity");function vr(e,t){if(!e||!t)return null;const n=Array.isArray(e.features)?e.features:[],o=t.featureId||null;let i=null;for(const r of n){const s=Array.isArray(r?.persistentData?.holes)?r.persistentData.holes:[];if(!s.length)continue;if(s.includes(t))return s.length;const a=Fr(r);o&&a&&String(a)===String(o)&&(i=s.length)}return i}d(vr,"countFeatureHoles");function Fr(e){if(!e||typeof e!="object")return null;const t=e.inputParams||{};return e.id??t.id??t.featureID??null}d(Fr,"resolveFeatureId");const Ie=d(e=>!e&&e!==0?"":String(e).trim().toLowerCase(),"normalizeKey"),ft=class ft{constructor(){this._map=new Map,this._aliases=new Map}register(t){if(!t)return;if(typeof t=="function"){const o=t;o.shortName||(o.shortName=o.featureShortName||o.name||o.type||"ANN"),o.longName||(o.longName=o.featureName||o.name||o.shortName||o.type||"Annotation"),typeof o.showContexButton!="function"&&(o.showContexButton=()=>!1)}const n=Ie(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 o of t.aliases){const i=Ie(o);i&&this._aliases.set(i,t)}}get(t){const n=Ie(t);if(!n)throw new Error("Annotation type must be a non-empty string");const o=this._map.get(n)||this._aliases.get(n);if(!o)throw new Error(`Annotation type "${t}" is not registered.`);return o}getSafe(t){try{return this.get(t)}catch{return null}}has(t){return!!this.getSafe(t)}list(){return Array.from(this._map.values())}};d(ft,"AnnotationRegistry");let it=ft;const se=new it;se.register($e);se.register(Ge);se.register(Ze);se.register(Ke);se.register(tt);se.register(nt);se.register(ot);export{$e as L,Ge as R,Vr as _,se as a,Nn as b,An as c,ze as d,_r as e,Sn as i,at as p,Ct as r,je as t};