@corva/ui 3.70.0-4 → 3.70.0-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.js +1 -1
  2. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
  3. package/cjs-bundle/components/BICOffsetPickerDialog/components/Map/Map.js +1 -1
  4. package/cjs-bundle/components/BICOffsetPickerDialog/components/Map/Map.js.map +1 -1
  5. package/cjs-bundle/components/NewCommentCursor/NewCommentCursor.js +1 -1
  6. package/cjs-bundle/components/NewCommentCursor/NewCommentCursor.scss.js +1 -1
  7. package/cjs-bundle/components/OffsetWellMap/OffsetWellMap.js +1 -1
  8. package/cjs-bundle/components/OffsetWellMap/OffsetWellMap.js.map +1 -1
  9. package/cjs-bundle/components/OffsetWellPickerV2/components/Map/Map.js +1 -1
  10. package/cjs-bundle/components/OffsetWellPickerV2/components/Map/Map.js.map +1 -1
  11. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js +1 -1
  12. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js.map +1 -1
  13. package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/OffsetWellMap.js +1 -1
  14. package/cjs-bundle/components/OffsetWellPickerV5/components/MapPreloader/MapPreloader.js +1 -1
  15. package/cjs-bundle/components/PinnableFilters/effects/index.js +1 -1
  16. package/cjs-bundle/components/PinnableFilters/effects/index.js.map +1 -1
  17. package/cjs-bundle/config/mapbox/index.js +1 -1
  18. package/cjs-bundle/config/mapbox/index.js.map +1 -1
  19. package/components/AttachmentPreview/AttachmentPreview.d.ts.map +1 -1
  20. package/components/AttachmentPreview/AttachmentPreview.js +1 -1
  21. package/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
  22. package/components/BICOffsetPickerDialog/components/Map/Map.d.ts.map +1 -1
  23. package/components/BICOffsetPickerDialog/components/Map/Map.js +1 -1
  24. package/components/BICOffsetPickerDialog/components/Map/Map.js.map +1 -1
  25. package/components/NewCommentCursor/NewCommentCursor.d.ts.map +1 -1
  26. package/components/NewCommentCursor/NewCommentCursor.js +1 -1
  27. package/components/NewCommentCursor/NewCommentCursor.scss.js +1 -1
  28. package/components/OffsetWellMap/OffsetWellMap.d.ts.map +1 -1
  29. package/components/OffsetWellMap/OffsetWellMap.js +1 -1
  30. package/components/OffsetWellMap/OffsetWellMap.js.map +1 -1
  31. package/components/OffsetWellPickerV2/components/Map/Map.d.ts.map +1 -1
  32. package/components/OffsetWellPickerV2/components/Map/Map.js +1 -1
  33. package/components/OffsetWellPickerV2/components/Map/Map.js.map +1 -1
  34. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.d.ts.map +1 -1
  35. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js +1 -1
  36. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js.map +1 -1
  37. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/OffsetWellMap.d.ts.map +1 -1
  38. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/OffsetWellMap.js +1 -1
  39. package/components/OffsetWellPickerV5/components/MapPreloader/MapPreloader.d.ts.map +1 -1
  40. package/components/OffsetWellPickerV5/components/MapPreloader/MapPreloader.js +1 -1
  41. package/components/PinnableFilters/effects/index.js +1 -1
  42. package/components/PinnableFilters/effects/index.js.map +1 -1
  43. package/config/mapbox/index.d.ts +1 -0
  44. package/config/mapbox/index.d.ts.map +1 -1
  45. package/config/mapbox/index.js +1 -1
  46. package/config/mapbox/index.js.map +1 -1
  47. package/mcp-server/server.mjs +11 -1
  48. package/package.json +1 -1
  49. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Map.js","sources":["../../../../../src/components/BICOffsetPickerDialog/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get } from 'lodash';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport mapboxgl from '~/config/mapboxGl';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 8;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#FFC107';\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst HIGHLIGHT_ID = 'wells-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\nconst toolTip =\n () =>\n // eslint-disable-next-line react/prop-types\n ({ well }) => {\n return (\n <div style={{ color: '#fff', background: '##414141' }}>\n <span style={{ fontSize: '11px', lineHeight: '16px' }}>{get(well, 'name')}</span>\n </div>\n );\n };\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Initialize map\n useEffect(() => {\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack),\n // and the hover highlight layer last so it renders on top of the markers\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n mapRef.current.addSource(HIGHLIGHT_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: HIGHLIGHT_ID,\n type: 'circle',\n source: HIGHLIGHT_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': 0.2,\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n }, [radius, subjectWellCoords, isMapReady]);\n\n const handleMouseOver = (coords, r) => {\n // Highlight the hovered well with a bigger translucent circle\n mapRef.current.getSource(HIGHLIGHT_ID).setData({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { radius: r * 3 },\n });\n };\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n mapRef.current.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n const coords = get(well, coordsDataPath);\n\n // Tooltip\n const tooltipContainer = document.createElement('div');\n const tootipContent = createElement(toolTip(), { well });\n ReactDOM.render(tootipContent, tooltipContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current.setLngLat(toLngLat(coords)).setDOMContent(tooltipContainer).addTo(map);\n\n // Highlight\n handleMouseOver(coords, e.features[0].properties.radius);\n };\n\n // NOTE: was the mouseout handler of the Leaflet highlight marker\n const handleHighlightMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n map.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n popupRef.current?.remove();\n };\n\n // NOTE: If the pointer exits before the highlight renders under it, the highlight\n // layer never emits mouseleave — clear here unless the cursor is inside the highlight\n const handleWellsMouseLeave = e => {\n if (e?.point && map.queryRenderedFeatures(e.point, { layers: [HIGHLIGHT_ID] }).length) {\n return;\n }\n handleHighlightMouseLeave();\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.on('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && markersBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.off('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","HIGHLIGHT_ID","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref6","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","coordsDataPath","mapContainerRef","useRef","mapRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","subjectWellCoords","useMemo","get","useEffect","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","id","source","paint","map","remove","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","push","sin","makeCirclePolygon","getSource","setData","geometry","coordinates","_popupRef$current","prevWells","offsetWellIds","well","wellsById","bounds","LngLatBounds","forEach","coords","isWellSubject","isWellOffset","includes","r","opacity","extend","properties","wellId","length","hoveredWellId","handleMouseMove","e","getCanvas","cursor","tooltipContainer","document","createElement","tootipContent","_ref5","_jsx","color","background","children","fontSize","lineHeight","ReactDOM","render","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseOver","handleHighlightMouseLeave","_popupRef$current2","handleWellsMouseLeave","point","queryRenderedFeatures","layers","setTimeout","fitBounds","off","className","styles","mapMain","ref","propTypes","PropTypes","shape","number","formation","string","arrayOf","isRequired","defaultProps","memo"],"mappings":"6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EAAiBY,QAE7C,GAAE,KAEI,WACLmB,EAAIyE,IAAI,YAhPG,QAgPoBhC,GAC/BzC,EAAIyE,IAAI,aAjPG,QAiPqBN,GAChCnE,EAAIyE,IAAI,aAAc7H,EAAcqH,GA5FtC,CA8FD,GAAE,CAAC1G,EAAaC,EAAOC,EAAac,IAGnC2E,EAAA,MAAA,CAAKwB,UAAWC,EAAO3E,IAAIqD,SACzBH,EAAA,MAAA,CAAKwB,UAAWC,EAAOC,QAASC,IAAK/G,KAG3C,CAEAT,EAASyH,UAAY,CACnBvH,YAAawH,EAAUC,MAAM,CAC3BnF,GAAIkF,EAAUE,OACdC,UAAWH,EAAUI,SAEvB3H,MAAOuH,EAAUK,QAAQL,EAAUC,MAAM,CAAA,IAAKK,WAC9C5H,YAAasH,EAAUK,QAAQL,EAAUC,MAAM,CAAE,IACjDtH,OAAQqH,EAAUE,OAAOI,WACzB1H,sBAAuBoH,EAAUE,OACjCrH,eAAgBmH,EAAUE,OAC1BpH,eAAgBkH,EAAUI,QAG5B9H,EAASiI,aAAe,CACtB/H,YAAa,KACbI,sBAnRuC,EAoRvCC,eAnR+B,EAoR/BC,eAAgB,gCAChBJ,YAAa,MAGf,IAAe8H,EAAAA,EAAKlI"}
1
+ {"version":3,"file":"Map.js","sources":["../../../../../src/components/BICOffsetPickerDialog/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get } from 'lodash';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport mapboxgl from '~/config/mapboxGl';\nimport { IS_MAPBOX_ENABLED } from '~/config/mapbox';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 8;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#FFC107';\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst HIGHLIGHT_ID = 'wells-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\nconst toolTip =\n () =>\n // eslint-disable-next-line react/prop-types\n ({ well }) => {\n return (\n <div style={{ color: '#fff', background: '##414141' }}>\n <span style={{ fontSize: '11px', lineHeight: '16px' }}>{get(well, 'name')}</span>\n </div>\n );\n };\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Initialize map\n useEffect(() => {\n if (!IS_MAPBOX_ENABLED) return undefined;\n\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack),\n // and the hover highlight layer last so it renders on top of the markers\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n mapRef.current.addSource(HIGHLIGHT_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: HIGHLIGHT_ID,\n type: 'circle',\n source: HIGHLIGHT_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': 0.2,\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n }, [radius, subjectWellCoords, isMapReady]);\n\n const handleMouseOver = (coords, r) => {\n // Highlight the hovered well with a bigger translucent circle\n mapRef.current.getSource(HIGHLIGHT_ID).setData({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { radius: r * 3 },\n });\n };\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n mapRef.current.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n const coords = get(well, coordsDataPath);\n\n // Tooltip\n const tooltipContainer = document.createElement('div');\n const tootipContent = createElement(toolTip(), { well });\n ReactDOM.render(tootipContent, tooltipContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current.setLngLat(toLngLat(coords)).setDOMContent(tooltipContainer).addTo(map);\n\n // Highlight\n handleMouseOver(coords, e.features[0].properties.radius);\n };\n\n // NOTE: was the mouseout handler of the Leaflet highlight marker\n const handleHighlightMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n map.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n popupRef.current?.remove();\n };\n\n // NOTE: If the pointer exits before the highlight renders under it, the highlight\n // layer never emits mouseleave — clear here unless the cursor is inside the highlight\n const handleWellsMouseLeave = e => {\n if (e?.point && map.queryRenderedFeatures(e.point, { layers: [HIGHLIGHT_ID] }).length) {\n return;\n }\n handleHighlightMouseLeave();\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.on('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && markersBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.off('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","HIGHLIGHT_ID","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref6","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","coordsDataPath","mapContainerRef","useRef","mapRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","subjectWellCoords","useMemo","get","useEffect","IS_MAPBOX_ENABLED","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","id","source","paint","map","remove","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","push","sin","makeCirclePolygon","getSource","setData","geometry","coordinates","_popupRef$current","prevWells","offsetWellIds","well","wellsById","bounds","LngLatBounds","forEach","coords","isWellSubject","isWellOffset","includes","r","opacity","extend","properties","wellId","length","hoveredWellId","handleMouseMove","e","getCanvas","cursor","tooltipContainer","document","createElement","tootipContent","_ref5","_jsx","color","background","children","fontSize","lineHeight","ReactDOM","render","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseOver","handleHighlightMouseLeave","_popupRef$current2","handleWellsMouseLeave","point","queryRenderedFeatures","layers","setTimeout","fitBounds","off","className","styles","mapMain","ref","propTypes","PropTypes","shape","number","formation","string","arrayOf","isRequired","defaultProps","memo"],"mappings":"ohBAYA,IAAQA,EAAuBC,EAAvBD,mBAQFE,EAAiB,CAAC,WAAY,WAI9BC,EAAe,kBACfC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAElEC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EA0B3C,SAASC,EAQNC,GAAA,IAPDC,IAAAA,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E,IAAIqD,SACzBH,EAAA,MAAA,CAAKwB,UAAWC,EAAOC,QAASC,IAAKhH,KAG3C,CAEAT,EAAS0H,UAAY,CACnBxH,YAAayH,EAAUC,MAAM,CAC3BnF,GAAIkF,EAAUE,OACdC,UAAWH,EAAUI,SAEvB5H,MAAOwH,EAAUK,QAAQL,EAAUC,MAAM,CAAA,IAAKK,WAC9C7H,YAAauH,EAAUK,QAAQL,EAAUC,MAAM,CAAE,IACjDvH,OAAQsH,EAAUE,OAAOI,WACzB3H,sBAAuBqH,EAAUE,OACjCtH,eAAgBoH,EAAUE,OAC1BrH,eAAgBmH,EAAUI,QAG5B/H,EAASkI,aAAe,CACtBhI,YAAa,KACbI,sBArRuC,EAsRvCC,eArR+B,EAsR/BC,eAAgB,gCAChBJ,YAAa,MAGf,IAAe+H,EAAAA,EAAKnI"}
@@ -1 +1 @@
1
- {"version":3,"file":"NewCommentCursor.d.ts","sourceRoot":"","sources":["../../../src/components/NewCommentCursor/NewCommentCursor.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,kHAe5B,CAAC"}
1
+ {"version":3,"file":"NewCommentCursor.d.ts","sourceRoot":"","sources":["../../../src/components/NewCommentCursor/NewCommentCursor.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAQF,eAAO,MAAM,gBAAgB,kHA+B5B,CAAC"}
@@ -1,2 +1,2 @@
1
- import{jsx as r,jsxs as e}from"react/jsx-runtime";import{forwardRef as t}from"react";import i from"classnames";import o from"./NewCommentCursor.scss.js";var s=t((function(t,s){var l=t.size,a=void 0===l?40:l,c=t.onClick,m=t.className,n=t.testId;return r("div",{ref:s,"data-testid":n,className:i(o.root,m),style:{width:a,height:a},onClick:c,children:e("svg",{className:o.glyph,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[r("rect",{x:"6",y:"11.1",width:"12",height:"1.8",rx:"0.9",fill:"currentColor"}),r("rect",{x:"11.1",y:"6",width:"1.8",height:"12",rx:"0.9",fill:"currentColor"})]})})}));export{s as NewCommentCursor};
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{forwardRef as i}from"react";import o from"classnames";import l from"./NewCommentCursor.scss.js";var t=i((function(i,t){var d=i.size,n=void 0===d?40:d,s=i.onClick,a=i.className,c=i.testId;return e("div",{ref:t,"data-testid":c,className:o(l.root,a),style:{width:n,height:n},onClick:s,children:r("svg",{width:.48839026568430455*n,height:.48839026568430455*n,viewBox:"0 0 8.75 8.75",fill:"none","aria-hidden":!0,children:[e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 4.375C0 4.02982 0.279822 3.75 0.625 3.75H8.125C8.47018 3.75 8.75 4.02982 8.75 4.375C8.75 4.72018 8.47018 5 8.125 5H0.625C0.279822 5 0 4.72018 0 4.375Z",fill:"currentColor"}),e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.375 0C4.72018 0 5 0.279822 5 0.625V8.125C5 8.47018 4.72018 8.75 4.375 8.75C4.02982 8.75 3.75 8.47018 3.75 8.125V0.625C3.75 0.279822 4.02982 0 4.375 0Z",fill:"currentColor"})]})})}));export{t as NewCommentCursor};
2
2
  //# sourceMappingURL=NewCommentCursor.js.map
