{"version":3,"file":"ThreeDGlobe-Dw8W5rgG.cjs","names":[],"sources":["../node_modules/hex-to-rgba/build/index.js","../src/Components/Graphs/Maps/ThreeDGlobe/Graph.tsx","../src/Components/Graphs/Maps/ThreeDGlobe/index.tsx"],"sourcesContent":["\"use strict\";\n\nvar removeHash = function removeHash(hex) {\n  return hex.charAt(0) === '#' ? hex.slice(1) : hex;\n};\n\nvar parseHex = function parseHex(nakedHex) {\n  var isShort = nakedHex.length === 3 || nakedHex.length === 4;\n  var twoDigitHexR = isShort ? \"\".concat(nakedHex.slice(0, 1)).concat(nakedHex.slice(0, 1)) : nakedHex.slice(0, 2);\n  var twoDigitHexG = isShort ? \"\".concat(nakedHex.slice(1, 2)).concat(nakedHex.slice(1, 2)) : nakedHex.slice(2, 4);\n  var twoDigitHexB = isShort ? \"\".concat(nakedHex.slice(2, 3)).concat(nakedHex.slice(2, 3)) : nakedHex.slice(4, 6);\n  var twoDigitHexA = (isShort ? \"\".concat(nakedHex.slice(3, 4)).concat(nakedHex.slice(3, 4)) : nakedHex.slice(6, 8)) || 'ff'; // const numericA = +((parseInt(a, 16) / 255).toFixed(2));\n\n  return {\n    r: twoDigitHexR,\n    g: twoDigitHexG,\n    b: twoDigitHexB,\n    a: twoDigitHexA\n  };\n};\n\nvar hexToDecimal = function hexToDecimal(hex) {\n  return parseInt(hex, 16);\n};\n\nvar hexesToDecimals = function hexesToDecimals(_ref) {\n  var r = _ref.r,\n      g = _ref.g,\n      b = _ref.b,\n      a = _ref.a;\n  return {\n    r: hexToDecimal(r),\n    g: hexToDecimal(g),\n    b: hexToDecimal(b),\n    a: +(hexToDecimal(a) / 255).toFixed(2)\n  };\n};\n\nvar isNumeric = function isNumeric(n) {\n  return !isNaN(parseFloat(n)) && isFinite(n);\n}; // eslint-disable-line no-restricted-globals, max-len\n\n\nvar formatRgb = function formatRgb(decimalObject, parameterA) {\n  var r = decimalObject.r,\n      g = decimalObject.g,\n      b = decimalObject.b,\n      parsedA = decimalObject.a;\n  var a = isNumeric(parameterA) ? parameterA : parsedA;\n  return \"rgba(\".concat(r, \", \").concat(g, \", \").concat(b, \", \").concat(a, \")\");\n};\n/**\n * Turns an old-fashioned css hex color value into a rgb color value.\n *\n * If you specify an alpha value, you'll get a rgba() value instead.\n *\n * @param The hex value to convert. ('123456'. '#123456', ''123', '#123')\n * @param An alpha value to apply. (optional) ('0.5', '0.25')\n * @return An rgb or rgba value. ('rgb(11, 22, 33)'. 'rgba(11, 22, 33, 0.5)')\n */\n\n\nvar hexToRgba = function hexToRgba(hex, a) {\n  var hashlessHex = removeHash(hex);\n  var hexObject = parseHex(hashlessHex);\n  var decimalObject = hexesToDecimals(hexObject);\n  return formatRgb(decimalObject, a);\n};\n\nmodule.exports = hexToRgba;","import { cn } from '@undp/design-system-react/cn';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport { scaleOrdinal, scaleThreshold } from 'd3-scale';\r\nimport isEqual from 'fast-deep-equal';\r\nimport hexToRgba from 'hex-to-rgba';\r\nimport { useCallback, useEffect, useRef, useState } from 'react';\r\nimport Globe, { type GlobeMethods } from 'react-globe.gl';\r\nimport * as THREE from 'three';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport {\r\n  LegendCollapseButton,\r\n  LegendExpandButton,\r\n} from '@/Components/Elements/LegendExpandControls';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport type {\r\n  ChoroplethMapDataType,\r\n  ClassNameObject,\r\n  FogDataType,\r\n  LightConfig,\r\n  NumberFormatOptions,\r\n  StyleObject,\r\n} from '@/Types';\r\nimport { getCentroidCoordinates } from '@/Utils/getCentroidCoordinates';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\n\r\ninterface Props {\r\n  width: number;\r\n  data: ChoroplethMapDataType[];\r\n  autoRotate: number;\r\n  enableZoom: boolean;\r\n  categorical: boolean;\r\n  colorDomain: (number | string)[];\r\n  colors: string[];\r\n  height: number;\r\n  globeMaterial?: THREE.Material;\r\n  lights: LightConfig[];\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  polygonData: any;\r\n  mapProperty: string;\r\n  mapBorderColor: string;\r\n  atmosphereColor: string;\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  tooltip?: string | ((_d: any) => React.ReactNode);\r\n  styles?: StyleObject;\r\n  classNames?: ClassNameObject;\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  onSeriesMouseOver?: (_d: any) => void;\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  onSeriesMouseClick?: (_d: any) => void;\r\n  mapNoDataColor: string;\r\n  colorLegendTitle?: string;\r\n  showColorScale: boolean;\r\n  hoverStrokeColor: string;\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n  resetSelectionOnDoubleClick: boolean;\r\n  highlightedIds?: string[];\r\n  scale: number;\r\n  globeOffset: [number, number];\r\n  polygonAltitude: number;\r\n  centerLng: number;\r\n  centerLat: number;\r\n  atmosphereAltitude: number;\r\n  globeCurvatureResolution: number;\r\n  fogSettings?: FogDataType;\r\n  highlightedAltitude: number;\r\n  selectedId?: string;\r\n  collapseColorScaleByDefault?: boolean;\r\n  dimmedOpacity: number;\r\n  numberDisplayOptions?: Omit<NumberFormatOptions, 'suffix' | 'prefix'>;\r\n}\r\n\r\nfunction createLightFromConfig(config: LightConfig): THREE.Light {\r\n  let light: THREE.Light;\r\n\r\n  switch (config.type) {\r\n    case 'ambient':\r\n      light = new THREE.AmbientLight(config.color, config.intensity);\r\n      break;\r\n    case 'directional':\r\n      light = new THREE.DirectionalLight(config.color, config.intensity);\r\n      if (config.position) {\r\n        if (config.position === 'camera') light.position.set(0, 0, 0);\r\n        else light.position.set(config.position.x, config.position.y, config.position.z);\r\n      }\r\n      if (config.target || config.position === 'camera') {\r\n        (light as THREE.SpotLight).target.position.set(\r\n          config.target?.x || 0,\r\n          config.target?.y || 0,\r\n          config.target?.z === undefined ? -1 : config.target.z,\r\n        );\r\n      }\r\n      if (config.castShadow) {\r\n        (light as THREE.DirectionalLight).castShadow = true;\r\n        if (config.shadow) {\r\n          (light as THREE.DirectionalLight).shadow.mapSize.width = config.shadow.mapSize.width;\r\n          (light as THREE.DirectionalLight).shadow.mapSize.height = config.shadow.mapSize.height;\r\n          (light as THREE.DirectionalLight).shadow.camera.near = config.shadow.camera.near;\r\n          (light as THREE.DirectionalLight).shadow.camera.far = config.shadow.camera.far;\r\n        }\r\n      }\r\n      break;\r\n    case 'point':\r\n      light = new THREE.PointLight(\r\n        config.color,\r\n        config.intensity,\r\n        config.distance || 0,\r\n        config.decay || 2,\r\n      );\r\n      if (config.position) {\r\n        if (config.position === 'camera') light.position.set(0, 0, 0);\r\n        else light.position.set(config.position.x, config.position.y, config.position.z);\r\n      }\r\n      break;\r\n    case 'spot':\r\n      light = new THREE.SpotLight(\r\n        config.color,\r\n        config.intensity,\r\n        config.distance || 0,\r\n        config.angle || Math.PI / 3,\r\n        config.penumbra || 0,\r\n        config.decay || 2,\r\n      );\r\n      if (config.position) {\r\n        if (config.position === 'camera') light.position.set(0, 0, 0);\r\n        else light.position.set(config.position.x, config.position.y, config.position.z);\r\n      }\r\n      if (config.target || config.position === 'camera') {\r\n        (light as THREE.SpotLight).target.position.set(\r\n          config.target?.x || 0,\r\n          config.target?.y || 0,\r\n          config.target?.z || 0,\r\n        );\r\n      }\r\n      if (config.castShadow) {\r\n        (light as THREE.SpotLight).castShadow = true;\r\n        if (config.shadow) {\r\n          (light as THREE.SpotLight).shadow.mapSize.width = config.shadow.mapSize.width;\r\n          (light as THREE.SpotLight).shadow.mapSize.height = config.shadow.mapSize.height;\r\n          (light as THREE.SpotLight).shadow.camera.near = config.shadow.camera.near;\r\n          (light as THREE.SpotLight).shadow.camera.far = config.shadow.camera.far;\r\n        }\r\n      }\r\n      break;\r\n    default:\r\n      throw new Error('Unknown light type');\r\n  }\r\n\r\n  return light;\r\n}\r\nfunction Graph(props: Props) {\r\n  const {\r\n    width,\r\n    autoRotate,\r\n    data,\r\n    enableZoom,\r\n    categorical,\r\n    colorDomain,\r\n    colors,\r\n    globeMaterial,\r\n    height,\r\n    polygonData,\r\n    mapProperty,\r\n    mapBorderColor,\r\n    atmosphereColor,\r\n    tooltip,\r\n    styles,\r\n    classNames,\r\n    mapNoDataColor,\r\n    colorLegendTitle,\r\n    showColorScale,\r\n    hoverStrokeColor,\r\n    detailsOnClick,\r\n    onSeriesMouseClick,\r\n    onSeriesMouseOver,\r\n    resetSelectionOnDoubleClick,\r\n    highlightedIds,\r\n    scale,\r\n    globeOffset,\r\n    polygonAltitude,\r\n    centerLng,\r\n    centerLat,\r\n    atmosphereAltitude,\r\n    globeCurvatureResolution,\r\n    fogSettings,\r\n    lights,\r\n    highlightedAltitude,\r\n    selectedId,\r\n    collapseColorScaleByDefault,\r\n    dimmedOpacity,\r\n    numberDisplayOptions,\r\n  } = props;\r\n  const [globeReady, setGlobeReady] = useState(false);\r\n  const globeEl = useRef<GlobeMethods | undefined>(undefined);\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n\r\n  const [showLegend, setShowLegend] = useState(\r\n    collapseColorScaleByDefault === undefined ? !(width < 680) : !collapseColorScaleByDefault,\r\n  );\r\n  const [mousePos, setMousePos] = useState({ x: 0, y: 0 });\r\n  const [mouseOverData, setMouseOverData] = useState<ChoroplethMapDataType | undefined>(undefined);\r\n  const colorScale = categorical\r\n    ? scaleOrdinal<number | string, string>().domain(colorDomain).range(colors)\r\n    : scaleThreshold<number, string>()\r\n        .domain(colorDomain as number[])\r\n        .range(colors);\r\n  useEffect(() => {\r\n    if (globeEl.current) {\r\n      globeEl.current.controls().enableZoom = enableZoom;\r\n    }\r\n  }, [enableZoom]);\r\n  useEffect(() => {\r\n    if (globeEl.current) {\r\n      if (mouseOverData || selectedId) {\r\n        globeEl.current.controls().autoRotate = false;\r\n      } else {\r\n        globeEl.current.controls().autoRotate = autoRotate !== 0;\r\n        globeEl.current.controls().autoRotateSpeed = autoRotate;\r\n      }\r\n    }\r\n  }, [mouseOverData, selectedId, autoRotate]);\r\n  useEffect(() => {\r\n    if (globeEl.current && selectedId) {\r\n      const selectedPolygon = polygonData.find(\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        (d: any) => d.properties[mapProperty] === selectedId,\r\n      );\r\n      const [lng, lat] = getCentroidCoordinates(selectedPolygon);\r\n      globeEl.current.pointOfView({ lat, lng, altitude: scale }, 1000);\r\n    }\r\n  }, [selectedId, scale, polygonData, mapProperty]);\r\n\r\n  useEffect(() => {\r\n    const canvas = globeEl.current?.renderer().domElement;\r\n    if (!canvas) return;\r\n\r\n    const handleMouseMove = (e: MouseEvent) => {\r\n      setMousePos({ x: e.clientX, y: e.clientY });\r\n    };\r\n\r\n    canvas.addEventListener('mousemove', handleMouseMove);\r\n    return () => canvas.removeEventListener('mousemove', handleMouseMove);\r\n  }, []);\r\n\r\n  useEffect(() => {\r\n    if (globeEl.current) {\r\n      globeEl.current.pointOfView({ lat: centerLat, lng: centerLng, altitude: scale }, 1000);\r\n    }\r\n  }, [scale, centerLng, centerLat]);\r\n  const materials =\r\n    globeMaterial ||\r\n    new THREE.MeshBasicMaterial({\r\n      color: '#FFF',\r\n    });\r\n  const setupCustomLighting = useCallback(() => {\r\n    if (!globeEl.current) return;\r\n\r\n    const scene = globeEl.current.scene();\r\n    const camera = globeEl.current.camera();\r\n\r\n    let lightsAndObjToRemove: THREE.Object3D[] = [];\r\n    scene.traverse((obj) => {\r\n      if (obj instanceof THREE.Light) {\r\n        lightsAndObjToRemove.push(obj);\r\n      }\r\n    });\r\n    lightsAndObjToRemove = [...lightsAndObjToRemove, ...camera.children];\r\n    lightsAndObjToRemove.forEach((light) => {\r\n      light.parent?.remove(light);\r\n    });\r\n\r\n    const lightConfig = lights.map((config) => createLightFromConfig(config));\r\n    lightConfig.forEach((light, i) => {\r\n      if (lights[i].type !== 'ambient' && lights[i].position === 'camera') {\r\n        camera.add(light);\r\n        if (lights[i].type !== 'point') {\r\n          camera.add((light as THREE.DirectionalLight | THREE.SpotLight).target);\r\n        }\r\n      } else {\r\n        scene.add(light);\r\n      }\r\n    });\r\n\r\n    if (fogSettings) {\r\n      scene.fog = new THREE.Fog(fogSettings.color, fogSettings.near, fogSettings.far);\r\n    }\r\n  }, [lights, fogSettings]);\r\n\r\n  const handleGlobeReady = () => {\r\n    setGlobeReady(true);\r\n    setupCustomLighting();\r\n  };\r\n  useEffect(() => {\r\n    if (globeReady) {\r\n      setupCustomLighting();\r\n    }\r\n  }, [globeReady, setupCustomLighting]);\r\n  return (\r\n    <div className='relative'>\r\n      <Globe\r\n        ref={globeEl}\r\n        height={height}\r\n        width={width}\r\n        globeOffset={globeOffset}\r\n        lineHoverPrecision={0}\r\n        polygonsData={polygonData}\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        polygonAltitude={(polygon: any) =>\r\n          highlightedIds?.includes(polygon?.properties?.[mapProperty]) ||\r\n          polygon?.properties?.[mapProperty] === selectedId\r\n            ? highlightedAltitude\r\n            : polygon?.properties?.[mapProperty] === mouseOverData?.id ||\r\n                polygon?.properties?.[mapProperty] === mouseClickData?.id\r\n              ? highlightedAltitude\r\n              : polygonAltitude\r\n        }\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        polygonCapColor={(polygon: any) => {\r\n          const opacity = selectedId\r\n            ? polygon?.properties?.[mapProperty] === selectedId\r\n              ? 1\r\n              : dimmedOpacity\r\n            : highlightedIds\r\n              ? highlightedIds.includes(polygon?.properties?.[mapProperty])\r\n                ? 1\r\n                : dimmedOpacity\r\n              : 1;\r\n          const id = polygon?.properties?.[mapProperty];\r\n          const val = data.find((el) => el.id === id)?.x;\r\n          // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n          const color = val !== undefined && val !== null ? colorScale(val as any) : mapNoDataColor;\r\n          return hexToRgba(color, `${opacity}`);\r\n        }}\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        polygonSideColor={(polygon: any) => {\r\n          const id = polygon?.properties?.[mapProperty];\r\n          const val = data.find((el) => el.id === id)?.x;\r\n          const opacity = selectedId\r\n            ? polygon?.properties?.[mapProperty] === selectedId\r\n              ? 1\r\n              : dimmedOpacity\r\n            : highlightedIds\r\n              ? highlightedIds.includes(polygon?.properties?.[mapProperty])\r\n                ? 1\r\n                : dimmedOpacity\r\n              : 1;\r\n          // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n          const color = val !== undefined && val !== null ? colorScale(val as any) : mapNoDataColor;\r\n          return hexToRgba(color, `${opacity}`);\r\n        }}\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        polygonStrokeColor={(polygon: any) =>\r\n          polygon?.properties?.[mapProperty] === mouseOverData?.id\r\n            ? hoverStrokeColor\r\n            : mapBorderColor\r\n        }\r\n        onGlobeClick={() => {\r\n          setMouseClickData(undefined);\r\n        }}\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        onPolygonClick={(polygon: any) => {\r\n          const clickedData = polygon?.properties?.[mapProperty]\r\n            ? data.find((el) => el.id === polygon?.properties?.[mapProperty])\r\n            : undefined;\r\n          if (onSeriesMouseClick || detailsOnClick) {\r\n            if (\r\n              isEqual(mouseClickData, clickedData) &&\r\n              resetSelectionOnDoubleClick &&\r\n              clickedData\r\n            ) {\r\n              setMouseClickData(undefined);\r\n              onSeriesMouseClick?.(undefined);\r\n            } else {\r\n              setMouseClickData(clickedData);\r\n              onSeriesMouseClick?.(clickedData);\r\n            }\r\n          }\r\n        }}\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        onPolygonHover={(polygon: any) => {\r\n          const hoverData = polygon?.properties?.[mapProperty]\r\n            ? data.find((el) => el.id === polygon?.properties?.[mapProperty])\r\n            : undefined;\r\n          setMouseOverData(hoverData);\r\n          onSeriesMouseOver?.(hoverData);\r\n        }}\r\n        atmosphereColor={atmosphereColor}\r\n        atmosphereAltitude={atmosphereAltitude}\r\n        globeCurvatureResolution={globeCurvatureResolution}\r\n        globeMaterial={materials}\r\n        backgroundColor='rgba(0, 0, 0, 0)'\r\n        polygonsTransitionDuration={100}\r\n        onGlobeReady={() => {\r\n          if (globeEl.current) {\r\n            globeEl.current.pointOfView({\r\n              lat: centerLat,\r\n              lng: centerLng,\r\n            });\r\n            const scene = globeEl.current.scene();\r\n            setTimeout(() => {\r\n              const polygons = scene.children[3]?.children[0]?.children[4]?.children || [];\r\n              polygons.forEach((d) => {\r\n                const line = d.children[1];\r\n                line.renderOrder = 2;\r\n              });\r\n            }, 300);\r\n            const camera = globeEl.current.camera();\r\n            scene.add(camera);\r\n            handleGlobeReady();\r\n          }\r\n        }}\r\n      />\r\n      {showColorScale === false ? null : (\r\n        <div className={cn('absolute left-4 bottom-4 map-color-legend', classNames?.colorLegend)}>\r\n          {showLegend ? (\r\n            <>\r\n              <LegendCollapseButton setExpanded={setShowLegend} />\r\n              <div\r\n                className='color-legend-box p-2 bg-surface-sm/70'\r\n                style={{\r\n                  width: categorical ? undefined : '340px',\r\n                }}\r\n              >\r\n                {colorLegendTitle && colorLegendTitle !== '' ? (\r\n                  <P\r\n                    size='xs'\r\n                    marginBottom='xs'\r\n                    className='p-0 leading-normal overflow-hidden text-content-primary'\r\n                    style={{\r\n                      display: '-webkit-box',\r\n                      WebkitLineClamp: '1',\r\n                      WebkitBoxOrient: 'vertical',\r\n                    }}\r\n                  >\r\n                    {colorLegendTitle}\r\n                  </P>\r\n                ) : null}\r\n                {!categorical ? (\r\n                  <svg width='100%' viewBox='0 0 320 30' direction='ltr'>\r\n                    <g>\r\n                      {colorDomain.map((d, i) => (\r\n                        // biome-ignore lint/suspicious/noArrayIndexKey: index is the unique identifier\r\n                        <g key={i} className='cursor-pointer'>\r\n                          <rect\r\n                            x={(i * 320) / colors.length + 1}\r\n                            y={1}\r\n                            width={320 / colors.length - 2}\r\n                            height={8}\r\n                            style={{\r\n                              fill: colors[i],\r\n                              stroke: colors[i],\r\n                            }}\r\n                          />\r\n                          <text\r\n                            x={((i + 1) * 320) / colors.length}\r\n                            y={25}\r\n                            className='fill-content-primary text-xs'\r\n                            style={{ textAnchor: 'middle' }}\r\n                          >\r\n                            {numberFormattingFunction(\r\n                              d as number,\r\n                              undefined,\r\n                              numberDisplayOptions?.precision ?? 2,\r\n                              undefined,\r\n                              undefined,\r\n                              numberDisplayOptions?.locale || 'en',\r\n                              numberDisplayOptions?.padZeros || 'none',\r\n                            )}\r\n                          </text>\r\n                        </g>\r\n                      ))}\r\n                      <g>\r\n                        <rect\r\n                          x={(colorDomain.length * 320) / colors.length + 1}\r\n                          y={1}\r\n                          width={320 / colors.length - 2}\r\n                          height={8}\r\n                          style={{\r\n                            fill: colors[colorDomain.length],\r\n                            stroke: colors[colorDomain.length],\r\n                          }}\r\n                        />\r\n                      </g>\r\n                    </g>\r\n                  </svg>\r\n                ) : (\r\n                  <div className='flex flex-col gap-3'>\r\n                    {colorDomain.map((d, i) => (\r\n                      // biome-ignore lint/suspicious/noArrayIndexKey: index is the unique identifier\r\n                      <div key={i} className='flex gap-2 items-center'>\r\n                        <div\r\n                          className='w-2 h-2 rounded-full'\r\n                          style={{ backgroundColor: colors[i % colors.length] }}\r\n                        />\r\n                        <P size='sm' marginBottom='none' leading='none'>\r\n                          {d}\r\n                        </P>\r\n                      </div>\r\n                    ))}\r\n                  </div>\r\n                )}\r\n              </div>\r\n            </>\r\n          ) : (\r\n            <LegendExpandButton setExpanded={setShowLegend} />\r\n          )}\r\n        </div>\r\n      )}\r\n      {mouseOverData && tooltip ? (\r\n        <Tooltip\r\n          data={mouseOverData}\r\n          body={tooltip}\r\n          xPos={mousePos.x}\r\n          yPos={mousePos.y}\r\n          backgroundStyle={styles?.tooltip}\r\n          className={classNames?.tooltip}\r\n        />\r\n      ) : null}\r\n      {detailsOnClick && mouseClickData !== undefined ? (\r\n        <DetailsModal\r\n          body={detailsOnClick}\r\n          data={mouseClickData}\r\n          setData={setMouseClickData}\r\n          className={classNames?.modal}\r\n        />\r\n      ) : null}\r\n    </div>\r\n  );\r\n}\r\n\r\nexport default Graph;\r\n","import { Spinner } from '@undp/design-system-react/Spinner';\r\nimport type React from 'react';\r\nimport { useEffect, useEffectEvent, useRef, useState } from 'react';\r\nimport type * as THREE from 'three';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { GraphArea, GraphContainer } from '@/Components/Elements/GraphContainer';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { useElementSize } from '@/hooks/useElementSize';\r\nimport type {\r\n  ChoroplethMapDataType,\r\n  ClassNameObject,\r\n  FogDataType,\r\n  Languages,\r\n  LightConfig,\r\n  NumberFormatOptions,\r\n  ScaleDataType,\r\n  SourcesDataType,\r\n  StyleObject,\r\n} from '@/Types';\r\nimport { fetchAndParseJSON } from '@/Utils/fetchAndParseData';\r\nimport { getJenks } from '@/Utils/getJenks';\r\nimport { getUniqValue } from '@/Utils/getUniqValue';\r\nimport Graph from './Graph';\r\n\r\ninterface Props {\r\n  // Data\r\n  /** Array of data objects */\r\n  data: ChoroplethMapDataType[];\r\n\r\n  // Titles, Labels, and Sources\r\n  /** Title of the graph */\r\n  graphTitle?: string | React.ReactNode;\r\n  /** Description of the graph */\r\n  graphDescription?: string | React.ReactNode;\r\n  /** Footnote for the graph */\r\n  footNote?: string | React.ReactNode;\r\n  /** Source data for the graph */\r\n  sources?: SourcesDataType[];\r\n  /** Accessibility label */\r\n  ariaLabel?: string;\r\n\r\n  // Colors and Styling\r\n  /** Colors for the choropleth map. Make sure the the colors are in hex code, any other format can cause issues. */\r\n  colors?: string[];\r\n  /** Domain of colors for the graph */\r\n  colorDomain?: number[] | string[];\r\n  /** Title for the color legend */\r\n  colorLegendTitle?: string;\r\n  /** Color for the areas where data is no available */\r\n  mapNoDataColor?: string;\r\n  /** Background color of the graph */\r\n  backgroundColor?: string | boolean;\r\n  /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n  styles?: StyleObject;\r\n  /** Custom class names */\r\n  classNames?: ClassNameObject;\r\n\r\n  // Size and Spacing\r\n  /** Width of the graph */\r\n  width?: number;\r\n  /** Height of the graph */\r\n  height?: number;\r\n  /** Minimum height of the graph */\r\n  minHeight?: number;\r\n  /** Relative height scaling factor. This overwrites the height props */\r\n  relativeHeight?: number;\r\n  /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n  padding?: string;\r\n\r\n  // Graph Parameters\r\n  /** Map data as an object in geoJson format or a url for geoJson */\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  mapData?: any;\r\n  /** Stroke color of the regions in the map */\r\n  mapBorderColor?: string;\r\n  /** Center point of the map */\r\n  centerPoint?: [number, number];\r\n  /** Defines if the globe rotates automatically */\r\n  autoRotate?: number | boolean;\r\n  /** Defines the material property applied to the sphere of the globe */\r\n  globeMaterial?: THREE.Material;\r\n  /** Defines the lights for the 3D scene */\r\n  lights?: LightConfig[];\r\n  /** Defines the colo of the glow around the globe */\r\n  atmosphereColor?: string;\r\n  /** Defines if the globe can be zoomed when scrolled */\r\n  enableZoom?: boolean;\r\n  /** Position offset of the globe relative to the canvas center */\r\n  globeOffset?: [number, number];\r\n  /** Defines the camera distance from Earth. This helps in defining the default size of the globe. Smaller = closer camera therefore the globe is bigger) */\r\n  scale?: number;\r\n  /** Defines the spacing between the country shape polygon with the sphere */\r\n  polygonAltitude?: number;\r\n  /** Scale for the colors */\r\n  scaleType?: Exclude<ScaleDataType, 'linear'>;\r\n  /** Toggle visibility of color scale. */\r\n  showColorScale?: boolean;\r\n  /** Configuration options for controlling number formatting, localization, precision, and zero padding. */\r\n  numberDisplayOptions?: Omit<NumberFormatOptions, 'suffix' | 'prefix'>;\r\n  /** Toggle if color scale is collapsed by default. */\r\n  collapseColorScaleByDefault?: boolean;\r\n  /** The max altitude of the atmosphere, in terms of globe radius units. */\r\n  atmosphereAltitude?: number;\r\n  /** Resolution in angular degrees of the sphere curvature. The finer the resolution, the more the globe is fragmented into smaller faces to approximate the spheric surface, at the cost of performance. */\r\n  globeCurvatureResolution?: number;\r\n  /** Defines fog settings for the scene. */\r\n  fogSettings?: FogDataType;\r\n  /** Property in the property object in mapData geoJson object is used to match to the id in the data object */\r\n  mapProperty?: string;\r\n  /** Countries or regions to be highlighted */\r\n  selectedId?: string;\r\n  /** Countries or regions to be highlighted */\r\n  highlightedIds?: string[];\r\n  /** Defines the altitude of the highlighted countries or the countries on mouseover. */\r\n  highlightedAltitude?: number;\r\n  /** Defines the opacity of the non-highlighted data */\r\n  dimmedOpacity?: number;\r\n  /** Enable data download option as a csv */\r\n  dataDownload?: boolean;\r\n  /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n  resetSelectionOnDoubleClick?: boolean;\r\n\r\n  // Interactions and Callbacks\r\n  /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  tooltip?: string | ((_d: any) => React.ReactNode);\r\n  /** Details displayed on the modal when user clicks of a data point. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n  /** Callback for mouse over event */\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  onSeriesMouseOver?: (_d: any) => void;\r\n  /** Callback for mouse click event */\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  onSeriesMouseClick?: (_d: any) => void;\r\n\r\n  // Configuration and Options\r\n  /** Language setting  */\r\n  language?: Languages;\r\n  /** Color theme */\r\n  theme?: 'light' | 'dark';\r\n  /** Unique ID for the graph */\r\n  graphID?: string;\r\n}\r\n\r\n/** For using these maps you will have to install [`three`](https://threejs.org/manual/) and [react-globe.gl](https://www.npmjs.com/package/react-globe.gl) package to your project */\r\nexport function ThreeDGlobe(props: Props) {\r\n  const {\r\n    data,\r\n    mapData = 'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-simplified.json',\r\n    graphTitle,\r\n    colors,\r\n    sources,\r\n    graphDescription,\r\n    height,\r\n    width,\r\n    footNote = 'The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.',\r\n    colorDomain,\r\n    colorLegendTitle,\r\n    scaleType = 'threshold',\r\n    padding,\r\n    mapNoDataColor = Colors.light.graphNoData,\r\n    backgroundColor = false,\r\n    mapBorderColor = Colors.light.grays['gray-500'],\r\n    relativeHeight,\r\n    tooltip,\r\n    graphID,\r\n    mapProperty = 'ISO3',\r\n    dataDownload = false,\r\n    language = 'en',\r\n    minHeight = 0,\r\n    theme = 'light',\r\n    ariaLabel,\r\n    styles,\r\n    classNames,\r\n    autoRotate = true,\r\n    enableZoom = true,\r\n    globeMaterial,\r\n    centerPoint = [0, 0],\r\n    atmosphereColor = '#999',\r\n    showColorScale = true,\r\n    resetSelectionOnDoubleClick = true,\r\n    detailsOnClick,\r\n    onSeriesMouseOver,\r\n    onSeriesMouseClick,\r\n    highlightedIds,\r\n    highlightedAltitude = 0.1,\r\n    dimmedOpacity = 0.3,\r\n    scale = 1,\r\n    globeOffset = [0, 0],\r\n    polygonAltitude = 0.01,\r\n    globeCurvatureResolution = 4,\r\n    atmosphereAltitude = 0.15,\r\n    fogSettings,\r\n    lights = [\r\n      {\r\n        type: 'ambient',\r\n        color: 0x404040,\r\n        intensity: 0.4,\r\n      },\r\n      {\r\n        type: 'directional',\r\n        color: 0xffffff,\r\n        intensity: 1,\r\n        position: { x: 5, y: 10, z: 5 },\r\n      },\r\n    ],\r\n    selectedId,\r\n    collapseColorScaleByDefault,\r\n    numberDisplayOptions,\r\n  } = props;\r\n  const { graphDiv, svgWidth, svgHeight } = useElementSize<HTMLDivElement>();\r\n  const graphParentDiv = useRef<HTMLDivElement>(null);\r\n\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const [mapShape, setMapShape] = useState<any>(undefined);\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const onUpdateShape = useEffectEvent((shape: any) => {\r\n    setMapShape(shape);\r\n  });\r\n  useEffect(() => {\r\n    if (typeof mapData === 'string') {\r\n      const fetchData = fetchAndParseJSON(mapData);\r\n      fetchData.then((d) => {\r\n        if (\r\n          mapData ===\r\n          'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-simplified.json'\r\n        ) {\r\n          // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n          const features = d.features.map((el: any) => {\r\n            if (el.geometry.type === 'Polygon') {\r\n              const reversed = [...el.geometry.coordinates[0]].reverse();\r\n              const geometry = { ...el.geometry, coordinates: [reversed] };\r\n              return { ...el, geometry };\r\n            }\r\n            // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n            const coord: any = [];\r\n            // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n            el.geometry.coordinates.forEach((c: any) => {\r\n              const reversed = [...c[0]].reverse();\r\n              coord.push([reversed]);\r\n            });\r\n            const geometry = { ...el.geometry, coordinates: coord };\r\n            return { ...el, geometry };\r\n          });\r\n          onUpdateShape(features);\r\n        } else onUpdateShape(d.features);\r\n      });\r\n    } else {\r\n      onUpdateShape(mapData.features);\r\n    }\r\n  }, [mapData]);\r\n\r\n  const domain =\r\n    colorDomain ||\r\n    (scaleType === 'categorical'\r\n      ? getUniqValue(data, 'x')\r\n      : getJenks(\r\n          data.map((d) => d.x as number | null | undefined),\r\n          colors?.length || 4,\r\n        ));\r\n  return (\r\n    <GraphContainer\r\n      className={classNames?.graphContainer}\r\n      style={styles?.graphContainer}\r\n      id={graphID}\r\n      ref={graphParentDiv}\r\n      aria-label={ariaLabel}\r\n      backgroundColor={backgroundColor}\r\n      theme={theme}\r\n      language={language}\r\n      minHeight={minHeight}\r\n      width={width}\r\n      height={height}\r\n      relativeHeight={relativeHeight}\r\n      padding={padding}\r\n    >\r\n      {graphTitle || graphDescription || dataDownload ? (\r\n        <GraphHeader\r\n          styles={{\r\n            title: styles?.title,\r\n            description: styles?.description,\r\n          }}\r\n          classNames={{\r\n            title: classNames?.title,\r\n            description: classNames?.description,\r\n          }}\r\n          graphTitle={graphTitle}\r\n          graphDescription={graphDescription}\r\n          width={width}\r\n          graphDownload={undefined}\r\n          dataDownload={\r\n            dataDownload\r\n              ? data.map((d) => d.data).filter((d) => d !== undefined).length > 0\r\n                ? data.map((d) => d.data).filter((d) => d !== undefined)\r\n                : data.filter((d) => d !== undefined)\r\n              : null\r\n          }\r\n        />\r\n      ) : null}\r\n      <GraphArea ref={graphDiv}>\r\n        {svgWidth && svgHeight && mapShape ? (\r\n          <Graph\r\n            data={data}\r\n            globeOffset={globeOffset}\r\n            polygonData={mapShape}\r\n            colorDomain={domain}\r\n            width={svgWidth}\r\n            height={svgHeight}\r\n            colors={\r\n              colors ||\r\n              (scaleType === 'categorical'\r\n                ? Colors[theme].sequentialColors[\r\n                    `neutralColorsx0${domain.length as 4 | 5 | 6 | 7 | 8 | 9}`\r\n                  ]\r\n                : Colors[theme].sequentialColors[\r\n                    `neutralColorsx0${(domain.length + 1) as 4 | 5 | 6 | 7 | 8 | 9}`\r\n                  ])\r\n            }\r\n            mapNoDataColor={mapNoDataColor}\r\n            categorical={scaleType === 'categorical'}\r\n            mapBorderColor={mapBorderColor}\r\n            tooltip={tooltip}\r\n            mapProperty={mapProperty}\r\n            styles={styles}\r\n            classNames={classNames}\r\n            autoRotate={autoRotate === true ? 1.5 : autoRotate === false ? 0 : autoRotate}\r\n            enableZoom={enableZoom}\r\n            globeMaterial={globeMaterial}\r\n            atmosphereColor={atmosphereColor}\r\n            colorLegendTitle={colorLegendTitle}\r\n            showColorScale={showColorScale}\r\n            hoverStrokeColor={\r\n              theme === 'light' ? Colors.light.grays['gray-700'] : Colors.light.grays['gray-300']\r\n            }\r\n            highlightedIds={highlightedIds}\r\n            resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n            detailsOnClick={detailsOnClick}\r\n            onSeriesMouseOver={onSeriesMouseOver}\r\n            onSeriesMouseClick={onSeriesMouseClick}\r\n            scale={scale}\r\n            polygonAltitude={polygonAltitude}\r\n            centerLat={centerPoint[0]}\r\n            centerLng={centerPoint[1]}\r\n            atmosphereAltitude={atmosphereAltitude}\r\n            globeCurvatureResolution={globeCurvatureResolution}\r\n            fogSettings={fogSettings}\r\n            lights={lights}\r\n            highlightedAltitude={highlightedAltitude}\r\n            selectedId={selectedId}\r\n            collapseColorScaleByDefault={collapseColorScaleByDefault}\r\n            dimmedOpacity={dimmedOpacity}\r\n            numberDisplayOptions={numberDisplayOptions}\r\n          />\r\n        ) : (\r\n          <div\r\n            style={{\r\n              height: `${Math.max(\r\n                minHeight,\r\n                height ||\r\n                  (relativeHeight\r\n                    ? minHeight\r\n                      ? (width || svgWidth) * relativeHeight > minHeight\r\n                        ? (width || svgWidth) * relativeHeight\r\n                        : minHeight\r\n                      : (width || svgWidth) * relativeHeight\r\n                    : svgHeight),\r\n              )}px`,\r\n            }}\r\n            className='flex items-center justify-center'\r\n          >\r\n            <Spinner aria-label='Loading graph' />\r\n          </div>\r\n        )}\r\n      </GraphArea>\r\n      {sources || footNote ? (\r\n        <GraphFooter\r\n          styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n          classNames={{\r\n            footnote: classNames?.footnote,\r\n            source: classNames?.source,\r\n          }}\r\n          sources={sources}\r\n          footNote={footNote}\r\n          width={width}\r\n        />\r\n      ) : null}\r\n    </GraphContainer>\r\n  );\r\n}\r\n"],"x_google_ignoreList":[0],"mappings":"i3BAEA,IAAI,EAAa,SAAoB,EAAK,CACxC,OAAO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