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