UNPKG

@frontify/fondue-charts

Version:

Frontify's data viz library

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