@oliasoft-open-source/charts-library 5.0.1 → 5.0.2-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/assets/{Color-YHDXOIA2-D6i6tiFz.js → Color-YHDXOIA2-Df_YstNU.js} +1 -1
  2. package/dist/assets/{DocsRenderer-CFRXHY34-D88vu1Xb.js → DocsRenderer-CFRXHY34-DKIsUafc.js} +3 -3
  3. package/dist/assets/{bar-chart.stories-D9mtWCnD.js → bar-chart.stories-Eq_jQ19D.js} +1 -1
  4. package/dist/assets/{entry-preview-D2XJoWVM.js → entry-preview-CQnVs0vE.js} +1 -1
  5. package/dist/assets/{get-draggableData-DO0Px5pc.js → get-draggableData-CQpLHCdg.js} +1 -1
  6. package/dist/assets/{iframe-DLnw2TiW.js → iframe-DFPTtPL0.js} +2 -2
  7. package/dist/assets/{legend-context-BNCYpFYh.js → legend-context-vqtlaWwg.js} +2 -2
  8. package/dist/assets/{legend-BI53UIaI.js → legend-krJw8Ykb.js} +1 -1
  9. package/dist/assets/line-chart-Dv_KrvKB.js +1 -0
  10. package/dist/assets/{line-chart.stories-BVsiy8CQ.js → line-chart.stories-ChiBYJlu.js} +94 -69
  11. package/dist/assets/{line-chart.test-case.stories-DgfMW1VB.js → line-chart.test-case.stories-DWzxvnmk.js} +1 -1
  12. package/dist/assets/{pie-chart.stories-BVurv17M.js → pie-chart.stories-BiFagB5b.js} +1 -1
  13. package/dist/assets/{preview-XObsormK.js → preview-BSEAQ_IE.js} +1 -1
  14. package/dist/assets/{preview-CLM2f008.js → preview-DLeQ-_m8.js} +2 -2
  15. package/dist/assets/{scatter-chart.stories-DnivHhIH.js → scatter-chart.stories-BCbRBdJY.js} +1 -1
  16. package/dist/common/helpers/chart-utils.d.ts +1 -0
  17. package/dist/iframe.html +1 -1
  18. package/dist/index.js.js +15 -8
  19. package/dist/index.js.js.map +1 -1
  20. package/dist/line-chart/controls/axes-options/axes-options-interfaces.d.ts +7 -5
  21. package/dist/line-chart/controls/axes-options/axes-validation.d.ts +8 -0
  22. package/dist/line-chart/controls/controls-interfaces.d.ts +1 -1
  23. package/dist/line-chart/controls/controls.d.ts +1 -4
  24. package/dist/line-chart/hooks/use-chart-functions.d.ts +1 -1
  25. package/dist/line-chart/hooks/use-chart-state.d.ts +2 -3
  26. package/dist/line-chart/line-chart.interface.d.ts +4 -0
  27. package/dist/line-chart/state/action-types.d.ts +0 -1
  28. package/dist/line-chart/state/helpers.d.ts +13 -0
  29. package/dist/line-chart/state/state.interfaces.d.ts +3 -12
  30. package/dist/project.json +1 -1
  31. package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/dist/assets/line-chart-BdFuLh7N.js +0 -1
  34. package/dist/line-chart/controls/axes-options/action-types.d.ts +0 -5
  35. package/dist/line-chart/controls/axes-options/axes-options-form-state.d.ts +0 -23
@@ -62,7 +62,7 @@ function print() { __p += __j.call(arguments, '') }
62
62
  Copyright (c) 2018 Jed Watson.
63
63
  Licensed under the MIT License (MIT), see
64
64
  http://jedwatson.github.io/classnames
