/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/vec3","../../../../chunks/vec3f64","../../../../geometry/geometryEngine","../../../../geometry/Polygon","../../../../geometry/projection","../../../../geometry/SpatialReference","../../../../geometry/support/geodesicUtils","../../support/mathUtils"],(function(e,t,n,o,r,i,a,c,s){"use strict";function l(e,n){const o=n.center;t.set(o,0,0,0);for(let i=0;i<e.length;++i)t.add(o,o,e[i]);t.scale(o,o,1/e.length);let r=0;for(let i=0;i<e.length;++i)r=Math.max(r,t.squaredDistance(o,e[i]));n.radius=Math.sqrt(r)}function u(e,t){if(e.length<3)throw new Error("need at least 3 points to fit a plane");s.planeFromPoints(e[0],e[1],e[2],t)}function f(e,n){return t.dot(e,n)+e[3]}function g(e,n,o){return i.projectPointToVector(e,y,o)&&i.projectPointToVector(n,L,o)?t.distance(y,L):0}function p(e,t){if(!i.projectPointToWGS84ComparableLonLat(e,y)||!i.projectPointToWGS84ComparableLonLat(t,L))return 0;const n={distance:null};return c.inverseGeodeticSolver(n,[y[0],y[1]],[L[0],L[1]]),n.distance}function d(e,t,n){const o={distance:null};return c.inverseGeodeticSolver(o,[e[0],e[1]],[t[0],t[1]],n),o.distance}function m(e,t,n,r){const a=G;return i.projectVectorToWGS84ComparableLonLat(e,r,y)&&i.projectVectorToWGS84ComparableLonLat(t,r,L)&&i.projectVectorToWGS84ComparableLonLat(n,r,S)?(a.setPoint(0,0,y),a.setPoint(0,1,L),a.setPoint(0,2,S),Math.abs(o.geodesicArea(a,"square-meters"))):0}function h(e,n,o){Math.abs(e[0])>Math.abs(e[1])?t.set(n,0,1,0):t.set(n,1,0,0),t.cross(o,e,n),t.normalize(n,n),t.cross(n,o,e),t.normalize(o,o)}function P(e,n=null,o=!0){const r=1e-6,i=(e,n)=>{if(0===n[0]&&0===n[1]&&0===n[2])return!1;for(let o=0;o<e.length;++o)if(t.dot(n,e[o])<-r)return!1;return!0};if(0===e.length)return!1;if(1===e.length)return n&&t.copy(n,e[0]),!0;t.set(j,0,0,0);for(let a=0;a<e.length;++a)t.add(j,j,e[a]);if(t.normalize(j,j),i(e,j))return n&&t.copy(n,j),!0;if(!o)return!1;for(let a=0;a<e.length;++a)for(let o=0;o<e.length;++o)if(a!==o&&(t.cross(j,e[a],e[o]),t.normalize(j,j),i(e,j)))return n&&t.copy(n,j),!0;return!1}function b(e){return"mouse"!==e.pointerType||0===e.button}const y=n.create(),L=n.create(),S=n.create(),G=new r({rings:[[y,L,S]],spatialReference:a.WGS84}),j=n.create();e.bestFitPlane=u,e.boundingSphere=l,e.fitHemisphere=P,e.isPrimaryPointerAction=b,e.planePointDistance=f,e.segmentLengthEuclidean=g,e.segmentLengthGeodesic=p,e.segmentLengthGeodesicVector=d,e.tangentFrame=h,e.triangleAreaGeodesic=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
