import e from"@babel/runtime/helpers/slicedToArray";import{useState as s,useRef as t,useMemo as o}from"react";import{MapConfig as r}from"../constants.js";import{getWellsInCircle as i}from"../utils/selection-geometry.js";import"../../../../stores/selection-tool-store/SelectionToolStoreContext.js";import"../../../../stores/selection-tool-store/SelectionToolStoreProvider.js";import"zustand";import{useSelectionToolStore as n}from"../../../../stores/selection-tool-store/useSelectionToolStore.js";import{createCircleGeoJSON as l}from"./utils/radius-geometry.js";import{useGlobalRadiusMouseUp as a,useResetOnInactive as u,useSyncPlacingCenter as d,useSyncRadiusMilesRef as f}from"./useRadiusDrawingEffects.js";import{useRadiusMouseMove as c}from"./useRadiusMouseMove.js";import{useRadiusDragEnd as m}from"./useRadiusDragEnd.js";import{useRadiusActions as g}from"./useRadiusActions.js";import{useRadiusClickHandlers as M}from"./useRadiusClickHandlers.js";var p=function(e){return Math.max(r.Radius.Min,Math.min(e,r.Radius.Max))},R=function(r){var p=r.mapRef,R=r.isActive,v=r.wells,h=r.onWellsSelected,j=r.subjectWellId,I=n((function(e){return e.setRadiusState})),S=n((function(e){return e.radiusState})),C=n((function(e){return e.setMode})),D=s(null),H=e(D,2),w=H[0],E=H[1],x=s(null),T=e(x,2),b=T[0],k=T[1],y=s(!1),A=e(y,2),O=A[0],W=A[1],z=s(!1),P=e(z,2),U=P[0],q=P[1],B=s(!1),F=e(B,2),G=F[0],J=F[1],K=t("none"),L=t(null),N=t(null),Q=t(null),V={setCenter:E,setRadiusMiles:k,setIsDragging:J,setIsHoveringEdge:W,setIsHoveringInside:q,centerRef:L,radiusMilesRef:N,dragModeRef:K,dragOffsetRef:Q},X=o((function(){return w&&b?i(v,w,b,null!=j?j:void 0):[]}),[v,w,b,j]),Y=o((function(){return w&&b?l(w,b):null}),[w,b]),Z=M(R,S,w,b,O,U,E,J,I,L,K,Q),$=Z.handleMapClick,_=Z.handleMouseDown,ee=c(p,R,S,w,b,K,L,N,Q,k,E,W,q),se=m(K,L,N,Q,J,I),te=g(S,X,w,h,I,C,V),oe=te.confirm,re=te.cancel,ie=te.setRadiusMilesExternal;return a(se,K),u(R,{setCenter:E,setRadiusMiles:k,setIsDragging:J,setIsHoveringEdge:W,setIsHoveringInside:q},{dragModeRef:K,centerRef:L,radiusMilesRef:N,dragOffsetRef:Q}),d(S.phase,E,k,L,N),f(b,N),{radiusState:S,radiusMiles:b,setRadiusMiles:ie,wellsInRadiusCount:X.length,previewCircle:Y,isHoveringEdge:O,isHoveringInside:U,isDragging:G,handlers:{handleMapClick:$,handleMouseMove:ee,handleMouseDown:_,handleMouseUp:se},confirm:oe,cancel:re}};export{p as clampRadius,R as useRadiusDrawing};
//# sourceMappingURL=useRadiusDrawing.js.map
