/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{d as e,h as t,i as r,n,f as o,g as s,j as i,s as f}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import a from"../../../../geometry/Polygon.js";import{planeFromPoints as c}from"../../support/mathUtils.js";function u(e,n){t(n.center,0,0,0);for(let t=0;t<e.length;++t)r(n.center,n.center,e[t]);i(n.center,n.center,1/e.length);let o=0;for(let t=0;t<e.length;++t)o=Math.max(o,f(n.center,e[t]));n.radius=Math.sqrt(o)}function g(e,t){if(e.length<3)throw new Error("need at least 3 points to fit a plane");c(e[0],e[1],e[2],t)}function h(e,t){return s(e,t)+e[3]}function m(t,r,n,o,{geodesicArea:s}){const i=d;return e(i.rings[0][0],t),e(i.rings[0][1],r),e(i.rings[0][2],n),e(i.rings[0][3],t),i.spatialReference=o,i.clearCache(),s(i)}function p(i,f=null,l=!0){const a=(e,t)=>{if(0===t[0]&&0===t[1]&&0===t[2])return!1;for(let r=0;r<e.length;++r)if(s(t,e[r])<-1e-6)return!1;return!0};if(0===i.length)return!1;if(1===i.length)return f&&e(f,i[0]),!0;t(w,0,0,0);for(let e=0;e<i.length;++e)r(w,w,i[e]);if(n(w,w),a(i,w))return f&&e(f,w),!0;if(!l)return!1;for(let t=0;t<i.length;++t)for(let r=0;r<i.length;++r)if(t!==r&&(o(w,i[t],i[r]),n(w,w),a(i,w)))return f&&e(f,w),!0;return!1}function j(e){return"mouse"!==e.pointerType||0===e.button}const d=new a({hasM:!1,hasZ:!0,rings:[[l(),l(),l(),l()]],spatialReference:null}),w=l();export{g as bestFitPlane,u as boundingSphere,p as fitHemisphere,j as isPrimaryPointerAction,h as planePointDistance,m as triangleAreaGeodesic};
