"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react"),t=require("../constants.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=a(e);exports.useMapClickHandler=function(e){var a=e.mapRef,l=e.isViewOnly,o=e.isRadiusToolActive,n=e.radiusDrawingHandlers,s=e.shouldSuppressClickRef,u=e.handleChangeOffsetWell;return r.useCallback((function(e){var r;if(!l)if(s.current)s.current=!1;else if(o)n.handleMapClick(e);else{var f=e.features;if(null!=f&&f.length){var d=f[0],c=null===(r=d.layer)||void 0===r?void 0:r.id;if(c!==t.MapConfig.LayerIds.WellsClusters){if(c===t.MapConfig.LayerIds.WellsUnclustered){var p=d.properties;if(p){var v={id:p.id,name:p.name,formation:p.formation,totalDepth:p.totalDepth,rigReleaseDate:p.rigReleaseDate};u(v,!p.isOffsetWell)}}}else!function(e){var r,a,l=e.mapRef,o=e.feature,n=null===(r=l.current)||void 0===r?void 0:r.getMap(),s=null===(a=o.properties)||void 0===a?void 0:a.cluster_id;if(n&&void 0!==s&&"Point"===o.geometry.type){var u=i.default(o.geometry.coordinates,2),f=u[0],d=u[1],c=n.getSource(t.MapConfig.SourceIds.WellsClustered);c&&c.getClusterExpansionZoom(s,(function(e,r){e||void 0===r||n.easeTo({center:[f,d],zoom:(null!=r?r:0)+.5,duration:300})}))}}({mapRef:a,feature:d})}}}),[l,s,o,n,u,a])};
//# sourceMappingURL=useMapClickHandler.js.map
