@undp/data-viz 1.4.3 → 1.4.5
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.
- package/dist/BarGraph.cjs +1 -1
- package/dist/BarGraph.cjs.map +1 -1
- package/dist/BarGraph.d.ts +2 -0
- package/dist/BarGraph.js +1180 -1170
- package/dist/BarGraph.js.map +1 -1
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.cjs.map +1 -1
- package/dist/DumbbellChart.d.ts +2 -0
- package/dist/DumbbellChart.js +354 -345
- package/dist/DumbbellChart.js.map +1 -1
- package/dist/GraphEl-C0FNZlDn.cjs +2 -0
- package/dist/GraphEl-C0FNZlDn.cjs.map +1 -0
- package/dist/{GraphEl-BdIyscdt.js → GraphEl-DfPT8ffl.js} +3 -1
- package/dist/GraphEl-DfPT8ffl.js.map +1 -0
- package/dist/GriddedGraphs.cjs +1 -1
- package/dist/GriddedGraphs.js +1 -1
- package/dist/SingleGraphDashboard.cjs +1 -1
- package/dist/SingleGraphDashboard.js +1 -1
- package/dist/ThreeDGlobe.cjs +1 -1
- package/dist/ThreeDGlobe.cjs.map +1 -1
- package/dist/ThreeDGlobe.js +246 -237
- package/dist/ThreeDGlobe.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/package.json +1 -1
- package/dist/GraphEl-B5gAX1IQ.cjs +0 -2
- package/dist/GraphEl-B5gAX1IQ.cjs.map +0 -1
- package/dist/GraphEl-BdIyscdt.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"),Se=require("./index-CZbIGs8q.cjs"),m=require("react"),De=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"),Qe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Ze=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"),Ge=require("./index-BW8iNx7E.cjs"),ge=require("./proxy-BHRoeZgd.cjs"),qe=require("./GraphFooter.cjs"),Ue=require("./GraphHeader.cjs"),We=require("./ColorLegendWithMouseOver.cjs"),Xe=require("./EmptyState-d8_8SxeW.cjs"),Ie=require("./index-BW_-wD2k.cjs"),Ne=require("./ensureCompleteData-DqWQ2Zbi.cjs"),Ye=require("./init-DU0ybBc_.cjs"),ke=require("./index-C21TvELx.cjs"),Ke=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),et=require("./XAxesLabels-OjBNl_lS.cjs"),tt=require("./YTicksAndGridLines-DBDuz6vb.cjs");function it(fe){const{data:l,barColor:p,suffix:H,prefix:A,barPadding:G,showValues:me,showTicks:de,leftMargin:he,truncateBy:Q,width:q,height:ie,colorDomain:I,rightMargin:oe,topMargin:xe,bottomMargin:C,showLabels:U,tooltip:_,onSeriesMouseOver:Z,refValues:E,selectedColor:f,highlightedDataPoints:L,maxValue:ae,minValue:se,onSeriesMouseClick:J,labelOrder:ee,rtl:ne,maxBarThickness:W,minBarThickness:pe,resetSelectionOnDoubleClick:ce,detailsOnClick:S,barAxisTitle:b,valueColor:g,noOfTicks:w,styles:D,classNames:N,animate:M,dimmedOpacity:z,precision:V,customLayers:v,naLabel:j}=fe,X=m.useRef(null),$=Pe.useInView(X,{once:M.once,amount:M.amount}),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),[F,h]=m.useState(void 0),k={top:b?xe+25:xe,bottom:C,left:he,right:oe},y=q-k.left-k.right,c=ie-k.top-k.bottom,d=l.map((s,x)=>({...s,id:ee?`${s.label}`:`${x}`})),o=He.linear().domain([se,ae]).range([0,y]).nice(),a=ee||d.map(s=>`${s.id}`),r=$e.band().domain(a).range([0,pe?Math.max(c,pe*a.length):W?Math.min(c,W*a.length):c]).paddingInner(G),t=o.ticks(w);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:X,width:`${q}px`,height:`${ie}px`,viewBox:`0 0 ${q} ${ie}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${k.left},${k.top})`,children:[de?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:t.filter(s=>s!==0),x:t.filter(s=>s!==0).map(s=>o(s)),y1:0-xe,y2:c+k.bottom,styles:{gridLines:D?.xAxis?.gridLines,labels:D?.xAxis?.labels},classNames:{gridLines:N?.xAxis?.gridLines,labels:N?.xAxis?.labels},suffix:H,prefix:A,labelType:"secondary",showGridLines:!0,precision:V}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:y/2,y:0-k.top+15,style:D?.xAxis?.title,className:N?.xAxis?.title,text:b}),v.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[d.map(s=>Y.checkIfNullOrUndefined(r(s.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:f?s.color&&p[I.indexOf(s.color)]===f?1:z:L.length!==0?L.indexOf(s.label)!==-1?.85:z:.85},whileInView:{opacity:f?s.color&&p[I.indexOf(s.color)]===f?1:z:L.length!==0?L.indexOf(s.label)!==-1?.85:z:.85,transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},onMouseEnter:x=>{ue(s),h(x.clientY),R(x.clientX),Z?.(s)},onClick:()=>{(J||S)&&(Te.isEqual(P,s)&&ce?(B(void 0),J?.(void 0)):(B(s),J?.(s)))},onMouseMove:x=>{ue(s),h(x.clientY),R(x.clientX)},onMouseLeave:()=>{ue(void 0),R(void 0),h(void 0),Z?.(void 0)},children:[s.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{variants:{initial:{width:0,x:o(0),y:r(`${s.id}`),fill:l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray},whileInView:{width:s.size>=0?o(s.size)-o(0):o(0)-o(s.size),x:s.size>=0?o(0):o(s.size),y:r(`${s.id}`),fill:l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray,transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{width:0,x:o(0),transition:{duration:M.duration}},height:r.bandwidth()}):null,U?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${s.label}`.length<Q?`${s.label}`:`${`${s.label}`.substring(0,Q)}...`,y:r(s.id)||0,x:(s.size||0)<0?o(0):0-k.left,width:(s.size||0)<0?q-o(0):o(0)+k.left,height:r.bandwidth(),alignment:s.size&&s.size<0?"left":"right",style:D?.yAxis?.labels,className:N?.yAxis?.labels,animate:M,isInView:$}):null,me?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:s.size&&s.size<0?"end":"start",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!g&&p.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",N?.graphObjectValues),dx:s.size&&s.size<0?-5:5,dy:"0.33em",variants:{initial:{x:o(0),y:r(`${s.id}`)+r.bandwidth()/2,opacity:0,fill:g||(l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray)},whileInView:{x:s.size?o(s.size):o(0),opacity:1,y:r(`${s.id}`)+r.bandwidth()/2,fill:g||(l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray),transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},children:Me.numberFormattingFunction(s.size,j,V,A,H)}):null]},s.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:N?.yAxis?.axis},styles:{axis:D?.yAxis?.axis}}),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((s,x)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:s.text,color:s.color,x:o(s.value),y1:0-k.top,y2:c+k.bottom,textSide:o(s.value)>y*.75||ne?"left":"right",classNames:s.classNames,styles:s.styles,animate:M,isInView:$},x))}):null]}),v.filter(s=>s.position==="after").map(s=>s.layer)]})}),T&&_&&re&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:T,body:_,xPos:re,yPos:F,backgroundStyle:D?.tooltip,className:N?.tooltip}):null,S&&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 S=="string"?{__html:Ve.string2HTML(S,P)}:void 0,children:typeof S=="function"?S(P):null})}):null]})}function at(fe){const{data:l,graphTitle:p,colors:H,suffix:A="",sources:G,prefix:me="",graphDescription:de,barPadding:he=.25,showValues:Q=!0,showTicks:q=!0,leftMargin:ie=100,rightMargin:I=40,truncateBy:oe=999,height:xe,width:C,footNote:U,colorDomain:_,colorLegendTitle:Z,highlightedDataPoints:E=[],padding:f,backgroundColor:L=!1,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:ee,tooltip:ne,onSeriesMouseOver:W,refValues:pe,showColorScale:ce=!0,graphID:S,maxValue:b,minValue:g,onSeriesMouseClick:w,graphDownload:D=!1,dataDownload:N=!1,sortData:M,labelOrder:z,language:V="en",showNAColor:v=!0,minHeight:j=0,theme:X="light",maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:re,barAxisTitle:R,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=fe,[x,Oe]=m.useState(0),[K,je]=m.useState(0),[ve,we]=m.useState(t.autoplay),le=Re.sort(Se.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,be)=>Ye.ascending(i,be)),[ye,u]=m.useState(t.autoplay?0:le.length-1),[te,n]=m.useState(void 0),O=m.useRef(null),_e=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(be=>{Oe(C||be[0].target.clientWidth||620),je(xe||be[0].target.clientHeight||480)});return O.current&&(je(O.current.clientHeight||480),Oe(O.current.clientWidth||620),C||i.observe(O.current)),()=>i.disconnect()},[C,xe]),m.useEffect(()=>{const i=setInterval(()=>{u(be=>be<le.length-1?be+1:0)},(t.speed||2)*1e3);return ve||clearInterval(i),()=>clearInterval(i)},[le,ve,t.speed]);const Je=Re.getSliderMarks(le,ye,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:V==="he"||V==="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 ${V||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...L&&L!==!0?{backgroundColor:L}:{}},id:S,ref:_e,"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||D||N?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:D?_e.current:void 0,dataDownload:N?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&&le.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!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(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:le[0],max:le[le.length-1],marks:Je,step:null,defaultValue:le[le.length-1],value:le[ye],onChangeComplete:i=>{u(le.indexOf(i))},onChange:i=>{u(le.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:Z,colors:H||Ce.Colors[X].categoricalColors.colors,colorDomain:_||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:n,showNAColor:v}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:O,"aria-label":"Graph area",children:(C||x)&&(xe||K)?e.jsxRuntimeExports.jsx(it,{data:M==="asc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,be)=>T?be<T:!0):M==="desc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,be)=>T?be<T:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,be)=>T?be<T:!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?[]:_||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:C||x,selectedColor:te,height:Math.max(j,xe||(ee?j?(C||x)*ee>j?(C||x)*ee:j:(C||x)*ee:K)),suffix:A,prefix:me,barPadding:he,showValues:Q,showTicks:q,leftMargin:ie,rightMargin:I,topMargin:ae,bottomMargin:se,truncateBy:oe,showLabels:J,tooltip:ne,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:z,rtl:V==="he"||V==="ar",maxBarThickness:$,minBarThickness:ue,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,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:a,customLayers:r,naLabel:s}):null})]})}),G||U?e.jsxRuntimeExports.jsx(qe.GraphFooter,{sources:G,footNote:U,width:C,styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source}}):null]})})})})}function st(fe){const{data:l,barColors:p,barPadding:H,showTicks:A,leftMargin:G,truncateBy:me,width:de,height:he,suffix:Q,prefix:q,showValues:ie,rightMargin:I,topMargin:oe,bottomMargin:xe,showLabels:C,tooltip:U,onSeriesMouseOver:_,refValues:Z,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,rtl:se,labelOrder:J,maxBarThickness:ee,resetSelectionOnDoubleClick:ne,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:S,styles:b,classNames:g,animate:w,colorDomain:D,precision:N,customLayers:M,naLabel:z}=fe,V=m.useRef(null),v=Pe.useInView(V,{once:w.once,amount:w.amount}),j={top:pe?oe+25:oe,bottom:xe,left:G,right:I},[X,$]=m.useState(void 0),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),F=de-j.left-j.right,h=he-j.top-j.bottom,k=l.map((r,t)=>({...r,id:J?`${r.label}`:`${t}`})),y=J||k.map(r=>`${r.id}`),c=He.linear().domain([f,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,ee?Math.min(h,ee*y.length):h]).paddingInner(H),o=$e.band().domain(l[0].size.map((r,t)=>`${t}`)).range([0,d.bandwidth()]).paddingInner(.1),a=c.ticks(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:V,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:[A?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:a.filter(r=>r!==0),x:a.filter(r=>r!==0).map(r=>c(r)),y1:0-oe,y2:h+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:Q,prefix:q,labelType:"secondary",showGridLines:!0,precision:N}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),M.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(r=>Y.checkIfNullOrUndefined(d(r.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{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((t,s)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?p[s]===ae?1:.3:.85,onMouseEnter:x=>{$({...r,sizeIndex:s}),R(x.clientY),B(x.clientX),_?.({...r,sizeIndex:s})},onMouseMove:x=>{$({...r,sizeIndex:s}),R(x.clientY),B(x.clientX)},onMouseLeave:()=>{$(void 0),B(void 0),R(void 0),_?.(void 0)},onClick:()=>{(L||W)&&(Te.isEqual(T,{...r,sizeIndex:s})&&ne?(ue(void 0),L?.(void 0)):(ue({...r,sizeIndex:s}),L&&L({...r,sizeIndex:s})))},children:[Y.checkIfNullOrUndefined(t)?null:e.jsxRuntimeExports.jsx(ge.motion.rect,{y:o(`${s}`),variants:{initial:{width:0,x:c(0),fill:p[s]},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[s],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(`${s}`)+o.bandwidth()/2,style:{fill:ce||p[s],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,z,N,q,Q)}):null]},`${r.label}-${D[s]||s}`)),C?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${r.label}`.length<me?`${r.label}`:`${`${r.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]},r.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}}),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((r,t)=>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||se?"left":"right",classNames:r.classNames,styles:r.styles,animate:w,isInView:v},t))}):null]}),M.filter(r=>r.position==="after").map(r=>r.layer)]})}),X&&U&&P&&re?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:U,xPos:P,yPos:re,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&T!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:T!==void 0,onClose:()=>{ue(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,T)}:void 0,children:typeof W=="function"?W(T):null})}):null]})}function rt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,truncateBy:he=999,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe="",prefix:C="",showValues:U=!0,showColorScale:_=!0,padding:Z,backgroundColor:E=!1,leftMargin:f=100,rightMargin:L=40,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:ee,tooltip:ne,onSeriesMouseOver:W,refValues:pe,graphID:ce,maxValue:S,minValue:b,onSeriesMouseClick:g,graphDownload:w=!1,dataDownload:D=!1,language:N="en",labelOrder:M,minHeight:z=0,theme:V="light",maxBarThickness:v,ariaLabel:j,resetSelectionOnDoubleClick:X=!0,detailsOnClick:$,barAxisTitle:T,noOfTicks:ue=5,valueColor:P,styles:B,classNames:re,filterNA:R=!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),[a,r]=m.useState(0),[t,s]=m.useState(y.autoplay),x=Re.sort(Se.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)),[Oe,K]=m.useState(y.autoplay?0:x.length-1),[je,ve]=m.useState(void 0),we=m.useRef(null),le=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(q||te[0].target.clientWidth||620),r(Q||te[0].target.clientHeight||480)});return we.current&&(r(we.current.clientHeight||480),o(we.current.clientWidth||620),q||u.observe(we.current)),()=>u.disconnect()},[q,Q]),m.useEffect(()=>{const u=setInterval(()=>{K(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const ye=Re.getSliderMarks(x,Oe,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${V||"light"} flex ${q?"w-fit grow-0":"w-full grow"}`,dir:N==="he"||N==="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 ${N||"en"}`,re?.graphContainer),style:{...B?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:ce,ref:le,"aria-label":j||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?Z||"1rem":Z||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||G||w||D?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:B?.title,description:B?.description},classNames:{title:re?.title,description:re?.description},graphTitle:p,graphDescription:G,width:q,graphDownload:w?le.current:void 0,dataDownload:D?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&&ye?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{s(!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(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:ye,step:null,defaultValue:x[x.length-1],value:x[Oe],onChangeComplete:u=>{K(x.indexOf(u))},onChange:u=>{K(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:q,colorDomain:I,colors:H,colorLegendTitle:oe,setSelectedColor:ve,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:we,"aria-label":"Graph area",children:(q||d)&&(Q||a)?e.jsxRuntimeExports.jsx(st,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[Oe]),y.dateFormat||"yyyy"):u).filter(u=>R?!u.size.every(te=>te==null):u),barColors:H,width:q||d,height:Math.max(z,Q||(ee?z?(q||d)*ee>z?(q||d)*ee:z:(q||d)*ee:a)),suffix:xe,prefix:C,showValues:U,barPadding:me,showTicks:de,leftMargin:f,rightMargin:L,topMargin:ae,bottomMargin:se,truncateBy:he,showLabels:J,tooltip:ne,onSeriesMouseOver:W,refValues:pe,maxValue:Y.checkIfNullOrUndefined(S)?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))))):S,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:je,labelOrder:M,rtl:N==="he"||N==="ar",maxBarThickness:v,resetSelectionOnDoubleClick:X,detailsOnClick:$,barAxisTitle:T,noOfTicks:ue,valueColor:P,styles:B,classNames:re,colorDomain:I,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},precision:h,customLayers:k,naLabel:c}):null})]})}),A||ie?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:B?.footnote,source:B?.source},classNames:{footnote:re?.footnote,source:re?.source},sources:A,footNote:ie,width:q}):null]})})})})}function nt(fe){const{data:l,barColors:p,barPadding:H,showTicks:A,leftMargin:G,rightMargin:me,truncateBy:de,width:he,height:Q,topMargin:q,bottomMargin:ie,tooltip:I,onSeriesMouseOver:oe,showLabels:xe,suffix:C,prefix:U,showValues:_,refValues:Z,maxValue:E,onSeriesMouseClick:f,selectedColor:L,rtl:ae,labelOrder:se,maxBarThickness:J,minBarThickness:ee,resetSelectionOnDoubleClick:ne,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:S,styles:b,classNames:g,animate:w,colorDomain:D,precision:N,customLayers:M,naLabel:z}=fe,V=m.useRef(null),v=Pe.useInView(V,{once:w.once,amount:w.amount}),j={top:pe?q+25:q,bottom:ie,left:G,right:me},[X,$]=m.useState(void 0),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),F=he-j.left-j.right,h=Q-j.top-j.bottom,k=l.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),y=se||k.map(a=>`${a.id}`),c=He.linear().domain([0,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,ee?Math.max(h,ee*y.length):J?Math.min(h,J*y.length):h]).paddingInner(H),o=c.ticks(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:V,width:`${he}px`,height:`${Q}px`,viewBox:`0 0 ${he} ${Q}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[A?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:o.filter(a=>a!==0),x:o.filter(a=>a!==0).map(a=>c(a)),y1:0-q,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:N}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),M.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(a=>Y.checkIfNullOrUndefined(d(a.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:0,y:d(`${a.id}`)},whileInView:{x:0,y:d(`${a.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?p[t]===L?1:.3:1,onMouseEnter:s=>{$({...a,sizeIndex:t}),R(s.clientY),B(s.clientX),oe?.({...a,sizeIndex:t})},onMouseMove:s=>{$({...a,sizeIndex:t}),R(s.clientY),B(s.clientX)},onMouseLeave:()=>{$(void 0),B(void 0),R(void 0),oe?.(void 0)},onClick:()=>{(f||W)&&(Te.isEqual(T,{...a,sizeIndex:t})&&ne?(ue(void 0),f?.(void 0)):(ue({...a,sizeIndex:t}),f&&f({...a,sizeIndex:t})))},children:[r?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(r||0),x:c(t===0?0:ke.sum(a.size.filter((s,x)=>x<t&&s))),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:Ke.getTextColorBasedOnBgColor(p[t])},whileInView:{x:c(t===0?0:ke.sum(a.size.filter((s,x)=>x<t&&s)))+c(r||0)/2,opacity:r&&c(r)/Me.numberFormattingFunction(r,z,N,U,C).length>12?1:0,fill:Ke.getTextColorBasedOnBgColor(p[t]),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(r,z,N,U,C)}):null]},`${a.label}-${D[t]||t}`)),xe?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${a.label}`.length<de?`${a.label}`:`${`${a.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(a.size.map(r=>r||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(a.size.filter(r=>r)),z,N,U,C)}):null]},a.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}}),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((a,r)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:a.text,color:a.color,x:c(a.value),y1:0-j.top,y2:h+j.bottom,textSide:c(a.value)>F*.75||ae?"left":"right",classNames:a.classNames,styles:a.styles,animate:w,isInView:v},r))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})}),X&&I&&P&&re?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:I,xPos:P,yPos:re,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&T!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:T!==void 0,onClose:()=>{ue(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,T)}:void 0,children:typeof W=="function"?W(T):null})}):null]})}function lt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=100,rightMargin:Q=40,truncateBy:q=999,height:ie,width:I,footNote:oe,colorDomain:xe,colorLegendTitle:C,padding:U,backgroundColor:_=!1,topMargin:Z=25,bottomMargin:E=10,tooltip:f,onSeriesMouseOver:L,suffix:ae="",prefix:se="",showLabels:J=!0,relativeHeight:ee,showValues:ne=!0,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b=!1,dataDownload:g=!1,language:w="en",labelOrder:D,minHeight:N=0,theme:M="light",maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,showColorScale:X=!0,ariaLabel:$,resetSelectionOnDoubleClick:T=!0,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B=5,valueColor:re,styles:R,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA"}=fe,[a,r]=m.useState(0),[t,s]=m.useState(0),[x,Oe]=m.useState(d.autoplay),K=Re.sort(Se.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,O)=>Ye.ascending(n,O)),[je,ve]=m.useState(d.autoplay?0:K.length-1),[we,le]=m.useState(void 0),ye=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(O=>{r(I||O[0].target.clientWidth||620),s(ie||O[0].target.clientHeight||480)});return ye.current&&(s(ye.current.clientHeight||480),r(ye.current.clientWidth||620),I||n.observe(ye.current)),()=>n.disconnect()},[I,ie]),m.useEffect(()=>{const n=setInterval(()=>{ve(O=>O<K.length-1?O+1:0)},(d.speed||2)*1e3);return x||clearInterval(n),()=>clearInterval(n)},[K,x,d.speed]);const te=Re.getSliderMarks(K,je,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${M||"light"} flex ${I?"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:{...R?.graphContainer||{},..._&&_!==!0?{backgroundColor:_}:{}},id:pe,ref:u,"aria-label":$||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${G?` ${G}`:""}`,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||G||b||g?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:G,width:I,graphDownload:b?u.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&&K.length>0&&te?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!x)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":x?"Click to pause animation":"Click to play animation",children:x?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:K[0],max:K[K.length-1],marks:te,step:null,defaultValue:K[K.length-1],value:K[je],onChangeComplete:n=>{ve(K.indexOf(n))},onChange:n=>{ve(K.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:I,colorDomain:xe,colors:H,colorLegendTitle:C,setSelectedColor:le,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ye,"aria-label":"Graph area",children:(I||a)&&(ie||t)?e.jsxRuntimeExports.jsx(nt,{data:V!==void 0?V==="total"?De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))).reverse().filter((n,O)=>v?O<v:!0):De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>Y.checkIfNullOrUndefined(n.size[V])?-1/0:n.size[V]).reverse().filter((n,O)=>v?O<v:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n).filter((n,O)=>v?O<v:!0),barColors:H,width:I||a,height:Math.max(N,ie||(ee?N?(I||a)*ee>N?(I||a)*ee:N:(I||a)*ee:t)),barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:Z,bottomMargin:E,truncateBy:q,showLabels:J,tooltip:f,onSeriesMouseOver:L,showValues:ne,suffix:ae,prefix:se,refValues:W,maxValue:Y.checkIfNullOrUndefined(ce)?Math.max(...l.map(n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))||0)):ce,onSeriesMouseClick:S,selectedColor:we,rtl:w==="he"||w==="ar",labelOrder:D,maxBarThickness:z,minBarThickness:j,resetSelectionOnDoubleClick:T,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B,valueColor:re,classNames:F,styles:R,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})]})}),A||oe?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:A,footNote:oe,width:I}):null]})})})})}function ot(fe){const{data:l,width:p,height:H,barColor:A,suffix:G,prefix:me,barPadding:de,showLabels:he,showValues:Q,showTicks:q,colorDomain:ie,truncateBy:I,rightMargin:oe,topMargin:xe,bottomMargin:C,leftMargin:U,tooltip:_,onSeriesMouseOver:Z,refValues:E,selectedColor:f,maxValue:L,minValue:ae,highlightedDataPoints:se,onSeriesMouseClick:J,labelOrder:ee,maxBarThickness:ne,minBarThickness:W,resetSelectionOnDoubleClick:pe,detailsOnClick:ce,barAxisTitle:S,valueColor:b,noOfTicks:g,styles:w,classNames:D,dimmedOpacity:N,animate:M,precision:z,customLayers:V,naLabel:v}=fe,j=m.useRef(null),X=Pe.useInView(j,{once:M.once,amount:M.amount}),$={top:xe,bottom:C,left:S?U+30:U,right:oe},[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),[F,h]=m.useState(void 0),k=p-$.left-$.right,y=H-$.top-$.bottom,c=He.linear().domain([ae,L]).range([y,0]).nice(),d=l.map((t,s)=>({...t,id:ee?`${t.label}`:`${s}`})),o=ee||d.map(t=>`${t.id}`),a=$e.band().domain(o).range([0,W?Math.max(k,W*o.length):ne?Math.min(k,ne*o.length):k]).paddingInner(de),r=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(${$.left},${$.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:c(ae<0?0:ae),y2:c(ae<0?0:ae),x1:0-U,x2:k+$.right,label:Me.numberFormattingFunction(ae<0?0:ae,v,z,me,G),labelPos:{x:0-U,dx:0,dy:L<0?"1em":-5,y:c(ae<0?0:ae)},classNames:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels},styles:{axis:w?.xAxis?.axis,label:w?.yAxis?.labels}}),q?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:r.filter(t=>t!==0),y:r.filter(t=>t!==0).map(t=>c(t)),x1:0-U,x2:k+$.right,styles:{gridLines:w?.yAxis?.gridLines,labels:w?.yAxis?.labels},classNames:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},suffix:G,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:z}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-U-15,y:y/2,style:w?.yAxis?.title,className:D?.yAxis?.title,text:S,rotate90:!0}),V.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[d.map((t,s)=>Y.checkIfNullOrUndefined(a(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&&A[ie.indexOf(t.color)]===f?1:N:se.length!==0?se.indexOf(t.label)!==-1?.85:N:.85},whileInView:{opacity:f?t.color&&A[ie.indexOf(t.color)]===f?1:N:se.length!==0?se.indexOf(t.label)!==-1?.85:N:.85,transition:{duration:M.duration}}},exit:{opacity:0,transition:{duration:M.duration}},onMouseEnter:x=>{ue(t),h(x.clientY),R(x.clientX),Z?.(t)},onClick:()=>{(J||ce)&&(Te.isEqual(P,t)&&pe?(B(void 0),J?.(void 0)):(B(t),J?.(t)))},onMouseMove:x=>{ue(t),h(x.clientY),R(x.clientX)},onMouseLeave:()=>{ue(void 0),R(void 0),h(void 0),Z?.(void 0)},children:[t.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{width:a.bandwidth(),initial:"initial",animate:X?"whileInView":"initial",variants:{initial:{height:0,x:a(`${t.id}`),y:c(0),fill:l.filter(x=>x.color).length===0?A[0]:t.color?A[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:a(`${t.id}`),fill:l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray,transition:{duration:M.duration}}},exit:{height:0,y:c(0),transition:{duration:M.duration}}}):null,he?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${t.label}`.length<I?`${t.label}`:`${`${t.label}`.substring(0,I)}...`,y:(t.size||0)<0?0:c(0)+5,x:a(`${t.id}`),width:a.bandwidth(),height:(t.size||0)<0?c(0)-5:$.bottom,style:w?.xAxis?.labels,className:D?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:M,isInView:X}):null,Q?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:"middle",...w?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!b&&A.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",D?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",variants:{initial:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(0),opacity:0,fill:b||(l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray)},whileInView:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(t.size||0),fill:b||(l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray),opacity:1,transition:{duration:M.duration}}},initial:"initial",animate:X?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},children:Me.numberFormattingFunction(t.size,v,z,me,G)}):null]},t.label)),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((t,s)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:t.text,color:t.color,y:c(t.value),x1:0-U,x2:k+$.right,classNames:t.classNames,styles:t.styles,animate:M,isInView:X},s))}):null]}),V.filter(t=>t.position==="after").map(t=>t.layer)]})}),T&&_&&re&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:T,body:_,xPos:re,yPos:F,backgroundStyle:w?.tooltip,className:D?.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 ut(fe){const{data:l,graphTitle:p,colors:H,barPadding:A=.25,showTicks:G=!0,leftMargin:me=20,rightMargin:de=20,topMargin:he=20,bottomMargin:Q=25,truncateBy:q=999,showLabels:ie=!0,showValues:I=!0,backgroundColor:oe=!1,suffix:xe="",prefix:C="",sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe=!0,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g=[],onSeriesMouseClick:w,graphDownload:D=!1,dataDownload:N=!1,language:M="en",theme:z="light",sortData:V,labelOrder:v,showNAColor:j=!0,minHeight:X=0,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:re,barAxisTitle:R,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=fe,[x,Oe]=m.useState(0),[K,je]=m.useState(0),[ve,we]=m.useState(t.autoplay),le=Re.sort(Se.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,be)=>Ye.ascending(i,be)),[ye,u]=m.useState(t.autoplay?0:le.length-1),[te,n]=m.useState(void 0),O=m.useRef(null),_e=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(be=>{Oe(E||be[0].target.clientWidth||620),je(Z||be[0].target.clientHeight||480)});return O.current&&(je(O.current.clientHeight||480),Oe(O.current.clientWidth||620),E||i.observe(O.current)),()=>i.disconnect()},[E,Z]),m.useEffect(()=>{const i=setInterval(()=>{u(be=>be<le.length-1?be+1:0)},(t.speed||2)*1e3);return ve||clearInterval(i),()=>clearInterval(i)},[le,ve,t.speed]);const Je=Re.getSliderMarks(le,ye,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${z||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${oe?oe===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...oe&&oe!==!0?{backgroundColor:oe}:{}},id:ce,ref:_e,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${_?` ${_}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:oe?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||_||D||N?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:D?_e.current:void 0,dataDownload:N?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&&le.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!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(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:le[0],max:le[le.length-1],marks:Je,step:null,defaultValue:le[le.length-1],value:le[ye],onChangeComplete:i=>{u(le.indexOf(i))},onChange:i=>{u(le.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[z].categoricalColors.colors,colorDomain:L||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:n,showNAColor:j}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:O,"aria-label":"Graph area",children:(E||x)&&(Z||K)?e.jsxRuntimeExports.jsx(ot,{data:V==="asc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,be)=>T?be<T:!0):V==="desc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,be)=>T?be<T:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,be)=>T?be<T:!0),barColor:l.filter(i=>i.color).length===0?H?[H]:[Ce.Colors.primaryColors["blue-600"]]:H||Ce.Colors[z].categoricalColors.colors,colorDomain:l.filter(i=>i.color).length===0?[]:L||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:E||x,refValues:W,height:Math.max(X,Z||(J?X?(E||x)*J>X?(E||x)*J:X:(E||x)*J:K)),suffix:xe,prefix:C,barPadding:A,showLabels:ie,showValues:I,showTicks:G,truncateBy:q,leftMargin:me,rightMargin:de,selectedColor:te,topMargin:he,bottomMargin:Q,tooltip:ee,onSeriesMouseOver:ne,maxValue:Y.checkIfNullOrUndefined(S)?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)):S,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:$,minBarThickness:ue,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,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:a,customLayers:r,naLabel:s}):null})]})}),U||f?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source},sources:U,footNote:f,width:E}):null]})})})})}function ct(fe){const{data:l,width:p,height:H,barColors:A,suffix:G,prefix:me,barPadding:de,showLabels:he,showValues:Q,showTicks:q,truncateBy:ie,leftMargin:I,rightMargin:oe,topMargin:xe,bottomMargin:C,tooltip:U,onSeriesMouseOver:_,refValues:Z,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,labelOrder:se,maxBarThickness:J,resetSelectionOnDoubleClick:ee,detailsOnClick:ne,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:S,classNames:b,animate:g,colorDomain:w,precision:D,customLayers:N,naLabel:M}=fe,z=m.useRef(null),V=Pe.useInView(z,{once:g.once,amount:g.amount}),v={top:xe,bottom:C,left:W?I+30:I,right:oe},[j,X]=m.useState(void 0),[$,T]=m.useState(void 0),[ue,P]=m.useState(void 0),[B,re]=m.useState(void 0),R=p-v.left-v.right,F=H-v.top-v.bottom,h=He.linear().domain([f,E]).range([F,0]).nice(),k=l.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),y=se||k.map(a=>`${a.id}`),c=$e.band().domain(y).range([0,J?Math.min(R,J*y.length):R]).paddingInner(de),d=$e.band().domain(l[0].size.map((a,r)=>`${r}`)).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:z,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-I,x2:R+v.right,label:Me.numberFormattingFunction(f<0?0:f,M,D,me,G),labelPos:{x:0-I,dx:0,dy:E<0?"1em":-5,y:h(f<0?0:f)},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:S?.xAxis?.axis,label:S?.yAxis?.labels}}),q?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:o.filter(a=>a!==0),y:o.filter(a=>a!==0).map(a=>h(a)),x1:0-I,x2:R+v.right,styles:{gridLines:S?.yAxis?.gridLines,labels:S?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:G,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-I-15,y:F/2,style:S?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),N.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(a=>Y.checkIfNullOrUndefined(c(a.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{variants:{initial:{x:c(`${a.id}`),y:0},whileInView:{x:c(`${a.id}`),y:0,transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?A[t]===ae?1:.3:.85,onMouseEnter:s=>{X({...a,sizeIndex:t}),re(s.clientY),P(s.clientX),_?.({...a,sizeIndex:t})},onMouseMove:s=>{X({...a,sizeIndex:t}),re(s.clientY),P(s.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),re(void 0),_?.(void 0)},onClick:()=>{(L||ne)&&(Te.isEqual($,{...a,sizeIndex:t})&&ee?(T(void 0),L?.(void 0)):(T({...a,sizeIndex:t}),L&&L({...a,sizeIndex:t})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:d(`${t}`),width:d.bandwidth(),variants:{initial:{height:0,y:h(0),fill:A[t]},whileInView:{height:Y.checkIfNullOrUndefined(r)?0:Math.abs(h(r)-h(0)),y:Y.checkIfNullOrUndefined(r)?h(0):r>0?h(r):h(0),fill:A[t],transition:{duration:g.duration}}},exit:{height:0,y:h(0),transition:{duration:g.duration}},initial:"initial",animate:V?"whileInView":"initial"}),Q?e.jsxRuntimeExports.jsx(ge.motion.text,{x:d(`${t}`)+d.bandwidth()/2,style:{fill:pe||A[t],textAnchor:"middle",...S?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:r?r>=0?"-5px":"1em":"-5px",variants:{initial:{y:h(0),opacity:0},whileInView:{y:h(r||0),opacity:1,transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(r,M,D,me,G)}):null]},`${a.label}-${w[t]||t}`)),he?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${a.label}`.length<ie?`${a.label}`:`${`${a.label}`.substring(0,ie)}...`,y:h(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:S?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:V}):null]},a.label)),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((a,r)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:a.text,color:a.color,y:h(a.value),x1:0-I,x2:R+v.right,classNames:a.classNames,styles:a.styles,animate:g,isInView:V},r))}):null]}),N.filter(a=>a.position==="after").map(a=>a.layer)]})}),j&&U&&ue&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:U,xPos:ue,yPos:B,backgroundStyle:S?.tooltip,className:b?.tooltip}):null,ne&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ne=="string"?{__html:Ve.string2HTML(ne,$)}:void 0,children:typeof ne=="function"?ne($):null})}):null]})}function xt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Q=20,topMargin:q=20,bottomMargin:ie=25,truncateBy:I=999,showLabels:oe=!0,showValues:xe=!0,backgroundColor:C=!1,suffix:U="",prefix:_="",height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:D="en",theme:N="light",labelOrder:M,minHeight:z=0,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j=!0,detailsOnClick:X,barAxisTitle:$,noOfTicks:T=5,valueColor:ue,styles:P,classNames:B,filterNA:re=!0,showColorScale:R=!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),[a,r]=m.useState(0),[t,s]=m.useState(y.autoplay),x=Re.sort(Se.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)),[Oe,K]=m.useState(y.autoplay?0:x.length-1),[je,ve]=m.useState(void 0),we=m.useRef(null),le=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(E||te[0].target.clientWidth||620),r(Z||te[0].target.clientHeight||480)});return we.current&&(r(we.current.clientHeight||480),o(we.current.clientWidth||620),E||u.observe(we.current)),()=>u.disconnect()},[E,Z]),m.useEffect(()=>{const u=setInterval(()=>{K(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const ye=Re.getSliderMarks(x,Oe,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="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 ${D||"en"}`,B?.graphContainer),style:{...P?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:pe,ref:le,"aria-label":v||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${G?` ${G}`:""}`,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||G||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:P?.title,description:P?.description},classNames:{title:B?.title,description:B?.description},graphTitle:p,graphDescription:G,width:E,graphDownload:g?le.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&&ye?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{s(!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(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:ye,step:null,defaultValue:x[x.length-1],value:x[Oe],onChangeComplete:u=>{K(x.indexOf(u))},onChange:u=>{K(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:[R?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:E,colorDomain:L,colors:H,colorLegendTitle:ae,setSelectedColor:ve,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:we,"aria-label":"Graph area",children:(E||d)&&(Z||a)?e.jsxRuntimeExports.jsx(ct,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[Oe]),y.dateFormat||"yyyy"):u).filter(u=>re?!u.size.every(te=>te==null):u),barColors:H,width:E||d,height:Math.max(z,Z||(J?z?(E||d)*J>z?(E||d)*J:z:(E||d)*J:a)),suffix:U,prefix:_,barPadding:me,showLabels:oe,showValues:xe,showTicks:de,truncateBy:I,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,tooltip:ee,onSeriesMouseOver:ne,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(S)?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))))):S,onSeriesMouseClick:b,selectedColor:je,labelOrder:M,maxBarThickness:V,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,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})]})}),A||f?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:P?.footnote,source:P?.source},classNames:{footnote:B?.footnote,source:B?.source},sources:A,footNote:f,width:E}):null]})})})})}function dt(fe){const{data:l,width:p,height:H,barColors:A,barPadding:G,showLabels:me,showTicks:de,truncateBy:he,leftMargin:Q,topMargin:q,bottomMargin:ie,rightMargin:I,tooltip:oe,onSeriesMouseOver:xe,suffix:C,prefix:U,showValues:_,refValues:Z,maxValue:E,onSeriesMouseClick:f,selectedColor:L,labelOrder:ae,maxBarThickness:se,minBarThickness:J,resetSelectionOnDoubleClick:ee,detailsOnClick:ne,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:S,classNames:b,animate:g,colorDomain:w,precision:D,customLayers:N,naLabel:M}=fe,z=m.useRef(null),V=Pe.useInView(z,{once:g.once,amount:g.amount}),v={top:q,bottom:ie,left:W?Q+30:Q,right:I},[j,X]=m.useState(void 0),[$,T]=m.useState(void 0),[ue,P]=m.useState(void 0),[B,re]=m.useState(void 0),R=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,a)=>({...o,id:ae?`${o.label}`:`${a}`})),y=ae||k.map(o=>`${o.id}`),c=$e.band().domain(y).range([0,J?Math.max(R,J*y.length):se?Math.min(R,se*y.length):R]).paddingInner(G),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:z,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-Q,x2:R+v.right,label:Me.numberFormattingFunction(0,M,D,U,C),labelPos:{x:0-Q,y:h(0),dx:0,dy:-5},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:S?.xAxis?.axis,label:S?.yAxis?.labels}}),de?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:d.filter(o=>o!==0),y:d.filter(o=>o!==0).map(o=>h(o)),x1:0-Q,x2:R+v.right,styles:{gridLines:S?.yAxis?.gridLines,labels:S?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:C,prefix:U,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-Q-15,y:F/2,style:S?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),N.filter(o=>o.position==="before").map(o=>o.layer),e.jsxRuntimeExports.jsxs(Ge.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:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[o.size.map((a,r)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?A[r]===L?1:.3:1,onMouseEnter:t=>{X({...o,sizeIndex:r}),re(t.clientY),P(t.clientX),xe?.({...o,sizeIndex:r})},onMouseMove:t=>{X({...o,sizeIndex:r}),re(t.clientY),P(t.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),re(void 0),xe?.(void 0)},onClick:()=>{(f||ne)&&(Te.isEqual($,{...o,sizeIndex:r})&&ee?(T(void 0),f?.(void 0)):(T({...o,sizeIndex:r}),f&&f({...o,sizeIndex:r})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:0,width:c.bandwidth(),variants:{initial:{height:0,fill:A[r],y:h(0)},whileInView:{height:Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t)))),y:h(ke.sum(o.size.filter((t,s)=>s<=r&&t))),fill:A[r],transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{height:0,y:h(0),transition:{duration:g.duration}}}),_?e.jsxRuntimeExports.jsx(ge.motion.text,{x:c.bandwidth()/2,style:{fill:Ke.getTextColorBasedOnBgColor(A[r]),textAnchor:"middle",...S?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:"0.33em",variants:{initial:{y:h(0),opacity:0,fill:Ke.getTextColorBasedOnBgColor(A[r])},whileInView:{y:h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))+Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t))))/2,opacity:a&&Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t))))>20?1:0,fill:Ke.getTextColorBasedOnBgColor(A[r]),transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(a,M,D,U,C)}):null]},`${o.label}-${w[r]||r}`)),me?e.jsxRuntimeExports.jsx(et.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:S?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:V}):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{...pe&&{fill:pe},textAnchor:"middle",...S?.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(a=>a||0))),opacity:1,transition:{duration:g.duration}}},exit:{opacity:0,transition:{duration:g.duration}},initial:"initial",animate:V?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(o.size.filter(a=>a)),M,D,U,C)}):null]},o.label)),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((o,a)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:o.text,color:o.color,y:h(o.value),x1:0-Q,x2:R+v.right,classNames:o.classNames,styles:o.styles,animate:g,isInView:V},a))}):null]}),N.filter(o=>o.position==="after").map(o=>o.layer)]})}),j&&oe&&ue&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:oe,xPos:ue,yPos:B,backgroundStyle:S?.tooltip,className:b?.tooltip}):null,ne&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ne=="string"?{__html:Ve.string2HTML(ne,$)}:void 0,children:typeof ne=="function"?ne($):null})}):null]})}function mt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Q=20,topMargin:q=20,bottomMargin:ie=25,truncateBy:I=999,showLabels:oe=!0,showValues:xe=!0,backgroundColor:C=!1,showColorScale:U=!0,suffix:_="",prefix:Z="",height:E,width:f,footNote:L,colorDomain:ae,colorLegendTitle:se,padding:J,tooltip:ee,onSeriesMouseOver:ne,relativeHeight:W,refValues:pe,graphID:ce,maxValue:S,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:D="en",theme:N="light",labelOrder:M,minHeight:z=0,maxBarThickness:V,sortParameter:v,maxNumberOfBars:j,minBarThickness:X,ariaLabel:$,resetSelectionOnDoubleClick:T=!0,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B=5,valueColor:re,styles:R,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA"}=fe,[a,r]=m.useState(0),[t,s]=m.useState(0),[x,Oe]=m.useState(d.autoplay),K=Re.sort(Se.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,O)=>Ye.ascending(n,O)),[je,ve]=m.useState(d.autoplay?0:K.length-1),[we,le]=m.useState(void 0),ye=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(O=>{r(f||O[0].target.clientWidth||620),s(E||O[0].target.clientHeight||480)});return ye.current&&(s(ye.current.clientHeight||480),r(ye.current.clientWidth||620),f||n.observe(ye.current)),()=>n.disconnect()},[f,E]),m.useEffect(()=>{const n=setInterval(()=>{ve(O=>O<K.length-1?O+1:0)},(d.speed||2)*1e3);return x||clearInterval(n),()=>clearInterval(n)},[K,x,d.speed]);const te=Re.getSliderMarks(K,je,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${f?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="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 ${D||"en"}`,F?.graphContainer),style:{...R?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:ce,ref:u,"aria-label":$||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${G?` ${G}`:""}`,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||G||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:G,width:f,graphDownload:g?u.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&&K.length>0&&te?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!x)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":x?"Click to pause animation":"Click to play animation",children:x?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:K[0],max:K[K.length-1],marks:te,step:null,defaultValue:K[K.length-1],value:K[je],onChangeComplete:n=>{ve(K.indexOf(n))},onChange:n=>{ve(K.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:le,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ye,"aria-label":"Graph area",children:(f||a)&&(E||t)?e.jsxRuntimeExports.jsx(dt,{data:v!==void 0?v==="total"?De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))).filter((n,O)=>j?O<j:!0):De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>Y.checkIfNullOrUndefined(n.size[v])?-1/0:n.size[v]).filter((n,O)=>j?O<j:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>h?!n.size.every(O=>O==null):n).filter((n,O)=>j?O<j:!0),barColors:H,width:f||a,height:Math.max(z,E||(W?z?(f||a)*W>z?(f||a)*W:z:(f||a)*W:t)),barPadding:me,showLabels:oe,showTicks:de,truncateBy:I,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,tooltip:ee,onSeriesMouseOver:ne,showValues:xe,suffix:_,prefix:Z,refValues:pe,maxValue:Y.checkIfNullOrUndefined(S)?Math.max(...l.map(n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))||0)):S,onSeriesMouseClick:b,selectedColor:we,labelOrder:M,maxBarThickness:V,minBarThickness:X,resetSelectionOnDoubleClick:T,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B,valueColor:re,styles:R,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})]})}),A||L?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:A,footNote:L,width:f}):null]})})})})}function ht(fe){const{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,orientation:k="vertical",styles:y,classNames:c,filterNA:d,animate:o,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:x}=fe;return k==="vertical"?e.jsxRuntimeExports.jsx(ut,{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,animate:o,dimmedOpacity:a,precision:r,customLayers:t,timeline:s}):e.jsxRuntimeExports.jsx(at,{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:x})}function pt(fe){const{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,orientation:P="vertical",styles:B,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}=fe;return P==="vertical"?e.jsxRuntimeExports.jsx(xt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}):e.jsxRuntimeExports.jsx(rt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d})}function gt(fe){const{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,orientation:re="vertical",styles:R,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a}=fe;return re==="vertical"?e.jsxRuntimeExports.jsx(mt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,styles:R,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a}):e.jsxRuntimeExports.jsx(lt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,styles:R,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a})}exports.GroupedBarGraph=pt;exports.SimpleBarGraph=ht;exports.StackedBarGraph=gt;
|
|
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;
|
|
2
2
|
//# sourceMappingURL=BarGraph.cjs.map
|