@undp/data-viz 1.4.8 → 1.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/BarGraph.cjs +1 -1
  2. package/dist/BarGraph.cjs.map +1 -1
  3. package/dist/BarGraph.d.ts +4 -0
  4. package/dist/BarGraph.js +1960 -1904
  5. package/dist/BarGraph.js.map +1 -1
  6. package/dist/GraphEl-OzC-icbr.cjs +2 -0
  7. package/dist/GraphEl-OzC-icbr.cjs.map +1 -0
  8. package/dist/{GraphEl-DfPT8ffl.js → GraphEl-s3ctz7oA.js} +3 -1
  9. package/dist/GraphEl-s3ctz7oA.js.map +1 -0
  10. package/dist/GriddedGraphs.cjs +1 -1
  11. package/dist/GriddedGraphs.d.ts +7 -0
  12. package/dist/GriddedGraphs.js +1 -1
  13. package/dist/GriddedGraphsFromConfig.d.ts +7 -0
  14. package/dist/MultiGraphDashboard.d.ts +7 -0
  15. package/dist/MultiGraphDashboardFromConfig.d.ts +7 -0
  16. package/dist/PerformanceIntensiveMultiGraphDashboard.d.ts +7 -0
  17. package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.d.ts +7 -0
  18. package/dist/PerformanceIntensiveScrollStory.d.ts +7 -0
  19. package/dist/ScrollStory.d.ts +7 -0
  20. package/dist/SingleGraphDashboard.cjs +1 -1
  21. package/dist/SingleGraphDashboard.d.ts +7 -0
  22. package/dist/SingleGraphDashboard.js +1 -1
  23. package/dist/SingleGraphDashboardFromConfig.d.ts +7 -0
  24. package/dist/SingleGraphDashboardGeoHubMaps.d.ts +7 -0
  25. package/dist/SingleGraphDashboardGeoHubMapsFromConfig.d.ts +7 -0
  26. package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
  27. package/dist/SingleGraphDashboardThreeDGraphs.cjs.map +1 -1
  28. package/dist/SingleGraphDashboardThreeDGraphs.d.ts +7 -0
  29. package/dist/SingleGraphDashboardThreeDGraphs.js +17 -16
  30. package/dist/SingleGraphDashboardThreeDGraphs.js.map +1 -1
  31. package/dist/SingleGraphDashboardThreeDGraphsFromConfig.d.ts +7 -0
  32. package/dist/ThreeDGlobe.cjs +1 -1
  33. package/dist/ThreeDGlobe.cjs.map +1 -1
  34. package/dist/ThreeDGlobe.d.ts +8 -0
  35. package/dist/ThreeDGlobe.js +173 -172
  36. package/dist/ThreeDGlobe.js.map +1 -1
  37. package/dist/Types.d.ts +7 -0
  38. package/dist/index.d.ts +13 -0
  39. package/dist/style.css +1 -1
  40. package/package.json +2 -3
  41. package/dist/GraphEl-C0FNZlDn.cjs +0 -2
  42. package/dist/GraphEl-C0FNZlDn.cjs.map +0 -1
  43. package/dist/GraphEl-DfPT8ffl.js.map +0 -1