@@ -1,2 +1,2 @@
1
- import r from'./../../ext-esm/style-inject/dist/style-inject.es.js';var e={spacing:"8",root:"NewCommentCursor_root__41tBB",glyph:"NewCommentCursor_glyph__NnE7w"};r(".NewCommentCursor_root__41tBB{align-items:center;background:var(--palette-primary-text-1);border-radius:50% 50% 50% 4px;box-shadow:0 4px 8px rgb(from var(--palette-background-b-1) r g b/.32);color:var(--palette-background-b-4);cursor:pointer;display:flex;justify-content:center}.NewCommentCursor_glyph__NnE7w{height:60%;width:60%}");export{e as default};
1
+ import r from'./../../ext-esm/style-inject/dist/style-inject.es.js';var t={spacing:"8",root:"NewCommentCursor_root__41tBB"};r(".NewCommentCursor_root__41tBB{align-items:center;background:var(--palette-primary-text-1);border-radius:50% 50% 50% 4px;box-shadow:0 4px 8px rgb(from var(--palette-background-b-1) r g b/.32);color:var(--palette-background-b-4);cursor:pointer;display:flex;justify-content:center}");export{t as default};
2
2
  //# sourceMappingURL=NewCommentCursor.scss.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OffsetWellMap.d.ts","sourceRoot":"","sources":["../../../src/components/OffsetWellMap/OffsetWellMap.js"],"names":[],"mappings":";AAkEA,0EAA0E;AAC1E,6BADW,KAAK,CAAC,EAAE,CAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,CA+bpE"}
