UNPKG

@frontify/fondue-charts

Version:

Frontify's data viz library

4 lines (3 loc) • 36.5 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),_=require("@visx/xychart"),f=require("react"),oe=require("@visx/scale"),re=require("@visx/grid"),ae=require("@visx/glyph"),ut=require("@visx/tooltip"),K=require("@visx/group"),ce=require("@visx/shape"),st=require("@visx/hierarchy"),ie=require("lodash-es"),le=50,de=5,ue=(t,e)=>{const s=Math.min(Math.floor((e??0)/(le+2*de)),t[0].dataPoints.length);return t[0].dataPoints.filter((o,n,r)=>n%Math.round((r.length-1)/s)===0).map(o=>o.timestamp)},wt=({linearScaleTicks:t,valueFormatter:e,locale:s,series:o})=>{const{innerWidth:n}=f.useContext(_.DataContext),r=ue(o,n),a=c=>new Intl.DateTimeFormat(s??Intl.DateTimeFormat().resolvedOptions().locale,{month:"short",day:"2-digit"}).format(c);return i.jsxs(i.Fragment,{children:[i.jsx(_.Axis,{hideAxisLine:!0,numTicks:5,orientation:"left",tickValues:t,tickFormat:e}),i.jsx(_.Axis,{tickValues:r,hideAxisLine:!1,orientation:"bottom",tickFormat:a})]})},he="_label_1cnpe_3",pe={label:he},Rt=8,Wt=2,fe={width:0,height:0},xe=t=>{const{width:e,height:s}=t.getBBox(),o=e+2*Rt,n=s+2*Wt;return{width:o,height:n}},Gt=({value:t,name:e})=>{const{xScale:s,yScale:o}=f.useContext(_.DataContext),[n,r]=f.useState(fe),a=f.useCallback(x=>{x!==null&&r(xe(x))},[e]),c=[Number((s==null?void 0:s.range()[0])??0),Number((s==null?void 0:s.range()[1])??0)],l=Number((o==null?void 0:o(t))??0),h=c[0]+c[1]/2-n.width/2,u=c[0]+c[1]/2-Rt-n.width/2,d=l+2*Wt,p=l-n.height/2;return i.jsxs("g",{children:[i.jsx("line",{x1:c[0],y1:l,x2:c[1],y2:l,stroke:"black"}),i.jsx("rect",{x:u,y:p,width:n.width,height:n.height,rx:"4",fill:"white",stroke:"black"}),i.jsx("text",{x:h,y:d,ref:a,strokeWidth:0,fill:"var(--color-secondary-default)",className:pe.label,children:e})]})},X="-nodata",q=["var(--fc-primary-base-color)","var(--fc-secondary-base-color)","var(--fc-tertiary-base-color)"],At=["var(--fc-primary-weak-color)","var(--fc-secondary-weak-color)","var(--fc-tertiary-weak-color)"],Lt=["var(--fc-primary-hover-color)","var(--fc-secondary-hover-color)","var(--fc-tertiary-hover-color)"],ge="var(--fc-backfilled-base-color)",Bt="var(--fc-negative-base-color)",me="var(--fc-backfilled-weak-color)",ye="var(--fc-negative-weak-color)",ht="--fc-font-family",_e="400",$=t=>t?t.timestamp.valueOf()||0:null,M=t=>(t==null?void 0:t.value)??null,ve=(t,e,s)=>t!==null&&t<0&&e?Bt:s,F=t=>t.value!==null&&!Number.isNaN(t.value),Se=t=>t.map(e=>{var r,a;const s=(r=e.at(-1))==null?void 0:r.value,o=((a=e[0])==null?void 0:a.value)??s,n=s-o;return e.map((c,l)=>{const h=o+n*(l/(e.length-1));return{...c,value:h}})}),ke=t=>{const e=[];return t.dataPoints.reduce((s,o,n)=>{var r;if(!F(o)){const a=n>0&&F(t.dataPoints[n-1]),c=n<t.dataPoints.length-1&&F(t.dataPoints[n+1]),l=n===t.dataPoints.length-1&&!F(o);a&&s.push(t.dataPoints[n-1]),s.push(o),c&&(s.push(t.dataPoints[n+1]),e.push([...s]),s.splice(0,s.length)),l&&(s[0]&&F(s[0])&&s.push({...o,value:(r=s[0])==null?void 0:r.value}),e.push([...s]),s.splice(0,s.length))}return s},[]),e},Ft=t=>t.reduce((e,s)=>{const o=ke(s);if(o){const n=Se(o);return[...e,...n.map((r,a)=>({name:`${s.name}-${a}`,dataPoints:r}))]}else return e},[]),Ht=(t,e)=>{const s=Array(e).fill(me);return[...Array.from({length:t},(n,r)=>At[r%At.length]),...s]},It="__react_svg_text_measurement_id",W=(t,e)=>{let s=document.getElementById(It);if(!s){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true"),r.style.width="0",r.style.height="0",r.style.position="absolute",r.style.top="-100%",r.style.left="-100%",s=document.createElementNS("http://www.w3.org/2000/svg","text"),s.setAttribute("id",It),r.appendChild(s),document.body.appendChild(r)}Object.assign(s.style,e),s.textContent=t;const{width:o,height:n}=s.getBoundingClientRect();return{width:o,height:n}},pt="positive",ft="negative",Te=({highlightNegativeValues:t})=>{const e=f.useContext(_.DataContext),{xScale:s,yScale:o}=e,n=[Number((s==null?void 0:s.range()[0])??0),Number((s==null?void 0:s.range()[1])??0)],r=[Number((o==null?void 0:o.range()[0])??0),Number((o==null?void 0:o.range()[1])??0)],a=Number((o==null?void 0:o(0))??0),c=n[1]-n[0],l=r[0]-r[1];return i.jsxs("defs",{children:[i.jsx("clipPath",{id:pt,children:i.jsx("rect",{x:n[0],y:r[1],width:c,height:t?a-r[1]:l})}),i.jsx("clipPath",{id:ft,children:i.jsx("rect",{x:n[0],y:a,width:c,height:t?r[0]-a:0})})]})},je=({series:t,backfilledSeries:e,hideArea:s})=>{const o=s?0:1;return i.jsxs(i.Fragment,{children:[t.map(n=>i.jsxs(f.Fragment,{children:[i.jsx(_.AreaSeries,{dataKey:n.name,data:n.dataPoints,xAccessor:$,yAccessor:M,renderLine:!1,clipPath:`url(#${pt})`,fillOpacity:o},`${n.name}-area-positive`),i.jsx(_.AreaSeries,{dataKey:n.name,data:n.dataPoints,xAccessor:$,yAccessor:M,renderLine:!1,clipPath:`url(#${ft})`,fillOpacity:o,fill:ye},`${n.name}-area-negative`)]},`${n.name}-area`)),e.map((n,r)=>i.jsx(_.AreaSeries,{dataKey:`${n.name}${X}-${r}`,data:n.dataPoints,xAccessor:$,yAccessor:M,renderLine:!1,fillOpacity:o},`${n.name}${X}-${r}-area`))]})},xt=(t,e)=>{const s=e.findIndex(o=>o.name===t);return q[s%q.length]},D=t=>q[t%q.length],G=t=>Lt[t%Lt.length],gt=(t,e,s=!0)=>{const o=t[0]>0?0:t[0],n=t[1]<0?0:t[1],a=oe.createScale({type:"linear",domain:[o,n]}).ticks(e);return s?a:be(a)},be=t=>t.filter(e=>e%1===0),Yt=t=>{const e=Math.abs(t);return 10**(Math.round(e).toString().length-1)},Et=(t,e,s)=>{const o=s==="min"?Math.min:Math.max,n=s==="min"?Math.floor:Math.ceil,r=t.map(l=>o(...l.dataPoints.map(h=>h.value??0))),a=o(...r,e),c=Yt(a);return n(a/c)*c},Ae=(t,e)=>{const s=Et(t,e??0,"min"),o=Et(t,e??0,"max");return[s,o]},Vt=(t,e)=>{const[s,o]=Ae(t,e);return s===0&&o===0?[0,1]:[s,o]},it=1.5,Le=({color:t,x:e,y:s},o)=>o?null:i.jsx("circle",{className:"visx-circle-glyph",fill:"var(--fc-base-color)",stroke:t,strokeWidth:"1.5",r:3,cx:e,cy:s}),Ie=({series:t,backfilledSeries:e,hideGlyphs:s,highlightNegativeValues:o})=>i.jsxs(i.Fragment,{children:[t.map((n,r)=>i.jsxs(f.Fragment,{children:[i.jsx(_.LineSeries,{dataKey:n.name,data:n.dataPoints,xAccessor:$,yAccessor:M,stroke:D(r),strokeWidth:it,clipPath:`url(#${pt})`}),i.jsx(_.LineSeries,{dataKey:n.name,data:n.dataPoints,xAccessor:$,yAccessor:M,stroke:Bt,strokeWidth:it,clipPath:`url(#${ft})`}),i.jsx(_.GlyphSeries,{dataKey:n.name,data:n.dataPoints,xAccessor:$,yAccessor:M,colorAccessor:a=>ve(M(a),o,D(r)),renderGlyph:a=>Le(a,s)})]},`${n.name}-line`)),e.map((n,r)=>i.jsx(_.LineSeries,{dataKey:`${n.name}${X}-${r}`,data:n.dataPoints,xAccessor:$,yAccessor:M,stroke:ge,opacity:.3,strokeDasharray:"4 4",strokeWidth:it},`${n.name}${X}-${r}-line`))]}),Ee=({series:t,backfilledSeries:e,hideGlyphs:s,hideArea:o,highlightNegativeValues:n})=>i.jsxs(i.Fragment,{children:[i.jsx(Te,{highlightNegativeValues:n}),i.jsx(je,{series:t,backfilledSeries:e,hideArea:o}),i.jsx(Ie,{series:t,backfilledSeries:e,hideGlyphs:s,highlightNegativeValues:n})]}),Ne="_root_1fixl_4",De="_item_1fixl_11",Pe="_label_1fixl_15",Me="_colorBox_1fixl_22",V={root:Ne,item:De,label:Pe,colorBox:Me,"shape-line":"_shape-line_1fixl_28","shape-rectangle":"_shape-rectangle_1fixl_34","shape-circle":"_shape-circle_1fixl_40","shape-square":"_shape-square_1fixl_46"},O=({names:t,style:e,colorAccessor:s=D})=>i.jsx("div",{className:V.root,children:t.map((o,n)=>i.jsxs("span",{className:V.item,children:[i.jsx($e,{color:s(n),style:e}),i.jsx("span",{className:V.label,children:o})]},`${o}-legend-${n}`))}),$e=({color:t,style:e})=>i.jsx("span",{className:`${V.colorBox} ${V[`shape-${e}`]}`,style:{backgroundColor:t}}),Kt="-",nt=(t,e,s)=>e==null||Number.isNaN(e)?t:s?s(e):e,Xt=t=>t.includes(X)||t.includes("white-gap"),Oe=(t,e,s,o,n)=>{var c,l,h;const r=[];let a=0;if(o)for(const u of Object.keys(o))Xt(u)||(n&&(a+=((c=o[u])==null?void 0:c.datum.value)||0),r.push({title:u,value:nt(t,(l=o[u])==null?void 0:l.datum.value,s),color:e(u),valueContext:(h=o[u])==null?void 0:h.datum.valueContext}));return n?[...r,{title:n,value:nt(t,a,s),color:""}]:r},at=t=>"bandwidth"in t&&"paddingInner"in t&&"paddingOuter"in t,lt=t=>{const e=t;return e&&"bandwidth"in e?(e==null?void 0:e.bandwidth())??0:0},Ce=(t,e,s,o)=>{const n=t?o:s;let r;if(n&&at(n)){const a=n.paddingInner(),c=n.paddingOuter();r=1+a+c}else r=1+e;return lt(t?o:s)*r},we=(t,e)=>t?new Intl.DateTimeFormat(e??Intl.DateTimeFormat().resolvedOptions().locale,{month:"short",day:"2-digit",year:"numeric"}).format(t):"",Re=t=>t!==void 0&&t.value!==void 0&&t.timestamp!==void 0,We=(t,e,s)=>Re(t)?we(t.timestamp,e):s&&t?s(t.label):t==null?void 0:t.label,ot=t=>t!==null&&typeof t=="number"&&!Number.isNaN(t)&&Number.isFinite(t),Ge=(t,e,s)=>{const{left:o,top:n}=t,r=!s&&ot(o)?o:e.left,a=s&&ot(n)?n:e.top;return{tooltipLeft:r,tooltipTop:a}},Be=3,Fe=({horizontal:t,style:e,scalePadding:s,tooltipPosition:o})=>{const{innerHeight:n,innerWidth:r,xScale:a,yScale:c}=f.useContext(_.DataContext)||{},l={strokeWidth:e==="bar"?Ce(t,s,a,c):1,stroke:e==="bar"?"var(--fc-tooltip-crosshair-stroke-color-weak)":"var(--fc-tooltip-crosshair-stroke-color)"},{tooltipLeft:h,tooltipTop:u}=o;return i.jsxs(i.Fragment,{children:[!t&&i.jsx("line",{x1:h,x2:h,y1:Be*3+1,y2:Number((c==null?void 0:c.range()[0])||n),strokeWidth:l.strokeWidth,stroke:l.stroke}),t&&i.jsx("line",{x1:0,x2:Number((a==null?void 0:a.range()[1])||r),y1:u,y2:u,strokeWidth:l.strokeWidth,stroke:l.stroke})]})},He="_root_12zit_4",Ye="_imageWrapper_12zit_14",Ve="_image_12zit_14",Ke="_body_12zit_25",Xe="_withTitle_12zit_28",qe="_title_12zit_32",Ue="_type_12zit_39",Je="_description_12zit_47",Ze="_descriptionLine_12zit_54",ze="_item_12zit_60",Qe="_itemDot_12zit_67",ts="_itemValue_12zit_75",N={root:He,imageWrapper:Ye,image:Ve,body:Ke,withTitle:Xe,title:qe,type:Ue,description:Je,descriptionLine:Ze,item:ze,itemDot:Qe,itemValue:ts},mt=({title:t,description:e,imageUrl:s,entries:o})=>{const n=(e==null?void 0:e.split(` `))??[],r=o[1];return i.jsxs("div",{className:N.root,children:[s&&i.jsx("div",{className:N.imageWrapper,children:i.jsx("img",{src:s,alt:e,className:N.image})}),i.jsxs("div",{className:t?`${N.body} ${N.withTitle}`:N.body,children:[i.jsx("div",{className:N.title,children:t}),(r==null?void 0:r.type)&&i.jsxs("div",{className:N.type,children:[r.type,": ",r.title]}),n.length>0&&i.jsx("div",{className:N.description,children:n.map(a=>i.jsx("div",{className:N.descriptionLine,children:a},a))})]}),o.map(a=>i.jsx(es,{title:a.title,color:a.color,value:a.value,type:a==null?void 0:a.typeByGrouping,valueContext:a==null?void 0:a.valueContext},a.title))]})},es=({title:t,value:e,color:s,type:o,valueContext:n})=>i.jsxs("div",{className:N.item,children:[s&&i.jsx("span",{className:N.itemDot,style:{backgroundColor:s}}),i.jsx("span",{children:`${o||t}: `}),i.jsx("span",{className:N.itemValue,children:`${e} ${n||""}`})]},`${t}-value`),ss=()=>{const{tooltipLeft:t,tooltipTop:e}=f.useContext(_.TooltipContext),[s,o]=f.useState("");return f.useEffect(()=>{o(`${t}-${e}`)},[t,e]),s},ns=(t,e,s=!1)=>{var T,v;const{xScale:o,yScale:n,dataRegistry:r}=f.useContext(_.DataContext)||{},a=f.useContext(_.TooltipContext),c=o?lt(o):0,l=n?lt(n):0,h=f.useCallback((y,b)=>{const S=r==null?void 0:r.get(y),A=S==null?void 0:S.xAccessor,j=S==null?void 0:S.yAccessor,L=o&&A?Number(o(A(b)))+c/2||0:void 0,E=n&&j?Number(n(j(b)))+l/2||0:void 0;return{left:L,top:E}},[r,c,l,o,n]),u=(y,b)=>{var E,k;const S=Object.values(((E=a==null?void 0:a.tooltipData)==null?void 0:E.datumByKey)??{}).filter(I=>!I.key.includes("white-gap")),A=S.findIndex(I=>I.key===y),j=(o&&Number(o($(b)||0))+c/2)??0;let L=0;for(let I=0;I<=A;I++)L+=((k=S[I])==null?void 0:k.datum.value)??0;return L=(n&&Number(n(L))+l/2)??0,{left:j,top:L}},d=!!(a!=null&&a.tooltipOpen&&(a!=null&&a.tooltipData)),p=(T=a==null?void 0:a.tooltipData)==null?void 0:T.nearestDatum,x=[];let m=a==null?void 0:a.tooltipLeft,g=a==null?void 0:a.tooltipTop;if(d&&p&&m&&g){if(!t)for(const{key:A,datum:j}of Object.values(((v=a==null?void 0:a.tooltipData)==null?void 0:v.datumByKey)??{})){const{left:L,top:E}=s?u(A,j):h(A,j);ot(L)&&ot(E)&&x.push({key:A,x:L,y:E})}const{left:y,top:b}=s?u(p.key,p.datum):h(p.key,p.datum),S=Ge({left:y,top:b},{left:m,top:g},e);m=S.tooltipLeft,g=S.tooltipTop}return{glyphProps:x,tooltipPosition:{tooltipLeft:m,tooltipTop:g}}},os={position:"absolute",left:0,top:0,opacity:0,width:0,height:0,pointerEvents:"none"},H=3,yt=({crossHairStyle:t,horizontal:e=!1,hideGlyphs:s=!1,missingValueLabel:o=Kt,childSumLabel:n,scalePadding:r=0,colorAccessor:a=()=>"",valueFormatter:c,labelFormatter:l,locale:h,stackingGlyphs:u=!1})=>{var I,J,Z,z,B,R,C;const d=f.useContext(_.TooltipContext),{containerRef:p,TooltipInPortal:x}=ut.useTooltipInPortal({scroll:!0}),{glyphProps:m,tooltipPosition:g}=ns(s,e,u),T=ss(),{tooltipLeft:v,tooltipTop:y}=g,b=Oe(o,a,c,(I=d.tooltipData)==null?void 0:I.datumByKey,n),A=u?[...b].reverse():b,j=(z=(Z=(J=d.tooltipData)==null?void 0:J.nearestDatum)==null?void 0:Z.datum)==null?void 0:z.imageUrl,{innerHeight:L,innerWidth:E,margin:k}=f.useContext(_.DataContext)||{};return i.jsxs(i.Fragment,{children:[i.jsx("svg",{ref:p,style:os},T),(d==null?void 0:d.tooltipOpen)&&(d==null?void 0:d.tooltipData)&&i.jsxs("svg",{width:"100%",height:"100%",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[i.jsx("defs",{children:i.jsx("clipPath",{id:"chart-clip",children:i.jsx("rect",{x:k!=null&&k.left?k.left-H:0,y:k!=null&&k.top?(k==null?void 0:k.top)-H:0,width:E?E+H*2:"100%",height:L?L+H*2:"100%"})})}),i.jsxs("g",{clipPath:"url(#chart-clip)",children:[i.jsx(Fe,{horizontal:e,style:t,scalePadding:r,tooltipPosition:g}),m.map(P=>Xt(P.key)?null:i.jsx(ae.GlyphDot,{cx:P.x,cy:P.y,r:H,fill:a(P.key),stroke:a(P.key)},P.key))]})]}),(d==null?void 0:d.tooltipOpen)&&(d==null?void 0:d.tooltipData)&&i.jsx(x,{left:v,top:y,applyPositionStyle:!0,unstyled:!0,children:i.jsx(mt,{title:We((B=d.tooltipData.nearestDatum)==null?void 0:B.datum,h,l),description:(C=(R=d.tooltipData.nearestDatum)==null?void 0:R.datum)==null?void 0:C.description,imageUrl:j,entries:A})})]})},rs=t=>{if(!t[0])return 0;let e=0;const s=t[0].dataPoints.length;for(let o=0;o<s;o++){const n=t.reduce((r,a)=>{var c;return r+(((c=a==null?void 0:a.dataPoints[o])==null?void 0:c.value)||0)},0);e=Math.max(e,n)}return e},as=(t,e)=>{const s=rs(t),o=Yt(Math.max(s,e??0)),n=Math.ceil(Math.max(s,e||0)/o)*o;return n===0?[0,1]:[0,n]},cs=(t,e)=>{const[s,o]=t,n=(o-s)/(e-1);return Array.from({length:e}).map((a,c)=>Math.ceil(c*n))},Nt=t=>t<1e3?t:t>1e5?Math.ceil(t/(1024*100))*(1024*100):Math.ceil(t/1024)*1024,is=t=>[Nt(t[0]),Nt(t[1])],ls=t=>t.reduce((e,s)=>[...e,...s.dataPoints.map(o=>o.label)],[]),dt=t=>t.length<=12?t:`${t.slice(0,9).trimEnd()}...`,ds={bottom:24,left:52.265625,right:20,top:10},us=({ticks:t,tickLabelStyle:e,valueFormatter:s})=>t.reduce((o,n)=>{const r=dt(s?s(n):String(n)),a=W(r,e).width??0;return Math.max(o,a)},0),hs=({tickLabelStyle:t,tickLength:e})=>{const s=typeof t.dx=="string"?parseFloat(t.dx):t.dx??0;return e+Math.abs(s)},_t=t=>{const{tickLabelStyle:e,ticks:s,valueFormatter:o,tickLength:n,maxLabelHeight:r=6,firstLabelOverflowsBy:a=0}=t,[c,l]=f.useState(ds),h=hs({tickLabelStyle:e,tickLength:n}),u=JSON.stringify(s),d=JSON.stringify(e);return f.useEffect(()=>{const p=JSON.parse(u),x=JSON.parse(d);let g=us({ticks:p,tickLabelStyle:x,tickLength:p.length,valueFormatter:o})+h;a>g&&(g=a),l({top:10,right:20,bottom:r+18,left:g})},[u,d,o,r,a,h]),c},ps=6,Dt=4,vt={fontSize:"var(--typography-font-size-x-small)",fontFamily:`var(${ht})`,fontWeight:_e,fill:"var(--fc-font-color-weak)"},tt=t=>({axisLabel:{},axisLine:{stroke:t==="x"?"var(--fc-axis-x-stroke-color)":"var(--fc-axis-y-stroke-color)"},tickLine:{stroke:"var(--fc-tick-stroke-color)"},tickLabel:{...vt,textAnchor:t==="x"?"middle":"end",verticalAnchor:t==="x"?"end":"middle",dx:t==="x"?0:-Dt,dy:t==="x"?Dt:0},tickLength:ps}),St=t=>({..._.lightTheme,backgroundColor:"var(--fc-base-color)",colors:t,gridStyles:{stroke:"var(--fc-grid-stroke-color)"},axisStyles:{x:{bottom:tt("x"),top:tt("x")},y:{left:tt("y"),right:tt("y")}}}),fs="_root_gqg3e_2",xs={root:fs},gs=({series:t})=>{const e=[...t].reverse();return i.jsx(_.AreaStack,{children:e.map((s,o)=>i.jsx(_.AreaSeries,{dataKey:s.name,data:s.dataPoints,xAccessor:$,yAccessor:M,fillOpacity:.2,lineProps:{strokeWidth:2},fill:D(e.length-1-o)},s.name))})},ms=({tickValues:t})=>{const{yScale:e,innerWidth:s,margin:o}=f.useContext(_.DataContext);return e?i.jsx(re.GridRows,{left:(o==null?void 0:o.left)||0,width:s||0,scale:e,numTicks:5,tickValues:t}):null},ys=5,_s="storage",vs="storage",Pt="top",Ss=({width:t,height:e,series:s,missingValueLabel:o,locale:n,hideLegend:r=!1,legendPosition:a=Pt,markLine:c,valueFormatter:l,childSumLabel:h,domain:u=vs})=>{const d=Ft(s),p=St(Ht(s.length,d.length)),x=as(s,(c==null?void 0:c.value)??0),m=u===_s?is(x):x,g=gt(m,ys),T=cs(m,g.length),v=_t({ticks:T,tickLabelStyle:p.axisStyles.y.left.tickLabel,valueFormatter:l,tickLength:p.axisStyles.y.left.tickLength});return i.jsxs("div",{className:xs.root,children:[!r&&a===Pt&&i.jsx(O,{names:s.map(y=>y.name),style:"line"}),i.jsxs(_.XYChart,{theme:p,xScale:{type:"time"},yScale:{type:"linear",domain:m},height:e,width:t,margin:v,children:[i.jsx(ms,{tickValues:T}),i.jsx(gs,{series:s}),i.jsx(wt,{linearScaleTicks:T,valueFormatter:l,locale:n,series:s}),c&&i.jsx(Gt,{...c}),i.jsx(yt,{crossHairStyle:"line",hideGlyphs:!1,colorAccessor:y=>xt(y,s),missingValueLabel:o,childSumLabel:h,valueFormatter:l,locale:n,stackingGlyphs:!0})]}),!r&&a==="bottom"&&i.jsx(O,{names:s.map(y=>y.name),style:"line"})]})},ks=({horizontal:t})=>{const e=f.useContext(_.DataContext),{xScale:s,yScale:o}=e,n=t?o:s;if(n&&at(n)&&n.bandwidth()>50){const[a,c]=n.range(),l=n.domain().length,h=Math.abs((c-a)/l),u=(h-50)/h;n.paddingInner(u),n.paddingOuter(u/2)}return null},Ts="_root_gqg3e_2",js={root:Ts},bs=(t,e)=>{const[s,o]=f.useState([]),n=f.useContext(_.DataContext),{xScale:r,yScale:a}=n,c=t?a:r,l=c?JSON.stringify(c.domain()):null,h=(n==null?void 0:n.innerWidth)??null,u=(n==null?void 0:n.innerHeight)??null;return f.useEffect(()=>{const d=t?u:h;if(d&&l){let p=JSON.parse(l),x=d/p.length;for(;x<15&&p.length>1;)p=p.filter((m,g)=>g%2===0),x=d/p.length;o(p),e(p)}},[h,u,t,e,l]),s},qt=t=>t.label,Ut=t=>t.value,As=(t,e)=>e?Ut(t):qt(t),Ls=(t,e)=>e?qt(t):Ut(t),Is=t=>{if(t&&at(t)){const e=t.bandwidth(),s=t.paddingInner();return e*(1+s)}return 0},Es=(t,e)=>{const s=vt;return t.reduce((o,n,r)=>{let a=o.rotationAngle,{width:c,height:l}=W(n,s);c>e&&(a=315,{width:c,height:l}=W(n,{...s,transform:`rotate(${a}deg)`}));const h=Math.max(o.maxHeight,l),u=r===0?c:o.firstItemWidth;return{rotationAngle:Math.max(a,o.rotationAngle),maxHeight:h,firstItemWidth:u}},{rotationAngle:0,maxHeight:0,firstItemWidth:0})},Ns=(t,e,s,o)=>{const[n,r]=f.useState(0),a=f.useContext(_.DataContext),{xScale:c}=a,l=t?void 0:c,h=l?l.domain().map(p=>o(p)):null,u=l?JSON.stringify(h):null,d=Math.round(Is(l));return f.useEffect(()=>{if(d>0&&u){const p=JSON.parse(u),{rotationAngle:x,maxHeight:m,firstItemWidth:g}=Es(p,d);r(x),e(m),s(g-d/2)}else r(0)},[d,u,e,s]),n},Ds=(t,e)=>{let s;return t?s="end":s=e>0?"end":"middle",s},Ps=({linearAxesTicks:t,horizontal:e,updateMaxLabelHeight:s,updateFirstLabelOverflowsBy:o,updateBandScaleTicks:n,valueFormatter:r,labelFormatter:a})=>{const c=d=>dt(a(d.toString())),l=Ns(e,s,o,c),h=bs(e,n),u=Ds(e,l);return i.jsxs(i.Fragment,{children:[i.jsx(_.Axis,{tickClassName:"tick",tickLength:4,hideAxisLine:!1,stroke:"var(--fc-axis-y-color)",tickStroke:"var(--fc-tick-stroke-color)",numTicks:t.length,orientation:e?"bottom":"left",tickValues:t,tickFormat:r}),i.jsx(_.Axis,{tickClassName:"tick",tickLength:4,hideAxisLine:!1,orientation:e?"left":"bottom",stroke:"var(--fc-axis-x-color)",tickStroke:"var(--fc-tick-stroke-color)",tickLabelProps:()=>({angle:l,textAnchor:u}),tickFormat:c,tickValues:h})]})},Ms=({series:t,horizontal:e,displayStyle:s})=>{const[o,n]=f.useState(null),r=s==="overlapped",a=h=>n(h.datum.label),c=()=>n(null),l=t.map((h,u)=>i.jsx(_.BarSeries,{dataKey:`${h.name}`,data:h.dataPoints,xAccessor:d=>As(d,e),yAccessor:d=>Ls(d,e),barPadding:20,colorAccessor:d=>o===d.label?G(u):D(u),onPointerMove:r?a:void 0,onPointerOut:r?c:void 0},`${h.name}-bar-${u}`));return r&&l.length>0?l:i.jsx(_.BarGroup,{onPointerMove:a,onPointerOut:c,children:l})},$s=5,Os=t=>String(t),Cs=t=>t,ws=({series:t,height:e,width:s,horizontal:o=!1,displayStyle:n="default",hideLegend:r=!1,allowDecimalTickValues:a=!0,legendPosition:c="top",valueFormatter:l=Os,labelFormatter:h=Cs,onBarClick:u})=>{const[d,p]=f.useState(0),[x,m]=f.useState(0),[g,T]=f.useState(()=>ls(t)),v=n==="overlapped"?.2:0,y=St(q),b=Vt(t,0),S=gt(b,$s,a),A=_t({ticks:o?g:S,tickLabelStyle:y.axisStyles.y.left.tickLabel,tickLength:y.axisStyles.y.left.tickLength,valueFormatter:l,maxLabelHeight:d,firstLabelOverflowsBy:x});return i.jsxs("div",{className:js.root,children:[!r&&c==="top"&&i.jsx(O,{style:"rectangle",names:t.map(j=>j.name)}),i.jsx("span",{className:u?"bar-chart-cursor-pointer":"",children:i.jsxs(_.XYChart,{theme:y,width:s,height:e,horizontal:o,xScale:o?{type:"linear",padding:v,domain:b}:{type:"band",padding:v},yScale:o?{type:"band",padding:v}:{type:"linear",padding:v,domain:b},margin:A,onPointerDown:u,children:[i.jsx(ks,{horizontal:o}),i.jsx(_.Grid,{rows:!o,columns:o,numTicks:S.length-1,stroke:"var(--fc-grid-stroke-color)"},"grid"),i.jsx(Ps,{linearAxesTicks:S,horizontal:o,updateFirstLabelOverflowsBy:m,updateMaxLabelHeight:p,updateBandScaleTicks:T,valueFormatter:l,labelFormatter:h}),i.jsx(Ms,{series:t,horizontal:o,displayStyle:n}),i.jsx(yt,{crossHairStyle:"bar",hideGlyphs:!0,colorAccessor:j=>xt(j,t),horizontal:o,scalePadding:v,valueFormatter:l,labelFormatter:h})]})}),!r&&c==="bottom"&&i.jsx(O,{style:"rectangle",names:t.map(j=>j.name)})]})},Rs="_root_1cl5u_4",Ws="_titleRow_1cl5u_8",Gs="_title_1cl5u_8",Bs="_descriptionWrapper_1cl5u_21",Fs="_description_1cl5u_21",Y={root:Rs,titleRow:Ws,title:Gs,descriptionWrapper:Bs,description:Fs},Hs=({title:t,description:e,icon:s})=>i.jsxs("div",{className:Y.root,children:[i.jsxs("div",{className:Y.titleRow,children:[i.jsx("span",{className:Y.title,children:t}),s]}),e&&i.jsx("div",{className:Y.descriptionWrapper,children:i.jsx("span",{className:Y.description,children:e})})]}),Ys="_root_gqg3e_2",Vs={root:Ys},Mt=5,Ks=({width:t,height:e,series:s,missingValueLabel:o,locale:n,hideGlyphs:r=!1,hideArea:a=!1,hideLegend:c=!1,legendPosition:l="top",highlightNegativeValues:h=!1,markLine:u,valueFormatter:d})=>{const p=Ft(s),x=St(Ht(s.length,p.length)),m=Vt(s,(u==null?void 0:u.value)??0),g=gt(m,Mt),T=_t({ticks:g,tickLabelStyle:x.axisStyles.y.left.tickLabel,valueFormatter:d,tickLength:x.axisStyles.y.left.tickLength});return i.jsxs("div",{className:Vs.root,children:[!c&&l==="top"&&i.jsx(O,{names:s.map(v=>v.name),style:"line"}),i.jsxs(_.XYChart,{theme:x,xScale:{type:"time"},yScale:{type:"linear",domain:m},height:e,width:t,margin:T,children:[i.jsx(_.Grid,{rows:!0,columns:!1,numTicks:Mt,stroke:"var(--fc-grid-stroke-color)"},"grid"),i.jsx(wt,{linearScaleTicks:g,valueFormatter:d,locale:n,series:s}),i.jsx(Ee,{series:s,backfilledSeries:p,hideGlyphs:r,hideArea:a,highlightNegativeValues:h}),u&&i.jsx(Gt,{...u}),i.jsx(yt,{crossHairStyle:"line",hideGlyphs:!1,colorAccessor:v=>xt(v,s),missingValueLabel:o,valueFormatter:d,locale:n})]}),!c&&l==="bottom"&&i.jsx(O,{names:s.map(v=>v.name),style:"line"})]})},rt=10,Xs=({TooltipInPortal:t,x:e,y:s,entries:o})=>i.jsx(t,{left:e,top:s,offsetLeft:rt,offsetTop:rt,applyPositionStyle:!0,unstyled:!0,children:i.jsx(mt,{entries:o})}),qs=({index:t,percentage:e})=>{const[s,o]=f.useState(!1),n=s?G(t):D(t);return i.jsx("div",{onPointerEnter:()=>o(!0),onPointerLeave:()=>o(!1),style:{flexBasis:`${e}%`,backgroundColor:n}})},Us="_stack_98ryw_3",Js="_bar_98ryw_9",$t={stack:Us,bar:Js},Zs=({sections:t,totalLabel:e,totalValue:s})=>{const{containerRef:o,TooltipInPortal:n}=ut.useTooltipInPortal({scroll:!0}),[r,a]=f.useState(null),c=t.map(({name:d})=>d),l=t.map((d,p)=>({color:D(p)??"var(--fc-primary-base-color)",title:d.name,value:d.label}));e&&l.unshift({color:"",title:e,value:s});const h=d=>{const p=d.currentTarget.parentElement,x=(p==null?void 0:p.getBoundingClientRect().left)??0,m=(p==null?void 0:p.getBoundingClientRect().top)??0;a({x:d.clientX-x,y:d.clientY-m})},u=()=>{a(null)};return i.jsxs("div",{ref:o,children:[i.jsxs("div",{className:$t.stack,children:[i.jsx(O,{names:c,style:"square"}),i.jsx("div",{onPointerMove:d=>h(d),onPointerLeave:u,className:$t.bar,children:t.map((d,p)=>i.jsx(qs,{index:p,percentage:d.percentage},d.name))})]}),r!==null&&i.jsx(Xs,{TooltipInPortal:n,x:r.x,y:r.y,entries:l})]})},kt={top:0,right:0,bottom:0,left:0},zs=(t,e,s)=>{const[o,n]=f.useState("label"),[r,a]=f.useState(t),c=r/2,l=o==="label"?s:kt,h=[l.left+c,l.top+c],u=r+l.left+l.right,d=r+l.top+l.bottom;return f.useEffect(()=>{const p=()=>{const x=t+s.left+s.right;e.current&&(e.current.clientWidth<x?(n("legend"),a(Math.min(e.current.clientWidth,t))):(a(t),n("label")))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[t,s,e]),{radius:c,center:h,width:u,height:d,labelStyle:o}},Qs="_root_1o7ku_2",tn={root:Qs},en="var(--fc-base-color)",sn="2px",nn=({arcDatum:t,path:e,onMouseEnter:s,onMouseLeave:o})=>{const n=D(t.index),r=G(t.index),[a,c]=f.useState(n),l=()=>{c(r),s()},h=()=>{c(n),o()};return i.jsx("path",{d:e(t)||"",fill:a,stroke:en,strokeWidth:sn,onMouseEnter:l,onMouseLeave:h,tabIndex:0,"aria-label":`${t.data.label} ${t.data.value}`})},Tt="--body-size-large",Jt={fontSize:`var(${Tt})`,fontWeight:"var(--typography-font-weight-bold)",fontFamily:`var(${ht})`,fill:"var(--fc-font-color-default)"},jt={fontSize:`var(${Tt})`,fontWeight:"var(--typography-font-weight-regular)",fontFamily:`var(${ht})`,fill:"var(--fc-font-color-default)"},Zt={...jt,fill:"var(--fc-font-color-weak)"},w=10,on=4,rn=30,et=15,an=(t,e,s,o)=>{const[n,r]=e,a=s/2+on,c=a+rn;let l,h,u,d,p;return t<=Math.PI/2||o?(l=n+Math.sin(t)*a,h=r-Math.cos(t)*a,u=n+Math.sin(t)*c,d=r-Math.cos(t)*c,p=u+et):t>Math.PI/2&&t<=Math.PI?(l=n+Math.cos(t-Math.PI/2)*a,h=r+Math.sin(t-Math.PI/2)*a,u=n+Math.cos(t-Math.PI/2)*c,d=r+Math.sin(t-Math.PI/2)*c,p=u+et):t>Math.PI&&t<Math.PI*1.5?(l=n-Math.sin(t-Math.PI)*a,h=r+Math.cos(t-Math.PI)*a,u=n-Math.sin(t-Math.PI)*c,d=r+Math.cos(t-Math.PI)*c,p=u-et):(l=n-Math.cos(t-Math.PI*1.5)*a,h=r-Math.sin(t-Math.PI*1.5)*a,u=n-Math.cos(t-Math.PI*1.5)*c,d=r-Math.sin(t-Math.PI*1.5)*c,p=u-et),{x1:l,y1:h,x2:u,y2:d,x3:p}},cn=(t,e,s,o,n,r)=>{const[a,c]=o;let l=0,h=0,u=0,d=0;return t<Math.PI/2?(h=a+s+w-e,l=Math.abs(c)-e+n):t===Math.PI/2?h=Math.abs(a)+s+w-e:t>Math.PI/2&&t<Math.PI?(d=c-e+r,h=a+s+w-e):t===Math.PI?d=c-e+r:t>Math.PI&&t<Math.PI*1.5?(d=Math.abs(c)-e+r,u=Math.abs(a)-e+w):(t===Math.PI*1.5||(l=Math.abs(c)-e+n),u=Math.abs(a)-e+w),{paddingTop:l,paddingRight:h,paddingLeft:u,paddingBottom:d}},ln=(t,e,s,o)=>{const[n,r]=s;let a;return t<=Math.PI||o?a=n+w:a=n-e-w,{textAnchorX:a,textAnchorY:r}},dn=(t,e,s)=>{const o=getComputedStyle(document.body).getPropertyValue("font-size"),n=getComputedStyle(document.documentElement).getPropertyValue(Tt)??"0",r=parseFloat(n)*parseFloat(o);return{textTopOffset:r,textBottomOffset:t&&(e||s)?r:0}},un=(t,e,s)=>{const[o,n]=f.useState({labelWidth:0,valueWidth:0,percentageWidth:0});return f.useEffect(()=>{const r=W(t,Jt).width??0,a=W(e,jt).width??0,c=W(s,Zt).width??0;n({labelWidth:r,valueWidth:a,percentageWidth:c})},[t,e,s]),o},hn=({centroid:t,centroidAngle:e,prevCentroidAngle:s,arcDatum:o,radius:n,showLabelTitle:r,showLabelValue:a,showLabelPercentage:c,setPadding:l,labelsShownOnHover:h,hideLabel:u,valueFormatter:d})=>{const{data:p,startAngle:x,endAngle:m,index:g}=o,T=r||a||c,v=((m-x)/(Math.PI*2)*100).toFixed(1),y=(d==null?void 0:d(p.value))??p.value,b=r?p.label:"",S=`${a?y:""}`,A=c?`(${v}%)`:"",{labelWidth:j,valueWidth:L,percentageWidth:E}=un(b,S,A),k=Math.max(j,L+E),I=!h&&e-s<Math.PI*.15,{x1:J,y1:Z,x2:z,y2:B,x3:R}=an(e,t,n,I),{textAnchorX:C,textAnchorY:P}=ln(e,k,[R,B],I),{textTopOffset:bt,textBottomOffset:ct}=dn(r,a,c),Qt=C<R?k-j:0;return f.useEffect(()=>{if(T){const{paddingTop:te,paddingRight:ee,paddingBottom:se,paddingLeft:ne}=cn(e,n,k,[C,P],bt,ct*1.5);l(Q=>({top:Math.max(Q.top,te),right:Math.max(Q.right,ee),bottom:Math.max(Q.bottom,se),left:Math.max(Q.left,ne)}))}else l(kt)},[e,k,n,C,P,bt,ct,T,l]),T&&!u?i.jsxs("g",{children:[i.jsx("path",{d:`M ${J} ${Z} L ${z} ${B} H ${R}`,stroke:D(g),strokeWidth:"2px",fill:"none"}),i.jsxs("text",{x:C,y:P,...vt,children:[r&&i.jsx("tspan",{dx:Qt,...Jt,children:b}),i.jsxs("tspan",{x:C,dy:ct*1.25,...jt,children:[S," ",i.jsx("tspan",{...Zt,children:A})]})]})]}):null},pn=(t,e)=>({...t,startAngle:t.startAngle===t.endAngle?t.index*(2*Math.PI/e):t.startAngle,endAngle:t.startAngle===t.endAngle?(t.index+1)*(2*Math.PI/e):t.endAngle}),fn=({arc:t,previousArc:e,numberOfArcs:s,radius:o,isLabelHidden:n,showLabelValue:r,showLabelPercentage:a,showLabelTitle:c,path:l,setPaddingForLabels:h,valueFormatter:u})=>{const d=s>3,[p,x]=f.useState(!1),m=n||d&&!p,g=pn(t,s),T=(g.startAngle+g.endAngle)/2,v=e?(e.startAngle+e.endAngle)/2:0,y=l.centroid(g);return i.jsxs(f.Fragment,{children:[i.jsx(nn,{arcDatum:g,path:l,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1)}),i.jsx(hn,{centroid:y,centroidAngle:T,prevCentroidAngle:v,arcDatum:g,radius:o,showLabelTitle:c,showLabelValue:r,showLabelPercentage:a,setPadding:h,valueFormatter:u,labelsShownOnHover:d,hideLabel:m})]},`fondue-charts-pie-arc-${t.index}`)},xn=({size:t,data:e,valueFormatter:s,showLabelTitle:o=!1,showLabelValue:n=!1,showLabelPercentage:r=!1,shouldSortData:a=!1})=>{const[c,l]=f.useState(kt),h=f.useRef(null),{radius:u,labelStyle:d,center:p,width:x,height:m}=zs(t,h,c),g=e.filter(y=>y.value>0),T=g.length>0?g:e,v=a?T.sort((y,b)=>b.value-y.value):T;return i.jsxs("div",{ref:h,className:tn.root,children:[i.jsx("svg",{width:x,height:m,children:i.jsx(K.Group,{top:p[1],left:p[0],children:i.jsx(ce.Pie,{data:v,pieValue:y=>y.value,outerRadius:u,pieSort:null,pieSortValues:null,children:({arcs:y,path:b})=>i.jsx("g",{children:y.map((S,A)=>i.jsx(fn,{arc:S,previousArc:y[A-1],numberOfArcs:y.length,radius:u,isLabelHidden:d==="legend",showLabelValue:n,showLabelPercentage:r,showLabelTitle:o,path:b,setPaddingForLabels:l,valueFormatter:s},`${S.startAngle}-${S.index}-${S.value}-${S.data.label}`))})})})}),d==="legend"&&i.jsx(O,{names:e.map(y=>y.label),style:"circle",colorAccessor:D})]})},gn=768,mn=(t,e,s)=>{const n=t.x1-t.x0<gn?s.mobile:s.desktop;f.useEffect(()=>{const r=t.descendants().filter(a=>{var h;const c=a.x1-a.x0,l=a.y1-a.y0;return(c<=n||l<=n)&&c!==0&&l!==0&&!((h=a.data.id)!=null&&h.includes("group"))});if(r!=null&&r.length&&r.length>0){const a=r.map(l=>l.value??0),c=Math.max(...a);e(c)}else e(0)},[e,n,t])},U=t=>t?t==="PRIMARY"?D(0):t==="SECONDARY"?D(1):t==="TERTIARY"?D(2):t:"transparent",yn=t=>t?t==="PRIMARY"?G(0):t==="SECONDARY"?G(1):t==="TERTIARY"?G(2):t:"transparent",_n=t=>st.hierarchy(st.stratify().id(e=>e.id).parentId(e=>e.parentId)(t).sum(e=>e.value??0)).sort((e,s)=>{if(e.data.data.color===s.data.data.color)return(s.value??0)-(e.value??0);switch(e.data.data.color){case"PRIMARY":return-1;case"SECONDARY":return 1;case"TERTIARY":return 1;default:return 2}}),Ot=(t,e,s)=>{const o=t.currentTarget.closest("svg"),n=(o==null?void 0:o.getBoundingClientRect().left)??0,r=(o==null?void 0:o.getBoundingClientRect().top)??0;s({activeNode:e,x:t.clientX-n,y:t.clientY-r})},vn=({childNodes:t,setTooltipState:e})=>{const[s,o]=f.useState(""),n="translate(6,6)",r=t[0].x0,a=t[0].y0;return i.jsx(K.Group,{transform:n,children:t.map(c=>{const l=c.x0-r,h=c.y0-a,u=c.x1-c.x0,d=c.y1-c.y0,p=s===c.data.id;return i.jsxs(K.Group,{onPointerEnter:()=>o(c.data.id||""),onPointerMove:x=>Ot(x,c.data,e),onPointerDown:x=>Ot(x,c.data,e),onPointerLeave:()=>{e(null),o("")},children:[i.jsx("rect",{x:l,y:h,width:u,height:d,fill:p?yn(c.data.data.color):U(c.data.data.color)}),p&&i.jsx("rect",{x:l+1,y:h+1,width:u-2,height:d-2,fill:"transparent",stroke:U(c.data.data.color),strokeWidth:1.5})]},`child-node-${c.data.id}-${c.x0}-${c.y0}`)})})},Sn=({treemap:t,setTooltipState:e,setSizeThreshold:s,isReadyToBeRendered:o,sizeThresholds:n})=>{var c;const[r,a]=f.useState("");return mn(t,s,n),i.jsx(K.Group,{children:(c=t.children)==null?void 0:c.map((l,h)=>{const u=l.x1-l.x0,d=l.y1-l.y0;return o&&d&&u&&i.jsxs(K.Group,{top:l.y0,left:l.x0,onPointerEnter:()=>a(l.data.id||""),onPointerLeave:()=>a(""),children:[i.jsx("rect",{rx:3,width:u,height:d,x:3,y:3,stroke:r===l.data.id?"var(--color-line-strong)":"var(--fc-axis-y-color)",strokeWidth:1.5,fill:U(l.data.data.color)}),l.children&&l.children.length>0&&i.jsx(vn,{childNodes:l.children,setTooltipState:e})]},`node-${h}`)})})},kn=(t,e,s,o,n,r)=>{var l,h;const c=[{title:o,value:nt(s,e.value,n),color:""}];if(t.depth>1){const u=r==null?void 0:r[t.data.color||""],d=(l=t.data.id)!=null&&l.includes("group")&&((h=t.data.groupIds)==null?void 0:h.length)>1?u==null?void 0:u.plural:u==null?void 0:u.singular,p={title:t.data.label,value:nt(s,t.data.value,n),color:U(t.data.color)??"",typeByGrouping:d??"",type:(u==null?void 0:u.singular)??""};c.push(p)}return c},Tn=t=>{var n;const e=t.data,s=jn(t),o=((n=s.children)==null?void 0:n.reduce((r,a)=>r+(a.value??0),0))??0;return{...e,label:s.data.label,value:o||e.value}},jn=t=>{let e=t;return e.depth>1&&(e=t.parent??t),e},bn=({TooltipInPortal:t,activeNode:e,x:s,y:o,childSumLabel:n,missingValueLabel:r=Kt,valueFormatter:a,groupformatter:c,colorLabelMap:l})=>{var m;const h=Tn(e);let u=0;const d=(m=e.parent)==null?void 0:m.data;d&&"groupIds"in d&&(u=d.groupIds.length);const p=u>1,x=kn(e,h,r,n,a,l);return i.jsx(t,{left:s,top:o,offsetLeft:rt,offsetTop:rt,applyPositionStyle:!0,detectBounds:!0,unstyled:!0,children:i.jsx(mt,{title:p?c==null?void 0:c(u):h.label,entries:x})})},An=(t,e)=>{const s=[],o=[],n=[];for(const r of t){const a=t.find(h=>h.id===r.parentId),c=(a==null?void 0:a.parentId)===null;let l=r.value??0;c?(l=t.filter(u=>u.parentId===r.id).reduce((u,d)=>u+(d.value??0),0)??0,l>(e||0)?s.push(r):n.push(r)):l>(e||0)||r.parentId===null?s.push(r):o.push(r)}return{unchanged:s,toBeGroupedFirstLevel:n,toBeGroupedSecondLevel:o}},Ln=t=>{const e=t.reduce((s,o)=>{const n=`group-${o.color}`,r=s[n];return s[n]=zt(o,n,r,void 0,n),s},{});return Object.values(e)},In=(t,e,s)=>{const o=t.reduce((n,r)=>{var p,x;const a=e.find(m=>{var g;return r.parentId&&((g=m.groupIds)==null?void 0:g.includes(r.parentId))}),c=a?`group-${a.color}-${r.color}`:`group-${r.parentId}-${r.color}`,l=n[c],h=(p=s==null?void 0:s[r.color||""])==null?void 0:p.group,d=l&&l.groupIds&&l.groupIds.length>0?h==null?void 0:h((((x=l.groupIds)==null?void 0:x.length)||0)+1):r.label;return n[c]=zt(r,c,l,a,d),n},{});return Object.values(o)},zt=(t,e,s,o,n)=>s?{...s,label:n||s.label,value:(s.value??0)+(t.value??0),groupIds:[...s.groupIds||[],t.id]}:{...t,id:e,description:"",groupIds:[t.id],parentId:o?`group-${o.color}`:t.parentId},En=t=>{const e=f.useRef();return f.useEffect(()=>{e.current=t}),e.current},Nn=(t,e,s)=>{const[o,n]=f.useState(t),r=f.useRef(!1),a=En(t),c=!ie.isEqual(t,a)&&a!==void 0;return c&&e&&(r.current=!1),f.useEffect(()=>{if(e&&e>0||c){const{unchanged:l,toBeGroupedFirstLevel:h,toBeGroupedSecondLevel:u}=An(t,e),d=Ln(h),p=In(u,d,s);r.current=!0,n([...l,...d,...p])}},[t,e,s]),{groupedData:o,wasGrouped:r.current}},Dn="_root_ryw0h_2",Pn="_chartWrapper_ryw0h_12",Ct={root:Dn,chartWrapper:Pn},Mn=({data:t,childSumLabel:e,missingValueLabel:s="",colorLabelMap:o,valueFormatter:n,width:r,height:a,legendItems:c,sizeThresholds:l={mobile:20,desktop:15}})=>{var L,E;const{containerRef:h,TooltipInPortal:u}=ut.useTooltipInPortal({scroll:!0}),d=f.useRef(null),[p,x]=f.useState(null),[m,g]=f.useState(null),{groupedData:T,wasGrouped:v}=Nn(t,m,o),y=_n(T),A=v&&m===0||m!==null&&!v,j=c==null?void 0:c.map(k=>k.label);return i.jsxs("div",{className:Ct.root,children:[j&&j.length>0&&i.jsx(O,{names:j,style:"square",colorAccessor:k=>{var I;return U((I=c==null?void 0:c[k])==null?void 0:I.color)}}),i.jsx("div",{ref:d,className:Ct.chartWrapper,children:i.jsxs("svg",{width:r,height:a,ref:h,children:[i.jsx(st.Treemap,{top:0,root:y,size:[r-1,a-1],tile:st.treemapBinary,round:!0,paddingOuter:3,paddingInner:1,children:k=>i.jsx(Sn,{treemap:k,setTooltipState:x,setSizeThreshold:g,isReadyToBeRendered:A,sizeThresholds:l})}),p!==null&&i.jsx(bn,{TooltipInPortal:u,childSumLabel:e,missingValueLabel:s,valueFormatter:n,groupformatter:(E=o==null?void 0:o[((L=p.activeNode.parent)==null?void 0:L.data.color)||""])==null?void 0:E.group,colorLabelMap:o,...p})]})})]})};exports.AreaStackChart=Ss;exports.BarChart=ws;exports.ChartHeading=Hs;exports.LineChart=Ks;exports.LinearGauge=Zs;exports.PieChart=xn;exports.Treemap=Mn;exports.isBandScale=at; //# sourceMappingURL=index.cjs.js.map