package/dist/BarGraph.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),Ie=require("./index-CZbIGs8q.cjs"),m=require("react"),Ke=require("./index-BzeLQvXk.cjs"),Ee=require("./parse-hMnG_lRV.cjs"),Re=require("./getSliderMarks-CtsEXiLV.cjs"),Te=require("./index-BXns0-ng.cjs"),Ae=require("./Modal-tXZlLE5s.cjs"),Me=require("./numberFormattingFunction-02t-wJta.cjs"),ze=require("./Tooltip-n8z5bfav.cjs"),Y=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ce=require("./Colors.cjs"),Ve=require("./string2HTML-D2Avudmb.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),et=require("./YAxesLabels-D8IydyZj.cjs"),Le=require("./AxisTitle-CK9YeovX.cjs"),Be=require("./Axis-DE7dSn1_.cjs"),Fe=require("./ReferenceLine-CFVBBN__.cjs"),Pe=require("./use-in-view-sQJZ_xDO.cjs"),He=require("./linear-BVckp9RD.cjs"),$e=require("./band-CAApY4Pd.cjs"),qe=require("./index-BW8iNx7E.cjs"),ge=require("./proxy-BHRoeZgd.cjs"),Ge=require("./GraphFooter.cjs"),Ue=require("./GraphHeader.cjs"),We=require("./ColorLegendWithMouseOver.cjs"),Xe=require("./EmptyState-d8_8SxeW.cjs"),De=require("./index-BW_-wD2k.cjs"),Ne=require("./ensureCompleteData-DqWQ2Zbi.cjs"),Ye=require("./init-DU0ybBc_.cjs"),ke=require("./index-C21TvELx.cjs"),Qe=require("./index-BczVvEBZ.cjs"),Je=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),tt=require("./XAxesLabels-OjBNl_lS.cjs"),it=require("./YTicksAndGridLines-DBDuz6vb.cjs");function at(fe){const{data:l,barColor:p,suffix:H,prefix:T,barPadding:q,showValues:me,showTicks:de,leftMargin:he,truncateBy:K,width:G,height:ie,colorDomain:M,rightMargin:le,topMargin:xe,bottomMargin:C,showLabels:U,tooltip:_,onSeriesMouseOver:Q,refValues:E,selectedColor:f,highlightedDataPoints:L,maxValue:ae,minValue:se,onSeriesMouseClick:J,labelOrder:Z,rtl:re,maxBarThickness:W,minBarThickness:pe,resetSelectionOnDoubleClick:ce,detailsOnClick:D,barAxisTitle:b,valueColor:g,noOfTicks:w,styles:I,classNames:R,animate:O,dimmedOpacity:A,precision:z,customLayers:v,naLabel:j}=fe,X=m.useRef(null),S=Pe.useInView(X,{once:O.once,amount:O.amount}),[$,oe]=m.useState(void 0),[P,B]=m.useState(void 0),[ee,N]=m.useState(void 0),[F,h]=m.useState(void 0),k={top:b?xe+25:xe,bottom:C,left:he,right:le},y=G-k.left-k.right,c=ie-k.top-k.bottom,d=l.map((a,x)=>({...a,id:Z?`${a.label}`:`${x}`})),o=He.linear().domain([se,ae]).range([0,y]).nice(),r=Z||d.map(a=>`${a.id}`),s=$e.band().domain(r).range([0,pe?Math.max(c,pe*r.length):W?Math.min(c,W*r.length):c]).paddingInner(q),t=o.ticks(w);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:X,width:`${G}px`,height:`${ie}px`,viewBox:`0 0 ${G} ${ie}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${k.left},${k.top})`,children:[de?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:t.filter(a=>a!==0),x:t.filter(a=>a!==0).map(a=>o(a)),y1:0-xe,y2:c+k.bottom,styles:{gridLines:I?.xAxis?.gridLines,labels:I?.xAxis?.labels},classNames:{gridLines:R?.xAxis?.gridLines,labels:R?.xAxis?.labels},suffix:H,prefix:T,labelType:"secondary",showGridLines:!0,precision:z}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:y/2,y:0-k.top+15,style:I?.xAxis?.title,className:R?.xAxis?.title,text:b}),v.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[d.map(a=>Y.checkIfNullOrUndefined(s(a.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:f?a.color&&p[M.indexOf(a.color)]===f?1:A:L.length!==0?L.indexOf(a.label)!==-1?.85:A:.85},whileInView:{opacity:f?a.color&&p[M.indexOf(a.color)]===f?1:A:L.length!==0?L.indexOf(a.label)!==-1?.85:A:.85,transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},onMouseEnter:x=>{oe(a),h(x.clientY),N(x.clientX),Q?.(a)},onClick:()=>{(J||D)&&(Te.isEqual(P,a)&&ce?(B(void 0),J?.(void 0)):(B(a),J?.(a)))},onMouseMove:x=>{oe(a),h(x.clientY),N(x.clientX)},onMouseLeave:()=>{oe(void 0),N(void 0),h(void 0),Q?.(void 0)},children:[a.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{variants:{initial:{width:0,x:o(0),y:s(`${a.id}`),fill:l.filter(x=>x.color).length===0?p[0]:a.color?p[M.indexOf(a.color)]:Ce.Colors.gray},whileInView:{width:a.size>=0?o(a.size)-o(0):o(0)-o(a.size),x:a.size>=0?o(0):o(a.size),y:s(`${a.id}`),fill:l.filter(x=>x.color).length===0?p[0]:a.color?p[M.indexOf(a.color)]:Ce.Colors.gray,transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{width:0,x:o(0),transition:{duration:O.duration}},height:s.bandwidth()}):null,U?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${a.label}`.length<K?`${a.label}`:`${`${a.label}`.substring(0,K)}...`,y:s(a.id)||0,x:(a.size||0)<0?o(0):0-k.left,width:(a.size||0)<0?G-o(0):o(0)+k.left,height:s.bandwidth(),alignment:a.size&&a.size<0?"left":"right",style:I?.yAxis?.labels,className:R?.yAxis?.labels,animate:O,isInView:S}):null,me?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:a.size&&a.size<0?"end":"start",...I?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!g&&p.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",R?.graphObjectValues),dx:a.size&&a.size<0?-5:5,dy:"0.33em",variants:{initial:{x:o(0),y:s(`${a.id}`)+s.bandwidth()/2,opacity:0,fill:g||(l.filter(x=>x.color).length===0?p[0]:a.color?p[M.indexOf(a.color)]:Ce.Colors.gray)},whileInView:{x:a.size?o(a.size):o(0),opacity:1,y:s(`${a.id}`)+s.bandwidth()/2,fill:g||(l.filter(x=>x.color).length===0?p[0]:a.color?p[M.indexOf(a.color)]:Ce.Colors.gray),transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},children:Me.numberFormattingFunction(a.size,j,z,T,H)}):null]},a.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:o(se<0?0:se),x2:o(se<0?0:se),y1:-2.5,y2:c+k.bottom,classNames:{axis:R?.yAxis?.axis},styles:{axis:I?.yAxis?.axis}}),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((a,x)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:a.text,color:a.color,x:o(a.value),y1:0-k.top,y2:c+k.bottom,textSide:o(a.value)>y*.75||re?"left":"right",classNames:a.classNames,styles:a.styles,animate:O,isInView:S},x))}):null]}),v.filter(a=>a.position==="after").map(a=>a.layer)]})}),$&&_&&ee&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:$,body:_,xPos:ee,yPos:F,backgroundStyle:I?.tooltip,className:R?.tooltip}):null,D&&P!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof D=="string"?{__html:Ve.string2HTML(D,P)}:void 0,children:typeof D=="function"?D(P):null})}):null]})}function st(fe){const{data:l,graphTitle:p,colors:H,suffix:T="",sources:q,prefix:me="",graphDescription:de,barPadding:he=.25,showValues:K=!0,showTicks:G=!0,leftMargin:ie=100,rightMargin:M=40,truncateBy:le=999,height:xe,width:C,footNote:U,colorDomain:_,colorLegendTitle:Q,highlightedDataPoints:E=[],padding:f,backgroundColor:L=!1,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:Z,tooltip:re,onSeriesMouseOver:W,refValues:pe,showColorScale:ce=!0,graphID:D,maxValue:b,minValue:g,onSeriesMouseClick:w,graphDownload:I=!1,dataDownload:R=!1,sortData:O,labelOrder:A,language:z="en",showNAColor:v=!0,minHeight:j=0,theme:X="light",maxBarThickness:S,maxNumberOfBars:$,minBarThickness:oe,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:ee,barAxisTitle:N,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:r=2,customLayers:s=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:a="NA"}=fe,[x,ve]=m.useState(0),[Oe,ue]=m.useState(0),[be,je]=m.useState(t.autoplay),ne=Re.sort(Ie.uniqBy(l.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>Ee.parse(`${i.date}`,t.dateFormat||"yyyy",new Date).getTime()),(i,ye)=>Ye.ascending(i,ye)),[we,u]=m.useState(t.autoplay?0:ne.length-1),[te,Se]=m.useState(void 0),n=m.useRef(null),V=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(ye=>{ve(C||ye[0].target.clientWidth||620),ue(xe||ye[0].target.clientHeight||480)});return n.current&&(ue(n.current.clientHeight||480),ve(n.current.clientWidth||620),C||i.observe(n.current)),()=>i.disconnect()},[C,xe]),m.useEffect(()=>{const i=setInterval(()=>{u(ye=>ye<ne.length-1?ye+1:0)},(t.speed||2)*1e3);return be||clearInterval(i),()=>clearInterval(i)},[ne,be,t.speed]);const _e=Re.getSliderMarks(ne,we,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:z==="he"||z==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${L?L===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${z||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...L&&L!==!0?{backgroundColor:L}:{}},id:D,ref:V,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a bar chart. ${de?` ${de}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:L?f||"1rem":f||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||de||I||R?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:y?.title,description:y?.description},graphTitle:p,graphDescription:de,width:C,graphDownload:I?V.current:void 0,dataDownload:R?l.map(i=>i.data).filter(i=>i!==void 0).length>0?l.map(i=>i.data).filter(i=>i!==void 0):l.filter(i=>i!==void 0):null}):null,t.enabled&&ne.length>0&&_e?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{je(!be)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":be?"Click to pause animation":"Click to play animation",children:be?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ne[0],max:ne[ne.length-1],marks:_e,step:null,defaultValue:ne[ne.length-1],value:ne[we],onChangeComplete:i=>{u(ne.indexOf(i))},onChange:i=>{u(ne.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[ce&&l.filter(i=>i.color).length!==0?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:C,colorLegendTitle:Q,colors:H||Ce.Colors[X].categoricalColors.colors,colorDomain:_||Ie.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:Se,showNAColor:v}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:n,"aria-label":"Graph area",children:(C||x)&&(xe||Oe)?e.jsxRuntimeExports.jsx(at,{data:O==="asc"?Ke.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(ne[we]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,ye)=>$?ye<$:!0):O==="desc"?Ke.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(ne[we]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,ye)=>$?ye<$:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(ne[we]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,ye)=>$?ye<$:!0),barColor:l.filter(i=>i.color).length===0?H?[H]:[Ce.Colors.primaryColors["blue-600"]]:H||Ce.Colors[X].categoricalColors.colors,colorDomain:l.filter(i=>i.color).length===0?[]:_||Ie.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:C||x,selectedColor:te,height:Math.max(j,xe||(Z?j?(C||x)*Z>j?(C||x)*Z:j:(C||x)*Z:Oe)),suffix:T,prefix:me,barPadding:he,showValues:K,showTicks:G,leftMargin:ie,rightMargin:M,topMargin:ae,bottomMargin:se,truncateBy:le,showLabels:J,tooltip:re,onSeriesMouseOver:W,refValues:pe,maxValue:Y.checkIfNullOrUndefined(b)?Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))<0?0:Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):b,minValue:Y.checkIfNullOrUndefined(g)?Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))>=0?0:Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):g,highlightedDataPoints:E,onSeriesMouseClick:w,labelOrder:A,rtl:z==="he"||z==="ar",maxBarThickness:S,minBarThickness:oe,resetSelectionOnDoubleClick:B,detailsOnClick:ee,barAxisTitle:N,noOfTicks:F,valueColor:h,classNames:y,styles:k,animate:d===!0?{duration:.5,once:!0,amount:.5}:d||{duration:0,once:!0,amount:0},dimmedOpacity:o,precision:r,customLayers:s,naLabel:a}):null})]})}),q||U?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{sources:q,footNote:U,width:C,styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source}}):null]})})})})}function rt(fe){const{data:l,barColors:p,barPadding:H,showTicks:T,leftMargin:q,truncateBy:me,width:de,height:he,suffix:K,prefix:G,showValues:ie,rightMargin:M,topMargin:le,bottomMargin:xe,showLabels:C,tooltip:U,onSeriesMouseOver:_,refValues:Q,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,rtl:se,labelOrder:J,maxBarThickness:Z,resetSelectionOnDoubleClick:re,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:D,styles:b,classNames:g,animate:w,colorDomain:I,precision:R,customLayers:O,naLabel:A}=fe,z=m.useRef(null),v=Pe.useInView(z,{once:w.once,amount:w.amount}),j={top:pe?le+25:le,bottom:xe,left:q,right:M},[X,S]=m.useState(void 0),[$,oe]=m.useState(void 0),[P,B]=m.useState(void 0),[ee,N]=m.useState(void 0),F=de-j.left-j.right,h=he-j.top-j.bottom,k=l.map((s,t)=>({...s,id:J?`${s.label}`:`${t}`})),y=J||k.map(s=>`${s.id}`),c=He.linear().domain([f,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,Z?Math.min(h,Z*y.length):h]).paddingInner(H),o=$e.band().domain(l[0].size.map((s,t)=>`${t}`)).range([0,d.bandwidth()]).paddingInner(.1),r=c.ticks(D);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:z,width:`${de}px`,height:`${he}px`,viewBox:`0 0 ${de} ${he}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[T?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:r.filter(s=>s!==0),x:r.filter(s=>s!==0).map(s=>c(s)),y1:0-le,y2:h+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:K,prefix:G,labelType:"secondary",showGridLines:!0,precision:R}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),O.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[k.map(s=>Y.checkIfNullOrUndefined(d(s.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{variants:{initial:{x:0,y:d(`${s.id}`)},whileInView:{x:0,y:d(`${s.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[s.size.map((t,a)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?p[a]===ae?1:.3:.85,onMouseEnter:x=>{S({...s,sizeIndex:a}),N(x.clientY),B(x.clientX),_?.({...s,sizeIndex:a})},onMouseMove:x=>{S({...s,sizeIndex:a}),N(x.clientY),B(x.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),N(void 0),_?.(void 0)},onClick:()=>{(L||W)&&(Te.isEqual($,{...s,sizeIndex:a})&&re?(oe(void 0),L?.(void 0)):(oe({...s,sizeIndex:a}),L&&L({...s,sizeIndex:a})))},children:[Y.checkIfNullOrUndefined(t)?null:e.jsxRuntimeExports.jsx(ge.motion.rect,{y:o(`${a}`),variants:{initial:{width:0,x:c(0),fill:p[a]},whileInView:{width:Y.checkIfNullOrUndefined(t)?0:t>=0?c(t)-c(0):c(0)-c(t),x:t>=0?c(0):c(t),fill:p[a],transition:{duration:w.duration}}},exit:{width:0,x:c(0),transition:{duration:w.duration}},height:o.bandwidth(),initial:"initial",animate:v?"whileInView":"initial"}),ie?e.jsxRuntimeExports.jsx(ge.motion.text,{y:o(`${a}`)+o.bandwidth()/2,style:{fill:ce||p[a],textAnchor:t&&t<0?"end":"start",...b?.graphObjectValues||{}},className:e.mo("graph-value text-sm",g?.graphObjectValues),dx:t&&t<0?-5:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(t||0),opacity:1,transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:Me.numberFormattingFunction(t,A,R,G,K)}):null]},`${s.label}-${I[a]||a}`)),C?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${s.label}`.length<me?`${s.label}`:`${`${s.label}`.substring(0,me)}...`,y:0,x:0-j.left,width:c(f<0?0:f)+j.left,height:d.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null]},s.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:c(f<0?0:f),x2:c(f<0?0:f),y1:-2.5,y2:h+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),Q?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Q.map((s,t)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:s.text,color:s.color,x:c(s.value),y1:0-j.top,y2:h+j.bottom,textSide:c(s.value)>F*.75||se?"left":"right",classNames:s.classNames,styles:s.styles,animate:w,isInView:v},t))}):null]}),O.filter(s=>s.position==="after").map(s=>s.layer)]})}),X&&U&&P&&ee?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:U,xPos:P,yPos:ee,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{oe(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,$)}:void 0,children:typeof W=="function"?W($):null})}):null]})}function nt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,truncateBy:he=999,height:K,width:G,footNote:ie,colorDomain:M,colorLegendTitle:le,suffix:xe="",prefix:C="",showValues:U=!0,showColorScale:_=!0,padding:Q,backgroundColor:E=!1,leftMargin:f=100,rightMargin:L=40,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:Z,tooltip:re,onSeriesMouseOver:W,refValues:pe,graphID:ce,maxValue:D,minValue:b,onSeriesMouseClick:g,graphDownload:w=!1,dataDownload:I=!1,language:R="en",labelOrder:O,minHeight:A=0,theme:z="light",maxBarThickness:v,ariaLabel:j,resetSelectionOnDoubleClick:X=!0,detailsOnClick:S,barAxisTitle:$,noOfTicks:oe=5,valueColor:P,styles:B,classNames:ee,filterNA:N=!0,animate:F=!1,precision:h=2,customLayers:k=[],timeline:y={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA"}=fe,[d,o]=m.useState(0),[r,s]=m.useState(0),[t,a]=m.useState(y.autoplay),x=Re.sort(Ie.uniqBy(l.filter(u=>u.date!==void 0&&u.date!==null),u=>u.date).map(u=>Ee.parse(`${u.date}`,y.dateFormat||"yyyy",new Date).getTime()),(u,te)=>Ye.ascending(u,te)),[ve,Oe]=m.useState(y.autoplay?0:x.length-1),[ue,be]=m.useState(void 0),je=m.useRef(null),ne=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(G||te[0].target.clientWidth||620),s(K||te[0].target.clientHeight||480)});return je.current&&(s(je.current.clientHeight||480),o(je.current.clientWidth||620),G||u.observe(je.current)),()=>u.disconnect()},[G,K]),m.useEffect(()=>{const u=setInterval(()=>{Oe(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const we=Re.getSliderMarks(x,ve,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${z||"light"} flex ${G?"w-fit grow-0":"w-full grow"}`,dir:R==="he"||R==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${E?E===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${R||"en"}`,ee?.graphContainer),style:{...B?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:ce,ref:ne,"aria-label":j||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?Q||"1rem":Q||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||q||w||I?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:B?.title,description:B?.description},classNames:{title:ee?.title,description:ee?.description},graphTitle:p,graphDescription:q,width:G,graphDownload:w?ne.current:void 0,dataDownload:I?l.map(u=>u.data).filter(u=>u!==void 0).length>0?l.map(u=>u.data).filter(u=>u!==void 0):l.filter(u=>u!==void 0):null}):null,y.enabled&&x.length>0&&we?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{a(!t)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":t?"Click to pause animation":"Click to play animation",children:t?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:we,step:null,defaultValue:x[x.length-1],value:x[ve],onChangeComplete:u=>{Oe(x.indexOf(u))},onChange:u=>{Oe(x.indexOf(u))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:G,colorDomain:M,colors:H,colorLegendTitle:le,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:je,"aria-label":"Graph area",children:(G||d)&&(K||r)?e.jsxRuntimeExports.jsx(rt,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[ve]),y.dateFormat||"yyyy"):u).filter(u=>N?!u.size.every(te=>te==null):u),barColors:H,width:G||d,height:Math.max(A,K||(Z?A?(G||d)*Z>A?(G||d)*Z:A:(G||d)*Z:r)),suffix:xe,prefix:C,showValues:U,barPadding:me,showTicks:de,leftMargin:f,rightMargin:L,topMargin:ae,bottomMargin:se,truncateBy:he,showLabels:J,tooltip:re,onSeriesMouseOver:W,refValues:pe,maxValue:Y.checkIfNullOrUndefined(D)?Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))<0?0:Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):D,minValue:Y.checkIfNullOrUndefined(b)?Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))>=0?0:Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):b,onSeriesMouseClick:g,selectedColor:ue,labelOrder:O,rtl:R==="he"||R==="ar",maxBarThickness:v,resetSelectionOnDoubleClick:X,detailsOnClick:S,barAxisTitle:$,noOfTicks:oe,valueColor:P,styles:B,classNames:ee,colorDomain:M,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},precision:h,customLayers:k,naLabel:c}):null})]})}),T||ie?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:B?.footnote,source:B?.source},classNames:{footnote:ee?.footnote,source:ee?.source},sources:T,footNote:ie,width:G}):null]})})})})}function lt(fe){const{data:l,barColors:p,barPadding:H,showTicks:T,leftMargin:q,rightMargin:me,truncateBy:de,width:he,height:K,topMargin:G,bottomMargin:ie,tooltip:M,onSeriesMouseOver:le,showLabels:xe,suffix:C,prefix:U,showValues:_,refValues:Q,maxValue:E,onSeriesMouseClick:f,selectedColor:L,rtl:ae,labelOrder:se,maxBarThickness:J,minBarThickness:Z,resetSelectionOnDoubleClick:re,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:D,styles:b,classNames:g,animate:w,colorDomain:I,precision:R,customLayers:O,naLabel:A}=fe,z=m.useRef(null),v=Pe.useInView(z,{once:w.once,amount:w.amount}),j={top:pe?G+25:G,bottom:ie,left:q,right:me},[X,S]=m.useState(void 0),[$,oe]=m.useState(void 0),[P,B]=m.useState(void 0),[ee,N]=m.useState(void 0),F=he-j.left-j.right,h=K-j.top-j.bottom,k=l.map((r,s)=>({...r,id:se?`${r.label}`:`${s}`})),y=se||k.map(r=>`${r.id}`),c=He.linear().domain([0,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,Z?Math.max(h,Z*y.length):J?Math.min(h,J*y.length):h]).paddingInner(H),o=c.ticks(D);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:z,width:`${he}px`,height:`${K}px`,viewBox:`0 0 ${he} ${K}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[T?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:o.filter(r=>r!==0),x:o.filter(r=>r!==0).map(r=>c(r)),y1:0-G,y2:h+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:C,prefix:U,labelType:"secondary",showGridLines:!0,precision:R}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),O.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[k.map(r=>Y.checkIfNullOrUndefined(d(r.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:0,y:d(`${r.id}`)},whileInView:{x:0,y:d(`${r.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[r.size.map((s,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?p[t]===L?1:.3:1,onMouseEnter:a=>{S({...r,sizeIndex:t}),N(a.clientY),B(a.clientX),le?.({...r,sizeIndex:t})},onMouseMove:a=>{S({...r,sizeIndex:t}),N(a.clientY),B(a.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),N(void 0),le?.(void 0)},onClick:()=>{(f||W)&&(Te.isEqual($,{...r,sizeIndex:t})&&re?(oe(void 0),f?.(void 0)):(oe({...r,sizeIndex:t}),f&&f({...r,sizeIndex:t})))},children:[s?e.jsxRuntimeExports.jsx(ge.motion.rect,{y:0,style:{fill:p[t]},height:d.bandwidth(),exit:{width:0,x:c(0),transition:{duration:w.duration}},variants:{initial:{width:0,x:c(0),fill:p[t]},whileInView:{width:c(s||0),x:c(t===0?0:ke.sum(r.size.filter((a,x)=>x<t&&a))),fill:p[t],transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial"},t):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{y:d.bandwidth()/2,style:{textAnchor:"middle",...b?.graphObjectValues||{}},dy:"0.33em",className:e.mo("graph-value text-sm",g?.graphObjectValues),exit:{opacity:0,transition:{duration:w.duration}},variants:{initial:{x:c(0),opacity:0,fill:Je.getTextColorBasedOnBgColor(p[t])},whileInView:{x:c(t===0?0:ke.sum(r.size.filter((a,x)=>x<t&&a)))+c(s||0)/2,opacity:s&&c(s)/Me.numberFormattingFunction(s,A,R,U,C).length>12?1:0,fill:Je.getTextColorBasedOnBgColor(p[t]),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(s,A,R,U,C)}):null]},`${r.label}-${I[t]||t}`)),xe?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${r.label}`.length<de?`${r.label}`:`${`${r.label}`.substring(0,de)}...`,y:0,x:0-j.left,width:0+j.left,height:d.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{className:e.mo("graph-value graph-value-total text-sm",ce?"":" fill-primary-gray-700 dark:fill-primary-gray-300",g?.graphObjectValues),style:{...ce?{fill:ce}:{},textAnchor:"start",...b?.graphObjectValues||{}},y:d.bandwidth()/2,dx:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(ke.sum(r.size.map(s=>s||0))),opacity:1,transition:{duration:w.duration}}},exit:{opacity:0,transition:{duration:w.duration}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(r.size.filter(s=>s)),A,R,U,C)}):null]},r.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:c(0),x2:c(0),y1:-2.5,y2:h+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),Q?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Q.map((r,s)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:r.text,color:r.color,x:c(r.value),y1:0-j.top,y2:h+j.bottom,textSide:c(r.value)>F*.75||ae?"left":"right",classNames:r.classNames,styles:r.styles,animate:w,isInView:v},s))}):null]}),O.filter(r=>r.position==="after").map(r=>r.layer)]})}),X&&M&&P&&ee?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:M,xPos:P,yPos:ee,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{oe(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,$)}:void 0,children:typeof W=="function"?W($):null})}):null]})}function ot(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,leftMargin:he=100,rightMargin:K=40,truncateBy:G=999,height:ie,width:M,footNote:le,colorDomain:xe,colorLegendTitle:C,padding:U,backgroundColor:_=!1,topMargin:Q=25,bottomMargin:E=10,tooltip:f,onSeriesMouseOver:L,suffix:ae="",prefix:se="",showLabels:J=!0,relativeHeight:Z,showValues:re=!0,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:D,graphDownload:b=!1,dataDownload:g=!1,language:w="en",labelOrder:I,minHeight:R=0,theme:O="light",maxBarThickness:A,sortParameter:z,maxNumberOfBars:v,minBarThickness:j,showColorScale:X=!0,ariaLabel:S,resetSelectionOnDoubleClick:$=!0,detailsOnClick:oe,barAxisTitle:P,noOfTicks:B=5,valueColor:ee,styles:N,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA",sortData:r}=fe,[s,t]=m.useState(0),[a,x]=m.useState(0),[ve,Oe]=m.useState(d.autoplay),ue=Re.sort(Ie.uniqBy(l.filter(n=>n.date!==void 0&&n.date!==null),n=>n.date).map(n=>Ee.parse(`${n.date}`,d.dateFormat||"yyyy",new Date).getTime()),(n,V)=>Ye.ascending(n,V)),[be,je]=m.useState(d.autoplay?0:ue.length-1),[ne,we]=m.useState(void 0),u=m.useRef(null),te=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(V=>{t(M||V[0].target.clientWidth||620),x(ie||V[0].target.clientHeight||480)});return u.current&&(x(u.current.clientHeight||480),t(u.current.clientWidth||620),M||n.observe(u.current)),()=>n.disconnect()},[M,ie]),m.useEffect(()=>{const n=setInterval(()=>{je(V=>V<ue.length-1?V+1:0)},(d.speed||2)*1e3);return ve||clearInterval(n),()=>clearInterval(n)},[ue,ve,d.speed]);const Se=Re.getSliderMarks(ue,be,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${O||"light"} flex ${M?"w-fit grow-0":"w-full grow"}`,dir:w==="he"||w==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${_?_===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${w||"en"}`,F?.graphContainer),style:{...N?.graphContainer||{},..._&&_!==!0?{backgroundColor:_}:{}},id:pe,ref:te,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:_?U||"1rem":U||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||q||b||g?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:N?.title,description:N?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:q,width:M,graphDownload:b?te.current:void 0,dataDownload:g?l.map(n=>n.data).filter(n=>n!==void 0).length>0?l.map(n=>n.data).filter(n=>n!==void 0):l.filter(n=>n!==void 0):null}):null,d.enabled&&ue.length>0&&Se?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!ve)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ve?"Click to pause animation":"Click to play animation",children:ve?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ue[0],max:ue[ue.length-1],marks:Se,step:null,defaultValue:ue[ue.length-1],value:ue[be],onChangeComplete:n=>{je(ue.indexOf(n))},onChange:n=>{je(ue.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[X?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:M,colorDomain:xe,colors:H,colorLegendTitle:C,setSelectedColor:we,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:u,"aria-label":"Graph area",children:(M||s)&&(ie||a)?e.jsxRuntimeExports.jsx(lt,{data:z!==void 0?z==="total"?Qe.orderBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(ue[be]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(V=>V==null):n),n=>ke.sum(n.size.filter(V=>!Y.checkIfNullOrUndefined(V))),[r||"asc"]).filter((n,V)=>v?V<v:!0):Qe.orderBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(ue[be]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(V=>V==null):n),n=>Y.checkIfNullOrUndefined(n.size[z])?-1/0:n.size[z],[r||"asc"]).filter((n,V)=>v?V<v:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(ue[be]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(V=>V==null):n).filter((n,V)=>v?V<v:!0),barColors:H,width:M||s,height:Math.max(R,ie||(Z?R?(M||s)*Z>R?(M||s)*Z:R:(M||s)*Z:a)),barPadding:me,showTicks:de,leftMargin:he,rightMargin:K,topMargin:Q,bottomMargin:E,truncateBy:G,showLabels:J,tooltip:f,onSeriesMouseOver:L,showValues:re,suffix:ae,prefix:se,refValues:W,maxValue:Y.checkIfNullOrUndefined(ce)?Math.max(...l.map(n=>ke.sum(n.size.filter(V=>!Y.checkIfNullOrUndefined(V)))||0)):ce,onSeriesMouseClick:D,selectedColor:ne,rtl:w==="he"||w==="ar",labelOrder:I,maxBarThickness:A,minBarThickness:j,resetSelectionOnDoubleClick:$,detailsOnClick:oe,barAxisTitle:P,noOfTicks:B,valueColor:ee,classNames:F,styles:N,animate:k===!0?{duration:.5,once:!0,amount:.5}:k||{duration:0,once:!0,amount:0},colorDomain:xe,precision:y,customLayers:c,naLabel:o}):null})]})}),T||le?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:N?.footnote,source:N?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:T,footNote:le,width:M}):null]})})})})}function ut(fe){const{data:l,width:p,height:H,barColor:T,suffix:q,prefix:me,barPadding:de,showLabels:he,showValues:K,showTicks:G,colorDomain:ie,truncateBy:M,rightMargin:le,topMargin:xe,bottomMargin:C,leftMargin:U,tooltip:_,onSeriesMouseOver:Q,refValues:E,selectedColor:f,maxValue:L,minValue:ae,highlightedDataPoints:se,onSeriesMouseClick:J,labelOrder:Z,maxBarThickness:re,minBarThickness:W,resetSelectionOnDoubleClick:pe,detailsOnClick:ce,barAxisTitle:D,valueColor:b,noOfTicks:g,styles:w,classNames:I,dimmedOpacity:R,animate:O,precision:A,customLayers:z,naLabel:v}=fe,j=m.useRef(null),X=Pe.useInView(j,{once:O.once,amount:O.amount}),S={top:xe,bottom:C,left:D?U+30:U,right:le},[$,oe]=m.useState(void 0),[P,B]=m.useState(void 0),[ee,N]=m.useState(void 0),[F,h]=m.useState(void 0),k=p-S.left-S.right,y=H-S.top-S.bottom,c=He.linear().domain([ae,L]).range([y,0]).nice(),d=l.map((t,a)=>({...t,id:Z?`${t.label}`:`${a}`})),o=Z||d.map(t=>`${t.id}`),r=$e.band().domain(o).range([0,W?Math.max(k,W*o.length):re?Math.min(k,re*o.length):k]).paddingInner(de),s=c.ticks(g);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:j,width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${S.left},${S.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:c(ae<0?0:ae),y2:c(ae<0?0:ae),x1:0-U,x2:k+S.right,label:Me.numberFormattingFunction(ae<0?0:ae,v,A,me,q),labelPos:{x:0-U,dx:0,dy:L<0?"1em":-5,y:c(ae<0?0:ae)},classNames:{axis:I?.xAxis?.axis,label:I?.yAxis?.labels},styles:{axis:w?.xAxis?.axis,label:w?.yAxis?.labels}}),G?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:s.filter(t=>t!==0),y:s.filter(t=>t!==0).map(t=>c(t)),x1:0-U,x2:k+S.right,styles:{gridLines:w?.yAxis?.gridLines,labels:w?.yAxis?.labels},classNames:{gridLines:I?.yAxis?.gridLines,labels:I?.yAxis?.labels},suffix:q,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:A}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-U-15,y:y/2,style:w?.yAxis?.title,className:I?.yAxis?.title,text:D,rotate90:!0}),z.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[d.map((t,a)=>Y.checkIfNullOrUndefined(r(t.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",initial:"initial",animate:X?"whileInView":"initial",variants:{initial:{opacity:f?t.color&&T[ie.indexOf(t.color)]===f?1:R:se.length!==0?se.indexOf(t.label)!==-1?.85:R:.85},whileInView:{opacity:f?t.color&&T[ie.indexOf(t.color)]===f?1:R:se.length!==0?se.indexOf(t.label)!==-1?.85:R:.85,transition:{duration:O.duration}}},exit:{opacity:0,transition:{duration:O.duration}},onMouseEnter:x=>{oe(t),h(x.clientY),N(x.clientX),Q?.(t)},onClick:()=>{(J||ce)&&(Te.isEqual(P,t)&&pe?(B(void 0),J?.(void 0)):(B(t),J?.(t)))},onMouseMove:x=>{oe(t),h(x.clientY),N(x.clientX)},onMouseLeave:()=>{oe(void 0),N(void 0),h(void 0),Q?.(void 0)},children:[t.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{width:r.bandwidth(),initial:"initial",animate:X?"whileInView":"initial",variants:{initial:{height:0,x:r(`${t.id}`),y:c(0),fill:l.filter(x=>x.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ce.Colors.gray},whileInView:{height:t.size?Math.abs(c(t.size)-c(0)):0,y:t.size&&t.size>0?c(t.size):c(0),x:r(`${t.id}`),fill:l.filter(x=>x.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ce.Colors.gray,transition:{duration:O.duration}}},exit:{height:0,y:c(0),transition:{duration:O.duration}}}):null,he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${t.label}`.length<M?`${t.label}`:`${`${t.label}`.substring(0,M)}...`,y:(t.size||0)<0?0:c(0)+5,x:r(`${t.id}`),width:r.bandwidth(),height:(t.size||0)<0?c(0)-5:S.bottom,style:w?.xAxis?.labels,className:I?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:O,isInView:X}):null,K?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:"middle",...w?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!b&&T.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",I?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",variants:{initial:{x:r(`${t.id}`)+r.bandwidth()/2,y:c(0),opacity:0,fill:b||(l.filter(x=>x.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ce.Colors.gray)},whileInView:{x:r(`${t.id}`)+r.bandwidth()/2,y:c(t.size||0),fill:b||(l.filter(x=>x.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ce.Colors.gray),opacity:1,transition:{duration:O.duration}}},initial:"initial",animate:X?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},children:Me.numberFormattingFunction(t.size,v,A,me,q)}):null]},t.label)),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((t,a)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:t.text,color:t.color,y:c(t.value),x1:0-U,x2:k+S.right,classNames:t.classNames,styles:t.styles,animate:O,isInView:X},a))}):null]}),z.filter(t=>t.position==="after").map(t=>t.layer)]})}),$&&_&&ee&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:$,body:_,xPos:ee,yPos:F,backgroundStyle:w?.tooltip,className:I?.tooltip}):null,ce&&P!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ce=="string"?{__html:Ve.string2HTML(ce,P)}:void 0,children:typeof ce=="function"?ce(P):null})}):null]})}function ct(fe){const{data:l,graphTitle:p,colors:H,barPadding:T=.25,showTicks:q=!0,leftMargin:me=20,rightMargin:de=20,topMargin:he=20,bottomMargin:K=25,truncateBy:G=999,showLabels:ie=!0,showValues:M=!0,backgroundColor:le=!1,suffix:xe="",prefix:C="",sources:U,graphDescription:_,height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,showColorScale:pe=!0,graphID:ce,maxValue:D,minValue:b,highlightedDataPoints:g=[],onSeriesMouseClick:w,graphDownload:I=!1,dataDownload:R=!1,language:O="en",theme:A="light",sortData:z,labelOrder:v,showNAColor:j=!0,minHeight:X=0,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:oe,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:ee,barAxisTitle:N,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:r=2,customLayers:s=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:a="NA"}=fe,[x,ve]=m.useState(0),[Oe,ue]=m.useState(0),[be,je]=m.useState(t.autoplay),ne=Re.sort(Ie.uniqBy(l.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>Ee.parse(`${i.date}`,t.dateFormat||"yyyy",new Date).getTime()),(i,ye)=>Ye.ascending(i,ye)),[we,u]=m.useState(t.autoplay?0:ne.length-1),[te,Se]=m.useState(void 0),n=m.useRef(null),V=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(ye=>{ve(E||ye[0].target.clientWidth||620),ue(Q||ye[0].target.clientHeight||480)});return n.current&&(ue(n.current.clientHeight||480),ve(n.current.clientWidth||620),E||i.observe(n.current)),()=>i.disconnect()},[E,Q]),m.useEffect(()=>{const i=setInterval(()=>{u(ye=>ye<ne.length-1?ye+1:0)},(t.speed||2)*1e3);return be||clearInterval(i),()=>clearInterval(i)},[ne,be,t.speed]);const _e=Re.getSliderMarks(ne,we,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${A||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:O==="he"||O==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${le?le===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${O||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...le&&le!==!0?{backgroundColor:le}:{}},id:ce,ref:V,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${_?` ${_}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:le?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||_||I||R?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:y?.title,description:y?.description},graphTitle:p,graphDescription:_,width:E,graphDownload:I?V.current:void 0,dataDownload:R?l.map(i=>i.data).filter(i=>i!==void 0).length>0?l.map(i=>i.data).filter(i=>i!==void 0):l.filter(i=>i!==void 0):null}):null,t.enabled&&ne.length>0&&_e?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{je(!be)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":be?"Click to pause animation":"Click to play animation",children:be?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ne[0],max:ne[ne.length-1],marks:_e,step:null,defaultValue:ne[ne.length-1],value:ne[we],onChangeComplete:i=>{u(ne.indexOf(i))},onChange:i=>{u(ne.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[pe&&l.filter(i=>i.color).length!==0?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:E,colorLegendTitle:ae,colors:H||Ce.Colors[A].categoricalColors.colors,colorDomain:L||Ie.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:Se,showNAColor:j}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:n,"aria-label":"Graph area",children:(E||x)&&(Q||Oe)?e.jsxRuntimeExports.jsx(ut,{data:z==="asc"?Ke.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(ne[we]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,ye)=>$?ye<$:!0):z==="desc"?Ke.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(ne[we]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,ye)=>$?ye<$:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(ne[we]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,ye)=>$?ye<$:!0),barColor:l.filter(i=>i.color).length===0?H?[H]:[Ce.Colors.primaryColors["blue-600"]]:H||Ce.Colors[A].categoricalColors.colors,colorDomain:l.filter(i=>i.color).length===0?[]:L||Ie.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:E||x,refValues:W,height:Math.max(X,Q||(J?X?(E||x)*J>X?(E||x)*J:X:(E||x)*J:Oe)),suffix:xe,prefix:C,barPadding:T,showLabels:ie,showValues:M,showTicks:q,truncateBy:G,leftMargin:me,rightMargin:de,selectedColor:te,topMargin:he,bottomMargin:K,tooltip:Z,onSeriesMouseOver:re,maxValue:Y.checkIfNullOrUndefined(D)?Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))<0?0:Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):D,minValue:Y.checkIfNullOrUndefined(b)?Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))>=0?0:Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):b,highlightedDataPoints:g,onSeriesMouseClick:w,labelOrder:v,maxBarThickness:S,minBarThickness:oe,resetSelectionOnDoubleClick:B,detailsOnClick:ee,barAxisTitle:N,noOfTicks:F,valueColor:h,styles:k,classNames:y,animate:d===!0?{duration:.5,once:!0,amount:.5}:d||{duration:0,once:!0,amount:0},dimmedOpacity:o,precision:r,customLayers:s,naLabel:a}):null})]})}),U||f?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source},sources:U,footNote:f,width:E}):null]})})})})}function xt(fe){const{data:l,width:p,height:H,barColors:T,suffix:q,prefix:me,barPadding:de,showLabels:he,showValues:K,showTicks:G,truncateBy:ie,leftMargin:M,rightMargin:le,topMargin:xe,bottomMargin:C,tooltip:U,onSeriesMouseOver:_,refValues:Q,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,labelOrder:se,maxBarThickness:J,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:D,classNames:b,animate:g,colorDomain:w,precision:I,customLayers:R,naLabel:O}=fe,A=m.useRef(null),z=Pe.useInView(A,{once:g.once,amount:g.amount}),v={top:xe,bottom:C,left:W?M+30:M,right:le},[j,X]=m.useState(void 0),[S,$]=m.useState(void 0),[oe,P]=m.useState(void 0),[B,ee]=m.useState(void 0),N=p-v.left-v.right,F=H-v.top-v.bottom,h=He.linear().domain([f,E]).range([F,0]).nice(),k=l.map((r,s)=>({...r,id:se?`${r.label}`:`${s}`})),y=se||k.map(r=>`${r.id}`),c=$e.band().domain(y).range([0,J?Math.min(N,J*y.length):N]).paddingInner(de),d=$e.band().domain(l[0].size.map((r,s)=>`${s}`)).range([0,c.bandwidth()]).paddingInner(.1),o=h.ticks(ce);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",ref:A,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:h(f<0?0:f),y2:h(f<0?0:f),x1:0-M,x2:N+v.right,label:Me.numberFormattingFunction(f<0?0:f,O,I,me,q),labelPos:{x:0-M,dx:0,dy:E<0?"1em":-5,y:h(f<0?0:f)},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels}}),G?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:o.filter(r=>r!==0),y:o.filter(r=>r!==0).map(r=>h(r)),x1:0-M,x2:N+v.right,styles:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:q,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:I}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-M-15,y:F/2,style:D?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),R.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[k.map(r=>Y.checkIfNullOrUndefined(c(r.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{variants:{initial:{x:c(`${r.id}`),y:0},whileInView:{x:c(`${r.id}`),y:0,transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[r.size.map((s,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?T[t]===ae?1:.3:.85,onMouseEnter:a=>{X({...r,sizeIndex:t}),ee(a.clientY),P(a.clientX),_?.({...r,sizeIndex:t})},onMouseMove:a=>{X({...r,sizeIndex:t}),ee(a.clientY),P(a.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),ee(void 0),_?.(void 0)},onClick:()=>{(L||re)&&(Te.isEqual(S,{...r,sizeIndex:t})&&Z?($(void 0),L?.(void 0)):($({...r,sizeIndex:t}),L&&L({...r,sizeIndex:t})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:d(`${t}`),width:d.bandwidth(),variants:{initial:{height:0,y:h(0),fill:T[t]},whileInView:{height:Y.checkIfNullOrUndefined(s)?0:Math.abs(h(s)-h(0)),y:Y.checkIfNullOrUndefined(s)?h(0):s>0?h(s):h(0),fill:T[t],transition:{duration:g.duration}}},exit:{height:0,y:h(0),transition:{duration:g.duration}},initial:"initial",animate:z?"whileInView":"initial"}),K?e.jsxRuntimeExports.jsx(ge.motion.text,{x:d(`${t}`)+d.bandwidth()/2,style:{fill:pe||T[t],textAnchor:"middle",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:s?s>=0?"-5px":"1em":"-5px",variants:{initial:{y:h(0),opacity:0},whileInView:{y:h(s||0),opacity:1,transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(s,O,I,me,q)}):null]},`${r.label}-${w[t]||t}`)),he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${r.label}`.length<ie?`${r.label}`:`${`${r.label}`.substring(0,ie)}...`,y:h(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:D?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:z}):null]},r.label)),Q?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Q.map((r,s)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:r.text,color:r.color,y:h(r.value),x1:0-M,x2:N+v.right,classNames:r.classNames,styles:r.styles,animate:g,isInView:z},s))}):null]}),R.filter(r=>r.position==="after").map(r=>r.layer)]})}),j&&U&&oe&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:U,xPos:oe,yPos:B,backgroundStyle:D?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:S!==void 0,onClose:()=>{$(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Ve.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function dt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:K=20,topMargin:G=20,bottomMargin:ie=25,truncateBy:M=999,showLabels:le=!0,showValues:xe=!0,backgroundColor:C=!1,suffix:U="",prefix:_="",height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,graphID:pe,maxValue:ce,minValue:D,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:I="en",theme:R="light",labelOrder:O,minHeight:A=0,maxBarThickness:z,ariaLabel:v,resetSelectionOnDoubleClick:j=!0,detailsOnClick:X,barAxisTitle:S,noOfTicks:$=5,valueColor:oe,styles:P,classNames:B,filterNA:ee=!0,showColorScale:N=!0,animate:F=!1,precision:h=2,customLayers:k=[],timeline:y={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA"}=fe,[d,o]=m.useState(0),[r,s]=m.useState(0),[t,a]=m.useState(y.autoplay),x=Re.sort(Ie.uniqBy(l.filter(u=>u.date!==void 0&&u.date!==null),u=>u.date).map(u=>Ee.parse(`${u.date}`,y.dateFormat||"yyyy",new Date).getTime()),(u,te)=>Ye.ascending(u,te)),[ve,Oe]=m.useState(y.autoplay?0:x.length-1),[ue,be]=m.useState(void 0),je=m.useRef(null),ne=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(E||te[0].target.clientWidth||620),s(Q||te[0].target.clientHeight||480)});return je.current&&(s(je.current.clientHeight||480),o(je.current.clientWidth||620),E||u.observe(je.current)),()=>u.disconnect()},[E,Q]),m.useEffect(()=>{const u=setInterval(()=>{Oe(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const we=Re.getSliderMarks(x,ve,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${R||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:I==="he"||I==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${I||"en"}`,B?.graphContainer),style:{...P?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:pe,ref:ne,"aria-label":v||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||q||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:P?.title,description:P?.description},classNames:{title:B?.title,description:B?.description},graphTitle:p,graphDescription:q,width:E,graphDownload:g?ne.current:void 0,dataDownload:w?l.map(u=>u.data).filter(u=>u!==void 0).length>0?l.map(u=>u.data).filter(u=>u!==void 0):l.filter(u=>u!==void 0):null}):null,y.enabled&&x.length>0&&we?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{a(!t)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":t?"Click to pause animation":"Click to play animation",children:t?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:we,step:null,defaultValue:x[x.length-1],value:x[ve],onChangeComplete:u=>{Oe(x.indexOf(u))},onChange:u=>{Oe(x.indexOf(u))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[N?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:E,colorDomain:L,colors:H,colorLegendTitle:ae,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:je,"aria-label":"Graph area",children:(E||d)&&(Q||r)?e.jsxRuntimeExports.jsx(xt,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[ve]),y.dateFormat||"yyyy"):u).filter(u=>ee?!u.size.every(te=>te==null):u),barColors:H,width:E||d,height:Math.max(A,Q||(J?A?(E||d)*J>A?(E||d)*J:A:(E||d)*J:r)),suffix:U,prefix:_,barPadding:me,showLabels:le,showValues:xe,showTicks:de,truncateBy:M,leftMargin:he,rightMargin:K,topMargin:G,bottomMargin:ie,tooltip:Z,onSeriesMouseOver:re,refValues:W,maxValue:Y.checkIfNullOrUndefined(ce)?Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))<0?0:Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):ce,minValue:Y.checkIfNullOrUndefined(D)?Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))>=0?0:Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):D,onSeriesMouseClick:b,selectedColor:ue,labelOrder:O,maxBarThickness:z,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:S,noOfTicks:$,valueColor:oe,styles:P,classNames:B,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},colorDomain:L,precision:h,customLayers:k,naLabel:c}):null})]})}),T||f?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:P?.footnote,source:P?.source},classNames:{footnote:B?.footnote,source:B?.source},sources:T,footNote:f,width:E}):null]})})})})}function mt(fe){const{data:l,width:p,height:H,barColors:T,barPadding:q,showLabels:me,showTicks:de,truncateBy:he,leftMargin:K,topMargin:G,bottomMargin:ie,rightMargin:M,tooltip:le,onSeriesMouseOver:xe,suffix:C,prefix:U,showValues:_,refValues:Q,maxValue:E,onSeriesMouseClick:f,selectedColor:L,labelOrder:ae,maxBarThickness:se,minBarThickness:J,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:D,classNames:b,animate:g,colorDomain:w,precision:I,customLayers:R,naLabel:O}=fe,A=m.useRef(null),z=Pe.useInView(A,{once:g.once,amount:g.amount}),v={top:G,bottom:ie,left:W?K+30:K,right:M},[j,X]=m.useState(void 0),[S,$]=m.useState(void 0),[oe,P]=m.useState(void 0),[B,ee]=m.useState(void 0),N=p-v.left-v.right,F=H-v.top-v.bottom,h=He.linear().domain([0,E]).range([F,0]).nice(),k=l.map((o,r)=>({...o,id:ae?`${o.label}`:`${r}`})),y=ae||k.map(o=>`${o.id}`),c=$e.band().domain(y).range([0,J?Math.max(N,J*y.length):se?Math.min(N,se*y.length):N]).paddingInner(q),d=h.ticks(ce);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",ref:A,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:h(0),y2:h(0),x1:0-K,x2:N+v.right,label:Me.numberFormattingFunction(0,O,I,U,C),labelPos:{x:0-K,y:h(0),dx:0,dy:-5},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels}}),de?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:d.filter(o=>o!==0),y:d.filter(o=>o!==0).map(o=>h(o)),x1:0-K,x2:N+v.right,styles:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:C,prefix:U,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:I}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-K-15,y:F/2,style:D?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),R.filter(o=>o.position==="before").map(o=>o.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[k.map(o=>Y.checkIfNullOrUndefined(c(o.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:c(`${o.id}`),y:0},whileInView:{x:c(`${o.id}`),y:0,transition:{duration:g.duration}}},transition:{duration:g.duration},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[o.size.map((r,s)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?T[s]===L?1:.3:1,onMouseEnter:t=>{X({...o,sizeIndex:s}),ee(t.clientY),P(t.clientX),xe?.({...o,sizeIndex:s})},onMouseMove:t=>{X({...o,sizeIndex:s}),ee(t.clientY),P(t.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),ee(void 0),xe?.(void 0)},onClick:()=>{(f||re)&&(Te.isEqual(S,{...o,sizeIndex:s})&&Z?($(void 0),f?.(void 0)):($({...o,sizeIndex:s}),f&&f({...o,sizeIndex:s})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:0,width:c.bandwidth(),variants:{initial:{height:0,fill:T[s],y:h(0)},whileInView:{height:Math.abs(h(ke.sum(o.size.filter((t,a)=>a<=s&&t)))-h(ke.sum(o.size.filter((t,a)=>a<s&&t)))),y:h(ke.sum(o.size.filter((t,a)=>a<=s&&t))),fill:T[s],transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{height:0,y:h(0),transition:{duration:g.duration}}}),_?e.jsxRuntimeExports.jsx(ge.motion.text,{x:c.bandwidth()/2,style:{fill:Je.getTextColorBasedOnBgColor(T[s]),textAnchor:"middle",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:"0.33em",variants:{initial:{y:h(0),opacity:0,fill:Je.getTextColorBasedOnBgColor(T[s])},whileInView:{y:h(ke.sum(o.size.filter((t,a)=>a<=s&&t)))+Math.abs(h(ke.sum(o.size.filter((t,a)=>a<=s&&t)))-h(ke.sum(o.size.filter((t,a)=>a<s&&t))))/2,opacity:r&&Math.abs(h(ke.sum(o.size.filter((t,a)=>a<=s&&t)))-h(ke.sum(o.size.filter((t,a)=>a<s&&t))))>20?1:0,fill:Je.getTextColorBasedOnBgColor(T[s]),transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(r,O,I,U,C)}):null]},`${o.label}-${w[s]||s}`)),me?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${o.label}`.length<he?`${o.label}`:`${`${o.label}`.substring(0,he)}...`,y:h(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:D?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:z}):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{...pe&&{fill:pe},textAnchor:"middle",...D?.graphObjectValues||{}},x:c.bandwidth()/2,dy:-10,className:e.mo("graph-value graph-value-total",pe?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",b?.graphObjectValues),variants:{initial:{y:h(0),opacity:0},whileInView:{y:h(ke.sum(o.size.map(r=>r||0))),opacity:1,transition:{duration:g.duration}}},exit:{opacity:0,transition:{duration:g.duration}},initial:"initial",animate:z?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(o.size.filter(r=>r)),O,I,U,C)}):null]},o.label)),Q?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Q.map((o,r)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:o.text,color:o.color,y:h(o.value),x1:0-K,x2:N+v.right,classNames:o.classNames,styles:o.styles,animate:g,isInView:z},r))}):null]}),R.filter(o=>o.position==="after").map(o=>o.layer)]})}),j&&le&&oe&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:le,xPos:oe,yPos:B,backgroundStyle:D?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:S!==void 0,onClose:()=>{$(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Ve.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function ht(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:K=20,topMargin:G=20,bottomMargin:ie=25,truncateBy:M=999,showLabels:le=!0,showValues:xe=!0,backgroundColor:C=!1,showColorScale:U=!0,suffix:_="",prefix:Q="",height:E,width:f,footNote:L,colorDomain:ae,colorLegendTitle:se,padding:J,tooltip:Z,onSeriesMouseOver:re,relativeHeight:W,refValues:pe,graphID:ce,maxValue:D,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:I="en",theme:R="light",labelOrder:O,minHeight:A=0,maxBarThickness:z,sortParameter:v,maxNumberOfBars:j,minBarThickness:X,ariaLabel:S,resetSelectionOnDoubleClick:$=!0,detailsOnClick:oe,barAxisTitle:P,noOfTicks:B=5,valueColor:ee,styles:N,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA",sortData:r}=fe,[s,t]=m.useState(0),[a,x]=m.useState(0),[ve,Oe]=m.useState(d.autoplay),ue=Re.sort(Ie.uniqBy(l.filter(n=>n.date!==void 0&&n.date!==null),n=>n.date).map(n=>Ee.parse(`${n.date}`,d.dateFormat||"yyyy",new Date).getTime()),(n,V)=>Ye.ascending(n,V)),[be,je]=m.useState(d.autoplay?0:ue.length-1),[ne,we]=m.useState(void 0),u=m.useRef(null),te=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(V=>{t(f||V[0].target.clientWidth||620),x(E||V[0].target.clientHeight||480)});return u.current&&(x(u.current.clientHeight||480),t(u.current.clientWidth||620),f||n.observe(u.current)),()=>n.disconnect()},[f,E]),m.useEffect(()=>{const n=setInterval(()=>{je(V=>V<ue.length-1?V+1:0)},(d.speed||2)*1e3);return ve||clearInterval(n),()=>clearInterval(n)},[ue,ve,d.speed]);const Se=Re.getSliderMarks(ue,be,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${R||"light"} flex ${f?"w-fit grow-0":"w-full grow"}`,dir:I==="he"||I==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${I||"en"}`,F?.graphContainer),style:{...N?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:ce,ref:te,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{style:{padding:C?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||q||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:N?.title,description:N?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:q,width:f,graphDownload:g?te.current:void 0,dataDownload:w?l.map(n=>n.data).filter(n=>n!==void 0).length>0?l.map(n=>n.data).filter(n=>n!==void 0):l.filter(n=>n!==void 0):null}):null,d.enabled&&ue.length>0&&Se?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!ve)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ve?"Click to pause animation":"Click to play animation",children:ve?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ue[0],max:ue[ue.length-1],marks:Se,step:null,defaultValue:ue[ue.length-1],value:ue[be],onChangeComplete:n=>{je(ue.indexOf(n))},onChange:n=>{je(ue.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[U?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:f,colorDomain:ae,colors:H,colorLegendTitle:se,setSelectedColor:we,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:u,"aria-label":"Graph area",children:(f||s)&&(E||a)?e.jsxRuntimeExports.jsx(mt,{data:v!==void 0?v==="total"?Qe.orderBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(ue[be]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(V=>V==null):n),n=>ke.sum(n.size.filter(V=>!Y.checkIfNullOrUndefined(V))),[r||"asc"]).filter((n,V)=>j?V<j:!0):Qe.orderBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(ue[be]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(V=>V==null):n),n=>Y.checkIfNullOrUndefined(n.size[v])?-1/0:n.size[v],[r||"asc"]).filter((n,V)=>j?V<j:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>h?!n.size.every(V=>V==null):n).filter((n,V)=>j?V<j:!0),barColors:H,width:f||s,height:Math.max(A,E||(W?A?(f||s)*W>A?(f||s)*W:A:(f||s)*W:a)),barPadding:me,showLabels:le,showTicks:de,truncateBy:M,leftMargin:he,rightMargin:K,topMargin:G,bottomMargin:ie,tooltip:Z,onSeriesMouseOver:re,showValues:xe,suffix:_,prefix:Q,refValues:pe,maxValue:Y.checkIfNullOrUndefined(D)?Math.max(...l.map(n=>ke.sum(n.size.filter(V=>!Y.checkIfNullOrUndefined(V)))||0)):D,onSeriesMouseClick:b,selectedColor:ne,labelOrder:O,maxBarThickness:z,minBarThickness:X,resetSelectionOnDoubleClick:$,detailsOnClick:oe,barAxisTitle:P,noOfTicks:B,valueColor:ee,styles:N,classNames:F,animate:k===!0?{duration:.5,once:!0,amount:.5}:k||{duration:0,once:!0,amount:0},colorDomain:ae,precision:y,customLayers:c,naLabel:o}):null})]})}),T||L?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:N?.footnote,source:N?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:T,footNote:L,width:f}):null]})})})})}function pt(fe){const{data:l,graphTitle:p,colors:H,barPadding:T,showTicks:q,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:K,truncateBy:G,showLabels:ie,showValues:M,backgroundColor:le,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,showColorScale:pe,graphID:ce,maxValue:D,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:I,dataDownload:R,language:O,theme:A,sortData:z,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:oe,ariaLabel:P,resetSelectionOnDoubleClick:B,detailsOnClick:ee,barAxisTitle:N,noOfTicks:F,valueColor:h,orientation:k="vertical",styles:y,classNames:c,filterNA:d,animate:o,dimmedOpacity:r,precision:s,customLayers:t,timeline:a,naLabel:x}=fe;return k==="vertical"?e.jsxRuntimeExports.jsx(ct,{data:l,graphTitle:p,colors:H,barPadding:T,showTicks:q,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:K,truncateBy:G,showLabels:ie,showValues:M,backgroundColor:le,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,showColorScale:pe,graphID:ce,maxValue:D,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:I,dataDownload:R,language:O,theme:A,sortData:z,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:oe,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:ee,barAxisTitle:N,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,animate:o,dimmedOpacity:r,precision:s,customLayers:t,timeline:a}):e.jsxRuntimeExports.jsx(st,{data:l,graphTitle:p,colors:H,barPadding:T,showTicks:q,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:K,truncateBy:G,showLabels:ie,showValues:M,backgroundColor:le,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,showColorScale:pe,graphID:ce,maxValue:D,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:I,dataDownload:R,language:O,theme:A,sortData:z,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:oe,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:ee,barAxisTitle:N,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,dimmedOpacity:r,precision:s,customLayers:t,timeline:a,naLabel:x})}function gt(fe){const{data:l,graphTitle:p,colors:H,sources:T,graphDescription:q,barPadding:me,showTicks:de,truncateBy:he,height:K,width:G,footNote:ie,colorDomain:M,colorLegendTitle:le,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Q,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,graphID:pe,maxValue:ce,minValue:D,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:I,labelOrder:R,minHeight:O,theme:A,maxBarThickness:z,ariaLabel:v,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:S,noOfTicks:$,valueColor:oe,orientation:P="vertical",styles:B,classNames:ee,filterNA:N,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}=fe;return P==="vertical"?e.jsxRuntimeExports.jsx(dt,{data:l,graphTitle:p,colors:H,sources:T,graphDescription:q,barPadding:me,showTicks:de,truncateBy:he,height:K,width:G,footNote:ie,colorDomain:M,colorLegendTitle:le,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Q,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,graphID:pe,maxValue:ce,minValue:D,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:I,labelOrder:R,minHeight:O,theme:A,maxBarThickness:z,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:S,noOfTicks:$,valueColor:oe,classNames:ee,filterNA:N,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}):e.jsxRuntimeExports.jsx(nt,{data:l,graphTitle:p,colors:H,sources:T,graphDescription:q,barPadding:me,showTicks:de,truncateBy:he,height:K,width:G,footNote:ie,colorDomain:M,colorLegendTitle:le,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Q,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:Z,onSeriesMouseOver:re,refValues:W,graphID:pe,maxValue:ce,minValue:D,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:I,labelOrder:R,minHeight:O,theme:A,maxBarThickness:z,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:S,noOfTicks:$,valueColor:oe,classNames:ee,filterNA:N,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d})}function ft(fe){const{data:l,graphTitle:p,colors:H,sources:T,graphDescription:q,barPadding:me,showTicks:de,leftMargin:he,rightMargin:K,topMargin:G,bottomMargin:ie,truncateBy:M,showLabels:le,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:Z,relativeHeight:re,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:D,graphDownload:b,dataDownload:g,language:w,theme:I,labelOrder:R,minHeight:O,maxBarThickness:A,sortParameter:z,sortData:v,maxNumberOfBars:j,minBarThickness:X,ariaLabel:S,resetSelectionOnDoubleClick:$,detailsOnClick:oe,barAxisTitle:P,noOfTicks:B,valueColor:ee,orientation:N="vertical",styles:F,classNames:h,filterNA:k,animate:y,precision:c,customLayers:d,showColorScale:o,timeline:r,naLabel:s}=fe;return N==="vertical"?e.jsxRuntimeExports.jsx(ht,{data:l,graphTitle:p,colors:H,sources:T,graphDescription:q,barPadding:me,showTicks:de,leftMargin:he,rightMargin:K,topMargin:G,bottomMargin:ie,truncateBy:M,showLabels:le,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:Z,relativeHeight:re,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:D,graphDownload:b,dataDownload:g,language:w,theme:I,labelOrder:R,minHeight:O,maxBarThickness:A,sortParameter:z,sortData:v,maxNumberOfBars:j,minBarThickness:X,ariaLabel:S,resetSelectionOnDoubleClick:$,styles:F,detailsOnClick:oe,barAxisTitle:P,noOfTicks:B,valueColor:ee,classNames:h,filterNA:k,animate:y,precision:c,customLayers:d,showColorScale:o,timeline:r,naLabel:s}):e.jsxRuntimeExports.jsx(ot,{data:l,graphTitle:p,colors:H,sources:T,graphDescription:q,barPadding:me,showTicks:de,leftMargin:he,rightMargin:K,topMargin:G,bottomMargin:ie,truncateBy:M,showLabels:le,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Q,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:Z,relativeHeight:re,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:D,graphDownload:b,dataDownload:g,language:w,theme:I,labelOrder:R,minHeight:O,maxBarThickness:A,sortParameter:z,sortData:v,maxNumberOfBars:j,minBarThickness:X,ariaLabel:S,resetSelectionOnDoubleClick:$,styles:F,detailsOnClick:oe,barAxisTitle:P,noOfTicks:B,valueColor:ee,classNames:h,filterNA:k,animate:y,precision:c,customLayers:d,showColorScale:o,timeline:r,naLabel:s})}exports.GroupedBarGraph=gt;exports.SimpleBarGraph=pt;exports.StackedBarGraph=ft;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),Se=require("./index-CZbIGs8q.cjs"),d=require("react"),Qe=require("./index-BzeLQvXk.cjs"),ke=require("./parse-hMnG_lRV.cjs"),Re=require("./getSliderMarks-CtsEXiLV.cjs"),Ae=require("./index-BXns0-ng.cjs"),ze=require("./Modal-tXZlLE5s.cjs"),De=require("./numberFormattingFunction-02t-wJta.cjs"),Ve=require("./Tooltip-n8z5bfav.cjs"),P=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ee=require("./Colors.cjs"),Le=require("./string2HTML-D2Avudmb.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),et=require("./YAxesLabels-D8IydyZj.cjs"),Be=require("./AxisTitle-CK9YeovX.cjs"),Fe=require("./Axis-DE7dSn1_.cjs"),Pe=require("./ReferenceLine-CFVBBN__.cjs"),He=require("./use-in-view-sQJZ_xDO.cjs"),Ue=require("./linear-BVckp9RD.cjs"),$e=require("./band-CAApY4Pd.cjs"),qe=require("./index-BW8iNx7E.cjs"),fe=require("./proxy-BHRoeZgd.cjs"),Ge=require("./GraphFooter.cjs"),We=require("./GraphHeader.cjs"),Xe=require("./ColorLegendWithMouseOver.cjs"),Ye=require("./EmptyState-d8_8SxeW.cjs"),Ie=require("./index-BW_-wD2k.cjs"),Oe=require("./ensureCompleteData-DqWQ2Zbi.cjs"),_e=require("./init-DU0ybBc_.cjs"),Te=require("./index-BczVvEBZ.cjs"),Ce=require("./index-C21TvELx.cjs"),Ke=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),tt=require("./XAxesLabels-OjBNl_lS.cjs"),it=require("./YTicksAndGridLines-DBDuz6vb.cjs");function at(ye){const{data:o,barColor:p,suffix:U,prefix:T,barPadding:q,showValues:me,showTicks:de,leftMargin:he,truncateBy:Z,width:G,height:ie,colorDomain:M,rightMargin:ne,topMargin:xe,bottomMargin:R,showLabels:W,tooltip:J,onSeriesMouseOver:ee,refValues:k,selectedColor:y,highlightedDataPoints:L,maxValue:ae,minValue:se,onSeriesMouseClick:K,labelOrder:te,rtl:re,maxBarThickness:X,minBarThickness:pe,resetSelectionOnDoubleClick:oe,detailsOnClick:D,barAxisTitle:b,valueColor:g,noOfTicks:w,styles:I,classNames:O,animate:N,dimmedOpacity:A,precision:z,customLayers:v,naLabel:j}=ye,Y=d.useRef(null),S=He.useInView(Y,{once:N.once,amount:N.amount}),[$,le]=d.useState(void 0),[H,B]=d.useState(void 0),[Q,E]=d.useState(void 0),[F,m]=d.useState(void 0),C={top:b?xe+25:xe,bottom:R,left:he,right:ne},h=G-C.left-C.right,c=ie-C.top-C.bottom,x=o.map((r,f)=>({...r,id:te?`${r.label}`:`${f}`})),u=Ue.linear().domain([se,ae]).range([0,h]).nice(),s=te||x.map(r=>`${r.id}`),n=$e.band().domain(s).range([0,pe?Math.max(c,pe*s.length):X?Math.min(c,X*s.length):c]).paddingInner(q),t=u.ticks(w);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:Y,width:`${G}px`,height:`${ie}px`,viewBox:`0 0 ${G} ${ie}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${C.left},${C.top})`,children:[de?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:t.filter(r=>r!==0),x:t.filter(r=>r!==0).map(r=>u(r)),y1:0-xe,y2:c+C.bottom,styles:{gridLines:I?.xAxis?.gridLines,labels:I?.xAxis?.labels},classNames:{gridLines:O?.xAxis?.gridLines,labels:O?.xAxis?.labels},suffix:U,prefix:T,labelType:"secondary",showGridLines:!0,precision:z}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:h/2,y:0-C.top+15,style:I?.xAxis?.title,className:O?.xAxis?.title,text:b}),v.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[x.map(r=>P.checkIfNullOrUndefined(n(r.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:y?r.color&&p[M.indexOf(r.color)]===y?1:A:L.length!==0?L.indexOf(r.label)!==-1?.85:A:.85},whileInView:{opacity:y?r.color&&p[M.indexOf(r.color)]===y?1:A:L.length!==0?L.indexOf(r.label)!==-1?.85:A:.85,transition:{duration:N.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:N.duration}},onMouseEnter:f=>{le(r),m(f.clientY),E(f.clientX),ee?.(r)},onClick:()=>{(K||D)&&(Ae.isEqual(H,r)&&oe?(B(void 0),K?.(void 0)):(B(r),K?.(r)))},onMouseMove:f=>{le(r),m(f.clientY),E(f.clientX)},onMouseLeave:()=>{le(void 0),E(void 0),m(void 0),ee?.(void 0)},children:[r.size?e.jsxRuntimeExports.jsx(fe.motion.rect,{variants:{initial:{width:0,x:u(0),y:n(`${r.id}`),fill:o.filter(f=>f.color).length===0?p[0]:r.color?p[M.indexOf(r.color)]:Ee.Colors.gray},whileInView:{width:r.size>=0?u(r.size)-u(0):u(0)-u(r.size),x:r.size>=0?u(0):u(r.size),y:n(`${r.id}`),fill:o.filter(f=>f.color).length===0?p[0]:r.color?p[M.indexOf(r.color)]:Ee.Colors.gray,transition:{duration:N.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{width:0,x:u(0),transition:{duration:N.duration}},height:n.bandwidth()}):null,W?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${r.label}`.length<Z?`${r.label}`:`${`${r.label}`.substring(0,Z)}...`,y:n(r.id)||0,x:(r.size||0)<0?u(0):0-C.left,width:(r.size||0)<0?G-u(0):u(0)+C.left,height:n.bandwidth(),alignment:r.size&&r.size<0?"left":"right",style:I?.yAxis?.labels,className:O?.yAxis?.labels,animate:N,isInView:S}):null,me?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{textAnchor:r.size&&r.size<0?"end":"start",...I?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!g&&p.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",O?.graphObjectValues),dx:r.size&&r.size<0?-5:5,dy:"0.33em",variants:{initial:{x:u(0),y:n(`${r.id}`)+n.bandwidth()/2,opacity:0,fill:g||(o.filter(f=>f.color).length===0?p[0]:r.color?p[M.indexOf(r.color)]:Ee.Colors.gray)},whileInView:{x:r.size?u(r.size):u(0),opacity:1,y:n(`${r.id}`)+n.bandwidth()/2,fill:g||(o.filter(f=>f.color).length===0?p[0]:r.color?p[M.indexOf(r.color)]:Ee.Colors.gray),transition:{duration:N.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:N.duration}},children:De.numberFormattingFunction(r.size,j,z,T,U)}):null]},r.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:u(se<0?0:se),x2:u(se<0?0:se),y1:-2.5,y2:c+C.bottom,classNames:{axis:O?.yAxis?.axis},styles:{axis:I?.yAxis?.axis}}),k?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:k.map((r,f)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:r.text,color:r.color,x:u(r.value),y1:0-C.top,y2:c+C.bottom,textSide:u(r.value)>h*.75||re?"left":"right",classNames:r.classNames,styles:r.styles,animate:N,isInView:S},f))}):null]}),v.filter(r=>r.position==="after").map(r=>r.layer)]})}),$&&J&&Q&&F?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:$,body:J,xPos:Q,yPos:F,backgroundStyle:I?.tooltip,className:O?.tooltip}):null,D&&H!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:H!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof D=="string"?{__html:Le.string2HTML(D,H)}:void 0,children:typeof D=="function"?D(H):null})}):null]})}function st(ye){const{data:o,graphTitle:p,colors:U,suffix:T="",sources:q,prefix:me="",graphDescription:de,barPadding:he=.25,showValues:Z=!0,showTicks:G=!0,leftMargin:ie=100,rightMargin:M=40,truncateBy:ne=999,height:xe,width:R,footNote:W,colorDomain:J,colorLegendTitle:ee,highlightedDataPoints:k=[],padding:y,backgroundColor:L=!1,topMargin:ae=25,bottomMargin:se=10,showLabels:K=!0,relativeHeight:te,tooltip:re,onSeriesMouseOver:X,refValues:pe,showColorScale:oe=!0,graphID:D,maxValue:b,minValue:g,onSeriesMouseClick:w,graphDownload:I=!1,dataDownload:O=!1,sortData:N,labelOrder:A,language:z="en",showNAColor:v=!0,minHeight:j=0,theme:Y="light",maxBarThickness:S,maxNumberOfBars:$,minBarThickness:le,ariaLabel:H,resetSelectionOnDoubleClick:B=!0,detailsOnClick:Q,barAxisTitle:E,noOfTicks:F=5,valueColor:m,styles:C,classNames:h,filterNA:c=!0,animate:x=!1,dimmedOpacity:u=.3,precision:s=2,customLayers:n=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:r="NA"}=ye,[f,we]=d.useState(0),[ue,_]=d.useState(0),[ge,Ne]=d.useState(t.autoplay),ce=Re.sort(Se.uniqBy(o.filter(a=>a.date!==void 0&&a.date!==null),a=>a.date).map(a=>ke.parse(`${a.date}`,t.dateFormat||"yyyy",new Date).getTime()),(a,ve)=>_e.ascending(a,ve)),[be,je]=d.useState(t.autoplay?0:ce.length-1),[Me,l]=d.useState(void 0),i=d.useRef(null),V=d.useRef(null);d.useEffect(()=>{const a=new ResizeObserver(ve=>{we(R||ve[0].target.clientWidth||620),_(xe||ve[0].target.clientHeight||480)});return i.current&&(_(i.current.clientHeight||480),we(i.current.clientWidth||620),R||a.observe(i.current)),()=>a.disconnect()},[R,xe]),d.useEffect(()=>{const a=setInterval(()=>{je(ve=>ve<ce.length-1?ve+1:0)},(t.speed||2)*1e3);return ge||clearInterval(a),()=>clearInterval(a)},[ce,ge,t.speed]);const Je=Re.getSliderMarks(ce,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${Y||"light"} flex ${R?"w-fit grow-0":"w-full grow"}`,dir:z==="he"||z==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${L?L===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${z||"en"}`,h?.graphContainer),style:{...C?.graphContainer||{},...L&&L!==!0?{backgroundColor:L}:{}},id:D,ref:V,"aria-label":H||`${p?`The graph shows ${p}. `:""}This is a bar chart. ${de?` ${de}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:L?y||"1rem":y||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||de||I||O?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:h?.title,description:h?.description},graphTitle:p,graphDescription:de,width:R,graphDownload:I?V.current:void 0,dataDownload:O?o.map(a=>a.data).filter(a=>a!==void 0).length>0?o.map(a=>a.data).filter(a=>a!==void 0):o.filter(a=>a!==void 0):null}):null,t.enabled&&ce.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ne(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ce[0],max:ce[ce.length-1],marks:Je,step:null,defaultValue:ce[ce.length-1],value:ce[be],onChangeComplete:a=>{je(ce.indexOf(a))},onChange:a=>{je(ce.indexOf(a))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[oe&&o.filter(a=>a.color).length!==0?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:R,colorLegendTitle:ee,colors:U||Ee.Colors[Y].categoricalColors.colors,colorDomain:J||Se.uniqBy(o.filter(a=>a.color),"color").map(a=>a.color),setSelectedColor:l,showNAColor:v}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:i,"aria-label":"Graph area",children:(R||f)&&(xe||ue)?e.jsxRuntimeExports.jsx(at,{data:N==="asc"?Qe.sortBy(Oe.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(a=>t.enabled?a.date===ke.format(new Date(ce[be]),t.dateFormat||"yyyy"):a).filter(a=>c?!P.checkIfNullOrUndefined(a.size):a),a=>a.size).filter((a,ve)=>$?ve<$:!0):N==="desc"?Qe.sortBy(Oe.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(a=>t.enabled?a.date===ke.format(new Date(ce[be]),t.dateFormat||"yyyy"):a).filter(a=>c?!P.checkIfNullOrUndefined(a.size):a),a=>a.size).reverse().filter((a,ve)=>$?ve<$:!0):Oe.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(a=>t.enabled?a.date===ke.format(new Date(ce[be]),t.dateFormat||"yyyy"):a).filter(a=>c?!P.checkIfNullOrUndefined(a.size):a).filter((a,ve)=>$?ve<$:!0),barColor:o.filter(a=>a.color).length===0?U?[U]:[Ee.Colors.primaryColors["blue-600"]]:U||Ee.Colors[Y].categoricalColors.colors,colorDomain:o.filter(a=>a.color).length===0?[]:J||Se.uniqBy(o.filter(a=>a.color),"color").map(a=>a.color),width:R||f,selectedColor:Me,height:Math.max(j,xe||(te?j?(R||f)*te>j?(R||f)*te:j:(R||f)*te:ue)),suffix:T,prefix:me,barPadding:he,showValues:Z,showTicks:G,leftMargin:ie,rightMargin:M,topMargin:ae,bottomMargin:se,truncateBy:ne,showLabels:K,tooltip:re,onSeriesMouseOver:X,refValues:pe,maxValue:P.checkIfNullOrUndefined(b)?Math.max(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size))<0?0:Math.max(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size)):b,minValue:P.checkIfNullOrUndefined(g)?Math.min(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size))>=0?0:Math.min(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size)):g,highlightedDataPoints:k,onSeriesMouseClick:w,labelOrder:A,rtl:z==="he"||z==="ar",maxBarThickness:S,minBarThickness:le,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:E,noOfTicks:F,valueColor:m,classNames:h,styles:C,animate:x===!0?{duration:.5,once:!0,amount:.5}:x||{duration:0,once:!0,amount:0},dimmedOpacity:u,precision:s,customLayers:n,naLabel:r}):null})]})}),q||W?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{sources:q,footNote:W,width:R,styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:h?.footnote,source:h?.source}}):null]})})})})}function rt(ye){const{data:o,barColors:p,barPadding:U,showTicks:T,leftMargin:q,truncateBy:me,width:de,height:he,suffix:Z,prefix:G,showValues:ie,rightMargin:M,topMargin:ne,bottomMargin:xe,showLabels:R,tooltip:W,onSeriesMouseOver:J,refValues:ee,maxValue:k,minValue:y,onSeriesMouseClick:L,selectedColor:ae,rtl:se,labelOrder:K,maxBarThickness:te,resetSelectionOnDoubleClick:re,detailsOnClick:X,barAxisTitle:pe,valueColor:oe,noOfTicks:D,styles:b,classNames:g,animate:w,colorDomain:I,precision:O,customLayers:N,naLabel:A}=ye,z=d.useRef(null),v=He.useInView(z,{once:w.once,amount:w.amount}),j={top:pe?ne+25:ne,bottom:xe,left:q,right:M},[Y,S]=d.useState(void 0),[$,le]=d.useState(void 0),[H,B]=d.useState(void 0),[Q,E]=d.useState(void 0),F=de-j.left-j.right,m=he-j.top-j.bottom,C=o.map((n,t)=>({...n,id:K?`${n.label}`:`${t}`})),h=K||C.map(n=>`${n.id}`),c=Ue.linear().domain([y,k]).range([0,F]).nice(),x=$e.band().domain(h).range([0,te?Math.min(m,te*h.length):m]).paddingInner(U),u=$e.band().domain(o[0].size.map((n,t)=>`${t}`)).range([0,x.bandwidth()]).paddingInner(.1),s=c.ticks(D);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:z,width:`${de}px`,height:`${he}px`,viewBox:`0 0 ${de} ${he}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[T?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:s.filter(n=>n!==0),x:s.filter(n=>n!==0).map(n=>c(n)),y1:0-ne,y2:m+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:Z,prefix:G,labelType:"secondary",showGridLines:!0,precision:O}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),N.filter(n=>n.position==="before").map(n=>n.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[C.map(n=>P.checkIfNullOrUndefined(x(n.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{variants:{initial:{x:0,y:x(`${n.id}`)},whileInView:{x:0,y:x(`${n.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[n.size.map((t,r)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?p[r]===ae?1:.3:.85,onMouseEnter:f=>{S({...n,sizeIndex:r}),E(f.clientY),B(f.clientX),J?.({...n,sizeIndex:r})},onMouseMove:f=>{S({...n,sizeIndex:r}),E(f.clientY),B(f.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),E(void 0),J?.(void 0)},onClick:()=>{(L||X)&&(Ae.isEqual($,{...n,sizeIndex:r})&&re?(le(void 0),L?.(void 0)):(le({...n,sizeIndex:r}),L&&L({...n,sizeIndex:r})))},children:[P.checkIfNullOrUndefined(t)?null:e.jsxRuntimeExports.jsx(fe.motion.rect,{y:u(`${r}`),variants:{initial:{width:0,x:c(0),fill:p[r]},whileInView:{width:P.checkIfNullOrUndefined(t)?0:t>=0?c(t)-c(0):c(0)-c(t),x:t>=0?c(0):c(t),fill:p[r],transition:{duration:w.duration}}},exit:{width:0,x:c(0),transition:{duration:w.duration}},height:u.bandwidth(),initial:"initial",animate:v?"whileInView":"initial"}),ie?e.jsxRuntimeExports.jsx(fe.motion.text,{y:u(`${r}`)+u.bandwidth()/2,style:{fill:oe||p[r],textAnchor:t&&t<0?"end":"start",...b?.graphObjectValues||{}},className:e.mo("graph-value text-sm",g?.graphObjectValues),dx:t&&t<0?-5:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(t||0),opacity:1,transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:De.numberFormattingFunction(t,A,O,G,Z)}):null]},`${n.label}-${I[r]||r}`)),R?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${n.label}`.length<me?`${n.label}`:`${`${n.label}`.substring(0,me)}...`,y:0,x:0-j.left,width:c(y<0?0:y)+j.left,height:x.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null]},n.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:c(y<0?0:y),x2:c(y<0?0:y),y1:-2.5,y2:m+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((n,t)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:n.text,color:n.color,x:c(n.value),y1:0-j.top,y2:m+j.bottom,textSide:c(n.value)>F*.75||se?"left":"right",classNames:n.classNames,styles:n.styles,animate:w,isInView:v},t))}):null]}),N.filter(n=>n.position==="after").map(n=>n.layer)]})}),Y&&W&&H&&Q?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:Y,body:W,xPos:H,yPos:Q,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,X&&$!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:$!==void 0,onClose:()=>{le(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof X=="string"?{__html:Le.string2HTML(X,$)}:void 0,children:typeof X=="function"?X($):null})}):null]})}function nt(ye){const{data:o,graphTitle:p,colors:U=Ee.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,truncateBy:he=999,height:Z,width:G,footNote:ie,colorDomain:M,colorLegendTitle:ne,suffix:xe="",prefix:R="",showValues:W=!0,showColorScale:J=!0,padding:ee,backgroundColor:k=!1,leftMargin:y=100,rightMargin:L=40,topMargin:ae=25,bottomMargin:se=10,showLabels:K=!0,relativeHeight:te,tooltip:re,onSeriesMouseOver:X,refValues:pe,graphID:oe,maxValue:D,minValue:b,onSeriesMouseClick:g,graphDownload:w=!1,dataDownload:I=!1,language:O="en",labelOrder:N,minHeight:A=0,theme:z="light",maxBarThickness:v,ariaLabel:j,resetSelectionOnDoubleClick:Y=!0,detailsOnClick:S,barAxisTitle:$,noOfTicks:le=5,valueColor:H,styles:B,classNames:Q,filterNA:E=!0,animate:F=!1,precision:m=2,customLayers:C=[],timeline:h={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA",sortParameter:x,sortData:u}=ye,[s,n]=d.useState(0),[t,r]=d.useState(0),[f,we]=d.useState(h.autoplay),ue=Re.sort(Se.uniqBy(o.filter(l=>l.date!==void 0&&l.date!==null),l=>l.date).map(l=>ke.parse(`${l.date}`,h.dateFormat||"yyyy",new Date).getTime()),(l,i)=>_e.ascending(l,i)),[_,ge]=d.useState(h.autoplay?0:ue.length-1),[Ne,ce]=d.useState(void 0),be=d.useRef(null),je=d.useRef(null);d.useEffect(()=>{const l=new ResizeObserver(i=>{n(G||i[0].target.clientWidth||620),r(Z||i[0].target.clientHeight||480)});return be.current&&(r(be.current.clientHeight||480),n(be.current.clientWidth||620),G||l.observe(be.current)),()=>l.disconnect()},[G,Z]),d.useEffect(()=>{const l=setInterval(()=>{ge(i=>i<ue.length-1?i+1:0)},(h.speed||2)*1e3);return f||clearInterval(l),()=>clearInterval(l)},[ue,f,h.speed]);const Me=Re.getSliderMarks(ue,_,h.showOnlyActiveDate,h.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${z||"light"} flex ${G?"w-fit grow-0":"w-full grow"}`,dir:O==="he"||O==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${k?k===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${O||"en"}`,Q?.graphContainer),style:{...B?.graphContainer||{},...k&&k!==!0?{backgroundColor:k}:{}},id:oe,ref:je,"aria-label":j||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:k?ee||"1rem":ee||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||q||w||I?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:B?.title,description:B?.description},classNames:{title:Q?.title,description:Q?.description},graphTitle:p,graphDescription:q,width:G,graphDownload:w?je.current:void 0,dataDownload:I?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,h.enabled&&ue.length>0&&Me?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!f)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":f?"Click to pause animation":"Click to play animation",children:f?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ue[0],max:ue[ue.length-1],marks:Me,step:null,defaultValue:ue[ue.length-1],value:ue[_],onChangeComplete:l=>{ge(ue.indexOf(l))},onChange:l=>{ge(ue.indexOf(l))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[J?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:G,colorDomain:M,colors:U,colorLegendTitle:ne,setSelectedColor:ce,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:be,"aria-label":"Graph area",children:(G||s)&&(Z||t)?e.jsxRuntimeExports.jsx(rt,{data:x!==void 0?x==="total"?Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===ke.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>E?!l.size.every(i=>i==null):l),l=>Ce.sum(l.size.filter(i=>!P.checkIfNullOrUndefined(i))),[u||"asc"]):Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===ke.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>E?!l.size.every(i=>i==null):l),l=>P.checkIfNullOrUndefined(l.size[x])?-1/0:l.size[x],[u||"asc"]):Oe.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>E?!l.size.every(i=>i==null):l),barColors:U,width:G||s,height:Math.max(A,Z||(te?A?(G||s)*te>A?(G||s)*te:A:(G||s)*te:t)),suffix:xe,prefix:R,showValues:W,barPadding:me,showTicks:de,leftMargin:y,rightMargin:L,topMargin:ae,bottomMargin:se,truncateBy:he,showLabels:K,tooltip:re,onSeriesMouseOver:X,refValues:pe,maxValue:P.checkIfNullOrUndefined(D)?Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!P.checkIfNullOrUndefined(i)))))<0?0:Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!P.checkIfNullOrUndefined(i))))):D,minValue:P.checkIfNullOrUndefined(b)?Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!P.checkIfNullOrUndefined(i)))))>=0?0:Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!P.checkIfNullOrUndefined(i))))):b,onSeriesMouseClick:g,selectedColor:Ne,labelOrder:N,rtl:O==="he"||O==="ar",maxBarThickness:v,resetSelectionOnDoubleClick:Y,detailsOnClick:S,barAxisTitle:$,noOfTicks:le,valueColor:H,styles:B,classNames:Q,colorDomain:M,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},precision:m,customLayers:C,naLabel:c}):null})]})}),T||ie?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:B?.footnote,source:B?.source},classNames:{footnote:Q?.footnote,source:Q?.source},sources:T,footNote:ie,width:G}):null]})})})})}function lt(ye){const{data:o,barColors:p,barPadding:U,showTicks:T,leftMargin:q,rightMargin:me,truncateBy:de,width:he,height:Z,topMargin:G,bottomMargin:ie,tooltip:M,onSeriesMouseOver:ne,showLabels:xe,suffix:R,prefix:W,showValues:J,refValues:ee,maxValue:k,onSeriesMouseClick:y,selectedColor:L,rtl:ae,labelOrder:se,maxBarThickness:K,minBarThickness:te,resetSelectionOnDoubleClick:re,detailsOnClick:X,barAxisTitle:pe,valueColor:oe,noOfTicks:D,styles:b,classNames:g,animate:w,colorDomain:I,precision:O,customLayers:N,naLabel:A}=ye,z=d.useRef(null),v=He.useInView(z,{once:w.once,amount:w.amount}),j={top:pe?G+25:G,bottom:ie,left:q,right:me},[Y,S]=d.useState(void 0),[$,le]=d.useState(void 0),[H,B]=d.useState(void 0),[Q,E]=d.useState(void 0),F=he-j.left-j.right,m=Z-j.top-j.bottom,C=o.map((s,n)=>({...s,id:se?`${s.label}`:`${n}`})),h=se||C.map(s=>`${s.id}`),c=Ue.linear().domain([0,k]).range([0,F]).nice(),x=$e.band().domain(h).range([0,te?Math.max(m,te*h.length):K?Math.min(m,K*h.length):m]).paddingInner(U),u=c.ticks(D);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:z,width:`${he}px`,height:`${Z}px`,viewBox:`0 0 ${he} ${Z}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[T?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:u.filter(s=>s!==0),x:u.filter(s=>s!==0).map(s=>c(s)),y1:0-G,y2:m+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:R,prefix:W,labelType:"secondary",showGridLines:!0,precision:O}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),N.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[C.map(s=>P.checkIfNullOrUndefined(x(s.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:0,y:x(`${s.id}`)},whileInView:{x:0,y:x(`${s.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[s.size.map((n,t)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{opacity:L?p[t]===L?1:.3:1,onMouseEnter:r=>{S({...s,sizeIndex:t}),E(r.clientY),B(r.clientX),ne?.({...s,sizeIndex:t})},onMouseMove:r=>{S({...s,sizeIndex:t}),E(r.clientY),B(r.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),E(void 0),ne?.(void 0)},onClick:()=>{(y||X)&&(Ae.isEqual($,{...s,sizeIndex:t})&&re?(le(void 0),y?.(void 0)):(le({...s,sizeIndex:t}),y&&y({...s,sizeIndex:t})))},children:[n?e.jsxRuntimeExports.jsx(fe.motion.rect,{y:0,style:{fill:p[t]},height:x.bandwidth(),exit:{width:0,x:c(0),transition:{duration:w.duration}},variants:{initial:{width:0,x:c(0),fill:p[t]},whileInView:{width:c(n||0),x:c(t===0?0:Ce.sum(s.size.filter((r,f)=>f<t&&r))),fill:p[t],transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial"},t):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{y:x.bandwidth()/2,style:{textAnchor:"middle",...b?.graphObjectValues||{}},dy:"0.33em",className:e.mo("graph-value text-sm",g?.graphObjectValues),exit:{opacity:0,transition:{duration:w.duration}},variants:{initial:{x:c(0),opacity:0,fill:Ke.getTextColorBasedOnBgColor(p[t])},whileInView:{x:c(t===0?0:Ce.sum(s.size.filter((r,f)=>f<t&&r)))+c(n||0)/2,opacity:n&&c(n)/De.numberFormattingFunction(n,A,O,W,R).length>12?1:0,fill:Ke.getTextColorBasedOnBgColor(p[t]),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",children:De.numberFormattingFunction(n,A,O,W,R)}):null]},`${s.label}-${I[t]||t}`)),xe?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${s.label}`.length<de?`${s.label}`:`${`${s.label}`.substring(0,de)}...`,y:0,x:0-j.left,width:0+j.left,height:x.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{className:e.mo("graph-value graph-value-total text-sm",oe?"":" fill-primary-gray-700 dark:fill-primary-gray-300",g?.graphObjectValues),style:{...oe?{fill:oe}:{},textAnchor:"start",...b?.graphObjectValues||{}},y:x.bandwidth()/2,dx:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(Ce.sum(s.size.map(n=>n||0))),opacity:1,transition:{duration:w.duration}}},exit:{opacity:0,transition:{duration:w.duration}},initial:"initial",animate:v?"whileInView":"initial",children:De.numberFormattingFunction(Ce.sum(s.size.filter(n=>n)),A,O,W,R)}):null]},s.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:c(0),x2:c(0),y1:-2.5,y2:m+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((s,n)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:s.text,color:s.color,x:c(s.value),y1:0-j.top,y2:m+j.bottom,textSide:c(s.value)>F*.75||ae?"left":"right",classNames:s.classNames,styles:s.styles,animate:w,isInView:v},n))}):null]}),N.filter(s=>s.position==="after").map(s=>s.layer)]})}),Y&&M&&H&&Q?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:Y,body:M,xPos:H,yPos:Q,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,X&&$!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:$!==void 0,onClose:()=>{le(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof X=="string"?{__html:Le.string2HTML(X,$)}:void 0,children:typeof X=="function"?X($):null})}):null]})}function ot(ye){const{data:o,graphTitle:p,colors:U=Ee.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,leftMargin:he=100,rightMargin:Z=40,truncateBy:G=999,height:ie,width:M,footNote:ne,colorDomain:xe,colorLegendTitle:R,padding:W,backgroundColor:J=!1,topMargin:ee=25,bottomMargin:k=10,tooltip:y,onSeriesMouseOver:L,suffix:ae="",prefix:se="",showLabels:K=!0,relativeHeight:te,showValues:re=!0,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:D,graphDownload:b=!1,dataDownload:g=!1,language:w="en",labelOrder:I,minHeight:O=0,theme:N="light",maxBarThickness:A,sortParameter:z,maxNumberOfBars:v,minBarThickness:j,showColorScale:Y=!0,ariaLabel:S,resetSelectionOnDoubleClick:$=!0,detailsOnClick:le,barAxisTitle:H,noOfTicks:B=5,valueColor:Q,styles:E,classNames:F,filterNA:m=!0,animate:C=!1,precision:h=2,customLayers:c=[],timeline:x={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:u="NA",sortData:s}=ye,[n,t]=d.useState(0),[r,f]=d.useState(0),[we,ue]=d.useState(x.autoplay),_=Re.sort(Se.uniqBy(o.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>ke.parse(`${i.date}`,x.dateFormat||"yyyy",new Date).getTime()),(i,V)=>_e.ascending(i,V)),[ge,Ne]=d.useState(x.autoplay?0:_.length-1),[ce,be]=d.useState(void 0),je=d.useRef(null),Me=d.useRef(null);d.useEffect(()=>{const i=new ResizeObserver(V=>{t(M||V[0].target.clientWidth||620),f(ie||V[0].target.clientHeight||480)});return je.current&&(f(je.current.clientHeight||480),t(je.current.clientWidth||620),M||i.observe(je.current)),()=>i.disconnect()},[M,ie]),d.useEffect(()=>{const i=setInterval(()=>{Ne(V=>V<_.length-1?V+1:0)},(x.speed||2)*1e3);return we||clearInterval(i),()=>clearInterval(i)},[_,we,x.speed]);const l=Re.getSliderMarks(_,ge,x.showOnlyActiveDate,x.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${M?"w-fit grow-0":"w-full grow"}`,dir:w==="he"||w==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${J?J===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${w||"en"}`,F?.graphContainer),style:{...E?.graphContainer||{},...J&&J!==!0?{backgroundColor:J}:{}},id:pe,ref:Me,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:J?W||"1rem":W||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||q||b||g?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:q,width:M,graphDownload:b?Me.current:void 0,dataDownload:g?o.map(i=>i.data).filter(i=>i!==void 0).length>0?o.map(i=>i.data).filter(i=>i!==void 0):o.filter(i=>i!==void 0):null}):null,x.enabled&&_.length>0&&l?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{ue(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:_[0],max:_[_.length-1],marks:l,step:null,defaultValue:_[_.length-1],value:_[ge],onChangeComplete:i=>{Ne(_.indexOf(i))},onChange:i=>{Ne(_.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[Y?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:M,colorDomain:xe,colors:U,colorLegendTitle:R,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:je,"aria-label":"Graph area",children:(M||n)&&(ie||r)?e.jsxRuntimeExports.jsx(lt,{data:z!==void 0?z==="total"?Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===ke.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(V=>V==null):i),i=>Ce.sum(i.size.filter(V=>!P.checkIfNullOrUndefined(V))),[s||"asc"]).filter((i,V)=>v?V<v:!0):Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===ke.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(V=>V==null):i),i=>P.checkIfNullOrUndefined(i.size[z])?-1/0:i.size[z],[s||"asc"]).filter((i,V)=>v?V<v:!0):Oe.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===ke.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(V=>V==null):i).filter((i,V)=>v?V<v:!0),barColors:U,width:M||n,height:Math.max(O,ie||(te?O?(M||n)*te>O?(M||n)*te:O:(M||n)*te:r)),barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:ee,bottomMargin:k,truncateBy:G,showLabels:K,tooltip:y,onSeriesMouseOver:L,showValues:re,suffix:ae,prefix:se,refValues:X,maxValue:P.checkIfNullOrUndefined(oe)?Math.max(...o.map(i=>Ce.sum(i.size.filter(V=>!P.checkIfNullOrUndefined(V)))||0)):oe,onSeriesMouseClick:D,selectedColor:ce,rtl:w==="he"||w==="ar",labelOrder:I,maxBarThickness:A,minBarThickness:j,resetSelectionOnDoubleClick:$,detailsOnClick:le,barAxisTitle:H,noOfTicks:B,valueColor:Q,classNames:F,styles:E,animate:C===!0?{duration:.5,once:!0,amount:.5}:C||{duration:0,once:!0,amount:0},colorDomain:xe,precision:h,customLayers:c,naLabel:u}):null})]})}),T||ne?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:T,footNote:ne,width:M}):null]})})})})}function ut(ye){const{data:o,width:p,height:U,barColor:T,suffix:q,prefix:me,barPadding:de,showLabels:he,showValues:Z,showTicks:G,colorDomain:ie,truncateBy:M,rightMargin:ne,topMargin:xe,bottomMargin:R,leftMargin:W,tooltip:J,onSeriesMouseOver:ee,refValues:k,selectedColor:y,maxValue:L,minValue:ae,highlightedDataPoints:se,onSeriesMouseClick:K,labelOrder:te,maxBarThickness:re,minBarThickness:X,resetSelectionOnDoubleClick:pe,detailsOnClick:oe,barAxisTitle:D,valueColor:b,noOfTicks:g,styles:w,classNames:I,dimmedOpacity:O,animate:N,precision:A,customLayers:z,naLabel:v}=ye,j=d.useRef(null),Y=He.useInView(j,{once:N.once,amount:N.amount}),S={top:xe,bottom:R,left:D?W+30:W,right:ne},[$,le]=d.useState(void 0),[H,B]=d.useState(void 0),[Q,E]=d.useState(void 0),[F,m]=d.useState(void 0),C=p-S.left-S.right,h=U-S.top-S.bottom,c=Ue.linear().domain([ae,L]).range([h,0]).nice(),x=o.map((t,r)=>({...t,id:te?`${t.label}`:`${r}`})),u=te||x.map(t=>`${t.id}`),s=$e.band().domain(u).range([0,X?Math.max(C,X*u.length):re?Math.min(C,re*u.length):C]).paddingInner(de),n=c.ticks(g);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:j,width:`${p}px`,height:`${U}px`,viewBox:`0 0 ${p} ${U}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${S.left},${S.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:c(ae<0?0:ae),y2:c(ae<0?0:ae),x1:0-W,x2:C+S.right,label:De.numberFormattingFunction(ae<0?0:ae,v,A,me,q),labelPos:{x:0-W,dx:0,dy:L<0?"1em":-5,y:c(ae<0?0:ae)},classNames:{axis:I?.xAxis?.axis,label:I?.yAxis?.labels},styles:{axis:w?.xAxis?.axis,label:w?.yAxis?.labels}}),G?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:n.filter(t=>t!==0),y:n.filter(t=>t!==0).map(t=>c(t)),x1:0-W,x2:C+S.right,styles:{gridLines:w?.yAxis?.gridLines,labels:w?.yAxis?.labels},classNames:{gridLines:I?.yAxis?.gridLines,labels:I?.yAxis?.labels},suffix:q,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:A}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-W-15,y:h/2,style:w?.yAxis?.title,className:I?.yAxis?.title,text:D,rotate90:!0}),z.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[x.map((t,r)=>P.checkIfNullOrUndefined(s(t.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",initial:"initial",animate:Y?"whileInView":"initial",variants:{initial:{opacity:y?t.color&&T[ie.indexOf(t.color)]===y?1:O:se.length!==0?se.indexOf(t.label)!==-1?.85:O:.85},whileInView:{opacity:y?t.color&&T[ie.indexOf(t.color)]===y?1:O:se.length!==0?se.indexOf(t.label)!==-1?.85:O:.85,transition:{duration:N.duration}}},exit:{opacity:0,transition:{duration:N.duration}},onMouseEnter:f=>{le(t),m(f.clientY),E(f.clientX),ee?.(t)},onClick:()=>{(K||oe)&&(Ae.isEqual(H,t)&&pe?(B(void 0),K?.(void 0)):(B(t),K?.(t)))},onMouseMove:f=>{le(t),m(f.clientY),E(f.clientX)},onMouseLeave:()=>{le(void 0),E(void 0),m(void 0),ee?.(void 0)},children:[t.size?e.jsxRuntimeExports.jsx(fe.motion.rect,{width:s.bandwidth(),initial:"initial",animate:Y?"whileInView":"initial",variants:{initial:{height:0,x:s(`${t.id}`),y:c(0),fill:o.filter(f=>f.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ee.Colors.gray},whileInView:{height:t.size?Math.abs(c(t.size)-c(0)):0,y:t.size&&t.size>0?c(t.size):c(0),x:s(`${t.id}`),fill:o.filter(f=>f.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ee.Colors.gray,transition:{duration:N.duration}}},exit:{height:0,y:c(0),transition:{duration:N.duration}}}):null,he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${t.label}`.length<M?`${t.label}`:`${`${t.label}`.substring(0,M)}...`,y:(t.size||0)<0?0:c(0)+5,x:s(`${t.id}`),width:s.bandwidth(),height:(t.size||0)<0?c(0)-5:S.bottom,style:w?.xAxis?.labels,className:I?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:N,isInView:Y}):null,Z?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{textAnchor:"middle",...w?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!b&&T.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",I?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",variants:{initial:{x:s(`${t.id}`)+s.bandwidth()/2,y:c(0),opacity:0,fill:b||(o.filter(f=>f.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ee.Colors.gray)},whileInView:{x:s(`${t.id}`)+s.bandwidth()/2,y:c(t.size||0),fill:b||(o.filter(f=>f.color).length===0?T[0]:t.color?T[ie.indexOf(t.color)]:Ee.Colors.gray),opacity:1,transition:{duration:N.duration}}},initial:"initial",animate:Y?"whileInView":"initial",exit:{opacity:0,transition:{duration:N.duration}},children:De.numberFormattingFunction(t.size,v,A,me,q)}):null]},t.label)),k?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:k.map((t,r)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:t.text,color:t.color,y:c(t.value),x1:0-W,x2:C+S.right,classNames:t.classNames,styles:t.styles,animate:N,isInView:Y},r))}):null]}),z.filter(t=>t.position==="after").map(t=>t.layer)]})}),$&&J&&Q&&F?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:$,body:J,xPos:Q,yPos:F,backgroundStyle:w?.tooltip,className:I?.tooltip}):null,oe&&H!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:H!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof oe=="string"?{__html:Le.string2HTML(oe,H)}:void 0,children:typeof oe=="function"?oe(H):null})}):null]})}function ct(ye){const{data:o,graphTitle:p,colors:U,barPadding:T=.25,showTicks:q=!0,leftMargin:me=20,rightMargin:de=20,topMargin:he=20,bottomMargin:Z=25,truncateBy:G=999,showLabels:ie=!0,showValues:M=!0,backgroundColor:ne=!1,suffix:xe="",prefix:R="",sources:W,graphDescription:J,height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe=!0,graphID:oe,maxValue:D,minValue:b,highlightedDataPoints:g=[],onSeriesMouseClick:w,graphDownload:I=!1,dataDownload:O=!1,language:N="en",theme:A="light",sortData:z,labelOrder:v,showNAColor:j=!0,minHeight:Y=0,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:le,ariaLabel:H,resetSelectionOnDoubleClick:B=!0,detailsOnClick:Q,barAxisTitle:E,noOfTicks:F=5,valueColor:m,styles:C,classNames:h,filterNA:c=!0,animate:x=!1,dimmedOpacity:u=.3,precision:s=2,customLayers:n=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:r="NA"}=ye,[f,we]=d.useState(0),[ue,_]=d.useState(0),[ge,Ne]=d.useState(t.autoplay),ce=Re.sort(Se.uniqBy(o.filter(a=>a.date!==void 0&&a.date!==null),a=>a.date).map(a=>ke.parse(`${a.date}`,t.dateFormat||"yyyy",new Date).getTime()),(a,ve)=>_e.ascending(a,ve)),[be,je]=d.useState(t.autoplay?0:ce.length-1),[Me,l]=d.useState(void 0),i=d.useRef(null),V=d.useRef(null);d.useEffect(()=>{const a=new ResizeObserver(ve=>{we(k||ve[0].target.clientWidth||620),_(ee||ve[0].target.clientHeight||480)});return i.current&&(_(i.current.clientHeight||480),we(i.current.clientWidth||620),k||a.observe(i.current)),()=>a.disconnect()},[k,ee]),d.useEffect(()=>{const a=setInterval(()=>{je(ve=>ve<ce.length-1?ve+1:0)},(t.speed||2)*1e3);return ge||clearInterval(a),()=>clearInterval(a)},[ce,ge,t.speed]);const Je=Re.getSliderMarks(ce,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${A||"light"} flex ${k?"w-fit grow-0":"w-full grow"}`,dir:N==="he"||N==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${ne?ne===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${N||"en"}`,h?.graphContainer),style:{...C?.graphContainer||{},...ne&&ne!==!0?{backgroundColor:ne}:{}},id:oe,ref:V,"aria-label":H||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${J?` ${J}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:ne?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||J||I||O?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:h?.title,description:h?.description},graphTitle:p,graphDescription:J,width:k,graphDownload:I?V.current:void 0,dataDownload:O?o.map(a=>a.data).filter(a=>a!==void 0).length>0?o.map(a=>a.data).filter(a=>a!==void 0):o.filter(a=>a!==void 0):null}):null,t.enabled&&ce.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ne(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ce[0],max:ce[ce.length-1],marks:Je,step:null,defaultValue:ce[ce.length-1],value:ce[be],onChangeComplete:a=>{je(ce.indexOf(a))},onChange:a=>{je(ce.indexOf(a))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[pe&&o.filter(a=>a.color).length!==0?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:k,colorLegendTitle:ae,colors:U||Ee.Colors[A].categoricalColors.colors,colorDomain:L||Se.uniqBy(o.filter(a=>a.color),"color").map(a=>a.color),setSelectedColor:l,showNAColor:j}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:i,"aria-label":"Graph area",children:(k||f)&&(ee||ue)?e.jsxRuntimeExports.jsx(ut,{data:z==="asc"?Qe.sortBy(Oe.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(a=>t.enabled?a.date===ke.format(new Date(ce[be]),t.dateFormat||"yyyy"):a).filter(a=>c?!P.checkIfNullOrUndefined(a.size):a),a=>a.size).filter((a,ve)=>$?ve<$:!0):z==="desc"?Qe.sortBy(Oe.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(a=>t.enabled?a.date===ke.format(new Date(ce[be]),t.dateFormat||"yyyy"):a).filter(a=>c?!P.checkIfNullOrUndefined(a.size):a),a=>a.size).reverse().filter((a,ve)=>$?ve<$:!0):Oe.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(a=>t.enabled?a.date===ke.format(new Date(ce[be]),t.dateFormat||"yyyy"):a).filter(a=>c?!P.checkIfNullOrUndefined(a.size):a).filter((a,ve)=>$?ve<$:!0),barColor:o.filter(a=>a.color).length===0?U?[U]:[Ee.Colors.primaryColors["blue-600"]]:U||Ee.Colors[A].categoricalColors.colors,colorDomain:o.filter(a=>a.color).length===0?[]:L||Se.uniqBy(o.filter(a=>a.color),"color").map(a=>a.color),width:k||f,refValues:X,height:Math.max(Y,ee||(K?Y?(k||f)*K>Y?(k||f)*K:Y:(k||f)*K:ue)),suffix:xe,prefix:R,barPadding:T,showLabels:ie,showValues:M,showTicks:q,truncateBy:G,leftMargin:me,rightMargin:de,selectedColor:Me,topMargin:he,bottomMargin:Z,tooltip:te,onSeriesMouseOver:re,maxValue:P.checkIfNullOrUndefined(D)?Math.max(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size))<0?0:Math.max(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size)):D,minValue:P.checkIfNullOrUndefined(b)?Math.min(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size))>=0?0:Math.min(...o.filter(a=>!P.checkIfNullOrUndefined(a.size)).map(a=>a.size)):b,highlightedDataPoints:g,onSeriesMouseClick:w,labelOrder:v,maxBarThickness:S,minBarThickness:le,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:E,noOfTicks:F,valueColor:m,styles:C,classNames:h,animate:x===!0?{duration:.5,once:!0,amount:.5}:x||{duration:0,once:!0,amount:0},dimmedOpacity:u,precision:s,customLayers:n,naLabel:r}):null})]})}),W||y?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:W,footNote:y,width:k}):null]})})})})}function xt(ye){const{data:o,width:p,height:U,barColors:T,suffix:q,prefix:me,barPadding:de,showLabels:he,showValues:Z,showTicks:G,truncateBy:ie,leftMargin:M,rightMargin:ne,topMargin:xe,bottomMargin:R,tooltip:W,onSeriesMouseOver:J,refValues:ee,maxValue:k,minValue:y,onSeriesMouseClick:L,selectedColor:ae,labelOrder:se,maxBarThickness:K,resetSelectionOnDoubleClick:te,detailsOnClick:re,barAxisTitle:X,valueColor:pe,noOfTicks:oe,styles:D,classNames:b,animate:g,colorDomain:w,precision:I,customLayers:O,naLabel:N}=ye,A=d.useRef(null),z=He.useInView(A,{once:g.once,amount:g.amount}),v={top:xe,bottom:R,left:X?M+30:M,right:ne},[j,Y]=d.useState(void 0),[S,$]=d.useState(void 0),[le,H]=d.useState(void 0),[B,Q]=d.useState(void 0),E=p-v.left-v.right,F=U-v.top-v.bottom,m=Ue.linear().domain([y,k]).range([F,0]).nice(),C=o.map((s,n)=>({...s,id:se?`${s.label}`:`${n}`})),h=se||C.map(s=>`${s.id}`),c=$e.band().domain(h).range([0,K?Math.min(E,K*h.length):E]).paddingInner(de),x=$e.band().domain(o[0].size.map((s,n)=>`${n}`)).range([0,c.bandwidth()]).paddingInner(.1),u=m.ticks(oe);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{width:`${p}px`,height:`${U}px`,viewBox:`0 0 ${p} ${U}`,direction:"ltr",ref:A,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:m(y<0?0:y),y2:m(y<0?0:y),x1:0-M,x2:E+v.right,label:De.numberFormattingFunction(y<0?0:y,N,I,me,q),labelPos:{x:0-M,dx:0,dy:k<0?"1em":-5,y:m(y<0?0:y)},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels}}),G?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:u.filter(s=>s!==0),y:u.filter(s=>s!==0).map(s=>m(s)),x1:0-M,x2:E+v.right,styles:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:q,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:I}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-M-15,y:F/2,style:D?.yAxis?.title,className:b?.yAxis?.title,text:X,rotate90:!0}),O.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[C.map(s=>P.checkIfNullOrUndefined(c(s.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{variants:{initial:{x:c(`${s.id}`),y:0},whileInView:{x:c(`${s.id}`),y:0,transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[s.size.map((n,t)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?T[t]===ae?1:.3:.85,onMouseEnter:r=>{Y({...s,sizeIndex:t}),Q(r.clientY),H(r.clientX),J?.({...s,sizeIndex:t})},onMouseMove:r=>{Y({...s,sizeIndex:t}),Q(r.clientY),H(r.clientX)},onMouseLeave:()=>{Y(void 0),H(void 0),Q(void 0),J?.(void 0)},onClick:()=>{(L||re)&&(Ae.isEqual(S,{...s,sizeIndex:t})&&te?($(void 0),L?.(void 0)):($({...s,sizeIndex:t}),L&&L({...s,sizeIndex:t})))},children:[e.jsxRuntimeExports.jsx(fe.motion.rect,{x:x(`${t}`),width:x.bandwidth(),variants:{initial:{height:0,y:m(0),fill:T[t]},whileInView:{height:P.checkIfNullOrUndefined(n)?0:Math.abs(m(n)-m(0)),y:P.checkIfNullOrUndefined(n)?m(0):n>0?m(n):m(0),fill:T[t],transition:{duration:g.duration}}},exit:{height:0,y:m(0),transition:{duration:g.duration}},initial:"initial",animate:z?"whileInView":"initial"}),Z?e.jsxRuntimeExports.jsx(fe.motion.text,{x:x(`${t}`)+x.bandwidth()/2,style:{fill:pe||T[t],textAnchor:"middle",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:n?n>=0?"-5px":"1em":"-5px",variants:{initial:{y:m(0),opacity:0},whileInView:{y:m(n||0),opacity:1,transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:De.numberFormattingFunction(n,N,I,me,q)}):null]},`${s.label}-${w[t]||t}`)),he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${s.label}`.length<ie?`${s.label}`:`${`${s.label}`.substring(0,ie)}...`,y:m(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:D?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:z}):null]},s.label)),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((s,n)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:s.text,color:s.color,y:m(s.value),x1:0-M,x2:E+v.right,classNames:s.classNames,styles:s.styles,animate:g,isInView:z},n))}):null]}),O.filter(s=>s.position==="after").map(s=>s.layer)]})}),j&&W&&le&&B?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:j,body:W,xPos:le,yPos:B,backgroundStyle:D?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:S!==void 0,onClose:()=>{$(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Le.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function dt(ye){const{data:o,graphTitle:p,colors:U=Ee.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Z=20,topMargin:G=20,bottomMargin:ie=25,truncateBy:M=999,showLabels:ne=!0,showValues:xe=!0,backgroundColor:R=!1,suffix:W="",prefix:J="",height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:D,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:I="en",theme:O="light",labelOrder:N,minHeight:A=0,maxBarThickness:z,ariaLabel:v,resetSelectionOnDoubleClick:j=!0,detailsOnClick:Y,barAxisTitle:S,noOfTicks:$=5,valueColor:le,styles:H,classNames:B,filterNA:Q=!0,showColorScale:E=!0,animate:F=!1,precision:m=2,customLayers:C=[],timeline:h={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA",sortParameter:x,sortData:u}=ye,[s,n]=d.useState(0),[t,r]=d.useState(0),[f,we]=d.useState(h.autoplay),ue=Re.sort(Se.uniqBy(o.filter(l=>l.date!==void 0&&l.date!==null),l=>l.date).map(l=>ke.parse(`${l.date}`,h.dateFormat||"yyyy",new Date).getTime()),(l,i)=>_e.ascending(l,i)),[_,ge]=d.useState(h.autoplay?0:ue.length-1),[Ne,ce]=d.useState(void 0),be=d.useRef(null),je=d.useRef(null);d.useEffect(()=>{const l=new ResizeObserver(i=>{n(k||i[0].target.clientWidth||620),r(ee||i[0].target.clientHeight||480)});return be.current&&(r(be.current.clientHeight||480),n(be.current.clientWidth||620),k||l.observe(be.current)),()=>l.disconnect()},[k,ee]),d.useEffect(()=>{const l=setInterval(()=>{ge(i=>i<ue.length-1?i+1:0)},(h.speed||2)*1e3);return f||clearInterval(l),()=>clearInterval(l)},[ue,f,h.speed]);const Me=Re.getSliderMarks(ue,_,h.showOnlyActiveDate,h.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${O||"light"} flex ${k?"w-fit grow-0":"w-full grow"}`,dir:I==="he"||I==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${R?R===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${I||"en"}`,B?.graphContainer),style:{...H?.graphContainer||{},...R&&R!==!0?{backgroundColor:R}:{}},id:pe,ref:je,"aria-label":v||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:R?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||q||g||w?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:H?.title,description:H?.description},classNames:{title:B?.title,description:B?.description},graphTitle:p,graphDescription:q,width:k,graphDownload:g?je.current:void 0,dataDownload:w?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,h.enabled&&ue.length>0&&Me?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!f)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":f?"Click to pause animation":"Click to play animation",children:f?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:ue[0],max:ue[ue.length-1],marks:Me,step:null,defaultValue:ue[ue.length-1],value:ue[_],onChangeComplete:l=>{ge(ue.indexOf(l))},onChange:l=>{ge(ue.indexOf(l))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[E?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:k,colorDomain:L,colors:U,colorLegendTitle:ae,setSelectedColor:ce,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:be,"aria-label":"Graph area",children:(k||s)&&(ee||t)?e.jsxRuntimeExports.jsx(xt,{data:x!==void 0?x==="total"?Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===ke.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>Q?!l.size.every(i=>i==null):l),l=>Ce.sum(l.size.filter(i=>!P.checkIfNullOrUndefined(i))),[u||"asc"]):Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===ke.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>Q?!l.size.every(i=>i==null):l),l=>P.checkIfNullOrUndefined(l.size[x])?-1/0:l.size[x],[u||"asc"]):Oe.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>Q?!l.size.every(i=>i==null):l),barColors:U,width:k||s,height:Math.max(A,ee||(K?A?(k||s)*K>A?(k||s)*K:A:(k||s)*K:t)),suffix:W,prefix:J,barPadding:me,showLabels:ne,showValues:xe,showTicks:de,truncateBy:M,leftMargin:he,rightMargin:Z,topMargin:G,bottomMargin:ie,tooltip:te,onSeriesMouseOver:re,refValues:X,maxValue:P.checkIfNullOrUndefined(oe)?Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!P.checkIfNullOrUndefined(i)))))<0?0:Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!P.checkIfNullOrUndefined(i))))):oe,minValue:P.checkIfNullOrUndefined(D)?Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!P.checkIfNullOrUndefined(i)))))>=0?0:Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!P.checkIfNullOrUndefined(i))))):D,onSeriesMouseClick:b,selectedColor:Ne,labelOrder:N,maxBarThickness:z,resetSelectionOnDoubleClick:j,detailsOnClick:Y,barAxisTitle:S,noOfTicks:$,valueColor:le,styles:H,classNames:B,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},colorDomain:L,precision:m,customLayers:C,naLabel:c}):null})]})}),T||y?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:H?.footnote,source:H?.source},classNames:{footnote:B?.footnote,source:B?.source},sources:T,footNote:y,width:k}):null]})})})})}function mt(ye){const{data:o,width:p,height:U,barColors:T,barPadding:q,showLabels:me,showTicks:de,truncateBy:he,leftMargin:Z,topMargin:G,bottomMargin:ie,rightMargin:M,tooltip:ne,onSeriesMouseOver:xe,suffix:R,prefix:W,showValues:J,refValues:ee,maxValue:k,onSeriesMouseClick:y,selectedColor:L,labelOrder:ae,maxBarThickness:se,minBarThickness:K,resetSelectionOnDoubleClick:te,detailsOnClick:re,barAxisTitle:X,valueColor:pe,noOfTicks:oe,styles:D,classNames:b,animate:g,colorDomain:w,precision:I,customLayers:O,naLabel:N}=ye,A=d.useRef(null),z=He.useInView(A,{once:g.once,amount:g.amount}),v={top:G,bottom:ie,left:X?Z+30:Z,right:M},[j,Y]=d.useState(void 0),[S,$]=d.useState(void 0),[le,H]=d.useState(void 0),[B,Q]=d.useState(void 0),E=p-v.left-v.right,F=U-v.top-v.bottom,m=Ue.linear().domain([0,k]).range([F,0]).nice(),C=o.map((u,s)=>({...u,id:ae?`${u.label}`:`${s}`})),h=ae||C.map(u=>`${u.id}`),c=$e.band().domain(h).range([0,K?Math.max(E,K*h.length):se?Math.min(E,se*h.length):E]).paddingInner(q),x=m.ticks(oe);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{width:`${p}px`,height:`${U}px`,viewBox:`0 0 ${p} ${U}`,direction:"ltr",ref:A,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:m(0),y2:m(0),x1:0-Z,x2:E+v.right,label:De.numberFormattingFunction(0,N,I,W,R),labelPos:{x:0-Z,y:m(0),dx:0,dy:-5},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels}}),de?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:x.filter(u=>u!==0),y:x.filter(u=>u!==0).map(u=>m(u)),x1:0-Z,x2:E+v.right,styles:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:R,prefix:W,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:I}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-Z-15,y:F/2,style:D?.yAxis?.title,className:b?.yAxis?.title,text:X,rotate90:!0}),O.filter(u=>u.position==="before").map(u=>u.layer),e.jsxRuntimeExports.jsxs(qe.AnimatePresence,{children:[C.map(u=>P.checkIfNullOrUndefined(c(u.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:c(`${u.id}`),y:0},whileInView:{x:c(`${u.id}`),y:0,transition:{duration:g.duration}}},transition:{duration:g.duration},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[u.size.map((s,n)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{opacity:L?T[n]===L?1:.3:1,onMouseEnter:t=>{Y({...u,sizeIndex:n}),Q(t.clientY),H(t.clientX),xe?.({...u,sizeIndex:n})},onMouseMove:t=>{Y({...u,sizeIndex:n}),Q(t.clientY),H(t.clientX)},onMouseLeave:()=>{Y(void 0),H(void 0),Q(void 0),xe?.(void 0)},onClick:()=>{(y||re)&&(Ae.isEqual(S,{...u,sizeIndex:n})&&te?($(void 0),y?.(void 0)):($({...u,sizeIndex:n}),y&&y({...u,sizeIndex:n})))},children:[e.jsxRuntimeExports.jsx(fe.motion.rect,{x:0,width:c.bandwidth(),variants:{initial:{height:0,fill:T[n],y:m(0)},whileInView:{height:Math.abs(m(Ce.sum(u.size.filter((t,r)=>r<=n&&t)))-m(Ce.sum(u.size.filter((t,r)=>r<n&&t)))),y:m(Ce.sum(u.size.filter((t,r)=>r<=n&&t))),fill:T[n],transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{height:0,y:m(0),transition:{duration:g.duration}}}),J?e.jsxRuntimeExports.jsx(fe.motion.text,{x:c.bandwidth()/2,style:{fill:Ke.getTextColorBasedOnBgColor(T[n]),textAnchor:"middle",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:"0.33em",variants:{initial:{y:m(0),opacity:0,fill:Ke.getTextColorBasedOnBgColor(T[n])},whileInView:{y:m(Ce.sum(u.size.filter((t,r)=>r<=n&&t)))+Math.abs(m(Ce.sum(u.size.filter((t,r)=>r<=n&&t)))-m(Ce.sum(u.size.filter((t,r)=>r<n&&t))))/2,opacity:s&&Math.abs(m(Ce.sum(u.size.filter((t,r)=>r<=n&&t)))-m(Ce.sum(u.size.filter((t,r)=>r<n&&t))))>20?1:0,fill:Ke.getTextColorBasedOnBgColor(T[n]),transition:{duration:g.duration}}},initial:"initial",animate:z?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:De.numberFormattingFunction(s,N,I,W,R)}):null]},`${u.label}-${w[n]||n}`)),me?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${u.label}`.length<he?`${u.label}`:`${`${u.label}`.substring(0,he)}...`,y:m(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:D?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:z}):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{...pe&&{fill:pe},textAnchor:"middle",...D?.graphObjectValues||{}},x:c.bandwidth()/2,dy:-10,className:e.mo("graph-value graph-value-total",pe?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",b?.graphObjectValues),variants:{initial:{y:m(0),opacity:0},whileInView:{y:m(Ce.sum(u.size.map(s=>s||0))),opacity:1,transition:{duration:g.duration}}},exit:{opacity:0,transition:{duration:g.duration}},initial:"initial",animate:z?"whileInView":"initial",children:De.numberFormattingFunction(Ce.sum(u.size.filter(s=>s)),N,I,W,R)}):null]},u.label)),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((u,s)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:u.text,color:u.color,y:m(u.value),x1:0-Z,x2:E+v.right,classNames:u.classNames,styles:u.styles,animate:g,isInView:z},s))}):null]}),O.filter(u=>u.position==="after").map(u=>u.layer)]})}),j&&ne&&le&&B?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:j,body:ne,xPos:le,yPos:B,backgroundStyle:D?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:S!==void 0,onClose:()=>{$(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Le.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function ht(ye){const{data:o,graphTitle:p,colors:U=Ee.Colors.light.categoricalColors.colors,sources:T,graphDescription:q,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Z=20,topMargin:G=20,bottomMargin:ie=25,truncateBy:M=999,showLabels:ne=!0,showValues:xe=!0,backgroundColor:R=!1,showColorScale:W=!0,suffix:J="",prefix:ee="",height:k,width:y,footNote:L,colorDomain:ae,colorLegendTitle:se,padding:K,tooltip:te,onSeriesMouseOver:re,relativeHeight:X,refValues:pe,graphID:oe,maxValue:D,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:I="en",theme:O="light",labelOrder:N,minHeight:A=0,maxBarThickness:z,sortParameter:v,maxNumberOfBars:j,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:$=!0,detailsOnClick:le,barAxisTitle:H,noOfTicks:B=5,valueColor:Q,styles:E,classNames:F,filterNA:m=!0,animate:C=!1,precision:h=2,customLayers:c=[],timeline:x={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:u="NA",sortData:s}=ye,[n,t]=d.useState(0),[r,f]=d.useState(0),[we,ue]=d.useState(x.autoplay),_=Re.sort(Se.uniqBy(o.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>ke.parse(`${i.date}`,x.dateFormat||"yyyy",new Date).getTime()),(i,V)=>_e.ascending(i,V)),[ge,Ne]=d.useState(x.autoplay?0:_.length-1),[ce,be]=d.useState(void 0),je=d.useRef(null),Me=d.useRef(null);d.useEffect(()=>{const i=new ResizeObserver(V=>{t(y||V[0].target.clientWidth||620),f(k||V[0].target.clientHeight||480)});return je.current&&(f(je.current.clientHeight||480),t(je.current.clientWidth||620),y||i.observe(je.current)),()=>i.disconnect()},[y,k]),d.useEffect(()=>{const i=setInterval(()=>{Ne(V=>V<_.length-1?V+1:0)},(x.speed||2)*1e3);return we||clearInterval(i),()=>clearInterval(i)},[_,we,x.speed]);const l=Re.getSliderMarks(_,ge,x.showOnlyActiveDate,x.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${O||"light"} flex ${y?"w-fit grow-0":"w-full grow"}`,dir:I==="he"||I==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${R?R===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${I||"en"}`,F?.graphContainer),style:{...E?.graphContainer||{},...R&&R!==!0?{backgroundColor:R}:{}},id:oe,ref:Me,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{style:{padding:R?K||"1rem":K||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||q||g||w?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:q,width:y,graphDownload:g?Me.current:void 0,dataDownload:w?o.map(i=>i.data).filter(i=>i!==void 0).length>0?o.map(i=>i.data).filter(i=>i!==void 0):o.filter(i=>i!==void 0):null}):null,x.enabled&&_.length>0&&l?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{ue(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:_[0],max:_[_.length-1],marks:l,step:null,defaultValue:_[_.length-1],value:_[ge],onChangeComplete:i=>{Ne(_.indexOf(i))},onChange:i=>{Ne(_.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[W?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:y,colorDomain:ae,colors:U,colorLegendTitle:se,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:je,"aria-label":"Graph area",children:(y||n)&&(k||r)?e.jsxRuntimeExports.jsx(mt,{data:v!==void 0?v==="total"?Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===ke.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(V=>V==null):i),i=>Ce.sum(i.size.filter(V=>!P.checkIfNullOrUndefined(V))),[s||"asc"]).filter((i,V)=>j?V<j:!0):Te.orderBy(Oe.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===ke.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(V=>V==null):i),i=>P.checkIfNullOrUndefined(i.size[v])?-1/0:i.size[v],[s||"asc"]).filter((i,V)=>j?V<j:!0):Oe.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>m?!i.size.every(V=>V==null):i).filter((i,V)=>j?V<j:!0),barColors:U,width:y||n,height:Math.max(A,k||(X?A?(y||n)*X>A?(y||n)*X:A:(y||n)*X:r)),barPadding:me,showLabels:ne,showTicks:de,truncateBy:M,leftMargin:he,rightMargin:Z,topMargin:G,bottomMargin:ie,tooltip:te,onSeriesMouseOver:re,showValues:xe,suffix:J,prefix:ee,refValues:pe,maxValue:P.checkIfNullOrUndefined(D)?Math.max(...o.map(i=>Ce.sum(i.size.filter(V=>!P.checkIfNullOrUndefined(V)))||0)):D,onSeriesMouseClick:b,selectedColor:ce,labelOrder:N,maxBarThickness:z,minBarThickness:Y,resetSelectionOnDoubleClick:$,detailsOnClick:le,barAxisTitle:H,noOfTicks:B,valueColor:Q,styles:E,classNames:F,animate:C===!0?{duration:.5,once:!0,amount:.5}:C||{duration:0,once:!0,amount:0},colorDomain:ae,precision:h,customLayers:c,naLabel:u}):null})]})}),T||L?e.jsxRuntimeExports.jsx(Ge.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:T,footNote:L,width:y}):null]})})})})}function pt(ye){const{data:o,graphTitle:p,colors:U,barPadding:T,showTicks:q,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:G,showLabels:ie,showValues:M,backgroundColor:ne,suffix:xe,prefix:R,sources:W,graphDescription:J,height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:D,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:I,dataDownload:O,language:N,theme:A,sortData:z,labelOrder:v,showNAColor:j,minHeight:Y,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:le,ariaLabel:H,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:E,noOfTicks:F,valueColor:m,orientation:C="vertical",styles:h,classNames:c,filterNA:x,animate:u,dimmedOpacity:s,precision:n,customLayers:t,timeline:r,naLabel:f}=ye;return C==="vertical"?e.jsxRuntimeExports.jsx(ct,{data:o,graphTitle:p,colors:U,barPadding:T,showTicks:q,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:G,showLabels:ie,showValues:M,backgroundColor:ne,suffix:xe,prefix:R,sources:W,graphDescription:J,height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:D,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:I,dataDownload:O,language:N,theme:A,sortData:z,labelOrder:v,showNAColor:j,minHeight:Y,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:le,ariaLabel:H,resetSelectionOnDoubleClick:B,styles:h,detailsOnClick:Q,barAxisTitle:E,noOfTicks:F,valueColor:m,classNames:c,filterNA:x,animate:u,dimmedOpacity:s,precision:n,customLayers:t,timeline:r}):e.jsxRuntimeExports.jsx(st,{data:o,graphTitle:p,colors:U,barPadding:T,showTicks:q,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:G,showLabels:ie,showValues:M,backgroundColor:ne,suffix:xe,prefix:R,sources:W,graphDescription:J,height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:D,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:I,dataDownload:O,language:N,theme:A,sortData:z,labelOrder:v,showNAColor:j,minHeight:Y,maxBarThickness:S,maxNumberOfBars:$,minBarThickness:le,ariaLabel:H,resetSelectionOnDoubleClick:B,styles:h,detailsOnClick:Q,barAxisTitle:E,noOfTicks:F,valueColor:m,classNames:c,filterNA:x,dimmedOpacity:s,precision:n,customLayers:t,timeline:r,naLabel:f})}function gt(ye){const{data:o,graphTitle:p,colors:U,sources:T,graphDescription:q,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:G,footNote:ie,colorDomain:M,colorLegendTitle:ne,suffix:xe,prefix:R,showValues:W,padding:J,backgroundColor:ee,leftMargin:k,rightMargin:y,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:D,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:I,labelOrder:O,minHeight:N,theme:A,sortParameter:z,sortData:v,maxBarThickness:j,ariaLabel:Y,resetSelectionOnDoubleClick:S,detailsOnClick:$,barAxisTitle:le,noOfTicks:H,valueColor:B,orientation:Q="vertical",styles:E,classNames:F,filterNA:m,animate:C,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:s}=ye;return Q==="vertical"?e.jsxRuntimeExports.jsx(dt,{data:o,graphTitle:p,colors:U,sources:T,graphDescription:q,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:G,footNote:ie,colorDomain:M,colorLegendTitle:ne,suffix:xe,prefix:R,showValues:W,padding:J,backgroundColor:ee,leftMargin:k,rightMargin:y,sortParameter:z,sortData:v,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:D,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:I,labelOrder:O,minHeight:N,theme:A,maxBarThickness:j,ariaLabel:Y,resetSelectionOnDoubleClick:S,styles:E,detailsOnClick:$,barAxisTitle:le,noOfTicks:H,valueColor:B,classNames:F,filterNA:m,animate:C,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:s}):e.jsxRuntimeExports.jsx(nt,{data:o,graphTitle:p,colors:U,sortParameter:z,sortData:v,sources:T,graphDescription:q,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:G,footNote:ie,colorDomain:M,colorLegendTitle:ne,suffix:xe,prefix:R,showValues:W,padding:J,backgroundColor:ee,leftMargin:k,rightMargin:y,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:D,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:I,labelOrder:O,minHeight:N,theme:A,maxBarThickness:j,ariaLabel:Y,resetSelectionOnDoubleClick:S,styles:E,detailsOnClick:$,barAxisTitle:le,noOfTicks:H,valueColor:B,classNames:F,filterNA:m,animate:C,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:s})}function ft(ye){const{data:o,graphTitle:p,colors:U,sources:T,graphDescription:q,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:G,bottomMargin:ie,truncateBy:M,showLabels:ne,showValues:xe,backgroundColor:R,suffix:W,prefix:J,height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:D,graphDownload:b,dataDownload:g,language:w,theme:I,labelOrder:O,minHeight:N,maxBarThickness:A,sortParameter:z,sortData:v,maxNumberOfBars:j,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:$,detailsOnClick:le,barAxisTitle:H,noOfTicks:B,valueColor:Q,orientation:E="vertical",styles:F,classNames:m,filterNA:C,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:s,naLabel:n}=ye;return E==="vertical"?e.jsxRuntimeExports.jsx(ht,{data:o,graphTitle:p,colors:U,sources:T,graphDescription:q,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:G,bottomMargin:ie,truncateBy:M,showLabels:ne,showValues:xe,backgroundColor:R,suffix:W,prefix:J,height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:D,graphDownload:b,dataDownload:g,language:w,theme:I,labelOrder:O,minHeight:N,maxBarThickness:A,sortParameter:z,sortData:v,maxNumberOfBars:j,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:$,styles:F,detailsOnClick:le,barAxisTitle:H,noOfTicks:B,valueColor:Q,classNames:m,filterNA:C,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:s,naLabel:n}):e.jsxRuntimeExports.jsx(ot,{data:o,graphTitle:p,colors:U,sources:T,graphDescription:q,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:G,bottomMargin:ie,truncateBy:M,showLabels:ne,showValues:xe,backgroundColor:R,suffix:W,prefix:J,height:ee,width:k,footNote:y,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:D,graphDownload:b,dataDownload:g,language:w,theme:I,labelOrder:O,minHeight:N,maxBarThickness:A,sortParameter:z,sortData:v,maxNumberOfBars:j,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:$,styles:F,detailsOnClick:le,barAxisTitle:H,noOfTicks:B,valueColor:Q,classNames:m,filterNA:C,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:s,naLabel:n})}exports.GroupedBarGraph=gt;exports.SimpleBarGraph=pt;exports.StackedBarGraph=ft;
2
2
  //# sourceMappingURL=BarGraph.cjs.map