1
+ {"version":3,"file":"OffsetWellMap.d.ts","sourceRoot":"","sources":["../../../src/components/OffsetWellMap/OffsetWellMap.js"],"names":[],"mappings":";AAmEA,0EAA0E;AAC1E,6BADW,KAAK,CAAC,EAAE,CAAC,OAAO,sBAAsB,EAAE,kBAAkB,CAAC,CAicpE"}
@@ -1,2 +1,2 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{useMemo as t,useRef as l,useState as o,useEffect as i,createElement as c}from"react";import n from"react-dom";import{get as u}from"lodash";import s from"classnames";import{Tooltip as a}from"@material-ui/core";import{Add as d,Remove as f}from"@material-ui/icons";import"mapbox-gl/dist/mapbox-gl.css";import{usePreviousWells as m}from"./effects/usePreviousWells.js";import{WellTooltip as v}from"./WellTooltip.js";import{getAllFormations as h}from"./utils.js";import p from"./OffsetWellMap.module.css.js";import"../../config/mapboxGl/index.js";import{mapbox as g}from"../../utils/index.js";import{jsx as y,jsxs as w,Fragment as b}from"react/jsx-runtime";import W from"mapbox-gl";var j=g.isValidCoordinates,C=[29.749907,-95.358421],F={type:"FeatureCollection",features:[]},B=["==",["id"],-1],L=function(e){var t=r(e,2),l=t[0];return[t[1],l]},D=function(e,t){for(var l=r(e,2),o=l[0],i=l[1],c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,n=t/(111320*Math.cos(o*Math.PI/180)),u=t/110574,s=[],a=0;a<=c;a+=1){var d=a/c*2*Math.PI;s.push([i+n*Math.cos(d),o+u*Math.sin(d)])}return{type:"Polygon",coordinates:[s]}},M=function(g){var M=g.isViewOnly,O=g.subjectWell,x=void 0===O?null:O,S=g.wells,k=g.offsetWellIds,P=g.radius,z=g.handleChanageOffsetWell,I=g.handleChangeOffsetWell,Z=void 0===I?z:I,E=g.activeWellId,N=g.isClickable,T=void 0===N||N,V=g.classes,A=void 0===V?{}:V,G=t((function(){return x&&u(x,"topHole.coordinates")}),[x]),H=t((function(){return h(S)}),[S]),q=l(),R=l(),J=l(),K=l(null),Q=l(null),U=l(),X=l(new Map),Y=l(null),$=l(null),_=o(!1),ee=r(_,2),re=ee[0],te=ee[1],le=(null==x?void 0:x.id)===E,oe=m(S),ie=o(!1),ce=r(ie,2),ne=ce[0],ue=ce[1],se=o(3),ae=r(se,2),de=ae[0],fe=ae[1];i((function(){var e=new W.Map({container:q.current,style:"mapbox://styles/mapbox/dark-v9",center:L(C),zoom:3,maxZoom:18,attributionControl:!1,scrollZoom:!1,doubleClickZoom:!1});return R.current=e,e.on("zoomend",(function(){return fe(Math.round(e.getZoom()))})),e.on("load",(function(){e.addSource("radius-circle",{type:"geojson",data:F}),e.addLayer({id:"radius-circle-fill",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),e.addSource("wells",{type:"geojson",data:F}),e.addLayer({id:"wells-halo",type:"circle",source:"wells",filter:["==",["get","isOffsetWell"],!0],paint:{"circle-radius":12,"circle-color":["get","color"],"circle-opacity":.08}}),e.addLayer({id:"wells-circle",type:"circle",source:"wells",layout:{"circle-sort-key":["get","order"]},paint:{"circle-radius":5,"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),e.addLayer({id:"wells-active-highlight",type:"circle",source:"wells",filter:["==",["get","isActive"],!0],paint:{"circle-radius":12,"circle-color":["get","color"],"circle-opacity":.24}}),e.addLayer({id:"wells-hover-highlight",type:"circle",source:"wells",filter:B,paint:{"circle-radius":["case",["get","isSubjectWell"],5,12],"circle-color":["case",["get","isSubjectWell"],"#63EFFF",["get","color"]],"circle-opacity":.24}}),ue(!0)})),function(){e.remove(),R.current=null,J.current=null,U.current=null,K.current=null,Q.current=null}}),[]),i((function(){var e,t,l,o,i,c;K.current=G&&P?(e=1609.34*P,t=r(G,2),l=t[0],o=t[1],i=e/(111320*Math.cos(l*Math.PI/180)),[[o-i,l-(c=e/110574)],[o+i,l+c]]):null;var n=R.current;n&&ne&&n.getSource("radius-circle").setData(G&&P?{type:"Feature",properties:{},geometry:D(G,1609.34*P)}:F)}),[P,G,ne]);var me=function(e,r,t,l){var o=document.createElement("div"),i=c(v(),{isViewOnly:M,well:e,color:u(H,e.formation,"#BDBDBD"),isOffsetWell:r,isSubjectWell:t,isClickable:T});n.render(y(b,{children:i}),o),J.current||(J.current=new W.Popup({closeButton:!1,offset:12})),J.current.setLngLat(L(l)).setDOMContent(o).addTo(R.current)};i((function(){var e=R.current;e&&ne&&e.setPaintProperty("wells-circle","circle-color",re?["case",["get","isSubjectWell"],"#63EFFF",["get","color"]]:["get","color"])}),[re,ne]),i((function(){var e;if(S&&k){null===(e=J.current)||void 0===e||e.remove();var r=[],t=[];S.forEach((function(e){e.id!==(null==x?void 0:x.id)&&(k.includes(e.id)?r.push(e):t.push(e))}));var l=[].concat(t,r,[x]),o=[],i=new W.LngLatBounds;X.current.clear(),Y.current=null,l.forEach((function(e,r){var t,l=null==e||null===(t=e.topHole)||void 0===t?void 0:t.coordinates;if(l&&j(l)){var c=(null==x?void 0:x.id)===e.id,n=k.includes(e.id)&&!c,s=c?"#03BCD4":u(H,e.formation,"#BDBDBD"),a=n?.7:.3;o.push({type:"Feature",id:r,geometry:{type:"Point",coordinates:L(l)},properties:{color:s,opacity:c?1:a,isSubjectWell:c,isOffsetWell:n,isActive:e.id===E&&!le,order:r}}),X.current.set(r,{well:e,coords:l,isOffsetWell:n,isSubjectWell:c}),c&&(Y.current=r),i.extend(L(l))}})),Q.current=o.length?i:null;var c=R.current;if(c&&ne){c.getSource("wells").setData({type:"FeatureCollection",features:o}),c.setFilter("wells-hover-highlight",B),$.current=null;var n=function(e){var r,t=null===(r=e.features)||void 0===r?void 0:r[0];if(t&&$.current!==t.id){var l=X.current.get(t.id);l&&($.current=t.id,c.getCanvas().style.cursor="pointer",c.setFilter("wells-hover-highlight",["==",["id"],t.id]),me(l.well,l.isOffsetWell,l.isSubjectWell,l.coords),l.isSubjectWell&&te(!0))}},s=function(e){var r;if(null==e||!e.point||!c.queryRenderedFeatures(e.point,{layers:["wells-circle","wells-hover-highlight"]}).length){var t=null!==$.current&&$.current===Y.current;$.current=null,c.getCanvas().style.cursor="",c.setFilter("wells-hover-highlight",B),null===(r=J.current)||void 0===r||r.remove(),t&&te(!1)}},a=function(e){var r,t;if(!M){var l=X.current.get(null===(r=e.features)||void 0===r||null===(t=r[0])||void 0===t?void 0:t.id);l&&Z(l.well,!l.isOffsetWell)}};return c.on("mousemove","wells-circle",n),c.on("mouseleave","wells-circle",s),c.on("mouseleave","wells-hover-highlight",s),c.on("click","wells-circle",a),setTimeout((function(){P<3e3&&R.current&&K.current&&S!==oe&&R.current.fitBounds(K.current,{padding:5})}),500),function(){c.off("mousemove","wells-circle",n),c.off("mouseleave","wells-circle",s),c.off("mouseleave","wells-hover-highlight",s),c.off("click","wells-circle",a)}}}}),[x,S,k,E,ne]),i((function(){var e=R.current;if(U.current&&(U.current.remove(),U.current=null),e&&G){var t=re||le,l=document.createElement("img");l.src=t?"/static/media/5e9c4959259cb12c11b2c5eaf27eb3ad.svg":"/static/media/9efe5882f31d2f22bd57af92069d0a3e.svg";var o=r(t?[70,20]:[62,12],2),i=o[0],c=o[1],n=r(t?[35,29]:[31,25],2),u=n[0],s=n[1];l.width=i,l.height=c,l.addEventListener("mouseover",(function(){te(!0),null!==Y.current&&e.getLayer("wells-hover-highlight")&&($.current=Y.current,e.setFilter("wells-hover-highlight",["==",["id"],Y.current])),me(x,!1,!0,G)})),l.addEventListener("mouseout",(function(){var r;$.current=null,e.getLayer("wells-hover-highlight")&&e.setFilter("wells-hover-highlight",B),null===(r=J.current)||void 0===r||r.remove(),te(!1)})),U.current=new W.Marker({element:l,anchor:"center",offset:[i/2-u,c/2-s]}).setLngLat(L(G)).addTo(e)}}),[re,G,P,x,le]),i((function(){P>3e3?R.current.setZoom(1):setTimeout((function(){x?R.current&&K.current&&P&&R.current.fitBounds(K.current,{padding:5}):R.current&&Q.current&&R.current.fitBounds(Q.current),G&&R.current&&R.current.easeTo({center:L(G),duration:700})}),500)}),[P,x,G]);var ve=function(){R.current.setZoom(de+1)};return y("div",{className:s(p.mapView,A.root),children:y("div",{className:s(p.mapMain,A.map),ref:q,onDoubleClick:ve,children:w("div",{className:p.zoomGroup,children:[y(a,{title:de<18?"Zoom in":"",placement:"left",children:y("div",{className:s(p.zoomButton,e({},p.zoomDisabled,18===de)),onClick:ve,children:y(d,{className:p.zoomInOutIcon})})}),y(a,{title:de>1?"Zoom out":"",placement:"left",children:y("div",{className:s(p.zoomButton,e({},p.zoomDisabled,1===de)),onClick:function(){de>1&&R.current.setZoom(de-1)},children:y(f,{className:p.zoomInOutIcon})})})]})})})};export{M as default};
1
+ import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{useMemo as t,useRef as l,useState as o,useEffect as i,createElement as c}from"react";import n from"react-dom";import{get as u}from"lodash";import a from"classnames";import{Tooltip as s}from"@material-ui/core";import{Add as d,Remove as f}from"@material-ui/icons";import"mapbox-gl/dist/mapbox-gl.css";import{usePreviousWells as m}from"./effects/usePreviousWells.js";import{WellTooltip as v}from"./WellTooltip.js";import{getAllFormations as h}from"./utils.js";import p from"./OffsetWellMap.module.css.js";import"../../config/mapboxGl/index.js";import{IS_MAPBOX_ENABLED as g}from"../../config/mapbox/index.js";import{mapbox as y}from"../../utils/index.js";import{jsx as w,jsxs as b,Fragment as W}from"react/jsx-runtime";import j from"mapbox-gl";var C=y.isValidCoordinates,F=[29.749907,-95.358421],B={type:"FeatureCollection",features:[]},L=["==",["id"],-1],x=function(e){var t=r(e,2),l=t[0];return[t[1],l]},D=function(e,t){for(var l=r(e,2),o=l[0],i=l[1],c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,n=t/(111320*Math.cos(o*Math.PI/180)),u=t/110574,a=[],s=0;s<=c;s+=1){var d=s/c*2*Math.PI;a.push([i+n*Math.cos(d),o+u*Math.sin(d)])}return{type:"Polygon",coordinates:[a]}},M=function(y){var M=y.isViewOnly,O=y.subjectWell,S=void 0===O?null:O,k=y.wells,P=y.offsetWellIds,z=y.radius,I=y.handleChanageOffsetWell,Z=y.handleChangeOffsetWell,E=void 0===Z?I:Z,N=y.activeWellId,T=y.isClickable,V=void 0===T||T,A=y.classes,G=void 0===A?{}:A,H=t((function(){return S&&u(S,"topHole.coordinates")}),[S]),q=t((function(){return h(k)}),[k]),R=l(),J=l(),K=l(),Q=l(null),U=l(null),X=l(),Y=l(new Map),$=l(null),_=l(null),ee=o(!1),re=r(ee,2),te=re[0],le=re[1],oe=(null==S?void 0:S.id)===N,ie=m(k),ce=o(!1),ne=r(ce,2),ue=ne[0],ae=ne[1],se=o(3),de=r(se,2),fe=de[0],me=de[1];i((function(){if(g){var e=new j.Map({container:R.current,style:"mapbox://styles/mapbox/dark-v9",center:x(F),zoom:3,maxZoom:18,attributionControl:!1,scrollZoom:!1,doubleClickZoom:!1});return J.current=e,e.on("zoomend",(function(){return me(Math.round(e.getZoom()))})),e.on("load",(function(){e.addSource("radius-circle",{type:"geojson",data:B}),e.addLayer({id:"radius-circle-fill",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),e.addSource("wells",{type:"geojson",data:B}),e.addLayer({id:"wells-halo",type:"circle",source:"wells",filter:["==",["get","isOffsetWell"],!0],paint:{"circle-radius":12,"circle-color":["get","color"],"circle-opacity":.08}}),e.addLayer({id:"wells-circle",type:"circle",source:"wells",layout:{"circle-sort-key":["get","order"]},paint:{"circle-radius":5,"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),e.addLayer({id:"wells-active-highlight",type:"circle",source:"wells",filter:["==",["get","isActive"],!0],paint:{"circle-radius":12,"circle-color":["get","color"],"circle-opacity":.24}}),e.addLayer({id:"wells-hover-highlight",type:"circle",source:"wells",filter:L,paint:{"circle-radius":["case",["get","isSubjectWell"],5,12],"circle-color":["case",["get","isSubjectWell"],"#63EFFF",["get","color"]],"circle-opacity":.24}}),ae(!0)})),function(){e.remove(),J.current=null,K.current=null,X.current=null,Q.current=null,U.current=null}}}),[]),i((function(){var e,t,l,o,i,c;Q.current=H&&z?(e=1609.34*z,t=r(H,2),l=t[0],o=t[1],i=e/(111320*Math.cos(l*Math.PI/180)),[[o-i,l-(c=e/110574)],[o+i,l+c]]):null;var n=J.current;n&&ue&&n.getSource("radius-circle").setData(H&&z?{type:"Feature",properties:{},geometry:D(H,1609.34*z)}:B)}),[z,H,ue]);var ve=function(e,r,t,l){var o=document.createElement("div"),i=c(v(),{isViewOnly:M,well:e,color:u(q,e.formation,"#BDBDBD"),isOffsetWell:r,isSubjectWell:t,isClickable:V});n.render(w(W,{children:i}),o),K.current||(K.current=new j.Popup({closeButton:!1,offset:12})),K.current.setLngLat(x(l)).setDOMContent(o).addTo(J.current)};i((function(){var e=J.current;e&&ue&&e.setPaintProperty("wells-circle","circle-color",te?["case",["get","isSubjectWell"],"#63EFFF",["get","color"]]:["get","color"])}),[te,ue]),i((function(){var e;if(k&&P){null===(e=K.current)||void 0===e||e.remove();var r=[],t=[];k.forEach((function(e){e.id!==(null==S?void 0:S.id)&&(P.includes(e.id)?r.push(e):t.push(e))}));var l=[].concat(t,r,[S]),o=[],i=new j.LngLatBounds;Y.current.clear(),$.current=null,l.forEach((function(e,r){var t,l=null==e||null===(t=e.topHole)||void 0===t?void 0:t.coordinates;if(l&&C(l)){var c=(null==S?void 0:S.id)===e.id,n=P.includes(e.id)&&!c,a=c?"#03BCD4":u(q,e.formation,"#BDBDBD"),s=n?.7:.3;o.push({type:"Feature",id:r,geometry:{type:"Point",coordinates:x(l)},properties:{color:a,opacity:c?1:s,isSubjectWell:c,isOffsetWell:n,isActive:e.id===N&&!oe,order:r}}),Y.current.set(r,{well:e,coords:l,isOffsetWell:n,isSubjectWell:c}),c&&($.current=r),i.extend(x(l))}})),U.current=o.length?i:null;var c=J.current;if(c&&ue){c.getSource("wells").setData({type:"FeatureCollection",features:o}),c.setFilter("wells-hover-highlight",L),_.current=null;var n=function(e){var r,t=null===(r=e.features)||void 0===r?void 0:r[0];if(t&&_.current!==t.id){var l=Y.current.get(t.id);l&&(_.current=t.id,c.getCanvas().style.cursor="pointer",c.setFilter("wells-hover-highlight",["==",["id"],t.id]),ve(l.well,l.isOffsetWell,l.isSubjectWell,l.coords),l.isSubjectWell&&le(!0))}},a=function(e){var r;if(null==e||!e.point||!c.queryRenderedFeatures(e.point,{layers:["wells-circle","wells-hover-highlight"]}).length){var t=null!==_.current&&_.current===$.current;_.current=null,c.getCanvas().style.cursor="",c.setFilter("wells-hover-highlight",L),null===(r=K.current)||void 0===r||r.remove(),t&&le(!1)}},s=function(e){var r,t;if(!M){var l=Y.current.get(null===(r=e.features)||void 0===r||null===(t=r[0])||void 0===t?void 0:t.id);l&&E(l.well,!l.isOffsetWell)}};return c.on("mousemove","wells-circle",n),c.on("mouseleave","wells-circle",a),c.on("mouseleave","wells-hover-highlight",a),c.on("click","wells-circle",s),setTimeout((function(){z<3e3&&J.current&&Q.current&&k!==ie&&J.current.fitBounds(Q.current,{padding:5})}),500),function(){c.off("mousemove","wells-circle",n),c.off("mouseleave","wells-circle",a),c.off("mouseleave","wells-hover-highlight",a),c.off("click","wells-circle",s)}}}}),[S,k,P,N,ue]),i((function(){var e=J.current;if(X.current&&(X.current.remove(),X.current=null),e&&H){var t=te||oe,l=document.createElement("img");l.src=t?"/static/media/5e9c4959259cb12c11b2c5eaf27eb3ad.svg":"/static/media/9efe5882f31d2f22bd57af92069d0a3e.svg";var o=r(t?[70,20]:[62,12],2),i=o[0],c=o[1],n=r(t?[35,29]:[31,25],2),u=n[0],a=n[1];l.width=i,l.height=c,l.addEventListener("mouseover",(function(){le(!0),null!==$.current&&e.getLayer("wells-hover-highlight")&&(_.current=$.current,e.setFilter("wells-hover-highlight",["==",["id"],$.current])),ve(S,!1,!0,H)})),l.addEventListener("mouseout",(function(){var r;_.current=null,e.getLayer("wells-hover-highlight")&&e.setFilter("wells-hover-highlight",L),null===(r=K.current)||void 0===r||r.remove(),le(!1)})),X.current=new j.Marker({element:l,anchor:"center",offset:[i/2-u,c/2-a]}).setLngLat(x(H)).addTo(e)}}),[te,H,z,S,oe]),i((function(){var e;z>3e3?null===(e=J.current)||void 0===e||e.setZoom(1):setTimeout((function(){S?J.current&&Q.current&&z&&J.current.fitBounds(Q.current,{padding:5}):J.current&&U.current&&J.current.fitBounds(U.current),H&&J.current&&J.current.easeTo({center:x(H),duration:700})}),500)}),[z,S,H]);var he=function(){var e;null===(e=J.current)||void 0===e||e.setZoom(fe+1)};return w("div",{className:a(p.mapView,G.root),children:w("div",{className:a(p.mapMain,G.map),ref:R,onDoubleClick:he,children:b("div",{className:p.zoomGroup,children:[w(s,{title:fe<18?"Zoom in":"",placement:"left",children:w("div",{className:a(p.zoomButton,e({},p.zoomDisabled,18===fe)),onClick:he,children:w(d,{className:p.zoomInOutIcon})})}),w(s,{title:fe>1?"Zoom out":"",placement:"left",children:w("div",{className:a(p.zoomButton,e({},p.zoomDisabled,1===fe)),onClick:function(){var e;fe>1&&(null===(e=J.current)||void 0===e||e.setZoom(fe-1))},children:w(f,{className:p.zoomInOutIcon})})})]})})})};export{M as default};
2
2
  //# sourceMappingURL=OffsetWellMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OffsetWellMap.js","sources":["../../../src/components/OffsetWellMap/OffsetWellMap.js"],"sourcesContent":["import { createElement, useRef, useEffect, useState, useMemo } from 'react';\nimport ReactDOM from 'react-dom';\nimport { get } from 'lodash';\nimport classNames from 'classnames';\nimport { Tooltip } from '@material-ui/core';\nimport { Add as ZoomInIcon, Remove as ZoomOutIcon } from '@material-ui/icons';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nimport SubjectWellIcon from './CustomIcon/SubjectWellIcon.svg';\nimport SubjectHighlightWellIcon from './CustomIcon/SubjectHighlightWellIcon.svg';\nimport { usePreviousWells } from './effects';\nimport { WellTooltip } from './WellTooltip';\nimport { getAllFormations } from './utils';\n\nimport styles from './OffsetWellMap.module.css';\n\nimport mapboxgl from '~/config/mapboxGl';\nimport { mapbox } from '~/utils';\n\nconst { isValidCoordinates } = mapbox;\nconst DEFAULT_COORDS = [29.749907, -95.358421];\nconst WELL_MARKER_SIZE = 5;\nconst HIGHLIGHT_MARKER_SIZE = 12;\nconst OFFSET_WELL_COLOR = '#03BCD4';\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst HIGHLIGHT_WELL_COLOR = '#63EFFF';\nconst METERS_IN_MILE = 1609.34;\nconst ZOOM_INIT_VALUE = 3;\nconst ZOOM_MAX_VALUE = 18;\nconst ZOOM_MIN_VALUE = 1;\nconst MAX_RADIUS = 3000;\n\nconst RADIUS_SOURCE_ID = 'radius-circle';\nconst RADIUS_LAYER_ID = 'radius-circle-fill';\nconst WELLS_SOURCE_ID = 'wells';\nconst WELLS_HALO_LAYER_ID = 'wells-halo';\nconst WELLS_LAYER_ID = 'wells-circle';\nconst WELLS_ACTIVE_LAYER_ID = 'wells-active-highlight';\nconst WELLS_HOVER_LAYER_ID = 'wells-hover-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\nconst NO_HOVER_FILTER = ['==', ['id'], -1];\n\n// NOTE: Props keep the Leaflet [lat, lng] convention; mapbox-gl expects [lng, lat]\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl circle layers are pixel-radius, so approximate the meter radius with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n const ring = [];\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * 2 * Math.PI;\n ring.push([lng + degreesLng * Math.cos(theta), lat + degreesLat * Math.sin(theta)]);\n }\n return { type: 'Polygon', coordinates: [ring] };\n};\n\nconst getCircleBounds = ([lat, lng], radiusMeters) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n return [\n [lng - degreesLng, lat - degreesLat],\n [lng + degreesLng, lat + degreesLat],\n ];\n};\n\n/** @type {React.FC<import('./OffsetWellMapProps').OffsetWellMapProps>} */\nconst OffsetWellMap = ({\n isViewOnly,\n subjectWell = null,\n wells,\n offsetWellIds,\n radius,\n handleChanageOffsetWell,\n handleChangeOffsetWell = handleChanageOffsetWell,\n activeWellId,\n isClickable = true,\n classes = {},\n}) => {\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, 'topHole.coordinates');\n }, [subjectWell]);\n const formationColors = useMemo(() => getAllFormations(wells), [wells]);\n\n const containerRef = useRef();\n const mapRef = useRef();\n const popupRef = useRef();\n const radiusBoundsRef = useRef(null);\n const wellsBoundsRef = useRef(null);\n const subjectIconRef = useRef();\n const wellByFeatureIdRef = useRef(new Map());\n const subjectFeatureIdRef = useRef(null);\n const hoveredFeatureIdRef = useRef(null);\n const [isSubjectWellHovered, setIsSubjectWellHovered] = useState(false);\n const isActiveWellIsSubjectWell = subjectWell?.id === activeWellId;\n const prevWells = usePreviousWells(wells);\n const [isMapReady, setIsMapReady] = useState(false);\n const [zoom, setZoom] = useState(ZOOM_INIT_VALUE);\n\n // NOTE: Initialize map\n useEffect(() => {\n const map = new mapboxgl.Map({\n container: containerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: ZOOM_INIT_VALUE,\n // NOTE: keep the zoom buttons' disable logic (zoom === ZOOM_MAX_VALUE) reachable\n maxZoom: ZOOM_MAX_VALUE,\n attributionControl: false,\n scrollZoom: false,\n doubleClickZoom: false,\n });\n mapRef.current = map;\n\n // NOTE: GL zoom is fractional where Leaflet was integer\n map.on('zoomend', () => setZoom(Math.round(map.getZoom())));\n\n // NOTE: Sources/layers can only be added after the style loads\n map.on('load', () => {\n map.addSource(RADIUS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: RADIUS_LAYER_ID,\n type: 'fill',\n source: RADIUS_SOURCE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n map.addSource(WELLS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: WELLS_HALO_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isOffsetWell'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.08,\n },\n });\n map.addLayer({\n id: WELLS_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n layout: {\n 'circle-sort-key': ['get', 'order'],\n },\n paint: {\n 'circle-radius': WELL_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n map.addLayer({\n id: WELLS_ACTIVE_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isActive'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.24,\n },\n });\n map.addLayer({\n id: WELLS_HOVER_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: NO_HOVER_FILTER,\n paint: {\n 'circle-radius': [\n 'case',\n ['get', 'isSubjectWell'],\n WELL_MARKER_SIZE,\n HIGHLIGHT_MARKER_SIZE,\n ],\n 'circle-color': [\n 'case',\n ['get', 'isSubjectWell'],\n HIGHLIGHT_WELL_COLOR,\n ['get', 'color'],\n ],\n 'circle-opacity': 0.24,\n },\n });\n\n setIsMapReady(true);\n });\n\n return () => {\n map.remove();\n mapRef.current = null;\n popupRef.current = null;\n subjectIconRef.current = null;\n radiusBoundsRef.current = null;\n wellsBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n radiusBoundsRef.current =\n subjectWellCoords && radius\n ? getCircleBounds(subjectWellCoords, radius * METERS_IN_MILE)\n : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.getSource(RADIUS_SOURCE_ID).setData(\n subjectWellCoords && radius\n ? {\n type: 'Feature',\n properties: {},\n geometry: makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE),\n }\n : EMPTY_FEATURE_COLLECTION\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n const showTooltip = (well, isOffsetWell, isSubjectWell, coords) => {\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(WellTooltip(), {\n isViewOnly,\n well,\n color: get(formationColors, well.formation, '#BDBDBD'),\n isOffsetWell,\n isSubjectWell,\n isClickable,\n });\n ReactDOM.render(<>{popUpContent}</>, popUpContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({\n closeButton: false,\n offset: HIGHLIGHT_MARKER_SIZE,\n });\n }\n popupRef.current\n .setLngLat(toLngLat(coords))\n .setDOMContent(popUpContainer)\n .addTo(mapRef.current);\n };\n\n // NOTE: Subject well hover swaps the subject marker color\n useEffect(() => {\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.setPaintProperty(\n WELLS_LAYER_ID,\n 'circle-color',\n isSubjectWellHovered\n ? ['case', ['get', 'isSubjectWell'], HIGHLIGHT_WELL_COLOR, ['get', 'color']]\n : ['get', 'color']\n );\n }, [isSubjectWellHovered, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!wells || !offsetWellIds) {\n return undefined;\n }\n\n popupRef.current?.remove();\n\n const offsetWells = [];\n const unSelectedWells = [];\n wells.forEach(well => {\n if (well.id !== subjectWell?.id) {\n if (offsetWellIds.includes(well.id)) {\n offsetWells.push(well);\n } else {\n unSelectedWells.push(well);\n }\n }\n });\n const sortedWells = [...unSelectedWells, ...offsetWells, subjectWell];\n\n const features = [];\n const wellsBounds = new mapboxgl.LngLatBounds();\n wellByFeatureIdRef.current.clear();\n subjectFeatureIdRef.current = null;\n sortedWells.forEach((well, index) => {\n const coords = well?.topHole?.coordinates;\n\n if (coords && isValidCoordinates(coords)) {\n const isSubjectWell = subjectWell?.id === well.id;\n const isOffsetWell = offsetWellIds.includes(well.id) && !isSubjectWell;\n const color = isSubjectWell\n ? OFFSET_WELL_COLOR\n : get(formationColors, well.formation, '#BDBDBD');\n const opacity = isOffsetWell ? 0.7 : 0.3;\n\n features.push({\n type: 'Feature',\n id: index,\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: {\n color,\n opacity: isSubjectWell ? 1 : opacity,\n isSubjectWell,\n isOffsetWell,\n isActive: well.id === activeWellId && !isActiveWellIsSubjectWell,\n order: index,\n },\n });\n wellByFeatureIdRef.current.set(index, { well, coords, isOffsetWell, isSubjectWell });\n if (isSubjectWell) {\n subjectFeatureIdRef.current = index;\n }\n wellsBounds.extend(toLngLat(coords));\n }\n });\n wellsBoundsRef.current = features.length ? wellsBounds : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return undefined;\n }\n\n map.getSource(WELLS_SOURCE_ID).setData({ type: 'FeatureCollection', features });\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n hoveredFeatureIdRef.current = null;\n\n const handleMouseMove = e => {\n const feature = e.features?.[0];\n if (!feature || hoveredFeatureIdRef.current === feature.id) {\n return;\n }\n const entry = wellByFeatureIdRef.current.get(feature.id);\n if (!entry) {\n return;\n }\n\n hoveredFeatureIdRef.current = feature.id;\n map.getCanvas().style.cursor = 'pointer';\n\n // Highlight\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], feature.id]);\n showTooltip(entry.well, entry.isOffsetWell, entry.isSubjectWell, entry.coords);\n if (entry.isSubjectWell) {\n setIsSubjectWellHovered(true);\n }\n };\n\n const handleMouseLeave = e => {\n // NOTE: Leaflet cleared hover on leaving the ENLARGED highlight marker, so keep the\n // hover while the cursor is still over the hover halo (or another well marker)\n if (\n e?.point &&\n map.queryRenderedFeatures(e.point, { layers: [WELLS_LAYER_ID, WELLS_HOVER_LAYER_ID] })\n .length\n ) {\n return;\n }\n const wasSubjectWell =\n hoveredFeatureIdRef.current !== null &&\n hoveredFeatureIdRef.current === subjectFeatureIdRef.current;\n hoveredFeatureIdRef.current = null;\n map.getCanvas().style.cursor = '';\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n popupRef.current?.remove();\n if (wasSubjectWell) {\n setIsSubjectWellHovered(false);\n }\n };\n\n const handleClick = e => {\n if (isViewOnly) return;\n const entry = wellByFeatureIdRef.current.get(e.features?.[0]?.id);\n if (!entry) {\n return;\n }\n handleChangeOffsetWell(entry.well, !entry.isOffsetWell);\n };\n\n map.on('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.on('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.on('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.on('click', WELLS_LAYER_ID, handleClick);\n\n setTimeout(() => {\n if (radius < MAX_RADIUS && mapRef.current && radiusBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.off('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.off('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.off('click', WELLS_LAYER_ID, handleClick);\n };\n }, [subjectWell, wells, offsetWellIds, activeWellId, isMapReady]);\n\n // NOTE: Subject Well Icon\n\n useEffect(() => {\n const map = mapRef.current;\n\n if (subjectIconRef.current) {\n subjectIconRef.current.remove();\n subjectIconRef.current = null;\n }\n\n if (!map || !subjectWellCoords) return;\n\n const isHighlighted = isSubjectWellHovered || isActiveWellIsSubjectWell;\n const icon = document.createElement('img');\n icon.src = isHighlighted ? SubjectHighlightWellIcon : SubjectWellIcon;\n const [iconWidth, iconHeight] = isHighlighted ? [70, 20] : [62, 12];\n const [anchorX, anchorY] = isHighlighted ? [35, 29] : [31, 25];\n icon.width = iconWidth;\n icon.height = iconHeight;\n\n icon.addEventListener('mouseover', () => {\n setIsSubjectWellHovered(true);\n\n // Highlight\n if (subjectFeatureIdRef.current !== null && map.getLayer(WELLS_HOVER_LAYER_ID)) {\n hoveredFeatureIdRef.current = subjectFeatureIdRef.current;\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], subjectFeatureIdRef.current]);\n }\n showTooltip(subjectWell, false, true, subjectWellCoords);\n });\n\n icon.addEventListener('mouseout', () => {\n hoveredFeatureIdRef.current = null;\n if (map.getLayer(WELLS_HOVER_LAYER_ID)) {\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n }\n popupRef.current?.remove();\n setIsSubjectWellHovered(false);\n });\n\n subjectIconRef.current = new mapboxgl.Marker({\n element: icon,\n anchor: 'center',\n // NOTE: Leaflet anchored the icon at [anchorX, anchorY] from its top-left corner\n offset: [iconWidth / 2 - anchorX, iconHeight / 2 - anchorY],\n })\n .setLngLat(toLngLat(subjectWellCoords))\n .addTo(map);\n }, [isSubjectWellHovered, subjectWellCoords, radius, subjectWell, isActiveWellIsSubjectWell]);\n\n // NOTE: Map Update\n useEffect(() => {\n if (radius > MAX_RADIUS) {\n mapRef.current.setZoom(1);\n return;\n }\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusBoundsRef.current && radius) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n } else if (mapRef.current && wellsBoundsRef.current) {\n mapRef.current.fitBounds(wellsBoundsRef.current);\n }\n if (subjectWellCoords && mapRef.current) {\n mapRef.current.easeTo({ center: toLngLat(subjectWellCoords), duration: 700 });\n }\n }, 500);\n }, [radius, subjectWell, subjectWellCoords]);\n\n const handleZoomIn = () => {\n mapRef.current.setZoom(zoom + 1);\n };\n\n const handleZoomOut = () => {\n if (zoom > 1) {\n mapRef.current.setZoom(zoom - 1);\n }\n };\n\n return (\n <div className={classNames(styles.mapView, classes.root)}>\n <div\n className={classNames(styles.mapMain, classes.map)}\n ref={containerRef}\n onDoubleClick={handleZoomIn}\n >\n <div className={styles.zoomGroup}>\n <Tooltip title={zoom < ZOOM_MAX_VALUE ? 'Zoom in' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MAX_VALUE,\n })}\n onClick={handleZoomIn}\n >\n <ZoomInIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n <Tooltip title={zoom > ZOOM_MIN_VALUE ? 'Zoom out' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MIN_VALUE,\n })}\n onClick={handleZoomOut}\n >\n <ZoomOutIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n </div>\n </div>\n </div>\n );\n};\n\nexport default OffsetWellMap;\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","NO_HOVER_FILTER","toLngLat","_ref","_ref2","_slicedToArray","lat","makeCirclePolygon","_ref3","radiusMeters","_ref4","lng","points","degreesLng","Math","cos","PI","degreesLat","ring","i","theta","push","sin","coordinates","OffsetWellMap","_ref7","isViewOnly","_ref7$subjectWell","subjectWell","wells","offsetWellIds","radius","handleChanageOffsetWell","_ref7$handleChangeOff","handleChangeOffsetWell","activeWellId","_ref7$isClickable","isClickable","_ref7$classes","classes","subjectWellCoords","useMemo","get","formationColors","getAllFormations","containerRef","useRef","mapRef","popupRef","radiusBoundsRef","wellsBoundsRef","subjectIconRef","wellByFeatureIdRef","Map","subjectFeatureIdRef","hoveredFeatureIdRef","useState","_useState2","_useState","isSubjectWellHovered","setIsSubjectWellHovered","isActiveWellIsSubjectWell","id","prevWells","usePreviousWells","_useState4","_useState3","isMapReady","setIsMapReady","_useState6","_useState5","zoom","setZoom","useEffect","map","mapboxgl","container","current","style","center","maxZoom","attributionControl","scrollZoom","doubleClickZoom","on","round","getZoom","addSource","data","addLayer","source","paint","filter","layout","remove","_ref6","getSource","setData","properties","geometry","showTooltip","well","isOffsetWell","isSubjectWell","coords","popUpContainer","document","createElement","popUpContent","WellTooltip","color","formation","ReactDOM","render","_jsx","_Fragment","children","Popup","closeButton","offset","setLngLat","setDOMContent","addTo","setPaintProperty","_popupRef$current","offsetWells","unSelectedWells","forEach","includes","sortedWells","wellsBounds","LngLatBounds","clear","index","_well$topHole","topHole","opacity","isActive","order","set","extend","length","setFilter","handleMouseMove","e","_e$features","feature","entry","getCanvas","cursor","handleMouseLeave","_popupRef$current2","point","queryRenderedFeatures","layers","wasSubjectWell","handleClick","_e$features2","_e$features2$","setTimeout","fitBounds","padding","off","isHighlighted","icon","src","_ref9","iconWidth","iconHeight","_ref11","anchorX","anchorY","width","height","addEventListener","getLayer","_popupRef$current3","Marker","element","anchor","easeTo","duration","handleZoomIn","className","classNames","styles","mapView","root","mapMain","ref","onDoubleClick","_jsxs","zoomGroup","Tooltip","title","placement","zo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AAOa,aAhdD,KAgdgB/H,KAEzBgI,QAASjB,GAAalE,SAEtBF,EAACsF,EAAU,CAACjB,UAAWE,EAAOgB,oBAGlCvF,EAAC+E,EAAO,CAACC,MAAO3H,GAtdH,EAsd2B,WAAa,GAAI4H,UAAU,OAAM/E,SACvEF,EAAA,MAAA,CACEqE,UAAWC,EAAWC,EAAOW,WAAUC,EAAA,GACpCZ,EAAOa,aAzdD,IAydgB/H,KAEzBgI,QA7BU,WAChBhI,GAAO,GACTxB,EAAO8B,QAAQL,QAAQD,GAAO,IA2BC6C,SAEvBF,EAACwF,EAAW,CAACnB,UAAWE,EAAOgB,0BAO7C"}
1
+ {"version":3,"file":"OffsetWellMap.js","sources":["../../../src/components/OffsetWellMap/OffsetWellMap.js"],"sourcesContent":["import { createElement, useRef, useEffect, useState, useMemo } from 'react';\nimport ReactDOM from 'react-dom';\nimport { get } from 'lodash';\nimport classNames from 'classnames';\nimport { Tooltip } from '@material-ui/core';\nimport { Add as ZoomInIcon, Remove as ZoomOutIcon } from '@material-ui/icons';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nimport SubjectWellIcon from './CustomIcon/SubjectWellIcon.svg';\nimport SubjectHighlightWellIcon from './CustomIcon/SubjectHighlightWellIcon.svg';\nimport { usePreviousWells } from './effects';\nimport { WellTooltip } from './WellTooltip';\nimport { getAllFormations } from './utils';\n\nimport styles from './OffsetWellMap.module.css';\n\nimport mapboxgl from '~/config/mapboxGl';\nimport { IS_MAPBOX_ENABLED } from '~/config/mapbox';\nimport { mapbox } from '~/utils';\n\nconst { isValidCoordinates } = mapbox;\nconst DEFAULT_COORDS = [29.749907, -95.358421];\nconst WELL_MARKER_SIZE = 5;\nconst HIGHLIGHT_MARKER_SIZE = 12;\nconst OFFSET_WELL_COLOR = '#03BCD4';\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst HIGHLIGHT_WELL_COLOR = '#63EFFF';\nconst METERS_IN_MILE = 1609.34;\nconst ZOOM_INIT_VALUE = 3;\nconst ZOOM_MAX_VALUE = 18;\nconst ZOOM_MIN_VALUE = 1;\nconst MAX_RADIUS = 3000;\n\nconst RADIUS_SOURCE_ID = 'radius-circle';\nconst RADIUS_LAYER_ID = 'radius-circle-fill';\nconst WELLS_SOURCE_ID = 'wells';\nconst WELLS_HALO_LAYER_ID = 'wells-halo';\nconst WELLS_LAYER_ID = 'wells-circle';\nconst WELLS_ACTIVE_LAYER_ID = 'wells-active-highlight';\nconst WELLS_HOVER_LAYER_ID = 'wells-hover-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\nconst NO_HOVER_FILTER = ['==', ['id'], -1];\n\n// NOTE: Props keep the Leaflet [lat, lng] convention; mapbox-gl expects [lng, lat]\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl circle layers are pixel-radius, so approximate the meter radius with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n const ring = [];\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * 2 * Math.PI;\n ring.push([lng + degreesLng * Math.cos(theta), lat + degreesLat * Math.sin(theta)]);\n }\n return { type: 'Polygon', coordinates: [ring] };\n};\n\nconst getCircleBounds = ([lat, lng], radiusMeters) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n return [\n [lng - degreesLng, lat - degreesLat],\n [lng + degreesLng, lat + degreesLat],\n ];\n};\n\n/** @type {React.FC<import('./OffsetWellMapProps').OffsetWellMapProps>} */\nconst OffsetWellMap = ({\n isViewOnly,\n subjectWell = null,\n wells,\n offsetWellIds,\n radius,\n handleChanageOffsetWell,\n handleChangeOffsetWell = handleChanageOffsetWell,\n activeWellId,\n isClickable = true,\n classes = {},\n}) => {\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, 'topHole.coordinates');\n }, [subjectWell]);\n const formationColors = useMemo(() => getAllFormations(wells), [wells]);\n\n const containerRef = useRef();\n const mapRef = useRef();\n const popupRef = useRef();\n const radiusBoundsRef = useRef(null);\n const wellsBoundsRef = useRef(null);\n const subjectIconRef = useRef();\n const wellByFeatureIdRef = useRef(new Map());\n const subjectFeatureIdRef = useRef(null);\n const hoveredFeatureIdRef = useRef(null);\n const [isSubjectWellHovered, setIsSubjectWellHovered] = useState(false);\n const isActiveWellIsSubjectWell = subjectWell?.id === activeWellId;\n const prevWells = usePreviousWells(wells);\n const [isMapReady, setIsMapReady] = useState(false);\n const [zoom, setZoom] = useState(ZOOM_INIT_VALUE);\n\n // NOTE: Initialize map\n useEffect(() => {\n if (!IS_MAPBOX_ENABLED) return undefined;\n\n const map = new mapboxgl.Map({\n container: containerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: ZOOM_INIT_VALUE,\n // NOTE: keep the zoom buttons' disable logic (zoom === ZOOM_MAX_VALUE) reachable\n maxZoom: ZOOM_MAX_VALUE,\n attributionControl: false,\n scrollZoom: false,\n doubleClickZoom: false,\n });\n mapRef.current = map;\n\n // NOTE: GL zoom is fractional where Leaflet was integer\n map.on('zoomend', () => setZoom(Math.round(map.getZoom())));\n\n // NOTE: Sources/layers can only be added after the style loads\n map.on('load', () => {\n map.addSource(RADIUS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: RADIUS_LAYER_ID,\n type: 'fill',\n source: RADIUS_SOURCE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n map.addSource(WELLS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: WELLS_HALO_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isOffsetWell'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.08,\n },\n });\n map.addLayer({\n id: WELLS_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n layout: {\n 'circle-sort-key': ['get', 'order'],\n },\n paint: {\n 'circle-radius': WELL_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n map.addLayer({\n id: WELLS_ACTIVE_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isActive'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.24,\n },\n });\n map.addLayer({\n id: WELLS_HOVER_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: NO_HOVER_FILTER,\n paint: {\n 'circle-radius': [\n 'case',\n ['get', 'isSubjectWell'],\n WELL_MARKER_SIZE,\n HIGHLIGHT_MARKER_SIZE,\n ],\n 'circle-color': [\n 'case',\n ['get', 'isSubjectWell'],\n HIGHLIGHT_WELL_COLOR,\n ['get', 'color'],\n ],\n 'circle-opacity': 0.24,\n },\n });\n\n setIsMapReady(true);\n });\n\n return () => {\n map.remove();\n mapRef.current = null;\n popupRef.current = null;\n subjectIconRef.current = null;\n radiusBoundsRef.current = null;\n wellsBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n radiusBoundsRef.current =\n subjectWellCoords && radius\n ? getCircleBounds(subjectWellCoords, radius * METERS_IN_MILE)\n : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.getSource(RADIUS_SOURCE_ID).setData(\n subjectWellCoords && radius\n ? {\n type: 'Feature',\n properties: {},\n geometry: makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE),\n }\n : EMPTY_FEATURE_COLLECTION\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n const showTooltip = (well, isOffsetWell, isSubjectWell, coords) => {\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(WellTooltip(), {\n isViewOnly,\n well,\n color: get(formationColors, well.formation, '#BDBDBD'),\n isOffsetWell,\n isSubjectWell,\n isClickable,\n });\n ReactDOM.render(<>{popUpContent}</>, popUpContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({\n closeButton: false,\n offset: HIGHLIGHT_MARKER_SIZE,\n });\n }\n popupRef.current\n .setLngLat(toLngLat(coords))\n .setDOMContent(popUpContainer)\n .addTo(mapRef.current);\n };\n\n // NOTE: Subject well hover swaps the subject marker color\n useEffect(() => {\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.setPaintProperty(\n WELLS_LAYER_ID,\n 'circle-color',\n isSubjectWellHovered\n ? ['case', ['get', 'isSubjectWell'], HIGHLIGHT_WELL_COLOR, ['get', 'color']]\n : ['get', 'color']\n );\n }, [isSubjectWellHovered, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!wells || !offsetWellIds) {\n return undefined;\n }\n\n popupRef.current?.remove();\n\n const offsetWells = [];\n const unSelectedWells = [];\n wells.forEach(well => {\n if (well.id !== subjectWell?.id) {\n if (offsetWellIds.includes(well.id)) {\n offsetWells.push(well);\n } else {\n unSelectedWells.push(well);\n }\n }\n });\n const sortedWells = [...unSelectedWells, ...offsetWells, subjectWell];\n\n const features = [];\n const wellsBounds = new mapboxgl.LngLatBounds();\n wellByFeatureIdRef.current.clear();\n subjectFeatureIdRef.current = null;\n sortedWells.forEach((well, index) => {\n const coords = well?.topHole?.coordinates;\n\n if (coords && isValidCoordinates(coords)) {\n const isSubjectWell = subjectWell?.id === well.id;\n const isOffsetWell = offsetWellIds.includes(well.id) && !isSubjectWell;\n const color = isSubjectWell\n ? OFFSET_WELL_COLOR\n : get(formationColors, well.formation, '#BDBDBD');\n const opacity = isOffsetWell ? 0.7 : 0.3;\n\n features.push({\n type: 'Feature',\n id: index,\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: {\n color,\n opacity: isSubjectWell ? 1 : opacity,\n isSubjectWell,\n isOffsetWell,\n isActive: well.id === activeWellId && !isActiveWellIsSubjectWell,\n order: index,\n },\n });\n wellByFeatureIdRef.current.set(index, { well, coords, isOffsetWell, isSubjectWell });\n if (isSubjectWell) {\n subjectFeatureIdRef.current = index;\n }\n wellsBounds.extend(toLngLat(coords));\n }\n });\n wellsBoundsRef.current = features.length ? wellsBounds : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return undefined;\n }\n\n map.getSource(WELLS_SOURCE_ID).setData({ type: 'FeatureCollection', features });\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n hoveredFeatureIdRef.current = null;\n\n const handleMouseMove = e => {\n const feature = e.features?.[0];\n if (!feature || hoveredFeatureIdRef.current === feature.id) {\n return;\n }\n const entry = wellByFeatureIdRef.current.get(feature.id);\n if (!entry) {\n return;\n }\n\n hoveredFeatureIdRef.current = feature.id;\n map.getCanvas().style.cursor = 'pointer';\n\n // Highlight\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], feature.id]);\n showTooltip(entry.well, entry.isOffsetWell, entry.isSubjectWell, entry.coords);\n if (entry.isSubjectWell) {\n setIsSubjectWellHovered(true);\n }\n };\n\n const handleMouseLeave = e => {\n // NOTE: Leaflet cleared hover on leaving the ENLARGED highlight marker, so keep the\n // hover while the cursor is still over the hover halo (or another well marker)\n if (\n e?.point &&\n map.queryRenderedFeatures(e.point, { layers: [WELLS_LAYER_ID, WELLS_HOVER_LAYER_ID] })\n .length\n ) {\n return;\n }\n const wasSubjectWell =\n hoveredFeatureIdRef.current !== null &&\n hoveredFeatureIdRef.current === subjectFeatureIdRef.current;\n hoveredFeatureIdRef.current = null;\n map.getCanvas().style.cursor = '';\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n popupRef.current?.remove();\n if (wasSubjectWell) {\n setIsSubjectWellHovered(false);\n }\n };\n\n const handleClick = e => {\n if (isViewOnly) return;\n const entry = wellByFeatureIdRef.current.get(e.features?.[0]?.id);\n if (!entry) {\n return;\n }\n handleChangeOffsetWell(entry.well, !entry.isOffsetWell);\n };\n\n map.on('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.on('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.on('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.on('click', WELLS_LAYER_ID, handleClick);\n\n setTimeout(() => {\n if (radius < MAX_RADIUS && mapRef.current && radiusBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.off('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.off('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.off('click', WELLS_LAYER_ID, handleClick);\n };\n }, [subjectWell, wells, offsetWellIds, activeWellId, isMapReady]);\n\n // NOTE: Subject Well Icon\n\n useEffect(() => {\n const map = mapRef.current;\n\n if (subjectIconRef.current) {\n subjectIconRef.current.remove();\n subjectIconRef.current = null;\n }\n\n if (!map || !subjectWellCoords) return;\n\n const isHighlighted = isSubjectWellHovered || isActiveWellIsSubjectWell;\n const icon = document.createElement('img');\n icon.src = isHighlighted ? SubjectHighlightWellIcon : SubjectWellIcon;\n const [iconWidth, iconHeight] = isHighlighted ? [70, 20] : [62, 12];\n const [anchorX, anchorY] = isHighlighted ? [35, 29] : [31, 25];\n icon.width = iconWidth;\n icon.height = iconHeight;\n\n icon.addEventListener('mouseover', () => {\n setIsSubjectWellHovered(true);\n\n // Highlight\n if (subjectFeatureIdRef.current !== null && map.getLayer(WELLS_HOVER_LAYER_ID)) {\n hoveredFeatureIdRef.current = subjectFeatureIdRef.current;\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], subjectFeatureIdRef.current]);\n }\n showTooltip(subjectWell, false, true, subjectWellCoords);\n });\n\n icon.addEventListener('mouseout', () => {\n hoveredFeatureIdRef.current = null;\n if (map.getLayer(WELLS_HOVER_LAYER_ID)) {\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n }\n popupRef.current?.remove();\n setIsSubjectWellHovered(false);\n });\n\n subjectIconRef.current = new mapboxgl.Marker({\n element: icon,\n anchor: 'center',\n // NOTE: Leaflet anchored the icon at [anchorX, anchorY] from its top-left corner\n offset: [iconWidth / 2 - anchorX, iconHeight / 2 - anchorY],\n })\n .setLngLat(toLngLat(subjectWellCoords))\n .addTo(map);\n }, [isSubjectWellHovered, subjectWellCoords, radius, subjectWell, isActiveWellIsSubjectWell]);\n\n // NOTE: Map Update\n useEffect(() => {\n if (radius > MAX_RADIUS) {\n mapRef.current?.setZoom(1);\n return;\n }\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusBoundsRef.current && radius) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n } else if (mapRef.current && wellsBoundsRef.current) {\n mapRef.current.fitBounds(wellsBoundsRef.current);\n }\n if (subjectWellCoords && mapRef.current) {\n mapRef.current.easeTo({ center: toLngLat(subjectWellCoords), duration: 700 });\n }\n }, 500);\n }, [radius, subjectWell, subjectWellCoords]);\n\n const handleZoomIn = () => {\n mapRef.current?.setZoom(zoom + 1);\n };\n\n const handleZoomOut = () => {\n if (zoom > 1) {\n mapRef.current?.setZoom(zoom - 1);\n }\n };\n\n return (\n <div className={classNames(styles.mapView, classes.root)}>\n <div\n className={classNames(styles.mapMain, classes.map)}\n ref={containerRef}\n onDoubleClick={handleZoomIn}\n >\n <div className={styles.zoomGroup}>\n <Tooltip title={zoom < ZOOM_MAX_VALUE ? 'Zoom in' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MAX_VALUE,\n })}\n onClick={handleZoomIn}\n >\n <ZoomInIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n <Tooltip title={zoom > ZOOM_MIN_VALUE ? 'Zoom out' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MIN_VALUE,\n })}\n onClick={handleZoomOut}\n >\n <ZoomOutIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n </div>\n </div>\n </div>\n );\n};\n\nexport default OffsetWellMap;\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","NO_HOVER_FILTER","toLngLat","_ref","_ref2","_slicedToArray","lat","makeCirclePolygon","_ref3","radiusMeters","_ref4","lng","points","degreesLng","Math","cos","PI","degreesLat","ring","i","theta","push","sin","coordinates","OffsetWellMap","_ref7","isViewOnly","_ref7$subjectWell","subjectWell","wells","offsetWellIds","radius","handleChanageOffsetWell","_ref7$handleChangeOff","handleChangeOffsetWell","activeWellId","_ref7$isClickable","isClickable","_ref7$classes","classes","subjectWellCoords","useMemo","get","formationColors","getAllFormations","containerRef","useRef","mapRef","popupRef","radiusBoundsRef","wellsBoundsRef","subjectIconRef","wellByFeatureIdRef","Map","subjectFeatureIdRef","hoveredFeatureIdRef","useState","_useState2","_useState","isSubjectWellHovered","setIsSubjectWellHovered","isActiveWellIsSubjectWell","id","prevWells","usePreviousWells","_useState4","_useState3","isMapReady","setIsMapReady","_useState6","_useState5","zoom","setZoom","useEffect","IS_MAPBOX_ENABLED","map","mapboxgl","container","current","style","center","maxZoom","attributionControl","scrollZoom","doubleClickZoom","on","round","getZoom","addSource","data","addLayer","source","paint","filter","layout","remove","_ref6","getSource","setData","properties","geometry","showTooltip","well","isOffsetWell","isSubjectWell","coords","popUpContainer","document","createElement","popUpContent","WellTooltip","color","formation","ReactDOM","render","_jsx","_Fragment","children","Popup","closeButton","offset","setLngLat","setDOMContent","addTo","setPaintProperty","_popupRef$current","offsetWells","unSelectedWells","forEach","includes","sortedWells","wellsBounds","LngLatBounds","clear","index","_well$topHole","topHole","opacity","isActive","order","set","extend","length","setFilter","handleMouseMove","e","_e$features","feature","entry","getCanvas","cursor","handleMouseLeave","_popupRef$current2","point","queryRenderedFeatures","layers","wasSubjectWell","handleClick","_e$features2","_e$features2$","setTimeout","fitBounds","padding","off","isHighlighted","icon","src","_ref9","iconWidth","iconHeight","_ref11","anchorX","anchorY","width","height","addEventListener","getLayer","_popupRef$current3","Marker","element","anchor","_mapRef$current","easeTo","duration","handleZoomIn","_mapRef$current2","className","classNames","styles","mapView","root","mapMain","ref","onDoubleClick","_jsxs","zoomGroup","Tooltip","title","placement","zoomButton","_defineProperty","zoomDisabled","onClick","ZoomInIcon","zoomInOutIcon","_mapRef$current3","ZoomOutIcon"],"mappings":"q1BAMsC,IAc9BA,EAAuBC,EAAvBD,mBACFE,EAAiB,CAAC,WAAY,WAmB9BC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAClEC,EAAkB,CAAC,KAAM,CAAC,OAAQ,GAGlCC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EAGrCC,EAAoB,SAAHC,EAAgBC,GAIrC,IAJmE,IAAAC,EAAAL,EAAAG,EAAA,GAAzCF,EAAGI,EAAA,GAAEC,EAAGD,EAAA,GAAiBE,yDAAS,GACtDC,EAAaJ,GAAgB,OAASK,KAAKC,IAAKT,EAAMQ,KAAKE,GAAM,MACjEC,EAAaR,EAAe,OAC5BS,EAAO,GACJC,EAAI,EAAGA,GAAKP,EAAQO,GAAK,EAAG,CACnC,IAAMC,EAASD,EAAIP,EAAU,EAAIE,KAAKE,GACtCE,EAAKG,KAAK,CAACV,EAAME,EAAaC,KAAKC,IAAIK,GAAQd,EAAMW,EAAaH,KAAKQ,IAAIF,IAC7E,CACA,MAAO,CAAErB,KAAM,UAAWwB,YAAa,CAACL,GAC1C,EAYMM,EAAgB,SAWhBC,GAAA,IA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,GAAE,CAACxJ,EAAQH,EAAaY,IAEzB,IAAMgJ,GAAe,WAAM,IAAAC,EACzB,QAAA1I,EAAAA,EAAO+B,eAAP,IAAA2G,GAAAA,EAAgBjH,QAAQD,GAAO,IASjC,OACE4C,EAAA,MAAA,CAAKuE,UAAWC,EAAWC,EAAOC,QAAStJ,EAAQuJ,MAAMzE,SACvDF,EAAA,MAAA,CACEuE,UAAWC,EAAWC,EAAOG,QAASxJ,EAAQoC,KAC9CqH,IAAKnJ,EACLoJ,cAAeT,GAAanE,SAE5B6E,EAAA,MAAA,CAAKR,UAAWE,EAAOO,UAAU9E,SAAA,CAC/BF,EAACiF,EAAO,CAACC,MAAO9H,GA/cH,GA+c2B,UAAY,GAAI+H,UAAU,OAAMjF,SACtEF,EAAA,MAAA,CACEuE,UAAWC,EAAWC,EAAOW,WAAUC,EAAA,GACpCZ,EAAOa,aAldD,KAkdgBlI,KAEzBmI,QAASlB,GAAanE,SAEtBF,EAACwF,EAAU,CAACjB,UAAWE,EAAOgB,oBAGlCzF,EAACiF,EAAO,CAACC,MAAO9H,GAxdH,EAwd2B,WAAa,GAAI+H,UAAU,OAAMjF,SACvEF,EAAA,MAAA,CACEuE,UAAWC,EAAWC,EAAOW,WAAUC,EAAA,GACpCZ,EAAOa,aA3dD,IA2dgBlI,KAEzBmI,QA7BU,WACN,IAAAG,EAAVtI,GAAO,IACT,QAAAxB,EAAAA,EAAO+B,eAAP,IAAA+H,GAAAA,EAAgBrI,QAAQD,GAAO,KA2BA8C,SAEvBF,EAAC2F,EAAW,CAACpB,UAAWE,EAAOgB,0BAO7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"Map.d.ts","sourceRoot":"","sources":["../../../../../src/components/OffsetWellPickerV2/components/Map/Map.js"],"names":[],"mappings":";;AAuDA;;;;;;;;;gBAqRC;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA1UqB,YAAY;AAelC,gDAAyC,EAAE,CAAC;AAC5C,wCAAiC,CAAC,CAAC"}
1
+ {"version":3,"file":"Map.d.ts","sourceRoot":"","sources":["../../../../../src/components/OffsetWellPickerV2/components/Map/Map.js"],"names":[],"mappings":";;AAwDA;;;;;;;;;gBAuRC;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA7UqB,YAAY;AAgBlC,gDAAyC,EAAE,CAAC;AAC5C,wCAAiC,CAAC,CAAC"}
@@ -1,2 +1,2 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{memo as t,useRef as o,useState as n,useMemo as i,useEffect as a,createElement as l}from"react";import s from"react-dom";import u from"prop-types";import{get as c,sortBy as m}from"lodash";import{MuiThemeProvider as p}from"@material-ui/core/styles";import d from"./Map.css.js";import{mapbox as f}from"../../../../utils/index.js";import{darkTheme as h}from"../../../../config/theme/index.js";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/typeof";import"@babel/runtime/regenerator";import"highcharts";import"highcharts/highcharts-more";import"highcharts/modules/solid-gauge";import"highcharts/modules/heatmap";import"highcharts/modules/boost";import"highcharts/modules/exporting";import"highcharts/modules/xrange";import"highcharts/modules/dumbbell";import"highcharts/modules/pattern-fill";import"highcharts/modules/annotations";import"highcharts-multicolor-series";import"dompurify";import"@babel/runtime/helpers/createClass";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/assertThisInitialized";import"@babel/runtime/helpers/inherits";import"@babel/runtime/helpers/possibleConstructorReturn";import"@babel/runtime/helpers/getPrototypeOf";import"@babel/runtime/helpers/toArray";import"@babel/runtime/helpers/toConsumableArray";import"../../../../clients/subscriptions/constants.js";import"../../../../clients/subscriptions.v1.js";import"../../../../clients/subscriptions/subscriptions-client.factory.js";import"../../../../config/extendNative.js";import"../../../../config/mapboxGl/index.js";import"mapbox-gl/dist/mapbox-gl.css";import{jsxs as b,jsx as g}from"react/jsx-runtime";import y from"mapbox-gl";function v(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function F(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?v(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}var j=f.isValidCoordinates,w=["#FF00FF","#F5BD80","#FF0000","#0080FF","#FF8000","#58ACFA","#FA58F4","#40FF00","#4B8A08","#40FF00","#D8F781"],O=[29.749907,-95.358421],C={type:"FeatureCollection",features:[]},P=function(e){var t=r(e,2),o=t[0];return[t[1],o]};function x(t){var u=t.subjectWell,f=t.wells,v=t.offsetWells,x=t.radius,S=t.subjectWellMarkerSize,M=t.wellMarkerSize,D=t.popUpFormatter,N=t.coordsDataPath,k=o(null),I=o(null),W=o(null),L=o(null),B=o(null),z=o(),A=n(!1),T=r(A,2),E=T[0],q=T[1],R=i((function(){return f.filter((function(e){return!u||u.id!==e.id}))}),[u,f]),U=i((function(){return u&&c(u,N)}),[u,N]),G=i((function(){var r=[],t=!1;R.forEach((function(e){"Null"===e.formation?t=!0:u&&u.formation===e.formation||r.includes(e.formation)||r.push(e.formation)}));var o=u?[u.formation].concat(m(r)):m(r);t&&!o.includes("Null")&&o.push("Null");var n=o.reduce((function(r,t,o){return F(F({},r),{},e({},t,w[o%w.length]))}),{});return[o,n]}),[u,R]),V=r(G,2),Z=V[0],_=V[1];return a((function(){I.current=new y.Map({container:k.current,style:"mapbox://styles/mapbox/dark-v9",center:P(O),zoom:1,attributionControl:!1,scrollZoom:!1}),I.current.addControl(new y.NavigationControl({showCompass:!1}),"bottom-right"),I.current.on("load",(function(){I.current.addSource("radius-circle",{type:"geojson",data:C}),I.current.addLayer({id:"radius-circle",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),I.current.addSource("wells",{type:"geojson",data:C}),I.current.addLayer({id:"wells",type:"circle",source:"wells",paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),q(!0)}));var e=I.current;return function(){e.remove(),I.current=null,W.current=null,L.current=null}}),[]),a((function(){if(I.current&&E){if(!U)return I.current.getSource("radius-circle").setData(C),void(W.current=null);var e=function(e,t){for(var o=r(e,2),n=o[0],i=o[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,l=[],s=t/(111320*Math.cos(n*Math.PI/180)),u=t/110574,c=0;c<=a;c+=1){var m=c/a*(2*Math.PI);l.push([i+s*Math.cos(m),n+u*Math.sin(m)])}return l}(U,1609.34*x);I.current.getSource("radius-circle").setData({type:"Feature",geometry:{type:"Polygon",coordinates:[e]}}),W.current=e.reduce((function(e,r){return e.extend(r)}),new y.LngLatBounds)}}),[x,U,E]),a((function(){var e;if(I.current&&E){var r=z.current;z.current=f,null===(e=B.current)||void 0===e||e.remove();var t=v.map((function(e){return e.id})),o=[],n={},i=new y.LngLatBounds;f.forEach((function(e){var r=c(e,N);if(r&&j(r)){var a=u&&u.id===e.id,l=t.includes(e.id),s=a?S:M,m=a||l?"#00FFFF":_[e.formation],p=a||l?1:.3;n[e.id]=e,i.extend(P(r)),o.push({type:"Feature",geometry:{type:"Point",coordinates:P(r)},properties:{wellId:e.id,radius:s,color:m,opacity:p}})}})),I.current.getSource("wells").setData({type:"FeatureCollection",features:o}),L.current=o.length?i:null;var a=I.current,m=null,d=function(e){a.getCanvas().style.cursor="pointer";var r=n[e.features[0].properties.wellId];if(r&&r.id!==m&&(m=r.id,D)){var t=document.createElement("div"),o=l(D,{well:r,color:_[r.formation]});s.render(g(p,{theme:h,children:o}),t),B.current||(B.current=new y.Popup({closeButton:!1,maxWidth:"none"})),B.current.setLngLat(P(c(r,N))).setDOMContent(t).addTo(a)}},b=function(){m=null,a.getCanvas().style.cursor=""};return a.on("mousemove","wells",d),a.on("mouseleave","wells",b),setTimeout((function(){I.current&&W.current&&f!==r&&I.current.fitBounds(W.current,{padding:5})}),500),function(){a.off("mousemove","wells",d),a.off("mouseleave","wells",b)}}}),[u,f,v,_,E]),a((function(){setTimeout((function(){u?I.current&&W.current&&I.current.fitBounds(W.current,{padding:5}):I.current&&L.current&&I.current.fitBounds(L.current)}),500)}),[x,u,E]),b("div",{className:d.map,children:[g("div",{className:d.mapMain,ref:k}),b("div",{className:d.mapFooter,children:[v&&b("div",{className:d.mapFooterItem,children:[g("div",{className:d.mapFooterItemSquare,style:{backgroundColor:"#00FFFF"}}),g("div",{className:d.mapFooterItemLabel,children:"Selected Offset Wells"})]}),Z.map((function(e){return b("div",{className:d.mapFooterItem,children:[g("div",{className:d.mapFooterItemSquare,style:{backgroundColor:_[e]}}),g("div",{className:d.mapFooterItemLabel,children:e})]},e)}))]})]})}x.propTypes={subjectWell:u.shape({id:u.number,formation:u.string}),wells:u.arrayOf(u.shape({})).isRequired,offsetWells:u.arrayOf(u.shape({})),radius:u.number.isRequired,subjectWellMarkerSize:u.number,wellMarkerSize:u.number,popUpFormatter:u.func,coordsDataPath:u.string},x.defaultProps={subjectWell:null,subjectWellMarkerSize:10,wellMarkerSize:5,popUpFormatter:null,coordsDataPath:"settings.top_hole.coordinates",offsetWells:null};var S=t(x);export{S as default};
1
+ import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{memo as t,useRef as o,useState as n,useMemo as i,useEffect as a,createElement as l}from"react";import s from"react-dom";import c from"prop-types";import{get as u,sortBy as m}from"lodash";import{MuiThemeProvider as p}from"@material-ui/core/styles";import d from"./Map.css.js";import{mapbox as f}from"../../../../utils/index.js";import{darkTheme as h}from"../../../../config/theme/index.js";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/typeof";import"@babel/runtime/regenerator";import"highcharts";import"highcharts/highcharts-more";import"highcharts/modules/solid-gauge";import"highcharts/modules/heatmap";import"highcharts/modules/boost";import"highcharts/modules/exporting";import"highcharts/modules/xrange";import"highcharts/modules/dumbbell";import"highcharts/modules/pattern-fill";import"highcharts/modules/annotations";import"highcharts-multicolor-series";import"dompurify";import{IS_MAPBOX_ENABLED as b}from"../../../../config/mapbox/index.js";import"@babel/runtime/helpers/createClass";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/assertThisInitialized";import"@babel/runtime/helpers/inherits";import"@babel/runtime/helpers/possibleConstructorReturn";import"@babel/runtime/helpers/getPrototypeOf";import"@babel/runtime/helpers/toArray";import"@babel/runtime/helpers/toConsumableArray";import"../../../../clients/subscriptions/constants.js";import"../../../../clients/subscriptions.v1.js";import"../../../../clients/subscriptions/subscriptions-client.factory.js";import"../../../../config/extendNative.js";import"../../../../config/mapboxGl/index.js";import"mapbox-gl/dist/mapbox-gl.css";import{jsxs as g,jsx as y}from"react/jsx-runtime";import v from"mapbox-gl";function F(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function j(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?F(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):F(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}var w=f.isValidCoordinates,O=["#FF00FF","#F5BD80","#FF0000","#0080FF","#FF8000","#58ACFA","#FA58F4","#40FF00","#4B8A08","#40FF00","#D8F781"],x=[29.749907,-95.358421],C={type:"FeatureCollection",features:[]},P=function(e){var t=r(e,2),o=t[0];return[t[1],o]};function S(t){var c=t.subjectWell,f=t.wells,F=t.offsetWells,S=t.radius,M=t.subjectWellMarkerSize,D=t.wellMarkerSize,N=t.popUpFormatter,k=t.coordsDataPath,I=o(null),W=o(null),L=o(null),B=o(null),z=o(null),A=o(),T=n(!1),E=r(T,2),q=E[0],R=E[1],U=i((function(){return f.filter((function(e){return!c||c.id!==e.id}))}),[c,f]),G=i((function(){return c&&u(c,k)}),[c,k]),V=i((function(){var r=[],t=!1;U.forEach((function(e){"Null"===e.formation?t=!0:c&&c.formation===e.formation||r.includes(e.formation)||r.push(e.formation)}));var o=c?[c.formation].concat(m(r)):m(r);t&&!o.includes("Null")&&o.push("Null");var n=o.reduce((function(r,t,o){return j(j({},r),{},e({},t,O[o%O.length]))}),{});return[o,n]}),[c,U]),Z=r(V,2),_=Z[0],H=Z[1];return a((function(){if(b){W.current=new v.Map({container:I.current,style:"mapbox://styles/mapbox/dark-v9",center:P(x),zoom:1,attributionControl:!1,scrollZoom:!1}),W.current.addControl(new v.NavigationControl({showCompass:!1}),"bottom-right"),W.current.on("load",(function(){W.current.addSource("radius-circle",{type:"geojson",data:C}),W.current.addLayer({id:"radius-circle",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),W.current.addSource("wells",{type:"geojson",data:C}),W.current.addLayer({id:"wells",type:"circle",source:"wells",paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),R(!0)}));var e=W.current;return function(){e.remove(),W.current=null,L.current=null,B.current=null}}}),[]),a((function(){if(W.current&&q){if(!G)return W.current.getSource("radius-circle").setData(C),void(L.current=null);var e=function(e,t){for(var o=r(e,2),n=o[0],i=o[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,l=[],s=t/(111320*Math.cos(n*Math.PI/180)),c=t/110574,u=0;u<=a;u+=1){var m=u/a*(2*Math.PI);l.push([i+s*Math.cos(m),n+c*Math.sin(m)])}return l}(G,1609.34*S);W.current.getSource("radius-circle").setData({type:"Feature",geometry:{type:"Polygon",coordinates:[e]}}),L.current=e.reduce((function(e,r){return e.extend(r)}),new v.LngLatBounds)}}),[S,G,q]),a((function(){var e;if(W.current&&q){var r=A.current;A.current=f,null===(e=z.current)||void 0===e||e.remove();var t=F.map((function(e){return e.id})),o=[],n={},i=new v.LngLatBounds;f.forEach((function(e){var r=u(e,k);if(r&&w(r)){var a=c&&c.id===e.id,l=t.includes(e.id),s=a?M:D,m=a||l?"#00FFFF":H[e.formation],p=a||l?1:.3;n[e.id]=e,i.extend(P(r)),o.push({type:"Feature",geometry:{type:"Point",coordinates:P(r)},properties:{wellId:e.id,radius:s,color:m,opacity:p}})}})),W.current.getSource("wells").setData({type:"FeatureCollection",features:o}),B.current=o.length?i:null;var a=W.current,m=null,d=function(e){a.getCanvas().style.cursor="pointer";var r=n[e.features[0].properties.wellId];if(r&&r.id!==m&&(m=r.id,N)){var t=document.createElement("div"),o=l(N,{well:r,color:H[r.formation]});s.render(y(p,{theme:h,children:o}),t),z.current||(z.current=new v.Popup({closeButton:!1,maxWidth:"none"})),z.current.setLngLat(P(u(r,k))).setDOMContent(t).addTo(a)}},b=function(){m=null,a.getCanvas().style.cursor=""};return a.on("mousemove","wells",d),a.on("mouseleave","wells",b),setTimeout((function(){W.current&&L.current&&f!==r&&W.current.fitBounds(L.current,{padding:5})}),500),function(){a.off("mousemove","wells",d),a.off("mouseleave","wells",b)}}}),[c,f,F,H,q]),a((function(){setTimeout((function(){c?W.current&&L.current&&W.current.fitBounds(L.current,{padding:5}):W.current&&B.current&&W.current.fitBounds(B.current)}),500)}),[S,c,q]),g("div",{className:d.map,children:[y("div",{className:d.mapMain,ref:I}),g("div",{className:d.mapFooter,children:[F&&g("div",{className:d.mapFooterItem,children:[y("div",{className:d.mapFooterItemSquare,style:{backgroundColor:"#00FFFF"}}),y("div",{className:d.mapFooterItemLabel,children:"Selected Offset Wells"})]}),_.map((function(e){return g("div",{className:d.mapFooterItem,children:[y("div",{className:d.mapFooterItemSquare,style:{backgroundColor:H[e]}}),y("div",{className:d.mapFooterItemLabel,children:e})]},e)}))]})]})}S.propTypes={subjectWell:c.shape({id:c.number,formation:c.string}),wells:c.arrayOf(c.shape({})).isRequired,offsetWells:c.arrayOf(c.shape({})),radius:c.number.isRequired,subjectWellMarkerSize:c.number,wellMarkerSize:c.number,popUpFormatter:c.func,coordsDataPath:c.string},S.defaultProps={subjectWell:null,subjectWellMarkerSize:10,wellMarkerSize:5,popUpFormatter:null,coordsDataPath:"settings.top_hole.coordinates",offsetWells:null};var M=t(S);export{M as default};
2
2
  //# sourceMappingURL=Map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Map.js","sources":["../../../../../src/components/OffsetWellPickerV2/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get, sortBy } from 'lodash';\nimport { MuiThemeProvider } from '@material-ui/core/styles';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport { theme } from '~/config';\nimport mapboxgl from '~/config/mapboxGl';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 10;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#00FFFF';\nconst COLORS = [\n '#FF00FF',\n '#F5BD80',\n '#FF0000',\n '#0080FF',\n '#FF8000',\n '#58ACFA',\n '#FA58F4',\n '#40FF00',\n '#4B8A08',\n '#40FF00',\n '#D8F781',\n];\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n popUpFormatter,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const radiusCircleBoundsRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const restWells = useMemo(() => {\n return wells.filter(well => !subjectWell || subjectWell.id !== well.id);\n }, [subjectWell, wells]);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Get well marker colors according to its target formation\n const [formations, colorDict] = useMemo(() => {\n // NOTE: Determine well marker colors\n const restFormations = [];\n let hasNullFormation = false;\n\n restWells.forEach(well => {\n if (well.formation === 'Null') {\n hasNullFormation = true;\n } else if (\n (!subjectWell || subjectWell.formation !== well.formation) &&\n !restFormations.includes(well.formation)\n ) {\n restFormations.push(well.formation);\n }\n });\n\n const sortedFormations = subjectWell\n ? [subjectWell.formation].concat(sortBy(restFormations))\n : sortBy(restFormations);\n\n if (hasNullFormation && !sortedFormations.includes('Null')) {\n sortedFormations.push('Null');\n }\n\n const colors = sortedFormations.reduce(\n (result, item, idx) => ({\n ...result,\n [item]: COLORS[idx % COLORS.length],\n }),\n {}\n );\n\n return [sortedFormations, colors];\n }, [subjectWell, restWells]);\n\n // NOTE: Initialize map\n useEffect(() => {\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack)\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n radiusCircleBoundsRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n radiusCircleBoundsRef.current = null;\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n radiusCircleBoundsRef.current = ring.reduce(\n (bounds, coord) => bounds.extend(coord),\n new mapboxgl.LngLatBounds()\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const color = isWellSubject || isWellOffset ? OFFSET_WELL_COLOR : colorDict[well.formation];\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, color, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n if (popUpFormatter) {\n // Container to put React generated content in.\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(popUpFormatter, {\n well,\n color: colorDict[well.formation],\n });\n // NOTE: Custom popup may have buttons\n ReactDOM.render(\n <MuiThemeProvider theme={theme.darkTheme}>{popUpContent}</MuiThemeProvider>,\n popUpContainer\n );\n\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current\n .setLngLat(toLngLat(get(well, coordsDataPath)))\n .setDOMContent(popUpContainer)\n .addTo(map);\n }\n };\n\n const handleMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && radiusCircleBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, colorDict, isMapReady]);\n\n useEffect(() => {\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusCircleBoundsRef.current) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, {\n padding: 5,\n });\n }\n } else if (mapRef.current && markersBoundsRef.current) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n }, [radius, subjectWell, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n\n <div className={styles.mapFooter}>\n {offsetWells && (\n <div className={styles.mapFooterItem}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: OFFSET_WELL_COLOR }}\n />\n <div className={styles.mapFooterItemLabel}>Selected Offset Wells</div>\n </div>\n )}\n\n {formations.map(item => (\n <div className={styles.mapFooterItem} key={item}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: colorDict[item] }}\n />\n <div className={styles.mapFooterItemLabel}>{item}</div>\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n popUpFormatter: PropTypes.func,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n popUpFormatter: null,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","COLORS","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref5","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","popUpFormatter","coordsDataPath","mapContainerRef","useRef","mapRef","radiusCircleBoundsRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","restWells","useMemo","filter","well","id","subjectWellCoords","get","restFormations","hasNullFormation","forEach","formation","includes","push","sortedFormations","concat","sortBy","colors","reduce","result","item","idx","length","_useMemo2","_useMemo","formations","colorDict","useEffect","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","source","paint","map","remove","getSource","setData","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","sin","makeCirclePolygon","geometry","coordinates","bounds","coord","extend","LngLatBounds","_popupRef$current","prevWells","offsetWellIds","wellsById","coords","isWellSubject","isWellOffset","r","color","opacity","properties","wellId","hoveredWellId","handleMouseMove","e","getCanvas","cursor","popUpContainer","document","createElement","popUpContent","ReactDOM","render","_jsx","MuiThemeProvider","theme","children","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseLeave","setTimeout","fitBounds","padding","off","_jsxs","className","styles","mapMain","ref","mapFooter","mapFooterItem","mapFooterItemSquare","backgroundColor","mapFooterItemLabel","propTypes","PropTypes","shape","number","string","arrayOf","isRequired","func","defaultProps","memo"],"mappings":"6yEAaA,IAAQA,EAAuBC,EAAvBD,mBAOFE,EAAS,CACb,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,WAGIC,EAAiB,CAAC,WAAY,WAI9BC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAElE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3BpH,GAAImH,EAAUE,OACd/G,UAAW6G,EAAUG,SAEvB7I,MAAO0I,EAAUI,QAAQJ,EAAUC,MAAM,CAAA,IAAKI,WAC9C9I,YAAayI,EAAUI,QAAQJ,EAAUC,MAAM,CAAE,IACjDzI,OAAQwI,EAAUE,OAAOG,WACzB5I,sBAAuBuI,EAAUE,OACjCxI,eAAgBsI,EAAUE,OAC1BvI,eAAgBqI,EAAUM,KAC1B1I,eAAgBoI,EAAUG,QAG5BhJ,EAASoJ,aAAe,CACtBlJ,YAAa,KACbI,sBA7UuC,GA8UvCC,eA7U+B,EA8U/BC,eAAgB,KAChBC,eAAgB,gCAChBL,YAAa,MAGf,IAAeiJ,EAAAA,EAAKrJ"}
1
+ {"version":3,"file":"Map.js","sources":["../../../../../src/components/OffsetWellPickerV2/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get, sortBy } from 'lodash';\nimport { MuiThemeProvider } from '@material-ui/core/styles';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport { theme } from '~/config';\nimport mapboxgl from '~/config/mapboxGl';\nimport { IS_MAPBOX_ENABLED } from '~/config/mapbox';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 10;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#00FFFF';\nconst COLORS = [\n '#FF00FF',\n '#F5BD80',\n '#FF0000',\n '#0080FF',\n '#FF8000',\n '#58ACFA',\n '#FA58F4',\n '#40FF00',\n '#4B8A08',\n '#40FF00',\n '#D8F781',\n];\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n popUpFormatter,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const radiusCircleBoundsRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const restWells = useMemo(() => {\n return wells.filter(well => !subjectWell || subjectWell.id !== well.id);\n }, [subjectWell, wells]);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Get well marker colors according to its target formation\n const [formations, colorDict] = useMemo(() => {\n // NOTE: Determine well marker colors\n const restFormations = [];\n let hasNullFormation = false;\n\n restWells.forEach(well => {\n if (well.formation === 'Null') {\n hasNullFormation = true;\n } else if (\n (!subjectWell || subjectWell.formation !== well.formation) &&\n !restFormations.includes(well.formation)\n ) {\n restFormations.push(well.formation);\n }\n });\n\n const sortedFormations = subjectWell\n ? [subjectWell.formation].concat(sortBy(restFormations))\n : sortBy(restFormations);\n\n if (hasNullFormation && !sortedFormations.includes('Null')) {\n sortedFormations.push('Null');\n }\n\n const colors = sortedFormations.reduce(\n (result, item, idx) => ({\n ...result,\n [item]: COLORS[idx % COLORS.length],\n }),\n {}\n );\n\n return [sortedFormations, colors];\n }, [subjectWell, restWells]);\n\n // NOTE: Initialize map\n useEffect(() => {\n if (!IS_MAPBOX_ENABLED) return undefined;\n\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack)\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n radiusCircleBoundsRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n radiusCircleBoundsRef.current = null;\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n radiusCircleBoundsRef.current = ring.reduce(\n (bounds, coord) => bounds.extend(coord),\n new mapboxgl.LngLatBounds()\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const color = isWellSubject || isWellOffset ? OFFSET_WELL_COLOR : colorDict[well.formation];\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, color, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n if (popUpFormatter) {\n // Container to put React generated content in.\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(popUpFormatter, {\n well,\n color: colorDict[well.formation],\n });\n // NOTE: Custom popup may have buttons\n ReactDOM.render(\n <MuiThemeProvider theme={theme.darkTheme}>{popUpContent}</MuiThemeProvider>,\n popUpContainer\n );\n\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current\n .setLngLat(toLngLat(get(well, coordsDataPath)))\n .setDOMContent(popUpContainer)\n .addTo(map);\n }\n };\n\n const handleMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && radiusCircleBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, colorDict, isMapReady]);\n\n useEffect(() => {\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusCircleBoundsRef.current) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, {\n padding: 5,\n });\n }\n } else if (mapRef.current && markersBoundsRef.current) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n }, [radius, subjectWell, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n\n <div className={styles.mapFooter}>\n {offsetWells && (\n <div className={styles.mapFooterItem}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: OFFSET_WELL_COLOR }}\n />\n <div className={styles.mapFooterItemLabel}>Selected Offset Wells</div>\n </div>\n )}\n\n {formations.map(item => (\n <div className={styles.mapFooterItem} key={item}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: colorDict[item] }}\n />\n <div className={styles.mapFooterItemLabel}>{item}</div>\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n popUpFormatter: PropTypes.func,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n popUpFormatter: null,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","COLORS","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref5","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","popUpFormatter","coordsDataPath","mapContainerRef","useRef","mapRef","radiusCircleBoundsRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","restWells","useMemo","filter","well","id","subjectWellCoords","get","restFormations","hasNullFormation","forEach","formation","includes","push","sortedFormations","concat","sortBy","colors","reduce","result","item","idx","length","_useMemo2","_useMemo","formations","colorDict","useEffect","IS_MAPBOX_ENABLED","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","source","paint","map","remove","getSource","setData","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","sin","makeCirclePolygon","geometry","coordinates","bounds","coord","extend","LngLatBounds","_popupRef$current","prevWells","offsetWellIds","wellsById","coords","isWellSubject","isWellOffset","r","color","opacity","properties","wellId","hoveredWellId","handleMouseMove","e","getCanvas","cursor","popUpContainer","document","createElement","popUpContent","ReactDOM","render","_jsx","MuiThemeProvider","theme","children","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseLeave","setTimeout","fitBounds","padding","off","_jsxs","className","styles","mapMain","ref","mapFooter","mapFooterItem","mapFooterItemSquare","backgroundColor","mapFooterItemLabel","propTypes","PropTypes","shape","number","string","arrayOf","isRequired","func","defaultProps","memo"],"mappings":"o3EAcA,IAAQA,EAAuBC,EAAvBD,mBAOFE,EAAS,CACb,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,WAGIC,EAAiB,CAAC,WAAY,WAI9BC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAElEC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EAe3C,SAASC,EASNC,GAAA,IARDC,IAAAA,YACAC,IAAAA,MACAC,IAAAA,YACAC,IAAAA,OACAC,IAAAA,sBACAC,IAAAA,eACAC,IAAAA,eACAC,IAAAA,eAEMC,EAAkBC,EAAO,MACzBC,EAASD,EAAO,MAChBE,EAAwBF,EAAO,MAC/BG,EAAmBH,EAAO,MAC1BI,EAAWJ,EAAO,MAClBK,EAAeL,IACeM,EAAAA,GAAS,GAAMC,EAAApB,EAAAqB,EAAA,GAA5CC,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAE1BI,EAAYC,GAAQ,WACxB,OAAOpB,EAAMqB,QAAO,SAAAC,GAAI,OAAKvB,GAAeA,EAAYwB,KAAOD,EAAKC,KACtE,GAAG,CAACxB,EAAaC,IAEXwB,EAAoBJ,GAAQ,WAChC,OAAOrB,GAAe0B,EAAI1B,EAAaO,EACzC,GAAG,CAACP,EAAaO,IAGec,EAAAA,GAAQ,WAEtC,IAAMM,EAAiB,GACnBC,GAAmB,EAEvBR,EAAUS,SAAQ,SAAAN,GACO,SAAnBA,EAAKO,UACPF,GAAmB,EAEjB5B,GAAeA,EAAY8B,YAAcP,EAAKO,WAC/CH,EAAeI,SAASR,EAAKO,YAE9BH,EAAeK,KAAKT,EAAKO,UAE7B,IAEA,IAAMG,EAAmBjC,EACrB,CAACA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mBrB,SAAA,6BAI7CzE,EAAWsB,KAAI,SAAA3B,GAAI,OAClB0F,EAAA,MAAA,CAAKC,UAAWC,EAAOI,cAAclB,SACnC,CAAAH,EAAA,MAAA,CACEgB,UAAWC,EAAOK,oBAClBpF,MAAO,CAAEqF,gBAAiB5F,EAAUN,MAEtC2E,EAAA,MAAA,CAAKgB,UAAWC,EAAOO,mBAAmBrB,SAAE9E,MALHA,EAMrC,SAKhB,CAEAzC,EAAS6I,UAAY,CACnB3I,YAAa4I,EAAUC,MAAM,CAC3BrH,GAAIoH,EAAUE,OACdhH,UAAW8G,EAAUG,SAEvB9I,MAAO2I,EAAUI,QAAQJ,EAAUC,MAAM,CAAA,IAAKI,WAC9C/I,YAAa0I,EAAUI,QAAQJ,EAAUC,MAAM,CAAE,IACjD1I,OAAQyI,EAAUE,OAAOG,WACzB7I,sBAAuBwI,EAAUE,OACjCzI,eAAgBuI,EAAUE,OAC1BxI,eAAgBsI,EAAUM,KAC1B3I,eAAgBqI,EAAUG,QAG5BjJ,EAASqJ,aAAe,CACtBnJ,YAAa,KACbI,sBA/UuC,GAgVvCC,eA/U+B,EAgV/BC,eAAgB,KAChBC,eAAgB,gCAChBL,YAAa,MAGf,IAAekJ,EAAAA,EAAKtJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Map.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js"],"names":[],"mappings":";;AAuCA;;;;;;;;;;;gBAmPC;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAxRqB,YAAY"}
1
+ {"version":3,"file":"Map.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js"],"names":[],"mappings":";;AAwCA;;;;;;;;;;;gBAmPC;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAzRqB,YAAY"}
@@ -1,2 +1,2 @@
1
- import e from"@babel/runtime/helpers/slicedToArray";import{memo as r,useRef as t,useState as o,useMemo as n,useEffect as u,createElement as l}from"react";import i from"react-dom";import c from"prop-types";import{get as a,sortBy as s}from"lodash";import d from"./Map.css.js";import{mapbox as f}from"../../../../../../utils/index.js";import"../../../../../../config/mapboxGl/index.js";import"mapbox-gl/dist/mapbox-gl.css";import{jsx as p,Fragment as m}from"react/jsx-runtime";import v from"mapbox-gl";var y=f.isValidCoordinates,g=[29.749907,-95.358421],h={type:"FeatureCollection",features:[]},w=function(r){var t=e(r,2),o=t[0];return[t[1],o]};function b(r){var c=r.open,f=r.subjectWell,b=r.wells,D=r.offsetWells,x=r.radius,B=r.formationColors,C=r.popUpFormatter,F=r.coordsDataPath,W=r.onAddOffsetWell,j=r.onDeleteOffsetWell,M=t(null),P=t(),L=t(null),O=t(null),q=t(null),R=t(),I=o(!1),S=e(I,2),T=S[0],k=S[1],A=n((function(){return f&&a(f,F)}),[f,F]);return u((function(){c&&!P.current&&(P.current=new v.Map({container:M.current,style:"mapbox://styles/mapbox/dark-v9",center:w(g),zoom:1,attributionControl:!1,scrollZoom:!1}),P.current.addControl(new v.NavigationControl({showCompass:!1}),"bottom-right"),P.current.on("load",(function(){P.current.addSource("radius-circle",{type:"geojson",data:h}),P.current.addLayer({id:"radius-circle",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),P.current.addSource("wells",{type:"geojson",data:h}),P.current.addLayer({id:"wells",type:"circle",source:"wells",layout:{"circle-sort-key":["get","sortKey"]},paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),k(!0)})))}),[c]),u((function(){return function(){P.current&&(P.current.remove(),P.current=null,L.current=null,O.current=null)}}),[]),u((function(){if(P.current&&T&&c){if(!A)return P.current.getSource("radius-circle").setData(h),void(L.current=null);var r=function(r,t){for(var o=e(r,2),n=o[0],u=o[1],l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,i=[],c=t/(111320*Math.cos(n*Math.PI/180)),a=t/110574,s=0;s<=l;s+=1){var d=s/l*(2*Math.PI);i.push([u+c*Math.cos(d),n+a*Math.sin(d)])}return i}(A,1609.34*x);P.current.getSource("radius-circle").setData({type:"Feature",geometry:{type:"Polygon",coordinates:[r]}}),L.current=r.reduce((function(e,r){return e.extend(r)}),new v.LngLatBounds)}}),[x,A,c,T]),u((function(){if(P.current&&T&&c){var e=R.current;R.current=b;var r=D.map((function(e){return e.id})),t=s(b,(function(e){return r.includes(e.id)})),o=[],n={},u=new v.LngLatBounds;t.forEach((function(e){var t=a(e,F);if(t&&y(t)){var l=f&&f.id===e.id,i=r.includes(e.id),c=l?10:5,s=l||i?"#00FFFF":a(B,e.formation,"#BDBDBD"),d=l||i?1:.3;n[e.id]=e,u.extend(w(t)),o.push({type:"Feature",geometry:{type:"Point",coordinates:w(t)},properties:{wellId:e.id,radius:c,color:s,opacity:d,sortKey:i?1:0}})}})),P.current.getSource("wells").setData({type:"FeatureCollection",features:o}),O.current=o.length?u:null;var d=P.current,g=null,h=function(e){d.getCanvas().style.cursor="pointer";var r=n[e.features[0].properties.wellId];if(r&&r.id!==g&&(g=r.id,C)){var t=document.createElement("div"),o=l(C,{well:r,color:a(B,r.formation,"#BDBDBD")});i.render(p(m,{children:o}),t),q.current||(q.current=new v.Popup({closeButton:!1,maxWidth:"none"})),q.current.setLngLat(w(a(r,F))).setDOMContent(t).addTo(d)}},x=function(){var e;g=null,d.getCanvas().style.cursor="",null===(e=q.current)||void 0===e||e.remove()},M=function(e){var t=e.features[0].properties.wellId,o=f&&f.id===t;r.includes(t)&&!o?j(t):W(t)};return d.on("mousemove","wells",h),d.on("mouseleave","wells",x),d.on("click","wells",M),setTimeout((function(){P.current&&L.current&&b!==e&&P.current.fitBounds(L.current,{padding:5})}),500),function(){d.off("mousemove","wells",h),d.off("mouseleave","wells",x),d.off("click","wells",M)}}}),[f,b,D,c,T]),u((function(){c&&setTimeout((function(){f?P.current&&L.current&&P.current.fitBounds(L.current,{padding:5}):P.current&&O.current&&P.current.fitBounds(O.current)}),500)}),[x,f,c,T]),p("div",{className:d.map,children:p("div",{className:d.mapMain,ref:M})})}b.propTypes={open:c.bool.isRequired,subjectWell:c.shape({id:c.number,formation:c.string}),wells:c.arrayOf(c.shape({})).isRequired,offsetWells:c.arrayOf(c.shape({})),radius:c.number.isRequired,formationColors:c.shape({}).isRequired,popUpFormatter:c.func,coordsDataPath:c.string,onAddOffsetWell:c.func.isRequired,onDeleteOffsetWell:c.func.isRequired},b.defaultProps={subjectWell:null,popUpFormatter:null,coordsDataPath:"settings.top_hole.coordinates",offsetWells:null};var D=r(b);export{D as default};
1
+ import e from"@babel/runtime/helpers/slicedToArray";import{memo as r,useRef as t,useState as o,useMemo as n,useEffect as u,createElement as i}from"react";import l from"react-dom";import c from"prop-types";import{get as a,sortBy as s}from"lodash";import d from"./Map.css.js";import{mapbox as f}from"../../../../../../utils/index.js";import"../../../../../../config/mapboxGl/index.js";import{IS_MAPBOX_ENABLED as p}from"../../../../../../config/mapbox/index.js";import"mapbox-gl/dist/mapbox-gl.css";import{jsx as m,Fragment as v}from"react/jsx-runtime";import y from"mapbox-gl";var g=f.isValidCoordinates,h=[29.749907,-95.358421],w={type:"FeatureCollection",features:[]},b=function(r){var t=e(r,2),o=t[0];return[t[1],o]};function D(r){var c=r.open,f=r.subjectWell,D=r.wells,x=r.offsetWells,B=r.radius,C=r.formationColors,F=r.popUpFormatter,W=r.coordsDataPath,j=r.onAddOffsetWell,M=r.onDeleteOffsetWell,P=t(null),L=t(),O=t(null),q=t(null),R=t(null),I=t(),S=o(!1),T=e(S,2),k=T[0],A=T[1],N=n((function(){return f&&a(f,W)}),[f,W]);return u((function(){p&&c&&!L.current&&(L.current=new y.Map({container:P.current,style:"mapbox://styles/mapbox/dark-v9",center:b(h),zoom:1,attributionControl:!1,scrollZoom:!1}),L.current.addControl(new y.NavigationControl({showCompass:!1}),"bottom-right"),L.current.on("load",(function(){L.current.addSource("radius-circle",{type:"geojson",data:w}),L.current.addLayer({id:"radius-circle",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),L.current.addSource("wells",{type:"geojson",data:w}),L.current.addLayer({id:"wells",type:"circle",source:"wells",layout:{"circle-sort-key":["get","sortKey"]},paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),A(!0)})))}),[c]),u((function(){return function(){L.current&&(L.current.remove(),L.current=null,O.current=null,q.current=null)}}),[]),u((function(){if(L.current&&k&&c){if(!N)return L.current.getSource("radius-circle").setData(w),void(O.current=null);var r=function(r,t){for(var o=e(r,2),n=o[0],u=o[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,l=[],c=t/(111320*Math.cos(n*Math.PI/180)),a=t/110574,s=0;s<=i;s+=1){var d=s/i*(2*Math.PI);l.push([u+c*Math.cos(d),n+a*Math.sin(d)])}return l}(N,1609.34*B);L.current.getSource("radius-circle").setData({type:"Feature",geometry:{type:"Polygon",coordinates:[r]}}),O.current=r.reduce((function(e,r){return e.extend(r)}),new y.LngLatBounds)}}),[B,N,c,k]),u((function(){if(L.current&&k&&c){var e=I.current;I.current=D;var r=x.map((function(e){return e.id})),t=s(D,(function(e){return r.includes(e.id)})),o=[],n={},u=new y.LngLatBounds;t.forEach((function(e){var t=a(e,W);if(t&&g(t)){var i=f&&f.id===e.id,l=r.includes(e.id),c=i?10:5,s=i||l?"#00FFFF":a(C,e.formation,"#BDBDBD"),d=i||l?1:.3;n[e.id]=e,u.extend(b(t)),o.push({type:"Feature",geometry:{type:"Point",coordinates:b(t)},properties:{wellId:e.id,radius:c,color:s,opacity:d,sortKey:l?1:0}})}})),L.current.getSource("wells").setData({type:"FeatureCollection",features:o}),q.current=o.length?u:null;var d=L.current,p=null,h=function(e){d.getCanvas().style.cursor="pointer";var r=n[e.features[0].properties.wellId];if(r&&r.id!==p&&(p=r.id,F)){var t=document.createElement("div"),o=i(F,{well:r,color:a(C,r.formation,"#BDBDBD")});l.render(m(v,{children:o}),t),R.current||(R.current=new y.Popup({closeButton:!1,maxWidth:"none"})),R.current.setLngLat(b(a(r,W))).setDOMContent(t).addTo(d)}},w=function(){var e;p=null,d.getCanvas().style.cursor="",null===(e=R.current)||void 0===e||e.remove()},B=function(e){var t=e.features[0].properties.wellId,o=f&&f.id===t;r.includes(t)&&!o?M(t):j(t)};return d.on("mousemove","wells",h),d.on("mouseleave","wells",w),d.on("click","wells",B),setTimeout((function(){L.current&&O.current&&D!==e&&L.current.fitBounds(O.current,{padding:5})}),500),function(){d.off("mousemove","wells",h),d.off("mouseleave","wells",w),d.off("click","wells",B)}}}),[f,D,x,c,k]),u((function(){c&&setTimeout((function(){f?L.current&&O.current&&L.current.fitBounds(O.current,{padding:5}):L.current&&q.current&&L.current.fitBounds(q.current)}),500)}),[B,f,c,k]),m("div",{className:d.map,children:m("div",{className:d.mapMain,ref:P})})}D.propTypes={open:c.bool.isRequired,subjectWell:c.shape({id:c.number,formation:c.string}),wells:c.arrayOf(c.shape({})).isRequired,offsetWells:c.arrayOf(c.shape({})),radius:c.number.isRequired,formationColors:c.shape({}).isRequired,popUpFormatter:c.func,coordsDataPath:c.string,onAddOffsetWell:c.func.isRequired,onDeleteOffsetWell:c.func.isRequired},D.defaultProps={subjectWell:null,popUpFormatter:null,coordsDataPath:"settings.top_hole.coordinates",offsetWells:null};var x=r(D);export{x as default};
2
2
  //# sourceMappingURL=Map.js.map