/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{S as e}from"../../../chunks/SimpleGeometryCursor.js";import{G as r}from"../../../chunks/GeometryCursor.js";import{d as t,p as n,c as s,G as o,i,a as u}from"../../../chunks/Geometry.js";import{m,k as c,P as a,l,M as g}from"../../../chunks/MultiPathImpl.js";import{m as d,P as p}from"../../../chunks/Point2D.js";class y{getOperatorType(){return 10113}supportsCurves(){return!1}accelerateGeometry(e,r,t){return!1}canAccelerateGeometry(e){return!1}executeMany(e,r,t){return new h(e,r,t)}execute(r,n){const s=new e([r]),o=this.executeMany(s,!1,n).next();return o||t("null output"),o}minimumBoundingCircle(e,r,t,n){return m(e,r,t)}}class h extends r{m_geometryCursor;m_progressTracker;m_bMerge;constructor(e,r,t){super(),this.m_geometryCursor=e,this.m_bMerge=r,this.m_progressTracker=t}tock(){return!0}getRank(){return 1}next(){if(this.m_bMerge)return this.mergedMinimumBoundingCircle();const e=this.m_geometryCursor.next();return e?this.minimumBoundingCircle(e):null}getGeometryID(){return this.m_geometryCursor.getGeometryID()}minimumBoundingCircle(e){if(n(e),s(e),this.m_progressTracker?.checkProgress(),e.isEmpty())return e.clone();const r=e.getGeometryType();if(r===o.enumPoint)return this.makeCircle([e.getXY()],1);if(r===o.enumLine){const r=e,t=[r.getStartXY(),r.getEndXY()];return this.makeCircle(t,2)}if(r===o.enumEnvelope){const r=e,t=d(p,2);return r.queryCorner(0,t[0]),r.queryCorner(2,t[1]),this.makeCircle(t,2)}if(i(r)){const r=e,t=[0,0,0],n=c(r,t),s=new Array(n);for(let e=0;e<n;++e)s[e]=r.getXY(t[e]);return this.makeCircle(s,n)}u("Geometry type not supported.")}makeCircle(e,r){const t=new a,n=new l;if(1===r)n.constructCircleRadius(0,e[0],!1);else if(2===r){const r=p.lerp(e[0],e[1],.5),t=p.distance(e[0],r),s=p.distance(e[1],r);n.constructCircleRadius(Math.max(t,s),r,!1)}else if(3===r){const r=p.calculateCircleCenterFromThreePoints(e[0],e[1],e[2]),t=p.distance(e[0],r),s=p.distance(e[1],r),o=p.distance(e[2],r);n.constructCircleRadius(Math.max(t,s,o),r,!1)}return t.addPathFromClosedSegment(n,!1),t}mergedMinimumBoundingCircle(){let e=null,r=this.m_geometryCursor.next();if(!r)return null;e=new g;const t=e.getImpl();do{n(r),s(r),this.m_progressTracker?.checkProgress();switch(r.getGeometryType()){case o.enumPoint:t.addPoint2D(r.getXY());break;case o.enumLine:t.addPoint2D(r.getStartXY()),t.addPoint2D(r.getEndXY());break;case o.enumEnvelope:for(let e=0;e<4;++e){const n=new p;r.queryCorner(e,n),t.addPoint2D(n)}break;case o.enumMultiPoint:case o.enumPolyline:case o.enumPolygon:{const e=r.getImpl();for(let r=0,n=e.getPointCount();r<n;r++)t.addPoint2D(e.getXY(r));break}default:u("Geometry type not supported.")}}while(r=this.m_geometryCursor.next());return this.minimumBoundingCircle(e)}}const C=new y;function f(e){return C.execute(e,null)}function k(r,t){const n=C.executeMany(new e(r),t,null);return Array.from(n)}function P(){return C.supportsCurves()}export{f as execute,k as executeMany,P as supportsCurves};
