import{useCallback as e}from"react";import{convertDrawCoordsToApi as t}from"../utils/polygonCoords.js";var r=function(r,n,o,a,i,l,u,c,d,g,f){return{handleDrawCreate:e((function(e){var t=e.features[0];"Polygon"===(null==t?void 0:t.geometry.type)&&f(t.geometry.coordinates[0])}),[f]),handleDrawUpdate:e((function(e){var i=e.features[0];if("Polygon"===(null==i?void 0:i.geometry.type)){var l=i.geometry.coordinates[0],u=t(l);"confirming"===r.phase?(a(u),o({phase:"confirming",polygon:u.map((function(e){return{latitude:e.latitude,longitude:e.longitude}}))})):n(u)}}),[r.phase,n,o,a]),handleModeChange:e((function(e){i("draw_polygon"===e.mode),u("direct_select"===e.mode)}),[i,u]),handleSelectionChange:e((function(e){if(g.current&&e.features.length>0&&d.current)return g.current=!1,void d.current.changeMode("simple_select",{featureIds:[]});g.current=!1,l(e.features.length>0)}),[g,d,l]),handleMapClick:e((function(){if(d.current){var e=d.current.getAll().features[0];if("Polygon"===(null==e?void 0:e.geometry.type)){var t=e.geometry.coordinates[0];c(Math.max(0,t.length-2))}}}),[d,c])}};export{r as useLassoEventHandlers};
//# sourceMappingURL=useLassoEventHandlers.js.map
