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