import{useRef as e,useCallback as n}from"react";import{MapConfig as t}from"../../constants.js";var r=function(r,a){var o=e({create:null,update:null,delete:null,modeChange:null,selectionChange:null}),l=n((function(e){var n=e.map.getMap();o.current.create=function(e){r.onDrawCreate(e)},o.current.update=function(e){r.onDrawUpdate(e)},o.current.delete=function(){r.onDrawDelete()},o.current.modeChange=function(e){r.onModeChange(e)},o.current.selectionChange=function(e){r.onSelectionChange(e)},n.on("draw.create",o.current.create),n.on("draw.update",o.current.update),n.on("draw.delete",o.current.delete),n.on("draw.modechange",o.current.modeChange),n.on("draw.selectionchange",o.current.selectionChange),n.once("idle",(function(){null!=n&&n.getLayer(t.LayerIds.Wells)&&n.moveLayer(t.LayerIds.Wells)}))}),[r]),c=n((function(e){var n=e.map.getMap(),t=o.current;t.create&&n.off("draw.create",t.create),t.update&&n.off("draw.update",t.update),t.delete&&n.off("draw.delete",t.delete),t.modeChange&&n.off("draw.modechange",t.modeChange),t.selectionChange&&n.off("draw.selectionchange",t.selectionChange),o.current={create:null,update:null,delete:null,modeChange:null,selectionChange:null},a.current=null}),[a]);return{handlersRef:o,onAdd:l,onRemove:c}};export{r as useDrawEventHandlers};
//# sourceMappingURL=useDrawEventHandlers.js.map