65
- */var mg;function MP(){return mg||(mg=1,function(t){(function(){var e={}.hasOwnProperty;function n(){for(var o="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(o=s(o,i(c)))}return o}function i(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return n.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var l="";for(var c in o)e.call(o,c)&&o[c]&&(l=s(l,c));return l}function s(o,l){return l?o?o+" "+l:o+l:o}t.exports?(n.default=n,t.exports=n):window.classNames=n})()}(Ec)),Ec.exports}var TP=MP();const PP=xg(TP),pg=10,kP=t=>t.reduce((e,n,i)=>{if(i===0)return e;const s=Math.abs(n-t[i-1]);return Math.max(s,e)},0),CP=(t,e,n)=>{const{axis:i,left:s,top:o,right:l,bottom:c}=n,u=i==="x",h=u?s:o,d=u?l:c,m=t>h,_=t<d,v=e.indexOf(t)!==-1;return m&&_&&!v},EP=(t,e)=>{const n=t.sort((c,u)=>c-u),i=kP(t)/10,s=t[0],o=(t.length+1)*pg;return[...Array(o)].map((c,u)=>{const h=s+(u-pg+1)*i;return parseFloat(h.toFixed(1))}).filter(c=>CP(c,n,e))},IP=t=>{var c,u,h,d,m,_,v,M,T;const{chart:e,ctx:n}=t,i=e.config;if(!((d=(h=(u=(c=i==null?void 0:i.options)==null?void 0:c.scales)==null?void 0:u[t.id])==null?void 0:h.grid)!=null&&d.drawOnChartArea)||i.options.indexAxis===t.axis)return;const s=t.axis==="x",o=t.ticks.map((C,A)=>t.getPixelForTick(A)).sort((C,A)=>C-A),l=EP(o,t);n.save(),n.strokeStyle=((T=(M=(v=(_=(m=i==null?void 0:i._config)==null?void 0:m.options)==null?void 0:_.scales)==null?void 0:v[t.id])==null?void 0:M.grid)==null?void 0:T.color)||"rgba(0,0,0,0.06)",n.lineWidth=.5,l.forEach(C=>{if(n.beginPath(),s){const{top:A,bottom:D}=e.chartArea;n.moveTo(C,A),n.lineTo(C,D)}else{const{left:A,right:D}=e.chartArea;n.moveTo(A,C),n.lineTo(D,C)}n.stroke()}),n.restore()},AP={id:"minorGridlines",beforeDatasetsDraw:t=>{const{scales:e}=t;Object.keys(e).forEach(n=>IP(e[n]))}},ki={ZERO:0,INITIAL:2,HOVERED:6,POINT_HOVERED:8},OP="rgba(0,0,0,0.1)",DP=[10,2],RP=12,Km='"Roobert", "Noto Sans", sans-serif',qm="hsl(60, 10.34482759%, 12.5%)",_g=12,Lk=8,Nk=4,_a="transparent",Bk=[1,10,100,1e3,1e4],LP=["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395","#994499","#22aa99","#aaaa11","#6633cc","#e67300","#8b0707","#651067","#329262","#5574a6","#3b3eac"],Fk="99",NP=16777215,Wk="auto",zk={NO:0,FAST:1e3},BP="new_chart",FP="htmlLegend",WP=9,Hk=1/10**WP,Uk=[{offset:0,color:"rgba(144,238,144,0.8)"},{offset:.6,color:"rgba(255,255,224,0.8)"},{offset:.8,color:"rgba(255,255,224,0.8)"},{offset:.92,color:"rgba(255,182,193,0.5)"},{offset:.99,color:"rgba(255,182,193,0.8)"}];var xf=(t=>(t.X="x",t.Y="y",t))(xf||{}),Si=(t=>(t.Bottom="bottom",t.Top="top",t.Left="left",t.Right="right",t.TopRight="top-right",t.TopLeft="top-left",t.BottomLeft="bottom-left",t.BottomRight="bottom-right",t))(Si||{}),zP=(t=>(t.Line="line",t.Bar="bar",t))(zP||{}),rs=(t=>(t.Pointer="pointer",t.Initial="initial",t.Grab="grab",t.Grabbing="grabbing",t.Crosshair="crosshair",t.Move="move",t))(rs||{}),HP=(t=>(t.Category="category",t.Linear="linear",t.Logarithmic="logarithmic",t))(HP||{}),jm=(t=>(t.Vertical="vertical",t))(jm||{}),UP=(t=>(t.Y="yLabel",t.X="xLabel",t))(UP||{}),VP=(t=>(t.End="end",t.Start="start",t.Center="center",t.Right="right",t.Left="left",t))(VP||{}),$P=(t=>(t.Box="box",t.Ellipse="ellipse",t.Line="line",t.Text="text",t))($P||{}),Zm=(t=>(t.Circle="circle",t.Square="rect",t.Diamond="rectRot",t.Triangle="triangle",t))(Zm||{}),GP=(t=>(t.Nearest="nearest",t))(GP||{}),YP=(t=>(t.X="x",t.Y="y",t.XY="xy",t.Z="z",t))(YP||{}),XP=(t=>(t.Shift="Shift",t))(XP||{}),KP=(t=>(t.Mousemove="mousemove",t.Mouseout="mouseout",t.Click="click",t.Touchstart="touchstart",t.Touchmove="touchmove",t.Dblclick="dblclick",t))(KP||{});const qP={id:"chartAreaBorder",beforeDraw(t,e,n){const{ctx:i,chartArea:{left:s,top:o,width:l,height:c}}=t;i.save(),i.strokeStyle=n.borderColor,i.lineWidth=n.borderWidth,i.setLineDash(n.borderDash||[]),i.lineDashOffset=n.borderDashOffset??0,i.strokeRect(s,o,l,c),i.restore()}},Vk=(t,e)=>{var s;let n=[];t.showMinorGridlines&&n.push(AP);const i=e==null?void 0:e.customLegend;return i!=null&&i.customLegendPlugin&&(i!=null&&i.customLegendContainerID)&&n.push({id:FP,...(s=e==null?void 0:e.customLegend)==null?void 0:s.customLegendPlugin}),n.push(qP),n},jP=t=>{const e=`#${Math.floor(Math.random()*NP).toString(16)}`;return t.includes(e)?jP(t):(t.push(e),t)},$k=t=>t.title!==""?{display:!0,text:t.title}:{},Gk=t=>t===jm.Vertical,Yk=(t,e)=>{const[n,i]=t===xf.Y?[Si.Left,Si.Right]:[Si.Top,Si.Bottom];return e%2===0?n:i},Xk=(t,e)=>{const{width:n,height:i,staticChartHeight:s=!1,squareAspectRatio:o=0}=t,l=o?e.squareAspectRatio:"";let c="";return n||i?c="":c=s?e==null?void 0:e.fixedHeight:e==null?void 0:e.stretchHeight,PP(e.chart,c,l)},Kk=(t,e)=>{const{legend:n}=t||{};return{position:(n==null?void 0:n.position)||Si.Top,display:n==null?void 0:n.display,align:n==null?void 0:n.align,labels:{boxHeight:_g,boxWidth:n!=null&&n.usePointStyle?_g:void 0,usePointStyle:n==null?void 0:n.usePointStyle},onClick:e}},qk=t=>{const{error:e}=t.dataset.data[t==null?void 0:t.dataIndex];return e?`Error: ${Bm(e,4)}`:""},jk=(t,e)=>{var s,o,l;const n=(l=(o=(s=t==null?void 0:t.dataset)==null?void 0:s.data)==null?void 0:o[t==null?void 0:t.dataIndex])==null?void 0:l.label,i=Array.isArray(n)?n.join(" , "):n;return e&&(i!=null&&i.length)?` (${i})`:""},Zk=t=>t?t.reduce((n,i,s)=>{var l;const o=((l=i.label)==null?void 0:l.replace(/\s/g,"_"))||String(s);return[...n,o]},[]).join("_"):BP,Jk=()=>{At.font.size=RP,At.font.family=Km,At.color=qm,At.borderColor=OP},Qk=t=>!!(t==null||t===""||Array.isArray(t)&&t.length===0||typeof t=="object"&&Object.keys(t).length===0),ZP="TOGGLE_DATA_VISIBILITY",JP="RESET_STATE",QP={annotation:[]},tk=(t,e)=>{var n;switch(e.type){case JP:return e.payload;case ZP:{const{chartInstance:i,dsConfig:s,annotationConfig:o}=e.payload,{datasetIndex:l,datasets:c,dataset:u}=s,{annotationIndex:h}=o,d=Pr.cloneDeep(t),m=Pr.defaultTo(i==null?void 0:i.isDatasetVisible(l),!0);if(l>=0&&(i==null||i.setDatasetVisibility(l,!m),u!=null&&u.displayGroup)){const _=u.displayGroup;c.forEach((v,M)=>{v.displayGroup===_&&(i==null||i.setDatasetVisibility(Number(M),!m))})}if(h>=0){const _=Pr.findIndex(d.annotation,{annotationIndex:h});if(_>=0){const v=Pr.defaultTo((n=d.annotation[_])==null?void 0:n.display,!1);Pr.set(d,["annotation",_,"display"],!v)}}return d}default:return t}};var ek=(t=>(t.MOUSEDOWN="mousedown",t.MOUSEMOVE="mousemove",t.MOUSEUP="mouseup",t))(ek||{}),se=(t=>(t.POINT="point",t.BOX="box",t.LINE="line",t.ELLIPSE="ellipse",t))(se||{}),nk=(t=>(t.X="x",t.Y="y",t.Both="both",t))(nk||{});const ik=(t,e,n)=>{var i;e.canvas.style.cursor=rs.Pointer,(i=t.options.scaleID)!=null&&i.includes(xf.X)&&t.options.label&&(t.options.label.xAdjust=e.chartArea.left),t.options.borderWidth=ki.HOVERED,t.options.label&&(t.label.options.display=!0,t.options.label.enabled=!0),n!=null&&n.enableDrag&&(e.hoveredAnnotationId=t.options.id||null,e.update()),e.draw()},sk=(t,e,n)=>{t.options.borderWidth=ki.INITIAL,e.canvas.style.cursor=rs.Initial,e.hoveredAnnotationId=null,t.options.label&&(t.label.options.display=!1,t.options.label.enabled=!1),n!=null&&n.enableDrag&&(e.hoveredAnnotationId=null,e.update()),e.draw()},rk=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=t.options.id||null,e.update(),t.options.borderWidth=ki.HOVERED,e.canvas.style.cursor=rs.Pointer),e.draw()},ok=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=null,t.options.borderWidth=ki.INITIAL,e.canvas.style.cursor=rs.Initial,e.update()),e.draw()},ak=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=t.options.id||null,e.update(),t.options.borderWidth=ki.POINT_HOVERED,e.canvas.style.cursor=rs.Pointer),e.draw()},lk=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=null,t.options.borderWidth=ki.INITIAL,e.canvas.style.cursor=rs.Initial,e.update()),e.draw()},ck=t=>t==null?void 0:t.map((e,n)=>{var A,D,W,z,N,Y;const i=(e==null?void 0:e.annotationAxis)??void 0,s=(e==null?void 0:e.color)??LP[n],o=(e==null?void 0:e.type)??se.LINE,l=e==null?void 0:e.adjustScaleRange,c={[se.LINE]:s,[se.POINT]:s,[se.BOX]:s,[se.ELLIPSE]:_a}[o]||_a,u=o===se.LINE?ki.INITIAL:0,h=o===se.LINE?DP:void 0,d={content:e==null?void 0:e.label,display:!0,font:{weight:"normal"}},m={[se.LINE]:{backgroundColor:s,content:e==null?void 0:e.label,display:!1,position:Si.Top},[se.POINT]:{backgroundColor:((A=e==null?void 0:e.labelConfig)==null?void 0:A.backgroundColor)??_a,content:e==null?void 0:e.label,display:((D=e==null?void 0:e.labelConfig)==null?void 0:D.display)??!!(e!=null&&e.label),position:((W=e==null?void 0:e.labelConfig)==null?void 0:W.position)??Si.Bottom,color:((z=e==null?void 0:e.labelConfig)==null?void 0:z.color)??qm,font:((N=e==null?void 0:e.labelConfig)==null?void 0:N.font)??`12px ${Km}`,borderWidth:ki.INITIAL,padding:5,borderRadius:3,borderColor:((Y=e==null?void 0:e.labelConfig)==null?void 0:Y.borderColor)??_a},[se.BOX]:d,[se.ELLIPSE]:d}[o]||d,_=({element:$},{chart:G})=>{switch(o){case se.LINE:ik($,G,e);break;case se.BOX:rk($,G,e);break;case se.POINT:ak($,G,e);break}},v=({element:$},{chart:G})=>{switch(o){case se.LINE:sk($,G,e);break;case se.BOX:ok($,G,e);break;case se.POINT:lk($,G,e);break}},M=()=>($,G)=>e!=null&&e.onDragStart?e==null?void 0:e.onDragStart($,G):void 0,T=()=>($,G)=>e!=null&&e.onDrag?e==null?void 0:e.onDrag($,G):void 0,C=()=>($,G)=>e!=null&&e.onDragEnd?e==null?void 0:e.onDragEnd($,G):void 0;return{...e,display:e==null?void 0:e.display,annotationIndex:n,id:`${e==null?void 0:e.label}-${e==null?void 0:e.value}-${n}`,scaleID:i,label:m,backgroundColor:s,borderColor:c,borderWidth:u,borderDash:h,type:o,adjustScaleRange:l,enter:_,leave:v,onDragStart:M,onDrag:T,onDragEnd:C,pointStyle:(e==null?void 0:e.pointStyle)??Zm.Circle,resizable:(e==null?void 0:e.resizable)??!0,displayDragCoordinates:(e==null?void 0:e.displayDragCoordinates)??!0}}),fk=({showAnnotations:t,annotationsData:e})=>t&&e&&(e==null?void 0:e.length)?ck(e)??[]:[],uk=(t,e,n)=>{const i=ye.useRef(t);ye.useEffect(()=>{jy(t,i==null?void 0:i.current)||(e({type:"RESET_STATE",payload:t}),i.current=t)},[...n])},hk=ye.createContext(void 0),dk=({children:t,options:e})=>{const{showAnnotations:n=!0,annotationsData:i=[]}=(e==null?void 0:e.annotations)??{},s=fk({showAnnotations:n,annotationsData:i}),o={...QP,annotation:s},[l,c]=ye.useReducer(tk,o),u=ye.useMemo(()=>({state:l,dispatch:c}),[l,e,c]);return uk(o,c,[e]),qy.jsx(hk.Provider,{value:u,children:t})};dk.__docgenInfo={description:"",methods:[],displayName:"LegendProvider",props:{children:{required:!0,tsType:{name:"ReactNode"},description:""},options:{required:!0,tsType:{name:"union",raw:`| ILineChartOptions
65
+ */var mg;function MP(){return mg||(mg=1,function(t){(function(){var e={}.hasOwnProperty;function n(){for(var o="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(o=s(o,i(c)))}return o}function i(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return n.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var l="";for(var c in o)e.call(o,c)&&o[c]&&(l=s(l,c));return l}function s(o,l){return l?o?o+" "+l:o+l:o}t.exports?(n.default=n,t.exports=n):window.classNames=n})()}(Ec)),Ec.exports}var TP=MP();const PP=xg(TP),pg=10,kP=t=>t.reduce((e,n,i)=>{if(i===0)return e;const s=Math.abs(n-t[i-1]);return Math.max(s,e)},0),CP=(t,e,n)=>{const{axis:i,left:s,top:o,right:l,bottom:c}=n,u=i==="x",h=u?s:o,d=u?l:c,m=t>h,_=t<d,v=e.indexOf(t)!==-1;return m&&_&&!v},EP=(t,e)=>{const n=t.sort((c,u)=>c-u),i=kP(t)/10,s=t[0],o=(t.length+1)*pg;return[...Array(o)].map((c,u)=>{const h=s+(u-pg+1)*i;return parseFloat(h.toFixed(1))}).filter(c=>CP(c,n,e))},IP=t=>{var c,u,h,d,m,_,v,M,T;const{chart:e,ctx:n}=t,i=e.config;if(!((d=(h=(u=(c=i==null?void 0:i.options)==null?void 0:c.scales)==null?void 0:u[t.id])==null?void 0:h.grid)!=null&&d.drawOnChartArea)||i.options.indexAxis===t.axis)return;const s=t.axis==="x",o=t.ticks.map((C,A)=>t.getPixelForTick(A)).sort((C,A)=>C-A),l=EP(o,t);n.save(),n.strokeStyle=((T=(M=(v=(_=(m=i==null?void 0:i._config)==null?void 0:m.options)==null?void 0:_.scales)==null?void 0:v[t.id])==null?void 0:M.grid)==null?void 0:T.color)||"rgba(0,0,0,0.06)",n.lineWidth=.5,l.forEach(C=>{if(n.beginPath(),s){const{top:A,bottom:D}=e.chartArea;n.moveTo(C,A),n.lineTo(C,D)}else{const{left:A,right:D}=e.chartArea;n.moveTo(A,C),n.lineTo(D,C)}n.stroke()}),n.restore()},AP={id:"minorGridlines",beforeDatasetsDraw:t=>{const{scales:e}=t;Object.keys(e).forEach(n=>IP(e[n]))}},ki={ZERO:0,INITIAL:2,HOVERED:6,POINT_HOVERED:8},OP="rgba(0,0,0,0.1)",DP=[10,2],RP=12,Km='"Roobert", "Noto Sans", sans-serif',qm="hsl(60, 10.34482759%, 12.5%)",_g=12,Lk=8,Nk=4,_a="transparent",Bk=[1,10,100,1e3,1e4],LP=["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395","#994499","#22aa99","#aaaa11","#6633cc","#e67300","#8b0707","#651067","#329262","#5574a6","#3b3eac"],Fk="99",NP=16777215,Wk="auto",zk={NO:0,FAST:1e3},BP="new_chart",FP="htmlLegend",WP=9,Hk=1/10**WP,Uk=[{offset:0,color:"rgba(144,238,144,0.8)"},{offset:.6,color:"rgba(255,255,224,0.8)"},{offset:.8,color:"rgba(255,255,224,0.8)"},{offset:.92,color:"rgba(255,182,193,0.5)"},{offset:.99,color:"rgba(255,182,193,0.8)"}];var xf=(t=>(t.X="x",t.Y="y",t))(xf||{}),Si=(t=>(t.Bottom="bottom",t.Top="top",t.Left="left",t.Right="right",t.TopRight="top-right",t.TopLeft="top-left",t.BottomLeft="bottom-left",t.BottomRight="bottom-right",t))(Si||{}),zP=(t=>(t.Line="line",t.Bar="bar",t))(zP||{}),rs=(t=>(t.Pointer="pointer",t.Initial="initial",t.Grab="grab",t.Grabbing="grabbing",t.Crosshair="crosshair",t.Move="move",t))(rs||{}),HP=(t=>(t.Category="category",t.Linear="linear",t.Logarithmic="logarithmic",t))(HP||{}),jm=(t=>(t.Vertical="vertical",t))(jm||{}),UP=(t=>(t.Y="yLabel",t.X="xLabel",t))(UP||{}),VP=(t=>(t.End="end",t.Start="start",t.Center="center",t.Right="right",t.Left="left",t))(VP||{}),$P=(t=>(t.Box="box",t.Ellipse="ellipse",t.Line="line",t.Text="text",t))($P||{}),Zm=(t=>(t.Circle="circle",t.Square="rect",t.Diamond="rectRot",t.Triangle="triangle",t))(Zm||{}),GP=(t=>(t.Nearest="nearest",t))(GP||{}),YP=(t=>(t.X="x",t.Y="y",t.XY="xy",t.Z="z",t))(YP||{}),XP=(t=>(t.Shift="Shift",t))(XP||{}),KP=(t=>(t.Mousemove="mousemove",t.Mouseout="mouseout",t.Click="click",t.Touchstart="touchstart",t.Touchmove="touchmove",t.Dblclick="dblclick",t))(KP||{});const qP={id:"chartAreaBorder",beforeDraw(t,e,n){const{ctx:i,chartArea:{left:s,top:o,width:l,height:c}}=t;i.save(),i.strokeStyle=n.borderColor,i.lineWidth=n.borderWidth,i.setLineDash(n.borderDash||[]),i.lineDashOffset=n.borderDashOffset??0,i.strokeRect(s,o,l,c),i.restore()}},Vk=(t,e)=>{var s;let n=[];t.showMinorGridlines&&n.push(AP);const i=e==null?void 0:e.customLegend;return i!=null&&i.customLegendPlugin&&(i!=null&&i.customLegendContainerID)&&n.push({id:FP,...(s=e==null?void 0:e.customLegend)==null?void 0:s.customLegendPlugin}),n.push(qP),n},jP=t=>{const e=`#${Math.floor(Math.random()*NP).toString(16)}`;return t.includes(e)?jP(t):(t.push(e),t)},$k=t=>t.title!==""?{display:!0,text:t.title}:{},Gk=t=>t===jm.Vertical,Yk=(t,e)=>{const[n,i]=t===xf.Y?[Si.Left,Si.Right]:[Si.Top,Si.Bottom];return e%2===0?n:i},Xk=(t,e)=>{const{width:n,height:i,staticChartHeight:s=!1,squareAspectRatio:o=0}=t,l=o?e.squareAspectRatio:"";let c="";return n||i?c="":c=s?e==null?void 0:e.fixedHeight:e==null?void 0:e.stretchHeight,PP(e.chart,c,l)},Kk=(t,e)=>{const{legend:n}=t||{};return{position:(n==null?void 0:n.position)||Si.Top,display:n==null?void 0:n.display,align:n==null?void 0:n.align,labels:{boxHeight:_g,boxWidth:n!=null&&n.usePointStyle?_g:void 0,usePointStyle:n==null?void 0:n.usePointStyle},onClick:e}},qk=t=>{const{error:e}=t.dataset.data[t==null?void 0:t.dataIndex];return e?`Error: ${Bm(e,4)}`:""},jk=(t,e)=>{var s,o,l;const n=(l=(o=(s=t==null?void 0:t.dataset)==null?void 0:s.data)==null?void 0:o[t==null?void 0:t.dataIndex])==null?void 0:l.label,i=Array.isArray(n)?n.join(" , "):n;return e&&(i!=null&&i.length)?` (${i})`:""},Zk=t=>t?t.reduce((n,i,s)=>{var l;const o=((l=i.label)==null?void 0:l.replace(/\s/g,"_"))||String(s);return[...n,o]},[]).join("_"):BP,Jk=()=>{At.font.size=RP,At.font.family=Km,At.color=qm,At.borderColor=OP},Qk=t=>!!(t==null||t===""||Array.isArray(t)&&t.length===0||typeof t=="object"&&Object.keys(t).length===0),t3=t=>t==="",ZP="TOGGLE_DATA_VISIBILITY",JP="RESET_STATE",QP={annotation:[]},tk=(t,e)=>{var n;switch(e.type){case JP:return e.payload;case ZP:{const{chartInstance:i,dsConfig:s,annotationConfig:o}=e.payload,{datasetIndex:l,datasets:c,dataset:u}=s,{annotationIndex:h}=o,d=Pr.cloneDeep(t),m=Pr.defaultTo(i==null?void 0:i.isDatasetVisible(l),!0);if(l>=0&&(i==null||i.setDatasetVisibility(l,!m),u!=null&&u.displayGroup)){const _=u.displayGroup;c.forEach((v,M)=>{v.displayGroup===_&&(i==null||i.setDatasetVisibility(Number(M),!m))})}if(h>=0){const _=Pr.findIndex(d.annotation,{annotationIndex:h});if(_>=0){const v=Pr.defaultTo((n=d.annotation[_])==null?void 0:n.display,!1);Pr.set(d,["annotation",_,"display"],!v)}}return d}default:return t}};var ek=(t=>(t.MOUSEDOWN="mousedown",t.MOUSEMOVE="mousemove",t.MOUSEUP="mouseup",t))(ek||{}),se=(t=>(t.POINT="point",t.BOX="box",t.LINE="line",t.ELLIPSE="ellipse",t))(se||{}),nk=(t=>(t.X="x",t.Y="y",t.Both="both",t))(nk||{});const ik=(t,e,n)=>{var i;e.canvas.style.cursor=rs.Pointer,(i=t.options.scaleID)!=null&&i.includes(xf.X)&&t.options.label&&(t.options.label.xAdjust=e.chartArea.left),t.options.borderWidth=ki.HOVERED,t.options.label&&(t.label.options.display=!0,t.options.label.enabled=!0),n!=null&&n.enableDrag&&(e.hoveredAnnotationId=t.options.id||null,e.update()),e.draw()},sk=(t,e,n)=>{t.options.borderWidth=ki.INITIAL,e.canvas.style.cursor=rs.Initial,e.hoveredAnnotationId=null,t.options.label&&(t.label.options.display=!1,t.options.label.enabled=!1),n!=null&&n.enableDrag&&(e.hoveredAnnotationId=null,e.update()),e.draw()},rk=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=t.options.id||null,e.update(),t.options.borderWidth=ki.HOVERED,e.canvas.style.cursor=rs.Pointer),e.draw()},ok=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=null,t.options.borderWidth=ki.INITIAL,e.canvas.style.cursor=rs.Initial,e.update()),e.draw()},ak=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=t.options.id||null,e.update(),t.options.borderWidth=ki.POINT_HOVERED,e.canvas.style.cursor=rs.Pointer),e.draw()},lk=(t,e,n)=>{n!=null&&n.enableDrag&&(e.hoveredAnnotationId=null,t.options.borderWidth=ki.INITIAL,e.canvas.style.cursor=rs.Initial,e.update()),e.draw()},ck=t=>t==null?void 0:t.map((e,n)=>{var A,D,W,z,N,Y;const i=(e==null?void 0:e.annotationAxis)??void 0,s=(e==null?void 0:e.color)??LP[n],o=(e==null?void 0:e.type)??se.LINE,l=e==null?void 0:e.adjustScaleRange,c={[se.LINE]:s,[se.POINT]:s,[se.BOX]:s,[se.ELLIPSE]:_a}[o]||_a,u=o===se.LINE?ki.INITIAL:0,h=o===se.LINE?DP:void 0,d={content:e==null?void 0:e.label,display:!0,font:{weight:"normal"}},m={[se.LINE]:{backgroundColor:s,content:e==null?void 0:e.label,display:!1,position:Si.Top},[se.POINT]:{backgroundColor:((A=e==null?void 0:e.labelConfig)==null?void 0:A.backgroundColor)??_a,content:e==null?void 0:e.label,display:((D=e==null?void 0:e.labelConfig)==null?void 0:D.display)??!!(e!=null&&e.label),position:((W=e==null?void 0:e.labelConfig)==null?void 0:W.position)??Si.Bottom,color:((z=e==null?void 0:e.labelConfig)==null?void 0:z.color)??qm,font:((N=e==null?void 0:e.labelConfig)==null?void 0:N.font)??`12px ${Km}`,borderWidth:ki.INITIAL,padding:5,borderRadius:3,borderColor:((Y=e==null?void 0:e.labelConfig)==null?void 0:Y.borderColor)??_a},[se.BOX]:d,[se.ELLIPSE]:d}[o]||d,_=({element:$},{chart:G})=>{switch(o){case se.LINE:ik($,G,e);break;case se.BOX:rk($,G,e);break;case se.POINT:ak($,G,e);break}},v=({element:$},{chart:G})=>{switch(o){case se.LINE:sk($,G,e);break;case se.BOX:ok($,G,e);break;case se.POINT:lk($,G,e);break}},M=()=>($,G)=>e!=null&&e.onDragStart?e==null?void 0:e.onDragStart($,G):void 0,T=()=>($,G)=>e!=null&&e.onDrag?e==null?void 0:e.onDrag($,G):void 0,C=()=>($,G)=>e!=null&&e.onDragEnd?e==null?void 0:e.onDragEnd($,G):void 0;return{...e,display:e==null?void 0:e.display,annotationIndex:n,id:`${e==null?void 0:e.label}-${e==null?void 0:e.value}-${n}`,scaleID:i,label:m,backgroundColor:s,borderColor:c,borderWidth:u,borderDash:h,type:o,adjustScaleRange:l,enter:_,leave:v,onDragStart:M,onDrag:T,onDragEnd:C,pointStyle:(e==null?void 0:e.pointStyle)??Zm.Circle,resizable:(e==null?void 0:e.resizable)??!0,displayDragCoordinates:(e==null?void 0:e.displayDragCoordinates)??!0}}),fk=({showAnnotations:t,annotationsData:e})=>t&&e&&(e==null?void 0:e.length)?ck(e)??[]:[],uk=(t,e,n)=>{const i=ye.useRef(t);ye.useEffect(()=>{jy(t,i==null?void 0:i.current)||(e({type:"RESET_STATE",payload:t}),i.current=t)},[...n])},hk=ye.createContext(void 0),dk=({children:t,options:e})=>{const{showAnnotations:n=!0,annotationsData:i=[]}=(e==null?void 0:e.annotations)??{},s=fk({showAnnotations:n,annotationsData:i}),o={...QP,annotation:s},[l,c]=ye.useReducer(tk,o),u=ye.useMemo(()=>({state:l,dispatch:c}),[l,e,c]);return uk(o,c,[e]),qy.jsx(hk.Provider,{value:u,children:t})};dk.__docgenInfo={description:"",methods:[],displayName:"LegendProvider",props:{children:{required:!0,tsType:{name:"ReactNode"},description:""},options:{required:!0,tsType:{name:"union",raw:`| ILineChartOptions
66
66
  | IBarOptions
67
67
  | IPieOptions
68
- | IScatterOptions`,elements:[{name:"ILineChartOptions"},{name:"IBarOptions"},{name:"IPieOptions"},{name:"IScatterOptions"}]},description:""}}};export{Qk as $,VP as A,OP as B,LP as C,Km as D,Wk as E,Xk as F,Uk as G,Pk as H,Vk as I,wa as J,zP as K,_g as L,Fk as M,Yk as N,Bk as O,Si as P,Bm as Q,qk as R,HP as S,Nk as T,GP as U,jk as V,UP as W,Mk as X,Ji as Y,Ma as Z,Zk as _,Lk as a,XP as a0,YP as a1,ki as a2,DP as a3,Y2 as a4,Hk as a5,WP as a6,Zm as a7,KP as a8,se as a9,Ft as aA,Av as aB,Ns as aC,ue as aD,Pg as aE,At as aF,En as aG,Ak as aH,z2 as aI,Rk as aJ,Hs as aK,Dk as aL,Ha as aM,Ek as aN,hk as aO,ZP as aP,Kk as aQ,FP as aR,$P as aS,rs as aa,nk as ab,ek as ac,wk as ad,bt as ae,Xt as af,_n as ag,Jn as ah,Ac as ai,Ur as aj,Ye as ak,Ht as al,La as am,Na as an,Ti as ao,kv as ap,Ca as aq,Rs as ar,Cr as as,Yg as at,ct as au,Zt as av,ot as aw,Gi as ax,te as ay,Rh as az,dk as b,PP as c,Ok as d,Tk as e,zk as f,jP as g,hf as h,Hd as i,Wd as j,$d as k,Ir as l,Sk as m,vk as n,xk as o,yk as p,kk as q,Ik as r,Jk as s,Ck as t,Xm as u,Pr as v,Gk as w,xf as x,RP as y,$k as z};
68
+ | IScatterOptions`,elements:[{name:"ILineChartOptions"},{name:"IBarOptions"},{name:"IPieOptions"},{name:"IScatterOptions"}]},description:""}}};export{Qk as $,VP as A,OP as B,LP as C,Km as D,Wk as E,Xk as F,Uk as G,Pk as H,Vk as I,wa as J,zP as K,_g as L,Fk as M,Yk as N,Bk as O,Si as P,Bm as Q,qk as R,HP as S,Nk as T,GP as U,jk as V,UP as W,Mk as X,Ji as Y,Ma as Z,Zk as _,Lk as a,XP as a0,YP as a1,t3 as a2,ki as a3,DP as a4,Y2 as a5,Hk as a6,WP as a7,Zm as a8,KP as a9,Rh as aA,Ft as aB,Av as aC,Ns as aD,ue as aE,Pg as aF,At as aG,En as aH,Ak as aI,z2 as aJ,Rk as aK,Hs as aL,Dk as aM,Ha as aN,Ek as aO,hk as aP,ZP as aQ,Kk as aR,FP as aS,$P as aT,se as aa,rs as ab,nk as ac,ek as ad,wk as ae,bt as af,Xt as ag,_n as ah,Jn as ai,Ac as aj,Ur as ak,Ye as al,Ht as am,La as an,Na as ao,Ti as ap,kv as aq,Ca as ar,Rs as as,Cr as at,Yg as au,ct as av,Zt as aw,ot as ax,Gi as ay,te as az,dk as b,PP as c,Ok as d,Tk as e,zk as f,jP as g,hf as h,Hd as i,Wd as j,$d as k,Ir as l,Sk as m,vk as n,xk as o,yk as p,kk as q,Ik as r,Jk as s,Ck as t,Xm as u,Pr as v,Gk as w,xf as x,RP as y,$k as z};
@@ -1,4 +1,4 @@
1
- import{ae as Yl,af as Xl,h as E0,ag as zu,ah as vs,ai as _I,aj as fs,ak as N1,al as oo,am as dee,an as hee,ao as zl,ap as YW,aq as fee,ar as pee,as as mee,at as gee,au as dh,av as XW,aw as AI,ax as Zc,ay as Hf,az as I6,aA as KW,aB as yee,aC as M6,aD as T0,aE as R6,aF as vee,v as Cn,aG as b4,aH as Eee,r as Tee,aI as wee,aJ as See,aK as _ee,aL as Aee,aM as Cee,aN as kee,aO as Dee,aP as Iee,aQ as Mee,aR as Ree,aS as w0,c as CI,P as Fd}from"./legend-context-BNCYpFYh.js";import{j as P}from"./jsx-runtime-Y5Ju2SGo.js";import{r as O,g as bee,R as Oe}from"./index-eCxJ45ll.js";import{r as Ro,h as jW}from"./index-BGqSdrBK.js";import{e as Nee}from"./index-B-BONL6g.js";/*!
1
+ import{af as Yl,ag as Xl,h as E0,ah as zu,ai as vs,aj as _I,ak as fs,al as N1,am as oo,an as dee,ao as hee,ap as zl,aq as YW,ar as fee,as as pee,at as mee,au as gee,av as dh,aw as XW,ax as AI,ay as Zc,az as Hf,aA as I6,aB as KW,aC as yee,aD as M6,aE as T0,aF as R6,aG as vee,v as Cn,aH as b4,aI as Eee,r as Tee,aJ as wee,aK as See,aL as _ee,aM as Aee,aN as Cee,aO as kee,aP as Dee,aQ as Iee,aR as Mee,aS as Ree,aT as w0,c as CI,P as Fd}from"./legend-context-vqtlaWwg.js";import{j as P}from"./jsx-runtime-Y5Ju2SGo.js";import{r as O,g as bee,R as Oe}from"./index-eCxJ45ll.js";import{r as Ro,h as jW}from"./index-BGqSdrBK.js";import{e as Nee}from"./index-B-BONL6g.js";/*!
2
2
  * chartjs-plugin-annotation v3.1.0
3
3
  * https://www.chartjs.org/chartjs-plugin-annotation/index
4
4
  * (c) 2024 chartjs-plugin-annotation Contributors
@@ -0,0 +1 @@
1
+ import{j as h}from"./jsx-runtime-Y5Ju2SGo.js";import{r as O}from"./index-eCxJ45ll.js";import{$ as Ht,a0 as qe,a1 as K,x as V,a2 as Ut,v as S,A as j,P as oe,C as J,a3 as Ge,a4 as Yt,g as we,N as qt,S as Wt,y as $t,O as Zt,a5 as le,a6 as ie,Q,a7 as fe,E as De,R as Kt,T as Jt,L as We,a as Qt,U as ge,V as en,W as $,d as tn,r as nn,B as $e,a8 as sn,f as rn,a9 as on,I as ln,aa as F,ab as ze,ac as re,D as an,ad as Z,b as un,s as cn,F as dn,ae as fn,h as gn,i as mn,J as bn,Y as hn,j as pn,k as yn,p as xn,m as _n,n as Tn,o as En,q as An,t as Ln}from"./legend-context-vqtlaWwg.js";import{r as Oe,M as Re,p as me,B as X,s as On,v as Sn,w as Ze,x as Cn,y as Pn,z as wn,A as Dn,E as Nn,N as Ke,G as Mn,S as In,f as vn,e as jn,F as Fn,T as mt,J as kn,K as Gn,h as zn,O as Rn,Q as Bn,k as Vn,q as Xn,U as Hn,u as Un,j as Yn,Z as qn,t as Wn,R as $n,m as Zn,H as Kn,L as Jn,n as Qn,o as es}from"./legend-krJw8Ykb.js";import{c as ts,C as ns,f as Je,a as ss,b as rs}from"./get-draggableData-CQpLHCdg.js";import{e as bt}from"./index-B-BONL6g.js";const os="_chart_e3qdd_1",ls="_canvas_e3qdd_11",is="_fixedHeight_e3qdd_20",as="_stretchHeight_e3qdd_26",us="_squareAspectRatio_e3qdd_32",cs="_table_e3qdd_62",Se={chart:os,canvas:ls,fixedHeight:is,stretchHeight:as,squareAspectRatio:us,table:cs};var ht=Symbol.for("immer-nothing"),Qe=Symbol.for("immer-draftable"),N=Symbol.for("immer-state");function I(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ee=Object.getPrototypeOf;function te(e){return!!e&&!!e[N]}function q(e){var t;return e?pt(e)||Array.isArray(e)||!!e[Qe]||!!((t=e.constructor)!=null&&t[Qe])||Ee(e)||Ae(e):!1}var ds=Object.prototype.constructor.toString();function pt(e){if(!e||typeof e!="object")return!1;const t=ee(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===ds}function be(e,t){Te(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,s)=>t(s,n,e))}function Te(e){const t=e[N];return t?t.type_:Array.isArray(e)?1:Ee(e)?2:Ae(e)?3:0}function Ne(e,t){return Te(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function yt(e,t,n){const s=Te(e);s===2?e.set(t,n):s===3?e.add(n):e[t]=n}function fs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ee(e){return e instanceof Map}function Ae(e){return e instanceof Set}function Y(e){return e.copy_||e.base_}function Me(e,t){if(Ee(e))return new Map(e);if(Ae(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=pt(e);if(t===!0||t==="class_only"&&!n){const s=Object.getOwnPropertyDescriptors(e);delete s[N];let r=Reflect.ownKeys(s);for(let o=0;o<r.length;o++){const i=r[o],l=s[i];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(s[i]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[i]})}return Object.create(ee(e),s)}else{const s=ee(e);if(s!==null&&n)return{...e};const r=Object.create(s);return Object.assign(r,e)}}function Be(e,t=!1){return Le(e)||te(e)||!q(e)||(Te(e)>1&&(e.set=e.add=e.clear=e.delete=gs),Object.freeze(e),t&&Object.entries(e).forEach(([n,s])=>Be(s,!0))),e}function gs(){I(2)}function Le(e){return Object.isFrozen(e)}var ms={};function W(e){const t=ms[e];return t||I(0,e),t}var ae;function xt(){return ae}function bs(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function et(e,t){t&&(W("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ie(e){ve(e),e.drafts_.forEach(hs),e.drafts_=null}function ve(e){e===ae&&(ae=e.parent_)}function tt(e){return ae=bs(ae,e)}function hs(e){const t=e[N];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function nt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[N].modified_&&(Ie(t),I(4)),q(e)&&(e=he(t,e),t.parent_||pe(t,e)),t.patches_&&W("Patches").generateReplacementPatches_(n[N].base_,e,t.patches_,t.inversePatches_)):e=he(t,n,[]),Ie(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ht?e:void 0}function he(e,t,n){if(Le(t))return t;const s=t[N];if(!s)return be(t,(r,o)=>st(e,s,t,r,o,n)),t;if(s.scope_!==e)return t;if(!s.modified_)return pe(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const r=s.copy_;let o=r,i=!1;s.type_===3&&(o=new Set(r),r.clear(),i=!0),be(o,(l,a)=>st(e,s,r,l,a,n,i)),pe(e,r,!1),n&&e.patches_&&W("Patches").generatePatches_(s,n,e.patches_,e.inversePatches_)}return s.copy_}function st(e,t,n,s,r,o,i){if(te(r)){const l=o&&t&&t.type_!==3&&!Ne(t.assigned_,s)?o.concat(s):void 0,a=he(e,r,l);if(yt(n,s,a),te(a))e.canAutoFreeze_=!1;else return}else i&&n.add(r);if(q(r)&&!Le(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;he(e,r),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,s)&&pe(e,r)}}function pe(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Be(t,n)}function ps(e,t){const n=Array.isArray(e),s={type_:n?1:0,scope_:t?t.scope_:xt(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=s,o=Ve;n&&(r=[s],o=ue);const{revoke:i,proxy:l}=Proxy.revocable(r,o);return s.draft_=l,s.revoke_=i,l}var Ve={get(e,t){if(t===N)return e;const n=Y(e);if(!Ne(n,t))return ys(e,n,t);const s=n[t];return e.finalized_||!q(s)?s:s===Ce(e.base_,t)?(Pe(e),e.copy_[t]=Fe(s,e)):s},has(e,t){return t in Y(e)},ownKeys(e){return Reflect.ownKeys(Y(e))},set(e,t,n){const s=_t(Y(e),t);if(s!=null&&s.set)return s.set.call(e.draft_,n),!0;if(!e.modified_){const r=Ce(Y(e),t),o=r==null?void 0:r[N];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(fs(n,r)&&(n!==void 0||Ne(e.base_,t)))return!0;Pe(e),je(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Ce(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Pe(e),je(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Y(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:n[t]}},defineProperty(){I(11)},getPrototypeOf(e){return ee(e.base_)},setPrototypeOf(){I(12)}},ue={};be(Ve,(e,t)=>{ue[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});ue.deleteProperty=function(e,t){return ue.set.call(this,e,t,void 0)};ue.set=function(e,t,n){return Ve.set.call(this,e[0],t,n,e[0])};function Ce(e,t){const n=e[N];return(n?Y(n):e)[t]}function ys(e,t,n){var r;const s=_t(t,n);return s?"value"in s?s.value:(r=s.get)==null?void 0:r.call(e.draft_):void 0}function _t(e,t){if(!(t in e))return;let n=ee(e);for(;n;){const s=Object.getOwnPropertyDescriptor(n,t);if(s)return s;n=ee(n)}}function je(e){e.modified_||(e.modified_=!0,e.parent_&&je(e.parent_))}function Pe(e){e.copy_||(e.copy_=Me(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var xs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,s)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const i=this;return function(a=o,...c){return i.produce(a,u=>n.call(this,u,...c))}}typeof n!="function"&&I(6),s!==void 0&&typeof s!="function"&&I(7);let r;if(q(t)){const o=tt(this),i=Fe(t,void 0);let l=!0;try{r=n(i),l=!1}finally{l?Ie(o):ve(o)}return et(o,s),nt(r,o)}else if(!t||typeof t!="object"){if(r=n(t),r===void 0&&(r=t),r===ht&&(r=void 0),this.autoFreeze_&&Be(r,!0),s){const o=[],i=[];W("Patches").generateReplacementPatches_(t,r,o,i),s(o,i)}return r}else I(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(i,...l)=>this.produceWithPatches(i,a=>t(a,...l));let s,r;return[this.produce(t,n,(i,l)=>{s=i,r=l}),s,r]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){q(e)||I(8),te(e)&&(e=_s(e));const t=tt(this),n=Fe(e,void 0);return n[N].isManual_=!0,ve(t),n}finishDraft(e,t){const n=e&&e[N];(!n||!n.isManual_)&&I(9);const{scope_:s}=n;return et(s,t),nt(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}n>-1&&(t=t.slice(n+1));const s=W("Patches").applyPatches_;return te(e)?s(e,t):this.produce(e,r=>s(r,t))}};function Fe(e,t){const n=Ee(e)?W("MapSet").proxyMap_(e,t):Ae(e)?W("MapSet").proxySet_(e,t):ps(e,t);return(t?t.scope_:xt()).drafts_.push(n),n}function _s(e){return te(e)||I(10,e),Tt(e)}function Tt(e){if(!q(e)||Le(e))return e;const t=e[N];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Me(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Me(e,!0);return be(n,(s,r)=>{yt(n,s,Tt(r))}),t&&(t.finalized_=!1),n}var M=new xs,Ts=M.produce;M.produceWithPatches.bind(M);M.setAutoFreeze.bind(M);M.setUseStrictShallowCopy.bind(M);M.applyPatches.bind(M);M.createDraft.bind(M);M.finishDraft.bind(M);const Et="TOGGLE_ZOOM",At="TOGGLE_PAN",Lt="TOGGLE_POINTS",Ot="TOGGLE_LINE",St="TOGGLE_LEGEND",Ct="TOGGLE_TABLE",Pt="RESET_AXES_RANGES",ye="UPDATE_AXES_RANGES",wt="TOGGLE_DRAG_POINTS",Dt="TOGGLE_DRAG_ANNOTATION",Nt="DISABLE_DRAG_OPTIONS",Es=(e,t)=>Ts(e,n=>{switch(t.type){case Et:{n.zoomEnabled=!n.zoomEnabled,n.panEnabled&&(n.panEnabled=!1),n.enableDragPoints&&(n.enableDragPoints=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case At:{n.panEnabled=!n.panEnabled,n.zoomEnabled&&(n.zoomEnabled=!1),n.enableDragPoints&&(n.enableDragPoints=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case Lt:{n.pointsEnabled=!n.pointsEnabled;break}case Ot:{n.lineEnabled=!n.lineEnabled;break}case St:{n.legendEnabled=!n.legendEnabled;break}case Ct:{n.showTable=!n.showTable;break}case ye:{const{axes:s}=t.payload;n.axes=s;break}case Pt:{const{axes:s}=t.payload;n.axes=s;break}case wt:{n.enableDragPoints=!n.enableDragPoints,n.panEnabled&&(n.panEnabled=!1),n.zoomEnabled&&(n.zoomEnabled=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case Dt:{n.enableDragAnnotation=!n.enableDragAnnotation,n.panEnabled&&(n.panEnabled=!1),n.zoomEnabled&&(n.zoomEnabled=!1);break}case Nt:{(n.enableDragAnnotation||n.enableDragPoints||n.panEnabled||n.zoomEnabled)&&(n.enableDragAnnotation=!1,n.enableDragPoints=!1,n.panEnabled=!1,n.zoomEnabled=!1);break}}}),As=e=>{if(!e)return null;const t=`line-chart-state-${e}`,n=localStorage.getItem(t);return n?JSON.parse(n).state:null},Ls=(e=72)=>{const t=new Date().getTime(),n=e*60*60*1e3;for(let s=0;s<localStorage.length;s++){const r=localStorage.key(s);if(r!=null&&r.includes("line-chart-state-")){const o=localStorage.getItem(r);if(o){const l=JSON.parse(o).timestamp;l&&t-l>n&&localStorage.removeItem(r)}}}},Os=(e,t)=>{if(!t)return;const n=new Date().getTime(),s=`line-chart-state-${t}`,r={state:e,timestamp:n};localStorage.setItem(s,JSON.stringify(r)),Ls()},Ss=({options:e,persistenceId:t})=>{const{chartOptions:{enableZoom:n,enablePan:s,showPoints:r,showLine:o,enableDragAnnotation:i},legend:{display:l},dragData:a}=e,{zoomEnabled:c,panEnabled:u,pointsEnabled:g,lineEnabled:p,legendEnabled:f,enableDragPoints:_,enableDragAnnotation:b}=As(t)||{};return{zoomEnabled:i??b?!1:c??n,panEnabled:u??s,pointsEnabled:g??r,lineEnabled:p??o,legendEnabled:f??l,axes:[],showTable:!1,enableDragPoints:(a==null?void 0:a.enableDragData)&&_,enableDragAnnotation:i??b}},Cs=e=>O.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...e},O.createElement("clipPath",{id:"a"},O.createElement("path",{d:"m0 0h12v12h-12z"})),O.createElement("g",{clipPath:"url(#a)"},O.createElement("path",{d:"m.5 6.5v-1h11v1c-4.16104 0-6.63549 0-11 0z"}))),Ps=e=>O.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e},O.createElement("circle",{cx:6,cy:6,r:2})),ws=e=>O.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...e},O.createElement("clipPath",{id:"a"},O.createElement("path",{d:"m0 0h12v12h-12z"})),O.createElement("g",{clipPath:"url(#a)"},O.createElement("path",{d:"m7.937 6.5c-.11122.42912-.36179.80916-.71237 1.08047-.35058.2713-.78133.4185-1.22463.4185s-.87405-.1472-1.22463-.4185c-.35058-.27131-.60115-.65135-.71237-1.08047h-3.563v-1h3.563c.11122-.42912.36179-.80916.71237-1.08046s.78133-.41851 1.22463-.41851.87405.14721 1.22463.41851.60115.65134.71237 1.08046h3.563v1z"})));function Ds({lineEnabled:e,onToggleLine:t,onTogglePoints:n,pointsEnabled:s,translations:r}){return[{type:"Option",label:r.pointsLines,icon:h.jsx(Oe,{icon:h.jsx(ws,{})}),selected:s&&e,onClick:()=>{s||n(),e||t()}},{type:"Option",label:r.linesOnly,icon:h.jsx(Oe,{icon:h.jsx(Cs,{})}),selected:!s&&e,onClick:()=>{s&&n(),e||t()}},{type:"Option",label:r.pointsOnly,icon:h.jsx(Oe,{icon:h.jsx(Ps,{})}),selected:s&&!e,onClick:()=>{s||n(),e&&t()}}]}const Mt=({options:e})=>{const[t,n]=O.useState(!1),s=e.find(r=>r.selected);return h.jsx(Re,{open:t,setOpen:n,menu:{sections:e,trigger:"Component",component:h.jsx(me,{display:"inline-flex",text:s==null?void 0:s.label,placement:"bottom-start",enabled:!t,children:h.jsx(X,{colored:"muted",basic:!0,small:!0,round:!0,icon:s==null?void 0:s.icon})})}})};Mt.__docgenInfo={description:"",methods:[],displayName:"LineOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};function Ns({onTogglePan:e,onToggleZoom:t,panEnabled:n,zoomEnabled:s,enableDragPoints:r,enableDragAnnotation:o,isDragDataAllowed:i,isDragAnnotationAllowed:l,onToggleDragAnnotation:a,onToggleDragPoints:c,onDisableDragOptions:u,translations:{dragToZoom:g,doubleClickToReset:p,dragToPan:f,dragToMovePoints:_,dragDisabled:b,dragToMoveAnnotation:T}}){return[{label:g,description:p,icon:h.jsx(On,{}),selected:s,type:"Option",onClick:()=>{s||t()}},{label:f,description:p,icon:h.jsx(Sn,{}),selected:n,type:"Option",onClick:()=>{n||e()}},...i?[{label:_,icon:h.jsx(Ze,{}),selected:r,type:"Option",onClick:()=>{r||c()}}]:[],...l?[{label:T,icon:h.jsx(Ze,{}),selected:o,type:"Option",onClick:()=>{o||a()}}]:[],{label:b,icon:h.jsx(Cn,{}),selected:!s&&!n&&!r&&!o,type:"Option",onClick:u}]}const It=({options:e})=>{const t=e.find(n=>n.selected);return h.jsx(Re,{menu:{sections:e,trigger:"Component",component:h.jsx(X,{colored:"muted",basic:!0,small:!0,label:t==null?void 0:t.label,icon:t==null?void 0:t.icon})}})};It.__docgenInfo={description:"@param {import('./drag-options-interfaces').IDragOptions} obj",methods:[],displayName:"DragOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};const Ms="_controls_1edjs_1",Is="_buttons_1edjs_6",rt={controls:Ms,buttons:Is},vs=e=>{const t=O.useCallback(s=>()=>{e({type:s})},[e]);return{onToggleLegend:t(St),onToggleLine:t(Ot),onTogglePan:t(At),onTogglePoints:t(Lt),onToggleTable:t(Ct),onToggleZoom:t(Et),onToggleDragPoints:t(wt),onToggleDragAnnotation:t(Dt),onDisableDragOptions:t(Nt)}},js=(e,t)=>e===void 0||t===void 0||Number(e)<Number(t),Fs=(e,t)=>e===void 0||t===void 0||Number(e)>Number(t),vt=(e,t=0,n=!1)=>{const s=n&&t!==0?t+1:"";return`${e}${s}`},ks=e=>{var t;return((t=e==null?void 0:e.match(/[^0-9/]+/gi))==null?void 0:t[0])??""},Gs=e=>e.join(""),Hr=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,zs=e=>e?Object.values(e).some(t=>!Ht(t)):!1,Xe=({chartRef:e,state:t,options:n,dispatch:s,generatedDatasets:r})=>{const{interactions:{onHover:o,onUnhover:i},axes:l}=n,a=O.useCallback(()=>{const d=e==null?void 0:e.current;d==null||d.resetZoom(),d==null||d.reset(),s({type:"RESET_AXES_RANGES",payload:{axes:[]}})},[e==null?void 0:e.current,s]),c=O.useCallback((d,A,m)=>(x,y)=>{var L,E;if(!(y!=null&&y.length)&&i&&d&&(A(null),i(x),(L=e==null?void 0:e.current)==null||L.update()),y!=null&&y.length&&o){const{index:C,datasetIndex:P}=y[0],D=m[P],w=D==null?void 0:D.data[C];w&&!bt(d,w)&&(A(w),o(x,P,C,m),(E=e==null?void 0:e.current)==null||E.update())}},[o,i,r]),u=O.useCallback(()=>ts(e,t),[e==null?void 0:e.current,t.axes]),g=O.useCallback(d=>{var A,m,x,y,L;if(d.key===qe.Shift){const E=e.current,C=(x=(m=(A=E==null?void 0:E.config)==null?void 0:A.options)==null?void 0:m.plugins)==null?void 0:x.zoom;(y=C==null?void 0:C.zoom)!=null&&y.mode&&((L=C==null?void 0:C.pan)!=null&&L.mode)&&(C.zoom.mode=K.Y,C.pan.mode=K.Y,E==null||E.update())}},[e==null?void 0:e.current]),p=O.useCallback(d=>{var A,m,x,y,L;if(d.key===qe.Shift){const E=e.current,C=(x=(m=(A=E==null?void 0:E.config)==null?void 0:A.options)==null?void 0:m.plugins)==null?void 0:x.zoom;(y=C==null?void 0:C.zoom)!=null&&y.mode&&((L=C==null?void 0:C.pan)!=null&&L.mode)&&(C.zoom.mode=K.XY,C.pan.mode=K.XY,E==null||E.update())}},[e==null?void 0:e.current]),f=O.useCallback(d=>{var m;if(!((m=Object.keys(d))!=null&&m.length))return[];const A=(x,y)=>{var L;return!x[y]||!((L=x[y])!=null&&L.length)?[]:x[y].map((E,C)=>({id:vt(y,C,x[y].length>1),label:(E==null?void 0:E.label)||""}))};return[...A(d,V.X),...A(d,V.Y)]},[l]),_=O.useCallback(()=>{var m;const{scales:d={}}=(e==null?void 0:e.current)||{},A=(m=Object.entries(d))==null?void 0:m.map(([x,{min:y,max:L}])=>({id:x,min:y??0,max:L??0}));s({type:ye,payload:{axes:A}})},[l]),b=O.useCallback(()=>{const d=e==null?void 0:e.current;d==null||d.resetZoom(),d==null||d.reset(),s({type:Pt,payload:{axes:[]}})},[e==null?void 0:e.current]),T=O.useCallback(({axes:d})=>{s({type:ye,payload:{axes:d}})},[]);return{resetZoom:a,onHover:c,handleDownload:u,handleKeyDown:g,handleKeyUp:p,controlsAxesLabels:f(l),updateAxesRangesFromChart:_,onResetAxes:b,onUpdateAxes:T}},ot=(e,t,n)=>{const s=[];return Ut(e)&&s.push("mustHaveAValue"),n==="min"&&!js(e,t)?s.push("mustBeLessThanMax"):n==="max"&&!Fs(e,t)&&s.push("mustBeGreaterThanMin"),s},Rs=e=>{const t=e.map(({id:s,min:r,max:o})=>({id:s,min:ot(String(r),String(o),"min"),max:ot(String(o),String(r),"max")})),n=t.every(s=>s.min.length===0&&s.max.length===0);return{errors:t,valid:n}},lt=1,it=({chartRef:e,state:t})=>{const n=e==null?void 0:e.current;if(!n)return[];const s=(n==null?void 0:n.getInitialScaleBounds())??{};return Object.entries(s).map(([r,{min:o="",max:i=""}])=>{var u;let l=Number(o),a=Number(i);isNaN(l)&&(l=0),isNaN(a)&&(a=l+lt),l===a&&(a+=lt);const{unit:c}=((u=t==null?void 0:t.axes)==null?void 0:u.find(g=>g.id===r))??{};return{id:r,min:l,max:a,unit:c}})},Bs=e=>{var A;const{state:t,controlsAxesLabels:n,onUpdateAxes:s,onResetAxes:r,depthType:o,translations:i,close:l,chartRef:a}=e??{},[c,u]=O.useState({localAxes:it({chartRef:a,state:t}),depthType:o==null?void 0:o.selectedDepthType,edited:!1}),{errors:g,valid:p}=Rs(c.localAxes),f=({name:m,value:x,id:y})=>{u(L=>({...L,localAxes:L.localAxes.map(E=>E.id===y?{...E,[m]:x}:E),edited:!0}))},_=({name:m,value:x,id:y})=>{u(L=>({...L,localAxes:L.localAxes.map(E=>E.id===y&&typeof E.unit=="object"?{...E,unit:{...E.unit,[m]:x}}:E),edited:!0}))},b=m=>{m.preventDefault(),p&&(s({axes:c.localAxes}),l==null||l()),o&&(o!=null&&o.setSelectedDepthType)&&(o==null||o.setSelectedDepthType(c.depthType))},T=()=>{u({localAxes:it({chartRef:a,state:t}),depthType:o==null?void 0:o.selectedDepthType,edited:!1}),r(),l==null||l()},d=m=>m.target.select();return h.jsxs("form",{onSubmit:b,children:[c.localAxes.map(m=>{var E,C;const x=n.find(P=>P.id===m.id),y=(x==null?void 0:x.label)||S.startCase(m.id),L=g.find(P=>P.id===m.id);return h.jsx(Dn,{label:y,children:h.jsxs(Nn,{small:!0,width:"300px",children:[h.jsx(Ke,{name:"min",value:m.min,error:(E=L==null?void 0:L.min)!=null&&E[0]?i[L.min[0]]:null,width:"100%",onChange:P=>f({name:P.target.name,value:P.target.value,id:m.id}),onFocus:d}),h.jsx(Mn,{children:"to"}),h.jsx(Ke,{name:"max",value:m.max,error:(C=L==null?void 0:L.max)!=null&&C[0]?i[L.max[0]]:null,width:"100%",onChange:P=>f({name:P.target.name,value:P.target.value,id:m.id}),onFocus:d}),m.unit?h.jsx(In,{name:"selectedUnit",options:typeof m.unit!="string"?m.unit.options:[],value:typeof m.unit!="string"?m.unit.selectedUnit:void 0,onChange:P=>_({name:P.target.name,value:P.target.value,id:m.id}),autoLayerWidth:!0,width:"15%"}):null]})},m.id)}),((A=o==null?void 0:o.options)==null?void 0:A.length)>0&&h.jsxs(h.Fragment,{children:[h.jsx(vn,{items:o.options.map((m,x)=>({key:x,label:m})),onSelected:m=>u(x=>({...x,depthType:o.options[m],edited:!0})),small:!0,value:o.options.indexOf(c.depthType)}),h.jsx(jn,{})]}),h.jsxs(Fn,{gap:"8px",alignItems:"center",children:[h.jsx(X,{type:"submit",small:!0,colored:!0,label:i.done,disabled:!p||!c.edited}),h.jsx(X,{small:!0,name:"resetAxes",label:i.resetAxes,onClick:T}),h.jsx(mt,{small:!0,muted:!0,children:i.orDoubleClickToCanvas})]})]})},jt=e=>h.jsx(Pn,{placement:"bottom-start",overflowContainer:!0,content:h.jsx(Bs,{...e}),children:h.jsx(me,{text:e.translations.axesOptions,placement:"bottom-start",display:"inline-flex",children:h.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:h.jsx(wn,{})})})});jt.__docgenInfo={description:"",methods:[],displayName:"AxesOptions",props:{chartRef:{required:!0,tsType:{name:"RefObject",elements:[{name:"Chart"}],raw:"RefObject<Chart>"},description:""},state:{required:!0,tsType:{name:"IState"},description:""},controlsAxesLabels:{required:!0,tsType:{name:"Array",elements:[{name:"IAxisControlLabel"}],raw:"IAxisControlLabel[]"},description:""},onUpdateAxes:{required:!0,tsType:{name:"signature",type:"function",raw:"({ axes }: { axes: IAxisState }) => void",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ axes: IAxisState }",signature:{properties:[{key:"axes",value:{name:"IAxisState",required:!0}}]}},name:""}],return:{name:"void"}}},description:""},onResetAxes:{required:!0,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},depthType:{required:!1,tsType:{name:"union",raw:"IDepthType | object",elements:[{name:"IDepthType"},{name:"object"}]},description:""},close:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},translations:{required:!0,tsType:{name:"Record",elements:[{name:"string"},{name:"string"}],raw:"Record<string, string>"},description:""}}};const Ft=({table:e,headerComponent:t,subheaderComponent:n,chartRef:s,state:r,options:o,dispatch:i,generatedDatasets:l,translations:a,controlsPortalId:c})=>{const{enableDragPoints:u,lineEnabled:g,panEnabled:p,pointsEnabled:f,showTable:_,zoomEnabled:b,enableDragAnnotation:T}=r,{dragData:d,depthType:A,annotations:m}=o,{onToggleLine:x,onTogglePan:y,onTogglePoints:L,onToggleTable:E,onToggleZoom:C,onToggleDragPoints:P,onToggleDragAnnotation:D,onDisableDragOptions:w}=vs(i),{handleDownload:H,controlsAxesLabels:k,onResetAxes:ne,onUpdateAxes:G}=Xe({chartRef:s,state:r,options:o,dispatch:i,generatedDatasets:l}),[z,{width:se}]=kn(),U=se<200,R=O.useMemo(()=>Ds({lineEnabled:g,onToggleLine:x,onTogglePoints:L,pointsEnabled:f,translations:a}),[g,f]),B=O.useMemo(()=>Ns({onTogglePan:y,onToggleZoom:C,panEnabled:p,zoomEnabled:b,enableDragPoints:u,enableDragAnnotation:T,isDragDataAllowed:d==null?void 0:d.enableDragData,isDragAnnotationAllowed:m==null?void 0:m.enableDragAnnotation,onToggleDragAnnotation:D,onToggleDragPoints:P,onDisableDragOptions:w,translations:a}),[b,p,u,d==null?void 0:d.enableDragData,m==null?void 0:m.enableDragAnnotation]);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:rt.controls,children:[!!o.title&&h.jsx(mt,{bold:!0,children:o.title}),t,h.jsx(ns,{controlsPortalId:c??"",children:h.jsxs("div",{className:rt.buttons,ref:z,children:[!_&&h.jsxs(h.Fragment,{children:[h.jsx(jt,{chartRef:s,state:r,controlsAxesLabels:k,onUpdateAxes:G,onResetAxes:ne,depthType:A,translations:a}),U?h.jsx(Re,{menu:{placement:"bottom-end",sections:[...R,{type:"Divider"},...B,{type:"Divider"},{icon:"download",label:a.downloadAsPNG,type:"Option",onClick:H}],trigger:"Component",component:h.jsx(X,{colored:"muted",basic:!0,small:!0,round:!0,icon:"menu"})}}):h.jsxs(h.Fragment,{children:[h.jsx(Mt,{options:R}),h.jsx(me,{display:"inline-flex",text:a.downloadAsPNG,placement:"bottom-end",children:h.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:"download",onClick:H})}),h.jsx(It,{options:B})]})]}),e?h.jsx(me,{display:"inline-flex",text:_?a.showChart:a.showTable,placement:"bottom-end",children:h.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:_?"chart":"table",onClick:E})}):null]})})]}),n]})};Ft.__docgenInfo={description:"",methods:[],displayName:"Controls",props:{headerComponent:{required:!1,tsType:{name:"ReactNode"},description:""},subheaderComponent:{required:!1,tsType:{name:"ReactNode"},description:""},table:{required:!1,tsType:{name:"ReactNode"},description:""},chartRef:{required:!0,tsType:{name:"RefObject",elements:[{name:"Chart"}],raw:"RefObject<Chart>"},description:""},state:{required:!0,tsType:{name:"IState"},description:""},options:{required:!0,tsType:{name:"ILineChartOptions"},description:""},dispatch:{required:!0,tsType:{name:"Dispatch",elements:[{name:"any"}],raw:"Dispatch<any>"},description:""},generatedDatasets:{required:!0,tsType:{name:"Array",elements:[{name:"IGeneratedLineChartDataset"}],raw:"IGeneratedLineChartDataset[]"},description:""},translations:{required:!0,tsType:{name:"Record",elements:[{name:"string"},{name:"string"}],raw:"Record<string, string>"},description:""},controlsPortalId:{required:!1,tsType:{name:"string"},description:""}}};const v={TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",MIDDLE_LEFT:"middle-left",MIDDLE_CENTER:"middle-center",MIDDLE_RIGHT:"middle-right",BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right"},at=e=>({label:"",position:e,color:"",unit:{options:[],selectedUnit:"",setSelectedUnit:()=>{}}}),Vs=e=>({x:(e==null?void 0:e.x)||[at("bottom")],y:(e==null?void 0:e.y)||[at("left")]}),Xs=e=>({chartScaleType:(e==null?void 0:e.chartScaleType)||"linear",reverse:(e==null?void 0:e.reverse)||!1,beginAtZero:(e==null?void 0:e.beginAtZero)??!1,stepSize:e==null?void 0:e.stepSize,suggestedMin:e==null?void 0:e.suggestedMin,suggestedMax:e==null?void 0:e.suggestedMax,range:e==null?void 0:e.range,autoAxisPadding:(e==null?void 0:e.autoAxisPadding)??!1}),Hs=e=>({width:e==null?void 0:e.width,height:e==null?void 0:e.height,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)??!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)??!1,performanceMode:(e==null?void 0:e.performanceMode)??!0,squareAspectRatio:(e==null?void 0:e.squareAspectRatio)??!1,layoutPadding:(e==null?void 0:e.layoutPadding)||{top:0,bottom:20,left:0,right:0}}),Us=e=>({tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)??!1,hideSimulationName:(e==null?void 0:e.hideSimulationName)??!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),Ys=e=>({lineTension:(e==null?void 0:e.lineTension)??.01,spanGaps:(e==null?void 0:e.spanGaps)??!1,showDataLabels:(e==null?void 0:e.showDataLabels)??!1,showMinorGridlines:(e==null?void 0:e.showMinorGridlines)??!1}),qs=e=>e?e.map(t=>({...t,display:(t==null?void 0:t.display)??!0})):[],Ws=e=>{var t,n,s,r,o,i,l,a;return{labelAnnotation:{showLabel:((t=e==null?void 0:e.labelAnnotation)==null?void 0:t.showLabel)??!1,text:((n=e==null?void 0:e.labelAnnotation)==null?void 0:n.text)??"",position:((s=e==null?void 0:e.labelAnnotation)==null?void 0:s.position)??v.BOTTOM_RIGHT,fontSize:((r=e==null?void 0:e.labelAnnotation)==null?void 0:r.fontSize)??12,xOffset:((o=e==null?void 0:e.labelAnnotation)==null?void 0:o.xOffset)??5,yOffset:((i=e==null?void 0:e.labelAnnotation)==null?void 0:i.yOffset)??5,maxWidth:((l=e==null?void 0:e.labelAnnotation)==null?void 0:l.maxWidth)??300,lineHeight:((a=e==null?void 0:e.labelAnnotation)==null?void 0:a.lineHeight)??12},showAnnotations:(e==null?void 0:e.showAnnotations)??!1,controlAnnotation:(e==null?void 0:e.controlAnnotation)??!1,enableDragAnnotation:(e==null?void 0:e.enableDragAnnotation)??!1,annotationsData:qs(e==null?void 0:e.annotationsData)}},$s=e=>({display:(e==null?void 0:e.display)??!0,position:(e==null?void 0:e.position)??oe.BottomLeft,align:(e==null?void 0:e.align)??j.Center,customLegend:(e==null?void 0:e.customLegend)??{customLegendPlugin:null,customLegendContainerID:""},usePointStyle:(e==null?void 0:e.usePointStyle)??!0}),Zs=e=>({showPoints:(e==null?void 0:e.showPoints)??!0,showLine:(e==null?void 0:e.showLine)??!0,enableZoom:(e==null?void 0:e.enableZoom)??!0,enablePan:(e==null?void 0:e.enablePan)??!1,enableDragAnnotation:(e==null?void 0:e.enableDragAnnotation)??!1,closeOnOutsideClick:(e==null?void 0:e.closeOnOutsideClick)??!1}),Ks=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover,onAnimationComplete:e==null?void 0:e.onAnimationComplete}),Js=e=>({enableDragData:(e==null?void 0:e.enableDragData)??!1,showTooltip:(e==null?void 0:e.showTooltip)??!0,roundPoints:(e==null?void 0:e.roundPoints)??!0,dragX:(e==null?void 0:e.dragX)??!0,dragY:(e==null?void 0:e.dragY)??!0,onDragStart:e==null?void 0:e.onDragStart,onDrag:e==null?void 0:e.onDrag,onDragEnd:e==null?void 0:e.onDragEnd}),kt=e=>{const t=(e==null?void 0:e.chart)||{},n=(t==null?void 0:t.options)||{};return{persistenceId:(t==null?void 0:t.persistenceId)??"",controlsPortalId:(t==null?void 0:t.controlsPortalId)??"",testId:(t==null?void 0:t.testId)??void 0,data:t==null?void 0:t.data,options:{title:(n==null?void 0:n.title)??"",scales:(n==null?void 0:n.scales)??{},axes:Vs(n==null?void 0:n.axes),additionalAxesOptions:Xs(n==null?void 0:n.additionalAxesOptions),chartStyling:Hs(n==null?void 0:n.chartStyling),tooltip:Us(n==null?void 0:n.tooltip),graph:Ys(n==null?void 0:n.graph),annotations:Ws(n==null?void 0:n.annotations),legend:$s(n==null?void 0:n.legend),chartOptions:Zs(n==null?void 0:n.chartOptions),interactions:Ks(n==null?void 0:n.interactions),dragData:Js(n==null?void 0:n.dragData),depthType:(n==null?void 0:n.depthType)??{}}}},Qs=(e,t)=>{if(S.isEmpty(e)||S.isEmpty(t))return!1;const n=s=>typeof t=="string"?s&&S.has(s,t):S.isArray(t)?s&&S.some(t,r=>s&&S.has(s,r)):s&&S.some(Object.values(t),r=>s&&S.has(s,r));return S.isArray(e)?S.some(e,n):n(e)};var Gt=(e=>(e.showLine="showLine",e.showPoints="showPoints",e))(Gt||{});const er=(e,t,n,{label:s})=>{const r=[...e??[]],{annotations:o,graph:i}=n??{},{controlAnnotation:l,showAnnotations:a,annotationsData:c=[]}=o??{};if(l&&a){const u=c.map((g,p)=>{const{type:f,..._}=g,b=_.color??J[p],T=Yt,d=Ge.INITIAL;return{..._,isAnnotation:!0,annotationType:f,label:_.label,annotationIndex:p,backgroundColor:b,pointBackgroundColor:b,borderColor:b,borderDash:T,borderWidth:d,data:[{}]}});r.push(...u)}return r==null?void 0:r.map((u,g)=>{var B,He;const{formation:p,data:f=[],pointRadius:_,pointHoverRadius:b,borderWidth:T,borderColor:d,backgroundColor:A,pointBackgroundColor:m,borderDash:x,showPoints:y,showLine:L}=u??{},{lineEnabled:E,pointsEnabled:C,axes:P=[]}=t??{},{lineTension:D,spanGaps:w}=i??{};if(p){const Ue=Number((B=P[0])==null?void 0:B.min),Ye=Number((He=P[0])==null?void 0:He.max),[ce,de]=f;Ue&&(ce!=null&&ce.x)&&(f[0].x=Math.max(Ue,ce.x)),Ye&&(de!=null&&de.x)&&(f[2].x=Math.min(Ye,de.x))}const H=Qs(u,Gt),k=f.filter(Boolean)||[],ne=(k==null?void 0:k.length)===1;let G,z;y!==void 0?G=y:L===!1?G=!0:G=C||ne,L!==void 0?z=L:y===!1?z=!0:z=E;const se=parseFloat(_)||zn,U=parseFloat(b)||Gn,R=J[g];return{...u,label:(u==null?void 0:u.label)??`${s} ${g+1}`,data:k,showLine:z,lineTension:(u==null?void 0:u.lineTension)??D,spanGaps:w,borderWidth:parseFloat(T)||Vn,borderDash:x||[],borderJoinStyle:Bn,borderColor:d??R??we(J),backgroundColor:A??Rn,pointBackgroundColor:m??R??we(J),pointRadius:G?se:0,pointHoverRadius:U,pointHitRadius:(u==null?void 0:u.pointHitRadius)??U,...H?{hasCustomOpt:H}:{}}})},zt=e=>e==null?void 0:e.reduce((t,n)=>({...t,[n.annotationAxis]:[...t[n.annotationAxis]||[],+n.value]}),{}),Rt=(e,t,n)=>{if(!e||!e.current)return null;const s=e.current.getSortedVisibleDatasetMetas(),r=zt(n)[t]??[];let o=[];if(s.forEach(a=>{const c=a._parsed.map(u=>u[t]).filter(u=>u!=null&&!isNaN(u));o=o.concat(c)}),o=o.concat(r),o.length===0)return null;const i=Math.min(...o),l=Math.max(...o);return{min:i,max:l}},ke=(e,t,n,s,r=0)=>{var u,g,p,f,_,b,T;const o=s||e.axes[t][0]||{},i=n==null?void 0:n.axes.filter(d=>{var A;return(A=d==null?void 0:d.id)==null?void 0:A.startsWith(t)})[r],l=(g=(u=e==null?void 0:e.scales)==null?void 0:u[`${r===0?t:t+r}`])==null?void 0:g.ticks,{additionalAxesOptions:a}=e,c=()=>{const d=(a==null?void 0:a.chartScaleType)===Wt.Logarithmic,A=(y,L,E)=>d?Zt.includes(y)?Je(y,E):"":Je(y,E);return{...d?{}:{stepSize:o.stepSize??(t===V.Y?a.stepSize:null)},callback:A,includeBounds:!1,...l,font:{size:$t}}};return{display:!0,type:a.chartScaleType,position:o.position,beginAtZero:a.beginAtZero,reverse:t===V.Y?a.reverse:!1,suggestedMax:a.suggestedMax,suggestedMin:a.suggestedMin,min:(i==null?void 0:i.min)??((f=(p=a==null?void 0:a.range)==null?void 0:p[t])==null?void 0:f.min),max:(i==null?void 0:i.max)??((b=(_=a==null?void 0:a.range)==null?void 0:_[t])==null?void 0:b.max),title:{display:(T=o.label)==null?void 0:T.length,text:o.label,padding:0},ticks:c(),grid:{...o.gridLines}}},ut=(e,t,n)=>e.axes[t].reduce((o,i,l)=>{const a=i;a.color=i.color||J[l]||we(J),a.position=i.position||qt(t,l);const c=ke(e,t,n,a,l),u=vt(t,l,!0);return{...o,[u]:c}},{}),tr=(e,t)=>{var i,l;const n=((i=e.axes.x)==null?void 0:i.length)>1,s=((l=e.axes.y)==null?void 0:l.length)>1,r=n?ut(e,V.X,t):{x:ke(e,V.X,t)},o=s?ut(e,V.Y,t):{y:ke(e,V.Y,t)};return{...r,...o}},nr=e=>{var n;if(!Array.isArray(e)||!(e!=null&&e.length))return!1;const t=e==null?void 0:e.reduce((s,r)=>{var a,c,u,g;const o=(r==null?void 0:r.xAxisID)??"defaultX",i=(r==null?void 0:r.yAxisID)??"defaultY",l=(r==null?void 0:r.data)??[];if(l&&(l!=null&&l.length)){const{x:p,y:f}=(l==null?void 0:l[0])??{},{x:_=0,y:b=0}=(l==null?void 0:l.at(-1))??{},T=((a=s==null?void 0:s[o])==null?void 0:a.xFirst)??p,d=((c=s==null?void 0:s[o])==null?void 0:c.xLast)??_,A=((u=s==null?void 0:s[i])==null?void 0:u.yFirst)??f,m=((g=s==null?void 0:s[i])==null?void 0:g.yLast)??b,x=Math.min(p,T),y=Math.max(_,d),L=Math.min(f,A),E=Math.max(b,m);s={...s,[o]:{...s[o],xFirst:x,xLast:y},[i]:{yFirst:L,yLast:E}}}return s},{});return(n=Object.values(t))==null?void 0:n.some(({xFirst:s,xLast:r,yFirst:o,yLast:i})=>le(s,r,{absoluteDiff:ie})||le(o,i,{absoluteDiff:ie}))},ct=.05,sr={min:-1,max:1},rr=({data:e,beginAtZero:t=!1,autoAxisPadding:n=!1})=>{const s=Math.min(...e.filter(f=>f!=null&&!isNaN(f))),r=Math.max(...e.filter(f=>f!=null&&!isNaN(f))),o=Math.sign(s)===-1||Math.sign(r)===-1,i=le(s,0,{absoluteDiff:ie})&&le(r,0,{absoluteDiff:ie});if(!(e!=null&&e.length)||i)return sr;if(le(s,r,{absoluteDiff:ie})){const f=r,_=f*ct,b=t&&!o?0:f-_,T=t&&o?0:f+_,d=Q(T,fe),A=Q(b,fe);return{min:d<0?d:A,max:A<0?A:d}}if(!n)return{min:void 0,max:void 0};const l=s===0||r===0||t,a=Math.sign(s)===-1&&Math.sign(r)===1,c=Math.abs(r-s),u=n?c*ct:0,g=!a&&l&&t&&!o?0:s-u,p=!a&&l&&t&&o?0:r+u;return{min:Q(g,fe),max:Q(p,fe)}},or=(e,t,n)=>{var o;if(!e||!t)return{};const s=((o=e==null?void 0:e.current)==null?void 0:o.getSortedVisibleDatasetMetas())??[],r=zt(n);return s&&(t==null?void 0:t.reduce((i,l)=>{const a=s.filter(c=>Object.values(c).includes(l)).flatMap(c=>c._parsed).map(c=>c[ks(l)]).concat((r==null?void 0:r[l])??[]);return{...i,[l]:[...new Set(a)]}},{}))},dt=(e,t)=>!S.isNil(e)||!S.isNil(t),lr=(e,t,n,s)=>{const{additionalAxesOptions:r,annotations:{annotationsData:o=[],controlAnnotation:i=!1}={}}=e||{},l=tr(e,t)||{},a=i?n.filter(({isAnnotation:p})=>!p):n;if(!(r!=null&&r.autoAxisPadding)&&!nr(a))return l;const c=Object.keys(l)??[],u=or(s,c,o);return(u&&(c==null?void 0:c.reduce((p,f)=>{const _=l[f],{min:b=void 0,max:T=void 0}=_,{min:d,max:A}=Rt(s,f,o)??{},{min:m,max:x}=rr({data:u[f],beginAtZero:r==null?void 0:r.beginAtZero,autoAxisPadding:r==null?void 0:r.autoAxisPadding}),y={[f]:{..._,min:b??(dt(b,T)?d:m),max:T??(dt(b,T)?A:x)}};return{...p,...y}},{})))??l},ir=(e,t,n,s,r)=>{const i=e??0,l=t??0,a=n??0,c=s??0,u=r??0,g=i-100<=a,p=i+100>=c,f=i+100>=a&&i+100<c&&l+100>=u;return{overLeftSide:g,overRightSide:p,overBottomSide:f}},ar=e=>{var g;const{chart:t,dataIndex:n=0,datasetIndex:s=0}=e,{chartArea:r}=t,{left:o=null,right:i=null,bottom:l=null}=r,a=t.getDatasetMeta(s),{x:c=null,y:u=null}=((g=a==null?void 0:a.data)==null?void 0:g[n])||{};return{x:c,y:u,left:o,right:i,bottom:l}},ur=()=>e=>{const{x:t,y:n,left:s,right:r,bottom:o}=ar(e),{overLeftSide:i=!1,overRightSide:l=!1,overBottomSide:a=!1}=ir(t,n,s,r,o);return i&&j.Right||l&&j.Left||a&&j.End||j.Start},cr=e=>e.graph.showDataLabels?{display:De,align:ur(),formatter:(t,n)=>{var r,o;const s=(o=(r=n==null?void 0:n.dataset)==null?void 0:r.data)==null?void 0:o[n==null?void 0:n.dataIndex];return s&&typeof(s==null?void 0:s.label)=="string"?s==null?void 0:s.label:""}}:{display:!1},dr=e=>{const t=e==null?void 0:e.match(/\[(.*)\]/g);return t&&(t==null?void 0:t.length)>0?t==null?void 0:t[0]:""},ft=(e,t)=>{let n={};return t?(Math.abs(e)<Xn||Math.abs(e)>Hn)&&(n={roundScientificCoefficient:3}):n={scientific:!1},tn(nn(e),n)},fr=e=>{const{scientificNotation:t}=e.tooltip,n=({xAxisID:o="",yAxisID:i=""})=>{var g,p,f;const l=(o==null?void 0:o.length)>1?Number(o[1])-1:0,a=(i==null?void 0:i.length)>1?Number(i[1])-1:0,c=e.axes.x[l],u=e.axes.y[a];return((f=(p=(g=e==null?void 0:e.axes)==null?void 0:g.x)==null?void 0:p[0])==null?void 0:f.position)===oe.Top?{titleAxisLabel:(u==null?void 0:u.label)||"",valueAxisLabel:(c==null?void 0:c.label)||"",titleLabel:$.Y,valueLabel:$.X}:{titleAxisLabel:(c==null?void 0:c.label)||"",valueAxisLabel:(u==null?void 0:u.label)||"",titleLabel:$.X,valueLabel:$.Y}},s=o=>{const i=n(o[0].dataset),{titleLabel:l,titleAxisLabel:a}=i??{},c=l===$.Y?o[0].parsed.y:o[0].parsed.x;return`${ft(c,t)} ${a}`},r=o=>{const{showLabelsInTooltips:i}=e.tooltip;let l=o.dataset.label||"";const a=n(o.dataset),{valueLabel:c="",valueAxisLabel:u=""}=a??{},p=(()=>{const b=c===$.X?o.parsed.x:o.parsed.y;return ft(b,t)})(),f=dr(u),_=en(o,i);return`${l}: ${p} ${f} ${_}`};return{enabled:e.tooltip.tooltips,mode:ge.Nearest,intersect:!0,padding:Qt,usePointStyle:!0,boxWidth:We,boxHeight:We,boxPadding:Jt,callbacks:{title:s,label:r,afterLabel:Kt}}},gr=({chartRef:e,state:t,options:n,dispatch:s,generatedDatasets:r})=>{const{interactions:{onAnimationComplete:o},annotations:{labelAnnotation:{showLabel:i,text:l,position:a,fontSize:c,xOffset:u,yOffset:g,maxWidth:p,lineHeight:f}={}},chartStyling:{layoutPadding:_}}=n,{enableDragPoints:b,zoomEnabled:T,panEnabled:d,lineEnabled:A}=t,[m,x]=O.useState(null),{updateAxesRangesFromChart:y,onHover:L}=Xe({chartRef:e,state:t,options:n,dispatch:s,generatedDatasets:r}),{legend:E,customLegendPlugin:C}=Un({chartRef:e,options:n})??{},{state:P}=Yn()??{},{annotation:D}=P??{},w=cr(n),H=fr(n),k=O.useMemo(()=>lr(n,t,r,e),[n,t,r,e]),ne=O.useMemo(()=>b&&ss(n),[b,n]),G=O.useMemo(()=>({enabled:d,mode:K.XY,onPanComplete(){y()}}),[d]),z=O.useMemo(()=>({mode:K.XY,drag:{enabled:T,threshold:3,backgroundColor:qn,borderColor:$e,borderWidth:1},onZoomComplete(){y()}}),[T]),se={datalabels:w,annotationDraggerPlugin:{enabled:t==null?void 0:t.enableDragAnnotation},annotation:Wn(D),zoom:{pan:G,zoom:z},tooltip:H,legend:{...E,display:!1,events:[]},customLegendPlugin:C,chartAreaBorder:{borderColor:$e},chartAreaText:{showLabel:i,text:l,position:a,fontSize:c,xOffset:u,yOffset:g,maxWidth:p,lineHeight:f},...ne};return O.useMemo(()=>{var U,R,B;return{layout:{padding:_},onHover:L(m,x,r),maintainAspectRatio:(U=n==null?void 0:n.chartStyling)==null?void 0:U.maintainAspectRatio,aspectRatio:(R=n==null?void 0:n.chartStyling)!=null&&R.squareAspectRatio?1:0,animation:(B=n==null?void 0:n.chartStyling)!=null&&B.performanceMode?!1:{duration:rn.FAST,onComplete:o},hover:{mode:ge.Nearest,intersect:!0},elements:{line:{pointStyle:sn.Circle,showLine:A,tension:0}},scales:k,plugins:se,events:Object.values(on)}},[t,n,e,r])},mr=({options:e,resetZoom:t})=>{const{graph:n,legend:s}=e,r=O.useCallback(S.debounce(()=>{t()},100),[t]),o=O.useCallback((i,l)=>{const{event:a}=l;a.type===$n&&r()},[r]);return O.useMemo(()=>[...ln(n,s),{id:"customEventCatcher",beforeEvent:o}],[o])},br=1,hr=(e,t)=>{var n,s;O.useEffect(()=>{var r,o;if((o=(r=t==null?void 0:t.legend)==null?void 0:r.customLegend)!=null&&o.customLegendPlugin){const i=document.getElementById(t.legend.customLegend.customLegendContainerID);i!==null&&(i.style.visibility=e.legendEnabled?"visible":"hidden")}},[(s=(n=t==null?void 0:t.legend)==null?void 0:n.customLegend)==null?void 0:s.customLegendPlugin,e.legendEnabled])},pr=(e,t)=>{O.useEffect(()=>{Os(e,t)},[e.panEnabled,e.lineEnabled,e.pointsEnabled,e.legendEnabled,e.enableDragPoints,e.zoomEnabled])},yr=({chartRef:e,range:t,state:n,dispatch:s,annotationsData:r})=>{const o=O.useRef(n.axes);O.useEffect(()=>{if(t&&zs(t)){const i=Object.entries(t).map(([a,{min:c,max:u}])=>{const{min:g=void 0,max:p=void 0}=Rt(e,a,r)??{};let f=c??g,_=u??p;return f===_&&(_+=br),{id:a,min:f,max:_}}),l=[...o.current??[]].map(a=>{const c=i.find(u=>u.id===a.id);return c?{...a,...c}:a});bt(l,o.current)||(s({type:ye,payload:{axes:l}}),o.current=l)}},[t])},xr=({chartRef:e,options:t,state:n,dispatch:s,persistenceId:r})=>{const o=O.useMemo(()=>n,[n]),i=O.useMemo(()=>t,[t]),{additionalAxesOptions:{range:l=void 0},annotations:{annotationsData:a=[]}={}}=i;pr(o,r),hr(o,i),yr({range:l,state:o,dispatch:s,chartRef:e,annotationsData:a})},xe=" ",_r="rgba(0, 0, 0, 0.5)",Tr=e=>(Array.isArray(e)?e.join(xe):e).split(xe),Er=({ctx:e,lines:t,lineHeight:n,x:s,y:r,position:o})=>{t.forEach((i,l)=>{const a=o.includes("top")?r+n*(l+1)-5:r-(t.length-1-l)*n;e.fillText(i,s,a)})},Ar=(e,t)=>{const r=t<500?.5:t<700?.7:1;return e*r},Lr=e=>{const{legend:t}=e,n=t&&t.display&&t.options.position==="left"?t.width+t.options.labels.padding*2:0,s=t&&t.display&&(t.options.position==="top"||t.options.position==="bottom")?t.height+t.options.labels.padding*2:0;return{legendWidth:n,legendHeight:s}},Or=(e,t,n,s)=>{const{chartArea:r,width:o}=t,i=o-8,{legendWidth:l,legendHeight:a}=Lr(t);switch(e){case v.TOP_LEFT:return[r.left+n+l,r.top+s+a];case v.TOP_CENTER:return[r.left+r.width/2,r.top+s+a];case v.TOP_RIGHT:return[i-n,r.top+s+a];case v.MIDDLE_LEFT:return[r.left+n+l,r.top+r.height/2];case v.MIDDLE_CENTER:return[r.left+r.width/2,r.top+r.height/2];case v.MIDDLE_RIGHT:return[i-n-l,r.top+r.height/2];case v.BOTTOM_LEFT:return[r.left+n+l,r.bottom-s-a];case v.BOTTOM_CENTER:return[r.left+r.width/2,r.bottom-s-a];case v.BOTTOM_RIGHT:default:return[i-n-l,r.bottom-s-a]}},Sr=e=>e.includes(j.Center)?j.Center:e.includes(j.Left)?j.Left:j.Right,Cr=(e,t,n)=>{let s="",r=[];for(let o=0;o<e.length;o++){const i=`${s}${e[o]}${xe}`,{width:l}=n.measureText(i);l>t?(r.push(s.trim()),s=`${e[o]}${xe}`):s=i}return r.push(s.trim()),r},Pr=(e,t)=>{const{text:n,maxWidth:s,fontSize:r,lineHeight:o,x:i,y:l,position:a}=t,c=Tr(n),u=Cr(c,s,e);e.save(),e.font=`${r}px Arial`,e.fillStyle=_r,e.textAlign=Sr(a),Er({ctx:e,lines:u,lineHeight:o,x:i,y:l,position:a}),e.restore()},wr={id:"chartAreaText",beforeDraw:(e,t,n)=>{const{showLabel:s,text:r,fontSize:o,xOffset:i,yOffset:l,lineHeight:a,maxWidth:c,position:u}=n;if(!s||!r)return;const{ctx:g,chartArea:p}=e,f=Ar(c,p.width),[_,b]=Or(u,e,i,l);Pr(g,{text:r,maxWidth:f,fontSize:o,lineHeight:a,x:_,y:b,position:u})}},Bt=(e,t,n,s,r)=>{const o=t.getBoundingClientRect(),i=e.clientX-o.left,l=e.clientY-o.top,a=n[s],c=n[r],u=(a==null?void 0:a.getValueForPixel(i))??-1,g=(c==null?void 0:c.getValueForPixel(l))??-1;return{x:u,y:g}},_e=e=>{const{xMin:t,xMax:n,yMin:s,yMax:r,xValue:o,yValue:i,type:l}=e??{};let a,c,u,g;return!S.isNil(t)&&!S.isNil(n)&&!S.isNil(s)&&!S.isNil(r)&&l===F.BOX?(a=(t+n)/2,c=(s+r)/2,u=n-t,g=r-s):!S.isNil(o)&&!S.isNil(i)&&l===F.POINT&&(a=o,c=i,u=0,g=0),{centerX:a,centerY:c,width:u,height:g}},Vt=(e,t,n,s)=>{const{xMin:r,xMax:o,yMin:i,yMax:l,xValue:a,yValue:c,type:u}=e??{};let g,p,f,_;const b=t[n],T=t[s];if(!S.isNil(r)&&!S.isNil(o)&&!S.isNil(i)&&!S.isNil(l)&&u===F.BOX){const d=(r+o)/2,A=(i+l)/2,m=(b==null?void 0:b.getPixelForValue(r))??0,x=(b==null?void 0:b.getPixelForValue(o))??0,y=(T==null?void 0:T.getPixelForValue(i))??0,L=(T==null?void 0:T.getPixelForValue(l))??0;f=m-x,_=y-L,g=(b==null?void 0:b.getPixelForValue(d))??-1,p=(T==null?void 0:T.getPixelForValue(A))??-1}else!S.isNil(a)&&!S.isNil(c)&&u===F.POINT&&(f=0,_=0,g=(b==null?void 0:b.getPixelForValue(a))??-1,p=(T==null?void 0:T.getPixelForValue(c))??-1);return{centerX:g,centerY:p,width:f,height:_}},Dr=({x:e,y:t,chartArea:n,scales:s,metrics:r,resizable:o=!1,dragRange:i,annotationType:l,xScaleID:a,yScaleID:c})=>{if(o&&!i)return!0;if(i){const T=e!==void 0&&i.x?e>=i.x[0]&&e<=i.x[1]:!0,d=t!==void 0&&i.y?t>=i.y[0]&&t<=i.y[1]:!0;return T&&d}const u=s[a],g=s[c],p=(u==null?void 0:u.getValueForPixel(n.left))??Number.NEGATIVE_INFINITY,f=(u==null?void 0:u.getValueForPixel(n.right))??Number.POSITIVE_INFINITY,_=(g==null?void 0:g.getValueForPixel(n.bottom))??Number.NEGATIVE_INFINITY,b=(g==null?void 0:g.getValueForPixel(n.top))??Number.POSITIVE_INFINITY;if(l===F.POINT){const T=e!==void 0?e>=p&&e<=f:!0,d=t!==void 0?t>=_&&t<=b:!0;return T&&d}if(l===F.BOX&&r.width!==void 0&&r.height!==void 0){const T=e!==void 0?e-r.width/2:void 0,d=e!==void 0?e+r.width/2:void 0,A=t!==void 0?t-r.height/2:void 0,m=t!==void 0?t+r.height/2:void 0,x=T!==void 0&&d!==void 0?T>=p&&d<=f:!0,y=A!==void 0&&m!==void 0?A>=_&&m<=b:!0;return x&&y}return!0},gt=(e,t,n,s,r,o,i,l)=>{const{resizable:a,dragRange:c=null}=n??{};Dr({[e]:t,chartArea:s.chartArea,scales:r,resizable:a,dragRange:c,metrics:l||{},annotationType:n.type,xScaleID:o,yScaleID:i})&&(n.type===F.POINT?e==="x"?n.xValue=t:e==="y"&&(n.yValue=t):n.type===F.BOX&&l&&(e==="x"&&l.width&&(n.xMin=t-l.width/2,n.xMax=t+l.width/2),e==="y"&&l.height&&(n.yMin=t-l.height/2,n.yMax=t+l.height/2)))},Xt=(e,t,n)=>{var r,o,i;if(!t)return;const s=(i=(o=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:o.annotation)==null?void 0:i.annotations;s&&t&&s[t]&&(s[t].borderWidth=n)},Nr=(e,t,n,s,r,o)=>{const i=o?s==null?void 0:s[o]:null;if(!i)return;const{xScaleID:l="x",yScaleID:a="y"}=i,{x:c,y:u}=Bt(e,t,n,l,a),g=_e(i);if(i&&i.enableDrag&&!S.isNil(g.centerY)&&!S.isNil(g.centerX)){!S.isNil(t)&&!S.isNil(t.style)&&(t.style.cursor=ze.Move);const p=c-g.centerX,f=u-g.centerY;r(!0,i,p,f),i!=null&&i.onDragStart&&i.onDragStart({x:c,y:u},i)}},Mr=(e,t,n,s,r,o,i,l)=>{if(s&&r){!S.isNil(t)&&!S.isNil(t.style)&&(t.style.cursor=ze.Move);const a=r==null?void 0:r.id;Xt(l,a,Ge.HOVERED);const c=(r==null?void 0:r.dragAxis)??re.Both,{xScaleID:u="x",yScaleID:g="y"}=r,{x:p,y:f}=Bt(e,t,n,u,g),_=_e(r);let b=p-o,T=f-i;c!==re.Y&&gt(re.X,b,r,l,n,u,g,_),c!==re.X&&gt(re.Y,T,r,l,n,u,g,_),l.update(),r!=null&&r.onDrag&&r.onDrag({x:p,y:f},r);const{ctx:d,width:A,height:m}=l,{centerX:x,centerY:y}=_e(r)??{},{centerX:L,centerY:E}=Vt(r,n,u,g);if(!S.isNil(x)&&!S.isNil(y)&&!S.isNil(L)&&!S.isNil(E)&&(d.save(),d.clearRect(0,0,A,m),l.draw(),d.font=an,d.fillStyle="black",r!=null&&r.displayDragCoordinates)){let C=L-45,P=E-20;const D=`X: ${Q(x,2)}, Y: ${Q(y,2)}`,w=14;P-w<0&&(P=E+w+15),P>m&&(P=m-7),d.fillText(D,C,P),d.restore()}}},Ir=(e,t,n,s,r)=>{if(e&&t){const o=t==null?void 0:t.id;Xt(n,o,Ge.ZERO);const{centerX:i=-1,centerY:l=-1}=_e(t)??{};S.isNil(t==null?void 0:t.onDragEnd)||t==null||t.onDragEnd({x:i,y:l},t),!S.isNil(s)&&!S.isNil(s.style)&&(s.style.cursor=ze.Pointer),r(!1,null)}},vr=(e,t,n)=>{Object.values(t).forEach(s=>{var r;if(s.type===F.POINT&&!S.isNil(s==null?void 0:s.label)&&((r=s==null?void 0:s.label)!=null&&r.display)){const{content:o,font:i,color:l,position:a,padding:c}=(s==null?void 0:s.label)??{},{xScaleID:u="x",yScaleID:g="y"}=s;e.save(),e.font=i,e.fillStyle=l;const{centerX:p=-1,centerY:f=-1}=Vt(s,n,u,g),_=e.measureText(o).width;let b=p-_/2,T=f+20;switch(a){case oe.Top:T=f-20;break;case oe.Left:b=p-_-c,T=f;break;case oe.Right:b=p+c,T=f;break}e.fillText(o,b,T),e.restore()}})},jr={id:"annotationDraggerPlugin",beforeDraw(e){var s,r,o,i,l,a,c,u;let t=((r=(s=e.options.plugins)==null?void 0:s.annotation)==null?void 0:r.annotations)??{};if(!t)return;vr(e.ctx,t,e.scales),(((i=(o=e==null?void 0:e.options)==null?void 0:o.plugins)==null?void 0:i.annotationDraggerPlugin)||{enabled:!1}).enabled?((a=(l=e==null?void 0:e.options)==null?void 0:l.plugins)!=null&&a.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((u=(c=e==null?void 0:e.options)==null?void 0:c.plugins)!=null&&u.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:ge.Nearest,intersect:!0})},afterUpdate(e){var p,f,_,b,T,d,A,m;const{canvas:t,scales:n,hoveredAnnotationId:s}=e??{},r=((f=(p=e==null?void 0:e.options)==null?void 0:p.plugins)==null?void 0:f.annotationDraggerPlugin)||{enabled:!1},o={...n,x:n.x,y:n.y};let i=((b=(_=e.options.plugins)==null?void 0:_.annotation)==null?void 0:b.annotations)??{};if(!e&&!i)return;r.enabled?((d=(T=e==null?void 0:e.options)==null?void 0:T.plugins)!=null&&d.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((m=(A=e==null?void 0:e.options)==null?void 0:A.plugins)!=null&&m.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:ge.Nearest,intersect:!0});let l=!1,a,c,u=null;const g=(x,y,L,E)=>{l=x,u=y,L!==void 0&&E!==void 0&&(a=L,c=E)};!t.dataset.annotationDraggerInitialized&&r.enabled&&s&&(t.addEventListener(Z.MOUSEDOWN,x=>{var y,L,E;Nr(x,t,o,(E=(L=(y=e==null?void 0:e.options)==null?void 0:y.plugins)==null?void 0:L.annotation)==null?void 0:E.annotations,g,e.hoveredAnnotationId)}),t.addEventListener(Z.MOUSEMOVE,x=>{S.debounce(()=>Mr(x,t,o,l,u,a,c,e),5)()}),t.addEventListener(Z.MOUSEUP,x=>{const y=x.currentTarget;Ir(l,u,e,y,g)}),t.dataset.annotationDraggerInitialized="true"),r.enabled||(t.removeEventListener(Z.MOUSEDOWN,()=>{}),t.removeEventListener(Z.MOUSEMOVE,()=>{}),t.removeEventListener(Z.MOUSEUP,()=>{}),t.dataset.annotationDraggerInitialized="")}};gn.register(mn,bn,hn,pn,yn,xn,_n,Tn,En,An,Ln,es,wr,jr);const Fr=e=>{var D,w;cn();const t=O.useRef(null),{table:n,headerComponent:s,subheaderComponent:r}=e??{},{translations:o,languageKey:i}=rs(),l=kt(e),{data:{datasets:a}={datasets:[]},options:c,testId:u,persistenceId:g,controlsPortalId:p}=l,{annotations:f,axes:_,chartStyling:b,graph:T}=c??{},d=!((w=(D=c==null?void 0:c.legend)==null?void 0:D.customLegend)!=null&&w.customLegendContainerID),[A,m]=O.useReducer(Es,{options:c,persistenceId:g,chartRef:t},Ss),x=O.useMemo(()=>er(a,A,c,o),[A.lineEnabled,A.pointsEnabled,a,_,f,T]);xr({chartRef:t,options:c,state:A,dispatch:m,persistenceId:g});const{resetZoom:y,handleKeyDown:L,handleKeyUp:E}=Xe({chartRef:t,state:A,options:c,dispatch:m,generatedDatasets:x}),C=gr({chartRef:t,state:A,options:c,dispatch:m,generatedDatasets:x}),P=mr({options:c,resetZoom:y});return h.jsxs("div",{className:dn(b,Se),style:{width:b.width||De,height:b.height||De},tabIndex:0,onKeyDown:L,onKeyUp:E,"data-testid":u,children:[h.jsx(Ft,{table:n,headerComponent:s,subheaderComponent:r,chartRef:t,state:A,options:c,dispatch:m,generatedDatasets:x,translations:o,controlsPortalId:p}),n&&A.showTable?h.jsx("div",{className:Se.table,children:n}):h.jsx(Zn,{backend:Kn,context:window,children:h.jsxs("div",{className:Se.canvas,id:"canvas",children:[h.jsx(fn,{ref:t,data:{datasets:x},options:C,plugins:P}),d&&!!x.length&&h.jsx(Jn,{chartRef:t,legendConfig:{options:c,generatedDatasets:x,chartType:Qn.LINE}})]})})]},Gs([...Object.values(A),i]))},kr=e=>{const{options:t}=kt(e);return h.jsx(un,{options:t,children:h.jsx(Fr,{...e})})};kr.__docgenInfo={description:"",methods:[],displayName:"LineChartWithLegend",props:{chart:{required:!0,tsType:{name:"ILineChartData"},description:""},table:{required:!1,tsType:{name:"ReactNode"},description:""},headerComponent:{required:!1,tsType:{name:"ReactNode"},description:""},subheaderComponent:{required:!1,tsType:{name:"ReactNode"},description:""}}};export{kr as L,Hr as i};