{"version":3,"file":"SankeyChart-DQr7gOXV.cjs","names":["sum","sum","x","pointX","y","pointY","constant"],"sources":["../node_modules/d3-sankey/node_modules/d3-array/src/max.js","../node_modules/d3-sankey/node_modules/d3-array/src/min.js","../node_modules/d3-sankey/node_modules/d3-array/src/sum.js","../node_modules/d3-sankey/src/align.js","../node_modules/d3-sankey/src/constant.js","../node_modules/d3-sankey/src/sankey.js","../node_modules/d3-sankey/node_modules/d3-path/src/path.js","../node_modules/d3-sankey/node_modules/d3-shape/src/constant.js","../node_modules/d3-sankey/node_modules/d3-shape/src/point.js","../node_modules/d3-sankey/node_modules/d3-shape/src/array.js","../node_modules/d3-sankey/node_modules/d3-shape/src/link/index.js","../node_modules/d3-sankey/src/sankeyLinkHorizontal.js","../src/Components/Graphs/SankeyChart/Graph.tsx","../src/Components/Graphs/SankeyChart/index.tsx"],"sourcesContent":["export default function max(values, valueof) {\n  let max;\n  if (valueof === undefined) {\n    for (const value of values) {\n      if (value != null\n          && (max < value || (max === undefined && value >= value))) {\n        max = value;\n      }\n    }\n  } else {\n    let index = -1;\n    for (let value of values) {\n      if ((value = valueof(value, ++index, values)) != null\n          && (max < value || (max === undefined && value >= value))) {\n        max = value;\n      }\n    }\n  }\n  return max;\n}\n","export default function min(values, valueof) {\n  let min;\n  if (valueof === undefined) {\n    for (const value of values) {\n      if (value != null\n          && (min > value || (min === undefined && value >= value))) {\n        min = value;\n      }\n    }\n  } else {\n    let index = -1;\n    for (let value of values) {\n      if ((value = valueof(value, ++index, values)) != null\n          && (min > value || (min === undefined && value >= value))) {\n        min = value;\n      }\n    }\n  }\n  return min;\n}\n","export default function sum(values, valueof) {\n  let sum = 0;\n  if (valueof === undefined) {\n    for (let value of values) {\n      if (value = +value) {\n        sum += value;\n      }\n    }\n  } else {\n    let index = -1;\n    for (let value of values) {\n      if (value = +valueof(value, ++index, values)) {\n        sum += value;\n      }\n    }\n  }\n  return sum;\n}\n","import {min} from \"d3-array\";\n\nfunction targetDepth(d) {\n  return d.target.depth;\n}\n\nexport function left(node) {\n  return node.depth;\n}\n\nexport function right(node, n) {\n  return n - 1 - node.height;\n}\n\nexport function justify(node, n) {\n  return node.sourceLinks.length ? node.depth : n - 1;\n}\n\nexport function center(node) {\n  return node.targetLinks.length ? node.depth\n      : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1\n      : 0;\n}\n","export default function constant(x) {\n  return function() {\n    return x;\n  };\n}\n","import {max, min, sum} from \"d3-array\";\nimport {justify} from \"./align.js\";\nimport constant from \"./constant.js\";\n\nfunction ascendingSourceBreadth(a, b) {\n  return ascendingBreadth(a.source, b.source) || a.index - b.index;\n}\n\nfunction ascendingTargetBreadth(a, b) {\n  return ascendingBreadth(a.target, b.target) || a.index - b.index;\n}\n\nfunction ascendingBreadth(a, b) {\n  return a.y0 - b.y0;\n}\n\nfunction value(d) {\n  return d.value;\n}\n\nfunction defaultId(d) {\n  return d.index;\n}\n\nfunction defaultNodes(graph) {\n  return graph.nodes;\n}\n\nfunction defaultLinks(graph) {\n  return graph.links;\n}\n\nfunction find(nodeById, id) {\n  const node = nodeById.get(id);\n  if (!node) throw new Error(\"missing: \" + id);\n  return node;\n}\n\nfunction computeLinkBreadths({nodes}) {\n  for (const node of nodes) {\n    let y0 = node.y0;\n    let y1 = y0;\n    for (const link of node.sourceLinks) {\n      link.y0 = y0 + link.width / 2;\n      y0 += link.width;\n    }\n    for (const link of node.targetLinks) {\n      link.y1 = y1 + link.width / 2;\n      y1 += link.width;\n    }\n  }\n}\n\nexport default function Sankey() {\n  let x0 = 0, y0 = 0, x1 = 1, y1 = 1; // extent\n  let dx = 24; // nodeWidth\n  let dy = 8, py; // nodePadding\n  let id = defaultId;\n  let align = justify;\n  let sort;\n  let linkSort;\n  let nodes = defaultNodes;\n  let links = defaultLinks;\n  let iterations = 6;\n\n  function sankey() {\n    const graph = {nodes: nodes.apply(null, arguments), links: links.apply(null, arguments)};\n    computeNodeLinks(graph);\n    computeNodeValues(graph);\n    computeNodeDepths(graph);\n    computeNodeHeights(graph);\n    computeNodeBreadths(graph);\n    computeLinkBreadths(graph);\n    return graph;\n  }\n\n  sankey.update = function(graph) {\n    computeLinkBreadths(graph);\n    return graph;\n  };\n\n  sankey.nodeId = function(_) {\n    return arguments.length ? (id = typeof _ === \"function\" ? _ : constant(_), sankey) : id;\n  };\n\n  sankey.nodeAlign = function(_) {\n    return arguments.length ? (align = typeof _ === \"function\" ? _ : constant(_), sankey) : align;\n  };\n\n  sankey.nodeSort = function(_) {\n    return arguments.length ? (sort = _, sankey) : sort;\n  };\n\n  sankey.nodeWidth = function(_) {\n    return arguments.length ? (dx = +_, sankey) : dx;\n  };\n\n  sankey.nodePadding = function(_) {\n    return arguments.length ? (dy = py = +_, sankey) : dy;\n  };\n\n  sankey.nodes = function(_) {\n    return arguments.length ? (nodes = typeof _ === \"function\" ? _ : constant(_), sankey) : nodes;\n  };\n\n  sankey.links = function(_) {\n    return arguments.length ? (links = typeof _ === \"function\" ? _ : constant(_), sankey) : links;\n  };\n\n  sankey.linkSort = function(_) {\n    return arguments.length ? (linkSort = _, sankey) : linkSort;\n  };\n\n  sankey.size = function(_) {\n    return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];\n  };\n\n  sankey.extent = function(_) {\n    return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];\n  };\n\n  sankey.iterations = function(_) {\n    return arguments.length ? (iterations = +_, sankey) : iterations;\n  };\n\n  function computeNodeLinks({nodes, links}) {\n    for (const [i, node] of nodes.entries()) {\n      node.index = i;\n      node.sourceLinks = [];\n      node.targetLinks = [];\n    }\n    const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d]));\n    for (const [i, link] of links.entries()) {\n      link.index = i;\n      let {source, target} = link;\n      if (typeof source !== \"object\") source = link.source = find(nodeById, source);\n      if (typeof target !== \"object\") target = link.target = find(nodeById, target);\n      source.sourceLinks.push(link);\n      target.targetLinks.push(link);\n    }\n    if (linkSort != null) {\n      for (const {sourceLinks, targetLinks} of nodes) {\n        sourceLinks.sort(linkSort);\n        targetLinks.sort(linkSort);\n      }\n    }\n  }\n\n  function computeNodeValues({nodes}) {\n    for (const node of nodes) {\n      node.value = node.fixedValue === undefined\n          ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value))\n          : node.fixedValue;\n    }\n  }\n\n  function computeNodeDepths({nodes}) {\n    const n = nodes.length;\n    let current = new Set(nodes);\n    let next = new Set;\n    let x = 0;\n    while (current.size) {\n      for (const node of current) {\n        node.depth = x;\n        for (const {target} of node.sourceLinks) {\n          next.add(target);\n        }\n      }\n      if (++x > n) throw new Error(\"circular link\");\n      current = next;\n      next = new Set;\n    }\n  }\n\n  function computeNodeHeights({nodes}) {\n    const n = nodes.length;\n    let current = new Set(nodes);\n    let next = new Set;\n    let x = 0;\n    while (current.size) {\n      for (const node of current) {\n        node.height = x;\n        for (const {source} of node.targetLinks) {\n          next.add(source);\n        }\n      }\n      if (++x > n) throw new Error(\"circular link\");\n      current = next;\n      next = new Set;\n    }\n  }\n\n  function computeNodeLayers({nodes}) {\n    const x = max(nodes, d => d.depth) + 1;\n    const kx = (x1 - x0 - dx) / (x - 1);\n    const columns = new Array(x);\n    for (const node of nodes) {\n      const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x))));\n      node.layer = i;\n      node.x0 = x0 + i * kx;\n      node.x1 = node.x0 + dx;\n      if (columns[i]) columns[i].push(node);\n      else columns[i] = [node];\n    }\n    if (sort) for (const column of columns) {\n      column.sort(sort);\n    }\n    return columns;\n  }\n\n  function initializeNodeBreadths(columns) {\n    const ky = min(columns, c => (y1 - y0 - (c.length - 1) * py) / sum(c, value));\n    for (const nodes of columns) {\n      let y = y0;\n      for (const node of nodes) {\n        node.y0 = y;\n        node.y1 = y + node.value * ky;\n        y = node.y1 + py;\n        for (const link of node.sourceLinks) {\n          link.width = link.value * ky;\n        }\n      }\n      y = (y1 - y + py) / (nodes.length + 1);\n      for (let i = 0; i < nodes.length; ++i) {\n        const node = nodes[i];\n        node.y0 += y * (i + 1);\n        node.y1 += y * (i + 1);\n      }\n      reorderLinks(nodes);\n    }\n  }\n\n  function computeNodeBreadths(graph) {\n    const columns = computeNodeLayers(graph);\n    py = Math.min(dy, (y1 - y0) / (max(columns, c => c.length) - 1));\n    initializeNodeBreadths(columns);\n    for (let i = 0; i < iterations; ++i) {\n      const alpha = Math.pow(0.99, i);\n      const beta = Math.max(1 - alpha, (i + 1) / iterations);\n      relaxRightToLeft(columns, alpha, beta);\n      relaxLeftToRight(columns, alpha, beta);\n    }\n  }\n\n  // Reposition each node based on its incoming (target) links.\n  function relaxLeftToRight(columns, alpha, beta) {\n    for (let i = 1, n = columns.length; i < n; ++i) {\n      const column = columns[i];\n      for (const target of column) {\n        let y = 0;\n        let w = 0;\n        for (const {source, value} of target.targetLinks) {\n          let v = value * (target.layer - source.layer);\n          y += targetTop(source, target) * v;\n          w += v;\n        }\n        if (!(w > 0)) continue;\n        let dy = (y / w - target.y0) * alpha;\n        target.y0 += dy;\n        target.y1 += dy;\n        reorderNodeLinks(target);\n      }\n      if (sort === undefined) column.sort(ascendingBreadth);\n      resolveCollisions(column, beta);\n    }\n  }\n\n  // Reposition each node based on its outgoing (source) links.\n  function relaxRightToLeft(columns, alpha, beta) {\n    for (let n = columns.length, i = n - 2; i >= 0; --i) {\n      const column = columns[i];\n      for (const source of column) {\n        let y = 0;\n        let w = 0;\n        for (const {target, value} of source.sourceLinks) {\n          let v = value * (target.layer - source.layer);\n          y += sourceTop(source, target) * v;\n          w += v;\n        }\n        if (!(w > 0)) continue;\n        let dy = (y / w - source.y0) * alpha;\n        source.y0 += dy;\n        source.y1 += dy;\n        reorderNodeLinks(source);\n      }\n      if (sort === undefined) column.sort(ascendingBreadth);\n      resolveCollisions(column, beta);\n    }\n  }\n\n  function resolveCollisions(nodes, alpha) {\n    const i = nodes.length >> 1;\n    const subject = nodes[i];\n    resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha);\n    resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha);\n    resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha);\n    resolveCollisionsTopToBottom(nodes, y0, 0, alpha);\n  }\n\n  // Push any overlapping nodes down.\n  function resolveCollisionsTopToBottom(nodes, y, i, alpha) {\n    for (; i < nodes.length; ++i) {\n      const node = nodes[i];\n      const dy = (y - node.y0) * alpha;\n      if (dy > 1e-6) node.y0 += dy, node.y1 += dy;\n      y = node.y1 + py;\n    }\n  }\n\n  // Push any overlapping nodes up.\n  function resolveCollisionsBottomToTop(nodes, y, i, alpha) {\n    for (; i >= 0; --i) {\n      const node = nodes[i];\n      const dy = (node.y1 - y) * alpha;\n      if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy;\n      y = node.y0 - py;\n    }\n  }\n\n  function reorderNodeLinks({sourceLinks, targetLinks}) {\n    if (linkSort === undefined) {\n      for (const {source: {sourceLinks}} of targetLinks) {\n        sourceLinks.sort(ascendingTargetBreadth);\n      }\n      for (const {target: {targetLinks}} of sourceLinks) {\n        targetLinks.sort(ascendingSourceBreadth);\n      }\n    }\n  }\n\n  function reorderLinks(nodes) {\n    if (linkSort === undefined) {\n      for (const {sourceLinks, targetLinks} of nodes) {\n        sourceLinks.sort(ascendingTargetBreadth);\n        targetLinks.sort(ascendingSourceBreadth);\n      }\n    }\n  }\n\n  // Returns the target.y0 that would produce an ideal link from source to target.\n  function targetTop(source, target) {\n    let y = source.y0 - (source.sourceLinks.length - 1) * py / 2;\n    for (const {target: node, width} of source.sourceLinks) {\n      if (node === target) break;\n      y += width + py;\n    }\n    for (const {source: node, width} of target.targetLinks) {\n      if (node === source) break;\n      y -= width;\n    }\n    return y;\n  }\n\n  // Returns the source.y0 that would produce an ideal link from source to target.\n  function sourceTop(source, target) {\n    let y = target.y0 - (target.targetLinks.length - 1) * py / 2;\n    for (const {source: node, width} of target.targetLinks) {\n      if (node === source) break;\n      y += width + py;\n    }\n    for (const {target: node, width} of source.sourceLinks) {\n      if (node === target) break;\n      y -= width;\n    }\n    return y;\n  }\n\n  return sankey;\n}\n","var pi = Math.PI,\n    tau = 2 * pi,\n    epsilon = 1e-6,\n    tauEpsilon = tau - epsilon;\n\nfunction Path() {\n  this._x0 = this._y0 = // start of current subpath\n  this._x1 = this._y1 = null; // end of current subpath\n  this._ = \"\";\n}\n\nfunction path() {\n  return new Path;\n}\n\nPath.prototype = path.prototype = {\n  constructor: Path,\n  moveTo: function(x, y) {\n    this._ += \"M\" + (this._x0 = this._x1 = +x) + \",\" + (this._y0 = this._y1 = +y);\n  },\n  closePath: function() {\n    if (this._x1 !== null) {\n      this._x1 = this._x0, this._y1 = this._y0;\n      this._ += \"Z\";\n    }\n  },\n  lineTo: function(x, y) {\n    this._ += \"L\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n  },\n  quadraticCurveTo: function(x1, y1, x, y) {\n    this._ += \"Q\" + (+x1) + \",\" + (+y1) + \",\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n  },\n  bezierCurveTo: function(x1, y1, x2, y2, x, y) {\n    this._ += \"C\" + (+x1) + \",\" + (+y1) + \",\" + (+x2) + \",\" + (+y2) + \",\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n  },\n  arcTo: function(x1, y1, x2, y2, r) {\n    x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;\n    var x0 = this._x1,\n        y0 = this._y1,\n        x21 = x2 - x1,\n        y21 = y2 - y1,\n        x01 = x0 - x1,\n        y01 = y0 - y1,\n        l01_2 = x01 * x01 + y01 * y01;\n\n    // Is the radius negative? Error.\n    if (r < 0) throw new Error(\"negative radius: \" + r);\n\n    // Is this path empty? Move to (x1,y1).\n    if (this._x1 === null) {\n      this._ += \"M\" + (this._x1 = x1) + \",\" + (this._y1 = y1);\n    }\n\n    // Or, is (x1,y1) coincident with (x0,y0)? Do nothing.\n    else if (!(l01_2 > epsilon));\n\n    // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?\n    // Equivalently, is (x1,y1) coincident with (x2,y2)?\n    // Or, is the radius zero? Line to (x1,y1).\n    else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {\n      this._ += \"L\" + (this._x1 = x1) + \",\" + (this._y1 = y1);\n    }\n\n    // Otherwise, draw an arc!\n    else {\n      var x20 = x2 - x0,\n          y20 = y2 - y0,\n          l21_2 = x21 * x21 + y21 * y21,\n          l20_2 = x20 * x20 + y20 * y20,\n          l21 = Math.sqrt(l21_2),\n          l01 = Math.sqrt(l01_2),\n          l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),\n          t01 = l / l01,\n          t21 = l / l21;\n\n      // If the start tangent is not coincident with (x0,y0), line to.\n      if (Math.abs(t01 - 1) > epsilon) {\n        this._ += \"L\" + (x1 + t01 * x01) + \",\" + (y1 + t01 * y01);\n      }\n\n      this._ += \"A\" + r + \",\" + r + \",0,0,\" + (+(y01 * x20 > x01 * y20)) + \",\" + (this._x1 = x1 + t21 * x21) + \",\" + (this._y1 = y1 + t21 * y21);\n    }\n  },\n  arc: function(x, y, r, a0, a1, ccw) {\n    x = +x, y = +y, r = +r, ccw = !!ccw;\n    var dx = r * Math.cos(a0),\n        dy = r * Math.sin(a0),\n        x0 = x + dx,\n        y0 = y + dy,\n        cw = 1 ^ ccw,\n        da = ccw ? a0 - a1 : a1 - a0;\n\n    // Is the radius negative? Error.\n    if (r < 0) throw new Error(\"negative radius: \" + r);\n\n    // Is this path empty? Move to (x0,y0).\n    if (this._x1 === null) {\n      this._ += \"M\" + x0 + \",\" + y0;\n    }\n\n    // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).\n    else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {\n      this._ += \"L\" + x0 + \",\" + y0;\n    }\n\n    // Is this arc empty? We’re done.\n    if (!r) return;\n\n    // Does the angle go the wrong way? Flip the direction.\n    if (da < 0) da = da % tau + tau;\n\n    // Is this a complete circle? Draw two arcs to complete the circle.\n    if (da > tauEpsilon) {\n      this._ += \"A\" + r + \",\" + r + \",0,1,\" + cw + \",\" + (x - dx) + \",\" + (y - dy) + \"A\" + r + \",\" + r + \",0,1,\" + cw + \",\" + (this._x1 = x0) + \",\" + (this._y1 = y0);\n    }\n\n    // Is this arc non-empty? Draw an arc!\n    else if (da > epsilon) {\n      this._ += \"A\" + r + \",\" + r + \",0,\" + (+(da >= pi)) + \",\" + cw + \",\" + (this._x1 = x + r * Math.cos(a1)) + \",\" + (this._y1 = y + r * Math.sin(a1));\n    }\n  },\n  rect: function(x, y, w, h) {\n    this._ += \"M\" + (this._x0 = this._x1 = +x) + \",\" + (this._y0 = this._y1 = +y) + \"h\" + (+w) + \"v\" + (+h) + \"h\" + (-w) + \"Z\";\n  },\n  toString: function() {\n    return this._;\n  }\n};\n\nexport default path;\n","export default function(x) {\n  return function constant() {\n    return x;\n  };\n}\n","export function x(p) {\n  return p[0];\n}\n\nexport function y(p) {\n  return p[1];\n}\n","export var slice = Array.prototype.slice;\n","import {path} from \"d3-path\";\nimport {slice} from \"../array.js\";\nimport constant from \"../constant.js\";\nimport {x as pointX, y as pointY} from \"../point.js\";\nimport pointRadial from \"../pointRadial.js\";\n\nfunction linkSource(d) {\n  return d.source;\n}\n\nfunction linkTarget(d) {\n  return d.target;\n}\n\nfunction link(curve) {\n  var source = linkSource,\n      target = linkTarget,\n      x = pointX,\n      y = pointY,\n      context = null;\n\n  function link() {\n    var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);\n    if (!context) context = buffer = path();\n    curve(context, +x.apply(this, (argv[0] = s, argv)), +y.apply(this, argv), +x.apply(this, (argv[0] = t, argv)), +y.apply(this, argv));\n    if (buffer) return context = null, buffer + \"\" || null;\n  }\n\n  link.source = function(_) {\n    return arguments.length ? (source = _, link) : source;\n  };\n\n  link.target = function(_) {\n    return arguments.length ? (target = _, link) : target;\n  };\n\n  link.x = function(_) {\n    return arguments.length ? (x = typeof _ === \"function\" ? _ : constant(+_), link) : x;\n  };\n\n  link.y = function(_) {\n    return arguments.length ? (y = typeof _ === \"function\" ? _ : constant(+_), link) : y;\n  };\n\n  link.context = function(_) {\n    return arguments.length ? ((context = _ == null ? null : _), link) : context;\n  };\n\n  return link;\n}\n\nfunction curveHorizontal(context, x0, y0, x1, y1) {\n  context.moveTo(x0, y0);\n  context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);\n}\n\nfunction curveVertical(context, x0, y0, x1, y1) {\n  context.moveTo(x0, y0);\n  context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);\n}\n\nfunction curveRadial(context, x0, y0, x1, y1) {\n  var p0 = pointRadial(x0, y0),\n      p1 = pointRadial(x0, y0 = (y0 + y1) / 2),\n      p2 = pointRadial(x1, y0),\n      p3 = pointRadial(x1, y1);\n  context.moveTo(p0[0], p0[1]);\n  context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);\n}\n\nexport function linkHorizontal() {\n  return link(curveHorizontal);\n}\n\nexport function linkVertical() {\n  return link(curveVertical);\n}\n\nexport function linkRadial() {\n  var l = link(curveRadial);\n  l.angle = l.x, delete l.x;\n  l.radius = l.y, delete l.y;\n  return l;\n}\n","import {linkHorizontal} from \"d3-shape\";\n\nfunction horizontalSource(d) {\n  return [d.source.x1, d.y0];\n}\n\nfunction horizontalTarget(d) {\n  return [d.target.x0, d.y1];\n}\n\nexport default function() {\n  return linkHorizontal()\n      .source(horizontalSource)\n      .target(horizontalTarget);\n}\n","import { cn } from '@undp/design-system-react/cn';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport { sankey, sankeyCenter, sankeyLinkHorizontal } from 'd3-sankey';\r\nimport isEqual from 'fast-deep-equal';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { useMemo, useRef, useState } from 'react';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport type {\r\n  AnimateDataType,\r\n  ClassNameObject,\r\n  CustomLayerDataType,\r\n  NodeDataType,\r\n  NodesLinkDataType,\r\n  PadZerosTypes,\r\n  StyleObject,\r\n} from '@/Types';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\nimport { getGraphDimensions } from '@/Utils/getGraphDimensions';\r\nimport { getTextColorBasedOnBgColor } from '@/Utils/getTextColorBasedOnBgColor';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\n\r\ninterface Props {\r\n  data: NodesLinkDataType;\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  showLabels: boolean | ((_d: any) => React.ReactNode);\r\n  leftMargin: number;\r\n  truncateBy: number;\r\n  defaultLinkOpacity: number;\r\n  width: number;\r\n  height: number;\r\n  nodePadding: number;\r\n  nodeWidth: number;\r\n  rightMargin: number;\r\n  topMargin: number;\r\n  bottomMargin: number;\r\n  suffix: string;\r\n  prefix: string;\r\n  showValues?: boolean;\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  tooltip?: string | ((_d: any) => React.ReactNode);\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  highlightedSourceDataPoints?: string[];\r\n  highlightedTargetDataPoints?: string[];\r\n  sourceTitle?: string;\r\n  targetTitle?: string;\r\n  animate: AnimateDataType;\r\n  sortNodes: 'asc' | 'desc' | 'mostReadable' | 'none';\r\n  resetSelectionOnDoubleClick: boolean;\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n  styles?: StyleObject;\r\n  classNames?: ClassNameObject;\r\n  precision: number;\r\n  customLayers: CustomLayerDataType[];\r\n  locale: string;\r\n  padZeros: PadZerosTypes;\r\n  labelPosition: 'inside' | 'outside' | 'overlap';\r\n  labelWidth: number;\r\n  dimmedNodeOpacity: number;\r\n  minLabelHeight: number;\r\n  highlightedLinks?: { source: string | number; target: string | number }[];\r\n  linkColor?: string | 'source' | 'target' | 'source-target';\r\n  theme: 'dark' | 'light';\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n  const {\r\n    data,\r\n    showLabels,\r\n    leftMargin,\r\n    rightMargin,\r\n    truncateBy,\r\n    width,\r\n    height,\r\n    topMargin,\r\n    bottomMargin,\r\n    tooltip,\r\n    onSeriesMouseOver,\r\n    suffix,\r\n    prefix,\r\n    showValues,\r\n    onSeriesMouseClick,\r\n    nodePadding,\r\n    nodeWidth,\r\n    highlightedSourceDataPoints,\r\n    highlightedTargetDataPoints,\r\n    defaultLinkOpacity,\r\n    sourceTitle,\r\n    targetTitle,\r\n    animate,\r\n    sortNodes,\r\n    resetSelectionOnDoubleClick,\r\n    detailsOnClick,\r\n    styles,\r\n    classNames,\r\n    precision,\r\n    customLayers,\r\n    locale,\r\n    padZeros,\r\n    labelPosition,\r\n    labelWidth,\r\n    dimmedNodeOpacity,\r\n    highlightedLinks,\r\n    minLabelHeight,\r\n    linkColor,\r\n    theme,\r\n  } = props;\r\n  const svgRef = useRef(null);\r\n  const id = useMemo(() => generateRandomString(8), []);\r\n  const isInView = useInView(svgRef, {\r\n    once: animate.once,\r\n    amount: animate.amount,\r\n  });\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const [selectedNode, setSelectedNode] = useState<any>(undefined);\r\n  const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n  const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n  const margin = {\r\n    top: topMargin,\r\n    bottom: bottomMargin,\r\n    left: leftMargin,\r\n    right: rightMargin,\r\n  };\r\n  const { graphHeight, graphWidth } = getGraphDimensions({ width, height }, margin);\r\n  const sankeyGenerator =\r\n    sortNodes === 'mostReadable'\r\n      ? sankey()\r\n          .nodeWidth(nodeWidth)\r\n          .nodePadding(nodePadding)\r\n          .size([graphWidth, graphHeight])\r\n          .nodeAlign(sankeyCenter)\r\n      : sortNodes === 'none'\r\n        ? sankey()\r\n            .nodeWidth(nodeWidth)\r\n            .nodePadding(nodePadding)\r\n            .size([graphWidth, graphHeight])\r\n            .nodeAlign(sankeyCenter)\r\n            .nodeSort(null)\r\n            .linkSort(null)\r\n        : sankey()\r\n            .nodeWidth(nodeWidth)\r\n            .nodePadding(nodePadding)\r\n            .size([graphWidth, graphHeight])\r\n            .nodeAlign(sankeyCenter)\r\n            .nodeSort(\r\n              sortNodes === 'desc'\r\n                ? (a, b) => (b.value || 0) - (a.value || 0)\r\n                : (a, b) => (a.value || 0) - (b.value || 0),\r\n            );\r\n  const sankeyData = {\r\n    nodes: data.nodes.map((node) => ({ ...node })),\r\n    links: data.links.map((link) => ({ ...link })),\r\n  };\r\n\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const { nodes, links } = sankeyGenerator(sankeyData as any);\r\n  const linkPathGenerator = sankeyLinkHorizontal();\r\n  return (\r\n    <>\r\n      <motion.svg\r\n        width={`${width}px`}\r\n        height={`${height}px`}\r\n        viewBox={`0 0 ${width} ${height}`}\r\n        style={{ marginLeft: 'auto', marginRight: 'auto' }}\r\n        direction='ltr'\r\n        ref={svgRef}\r\n      >\r\n        {sourceTitle ? (\r\n          <text\r\n            x={margin.left}\r\n            y={margin.top - 10}\r\n            className='text-base font-bold fill-content-primary'\r\n            style={{ textAnchor: 'start' }}\r\n          >\r\n            {sourceTitle}\r\n          </text>\r\n        ) : null}\r\n        {targetTitle ? (\r\n          <text\r\n            x={width - margin.right}\r\n            y={margin.top - 10}\r\n            className='text-base font-bold fill-content-primary'\r\n            style={{ textAnchor: 'end' }}\r\n          >\r\n            {targetTitle}\r\n          </text>\r\n        ) : null}\r\n        <g transform={`translate(${margin.left},${margin.top})`}>\r\n          {customLayers.filter((d) => d.position === 'before').map((d) => d.layer)}\r\n          <defs>\r\n            {links.map((d, i) => (\r\n              <linearGradient\r\n                id={`${id}-gradient-${i}`}\r\n                x1='0%'\r\n                y1='0%'\r\n                x2='100%'\r\n                y2='0%'\r\n                // biome-ignore lint/suspicious/noArrayIndexKey: index is the unique identifier\r\n                key={i}\r\n                gradientUnits='userSpaceOnUse'\r\n              >\r\n                <stop\r\n                  offset='0%'\r\n                  style={{\r\n                    stopColor: (d.source as NodeDataType).color,\r\n                    stopOpacity: 1,\r\n                  }}\r\n                />\r\n                <stop\r\n                  offset='100%'\r\n                  style={{\r\n                    stopColor: (d.target as NodeDataType).color,\r\n                    stopOpacity: 1,\r\n                  }}\r\n                />\r\n              </linearGradient>\r\n            ))}\r\n          </defs>\r\n          <g>\r\n            <AnimatePresence>\r\n              {links.map((d, i) => {\r\n                const isLinkHighlighted =\r\n                  highlightedSourceDataPoints?.some(\r\n                    // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                    (el) => `source_${el}` === (d.source as any).name,\r\n                  ) ||\r\n                  highlightedTargetDataPoints?.some(\r\n                    // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                    (el) => `target_${el}` === (d.target as any).name,\r\n                  ) ||\r\n                  highlightedLinks?.some(\r\n                    (el) =>\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      `source_${el.source}` === (d.source as any).name &&\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      `target_${el.target}` === (d.target as any).name,\r\n                  );\r\n                return (\r\n                  <motion.g\r\n                    className='undp-viz-g-with-hover'\r\n                    // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                    key={`${(d.source as any).name}-${(d.target as any).name}`}\r\n                    onMouseEnter={(event) => {\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      setMouseOverData((d as any).data);\r\n                      setEventY(event.clientY);\r\n                      setEventX(event.clientX);\r\n\r\n                      onSeriesMouseOver?.(d);\r\n                    }}\r\n                    onMouseMove={(event) => {\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      setMouseOverData((d as any).data);\r\n                      setEventY(event.clientY);\r\n                      setEventX(event.clientX);\r\n                    }}\r\n                    onClick={() => {\r\n                      if (onSeriesMouseClick || detailsOnClick) {\r\n                        if (\r\n                          // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                          isEqual(mouseClickData, (d as any).data) &&\r\n                          resetSelectionOnDoubleClick\r\n                        ) {\r\n                          setMouseClickData(undefined);\r\n                          onSeriesMouseClick?.(undefined);\r\n                        } else {\r\n                          // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                          setMouseClickData((d as any).data);\r\n                          // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                          onSeriesMouseClick?.((d as any).data);\r\n                        }\r\n                      }\r\n                    }}\r\n                    onMouseLeave={() => {\r\n                      setMouseOverData(undefined);\r\n                      setEventX(undefined);\r\n                      setEventY(undefined);\r\n                      onSeriesMouseOver?.(undefined);\r\n                    }}\r\n                    opacity={\r\n                      selectedNode\r\n                        ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                          (d.source as any).name === selectedNode.name ||\r\n                          // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                          (d.target as any).name === selectedNode.name\r\n                          ? 0.85\r\n                          : defaultLinkOpacity\r\n                        : highlightedSourceDataPoints || highlightedTargetDataPoints\r\n                          ? isLinkHighlighted\r\n                            ? 0.85\r\n                            : defaultLinkOpacity\r\n                          : highlightedLinks && !mouseOverData\r\n                            ? isLinkHighlighted\r\n                              ? 0.85\r\n                              : defaultLinkOpacity\r\n                            : defaultLinkOpacity\r\n                    }\r\n                  >\r\n                    <motion.path\r\n                      key={`${(d.source as NodeDataType).name}-${(d.target as NodeDataType).name}`}\r\n                      d={linkPathGenerator(d) || ''}\r\n                      style={{\r\n                        fill: 'none',\r\n                      }}\r\n                      exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n                      variants={{\r\n                        initial: {\r\n                          pathLength: 0,\r\n                          opacity: 1,\r\n                          strokeWidth: d.width,\r\n                          stroke:\r\n                            linkColor === 'source'\r\n                              ? (d.source as NodeDataType).color\r\n                              : linkColor === 'target'\r\n                                ? (d.target as NodeDataType).color\r\n                                : linkColor === 'source-target'\r\n                                  ? `url(#${id}-gradient-${i})`\r\n                                  : linkColor,\r\n                        },\r\n                        whileInView: {\r\n                          pathLength: 1,\r\n                          opacity: 1,\r\n                          strokeWidth: d.width,\r\n                          stroke:\r\n                            linkColor === 'source'\r\n                              ? (d.source as NodeDataType).color\r\n                              : linkColor === 'target'\r\n                                ? (d.target as NodeDataType).color\r\n                                : linkColor === 'source-target'\r\n                                  ? `url(#${id}-gradient-${i})`\r\n                                  : linkColor,\r\n                          transition: { duration: animate.duration },\r\n                        },\r\n                      }}\r\n                      initial='initial'\r\n                      animate={isInView ? 'whileInView' : 'initial'}\r\n                    />\r\n                  </motion.g>\r\n                );\r\n              })}\r\n            </AnimatePresence>\r\n          </g>\r\n          {nodes\r\n            // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n            .filter((d: any) => d.type === 'source')\r\n            .map((d, i) => (\r\n              // biome-ignore lint/a11y/noStaticElementInteractions: interaction for graph\r\n              <g\r\n                // biome-ignore lint/suspicious/noArrayIndexKey: index is the unique identifier\r\n                key={i}\r\n                onFocus={() => {\r\n                  setSelectedNode(d);\r\n                }}\r\n                onMouseEnter={(event) => {\r\n                  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                  setMouseOverData((d as any).data);\r\n                  setSelectedNode(d);\r\n                  setEventY(event.clientY);\r\n                  setEventX(event.clientX);\r\n\r\n                  onSeriesMouseOver?.(d);\r\n                }}\r\n                onMouseMove={(event) => {\r\n                  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                  setMouseOverData((d as any).data);\r\n                  setEventY(event.clientY);\r\n                  setEventX(event.clientX);\r\n                }}\r\n                onClick={() => {\r\n                  if (onSeriesMouseClick || detailsOnClick) {\r\n                    if (\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      isEqual(mouseClickData, (d as any).data) &&\r\n                      resetSelectionOnDoubleClick\r\n                    ) {\r\n                      setMouseClickData(undefined);\r\n                      onSeriesMouseClick?.(undefined);\r\n                    } else {\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      setMouseClickData((d as any).data);\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      onSeriesMouseClick?.((d as any).data);\r\n                    }\r\n                  }\r\n                }}\r\n                onMouseLeave={() => {\r\n                  setMouseOverData(undefined);\r\n                  setSelectedNode(undefined);\r\n                  setEventX(undefined);\r\n                  setEventY(undefined);\r\n                  onSeriesMouseOver?.(undefined);\r\n                }}\r\n                opacity={\r\n                  selectedNode && selectedNode.type === 'source'\r\n                    ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      selectedNode.name === (d as any).name\r\n                      ? 1\r\n                      : dimmedNodeOpacity\r\n                    : highlightedSourceDataPoints\r\n                      ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                        highlightedSourceDataPoints.includes((d as any).label)\r\n                        ? 1\r\n                        : dimmedNodeOpacity\r\n                      : 1\r\n                }\r\n              >\r\n                <g transform={`translate(${d.x0},${d.y0})`}>\r\n                  <rect\r\n                    x={0}\r\n                    y={0}\r\n                    width={(d.x1 || 0) - (d.x0 || 0)}\r\n                    height={(d.y1 || 0) - (d.y0 || 0)}\r\n                    style={{ fill: (d as NodeDataType).color }}\r\n                  />\r\n                  {showLabels || showValues ? (\r\n                    <foreignObject\r\n                      y={0 - nodePadding / 2}\r\n                      x={\r\n                        labelPosition === 'outside'\r\n                          ? 0 - leftMargin\r\n                          : labelPosition === 'inside'\r\n                            ? nodeWidth\r\n                            : 0\r\n                      }\r\n                      width={\r\n                        labelPosition === 'outside'\r\n                          ? leftMargin\r\n                          : labelPosition === 'inside'\r\n                            ? labelWidth\r\n                            : nodeWidth\r\n                      }\r\n                      height={(d.y1 || 0) - (d.y0 || 0) + nodePadding}\r\n                      opacity={(d.y1 || 0) - (d.y0 || 0) + nodePadding < minLabelHeight ? 0 : 1}\r\n                    >\r\n                      <div\r\n                        className='flex flex-col gap-0.5 justify-center py-0 px-1.5'\r\n                        style={{\r\n                          height: `${(d.y1 || 0) - (d.y0 || 0) + nodePadding}px`,\r\n                          overflow: 'visible',\r\n                        }}\r\n                      >\r\n                        {showLabels &&\r\n                          (showLabels instanceof Function ? (\r\n                            showLabels(d)\r\n                          ) : (\r\n                            <P\r\n                              marginBottom={showValues ? '3xs' : 'none'}\r\n                              size='sm'\r\n                              leading='xs'\r\n                              className={cn(\r\n                                'sankey-source-label',\r\n                                labelPosition === 'outside' ? 'text-right' : 'text-left',\r\n                                classNames?.graphObjectValues,\r\n                              )}\r\n                              style={{\r\n                                hyphens: 'auto',\r\n                                color:\r\n                                  labelPosition === 'outside'\r\n                                    ? (d as NodeDataType).color\r\n                                    : labelPosition === 'inside'\r\n                                      ? Colors[theme].grays['gray-700']\r\n                                      : getTextColorBasedOnBgColor((d as NodeDataType).color),\r\n                                ...styles?.graphObjectValues,\r\n                              }}\r\n                            >\r\n                              {`${(d as NodeDataType).label}`.length < truncateBy\r\n                                ? `${(d as NodeDataType).label}`\r\n                                : `${`${(d as NodeDataType).label}`.substring(0, truncateBy)}...`}\r\n                            </P>\r\n                          ))}\r\n                        {showValues && (\r\n                          <P\r\n                            marginBottom='none'\r\n                            size='sm'\r\n                            leading='xs'\r\n                            className={cn(\r\n                              'sankey-source-value font-bold',\r\n                              labelPosition === 'outside' ? 'text-right' : 'text-left',\r\n                              classNames?.graphObjectValues,\r\n                            )}\r\n                            style={{\r\n                              hyphens: 'auto',\r\n                              color:\r\n                                labelPosition === 'outside'\r\n                                  ? (d as NodeDataType).color\r\n                                  : labelPosition === 'inside'\r\n                                    ? Colors[theme].grays['gray-700']\r\n                                    : getTextColorBasedOnBgColor((d as NodeDataType).color),\r\n                              ...styles?.graphObjectValues,\r\n                            }}\r\n                          >\r\n                            {numberFormattingFunction(\r\n                              d.value,\r\n                              undefined,\r\n                              precision,\r\n                              prefix,\r\n                              suffix,\r\n                              locale,\r\n                              padZeros,\r\n                            )}\r\n                          </P>\r\n                        )}\r\n                      </div>\r\n                    </foreignObject>\r\n                  ) : null}\r\n                </g>\r\n              </g>\r\n            ))}\r\n          {nodes\r\n            // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n            .filter((d: any) => d.type === 'target')\r\n            .map((d, i) => (\r\n              // biome-ignore lint/a11y/noStaticElementInteractions: interaction for graph\r\n              <g\r\n                // biome-ignore lint/suspicious/noArrayIndexKey: index is the unique identifier\r\n                key={i}\r\n                onFocus={() => {\r\n                  setSelectedNode(d);\r\n                }}\r\n                onMouseEnter={(event) => {\r\n                  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                  setMouseOverData((d as any).data);\r\n                  setSelectedNode(d);\r\n                  setEventY(event.clientY);\r\n                  setEventX(event.clientX);\r\n\r\n                  onSeriesMouseOver?.(d);\r\n                }}\r\n                onMouseMove={(event) => {\r\n                  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                  setMouseOverData((d as any).data);\r\n                  setEventY(event.clientY);\r\n                  setEventX(event.clientX);\r\n                }}\r\n                onClick={() => {\r\n                  if (onSeriesMouseClick || detailsOnClick) {\r\n                    if (\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      isEqual(mouseClickData, (d as any).data) &&\r\n                      resetSelectionOnDoubleClick\r\n                    ) {\r\n                      setMouseClickData(undefined);\r\n                      onSeriesMouseClick?.(undefined);\r\n                    } else {\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      setMouseClickData((d as any).data);\r\n                      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      onSeriesMouseClick?.((d as any).data);\r\n                    }\r\n                  }\r\n                }}\r\n                onMouseLeave={() => {\r\n                  setMouseOverData(undefined);\r\n                  setSelectedNode(undefined);\r\n                  setEventX(undefined);\r\n                  setEventY(undefined);\r\n                  onSeriesMouseOver?.(undefined);\r\n                }}\r\n                opacity={\r\n                  selectedNode && selectedNode.type === 'target'\r\n                    ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                      selectedNode.name === (d as any).name\r\n                      ? 1\r\n                      : dimmedNodeOpacity\r\n                    : highlightedTargetDataPoints\r\n                      ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                        highlightedTargetDataPoints.includes((d as any).label)\r\n                        ? 1\r\n                        : dimmedNodeOpacity\r\n                      : 1\r\n                }\r\n              >\r\n                <g transform={`translate(${d.x0},${d.y0})`}>\r\n                  <rect\r\n                    x={0}\r\n                    y={0}\r\n                    width={(d.x1 || 0) - (d.x0 || 0)}\r\n                    height={(d.y1 || 0) - (d.y0 || 0)}\r\n                    style={{ fill: (d as NodeDataType).color }}\r\n                  />\r\n                  {showLabels || showValues ? (\r\n                    <foreignObject\r\n                      y={0 - nodePadding / 2}\r\n                      x={\r\n                        labelPosition === 'outside'\r\n                          ? nodeWidth\r\n                          : labelPosition === 'inside'\r\n                            ? 0 - labelWidth\r\n                            : 0\r\n                      }\r\n                      width={\r\n                        labelPosition === 'outside'\r\n                          ? rightMargin\r\n                          : labelPosition === 'inside'\r\n                            ? labelWidth\r\n                            : nodeWidth\r\n                      }\r\n                      height={(d.y1 || 0) - (d.y0 || 0) + nodePadding}\r\n                      opacity={(d.y1 || 0) - (d.y0 || 0) + nodePadding < minLabelHeight ? 0 : 1}\r\n                    >\r\n                      <div\r\n                        className='flex flex-col gap-0.5 justify-center py-0 px-1.5'\r\n                        style={{\r\n                          height: `${(d.y1 || 0) - (d.y0 || 0) + nodePadding}px`,\r\n                        }}\r\n                      >\r\n                        {showLabels ? (\r\n                          <P\r\n                            marginBottom={showValues ? '3xs' : 'none'}\r\n                            size='sm'\r\n                            leading='xs'\r\n                            className={cn(\r\n                              'sankey-target-label',\r\n                              labelPosition === 'outside' ? 'text-left' : 'text-right',\r\n                              classNames?.graphObjectValues,\r\n                            )}\r\n                            style={{\r\n                              hyphens: 'auto',\r\n                              color:\r\n                                labelPosition === 'outside'\r\n                                  ? (d as NodeDataType).color\r\n                                  : labelPosition === 'inside'\r\n                                    ? Colors[theme].grays['gray-700']\r\n                                    : getTextColorBasedOnBgColor((d as NodeDataType).color),\r\n                              ...styles?.graphObjectValues,\r\n                            }}\r\n                          >\r\n                            {`${(d as NodeDataType).label}`.length < truncateBy\r\n                              ? `${(d as NodeDataType).label}`\r\n                              : `${`${(d as NodeDataType).label}`.substring(0, truncateBy)}...`}\r\n                          </P>\r\n                        ) : null}\r\n                        {showValues ? (\r\n                          <P\r\n                            size='sm'\r\n                            leading='xs'\r\n                            marginBottom='none'\r\n                            className={cn(\r\n                              'sankey-target-value font-bold',\r\n                              labelPosition === 'outside' ? 'text-left' : 'text-right',\r\n                              classNames?.graphObjectValues,\r\n                            )}\r\n                            style={{\r\n                              hyphens: 'auto',\r\n                              color:\r\n                                labelPosition === 'outside'\r\n                                  ? (d as NodeDataType).color\r\n                                  : labelPosition === 'inside'\r\n                                    ? Colors[theme].grays['gray-700']\r\n                                    : getTextColorBasedOnBgColor((d as NodeDataType).color),\r\n                              ...styles?.graphObjectValues,\r\n                            }}\r\n                          >\r\n                            {numberFormattingFunction(\r\n                              d.value,\r\n                              undefined,\r\n                              precision,\r\n                              prefix,\r\n                              suffix,\r\n                              locale,\r\n                              padZeros,\r\n                            )}\r\n                          </P>\r\n                        ) : null}\r\n                      </div>\r\n                    </foreignObject>\r\n                  ) : null}\r\n                </g>\r\n              </g>\r\n            ))}\r\n          {customLayers.filter((d) => d.position === 'after').map((d) => d.layer)}\r\n        </g>\r\n      </motion.svg>\r\n      {mouseOverData && tooltip && eventX && eventY ? (\r\n        <Tooltip\r\n          data={mouseOverData}\r\n          body={tooltip}\r\n          xPos={eventX}\r\n          yPos={eventY}\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    </>\r\n  );\r\n}\r\n","import orderBy from 'lodash.orderby';\r\nimport sum from 'lodash.sum';\r\nimport { useEffect, useEffectEvent, useRef, useState } from 'react';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\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  AnimateDataType,\r\n  ClassNameObject,\r\n  CustomLayerDataType,\r\n  Languages,\r\n  NodesLinkDataType,\r\n  NumberFormatOptions,\r\n  SankeyDataType,\r\n  SourcesDataType,\r\n  StyleObject,\r\n} from '@/Types';\r\nimport { uniqBy } from '@/Utils/uniqBy';\r\nimport { Graph } from './Graph';\r\n\r\ninterface Props {\r\n  // Data\r\n  /** Array of data objects */\r\n  data: SankeyDataType[];\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  /** Color or array of colors for source */\r\n  sourceColors?: string[] | string;\r\n  /** Color or array of colors for targets */\r\n  targetColors?: string[] | string;\r\n  /** Domain of colors for the source */\r\n  sourceColorDomain?: (string | number)[];\r\n  /** Domain of colors for the target */\r\n  targetColorDomain?: (string | number)[];\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  /** Left margin of the graph */\r\n  leftMargin?: number;\r\n  /** Right margin of the graph */\r\n  rightMargin?: number;\r\n  /** Top margin of the graph */\r\n  topMargin?: number;\r\n  /** Bottom margin of the graph */\r\n  bottomMargin?: number;\r\n  /** Toggles the background to fill the container. This only works if the width of the graph is defined. */\r\n  fillContainer?: boolean;\r\n  /** Padding between nodes */\r\n  nodePadding?: number;\r\n  /** Thickness of each node */\r\n  nodeWidth?: number;\r\n\r\n  // Values and Ticks\r\n  /** Truncate labels by specified length */\r\n  truncateBy?: number;\r\n\r\n  // Graph Parameters\r\n  /** Title of the source */\r\n  sourceTitle?: string;\r\n  /** Title of the targets */\r\n  targetTitle?: string;\r\n  /** Minimum height of the nodes for which labels and values are visible */\r\n  minLabelHeight?: number;\r\n  /** Toggle visibility of labels or defines what is shown in the label */\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  showLabels?: boolean | ((_d: any) => React.ReactNode);\r\n  /** Option to position the labels */\r\n  labelPosition?: 'inside' | 'outside' | 'overlap';\r\n  /** Defines the width of the labels if the `labelPosition` is set to `inside`*/\r\n  labelWidth?: number;\r\n  /** Toggle visibility of values */\r\n  showValues?: boolean;\r\n  /** Source to highlight. Use the label value from data to highlight the data point */\r\n  highlightedSourceDataPoints?: (string | number)[];\r\n  /** Targets to highlight. Use the label value from data to highlight the data point */\r\n  highlightedTargetDataPoints?: (string | number)[];\r\n  /** Links to highlight. Use the label value from data to highlight the data point */\r\n  highlightedLinks?: { source: string | number; target: string | number }[];\r\n  /** Opacity of the links */\r\n  defaultLinkOpacity?: number;\r\n  /** Color of the links. If the value is 'source' then the links will be colored based on the source color, if the value is 'target' then the links will be colored based on the target color, if the value is 'source-target' then the links will be colored based on the source and target color. A color can also be defined as hex code. */\r\n  linkColor?: string | 'source' | 'target' | 'source-target';\r\n  /** Opacity of the nodes when other nodes are highlighted or hovered. If no value is provided then it take the value of `defaultLinkOpacity` */\r\n  dimmedNodeOpacity?: number;\r\n  /** Sorting order of the nodes */\r\n  sortNodes?: 'asc' | 'desc' | 'mostReadable' | 'none';\r\n  /** Toggles if the graph animates in when loaded.  */\r\n  animate?: boolean | AnimateDataType;\r\n  /** Configuration options for controlling number formatting, localization, prefixes/suffixes, precision, and zero padding. */\r\n  numberDisplayOptions?: NumberFormatOptions;\r\n  /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n  customLayers?: CustomLayerDataType[];\r\n  /** Enable graph download option as png */\r\n  graphDownload?: boolean;\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 when user mouseover on the links. 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\nexport function SankeyChart(props: Props) {\r\n  const {\r\n    data,\r\n    graphTitle,\r\n    sources,\r\n    graphDescription,\r\n    showLabels = true,\r\n    leftMargin = 75,\r\n    rightMargin = 75,\r\n    topMargin = 30,\r\n    bottomMargin = 10,\r\n    truncateBy = 999,\r\n    height,\r\n    width,\r\n    footNote,\r\n    padding,\r\n    backgroundColor = false,\r\n    tooltip,\r\n    onSeriesMouseOver,\r\n    relativeHeight,\r\n    showValues = true,\r\n    graphID,\r\n    onSeriesMouseClick,\r\n    graphDownload = false,\r\n    dataDownload = false,\r\n    fillContainer = true,\r\n    language = 'en',\r\n    minHeight = 0,\r\n    theme = 'light',\r\n    ariaLabel,\r\n    sourceColors,\r\n    targetColors,\r\n    sourceColorDomain,\r\n    targetColorDomain,\r\n    nodePadding = 5,\r\n    nodeWidth = 5,\r\n    highlightedSourceDataPoints,\r\n    highlightedTargetDataPoints,\r\n    highlightedLinks,\r\n    defaultLinkOpacity = 0.3,\r\n    sourceTitle,\r\n    targetTitle,\r\n    sortNodes = 'mostReadable',\r\n    resetSelectionOnDoubleClick = true,\r\n    detailsOnClick,\r\n    styles,\r\n    classNames,\r\n    animate = false,\r\n    customLayers = [],\r\n    numberDisplayOptions,\r\n    labelPosition = 'outside',\r\n    labelWidth = 75,\r\n    dimmedNodeOpacity,\r\n    minLabelHeight = 25,\r\n    linkColor = 'source-target',\r\n  } = props;\r\n  const { graphDiv, svgWidth, svgHeight } = useElementSize<HTMLDivElement>();\r\n  const graphParentDiv = useRef<HTMLDivElement>(null);\r\n  const [sankeyData, setSankeyData] = useState<NodesLinkDataType | undefined>(undefined);\r\n\r\n  const updateSankeyDataEvent = useEffectEvent((data: NodesLinkDataType) => {\r\n    setSankeyData(data);\r\n  });\r\n\r\n  useEffect(() => {\r\n    const sourceNodes = uniqBy(data, 'source', true).map((d) => ({\r\n      name: `source_${d}`,\r\n      type: 'source' as const,\r\n      label: `${d}`,\r\n      color:\r\n        typeof sourceColors === 'string' || !sourceColors\r\n          ? sourceColors || Colors.graphMainColor\r\n          : sourceColors[\r\n              (sourceColorDomain || uniqBy(data, 'source', true)).findIndex(\r\n                (el) => `${el}` === `${d}`,\r\n              ) > sourceColors.length\r\n                ? sourceColors.length - 1\r\n                : (sourceColorDomain || uniqBy(data, 'source', true)).findIndex(\r\n                    (el) => `${el}` === `${d}`,\r\n                  )\r\n            ],\r\n      totalValue: sum(data.filter((el) => `${el.source}` === `${d}`).map((el) => el.value)),\r\n    }));\r\n    const sourceNodesSorted =\r\n      sortNodes === 'asc' || sortNodes === 'desc'\r\n        ? orderBy(sourceNodes, ['totalValue'], [sortNodes])\r\n        : sourceNodes;\r\n    const targetNodes = uniqBy(data, 'target', true).map((d) => ({\r\n      name: `target_${d}`,\r\n      type: 'target' as const,\r\n      label: `${d}`,\r\n      color:\r\n        typeof targetColors === 'string' || !targetColors\r\n          ? targetColors || Colors.graphMainColor\r\n          : targetColors[\r\n              (targetColorDomain || uniqBy(data, 'target', true)).findIndex(\r\n                (el) => `${el}` === `${d}`,\r\n              ) > targetColors.length\r\n                ? targetColors.length - 1\r\n                : (targetColorDomain || uniqBy(data, 'target', true)).findIndex(\r\n                    (el) => `${el}` === `${d}`,\r\n                  )\r\n            ],\r\n      totalValue: sum(data.filter((el) => `${el.target}` === `${d}`).map((el) => el.value)),\r\n    }));\r\n    const targetNodesSorted =\r\n      sortNodes === 'asc' || sortNodes === 'desc'\r\n        ? orderBy(targetNodes, ['totalValue'], [sortNodes])\r\n        : targetNodes;\r\n\r\n    const nodes = [...sourceNodesSorted, ...targetNodesSorted];\r\n    updateSankeyDataEvent({\r\n      nodes: nodes.map((d) => ({\r\n        ...d,\r\n        data: { node: d.label, value: d.totalValue, type: d.type },\r\n      })),\r\n      links: data.map((d) => ({\r\n        source: nodes.findIndex((el) => el.name === `source_${d.source}`),\r\n        target: nodes.findIndex((el) => el.name === `target_${d.target}`),\r\n        value: d.value,\r\n        data: { ...d },\r\n      })),\r\n    });\r\n  }, [data, sortNodes, sourceColorDomain, sourceColors, targetColorDomain, targetColors]);\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={fillContainer ? undefined : width}\r\n      height={height}\r\n      relativeHeight={relativeHeight}\r\n      padding={padding}\r\n    >\r\n      {graphTitle || graphDescription || graphDownload || 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={graphDownload ? graphParentDiv : 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        {data.length === 0 && <EmptyState />}\r\n        {svgWidth && svgHeight && sankeyData && data.length > 0 ? (\r\n          <Graph\r\n            data={sankeyData}\r\n            nodePadding={nodePadding}\r\n            nodeWidth={nodeWidth}\r\n            width={fillContainer || !width ? svgWidth : Math.min(svgWidth, width)}\r\n            height={svgHeight}\r\n            showLabels={showLabels}\r\n            leftMargin={leftMargin}\r\n            rightMargin={rightMargin}\r\n            topMargin={topMargin}\r\n            bottomMargin={bottomMargin}\r\n            truncateBy={truncateBy}\r\n            tooltip={tooltip}\r\n            onSeriesMouseOver={onSeriesMouseOver}\r\n            showValues={showValues}\r\n            onSeriesMouseClick={onSeriesMouseClick}\r\n            highlightedSourceDataPoints={highlightedSourceDataPoints?.map((d) => `${d}`)}\r\n            highlightedTargetDataPoints={highlightedTargetDataPoints?.map((d) => `${d}`)}\r\n            defaultLinkOpacity={defaultLinkOpacity}\r\n            sourceTitle={sourceTitle}\r\n            targetTitle={targetTitle}\r\n            sortNodes={sortNodes}\r\n            resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n            styles={styles}\r\n            classNames={classNames}\r\n            detailsOnClick={detailsOnClick}\r\n            animate={\r\n              animate === true\r\n                ? { duration: 0.5, once: true, amount: 0.5 }\r\n                : animate || { duration: 0, once: true, amount: 0 }\r\n            }\r\n            customLayers={customLayers}\r\n            locale={numberDisplayOptions?.locale || 'en'}\r\n            padZeros={numberDisplayOptions?.padZeros || 'none'}\r\n            suffix={numberDisplayOptions?.suffix || ''}\r\n            prefix={numberDisplayOptions?.prefix || ''}\r\n            precision={numberDisplayOptions?.precision ?? 2}\r\n            labelPosition={labelPosition}\r\n            labelWidth={labelWidth}\r\n            dimmedNodeOpacity={dimmedNodeOpacity ?? defaultLinkOpacity}\r\n            highlightedLinks={highlightedLinks}\r\n            minLabelHeight={minLabelHeight}\r\n            linkColor={linkColor}\r\n            theme={theme}\r\n          />\r\n        ) : null}\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,1,2,3,4,5,6,7,8,9,10,11],"mappings":"q5BAAA,SAAwB,GAAI,EAAQ,EAAS,CAC3C,IAAI,EACJ,GAAI,IAAY,IAAA,OACT,IAAM,KAAS,EACd,GAAS,OACL,EAAM,GAAU,IAAQ,IAAA,IAAa,GAAS,KACpD,EAAM,OAGL,CACL,IAAI,EAAQ,GACZ,IAAK,IAAI,KAAS,GACX,EAAQ,EAAQ,EAAO,EAAE,EAAO,CAAM,IAAM,OACzC,EAAM,GAAU,IAAQ,IAAA,IAAa,GAAS,KACpD,EAAM,EAGZ,CACA,OAAO,CACT,CCnBA,SAAwB,EAAI,EAAQ,EAAS,CAC3C,IAAI,EACJ,GAAI,IAAY,IAAA,OACT,IAAM,KAAS,EACd,GAAS,OACL,EAAM,GAAU,IAAQ,IAAA,IAAa,GAAS,KACpD,EAAM,OAGL,CACL,IAAI,EAAQ,GACZ,IAAK,IAAI,KAAS,GACX,EAAQ,EAAQ,EAAO,EAAE,EAAO,CAAM,IAAM,OACzC,EAAM,GAAU,IAAQ,IAAA,IAAa,GAAS,KACpD,EAAM,EAGZ,CACA,OAAO,CACT,CCnBA,SAAwBA,EAAI,EAAQ,EAAS,CAC3C,IAAI,EAAM,EACV,GAAI,IAAY,IAAA,OACT,IAAI,KAAS,GACZ,EAAQ,CAAC,KACX,GAAO,OAGN,CACL,IAAI,EAAQ,GACZ,IAAK,IAAI,KAAS,GACZ,EAAQ,CAAC,EAAQ,EAAO,EAAE,EAAO,CAAM,KACzC,GAAO,EAGb,CACA,OAAO,CACT,CCfA,SAAS,GAAY,EAAG,CACtB,OAAO,EAAE,OAAO,KAClB,CAUA,SAAgB,GAAQ,EAAM,EAAG,CAC/B,OAAO,EAAK,YAAY,OAAS,EAAK,MAAQ,EAAI,CACpD,CAEA,SAAgB,EAAO,EAAM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